[Quest API] Add HasItemOnCorpse() to Perl/Lua (#3824)

# Perl
- Add `$client->HasItemOnCorpse(item_id)`.

# Lua
- Add `client:HasItemOnCorpse(item_id)`.

# Notes
- Allows operators to see if a player has an item on any of their corpses.
- May need to address having to allocate and deallocate memory for every corpse that could possibly exist for a player.
This commit is contained in:
Alex King
2023-12-30 23:09:48 -05:00
committed by GitHub
parent 87e63e1e36
commit 6c18cd0bee
7 changed files with 52 additions and 8 deletions
+28
View File
@@ -4789,3 +4789,31 @@ void Client::SummonItemIntoInventory(
slot_id
);
}
bool Client::HasItemOnCorpse(uint32 item_id)
{
const uint32 corpse_count = GetCorpseCount();
if (!corpse_count) {
return EQ::invslot::SLOT_INVALID;
}
for (int i = 0; i < corpse_count; i++) {
const uint32 corpse_id = GetCorpseID(i);
for (int16 slot_id = EQ::invslot::POSSESSIONS_BEGIN; slot_id < EQ::invslot::POSSESSIONS_END; slot_id++) {
const uint32 current_item_id = GetCorpseItemAt(corpse_id, slot_id);
if (current_item_id && current_item_id == item_id) {
return true;
}
}
for (int16 slot_id = EQ::invbag::GENERAL_BAGS_BEGIN; slot_id < EQ::invbag::GENERAL_BAGS_END; slot_id++) {
const uint32 current_item_id = GetCorpseItemAt(corpse_id, slot_id);
if (current_item_id && current_item_id == item_id) {
return true;
}
}
}
return false;
}