-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: achievement vendor and vendor feedback (#1461)
* Groundwork * movie buying logic out of gm handler make transaction result more useful * Full implementation Cleanup and fix some calls in gamemessages * Load the component in the entity Patch Auth * new line at eof * cache lookups * remove sort * fix includes
- Loading branch information
1 parent
1328850
commit e729c7f
Showing
13 changed files
with
224 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#ifndef __EVENDORTRANSACTIONRESULT__ | ||
#define __EVENDORTRANSACTIONRESULT__ | ||
|
||
#include <cstdint> | ||
|
||
enum class eVendorTransactionResult : uint32_t { | ||
SELL_SUCCESS = 0, | ||
SELL_FAIL, | ||
PURCHASE_SUCCESS, | ||
PURCHASE_FAIL, | ||
DONATION_FAIL, | ||
DONATION_FULL | ||
}; | ||
|
||
#endif // !__EVENDORTRANSACTIONRESULT__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#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" | ||
|
||
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); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#ifndef __ACHIEVEMENTVENDORCOMPONENT__H__ | ||
#define __ACHIEVEMENTVENDORCOMPONENT__H__ | ||
|
||
#include "VendorComponent.h" | ||
#include "eReplicaComponentType.h" | ||
#include <set> | ||
#include <map> | ||
|
||
class Entity; | ||
|
||
class AchievementVendorComponent final : public VendorComponent { | ||
public: | ||
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::ACHIEVEMENT_VENDOR; | ||
AchievementVendorComponent(Entity* parent) : VendorComponent(parent) {}; | ||
bool SellsItem(Entity* buyer, const LOT lot); | ||
void Buy(Entity* buyer, LOT lot, uint32_t count); | ||
|
||
private: | ||
std::map<LWOOBJID,std::set<LOT>> m_PlayerPurchasableItems; | ||
}; | ||
|
||
|
||
#endif //!__ACHIEVEMENTVENDORCOMPONENT__H__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.