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

Pledge Move refactor #5621

Open
wants to merge 4 commits into
base: upcoming
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions data/battle_scripts_1.s
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,8 @@ BattleScript_EffectPledge::
goto BattleScript_MoveEnd

BattleScript_EffectCombinedPledge_Water::
call BattleScript_EffectHit_Pledge
call BattleScript_EffectHit_RetFromAccCheck
tryfaintmon BS_TARGET
setpledgestatus BS_ATTACKER, SIDE_STATUS_RAINBOW
pause B_WAIT_TIME_SHORTEST
printstring STRINGID_ARAINBOWAPPEAREDONSIDE
Expand All @@ -348,7 +349,8 @@ BattleScript_TheRainbowDisappeared::
end2

BattleScript_EffectCombinedPledge_Fire::
call BattleScript_EffectHit_Pledge
call BattleScript_EffectHit_RetFromAccCheck
tryfaintmon BS_TARGET
setpledgestatus BS_TARGET, SIDE_STATUS_SEA_OF_FIRE
pause B_WAIT_TIME_SHORTEST
printstring STRINGID_SEAOFFIREENVELOPEDSIDE
Expand All @@ -368,7 +370,8 @@ BattleScript_TheSeaOfFireDisappeared::
end2

BattleScript_EffectCombinedPledge_Grass::
call BattleScript_EffectHit_Pledge
call BattleScript_EffectHit_RetFromAccCheck
tryfaintmon BS_TARGET
setpledgestatus BS_TARGET, SIDE_STATUS_SWAMP
pause B_WAIT_TIME_SHORTEST
printstring STRINGID_SWAMPENVELOPEDSIDE
Expand All @@ -382,12 +385,10 @@ BattleScript_TheSwampDisappeared::
waitmessage B_WAIT_TIME_LONG
end2

BattleScript_EffectHit_Pledge::
BattleScript_TwoMovesBecomeOne::
pause B_WAIT_TIME_MED
printstring STRINGID_THETWOMOVESBECOMEONE
waitmessage B_WAIT_TIME_LONG
call BattleScript_EffectHit_RetFromAccCheck
tryfaintmon BS_TARGET
return

BattleScript_EffectSaltCure::
Expand Down
1 change: 1 addition & 0 deletions include/battle_scripts.h
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,7 @@ extern const u8 BattleScript_SelectingNotAllowedCurrentMoveInPalace[];
extern const u8 BattleScript_SaltCureExtraDamage[];
extern const u8 BattleScript_SyrupBombEndTurn[];
extern const u8 BattleScript_SyrupBombActivates[];
extern const u8 BattleScript_TwoMovesBecomeOne[];
extern const u8 BattleScript_EffectCombinedPledge_Water[];
extern const u8 BattleScript_EffectCombinedPledge_Fire[];
extern const u8 BattleScript_EffectCombinedPledge_Grass[];
Expand Down
9 changes: 9 additions & 0 deletions include/battle_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ struct TypePower
u16 effect;
};

// If the sub type is used after the main type of the combo,
// gCurrentMove is set to the main type when the combo is executed.
struct PledgeCombo
{
u8 mainType;
u8 subType;
const u8* battleScript; // Script to execute upon combining.
};

enum
{
CANCELLER_FLAGS,
Expand Down
2 changes: 1 addition & 1 deletion src/battle_ai_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2246,7 +2246,7 @@ static s32 AI_CheckBadMove(u32 battlerAtk, u32 battlerDef, u32 move, s32 score)
{
if (aiData->partnerMove != MOVE_NONE
&& gMovesInfo[aiData->partnerMove].effect == EFFECT_PLEDGE
&& move != aiData->partnerMove) // Different pledge moves
&& gMovesInfo[move].type != gMovesInfo[aiData->partnerMove].type) // Different pledge moves
{
if (gBattleMons[BATTLE_PARTNER(battlerAtk)].status1 & (STATUS1_SLEEP | STATUS1_FREEZE))
// && gBattleMons[BATTLE_PARTNER(battlerAtk)].status1 != 1) // Will wake up this turn - how would AI know
Expand Down
42 changes: 25 additions & 17 deletions src/battle_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -16748,12 +16748,22 @@ void BS_TryRelicSong(void)
}
}

static const struct PledgeCombo sPledgeCombos[] =
{
// Dominant, Passive, Script to execute
{ TYPE_GRASS, TYPE_WATER, BattleScript_EffectCombinedPledge_Grass },
{ TYPE_WATER, TYPE_FIRE, BattleScript_EffectCombinedPledge_Water },
{ TYPE_FIRE, TYPE_GRASS, BattleScript_EffectCombinedPledge_Fire },
Comment on lines +16754 to +16756
Copy link
Collaborator

@AlexOn1ine AlexOn1ine Oct 30, 2024

Choose a reason for hiding this comment

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

Do you think you could find a way to include base power in the table as well in this table and then store it in a BattleStruct field?

    case EFFECT_PLEDGE:
        if (gBattleStruct->pledgeMove)
            basePower = BattleStruct->combinedMoveBasePower;
  1. It can be change adjusted depending on the type
  2. If hackers add more type combinations they aren't locked into 150

Copy link
Collaborator

Choose a reason for hiding this comment

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

Great idea overall

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Do you think you could find a way to include base power in the table as well in this table and then store it in a BattleStruct field?

I was able to do this locally, but I want to check what else would we like to allow for customability.
Targets? Animations? This could potentially be a realization of GF's old "combined moves" leftover code.

Copy link
Collaborator

@AlexOn1ine AlexOn1ine Oct 30, 2024

Choose a reason for hiding this comment

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

I doubt target is needed. That's get chosen by AI / Player.

Not sure about animation since usually the one that overrides the type gets chosen.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I would say that the target could change, in the form of going from MOVE_TARGET_SELECTED to MOVE_TARGET_BOTH or MOVE_TARGET_FOES_AND_ALLY (or even MOVE_TARGET_SELF).
Testing by replacing the effect for Fire+Grass with BattleScript_EffectExplosion only damaged 1 opponent. And used the animation for Fire Pledge.

};

void BS_SetPledge(void)
{
NATIVE_ARGS(const u8 *jumpInstr);

u32 moveType = gMovesInfo[gCurrentMove].type;
u32 partner = BATTLE_PARTNER(gBattlerAttacker);
u32 partnerMove = gBattleMons[partner].moves[gBattleStruct->chosenMovePositions[partner]];
u32 partnerMoveType = gMovesInfo[partnerMove].type;
u32 i = 0;
u32 k = 0;

Expand All @@ -16762,23 +16772,21 @@ void BS_SetPledge(void)
PrepareStringBattle(STRINGID_USEDMOVE, gBattlerAttacker);
gHitMarker |= HITMARKER_ATTACKSTRING_PRINTED;

if ((gCurrentMove == MOVE_GRASS_PLEDGE && partnerMove == MOVE_WATER_PLEDGE)
|| (gCurrentMove == MOVE_WATER_PLEDGE && partnerMove == MOVE_GRASS_PLEDGE))
{
gCurrentMove = MOVE_GRASS_PLEDGE;
gBattlescriptCurrInstr = BattleScript_EffectCombinedPledge_Grass;
}
else if ((gCurrentMove == MOVE_FIRE_PLEDGE && partnerMove == MOVE_GRASS_PLEDGE)
|| (gCurrentMove == MOVE_GRASS_PLEDGE && partnerMove == MOVE_FIRE_PLEDGE))
{
gCurrentMove = MOVE_FIRE_PLEDGE;
gBattlescriptCurrInstr = BattleScript_EffectCombinedPledge_Fire;
}
else if ((gCurrentMove == MOVE_WATER_PLEDGE && partnerMove == MOVE_FIRE_PLEDGE)
|| (gCurrentMove == MOVE_FIRE_PLEDGE && partnerMove == MOVE_WATER_PLEDGE))
for (i = 0; i < ARRAY_COUNT(sPledgeCombos); i++)
{
gCurrentMove = MOVE_WATER_PLEDGE;
gBattlescriptCurrInstr = BattleScript_EffectCombinedPledge_Water;
if (moveType == sPledgeCombos[i].mainType && partnerMoveType == sPledgeCombos[i].subType)
{
BattleScriptPush(sPledgeCombos[i].battleScript);
gBattlescriptCurrInstr = BattleScript_TwoMovesBecomeOne;
break;
}
else if (moveType == sPledgeCombos[i].subType && partnerMoveType == sPledgeCombos[i].mainType)
{
gCurrentMove = partnerMove;
BattleScriptPush(sPledgeCombos[i].battleScript);
gBattlescriptCurrInstr = BattleScript_TwoMovesBecomeOne;
break;
}
}

gBattleCommunication[MSG_DISPLAY] = 0;
Expand All @@ -16788,7 +16796,7 @@ void BS_SetPledge(void)
&& IsBattlerAlive(partner)
&& GetBattlerTurnOrderNum(gBattlerAttacker) < GetBattlerTurnOrderNum(partner)
&& !(gHitMarker & HITMARKER_UNABLE_TO_USE_MOVE)
&& gCurrentMove != partnerMove
&& moveType != partnerMoveType
&& gMovesInfo[partnerMove].effect == EFFECT_PLEDGE)
{
u32 currPledgeUser = 0;
Expand Down
8 changes: 5 additions & 3 deletions src/battle_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -3522,10 +3522,12 @@ u8 AtkCanceller_UnableToUseMove(u32 moveType)
case CANCELLER_POWDER_STATUS:
if (gBattleMons[gBattlerAttacker].status2 & STATUS2_POWDER)
{
u32 partnerMove = gBattleMons[BATTLE_PARTNER(gBattlerAttacker)].moves[gBattleStruct->chosenMovePositions[BATTLE_PARTNER(gBattlerAttacker)]];
u32 userEffect = gMovesInfo[gCurrentMove].effect;
u32 partnerEffect = gMovesInfo[gBattleMons[BATTLE_PARTNER(gBattlerAttacker)].moves[gBattleStruct->chosenMovePositions[BATTLE_PARTNER(gBattlerAttacker)]]].effect;
u32 partnerMoveType = gMovesInfo[gBattleMons[BATTLE_PARTNER(gBattlerAttacker)].moves[gBattleStruct->chosenMovePositions[BATTLE_PARTNER(gBattlerAttacker)]]].type;
if ((moveType == TYPE_FIRE && !gBattleStruct->pledgeMove)
|| (gCurrentMove == MOVE_FIRE_PLEDGE && partnerMove == MOVE_GRASS_PLEDGE)
|| (gCurrentMove == MOVE_GRASS_PLEDGE && partnerMove == MOVE_FIRE_PLEDGE && gBattleStruct->pledgeMove))
|| (userEffect == EFFECT_PLEDGE && moveType == TYPE_FIRE && partnerEffect == EFFECT_PLEDGE && partnerMoveType == TYPE_GRASS)
|| (userEffect == EFFECT_PLEDGE && moveType == TYPE_GRASS && partnerEffect == EFFECT_PLEDGE && partnerMoveType == TYPE_FIRE && gBattleStruct->pledgeMove))
{
gProtectStructs[gBattlerAttacker].powderSelfDmg = TRUE;
if (GetBattlerAbility(gBattlerAttacker) != ABILITY_MAGIC_GUARD
Expand Down
Loading