Skip to content

Commit

Permalink
Fixes to Opportunist and Mirror Herb adjustments (rh-hideout#4928)
Browse files Browse the repository at this point in the history
* Replace Opportunist todo tests with proper tests

* add failing test

* desc

* Fixes to Opportunist and Mirror Herb adjustments

* more tests

* some fixes

* first turn events switch

* simple enum + revert test desc
  • Loading branch information
AlexOn1ine authored Jul 19, 2024
1 parent 93ee3a9 commit 552e276
Show file tree
Hide file tree
Showing 11 changed files with 525 additions and 179 deletions.
6 changes: 6 additions & 0 deletions asm/macros/battle_script.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1639,6 +1639,12 @@
.4byte \failInstr
.endm

.macro copyfoesstatincrease battler:req, failInstr:req
callnative BS_CopyFoesStatIncrease
.byte \battler
.4byte \failInstr
.endm

@ various command changed to more readable macros
.macro cancelmultiturnmoves battler:req
various \battler, VARIOUS_CANCEL_MULTI_TURN_MOVES
Expand Down
21 changes: 14 additions & 7 deletions data/battle_scripts_1.s
Original file line number Diff line number Diff line change
Expand Up @@ -9100,7 +9100,6 @@ BattleScript_TotemFlaredToLife::
call BattleScript_ApplyTotemVarBoost
end2

@ remove the mirror herb, do totem loop
BattleScript_MirrorHerbCopyStatChangeEnd2::
call BattleScript_MirrorHerbCopyStatChange
end2
Expand All @@ -9110,16 +9109,24 @@ BattleScript_MirrorHerbCopyStatChange::
printstring STRINGID_MIRRORHERBCOPIED
waitmessage B_WAIT_TIME_LONG
removeitem BS_SCRIPTING
call BattleScript_TotemVar_Ret
copybyte gBattlerAttacker, sSAVED_BATTLER @ restore the original attacker just to be safe
playanimation BS_SCRIPTING, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1
BattleScript_MirrorHerbStartCopyStats:
copyfoesstatincrease BS_SCRIPTING, BattleScript_MirrorHerbStartReturn
statbuffchange STAT_CHANGE_ALLOW_PTR, BattleScript_MirrorHerbStartReturn
goto BattleScript_MirrorHerbStartCopyStats
BattleScript_MirrorHerbStartReturn:
return

BattleScript_OpportunistCopyStatChange::
call BattleScript_AbilityPopUp
printstring STRINGID_OPPORTUNISTCOPIED
call BattleScript_AbilityPopUpScripting
playanimation BS_SCRIPTING, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1
BattleScript_OpportunistStartCopyStats:
copyfoesstatincrease BS_SCRIPTING, BattleScript_OpportunistCopyStatChangeEnd
statbuffchange STAT_CHANGE_ALLOW_PTR, BattleScript_OpportunistCopyStatChangeEnd
printfromtable gStatUpStringIds
waitmessage B_WAIT_TIME_LONG
call BattleScript_TotemVar_Ret
copybyte gBattlerAttacker, sSAVED_BATTLER @ restore the original attacker just to be safe
goto BattleScript_OpportunistStartCopyStats
BattleScript_OpportunistCopyStatChangeEnd:
end3

BattleScript_TotemVar::
Expand Down
4 changes: 2 additions & 2 deletions include/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ struct BattleStruct
u8 moneyMultiplierItem:1;
u8 moneyMultiplierMove:1;
u8 savedTurnActionNumber;
u8 switchInAbilitiesCounter;
u8 eventsBeforeFirstTurnState;
u8 faintedActionsState;
u8 faintedActionsBattlerId;
u8 scriptPartyIdx; // for printing the nickname
Expand Down Expand Up @@ -672,7 +672,7 @@ struct BattleStruct
u16 chosenItem[MAX_BATTLERS_COUNT];
u16 choicedMove[MAX_BATTLERS_COUNT];
u16 changedItems[MAX_BATTLERS_COUNT];
u8 switchInItemsCounter;
u8 switchInBattlerCounter;
u8 arenaTurnCounter;
u8 turnSideTracker;
u16 lastTakenMoveFrom[MAX_BATTLERS_COUNT][MAX_BATTLERS_COUNT]; // a 2-D array [target][attacker]
Expand Down
14 changes: 14 additions & 0 deletions include/battle_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,20 @@ struct MultiPartnerMenuPokemon
#define BOUNCE_MON 0x0
#define BOUNCE_HEALTHBOX 0x1

enum {
FIRST_TURN_EVENTS_START,
FIRST_TURN_EVENTS_OVERWORLD_WEATHER,
FIRST_TURN_EVENTS_TERRAIN,
FIRST_TURN_EVENTS_STARTING_STATUS,
FIRST_TURN_EVENTS_TOTEM_BOOST,
FIRST_TURN_EVENTS_NEUTRALIZING_GAS,
FIRST_TURN_EVENTS_SWITCH_IN_ABILITIES,
FIRST_TURN_EVENTS_OPPORTUNIST_1,
FIRST_TURN_EVENTS_ITEM_EFFECTS,
FIRST_TURN_EVENTS_OPPORTUNIST_2,
FIRST_TURN_EVENTS_END,
};

void CB2_InitBattle(void);
void BattleMainCB2(void);
void CB2_QuitRecordedBattle(void);
Expand Down
75 changes: 37 additions & 38 deletions include/constants/battle_string_ids.h
Original file line number Diff line number Diff line change
Expand Up @@ -670,45 +670,44 @@
#define STRINGID_CURRENTMOVECANTSELECT 668
#define STRINGID_TARGETISBEINGSALTCURED 669
#define STRINGID_TARGETISHURTBYSALTCURE 670
#define STRINGID_OPPORTUNISTCOPIED 671
#define STRINGID_TARGETCOVEREDINSTICKYCANDYSYRUP 672
#define STRINGID_SHARPSTEELFLOATS 673
#define STRINGID_SHARPSTEELDMG 674
#define STRINGID_PKMNBLEWAWAYSHARPSTEEL 675
#define STRINGID_SHARPSTEELDISAPPEAREDFROMTEAM 676
#define STRINGID_TEAMTRAPPEDWITHVINES 677
#define STRINGID_PKMNHURTBYVINES 678
#define STRINGID_TEAMCAUGHTINVORTEX 679
#define STRINGID_PKMNHURTBYVORTEX 680
#define STRINGID_TEAMSURROUNDEDBYFIRE 681
#define STRINGID_PKMNBURNINGUP 682
#define STRINGID_TEAMSURROUNDEDBYROCKS 683
#define STRINGID_PKMNHURTBYROCKSTHROWN 684
#define STRINGID_MOVEBLOCKEDBYDYNAMAX 685
#define STRINGID_ZEROTOHEROTRANSFORMATION 686
#define STRINGID_THETWOMOVESBECOMEONE 687
#define STRINGID_ARAINBOWAPPEAREDONSIDE 688
#define STRINGID_THERAINBOWDISAPPEARED 689
#define STRINGID_WAITINGFORPARTNERSMOVE 690
#define STRINGID_SEAOFFIREENVELOPEDSIDE 691
#define STRINGID_HURTBYTHESEAOFFIRE 692
#define STRINGID_THESEAOFFIREDISAPPEARED 693
#define STRINGID_SWAMPENVELOPEDSIDE 694
#define STRINGID_THESWAMPDISAPPEARED 695
#define STRINGID_PKMNTELLCHILLINGRECEPTIONJOKE 696
#define STRINGID_HOSPITALITYRESTORATION 697
#define STRINGID_ELECTROSHOTCHARGING 698
#define STRINGID_ITEMWASUSEDUP 699
#define STRINGID_ATTACKERLOSTITSTYPE 700
#define STRINGID_SHEDITSTAIL 701
#define STRINGID_CLOAKEDINAHARSHLIGHT 702
#define STRINGID_SUPERSWEETAROMAWAFTS 703
#define STRINGID_DIMENSIONSWERETWISTED 704
#define STRINGID_BIZARREARENACREATED 705
#define STRINGID_BIZARREAREACREATED 706
#define STRINGID_TIDYINGUPCOMPLETE 707
#define STRINGID_TARGETCOVEREDINSTICKYCANDYSYRUP 671
#define STRINGID_SHARPSTEELFLOATS 672
#define STRINGID_SHARPSTEELDMG 673
#define STRINGID_PKMNBLEWAWAYSHARPSTEEL 674
#define STRINGID_SHARPSTEELDISAPPEAREDFROMTEAM 675
#define STRINGID_TEAMTRAPPEDWITHVINES 676
#define STRINGID_PKMNHURTBYVINES 677
#define STRINGID_TEAMCAUGHTINVORTEX 678
#define STRINGID_PKMNHURTBYVORTEX 679
#define STRINGID_TEAMSURROUNDEDBYFIRE 680
#define STRINGID_PKMNBURNINGUP 681
#define STRINGID_TEAMSURROUNDEDBYROCKS 682
#define STRINGID_PKMNHURTBYROCKSTHROWN 683
#define STRINGID_MOVEBLOCKEDBYDYNAMAX 684
#define STRINGID_ZEROTOHEROTRANSFORMATION 685
#define STRINGID_THETWOMOVESBECOMEONE 686
#define STRINGID_ARAINBOWAPPEAREDONSIDE 687
#define STRINGID_THERAINBOWDISAPPEARED 688
#define STRINGID_WAITINGFORPARTNERSMOVE 689
#define STRINGID_SEAOFFIREENVELOPEDSIDE 690
#define STRINGID_HURTBYTHESEAOFFIRE 691
#define STRINGID_THESEAOFFIREDISAPPEARED 692
#define STRINGID_SWAMPENVELOPEDSIDE 693
#define STRINGID_THESWAMPDISAPPEARED 694
#define STRINGID_PKMNTELLCHILLINGRECEPTIONJOKE 695
#define STRINGID_HOSPITALITYRESTORATION 696
#define STRINGID_ELECTROSHOTCHARGING 697
#define STRINGID_ITEMWASUSEDUP 698
#define STRINGID_ATTACKERLOSTITSTYPE 699
#define STRINGID_SHEDITSTAIL 700
#define STRINGID_CLOAKEDINAHARSHLIGHT 701
#define STRINGID_SUPERSWEETAROMAWAFTS 702
#define STRINGID_DIMENSIONSWERETWISTED 703
#define STRINGID_BIZARREARENACREATED 704
#define STRINGID_BIZARREAREACREATED 705
#define STRINGID_TIDYINGUPCOMPLETE 706

#define BATTLESTRINGS_COUNT 708
#define BATTLESTRINGS_COUNT 707

// This is the string id that gBattleStringsTable starts with.
// String ids before this (e.g. STRINGID_INTROMSG) are not in the table,
Expand Down
Loading

0 comments on commit 552e276

Please sign in to comment.