mirror of
https://github.com/HarbourMasters/Shipwright
synced 2026-08-08 19:03:19 -04:00
Update CSMC to CMC and update chests to other shuffles (#6085)
This commit is contained in:
@@ -55,7 +55,7 @@ void EnBox_AppearAnimation(EnBox*, PlayState*);
|
||||
void EnBox_WaitOpen(EnBox*, PlayState*);
|
||||
void EnBox_Open(EnBox*, PlayState*);
|
||||
void EnBox_CreateExtraChestTextures();
|
||||
void EnBox_UpdateSizeAndTexture(EnBox*, PlayState*);
|
||||
void EnBox_UpdateTexture(EnBox*, PlayState*);
|
||||
|
||||
const ActorInit En_Box_InitVars = {
|
||||
ACTOR_EN_BOX,
|
||||
@@ -93,6 +93,16 @@ u8 hasCreatedRandoChestTextures = 0;
|
||||
u8 hasCustomChestDLs = 0;
|
||||
u8 hasChristmasChestTexturesAvailable = 0;
|
||||
|
||||
static Gfx* EnBox_LoadChestDL(const char* dlName, const char* fallbackName) {
|
||||
Gfx* dl = ResourceMgr_LoadGfxByName(dlName);
|
||||
|
||||
if (dl == NULL && fallbackName != NULL) {
|
||||
dl = ResourceMgr_LoadGfxByName(fallbackName);
|
||||
}
|
||||
|
||||
return dl;
|
||||
}
|
||||
|
||||
void EnBox_SetupAction(EnBox* this, EnBoxActionFunc actionFunc) {
|
||||
this->actionFunc = actionFunc;
|
||||
}
|
||||
@@ -203,7 +213,7 @@ void EnBox_Init(Actor* thisx, PlayState* play2) {
|
||||
}
|
||||
}
|
||||
|
||||
EnBox_UpdateSizeAndTexture(this, play);
|
||||
EnBox_UpdateTexture(this, play);
|
||||
// For SOH we spawn a chest actor instead of rendering the object from scratch for forest boss
|
||||
// key chest, and it's up on the wall so disable gravity for it.
|
||||
if (play->sceneNum == SCENE_FOREST_TEMPLE && this->dyna.actor.params == 10222) {
|
||||
@@ -542,7 +552,7 @@ void EnBox_SpawnIceSmoke(EnBox* this, PlayState* play) {
|
||||
void EnBox_Update(Actor* thisx, PlayState* play) {
|
||||
EnBox* this = (EnBox*)thisx;
|
||||
|
||||
EnBox_UpdateSizeAndTexture(this, play);
|
||||
EnBox_UpdateTexture(this, play);
|
||||
|
||||
if (this->movementFlags & ENBOX_MOVE_STICK_TO_GROUND) {
|
||||
this->movementFlags &= ~ENBOX_MOVE_STICK_TO_GROUND;
|
||||
@@ -575,102 +585,91 @@ void EnBox_Update(Actor* thisx, PlayState* play) {
|
||||
}
|
||||
}
|
||||
|
||||
void EnBox_UpdateSizeAndTexture(EnBox* this, PlayState* play) {
|
||||
void EnBox_UpdateTexture(EnBox* this, PlayState* play) {
|
||||
EnBox_CreateExtraChestTextures();
|
||||
int csmc = CVarGetInteger(CVAR_ENHANCEMENT("ChestSizeAndTextureMatchContents"), CSMC_DISABLED);
|
||||
bool csmc = CVarGetInteger(CVAR_ENHANCEMENT("ChestSizeAndTextureMatchContents"), 0);
|
||||
int requiresStoneAgony = CVarGetInteger(CVAR_ENHANCEMENT("ChestSizeDependsStoneOfAgony"), 0);
|
||||
GetItemCategory getItemCategory;
|
||||
GetItemEntry chestItem = this->getItemEntry;
|
||||
|
||||
int isVanilla = csmc == CSMC_DISABLED || (requiresStoneAgony && !CHECK_QUEST_ITEM(QUEST_STONE_OF_AGONY)) ||
|
||||
int isVanilla = !csmc || (requiresStoneAgony && !CHECK_QUEST_ITEM(QUEST_STONE_OF_AGONY)) ||
|
||||
(play->sceneNum == SCENE_TREASURE_BOX_SHOP &&
|
||||
this->dyna.actor.room != 6); // Exclude treasure game chests except for the final room
|
||||
|
||||
if (!isVanilla) {
|
||||
GetItemEntry test = this->getItemEntry;
|
||||
getItemCategory = this->getItemEntry.getItemCategory;
|
||||
getItemCategory = chestItem.getItemCategory;
|
||||
// If they have bombchus, don't consider the bombchu item major
|
||||
if (INV_CONTENT(ITEM_BOMBCHU) == ITEM_BOMBCHU &&
|
||||
((this->getItemEntry.modIndex == MOD_RANDOMIZER &&
|
||||
this->getItemEntry.getItemId == RG_PROGRESSIVE_BOMBCHU_BAG) ||
|
||||
(this->getItemEntry.modIndex == MOD_NONE &&
|
||||
(this->getItemEntry.getItemId == GI_BOMBCHUS_5 || this->getItemEntry.getItemId == GI_BOMBCHUS_10 ||
|
||||
this->getItemEntry.getItemId == GI_BOMBCHUS_20)))) {
|
||||
((chestItem.modIndex == MOD_RANDOMIZER && chestItem.getItemId == RG_PROGRESSIVE_BOMBCHU_BAG) ||
|
||||
(chestItem.modIndex == MOD_NONE &&
|
||||
(chestItem.getItemId == GI_BOMBCHUS_5 || chestItem.getItemId == GI_BOMBCHUS_10 ||
|
||||
chestItem.getItemId == GI_BOMBCHUS_20)))) {
|
||||
getItemCategory = ITEM_CATEGORY_JUNK;
|
||||
// If it's a bottle and they already have one, consider the item lesser
|
||||
} else if ((this->getItemEntry.modIndex == MOD_RANDOMIZER &&
|
||||
this->getItemEntry.getItemId >= RG_BOTTLE_WITH_RED_POTION &&
|
||||
this->getItemEntry.getItemId <= RG_BOTTLE_WITH_POE) ||
|
||||
(this->getItemEntry.modIndex == MOD_NONE &&
|
||||
(this->getItemEntry.getItemId == GI_BOTTLE || this->getItemEntry.getItemId == GI_MILK_BOTTLE))) {
|
||||
} else if ((chestItem.modIndex == MOD_RANDOMIZER && chestItem.getItemId >= RG_BOTTLE_WITH_RED_POTION &&
|
||||
chestItem.getItemId <= RG_BOTTLE_WITH_POE) ||
|
||||
(chestItem.modIndex == MOD_NONE &&
|
||||
(chestItem.getItemId == GI_BOTTLE || chestItem.getItemId == GI_MILK_BOTTLE))) {
|
||||
if (gSaveContext.inventory.items[SLOT_BOTTLE_1] != ITEM_NONE) {
|
||||
getItemCategory = ITEM_CATEGORY_LESSER;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Change size
|
||||
if (!isVanilla && (csmc == CSMC_BOTH || csmc == CSMC_SIZE)) {
|
||||
switch (getItemCategory) {
|
||||
case ITEM_CATEGORY_JUNK:
|
||||
case ITEM_CATEGORY_SMALL_KEY:
|
||||
case ITEM_CATEGORY_SKULLTULA_TOKEN:
|
||||
Actor_SetScale(&this->dyna.actor, 0.005f);
|
||||
Actor_SetFocus(&this->dyna.actor, 20.0f);
|
||||
break;
|
||||
default:
|
||||
Actor_SetScale(&this->dyna.actor, 0.01f);
|
||||
Actor_SetFocus(&this->dyna.actor, 40.0f);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch (this->type) {
|
||||
case ENBOX_TYPE_SMALL:
|
||||
case ENBOX_TYPE_6:
|
||||
case ENBOX_TYPE_ROOM_CLEAR_SMALL:
|
||||
case ENBOX_TYPE_SWITCH_FLAG_FALL_SMALL:
|
||||
Actor_SetScale(&this->dyna.actor, 0.005f);
|
||||
Actor_SetFocus(&this->dyna.actor, 20.0f);
|
||||
break;
|
||||
default:
|
||||
Actor_SetScale(&this->dyna.actor, 0.01f);
|
||||
Actor_SetFocus(&this->dyna.actor, 40.0f);
|
||||
}
|
||||
switch (this->type) {
|
||||
case ENBOX_TYPE_SMALL:
|
||||
case ENBOX_TYPE_6:
|
||||
case ENBOX_TYPE_ROOM_CLEAR_SMALL:
|
||||
case ENBOX_TYPE_SWITCH_FLAG_FALL_SMALL:
|
||||
Actor_SetScale(&this->dyna.actor, 0.005f);
|
||||
Actor_SetFocus(&this->dyna.actor, 20.0f);
|
||||
break;
|
||||
default:
|
||||
Actor_SetScale(&this->dyna.actor, 0.01f);
|
||||
Actor_SetFocus(&this->dyna.actor, 40.0f);
|
||||
}
|
||||
|
||||
// Change texture
|
||||
if (!isVanilla && hasCreatedRandoChestTextures && !hasCustomChestDLs &&
|
||||
(csmc == CSMC_BOTH || csmc == CSMC_TEXTURE)) {
|
||||
// Change model/texture
|
||||
if (!isVanilla) {
|
||||
switch (getItemCategory) {
|
||||
case ITEM_CATEGORY_MAJOR:
|
||||
this->boxBodyDL = gGoldTreasureChestChestFrontDL;
|
||||
this->boxLidDL = gGoldTreasureChestChestSideAndLidDL;
|
||||
this->boxBodyDL = EnBox_LoadChestDL(gChestBodyMajorDL, gTreasureChestChestFrontDL);
|
||||
this->boxLidDL = EnBox_LoadChestDL(gChestLidMajorDL, gTreasureChestChestSideAndLidDL);
|
||||
break;
|
||||
case ITEM_CATEGORY_SKULLTULA_TOKEN:
|
||||
this->boxBodyDL = gSkullTreasureChestChestFrontDL;
|
||||
this->boxLidDL = gSkullTreasureChestChestSideAndLidDL;
|
||||
this->boxBodyDL = EnBox_LoadChestDL(gChestBodyTokenDL, gTreasureChestChestFrontDL);
|
||||
this->boxLidDL = EnBox_LoadChestDL(gChestLidTokenDL, gTreasureChestChestSideAndLidDL);
|
||||
break;
|
||||
case ITEM_CATEGORY_SMALL_KEY:
|
||||
this->boxBodyDL = gKeyTreasureChestChestFrontDL;
|
||||
this->boxLidDL = gKeyTreasureChestChestSideAndLidDL;
|
||||
this->boxBodyDL = EnBox_LoadChestDL(gChestBodySmallKeyDL, gTreasureChestChestFrontDL);
|
||||
this->boxLidDL = EnBox_LoadChestDL(gChestLidSmallKeyDL, gTreasureChestChestSideAndLidDL);
|
||||
break;
|
||||
case ITEM_CATEGORY_BOSS_KEY:
|
||||
this->boxBodyDL = gTreasureChestBossKeyChestFrontDL;
|
||||
this->boxLidDL = gTreasureChestBossKeyChestSideAndTopDL;
|
||||
this->boxBodyDL = EnBox_LoadChestDL(gTreasureChestBossKeyChestFrontDL, gTreasureChestChestFrontDL);
|
||||
this->boxLidDL =
|
||||
EnBox_LoadChestDL(gTreasureChestBossKeyChestSideAndTopDL, gTreasureChestChestSideAndLidDL);
|
||||
break;
|
||||
case ITEM_CATEGORY_HEALTH:
|
||||
this->boxBodyDL = EnBox_LoadChestDL(gChestBodyHeartDL, gTreasureChestChestFrontDL);
|
||||
this->boxLidDL = EnBox_LoadChestDL(gChestLidHeartDL, gTreasureChestChestSideAndLidDL);
|
||||
break;
|
||||
case ITEM_CATEGORY_LESSER:
|
||||
this->boxBodyDL = EnBox_LoadChestDL(gChestBodyMinorDL, gTreasureChestChestFrontDL);
|
||||
this->boxLidDL = EnBox_LoadChestDL(gChestLidMinorDL, gTreasureChestChestSideAndLidDL);
|
||||
break;
|
||||
case ITEM_CATEGORY_JUNK:
|
||||
default:
|
||||
this->boxBodyDL = gTreasureChestChestFrontDL;
|
||||
this->boxLidDL = gTreasureChestChestSideAndLidDL;
|
||||
this->boxBodyDL = EnBox_LoadChestDL(gChestBodyJunkDL, gTreasureChestChestFrontDL);
|
||||
this->boxLidDL = EnBox_LoadChestDL(gChestLidJunkDL, gTreasureChestChestSideAndLidDL);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (this->type != ENBOX_TYPE_DECORATED_BIG) {
|
||||
this->boxBodyDL = gTreasureChestChestFrontDL;
|
||||
this->boxLidDL = gTreasureChestChestSideAndLidDL;
|
||||
this->boxBodyDL = EnBox_LoadChestDL(gTreasureChestChestFrontDL, NULL);
|
||||
this->boxLidDL = EnBox_LoadChestDL(gTreasureChestChestSideAndLidDL, NULL);
|
||||
} else {
|
||||
this->boxBodyDL = gTreasureChestBossKeyChestFrontDL;
|
||||
this->boxLidDL = gTreasureChestBossKeyChestSideAndTopDL;
|
||||
this->boxBodyDL = EnBox_LoadChestDL(gTreasureChestBossKeyChestFrontDL, gTreasureChestChestFrontDL);
|
||||
this->boxLidDL = EnBox_LoadChestDL(gTreasureChestBossKeyChestSideAndTopDL, gTreasureChestChestSideAndLidDL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -684,36 +683,6 @@ void EnBox_UpdateSizeAndTexture(EnBox* this, PlayState* play) {
|
||||
this->boxLidDL = gChristmasGreenTreasureChestChestSideAndLidDL;
|
||||
}
|
||||
}
|
||||
|
||||
// Chest Sizes Match Contents can make certain chests unreachable, so nudge
|
||||
// the ones that cause problems.
|
||||
// https://github.com/gamestabled/OoT3D_Randomizer/blob/68cf3f190d319e554bdeebc7f16e67578430dbc3/code/src/actors/chest.c#L57
|
||||
s16 params = this->dyna.actor.params;
|
||||
s16 sceneNum = play->sceneNum;
|
||||
s16 room = this->dyna.actor.room;
|
||||
s16 isLarge = this->dyna.actor.scale.x == 0.01f;
|
||||
|
||||
// Make Ganon's Castle Zelda's Lullaby chest reachable when large.
|
||||
if ((params & 0xF000) == 0x8000 && sceneNum == SCENE_INSIDE_GANONS_CASTLE && room == 9) {
|
||||
this->dyna.actor.world.pos.z = isLarge ? -962.0f : -952.0f;
|
||||
}
|
||||
|
||||
// Make MQ Deku Tree Song of Time chest reachable when large.
|
||||
if (params == 0x5AA0 && sceneNum == SCENE_DEKU_TREE && room == 5) {
|
||||
this->dyna.actor.world.pos.x = isLarge ? -1380.0f : -1376.0f;
|
||||
}
|
||||
|
||||
// Make Ganon's Castle Gold Gauntlets chest reachable with hookshot from the
|
||||
// switch platform when small.
|
||||
if (params == 0x36C5 && sceneNum == SCENE_INSIDE_GANONS_CASTLE && room == 12) {
|
||||
this->dyna.actor.world.pos.x = isLarge ? 1757.0f : 1777.0f;
|
||||
this->dyna.actor.world.pos.z = isLarge ? -3595.0f : -3626.0f;
|
||||
}
|
||||
|
||||
// Make Spirit Temple Compass Chest reachable with hookshot when small.
|
||||
if (params == 0x3804 && sceneNum == SCENE_SPIRIT_TEMPLE && room == 14) {
|
||||
this->dyna.actor.world.pos.x = isLarge ? 358.0f : 400.0f;
|
||||
}
|
||||
}
|
||||
|
||||
void EnBox_CreateExtraChestTextures() {
|
||||
|
||||
Reference in New Issue
Block a user