I’m having trouble with setting a maximum attribute that cannot be exceeded, this is coming up in the following context:
A character can have a maximum stamina of 24, luck of 12 and skill of 12 and these are set at the start of the game .They cannot max out stats at the start (code attached last for clarity)
The player can lose stamina through being hurt, attacked etc and then regain this by eg eating a provision , or pick up a lucky item or increase their skill
However, if the character eg eats some provisions and I use the code of
*set stamina + 7
then they can exceed the maximum limit
for example, they can be on stamina of 18, eat provision and go to stamina 25
Is there a way to set an attribute so it cannot be exceeded?
Here is the code for the game start, it works, it is here for more context:
*label init
*temp ap 6
*temp skill_limit 4
*temp stamina_limit 6
*temp luck_limit 4
*temp skillset false
*temp luckset false
*temp staminaset false
*label choose_stats
You have ${ap} AP left to spend to increase your stats. Which stat do you want to increase
*choice
*selectable_if (skillset = false) #Skill
How many AP will you spend to increase skill? (1 - ${skill_limit})
*input_number stat1 1 skill_limit
*set skill +stat1
*set skillset true
*goto adjust_ap
*selectable_if (staminaset = false) #Stamina
How many AP will you spend to increase stamina? (1 - ${stamina_limit})
*input_number stat1 1 stamina_limit
*set stamina +stat1
*set staminaset true
*goto adjust_ap
*selectable_if (luckset = false) #Luck
How many AP will you spend to increase luck? (1 - ${luck_limit})
*input_number stat1 1 luck_limit
*set luck +stat1
*set luckset true
*goto adjust_ap
#I'm finished spending AP
*goto done
#Reset stats and AP
*set stamina 17
*set luck 8
*set skill 8
*goto init
*label adjust_ap
*set ap -stat1
*if ap < 1
*goto done
*if skill_limit > ap
*set skill_limit ap
*if stamina_limit > ap
*set stamina_limit ap
*if luck_limit > ap
*set luck_limit ap
*goto choose_stats
*label done
*goto_scene provisionstest