/mt_pickup 1 MASK picks up every own or ownerless ground item within the original pickup distance whose category matches the 8-bit mask, nearest first, capped at 48. Each item goes through the original PickupItem, so distance, stacking, inventory space, ItemLog GET and quest triggers are unchanged; only the first failure INFO line is resent. 500 ms throttle, MTPU1 done/error replies, MTF1 cap mask 127 -> 255. Live tested on the channel-5 test core (isolated binary) with the macOS native client. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
61 lines
3.8 KiB
Markdown
61 lines
3.8 KiB
Markdown
# PORT batch pickup, v1
|
|
|
|
AVA2-style batch pickup (reference: AVA2 `do_pickup_all`). One command picks up every ground item the character owns within the normal pickup distance, filtered by category. Source: `src/server/game/src/port_pickup.h`, command `mt_pickup` (cmd.cpp), throttle field `m_portPickupLastCommand` in char.h. It reuses the quiet-INFO hook (`m_portQuietInfo`) added for the switchbot. No packet header, no DB schema, no affect. AVA2's `HEADER_CG_ITEMS_PICKUP` packet and its premium automatic pickup (`AFFECT_AUTO_PICK_UP`, item 70002) are not ported.
|
|
|
|
## Rules
|
|
|
|
- Collection walks `ForEachAround` on the character's sectree. An item is taken only when it:
|
|
- is on the ground (has a sectree);
|
|
- passes `DistanceValid` (the original 300-unit pickup distance);
|
|
- passes `IsOwnership(ch)` (own or ownerless);
|
|
- matches the category mask.
|
|
- Party loot owned by someone else is excluded. `PickupItem`'s party branch would hand it to the requester, which is what AVA2 also avoids.
|
|
- Items are sorted nearest-first and capped at 48 per command. Each one is looked up again by VID and goes through the original `CHARACTER::PickupItem`. Distance, stacking, inventory space, `ItemLog GET` and quest triggers are therefore the original path's.
|
|
- Each successful pickup still sends its own INFO line. Of the failures (usually a full inventory), only the first INFO line is sent, once.
|
|
- Busy: dead, stunned, observer mode, warping, or no sectree.
|
|
- Throttle: one command per 500 ms per character.
|
|
|
|
## Protocol (CHAT_TYPE_COMMAND, version 1)
|
|
|
|
```
|
|
/mt_pickup 1 MASK MASK = 1..255, at most 3 digits
|
|
MTPU1 done FOUND PICKED FAILED
|
|
MTPU1 error rate|invalid|busy
|
|
```
|
|
|
|
A request with a version other than `1`, a token longer than 10 characters or more than 3 tokens is ignored silently.
|
|
|
|
| Bit | Category | Item type |
|
|
| --- | --- | --- |
|
|
| 1 | yang | `ITEM_ELK` |
|
|
| 2 | weapon | `ITEM_WEAPON` |
|
|
| 4 | armor / jewellery | `ITEM_ARMOR` |
|
|
| 8 | skill book | `ITEM_SKILLBOOK` |
|
|
| 16 | stone | `ITEM_METIN` |
|
|
| 32 | material | `ITEM_MATERIAL` |
|
|
| 64 | costume | `ITEM_COSTUME` |
|
|
| 128 | other | every other type |
|
|
|
|
Capability: the MTF1 cap mask advertises bit 128 (127 -> 255). The client also falls back to single pickup when it gets no reply within 3 s.
|
|
|
|
## Verification
|
|
|
|
- `tests/features/test_pickup.py` compiles the production header against stubs of the PickupItem/ChatPacket contract. It covers:
|
|
- nearest-first order;
|
|
- foreign and far items left on the ground;
|
|
- per-category masks;
|
|
- the yang/INFO pass-through;
|
|
- a full inventory (`done 8 3 5`, one failure line);
|
|
- the 48 cap;
|
|
- rate, invalid, busy and silently ignored input.
|
|
- `tests/features/test_queries.py` was updated for cap mask 255. `test_switchbot.py` still passes.
|
|
- FreeBSD build of the whole game target on 203 in `/root/metin2-features-dev`, log `/root/metin2-features-dev/pickup-build.log`. The live `/usr/metin2` binary was not replaced and no live service was restarted.
|
|
- Live test on 2026-10-15 against the channel-5 test core (`/usr/metin2/server/channel5/first`, port 13040, isolated binary) with the macOS native client as [SA]Admin. The test created weapon 19, armor 11209, material 30003, stone 28030 and skill book 50300 with `/item`, then dropped each one and 1000 yang:
|
|
- mask 2 → `done 1 1 0` (weapon only);
|
|
- mask 48 → `done 2 2 0` (stone + material);
|
|
- mask 255 → `done 3 3 0` (armor, book, yang; the yang balance was restored);
|
|
- nothing left → `done 0 0 0`, and an immediate second command → `error rate`.
|
|
- `log.log` has one `GET` row per item, matching the `DROP` rows. The original path logs no GET for yang.
|
|
- The core's syserr shows no new errors. The LOCALE_ERROR there comes from the original yang-drop message.
|
|
- Not done yet: a live full-inventory run and Android device validation.
|