Clarify var names and comments

Also preserve chain platform cutscene in spirit based on Link's position
This commit is contained in:
Sarge-117 2022-09-06 10:40:26 -07:00
parent a999a51998
commit a73729b9b1
4 changed files with 44 additions and 32 deletions

View File

@ -94,7 +94,7 @@ static InitChainEntry sInitChain[] = {
ICHAIN_F32(uncullZoneDownward, 400, ICHAIN_STOP),
};
bool blueFireArrowsDC = false;
bool blueFireArrowsEnabledOnMudwallLoad = false;
void BgBreakwall_SetupAction(BgBreakwall* this, BgBreakwallActionFunc actionFunc) {
this->actionFunc = actionFunc;
@ -105,7 +105,8 @@ void BgBreakwall_Init(Actor* thisx, GlobalContext* globalCtx) {
s32 pad;
s32 wallType = ((this->dyna.actor.params >> 13) & 3) & 0xFF;
blueFireArrowsDC = (CVar_GetS32("gBlueFireArrows", 0) != 0);
// Initialize this with the mud wall, so it can't be affected by toggling while the actor is loaded
blueFireArrowsEnabledOnMudwallLoad = (CVar_GetS32("gBlueFireArrows", 0) != 0);
Actor_ProcessInitChain(&this->dyna.actor, sInitChain);
DynaPolyActor_Init(&this->dyna, DPM_UNK);
@ -125,7 +126,7 @@ void BgBreakwall_Init(Actor* thisx, GlobalContext* globalCtx) {
ActorShape_Init(&this->dyna.actor.shape, 0.0f, NULL, 0.0f);
// If "Blue Fire Arrows" are enabled, set up this collider for them
if (blueFireArrowsDC) {
if (blueFireArrowsEnabledOnMudwallLoad) {
Collider_InitQuad(globalCtx, &this->collider);
Collider_SetQuad(globalCtx, &this->collider, &this->dyna.actor, &sIceArrowQuadInit);
} else {
@ -261,7 +262,7 @@ void BgBreakwall_WaitForObject(BgBreakwall* this, GlobalContext* globalCtx) {
void BgBreakwall_Wait(BgBreakwall* this, GlobalContext* globalCtx) {
bool blueFireArrowHit = false;
// If "Blue Fire Arrows" enabled, check this collider for a hit
if (blueFireArrowsDC) {
if (blueFireArrowsEnabledOnMudwallLoad) {
if (this->collider.base.acFlags & AC_HIT) {
if ((this->collider.base.ac != NULL) && (this->collider.base.ac->id == ACTOR_EN_ARROW)) {

View File

@ -14,7 +14,8 @@ void func_808911BC(BgIceShelter* this);
void func_8089107C(BgIceShelter* this, GlobalContext* globalCtx);
void func_808911D4(BgIceShelter* this, GlobalContext* globalCtx);
void CheckIceArrowHit(BgIceShelter* this, ColliderCylinder cylinder, s16 type, GlobalContext* globalCtx);
// For "Blue Fire Arrows" enhancement
void MeltOnIceArrowHit(BgIceShelter* this, ColliderCylinder cylinder, s16 type, GlobalContext* globalCtx);
const ActorInit Bg_Ice_Shelter_InitVars = {
ACTOR_BG_ICE_SHELTER,
@ -95,7 +96,7 @@ static ColliderCylinderInit sIceArrowCylinderInit = {
{ 0, 0, 0, { 0, 0, 0 } },
};
bool blueFireArrows = false;
bool blueFireArrowsEnabledOnRedIceLoad = false;
void func_80890740(BgIceShelter* this, GlobalContext* globalCtx) {
static s16 cylinderRadii[] = { 47, 33, 44, 41, 100 };
@ -103,11 +104,12 @@ void func_80890740(BgIceShelter* this, GlobalContext* globalCtx) {
s32 pad;
s32 type = (this->dyna.actor.params >> 8) & 7;
blueFireArrows = (CVar_GetS32("gBlueFireArrows", 0) != 0);
// Initialize this with the red ice, so it can't be affected by toggling while the actor is loaded
blueFireArrowsEnabledOnRedIceLoad = (CVar_GetS32("gBlueFireArrows", 0) != 0);
Collider_InitCylinder(globalCtx, &this->cylinder1);
// If "Blue Fire Arrows" is enabled, set up a collider on the red ice that responds to them
if (blueFireArrows) {
if (blueFireArrowsEnabledOnRedIceLoad) {
Collider_SetCylinder(globalCtx, &this->cylinder1, &this->dyna.actor, &sIceArrowCylinderInit);
} else {
Collider_SetCylinder(globalCtx, &this->cylinder1, &this->dyna.actor, &sCylinder1Init);
@ -325,9 +327,9 @@ void func_8089107C(BgIceShelter* this, GlobalContext* globalCtx) {
}
}
// If we have "Blue Fire Arrows" enabled, check both cylinders for a hit
if (blueFireArrows) {
CheckIceArrowHit(this, this->cylinder1, type, globalCtx);
CheckIceArrowHit(this, this->cylinder2, type, globalCtx);
if (blueFireArrowsEnabledOnRedIceLoad) {
MeltOnIceArrowHit(this, this->cylinder1, type, globalCtx);
MeltOnIceArrowHit(this, this->cylinder2, type, globalCtx);
}
// Default blue fire check
if (this->cylinder1.base.acFlags & AC_HIT) {
@ -357,8 +359,8 @@ void func_8089107C(BgIceShelter* this, GlobalContext* globalCtx) {
CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->cylinder1.base);
}
// Check for an Ice Arrow hit (for "Blue Fire Arrows" enhancement). Copied from default blue fire check
void CheckIceArrowHit(BgIceShelter* this, ColliderCylinder cylinder, s16 type, GlobalContext* globalCtx) {
// For "Blue Fire Arrows" enhancement: If hit by an Ice Arrow, melt the red ice (copied from the default blue fire function above).
void MeltOnIceArrowHit(BgIceShelter* this, ColliderCylinder cylinder, s16 type, GlobalContext* globalCtx) {
if (cylinder.base.acFlags & AC_HIT) {
cylinder.base.acFlags &= ~AC_HIT;
if ((cylinder.base.ac != NULL) && (cylinder.base.ac->id == ACTOR_EN_ARROW)) {

View File

@ -96,12 +96,19 @@ void BgJyaLift_DelayMove(BgJyaLift* this, GlobalContext* globalCtx) {
if (Flags_GetSwitch(globalCtx, this->dyna.actor.params & 0x3F) || (this->moveDelay > 0)) {
this->moveDelay++;
if (this->moveDelay >= 20) {
// Skip this cutscene if using Sunlight Arrows in rando, since activating the switch while
// not standing on the platform will cause the cutscene to show the unloaded central room
if (!(gSaveContext.n64ddFlag && CVar_GetS32("gSunlightArrows", 0) != 0)) {
// The cutscene of the platform lowering will show the central room in an unloaded state if
// Link is not standing on the platform as it lowers. Therefore check for the Sunlight arrows
// enhancement and if it's enabled, check that Link is on the platform. Otherwise skip it.
if (gSaveContext.n64ddFlag && CVar_GetS32("gSunlightArrows", 0)) {
if (GET_PLAYER(globalCtx)->actor.world.pos.x > -19.0f && GET_PLAYER(globalCtx)->actor.world.pos.x < 139.0f &&
GET_PLAYER(globalCtx)->actor.world.pos.z > -1172.0f && GET_PLAYER(globalCtx)->actor.world.pos.z < -1009.0f) {
OnePointCutscene_Init(globalCtx, 3430, -99, &this->dyna.actor, MAIN_CAM);
}
BgJyaLift_SetupMove(this);
} else {
OnePointCutscene_Init(globalCtx, 3430, -99, &this->dyna.actor, MAIN_CAM);
BgJyaLift_SetupMove(this);
}
BgJyaLift_SetupMove(this);
}
}
}

View File

@ -101,8 +101,8 @@ static ColliderJntSphInit sColliderLightArrowInit = {
sColliderLightArrowElementInit,
};
bool activatedByLightArrow = false;
bool sunLightArrows = false;
bool sunSwitchActivatedByLightArrow = false;
bool sunLightArrowsEnabledOnSunSwitchLoad = false;
static CollisionCheckInfoInit sColChkInfoInit = { 0, 12, 60, MASS_IMMOVABLE };
@ -121,11 +121,13 @@ static InitChainEntry sInitChain[] = {
void ObjLightswitch_InitCollider(ObjLightswitch* this, GlobalContext* globalCtx) {
s32 pad;
sunLightArrows = (CVar_GetS32("gSunlightArrows", 0) != 0);
// Initialize this with the sun switch, so it can't be affected by toggling while the actor is loaded
sunLightArrowsEnabledOnSunSwitchLoad = (CVar_GetS32("gSunlightArrows", 0) != 0);
Collider_InitJntSph(globalCtx, &this->collider);
// If "Sunlight Arrows" is enabled, set up the collider to allow Light Arrow hits
if (sunLightArrows) {
if (sunLightArrowsEnabledOnSunSwitchLoad) {
Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sColliderLightArrowInit, this->colliderItems);
} else {
Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sColliderJntSphInit, this->colliderItems);
@ -251,7 +253,7 @@ void ObjLightswitch_Destroy(Actor* thisx, GlobalContext* globalCtx2) {
// vanishing on its own after activating the sun switch by Light Arrow
// Also prevents the cobra mirror from rotating to face the sun on its own
// Makes sun switches temporary when activated by Light Arrows (will turn off on room exit)
if (activatedByLightArrow && sunLightArrows) {
if (sunSwitchActivatedByLightArrow) {
switch (this->actor.params >> 4 & 3) {
case OBJLIGHTSWITCH_TYPE_STAY_ON:
case OBJLIGHTSWITCH_TYPE_2:
@ -260,7 +262,7 @@ void ObjLightswitch_Destroy(Actor* thisx, GlobalContext* globalCtx2) {
if (this->actor.room != 25) {
Flags_UnsetSwitch(globalCtx, this->actor.params >> 8 & 0x3F);
}
activatedByLightArrow = false;
sunSwitchActivatedByLightArrow = false;
break;
case OBJLIGHTSWITCH_TYPE_BURN:
break;
@ -277,8 +279,8 @@ void ObjLightswitch_SetupOff(ObjLightswitch* this) {
this->color[1] = 125 << 6;
this->color[2] = 255 << 6;
this->alpha = 255 << 6;
if (sunLightArrows) {
activatedByLightArrow = false;
if (sunLightArrowsEnabledOnSunSwitchLoad) {
sunSwitchActivatedByLightArrow = false;
}
}
// A Sun Switch that is currently turned off
@ -291,9 +293,9 @@ void ObjLightswitch_Off(ObjLightswitch* this, GlobalContext* globalCtx) {
ObjLightswitch_SetSwitchFlag(this, globalCtx);
// Remember if we've been activated by a Light Arrow, so we can
// prevent the switch from immediately turning back off
if (sunLightArrows) {
if (sunLightArrowsEnabledOnSunSwitchLoad) {
if (this->collider.base.ac != NULL && this->collider.base.ac->id == ACTOR_EN_ARROW) {
activatedByLightArrow = true;
sunSwitchActivatedByLightArrow = true;
}
}
}
@ -363,9 +365,9 @@ void ObjLightswitch_On(ObjLightswitch* this, GlobalContext* globalCtx) {
ObjLightswitch_SetupTurnOff(this);
}
// If hit by sunlight after already being turned on, then behave as if originally activated by sunlight
if (sunLightArrows && (this->collider.base.acFlags & AC_HIT)) {
if (sunLightArrowsEnabledOnSunSwitchLoad && (this->collider.base.acFlags & AC_HIT)) {
if (this->collider.base.ac != NULL && this->collider.base.ac->id != ACTOR_EN_ARROW) {
activatedByLightArrow = false;
sunSwitchActivatedByLightArrow = false;
}
}
break;
@ -377,15 +379,15 @@ void ObjLightswitch_On(ObjLightswitch* this, GlobalContext* globalCtx) {
break;
case OBJLIGHTSWITCH_TYPE_2:
// If hit by sunlight after already being turned on, then behave as if originally activated by sunlight
if (sunLightArrows && (this->collider.base.acFlags & AC_HIT)) {
if (sunLightArrowsEnabledOnSunSwitchLoad && (this->collider.base.acFlags & AC_HIT)) {
if (this->collider.base.ac != NULL && this->collider.base.ac->id != ACTOR_EN_ARROW) {
activatedByLightArrow = false;
sunSwitchActivatedByLightArrow = false;
}
}
if (!(this->collider.base.acFlags & AC_HIT)) {
if (this->timer >= 7) {
// If we aren't using Enhanced Light Arrows, let the switch turn off normally
if (!activatedByLightArrow) {
if (!sunSwitchActivatedByLightArrow) {
ObjLightswitch_SetupTurnOff(this);
ObjLightswitch_ClearSwitchFlag(this, globalCtx);
}