I'm using Yanfly's Actor Variables plug-in to create a Survival Needs system which works through common events
I'm making that each correspond to each party member's various needs (Very tedious work).
One of the Needs I had in mind was maintaining a character's body temperature in various climates.
Putting on equipment would add to a character's Warmth variable which is added to his/her Temperature variable.
I could use common events to add Warmth values if a particular actor was wearing this or that kind of clothing but since I'm going to add
at least hundreds of pieces of equipment, I knew that would be needlessly painstaking and tedious so I wonder if there's an easier way
by simply writing a piece of code in each Armor's note box.
Like:
Add.Variable.<<Harold>>Warmth.+2
(I know this isn't real coding but you get the idea, right?)
Any help would appreciated.
Thanks.
I would try makin cold a state that calls that common event with its variables.
the states are way easier to change into something like this, unless I am misunderstanding.
How familiar are you with js? I'm not sure how much this would help, but you can easily make extra equip stats using the meta data. You can add a tag <warmth: 2> The trick from here is making the code read and apply the tag. The basic way to do this would be calling the meta code via item.meta.warmth with item being the exact item as definded in the code. This part can vary based on the function you're working with. For example, if you wanted the warmth value of the first weapon in the party's inventory, you could use $gameParty._weapons[0].meta.warmth. Hope I didn't confuse you or over explain that...
I think the best approach for this, logically, is to treat it like actual temperature. Assign each character a body temperature. For humans that's 98.6°F or 37°C. If you don't want to use degrees, you could just use percentages to make life easier so you could have 100% = optimal body temperature. It's all the same it just depends on if you like nice round numbers or numbers you can compare to real life.
Let's assume you chose Farenheit since that's what I'm most familiar with.
You could then have your map (or even terrain) have a temperature value. A snowy mountain might be 30°, quite cold! An arid desert might be 110°, scorching!
Then you would affect the characters by raising or lowering their temperatures by a small amount at certain intervals. You could use common events but since we do have access to JavaScript, you could also do it based on a time interval like every 60 seconds. What you would do is determine how many interval ticks it should take for the character's body temp to match the terrain. I think 10 is probably realistic. So every minute (or whatever interval you choose) you would take the difference in temperature between the terrain and the character's optimal body temperature, divide that by 10 and then add the resulting number to their body temperature. I call this a rate of homeostasis (rate in which the temperature balances out).
You would then have safety thresholds for the characters. Perhaps at 105°F they start suffering heat exhaustion and start losing HP. Perhaps at 85°F they suffer hyperthermia and become sluggish.
For the clothes: For this last part you would add a property to your armor/clothing that would affect the rate in which body temperature changes. The formula you would use should be similar to the general formula for how the terrain affects temperature but warming garments would have a positive effect on temperature (increase) and cooling garments would have a negative effect (decrease). If the terrain has a homeostasis rate of 10%, most clothing would probably have a less powerful effect. A fur coat, for example, could have +5% warmth which would be a +5% homeostasis rate to increase temperature.
Let's look at some formulas to use as examples:
Snowy Mountain:
Terrain Temperature: 30°F.
Body Temperature: 98°F.
Homeostasis Rate: 10%
Temperature Changes: Every 60 seconds
Change Rate: (30-98) / 10 = -6.8° every minute
Arid Desert
Terrain Temperature: 110°F.
Body Temperature: 98°F.
Homeostasis Rate: 10%
Temperature Changes: Every 60 seconds
Change Rate: (110-98) / 10 = +1.2° every minute
Fur Coat
Homeostasis Rate: 5%
Change Rate: |(Terrain - Body)| / 20 = ??? [Depends on Terrain, Always Positive]
Skimpy Bathing Suit
Homeostasis Rate: 5%
Change Rate: (|(Terrain - Body) / 20|) * -1 = ??? [Depends on Terrain, Always Negative]
Fur Coat in Snowy Mountain:
Change Rate: |(30-98)| / 20 = +3.4° every minute
Overall Rate: [(30-98)/10] + [|(30-98)|/20] = -3.4° Every Minute
Fur Coat in Arid Desert:
Change Rate: |(110-98)| / 20 = +0.6° every minute
Overall Rate: [(110-98)/10] + [|(110-98)|/20] = +1.8° Every Minute
Bathing Suit in Snowy Mountain:
Change Rate: |(30-98) / 20| * -1= -3.4° every minute
Overall Rate: [(30-98)/10] + [|(30-98) / 20| * -1] = -10.2° Every Minute
Bathing Suit in Arid Desert:
Change Rate: [|(110-98)| / 20] * -1 = -0.6° every minute
Overall Rate: [(110-98)/10] + [|(110-98)/20| * -1] = +0.6° Every Minute
The pipe characters |these ones| mean absolute value (so regardless if the resulting number is negative, just use it as positive). Notice how the bathing suit actually makes you lose heat faster in the cold and the fur coat makes you overheat faster in the heat.
I realize this is not code at all but I think this is the basis for a much easier-to-code component. A solid logical design will make for code that's easier to maintain.