feat: Loot rework (#1909)

* feat: Loot rework

* Allow dupe powerup pickups

* change default team loot to shared
This commit is contained in:
David Markowitz
2025-10-14 22:53:39 -07:00
committed by GitHub
parent fd6029ae10
commit 74630b56c8
22 changed files with 685 additions and 324 deletions

View File

@@ -15,11 +15,6 @@ void ScriptedPowerupSpawner::OnTimerDone(Entity* self, std::string message) {
const auto itemLOT = self->GetVar<LOT>(u"lootLOT");
// Build drop table
std::unordered_map<LOT, int32_t> drops;
drops.emplace(itemLOT, 1);
// Spawn the required number of powerups
auto* owner = Game::entityManager->GetEntity(self->GetSpawnerID());
if (owner != nullptr) {
@@ -28,8 +23,19 @@ void ScriptedPowerupSpawner::OnTimerDone(Entity* self, std::string message) {
if (renderComponent != nullptr) {
renderComponent->PlayEffect(0, u"cast", "N_cast");
}
GameMessages::GetPosition posMsg{};
posMsg.target = self->GetObjectID();
posMsg.Send();
Loot::DropLoot(owner, self->GetObjectID(), drops, 0, 0);
GameMessages::DropClientLoot lootMsg{};
lootMsg.target = owner->GetObjectID();
lootMsg.ownerID = owner->GetObjectID();
lootMsg.sourceID = self->GetObjectID();
lootMsg.spawnPos = posMsg.pos;
lootMsg.item = itemLOT;
lootMsg.count = 1;
lootMsg.currency = 0;
Loot::DropItem(*owner, lootMsg, true, true);
}
// Increment the current cycle

View File

@@ -10,8 +10,21 @@ void AgPicnicBlanket::OnUse(Entity* self, Entity* user) {
return;
self->SetVar<bool>(u"active", true);
auto lootTable = std::unordered_map<LOT, int32_t>{ {935, 3} };
Loot::DropLoot(user, self->GetObjectID(), lootTable, 0, 0);
GameMessages::GetPosition posMsg{};
posMsg.target = self->GetObjectID();
posMsg.Send();
for (int32_t i = 0; i < 3; i++) {
GameMessages::DropClientLoot lootMsg{};
lootMsg.target = user->GetObjectID();
lootMsg.ownerID = user->GetObjectID();
lootMsg.sourceID = self->GetObjectID();
lootMsg.item = 935;
lootMsg.count = 1;
lootMsg.spawnPos = posMsg.pos;
lootMsg.currency = 0;
Loot::DropItem(*user, lootMsg, true);
}
self->AddCallbackTimer(5.0f, [self]() {
self->SetVar<bool>(u"active", false);

View File

@@ -415,9 +415,7 @@ void SGCannon::SpawnNewModel(Entity* self) {
}
if (lootMatrix != 0) {
std::unordered_map<LOT, int32_t> toDrop = {};
toDrop = Loot::RollLootMatrix(player, lootMatrix);
const auto toDrop = Loot::RollLootMatrix(player, lootMatrix);
for (const auto [lot, count] : toDrop) {
GameMessages::SetModelToBuild modelToBuild{};
modelToBuild.modelLot = lot;