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

feat(content,port): corpses decay into items, use existing harvest entries to actually implement feature, fix off-map decay behavior #4751

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading