first merge of ghoul's branch
This commit is contained in:
commit
28183ec299
20 changed files with 225 additions and 2 deletions
BIN
.swp
Normal file
BIN
.swp
Normal file
Binary file not shown.
|
@ -693,6 +693,11 @@ EventScript_BackupMrBrineyLocation::
|
|||
.include "data/scripts/rival_graphics.inc"
|
||||
.include "data/scripts/set_gym_trainers.inc"
|
||||
|
||||
EventScript_CancelMessageBox::
|
||||
special DoPicboxCancel
|
||||
release
|
||||
end
|
||||
|
||||
Common_EventScript_ShowBagIsFull::
|
||||
msgbox gText_TooBadBagIsFull, MSGBOX_DEFAULT
|
||||
release
|
||||
|
|
|
@ -554,3 +554,4 @@ gSpecials::
|
|||
def_special Script_GetChosenMonDefensiveEVs
|
||||
def_special Script_GetChosenMonOffensiveIVs
|
||||
def_special Script_GetChosenMonDefensiveIVs
|
||||
def_special DoPicboxCancel
|
||||
|
|
Binary file not shown.
|
@ -30,7 +30,7 @@
|
|||
#define MB_UNUSED_SOOTOPOLIS_DEEP_WATER_2 0x1A
|
||||
#define MB_STAIRS_OUTSIDE_ABANDONED_SHIP 0x1B
|
||||
#define MB_SHOAL_CAVE_ENTRANCE 0x1C
|
||||
#define MB_UNUSED_1D 0x1D
|
||||
#define MB_SIGNPOST 0x1D
|
||||
#define MB_UNUSED_1E 0x1E
|
||||
#define MB_UNUSED_1F 0x1F
|
||||
#define MB_ICE 0x20
|
||||
|
|
|
@ -647,4 +647,6 @@ extern const u8 EventScript_VsSeekerChargingDone[];
|
|||
extern const u8 Common_Movement_FollowerSafeStart[];
|
||||
extern const u8 Common_Movement_FollowerSafeEnd[];
|
||||
|
||||
extern const u8 EventScript_CancelMessageBox[];
|
||||
|
||||
#endif // GUARD_EVENT_SCRIPTS_H
|
||||
|
|
|
@ -34,5 +34,6 @@ u8 TrySetDiveWarp(void);
|
|||
const u8 *GetInteractedLinkPlayerScript(struct MapPosition *position, u8 metatileBehavior, u8 direction);
|
||||
const u8 *GetCoordEventScriptAtMapPosition(struct MapPosition *position);
|
||||
void ClearPoisonStepCounter(void);
|
||||
void FieldInput_HandleCancelSignpost(struct FieldInput *input);
|
||||
|
||||
#endif // GUARD_FIELDCONTROLAVATAR_H
|
||||
|
|
|
@ -19,4 +19,6 @@ u8 GetFieldMessageBoxMode(void);
|
|||
void StopFieldMessage(void);
|
||||
void InitFieldMessageBox(void);
|
||||
|
||||
extern u8 gWalkAwayFromSignInhibitTimer;
|
||||
|
||||
#endif // GUARD_FIELD_MESSAGE_BOX_H
|
||||
|
|
|
@ -148,5 +148,6 @@ bool8 MetatileBehavior_IsQuestionnaire(u8);
|
|||
bool8 MetatileBehavior_IsLongGrass_Duplicate(u8);
|
||||
bool8 MetatileBehavior_IsLongGrassSouthEdge(u8);
|
||||
bool8 MetatileBehavior_IsTrainerHillTimer(u8);
|
||||
bool8 MetatileBehavior_IsSignpost(u8 mb);
|
||||
|
||||
#endif // GUARD_METATILE_BEHAVIOR_H
|
||||
|
|
|
@ -63,4 +63,12 @@ void InitRamScript_NoObjectEvent(u8 *script, u16 scriptSize);
|
|||
// srccmd.h
|
||||
void SetMovingNpcId(u16 npcId);
|
||||
|
||||
// auto read signs
|
||||
void SetWalkingIntoSignVars(void);
|
||||
void MsgSetSignPost(void);
|
||||
void ResetFacingNpcOrSignPostVars(void);
|
||||
bool32 IsMsgSignPost(void);
|
||||
bool32 CanWalkAwayToCancelMsgBox(void);
|
||||
void ClearMsgBoxCancelableState(void);
|
||||
|
||||
#endif // GUARD_SCRIPT_H
|
||||
|
|
|
@ -23,5 +23,6 @@ void DrawTextBorderInner(u8 windowId, u16 tileNum, u8 palNum);
|
|||
void rbox_fill_rectangle(u8 windowId);
|
||||
const u16 *GetTextWindowPalette(u8 id);
|
||||
const u16 *GetOverworldTextboxPalettePtr(void);
|
||||
void LoadSignPostWindowFrameGfx(void);
|
||||
|
||||
#endif // GUARD_TEXT_WINDOW_H
|
||||
|
|
0
log2.txt
Normal file
0
log2.txt
Normal file
|
@ -10,6 +10,7 @@
|
|||
#include "event_scripts.h"
|
||||
#include "fieldmap.h"
|
||||
#include "field_control_avatar.h"
|
||||
#include "field_message_box.h"
|
||||
#include "field_player_avatar.h"
|
||||
#include "field_poison.h"
|
||||
#include "field_screen_effect.h"
|
||||
|
@ -42,6 +43,13 @@ static EWRAM_DATA u16 sPrevMetatileBehavior = 0;
|
|||
|
||||
u8 gSelectedObjectEvent;
|
||||
|
||||
#define SIGNPOST_POKECENTER 0
|
||||
#define SIGNPOST_POKEMART 1
|
||||
#define SIGNPOST_INDIGO_1 2
|
||||
#define SIGNPOST_INDIGO_2 3
|
||||
#define SIGNPOST_SCRIPTED 240
|
||||
#define SIGNPOST_NA 255
|
||||
|
||||
static void GetPlayerPosition(struct MapPosition *);
|
||||
static void GetInFrontOfPlayerPosition(struct MapPosition *);
|
||||
static u16 GetPlayerCurMetatileBehavior(int);
|
||||
|
@ -73,6 +81,10 @@ static void UpdateLetsGoEvolutionTracker(void);
|
|||
#if OW_POISON_DAMAGE < GEN_5
|
||||
static bool8 UpdatePoisonStepCounter(void);
|
||||
#endif // OW_POISON_DAMAGE
|
||||
static bool8 TrySetUpWalkIntoSignpostScript(struct MapPosition * position, u16 metatileBehavior, u8 playerDirection);
|
||||
static void SetUpWalkIntoSignScript(const u8 *script, u8 playerDirection);
|
||||
static u8 GetFacingSignpostType(u16 metatileBehvaior, u8 direction);
|
||||
static const u8 *GetSignpostScriptAtMapPosition(struct MapPosition * position);
|
||||
|
||||
void FieldClearPlayerInput(struct FieldInput *input)
|
||||
{
|
||||
|
@ -153,6 +165,7 @@ int ProcessPlayerFieldInput(struct FieldInput *input)
|
|||
gSpecialVar_LastTalked = 0;
|
||||
gSelectedObjectEvent = 0;
|
||||
|
||||
ResetFacingNpcOrSignPostVars();
|
||||
playerDirection = GetPlayerFacingDirection();
|
||||
GetPlayerPosition(&position);
|
||||
metatileBehavior = MapGridGetMetatileBehaviorAt(position.x, position.y);
|
||||
|
@ -172,6 +185,20 @@ int ProcessPlayerFieldInput(struct FieldInput *input)
|
|||
if (TryStartStepBasedScript(&position, metatileBehavior, playerDirection) == TRUE)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (input->checkStandardWildEncounter)
|
||||
{
|
||||
if (input->dpadDirection == 0 || input->dpadDirection == playerDirection)
|
||||
{
|
||||
GetInFrontOfPlayerPosition(&position);
|
||||
metatileBehavior = MapGridGetMetatileBehaviorAt(position.x, position.y);
|
||||
if (TrySetUpWalkIntoSignpostScript(&position, metatileBehavior, playerDirection) == TRUE)
|
||||
return TRUE;
|
||||
GetPlayerPosition(&position);
|
||||
metatileBehavior = MapGridGetMetatileBehaviorAt(position.x, position.y);
|
||||
}
|
||||
}
|
||||
|
||||
if (input->checkStandardWildEncounter && CheckStandardWildEncounter(metatileBehavior) == TRUE)
|
||||
return TRUE;
|
||||
if (input->heldDirection && input->dpadDirection == playerDirection)
|
||||
|
@ -182,6 +209,13 @@ int ProcessPlayerFieldInput(struct FieldInput *input)
|
|||
|
||||
GetInFrontOfPlayerPosition(&position);
|
||||
metatileBehavior = MapGridGetMetatileBehaviorAt(position.x, position.y);
|
||||
|
||||
if (input->heldDirection && input->dpadDirection == playerDirection)
|
||||
{
|
||||
if (TrySetUpWalkIntoSignpostScript(&position, metatileBehavior, playerDirection) == TRUE)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (input->pressedAButton && TryStartInteractionScript(&position, metatileBehavior, playerDirection) == TRUE)
|
||||
return TRUE;
|
||||
|
||||
|
@ -1060,3 +1094,102 @@ int SetCableClubWarp(void)
|
|||
SetupWarp(&gMapHeader, GetWarpEventAtMapPosition(&gMapHeader, &position), &position);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// auto read signposts
|
||||
// signposts
|
||||
static bool8 TrySetUpWalkIntoSignpostScript(struct MapPosition *position, u16 metatileBehavior, u8 playerDirection)
|
||||
{
|
||||
const u8 *script;
|
||||
|
||||
if (JOY_HELD(DPAD_LEFT | DPAD_RIGHT))
|
||||
return FALSE;
|
||||
if (playerDirection != DIR_NORTH)
|
||||
return FALSE;
|
||||
|
||||
switch (GetFacingSignpostType(metatileBehavior, playerDirection))
|
||||
{
|
||||
/* leaving this commented out for examples of custom signpost types
|
||||
case SIGNPOST_POKECENTER:
|
||||
SetUpWalkIntoSignScript(EventScript_PokecenterSign, playerDirection);
|
||||
return TRUE;
|
||||
case SIGNPOST_POKEMART:
|
||||
SetUpWalkIntoSignScript(EventScript_PokemartSign, playerDirection);
|
||||
return TRUE;*/
|
||||
case SIGNPOST_SCRIPTED:
|
||||
script = GetSignpostScriptAtMapPosition(position);
|
||||
if (script == NULL)
|
||||
return FALSE;
|
||||
SetUpWalkIntoSignScript(script, playerDirection);
|
||||
return TRUE;
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
static u8 GetFacingSignpostType(u16 metatileBehavior, u8 playerDirection)
|
||||
{
|
||||
/*if (MetatileBehavior_IsPlayerFacingPokemonCenterSign(metatileBehavior, playerDirection) == TRUE)
|
||||
return SIGNPOST_POKECENTER;
|
||||
if (MetatileBehavior_IsPlayerFacingPokeMartSign(metatileBehavior, playerDirection) == TRUE)
|
||||
return SIGNPOST_POKEMART;*/
|
||||
|
||||
if (MetatileBehavior_IsSignpost(metatileBehavior) == TRUE)
|
||||
return SIGNPOST_SCRIPTED;
|
||||
|
||||
return SIGNPOST_NA;
|
||||
}
|
||||
|
||||
static void SetUpWalkIntoSignScript(const u8 *script, u8 playerDirection)
|
||||
{
|
||||
gSpecialVar_Facing = playerDirection;
|
||||
ScriptContext_SetupScript(script);
|
||||
SetWalkingIntoSignVars();
|
||||
MsgSetSignPost();
|
||||
}
|
||||
|
||||
static const u8 *GetSignpostScriptAtMapPosition(struct MapPosition *position)
|
||||
{
|
||||
const struct BgEvent *event = GetBackgroundEventAtPosition(&gMapHeader, position->x - 7, position->y - 7, position->elevation);
|
||||
if (event == NULL)
|
||||
return NULL;
|
||||
if (event->bgUnion.script != NULL)
|
||||
return event->bgUnion.script;
|
||||
return EventScript_TestSignpostMsg;
|
||||
}
|
||||
|
||||
static void Task_OpenStartMenu(u8 taskId)
|
||||
{
|
||||
if (!ArePlayerFieldControlsLocked())
|
||||
{
|
||||
PlaySE(SE_WIN_OPEN);
|
||||
ShowStartMenu();
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
}
|
||||
|
||||
void FieldInput_HandleCancelSignpost(struct FieldInput *input)
|
||||
{
|
||||
if (ScriptContext_IsEnabled() == TRUE)
|
||||
{
|
||||
if (gWalkAwayFromSignInhibitTimer != 0)
|
||||
{
|
||||
gWalkAwayFromSignInhibitTimer--;
|
||||
}
|
||||
else if (CanWalkAwayToCancelMsgBox() == TRUE)
|
||||
{
|
||||
//ClearMsgBoxCancelableState();
|
||||
if (input->dpadDirection != 0 && GetPlayerFacingDirection() != input->dpadDirection)
|
||||
{
|
||||
ScriptContext_SetupScript(EventScript_CancelMessageBox);
|
||||
LockPlayerFieldControls();
|
||||
}
|
||||
else if (input->pressedStartButton)
|
||||
{
|
||||
ScriptContext_SetupScript(EventScript_CancelMessageBox);
|
||||
LockPlayerFieldControls();
|
||||
if (!FuncIsActiveTask(Task_OpenStartMenu))
|
||||
CreateTask(Task_OpenStartMenu, 8);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,8 +5,11 @@
|
|||
#include "text.h"
|
||||
#include "match_call.h"
|
||||
#include "field_message_box.h"
|
||||
#include "text_window.h"
|
||||
#include "script.h"
|
||||
|
||||
static EWRAM_DATA u8 sFieldMessageBoxMode = 0;
|
||||
EWRAM_DATA u8 gWalkAwayFromSignInhibitTimer = 0;
|
||||
|
||||
static void ExpandStringAndStartDrawFieldMessage(const u8 *, bool32);
|
||||
static void StartDrawFieldMessage(void);
|
||||
|
@ -29,7 +32,12 @@ static void Task_DrawFieldMessage(u8 taskId)
|
|||
switch (task->tState)
|
||||
{
|
||||
case 0:
|
||||
LoadMessageBoxAndBorderGfx();
|
||||
if (IsMsgSignPost())
|
||||
LoadSignPostWindowFrameGfx();
|
||||
else
|
||||
LoadMessageBoxAndBorderGfx();
|
||||
task->tState++;
|
||||
break;
|
||||
task->tState++;
|
||||
break;
|
||||
case 1:
|
||||
|
|
|
@ -4266,3 +4266,10 @@ void PreparePartyForSkyBattle(void)
|
|||
VarSet(B_VAR_SKY_BATTLE,participatingPokemonSlot);
|
||||
CompactPartySlots();
|
||||
}
|
||||
|
||||
void DoPicboxCancel(void)
|
||||
{
|
||||
u8 t = EOS;
|
||||
AddTextPrinterParameterized(0, FONT_NORMAL, &t, 0, 1, 0, NULL);
|
||||
ScriptMenu_HidePokemonPic();
|
||||
}
|
||||
|
|
|
@ -125,6 +125,7 @@ static const u8 sTileBitAttributes[NUM_METATILE_BEHAVIORS] =
|
|||
[MB_ISOLATED_HORIZONTAL_RAIL] = TILE_FLAG_UNUSED,
|
||||
[MB_VERTICAL_RAIL] = TILE_FLAG_UNUSED,
|
||||
[MB_HORIZONTAL_RAIL] = TILE_FLAG_UNUSED,
|
||||
[MB_SIGNPOST] = TILE_FLAG_UNUSED,
|
||||
};
|
||||
|
||||
bool8 MetatileBehavior_IsATile(u8 metatileBehavior)
|
||||
|
@ -1400,3 +1401,9 @@ bool8 MetatileBehavior_IsTrainerHillTimer(u8 metatileBehavior)
|
|||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 MetatileBehavior_IsSignpost(u8 mb)
|
||||
{
|
||||
return (mb == MB_SIGNPOST);
|
||||
}
|
||||
|
||||
|
|
|
@ -1489,6 +1489,7 @@ static void DoCB1_Overworld(u16 newKeys, u16 heldKeys)
|
|||
UpdatePlayerAvatarTransitionState();
|
||||
FieldClearPlayerInput(&inputStruct);
|
||||
FieldGetPlayerInput(&inputStruct, newKeys, heldKeys);
|
||||
FieldInput_HandleCancelSignpost(&inputStruct);
|
||||
if (!ArePlayerFieldControlsLocked())
|
||||
{
|
||||
if (ProcessPlayerFieldInput(&inputStruct) == 1)
|
||||
|
|
|
@ -1290,6 +1290,7 @@ bool8 ScrCmd_releaseall(struct ScriptContext *ctx)
|
|||
ObjectEventClearHeldMovementIfFinished(&gObjectEvents[playerObjectId]);
|
||||
ScriptMovement_UnfreezeObjectEvents();
|
||||
UnfreezeObjectEvents();
|
||||
ClearMsgBoxCancelableState();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -1308,6 +1309,7 @@ bool8 ScrCmd_release(struct ScriptContext *ctx)
|
|||
ObjectEventClearHeldMovementIfFinished(&gObjectEvents[playerObjectId]);
|
||||
ScriptMovement_UnfreezeObjectEvents();
|
||||
UnfreezeObjectEvents();
|
||||
ClearMsgBoxCancelableState();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
35
src/script.c
35
src/script.c
|
@ -5,6 +5,7 @@
|
|||
#include "util.h"
|
||||
#include "constants/event_objects.h"
|
||||
#include "constants/map_scripts.h"
|
||||
#include "field_message_box.h"
|
||||
|
||||
#define RAM_SCRIPT_MAGIC 51
|
||||
|
||||
|
@ -26,6 +27,8 @@ static u8 sGlobalScriptContextStatus;
|
|||
static struct ScriptContext sGlobalScriptContext;
|
||||
static struct ScriptContext sImmediateScriptContext;
|
||||
static bool8 sLockFieldControls;
|
||||
static u8 sMsgIsSignPost;
|
||||
static u8 sMsgBoxIsCancelable;
|
||||
|
||||
extern ScrCmdFunc gScriptCmdTable[];
|
||||
extern ScrCmdFunc gScriptCmdTableEnd[];
|
||||
|
@ -501,3 +504,35 @@ void InitRamScript_NoObjectEvent(u8 *script, u16 scriptSize)
|
|||
InitRamScript(script, scriptSize, MAP_GROUP(UNDEFINED), MAP_NUM(UNDEFINED), NO_OBJECT);
|
||||
#endif //FREE_MYSTERY_EVENT_BUFFERS
|
||||
}
|
||||
|
||||
// auto read signposts
|
||||
void SetWalkingIntoSignVars(void)
|
||||
{
|
||||
gWalkAwayFromSignInhibitTimer = 6;
|
||||
sMsgBoxIsCancelable = TRUE;
|
||||
}
|
||||
|
||||
bool32 IsMsgSignPost(void)
|
||||
{
|
||||
return sMsgIsSignPost;
|
||||
}
|
||||
|
||||
void ResetFacingNpcOrSignPostVars(void)
|
||||
{
|
||||
sMsgIsSignPost = FALSE;
|
||||
}
|
||||
|
||||
void MsgSetSignPost(void)
|
||||
{
|
||||
sMsgIsSignPost = TRUE;
|
||||
}
|
||||
|
||||
void ClearMsgBoxCancelableState(void)
|
||||
{
|
||||
sMsgBoxIsCancelable = FALSE;
|
||||
}
|
||||
|
||||
bool32 CanWalkAwayToCancelMsgBox(void)
|
||||
{
|
||||
return sMsgBoxIsCancelable;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "palette.h"
|
||||
#include "bg.h"
|
||||
#include "graphics.h"
|
||||
#include "menu.h"
|
||||
|
||||
const u8 gTextWindowFrame1_Gfx[] = INCBIN_U8("graphics/text_window/1.4bpp");
|
||||
static const u8 sTextWindowFrame2_Gfx[] = INCBIN_U8("graphics/text_window/2.4bpp");
|
||||
|
@ -195,3 +196,11 @@ void LoadUserWindowBorderGfxOnBg(u8 bg, u16 destOffset, u8 palOffset)
|
|||
LoadBgTiles(bg, sWindowFrames[gSaveBlock2Ptr->optionsWindowFrameType].tiles, 0x120, destOffset);
|
||||
LoadPalette(GetWindowFrameTilesPal(gSaveBlock2Ptr->optionsWindowFrameType)->pal, palOffset, PLTT_SIZE_4BPP);
|
||||
}
|
||||
|
||||
void LoadSignPostWindowFrameGfx(void)
|
||||
{
|
||||
// TODO signpost msgbox frames
|
||||
//LoadBgTiles(GetWindowAttribute(windowId, WINDOW_BG), gUnknown_8470B0C, 0x260, destOffset);
|
||||
//LoadPalette(GetWindowFrameTilesPal(1), palIdx, 32);
|
||||
LoadMessageBoxAndBorderGfx();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue