void npc_class::check_consistency() { for( const auto &legacy : legacy_ids ) { if( !npc_class_factory.is_valid( legacy ) ) { debugmsg( "Missing legacy npc class %s", legacy.c_str() ); } } for( auto &cl : npc_class_factory.get_all() ) { if( !item_group::group_is_defined( cl.shopkeeper_item_group ) ) { debugmsg( "Missing shopkeeper item group %s", cl.shopkeeper_item_group.c_str() ); } if( !cl.worn_override.empty() && !item_group::group_is_defined( cl.worn_override ) ) { debugmsg( "Missing worn override item group %s", cl.worn_override.c_str() ); } if( !cl.carry_override.empty() && !item_group::group_is_defined( cl.carry_override ) ) { debugmsg( "Missing carry override item group %s", cl.carry_override.c_str() ); } if( !cl.weapon_override.empty() && !item_group::group_is_defined( cl.weapon_override ) ) { debugmsg( "Missing weapon override item group %s", cl.weapon_override.c_str() ); } for( const auto &pr : cl.skills ) { if( !pr.first.is_valid() ) { debugmsg( "Invalid skill %s", pr.first.c_str() ); } } for( const auto &pr : cl.traits ) { if( !pr.first.is_valid() ) { debugmsg( "Invalid trait %s", pr.first.c_str() ); } } } }
const npc_class_id &npc_class::random_common() { std::list<const npc_class_id *> common_classes; for( const auto &pr : npc_class_factory.get_all() ) { if( pr.common ) { common_classes.push_back( &pr.id ); } } if( common_classes.empty() || one_in( common_classes.size() ) ) { return NC_NONE; } return *random_entry( common_classes ); }
void npc_class::finalize_all() { for( auto &cl_const : npc_class_factory.get_all() ) { auto &cl = const_cast<npc_class &>( cl_const ); apply_all_to_unassigned( cl.skills ); apply_all_to_unassigned( cl.bonus_skills ); for( const auto &pr : cl.bonus_skills ) { if( cl.skills.count( pr.first ) == 0 ) { cl.skills[ pr.first ] = pr.second; } else { cl.skills[ pr.first ] = cl.skills[ pr.first ] + pr.second; } } } }
const std::vector<mission_type> &mission_type::get_all() { return mission_type_factory.get_all(); }
void mission_type::reset() { mission_type_factory.reset(); }
void mission_type::load_mission_type( JsonObject &jo, const std::string &src ) { mission_type_factory.load( jo, src ); }
bool string_id<mission_type>::is_valid() const { return mission_type_factory.is_valid( *this ); }
const mission_type &string_id<mission_type>::obj() const { return mission_type_factory.obj( *this ); }
void npc_class::reset_npc_classes() { npc_class_factory.reset(); }
void npc_class::load_npc_class( JsonObject &jo, const std::string &src ) { npc_class_factory.load( jo, src ); }
bool string_id<npc_class>::is_valid() const { return npc_class_factory.is_valid( *this ); }
const npc_class &string_id<npc_class>::obj() const { return npc_class_factory.obj( *this ); }
const std::vector<npc_class> &npc_class::get_all() { return npc_class_factory.get_all(); }