Make loot accurate to the loot drop rates during live. (#216)

* loot fix (broken)

* Fixed loot

* Update SlashCommandHandler.cpp

* Remove debug command

* Roll loot command

* Remove debug log

* Added const references
When this commit is applied it adds const references to the loot system avoid some unnecessary copies.

Co-authored-by: wincent <wincent.holm@gmail.com>
Co-authored-by: Avery <averysumner@gmail.com>
This commit is contained in:
Jett
2021-12-20 10:25:45 +00:00
committed by GitHub
parent f7858ab183
commit 0531365cb5
29 changed files with 450 additions and 378 deletions

View File

@@ -70,7 +70,7 @@ void ActivityManager::StopActivity(Entity *self, const LWOOBJID playerID, const
SetActivityValue(self, playerID, 1, value1);
SetActivityValue(self, playerID, 2, value2);
Loot::GiveActivityLoot(player, self, gameID, CalculateActivityRating(self, playerID));
LootGenerator::Instance().GiveActivityLoot(player, self, gameID, CalculateActivityRating(self, playerID));
// Save the new score to the leaderboard and show the leaderboard to the player
LeaderboardManager::SaveScore(playerID, gameID, score, value1);

View File

@@ -8,7 +8,7 @@ void AgPicnicBlanket::OnUse(Entity *self, Entity *user) {
self->SetVar<bool>(u"active", true);
auto lootTable = std::unordered_map<LOT, int32_t> {{935, 3}};
Loot::DropLoot(user, self, lootTable, 0, 0);
LootGenerator::Instance().DropLoot(user, self, lootTable, 0, 0);
self->AddCallbackTimer(5.0f, [self]() {
self->SetVar<bool>(u"active", false);

View File

@@ -25,7 +25,7 @@ void BaseInteractDropLootServer::BaseUse(Entity* self, Entity* user)
self->SetNetworkVar(u"bInUse", true);
Loot::DropLoot(user, self, lootMatrix, 0, 0);
LootGenerator::Instance().DropLoot(user, self, lootMatrix, 0, 0);
self->AddCallbackTimer(cooldownTime, [this, self] () {
self->SetNetworkVar(u"bInUse", false);

View File

@@ -41,7 +41,7 @@ BootyDigServer::OnFireEventServerSide(Entity *self, Entity *sender, std::string
if (renderComponent != nullptr)
renderComponent->PlayEffect(7730, u"cast", "bootyshine");
Loot::DropLoot(player, self, 231, 75, 75);
LootGenerator::Instance().DropLoot(player, self, 231, 75, 75);
}
}
} else if (args == "ChestDead") {

View File

@@ -6,6 +6,7 @@
#include "MissionState.h"
#include "Game.h"
#include "dLogger.h"
#include "Loot.h"
class User;
class Entity;

View File

@@ -10,7 +10,7 @@ void GrowingFlower::OnSkillEventFired(Entity *self, Entity *target, const std::s
const auto mission1 = self->GetVar<int32_t>(u"missionID");
const auto mission2 = self->GetVar<int32_t>(u"missionID2");
Loot::DropActivityLoot(target, self, self->GetLOT(), 0);
LootGenerator::Instance().DropActivityLoot(target, self, self->GetLOT(), 0);
auto* missionComponent = target->GetComponent<MissionComponent>();
if (missionComponent != nullptr) {

View File

@@ -22,10 +22,10 @@ void MinigameTreasureChestServer::OnUse(Entity *self, Entity *user) {
for (const auto& teamMemberID : team->members) {
auto* teamMember = EntityManager::Instance()->GetEntity(teamMemberID);
if (teamMember != nullptr)
Loot::DropActivityLoot(teamMember, self, sac->GetActivityID(), CalculateActivityRating(self, teamMemberID));
LootGenerator::Instance().DropActivityLoot(teamMember, self, sac->GetActivityID(), CalculateActivityRating(self, teamMemberID));
}
} else {
Loot::DropActivityLoot(user, self, sac->GetActivityID(), CalculateActivityRating(self, user->GetObjectID()));
LootGenerator::Instance().DropActivityLoot(user, self, sac->GetActivityID(), CalculateActivityRating(self, user->GetObjectID()));
}
sac->PlayerRemove(user->GetObjectID());

View File

@@ -10,6 +10,6 @@ void NjDragonEmblemChestServer::OnUse(Entity *self, Entity *user) {
auto* destroyable = self->GetComponent<DestroyableComponent>();
if (destroyable != nullptr) {
Loot::DropLoot(user, self, destroyable->GetLootMatrixID(), 0, 0);
LootGenerator::Instance().DropLoot(user, self, destroyable->GetLootMatrixID(), 0, 0);
}
}

View File

@@ -423,7 +423,7 @@ void SGCannon::SpawnNewModel(Entity *self) {
if (lootMatrix != 0) {
std::unordered_map<LOT, int32_t> toDrop = {};
Loot::CalculateLootMatrix(lootMatrix, player, toDrop);
toDrop = LootGenerator::Instance().RollLootMatrix(player, lootMatrix);
for (auto drop : toDrop) {
rewardModel->OnFireEventServerSide(self, ModelToBuildEvent, drop.first);
@@ -581,7 +581,7 @@ void SGCannon::StopGame(Entity *self, bool cancel) {
);
}
Loot::GiveActivityLoot(player, self, GetGameID(self), self->GetVar<uint32_t>(TotalScoreVariable));
LootGenerator::Instance().GiveActivityLoot(player, self, GetGameID(self), self->GetVar<uint32_t>(TotalScoreVariable));
StopActivity(self, player->GetObjectID(), self->GetVar<uint32_t>(TotalScoreVariable),
self->GetVar<uint32_t>(MaxStreakVariable), percentage);

View File

@@ -24,7 +24,7 @@ void ScriptedPowerupSpawner::OnTimerDone(Entity *self, std::string message) {
renderComponent->PlayEffect(0, u"cast", "N_cast");
}
Loot::DropItem(owner, self, itemLOT, 0, 1, true, true);
LootGenerator::Instance().DropLoot(owner, self, itemLOT, 0, 1);
}
// Increment the current cycle

View File

@@ -39,12 +39,12 @@ void TreasureChestDragonServer::OnUse(Entity* self, Entity* user)
if (memberObject == nullptr) continue;
Loot::DropActivityLoot(memberObject, self, scriptedActivityComponent->GetActivityID(), rating);
LootGenerator::Instance().DropActivityLoot(memberObject, self, scriptedActivityComponent->GetActivityID(), rating);
}
}
else
{
Loot::DropActivityLoot(user, self, scriptedActivityComponent->GetActivityID(), rating);
LootGenerator::Instance().DropActivityLoot(user, self, scriptedActivityComponent->GetActivityID(), rating);
}
self->Smash(self->GetObjectID());

View File

@@ -4,7 +4,7 @@
#include "GameMessages.h"
void VeMissionConsole::OnUse(Entity *self, Entity *user) {
Loot::DropActivityLoot(user, self, 12551);
LootGenerator::Instance().DropActivityLoot(user, self, 12551);
auto* inventoryComponent = user->GetComponent<InventoryComponent>();
if (inventoryComponent != nullptr) {

View File

@@ -24,7 +24,7 @@ void WishingWellServer::OnUse(Entity* self, Entity* user)
GameMessages::SendPlayNDAudioEmitter(self, user->GetSystemAddress(), audio);
}
Loot::DropActivityLoot(
LootGenerator::Instance().DropActivityLoot(
user,
self,
static_cast<uint32_t>(scriptedActivity->GetActivityID()),