commit b9377d715f889d3ea81c055442fd33922161276f
parent ccaf019160aefac853ccb514dfb822229aaed90d
Author: anon <anon@example.com>
Date: Sun, 25 Oct 2026 00:31:28 +0000
Support catalog implants across all thirteen slots
Diffstat:
6 files changed, 737 insertions(+), 94 deletions(-)
diff --git a/TODO.md b/TODO.md
@@ -136,21 +136,17 @@ unverified mass/deletion/reclaim policies are in [backpacks](docs/backpacks.md).
qualities and rounding boundaries, including after equip/remove and restart.
- [x] Equip one implant. Check: its slot, treatment/ability requirements and
bonuses work independently of armor and weapon slots.
-- [ ] Expand implant admission to complete catalog contracts and slots.
- Check Jobe SkillLockModifier382 sources, signed bonuses, strict requirements,
- surgery access, removal and cold recovery with actual WASM gear changes.
- Verify live use and cold restoration with changed real implant modifiers.
- Native FullCharacter applies installed OnWear effects before directly restoring
- its remaining-second lock pairs; it does not rescale those pairs.
- Original modifier-only fixtures include chest178218/219, leg191026/027 and
- hand193502/503; QL1 bonuses are positive and QL200 negative. Exact records are
- retained in `local/skill-lock-research/catalog/`. Do not infer intermediate
- qualities or silently admit unsupported OnWear effects.
- The complete 44,356-definition implant audit and 13-slot fixtures are in
- `local/implant-catalog-research/`. Authored QLs are 1, 200, 201 and 300;
- there are no QL400 implants. Respect multi-slot masks, reject complete items
- with unsupported effect stats or unknown section contracts, and evaluate
- action7 for removal independently of action6 installation requirements.
+- [ ] Complete the remaining 8,604 implant contracts before admitting them.
+ Implement consumers for absorption226/227/228/229/230/231/233/234 and stats
+ 277/318/343/364/381/383; establish each original rule before naming unknown
+ stats. Support conditional OnWear130263, Notum Splice204649's complete usable
+ effect, and the unclassified sections of six additional dungeon implants.
+ Do not grant partial effects. Complete records and rejected fixtures are in
+ `local/implant-catalog-research/`.
+- [ ] Recover implant interpolation contracts and original endpoint pairing.
+ Check representative requirements, signed bonuses and native proxy templates
+ across ordinary and refined intermediate qualities. Authored endpoints are
+ QL1/200/201/300; there are no QL400 implants. Do not infer pairs from names.
- [x] Equip one belt. Check: the corresponding deck slots become available and
invalid belt removal cannot strand installed equipment.
- [x] Install one NCU memory. Check: available NCU changes by the item's amount
@@ -174,8 +170,8 @@ server-side damage checks are recorded in [armor](docs/armor.md). These stat
bonus milestones use AC; broader skill and resource modifiers remain future work.
The axe's requirement tiers, native field adjustment, checks and remaining
server arithmetic limits are recorded in [overequipping](docs/overequipping.md).
-The QL 1 chest implant, portable clinic self-use, Treatment requirements,
-cooldown persistence and native verification are recorded in
+Catalog implants across all 13 slots, portable clinic self-use, authored
+requirements, signed cooldown modifiers and native verification are recorded in
[implants](docs/implants.md).
The Ti-100X belt, QL 1 memory, deck placement rules, native delays and persistent
capacity checks are recorded in [belts and NCU](docs/belts-ncu.md).
@@ -479,7 +475,7 @@ replay/failure tests and WASM checks are recorded in [IP training](docs/ip-train
simultaneous skills, cold restoration and last-charge deletion are verified.
Two racing healers share one patient lock; deleting a healer preserves it.
Modifier rounding and combined equipment/nano effects have regression coverage;
- real Jobe implant admission and WASM modifier changes remain tracked above.
+ real Jobe admission and WASM modifier changes are verified in the implant work above.
See [skill locks](docs/skill-locks.md).
The First Aid item, native charge protocol and unresolved combat-healing
diff --git a/docs/implants.md b/docs/implants.md
@@ -1,34 +1,84 @@
-# Chest implant and portable surgery clinic
-
-The supported implant is template 101173, exact QL 1, native type 51022:
-Chest Implant: Melee/Ma AC, Shiny. Its shipped record is in
-`server/gamedata/items/items_011.yaml`, with payload SHA-256
-`9cafdcadc8aa4b78a079b9265a758fe0a061d2256c967da42bf93fbd405af4e9`.
-[Auno's historical 14.8 record](https://auno.org/ao/db.php?id=101173&patch=14080000)
-corroborates the requirements and bonus.
-
-| Property | Recovered value |
-| --- | --- |
-| Implant class, stat 76 | 3 |
-| Location mask, stat 298 | 32, bit 5 |
-| Native placement | Page 103, absolute slot 37 |
-| Install action 6 | Treatment > 10 and Strength > 5 |
-| OnWear | Modify 53045, Melee AC 91 +8 |
-| EquipDelay 211 | Inherited 10 centiseconds; no template override |
-
-The implant uses neither chest armor slot 21 nor weapon slot 6. Server AC is
-derived from the currently equipped armor and implant, without saving a second
-modifier balance. The QL 1 Metaplast chest, boots and implant total Melee AC 14;
-removing the implant leaves 6. Other AC types keep the armor's contributions.
-Installing requires the effective Treatment skill, including ability trickle;
-removal does not recheck the install requirements.
+# Implants and surgery access
+
+Implants use native type 51022, ItemType 76=3 and Wear bit 4 in Can30. Admission
+requires the exact authored quality, a valid anatomical mask and a complete
+implemented effect contract. The decoded catalog contains 44,356 implant
+definitions; 35,752 currently qualify. Authored qualities are 1, 200, 201 and
+300; no QL400 implants exist.
+Intermediate qualities are not inferred from matching names.
+
+Every admitted function is unconditional OnWear14 Modify53045, target2, one
+tick and zero interval, with two integer arguments. Supported consumers cover
+abilities, all trained skills, AC, health/nano maxima, NCU, offense, damage,
+XP, weapon range and SkillLockModifier382. Blank implants also qualify.
+Conditional/repeating effects, unsupported stat consumers, other use effects,
+unparsed data and unknown section contracts reject the complete item. The
+remaining 8,604 definitions are unavailable until their full behavior is modeled.
+
+## Slots and installation
+
+LocationMask298 uses bit `absolute_slot-32`; multi-slot masks permit every
+matching slot. The authored default position selects a UI default, without
+restricting an item to that one position.
+
+| Slot | Anatomy | Mask |
+| ---: | --- | ---: |
+|33|Eyes|2|
+|34|Head|4|
+|35|Ears|8|
+|36|Right arm|16|
+|37|Chest|32|
+|38|Left arm|64|
+|39|Right wrist|128|
+|40|Waist|256|
+|41|Left wrist|512|
+|42|Right hand|1024|
+|43|Legs|2048|
+|44|Left hand|4096|
+|45|Feet|8192|
+
+Installation evaluates the complete authored action6 postfix expression,
+including strict Treatment/ability/title thresholds and intrinsic breed,
+profession or side restrictions. Missing action6 imposes no wear requirements;
+Plastic Muscles' separate action3 criteria do not become invented wear gates.
+Occupied implant destinations reject insertion. Removal evaluates action7 when
+authored, independently of action6. Both permission and applicable criteria are
+checked again when the delayed move completes.
+
+EquipDelay211 inherits10 centiseconds (100ms) when absent. Authored overrides
+remain effective, including50 centiseconds for Plastic Muscles. Each complete
+move persists the same instance and its resource clamps atomically before
+publishing effects. Implants bypass armor overequipping; dropping below an
+installation threshold does not reduce their installed modifiers.
+
+Template101173/QL1 is a representative chest implant: Treatment>10 AND
+Strength>5, MeleeAC91 +8, mask32 and inherited100ms delay. The QL1 Metaplast
+chest, boots and implant total MeleeAC14; removing the implant leaves6. Derived
+bonuses come from current equipment, without a second persisted modifier balance.
+
+## Jobe cooldown modifiers
+
+Pure modifier implants include chest178218/219 (+2/-2), leg191026/027 (+5/-5)
+and left-hand193502/503 (+3/-3) at QL1/200. Positive signs in the original QL1
+data increase cooldown duration. Leg endpoints illustrate the strict gates:
+
+| Template/QL | Modifier382 | Treatment > | Stamina > | Title level > |
+| --- | ---: | ---: | ---: | ---: |
+|191026/1|5|10|15|2|
+|191027/200|-5|1004|413|3|
+|191028/201|-5|1000|425|4|
+|191029/300|-9|2050|1094|5|
+
+New uses sample the effective modifier once. Equipment changes preserve each
+existing absolute deadline. FullCharacter restores its remaining-second pairs
+directly after applying installed OnWear effects; it does not rescale them with
+the current gear. See [skill locks](skill-locks.md) for native rounding and expiry.
Treatment is a persisted base skill. Resource 1000204/124 supplies weights
`[0,30,0,50,20,0]` for Strength, Agility, Stamina, Intelligence, Sense and Psychic.
The native skill calculation is documented in [starting stats](combat-starting-stats.md).
The native default initializer `10072760`, specifically its store at `10072853`,
-sets Treatment base 5. New and older profiles missing this field use that
-baseline, replacing the server's previous fixed Treatment 100 placeholder.
+sets Treatment base5, also used by current character creation.
This is verified client default behavior; historical server character-creation
values remain unproven. FullCharacter transmits the base skill so the client
applies trickle once.
@@ -46,7 +96,7 @@ The clinic requires Treatment > 5 and a selected character. Its raw
Treatment cooldown. Native LookAt `2252445f` reports the selected identity and
mode. The request's separate user identity must still be its actual owner.
-Authored Use effects lock the target's Treatment for 600 seconds and grant
+Authored Use effects start a raw 600-second Treatment lock and grant
Features 224 bit 0x10 for 30 seconds. The portable clinic adds no Treatment
bonus. Both installation and removal require this permission, including at
completion of a pending equipment move. A full ordinary inventory cannot
@@ -56,7 +106,7 @@ ownership checks and atomic inventory saves also apply.
The server saves absolute permission and cooldown deadlines before acknowledging
use. Repeated requests cannot extend either deadline. Reconnect/restart restores
the remaining window and cooldown, without re-executing the 30-second Use effect.
-Expiry removes the permission and unlocks Treatment. The cooldown uses shared
+Each expiry clears its corresponding permission or skill lock. The cooldown uses shared
[SkillLockModifier382 rules](skill-locks.md); its independent access window
remains 30 seconds. Historical handling of portable permission
across zoning, death and server downtime remains unverified; retaining these
@@ -75,7 +125,7 @@ The server therefore follows the acknowledgement with TemplateAction `35505644`:
The auxiliary identity selects the effect recipient. It is required for the
clinic's target-3 effects. Ordinary placement slots are translated between saved
64..93 and native 48..77, including this message. CharacterAction `5e477770`
-with body `{170,0,0,124,remainingSeconds}` installs the native Treatment lock;
+with body `{170,0,0,124,rawSeconds}` starts the native Treatment lock;
`{164,0,0,0,124}` clears it. LockSkill's authored function reaches an original
client stub, so the explicit server lock response is necessary.
@@ -84,8 +134,9 @@ The owner restores active Features 224 bit 0x10 through FullCharacter. StatIIR
authors no other Features bits.
Implant moves use ContainerAddItem `47537a24`: source page 104 for installation,
-page 103/slot 37 for removal, and destination 111 for first free ordinary slot.
-TemplateAction 6/7 applies/removes the implant bonus using placement 103/37.
+page103/absolute implant slot for removal, and destination111 for the first free
+ordinary slot. TemplateAction6/7 applies/removes the implant bonus using
+placement103 and the absolute slot33..45.
FullCharacter already applies installed implant effects during initialization;
another owner wear message would double the bonus. Observers receive one wear
action after their SimpleChar snapshot, as with armor.
@@ -98,6 +149,9 @@ Addresses use its original base 0x10000000; generated C uses 0x36000000.
The retained `local/reports/implant-protocol-1491-evidence.json` has 136 REA
records. Catalog and historical-page extracts are in
`local/implant-smoke/source-ledger.json` and `treatment-weights.json`.
+The complete catalog audit, original verification of every family payload,
+49 independently re-parsed fixtures, 146 complete native evidence records and
+22 complete translated routines are retained in `local/implant-catalog-research/`.
| Finding | Original function | Evidence ID |
| --- | --- | --- |
@@ -115,34 +169,42 @@ supported network CharacterAction.
## Verification
-The maintained `go test ./server/... -count=1` suite passed in 98.280 seconds.
-Focused race tests covering implants, clinics, armor, equipment, backpacks and
-character stats passed in 120.598 seconds. Tests cover exact requirement
-boundaries, inherited delay, source-page validation, occupied slots, full
-inventory removal, failed saves, permission expiry during a pending move,
-request replay, cooldown expiry, ownership and persistent state. FullCharacter
-checks verify base Treatment and restored permission without duplicating AC.
-
-Actual Chromium WASM tests are retained in `local/implant-smoke/`, including
-screenshots, packet logs, five read-only native inventory snapshots and three
-native Treatment-lock snapshots. The native UI installed the implant in slot
-37, changed Melee AC from 6 to 14, removed it back to 6, and reinstalled it.
-Projectile AC stayed 6 and attack rating stayed 400. Treatment 10 and Strength
-5 failed; the qualifying fixture used Treatment 11 and Strength 10. Removing
-after the real 30-second access expiry failed. A second browser character kept
-its empty inventory and zero AC.
-
-Reconnect and server restart restored the same five item identities and native
-AC 14, with no duplicate OnWear bonus. The Treatment-lock list contained stat
-124 with 589 seconds after use, 524 after reconnect, and 407 after the final
-server restart. Its saved absolute deadline stayed unchanged when use was
-rejected during cooldown. The test fixture advanced the clinic clock between
-repeat scenarios; production exposes no such endpoint. Native permission
-restoration is covered by FullCharacter stat assertions; an early UI removal
-attempt during a short reload was inconclusive and is excluded from the
-manual completion checks.
-
-There were no client exceptions or adapter failures. Seven connection-refused
-console messages occurred during the intentional server restart. All test
-browser contexts, temporary server and native analysis sessions were closed;
-the temporary fixture binary was removed.
+The full `go test ./server/... -count=1 -timeout 20m` suite passed in 547.172
+seconds. Focused race checks passed in 111.941 seconds; additional malformed
+contract/default-delay checks passed in 10.203 seconds, and vet was clean.
+Logs are under `local/implant-catalog-checks/`.
+
+Tests validate every decoded implant against the independently audited family
+counts, all 13 install/remove routes, owner/observer placement, identity and
+cold recovery. They exercise exact Jobe qualities and strict Treatment,
+ability/title/breed boundaries, multi-slot masks, independent action7 removal,
+missing action6, authored/inherited delays, whole-item unsupported-effect
+rejection, full inventory, failed saves and completion-time revalidation.
+Resource, ability, skill and NCU fixtures apply once and restore their bases;
+removal clamps HP/nano atomically. Real Jobe fixtures sample signed cooldown
+modifiers and preserve existing deadlines through gear removal and restart.
+
+Actual GPU/OpenGL Chromium WASM checks are under
+`local/implant-catalog-smoke/`. The native UI installs all 13 anatomical slots,
+shows the exact AC/skill contributions, rejects an occupied leg slot and
+conserves the original 21 instances. Original Jobe 191026/QL1 produces modifier +5,
+a raw 600 clinic lock lasting 629 seconds, and raw 40 First Aid lasting 41.
+Swapping to 191027/QL200 gives -5 without altering either existing deadline;
+a later First Aid use lasts 38 seconds and a repeat consumes nothing.
+
+Page reload and an actual server restart retain the same instances, modifier -5
+and original clinic deadline. Native removal fails after the real 30-second
+surgery window expires. After a declared GM access-window extension, removing
+the negative implant and reloading restores modifier 0 while retaining that
+deadline. Returning all remaining implants to ordinary inventory restores
+their baseline stats and preserves all 21 instances; only the two actual stim
+uses reduce its count from 25 to 23. Native snapshots and complete world-stream
+parsing verify 15 wear and 15 unwear actions, with no owner wear replays during
+FullCharacter restoration.
+
+Raw player skills and extended surgery access are explicit GM fixtures to
+permit the long manual run. Cooldown deadlines are never edited. Owned
+fixtures are removed with FK/integrity checks and unchanged hashes for every
+unrelated table. Browser runs have no exceptions or adapter failures. Earlier
+chest/clinic boundary and second-character isolation evidence remains under
+`local/implant-smoke/`.
diff --git a/server/equipment.go b/server/equipment.go
@@ -29,10 +29,11 @@ func (item ownedItem) fitsEquipmentSlot(slot uint32) bool {
if item.isClothing() {
return slot >= 16 && slot < 32 && itemStat(gamedata.ItemTemplates[item.Template], 298)&(1<<(slot-16)) != 0
}
+ if item.isImplant() {
+ return slot >= 33 && slot <= 45 && itemStat(gamedata.ItemTemplates[item.Template], 298)&(1<<(slot-32)) != 0
+ }
if item.Type == 51022 && item.Quality == 1 {
switch item.Template {
- case 101173:
- return slot == 37
case 36783:
return slot == 7
case 36779:
@@ -60,14 +61,10 @@ func (character *character) canEquip(item ownedItem) bool {
stats := character.baseStats()
return character.effectiveSkill(161, stats.TradeRepair.ComputerLiteracy, [6]uint32{0, 0, 0, 100, 0, 0}) > 5
}
- if item.fitsEquipmentSlot(37) {
- stats := character.baseStats()
- return character.effectiveAbility(16) > 5 && character.effectiveSkill(124, stats.NanoAiding.Treatment, [6]uint32{0, 30, 0, 50, 20, 0}) > 10
- }
if item.isWieldableWeapon() {
return item.requirementsMet(8, character.meetsStatRequirement)
}
- if item.isClothing() {
+ if item.isClothing() || item.isImplant() {
return item.requirementsMet(6, character.meetsStatRequirement)
}
return false
@@ -112,7 +109,8 @@ func (character *character) canMoveEquipment(item ownedItem, destination uint32,
if destination < 64 && (!item.fitsEquipmentSlot(destination) || !character.canEquip(item)) {
return false
}
- if item.fitsEquipmentSlot(37) && !now.Before(character.implantChangesUntil) {
+ if item.isImplant() && (!now.Before(character.implantChangesUntil) ||
+ item.Slot < 64 && !item.requirementsMet(7, character.meetsStatRequirement)) {
return false
}
@@ -150,7 +148,7 @@ func itemMovePacket(owner, source, destination uint32) []byte {
page = 101
} else if source >= 16 && source < 32 {
page = 102
- } else if source == 37 {
+ } else if source >= 33 && source <= 45 {
page = 103
}
var body []byte
@@ -272,7 +270,7 @@ func (server *server) advanceEquipment(now time.Time) {
character.position = position
client.movementStarted = now
}
- if move.source == 1 || move.source == 7 || move.source >= 9 && move.source <= 14 || move.source >= 16 && move.source < 32 || move.source == 37 {
+ if move.source == 1 || move.source == 7 || move.source >= 9 && move.source <= 14 || move.source >= 16 && move.source < 32 || move.source >= 33 && move.source <= 45 {
server.queueCombat_locked(updates, character, character, equipmentActionPacket(character.id, item, 7))
}
if move.source == 6 {
@@ -289,7 +287,7 @@ func (server *server) advanceEquipment(now time.Time) {
updates[client] = append(updates[client], n3Packet(0x36510078, item.Type, move.itemID, nil))
}
updates[client] = append(updates[client], itemMovePacket(client.id, move.source, move.requestedSlot))
- if move.destination == 1 || move.destination == 7 || move.destination >= 9 && move.destination <= 14 || move.destination >= 16 && move.destination < 32 || move.destination == 37 {
+ if move.destination == 1 || move.destination == 7 || move.destination >= 9 && move.destination <= 14 || move.destination >= 16 && move.destination < 32 || move.destination >= 33 && move.destination <= 45 {
server.queueCombat_locked(updates, character, character, equipmentActionPacket(character.id, character.inventory.Items[index], 6))
}
if move.source == 6 || move.destination == 6 {
@@ -365,7 +363,7 @@ func equipmentActionPacket(owner uint32, item ownedItem, action uint32) []byte {
page := uint32(102)
if item.Slot < 16 {
page = 101
- } else if item.Slot == 37 {
+ } else if item.Slot >= 33 && item.Slot <= 45 {
page = 103
}
var body []byte
@@ -379,7 +377,7 @@ func equipmentActionPacket(owner uint32, item ownedItem, action uint32) []byte {
func equippedItemPackets(character *character) [][]byte {
packets := equippedWeaponPackets(character)
for _, item := range character.inventory.Items {
- if item.Slot == 1 || item.Slot == 7 || item.Slot >= 9 && item.Slot <= 14 || item.Slot >= 16 && item.Slot < 32 || item.Slot == 37 {
+ if item.Slot == 1 || item.Slot == 7 || item.Slot >= 9 && item.Slot <= 14 || item.Slot >= 16 && item.Slot < 32 || item.Slot >= 33 && item.Slot <= 45 {
packets = append(packets, equipmentActionPacket(character.id, item, 6))
}
}
diff --git a/server/implant_catalog_test.go b/server/implant_catalog_test.go
@@ -0,0 +1,548 @@
+package main
+
+import (
+ "ao/server/gamedata"
+ "bytes"
+ "encoding/binary"
+ "fmt"
+ "reflect"
+ "slices"
+ "testing"
+ "time"
+)
+
+func newCatalogImplantWorld(t *testing.T, template uint32) (*server, *combatTestConn) {
+ t.Helper()
+ world, conn := newEquipmentWorld(t)
+ player, client := world.characters[1], world.clients[1]
+ player.stats.NanoAiding.Treatment = 9
+ if err := world.saveUser_locked(player); err != nil {
+ t.Fatal(err)
+ }
+ for _, id := range []uint32{43552, template} {
+ if granted, err := world.grantItem_locked(player, id); err != nil || !granted {
+ t.Fatal(granted, err)
+ }
+ }
+ client.selectedTarget = [2]uint32{50000, 1}
+ if err := world.handleOwnedItemUse(client, backpackUseRequest(1, 65, 1)[20:]); err != nil {
+ t.Fatal(err)
+ }
+ conn.packets = nil
+ return world, conn
+}
+
+func TestImplantCatalogAdmissionMatchesCompleteAuthoredContracts(t *testing.T) {
+ // Counts come from the complete original-payload audit, including unknown sections.
+ accepted := make(map[uint32]int)
+ total := 0
+
+ for id, definition := range gamedata.ItemTemplates {
+ if definition.HeaderWords[0] != 51022 || itemStat(definition, 76) != 3 {
+ continue
+ }
+ total++
+ inventory := playerInventory{LastID: 1, Items: []ownedItem{{ID: 1, Type: 51022, Template: id,
+ Quality: *definition.Quality, Slot: 32 + itemStat(definition, 88), Count: 1}}}
+ if inventory.validate() == nil {
+ accepted[*definition.Quality]++
+ }
+ }
+
+ if total != 44356 || !reflect.DeepEqual(accepted, map[uint32]int{1: 9006, 200: 9003, 201: 8871, 300: 8872}) {
+ t.Fatal("implant admission diverged from the original complete-effect audit", total, accepted)
+ }
+}
+
+func TestCatalogImplantsUseEveryAnatomicalSlotAndPreserveIdentity(t *testing.T) {
+ for _, fixture := range []struct {
+ template, slot, stat uint32
+ bonus int32
+ }{
+ {101103, 33, 108, 2}, {101119, 34, 135, 2}, {101135, 35, 117, 2},
+ {101151, 36, 94, 3}, {101167, 37, 107, 2}, {101183, 38, 93, 3},
+ {101199, 39, 101, 2}, {101215, 40, 90, 3}, {101231, 41, 168, 2},
+ {101247, 42, 97, 3}, {101263, 43, 91, 3}, {101279, 44, 95, 3}, {101295, 45, 153, 2},
+ } {
+ t.Run(fmt.Sprint(fixture.slot), func(t *testing.T) {
+ world, owner := newCatalogImplantWorld(t, fixture.template)
+ player, client := world.characters[1], world.clients[1]
+ observer := &combatTestConn{}
+ world.characters[2] = &character{id: 2, playfield: 950, health: 100}
+ world.clients[2] = &worldClient{id: 2, conn: observer, target: true, ready: true}
+ before := slices.Clone(player.inventory.Items)
+
+ started := time.Now()
+ if err := world.handleInventory(client, inventoryMovePacket(1, 66, fixture.slot)[20:]); err != nil {
+ t.Fatal(err)
+ }
+ if client.equipment == nil || client.equipment.readyAt.Before(started.Add(100*time.Millisecond)) || client.equipment.readyAt.After(time.Now().Add(100*time.Millisecond)) {
+ t.Fatal("catalog implant did not start its inherited equip delay")
+ }
+ world.advanceEquipment(client.equipment.readyAt.Add(-time.Nanosecond))
+ if !reflect.DeepEqual(player.inventory.Items, before) || len(owner.packets) != 0 || len(observer.packets) != 0 {
+ t.Fatal("implant changed before the equip deadline")
+ }
+ world.advanceEquipment(client.equipment.readyAt)
+ restored := newTestInventoryServer(t).characters[1]
+ if restored.inventory.Items[2].Slot != fixture.slot || restored.equipmentBonus(fixture.stat) != fixture.bonus || len(equippedItemPackets(restored)) != 1 {
+ t.Fatal("cold restore lost the implant, its bonus or observer wear", restored.inventory.Items)
+ }
+ if len(owner.packets) != 2 || len(observer.packets) != 1 || !bytes.Equal(owner.packets[1][16:], observer.packets[0][16:]) ||
+ binary.BigEndian.Uint32(owner.packets[1][49:53]) != 103 || binary.BigEndian.Uint32(owner.packets[1][53:57]) != fixture.slot {
+ t.Fatal("owner/observer wear used the wrong implant page or slot")
+ }
+ player.stats.NanoAiding.Treatment = 0
+ if player.equipmentBonus(fixture.stat) != fixture.bonus {
+ t.Fatal("implant bonuses incorrectly became overequipped")
+ }
+ if err := world.handleInventory(client, itemMovePacket(1, fixture.slot, 111)[20:]); err != nil {
+ t.Fatal(err)
+ }
+ if client.equipment == nil {
+ t.Fatal("removal incorrectly rechecked installation requirements")
+ }
+ world.advanceEquipment(client.equipment.readyAt)
+ removed := newTestInventoryServer(t).characters[1]
+
+ if !reflect.DeepEqual(player.inventory.Items, before) || !reflect.DeepEqual(removed.inventory.Items, before) || player.equipmentBonus(fixture.stat) != 0 ||
+ len(owner.packets) != 4 || len(observer.packets) != 2 || binary.BigEndian.Uint32(observer.packets[1][45:49]) != 7 ||
+ binary.BigEndian.Uint32(owner.packets[3][29:33]) != 103 || binary.BigEndian.Uint32(owner.packets[3][33:37]) != fixture.slot {
+ t.Fatal("implant removal lost identity, retained its bonus or used an incorrect source page")
+ }
+ })
+ }
+}
+
+func TestImplantSurgeryRevalidatesOutsideChestSlot(t *testing.T) {
+ for _, scenario := range []string{"no access", "expired at completion", "requirements changed", "failed save", "wrong removal page", "full inventory"} {
+ t.Run(scenario, func(t *testing.T) {
+ world, conn := newCatalogImplantWorld(t, 101295)
+ player, client := world.characters[1], world.clients[1]
+ if scenario == "wrong removal page" || scenario == "full inventory" {
+ world.handleInventory(client, inventoryMovePacket(1, 66, 45)[20:])
+ world.advanceEquipment(client.equipment.readyAt)
+ }
+ if scenario == "full inventory" {
+ for {
+ granted, err := world.grantItem_locked(player, 121567)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if !granted {
+ break
+ }
+ }
+ }
+ if scenario == "no access" {
+ player.implantChangesUntil = time.Now().Add(-time.Second)
+ }
+ before := slices.Clone(player.inventory.Items)
+ stored, _ := readTestItemStore(world)
+ conn.packets = nil
+
+ request := inventoryMovePacket(1, 66, 45)
+ if scenario == "wrong removal page" || scenario == "full inventory" {
+ request = itemMovePacket(1, 45, 111)
+ if scenario == "wrong removal page" {
+ binary.BigEndian.PutUint32(request[36:40], 102)
+ }
+ }
+ err := world.handleInventory(client, request[20:])
+ if scenario == "expired at completion" || scenario == "requirements changed" || scenario == "failed save" {
+ if client.equipment == nil {
+ t.Fatal("initial valid implant move did not start")
+ }
+ if scenario == "expired at completion" {
+ player.implantChangesUntil = client.equipment.readyAt
+ } else if scenario == "requirements changed" {
+ player.stats.NanoAiding.Treatment = 0
+ } else {
+ failDatabaseWrites(t, world)
+ }
+ world.advanceEquipment(client.equipment.readyAt)
+ }
+ after, _ := readTestItemStore(world)
+
+ if err != nil || client.equipment != nil || !reflect.DeepEqual(player.inventory.Items, before) || !bytes.Equal(stored, after) {
+ t.Fatal("rejected surgery outside the chest slot changed item identity or placement", err)
+ }
+ for _, packet := range conn.packets {
+ if binary.BigEndian.Uint32(packet[16:20]) == 0x35505644 {
+ t.Fatal("rejected surgery published wear effects")
+ }
+ }
+ })
+ }
+}
+
+func TestCatalogImplantsRejectIncompleteEffectsAsWholeItems(t *testing.T) {
+ for _, template := range []uint32{
+ 130263, 204649, 181297, 181846, 181321, 182584, 179455, 182822, 180292, 183214,
+ 172245, 173249, 178548, 166365, 176593, 177719, 204613, 204614, 204647, 204650, 204651, 206246,
+ } {
+ t.Run(fmt.Sprint(template), func(t *testing.T) {
+ world, conn := newCatalogImplantWorld(t, template)
+ player, client := world.characters[1], world.clients[1]
+ player.level = 200
+ for _, field := range player.stats.trainingStats() {
+ *field.value = 5000
+ }
+ before := slices.Clone(player.inventory.Items)
+ stored, _ := readTestItemStore(world)
+
+ err := world.handleInventory(client, inventoryMovePacket(1, 66, 32+itemStat(gamedata.ItemTemplates[template], 88))[20:])
+ after, _ := readTestItemStore(world)
+
+ if err != nil || client.equipment != nil || !reflect.DeepEqual(player.inventory.Items, before) || !bytes.Equal(stored, after) || len(conn.packets) != 2 {
+ t.Fatal("incomplete implant was admitted or changed ownership", err)
+ }
+ })
+ }
+}
+
+func TestJobeImplantsEnforceAuthoredQualityAndStrictRequirements(t *testing.T) {
+ for _, fixture := range []struct {
+ template, quality uint32
+ level, treatment, stamina uint16
+ bonus int32
+ }{
+ {191026, 1, 50, 9, 16, 5}, {191027, 200, 100, 1003, 414, -5},
+ {191028, 201, 150, 999, 426, -5}, {191029, 300, 190, 2049, 1095, -9},
+ } {
+ for _, scenario := range []string{"accepted", "Treatment equality", "stamina equality", "title equality", "unauthored quality"} {
+ t.Run(fmt.Sprintf("%d/%s", fixture.template, scenario), func(t *testing.T) {
+ world, _ := newCatalogImplantWorld(t, fixture.template)
+ player, client := world.characters[1], world.clients[1]
+ player.level, player.stats.NanoAiding.Treatment, player.stats.Abilities.Stamina = fixture.level, fixture.treatment, fixture.stamina
+ switch scenario {
+ case "Treatment equality":
+ player.stats.NanoAiding.Treatment--
+ case "stamina equality":
+ player.stats.Abilities.Stamina--
+ case "title equality":
+ player.level--
+ case "unauthored quality":
+ player.inventory.Items[2].Quality++
+ }
+ if err := world.saveUser_locked(player); err != nil {
+ t.Fatal(err)
+ }
+ if err := world.saveInventory_locked(player, player.inventory); err != nil {
+ t.Fatal(err)
+ }
+
+ err := world.handleInventory(client, inventoryMovePacket(1, 66, 43)[20:])
+ if client.equipment != nil {
+ world.advanceEquipment(client.equipment.readyAt)
+ }
+ restored := newTestInventoryServer(t).characters[1]
+
+ if err != nil || (player.inventory.Items[2].Slot == 43) != (scenario == "accepted") || !reflect.DeepEqual(player.inventory.Items, restored.inventory.Items) {
+ t.Fatal("Jobe implant ignored its strict endpoint requirements or lost its instance", err)
+ }
+ if scenario == "accepted" && (restored.equipmentBonus(382) != fixture.bonus || restored.inventory.Items[2].Quality != fixture.quality) {
+ t.Fatal("Jobe modifier changed sign or authored quality")
+ }
+ })
+ }
+ }
+}
+
+func TestRealJobeModifierChangesNewLocksButNotExistingDeadlines(t *testing.T) {
+ for _, fixture := range []struct {
+ template uint32
+ level, treatment uint16
+ stamina uint16
+ seconds int
+ }{{191026, 50, 9, 16, 41}, {191027, 100, 1003, 414, 38}, {191029, 190, 2049, 1095, 36}} {
+ t.Run(fmt.Sprint(fixture.template), func(t *testing.T) {
+ world, conn := newCatalogImplantWorld(t, fixture.template)
+ player, client := world.characters[1], world.clients[1]
+ player.level, player.stats.NanoAiding.Treatment, player.stats.Abilities.Stamina = fixture.level, fixture.treatment, fixture.stamina
+ player.stats.NanoAiding.FirstAid = 6
+ if err := world.saveUser_locked(player); err != nil {
+ t.Fatal(err)
+ }
+ world.handleInventory(client, inventoryMovePacket(1, 66, 43)[20:])
+ world.advanceEquipment(client.equipment.readyAt)
+ if granted, err := world.grantItem_locked(player, 85366); err != nil || !granted {
+ t.Fatal(granted, err)
+ }
+ clinicDeadline := player.skillLocks[124]
+ conn.packets = nil
+ started := time.Now()
+
+ err := world.handleOwnedItemUse(client, backpackUseRequest(1, 66, 2)[20:])
+ deadline := player.skillLocks[123]
+ world.handleInventory(client, itemMovePacket(1, 43, 111)[20:])
+ if client.equipment == nil {
+ t.Fatal("Jobe modifier could not be removed during an independent skill lock")
+ }
+ world.advanceEquipment(client.equipment.readyAt)
+ restored := newTestInventoryServer(t).characters[1]
+
+ if err != nil || deadline.Before(started.Add(time.Duration(fixture.seconds)*time.Second)) || deadline.After(time.Now().Add(time.Duration(fixture.seconds)*time.Second)) ||
+ !player.skillLocks[123].Equal(deadline) || !restored.skillLocks[123].Equal(deadline) || !restored.skillLocks[124].Equal(clinicDeadline) ||
+ restored.equipmentBonus(382) != 0 || restored.inventory.Items[2].ID != 3 || restored.inventory.Items[2].Slot != 67 || restored.inventory.Items[3].ID != 4 || restored.inventory.Items[3].Count != 24 {
+ t.Fatalf("real Jobe use/removal: duration=%v expected=%ds live=%v cold=%v clinic=%v items=%+v err=%v", deadline.Sub(started), fixture.seconds, player.skillLocks, restored.skillLocks, clinicDeadline, restored.inventory.Items, err)
+ }
+ starts := 0
+ for _, packet := range conn.packets {
+ if binary.BigEndian.Uint32(packet[16:20]) == 0x5e477770 && binary.BigEndian.Uint32(packet[29:33]) == 170 {
+ starts++
+ if binary.BigEndian.Uint32(packet[41:45]) != 123 || binary.BigEndian.Uint32(packet[45:49]) != 40 {
+ t.Fatal("new lock sent scaled seconds to the native client")
+ }
+ }
+ }
+ if starts != 1 {
+ t.Fatal("new use did not publish exactly one raw First Aid lock")
+ }
+ })
+ }
+}
+
+func TestMultiSlotImplantsUseTheirFullMasksAndBreedRequirements(t *testing.T) {
+ for _, fixture := range []struct{ template, slot uint32 }{{164831, 36}, {164831, 38}, {164833, 39}, {164833, 41}, {204980, 39}, {204980, 41}} {
+ for _, breed := range []uint16{1, 4} {
+ t.Run(fmt.Sprintf("%d/%d/breed%d", fixture.template, fixture.slot, breed), func(t *testing.T) {
+ world, _ := newCatalogImplantWorld(t, fixture.template)
+ player, client := world.characters[1], world.clients[1]
+ appearance := unpackAppearance(player.appearance)
+ appearance.Breed = breed
+ player.appearance = appearance.packed()
+ if err := world.saveUser_locked(player); err != nil {
+ t.Fatal(err)
+ }
+
+ err := world.handleInventory(client, inventoryMovePacket(1, 66, fixture.slot)[20:])
+ if client.equipment != nil {
+ world.advanceEquipment(client.equipment.readyAt)
+ }
+ restored := newTestInventoryServer(t).characters[1]
+
+ if err != nil || (player.inventory.Items[2].Slot == fixture.slot) != (breed == 4 || fixture.template == 204980) ||
+ !reflect.DeepEqual(player.inventory.Items, restored.inventory.Items) {
+ t.Fatal("implant used only its default slot or ignored breed equality", err)
+ }
+ if fixture.template == 204980 && (restored.maximumNCU() != 9 || restored.inventory.equipmentBonus(221) != 1) {
+ t.Fatal("multi-slot NCU implant lost one of its complete bonuses")
+ }
+ })
+ }
+ }
+}
+
+func TestImplantRemovalUsesItsOwnActionCriteria(t *testing.T) {
+ for _, scenario := range []string{"allowed", "blocked initially", "changed during removal"} {
+ t.Run(scenario, func(t *testing.T) {
+ world, _ := newCatalogImplantWorld(t, 101295)
+ player, client := world.characters[1], world.clients[1]
+ original := gamedata.ItemTemplates[101295]
+ definition := *original
+ definition.Sections = slices.Clone(original.Sections)
+ for index, section := range definition.Sections {
+ if section.Actions != nil {
+ actions := append(slices.Clone(*section.Actions), gamedata.ItemAction{Type: 7,
+ Requirements: []gamedata.ItemRequirement{{Stat: 33, Value: 2, Operator: 0}}})
+ definition.Sections[index].Actions = &actions
+ }
+ }
+ gamedata.ItemTemplates[101295] = &definition
+ t.Cleanup(func() { gamedata.ItemTemplates[101295] = original })
+ appearance := unpackAppearance(player.appearance)
+ appearance.Side = 2
+ player.appearance = appearance.packed()
+ world.handleInventory(client, inventoryMovePacket(1, 66, 45)[20:])
+ world.advanceEquipment(client.equipment.readyAt)
+ player.stats.NanoAiding.Treatment = 0
+ if scenario == "blocked initially" {
+ appearance.Side = 0
+ player.appearance = appearance.packed()
+ }
+
+ err := world.handleInventory(client, itemMovePacket(1, 45, 111)[20:])
+ if scenario == "changed during removal" {
+ if client.equipment == nil {
+ t.Fatal("initial action7 requirements were not accepted")
+ }
+ appearance.Side = 0
+ player.appearance = appearance.packed()
+ }
+ if client.equipment != nil {
+ world.advanceEquipment(client.equipment.readyAt)
+ }
+ restored := newTestInventoryServer(t).characters[1]
+
+ if err != nil || (player.inventory.Items[2].Slot == 66) != (scenario == "allowed") ||
+ !reflect.DeepEqual(player.inventory.Items, restored.inventory.Items) {
+ t.Fatal("removal ignored action7 or incorrectly required action6 again", err)
+ }
+ })
+ }
+}
+
+func TestImplantResourcesSkillsAndAbilitiesApplyOnceAndClampOnRemoval(t *testing.T) {
+ for _, fixture := range []struct {
+ template, slot, stat uint32
+ bonus int32
+ }{
+ {108466, 37, 1, 7}, {105187, 34, 221, 7}, {107483, 36, 16, 5},
+ {101253, 42, 100, 6}, {166669, 39, 181, 3},
+ } {
+ t.Run(fmt.Sprint(fixture.template), func(t *testing.T) {
+ world, _ := newCatalogImplantWorld(t, fixture.template)
+ player, client := world.characters[1], world.clients[1]
+ if fixture.stat == 181 {
+ player.level, player.stats.Abilities.Agility = 50, 16
+ }
+ if err := world.saveUser_locked(player); err != nil {
+ t.Fatal(err)
+ }
+ health, nano, ncu := player.maximumHealth(), player.maximumNano(), player.maximumNCU()
+ ability, skill := player.effectiveAbility(16), player.attackRating()
+
+ world.handleInventory(client, inventoryMovePacket(1, 66, fixture.slot)[20:])
+ if client.equipment == nil {
+ t.Fatal("resource/ability implant was rejected")
+ }
+ world.advanceEquipment(client.equipment.readyAt)
+ restored := newTestInventoryServer(t).characters[1]
+ if restored.equipmentBonus(fixture.stat) != fixture.bonus || player.equipmentBonus(fixture.stat) != fixture.bonus {
+ t.Fatal("implant modifier was missing or duplicated after cold recovery")
+ }
+ switch fixture.stat {
+ case 1:
+ if restored.maximumHealth() != health+7 {
+ t.Fatal("maximum health did not include the implant once")
+ }
+ case 221:
+ if restored.maximumNano() != nano+7 {
+ t.Fatal("maximum nano did not include the implant once")
+ }
+ case 16:
+ if restored.effectiveAbility(16) != ability+5 {
+ t.Fatal("strength did not include the implant once")
+ }
+ case 100:
+ if restored.attackRating() != skill+6 {
+ t.Fatal("Martial Arts did not affect the attack rating once")
+ }
+ case 181:
+ if restored.maximumNCU() != ncu+3 {
+ t.Fatal("NCU did not include the implant once")
+ }
+ }
+ player.health, player.nano = player.maximumHealth(), player.maximumNano()
+ if err := world.savePosition_locked(player); err != nil {
+ t.Fatal(err)
+ }
+ world.handleInventory(client, itemMovePacket(1, fixture.slot, 111)[20:])
+ world.advanceEquipment(client.equipment.readyAt)
+ removed := newTestInventoryServer(t).characters[1]
+
+ if removed.maximumHealth() != health || removed.maximumNano() != nano || removed.maximumNCU() != ncu ||
+ removed.effectiveAbility(16) != ability || removed.attackRating() != skill || removed.equipmentBonus(fixture.stat) != 0 ||
+ removed.health != health || removed.nano != nano || player.health != health || player.nano != nano || removed.inventory.Items[2].ID != 3 || removed.inventory.Items[2].Slot != 66 {
+ t.Fatal("implant removal retained effects, lost its instance or failed atomic resource clamps")
+ }
+ })
+ }
+}
+
+func TestImplantMalformedAndTimedContractsPreserveOwnedItems(t *testing.T) {
+ for _, scenario := range []string{"wrong type", "cannot wear", "empty mask", "unknown mask bit", "unknown function", "wrong target", "repeated modifier", "modifier interval", "missing argument", "undecoded data"} {
+ t.Run(scenario, func(t *testing.T) {
+ world, conn := newCatalogImplantWorld(t, 101295)
+ player, client := world.characters[1], world.clients[1]
+ original := gamedata.ItemTemplates[101295]
+ definition := *original
+ definition.Stats, definition.Sections = slices.Clone(original.Stats), slices.Clone(original.Sections)
+ for index, stat := range definition.Stats {
+ if scenario == "cannot wear" && stat[0] == 30 {
+ definition.Stats[index][1] &^= 4
+ }
+ if stat[0] == 298 {
+ if scenario == "empty mask" {
+ definition.Stats[index][1] = 0
+ } else if scenario == "unknown mask bit" {
+ definition.Stats[index][1] |= 1
+ }
+ }
+ }
+ for index, section := range definition.Sections {
+ if section.Functions == nil {
+ continue
+ }
+ functions := slices.Clone(*section.Functions)
+ switch scenario {
+ case "unknown function":
+ functions[0].ID = 53051
+ case "wrong target":
+ functions[0].Target = 3
+ case "repeated modifier":
+ functions[0].TickCount = 2
+ case "modifier interval":
+ functions[0].TickInterval = 1
+ case "missing argument":
+ functions[0].Arguments = nil
+ }
+ definition.Sections[index].Functions = &functions
+ }
+ if scenario == "undecoded data" {
+ definition.Undecoded = &gamedata.UndecodedItemData{Reason: "unknown effect data"}
+ } else if scenario == "wrong type" {
+ player.inventory.Items[2].Type = 51018
+ }
+ gamedata.ItemTemplates[101295] = &definition
+ t.Cleanup(func() { gamedata.ItemTemplates[101295] = original })
+ if err := world.saveInventory_locked(player, player.inventory); err != nil {
+ t.Fatal(err)
+ }
+ before := slices.Clone(player.inventory.Items)
+ stored, _ := readTestItemStore(world)
+
+ err := world.handleInventory(client, inventoryMovePacket(1, 66, 45)[20:])
+ after, _ := readTestItemStore(world)
+
+ if err != nil || client.equipment != nil || !reflect.DeepEqual(player.inventory.Items, before) || !bytes.Equal(stored, after) || len(conn.packets) != 2 {
+ t.Fatal("malformed/timed implant produced partial effects or changed ownership", err)
+ }
+ })
+ }
+}
+
+func TestImplantsWithoutWearCriteriaKeepTheirAuthoredDelays(t *testing.T) {
+ for _, fixture := range []struct {
+ template uint32
+ delay time.Duration
+ runSpeed int32
+ }{{25806, 500 * time.Millisecond, 3}, {25807, 500 * time.Millisecond, 100}, {101101, 100 * time.Millisecond, 0}} {
+ t.Run(fmt.Sprint(fixture.template), func(t *testing.T) {
+ world, _ := newCatalogImplantWorld(t, fixture.template)
+ player, client := world.characters[1], world.clients[1]
+ player.stats.NanoAiding.Treatment = 0
+ player.stats.Abilities = characterAbilitiesStats{1, 1, 1, 1, 1, 1}
+ if err := world.saveUser_locked(player); err != nil {
+ t.Fatal(err)
+ }
+ slot := uint32(45)
+ if fixture.template == 101101 {
+ slot = 33
+ }
+
+ started := time.Now()
+ err := world.handleInventory(client, inventoryMovePacket(1, 66, slot)[20:])
+ if client.equipment == nil || client.equipment.readyAt.Before(started.Add(fixture.delay)) || client.equipment.readyAt.After(time.Now().Add(fixture.delay)) {
+ t.Fatal("missing action6 invented wear requirements or ignored EquipDelay211")
+ }
+ world.advanceEquipment(client.equipment.readyAt)
+ restored := newTestInventoryServer(t).characters[1]
+
+ if err != nil || restored.inventory.Items[2].ID != 3 || restored.inventory.Items[2].Slot != slot || restored.equipmentBonus(156) != fixture.runSpeed {
+ t.Fatal("blank/Plastic Muscles implant lost identity, slot or complete effects", err)
+ }
+ })
+ }
+}
diff --git a/server/implants.go b/server/implants.go
@@ -1,6 +1,7 @@
package main
import (
+ "ao/server/gamedata"
"encoding/binary"
"fmt"
"time"
@@ -113,3 +114,41 @@ func (server *server) advanceItemEffects(now time.Time) {
server.mutex.Unlock()
server.sendCombatUpdates(updates)
}
+
+func (item ownedItem) isImplant() bool {
+ definition := gamedata.ItemTemplates[item.Template]
+ if item.Type != 51022 || definition == nil || definition.HeaderWords[0] != item.Type ||
+ definition.Undecoded != nil || itemStat(definition, 76) != 3 || itemStat(definition, 30)&4 == 0 ||
+ item.Quality != *definition.Quality || itemStat(definition, 298) == 0 || itemStat(definition, 298)&^uint32(0x3ffe) != 0 {
+ return false
+ }
+
+ // Admit complete one-shot stat modifiers and ordinary authored action criteria.
+ for _, section := range definition.Sections {
+ if section.Type == 22 && section.Subtype == 36 {
+ continue
+ }
+ if section.Type != 2 || section.Subtype != 14 {
+ return false
+ }
+ for _, function := range *section.Functions {
+ if function.ID != 53045 || function.Target != 2 || len(function.Requirements) != 0 ||
+ function.TickCount != 1 || function.TickInterval != 0 || len(function.Arguments) != 2 ||
+ function.Arguments[0].Integer == nil || function.Arguments[1].Integer == nil {
+ return false
+ }
+
+ // These stats have server consumers; accumulating other IDs is insufficient.
+ stat := uint32(*function.Arguments[0].Integer)
+ if stat >= 16 && stat <= 21 || stat >= 90 && stat <= 97 || stat >= 100 && stat <= 168 {
+ continue
+ }
+ switch stat {
+ case 1, 181, 221, 276, 278, 279, 280, 281, 282, 311, 316, 317, 319, 380, 382:
+ default:
+ return false
+ }
+ }
+ }
+ return true
+}
diff --git a/server/inventory.go b/server/inventory.go
@@ -239,7 +239,7 @@ func (server *server) handleInventory(client *worldClient, body []byte) error {
}
if index < 0 || (sourceSlot >= 64 && sourceType != 104) ||
((sourceSlot == 1 || sourceSlot == 6 || sourceSlot == 7 || sourceSlot >= 9 && sourceSlot <= 14) && sourceType != 101) ||
- (sourceSlot == 37 && sourceType != 103) ||
+ (sourceSlot >= 33 && sourceSlot <= 45 && sourceType != 103) ||
(sourceSlot >= 16 && sourceSlot < 32 && sourceType != 102) {
return nil
}