Repository navigation
Expand file tree
/
Copy pathnextaction.lua
More file actions
1503 lines (1447 loc) · 70.6 KB
/
Copy pathnextaction.lua
File metadata and controls
1503 lines (1447 loc) · 70.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
--=========================================================================================
-- Next action guide (paladin seal twisting): pure decision engine, no WoW API.
--
-- Ported from the archived builds under docs/swedge/SwedgeTimer_TBC (byte-identical to
-- the *_Forever copy); reference lines:
-- * rotation.lua:37-70 sequences / descriptions / display_names tables
-- * rotation.lua:91-111 get_gcd_duration (cast time -> GCD, clamped [1.0, 1.5])
-- * rotation.lua:114-119 get_haste_amount (1.5 - gcd)
-- * rotation.lua:140-172 calculate_rotation thresholds, in priority order
-- * nextaction.lua:146-155 get_seal_remaining
-- * nextaction.lua:162-177 get_active_seal (Command freshness rule)
-- * nextaction.lua:186-465 compute(): landmarks 208-214, seal=="sob" branches
-- 240-261, GCD-busy table 262-324, GCD-ready table 325-363, prediction_hold
-- floor 366-368, filler suppression 370-373, CS override 375-396, filler
-- selection 398-429, judgement cue 434-456.
--
-- This module is deliberately PURE (no WoW API calls, no addon-owned state) so it can
-- be unit-tested offline with the harness in tests/nextaction_state.lua. The WoW-facing
-- call sites gather the live values (swing timer, GCD, cooldowns, seals, mana, target)
-- and call into these helpers rather than re-implementing the rules.
--
-- evaluate(inputs, out) contract:
-- * inputs are plain numbers/strings, all optional (missing ones fall back to the
-- archived defaults). Frozen input names: speed, swing_remaining, G, gcd_remaining,
-- twist_window, reaction, cs_remaining, judge_remaining, seal, cs_delay_max,
-- waiting_judgement, melee_count, mana_pct, creature_type, filler_remaining.
-- * out is caller-owned and reused across ticks; evaluate writes the result fields
-- into it and returns it — no per-call result table is allocated.
-- * out fields: action ("soc"|"sob"|"twist"|"cs"), hold, riding, judge_call,
-- filler_kind (nil|"consecration"|"exorcism"|"how", the last Era-only),
-- prediction_hold, waiting_judgement, inputs_unknown.
-- * out advisory fields (all false unless the rule below fires; the guide
-- frame ignores unknown keys, so they are display-inert until a UI lane
-- consumes them): stopattack (the sim would StopAttack before this cue),
-- prepull_ready (prepull window open, seal down), seal_maintenance
-- (FCFS SoD only: primary seal needs its reseal), rank1_advice (SoC
-- Rank 1 is known: twist on rank 1), hard_wait (strictSequence: wait the
-- swing out, do not fill).
-- * inputs.waiting_judgement is the current judgement-cue latch; out.waiting_judgement
-- is the updated latch — the caller feeds it back in on the next tick.
-- * inputs.inputs_unknown (optional bool, M6): the caller's own "the core timing
-- reads are unusable" flag - the provider sets it when the swing fields cannot be
-- trusted. The engine threads it into out.inputs_unknown unchanged; the guide UI
-- renders "…" instead of an action while it is true. The engine never derives it
-- itself: an all-defaults input set is indistinguishable from a legitimate one here.
--
-- Optional inputs beyond the frozen set (each falls back to the archived db default, so
-- callers that omit them get the archive's behaviour):
-- * gcd_before_swing — archived st.bar.get_gcd_time_before_swing(), i.e.
-- G plus the configured GCD padding; default G.
-- * mana_exorcism_threshold — db.nextaction_filler_mana_exorcism or 30.
-- * mana_consecration_threshold — db.nextaction_filler_mana_consecration or 35.
-- Sim-sourced optional inputs (each defaults to the archived behaviour when
-- absent; the live paladin provider sets the ones its client can answer):
-- * cs_hold_remaining — pull-phase CS hold, seconds left (TBC sim
-- "Delay Major CDs" 11 s; TBC_PULL_CS_HOLD_SECONDS). While positive the
-- CS override never fires. nil/<=0 = archived.
-- * auto_age_seconds — seconds since the last real auto landed
-- (nil = unknown = archived). Feeds the two recency rules below.
-- * reseal_auto_guard_seconds — TBC reseal guard (TBC sim: no reseal
-- within TBC_RESEAL_AUTO_GUARD_SECONDS of the last auto). When set, a
-- fresh auto degrades the immediate reseal to a ride.
-- * twist_mana_threshold — mana-sustain governor plug-in (percent;
-- unset = off = archived). When set and mana sits below it, the
-- immediate reseal degrades to a ride instead of spending the mana.
-- * how_cast_seconds — Hammer of Wrath cast time, seconds
-- (nil = unknown = archived hp-only rule). An instant (<= 0) HoW cues
-- regardless of target health (Forever sim shape).
-- * fight_remaining_pct — fight remaining, percent (nil = unknown =
-- archived). FCFS SoD only: below SOD_EXECUTE_FIGHT_PCT the HoW execute
-- fires without the hp read (SoD APL execute burn).
-- * hor_remaining — Hand of Reckoning cooldown remaining,
-- seconds (nil or the 999 sentinel = unknown on this client). FCFS Wrath
-- only: the WotLK APL's TOP row (i=1, 67485). The provider feeds it only
-- when the client's own spell book knows the spell, so a build without the
-- talent never sees the prompt (the APL UTILITY layer, bench/
-- rotation_gap_vs_apl_2026-10-20.md §6.2).
-- * how_wrath_remaining — Hammer of Wrath (WotLK 48806) cooldown
-- remaining, seconds (nil = unknown = withheld). FCFS Wrath only: the
-- WotLK APL's second row (i=2). The client's sim gates the cast on the
-- execute phase (sim wowsims/wotlk sim/paladin/hammer_of_wrath.go:31-32
-- ExtraCastCondition: sim.IsExecutePhase20()), so the arm asks for the
-- spell only below 20 % target health.
-- Follow-up optional inputs (each nil/false = archived; the live paladin
-- provider feeds the ones its client can answer, the rest stay filed):
-- * time_to_pull_seconds — pull countdown, seconds (nil = unknown =
-- archived). The classic APL prepulls the primary seal at -1.5 s; the pull
-- timer itself lives outside this module (filed: main.lua).
-- * seal_remaining_seconds — primary-seal remaining, seconds (nil =
-- unknown = archived). FCFS SoD only: below SEAL_MAINTAIN_RESEAL_SECONDS
-- the sim refreshes Judge above the damage order (filed: seal-aura source
-- per SoD build + guide slot + nextaction_ui).
-- * soc_rank1_known — SoC Rank 1 (20375) in the book (nil/false =
-- archived). The min/max consensus twists on rank 1; the reader is the
-- live spell book (filed: guide slot + option).
-- * strict_sequence — SoD strictSequence wait (nil/false =
-- archived). True on SoD twist builds (rune-gated): a held twist waits the
-- swing out instead of filling (filed: nextaction_ui hard-wait render).
-- Era-correctness opt-ins (sourced Era 1.15.9 ret; absent means the archived
-- behaviour, so old callers are unaffected — the live paladin provider sets them):
-- * cs_known — false when Crusader Strike is unknown on this
-- client (Era-base: the spell does not exist). Default true. False disables
-- the CS override entirely and resolves every no-seal reseal tiebreak to
-- Command (there is no CS timing to wait for).
-- * era — true on the Era family. Default false. Era lifts
-- the Consecration AoE-only gate (single-target is mana permitting on Era),
-- enables the Hammer of Wrath execute cue below, and costs the
-- judge-feasibility reseal as a single GCD (Judge plus the one SoR->SoC
-- reseal, not the TBC double reseal).
-- * target_health_pct — target health percent (0-100), or nil when
-- unknown. Only read on Era.
-- * how_remaining — Hammer of Wrath cooldown remaining (seconds);
-- nil (or the 999 sentinel) means unknown on this client, like
-- filler_remaining. Only read on Era.
-- Out extension: filler_kind gains "how" (Era execute, hp < 20% with HoW ready).
-- It flows through the provider mapping untouched; the shipped 7-slot frame has
-- no HoW icon, so the frame drops the unknown key without error until a slot
-- exists for it.
-- TBC-correctness opt-ins (sourced TBC 2.5.6 ret; absent means the archived
-- behaviour, so old callers are unaffected — the live paladin provider sets them):
-- * judge_require_fit — TBC judge-feasibility gate (default false =
-- the archived cue); true requires Judgement's GCD plus the SoB->SoC double
-- reseal to fit before the next swing's twist window.
-- * jotc_remaining — target Judgement-of-the-Crusader seconds left
-- (default nil = untracked = the archived Blood-only cue); an expiring JotC
-- outranks judging Blood.
-- * target_count — enemies in Consecration range (default nil =
-- unknown = the archived suggestion); 1 or 0 withholds Consecration, which
-- is AoE-only on TBC single-target.
-- Forever opt-in (UNCONFIRMED beta behaviour; docs/research/forever_beta.md):
-- * forever — true on the Forever family. Default false
-- (archived). Twist of Light alternates Seal of Command / Seal of
-- Righteousness after auto attacks (the provider feeds SoR into the
-- twist-seal position, reusing these landmarks; the optimal window is
-- still unknown per the beta guides, so the 0.4 s landmarks stand),
-- Judgement no longer consumes seals (the fit gate costs Judgement's own
-- GCD only, no reseal), Consecration is a single-target filler (the beta
-- Ret ST lists it), and Hammer of Wrath cues below 20% (beta Ret ST).
-- * holy_strike_known — Holy Strike (10333) in the player's book
-- on Forever (default nil = unknown = the archived behaviour). The id is
-- WEB-CONFIRMED but CLIENT-UNCONFIRMED (bench/ids_research_2026-10-19.md
-- §2), and the class resolves it by NAME before the book is asked, so a
-- wrong id leaves this unknown rather than answering. PLUG-IN POINT: the
-- engine does not read it yet - the frozen ten guide slots have no Holy
-- Strike slot, and a slot-budget ruling is owed before one is added - so
-- nothing prompts on it yet.
--=========================================================================================
-- Retail (12.x) inertness: st.family == "RETAIL" short-circuits evaluate to the
-- empty display shape before any branch below. The inert stand-in never reports a
-- swing, but seals, cooldowns, mana and creature type all answer on Retail, so the
-- tree below would prompt (soc reseals, the CS override, fillers, the judgement
-- cue) with no swing at all. Every other family - including Forever, which swings
-- - runs the archived tree unchanged; a nil family (offline callers that predate
-- it) keeps the old behaviour too.
--=========================================================================================
local _, st = ...
st.nextaction = st.nextaction or {}
-- Spell ids (archived nextaction.lua:35-42; SOC/SOB were the texture ids).
st.nextaction.CS_SPELL_ID = 35395 -- Crusader Strike
st.nextaction.JUDGEMENT_SPELL_ID = 20271 -- Judgement
st.nextaction.CONSECRATION_SPELL_ID = 26573
st.nextaction.EXORCISM_SPELL_ID = 879
st.nextaction.SOC_ID = 20375 -- Seal of Command
st.nextaction.SOB_ID = 31892 -- Seal of Blood / Martyr
-- Rotation definitions (archived rotation.lua:37-70), ported verbatim; the eight keys
-- are also the priority order of calculate_rotation below.
st.nextaction.sequences = {
["1/2"] = { "cs", "twist" },
["2/3"] = { "cs", "twist", "twist" },
["2/2/5"] = { "cs", "twist", "cs_late", "blood_auto", "twist" },
["2/4"] = { "cs", "twist", "blood_auto", "twist" },
["1/3"] = { "cs", "blood_auto", "twist" },
["2/5_blood"] = { "cs", "blood_auto", "twist", "blood_auto", "twist" },
["2/5_command"] = { "cs", "cmd_auto", "twist", "cmd_auto", "twist" },
["2007"] = { "blood_auto", "cs" },
}
st.nextaction.descriptions = {
["1/2"] = "CS, Twist",
["2/3"] = "CS, Twist, Twist",
["2/2/5"] = "CS, Twist, CS (late), Auto, Twist",
["2/4"] = "CS, Twist, Auto, Twist",
["1/3"] = "CS, Auto, Twist",
["2/5_blood"] = "CS, Auto, Twist, Auto, Twist",
["2/5_command"] = "CS, Cmd Auto, Twist, Cmd Auto, Twist",
["2007"] = "Ride Blood & CS",
}
st.nextaction.display_names = {
["1/2"] = "1/2",
["2/3"] = "2/3",
["2/2/5"] = "2/2/5",
["2/4"] = "2/4",
["1/3"] = "1/3",
["2/5_blood"] = "2/5 Blood",
["2/5_command"] = "2/5 Command",
["2007"] = "2007",
["prot"] = "Protection",
}
-- UnitCreatureType returns localized strings; these are the Undead/Demon names in all
-- client locales the archived build shipped (archived nextaction.lua:51-61). Unknown
-- locales fall back to the Consecration suggestion.
st.nextaction.exorcism_target_types = {
["Undead"] = true,
["Demon"] = true,
["Untoter"] = true,
["Dämon"] = true,
["Mort-vivant"] = true,
["Démon"] = true,
["No-muerto"] = true,
["Demonio"] = true,
["Morto-vivo"] = true,
["Demônio"] = true,
["Нежить"] = true,
["Демон"] = true,
["언데드"] = true,
["악마"] = true,
["亡灵"] = true,
["恶魔"] = true,
["不死族"] = true,
["惡魔"] = true,
}
-- Pure: GCD duration from the base cast time in seconds, clamped to [1.0, 1.5]
-- (archived rotation.lua:91-111, where the cast time came from the flash-heal spell;
-- nil -> base 1.5).
function st.nextaction.get_gcd_duration(base_cast_seconds)
local gcd = 1.5
if type(base_cast_seconds) == "number" then
gcd = base_cast_seconds
end
if gcd >= 1.5 then
gcd = 1.5
elseif gcd < 1.0 then
gcd = 1.0
end
return gcd
end
-- Pure: haste amount = base GCD (1.5) minus the current GCD, floored at 0
-- (archived rotation.lua:114-119).
function st.nextaction.get_haste_amount(gcd)
if type(gcd) ~= "number" then
gcd = 1.5
end
local haste = 1.5 - gcd
if haste < 0 then
haste = 0
end
return haste
end
-- Pure: rotation selection from attack speed (seconds per swing) and GCD. Thresholds
-- and their order are verbatim from the archived rotation.lua:140-172; attack speed
-- defaults to 3.0 and the GCD to 1.5. Returns nil when no threshold matches (the
-- archive's cache and live reads are dropped here).
function st.nextaction.calculate_rotation(attack_speed, gcd)
if type(attack_speed) ~= "number" then
attack_speed = 3.0
end
if type(gcd) ~= "number" then
gcd = 1.5
end
local haste = st.nextaction.get_haste_amount(gcd)
local rotation = nil
if attack_speed > 2.6 then
-- Slowest weapons: simple 1 twist per CS cycle
rotation = "1/2"
elseif attack_speed >= math.max(1.9, 2 * gcd - 0.35) and haste > 0.1 then
-- Fast enough with high haste: 2 twists per CS cycle
rotation = "2/3"
elseif attack_speed >= 2.4 or (attack_speed >= 2.3 and haste > 0.05) then
-- Medium speed: complex pattern with late CS
rotation = "2/2/5"
elseif attack_speed >= math.max(1.5, 1.5 * gcd + 0.05) and haste > 0.1 then
-- Fast with high haste: 2 twists in 4 actions
rotation = "2/4"
elseif attack_speed >= 1.9 then
-- Standard rotation: 1 twist per 3 actions
rotation = "1/3"
elseif attack_speed >= (gcd + 0.07) then
-- Very fast: ride Blood between twists
rotation = "2/5_blood"
elseif attack_speed > 1.0 then
-- Extremely fast: ride Command for procs
rotation = "2/5_command"
elseif attack_speed >= 0.01 then
-- Ludicrous speed (full Bloodlust + haste): just ride Blood and CS
rotation = "2007"
end
return rotation
end
-- Pure: active seal for the decision tree: "sob", "soc", or "none" (archived
-- nextaction.lua:146-177). Blood wins during the dual-seal twist window (the correct
-- next step after twisting is to re-seal Command). Command only counts with >1 s
-- remaining — the freshness rule: a Command seal whose tracked expiry is nil reads as
-- fresh, an expiry at or inside 1 s reads as "none" (the archive treated practice-mode
-- seals as never expiring; that is the caller's concern here).
function st.nextaction.get_seal_state(has_soc, has_sob, soc_remaining_seconds)
if has_sob then
return "sob"
end
if has_soc then
local remaining = soc_remaining_seconds
if remaining == nil or remaining > 1 then
return "soc"
end
end
return "none"
end
-- Pure: TBC twist-weapon suitability label for a weapon speed in seconds per
-- swing. "optimal" at/above the 3.8 best-proc-rate speed, "slow" down to the
-- 3.0 twist floor, "fast" below it (twists poorly). Non-numbers default to
-- 3.0 like calculate_rotation. Label only: rotation selection is untouched.
function st.nextaction.classify_twist_weapon(attack_speed)
if type(attack_speed) ~= "number" then
attack_speed = 3.0
end
if attack_speed >= st.nextaction.TBC_TWIST_BEST_SPEED then
return "optimal"
elseif attack_speed >= st.nextaction.TBC_TWIST_MIN_SPEED then
return "slow"
end
return "fast"
end
-- Pure: the swing's landmark name from its three relative offsets, the ladder the
-- decision tree branches on. Module scope on purpose: evaluate() runs on the 20 Hz hot
-- path and must not allocate a closure per call.
local function where_is_swing_at(rel_div, rel_gap, rel_swing)
if rel_div < 0 and rel_gap < 0 and rel_swing < 0 then
return "swing ready"
elseif rel_div > 0 then
return "before div"
elseif rel_gap < 0 then
return "in twist"
elseif rel_swing > 0 then
return "after div"
else
return "swing ready"
end
end
-- TBC twist-weapon suitability labels (sourced TBC 2.5.6 ret;
-- docs/research/tbc_minmax.md): slow weapons (>= 3.0 s) twist; 3.8 is the
-- highest-SoC-proc-rate speed (~44.3% [uncertain] community parse data),
-- 3.6 the common raid speed (~42%). The rotation thresholds above already
-- cadence every speed, so classify_twist_weapon only labels for callers.
st.nextaction.TBC_TWIST_MIN_SPEED = 3.0
st.nextaction.TBC_TWIST_BEST_SPEED = 3.8
-- TBC Seal of Command proc delay (~0.5 s after the white hit; the 0.4 s twist
-- window sits inside it). Documentary: the landmarks below take the window as
-- an input, so this is not wired into the math.
st.nextaction.TBC_SOC_PROC_DELAY = 0.5
-- TBC judge constants (sourced TBC 2.5.6 ret; plain constants, no new options).
-- TBC_JUDGE_SEAL_GCDS is Judgement's own GCD plus the SoB->SoC double reseal
-- that judging consumes. JOTC_REFRESH_LEAD is how far ahead of JotC expiry the
-- Crusader-priority cue fires: JotC lasts 10 s
-- (LibClassicDurations/classAbilities.lua line 837, "Judgement of the
-- Crusader"), so this lead leaves one Judge GCD plus reaction before it falls
-- off. Confirm the lead in-client; the engine treats a nil JotC reading as
-- untracked (archived Blood-only cue).
local TBC_JUDGE_SEAL_GCDS = 3
local JOTC_REFRESH_LEAD = 3
-- Era constants (sourced Era 1.15.9 ret). ERA_JUDGE_SEAL_GCDS is Judgement's
-- own GCD plus the single SoR->SoC reseal that judging consumes on Era (the
-- TBC cost above carries the SoB->SoC double reseal). ERA_HOW_HEALTH_PCT is
-- the Hammer of Wrath execute window, strict: HoW is unusable at 20%+.
local ERA_JUDGE_SEAL_GCDS = 2
local ERA_HOW_HEALTH_PCT = 20
-- FOREVER_JUDGE_SEAL_GCDS is Judgement's own GCD alone: on the Forever family
-- Judgement no longer consumes seals (docs/research/forever_beta.md,
-- UNCONFIRMED beta), so judging costs no reseal. TBC pays the SoB->SoC double
-- reseal above, Era the single SoR->SoC reseal.
local FOREVER_JUDGE_SEAL_GCDS = 1
-- Sim-sourced pull/recency constants (bench/paladin_rotation_audit_2026-10-19.md).
-- TBC_PULL_CS_HOLD_SECONDS is the TBC APL's "Delay Major CDs" variable: major
-- cooldowns hold 11 s at pull, so the CS override suppresses that long. The
-- provider owns the combat-start clock and passes the remainder; the engine
-- only honours a positive remainder.
st.nextaction.TBC_PULL_CS_HOLD_SECONDS = 11
-- TBC_RESEAL_AUTO_GUARD_SECONDS is the TBC APL's reseal age guard: no reseal
-- within 0.5 s of the last auto. The provider passes it on the TBC twist path
-- only (nil elsewhere = archived); the age itself rides auto_age_seconds.
st.nextaction.TBC_RESEAL_AUTO_GUARD_SECONDS = 0.5
-- FOREVER_HOW_AUTO_WINDOW is the Forever sim's post-auto HoW window: HoW cues
-- when its cast time is 0 or within 0.2 s after the last auto (an
-- instant-cast/proc window, not an execute threshold).
st.nextaction.FOREVER_HOW_AUTO_WINDOW = 0.2
-- SOD_EXECUTE_FIGHT_PCT is the SoD APL execute burn: below 10% fight
-- remaining HoW spams without the hp read (FCFS SoD only).
st.nextaction.SOD_EXECUTE_FIGHT_PCT = 10
-- PREPULL_SEAL_LEAD_SECONDS is the classic APL prepull: the primary seal goes
-- up 1.5 s before the pull. The engine only reports the window (prepull_ready
-- below); which seal is family-specific and stays filed with the pull timer.
st.nextaction.PREPULL_SEAL_LEAD_SECONDS = 1.5
-- SEAL_MAINTAIN_RESEAL_SECONDS is the classic APL reseal freshness line (the
-- same <1 s the get_seal_state freshness rule already uses): a primary seal
-- inside it is maintained above the damage order on FCFS SoD.
st.nextaction.SEAL_MAINTAIN_RESEAL_SECONDS = 1
-- SoD variant reseal/maintenance constants (bench/sod_paladin_variants_2026-10-19.md
-- §3-§6, all six p8 APLs fetched in-lane; in-client behaviour UNCONFIRMED):
-- * SOD_STACK_SEAL_RESEAL_SECONDS: p8-stack independent refreshes (SoC <=1 s,
-- SoM <=1 s, two timers, §3).
-- * SOD_SHOCK_SEAL_RESEAL_SECONDS: shockadin seal/Judge maintenance at 1.5 s
-- (wider than Exodin's 1 s, §4).
-- * SOD_WRATH_RESEAL_SECONDS: p8-wrath reseal <=0.5 s (tightest, §6).
-- * SOD_WRATH_CONS_FALLBACK_SECONDS: p8-wrath Cons filler ONLY when DS/CS/Exo
-- all >1.5 s out (or stacks <3, §6).
-- * SOD_TEMPLAR_WAIT_SECONDS: p8-wrath Templar (1226464 <=1 s at 3 stacks)
-- wait-for-DS rule (§6); shockadin Templar-stack (1240574 <=1.5 s at
-- 3 stacks, §4) reuses its own 1.5 s maintenance line below.
st.nextaction.SOD_STACK_SEAL_RESEAL_SECONDS = 1
st.nextaction.SOD_SHOCK_SEAL_RESEAL_SECONDS = 1.5
st.nextaction.SOD_WRATH_RESEAL_SECONDS = 0.5
st.nextaction.SOD_WRATH_CONS_FALLBACK_SECONDS = 1.5
st.nextaction.SOD_TEMPLAR_WAIT_SECONDS = 1
-- Bloodlust / Heroism override for the twist window (sourced TBC 2.5.6 ret;
-- bench/verify_bank.md P3 row): under a haste raid buff every action is busy
-- sooner, so the twist window the caller feeds the landmarks must shrink. The
-- scale is a plain constant (no option); the caller decides whether to apply
-- it (the paladin gather gates on its own option and on the live aura scan).
-- apply_lust_window(window_seconds, lust_active) is pure: without an active
-- buff the window passes through untouched (nil stays nil); with one it is
-- scaled by LUST_TWIST_WINDOW_SCALE and floored at 0.
st.nextaction.LUST_TWIST_WINDOW_SCALE = 0.6
function st.nextaction.apply_lust_window(window_seconds, lust_active)
if type(window_seconds) ~= "number" then
return window_seconds
end
if lust_active ~= true then
return window_seconds
end
local scaled = window_seconds * st.nextaction.LUST_TWIST_WINDOW_SCALE
if scaled < 0 then
return 0
end
return scaled
end
-- Pure: one engine tick (archived nextaction.lua:186-465, compute() minus
-- practice/editmode/UI). Reads `inputs`, writes into the caller-owned `out` table and
-- returns it. See the module header for the input/output contract.
function st.nextaction.evaluate(inputs, out)
inputs = inputs or {}
if type(out) ~= "table" then
out = {}
end
if st.family == "RETAIL" then
-- Retail (12.x): no live swing exists (see the header), so the tree
-- prompts nothing - no action, no ride, no filler, no judgement cue.
out.action = nil
out.hold = false
out.riding = false
out.judge_call = false
out.filler_kind = nil
out.prediction_hold = 0
out.waiting_judgement = false
out.inputs_unknown = true
out.stopattack = false
out.prepull_ready = false
out.seal_maintenance = false
out.rank1_advice = false
out.hard_wait = false
return out
end
if inputs.forever_guide == true or st.family == "FOREVER" or inputs.forever == true then
if st.forever_guide and st.forever_guide.evaluate then
return st.forever_guide.evaluate(inputs.class or "PALADIN", inputs.spec or inputs.fcfs_mode, inputs, out)
end
end
-- M6: the caller's explicit "core inputs unusable" bit is threaded through
-- untouched; the UI renders "…" instead of advice while it is set. The engine
-- itself only reports what the caller declared - the provider owns the reads.
out.inputs_unknown = inputs.inputs_unknown == true
local speed = inputs.speed or 3.0
local swing_remaining = inputs.swing_remaining or 0
local G = inputs.G or 1.5
local gcd_remaining = inputs.gcd_remaining or 0
if gcd_remaining < 0 then
-- The archive only ever used a positive running GCD; a negative timer is idle.
gcd_remaining = 0
end
local twist_window = inputs.twist_window or 0.4
local reaction = inputs.reaction or 0.1
-- TBC default: researched CS delay is under 1 s; the archived 1.7 s
-- over-delays CS and bleeds twists. CONFLICT: Wrath wants ~0 (no twist to
-- protect) — one default cannot serve both families; revisit with a family
-- branch if the guide ever targets Wrath FCFS (out of scope). The option
-- range in option_tables.lua is unchanged.
local cs_delay_max = inputs.cs_delay_max or 0.9
local melee_count = inputs.melee_count or 0
local mana_pct = inputs.mana_pct or 0
local creature_type = inputs.creature_type
local seal = inputs.seal or "none"
local cs_remaining = inputs.cs_remaining or 0
local judge_remaining = inputs.judge_remaining or 0
-- Era opt-ins (header contract): cs_known defaults to true (archived), era
-- defaults to false (archived). Every branch below is byte-identical unless
-- the caller sets them.
local cs_known = inputs.cs_known ~= false
local era_mode = inputs.era == true
-- Forever opt-in (header contract): defaults to false (archived). Every
-- branch below is byte-identical unless the caller sets it.
local forever_mode = inputs.forever == true
-- Swing recency (header contract): seconds since the last real auto
-- landed, or nil when the caller cannot time it (unknown = archived
-- everywhere below).
local auto_age = inputs.auto_age_seconds
if type(auto_age) ~= "number" or auto_age ~= auto_age then
auto_age = nil
end
-- Time from now until each landmark, mirroring the archive's nextSwing / divWhen /
-- twistGap and their next-swing equivalents (208-214). "div" is the last moment a
-- seal GCD can start and still finish before the twist window opens.
local rel_swing = swing_remaining - reaction / 2
local rel_div = swing_remaining - twist_window - G - reaction / 2
local rel_gap = swing_remaining - twist_window - reaction / 4
local rel_div2 = swing_remaining + speed - twist_window - G
local rel_gap2 = swing_remaining + speed - twist_window
local prediction_land = gcd_remaining + G
local action = out.action -- seeded like the archive's last action; every branch overwrites it
local hold = false
local filler = false
local riding = false
local prediction_hold = 10
-- twist_now marks the immediate (cast-now, inside the window) twist cue:
-- the GCD-busy in-gap and GCD-ready in-twist branches below. It feeds the
-- stopattack advisory at the end (the sim StopAttacks before a twist or a
-- judge that lands inside the window).
local twist_now = false
local waiting_judgement = inputs.waiting_judgement or false
if seal == "sob" then
-- Blood is up: decide directly from the swing timer whether a twist for THIS
-- swing still fits (reseal Command) or whether the swing lands as a blood auto
-- (ride it). The reseal deadline is the bar's own GCD marker: Command's GCD must
-- free before the swing lands so Blood can be recast inside the twist window.
action = "soc"
local reseal_deadline = (inputs.gcd_before_swing or G) + reaction
-- TBC reseal age guard: no reseal within reseal_auto_guard_seconds of
-- the last auto (nil guard or unknowable age = archived). Mana
-- governor plug-in: below twist_mana_threshold the reseal's mana is
-- kept and the swing rides instead (unset = off = archived).
local reseal_guard = inputs.reseal_auto_guard_seconds
if type(reseal_guard) ~= "number" or reseal_guard ~= reseal_guard then
reseal_guard = nil
end
local auto_fresh = auto_age ~= nil and reseal_guard ~= nil
and auto_age < reseal_guard
local mana_throttle = type(inputs.twist_mana_threshold) == "number"
and mana_pct < inputs.twist_mana_threshold
if (swing_remaining - gcd_remaining) > reseal_deadline
and not auto_fresh and not mana_throttle then
-- Reseal now (or queue it for the end of the running GCD)
prediction_hold = reaction + math.max(rel_gap, 0)
elseif rel_gap > 0 then
-- Blood auto: ride the seal, resealing only once the twist window opens
-- (a reseal inside the window preserves the blood swing)
hold = true
riding = true
filler = true
prediction_hold = reaction + math.max(prediction_land, rel_gap2)
else
-- Window open: resealing now preserves the blood swing
prediction_hold = reaction + rel_gap2
end
elseif gcd_remaining > 0 then
-- GCD busy: decide based on when it frees relative to the swing landmarks
local check = gcd_remaining
if rel_div >= check then
-- GCD frees before div
if seal ~= "soc" then
action = "soc"
prediction_hold = reaction + rel_gap
else
action = "twist"
hold = true
filler = true
prediction_hold = reaction + rel_gap
end
elseif check > rel_gap and check < rel_swing then
-- GCD frees inside the twist gap
if seal == "soc" then
action = "twist"
twist_now = true
prediction_hold = -1
else
if (not cs_known) or cs_remaining <= check + G then
action = "soc"
else
action = "sob"
end
prediction_hold = reaction + gcd_remaining
end
elseif check < rel_gap then
-- GCD frees after div but before the twist gap
if seal == "soc" then
action = "twist"
hold = true
prediction_hold = reaction + rel_gap
else
if (not cs_known) or cs_remaining <= check + G then
action = "soc"
else
action = "sob"
end
prediction_hold = reaction + gcd_remaining
end
elseif rel_div2 >= check then
-- GCD frees before the next swing's div
if seal ~= "soc" then
action = "soc"
prediction_hold = reaction + math.max(prediction_land, rel_gap2)
else
action = "twist"
hold = true
filler = true
prediction_hold = reaction + math.max(prediction_land, rel_gap2)
end
else
-- GCD frees after the next swing's div
if seal == "soc" then
action = "twist"
hold = true
prediction_hold = reaction + math.max(prediction_land, rel_gap2)
else
action = "soc"
prediction_hold = reaction + gcd_remaining
end
end
else
-- GCD ready: decide based on where the swing is right now
local at = where_is_swing_at(rel_div, rel_gap, rel_swing)
if at == "before div" or at == "swing ready" then
if seal ~= "soc" then
action = "soc"
prediction_hold = reaction + rel_gap
else
action = "twist"
hold = true
filler = true
prediction_hold = reaction + rel_gap
end
elseif at == "in twist" then
if seal == "soc" then
action = "twist"
twist_now = true
prediction_hold = -1
else
if (not cs_known) or cs_remaining <= G then
action = "soc"
else
action = "sob"
end
prediction_hold = 0
end
elseif at == "after div" then
if seal == "soc" then
action = "twist"
hold = true
prediction_hold = reaction + rel_gap
else
if (not cs_known) or cs_remaining <= G then
action = "soc"
else
action = "sob"
end
prediction_hold = 0
end
end
end
if prediction_hold < 0 then
prediction_hold = 0
end
-- No filler if CS comes back before the current GCD would finish (370-373)
if filler and (cs_remaining + 0.05) < G then
filler = false
end
-- Crusader Strike override: if delaying CS any longer would exceed the allowed
-- delay budget, CS becomes the next action (375-396). Era-base has no
-- Crusader Strike (cs_known false from the client's spell book), so the
-- override never fires there. Pull-phase hold (TBC sim "Delay Major CDs"):
-- while cs_hold_remaining stays positive the override stays suppressed.
if action == "twist" then
cs_delay_max = cs_delay_max + 0.1
end
local cs_when = prediction_hold + G + reaction
local cs_delay = cs_remaining - cs_when + cs_delay_max
local cs_hold_left = inputs.cs_hold_remaining
local cs_held = type(cs_hold_left) == "number" and cs_hold_left > 0
if cs_known and cs_delay <= 0 and not cs_held then
action = "cs"
hold = false
riding = false
if gcd_remaining <= 0 then
if cs_remaining > 0.1 then
hold = true
end
else
if cs_remaining + 0.1 > gcd_remaining then
hold = true
end
end
end
-- Filler suggestion (Consecration / Exorcism) when there is room in the rotation.
-- The kind is chosen first (target type + mana), then gated on that spell's own
-- cooldown being back by the time the GCD frees (398-429)
local filler_kind = nil
if filler and speed > 2.2 and melee_count > 2 then
local candidate = nil
-- Era/Forever execute first: Hammer of Wrath below 20% target health
-- outranks the rotation fillers (its window is conditional, theirs is
-- not), when its own cooldown is back by the time the GCD frees.
-- Forever reuses the window: the beta Ret ST lists Hammer of Wrath
-- below 20% (UNCONFIRMED). Anything else (unknown health,
-- unknown/unready HoW) falls through to the rotation fillers below.
local target_hp = inputs.target_health_pct
local how_remaining = inputs.how_remaining
local how_ready = how_remaining ~= nil and how_remaining < 999
and how_remaining <= gcd_remaining
-- Instant-cast HoW cues regardless of target health (Forever sim
-- shape; nil cast time = unknown = archived hp-only rule). Forever
-- post-auto recency cues inside FOREVER_HOW_AUTO_WINDOW of the last
-- auto (same sim shape; unknowable age = archived).
local how_instant = type(inputs.how_cast_seconds) == "number"
and inputs.how_cast_seconds <= 0
local how_recent_auto = forever_mode and auto_age ~= nil
and auto_age <= st.nextaction.FOREVER_HOW_AUTO_WINDOW
local exo_eligible = inputs.exo_known ~= false
and (forever_mode
or (creature_type and st.nextaction.exorcism_target_types[creature_type]))
local cons_eligible = inputs.cons_known ~= false
and (era_mode or forever_mode or inputs.target_count == nil or inputs.target_count > 1)
if (era_mode or forever_mode) and how_ready
and (how_instant or how_recent_auto
or (type(target_hp) == "number"
and target_hp < ERA_HOW_HEALTH_PCT)) then
candidate = "how"
elseif exo_eligible and mana_pct > (inputs.mana_exorcism_threshold or 30) then
candidate = "exorcism"
elseif cons_eligible and mana_pct > (inputs.mana_consecration_threshold or 35) then
candidate = "consecration"
end
if candidate then
local remaining = inputs.filler_remaining
if candidate == "how" then
-- The execute reads its own cooldown, not the mirrored filler
-- one (the gather mirrors the filler it would pick; HoW is a
-- separate spell with its own id set).
remaining = inputs.how_remaining
end
-- The archived get_filler_remaining() also returned a "known" flag; nil or a
-- 999 sentinel means the same thing here (spell not known / no reading).
local known = remaining ~= nil and remaining < 999
if known and remaining <= gcd_remaining then
filler_kind = candidate
end
end
end
-- Judgement cue. Blood path (archive): judge the active Seal of Blood before
-- twisting back to Command; suppressed while riding — judging would consume
-- the seal and ruin the blood auto, so the cue appears once the ride ends at
-- the reseal point (434-456). TBC feasibility (judge_require_fit, set by the
-- live provider): Judgement's own GCD plus the SoB->SoC double reseal (3
-- GCDs) must still fit before the next swing's twist window opens (rel_gap2)
-- — judging then costs at most one twist; otherwise the guide keeps
-- twisting. Crusader path: a JotC that needs refresh outranks Blood (judge
-- the Crusader debuff first); it bypasses the fit gate (debuff uptime beats
-- one twist) but never fires mid-ride. Twist/CS/Exorcism-vs-Undead/Demon
-- are untouched.
local judge_call = false
local jotc_remaining = inputs.jotc_remaining
local crusader_due = jotc_remaining ~= nil and jotc_remaining < JOTC_REFRESH_LEAD
if action == "soc" and seal == "sob" and not riding then
local a_rel
if where_is_swing_at(rel_div, rel_gap, rel_swing) == "before div" then
a_rel = rel_div
else
a_rel = rel_div2
end
local blood_due = judge_remaining < a_rel
if blood_due and inputs.judge_require_fit then
-- One reaction of tolerance: rel_gap2 embeds none, and the cue is
-- acted on by a human a tick later.
-- Era re-arms with a single reseal (Judgement plus the one
-- SoR->SoC reseal), not the TBC double reseal, so the fit costs
-- one GCD less. Forever re-arms with Judgement alone (no seal is
-- consumed there), so the fit costs no reseal at all.
local judge_seal_gcds = TBC_JUDGE_SEAL_GCDS
if era_mode then
judge_seal_gcds = ERA_JUDGE_SEAL_GCDS
elseif forever_mode then
judge_seal_gcds = FOREVER_JUDGE_SEAL_GCDS
end
blood_due = (judge_remaining + judge_seal_gcds * G)
<= (rel_gap2 + reaction)
end
if crusader_due or blood_due then
judge_call = true
if judge_remaining > 0 and speed > 2.3 then
if not hold then
hold = true
waiting_judgement = true
end
elseif waiting_judgement then
hold = false
waiting_judgement = false
end
end
else
waiting_judgement = false
end
-- Follow-up advisories (all default off; each cites its sim shape in the
-- header). Stopattack discipline (classic IsUsingJudgementStopAttack +
-- SoD StopAttack/StartAttack twists/judges): cueing a twist-now or a
-- judge while the swing sits inside the window collides with the auto, so
-- the sim stops the attack first. Advisory only: the macro/UI that acts
-- on it is filed (addons cannot cast anyway), and the frame ignores the
-- key meanwhile.
local swing_inside_window = swing_remaining <= twist_window
local stopattack = (twist_now or judge_call) and swing_inside_window
-- Prepull guidance (classic APL -1.5 s): the window is open while the pull
-- is that close and no seal is up. The pull countdown itself is filed.
local time_to_pull = inputs.time_to_pull_seconds
local prepull_ready = type(time_to_pull) == "number"
and time_to_pull == time_to_pull and time_to_pull >= 0
and time_to_pull <= st.nextaction.PREPULL_SEAL_LEAD_SECONDS
and seal == "none"
-- Rank-1 advice (min/max consensus; sim APLs cast rank 1): a known book
-- rank 1 reads as advice. The slot that would carry it is filed.
local rank1_advice = inputs.soc_rank1_known == true
-- strictSequence hard-wait groundwork (SoD twist APLs): a held twist on a
-- strict build waits the swing out instead of filling. The render is filed.
local hard_wait = inputs.strict_sequence == true and hold == true
out.action = action
out.hold = hold
out.riding = riding
out.judge_call = judge_call
out.filler_kind = filler_kind
out.prediction_hold = prediction_hold
out.waiting_judgement = waiting_judgement
out.stopattack = stopattack
out.prepull_ready = prepull_ready
out.seal_maintenance = false
out.rank1_advice = rank1_advice
out.hard_wait = hard_wait
return out
end
-- Helpers above are reachable via st.nextaction and pure (no WoW globals).
-- Wrath FCFS + SoD Exodin + three SoD-native variants live below
-- (evaluate_fcfs): same out channels, new branches only. TBC / Era /
-- Retail never set inputs.fcfs_mode, so evaluate() above runs
-- bit-identically there.
if st.debug then st.utils.print_msg('-- Parsed nextaction.lua correctly') end
--=========================================================================================
-- Wrath FCFS + SoD Exodin + SoD stack / shockadin / wrath-like (first-come-
-- first-served winner): pure, no WoW API.
--
-- Sourced ret min/max (docs/research/rotations_wrath.md, rotations_sod.md):
-- * Wrath FCFS (single target): CS > Judge > DS > Cons > Exo-instant-via-AoW >
-- Holy Wrath (Undead/Demon only). Never-wait: a ready lower-priority ability
-- beats waiting on a higher-priority cooldown.
-- * SoD Exodin: Exo (core, every target) > CS > DS > Judge > Cons (mana, 3+
-- targets) > HoW (< 20%). Exo < 10% is subsumed (Exo is already first).
-- * SoD stack (bench/sod_paladin_variants_2026-10-19.md §3, p8-stack APL,
-- in-client UNCONFIRMED): independent SoC/SoM <=1 s refreshes; DS
-- stack-gated; CS; Exo; HW r2 Undead + Naxx-6pc; Cons r5; Judge dual-only.
-- * Shockadin (bench §4-§5, p8-shockadin-1h/2h APLs, in-client UNCONFIRMED):
-- seal/Judge 1.5 s maintenance (FILED: p8 primary role UNCONFIRMED);
-- Sunlight/Templar maintenance AM+HS weave; Exo > AM (Libram-gated,
-- 3 stacks) > HS (3 stacks) > CS.
-- * Wrath-like (bench §6, p8-wrath APL, in-client UNCONFIRMED): Judge
-- T2-2pc-gated; reseal 0.5 s (FILED: primary role UNCONFIRMED, constant
-- carried here); Templar <=1 s at 3 stacks waits DS; DS (3 stacks) > CS >
-- Exo > DS ungated fallback > Judge GCD fallback > Cons (DS/CS/Exo all
-- >1.5 s out or stacks <3).
-- * 2pc-T10 note: NO explicit set-bonus input. Post-2pc DS resets surface as
-- ds_remaining readiness (the live client cooldown), so this walk elevates DS
-- automatically; the ORDER is unchanged pre/post 2pc. Explicit set-bonus
-- detection is deferred (no offline-testable probe).
--
-- evaluate_fcfs(inputs, out) contract:
-- * inputs.fcfs_mode selects the table: "wrath", "sod", "sod_stack",
-- "sod_shock" or "sod_wrath" (the last three are SoD-native, ERA-gated +
-- rune/item-gated in the gather, never client-version; bench file above).
-- Any other mode (or Retail, which never sets a mode) yields the empty
-- display shape. "sod" (Exodin) is unchanged by every branch below.
-- * Cooldown inputs (seconds remaining; nil or the 999 sentinel means unknown
-- on this client and withholds the ability, never prompts it):
-- cs_remaining, judge_remaining, ds_remaining, cons_remaining,
-- exo_remaining, hw_remaining (Wrath Holy Wrath), how_remaining (SoD HoW),
-- hs_remaining (shockadin Holy Shock), am_remaining (shockadin Aura Mastery),
-- hor_remaining (Wrath Hand of Reckoning), how_wrath_remaining (Wrath
-- Hammer of Wrath).
-- * Gates: cs_known (default true, like evaluate), has_aow (Wrath Exo only),
-- mana_pct with mana_consecration_threshold (35) / mana_exorcism_threshold
-- (30), creature_type (Wrath HW eligibility via exorcism_target_types;
-- stack HW adds Naxx-6pc), target_count (SoD Cons cleave gate),
-- target_health_pct (SoD HoW window), fight_remaining_pct (SoD HoW
-- execute burn: below SOD_EXECUTE_FIGHT_PCT the cue fires without the
-- hp read; nil = unknown = archived hp-only rule).
-- * SoD-variant gates (all nil/false = unknown = withheld, never prompted):
-- holy_power_stacks (1226461 stacks, APL-cited, in-client UNCONFIRMED),
-- holy_power_set_known (1226460, OR-gate for DS per the twist GAP),
-- sod_dual_seal_active (stack Judge dual gate), sod_t2_known (467518,
-- wrath Judge gate), sod_naxx_known (1219193, stack HW gate),
-- sod_libram_known (1214298, shock AM gate), am_rune_known (407624),
-- sunlight_remaining (1239543), templar_stack_remaining (1240574),
-- templar_wrath_remaining (1226464), soc_remaining_seconds /
-- som_remaining_seconds (stack dual timers, SoC 20920r5 + SoM 407798).
-- * Ready = remaining <= max(gcd_remaining, 0): castable when the GCD frees.
-- * out reuses the archived channels so the provider mapping is untouched:
-- action "cs"; action "sob" (Divine Storm - the sob slot carries the DS
-- texture on FCFS families, same key); judge_call (Judgement cue);
-- filler_kind "consecration" | "exorcism" | "how" (Holy Wrath on Wrath,
-- Hammer of Wrath on SoD) | "holy_shock" | "aura_mastery" (shockadin;
-- new slots carry them, same key). hold is true only when nothing is
-- ready (wait on the first known ability); riding never;
-- waiting_judgement always false.
-- * inputs.inputs_unknown (optional bool, M6) passes through to
-- out.inputs_unknown exactly as in evaluate above.
--=========================================================================================
-- Priority orders, first match wins (sourced above; index order is the contract).
--
-- WRATH carries the WotLK APL's UTILITY BAND at the front (the APL layer,
-- bench/rotation_gap_vs_apl_2026-10-20.md §6.2 - the APL file was re-fetched
-- on 2026-10-20 and every group expanded inline):
-- * "hor" Hand of Reckoning 67485 - the APL's i=1, its TOP row.
-- * "how_wrath" Hammer of Wrath 48806 - the APL's i=2 (the WotLK spell, not
-- the Era/Forever execute Hammer of Wrath the "how" key names;
-- the sim gates the cast on the execute phase, so the arm asks
-- for it only below 20 % target health).
-- The damage rows below them keep their shipped relative order (cs, judge, ds,
-- cons, exo, hw): the utility band is ADDED above them, never a re-cut of the
-- shipped order. The APL's third row (Judgement of Wisdom 53408) is NOT in the
-- band - it shares the 10 s judgement cooldown with the shipped "judge" row
-- (Judgement of Light 20271), so an arm would displace the shipped judgement
-- cue; that row ships in the ROTATION TABLE with engine = false and the reason
-- filed (bench/paladin_apl_utility_build_2026-10-20.md §4).
local FCFS_ORDER_WRATH = { "hor", "how_wrath", "cs", "judge", "ds", "cons", "exo", "hw" }
local FCFS_ORDER_SOD = { "exo", "cs", "ds", "judge", "cons", "how" }
-- SoD-variant orders (bench/sod_paladin_variants_2026-10-19.md §3-§6):
-- * stack (§3): DS stack-gated > CS > Exo > HW (Undead + Naxx-6pc) > Cons r5 >
-- Judge dual-only last. Maintenance (dual 1 s refreshes) overrides below.
-- * shock (§4): Exo core > AM (Libram-gated, 3 stacks) > HS (3 stacks) > CS.
-- Sunlight/Templar maintenance elevates AM/HS above Exo below. No Cons/HW
-- line in the APL (order lacks them).
-- * wrath-like (§6): DS (3 stacks) > CS > Exo > Judge (T2-2pc-gated,
-- GCD fallback) > Cons (fallback ONLY when DS/CS/Exo all >1.5 s out or
-- stacks <3). Templar-wait holds for DS below. DS ungated fallback: when
-- CS/Exo/Judge/Cons are all ineligible, DS prompts if known+ready even
-- without stacks (second DS line in the APL).
local FCFS_ORDER_SOD_STACK = { "ds", "cs", "exo", "hw", "cons", "judge" }
local FCFS_ORDER_SOD_SHOCK = { "exo", "am", "hs", "cs" }
local FCFS_ORDER_SOD_WRATH = { "ds", "cs", "exo", "judge", "cons" }
local FCFS_ORDER_PROT_FOREVER = { "rf", "seal", "judge", "cons", "hs", "holy_shield", "holy_strike", "exo" }
local FCFS_ORDER_PROT = { "rf", "holy_shield", "judge", "seal", "cons", "as", "exo", "how" }
-- The priority tables, published so no caller has to copy them (the
-- practice rotation table and the priority-order drill read them instead of
-- duplicating the order; a copy would drift from the engine on the next
-- order change). READ-ONLY: the tables are module-level and shared, so a