Label slot machine ids, fix GetPriceReduction

This commit is contained in:
GriffinR 2021-11-16 13:55:02 -05:00
parent 63c5905914
commit 5d9c31a610
12 changed files with 151 additions and 61 deletions

View File

@ -1107,10 +1107,10 @@
.4byte \products
.endm
@ Starts up the slot machine minigame.
.macro playslotmachine word:req
@ Starts up the slot machine minigame. id is a SLOT_MACHINE_* value that influences probabilities of certain reel outcomes.
.macro playslotmachine id:req
.byte 0x89
.2byte \word
.2byte \id
.endm
@ Sets a berry tree's specific berry and growth stage.
@ -1197,7 +1197,7 @@
.endm
@ Gets the price reduction for the index given.
.macro getpricereduction index:req
.macro getpokenewsactive index:req
.byte 0x96
.2byte \index
.endm

View File

@ -17,7 +17,7 @@ LilycoveCity_ContestLobby_OnTransition:
end
LilycoveCity_ContestLobby_EventScript_TryShowBlendMaster::
getpricereduction POKENEWS_BLENDMASTER
getpokenewsactive POKENEWS_BLENDMASTER
compare VAR_RESULT, TRUE
goto_if_eq LilycoveCity_ContestLobby_EventScript_ShowBlendMaster
clearflag FLAG_HIDE_LILYCOVE_CONTEST_HALL_BLEND_MASTER_REPLACEMENT

View File

@ -3,7 +3,7 @@ LilycoveCity_DepartmentStoreRooftop_MapScripts::
.byte 0
LilycoveCity_DepartmentStoreRooftop_OnTransition:
getpricereduction POKENEWS_LILYCOVE
getpokenewsactive POKENEWS_LILYCOVE
compare VAR_RESULT, TRUE
call_if_eq LilycoveCity_DepartmentStoreRooftop_EventScript_ShowSaleWoman
compare VAR_RESULT, FALSE
@ -51,7 +51,7 @@ LilycoveCity_DepartmentStoreRooftop_PokemartDecor_ClearOutSale:
LilycoveCity_DepartmentStoreRooftop_EventScript_Man::
lock
faceplayer
getpricereduction POKENEWS_LILYCOVE
getpokenewsactive POKENEWS_LILYCOVE
compare VAR_RESULT, TRUE
call_if_eq LilycoveCity_DepartmentStoreRooftop_EventScript_ManClearOutSale
msgbox LilycoveCity_DepartmentStoreRooftop_Text_SetDatesForClearOutSales, MSGBOX_DEFAULT

View File

@ -150,7 +150,7 @@ gScriptCmdTable::
.4byte ScrCmd_showmoneybox @ 0x93
.4byte ScrCmd_hidemoneybox @ 0x94
.4byte ScrCmd_updatemoneybox @ 0x95
.4byte ScrCmd_getpricereduction @ 0x96
.4byte ScrCmd_getpokenewsactive @ 0x96
.4byte ScrCmd_fadescreen @ 0x97
.4byte ScrCmd_fadescreenspeed @ 0x98
.4byte ScrCmd_setflashradius @ 0x99

View File

@ -3,7 +3,7 @@ Roulette_EventScript_Table1::
compare VAR_RESULT, FALSE
goto_if_eq MauvilleCity_GameCorner_EventScript_NoCoinCase
setvar VAR_0x8004, 0
getpricereduction POKENEWS_GAME_CORNER
getpokenewsactive POKENEWS_GAME_CORNER
compare VAR_RESULT, FALSE
goto_if_eq Roulette_EventScript_Play
addvar VAR_0x8004, ROULETTE_SPECIAL_RATE
@ -15,7 +15,7 @@ Roulette_EventScript_Table2::
compare VAR_RESULT, FALSE
goto_if_eq MauvilleCity_GameCorner_EventScript_NoCoinCase
setvar VAR_0x8004, 1
getpricereduction POKENEWS_GAME_CORNER
getpokenewsactive POKENEWS_GAME_CORNER
compare VAR_RESULT, FALSE
goto_if_eq Roulette_EventScript_Play
addvar VAR_0x8004, ROULETTE_SPECIAL_RATE

View File

@ -3,4 +3,13 @@
#define SLOT_MACHINE_COUNT 12
// Slot machine IDs
#define SLOT_MACHINE_UNLUCKIEST 0
#define SLOT_MACHINE_UNLUCKIER 1
#define SLOT_MACHINE_UNLUCKY 2
#define SLOT_MACHINE_LUCKY 3
#define SLOT_MACHINE_LUCKIER 4
#define SLOT_MACHINE_LUCKIEST 5
#define NUM_SLOT_MACHINE_IDS 6
#endif // GUARD_CONSTANTS_SLOT_MACHINE_H

View File

@ -19,7 +19,7 @@ void HideBattleTowerReporter(void);
void ReceiveTvShowsData(void *src, u32 size, u8 masterIdx);
void TryPutSpotTheCutiesOnAir(struct Pokemon *pokemon, u8 ribbonMonDataIdx);
u32 GetPlayerIDAsU32(void);
bool8 GetPriceReduction(u8 newsKind);
bool8 IsPokeNewsActive(u8 newsKind);
void SanitizeTVShowLocationsForRuby(TVShow *shows);
size_t CountDigits(int value);
u8 GetRibbonCount(struct Pokemon *pokemon);

View File

@ -1330,15 +1330,40 @@ void BufferEReaderTrainerName(void)
u16 GetSlotMachineId(void)
{
static const u8 sSlotMachineRandomSeeds[] = {12, 2, 4, 5, 1, 8, 7, 11, 3, 10, 9, 6};
static const u8 sSlotMachineIds[] = {0, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5};
static const u8 sSlotMachineServiceDayIds[] = {3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5};
static const u8 sSlotMachineRandomSeeds[SLOT_MACHINE_COUNT] = {12, 2, 4, 5, 1, 8, 7, 11, 3, 10, 9, 6};
static const u8 sSlotMachineIds[SLOT_MACHINE_COUNT] = {
SLOT_MACHINE_UNLUCKIEST,
SLOT_MACHINE_UNLUCKIER,
SLOT_MACHINE_UNLUCKIER,
SLOT_MACHINE_UNLUCKY,
SLOT_MACHINE_UNLUCKY,
SLOT_MACHINE_UNLUCKY,
SLOT_MACHINE_LUCKY,
SLOT_MACHINE_LUCKY,
SLOT_MACHINE_LUCKY,
SLOT_MACHINE_LUCKIER,
SLOT_MACHINE_LUCKIER,
SLOT_MACHINE_LUCKIEST
};
static const u8 sSlotMachineServiceDayIds[SLOT_MACHINE_COUNT] = {
SLOT_MACHINE_LUCKY,
SLOT_MACHINE_LUCKY,
SLOT_MACHINE_LUCKY,
SLOT_MACHINE_LUCKY,
SLOT_MACHINE_LUCKY,
SLOT_MACHINE_LUCKY,
SLOT_MACHINE_LUCKIER,
SLOT_MACHINE_LUCKIER,
SLOT_MACHINE_LUCKIER,
SLOT_MACHINE_LUCKIER,
SLOT_MACHINE_LUCKIEST,
SLOT_MACHINE_LUCKIEST
};
u32 rnd = gSaveBlock1Ptr->dewfordTrends[0].trendiness + gSaveBlock1Ptr->dewfordTrends[0].rand + sSlotMachineRandomSeeds[gSpecialVar_0x8004];
if (GetPriceReduction(POKENEWS_GAME_CORNER))
{
if (IsPokeNewsActive(POKENEWS_GAME_CORNER))
return sSlotMachineServiceDayIds[rnd % SLOT_MACHINE_COUNT];
}
return sSlotMachineIds[rnd % SLOT_MACHINE_COUNT];
}

View File

@ -1936,11 +1936,11 @@ bool8 ScrCmd_setberrytree(struct ScriptContext *ctx)
return FALSE;
}
bool8 ScrCmd_getpricereduction(struct ScriptContext *ctx)
bool8 ScrCmd_getpokenewsactive(struct ScriptContext *ctx)
{
u16 newsKind = VarGet(ScriptReadHalfword(ctx));
gSpecialVar_Result = GetPriceReduction(newsKind);
gSpecialVar_Result = IsPokeNewsActive(newsKind);
return FALSE;
}

View File

@ -562,7 +562,7 @@ static void BuyMenuPrintPriceInList(u8 windowId, u32 itemId, u8 y)
{
ConvertIntToDecimalStringN(
gStringVar1,
ItemId_GetPrice(itemId) >> GetPriceReduction(POKENEWS_SLATEPORT),
ItemId_GetPrice(itemId) >> IsPokeNewsActive(POKENEWS_SLATEPORT),
STR_CONV_MODE_LEFT_ALIGN,
5);
}
@ -934,7 +934,7 @@ static void Task_BuyMenu(u8 taskId)
if (sMartInfo.martType == MART_TYPE_NORMAL)
{
sShopData->totalCost = (ItemId_GetPrice(itemId) >> GetPriceReduction(POKENEWS_SLATEPORT));
sShopData->totalCost = (ItemId_GetPrice(itemId) >> IsPokeNewsActive(POKENEWS_SLATEPORT));
}
else
{
@ -1014,7 +1014,7 @@ static void Task_BuyHowManyDialogueHandleInput(u8 taskId)
if (AdjustQuantityAccordingToDPadInput(&tItemCount, sShopData->maxQuantity) == TRUE)
{
sShopData->totalCost = (ItemId_GetPrice(tItemId) >> GetPriceReduction(POKENEWS_SLATEPORT)) * tItemCount;
sShopData->totalCost = (ItemId_GetPrice(tItemId) >> IsPokeNewsActive(POKENEWS_SLATEPORT)) * tItemCount;
BuyMenuPrintItemQuantityAndPrice(taskId);
}
else

View File

@ -557,10 +557,10 @@ static struct SpriteFrameImage *sImageTables_DigitalDisplay[NUM_DIG_DISPLAY_SPRI
// Const rom data.
static const struct DigitalDisplaySprite *const sDigitalDisplayScenes[];
static const u16 sUnkPalette[];
static const u8 sLuckyRoundProbabilities[][3];
static const u8 sLuckyRoundProbabilities[NUM_SLOT_MACHINE_IDS][MAX_BET];
static const u8 sBiasTags[];
static const u16 sLuckyFlagSettings_Top3[];
static const u16 sLuckyFlagSettings_NotTop3[];
static const u16 sLuckyFlagSettings_Top3[3];
static const u16 sLuckyFlagSettings_NotTop3[5];
static const s16 sDigitalDisplay_SpriteCoords[][2];
static const SpriteCallback sDigitalDisplay_SpriteCallbacks[];
static const struct SpriteTemplate *const sSpriteTemplates_DigitalDisplay[NUM_DIG_DISPLAY_SPRITES];
@ -582,8 +582,8 @@ static const struct SpriteSheet sSlotMachineSpriteSheets[22];
static const struct SpritePalette sSlotMachineSpritePalettes[];
static const u16 *const sDigitalDisplay_Pal;
static const s16 sInitialReelPositions[NUM_REELS][2];
static const u8 sLuckyFlagProbabilities_Top3[][6];
static const u8 sLuckyFlagProbabilities_NotTop3[][6];
static const u8 sLuckyFlagProbabilities_Top3[][NUM_SLOT_MACHINE_IDS];
static const u8 sLuckyFlagProbabilities_NotTop3[][NUM_SLOT_MACHINE_IDS];
static const u8 sReeltimeProbabilities_UnluckyGame[][17];
static const u8 sReelTimeProbabilities_LuckyGame[][17];
static const u8 sSymToMatch[];
@ -1651,24 +1651,20 @@ static void DrawLuckyFlags(void)
if (IsThisRoundLucky())
{
attempts = AttemptsAtLuckyFlags_Top3();
if (attempts != 3) // if you found a lucky number
if (attempts != ARRAY_COUNT(sLuckyFlagSettings_Top3)) // if you found a lucky number
{
// attempts == 1: reelTime flag set
sSlotMachine->luckyFlags |= sLuckyFlagSettings_Top3[attempts];
if (attempts != 1)
{
return;
}
}
}
// if it's not a lucky round or you got reel time, roll for the lower lucky flags
attempts = AttemptsAtLuckyFlags_NotTop3();
if (attempts != 5) // if you found a lucky number
{
if (attempts != ARRAY_COUNT(sLuckyFlagSettings_NotTop3)) // if you found a lucky number
sSlotMachine->luckyFlags |= sLuckyFlagSettings_NotTop3[attempts];
}
}
}
}
static void SetLuckySpins(void)
@ -1704,7 +1700,7 @@ static u8 AttemptsAtLuckyFlags_Top3(void)
{
s16 count;
for (count = 0; count < 3; count++)
for (count = 0; count < (int)ARRAY_COUNT(sLuckyFlagSettings_Top3); count++)
{
s16 rval = Random() & 0xff;
s16 value = sLuckyFlagProbabilities_Top3[count][sSlotMachine->machineId];
@ -1718,7 +1714,7 @@ static u8 AttemptsAtLuckyFlags_NotTop3(void)
{
s16 count;
for (count = 0; count < 5; count++)
for (count = 0; count < (int)ARRAY_COUNT(sLuckyFlagSettings_NotTop3); count++)
{
s16 rval = Random() & 0xff; // random byte
s16 value = sLuckyFlagProbabilities_NotTop3[count][sSlotMachine->machineId];
@ -4807,27 +4803,83 @@ static const s16 sInitialReelPositions[NUM_REELS][2] = {
[RIGHT_REEL] = {0, 2}
};
static const u8 sLuckyRoundProbabilities[][3] = {
{1, 1, 12},
{1, 1, 14},
{2, 2, 14},
{2, 2, 14},
{2, 3, 16},
{3, 3, 16}
static const u8 sLuckyRoundProbabilities[NUM_SLOT_MACHINE_IDS][MAX_BET] = {
[SLOT_MACHINE_UNLUCKIEST] = {1, 1, 12},
[SLOT_MACHINE_UNLUCKIER] = {1, 1, 14},
[SLOT_MACHINE_UNLUCKY] = {2, 2, 14},
[SLOT_MACHINE_LUCKY] = {2, 2, 14},
[SLOT_MACHINE_LUCKIER] = {2, 3, 16},
[SLOT_MACHINE_LUCKIEST] = {3, 3, 16}
};
static const u8 sLuckyFlagProbabilities_Top3[][6] = {
{25, 25, 30, 40, 40, 50},
{25, 25, 30, 30, 35, 35},
{25, 25, 30, 25, 25, 30}
static const u8 sLuckyFlagProbabilities_Top3[][NUM_SLOT_MACHINE_IDS] = {
{ // Probabilities for LUCKY_BIAS_777
[SLOT_MACHINE_UNLUCKIEST] = 25,
[SLOT_MACHINE_UNLUCKIER] = 25,
[SLOT_MACHINE_UNLUCKY] = 30,
[SLOT_MACHINE_LUCKY] = 40,
[SLOT_MACHINE_LUCKIER] = 40,
[SLOT_MACHINE_LUCKIEST] = 50
},
{ // Probabilities for LUCKY_BIAS_REELTIME
[SLOT_MACHINE_UNLUCKIEST] = 25,
[SLOT_MACHINE_UNLUCKIER] = 25,
[SLOT_MACHINE_UNLUCKY] = 30,
[SLOT_MACHINE_LUCKY] = 30,
[SLOT_MACHINE_LUCKIER] = 35,
[SLOT_MACHINE_LUCKIEST] = 35
},
{ // Probabilities for LUCKY_BIAS_MIXED_777
[SLOT_MACHINE_UNLUCKIEST] = 25,
[SLOT_MACHINE_UNLUCKIER] = 25,
[SLOT_MACHINE_UNLUCKY] = 30,
[SLOT_MACHINE_LUCKY] = 25,
[SLOT_MACHINE_LUCKIER] = 25,
[SLOT_MACHINE_LUCKIEST] = 30
}
};
static const u8 sLuckyFlagProbabilities_NotTop3[][6] = {
{20, 25, 25, 20, 25, 25},
{12, 15, 15, 18, 19, 22},
{25, 25, 25, 30, 30, 40},
{25, 25, 20, 20, 15, 15},
{40, 40, 35, 35, 40, 40}
static const u8 sLuckyFlagProbabilities_NotTop3[][NUM_SLOT_MACHINE_IDS] = {
{ // Probabilities for LUCKY_BIAS_POWER
[SLOT_MACHINE_UNLUCKIEST] = 20,
[SLOT_MACHINE_UNLUCKIER] = 25,
[SLOT_MACHINE_UNLUCKY] = 25,
[SLOT_MACHINE_LUCKY] = 20,
[SLOT_MACHINE_LUCKIER] = 25,
[SLOT_MACHINE_LUCKIEST] = 25
},
{ // Probabilities for LUCKY_BIAS_AZURILL
[SLOT_MACHINE_UNLUCKIEST] = 12,
[SLOT_MACHINE_UNLUCKIER] = 15,
[SLOT_MACHINE_UNLUCKY] = 15,
[SLOT_MACHINE_LUCKY] = 18,
[SLOT_MACHINE_LUCKIER] = 19,
[SLOT_MACHINE_LUCKIEST] = 22
},
{ // Probabilities for LUCKY_BIAS_LOTAD
[SLOT_MACHINE_UNLUCKIEST] = 25,
[SLOT_MACHINE_UNLUCKIER] = 25,
[SLOT_MACHINE_UNLUCKY] = 25,
[SLOT_MACHINE_LUCKY] = 30,
[SLOT_MACHINE_LUCKIER] = 30,
[SLOT_MACHINE_LUCKIEST] = 40
},
{ // Probabilities for LUCKY_BIAS_CHERRY
[SLOT_MACHINE_UNLUCKIEST] = 25,
[SLOT_MACHINE_UNLUCKIER] = 25,
[SLOT_MACHINE_UNLUCKY] = 20,
[SLOT_MACHINE_LUCKY] = 20,
[SLOT_MACHINE_LUCKIER] = 15,
[SLOT_MACHINE_LUCKIEST] = 15
},
{ // Probabilities for LUCKY_BIAS_REPLAY
[SLOT_MACHINE_UNLUCKIEST] = 40,
[SLOT_MACHINE_UNLUCKIER] = 40,
[SLOT_MACHINE_UNLUCKY] = 35,
[SLOT_MACHINE_LUCKY] = 35,
[SLOT_MACHINE_LUCKIER] = 40,
[SLOT_MACHINE_LUCKIEST] = 40
}
};
static const u8 sReeltimeProbabilities_UnluckyGame[][17] = {
@ -5708,7 +5760,7 @@ static const struct SpriteTemplate sSpriteTemplate_DigitalDisplay_Insert =
static const struct SpriteTemplate sSpriteTemplate_DigitalDisplay_Stop =
{
.tileTag = 18,
.tileTag = GFXTAG_STOP,
.paletteTag = PALTAG_DIG_DISPLAY,
.oam = &sOam_8x8,
.anims = sAnims_SingleFrame,
@ -5741,7 +5793,7 @@ static const struct SpriteTemplate sSpriteTemplate_DigitalDisplay_Lose =
static const struct SpriteTemplate sSpriteTemplate_DigitalDisplay_Bonus =
{
.tileTag = 19,
.tileTag = GFXTAG_BONUS,
.paletteTag = PALTAG_DIG_DISPLAY,
.oam = &sOam_8x8,
.anims = sAnims_SingleFrame,
@ -5752,7 +5804,7 @@ static const struct SpriteTemplate sSpriteTemplate_DigitalDisplay_Bonus =
static const struct SpriteTemplate sSpriteTemplate_DigitalDisplay_Big =
{
.tileTag = 20,
.tileTag = GFXTAG_BIG,
.paletteTag = PALTAG_DIG_DISPLAY,
.oam = &sOam_8x8,
.anims = sAnims_SingleFrame,
@ -5763,7 +5815,7 @@ static const struct SpriteTemplate sSpriteTemplate_DigitalDisplay_Big =
static const struct SpriteTemplate sSpriteTemplate_DigitalDisplay_Reg =
{
.tileTag = 21,
.tileTag = GFXTAG_REG,
.paletteTag = PALTAG_DIG_DISPLAY,
.oam = &sOam_8x8,
.anims = sAnims_SingleFrame,

View File

@ -145,7 +145,7 @@ static void ResolveNumberOneShow(u16);
static void TryPutFishingAdviceOnAir(void);
static u8 MonDataIdxToRibbon(u8);
static void TryPutNumberOneOnAir(u8);
static bool8 IsPriceDiscounted(u8);
static bool8 ShouldApplyPokeNewsEffect(u8);
static void TryPutWorldOfMastersOnAir(void);
static void InterviewBefore_FanClubLetter(void);
static void InterviewBefore_RecentHappenings(void);
@ -1525,7 +1525,7 @@ void TryPutSmartShopperOnAir(void)
show->smartshopperShow.itemIds[i] = gMartPurchaseHistory[i].itemId;
show->smartshopperShow.itemAmounts[i] = gMartPurchaseHistory[i].quantity;
}
show->smartshopperShow.priceReduced = GetPriceReduction(POKENEWS_SLATEPORT);
show->smartshopperShow.priceReduced = IsPokeNewsActive(POKENEWS_SLATEPORT);
StringCopy(show->smartshopperShow.playerName, gSaveBlock2Ptr->playerName);
StorePlayerIdInRecordMixShow(show);
show->smartshopperShow.language = gGameLanguage;
@ -2641,7 +2641,7 @@ void DoPokeNews(void)
}
}
bool8 GetPriceReduction(u8 newsKind)
bool8 IsPokeNewsActive(u8 newsKind)
{
u8 i;
@ -2652,7 +2652,7 @@ bool8 GetPriceReduction(u8 newsKind)
{
if (gSaveBlock1Ptr->pokeNews[i].kind == newsKind)
{
if (gSaveBlock1Ptr->pokeNews[i].state == 2 && IsPriceDiscounted(newsKind))
if (gSaveBlock1Ptr->pokeNews[i].state == 2 && ShouldApplyPokeNewsEffect(newsKind))
return TRUE;
return FALSE;
@ -2661,7 +2661,11 @@ bool8 GetPriceReduction(u8 newsKind)
return FALSE;
}
static bool8 IsPriceDiscounted(u8 newsKind)
// Returns TRUE if the effects of the given PokeNews should be applied.
// For POKENEWS_SLATEPORT / POKENEWS_LILYCOVE, only apply the effect (price reduction)
// if the player is talking to the Energy Guru / at the Dept Store Rooftop.
// For any other type of PokeNews this is always TRUE.
static bool8 ShouldApplyPokeNewsEffect(u8 newsKind)
{
switch (newsKind)
{