aorecomp

Anarchy Online classic in the browser

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


commit 5b8692bc878cd65b9bbe7479703ce8b76c99853c
parent 899105ecac4ce99d6c551896592165b95728b8a9
Author: anon <anon@example.com>
Date:   Sun, 25 Oct 2026 17:20:06 +0000

Add shared NPC threat and complete instant taunt nanos

Separate individual NPC threat from player/team reward credit. Retarget eligible
participants without resetting swing clocks, and drain native weapon results
before changing opponents. Keep encounter threat in memory and remove departing
or dead players through the common combat lifecycle.

Admit 27 complete original Hit plus TauntNPC programs and their 27 crystals
through the shared nano reader. Preserve authored damage, signed taunt values,
criteria and instant lifecycle; publish threat only after outcome commit.

Document reconstruction choices and remaining native HP/expiry checks. Verify
all catalog contracts, positive/negative gates, rollback, team credit, death,
zoning and socket disconnect; full server suite, race checks, vet, build and
actual two-client RTX WASM target-switch checks pass.

Diffstat:
MTODO.md | 27++++++++++++++++++++++++++-
Mdocs/nano-direct-damage.md | 4+++-
Mdocs/nano-initiative-debuffs.md | 4+++-
Adocs/npc-threat.md | 133+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mserver/combat.go | 33+++++++++++++++++++++++++++++++--
Mserver/nano_casting.go | 3+++
Mserver/nano_damage.go | 45++++++++++++++++++++++++++++++++++++++-------
Mserver/nano_damage_test.go | 4++--
Mserver/nano_periodic.go | 5+----
Aserver/nano_taunt_test.go | 345+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aserver/npc_threat.go | 34++++++++++++++++++++++++++++++++++
Aserver/npc_threat_test.go | 154+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mserver/state.go | 1+
Aserver/testdata/hit-taunt-nanos.json | 29+++++++++++++++++++++++++++++
14 files changed, 803 insertions(+), 18 deletions(-)

diff --git a/TODO.md b/TODO.md @@ -353,11 +353,24 @@ for exact records, protocol, tests and remaining reconstruction assumptions. to its home area and can participate in a new encounter. - [ ] Give one hostile creature proximity aggression. Check: an eligible nearby player is attacked while an ineligible or out-of-range player is not. -- [ ] Switch targets using damage threat. Check: a controlled two-player fight +- [x] Switch targets using damage threat. Check: a controlled two-player fight selects the expected target and removes disconnected targets. Keep threat separate from damage credit and XP. Support authored TauntNPC53117 amounts through that same threat system before admitting the complete root/snare contracts; verify zero damage, target switches, disconnects and failed saves. + Individual threat now shares all damage paths and complete instant taunts; + reward credit remains separate. See [threat policy](docs/npc-threat.md). +- [ ] Establish original-server threat arithmetic and lifecycle. Check: + correlated period evidence establishes damage conversion, target preference, + decay/reset, disconnect/reconnect and healing/pet/proximity threat. The + current additive, current-target ties and encounter restart policy are + explicit reconstruction choices, not recovered server formulas. +- [ ] Verify NPC takeover after browser reconnect grace with two native clients. + Check: the closed tab's living character remains eligible during transport + grace, then its threat disappears and a surviving participant takes over with + no phantom hit. The first smoke's disconnected character died in the last + tick before expiry, so that capture verifies death cleanup, not clean expiry. + Controlled socket disconnect/retarget is separately covered in automation. - [ ] Navigate around one simple obstacle. Check: a pursuing creature takes a valid route around a wall rather than walking through it. - [x] Recover NPC resources outside combat. Check: one profile follows an @@ -495,6 +508,13 @@ replay/failure tests and WASM checks are recorded in [IP training](docs/ip-train IIR classes beyond KKR, including JJR's inert Heal export. No usable delivery primitive was found. The bounded historical-capture and period-footage search also leaves update cadence unresolved; see [combat healing delivery](docs/combat-healing-delivery.md). +- [ ] Reconcile player HP across native observers during incoming combat and + target switches. Check: correlate authoritative HP, weapon queues and recovery + with ordinary and increased Body Development, before/after StopFight, zoning + and reconnect. The two-client taunt smoke agreed at Body Development80 after + a switch, but inflated Body Development5000 fixtures showed larger observer + differences. Separate prediction phase and invalid fixture inputs from a + delivery/recovery bug; do not assume the threat fix resolves healing delivery. - [x] Use one nano-restoring item. Check: nano recovery, consumption and its lock match that item rather than inheriting the health item's behavior. - [x] Use one sitting treatment kit. Check: it works in the permitted posture @@ -840,6 +860,11 @@ introduction and starting-item gameplay remain open below. dependency; do not substitute idle-only healing. Cover friendly targets, shared short-HoT strain12, independent long-HoT strain255, real/visual profession and level criteria, replacement, death and atomic failed ticks. +- [x] Execute complete ordinary instant Hit plus TauntNPC programs. Check: + independent full-record census admits exactly 27 programs and 27 crystals, + including all 20 one-point taunts and seven nukes. Preserve signed amounts, + every authored requirement, damage credit and instant lifecycle; use shared + threat selection without spell-ID branches. See [taunt contracts](docs/npc-threat.md). - [x] Audit original root/snare templates and native control consumers. Check: retain complete contracts for 52 ordinary roots, 21 ordinary snares and all 73 crystals; verify movement permission, signed modifiers and inverse paths. diff --git a/docs/nano-direct-damage.md b/docs/nano-direct-damage.md @@ -51,7 +51,9 @@ Ice Flechette 28612 additionally supports its full Hit followed by CastNano 53051 of 144632: four initiative debuffs for 6000 cs. Its child installation, refresh, expiry and persistence are covered in [initiative debuffs](nano-initiative-debuffs.md). Other secondary contracts and -area programs such as Radiation Pulse 28631 remain excluded. +area programs such as Radiation Pulse 28631 remain excluded. An additional +27 complete Hit plus TauntNPC programs now share the instant damage path; +see [NPC threat and taunts](npc-threat.md) for their separate census and policy. The separate flag `0x80000` zeroes native cast/recharge deadlines; it is outside this ordinary timing contract. diff --git a/docs/nano-initiative-debuffs.md b/docs/nano-initiative-debuffs.md @@ -21,8 +21,10 @@ as well. No program-ID dispatch or damage-only fallback is used. The original resource census finds two programs containing only negative initiative Modifies. Red Tape 30090 also has an area/casting contract and fails this passive-child reader. Only child 144632 and its parent 28612 pass. The -ordinary supported damage family is consequently 33 single-Hit programs plus +single-Hit/initiative-child subset is consequently 33 single-Hit programs plus Ice Flechette, with 32 ordinary single-program crystal uploaders in total. +The additional complete Hit plus TauntNPC family is covered in +[NPC threat and taunts](npc-threat.md). This does not admit arbitrary CastNano chains, hostile player casting, area effects or other debuff families. diff --git a/docs/npc-threat.md b/docs/npc-threat.md @@ -0,0 +1,133 @@ +# NPC threat and instant taunts + +NPC target selection uses individual player threat, separately from the +player/team damage totals that determine rewards and corpse access. Ordinary +weapons, specials, instant nano damage and periodic nano damage share it. +Complete instant Hit plus TauntNPC programs add their authored signed amount +after recording actual damage. No program ID chooses threat behavior. + +## Reconstruction policy + +The original client does not implement the server's hate arithmetic. Shipped +team help describes retaliation, tanks and taunting a monster off a teammate. +Funcom's 14.0 notes, reproduced in an +[April 2002 report](https://www.gamereactor.no/anarchy-online-oppdaterer-til-v140/), +say Mongo Smash incorrectly used Mongo Slam's hate amount. This establishes +that magnitude matters, without supplying a numerical formula. The June 2003 +Managing Aggro guide survives in differing later mirrors; its exact numbers +are not sufficient evidence for the original server. + +The following rules are explicit reconstruction choices: + +- Add one point of threat per actual HP removed, then the signed TauntNPC + amount. Clamp a negative total to zero. A hostile cast or zero-damage hit + can introduce a zero-score participant without inventing damage credit. +- Select the highest eligible individual score. Retain the current opponent + on equal scores; otherwise choose the lowest actor identity on a tie. +- Require a living connected player, ready and finished loading, in the same + playfield, with interest in the NPC. Recheck active NPC fights each combat + visit. Range and the existing pursuit policy still govern actual attacks. +- Disconnect, zoning and death remove that player's entry and immediately + select another eligible participant. Stopping a player's own attack does + not pacify the NPC. Damage credit remains for the NPC's life. +- NPC death clears threat. New lives start empty. Threat, fighting targets + and attack clocks are encounter state held in memory; restarting the server + resets them. Durable damage, contributions, rewards and nano progress retain + their existing persistence rules. A later offline DoT can add damage threat + but cannot select its disconnected caster. + +No decay, damage-equivalent multiplier, current-target bonus, healing threat, +pet threat or proximity aggression formula is claimed. A correlated period +server capture is still needed to replace these choices with canonical rules. + +Switching sends StopFight before Attack, so the native holder consumes queued +weapon results against its old opponent. It preserves an existing next-swing +deadline and recharge, rather than restarting or accelerating either phase. +The relevant maintained native fields and consumers are in +[combat state](combat-client-state-machine.md). + +## Complete template contracts + +An independent reparse scanned 4,366 original nanos and 83,245 item resources. +Of 239 nanos containing TauntNPC53117, none contains it alone. The supported +ordinary group is 27 complete programs and 27 individual crystals: 20 taunts +and seven nukes. All have exactly Hit53002 followed by TauntNPC53117, with +target3, one execution, no interval or function requirements, header `[0,4]` +and argument header9. The taunt arguments are two zero eight-byte opaque +values surrounding one signed integer. Unknown companions remain rejected. + +The complete reader checks the attack/defence dictionaries, their zero default +entries, the OnUse section, action3 criteria and ordinary casting metadata. +The reviewed flag variants are `0x8000` and `0x80008000`, with no duration or +strain. Taunts have school405=4 and zero Nano Resist weight; nukes have +school405=1 and their own positive weight. Resonance Blast retains can30=1. +Ordinary single-Hit and periodic admission retain their existing restrictions. + +| Program | Crystal | Actual HP damage | Authored taunt | +| --- | --- | --- | --- | +| Aggression Prod26341 | 26468 | 1, stat92 | 59 | +| Ego Pummel26418 | 26545 | 1, stat92 | 181 | +| Enmity26421 | 26548 | 1, stat92 | 50 | +| Burning Bones28597 | 28800 | 1005..2476, stat97 | 2520 | +| Resonance Blast201935 | 201936 | 3105..5970, stat94 | -3000 | + +Every ordinary taunt includes its authored one-point energy Hit (stat92). +Enmity retains its unusual 35m range and 50 taunt. These are instant contracts: no timed active +nano or NCU occupancy is manufactured from the NCU stat. Raw costs, native +float debit, attack/recharge, range and real/visual profession, level and skill +criteria use the shared upload/cast path. Existing resistance, damage and +line-of-sight reconstruction limits still apply. + +Mongo wrappers/area children, roots, snares, calms, pet aggression and unusual +NPC/event effects are separate complete contracts and remain unsupported. +Supporting their taunt component does not admit their other effects. + +The checked-in independent oracle is +`server/testdata/hit-taunt-nanos.json`. Complete raw records, source offsets, +hashes and separate reparse verification are retained in +`local/npc-threat-research/catalog/`; period-source findings are in the adjacent +`sources/` directory. Resource DAT SHA256 is +`ad8afec23058db02af75b9f5d614ef6ebe3e93cc817bd626955f18a372e13741`; +IDX SHA256 is +`46e5dc54af9358cc9bff05f4358e86af630e497bc677f361c133c88073b84d71`. + +## Verification + +Automated coverage includes the exact 27-program/crystal census, each upload +and complete cast, every authored requirement boundary, signed negative +taunt, instant lifecycle, cold durable results and encounter reset. Two-player +checks cover damage switching, ties, shared team credit, swing-clock retention, +packet order, unavailable targets, zoning and death. Fault injection covers +target failure, ignored contribution writes and deferred COMMIT failure: +uncommitted damage and threat cannot become visible or retarget the NPC. + +The complete Go server/data suite passed 5,655 tests/subtests, with the server +package completing in 855.426s. The exporter and assets packages compiled and +have no test files. Focused threat, transaction and concurrent periodic-damage +checks passed under the race detector three times in 101.067s. Vet and the +preview build passed. + +An additional controlled socket-disconnect test verifies immediate threat +removal, takeover by the remaining connection, preserved swing deadline and +unchanged lifetime damage credit. It was added after the full suite and is +verified separately under the race detector. +All ten repetitions passed in 94.307s; production code was unchanged after +the full-suite run. + +Two headed WASM clients on the GPU uploaded Aggression Prod through the +native inventory, cast through the native PSI menu, and agreed on target +selection in both directions. Equal totals retained the current target; +repeated taunts switched it. Both clients received eight one-point energy hits +on the primary fixture across the initial and ordinary-stat runs, with ordered +StopFight/Attack on target changes and no timed nano or application errors. +A fresh login correctly retained the other participant as the NPC target. +The two-minute browser grace observation ended with the disconnected actor +dying in its last combat tick before expiry. Its native observer saw the NPC +stop at death while the other fight continued. That run is inconclusive for +clean disconnect-expiry takeover; a living-target native repeat remains open. + +The initial Body Development5000 fixtures showed player HP differences between +native observers. At Body Development80, both clients read 326/347 HP after +the checked switch. This bounds the observed result; it does not establish +general combat HP/recovery correctness. Correlating server HP, recovery phases +and pending weapon results remains a separate TODO alongside healing delivery. diff --git a/server/combat.go b/server/combat.go @@ -323,6 +323,13 @@ func (server *server) stopAttack_locked(attacker *character, updates map[*worldC } func (server *server) cancelCombat_locked(id uint32, updates map[*worldClient][][]byte) { + // Threat belongs to this encounter, independently of lifetime damage credit. + for _, npc := range server.characters { + if _, exists := npc.threat[id]; exists { + delete(npc.threat, id) + server.selectNPCTarget_locked(npc, time.Now(), updates) + } + } // Leaving or dying also releases every opponent targeting this character. for _, attacker := range server.fighting { if attacker.id == id || attacker.fighting == id { @@ -340,6 +347,13 @@ func (server *server) advanceCombat(now time.Time) { server.mutex.Lock() updates := make(map[*worldClient][][]byte) + // An unavailable opponent must not prevent another participant taking over. + for _, attacker := range server.fighting { + if attacker.npc && len(attacker.threat) != 0 { + server.selectNPCTarget_locked(attacker, now, updates) + } + } + // Resolve simultaneous swings in identity order, without replaying missed ticks. ids := make([]uint32, 0, len(server.fighting)) for id := range server.fighting { @@ -439,12 +453,17 @@ func prepareDamage(attacker, target *character, damage uint32, now time.Time) ch candidate.collectReclaim(now) } candidate.damageContributors = maps.Clone(target.damageContributors) + candidate.threat = maps.Clone(target.threat) if target.corpse != nil { corpse := *target.corpse candidate.corpse = &corpse } // Credit the player or team present at each hit for this NPC life. if candidate.npc && !attacker.npc { + if candidate.threat == nil { + candidate.threat = make(map[uint32]int64) + } + candidate.threat[attacker.id] += int64(damage) if candidate.damageContributors == nil { candidate.damageContributors = make(map[damageContributor]uint32) } @@ -458,6 +477,9 @@ func prepareDamage(attacker, target *character, damage uint32, now time.Time) ch candidate.leadingContributor = contributor } } + if candidate.health == 0 { + candidate.threat = nil + } monster := gamedata.MonsterTemplates[candidate.monsterData] if candidate.health == 0 && candidate.npc && monster != nil && len(monster.DeathAnimations) != 0 { if candidate.corpse == nil { @@ -521,8 +543,15 @@ func (server *server) finishDamageEffects_locked(attacker, target *character, pr npc: target, at: now.Add(time.Duration(target.combatProfile.RespawnSeconds) * time.Second), }) } - } else if target.npc && target.fighting == 0 { - server.startAttack_locked(target, attacker, now, updates) + } else if target.npc && !attacker.npc { + // A hostile cast or a zero-damage hit still starts an encounter. + if target.threat == nil { + target.threat = make(map[uint32]int64) + } + if _, exists := target.threat[attacker.id]; !exists { + target.threat[attacker.id] = 0 + } + server.selectNPCTarget_locked(target, now, updates) } } diff --git a/server/nano_casting.go b/server/nano_casting.go @@ -230,6 +230,9 @@ func (server *server) advanceNanos(now time.Time) { minimum, maximum := uint32(-*hit.Arguments[1].Integer), uint32(-*hit.Arguments[2].Integer) damage = min(minimum+rand.Uint32N(maximum-minimum+1), target.health) victim = prepareDamage(player, target, damage, now) + if victim.npc && victim.health != 0 { + victim.threat[player.id] = max(0, victim.threat[player.id]+int64(damageNanoTaunt(program))) + } effectProgram = damageNanoSecondary(program) } if effectProgram != 0 && victim.health != 0 { diff --git a/server/nano_damage.go b/server/nano_damage.go @@ -16,7 +16,7 @@ func damageOverTimeNano(program uint32) *gamedata.ItemFunction { func hostileHitNano(program uint32, periodic bool) *gamedata.ItemFunction { definition := gamedata.NanoTemplates[program] if definition == nil || definition.RecordType != 1040005 || definition.HeaderWords[0] != 51051 || definition.Undecoded != nil || - itemStat(definition, 30) != 0 || itemStat(definition, 76) != 0 || len(definition.Sections) != 4 { + itemStat(definition, 30) > 1 || itemStat(definition, 76) != 0 || len(definition.Sections) != 4 { return nil } if periodic { @@ -31,7 +31,7 @@ func hostileHitNano(program uint32, periodic bool) *gamedata.ItemFunction { return nil } } - } else if itemStat(definition, 0) != 0x80008000 { + } else if flags := itemStat(definition, 0); flags != 0x80008000 && flags != 0x8000 { return nil } for _, stat := range []uint32{210, 287, 294, 407} { @@ -51,7 +51,7 @@ func hostileHitNano(program uint32, periodic bool) *gamedata.ItemFunction { attack, defense = defense, attack } if attack.Type == nil || *attack.Type != 12 || attack.Stats == nil || defense.Type == nil || *defense.Type != 13 || defense.Stats == nil || - len(*defense.Stats) != 1 || (*defense.Stats)[0][0] != 168 || (*defense.Stats)[0][1] == 0 { + len(*defense.Stats) != 1 || (*defense.Stats)[0][0] != 168 { return nil } var total uint32 @@ -105,26 +105,57 @@ func hostileHitNano(program uint32, periodic bool) *gamedata.ItemFunction { *hit.Arguments[3].Integer < 90 || *hit.Arguments[3].Integer > 97 { return nil } + taunt := false if len(*effects.Functions) == 2 { secondary := (*effects.Functions)[1] - if secondary.ID != 53051 || secondary.HeaderWords != [2]uint32{0, 4} || secondary.ArgumentHeader != 9 || secondary.Target != 3 || - len(secondary.Requirements) != 0 || secondary.TickCount != 1 || secondary.TickInterval != 0 || len(secondary.Arguments) != 1 || - secondary.Arguments[0].Integer == nil || !initiativeDebuffNano(uint32(*secondary.Arguments[0].Integer)) { + if secondary.HeaderWords != [2]uint32{0, 4} || secondary.ArgumentHeader != 9 || secondary.Target != 3 || + len(secondary.Requirements) != 0 || secondary.TickCount != 1 || secondary.TickInterval != 0 { + return nil + } + switch secondary.ID { + case 53051: + if len(secondary.Arguments) != 1 || secondary.Arguments[0].Integer == nil || !initiativeDebuffNano(uint32(*secondary.Arguments[0].Integer)) { + return nil + } + case 53117: + if len(secondary.Arguments) != 3 || secondary.Arguments[0].BytesHex == nil || *secondary.Arguments[0].BytesHex != "0000000000000000" || + secondary.Arguments[1].Integer == nil || secondary.Arguments[2].BytesHex == nil || *secondary.Arguments[2].BytesHex != "0000000000000000" { + return nil + } + taunt = true + default: return nil } } + if taunt { + if periodic || itemStat(definition, 8) != 0 || itemStat(definition, 75) != 0 || + (itemStat(definition, 405) != 1 && itemStat(definition, 405) != 4) { + return nil + } + } else if itemStat(definition, 30) != 0 || (*defense.Stats)[0][1] == 0 || !periodic && itemStat(definition, 0) != 0x80008000 { + return nil + } return hit } func damageNanoSecondary(program uint32) uint32 { // Called only after admission of the complete direct-damage contract. functions := *gamedata.NanoTemplates[program].Sections[2].Functions - if len(functions) == 2 { + if len(functions) == 2 && functions[1].ID == 53051 { return uint32(*functions[1].Arguments[0].Integer) } return 0 } +func damageNanoTaunt(program uint32) int32 { + // Called only after admission of the complete direct-damage contract. + functions := *gamedata.NanoTemplates[program].Sections[2].Functions + if len(functions) == 2 && functions[1].ID == 53117 { + return *functions[1].Arguments[1].Integer + } + return 0 +} + func initiativeDebuffNano(program uint32) bool { definition := gamedata.NanoTemplates[program] if definition == nil || definition.RecordType != 1040005 || definition.HeaderWords[0] != 51051 || definition.Undecoded != nil || diff --git a/server/nano_damage_test.go b/server/nano_damage_test.go @@ -70,12 +70,12 @@ func TestDirectDamageNanoCatalogMatchesCompleteOriginalContracts(t *testing.T) { } for program := range gamedata.NanoTemplates { - if directDamageNano(program) != nil && damageNanoSecondary(program) == 0 { + if directDamageNano(program) != nil && damageNanoSecondary(program) == 0 && damageNanoTaunt(program) == 0 { programs = append(programs, program) } } for crystal := range gamedata.ItemTemplates { - if program := nanoCrystalProgram(crystal); directDamageNano(program) != nil && damageNanoSecondary(program) == 0 { + if program := nanoCrystalProgram(crystal); directDamageNano(program) != nil && damageNanoSecondary(program) == 0 && damageNanoTaunt(program) == 0 { crystals = append(crystals, crystal) } } diff --git a/server/nano_periodic.go b/server/nano_periodic.go @@ -56,10 +56,7 @@ func (server *server) advancePeriodicNanos_locked(now time.Time, updates map[*wo previous := *target *target = candidate server.queueCombat_locked(updates, target, target, packets...) - client := server.clients[attacker.id] - if target.health == 0 || client != nil && client.ready && !client.loading && attacker.health != 0 && attacker.playfield == target.playfield { - server.finishDamageEffects_locked(attacker, target, previous, now, updates) - } + server.finishDamageEffects_locked(attacker, target, previous, now, updates) server.applyExperienceAward_locked(award, now, updates) if target.health == 0 { server.queueCombat_locked(updates, target, target, characterActionPacket(target.id, [5]uint32{153, 0, 0, 0, 5})) diff --git a/server/nano_taunt_test.go b/server/nano_taunt_test.go @@ -0,0 +1,345 @@ +package main + +import ( + "ao/server/gamedata" + _ "embed" + "encoding/binary" + "encoding/json" + "fmt" + "reflect" + "slices" + "testing" + "time" +) + +//go:embed testdata/hit-taunt-nanos.json +var hitTauntNanoData []byte + +type hitTauntNanoFixture struct { + directDamageNanoFixture + Taunt int32 + TargetType uint32 `json:"target_type"` + Can, Flags uint32 + NCU uint32 + Actions []gamedata.ItemAction + Weights []gamedata.ItemEntry +} + +func hitTauntNanoFixtures(t *testing.T) []hitTauntNanoFixture { + t.Helper() + var fixtures []hitTauntNanoFixture + if err := json.Unmarshal(hitTauntNanoData, &fixtures); err != nil { + t.Fatal(err) + } + return fixtures +} + +func newHitTauntWorld(t *testing.T, fixture hitTauntNanoFixture) (*server, *combatTestConn) { + t.Helper() + world, conn := newDirectDamageWorld(t, fixture.directDamageNanoFixture) + player, target := world.characters[1], world.characters[1000000] + player.level = 200 + for _, requirement := range fixture.Actions[0].Requirements { + if requirement.Stat == 60 || requirement.Stat == 368 { + player.profession = uint16(requirement.Value) + } + } + target.health = 20000 + if err := world.saveUser_locked(player); err != nil { + t.Fatal(err) + } + if err := world.flushWorld(); err != nil { + t.Fatal(err) + } + return world, conn +} + +func TestHitTauntNanoCatalogMatchesCompleteOriginalContracts(t *testing.T) { + var programs, crystals, expectedPrograms, expectedCrystals []uint32 + fixtures := hitTauntNanoFixtures(t) + for _, fixture := range fixtures { + expectedPrograms = append(expectedPrograms, fixture.Program) + expectedCrystals = append(expectedCrystals, fixture.Crystal) + } + + for program := range gamedata.NanoTemplates { + if directDamageNano(program) != nil && damageNanoTaunt(program) != 0 { + programs = append(programs, program) + } + } + for crystal := range gamedata.ItemTemplates { + if program := nanoCrystalProgram(crystal); directDamageNano(program) != nil && damageNanoTaunt(program) != 0 { + crystals = append(crystals, crystal) + } + } + for _, values := range [][]uint32{programs, crystals, expectedPrograms, expectedCrystals} { + slices.Sort(values) + } + + if len(programs) != 27 || len(crystals) != 27 || !slices.Equal(programs, expectedPrograms) || !slices.Equal(crystals, expectedCrystals) { + t.Fatal("complete original-record census differs", programs, crystals) + } + for _, fixture := range fixtures { + definition, hit := gamedata.NanoTemplates[fixture.Program], directDamageNano(fixture.Program) + if uint32(-*hit.Arguments[1].Integer) != fixture.Minimum || uint32(-*hit.Arguments[2].Integer) != fixture.Maximum || + uint32(*hit.Arguments[3].Integer) != fixture.DamageType || damageNanoTaunt(fixture.Program) != fixture.Taunt || + nanoStat(fixture.Program, 407) != fixture.NanoCost || nanoStat(fixture.Program, 294) != fixture.AttackDelay || + nanoStat(fixture.Program, 210) != fixture.RechargeDelay || nanoStat(fixture.Program, 287) != fixture.Range || + nanoStat(fixture.Program, 405) != fixture.TargetType || nanoStat(fixture.Program, 0) != fixture.Flags || + nanoStat(fixture.Program, 30) != fixture.Can || nanoStat(fixture.Program, 54) != fixture.NCU || + !reflect.DeepEqual(*definition.Sections[0].Entries, fixture.Weights) || !reflect.DeepEqual(*definition.Sections[3].Actions, fixture.Actions) { + t.Fatal("authored complete contract changed", fixture.Program) + } + } +} + +func TestHitTauntNanosUploadCastAndCommitDamageSeparatelyFromThreat(t *testing.T) { + for _, fixture := range hitTauntNanoFixtures(t) { + t.Run(fmt.Sprint(fixture.Program), func(t *testing.T) { + world, conn := newHitTauntWorld(t, fixture) + player, target, client := world.characters[1], world.characters[1000000], world.clients[1] + target.threat = map[uint32]int64{1: 10000, 2: 25000} + if err := world.handleOwnedItemUse(client, backpackUseRequest(1, 64, 1)[20:]); err != nil { + t.Fatal(err) + } + if len(player.inventory.Items) != 0 || !slices.Equal(player.inventory.LearnedNanos, []uint32{fixture.Program}) { + t.Fatal("qualified original crystal did not upload exactly once") + } + conn.packets = nil + + if err := world.handleNanoCast(client, characterActionPacket(1, [5]uint32{19, 50000, target.id, 53019, fixture.Program})[20:]); err != nil { + t.Fatal(err) + } + if client.nanoCast == nil { + t.Fatal("qualified learned program was rejected") + } + at := client.nanoCast.readyAt + world.advanceNanos(at) + if target.health != 20000 || target.threat[1] != 10000 { + t.Fatal("effect arrived before execution") + } + world.advanceNanos(at.Add(time.Nanosecond)) + damage, packets := 20000-target.health, len(conn.packets) + world.advanceNanos(at.Add(time.Second)) + cold := newTestInventoryServer(t) + + if damage < fixture.Minimum || damage > fixture.Maximum || target.threat[1] != 10000+int64(damage)+int64(fixture.Taunt) || + target.threat[2] != 25000 || target.damageContributors[damageContributor{player: 1}] != damage || target.fighting != 1 || + len(conn.packets) != packets || len(target.activeNanos) != 0 || client.nanoCast != nil || player.nanoReserved != 0 || + player.nano != 50000-(fixture.NanoCost-1) || cold.characters[1].nano != player.nano || cold.characters[target.id].health != target.health || + cold.characters[target.id].damageContributors[damageContributor{player: 1}] != damage || len(cold.characters[target.id].threat) != 0 { + t.Fatalf("complete cast lost damage, signed threat, cost or restart policy: damage=%d threat=%v", damage, target.threat) + } + if len(conn.packets) != 5 || binary.BigEndian.Uint32(conn.packets[2][29:33]) != 107 || + binary.BigEndian.Uint32(conn.packets[3][16:20]) != 0x4727213e || int32(binary.BigEndian.Uint32(conn.packets[3][29:33])) != -int32(damage) || + binary.BigEndian.Uint32(conn.packets[3][33:37]) != fixture.DamageType || binary.BigEndian.Uint32(conn.packets[4][16:20]) != 0x28494070 { + t.Fatal("instant taunt manufactured a timed effect or lost the authored hit") + } + }) + } +} + +func TestHitTauntNanoRequirementsApplyToBothUploadAndCast(t *testing.T) { + for _, fixture := range hitTauntNanoFixtures(t) { + for _, requirement := range fixture.Actions[0].Requirements { + if requirement.Operator != 2 && requirement.Stat != 60 && requirement.Stat != 368 { + continue + } + for _, passed := range []bool{false, true} { + t.Run(fmt.Sprintf("%d/%d/pass=%t", fixture.Program, requirement.Stat, passed), func(t *testing.T) { + world, _ := newHitTauntWorld(t, fixture) + player, client := world.characters[1], world.clients[1] + value := uint16(requirement.Value) + if passed { + value++ + } + if requirement.Stat == 54 { + player.level = value + } else if requirement.Stat == 60 || requirement.Stat == 368 { + if !passed { + player.profession = uint16(requirement.Value%12 + 1) + } + } else { + for _, field := range player.stats.trainingStats() { + if field.stat == uint32(requirement.Stat) { + *field.value = value + } + } + } + + if err := world.handleOwnedItemUse(client, backpackUseRequest(1, 64, 1)[20:]); err != nil { + t.Fatal(err) + } + if (len(player.inventory.LearnedNanos) == 1) != passed || !passed && len(player.inventory.Items) != 1 { + t.Fatal("original crystal ignored an authored requirement") + } + player.inventory.LearnedNanos = []uint32{fixture.Program} + if err := world.handleNanoCast(client, characterActionPacket(1, [5]uint32{19, 50000, 1000000, 53019, fixture.Program})[20:]); err != nil { + t.Fatal(err) + } + + if (client.nanoCast != nil) != passed || !passed && player.nano != 50000 { + t.Fatal("casting requirement or rejected cost changed") + } + }) + } + } + } +} + +func TestHitTauntRejectsIncompleteAndUnverifiedCompanions(t *testing.T) { + for _, scenario := range []string{"missing hit", "extra effect", "wrong order", "periodic taunt", "taunt interval", "self target", "conditional", "unknown prefix", "unknown suffix", "opaque amount", "unknown function", "lifetime", "strain"} { + t.Run(scenario, func(t *testing.T) { + original := gamedata.NanoTemplates[26341] + definition := *original + definition.Stats, definition.Sections = slices.Clone(original.Stats), slices.Clone(original.Sections) + functions := slices.Clone(*definition.Sections[2].Functions) + functions[1].Arguments = slices.Clone(functions[1].Arguments) + definition.Sections[2].Functions = &functions + switch scenario { + case "missing hit": + functions = functions[1:] + case "extra effect": + functions = append(functions, functions[1]) + case "wrong order": + functions[0], functions[1] = functions[1], functions[0] + case "periodic taunt": + functions[1].TickCount = 2 + case "taunt interval": + functions[1].TickInterval = 100 + case "self target": + functions[1].Target = 2 + case "conditional": + functions[1].Requirements = []gamedata.ItemRequirement{{Stat: 54, Value: 1, Operator: 2}} + case "unknown prefix", "unknown suffix": + value := "0000000000000001" + index := 0 + if scenario == "unknown suffix" { + index = 2 + } + functions[1].Arguments[index].BytesHex = &value + case "opaque amount": + functions[1].Arguments[1].Integer = nil + case "unknown function": + functions[1].ID = 53118 + case "lifetime": + definition.Stats = append(definition.Stats, [2]uint32{8, 100}) + case "strain": + definition.Stats = append(definition.Stats, [2]uint32{75, 100}) + } + gamedata.NanoTemplates[26341] = &definition + t.Cleanup(func() { gamedata.NanoTemplates[26341] = original }) + world, _ := newDirectDamageWorld(t, directDamageNanoFixture{}) + player, client := world.characters[1], world.clients[1] + player.inventory.LearnedNanos = []uint32{26341} + + if err := world.handleNanoCast(client, characterActionPacket(1, [5]uint32{19, 50000, 1000000, 53019, 26341})[20:]); err != nil { + t.Fatal(err) + } + + if directDamageNano(26341) != nil || nanoCrystalProgram(26468) != 0 || client.nanoCast != nil || player.nano != 50000 || len(world.characters[1000000].threat) != 0 { + t.Fatal("partial contract was admitted or affected resources/threat") + } + }) + } +} + +func TestFailedTauntOutcomeCannotPublishThreatOrRetarget(t *testing.T) { + for _, statement := range []string{ + "CREATE TRIGGER fail_taunt BEFORE UPDATE ON npcs BEGIN SELECT RAISE(FAIL, 'test NPC'); END", + "CREATE TRIGGER fail_taunt BEFORE INSERT ON npc_damage_contributors BEGIN SELECT RAISE(IGNORE); END", + "CREATE TABLE pending_taunt (player_id INTEGER REFERENCES players(id) DEFERRABLE INITIALLY DEFERRED); CREATE TRIGGER fail_taunt AFTER UPDATE OF nano ON characters WHEN NEW.id=1 BEGIN INSERT INTO pending_taunt VALUES (999999); END", + } { + t.Run(statement, func(t *testing.T) { + world, conn := newHitTauntWorld(t, hitTauntNanoFixtures(t)[0]) + player, target, client := world.characters[1], world.characters[1000000], world.clients[1] + player.inventory.LearnedNanos = []uint32{26341} + target.threat = map[uint32]int64{1: 5, 2: 20} + target.fighting, target.nextAttack = 2, time.Now().Add(time.Second) + clock := target.nextAttack + if err := world.handleNanoCast(client, characterActionPacket(1, [5]uint32{19, 50000, target.id, 53019, 26341})[20:]); err != nil { + t.Fatal(err) + } + at := client.nanoCast.readyAt.Add(time.Nanosecond) + if _, err := world.db.Exec(statement); err != nil { + t.Fatal(err) + } + conn.packets = nil + + world.advanceNanos(at) + if _, err := world.db.Exec("DROP TRIGGER fail_taunt"); err != nil { + t.Fatal(err) + } + cold := newTestInventoryServer(t) + + if target.health != 20000 || target.threat[1] != 5 || target.threat[2] != 20 || target.fighting != 2 || target.nextAttack != clock || + len(target.damageContributors) != 0 || cold.characters[target.id].health != 20000 || !player.nanoRechargeUntil.IsZero() { + t.Fatal("failed transaction changed damage, threat, target or attack clock") + } + for _, packet := range conn.packets { + if binary.BigEndian.Uint32(packet[16:20]) != 0x5e477770 && binary.BigEndian.Uint32(packet[16:20]) != 0x2b333d6e { + t.Fatal("failed transaction published a hit or target switch") + } + } + }) + } +} + +func TestTauntSwitchesBetweenConnectedPlayersWithoutChangingRewardCredit(t *testing.T) { + world, conn := newHitTauntWorld(t, hitTauntNanoFixtures(t)[0]) + player, target, client := world.characters[1], world.characters[1000000], world.clients[1] + world.characters[2] = &character{id: 2, playfield: 950, health: 100, stats: testCharacterStats()} + world.clients[2] = &worldClient{id: 2, conn: &combatTestConn{}, ready: true, npcs: map[uint32]bool{target.id: true}} + player.inventory.LearnedNanos = []uint32{26341} + target.threat = map[uint32]int64{2: 20} + target.damageContributors = map[damageContributor]uint32{{player: 2}: 20} + target.leadingContributor = damageContributor{player: 2} + target.fighting, target.nextAttack = 2, time.Now().Add(10*time.Second) + clock := target.nextAttack + world.fighting[target.id] = target + if err := world.handleNanoCast(client, characterActionPacket(1, [5]uint32{19, 50000, target.id, 53019, 26341})[20:]); err != nil { + t.Fatal(err) + } + conn.packets = nil + + world.advanceNanos(client.nanoCast.readyAt.Add(time.Nanosecond)) + + if target.fighting != 1 || target.nextAttack != clock || target.threat[1] != 60 || target.threat[2] != 20 || + target.damageContributors[damageContributor{player: 1}] != 1 || target.damageContributors[damageContributor{player: 2}] != 20 || + target.leadingContributor != (damageContributor{player: 2}) || len(conn.packets) != 4 || + binary.BigEndian.Uint32(conn.packets[2][16:20]) != 0x4a41203e || binary.BigEndian.Uint32(conn.packets[3][16:20]) != 0x28494070 { + t.Fatal("taunt changed damage/clock/credit or failed to retarget", target.threat, target.damageContributors) + } +} + +func TestPlayerDeathReleasesThreatAndRetargetsTheSurvivingParticipant(t *testing.T) { + world, _ := newHitTauntWorld(t, hitTauntNanoFixtures(t)[0]) + player, target := world.characters[1], world.characters[1000000] + player.health = 1 + world.characters[2] = &character{id: 2, playfield: 950, health: 100, stats: testCharacterStats()} + world.clients[2] = &worldClient{id: 2, conn: &combatTestConn{}, ready: true, npcs: map[uint32]bool{target.id: true}} + target.threat = map[uint32]int64{1: 10, 2: 5} + target.fighting, target.nextAttack = 1, time.Now() + world.fighting[target.id] = target + if err := world.saveUser_locked(player); err != nil { + t.Fatal(err) + } + + world.advanceCombat(target.nextAttack) + + if player.health != 0 || target.fighting != 2 || len(target.threat) != 1 || target.threat[2] != 5 { + t.Fatal("death retained the dead target or lost the surviving participant", target.threat) + } +} + +func TestHostilePeriodicCastStartsThreatBeforeAnyDamage(t *testing.T) { + world, _ := newPeriodicNanoWorld(t) + + castPeriodicNano(t, world, 43376) + + target := world.characters[1000000] + score, exists := target.threat[1] + if target.health != 100 || target.fighting != 1 || !exists || score != 0 || len(target.damageContributors) != 0 { + t.Fatal("initial hostile contact needs zero threat without invented damage or XP credit") + } +} diff --git a/server/npc_threat.go b/server/npc_threat.go @@ -0,0 +1,34 @@ +package main + +import "time" + +func (server *server) selectNPCTarget_locked(npc *character, now time.Time, updates map[*worldClient][][]byte) { + var target *character + if npc.health != 0 { + for id, score := range npc.threat { + player, client := server.characters[id], server.clients[id] + if player == nil || player.health == 0 || player.playfield != npc.playfield || + client == nil || !client.ready || client.loading || !client.npcs[npc.id] { + continue + } + // Keep the current opponent on ties; otherwise use stable identity order. + if target == nil || score > npc.threat[target.id] || score == npc.threat[target.id] && + (id == npc.fighting || target.id != npc.fighting && id < target.id) { + target = player + } + } + } + if target != nil && npc.fighting == target.id { + return + } + + // Native StopFight consumes queued hits against the old opponent first. + nextAttack := npc.nextAttack + server.stopAttack_locked(npc, updates) + if target != nil { + server.startAttack_locked(npc, target, now, updates) + if !nextAttack.IsZero() { + npc.nextAttack = nextAttack + } + } +} diff --git a/server/npc_threat_test.go b/server/npc_threat_test.go @@ -0,0 +1,154 @@ +package main + +import ( + "encoding/binary" + "testing" + "time" +) + +func newThreatWorld() (*server, *combatTestConn) { + world, conn := newCombatWorld() + world.characters[2] = &character{id: 2, playfield: 950, health: 100, stats: testCharacterStats()} + world.clients[2] = &worldClient{id: 2, conn: &combatTestConn{}, ready: true, npcs: map[uint32]bool{1000000: true}} + return world, conn +} + +func TestNPCSwitchesToHigherDamageWithoutResettingItsAttackClock(t *testing.T) { + world, conn := newThreatWorld() + npc := world.characters[1000000] + world.handleCombat(world.clients[1], attackPacket(1, npc.id)[20:]) + first := world.characters[1].nextAttack + world.advanceCombat(first) + world.handleCombat(world.clients[1], stopFightPacket(1)[20:]) + next := npc.nextAttack + world.handleCombat(world.clients[2], attackPacket(2, npc.id)[20:]) + second := world.characters[2].nextAttack + world.advanceCombat(second) + if npc.fighting != 1 { + t.Fatal("equal damage must retain the current target") + } + // Give the second player another swing while the NPC is in its recharge. + world.characters[2].nextAttack = second.Add(time.Millisecond) + conn.packets = nil + + world.advanceCombat(second.Add(time.Millisecond)) + + if npc.fighting != 2 || npc.nextAttack != next { + t.Fatalf("higher damage did not switch targets without resetting the clock: target=%d clock=%v want=%v", npc.fighting, npc.nextAttack, next) + } + if len(conn.packets) != 3 || binary.BigEndian.Uint32(conn.packets[1][16:20]) != 0x4a41203e || + binary.BigEndian.Uint32(conn.packets[2][16:20]) != 0x28494070 || binary.BigEndian.Uint32(conn.packets[2][33:37]) != 2 { + t.Fatal("retarget must drain queued native hits with StopFight before Attack") + } +} + +func TestNPCThreatIsIndividualEvenWhenDamageCreditBelongsToATeam(t *testing.T) { + world, _ := newThreatWorld() + npc := world.characters[1000000] + team := &playerTeam{id: 7} + world.characters[1].team, world.characters[2].team = team, team + world.handleCombat(world.clients[1], attackPacket(1, npc.id)[20:]) + world.advanceCombat(world.characters[1].nextAttack) + world.handleCombat(world.clients[1], stopFightPacket(1)[20:]) + world.handleCombat(world.clients[2], attackPacket(2, npc.id)[20:]) + world.advanceCombat(world.characters[2].nextAttack) + world.characters[2].nextAttack = npc.nextAttack.Add(-time.Nanosecond) + + world.advanceCombat(world.characters[2].nextAttack) + + if npc.fighting != 2 || npc.threat[1] != 5 || npc.threat[2] != 10 || len(npc.damageContributors) != 1 || + npc.damageContributors[damageContributor{team: 7}] != 15 || npc.leadingContributor != (damageContributor{team: 7}) { + t.Fatal("team reward credit replaced individual target selection", npc.threat, npc.damageContributors) + } +} + +func TestNPCChoosesAnEligibleParticipantWhenItsTargetBecomesUnavailable(t *testing.T) { + for _, scenario := range []string{"offline", "dead", "other zone", "loading", "not ready", "no interest", "missing actor"} { + t.Run(scenario, func(t *testing.T) { + world, _ := newThreatWorld() + npc := world.characters[1000000] + world.handleCombat(world.clients[1], attackPacket(1, npc.id)[20:]) + world.advanceCombat(world.characters[1].nextAttack) + world.handleCombat(world.clients[1], stopFightPacket(1)[20:]) + world.handleCombat(world.clients[2], attackPacket(2, npc.id)[20:]) + world.advanceCombat(world.characters[2].nextAttack) + clock := npc.nextAttack + switch scenario { + case "offline": + delete(world.clients, 1) + case "dead": + world.characters[1].health = 0 + case "other zone": + world.characters[1].playfield = 705 + case "loading": + world.clients[1].loading = true + case "not ready": + world.clients[1].ready = false + case "no interest": + delete(world.clients[1].npcs, npc.id) + case "missing actor": + delete(world.clients, 1) + delete(world.characters, 1) + } + + world.advanceCombat(clock.Add(-time.Nanosecond)) + + if npc.fighting != 2 || npc.nextAttack != clock { + t.Fatal("an ineligible target blocked a participant or reset the swing clock") + } + }) + } +} + +func TestNPCRemovesZonedPlayersFromThreatButKeepsTheirDamageCredit(t *testing.T) { + t.Chdir(t.TempDir()) + world, _ := newThreatWorld() + npc := world.characters[1000000] + world.handleCombat(world.clients[1], attackPacket(1, npc.id)[20:]) + world.advanceCombat(world.characters[1].nextAttack) + world.handleCombat(world.clients[1], stopFightPacket(1)[20:]) + world.handleCombat(world.clients[2], attackPacket(2, npc.id)[20:]) + world.advanceCombat(world.characters[2].nextAttack) + destination := world.characters[1].userData() + destination.Playfield = 705 + + err := world.updateUser(destination) + + if err != nil || npc.fighting != 2 || len(npc.threat) != 1 || npc.threat[2] != 5 || + npc.damageContributors[damageContributor{player: 1}] != 5 || npc.damageContributors[damageContributor{player: 2}] != 5 { + t.Fatal("zoning retained threat or removed lifetime reward credit", err, npc.threat) + } +} + +func TestNPCDisconnectRemovesThreatAndRetargetsTheRemainingConnection(t *testing.T) { + world, _ := newThreatWorld() + delete(world.clients, 1) + peer := connectZoningClient(t, world, false) + world.mutex.Lock() + npc := world.characters[1000000] + npc.threat = map[uint32]int64{1: 10, 2: 5} + npc.damageContributors = map[damageContributor]uint32{{player: 1}: 10, {player: 2}: 5} + npc.fighting, npc.nextAttack = 1, time.Now().Add(10*time.Second) + clock := npc.nextAttack + world.fighting[npc.id] = npc + world.mutex.Unlock() + + peer.Close() + deadline := time.Now().Add(time.Second) + for { + world.mutex.Lock() + disconnected := world.clients[1] == nil + world.mutex.Unlock() + if disconnected || time.Now().After(deadline) { + break + } + time.Sleep(time.Millisecond) + } + + world.mutex.Lock() + defer world.mutex.Unlock() + if world.clients[1] != nil || npc.fighting != 2 || npc.nextAttack != clock || len(npc.threat) != 1 || npc.threat[2] != 5 || + npc.damageContributors[damageContributor{player: 1}] != 10 || npc.damageContributors[damageContributor{player: 2}] != 5 { + t.Fatal("actual disconnect retained threat, lost credit, or failed to retarget with its existing clock", npc.threat) + } +} diff --git a/server/state.go b/server/state.go @@ -48,6 +48,7 @@ type character struct { damageContributors map[damageContributor]uint32 leadingContributor damageContributor + threat map[uint32]int64 browserTokenHash string resurrectionTerminal uint32 diff --git a/server/testdata/hit-taunt-nanos.json b/server/testdata/hit-taunt-nanos.json @@ -0,0 +1,29 @@ +[ + {"program":26341,"crystal":26468,"quality":1,"minimum":1,"maximum":1,"damage_type":92,"taunt":59,"target_type":4,"can":0,"flags":2147516416,"nano_cost":14,"attack_delay":200,"recharge_delay":600,"range":12,"ncu":1,"actions":[{"type":3,"requirements":[{"stat":129,"value":16,"operator":2}]}],"weights":[{"type":13,"stats":[[168,0]]},{"type":12,"stats":[[129,100]]}]}, + {"program":26418,"crystal":26545,"quality":14,"minimum":1,"maximum":1,"damage_type":92,"taunt":181,"target_type":4,"can":0,"flags":2147516416,"nano_cost":58,"attack_delay":200,"recharge_delay":600,"range":12,"ncu":5,"actions":[{"type":3,"requirements":[{"stat":129,"value":74,"operator":2}]}],"weights":[{"type":12,"stats":[[129,100]]},{"type":13,"stats":[[168,0]]}]}, + {"program":26421,"crystal":26548,"quality":30,"minimum":1,"maximum":1,"damage_type":92,"taunt":50,"target_type":4,"can":0,"flags":2147516416,"nano_cost":121,"attack_delay":200,"recharge_delay":600,"range":35,"ncu":10,"actions":[{"type":3,"requirements":[{"stat":129,"value":154,"operator":2}]}],"weights":[{"type":12,"stats":[[129,100]]},{"type":13,"stats":[[168,0]]}]}, + {"program":28597,"crystal":28800,"quality":182,"minimum":1005,"maximum":2476,"damage_type":97,"taunt":2520,"target_type":1,"can":0,"flags":2147516416,"nano_cost":298,"attack_delay":384,"recharge_delay":390,"range":30,"ncu":56,"actions":[{"type":3,"requirements":[{"stat":130,"value":844,"operator":2},{"stat":368,"value":11,"operator":0},{"stat":0,"value":0,"operator":4}]}],"weights":[{"type":12,"stats":[[130,100]]},{"type":13,"stats":[[168,110]]}]}, + {"program":28613,"crystal":28816,"quality":162,"minimum":894,"maximum":1980,"damage_type":97,"taunt":1994,"target_type":1,"can":0,"flags":2147516416,"nano_cost":272,"attack_delay":430,"recharge_delay":360,"range":30,"ncu":50,"actions":[{"type":3,"requirements":[{"stat":130,"value":750,"operator":2},{"stat":368,"value":11,"operator":0},{"stat":0,"value":0,"operator":4}]}],"weights":[{"type":12,"stats":[[130,100]]},{"type":13,"stats":[[168,108]]}]}, + {"program":28866,"crystal":28917,"quality":24,"minimum":1,"maximum":1,"damage_type":92,"taunt":274,"target_type":4,"can":0,"flags":2147516416,"nano_cost":54,"attack_delay":100,"recharge_delay":500,"range":12,"ncu":8,"actions":[{"type":3,"requirements":[{"stat":129,"value":116,"operator":2},{"stat":368,"value":2,"operator":0},{"stat":0,"value":0,"operator":4}]}],"weights":[{"type":12,"stats":[[129,100]]},{"type":13,"stats":[[168,0]]}]}, + {"program":29218,"crystal":29330,"quality":90,"minimum":1,"maximum":1,"damage_type":92,"taunt":890,"target_type":4,"can":0,"flags":2147516416,"nano_cost":167,"attack_delay":100,"recharge_delay":500,"range":12,"ncu":28,"actions":[{"type":3,"requirements":[{"stat":129,"value":427,"operator":2},{"stat":368,"value":1,"operator":0},{"stat":0,"value":0,"operator":4}]}],"weights":[{"type":12,"stats":[[129,100]]},{"type":13,"stats":[[168,0]]}]}, + {"program":29228,"crystal":29340,"quality":4,"minimum":1,"maximum":1,"damage_type":92,"taunt":87,"target_type":4,"can":0,"flags":2147516416,"nano_cost":13,"attack_delay":100,"recharge_delay":500,"range":12,"ncu":2,"actions":[{"type":3,"requirements":[{"stat":129,"value":30,"operator":2},{"stat":368,"value":1,"operator":0},{"stat":0,"value":0,"operator":4}]}],"weights":[{"type":12,"stats":[[129,100]]},{"type":13,"stats":[[168,0]]}]}, + {"program":29242,"crystal":29354,"quality":152,"minimum":1,"maximum":1,"damage_type":92,"taunt":1617,"target_type":4,"can":0,"flags":2147516416,"nano_cost":301,"attack_delay":100,"recharge_delay":500,"range":12,"ncu":47,"actions":[{"type":3,"requirements":[{"stat":129,"value":705,"operator":2},{"stat":368,"value":1,"operator":0},{"stat":0,"value":0,"operator":4}]}],"weights":[{"type":12,"stats":[[129,100]]},{"type":13,"stats":[[168,0]]}]}, + {"program":45192,"crystal":45325,"quality":189,"minimum":1270,"maximum":2356,"damage_type":95,"taunt":2652,"target_type":1,"can":0,"flags":32768,"nano_cost":302,"attack_delay":387,"recharge_delay":398,"range":25,"ncu":58,"actions":[{"type":3,"requirements":[{"stat":130,"value":867,"operator":2},{"stat":368,"value":11,"operator":0},{"stat":0,"value":0,"operator":4}]}],"weights":[{"type":12,"stats":[[130,100]]},{"type":13,"stats":[[168,110]]}]}, + {"program":45213,"crystal":45328,"quality":152,"minimum":978,"maximum":2415,"damage_type":97,"taunt":2442,"target_type":1,"can":0,"flags":32768,"nano_cost":348,"attack_delay":770,"recharge_delay":338,"range":25,"ncu":47,"actions":[{"type":3,"requirements":[{"stat":130,"value":705,"operator":2},{"stat":368,"value":11,"operator":0},{"stat":0,"value":0,"operator":4}]}],"weights":[{"type":12,"stats":[[130,100]]},{"type":13,"stats":[[168,111]]}]}, + {"program":45217,"crystal":45355,"quality":165,"minimum":852,"maximum":1951,"damage_type":90,"taunt":1934,"target_type":1,"can":0,"flags":32768,"nano_cost":260,"attack_delay":376,"recharge_delay":365,"range":25,"ncu":51,"actions":[{"type":3,"requirements":[{"stat":130,"value":765,"operator":2},{"stat":368,"value":11,"operator":0},{"stat":0,"value":0,"operator":4}]}],"weights":[{"type":12,"stats":[[130,100]]},{"type":13,"stats":[[168,108]]}]}, + {"program":45233,"crystal":45373,"quality":175,"minimum":1189,"maximum":2695,"damage_type":95,"taunt":2890,"target_type":1,"can":0,"flags":32768,"nano_cost":344,"attack_delay":550,"recharge_delay":379,"range":25,"ncu":54,"actions":[{"type":3,"requirements":[{"stat":130,"value":810,"operator":2},{"stat":368,"value":11,"operator":0},{"stat":0,"value":0,"operator":4}]}],"weights":[{"type":12,"stats":[[130,100]]},{"type":13,"stats":[[168,113]]}]}, + {"program":100205,"crystal":100230,"quality":70,"minimum":1,"maximum":1,"damage_type":92,"taunt":712,"target_type":4,"can":0,"flags":32768,"nano_cost":118,"attack_delay":100,"recharge_delay":500,"range":12,"ncu":22,"actions":[{"type":3,"requirements":[{"stat":129,"value":335,"operator":2},{"stat":368,"value":1,"operator":0},{"stat":0,"value":0,"operator":4}]}],"weights":[{"type":12,"stats":[[129,100]]},{"type":13,"stats":[[168,0]]}]}, + {"program":100206,"crystal":100229,"quality":30,"minimum":1,"maximum":1,"damage_type":92,"taunt":349,"target_type":4,"can":0,"flags":32768,"nano_cost":62,"attack_delay":100,"recharge_delay":500,"range":12,"ncu":10,"actions":[{"type":3,"requirements":[{"stat":129,"value":150,"operator":2},{"stat":368,"value":1,"operator":0},{"stat":0,"value":0,"operator":4}]}],"weights":[{"type":12,"stats":[[129,100]]},{"type":13,"stats":[[168,0]]}]}, + {"program":100207,"crystal":100227,"quality":132,"minimum":1,"maximum":1,"damage_type":92,"taunt":1244,"target_type":4,"can":0,"flags":32768,"nano_cost":238,"attack_delay":100,"recharge_delay":500,"range":12,"ncu":41,"actions":[{"type":3,"requirements":[{"stat":129,"value":614,"operator":2},{"stat":368,"value":1,"operator":0},{"stat":0,"value":0,"operator":4}]}],"weights":[{"type":12,"stats":[[129,100]]},{"type":13,"stats":[[168,0]]}]}, + {"program":100208,"crystal":100228,"quality":14,"minimum":1,"maximum":1,"damage_type":92,"taunt":199,"target_type":4,"can":0,"flags":32768,"nano_cost":34,"attack_delay":100,"recharge_delay":500,"range":12,"ncu":5,"actions":[{"type":3,"requirements":[{"stat":129,"value":82,"operator":2},{"stat":368,"value":1,"operator":0},{"stat":0,"value":0,"operator":4}]}],"weights":[{"type":12,"stats":[[129,100]]},{"type":13,"stats":[[168,0]]}]}, + {"program":100209,"crystal":100226,"quality":139,"minimum":1,"maximum":1,"damage_type":92,"taunt":1664,"target_type":4,"can":0,"flags":32768,"nano_cost":307,"attack_delay":100,"recharge_delay":500,"range":12,"ncu":43,"actions":[{"type":3,"requirements":[{"stat":129,"value":644,"operator":2},{"stat":368,"value":9,"operator":0},{"stat":0,"value":0,"operator":4}]}],"weights":[{"type":12,"stats":[[129,100]]},{"type":13,"stats":[[168,0]]}]}, + {"program":100210,"crystal":100222,"quality":116,"minimum":1,"maximum":1,"damage_type":92,"taunt":1123,"target_type":4,"can":0,"flags":32768,"nano_cost":216,"attack_delay":100,"recharge_delay":500,"range":12,"ncu":36,"actions":[{"type":3,"requirements":[{"stat":129,"value":546,"operator":2},{"stat":368,"value":9,"operator":0},{"stat":0,"value":0,"operator":4}]}],"weights":[{"type":12,"stats":[[129,100]]},{"type":13,"stats":[[168,0]]}]}, + {"program":100211,"crystal":100224,"quality":27,"minimum":1,"maximum":1,"damage_type":92,"taunt":339,"target_type":4,"can":0,"flags":32768,"nano_cost":61,"attack_delay":100,"recharge_delay":500,"range":12,"ncu":9,"actions":[{"type":3,"requirements":[{"stat":129,"value":136,"operator":2},{"stat":368,"value":9,"operator":0},{"stat":0,"value":0,"operator":4}]}],"weights":[{"type":12,"stats":[[129,100]]},{"type":13,"stats":[[168,0]]}]}, + {"program":100212,"crystal":100225,"quality":57,"minimum":1,"maximum":1,"damage_type":92,"taunt":638,"target_type":4,"can":0,"flags":32768,"nano_cost":105,"attack_delay":100,"recharge_delay":500,"range":12,"ncu":18,"actions":[{"type":3,"requirements":[{"stat":129,"value":267,"operator":2},{"stat":368,"value":9,"operator":0},{"stat":0,"value":0,"operator":4}]}],"weights":[{"type":12,"stats":[[129,100]]},{"type":13,"stats":[[168,0]]}]}, + {"program":100213,"crystal":100223,"quality":7,"minimum":1,"maximum":1,"damage_type":92,"taunt":125,"target_type":4,"can":0,"flags":32768,"nano_cost":20,"attack_delay":100,"recharge_delay":500,"range":12,"ncu":3,"actions":[{"type":3,"requirements":[{"stat":129,"value":45,"operator":2},{"stat":368,"value":9,"operator":0},{"stat":0,"value":0,"operator":4}]}],"weights":[{"type":12,"stats":[[129,100]]},{"type":13,"stats":[[168,0]]}]}, + {"program":100214,"crystal":100218,"quality":162,"minimum":1,"maximum":1,"damage_type":92,"taunt":1767,"target_type":4,"can":0,"flags":32768,"nano_cost":350,"attack_delay":100,"recharge_delay":500,"range":12,"ncu":50,"actions":[{"type":3,"requirements":[{"stat":129,"value":751,"operator":2},{"stat":368,"value":2,"operator":0},{"stat":0,"value":0,"operator":4}]}],"weights":[{"type":12,"stats":[[129,100]]},{"type":13,"stats":[[168,0]]}]}, + {"program":100215,"crystal":100221,"quality":86,"minimum":1,"maximum":1,"damage_type":92,"taunt":843,"target_type":4,"can":0,"flags":32768,"nano_cost":169,"attack_delay":100,"recharge_delay":500,"range":12,"ncu":27,"actions":[{"type":3,"requirements":[{"stat":129,"value":402,"operator":2},{"stat":368,"value":2,"operator":0},{"stat":0,"value":0,"operator":4}]}],"weights":[{"type":12,"stats":[[129,100]]},{"type":13,"stats":[[168,0]]}]}, + {"program":100216,"crystal":100219,"quality":136,"minimum":1,"maximum":1,"damage_type":92,"taunt":1291,"target_type":4,"can":0,"flags":32768,"nano_cost":272,"attack_delay":100,"recharge_delay":500,"range":12,"ncu":42,"actions":[{"type":3,"requirements":[{"stat":129,"value":625,"operator":2},{"stat":368,"value":2,"operator":0},{"stat":0,"value":0,"operator":4}]}],"weights":[{"type":12,"stats":[[129,100]]},{"type":13,"stats":[[168,0]]}]}, + {"program":100217,"crystal":100220,"quality":53,"minimum":1,"maximum":1,"damage_type":92,"taunt":582,"target_type":4,"can":0,"flags":32768,"nano_cost":107,"attack_delay":100,"recharge_delay":500,"range":12,"ncu":17,"actions":[{"type":3,"requirements":[{"stat":129,"value":261,"operator":2},{"stat":368,"value":2,"operator":0},{"stat":0,"value":0,"operator":4}]}],"weights":[{"type":12,"stats":[[129,100]]},{"type":13,"stats":[[168,0]]}]}, + {"program":201935,"crystal":201936,"quality":200,"minimum":3105,"maximum":5970,"damage_type":94,"taunt":-3000,"target_type":1,"can":1,"flags":32768,"nano_cost":752,"attack_delay":900,"recharge_delay":250,"range":21,"ncu":50,"actions":[{"type":3,"requirements":[{"stat":60,"value":11,"operator":0},{"stat":54,"value":194,"operator":2},{"stat":0,"value":0,"operator":4},{"stat":130,"value":1046,"operator":2},{"stat":0,"value":0,"operator":4}]}],"weights":[{"type":12,"stats":[[130,100]]},{"type":13,"stats":[[168,101]]}]} +]