through GetInteractedObjectEventScript
This commit is contained in:
+24
-1094
File diff suppressed because it is too large
Load Diff
+6
-6
@@ -3259,7 +3259,7 @@ sub_805644C: @ 805644C
|
||||
bl sub_805BEB8
|
||||
mov r6, sp
|
||||
mov r0, sp
|
||||
bl sub_806C888
|
||||
bl FieldClearPlayerInput
|
||||
mov r0, sp
|
||||
adds r1, r5, 0
|
||||
adds r2, r4, 0
|
||||
@@ -3271,7 +3271,7 @@ sub_805644C: @ 805644C
|
||||
cmp r0, 0
|
||||
bne _080564BA
|
||||
mov r0, sp
|
||||
bl sub_806CAC8
|
||||
bl ProcessPlayerFieldInput
|
||||
cmp r0, 0x1
|
||||
bne _080564B0
|
||||
ldr r0, _080564A8 @ =gUnknown_3005E88
|
||||
@@ -3308,7 +3308,7 @@ sub_80564C8: @ 80564C8
|
||||
bl sub_805BEB8
|
||||
bl sub_8111C68
|
||||
mov r0, sp
|
||||
bl sub_806C888
|
||||
bl FieldClearPlayerInput
|
||||
ldr r0, _08056508 @ =gUnknown_3005E90
|
||||
ldr r0, [r0]
|
||||
str r0, [sp]
|
||||
@@ -3319,7 +3319,7 @@ sub_80564C8: @ 80564C8
|
||||
cmp r0, 0
|
||||
bne _08056512
|
||||
mov r0, sp
|
||||
bl sub_806CAC8
|
||||
bl ProcessPlayerFieldInput
|
||||
cmp r0, 0x1
|
||||
bne _0805650C
|
||||
bl ScriptContext2_Enable
|
||||
@@ -3339,7 +3339,7 @@ _08056512:
|
||||
bl RunQuestLogCB
|
||||
_08056522:
|
||||
ldr r0, _08056530 @ =gUnknown_3005E90
|
||||
bl sub_806C888
|
||||
bl FieldClearPlayerInput
|
||||
add sp, 0x4
|
||||
pop {r0}
|
||||
bx r0
|
||||
@@ -6825,7 +6825,7 @@ _08058118:
|
||||
ldrb r1, [r4, 0xC]
|
||||
ldrb r2, [r4, 0x3]
|
||||
mov r0, sp
|
||||
bl sub_806CF38
|
||||
bl GetInteractedLinkPlayerScript
|
||||
_08058122:
|
||||
add sp, 0x8
|
||||
pop {r4}
|
||||
|
||||
@@ -18,7 +18,7 @@ PalletTown_OnTransition:: @ 8165465
|
||||
end
|
||||
|
||||
PalletTown_EventScript_TryReadySignLady:: @ 8165488
|
||||
goto_if_unset FLAG_PALLET_TOWN_LADY_MOVED_FROM_SIGN, EventScript_Return
|
||||
goto_if_unset FLAG_OPENED_START_MENU, EventScript_Return
|
||||
compare VAR_MAP_SCENE_PALLET_TOWN_SIGN_LADY, 1
|
||||
goto_if_ge EventScript_Return
|
||||
setvar VAR_MAP_SCENE_PALLET_TOWN_SIGN_LADY, 1
|
||||
@@ -447,7 +447,7 @@ PalletTown_EventScript_SignLadyShowSign:: @ 8165894
|
||||
closemessage
|
||||
delay 20
|
||||
textcolor 3
|
||||
setflag FLAG_PALLET_TOWN_LADY_MOVED_FROM_SIGN
|
||||
setflag FLAG_OPENED_START_MENU
|
||||
setvar VAR_MAP_SCENE_PALLET_TOWN_SIGN_LADY, 1
|
||||
setvar SIGN_LADY_READY, FALSE
|
||||
special sub_80699E0
|
||||
|
||||
@@ -1274,7 +1274,7 @@ PalletTown_ProfessorOaksLab_EventScript_RivalTakesStarter:: @ 8169D2F
|
||||
playfanfare MUS_FAN5
|
||||
waitfanfare
|
||||
setvar VAR_MAP_SCENE_PALLET_TOWN_PROFESSOR_OAKS_LAB, 3
|
||||
call_if_set FLAG_PALLET_TOWN_LADY_MOVED_FROM_SIGN, PalletTown_ProfessorOaksLab_EventScript_ReadyEndSignLadyScene
|
||||
call_if_set FLAG_OPENED_START_MENU, PalletTown_ProfessorOaksLab_EventScript_ReadyEndSignLadyScene
|
||||
release
|
||||
end
|
||||
|
||||
|
||||
@@ -1360,7 +1360,7 @@
|
||||
#define FLAG_SYS_RIBBON_GET (SYS_FLAGS + 0x3B)
|
||||
#define FLAG_SYS_SAW_HELP_SYSTEM_INTRO (SYS_FLAGS + 0x3C)
|
||||
#define FLAG_0x83D (SYS_FLAGS + 0x3D)
|
||||
#define FLAG_PALLET_TOWN_LADY_MOVED_FROM_SIGN (SYS_FLAGS + 0x3E)
|
||||
#define FLAG_OPENED_START_MENU (SYS_FLAGS + 0x3E)
|
||||
#define FLAG_0x83F (SYS_FLAGS + 0x3F)
|
||||
#define FLAG_SYS_NATIONAL_DEX (SYS_FLAGS + 0x40)
|
||||
#define FLAG_SYS_PC_STORAGE_DISABLED (SYS_FLAGS + 0x41)
|
||||
|
||||
@@ -1212,4 +1212,8 @@ extern const u8 CableClub_Text_PleaseWaitBCancel[];
|
||||
// fldeff_flash
|
||||
extern const u8 EventScript_FldEffFlash[];
|
||||
|
||||
// field_control_avatar
|
||||
extern const u8 gUnknown_81A7ADB[];
|
||||
extern const u8 PalletTown_PlayersHouse_2F_EventScript_PC[];
|
||||
|
||||
#endif //GUARD_EVENT_SCRIPTS_H
|
||||
|
||||
@@ -3,7 +3,25 @@
|
||||
|
||||
#include "global.h"
|
||||
|
||||
extern u32 gUnknown_3005078;
|
||||
struct FieldInput
|
||||
{
|
||||
bool8 pressedAButton:1;
|
||||
bool8 checkStandardWildEncounter:1;
|
||||
bool8 pressedStartButton:1;
|
||||
bool8 pressedSelectButton:1;
|
||||
bool8 heldDirection:1;
|
||||
bool8 heldDirection2:1;
|
||||
bool8 tookStep:1;
|
||||
bool8 pressedBButton:1;
|
||||
bool8 pressedRButton:1;
|
||||
bool8 input_field_1_0:1;
|
||||
bool8 input_field_1_1:1;
|
||||
bool8 input_field_1_2:1;
|
||||
bool8 input_field_1_3:1;
|
||||
u8 dpadDirection;
|
||||
};
|
||||
|
||||
extern struct FieldInput gUnknown_3005078;
|
||||
|
||||
void RestartWildEncounterImmunitySteps(void);
|
||||
void ClearPoisonStepCounter(void);
|
||||
|
||||
@@ -28,5 +28,8 @@ u8 GetUnlockedSeviiAreas(void);
|
||||
u32 GetPlayerTrainerId(void);
|
||||
bool8 CutMoveRuinValleyCheck(void);
|
||||
void CutMoveOpenDottedHoleDoor(void);
|
||||
void RunMassageCooldownStepCounter(void);
|
||||
void IncrementResortGorgeousStepCounter(void);
|
||||
void IncrementBirthIslandRockStepCount(void);
|
||||
|
||||
#endif // GUARD_FIELD_SPECIALS_H
|
||||
|
||||
@@ -318,6 +318,14 @@ enum
|
||||
COLLISION_HORIZONTAL_RAIL,
|
||||
};
|
||||
|
||||
// player running states
|
||||
enum
|
||||
{
|
||||
NOT_MOVING,
|
||||
TURN_DIRECTION, // not the same as turning! turns your avatar without moving. also known as a turn frame in some circles
|
||||
MOVING,
|
||||
};
|
||||
|
||||
// player tile transition states
|
||||
enum
|
||||
{
|
||||
|
||||
@@ -41,5 +41,6 @@ void InitOldManBag(void);
|
||||
void Pocket_CalculateNItemsAndMaxShowed(u8 pocketId);
|
||||
void PocketCalculateInitialCursorPosAndItemsAbove(u8 pocketId);
|
||||
void GoToBagMenu(u8 menuType, u8 pocket, MainCallback callback);
|
||||
bool8 UseRegisteredKeyItemOnField(void);
|
||||
|
||||
#endif //GUARD_ITEM_MENU_H
|
||||
|
||||
+7
-2
@@ -53,12 +53,12 @@ void mapheader_run_script_with_tag_x3(void);
|
||||
void mapheader_run_script_with_tag_x5(void);
|
||||
void mapheader_run_script_with_tag_x7(void);
|
||||
void mapheader_run_script_with_tag_x6(void);
|
||||
bool8 mapheader_run_first_tag2_script_list_match(void);
|
||||
bool8 TryRunOnFrameMapScript(void);
|
||||
void mapheader_run_first_tag4_script_list_match(void);
|
||||
u32 CalculateRamScriptChecksum(void);
|
||||
void ClearRamScript(void);
|
||||
bool8 InitRamScript(u8 *script, u16 scriptSize, u8 mapGroup, u8 mapNum, u8 objectId);
|
||||
u8 *GetRamScript(u8 objectId, u8 *script);
|
||||
const u8 *GetRamScript(u8 objectId, const u8 *script);
|
||||
bool32 sub_80991F8(void);
|
||||
u8 *sub_8099244(void);
|
||||
void sub_80992A0(u8 *script, u16 scriptSize);
|
||||
@@ -73,7 +73,12 @@ void sub_8069970(void);
|
||||
void sub_8069A20(void);
|
||||
void sub_8069A2C(void);
|
||||
bool8 IsMsgSignPost(void);
|
||||
bool8 sub_806997C(void);
|
||||
u8 sub_80699B0(void);
|
||||
void sub_8069A54(void);
|
||||
bool8 sub_8069A04(void);
|
||||
|
||||
extern const u8 *gRAMScriptPtr;
|
||||
extern u8 gUnknown_20370A0;
|
||||
|
||||
#endif // GUARD_SCRIPT_H
|
||||
|
||||
@@ -99,6 +99,7 @@ SECTIONS {
|
||||
src/text_window_graphics.o(.text);
|
||||
src/script.o(.text);
|
||||
src/scrcmd.o(.text);
|
||||
src/field_control_avatar.o(.text);
|
||||
asm/field_control_avatar.o(.text);
|
||||
src/event_data.o(.text);
|
||||
src/coord_event_weather.o(.text);
|
||||
|
||||
@@ -0,0 +1,428 @@
|
||||
#include "global.h"
|
||||
#include "gflib.h"
|
||||
#include "bike.h"
|
||||
#include "event_data.h"
|
||||
#include "event_object_movement.h"
|
||||
#include "event_scripts.h"
|
||||
#include "fieldmap.h"
|
||||
#include "field_control_avatar.h"
|
||||
#include "field_player_avatar.h"
|
||||
#include "field_specials.h"
|
||||
#include "item_menu.h"
|
||||
#include "link.h"
|
||||
#include "menews_jisan.h"
|
||||
#include "metatile_behavior.h"
|
||||
#include "overworld.h"
|
||||
#include "renewable_hidden_items.h"
|
||||
#include "quest_log.h"
|
||||
#include "script.h"
|
||||
#include "start_menu.h"
|
||||
#include "trainer_see.h"
|
||||
#include "constants/songs.h"
|
||||
#include "constants/event_objects.h"
|
||||
|
||||
void sub_806CA4C(struct FieldInput *input, u16 *newKeys, u16 *heldKeys);
|
||||
bool8 sub_80699D4(void);
|
||||
void sub_806CDF8(u8 taskId);
|
||||
void GetPlayerPosition(struct MapPosition * position);
|
||||
void GetInFrontOfPlayerPosition(struct MapPosition * position);
|
||||
u16 GetPlayerCurMetatileBehavior(void);
|
||||
bool8 TryStartStepBasedScript(struct MapPosition * position, u16 metatileBehavior, u8 playerDirection);
|
||||
bool8 TryArrowWarp(struct MapPosition * position, u16 metatileBehavior, u8 playerDirection);
|
||||
bool8 TryDoorWarp(struct MapPosition * position, u16 metatileBehavior, u8 playerDirection);
|
||||
bool8 TryStartInteractionScript(struct MapPosition * position, u16 metatileBehavior, u8 playerDirection);
|
||||
const u8 *GetInteractionScript(struct MapPosition * position, u8 metatileBehavior, u8 playerDirection);
|
||||
const u8 *GetInteractedObjectEventScript(struct MapPosition * position, u8 metatileBehavior, u8 playerDirection);
|
||||
const u8 *GetInteractedBackgroundEventScript(struct MapPosition * position, u8 metatileBehavior, u8 playerDirection);
|
||||
const u8 *GetInteractedMetatileScript(struct MapPosition * position, u8 metatileBehavior, u8 playerDirection);
|
||||
const u8 *GetInteractedWaterScript(struct MapPosition * position, u8 metatileBehavior, u8 playerDirection);
|
||||
bool8 sub_806D804(struct MapPosition * position, u16 metatileBehavior, u8 playerDirection);
|
||||
bool8 CheckStandardWildEncounter(u32 encounter);
|
||||
|
||||
struct FieldInput gUnknown_3005078;
|
||||
|
||||
void FieldClearPlayerInput(struct FieldInput *input)
|
||||
{
|
||||
input->pressedAButton = FALSE;
|
||||
input->checkStandardWildEncounter = FALSE;
|
||||
input->pressedStartButton = FALSE;
|
||||
input->pressedSelectButton = FALSE;
|
||||
input->heldDirection = FALSE;
|
||||
input->heldDirection2 = FALSE;
|
||||
input->tookStep = FALSE;
|
||||
input->pressedBButton = FALSE;
|
||||
input->pressedRButton = FALSE;
|
||||
input->input_field_1_0 = FALSE;
|
||||
input->input_field_1_1 = FALSE;
|
||||
input->input_field_1_2 = FALSE;
|
||||
input->input_field_1_3 = FALSE;
|
||||
input->dpadDirection = 0;
|
||||
}
|
||||
|
||||
void FieldGetPlayerInput(struct FieldInput *input, u16 newKeys, u16 heldKeys)
|
||||
{
|
||||
u8 runningState = gPlayerAvatar.runningState;
|
||||
u8 tileTransitionState = gPlayerAvatar.tileTransitionState;
|
||||
bool8 forcedMove = MetatileBehavior_IsForcedMovementTile(GetPlayerCurMetatileBehavior());
|
||||
|
||||
if (!ScriptContext1_IsScriptSetUp() && sub_806997C() == TRUE)
|
||||
{
|
||||
sub_806CA4C(input, &newKeys, &heldKeys);
|
||||
}
|
||||
if ((tileTransitionState == T_TILE_CENTER && forcedMove == FALSE) || tileTransitionState == T_NOT_MOVING)
|
||||
{
|
||||
if (GetPlayerSpeed() != 4)
|
||||
{
|
||||
if ((newKeys & START_BUTTON) && !(gPlayerAvatar.flags & 0x40))
|
||||
input->pressedStartButton = TRUE;
|
||||
if (gQuestLogState != QL_STATE_2 && gQuestLogState != QL_STATE_3)
|
||||
{
|
||||
if (!(gPlayerAvatar.flags & 0x40))
|
||||
{
|
||||
if (newKeys & SELECT_BUTTON)
|
||||
input->pressedSelectButton = TRUE;
|
||||
if (newKeys & A_BUTTON)
|
||||
input->pressedAButton = TRUE;
|
||||
if (newKeys & B_BUTTON)
|
||||
input->pressedBButton = TRUE;
|
||||
if (newKeys & R_BUTTON)
|
||||
input->pressedRButton = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (gQuestLogState != QL_STATE_2 && gQuestLogState != QL_STATE_3)
|
||||
{
|
||||
if (heldKeys & (DPAD_UP | DPAD_DOWN | DPAD_LEFT | DPAD_RIGHT))
|
||||
{
|
||||
input->heldDirection = TRUE;
|
||||
input->heldDirection2 = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (forcedMove == FALSE)
|
||||
{
|
||||
if (tileTransitionState == T_TILE_CENTER && runningState == MOVING)
|
||||
input->tookStep = TRUE;
|
||||
if (forcedMove == FALSE && tileTransitionState == T_TILE_CENTER)
|
||||
input->checkStandardWildEncounter = TRUE;
|
||||
}
|
||||
|
||||
if (gQuestLogState != QL_STATE_2 && gQuestLogState != QL_STATE_3)
|
||||
{
|
||||
if (heldKeys & DPAD_UP)
|
||||
input->dpadDirection = DIR_NORTH;
|
||||
else if (heldKeys & DPAD_DOWN)
|
||||
input->dpadDirection = DIR_SOUTH;
|
||||
else if (heldKeys & DPAD_LEFT)
|
||||
input->dpadDirection = DIR_WEST;
|
||||
else if (heldKeys & DPAD_RIGHT)
|
||||
input->dpadDirection = DIR_EAST;
|
||||
}
|
||||
}
|
||||
|
||||
void sub_806CA4C(struct FieldInput *input, u16 *newKeys, u16 *heldKeys)
|
||||
{
|
||||
switch (sub_80699B0())
|
||||
{
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
*heldKeys = *newKeys = DPAD_UP;
|
||||
break;
|
||||
case 2:
|
||||
*heldKeys = *newKeys = DPAD_DOWN;
|
||||
break;
|
||||
case 3:
|
||||
*heldKeys = *newKeys = DPAD_LEFT;
|
||||
break;
|
||||
case 4:
|
||||
*heldKeys = *newKeys = DPAD_RIGHT;
|
||||
break;
|
||||
case 5:
|
||||
*heldKeys = *newKeys = L_BUTTON;
|
||||
break;
|
||||
case 6:
|
||||
*heldKeys = *newKeys = R_BUTTON;
|
||||
break;
|
||||
case 7:
|
||||
*heldKeys = *newKeys = START_BUTTON;
|
||||
break;
|
||||
case 8:
|
||||
*heldKeys = *newKeys = SELECT_BUTTON;
|
||||
break;
|
||||
}
|
||||
sub_8069970();
|
||||
sub_80699A4();
|
||||
}
|
||||
|
||||
int ProcessPlayerFieldInput(struct FieldInput *input)
|
||||
{
|
||||
struct MapPosition position;
|
||||
u8 playerDirection;
|
||||
u16 metatileBehavior;
|
||||
u32 r8;
|
||||
|
||||
sub_8069A54();
|
||||
playerDirection = GetPlayerFacingDirection();
|
||||
GetPlayerPosition(&position);
|
||||
r8 = MapGridGetMetatileAttributeAt(position.x, position.y, 0xFF);
|
||||
metatileBehavior = MapGridGetMetatileBehaviorAt(position.x, position.y);
|
||||
|
||||
FieldClearPlayerInput(&gUnknown_3005078);
|
||||
gUnknown_3005078.dpadDirection = input->dpadDirection;
|
||||
|
||||
if (CheckForTrainersWantingBattle() == TRUE)
|
||||
return TRUE;
|
||||
|
||||
if (TryRunOnFrameMapScript() == TRUE)
|
||||
return TRUE;
|
||||
|
||||
if (input->tookStep)
|
||||
{
|
||||
IncrementGameStat(GAME_STAT_STEPS);
|
||||
MENewsJisanStepCounter();
|
||||
IncrementRenewableHiddenItemStepCounter();
|
||||
RunMassageCooldownStepCounter();
|
||||
IncrementResortGorgeousStepCounter();
|
||||
IncrementBirthIslandRockStepCount();
|
||||
if (TryStartStepBasedScript(&position, metatileBehavior, playerDirection) == TRUE)
|
||||
{
|
||||
gUnknown_3005078.tookStep = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
if (input->checkStandardWildEncounter)
|
||||
{
|
||||
if (input->dpadDirection == 0 || input->dpadDirection == playerDirection)
|
||||
{
|
||||
GetInFrontOfPlayerPosition(&position);
|
||||
metatileBehavior = MapGridGetMetatileBehaviorAt(position.x, position.y);
|
||||
if (sub_806D804(&position, metatileBehavior, playerDirection) == TRUE)
|
||||
{
|
||||
gUnknown_3005078.checkStandardWildEncounter = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
GetPlayerPosition(&position);
|
||||
metatileBehavior = MapGridGetMetatileBehaviorAt(position.x, position.y);
|
||||
}
|
||||
}
|
||||
if (input->checkStandardWildEncounter && CheckStandardWildEncounter(r8) == TRUE)
|
||||
{
|
||||
gUnknown_3005078.checkStandardWildEncounter = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
if (input->heldDirection && input->dpadDirection == playerDirection)
|
||||
{
|
||||
if (TryArrowWarp(&position, metatileBehavior, playerDirection) == TRUE)
|
||||
{
|
||||
gUnknown_3005078.heldDirection = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
GetInFrontOfPlayerPosition(&position);
|
||||
metatileBehavior = MapGridGetMetatileBehaviorAt(position.x, position.y);
|
||||
if (input->heldDirection && input->dpadDirection == playerDirection)
|
||||
{
|
||||
if (sub_806D804(&position, metatileBehavior, playerDirection) == TRUE)
|
||||
{
|
||||
gUnknown_3005078.heldDirection = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (input->pressedAButton && TryStartInteractionScript(&position, metatileBehavior, playerDirection) == TRUE)
|
||||
{
|
||||
gUnknown_3005078.pressedAButton = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (input->heldDirection2 && input->dpadDirection == playerDirection)
|
||||
{
|
||||
if (TryDoorWarp(&position, metatileBehavior, playerDirection) == TRUE)
|
||||
{
|
||||
gUnknown_3005078.heldDirection2 = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (input->pressedStartButton)
|
||||
{
|
||||
gUnknown_3005078.pressedStartButton = TRUE;
|
||||
FlagSet(FLAG_OPENED_START_MENU);
|
||||
PlaySE(SE_WIN_OPEN);
|
||||
ShowStartMenu();
|
||||
return TRUE;
|
||||
}
|
||||
if (input->pressedSelectButton && UseRegisteredKeyItemOnField() == TRUE)
|
||||
{
|
||||
gUnknown_3005078.pressedSelectButton = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void sub_806CD30(struct FieldInput * input)
|
||||
{
|
||||
if (ScriptContext1_IsScriptSetUp() == TRUE)
|
||||
{
|
||||
if (gUnknown_20370A0 != 0)
|
||||
gUnknown_20370A0--;
|
||||
else if (sub_8069A04() == TRUE)
|
||||
{
|
||||
if (input->dpadDirection != 0 && GetPlayerFacingDirection() != input->dpadDirection)
|
||||
{
|
||||
if (sub_80699D4() == TRUE)
|
||||
return;
|
||||
if (input->dpadDirection == DIR_NORTH)
|
||||
sub_8069998(1);
|
||||
else if (input->dpadDirection == DIR_SOUTH)
|
||||
sub_8069998(2);
|
||||
else if (input->dpadDirection == DIR_WEST)
|
||||
sub_8069998(3);
|
||||
else if (input->dpadDirection == DIR_EAST)
|
||||
sub_8069998(4);
|
||||
ScriptContext1_SetupScript(gUnknown_81A7ADB);
|
||||
ScriptContext2_Enable();
|
||||
}
|
||||
else if (input->pressedStartButton)
|
||||
{
|
||||
ScriptContext1_SetupScript(gUnknown_81A7ADB);
|
||||
ScriptContext2_Enable();
|
||||
if (!FuncIsActiveTask(sub_806CDF8))
|
||||
CreateTask(sub_806CDF8, 8);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sub_806CDF8(u8 taskId)
|
||||
{
|
||||
if (!ScriptContext2_IsEnabled())
|
||||
{
|
||||
PlaySE(SE_WIN_OPEN);
|
||||
ShowStartMenu();
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
}
|
||||
|
||||
void GetPlayerPosition(struct MapPosition *position)
|
||||
{
|
||||
PlayerGetDestCoords(&position->x, &position->y);
|
||||
position->height = PlayerGetZCoord();
|
||||
}
|
||||
|
||||
void GetInFrontOfPlayerPosition(struct MapPosition *position)
|
||||
{
|
||||
s16 x, y;
|
||||
|
||||
GetXYCoordsOneStepInFrontOfPlayer(&position->x, &position->y);
|
||||
PlayerGetDestCoords(&x, &y);
|
||||
if (MapGridGetZCoordAt(x, y) != 0)
|
||||
position->height = PlayerGetZCoord();
|
||||
else
|
||||
position->height = 0;
|
||||
}
|
||||
|
||||
u16 GetPlayerCurMetatileBehavior(void)
|
||||
{
|
||||
s16 x, y;
|
||||
|
||||
PlayerGetDestCoords(&x, &y);
|
||||
return MapGridGetMetatileBehaviorAt(x, y);
|
||||
}
|
||||
|
||||
bool8 TryStartInteractionScript(struct MapPosition *position, u16 metatileBehavior, u8 direction)
|
||||
{
|
||||
const u8 *script = GetInteractionScript(position, metatileBehavior, direction);
|
||||
if (script == NULL)
|
||||
return FALSE;
|
||||
|
||||
// Don't play interaction sound for certain scripts.
|
||||
if (script != PalletTown_PlayersHouse_2F_EventScript_PC
|
||||
&& script != EventScript_PC)
|
||||
PlaySE(SE_SELECT);
|
||||
|
||||
ScriptContext1_SetupScript(script);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
const u8 *GetInteractionScript(struct MapPosition *position, u8 metatileBehavior, u8 direction)
|
||||
{
|
||||
const u8 *script = GetInteractedObjectEventScript(position, metatileBehavior, direction);
|
||||
if (script != NULL)
|
||||
return script;
|
||||
|
||||
script = GetInteractedBackgroundEventScript(position, metatileBehavior, direction);
|
||||
if (script != NULL)
|
||||
return script;
|
||||
|
||||
script = GetInteractedMetatileScript(position, metatileBehavior, direction);
|
||||
if (script != NULL)
|
||||
return script;
|
||||
|
||||
script = GetInteractedWaterScript(position, metatileBehavior, direction);
|
||||
if (script != NULL)
|
||||
return script;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const u8 *GetInteractedLinkPlayerScript(struct MapPosition *position, u8 metatileBehavior, u8 direction)
|
||||
{
|
||||
u8 objectEventId;
|
||||
s32 i;
|
||||
|
||||
if (!MetatileBehavior_IsCounter(MapGridGetMetatileBehaviorAt(position->x, position->y)))
|
||||
objectEventId = GetObjectEventIdByXYZ(position->x, position->y, position->height);
|
||||
else
|
||||
objectEventId = GetObjectEventIdByXYZ(position->x + gDirectionToVectors[direction].x, position->y + gDirectionToVectors[direction].y, position->height);
|
||||
|
||||
if (objectEventId == OBJECT_EVENTS_COUNT || gObjectEvents[objectEventId].localId == OBJ_EVENT_ID_PLAYER)
|
||||
return NULL;
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
if (gLinkPlayerObjectEvents[i].active == TRUE && gLinkPlayerObjectEvents[i].objEventId == objectEventId)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gSelectedObjectEvent = objectEventId;
|
||||
gSpecialVar_LastTalked = gObjectEvents[objectEventId].localId;
|
||||
gSpecialVar_Facing = direction;
|
||||
return GetObjectEventScriptPointerByObjectEventId(objectEventId);
|
||||
}
|
||||
|
||||
const u8 *GetInteractedObjectEventScript(struct MapPosition *position, u8 metatileBehavior, u8 direction)
|
||||
{
|
||||
u8 objectEventId;
|
||||
const u8 *script;
|
||||
|
||||
objectEventId = GetObjectEventIdByXYZ(position->x, position->y, position->height);
|
||||
if (objectEventId == OBJECT_EVENTS_COUNT || gObjectEvents[objectEventId].localId == OBJ_EVENT_ID_PLAYER)
|
||||
{
|
||||
if (MetatileBehavior_IsCounter(metatileBehavior) != TRUE)
|
||||
return NULL;
|
||||
|
||||
// Look for an object event on the other side of the counter.
|
||||
objectEventId = GetObjectEventIdByXYZ(position->x + gDirectionToVectors[direction].x, position->y + gDirectionToVectors[direction].y, position->height);
|
||||
if (objectEventId == OBJECT_EVENTS_COUNT || gObjectEvents[objectEventId].localId == OBJ_EVENT_ID_PLAYER)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (InUnionRoom() == TRUE && !ObjectEventCheckHeldMovementStatus(&gObjectEvents[objectEventId]))
|
||||
return NULL;
|
||||
|
||||
gSelectedObjectEvent = objectEventId;
|
||||
gSpecialVar_LastTalked = gObjectEvents[objectEventId].localId;
|
||||
gSpecialVar_Facing = direction;
|
||||
|
||||
script = GetObjectEventScriptPointerByObjectEventId(objectEventId);
|
||||
|
||||
script = GetRamScript(gSpecialVar_LastTalked, script);
|
||||
return script;
|
||||
}
|
||||
@@ -2435,7 +2435,7 @@ static void Task_WaitDeoxysFieldEffect(u8 taskId)
|
||||
}
|
||||
}
|
||||
|
||||
void BirthIslandDeoxysStepCounter(void)
|
||||
void IncrementBirthIslandRockStepCount(void)
|
||||
{
|
||||
u16 count = VarGet(VAR_DEOXYS_INTERACTION_STEP_COUNTER);
|
||||
if (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(BIRTH_ISLAND_EXTERIOR) && gSaveBlock1Ptr->location.mapNum == MAP_NUM(BIRTH_ISLAND_EXTERIOR))
|
||||
|
||||
+14
-14
@@ -21,18 +21,18 @@ enum
|
||||
EWRAM_DATA u8 gUnknown_20370A0 = 0;
|
||||
EWRAM_DATA const u8 *gRAMScriptPtr = NULL;
|
||||
|
||||
// ewram bss
|
||||
/*IWRAM_DATA*/ static u8 sScriptContext1Status;
|
||||
/*IWRAM_DATA*/ static u32 sUnusedVariable1;
|
||||
/*IWRAM_DATA*/ static struct ScriptContext sScriptContext1;
|
||||
/*IWRAM_DATA*/ static u32 sUnusedVariable2;
|
||||
/*IWRAM_DATA*/ static struct ScriptContext sScriptContext2;
|
||||
/*IWRAM_DATA*/ static bool8 sScriptContext2Enabled;
|
||||
/*IWRAM_DATA*/ static u8 gUnknown_3000F9D;
|
||||
/*IWRAM_DATA*/ static u8 gUnknown_3000F9E;
|
||||
/*IWRAM_DATA*/ static u8 gUnknown_3000F9F;
|
||||
/*IWRAM_DATA*/ static u8 gUnknown_3000FA0;
|
||||
/*IWRAM_DATA*/ static u8 gUnknown_3000FA1;
|
||||
// iwram bss
|
||||
static u8 sScriptContext1Status;
|
||||
static u32 sUnusedVariable1;
|
||||
static struct ScriptContext sScriptContext1;
|
||||
static u32 sUnusedVariable2;
|
||||
static struct ScriptContext sScriptContext2;
|
||||
static bool8 sScriptContext2Enabled;
|
||||
static u8 gUnknown_3000F9D;
|
||||
static u8 gUnknown_3000F9E;
|
||||
static u8 gUnknown_3000F9F;
|
||||
static u8 gUnknown_3000FA0;
|
||||
static u8 gUnknown_3000FA1;
|
||||
|
||||
extern ScrCmdFunc gScriptCmdTable[];
|
||||
extern ScrCmdFunc gScriptCmdTableEnd[];
|
||||
@@ -431,7 +431,7 @@ void mapheader_run_script_with_tag_x6(void)
|
||||
mapheader_run_script_by_tag(6);
|
||||
}
|
||||
|
||||
bool8 mapheader_run_first_tag2_script_list_match(void)
|
||||
bool8 TryRunOnFrameMapScript(void)
|
||||
{
|
||||
u8 *ptr;
|
||||
|
||||
@@ -482,7 +482,7 @@ bool8 InitRamScript(u8 *script, u16 scriptSize, u8 mapGroup, u8 mapNum, u8 objec
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
u8 *GetRamScript(u8 objectId, u8 *script)
|
||||
const u8 *GetRamScript(u8 objectId, const u8 *script)
|
||||
{
|
||||
struct RamScriptData *scriptData = &gSaveBlock1Ptr->ramScript.data;
|
||||
gRAMScriptPtr = NULL;
|
||||
|
||||
Reference in New Issue
Block a user