mirror of
https://github.com/zeldaret/oot.git
synced 2025-06-08 01:21:52 +00:00
Doc pass on EnDoor and transition actors (#1243)
* Doc pass on EnDoor and transition actors * (re)Name things * Forgot to change gameplay_keep.xml * "actor transition index" -> "transition actor index" * Run formatter * Better names for `DOOR_DL_` enum * `TRANSITION_ACTOR_INDEX` -> `GET_TRANSITION_ACTOR_INDEX` * name endoor params macros with get/is, _mask to _flag for the doubledoor flag * Move last ; from `DOOR_ACTOR_BASE` expansion to usage
This commit is contained in:
parent
455321d2e8
commit
6889c275cb
17 changed files with 151 additions and 100 deletions
|
@ -27,8 +27,8 @@
|
|||
<Texture Name="gBgBombwallNormalTex" OutName="bombwall_normal" Format="ci4" Width="32" Height="64" Offset="0x3720" TlutOffset="0x3700"/>
|
||||
<Texture Name="gBgBombWallBrokenTex" OutName="bombwall_broken" Format="ci4" Width="32" Height="64" Offset="0x3B20" TlutOffset="0x3700"/>
|
||||
<DList Name="gFieldDoorDL_004720" Offset="0x4720"/>
|
||||
<DList Name="gFieldDoor1DL" Offset="0x47A0"/>
|
||||
<DList Name="gFieldDoor2DL" Offset="0x4978"/>
|
||||
<DList Name="gFieldDoorLeftDL" Offset="0x47A0"/>
|
||||
<DList Name="gFieldDoorRightDL" Offset="0x4978"/>
|
||||
<Texture Name="gFieldDoor1Tex" OutName="field_door1" Format="i8" Width="32" Height="128" Offset="0x04F50"/>
|
||||
<Texture Name="gFieldDoorKnobTopHalfTex" OutName="field_door_knob_upper" Format="rgba16" Width="16" Height="16" Offset="0x4B50"/>
|
||||
<Texture Name="gFieldDoorKnobTex" OutName="field_door_knob" Format="rgba16" Width="16" Height="16" Offset="0x4D50"/>
|
||||
|
|
|
@ -654,15 +654,15 @@
|
|||
<DList Name="gBoulderFragmentsDL" Offset="0xD340"/>
|
||||
<Texture Name="gRockFragment1Tex" OutName="rock_fragment_1" Format="rgba16" Width="32" Height="32" Offset="0xD4E0"/>
|
||||
<Texture Name="gRockFragment2Tex" OutName="rock_fragment_2" Format="rgba16" Width="32" Height="32" Offset="0xDCE0"/>
|
||||
<Animation Name="gDoor1Anim" Offset="0xE5B4"/>
|
||||
<Animation Name="gDoor2Anim" Offset="0xE6A0"/>
|
||||
<Animation Name="gDoor3Anim" Offset="0xE758"/>
|
||||
<Animation Name="gDoorChildOpeningLeftAnim" Offset="0xE5B4"/>
|
||||
<Animation Name="gDoorChildOpeningRightAnim" Offset="0xE6A0"/>
|
||||
<Animation Name="gDoorAdultOpeningLeftAnim" Offset="0xE758"/>
|
||||
<DList Name="gDoorFrameDL" Offset="0xEC30"/>
|
||||
<DList Name="gDoorLeftDL" Offset="0xECB8"/>
|
||||
<DList Name="gDoorRightDL" Offset="0xEE00"/>
|
||||
<Texture Name="gWoodenDoorTex" OutName="wooden_door" Format="rgba16" Width="32" Height="64" Offset="0xEF38"/>
|
||||
<Skeleton Name="gDoorSkel" Type="Normal" LimbType="Standard" Offset="0xFF78"/>
|
||||
<Animation Name="gDoor4Anim" Offset="0x10038"/>
|
||||
<Animation Name="gDoorAdultOpeningRightAnim" Offset="0x10038"/>
|
||||
<DList Name="gEffDustDL" Offset="0x10050"/>
|
||||
<DList Name="gEffFlash1DL" Offset="0x10130"/>
|
||||
<DList Name="gEffFlash2DL" Offset="0x101A8"/>
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
<File Name="object_haka_door" Segment="6">
|
||||
<Texture Name="object_haka_door_Tex_000000" OutName="tex_00000000" Format="rgba16" Width="32" Height="64" Offset="0x0"/>
|
||||
<DList Name="object_haka_door_DL_001310" Offset="0x1310"/>
|
||||
<DList Name="object_haka_door_DL_0013B8" Offset="0x13B8"/>
|
||||
<DList Name="object_haka_door_DL_001420" Offset="0x1420"/>
|
||||
<DList Name="gShadowDoorLeftDL" Offset="0x13B8"/>
|
||||
<DList Name="gShadowDoorRightDL" Offset="0x1420"/>
|
||||
<Texture Name="object_haka_door_Tex_001490" OutName="tex_00001490" Format="rgba16" Width="32" Height="64" Offset="0x1490"/>
|
||||
<DList Name="object_haka_door_DL_002620" Offset="0x2620"/>
|
||||
<Texture Name="object_haka_door_Tex_002700" OutName="tex_00002700" Format="rgba16" Width="32" Height="64" Offset="0x2700"/>
|
||||
|
|
|
@ -79,8 +79,8 @@
|
|||
<Collision Name="gFireTemplePillarInsertedInGroundCol" Offset="0xD188"/>
|
||||
|
||||
<DList Name="gFireTempleBombableDoorFrameDL" Offset="0xF890"/>
|
||||
<DList Name="gFireTempleDoorWithHandleBackDL" Offset="0xF938"/>
|
||||
<DList Name="gFireTempleDoorWithHandleFrontDL" Offset="0xF998"/>
|
||||
<DList Name="gFireTempleDoorWithHandleRightDL" Offset="0xF938"/>
|
||||
<DList Name="gFireTempleDoorWithHandleLeftDL" Offset="0xF998"/>
|
||||
<DList Name="gFireTempleDoorFrontDL" Offset="0x10CB0"/>
|
||||
<DList Name="gFireTempleDoorBackDL" Offset="0x11F20"/>
|
||||
|
||||
|
|
|
@ -498,6 +498,29 @@ typedef enum {
|
|||
/* 0xFF */ NAVI_ENEMY_NONE = 0xFF
|
||||
} NaviEnemy;
|
||||
|
||||
#define TRANSITION_ACTOR_PARAMS_INDEX_SHIFT 10
|
||||
#define GET_TRANSITION_ACTOR_INDEX(actor) ((u16)(actor)->params >> TRANSITION_ACTOR_PARAMS_INDEX_SHIFT)
|
||||
|
||||
// EnDoor and DoorKiller share openAnim and playerIsOpening
|
||||
// Due to alignment, a substruct cannot be used in the structs of these actors.
|
||||
#define DOOR_ACTOR_BASE \
|
||||
/* 0x0000 */ Actor actor; \
|
||||
/* 0x014C */ SkelAnime skelAnime; \
|
||||
/* 0x0190 */ u8 openAnim; \
|
||||
/* 0x0191 */ u8 playerIsOpening
|
||||
|
||||
typedef struct DoorActorBase {
|
||||
/* 0x0000 */ DOOR_ACTOR_BASE;
|
||||
} DoorActorBase;
|
||||
|
||||
typedef enum {
|
||||
/* 0x00 */ DOOR_OPEN_ANIM_ADULT_L,
|
||||
/* 0x01 */ DOOR_OPEN_ANIM_CHILD_L,
|
||||
/* 0x02 */ DOOR_OPEN_ANIM_ADULT_R,
|
||||
/* 0x03 */ DOOR_OPEN_ANIM_CHILD_R,
|
||||
/* 0x04 */ DOOR_OPEN_ANIM_MAX
|
||||
} DoorOpenAnim;
|
||||
|
||||
#define UPDBGCHECKINFO_FLAG_0 (1 << 0) // check wall
|
||||
#define UPDBGCHECKINFO_FLAG_1 (1 << 1) // check ceiling
|
||||
#define UPDBGCHECKINFO_FLAG_2 (1 << 2) // check floor and water
|
||||
|
|
|
@ -2840,7 +2840,7 @@ void Actor_SpawnTransitionActors(PlayState* play, ActorContext* actorCtx) {
|
|||
(transitionActor->sides[1].room == play->roomCtx.prevRoom.num)))) {
|
||||
Actor_Spawn(actorCtx, play, (s16)(transitionActor->id & 0x1FFF), transitionActor->pos.x,
|
||||
transitionActor->pos.y, transitionActor->pos.z, 0, transitionActor->rotY, 0,
|
||||
(i << 0xA) + transitionActor->params);
|
||||
(i << TRANSITION_ACTOR_PARAMS_INDEX_SHIFT) + transitionActor->params);
|
||||
|
||||
transitionActor->id = -transitionActor->id;
|
||||
numActors = play->transiActorCtx.numActors;
|
||||
|
|
|
@ -1748,7 +1748,7 @@ s32 func_800C0D34(PlayState* this, Actor* actor, s16* yaw) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
transitionActor = &this->transiActorCtx.list[(u16)actor->params >> 10];
|
||||
transitionActor = &this->transiActorCtx.list[GET_TRANSITION_ACTOR_INDEX(actor)];
|
||||
frontRoom = transitionActor->sides[0].room;
|
||||
|
||||
if (frontRoom == transitionActor->sides[1].room) {
|
||||
|
|
|
@ -491,7 +491,7 @@ void DemoEffect_Init(Actor* thisx, PlayState* play2) {
|
|||
this->jewel.type = DEMO_EFFECT_JEWEL_ZORA;
|
||||
this->jewel.isPositionInit = 0;
|
||||
DemoEffect_InitJewel(play, this);
|
||||
Actor_ChangeCategory(play, &play->actorCtx, &this->actor, ACTOR_EN_DOOR);
|
||||
Actor_ChangeCategory(play, &play->actorCtx, &this->actor, ACTORCAT_BOSS);
|
||||
if ((play->sceneNum == SCENE_BDAN) && GET_INFTABLE(INFTABLE_145)) {
|
||||
Actor_Kill(&this->actor);
|
||||
return;
|
||||
|
|
|
@ -117,8 +117,8 @@ void DoorKiller_Init(Actor* thisx, PlayState* play2) {
|
|||
Actor_SetScale(&this->actor, 0.01f);
|
||||
this->timer = 0;
|
||||
this->hasHitPlayerOrGround = 0;
|
||||
this->animStyle = 0;
|
||||
this->playerIsOpening = 0;
|
||||
this->openAnim = 0;
|
||||
this->playerIsOpening = false;
|
||||
|
||||
switch ((u8)(this->actor.params & 0xFF)) {
|
||||
case DOOR_KILLER_DOOR:
|
||||
|
@ -416,7 +416,7 @@ void DoorKiller_Wait(DoorKiller* this, PlayState* play) {
|
|||
if (this->playerIsOpening) {
|
||||
this->actionFunc = DoorKiller_WaitBeforeWobble;
|
||||
this->timer = 10;
|
||||
this->playerIsOpening = 0;
|
||||
this->playerIsOpening = false;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
/*
|
||||
* Associated switch flag: (params >> 8) & 0x3F
|
||||
* ((params >> 8) & 0x3F) == 0x3F means no switch flag is checked / set
|
||||
*/
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
/* 0x00 */ s16 objectId;
|
||||
|
@ -19,10 +19,7 @@ struct DoorKiller;
|
|||
typedef void (*DoorKillerActionFunc)(struct DoorKiller*, PlayState*);
|
||||
|
||||
typedef struct DoorKiller {
|
||||
/* 0x0000 */ Actor actor;
|
||||
/* 0x014C */ SkelAnime skelAnime;
|
||||
/* 0x0190 */ u8 animStyle; // Must be at same offset as animStyle in EnDoor due to the cast in func_80839800
|
||||
/* 0x0191 */ u8 playerIsOpening; // Must be at same offset as playerIsOpening in EnDoor
|
||||
/* 0x0000 */ DOOR_ACTOR_BASE;
|
||||
/* 0x0192 */ Vec3s jointTable[9];
|
||||
/* 0x01C8 */ ColliderCylinder colliderCylinder;
|
||||
/* 0x0214 */ void* texture;
|
||||
|
|
|
@ -174,7 +174,7 @@ void DoorShutter_SetupAction(DoorShutter* this, DoorShutterActionFunc actionFunc
|
|||
}
|
||||
|
||||
s32 DoorShutter_SetupDoor(DoorShutter* this, PlayState* play) {
|
||||
TransitionActorEntry* transitionEntry = &play->transiActorCtx.list[(u16)this->dyna.actor.params >> 0xA];
|
||||
TransitionActorEntry* transitionEntry = &play->transiActorCtx.list[GET_TRANSITION_ACTOR_INDEX(&this->dyna.actor)];
|
||||
s8 frontRoom = transitionEntry->sides[0].room;
|
||||
s32 doorType = this->doorType;
|
||||
ShutterObjectInfo* temp_t0 = &sObjectInfo[this->unk_16B];
|
||||
|
@ -278,7 +278,7 @@ void DoorShutter_Destroy(Actor* thisx, PlayState* play) {
|
|||
|
||||
DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId);
|
||||
if (this->dyna.actor.room >= 0) {
|
||||
s32 transitionActorId = (u16)this->dyna.actor.params >> 0xA;
|
||||
s32 transitionActorId = GET_TRANSITION_ACTOR_INDEX(&this->dyna.actor);
|
||||
|
||||
play->transiActorCtx.list[transitionActorId].id *= -1;
|
||||
}
|
||||
|
@ -540,7 +540,7 @@ void func_80997220(DoorShutter* this, PlayState* play) {
|
|||
|
||||
func_8002DBD0(&this->dyna.actor, &vec, &player->actor.world.pos);
|
||||
this->dyna.actor.room =
|
||||
play->transiActorCtx.list[(u16)this->dyna.actor.params >> 0xA].sides[(vec.z < 0.0f) ? 0 : 1].room;
|
||||
play->transiActorCtx.list[GET_TRANSITION_ACTOR_INDEX(&this->dyna.actor)].sides[(vec.z < 0.0f) ? 0 : 1].room;
|
||||
if (room != this->dyna.actor.room) {
|
||||
Room tempRoom = play->roomCtx.curRoom;
|
||||
|
||||
|
@ -727,7 +727,8 @@ void DoorShutter_Draw(Actor* thisx, PlayState* play) {
|
|||
}
|
||||
} else {
|
||||
if (sp70->b != NULL) {
|
||||
TransitionActorEntry* transitionEntry = &play->transiActorCtx.list[(u16)this->dyna.actor.params >> 0xA];
|
||||
TransitionActorEntry* transitionEntry =
|
||||
&play->transiActorCtx.list[GET_TRANSITION_ACTOR_INDEX(&this->dyna.actor)];
|
||||
|
||||
if (play->roomCtx.prevRoom.num >= 0 ||
|
||||
transitionEntry->sides[0].room == transitionEntry->sides[1].room) {
|
||||
|
|
|
@ -44,17 +44,32 @@ const ActorInit En_Door_InitVars = {
|
|||
(ActorFunc)EnDoor_Draw,
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
/* 0x00 */ s16 sceneNum;
|
||||
/* 0x02 */ u8 dListIndex;
|
||||
/* 0x04 */ s16 objectId;
|
||||
} EnDoorInfo;
|
||||
|
||||
typedef enum {
|
||||
/* 0 */ DOOR_DL_DEFAULT,
|
||||
/* 1 */ DOOR_DL_FIRE_TEMPLE,
|
||||
/* 2 */ DOOR_DL_WATER_TEMPLE,
|
||||
/* 3 */ DOOR_DL_SHADOW,
|
||||
/* 4 */ DOOR_DL_DEFAULT_FIELD_KEEP,
|
||||
/* 5 */ DOOR_DL_MAX
|
||||
} EnDoorDListIndex;
|
||||
|
||||
/**
|
||||
* Controls which object and display lists to use in a given scene
|
||||
*/
|
||||
static EnDoorInfo sDoorInfo[] = {
|
||||
{ SCENE_HIDAN, 1, OBJECT_HIDAN_OBJECTS },
|
||||
{ SCENE_MIZUSIN, 2, OBJECT_MIZU_OBJECTS },
|
||||
{ SCENE_HAKADAN, 3, OBJECT_HAKA_DOOR },
|
||||
{ SCENE_HAKADANCH, 3, OBJECT_HAKA_DOOR },
|
||||
{ SCENE_HIDAN, DOOR_DL_FIRE_TEMPLE, OBJECT_HIDAN_OBJECTS },
|
||||
{ SCENE_MIZUSIN, DOOR_DL_WATER_TEMPLE, OBJECT_MIZU_OBJECTS },
|
||||
{ SCENE_HAKADAN, DOOR_DL_SHADOW, OBJECT_HAKA_DOOR },
|
||||
{ SCENE_HAKADANCH, DOOR_DL_SHADOW, OBJECT_HAKA_DOOR },
|
||||
// KEEP objects should remain last and in this order
|
||||
{ -1, 0, OBJECT_GAMEPLAY_KEEP },
|
||||
{ -1, 4, OBJECT_GAMEPLAY_FIELD_KEEP },
|
||||
{ -1, DOOR_DL_DEFAULT, OBJECT_GAMEPLAY_KEEP },
|
||||
{ -1, DOOR_DL_DEFAULT_FIELD_KEEP, OBJECT_GAMEPLAY_FIELD_KEEP },
|
||||
};
|
||||
|
||||
static InitChainEntry sInitChain[] = {
|
||||
|
@ -62,18 +77,33 @@ static InitChainEntry sInitChain[] = {
|
|||
ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_STOP),
|
||||
};
|
||||
|
||||
static AnimationHeader* sDoorAnims[] = { &gDoor3Anim, &gDoor1Anim, &gDoor4Anim, &gDoor2Anim };
|
||||
static AnimationHeader* sDoorAnims[DOOR_OPEN_ANIM_MAX] = {
|
||||
&gDoorAdultOpeningLeftAnim, // DOOR_OPEN_ANIM_ADULT_L
|
||||
&gDoorChildOpeningLeftAnim, // DOOR_OPEN_ANIM_CHILD_L
|
||||
&gDoorAdultOpeningRightAnim, // DOOR_OPEN_ANIM_ADULT_R
|
||||
&gDoorChildOpeningRightAnim, // DOOR_OPEN_ANIM_CHILD_R
|
||||
};
|
||||
|
||||
static u8 sDoorAnimOpenFrames[] = { 25, 25, 25, 25 };
|
||||
static u8 sDoorAnimOpenFrames[DOOR_OPEN_ANIM_MAX] = {
|
||||
25, // DOOR_OPEN_ANIM_ADULT_L
|
||||
25, // DOOR_OPEN_ANIM_CHILD_L
|
||||
25, // DOOR_OPEN_ANIM_ADULT_R
|
||||
25, // DOOR_OPEN_ANIM_CHILD_R
|
||||
};
|
||||
|
||||
static u8 sDoorAnimCloseFrames[] = { 60, 70, 60, 70 };
|
||||
static u8 sDoorAnimCloseFrames[DOOR_OPEN_ANIM_MAX] = {
|
||||
60, // DOOR_OPEN_ANIM_ADULT_L
|
||||
70, // DOOR_OPEN_ANIM_CHILD_L
|
||||
60, // DOOR_OPEN_ANIM_ADULT_R
|
||||
70, // DOOR_OPEN_ANIM_CHILD_R
|
||||
};
|
||||
|
||||
static Gfx* sDoorDLists[5][2] = {
|
||||
{ gDoorLeftDL, gDoorRightDL },
|
||||
{ gFireTempleDoorWithHandleFrontDL, gFireTempleDoorWithHandleBackDL },
|
||||
{ gWaterTempleDoorLeftDL, gWaterTempleDoorRightDL },
|
||||
{ object_haka_door_DL_0013B8, object_haka_door_DL_001420 },
|
||||
{ gFieldDoor1DL, gFieldDoor2DL },
|
||||
static Gfx* sDoorDLists[DOOR_DL_MAX][2] = {
|
||||
{ gDoorLeftDL, gDoorRightDL }, // DOOR_DL_DEFAULT
|
||||
{ gFireTempleDoorWithHandleLeftDL, gFireTempleDoorWithHandleRightDL }, // DOOR_DL_FIRE_TEMPLE
|
||||
{ gWaterTempleDoorLeftDL, gWaterTempleDoorRightDL }, // DOOR_DL_WATER_TEMPLE
|
||||
{ gShadowDoorLeftDL, gShadowDoorRightDL }, // DOOR_DL_SHADOW
|
||||
{ gFieldDoorLeftDL, gFieldDoorRightDL }, // DOOR_DL_DEFAULT_FIELD_KEEP
|
||||
};
|
||||
|
||||
void EnDoor_Init(Actor* thisx, PlayState* play2) {
|
||||
|
@ -87,7 +117,8 @@ void EnDoor_Init(Actor* thisx, PlayState* play2) {
|
|||
|
||||
objectInfo = &sDoorInfo[0];
|
||||
Actor_ProcessInitChain(&this->actor, sInitChain);
|
||||
SkelAnime_Init(play, &this->skelAnime, &gDoorSkel, &gDoor3Anim, this->jointTable, this->morphTable, 5);
|
||||
SkelAnime_Init(play, &this->skelAnime, &gDoorSkel, &gDoorAdultOpeningLeftAnim, this->jointTable, this->morphTable,
|
||||
5);
|
||||
for (i = 0; i < ARRAY_COUNT(sDoorInfo) - 2; i++, objectInfo++) {
|
||||
if (play->sceneNum == objectInfo->sceneNum) {
|
||||
break;
|
||||
|
@ -113,7 +144,7 @@ void EnDoor_Init(Actor* thisx, PlayState* play2) {
|
|||
}
|
||||
|
||||
// Double doors
|
||||
if (this->actor.params & 0x40) {
|
||||
if (ENDOOR_IS_DOUBLE_DOOR(&this->actor)) {
|
||||
EnDoor* other;
|
||||
|
||||
xOffset = Math_CosS(this->actor.shape.rot.y) * 30.0f;
|
||||
|
@ -121,7 +152,7 @@ void EnDoor_Init(Actor* thisx, PlayState* play2) {
|
|||
other = (EnDoor*)Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_DOOR,
|
||||
this->actor.world.pos.x + xOffset, this->actor.world.pos.y,
|
||||
this->actor.world.pos.z - zOffset, 0, this->actor.shape.rot.y + 0x8000, 0,
|
||||
this->actor.params & ~0x40);
|
||||
this->actor.params & ~ENDOOR_PARAMS_DOUBLE_DOOR_FLAG);
|
||||
if (other != NULL) {
|
||||
other->unk_192 = 1;
|
||||
}
|
||||
|
@ -135,7 +166,7 @@ void EnDoor_Destroy(Actor* thisx, PlayState* play) {
|
|||
TransitionActorEntry* transitionEntry;
|
||||
EnDoor* this = (EnDoor*)thisx;
|
||||
|
||||
transitionEntry = &play->transiActorCtx.list[(u16)this->actor.params >> 0xA];
|
||||
transitionEntry = &play->transiActorCtx.list[GET_TRANSITION_ACTOR_INDEX(&this->actor)];
|
||||
if (transitionEntry->id < 0) {
|
||||
transitionEntry->id = -transitionEntry->id;
|
||||
}
|
||||
|
@ -145,7 +176,7 @@ void EnDoor_SetupType(EnDoor* this, PlayState* play) {
|
|||
s32 doorType;
|
||||
|
||||
if (Object_IsLoaded(&play->objectCtx, this->requiredObjBankIndex)) {
|
||||
doorType = this->actor.params >> 7 & 7;
|
||||
doorType = ENDOOR_GET_TYPE(&this->actor);
|
||||
this->actor.flags &= ~ACTOR_FLAG_4;
|
||||
this->actor.objBankIndex = this->requiredObjBankIndex;
|
||||
this->actionFunc = EnDoor_Idle;
|
||||
|
@ -156,7 +187,7 @@ void EnDoor_SetupType(EnDoor* this, PlayState* play) {
|
|||
}
|
||||
this->actor.world.rot.y = 0x0000;
|
||||
if (doorType == DOOR_LOCKED) {
|
||||
if (!Flags_GetSwitch(play, this->actor.params & 0x3F)) {
|
||||
if (!Flags_GetSwitch(play, ENDOOR_GET_LOCKED_SWITCH_FLAG(&this->actor))) {
|
||||
this->lockTimer = 10;
|
||||
}
|
||||
} else if (doorType == DOOR_AJAR) {
|
||||
|
@ -165,7 +196,7 @@ void EnDoor_SetupType(EnDoor* this, PlayState* play) {
|
|||
this->actor.world.rot.y = -0x1800;
|
||||
}
|
||||
} else if (doorType == DOOR_CHECKABLE) {
|
||||
this->actor.textId = (this->actor.params & 0x3F) + 0x0200;
|
||||
this->actor.textId = ENDOOR_GET_CHECKABLE_TEXT_ID(&this->actor) + 0x0200;
|
||||
if (this->actor.textId == 0x0229 && !GET_EVENTCHKINF(EVENTCHKINF_14)) {
|
||||
// Talon's house door. If Talon has not been woken up at Hyrule Castle
|
||||
// this door should be openable at any time of day.
|
||||
|
@ -178,7 +209,7 @@ void EnDoor_SetupType(EnDoor* this, PlayState* play) {
|
|||
}
|
||||
}
|
||||
// Replace the door type it was loaded with by the new type
|
||||
this->actor.params = (this->actor.params & ~0x380) | (doorType << 7);
|
||||
this->actor.params = (this->actor.params & ~ENDOOR_PARAMS_TYPE_MASK) | (doorType << ENDOOR_PARAMS_TYPE_SHIFT);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -188,15 +219,15 @@ void EnDoor_Idle(EnDoor* this, PlayState* play) {
|
|||
Vec3f playerPosRelToDoor;
|
||||
s16 yawDiff;
|
||||
|
||||
doorType = this->actor.params >> 7 & 7;
|
||||
doorType = ENDOOR_GET_TYPE(&this->actor);
|
||||
func_8002DBD0(&this->actor, &playerPosRelToDoor, &player->actor.world.pos);
|
||||
if (this->playerIsOpening != 0) {
|
||||
if (this->playerIsOpening) {
|
||||
this->actionFunc = EnDoor_Open;
|
||||
Animation_PlayOnceSetSpeed(&this->skelAnime, sDoorAnims[this->animStyle],
|
||||
Animation_PlayOnceSetSpeed(&this->skelAnime, sDoorAnims[this->openAnim],
|
||||
(player->stateFlags1 & PLAYER_STATE1_27) ? 0.75f : 1.5f);
|
||||
if (this->lockTimer != 0) {
|
||||
gSaveContext.inventory.dungeonKeys[gSaveContext.mapIndex]--;
|
||||
Flags_SetSwitch(play, this->actor.params & 0x3F);
|
||||
Flags_SetSwitch(play, ENDOOR_GET_LOCKED_SWITCH_FLAG(&this->actor));
|
||||
Audio_PlayActorSfx2(&this->actor, NA_SE_EV_CHAIN_KEY_UNLOCK);
|
||||
}
|
||||
} else if (!Player_InCsMode(play)) {
|
||||
|
@ -268,8 +299,8 @@ void EnDoor_Open(EnDoor* this, PlayState* play) {
|
|||
if (DECR(this->lockTimer) == 0) {
|
||||
if (SkelAnime_Update(&this->skelAnime)) {
|
||||
this->actionFunc = EnDoor_Idle;
|
||||
this->playerIsOpening = 0;
|
||||
} else if (Animation_OnFrame(&this->skelAnime, sDoorAnimOpenFrames[this->animStyle])) {
|
||||
this->playerIsOpening = false;
|
||||
} else if (Animation_OnFrame(&this->skelAnime, sDoorAnimOpenFrames[this->openAnim])) {
|
||||
Audio_PlayActorSfx2(&this->actor, (play->sceneNum == SCENE_HAKADAN || play->sceneNum == SCENE_HAKADANCH ||
|
||||
play->sceneNum == SCENE_HIDAN)
|
||||
? NA_SE_EV_IRON_DOOR_OPEN
|
||||
|
@ -280,7 +311,7 @@ void EnDoor_Open(EnDoor* this, PlayState* play) {
|
|||
EffectSsBubble_Spawn(play, &this->actor.world.pos, 60.0f, 100.0f, 50.0f, 0.15f);
|
||||
}
|
||||
}
|
||||
} else if (Animation_OnFrame(&this->skelAnime, sDoorAnimCloseFrames[this->animStyle])) {
|
||||
} else if (Animation_OnFrame(&this->skelAnime, sDoorAnimCloseFrames[this->openAnim])) {
|
||||
Audio_PlayActorSfx2(&this->actor, (play->sceneNum == SCENE_HAKADAN || play->sceneNum == SCENE_HAKADANCH ||
|
||||
play->sceneNum == SCENE_HIDAN)
|
||||
? NA_SE_EV_IRON_DOOR_CLOSE
|
||||
|
@ -306,10 +337,11 @@ s32 EnDoor_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f*
|
|||
|
||||
if (limbIndex == 4) {
|
||||
doorDLists = sDoorDLists[this->dListIndex];
|
||||
transitionEntry = &play->transiActorCtx.list[(u16)this->actor.params >> 0xA];
|
||||
transitionEntry = &play->transiActorCtx.list[GET_TRANSITION_ACTOR_INDEX(&this->actor)];
|
||||
rot->z += this->actor.world.rot.y;
|
||||
if ((play->roomCtx.prevRoom.num >= 0) || (transitionEntry->sides[0].room == transitionEntry->sides[1].room)) {
|
||||
rotDiff = ((this->actor.shape.rot.y + this->skelAnime.jointTable[3].z) + rot->z) -
|
||||
// Draw the side of the door that is visible to the camera
|
||||
rotDiff = this->actor.shape.rot.y + this->skelAnime.jointTable[3].z + rot->z -
|
||||
Math_Vec3f_Yaw(&play->view.eye, &this->actor.world.pos);
|
||||
*dList = (ABS(rotDiff) < 0x4000) ? doorDLists[0] : doorDLists[1];
|
||||
} else {
|
||||
|
|
|
@ -22,11 +22,14 @@
|
|||
*
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
/* 0x00 */ s16 sceneNum;
|
||||
/* 0x02 */ u8 dListIndex;
|
||||
/* 0x04 */ s16 objectId;
|
||||
} EnDoorInfo;
|
||||
#define ENDOOR_PARAMS_TYPE_SHIFT 7
|
||||
#define ENDOOR_PARAMS_TYPE_MASK (7 << ENDOOR_PARAMS_TYPE_SHIFT)
|
||||
#define ENDOOR_GET_TYPE(thisx) ((thisx)->params >> ENDOOR_PARAMS_TYPE_SHIFT & 7)
|
||||
#define ENDOOR_PARAMS_DOUBLE_DOOR_FLAG 0x40
|
||||
#define ENDOOR_IS_DOUBLE_DOOR(thisx) ((thisx)->params & ENDOOR_PARAMS_DOUBLE_DOOR_FLAG)
|
||||
#define ENDOOR_GET_LOCKED_SWITCH_FLAG(thisx) ((thisx)->params & 0x3F)
|
||||
#define ENDOOR_GET_CHECKABLE_TEXT_ID(thisx) ((thisx)->params & 0x3F)
|
||||
|
||||
|
||||
typedef enum {
|
||||
/* 0x00 */ DOOR_ROOMLOAD, // loads rooms
|
||||
|
@ -44,10 +47,7 @@ struct EnDoor;
|
|||
typedef void (*EnDoorActionFunc)(struct EnDoor*, PlayState*);
|
||||
|
||||
typedef struct EnDoor {
|
||||
/* 0x0000 */ Actor actor;
|
||||
/* 0x014C */ SkelAnime skelAnime;
|
||||
/* 0x0190 */ u8 animStyle; // Must be at same offset as animStyle in DoorKiller due to the cast in func_80839800
|
||||
/* 0x0191 */ u8 playerIsOpening; // Must be at same offset as playerIsOpening in DoorKiller due to the cast in func_80839800
|
||||
/* 0x0000 */ DOOR_ACTOR_BASE;
|
||||
/* 0x0192 */ u8 unk_192;
|
||||
/* 0x0193 */ s8 requiredObjBankIndex;
|
||||
/* 0x0194 */ s8 dListIndex;
|
||||
|
|
|
@ -93,7 +93,7 @@ void EnHeishi2_Init(Actor* thisx, PlayState* play) {
|
|||
if ((this->type == 6) || (this->type == 9)) {
|
||||
this->actor.draw = EnHeishi2_DrawKingGuard;
|
||||
this->actor.flags &= ~ACTOR_FLAG_0;
|
||||
Actor_ChangeCategory(play, &play->actorCtx, &this->actor, 6);
|
||||
Actor_ChangeCategory(play, &play->actorCtx, &this->actor, ACTORCAT_PROP);
|
||||
if (this->type == 6) {
|
||||
this->actionFunc = EnHeishi2_DoNothing1;
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ void EnHoll_Init(Actor* thisx, PlayState* play) {
|
|||
}
|
||||
|
||||
void EnHoll_Destroy(Actor* thisx, PlayState* play) {
|
||||
s32 transitionActorIdx = (u16)thisx->params >> 0xA;
|
||||
s32 transitionActorIdx = GET_TRANSITION_ACTOR_INDEX(thisx);
|
||||
TransitionActorEntry* transitionEntry = &play->transiActorCtx.list[transitionActorIdx];
|
||||
|
||||
transitionEntry->id = -transitionEntry->id;
|
||||
|
@ -129,7 +129,7 @@ void func_80A58DD4(EnHoll* this, PlayState* play) {
|
|||
absZ = fabsf(vec.z);
|
||||
if (vec.y > PLANE_Y_MIN && vec.y < PLANE_Y_MAX && fabsf(vec.x) < PLANE_HALFWIDTH &&
|
||||
absZ < sHorizTriggerDists[phi_t0][0]) {
|
||||
transitionActorIdx = (u16)this->actor.params >> 0xA;
|
||||
transitionActorIdx = GET_TRANSITION_ACTOR_INDEX(&this->actor);
|
||||
if (absZ > sHorizTriggerDists[phi_t0][1]) {
|
||||
if (play->roomCtx.prevRoom.num >= 0 && play->roomCtx.status == 0) {
|
||||
this->actor.room = play->transiActorCtx.list[transitionActorIdx].sides[this->side].room;
|
||||
|
@ -167,7 +167,7 @@ void func_80A59014(EnHoll* this, PlayState* play) {
|
|||
temp = EnHoll_IsKokiriLayer8();
|
||||
if (temp || (PLANE_Y_MIN < vec.y && vec.y < PLANE_Y_MAX && fabsf(vec.x) < planeHalfWidth &&
|
||||
(absZ = fabsf(vec.z), 100.0f > absZ && absZ > 50.0f))) {
|
||||
s32 transitionActorIdx = (u16)this->actor.params >> 0xA;
|
||||
s32 transitionActorIdx = GET_TRANSITION_ACTOR_INDEX(&this->actor);
|
||||
s32 side = (vec.z < 0.0f) ? 0 : 1;
|
||||
TransitionActorEntry* transitionEntry = &play->transiActorCtx.list[transitionActorIdx];
|
||||
s32 room = transitionEntry->sides[side].room;
|
||||
|
@ -190,7 +190,7 @@ void func_80A591C0(EnHoll* this, PlayState* play) {
|
|||
s32 transitionActorIdx;
|
||||
|
||||
if (this->actor.xzDistToPlayer < 500.0f && absY < 700.0f) {
|
||||
transitionActorIdx = (u16)this->actor.params >> 0xA;
|
||||
transitionActorIdx = GET_TRANSITION_ACTOR_INDEX(&this->actor);
|
||||
if (absY < 95.0f) {
|
||||
play->unk_11E18 = 0xFF;
|
||||
} else if (absY > 605.0f) {
|
||||
|
@ -228,7 +228,7 @@ void func_80A593A4(EnHoll* this, PlayState* play) {
|
|||
play->unk_11E18 = (200.0f - absY) * 1.7f;
|
||||
}
|
||||
if (absY > 50.0f) {
|
||||
transitionActorIdx = (u16)this->actor.params >> 0xA;
|
||||
transitionActorIdx = GET_TRANSITION_ACTOR_INDEX(&this->actor);
|
||||
side = (0.0f < this->actor.yDistToPlayer) ? 0 : 1;
|
||||
this->actor.room = play->transiActorCtx.list[transitionActorIdx].sides[side].room;
|
||||
if (this->actor.room != play->roomCtx.curRoom.num &&
|
||||
|
@ -252,7 +252,7 @@ void func_80A59520(EnHoll* this, PlayState* play) {
|
|||
if (this->actor.xzDistToPlayer < 120.0f) {
|
||||
absY = fabsf(this->actor.yDistToPlayer);
|
||||
if (absY < 200.0f && absY > 50.0f) {
|
||||
transitionActorIdx = (u16)this->actor.params >> 0xA;
|
||||
transitionActorIdx = GET_TRANSITION_ACTOR_INDEX(&this->actor);
|
||||
side = (0.0f < this->actor.yDistToPlayer) ? 0 : 1;
|
||||
this->actor.room = play->transiActorCtx.list[transitionActorIdx].sides[side].room;
|
||||
if (this->actor.room != play->roomCtx.curRoom.num &&
|
||||
|
@ -281,7 +281,7 @@ void func_80A59618(EnHoll* this, PlayState* play) {
|
|||
absZ = fabsf(vec.z);
|
||||
if (PLANE_Y_MIN < vec.y && vec.y < PLANE_Y_MAX && fabsf(vec.x) < PLANE_HALFWIDTH_2 && absZ < 100.0f) {
|
||||
this->unk_14F = 1;
|
||||
transitionActorIdx = (u16)this->actor.params >> 0xA;
|
||||
transitionActorIdx = GET_TRANSITION_ACTOR_INDEX(&this->actor);
|
||||
play->unk_11E18 = 0xFF - (s32)((absZ - 50.0f) * 5.9f);
|
||||
if (play->unk_11E18 >= 0x100) {
|
||||
play->unk_11E18 = 0xFF;
|
||||
|
|
|
@ -379,7 +379,7 @@ void EnPoh_SetupDeath(EnPoh* this, PlayState* play) {
|
|||
if (this->infoIdx != EN_POH_INFO_COMPOSER) {
|
||||
this->actor.shape.rot.x = -0x8000;
|
||||
}
|
||||
Actor_ChangeCategory(play, &play->actorCtx, &this->actor, 8);
|
||||
Actor_ChangeCategory(play, &play->actorCtx, &this->actor, ACTORCAT_MISC);
|
||||
this->unk_198 = 60;
|
||||
this->actionFunc = EnPoh_Death;
|
||||
}
|
||||
|
|
|
@ -39,13 +39,6 @@ typedef struct {
|
|||
#define GET_ITEM_NONE \
|
||||
{ ITEM_NONE, 0, 0, 0, OBJECT_INVALID }
|
||||
|
||||
typedef enum {
|
||||
/* 0x00 */ KNOB_ANIM_ADULT_L,
|
||||
/* 0x01 */ KNOB_ANIM_CHILD_L,
|
||||
/* 0x02 */ KNOB_ANIM_ADULT_R,
|
||||
/* 0x03 */ KNOB_ANIM_CHILD_R
|
||||
} KnobDoorAnim;
|
||||
|
||||
typedef struct {
|
||||
/* 0x00 */ u8 itemId;
|
||||
/* 0x02 */ s16 actorId;
|
||||
|
@ -4308,7 +4301,7 @@ s32 func_80839768(PlayState* play, Player* this, Vec3f* arg2, CollisionPoly** ar
|
|||
|
||||
s32 func_80839800(Player* this, PlayState* play) {
|
||||
DoorShutter* doorShutter;
|
||||
EnDoor* door; // Can also be DoorKiller*
|
||||
DoorActorBase* door;
|
||||
s32 doorDirection;
|
||||
f32 sp78;
|
||||
f32 sp74;
|
||||
|
@ -4373,26 +4366,26 @@ s32 func_80839800(Player* this, PlayState* play) {
|
|||
}
|
||||
|
||||
if (doorShutter->dyna.actor.category == ACTORCAT_DOOR) {
|
||||
this->doorBgCamIndex = play->transiActorCtx.list[(u16)doorShutter->dyna.actor.params >> 10]
|
||||
.sides[(doorDirection > 0) ? 0 : 1]
|
||||
.bgCamIndex;
|
||||
this->doorBgCamIndex =
|
||||
play->transiActorCtx.list[GET_TRANSITION_ACTOR_INDEX(&doorShutter->dyna.actor)]
|
||||
.sides[(doorDirection > 0) ? 0 : 1]
|
||||
.bgCamIndex;
|
||||
|
||||
Actor_DisableLens(play);
|
||||
}
|
||||
} else {
|
||||
// This actor can be either EnDoor or DoorKiller.
|
||||
// Don't try to access any struct vars other than `animStyle` and `playerIsOpening`! These two variables
|
||||
// are common across the two actors' structs however most other variables are not!
|
||||
door = (EnDoor*)doorActor;
|
||||
// The door actor can be either EnDoor or DoorKiller.
|
||||
door = (DoorActorBase*)doorActor;
|
||||
|
||||
door->animStyle = (doorDirection < 0.0f) ? (LINK_IS_ADULT ? KNOB_ANIM_ADULT_L : KNOB_ANIM_CHILD_L)
|
||||
: (LINK_IS_ADULT ? KNOB_ANIM_ADULT_R : KNOB_ANIM_CHILD_R);
|
||||
door->openAnim = (doorDirection < 0.0f)
|
||||
? (LINK_IS_ADULT ? DOOR_OPEN_ANIM_ADULT_L : DOOR_OPEN_ANIM_CHILD_L)
|
||||
: (LINK_IS_ADULT ? DOOR_OPEN_ANIM_ADULT_R : DOOR_OPEN_ANIM_CHILD_R);
|
||||
|
||||
if (door->animStyle == KNOB_ANIM_ADULT_L) {
|
||||
if (door->openAnim == DOOR_OPEN_ANIM_ADULT_L) {
|
||||
sp5C = GET_PLAYER_ANIM(PLAYER_ANIMGROUP_9, this->modelAnimType);
|
||||
} else if (door->animStyle == KNOB_ANIM_CHILD_L) {
|
||||
} else if (door->openAnim == DOOR_OPEN_ANIM_CHILD_L) {
|
||||
sp5C = GET_PLAYER_ANIM(PLAYER_ANIMGROUP_10, this->modelAnimType);
|
||||
} else if (door->animStyle == KNOB_ANIM_ADULT_R) {
|
||||
} else if (door->openAnim == DOOR_OPEN_ANIM_ADULT_R) {
|
||||
sp5C = GET_PLAYER_ANIM(PLAYER_ANIMGROUP_11, this->modelAnimType);
|
||||
} else {
|
||||
sp5C = GET_PLAYER_ANIM(PLAYER_ANIMGROUP_12, this->modelAnimType);
|
||||
|
@ -4422,17 +4415,21 @@ s32 func_80839800(Player* this, PlayState* play) {
|
|||
func_80832224(this);
|
||||
func_80832F54(play, this, 0x28F);
|
||||
|
||||
// If this door is the second half of a double door (spawned as child)
|
||||
if (doorActor->parent != NULL) {
|
||||
doorDirection = -doorDirection;
|
||||
}
|
||||
|
||||
door->playerIsOpening = 1;
|
||||
door->playerIsOpening = true;
|
||||
|
||||
// If the door actor is not DoorKiller
|
||||
if (this->doorType != PLAYER_DOORTYPE_FAKE) {
|
||||
// The door actor is EnDoor
|
||||
|
||||
this->stateFlags1 |= PLAYER_STATE1_29;
|
||||
Actor_DisableLens(play);
|
||||
|
||||
if (((doorActor->params >> 7) & 7) == 3) {
|
||||
if (ENDOOR_GET_TYPE(doorActor) == DOOR_SCENEEXIT) {
|
||||
sp4C.x = doorActor->world.pos.x - (sp6C * sp74);
|
||||
sp4C.y = doorActor->world.pos.y + 10.0f;
|
||||
sp4C.z = doorActor->world.pos.z - (sp6C * sp78);
|
||||
|
@ -4445,7 +4442,7 @@ s32 func_80839800(Player* this, PlayState* play) {
|
|||
}
|
||||
} else {
|
||||
Camera_ChangeDoorCam(Play_GetCamera(play, CAM_ID_MAIN), doorActor,
|
||||
play->transiActorCtx.list[(u16)doorActor->params >> 10]
|
||||
play->transiActorCtx.list[GET_TRANSITION_ACTOR_INDEX(doorActor)]
|
||||
.sides[(doorDirection > 0) ? 0 : 1]
|
||||
.bgCamIndex,
|
||||
0, 38.0f * D_808535EC, 26.0f * D_808535EC, 10.0f * D_808535EC);
|
||||
|
@ -4454,8 +4451,9 @@ s32 func_80839800(Player* this, PlayState* play) {
|
|||
}
|
||||
|
||||
if ((this->doorType != PLAYER_DOORTYPE_FAKE) && (doorActor->category == ACTORCAT_DOOR)) {
|
||||
frontRoom =
|
||||
play->transiActorCtx.list[(u16)doorActor->params >> 10].sides[(doorDirection > 0) ? 0 : 1].room;
|
||||
frontRoom = play->transiActorCtx.list[GET_TRANSITION_ACTOR_INDEX(doorActor)]
|
||||
.sides[(doorDirection > 0) ? 0 : 1]
|
||||
.room;
|
||||
|
||||
if ((frontRoom >= 0) && (frontRoom != play->roomCtx.curRoom.num)) {
|
||||
func_8009728C(play, &play->roomCtx, frontRoom);
|
||||
|
|
Loading…
Add table
Reference in a new issue