Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Heat up bodyparts over adjacent fires #9974

Merged
merged 6 commits into from Nov 18, 2014

Conversation

Projects
None yet
7 participants
@Coolthulhu
Copy link
Contributor

commented Nov 11, 2014

Makes the non-sleeping survivors heat up bodyparts when there's an adjacent fire. Torso, head and legs don't get much heat unless the fire is big. Arms get more and hands get a lot, because you can get them close to fire.
Feet get only a tiny bit, unless the survivor is on a chair and then they get a lot.

Only chairs, armchairs and benches are recognized as chairs. Beds would probably catch fire from the sparks, vehicle seats would probably be hard to get in a good position.
Any other good chair-type furniture? Something non-flammable would be nice, because currently comfy campfire isn't possible.

Only the best fire is used, because one cannot extend arm over two fires at once.

Additionally I fixed a moderately severe bug with fire heat: fire heat would use max(1,max(j, k)) as distance, despite j and k often having negative values. This would make fires to the north and to the west always as hot as if they were adjacent.

@KA101

This comment has been minimized.

Copy link
Contributor

commented Nov 11, 2014

Nice catch re the coordinates.

One thing I'd point out: any contained single-tile fire is going to be Small, and any fire larger than that is probably gonna get you Warm (if not Toasty) just fine on its own.

@Coolthulhu

This comment has been minimized.

Copy link
Contributor Author

commented Nov 11, 2014

It usually will, but especially badly-geared survivors still can use it. Also, winter lab dives without good equipment (just painkillers to stop frostbite pain) can benefit from it.

Is there a good way of bypassing the convergent temperature thing when temperature is too low? It would be more useful if survivors with icicles for hands could heat up at full speed even if they only need a couple of degrees.

@Coolthulhu

This comment has been minimized.

Copy link
Contributor Author

commented Nov 11, 2014

Added rapid cooling and heating both to fires and sleeping.
Instead of using only regular temperature converging mechanic, both sleep and fire will use maximum possible heat when heating up and none when cooling down, then clamp if this results in too much/too little heat to keep comfortable.

How it works from the realism perspective:
Frozen survivors will essentially put on all the blankets at first and then kick off some during sleep instead of using only enough to eventually get comfy. Similar thing happens when lying down to sleep in a cool basement after taking off that hot armor - survivor won't cover self with blankets when overheated (even when the room is cold) until some of that extra heat dissipates.
It also works with fire: survivors will extend hands pretty much next to fire when they're even slightly cold instead of putting them in a spot where they would eventually reach comfy temperature.

This helps to make my idea useful: now you can set up a fire to quickly warm up frozen hands and go back to work, rather than just having a fire make your torso very warm while making hands cold (from freezing), because you spawned without winter gloves but with a winter coat.

if (frostbite_timer[i] > 0) {
frostbite_timer[i] -= heat_intensity - fire_dist / 2;
}
temp_conv[i] += 300 * heat_intensity * heat_intensity / (fire_dist * fire_dist);
blister_count += heat_intensity / (fire_dist * fire_dist);
if( std::abs( j ) <= 1 && std::abs( k ) <= 1 ) {

This comment has been minimized.

Copy link
@kevingranade

kevingranade Nov 11, 2014

Member

Just use fire_dist <= 1

temp_cur[i] = temp_max;
}
// Don't alarm the player with this extra heat - it won't cause debuffs
if( temp_conv[i] > BODYTEMP_NORM ) {

This comment has been minimized.

Copy link
@kevingranade

kevingranade Nov 11, 2014

Member

I don't like playing games like this, it's either heating you up fast, or it's not. Whatever it's doing, display it.

@@ -1204,6 +1227,28 @@ void player::update_bodytemp()
if( temp_cur[i] != temp_conv[i] ) {
temp_cur[i] = temp_difference * exp(-0.002) + temp_conv[i] + rounding_error;
}
// Rapid heating with clothes on the ground or adjactent fire

This comment has been minimized.

Copy link
@kevingranade

kevingranade Nov 11, 2014

Member

This section is unnecessary and confusing, if you're introducing an additional heat source, bump up temp_conv and evaluate it as normal. If you're concerned about a spike in heat confusing the player, output some log messages letting them know what's happening.

@Coolthulhu

This comment has been minimized.

Copy link
Contributor Author

commented Nov 11, 2014

I've tested a few ideas, but I'm not sure which one would be the most proper:

  1. Invert the formula and calculate the desired temp_conv
  2. Let it overshoot and undershoot a bit. Due to windchill and hot air, temperatures fluctuate wildly anyway
  3. Clean up the current idea - calculate both minimal and maximal temperature that can be achieved with this extra heat, then apply one of them or BODYTEMP_NORM

Anything better that I'm missing?

@Coolthulhu

This comment has been minimized.

Copy link
Contributor Author

commented Nov 11, 2014

Went with the inverted formula. I calculate desired temp_conv (+/- some), then try to get it by adding some or all of the bonus heat.
Works as expected, though the numbers might need a slight to moderate buff - only hands are noticeably warmed up.

I may have discovered a bug: fire temperature formula uses sees(int, int), which seems to use player::sees(int, int, int&) which respects clairvoyance and uses seen cache after that, possibly skipping fire obscured by smoke and fires not visible due to short-sightedness or blindness.
EDIT: Confirmed the bug above. Filed a proper bug report, because I haven't seen any reachable()-type function to quickly fix this up here.
#9978

@Mshock777

This comment has been minimized.

Copy link
Contributor

commented Nov 11, 2014

My humble opinion: there is more furniture, as well as normal items, that can be used to "sit down by the fire", so 4 times difference for these 3 cases feels kind of odd.

@Shoes01

This comment has been minimized.

Copy link
Contributor

commented Nov 11, 2014

This is great work, fire code warming the player is something I've neglected for a long time.

Looking at your work on lines 1218, I have a suggestion. You're trying to allow the player to warm up without letting him get too hot, right? So you're trying to calculate the buff needed to get you to comfortable. I would simply do "if (bonus_warmth > 0 && temp_cur[i] < BODYTEMP_WARM)". What would essentially happen is that the player would withdraw his hands when they are warm.

But yeah, if you have any questions about the logic used, let me know! These are exciting changes.

@boydkr

This comment has been minimized.

Copy link
Contributor

commented Nov 11, 2014

Very cool. The cleaned up code looks much better than the initial revision.

I look forward to trying this out.

break;
case bp_foot_l:
case bp_foot_r:
if( furn_at_pos == f_armchair || furn_at_pos == f_chair || furn_at_pos == f_bench ) {

This comment has been minimized.

Copy link
@kevingranade

kevingranade Nov 11, 2014

Member

Ideally this would be a furniture flag.

@kevingranade

This comment has been minimized.

Copy link
Member

commented Nov 11, 2014

Not sure if this does what you want, but have you considered maxxing the convergent temp at the lower bound of either warm or hot? That would basically model "You get as close as you can stand" (stand as in 'handle').

@@ -949,12 +950,16 @@ void player::update_bodytemp()
}
if (heat_intensity > 0 && sees(posx + j, posy + k)) {

This comment has been minimized.

Copy link
@BevapDin

BevapDin Nov 11, 2014

Contributor

map::sees might be useful here. It only checks the transparency of the squares via map::trans

@Coolthulhu

This comment has been minimized.

Copy link
Contributor Author

commented Nov 12, 2014

Added cap Kevin mentioned. Makes sense and prevents scary big values in the UI.
I removed the warning about warming next to fire, because before that I tied it to temp_conv value.

Now there's no outside way of seeing the fire heating, except for temperatures alone. Any good way of pointing out to player that this is the case?

What about small "got comfy" morale bonus dependent on bonus heat when current temperature is below warm? This would trigger both during sleep (a bit better mood in the morning) and during crafting and skillbook reading sessions next to fire.

@KA101

This comment has been minimized.

Copy link
Contributor

commented Nov 12, 2014

A minor morale bonus (2-4 points) would be worthwhile. Unfortunately, you'd need to touch strings there.

@kevingranade

This comment has been minimized.

Copy link
Member

commented Nov 13, 2014

This is big enough to fall under the feature freeze anyway.

@KA101

This comment has been minimized.

Copy link
Contributor

commented Nov 17, 2014

Thaw'd. Finish this up and let's get it queued for testing.

@Coolthulhu

This comment has been minimized.

Copy link
Contributor Author

commented Nov 17, 2014

I tested the values on my side, found them a fair bit too small and buffed the entire thing. It's still nowhere near "a lot", but enough to make fireplaces actually matter, especially for bodyparts vulnerable to frostbite.

Added the "comfy" morale bonus when the survivor is fully comfortable (no bodypart is warm or cold) and at least some bodyparts benefit from the bonus heat (ie. approach comfortable temp from below). Comfy bonus is applied for every bodypart, but has a global cap of 5.
In order to make it rise smoothly (like music) bodypart i which benefits from heat adds 1 morale bonus when calendar::turn%MINUTES( 1 ) == (MINUTES(i)/(MINUTES(num_bp)), so that the entire body is processed over the course of minute.
Comfy bonus will proc both for fire-warming and sleeping in comfortable place. Spelled "comfy" rather than "comfortable" to distinguish it from comfortable temperature.

@KA101 KA101 self-assigned this Nov 17, 2014

@KA101

This comment has been minimized.

Copy link
Contributor

commented Nov 17, 2014

May have to revisit comfy (and I'll add a translation note because it's slang USian: in future, you can do so by using //~ explanation goes here before the string) but for now, let's make things happen.

@KA101 KA101 merged commit 82b854a into CleverRaven:master Nov 18, 2014

@Coolthulhu Coolthulhu deleted the cataclysmbnteam:fire-warming branch Nov 20, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.