fix: hardcore mode fixes (#1882)

fixes hardcore modes uscore drops
adds config option for excluded item drops
This commit is contained in:
David Markowitz
2025-09-21 18:36:32 -07:00
committed by GitHub
parent 4a577f233d
commit 4a5dd68e87
6 changed files with 47 additions and 24 deletions

View File

@@ -37,6 +37,7 @@
#include "eMissionTaskType.h"
#include "eStateChangeType.h"
#include "eGameActivity.h"
#include <ranges>
#include "CDComponentsRegistryTable.h"
@@ -981,7 +982,8 @@ void DestroyableComponent::DoHardcoreModeDrops(const LWOOBJID source) {
auto* character = m_Parent->GetComponent<CharacterComponent>();
auto uscore = character->GetUScore();
auto uscoreToLose = uscore * (Game::entityManager->GetHardcoreLoseUscoreOnDeathPercent() / 100);
auto uscoreToLose = static_cast<uint64_t>(uscore * (Game::entityManager->GetHardcoreLoseUscoreOnDeathPercent() / 100.0f));
LOG("Player %llu has lost %llu uscore!", m_Parent->GetObjectID(), uscoreToLose);
character->SetUScore(uscore - uscoreToLose);
GameMessages::SendModifyLEGOScore(m_Parent, m_Parent->GetSystemAddress(), -uscoreToLose, eLootSourceType::MISSION);
@@ -995,13 +997,11 @@ void DestroyableComponent::DoHardcoreModeDrops(const LWOOBJID source) {
if (items) {
auto itemMap = items->GetItems();
if (!itemMap.empty()) {
for (const auto& item : itemMap) {
//drop the item:
if (!item.second) continue;
// don't drop the thinkng cap
if (item.second->GetLot() == 6086) continue;
GameMessages::SendDropClientLoot(m_Parent, source, item.second->GetLot(), 0, m_Parent->GetPosition(), item.second->GetCount());
item.second->SetCount(0, false, false);
for (const auto item : itemMap | std::views::values) {
// Don't drop excluded items or null ones
if (!item || Game::entityManager->GetHardcoreExcludedItemDrops().contains(item->GetLot())) continue;
GameMessages::SendDropClientLoot(m_Parent, source, item->GetLot(), 0, m_Parent->GetPosition(), item->GetCount());
item->SetCount(0, false, false);
}
Game::entityManager->SerializeEntity(m_Parent);
}
@@ -1020,11 +1020,6 @@ void DestroyableComponent::DoHardcoreModeDrops(const LWOOBJID source) {
//drop all coins:
GameMessages::SendDropClientLoot(m_Parent, source, LOT_NULL, coins, m_Parent->GetPosition());
}
// Reload the player since we can't normally reduce uscore from the server and we want the UI to update
// do this last so we don't get killed.... again
Game::entityManager->DestructEntity(m_Parent);
Game::entityManager->ConstructEntity(m_Parent);
return;
}
@@ -1032,12 +1027,12 @@ void DestroyableComponent::DoHardcoreModeDrops(const LWOOBJID source) {
auto* player = Game::entityManager->GetEntity(source);
if (player && player->IsPlayer()) {
auto* playerStats = player->GetComponent<CharacterComponent>();
if (playerStats) {
if (playerStats && GetMaxHealth() > 0) {
//get the maximum health from this enemy:
auto maxHealth = GetMaxHealth();
int uscore = maxHealth * Game::entityManager->GetHardcoreUscoreEnemiesMultiplier();
LOG("Rewarding player %llu with %i uscore for killing enemy %i", player->GetObjectID(), uscore, m_Parent->GetLOT());
playerStats->SetUScore(playerStats->GetUScore() + uscore);
GameMessages::SendModifyLEGOScore(player, player->GetSystemAddress(), uscore, eLootSourceType::MISSION);