From e7934afaf68963b6602418a6b68c6ff52e5b3c88 Mon Sep 17 00:00:00 2001 From: adrunkhuman <16039109+adrunkhuman@users.noreply.github.com> Date: Sun, 30 Aug 2026 05:51:26 +0200 Subject: [PATCH] playerbot: dispose surplus navigation tools --- docs/playerbots.md | 9 +++++---- docs/testing.md | 2 +- .../playerbot-gameplay/assertions-navigation.ps1 | 14 ++++++++++---- scripts/playerbot-gameplay/scenarios-service.ps1 | 2 +- server/src/playerbotinventorypolicy.cpp | 2 +- server/tests/playerbot-gameplay/includes/login.inc | 3 +++ .../playerbot-gameplay/includes/verifiers.inc | 4 +++- 7 files changed, 24 insertions(+), 12 deletions(-) diff --git a/docs/playerbots.md b/docs/playerbots.md index d1ebec5b..a506504e 100644 --- a/docs/playerbots.md +++ b/docs/playerbots.md @@ -425,10 +425,11 @@ scan. A selected route is transferred into normal navigation, so it is not planned again. The selected actual locker ID, rather than the town ID, identifies the opened locker and player depot storage. Nested containers are opened and deposits are verified through normal item -movement. Equipped items, the root backpack, currency, rope, shovel, the potion -reserve, food, and unknown items are retained. The depot equips carried upgrades -through the normal verified equipment path, then treats displaced and inferior -equipment as ordinary cargo for sale or deposit. This prevents equipment from +movement. Equipped items, the root backpack, currency, one rope, one shovel, the +potion reserve, food, and unknown items are retained. Surplus ropes and shovels +are ordinary cargo for sale or deposit. The depot equips carried upgrades through +the normal verified equipment path, then treats displaced and inferior equipment +as ordinary cargo for sale or deposit. This prevents equipment from permanently consuming capacity without discarding upgrades. A carried weapon must improve maximum damage with the player's trained weapon skill; higher raw attack alone does not justify switching weapon classes. Two-handed weapons are diff --git a/docs/testing.md b/docs/testing.md index 625a3a43..e22a05e7 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -52,7 +52,7 @@ the changed behavior: | `-CombatReadiness` | Equipment, the one-potion return threshold and 10-potion restock target, optional-food hunting, generic food consumption and reclaimable capacity, low-wealth banking, carried-upgrade retention through service, and restart reconstruction. It does not cover the terminal case where total funds cannot buy enough potions to exceed the return threshold. | | `-EquipmentPurchases` | Justified purchase and equip verification, clean restart persistence, carried-upgrade recovery, displaced-item-space rejection, and rejected transactions. | | `-MainlandRewards` | Real Thais reward object from a teleported, high-capacity fixture; scale-armor claim and equip, displaced-item and bundle preservation, restart reconstruction, and non-null battle-axe rejection evidence. It does not prove normal traversal, realistic capacity limits, or a specific rejection reason. | -| `-Depot` | Real Thais locker/chest discovery from Naji, including exact nearest-locker selection, carried-upgrade equipment, displaced and inferior equipment deposits, nested loot, move verification, retries, and restart checkpoints. | +| `-Depot` | Real Thais locker/chest discovery from Naji, including exact nearest-locker selection, carried-upgrade equipment, displaced and inferior equipment deposits, one carried rope and shovel, surplus tool deposits, nested loot, move verification, retries, and restart checkpoints. | | `-SlottedLoot` | Invalid-slot loot sale through a live seller, direct depot fallback without an eligible seller, protected-equipment retention, move verification, and interrupted-deposit restart recovery. | | `-SellLoot` | Local and remote-depot liquidation, capacity-bounded manifests, verified withdrawal, seller travel, sale ordering, and proceeds-funded resupply. The workflow excludes fluid containers and splashes; current fixtures do not seed those item types. | | `-MainlandLoop` | Two real Thais hunt/depot cycles, local services, depot fallback for remote-buyer loot, restart recovery, and teleport exclusion. | diff --git a/scripts/playerbot-gameplay/assertions-navigation.ps1 b/scripts/playerbot-gameplay/assertions-navigation.ps1 index 8f46a3f3..b2187c83 100644 --- a/scripts/playerbot-gameplay/assertions-navigation.ps1 +++ b/scripts/playerbot-gameplay/assertions-navigation.ps1 @@ -296,7 +296,7 @@ function Assert-CorpseDetourEvents { } function Assert-DepotEvents { - param([string]$Logs, [int]$ExpectedDepositedCount, [int]$ExpectedEquipmentDeposits) + param([string]$Logs, [int]$ExpectedDepositedCount, [int]$ExpectedEquipmentDeposits, [int]$ExpectedToolDeposits = 0) $events = @(ConvertFrom-PlayerbotLogs -Logs $Logs) $discovery = @($events | Where-Object { @@ -330,6 +330,12 @@ function Assert-DepotEvents { $_.event -eq "action_result" -and $_.action -eq "deposit" -and $_.result -in @("success", "partial") -and $_.item_id -in @(2380, 2382) -and $_.verified -eq 1 }) + $toolDeposits = @($events | Where-Object { + $_.event -eq "action_result" -and $_.action -eq "deposit" -and $_.result -eq "success" -and + $_.item_id -in @(2120, 2554) -and $_.verified -eq 1 -and + $_.inventory_after -eq ($_.inventory_before - 1) -and $_.inventory_after -ge 1 -and + $_.depot_after -eq ($_.depot_before + 1) + }) $equipmentUpgrades = @($events | Where-Object { $_.event -eq "action_result" -and $_.action -eq "equip_readiness" -and $_.result -eq "success" -and $_.item_id -in @(2395, 2461, 2643) @@ -337,14 +343,14 @@ function Assert-DepotEvents { $deposited = ($verified | Measure-Object -Property verified -Sum).Sum $unsafeMoves = @($events | Where-Object { $_.event -eq "action_result" -and $_.action -eq "deposit" -and - $_.item_id -in @(2050, 2120, 2554, 2467, 2666, 7618) + $_.item_id -in @(2050, 2467, 2666, 7618) }) $terminal = @($events | Where-Object { $_.event -eq "terminal" }) if ($discovery.Count -lt 1 -or $locker.Count -lt 1 -or $chest.Count -lt 1 -or $deposited -ne $ExpectedDepositedCount -or $complete.Count -lt 1 -or $equipmentDeposits.Count -ne $ExpectedEquipmentDeposits -or $equipmentUpgrades.Count -ne (3 * [Math]::Min($ExpectedEquipmentDeposits, 1)) -or - $unsafeMoves.Count -ne 0 -or $terminal.Count -ne 0) { - throw "Real Thais depot evidence was incomplete. discovery=$($discovery.Count), depotId=$depotId, locker=$($locker.Count), chest=$($chest.Count), deposited=$deposited/$ExpectedDepositedCount, equipment_deposits=$($equipmentDeposits.Count)/$ExpectedEquipmentDeposits, equipment_upgrades=$($equipmentUpgrades.Count)/$(3 * [Math]::Min($ExpectedEquipmentDeposits, 1)), complete=$($complete.Count), unsafe=$($unsafeMoves.Count), terminal=$($terminal.Count)." + $toolDeposits.Count -ne $ExpectedToolDeposits -or $unsafeMoves.Count -ne 0 -or $terminal.Count -ne 0) { + throw "Real Thais depot evidence was incomplete. discovery=$($discovery.Count), depotId=$depotId, locker=$($locker.Count), chest=$($chest.Count), deposited=$deposited/$ExpectedDepositedCount, equipment_deposits=$($equipmentDeposits.Count)/$ExpectedEquipmentDeposits, equipment_upgrades=$($equipmentUpgrades.Count)/$(3 * [Math]::Min($ExpectedEquipmentDeposits, 1)), tool_deposits=$($toolDeposits.Count)/$ExpectedToolDeposits, complete=$($complete.Count), unsafe=$($unsafeMoves.Count), terminal=$($terminal.Count)." } } diff --git a/scripts/playerbot-gameplay/scenarios-service.ps1 b/scripts/playerbot-gameplay/scenarios-service.ps1 index 2cb845f0..d427a6d3 100644 --- a/scripts/playerbot-gameplay/scenarios-service.ps1 +++ b/scripts/playerbot-gameplay/scenarios-service.ps1 @@ -143,7 +143,7 @@ Invoke-Compose up --detach Invoke-DatabaseCommand -Query "INSERT INTO player_depotitems (player_id, sid, pid, itemtype, count, attributes) SELECT id, 9001, 2, 2684, 7, X'' FROM players WHERE name = 'Rook Tester'" $firstCycleLogs = Wait-ForLog -Pattern '"action":"deposit","result":"complete"' - Assert-DepotEvents -Logs $firstCycleLogs -ExpectedDepositedCount 2 -ExpectedEquipmentDeposits 2 + Assert-DepotEvents -Logs $firstCycleLogs -ExpectedDepositedCount 2 -ExpectedEquipmentDeposits 2 -ExpectedToolDeposits 4 Invoke-Compose stop server Invoke-Compose up --detach server diff --git a/server/src/playerbotinventorypolicy.cpp b/server/src/playerbotinventorypolicy.cpp index e24d6133..3aa7e053 100644 --- a/server/src/playerbotinventorypolicy.cpp +++ b/server/src/playerbotinventorypolicy.cpp @@ -163,7 +163,7 @@ bool PlayerBotInventoryPolicy::isProtectedDepositItem(const Player& player, cons return false; } const ItemType& type = Item::items[item.getID()]; - return (type.isContainer() && type.corpseType == RACE_NONE) || item.getID() == ropeItemId || item.getID() == 2554 || + return (type.isContainer() && type.corpseType == RACE_NONE) || ((type.slotPosition & SLOTP_TWO_HAND) != 0 && type.weaponType != WEAPON_NONE) || equipmentUpgrade(player, item) || item.getWorth() != 0 || sellValues.find(item.getID()) == sellValues.end(); } diff --git a/server/tests/playerbot-gameplay/includes/login.inc b/server/tests/playerbot-gameplay/includes/login.inc index 590abaa2..41586c24 100644 --- a/server/tests/playerbot-gameplay/includes/login.inc +++ b/server/tests/playerbot-gameplay/includes/login.inc @@ -473,6 +473,9 @@ function F.login.onLogin(player) assert(nested and nested:addItem(F.depotLootItemId, 1) and nested:addItem(F.depotLootItemId, 1) and nested:addItem(F.depotLootItemId, 1) and nested:addItem(F.depotLootItemId, 1), "depot fixture could not seed nested loot") assert(nested:addItem(2380, 1) and nested:addItem(F.seedWeaponId, 1) and nested:addItem(2461, 1) and nested:addItem(2643, 1), "depot fixture could not seed surplus equipment") assert(backpack:addItem(2050, 1), "depot fixture could not seed an unknown retained item") + assert(backpack:addItem(2120, 1) and backpack:addItem(2120, 1) and + backpack:addItem(2554, 1) and backpack:addItem(2554, 1), + "depot fixture could not seed surplus navigation tools") local restartPhase = os.getenv("PLAYERBOT_DEPOT_RESTART_PHASE") or "" assert(player:setStorageValue(F.depotFixtureStorage, restartPhase == "" and 0 or 2), "depot fixture state could not persist") elseif fixtureState == 0 then diff --git a/server/tests/playerbot-gameplay/includes/verifiers.inc b/server/tests/playerbot-gameplay/includes/verifiers.inc index 7027c8cb..bd88ee39 100644 --- a/server/tests/playerbot-gameplay/includes/verifiers.inc +++ b/server/tests/playerbot-gameplay/includes/verifiers.inc @@ -419,7 +419,9 @@ function F.verifyDepot(playerId, attempts) assert(player:getSlotItem(CONST_SLOT_LEFT):getId() == F.seedWeaponId, "carried weapon upgrade was not equipped") assert(player:getSlotItem(CONST_SLOT_HEAD):getId() == 2461, "carried helmet upgrade was not equipped") assert(player:getSlotItem(CONST_SLOT_FEET):getId() == 2643, "carried boot upgrade was not equipped") - assert(player:getItemCount(2120) == 1 and player:getItemCount(2554) == 1, "navigation tools were deposited") + assert(player:getItemCount(2120) == 1 and player:getItemCount(2554) == 1, "navigation tool reserves were not retained") + assert(chest:getItemCountById(2120) == 2 and chest:getItemCountById(2554) == 2, + "surplus navigation tools were not deposited") assert(player:getItemCount(F.potionItemId) >= 5 and player:getItemCount(F.meatItemId) >= 1, "supply reserves were deposited") print("PLAYERBOT_GAMEPLAY_TEST DEPOT_PASS") end