Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moved scripts array to src/data/battle_move_effects.h #3994

Merged

Conversation

cfmnephrite
Copy link

@cfmnephrite cfmnephrite commented Jan 14, 2024

Instead of an array in battle_scripts_1.s that has to be kept in sync with the enums in include/constants/battle_move_effects.h, defined a struct BattleMoveEffect and created an array of those in src/data/battle_move_effects.h.

The ordered array in battle_scripts_1.s always causes problems whenever there are merges. With the array defined here, the order no longer matters and pain caused by merges should be greatly reduced - and since it's an array in C, it can be expanded to a struct with more information.

Description

BattleMoveEffect struct defined like so for now - makes a reference to the relevant battle script and contains other information such as battle TV scores and AI flags.

struct __attribute__((packed, aligned(2))) BattleMoveEffect
{
    const u8 *ptr;
    u8 battleTvScore;

    // Free byte, might as well be flags?
    u8 encourageEncore:1;
    u8 padding:7;
};

Discord contact info

The Cancer Fairy/thechurchofcage

@AsparagusEduardo
Copy link
Collaborator

What's the benefit of this? you're just moving scripts from one array to another

@cfmnephrite
Copy link
Author

cfmnephrite commented Jan 14, 2024

What's the benefit of this? you're just moving scripts from one array to another

The benefit is that effects will always point to the right script - you won't get errors from the array in BS1 and the EFFECT enums being out of sync and the ide will tell you if there any undefined effects.

EDIT: with an array in C, we can also move effect-specific information to it by using structs (such as battle TV scores) but that's just an extra.

@cfmnephrite cfmnephrite force-pushed the gBattleScriptsForMoveEffects branch from e0bcc66 to 45eca79 Compare January 19, 2024 07:28
@cfmnephrite cfmnephrite force-pushed the gBattleScriptsForMoveEffects branch from 45eca79 to 2a62e2a Compare January 19, 2024 07:31
@cfmnephrite cfmnephrite marked this pull request as ready for review January 19, 2024 07:31
Also tweaked struct, added macro
@AlexOn1ine AlexOn1ine merged commit 89a632c into rh-hideout:upcoming Jan 19, 2024
1 check passed
@cfmnephrite cfmnephrite deleted the gBattleScriptsForMoveEffects branch January 20, 2024 00:25
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.

3 participants