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

Adds Commander and Order Up #5246

Merged
merged 27 commits into from
Sep 29, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
f8354b0
Adds Commander
AlexOn1ine Jul 30, 2024
bf638ae
merge rhh/upcoming
AlexOn1ine Aug 23, 2024
e6ec4b4
review points
AlexOn1ine Aug 24, 2024
28afd90
new line
AlexOn1ine Aug 24, 2024
02c0482
correction
AlexOn1ine Aug 24, 2024
d6736d0
regression / double targeting still broken
AlexOn1ine Aug 25, 2024
d292492
fix wrong target order
AlexOn1ine Aug 25, 2024
6c97796
transform fixes
AlexOn1ine Aug 25, 2024
1fee63a
haze test
AlexOn1ine Aug 25, 2024
afe306d
fixes, tests
AlexOn1ine Sep 8, 2024
a02e4c1
rhh merge/upcoming
AlexOn1ine Sep 8, 2024
1653981
bring back wrongly removed else if case
AlexOn1ine Sep 16, 2024
42edcec
Eject Pack / Button test + fix
AlexOn1ine Sep 16, 2024
f786946
rhh merge/upcoming
AlexOn1ine Sep 16, 2024
64fcaf2
red card fix
AlexOn1ine Sep 16, 2024
30a0908
test fixes
AlexOn1ine Sep 16, 2024
233cadf
Fixes Tatsu being hit by multi hit move
AlexOn1ine Sep 19, 2024
7d897e4
change transform check
AlexOn1ine Sep 19, 2024
59fdda8
fix test + revert change
AlexOn1ine Sep 22, 2024
054ef0a
Fix Tatsugiri attacking after freed up from Dozo in the same turn
AlexOn1ine Sep 22, 2024
4acfdde
Dragon Darts tests
AlexOn1ine Sep 27, 2024
b3ec57c
fix test
AlexOn1ine Sep 27, 2024
e9842ab
review comments
AlexOn1ine Sep 28, 2024
053ef19
Merge remote-tracking branch 'rhh/upcoming' into commander
AlexOn1ine Sep 28, 2024
5be10ed
assumtion in wrong file
AlexOn1ine Sep 28, 2024
30eecf2
Order Up test fixes
AlexOn1ine Sep 29, 2024
1a53422
Merge branch 'upcoming' into commander
hedara90 Sep 29, 2024
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
6 changes: 5 additions & 1 deletion asm/macros/battle_script.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1351,7 +1351,6 @@
.4byte \func
.endm

@ callnative macros
AsparagusEduardo marked this conversation as resolved.
Show resolved Hide resolved
.macro savetarget
callnative BS_SaveTarget
.endm
Expand Down Expand Up @@ -1674,6 +1673,11 @@
callnative BS_FickleBeamDamageCalculation
.endm

.macro jumpfifcommanderactive jumpInstr:req
AlexOn1ine marked this conversation as resolved.
Show resolved Hide resolved
callnative BS_JumpIfCommanderActive
.4byte \jumpInstr
.endm

@ various command changed to more readable macros
.macro cancelmultiturnmoves battler:req
various \battler, VARIOUS_CANCEL_MULTI_TURN_MOVES
Expand Down
46 changes: 45 additions & 1 deletion data/battle_scripts_1.s
Original file line number Diff line number Diff line change
Expand Up @@ -3272,6 +3272,7 @@ BattleScript_EffectRoar::
attackstring
ppreduce
jumpifroarfails BattleScript_ButItFailed
jumpfifcommanderactive BattleScript_ButItFailed
jumpifability BS_TARGET, ABILITY_GUARD_DOG, BattleScript_ButItFailed
jumpifability BS_TARGET, ABILITY_SUCTION_CUPS, BattleScript_AbilityPreventsPhasingOut
jumpifstatus3 BS_TARGET, STATUS3_ROOTED, BattleScript_PrintMonIsRooted
Expand Down Expand Up @@ -8047,11 +8048,54 @@ BattleScript_CostarActivates::

BattleScript_ZeroToHeroActivates::
pause B_WAIT_TIME_SHORT
call BattleScript_AbilityPopUp
call BattleScript_AbilityPopUpScripting
printstring STRINGID_ZEROTOHEROTRANSFORMATION
waitmessage B_WAIT_TIME_LONG
end3

BattleScript_CommanderActivates::
pause B_WAIT_TIME_SHORT
call BattleScript_AbilityPopUpScripting
printstring STRINGID_COMMANDERACTIVATES
waitmessage B_WAIT_TIME_LONG
swapattackerwithtarget
AlexOn1ine marked this conversation as resolved.
Show resolved Hide resolved
BattleScript_CommanderAtkIncrease:
setbyte sSTAT_ANIM_PLAYED, FALSE
playstatchangeanimation BS_ATTACKER, BIT_ATK | BIT_DEF | BIT_SPATK | BIT_SPDEF | BIT_SPEED, STAT_CHANGE_BY_TWO
setstatchanger STAT_ATK, 2, FALSE
statbuffchange MOVE_EFFECT_AFFECTS_USER | STAT_CHANGE_ALLOW_PTR, BattleScript_CommanderDefIncrease
jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, B_MSG_STAT_WONT_INCREASE, BattleScript_CommanderDefIncrease
printfromtable gStatUpStringIds
waitmessage B_WAIT_TIME_LONG
BattleScript_CommanderDefIncrease:
setstatchanger STAT_DEF, 2, FALSE
statbuffchange MOVE_EFFECT_AFFECTS_USER | STAT_CHANGE_ALLOW_PTR, BattleScript_CommanderSpAtkIncrease
jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, B_MSG_STAT_WONT_INCREASE, BattleScript_CommanderSpAtkIncrease
printfromtable gStatUpStringIds
waitmessage B_WAIT_TIME_LONG
BattleScript_CommanderSpAtkIncrease:
setstatchanger STAT_SPATK, 2, FALSE
statbuffchange MOVE_EFFECT_AFFECTS_USER | STAT_CHANGE_ALLOW_PTR, BattleScript_CommanderSpDefIncrease
jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, B_MSG_STAT_WONT_INCREASE, BattleScript_CommanderSpDefIncrease
printfromtable gStatUpStringIds
waitmessage B_WAIT_TIME_LONG
BattleScript_CommanderSpDefIncrease:
setstatchanger STAT_SPDEF, 2, FALSE
statbuffchange MOVE_EFFECT_AFFECTS_USER | STAT_CHANGE_ALLOW_PTR, BattleScript_CommanderSpeedIncrease
jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, B_MSG_STAT_WONT_INCREASE, BattleScript_CommanderSpeedIncrease
printfromtable gStatUpStringIds
waitmessage B_WAIT_TIME_LONG
BattleScript_CommanderSpeedIncrease:
setstatchanger STAT_SPEED, 2, FALSE
statbuffchange MOVE_EFFECT_AFFECTS_USER | STAT_CHANGE_ALLOW_PTR, BattleScript_CommanderEnd
jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, B_MSG_STAT_WONT_INCREASE, BattleScript_CommanderEnd
printfromtable gStatUpStringIds
waitmessage B_WAIT_TIME_LONG
BattleScript_CommanderEnd:
restoreattacker
restoretarget
AlexOn1ine marked this conversation as resolved.
Show resolved Hide resolved
end3

BattleScript_HospitalityActivates::
pause B_WAIT_TIME_SHORT
call BattleScript_AbilityPopUp
Expand Down
4 changes: 3 additions & 1 deletion include/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -823,8 +823,11 @@ struct BattleStruct
u8 boosterEnergyActivates;
u8 distortedTypeMatchups;
u8 categoryOverride; // for Z-Moves and Max Moves
u8 commandingDondozo;
u16 commanderActive[NUM_BATTLE_SIDES];
u32 stellarBoostFlags[NUM_BATTLE_SIDES]; // stored as a bitfield of flags for all types for each side
u8 fickleBeamBoosted:1;
u8 padding:7;
};

// The palaceFlags member of struct BattleStruct contains 1 flag per move to indicate which moves the AI should consider,
Expand Down Expand Up @@ -1159,7 +1162,6 @@ static inline u32 GetBattlerSide(u32 battler)
static inline struct Pokemon* GetBattlerData(u32 battlerId)
{
u32 index = gBattlerPartyIndexes[battlerId];

return (GetBattlerSide(battlerId) == B_SIDE_OPPONENT) ? &gEnemyParty[index] : &gPlayerParty[index];
}

Expand Down
3 changes: 3 additions & 0 deletions include/battle_script_commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ bool32 IsMoveNotAllowedInSkyBattles(u32 move);
bool32 DoSwitchInAbilities(u32 battlerId);
u8 GetFirstFaintedPartyIndex(u8 battlerId);
bool32 IsMoveAffectedByParentalBond(u32 move, u32 battler);
void SaveBattlerTarget(u32 battler);
void SaveBattlerAttacker(u32 battler);

AlexOn1ine marked this conversation as resolved.
Show resolved Hide resolved

extern void (* const gBattleScriptingCommandsTable[])(void);
extern const struct StatFractions gAccuracyStageRatios[];
Expand Down
1 change: 1 addition & 0 deletions include/battle_scripts.h
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,7 @@ extern const u8 BattleScript_CudChewActivates[];
extern const u8 BattleScript_SupremeOverlordActivates[];
extern const u8 BattleScript_CostarActivates[];
extern const u8 BattleScript_ZeroToHeroActivates[];
extern const u8 BattleScript_CommanderActivates[];
extern const u8 BattleScript_HospitalityActivates[];
extern const u8 BattleScript_ToxicDebrisActivates[];
extern const u8 BattleScript_EarthEaterActivates[];
Expand Down
2 changes: 1 addition & 1 deletion include/config/general.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// still has them in the ROM. This is because the developers forgot
// to define NDEBUG before release, however this has been changed as
// Ruby's actual debug build does not use the AGBPrint features.
#define NDEBUG
// #define NDEBUG

// To enable printf debugging, comment out "#define NDEBUG". This allows
// the various AGBPrint functions to be used. (See include/gba/isagbprint.h).
Expand Down
7 changes: 4 additions & 3 deletions include/constants/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
#define STATUS3_YAWN_TURN(num) (((num) << 11) & STATUS3_YAWN)
#define STATUS3_IMPRISONED_OTHERS (1 << 13)
#define STATUS3_GRUDGE (1 << 14)
#define STATUS3___UNUSED (1 << 15)
#define STATUS3_COMMANDER (1 << 15)
#define STATUS3_GASTRO_ACID (1 << 16)
#define STATUS3_EMBARGO (1 << 17)
#define STATUS3_UNDERWATER (1 << 18)
Expand All @@ -183,7 +183,7 @@
#define STATUS3_LASER_FOCUS (1 << 29)
#define STATUS3_POWER_TRICK (1 << 30)
#define STATUS3_SKY_DROPPED (1 << 31) // Target of Sky Drop
#define STATUS3_SEMI_INVULNERABLE (STATUS3_UNDERGROUND | STATUS3_ON_AIR | STATUS3_UNDERWATER | STATUS3_PHANTOM_FORCE)
#define STATUS3_SEMI_INVULNERABLE (STATUS3_UNDERGROUND | STATUS3_ON_AIR | STATUS3_UNDERWATER | STATUS3_PHANTOM_FORCE | STATUS3_COMMANDER)

#define STATUS4_ELECTRIFIED (1 << 0)
#define STATUS4_MUD_SPORT (1 << 1) // Only used if B_SPORT_TURNS < GEN_6
Expand Down Expand Up @@ -401,8 +401,9 @@
#define MOVE_EFFECT_SECRET_POWER 77
#define MOVE_EFFECT_PSYCHIC_NOISE 78
#define MOVE_EFFECT_TERA_BLAST 79
#define MOVE_EFFECT_ORDER_UP 80

#define NUM_MOVE_EFFECTS 80
#define NUM_MOVE_EFFECTS 81

#define MOVE_EFFECT_AFFECTS_USER 0x2000
#define MOVE_EFFECT_CERTAIN 0x4000
Expand Down
3 changes: 2 additions & 1 deletion include/constants/battle_string_ids.h
Original file line number Diff line number Diff line change
Expand Up @@ -713,8 +713,9 @@
#define STRINGID_FOGLIFTED 711
#define STRINGID_PKMNMADESHELLGLEAM 712
#define STRINGID_FICKLEBEAMDOUBLED 713
#define STRINGID_COMMANDERACTIVATES 714

#define BATTLESTRINGS_COUNT 714
#define BATTLESTRINGS_COUNT 715

// This is the string id that gBattleStringsTable starts with.
// String ids before this (e.g. STRINGID_INTROMSG) are not in the table,
Expand Down
3 changes: 3 additions & 0 deletions src/battle_ai_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,9 @@ static s32 AI_CheckBadMove(u32 battlerAtk, u32 battlerDef, u32 move, s32 score)
if (IsTwoTurnNotSemiInvulnerableMove(battlerAtk, move) && CanTargetFaintAi(battlerDef, battlerAtk))
RETURN_SCORE_MINUS(10);

if (gBattleStruct->commandingDondozo & (1u << battlerDef))
RETURN_SCORE_MINUS(20);

// check if negates type
switch (effectiveness)
{
Expand Down
3 changes: 3 additions & 0 deletions src/battle_ai_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,9 @@ bool32 IsDamageMoveUnusable(u32 move, u32 battlerAtk, u32 battlerDef)
if (battlerDef == BATTLE_PARTNER(battlerAtk))
battlerDefAbility = aiData->abilities[battlerDef];

if (gBattleStruct->commandingDondozo & (1u << battlerDef))
return TRUE;

switch (battlerDefAbility)
{
case ABILITY_LIGHTNING_ROD:
Expand Down
15 changes: 14 additions & 1 deletion src/battle_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3350,6 +3350,19 @@ const u8* FaintClearSetData(u32 battler)
gBattleStruct->palaceFlags &= ~(1u << battler);
gBattleStruct->boosterEnergyActivates &= ~(1u << battler);

if (gBattleStruct->commanderActive[battler] != SPECIES_NONE)
{
u32 partner = BATTLE_PARTNER(battler);
gBattleStruct->commanderActive[battler] = SPECIES_NONE;
if (IsBattlerAlive(partner))
{
gBattleStruct->commandingDondozo &= ~(1u << partner);
gStatuses3[partner] &= ~STATUS3_COMMANDER;
BtlController_EmitSpriteInvisibility(partner, BUFFER_A, FALSE);
MarkBattlerForControllerExec(partner);
}
}

AlexOn1ine marked this conversation as resolved.
Show resolved Hide resolved
for (i = 0; i < ARRAY_COUNT(gSideTimers); i++)
{
// User of sticky web fainted, so reset the stored battler ID
Expand Down Expand Up @@ -4199,7 +4212,7 @@ static void HandleTurnActionSelectionState(void)
|| gBattleStruct->absentBattlerFlags & (1u << GetBattlerAtPosition(BATTLE_PARTNER(position)))
|| gBattleCommunication[GetBattlerAtPosition(BATTLE_PARTNER(position))] == STATE_WAIT_ACTION_CONFIRMED)
{
if (gBattleStruct->absentBattlerFlags & (1u << battler))
if (gBattleStruct->absentBattlerFlags & (1u << battler) || gBattleStruct->commandingDondozo & (1u << battler))
AlexOn1ine marked this conversation as resolved.
Show resolved Hide resolved
{
gChosenActionByBattler[battler] = B_ACTION_NOTHING_FAINTED;
if (!(gBattleTypeFlags & BATTLE_TYPE_MULTI))
Expand Down
4 changes: 3 additions & 1 deletion src/battle_message.c
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,8 @@ static const u8 sText_TargetIsBeingSaltCured[] = _("{B_DEF_NAME_WITH_PREFIX} is
static const u8 sText_TargetIsHurtBySaltCure[] = _("{B_DEF_NAME_WITH_PREFIX} is hurt by {B_BUFF1}!");
static const u8 sText_TargetCoveredInStickyCandySyrup[] = _("{B_DEF_NAME_WITH_PREFIX} got covered\nin sticky syrup!");
static const u8 sText_PkmnTellChillingReceptionJoke[] = _("{B_ATK_NAME_WITH_PREFIX} is preparing to tell a\nchillingly bad joke!");
static const u8 sText_ZeroToHeroTransformation[] = _("{B_ATK_NAME_WITH_PREFIX} underwent a heroic\ntransformation!");
static const u8 sText_ZeroToHeroTransformation[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} underwent a heroic\ntransformation!");
static const u8 sText_CommanderActivates[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} was swallowed by Dondozo\nand became Dondozo's commander!");
static const u8 sText_TheTwoMovesBecomeOne[] = _("The two moves become one!\nIt's a combined move!{PAUSE 16}");
static const u8 sText_ARainbowAppearedOnSide[] = _("A rainbow appeared in the sky\non {B_ATK_TEAM2} team's side!");
static const u8 sText_TheRainbowDisappeared[] = _("The rainbow on {B_ATK_TEAM2}\nside disappeared!");
Expand Down Expand Up @@ -870,6 +871,7 @@ const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] =
[STRINGID_ARAINBOWAPPEAREDONSIDE - BATTLESTRINGS_TABLE_START] = sText_ARainbowAppearedOnSide,
[STRINGID_THETWOMOVESBECOMEONE - BATTLESTRINGS_TABLE_START] = sText_TheTwoMovesBecomeOne,
[STRINGID_ZEROTOHEROTRANSFORMATION - BATTLESTRINGS_TABLE_START] = sText_ZeroToHeroTransformation,
[STRINGID_COMMANDERACTIVATES - BATTLESTRINGS_TABLE_START] = sText_CommanderActivates,
[STRINGID_PKMNTELLCHILLINGRECEPTIONJOKE - BATTLESTRINGS_TABLE_START] = sText_PkmnTellChillingReceptionJoke,
[STRINGID_MOVEBLOCKEDBYDYNAMAX - BATTLESTRINGS_TABLE_START] = sText_MoveBlockedByDynamax,
[STRINGID_TARGETISHURTBYSALTCURE - BATTLESTRINGS_TABLE_START] = sText_TargetIsHurtBySaltCure,
Expand Down
Loading
Loading