Merge branch 'followers-expanded-id' into lighting-expanded-id

This commit is contained in:
Ariel A 2023-04-23 17:50:20 -04:00
commit 6a89e5b0d2
5 changed files with 120 additions and 10 deletions

View File

@ -105,8 +105,8 @@
},
{
"graphics_id": "OBJ_EVENT_GFX_PIKACHU",
"x": 49,
"y": 2,
"x": 51,
"y": 1,
"elevation": 3,
"movement_type": "MOVEMENT_TYPE_LOOK_AROUND",
"movement_range_x": 0,
@ -336,6 +336,32 @@
"trainer_sight_or_berry_tree_id": "4",
"script": "Route117_EventScript_Melina",
"flag": "0"
},
{
"graphics_id": "OBJ_EVENT_GFX_VAR_0",
"x": 47,
"y": 2,
"elevation": 3,
"movement_type": "MOVEMENT_TYPE_LOOK_AROUND",
"movement_range_x": 0,
"movement_range_y": 0,
"trainer_type": "TRAINER_TYPE_NONE",
"trainer_sight_or_berry_tree_id": "VAR_TEMP_0",
"script": "NULL",
"flag": "FLAG_TEMP_1"
},
{
"graphics_id": "OBJ_EVENT_GFX_VAR_1",
"x": 49,
"y": 2,
"elevation": 3,
"movement_type": "MOVEMENT_TYPE_LOOK_AROUND",
"movement_range_x": 0,
"movement_range_y": 0,
"trainer_type": "TRAINER_TYPE_NONE",
"trainer_sight_or_berry_tree_id": "VAR_TEMP_1",
"script": "NULL",
"flag": "FLAG_TEMP_2"
}
],
"warp_events": [

View File

@ -1,13 +1,61 @@
.set LOCALID_DAYCARE_MAN, 3
.set LOCALID_DAYCARE_MON_0, 25
.set LOCALID_DAYCARE_MON_1, 26
Route117_MapScripts::
map_script MAP_SCRIPT_ON_TRANSITION, Route117_OnTransition
.byte 0
.macro getdaycaregfx var0:req var1:req var2:req var3:req
callfunc ScrFunc_getdaycaregfx
.2byte \var0
.2byte \var1
.2byte \var2
.2byte \var3
.endm
Route117_OnTransition:
call Route117_EventScript_TryMoveDayCareMan
@ set flags for OW daycare mons
setflag FLAG_TEMP_1
setflag FLAG_TEMP_2
getdaycaregfx VAR_OBJ_GFX_ID_0, VAR_OBJ_GFX_ID_1, VAR_TEMP_0, VAR_TEMP_1
switch VAR_RESULT
case 2, Route117_EventScript_ShowDaycareMon1
case 1, Route117_EventScript_ShowDaycareMon0
end
Route117_EventScript_ShowDaycareMon1:
@ set pokemon movement type based on compatibility
special SetDaycareCompatibilityString
@ 0:
call_if_eq VAR_RESULT, PARENTS_INCOMPATIBLE, Route117_EventScript_DaycareMonIncompatible
@ 20: do nothing if low compatibility
@ call_if_eq VAR_RESULT, PARENTS_LOW_COMPATIBILITY, Route117_EventScript_DaycareMonLowCompatibility
@ 50:
call_if_eq VAR_RESULT, PARENTS_MED_COMPATIBILITY, Route117_EventScript_DaycareMonMedCompatibility
@ 70:
call_if_eq VAR_RESULT, PARENTS_MAX_COMPATIBILITY, Route117_EventScript_DaycareMonMaxCompatibility
clearflag FLAG_TEMP_2
Route117_EventScript_ShowDaycareMon0:
clearflag FLAG_TEMP_1
end
Route117_EventScript_DaycareMonIncompatible: @ mons never face each other
setobjectmovementtype LOCALID_DAYCARE_MON_0, MOVEMENT_TYPE_FACE_DOWN_UP_AND_LEFT
setobjectmovementtype LOCALID_DAYCARE_MON_1, MOVEMENT_TYPE_FACE_DOWN_UP_AND_RIGHT
return
Route117_EventScript_DaycareMonMedCompatibility: @ down and towards each other
setobjectmovementtype LOCALID_DAYCARE_MON_0, MOVEMENT_TYPE_FACE_DOWN_AND_RIGHT
setobjectmovementtype LOCALID_DAYCARE_MON_1, MOVEMENT_TYPE_FACE_DOWN_AND_LEFT
return
Route117_EventScript_DaycareMonMaxCompatibility: @ facing; walk in place
setobjectmovementtype LOCALID_DAYCARE_MON_0, MOVEMENT_TYPE_WALK_IN_PLACE_RIGHT
setobjectmovementtype LOCALID_DAYCARE_MON_1, MOVEMENT_TYPE_WALK_IN_PLACE_LEFT
return
Route117_EventScript_TryMoveDayCareMan::
goto_if_unset FLAG_PENDING_DAYCARE_EGG, Route117_EventScript_StopMoveDayCareMan
setobjectxyperm LOCALID_DAYCARE_MAN, 47, 6
@ -205,4 +253,3 @@ Route117_Text_RouteSignMauville:
Route117_Text_DayCareSign:
.string "POKéMON DAY CARE\n"
.string "“Let us raise your POKéMON.”$"

View File

@ -1079,7 +1079,9 @@ static u8 GetDaycareCompatibilityScore(struct DayCare *daycare)
static u8 GetDaycareCompatibilityScoreFromSave(void)
{
return GetDaycareCompatibilityScore(&gSaveBlock1Ptr->daycare);
// Changed to also store result for scripts
gSpecialVar_Result = GetDaycareCompatibilityScore(&gSaveBlock1Ptr->daycare);
return gSpecialVar_Result;
}
void SetDaycareCompatibilityString(void)

View File

@ -41,7 +41,7 @@
#define PLACE_DECORATION_SELECTOR_TAG 0xbe5
#define PLACE_DECORATION_PLAYER_TAG 0x008
#define NUM_DECORATION_FLAGS (FLAG_DECORATION_14 - FLAG_DECORATION_1 + 1)
#define NUM_DECORATION_FLAGS (FLAG_DECORATION_13 - FLAG_DECORATION_1 + 1)
#define tCursorX data[0]
#define tCursorY data[1]
@ -1360,6 +1360,7 @@ static void Task_PlaceDecoration(u8 taskId)
}
break;
case 1:
RemoveFollowingPokemon();
gPaletteFade.bufferTransferDisabled = TRUE;
ConfigureCameraObjectForPlacingDecoration(&sPlaceDecorationGraphicsDataBuffer, gCurDecorationItems[gCurDecorationIndex]);
SetUpDecorationShape(taskId);
@ -1615,6 +1616,14 @@ static bool8 CanPlaceDecoration(u8 taskId, const struct Decoration *decoration)
}
break;
}
// If sprite(like), check if there is an available object event slot for it
if (decoration->permission == DECORPERM_SPRITE) {
for (i = 0; i < NUM_DECORATION_FLAGS; i++)
if (FlagGet(FLAG_DECORATION_1 + i) == TRUE)
return TRUE;
return FALSE;
}
return TRUE;
}
@ -2316,6 +2325,7 @@ static void Task_ContinuePuttingAwayDecorations(u8 taskId)
}
break;
case 1:
RemoveFollowingPokemon();
SetUpPuttingAwayDecorationPlayerAvatar();
FadeInFromBlack();
tState = 2;

View File

@ -1324,11 +1324,12 @@ static u8 InitObjectEventStateFromTemplate(const struct ObjectEventTemplate *tem
objectEvent->active = TRUE;
objectEvent->triggerGroundEffectsOnMove = TRUE;
objectEvent->graphicsId = PackGraphicsId(template);
SetObjectEventDynamicGraphicsId(objectEvent);
if (objectEvent->graphicsId >= OBJ_EVENT_GFX_MON_BASE) {
if (template->script && template->script[0] == 0x7d)
objectEvent->shiny = T1_READ_16(&template->script[2]) >> 15;
else if (template->trainerRange_berryTreeId)
objectEvent->shiny = template->trainerRange_berryTreeId >> 5;
objectEvent->shiny = VarGet(template->trainerRange_berryTreeId) >> 5;
}
objectEvent->movementType = template->movementType;
objectEvent->localId = template->localId;
@ -1349,7 +1350,6 @@ static u8 InitObjectEventStateFromTemplate(const struct ObjectEventTemplate *tem
objectEvent->trainerRange_berryTreeId = template->trainerRange_berryTreeId;
objectEvent->previousMovementDirection = gInitialMovementTypeFacingDirections[template->movementType];
SetObjectEventDirection(objectEvent, objectEvent->previousMovementDirection);
SetObjectEventDynamicGraphicsId(objectEvent);
if (sMovementTypeHasRange[objectEvent->movementType])
{
if (objectEvent->rangeX == 0)
@ -1854,9 +1854,7 @@ static u8 GetOverworldCastformForm(void) {
return CASTFORM_NORMAL;
}
// Retrieve graphic information about the following pokemon, if any
static bool8 GetFollowerInfo(u16 *species, u8 *form, u8 *shiny) {
struct Pokemon *mon = GetFirstLiveMon();
static bool8 GetMonInfo(struct Pokemon * mon, u16 *species, u8 *form, u8 *shiny) {
if (!mon) {
*species = SPECIES_NONE;
*form = 0;
@ -1878,6 +1876,11 @@ static bool8 GetFollowerInfo(u16 *species, u8 *form, u8 *shiny) {
return TRUE;
}
// Retrieve graphic information about the following pokemon, if any
static bool8 GetFollowerInfo(u16 *species, u8 *form, u8 *shiny) {
return GetMonInfo(GetFirstLiveMon(), species, form, shiny);
}
void UpdateFollowingPokemon(void) { // Update following pokemon if any
struct ObjectEvent *objEvent = GetFollowerObject();
struct Sprite *sprite;
@ -10288,3 +10291,25 @@ u8 MovementAction_Fly_Finish(struct ObjectEvent *objectEvent, struct Sprite *spr
{
return TRUE;
}
// Get gfx data from daycare pokemon and store it in vars
bool8 ScrFunc_getdaycaregfx(struct ScriptContext *ctx) {
u16 varGfx[] = {ScriptReadHalfword(ctx), ScriptReadHalfword(ctx)};
u16 varForm[] = {ScriptReadHalfword(ctx), ScriptReadHalfword(ctx)};
u16 specGfx;
u8 form;
u8 shiny;
s32 i;
for (i = 0; i < 2; i++) {
GetMonInfo((struct Pokemon *) &gSaveBlock1Ptr->daycare.mons[i].mon, &specGfx, &form, &shiny);
if (specGfx == SPECIES_NONE)
break;
// Assemble gfx ID like FollowerSetGraphics
specGfx = (OBJ_EVENT_GFX_MON_BASE + specGfx) & OBJ_EVENT_GFX_SPECIES_MASK;
specGfx |= form << OBJ_EVENT_GFX_SPECIES_BITS;
VarSet(varGfx[i], specGfx);
VarSet(varForm[i], form | (shiny << 5));
}
gSpecialVar_Result = i;
return FALSE;
}