Hey y’all. I was wondering if it was possible to connect different variables to each other. Say, if I have three different variables for the mcs army (morale, discipline, and stamina) but I want to express the overall condition using just one variable like army strength so an increase in morale will result in a proportional increase in army strength without me having to write “*set armystrength-10” and I can also be able to reduce the strength and cause a decrease in the other three stats as well. Is there a way to do it or do I have to do the changes manually?
You have to define what’s the relationship between these variables and army_strength
. Is army_strength
the average, the sum, or something else?
To keep the values in sync, every time you update one of the base values, you’ll have to update army_strength as well. There’s no way to do that automatically.
On the other hand, if you’re only going to use the derived value in the stats screen, you can do the calculation right there, so whenever the player opens the stats, army_strength will be up to date. Otherwise, I’m afraid, you’ll have to do it manually.
Ah, I see. At least I don’t feel stupid for doing it manually all this time
There is an alternative to updating everything manually. That is to make a subroutine or scene dedicated to performing updates and whatnot that are always calculated the same way. Here is the minimum working example:
startup.txt
*comment startup.txt
*title Help With Stats
*author J. S. Fung
*scene_list
startup
chapter1
*create army_strength 50
*create army_morale 50
*create army_discipline 50
*create army_stamina 50
Here we assume army_strength is:
30% army_morale
30% army_discipline
40% army_stamina
*finish
chapter1.txt
*comment chapter1.txt
*temp change 0
*label stat_change
army_strength: ${army_strength}
army_morale: ${army_morale}
army_discipline: ${army_discipline}
army_stamina: ${army_stamina}
*choice
#Update army strength.
Current army_strength: ${army_strength}
Enter the decrease in army strength (negative numbers only).
[i](This can also be set in code instead)[/i]
*input_number change (0 - army_strength) 0
*gosub_scene subroutines decrease_armystrength change
*goto stat_change
#Update morale.
Current army_morale: ${army_morale}
Enter the army morale.
[i](This can also be set in code instead)[/i]
*input_number army_morale 0 100
*gosub_scene subroutines calc_armystrength
*goto stat_change
#Update discipline.
Current army_discipline: ${army_discipline}
Enter the army discipline.
[i](This can also be set in code instead)[/i]
*input_number army_discipline 0 100
*gosub_scene subroutines calc_armystrength
*goto stat_change
#Update stamina.
Current army_stamina: ${army_stamina}
Enter the army stamina.
[i](This can also be set in code instead)[/i]
*input_number army_stamina 0 100
*gosub_scene subroutines calc_armystrength
*goto stat_change
#End
*goto continue
*label continue
This concludes the test.
*finish
subroutines.txt
*comment subroutines.txt
*label calc_armystrength
*comment change to match your formulation
*set army_strength (((0.3*army_morale) + (0.3*army_discipline)) + (0.4*army_stamina))
*return
*label decrease_armystrength
*params strength_change
*temp strength_percent (strength_change / army_strength)
*set army_morale + (army_morale * strength_percent)
*set army_discipline + (army_discipline * strength_percent)
*set army_stamina + (army_stamina * strength_percent)
*set army_strength + strength_change
*return
Below are some screenshots of the example being tested.
Thanks. I had no idea you could do this
This topic was automatically closed 24 hours after the last reply. If you want to reopen your WiP, contact the moderators.