mirror of
https://github.com/prosolis/gogobee.git
synced 2026-07-15 08:32:41 +00:00
Tedium-removal pass driven by live play feedback. Three big threads: Expedition autopilot Phase 4 — background auto-run + harvest-until-dry: - New expeditionAutoRunTicker walks active expeditions every 15min (5min tick, per-expedition CAS on new last_autorun_at column). Skips combat sessions, briefing/recap quiet windows, expeditions <30min old. - Walks up to 3 rooms/tick with compact narration; suppresses DMs when 0 rooms walked or just hitting the per-tick cap (no "stretch complete" filler). Player only hears from the bot when a real decision is needed. - Compact mode: one-line combat narration for trash/elite, auto-resolves elite doorways via the forward-sim engine (boss still pauses). Threaded via new advanceOnceWithOpts → resolveRoom → resolveCombatRoom. - Auto-harvest now grinds each Common/Uncommon node until dry (cap at 8 attempts/visit), mirroring manual !scavenge retries. Rare+ still pauses. - Ambient ticker: anti-repeat by Kind via new last_ambient_kind column (avoids two pack_rat DMs in a row when the pool only has 6 lines). - !expedition go <n> now routes to the fork-choice handler when active + numeric; fork footer rewritten to suggest !expedition go instead of !zone go. Boss/Elite doorway: formatNextRoomMessage routes the action hint by next room type and autopilot loop breaks via new nextRoomType field so "Room X/Y — Boss" doesn't double-print with contradictory hints (!zone advance vs !fight). - runAutopilotWalk extracted from expeditionCmdRun so foreground and background share the loop body. Rogue Sneak Attack actually exists now: - Audit found the rogue's "Sneak Attack" passive was AutoCritFirst + 5% damage rider. No Nd6, ever. Phase 2 Monte Carlo masked this with a small flat buff; the class's defining mechanic never matched its tooltip or 5e identity. - Added SneakAttackDie int to CombatModifiers, per-hit Nd6 in combat_primitives.go (same lane as DivineStrikePerHit). Scales with level: 1d6 at L1-2 ... 4d6 at L7-8 ... capped at 10d6 at L19-20. - AutoCritFirst + 5% rider retained as bonuses on top of working sneak attack — preserves the opener-burst feel. - L7 rogue expected per-hit ~8 → ~22 damage. Valdris fight math goes from "16 rounds to kill, die in 8" to winnable. TwinBee voice sweep (Phase B3): - ~530 line changes across 24 files replacing third-person "TwinBee notes/files/tracks/respects/..." constructions with first-person inside flavor string literals. Code identifiers (TwinBeeLine, twinBeeLine, etc.), chat-prefix labels (🎭 **TwinBee:**), item names (TwinBee's Bell), achievements, and game-title references in fun.go (Konami TwinBee ship) left intact. - Catches a real bug: Valdris fight rendered "TwinBee marks the Legendary Resistance" mid-combat in third person, contradicting the Phase B2 convention. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
129 lines
5.0 KiB
Go
129 lines
5.0 KiB
Go
package plugin
|
|
|
|
// Shared combat resolution primitives.
|
|
//
|
|
// These are the building blocks both the auto-resolve engine (SimulateCombat)
|
|
// and the upcoming turn-based engine call into, so a single attack resolves
|
|
// identically regardless of which loop drives it. Everything here is a
|
|
// behavior-preserving extraction from combat_engine.go — the combat
|
|
// characterization golden file pins that no event stream shifted.
|
|
|
|
// effectiveAttackBonus returns the d20 attack bonus for a combatant, applying
|
|
// the appendix §8 non-proficient-weapon penalty (-4) when the combatant wields
|
|
// a D&D weapon without proficiency. Monsters and weaponless combatants have no
|
|
// Weapon set, so they fall through to the raw bonus.
|
|
func effectiveAttackBonus(s CombatStats) int {
|
|
ab := s.AttackBonus
|
|
if s.Weapon != nil && !s.WeaponProficient {
|
|
ab -= 4
|
|
}
|
|
return ab
|
|
}
|
|
|
|
// attackCritFloor returns the lowest d20 face that counts as a critical hit.
|
|
// Default 20; Champion Improved Critical (and later tiers) lower it via
|
|
// CritThreshold. A zero or out-of-range CritThreshold means "use default".
|
|
func attackCritFloor(m CombatModifiers) int {
|
|
if m.CritThreshold > 0 && m.CritThreshold < 20 {
|
|
return m.CritThreshold
|
|
}
|
|
return 20
|
|
}
|
|
|
|
// attackConnects decides whether a d20 attack lands. roll is the raw d20 face
|
|
// (post-reroll), total is roll+bonus, ac is the defender's armor class, and
|
|
// critFloor is the crit threshold from attackCritFloor. A raw 1 always misses
|
|
// (fumble); a roll at/above critFloor always hits; otherwise total must meet AC.
|
|
func attackConnects(roll, total, ac, critFloor int) bool {
|
|
if roll == 1 {
|
|
return false
|
|
}
|
|
if roll >= critFloor {
|
|
return true
|
|
}
|
|
return total >= ac
|
|
}
|
|
|
|
// applyPlayerHitDamageMods runs the post-hit player damage stack on a connected
|
|
// attack: crit doubling (natural or AutoCritFirst consumable), Orc Rage, the
|
|
// Berserker rage flat+multiplicative bumps, Cleric Divine Strike, and the
|
|
// Assassinate first-hit bonus. It consumes the relevant one-shot state on st
|
|
// (autoCrit, pendingRageAttack, assassinateBonusUsed) and returns the final
|
|
// damage plus the event action/desc labels. dmg is clamped to >=1.
|
|
func applyPlayerHitDamageMods(st *combatState, player *Combatant, dmg int, isCritRoll, blocked bool) (int, string, string) {
|
|
isCrit := isCritRoll
|
|
autoCritFired := false
|
|
if !isCritRoll && st.autoCrit {
|
|
isCrit = true
|
|
autoCritFired = true
|
|
st.autoCrit = false
|
|
} else if st.autoCrit && isCritRoll {
|
|
// Natural crit consumes the auto-crit charge but doesn't get the
|
|
// "passive fired" flavor — the dice already explain it.
|
|
st.autoCrit = false
|
|
}
|
|
if isCrit {
|
|
// Crit: double damage. (5e rolls extra dice; we double total to
|
|
// match the engine's pre-Phase-8 crit semantics.)
|
|
dmg *= 2
|
|
}
|
|
// Orc Rage: +50% damage on this attack, then consume.
|
|
if st.pendingRageAttack {
|
|
dmg = int(float64(dmg) * 1.5)
|
|
st.pendingRageAttack = false
|
|
}
|
|
// Phase 10 SUB2a — Berserker rage: +flat per hit, plus Frenzy
|
|
// multiplicative bump that approximates the bonus-attack-per-turn we
|
|
// can't model in one-shot combat.
|
|
if player.Mods.BerserkerRage {
|
|
if player.Mods.RageMeleeDmg > 0 {
|
|
dmg += player.Mods.RageMeleeDmg
|
|
}
|
|
if player.Mods.FrenzyDmgBonus > 0 {
|
|
dmg = int(float64(dmg) * (1 + player.Mods.FrenzyDmgBonus))
|
|
}
|
|
}
|
|
// Phase 10 SUB3c — Divine Strike. Flat per-hit bonus on weapon hits only
|
|
// (5e specs "weapon hit"; no Weapon means we're on the legacy/non-weapon
|
|
// damage path and Divine Strike doesn't apply). Lands every hit because
|
|
// our 1v1 model has no concept of "once per turn" turn boundaries.
|
|
if player.Mods.DivineStrikePerHit > 0 && player.Stats.Weapon != nil {
|
|
dmg += player.Mods.DivineStrikePerHit
|
|
}
|
|
// Class-identity audit (2026-05-16) — Rogue Sneak Attack. Add Nd6 on
|
|
// every player hit. Same "once per turn = every hit" convention as
|
|
// Divine Strike. Rogues swing once per round so this naturally lands
|
|
// once/round at the cadence 5e expects. The bonus rides through the
|
|
// crit doubling above (already applied to dmg) so a sneak-attack crit
|
|
// reads correctly: doubled weapon dmg, then +Nd6 unaffected by the
|
|
// crit. (5e doubles the sneak attack dice on crit too — we under-
|
|
// shoot by ~Nd6 on the rare crit, which is acceptable for now.)
|
|
if player.Mods.SneakAttackDie > 0 {
|
|
for i := 0; i < player.Mods.SneakAttackDie; i++ {
|
|
dmg += 1 + st.roll(6)
|
|
}
|
|
}
|
|
// Phase 10 SUB2a-ii — Assassin Death Strike proxy: bonus damage on the
|
|
// first hit only. Stacks on top of the Rogue's Sneak Attack auto-crit
|
|
// (which already doubled the base damage above) — the bonus itself is
|
|
// applied AFTER the crit doubling so the math is "double base + flat
|
|
// surprise damage". Consumed on first hit regardless of crit status.
|
|
if player.Mods.AssassinateBonusDmg > 0 && !st.assassinateBonusUsed {
|
|
dmg += player.Mods.AssassinateBonusDmg
|
|
st.assassinateBonusUsed = true
|
|
}
|
|
dmg = max(1, dmg)
|
|
|
|
action := "hit"
|
|
desc := ""
|
|
if isCrit {
|
|
action = "crit"
|
|
if autoCritFired {
|
|
desc = "auto_crit"
|
|
}
|
|
} else if blocked {
|
|
action = "block"
|
|
}
|
|
return dmg, action, desc
|
|
}
|