mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-02 10:53:44 +00:00
fix(loot): activity rewards drop from the player at the activity object
Live sent quickbuild completion loot (about 190 samples) and the dragon, BONS, spider queen and Frakjaw chest and wishing well rewards with the player who earned them as the DropClientLoot source and owner, use_position true and the spawn position at the object. DLU used the object as the source, so use_position was false. DropActivityLoot now uses the player as the source by default. The growing flowers and the VE mission console have no live samples and keep the object as the source. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -335,7 +335,8 @@ void DropRegularLoot(Team& team, GameMessages::DropClientLoot& lootMsg, const bo
|
||||
DistrbuteMsgToTeam(lootMsg, team);
|
||||
}
|
||||
|
||||
void DropLoot(Entity* player, const LWOOBJID source, const std::map<LOT, LootDropInfo>& rolledItems, uint32_t minCoins, uint32_t maxCoins, const bool noTeamLootOnDeath) {
|
||||
// source: the DropClientLoot source object; spawnPosition: where the loot spawns
|
||||
void DropLoot(Entity* player, const LWOOBJID source, const NiPoint3& spawnPosition, const std::map<LOT, LootDropInfo>& rolledItems, uint32_t minCoins, uint32_t maxCoins, const bool noTeamLootOnDeath) {
|
||||
player = player->GetOwner(); // if the owner is overwritten, we collect that here
|
||||
const auto playerID = player->GetObjectID();
|
||||
if (!player->IsPlayer()) {
|
||||
@@ -352,11 +353,6 @@ void DropLoot(Entity* player, const LWOOBJID source, const std::map<LOT, LootDro
|
||||
// if Free for all, drop everything with NO owner, except tokens which follow the same logic as above
|
||||
auto* team = TeamManager::Instance()->GetTeam(playerID);
|
||||
|
||||
GameMessages::GetPosition posMsg;
|
||||
posMsg.target = source;
|
||||
posMsg.Send();
|
||||
|
||||
const auto spawnPosition = posMsg.pos;
|
||||
auto* const objectsTable = CDClientManager::GetTable<CDObjectsTable>();
|
||||
|
||||
for (const auto& [lootLot, info] : rolledItems) {
|
||||
@@ -590,23 +586,36 @@ void Loot::GiveActivityLoot(Entity* player, const LWOOBJID source, uint32_t acti
|
||||
character->SetCoins(character->GetCoins() + coins, eLootSourceType::ACTIVITY, CoinSource::Object(*player));
|
||||
}
|
||||
|
||||
void Loot::DropLoot(Entity* player, const LWOOBJID source, uint32_t matrixIndex, uint32_t minCoins, uint32_t maxCoins) {
|
||||
player = player->GetOwner(); // if the owner is overwritten, we collect that here
|
||||
namespace {
|
||||
NiPoint3 GetDropSpawnPosition(const LWOOBJID object) {
|
||||
GameMessages::GetPosition posMsg;
|
||||
posMsg.target = object;
|
||||
posMsg.Send();
|
||||
return posMsg.pos;
|
||||
}
|
||||
|
||||
auto* scriptedActivityComponent = Game::entityManager->GetZoneControlEntity()->GetComponent<ScriptedActivityComponent>();
|
||||
const bool noTeamLootOnDeath = scriptedActivityComponent ? scriptedActivityComponent->GetNoTeamLootOnDeath() : false;
|
||||
void RollAndDropLoot(Entity* player, const LWOOBJID source, const NiPoint3& spawnPosition, uint32_t matrixIndex, uint32_t minCoins, uint32_t maxCoins) {
|
||||
player = player->GetOwner(); // if the owner is overwritten, we collect that here
|
||||
|
||||
auto* inventoryComponent = player->GetComponent<InventoryComponent>();
|
||||
auto* scriptedActivityComponent = Game::entityManager->GetZoneControlEntity()->GetComponent<ScriptedActivityComponent>();
|
||||
const bool noTeamLootOnDeath = scriptedActivityComponent ? scriptedActivityComponent->GetNoTeamLootOnDeath() : false;
|
||||
|
||||
if (!inventoryComponent)
|
||||
return;
|
||||
auto* inventoryComponent = player->GetComponent<InventoryComponent>();
|
||||
|
||||
const auto result = ::RollLootMatrix(matrixIndex, LiveEvents::LootChanceMultiplier());
|
||||
if (!inventoryComponent)
|
||||
return;
|
||||
|
||||
::DropLoot(player, source, result, minCoins, maxCoins, noTeamLootOnDeath);
|
||||
const auto result = ::RollLootMatrix(matrixIndex, LiveEvents::LootChanceMultiplier());
|
||||
|
||||
::DropLoot(player, source, spawnPosition, result, minCoins, maxCoins, noTeamLootOnDeath);
|
||||
}
|
||||
}
|
||||
|
||||
void Loot::DropActivityLoot(Entity* player, const LWOOBJID source, uint32_t activityID, int32_t rating) {
|
||||
void Loot::DropLoot(Entity* player, const LWOOBJID source, uint32_t matrixIndex, uint32_t minCoins, uint32_t maxCoins) {
|
||||
RollAndDropLoot(player, source, GetDropSpawnPosition(source), matrixIndex, minCoins, maxCoins);
|
||||
}
|
||||
|
||||
void Loot::DropActivityLoot(Entity* player, const LWOOBJID source, uint32_t activityID, int32_t rating, const bool fromPlayer) {
|
||||
CDActivityRewardsTable* activityRewardsTable = CDClientManager::GetTable<CDActivityRewardsTable>();
|
||||
std::vector<CDActivityRewards> activityRewards = activityRewardsTable->Query([activityID](CDActivityRewards entry) { return (entry.objectTemplate == activityID); });
|
||||
|
||||
@@ -623,5 +632,7 @@ void Loot::DropActivityLoot(Entity* player, const LWOOBJID source, uint32_t acti
|
||||
|
||||
const auto [minCoins, maxCoins] = GetActivityCoinRange(*selectedReward);
|
||||
|
||||
DropLoot(player, source, selectedReward->LootMatrixIndex, minCoins, maxCoins);
|
||||
// Live sent activity rewards from the player who earned them, spawning at the activity object
|
||||
const auto dropSource = fromPlayer ? player->GetOwner()->GetObjectID() : source;
|
||||
RollAndDropLoot(player, dropSource, GetDropSpawnPosition(source), selectedReward->LootMatrixIndex, minCoins, maxCoins);
|
||||
}
|
||||
|
||||
@@ -31,7 +31,12 @@ namespace Loot {
|
||||
void GiveActivityLoot(Entity* player, const LWOOBJID source, uint32_t activityID, int32_t rating = 0);
|
||||
void DropLoot(Entity* player, const LWOOBJID source, uint32_t matrixIndex, uint32_t minCoins, uint32_t maxCoins);
|
||||
void DropItem(Entity& player, GameMessages::DropClientLoot& lootMsg, bool useTeam = false, bool forceFfa = false);
|
||||
void DropActivityLoot(Entity* player, const LWOOBJID source, uint32_t activityID, int32_t rating = 0);
|
||||
/**
|
||||
* Drops the loot of an activity's reward for the given rating, spawning at the source object.
|
||||
* fromPlayer: the DropClientLoot source is the player instead of the object, as live sent quickbuild, chest and
|
||||
* wishing well rewards (use_position true, spawn position the object's).
|
||||
*/
|
||||
void DropActivityLoot(Entity* player, const LWOOBJID source, uint32_t activityID, int32_t rating = 0, bool fromPlayer = true);
|
||||
|
||||
/**
|
||||
* The coin range {min, max} of an ActivityRewards row, as live rolled it: the reward's ChallengeRating is the
|
||||
|
||||
Reference in New Issue
Block a user