Implement Enhanced Magic Arrows

Currently as a rando-only enhancement until it can be accounted for in logic
This commit is contained in:
Sarge-117 2022-08-27 22:49:13 -07:00
parent c9755cd05e
commit 669f76d2f4
5 changed files with 197 additions and 12 deletions

View File

@ -59,6 +59,27 @@ static ColliderQuadInit sQuadInit = {
{ { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } },
};
// This quad only used for "Blue Fire Arrows" enhancement
static ColliderQuadInit sIceArrowQuadInit = {
{
COLTYPE_NONE,
AT_NONE,
AC_ON | AC_TYPE_PLAYER,
OC1_NONE,
OC2_TYPE_2,
COLSHAPE_QUAD,
},
{
ELEMTYPE_UNK0,
{ 0x00000000, 0x00, 0x00 },
{ 0xFFCFFFFF, 0x00, 0x00 },
TOUCH_NONE,
BUMP_ON,
OCELEM_NONE,
},
{ { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } },
};
static BombableWallInfo sBombableWallInfo[] = {
{ &object_bwall_Col_000118, object_bwall_DL_000040, 0 },
{ &object_bwall_Col_000118, object_bwall_DL_000040, 0 },
@ -73,6 +94,8 @@ static InitChainEntry sInitChain[] = {
ICHAIN_F32(uncullZoneDownward, 400, ICHAIN_STOP),
};
bool enhancedIceArrow = false;
void BgBreakwall_SetupAction(BgBreakwall* this, BgBreakwallActionFunc actionFunc) {
this->actionFunc = actionFunc;
}
@ -82,6 +105,8 @@ void BgBreakwall_Init(Actor* thisx, GlobalContext* globalCtx) {
s32 pad;
s32 wallType = ((this->dyna.actor.params >> 13) & 3) & 0xFF;
enhancedIceArrow = (gSaveContext.n64ddFlag && (CVar_GetS32("gEnhancedMagicArrows", 0) != 0));
Actor_ProcessInitChain(&this->dyna.actor, sInitChain);
DynaPolyActor_Init(&this->dyna, DPM_UNK);
this->bombableWallDList = sBombableWallInfo[wallType].dList;
@ -100,6 +125,11 @@ void BgBreakwall_Init(Actor* thisx, GlobalContext* globalCtx) {
ActorShape_Init(&this->dyna.actor.shape, 0.0f, NULL, 0.0f);
Collider_InitQuad(globalCtx, &this->collider);
Collider_SetQuad(globalCtx, &this->collider, &this->dyna.actor, &sQuadInit);
// If "Blue Fire Arrows" are enabled, set up this collider for them
if (enhancedIceArrow) {
Collider_InitQuad(globalCtx, &this->colliderIceArrow);
Collider_SetQuad(globalCtx, &this->colliderIceArrow, &this->dyna.actor, &sIceArrowQuadInit);
}
} else {
this->dyna.actor.world.pos.y -= 40.0f;
}
@ -227,7 +257,22 @@ void BgBreakwall_WaitForObject(BgBreakwall* this, GlobalContext* globalCtx) {
* despawn itself.
*/
void BgBreakwall_Wait(BgBreakwall* this, GlobalContext* globalCtx) {
if (this->collider.base.acFlags & 2) {
bool blueFireArrowCheck = false;
// If "Blue Fire Arrows" enabled, check this collider for a hit
if (enhancedIceArrow) {
if (this->colliderIceArrow.base.acFlags & AC_HIT) {
this->colliderIceArrow.base.acFlags &= ~AC_HIT;
if ((this->colliderIceArrow.base.ac != NULL) && (this->colliderIceArrow.base.ac->id == ACTOR_EN_ARROW)) {
if (this->colliderIceArrow.base.ac->child != NULL &&
this->colliderIceArrow.base.ac->child->id == ACTOR_ARROW_ICE) {
blueFireArrowCheck = true;
}
}
}
}
if (this->collider.base.acFlags & 2 || blueFireArrowCheck) {
Vec3f effectPos;
s32 wallType = ((this->dyna.actor.params >> 13) & 3) & 0xFF;
@ -313,6 +358,10 @@ void BgBreakwall_Draw(Actor* thisx, GlobalContext* globalCtx) {
Collider_SetQuadVertices(&this->collider, &colQuad[0], &colQuad[1], &colQuad[2], &colQuad[3]);
CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base);
if (enhancedIceArrow) {
Collider_SetQuadVertices(&this->colliderIceArrow, &colQuad[0], &colQuad[1], &colQuad[2], &colQuad[3]);
CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderIceArrow.base);
}
}
CLOSE_DISPS(globalCtx->state.gfxCtx);

View File

@ -14,6 +14,7 @@ typedef struct BgBreakwall {
/* 0x0168 */ s8 colType;
/* 0x0169 */ s8 bankIndex;
/* 0x016C */ ColliderQuad collider;
ColliderQuad colliderIceArrow; // Blue Fire Arrows
/* 0x01EC */ BgBreakwallActionFunc actionFunc;
} BgBreakwall; // size = 0x01F0

View File

@ -14,6 +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);
const ActorInit Bg_Ice_Shelter_InitVars = {
ACTOR_BG_ICE_SHELTER,
ACTORCAT_BG,
@ -32,7 +34,7 @@ static f32 sScales[] = { 0.1f, 0.06f, 0.1f, 0.1f, 0.25f };
static Color_RGBA8 sDustPrimColor = { 250, 250, 250, 255 };
static Color_RGBA8 sDustEnvColor = { 180, 180, 180, 255 };
static ColliderCylinderInit D_8089170C = {
static ColliderCylinderInit sCylinder1Init = {
{
COLTYPE_NONE,
AT_NONE,
@ -52,7 +54,7 @@ static ColliderCylinderInit D_8089170C = {
{ 0, 0, 0, { 0, 0, 0 } },
};
static ColliderCylinderInit D_80891738 = {
static ColliderCylinderInit sCylinder2Init = {
{
COLTYPE_HARD,
AT_NONE,
@ -72,14 +74,44 @@ static ColliderCylinderInit D_80891738 = {
{ 0, 0, 0, { 0, 0, 0 } },
};
// This cylinder only used for "Blue Fire Arrows" enhancement
static ColliderCylinderInit sIceArrowCylinderInit = {
{
COLTYPE_NONE,
AT_NONE,
AC_ON | AC_TYPE_OTHER | AC_TYPE_PLAYER,
OC1_ON | OC1_TYPE_ALL,
OC2_TYPE_2,
COLSHAPE_CYLINDER,
},
{
ELEMTYPE_UNK0,
{ 0x00000000, 0x00, 0x00 },
{ 0xFFCFFFFF, 0x00, 0x00 },
TOUCH_NONE,
BUMP_ON,
OCELEM_ON,
},
{ 0, 0, 0, { 0, 0, 0 } },
};
bool enhancedIceArrow = false;
void func_80890740(BgIceShelter* this, GlobalContext* globalCtx) {
static s16 cylinderRadii[] = { 47, 33, 44, 41, 100 };
static s16 cylinderHeights[] = { 80, 54, 90, 60, 200 };
s32 pad;
s32 type = (this->dyna.actor.params >> 8) & 7;
enhancedIceArrow = (gSaveContext.n64ddFlag && (CVar_GetS32("gEnhancedMagicArrows", 0) != 0));
Collider_InitCylinder(globalCtx, &this->cylinder1);
Collider_SetCylinder(globalCtx, &this->cylinder1, &this->dyna.actor, &D_8089170C);
// If "Blue Fire Arrows" is enabled, set up a collider on the red ice that responds to them
if (enhancedIceArrow) {
Collider_SetCylinder(globalCtx, &this->cylinder1, &this->dyna.actor, &sIceArrowCylinderInit);
} else {
Collider_SetCylinder(globalCtx, &this->cylinder1, &this->dyna.actor, &sCylinder1Init);
}
Collider_UpdateCylinder(&this->dyna.actor, &this->cylinder1);
this->cylinder1.dim.radius = cylinderRadii[type];
@ -87,7 +119,7 @@ void func_80890740(BgIceShelter* this, GlobalContext* globalCtx) {
if (type == 0 || type == 1 || type == 4) {
Collider_InitCylinder(globalCtx, &this->cylinder2);
Collider_SetCylinder(globalCtx, &this->cylinder2, &this->dyna.actor, &D_80891738);
Collider_SetCylinder(globalCtx, &this->cylinder2, &this->dyna.actor, &sCylinder2Init);
Collider_UpdateCylinder(&this->dyna.actor, &this->cylinder2);
this->cylinder2.dim.radius = cylinderRadii[type];
this->cylinder2.dim.height = cylinderHeights[type];
@ -292,7 +324,12 @@ void func_8089107C(BgIceShelter* this, GlobalContext* globalCtx) {
this->dyna.actor.parent->freezeTimer = 10000;
}
}
// If we have "Blue Fire Arrows" enabled, check both cylinders for a hit
if (enhancedIceArrow) {
CheckIceArrowHit(this, this->cylinder1, type, globalCtx);
CheckIceArrowHit(this, this->cylinder2, type, globalCtx);
}
// Default blue fire check
if (this->cylinder1.base.acFlags & AC_HIT) {
this->cylinder1.base.acFlags &= ~AC_HIT;
@ -320,6 +357,24 @@ 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) {
if (cylinder.base.acFlags & AC_HIT) {
cylinder.base.acFlags &= ~AC_HIT;
if ((cylinder.base.ac != NULL) && (cylinder.base.ac->id == ACTOR_EN_ARROW)) {
if (cylinder.base.ac->child != NULL && cylinder.base.ac->child->id == ACTOR_ARROW_ICE) {
if (type == 4) {
if (this->dyna.actor.parent != NULL) {
this->dyna.actor.parent->freezeTimer = 50;
}
}
func_808911BC(this);
Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_ICE_MELT);
}
}
}
}
void func_808911BC(BgIceShelter* this) {
this->actionFunc = func_808911D4;
this->alpha = 255;

View File

@ -96,7 +96,11 @@ 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) {
OnePointCutscene_Init(globalCtx, 3430, -99, &this->dyna.actor, MAIN_CAM);
// Skip this cutscene if using Enhanced Arrows, since activating the switch while
// not standing on the platform will cause the cutscene to show the unloaded room
if (!(gSaveContext.n64ddFlag && CVar_GetS32("gEnhancedMagicArrows", 0) != 0)) {
OnePointCutscene_Init(globalCtx, 3430, -99, &this->dyna.actor, MAIN_CAM);
}
BgJyaLift_SetupMove(this);
}
}

View File

@ -73,6 +73,36 @@ static ColliderJntSphInit sColliderJntSphInit = {
1,
sColliderJntSphElementInit,
};
// Collider info used for "Enhanced Arrows"
static ColliderJntSphElementInit sColliderLightArrowElementInit[] = {
{
{
ELEMTYPE_UNK0,
{ 0x00000000, 0x00, 0x00 },
{ 0x00202000, 0x00, 0x00 },
TOUCH_NONE,
BUMP_ON,
OCELEM_ON,
},
{ 0, { { 0, 0, 0 }, 19 }, 100 },
},
};
// Sphere collider used for "Enhanced Arrows"
static ColliderJntSphInit sColliderLightArrowInit = {
{
COLTYPE_NONE,
AT_NONE,
AC_ON | AC_TYPE_PLAYER,
OC1_ON | OC1_TYPE_ALL,
OC2_TYPE_2,
COLSHAPE_JNTSPH,
},
1,
sColliderLightArrowElementInit,
};
bool activatedByLightArrow = false;
bool enhancedLightArrow = false;
static CollisionCheckInfoInit sColChkInfoInit = { 0, 12, 60, MASS_IMMOVABLE };
@ -91,9 +121,15 @@ static InitChainEntry sInitChain[] = {
void ObjLightswitch_InitCollider(ObjLightswitch* this, GlobalContext* globalCtx) {
s32 pad;
enhancedLightArrow = (gSaveContext.n64ddFlag && (CVar_GetS32("gEnhancedMagicArrows", 0) != 0));
Collider_InitJntSph(globalCtx, &this->collider);
Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sColliderJntSphInit, this->colliderItems);
// If "Enhanced Arrows" is enabled, set up the collider to allow Light Arrow hits
if (enhancedLightArrow) {
Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sColliderLightArrowInit, this->colliderItems);
} else {
Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sColliderJntSphInit, this->colliderItems);
}
Matrix_SetTranslateRotateYXZ(this->actor.world.pos.x,
this->actor.world.pos.y + (this->actor.shape.yOffset * this->actor.scale.y),
this->actor.world.pos.z, &this->actor.shape.rot);
@ -211,6 +247,23 @@ void ObjLightswitch_Destroy(Actor* thisx, GlobalContext* globalCtx2) {
GlobalContext* globalCtx = globalCtx2;
ObjLightswitch* this = (ObjLightswitch*)thisx;
// Unset the switch flag on room exit to prevent the rock in the wall from
// vanishing on its own after activating the sun switch by Light Arrow
if (activatedByLightArrow && enhancedLightArrow) {
switch (this->actor.params >> 4 & 3) {
case OBJLIGHTSWITCH_TYPE_STAY_ON:
case OBJLIGHTSWITCH_TYPE_2:
case OBJLIGHTSWITCH_TYPE_1:
if (this->actor.room != 25) { // Don't unset the flag for the chain platform
Flags_UnsetSwitch(globalCtx, this->actor.params >> 8 & 0x3F);
}
activatedByLightArrow = false;
break;
case OBJLIGHTSWITCH_TYPE_BURN:
break;
}
}
Collider_DestroyJntSph(globalCtx, &this->collider);
}
@ -221,8 +274,11 @@ void ObjLightswitch_SetupOff(ObjLightswitch* this) {
this->color[1] = 125 << 6;
this->color[2] = 255 << 6;
this->alpha = 255 << 6;
if (enhancedLightArrow) {
activatedByLightArrow = false;
}
}
// A Sun Switch that is currently turned off
void ObjLightswitch_Off(ObjLightswitch* this, GlobalContext* globalCtx) {
switch (this->actor.params >> 4 & 3) {
case OBJLIGHTSWITCH_TYPE_STAY_ON:
@ -230,6 +286,13 @@ void ObjLightswitch_Off(ObjLightswitch* this, GlobalContext* globalCtx) {
if (this->collider.base.acFlags & AC_HIT) {
ObjLightswitch_SetupTurnOn(this);
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 (enhancedLightArrow) {
if (this->collider.base.ac != NULL && this->collider.base.ac->id == ACTOR_EN_ARROW) {
activatedByLightArrow = true;
}
}
}
break;
case OBJLIGHTSWITCH_TYPE_1:
@ -289,13 +352,18 @@ void ObjLightswitch_SetupOn(ObjLightswitch* this) {
this->flameRingRotSpeed = -0xAA;
this->timer = 0;
}
// A Sun Switch that is currently turned on
void ObjLightswitch_On(ObjLightswitch* this, GlobalContext* globalCtx) {
switch (this->actor.params >> 4 & 3) {
case OBJLIGHTSWITCH_TYPE_STAY_ON:
if (!Flags_GetSwitch(globalCtx, this->actor.params >> 8 & 0x3F)) {
ObjLightswitch_SetupTurnOff(this);
}
if (enhancedLightArrow && (this->collider.base.acFlags & AC_HIT)) {
if (this->collider.base.ac != NULL && this->collider.base.ac->id != ACTOR_EN_ARROW) {
activatedByLightArrow = false;
}
}
break;
case OBJLIGHTSWITCH_TYPE_1:
if (this->collider.base.acFlags & AC_HIT && !(this->prevFrameACflags & AC_HIT)) {
@ -304,10 +372,18 @@ void ObjLightswitch_On(ObjLightswitch* this, GlobalContext* globalCtx) {
}
break;
case OBJLIGHTSWITCH_TYPE_2:
if (enhancedLightArrow && (this->collider.base.acFlags & AC_HIT)) {
if (this->collider.base.ac != NULL && this->collider.base.ac->id != ACTOR_EN_ARROW) {
activatedByLightArrow = false;
}
}
if (!(this->collider.base.acFlags & AC_HIT)) {
if (this->timer >= 7) {
ObjLightswitch_SetupTurnOff(this);
ObjLightswitch_ClearSwitchFlag(this, globalCtx);
// If we aren't using Enhanced Light Arrows, let the switch turn off normally
if (!activatedByLightArrow) {
ObjLightswitch_SetupTurnOff(this);
ObjLightswitch_ClearSwitchFlag(this, globalCtx);
}
} else {
this->timer++;
}