void game::update_bodytemp()
{
// NOTE I didn't do anything with levz, bionics, or diseases
int Ctemperature = (temperature - 32) * 5/9; // Converts temperature to Celsius!(Wito plans on using degrees Kelvin later)
int temp_gap = 10*(Ctemperature - 22); // distance actual temp and room temp (22C) ; this value is negative when it is colder than 22C
int warmth = u.warmth(bp_head) + u.warmth(bp_eyes) + u.warmth(bp_mouth) + u.warmth(bp_torso); // At the moment, warmth is only head/face and torso
// Determine max bodytemp
int impact = 0;
if (!m.is_outside(u.posx, u.posy)) {impact = 1;}
if ( m.is_outside(u.posx, u.posy)) {impact = 4;}
/* Fetch the morale value of wetness for bodywetness
for (int i = 0; bodywetness == 0 && i < u.morale.size(); i++)
if( u.morale.type == MORALE_WET ) {
bodywetness = u.morale.bonus;
}
*/
int warmth_bonus = 0;
if (temp_gap > 0) {warmth_bonus = 3*warmth/2;}
else if (temp_gap < 0) {warmth_bonus = 3*warmth*2;}
converging_bodytemp = 370
+ temp_gap*impact/10
+ warmth_bonus
//- bodywetness
;
unsigned int body_temp_gap = bodytemp - converging_bodytemp;
// Actually change bodytemp
if (bodytemp != converging_bodytemp){
if (bodytemp > converging_bodytemp && converging_bodytemp < 370) {bodytemp -= 1*abs(body_temp_gap)/4;} // It is cold, you are getting cold
else if (bodytemp > converging_bodytemp && converging_bodytemp > 370) {bodytemp -= 1;} // It is warm, you are getting cold
else if (bodytemp < converging_bodytemp && converging_bodytemp < 370) {bodytemp += 1;} // It is cold, you are getting warm
else if (bodytemp < converging_bodytemp && converging_bodytemp > 370) {bodytemp += 1*abs(body_temp_gap)/4;} // It is warm, you are getting warm
}
// Diseases
if (bodytemp < 350) {
if (u.has_disease(DI_COLD) == false) {add_msg("You have mild hypothermia.");}
u.add_disease(DI_COLD, 11, this, 1, 1);
} else if (bodytemp < 325) {
add_msg("You have moderate hypothermia.");
u.add_disease(DI_COLD, 11, this, 2, 2);
} else if (bodytemp < 300) {
add_msg("You have severe hypothermia.");
u.add_disease(DI_COLD, 11, this, 3, 3);
} else if (bodytemp > 390) {
add_msg("You have mild hyperthermia.");
} else if (bodytemp > 410) {
add_msg("You have moderate hyperthermia.");
} else if (bodytemp > 430) {
add_msg("You have severe hyperthermia.");
} else if (bodytemp < 280 || bodytemp > 460) {
add_msg("You die from too much thermia."); // This kills the player
}
When running the wetness code, I got this error. It seems morale isn’t detailed enough at the moment.
g++ -g -c game.cpp -o obj/game.o
game.cpp: In member function ‘void game::update_bodytemp()’:
game.cpp:720:15: erreur: ‘class std::vector<morale_point>’ has no member named ‘type’
game.cpp:721:26: erreur: ‘class std::vector<morale_point>’ has no member named ‘bonus’
game.cpp:725:2: erreur: expected ‘,’ or ‘;’ before ‘if’
game.cpp:726:2: erreur: ‘else’ without a previous ‘if’
game.cpp:777:38: erreur: expected primary-expression before ‘const’
Makefile:125: recipe for target `obj/game.o' failed
make: *** [obj/game.o] Error 1
Also! The disease section works The only issue is that the message for -thermias play every ten turns. The u.has_disease() doesn’t recognize intensity (I don’t think), which is what I would really want. If the DI_COLD gets worse, tell the player ; if not, don’t say anything.
I cleaned up the converging_bodytemp stuff, it was more complicated than it needed to be. I also added the fact that strong at resisting cold but weak and increasing heat. I still have to play with the numbers though.
What I would like specific advice on is on how to clean up the bodytemp increment code. There are four different cases, and I want the bodytemp to increment differently for each. For example, if it is super cold out, the bodytemp should drop a lot, but if you layer up a ton, you shouldn’t suddenly gain heat like mad.
I ramble a lot in these posts, so don’t think you have to comment or solve everything ;p anyway, movie time.
edit: I find myself wishing I could use exponents. Should I, or is that bad? Because I really want this to be exponential…