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

Jsonized companion skill practice data #35831

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
91 changes: 70 additions & 21 deletions data/json/skills.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"name": "speaking",
"description": "Your skill in speaking to other people. Covers ability in boasting, flattery, threats, persuasion, lies, and other facets of interpersonal communication. Works best in conjunction with a high level of intelligence.",
"companion_survival_rank_factor": 1,
"display_category": "display_social"
"display_category": "display_social",
"companion_skill_practice": [ { "skill": "recruiting", "weight": 15 }, { "skill": "recruiting", "weight": 70 } ]
},
{
"type": "skill",
Expand All @@ -28,23 +29,26 @@
"description": "Your skill in effecting emergency medical treatment. Higher levels allow better use of medicines and items like bandages and first aid kits, and reduce the failure and complication rates of medical procedures.",
"companion_survival_rank_factor": 1,
"companion_industry_rank_factor": 1,
"display_category": "display_interaction"
"display_category": "display_interaction",
"companion_skill_practice": [ { "skill": "hunting", "weight": 10 }, { "skill": "combat", "weight": 10 } ]
},
{
"type": "skill",
"ident": "mechanics",
"name": "mechanics",
"description": "Your skill in engineering, maintaining and repairing vehicles and other mechanical systems. This skill covers the craft of items with complex parts, and plays a role in the installation of bionic equipment.",
"companion_industry_rank_factor": 1,
"display_category": "display_interaction"
"display_category": "display_interaction",
"companion_skill_practice": [ { "skill": "menial", "weight": 10 }, { "skill": "construction", "weight": 20 } ]
},
{
"type": "skill",
"ident": "traps",
"name": "trapping",
"description": "Your skill in creating, setting, finding and disarming traps safely and effectively. This skill does not affect the evasion of traps that are triggered.",
"companion_survival_rank_factor": 1,
"display_category": "display_interaction"
"display_category": "display_interaction",
"companion_skill_practice": [ { "skill": "", "weight": 15 }, { "skill": "gathering", "weight": 15 }, { "skill": "trapping", "weight": 80 } ]
},
{
"type": "skill",
Expand All @@ -58,39 +62,59 @@
"ident": "swimming",
"name": "swimming",
"description": "Your ability to stay afloat and move around in bodies of water. This skill keeps you from drowning, affects your combat effectiveness and speed in deep water, and determines the detriment of swimming with heavier gear.",
"display_category": "display_interaction"
"display_category": "display_interaction",
"companion_skill_practice": [ { "skill": "", "weight": 5 }, { "skill": "gathering", "weight": 5 }, { "skill": "trapping", "weight": 5 } ]
},
{
"type": "skill",
"ident": "fabrication",
"name": "fabrication",
"description": "Your skill in working with raw materials and shaping them into useful objects. This skill plays an important role in the crafting of many objects.",
"companion_industry_rank_factor": 1,
"display_category": "display_crafting"
"display_category": "display_crafting",
"companion_skill_practice": [
{ "skill": "", "weight": 10 },
{ "skill": "gathering", "weight": 10 },
{ "skill": "trapping", "weight": 10 },
{ "skill": "menial", "weight": 60 },
{ "skill": "construction", "weight": 70 }
]
},
{
"type": "skill",
"ident": "cooking",
"name": "cooking",
"description": "Your skill in combining food ingredients to make other, tastier food items. It may also be used in certain chemical mixtures and other, more esoteric tasks.",
"companion_industry_rank_factor": 1,
"display_category": "display_crafting"
"display_category": "display_crafting",
"companion_skill_practice": [ { "skill": "menial", "weight": 15 } ]
},
{
"type": "skill",
"ident": "tailor",
"name": "tailoring",
"description": "Your skill in the craft and repair of clothing, bags, blankets and other textiles. Affects knitting, sewing, stitching, weaving, and nearly anything else involving a needle and thread.",
"companion_industry_rank_factor": 1,
"display_category": "display_crafting"
"display_category": "display_crafting",
"companion_skill_practice": [ { "skill": "menial", "weight": 15 } ]
},
{
"type": "skill",
"ident": "survival",
"name": "survival",
"description": "Your skill in surviving the wilderness, and in crafting various basic survival items. This also covers your ability to skin and butcher animals for meat and hides.",
"companion_survival_rank_factor": 1,
"display_category": "display_crafting"
"display_category": "display_crafting",
"companion_skill_practice": [
{ "skill": "", "weight": 80 },
{ "skill": "gathering", "weight": 80 },
{ "skill": "trapping", "weight": 15 },
{ "skill": "hunting", "weight": 15 },
{ "skill": "menial", "weight": 10 },
{ "skill": "construction", "weight": 10 },
{ "skill": "recruiting", "weight": 25 },
{ "skill": "combat", "weight": 10 }
]
},
{
"type": "skill",
Expand All @@ -108,15 +132,23 @@
"tags": [ "combat_skill" ],
"companion_combat_rank_factor": 1,
"companion_survival_rank_factor": 1,
"display_category": "display_ranged"
"display_category": "display_ranged",
"companion_skill_practice": [
{ "skill": "", "weight": 5 },
{ "skill": "gathering", "weight": 5 },
{ "skill": "trapping", "weight": 5 },
{ "skill": "hunting", "weight": 45 },
{ "skill": "combat", "weight": 15 }
]
},
{
"type": "skill",
"ident": "gun",
"name": "marksmanship",
"description": "Your overall skill in using bows and firearms. With higher levels, this general experience increases accuracy with any bows or firearms, but is secondary to practice with the type of ranged weapon in question.",
"tags": [ "combat_skill" ],
"display_category": "display_ranged"
"display_category": "display_ranged",
"companion_skill_practice": [ { "skill": "gathering", "weight": 60 }, { "skill": "combat", "weight": 5 } ]
},
{
"type": "skill",
Expand All @@ -132,31 +164,35 @@
"name": "handguns",
"description": "Handguns have poor accuracy compared to rifles, but are usually quick to fire and reload faster than other guns. They are very effective at close quarters, though unsuited for long range engagement.",
"tags": [ "combat_skill" ],
"display_category": "display_ranged"
"display_category": "display_ranged",
"companion_skill_practice": [ { "skill": "hunting", "weight": 25 } ]
},
{
"type": "skill",
"ident": "rifle",
"name": "rifles",
"description": "Rifles have terrific range and accuracy compared to other firearms, but may be slow to fire and reload, and can prove difficult to use in close quarters. Fully automatic rifles can fire rapidly, but are harder to handle properly.",
"tags": [ "combat_skill" ],
"display_category": "display_ranged"
"display_category": "display_ranged",
"companion_skill_practice": [ { "skill": "hunting", "weight": 45 } ]
},
{
"type": "skill",
"ident": "shotgun",
"name": "shotguns",
"description": "Shotguns are easy to shoot and can inflict massive damage, but their effectiveness and accuracy decline rapidly with range. Slugs can be loaded into shotguns to provide greater range, though they are somewhat inaccurate.",
"tags": [ "combat_skill" ],
"display_category": "display_ranged"
"display_category": "display_ranged",
"companion_skill_practice": [ { "skill": "hunting", "weight": 25 } ]
},
{
"type": "skill",
"ident": "smg",
"name": "submachine guns",
"description": "Comprised of an automatic rifle carbine designed to fire a pistol cartridge, submachine guns can reload and fire quickly, sometimes in bursts, but they are relatively inaccurate and may be prone to mechanical failures.",
"tags": [ "combat_skill" ],
"display_category": "display_ranged"
"display_category": "display_ranged",
"companion_skill_practice": [ { "skill": "hunting", "weight": 25 } ]
},
{
"type": "skill",
Expand All @@ -173,7 +209,15 @@
"description": "Your skill and finesse in personal combat, both with and without a weapon. Higher levels can significantly increase the accuracy and effectiveness of your physical attacks.",
"tags": [ "combat_skill" ],
"companion_combat_rank_factor": 1,
"display_category": "display_melee"
"display_category": "display_melee",
"companion_skill_practice": [
{ "skill": "", "weight": 5 },
{ "skill": "gathering", "weight": 5 },
{ "skill": "trapping", "weight": 5 },
{ "skill": "hunting", "weight": 10 },
{ "skill": "recruiting", "weight": 5 },
{ "skill": "combat", "weight": 20 }
]
},
{
"type": "skill",
Expand All @@ -182,7 +226,8 @@
"description": "Your skill in fighting with blunt weaponry, from rocks and sticks to baseball bats and the butts of rifles. Skill increases damage, and higher levels will improve the accuracy of an attack.",
"tags": [ "combat_skill" ],
"companion_combat_rank_factor": 1,
"display_category": "display_melee"
"display_category": "display_melee",
"companion_skill_practice": [ { "skill": "hunting", "weight": 10 }, { "skill": "combat", "weight": 10 } ]
},
{
"type": "skill",
Expand All @@ -191,14 +236,16 @@
"description": "Your skill in fighting with weaponry designed to cut, hack and slash an opponent. Lower levels of skill increase accuracy and damage, while higher levels will help to bypass heavy armor and thick hides.",
"tags": [ "combat_skill" ],
"companion_combat_rank_factor": 1,
"display_category": "display_melee"
"display_category": "display_melee",
"companion_skill_practice": [ { "skill": "hunting", "weight": 10 }, { "skill": "combat", "weight": 10 } ]
},
{
"type": "skill",
"ident": "dodge",
"name": "dodging",
"description": "Your ability to dodge an oncoming threat, be it an enemy's attack, a triggered trap, or a falling rock. This skill is also used in attempts to fall gracefully, and for other acrobatic feats. The first number shown includes modifiers, and the second does not.",
"display_category": "display_melee"
"display_category": "display_melee",
"companion_skill_practice": [ { "skill": "hunting", "weight": 15 }, { "skill": "combat", "weight": 20 } ]
},
{
"type": "skill",
Expand All @@ -207,7 +254,8 @@
"description": "Your skill in fighting with knives, spears and other such stabbing implements. Skill increases attack accuracy as well as the chance of inflicting a deadly and critical blow.",
"tags": [ "combat_skill" ],
"companion_combat_rank_factor": 1,
"display_category": "display_melee"
"display_category": "display_melee",
"companion_skill_practice": [ { "skill": "hunting", "weight": 10 }, { "skill": "combat", "weight": 10 } ]
},
{
"type": "skill",
Expand All @@ -217,7 +265,8 @@
"tags": [ "combat_skill" ],
"companion_combat_rank_factor": 1,
"companion_survival_rank_factor": 1,
"display_category": "display_melee"
"display_category": "display_melee",
"companion_skill_practice": [ { "skill": "hunting", "weight": 10 }, { "skill": "combat", "weight": 10 } ]
},
{
"type": "skill",
Expand Down
76 changes: 10 additions & 66 deletions src/mission_companion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,6 @@ const skill_id skill_tailor( "tailor" );
const skill_id skill_cooking( "cooking" );
const skill_id skill_traps( "traps" );
const skill_id skill_archery( "archery" );
const skill_id skill_rifle( "rifle" );
const skill_id skill_pistol( "pistol" );
const skill_id skill_shotgun( "shotgun" );
const skill_id skill_smg( "smg" );
const skill_id skill_swimming( "swimming" );

static const trait_id trait_NPC_CONSTRUCTION_LEV_1( "NPC_CONSTRUCTION_LEV_1" );
static const trait_id trait_NPC_CONSTRUCTION_LEV_2( "NPC_CONSTRUCTION_LEV_2" );
Expand Down Expand Up @@ -1698,72 +1693,21 @@ void talk_function::companion_skill_trainer( npc &comp, const std::string &skill
int checks = 1 + to_minutes<int>( time_worked ) / 10;

weighted_int_list<skill_id> skill_practice;
if( skill_tested.empty() || skill_tested == "gathering" ) {
skill_practice.add( skill_survival, 80 );
skill_practice.add( skill_traps, 15 );
skill_practice.add( skill_fabrication, 10 );
skill_practice.add( skill_archery, 5 );
skill_practice.add( skill_melee, 5 );
skill_practice.add( skill_swimming, 5 );
} else if( skill_tested == "trapping" ) {
skill_practice.add( skill_traps, 80 );
skill_practice.add( skill_survival, 15 );
skill_practice.add( skill_fabrication, 10 );
skill_practice.add( skill_archery, 5 );
skill_practice.add( skill_melee, 5 );
skill_practice.add( skill_swimming, 5 );
} else if( skill_tested == "hunting" ) {
skill_practice.add( skill_gun, 60 );
skill_practice.add( skill_archery, 45 );
skill_practice.add( skill_rifle, 45 );
skill_practice.add( skill_pistol, 25 );
skill_practice.add( skill_shotgun, 25 );
// who shoots Bambi with an Uzi?
skill_practice.add( skill_smg, 25 );
skill_practice.add( skill_dodge, 15 );
skill_practice.add( skill_survival, 15 );
skill_practice.add( skill_melee, 10 );
skill_practice.add( skill_firstaid, 10 );
skill_practice.add( skill_bashing, 10 );
skill_practice.add( skill_stabbing, 10 );
skill_practice.add( skill_cutting, 10 );
skill_practice.add( skill_unarmed, 10 );
} else if( skill_tested == "menial" ) {
skill_practice.add( skill_fabrication, 60 );
skill_practice.add( skill_tailor, 15 );
skill_practice.add( skill_speech, 15 );
skill_practice.add( skill_cooking, 15 );
skill_practice.add( skill_survival, 10 );
skill_practice.add( skill_mechanics, 10 );
} else if( skill_tested == "construction" ) {
skill_practice.add( skill_fabrication, 70 );
skill_practice.add( skill_mechanics, 20 );
skill_practice.add( skill_survival, 10 );
} else if( skill_tested == "recruiting" ) {
skill_practice.add( skill_speech, 70 );
skill_practice.add( skill_survival, 25 );
skill_practice.add( skill_melee, 5 );
} else if( skill_tested == "combat" ) {
if( skill_tested == "combat" ) {
const skill_id best_skill = comp.best_skill();
if( best_skill ) {
skill_practice.add( best_skill, 30 );
}
skill_practice.add( skill_melee, 20 );
skill_practice.add( skill_dodge, 20 );
skill_practice.add( skill_archery, 15 );
skill_practice.add( skill_survival, 10 );
skill_practice.add( skill_firstaid, 10 );
skill_practice.add( skill_bashing, 10 );
skill_practice.add( skill_stabbing, 10 );
skill_practice.add( skill_cutting, 10 );
skill_practice.add( skill_unarmed, 10 );
skill_practice.add( skill_gun, 5 );
} else {
comp.practice( skill_id( skill_tested ), difficulty * to_minutes<int>( time_worked ) / 10 );
return;
}
for( int i = 0; i < checks; i++ ) {
comp.practice( *skill_practice.pick(), difficulty );
for( Skill &sk : Skill::skills ) {
skill_practice.add( sk.ident(), sk.get_companion_skill_practice( skill_tested ) );
}
if( skill_practice.empty() ) {
comp.practice( skill_id( skill_tested ), difficulty * to_minutes<int>( time_worked ) / 10 );
} else {
for( int i = 0; i < checks; i++ ) {
comp.practice( *skill_practice.pick(), difficulty );
}
}
}

Expand Down
7 changes: 7 additions & 0 deletions src/skill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,22 @@ void Skill::load_skill( JsonObject &jsobj )
return s._ident == ident;
} ), end( skills ) );

std::unordered_map<std::string, int> companion_skill_practice;
translation name, desc;
jsobj.read( "name", name );
jsobj.read( "description", desc );
JsonArray ja = jsobj.get_array( "companion_skill_practice" );
while( ja.has_more() ) {
JsonObject jo = ja.next_object();
companion_skill_practice.emplace( jo.get_string( "skill" ), jo.get_int( "weight" ) );
}
skill_displayType_id display_type = skill_displayType_id( jsobj.get_string( "display_category" ) );
Skill sk( ident, name, desc, jsobj.get_tags( "tags" ), display_type );

sk._companion_combat_rank_factor = jsobj.get_int( "companion_combat_rank_factor", 0 );
sk._companion_survival_rank_factor = jsobj.get_int( "companion_survival_rank_factor", 0 );
sk._companion_industry_rank_factor = jsobj.get_int( "companion_industry_rank_factor", 0 );
sk._companion_skill_practice = companion_skill_practice;

if( sk.is_contextual_skill() ) {
contextual_skills[sk.ident()] = sk;
Expand Down
6 changes: 6 additions & 0 deletions src/skill.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <set>
#include <vector>
#include <string>
#include <unordered_map>

#include "calendar.h"
#include "string_id.h"
Expand All @@ -28,6 +29,7 @@ class Skill
translation _description;
std::set<std::string> _tags;
skill_displayType_id _display_type;
std::unordered_map<std::string, int> _companion_skill_practice;
// these are not real skills, they depend on context
static std::map<skill_id, Skill> contextual_skills;
int _companion_combat_rank_factor;
Expand Down Expand Up @@ -59,6 +61,10 @@ class Skill
std::string description() const {
return _description.translated();
}
int get_companion_skill_practice( const std::string &companion_skill ) const {
return _companion_skill_practice.find( companion_skill ) == _companion_skill_practice.end() ? 0 :
_companion_skill_practice.at( companion_skill );
}
skill_displayType_id display_category() const {
return _display_type;
}
Expand Down