Shop Scripting
Overview
For Fateful Remedies to work as a viable game, we needed ways to show players that their decisions mattered and also a way to prevent the player from bombarding the customer with too many potions for one appointment. So the potions mana system was made and the stats tab had logic applied to it. What are these two things?
Shop Process
Overview
This process section separates into these three sections.
Setting Mana
Mana reduction
Visualization of stats
Setting Mana
Layman's Terms Summary
The amount of mana (the currency the player needs to give potions) the player has starts at 200 when the game begins. After every customer has their potions and once the week is done, the mana resets back to its original base 200. When enough in game weeks pass the amount that refreshes reduces and it becomes 175 midway through the game, and 135 in the endgame.
Mana Reduction
Layman's Terms Summary
During Fateful Remedies' run time, potions will cost varying amounts of mana, the better they alter stats the more they cost. So this system was made to balance things out. Mana subtracts with every potion that gets given to a customer, if the cost is over or equal to the required amount the potion will be given as intended, but if it's less the script and the game will let the player know and the potion won't be given.
Setting the stats
These functions fire off two times during each appointment, once at the beginning and again after a potion has been given. Originally this set of functions used to be shorter, though since the script used has been updated for awhile, so now each function is longer and requires more explanation.
Stat Visuals (Step 1: Readying)
Layman's Terms Summary
Directly below the shop U.I is another tab containing the customer's stats. Every single one is set to zero with every customer's first appointment, but before anything else can be done the findTextMesh function first finds and readies the numbers in the stats tab for alteration.
Stat Visuals (Step 3: Refreshing)
Layman's Terms Summary
After the previous stats are cleared visually, the getStatsForChar function grabs the updated stats from the director script and sets them to each customer's stats within the U.I. script. Which set of stats gets updated depends on who is in the scene.
Stat Visuals (Step 3: Refreshing)
Layman's Terms Summary
After the stats get updated within the script, the only thing left is updating them visually, which is what the setTextMesh function is for. What it does is convert the newly updated stats for each customer into text and replaces what number values were there originally.
End Result
The Shop
In a nutshell: when using the shop, the player selects a potion to give to their customer and then the stats of the potion will be applied immediately after. The player won't be able to give a potion if it's during a problem explanation, if they don't have the minimum amount of mana, or if a potion has already been given away.