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

Construct a grave and bury your fallen companions or pets. #30281

Merged
merged 9 commits into from
May 12, 2019
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
35 changes: 24 additions & 11 deletions data/json/construction.json
Original file line number Diff line number Diff line change
Expand Up @@ -1219,17 +1219,6 @@
"pre_special": "check_empty",
"post_terrain": "f_crate_o"
},
{
"type": "construction",
"description": "Seal Coffin",
"category": "FURN",
"required_skills": [ [ "mechanics", 0 ] ],
"time": 10,
"components": [ [ [ "nail", 6 ] ] ],
"qualities": [ [ { "id": "HAMMER", "level": 1 } ] ],
"pre_terrain": "f_coffin_o",
"post_terrain": "f_coffin_c"
},
{
"type": "construction",
"description": "Build Coffin",
Expand All @@ -1245,6 +1234,30 @@
"pre_special": "check_empty",
"post_terrain": "f_coffin_o"
},
{
"type": "construction",
"description": "Seal Coffin",
"category": "FURN",
"required_skills": [ [ "mechanics", 0 ] ],
"time": 10,
"components": [ [ [ "nail", 6 ] ] ],
"qualities": [ [ { "id": "HAMMER", "level": 1 } ] ],
"pre_terrain": "f_coffin_o",
"post_terrain": "f_coffin_c"
},
{
"type": "construction",
"description": "Dig Grave and Bury Sealed Coffin",
"category": "DIG",
"required_skills": [ [ "fabrication", 0 ] ],
"time": 60,
"qualities": [ [ { "id": "HAMMER", "level": 1 } ], [ { "id": "DIG", "level": 2 } ] ],
"components": [ [ [ "rock", 20 ], [ "2x4", 2 ] ] ],
"pre_flags": "DIGGABLE",
"pre_terrain": "f_coffin_c",
"post_terrain": "t_grave_new",
"post_special": "done_grave"
},
{
"type": "construction",
"description": "Build Bulletin Board",
Expand Down
5 changes: 5 additions & 0 deletions data/json/morale_types.json
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,11 @@
"type": "morale_type",
"text": "Dug out a grave"
},
{
"id": "morale_funeral",
"type": "morale_type",
"text": "Conducted a funeral"
},
{
"id": "morale_tree_communion",
"type": "morale_type",
Expand Down
14 changes: 13 additions & 1 deletion data/json/terrain.json
Original file line number Diff line number Diff line change
Expand Up @@ -10296,6 +10296,18 @@
"color": "green",
"move_cost": 3,
"flags": [ "TRANSPARENT", "DIGGABLE", "MOUNTABLE", "NOCOLLIDE" ],
"bash": { "sound": "thump", "ter_set": "t_null", "str_min": 50, "str_max": 100, "str_min_supported": 100 }
"bash": { "sound": "thump", "ter_set": "t_dirt", "str_min": 50, "str_max": 100, "str_min_supported": 100 }
},
{
"type": "terrain",
"id": "t_grave_new",
"name": "grave",
"looks_like": "t_dirtmound",
"description": "A fresh grave, covered with stones, either to keep something from digging it out or to keep one inside from digging out of it. Two planks mark this place of someone's eternal rest.",
"symbol": "#",
"color": "brown",
"move_cost": 3,
"flags": [ "TRANSPARENT", "DIGGABLE", "MOUNTABLE", "NOCOLLIDE", "CONTAINER", "SEALED" ],
"bash": { "sound": "thump", "ter_set": "t_dirt", "str_min": 50, "str_max": 100, "str_min_supported": 100 }
}
]
51 changes: 51 additions & 0 deletions src/construction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
#include "int_id.h"
#include "item.h"
#include "player_activity.h"
#include "pldata.h"
#include "morale_types.h"

class inventory;

Expand All @@ -53,6 +55,7 @@ static const skill_id skill_electronics( "electronics" );
static const trait_id trait_DEBUG_HS( "DEBUG_HS" );
static const trait_id trait_PAINRESIST_TROGLO( "PAINRESIST_TROGLO" );
static const trait_id trait_STOCKY_TROGLO( "STOCKY_TROGLO" );
static const trait_id trait_SPIRITUAL( "SPIRITUAL" );

const trap_str_id tr_firewood_source( "tr_firewood_source" );
const trap_str_id tr_practice_target( "tr_practice_target" );
Expand All @@ -75,6 +78,7 @@ bool check_no_trap( const tripoint & );
// Special actions to be run post-terrain-mod
void done_nothing( const tripoint & ) {}
void done_trunk_plank( const tripoint & );
void done_grave( const tripoint & );
void done_vehicle( const tripoint & );
void done_deconstruct( const tripoint & );
void done_digormine_stair( const tripoint &, bool );
Expand Down Expand Up @@ -946,6 +950,52 @@ void construct::done_trunk_plank( const tripoint &p )
}
}

void construct::done_grave( const tripoint &p )
{
map_stack its = g->m.i_at( p );
for( item it : its ) {
if( it.is_corpse() ) {
if( it.get_corpse_name().empty() ) {
if( it.get_mtype()->has_flag( MF_HUMAN ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that if it's not human corpse, then do nothing? We were supposed to bury pets too, but in this case there's no morale changes nor sad words.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually if your pet animal was named, it falls under further check, that does not check if corpse was a human. I double checked if pet names carry on to their corpses and if it is recognized by the bury code. It is. Will fix the descriptions of morale gain to more general though.

image

So mourn all you want, but name your pet first.
I wish I could say that no in-game dog was harmed in making this feature but... c'est la vie.

if( g->u.has_trait( trait_SPIRITUAL ) ) {
g->u.add_morale( MORALE_FUNERAL, 50, 75, 1_days, 1_hours );
add_msg( m_good,
_( "You feel relieved after providing last rites for this human being, whose name is lost in the Cataclysm." ) );
} else {
add_msg( m_neutral, _( "You bury remains of a human, whose name is lost in the Cataclysm." ) );
}
g->u.add_memorial_log( pgettext( "memorial_male",
string_format( "You buried unknown victim of the Cataclysm.", it.type_name() ).c_str() ),
pgettext( "memorial_female", string_format( "You buried unknown victim of The Cataclysm.",
it.type_name() ).c_str() ) );
}
} else {
if( g->u.has_trait( trait_SPIRITUAL ) ) {
g->u.add_morale( MORALE_FUNERAL, 50, 75, 1_days, 1_hours );
add_msg( m_good,
_( "You feel sadness, but also relief after providing last rites for %s, whose name you will keep in your memory." ),
it.get_corpse_name() );
} else {
add_msg( m_neutral,
_( "You bury remains of %s, who joined uncounted masses perished in the Cataclysm." ),
it.get_corpse_name() );
}
g->u.add_memorial_log( pgettext( "memorial_male", string_format( "You buried %s.",
it.get_corpse_name() ).c_str() ),
pgettext( "memorial_female", string_format( "You buried %s.", it.get_corpse_name() ).c_str() ) );
}
}
}
if( g->u.has_quality( quality_id( "CUT" ) ) ) {
iuse::handle_ground_graffiti( g->u, nullptr, _( "Inscribe something on the grave?" ), p );
} else {
add_msg( m_neutral,
_( "Unfortunately you don't have anything sharp to place an inscription on the grave." ) );
}

g->m.destroy_furn( p, true );
}

vpart_id vpart_from_item( const std::string &item_id )
{
for( const auto &e : vpart_info::all() ) {
Expand Down Expand Up @@ -1275,6 +1325,7 @@ void load_construction( JsonObject &jo )
static const std::map<std::string, std::function<void( const tripoint & )>> post_special_map = {{
{ "", construct::done_nothing },
{ "done_trunk_plank", construct::done_trunk_plank },
{ "done_grave", construct::done_grave },
{ "done_vehicle", construct::done_vehicle },
{ "done_deconstruct", construct::done_deconstruct },
{ "done_dig_stair", construct::done_dig_stair },
Expand Down
4 changes: 3 additions & 1 deletion src/editmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,9 @@ void editmap::update_view( bool update_info )
}

if( g->m.has_graffiti_at( target ) ) {
mvwprintw( w_info, off, 1, _( "Graffiti: %s" ), g->m.graffiti_at( target ) );
mvwprintw( w_info, off, 1,
g->m.ter( target ) == t_grave_new ? _( "Graffiti: %s" ) : _( "Incription: %s" ),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This causes "Inscription" label for all graffiti in edit map view if terrain is not t_grave_new (i.e. walls, doors, etc).

g->m.graffiti_at( target ) );
}

wrefresh( w_info );
Expand Down
3 changes: 2 additions & 1 deletion src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6161,7 +6161,8 @@ void game::print_graffiti_info( const tripoint &lp, const catacurses::window &w_

const int max_width = getmaxx( w_look ) - column - 2;
if( m.has_graffiti_at( lp ) ) {
fold_and_print( w_look, ++line, column, max_width, c_light_gray, _( "Graffiti: %s" ),
fold_and_print( w_look, ++line, column, max_width, c_light_gray,
m.ter( lp ) == t_grave_new ? _( "Graffiti: %s" ) : _( "Incription: %s" ),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This causes "Inscription" label for all graffiti in look around view if terrain is not t_grave_new (i.e. walls, doors, etc).

m.graffiti_at( lp ) );
}
}
Expand Down
8 changes: 8 additions & 0 deletions src/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8051,6 +8051,14 @@ std::string item::type_name( unsigned int quantity ) const
}
}

std::string item::get_corpse_name()
{
if( corpse_name.empty() ) {
return std::string();
}
return corpse_name;
}

std::string item::nname( const itype_id &id, unsigned int quantity )
{
const auto t = find_type( id );
Expand Down
5 changes: 4 additions & 1 deletion src/item.h
Original file line number Diff line number Diff line change
Expand Up @@ -1777,7 +1777,10 @@ class item : public visitable<item>
* @param qty units required, if unspecified use item default
*/
bool units_sufficient( const Character &ch, int qty = -1 ) const;

/**
* Returns name of deceased being if it had any or empty string if not
**/
std::string get_corpse_name();
/**
* Returns the translated item name for the item with given id.
* The name is in the proper plural form as specified by the
Expand Down
33 changes: 24 additions & 9 deletions src/iuse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2669,8 +2669,11 @@ int iuse::dig( player *p, item *it, bool t, const tripoint & )

const tripoint dig_point = p->pos();

const bool can_dig_here = g->m.has_flag( "DIGGABLE", dig_point ) && !g->m.has_furn( dig_point ) &&
g->m.tr_at( dig_point ).is_null() && g->m.i_at( dig_point ).empty() && !g->m.veh_at( dig_point );
const bool can_dig_here = g->m.has_flag( "DIGGABLE", dig_point ) &&
!g->m.has_furn( dig_point ) &&
g->m.tr_at( dig_point ).is_null() &&
( g->m.ter( dig_point ) == t_grave_new || g->m.i_at( dig_point ).empty() ) &&
!g->m.veh_at( dig_point );

if( !can_dig_here ) {
p->add_msg_if_player(
Expand Down Expand Up @@ -5009,10 +5012,10 @@ int iuse::artifact( player *p, item *it, bool, const tripoint & )

int iuse::spray_can( player *p, item *it, bool, const tripoint & )
{
return handle_ground_graffiti( *p, it, _( "Spray what?" ) );
return handle_ground_graffiti( *p, it, _( "Spray what?" ), p->pos() );
}

int iuse::handle_ground_graffiti( player &p, item *it, const std::string &prefix )
int iuse::handle_ground_graffiti( player &p, item *it, const std::string &prefix, tripoint pt )
{
std::string message = string_input_popup()
.title( prefix + " " + _( "(To delete, input one '.')" ) )
Expand All @@ -5022,26 +5025,38 @@ int iuse::handle_ground_graffiti( player &p, item *it, const std::string &prefix
if( message.empty() ) {
return 0;
} else {
const auto where = p.pos();
const auto where = pt != p.pos() ? pt : p.pos();
bool grave = g->m.ter( where ) == t_grave_new;
int move_cost;
if( message == "." ) {
if( g->m.has_graffiti_at( where ) ) {
move_cost = 3 * g->m.graffiti_at( where ).length();
g->m.delete_graffiti( where );
add_msg( _( "You manage to get rid of the message on the ground." ) );
if( grave ) {
add_msg( _( "You blur the inscription on the grave." ) );
} else {
add_msg( _( "You manage to get rid of the message on the ground." ) );
}
} else {
add_msg( _( "There isn't anything to erase here." ) );
return 0;
}
} else {
g->m.set_graffiti( where, message );
add_msg( _( "You write a message on the ground." ) );
if( grave ) {
add_msg( _( "You carve an inscription on the grave." ) );
} else {
add_msg( _( "You write a message on the ground." ) );
}
move_cost = 2 * message.length();
}
p.moves -= move_cost;
}

return it->type->charges_to_use();
if( it != nullptr ) {
return it->type->charges_to_use();
} else {
return 0;
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/iuse.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ class iuse
static void play_music( player &p, const tripoint &source, int volume, int max_morale );

// Helper for handling pesky wannabe-artists
static int handle_ground_graffiti( player &p, item *it, const std::string &prefix );
static int handle_ground_graffiti( player &p, item *it, const std::string &prefix, tripoint pt );

};

Expand Down
2 changes: 1 addition & 1 deletion src/iuse_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1565,7 +1565,7 @@ long inscribe_actor::use( player &p, item &it, bool t, const tripoint & ) const
}

if( choice == 0 ) {
return iuse::handle_ground_graffiti( p, &it, string_format( _( "%s what?" ), _( verb ) ) );
return iuse::handle_ground_graffiti( p, &it, string_format( _( "%s what?" ), _( verb ) ), p.pos() );
}

int pos = g->inv_for_all( _( "Inscribe which item?" ) );
Expand Down
3 changes: 2 additions & 1 deletion src/mapdata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ bool map_data_common_t::connects( int &ret ) const
ter_id t_null,
t_hole, // Real nothingness; makes you fall a z-level
// Ground
t_dirt, t_sand, t_clay, t_dirtmound, t_pit_shallow, t_pit, t_grave,
t_dirt, t_sand, t_clay, t_dirtmound, t_pit_shallow, t_pit, t_grave, t_grave_new,
t_pit_corpsed, t_pit_covered, t_pit_spiked, t_pit_spiked_covered, t_pit_glass, t_pit_glass_covered,
t_rock_floor,
t_grass, t_grass_long, t_grass_tall, t_grass_golf, t_grass_dead, t_grass_white,
Expand Down Expand Up @@ -583,6 +583,7 @@ void set_ter_ids()
t_clay = ter_id( "t_clay" );
t_dirtmound = ter_id( "t_dirtmound" );
t_grave = ter_id( "t_grave" );
t_grave_new = ter_id( "t_grave_new" );
t_pit_shallow = ter_id( "t_pit_shallow" );
t_pit = ter_id( "t_pit" );
t_pit_corpsed = ter_id( "t_pit_corpsed" );
Expand Down
2 changes: 1 addition & 1 deletion src/mapdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ t_basalt
extern ter_id t_null,
t_hole, // Real nothingness; makes you fall a z-level
// Ground
t_dirt, t_sand, t_clay, t_dirtmound, t_pit_shallow, t_pit, t_grave,
t_dirt, t_sand, t_clay, t_dirtmound, t_pit_shallow, t_pit, t_grave, t_grave_new,
t_pit_corpsed, t_pit_covered, t_pit_spiked, t_pit_spiked_covered, t_pit_glass, t_pit_glass_covered,
t_rock_floor,
t_grass, t_grass_long, t_grass_tall, t_grass_golf, t_grass_dead, t_grass_white,
Expand Down
2 changes: 2 additions & 0 deletions src/morale_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ const morale_type &morale_type_data::convert_legacy( int lmt )

morale_type( "morale_butcher" ),
morale_type( "morale_gravedigger" ),
morale_type( "morale_funeral" ),

morale_type( "morale_accomplishment" ),
morale_type( "morale_failure" ),
Expand Down Expand Up @@ -183,6 +184,7 @@ const morale_type MORALE_PERM_FILTHY( "morale_perm_filthy" );
const morale_type MORALE_PERM_DEBUG( "morale_perm_debug" );
const morale_type MORALE_BUTCHER( "morale_butcher" );
const morale_type MORALE_GRAVEDIGGER( "morale_gravedigger" );
const morale_type MORALE_FUNERAL( "morale_funeral" );
const morale_type MORALE_TREE_COMMUNION( "morale_tree_communion" );
const morale_type MORALE_ACCOMPLISHMENT( "morale_accomplishment" );
const morale_type MORALE_FAILURE( "morale_failure" );
Expand Down
1 change: 1 addition & 0 deletions src/morale_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ extern const morale_type MORALE_PERM_FILTHY;
extern const morale_type MORALE_PERM_DEBUG;
extern const morale_type MORALE_BUTCHER;
extern const morale_type MORALE_GRAVEDIGGER;
extern const morale_type MORALE_FUNERAL;
extern const morale_type MORALE_TREE_COMMUNION;
extern const morale_type MORALE_ACCOMPLISHMENT;
extern const morale_type MORALE_FAILURE;
Expand Down