mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-11-16 19:47:35 +01:00
Merge pull request #1316 from GriffinRichards/doc-scrcmd
Label remaining script commands, document some scrcmd.c, event_object_lock, trainer_see, berry tree
This commit is contained in:
commit
7e26aa3d21
@ -930,6 +930,17 @@
|
||||
.4byte \text
|
||||
.endm
|
||||
|
||||
@ Formatting for the braille window, to be put at the start of a pointer used by braillemessage.
|
||||
@ These are from RS and are ignored in Emerald (see ScrCmd_braillemessage, and comment above)
|
||||
.macro brailleformat winLeft:req, winTop:req, winRight:req, winBottom:req, textLeft:req, textTop:req
|
||||
.byte \winLeft
|
||||
.byte \winTop
|
||||
.byte \winRight
|
||||
.byte \winBottom
|
||||
.byte \textLeft
|
||||
.byte \textTop
|
||||
.endm
|
||||
|
||||
@ Gives the player one of the specified (species) Pokemon at level level holding item. The trailing 0s are unused parameters
|
||||
.macro givemon species:req, level:req, item:req
|
||||
.byte 0x79
|
||||
@ -1550,11 +1561,11 @@
|
||||
.2byte \y
|
||||
.endm
|
||||
|
||||
.macro cmdD8
|
||||
.macro selectapproachingtrainer
|
||||
.byte 0xd8
|
||||
.endm
|
||||
|
||||
.macro cmdD9
|
||||
.macro lockfortrainer
|
||||
.byte 0xd9
|
||||
.endm
|
||||
|
||||
@ -1562,7 +1573,7 @@
|
||||
.byte 0xda
|
||||
.endm
|
||||
|
||||
.macro message3 pointer:req
|
||||
.macro messageinstant pointer:req
|
||||
.byte 0xdb
|
||||
.4byte \pointer
|
||||
.endm
|
||||
|
@ -783,7 +783,7 @@ LilycoveCity_ContestLobby_EventScript_TrySetUpLinkContest:: @ 821AA15
|
||||
goto_if_eq LilycoveCity_ContestLobby_EventScript_CancelLinkError
|
||||
compare VAR_RESULT, LINKUP_FAILED_CONTEST_GMODE
|
||||
goto_if_eq LilycoveCity_ContestLobby_EventScript_CancelLinkModeDifference
|
||||
message3 LilycoveCity_ContestLobby_Text_Transmitting
|
||||
messageinstant LilycoveCity_ContestLobby_Text_Transmitting
|
||||
contestlinktransfer
|
||||
switch VAR_0x8004
|
||||
case 0, LilycoveCity_ContestLobby_EventScript_StartLinkContest
|
||||
@ -926,7 +926,7 @@ LilycoveCity_ContestLobby_EventScript_TryJoinLinkGroup:: @ 821AC38
|
||||
return
|
||||
|
||||
LilycoveCity_ContestLobby_EventScript_LinkLeaderDecided:: @ 821AC3D
|
||||
message3 LilycoveCity_ContestLobby_Text_Transmitting
|
||||
messageinstant LilycoveCity_ContestLobby_Text_Transmitting
|
||||
contestlinktransfer
|
||||
goto LilycoveCity_ContestLobby_EventScript_StartLinkContest
|
||||
end
|
||||
|
@ -216,10 +216,10 @@ gScriptCmdTable:: @ 81DB67C
|
||||
.4byte ScrCmd_initrotatingtilepuzzle @ 0xd5
|
||||
.4byte ScrCmd_freerotatingtilepuzzle @ 0xd6
|
||||
.4byte ScrCmd_warpmossdeepgym @ 0xd7
|
||||
.4byte ScrCmd_cmdD8 @ 0xd8
|
||||
.4byte ScrCmd_cmdD9 @ 0xd9
|
||||
.4byte ScrCmd_selectapproachingtrainer @ 0xd8
|
||||
.4byte ScrCmd_lockfortrainer @ 0xd9
|
||||
.4byte ScrCmd_closebraillemessage @ 0xda
|
||||
.4byte ScrCmd_cmdDB @ 0xdb
|
||||
.4byte ScrCmd_messageinstant @ 0xdb
|
||||
.4byte ScrCmd_fadescreenswapbuffers @ 0xdc
|
||||
.4byte ScrCmd_buffertrainerclassname @ 0xdd
|
||||
.4byte ScrCmd_buffertrainername @ 0xde
|
||||
|
@ -1,10 +1,9 @@
|
||||
EventScript_271354:: @ 8271354
|
||||
cmdD8
|
||||
cmdD9
|
||||
|
||||
EventScript_ShowSecondTrainerIntro:: @ 8271356
|
||||
special SetUpTrainerEncounterMusic
|
||||
special EndTrainerApproach
|
||||
EventScript_StartTrainerApproach:: @ 8271354
|
||||
selectapproachingtrainer
|
||||
lockfortrainer
|
||||
EventScript_TrainerApproach:: @ 8271356
|
||||
special PlayTrainerEncounterMusic
|
||||
special DoTrainerApproach
|
||||
waitstate
|
||||
goto EventScript_ShowTrainerIntroMsg
|
||||
|
||||
@ -14,11 +13,12 @@ EventScript_TryDoNormalTrainerBattle:: @ 8271362
|
||||
applymovement VAR_LAST_TALKED, Movement_RevealTrainer
|
||||
waitmovement 0
|
||||
specialvar VAR_RESULT, GetTrainerFlag
|
||||
compare VAR_RESULT, 0
|
||||
compare VAR_RESULT, FALSE
|
||||
goto_if_ne EventScript_NoNormalTrainerBattle
|
||||
special SetUpTrainerEncounterMusic
|
||||
special SetUpTrainerMovement
|
||||
special PlayTrainerEncounterMusic
|
||||
special SetTrainerFacingDirection
|
||||
goto EventScript_ShowTrainerIntroMsg
|
||||
|
||||
EventScript_NoNormalTrainerBattle:: @ 8271389
|
||||
gotopostbattlescript
|
||||
|
||||
@ -27,27 +27,29 @@ EventScript_TryDoDoubleTrainerBattle:: @ 827138A
|
||||
faceplayer
|
||||
call EventScript_RevealTrainer
|
||||
specialvar VAR_RESULT, GetTrainerFlag
|
||||
compare VAR_RESULT, 0
|
||||
compare VAR_RESULT, FALSE
|
||||
goto_if_ne EventScript_NoDoubleTrainerBattle
|
||||
special HasEnoughMonsForDoubleBattle
|
||||
compare VAR_RESULT, PLAYER_HAS_TWO_USABLE_MONS
|
||||
goto_if_ne EventScript_NotEnoughMonsForDoubleBattle
|
||||
special SetUpTrainerEncounterMusic
|
||||
special SetUpTrainerMovement
|
||||
special PlayTrainerEncounterMusic
|
||||
special SetTrainerFacingDirection
|
||||
goto EventScript_ShowTrainerIntroMsg
|
||||
|
||||
EventScript_NotEnoughMonsForDoubleBattle:: @ 82713BA
|
||||
special ShowTrainerCantBattleSpeech
|
||||
waitmessage
|
||||
waitbuttonpress
|
||||
release
|
||||
end
|
||||
|
||||
EventScript_NoDoubleTrainerBattle:: @ 82713C1
|
||||
gotopostbattlescript
|
||||
|
||||
EventScript_DoNoIntroTrainerBattle:: @ 82713C2
|
||||
applymovement VAR_LAST_TALKED, Movement_RevealTrainer
|
||||
waitmovement 0
|
||||
special SetUpTrainerEncounterMusic
|
||||
special PlayTrainerEncounterMusic
|
||||
trainerbattlebegin
|
||||
gotopostbattlescript
|
||||
|
||||
@ -56,8 +58,8 @@ EventScript_TryDoRematchBattle:: @ 82713D1
|
||||
specialvar VAR_RESULT, IsTrainerReadyForRematch
|
||||
compare VAR_RESULT, FALSE
|
||||
goto_if_eq EventScript_NoRematchTrainerBattle
|
||||
special SetUpTrainerEncounterMusic
|
||||
special SetUpTrainerMovement
|
||||
special PlayTrainerEncounterMusic
|
||||
special SetTrainerFacingDirection
|
||||
special ShowTrainerIntroSpeech
|
||||
waitmessage
|
||||
waitbuttonpress
|
||||
@ -65,6 +67,7 @@ EventScript_TryDoRematchBattle:: @ 82713D1
|
||||
waitstate
|
||||
releaseall
|
||||
end
|
||||
|
||||
EventScript_NoRematchTrainerBattle:: @ 82713F7
|
||||
gotopostbattlescript
|
||||
|
||||
@ -75,8 +78,8 @@ EventScript_TryDoDoubleRematchBattle:: @ 82713F8
|
||||
special HasEnoughMonsForDoubleBattle
|
||||
compare VAR_RESULT, PLAYER_HAS_TWO_USABLE_MONS
|
||||
goto_if_ne EventScript_NotEnoughMonsForDoubleRematchBattle
|
||||
special SetUpTrainerEncounterMusic
|
||||
special SetUpTrainerMovement
|
||||
special PlayTrainerEncounterMusic
|
||||
special SetTrainerFacingDirection
|
||||
special ShowTrainerIntroSpeech
|
||||
waitmessage
|
||||
waitbuttonpress
|
||||
@ -84,8 +87,10 @@ EventScript_TryDoDoubleRematchBattle:: @ 82713F8
|
||||
waitstate
|
||||
releaseall
|
||||
end
|
||||
|
||||
EventScript_NoDoubleRematchTrainerBattle:: @ 8271427
|
||||
gotopostbattlescript
|
||||
|
||||
EventScript_NotEnoughMonsForDoubleRematchBattle:: @ 8271428
|
||||
special ShowTrainerCantBattleSpeech
|
||||
waitmessage
|
||||
@ -108,7 +113,7 @@ EventScript_ShowTrainerIntroMsg:: @ 827143C
|
||||
waitbuttonpress
|
||||
special TryPrepareSecondApproachingTrainer
|
||||
compare VAR_RESULT, TRUE
|
||||
goto_if_eq EventScript_ShowSecondTrainerIntro
|
||||
goto_if_eq EventScript_TrainerApproach
|
||||
goto EventScript_DoTrainerBattle
|
||||
|
||||
EventScript_DoTrainerBattle:: @ 8271454
|
||||
|
@ -66,8 +66,8 @@ gSpecials:: @ 81DBA64
|
||||
def_special ShowTrainerIntroSpeech
|
||||
def_special ShowTrainerCantBattleSpeech
|
||||
def_special GetTrainerFlag
|
||||
def_special EndTrainerApproach
|
||||
def_special SetUpTrainerEncounterMusic
|
||||
def_special DoTrainerApproach
|
||||
def_special PlayTrainerEncounterMusic
|
||||
def_special ShouldTryRematchBattle
|
||||
def_special IsTrainerReadyForRematch
|
||||
def_special BattleSetup_StartRematchBattle
|
||||
@ -324,7 +324,7 @@ gSpecials:: @ 81DBA64
|
||||
def_special StartGroudonKyogreBattle
|
||||
def_special BattleSetup_StartLegendaryBattle
|
||||
def_special StartRegiBattle
|
||||
def_special SetUpTrainerMovement
|
||||
def_special SetTrainerFacingDirection
|
||||
def_special DoSealedChamberShakingEffect2
|
||||
def_special FoundBlackGlasses
|
||||
def_special StartDroughtWeatherBlend
|
||||
|
@ -1,222 +1,112 @@
|
||||
Underwater_SealedChamber_Braille_GoUpHere: @ 82A6B15
|
||||
.byte 4
|
||||
.byte 6
|
||||
.byte 26
|
||||
.byte 13
|
||||
.byte 7
|
||||
.byte 9
|
||||
brailleformat 4, 6, 26, 13, 7, 9
|
||||
.braille "GO UP HERE.$"
|
||||
|
||||
SealedChamber_OuterRoom_Braille_ABC: @ 82A6B27
|
||||
.byte 7
|
||||
.byte 6
|
||||
.byte 21
|
||||
.byte 13
|
||||
.byte 10
|
||||
.byte 9
|
||||
brailleformat 7, 6, 21, 13, 10, 9
|
||||
.braille "ABC$"
|
||||
|
||||
SealedChamber_OuterRoom_Braille_GHI: @ 82A6B31
|
||||
.byte 7
|
||||
.byte 6
|
||||
.byte 21
|
||||
.byte 13
|
||||
.byte 10
|
||||
.byte 9
|
||||
brailleformat 7, 6, 21, 13, 10, 9
|
||||
.braille "GHI$"
|
||||
|
||||
SealedChamber_OuterRoom_Braille_MNO: @ 82A6B3B
|
||||
.byte 7
|
||||
.byte 6
|
||||
.byte 21
|
||||
.byte 13
|
||||
.byte 10
|
||||
.byte 9
|
||||
brailleformat 7, 6, 21, 13, 10, 9
|
||||
.braille "MNO$"
|
||||
|
||||
SealedChamber_OuterRoom_Braille_TUV: @ 82A6B45
|
||||
.byte 7
|
||||
.byte 6
|
||||
.byte 21
|
||||
.byte 13
|
||||
.byte 10
|
||||
.byte 9
|
||||
brailleformat 7, 6, 21, 13, 10, 9
|
||||
.braille "TUV$"
|
||||
|
||||
SealedChamber_OuterRoom_Braille_DEF: @ 82A6B4F
|
||||
.byte 7
|
||||
.byte 6
|
||||
.byte 21
|
||||
.byte 13
|
||||
.byte 10
|
||||
.byte 9
|
||||
brailleformat 7, 6, 21, 13, 10, 9
|
||||
.braille "DEF$"
|
||||
|
||||
SealedChamber_OuterRoom_Braille_JKL: @ 82A6B59
|
||||
.byte 7
|
||||
.byte 6
|
||||
.byte 21
|
||||
.byte 13
|
||||
.byte 10
|
||||
.byte 9
|
||||
brailleformat 7, 6, 21, 13, 10, 9
|
||||
.braille "JKL$"
|
||||
|
||||
SealedChamber_OuterRoom_Braille_PQRS: @ 82A6B63
|
||||
.byte 7
|
||||
.byte 6
|
||||
.byte 21
|
||||
.byte 13
|
||||
.byte 10
|
||||
.byte 9
|
||||
brailleformat 7, 6, 21, 13, 10, 9
|
||||
.braille "PQRS$"
|
||||
|
||||
SealedChamber_OuterRoom_Braille_Period: @ 82A6B6E
|
||||
.byte 9
|
||||
.byte 6
|
||||
.byte 19
|
||||
.byte 13
|
||||
.byte 12
|
||||
.byte 9
|
||||
brailleformat 9, 6, 19, 13, 12, 9
|
||||
.braille ".$"
|
||||
|
||||
SealedChamber_OuterRoom_Braille_WXYZ: @ 82A6B76
|
||||
.byte 7
|
||||
.byte 6
|
||||
.byte 21
|
||||
.byte 13
|
||||
.byte 10
|
||||
.byte 9
|
||||
brailleformat 7, 6, 21, 13, 10, 9
|
||||
.braille "WXYZ$"
|
||||
|
||||
SealedChamber_OuterRoom_Braille_Comma: @ 82A6B81
|
||||
.byte 9
|
||||
.byte 6
|
||||
.byte 19
|
||||
.byte 13
|
||||
.byte 12
|
||||
.byte 9
|
||||
brailleformat 9, 6, 19, 13, 12, 9
|
||||
.braille ",$"
|
||||
|
||||
SealedChamber_OuterRoom_Braille_DigHere: @ 82A6B89
|
||||
.byte 7
|
||||
.byte 4
|
||||
.byte 23
|
||||
.byte 15
|
||||
.byte 10
|
||||
.byte 7
|
||||
brailleformat 7, 4, 23, 15, 10, 7
|
||||
.braille "DIG HERE.$"
|
||||
|
||||
SealedChamber_InnerRoom_Braille_FirstWailordLastRelicanth: @ 82A6B99
|
||||
.byte 0
|
||||
.byte 0
|
||||
.byte 29
|
||||
.byte 19
|
||||
.byte 3
|
||||
.byte 3
|
||||
brailleformat 0, 0, 29, 19, 3, 3
|
||||
.braille "FIRST COMES\n"
|
||||
.braille "WAILORD.\n"
|
||||
.braille "LAST COMES\n"
|
||||
.braille "RELICANTH.$"
|
||||
|
||||
SealedChamber_InnerRoom_Braille_InThisCaveWeHaveLived: @ 82A6BCA
|
||||
.byte 2
|
||||
.byte 0
|
||||
.byte 26
|
||||
.byte 19
|
||||
.byte 5
|
||||
.byte 3
|
||||
brailleformat 2, 0, 26, 19, 5, 3
|
||||
.braille "IN THIS\n"
|
||||
.braille "CAVE WE\n"
|
||||
.braille "HAVE\n"
|
||||
.braille "LIVED.$"
|
||||
|
||||
SealedChamber_InnerRoom_Braille_WeOweAllToThePokemon: @ 82A6BEC
|
||||
.byte 7
|
||||
.byte 2
|
||||
.byte 23
|
||||
.byte 17
|
||||
.byte 10
|
||||
.byte 5
|
||||
brailleformat 7, 2, 23, 17, 10, 5
|
||||
.braille "WE OWE ALL\n"
|
||||
.braille "TO THE\n"
|
||||
.braille "POKEMON.$"
|
||||
|
||||
SealedChamber_InnerRoom_Braille_ButWeSealedThePokemonAway: @ 82A6C0D
|
||||
.byte 3
|
||||
.byte 0
|
||||
.byte 25
|
||||
.byte 19
|
||||
.byte 6
|
||||
.byte 3
|
||||
brailleformat 3, 0, 25, 19, 6, 3
|
||||
.braille "BUT, WE\n"
|
||||
.braille "SEALED THE\n"
|
||||
.braille "POKEMON\n"
|
||||
.braille "AWAY.$"
|
||||
|
||||
SealedChamber_InnerRoom_Braille_WeFearedIt: @ 82A6C34
|
||||
.byte 5
|
||||
.byte 6
|
||||
.byte 25
|
||||
.byte 13
|
||||
.byte 8
|
||||
.byte 9
|
||||
brailleformat 5, 6, 25, 13, 8, 9
|
||||
.braille "WE FEARED IT.$"
|
||||
|
||||
SealedChamber_InnerRoom_Braille_ThoseWithCourageHope: @ 82A6C48
|
||||
.byte 6
|
||||
.byte 0
|
||||
.byte 24
|
||||
.byte 19
|
||||
.byte 9
|
||||
.byte 3
|
||||
brailleformat 6, 0, 24, 19, 9, 3
|
||||
.braille "THOSE WITH\n"
|
||||
.braille "COURAGE,\n"
|
||||
.braille "THOSE WITH\n"
|
||||
.braille "HOPE.$"
|
||||
|
||||
SealedChamber_InnerRoom_Braille_OpenDoorEternalPokemonWaits: @ 82A6C73
|
||||
.byte 3
|
||||
.byte 2
|
||||
.byte 27
|
||||
.byte 17
|
||||
.byte 6
|
||||
.byte 5
|
||||
brailleformat 3, 2, 27, 17, 6, 5
|
||||
.braille "OPEN A DOOR.\n"
|
||||
.braille "AN ETERNAL\n"
|
||||
.braille "POKEMON\n"
|
||||
.braille "WAITS.$"
|
||||
|
||||
DesertRuins_Braille_UseRockSmash: @ 82A6CA0
|
||||
.byte 1
|
||||
.byte 0
|
||||
.byte 27
|
||||
.byte 19
|
||||
.byte 4
|
||||
.byte 3
|
||||
brailleformat 1, 0, 27, 19, 4, 3
|
||||
.braille "LEFT, LEFT,\n"
|
||||
.braille "DOWN, DOWN.\n"
|
||||
.braille "THEN, USE\n"
|
||||
.braille "ROCK SMASH.$"
|
||||
|
||||
IslandCave_Braille_RunLapAroundWall: @ 82A6CD4
|
||||
.byte 5
|
||||
.byte 0
|
||||
.byte 25
|
||||
.byte 19
|
||||
.byte 8
|
||||
.byte 3
|
||||
brailleformat 5, 0, 25, 19, 8, 3
|
||||
.braille "STAY CLOSE\n"
|
||||
.braille "TO THE WALL.\n"
|
||||
.braille "RUN AROUND\n"
|
||||
.braille "ONE LAP.$"
|
||||
|
||||
AncientTomb_Braille_ShineInTheMiddle: @ 82A6D06
|
||||
.byte 3
|
||||
.byte 0
|
||||
.byte 25
|
||||
.byte 19
|
||||
.byte 6
|
||||
.byte 3
|
||||
brailleformat 3, 0, 25, 19, 6, 3
|
||||
.braille "THOSE WHO\n"
|
||||
.braille "INHERIT OUR\n"
|
||||
.braille "WILL, SHINE\n"
|
||||
|
@ -37,7 +37,7 @@ void ConfigureAndSetUpOneTrainerBattle(u8 trainerObjEventId, const u8 *trainerSc
|
||||
void ConfigureTwoTrainersBattle(u8 trainerObjEventId, const u8 *trainerScript);
|
||||
void SetUpTwoTrainersBattle(void);
|
||||
bool32 GetTrainerFlagFromScriptPointer(const u8 *data);
|
||||
void SetUpTrainerMovement(void);
|
||||
void SetTrainerFacingDirection(void);
|
||||
u8 GetTrainerBattleMode(void);
|
||||
bool8 GetTrainerFlag(void);
|
||||
bool8 HasTrainerBeenFought(u16 trainerId);
|
||||
@ -49,7 +49,7 @@ void ShowTrainerIntroSpeech(void);
|
||||
const u8 *BattleSetup_GetScriptAddrAfterBattle(void);
|
||||
const u8 *BattleSetup_GetTrainerPostBattleScript(void);
|
||||
void ShowTrainerCantBattleSpeech(void);
|
||||
void SetUpTrainerEncounterMusic(void);
|
||||
void PlayTrainerEncounterMusic(void);
|
||||
const u8 *GetTrainerALoseText(void);
|
||||
const u8 *GetTrainerBLoseText(void);
|
||||
const u8 *GetTrainerWonSpeech(void);
|
||||
|
@ -1,6 +1,8 @@
|
||||
#ifndef GUARD_BERRY_H
|
||||
#define GUARD_BERRY_H
|
||||
|
||||
#include "constants/berry.h"
|
||||
|
||||
void ClearEnigmaBerries(void);
|
||||
void SetEnigmaBerry(u8 *src);
|
||||
bool32 IsEnigmaBerryValid(void);
|
||||
@ -24,7 +26,7 @@ void ObjectEventInteractionPlantBerryTree(void);
|
||||
void ObjectEventInteractionPickBerryTree(void);
|
||||
void ObjectEventInteractionRemoveBerryTree(void);
|
||||
bool8 PlayerHasBerries(void);
|
||||
void ResetBerryTreeSparkleFlags(void);
|
||||
void SetBerryTreesSeen(void);
|
||||
|
||||
extern const struct Berry gBerries[];
|
||||
|
||||
|
@ -71,7 +71,7 @@ void MovePlayerOnBike(u8 direction, u16 newKeys, u16 heldKeys);
|
||||
void Bike_TryAcroBikeHistoryUpdate(u16 newKeys, u16 heldKeys);
|
||||
bool8 RS_IsRunningDisallowed(u8 tile);
|
||||
bool8 IsBikingDisallowedByPlayer(void);
|
||||
bool8 player_should_look_direction_be_enforced_upon_movement(void);
|
||||
bool8 IsPlayerNotUsingAcroBikeOnBumpySlope(void);
|
||||
void GetOnOffBike(u8 transitionFlags);
|
||||
void BikeClearState(int newDirHistory, int newAbStartHistory);
|
||||
void Bike_UpdateBikeCounterSpeed(u8 counter);
|
||||
|
@ -39,8 +39,6 @@
|
||||
|
||||
// These are the "abnormal weather events" that are used
|
||||
// to find Kyogre and Groudon.
|
||||
#define ABNORMAL_WEATHER_LOCATIONS (MARINE_CAVE_LOCATIONS + TERRA_CAVE_LOCATIONS)
|
||||
#define ABNORMAL_WEATHER_NONE 0
|
||||
|
||||
// Groudon/Terra Cave locations
|
||||
#define TERRA_CAVE_LOCATIONS_START 1
|
||||
@ -66,4 +64,7 @@
|
||||
#define ABNORMAL_WEATHER_ROUTE_129_EAST (MARINE_CAVE_LOCATIONS_START + 7)
|
||||
#define MARINE_CAVE_LOCATIONS 8
|
||||
|
||||
#define ABNORMAL_WEATHER_LOCATIONS (MARINE_CAVE_LOCATIONS + TERRA_CAVE_LOCATIONS)
|
||||
#define ABNORMAL_WEATHER_NONE 0
|
||||
|
||||
#endif // GUARD_CONSTANTS_WEATHER_H
|
||||
|
@ -1,12 +1,12 @@
|
||||
#ifndef GUARD_EVENT_OBJECT_LOCK_H
|
||||
#define GUARD_EVENT_OBJECT_LOCK_H
|
||||
|
||||
bool8 sub_80983C4(void);
|
||||
bool8 IsFreezePlayerFinished(void);
|
||||
void ScriptFreezeObjectEvents(void);
|
||||
bool8 sub_809847C(void);
|
||||
bool8 IsFreezeSelectedObjectAndPlayerFinished(void);
|
||||
void LockSelectedObjectEvent(void);
|
||||
void sub_8098630(void);
|
||||
bool8 sub_8098734(void);
|
||||
void FreezeForApproachingTrainers(void);
|
||||
bool8 IsFreezeObjectAndPlayerFinished(void);
|
||||
void ScriptUnfreezeObjectEvents(void);
|
||||
void UnionRoom_UnlockPlayerAndChatPartner(void);
|
||||
|
||||
|
@ -106,11 +106,11 @@ void ObjectEventSetGraphicsId(struct ObjectEvent *, u8 graphicsId);
|
||||
void ObjectEventTurn(struct ObjectEvent *, u8);
|
||||
void ObjectEventTurnByLocalIdAndMap(u8, u8, u8, u8);
|
||||
const struct ObjectEventGraphicsInfo *GetObjectEventGraphicsInfo(u8 graphicsId);
|
||||
void npc_by_local_id_and_map_set_field_1_bit_x20(u8, u8, u8, u8);
|
||||
void SetObjectInvisibility(u8, u8, u8, bool8);
|
||||
void FreeAndReserveObjectSpritePalettes(void);
|
||||
void SetObjectEventSpritePosByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup, s16 x, s16 y);
|
||||
void sub_808E7E4(u8, u8, u8);
|
||||
void sub_808E78C(u8, u8, u8, u8);
|
||||
void ResetObjectPriority(u8, u8, u8);
|
||||
void SetObjectPriority(u8, u8, u8, u8);
|
||||
void sub_808E75C(s16, s16);
|
||||
void ObjectEventGetLocalIdAndMap(struct ObjectEvent *objectEvent, void *localId, void *mapNum, void *mapGroup);
|
||||
void ShiftObjectEventCoords(struct ObjectEvent *, s16, s16);
|
||||
@ -189,7 +189,7 @@ void DestroyExtraMovementTask(u8);
|
||||
void UnfreezeObjectEvents(void);
|
||||
void FreezeObjectEventsExceptOne(u8 objectEventId);
|
||||
void TurnObjectEventSprite(u8, u8);
|
||||
void sub_8098074(u8 var1, u8 var2);
|
||||
void FreezeObjectEventsExceptTwo(u8 objectEventId1, u8 objectEventId2);
|
||||
void FreezeObjectEvents(void);
|
||||
bool8 FreezeObjectEvent(struct ObjectEvent *objectEvent);
|
||||
u8 GetMoveDirectionFastAnimNum(u8);
|
||||
@ -203,7 +203,7 @@ s16 GetFigure8XOffset(s16 idx);
|
||||
s16 GetFigure8YOffset(s16 idx);
|
||||
void CameraObjectReset2(void);
|
||||
u8 GetObjectEventBerryTreeId(u8 objectEventId);
|
||||
void sub_8092EF0(u8 mapId, u8 mapNumber, u8 mapGroup);
|
||||
void SetBerryTreeJustPicked(u8 mapId, u8 mapNumber, u8 mapGroup);
|
||||
bool8 IsBerryTreeSparkling(u8, u8, u8);
|
||||
|
||||
void MovementType_None(struct Sprite *);
|
||||
@ -307,11 +307,11 @@ u8 MovementType_WanderLeftAndRight_Step6(struct ObjectEvent *, struct Sprite *);
|
||||
u8 MovementType_FaceDirection_Step0(struct ObjectEvent *, struct Sprite *);
|
||||
u8 MovementType_FaceDirection_Step1(struct ObjectEvent *, struct Sprite *);
|
||||
u8 MovementType_FaceDirection_Step2(struct ObjectEvent *, struct Sprite *);
|
||||
u8 MovementType_BerryTreeGrowth_Step0(struct ObjectEvent *, struct Sprite *);
|
||||
u8 MovementType_BerryTreeGrowth_Step1(struct ObjectEvent *, struct Sprite *);
|
||||
u8 MovementType_BerryTreeGrowth_Step2(struct ObjectEvent *, struct Sprite *);
|
||||
u8 MovementType_BerryTreeGrowth_Step3(struct ObjectEvent *, struct Sprite *);
|
||||
u8 MovementType_BerryTreeGrowth_Step4(struct ObjectEvent *, struct Sprite *);
|
||||
u8 MovementType_BerryTreeGrowth_Normal(struct ObjectEvent *, struct Sprite *);
|
||||
u8 MovementType_BerryTreeGrowth_Move(struct ObjectEvent *, struct Sprite *);
|
||||
u8 MovementType_BerryTreeGrowth_SparkleStart(struct ObjectEvent *, struct Sprite *);
|
||||
u8 MovementType_BerryTreeGrowth_Sparkle(struct ObjectEvent *, struct Sprite *);
|
||||
u8 MovementType_BerryTreeGrowth_SparkleEnd(struct ObjectEvent *, struct Sprite *);
|
||||
u8 MovementType_FaceDownAndUp_Step0(struct ObjectEvent *, struct Sprite *);
|
||||
u8 MovementType_FaceDownAndUp_Step1(struct ObjectEvent *, struct Sprite *);
|
||||
u8 MovementType_FaceDownAndUp_Step2(struct ObjectEvent *, struct Sprite *);
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
extern const u8 EventScript_TestSignpostMsg[];
|
||||
extern const u8 EventScript_TryGetTrainerScript[];
|
||||
extern const u8 EventScript_271354[];
|
||||
extern const u8 EventScript_StartTrainerApproach[];
|
||||
extern const u8 EventScript_DoNoIntroTrainerBattle[];
|
||||
extern const u8 EventScript_TryDoDoubleTrainerBattle[];
|
||||
extern const u8 EventScript_TryDoNormalTrainerBattle[];
|
||||
|
@ -34,7 +34,7 @@ u8 PlayerGetZCoord(void);
|
||||
void SetPlayerAvatarTransitionFlags(u16 a);
|
||||
void sub_808BCE8(void);
|
||||
void InitPlayerAvatar(s16 a, s16 b, u8 c, u8 d);
|
||||
void sub_808B864(void);
|
||||
void PlayerFreeze(void);
|
||||
void sub_808BCF4(void);
|
||||
void SetSpinStartFacingDir(u8);
|
||||
void GetXYCoordsOneStepInFrontOfPlayer(s16 *xPtr, s16 *yPtr);
|
||||
|
@ -63,7 +63,7 @@ struct BerryTree
|
||||
{
|
||||
u8 berry;
|
||||
u8 stage:7;
|
||||
u8 growthSparkle:1;
|
||||
u8 stopGrowth:1;
|
||||
u16 minutesUntilNextStage;
|
||||
u8 berryYield;
|
||||
u8 regrowthCount:4;
|
||||
|
@ -17,8 +17,8 @@ extern bool8 gTrainerApproachedPlayer;
|
||||
extern u8 gApproachingTrainerId;
|
||||
|
||||
bool8 CheckForTrainersWantingBattle(void);
|
||||
void sub_80B4578(struct ObjectEvent *var);
|
||||
void EndTrainerApproach(void);
|
||||
void SetHiddenTrainerMovement(struct ObjectEvent *var);
|
||||
void DoTrainerApproach(void);
|
||||
void TryPrepareSecondApproachingTrainer(void);
|
||||
u8 FldEff_ExclamationMarkIcon(void);
|
||||
u8 FldEff_QuestionMarkIcon(void);
|
||||
|
@ -923,7 +923,7 @@ static void Script_PrintApprenticeMessage(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
FreezeObjectEvents();
|
||||
sub_808B864();
|
||||
PlayerFreeze();
|
||||
sub_808BCF4();
|
||||
DrawDialogueFrame(0, 1);
|
||||
PrintApprenticeMessage();
|
||||
|
@ -1197,7 +1197,7 @@ void ConfigureAndSetUpOneTrainerBattle(u8 trainerObjEventId, const u8 *trainerSc
|
||||
gSelectedObjectEvent = trainerObjEventId;
|
||||
gSpecialVar_LastTalked = gObjectEvents[trainerObjEventId].localId;
|
||||
BattleSetup_ConfigureTrainerBattle(trainerScript + 1);
|
||||
ScriptContext1_SetupScript(EventScript_271354);
|
||||
ScriptContext1_SetupScript(EventScript_StartTrainerApproach);
|
||||
ScriptContext2_Enable();
|
||||
}
|
||||
|
||||
@ -1210,7 +1210,7 @@ void ConfigureTwoTrainersBattle(u8 trainerObjEventId, const u8 *trainerScript)
|
||||
|
||||
void SetUpTwoTrainersBattle(void)
|
||||
{
|
||||
ScriptContext1_SetupScript(EventScript_271354);
|
||||
ScriptContext1_SetupScript(EventScript_StartTrainerApproach);
|
||||
ScriptContext2_Enable();
|
||||
}
|
||||
|
||||
@ -1220,10 +1220,12 @@ bool32 GetTrainerFlagFromScriptPointer(const u8 *data)
|
||||
return FlagGet(TRAINER_FLAGS_START + flag);
|
||||
}
|
||||
|
||||
void SetUpTrainerMovement(void)
|
||||
// Set trainer's movement type so they stop and remain facing that direction
|
||||
// Note: Only for trainers who are spoken to directly
|
||||
// For trainers who spot the player this is handled by PlayerFaceApproachingTrainer
|
||||
void SetTrainerFacingDirection(void)
|
||||
{
|
||||
struct ObjectEvent *objectEvent = &gObjectEvents[gSelectedObjectEvent];
|
||||
|
||||
SetTrainerMovementType(objectEvent, GetTrainerFacingDirectionMovementType(objectEvent->facingDirection));
|
||||
}
|
||||
|
||||
@ -1437,7 +1439,7 @@ void ShowTrainerCantBattleSpeech(void)
|
||||
ShowFieldMessage(GetTrainerCantBattleSpeech());
|
||||
}
|
||||
|
||||
void SetUpTrainerEncounterMusic(void)
|
||||
void PlayTrainerEncounterMusic(void)
|
||||
{
|
||||
u16 trainerId;
|
||||
u16 music;
|
||||
|
27
src/berry.c
27
src/berry.c
@ -1046,8 +1046,9 @@ void ClearBerryTrees(void)
|
||||
|
||||
static bool32 BerryTreeGrow(struct BerryTree *tree)
|
||||
{
|
||||
if (tree->growthSparkle)
|
||||
if (tree->stopGrowth)
|
||||
return FALSE;
|
||||
|
||||
switch (tree->stage)
|
||||
{
|
||||
case BERRY_STAGE_NO_BERRY:
|
||||
@ -1082,7 +1083,7 @@ void BerryTreeTimeUpdate(s32 minutes)
|
||||
{
|
||||
tree = &gSaveBlock1Ptr->berryTrees[i];
|
||||
|
||||
if (tree->berry && tree->stage && !tree->growthSparkle)
|
||||
if (tree->berry && tree->stage && !tree->stopGrowth)
|
||||
{
|
||||
if (minutes >= GetStageDurationByBerryType(tree->berry) * 71)
|
||||
{
|
||||
@ -1111,7 +1112,7 @@ void BerryTreeTimeUpdate(s32 minutes)
|
||||
}
|
||||
}
|
||||
|
||||
void PlantBerryTree(u8 id, u8 berry, u8 stage, bool8 sparkle)
|
||||
void PlantBerryTree(u8 id, u8 berry, u8 stage, bool8 allowGrowth)
|
||||
{
|
||||
struct BerryTree *tree = GetBerryTreeInfo(id);
|
||||
|
||||
@ -1125,8 +1126,10 @@ void PlantBerryTree(u8 id, u8 berry, u8 stage, bool8 sparkle)
|
||||
tree->minutesUntilNextStage *= 4;
|
||||
}
|
||||
|
||||
if (!sparkle)
|
||||
tree->growthSparkle = TRUE;
|
||||
// Stop growth, to keep tree at this stage until the player has seen it
|
||||
// allowGrowth is always true for berry trees the player has planted
|
||||
if (!allowGrowth)
|
||||
tree->stopGrowth = TRUE;
|
||||
}
|
||||
|
||||
void RemoveBerryTree(u8 id)
|
||||
@ -1175,9 +1178,9 @@ void GetBerryCountStringByBerryType(u8 berry, u8* dest, u32 berryCount)
|
||||
GetBerryCountString(dest, GetBerryInfo(berry)->name, berryCount);
|
||||
}
|
||||
|
||||
void ResetBerryTreeSparkleFlag(u8 id)
|
||||
void AllowBerryTreeGrowth(u8 id)
|
||||
{
|
||||
GetBerryTreeInfo(id)->growthSparkle = FALSE;
|
||||
GetBerryTreeInfo(id)->stopGrowth = FALSE;
|
||||
}
|
||||
|
||||
static u8 BerryTreeGetNumStagesWatered(struct BerryTree *tree)
|
||||
@ -1262,7 +1265,7 @@ void ObjectEventInteractionGetBerryTreeData(void)
|
||||
|
||||
id = GetObjectEventBerryTreeId(gSelectedObjectEvent);
|
||||
berry = GetBerryTypeByBerryTreeId(id);
|
||||
ResetBerryTreeSparkleFlag(id);
|
||||
AllowBerryTreeGrowth(id);
|
||||
localId = gSpecialVar_LastTalked;
|
||||
num = gSaveBlock1Ptr->location.mapNum;
|
||||
group = gSaveBlock1Ptr->location.mapGroup;
|
||||
@ -1313,7 +1316,7 @@ void ObjectEventInteractionPickBerryTree(void)
|
||||
void ObjectEventInteractionRemoveBerryTree(void)
|
||||
{
|
||||
RemoveBerryTree(GetObjectEventBerryTreeId(gSelectedObjectEvent));
|
||||
sub_8092EF0(gSpecialVar_LastTalked, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup);
|
||||
SetBerryTreeJustPicked(gSpecialVar_LastTalked, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup);
|
||||
}
|
||||
|
||||
bool8 PlayerHasBerries(void)
|
||||
@ -1321,7 +1324,9 @@ bool8 PlayerHasBerries(void)
|
||||
return IsBagPocketNonEmpty(POCKET_BERRIES);
|
||||
}
|
||||
|
||||
void ResetBerryTreeSparkleFlags(void)
|
||||
// Berry tree growth is frozen at their initial stage (usually, fully grown) until the player has seen the tree
|
||||
// For all berry trees on screen, allow normal growth
|
||||
void SetBerryTreesSeen(void)
|
||||
{
|
||||
s16 cam_left;
|
||||
s16 cam_top;
|
||||
@ -1343,7 +1348,7 @@ void ResetBerryTreeSparkleFlags(void)
|
||||
cam_left = gObjectEvents[i].currentCoords.x;
|
||||
cam_top = gObjectEvents[i].currentCoords.y;
|
||||
if (left <= cam_left && cam_left <= right && top <= cam_top && cam_top <= bottom)
|
||||
ResetBerryTreeSparkleFlag(gObjectEvents[i].trainerRange_berryTreeId);
|
||||
AllowBerryTreeGrowth(gObjectEvents[i].trainerRange_berryTreeId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -963,9 +963,10 @@ bool8 IsBikingDisallowedByPlayer(void)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool8 player_should_look_direction_be_enforced_upon_movement(void)
|
||||
bool8 IsPlayerNotUsingAcroBikeOnBumpySlope(void)
|
||||
{
|
||||
if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_ACRO_BIKE) != FALSE && MetatileBehavior_IsBumpySlope(gObjectEvents[gPlayerAvatar.objectEventId].currentMetatileBehavior) != FALSE)
|
||||
if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_ACRO_BIKE)
|
||||
&& MetatileBehavior_IsBumpySlope(gObjectEvents[gPlayerAvatar.objectEventId].currentMetatileBehavior))
|
||||
return FALSE;
|
||||
else
|
||||
return TRUE;
|
||||
|
@ -63,11 +63,11 @@ u8 (*const gMovementTypeFuncs_FaceDirection[])(struct ObjectEvent *, struct Spri
|
||||
};
|
||||
|
||||
u8 (*const gMovementTypeFuncs_BerryTreeGrowth[])(struct ObjectEvent *, struct Sprite *) = {
|
||||
MovementType_BerryTreeGrowth_Step0,
|
||||
MovementType_BerryTreeGrowth_Step1,
|
||||
MovementType_BerryTreeGrowth_Step2,
|
||||
MovementType_BerryTreeGrowth_Step3,
|
||||
MovementType_BerryTreeGrowth_Step4,
|
||||
MovementType_BerryTreeGrowth_Normal,
|
||||
MovementType_BerryTreeGrowth_Move,
|
||||
MovementType_BerryTreeGrowth_SparkleStart,
|
||||
MovementType_BerryTreeGrowth_Sparkle,
|
||||
MovementType_BerryTreeGrowth_SparkleEnd,
|
||||
};
|
||||
|
||||
u8 (*const gMovementTypeFuncs_FaceDownAndUp[])(struct ObjectEvent *, struct Sprite *) = {
|
||||
|
@ -16,18 +16,19 @@ bool8 IsPlayerStandingStill(void)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void sub_80983A4(u8 taskId)
|
||||
// Freeze player once their movement is finished
|
||||
static void Task_FreezePlayer(u8 taskId)
|
||||
{
|
||||
if (IsPlayerStandingStill())
|
||||
{
|
||||
sub_808B864();
|
||||
PlayerFreeze();
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
}
|
||||
|
||||
bool8 sub_80983C4(void)
|
||||
bool8 IsFreezePlayerFinished(void)
|
||||
{
|
||||
if (FuncIsActiveTask(sub_80983A4))
|
||||
if (FuncIsActiveTask(Task_FreezePlayer))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@ -42,30 +43,35 @@ bool8 sub_80983C4(void)
|
||||
void ScriptFreezeObjectEvents(void)
|
||||
{
|
||||
FreezeObjectEvents();
|
||||
CreateTask(sub_80983A4, 80);
|
||||
CreateTask(Task_FreezePlayer, 80);
|
||||
}
|
||||
|
||||
static void sub_8098400(u8 taskId)
|
||||
#define tPlayerFrozen data[0]
|
||||
#define tObjectFrozen data[1]
|
||||
#define tObjectId data[2]
|
||||
|
||||
// Freeze selected object and player once their movement is finished
|
||||
static void Task_FreezeSelectedObjectAndPlayer(u8 taskId)
|
||||
{
|
||||
struct Task *task = &gTasks[taskId];
|
||||
|
||||
if (!task->data[0] && IsPlayerStandingStill() == TRUE)
|
||||
if (!task->tPlayerFrozen && IsPlayerStandingStill() == TRUE)
|
||||
{
|
||||
sub_808B864();
|
||||
task->data[0] = 1;
|
||||
PlayerFreeze();
|
||||
task->tPlayerFrozen = TRUE;
|
||||
}
|
||||
if (!task->data[1] && !gObjectEvents[gSelectedObjectEvent].singleMovementActive)
|
||||
if (!task->tObjectFrozen && !gObjectEvents[gSelectedObjectEvent].singleMovementActive)
|
||||
{
|
||||
FreezeObjectEvent(&gObjectEvents[gSelectedObjectEvent]);
|
||||
task->data[1] = 1;
|
||||
task->tObjectFrozen = TRUE;
|
||||
}
|
||||
if (task->data[0] && task->data[1])
|
||||
if (task->tPlayerFrozen && task->tObjectFrozen)
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
|
||||
bool8 sub_809847C(void)
|
||||
bool8 IsFreezeSelectedObjectAndPlayerFinished(void)
|
||||
{
|
||||
if (FuncIsActiveTask(sub_8098400))
|
||||
if (FuncIsActiveTask(Task_FreezeSelectedObjectAndPlayer))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@ -80,11 +86,11 @@ void LockSelectedObjectEvent(void)
|
||||
{
|
||||
u8 taskId;
|
||||
FreezeObjectEventsExceptOne(gSelectedObjectEvent);
|
||||
taskId = CreateTask(sub_8098400, 80);
|
||||
taskId = CreateTask(Task_FreezeSelectedObjectAndPlayer, 80);
|
||||
if (!gObjectEvents[gSelectedObjectEvent].singleMovementActive)
|
||||
{
|
||||
FreezeObjectEvent(&gObjectEvents[gSelectedObjectEvent]);
|
||||
gTasks[taskId].data[1] = 1;
|
||||
gTasks[taskId].tObjectFrozen = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
@ -118,64 +124,71 @@ void Script_ClearHeldMovement(void)
|
||||
ObjectEventClearHeldMovementIfActive(&gObjectEvents[gSelectedObjectEvent]);
|
||||
}
|
||||
|
||||
static void sub_80985BC(u8 taskId)
|
||||
// Freeze designated object and player once their movement is finished
|
||||
static void Task_FreezeObjectAndPlayer(u8 taskId)
|
||||
{
|
||||
struct Task *task = &gTasks[taskId];
|
||||
u8 objectEventId = task->data[2];
|
||||
u8 objectEventId = task->tObjectId;
|
||||
|
||||
if (!task->data[0] && IsPlayerStandingStill() == TRUE)
|
||||
if (!task->tPlayerFrozen && IsPlayerStandingStill() == TRUE)
|
||||
{
|
||||
sub_808B864();
|
||||
task->data[0] = 1;
|
||||
PlayerFreeze();
|
||||
task->tPlayerFrozen = TRUE;
|
||||
}
|
||||
if (!task->data[1] && !gObjectEvents[objectEventId].singleMovementActive)
|
||||
if (!task->tObjectFrozen && !gObjectEvents[objectEventId].singleMovementActive)
|
||||
{
|
||||
FreezeObjectEvent(&gObjectEvents[objectEventId]);
|
||||
task->data[1] = 1;
|
||||
task->tObjectFrozen = TRUE;
|
||||
}
|
||||
if (task->data[0] && task->data[1])
|
||||
if (task->tPlayerFrozen && task->tObjectFrozen)
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
|
||||
void sub_8098630(void)
|
||||
void FreezeForApproachingTrainers(void)
|
||||
{
|
||||
u8 trainerObjectId1, trainerObjectId2, taskId;
|
||||
trainerObjectId1 = GetChosenApproachingTrainerObjectEventId(0);
|
||||
if(gNoOfApproachingTrainers == 2)
|
||||
|
||||
if (gNoOfApproachingTrainers == 2)
|
||||
{
|
||||
// Get second trainer, freeze all other objects
|
||||
trainerObjectId2 = GetChosenApproachingTrainerObjectEventId(1);
|
||||
sub_8098074(trainerObjectId1, trainerObjectId2);
|
||||
taskId = CreateTask(sub_80985BC, 80);
|
||||
gTasks[taskId].data[2] = trainerObjectId1;
|
||||
if(!gObjectEvents[trainerObjectId1].singleMovementActive)
|
||||
FreezeObjectEventsExceptTwo(trainerObjectId1, trainerObjectId2);
|
||||
|
||||
// Start task to freeze trainer 1 (and player) after movement
|
||||
taskId = CreateTask(Task_FreezeObjectAndPlayer, 80);
|
||||
gTasks[taskId].tObjectId = trainerObjectId1;
|
||||
if (!gObjectEvents[trainerObjectId1].singleMovementActive)
|
||||
{
|
||||
FreezeObjectEvent(&gObjectEvents[trainerObjectId1]);
|
||||
gTasks[taskId].data[1] = 1;
|
||||
gTasks[taskId].tObjectFrozen = TRUE;
|
||||
}
|
||||
taskId = CreateTask(sub_80985BC, 81);
|
||||
gTasks[taskId].data[2] = trainerObjectId2;
|
||||
if(!gObjectEvents[trainerObjectId2].singleMovementActive)
|
||||
|
||||
// Start task to freeze trainer 2 after movement
|
||||
taskId = CreateTask(Task_FreezeObjectAndPlayer, 81);
|
||||
gTasks[taskId].tObjectId = trainerObjectId2;
|
||||
if (!gObjectEvents[trainerObjectId2].singleMovementActive)
|
||||
{
|
||||
FreezeObjectEvent(&gObjectEvents[trainerObjectId2]);
|
||||
gTasks[taskId].data[1] = 1;
|
||||
gTasks[taskId].tObjectFrozen = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FreezeObjectEventsExceptOne(trainerObjectId1);
|
||||
taskId = CreateTask(sub_80985BC, 80);
|
||||
gTasks[taskId].data[2] = trainerObjectId1;
|
||||
if(!gObjectEvents[trainerObjectId1].singleMovementActive)
|
||||
taskId = CreateTask(Task_FreezeObjectAndPlayer, 80);
|
||||
gTasks[taskId].tObjectId = trainerObjectId1;
|
||||
if (!gObjectEvents[trainerObjectId1].singleMovementActive)
|
||||
{
|
||||
FreezeObjectEvent(&gObjectEvents[trainerObjectId1]);
|
||||
gTasks[taskId].data[1] = 1;
|
||||
gTasks[taskId].tObjectFrozen = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool8 sub_8098734(void)
|
||||
bool8 IsFreezeObjectAndPlayerFinished(void)
|
||||
{
|
||||
if (FuncIsActiveTask(sub_80985BC))
|
||||
if (FuncIsActiveTask(Task_FreezeObjectAndPlayer))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@ -185,3 +198,7 @@ bool8 sub_8098734(void)
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
#undef tPlayerFrozen
|
||||
#undef tObjectFrozen
|
||||
#undef tObjectId
|
||||
|
@ -1834,7 +1834,7 @@ void PlayerObjectTurn(struct PlayerAvatar *playerAvatar, u8 direction)
|
||||
ObjectEventTurn(&gObjectEvents[playerAvatar->objectEventId], direction);
|
||||
}
|
||||
|
||||
static void get_berry_tree_graphics(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
||||
static void SetBerryTreeGraphics(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
||||
{
|
||||
u8 berryStage;
|
||||
u8 berryId;
|
||||
@ -1842,7 +1842,7 @@ static void get_berry_tree_graphics(struct ObjectEvent *objectEvent, struct Spri
|
||||
objectEvent->invisible = TRUE;
|
||||
sprite->invisible = TRUE;
|
||||
berryStage = GetStageByBerryTreeId(objectEvent->trainerRange_berryTreeId);
|
||||
if (berryStage != 0)
|
||||
if (berryStage != BERRY_STAGE_NO_BERRY)
|
||||
{
|
||||
objectEvent->invisible = FALSE;
|
||||
sprite->invisible = FALSE;
|
||||
@ -1888,13 +1888,13 @@ static void SetObjectEventDynamicGraphicsId(struct ObjectEvent *objectEvent)
|
||||
}
|
||||
}
|
||||
|
||||
void npc_by_local_id_and_map_set_field_1_bit_x20(u8 localId, u8 mapNum, u8 mapGroup, u8 state)
|
||||
void SetObjectInvisibility(u8 localId, u8 mapNum, u8 mapGroup, bool8 invisible)
|
||||
{
|
||||
u8 objectEventId;
|
||||
|
||||
if (!TryGetObjectEventIdByLocalIdAndMap(localId, mapNum, mapGroup, &objectEventId))
|
||||
{
|
||||
gObjectEvents[objectEventId].invisible = state;
|
||||
gObjectEvents[objectEventId].invisible = invisible;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1918,7 +1918,7 @@ void sub_808E75C(s16 x, s16 y)
|
||||
}
|
||||
}
|
||||
|
||||
void sub_808E78C(u8 localId, u8 mapNum, u8 mapGroup, u8 subpriority)
|
||||
void SetObjectPriority(u8 localId, u8 mapNum, u8 mapGroup, u8 subpriority)
|
||||
{
|
||||
u8 objectEventId;
|
||||
struct ObjectEvent *objectEvent;
|
||||
@ -1933,7 +1933,7 @@ void sub_808E78C(u8 localId, u8 mapNum, u8 mapGroup, u8 subpriority)
|
||||
}
|
||||
}
|
||||
|
||||
void sub_808E7E4(u8 localId, u8 mapNum, u8 mapGroup)
|
||||
void ResetObjectPriority(u8 localId, u8 mapNum, u8 mapGroup)
|
||||
{
|
||||
u8 objectEventId;
|
||||
struct ObjectEvent *objectEvent;
|
||||
@ -2595,7 +2595,7 @@ bool8 MovementType_WanderAround_Step4(struct ObjectEvent *objectEvent, struct Sp
|
||||
bool8 MovementType_WanderAround_Step5(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
||||
{
|
||||
ObjectEventSetSingleMovement(objectEvent, sprite, GetWalkNormalMovementAction(objectEvent->movementDirection));
|
||||
objectEvent->singleMovementActive = 1;
|
||||
objectEvent->singleMovementActive = TRUE;
|
||||
sprite->data[1] = 6;
|
||||
return TRUE;
|
||||
}
|
||||
@ -2604,7 +2604,7 @@ bool8 MovementType_WanderAround_Step6(struct ObjectEvent *objectEvent, struct Sp
|
||||
{
|
||||
if (ObjectEventExecSingleMovementAction(objectEvent, sprite))
|
||||
{
|
||||
objectEvent->singleMovementActive = 0;
|
||||
objectEvent->singleMovementActive = FALSE;
|
||||
sprite->data[1] = 1;
|
||||
}
|
||||
return FALSE;
|
||||
@ -2880,7 +2880,7 @@ bool8 MovementType_LookAround_Step2(struct ObjectEvent *objectEvent, struct Spri
|
||||
if (ObjectEventExecSingleMovementAction(objectEvent, sprite))
|
||||
{
|
||||
SetMovementDelay(sprite, gMovementDelaysMedium[Random() & 3]);
|
||||
objectEvent->singleMovementActive = 0;
|
||||
objectEvent->singleMovementActive = FALSE;
|
||||
sprite->data[1] = 3;
|
||||
}
|
||||
return FALSE;
|
||||
@ -2964,7 +2964,7 @@ bool8 MovementType_WanderUpAndDown_Step4(struct ObjectEvent *objectEvent, struct
|
||||
bool8 MovementType_WanderUpAndDown_Step5(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
||||
{
|
||||
ObjectEventSetSingleMovement(objectEvent, sprite, GetWalkNormalMovementAction(objectEvent->movementDirection));
|
||||
objectEvent->singleMovementActive = 1;
|
||||
objectEvent->singleMovementActive = TRUE;
|
||||
sprite->data[1] = 6;
|
||||
return TRUE;
|
||||
}
|
||||
@ -2973,7 +2973,7 @@ bool8 MovementType_WanderUpAndDown_Step6(struct ObjectEvent *objectEvent, struct
|
||||
{
|
||||
if (ObjectEventExecSingleMovementAction(objectEvent, sprite))
|
||||
{
|
||||
objectEvent->singleMovementActive = 0;
|
||||
objectEvent->singleMovementActive = FALSE;
|
||||
sprite->data[1] = 1;
|
||||
}
|
||||
return FALSE;
|
||||
@ -3033,7 +3033,7 @@ bool8 MovementType_WanderLeftAndRight_Step4(struct ObjectEvent *objectEvent, str
|
||||
bool8 MovementType_WanderLeftAndRight_Step5(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
||||
{
|
||||
ObjectEventSetSingleMovement(objectEvent, sprite, GetWalkNormalMovementAction(objectEvent->movementDirection));
|
||||
objectEvent->singleMovementActive = 1;
|
||||
objectEvent->singleMovementActive = TRUE;
|
||||
sprite->data[1] = 6;
|
||||
return TRUE;
|
||||
}
|
||||
@ -3042,7 +3042,7 @@ bool8 MovementType_WanderLeftAndRight_Step6(struct ObjectEvent *objectEvent, str
|
||||
{
|
||||
if (ObjectEventExecSingleMovementAction(objectEvent, sprite))
|
||||
{
|
||||
objectEvent->singleMovementActive = 0;
|
||||
objectEvent->singleMovementActive = FALSE;
|
||||
sprite->data[1] = 1;
|
||||
}
|
||||
return FALSE;
|
||||
@ -3070,39 +3070,58 @@ bool8 MovementType_FaceDirection_Step1(struct ObjectEvent *objectEvent, struct S
|
||||
|
||||
bool8 MovementType_FaceDirection_Step2(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
||||
{
|
||||
objectEvent->singleMovementActive = 0;
|
||||
objectEvent->singleMovementActive = FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static bool8 ObjectEventCB2_BerryTree(struct ObjectEvent *objectEvent, struct Sprite *sprite);
|
||||
extern bool8 (*const gMovementTypeFuncs_BerryTreeGrowth[])(struct ObjectEvent *objectEvent, struct Sprite *sprite);
|
||||
|
||||
enum {
|
||||
BERRYTREEFUNC_NORMAL,
|
||||
BERRYTREEFUNC_MOVE,
|
||||
BERRYTREEFUNC_SPARKLE_START,
|
||||
BERRYTREEFUNC_SPARKLE,
|
||||
BERRYTREEFUNC_SPARKLE_END,
|
||||
};
|
||||
|
||||
#define sObjEventId data[0]
|
||||
#define sFuncId data[1]
|
||||
#define sTimer data[2]
|
||||
#define sBerryTreeFlags data[7]
|
||||
|
||||
#define BERRY_FLAG_SET_GFX (1 << 0)
|
||||
#define BERRY_FLAG_SPARKLING (1 << 1)
|
||||
#define BERRY_FLAG_JUST_PICKED (1 << 2)
|
||||
|
||||
void MovementType_BerryTreeGrowth(struct Sprite *sprite)
|
||||
{
|
||||
struct ObjectEvent *objectEvent;
|
||||
|
||||
objectEvent = &gObjectEvents[sprite->data[0]];
|
||||
if (!(sprite->data[7] & 1))
|
||||
objectEvent = &gObjectEvents[sprite->sObjEventId];
|
||||
if (!(sprite->sBerryTreeFlags & BERRY_FLAG_SET_GFX))
|
||||
{
|
||||
get_berry_tree_graphics(objectEvent, sprite);
|
||||
sprite->data[7] |= 1;
|
||||
SetBerryTreeGraphics(objectEvent, sprite);
|
||||
sprite->sBerryTreeFlags |= BERRY_FLAG_SET_GFX;
|
||||
}
|
||||
UpdateObjectEventCurrentMovement(objectEvent, sprite, ObjectEventCB2_BerryTree);
|
||||
}
|
||||
static bool8 ObjectEventCB2_BerryTree(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
||||
{
|
||||
return gMovementTypeFuncs_BerryTreeGrowth[sprite->data[1]](objectEvent, sprite);
|
||||
return gMovementTypeFuncs_BerryTreeGrowth[sprite->sFuncId](objectEvent, sprite);
|
||||
}
|
||||
|
||||
bool8 MovementType_BerryTreeGrowth_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
||||
// BERRYTREEFUNC_NORMAL
|
||||
bool8 MovementType_BerryTreeGrowth_Normal(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
||||
{
|
||||
u8 berryStage;
|
||||
ClearObjectEventMovement(objectEvent, sprite);
|
||||
objectEvent->invisible = TRUE;
|
||||
sprite->invisible = TRUE;
|
||||
berryStage = GetStageByBerryTreeId(objectEvent->trainerRange_berryTreeId);
|
||||
if (berryStage == 0)
|
||||
if (berryStage == BERRY_STAGE_NO_BERRY)
|
||||
{
|
||||
if (!(sprite->data[7] & 4) && sprite->animNum == 4)
|
||||
if (!(sprite->sBerryTreeFlags & BERRY_FLAG_JUST_PICKED) && sprite->animNum == BERRY_STAGE_FLOWERING)
|
||||
{
|
||||
gFieldEffectArguments[0] = objectEvent->currentCoords.x;
|
||||
gFieldEffectArguments[1] = objectEvent->currentCoords.y;
|
||||
@ -3115,34 +3134,36 @@ bool8 MovementType_BerryTreeGrowth_Step0(struct ObjectEvent *objectEvent, struct
|
||||
}
|
||||
objectEvent->invisible = FALSE;
|
||||
sprite->invisible = FALSE;
|
||||
berryStage --;
|
||||
berryStage--;
|
||||
if (sprite->animNum != berryStage)
|
||||
{
|
||||
sprite->data[1] = 2;
|
||||
sprite->sFuncId = BERRYTREEFUNC_SPARKLE_START;
|
||||
return TRUE;
|
||||
}
|
||||
get_berry_tree_graphics(objectEvent, sprite);
|
||||
SetBerryTreeGraphics(objectEvent, sprite);
|
||||
ObjectEventSetSingleMovement(objectEvent, sprite, MOVEMENT_ACTION_START_ANIM_IN_DIRECTION);
|
||||
sprite->data[1] = 1;
|
||||
sprite->sFuncId = BERRYTREEFUNC_MOVE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool8 MovementType_BerryTreeGrowth_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
||||
// BERRYTREEFUNC_MOVE
|
||||
bool8 MovementType_BerryTreeGrowth_Move(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
||||
{
|
||||
if (ObjectEventExecSingleMovementAction(objectEvent, sprite))
|
||||
{
|
||||
sprite->data[1] = 0;
|
||||
sprite->sFuncId = BERRYTREEFUNC_NORMAL;
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 MovementType_BerryTreeGrowth_Step2(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
||||
// BERRYTREEFUNC_SPARKLE_START
|
||||
bool8 MovementType_BerryTreeGrowth_SparkleStart(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
||||
{
|
||||
objectEvent->singleMovementActive = 1;
|
||||
sprite->data[1] = 3;
|
||||
sprite->data[2] = 0;
|
||||
sprite->data[7] |= 2;
|
||||
objectEvent->singleMovementActive = TRUE;
|
||||
sprite->sFuncId = BERRYTREEFUNC_SPARKLE;
|
||||
sprite->sTimer = 0;
|
||||
sprite->sBerryTreeFlags |= BERRY_FLAG_SPARKLING;
|
||||
gFieldEffectArguments[0] = objectEvent->currentCoords.x;
|
||||
gFieldEffectArguments[1] = objectEvent->currentCoords.y;
|
||||
gFieldEffectArguments[2] = sprite->subpriority - 1;
|
||||
@ -3151,30 +3172,32 @@ bool8 MovementType_BerryTreeGrowth_Step2(struct ObjectEvent *objectEvent, struct
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool8 MovementType_BerryTreeGrowth_Step3(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
||||
// BERRYTREEFUNC_SPARKLE
|
||||
bool8 MovementType_BerryTreeGrowth_Sparkle(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
||||
{
|
||||
sprite->data[2]++;
|
||||
objectEvent->invisible = (sprite->data[2] & 0x02) >> 1;
|
||||
sprite->sTimer++;
|
||||
objectEvent->invisible = (sprite->sTimer & 2) >> 1;
|
||||
sprite->animPaused = TRUE;
|
||||
if (sprite->data[2] > 64)
|
||||
if (sprite->sTimer > 64)
|
||||
{
|
||||
get_berry_tree_graphics(objectEvent, sprite);
|
||||
sprite->data[1] = 4;
|
||||
sprite->data[2] = 0;
|
||||
SetBerryTreeGraphics(objectEvent, sprite);
|
||||
sprite->sFuncId = BERRYTREEFUNC_SPARKLE_END;
|
||||
sprite->sTimer = 0;
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 MovementType_BerryTreeGrowth_Step4(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
||||
// BERRYTREEFUNC_SPARKLE_END
|
||||
bool8 MovementType_BerryTreeGrowth_SparkleEnd(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
||||
{
|
||||
sprite->data[2]++;
|
||||
objectEvent->invisible = (sprite->data[2] & 0x02) >> 1;
|
||||
sprite->sTimer++;
|
||||
objectEvent->invisible = (sprite->sTimer & 2) >> 1;
|
||||
sprite->animPaused = TRUE;
|
||||
if (sprite->data[2] > 64)
|
||||
if (sprite->sTimer > 64)
|
||||
{
|
||||
sprite->data[1] = 0;
|
||||
sprite->data[7] &= ~0x0002;
|
||||
sprite->sFuncId = BERRYTREEFUNC_NORMAL;
|
||||
sprite->sBerryTreeFlags &= ~BERRY_FLAG_SPARKLING;
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
@ -3201,7 +3224,7 @@ bool8 MovementType_FaceDownAndUp_Step2(struct ObjectEvent *objectEvent, struct S
|
||||
if (ObjectEventExecSingleMovementAction(objectEvent, sprite))
|
||||
{
|
||||
SetMovementDelay(sprite, gMovementDelaysMedium[Random() & 3]);
|
||||
objectEvent->singleMovementActive = 0;
|
||||
objectEvent->singleMovementActive = FALSE;
|
||||
sprite->data[1] = 3;
|
||||
}
|
||||
return FALSE;
|
||||
@ -3253,7 +3276,7 @@ bool8 MovementType_FaceLeftAndRight_Step2(struct ObjectEvent *objectEvent, struc
|
||||
if (ObjectEventExecSingleMovementAction(objectEvent, sprite))
|
||||
{
|
||||
SetMovementDelay(sprite, gMovementDelaysMedium[Random() & 3]);
|
||||
objectEvent->singleMovementActive = 0;
|
||||
objectEvent->singleMovementActive = FALSE;
|
||||
sprite->data[1] = 3;
|
||||
}
|
||||
return FALSE;
|
||||
@ -3305,7 +3328,7 @@ bool8 MovementType_FaceUpAndLeft_Step2(struct ObjectEvent *objectEvent, struct S
|
||||
if (ObjectEventExecSingleMovementAction(objectEvent, sprite))
|
||||
{
|
||||
SetMovementDelay(sprite, gMovementDelaysShort[Random() & 3]);
|
||||
objectEvent->singleMovementActive = 0;
|
||||
objectEvent->singleMovementActive = FALSE;
|
||||
sprite->data[1] = 3;
|
||||
}
|
||||
return FALSE;
|
||||
@ -3357,7 +3380,7 @@ bool8 MovementType_FaceUpAndRight_Step2(struct ObjectEvent *objectEvent, struct
|
||||
if (ObjectEventExecSingleMovementAction(objectEvent, sprite))
|
||||
{
|
||||
SetMovementDelay(sprite, gMovementDelaysShort[Random() & 3]);
|
||||
objectEvent->singleMovementActive = 0;
|
||||
objectEvent->singleMovementActive = FALSE;
|
||||
sprite->data[1] = 3;
|
||||
}
|
||||
return FALSE;
|
||||
@ -3409,7 +3432,7 @@ bool8 MovementType_FaceDownAndLeft_Step2(struct ObjectEvent *objectEvent, struct
|
||||
if (ObjectEventExecSingleMovementAction(objectEvent, sprite))
|
||||
{
|
||||
SetMovementDelay(sprite, gMovementDelaysShort[Random() & 3]);
|
||||
objectEvent->singleMovementActive = 0;
|
||||
objectEvent->singleMovementActive = FALSE;
|
||||
sprite->data[1] = 3;
|
||||
}
|
||||
return FALSE;
|
||||
@ -3461,7 +3484,7 @@ bool8 MovementType_FaceDownAndRight_Step2(struct ObjectEvent *objectEvent, struc
|
||||
if (ObjectEventExecSingleMovementAction(objectEvent, sprite))
|
||||
{
|
||||
SetMovementDelay(sprite, gMovementDelaysShort[Random() & 3]);
|
||||
objectEvent->singleMovementActive = 0;
|
||||
objectEvent->singleMovementActive = FALSE;
|
||||
sprite->data[1] = 3;
|
||||
}
|
||||
return FALSE;
|
||||
@ -3513,7 +3536,7 @@ bool8 MovementType_FaceDownUpAndLeft_Step2(struct ObjectEvent *objectEvent, stru
|
||||
if (ObjectEventExecSingleMovementAction(objectEvent, sprite))
|
||||
{
|
||||
SetMovementDelay(sprite, gMovementDelaysShort[Random() & 3]);
|
||||
objectEvent->singleMovementActive = 0;
|
||||
objectEvent->singleMovementActive = FALSE;
|
||||
sprite->data[1] = 3;
|
||||
}
|
||||
return FALSE;
|
||||
@ -3565,7 +3588,7 @@ bool8 MovementType_FaceDownUpAndRight_Step2(struct ObjectEvent *objectEvent, str
|
||||
if (ObjectEventExecSingleMovementAction(objectEvent, sprite))
|
||||
{
|
||||
SetMovementDelay(sprite, gMovementDelaysShort[Random() & 3]);
|
||||
objectEvent->singleMovementActive = 0;
|
||||
objectEvent->singleMovementActive = FALSE;
|
||||
sprite->data[1] = 3;
|
||||
}
|
||||
return FALSE;
|
||||
@ -3617,7 +3640,7 @@ bool8 MovementType_FaceUpLeftAndRight_Step2(struct ObjectEvent *objectEvent, str
|
||||
if (ObjectEventExecSingleMovementAction(objectEvent, sprite))
|
||||
{
|
||||
SetMovementDelay(sprite, gMovementDelaysShort[Random() & 3]);
|
||||
objectEvent->singleMovementActive = 0;
|
||||
objectEvent->singleMovementActive = FALSE;
|
||||
sprite->data[1] = 3;
|
||||
}
|
||||
return FALSE;
|
||||
@ -3669,7 +3692,7 @@ bool8 MovementType_FaceDownLeftAndRight_Step2(struct ObjectEvent *objectEvent, s
|
||||
if (ObjectEventExecSingleMovementAction(objectEvent, sprite))
|
||||
{
|
||||
SetMovementDelay(sprite, gMovementDelaysShort[Random() & 3]);
|
||||
objectEvent->singleMovementActive = 0;
|
||||
objectEvent->singleMovementActive = FALSE;
|
||||
sprite->data[1] = 3;
|
||||
}
|
||||
return FALSE;
|
||||
@ -3835,7 +3858,7 @@ bool8 MovementType_WalkBackAndForth_Step2(struct ObjectEvent *objectEvent, struc
|
||||
movementActionId = GetWalkInPlaceNormalMovementAction(objectEvent->facingDirection);
|
||||
|
||||
ObjectEventSetSingleMovement(objectEvent, sprite, movementActionId);
|
||||
objectEvent->singleMovementActive = 1;
|
||||
objectEvent->singleMovementActive = TRUE;
|
||||
sprite->data[1] = 3;
|
||||
return TRUE;
|
||||
}
|
||||
@ -3844,7 +3867,7 @@ bool8 MovementType_WalkBackAndForth_Step3(struct ObjectEvent *objectEvent, struc
|
||||
{
|
||||
if (ObjectEventExecSingleMovementAction(objectEvent, sprite))
|
||||
{
|
||||
objectEvent->singleMovementActive = 0;
|
||||
objectEvent->singleMovementActive = FALSE;
|
||||
sprite->data[1] = 1;
|
||||
}
|
||||
return FALSE;
|
||||
@ -3880,7 +3903,7 @@ bool8 MoveNextDirectionInSequence(struct ObjectEvent *objectEvent, struct Sprite
|
||||
movementActionId = GetWalkInPlaceNormalMovementAction(objectEvent->facingDirection);
|
||||
|
||||
ObjectEventSetSingleMovement(objectEvent, sprite, movementActionId);
|
||||
objectEvent->singleMovementActive = 1;
|
||||
objectEvent->singleMovementActive = TRUE;
|
||||
sprite->data[1] = 2;
|
||||
return TRUE;
|
||||
}
|
||||
@ -3889,7 +3912,7 @@ bool8 MovementType_WalkSequence_Step2(struct ObjectEvent *objectEvent, struct Sp
|
||||
{
|
||||
if (ObjectEventExecSingleMovementAction(objectEvent, sprite))
|
||||
{
|
||||
objectEvent->singleMovementActive = 0;
|
||||
objectEvent->singleMovementActive = FALSE;
|
||||
sprite->data[1] = 1;
|
||||
}
|
||||
return FALSE;
|
||||
@ -4233,7 +4256,7 @@ bool8 MovementType_CopyPlayer_Step2(struct ObjectEvent *objectEvent, struct Spri
|
||||
{
|
||||
if (ObjectEventExecSingleMovementAction(objectEvent, sprite))
|
||||
{
|
||||
objectEvent->singleMovementActive = 0;
|
||||
objectEvent->singleMovementActive = FALSE;
|
||||
sprite->data[1] = 1;
|
||||
}
|
||||
return FALSE;
|
||||
@ -4247,7 +4270,7 @@ bool8 CopyablePlayerMovement_None(struct ObjectEvent *objectEvent, struct Sprite
|
||||
bool8 CopyablePlayerMovement_FaceDirection(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 playerDirection, bool8 tileCallback(u8))
|
||||
{
|
||||
ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(state_to_direction(gInitialMovementTypeFacingDirections[objectEvent->movementType], objectEvent->directionSequenceIndex, playerDirection)));
|
||||
objectEvent->singleMovementActive = 1;
|
||||
objectEvent->singleMovementActive = TRUE;
|
||||
sprite->data[1] = 2;
|
||||
return TRUE;
|
||||
}
|
||||
@ -4268,7 +4291,7 @@ bool8 CopyablePlayerMovement_GoSpeed0(struct ObjectEvent *objectEvent, struct Sp
|
||||
direction = state_to_direction(gInitialMovementTypeFacingDirections[objectEvent->movementType], objectEvent->directionSequenceIndex, direction);
|
||||
ObjectEventMoveDestCoords(objectEvent, direction, &x, &y);
|
||||
ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(direction));
|
||||
objectEvent->singleMovementActive = 1;
|
||||
objectEvent->singleMovementActive = TRUE;
|
||||
sprite->data[1] = 2;
|
||||
return TRUE;
|
||||
}
|
||||
@ -4283,7 +4306,7 @@ bool8 CopyablePlayerMovement_GoSpeed0(struct ObjectEvent *objectEvent, struct Sp
|
||||
{
|
||||
ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(direction));
|
||||
}
|
||||
objectEvent->singleMovementActive = 1;
|
||||
objectEvent->singleMovementActive = TRUE;
|
||||
sprite->data[1] = 2;
|
||||
return TRUE;
|
||||
}
|
||||
@ -4538,13 +4561,13 @@ bool8 MovementType_Invisible_Step1(struct ObjectEvent *objectEvent, struct Sprit
|
||||
|
||||
bool8 MovementType_Invisible_Step2(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
||||
{
|
||||
objectEvent->singleMovementActive = 0;
|
||||
objectEvent->singleMovementActive = FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void ClearObjectEventMovement(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
||||
{
|
||||
objectEvent->singleMovementActive = 0;
|
||||
objectEvent->singleMovementActive = FALSE;
|
||||
objectEvent->heldMovementActive = FALSE;
|
||||
objectEvent->heldMovementFinished = FALSE;
|
||||
objectEvent->movementActionId = 0xFF;
|
||||
@ -4824,7 +4847,7 @@ bool8 IsBerryTreeSparkling(u8 localId, u8 mapNum, u8 mapGroup)
|
||||
u8 objectEventId;
|
||||
|
||||
if (!TryGetObjectEventIdByLocalIdAndMap(localId, mapNum, mapGroup, &objectEventId)
|
||||
&& gSprites[gObjectEvents[objectEventId].spriteId].data[7] & 2)
|
||||
&& gSprites[gObjectEvents[objectEventId].spriteId].sBerryTreeFlags & BERRY_FLAG_SPARKLING)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
@ -4832,13 +4855,13 @@ bool8 IsBerryTreeSparkling(u8 localId, u8 mapNum, u8 mapGroup)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void sub_8092EF0(u8 localId, u8 mapNum, u8 mapGroup)
|
||||
void SetBerryTreeJustPicked(u8 localId, u8 mapNum, u8 mapGroup)
|
||||
{
|
||||
u8 objectEventId;
|
||||
|
||||
if (!TryGetObjectEventIdByLocalIdAndMap(localId, mapNum, mapGroup, &objectEventId))
|
||||
{
|
||||
gSprites[gObjectEvents[objectEventId].spriteId].data[7] |= 0x04;
|
||||
gSprites[gObjectEvents[objectEventId].spriteId].sBerryTreeFlags |= BERRY_FLAG_JUST_PICKED;
|
||||
}
|
||||
}
|
||||
|
||||
@ -6579,7 +6602,7 @@ bool8 MovementAction_RevealTrainer_Step0(struct ObjectEvent *objectEvent, struct
|
||||
{
|
||||
if (objectEvent->movementType == MOVEMENT_TYPE_HIDDEN)
|
||||
{
|
||||
sub_80B4578(objectEvent);
|
||||
SetHiddenTrainerMovement(objectEvent);
|
||||
return FALSE;
|
||||
}
|
||||
if (objectEvent->movementType != MOVEMENT_TYPE_TREE_DISGUISE && objectEvent->movementType != MOVEMENT_TYPE_MOUNTAIN_DISGUISE)
|
||||
@ -8971,13 +8994,14 @@ void DestroyExtraMovementTask(u8 taskId)
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
|
||||
void sub_8098074(u8 var1, u8 var2)
|
||||
// Used to freeze other objects except two trainers approaching for battle
|
||||
void FreezeObjectEventsExceptTwo(u8 objectEventId1, u8 objectEventId2)
|
||||
{
|
||||
u8 i;
|
||||
|
||||
for(i = 0; i < OBJECT_EVENTS_COUNT; i++)
|
||||
{
|
||||
if(i != var1 && i != var2 &&
|
||||
if(i != objectEventId1 && i != objectEventId2 &&
|
||||
gObjectEvents[i].active && i != gPlayerAvatar.objectEventId)
|
||||
FreezeObjectEvent(&gObjectEvents[i]);
|
||||
}
|
||||
|
@ -417,7 +417,7 @@ void CameraUpdate(void)
|
||||
CameraMove(deltaX, deltaY);
|
||||
UpdateObjectEventsForCameraUpdate(deltaX, deltaY);
|
||||
RotatingGatePuzzleCameraUpdate(deltaX, deltaY);
|
||||
ResetBerryTreeSparkleFlags();
|
||||
SetBerryTreesSeen();
|
||||
AddCameraTileOffset(&sFieldCameraOffset, deltaX * 2, deltaY * 2);
|
||||
RedrawMapSlicesForCameraUpdate(&sFieldCameraOffset, deltaX * 2, deltaY * 2);
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ static void PlayerNotOnBikeCollideWithFarawayIslandMew(u8);
|
||||
|
||||
static void PlayCollisionSoundIfNotFacingWarp(u8 a);
|
||||
|
||||
static void sub_808C280(struct ObjectEvent *);
|
||||
static void HideShowWarpArrow(struct ObjectEvent *);
|
||||
|
||||
static void StartStrengthAnim(u8, u8);
|
||||
static void Task_PushBoulder(u8 taskId);
|
||||
@ -323,7 +323,7 @@ void PlayerStep(u8 direction, u16 newKeys, u16 heldKeys)
|
||||
{
|
||||
struct ObjectEvent *playerObjEvent = &gObjectEvents[gPlayerAvatar.objectEventId];
|
||||
|
||||
sub_808C280(playerObjEvent);
|
||||
HideShowWarpArrow(playerObjEvent);
|
||||
if (gPlayerAvatar.preventStep == FALSE)
|
||||
{
|
||||
Bike_TryAcroBikeHistoryUpdate(newKeys, heldKeys);
|
||||
@ -940,9 +940,9 @@ u8 PlayerGetCopyableMovement(void)
|
||||
return gObjectEvents[gPlayerAvatar.objectEventId].playerCopyableMovement;
|
||||
}
|
||||
|
||||
static void sub_808B6BC(u8 a)
|
||||
static void PlayerForceSetHeldMovement(u8 movementActionId)
|
||||
{
|
||||
ObjectEventForceSetHeldMovement(&gObjectEvents[gPlayerAvatar.objectEventId], a);
|
||||
ObjectEventForceSetHeldMovement(&gObjectEvents[gPlayerAvatar.objectEventId], movementActionId);
|
||||
}
|
||||
|
||||
void PlayerSetAnimId(u8 movementActionId, u8 copyableMovement)
|
||||
@ -1020,12 +1020,13 @@ void PlayerJumpLedge(u8 direction)
|
||||
PlayerSetAnimId(GetJump2MovementAction(direction), 8);
|
||||
}
|
||||
|
||||
void sub_808B864(void)
|
||||
// Stop player on current facing direction once they're done moving and if they're not currently Acro Biking on bumpy slope
|
||||
void PlayerFreeze(void)
|
||||
{
|
||||
if (gPlayerAvatar.tileTransitionState == T_TILE_CENTER || gPlayerAvatar.tileTransitionState == T_NOT_MOVING)
|
||||
{
|
||||
if (player_should_look_direction_be_enforced_upon_movement())
|
||||
sub_808B6BC(GetFaceDirectionMovementAction(gObjectEvents[gPlayerAvatar.objectEventId].facingDirection));
|
||||
if (IsPlayerNotUsingAcroBikeOnBumpySlope())
|
||||
PlayerForceSetHeldMovement(GetFaceDirectionMovementAction(gObjectEvents[gPlayerAvatar.objectEventId].facingDirection));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1424,7 +1425,7 @@ void SetPlayerAvatarWatering(u8 direction)
|
||||
StartSpriteAnim(&gSprites[gPlayerAvatar.spriteId], GetFaceDirectionAnimNum(direction));
|
||||
}
|
||||
|
||||
static void sub_808C280(struct ObjectEvent *objectEvent)
|
||||
static void HideShowWarpArrow(struct ObjectEvent *objectEvent)
|
||||
{
|
||||
s16 x;
|
||||
s16 y;
|
||||
@ -1435,6 +1436,7 @@ static void sub_808C280(struct ObjectEvent *objectEvent)
|
||||
{
|
||||
if (sArrowWarpMetatileBehaviorChecks2[x](metatileBehavior) && direction == objectEvent->movementDirection)
|
||||
{
|
||||
// Show warp arrow if applicable
|
||||
x = objectEvent->currentCoords.x;
|
||||
y = objectEvent->currentCoords.y;
|
||||
MoveCoords(direction, &x, &y);
|
||||
|
@ -1971,7 +1971,7 @@ bool8 UseRegisteredKeyItemOnField(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
FreezeObjectEvents();
|
||||
sub_808B864();
|
||||
PlayerFreeze();
|
||||
sub_808BCF4();
|
||||
gSpecialVar_ItemId = gSaveBlock1Ptr->registeredItem;
|
||||
taskId = CreateTask(ItemId_GetFieldFunc(gSaveBlock1Ptr->registeredItem), 8);
|
||||
|
@ -1114,7 +1114,7 @@ static void StartMatchCall(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
FreezeObjectEvents();
|
||||
sub_808B864();
|
||||
PlayerFreeze();
|
||||
sub_808BCF4();
|
||||
}
|
||||
|
||||
|
110
src/scrcmd.c
110
src/scrcmd.c
@ -53,8 +53,8 @@
|
||||
typedef u16 (*SpecialFunc)(void);
|
||||
typedef void (*NativeFunc)(void);
|
||||
|
||||
EWRAM_DATA const u8 *gUnknown_020375C0 = NULL;
|
||||
static EWRAM_DATA u32 gUnknown_020375C4 = 0;
|
||||
EWRAM_DATA const u8 *gRamScriptRetAddr = NULL;
|
||||
static EWRAM_DATA u32 sAddressOffset = 0; // For relative addressing in vgoto etc., used by saved scripts (e.g. Mystery Event)
|
||||
static EWRAM_DATA u16 sPauseCounter = 0;
|
||||
static EWRAM_DATA u16 sMovingNpcId = 0;
|
||||
static EWRAM_DATA u16 sMovingNpcMapBank = 0;
|
||||
@ -192,7 +192,7 @@ bool8 ScrCmd_setvaddress(struct ScriptContext *ctx)
|
||||
u32 addr1 = (u32)ctx->scriptPtr - 1;
|
||||
u32 addr2 = ScriptReadWord(ctx);
|
||||
|
||||
gUnknown_020375C4 = addr2 - addr1;
|
||||
sAddressOffset = addr2 - addr1;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -200,7 +200,7 @@ bool8 ScrCmd_vgoto(struct ScriptContext *ctx)
|
||||
{
|
||||
u32 addr = ScriptReadWord(ctx);
|
||||
|
||||
ScriptJump(ctx, (u8 *)(addr - gUnknown_020375C4));
|
||||
ScriptJump(ctx, (u8 *)(addr - sAddressOffset));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -208,14 +208,14 @@ bool8 ScrCmd_vcall(struct ScriptContext *ctx)
|
||||
{
|
||||
u32 addr = ScriptReadWord(ctx);
|
||||
|
||||
ScriptCall(ctx, (u8 *)(addr - gUnknown_020375C4));
|
||||
ScriptCall(ctx, (u8 *)(addr - sAddressOffset));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 ScrCmd_vgoto_if(struct ScriptContext *ctx)
|
||||
{
|
||||
u8 condition = ScriptReadByte(ctx);
|
||||
const u8 *ptr = (const u8 *)(ScriptReadWord(ctx) - gUnknown_020375C4);
|
||||
const u8 *ptr = (const u8 *)(ScriptReadWord(ctx) - sAddressOffset);
|
||||
|
||||
if (sScriptConditionTable[condition][ctx->comparisonResult] == 1)
|
||||
ScriptJump(ctx, ptr);
|
||||
@ -225,7 +225,7 @@ bool8 ScrCmd_vgoto_if(struct ScriptContext *ctx)
|
||||
bool8 ScrCmd_vcall_if(struct ScriptContext *ctx)
|
||||
{
|
||||
u8 condition = ScriptReadByte(ctx);
|
||||
const u8 *ptr = (const u8 *)(ScriptReadWord(ctx) - gUnknown_020375C4);
|
||||
const u8 *ptr = (const u8 *)(ScriptReadWord(ctx) - sAddressOffset);
|
||||
|
||||
if (sScriptConditionTable[condition][ctx->comparisonResult] == 1)
|
||||
ScriptCall(ctx, ptr);
|
||||
@ -282,7 +282,7 @@ bool8 ScrCmd_callstd_if(struct ScriptContext *ctx)
|
||||
|
||||
bool8 ScrCmd_returnram(struct ScriptContext *ctx)
|
||||
{
|
||||
ScriptJump(ctx, gUnknown_020375C0);
|
||||
ScriptJump(ctx, gRamScriptRetAddr);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -378,32 +378,30 @@ bool8 ScrCmd_setorcopyvar(struct ScriptContext *ctx)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
u8 compare_012(u16 a1, u16 a2)
|
||||
u8 Compare(u16 a, u16 b)
|
||||
{
|
||||
if (a1 < a2)
|
||||
if (a < b)
|
||||
return 0;
|
||||
if (a1 == a2)
|
||||
if (a == b)
|
||||
return 1;
|
||||
return 2;
|
||||
}
|
||||
|
||||
// comparelocaltolocal
|
||||
bool8 ScrCmd_compare_local_to_local(struct ScriptContext *ctx)
|
||||
{
|
||||
const u8 value1 = ctx->data[ScriptReadByte(ctx)];
|
||||
const u8 value2 = ctx->data[ScriptReadByte(ctx)];
|
||||
|
||||
ctx->comparisonResult = compare_012(value1, value2);
|
||||
ctx->comparisonResult = Compare(value1, value2);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// comparelocaltoimm
|
||||
bool8 ScrCmd_compare_local_to_value(struct ScriptContext *ctx)
|
||||
{
|
||||
const u8 value1 = ctx->data[ScriptReadByte(ctx)];
|
||||
const u8 value2 = ScriptReadByte(ctx);
|
||||
|
||||
ctx->comparisonResult = compare_012(value1, value2);
|
||||
ctx->comparisonResult = Compare(value1, value2);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -412,7 +410,7 @@ bool8 ScrCmd_compare_local_to_addr(struct ScriptContext *ctx)
|
||||
const u8 value1 = ctx->data[ScriptReadByte(ctx)];
|
||||
const u8 value2 = *(const u8 *)ScriptReadWord(ctx);
|
||||
|
||||
ctx->comparisonResult = compare_012(value1, value2);
|
||||
ctx->comparisonResult = Compare(value1, value2);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -421,7 +419,7 @@ bool8 ScrCmd_compare_addr_to_local(struct ScriptContext *ctx)
|
||||
const u8 value1 = *(const u8 *)ScriptReadWord(ctx);
|
||||
const u8 value2 = ctx->data[ScriptReadByte(ctx)];
|
||||
|
||||
ctx->comparisonResult = compare_012(value1, value2);
|
||||
ctx->comparisonResult = Compare(value1, value2);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -430,7 +428,7 @@ bool8 ScrCmd_compare_addr_to_value(struct ScriptContext *ctx)
|
||||
const u8 value1 = *(const u8 *)ScriptReadWord(ctx);
|
||||
const u8 value2 = ScriptReadByte(ctx);
|
||||
|
||||
ctx->comparisonResult = compare_012(value1, value2);
|
||||
ctx->comparisonResult = Compare(value1, value2);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -439,7 +437,7 @@ bool8 ScrCmd_compare_addr_to_addr(struct ScriptContext *ctx)
|
||||
const u8 value1 = *(const u8 *)ScriptReadWord(ctx);
|
||||
const u8 value2 = *(const u8 *)ScriptReadWord(ctx);
|
||||
|
||||
ctx->comparisonResult = compare_012(value1, value2);
|
||||
ctx->comparisonResult = Compare(value1, value2);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -448,7 +446,7 @@ bool8 ScrCmd_compare_var_to_value(struct ScriptContext *ctx)
|
||||
const u16 value1 = *GetVarPointer(ScriptReadHalfword(ctx));
|
||||
const u16 value2 = ScriptReadHalfword(ctx);
|
||||
|
||||
ctx->comparisonResult = compare_012(value1, value2);
|
||||
ctx->comparisonResult = Compare(value1, value2);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -457,7 +455,7 @@ bool8 ScrCmd_compare_var_to_var(struct ScriptContext *ctx)
|
||||
const u16 *ptr1 = GetVarPointer(ScriptReadHalfword(ctx));
|
||||
const u16 *ptr2 = GetVarPointer(ScriptReadHalfword(ctx));
|
||||
|
||||
ctx->comparisonResult = compare_012(*ptr1, *ptr2);
|
||||
ctx->comparisonResult = Compare(*ptr1, *ptr2);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -1120,7 +1118,7 @@ bool8 ScrCmd_showobject_at(struct ScriptContext *ctx)
|
||||
u8 mapGroup = ScriptReadByte(ctx);
|
||||
u8 mapNum = ScriptReadByte(ctx);
|
||||
|
||||
npc_by_local_id_and_map_set_field_1_bit_x20(localId, mapNum, mapGroup, 0);
|
||||
SetObjectInvisibility(localId, mapNum, mapGroup, FALSE);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -1130,7 +1128,7 @@ bool8 ScrCmd_hideobject_at(struct ScriptContext *ctx)
|
||||
u8 mapGroup = ScriptReadByte(ctx);
|
||||
u8 mapNum = ScriptReadByte(ctx);
|
||||
|
||||
npc_by_local_id_and_map_set_field_1_bit_x20(localId, mapNum, mapGroup, 1);
|
||||
SetObjectInvisibility(localId, mapNum, mapGroup, TRUE);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -1141,7 +1139,7 @@ bool8 ScrCmd_setobjectpriority(struct ScriptContext *ctx)
|
||||
u8 mapNum = ScriptReadByte(ctx);
|
||||
u8 priority = ScriptReadByte(ctx);
|
||||
|
||||
sub_808E78C(localId, mapNum, mapGroup, priority + 83);
|
||||
SetObjectPriority(localId, mapNum, mapGroup, priority + 83);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -1151,7 +1149,7 @@ bool8 ScrCmd_resetobjectpriority(struct ScriptContext *ctx)
|
||||
u8 mapGroup = ScriptReadByte(ctx);
|
||||
u8 mapNum = ScriptReadByte(ctx);
|
||||
|
||||
sub_808E7E4(localId, mapNum, mapGroup);
|
||||
ResetObjectPriority(localId, mapNum, mapGroup);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -1214,7 +1212,7 @@ bool8 ScrCmd_lockall(struct ScriptContext *ctx)
|
||||
else
|
||||
{
|
||||
ScriptFreezeObjectEvents();
|
||||
SetupNativeScript(ctx, sub_80983C4);
|
||||
SetupNativeScript(ctx, IsFreezePlayerFinished);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
@ -1230,12 +1228,12 @@ bool8 ScrCmd_lock(struct ScriptContext *ctx)
|
||||
if (gObjectEvents[gSelectedObjectEvent].active)
|
||||
{
|
||||
LockSelectedObjectEvent();
|
||||
SetupNativeScript(ctx, sub_809847C);
|
||||
SetupNativeScript(ctx, IsFreezeSelectedObjectAndPlayerFinished);
|
||||
}
|
||||
else
|
||||
{
|
||||
ScriptFreezeObjectEvents();
|
||||
SetupNativeScript(ctx, sub_80983C4);
|
||||
SetupNativeScript(ctx, IsFreezePlayerFinished);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
@ -1299,7 +1297,8 @@ bool8 ScrCmd_messageautoscroll(struct ScriptContext *ctx)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 ScrCmd_cmdDB(struct ScriptContext *ctx)
|
||||
// Prints all at once. Skips waiting for player input. Only used by link contests
|
||||
bool8 ScrCmd_messageinstant(struct ScriptContext *ctx)
|
||||
{
|
||||
const u8 *msg = (const u8 *)ScriptReadWord(ctx);
|
||||
|
||||
@ -1489,27 +1488,30 @@ bool8 ScrCmd_braillemessage(struct ScriptContext *ctx)
|
||||
u8 xWindow, yWindow, xText, yText;
|
||||
u8 temp;
|
||||
|
||||
// + 6 for the 6 bytes at the start of a braille message (brailleformat macro)
|
||||
// In RS these bytes are used to position the text and window, but
|
||||
// in Emerald they are unused and position is calculated below instead
|
||||
StringExpandPlaceholders(gStringVar4, ptr + 6);
|
||||
|
||||
width = GetStringWidth(6, gStringVar4, -1) / 8u;
|
||||
|
||||
if (width > 0x1C)
|
||||
width = 0x1C;
|
||||
if (width > 28)
|
||||
width = 28;
|
||||
|
||||
for (i = 0, height = 4; gStringVar4[i] != 0xFF;)
|
||||
for (i = 0, height = 4; gStringVar4[i] != EOS;)
|
||||
{
|
||||
if (gStringVar4[i++] == 0xFE)
|
||||
if (gStringVar4[i++] == CHAR_NEWLINE)
|
||||
height += 3;
|
||||
}
|
||||
|
||||
if (height > 0x12)
|
||||
height = 0x12;
|
||||
if (height > 18)
|
||||
height = 18;
|
||||
|
||||
temp = width + 2;
|
||||
xWindow = (0x1E - temp) / 2;
|
||||
xWindow = (30 - temp) / 2;
|
||||
|
||||
temp = height + 2;
|
||||
yText = (0x14 - temp) / 2;
|
||||
yText = (20 - temp) / 2;
|
||||
|
||||
xText = xWindow;
|
||||
xWindow += 1;
|
||||
@ -1539,9 +1541,9 @@ bool8 ScrCmd_closebraillemessage(struct ScriptContext *ctx)
|
||||
|
||||
bool8 ScrCmd_vmessage(struct ScriptContext *ctx)
|
||||
{
|
||||
u32 v1 = ScriptReadWord(ctx);
|
||||
u32 msg = ScriptReadWord(ctx);
|
||||
|
||||
ShowFieldMessage((u8 *)(v1 - gUnknown_020375C4));
|
||||
ShowFieldMessage((u8 *)(msg - sAddressOffset));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -1651,7 +1653,7 @@ bool8 ScrCmd_bufferstring(struct ScriptContext *ctx)
|
||||
|
||||
bool8 ScrCmd_vloadword(struct ScriptContext *ctx)
|
||||
{
|
||||
const u8 *ptr = (u8 *)(ScriptReadWord(ctx) - gUnknown_020375C4);
|
||||
const u8 *ptr = (u8 *)(ScriptReadWord(ctx) - sAddressOffset);
|
||||
|
||||
StringExpandPlaceholders(gStringVar4, ptr);
|
||||
return FALSE;
|
||||
@ -1662,7 +1664,7 @@ bool8 ScrCmd_vbufferstring(struct ScriptContext *ctx)
|
||||
u8 stringVarIndex = ScriptReadByte(ctx);
|
||||
u32 addr = ScriptReadWord(ctx);
|
||||
|
||||
const u8 *src = (u8 *)(addr - gUnknown_020375C4);
|
||||
const u8 *src = (u8 *)(addr - sAddressOffset);
|
||||
u8 *dest = sScriptStringVars[stringVarIndex];
|
||||
StringCopy(dest, src);
|
||||
return FALSE;
|
||||
@ -1900,6 +1902,7 @@ bool8 ScrCmd_pokemartdecoration(struct ScriptContext *ctx)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Changes clerk dialogue slightly from above. See MART_TYPE_DECOR2
|
||||
bool8 ScrCmd_pokemartdecoration2(struct ScriptContext *ctx)
|
||||
{
|
||||
const void *ptr = (void *)ScriptReadWord(ctx);
|
||||
@ -2104,6 +2107,7 @@ bool8 ScrCmd_setdoorclosed(struct ScriptContext *ctx)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Below two are functions for elevators in RS, do nothing in Emerald
|
||||
bool8 ScrCmd_addelevmenuitem(struct ScriptContext *ctx)
|
||||
{
|
||||
u8 v3 = ScriptReadByte(ctx);
|
||||
@ -2135,9 +2139,9 @@ bool8 ScrCmd_addcoins(struct ScriptContext *ctx)
|
||||
u16 coins = VarGet(ScriptReadHalfword(ctx));
|
||||
|
||||
if (AddCoins(coins) == TRUE)
|
||||
gSpecialVar_Result = 0;
|
||||
gSpecialVar_Result = FALSE;
|
||||
else
|
||||
gSpecialVar_Result = 1;
|
||||
gSpecialVar_Result = TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -2146,9 +2150,9 @@ bool8 ScrCmd_removecoins(struct ScriptContext *ctx)
|
||||
u16 coins = VarGet(ScriptReadHalfword(ctx));
|
||||
|
||||
if (RemoveCoins(coins) == TRUE)
|
||||
gSpecialVar_Result = 0;
|
||||
gSpecialVar_Result = FALSE;
|
||||
else
|
||||
gSpecialVar_Result = 1;
|
||||
gSpecialVar_Result = TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -2180,13 +2184,13 @@ bool8 ScrCmd_freerotatingtilepuzzle(struct ScriptContext *ctx)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 ScrCmd_cmdD8(struct ScriptContext *ctx)
|
||||
bool8 ScrCmd_selectapproachingtrainer(struct ScriptContext *ctx)
|
||||
{
|
||||
gSelectedObjectEvent = GetCurrentApproachingTrainerObjectEventId();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 ScrCmd_cmdD9(struct ScriptContext *ctx)
|
||||
bool8 ScrCmd_lockfortrainer(struct ScriptContext *ctx)
|
||||
{
|
||||
if (IsUpdateLinkStateCBActive())
|
||||
{
|
||||
@ -2196,8 +2200,8 @@ bool8 ScrCmd_cmdD9(struct ScriptContext *ctx)
|
||||
{
|
||||
if (gObjectEvents[gSelectedObjectEvent].active)
|
||||
{
|
||||
sub_8098630();
|
||||
SetupNativeScript(ctx, sub_8098734);
|
||||
FreezeForApproachingTrainers();
|
||||
SetupNativeScript(ctx, IsFreezeObjectAndPlayerFinished);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
@ -2225,12 +2229,12 @@ bool8 ScrCmd_checkmonobedience(struct ScriptContext *ctx)
|
||||
// See GetSavedRamScriptIfValid, which is NULL if ValidateReceivedWonderCard returns FALSE
|
||||
bool8 ScrCmd_gotoram(struct ScriptContext *ctx)
|
||||
{
|
||||
const u8* v1 = GetSavedRamScriptIfValid();
|
||||
const u8* script = GetSavedRamScriptIfValid();
|
||||
|
||||
if (v1)
|
||||
if (script)
|
||||
{
|
||||
gUnknown_020375C0 = ctx->scriptPtr;
|
||||
ScriptJump(ctx, v1);
|
||||
gRamScriptRetAddr = ctx->scriptPtr;
|
||||
ScriptJump(ctx, script);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
#define RAM_SCRIPT_MAGIC 51
|
||||
|
||||
extern const u8* gUnknown_020375C0;
|
||||
extern const u8* gRamScriptRetAddr;
|
||||
|
||||
// ewram bss
|
||||
static u8 sScriptContext1Status;
|
||||
@ -363,7 +363,7 @@ bool8 InitRamScript(const u8 *script, u16 scriptSize, u8 mapGroup, u8 mapNum, u8
|
||||
const u8 *GetRamScript(u8 objectId, const u8 *script)
|
||||
{
|
||||
struct RamScriptData *scriptData = &gSaveBlock1Ptr->ramScript.data;
|
||||
gUnknown_020375C0 = NULL;
|
||||
gRamScriptRetAddr = NULL;
|
||||
if (scriptData->magic != RAM_SCRIPT_MAGIC)
|
||||
return script;
|
||||
if (scriptData->mapGroup != gSaveBlock1Ptr->location.mapGroup)
|
||||
@ -379,7 +379,7 @@ const u8 *GetRamScript(u8 objectId, const u8 *script)
|
||||
}
|
||||
else
|
||||
{
|
||||
gUnknown_020375C0 = script;
|
||||
gRamScriptRetAddr = script;
|
||||
return scriptData->script;
|
||||
}
|
||||
}
|
||||
|
@ -965,8 +965,9 @@ static void Task_BuyMenu(u8 taskId)
|
||||
|
||||
if (gMartInfo.martType == MART_TYPE_DECOR)
|
||||
StringExpandPlaceholders(gStringVar4, gText_Var1IsItThatllBeVar2);
|
||||
else
|
||||
else // MART_TYPE_DECOR2
|
||||
StringExpandPlaceholders(gStringVar4, gText_YouWantedVar1ThatllBeVar2);
|
||||
|
||||
BuyMenuDisplayMessage(taskId, gStringVar4, BuyMenuConfirmPurchase);
|
||||
}
|
||||
}
|
||||
@ -1069,13 +1070,9 @@ static void BuyMenuTryMakePurchase(u8 taskId)
|
||||
if (DecorationAdd(tItemId))
|
||||
{
|
||||
if (gMartInfo.martType == MART_TYPE_DECOR)
|
||||
{
|
||||
BuyMenuDisplayMessage(taskId, gText_ThankYouIllSendItHome, BuyMenuSubtractMoney);
|
||||
}
|
||||
else
|
||||
{
|
||||
else // MART_TYPE_DECOR2
|
||||
BuyMenuDisplayMessage(taskId, gText_ThanksIllSendItHome, BuyMenuSubtractMoney);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -541,7 +541,7 @@ void ShowStartMenu(void)
|
||||
if (!IsUpdateLinkStateCBActive())
|
||||
{
|
||||
FreezeObjectEvents();
|
||||
sub_808B864();
|
||||
PlayerFreeze();
|
||||
sub_808BCF4();
|
||||
}
|
||||
CreateStartMenuTask(Task_ShowStartMenu);
|
||||
|
@ -23,9 +23,9 @@
|
||||
static u8 CheckTrainer(u8 objectEventId);
|
||||
static u8 GetTrainerApproachDistance(struct ObjectEvent *trainerObj);
|
||||
static u8 CheckPathBetweenTrainerAndPlayer(struct ObjectEvent *trainerObj, u8 approachDistance, u8 direction);
|
||||
static void TrainerApproachPlayer(struct ObjectEvent *trainerObj, u8 range);
|
||||
static void InitTrainerApproachTask(struct ObjectEvent *trainerObj, u8 range);
|
||||
static void Task_RunTrainerSeeFuncList(u8 taskId);
|
||||
static void Task_DestroyTrainerApproachTask(u8 taskId);
|
||||
static void Task_EndTrainerApproach(u8 taskId);
|
||||
static void SetIconSpriteData(struct Sprite *sprite, u16 fldEffId, u8 spriteAnimNum);
|
||||
|
||||
static u8 GetTrainerApproachDistanceSouth(struct ObjectEvent *trainerObj, s16 range, s16 x, s16 y);
|
||||
@ -33,7 +33,7 @@ static u8 GetTrainerApproachDistanceNorth(struct ObjectEvent *trainerObj, s16 ra
|
||||
static u8 GetTrainerApproachDistanceWest(struct ObjectEvent *trainerObj, s16 range, s16 x, s16 y);
|
||||
static u8 GetTrainerApproachDistanceEast(struct ObjectEvent *trainerObj, s16 range, s16 x, s16 y);
|
||||
|
||||
static bool8 sub_80B4178(u8 taskId, struct Task *task, struct ObjectEvent *trainerObj);
|
||||
static bool8 TrainerSeeIdle(u8 taskId, struct Task *task, struct ObjectEvent *trainerObj);
|
||||
static bool8 TrainerExclamationMark(u8 taskId, struct Task *task, struct ObjectEvent *trainerObj);
|
||||
static bool8 WaitTrainerExclamationMark(u8 taskId, struct Task *task, struct ObjectEvent *trainerObj);
|
||||
static bool8 TrainerMoveToPlayer(u8 taskId, struct Task *task, struct ObjectEvent *trainerObj);
|
||||
@ -71,20 +71,35 @@ static u8 (*const sDirectionalApproachDistanceFuncs[])(struct ObjectEvent *train
|
||||
GetTrainerApproachDistanceEast,
|
||||
};
|
||||
|
||||
enum {
|
||||
TRSEE_NONE,
|
||||
TRSEE_EXCLAMATION,
|
||||
TRSEE_EXCLAMATION_WAIT,
|
||||
TRSEE_MOVE_TO_PLAYER,
|
||||
TRSEE_PLAYER_FACE,
|
||||
TRSEE_PLAYER_FACE_WAIT,
|
||||
TRSEE_REVEAL_DISGUISE,
|
||||
TRSEE_REVEAL_DISGUISE_WAIT,
|
||||
TRSEE_REVEAL_HIDDEN,
|
||||
TRSEE_HIDDEN_POP_OUT,
|
||||
TRSEE_HIDDEN_JUMP,
|
||||
TRSEE_REVEAL_HIDDEN_WAIT,
|
||||
};
|
||||
|
||||
static bool8 (*const sTrainerSeeFuncList[])(u8 taskId, struct Task *task, struct ObjectEvent *trainerObj) =
|
||||
{
|
||||
sub_80B4178,
|
||||
TrainerExclamationMark,
|
||||
WaitTrainerExclamationMark,
|
||||
TrainerMoveToPlayer,
|
||||
PlayerFaceApproachingTrainer,
|
||||
WaitPlayerFaceApproachingTrainer,
|
||||
RevealDisguisedTrainer,
|
||||
WaitRevealDisguisedTrainer,
|
||||
RevealHiddenTrainer,
|
||||
PopOutOfAshHiddenTrainer,
|
||||
JumpInPlaceHiddenTrainer,
|
||||
WaitRevealHiddenTrainer,
|
||||
[TRSEE_NONE] = TrainerSeeIdle,
|
||||
[TRSEE_EXCLAMATION] = TrainerExclamationMark,
|
||||
[TRSEE_EXCLAMATION_WAIT] = WaitTrainerExclamationMark,
|
||||
[TRSEE_MOVE_TO_PLAYER] = TrainerMoveToPlayer,
|
||||
[TRSEE_PLAYER_FACE] = PlayerFaceApproachingTrainer,
|
||||
[TRSEE_PLAYER_FACE_WAIT] = WaitPlayerFaceApproachingTrainer,
|
||||
[TRSEE_REVEAL_DISGUISE] = RevealDisguisedTrainer,
|
||||
[TRSEE_REVEAL_DISGUISE_WAIT] = WaitRevealDisguisedTrainer,
|
||||
[TRSEE_REVEAL_HIDDEN] = RevealHiddenTrainer,
|
||||
[TRSEE_HIDDEN_POP_OUT] = PopOutOfAshHiddenTrainer,
|
||||
[TRSEE_HIDDEN_JUMP] = JumpInPlaceHiddenTrainer,
|
||||
[TRSEE_REVEAL_HIDDEN_WAIT] = WaitRevealHiddenTrainer,
|
||||
};
|
||||
|
||||
static bool8 (*const sTrainerSeeFuncList2[])(u8 taskId, struct Task *task, struct ObjectEvent *trainerObj) =
|
||||
@ -233,7 +248,7 @@ bool8 CheckForTrainersWantingBattle(void)
|
||||
static u8 CheckTrainer(u8 objectEventId)
|
||||
{
|
||||
const u8 *scriptPtr;
|
||||
u8 ret = 1;
|
||||
u8 numTrainers = 1;
|
||||
u8 approachDistance;
|
||||
|
||||
if (InTrainerHill() == TRUE)
|
||||
@ -268,16 +283,16 @@ static u8 CheckTrainer(u8 objectEventId)
|
||||
if (GetMonsStateToDoubles_2() != 0)
|
||||
return 0;
|
||||
|
||||
ret = 2;
|
||||
numTrainers = 2;
|
||||
}
|
||||
|
||||
gApproachingTrainers[gNoOfApproachingTrainers].objectEventId = objectEventId;
|
||||
gApproachingTrainers[gNoOfApproachingTrainers].trainerScriptPtr = scriptPtr;
|
||||
gApproachingTrainers[gNoOfApproachingTrainers].radius = approachDistance;
|
||||
TrainerApproachPlayer(&gObjectEvents[objectEventId], approachDistance - 1);
|
||||
InitTrainerApproachTask(&gObjectEvents[objectEventId], approachDistance - 1);
|
||||
gNoOfApproachingTrainers++;
|
||||
|
||||
return ret;
|
||||
return numTrainers;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -357,8 +372,7 @@ static u8 GetTrainerApproachDistanceEast(struct ObjectEvent *trainerObj, s16 ran
|
||||
static u8 CheckPathBetweenTrainerAndPlayer(struct ObjectEvent *trainerObj, u8 approachDistance, u8 direction)
|
||||
{
|
||||
s16 x, y;
|
||||
u8 unk19_temp;
|
||||
u8 unk19b_temp;
|
||||
u8 rangeX, rangeY;
|
||||
u8 i;
|
||||
u8 collision;
|
||||
|
||||
@ -376,17 +390,16 @@ static u8 CheckPathBetweenTrainerAndPlayer(struct ObjectEvent *trainerObj, u8 ap
|
||||
return 0;
|
||||
}
|
||||
|
||||
// preserve mapobj_unk_19 before clearing.
|
||||
unk19_temp = trainerObj->rangeX;
|
||||
unk19b_temp = trainerObj->rangeY;
|
||||
rangeX = trainerObj->rangeX;
|
||||
rangeY = trainerObj->rangeY;
|
||||
trainerObj->rangeX = 0;
|
||||
trainerObj->rangeY = 0;
|
||||
|
||||
collision = GetCollisionAtCoords(trainerObj, x, y, direction);
|
||||
|
||||
trainerObj->rangeX = unk19_temp;
|
||||
trainerObj->rangeY = unk19b_temp;
|
||||
if (collision == 4)
|
||||
trainerObj->rangeX = rangeX;
|
||||
trainerObj->rangeY = rangeY;
|
||||
if (collision == COLLISION_OBJECT_EVENT)
|
||||
return approachDistance;
|
||||
|
||||
return 0;
|
||||
@ -397,7 +410,7 @@ static u8 CheckPathBetweenTrainerAndPlayer(struct ObjectEvent *trainerObj, u8 ap
|
||||
#define tOutOfAshSpriteId data[4]
|
||||
#define tTrainerObjectEventId data[7]
|
||||
|
||||
static void TrainerApproachPlayer(struct ObjectEvent *trainerObj, u8 range)
|
||||
static void InitTrainerApproachTask(struct ObjectEvent *trainerObj, u8 range)
|
||||
{
|
||||
struct Task *task;
|
||||
|
||||
@ -407,7 +420,7 @@ static void TrainerApproachPlayer(struct ObjectEvent *trainerObj, u8 range)
|
||||
task->tTrainerObjectEventId = gApproachingTrainers[gNoOfApproachingTrainers].objectEventId;
|
||||
}
|
||||
|
||||
static void sub_80B40C8(TaskFunc followupFunc)
|
||||
static void StartTrainerApproach(TaskFunc followupFunc)
|
||||
{
|
||||
u8 taskId;
|
||||
TaskFunc taskFunc;
|
||||
@ -419,7 +432,7 @@ static void sub_80B40C8(TaskFunc followupFunc)
|
||||
|
||||
taskFunc = Task_RunTrainerSeeFuncList;
|
||||
SetTaskFuncWithFollowupFunc(taskId, taskFunc, followupFunc);
|
||||
gTasks[taskId].tFuncId = 1;
|
||||
gTasks[taskId].tFuncId = TRSEE_EXCLAMATION;
|
||||
taskFunc(taskId);
|
||||
}
|
||||
|
||||
@ -438,11 +451,12 @@ static void Task_RunTrainerSeeFuncList(u8 taskId)
|
||||
}
|
||||
}
|
||||
|
||||
static bool8 sub_80B4178(u8 taskId, struct Task *task, struct ObjectEvent *trainerObj)
|
||||
static bool8 TrainerSeeIdle(u8 taskId, struct Task *task, struct ObjectEvent *trainerObj)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// TRSEE_EXCLAMATION
|
||||
static bool8 TrainerExclamationMark(u8 taskId, struct Task *task, struct ObjectEvent *trainerObj)
|
||||
{
|
||||
u8 direction;
|
||||
@ -451,10 +465,11 @@ static bool8 TrainerExclamationMark(u8 taskId, struct Task *task, struct ObjectE
|
||||
FieldEffectStart(FLDEFF_EXCLAMATION_MARK_ICON);
|
||||
direction = GetFaceDirectionMovementAction(trainerObj->facingDirection);
|
||||
ObjectEventSetHeldMovement(trainerObj, direction);
|
||||
task->tFuncId++;
|
||||
task->tFuncId++; // TRSEE_EXCLAMATION_WAIT
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// TRSEE_EXCLAMATION_WAIT
|
||||
static bool8 WaitTrainerExclamationMark(u8 taskId, struct Task *task, struct ObjectEvent *trainerObj)
|
||||
{
|
||||
if (FieldEffectActiveListContains(FLDEFF_EXCLAMATION_MARK_ICON))
|
||||
@ -463,15 +478,16 @@ static bool8 WaitTrainerExclamationMark(u8 taskId, struct Task *task, struct Obj
|
||||
}
|
||||
else
|
||||
{
|
||||
task->tFuncId++;
|
||||
task->tFuncId++; // TRSEE_MOVE_TO_PLAYER
|
||||
if (trainerObj->movementType == MOVEMENT_TYPE_TREE_DISGUISE || trainerObj->movementType == MOVEMENT_TYPE_MOUNTAIN_DISGUISE)
|
||||
task->tFuncId = 6;
|
||||
task->tFuncId = TRSEE_REVEAL_DISGUISE;
|
||||
if (trainerObj->movementType == MOVEMENT_TYPE_HIDDEN)
|
||||
task->tFuncId = 8;
|
||||
task->tFuncId = TRSEE_REVEAL_HIDDEN;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
// TRSEE_MOVE_TO_PLAYER
|
||||
static bool8 TrainerMoveToPlayer(u8 taskId, struct Task *task, struct ObjectEvent *trainerObj)
|
||||
{
|
||||
if (!ObjectEventIsMovementOverridden(trainerObj) || ObjectEventClearHeldMovementIfFinished(trainerObj))
|
||||
@ -484,12 +500,13 @@ static bool8 TrainerMoveToPlayer(u8 taskId, struct Task *task, struct ObjectEven
|
||||
else
|
||||
{
|
||||
ObjectEventSetHeldMovement(trainerObj, MOVEMENT_ACTION_FACE_PLAYER);
|
||||
task->tFuncId++;
|
||||
task->tFuncId++; // TRSEE_PLAYER_FACE
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// TRSEE_PLAYER_FACE
|
||||
static bool8 PlayerFaceApproachingTrainer(u8 taskId, struct Task *task, struct ObjectEvent *trainerObj)
|
||||
{
|
||||
struct ObjectEvent *playerObj;
|
||||
@ -497,6 +514,7 @@ static bool8 PlayerFaceApproachingTrainer(u8 taskId, struct Task *task, struct O
|
||||
if (ObjectEventIsMovementOverridden(trainerObj) && !ObjectEventClearHeldMovementIfFinished(trainerObj))
|
||||
return FALSE;
|
||||
|
||||
// Set trainer's movement type so they stop and remain facing that direction
|
||||
SetTrainerMovementType(trainerObj, GetTrainerFacingDirectionMovementType(trainerObj->facingDirection));
|
||||
TryOverrideTemplateCoordsForObjectEvent(trainerObj, GetTrainerFacingDirectionMovementType(trainerObj->facingDirection));
|
||||
OverrideTemplateCoordsForObjectEvent(trainerObj);
|
||||
@ -507,10 +525,11 @@ static bool8 PlayerFaceApproachingTrainer(u8 taskId, struct Task *task, struct O
|
||||
|
||||
sub_808BCE8();
|
||||
ObjectEventSetHeldMovement(&gObjectEvents[gPlayerAvatar.objectEventId], GetFaceDirectionMovementAction(GetOppositeDirection(trainerObj->facingDirection)));
|
||||
task->tFuncId++;
|
||||
task->tFuncId++; // TRSEE_PLAYER_FACE_WAIT
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// TRSEE_PLAYER_FACE_WAIT
|
||||
static bool8 WaitPlayerFaceApproachingTrainer(u8 taskId, struct Task *task, struct ObjectEvent *trainerObj)
|
||||
{
|
||||
struct ObjectEvent *playerObj = &gObjectEvents[gPlayerAvatar.objectEventId];
|
||||
@ -521,25 +540,28 @@ static bool8 WaitPlayerFaceApproachingTrainer(u8 taskId, struct Task *task, stru
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// TRSEE_REVEAL_DISGUISE
|
||||
static bool8 RevealDisguisedTrainer(u8 taskId, struct Task *task, struct ObjectEvent *trainerObj)
|
||||
{
|
||||
if (!ObjectEventIsMovementOverridden(trainerObj)
|
||||
|| ObjectEventClearHeldMovementIfFinished(trainerObj))
|
||||
{
|
||||
ObjectEventSetHeldMovement(trainerObj, MOVEMENT_ACTION_REVEAL_TRAINER);
|
||||
task->tFuncId++;
|
||||
task->tFuncId++; // TRSEE_REVEAL_DISGUISE_WAIT
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// TRSEE_REVEAL_DISGUISE_WAIT
|
||||
static bool8 WaitRevealDisguisedTrainer(u8 taskId, struct Task *task, struct ObjectEvent *trainerObj)
|
||||
{
|
||||
if (ObjectEventClearHeldMovementIfFinished(trainerObj))
|
||||
task->tFuncId = 3;
|
||||
task->tFuncId = TRSEE_MOVE_TO_PLAYER;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// TRSEE_REVEAL_HIDDEN
|
||||
static bool8 RevealHiddenTrainer(u8 taskId, struct Task *task, struct ObjectEvent *trainerObj)
|
||||
{
|
||||
if (!ObjectEventIsMovementOverridden(trainerObj)
|
||||
@ -551,6 +573,7 @@ static bool8 RevealHiddenTrainer(u8 taskId, struct Task *task, struct ObjectEven
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// TRSEE_HIDDEN_POP_OUT
|
||||
static bool8 PopOutOfAshHiddenTrainer(u8 taskId, struct Task *task, struct ObjectEvent *trainerObj)
|
||||
{
|
||||
if (ObjectEventCheckHeldMovementStatus(trainerObj))
|
||||
@ -565,6 +588,7 @@ static bool8 PopOutOfAshHiddenTrainer(u8 taskId, struct Task *task, struct Objec
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// TRSEE_HIDDEN_JUMP
|
||||
static bool8 JumpInPlaceHiddenTrainer(u8 taskId, struct Task *task, struct ObjectEvent *trainerObj)
|
||||
{
|
||||
struct Sprite *sprite;
|
||||
@ -584,33 +608,34 @@ static bool8 JumpInPlaceHiddenTrainer(u8 taskId, struct Task *task, struct Objec
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// TRSEE_REVEAL_HIDDEN_WAIT
|
||||
static bool8 WaitRevealHiddenTrainer(u8 taskId, struct Task *task, struct ObjectEvent *trainerObj)
|
||||
{
|
||||
if (!FieldEffectActiveListContains(FLDEFF_ASH_PUFF))
|
||||
task->tFuncId = 3;
|
||||
task->tFuncId = TRSEE_MOVE_TO_PLAYER;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#undef tFuncId
|
||||
#undef tTrainerRange
|
||||
#undef tOutOfAshSpriteId
|
||||
#undef tTrainerObjectEventId
|
||||
|
||||
static void sub_80B44C8(u8 taskId)
|
||||
#define tObjEvent data[1]
|
||||
|
||||
static void Task_SetHiddenTrainerMovement(u8 taskId)
|
||||
{
|
||||
struct Task *task = &gTasks[taskId];
|
||||
struct ObjectEvent *objEvent;
|
||||
|
||||
// another objEvent loaded into by loadword?
|
||||
LoadWordFromTwoHalfwords(&task->data[1], (u32 *)&objEvent);
|
||||
LoadWordFromTwoHalfwords(&task->tObjEvent, (u32 *)&objEvent);
|
||||
if (!task->data[7])
|
||||
{
|
||||
ObjectEventClearHeldMovement(objEvent);
|
||||
task->data[7]++;
|
||||
}
|
||||
sTrainerSeeFuncList2[task->data[0]](taskId, task, objEvent);
|
||||
if (task->data[0] == 3 && !FieldEffectActiveListContains(FLDEFF_ASH_PUFF))
|
||||
sTrainerSeeFuncList2[task->tFuncId](taskId, task, objEvent);
|
||||
if (task->tFuncId == ((int)ARRAY_COUNT(sTrainerSeeFuncList2) - 1) && !FieldEffectActiveListContains(FLDEFF_ASH_PUFF))
|
||||
{
|
||||
SetTrainerMovementType(objEvent, GetTrainerFacingDirectionMovementType(objEvent->facingDirection));
|
||||
TryOverrideTemplateCoordsForObjectEvent(objEvent, GetTrainerFacingDirectionMovementType(objEvent->facingDirection));
|
||||
@ -622,17 +647,18 @@ static void sub_80B44C8(u8 taskId)
|
||||
}
|
||||
}
|
||||
|
||||
void sub_80B4578(struct ObjectEvent *var)
|
||||
// Called when a "buried" trainer has the reveal_trainer movement applied, from direct interaction
|
||||
void SetHiddenTrainerMovement(struct ObjectEvent *objEvent)
|
||||
{
|
||||
StoreWordInTwoHalfwords(&gTasks[CreateTask(sub_80B44C8, 0)].data[1], (u32)var);
|
||||
StoreWordInTwoHalfwords(&gTasks[CreateTask(Task_SetHiddenTrainerMovement, 0)].tObjEvent, (u32)objEvent);
|
||||
}
|
||||
|
||||
void EndTrainerApproach(void)
|
||||
void DoTrainerApproach(void)
|
||||
{
|
||||
sub_80B40C8(Task_DestroyTrainerApproachTask);
|
||||
StartTrainerApproach(Task_EndTrainerApproach);
|
||||
}
|
||||
|
||||
static void Task_DestroyTrainerApproachTask(u8 taskId)
|
||||
static void Task_EndTrainerApproach(u8 taskId)
|
||||
{
|
||||
DestroyTask(taskId);
|
||||
EnableBothScriptContexts();
|
||||
|
Loading…
Reference in New Issue
Block a user