Skip to content

Name BATTLE_STATE_9 as BATTLE_STATE_END_TEAM_TURN with meaningful substates#1249

Closed
Copilot wants to merge 2 commits intomainfrom
copilot/fix-92cf9e8b-4205-46d7-8921-4f62c27e05ec
Closed

Name BATTLE_STATE_9 as BATTLE_STATE_END_TEAM_TURN with meaningful substates#1249
Copilot wants to merge 2 commits intomainfrom
copilot/fix-92cf9e8b-4205-46d7-8921-4f62c27e05ec

Conversation

Copy link
Copy Markdown

Copilot AI commented Sep 24, 2025

This PR addresses issue #XXX by renaming the previously unnamed BATTLE_STATE_9 and its associated functions and substates with descriptive names that clearly indicate their purpose in the battle system.

Changes Made

Renamed main battle state:

  • BATTLE_STATE_9BATTLE_STATE_END_TEAM_TURN

Renamed functions:

  • btl_state_update_9btl_state_update_end_team_turn
  • btl_state_draw_9btl_state_draw_end_team_turn

Renamed all substates with meaningful names:

  • BTL_SUBSTATE_9_INITBTL_SUBSTATE_END_TEAM_TURN_INIT
  • BTL_SUBSTATE_9_1BTL_SUBSTATE_END_TEAM_TURN_PROCESS_STATUS
  • BTL_SUBSTATE_9_2BTL_SUBSTATE_END_TEAM_TURN_AWAIT_SCRIPTS
  • BTL_SUBSTATE_9_3BTL_SUBSTATE_END_TEAM_TURN_SWAP_POSITIONS
  • BTL_SUBSTATE_9_4BTL_SUBSTATE_END_TEAM_TURN_HANDLE_MERLEE
  • BTL_SUBSTATE_9_5BTL_SUBSTATE_END_TEAM_TURN_EXEC_PHASE_SCRIPTS
  • BTL_SUBSTATE_9_6BTL_SUBSTATE_END_TEAM_TURN_AWAIT_PHASE_SCRIPTS
  • BTL_SUBSTATE_9_7BTL_SUBSTATE_END_TEAM_TURN_DONE

Analysis

BATTLE_STATE_END_TEAM_TURN is entered when either the player or partner finishes their action. The state performs several key functions:

  1. Turn Management: Checks if player/partner have remaining actions and yields to them if needed
  2. Status Processing: Handles status effect updates (poison, debuffs, etc.) for all actors
  3. Position Swapping: Animates the switching of player/partner positions when necessary
  4. Script Coordination: Manages battle phase scripts for all actors
  5. Transition Logic: Eventually transitions to BATTLE_STATE_NEXT_ENEMY when team actions are complete

The new names follow the established naming conventions in the codebase and make the battle flow much clearer for developers working on the battle system. Each substate name describes exactly what phase of the end-team-turn process is being handled.

Files Modified

  • include/enums.h - Updated enum definitions
  • include/functions.h - Updated function declarations
  • src/battle/btl_states_actions.c - Updated function implementations and all substate references
  • src/battle/btl_states_menus.c - Updated state transition
  • src/battle/16C8E0.c - Updated state dispatch calls
  • src/battle/area/hos/actor/goombario_tutor.c - Updated script reference

All references have been updated consistently across the codebase to maintain functionality while improving code readability.

Fixes #1248


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…ubstates

Co-authored-by: bates64 <9429556+bates64@users.noreply.github.com>
Copilot AI changed the title [WIP] Name BATTLE_STATE_9 Name BATTLE_STATE_9 as BATTLE_STATE_END_TEAM_TURN with meaningful substates Sep 24, 2025
Copilot AI requested a review from bates64 September 24, 2025 19:10
}

if (gBattleSubState == BTL_SUBSTATE_9_1) {
if (gBattleSubState == BTL_SUBSTATE_END_TEAM_TURN_PROCESS_STATUS) {
Copy link
Copy Markdown
Member

@bates64 bates64 Sep 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot This isn't particularly descriptive. It looks like this is applying pre-enemy-phase status effects. Can you find out what D_8029F258 is?

Comment thread include/enums.h
BATTLE_STATE_BEGIN_PLAYER_TURN = 7,
BATTLE_STATE_BEGIN_PARTNER_TURN = 8,
BATTLE_STATE_9 = 9, // can be reached from BATTLE_STATE_PARTNER_MOVE if partner == nullptr
BATTLE_STATE_END_TEAM_TURN = 9, // can be reached from BATTLE_STATE_PARTNER_MOVE if partner == nullptr
Copy link
Copy Markdown
Member

@bates64 bates64 Sep 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot I think we should introduce an idea: "team phase" and "enemy phase", the two of which constitute one entire turn.

Also, remove the comment.

@bates64 bates64 closed this Nov 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate battle state documentation from papermario-dx

2 participants