Skip to content

Refactor MonsterAttack() extra melee hit windows without behavior cha…#8511

Open
morfidon wants to merge 1 commit intodiasurgical:masterfrom
morfidon:refactor/monster-attack-extra-hit-windows
Open

Refactor MonsterAttack() extra melee hit windows without behavior cha…#8511
morfidon wants to merge 1 commit intodiasurgical:masterfrom
morfidon:refactor/monster-attack-extra-hit-windows

Conversation

@morfidon
Copy link
Copy Markdown

@morfidon morfidon commented Mar 13, 2026

Summary

Refactor the family-specific extra melee hit windows in MonsterAttack() into a small helper abstraction.

This patch is intentionally behavior-preserving. It does not change gameplay, timing, or audio behavior. It only makes the existing multi-hit logic easier to read and reason about.

What changed

  • added a small MeleeAttackWindow helper struct
  • moved the Magma and Storm extra melee hit windows out of inline conditionals in MonsterAttack()
  • kept the normal melee hit path separate from the family-specific extra hit windows
  • left Snake attack sound timing unchanged

Preserved behavior

This patch is intended to keep the current behavior exactly as it is today:

  • the normal melee hit still happens at animFrameNum - 1
  • Magma monsters still perform their extra hit on frame 8
  • Storm monsters still perform their extra hit on frame 12
  • the same hit chance and damage modifiers are still applied for those extra hits
  • Snake attack sound timing still happens on frame 0

Why

MonsterAttack() currently mixes three different concerns in one place:

  • the default melee attack flow
  • family-specific extra hit timing
  • special-case sound timing

Pulling the extra hit windows into a clearer abstraction makes the code easier to inspect without changing what the game does. It also gives us a cleaner base for any later discussion about these monster families, without combining that discussion with gameplay changes in this patch.

Non-goals

  • no gameplay rebalance
  • no attack timing changes
  • no audio behavior changes
  • no move to monster data tables yet

…nges

Extract the family-specific extra melee hit timing for Magma and Storm
into a small helper abstraction instead of keeping it hardcoded directly
inside MonsterAttack().

This keeps behavior unchanged:
- the normal melee hit still happens at animFrameNum - 1
- Magma monsters still perform their extra hit on frame 8
- Storm monsters still perform their extra hit on frame 12
- Snake attack sound timing remains unchanged

The goal is only to make the extra hit windows easier to reason about
without mixing those family-specific rules directly into the main melee
attack flow.
@yuripourre yuripourre added the pr size:medium Pull Requests that add less than 100 lines label May 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr size:medium Pull Requests that add less than 100 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants