mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-02 10:53:44 +00:00
Live DropClientLoot (12,501 decoded): use_position is set only when a player is the source (1,432, all activity rewards such as the dragon, Frakjaw and BONS chests); drops from enemies, smashables and chests leave it clear, so the client spawns the loot at the source object as it sees it and falls back to spawn_position only if that object is gone (LWODestroyableComponent::GetLootSpawnPos). Coins land where they spawn (final = spawn in all 3,158 coin drops); items land 10 units away (median 9.998, uniform direction) at spawn height. DLU always set use_position and scattered everything 4.2 units away. Inferred: the 10-unit rule for player-sourced items (live spread there ranges 0-58 units, source unknown). Check: kill enemies and smash crates: coins pop out of the object, items fly about 10 units away; open an activity chest (e.g. after a dragon or Frakjaw) and the loot still appears around you. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
44 lines
1.8 KiB
C++
44 lines
1.8 KiB
C++
#pragma once
|
|
|
|
#include "dCommonVars.h"
|
|
#include "eLootSourceType.h"
|
|
#include <unordered_map>
|
|
|
|
class Entity;
|
|
|
|
namespace GameMessages {
|
|
struct DropClientLoot;
|
|
};
|
|
|
|
namespace Loot {
|
|
struct Info {
|
|
LWOOBJID id = 0;
|
|
LOT lot = 0;
|
|
int32_t count = 0;
|
|
};
|
|
|
|
using Return = std::map<LOT, int32_t>;
|
|
|
|
Loot::Return RollLootMatrix(Entity* player, uint32_t matrixIndex);
|
|
void CacheMatrix(const uint32_t matrixIndex);
|
|
void GiveLoot(Entity* player, uint32_t matrixIndex, eLootSourceType lootSourceType = eLootSourceType::NONE);
|
|
void GiveLoot(Entity* player, const Loot::Return& result, eLootSourceType lootSourceType = eLootSourceType::NONE);
|
|
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);
|
|
|
|
// How far from where it spawns a dropped item lands, as live dropped them (median 10.0 units, uniform direction).
|
|
constexpr float ITEM_DROP_DISTANCE = 10.0f;
|
|
|
|
/**
|
|
* Fills DropClientLoot's use_position and final_position the way live did (12,501 live DropClientLoot).
|
|
* use_position is set only when a player is the source (activity rewards such as the dragon and BONS chests):
|
|
* otherwise the client spawns the loot at the source object where it is on the client, and only falls back
|
|
* to the spawn position if that object is gone. Coins land where they spawn; items land ITEM_DROP_DISTANCE away
|
|
* at the given angle (radians, around Y).
|
|
* Nothing is set when there is no spawn position.
|
|
*/
|
|
void SetDropPositions(GameMessages::DropClientLoot& lootMsg, bool sourceIsPlayer, float angle);
|
|
};
|