mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-05 18:24:12 +00:00
.github
cmake
dAuthServer
dChatFilter
dChatServer
dCommon
dDatabase
dGame
dBehaviors
dComponents
AchievementCacheKey.h
AchievementVendorComponent.cpp
AchievementVendorComponent.h
ActivityComponent.cpp
ActivityComponent.h
BaseCombatAIComponent.cpp
BaseCombatAIComponent.h
BouncerComponent.cpp
BouncerComponent.h
BuffComponent.cpp
BuffComponent.h
BuildBorderComponent.cpp
BuildBorderComponent.h
CMakeLists.txt
CharacterComponent.cpp
CharacterComponent.h
CollectibleComponent.cpp
CollectibleComponent.h
Component.cpp
Component.h
ControllablePhysicsComponent.cpp
ControllablePhysicsComponent.h
DestroyableComponent.cpp
DestroyableComponent.h
DonationVendorComponent.cpp
DonationVendorComponent.h
GhostComponent.cpp
GhostComponent.h
HavokVehiclePhysicsComponent.cpp
HavokVehiclePhysicsComponent.h
InventoryComponent.cpp
InventoryComponent.h
ItemComponent.cpp
ItemComponent.h
LUPExhibitComponent.cpp
LUPExhibitComponent.h
LevelProgressionComponent.cpp
LevelProgressionComponent.h
MiniGameControlComponent.cpp
MiniGameControlComponent.h
MinigameComponent.cpp
MissionComponent.cpp
MissionComponent.h
MissionOfferComponent.cpp
MissionOfferComponent.h
ModelComponent.cpp
ModelComponent.h
ModuleAssemblyComponent.cpp
ModuleAssemblyComponent.h
MovementAIComponent.cpp
MovementAIComponent.h
MovingPlatformComponent.cpp
MovingPlatformComponent.h
MultiZoneEntranceComponent.cpp
MultiZoneEntranceComponent.h
PetComponent.cpp
PetComponent.h
PhantomPhysicsComponent.cpp
PhantomPhysicsComponent.h
PhysicsComponent.cpp
PhysicsComponent.h
PlayerForcedMovementComponent.cpp
PlayerForcedMovementComponent.h
PossessableComponent.cpp
PossessableComponent.h
PossessorComponent.cpp
PossessorComponent.h
PropertyComponent.h
PropertyEntranceComponent.cpp
PropertyEntranceComponent.h
PropertyManagementComponent.cpp
PropertyManagementComponent.h
PropertyVendorComponent.cpp
PropertyVendorComponent.h
ProximityMonitorComponent.cpp
ProximityMonitorComponent.h
QuickBuildComponent.cpp
QuickBuildComponent.h
RacingControlComponent.cpp
RacingControlComponent.h
RacingSoundTriggerComponent.h
RacingStatsComponent.h
RailActivatorComponent.cpp
RailActivatorComponent.h
RenderComponent.cpp
RenderComponent.h
RigidbodyPhantomPhysicsComponent.cpp
RigidbodyPhantomPhysicsComponent.h
RocketLaunchpadControlComponent.cpp
RocketLaunchpadControlComponent.h
ScriptComponent.cpp
ScriptComponent.h
ScriptedActivityComponent.h
ShootingGalleryComponent.cpp
ShootingGalleryComponent.h
SimplePhysicsComponent.cpp
SimplePhysicsComponent.h
SkillComponent.cpp
SkillComponent.h
SoundTriggerComponent.cpp
SoundTriggerComponent.h
SwitchComponent.cpp
SwitchComponent.h
TriggerComponent.cpp
TriggerComponent.h
VendorComponent.cpp
VendorComponent.h
dEntity
dGameMessages
dInventory
dMission
dPropertyBehaviors
dUtilities
CMakeLists.txt
Character.cpp
Character.h
Entity.cpp
Entity.h
EntityManager.cpp
EntityManager.h
LeaderboardManager.cpp
LeaderboardManager.h
PlayerManager.cpp
PlayerManager.h
TeamManager.cpp
TeamManager.h
TradingManager.cpp
TradingManager.h
User.cpp
User.h
UserManager.cpp
UserManager.h
dMasterServer
dNavigation
dNet
dPhysics
dScripts
dServer
dWorldServer
dZoneManager
docs
migrations
resources
tests
thirdparty
vanity
.dockerignore
.editorconfig
.env.example
.git-blame-ignore-revs
.gitattributes
.gitignore
.gitmodules
CMakeLists.txt
CMakePresets.json
CMakeVariables.txt
CONTRIBUTING.md
Dockerfile
LICENSE
README.md
SECURITY.md
build.sh
docker-compose.yml
entrypoint.sh
logo.png
systemd.example
versions.txt
82 lines
3.5 KiB
C++
82 lines
3.5 KiB
C++
#include "AchievementVendorComponent.h"
|
|
#include "MissionComponent.h"
|
|
#include "InventoryComponent.h"
|
|
#include "eMissionState.h"
|
|
#include "CDComponentsRegistryTable.h"
|
|
#include "CDItemComponentTable.h"
|
|
#include "eVendorTransactionResult.h"
|
|
#include "CheatDetection.h"
|
|
#include "UserManager.h"
|
|
#include "CDMissionsTable.h"
|
|
|
|
AchievementVendorComponent::AchievementVendorComponent(Entity* parent) : VendorComponent(parent) {
|
|
RefreshInventory(true);
|
|
};
|
|
|
|
bool AchievementVendorComponent::SellsItem(Entity* buyer, const LOT lot) {
|
|
auto* missionComponent = buyer->GetComponent<MissionComponent>();
|
|
if (!missionComponent) return false;
|
|
|
|
if (m_PlayerPurchasableItems[buyer->GetObjectID()].contains(lot)) {
|
|
return true;
|
|
}
|
|
|
|
CDMissionsTable* missionsTable = CDClientManager::GetTable<CDMissionsTable>();
|
|
const auto missions = missionsTable->GetMissionsForReward(lot);
|
|
for (const auto mission : missions) {
|
|
if (missionComponent->GetMissionState(mission) == eMissionState::COMPLETE) {
|
|
m_PlayerPurchasableItems[buyer->GetObjectID()].insert(lot);
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
void AchievementVendorComponent::Buy(Entity* buyer, LOT lot, uint32_t count) {
|
|
// get the item Comp from the item LOT
|
|
CDComponentsRegistryTable* compRegistryTable = CDClientManager::GetTable<CDComponentsRegistryTable>();
|
|
CDItemComponentTable* itemComponentTable = CDClientManager::GetTable<CDItemComponentTable>();
|
|
int itemCompID = compRegistryTable->GetByIDAndType(lot, eReplicaComponentType::ITEM);
|
|
CDItemComponent itemComp = itemComponentTable->GetItemComponentByID(itemCompID);
|
|
uint32_t costLOT = itemComp.commendationLOT;
|
|
|
|
if (costLOT == -1 || !SellsItem(buyer, lot)) {
|
|
auto* user = UserManager::Instance()->GetUser(buyer->GetSystemAddress());
|
|
CheatDetection::ReportCheat(user, buyer->GetSystemAddress(), "Attempted to buy item %i from achievement vendor %i that is not purchasable", lot, m_Parent->GetLOT());
|
|
GameMessages::SendVendorTransactionResult(buyer, buyer->GetSystemAddress(), eVendorTransactionResult::PURCHASE_FAIL);
|
|
return;
|
|
}
|
|
|
|
auto* inventoryComponent = buyer->GetComponent<InventoryComponent>();
|
|
if (!inventoryComponent) {
|
|
GameMessages::SendVendorTransactionResult(buyer, buyer->GetSystemAddress(), eVendorTransactionResult::PURCHASE_FAIL);
|
|
return;
|
|
}
|
|
|
|
if (costLOT == 13763) { // Faction Token Proxy
|
|
auto* missionComponent = buyer->GetComponent<MissionComponent>();
|
|
if (!missionComponent) return;
|
|
|
|
if (missionComponent->GetMissionState(545) == eMissionState::COMPLETE) costLOT = 8318; // "Assembly Token"
|
|
if (missionComponent->GetMissionState(556) == eMissionState::COMPLETE) costLOT = 8321; // "Venture League Token"
|
|
if (missionComponent->GetMissionState(567) == eMissionState::COMPLETE) costLOT = 8319; // "Sentinels Token"
|
|
if (missionComponent->GetMissionState(578) == eMissionState::COMPLETE) costLOT = 8320; // "Paradox Token"
|
|
}
|
|
|
|
const uint32_t altCurrencyCost = itemComp.commendationCost * count;
|
|
if (inventoryComponent->GetLotCount(costLOT) < altCurrencyCost) {
|
|
GameMessages::SendVendorTransactionResult(buyer, buyer->GetSystemAddress(), eVendorTransactionResult::PURCHASE_FAIL);
|
|
return;
|
|
}
|
|
|
|
inventoryComponent->RemoveItem(costLOT, altCurrencyCost);
|
|
inventoryComponent->AddItem(lot, count, eLootSourceType::VENDOR);
|
|
GameMessages::SendVendorTransactionResult(buyer, buyer->GetSystemAddress(), eVendorTransactionResult::PURCHASE_SUCCESS);
|
|
|
|
}
|
|
|
|
void AchievementVendorComponent::RefreshInventory(bool isCreation) {
|
|
SetHasStandardCostItems(true);
|
|
Game::entityManager->SerializeEntity(m_Parent);
|
|
}
|