void activity_handlers::train_finish( player_activity *act, player *p ) { const Skill *skill = Skill::skill(act->name); if( skill == NULL ) { auto &mastyle = matype_id( act->name ).obj(); // Trained martial arts, add_msg(m_good, _("You learn %s."), mastyle.name.c_str()); //~ %s is martial art p->add_memorial_log(pgettext("memorial_male", "Learned %s."), pgettext("memorial_female", "Learned %s."), mastyle.name.c_str()); p->add_martialart( mastyle.id ); } else { int new_skill_level = p->skillLevel(skill) + 1; p->skillLevel(skill).level(new_skill_level); add_msg(m_good, _("You finish training %s to level %d."), skill->name().c_str(), new_skill_level); if( new_skill_level % 4 == 0 ) { //~ %d is skill level %s is skill name p->add_memorial_log(pgettext("memorial_male", "Reached skill level %1$d in %2$s."), pgettext("memorial_female", "Reached skill level %1$d in %2$s."), new_skill_level, skill->name().c_str()); } } act->type = ACT_NULL; }
void activity_handlers::train_finish( player_activity *act, player *p ) { const skill_id sk( act->name ); if( sk.is_valid() ) { const Skill *skill = &sk.obj(); int new_skill_level = p->skillLevel(skill) + 1; p->skillLevel(skill).level(new_skill_level); add_msg(m_good, _("You finish training %s to level %d."), skill->name().c_str(), new_skill_level); if( new_skill_level % 4 == 0 ) { //~ %d is skill level %s is skill name p->add_memorial_log(pgettext("memorial_male", "Reached skill level %1$d in %2$s."), pgettext("memorial_female", "Reached skill level %1$d in %2$s."), new_skill_level, skill->name().c_str()); } act->type = ACT_NULL; return; } const auto &ma_id = matype_id( act->name ); if( ma_id.is_valid() ) { const auto &mastyle = ma_id.obj(); // Trained martial arts, add_msg(m_good, _("You learn %s."), mastyle.name.c_str()); //~ %s is martial art p->add_memorial_log(pgettext("memorial_male", "Learned %s."), pgettext("memorial_female", "Learned %s."), mastyle.name.c_str()); p->add_martialart( mastyle.id ); } else { debugmsg( "train_finish without a valid skill or style name" ); } act->type = ACT_NULL; return; }
void mutation_branch::load( JsonObject &jsobj ) { const std::string id = jsobj.get_string( "id" ); mutation_branch &new_mut = mutation_data[id]; JsonArray jsarr; new_mut.name = _(jsobj.get_string("name").c_str()); new_mut.description = _(jsobj.get_string("description").c_str()); new_mut.points = jsobj.get_int("points"); new_mut.visibility = jsobj.get_int("visibility", 0); new_mut.ugliness = jsobj.get_int("ugliness", 0); new_mut.startingtrait = jsobj.get_bool("starting_trait", false); new_mut.mixed_effect = jsobj.get_bool("mixed_effect", false); new_mut.activated = jsobj.get_bool("active", false); new_mut.starts_active = jsobj.get_bool("starts_active", false); new_mut.destroys_gear = jsobj.get_bool("destroys_gear", false); new_mut.allow_soft_gear = jsobj.get_bool("allow_soft_gear", false); new_mut.cost = jsobj.get_int("cost", 0); new_mut.cooldown = jsobj.get_int("time",0); new_mut.hunger = jsobj.get_bool("hunger",false); new_mut.thirst = jsobj.get_bool("thirst",false); new_mut.fatigue = jsobj.get_bool("fatigue",false); new_mut.valid = jsobj.get_bool("valid", true); new_mut.purifiable = jsobj.get_bool("purifiable", true); for( auto & s : jsobj.get_string_array( "initial_ma_styles" ) ) { new_mut.initial_ma_styles.push_back( matype_id( s ) ); } JsonArray bodytemp_array = jsobj.get_array( "bodytemp_modifiers" ); if( bodytemp_array.has_more() ) { new_mut.bodytemp_min = bodytemp_array.get_int( 0 ); new_mut.bodytemp_max = bodytemp_array.get_int( 1 ); } new_mut.bodytemp_sleep = jsobj.get_int( "bodytemp_sleep", 0 ); new_mut.threshold = jsobj.get_bool("threshold", false); new_mut.profession = jsobj.get_bool("profession", false); auto vr = jsobj.get_array( "vitamin_rates" ); while( vr.has_more() ) { auto pair = vr.next_array(); new_mut.vitamin_rates[ vitamin_id( pair.get_string( 0 ) ) ] = pair.get_int( 1 ); } load_mutation_mods(jsobj, "passive_mods", new_mut.mods); /* Not currently supported due to inability to save active mutation state load_mutation_mods(jsobj, "active_mods", new_mut.mods); */ new_mut.prereqs = jsobj.get_string_array( "prereqs" ); // Helps to be able to have a trait require more than one other trait // (Individual prereq-lists are "OR", not "AND".) // Traits shoud NOT appear in both lists for a given mutation, unless // you want that trait to satisfy both requirements. // These are additional to the first list. new_mut.prereqs2 = jsobj.get_string_array( "prereqs2" ); // Dedicated-purpose prereq slot for Threshold mutations // Stuff like Huge might fit in more than one mutcat post-threshold, so yeah new_mut.threshreq = jsobj.get_string_array( "threshreq" ); new_mut.cancels = jsobj.get_string_array( "cancels" ); new_mut.replacements = jsobj.get_string_array( "changes_to" ); new_mut.additions = jsobj.get_string_array( "leads_to" ); new_mut.flags = jsobj.get_tags( "flags" ); jsarr = jsobj.get_array("category"); while (jsarr.has_more()) { std::string s = jsarr.next_string(); new_mut.category.push_back(s); mutations_category[s].push_back(id); } jsarr = jsobj.get_array("wet_protection"); while (jsarr.has_more()) { JsonObject jo = jsarr.next_object(); std::string part_id = jo.get_string("part"); int ignored = jo.get_int("ignored", 0); int neutral = jo.get_int("neutral", 0); int good = jo.get_int("good", 0); tripoint protect = tripoint(ignored, neutral, good); new_mut.protection[get_body_part_token( part_id )] = protect; } jsarr = jsobj.get_array("encumbrance_always"); while (jsarr.has_more()) { JsonArray jo = jsarr.next_array(); std::string part_id = jo.next_string(); int enc = jo.next_int(); new_mut.encumbrance_always[get_body_part_token( part_id )] = enc; } jsarr = jsobj.get_array("encumbrance_covered"); while (jsarr.has_more()) { JsonArray jo = jsarr.next_array(); std::string part_id = jo.next_string(); int enc = jo.next_int(); new_mut.encumbrance_covered[get_body_part_token( part_id )] = enc; } jsarr = jsobj.get_array("restricts_gear"); while( jsarr.has_more() ) { new_mut.restricts_gear.insert( get_body_part_token( jsarr.next_string() ) ); } jsarr = jsobj.get_array( "armor" ); while( jsarr.has_more() ) { JsonObject jo = jsarr.next_object(); auto parts = jo.get_tags( "parts" ); std::set<body_part> bps; for( const std::string &part_string : parts ) { if( part_string == "ALL" ) { // Shorthand, since many muts protect whole body for( size_t i = 0; i < num_bp; i++ ) { bps.insert( static_cast<body_part>( i ) ); } } else { bps.insert( get_body_part_token( part_string ) ); } } resistances res = load_resistances_instance( jo ); for( body_part bp : bps ) { new_mut.armor[ bp ] = res; } } }
void mutation_branch::load( JsonObject &jsobj ) { const std::string id = jsobj.get_string( "id" ); mutation_branch &new_mut = mutation_data[id]; JsonArray jsarr; new_mut.name = _(jsobj.get_string("name").c_str()); new_mut.description = _(jsobj.get_string("description").c_str()); new_mut.points = jsobj.get_int("points"); new_mut.visibility = jsobj.get_int("visibility", 0); new_mut.ugliness = jsobj.get_int("ugliness", 0); new_mut.startingtrait = jsobj.get_bool("starting_trait", false); new_mut.mixed_effect = jsobj.get_bool("mixed_effect", false); new_mut.activated = jsobj.get_bool("active", false); new_mut.cost = jsobj.get_int("cost", 0); new_mut.cooldown = jsobj.get_int("time",0); new_mut.hunger = jsobj.get_bool("hunger",false); new_mut.thirst = jsobj.get_bool("thirst",false); new_mut.fatigue = jsobj.get_bool("fatigue",false); new_mut.valid = jsobj.get_bool("valid", true); new_mut.purifiable = jsobj.get_bool("purifiable", true); for( auto & s : jsobj.get_string_array( "initial_ma_styles" ) ) { new_mut.initial_ma_styles.push_back( matype_id( s ) ); } JsonArray bodytemp_array = jsobj.get_array( "bodytemp_modifiers" ); if( bodytemp_array.has_more() ) { new_mut.bodytemp_min = bodytemp_array.get_int( 0 ); new_mut.bodytemp_max = bodytemp_array.get_int( 1 ); } new_mut.bodytemp_sleep = jsobj.get_int( "bodytemp_sleep", 0 ); new_mut.threshold = jsobj.get_bool("threshold", false); new_mut.profession = jsobj.get_bool("profession", false); load_mutation_mods(jsobj, "passive_mods", new_mut.mods); /* Not currently supported due to inability to save active mutation state load_mutation_mods(jsobj, "active_mods", new_mut.mods); */ new_mut.prereqs = jsobj.get_string_array( "prereqs" ); // Helps to be able to have a trait require more than one other trait // (Individual prereq-lists are "OR", not "AND".) // Traits shoud NOT appear in both lists for a given mutation, unless // you want that trait to satisfy both requirements. // These are additional to the first list. new_mut.prereqs2 = jsobj.get_string_array( "prereqs2" ); // Dedicated-purpose prereq slot for Threshold mutations // Stuff like Huge might fit in more than one mutcat post-threshold, so yeah new_mut.threshreq = jsobj.get_string_array( "threshreq" ); new_mut.cancels = jsobj.get_string_array( "cancels" ); new_mut.replacements = jsobj.get_string_array( "changes_to" ); new_mut.additions = jsobj.get_string_array( "leads_to" ); jsarr = jsobj.get_array("category"); while (jsarr.has_more()) { std::string s = jsarr.next_string(); new_mut.category.push_back(s); mutations_category[s].push_back(id); } jsarr = jsobj.get_array("wet_protection"); while (jsarr.has_more()) { JsonObject jo = jsarr.next_object(); std::string part_id = jo.get_string("part"); int ignored = jo.get_int("ignored", 0); int neutral = jo.get_int("neutral", 0); int good = jo.get_int("good", 0); tripoint protect = tripoint(ignored, neutral, good); new_mut.protection[get_body_part_token( part_id )] = protect; } }