mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2714] [Issue]: Game combat — speed-stat crowd-control (Frozen/Stunned) never applied; crit keys off defender not d20; NPC name collisions #1360
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#1360
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @kolacheee on GitHub (Jun 21, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2714
Originally assigned to: @SpicyMarinara on GitHub.
Summary
Game combat has correctness bugs: all speed-stat crowd-control (Frozen/Stunned/Chilled/Entangled, etc.) is cosmetic — never actually applied to initiative/turns — and the critical-hit "natural 20" check keys off the defender's defense modifier instead of the raw d20. Separately,
startingNpcsare reconciled by model-provided name with no de-duplication, so duplicate/empty names collide in avatars and journal lookups.Expected behavior
A Frozen/Stunned combatant should lose/skip its turn; crit chance should depend on rolling a natural 20; and NPCs with duplicate/empty names should be disambiguated rather than crossing each other's portraits/journal data.
Actual behavior
effect.stat === "attack","defense", or"hp".rollInitiativecomputes order from rawc.speedand never consultsstatusEffects; no path reads astat:"speed"modifier. But the elemental-reaction/Genshin/HSR tables inflict their control asstat:"speed"effects (Frozen{modifier:-99,stat:"speed"}, Stunned{-5}, Chilled{-2}, Entangled{-4}, etc.). So a Frozen/Stunned enemy still rolls full initiative and acts every round — damage multipliers from reactions apply, but the disabling half silently fails, making CC builds feel broken/unwinnable.attackRoll = d20 + floor(attacker.attack/3). The first crit condition isattackRoll - defenseMod >= 20wheredefenseMod = floor(defender.defense/3)— a property of the defender. The raw d20 is never retained, so the "natural 20" check is(attacker d20 + attacker attackMod − defender defenseMod) >= 20— an arbitrary quantity. Crit frequency depends on attacker attack vs defender defense, not on rolling a 20.applyGameSetupPayloadmapsstartingNpcsto records with a UUIDidbut the human identity is the model-providedname(fallbackNPC i). Avatar URLs derive purely from the slugified name and lookups/journal reconciliation match by normalized name, with no de-dup. Two NPCs with the same/empty name get distinct UUIDs but identical avatar slugs and collide under name-keyed lookups — portraits/journal data cross between them.How it breaks the pipeline
Code trace (staging @
b826f8f4):packages/server/src/services/game/combat.service.ts:369(attack),:374(defense),:439(hptick),:303-317(rollInitiativeuses rawc.speed);statusEffectsofstat:"speed"defined inelement-reactions.service.ts:77,93,134,191,320,367,399,407.combat.service.ts:328(attackRoll),:331(defenseModfrom defender),:338(crit condition); raw d20 discarded.game.routes.ts:3062-3078(NPC map, name identity),:2531-2537(buildNpcAvatarUrlslug),:2543-2547(findNpcRecordByName); validation only checks non-empty array at:2450.Steps to reproduce
resolveAttackwith a high-attack attacker vs a low-defense defender → crit rate vastly exceeds 1/20 and varies withdefender.defense.startingNpcswith the same/blank name → both resolve to the same avatar slug and collide infindNpcRecordByName.Suggested fix
rollInitiative, fold activestat:"speed"status modifiers into effective speed (clamp ≥ 0) and treat effectiveSpeed ≤ 0 / a Frozen marker as "skips turn" in the per-combatant loop.rawAttackD20) and base the nat-20 crit onrawAttackD20 === 20; keep the margin-based crit separate.startingNpcs(reject/rename blanks and collisions) and/or key avatars and reconciliation off the stable NPCidrather than the display name.Environment
b826f8f4)Additional context
Found via a systematic multi-agent audit of Game Mode. Combat-correctness + NPC-identity bugs that make CC builds and combat outcomes feel broken. Part of a set of game-mode issues filed together.
Template check
Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:
@SpicyMarinara commented on GitHub (Jun 21, 2026):
Fixed in
b48c9953. Combat initiative now folds active speed status modifiers into effective speed and skips turn-blocking statuses like Frozen/Stunned/Imprisoned; critical hits now use the raw attack d20 for natural 20s; setup NPC names are de-duplicated on apply so duplicate model names do not collide in name-keyed avatar/journal lookups.