summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGriffinR <griffin.g.richards@gmail.com>2021-11-16 13:55:02 -0500
committerGriffinR <griffin.g.richards@gmail.com>2021-11-16 15:43:52 -0500
commit5d9c31a610d8a6680a44b772fc1b88135d3884c3 (patch)
treed776a819221dec62b96314d2b172a50bb743007d /src
parent63c5905914b40d33e45a6a3101ab5a7da4375918 (diff)
Label slot machine ids, fix GetPriceReduction
Diffstat (limited to 'src')
-rw-r--r--src/field_specials.c37
-rw-r--r--src/scrcmd.c4
-rwxr-xr-xsrc/shop.c6
-rw-r--r--src/slot_machine.c124
-rw-r--r--src/tv.c14
5 files changed, 133 insertions, 52 deletions
diff --git a/src/field_specials.c b/src/field_specials.c
index dce9d8efa..22467cfee 100644
--- a/src/field_specials.c
+++ b/src/field_specials.c
@@ -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];
}
diff --git a/src/scrcmd.c b/src/scrcmd.c
index 98eaaf12c..04dff470b 100644
--- a/src/scrcmd.c
+++ b/src/scrcmd.c
@@ -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;
}
diff --git a/src/shop.c b/src/shop.c
index fa4a73bbb..f6fb2b9a0 100755
--- a/src/shop.c
+++ b/src/shop.c
@@ -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
diff --git a/src/slot_machine.c b/src/slot_machine.c
index 1c21f230d..6cbcd76fd 100644
--- a/src/slot_machine.c
+++ b/src/slot_machine.c
@@ -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,22 +1651,18 @@ 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];
- }
}
}
}
@@ -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_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_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[][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,
diff --git a/src/tv.c b/src/tv.c
index 4638fc621..64c3eb783 100644
--- a/src/tv.c
+++ b/src/tv.c
@@ -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)
{