Merge pull request #1 from pret/master

Upstream
This commit is contained in:
PokeCodec 2020-07-20 17:09:02 -04:00 committed by GitHub
commit 27ac010922
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
44 changed files with 1530 additions and 1433 deletions

View File

@ -1263,8 +1263,8 @@
various \battler, VARIOUS_GET_MOVE_TARGET
.endm
.macro various4 battler:req
various \battler, 4
.macro getbattlerfainted battler:req
various \battler, VARIOUS_GET_BATTLER_FAINTED
.endm
.macro resetintimidatetracebits battler:req
@ -1279,8 +1279,8 @@
various \battler, 7
.endm
.macro various8 battler:req
various \battler, 8
.macro palaceflavortext battler:req
various \battler, VARIOUS_PALACE_FLAVOR_TEXT
.endm
.macro arenajudgmentwindow
@ -1365,11 +1365,11 @@
.endm
.macro chosenstatus1animation battler:req, status:req
chosenstatusanimation \battler 0x0 \status
chosenstatusanimation \battler, 0x0, \status
.endm
.macro chosenstatus2animation battler:req, status:req
chosenstatusanimation \battler 0x1 \status
chosenstatusanimation \battler, 0x1, \status
.endm
.macro sethword dst:req, value:req

View File

@ -12,16 +12,16 @@
.align 2
gBattleAI_ScriptsTable:: @ 82DBEF8
.4byte AI_CheckBadMove
.4byte AI_TryToFaint
.4byte AI_CheckViability
.4byte AI_SetupFirstTurn
.4byte AI_Risky
.4byte AI_PreferStrongestMove
.4byte AI_PreferBatonPass
.4byte AI_DoubleBattle
.4byte AI_HPAware
.4byte AI_Unknown
.4byte AI_CheckBadMove @ AI_SCRIPT_CHECK_BAD_MOVE
.4byte AI_TryToFaint @ AI_SCRIPT_TRY_TO_FAINT
.4byte AI_CheckViability @ AI_SCRIPT_CHECK_VIABILITY
.4byte AI_SetupFirstTurn @ AI_SCRIPT_SETUP_FIRST_TURN
.4byte AI_Risky @ AI_SCRIPT_RISKY
.4byte AI_PreferStrongestMove @ AI_SCRIPT_PREFER_STRONGEST_MOVE
.4byte AI_PreferBatonPass @ AI_SCRIPT_PREFER_BATON_PASS
.4byte AI_DoubleBattle @ AI_SCRIPT_DOUBLE_BATTLE
.4byte AI_HPAware @ AI_SCRIPT_HP_AWARE
.4byte AI_Unknown @ AI_SCRIPT_UNKNOWN
.4byte AI_Ret
.4byte AI_Ret
.4byte AI_Ret
@ -41,9 +41,9 @@ gBattleAI_ScriptsTable:: @ 82DBEF8
.4byte AI_Ret
.4byte AI_Ret
.4byte AI_Ret
.4byte AI_Roaming
.4byte AI_Safari
.4byte AI_FirstBattle
.4byte AI_Roaming @ AI_SCRIPT_ROAMING
.4byte AI_Safari @ AI_SCRIPT_SAFARI
.4byte AI_FirstBattle @ AI_SCRIPT_FIRST_BATTLE
AI_CheckBadMove:
if_target_is_ally AI_Ret

View File

@ -3153,8 +3153,8 @@ BattleScript_PursuitDmgOnSwitchOut::
waitmessage 0x40
tryfaintmon BS_TARGET, FALSE, NULL
moveendfromto MOVEEND_ON_DAMAGE_ABILITIES, MOVEEND_CHOICE_MOVE
various4 BS_TARGET
jumpifbyte CMP_EQUAL, gBattleCommunication, 0x0, BattleScript_PursuitDmgOnSwitchOutRet
getbattlerfainted BS_TARGET
jumpifbyte CMP_EQUAL, gBattleCommunication, FALSE, BattleScript_PursuitDmgOnSwitchOutRet
setbyte sGIVEEXP_STATE, 0x0
getexp BS_TARGET
BattleScript_PursuitDmgOnSwitchOutRet:
@ -4442,18 +4442,18 @@ BattleScript_FlushMessageBox::
printstring STRINGID_EMPTYSTRING3
return
BattleScript_82DB881::
setbyte gBattleCommunication + 1, 0x0
BattleScript_82DB887::
various8 BS_ATTACKER
jumpifbyte CMP_NOT_EQUAL, gBattleCommunication, 0x1, BattleScript_82DB89D
printfromtable gStringIds_85CCF0A
BattleScript_PalacePrintFlavorText::
setbyte gBattleCommunication + 1, 0
BattleScript_PalaceTryBattlerFlavorText::
palaceflavortext BS_ATTACKER @ BS_ATTACKER here overwritten by gBattleCommunication + 1
jumpifbyte CMP_NOT_EQUAL, gBattleCommunication, TRUE, BattleScript_PalaceEndFlavorText
printfromtable gBattlePalaceFlavorTextTable
waitmessage 0x40
BattleScript_82DB89D::
addbyte gBattleCommunication + 1, 0x1
jumpifbytenotequal gBattleCommunication + 1, gBattlersCount, BattleScript_82DB887
setbyte gBattleCommunication, 0x0
setbyte gBattleCommunication + 1, 0x0
BattleScript_PalaceEndFlavorText::
addbyte gBattleCommunication + 1, 1
jumpifbytenotequal gBattleCommunication + 1, gBattlersCount, BattleScript_PalaceTryBattlerFlavorText
setbyte gBattleCommunication, 0
setbyte gBattleCommunication + 1, 0
end2
BattleScript_ArenaTurnBeginning::

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 448 B

After

Width:  |  Height:  |  Size: 448 B

View File

Before

Width:  |  Height:  |  Size: 733 B

After

Width:  |  Height:  |  Size: 733 B

View File

@ -684,7 +684,7 @@ $(OBJEVENTGFXDIR)/pics/effects/unknown_4F6D38/0.4bpp: %.4bpp: %.png
$(INTERFACEGFXDIR)/selector_outline.4bpp: %.4bpp: %.png
$(GFX) $< $@ -num_tiles 8
$(BATTRANSGFXDIR)/frontier_transition.4bpp: %.4bpp: %.png
$(BATTRANSGFXDIR)/frontier_logo_center.4bpp: %.4bpp: %.png
$(GFX) $< $@ -num_tiles 43

View File

@ -390,7 +390,7 @@ struct BattleStruct
u8 expGetterBattlerId;
u8 unused_5;
u8 field_91; // related to gAbsentBattlerFlags, possibly absent flags turn ago?
u8 field_92; // battle palace related
u8 palaceFlags; // First 4 bits are "is < 50% HP and not asleep" for each battler, last 4 bits are selected moves to pass to AI
u8 field_93; // related to choosing pokemon?
u8 wallyBattleState;
u8 wallyMovesState;

View File

@ -1,6 +1,8 @@
#ifndef GUARD_BATTLE_SCRIPT_COMMANDS_H
#define GUARD_BATTLE_SCRIPT_COMMANDS_H
#include "constants/pokemon.h"
#define WINDOW_CLEAR 0x1
#define WINDOW_x80 0x80
@ -16,6 +18,6 @@ void HandleBattleWindow(u8 xStart, u8 yStart, u8 xEnd, u8 yEnd, u8 flags);
bool8 UproarWakeUpCheck(u8 battlerId);
extern void (* const gBattleScriptingCommandsTable[])(void);
extern const u8 gUnknown_0831C494[][4];
extern const u8 gBattlePalaceNatureToMoveGroupLikelihood[NUM_NATURES][4];
#endif // GUARD_BATTLE_SCRIPT_COMMANDS_H

View File

@ -205,7 +205,7 @@ extern const u8 BattleScript_BerryStatRaiseEnd2[];
extern const u8 BattleScript_BerryFocusEnergyEnd2[];
extern const u8 BattleScript_ActionSelectionItemsCantBeUsed[];
extern const u8 BattleScript_ArenaTurnBeginning[];
extern const u8 BattleScript_82DB881[];
extern const u8 BattleScript_PalacePrintFlavorText[];
extern const u8 BattleScript_ArenaDoJudgment[];
extern const u8 BattleScript_82DAA0B[];
extern const u8 BattleScript_AskIfWantsToForfeitMatch[];

View File

@ -28,7 +28,7 @@ void BattleSetup_StartLegendaryBattle(void);
void StartGroudonKyogreBattle(void);
void StartRegiBattle(void);
u8 BattleSetup_GetTerrainId(void);
u8 sub_80B100C(s32 arg0);
u8 GetSpecialBattleTransition(s32 arg0);
void ChooseStarter(void);
void ResetTrainerOpponentIds(void);
void SetMapVarsToTrainer(void);

View File

@ -24,49 +24,49 @@ enum // TRANSITION_MUGSHOT
// credits for the names go to Dyskinesia, Tetrable and Farore
// names are naturally subject to change
#define B_TRANSITION_BLUR 0
#define B_TRANSITION_SWIRL 1
#define B_TRANSITION_SHUFFLE 2
#define B_TRANSITION_BIG_POKEBALL 3
#define B_TRANSITION_POKEBALLS_TRAIL 4
#define B_TRANSITION_CLOCKWISE_BLACKFADE 5
#define B_TRANSITION_RIPPLE 6
#define B_TRANSITION_WAVE 7
#define B_TRANSITION_SLICE 8
#define B_TRANSITION_WHITEFADE 9
#define B_TRANSITION_GRID_SQUARES 10
#define B_TRANSITION_SHARDS 11
#define B_TRANSITION_SIDNEY 12
#define B_TRANSITION_PHOEBE 13
#define B_TRANSITION_GLACIA 14
#define B_TRANSITION_DRAKE 15
#define B_TRANSITION_CHAMPION 16
#define B_TRANSITION_BLUR 0
#define B_TRANSITION_SWIRL 1
#define B_TRANSITION_SHUFFLE 2
#define B_TRANSITION_BIG_POKEBALL 3
#define B_TRANSITION_POKEBALLS_TRAIL 4
#define B_TRANSITION_CLOCKWISE_BLACKFADE 5
#define B_TRANSITION_RIPPLE 6
#define B_TRANSITION_WAVE 7
#define B_TRANSITION_SLICE 8
#define B_TRANSITION_WHITEFADE 9
#define B_TRANSITION_GRID_SQUARES 10
#define B_TRANSITION_SHARDS 11
#define B_TRANSITION_SIDNEY 12
#define B_TRANSITION_PHOEBE 13
#define B_TRANSITION_GLACIA 14
#define B_TRANSITION_DRAKE 15
#define B_TRANSITION_CHAMPION 16
// added in Emerald
#define B_TRANSITION_AQUA 17
#define B_TRANSITION_MAGMA 18
#define B_TRANSITION_REGICE 19
#define B_TRANSITION_REGISTEEL 20
#define B_TRANSITION_REGIROCK 21
#define B_TRANSITION_KYOGRE 22
#define B_TRANSITION_GROUDON 23
#define B_TRANSITION_RAYQUAZA 24
#define B_TRANSITION_SHRED_SPLIT 25
#define B_TRANSITION_BLACKHOLE1 26
#define B_TRANSITION_BLACKHOLE2 27
#define B_TRANSITION_RECTANGULAR_SPIRAL 28
#define B_TRANSITION_29 29
#define B_TRANSITION_30 30
#define B_TRANSITION_31 31
#define B_TRANSITION_32 32
#define B_TRANSITION_33 33
#define B_TRANSITION_34 34
#define B_TRANSITION_35 35
#define B_TRANSITION_36 36
#define B_TRANSITION_37 37
#define B_TRANSITION_38 38
#define B_TRANSITION_39 39
#define B_TRANSITION_40 40
#define B_TRANSITION_41 41
#define B_TRANSITION_COUNT 42
#define B_TRANSITION_AQUA 17
#define B_TRANSITION_MAGMA 18
#define B_TRANSITION_REGICE 19
#define B_TRANSITION_REGISTEEL 20
#define B_TRANSITION_REGIROCK 21
#define B_TRANSITION_KYOGRE 22
#define B_TRANSITION_GROUDON 23
#define B_TRANSITION_RAYQUAZA 24
#define B_TRANSITION_SHRED_SPLIT 25
#define B_TRANSITION_BLACKHOLE1 26
#define B_TRANSITION_BLACKHOLE2 27
#define B_TRANSITION_RECTANGULAR_SPIRAL 28
#define B_TRANSITION_FRONTIER_LOGO_WIGGLE 29
#define B_TRANSITION_FRONTIER_LOGO_WAVE 30
#define B_TRANSITION_FRONTIER_SQUARES 31
#define B_TRANSITION_FRONTIER_SQUARES_SCROLL 32
#define B_TRANSITION_FRONTIER_SQUARES_SPIRAL 33
#define B_TRANSITION_FRONTIER_CIRCLES_MEET 34
#define B_TRANSITION_FRONTIER_CIRCLES_CROSS 35
#define B_TRANSITION_FRONTIER_CIRCLES_ASYMMETRIC_SPIRAL 36
#define B_TRANSITION_FRONTIER_CIRCLES_SYMMETRIC_SPIRAL 37
#define B_TRANSITION_FRONTIER_CIRCLES_MEET_IN_SEQ 38
#define B_TRANSITION_FRONTIER_CIRCLES_CROSS_IN_SEQ 39
#define B_TRANSITION_FRONTIER_CIRCLES_ASYMMETRIC_SPIRAL_IN_SEQ 40
#define B_TRANSITION_FRONTIER_CIRCLES_SYMMETRIC_SPIRAL_IN_SEQ 41
#define B_TRANSITION_COUNT 42
#endif // GUARD_BATTLE_TRANSITION_H

View File

@ -0,0 +1,13 @@
#ifndef GUARD_BATTLE_TRANSITION_FRONTIER_H
#define GUARD_BATTLE_TRANSITION_FRONTIER_H
void Phase2Task_FrontierCirclesMeet(u8 taskId);
void Phase2Task_FrontierCirclesCross(u8 taskId);
void Phase2Task_FrontierCirclesAsymmetricSpiral(u8 taskId);
void Phase2Task_FrontierCirclesSymmetricSpiral(u8 taskId);
void Phase2Task_FrontierCirclesMeetInSeq(u8 taskId);
void Phase2Task_FrontierCirclesCrossInSeq(u8 taskId);
void Phase2Task_FrontierCirclesAsymmetricSpiralInSeq(u8 taskId);
void Phase2Task_FrontierCirclesSymmetricSpiralInSeq(u8 taskId);
#endif // GUARD_BATTLE_TRANSITION_FRONTIER_H

View File

@ -37,146 +37,156 @@
#define B_SIDE_PLAYER 0
#define B_SIDE_OPPONENT 1
#define B_FLANK_LEFT 0
#define B_FLANK_LEFT 0
#define B_FLANK_RIGHT 1
#define BIT_SIDE 1
#define BIT_FLANK 2
// Battle Type Flags
#define BATTLE_TYPE_DOUBLE 0x0001
#define BATTLE_TYPE_LINK 0x0002
#define BATTLE_TYPE_IS_MASTER 0x0004 // In not-link battles, it's always set.
#define BATTLE_TYPE_TRAINER 0x0008
#define BATTLE_TYPE_FIRST_BATTLE 0x0010
#define BATTLE_TYPE_20 0x0020
#define BATTLE_TYPE_MULTI 0x0040
#define BATTLE_TYPE_SAFARI 0x0080
#define BATTLE_TYPE_BATTLE_TOWER 0x0100
#define BATTLE_TYPE_WALLY_TUTORIAL 0x0200
#define BATTLE_TYPE_ROAMER 0x0400
#define BATTLE_TYPE_EREADER_TRAINER 0x0800
#define BATTLE_TYPE_KYOGRE_GROUDON 0x1000
#define BATTLE_TYPE_LEGENDARY 0x2000
#define BATTLE_TYPE_REGI 0x4000
#define BATTLE_TYPE_TWO_OPPONENTS 0x8000
#define BATTLE_TYPE_DOME 0x10000
#define BATTLE_TYPE_PALACE 0x20000
#define BATTLE_TYPE_ARENA 0x40000
#define BATTLE_TYPE_FACTORY 0x80000
#define BATTLE_TYPE_PIKE 0x100000
#define BATTLE_TYPE_PYRAMID 0x200000
#define BATTLE_TYPE_INGAME_PARTNER 0x400000
#define BATTLE_TYPE_x800000 0x800000
#define BATTLE_TYPE_RECORDED 0x1000000
#define BATTLE_TYPE_x2000000 0x2000000
#define BATTLE_TYPE_TRAINER_HILL 0x4000000
#define BATTLE_TYPE_SECRET_BASE 0x8000000
#define BATTLE_TYPE_GROUDON 0x10000000
#define BATTLE_TYPE_KYOGRE 0x20000000
#define BATTLE_TYPE_RAYQUAZA 0x40000000
#define BATTLE_TYPE_x80000000 0x80000000
#define BATTLE_TYPE_DOUBLE (1 << 0)
#define BATTLE_TYPE_LINK (1 << 1)
#define BATTLE_TYPE_IS_MASTER (1 << 2) // In not-link battles, it's always set.
#define BATTLE_TYPE_TRAINER (1 << 3)
#define BATTLE_TYPE_FIRST_BATTLE (1 << 4)
#define BATTLE_TYPE_20 (1 << 5)
#define BATTLE_TYPE_MULTI (1 << 6)
#define BATTLE_TYPE_SAFARI (1 << 7)
#define BATTLE_TYPE_BATTLE_TOWER (1 << 8)
#define BATTLE_TYPE_WALLY_TUTORIAL (1 << 9)
#define BATTLE_TYPE_ROAMER (1 << 10)
#define BATTLE_TYPE_EREADER_TRAINER (1 << 11)
#define BATTLE_TYPE_KYOGRE_GROUDON (1 << 12)
#define BATTLE_TYPE_LEGENDARY (1 << 13)
#define BATTLE_TYPE_REGI (1 << 14)
#define BATTLE_TYPE_TWO_OPPONENTS (1 << 15)
#define BATTLE_TYPE_DOME (1 << 16)
#define BATTLE_TYPE_PALACE (1 << 17)
#define BATTLE_TYPE_ARENA (1 << 18)
#define BATTLE_TYPE_FACTORY (1 << 19)
#define BATTLE_TYPE_PIKE (1 << 20)
#define BATTLE_TYPE_PYRAMID (1 << 21)
#define BATTLE_TYPE_INGAME_PARTNER (1 << 22)
#define BATTLE_TYPE_x800000 (1 << 23)
#define BATTLE_TYPE_RECORDED (1 << 24)
#define BATTLE_TYPE_x2000000 (1 << 25)
#define BATTLE_TYPE_TRAINER_HILL (1 << 26)
#define BATTLE_TYPE_SECRET_BASE (1 << 27)
#define BATTLE_TYPE_GROUDON (1 << 28)
#define BATTLE_TYPE_KYOGRE (1 << 29)
#define BATTLE_TYPE_RAYQUAZA (1 << 30)
#define BATTLE_TYPE_x80000000 (1 << 31)
#define BATTLE_TYPE_FRONTIER (BATTLE_TYPE_BATTLE_TOWER | BATTLE_TYPE_DOME | BATTLE_TYPE_PALACE | BATTLE_TYPE_ARENA | BATTLE_TYPE_FACTORY | BATTLE_TYPE_PIKE | BATTLE_TYPE_PYRAMID)
#define BATTLE_TYPE_FRONTIER_NO_PYRAMID (BATTLE_TYPE_BATTLE_TOWER | BATTLE_TYPE_DOME | BATTLE_TYPE_PALACE | BATTLE_TYPE_ARENA | BATTLE_TYPE_FACTORY | BATTLE_TYPE_PIKE)
// Battle Outcome defines
#define B_OUTCOME_WON 0x1
#define B_OUTCOME_LOST 0x2
#define B_OUTCOME_DREW 0x3
#define B_OUTCOME_RAN 0x4
#define B_OUTCOME_PLAYER_TELEPORTED 0x5
#define B_OUTCOME_MON_FLED 0x6
#define B_OUTCOME_CAUGHT 0x7
#define B_OUTCOME_NO_SAFARI_BALLS 0x8
#define B_OUTCOME_FORFEITED 0x9
#define B_OUTCOME_MON_TELEPORTED 0xA
#define B_OUTCOME_LINK_BATTLE_RAN 0x80
#define B_OUTCOME_WON 1
#define B_OUTCOME_LOST 2
#define B_OUTCOME_DREW 3
#define B_OUTCOME_RAN 4
#define B_OUTCOME_PLAYER_TELEPORTED 5
#define B_OUTCOME_MON_FLED 6
#define B_OUTCOME_CAUGHT 7
#define B_OUTCOME_NO_SAFARI_BALLS 8
#define B_OUTCOME_FORFEITED 9
#define B_OUTCOME_MON_TELEPORTED 10
#define B_OUTCOME_LINK_BATTLE_RAN (1 << 7) // 128
// Non-volatile status conditions
// These persist remain outside of battle and after switching out
#define STATUS1_NONE 0x0
#define STATUS1_SLEEP 0x7
#define STATUS1_POISON 0x8
#define STATUS1_BURN 0x10
#define STATUS1_FREEZE 0x20
#define STATUS1_PARALYSIS 0x40
#define STATUS1_TOXIC_POISON 0x80
#define STATUS1_TOXIC_COUNTER 0xF00
#define STATUS1_NONE 0
#define STATUS1_SLEEP (1 << 0 | 1 << 1 | 1 << 2) // First 3 bits (Number of turns to sleep)
#define STATUS1_SLEEP_TURN(num) ((num) << 0) // Just for readability (or if rearranging statuses)
#define STATUS1_POISON (1 << 3)
#define STATUS1_BURN (1 << 4)
#define STATUS1_FREEZE (1 << 5)
#define STATUS1_PARALYSIS (1 << 6)
#define STATUS1_TOXIC_POISON (1 << 7)
#define STATUS1_TOXIC_COUNTER (1 << 8 | 1 << 9 | 1 << 10 | 1 << 11)
#define STATUS1_TOXIC_TURN(num) ((num) << 8)
#define STATUS1_PSN_ANY (STATUS1_POISON | STATUS1_TOXIC_POISON)
#define STATUS1_ANY (STATUS1_SLEEP | STATUS1_POISON | STATUS1_BURN | STATUS1_FREEZE | STATUS1_PARALYSIS | STATUS1_TOXIC_POISON)
// Volatile status ailments
// These are removed after exiting the battle or switching out
#define STATUS2_CONFUSION 0x00000007
#define STATUS2_FLINCHED 0x00000008
#define STATUS2_UPROAR 0x00000070
#define STATUS2_BIDE 0x00000300 // two bits 0x100, 0x200
#define STATUS2_LOCK_CONFUSE 0x00000C00
#define STATUS2_MULTIPLETURNS 0x00001000
#define STATUS2_WRAPPED 0x0000E000
#define STATUS2_INFATUATION 0x000F0000 // 4 bits, one for every battler
#define STATUS2_CONFUSION (1 << 0 | 1 << 1 | 1 << 2)
#define STATUS2_CONFUSION_TURN(num) ((num) << 0)
#define STATUS2_FLINCHED (1 << 3)
#define STATUS2_UPROAR (1 << 4 | 1 << 5 | 1 << 6)
#define STATUS2_UPROAR_TURN(num) ((num) << 4)
#define STATUS2_UNUSED (1 << 7)
#define STATUS2_BIDE (1 << 8 | 1 << 9)
#define STATUS2_BIDE_TURN(num) (((num) << 8) & STATUS2_BIDE)
#define STATUS2_LOCK_CONFUSE (1 << 10 | 1 << 11) // e.g. Thrash
#define STATUS2_LOCK_CONFUSE_TURN(num)((num) << 10)
#define STATUS2_MULTIPLETURNS (1 << 12)
#define STATUS2_WRAPPED (1 << 13 | 1 << 14 | 1 << 15)
#define STATUS2_WRAPPED_TURN(num) ((num) << 13)
#define STATUS2_INFATUATION (1 << 16 | 1 << 17 | 1 << 18 | 1 << 19) // 4 bits, one for every battler
#define STATUS2_INFATUATED_WITH(battler) (gBitTable[battler] << 16)
#define STATUS2_FOCUS_ENERGY 0x00100000
#define STATUS2_TRANSFORMED 0x00200000
#define STATUS2_RECHARGE 0x00400000
#define STATUS2_RAGE 0x00800000
#define STATUS2_SUBSTITUTE 0x01000000
#define STATUS2_DESTINY_BOND 0x02000000
#define STATUS2_ESCAPE_PREVENTION 0x04000000
#define STATUS2_NIGHTMARE 0x08000000
#define STATUS2_CURSED 0x10000000
#define STATUS2_FORESIGHT 0x20000000
#define STATUS2_DEFENSE_CURL 0x40000000
#define STATUS2_TORMENT 0x80000000
#define STATUS2_FOCUS_ENERGY (1 << 20)
#define STATUS2_TRANSFORMED (1 << 21)
#define STATUS2_RECHARGE (1 << 22)
#define STATUS2_RAGE (1 << 23)
#define STATUS2_SUBSTITUTE (1 << 24)
#define STATUS2_DESTINY_BOND (1 << 25)
#define STATUS2_ESCAPE_PREVENTION (1 << 26)
#define STATUS2_NIGHTMARE (1 << 27)
#define STATUS2_CURSED (1 << 28)
#define STATUS2_FORESIGHT (1 << 29)
#define STATUS2_DEFENSE_CURL (1 << 30)
#define STATUS2_TORMENT (1 << 31)
// Seems like per-battler statuses. Not quite sure how to categorize these
#define STATUS3_LEECHSEED_BATTLER 0x3
#define STATUS3_LEECHSEED 0x4
#define STATUS3_ALWAYS_HITS 0x18 // two bits
#define STATUS3_PERISH_SONG 0x20
#define STATUS3_ON_AIR 0x40
#define STATUS3_UNDERGROUND 0x80
#define STATUS3_MINIMIZED 0x100
#define STATUS3_ROOTED 0x400
#define STATUS3_CHARGED_UP 0x200
#define STATUS3_YAWN 0x1800 // two bits
#define STATUS3_IMPRISONED_OTHERS 0x2000
#define STATUS3_GRUDGE 0x4000
#define STATUS3_CANT_SCORE_A_CRIT 0x8000
#define STATUS3_MUDSPORT 0x10000
#define STATUS3_WATERSPORT 0x20000
#define STATUS3_UNDERWATER 0x40000
#define STATUS3_INTIMIDATE_POKES 0x80000
#define STATUS3_TRACE 0x100000
#define STATUS3_LEECHSEED_BATTLER (1 << 0 | 1 << 1) // The battler to receive HP from Leech Seed
#define STATUS3_LEECHSEED (1 << 2)
#define STATUS3_ALWAYS_HITS (1 << 3 | 1 << 4)
#define STATUS3_ALWAYS_HITS_TURN(num) (((num) << 3) & STATUS3_ALWAYS_HITS) // "Always Hits" is set as a 2 turn timer, i.e. next turn is the last turn when it's active
#define STATUS3_PERISH_SONG (1 << 5)
#define STATUS3_ON_AIR (1 << 6)
#define STATUS3_UNDERGROUND (1 << 7)
#define STATUS3_MINIMIZED (1 << 8)
#define STATUS3_CHARGED_UP (1 << 9)
#define STATUS3_ROOTED (1 << 10)
#define STATUS3_YAWN (1 << 11 | 1 << 12) // Number of turns to sleep
#define STATUS3_YAWN_TURN(num) (((num) << 11) & STATUS3_YAWN)
#define STATUS3_IMPRISONED_OTHERS (1 << 13)
#define STATUS3_GRUDGE (1 << 14)
#define STATUS3_CANT_SCORE_A_CRIT (1 << 15)
#define STATUS3_MUDSPORT (1 << 16)
#define STATUS3_WATERSPORT (1 << 17)
#define STATUS3_UNDERWATER (1 << 18)
#define STATUS3_INTIMIDATE_POKES (1 << 19)
#define STATUS3_TRACE (1 << 20)
#define STATUS3_SEMI_INVULNERABLE (STATUS3_UNDERGROUND | STATUS3_ON_AIR | STATUS3_UNDERWATER)
// Not really sure what a "hitmarker" is.
#define HITMARKER_x10 0x00000010
#define HITMARKER_x20 0x00000020
#define HITMARKER_DESTINYBOND 0x00000040
#define HITMARKER_NO_ANIMATIONS 0x00000080
#define HITMARKER_IGNORE_SUBSTITUTE 0x00000100
#define HITMARKER_NO_ATTACKSTRING 0x00000200
#define HITMARKER_ATTACKSTRING_PRINTED 0x00000400
#define HITMARKER_NO_PPDEDUCT 0x00000800
#define HITMARKER_SWAP_ATTACKER_TARGET 0x00001000
#define HITMARKER_IGNORE_SAFEGUARD 0x00002000
#define HITMARKER_SYNCHRONISE_EFFECT 0x00004000
#define HITMARKER_RUN 0x00008000
#define HITMARKER_IGNORE_ON_AIR 0x00010000
#define HITMARKER_IGNORE_UNDERGROUND 0x00020000
#define HITMARKER_IGNORE_UNDERWATER 0x00040000
#define HITMARKER_UNABLE_TO_USE_MOVE 0x00080000
#define HITMARKER_x100000 0x00100000
#define HITMARKER_x200000 0x00200000
#define HITMARKER_x400000 0x00400000
#define HITMARKER_x800000 0x00800000
#define HITMARKER_GRUDGE 0x01000000
#define HITMARKER_OBEYS 0x02000000
#define HITMARKER_x4000000 0x04000000
#define HITMARKER_CHARGING 0x08000000
#define HITMARKER_FAINTED(battler) (gBitTable[battler] << 0x1C)
#define HITMARKER_UNK(battler) (0x10000000 << battler)
#define HITMARKER_x10 (1 << 4)
#define HITMARKER_x20 (1 << 5)
#define HITMARKER_DESTINYBOND (1 << 6)
#define HITMARKER_NO_ANIMATIONS (1 << 7)
#define HITMARKER_IGNORE_SUBSTITUTE (1 << 8)
#define HITMARKER_NO_ATTACKSTRING (1 << 9)
#define HITMARKER_ATTACKSTRING_PRINTED (1 << 10)
#define HITMARKER_NO_PPDEDUCT (1 << 11)
#define HITMARKER_SWAP_ATTACKER_TARGET (1 << 12)
#define HITMARKER_IGNORE_SAFEGUARD (1 << 13)
#define HITMARKER_SYNCHRONISE_EFFECT (1 << 14)
#define HITMARKER_RUN (1 << 15)
#define HITMARKER_IGNORE_ON_AIR (1 << 16)
#define HITMARKER_IGNORE_UNDERGROUND (1 << 17)
#define HITMARKER_IGNORE_UNDERWATER (1 << 18)
#define HITMARKER_UNABLE_TO_USE_MOVE (1 << 19)
#define HITMARKER_x100000 (1 << 20)
#define HITMARKER_x200000 (1 << 21)
#define HITMARKER_x400000 (1 << 22)
#define HITMARKER_x800000 (1 << 23)
#define HITMARKER_GRUDGE (1 << 24)
#define HITMARKER_OBEYS (1 << 25)
#define HITMARKER_x4000000 (1 << 26)
#define HITMARKER_CHARGING (1 << 27)
#define HITMARKER_FAINTED(battler) (gBitTable[battler] << 28)
#define HITMARKER_FAINTED2(battler) (1 << (28 + battler))
// Per-side statuses that affect an entire party
#define SIDE_STATUS_REFLECT (1 << 0)
@ -215,71 +225,70 @@
#define WEATHER_ANY (WEATHER_RAIN_ANY | WEATHER_SANDSTORM_ANY | WEATHER_SUN_ANY | WEATHER_HAIL_ANY)
// Move Effects
#define MOVE_EFFECT_SLEEP 0x1
#define MOVE_EFFECT_POISON 0x2
#define MOVE_EFFECT_BURN 0x3
#define MOVE_EFFECT_FREEZE 0x4
#define MOVE_EFFECT_PARALYSIS 0x5
#define MOVE_EFFECT_TOXIC 0x6
#define MOVE_EFFECT_CONFUSION 0x7
#define MOVE_EFFECT_FLINCH 0x8
#define MOVE_EFFECT_TRI_ATTACK 0x9
#define MOVE_EFFECT_UPROAR 0xA
#define MOVE_EFFECT_PAYDAY 0xB
#define MOVE_EFFECT_CHARGING 0xC
#define MOVE_EFFECT_WRAP 0xD
#define MOVE_EFFECT_RECOIL_25 0xE
#define MOVE_EFFECT_ATK_PLUS_1 0xF
#define MOVE_EFFECT_DEF_PLUS_1 0x10
#define MOVE_EFFECT_SPD_PLUS_1 0x11
#define MOVE_EFFECT_SP_ATK_PLUS_1 0x12
#define MOVE_EFFECT_SP_DEF_PLUS_1 0x13
#define MOVE_EFFECT_ACC_PLUS_1 0x14
#define MOVE_EFFECT_EVS_PLUS_1 0x15
#define MOVE_EFFECT_ATK_MINUS_1 0x16
#define MOVE_EFFECT_DEF_MINUS_1 0x17
#define MOVE_EFFECT_SPD_MINUS_1 0x18
#define MOVE_EFFECT_SP_ATK_MINUS_1 0x19
#define MOVE_EFFECT_SP_DEF_MINUS_1 0x1A
#define MOVE_EFFECT_ACC_MINUS_1 0x1B
#define MOVE_EFFECT_EVS_MINUS_1 0x1C
#define MOVE_EFFECT_RECHARGE 0x1D
#define MOVE_EFFECT_RAGE 0x1E
#define MOVE_EFFECT_STEAL_ITEM 0x1F
#define MOVE_EFFECT_PREVENT_ESCAPE 0x20
#define MOVE_EFFECT_NIGHTMARE 0x21
#define MOVE_EFFECT_ALL_STATS_UP 0x22
#define MOVE_EFFECT_RAPIDSPIN 0x23
#define MOVE_EFFECT_REMOVE_PARALYSIS 0x24
#define MOVE_EFFECT_ATK_DEF_DOWN 0x25
#define MOVE_EFFECT_RECOIL_33 0x26
#define MOVE_EFFECT_ATK_PLUS_2 0x27
#define MOVE_EFFECT_DEF_PLUS_2 0x28
#define MOVE_EFFECT_SPD_PLUS_2 0x29
#define MOVE_EFFECT_SP_ATK_PLUS_2 0x2A
#define MOVE_EFFECT_SP_DEF_PLUS_2 0x2B
#define MOVE_EFFECT_ACC_PLUS_2 0x2C
#define MOVE_EFFECT_EVS_PLUS_2 0x2D
#define MOVE_EFFECT_ATK_MINUS_2 0x2E
#define MOVE_EFFECT_DEF_MINUS_2 0x2F
#define MOVE_EFFECT_SPD_MINUS_2 0x30
#define MOVE_EFFECT_SP_ATK_MINUS_2 0x31
#define MOVE_EFFECT_SP_DEF_MINUS_2 0x32
#define MOVE_EFFECT_ACC_MINUS_2 0x33
#define MOVE_EFFECT_EVS_MINUS_2 0x34
#define MOVE_EFFECT_THRASH 0x35
#define MOVE_EFFECT_KNOCK_OFF 0x36
#define MOVE_EFFECT_NOTHING_37 0x37
#define MOVE_EFFECT_NOTHING_38 0x38
#define MOVE_EFFECT_NOTHING_39 0x39
#define MOVE_EFFECT_NOTHING_3A 0x3A
#define MOVE_EFFECT_SP_ATK_TWO_DOWN 0x3B
#define MOVE_EFFECT_NOTHING_3C 0x3C
#define MOVE_EFFECT_NOTHING_3D 0x3D
#define MOVE_EFFECT_NOTHING_3E 0x3E
#define MOVE_EFFECT_NOTHING_3F 0x3F
#define MOVE_EFFECT_AFFECTS_USER 0x40
#define MOVE_EFFECT_CERTAIN 0x80
#define MOVE_EFFECT_SLEEP 1
#define MOVE_EFFECT_POISON 2
#define MOVE_EFFECT_BURN 3
#define MOVE_EFFECT_FREEZE 4
#define MOVE_EFFECT_PARALYSIS 5
#define MOVE_EFFECT_TOXIC 6
#define PRIMARY_STATUS_MOVE_EFFECT MOVE_EFFECT_TOXIC // All above move effects apply primary status
#define MOVE_EFFECT_CONFUSION 7
#define MOVE_EFFECT_FLINCH 8
#define MOVE_EFFECT_TRI_ATTACK 9
#define MOVE_EFFECT_UPROAR 10
#define MOVE_EFFECT_PAYDAY 11
#define MOVE_EFFECT_CHARGING 12
#define MOVE_EFFECT_WRAP 13
#define MOVE_EFFECT_RECOIL_25 14
#define MOVE_EFFECT_ATK_PLUS_1 15
#define MOVE_EFFECT_DEF_PLUS_1 16
#define MOVE_EFFECT_SPD_PLUS_1 17
#define MOVE_EFFECT_SP_ATK_PLUS_1 18
#define MOVE_EFFECT_SP_DEF_PLUS_1 19
#define MOVE_EFFECT_ACC_PLUS_1 20
#define MOVE_EFFECT_EVS_PLUS_1 21
#define MOVE_EFFECT_ATK_MINUS_1 22
#define MOVE_EFFECT_DEF_MINUS_1 23
#define MOVE_EFFECT_SPD_MINUS_1 24
#define MOVE_EFFECT_SP_ATK_MINUS_1 25
#define MOVE_EFFECT_SP_DEF_MINUS_1 26
#define MOVE_EFFECT_ACC_MINUS_1 27
#define MOVE_EFFECT_EVS_MINUS_1 28
#define MOVE_EFFECT_RECHARGE 29
#define MOVE_EFFECT_RAGE 30
#define MOVE_EFFECT_STEAL_ITEM 31
#define MOVE_EFFECT_PREVENT_ESCAPE 32
#define MOVE_EFFECT_NIGHTMARE 33
#define MOVE_EFFECT_ALL_STATS_UP 34
#define MOVE_EFFECT_RAPIDSPIN 35
#define MOVE_EFFECT_REMOVE_PARALYSIS 36
#define MOVE_EFFECT_ATK_DEF_DOWN 37
#define MOVE_EFFECT_RECOIL_33 38
#define MOVE_EFFECT_ATK_PLUS_2 39
#define MOVE_EFFECT_DEF_PLUS_2 40
#define MOVE_EFFECT_SPD_PLUS_2 41
#define MOVE_EFFECT_SP_ATK_PLUS_2 42
#define MOVE_EFFECT_SP_DEF_PLUS_2 43
#define MOVE_EFFECT_ACC_PLUS_2 44
#define MOVE_EFFECT_EVS_PLUS_2 45
#define MOVE_EFFECT_ATK_MINUS_2 46
#define MOVE_EFFECT_DEF_MINUS_2 47
#define MOVE_EFFECT_SPD_MINUS_2 48
#define MOVE_EFFECT_SP_ATK_MINUS_2 49
#define MOVE_EFFECT_SP_DEF_MINUS_2 50
#define MOVE_EFFECT_ACC_MINUS_2 51
#define MOVE_EFFECT_EVS_MINUS_2 52
#define MOVE_EFFECT_THRASH 53
#define MOVE_EFFECT_KNOCK_OFF 54
#define MOVE_EFFECT_NOTHING_37 55
#define MOVE_EFFECT_NOTHING_38 56
#define MOVE_EFFECT_NOTHING_39 57
#define MOVE_EFFECT_NOTHING_3A 58
#define MOVE_EFFECT_SP_ATK_TWO_DOWN 59
#define NUM_MOVE_EFFECTS 60
#define MOVE_EFFECT_AFFECTS_USER (1 << 6) // 64
#define MOVE_EFFECT_CERTAIN (1 << 7) // 128
// Battle terrain defines for gBattleTerrain.
#define BATTLE_TERRAIN_GRASS 0

View File

@ -16,4 +16,14 @@
#define PALACE_DATA_WIN_STREAK 1
#define PALACE_DATA_WIN_STREAK_ACTIVE 2
// Pokemon in Battle Palace have a move "group" type preference depending on nature
#define PALACE_MOVE_GROUP_ATTACK 0
#define PALACE_MOVE_GROUP_DEFENSE 1
#define PALACE_MOVE_GROUP_SUPPORT 2
// In palace doubles battles pokemon have a target preference depending on nature
#define PALACE_TARGET_STRONGER 0
#define PALACE_TARGET_WEAKER 1
#define PALACE_TARGET_RANDOM 2
#endif //GUARD_CONSTANTS_BATTLE_PALACE_H

View File

@ -66,8 +66,10 @@
#define VARIOUS_SET_MAGIC_COAT_TARGET 1
#define VARIOUS_IS_RUNNING_IMPOSSIBLE 2
#define VARIOUS_GET_MOVE_TARGET 3
#define VARIOUS_GET_BATTLER_FAINTED 4
#define VARIOUS_RESET_INTIMIDATE_TRACE_BITS 5
#define VARIOUS_UPDATE_CHOICE_MOVE_ON_LVL_UP 6
#define VARIOUS_PALACE_FLAVOR_TEXT 8
#define VARIOUS_ARENA_JUDGMENT_WINDOW 9
#define VARIOUS_ARENA_OPPONENT_MON_LOST 10
#define VARIOUS_ARENA_PLAYER_MON_LOST 11

View File

@ -69,6 +69,7 @@
#define NATURE_SASSY 22
#define NATURE_CAREFUL 23
#define NATURE_QUIRKY 24
#define NUM_NATURES 25
// Pokemon Stats
#define STAT_HP 0
@ -80,7 +81,7 @@
#define STAT_ACC 6 // Only in battles.
#define STAT_EVASION 7 // Only in battles.
#define NUM_EV_STATS NUM_STATS - 1 // excludes HP
#define NUM_NATURE_STATS NUM_STATS - 1 // excludes HP
#define NUM_BATTLE_STATS NUM_STATS + 2 // includes Accuracy and Evasion
// Shiny odds

View File

@ -1,6 +1,9 @@
#ifndef GUARD_POKEBLOCK_H
#define GUARD_POKEBLOCK_H
#include "constants/berry.h"
#include "constants/pokemon.h"
#define GFX_TAG_POKEBLOCK 14818
#define GFX_TAG_POKEBLOCK_CASE 14800
@ -43,7 +46,7 @@ void ChooseMonToGivePokeblock(struct Pokeblock *pokeblock, void (*callback)(void
void CB2_PreparePokeblockFeedScene(void);
// pokeblock
extern const s8 gPokeblockFlavorCompatibilityTable[];
extern const s8 gPokeblockFlavorCompatibilityTable[NUM_NATURES * FLAVOR_COUNT];
extern const u8 *const gPokeblockNames[];
extern const struct CompressedSpriteSheet gPokeblockCase_SpriteSheet;
extern const struct CompressedSpritePalette gPokeblockCase_SpritePal;

View File

@ -1,13 +0,0 @@
#ifndef GUARD_UNK_TRANSITION_H
#define GUARD_UNK_TRANSITION_H
void Phase2Task_34(u8 taskId);
void Phase2Task_35(u8 taskId);
void Phase2Task_36(u8 taskId);
void Phase2Task_37(u8 taskId);
void Phase2Task_38(u8 taskId);
void Phase2Task_39(u8 taskId);
void Phase2Task_40(u8 taskId);
void Phase2Task_41(u8 taskId);
#endif // GUARD_UNK_TRANSITION_H

View File

@ -331,7 +331,7 @@ SECTIONS {
src/walda_phrase.o(.text);
src/contest_link_util.o(.text);
src/gym_leader_rematch.o(.text);
src/unk_transition.o(.text);
src/battle_transition_frontier.o(.text);
src/international_string_util.o(.text);
} =0
@ -685,7 +685,7 @@ SECTIONS {
src/rayquaza_scene.o(.rodata);
src/walda_phrase.o(.rodata);
src/gym_leader_rematch.o(.rodata);
src/unk_transition.o(.rodata);
src/battle_transition_frontier.o(.rodata);
src/text_input_strings.o(.rodata);
data/fonts.o(.rodata);
src/mystery_event_msg.o(.rodata);

View File

@ -471,9 +471,9 @@ static u8 ChooseMoveOrAction_Doubles(void)
else
{
if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
BattleAI_SetupAIData(gBattleStruct->field_92 >> 4);
BattleAI_SetupAIData(gBattleStruct->palaceFlags >> 4);
else
BattleAI_SetupAIData(0xF);
BattleAI_SetupAIData((1 << MAX_MON_MOVES) - 1);
gBattlerTarget = i;

View File

@ -6,39 +6,40 @@
#include "sprite.h"
#include "util.h"
#include "constants/pokemon.h"
#include "constants/battle_palace.h"
static void SmokescreenImpact_Callback(struct Sprite *);
static void SpriteCB_DestroySprite(struct Sprite *sprite);
// The below data for smokescreen starts and ends with some data that belongs to battle_gfx_sfx_util.c
const u8 gUnknown_0831C604[] =
const u8 gBattlePalaceNatureToMoveTarget[NUM_NATURES] =
{
[NATURE_HARDY] = 0,
[NATURE_LONELY] = 0,
[NATURE_BRAVE] = 1,
[NATURE_ADAMANT] = 0,
[NATURE_NAUGHTY] = 1,
[NATURE_BOLD] = 1,
[NATURE_DOCILE] = 2,
[NATURE_RELAXED] = 0,
[NATURE_IMPISH] = 0,
[NATURE_LAX] = 0,
[NATURE_TIMID] = 1,
[NATURE_HASTY] = 1,
[NATURE_SERIOUS] = 1,
[NATURE_JOLLY] = 0,
[NATURE_NAIVE] = 2,
[NATURE_MODEST] = 1,
[NATURE_MILD] = 0,
[NATURE_QUIET] = 1,
[NATURE_BASHFUL] = 1,
[NATURE_RASH] = 0,
[NATURE_CALM] = 0,
[NATURE_GENTLE] = 0,
[NATURE_SASSY] = 1,
[NATURE_CAREFUL] = 1,
[NATURE_QUIRKY] = 0,
[NATURE_HARDY] = PALACE_TARGET_STRONGER,
[NATURE_LONELY] = PALACE_TARGET_STRONGER,
[NATURE_BRAVE] = PALACE_TARGET_WEAKER,
[NATURE_ADAMANT] = PALACE_TARGET_STRONGER,
[NATURE_NAUGHTY] = PALACE_TARGET_WEAKER,
[NATURE_BOLD] = PALACE_TARGET_WEAKER,
[NATURE_DOCILE] = PALACE_TARGET_RANDOM,
[NATURE_RELAXED] = PALACE_TARGET_STRONGER,
[NATURE_IMPISH] = PALACE_TARGET_STRONGER,
[NATURE_LAX] = PALACE_TARGET_STRONGER,
[NATURE_TIMID] = PALACE_TARGET_WEAKER,
[NATURE_HASTY] = PALACE_TARGET_WEAKER,
[NATURE_SERIOUS] = PALACE_TARGET_WEAKER,
[NATURE_JOLLY] = PALACE_TARGET_STRONGER,
[NATURE_NAIVE] = PALACE_TARGET_RANDOM,
[NATURE_MODEST] = PALACE_TARGET_WEAKER,
[NATURE_MILD] = PALACE_TARGET_STRONGER,
[NATURE_QUIET] = PALACE_TARGET_WEAKER,
[NATURE_BASHFUL] = PALACE_TARGET_WEAKER,
[NATURE_RASH] = PALACE_TARGET_STRONGER,
[NATURE_CALM] = PALACE_TARGET_STRONGER,
[NATURE_GENTLE] = PALACE_TARGET_STRONGER,
[NATURE_SASSY] = PALACE_TARGET_WEAKER,
[NATURE_CAREFUL] = PALACE_TARGET_WEAKER,
[NATURE_QUIRKY] = PALACE_TARGET_STRONGER,
};
static const struct CompressedSpriteSheet sSmokescreenImpactSpriteSheet =

View File

@ -4692,7 +4692,7 @@ static void DisplayTrainerInfoOnCard(u8 flags, u8 trainerTourneyId)
allocatedArray[NUM_STATS] += allocatedArray[STAT_HP];
// Add the EVs with the nature modifier for this mon and and track number of negative natures
for (j = 0; j < NUM_EV_STATS; j++)
for (j = 0; j < NUM_NATURE_STATS; j++)
{
if (trainerId == TRAINER_FRONTIER_BRAIN)
nature = GetFrontierBrainMonNature(i);
@ -4706,7 +4706,7 @@ static void DisplayTrainerInfoOnCard(u8 flags, u8 trainerTourneyId)
else if (gNatureStatTable[nature][j] < 0)
{
allocatedArray[j + NUM_STATS + 1] += (allocatedArray[j + 1] * 90) / 100;
allocatedArray[j + NUM_STATS + NUM_EV_STATS + 2]++;
allocatedArray[j + NUM_STATS + NUM_NATURE_STATS + 2]++;
}
else
{
@ -4742,7 +4742,7 @@ static void DisplayTrainerInfoOnCard(u8 flags, u8 trainerTourneyId)
}
allocatedArray[NUM_STATS] += allocatedArray[STAT_HP];
for (j = 0; j < NUM_EV_STATS; j++)
for (j = 0; j < NUM_NATURE_STATS; j++)
{
nature = gFacilityTrainerMons[DOME_MONS[trainerTourneyId][i]].nature;
if (gNatureStatTable[nature][j] > 0)
@ -4752,7 +4752,7 @@ static void DisplayTrainerInfoOnCard(u8 flags, u8 trainerTourneyId)
else if (gNatureStatTable[nature][j] < 0)
{
allocatedArray[j + NUM_STATS + 1] += (allocatedArray[j + 1] * 90) / 100;
allocatedArray[j + NUM_STATS + NUM_EV_STATS + 2]++;
allocatedArray[j + NUM_STATS + NUM_NATURE_STATS + 2]++;
}
else
{

View File

@ -24,20 +24,21 @@
#include "contest.h"
#include "constants/songs.h"
#include "constants/rgb.h"
#include "constants/battle_palace.h"
extern struct MusicPlayerInfo gMPlayInfo_SE1;
extern struct MusicPlayerInfo gMPlayInfo_SE2;
extern struct MusicPlayerInfo gMPlayInfo_BGM;
extern const u8 gUnknown_0831C604[];
extern const u8 gBattlePalaceNatureToMoveTarget[];
extern const u8 * const gBattleAnims_General[];
extern const u8 * const gBattleAnims_Special[];
extern const struct CompressedSpriteSheet gSpriteSheet_EnemyShadow;
extern const struct SpriteTemplate gSpriteTemplate_EnemyShadow;
// this file's functions
static u8 sub_805D4A8(u16 move);
static u16 BattlePalaceGetTargetRetValue(void);
static u8 GetBattlePalaceMoveGroup(u16 move);
static u16 GetBattlePalaceTarget(void);
static void sub_805D7EC(struct Sprite *sprite);
static bool8 ShouldAnimBeDoneRegardlessOfSubsitute(u8 animId);
static void Task_ClearBitWhenBattleTableAnimDone(u8 taskId);
@ -108,6 +109,7 @@ void FreeBattleSpritesData(void)
FREE_AND_SET_NULL(gBattleSpritesDataPtr);
}
// Pokemon chooses move to use in Battle Palace rather than player
u16 ChooseMoveAndTargetInBattlePalace(void)
{
s32 i, var1, var2;
@ -116,60 +118,88 @@ u16 ChooseMoveAndTargetInBattlePalace(void)
u8 unusableMovesBits = CheckMoveLimitations(gActiveBattler, 0, 0xFF);
s32 percent = Random() % 100;
i = (gBattleStruct->field_92 & gBitTable[gActiveBattler]) ? 2 : 0;
var2 = i;
var1 = i + 2;
// Heavy variable re-use here makes this hard to read without defines
// Possibly just optimization? might still match with additional vars
#define maxGroupNum var1
#define minGroupNum var2
#define selectedGroup percent
#define selectedMoves var2
#define moveTarget var1
#define validMoveFlags var1
#define numValidMoveGroups var2
#define validMoveGroup var2
for (; i < var1; i++)
// If battler is < 50% HP and not asleep, use second set of move group likelihoods
// otherwise use first set
i = (gBattleStruct->palaceFlags & gBitTable[gActiveBattler]) ? 2 : 0;
minGroupNum = i;
maxGroupNum = i + 2; // + 2 because there are two percentages per set of likelihoods
// Each nature has a different percent chance to select a move from one of 3 move groups
// If percent is less than 1st check, use move from "Attack" group
// If percent is less than 2nd check, use move from "Defense" group
// Otherwise use move from "Support" group
for (; i < maxGroupNum; i++)
{
if (gUnknown_0831C494[GetNatureFromPersonality(gBattleMons[gActiveBattler].personality)][i] > percent)
if (gBattlePalaceNatureToMoveGroupLikelihood[GetNatureFromPersonality(gBattleMons[gActiveBattler].personality)][i] > percent)
break;
}
selectedGroup = i - minGroupNum;
if (i == maxGroupNum)
selectedGroup = PALACE_MOVE_GROUP_SUPPORT;
percent = i - var2;
if (i == var1)
percent = 2;
for (var2 = 0, i = 0; i < MAX_MON_MOVES; i++)
// Flag moves that match selected group, to be passed to AI
for (selectedMoves = 0, i = 0; i < MAX_MON_MOVES; i++)
{
if (moveInfo->moves[i] == MOVE_NONE)
break;
if (percent == sub_805D4A8(moveInfo->moves[i]) && moveInfo->currentPp[i] != 0)
var2 |= gBitTable[i];
if (selectedGroup == GetBattlePalaceMoveGroup(moveInfo->moves[i]) && moveInfo->currentPp[i] != 0)
selectedMoves |= gBitTable[i];
}
if (var2 != 0)
// Pass selected moves to AI, pick one
if (selectedMoves != 0)
{
gBattleStruct->field_92 &= 0xF;
gBattleStruct->field_92 |= (var2 << 4);
BattleAI_SetupAIData(var2);
gBattleStruct->palaceFlags &= 0xF;
gBattleStruct->palaceFlags |= (selectedMoves << 4);
BattleAI_SetupAIData(selectedMoves);
chosenMoveId = BattleAI_ChooseMoveOrAction();
}
// If no moves matched the selected group, pick a new move from groups the pokemon has
// In this case the AI is not checked again, so the choice may be worse
// If a move is chosen this way, there's a 50% chance that it will be unable to use it anyway
if (chosenMoveId == -1)
{
if (unusableMovesBits != 0xF)
{
var1 = 0, var2 = 0;
validMoveFlags = 0, numValidMoveGroups = 0;
for (i = 0; i < MAX_MON_MOVES; i++)
{
if (sub_805D4A8(moveInfo->moves[i]) == 0 && !(gBitTable[i] & unusableMovesBits))
var1 += 0x1;
if (sub_805D4A8(moveInfo->moves[i]) == 1 && !(gBitTable[i] & unusableMovesBits))
var1 += 0x10;
if (sub_805D4A8(moveInfo->moves[i]) == 2 && !(gBitTable[i] & unusableMovesBits))
var1 += 0x100;
// validMoveFlags is used here as a bitfield for which moves can be used for each move group type
// first 4 bits are for attack (1 for each move), then 4 bits for defense, and 4 for support
if (GetBattlePalaceMoveGroup(moveInfo->moves[i]) == PALACE_MOVE_GROUP_ATTACK && !(gBitTable[i] & unusableMovesBits))
validMoveFlags += (1 << 0);
if (GetBattlePalaceMoveGroup(moveInfo->moves[i]) == PALACE_MOVE_GROUP_DEFENSE && !(gBitTable[i] & unusableMovesBits))
validMoveFlags += (1 << 4);
if (GetBattlePalaceMoveGroup(moveInfo->moves[i]) == PALACE_MOVE_GROUP_SUPPORT && !(gBitTable[i] & unusableMovesBits))
validMoveFlags += (1 << 8);
}
if ((var1 & 0xF) > 1)
var2++;
if ((var1 & 0xF0) > 0x1F)
var2++;
if ((var1 & 0xF0) > 0x1FF)
var2++;
// Count the move groups the pokemon has
if ((validMoveFlags & 0xF) > 1)
numValidMoveGroups++;
if ((validMoveFlags & 0xF0) > 0x1F)
numValidMoveGroups++;
if ((validMoveFlags & 0xF0) > 0x1FF)
numValidMoveGroups++;
if (var2 > 1 || var2 == 0)
// If more than 1 possible move group, or no possible move groups
// then choose move randomly
if (numValidMoveGroups > 1 || numValidMoveGroups == 0)
{
do
{
@ -178,32 +208,35 @@ u16 ChooseMoveAndTargetInBattlePalace(void)
chosenMoveId = i;
} while (chosenMoveId == -1);
}
// Otherwise randomly choose move of only available move group
else
{
if ((var1 & 0xF) > 1)
var2 = 0;
if ((var1 & 0xF0) > 0x1F)
var2 = 1;
if ((var1 & 0xF0) > 0x1FF)
var2 = 2;
if ((validMoveFlags & 0xF) > 1)
validMoveGroup = PALACE_MOVE_GROUP_ATTACK;
if ((validMoveFlags & 0xF0) > 0x1F)
validMoveGroup = PALACE_MOVE_GROUP_DEFENSE;
if ((validMoveFlags & 0xF0) > 0x1FF)
validMoveGroup = PALACE_MOVE_GROUP_SUPPORT;
do
{
i = Random() % MAX_MON_MOVES;
if (!(gBitTable[i] & unusableMovesBits) && var2 == sub_805D4A8(moveInfo->moves[i]))
if (!(gBitTable[i] & unusableMovesBits) && validMoveGroup == GetBattlePalaceMoveGroup(moveInfo->moves[i]))
chosenMoveId = i;
} while (chosenMoveId == -1);
}
// If a move was selected (and in this case was not from the Nature-chosen group)
// then there's a 50% chance it won't be used anyway
if (Random() % 100 > 49)
{
gProtectStructs[gActiveBattler].palaceUnableToUseMove = 1;
gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE;
return 0;
}
}
else
{
gProtectStructs[gActiveBattler].palaceUnableToUseMove = 1;
gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE;
return 0;
}
}
@ -211,26 +244,35 @@ u16 ChooseMoveAndTargetInBattlePalace(void)
if (moveInfo->moves[chosenMoveId] == MOVE_CURSE)
{
if (moveInfo->monType1 != TYPE_GHOST && moveInfo->monType2 != TYPE_GHOST)
var1 = MOVE_TARGET_USER;
moveTarget = MOVE_TARGET_USER;
else
var1 = MOVE_TARGET_SELECTED;
moveTarget = MOVE_TARGET_SELECTED;
}
else
{
var1 = gBattleMoves[moveInfo->moves[chosenMoveId]].target;
moveTarget = gBattleMoves[moveInfo->moves[chosenMoveId]].target;
}
if (var1 & MOVE_TARGET_USER)
if (moveTarget & MOVE_TARGET_USER)
chosenMoveId |= (gActiveBattler << 8);
else if (var1 == MOVE_TARGET_SELECTED)
chosenMoveId |= (BattlePalaceGetTargetRetValue());
else if (moveTarget == MOVE_TARGET_SELECTED)
chosenMoveId |= GetBattlePalaceTarget();
else
chosenMoveId |= (GetBattlerAtPosition((GetBattlerPosition(gActiveBattler) & BIT_SIDE) ^ BIT_SIDE) << 8);
return chosenMoveId;
}
static u8 sub_805D4A8(u16 move)
#undef maxGroupNum
#undef minGroupNum
#undef selectedGroup
#undef selectedMoves
#undef moveTarget
#undef validMoveFlags
#undef numValidMoveGroups
#undef validMoveGroup
static u8 GetBattlePalaceMoveGroup(u16 move)
{
switch (gBattleMoves[move].target)
{
@ -240,21 +282,21 @@ static u8 sub_805D4A8(u16 move)
case MOVE_TARGET_BOTH:
case MOVE_TARGET_FOES_AND_ALLY:
if (gBattleMoves[move].power == 0)
return 2;
return PALACE_MOVE_GROUP_SUPPORT;
else
return 0;
return PALACE_MOVE_GROUP_ATTACK;
break;
case MOVE_TARGET_DEPENDS:
case MOVE_TARGET_OPPONENTS_FIELD:
return 2;
return PALACE_MOVE_GROUP_SUPPORT;
case MOVE_TARGET_USER:
return 1;
return PALACE_MOVE_GROUP_DEFENSE;
default:
return 0;
return PALACE_MOVE_GROUP_ATTACK;
}
}
static u16 BattlePalaceGetTargetRetValue(void)
static u16 GetBattlePalaceTarget(void)
{
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
{
@ -274,19 +316,19 @@ static u16 BattlePalaceGetTargetRetValue(void)
if (gBattleMons[opposing1].hp == gBattleMons[opposing2].hp)
return (((gActiveBattler & BIT_SIDE) ^ BIT_SIDE) + (Random() & 2)) << 8;
switch (gUnknown_0831C604[GetNatureFromPersonality(gBattleMons[gActiveBattler].personality)])
switch (gBattlePalaceNatureToMoveTarget[GetNatureFromPersonality(gBattleMons[gActiveBattler].personality)])
{
case 0:
case PALACE_TARGET_STRONGER:
if (gBattleMons[opposing1].hp > gBattleMons[opposing2].hp)
return opposing1 << 8;
else
return opposing2 << 8;
case 1:
case PALACE_TARGET_WEAKER:
if (gBattleMons[opposing1].hp < gBattleMons[opposing2].hp)
return opposing1 << 8;
else
return opposing2 << 8;
case 2:
case PALACE_TARGET_RANDOM:
return (((gActiveBattler & BIT_SIDE) ^ BIT_SIDE) + (Random() & 2)) << 8;
}
}

View File

@ -3112,7 +3112,7 @@ static void BattleStartClearSetData(void)
}
gBattleStruct->givenExpMons = 0;
gBattleStruct->field_92 = 0;
gBattleStruct->palaceFlags = 0;
gRandomTurnNumber = Random();
@ -3159,7 +3159,7 @@ void SwitchInClearSetData(void)
&& (gDisableStructs[i].battlerWithSureHit == gActiveBattler))
{
gStatuses3[i] &= ~(STATUS3_ALWAYS_HITS);
gStatuses3[i] |= 0x10;
gStatuses3[i] |= STATUS3_ALWAYS_HITS_TURN(2);
}
}
}
@ -3214,7 +3214,7 @@ void SwitchInClearSetData(void)
*(3 * 2 + gActiveBattler * 8 + (u8*)(gBattleStruct->lastTakenMoveFrom) + 0) = 0;
*(3 * 2 + gActiveBattler * 8 + (u8*)(gBattleStruct->lastTakenMoveFrom) + 1) = 0;
gBattleStruct->field_92 &= ~(gBitTable[gActiveBattler]);
gBattleStruct->palaceFlags &= ~(gBitTable[gActiveBattler]);
for (i = 0; i < gBattlersCount; i++)
{
@ -3309,7 +3309,7 @@ void FaintClearSetData(void)
*(3 * 2 + gActiveBattler * 8 + (u8*)(gBattleStruct->lastTakenMoveFrom) + 0) = 0;
*(3 * 2 + gActiveBattler * 8 + (u8*)(gBattleStruct->lastTakenMoveFrom) + 1) = 0;
gBattleStruct->field_92 &= ~(gBitTable[gActiveBattler]);
gBattleStruct->palaceFlags &= ~(gBitTable[gActiveBattler]);
for (i = 0; i < gBattlersCount; i++)
{
@ -4052,7 +4052,7 @@ void BattleTurnPassed(void)
gRandomTurnNumber = Random();
if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
BattleScriptExecute(BattleScript_82DB881);
BattleScriptExecute(BattleScript_PalacePrintFlavorText);
else if (gBattleTypeFlags & BATTLE_TYPE_ARENA && gBattleStruct->arenaTurnCounter == 0)
BattleScriptExecute(BattleScript_ArenaTurnBeginning);
}

View File

@ -1267,10 +1267,12 @@ static const u8 sText_PkmnGettingIntoPosition[] = _("{B_SCR_ACTIVE_NAME_WITH_PRE
static const u8 sText_PkmnBeganGrowlingDeeply[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} began growling deeply!");
static const u8 sText_PkmnEagerForMore[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} is eager for more!");
const u16 gStringIds_85CCF0A[] =
const u16 gBattlePalaceFlavorTextTable[] =
{
STRINGID_GLINTAPPEARSINEYE, STRINGID_PKMNGETTINGINTOPOSITION,
STRINGID_PKMNBEGANGROWLINGDEEPLY, STRINGID_PKMNEAGERFORMORE
STRINGID_GLINTAPPEARSINEYE,
STRINGID_PKMNGETTINGINTOPOSITION,
STRINGID_PKMNBEGANGROWLINGDEEPLY,
STRINGID_PKMNEAGERFORMORE
};
static const u8 sText_RefIfNothingIsDecided[] = _("REFEREE: If nothing is decided in\n3 turns, we will go to judging!");

View File

@ -606,111 +606,66 @@ static const struct StatFractions sAccuracyStageRatios[] =
// The chance is 1/N for each stage.
static const u16 sCriticalHitChance[] = {16, 8, 4, 3, 2};
static const u32 sStatusFlagsForMoveEffects[] =
static const u32 sStatusFlagsForMoveEffects[NUM_MOVE_EFFECTS] =
{
0x00000000,
STATUS1_SLEEP,
STATUS1_POISON,
STATUS1_BURN,
STATUS1_FREEZE,
STATUS1_PARALYSIS,
STATUS1_TOXIC_POISON,
STATUS2_CONFUSION,
STATUS2_FLINCHED,
0x00000000,
STATUS2_UPROAR,
0x00000000,
STATUS2_MULTIPLETURNS,
STATUS2_WRAPPED,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
STATUS2_RECHARGE,
0x00000000,
0x00000000,
STATUS2_ESCAPE_PREVENTION,
STATUS2_NIGHTMARE,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
STATUS2_LOCK_CONFUSE,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000
[MOVE_EFFECT_SLEEP] = STATUS1_SLEEP,
[MOVE_EFFECT_POISON] = STATUS1_POISON,
[MOVE_EFFECT_BURN] = STATUS1_BURN,
[MOVE_EFFECT_FREEZE] = STATUS1_FREEZE,
[MOVE_EFFECT_PARALYSIS] = STATUS1_PARALYSIS,
[MOVE_EFFECT_TOXIC] = STATUS1_TOXIC_POISON,
[MOVE_EFFECT_CONFUSION] = STATUS2_CONFUSION,
[MOVE_EFFECT_FLINCH] = STATUS2_FLINCHED,
[MOVE_EFFECT_UPROAR] = STATUS2_UPROAR,
[MOVE_EFFECT_CHARGING] = STATUS2_MULTIPLETURNS,
[MOVE_EFFECT_WRAP] = STATUS2_WRAPPED,
[MOVE_EFFECT_RECHARGE] = STATUS2_RECHARGE,
[MOVE_EFFECT_PREVENT_ESCAPE] = STATUS2_ESCAPE_PREVENTION,
[MOVE_EFFECT_NIGHTMARE] = STATUS2_NIGHTMARE,
[MOVE_EFFECT_THRASH] = STATUS2_LOCK_CONFUSE,
};
static const u8* const sMoveEffectBS_Ptrs[] =
{
[0] = BattleScript_MoveEffectSleep,
[MOVE_EFFECT_SLEEP] = BattleScript_MoveEffectSleep,
[MOVE_EFFECT_POISON] = BattleScript_MoveEffectPoison,
[MOVE_EFFECT_BURN] = BattleScript_MoveEffectBurn,
[MOVE_EFFECT_FREEZE] = BattleScript_MoveEffectFreeze,
[MOVE_EFFECT_PARALYSIS] = BattleScript_MoveEffectParalysis,
[MOVE_EFFECT_TOXIC] = BattleScript_MoveEffectToxic,
[MOVE_EFFECT_CONFUSION] = BattleScript_MoveEffectConfusion,
[MOVE_EFFECT_FLINCH] = BattleScript_MoveEffectSleep,
[MOVE_EFFECT_TRI_ATTACK] = BattleScript_MoveEffectSleep,
[MOVE_EFFECT_UPROAR] = BattleScript_MoveEffectUproar,
[MOVE_EFFECT_PAYDAY] = BattleScript_MoveEffectPayDay,
[MOVE_EFFECT_CHARGING] = BattleScript_MoveEffectSleep,
[MOVE_EFFECT_WRAP] = BattleScript_MoveEffectWrap,
[MOVE_EFFECT_RECOIL_25] = BattleScript_MoveEffectRecoil,
[MOVE_EFFECT_ATK_PLUS_1] = BattleScript_MoveEffectSleep,
[MOVE_EFFECT_DEF_PLUS_1] = BattleScript_MoveEffectSleep,
[MOVE_EFFECT_SPD_PLUS_1] = BattleScript_MoveEffectSleep,
[MOVE_EFFECT_SP_ATK_PLUS_1] = BattleScript_MoveEffectSleep,
[MOVE_EFFECT_SP_DEF_PLUS_1] = BattleScript_MoveEffectSleep,
[MOVE_EFFECT_ACC_PLUS_1] = BattleScript_MoveEffectSleep,
[MOVE_EFFECT_EVS_PLUS_1] = BattleScript_MoveEffectSleep,
[MOVE_EFFECT_ATK_MINUS_1] = BattleScript_MoveEffectSleep,
[MOVE_EFFECT_DEF_MINUS_1] = BattleScript_MoveEffectSleep,
[MOVE_EFFECT_SPD_MINUS_1] = BattleScript_MoveEffectSleep,
[MOVE_EFFECT_SP_ATK_MINUS_1] = BattleScript_MoveEffectSleep,
[MOVE_EFFECT_SP_DEF_MINUS_1] = BattleScript_MoveEffectSleep,
[MOVE_EFFECT_ACC_MINUS_1] = BattleScript_MoveEffectSleep,
[MOVE_EFFECT_EVS_MINUS_1] = BattleScript_MoveEffectSleep,
[MOVE_EFFECT_RECHARGE] = BattleScript_MoveEffectSleep,
[MOVE_EFFECT_RAGE] = BattleScript_MoveEffectSleep,
[MOVE_EFFECT_STEAL_ITEM] = BattleScript_MoveEffectSleep,
[MOVE_EFFECT_PREVENT_ESCAPE] = BattleScript_MoveEffectSleep,
[MOVE_EFFECT_NIGHTMARE] = BattleScript_MoveEffectSleep,
[MOVE_EFFECT_ALL_STATS_UP] = BattleScript_MoveEffectSleep,
[MOVE_EFFECT_RAPIDSPIN] = BattleScript_MoveEffectSleep,
[0] = BattleScript_MoveEffectSleep,
[MOVE_EFFECT_SLEEP] = BattleScript_MoveEffectSleep,
[MOVE_EFFECT_POISON] = BattleScript_MoveEffectPoison,
[MOVE_EFFECT_BURN] = BattleScript_MoveEffectBurn,
[MOVE_EFFECT_FREEZE] = BattleScript_MoveEffectFreeze,
[MOVE_EFFECT_PARALYSIS] = BattleScript_MoveEffectParalysis,
[MOVE_EFFECT_TOXIC] = BattleScript_MoveEffectToxic,
[MOVE_EFFECT_CONFUSION] = BattleScript_MoveEffectConfusion,
[MOVE_EFFECT_FLINCH] = BattleScript_MoveEffectSleep,
[MOVE_EFFECT_TRI_ATTACK] = BattleScript_MoveEffectSleep,
[MOVE_EFFECT_UPROAR] = BattleScript_MoveEffectUproar,
[MOVE_EFFECT_PAYDAY] = BattleScript_MoveEffectPayDay,
[MOVE_EFFECT_CHARGING] = BattleScript_MoveEffectSleep,
[MOVE_EFFECT_WRAP] = BattleScript_MoveEffectWrap,
[MOVE_EFFECT_RECOIL_25] = BattleScript_MoveEffectRecoil,
[MOVE_EFFECT_ATK_PLUS_1] = BattleScript_MoveEffectSleep,
[MOVE_EFFECT_DEF_PLUS_1] = BattleScript_MoveEffectSleep,
[MOVE_EFFECT_SPD_PLUS_1] = BattleScript_MoveEffectSleep,
[MOVE_EFFECT_SP_ATK_PLUS_1] = BattleScript_MoveEffectSleep,
[MOVE_EFFECT_SP_DEF_PLUS_1] = BattleScript_MoveEffectSleep,
[MOVE_EFFECT_ACC_PLUS_1] = BattleScript_MoveEffectSleep,
[MOVE_EFFECT_EVS_PLUS_1] = BattleScript_MoveEffectSleep,
[MOVE_EFFECT_ATK_MINUS_1] = BattleScript_MoveEffectSleep,
[MOVE_EFFECT_DEF_MINUS_1] = BattleScript_MoveEffectSleep,
[MOVE_EFFECT_SPD_MINUS_1] = BattleScript_MoveEffectSleep,
[MOVE_EFFECT_SP_ATK_MINUS_1] = BattleScript_MoveEffectSleep,
[MOVE_EFFECT_SP_DEF_MINUS_1] = BattleScript_MoveEffectSleep,
[MOVE_EFFECT_ACC_MINUS_1] = BattleScript_MoveEffectSleep,
[MOVE_EFFECT_EVS_MINUS_1] = BattleScript_MoveEffectSleep,
[MOVE_EFFECT_RECHARGE] = BattleScript_MoveEffectSleep,
[MOVE_EFFECT_RAGE] = BattleScript_MoveEffectSleep,
[MOVE_EFFECT_STEAL_ITEM] = BattleScript_MoveEffectSleep,
[MOVE_EFFECT_PREVENT_ESCAPE] = BattleScript_MoveEffectSleep,
[MOVE_EFFECT_NIGHTMARE] = BattleScript_MoveEffectSleep,
[MOVE_EFFECT_ALL_STATS_UP] = BattleScript_MoveEffectSleep,
[MOVE_EFFECT_RAPIDSPIN] = BattleScript_MoveEffectSleep,
[MOVE_EFFECT_REMOVE_PARALYSIS] = BattleScript_MoveEffectSleep,
[MOVE_EFFECT_ATK_DEF_DOWN] = BattleScript_MoveEffectSleep,
[MOVE_EFFECT_RECOIL_33] = BattleScript_MoveEffectRecoil,
[MOVE_EFFECT_ATK_DEF_DOWN] = BattleScript_MoveEffectSleep,
[MOVE_EFFECT_RECOIL_33] = BattleScript_MoveEffectRecoil,
};
static const struct WindowTemplate sUnusedWinTemplate = {0, 1, 3, 7, 0xF, 0x1F, 0x3F};
@ -797,16 +752,16 @@ static const u8 sFlailHpScaleToPowerTable[] =
static const u16 sNaturePowerMoves[] =
{
MOVE_STUN_SPORE,
MOVE_RAZOR_LEAF,
MOVE_EARTHQUAKE,
MOVE_HYDRO_PUMP,
MOVE_SURF,
MOVE_BUBBLE_BEAM,
MOVE_ROCK_SLIDE,
MOVE_SHADOW_BALL,
MOVE_SWIFT,
MOVE_SWIFT
[BATTLE_TERRAIN_GRASS] = MOVE_STUN_SPORE,
[BATTLE_TERRAIN_LONG_GRASS] = MOVE_RAZOR_LEAF,
[BATTLE_TERRAIN_SAND] = MOVE_EARTHQUAKE,
[BATTLE_TERRAIN_UNDERWATER] = MOVE_HYDRO_PUMP,
[BATTLE_TERRAIN_WATER] = MOVE_SURF,
[BATTLE_TERRAIN_POND] = MOVE_BUBBLE_BEAM,
[BATTLE_TERRAIN_MOUNTAIN] = MOVE_ROCK_SLIDE,
[BATTLE_TERRAIN_CAVE] = MOVE_SHADOW_BALL,
[BATTLE_TERRAIN_BUILDING] = MOVE_SWIFT,
[BATTLE_TERRAIN_PLAIN] = MOVE_SWIFT
};
// format: min. weight (hectograms), base power
@ -864,58 +819,92 @@ static const u8 sPickupProbabilities[] =
static const u8 sTerrainToType[] =
{
TYPE_GRASS, // tall grass
TYPE_GRASS, // long grass
TYPE_GROUND, // sand
TYPE_WATER, // underwater
TYPE_WATER, // water
TYPE_WATER, // pond water
TYPE_ROCK, // rock
TYPE_ROCK, // cave
TYPE_NORMAL, // building
TYPE_NORMAL, // plain
[BATTLE_TERRAIN_GRASS] = TYPE_GRASS,
[BATTLE_TERRAIN_LONG_GRASS] = TYPE_GRASS,
[BATTLE_TERRAIN_SAND] = TYPE_GROUND,
[BATTLE_TERRAIN_UNDERWATER] = TYPE_WATER,
[BATTLE_TERRAIN_WATER] = TYPE_WATER,
[BATTLE_TERRAIN_POND] = TYPE_WATER,
[BATTLE_TERRAIN_MOUNTAIN] = TYPE_ROCK,
[BATTLE_TERRAIN_CAVE] = TYPE_ROCK,
[BATTLE_TERRAIN_BUILDING] = TYPE_NORMAL,
[BATTLE_TERRAIN_PLAIN] = TYPE_NORMAL,
};
// - ITEM_ULTRA_BALL skips Master Ball and ITEM_NONE
static const u8 sBallCatchBonuses[] =
{
20, 15, 10, 15 // Ultra, Great, Poke, Safari
[ITEM_ULTRA_BALL - ITEM_ULTRA_BALL] = 20,
[ITEM_GREAT_BALL - ITEM_ULTRA_BALL] = 15,
[ITEM_POKE_BALL - ITEM_ULTRA_BALL] = 10,
[ITEM_SAFARI_BALL - ITEM_ULTRA_BALL] = 15
};
const ALIGNED(4) u8 gUnknown_0831C494[][4] =
// In Battle Palace, moves are chosen based on the pokemons nature rather than by the player
// Moves are grouped into "Attack", "Defense", or "Support" (see PALACE_MOVE_GROUP_*)
// Each nature has a certain percent chance of selecting a move from a particular group
// and a separate percent chance for each group when below 50% HP
// The table below doesn't list percentages for Support because you can subtract the other two
// Support percentages are listed in comments off to the side instead
#define PALACE_STYLE(atk, def, atkLow, defLow) {atk, atk + def, atkLow, atkLow + defLow}
const ALIGNED(4) u8 gBattlePalaceNatureToMoveGroupLikelihood[NUM_NATURES][4] =
{
{0x3d, 0x44, 0x3d, 0x44},
{0x14, 0x2d, 0x54, 0x5c},
{0x46, 0x55, 0x20, 0x5c},
{0x26, 0x45, 0x46, 0x55},
{0x14, 0x5a, 0x46, 0x5c},
{0x1e, 0x32, 0x20, 0x5a},
{0x38, 0x4e, 0x38, 0x4e},
{0x19, 0x28, 0x4b, 0x5a},
{0x45, 0x4b, 0x1c, 0x53},
{0x23, 0x2d, 0x1d, 0x23},
{0x3e, 0x48, 0x1e, 0x32},
{0x3a, 0x5f, 0x58, 0x5e},
{0x22, 0x2d, 0x1d, 0x28},
{0x23, 0x28, 0x23, 0x5f},
{0x38, 0x4e, 0x38, 0x4e},
{0x23, 0x50, 0x22, 0x5e},
{0x2c, 0x5e, 0x22, 0x28},
{0x38, 0x4e, 0x38, 0x4e},
{0x1e, 0x58, 0x1e, 0x58},
{0x1e, 0x2b, 0x1b, 0x21},
{0x28, 0x5a, 0x19, 0x57},
{0x12, 0x58, 0x5a, 0x5f},
{0x58, 0x5e, 0x16, 0x2a},
{0x2a, 0x5c, 0x2a, 0x2f},
{0x38, 0x4e, 0x38, 0x4e}
[NATURE_HARDY] = PALACE_STYLE(61, 7, 61, 7), // 32% support >= 50% HP, 32% support < 50% HP
[NATURE_LONELY] = PALACE_STYLE(20, 25, 84, 8), // 55%, 8%
[NATURE_BRAVE] = PALACE_STYLE(70, 15, 32, 60), // 15%, 8%
[NATURE_ADAMANT] = PALACE_STYLE(38, 31, 70, 15), // 31%, 15%
[NATURE_NAUGHTY] = PALACE_STYLE(20, 70, 70, 22), // 10%, 8%
[NATURE_BOLD] = PALACE_STYLE(30, 20, 32, 58), // 50%, 10%
[NATURE_DOCILE] = PALACE_STYLE(56, 22, 56, 22), // 22%, 22%
[NATURE_RELAXED] = PALACE_STYLE(25, 15, 75, 15), // 60%, 10%
[NATURE_IMPISH] = PALACE_STYLE(69, 6, 28, 55), // 25%, 17%
[NATURE_LAX] = PALACE_STYLE(35, 10, 29, 6), // 55%, 65%
[NATURE_TIMID] = PALACE_STYLE(62, 10, 30, 20), // 28%, 50%
[NATURE_HASTY] = PALACE_STYLE(58, 37, 88, 6), // 5%, 6%
[NATURE_SERIOUS] = PALACE_STYLE(34, 11, 29, 11), // 55%, 60%
[NATURE_JOLLY] = PALACE_STYLE(35, 5, 35, 60), // 60%, 5%
[NATURE_NAIVE] = PALACE_STYLE(56, 22, 56, 22), // 22%, 22%
[NATURE_MODEST] = PALACE_STYLE(35, 45, 34, 60), // 20%, 6%
[NATURE_MILD] = PALACE_STYLE(44, 50, 34, 6), // 6%, 60%
[NATURE_QUIET] = PALACE_STYLE(56, 22, 56, 22), // 22%, 22%
[NATURE_BASHFUL] = PALACE_STYLE(30, 58, 30, 58), // 12%, 12%
[NATURE_RASH] = PALACE_STYLE(30, 13, 27, 6), // 57%, 67%
[NATURE_CALM] = PALACE_STYLE(40, 50, 25, 62), // 10%, 13%
[NATURE_GENTLE] = PALACE_STYLE(18, 70, 90, 5), // 12%, 5%
[NATURE_SASSY] = PALACE_STYLE(88, 6, 22, 20), // 6%, 58%
[NATURE_CAREFUL] = PALACE_STYLE(42, 50, 42, 5), // 8%, 53%
[NATURE_QUIRKY] = PALACE_STYLE(56, 22, 56, 22) // 22%, 22%
};
static const u8 sUnknown_0831C4F8[] =
// Indices into gBattlePalaceFlavorTextTable
static const u8 sBattlePalaceNatureToFlavorTextId[NUM_NATURES] =
{
0x03, 0x00, 0x01, 0x00, 0x00, 0x01, 0x03, 0x00,
0x01, 0x02, 0x02, 0x00, 0x03, 0x01, 0x03, 0x01,
0x02, 0x03, 0x03, 0x02, 0x01, 0x00, 0x02, 0x02,
0x03, 0x00, 0x00, 0x00
[NATURE_HARDY] = 3,
[NATURE_LONELY] = 0,
[NATURE_BRAVE] = 1,
[NATURE_ADAMANT] = 0,
[NATURE_NAUGHTY] = 0,
[NATURE_BOLD] = 1,
[NATURE_DOCILE] = 3,
[NATURE_RELAXED] = 0,
[NATURE_IMPISH] = 1,
[NATURE_LAX] = 2,
[NATURE_TIMID] = 2,
[NATURE_HASTY] = 0,
[NATURE_SERIOUS] = 3,
[NATURE_JOLLY] = 1,
[NATURE_NAIVE] = 3,
[NATURE_MODEST] = 1,
[NATURE_MILD] = 2,
[NATURE_QUIET] = 3,
[NATURE_BASHFUL] = 3,
[NATURE_RASH] = 2,
[NATURE_CALM] = 1,
[NATURE_GENTLE] = 0,
[NATURE_SASSY] = 2,
[NATURE_CAREFUL] = 2,
[NATURE_QUIRKY] = 3,
};
static void Cmd_attackcanceler(void)
@ -2245,7 +2234,7 @@ void SetMoveEffect(bool8 primary, u8 certain)
if (gBattleMons[gEffectBattler].status2 & STATUS2_SUBSTITUTE && affectsUser != MOVE_EFFECT_AFFECTS_USER)
INCREMENT_RESET_RETURN
if (gBattleCommunication[MOVE_EFFECT_BYTE] <= 6) // status change
if (gBattleCommunication[MOVE_EFFECT_BYTE] <= PRIMARY_STATUS_MOVE_EFFECT)
{
switch (sStatusFlagsForMoveEffects[gBattleCommunication[MOVE_EFFECT_BYTE]])
{
@ -2453,7 +2442,7 @@ void SetMoveEffect(bool8 primary, u8 certain)
BattleScriptPush(gBattlescriptCurrInstr + 1);
if (sStatusFlagsForMoveEffects[gBattleCommunication[MOVE_EFFECT_BYTE]] == STATUS1_SLEEP)
gBattleMons[gEffectBattler].status1 |= ((Random() & 3) + 2);
gBattleMons[gEffectBattler].status1 |= STATUS1_SLEEP_TURN((Random() & 3) + 2); // 2-5 turns
else
gBattleMons[gEffectBattler].status1 |= sStatusFlagsForMoveEffects[gBattleCommunication[MOVE_EFFECT_BYTE]];
@ -2513,7 +2502,7 @@ void SetMoveEffect(bool8 primary, u8 certain)
}
else
{
gBattleMons[gEffectBattler].status2 |= (((Random()) % 0x4)) + 2;
gBattleMons[gEffectBattler].status2 |= STATUS2_CONFUSION_TURN(((Random()) % 4) + 2); // 2-5 turns
BattleScriptPush(gBattlescriptCurrInstr + 1);
gBattlescriptCurrInstr = sMoveEffectBS_Ptrs[gBattleCommunication[MOVE_EFFECT_BYTE]];
@ -2546,7 +2535,7 @@ void SetMoveEffect(bool8 primary, u8 certain)
gBattleMons[gEffectBattler].status2 |= STATUS2_MULTIPLETURNS;
gLockedMoves[gEffectBattler] = gCurrentMove;
gBattleMons[gEffectBattler].status2 |= ((Random() & 3) + 2) << 4;
gBattleMons[gEffectBattler].status2 |= STATUS2_UPROAR_TURN((Random() & 3) + 2); // 2-5 turns
BattleScriptPush(gBattlescriptCurrInstr + 1);
gBattlescriptCurrInstr = sMoveEffectBS_Ptrs[gBattleCommunication[MOVE_EFFECT_BYTE]];
@ -2591,7 +2580,7 @@ void SetMoveEffect(bool8 primary, u8 certain)
}
else
{
gBattleMons[gEffectBattler].status2 |= ((Random() & 3) + 3) << 0xD;
gBattleMons[gEffectBattler].status2 |= STATUS2_WRAPPED_TURN((Random() & 3) + 3); // 3-6 turns
*(gBattleStruct->wrappedMove + gEffectBattler * 2 + 0) = gCurrentMove;
*(gBattleStruct->wrappedMove + gEffectBattler * 2 + 1) = gCurrentMove >> 8;
@ -2834,7 +2823,7 @@ void SetMoveEffect(bool8 primary, u8 certain)
{
gBattleMons[gEffectBattler].status2 |= STATUS2_MULTIPLETURNS;
gLockedMoves[gEffectBattler] = gCurrentMove;
gBattleMons[gEffectBattler].status2 |= (((Random() & 1) + 2) << 0xA);
gBattleMons[gEffectBattler].status2 |= STATUS2_LOCK_CONFUSE_TURN((Random() & 1) + 2); // thrash for 2-3 turns
}
break;
case MOVE_EFFECT_KNOCK_OFF:
@ -2929,7 +2918,7 @@ static void Cmd_clearstatusfromeffect(void)
{
gActiveBattler = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]);
if (gBattleCommunication[MOVE_EFFECT_BYTE] <= MOVE_EFFECT_TOXIC)
if (gBattleCommunication[MOVE_EFFECT_BYTE] <= PRIMARY_STATUS_MOVE_EFFECT)
gBattleMons[gActiveBattler].status1 &= (~sStatusFlagsForMoveEffects[gBattleCommunication[MOVE_EFFECT_BYTE]]);
else
gBattleMons[gActiveBattler].status2 &= (~sStatusFlagsForMoveEffects[gBattleCommunication[MOVE_EFFECT_BYTE]]);
@ -3482,7 +3471,7 @@ static void Cmd_getexp(void)
else
{
gBattleStruct->expGetterMonId++;
if (gBattleStruct->expGetterMonId <= 5)
if (gBattleStruct->expGetterMonId < PARTY_SIZE)
gBattleScripting.getexpState = 2; // loop again
else
gBattleScripting.getexpState = 6; // we're done
@ -3552,13 +3541,13 @@ static void Cmd_unknown_24(void)
// Impossible to decompile loops.
for (foundPlayer = 0, i = 0; i < gBattlersCount; i += 2)
{
if (HITMARKER_UNK(i) & gHitMarker && !gSpecialStatuses[i].flag40)
if (HITMARKER_FAINTED2(i) & gHitMarker && !gSpecialStatuses[i].flag40)
foundPlayer++;
}
for (foundOpponent = 0, i = 1; i < gBattlersCount; i += 2)
{
if (HITMARKER_UNK(i) & gHitMarker && !gSpecialStatuses[i].flag40)
if (HITMARKER_FAINTED2(i) & gHitMarker && !gSpecialStatuses[i].flag40)
foundOpponent++;
}
@ -4914,10 +4903,12 @@ static void Cmd_switchindataupdate(void)
SwitchInClearSetData();
if (gBattleTypeFlags & BATTLE_TYPE_PALACE && gBattleMons[gActiveBattler].maxHP / 2 >= gBattleMons[gActiveBattler].hp
&& gBattleMons[gActiveBattler].hp != 0 && !(gBattleMons[gActiveBattler].status1 & STATUS1_SLEEP))
if (gBattleTypeFlags & BATTLE_TYPE_PALACE
&& gBattleMons[gActiveBattler].maxHP / 2 >= gBattleMons[gActiveBattler].hp
&& gBattleMons[gActiveBattler].hp != 0
&& !(gBattleMons[gActiveBattler].status1 & STATUS1_SLEEP))
{
gBattleStruct->field_92 |= gBitTable[gActiveBattler];
gBattleStruct->palaceFlags |= gBitTable[gActiveBattler];
}
gBattleScripting.battler = gActiveBattler;
@ -5101,7 +5092,7 @@ static void Cmd_jumpifcantswitch(void)
break;
}
if (i == 6)
if (i == PARTY_SIZE)
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 2);
else
gBattlescriptCurrInstr += 6;
@ -6588,11 +6579,11 @@ static void Cmd_various(void)
case VARIOUS_GET_MOVE_TARGET:
gBattlerTarget = GetMoveTarget(gCurrentMove, 0);
break;
case 4:
case VARIOUS_GET_BATTLER_FAINTED:
if (gHitMarker & HITMARKER_FAINTED(gActiveBattler))
gBattleCommunication[0] = 1;
gBattleCommunication[0] = TRUE;
else
gBattleCommunication[0] = 0;
gBattleCommunication[0] = FALSE;
break;
case VARIOUS_RESET_INTIMIDATE_TRACE_BITS:
gSpecialStatuses[gActiveBattler].intimidatedMon = 0;
@ -6628,17 +6619,19 @@ static void Cmd_various(void)
gHitMarker &= ~(HITMARKER_x400000);
}
break;
case 8:
gBattleCommunication[0] = 0;
case VARIOUS_PALACE_FLAVOR_TEXT:
// Try and print end-of-turn Battle Palace flavor text (e.g. "A glint appears in mon's eyes")
gBattleCommunication[0] = FALSE; // whether or not msg should be printed
gBattleScripting.battler = gActiveBattler = gBattleCommunication[1];
if (!(gBattleStruct->field_92 & gBitTable[gActiveBattler])
if (!(gBattleStruct->palaceFlags & gBitTable[gActiveBattler])
&& gBattleMons[gActiveBattler].maxHP / 2 >= gBattleMons[gActiveBattler].hp
&& gBattleMons[gActiveBattler].hp != 0
&& !(gBattleMons[gActiveBattler].status1 & STATUS1_SLEEP))
{
gBattleStruct->field_92 |= gBitTable[gActiveBattler];
gBattleCommunication[0] = 1;
gBattleCommunication[MULTISTRING_CHOOSER] = sUnknown_0831C4F8[GetNatureFromPersonality(gBattleMons[gActiveBattler].personality)];
gBattleStruct->palaceFlags |= gBitTable[gActiveBattler];
gBattleCommunication[0] = TRUE;
gBattleCommunication[MULTISTRING_CHOOSER] = sBattlePalaceNatureToFlavorTextId[GetNatureFromPersonality(gBattleMons[gActiveBattler].personality)];
}
break;
case VARIOUS_ARENA_JUDGMENT_WINDOW:
@ -7368,7 +7361,7 @@ static void Cmd_setbide(void)
gBattleMons[gBattlerAttacker].status2 |= STATUS2_MULTIPLETURNS;
gLockedMoves[gBattlerAttacker] = gCurrentMove;
gTakenDmg[gBattlerAttacker] = 0;
gBattleMons[gBattlerAttacker].status2 |= (STATUS2_BIDE - 0x100); // 2 turns
gBattleMons[gBattlerAttacker].status2 |= STATUS2_BIDE_TURN(2);
gBattlescriptCurrInstr++;
}
@ -8326,7 +8319,7 @@ static void Cmd_settypetorandomresistance(void) // conversion 2
static void Cmd_setalwayshitflag(void)
{
gStatuses3[gBattlerTarget] &= ~(STATUS3_ALWAYS_HITS);
gStatuses3[gBattlerTarget] |= 0x10;
gStatuses3[gBattlerTarget] |= STATUS3_ALWAYS_HITS_TURN(2);
gDisableStructs[gBattlerTarget].battlerWithSureHit = gBattlerAttacker;
gBattlescriptCurrInstr++;
}
@ -9145,7 +9138,7 @@ static void Cmd_trydobeatup(void)
else
{
u8 beforeLoop = gBattleCommunication[0];
for (;gBattleCommunication[0] < 6; gBattleCommunication[0]++)
for (;gBattleCommunication[0] < PARTY_SIZE; gBattleCommunication[0]++)
{
if (GetMonData(&party[gBattleCommunication[0]], MON_DATA_HP)
&& GetMonData(&party[gBattleCommunication[0]], MON_DATA_SPECIES2)
@ -9153,7 +9146,7 @@ static void Cmd_trydobeatup(void)
&& !GetMonData(&party[gBattleCommunication[0]], MON_DATA_STATUS))
break;
}
if (gBattleCommunication[0] < 6)
if (gBattleCommunication[0] < PARTY_SIZE)
{
PREPARE_MON_NICK_WITH_PREFIX_BUFFER(gBattleTextBuff1, gBattlerAttacker, gBattleCommunication[0])
@ -9520,7 +9513,7 @@ static void Cmd_setyawn(void)
}
else
{
gStatuses3[gBattlerTarget] |= 0x1000;
gStatuses3[gBattlerTarget] |= STATUS3_YAWN_TURN(2);
gBattlescriptCurrInstr += 5;
}
}
@ -9654,7 +9647,7 @@ static void Cmd_assistattackselect(void)
else
party = gPlayerParty;
for (monId = 0; monId < 6; monId++)
for (monId = 0; monId < PARTY_SIZE; monId++)
{
if (monId == gBattlerPartyIndexes[gBattlerAttacker])
continue;
@ -9865,7 +9858,7 @@ static void Cmd_pickup(void)
if (lvlDivBy10 > 9)
lvlDivBy10 = 9;
for (j = 0; j < 9; j++)
for (j = 0; j < (int)ARRAY_COUNT(sPickupProbabilities); j++)
{
if (sPickupProbabilities[j] > rand)
{
@ -10134,7 +10127,7 @@ static void Cmd_handleballthrow(void)
}
}
else
ballMultiplier = sBallCatchBonuses[gLastUsedItem - 2];
ballMultiplier = sBallCatchBonuses[gLastUsedItem - ITEM_ULTRA_BALL];
odds = (catchRate * ballMultiplier / 10)
* (gBattleMons[gBattlerTarget].maxHP * 3 - gBattleMons[gBattlerTarget].hp * 2)
@ -10436,7 +10429,7 @@ static void Cmd_trygivecaughtmonnick(void)
}
break;
case 4:
if (CalculatePlayerPartyCount() == 6)
if (CalculatePlayerPartyCount() == PARTY_SIZE)
gBattlescriptCurrInstr += 5;
else
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1);

View File

@ -124,28 +124,43 @@ static const u8 sBattleTransitionTable_Trainer[][2] =
{B_TRANSITION_SWIRL, B_TRANSITION_RIPPLE}, // Water
};
static const u8 sUnknown_0854FE98[] =
// Battle Frontier (excluding Pyramid and Dome, which have their own tables below)
static const u8 sBattleTransitionTable_BattleFrontier[] =
{
B_TRANSITION_29, B_TRANSITION_30, B_TRANSITION_31, B_TRANSITION_32,
B_TRANSITION_34, B_TRANSITION_35, B_TRANSITION_36, B_TRANSITION_37,
B_TRANSITION_38, B_TRANSITION_39, B_TRANSITION_40, B_TRANSITION_41
B_TRANSITION_FRONTIER_LOGO_WIGGLE,
B_TRANSITION_FRONTIER_LOGO_WAVE,
B_TRANSITION_FRONTIER_SQUARES,
B_TRANSITION_FRONTIER_SQUARES_SCROLL,
B_TRANSITION_FRONTIER_CIRCLES_MEET,
B_TRANSITION_FRONTIER_CIRCLES_CROSS,
B_TRANSITION_FRONTIER_CIRCLES_ASYMMETRIC_SPIRAL,
B_TRANSITION_FRONTIER_CIRCLES_SYMMETRIC_SPIRAL,
B_TRANSITION_FRONTIER_CIRCLES_MEET_IN_SEQ,
B_TRANSITION_FRONTIER_CIRCLES_CROSS_IN_SEQ,
B_TRANSITION_FRONTIER_CIRCLES_ASYMMETRIC_SPIRAL_IN_SEQ,
B_TRANSITION_FRONTIER_CIRCLES_SYMMETRIC_SPIRAL_IN_SEQ
};
static const u8 sUnknown_0854FEA4[] =
static const u8 sBattleTransitionTable_BattlePyramid[] =
{
B_TRANSITION_31, B_TRANSITION_32, B_TRANSITION_33
B_TRANSITION_FRONTIER_SQUARES,
B_TRANSITION_FRONTIER_SQUARES_SCROLL,
B_TRANSITION_FRONTIER_SQUARES_SPIRAL
};
static const u8 sUnknown_0854FEA7[] =
static const u8 sBattleTransitionTable_BattleDome[] =
{
B_TRANSITION_29, B_TRANSITION_31, B_TRANSITION_32, B_TRANSITION_33
B_TRANSITION_FRONTIER_LOGO_WIGGLE,
B_TRANSITION_FRONTIER_SQUARES,
B_TRANSITION_FRONTIER_SQUARES_SCROLL,
B_TRANSITION_FRONTIER_SQUARES_SPIRAL
};
static const struct TrainerBattleParameter sOrdinaryBattleParams[] =
{
{&sTrainerBattleMode, TRAINER_PARAM_LOAD_VAL_8BIT},
{&gTrainerBattleOpponent_A, TRAINER_PARAM_LOAD_VAL_16BIT},
{&sTrainerObjectEventLocalId, TRAINER_PARAM_LOAD_VAL_16BIT},
{&sTrainerObjectEventLocalId, TRAINER_PARAM_LOAD_VAL_16BIT},
{&sTrainerAIntroSpeech, TRAINER_PARAM_LOAD_VAL_32BIT},
{&sTrainerADefeatSpeech, TRAINER_PARAM_LOAD_VAL_32BIT},
{&sTrainerVictorySpeech, TRAINER_PARAM_CLEAR_VAL_32BIT},
@ -158,7 +173,7 @@ static const struct TrainerBattleParameter sContinueScriptBattleParams[] =
{
{&sTrainerBattleMode, TRAINER_PARAM_LOAD_VAL_8BIT},
{&gTrainerBattleOpponent_A, TRAINER_PARAM_LOAD_VAL_16BIT},
{&sTrainerObjectEventLocalId, TRAINER_PARAM_LOAD_VAL_16BIT},
{&sTrainerObjectEventLocalId, TRAINER_PARAM_LOAD_VAL_16BIT},
{&sTrainerAIntroSpeech, TRAINER_PARAM_LOAD_VAL_32BIT},
{&sTrainerADefeatSpeech, TRAINER_PARAM_LOAD_VAL_32BIT},
{&sTrainerVictorySpeech, TRAINER_PARAM_CLEAR_VAL_32BIT},
@ -171,7 +186,7 @@ static const struct TrainerBattleParameter sDoubleBattleParams[] =
{
{&sTrainerBattleMode, TRAINER_PARAM_LOAD_VAL_8BIT},
{&gTrainerBattleOpponent_A, TRAINER_PARAM_LOAD_VAL_16BIT},
{&sTrainerObjectEventLocalId, TRAINER_PARAM_LOAD_VAL_16BIT},
{&sTrainerObjectEventLocalId, TRAINER_PARAM_LOAD_VAL_16BIT},
{&sTrainerAIntroSpeech, TRAINER_PARAM_LOAD_VAL_32BIT},
{&sTrainerADefeatSpeech, TRAINER_PARAM_LOAD_VAL_32BIT},
{&sTrainerVictorySpeech, TRAINER_PARAM_CLEAR_VAL_32BIT},
@ -184,7 +199,7 @@ static const struct TrainerBattleParameter sOrdinaryNoIntroBattleParams[] =
{
{&sTrainerBattleMode, TRAINER_PARAM_LOAD_VAL_8BIT},
{&gTrainerBattleOpponent_A, TRAINER_PARAM_LOAD_VAL_16BIT},
{&sTrainerObjectEventLocalId, TRAINER_PARAM_LOAD_VAL_16BIT},
{&sTrainerObjectEventLocalId, TRAINER_PARAM_LOAD_VAL_16BIT},
{&sTrainerAIntroSpeech, TRAINER_PARAM_CLEAR_VAL_32BIT},
{&sTrainerADefeatSpeech, TRAINER_PARAM_LOAD_VAL_32BIT},
{&sTrainerVictorySpeech, TRAINER_PARAM_CLEAR_VAL_32BIT},
@ -197,7 +212,7 @@ static const struct TrainerBattleParameter sContinueScriptDoubleBattleParams[] =
{
{&sTrainerBattleMode, TRAINER_PARAM_LOAD_VAL_8BIT},
{&gTrainerBattleOpponent_A, TRAINER_PARAM_LOAD_VAL_16BIT},
{&sTrainerObjectEventLocalId, TRAINER_PARAM_LOAD_VAL_16BIT},
{&sTrainerObjectEventLocalId, TRAINER_PARAM_LOAD_VAL_16BIT},
{&sTrainerAIntroSpeech, TRAINER_PARAM_LOAD_VAL_32BIT},
{&sTrainerADefeatSpeech, TRAINER_PARAM_LOAD_VAL_32BIT},
{&sTrainerVictorySpeech, TRAINER_PARAM_CLEAR_VAL_32BIT},
@ -210,7 +225,7 @@ static const struct TrainerBattleParameter sTrainerBOrdinaryBattleParams[] =
{
{&sTrainerBattleMode, TRAINER_PARAM_LOAD_VAL_8BIT},
{&gTrainerBattleOpponent_B, TRAINER_PARAM_LOAD_VAL_16BIT},
{&sTrainerObjectEventLocalId, TRAINER_PARAM_LOAD_VAL_16BIT},
{&sTrainerObjectEventLocalId, TRAINER_PARAM_LOAD_VAL_16BIT},
{&sTrainerBIntroSpeech, TRAINER_PARAM_LOAD_VAL_32BIT},
{&sTrainerBDefeatSpeech, TRAINER_PARAM_LOAD_VAL_32BIT},
{&sTrainerVictorySpeech, TRAINER_PARAM_CLEAR_VAL_32BIT},
@ -223,7 +238,7 @@ static const struct TrainerBattleParameter sTrainerBContinueScriptBattleParams[]
{
{&sTrainerBattleMode, TRAINER_PARAM_LOAD_VAL_8BIT},
{&gTrainerBattleOpponent_B, TRAINER_PARAM_LOAD_VAL_16BIT},
{&sTrainerObjectEventLocalId, TRAINER_PARAM_LOAD_VAL_16BIT},
{&sTrainerObjectEventLocalId, TRAINER_PARAM_LOAD_VAL_16BIT},
{&sTrainerBIntroSpeech, TRAINER_PARAM_LOAD_VAL_32BIT},
{&sTrainerBDefeatSpeech, TRAINER_PARAM_LOAD_VAL_32BIT},
{&sTrainerVictorySpeech, TRAINER_PARAM_CLEAR_VAL_32BIT},
@ -234,7 +249,7 @@ static const struct TrainerBattleParameter sTrainerBContinueScriptBattleParams[]
#define REMATCH(trainer1, trainer2, trainer3, trainer4, trainer5, map) \
{ \
.trainerIds = {trainer1, trainer2, trainer3, trainer4, trainer5}, \
.trainerIds = {trainer1, trainer2, trainer3, trainer4, trainer5}, \
.mapGroup = MAP_GROUP(map), \
.mapNum = MAP_NUM(map), \
}
@ -449,9 +464,9 @@ static void DoTrainerBattle(void)
static void sub_80B0828(void)
{
if (InBattlePyramid())
CreateBattleStartTask(sub_80B100C(10), 0);
CreateBattleStartTask(GetSpecialBattleTransition(10), 0);
else
CreateBattleStartTask(sub_80B100C(11), 0);
CreateBattleStartTask(GetSpecialBattleTransition(11), 0);
IncrementGameStat(GAME_STAT_TOTAL_BATTLES);
IncrementGameStat(GAME_STAT_TRAINER_BATTLES);
@ -839,7 +854,17 @@ static u8 GetTrainerBattleTransition(void)
return sBattleTransitionTable_Trainer[transitionType][1];
}
u8 sub_80B100C(s32 arg0)
// 0: Battle Tower
// 3: Battle Dome
// 4: Battle Palace
// 5: Battle Arena
// 6: Battle Factory
// 7: Battle Pike
// 10: Battle Pyramid
// 11: Trainer Hill
// 12: Secret Base
// 13: E-Reader
u8 GetSpecialBattleTransition(s32 id)
{
u16 var;
u8 enemyLevel = GetMonData(&gEnemyParty[0], MON_DATA_LEVEL);
@ -847,43 +872,43 @@ u8 sub_80B100C(s32 arg0)
if (enemyLevel < playerLevel)
{
switch (arg0)
switch (id)
{
case 11:
case 12:
case 13:
return B_TRANSITION_POKEBALLS_TRAIL;
case 10:
return sUnknown_0854FEA4[Random() % ARRAY_COUNT(sUnknown_0854FEA4)];
return sBattleTransitionTable_BattlePyramid[Random() % ARRAY_COUNT(sBattleTransitionTable_BattlePyramid)];
case 3:
return sUnknown_0854FEA7[Random() % ARRAY_COUNT(sUnknown_0854FEA7)];
return sBattleTransitionTable_BattleDome[Random() % ARRAY_COUNT(sBattleTransitionTable_BattleDome)];
}
if (VarGet(VAR_FRONTIER_BATTLE_MODE) != FRONTIER_MODE_LINK_MULTIS)
return sUnknown_0854FE98[Random() % ARRAY_COUNT(sUnknown_0854FE98)];
return sBattleTransitionTable_BattleFrontier[Random() % ARRAY_COUNT(sBattleTransitionTable_BattleFrontier)];
}
else
{
switch (arg0)
switch (id)
{
case 11:
case 12:
case 13:
return B_TRANSITION_BIG_POKEBALL;
case 10:
return sUnknown_0854FEA4[Random() % ARRAY_COUNT(sUnknown_0854FEA4)];
return sBattleTransitionTable_BattlePyramid[Random() % ARRAY_COUNT(sBattleTransitionTable_BattlePyramid)];
case 3:
return sUnknown_0854FEA7[Random() % ARRAY_COUNT(sUnknown_0854FEA7)];
return sBattleTransitionTable_BattleDome[Random() % ARRAY_COUNT(sBattleTransitionTable_BattleDome)];
}
if (VarGet(VAR_FRONTIER_BATTLE_MODE) != FRONTIER_MODE_LINK_MULTIS)
return sUnknown_0854FE98[Random() % ARRAY_COUNT(sUnknown_0854FE98)];
return sBattleTransitionTable_BattleFrontier[Random() % ARRAY_COUNT(sBattleTransitionTable_BattleFrontier)];
}
var = gSaveBlock2Ptr->frontier.trainerIds[gSaveBlock2Ptr->frontier.curChallengeBattleNum * 2 + 0]
+ gSaveBlock2Ptr->frontier.trainerIds[gSaveBlock2Ptr->frontier.curChallengeBattleNum * 2 + 1];
return sUnknown_0854FE98[var % ARRAY_COUNT(sUnknown_0854FE98)];
return sBattleTransitionTable_BattleFrontier[var % ARRAY_COUNT(sBattleTransitionTable_BattleFrontier)];
}
void ChooseStarter(void)

View File

@ -2028,7 +2028,7 @@ void DoSpecialTrainerBattle(void)
}
CreateTask(Task_StartBattleAfterTransition, 1);
PlayMapChosenOrBattleBGM(0);
BattleTransition_StartOnField(sub_80B100C(0));
BattleTransition_StartOnField(GetSpecialBattleTransition(0));
break;
case SPECIAL_BATTLE_SECRET_BASE:
for (i = 0; i < PARTY_SIZE; i++)
@ -2038,7 +2038,7 @@ void DoSpecialTrainerBattle(void)
}
CreateTask(Task_StartBattleAfterTransition, 1);
PlayMapChosenOrBattleBGM(0);
BattleTransition_StartOnField(sub_80B100C(12));
BattleTransition_StartOnField(GetSpecialBattleTransition(12));
break;
case SPECIAL_BATTLE_EREADER:
ZeroEnemyPartyMons();
@ -2048,7 +2048,7 @@ void DoSpecialTrainerBattle(void)
gTrainerBattleOpponent_A = 0;
CreateTask(Task_StartBattleAfterTransition, 1);
PlayMapChosenOrBattleBGM(0);
BattleTransition_StartOnField(sub_80B100C(13));
BattleTransition_StartOnField(GetSpecialBattleTransition(13));
break;
case SPECIAL_BATTLE_DOME:
gBattleTypeFlags = BATTLE_TYPE_TRAINER | BATTLE_TYPE_DOME;
@ -2058,7 +2058,7 @@ void DoSpecialTrainerBattle(void)
FillFrontierTrainerParty(DOME_BATTLE_PARTY_SIZE);
CreateTask(Task_StartBattleAfterTransition, 1);
sub_806E694(0);
BattleTransition_StartOnField(sub_80B100C(3));
BattleTransition_StartOnField(GetSpecialBattleTransition(3));
break;
case SPECIAL_BATTLE_PALACE:
gBattleTypeFlags = BATTLE_TYPE_TRAINER | BATTLE_TYPE_PALACE;
@ -2070,7 +2070,7 @@ void DoSpecialTrainerBattle(void)
FillTentTrainerParty(FRONTIER_PARTY_SIZE);
CreateTask(Task_StartBattleAfterTransition, 1);
PlayMapChosenOrBattleBGM(0);
BattleTransition_StartOnField(sub_80B100C(4));
BattleTransition_StartOnField(GetSpecialBattleTransition(4));
break;
case SPECIAL_BATTLE_ARENA:
gBattleTypeFlags = BATTLE_TYPE_TRAINER | BATTLE_TYPE_ARENA;
@ -2080,7 +2080,7 @@ void DoSpecialTrainerBattle(void)
FillTentTrainerParty(FRONTIER_PARTY_SIZE);
CreateTask(Task_StartBattleAfterTransition, 1);
PlayMapChosenOrBattleBGM(0);
BattleTransition_StartOnField(sub_80B100C(5));
BattleTransition_StartOnField(GetSpecialBattleTransition(5));
break;
case SPECIAL_BATTLE_FACTORY:
gBattleTypeFlags = BATTLE_TYPE_TRAINER | BATTLE_TYPE_FACTORY;
@ -2089,28 +2089,28 @@ void DoSpecialTrainerBattle(void)
FillFactoryTrainerParty();
CreateTask(Task_StartBattleAfterTransition, 1);
PlayMapChosenOrBattleBGM(0);
BattleTransition_StartOnField(sub_80B100C(6));
BattleTransition_StartOnField(GetSpecialBattleTransition(6));
break;
case SPECIAL_BATTLE_PIKE_SINGLE:
gBattleTypeFlags = BATTLE_TYPE_TRAINER | BATTLE_TYPE_BATTLE_TOWER;
FillFrontierTrainerParty(FRONTIER_PARTY_SIZE);
CreateTask(Task_StartBattleAfterTransition, 1);
PlayMapChosenOrBattleBGM(0);
BattleTransition_StartOnField(sub_80B100C(7));
BattleTransition_StartOnField(GetSpecialBattleTransition(7));
break;
case SPECIAL_BATTLE_PYRAMID:
gBattleTypeFlags = BATTLE_TYPE_TRAINER | BATTLE_TYPE_PYRAMID;
FillFrontierTrainerParty(FRONTIER_PARTY_SIZE);
CreateTask(Task_StartBattleAfterTransition, 1);
PlayMapChosenOrBattleBGM(0);
BattleTransition_StartOnField(sub_80B100C(10));
BattleTransition_StartOnField(GetSpecialBattleTransition(10));
break;
case SPECIAL_BATTLE_PIKE_DOUBLE:
gBattleTypeFlags = BATTLE_TYPE_TRAINER | BATTLE_TYPE_BATTLE_TOWER | BATTLE_TYPE_DOUBLE | BATTLE_TYPE_TWO_OPPONENTS;
FillFrontierTrainersParties(1);
CreateTask(Task_StartBattleAfterTransition, 1);
PlayMapChosenOrBattleBGM(0);
BattleTransition_StartOnField(sub_80B100C(7));
BattleTransition_StartOnField(GetSpecialBattleTransition(7));
break;
case SPECIAL_BATTLE_STEVEN:
gBattleTypeFlags = BATTLE_TYPE_TRAINER | BATTLE_TYPE_DOUBLE | BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_MULTI | BATTLE_TYPE_INGAME_PARTNER;

View File

@ -1,6 +1,7 @@
#include "global.h"
#include "battle.h"
#include "battle_transition.h"
#include "battle_transition_frontier.h"
#include "bg.h"
#include "decompress.h"
#include "event_object_movement.h"
@ -18,7 +19,6 @@
#include "sprite.h"
#include "task.h"
#include "trig.h"
#include "unk_transition.h"
#include "util.h"
#include "constants/field_effects.h"
#include "constants/songs.h"
@ -93,11 +93,11 @@ static void Phase2Task_ShredSplit(u8 taskId);
static void Phase2Task_Blackhole1(u8 taskId);
static void Phase2Task_Blackhole2(u8 taskId);
static void Phase2Task_RectangularSpiral(u8 taskId);
static void Phase2Task_29(u8 taskId);
static void Phase2Task_30(u8 taskId);
static void Phase2Task_31(u8 taskId);
static void Phase2Task_32(u8 taskId);
static void Phase2Task_33(u8 taskId);
static void Phase2Task_FrontierLogoWiggle(u8 taskId);
static void Phase2Task_FrontierLogoWave(u8 taskId);
static void Phase2Task_FrontierSquares(u8 taskId);
static void Phase2Task_FrontierSquaresScroll(u8 taskId);
static void Phase2Task_FrontierSquaresSpiral(u8 taskId);
static void VBlankCB_BattleTransition(void);
static void VBlankCB_Phase2_Swirl(void);
static void HBlankCB_Phase2_Swirl(void);
@ -192,12 +192,12 @@ static bool8 Phase2_Blackhole2_Func2(struct Task *task);
static bool8 Phase2_RectangularSpiral_Func1(struct Task *task);
static bool8 Phase2_RectangularSpiral_Func2(struct Task *task);
static bool8 Phase2_RectangularSpiral_Func3(struct Task *task);
static bool8 Phase2_29_Func1(struct Task *task);
static bool8 Phase2_29_Func2(struct Task *task);
static bool8 Phase2_30_Func1(struct Task *task);
static bool8 Phase2_30_Func2(struct Task *task);
static bool8 Phase2_30_Func3(struct Task *task);
static bool8 Phase2_30_Func4(struct Task *task);
static bool8 Phase2_FrontierLogoWiggle_Func1(struct Task *task);
static bool8 Phase2_FrontierLogoWiggle_Func2(struct Task *task);
static bool8 Phase2_FrontierLogoWave_Func1(struct Task *task);
static bool8 Phase2_FrontierLogoWave_Func2(struct Task *task);
static bool8 Phase2_FrontierLogoWave_Func3(struct Task *task);
static bool8 Phase2_FrontierLogoWave_Func4(struct Task *task);
static bool8 Phase2_Rayquaza_Func3(struct Task *task);
static bool8 Phase2_Rayquaza_Func4(struct Task *task);
static bool8 Phase2_Rayquaza_Func5(struct Task *task);
@ -205,19 +205,19 @@ static bool8 Phase2_Rayquaza_Func6(struct Task *task);
static bool8 Phase2_Rayquaza_Func7(struct Task *task);
static bool8 Phase2_Rayquaza_Func8(struct Task *task);
static bool8 Phase2_Rayquaza_Func9(struct Task *task);
static bool8 Phase2_31_Func1(struct Task *task);
static bool8 Phase2_31_Func2(struct Task *task);
static bool8 Phase2_31_Func3(struct Task *task);
static bool8 Phase2_31_33_Func5(struct Task *task);
static bool8 Phase2_33_Func1(struct Task *task);
static bool8 Phase2_33_Func2(struct Task *task);
static bool8 Phase2_33_Func3(struct Task *task);
static bool8 Phase2_33_Func4(struct Task *task);
static bool8 Phase2_32_Func1(struct Task *task);
static bool8 Phase2_32_Func2(struct Task *task);
static bool8 Phase2_32_Func3(struct Task *task);
static bool8 Phase2_32_Func4(struct Task *task);
static bool8 Phase2_32_Func5(struct Task *task);
static bool8 Phase2_FrontierSquares_Func1(struct Task *task);
static bool8 Phase2_FrontierSquares_Func2(struct Task *task);
static bool8 Phase2_FrontierSquares_Func3(struct Task *task);
static bool8 Phase2_FrontierSquares_End(struct Task *task);
static bool8 Phase2_FrontierSquaresSpiral_Func1(struct Task *task);
static bool8 Phase2_FrontierSquaresSpiral_Func2(struct Task *task);
static bool8 Phase2_FrontierSquaresSpiral_Func3(struct Task *task);
static bool8 Phase2_FrontierSquaresSpiral_Func4(struct Task *task);
static bool8 Phase2_FrontierSquaresScroll_Func1(struct Task *task);
static bool8 Phase2_FrontierSquaresScroll_Func2(struct Task *task);
static bool8 Phase2_FrontierSquaresScroll_Func3(struct Task *task);
static bool8 Phase2_FrontierSquaresScroll_Func4(struct Task *task);
static bool8 Phase2_FrontierSquaresScroll_Func5(struct Task *task);
static bool8 Phase2_Mugshot_Func1(struct Task *task);
static bool8 Phase2_Mugshot_Func2(struct Task *task);
static bool8 Phase2_Mugshot_Func3(struct Task *task);
@ -302,15 +302,15 @@ static const u16 sGroudon2_Palette[] = INCBIN_U16("graphics/battle_transitions/g
static const u16 sRayquaza_Palette[] = INCBIN_U16("graphics/battle_transitions/rayquaza.gbapal");
static const u32 sRayquaza_Tileset[] = INCBIN_U32("graphics/battle_transitions/rayquaza.4bpp");
static const u32 sRayquaza_Tilemap[] = INCBIN_U32("graphics/battle_transitions/rayquaza.bin");
static const u16 gUnknown_085C7BE0[] = INCBIN_U16("graphics/battle_transitions/frontier_brain.gbapal");
static const u32 gUnknown_085C7C00[] = INCBIN_U32("graphics/battle_transitions/frontier_brain.4bpp.lz");
static const u32 gUnknown_085C828C[] = INCBIN_U32("graphics/battle_transitions/frontier_brain.bin.lz");
static const u16 gUnknown_085C8578[] = INCBIN_U16("graphics/battle_transitions/frontier_squares_blanktiles.gbapal");
static const u32 gUnknown_085C8598[] = INCBIN_U32("graphics/battle_transitions/frontier_square_1.4bpp.lz");
static const u32 gUnknown_085C86F4[] = INCBIN_U32("graphics/battle_transitions/frontier_square_2.4bpp.lz");
static const u32 gUnknown_085C87F4[] = INCBIN_U32("graphics/battle_transitions/frontier_square_3.4bpp.lz");
static const u32 gUnknown_085C88A4[] = INCBIN_U32("graphics/battle_transitions/frontier_square_4.4bpp.lz");
static const u32 gUnknown_085C8928[] = INCBIN_U32("graphics/battle_transitions/frontier_squares.bin");
static const u16 sFrontierLogo_Palette[] = INCBIN_U16("graphics/battle_transitions/frontier_logo.gbapal");
static const u32 sFrontierLogo_Tileset[] = INCBIN_U32("graphics/battle_transitions/frontier_logo.4bpp.lz");
static const u32 sFrontierLogo_Tilemap[] = INCBIN_U32("graphics/battle_transitions/frontier_logo.bin.lz");
static const u16 sFrontierSquares_Palette[] = INCBIN_U16("graphics/battle_transitions/frontier_squares_blanktiles.gbapal");
static const u32 sFrontierSquares_FilledBg_Tileset[] = INCBIN_U32("graphics/battle_transitions/frontier_square_1.4bpp.lz");
static const u32 sFrontierSquares_EmptyBg_Tileset[] = INCBIN_U32("graphics/battle_transitions/frontier_square_2.4bpp.lz");
static const u32 sFrontierSquares_Shrink1_Tileset[] = INCBIN_U32("graphics/battle_transitions/frontier_square_3.4bpp.lz");
static const u32 sFrontierSquares_Shrink2_Tileset[] = INCBIN_U32("graphics/battle_transitions/frontier_square_4.4bpp.lz");
static const u32 sFrontierSquares_Tilemap[] = INCBIN_U32("graphics/battle_transitions/frontier_squares.bin");
static const TaskFunc sPhase1_Tasks[B_TRANSITION_COUNT] =
{
@ -348,19 +348,19 @@ static const TaskFunc sPhase2_Tasks[B_TRANSITION_COUNT] =
[B_TRANSITION_BLACKHOLE1] = Phase2Task_Blackhole1,
[B_TRANSITION_BLACKHOLE2] = Phase2Task_Blackhole2,
[B_TRANSITION_RECTANGULAR_SPIRAL] = Phase2Task_RectangularSpiral,
[B_TRANSITION_29] = Phase2Task_29,
[B_TRANSITION_30] = Phase2Task_30,
[B_TRANSITION_31] = Phase2Task_31,
[B_TRANSITION_32] = Phase2Task_32,
[B_TRANSITION_33] = Phase2Task_33,
[B_TRANSITION_34] = Phase2Task_34,
[B_TRANSITION_35] = Phase2Task_35,
[B_TRANSITION_36] = Phase2Task_36,
[B_TRANSITION_37] = Phase2Task_37,
[B_TRANSITION_38] = Phase2Task_38,
[B_TRANSITION_39] = Phase2Task_39,
[B_TRANSITION_40] = Phase2Task_40,
[B_TRANSITION_41] = Phase2Task_41,
[B_TRANSITION_FRONTIER_LOGO_WIGGLE] = Phase2Task_FrontierLogoWiggle,
[B_TRANSITION_FRONTIER_LOGO_WAVE] = Phase2Task_FrontierLogoWave,
[B_TRANSITION_FRONTIER_SQUARES] = Phase2Task_FrontierSquares,
[B_TRANSITION_FRONTIER_SQUARES_SCROLL] = Phase2Task_FrontierSquaresScroll,
[B_TRANSITION_FRONTIER_SQUARES_SPIRAL] = Phase2Task_FrontierSquaresSpiral,
[B_TRANSITION_FRONTIER_CIRCLES_MEET] = Phase2Task_FrontierCirclesMeet,
[B_TRANSITION_FRONTIER_CIRCLES_CROSS] = Phase2Task_FrontierCirclesCross,
[B_TRANSITION_FRONTIER_CIRCLES_ASYMMETRIC_SPIRAL] = Phase2Task_FrontierCirclesAsymmetricSpiral,
[B_TRANSITION_FRONTIER_CIRCLES_SYMMETRIC_SPIRAL] = Phase2Task_FrontierCirclesSymmetricSpiral,
[B_TRANSITION_FRONTIER_CIRCLES_MEET_IN_SEQ] = Phase2Task_FrontierCirclesMeetInSeq,
[B_TRANSITION_FRONTIER_CIRCLES_CROSS_IN_SEQ] = Phase2Task_FrontierCirclesCrossInSeq,
[B_TRANSITION_FRONTIER_CIRCLES_ASYMMETRIC_SPIRAL_IN_SEQ] = Phase2Task_FrontierCirclesAsymmetricSpiralInSeq,
[B_TRANSITION_FRONTIER_CIRCLES_SYMMETRIC_SPIRAL_IN_SEQ] = Phase2Task_FrontierCirclesSymmetricSpiralInSeq,
};
static const TransitionStateFunc sMainTransitionPhases[] =
@ -856,48 +856,48 @@ static const struct SpritePalette sSpritePalette_UnusedTrainer =
static const u16 sBigPokeball_Tilemap[] = INCBIN_U16("graphics/battle_transitions/big_pokeball_map.bin");
static const u16 sMugshotsTilemap[] = INCBIN_U16("graphics/battle_transitions/elite_four_bg_map.bin");
static const TransitionStateFunc sPhase2_29_Funcs[] =
static const TransitionStateFunc sPhase2_FrontierLogoWiggle_Funcs[] =
{
Phase2_29_Func1,
Phase2_29_Func2,
Phase2_FrontierLogoWiggle_Func1,
Phase2_FrontierLogoWiggle_Func2,
Phase2_BigPokeball_Func3,
Phase2_BigPokeball_Func4,
Phase2_BigPokeball_Func5,
Phase2_BigPokeball_Func6
};
static const TransitionStateFunc sPhase2_30_Funcs[] =
static const TransitionStateFunc sPhase2_FrontierLogoWave_Funcs[] =
{
Phase2_30_Func1,
Phase2_30_Func2,
Phase2_30_Func3,
Phase2_30_Func4
Phase2_FrontierLogoWave_Func1,
Phase2_FrontierLogoWave_Func2,
Phase2_FrontierLogoWave_Func3,
Phase2_FrontierLogoWave_Func4
};
static const TransitionStateFunc sPhase2_31_Funcs[] =
static const TransitionStateFunc sPhase2_FrontierSquares_Funcs[] =
{
Phase2_31_Func1,
Phase2_31_Func2,
Phase2_31_Func3,
Phase2_31_33_Func5
Phase2_FrontierSquares_Func1,
Phase2_FrontierSquares_Func2,
Phase2_FrontierSquares_Func3,
Phase2_FrontierSquares_End
};
static const TransitionStateFunc sPhase2_33_Funcs[] =
static const TransitionStateFunc sPhase2_FrontierSquaresSpiral_Funcs[] =
{
Phase2_33_Func1,
Phase2_33_Func2,
Phase2_33_Func3,
Phase2_33_Func4,
Phase2_31_33_Func5
Phase2_FrontierSquaresSpiral_Func1,
Phase2_FrontierSquaresSpiral_Func2,
Phase2_FrontierSquaresSpiral_Func3,
Phase2_FrontierSquaresSpiral_Func4,
Phase2_FrontierSquares_End
};
static const TransitionStateFunc sPhase2_32_Funcs[] =
static const TransitionStateFunc sPhase2_FrontierSquaresScroll_Funcs[] =
{
Phase2_32_Func1,
Phase2_32_Func2,
Phase2_32_Func3,
Phase2_32_Func4,
Phase2_32_Func5
Phase2_FrontierSquaresScroll_Func1,
Phase2_FrontierSquaresScroll_Func2,
Phase2_FrontierSquaresScroll_Func3,
Phase2_FrontierSquaresScroll_Func4,
Phase2_FrontierSquaresScroll_Func5
};
static const u8 gUnknown_085C9A30[] = {0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x1b, 0x14, 0x0d, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x07, 0x0e, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x13, 0x0c, 0x0b, 0x0a, 0x09, 0x08, 0x0f, 0x10, 0x11, 0x12};
@ -3856,43 +3856,43 @@ static bool8 sub_814A228(s16 *data, bool8 a1, bool8 a2)
#define tData6 data[6]
#define tData7 data[7]
static bool8 Phase2_29_Func1(struct Task *task)
static bool8 Phase2_FrontierLogoWiggle_Func1(struct Task *task)
{
u16 *tilemap, *tileset;
sub_814669C(task);
GetBg0TilesDst(&tilemap, &tileset);
CpuFill16(0, tilemap, 0x800);
LZ77UnCompVram(gUnknown_085C7C00, tileset);
LoadPalette(gUnknown_085C7BE0, 0xF0, 0x20);
LZ77UnCompVram(sFrontierLogo_Tileset, tileset);
LoadPalette(sFrontierLogo_Palette, 0xF0, 0x20);
task->tState++;
return FALSE;
}
static bool8 Phase2_29_Func2(struct Task *task)
static bool8 Phase2_FrontierLogoWiggle_Func2(struct Task *task)
{
u16 *tilemap, *tileset;
GetBg0TilesDst(&tilemap, &tileset);
LZ77UnCompVram(gUnknown_085C828C, tilemap);
LZ77UnCompVram(sFrontierLogo_Tilemap, tilemap);
sub_8149F98(gScanlineEffectRegBuffers[0], 0, task->tData4, 0x84, task->tData5, 160);
task->tState++;
return TRUE;
}
static void Phase2Task_29(u8 taskId)
static void Phase2Task_FrontierLogoWiggle(u8 taskId)
{
while (sPhase2_29_Funcs[gTasks[taskId].tState](&gTasks[taskId]));
while (sPhase2_FrontierLogoWiggle_Funcs[gTasks[taskId].tState](&gTasks[taskId]));
}
static void Phase2Task_30(u8 taskId)
static void Phase2Task_FrontierLogoWave(u8 taskId)
{
while (sPhase2_30_Funcs[gTasks[taskId].tState](&gTasks[taskId]));
while (sPhase2_FrontierLogoWave_Funcs[gTasks[taskId].tState](&gTasks[taskId]));
}
static bool8 Phase2_30_Func1(struct Task *task)
static bool8 Phase2_FrontierLogoWave_Func1(struct Task *task)
{
u16 *tilemap, *tileset;
@ -3910,26 +3910,26 @@ static bool8 Phase2_30_Func1(struct Task *task)
REG_BLDALPHA = sTransitionStructPtr->BLDALPHA;
GetBg0TilesDst(&tilemap, &tileset);
CpuFill16(0, tilemap, 0x800);
LZ77UnCompVram(gUnknown_085C7C00, tileset);
LoadPalette(gUnknown_085C7BE0, 0xF0, 0x20);
LZ77UnCompVram(sFrontierLogo_Tileset, tileset);
LoadPalette(sFrontierLogo_Palette, 0xF0, 0x20);
sTransitionStructPtr->field_16 = 0;
task->tState++;
return FALSE;
}
static bool8 Phase2_30_Func2(struct Task *task)
static bool8 Phase2_FrontierLogoWave_Func2(struct Task *task)
{
u16 *tilemap, *tileset;
GetBg0TilesDst(&tilemap, &tileset);
LZ77UnCompVram(gUnknown_085C828C, tilemap);
LZ77UnCompVram(sFrontierLogo_Tilemap, tilemap);
task->tState++;
return TRUE;
}
static bool8 Phase2_30_Func3(struct Task *task)
static bool8 Phase2_FrontierLogoWave_Func3(struct Task *task)
{
u8 i;
@ -3946,7 +3946,7 @@ static bool8 Phase2_30_Func3(struct Task *task)
return TRUE;
}
static bool8 Phase2_30_Func4(struct Task *task)
static bool8 Phase2_FrontierLogoWave_Func4(struct Task *task)
{
u8 i;
u16 var6, amplitude, var8;
@ -3991,7 +3991,7 @@ static bool8 Phase2_30_Func4(struct Task *task)
}
if (task->tData4 != 0 && !gPaletteFade.active)
DestroyTask(FindTaskIdByFunc(Phase2Task_30));
DestroyTask(FindTaskIdByFunc(Phase2Task_FrontierLogoWave));
task->tData7 -= 17;
sTransitionStructPtr->VBlank_DMA++;
@ -4014,33 +4014,33 @@ static void HBlankCB_Phase2_30(void)
REG_BG0VOFS = var;
}
static void Phase2Task_31(u8 taskId)
static void Phase2Task_FrontierSquares(u8 taskId)
{
while (sPhase2_31_Funcs[gTasks[taskId].tState](&gTasks[taskId]));
while (sPhase2_FrontierSquares_Funcs[gTasks[taskId].tState](&gTasks[taskId]));
}
static void Phase2Task_33(u8 taskId)
static void Phase2Task_FrontierSquaresSpiral(u8 taskId)
{
while (sPhase2_33_Funcs[gTasks[taskId].tState](&gTasks[taskId]));
while (sPhase2_FrontierSquaresSpiral_Funcs[gTasks[taskId].tState](&gTasks[taskId]));
}
static void Phase2Task_32(u8 taskId)
static void Phase2Task_FrontierSquaresScroll(u8 taskId)
{
while (sPhase2_32_Funcs[gTasks[taskId].tState](&gTasks[taskId]));
while (sPhase2_FrontierSquaresScroll_Funcs[gTasks[taskId].tState](&gTasks[taskId]));
}
static bool8 Phase2_31_Func1(struct Task *task)
static bool8 Phase2_FrontierSquares_Func1(struct Task *task)
{
u16 *tilemap, *tileset;
GetBg0TilesDst(&tilemap, &tileset);
LZ77UnCompVram(gUnknown_085C8598, tileset);
LZ77UnCompVram(sFrontierSquares_FilledBg_Tileset, tileset);
FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 0x20, 0x20);
FillBgTilemapBufferRect(0, 1, 0, 0, 1, 0x20, 0xF);
FillBgTilemapBufferRect(0, 1, 0x1D, 0, 1, 0x20, 0xF);
CopyBgTilemapBufferToVram(0);
LoadPalette(gUnknown_085C8578, 0xF0, 0x20);
LoadPalette(sFrontierSquares_Palette, 0xF0, 0x20);
task->tData2 = 1;
task->tData3 = 0;
@ -4051,9 +4051,9 @@ static bool8 Phase2_31_Func1(struct Task *task)
return FALSE;
}
static bool8 Phase2_31_Func2(struct Task *task)
static bool8 Phase2_FrontierSquares_Func2(struct Task *task)
{
CopyRectToBgTilemapBufferRect(0, gUnknown_085C8928, 0, 0, 4, 4, task->tData2, task->tData3, 4, 4, 0xF, 0, 0);
CopyRectToBgTilemapBufferRect(0, sFrontierSquares_Tilemap, 0, 0, 4, 4, task->tData2, task->tData3, 4, 4, 0xF, 0, 0);
CopyBgTilemapBufferToVram(0);
task->tData2 += 4;
@ -4069,7 +4069,7 @@ static bool8 Phase2_31_Func2(struct Task *task)
return FALSE;
}
static bool8 Phase2_31_Func3(struct Task *task)
static bool8 Phase2_FrontierSquares_Func3(struct Task *task)
{
u8 i;
u16 *tilemap, *tileset;
@ -4088,13 +4088,13 @@ static bool8 Phase2_31_Func3(struct Task *task)
break;
case 1:
BlendPalettes(0xFFFF7FFF, 0x10, 0);
LZ77UnCompVram(gUnknown_085C86F4, tileset);
LZ77UnCompVram(sFrontierSquares_EmptyBg_Tileset, tileset);
break;
case 2:
LZ77UnCompVram(gUnknown_085C87F4, tileset);
LZ77UnCompVram(sFrontierSquares_Shrink1_Tileset, tileset);
break;
case 3:
LZ77UnCompVram(gUnknown_085C88A4, tileset);
LZ77UnCompVram(sFrontierSquares_Shrink2_Tileset, tileset);
break;
default:
FillBgTilemapBufferRect_Palette0(0, 1, 0, 0, 0x20, 0x20);
@ -4110,19 +4110,19 @@ static bool8 Phase2_31_Func3(struct Task *task)
return FALSE;
}
static bool8 Phase2_33_Func1(struct Task *task)
static bool8 Phase2_FrontierSquaresSpiral_Func1(struct Task *task)
{
u16 *tilemap, *tileset;
GetBg0TilesDst(&tilemap, &tileset);
LZ77UnCompVram(gUnknown_085C8598, tileset);
LZ77UnCompVram(sFrontierSquares_FilledBg_Tileset, tileset);
FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 0x20, 0x20);
FillBgTilemapBufferRect(0, 1, 0, 0, 1, 0x20, 0xF);
FillBgTilemapBufferRect(0, 1, 0x1D, 0, 1, 0x20, 0xF);
CopyBgTilemapBufferToVram(0);
LoadPalette(gUnknown_085C8578, 0xE0, 0x20);
LoadPalette(gUnknown_085C8578, 0xF0, 0x20);
LoadPalette(sFrontierSquares_Palette, 0xE0, 0x20);
LoadPalette(sFrontierSquares_Palette, 0xF0, 0x20);
BlendPalette(0xE0, 0x10, 8, 0);
task->tData2 = 34;
@ -4132,12 +4132,12 @@ static bool8 Phase2_33_Func1(struct Task *task)
return FALSE;
}
static bool8 Phase2_33_Func2(struct Task *task)
static bool8 Phase2_FrontierSquaresSpiral_Func2(struct Task *task)
{
u8 var = gUnknown_085C9A30[task->tData2];
u8 varMod = var % 7;
u8 varDiv = var / 7;
CopyRectToBgTilemapBufferRect(0, &gUnknown_085C8928, 0, 0, 4, 4, 4 * varMod + 1, 4 * varDiv, 4, 4, 0xF, 0, 0);
CopyRectToBgTilemapBufferRect(0, &sFrontierSquares_Tilemap, 0, 0, 4, 4, 4 * varMod + 1, 4 * varDiv, 4, 4, 0xF, 0, 0);
CopyBgTilemapBufferToVram(0);
if (--task->tData2 < 0)
@ -4145,7 +4145,7 @@ static bool8 Phase2_33_Func2(struct Task *task)
return FALSE;
}
static bool8 Phase2_33_Func3(struct Task *task)
static bool8 Phase2_FrontierSquaresSpiral_Func3(struct Task *task)
{
BlendPalette(0xE0, 0x10, 3, 0);
BlendPalettes(0xFFFF3FFF, 0x10, 0);
@ -4157,13 +4157,13 @@ static bool8 Phase2_33_Func3(struct Task *task)
return FALSE;
}
static bool8 Phase2_33_Func4(struct Task *task)
static bool8 Phase2_FrontierSquaresSpiral_Func4(struct Task *task)
{
if ((task->tData3 ^= 1))
{
CopyRectToBgTilemapBufferRect(
0,
gUnknown_085C8928,
sFrontierSquares_Tilemap,
0,
0,
4,
@ -4200,7 +4200,7 @@ static bool8 Phase2_33_Func4(struct Task *task)
return FALSE;
}
static bool8 Phase2_31_33_Func5(struct Task *task)
static bool8 Phase2_FrontierSquares_End(struct Task *task)
{
FillBgTilemapBufferRect_Palette0(0, 1, 0, 0, 0x20, 0x20);
CopyBgTilemapBufferToVram(0);
@ -4225,16 +4225,16 @@ static void sub_814ABE4(u8 taskId)
}
}
static bool8 Phase2_32_Func1(struct Task *task)
static bool8 Phase2_FrontierSquaresScroll_Func1(struct Task *task)
{
u8 taskId = 0;
u16 *tilemap, *tileset;
GetBg0TilesDst(&tilemap, &tileset);
LZ77UnCompVram(gUnknown_085C8598, tileset);
LZ77UnCompVram(sFrontierSquares_FilledBg_Tileset, tileset);
FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 0x20, 0x20);
CopyBgTilemapBufferToVram(0);
LoadPalette(gUnknown_085C8578, 0xF0, 0x20);
LoadPalette(sFrontierSquares_Palette, 0xF0, 0x20);
gBattle_BG0_X = 0;
gBattle_BG0_Y = 0;
@ -4267,7 +4267,7 @@ static bool8 Phase2_32_Func1(struct Task *task)
return FALSE;
}
static bool8 Phase2_32_Func2(struct Task *task)
static bool8 Phase2_FrontierSquaresScroll_Func2(struct Task *task)
{
u8 var = gUnknown_085C9A53[task->tData2];
u8 varDiv = var / 8;
@ -4275,7 +4275,7 @@ static bool8 Phase2_32_Func2(struct Task *task)
CopyRectToBgTilemapBufferRect(
0,
&gUnknown_085C8928,
&sFrontierSquares_Tilemap,
0,
0,
4,
@ -4294,7 +4294,7 @@ static bool8 Phase2_32_Func2(struct Task *task)
return 0;
}
static bool8 Phase2_32_Func3(struct Task *task)
static bool8 Phase2_FrontierSquaresScroll_Func3(struct Task *task)
{
BlendPalettes(0xFFFF7FFF, 0x10, 0);
@ -4304,7 +4304,7 @@ static bool8 Phase2_32_Func3(struct Task *task)
return FALSE;
}
static bool8 Phase2_32_Func4(struct Task *task)
static bool8 Phase2_FrontierSquaresScroll_Func4(struct Task *task)
{
u8 var = gUnknown_085C9A53[task->tData2];
u8 varDiv = var / 8;
@ -4326,7 +4326,7 @@ static bool8 Phase2_32_Func4(struct Task *task)
#undef tSub32_Y_delta
#undef tSub32_Bool
static bool8 Phase2_32_Func5(struct Task *task)
static bool8 Phase2_FrontierSquaresScroll_Func5(struct Task *task)
{
gBattle_BG0_X = 0;
gBattle_BG0_Y = 0;

View File

@ -0,0 +1,650 @@
#include "global.h"
#include "sprite.h"
#include "decompress.h"
#include "battle_transition_frontier.h"
#include "battle_transition.h"
#include "task.h"
#include "palette.h"
#include "trig.h"
#include "bg.h"
#include "gpu_regs.h"
#include "constants/rgb.h"
/*
There are 3 "categories" of Battle Frontier transition
1. The full logo is used (B_TRANSITION_FRONTIER_LOGO_*)
2. Small squares with the logo on it are used (B_TRANSITION_FRONTIER_SQUARES_*)
3. The balls that make up the logo come together to form the full logo (B_TRANSITION_FRONTIER_CIRCLES_*)
This file handles category 3. Functions for the other two are handled in battle_transition.c
*/
typedef bool8 (*TransitionStateFunc)(struct Task *task);
// this file's functions
static void SpriteCB_LogoCircleSlide(struct Sprite *sprite);
static void SpriteCB_LogoCircleSpiral(struct Sprite *sprite);
static bool8 WaitForLogoCirclesAnim(struct Task *task);
static bool8 FadeInCenterLogoCircle(struct Task *task);
static bool8 Circles_Init(struct Task *task);
static bool8 CirclesMeet_CreateSprites(struct Task *task);
static bool8 CirclesMeet_End(struct Task *task);
static bool8 CirclesCross_CreateSprites(struct Task *task);
static bool8 CirclesCross_End(struct Task *task);
static bool8 CirclesAsymmetricSpiral_CreateSprites(struct Task *task);
static bool8 CirclesAsymmetricSpiral_End(struct Task *task);
static bool8 CirclesSymmetricSpiral_CreateSprites(struct Task *task);
static bool8 CirclesSymmetricSpiral_End(struct Task *task);
static bool8 CirclesMeetInSeq_CreateSprites(struct Task *task);
static bool8 CirclesMeetInSeq_End(struct Task *task);
static bool8 CirclesCrossInSeq_CreateSprites(struct Task *task);
static bool8 CirclesCrossInSeq_End(struct Task *task);
static bool8 CirclesAsymmetricSpiralInSeq_CreateSprites(struct Task *task);
static bool8 CirclesAsymmetricSpiralInSeq_End(struct Task *task);
static bool8 CirclesSymmetricSpiralInSeq_CreateSprites(struct Task *task);
static bool8 CirclesSymmetricSpiralInSeq_End(struct Task *task);
#define PALTAG_LOGO_CIRCLES 0x2E90
// const rom data
static const u32 sLogoCenter_Gfx[] = INCBIN_U32("graphics/battle_transitions/frontier_logo_center.4bpp.lz");
static const u32 sLogoCenter_Tilemap[] = INCBIN_U32("graphics/battle_transitions/frontier_logo_center.bin");
static const u32 sLogoCircles_Gfx[] = INCBIN_U32("graphics/battle_transitions/frontier_logo_circles.4bpp.lz");
static const u16 sLogo_Pal[] = INCBIN_U16("graphics/battle_transitions/frontier_logo_circles.gbapal");
// Unused Empty data.
static const u8 sFiller[0x1C0] = {0};
static const struct OamData sOamData_LogoCircles =
{
.y = 0,
.affineMode = ST_OAM_AFFINE_OFF,
.objMode = ST_OAM_OBJ_NORMAL,
.mosaic = 0,
.bpp = ST_OAM_4BPP,
.shape = SPRITE_SHAPE(64x64),
.x = 0,
.matrixNum = 0,
.size = SPRITE_SIZE(64x64),
.tileNum = 0,
.priority = 1,
.paletteNum = 0,
.affineParam = 0
};
static const struct CompressedSpriteSheet sSpriteSheet_LogoCircles =
{
.data = sLogoCircles_Gfx,
.size = 0x1800,
.tag = PALTAG_LOGO_CIRCLES
};
static const struct SpritePalette sSpritePalette_LogoCircles =
{
.data = sLogo_Pal,
.tag = PALTAG_LOGO_CIRCLES
};
static const union AnimCmd sAnim_LogoCircle_Top[] =
{
ANIMCMD_FRAME(0, 1),
ANIMCMD_END
};
static const union AnimCmd sAnim_LogoCircle_Left[] =
{
ANIMCMD_FRAME(64, 1),
ANIMCMD_END
};
static const union AnimCmd sAnim_LogoCircle_Right[] =
{
ANIMCMD_FRAME(128, 1),
ANIMCMD_END
};
static const union AnimCmd *const sAnimTable_LogoCircles[] =
{
sAnim_LogoCircle_Top,
sAnim_LogoCircle_Left,
sAnim_LogoCircle_Right
};
static const struct SpriteTemplate sSpriteTemplate_LogoCircles =
{
.tileTag = PALTAG_LOGO_CIRCLES,
.paletteTag = PALTAG_LOGO_CIRCLES,
.oam = &sOamData_LogoCircles,
.anims = sAnimTable_LogoCircles,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
.callback = SpriteCallbackDummy,
};
static const TransitionStateFunc sPhase2_FrontierCirclesMeet_Funcs[] =
{
Circles_Init,
CirclesMeet_CreateSprites,
WaitForLogoCirclesAnim,
FadeInCenterLogoCircle,
CirclesMeet_End
};
static const TransitionStateFunc sPhase2_FrontierCirclesCross_Funcs[] =
{
Circles_Init,
CirclesCross_CreateSprites,
WaitForLogoCirclesAnim,
FadeInCenterLogoCircle,
CirclesCross_End
};
static const TransitionStateFunc sPhase2_FrontierCirclesAsymmetricSpiral_Funcs[] =
{
Circles_Init,
CirclesAsymmetricSpiral_CreateSprites,
WaitForLogoCirclesAnim,
FadeInCenterLogoCircle,
CirclesAsymmetricSpiral_End
};
static const TransitionStateFunc sPhase2_FrontierCirclesSymmetricSpiral_Funcs[] =
{
Circles_Init,
CirclesSymmetricSpiral_CreateSprites,
WaitForLogoCirclesAnim,
FadeInCenterLogoCircle,
CirclesSymmetricSpiral_End
};
static const TransitionStateFunc sPhase2_FrontierCirclesMeetInSeq_Funcs[] =
{
Circles_Init,
CirclesMeetInSeq_CreateSprites,
WaitForLogoCirclesAnim,
FadeInCenterLogoCircle,
CirclesMeetInSeq_End
};
static const TransitionStateFunc sPhase2_FrontierCirclesCrossInSeq_Funcs[] =
{
Circles_Init,
CirclesCrossInSeq_CreateSprites,
WaitForLogoCirclesAnim,
FadeInCenterLogoCircle,
CirclesCrossInSeq_End
};
static const TransitionStateFunc sPhase2_FrontierCirclesAsymmetricSpiralInSeq_Funcs[] =
{
Circles_Init,
CirclesAsymmetricSpiralInSeq_CreateSprites,
WaitForLogoCirclesAnim,
FadeInCenterLogoCircle,
CirclesAsymmetricSpiralInSeq_End
};
static const TransitionStateFunc sPhase2_FrontierCirclesSymmetricSpiralInSeq_Funcs[] =
{
Circles_Init,
CirclesSymmetricSpiralInSeq_CreateSprites,
WaitForLogoCirclesAnim,
FadeInCenterLogoCircle,
CirclesSymmetricSpiralInSeq_End
};
// code
static void LoadLogoGfx(void)
{
u16 *dst1, *dst2;
GetBg0TilesDst(&dst1, &dst2);
LZ77UnCompVram(sLogoCenter_Gfx, dst2);
LZ77UnCompVram(sLogoCenter_Tilemap, dst1);
LoadPalette(sLogo_Pal, 0xF0, 0x20);
LoadCompressedSpriteSheet(&sSpriteSheet_LogoCircles);
LoadSpritePalette(&sSpritePalette_LogoCircles);
}
static u8 CreateSlidingLogoCircleSprite(s16 x, s16 y, u8 arg2, u8 arg3, s8 arg4, s8 arg5, u8 spriteAnimNum)
{
u8 spriteId = CreateSprite(&sSpriteTemplate_LogoCircles, x, y, 0);
switch (spriteAnimNum)
{
case 0:
gSprites[spriteId].data[0] = 120;
gSprites[spriteId].data[1] = 45;
break;
case 1:
gSprites[spriteId].data[0] = 89;
gSprites[spriteId].data[1] = 97;
break;
case 2:
gSprites[spriteId].data[0] = 151;
gSprites[spriteId].data[1] = 97;
break;
}
gSprites[spriteId].data[2] = arg4;
gSprites[spriteId].data[3] = arg5;
gSprites[spriteId].data[6] = arg2;
gSprites[spriteId].data[7] = arg3;
gSprites[spriteId].data[4] = 0;
gSprites[spriteId].data[5] = 0;
StartSpriteAnim(&gSprites[spriteId], spriteAnimNum);
gSprites[spriteId].callback = SpriteCB_LogoCircleSlide;
return spriteId;
}
static void SpriteCB_LogoCircleSlide(struct Sprite *sprite)
{
s16 *data = sprite->data;
if (sprite->pos1.x == data[0] && sprite->pos1.y == data[1])
{
sprite->callback = SpriteCallbackDummy;
}
else
{
if (data[4] == data[6])
{
sprite->pos1.x += data[2];
data[4] = 0;
}
else
{
data[4]++;
}
if (data[5] == data[7])
{
sprite->pos1.y += data[3];
data[5] = 0;
}
else
{
data[5]++;
}
}
}
static u8 CreateSpiralingLogoCircleSprite(s16 x, s16 y, s16 arg2, s16 arg3, s16 arg4, s16 arg5, s16 arg6, u8 spriteAnimNum)
{
u8 spriteId = CreateSprite(&sSpriteTemplate_LogoCircles, x, y, 0);
switch (spriteAnimNum)
{
case 0:
gSprites[spriteId].data[0] = 120;
gSprites[spriteId].data[1] = 45;
break;
case 1:
gSprites[spriteId].data[0] = 89;
gSprites[spriteId].data[1] = 97;
break;
case 2:
gSprites[spriteId].data[0] = 151;
gSprites[spriteId].data[1] = 97;
break;
}
gSprites[spriteId].data[2] = arg2;
gSprites[spriteId].data[3] = arg3;
gSprites[spriteId].data[4] = arg4;
gSprites[spriteId].data[5] = arg5;
gSprites[spriteId].data[6] = arg6;
StartSpriteAnim(&gSprites[spriteId], spriteAnimNum);
gSprites[spriteId].callback = SpriteCB_LogoCircleSpiral;
return spriteId;
}
static void SpriteCB_LogoCircleSpiral(struct Sprite *sprite)
{
sprite->pos2.x = (Sin2(sprite->data[2]) * sprite->data[4]) >> 12; // div by 4096
sprite->pos2.y = (Cos2(sprite->data[2]) * sprite->data[4]) >> 12; // div by 4096
sprite->data[2] = (sprite->data[2] + sprite->data[3]) % 360;
if (sprite->data[4] != sprite->data[5])
sprite->data[4] += sprite->data[6];
else
sprite->callback = SpriteCallbackDummy;
}
#define tState data[0]
static void DestroyLogoCirclesGfx(struct Task *task)
{
FreeSpriteTilesByTag(PALTAG_LOGO_CIRCLES);
FreeSpritePaletteByTag(PALTAG_LOGO_CIRCLES);
DestroySprite(&gSprites[task->data[4]]);
DestroySprite(&gSprites[task->data[5]]);
DestroySprite(&gSprites[task->data[6]]);
}
static bool8 IsLogoCirclesAnimFinished(struct Task *task)
{
if (gSprites[task->data[4]].callback == SpriteCallbackDummy
&& gSprites[task->data[5]].callback == SpriteCallbackDummy
&& gSprites[task->data[6]].callback == SpriteCallbackDummy)
return TRUE;
else
return FALSE;
}
static bool8 Circles_Init(struct Task *task)
{
if (task->data[1] == 0)
{
ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON);
ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN1_ON);
ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_BG0_ON);
task->data[1]++;
return FALSE;
}
else
{
LoadLogoGfx();
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG0 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_ALL);
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(0, 16));
ChangeBgX(0, 0, 0);
ChangeBgY(0, 0, 0);
ChangeBgY(0, 0x500, 2);
task->data[1] = 0;
task->tState++;
return TRUE;
}
}
static bool8 FadeInCenterLogoCircle(struct Task *task)
{
if (task->data[2] == 0)
SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_BG0_ON);
if (task->data[2] == 16)
{
if (task->data[3] == 31)
{
BeginNormalPaletteFade(0xFFFFFFFF, -1, 0, 0x10, RGB_BLACK);
task->tState++;
}
else
{
task->data[3]++;
}
}
else
{
u16 blnd;
task->data[2]++;
blnd = task->data[2];
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(blnd, 16 - blnd));
}
return FALSE;
}
static bool8 WaitForLogoCirclesAnim(struct Task *task)
{
if (IsLogoCirclesAnimFinished(task) == TRUE)
task->tState++;
return FALSE;
}
void Phase2Task_FrontierCirclesMeet(u8 taskId)
{
while (sPhase2_FrontierCirclesMeet_Funcs[gTasks[taskId].tState](&gTasks[taskId]));
}
static bool8 CirclesMeet_CreateSprites(struct Task *task)
{
task->data[4] = CreateSlidingLogoCircleSprite(120, -51, 0, 0, 0, 2, 0);
task->data[5] = CreateSlidingLogoCircleSprite(-7, 193, 0, 0, 2, -2, 1);
task->data[6] = CreateSlidingLogoCircleSprite(247, 193, 0, 0, -2, -2, 2);
task->tState++;
return FALSE;
}
static bool8 CirclesMeet_End(struct Task *task)
{
if (!gPaletteFade.active)
{
DestroyLogoCirclesGfx(task);
DestroyTask(FindTaskIdByFunc(Phase2Task_FrontierCirclesMeet));
}
return FALSE;
}
void Phase2Task_FrontierCirclesCross(u8 taskId)
{
while (sPhase2_FrontierCirclesCross_Funcs[gTasks[taskId].tState](&gTasks[taskId]));
}
static bool8 CirclesCross_CreateSprites(struct Task *task)
{
task->data[4] = CreateSlidingLogoCircleSprite(120, 197, 0, 0, 0, -4, 0);
task->data[5] = CreateSlidingLogoCircleSprite(241, 59, 0, 1, -4, 2, 1);
task->data[6] = CreateSlidingLogoCircleSprite(-1, 59, 0, 1, 4, 2, 2);
task->tState++;
return FALSE;
}
static bool8 CirclesCross_End(struct Task *task)
{
if (!gPaletteFade.active)
{
DestroyLogoCirclesGfx(task);
DestroyTask(FindTaskIdByFunc(Phase2Task_FrontierCirclesCross));
}
return FALSE;
}
void Phase2Task_FrontierCirclesAsymmetricSpiral(u8 taskId)
{
while (sPhase2_FrontierCirclesAsymmetricSpiral_Funcs[gTasks[taskId].tState](&gTasks[taskId]));
}
static bool8 CirclesAsymmetricSpiral_CreateSprites(struct Task *task)
{
task->data[4] = CreateSpiralingLogoCircleSprite(120, 45, 12, 4, 128, 0, -4, 0);
task->data[5] = CreateSpiralingLogoCircleSprite(89, 97, 252, 4, 128, 0, -4, 1);
task->data[6] = CreateSpiralingLogoCircleSprite(151, 97, 132, 4, 128, 0, -4, 2);
task->tState++;
return FALSE;
}
static bool8 CirclesAsymmetricSpiral_End(struct Task *task)
{
if (!gPaletteFade.active)
{
DestroyLogoCirclesGfx(task);
DestroyTask(FindTaskIdByFunc(Phase2Task_FrontierCirclesAsymmetricSpiral));
}
return FALSE;
}
void Phase2Task_FrontierCirclesSymmetricSpiral(u8 taskId)
{
while (sPhase2_FrontierCirclesSymmetricSpiral_Funcs[gTasks[taskId].tState](&gTasks[taskId]));
}
static bool8 CirclesSymmetricSpiral_CreateSprites(struct Task *task)
{
task->data[4] = CreateSpiralingLogoCircleSprite(120, 80, 284, 8, 131, 35, -3, 0);
task->data[5] = CreateSpiralingLogoCircleSprite(120, 80, 44, 8, 131, 35, -3, 1);
task->data[6] = CreateSpiralingLogoCircleSprite(121, 80, 164, 8, 131, 35, -3, 2);
task->tState++;
return FALSE;
}
static bool8 CirclesSymmetricSpiral_End(struct Task *task)
{
if (!gPaletteFade.active)
{
DestroyLogoCirclesGfx(task);
DestroyTask(FindTaskIdByFunc(Phase2Task_FrontierCirclesSymmetricSpiral));
}
return FALSE;
}
void Phase2Task_FrontierCirclesMeetInSeq(u8 taskId)
{
while (sPhase2_FrontierCirclesMeetInSeq_Funcs[gTasks[taskId].tState](&gTasks[taskId]));
}
static bool8 CirclesMeetInSeq_CreateSprites(struct Task *task)
{
if (task->data[1] == 0)
{
task->data[4] = CreateSlidingLogoCircleSprite(120, -51, 0, 0, 0, 4, 0);
}
else if (task->data[1] == 16)
{
task->data[5] = CreateSlidingLogoCircleSprite(-7, 193, 0, 0, 4, -4, 1);
}
else if (task->data[1] == 32)
{
task->data[6] = CreateSlidingLogoCircleSprite(247, 193, 0, 0, -4, -4, 2);
task->tState++;
}
task->data[1]++;
return FALSE;
}
static bool8 CirclesMeetInSeq_End(struct Task *task)
{
if (!gPaletteFade.active)
{
DestroyLogoCirclesGfx(task);
DestroyTask(FindTaskIdByFunc(Phase2Task_FrontierCirclesMeetInSeq));
}
return FALSE;
}
void Phase2Task_FrontierCirclesCrossInSeq(u8 taskId)
{
while (sPhase2_FrontierCirclesCrossInSeq_Funcs[gTasks[taskId].tState](&gTasks[taskId]));
}
static bool8 CirclesCrossInSeq_CreateSprites(struct Task *task)
{
if (task->data[1] == 0)
{
task->data[4] = CreateSlidingLogoCircleSprite(120, 197, 0, 0, 0, -8, 0);
}
else if (task->data[1] == 16)
{
task->data[5] = CreateSlidingLogoCircleSprite(241, 78, 0, 0, -8, 1, 1);
}
else if (task->data[1] == 32)
{
task->data[6] = CreateSlidingLogoCircleSprite(-1, 78, 0, 0, 8, 1, 2);
task->tState++;
}
task->data[1]++;
return FALSE;
}
static bool8 CirclesCrossInSeq_End(struct Task *task)
{
if (!gPaletteFade.active)
{
DestroyLogoCirclesGfx(task);
DestroyTask(FindTaskIdByFunc(Phase2Task_FrontierCirclesCrossInSeq));
}
return FALSE;
}
void Phase2Task_FrontierCirclesAsymmetricSpiralInSeq(u8 taskId)
{
while (sPhase2_FrontierCirclesAsymmetricSpiralInSeq_Funcs[gTasks[taskId].tState](&gTasks[taskId]));
}
static bool8 CirclesAsymmetricSpiralInSeq_CreateSprites(struct Task *task)
{
if (task->data[1] == 0)
{
task->data[4] = CreateSpiralingLogoCircleSprite(120, 45, 12, 4, 128, 0, -4, 0);
}
else if (task->data[1] == 16)
{
task->data[5] = CreateSpiralingLogoCircleSprite(89, 97, 252, 4, 128, 0, -4, 1);
}
else if (task->data[1] == 32)
{
task->data[6] = CreateSpiralingLogoCircleSprite(151, 97, 132, 4, 128, 0, -4, 2);
task->tState++;
}
task->data[1]++;
return FALSE;
}
static bool8 CirclesAsymmetricSpiralInSeq_End(struct Task *task)
{
if (!gPaletteFade.active)
{
DestroyLogoCirclesGfx(task);
DestroyTask(FindTaskIdByFunc(Phase2Task_FrontierCirclesAsymmetricSpiralInSeq));
}
return FALSE;
}
void Phase2Task_FrontierCirclesSymmetricSpiralInSeq(u8 taskId)
{
while (sPhase2_FrontierCirclesSymmetricSpiralInSeq_Funcs[gTasks[taskId].tState](&gTasks[taskId]));
}
static bool8 CirclesSymmetricSpiralInSeq_CreateSprites(struct Task *task)
{
if (task->data[1] == 0)
{
task->data[4] = CreateSpiralingLogoCircleSprite(120, 80, 284, 8, 131, 35, -3, 0);
}
else if (task->data[1] == 16)
{
task->data[5] = CreateSpiralingLogoCircleSprite(120, 80, 44, 8, 131, 35, -3, 1);
}
else if (task->data[1] == 32)
{
task->data[6] = CreateSpiralingLogoCircleSprite(121, 80, 164, 8, 131, 35, -3, 2);
task->tState++;
}
task->data[1]++;
return FALSE;
}
static bool8 CirclesSymmetricSpiralInSeq_End(struct Task *task)
{
if (!gPaletteFade.active)
{
DestroyLogoCirclesGfx(task);
DestroyTask(FindTaskIdByFunc(Phase2Task_FrontierCirclesSymmetricSpiralInSeq));
}
return FALSE;
}

View File

@ -864,9 +864,9 @@ u8 DoBattlerEndTurnEffects(void)
gBattleMoveDamage = gBattleMons[gActiveBattler].maxHP / 16;
if (gBattleMoveDamage == 0)
gBattleMoveDamage = 1;
if ((gBattleMons[gActiveBattler].status1 & 0xF00) != 0xF00) // not 16 turns
gBattleMons[gActiveBattler].status1 += 0x100;
gBattleMoveDamage *= (gBattleMons[gActiveBattler].status1 & 0xF00) >> 8;
if ((gBattleMons[gActiveBattler].status1 & STATUS1_TOXIC_COUNTER) != STATUS1_TOXIC_TURN(15)) // not 16 turns
gBattleMons[gActiveBattler].status1 += STATUS1_TOXIC_TURN(1);
gBattleMoveDamage *= (gBattleMons[gActiveBattler].status1 & STATUS1_TOXIC_COUNTER) >> 8;
BattleScriptExecute(BattleScript_PoisonTurnDmg);
effect++;
}
@ -917,7 +917,7 @@ u8 DoBattlerEndTurnEffects(void)
case ENDTURN_WRAP: // wrap
if ((gBattleMons[gActiveBattler].status2 & STATUS2_WRAPPED) && gBattleMons[gActiveBattler].hp != 0)
{
gBattleMons[gActiveBattler].status2 -= 0x2000;
gBattleMons[gActiveBattler].status2 -= STATUS2_WRAPPED_TURN(1);
if (gBattleMons[gActiveBattler].status2 & STATUS2_WRAPPED) // damaged by wrap
{
// This is the only way I could get this array access to match.
@ -973,7 +973,7 @@ u8 DoBattlerEndTurnEffects(void)
else
{
gBattlerAttacker = gActiveBattler;
gBattleMons[gActiveBattler].status2 -= 0x10; // uproar timer goes down
gBattleMons[gActiveBattler].status2 -= STATUS2_UPROAR_TURN(1);
if (WasUnableToUseMove(gActiveBattler))
{
CancelMultiTurnMoves(gActiveBattler);
@ -999,7 +999,7 @@ u8 DoBattlerEndTurnEffects(void)
case ENDTURN_THRASH: // thrash
if (gBattleMons[gActiveBattler].status2 & STATUS2_LOCK_CONFUSE)
{
gBattleMons[gActiveBattler].status2 -= 0x400;
gBattleMons[gActiveBattler].status2 -= STATUS2_LOCK_CONFUSE_TURN(1);
if (WasUnableToUseMove(gActiveBattler))
CancelMultiTurnMoves(gActiveBattler);
else if (!(gBattleMons[gActiveBattler].status2 & STATUS2_LOCK_CONFUSE)
@ -1062,7 +1062,7 @@ u8 DoBattlerEndTurnEffects(void)
break;
case ENDTURN_LOCK_ON: // lock-on decrement
if (gStatuses3[gActiveBattler] & STATUS3_ALWAYS_HITS)
gStatuses3[gActiveBattler] -= 0x8;
gStatuses3[gActiveBattler] -= STATUS3_ALWAYS_HITS_TURN(1);
gBattleStruct->turnEffectsTracker++;
break;
case ENDTURN_CHARGE: // charge
@ -1078,13 +1078,13 @@ u8 DoBattlerEndTurnEffects(void)
case ENDTURN_YAWN: // yawn
if (gStatuses3[gActiveBattler] & STATUS3_YAWN)
{
gStatuses3[gActiveBattler] -= 0x800;
gStatuses3[gActiveBattler] -= STATUS3_YAWN_TURN(1);
if (!(gStatuses3[gActiveBattler] & STATUS3_YAWN) && !(gBattleMons[gActiveBattler].status1 & STATUS1_ANY)
&& gBattleMons[gActiveBattler].ability != ABILITY_VITAL_SPIRIT
&& gBattleMons[gActiveBattler].ability != ABILITY_INSOMNIA && !UproarWakeUpCheck(gActiveBattler))
{
CancelMultiTurnMoves(gActiveBattler);
gBattleMons[gActiveBattler].status1 |= (Random() & 3) + 2;
gBattleMons[gActiveBattler].status1 |= STATUS1_SLEEP_TURN((Random() & 3) + 2); // 2-5 turns of sleep
BtlController_EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBattler].status1);
MarkBattlerForControllerExec(gActiveBattler);
gEffectBattler = gActiveBattler;
@ -1478,7 +1478,7 @@ u8 AtkCanceller_UnableToUseMove(void)
case CANCELLER_CONFUSED: // confusion
if (gBattleMons[gBattlerAttacker].status2 & STATUS2_CONFUSION)
{
gBattleMons[gBattlerAttacker].status2--;
gBattleMons[gBattlerAttacker].status2 -= STATUS2_CONFUSION_TURN(1);
if (gBattleMons[gBattlerAttacker].status2 & STATUS2_CONFUSION)
{
if (Random() & 1)
@ -1540,7 +1540,7 @@ u8 AtkCanceller_UnableToUseMove(void)
case CANCELLER_BIDE: // bide
if (gBattleMons[gBattlerAttacker].status2 & STATUS2_BIDE)
{
gBattleMons[gBattlerAttacker].status2 -= 0x100;
gBattleMons[gBattlerAttacker].status2 -= STATUS2_BIDE_TURN(1);
if (gBattleMons[gBattlerAttacker].status2 & STATUS2_BIDE)
{
gBattlescriptCurrInstr = BattleScript_BideStoringEnergy;

View File

@ -24,7 +24,7 @@ static const u8 sSassyNatureName[] = _("SASSY");
static const u8 sCarefulNatureName[] = _("CAREFUL");
static const u8 sQuirkyNatureName[] = _("QUIRKY");
const u8 *const gNatureNamePointers[] =
const u8 *const gNatureNamePointers[NUM_NATURES] =
{
[NATURE_HARDY] = sHardyNatureName,
[NATURE_LONELY] = sLonelyNatureName,

View File

@ -2854,7 +2854,7 @@ void SetBattleTowerLinkPlayerGfx(void)
void ShowNatureGirlMessage(void)
{
static const u8 *const sNatureGirlMessages[] = {
static const u8 *const sNatureGirlMessages[NUM_NATURES] = {
[NATURE_HARDY] = BattleFrontier_Lounge5_Text_NatureGirlHardy,
[NATURE_LONELY] = BattleFrontier_Lounge5_Text_NatureGirlLonely,
[NATURE_BRAVE] = BattleFrontier_Lounge5_Text_NatureGirlBrave,

View File

@ -77,11 +77,9 @@ static void DrawTextOption(void);
static void DrawOptionMenuTexts(void);
static void sub_80BB154(void);
// EWRAM vars
EWRAM_DATA static bool8 sArrowPressed = FALSE;
// const rom data
static const u16 sUnknown_0855C604[] = INCBIN_U16("graphics/misc/option_menu_text.gbapal");
static const u16 sOptionMenuText_Pal[] = INCBIN_U16("graphics/misc/option_menu_text.gbapal");
// note: this is only used in the Japanese release
static const u8 sEqualSignGfx[] = INCBIN_U8("graphics/misc/option_menu_equals_sign.4bpp");
@ -141,7 +139,7 @@ static const struct BgTemplate sOptionMenuBgTemplates[] =
}
};
static const u16 sUnknown_0855C6A0[] = {0x7E51};
static const u16 sOptionMenuBg_Pal[] = {RGB(17, 18, 31)};
// code
static void MainCB2(void)
@ -209,12 +207,12 @@ void CB2_InitOptionMenu(void)
gMain.state++;
break;
case 4:
LoadPalette(sUnknown_0855C6A0, 0, sizeof(sUnknown_0855C6A0));
LoadPalette(sOptionMenuBg_Pal, 0, sizeof(sOptionMenuBg_Pal));
LoadPalette(GetWindowFrameTilesPal(gSaveBlock2Ptr->optionsWindowFrameType)->pal, 0x70, 0x20);
gMain.state++;
break;
case 5:
LoadPalette(sUnknown_0855C604, 0x10, sizeof(sUnknown_0855C604));
LoadPalette(sOptionMenuText_Pal, 16, sizeof(sOptionMenuText_Pal));
gMain.state++;
break;
case 6:

View File

@ -117,7 +117,7 @@ EWRAM_DATA static struct PokeblockSavedData sSavedPokeblockData = {0};
EWRAM_DATA static struct PokeblockMenuStruct *sPokeblockMenu = NULL;
// const rom data
const s8 gPokeblockFlavorCompatibilityTable[] =
const s8 gPokeblockFlavorCompatibilityTable[NUM_NATURES * FLAVOR_COUNT] =
{
// Cool, Beauty, Cute, Smart, Tough
0, 0, 0, 0, 0, // Hardy
@ -1386,7 +1386,7 @@ s16 PokeblockGetGain(u8 nature, const struct Pokeblock *pokeblock)
{
curGain = GetPokeblockData(pokeblock, flavor + PBLOCK_SPICY);
if (curGain > 0)
totalGain += curGain * gPokeblockFlavorCompatibilityTable[5 * nature + flavor];
totalGain += curGain * gPokeblockFlavorCompatibilityTable[FLAVOR_COUNT * nature + flavor];
}
return totalGain;

View File

@ -84,7 +84,7 @@ EWRAM_DATA static struct PokeblockFeedStruct *sPokeblockFeed = NULL;
EWRAM_DATA static struct CompressedSpritePalette sPokeblockSpritePal = {0};
// const rom data
static const u8 sNatureToMonPokeblockAnim[][2] =
static const u8 sNatureToMonPokeblockAnim[NUM_NATURES][2] =
{
[NATURE_HARDY] = { 0, 0 },
[NATURE_LONELY] = { 3, 0 },

View File

@ -1349,7 +1349,7 @@ const struct SpindaSpot gSpindaSpotGraphics[] =
#include "data/pokemon/item_effects.h"
const s8 gNatureStatTable[][NUM_EV_STATS] =
const s8 gNatureStatTable[NUM_NATURES][NUM_NATURE_STATS] =
{
// Atk Def Spd Sp.Atk Sp.Def
{ 0, 0, 0, 0, 0}, // Hardy
@ -5372,12 +5372,12 @@ u8 *UseStatIncreaseItem(u16 itemId)
u8 GetNature(struct Pokemon *mon)
{
return GetMonData(mon, MON_DATA_PERSONALITY, 0) % 25;
return GetMonData(mon, MON_DATA_PERSONALITY, 0) % NUM_NATURES;
}
u8 GetNatureFromPersonality(u32 personality)
{
return personality % 25;
return personality % NUM_NATURES;
}
u16 GetEvolutionTargetSpecies(struct Pokemon *mon, u8 type, u16 evolutionItem)
@ -5747,7 +5747,7 @@ u8 GetTrainerEncounterMusicId(u16 trainerOpponentId)
u16 ModifyStatByNature(u8 nature, u16 n, u8 statIndex)
{
// Dont modify HP, Accuracy, or Evasion by nature
if (statIndex <= STAT_HP || statIndex > NUM_EV_STATS)
if (statIndex <= STAT_HP || statIndex > NUM_NATURE_STATS)
{
// Should just be "return n", but it wouldn't match without this.
u16 retVal = n;
@ -6404,13 +6404,13 @@ bool8 IsMonSpriteNotFlipped(u16 species)
s8 GetMonFlavorRelation(struct Pokemon *mon, u8 flavor)
{
u8 nature = GetNature(mon);
return gPokeblockFlavorCompatibilityTable[nature * 5 + flavor];
return gPokeblockFlavorCompatibilityTable[nature * FLAVOR_COUNT + flavor];
}
s8 GetFlavorRelationByPersonality(u32 personality, u8 flavor)
{
u8 nature = GetNatureFromPersonality(personality);
return gPokeblockFlavorCompatibilityTable[nature * 5 + flavor];
return gPokeblockFlavorCompatibilityTable[nature * FLAVOR_COUNT + flavor];
}
bool8 IsTradedMon(struct Pokemon *mon)

View File

@ -783,7 +783,7 @@ static const u8 sBackAnimationIds[] =
0x94, 0x95, 0x96, // 0x19
};
static const u8 sBackAnimNatureModTable[] =
static const u8 sBackAnimNatureModTable[NUM_NATURES] =
{
[NATURE_HARDY] = 0x00,
[NATURE_LONELY] = 0x02,

View File

@ -128,7 +128,7 @@ struct PokemonStorageSystemData
u16 field_B0[528 / 2];
u16 field_2C0;
u16 field_2C2;
u8 field_2C4;
u8 field_2C4; // Unused
u8 field_2C5;
u8 showPartyMenuState;
u8 unk_02C7;
@ -136,21 +136,21 @@ struct PokemonStorageSystemData
bool8 unk_02C9;
s16 newCurrBoxId;
u16 bg2_X;
s16 field_2CE;
s16 wallpaperScrollSpeed;
u16 field_2D0;
u8 field_2D2;
u8 field_2D3;
u8 field_2D4;
u16 field_2D6;
s16 field_2D8;
u16 field_2DA;
u16 field_2DC;
u16 field_2DE;
u16 field_2E0;
u8 field_2D3; // Written to, but never read.
u8 field_2D4; // Written to, but never read.
u16 field_2D6; // Written to, but never read.
s16 field_2D8; // Written to, but never read.
u16 field_2DA; // Written to, but never read.
u16 field_2DC; // Written to, but never read.
u16 field_2DE; // Written to, but never read.
u16 field_2E0; // Written to, but never read.
u8 filler[22];
u8 field_2F8[1024];
u8 field_6F8;
u8 field_6F9;
u8 field_6F9; // Written to, but never read.
u8 field_6FA;
s8 field_6FB;
u16 field_6FC[16];
@ -160,14 +160,14 @@ struct PokemonStorageSystemData
struct Sprite *field_728[2];
struct Sprite *field_730[2];
u32 field_738;
u8 field_73C[80];
u16 field_78C;
u8 field_73C[80]; // Unused
u16 field_78C; // Written to, but never read.
s16 wallpaperSetId;
s16 wallpaperId;
u16 field_792[360];
u8 wallpaperChangeState;
u8 field_A63;
u8 field_A64;
u8 boxScrollDestination;
s8 field_A65;
u8 *wallpaperTiles;
struct Sprite *movingMonSprite;
@ -189,12 +189,12 @@ struct PokemonStorageSystemData
u8 field_C68;
s8 field_C69;
u8 field_C6A;
u8 field_C6B;
u8 field_C6B; // Written to, but never read.
struct WindowTemplate menuWindow;
struct StorageMenu menuItems[7];
u8 menuItemsCount;
u8 menuWidth;
u8 field_CAE;
u8 field_CAE; // Written to, but never read.
u16 field_CB0;
struct Sprite *field_CB4;
struct Sprite *field_CB8;
@ -247,7 +247,7 @@ struct PokemonStorageSystemData
u16 field_2176[8];
u8 field_2186;
u8 field_2187;
u8 field_2188;
u8 pokemonSummaryScreenMode;
union
{
struct Pokemon *mon;
@ -262,13 +262,13 @@ struct PokemonStorageSystemData
struct UnkStorageStruct field_2204[3];
u16 movingItem;
u16 field_2236;
u8 field_2238;
u8 field_2238; // Unused
u16 field_223A;
u16 *field_223C;
struct Sprite *cursorMonSprite;
u16 field_2244[0x40];
u8 field_22C4[0x800];
u8 field_2AC4[0x1800];
u8 field_2AC4[0x1800]; // Unused
u8 field_42C4[0x800];
u8 field_4AC4[0x1000];
u8 field_5AC4[0x800];
@ -658,7 +658,7 @@ static void SetBoxSpeciesAndPersonalities(u8 boxId);
static void sub_80CB9D0(struct Sprite *sprite, u16 partyId);
static void sub_80CC370(u8 taskId);
static void sub_80CCB50(u8 boxId);
static s8 sub_80CC644(u8 boxId);
static s8 DetermineBoxScrollDirection(u8 boxId);
static void sub_80CCA3C(const void *tilemap, s8 direction, u8 arg2);
static s16 sub_80CD00C(const u8 *string);
static bool8 MonPlaceChange_Shift(void);
@ -3879,7 +3879,7 @@ static void Cb_ChangeScreen(u8 taskId)
boxMons = sPSSData->field_218C.box;
monIndex = sPSSData->field_2187;
maxMonIndex = sPSSData->field_2186;
mode = sPSSData->field_2188;
mode = sPSSData->pokemonSummaryScreenMode;
FreePSSData();
if (mode == PSS_MODE_NORMAL && boxMons == &gUnknown_02039D14.box)
ShowPokemonSummaryScreenSet40EF(mode, boxMons, monIndex, maxMonIndex, Cb2_ReturnToPSS);
@ -5276,9 +5276,9 @@ static void sub_80CC370(u8 taskId)
static void SetUpScrollToBox(u8 boxId)
{
s8 direction = sub_80CC644(boxId);
s8 direction = DetermineBoxScrollDirection(boxId);
sPSSData->field_2CE = (direction > 0) ? 6 : -6;
sPSSData->wallpaperScrollSpeed = (direction > 0) ? 6 : -6;
sPSSData->field_2D3 = (direction > 0) ? 1 : 2;
sPSSData->field_2D0 = 32;
sPSSData->field_2D4 = boxId;
@ -5288,7 +5288,7 @@ static void SetUpScrollToBox(u8 boxId)
sPSSData->field_2DC = (direction <= 0) ? 5 : 0;
sPSSData->field_2DE = 0;
sPSSData->field_2E0 = 2;
sPSSData->field_A64 = boxId;
sPSSData->boxScrollDestination = boxId;
sPSSData->field_A65 = direction;
sPSSData->field_A63 = 0;
}
@ -5300,21 +5300,21 @@ static bool8 ScrollToBox(void)
switch (sPSSData->field_A63)
{
case 0:
LoadWallpaperGfx(sPSSData->field_A64, sPSSData->field_A65);
LoadWallpaperGfx(sPSSData->boxScrollDestination, sPSSData->field_A65);
sPSSData->field_A63++;
case 1:
if (!WaitForWallpaperGfxLoad())
return TRUE;
sub_80CB4CC(sPSSData->field_A64, sPSSData->field_A65);
sub_80CCCFC(sPSSData->field_A64, sPSSData->field_A65);
sub_80CB4CC(sPSSData->boxScrollDestination, sPSSData->field_A65);
sub_80CCCFC(sPSSData->boxScrollDestination, sPSSData->field_A65);
sub_80CD0B8(sPSSData->field_A65);
break;
case 2:
var = sub_80CB584();
if (sPSSData->field_2D0 != 0)
{
sPSSData->bg2_X += sPSSData->field_2CE;
sPSSData->bg2_X += sPSSData->wallpaperScrollSpeed;
if (--sPSSData->field_2D0 != 0)
return TRUE;
sub_80CCEE0();
@ -5327,7 +5327,7 @@ static bool8 ScrollToBox(void)
return TRUE;
}
static s8 sub_80CC644(u8 boxId)
static s8 DetermineBoxScrollDirection(u8 boxId)
{
u8 i;
u8 currentBox = StorageGetCurrentBox();
@ -5735,7 +5735,7 @@ static void sub_80CD210(struct Sprite *sprite)
sprite->data[0] = 3;
break;
case 3:
sprite->pos1.x -= sPSSData->field_2CE;
sprite->pos1.x -= sPSSData->wallpaperScrollSpeed;
if (sprite->pos1.x < 73 || sprite->pos1.x > 247)
sprite->invisible = TRUE;
if (--sprite->data[1] == 0)
@ -5746,7 +5746,7 @@ static void sub_80CD210(struct Sprite *sprite)
}
break;
case 4:
sprite->pos1.x -= sPSSData->field_2CE;
sprite->pos1.x -= sPSSData->wallpaperScrollSpeed;
break;
}
}
@ -6632,21 +6632,21 @@ static void sub_80CE7E8(void)
sPSSData->field_218C.mon = &gUnknown_02039D14;
sPSSData->field_2187 = 0;
sPSSData->field_2186 = 0;
sPSSData->field_2188 = 0;
sPSSData->pokemonSummaryScreenMode = PSS_MODE_NORMAL;
}
else if (sBoxCursorArea == CURSOR_AREA_IN_PARTY)
{
sPSSData->field_218C.mon = gPlayerParty;
sPSSData->field_2187 = sBoxCursorPosition;
sPSSData->field_2186 = CountPartyMons() - 1;
sPSSData->field_2188 = 0;
sPSSData->pokemonSummaryScreenMode = PSS_MODE_NORMAL;
}
else
{
sPSSData->field_218C.box = GetBoxedMonPtr(StorageGetCurrentBox(), 0);
sPSSData->field_2187 = sBoxCursorPosition;
sPSSData->field_2186 = IN_BOX_COUNT - 1;
sPSSData->field_2188 = 2;
sPSSData->pokemonSummaryScreenMode = PSS_MODE_BOX;
}
}

View File

@ -1,639 +0,0 @@
#include "global.h"
#include "sprite.h"
#include "decompress.h"
#include "unk_transition.h"
#include "battle_transition.h"
#include "task.h"
#include "palette.h"
#include "trig.h"
#include "bg.h"
#include "gpu_regs.h"
#include "constants/rgb.h"
typedef bool8 (*TransitionStateFunc)(struct Task *task);
// this file's functions
static void sub_81DA848(struct Sprite *sprite);
static void sub_81DA9BC(struct Sprite *sprite);
static bool8 sub_81DAACC(struct Task *task);
static bool8 sub_81DAC14(struct Task *task);
static bool8 sub_81DABBC(struct Task *task);
static bool8 sub_81DAB4C(struct Task *task);
static bool8 sub_81DAC80(struct Task *task);
static bool8 sub_81DACEC(struct Task *task);
static bool8 sub_81DAD58(struct Task *task);
static bool8 sub_81DADC4(struct Task *task);
static bool8 sub_81DAE44(struct Task *task);
static bool8 sub_81DAEB0(struct Task *task);
static bool8 sub_81DAF34(struct Task *task);
static bool8 sub_81DAFA0(struct Task *task);
static bool8 sub_81DB02C(struct Task *task);
static bool8 sub_81DB098(struct Task *task);
static bool8 sub_81DB124(struct Task *task);
static bool8 sub_81DB190(struct Task *task);
static bool8 sub_81DB224(struct Task *task);
static bool8 sub_81DB290(struct Task *task);
static bool8 sub_81DB328(struct Task *task);
// const rom data
static const u32 gUnknown_0862AD54[] = INCBIN_U32("graphics/battle_transitions/frontier_transition.4bpp.lz");
static const u32 gUnknown_0862AF30[] = INCBIN_U32("graphics/battle_transitions/frontier_transition.bin");
static const u32 gUnknown_0862B0DC[] = INCBIN_U32("graphics/battle_transitions/frontier_transition_circles.4bpp.lz");
static const u16 gUnknown_0862B53C[] = INCBIN_U16("graphics/battle_transitions/frontier_transition.gbapal");
// Unused Empty data.
static const u8 sFiller[0x1C0] = {0};
static const struct OamData sOamData_862B71C =
{
.y = 0,
.affineMode = ST_OAM_AFFINE_OFF,
.objMode = ST_OAM_OBJ_NORMAL,
.mosaic = 0,
.bpp = ST_OAM_4BPP,
.shape = SPRITE_SHAPE(64x64),
.x = 0,
.matrixNum = 0,
.size = SPRITE_SIZE(64x64),
.tileNum = 0,
.priority = 1,
.paletteNum = 0,
.affineParam = 0
};
static const struct CompressedSpriteSheet sUnknown_0862B724 =
{
.data = gUnknown_0862B0DC,
.size = 0x1800,
.tag = 11920
};
static const struct SpritePalette sUnknown_0862B72C =
{
.data = gUnknown_0862B53C,
.tag = 11920
};
static const union AnimCmd sSpriteAnim_862B734[] =
{
ANIMCMD_FRAME(0, 1),
ANIMCMD_END
};
static const union AnimCmd sSpriteAnim_862B73C[] =
{
ANIMCMD_FRAME(64, 1),
ANIMCMD_END
};
static const union AnimCmd sSpriteAnim_862B744[] =
{
ANIMCMD_FRAME(128, 1),
ANIMCMD_END
};
static const union AnimCmd *const sSpriteAnimTable_862B74C[] =
{
sSpriteAnim_862B734,
sSpriteAnim_862B73C,
sSpriteAnim_862B744
};
static const struct SpriteTemplate sUnknown_0862B758 =
{
.tileTag = 11920,
.paletteTag = 11920,
.oam = &sOamData_862B71C,
.anims = sSpriteAnimTable_862B74C,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
.callback = SpriteCallbackDummy,
};
static const TransitionStateFunc sPhase2_34_Funcs[] =
{
sub_81DAACC,
sub_81DAC14,
sub_81DABBC,
sub_81DAB4C,
sub_81DAC80
};
static const TransitionStateFunc sPhase2_35_Funcs[] =
{
sub_81DAACC,
sub_81DACEC,
sub_81DABBC,
sub_81DAB4C,
sub_81DAD58
};
static const TransitionStateFunc sPhase2_36_Funcs[] =
{
sub_81DAACC,
sub_81DADC4,
sub_81DABBC,
sub_81DAB4C,
sub_81DAE44
};
static const TransitionStateFunc sPhase2_37_Funcs[] =
{
sub_81DAACC,
sub_81DAEB0,
sub_81DABBC,
sub_81DAB4C,
sub_81DAF34
};
static const TransitionStateFunc sPhase2_38_Funcs[] =
{
sub_81DAACC,
sub_81DAFA0,
sub_81DABBC,
sub_81DAB4C,
sub_81DB02C
};
static const TransitionStateFunc sPhase2_39_Funcs[] =
{
sub_81DAACC,
sub_81DB098,
sub_81DABBC,
sub_81DAB4C,
sub_81DB124
};
static const TransitionStateFunc sPhase2_40_Funcs[] =
{
sub_81DAACC,
sub_81DB190,
sub_81DABBC,
sub_81DAB4C,
sub_81DB224
};
static const TransitionStateFunc sPhase2_41_Funcs[] =
{
sub_81DAACC,
sub_81DB290,
sub_81DABBC,
sub_81DAB4C,
sub_81DB328
};
// code
static void sub_81DA700(void)
{
u16 *dst1, *dst2;
GetBg0TilesDst(&dst1, &dst2);
LZ77UnCompVram(gUnknown_0862AD54, dst2);
LZ77UnCompVram(gUnknown_0862AF30, dst1);
LoadPalette(gUnknown_0862B53C, 0xF0, 0x20);
LoadCompressedSpriteSheet(&sUnknown_0862B724);
LoadSpritePalette(&sUnknown_0862B72C);
}
static u8 sub_81DA74C(s16 x, s16 y, u8 arg2, u8 arg3, s8 arg4, s8 arg5, u8 spriteAnimNum)
{
u8 spriteId = CreateSprite(&sUnknown_0862B758, x, y, 0);
switch (spriteAnimNum)
{
case 0:
gSprites[spriteId].data[0] = 120;
gSprites[spriteId].data[1] = 45;
break;
case 1:
gSprites[spriteId].data[0] = 89;
gSprites[spriteId].data[1] = 97;
break;
case 2:
gSprites[spriteId].data[0] = 151;
gSprites[spriteId].data[1] = 97;
break;
}
gSprites[spriteId].data[2] = arg4;
gSprites[spriteId].data[3] = arg5;
gSprites[spriteId].data[6] = arg2;
gSprites[spriteId].data[7] = arg3;
gSprites[spriteId].data[4] = 0;
gSprites[spriteId].data[5] = 0;
StartSpriteAnim(&gSprites[spriteId], spriteAnimNum);
gSprites[spriteId].callback = sub_81DA848;
return spriteId;
}
static void sub_81DA848(struct Sprite *sprite)
{
s16 *data = sprite->data;
if (sprite->pos1.x == data[0] && sprite->pos1.y == data[1])
{
sprite->callback = SpriteCallbackDummy;
}
else
{
if (data[4] == data[6])
{
sprite->pos1.x += data[2];
data[4] = 0;
}
else
{
data[4]++;
}
if (data[5] == data[7])
{
sprite->pos1.y += data[3];
data[5] = 0;
}
else
{
data[5]++;
}
}
}
static u8 sub_81DA8BC(s16 x, s16 y, s16 arg2, s16 arg3, s16 arg4, s16 arg5, s16 arg6, u8 spriteAnimNum)
{
u8 spriteId = CreateSprite(&sUnknown_0862B758, x, y, 0);
switch (spriteAnimNum)
{
case 0:
gSprites[spriteId].data[0] = 120;
gSprites[spriteId].data[1] = 45;
break;
case 1:
gSprites[spriteId].data[0] = 89;
gSprites[spriteId].data[1] = 97;
break;
case 2:
gSprites[spriteId].data[0] = 151;
gSprites[spriteId].data[1] = 97;
break;
}
gSprites[spriteId].data[2] = arg2;
gSprites[spriteId].data[3] = arg3;
gSprites[spriteId].data[4] = arg4;
gSprites[spriteId].data[5] = arg5;
gSprites[spriteId].data[6] = arg6;
StartSpriteAnim(&gSprites[spriteId], spriteAnimNum);
gSprites[spriteId].callback = sub_81DA9BC;
return spriteId;
}
static void sub_81DA9BC(struct Sprite *sprite)
{
sprite->pos2.x = (Sin2(sprite->data[2]) * sprite->data[4]) >> 12; // div by 4096
sprite->pos2.y = (Cos2(sprite->data[2]) * sprite->data[4]) >> 12; // div by 4096
sprite->data[2] = (sprite->data[2] + sprite->data[3]) % 360;
if (sprite->data[4] != sprite->data[5])
sprite->data[4] += sprite->data[6];
else
sprite->callback = SpriteCallbackDummy;
}
#define tState data[0]
static void sub_81DAA20(struct Task *task)
{
FreeSpriteTilesByTag(11920);
FreeSpritePaletteByTag(11920);
DestroySprite(&gSprites[task->data[4]]);
DestroySprite(&gSprites[task->data[5]]);
DestroySprite(&gSprites[task->data[6]]);
}
static bool8 sub_81DAA74(struct Task *task)
{
if (gSprites[task->data[4]].callback == SpriteCallbackDummy
&& gSprites[task->data[5]].callback == SpriteCallbackDummy
&& gSprites[task->data[6]].callback == SpriteCallbackDummy)
return TRUE;
else
return FALSE;
}
static bool8 sub_81DAACC(struct Task *task)
{
if (task->data[1] == 0)
{
ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON);
ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN1_ON);
ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_BG0_ON);
task->data[1]++;
return FALSE;
}
else
{
sub_81DA700();
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG0 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_ALL);
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(0, 16));
ChangeBgX(0, 0, 0);
ChangeBgY(0, 0, 0);
ChangeBgY(0, 0x500, 2);
task->data[1] = 0;
task->tState++;
return TRUE;
}
}
static bool8 sub_81DAB4C(struct Task *task)
{
if (task->data[2] == 0)
SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_BG0_ON);
if (task->data[2] == 16)
{
if (task->data[3] == 31)
{
BeginNormalPaletteFade(0xFFFFFFFF, -1, 0, 0x10, RGB_BLACK);
task->tState++;
}
else
{
task->data[3]++;
}
}
else
{
u16 blnd;
task->data[2]++;
blnd = task->data[2];
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(blnd, 16 - blnd));
}
return FALSE;
}
static bool8 sub_81DABBC(struct Task *task)
{
if (sub_81DAA74(task) == TRUE)
task->tState++;
return FALSE;
}
void Phase2Task_34(u8 taskId)
{
while (sPhase2_34_Funcs[gTasks[taskId].tState](&gTasks[taskId]));
}
static bool8 sub_81DAC14(struct Task *task)
{
task->data[4] = sub_81DA74C(120, -51, 0, 0, 0, 2, 0);
task->data[5] = sub_81DA74C(-7, 193, 0, 0, 2, -2, 1);
task->data[6] = sub_81DA74C(247, 193, 0, 0, -2, -2, 2);
task->tState++;
return FALSE;
}
static bool8 sub_81DAC80(struct Task *task)
{
if (!gPaletteFade.active)
{
sub_81DAA20(task);
DestroyTask(FindTaskIdByFunc(Phase2Task_34));
}
return FALSE;
}
void Phase2Task_35(u8 taskId)
{
while (sPhase2_35_Funcs[gTasks[taskId].tState](&gTasks[taskId]));
}
static bool8 sub_81DACEC(struct Task *task)
{
task->data[4] = sub_81DA74C(120, 197, 0, 0, 0, -4, 0);
task->data[5] = sub_81DA74C(241, 59, 0, 1, -4, 2, 1);
task->data[6] = sub_81DA74C(-1, 59, 0, 1, 4, 2, 2);
task->tState++;
return FALSE;
}
static bool8 sub_81DAD58(struct Task *task)
{
if (!gPaletteFade.active)
{
sub_81DAA20(task);
DestroyTask(FindTaskIdByFunc(Phase2Task_35));
}
return FALSE;
}
void Phase2Task_36(u8 taskId)
{
while (sPhase2_36_Funcs[gTasks[taskId].tState](&gTasks[taskId]));
}
static bool8 sub_81DADC4(struct Task *task)
{
task->data[4] = sub_81DA8BC(120, 45, 12, 4, 128, 0, -4, 0);
task->data[5] = sub_81DA8BC(89, 97, 252, 4, 128, 0, -4, 1);
task->data[6] = sub_81DA8BC(151, 97, 132, 4, 128, 0, -4, 2);
task->tState++;
return FALSE;
}
static bool8 sub_81DAE44(struct Task *task)
{
if (!gPaletteFade.active)
{
sub_81DAA20(task);
DestroyTask(FindTaskIdByFunc(Phase2Task_36));
}
return FALSE;
}
void Phase2Task_37(u8 taskId)
{
while (sPhase2_37_Funcs[gTasks[taskId].tState](&gTasks[taskId]));
}
static bool8 sub_81DAEB0(struct Task *task)
{
task->data[4] = sub_81DA8BC(120, 80, 284, 8, 131, 35, -3, 0);
task->data[5] = sub_81DA8BC(120, 80, 44, 8, 131, 35, -3, 1);
task->data[6] = sub_81DA8BC(121, 80, 164, 8, 131, 35, -3, 2);
task->tState++;
return FALSE;
}
static bool8 sub_81DAF34(struct Task *task)
{
if (!gPaletteFade.active)
{
sub_81DAA20(task);
DestroyTask(FindTaskIdByFunc(Phase2Task_37));
}
return FALSE;
}
void Phase2Task_38(u8 taskId)
{
while (sPhase2_38_Funcs[gTasks[taskId].tState](&gTasks[taskId]));
}
static bool8 sub_81DAFA0(struct Task *task)
{
if (task->data[1] == 0)
{
task->data[4] = sub_81DA74C(120, -51, 0, 0, 0, 4, 0);
}
else if (task->data[1] == 16)
{
task->data[5] = sub_81DA74C(-7, 193, 0, 0, 4, -4, 1);
}
else if (task->data[1] == 32)
{
task->data[6] = sub_81DA74C(247, 193, 0, 0, -4, -4, 2);
task->tState++;
}
task->data[1]++;
return FALSE;
}
static bool8 sub_81DB02C(struct Task *task)
{
if (!gPaletteFade.active)
{
sub_81DAA20(task);
DestroyTask(FindTaskIdByFunc(Phase2Task_38));
}
return FALSE;
}
void Phase2Task_39(u8 taskId)
{
while (sPhase2_39_Funcs[gTasks[taskId].tState](&gTasks[taskId]));
}
static bool8 sub_81DB098(struct Task *task)
{
if (task->data[1] == 0)
{
task->data[4] = sub_81DA74C(120, 197, 0, 0, 0, -8, 0);
}
else if (task->data[1] == 16)
{
task->data[5] = sub_81DA74C(241, 78, 0, 0, -8, 1, 1);
}
else if (task->data[1] == 32)
{
task->data[6] = sub_81DA74C(-1, 78, 0, 0, 8, 1, 2);
task->tState++;
}
task->data[1]++;
return FALSE;
}
static bool8 sub_81DB124(struct Task *task)
{
if (!gPaletteFade.active)
{
sub_81DAA20(task);
DestroyTask(FindTaskIdByFunc(Phase2Task_39));
}
return FALSE;
}
void Phase2Task_40(u8 taskId)
{
while (sPhase2_40_Funcs[gTasks[taskId].tState](&gTasks[taskId]));
}
static bool8 sub_81DB190(struct Task *task)
{
if (task->data[1] == 0)
{
task->data[4] = sub_81DA8BC(120, 45, 12, 4, 128, 0, -4, 0);
}
else if (task->data[1] == 16)
{
task->data[5] = sub_81DA8BC(89, 97, 252, 4, 128, 0, -4, 1);
}
else if (task->data[1] == 32)
{
task->data[6] = sub_81DA8BC(151, 97, 132, 4, 128, 0, -4, 2);
task->tState++;
}
task->data[1]++;
return FALSE;
}
static bool8 sub_81DB224(struct Task *task)
{
if (!gPaletteFade.active)
{
sub_81DAA20(task);
DestroyTask(FindTaskIdByFunc(Phase2Task_40));
}
return FALSE;
}
void Phase2Task_41(u8 taskId)
{
while (sPhase2_41_Funcs[gTasks[taskId].tState](&gTasks[taskId]));
}
static bool8 sub_81DB290(struct Task *task)
{
if (task->data[1] == 0)
{
task->data[4] = sub_81DA8BC(120, 80, 284, 8, 131, 35, -3, 0);
}
else if (task->data[1] == 16)
{
task->data[5] = sub_81DA8BC(120, 80, 44, 8, 131, 35, -3, 1);
}
else if (task->data[1] == 32)
{
task->data[6] = sub_81DA8BC(121, 80, 164, 8, 131, 35, -3, 2);
task->tState++;
}
task->data[1]++;
return FALSE;
}
static bool8 sub_81DB328(struct Task *task)
{
if (!gPaletteFade.active)
{
sub_81DAA20(task);
DestroyTask(FindTaskIdByFunc(Phase2Task_41));
}
return FALSE;
}

View File

@ -303,29 +303,27 @@ static u8 PickWildMonNature(void)
u8 i;
u8 j;
struct Pokeblock *safariPokeblock;
u8 natures[25];
u8 natures[NUM_NATURES];
if (GetSafariZoneFlag() == TRUE && Random() % 100 < 80)
{
safariPokeblock = SafariZoneGetActivePokeblock();
if (safariPokeblock != NULL)
{
for (i = 0; i < 25; i++)
for (i = 0; i < NUM_NATURES; i++)
natures[i] = i;
for (i = 0; i < 24; i++)
for (i = 0; i < NUM_NATURES - 1; i++)
{
for (j = i + 1; j < 25; j++)
for (j = i + 1; j < NUM_NATURES; j++)
{
if (Random() & 1)
{
u8 temp = natures[i];
natures[i] = natures[j];
natures[j] = temp;
u8 temp;
SWAP(natures[i], natures[j], temp);
}
}
}
for (i = 0; i < 25; i++)
for (i = 0; i < NUM_NATURES; i++)
{
if (PokeblockGetGain(natures[i], safariPokeblock) > 0)
return natures[i];
@ -337,11 +335,11 @@ static u8 PickWildMonNature(void)
&& GetMonAbility(&gPlayerParty[0]) == ABILITY_SYNCHRONIZE
&& Random() % 2 == 0)
{
return GetMonData(&gPlayerParty[0], MON_DATA_PERSONALITY) % 25;
return GetMonData(&gPlayerParty[0], MON_DATA_PERSONALITY) % NUM_NATURES;
}
// random nature
return Random() % 25;
return Random() % NUM_NATURES;
}
static void CreateWildMon(u16 species, u8 level)