[Tasks] Only update loot tasks for NPC corpses (#2513)

This fixes a bug that allowed looting items from a player's corpse to
increment a task if it didn't have an npc target defined. It looks
like this bug existed before the changes in 7482cfc0.

This also now passes count for task loot updates to handle item stacks.

Also fixes incorrectly casting Corpse to NPC on loot update
This commit is contained in:
hg
2022-11-05 11:13:02 -04:00
committed by GitHub
parent f6dbdf5db8
commit 070bf64d6a
6 changed files with 44 additions and 27 deletions
+6 -2
View File
@@ -1370,6 +1370,9 @@ void Corpse::LootItem(Client *client, const EQApplicationPacket *app)
}
}
// get count for task update before it's mutated by AutoPutLootInInventory
int count = inst->IsStackable() ? inst->GetCharges() : 1;
/* First add it to the looter - this will do the bag contents too */
if (lootitem->auto_loot > 0) {
if (!client->AutoPutLootInInventory(*inst, true, true, bag_item_data))
@@ -1380,8 +1383,9 @@ void Corpse::LootItem(Client *client, const EQApplicationPacket *app)
}
/* Update any tasks that have an activity to loot this item */
if (RuleB(TaskSystem, EnableTaskSystem))
client->UpdateTasksForItem(TaskActivityType::Loot, IsNPCCorpse() ? CastToNPC() : nullptr, item->ID);
if (RuleB(TaskSystem, EnableTaskSystem) && IsNPCCorpse()) {
client->UpdateTasksOnLoot(this, item->ID, count);
}
/* Remove it from Corpse */
if (item_data) {