interact: add Loot Corpse binding (single-corpse loot mode)

LootAllCorpses now accepts an optional count argument to cap the queue.
LootAllCorpses(1) loots the nearest corpse and stops.
This commit is contained in:
MarcelineVQ
2026-04-06 00:57:07 -07:00
parent d1e2455fed
commit c600050d87
2 changed files with 10 additions and 2 deletions
+3
View File
@@ -5,6 +5,9 @@
<Binding name="Interact (auto-loot)">
InteractNearest(1)
</Binding>
<Binding name="Loot Corpse">
LootAllCorpses(1)
</Binding>
<Binding name="Loot All Corpses">
LootAllCorpses()
</Binding>
+7 -2
View File
@@ -300,9 +300,14 @@ fn processLootQueue() void {
interactNextCorpse();
}
pub fn lootAllCorpses(_: *anyopaque) callconv(.c) u32 {
pub fn lootAllCorpses(L: *anyopaque) callconv(.c) u32 {
if (!isInWorld()) return 0;
const max: usize = if (luaIsNumber(L, 1))
@intFromFloat(luaToNumber(L, 1))
else
MAX_LOOT_QUEUE;
// Cancel any in-progress chain
loot_queue_count = 0;
loot_queue_index = 0;
@@ -316,7 +321,7 @@ pub fn lootAllCorpses(_: *anyopaque) callconv(.c) u32 {
const p_pos = getUnitPosition(player);
while (current_object != 0 and (current_object & 1) == 0) {
if (loot_queue_count >= MAX_LOOT_QUEUE) break;
if (loot_queue_count >= max) break;
const guid = hook.readMem(u64, current_object + 0x30);
const pointer = getObjectPointer(guid);