Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 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
16 changes: 16 additions & 0 deletions src/monstergenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,19 @@
}
}

void monster_invulnerability::deserialize( const JsonObject &jo )
{
optional( jo, false, "damage_type", damage_type, damage_type_id( "all" ) );

Check failure on line 748 in src/monstergenerator.cpp

View workflow job for this annotation

GitHub Actions / run-clang-tidy (directly-changed)

Temporary string_id instances with fixed content should be promoted to a static instance at global scope. [cata-static-string_id-constants,-warnings-as-errors]
optional( jo, false, "material", material, material_id::NULL_ID() );
optional( jo, false, "amount", amount, 0 );
}

void monster_vulnerability::deserialize( const JsonObject &jo )
{
optional( jo, false, "material", material, material_id::NULL_ID() );
optional( jo, false, "flag", flag, flag_id::NULL_ID() );
}

void mtype::load( const JsonObject &jo, const std::string &src )
{
bool strict = src == "dda";
Expand Down Expand Up @@ -784,6 +797,9 @@
if( was_loaded && jo.has_member( "copy-from" ) && looks_like.empty() ) {
looks_like = jo.get_string( "copy-from" );
}
optional( jo, was_loaded, "invulnerability", invulnerabilities );
optional( jo, was_loaded, "vulnerability", vulnerability );

jo.read( "looks_like", looks_like );

assign( jo, "bodytype", bodytype );
Expand Down
18 changes: 18 additions & 0 deletions src/mtype.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,22 @@ struct mon_effect_data {
void load( const JsonObject &jo );
};

struct monster_invulnerability {
damage_type_id damage_type; // e.g. "bash", "cut", "all"
material_id material; // optional; can be empty
int amount = 0; // e.g. percent or flat reduction

void deserialize( const JsonObject &jo );
};

struct monster_vulnerability {
material_id material; // optional; items of this material ignore invulnerability
flag_id flag; // optional; items of with this flag ignore invulnerability

void deserialize( const JsonObject &jo );
};


/** Pet food data */
struct pet_food_data {
std::set<std::string> food;
Expand Down Expand Up @@ -346,6 +362,8 @@ struct mtype {
mtype_id burn_into;

std::vector<revive_type> revive_types;
std::vector<monster_invulnerability> invulnerabilities;
std::optional<monster_vulnerability> vulnerability;

mtype_id zombify_into; // mtype_id this monster zombifies into
mtype_id fungalize_into; // mtype_id this monster fungalize into
Expand Down
Loading