aorecomp

Anarchy Online classic in the browser

git clone https://aorecomp.ubeagle.com/code/aorecomp.git


commit 19ea11f1c5a2d732add3920ebfaa2c3e5dd9d9e3
parent 2f779f4aa763f77025675289b7e7c3dfeee83e28
Author: anon <anon@example.com>
Date:   Sun, 25 Oct 2026 04:10:39 +0000

Support complete self-only and critical nanos

Diffstat:
MTODO.md | 35+++++++++++++++++++++++++++++------
Mdocs/critical-hits.md | 18++++++++++++++----
Mdocs/nano-learning.md | 6+++---
Mdocs/nano-skill-buffs.md | 121+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------
Mserver/combat.go | 2+-
Aserver/critical_nano_test.go | 349+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mserver/nano_buffs.go | 43+++++++++++++++++++++++++++++++++++++------
Mserver/nano_casting.go | 4++++
Aserver/self_nano_test.go | 315+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mserver/stat_buff_catalog_test.go | 10+++++++---
Aserver/testdata/self-and-critical-nanos.json | 39+++++++++++++++++++++++++++++++++++++++
11 files changed, 910 insertions(+), 32 deletions(-)

diff --git a/TODO.md b/TODO.md @@ -190,10 +190,11 @@ capacity checks are recorded in [belts and NCU](docs/belts-ncu.md). stat 379; Sniper's Friend modifies weapon range stat 380 instead. The unchanged original activation/queue/impact path now has Linux and WASM contract coverage. Ordinary attacks, Fast Attack and Fling now share a - tested provisional 3% base plus worn stat379 chance and max-plus-bonus damage. + tested provisional 3% base plus worn/nano stat379 chance and max-plus-bonus + damage. Verify the original baseline/caps, AR/evade/AggDef terms, critical AC/OE - arithmetic and nano function53012 before marking this canonical milestone - complete. See [critical-hit rules and limits](docs/critical-hits.md). + arithmetic before marking this canonical milestone complete. See + [critical-hit rules and limits](docs/critical-hits.md). - [x] Apply damage-type equipment modifiers to normal hits in the recovered order. Check: Robust Backpack's projectile, energy, radiation and fire bonuses affect the matching attacks, leave other types unchanged, and interact correctly with @@ -550,6 +551,13 @@ introduction and starting-item gameplay remain open below. ## Shops +- [ ] Populate shop rooms with their missing vending machines. Recover the + original room placements and machine types, then make the machines visible, + targetable and usable in the WASM client. Check representative shop interiors + after entry, zoning and restart; opening a machine must use its matching shop + contract rather than inventing stock from its name. If the game data does not + establish which items each shop sells, research online for shop inventories, + categories and QL ranges, and verify that the evidence applies to 14.9.1. - [ ] Support shop vending machines. Check: using a shipped terminal opens its native shop window with the correct stock and prices; purchases preserve credits and item identity atomically, and insufficient credits or inventory @@ -624,9 +632,16 @@ introduction and starting-item gameplay remain open below. Mastery29312, plus Fixer startup Minor Suppressor43370's exact flag variant. Retain both skill/profession gates, all effects and ordinary lifecycle; reject unverified metadata neighbors. See [skill nanos](docs/nano-skill-buffs.md). -- [ ] Research remaining skill-program contracts: Take The Shot32065's - critical-hit function, Trader transfers/wrangles and team targeting. Verify complete - effects, requirements, rejection, persistence and lifecycle before admission. +- [x] Support complete self-only and critical skill programs. The native selector + rule and shared Skill53012 modifier path admit 37 additional original programs + and crystals, including Take the Shot's Aimed Shot +130/CriticalIncrease +4, + the four self-only MA critical buffs, the three targeted Marks and 29 complete + self-only skill buffs. Cover upload/cast thresholds, complete contributions, + target redirection, combat consumers, cancellation, expiry, death, database + failures and cold recovery. See [skill nanos](docs/nano-skill-buffs.md). +- [ ] Research remaining skill-program contracts: Trader transfers/wrangles + and team targeting. Verify complete effects, requirements, rejection, + persistence and lifecycle before admission. Establish acquisition for Shijima's Cloak31405; the decoded original catalog has no ordinary LearnNano uploader for it. - [ ] Research Blood Circle27803 and special Iron Circle42052 delivery. @@ -924,6 +939,14 @@ and unresolved indoor lifecycle are explicit in [flight](docs/vehicles.md#yalmah its original InfoPacket reply; C adapters fix reached `_strdate` and `strcspn` crashes. Description verification and reference persistence follow. See [player information](docs/character-info.md). +- [ ] Fix T-key target inspection hanging indefinitely on NPCs. Reproduce the + native request/reply and loading-window path, and verify inspection of other + players too. The current `handleCharacterInfo` explicitly rejects NPCs; + establish their complete reply contract. Check: targeting an NPC or player + and pressing T finishes loading + the correct actor's information/stats window. Cover rapid target changes, + disappearing targets, invalid identities, reconnect and restart, without + showing stale information or disrupting combat health delivery. - [x] Correct native reference description stats. Check: a level-150 Engineer reference shows the actual level/profession/title, rather than level 0 and no profession. The reference callback now scopes normal-stat mode around diff --git a/docs/critical-hits.md b/docs/critical-hits.md @@ -99,7 +99,8 @@ source dates, provenance and search limits are retained in ## Current server reconstruction One percentage roll selects a critical when it is below -`clamp(3 + worn CriticalIncrease379, 0, 100)`. The 3% base follows the period +`clamp(3 + worn CriticalIncrease379 + nano CriticalIncrease379, 0, 100)`. +The 3% base follows the period Sybex attribution above; treating it as an additive term, clamping, integer percentage rolls and applying it equally to players and NPCs are provisional. Attack rating versus evades, AggDef, level differences, critical resistance, @@ -133,9 +134,12 @@ Worn stat379 uses the existing signed equipment contribution and armor OE calculation. The QL1 Agent Kevlar Wool Balaclava Helmet160568 adds one point; unequipping it removes that contribution, and both states survive reopening SQLite with the same item instance. Unsupported gear is still unsupported. -Critical nanos, including Subconscious Guidance's distinct function53012 and -special metadata, remain disabled until their complete contracts are supported; -this change does not admit only their visible critical modifier. +Eight original critical programs now contribute stat379 through the shared +timed-buff path. Take the Shot retains its accompanying Aimed Shot +130; +all four self-only MA programs redirect the supplied target to the caster. +The complete contracts and native Skill53012 evidence are recorded in +[skill nanos](nano-skill-buffs.md). This establishes the authored additive +modifier, not the unresolved historical probability equation. Ordinary AttackInfo carries result5 for a critical, including killing hits. The special-result body has no critical flag: Fast Attack and Fling publish the @@ -157,6 +161,12 @@ all nine protection types and invalid-type fallback for critical damage. The process-crash special tests force critical living and killing outcomes on both sides of SQLite commit, then reopen and retry through a new session. +`server/critical_nano_test.go` covers the two percentage boundaries for all +eight original critical programs across ordinary attacks, Fast Attack and +Fling, plus addition to the worn helmet contribution. Complete upload, +targeting, removal and persistence tests are described in +[skill nanos](nano-skill-buffs.md). + These checks validate the documented reconstruction, not the unresolved original probability formula or canonical creature balance. diff --git a/docs/nano-learning.md b/docs/nano-learning.md @@ -26,11 +26,11 @@ basic ability Boost crystals and QL 4 Augment Strength now share this upload path. Their exact crystal/program IDs and qualities are tabulated there; each uses its authored LearnNano function and requirements. -Complete-contract admission covers 241 ordinary ability, health, skill and -regeneration crystals for 242 programs. Shijima's Cloak 31405 has no original +Complete-contract admission covers 278 ability, health, skill, critical and +regeneration crystals for 279 programs. Shijima's Cloak 31405 has no original ordinary uploader in the decoded catalog; no replacement crystal is invented. Both upload and casting use the shared postfix requirement evaluator, including -the authored BM/MM/PM/MC thresholds and real or visual profession predicates. +the authored nano-skill/level thresholds and real or visual profession predicates. The full program, crystal and quality tables are in [temporary nanos](nano-buffs.md#complete-contract-admission) and [skill nanos](nano-skill-buffs.md). diff --git a/docs/nano-skill-buffs.md b/docs/nano-skill-buffs.md @@ -1,10 +1,11 @@ # Ordinary skill buffs in 14.9.1 -The shared timed-buff path admits 213 additional original positive skill +The shared timed-buff path admits original positive skill and critical programs, covering 60 of the 69 trained skills. It retains every effect in each program, including mixed contracts such as Offensive Steamroller 29240: Melee, Ranged, Physical and Nano Initiative +133, and Fling Shot +30. This -brings ordinary supported buffs to 242 programs and 241 crystal uploaders. +brings supported buffs to 279 programs and 278 crystal uploaders, including +the self-only and Skill contracts described below. The exact new program, crystal, authored quality, profession, modifiers, NCU, duration and native cost expectations are in @@ -16,11 +17,12 @@ learned entry; the server does not invent an acquisition path. ## Admission and defaults -The ordinary contract remains one unconditional, one-shot Modify 53045 effect -per function, with complete known metadata and authored requirements. All -functions must qualify. New positive modifiers use skill IDs 100..168 through -the existing signed effective-skill calculator. Negative skills, critical-hit -functions, damage functions, conditional effects and unverified program flags +The ordinary contract requires unconditional, one-shot Modify53045 or +Skill53012 effects, with complete known metadata and authored requirements. +All functions must qualify. Positive skill modifiers use IDs100..168 through +the existing signed effective-skill calculator; CriticalIncrease379 uses the +shared weapon critical selector. Negative skills, damage functions, +conditional effects and unverified program flags remain outside this class. In particular, mixed unsupported programs do not grant their otherwise supported skill subset. @@ -165,8 +167,8 @@ symbolic meaning to bit 2 or establish arbitrary Can/flag combinations. All three programs, their three ordinary uploaders and two bulk uploaders were freshly parsed from the original ResourceDatabase. The full expanded -catalog audit re-verifies 781 original records and admits exactly 242 programs -and 241 crystals. Bulk uploads remain rejected. The matching original KKR +catalog audit re-verifies 781 original records; that milestone admitted 242 +programs and 241 crystals. Bulk uploads remain rejected. The matching original KKR snapshot was reused; the owned session was exported and closed. Source records and native evidence are retained under @@ -202,3 +204,104 @@ The focused metadata and rejection tests passed under the race detector in cleanup removed the two test players and two remaining fixture items. Database integrity and foreign keys passed, and unrelated-row hashes were unchanged. Visitor8 was retained and the sole shared HTTPS preview was restarted. + +## Self-only and critical contracts + +The next complete-contract audit adds 37 programs and 37 single-crystal +uploaders, bringing the catalog to 279 programs and 278 crystals. Exact +program/crystal IDs, authored quality, profession, modifiers, NCU, duration, +cost and every skill/level threshold are retained in +[`self-and-critical-nanos.json`](../server/testdata/self-and-critical-nanos.json). +Fresh parsing and payload checks cover 619 original records; every program and +uploader requirement stream in the delta was inspected. + +| Program | Complete critical contract | Target | +| --- | --- | --- | +| Take the Shot32065 | Aimed Shot151 +130, CriticalIncrease379 +4 | Friendly player | +| Subconscious Guidance95526 | CriticalIncrease +8 | Self | +| Universal Vulnerability Compendium95527 | CriticalIncrease +24 | Self | +| Last Minute Adjustments95528 | CriticalIncrease +19 | Self | +| Vulnerability Seeker95529 | CriticalIncrease +13 | Self | +| Mark of Peril160574 | CriticalIncrease +7 | Friendly player | +| Mark of Danger160575 | CriticalIncrease +4 | Friendly player | +| Mark of Risk160576 | CriticalIncrease +2 | Friendly player | + +The remaining 29 programs contain only positive Modify53045 skill effects +whose consumers already exist: Enfraam's Toolkit, 15 Enforcer weapon buffs and +13 Soldier weapon buffs. Swiss Cheese203127 retains both Shotgun115 +90 and +Fling Shot150 +2. No spell-ID branches, new damage/transfer/proc behavior or +partial-program admission are needed. + +Original `kkr.dll:100b3e70` derives self-only metadata when every action-0 +effect selector is1 or2. `100646a0` then replaces the supplied target identity +with the caster before target admission. The server follows this rule for the +whole supported contract, including requests naming zero, an unknown actor, +a creature or another player. A contract mixing self and selected-target +selectors remains rejected. The exact flag value0x14000 is admitted for the +four original MA programs; flag0x4000 alone does not define self-only behavior. +Existing recipient, range, NCU and action gates still apply after redirection. + +Skill53012 dispatches directly to `100bd600`; Modify53045's wrapper `100bd4d0` +reaches the same handler. Both use stat key0 and signed amount key39, add through +`10074730`, and remove through `10074b00`, leaving trained values unchanged. +The Skill reader/writer `100b9aab`/`100b8039` additionally serialize opaque +key24. All1,387 such effects across297 original programs author zero for this +word; admission requires its complete four-byte zero representation. This +supports the shared additive consumer without guessing nonzero semantics. + +Fresh target evidence is `ev_60adda4e07b7bb48955027a52cef65428893299e73d59c9a639c63f7b158e5bb`. +The common modifier handler evidence is +`ev_27c953512839b1cff0ac854ff041eb3e0813c2df061a8858060432f10da08405`. +Original records, the reproducible catalog audit and exported native evidence +are retained in `local/critical-nano-research/`. The owned native session was +exported and closed. + +Public-operation tests cover every new crystal and program, every authored +threshold/profession, exact complete modifiers, costs, NCU, duration, +cancellation and database reopen. All 33 self-only programs redirect four +invalid or unrelated supplied targets to the caster. Separate tests exercise +all selector1/2 combinations, reject incomplete Skill contracts without granting +Take the Shot's otherwise supported Aimed Shot subset, and retain targeted +recipient validation. Controlled rolls cover all eight critical programs in +ordinary attacks, Fast Attack and Fling. Expiry/death and failed insertion, +COMMIT, cancellation and expiry preserve complete contributions atomically. + +Two headed Chromium clients on the GPU verified original crystal uploads +for Subconscious Guidance, UVC, Mark of Risk, Take the Shot and Swiss Cheese. +High skills, professions, level 200 and the 52-NCU equipment were explicit GM +fixtures; uploads, selection, casts and cancellation used the native UI. + +With the other player selected, Guidance applied +8/10 NCU to its caster; +UVC replaced it with +24/52 NCU. Native admission rejected the weaker Guidance. +Wire captures show that the self-only Guidance, UVC and Swiss Cheese requests +still named the selected player; the server redirected admission and effect +delivery to the caster. Both clients received and displayed the caster's +complete contribution, while the selected player stayed unchanged. + +Take the Shot rejected a full recipient without debit, then applied Aimed Shot ++130 and critical increase +4 together for 47 NCU on self. A valid friendly cast +applied both to the other player. Mark of Risk applied +2/18 NCU to its friendly +recipient. Swiss Cheese applied Shotgun +90 and Fling Shot +2 together for 45 NCU +to its caster while the Agent remained selected. Native cancellation removed +every companion modifier and freed the corresponding NCU in both clients. + +Stopping and reopening the same SQLite world, then connecting fresh clients, +restored UVC and Take the Shot with unchanged learned sets, trained values, +complete contributions and equipment instances. The five original crystal +qualities 30/169/57/152/178 were checked on the wire. No adapter or page errors +occurred. Screenshots, read-only native samples, ordered packet streams, +database snapshots and verification scripts are in `local/critical-nano-smoke/`. +These representative native checks do not claim manual execution of all 37 +programs or establish the original critical probability formula. + +The focused new nano tests passed under the race detector in 201.867 seconds; +final combat consumer tests passed in 19.406 seconds. `go vet` passed for all +tracked Go packages. + +Both owned browser contexts were closed after each run. Cleanup removed the +two test players and four remaining equipment fixtures. Foreign keys and +integrity passed, and hashes confirmed every unrelated row stayed unchanged. +Visitor8 was retained and the sole shared HTTPS preview was restarted. + +The complete tracked Go suite (`go test ./server/... ./tools/data/export_gamedata +-count=1 -timeout=30m`) passed: server 736.072 seconds, game data 7.665 seconds. diff --git a/server/combat.go b/server/combat.go @@ -179,7 +179,7 @@ func (server *server) weaponHit_locked(attacker, target *character) (uint32, boo roll = rand.Uint32N } // The period 3% baseline is provisional; NPC ratings are not established. - chance := min(100, max(0, int64(3)+int64(attacker.equipmentBonus(379)))) + chance := min(100, max(0, int64(3)+int64(attacker.equipmentBonus(379))+int64(attacker.nanoBonus(379)))) critical := int64(roll(100)) < chance return min(attacker.weaponDamage(target, critical, roll), target.health), critical } diff --git a/server/critical_nano_test.go b/server/critical_nano_test.go @@ -0,0 +1,349 @@ +package main + +import ( + "encoding/binary" + "fmt" + "slices" + "testing" + "time" +) + +func TestCriticalNanosChangeOrdinaryFastAttackAndFlingThresholds(t *testing.T) { + for _, fixture := range selfAndCriticalNanoFixtures(t) { + var bonus uint32 + for _, modifier := range fixture.Modifiers { + if modifier[0] == 379 { + bonus = uint32(modifier[1]) + } + } + if bonus == 0 { + continue + } + for _, attack := range []string{"ordinary", "fast", "fling"} { + for _, roll := range []uint32{bonus + 2, bonus + 3} { + t.Run(fmt.Sprintf("%d/%s/%d", fixture.Program, attack, roll), func(t *testing.T) { + world, conn := newSelfNanoWorld(t) + player, target, client := world.characters[1], world.characters[1000000], world.clients[1] + player.level, player.profession = 200, uint16(fixture.Profession) + player.stats.Abilities = characterAbilitiesStats{1, 1, 1, 1, 1, 1} + player.inventory.LearnedNanos = []uint32{fixture.Program} + if err := world.saveUser_locked(player); err != nil { + t.Fatal(err) + } + target.health, target.position = 1000, [3]float32{1, 0, 0} + if attack != "ordinary" { + template := uint32(209283) + if attack == "fling" { + template = 123742 + } + if granted, err := world.grantItem_locked(player, template); err != nil || !granted { + t.Fatal(granted, err) + } + if attack == "fling" { + inventory := player.inventory + inventory.Items = slices.Clone(inventory.Items) + inventory.Items[2].Ammo = 3 + if err := world.saveInventory_locked(player, inventory); err != nil { + t.Fatal(err) + } + } + if err := world.handleInventory(client, inventoryMovePacket(1, 64, 6)[20:]); err != nil { + t.Fatal(err) + } + if client.equipment == nil { + t.Fatal("original weapon was rejected") + } + world.advanceEquipment(client.equipment.readyAt) + } + castTestBuff(t, world, 1, 1, fixture.Program) + world.combatRoll = func(limit uint32) uint32 { + if limit == 100 { + return roll + } + return limit - 1 + } + conn.packets = nil + + var packet []byte + switch attack { + case "ordinary": + if err := world.handleCombat(client, attackPacket(1, target.id)[20:]); err != nil { + t.Fatal(err) + } + world.advanceCombat(player.nextAttack) + packet = conn.packets[1] + case "fast": + if err := world.handleWeaponSpecial(client, fastAttackRequest(1, target.id)[20:]); err != nil { + t.Fatal(err) + } + packet = conn.packets[0] + case "fling": + if err := world.handleWeaponSpecial(client, flingShotRequest(1, target.id)[20:]); err != nil { + t.Fatal(err) + } + packet = conn.packets[0] + } + + critical := roll == bonus+2 + want, result := uint32(16), uint32(4) + if critical { + want, result = 26, 5 + } + if attack == "fast" { + want = 65 + if critical { + want = 81 + } + } else if attack == "fling" { + want = 39 + if critical { + want = 78 + } + } + if target.health != 1000-want || player.nanoBonus(379) != int32(bonus) { + t.Fatal("authored critical modifier did not shift the shared weapon threshold", target.health, player.attackRating()) + } + if attack == "ordinary" { + if binary.BigEndian.Uint32(packet[29:33]) != want || binary.BigEndian.Uint32(packet[53:57]) != result { + t.Fatal("ordinary nano-boosted critical result mismatch", packet) + } + } else if binary.BigEndian.Uint32(packet[29:33]) != 6 || binary.BigEndian.Uint32(packet[33:37]) != want { + t.Fatal("named special changed its critical result layout", packet) + } + if attack == "fling" && player.inventory.Items[2].Ammo != 3 { + t.Fatal("critical buff made Fling deduct pre-15.5.5 ammunition") + } + }) + } + } + } +} + +func TestCriticalNanoExpiryAndDeathRemoveEveryContribution(t *testing.T) { + for _, fixture := range selfAndCriticalNanoFixtures(t) { + critical := false + for _, modifier := range fixture.Modifiers { + critical = critical || modifier[0] == 379 + } + if !critical { + continue + } + for _, operation := range []string{"expiry", "death"} { + t.Run(fmt.Sprintf("%d/%s", fixture.Program, operation), func(t *testing.T) { + world, _ := newSelfNanoWorld(t) + player := world.characters[1] + player.level, player.profession = 200, uint16(fixture.Profession) + player.inventory.LearnedNanos = []uint32{fixture.Program} + castTestBuff(t, world, 1, 1, fixture.Program) + expiry := player.activeNanos[0].expiresAt + + if operation == "expiry" { + world.advanceNanos(expiry.Add(-time.Nanosecond)) + if len(player.activeNanos) != 1 || player.nanoBonus(379) == 0 { + t.Fatal("critical buff expired before its exact deadline") + } + world.advanceNanos(expiry) + } else { + defeatReclaimPlayer(t, world) + } + world.advanceNanos(expiry.Add(time.Hour)) + cold := newTestInventoryServer(t).characters[1] + + if player.nanoBonus(379) != 0 || cold.nanoBonus(379) != 0 || len(player.activeNanos) != 0 || len(cold.activeNanos) != 0 || + player.usedNCU() != 0 || cold.usedNCU() != 0 || player.nanoBonus(151) != 0 || cold.nanoBonus(151) != 0 { + t.Fatal("critical nano lifecycle retained a critical or accompanying skill contribution") + } + if operation == "death" && (player.health != 0 || cold.health != 0) { + t.Fatal("critical nano lifecycle revived a dead player") + } + }) + } + } +} + +func TestTargetedCriticalNanosPreserveRecipientAdmission(t *testing.T) { + for _, fixture := range selfAndCriticalNanoFixtures(t) { + if fixture.SelfOnly { + continue + } + for _, scenario := range []string{"valid", "zero", "unknown", "NPC", "dead", "other zone", "other side", "far", "loading", "full NCU"} { + t.Run(fmt.Sprintf("%d/%s", fixture.Program, scenario), func(t *testing.T) { + world, _ := newSelfNanoWorld(t) + player, client := world.characters[1], world.clients[1] + player.profession = uint16(fixture.Profession) + player.inventory.LearnedNanos = []uint32{fixture.Program} + recipient := *player + recipient.id, recipient.name, recipient.profession = 2, "Recipient", 1 + recipient.inventory = playerInventory{} + world.characters[2], world.nextCharacter = &recipient, 2 + world.clients[2] = &worldClient{id: 2, conn: &combatTestConn{}, ready: true, target: true} + if err := world.saveUser_locked(&recipient); err != nil { + t.Fatal(err) + } + for _, template := range []uint32{173155, 168658} { + if granted, err := world.grantItem_locked(&recipient, template); err != nil || !granted { + t.Fatal(granted, err) + } + } + inventory := recipient.inventory + inventory.Items = slices.Clone(inventory.Items) + inventory.Items[0].Slot, inventory.Items[1].Slot = 35, 22 + if err := world.saveInventory_locked(&recipient, inventory); err != nil { + t.Fatal(err) + } + target := uint32(2) + switch scenario { + case "zero": + target = 0 + case "unknown": + target = 999 + case "NPC": + target = 1000000 + case "dead": + recipient.health = 0 + case "other zone": + recipient.playfield++ + case "other side": + recipient.appearance ^= 1 << 9 + case "far": + recipient.position = [3]float32{100, 0, 0} + case "loading": + world.clients[2].loading = true + case "full NCU": + recipient.inventory.Items = nil + } + + if err := world.handleNanoCast(client, characterActionPacket(1, [5]uint32{19, 50000, target, 53019, fixture.Program})[20:]); err != nil { + t.Fatal(err) + } + if client.nanoCast != nil { + world.advanceNanos(client.nanoCast.readyAt.Add(time.Nanosecond)) + } + + if len(player.activeNanos) != 0 || player.nanoBonus(379) != 0 || player.nanoBonus(151) != 0 { + t.Fatal("targeted critical buff fell back to the caster") + } + if scenario == "valid" { + cold := newTestInventoryServer(t).characters[2] + if len(recipient.activeNanos) != 1 || recipient.activeNanos[0].caster != 1 || recipient.usedNCU() != fixture.NCU || + player.nano != 50000-fixture.NanoCost || recipient.nano != 50000 || len(cold.activeNanos) != 1 { + t.Fatal("critical buff was charged or applied to the wrong actor") + } + for _, modifier := range fixture.Modifiers { + if recipient.nanoBonus(uint32(modifier[0])) != modifier[1] || cold.nanoBonus(uint32(modifier[0])) != modifier[1] { + t.Fatal("targeted buff lost a companion modifier", modifier) + } + } + } else if client.nanoCast != nil || player.nano != 50000 || player.nanoReserved != 0 || len(recipient.activeNanos) != 0 { + t.Fatal("invalid recipient consumed nano or received a critical effect") + } + }) + } + } +} + +func TestCriticalNanoDatabaseFailuresPreserveTheCompleteContract(t *testing.T) { + for _, program := range []uint32{32065, 95526} { + for _, operation := range []string{"insert", "commit", "cancel", "expire"} { + t.Run(fmt.Sprintf("%d/%s", program, operation), func(t *testing.T) { + world, conn := newSelfNanoWorld(t) + player, client := world.characters[1], world.clients[1] + player.profession = 2 + if program == 32065 { + player.profession = 5 + } + player.inventory.LearnedNanos = []uint32{program} + if err := world.handleNanoCast(client, characterActionPacket(1, [5]uint32{19, 50000, 1, 53019, program})[20:]); err != nil { + t.Fatal(err) + } + at := client.nanoCast.readyAt.Add(time.Nanosecond) + statement := "CREATE TRIGGER fail_buff BEFORE INSERT ON active_nanos BEGIN SELECT RAISE(FAIL, 'test add'); END" + if operation == "commit" { + statement = `CREATE TABLE pending_buff (player_id INTEGER REFERENCES players(id) DEFERRABLE INITIALLY DEFERRED); + CREATE TRIGGER fail_buff AFTER INSERT ON active_nanos BEGIN INSERT INTO pending_buff VALUES (999999); END` + } else if operation == "cancel" || operation == "expire" { + world.advanceNanos(at) + at = player.activeNanos[0].expiresAt + statement = "CREATE TRIGGER fail_buff BEFORE DELETE ON active_nanos BEGIN SELECT RAISE(FAIL, 'test remove'); END" + } + if _, err := world.db.Exec(statement); err != nil { + t.Fatal(err) + } + beforeNano, beforeCrit, beforeAimed, beforeNCU := player.nano, player.nanoBonus(379), player.nanoBonus(151), player.usedNCU() + conn.packets = nil + + var err error + if operation == "cancel" { + err = world.handleNanoRemoval(client, characterActionPacket(1, [5]uint32{65, 0, 0, 53019, program})[20:]) + } else { + world.advanceNanos(at) + } + cold := newTestInventoryServer(t).characters[1] + + if operation == "insert" || operation == "commit" { + if player.nano != 50000 || cold.nano != 50000 || player.nanoReserved != 0 || client.nanoCast != nil || + len(player.activeNanos) != 0 || len(cold.activeNanos) != 0 || player.nanoBonus(379) != 0 || player.nanoBonus(151) != 0 || + len(conn.packets) != 2 || binary.BigEndian.Uint32(conn.packets[0][29:33]) != 108 { + t.Fatal("failed critical effect published a modifier or lost its refund") + } + } else { + if operation == "cancel" && err == nil || len(conn.packets) != 0 || player.nano != beforeNano || cold.nano != beforeNano || + player.nanoBonus(379) != beforeCrit || cold.nanoBonus(379) != beforeCrit || player.nanoBonus(151) != beforeAimed || + cold.nanoBonus(151) != beforeAimed || player.usedNCU() != beforeNCU || cold.usedNCU() != beforeNCU { + t.Fatal("failed removal lost part of a critical contract or published success", err) + } + if _, err := world.db.Exec("DROP TRIGGER fail_buff"); err != nil { + t.Fatal(err) + } + world.advanceNanos(at.Add(time.Second)) + if player.nanoBonus(379) != 0 || player.nanoBonus(151) != 0 || len(player.activeNanos) != 0 || len(conn.packets) != 1 { + t.Fatal("critical effect removal did not retry exactly once") + } + } + }) + } + } +} + +func TestCriticalNanoAddsToWornChance(t *testing.T) { + for _, roll := range []uint32{7, 8} { + t.Run(fmt.Sprint(roll), func(t *testing.T) { + world, conn := newSelfNanoWorld(t) + player, target, client := world.characters[1], world.characters[1000000], world.clients[1] + player.profession = 5 + player.inventory.LearnedNanos = []uint32{32065} + if granted, err := world.grantItem_locked(player, 160568); err != nil || !granted { + t.Fatal(granted, err) + } + if err := world.handleInventory(client, inventoryMovePacket(1, 64, 18)[20:]); err != nil { + t.Fatal(err) + } + if client.equipment == nil { + t.Fatal("original Agent helmet was rejected") + } + world.advanceEquipment(client.equipment.readyAt) + castTestBuff(t, world, 1, 1, 32065) + target.position, target.health = [3]float32{1, 0, 0}, 1000 + world.combatRoll = func(limit uint32) uint32 { + if limit == 100 { + return roll + } + return limit - 1 + } + conn.packets = nil + + if err := world.handleCombat(client, attackPacket(1, target.id)[20:]); err != nil { + t.Fatal(err) + } + world.advanceCombat(player.nextAttack) + + want := uint32(5) + if roll == 8 { + want = 4 + } + if player.equipmentBonus(379) != 1 || player.nanoBonus(379) != 4 || binary.BigEndian.Uint32(conn.packets[1][53:57]) != want { + t.Fatal("critical nano replaced or double-counted the worn contribution") + } + }) + } +} diff --git a/server/nano_buffs.go b/server/nano_buffs.go @@ -27,7 +27,7 @@ func statBuffNano(program uint32) bool { if can := itemStat(definition, 30); can != 0 && can != 8 { return false } - if flags := itemStat(definition, 0); flags != 0x80010000 && flags != 0x10000 && flags != 0x10002 { + if flags := itemStat(definition, 0); flags != 0x80010000 && flags != 0x10000 && flags != 0x10002 && flags != 0x14000 { return false } // Ordinary timed buffs have finite duration, NCU, strain, range and casting costs. @@ -38,6 +38,7 @@ func statBuffNano(program uint32) bool { } hasEffect := false + var effectTarget uint32 for _, section := range definition.Sections { switch section.Type { case 4: @@ -77,14 +78,29 @@ func statBuffNano(program uint32) bool { return false } for _, function := range *section.Functions { - if function.ID != 53045 || function.Target != 3 || len(function.Requirements) != 0 || - function.TickCount != 1 || function.TickInterval != 0 || len(function.Arguments) != 2 || - function.Arguments[0].Integer == nil || function.Arguments[1].Integer == nil { + target := function.Target + if target == 1 { + target = 2 + } + if target != 2 && target != 3 || effectTarget != 0 && target != effectTarget || + len(function.Requirements) != 0 || function.TickCount != 1 || function.TickInterval != 0 { + return false + } + effectTarget = target + if function.ID == 53012 { + // Skill has a third serialized word; only authored zero is admitted. + if len(function.Arguments) != 3 || function.Arguments[2].BytesHex == nil || *function.Arguments[2].BytesHex != "00000000" { + return false + } + } else if function.ID != 53045 || len(function.Arguments) != 2 { + return false + } + if function.Arguments[0].Integer == nil || function.Arguments[1].Integer == nil { return false } stat, value := *function.Arguments[0].Integer, *function.Arguments[1].Integer switch stat { - case 1, 16, 17, 18, 19, 20, 21, 343, 364: + case 1, 16, 17, 18, 19, 20, 21, 343, 364, 379: if value <= 0 { return false } @@ -103,6 +119,21 @@ func statBuffNano(program uint32) bool { return hasEffect } +func selfOnlyNano(program uint32) bool { + // kkr.dll 100b3e70 derives self-only metadata from all action-0 selectors. + for _, section := range gamedata.NanoTemplates[program].Sections { + if section.Type != 2 || section.Subtype != 0 { + continue + } + for _, function := range *section.Functions { + if function.Target != 1 && function.Target != 2 { + return false + } + } + } + return true +} + func (effect activeNano) remainingAt(now time.Time) time.Duration { if effect.expiresAt.IsZero() { return effect.remaining @@ -117,7 +148,7 @@ func nanoProgramBonus(program, stat uint32) int32 { continue } for _, function := range *section.Functions { - if function.ID == 53045 && uint32(*function.Arguments[0].Integer) == stat { + if (function.ID == 53045 || function.ID == 53012) && uint32(*function.Arguments[0].Integer) == stat { bonus += *function.Arguments[1].Integer } } diff --git a/server/nano_casting.go b/server/nano_casting.go @@ -152,6 +152,10 @@ func (server *server) handleNanoCast(client *worldClient, body []byte) error { // Validate the learned program, shared action gates and its authored requirements. program := binary.BigEndian.Uint32(body[32:36]) target := server.characters[binary.BigEndian.Uint32(body[24:28])] + if statBuffNano(program) && selfOnlyNano(program) { + // Native admission 100646a0 redirects these selectors to the caster. + target = player + } accepted := binary.BigEndian.Uint32(body[20:24]) == 50000 && binary.BigEndian.Uint32(body[28:32]) == 53019 && slices.Contains(player.inventory.LearnedNanos, program) && player.nanoRequirementsMet(program) && player.nano >= nanoCost(program) && !player.sitting && !player.driving() && client.forward == 0 && !client.strafing && !client.turning && client.equipment == nil && diff --git a/server/self_nano_test.go b/server/self_nano_test.go @@ -0,0 +1,315 @@ +package main + +import ( + "ao/server/gamedata" + _ "embed" + "encoding/binary" + "encoding/json" + "fmt" + "slices" + "testing" + "time" +) + +//go:embed testdata/self-and-critical-nanos.json +var selfAndCriticalNanoData []byte + +type selfAndCriticalNanoFixture struct { + Program, Crystal, Quality, Profession uint32 + Modifiers [][2]int32 + Gates [][2]uint32 + NCU, Duration uint32 + NanoCost uint32 `json:"nano_cost"` + SelfOnly bool `json:"self_only"` +} + +func selfAndCriticalNanoFixtures(t *testing.T) []selfAndCriticalNanoFixture { + t.Helper() + var fixtures []selfAndCriticalNanoFixture + if err := json.Unmarshal(selfAndCriticalNanoData, &fixtures); err != nil { + t.Fatal(err) + } + return fixtures +} + +func newSelfNanoWorld(t *testing.T) (*server, *combatTestConn) { + t.Helper() + world, conn := newSkillNanoWorld(t) + player := world.characters[1] + player.stats.NanoAiding.PsychologicalModification, player.stats.NanoAiding.SensoryImprovement = 1000, 1000 + if err := world.saveUser_locked(player); err != nil { + t.Fatal(err) + } + return world, conn +} + +func TestSelfAndCriticalNanosUploadCastRestoreAndCancelCompleteContracts(t *testing.T) { + for _, fixture := range selfAndCriticalNanoFixtures(t) { + t.Run(fmt.Sprint(fixture.Program), func(t *testing.T) { + world, conn := newSelfNanoWorld(t) + player, client := world.characters[1], world.clients[1] + player.level, player.profession = 200, uint16(fixture.Profession) + if err := world.saveUser_locked(player); err != nil { + t.Fatal(err) + } + if granted, err := world.grantItem_locked(player, fixture.Crystal); err != nil || !granted { + t.Fatal(granted, err) + } + trained := player.baseStats() + before := make(map[uint32]int32) + for _, field := range trained.trainingStats() { + before[field.stat], _ = player.effectiveStat(field.stat) + } + + if err := world.handleOwnedItemUse(client, backpackUseRequest(1, 64, 1)[20:]); err != nil { + t.Fatal(err) + } + if len(conn.packets) != 3 || binary.BigEndian.Uint32(conn.packets[1][37:41]) != fixture.Quality { + t.Fatal("original crystal was rejected or changed quality") + } + completed := castTestBuff(t, world, 1, 1, fixture.Program) + cold := newTestInventoryServer(t).characters[1] + + if player.baseStats() != trained || cold.baseStats() != trained || player.usedNCU() != fixture.NCU || cold.usedNCU() != fixture.NCU || + player.nano != 50000-fixture.NanoCost || cold.nano != player.nano || player.health != 20 || cold.health != 20 || + len(player.activeNanos) != 1 || len(cold.activeNanos) != 1 || len(cold.inventory.Items) != 2 || + player.activeNanos[0].expiresAt.Sub(completed) != time.Duration(fixture.Duration)*10*time.Millisecond || + !slices.Equal(cold.inventory.LearnedNanos, []uint32{fixture.Program}) { + t.Fatal("original program lost its complete lifecycle or changed trained state", player.nano, player.usedNCU()) + } + for stat, base := range before { + want := base + for _, modifier := range fixture.Modifiers { + if uint32(modifier[0]) == stat { + want += modifier[1] + } + } + current, _ := player.effectiveStat(stat) + restored, _ := cold.effectiveStat(stat) + if current != want || restored != want { + t.Fatal("program lost an authored modifier or changed an unrelated skill", stat, current, restored, want) + } + } + var critical int32 + for _, modifier := range fixture.Modifiers { + if modifier[0] == 379 { + critical += modifier[1] + } + } + if player.nanoBonus(379) != critical || cold.nanoBonus(379) != critical { + t.Fatal("critical Skill effect did not survive cold recovery") + } + if err := world.handleNanoRemoval(client, characterActionPacket(1, [5]uint32{65, 0, 0, 53019, fixture.Program})[20:]); err != nil { + t.Fatal(err) + } + cold = newTestInventoryServer(t).characters[1] + if len(player.activeNanos) != 0 || len(cold.activeNanos) != 0 || player.usedNCU() != 0 || cold.usedNCU() != 0 || + player.nanoBonus(379) != 0 || cold.nanoBonus(379) != 0 { + t.Fatal("cancellation retained a critical modifier or NCU") + } + for stat, base := range before { + current, _ := player.effectiveStat(stat) + restored, _ := cold.effectiveStat(stat) + if current != base || restored != base { + t.Fatal("cancellation changed trained state or retained a contribution", stat, current, restored, base) + } + } + }) + } +} + +func TestSelfOnlyNanosRedirectEverySuppliedTargetToTheCaster(t *testing.T) { + for _, fixture := range selfAndCriticalNanoFixtures(t) { + if !fixture.SelfOnly { + continue + } + for _, supplied := range []uint32{0, 999, 1000000, 2} { + t.Run(fmt.Sprintf("%d/%d", fixture.Program, supplied), func(t *testing.T) { + world, _ := newSelfNanoWorld(t) + player := world.characters[1] + player.level, player.profession = 200, uint16(fixture.Profession) + player.inventory.LearnedNanos = []uint32{fixture.Program} + other := &character{id: 2, playfield: 999, health: 100, stats: testCharacterStats()} + world.characters[2] = other + world.clients[2] = &worldClient{id: 2, conn: &combatTestConn{}, target: true, ready: true} + + castTestBuff(t, world, 1, supplied, fixture.Program) + cold := newTestInventoryServer(t).characters[1] + + if len(player.activeNanos) != 1 || len(cold.activeNanos) != 1 || player.usedNCU() != fixture.NCU || + player.nano != 50000-fixture.NanoCost || len(other.activeNanos) != 0 || other.health != 100 || other.usedNCU() != 0 || + len(world.characters[1000000].activeNanos) != 0 { + t.Fatal("self-only cast used the supplied identity as its recipient") + } + }) + } + } +} + +func TestCriticalSkillNanoRejectsIncompleteContractsWithoutPartialAimedShot(t *testing.T) { + for _, scenario := range []string{"missing word", "nonzero word", "short word", "integer word", "missing stat", "missing amount", "unsupported stat", "negative critical", "conditional", "repeated", "interval", "mixed targets", "target selector", "unknown function"} { + t.Run(scenario, func(t *testing.T) { + original := gamedata.NanoTemplates[32065] + definition := *original + definition.Sections = slices.Clone(original.Sections) + for index, section := range definition.Sections { + if section.Type != 2 || section.Subtype != 0 { + continue + } + functions := slices.Clone(*section.Functions) + definition.Sections[index].Functions = &functions + for index := range functions { + if functions[index].ID != 53012 { + continue + } + function := &functions[index] + function.Arguments = slices.Clone(function.Arguments) + switch scenario { + case "missing word": + function.Arguments = function.Arguments[:2] + case "nonzero word": + function.Arguments[2].BytesHex = new("01000000") + case "short word": + function.Arguments[2].BytesHex = new("000000") + case "integer word": + function.Arguments[2] = gamedata.ItemArgument{Integer: new(int32(0))} + case "missing stat": + function.Arguments[0] = gamedata.ItemArgument{} + case "missing amount": + function.Arguments[1] = gamedata.ItemArgument{} + case "unsupported stat": + function.Arguments[0].Integer = new(int32(278)) + case "negative critical": + function.Arguments[1].Integer = new(int32(-4)) + case "conditional": + function.Requirements = []gamedata.ItemRequirement{{Stat: 54, Operator: 2, Value: 1}} + case "repeated": + function.TickCount = 2 + case "interval": + function.TickInterval = 1 + case "mixed targets": + function.Target = 2 + case "target selector": + function.Target = 4 + case "unknown function": + function.ID = 53110 + } + } + } + gamedata.NanoTemplates[32065] = &definition + t.Cleanup(func() { gamedata.NanoTemplates[32065] = original }) + world, conn := newSelfNanoWorld(t) + player, client := world.characters[1], world.clients[1] + player.level, player.profession = 200, 5 + if granted, err := world.grantItem_locked(player, 32106); err != nil || !granted { + t.Fatal(granted, err) + } + before, _ := player.effectiveStat(151) + + if err := world.handleOwnedItemUse(client, backpackUseRequest(1, 64, 1)[20:]); err != nil { + t.Fatal(err) + } + learned := len(player.inventory.LearnedNanos) + // Independently exercise cast admission without relying on the upload rejection. + player.inventory.LearnedNanos = []uint32{32065} + if err := world.handleNanoCast(client, characterActionPacket(1, [5]uint32{19, 50000, 1, 53019, 32065})[20:]); err != nil { + t.Fatal(err) + } + + after, _ := player.effectiveStat(151) + if learned != 0 || client.nanoCast != nil || player.nano != 50000 || player.nanoReserved != 0 || len(player.activeNanos) != 0 || + player.nanoBonus(379) != 0 || after != before || len(player.inventory.Items) != 3 || + len(conn.packets) != 2 || binary.BigEndian.Uint32(conn.packets[0][29:33]) != 2 || binary.BigEndian.Uint32(conn.packets[1][29:33]) != 108 { + t.Fatal("incomplete Skill contract consumed a crystal, charged nano or granted partial Aimed Shot") + } + }) + } +} + +func TestSelfAndCriticalNanosEnforceEveryAuthoredThresholdAndProfession(t *testing.T) { + for _, fixture := range selfAndCriticalNanoFixtures(t) { + gates := append(slices.Clone(fixture.Gates), [2]uint32{60, fixture.Profession}) + for _, gate := range gates { + for _, permitted := range []bool{false, true} { + t.Run(fmt.Sprintf("%d/%d/pass=%t", fixture.Program, gate[0], permitted), func(t *testing.T) { + world, _ := newSelfNanoWorld(t) + player, client := world.characters[1], world.clients[1] + player.level, player.profession = 200, uint16(fixture.Profession) + player.stats.Abilities = characterAbilitiesStats{1, 1, 1, 1, 1, 1} + value := uint16(gate[1]) + if permitted { + value++ + } + switch gate[0] { + case 54: + player.level = value + case 60: + if !permitted { + player.profession = 0 + } + default: + for _, field := range player.stats.trainingStats() { + if field.stat == gate[0] { + *field.value = value + } + } + } + if granted, err := world.grantItem_locked(player, fixture.Crystal); err != nil || !granted { + t.Fatal(granted, err) + } + + if err := world.handleOwnedItemUse(client, backpackUseRequest(1, 64, 1)[20:]); err != nil { + t.Fatal(err) + } + learned := len(player.inventory.LearnedNanos) + player.inventory.LearnedNanos = []uint32{fixture.Program} + if err := world.handleNanoCast(client, characterActionPacket(1, [5]uint32{19, 50000, 1, 53019, fixture.Program})[20:]); err != nil { + t.Fatal(err) + } + + if permitted { + if learned != 1 || client.nanoCast == nil || player.nanoReserved != fixture.NanoCost || len(player.inventory.Items) != 2 { + t.Fatal("one point above an authored threshold rejected upload or cast") + } + } else if learned != 0 || client.nanoCast != nil || player.nano != 50000 || player.nanoReserved != 0 || + len(player.activeNanos) != 0 || player.usedNCU() != 0 || len(player.inventory.Items) != 3 { + t.Fatal("an equal skill/level threshold or wrong profession consumed a crystal or started a cast") + } + }) + } + } + } +} + +func TestSelfSelectorsRedirectTheWholeContract(t *testing.T) { + for _, targets := range [][2]uint32{{1, 1}, {1, 2}, {2, 1}, {2, 2}} { + t.Run(fmt.Sprint(targets), func(t *testing.T) { + original := gamedata.NanoTemplates[32065] + definition := *original + definition.Sections = slices.Clone(definition.Sections) + for index := range definition.Sections { + section := &definition.Sections[index] + if section.Type != 2 { + continue + } + functions := slices.Clone(*section.Functions) + section.Functions = &functions + for index := range functions { + functions[index].Target = targets[index] + } + } + gamedata.NanoTemplates[32065] = &definition + t.Cleanup(func() { gamedata.NanoTemplates[32065] = original }) + world, _ := newSelfNanoWorld(t) + player := world.characters[1] + player.profession = 5 + player.inventory.LearnedNanos = []uint32{32065} + + castTestBuff(t, world, 1, 999, 32065) + + if player.nanoBonus(151) != 130 || player.nanoBonus(379) != 4 || len(player.activeNanos) != 1 { + t.Fatal("self selectors lost a companion effect or retained the supplied target") + } + }) + } +} diff --git a/server/stat_buff_catalog_test.go b/server/stat_buff_catalog_test.go @@ -51,6 +51,10 @@ func TestStatBuffCatalogAdmitsOnlyCompleteOrdinaryContracts(t *testing.T) { expectedCrystals = append(expectedCrystals, fixture.Crystal) } } + for _, fixture := range selfAndCriticalNanoFixtures(t) { + expectedPrograms = append(expectedPrograms, fixture.Program) + expectedCrystals = append(expectedCrystals, fixture.Crystal) + } slices.Sort(expectedPrograms) slices.Sort(expectedCrystals) @@ -68,10 +72,10 @@ func TestStatBuffCatalogAdmitsOnlyCompleteOrdinaryContracts(t *testing.T) { slices.Sort(crystals) // Exact IDs come from the independent complete-original-record catalog audit. - if len(programs) != 242 || !slices.Equal(programs, expectedPrograms) { + if len(programs) != 279 || !slices.Equal(programs, expectedPrograms) { t.Fatal("buff admission differs from the complete effect/metadata audit", programs) } - if len(crystals) != 241 || !slices.Equal(crystals, expectedCrystals) { + if len(crystals) != 278 || !slices.Equal(crystals, expectedCrystals) { t.Fatal("crystal admission differs from the complete upload audit", crystals) } } @@ -289,7 +293,7 @@ func TestStatBuffCastRejectsIncompleteOrSpecialContractsWithoutDebit(t *testing. case "interval": functions[0].TickInterval = 100 case "wrong target": - functions[0].Target = 2 + functions[0].Target = 4 case "unknown section": definition.Sections = append(definition.Sections, gamedata.ItemSection{Type: 20}) case "wrong mode": diff --git a/server/testdata/self-and-critical-nanos.json b/server/testdata/self-and-critical-nanos.json @@ -0,0 +1,39 @@ +[ + {"program": 32065, "crystal": 32106, "quality": 152, "profession": 5, "modifiers": [[151, 130], [379, 4]], "ncu": 47, "duration": 270000, "nano_cost": 553, "self_only": false, "gates": [[129, 699], [122, 699]]}, + {"program": 95526, "crystal": 95532, "quality": 30, "profession": 2, "modifiers": [[379, 8]], "ncu": 10, "duration": 270000, "nano_cost": 269, "self_only": true, "gates": [[129, 154], [122, 154], [131, 154]]}, + {"program": 95527, "crystal": 95531, "quality": 169, "profession": 2, "modifiers": [[379, 24]], "ncu": 52, "duration": 360000, "nano_cost": 1239, "self_only": true, "gates": [[129, 776], [122, 776], [131, 776]]}, + {"program": 95528, "crystal": 95533, "quality": 139, "profession": 2, "modifiers": [[379, 19]], "ncu": 43, "duration": 330000, "nano_cost": 1072, "self_only": true, "gates": [[129, 647], [122, 647], [131, 647]]}, + {"program": 95529, "crystal": 95538, "quality": 90, "profession": 2, "modifiers": [[379, 13]], "ncu": 28, "duration": 300000, "nano_cost": 696, "self_only": true, "gates": [[129, 417], [122, 417], [131, 417]]}, + {"program": 160574, "crystal": 160577, "quality": 159, "profession": 2, "modifiers": [[379, 7]], "ncu": 49, "duration": 360000, "nano_cost": 1186, "self_only": false, "gates": [[129, 736], [122, 736], [131, 736]]}, + {"program": 160575, "crystal": 160578, "quality": 126, "profession": 2, "modifiers": [[379, 4]], "ncu": 39, "duration": 300000, "nano_cost": 959, "self_only": false, "gates": [[129, 583], [122, 583], [131, 583]]}, + {"program": 160576, "crystal": 160579, "quality": 57, "profession": 2, "modifiers": [[379, 2]], "ncu": 18, "duration": 270000, "nano_cost": 465, "self_only": false, "gates": [[129, 277], [122, 277], [131, 277]]}, + {"program": 201521, "crystal": 201522, "quality": 80, "profession": 11, "modifiers": [[160, 75]], "ncu": 20, "duration": 180000, "nano_cost": 466, "self_only": true, "gates": [[129, 493], [122, 493], [54, 74]]}, + {"program": 202739, "crystal": 202740, "quality": 30, "profession": 9, "modifiers": [[103, 42]], "ncu": 8, "duration": 180000, "nano_cost": 102, "self_only": true, "gates": [[129, 155], [122, 155], [54, 24]]}, + {"program": 202774, "crystal": 202775, "quality": 59, "profession": 9, "modifiers": [[103, 65]], "ncu": 15, "duration": 270000, "nano_cost": 187, "self_only": true, "gates": [[129, 294], [122, 294], [54, 49]]}, + {"program": 202776, "crystal": 202724, "quality": 8, "profession": 9, "modifiers": [[103, 14]], "ncu": 2, "duration": 180000, "nano_cost": 32, "self_only": true, "gates": [[129, 48], [122, 48]]}, + {"program": 202791, "crystal": 202792, "quality": 89, "profession": 9, "modifiers": [[103, 89]], "ncu": 22, "duration": 270000, "nano_cost": 301, "self_only": true, "gates": [[129, 460], [122, 460], [54, 74]]}, + {"program": 202826, "crystal": 202827, "quality": 8, "profession": 9, "modifiers": [[105, 14]], "ncu": 2, "duration": 180000, "nano_cost": 32, "self_only": true, "gates": [[129, 48], [122, 48]]}, + {"program": 202828, "crystal": 202829, "quality": 30, "profession": 9, "modifiers": [[105, 42]], "ncu": 8, "duration": 180000, "nano_cost": 102, "self_only": true, "gates": [[129, 155], [122, 155], [54, 24]]}, + {"program": 202830, "crystal": 202831, "quality": 59, "profession": 9, "modifiers": [[105, 65]], "ncu": 15, "duration": 270000, "nano_cost": 187, "self_only": true, "gates": [[129, 294], [122, 294], [54, 49]]}, + {"program": 202832, "crystal": 202833, "quality": 89, "profession": 9, "modifiers": [[105, 89]], "ncu": 22, "duration": 270000, "nano_cost": 301, "self_only": true, "gates": [[129, 460], [122, 460], [54, 74]]}, + {"program": 202840, "crystal": 202841, "quality": 59, "profession": 9, "modifiers": [[102, 65]], "ncu": 15, "duration": 270000, "nano_cost": 187, "self_only": true, "gates": [[129, 294], [122, 294], [54, 49]]}, + {"program": 202848, "crystal": 202849, "quality": 8, "profession": 9, "modifiers": [[107, 14]], "ncu": 2, "duration": 180000, "nano_cost": 32, "self_only": true, "gates": [[129, 48], [122, 48]]}, + {"program": 202850, "crystal": 202851, "quality": 59, "profession": 9, "modifiers": [[107, 65]], "ncu": 15, "duration": 270000, "nano_cost": 187, "self_only": true, "gates": [[129, 294], [122, 294], [54, 49]]}, + {"program": 202864, "crystal": 202865, "quality": 93, "profession": 9, "modifiers": [[106, 90]], "ncu": 23, "duration": 270000, "nano_cost": 317, "self_only": true, "gates": [[129, 485], [122, 485], [54, 74]]}, + {"program": 202866, "crystal": 202867, "quality": 56, "profession": 9, "modifiers": [[106, 62]], "ncu": 14, "duration": 270000, "nano_cost": 176, "self_only": true, "gates": [[129, 276], [122, 276], [54, 49]]}, + {"program": 202868, "crystal": 202869, "quality": 35, "profession": 9, "modifiers": [[106, 45]], "ncu": 9, "duration": 180000, "nano_cost": 115, "self_only": true, "gates": [[129, 175], [122, 175], [54, 24]]}, + {"program": 202870, "crystal": 202871, "quality": 10, "profession": 9, "modifiers": [[106, 17]], "ncu": 3, "duration": 180000, "nano_cost": 38, "self_only": true, "gates": [[129, 58], [122, 58]]}, + {"program": 203121, "crystal": 203122, "quality": 30, "profession": 1, "modifiers": [[116, 30]], "ncu": 8, "duration": 180000, "nano_cost": 102, "self_only": true, "gates": [[129, 163], [122, 163], [54, 24]]}, + {"program": 203123, "crystal": 203124, "quality": 36, "profession": 1, "modifiers": [[115, 30]], "ncu": 9, "duration": 180000, "nano_cost": 118, "self_only": true, "gates": [[129, 193], [122, 193], [54, 24]]}, + {"program": 203125, "crystal": 203126, "quality": 68, "profession": 1, "modifiers": [[115, 50]], "ncu": 17, "duration": 270000, "nano_cost": 221, "self_only": true, "gates": [[129, 377], [122, 377], [54, 49]]}, + {"program": 203127, "crystal": 203128, "quality": 178, "profession": 1, "modifiers": [[115, 90], [150, 2]], "ncu": 45, "duration": 360000, "nano_cost": 582, "self_only": true, "gates": [[129, 903], [122, 903], [54, 174]]}, + {"program": 203133, "crystal": 203134, "quality": 38, "profession": 1, "modifiers": [[148, 33]], "ncu": 10, "duration": 180000, "nano_cost": 123, "self_only": true, "gates": [[129, 204], [122, 204], [54, 24]]}, + {"program": 203135, "crystal": 203136, "quality": 33, "profession": 1, "modifiers": [[133, 44]], "ncu": 8, "duration": 180000, "nano_cost": 110, "self_only": true, "gates": [[129, 178], [122, 178], [54, 24]]}, + {"program": 203143, "crystal": 203144, "quality": 106, "profession": 1, "modifiers": [[167, 71]], "ncu": 27, "duration": 360000, "nano_cost": 370, "self_only": true, "gates": [[129, 610], [122, 610], [54, 99]]}, + {"program": 203145, "crystal": 203146, "quality": 80, "profession": 1, "modifiers": [[167, 57]], "ncu": 20, "duration": 270000, "nano_cost": 267, "self_only": true, "gates": [[129, 450], [122, 450], [54, 74]]}, + {"program": 203147, "crystal": 203148, "quality": 56, "profession": 1, "modifiers": [[167, 43]], "ncu": 14, "duration": 270000, "nano_cost": 176, "self_only": true, "gates": [[129, 301], [122, 301], [54, 49]]}, + {"program": 203149, "crystal": 203150, "quality": 31, "profession": 1, "modifiers": [[167, 29]], "ncu": 8, "duration": 180000, "nano_cost": 105, "self_only": true, "gates": [[129, 168], [122, 168], [54, 24]]}, + {"program": 203209, "crystal": 203210, "quality": 121, "profession": 9, "modifiers": [[104, 96]], "ncu": 30, "duration": 360000, "nano_cost": 436, "self_only": true, "gates": [[129, 656], [122, 656], [54, 99]]}, + {"program": 203211, "crystal": 203212, "quality": 63, "profession": 9, "modifiers": [[104, 68]], "ncu": 16, "duration": 270000, "nano_cost": 202, "self_only": true, "gates": [[129, 319], [122, 319], [54, 49]]}, + {"program": 203213, "crystal": 203214, "quality": 20, "profession": 9, "modifiers": [[104, 29]], "ncu": 5, "duration": 180000, "nano_cost": 70, "self_only": true, "gates": [[129, 105], [122, 105]]} +]