Skip to content

Commit cedfc5b

Browse files
authored
Merge pull request #82617 from ehughsbaird/more-extend-delete
More monster type to optional/mandatory
2 parents 3e575f8 + 878ddea commit cedfc5b

File tree

13 files changed

+211
-254
lines changed

13 files changed

+211
-254
lines changed

data/json/monsters/insect_spider.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2370,7 +2370,7 @@
23702370
"weakpoints": [ { "id": "abdomen", "name": "the abdomen", "coverage": 30 } ],
23712371
"vision_night": 8,
23722372
"zombify_into": "mon_meat_cocoon_tiny",
2373-
"delete": { "weakpoints": [ { "id": "stinger" } ], "flags": [ "FLIES" ], "special_attacks": [ "DERMATIK" ] }
2373+
"delete": { "weakpoints": [ { "id": "stinger" } ], "flags": [ "FLIES" ], "special_attacks": [ "dermatik_impale" ] }
23742374
},
23752375
{
23762376
"id": "mon_dermatik_incubator_deer",

data/json/monsters/zed_nomex.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"families": [ "prof_wp_syn_armored", "prof_wp_nat_armored" ],
3333
"flags": [ "ACIDPROOF", "FIREPROOF" ]
3434
},
35-
"delete": { "special_attacks": [ "bite_humanoid" ] }
35+
"delete": { "special_attacks": [ "bite" ] }
3636
},
3737
{
3838
"id": "mon_zombie_fireproof_grappler",

data/mods/No_Hope/monsters.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,7 @@
503503
"weight": "386 kg",
504504
"hp": 120,
505505
"speed": 200,
506+
"weakpoint_sets": [ "wps_animal_quadruped" ],
506507
"material": [ "flesh" ],
507508
"symbol": "M",
508509
"color": "brown",

data/mods/Xedra_Evolved/monsters/zombies.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
"corpse_type": "NO_CORPSE"
9797
},
9898
"emit_fields": [ { "emit_id": "xedra_monochrome_boomer_frozen_time", "delay": "1 s" } ],
99-
"delete": { "special_attacks": [ "BOOMER" ] },
99+
"delete": { "special_attacks": [ "boomer_bile" ] },
100100
"extend": { "flags": [ "STABILIZED_TIMELINE" ] },
101101
"upgrades": false
102102
}

src/generic_factory.h

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,6 +1389,7 @@ template<typename Derived>
13891389
class generic_typed_reader
13901390
{
13911391
static constexpr bool read_objects = false;
1392+
static constexpr bool check_extend_delete_copy_from = true;
13921393
public:
13931394
template<typename C, typename Fn>
13941395
// I tried using a member function pointer and couldn't work it out
@@ -1619,8 +1620,11 @@ class generic_typed_reader
16191620
const Derived &derived = static_cast<const Derived &>( *this );
16201621
// or no handler for the container
16211622
if( !was_loaded ) {
1622-
warn_disabled_feature( jo, "extend", member_name, "no copy-from" );
1623-
warn_disabled_feature( jo, "delete", member_name, "no copy-from" );
1623+
// this is gross, but some JSON wants to delete from things loaded by a different member on the same entity
1624+
if( Derived::check_extend_delete_copy_from ) {
1625+
warn_disabled_feature( jo, "extend", member_name, "no copy-from" );
1626+
warn_disabled_feature( jo, "delete", member_name, "no copy-from" );
1627+
}
16241628
warn_disabled_feature( jo, "relative", member_name, "no copy-from" );
16251629
warn_disabled_feature( jo, "proportional", member_name, "no copy-from" );
16261630
}
@@ -2083,6 +2087,20 @@ class time_bound_reader : public bound_reader<T>
20832087
};
20842088
};
20852089

2090+
struct weakpoints;
2091+
2092+
struct weakpoints_reader : generic_typed_reader<weakpoints_reader> {
2093+
static constexpr bool check_extend_delete_copy_from = false;
2094+
2095+
std::set<std::string> &deleted;
2096+
2097+
explicit weakpoints_reader( std::set<std::string> &del ) : deleted( del ) {}
2098+
2099+
weakpoints get_next( const JsonValue &jv ) const;
2100+
bool do_extend( const JsonObject &jo, std::string_view name, weakpoints &member ) const;
2101+
bool do_delete( const JsonObject &jo, std::string_view name, weakpoints &member ) const;
2102+
};
2103+
20862104
/**
20872105
* Only for external use in legacy code where migrating to `class translation`
20882106
* is impractical. For new code load with `class translation` instead.

src/mattack_actors.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,17 @@ static const skill_id skill_throw( "throw" );
9393
static const trait_id trait_TOXICFLESH( "TOXICFLESH" );
9494
static const trait_id trait_VAMPIRE( "VAMPIRE" );
9595

96+
bool invalid_mattack_actor::call( monster &m ) const
97+
{
98+
debugmsg( "%s has invalid mattack actor definition!", m.type->id.str() );
99+
return false;
100+
}
101+
102+
std::unique_ptr<mattack_actor> invalid_mattack_actor::clone() const
103+
{
104+
return std::make_unique<invalid_mattack_actor>( *this );
105+
}
106+
96107
void leap_actor::load_internal( const JsonObject &obj, const std::string & )
97108
{
98109
// Mandatory:

src/mattack_actors.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ class Creature;
2222
class JsonObject;
2323
class monster;
2424

25+
class invalid_mattack_actor : public mattack_actor
26+
{
27+
bool call( monster & ) const override;
28+
std::unique_ptr<mattack_actor> clone() const override;
29+
void load_internal( const JsonObject &, const std::string & ) override {}
30+
};
31+
2532
class leap_actor : public mattack_actor
2633
{
2734
public:

src/mattack_common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class mattack_actor
4444
struct mtype_special_attack {
4545
protected:
4646
// TODO: Remove friend
47-
friend struct mtype;
47+
friend struct special_attacks_reader;
4848
cata::clone_ptr<mattack_actor> actor;
4949

5050
public:

0 commit comments

Comments
 (0)