Skip to content

Commit a868b99

Browse files
Hirmuoliokevingranade
authored andcommitted
Thermal energy based temperature system (CleverRaven#27387)
* set_temperature also sets energy, set product temp In old system crafted items just reset the temp check without setting the actual temperature. Not going to try to implement anything fancy for that so crafted items that are not heated up are just set to 20 C which should behave similarly to old system. Temperature is now calculated with newton's law of cooling. No more using approximation of an approximation. * Energy and temperature are in 0.00001 J/g and K
1 parent 84c5471 commit a868b99

File tree

13 files changed

+717
-253
lines changed

13 files changed

+717
-253
lines changed

data/json/materials.json

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@
6262
"ident": "bone",
6363
"name": "Bone",
6464
"density": 7,
65+
"specific_heat_liquid": 1.2,
66+
"specific_heat_solid": 1.2,
67+
"latent_heat": 200,
6568
"edible": true,
6669
"bash_resist": 2,
6770
"cut_resist": 3,
@@ -221,6 +224,9 @@
221224
"ident": "egg",
222225
"name": "Egg",
223226
"density": 3,
227+
"specific_heat_liquid": 3.63,
228+
"specific_heat_solid": 1.95,
229+
"latent_heat": 252,
224230
"edible": true,
225231
"bash_resist": 0,
226232
"cut_resist": 0,
@@ -239,6 +245,9 @@
239245
"ident": "flesh",
240246
"name": "Flesh",
241247
"density": 5,
248+
"specific_heat_liquid": 3.7,
249+
"specific_heat_solid": 2.15,
250+
"latent_heat": 260,
242251
"edible": true,
243252
"bash_resist": 1,
244253
"cut_resist": 1,
@@ -276,6 +285,9 @@
276285
"ident": "fruit",
277286
"name": "Fruit Matter",
278287
"density": 4,
288+
"specific_heat_liquid": 3.9,
289+
"specific_heat_solid": 1.9,
290+
"latent_heat": 290,
279291
"edible": true,
280292
"bash_resist": 1,
281293
"cut_resist": 1,
@@ -399,6 +411,9 @@
399411
"ident": "hflesh",
400412
"name": "Human Flesh",
401413
"density": 5,
414+
"specific_heat_liquid": 3.7,
415+
"specific_heat_solid": 2.15,
416+
"latent_heat": 260,
402417
"edible": true,
403418
"bash_resist": 1,
404419
"cut_resist": 1,
@@ -421,6 +436,9 @@
421436
"ident": "honey",
422437
"name": "Honey",
423438
"density": 1,
439+
"specific_heat_liquid": 2.03,
440+
"specific_heat_solid": 2.03,
441+
"latent_heat": 57,
424442
"edible": true,
425443
"bash_resist": 0,
426444
"cut_resist": 0,
@@ -459,6 +477,9 @@
459477
"ident": "iflesh",
460478
"name": "Insect Flesh",
461479
"density": 5,
480+
"specific_heat_liquid": 3.7,
481+
"specific_heat_solid": 2.15,
482+
"latent_heat": 260,
462483
"edible": true,
463484
"bash_resist": 1,
464485
"cut_resist": 1,
@@ -498,6 +519,9 @@
498519
"ident": "junk",
499520
"name": "Junk Food",
500521
"density": 4,
522+
"specific_heat_liquid": 3.3,
523+
"specific_heat_solid": 2.05,
524+
"latent_heat": 220,
501525
"edible": true,
502526
"bash_resist": 1,
503527
"cut_resist": 1,
@@ -572,6 +596,9 @@
572596
"ident": "milk",
573597
"name": "Dairy",
574598
"density": 1,
599+
"specific_heat_liquid": 3.89,
600+
"specific_heat_solid": 1.81,
601+
"latent_heat": 293,
575602
"edible": true,
576603
"bash_resist": 0,
577604
"cut_resist": 0,
@@ -651,6 +678,9 @@
651678
"ident": "oil",
652679
"name": "Oil",
653680
"density": 1,
681+
"specific_heat_liquid": 2,
682+
"specific_heat_solid": 1.8,
683+
"latent_heat": 200,
654684
"edible": true,
655685
"bash_resist": 0,
656686
"cut_resist": 0,
@@ -711,6 +741,9 @@
711741
"ident": "powder",
712742
"name": "Powder",
713743
"density": 1,
744+
"specific_heat_liquid": 1.5,
745+
"specific_heat_solid": 1.2,
746+
"latent_heat": 10,
714747
"bash_resist": 1,
715748
"cut_resist": 1,
716749
"acid_resist": 0,
@@ -731,6 +764,9 @@
731764
"ident": "powder_nonflam",
732765
"name": "Powder",
733766
"density": 1,
767+
"specific_heat_liquid": 1.5,
768+
"specific_heat_solid": 1.2,
769+
"latent_heat": 10,
734770
"bash_resist": 1,
735771
"cut_resist": 1,
736772
"acid_resist": 0,
@@ -832,6 +868,9 @@
832868
"ident": "veggy",
833869
"name": "Vegetable Matter",
834870
"density": 4,
871+
"specific_heat_liquid": 3.9,
872+
"specific_heat_solid": 1.9,
873+
"latent_heat": 290,
835874
"edible": true,
836875
"bash_resist": 1,
837876
"cut_resist": 1,
@@ -854,6 +893,9 @@
854893
"ident": "tomato",
855894
"name": "Tomato",
856895
"density": 4,
896+
"specific_heat_liquid": 3.9,
897+
"specific_heat_solid": 1.9,
898+
"latent_heat": 290,
857899
"edible": true,
858900
"bash_resist": 1,
859901
"cut_resist": 1,
@@ -876,6 +918,9 @@
876918
"ident": "bean",
877919
"name": "Bean",
878920
"density": 4,
921+
"specific_heat_liquid": 3.9,
922+
"specific_heat_solid": 1.9,
923+
"latent_heat": 290,
879924
"edible": true,
880925
"bash_resist": 1,
881926
"cut_resist": 1,
@@ -898,6 +943,9 @@
898943
"ident": "garlic",
899944
"name": "Garlic",
900945
"density": 4,
946+
"specific_heat_liquid": 3.9,
947+
"specific_heat_solid": 1.9,
948+
"latent_heat": 290,
901949
"edible": true,
902950
"bash_resist": 1,
903951
"cut_resist": 1,
@@ -920,6 +968,9 @@
920968
"ident": "nut",
921969
"name": "Nut",
922970
"density": 5,
971+
"specific_heat_liquid": 2.2,
972+
"specific_heat_solid": 2.2,
973+
"latent_heat": 20,
923974
"edible": true,
924975
"bash_resist": 1,
925976
"cut_resist": 1,
@@ -942,6 +993,9 @@
942993
"ident": "mushroom",
943994
"name": "Mushroom",
944995
"density": 4,
996+
"specific_heat_liquid": 3.9,
997+
"specific_heat_solid": 1.9,
998+
"latent_heat": 290,
945999
"edible": true,
9461000
"bash_resist": 1,
9471001
"cut_resist": 1,
@@ -964,6 +1018,9 @@
9641018
"ident": "water",
9651019
"name": "Water",
9661020
"density": 1,
1021+
"specific_heat_liquid": 4.186,
1022+
"specific_heat_solid": 2.108,
1023+
"latent_heat": 333,
9671024
"edible": true,
9681025
"bash_resist": 0,
9691026
"cut_resist": 0,
@@ -985,6 +1042,9 @@
9851042
"ident": "wheat",
9861043
"name": "Wheat",
9871044
"density": 4,
1045+
"specific_heat_liquid": 2,
1046+
"specific_heat_solid": 2,
1047+
"latent_heat": 150,
9881048
"edible": true,
9891049
"bash_resist": 1,
9901050
"cut_resist": 1,

doc/JSON_INFO.md

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -249,21 +249,38 @@ The syntax listed here is still valid.
249249
| `acid_resist` | Ability of a material to resist acid.
250250
| `elec_resist` | Ability of a material to resist electricity.
251251
| `fire_resist` | Ability of a material to resist fire.
252+
| `dmg_adj` | Adjectives used to describe damage states of a material.
252253
| `density` | Density of a material.
254+
| `vitamins` | Vitamins in a material. Usually overridden by item specific values.
255+
| `specific_heat_liquid` | Specific heat of a material when not frozen (J/(g K)). Default 4.186.
256+
| `specific_heat_solid` | Specific heat of a material when frozen (J/(g K)). Default 2.108.
257+
| `latent_heat` | Latent heat of a material (J/g). Default 334.
253258

254259
```C++
255260
{
256-
"ident" : "hflesh",
257-
"name" : "Human Flesh",
258-
"bash_resist" : 1,
259-
"cut_resist" : 1,
260-
"bash_dmg_verb" : "bruised",
261-
"cut_dmg_verb" : "sliced",
262-
"dmg_adj" : ["bruised", "mutilated", "badly mutilated", "thoroughly mutilated"],
263-
"acid_resist" : 1,
264-
"elec_resist" : 1,
265-
"fire_resist" : 0,
266-
"density" : 5
261+
"type": "material",
262+
"ident": "hflesh",
263+
"name": "Human Flesh",
264+
"density": 5,
265+
"specific_heat_liquid": 3.7,
266+
"specific_heat_solid": 2.15,
267+
"latent_heat": 260,
268+
"edible": true,
269+
"bash_resist": 1,
270+
"cut_resist": 1,
271+
"acid_resist": 1,
272+
"fire_resist": 1,
273+
"elec_resist": 1,
274+
"chip_resist": 2,
275+
"dmg_adj": [ "bruised", "mutilated", "badly mutilated", "thoroughly mutilated" ],
276+
"bash_dmg_verb": "bruised",
277+
"cut_dmg_verb": "sliced",
278+
"vitamins": [ [ "calcium", 0.1 ], [ "vitB", 1 ], [ "iron", 1.3 ] ],
279+
"burn_data": [
280+
{ "fuel": 1, "smoke": 1, "burn": 1, "volume_per_turn": "2500_ml" },
281+
{ "fuel": 2, "smoke": 3, "burn": 2, "volume_per_turn": "10000_ml" },
282+
{ "fuel": 3, "smoke": 10, "burn": 3 }
283+
]
267284
}
268285
```
269286

src/crafting.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -768,16 +768,15 @@ void player::complete_craft()
768768

769769
if( should_heat ) {
770770
newit.heat_up();
771-
} else {
771+
} else if( newit.is_food() || newit.is_food_container() ) {
772772
// Really what we should be doing is averaging the temperatures
773773
// between the recipe components if we don't have a heat tool, but
774-
// that's kind of hard. For now just reset the temperature, don't
774+
// that's kind of hard. For now just set the item to 20 C
775+
// and reset the temperature, don't
775776
// forget byproducts below either when you fix this.
776777
//
777-
// Also, this is going to reset the temperature on non-food items
778-
// as well. This isn't a big deal because they don't care about
779-
// temperature (yet?) and it's actually more costly to check for
780-
// is_food() than just reset the timer.
778+
// Temperature is not functional for non-foods
779+
newit.set_item_temperature( 293.15 );
781780
newit.reset_temp_check();
782781
}
783782

@@ -793,7 +792,8 @@ void player::complete_craft()
793792
}
794793
if( should_heat ) {
795794
bp.heat_up();
796-
} else {
795+
} else if( bp.is_food() || bp.is_food_container() ) {
796+
bp.set_item_temperature( 293.15 );
797797
bp.reset_temp_check();
798798
}
799799
finalize_crafted_item( bp );

src/game_constants.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
/** Temperature constants */
8383
namespace temperatures
8484
{
85-
/** temperature at which something starts warming and can become HOT */
85+
/** temperature at which something starts is considered HOT */
8686
constexpr int hot = 100; // ~ 38 Celsius
8787

8888
/** the "normal" temperature midpoint between cold and hot */
@@ -92,7 +92,7 @@ constexpr int normal = 70; // ~ 21 Celsius
9292
constexpr int fridge = 37; // ~ 2.7 Celsius
9393

9494
/** Temperature at which things are considered "cold" */
95-
constexpr int cold = 40;
95+
constexpr int cold = 40; // ~4.4 C
9696

9797
/** Temperature inside an active freezer in Fahrenheit */
9898
constexpr int freezer = 23; // -5 Celsius

0 commit comments

Comments
 (0)