mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-25 15:07:28 +00:00
address feedback
This commit is contained in:
parent
91df00a242
commit
666f0213ab
@ -1,7 +1,8 @@
|
|||||||
#include "VendorComponent.h"
|
#include "VendorComponent.h"
|
||||||
#include "BitStream.h"
|
#include "BitStream.h"
|
||||||
#include "Game.h"
|
|
||||||
#include "dServer.h"
|
#include "dServer.h"
|
||||||
|
#include "dZoneManager.h"
|
||||||
|
#include "WorldConfig.h"
|
||||||
#include "CDComponentsRegistryTable.h"
|
#include "CDComponentsRegistryTable.h"
|
||||||
#include "CDVendorComponentTable.h"
|
#include "CDVendorComponentTable.h"
|
||||||
#include "CDLootMatrixTable.h"
|
#include "CDLootMatrixTable.h"
|
||||||
@ -32,12 +33,14 @@ void VendorComponent::OnUse(Entity* originator) {
|
|||||||
void VendorComponent::RefreshInventory(bool isCreation) {
|
void VendorComponent::RefreshInventory(bool isCreation) {
|
||||||
SetHasStandardCostItems(false);
|
SetHasStandardCostItems(false);
|
||||||
SetHasMultiCostItems(false);
|
SetHasMultiCostItems(false);
|
||||||
|
m_Inventory.clear();
|
||||||
|
|
||||||
// Custom code for Max vanity NPC and Mr.Ree cameras
|
// Custom code for Max vanity NPC and Mr.Ree cameras
|
||||||
MaxCustomVendorRefreshInventory(isCreation);
|
if(isCreation && m_Parent->GetLOT() == 9749 && Game::server->GetZoneID() == 1201) {
|
||||||
if(m_Parent->GetLOT() == 9749 && Game::server->GetZoneID() == 1201) return;
|
SetupMaxCustomVendor();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
m_Inventory.clear();
|
|
||||||
auto* lootMatrixTable = CDClientManager::Instance().GetTable<CDLootMatrixTable>();
|
auto* lootMatrixTable = CDClientManager::Instance().GetTable<CDLootMatrixTable>();
|
||||||
const auto lootMatrices = lootMatrixTable->Query([=](CDLootMatrix entry) { return (entry.LootMatrixIndex == m_LootMatrixID); });
|
const auto lootMatrices = lootMatrixTable->Query([=](CDLootMatrix entry) { return (entry.LootMatrixIndex == m_LootMatrixID); });
|
||||||
|
|
||||||
@ -54,6 +57,10 @@ void VendorComponent::RefreshInventory(bool isCreation) {
|
|||||||
for (const auto& item : vendorItems) {
|
for (const auto& item : vendorItems) {
|
||||||
if (!m_HasStandardCostItems || !m_HasMultiCostItems) {
|
if (!m_HasStandardCostItems || !m_HasMultiCostItems) {
|
||||||
auto itemComponentID = compRegistryTable->GetByIDAndType(item.itemid, eReplicaComponentType::ITEM);
|
auto itemComponentID = compRegistryTable->GetByIDAndType(item.itemid, eReplicaComponentType::ITEM);
|
||||||
|
if (itemComponentID != -1) {
|
||||||
|
Game::logger->Log("VendorComponent", "Attempted to add item %i with ItemComponent ID -1 to vendor %i inventory. Not adding item!", itemComponentID, m_Parent->GetLOT());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
auto itemComponent = itemComponentTable->GetItemComponentByID(itemComponentID);
|
auto itemComponent = itemComponentTable->GetItemComponentByID(itemComponentID);
|
||||||
if (!m_HasStandardCostItems && itemComponent.baseValue != -1) SetHasStandardCostItems(true);
|
if (!m_HasStandardCostItems && itemComponent.baseValue != -1) SetHasStandardCostItems(true);
|
||||||
if (!m_HasMultiCostItems && !itemComponent.currencyCosts.empty()) SetHasMultiCostItems(true);
|
if (!m_HasMultiCostItems && !itemComponent.currencyCosts.empty()) SetHasMultiCostItems(true);
|
||||||
@ -70,7 +77,7 @@ void VendorComponent::RefreshInventory(bool isCreation) {
|
|||||||
vendorItems.erase(vendorItems.begin() + randomItemIndex);
|
vendorItems.erase(vendorItems.begin() + randomItemIndex);
|
||||||
if (!m_HasStandardCostItems || !m_HasMultiCostItems) {
|
if (!m_HasStandardCostItems || !m_HasMultiCostItems) {
|
||||||
auto itemComponentID = compRegistryTable->GetByIDAndType(randomItem.itemid, eReplicaComponentType::ITEM, -1);
|
auto itemComponentID = compRegistryTable->GetByIDAndType(randomItem.itemid, eReplicaComponentType::ITEM, -1);
|
||||||
if (itemComponentID == -1) {
|
if (itemComponentID != -1) {
|
||||||
Game::logger->Log("VendorComponent", "Attempted to add item %i with ItemComponent ID -1 to vendor %i inventory. Not adding item!", itemComponentID, m_Parent->GetLOT());
|
Game::logger->Log("VendorComponent", "Attempted to add item %i with ItemComponent ID -1 to vendor %i inventory. Not adding item!", itemComponentID, m_Parent->GetLOT());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -82,6 +89,7 @@ void VendorComponent::RefreshInventory(bool isCreation) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
HandleMrReeCameras();
|
||||||
|
|
||||||
// Callback timer to refresh this inventory.
|
// Callback timer to refresh this inventory.
|
||||||
if (m_RefreshTimeSeconds > 0.0) {
|
if (m_RefreshTimeSeconds > 0.0) {
|
||||||
@ -102,24 +110,31 @@ void VendorComponent::SetupConstants() {
|
|||||||
std::vector<CDVendorComponent> vendorComps = vendorComponentTable->Query([=](CDVendorComponent entry) { return (entry.id == componentID); });
|
std::vector<CDVendorComponent> vendorComps = vendorComponentTable->Query([=](CDVendorComponent entry) { return (entry.id == componentID); });
|
||||||
if (vendorComps.empty()) return;
|
if (vendorComps.empty()) return;
|
||||||
auto vendorData = vendorComps.at(0);
|
auto vendorData = vendorComps.at(0);
|
||||||
m_BuyScalar = vendorData.buyScalar;
|
if (vendorData.buyScalar == 0.0) m_BuyScalar = Game::zoneManager->GetWorldConfig()->vendorBuyMultiplier;
|
||||||
|
else m_BuyScalar = vendorData.buyScalar;
|
||||||
m_SellScalar = vendorData.sellScalar;
|
m_SellScalar = vendorData.sellScalar;
|
||||||
m_RefreshTimeSeconds = vendorData.refreshTimeSeconds;
|
m_RefreshTimeSeconds = vendorData.refreshTimeSeconds;
|
||||||
m_LootMatrixID = vendorData.LootMatrixIndex;
|
m_LootMatrixID = vendorData.LootMatrixIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool VendorComponent::SellsItem(const LOT item) const {
|
||||||
|
return std::count_if(m_Inventory.begin(), m_Inventory.end(), [item](const SoldItem& lhs) {
|
||||||
|
return lhs.lot == item;
|
||||||
|
}) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
void VendorComponent::MaxCustomVendorRefreshInventory(bool isCreation){
|
|
||||||
if(isCreation && m_Parent->GetLOT() == 9749 && Game::server->GetZoneID() == 1201) {
|
|
||||||
SetHasStandardCostItems(true);
|
|
||||||
m_Inventory.push_back(SoldItem(11909, 0)); // Top hat w frog
|
|
||||||
m_Inventory.push_back(SoldItem(7785, 0)); // Flash bulb
|
|
||||||
m_Inventory.push_back(SoldItem(12764, 0)); // Big fountain soda
|
|
||||||
m_Inventory.push_back(SoldItem(12241, 0)); // Hot cocoa (from fb)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
void VendorComponent::SetupMaxCustomVendor(){
|
||||||
|
SetHasStandardCostItems(true);
|
||||||
|
m_Inventory.push_back(SoldItem(11909, 0)); // Top hat w frog
|
||||||
|
m_Inventory.push_back(SoldItem(7785, 0)); // Flash bulb
|
||||||
|
m_Inventory.push_back(SoldItem(12764, 0)); // Big fountain soda
|
||||||
|
m_Inventory.push_back(SoldItem(12241, 0)); // Hot cocoa (from fb)
|
||||||
|
}
|
||||||
|
|
||||||
|
void VendorComponent::HandleMrReeCameras(){
|
||||||
if (m_Parent->GetLOT() == 13569) {
|
if (m_Parent->GetLOT() == 13569) {
|
||||||
|
SetHasStandardCostItems(true);
|
||||||
auto randomCamera = GeneralUtils::GenerateRandomNumber<int32_t>(0, 2);
|
auto randomCamera = GeneralUtils::GenerateRandomNumber<int32_t>(0, 2);
|
||||||
|
|
||||||
LOT camera = 0;
|
LOT camera = 0;
|
||||||
|
@ -27,12 +27,12 @@ public:
|
|||||||
void OnUse(Entity* originator) override;
|
void OnUse(Entity* originator) override;
|
||||||
void RefreshInventory(bool isCreation = false);
|
void RefreshInventory(bool isCreation = false);
|
||||||
void SetupConstants();
|
void SetupConstants();
|
||||||
|
bool SellsItem(const LOT item) const;
|
||||||
float GetBuyScalar() const { return m_BuyScalar; }
|
float GetBuyScalar() const { return m_BuyScalar; }
|
||||||
float GetSellScalar() const { return m_SellScalar; }
|
float GetSellScalar() const { return m_SellScalar; }
|
||||||
void SetBuyScalar(const float value) { m_BuyScalar = value; }
|
void SetBuyScalar(const float value) { m_BuyScalar = value; }
|
||||||
void SetSellScalar(const float value) { m_SellScalar = value; }
|
void SetSellScalar(const float value) { m_SellScalar = value; }
|
||||||
|
const std::vector<SoldItem>& GetInventory() { return m_Inventory; }
|
||||||
std::vector<SoldItem>& GetInventory() { return m_Inventory; }
|
|
||||||
|
|
||||||
void SetHasMultiCostItems(const bool hasMultiCostItems) {
|
void SetHasMultiCostItems(const bool hasMultiCostItems) {
|
||||||
if (m_HasMultiCostItems == hasMultiCostItems) return;
|
if (m_HasMultiCostItems == hasMultiCostItems) return;
|
||||||
@ -46,14 +46,10 @@ public:
|
|||||||
m_DirtyVendor = true;
|
m_DirtyVendor = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SellsItem(const LOT item) const {
|
|
||||||
return std::count_if(m_Inventory.begin(), m_Inventory.end(), [item](const SoldItem& lhs) {
|
|
||||||
return lhs.lot == item;
|
|
||||||
}) > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MaxCustomVendorRefreshInventory(bool isCreation = false);
|
|
||||||
private:
|
private:
|
||||||
|
void SetupMaxCustomVendor();
|
||||||
|
void HandleMrReeCameras();
|
||||||
float m_BuyScalar = 0.0f;
|
float m_BuyScalar = 0.0f;
|
||||||
float m_SellScalar = 0.0f;
|
float m_SellScalar = 0.0f;
|
||||||
float m_RefreshTimeSeconds = 0.0f;
|
float m_RefreshTimeSeconds = 0.0f;
|
||||||
|
@ -277,7 +277,7 @@ void dZoneManager::LoadWorldConfig() {
|
|||||||
m_WorldConfig->characterMaxSlope = worldConfig.getFloatField("character_max_slope");
|
m_WorldConfig->characterMaxSlope = worldConfig.getFloatField("character_max_slope");
|
||||||
m_WorldConfig->defaultRespawnTime = worldConfig.getFloatField("defaultrespawntime");
|
m_WorldConfig->defaultRespawnTime = worldConfig.getFloatField("defaultrespawntime");
|
||||||
m_WorldConfig->missionTooltipTimeout = worldConfig.getFloatField("mission_tooltip_timeout");
|
m_WorldConfig->missionTooltipTimeout = worldConfig.getFloatField("mission_tooltip_timeout");
|
||||||
m_WorldConfig->vendorBuyMultiplier = worldConfig.getFloatField("vendor_buy_multiplier");
|
m_WorldConfig->vendorBuyMultiplier = worldConfig.getFloatField("vendor_buy_multiplier", 0.1);
|
||||||
m_WorldConfig->petFollowRadius = worldConfig.getFloatField("pet_follow_radius");
|
m_WorldConfig->petFollowRadius = worldConfig.getFloatField("pet_follow_radius");
|
||||||
m_WorldConfig->characterEyeHeight = worldConfig.getFloatField("character_eye_height");
|
m_WorldConfig->characterEyeHeight = worldConfig.getFloatField("character_eye_height");
|
||||||
m_WorldConfig->flightVerticalVelocity = worldConfig.getFloatField("flight_vertical_velocity");
|
m_WorldConfig->flightVerticalVelocity = worldConfig.getFloatField("flight_vertical_velocity");
|
||||||
|
Loading…
Reference in New Issue
Block a user