What I think I will do is look at a very simple, linear system.
Base body temp 37C + 0.10*warmth , base outdoor temp 22C.
Body temp will {+0.5, -0.5} for each {+2, -2} degrees outdoor temp stays from 22C. For every -2C, your body loses 0.5C. At 24C, you are 37.5 + 0.10amount of warmth. At 20C, you are 36.5 + 0.10amount of warmth. Simple solution. If you are indoor, changes occur at {+1, -4} ; indoor is hotter. Under ground could be {+3, -3}, or something similar once humidity is modeled. If you are wet, {+4, -1}, or perhaps your warmth modifier is cut in half, or even ignored. **see edit
The only thing that’s missing is a higher temp change at high gaps of temps. Perhaps for every 4 degrees the outdoor temp is different from the body temp, it’s a x2 to the +/-. If you are sitting at 37C and step outside to 6C, your body temp will change (-0.5 + warmth)*2^(4). The cap remains the same, but your body temp reaches it quicker.
I think this system could work. Body temps rise and fall with outdoor temp, fast if the gap is great. Body temps will not “reach” ambient temps, because “they generate heat” (ie my code doesn’t let them wander).
I don’t think limbs need body temps, perhaps just warmth; if modifier*warmth does not exceed temperature, then penalties occur. Like I mentioned in the other thread, the penalties will be of varying intensity, but the duration will only last until a small time after limbs and body are covered up. Perhaps 10 turns * intensity.
EDIT : Instead, the +/-0.5 will be a cap on body temp, and it will increment 0.1*2^(abs(22C - temp)/4) or something. It will take some time to reach a cap.
EDIT 2 : Here is my code at the moment.
void game::update_bodytemp()
{
// Reference units
int base_bodytemp = 37; // Celsius
int base_airtemp = 22; // Celsius, disregards humidity at the moment
int converging_bodytemp = 37; // Bodytemp wants to converge to this ; starts at 37C
int Ctemperature = (temperature - 32) * 5/9; // Converts temperature to Celsius!(Wito plans on using degrees Kelvin later)
int temp_gap = Ctemperature - base_airtemp; // distance between reference temperature and actual temperature ; this is negative if it is colder out.
// Determine max bodytemp
// PSEUDO CODE : need real values for outdoor, warmth and wetness
if ( outdoor && temp_gap < 0) {converging_bodytemp = base_bodytemp + temp_gap*0.20 + 0.10*(1 - wetness)*warmth;}
else if ( outdoor && temp_gap > 0) {converging_bodytemp = base_bodytemp + temp_gap*0.30 + 0.10*(1 - wetness)*warmth;}
else if (!outdoor && temp_gap < 0) {converging_bodytemp = base_bodytemp + temp_gap*0.50 + 0.10*(1 - wetness)*warmth;}
else (!outdoor && temp_gap > 0) {converging_bodytemp = base_bodytemp + temp_gap*0.10 + 0.10*(1 - wetness)*warmth;}
// Actually change bodytemp
if (turn % 10 == 0 && bodytemp > converging_bodytemp){ //if you're hotter than your surroundings
bodytemp -= 0.1*2^(temp_gap/4);
else if (turn % 10 == 0 && bodytemp > converging_bodytemp) //if you're colder
bodytemp += 0.1*2^(temp_gap/4);
else //if you're just right, +/- 0.1
bodytemp += rng(-1, 1)/10;
}
// Diseases
// Body temp can ready three levels of low or high. Each level corresponds to the intensity of the disease, and brings with it symptoms.
// The disease will last until the player is warmed up enough. Of course, it takes time for the body to warm up ; the higher the max temp, the faster the player warms up.
// Remedys like drinking fluids or being near a fire _should_ reduce the intensity, but I am not sure how... perhaps by adding a flat amount to body temp. Hot adds, cold removes.
}
I am aware I am using int for things that clearly are not integers. I would like advice on that. Also, wetness in my mind is a measure of the morale wetness : from 0 to 50, and decreases slowly.
I am also not a coder, but I do have a math background and coding intrigues me. Any tips on how to make this more effecient or clean, let me know 