fix(loot): DropClientLoot positions like live

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>
This commit is contained in:
Aaron Kimbrell
2026-09-29 03:00:24 -05:00
parent 81db3a94ac
commit 44c6340294
4 changed files with 105 additions and 13 deletions

View File

@@ -27,4 +27,17 @@ namespace Loot {
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);
};