Skip to content

Commit

Permalink
feat(content,port): corpses decay into items, use existing harvest en…
Browse files Browse the repository at this point in the history
…tries to actually implement feature, fix off-map decay behavior (#4751)

* Start with the actual code ports, fixing for item identity

Co-Authored-By: RenechCDDA <[email protected]>

* feat (port): corpses decay into items, actually implement in JSON

* style(autofix.ci): automated formatting

* Way better way to do this

* Delete harvest_decay.json

* style(autofix.ci): automated formatting

* Move now-unrelated changes to separate PR

* Now works off-map too

Father I crave violence

* A fix and some aesthetics

* Goofy ahh attempt to fix dupe

* Reworks how the logic works

There's one part I hate about this and that's the way I have to move stuff out of the `remove_with()` function to make it work.

Sort of works but non-count_by_charges harvest materials don't stack when spawning for some reason?

* Document code

* Copper wire fix

* Add chance to get CBMs from decay

---------

Co-authored-by: RenechCDDA <[email protected]>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: KheirFerrum <[email protected]>
  • Loading branch information
4 people authored Jun 14, 2024
1 parent cf7287e commit 1d53969
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 37 deletions.
62 changes: 31 additions & 31 deletions data/json/harvest.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@
{ "drop": "lung", "type": "flesh", "mass_ratio": 0.0035 },
{ "drop": "liver", "type": "offal", "mass_ratio": 0.01 },
{ "drop": "brain", "type": "flesh", "mass_ratio": 0.005 },
{ "drop": "bone", "type": "bone", "mass_ratio": 0.15 },
{ "drop": "sinew", "type": "bone", "mass_ratio": 0.001 },
{ "drop": "bone", "type": "bone", "mass_ratio": 0.15 },
{ "drop": "raw_fur", "type": "skin", "mass_ratio": 0.13 },
{ "drop": "fat", "type": "flesh", "mass_ratio": 0.07 }
]
Expand All @@ -138,8 +138,8 @@
{ "drop": "sweetbread", "type": "flesh", "mass_ratio": 0.002 },
{ "drop": "kidney", "type": "offal", "mass_ratio": 0.002 },
{ "drop": "stomach", "scale_num": [ 1, 1 ], "max": 1, "type": "offal" },
{ "drop": "bone", "type": "bone", "mass_ratio": 0.15 },
{ "drop": "sinew", "type": "bone", "mass_ratio": 0.001 },
{ "drop": "bone", "type": "bone", "mass_ratio": 0.15 },
{ "drop": "raw_fur", "type": "skin", "mass_ratio": 0.08 },
{ "drop": "fat", "type": "flesh", "mass_ratio": 0.075 }
]
Expand All @@ -158,8 +158,8 @@
{ "drop": "sweetbread", "type": "flesh", "mass_ratio": 0.002 },
{ "drop": "kidney", "type": "offal", "mass_ratio": 0.002 },
{ "drop": "stomach_large", "scale_num": [ 1, 1 ], "max": 1, "type": "offal" },
{ "drop": "bone", "type": "bone", "mass_ratio": 0.15 },
{ "drop": "sinew", "type": "bone", "mass_ratio": 0.001 },
{ "drop": "bone", "type": "bone", "mass_ratio": 0.15 },
{ "drop": "raw_fur", "type": "skin", "mass_ratio": 0.04 },
{ "drop": "fat", "type": "flesh", "mass_ratio": 0.07 }
]
Expand All @@ -171,8 +171,8 @@
"entries": [
{ "drop": "mutant_human_flesh", "type": "flesh", "mass_ratio": 0.34 },
{ "drop": "hstomach", "scale_num": [ 1, 1 ], "max": 1, "type": "offal" },
{ "drop": "bone_human", "type": "bone", "mass_ratio": 0.15 },
{ "drop": "sinew", "type": "bone", "mass_ratio": 0.001 },
{ "drop": "bone_human", "type": "bone", "mass_ratio": 0.15 },
{ "drop": "raw_hfur", "type": "skin", "mass_ratio": 0.02 },
{ "drop": "mutant_human_fat", "type": "flesh", "mass_ratio": 0.07 }
]
Expand All @@ -185,8 +185,8 @@
{ "drop": "cyborg_harvest_uncommon", "type": "bionic_group", "faults": [ "fault_bionic_nonsterile" ] },
{ "drop": "mutant_human_flesh", "type": "flesh", "mass_ratio": 0.34 },
{ "drop": "hstomach", "scale_num": [ 1, 1 ], "max": 1, "type": "offal" },
{ "drop": "bone_human", "type": "bone", "mass_ratio": 0.15 },
{ "drop": "sinew", "type": "bone", "mass_ratio": 0.001 },
{ "drop": "bone_human", "type": "bone", "mass_ratio": 0.15 },
{ "drop": "raw_hfur", "type": "skin", "mass_ratio": 0.02 },
{ "drop": "mutant_human_fat", "type": "flesh", "mass_ratio": 0.07 }
]
Expand All @@ -198,8 +198,8 @@
"entries": [
{ "drop": "mutant_human_flesh", "type": "flesh", "mass_ratio": 0.34 },
{ "drop": "hstomach_large", "scale_num": [ 1, 1 ], "max": 1, "type": "offal" },
{ "drop": "bone_human", "type": "bone", "mass_ratio": 0.15 },
{ "drop": "sinew", "type": "bone", "mass_ratio": 0.001 },
{ "drop": "bone_human", "type": "bone", "mass_ratio": 0.15 },
{ "drop": "raw_hfur", "type": "skin", "mass_ratio": 0.02 },
{ "drop": "mutant_human_fat", "type": "flesh", "mass_ratio": 0.07 }
]
Expand All @@ -212,8 +212,8 @@
{ "drop": "cyborg_harvest_uncommon", "type": "bionic_group", "faults": [ "fault_bionic_nonsterile" ] },
{ "drop": "mutant_human_flesh", "type": "flesh", "mass_ratio": 0.34 },
{ "drop": "hstomach_large", "scale_num": [ 1, 1 ], "max": 1, "type": "offal" },
{ "drop": "bone_human", "type": "bone", "mass_ratio": 0.15 },
{ "drop": "sinew", "type": "bone", "mass_ratio": 0.001 },
{ "drop": "bone_human", "type": "bone", "mass_ratio": 0.15 },
{ "drop": "raw_hfur", "type": "skin", "mass_ratio": 0.02 },
{ "drop": "mutant_human_fat", "type": "flesh", "mass_ratio": 0.07 }
]
Expand All @@ -229,8 +229,8 @@
{ "drop": "lung", "type": "flesh", "mass_ratio": 0.0035 },
{ "drop": "liver", "type": "offal", "mass_ratio": 0.01 },
{ "drop": "brain", "type": "flesh", "mass_ratio": 0.005 },
{ "drop": "bone", "type": "bone", "mass_ratio": 0.15 },
{ "drop": "sinew", "type": "bone", "mass_ratio": 0.001 },
{ "drop": "bone", "type": "bone", "mass_ratio": 0.15 },
{ "drop": "raw_leather", "type": "skin", "mass_ratio": 0.13 },
{ "drop": "fat", "type": "flesh", "mass_ratio": 0.07 }
]
Expand All @@ -245,8 +245,8 @@
{ "drop": "mutant_meat_scrap", "type": "flesh", "mass_ratio": 0.05 },
{ "drop": "brain", "type": "flesh", "mass_ratio": 0.005 },
{ "drop": "mutant_offal", "type": "offal", "mass_ratio": 0.01 },
{ "drop": "bone", "type": "bone", "mass_ratio": 0.15 },
{ "drop": "sinew", "type": "bone", "mass_ratio": 0.001 },
{ "drop": "bone", "type": "bone", "mass_ratio": 0.15 },
{ "drop": "raw_fur", "type": "skin", "mass_ratio": 0.02 },
{ "drop": "mutant_fat", "type": "flesh", "mass_ratio": 0.07 }
]
Expand All @@ -265,8 +265,8 @@
{ "drop": "sweetbread", "type": "flesh", "mass_ratio": 0.002 },
{ "drop": "kidney", "type": "offal", "mass_ratio": 0.002 },
{ "drop": "stomach", "scale_num": [ 1, 1 ], "max": 1, "type": "offal" },
{ "drop": "bone", "type": "bone", "mass_ratio": 0.15 },
{ "drop": "sinew", "type": "bone", "mass_ratio": 0.001 },
{ "drop": "bone", "type": "bone", "mass_ratio": 0.15 },
{ "drop": "raw_leather", "type": "skin", "mass_ratio": 0.08 },
{ "drop": "fat", "type": "flesh", "mass_ratio": 0.07 }
]
Expand All @@ -282,8 +282,8 @@
{ "drop": "brain", "type": "flesh", "mass_ratio": 0.005 },
{ "drop": "mutant_offal", "type": "offal", "mass_ratio": 0.01 },
{ "drop": "stomach", "scale_num": [ 1, 1 ], "max": 1, "type": "offal" },
{ "drop": "bone", "type": "bone", "mass_ratio": 0.15 },
{ "drop": "sinew", "type": "bone", "mass_ratio": 0.001 },
{ "drop": "bone", "type": "bone", "mass_ratio": 0.15 },
{ "drop": "raw_leather", "type": "skin", "mass_ratio": 0.02 },
{ "drop": "mutant_fat", "type": "flesh", "mass_ratio": 0.07 }
]
Expand All @@ -302,8 +302,8 @@
{ "drop": "sweetbread", "type": "flesh", "mass_ratio": 0.002 },
{ "drop": "kidney", "type": "offal", "mass_ratio": 0.002 },
{ "drop": "stomach_large", "scale_num": [ 1, 1 ], "max": 1, "type": "offal" },
{ "drop": "bone", "type": "bone", "mass_ratio": 0.15 },
{ "drop": "sinew", "type": "bone", "mass_ratio": 0.001 },
{ "drop": "bone", "type": "bone", "mass_ratio": 0.15 },
{ "drop": "raw_leather", "type": "skin", "mass_ratio": 0.04 },
{ "drop": "fat", "type": "flesh", "mass_ratio": 0.07 }
]
Expand All @@ -319,8 +319,8 @@
{ "drop": "brain", "type": "flesh", "mass_ratio": 0.005 },
{ "drop": "mutant_offal", "type": "offal", "mass_ratio": 0.01 },
{ "drop": "stomach", "scale_num": [ 1, 1 ], "max": 1, "type": "offal" },
{ "drop": "bone", "type": "bone", "mass_ratio": 0.15 },
{ "drop": "sinew", "type": "bone", "mass_ratio": 0.001 },
{ "drop": "bone", "type": "bone", "mass_ratio": 0.15 },
{ "drop": "raw_fur", "type": "skin", "mass_ratio": 0.02 },
{ "drop": "mutant_fat", "type": "flesh", "mass_ratio": 0.07 }
]
Expand All @@ -339,8 +339,8 @@
{ "drop": "sweetbread", "type": "flesh", "mass_ratio": 0.002 },
{ "drop": "kidney", "type": "offal", "mass_ratio": 0.002 },
{ "drop": "stomach_large", "scale_num": [ 1, 1 ], "max": 1, "type": "offal" },
{ "drop": "bone", "type": "bone", "mass_ratio": 0.15 },
{ "drop": "sinew", "type": "bone", "mass_ratio": 0.001 },
{ "drop": "bone", "type": "bone", "mass_ratio": 0.15 },
{ "drop": "raw_leather", "type": "skin", "mass_ratio": 0.04 },
{ "drop": "mutant_fat", "type": "flesh", "mass_ratio": 0.07 }
]
Expand Down Expand Up @@ -376,8 +376,8 @@
{ "drop": "sweetbread", "type": "flesh", "mass_ratio": 0.002 },
{ "drop": "kidney", "type": "offal", "mass_ratio": 0.002 },
{ "drop": "stomach_large", "scale_num": [ 1, 1 ], "max": 1, "type": "offal" },
{ "drop": "bone", "type": "bone", "mass_ratio": 0.15 },
{ "drop": "sinew", "type": "bone", "mass_ratio": 0.001 },
{ "drop": "bone", "type": "bone", "mass_ratio": 0.15 },
{ "drop": "wool_staple", "type": "skin", "mass_ratio": 0.04 },
{ "drop": "fat", "type": "flesh", "mass_ratio": 0.07 }
]
Expand All @@ -392,8 +392,8 @@
{ "drop": "brain", "type": "flesh", "mass_ratio": 0.005 },
{ "drop": "mutant_offal", "type": "offal", "mass_ratio": 0.01 },
{ "drop": "stomach_large", "scale_num": [ 1, 1 ], "max": 1, "type": "offal" },
{ "drop": "bone", "type": "bone", "mass_ratio": 0.2 },
{ "drop": "sinew", "type": "bone", "mass_ratio": 0.001 },
{ "drop": "bone", "type": "bone", "mass_ratio": 0.2 },
{ "drop": "mutant_fat", "type": "flesh", "mass_ratio": 0.07 },
{ "drop": "chitin_piece", "type": "skin", "mass_ratio": 0.1 }
]
Expand All @@ -409,8 +409,8 @@
{ "drop": "brain", "type": "flesh", "mass_ratio": 0.005 },
{ "drop": "mutant_offal", "type": "offal", "mass_ratio": 0.01 },
{ "drop": "stomach_large", "scale_num": [ 1, 1 ], "max": 1, "type": "offal" },
{ "drop": "bone", "type": "bone", "mass_ratio": 0.15 },
{ "drop": "sinew", "type": "bone", "mass_ratio": 0.001 },
{ "drop": "bone", "type": "bone", "mass_ratio": 0.15 },
{ "drop": "raw_fur", "type": "skin", "mass_ratio": 0.02 },
{ "drop": "mutant_fat", "type": "flesh", "mass_ratio": 0.07 }
]
Expand All @@ -429,8 +429,8 @@
{ "drop": "sweetbread", "type": "flesh", "mass_ratio": 0.002 },
{ "drop": "kidney", "type": "offal", "mass_ratio": 0.002 },
{ "drop": "stomach", "scale_num": [ 1, 1 ], "max": 1, "type": "offal" },
{ "drop": "bone", "type": "bone", "mass_ratio": 0.15 },
{ "drop": "sinew", "type": "bone", "mass_ratio": 0.001 },
{ "drop": "bone", "type": "bone", "mass_ratio": 0.15 },
{ "drop": "fat", "type": "flesh", "mass_ratio": 0.07 }
]
},
Expand All @@ -448,8 +448,8 @@
{ "drop": "sweetbread", "type": "flesh", "mass_ratio": 0.002 },
{ "drop": "kidney", "type": "offal", "mass_ratio": 0.002 },
{ "drop": "stomach_large", "scale_num": [ 1, 1 ], "max": 1, "type": "offal" },
{ "drop": "bone", "type": "bone", "mass_ratio": 0.15 },
{ "drop": "sinew", "type": "bone", "mass_ratio": 0.001 },
{ "drop": "bone", "type": "bone", "mass_ratio": 0.15 },
{ "drop": "fat", "type": "flesh", "mass_ratio": 0.07 }
]
},
Expand All @@ -467,8 +467,8 @@
{ "drop": "sweetbread", "type": "flesh", "mass_ratio": 0.002 },
{ "drop": "kidney", "type": "offal", "mass_ratio": 0.002 },
{ "drop": "stomach_large", "scale_num": [ 1, 1 ], "max": 1, "type": "offal" },
{ "drop": "bone", "type": "bone", "mass_ratio": 0.15 },
{ "drop": "sinew", "type": "bone", "mass_ratio": 0.001 },
{ "drop": "bone", "type": "bone", "mass_ratio": 0.15 },
{ "drop": "mutant_fat", "type": "flesh", "mass_ratio": 0.07 }
]
},
Expand Down Expand Up @@ -557,8 +557,8 @@
{ "drop": "mutant_meat", "type": "flesh", "mass_ratio": 0.2 },
{ "drop": "meat_scrap", "type": "flesh", "mass_ratio": 0.1 },
{ "drop": "stomach", "scale_num": [ 0, 1 ], "max": 1, "type": "offal" },
{ "drop": "bone", "type": "bone", "mass_ratio": 0.15 },
{ "drop": "sinew", "type": "bone", "mass_ratio": 0.001 }
{ "drop": "sinew", "type": "bone", "mass_ratio": 0.001 },
{ "drop": "bone", "type": "bone", "mass_ratio": 0.15 }
]
},
{
Expand Down Expand Up @@ -819,8 +819,8 @@
"//": "spooky scary skeletons",
"type": "harvest",
"entries": [
{ "drop": "bone_tainted", "type": "flesh", "mass_ratio": 0.5 },
{ "drop": "sinew", "type": "bone", "mass_ratio": 0.001 }
{ "drop": "sinew", "type": "bone", "mass_ratio": 0.001 },
{ "drop": "bone_tainted", "type": "flesh", "mass_ratio": 0.5 }
]
},
{
Expand All @@ -832,8 +832,8 @@
{ "drop": "human_flesh", "type": "flesh", "mass_ratio": 0.2 },
{ "drop": "hstomach", "scale_num": [ 1, 1 ], "max": 1, "type": "offal" },
{ "drop": "human_fat", "type": "flesh", "mass_ratio": 0.1 },
{ "drop": "bone_human", "type": "bone", "mass_ratio": 0.15 },
{ "drop": "sinew", "type": "bone", "mass_ratio": 0.001 },
{ "drop": "bone_human", "type": "bone", "mass_ratio": 0.15 },
{ "drop": "raw_hleather", "type": "skin", "mass_ratio": 0.03 }
]
},
Expand All @@ -845,8 +845,8 @@
{ "drop": "mutant_human_flesh", "type": "flesh", "mass_ratio": 0.2 },
{ "drop": "hstomach", "scale_num": [ 1, 1 ], "max": 1, "type": "offal" },
{ "drop": "mutant_human_fat", "type": "flesh", "mass_ratio": 0.1 },
{ "drop": "bone_human", "type": "bone", "mass_ratio": 0.15 },
{ "drop": "sinew", "type": "bone", "mass_ratio": 0.001 },
{ "drop": "bone_human", "type": "bone", "mass_ratio": 0.15 },
{ "drop": "raw_hleather", "type": "skin", "mass_ratio": 0.03 }
]
},
Expand All @@ -859,8 +859,8 @@
{ "drop": "meat", "type": "flesh", "mass_ratio": 0.4 },
{ "drop": "hstomach", "scale_num": [ 1, 1 ], "max": 1, "type": "offal" },
{ "drop": "human_fat", "type": "flesh", "mass_ratio": 0.1 },
{ "drop": "bone_human", "type": "bone", "mass_ratio": 0.15 },
{ "drop": "sinew", "type": "bone", "mass_ratio": 0.001 },
{ "drop": "bone_human", "type": "bone", "mass_ratio": 0.15 },
{ "drop": "raw_leather", "type": "skin", "mass_ratio": 0.03 },
{ "drop": "raw_fur", "type": "skin", "mass_ratio": 0.001 }
]
Expand Down Expand Up @@ -917,8 +917,8 @@
{ "drop": "human_flesh", "type": "flesh", "mass_ratio": 0.2 },
{ "drop": "hstomach", "scale_num": [ 1, 1 ], "max": 1, "type": "offal" },
{ "drop": "human_fat", "type": "flesh", "mass_ratio": 0.1 },
{ "drop": "bone_human", "type": "bone", "mass_ratio": 0.15 },
{ "drop": "sinew", "type": "bone", "mass_ratio": 0.001 },
{ "drop": "bone_human", "type": "bone", "mass_ratio": 0.15 },
{ "drop": "raw_hleather", "type": "skin", "mass_ratio": 0.03 }
]
},
Expand Down Expand Up @@ -955,8 +955,8 @@
{ "drop": "human_flesh", "type": "flesh", "mass_ratio": 0.2 },
{ "drop": "hstomach", "scale_num": [ 1, 1 ], "max": 1, "type": "offal" },
{ "drop": "human_fat", "type": "flesh", "mass_ratio": 0.1 },
{ "drop": "bone_human", "type": "bone", "mass_ratio": 0.15 },
{ "drop": "sinew", "type": "bone", "mass_ratio": 0.001 },
{ "drop": "bone_human", "type": "bone", "mass_ratio": 0.15 },
{ "drop": "raw_hleather", "type": "skin", "mass_ratio": 0.03 }
]
},
Expand All @@ -981,8 +981,8 @@
{ "drop": "human_flesh", "type": "flesh", "mass_ratio": 0.2 },
{ "drop": "hstomach", "scale_num": [ 1, 1 ], "max": 1, "type": "offal" },
{ "drop": "human_fat", "type": "flesh", "mass_ratio": 0.1 },
{ "drop": "bone_human", "type": "bone", "mass_ratio": 0.15 },
{ "drop": "sinew", "type": "bone", "mass_ratio": 0.001 },
{ "drop": "bone_human", "type": "bone", "mass_ratio": 0.15 },
{ "drop": "raw_hleather", "type": "skin", "mass_ratio": 0.03 }
]
},
Expand Down Expand Up @@ -1031,8 +1031,8 @@
{ "drop": "human_flesh", "type": "flesh", "mass_ratio": 0.2 },
{ "drop": "hstomach", "scale_num": [ 1, 1 ], "max": 1, "type": "offal" },
{ "drop": "human_fat", "type": "flesh", "mass_ratio": 0.1 },
{ "drop": "bone_human", "type": "bone", "mass_ratio": 0.15 },
{ "drop": "sinew", "type": "bone", "mass_ratio": 0.001 },
{ "drop": "bone_human", "type": "bone", "mass_ratio": 0.15 },
{ "drop": "raw_hleather", "type": "skin", "mass_ratio": 0.03 }
]
},
Expand Down
15 changes: 12 additions & 3 deletions src/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9919,11 +9919,15 @@ detached_ptr<item> item::process_internal( detached_ptr<item> &&self, player *ca
}
// All foods that go bad have temperature
if( ( self->is_food() || self->is_corpse() ) ) {
bool comestible = self->is_comestible();
item &obj = *self;
self = process_rot( std::move( self ), seals, pos, carrier, flag, weather_generator );
if( comestible && !self ) {
here.rotten_item_spawn( obj, pos );
// If the item has rotted away, then self becomes a null pointer.
if( !self ) {
if( obj.is_comestible() ) {
here.rotten_item_spawn( obj, pos );
} else if( obj.is_corpse() ) {
here.handle_decayed_corpse( obj, pos );
}
}
}
return std::move( self );
Expand Down Expand Up @@ -10127,6 +10131,11 @@ std::string item::type_name( unsigned int quantity ) const
return ret_name;
}

const mtype *item::get_corpse_mon() const
{
return corpse;
}

std::string item::get_corpse_name()
{
if( corpse_name.empty() ) {
Expand Down
1 change: 1 addition & 0 deletions src/item.h
Original file line number Diff line number Diff line change
Expand Up @@ -2325,6 +2325,7 @@ class item : public location_visitable<item>, public game_object<item>
void add_component( detached_ptr<item> &&comp );
const location_vector<item> &get_components() const;
location_vector<item> &get_components();
const mtype *get_corpse_mon() const;
private:
location_vector<item> components;
const itype *curammo = nullptr;
Expand Down
Loading

0 comments on commit 1d53969

Please sign in to comment.