From 2e61839d93728d4193b5542558369f8cf05be61d Mon Sep 17 00:00:00 2001 From: EmosewaMC <39972741+EmosewaMC@users.noreply.github.com> Date: Fri, 22 Apr 2022 00:10:15 -0700 Subject: [PATCH 01/12] isPlayer changes Changed isPlayer to check for whether the entity has a character instead of checking system address of entity. --- dGame/Entity.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dGame/Entity.cpp b/dGame/Entity.cpp index 57b7af14..780ae45c 100644 --- a/dGame/Entity.cpp +++ b/dGame/Entity.cpp @@ -1739,7 +1739,7 @@ void Entity::CancelAllTimers() { } bool Entity::IsPlayer() const { - return m_TemplateID == 1 && GetSystemAddress() != UNASSIGNED_SYSTEM_ADDRESS; + return m_TemplateID == 1 && GetCharacter() != nullptr; } void Entity::TriggerEvent(std::string eventID, Entity* optionalTarget) { From 834b53b4ecbb51978b6afa63b7933a06886dfcb5 Mon Sep 17 00:00:00 2001 From: EmosewaMC <39972741+EmosewaMC@users.noreply.github.com> Date: Sat, 23 Apr 2022 04:13:23 -0700 Subject: [PATCH 02/12] Grammar error Level reward needed an underscore --- dCommon/dCommonVars.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dCommon/dCommonVars.h b/dCommon/dCommonVars.h index 680c0c1e..cbecdd37 100644 --- a/dCommon/dCommonVars.h +++ b/dCommon/dCommonVars.h @@ -493,7 +493,7 @@ enum eLootSourceType : int32_t { LOOT_SOURCE_CLAIMCODE, LOOT_SOURCE_CONSUMPTION, LOOT_SOURCE_CRAFTING, - LOOT_SOURCE_LEVELREWARD, + LOOT_SOURCE_LEVEL_REWARD, LOOT_SOURCE_RELOCATE }; From d0233a2cd064c78d2aa21dee0a7bacfb516204d0 Mon Sep 17 00:00:00 2001 From: EmosewaMC <39972741+EmosewaMC@users.noreply.github.com> Date: Sat, 23 Apr 2022 04:14:55 -0700 Subject: [PATCH 03/12] Updated AddItemToInventorySync AddItemToInventorySync now sends the correct loot source type --- dGame/dGameMessages/GameMessages.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dGame/dGameMessages/GameMessages.cpp b/dGame/dGameMessages/GameMessages.cpp index 9e68941c..881b6ff5 100644 --- a/dGame/dGameMessages/GameMessages.cpp +++ b/dGame/dGameMessages/GameMessages.cpp @@ -411,7 +411,7 @@ void GameMessages::SendGMLevelBroadcast(const LWOOBJID& objectID, uint8_t level) SEND_PACKET_BROADCAST } -void GameMessages::SendAddItemToInventoryClientSync(Entity* entity, const SystemAddress& sysAddr, Item* item, const LWOOBJID& objectID, bool showFlyingLoot, int itemCount, LWOOBJID subKey) { +void GameMessages::SendAddItemToInventoryClientSync(Entity* entity, const SystemAddress& sysAddr, Item* item, const LWOOBJID& objectID, bool showFlyingLoot, int itemCount, LWOOBJID subKey, eLootSourceType lootSourceType) { CBITSTREAM CMSGHEADER @@ -421,8 +421,8 @@ void GameMessages::SendAddItemToInventoryClientSync(Entity* entity, const System bitStream.Write(item->GetInfo().isBOE); bitStream.Write(item->GetInfo().isBOP); - bitStream.Write0(); // Loot source - //if (invType != LOOTTYPE_NONE) bitStream.Write(invType); + bitStream.Write(lootSourceType != eLootSourceType::LOOT_SOURCE_NONE); // Loot source + if (lootSourceType != eLootSourceType::LOOT_SOURCE_NONE) bitStream.Write(lootSourceType); LWONameValue extraInfo; From 0eece14b6849cb1cbf71436bb4a86928c19cdd5f Mon Sep 17 00:00:00 2001 From: EmosewaMC <39972741+EmosewaMC@users.noreply.github.com> Date: Sat, 23 Apr 2022 04:16:10 -0700 Subject: [PATCH 04/12] Vendor buyback inventory Fixed vendor buyback inventory so it properly scrolls when the player adds enough items to it. --- dGame/dComponents/InventoryComponent.cpp | 4 +++- dGame/dInventory/Inventory.cpp | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/dGame/dComponents/InventoryComponent.cpp b/dGame/dComponents/InventoryComponent.cpp index 5d3dda2e..cca5dde0 100644 --- a/dGame/dComponents/InventoryComponent.cpp +++ b/dGame/dComponents/InventoryComponent.cpp @@ -88,7 +88,9 @@ Inventory* InventoryComponent::GetInventory(const eInventoryType type) case eInventoryType::VAULT_ITEMS: size = 40u; break; - + case eInventoryType::VENDOR_BUYBACK: + size = 27u; + break; default: break; } diff --git a/dGame/dInventory/Inventory.cpp b/dGame/dInventory/Inventory.cpp index b77be4b2..ae1715d7 100644 --- a/dGame/dInventory/Inventory.cpp +++ b/dGame/dInventory/Inventory.cpp @@ -90,17 +90,17 @@ int32_t Inventory::FindEmptySlot() { if (free <= 6) // Up from 1 { - if (type != ITEMS && type != VAULT_ITEMS) + if (type != ITEMS && type != VAULT_ITEMS && type != eInventoryType::VAULT_MODELS) { uint32_t newSize = size; - if (type == MODELS || type == VAULT_MODELS) + if (type == MODELS) { newSize = 240; } - else + else if (type == eInventoryType::VENDOR_BUYBACK) { - newSize += 20; + newSize += 9u; } if (newSize > GetSize()) From a4d934913c3ecf181ce3174ad8c41eaf211cb196 Mon Sep 17 00:00:00 2001 From: EmosewaMC <39972741+EmosewaMC@users.noreply.github.com> Date: Sat, 23 Apr 2022 05:13:06 -0700 Subject: [PATCH 05/12] added lootsource send in GM WIP commit --- dGame/Entity.cpp | 2 +- dGame/TradingManager.cpp | 4 ++-- dGame/dComponents/CharacterComponent.cpp | 2 +- dGame/dComponents/InventoryComponent.cpp | 17 ++++++++++------- dGame/dComponents/InventoryComponent.h | 3 ++- dGame/dComponents/PetComponent.cpp | 2 +- .../dComponents/PropertyManagementComponent.cpp | 4 ++-- dGame/dGameMessages/GameMessages.cpp | 16 ++++++++-------- dGame/dGameMessages/GameMessages.h | 2 +- dGame/dInventory/Item.cpp | 15 ++++++++------- dGame/dInventory/Item.h | 6 ++++-- dGame/dMission/Mission.cpp | 4 ++-- dGame/dUtilities/Loot.cpp | 2 +- dGame/dUtilities/Mail.cpp | 2 +- dGame/dUtilities/SlashCommandHandler.cpp | 6 +++--- dScripts/AmDropshipComputer.cpp | 2 +- dScripts/NPCAddRemoveItem.cpp | 2 +- dScripts/NjColeNPC.cpp | 2 +- dScripts/NjScrollChestServer.cpp | 2 +- dScripts/NpcCowboyServer.cpp | 2 +- dScripts/NpcPirateServer.cpp | 2 +- dScripts/NpcWispServer.cpp | 2 +- dScripts/NsConcertInstrument.cpp | 4 ++-- dScripts/NsTokenConsoleServer.cpp | 8 ++++---- dScripts/NtDukeServer.cpp | 2 +- dScripts/SGCannon.cpp | 2 +- dScripts/TokenConsoleServer.cpp | 12 +++++++----- dScripts/VeBricksampleServer.cpp | 2 +- dScripts/VeMissionConsole.cpp | 2 +- 29 files changed, 71 insertions(+), 62 deletions(-) diff --git a/dGame/Entity.cpp b/dGame/Entity.cpp index 780ae45c..8a1d3c82 100644 --- a/dGame/Entity.cpp +++ b/dGame/Entity.cpp @@ -1637,7 +1637,7 @@ void Entity::PickupItem(const LWOOBJID& objectID) { } } else { - inv->AddItem(p.second.lot, p.second.count, INVALID, {}, LWOOBJID_EMPTY, true, false, LWOOBJID_EMPTY, INVALID, 1); + inv->AddItem(p.second.lot, p.second.count, INVALID, {}, LWOOBJID_EMPTY, true, false, LWOOBJID_EMPTY, INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_PICKUP); } } } diff --git a/dGame/TradingManager.cpp b/dGame/TradingManager.cpp index 0963aa6f..e178d130 100644 --- a/dGame/TradingManager.cpp +++ b/dGame/TradingManager.cpp @@ -170,12 +170,12 @@ void Trade::Complete() for (const auto& tradeItem : m_ItemsA) { - inventoryB->AddItem(tradeItem.itemLot, tradeItem.itemCount); + inventoryB->AddItem(tradeItem.itemLot, tradeItem.itemCount, eInventoryType::INVALID, {}, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_TRADE); } for (const auto& tradeItem : m_ItemsB) { - inventoryA->AddItem(tradeItem.itemLot, tradeItem.itemCount); + inventoryA->AddItem(tradeItem.itemLot, tradeItem.itemCount, eInventoryType::INVALID, {}, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_TRADE); } TradingManager::Instance()->CancelTrade(m_TradeId); diff --git a/dGame/dComponents/CharacterComponent.cpp b/dGame/dComponents/CharacterComponent.cpp index 590758b6..67b820c2 100644 --- a/dGame/dComponents/CharacterComponent.cpp +++ b/dGame/dComponents/CharacterComponent.cpp @@ -217,7 +217,7 @@ void CharacterComponent::HandleLevelUp() switch (reward->rewardType) { case 0: - inventoryComponent->AddItem(reward->value, reward->count); + inventoryComponent->AddItem(reward->value, reward->count, eInventoryType::INVALID, {}, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_LEVEL_REWARD); break; case 4: { diff --git a/dGame/dComponents/InventoryComponent.cpp b/dGame/dComponents/InventoryComponent.cpp index cca5dde0..d7a059a0 100644 --- a/dGame/dComponents/InventoryComponent.cpp +++ b/dGame/dComponents/InventoryComponent.cpp @@ -150,7 +150,8 @@ void InventoryComponent::AddItem( const eInventoryType inventorySourceType, const int32_t sourceType, const bool bound, - int32_t preferredSlot) + int32_t preferredSlot, + eLootSourceType lootSourceType) { if (count == 0) { @@ -188,8 +189,7 @@ void InventoryComponent::AddItem( return; } - - auto* item = new Item(lot, inventory, slot, count, config, parent, showFlyingLoot, isModMoveAndEquip, subKey, bound); + auto* item = new Item(lot, inventory, slot, count, config, parent, showFlyingLoot, isModMoveAndEquip, subKey, bound, lootSourceType); if (missions != nullptr && !IsTransferInventory(inventoryType)) { @@ -255,6 +255,9 @@ void InventoryComponent::AddItem( if (slot == -1) { + // if (inventoryType == eInventoryType::VAULT_ITEMS || inventoryType == eInventoryType::VAULT_MODELS) { + + // } auto* player = dynamic_cast(GetParent()); if (player == nullptr) @@ -284,8 +287,8 @@ void InventoryComponent::AddItem( continue; } - - auto* item = new Item(lot, inventory, slot, size, {}, parent, showFlyingLoot, isModMoveAndEquip, subKey); + Game::logger->Log("InventoryComponent", "new item with source %i\n", lootSourceType); + auto* item = new Item(lot, inventory, slot, size, {}, parent, showFlyingLoot, isModMoveAndEquip, subKey, false, lootSourceType); isModMoveAndEquip = false; } @@ -369,7 +372,7 @@ void InventoryComponent::MoveItemToInventory(Item* item, const eInventoryType in left -= delta; - AddItem(lot, delta, inventory, {}, LWOOBJID_EMPTY, showFlyingLot, isModMoveAndEquip, LWOOBJID_EMPTY, origin->GetType(), 0, false, preferredSlot); + AddItem(lot, delta, inventory, {}, LWOOBJID_EMPTY, showFlyingLot, isModMoveAndEquip, LWOOBJID_EMPTY, origin->GetType(), 0, false, preferredSlot, eLootSourceType::LOOT_SOURCE_NONE); item->SetCount(item->GetCount() - delta, false, false); @@ -387,7 +390,7 @@ void InventoryComponent::MoveItemToInventory(Item* item, const eInventoryType in const auto delta = std::min(item->GetCount(), count); - AddItem(lot, delta, inventory, config, LWOOBJID_EMPTY, showFlyingLot, isModMoveAndEquip, LWOOBJID_EMPTY, origin->GetType(), 0, item->GetBound(), preferredSlot); + AddItem(lot, delta, inventory, config, LWOOBJID_EMPTY, showFlyingLot, isModMoveAndEquip, LWOOBJID_EMPTY, origin->GetType(), 0, item->GetBound(), preferredSlot, eLootSourceType::LOOT_SOURCE_NONE); item->SetCount(item->GetCount() - delta, false, false); } diff --git a/dGame/dComponents/InventoryComponent.h b/dGame/dComponents/InventoryComponent.h index 0a4cfdb3..d73ee51d 100644 --- a/dGame/dComponents/InventoryComponent.h +++ b/dGame/dComponents/InventoryComponent.h @@ -100,7 +100,8 @@ public: eInventoryType inventorySourceType = INVALID, int32_t sourceType = 0, bool bound = false, - int32_t preferredSlot = -1 + int32_t preferredSlot = -1, + eLootSourceType lootSourceType = eLootSourceType::LOOT_SOURCE_NONE ); /** diff --git a/dGame/dComponents/PetComponent.cpp b/dGame/dComponents/PetComponent.cpp index a5c1168d..4b61384d 100644 --- a/dGame/dComponents/PetComponent.cpp +++ b/dGame/dComponents/PetComponent.cpp @@ -615,7 +615,7 @@ void PetComponent::NotifyTamingBuildSuccess(NiPoint3 position) GameMessages::SendRegisterPetDBID(m_Tamer, petSubKey, tamer->GetSystemAddress()); - inventoryComponent->AddItem(m_Parent->GetLOT(), 1, MODELS, {}, LWOOBJID_EMPTY, true, false, petSubKey); + inventoryComponent->AddItem(m_Parent->GetLOT(), 1, MODELS, {}, LWOOBJID_EMPTY, true, false, petSubKey, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_ACTIVITY); auto* item = inventoryComponent->FindItemBySubKey(petSubKey, MODELS); if (item == nullptr) diff --git a/dGame/dComponents/PropertyManagementComponent.cpp b/dGame/dComponents/PropertyManagementComponent.cpp index f982326c..ad0ec7c3 100644 --- a/dGame/dComponents/PropertyManagementComponent.cpp +++ b/dGame/dComponents/PropertyManagementComponent.cpp @@ -491,7 +491,7 @@ void PropertyManagementComponent::DeleteModel(const LWOOBJID id, const int delet settings.push_back(propertyObjectID); settings.push_back(modelType); - inventoryComponent->AddItem(6662, 1, HIDDEN, settings, LWOOBJID_EMPTY, false, false, spawnerId, INVALID, 13, false, -1); + inventoryComponent->AddItem(6662, 1, HIDDEN, settings, LWOOBJID_EMPTY, false, false, spawnerId, INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_DELETION); auto* item = inventoryComponent->FindItemBySubKey(spawnerId); if (item == nullptr) { @@ -526,7 +526,7 @@ void PropertyManagementComponent::DeleteModel(const LWOOBJID id, const int delet return; } - inventoryComponent->AddItem(model->GetLOT(), 1, INVALID, {}, LWOOBJID_EMPTY, false); + inventoryComponent->AddItem(model->GetLOT(), 1, INVALID, {}, LWOOBJID_EMPTY, false, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_DELETION); auto* item = inventoryComponent->FindItemByLot(model->GetLOT()); diff --git a/dGame/dGameMessages/GameMessages.cpp b/dGame/dGameMessages/GameMessages.cpp index 881b6ff5..d363f437 100644 --- a/dGame/dGameMessages/GameMessages.cpp +++ b/dGame/dGameMessages/GameMessages.cpp @@ -423,7 +423,7 @@ void GameMessages::SendAddItemToInventoryClientSync(Entity* entity, const System bitStream.Write(lootSourceType != eLootSourceType::LOOT_SOURCE_NONE); // Loot source if (lootSourceType != eLootSourceType::LOOT_SOURCE_NONE) bitStream.Write(lootSourceType); - + Game::logger->Log("GameMessages", "lootSource %i\n", lootSourceType); LWONameValue extraInfo; auto config = item->GetConfig(); @@ -451,8 +451,8 @@ void GameMessages::SendAddItemToInventoryClientSync(Entity* entity, const System auto* inventory = item->GetInventory(); const auto inventoryType = inventory->GetType(); - bitStream.Write(inventoryType != INVENTORY_DEFAULT); - if (inventoryType != INVENTORY_DEFAULT) bitStream.Write(inventoryType); + bitStream.Write(inventoryType != eInventoryType::ITEMS); + if (inventoryType != eInventoryType::ITEMS) bitStream.Write(inventoryType); bitStream.Write(itemCount != 1); if (itemCount != 1) bitStream.Write(itemCount); @@ -4700,7 +4700,7 @@ void GameMessages::HandleBuyFromVendor(RakNet::BitStream* inStream, Entity* enti inv->RemoveItem(tokenId, altCurrencyCost); - inv->AddItem(item, count); + inv->AddItem(item, count, eInventoryType::INVALID, {}, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_VENDOR); } else { @@ -4726,7 +4726,7 @@ void GameMessages::HandleBuyFromVendor(RakNet::BitStream* inStream, Entity* enti } character->SetCoins(character->GetCoins() - (coinCost), LOOT_SOURCE_VENDOR); - inv->AddItem(item, count); + inv->AddItem(item, count, eInventoryType::INVALID, {}, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_VENDOR); } GameMessages::SendVendorTransactionResult(entity, sysAddr); @@ -4769,7 +4769,7 @@ void GameMessages::HandleSellToVendor(RakNet::BitStream* inStream, Entity* entit if (Inventory::IsValidItem(itemComp.currencyLOT)) { const auto altCurrency = (itemComp.altCurrencyCost * sellScalar) * count; - inv->AddItem(itemComp.currencyLOT, std::floor(altCurrency)); // Return alt currencies like faction tokens. + inv->AddItem(itemComp.currencyLOT, std::floor(altCurrency), eInventoryType::INVALID, {}, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_VENDOR); // Return alt currencies like faction tokens. } //inv->RemoveItem(count, -1, iObjID); @@ -5590,11 +5590,11 @@ void GameMessages::HandleModularBuildFinish(RakNet::BitStream* inStream, Entity* if (count == 3) { - inv->AddItem(6416, 1, MODELS, config); + inv->AddItem(6416, 1, eInventoryType::MODELS, config, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_QUICKBUILD); } else if (count == 7) { - inv->AddItem(8092, 1, MODELS, config); + inv->AddItem(8092, 1, eInventoryType::MODELS, config, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_QUICKBUILD); } auto* missionComponent = character->GetComponent(); diff --git a/dGame/dGameMessages/GameMessages.h b/dGame/dGameMessages/GameMessages.h index ababed5f..f3997200 100644 --- a/dGame/dGameMessages/GameMessages.h +++ b/dGame/dGameMessages/GameMessages.h @@ -61,7 +61,7 @@ namespace GameMessages { void SendGMLevelBroadcast(const LWOOBJID& objectID, uint8_t level); void SendChatModeUpdate(const LWOOBJID& objectID, uint8_t level); - void SendAddItemToInventoryClientSync(Entity* entity, const SystemAddress& sysAddr, Item* item, const LWOOBJID& objectID, bool showFlyingLoot, int itemCount, LWOOBJID subKey = LWOOBJID_EMPTY); + void SendAddItemToInventoryClientSync(Entity* entity, const SystemAddress& sysAddr, Item* item, const LWOOBJID& objectID, bool showFlyingLoot, int itemCount, LWOOBJID subKey = LWOOBJID_EMPTY, eLootSourceType lootSourceType = eLootSourceType::LOOT_SOURCE_NONE); void SendNotifyClientFlagChange(const LWOOBJID& objectID, int iFlagID, bool bFlag, const SystemAddress& sysAddr); void SendChangeObjectWorldState(const LWOOBJID& objectID, int state, const SystemAddress& sysAddr); diff --git a/dGame/dInventory/Item.cpp b/dGame/dInventory/Item.cpp index 20f5321a..31601673 100644 --- a/dGame/dInventory/Item.cpp +++ b/dGame/dInventory/Item.cpp @@ -14,7 +14,7 @@ class Inventory; -Item::Item(const LWOOBJID id, const LOT lot, Inventory* inventory, const uint32_t slot, const uint32_t count, const bool bound, const std::vector& config, const LWOOBJID parent, LWOOBJID subKey) +Item::Item(const LWOOBJID id, const LOT lot, Inventory* inventory, const uint32_t slot, const uint32_t count, const bool bound, const std::vector& config, const LWOOBJID parent, LWOOBJID subKey, eLootSourceType lootSourceType) { if (!Inventory::IsValidItem(lot)) { @@ -46,7 +46,8 @@ Item::Item( bool showFlyingLoot, bool isModMoveAndEquip, LWOOBJID subKey, - bool bound) + bool bound, + eLootSourceType lootSourceType) { if (!Inventory::IsValidItem(lot)) { @@ -80,8 +81,8 @@ Item::Item( inventory->AddManagedItem(this); auto* entity = inventory->GetComponent()->GetParent(); - - GameMessages::SendAddItemToInventoryClientSync(entity, entity->GetSystemAddress(), this, id, showFlyingLoot, static_cast(this->count), subKey); + Game::logger->Log("test", "source %i\n", lootSourceType); + GameMessages::SendAddItemToInventoryClientSync(entity, entity->GetSystemAddress(), this, id, showFlyingLoot, static_cast(this->count), subKey, lootSourceType); if (isModMoveAndEquip) { @@ -176,7 +177,7 @@ void Item::SetCount(const uint32_t value, const bool silent, const bool disassem if (value > count) { - GameMessages::SendAddItemToInventoryClientSync(entity, entity->GetSystemAddress(), this, id, showFlyingLoot, delta); + GameMessages::SendAddItemToInventoryClientSync(entity, entity->GetSystemAddress(), this, id, showFlyingLoot, delta, 0LL); } else { @@ -374,7 +375,7 @@ void Item::Disassemble(const eInventoryType inventoryType) for (const auto mod : modArray) { - inventory->GetComponent()->AddItem(mod, 1, inventoryType); + inventory->GetComponent()->AddItem(mod, 1, inventoryType, {}, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_DELETION); } } } @@ -472,7 +473,7 @@ void Item::DisassembleModel() continue; } - GetInventory()->GetComponent()->AddItem(brickID[0].NDObjectID, 1); + GetInventory()->GetComponent()->AddItem(brickID[0].NDObjectID, 1, eInventoryType::INVALID, {}, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_DELETION); } } diff --git a/dGame/dInventory/Item.h b/dGame/dInventory/Item.h index 83ebb633..dd81d7fe 100644 --- a/dGame/dInventory/Item.h +++ b/dGame/dInventory/Item.h @@ -36,7 +36,8 @@ public: bool bound, const std::vector& config, LWOOBJID parent, - LWOOBJID subKey + LWOOBJID subKey, + eLootSourceType lootSourceType = eLootSourceType::LOOT_SOURCE_NONE ); /** @@ -62,7 +63,8 @@ public: bool showFlyingLoot = true, bool isModMoveAndEquip = false, LWOOBJID subKey = LWOOBJID_EMPTY, - bool bound = false + bool bound = false, + eLootSourceType lootSourceType = eLootSourceType::LOOT_SOURCE_NONE ); ~Item(); diff --git a/dGame/dMission/Mission.cpp b/dGame/dMission/Mission.cpp index 14fc5a24..93a60ae9 100644 --- a/dGame/dMission/Mission.cpp +++ b/dGame/dMission/Mission.cpp @@ -463,7 +463,7 @@ void Mission::YieldRewards() { count = 0; } - inventoryComponent->AddItem(pair.first, count); + inventoryComponent->AddItem(pair.first, count, eInventoryType::INVALID, {}, 0LL, IsMission(), false, 0LL, eInventoryType::INVALID, 0, false, -1, IsMission() ? eLootSourceType::LOOT_SOURCE_MISSION : eLootSourceType::LOOT_SOURCE_ACHIEVEMENT); } if (info->reward_currency_repeatable > 0 || coinsToSend > 0) { @@ -496,7 +496,7 @@ void Mission::YieldRewards() { count = 0; } - inventoryComponent->AddItem(pair.first, count); + inventoryComponent->AddItem(pair.first, count, eInventoryType::INVALID, {}, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, IsMission() ? eLootSourceType::LOOT_SOURCE_MISSION : eLootSourceType::LOOT_SOURCE_ACHIEVEMENT); } if (info->reward_currency > 0 || coinsToSend > 0) { diff --git a/dGame/dUtilities/Loot.cpp b/dGame/dUtilities/Loot.cpp index 635b2620..0cceaeb2 100644 --- a/dGame/dUtilities/Loot.cpp +++ b/dGame/dUtilities/Loot.cpp @@ -285,7 +285,7 @@ void LootGenerator::GiveLoot(Entity* player, std::unordered_map& r return; for (const auto& pair : result) { - inventoryComponent->AddItem(pair.first, pair.second); + inventoryComponent->AddItem(pair.first, pair.second, eInventoryType::INVALID, {}, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_ACTIVITY); } } diff --git a/dGame/dUtilities/Mail.cpp b/dGame/dUtilities/Mail.cpp index 302ba1cd..d0718f4c 100644 --- a/dGame/dUtilities/Mail.cpp +++ b/dGame/dUtilities/Mail.cpp @@ -363,7 +363,7 @@ void Mail::HandleAttachmentCollect(RakNet::BitStream* packet, const SystemAddres auto inv = static_cast(player->GetComponent(COMPONENT_TYPE_INVENTORY)); if (!inv) return; - inv->AddItem(attachmentLOT, attachmentCount); + inv->AddItem(attachmentLOT, attachmentCount, eInventoryType::INVALID, {}, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_MAIL); Mail::SendAttachmentRemoveConfirm(sysAddr, mailID); diff --git a/dGame/dUtilities/SlashCommandHandler.cpp b/dGame/dUtilities/SlashCommandHandler.cpp index 2e3e2be7..69ee60b0 100644 --- a/dGame/dUtilities/SlashCommandHandler.cpp +++ b/dGame/dUtilities/SlashCommandHandler.cpp @@ -794,7 +794,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit InventoryComponent * inventory = static_cast(entity->GetComponent(COMPONENT_TYPE_INVENTORY)); - inventory->AddItem(itemLOT, 1); + inventory->AddItem(itemLOT, 1, eInventoryType::INVALID, {}, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_MODERATION); } else if(args.size() == 2) { uint32_t itemLOT; @@ -814,7 +814,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit InventoryComponent* inventory = static_cast(entity->GetComponent(COMPONENT_TYPE_INVENTORY)); - inventory->AddItem(itemLOT, count); + inventory->AddItem(itemLOT, count, eInventoryType::INVALID, {}, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_MODERATION); } else { ChatPackets::SendSystemMessage(sysAddr, u"Correct usage: /gmadditem "); @@ -1626,7 +1626,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit std::vector data {}; data.push_back(new LDFData(u"reforgedLOT", reforgedItem)); - inventoryComponent->AddItem(baseItem, 1, INVALID, data); + inventoryComponent->AddItem(baseItem, 1, eInventoryType::INVALID, data, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_MODERATION); } if (chatCommand == "crash" && entity->GetGMLevel() >= GAME_MASTER_LEVEL_OPERATOR) diff --git a/dScripts/AmDropshipComputer.cpp b/dScripts/AmDropshipComputer.cpp index 4101f526..7f25574a 100644 --- a/dScripts/AmDropshipComputer.cpp +++ b/dScripts/AmDropshipComputer.cpp @@ -32,7 +32,7 @@ void AmDropshipComputer::OnUse(Entity* self, Entity* user) return; } - inventoryComponent->AddItem(12323, 1); + inventoryComponent->AddItem(12323, 1, eInventoryType::INVALID, {}, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_ACTIVITY); } void AmDropshipComputer::OnDie(Entity* self, Entity* killer) diff --git a/dScripts/NPCAddRemoveItem.cpp b/dScripts/NPCAddRemoveItem.cpp index 7d36c1e1..8cc2b6fd 100644 --- a/dScripts/NPCAddRemoveItem.cpp +++ b/dScripts/NPCAddRemoveItem.cpp @@ -11,7 +11,7 @@ void NPCAddRemoveItem::OnMissionDialogueOK(Entity *self, Entity *target, int mis for (const auto& itemSetting : missionSetting.second) { for (const auto& lot : itemSetting.items) { if (itemSetting.add && (missionState == MissionState::MISSION_STATE_AVAILABLE || missionState == MissionState::MISSION_STATE_COMPLETE_AVAILABLE)) { - inventory->AddItem(lot, 1); + inventory->AddItem(lot, 1, eInventoryType::INVALID, {}, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_ACTIVITY); } else if (itemSetting.remove && (missionState == MissionState::MISSION_STATE_READY_TO_COMPLETE || missionState == MissionState::MISSION_STATE_COMPLETE_READY_TO_COMPLETE)) { inventory->RemoveItem(lot, 1); } diff --git a/dScripts/NjColeNPC.cpp b/dScripts/NjColeNPC.cpp index 54d38bda..e342e429 100644 --- a/dScripts/NjColeNPC.cpp +++ b/dScripts/NjColeNPC.cpp @@ -54,6 +54,6 @@ void NjColeNPC::OnMissionDialogueOK(Entity* self, Entity* target, int missionID, return; } - inventoryComponent->AddItem(16644, 1); + inventoryComponent->AddItem(16644, 1, eInventoryType::INVALID, {}, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_VENDOR); } } diff --git a/dScripts/NjScrollChestServer.cpp b/dScripts/NjScrollChestServer.cpp index ba3fda7a..4677f827 100644 --- a/dScripts/NjScrollChestServer.cpp +++ b/dScripts/NjScrollChestServer.cpp @@ -12,6 +12,6 @@ void NjScrollChestServer::OnUse(Entity *self, Entity *user) { playerInventory->RemoveItem(keyLOT, 1); // Reward the player with the item set - playerInventory->AddItem(rewardItemLOT, 1); + playerInventory->AddItem(rewardItemLOT, 1, eInventoryType::INVALID, {}, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_ACTIVITY); } } diff --git a/dScripts/NpcCowboyServer.cpp b/dScripts/NpcCowboyServer.cpp index 7ec031b9..b92d921f 100644 --- a/dScripts/NpcCowboyServer.cpp +++ b/dScripts/NpcCowboyServer.cpp @@ -23,7 +23,7 @@ void NpcCowboyServer::OnMissionDialogueOK(Entity* self, Entity* target, int miss { if (inventoryComponent->GetLotCount(14378) == 0) { - inventoryComponent->AddItem(14378, 1); + inventoryComponent->AddItem(14378, 1, eInventoryType::INVALID, {}, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_ACTIVITY); } } else if (missionState == MissionState::MISSION_STATE_READY_TO_COMPLETE || missionState == MissionState::MISSION_STATE_COMPLETE_READY_TO_COMPLETE) diff --git a/dScripts/NpcPirateServer.cpp b/dScripts/NpcPirateServer.cpp index 4a1db1f6..acf7e67f 100644 --- a/dScripts/NpcPirateServer.cpp +++ b/dScripts/NpcPirateServer.cpp @@ -9,7 +9,7 @@ void NpcPirateServer::OnMissionDialogueOK(Entity *self, Entity *target, int miss // Add or remove the lucky shovel based on whether the mission was completed or started if ((missionState == MissionState::MISSION_STATE_AVAILABLE || missionState == MissionState::MISSION_STATE_COMPLETE_AVAILABLE) && luckyShovel == nullptr) { - inventory->AddItem(14591, 1); + inventory->AddItem(14591, 1, eInventoryType::INVALID, {}, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_ACTIVITY); } else if (missionState == MissionState::MISSION_STATE_READY_TO_COMPLETE || missionState == MissionState::MISSION_STATE_COMPLETE_READY_TO_COMPLETE) { inventory->RemoveItem(14591, 1); } diff --git a/dScripts/NpcWispServer.cpp b/dScripts/NpcWispServer.cpp index 2f94236d..3000b4c9 100644 --- a/dScripts/NpcWispServer.cpp +++ b/dScripts/NpcWispServer.cpp @@ -20,7 +20,7 @@ void NpcWispServer::OnMissionDialogueOK(Entity* self, Entity* target, int missio // For the daily we add the maelstrom vacuum if the player doesn't have it yet if (missionID == 1883 && (missionState == MissionState::MISSION_STATE_AVAILABLE || missionState == MissionState::MISSION_STATE_COMPLETE_AVAILABLE) && maelstromVacuum == nullptr) { - inventory->AddItem(maelstromVacuumLot, 1); + inventory->AddItem(maelstromVacuumLot, 1, eInventoryType::INVALID, {}, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_ACTIVITY); } else if (missionState == MissionState::MISSION_STATE_READY_TO_COMPLETE || missionState == MissionState::MISSION_STATE_COMPLETE_READY_TO_COMPLETE) { inventory->RemoveItem(maelstromVacuumLot, 1); } diff --git a/dScripts/NsConcertInstrument.cpp b/dScripts/NsConcertInstrument.cpp index f0257c93..d1de993c 100644 --- a/dScripts/NsConcertInstrument.cpp +++ b/dScripts/NsConcertInstrument.cpp @@ -195,7 +195,7 @@ void NsConcertInstrument::EquipInstruments(Entity *self, Entity *player) { // Equip the left hand instrument const auto leftInstrumentLot = instrumentLotLeft.find(GetInstrumentLot(self))->second; if (leftInstrumentLot != LOT_NULL) { - inventory->AddItem(leftInstrumentLot, 1, TEMP_ITEMS, {}, LWOOBJID_EMPTY, false); + inventory->AddItem(leftInstrumentLot, 1, TEMP_ITEMS, {}, LWOOBJID_EMPTY, false, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_ACTIVITY); auto* leftInstrument = inventory->FindItemByLot(leftInstrumentLot, TEMP_ITEMS); leftInstrument->Equip(); } @@ -203,7 +203,7 @@ void NsConcertInstrument::EquipInstruments(Entity *self, Entity *player) { // Equip the right hand instrument const auto rightInstrumentLot = instrumentLotRight.find(GetInstrumentLot(self))->second; if (rightInstrumentLot != LOT_NULL) { - inventory->AddItem(rightInstrumentLot, 1, TEMP_ITEMS, {}, LWOOBJID_EMPTY, false); + inventory->AddItem(rightInstrumentLot, 1, TEMP_ITEMS, {}, LWOOBJID_EMPTY, false, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_ACTIVITY); auto* rightInstrument = inventory->FindItemByLot(rightInstrumentLot, TEMP_ITEMS); rightInstrument->Equip(); } diff --git a/dScripts/NsTokenConsoleServer.cpp b/dScripts/NsTokenConsoleServer.cpp index f6b022d0..0416a030 100644 --- a/dScripts/NsTokenConsoleServer.cpp +++ b/dScripts/NsTokenConsoleServer.cpp @@ -50,19 +50,19 @@ void NsTokenConsoleServer::OnUse(Entity* self, Entity* user) if (character->GetPlayerFlag(46)) { - inventoryComponent->AddItem(8321, 5); + inventoryComponent->AddItem(8321, 5, eInventoryType::INVALID, {}, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_NONE); } else if (character->GetPlayerFlag(47)) { - inventoryComponent->AddItem(8318, 5); + inventoryComponent->AddItem(8318, 5, eInventoryType::INVALID, {}, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_NONE); } else if (character->GetPlayerFlag(48)) { - inventoryComponent->AddItem(8320, 5); + inventoryComponent->AddItem(8320, 5, eInventoryType::INVALID, {}, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_NONE); } else if (character->GetPlayerFlag(49)) { - inventoryComponent->AddItem(8319, 5); + inventoryComponent->AddItem(8319, 5, eInventoryType::INVALID, {}, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_NONE); } missionComponent->ForceProgressTaskType(863, 1, 1, false); diff --git a/dScripts/NtDukeServer.cpp b/dScripts/NtDukeServer.cpp index 0f56d6cc..db278aa1 100644 --- a/dScripts/NtDukeServer.cpp +++ b/dScripts/NtDukeServer.cpp @@ -29,7 +29,7 @@ void NtDukeServer::OnMissionDialogueOK(Entity *self, Entity *target, int mission auto lotCount = inventoryComponent->GetLotCount(m_SwordLot); if ((state == MissionState::MISSION_STATE_AVAILABLE || state == MissionState::MISSION_STATE_ACTIVE) && lotCount < 1) { - inventoryComponent->AddItem(m_SwordLot, 1); + inventoryComponent->AddItem(m_SwordLot, 1, eInventoryType::INVALID, {}, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_ACTIVITY); } else if (state == MissionState::MISSION_STATE_READY_TO_COMPLETE) { inventoryComponent->RemoveItem(m_SwordLot, lotCount); } diff --git a/dScripts/SGCannon.cpp b/dScripts/SGCannon.cpp index 4b991253..efb7d7fc 100644 --- a/dScripts/SGCannon.cpp +++ b/dScripts/SGCannon.cpp @@ -574,7 +574,7 @@ void SGCannon::StopGame(Entity *self, bool cancel) { auto* inventory = player->GetComponent(); if (inventory != nullptr) { for (const auto rewardLot : self->GetVar>(RewardsVariable)) { - inventory->AddItem(rewardLot, 1, eInventoryType::MODELS); + inventory->AddItem(rewardLot, 1, eInventoryType::MODELS, {}, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_ACTIVITY); } } diff --git a/dScripts/TokenConsoleServer.cpp b/dScripts/TokenConsoleServer.cpp index dcefe2f2..0ca18e76 100644 --- a/dScripts/TokenConsoleServer.cpp +++ b/dScripts/TokenConsoleServer.cpp @@ -21,15 +21,17 @@ void TokenConsoleServer::OnUse(Entity* self, Entity* user) { //figure out which faction the player belongs to: auto character = user->GetCharacter(); if (!character) return; - + // At this point the player has to be in a faction. + LOT tokenLOT = 0; if (character->GetPlayerFlag(ePlayerFlags::VENTURE_FACTION)) //venture - inv->AddItem(8321, tokensToGive); + tokenLOT = 8321; else if (character->GetPlayerFlag(ePlayerFlags::ASSEMBLY_FACTION)) //assembly - inv->AddItem(8318, tokensToGive); + tokenLOT = 8318; else if (character->GetPlayerFlag(ePlayerFlags::PARADOX_FACTION)) //paradox - inv->AddItem(8320, tokensToGive); + tokenLOT = 8320; else if (character->GetPlayerFlag(ePlayerFlags::SENTINEL_FACTION)) //sentinel - inv->AddItem(8319, tokensToGive); + tokenLOT = 8319; + inv->AddItem(tokenLOT, tokensToGive, eInventoryType::INVALID, {}, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_NONE); } GameMessages::SendTerminateInteraction(user->GetObjectID(), eTerminateType::FROM_INTERACTION, self->GetObjectID()); diff --git a/dScripts/VeBricksampleServer.cpp b/dScripts/VeBricksampleServer.cpp index 42ccd460..f9d5f3d2 100644 --- a/dScripts/VeBricksampleServer.cpp +++ b/dScripts/VeBricksampleServer.cpp @@ -10,7 +10,7 @@ void VeBricksampleServer::OnUse(Entity *self, Entity *user) { auto* inventoryComponent = user->GetComponent(); if (loot && inventoryComponent != nullptr && inventoryComponent->GetLotCount(loot) == 0) { - inventoryComponent->AddItem(loot, 1); + inventoryComponent->AddItem(loot, 1, eInventoryType::INVALID, {}, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_ACTIVITY); for (auto* brickEntity : EntityManager::Instance()->GetEntitiesInGroup("Bricks")) { GameMessages::SendNotifyClientObject(brickEntity->GetObjectID(), u"Pickedup"); diff --git a/dScripts/VeMissionConsole.cpp b/dScripts/VeMissionConsole.cpp index 4a506dac..9e560244 100644 --- a/dScripts/VeMissionConsole.cpp +++ b/dScripts/VeMissionConsole.cpp @@ -8,7 +8,7 @@ void VeMissionConsole::OnUse(Entity *self, Entity *user) { auto* inventoryComponent = user->GetComponent(); if (inventoryComponent != nullptr) { - inventoryComponent->AddItem(12547, 1); // Add the panel required for pickup + inventoryComponent->AddItem(12547, 1, eInventoryType::INVALID, {}, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_ACTIVITY); // Add the panel required for pickup } // The flag to set is 101 From 8e10f090fd6309f5649184722fb6e864fbd0d066 Mon Sep 17 00:00:00 2001 From: EmosewaMC <39972741+EmosewaMC@users.noreply.github.com> Date: Sat, 23 Apr 2022 18:52:21 -0700 Subject: [PATCH 06/12] corrected number --- dGame/Entity.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dGame/Entity.cpp b/dGame/Entity.cpp index 8a1d3c82..fbec1157 100644 --- a/dGame/Entity.cpp +++ b/dGame/Entity.cpp @@ -1637,7 +1637,7 @@ void Entity::PickupItem(const LWOOBJID& objectID) { } } else { - inv->AddItem(p.second.lot, p.second.count, INVALID, {}, LWOOBJID_EMPTY, true, false, LWOOBJID_EMPTY, INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_PICKUP); + inv->AddItem(p.second.lot, p.second.count, INVALID, {}, LWOOBJID_EMPTY, true, false, LWOOBJID_EMPTY, INVALID, 1, false, -1, eLootSourceType::LOOT_SOURCE_PICKUP); } } } From ceab229a63341ab763490f97724986bdf4c7e34d Mon Sep 17 00:00:00 2001 From: EmosewaMC <39972741+EmosewaMC@users.noreply.github.com> Date: Sat, 23 Apr 2022 20:32:31 -0700 Subject: [PATCH 07/12] Specified enum the LOOT_SOURCE enum is now attached to all loot sources. --- dGame/Character.cpp | 2 +- dGame/TradingManager.cpp | 4 ++-- dGame/dComponents/CharacterComponent.cpp | 2 +- dGame/dComponents/DestroyableComponent.cpp | 2 +- dGame/dComponents/InventoryComponent.cpp | 2 +- dGame/dGameMessages/GameMessages.cpp | 28 +++++++++++----------- dGame/dMission/Mission.cpp | 6 ++--- dGame/dUtilities/Mail.cpp | 2 +- dGame/dUtilities/SlashCommandHandler.cpp | 6 ++--- 9 files changed, 27 insertions(+), 27 deletions(-) diff --git a/dGame/Character.cpp b/dGame/Character.cpp index d396382c..ce61ae70 100644 --- a/dGame/Character.cpp +++ b/dGame/Character.cpp @@ -534,7 +534,7 @@ void Character::OnZoneLoad() */ if (HasPermission(PermissionMap::Old)) { if (GetCoins() > 1000000) { - SetCoins(1000000, LOOT_SOURCE_NONE); + SetCoins(1000000, eLootSourceType::LOOT_SOURCE_NONE); } } diff --git a/dGame/TradingManager.cpp b/dGame/TradingManager.cpp index e178d130..c489c47b 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, LOOT_SOURCE_TRADE); - characterB->SetCoins(characterB->GetCoins() - m_CoinsB + m_CoinsA, LOOT_SOURCE_TRADE); + characterA->SetCoins(characterA->GetCoins() - m_CoinsA + m_CoinsB, eLootSourceType::LOOT_SOURCE_TRADE); + characterB->SetCoins(characterB->GetCoins() - m_CoinsB + m_CoinsA, eLootSourceType::LOOT_SOURCE_TRADE); for (const auto& tradeItem : m_ItemsA) { diff --git a/dGame/dComponents/CharacterComponent.cpp b/dGame/dComponents/CharacterComponent.cpp index 67b820c2..8c4b0962 100644 --- a/dGame/dComponents/CharacterComponent.cpp +++ b/dGame/dComponents/CharacterComponent.cpp @@ -221,7 +221,7 @@ void CharacterComponent::HandleLevelUp() break; case 4: { - auto* items = inventoryComponent->GetInventory(ITEMS); + auto* items = inventoryComponent->GetInventory(eInventoryType::ITEMS); items->SetSize(items->GetSize() + reward->value); } break; diff --git a/dGame/dComponents/DestroyableComponent.cpp b/dGame/dComponents/DestroyableComponent.cpp index 31b3af19..8a99c069 100644 --- a/dGame/dComponents/DestroyableComponent.cpp +++ b/dGame/dComponents/DestroyableComponent.cpp @@ -821,7 +821,7 @@ void DestroyableComponent::Smash(const LWOOBJID source, const eKillType killType coinsTotal -= coinsToLoose; LootGenerator::Instance().DropLoot(m_Parent, m_Parent, -1, coinsToLoose, coinsToLoose); - character->SetCoins(coinsTotal, LOOT_SOURCE_PICKUP); + character->SetCoins(coinsTotal, eLootSourceType::LOOT_SOURCE_PICKUP); } } diff --git a/dGame/dComponents/InventoryComponent.cpp b/dGame/dComponents/InventoryComponent.cpp index d7a059a0..85d58065 100644 --- a/dGame/dComponents/InventoryComponent.cpp +++ b/dGame/dComponents/InventoryComponent.cpp @@ -207,7 +207,7 @@ void InventoryComponent::AddItem( auto stack = static_cast(info.stackSize); - if (inventoryType == BRICKS) + if (inventoryType == eInventoryType::BRICKS) { stack = 999; } diff --git a/dGame/dGameMessages/GameMessages.cpp b/dGame/dGameMessages/GameMessages.cpp index d363f437..b051ad45 100644 --- a/dGame/dGameMessages/GameMessages.cpp +++ b/dGame/dGameMessages/GameMessages.cpp @@ -566,8 +566,8 @@ void GameMessages::SendModifyLEGOScore(Entity* entity, const SystemAddress& sysA bitStream.Write((uint16_t)GAME_MSG_MODIFY_LEGO_SCORE); bitStream.Write(score); - bitStream.Write(sourceType != LOOT_SOURCE_NONE); - if (sourceType != LOOT_SOURCE_NONE) bitStream.Write(sourceType); + bitStream.Write(sourceType != eLootSourceType::LOOT_SOURCE_NONE); + if (sourceType != eLootSourceType::LOOT_SOURCE_NONE) bitStream.Write(sourceType); SEND_PACKET } @@ -4725,8 +4725,8 @@ void GameMessages::HandleBuyFromVendor(RakNet::BitStream* inStream, Entity* enti inv->RemoveItem(itemComp.currencyLOT, altCurrencyCost); } - character->SetCoins(character->GetCoins() - (coinCost), LOOT_SOURCE_VENDOR); inv->AddItem(item, count, eInventoryType::INVALID, {}, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_VENDOR); + character->SetCoins(character->GetCoins() - (coinCost), eLootSourceType::LOOT_SOURCE_VENDOR); } GameMessages::SendVendorTransactionResult(entity, sysAddr); @@ -4773,8 +4773,8 @@ 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)), LOOT_SOURCE_VENDOR); + inv->MoveItemToInventory(item, eInventoryType::VENDOR_BUYBACK, count, true, false, true); + character->SetCoins(std::floor(character->GetCoins() + ((itemComp.baseValue * sellScalar)*count)), eLootSourceType::LOOT_SOURCE_VENDOR); //EntityManager::Instance()->SerializeEntity(player); // so inventory updates GameMessages::SendVendorTransactionResult(entity, sysAddr); } @@ -4836,7 +4836,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, LOOT_SOURCE_VENDOR); + character->SetCoins(character->GetCoins() - cost, eLootSourceType::LOOT_SOURCE_VENDOR); //EntityManager::Instance()->SerializeEntity(player); // so inventory updates GameMessages::SendVendorTransactionResult(entity, sysAddr); } @@ -5269,7 +5269,7 @@ void GameMessages::HandlePickupCurrency(RakNet::BitStream* inStream, Entity* ent auto* ch = entity->GetCharacter(); if (entity->CanPickupCoins(currency)) { - ch->SetCoins(ch->GetCoins() + currency, LOOT_SOURCE_PICKUP); + ch->SetCoins(ch->GetCoins() + currency, eLootSourceType::LOOT_SOURCE_PICKUP); } } @@ -5484,8 +5484,8 @@ void GameMessages::HandleMoveItemInInventory(RakNet::BitStream* inStream, Entity } void GameMessages::HandleMoveItemBetweenInventoryTypes(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { - int inventoryTypeA; - int inventoryTypeB; + eInventoryType inventoryTypeA; + eInventoryType inventoryTypeB; LWOOBJID objectID; bool showFlyingLoot = true; bool stackCountIsDefault = false; @@ -5502,7 +5502,7 @@ void GameMessages::HandleMoveItemBetweenInventoryTypes(RakNet::BitStream* inStre inStream->Read(templateIDIsDefault); if (templateIDIsDefault) inStream->Read(templateID); - InventoryComponent* inv = static_cast(entity->GetComponent(COMPONENT_TYPE_INVENTORY)); + auto inv = entity->GetComponent(); if (!inv) return; auto* item = inv->FindItemById(objectID); @@ -5523,7 +5523,7 @@ void GameMessages::HandleMoveItemBetweenInventoryTypes(RakNet::BitStream* inStre } } - inv->MoveItemToInventory(item, static_cast(inventoryTypeB), stackCount, showFlyingLoot, false); + inv->MoveItemToInventory(item, inventoryTypeB, stackCount, showFlyingLoot); EntityManager::Instance()->SerializeEntity(entity); } @@ -5624,7 +5624,7 @@ void GameMessages::HandleModularBuildFinish(RakNet::BitStream* inStream, Entity* for (auto* item : items) { - inv->MoveItemToInventory(item, MODELS, item->GetCount(), false); + inv->MoveItemToInventory(item, eInventoryType::MODELS, item->GetCount(), false); } } @@ -5739,7 +5739,7 @@ void GameMessages::HandleDoneArrangingWithItem(RakNet::BitStream* inStream, Enti for (auto* item : items) { - inv->MoveItemToInventory(item, MODELS, item->GetCount(), false, false); + inv->MoveItemToInventory(item, eInventoryType::MODELS, item->GetCount(), false, false); } } @@ -5765,7 +5765,7 @@ void GameMessages::HandleModularBuildMoveAndEquip(RakNet::BitStream* inStream, E return; } - inv->MoveItemToInventory(item, MODELS, 1, false, true); + inv->MoveItemToInventory(item, eInventoryType::MODELS, 1, false, true); } void GameMessages::HandlePickupItem(RakNet::BitStream* inStream, Entity* entity) { diff --git a/dGame/dMission/Mission.cpp b/dGame/dMission/Mission.cpp index 93a60ae9..9732bb5b 100644 --- a/dGame/dMission/Mission.cpp +++ b/dGame/dMission/Mission.cpp @@ -430,7 +430,7 @@ void Mission::YieldRewards() { int32_t coinsToSend = 0; if (info->LegoScore > 0) { - eLootSourceType lootSource = info->isMission ? LOOT_SOURCE_MISSION : LOOT_SOURCE_ACHIEVEMENT; + eLootSourceType lootSource = info->isMission ? eLootSourceType::LOOT_SOURCE_MISSION : eLootSourceType::LOOT_SOURCE_ACHIEVEMENT; if(characterComponent->GetLevel() >= dZoneManager::Instance()->GetMaxLevel()) { // Since the character is at the level cap we reward them with coins instead of UScore. coinsToSend += info->LegoScore * dZoneManager::Instance()->GetLevelCapCurrencyConversion(); @@ -467,7 +467,7 @@ void Mission::YieldRewards() { } if (info->reward_currency_repeatable > 0 || coinsToSend > 0) { - eLootSourceType lootSource = info->isMission ? LOOT_SOURCE_MISSION : LOOT_SOURCE_ACHIEVEMENT; + eLootSourceType lootSource = info->isMission ? eLootSourceType::LOOT_SOURCE_MISSION : eLootSourceType::LOOT_SOURCE_ACHIEVEMENT; character->SetCoins(character->GetCoins() + info->reward_currency_repeatable + coinsToSend, lootSource); } @@ -500,7 +500,7 @@ void Mission::YieldRewards() { } if (info->reward_currency > 0 || coinsToSend > 0) { - eLootSourceType lootSource = info->isMission ? LOOT_SOURCE_MISSION : LOOT_SOURCE_ACHIEVEMENT; + eLootSourceType lootSource = info->isMission ? eLootSourceType::LOOT_SOURCE_MISSION : eLootSourceType::LOOT_SOURCE_ACHIEVEMENT; character->SetCoins(character->GetCoins() + info->reward_currency + coinsToSend, lootSource); } diff --git a/dGame/dUtilities/Mail.cpp b/dGame/dUtilities/Mail.cpp index d0718f4c..89cc0fff 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, LOOT_SOURCE_MAIL); + entity->GetCharacter()->SetCoins(entity->GetCharacter()->GetCoins() - mailCost, eLootSourceType::LOOT_SOURCE_MAIL); 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 69ee60b0..d94c8d47 100644 --- a/dGame/dUtilities/SlashCommandHandler.cpp +++ b/dGame/dUtilities/SlashCommandHandler.cpp @@ -1293,7 +1293,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit CharacterComponent* character = entity->GetComponent(); if (character) character->SetUScore(character->GetUScore() + uscore); // LOOT_SOURCE_MODERATION should work but it doesn't. Relog to see uscore changes - GameMessages::SendModifyLEGOScore(entity, entity->GetSystemAddress(), uscore, LOOT_SOURCE_MODERATION); + GameMessages::SendModifyLEGOScore(entity, entity->GetSystemAddress(), uscore, eLootSourceType::LOOT_SOURCE_MODERATION); } if (chatCommand == "pos" && entity->GetGMLevel() >= GAME_MASTER_LEVEL_DEVELOPER) { @@ -1337,7 +1337,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit } auto* ch = entity->GetCharacter(); - ch->SetCoins(ch->GetCoins() + money, LOOT_SOURCE_MODERATION); + ch->SetCoins(ch->GetCoins() + money, eLootSourceType::LOOT_SOURCE_MODERATION); } if ((chatCommand == "setcurrency") && args.size() == 1 && entity->GetGMLevel() >= GAME_MASTER_LEVEL_DEVELOPER) { @@ -1350,7 +1350,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit } auto* ch = entity->GetCharacter(); - ch->SetCoins(money, LOOT_SOURCE_MODERATION); + ch->SetCoins(money, eLootSourceType::LOOT_SOURCE_MODERATION); } // Allow for this on even while not a GM, as it sometimes toggles incorrrectly. From 7a051afd97f49583a5fbfba7136a8077e41bb81f Mon Sep 17 00:00:00 2001 From: EmosewaMC <39972741+EmosewaMC@users.noreply.github.com> Date: Sat, 23 Apr 2022 20:35:34 -0700 Subject: [PATCH 08/12] loot source for item drops Added support for Items to have a loot source attached to them when dropped or rolled. This fixes the issue where achievements would give the item before it appeared in the achievement window. --- dGame/Entity.cpp | 2 +- dGame/TradingManager.cpp | 4 ++-- dGame/dComponents/CharacterComponent.cpp | 2 +- dGame/dComponents/InventoryComponent.cpp | 15 ++++++--------- dGame/dComponents/InventoryComponent.h | 5 +++-- dGame/dComponents/PetComponent.cpp | 2 +- dGame/dComponents/PropertyManagementComponent.cpp | 4 ++-- dGame/dGameMessages/GameMessages.cpp | 12 ++++++------ dGame/dInventory/Item.cpp | 10 +++++----- dGame/dInventory/Item.h | 2 +- dGame/dMission/Mission.cpp | 4 ++-- dGame/dUtilities/Loot.cpp | 12 ++++++------ dGame/dUtilities/Loot.h | 4 ++-- dGame/dUtilities/Mail.cpp | 2 +- dGame/dUtilities/SlashCommandHandler.cpp | 6 +++--- dScripts/AmDropshipComputer.cpp | 2 +- dScripts/NPCAddRemoveItem.cpp | 2 +- dScripts/NjColeNPC.cpp | 2 +- dScripts/NjScrollChestServer.cpp | 2 +- dScripts/NpcCowboyServer.cpp | 2 +- dScripts/NpcPirateServer.cpp | 2 +- dScripts/NpcWispServer.cpp | 2 +- dScripts/NsConcertInstrument.cpp | 4 ++-- dScripts/NsTokenConsoleServer.cpp | 13 +++++++++---- dScripts/NtDukeServer.cpp | 2 +- dScripts/SGCannon.cpp | 2 +- dScripts/TokenConsoleServer.cpp | 2 +- dScripts/VeBricksampleServer.cpp | 2 +- dScripts/VeMissionConsole.cpp | 2 +- 29 files changed, 65 insertions(+), 62 deletions(-) diff --git a/dGame/Entity.cpp b/dGame/Entity.cpp index fbec1157..799e7803 100644 --- a/dGame/Entity.cpp +++ b/dGame/Entity.cpp @@ -1637,7 +1637,7 @@ void Entity::PickupItem(const LWOOBJID& objectID) { } } else { - inv->AddItem(p.second.lot, p.second.count, INVALID, {}, LWOOBJID_EMPTY, true, false, LWOOBJID_EMPTY, INVALID, 1, false, -1, eLootSourceType::LOOT_SOURCE_PICKUP); + inv->AddItem(p.second.lot, p.second.count, eLootSourceType::LOOT_SOURCE_PICKUP, eInventoryType::INVALID, {}, LWOOBJID_EMPTY, true, false, LWOOBJID_EMPTY, eInventoryType::INVALID, 1); } } } diff --git a/dGame/TradingManager.cpp b/dGame/TradingManager.cpp index c489c47b..04a0501d 100644 --- a/dGame/TradingManager.cpp +++ b/dGame/TradingManager.cpp @@ -170,12 +170,12 @@ void Trade::Complete() for (const auto& tradeItem : m_ItemsA) { - inventoryB->AddItem(tradeItem.itemLot, tradeItem.itemCount, eInventoryType::INVALID, {}, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_TRADE); + inventoryB->AddItem(tradeItem.itemLot, tradeItem.itemCount, eLootSourceType::LOOT_SOURCE_TRADE); } for (const auto& tradeItem : m_ItemsB) { - inventoryA->AddItem(tradeItem.itemLot, tradeItem.itemCount, eInventoryType::INVALID, {}, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_TRADE); + inventoryA->AddItem(tradeItem.itemLot, tradeItem.itemCount, eLootSourceType::LOOT_SOURCE_TRADE); } TradingManager::Instance()->CancelTrade(m_TradeId); diff --git a/dGame/dComponents/CharacterComponent.cpp b/dGame/dComponents/CharacterComponent.cpp index 8c4b0962..815a3d59 100644 --- a/dGame/dComponents/CharacterComponent.cpp +++ b/dGame/dComponents/CharacterComponent.cpp @@ -217,7 +217,7 @@ void CharacterComponent::HandleLevelUp() switch (reward->rewardType) { case 0: - inventoryComponent->AddItem(reward->value, reward->count, eInventoryType::INVALID, {}, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_LEVEL_REWARD); + inventoryComponent->AddItem(reward->value, reward->count, eLootSourceType::LOOT_SOURCE_LEVEL_REWARD); break; case 4: { diff --git a/dGame/dComponents/InventoryComponent.cpp b/dGame/dComponents/InventoryComponent.cpp index 85d58065..e03f4e92 100644 --- a/dGame/dComponents/InventoryComponent.cpp +++ b/dGame/dComponents/InventoryComponent.cpp @@ -141,6 +141,7 @@ const EquipmentMap& InventoryComponent::GetEquippedItems() const void InventoryComponent::AddItem( const LOT lot, const uint32_t count, + eLootSourceType lootSourceType, eInventoryType inventoryType, const std::vector& config, const LWOOBJID parent, @@ -150,8 +151,7 @@ void InventoryComponent::AddItem( const eInventoryType inventorySourceType, const int32_t sourceType, const bool bound, - int32_t preferredSlot, - eLootSourceType lootSourceType) + int32_t preferredSlot) { if (count == 0) { @@ -181,7 +181,7 @@ void InventoryComponent::AddItem( if (!config.empty() || bound) { - const auto slot = inventory->FindEmptySlot(); + const auto slot = preferredSlot != -1 && inventory->IsSlotEmpty(preferredSlot) ? preferredSlot : inventory->FindEmptySlot(); if (slot == -1) { @@ -224,7 +224,7 @@ void InventoryComponent::AddItem( left -= delta; - existing->SetCount(existing->GetCount() + delta, false, true, showFlyingLoot); + existing->SetCount(existing->GetCount() + delta, false, true, showFlyingLoot, lootSourceType); if (isModMoveAndEquip) { @@ -255,9 +255,6 @@ void InventoryComponent::AddItem( if (slot == -1) { - // if (inventoryType == eInventoryType::VAULT_ITEMS || inventoryType == eInventoryType::VAULT_MODELS) { - - // } auto* player = dynamic_cast(GetParent()); if (player == nullptr) @@ -372,7 +369,7 @@ void InventoryComponent::MoveItemToInventory(Item* item, const eInventoryType in left -= delta; - AddItem(lot, delta, inventory, {}, LWOOBJID_EMPTY, showFlyingLot, isModMoveAndEquip, LWOOBJID_EMPTY, origin->GetType(), 0, false, preferredSlot, eLootSourceType::LOOT_SOURCE_NONE); + AddItem(lot, delta, eLootSourceType::LOOT_SOURCE_NONE, inventory, {}, LWOOBJID_EMPTY, showFlyingLot, isModMoveAndEquip, LWOOBJID_EMPTY, origin->GetType(), 0, false, preferredSlot); item->SetCount(item->GetCount() - delta, false, false); @@ -390,7 +387,7 @@ void InventoryComponent::MoveItemToInventory(Item* item, const eInventoryType in const auto delta = std::min(item->GetCount(), count); - AddItem(lot, delta, inventory, config, LWOOBJID_EMPTY, showFlyingLot, isModMoveAndEquip, LWOOBJID_EMPTY, origin->GetType(), 0, item->GetBound(), preferredSlot, eLootSourceType::LOOT_SOURCE_NONE); + AddItem(lot, delta, eLootSourceType::LOOT_SOURCE_NONE, inventory, config, LWOOBJID_EMPTY, showFlyingLot, isModMoveAndEquip, LWOOBJID_EMPTY, origin->GetType(), 0, item->GetBound(), preferredSlot); item->SetCount(item->GetCount() - delta, false, false); } diff --git a/dGame/dComponents/InventoryComponent.h b/dGame/dComponents/InventoryComponent.h index d73ee51d..bf18d132 100644 --- a/dGame/dComponents/InventoryComponent.h +++ b/dGame/dComponents/InventoryComponent.h @@ -87,10 +87,12 @@ public: * @param sourceType the source of the item, used to determine if the item is dropped or mailed if the inventory is full * @param bound whether this item is bound * @param preferredSlot the preferred slot to store this item + * @param lootSourceType The source of the loot. Defaults to none. */ void AddItem( LOT lot, uint32_t count, + eLootSourceType lootSourceType = eLootSourceType::LOOT_SOURCE_NONE, eInventoryType inventoryType = INVALID, const std::vector& config = {}, LWOOBJID parent = LWOOBJID_EMPTY, @@ -100,8 +102,7 @@ public: eInventoryType inventorySourceType = INVALID, int32_t sourceType = 0, bool bound = false, - int32_t preferredSlot = -1, - eLootSourceType lootSourceType = eLootSourceType::LOOT_SOURCE_NONE + int32_t preferredSlot = -1 ); /** diff --git a/dGame/dComponents/PetComponent.cpp b/dGame/dComponents/PetComponent.cpp index 4b61384d..97c7e95b 100644 --- a/dGame/dComponents/PetComponent.cpp +++ b/dGame/dComponents/PetComponent.cpp @@ -615,7 +615,7 @@ void PetComponent::NotifyTamingBuildSuccess(NiPoint3 position) GameMessages::SendRegisterPetDBID(m_Tamer, petSubKey, tamer->GetSystemAddress()); - inventoryComponent->AddItem(m_Parent->GetLOT(), 1, MODELS, {}, LWOOBJID_EMPTY, true, false, petSubKey, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_ACTIVITY); + inventoryComponent->AddItem(m_Parent->GetLOT(), 1, eLootSourceType::LOOT_SOURCE_ACTIVITY, eInventoryType::MODELS, {}, LWOOBJID_EMPTY, true, false, petSubKey); auto* item = inventoryComponent->FindItemBySubKey(petSubKey, MODELS); if (item == nullptr) diff --git a/dGame/dComponents/PropertyManagementComponent.cpp b/dGame/dComponents/PropertyManagementComponent.cpp index ad0ec7c3..0a428e04 100644 --- a/dGame/dComponents/PropertyManagementComponent.cpp +++ b/dGame/dComponents/PropertyManagementComponent.cpp @@ -491,7 +491,7 @@ void PropertyManagementComponent::DeleteModel(const LWOOBJID id, const int delet settings.push_back(propertyObjectID); settings.push_back(modelType); - inventoryComponent->AddItem(6662, 1, HIDDEN, settings, LWOOBJID_EMPTY, false, false, spawnerId, INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_DELETION); + inventoryComponent->AddItem(6662, 1, eLootSourceType::LOOT_SOURCE_DELETION, eInventoryType::HIDDEN, settings, LWOOBJID_EMPTY, false, false, spawnerId); auto* item = inventoryComponent->FindItemBySubKey(spawnerId); if (item == nullptr) { @@ -526,7 +526,7 @@ void PropertyManagementComponent::DeleteModel(const LWOOBJID id, const int delet return; } - inventoryComponent->AddItem(model->GetLOT(), 1, INVALID, {}, LWOOBJID_EMPTY, false, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_DELETION); + inventoryComponent->AddItem(model->GetLOT(), 1, eLootSourceType::LOOT_SOURCE_DELETION, INVALID, {}, LWOOBJID_EMPTY, false); auto* item = inventoryComponent->FindItemByLot(model->GetLOT()); diff --git a/dGame/dGameMessages/GameMessages.cpp b/dGame/dGameMessages/GameMessages.cpp index b051ad45..e0f38dbe 100644 --- a/dGame/dGameMessages/GameMessages.cpp +++ b/dGame/dGameMessages/GameMessages.cpp @@ -4700,7 +4700,7 @@ void GameMessages::HandleBuyFromVendor(RakNet::BitStream* inStream, Entity* enti inv->RemoveItem(tokenId, altCurrencyCost); - inv->AddItem(item, count, eInventoryType::INVALID, {}, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_VENDOR); + inv->AddItem(item, count, eLootSourceType::LOOT_SOURCE_VENDOR); } else { @@ -4725,8 +4725,8 @@ void GameMessages::HandleBuyFromVendor(RakNet::BitStream* inStream, Entity* enti inv->RemoveItem(itemComp.currencyLOT, altCurrencyCost); } - inv->AddItem(item, count, eInventoryType::INVALID, {}, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_VENDOR); character->SetCoins(character->GetCoins() - (coinCost), eLootSourceType::LOOT_SOURCE_VENDOR); + inv->AddItem(item, count, eLootSourceType::LOOT_SOURCE_VENDOR); } GameMessages::SendVendorTransactionResult(entity, sysAddr); @@ -4769,7 +4769,7 @@ void GameMessages::HandleSellToVendor(RakNet::BitStream* inStream, Entity* entit if (Inventory::IsValidItem(itemComp.currencyLOT)) { const auto altCurrency = (itemComp.altCurrencyCost * sellScalar) * count; - inv->AddItem(itemComp.currencyLOT, std::floor(altCurrency), eInventoryType::INVALID, {}, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_VENDOR); // Return alt currencies like faction tokens. + inv->AddItem(itemComp.currencyLOT, std::floor(altCurrency), eLootSourceType::LOOT_SOURCE_VENDOR); // Return alt currencies like faction tokens. } //inv->RemoveItem(count, -1, iObjID); @@ -5103,7 +5103,7 @@ void GameMessages::HandleModularBuildConvertModel(RakNet::BitStream* inStream, E item->Disassemble(TEMP_MODELS); - item->SetCount(item->GetCount() - 1, false, false); + item->SetCount(item->GetCount() - 1, false, false, true, eLootSourceType::LOOT_SOURCE_QUICKBUILD); } void GameMessages::HandleSetFlag(RakNet::BitStream* inStream, Entity* entity) { @@ -5590,11 +5590,11 @@ void GameMessages::HandleModularBuildFinish(RakNet::BitStream* inStream, Entity* if (count == 3) { - inv->AddItem(6416, 1, eInventoryType::MODELS, config, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_QUICKBUILD); + inv->AddItem(6416, 1, eLootSourceType::LOOT_SOURCE_QUICKBUILD, eInventoryType::MODELS, config); } else if (count == 7) { - inv->AddItem(8092, 1, eInventoryType::MODELS, config, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_QUICKBUILD); + inv->AddItem(8092, 1, eLootSourceType::LOOT_SOURCE_QUICKBUILD, eInventoryType::MODELS, config); } auto* missionComponent = character->GetComponent(); diff --git a/dGame/dInventory/Item.cpp b/dGame/dInventory/Item.cpp index 31601673..213430d2 100644 --- a/dGame/dInventory/Item.cpp +++ b/dGame/dInventory/Item.cpp @@ -149,7 +149,7 @@ PreconditionExpression* Item::GetPreconditionExpression() const return preconditions; } -void Item::SetCount(const uint32_t value, const bool silent, const bool disassemble, const bool showFlyingLoot) +void Item::SetCount(const uint32_t value, const bool silent, const bool disassemble, const bool showFlyingLoot, eLootSourceType lootSourceType) { if (value == count) { @@ -177,7 +177,7 @@ void Item::SetCount(const uint32_t value, const bool silent, const bool disassem if (value > count) { - GameMessages::SendAddItemToInventoryClientSync(entity, entity->GetSystemAddress(), this, id, showFlyingLoot, delta, 0LL); + GameMessages::SendAddItemToInventoryClientSync(entity, entity->GetSystemAddress(), this, id, showFlyingLoot, delta, LWOOBJID_EMPTY, lootSourceType); } else { @@ -341,7 +341,7 @@ bool Item::UseNonEquip() return false; } - LootGenerator::Instance().GiveLoot(inventory->GetComponent()->GetParent(), result); + LootGenerator::Instance().GiveLoot(inventory->GetComponent()->GetParent(), result, eLootSourceType::LOOT_SOURCE_CONSUMPTION); } inventory->GetComponent()->RemoveItem(lot, 1); @@ -375,7 +375,7 @@ void Item::Disassemble(const eInventoryType inventoryType) for (const auto mod : modArray) { - inventory->GetComponent()->AddItem(mod, 1, inventoryType, {}, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_DELETION); + inventory->GetComponent()->AddItem(mod, 1, eLootSourceType::LOOT_SOURCE_DELETION, inventoryType); } } } @@ -473,7 +473,7 @@ void Item::DisassembleModel() continue; } - GetInventory()->GetComponent()->AddItem(brickID[0].NDObjectID, 1, eInventoryType::INVALID, {}, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_DELETION); + GetInventory()->GetComponent()->AddItem(brickID[0].NDObjectID, 1, eLootSourceType::LOOT_SOURCE_DELETION); } } diff --git a/dGame/dInventory/Item.h b/dGame/dInventory/Item.h index dd81d7fe..0be9449a 100644 --- a/dGame/dInventory/Item.h +++ b/dGame/dInventory/Item.h @@ -88,7 +88,7 @@ public: * @param disassemble if items were removed, this returns all the sub parts of the item individually if it had assembly part lots * @param showFlyingLoot shows flying loot to the client, if not silent */ - void SetCount(uint32_t value, bool silent = false, bool disassemble = true, bool showFlyingLoot = true); + void SetCount(uint32_t value, bool silent = false, bool disassemble = true, bool showFlyingLoot = true, eLootSourceType lootSourceType = eLootSourceType::LOOT_SOURCE_NONE); /** * Returns the number of items this item represents (e.g. for stacks) diff --git a/dGame/dMission/Mission.cpp b/dGame/dMission/Mission.cpp index 9732bb5b..c2553f24 100644 --- a/dGame/dMission/Mission.cpp +++ b/dGame/dMission/Mission.cpp @@ -463,7 +463,7 @@ void Mission::YieldRewards() { count = 0; } - inventoryComponent->AddItem(pair.first, count, eInventoryType::INVALID, {}, 0LL, IsMission(), false, 0LL, eInventoryType::INVALID, 0, false, -1, IsMission() ? eLootSourceType::LOOT_SOURCE_MISSION : eLootSourceType::LOOT_SOURCE_ACHIEVEMENT); + inventoryComponent->AddItem(pair.first, count, IsMission() ? eLootSourceType::LOOT_SOURCE_MISSION : eLootSourceType::LOOT_SOURCE_ACHIEVEMENT); } if (info->reward_currency_repeatable > 0 || coinsToSend > 0) { @@ -496,7 +496,7 @@ void Mission::YieldRewards() { count = 0; } - inventoryComponent->AddItem(pair.first, count, eInventoryType::INVALID, {}, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, IsMission() ? eLootSourceType::LOOT_SOURCE_MISSION : eLootSourceType::LOOT_SOURCE_ACHIEVEMENT); + inventoryComponent->AddItem(pair.first, count, IsMission() ? eLootSourceType::LOOT_SOURCE_MISSION : eLootSourceType::LOOT_SOURCE_ACHIEVEMENT); } if (info->reward_currency > 0 || coinsToSend > 0) { diff --git a/dGame/dUtilities/Loot.cpp b/dGame/dUtilities/Loot.cpp index 0cceaeb2..8305e152 100644 --- a/dGame/dUtilities/Loot.cpp +++ b/dGame/dUtilities/Loot.cpp @@ -268,15 +268,15 @@ std::unordered_map LootGenerator::RollLootMatrix(uint32_t matrixIn return drops; } -void LootGenerator::GiveLoot(Entity* player, uint32_t matrixIndex) { +void LootGenerator::GiveLoot(Entity* player, uint32_t matrixIndex, eLootSourceType lootSourceType) { player = player->GetOwner(); // If the owner is overwritten, we collect that here std::unordered_map result = RollLootMatrix(player, matrixIndex); - GiveLoot(player, result); + GiveLoot(player, result, lootSourceType); } -void LootGenerator::GiveLoot(Entity* player, std::unordered_map& result) { +void LootGenerator::GiveLoot(Entity* player, std::unordered_map& result, eLootSourceType lootSourceType) { player = player->GetOwner(); // if the owner is overwritten, we collect that here auto* inventoryComponent = player->GetComponent(); @@ -285,7 +285,7 @@ void LootGenerator::GiveLoot(Entity* player, std::unordered_map& r return; for (const auto& pair : result) { - inventoryComponent->AddItem(pair.first, pair.second, eInventoryType::INVALID, {}, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_ACTIVITY); + inventoryComponent->AddItem(pair.first, pair.second, lootSourceType); } } @@ -314,13 +314,13 @@ void LootGenerator::GiveActivityLoot(Entity* player, Entity* source, uint32_t ac maxCoins = currencyTable[0].maxvalue; } - GiveLoot(player, selectedReward->LootMatrixIndex); + GiveLoot(player, selectedReward->LootMatrixIndex, eLootSourceType::LOOT_SOURCE_ACTIVITY); uint32_t coins = (int)(minCoins + GeneralUtils::GenerateRandomNumber(0, 1) * (maxCoins - minCoins)); auto* character = player->GetCharacter(); - character->SetCoins(character->GetCoins() + coins, LOOT_SOURCE_ACTIVITY); + character->SetCoins(character->GetCoins() + coins, eLootSourceType::LOOT_SOURCE_ACTIVITY); } void LootGenerator::DropLoot(Entity* player, Entity* killedObject, uint32_t matrixIndex, uint32_t minCoins, uint32_t maxCoins) { diff --git a/dGame/dUtilities/Loot.h b/dGame/dUtilities/Loot.h index 23c6463d..b16c834a 100644 --- a/dGame/dUtilities/Loot.h +++ b/dGame/dUtilities/Loot.h @@ -47,8 +47,8 @@ class LootGenerator : public Singleton { std::unordered_map RollLootMatrix(Entity* player, uint32_t matrixIndex); std::unordered_map RollLootMatrix(uint32_t matrixIndex); - void GiveLoot(Entity* player, uint32_t matrixIndex); - void GiveLoot(Entity* player, std::unordered_map& result); + void GiveLoot(Entity* player, uint32_t matrixIndex, eLootSourceType lootSourceType = eLootSourceType::LOOT_SOURCE_NONE); + void GiveLoot(Entity* player, std::unordered_map& result, eLootSourceType lootSourceType = eLootSourceType::LOOT_SOURCE_NONE); void GiveActivityLoot(Entity* player, Entity* source, uint32_t activityID, int32_t rating = 0); void DropLoot(Entity* player, Entity* killedObject, uint32_t matrixIndex, uint32_t minCoins, uint32_t maxCoins); void DropLoot(Entity* player, Entity* killedObject, std::unordered_map& result, uint32_t minCoins, uint32_t maxCoins); diff --git a/dGame/dUtilities/Mail.cpp b/dGame/dUtilities/Mail.cpp index 89cc0fff..79e99c7d 100644 --- a/dGame/dUtilities/Mail.cpp +++ b/dGame/dUtilities/Mail.cpp @@ -363,7 +363,7 @@ void Mail::HandleAttachmentCollect(RakNet::BitStream* packet, const SystemAddres auto inv = static_cast(player->GetComponent(COMPONENT_TYPE_INVENTORY)); if (!inv) return; - inv->AddItem(attachmentLOT, attachmentCount, eInventoryType::INVALID, {}, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_MAIL); + inv->AddItem(attachmentLOT, attachmentCount, eLootSourceType::LOOT_SOURCE_MAIL); Mail::SendAttachmentRemoveConfirm(sysAddr, mailID); diff --git a/dGame/dUtilities/SlashCommandHandler.cpp b/dGame/dUtilities/SlashCommandHandler.cpp index d94c8d47..ca858920 100644 --- a/dGame/dUtilities/SlashCommandHandler.cpp +++ b/dGame/dUtilities/SlashCommandHandler.cpp @@ -794,7 +794,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit InventoryComponent * inventory = static_cast(entity->GetComponent(COMPONENT_TYPE_INVENTORY)); - inventory->AddItem(itemLOT, 1, eInventoryType::INVALID, {}, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_MODERATION); + inventory->AddItem(itemLOT, 1, eLootSourceType::LOOT_SOURCE_MODERATION); } else if(args.size() == 2) { uint32_t itemLOT; @@ -814,7 +814,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit InventoryComponent* inventory = static_cast(entity->GetComponent(COMPONENT_TYPE_INVENTORY)); - inventory->AddItem(itemLOT, count, eInventoryType::INVALID, {}, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_MODERATION); + inventory->AddItem(itemLOT, count, eLootSourceType::LOOT_SOURCE_MODERATION); } else { ChatPackets::SendSystemMessage(sysAddr, u"Correct usage: /gmadditem "); @@ -1626,7 +1626,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit std::vector data {}; data.push_back(new LDFData(u"reforgedLOT", reforgedItem)); - inventoryComponent->AddItem(baseItem, 1, eInventoryType::INVALID, data, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_MODERATION); + inventoryComponent->AddItem(baseItem, 1, eLootSourceType::LOOT_SOURCE_MODERATION); } if (chatCommand == "crash" && entity->GetGMLevel() >= GAME_MASTER_LEVEL_OPERATOR) diff --git a/dScripts/AmDropshipComputer.cpp b/dScripts/AmDropshipComputer.cpp index 7f25574a..d90bfa97 100644 --- a/dScripts/AmDropshipComputer.cpp +++ b/dScripts/AmDropshipComputer.cpp @@ -32,7 +32,7 @@ void AmDropshipComputer::OnUse(Entity* self, Entity* user) return; } - inventoryComponent->AddItem(12323, 1, eInventoryType::INVALID, {}, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_ACTIVITY); + inventoryComponent->AddItem(12323, 1, eLootSourceType::LOOT_SOURCE_ACTIVITY); } void AmDropshipComputer::OnDie(Entity* self, Entity* killer) diff --git a/dScripts/NPCAddRemoveItem.cpp b/dScripts/NPCAddRemoveItem.cpp index 8cc2b6fd..484cc827 100644 --- a/dScripts/NPCAddRemoveItem.cpp +++ b/dScripts/NPCAddRemoveItem.cpp @@ -11,7 +11,7 @@ void NPCAddRemoveItem::OnMissionDialogueOK(Entity *self, Entity *target, int mis for (const auto& itemSetting : missionSetting.second) { for (const auto& lot : itemSetting.items) { if (itemSetting.add && (missionState == MissionState::MISSION_STATE_AVAILABLE || missionState == MissionState::MISSION_STATE_COMPLETE_AVAILABLE)) { - inventory->AddItem(lot, 1, eInventoryType::INVALID, {}, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_ACTIVITY); + inventory->AddItem(lot, 1, eLootSourceType::LOOT_SOURCE_ACTIVITY); } else if (itemSetting.remove && (missionState == MissionState::MISSION_STATE_READY_TO_COMPLETE || missionState == MissionState::MISSION_STATE_COMPLETE_READY_TO_COMPLETE)) { inventory->RemoveItem(lot, 1); } diff --git a/dScripts/NjColeNPC.cpp b/dScripts/NjColeNPC.cpp index e342e429..d2388d7b 100644 --- a/dScripts/NjColeNPC.cpp +++ b/dScripts/NjColeNPC.cpp @@ -54,6 +54,6 @@ void NjColeNPC::OnMissionDialogueOK(Entity* self, Entity* target, int missionID, return; } - inventoryComponent->AddItem(16644, 1, eInventoryType::INVALID, {}, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_VENDOR); + inventoryComponent->AddItem(16644, 1, eLootSourceType::LOOT_SOURCE_VENDOR); } } diff --git a/dScripts/NjScrollChestServer.cpp b/dScripts/NjScrollChestServer.cpp index 4677f827..8a2f7750 100644 --- a/dScripts/NjScrollChestServer.cpp +++ b/dScripts/NjScrollChestServer.cpp @@ -12,6 +12,6 @@ void NjScrollChestServer::OnUse(Entity *self, Entity *user) { playerInventory->RemoveItem(keyLOT, 1); // Reward the player with the item set - playerInventory->AddItem(rewardItemLOT, 1, eInventoryType::INVALID, {}, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_ACTIVITY); + playerInventory->AddItem(rewardItemLOT, 1, eLootSourceType::LOOT_SOURCE_ACTIVITY); } } diff --git a/dScripts/NpcCowboyServer.cpp b/dScripts/NpcCowboyServer.cpp index b92d921f..b638d24f 100644 --- a/dScripts/NpcCowboyServer.cpp +++ b/dScripts/NpcCowboyServer.cpp @@ -23,7 +23,7 @@ void NpcCowboyServer::OnMissionDialogueOK(Entity* self, Entity* target, int miss { if (inventoryComponent->GetLotCount(14378) == 0) { - inventoryComponent->AddItem(14378, 1, eInventoryType::INVALID, {}, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_ACTIVITY); + inventoryComponent->AddItem(14378, 1, eLootSourceType::LOOT_SOURCE_ACTIVITY); } } else if (missionState == MissionState::MISSION_STATE_READY_TO_COMPLETE || missionState == MissionState::MISSION_STATE_COMPLETE_READY_TO_COMPLETE) diff --git a/dScripts/NpcPirateServer.cpp b/dScripts/NpcPirateServer.cpp index acf7e67f..b56380f3 100644 --- a/dScripts/NpcPirateServer.cpp +++ b/dScripts/NpcPirateServer.cpp @@ -9,7 +9,7 @@ void NpcPirateServer::OnMissionDialogueOK(Entity *self, Entity *target, int miss // Add or remove the lucky shovel based on whether the mission was completed or started if ((missionState == MissionState::MISSION_STATE_AVAILABLE || missionState == MissionState::MISSION_STATE_COMPLETE_AVAILABLE) && luckyShovel == nullptr) { - inventory->AddItem(14591, 1, eInventoryType::INVALID, {}, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_ACTIVITY); + inventory->AddItem(14591, 1, eLootSourceType::LOOT_SOURCE_ACTIVITY); } else if (missionState == MissionState::MISSION_STATE_READY_TO_COMPLETE || missionState == MissionState::MISSION_STATE_COMPLETE_READY_TO_COMPLETE) { inventory->RemoveItem(14591, 1); } diff --git a/dScripts/NpcWispServer.cpp b/dScripts/NpcWispServer.cpp index 3000b4c9..a0f8392c 100644 --- a/dScripts/NpcWispServer.cpp +++ b/dScripts/NpcWispServer.cpp @@ -20,7 +20,7 @@ void NpcWispServer::OnMissionDialogueOK(Entity* self, Entity* target, int missio // For the daily we add the maelstrom vacuum if the player doesn't have it yet if (missionID == 1883 && (missionState == MissionState::MISSION_STATE_AVAILABLE || missionState == MissionState::MISSION_STATE_COMPLETE_AVAILABLE) && maelstromVacuum == nullptr) { - inventory->AddItem(maelstromVacuumLot, 1, eInventoryType::INVALID, {}, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_ACTIVITY); + inventory->AddItem(maelstromVacuumLot, 1, eLootSourceType::LOOT_SOURCE_ACTIVITY); } else if (missionState == MissionState::MISSION_STATE_READY_TO_COMPLETE || missionState == MissionState::MISSION_STATE_COMPLETE_READY_TO_COMPLETE) { inventory->RemoveItem(maelstromVacuumLot, 1); } diff --git a/dScripts/NsConcertInstrument.cpp b/dScripts/NsConcertInstrument.cpp index d1de993c..92341ee9 100644 --- a/dScripts/NsConcertInstrument.cpp +++ b/dScripts/NsConcertInstrument.cpp @@ -195,7 +195,7 @@ void NsConcertInstrument::EquipInstruments(Entity *self, Entity *player) { // Equip the left hand instrument const auto leftInstrumentLot = instrumentLotLeft.find(GetInstrumentLot(self))->second; if (leftInstrumentLot != LOT_NULL) { - inventory->AddItem(leftInstrumentLot, 1, TEMP_ITEMS, {}, LWOOBJID_EMPTY, false, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_ACTIVITY); + inventory->AddItem(leftInstrumentLot, 1, eLootSourceType::LOOT_SOURCE_ACTIVITY); auto* leftInstrument = inventory->FindItemByLot(leftInstrumentLot, TEMP_ITEMS); leftInstrument->Equip(); } @@ -203,7 +203,7 @@ void NsConcertInstrument::EquipInstruments(Entity *self, Entity *player) { // Equip the right hand instrument const auto rightInstrumentLot = instrumentLotRight.find(GetInstrumentLot(self))->second; if (rightInstrumentLot != LOT_NULL) { - inventory->AddItem(rightInstrumentLot, 1, TEMP_ITEMS, {}, LWOOBJID_EMPTY, false, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_ACTIVITY); + inventory->AddItem(rightInstrumentLot, 1, eLootSourceType::LOOT_SOURCE_ACTIVITY); auto* rightInstrument = inventory->FindItemByLot(rightInstrumentLot, TEMP_ITEMS); rightInstrument->Equip(); } diff --git a/dScripts/NsTokenConsoleServer.cpp b/dScripts/NsTokenConsoleServer.cpp index 0416a030..0e9ac09e 100644 --- a/dScripts/NsTokenConsoleServer.cpp +++ b/dScripts/NsTokenConsoleServer.cpp @@ -47,24 +47,29 @@ void NsTokenConsoleServer::OnUse(Entity* self, Entity* user) { GameMessages::SendPlayNDAudioEmitter(self, UNASSIGNED_SYSTEM_ADDRESS, useSound); } + + // Player must be in faction to interact with this entity. + LOT tokenLOT = 0; if (character->GetPlayerFlag(46)) { - inventoryComponent->AddItem(8321, 5, eInventoryType::INVALID, {}, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_NONE); + tokenLOT = 8321; } else if (character->GetPlayerFlag(47)) { - inventoryComponent->AddItem(8318, 5, eInventoryType::INVALID, {}, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_NONE); + tokenLOT = 8318; } else if (character->GetPlayerFlag(48)) { - inventoryComponent->AddItem(8320, 5, eInventoryType::INVALID, {}, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_NONE); + tokenLOT = 8320; } else if (character->GetPlayerFlag(49)) { - inventoryComponent->AddItem(8319, 5, eInventoryType::INVALID, {}, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_NONE); + tokenLOT = 8319; } + inventoryComponent->AddItem(tokenLOT, 5, eLootSourceType::LOOT_SOURCE_NONE); + missionComponent->ForceProgressTaskType(863, 1, 1, false); GameMessages::SendTerminateInteraction(user->GetObjectID(), FROM_INTERACTION, self->GetObjectID()); diff --git a/dScripts/NtDukeServer.cpp b/dScripts/NtDukeServer.cpp index db278aa1..d82be277 100644 --- a/dScripts/NtDukeServer.cpp +++ b/dScripts/NtDukeServer.cpp @@ -29,7 +29,7 @@ void NtDukeServer::OnMissionDialogueOK(Entity *self, Entity *target, int mission auto lotCount = inventoryComponent->GetLotCount(m_SwordLot); if ((state == MissionState::MISSION_STATE_AVAILABLE || state == MissionState::MISSION_STATE_ACTIVE) && lotCount < 1) { - inventoryComponent->AddItem(m_SwordLot, 1, eInventoryType::INVALID, {}, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_ACTIVITY); + inventoryComponent->AddItem(m_SwordLot, 1, eLootSourceType::LOOT_SOURCE_ACTIVITY); } else if (state == MissionState::MISSION_STATE_READY_TO_COMPLETE) { inventoryComponent->RemoveItem(m_SwordLot, lotCount); } diff --git a/dScripts/SGCannon.cpp b/dScripts/SGCannon.cpp index efb7d7fc..a5c2c843 100644 --- a/dScripts/SGCannon.cpp +++ b/dScripts/SGCannon.cpp @@ -574,7 +574,7 @@ void SGCannon::StopGame(Entity *self, bool cancel) { auto* inventory = player->GetComponent(); if (inventory != nullptr) { for (const auto rewardLot : self->GetVar>(RewardsVariable)) { - inventory->AddItem(rewardLot, 1, eInventoryType::MODELS, {}, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_ACTIVITY); + inventory->AddItem(rewardLot, 1, eLootSourceType::LOOT_SOURCE_ACTIVITY, eInventoryType::MODELS); } } diff --git a/dScripts/TokenConsoleServer.cpp b/dScripts/TokenConsoleServer.cpp index 0ca18e76..58565869 100644 --- a/dScripts/TokenConsoleServer.cpp +++ b/dScripts/TokenConsoleServer.cpp @@ -31,7 +31,7 @@ void TokenConsoleServer::OnUse(Entity* self, Entity* user) { tokenLOT = 8320; else if (character->GetPlayerFlag(ePlayerFlags::SENTINEL_FACTION)) //sentinel tokenLOT = 8319; - inv->AddItem(tokenLOT, tokensToGive, eInventoryType::INVALID, {}, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_NONE); + inv->AddItem(tokenLOT, tokensToGive, eLootSourceType::LOOT_SOURCE_NONE); } GameMessages::SendTerminateInteraction(user->GetObjectID(), eTerminateType::FROM_INTERACTION, self->GetObjectID()); diff --git a/dScripts/VeBricksampleServer.cpp b/dScripts/VeBricksampleServer.cpp index f9d5f3d2..f42cd9a4 100644 --- a/dScripts/VeBricksampleServer.cpp +++ b/dScripts/VeBricksampleServer.cpp @@ -10,7 +10,7 @@ void VeBricksampleServer::OnUse(Entity *self, Entity *user) { auto* inventoryComponent = user->GetComponent(); if (loot && inventoryComponent != nullptr && inventoryComponent->GetLotCount(loot) == 0) { - inventoryComponent->AddItem(loot, 1, eInventoryType::INVALID, {}, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_ACTIVITY); + inventoryComponent->AddItem(loot, 1, eLootSourceType::LOOT_SOURCE_ACTIVITY); for (auto* brickEntity : EntityManager::Instance()->GetEntitiesInGroup("Bricks")) { GameMessages::SendNotifyClientObject(brickEntity->GetObjectID(), u"Pickedup"); diff --git a/dScripts/VeMissionConsole.cpp b/dScripts/VeMissionConsole.cpp index 9e560244..f815ebdc 100644 --- a/dScripts/VeMissionConsole.cpp +++ b/dScripts/VeMissionConsole.cpp @@ -8,7 +8,7 @@ void VeMissionConsole::OnUse(Entity *self, Entity *user) { auto* inventoryComponent = user->GetComponent(); if (inventoryComponent != nullptr) { - inventoryComponent->AddItem(12547, 1, eInventoryType::INVALID, {}, 0LL, true, false, 0LL, eInventoryType::INVALID, 0, false, -1, eLootSourceType::LOOT_SOURCE_ACTIVITY); // Add the panel required for pickup + inventoryComponent->AddItem(12547, 1, eLootSourceType::LOOT_SOURCE_ACTIVITY); // Add the panel required for pickup } // The flag to set is 101 From c6480192f8ef09ada262b0f9eac5038064aa6fe8 Mon Sep 17 00:00:00 2001 From: EmosewaMC <39972741+EmosewaMC@users.noreply.github.com> Date: Sat, 23 Apr 2022 20:35:39 -0700 Subject: [PATCH 09/12] Revert "isPlayer changes" This reverts commit 2e61839d93728d4193b5542558369f8cf05be61d. --- dGame/Entity.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dGame/Entity.cpp b/dGame/Entity.cpp index 799e7803..75d8d8b6 100644 --- a/dGame/Entity.cpp +++ b/dGame/Entity.cpp @@ -1739,7 +1739,7 @@ void Entity::CancelAllTimers() { } bool Entity::IsPlayer() const { - return m_TemplateID == 1 && GetCharacter() != nullptr; + return m_TemplateID == 1 && GetSystemAddress() != UNASSIGNED_SYSTEM_ADDRESS; } void Entity::TriggerEvent(std::string eventID, Entity* optionalTarget) { From 18fc01cd499fc4a97805511146259fbbaeb0cb3f Mon Sep 17 00:00:00 2001 From: EmosewaMC <39972741+EmosewaMC@users.noreply.github.com> Date: Sat, 23 Apr 2022 20:44:08 -0700 Subject: [PATCH 10/12] missed change for forge --- dGame/dUtilities/SlashCommandHandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dGame/dUtilities/SlashCommandHandler.cpp b/dGame/dUtilities/SlashCommandHandler.cpp index ca858920..324da751 100644 --- a/dGame/dUtilities/SlashCommandHandler.cpp +++ b/dGame/dUtilities/SlashCommandHandler.cpp @@ -1626,7 +1626,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit std::vector data {}; data.push_back(new LDFData(u"reforgedLOT", reforgedItem)); - inventoryComponent->AddItem(baseItem, 1, eLootSourceType::LOOT_SOURCE_MODERATION); + inventoryComponent->AddItem(baseItem, 1, eLootSourceType::LOOT_SOURCE_MODERATION, eInventoryType::INVALID, data); } if (chatCommand == "crash" && entity->GetGMLevel() >= GAME_MASTER_LEVEL_OPERATOR) From dc770299d1c44ac5ceae051bd6c1848a0633c8de Mon Sep 17 00:00:00 2001 From: EmosewaMC <39972741+EmosewaMC@users.noreply.github.com> Date: Sat, 23 Apr 2022 22:22:21 -0700 Subject: [PATCH 11/12] removed debug logs --- dGame/dComponents/InventoryComponent.cpp | 1 - dGame/dGameMessages/GameMessages.cpp | 1 - dGame/dInventory/Item.cpp | 1 - 3 files changed, 3 deletions(-) diff --git a/dGame/dComponents/InventoryComponent.cpp b/dGame/dComponents/InventoryComponent.cpp index e03f4e92..d2292168 100644 --- a/dGame/dComponents/InventoryComponent.cpp +++ b/dGame/dComponents/InventoryComponent.cpp @@ -284,7 +284,6 @@ void InventoryComponent::AddItem( continue; } - Game::logger->Log("InventoryComponent", "new item with source %i\n", lootSourceType); auto* item = new Item(lot, inventory, slot, size, {}, parent, showFlyingLoot, isModMoveAndEquip, subKey, false, lootSourceType); isModMoveAndEquip = false; diff --git a/dGame/dGameMessages/GameMessages.cpp b/dGame/dGameMessages/GameMessages.cpp index e0f38dbe..a1fbdb47 100644 --- a/dGame/dGameMessages/GameMessages.cpp +++ b/dGame/dGameMessages/GameMessages.cpp @@ -423,7 +423,6 @@ void GameMessages::SendAddItemToInventoryClientSync(Entity* entity, const System bitStream.Write(lootSourceType != eLootSourceType::LOOT_SOURCE_NONE); // Loot source if (lootSourceType != eLootSourceType::LOOT_SOURCE_NONE) bitStream.Write(lootSourceType); - Game::logger->Log("GameMessages", "lootSource %i\n", lootSourceType); LWONameValue extraInfo; auto config = item->GetConfig(); diff --git a/dGame/dInventory/Item.cpp b/dGame/dInventory/Item.cpp index 213430d2..a8e8d408 100644 --- a/dGame/dInventory/Item.cpp +++ b/dGame/dInventory/Item.cpp @@ -81,7 +81,6 @@ Item::Item( inventory->AddManagedItem(this); auto* entity = inventory->GetComponent()->GetParent(); - Game::logger->Log("test", "source %i\n", lootSourceType); GameMessages::SendAddItemToInventoryClientSync(entity, entity->GetSystemAddress(), this, id, showFlyingLoot, static_cast(this->count), subKey, lootSourceType); if (isModMoveAndEquip) From 4fd1467cbf7d711c777c83ec8da41044e748a60f Mon Sep 17 00:00:00 2001 From: EmosewaMC <39972741+EmosewaMC@users.noreply.github.com> Date: Sun, 24 Apr 2022 18:40:20 -0700 Subject: [PATCH 12/12] changed loot sources to none Changed loot sources for some scripts to none so they properly give loot to the player. --- dScripts/AmDropshipComputer.cpp | 2 +- dScripts/NPCAddRemoveItem.cpp | 2 +- dScripts/NjColeNPC.cpp | 2 +- dScripts/NjScrollChestServer.cpp | 2 +- dScripts/NpcCowboyServer.cpp | 2 +- dScripts/NpcPirateServer.cpp | 2 +- dScripts/NpcWispServer.cpp | 2 +- dScripts/NtDukeServer.cpp | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/dScripts/AmDropshipComputer.cpp b/dScripts/AmDropshipComputer.cpp index d90bfa97..836b09b0 100644 --- a/dScripts/AmDropshipComputer.cpp +++ b/dScripts/AmDropshipComputer.cpp @@ -32,7 +32,7 @@ void AmDropshipComputer::OnUse(Entity* self, Entity* user) return; } - inventoryComponent->AddItem(12323, 1, eLootSourceType::LOOT_SOURCE_ACTIVITY); + inventoryComponent->AddItem(12323, 1, eLootSourceType::LOOT_SOURCE_NONE); } void AmDropshipComputer::OnDie(Entity* self, Entity* killer) diff --git a/dScripts/NPCAddRemoveItem.cpp b/dScripts/NPCAddRemoveItem.cpp index 484cc827..58c46ac0 100644 --- a/dScripts/NPCAddRemoveItem.cpp +++ b/dScripts/NPCAddRemoveItem.cpp @@ -11,7 +11,7 @@ void NPCAddRemoveItem::OnMissionDialogueOK(Entity *self, Entity *target, int mis for (const auto& itemSetting : missionSetting.second) { for (const auto& lot : itemSetting.items) { if (itemSetting.add && (missionState == MissionState::MISSION_STATE_AVAILABLE || missionState == MissionState::MISSION_STATE_COMPLETE_AVAILABLE)) { - inventory->AddItem(lot, 1, eLootSourceType::LOOT_SOURCE_ACTIVITY); + inventory->AddItem(lot, 1, eLootSourceType::LOOT_SOURCE_NONE); } else if (itemSetting.remove && (missionState == MissionState::MISSION_STATE_READY_TO_COMPLETE || missionState == MissionState::MISSION_STATE_COMPLETE_READY_TO_COMPLETE)) { inventory->RemoveItem(lot, 1); } diff --git a/dScripts/NjColeNPC.cpp b/dScripts/NjColeNPC.cpp index d2388d7b..1b889445 100644 --- a/dScripts/NjColeNPC.cpp +++ b/dScripts/NjColeNPC.cpp @@ -54,6 +54,6 @@ void NjColeNPC::OnMissionDialogueOK(Entity* self, Entity* target, int missionID, return; } - inventoryComponent->AddItem(16644, 1, eLootSourceType::LOOT_SOURCE_VENDOR); + inventoryComponent->AddItem(16644, 1, eLootSourceType::LOOT_SOURCE_NONE); } } diff --git a/dScripts/NjScrollChestServer.cpp b/dScripts/NjScrollChestServer.cpp index 8a2f7750..b72f93cf 100644 --- a/dScripts/NjScrollChestServer.cpp +++ b/dScripts/NjScrollChestServer.cpp @@ -12,6 +12,6 @@ void NjScrollChestServer::OnUse(Entity *self, Entity *user) { playerInventory->RemoveItem(keyLOT, 1); // Reward the player with the item set - playerInventory->AddItem(rewardItemLOT, 1, eLootSourceType::LOOT_SOURCE_ACTIVITY); + playerInventory->AddItem(rewardItemLOT, 1, eLootSourceType::LOOT_SOURCE_NONE); } } diff --git a/dScripts/NpcCowboyServer.cpp b/dScripts/NpcCowboyServer.cpp index b638d24f..9223dcd4 100644 --- a/dScripts/NpcCowboyServer.cpp +++ b/dScripts/NpcCowboyServer.cpp @@ -23,7 +23,7 @@ void NpcCowboyServer::OnMissionDialogueOK(Entity* self, Entity* target, int miss { if (inventoryComponent->GetLotCount(14378) == 0) { - inventoryComponent->AddItem(14378, 1, eLootSourceType::LOOT_SOURCE_ACTIVITY); + inventoryComponent->AddItem(14378, 1, eLootSourceType::LOOT_SOURCE_NONE); } } else if (missionState == MissionState::MISSION_STATE_READY_TO_COMPLETE || missionState == MissionState::MISSION_STATE_COMPLETE_READY_TO_COMPLETE) diff --git a/dScripts/NpcPirateServer.cpp b/dScripts/NpcPirateServer.cpp index b56380f3..04c62b47 100644 --- a/dScripts/NpcPirateServer.cpp +++ b/dScripts/NpcPirateServer.cpp @@ -9,7 +9,7 @@ void NpcPirateServer::OnMissionDialogueOK(Entity *self, Entity *target, int miss // Add or remove the lucky shovel based on whether the mission was completed or started if ((missionState == MissionState::MISSION_STATE_AVAILABLE || missionState == MissionState::MISSION_STATE_COMPLETE_AVAILABLE) && luckyShovel == nullptr) { - inventory->AddItem(14591, 1, eLootSourceType::LOOT_SOURCE_ACTIVITY); + inventory->AddItem(14591, 1, eLootSourceType::LOOT_SOURCE_NONE); } else if (missionState == MissionState::MISSION_STATE_READY_TO_COMPLETE || missionState == MissionState::MISSION_STATE_COMPLETE_READY_TO_COMPLETE) { inventory->RemoveItem(14591, 1); } diff --git a/dScripts/NpcWispServer.cpp b/dScripts/NpcWispServer.cpp index a0f8392c..03c8f071 100644 --- a/dScripts/NpcWispServer.cpp +++ b/dScripts/NpcWispServer.cpp @@ -20,7 +20,7 @@ void NpcWispServer::OnMissionDialogueOK(Entity* self, Entity* target, int missio // For the daily we add the maelstrom vacuum if the player doesn't have it yet if (missionID == 1883 && (missionState == MissionState::MISSION_STATE_AVAILABLE || missionState == MissionState::MISSION_STATE_COMPLETE_AVAILABLE) && maelstromVacuum == nullptr) { - inventory->AddItem(maelstromVacuumLot, 1, eLootSourceType::LOOT_SOURCE_ACTIVITY); + inventory->AddItem(maelstromVacuumLot, 1, eLootSourceType::LOOT_SOURCE_NONE); } else if (missionState == MissionState::MISSION_STATE_READY_TO_COMPLETE || missionState == MissionState::MISSION_STATE_COMPLETE_READY_TO_COMPLETE) { inventory->RemoveItem(maelstromVacuumLot, 1); } diff --git a/dScripts/NtDukeServer.cpp b/dScripts/NtDukeServer.cpp index d82be277..fe196811 100644 --- a/dScripts/NtDukeServer.cpp +++ b/dScripts/NtDukeServer.cpp @@ -29,7 +29,7 @@ void NtDukeServer::OnMissionDialogueOK(Entity *self, Entity *target, int mission auto lotCount = inventoryComponent->GetLotCount(m_SwordLot); if ((state == MissionState::MISSION_STATE_AVAILABLE || state == MissionState::MISSION_STATE_ACTIVE) && lotCount < 1) { - inventoryComponent->AddItem(m_SwordLot, 1, eLootSourceType::LOOT_SOURCE_ACTIVITY); + inventoryComponent->AddItem(m_SwordLot, 1, eLootSourceType::LOOT_SOURCE_NONE); } else if (state == MissionState::MISSION_STATE_READY_TO_COMPLETE) { inventoryComponent->RemoveItem(m_SwordLot, lotCount); }