Implements items selling out and fixes issues with purchasing some items.

This commit is contained in:
Christopher Leggett 2022-09-06 00:58:36 -04:00
parent c0b3f229fa
commit 5d38b23850
No known key found for this signature in database
GPG Key ID: 7093AE5FF7037D79
2 changed files with 46 additions and 18 deletions

View File

@ -396,8 +396,12 @@ void EnGirlA_InitItem(EnGirlA* this, GlobalContext* globalCtx) {
if (shopItemIdentity.randomizerCheck != RC_UNKNOWN_CHECK) {
if (shopItemIdentity.enGirlAShopItem == -1) {
GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheckWithoutObtainabilityCheck(shopItemIdentity.randomizerCheck, shopItemIdentity.ogItemId);
objectId = getItemEntry.objectId;
if (Flags_GetRandomizerInf(shopItemIdentity.randomizerInf)) {
objectId = shopItemEntries[SI_SOLD_OUT].objID;
} else {
GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheckWithoutObtainabilityCheck(shopItemIdentity.randomizerCheck, shopItemIdentity.ogItemId);
objectId = getItemEntry.objectId;
}
} else {
objectId = shopItemEntries[shopItemIdentity.enGirlAShopItem].objID;
}
@ -974,6 +978,18 @@ void EnGirlA_BuyEvent_ObtainBombchuPack(GlobalContext* globalCtx, EnGirlA* this)
void EnGirlA_BuyEvent_Randomizer(GlobalContext* globalCtx, EnGirlA* this) {
ShopItemIdentity shopItemIdentity = Randomizer_IdentifyShopItem(globalCtx->sceneNum, this->randoSlotIndex);
Flags_SetRandomizerInf(shopItemIdentity.randomizerInf);
if (shopItemIdentity.enGirlAShopItem == -1) {
ShopItemEntry* itemEntry = &shopItemEntries[SI_SOLD_OUT];
this->actor.textId = itemEntry->itemDescTextId;
this->itemBuyPromptTextId = 0x9100 + ((shopItemIdentity.randomizerInf - RAND_INF_SHOP_ITEMS_KF_SHOP_ITEM_1) + NUM_SHOP_ITEMS);
this->getItemId = itemEntry->getItemId;
this->canBuyFunc = itemEntry->canBuyFunc;
this->itemGiveFunc = itemEntry->itemGiveFunc;
this->buyEventFunc = itemEntry->buyEventFunc;
this->basePrice = itemEntry->price;
this->itemCount = itemEntry->count;
this->giDrawId = itemEntry->giDrawId;
}
Rupees_ChangeBy(-this->basePrice);
}
@ -1030,8 +1046,6 @@ void EnGirlA_SetItemDescription(GlobalContext* globalCtx, EnGirlA* this) {
if (shopItemIdentity.randomizerCheck != RC_UNKNOWN_CHECK) {
if (shopItemIdentity.enGirlAShopItem == -1) {
this->actor.textId = 0x9100 + (shopItemIdentity.randomizerInf - RAND_INF_SHOP_ITEMS_KF_SHOP_ITEM_1);
} else {
this->actor.textId = &shopItemEntries[shopItemIdentity.enGirlAShopItem].itemDescTextId;
}
}
}
@ -1059,7 +1073,11 @@ void EnGirlA_UpdateStockedItem(GlobalContext* globalCtx, EnGirlA* this) {
ShopItemIdentity shopItemIdentity = Randomizer_IdentifyShopItem(globalCtx->sceneNum, this->randoSlotIndex);
if (shopItemIdentity.randomizerCheck != RC_UNKNOWN_CHECK) {
if (shopItemIdentity.enGirlAShopItem == -1) {
itemEntry->itemDescTextId = 0x9100 + (shopItemIdentity.randomizerInf - RAND_INF_SHOP_ITEMS_KF_SHOP_ITEM_1);
if (Flags_GetRandomizerInf(shopItemIdentity.randomizerInf)) {
itemEntry = &shopItemEntries[SI_SOLD_OUT];
} else {
itemEntry->itemDescTextId = 0x9100 + (shopItemIdentity.randomizerInf - RAND_INF_SHOP_ITEMS_KF_SHOP_ITEM_1);
}
} else {
itemEntry->itemDescTextId = &shopItemEntries[shopItemIdentity.enGirlAShopItem].itemDescTextId;
}
@ -1188,7 +1206,6 @@ void EnGirlA_InitializeItemAction(EnGirlA* this, GlobalContext* globalCtx) {
this->yRotation = 0;
this->yRotationInit = this->actor.shape.rot.y;
// TODO: This is pretty verbose, pointers are making this difficult
if (gSaveContext.n64ddFlag && Randomizer_GetSettingValue(RSK_SHOPSANITY)) {
ShopItemIdentity shopItemIdentity = Randomizer_IdentifyShopItem(globalCtx->sceneNum, this->randoSlotIndex);
if (shopItemIdentity.randomizerCheck != RC_UNKNOWN_CHECK) {
@ -1203,16 +1220,6 @@ void EnGirlA_InitializeItemAction(EnGirlA* this, GlobalContext* globalCtx) {
this->basePrice = shopItemIdentity.itemPrice;
this->itemCount = 1;
this->giDrawId = getItemEntry.gid;
} else {
this->actor.textId = (&shopItemEntries[shopItemIdentity.enGirlAShopItem])->itemDescTextId;
this->itemBuyPromptTextId = (&shopItemEntries[shopItemIdentity.enGirlAShopItem])->itemBuyPromptTextId;
this->getItemId = (&shopItemEntries[shopItemIdentity.enGirlAShopItem])->getItemId;
this->canBuyFunc = (&shopItemEntries[shopItemIdentity.enGirlAShopItem])->canBuyFunc;
this->itemGiveFunc = (&shopItemEntries[shopItemIdentity.enGirlAShopItem])->itemGiveFunc;
this->buyEventFunc = (&shopItemEntries[shopItemIdentity.enGirlAShopItem])->buyEventFunc;
this->basePrice = (&shopItemEntries[shopItemIdentity.enGirlAShopItem])->price;
this->itemCount = (&shopItemEntries[shopItemIdentity.enGirlAShopItem])->count;
this->giDrawId = (&shopItemEntries[shopItemIdentity.enGirlAShopItem])->giDrawId;
}
}
}
@ -1228,7 +1235,7 @@ void EnGirlA_Update2(EnGirlA* this, GlobalContext* globalCtx) {
Actor_SetFocus(&this->actor, 5.0f);
this->actor.shape.rot.x = 0.0f;
if (this->actor.params != SI_SOLD_OUT) {
if (this->isSelected) {
if (this->isSelected && this->giDrawId != GID_SOLDOUT) {
this->yRotation += 0x1F4;
} else {
Math_SmoothStepToS(&this->yRotation, 0, 10, 0x7D0, 0);

View File

@ -427,6 +427,16 @@ void EnOssan_SpawnItemsOnShelves(EnOssan* this, GlobalContext* globalCtx, ShopIt
this->shelfSlots[i] = NULL;
} else {
itemParams = sShopItemReplaceFunc[shopItems->shopItemIndex](shopItems->shopItemIndex);
if (gSaveContext.n64ddFlag && Randomizer_GetSettingValue(RSK_SHOPSANITY)) {
ShopItemIdentity shopItemIdentity = Randomizer_IdentifyShopItem(globalCtx->sceneNum, i);
if (shopItemIdentity.enGirlAShopItem == -1) {
if (Flags_GetRandomizerInf(shopItemIdentity.randomizerInf)) {
itemParams = SI_SOLD_OUT;
}
} else {
itemParams = shopItemIdentity.enGirlAShopItem;
}
}
if (itemParams < 0) {
this->shelfSlots[i] = NULL;
@ -1678,7 +1688,18 @@ void EnOssan_State_GiveItemWithFanfare(EnOssan* this, GlobalContext* globalCtx,
this->stateFlag = OSSAN_STATE_ITEM_PURCHASED;
return;
}
func_8002F434(&this->actor, globalCtx, this->shelfSlots[this->cursorIndex]->getItemId, 120.0f, 120.0f);
if (!gSaveContext.n64ddFlag) {
func_8002F434(&this->actor, globalCtx, this->shelfSlots[this->cursorIndex]->getItemId, 120.0f, 120.0f);
} else {
ShopItemIdentity shopItemIdentity = Randomizer_IdentifyShopItem(globalCtx->sceneNum, this->cursorIndex);
if (shopItemIdentity.randomizerCheck != RC_UNKNOWN_CHECK) {
GetItemEntry getItemEntry =
Randomizer_GetItemFromKnownCheck(shopItemIdentity.randomizerCheck, shopItemIdentity.ogItemId);
GiveItemEntryFromActor(&this->actor, globalCtx, getItemEntry, 120.0f, 120.0f);
} else {
func_8002F434(&this->actor, globalCtx, this->shelfSlots[this->cursorIndex]->getItemId, 120.0f, 120.0f);
}
}
}
void EnOssan_State_ItemPurchased(EnOssan* this, GlobalContext* globalCtx, Player* player) {