From d635d1243a011a505627a1f971cc5930e5a0a65f Mon Sep 17 00:00:00 2001 From: ZhilkinSerg Date: Wed, 4 Dec 2019 01:07:43 +0300 Subject: [PATCH] Jsonize skill companion rank factors --- data/json/skills.json | 18 ++++++++++++++++++ src/mission_companion.cpp | 18 +++++++++--------- src/skill.cpp | 6 +++++- src/skill.h | 12 ++++++++++++ 4 files changed, 44 insertions(+), 10 deletions(-) diff --git a/data/json/skills.json b/data/json/skills.json index 75f5575891f63..e3f4c99fb7d6d 100644 --- a/data/json/skills.json +++ b/data/json/skills.json @@ -11,6 +11,7 @@ "ident": "speech", "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" }, { @@ -25,6 +26,8 @@ "ident": "firstaid", "name": "first aid", "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" }, { @@ -32,6 +35,7 @@ "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" }, { @@ -39,6 +43,7 @@ "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" }, { @@ -60,6 +65,7 @@ "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" }, { @@ -67,6 +73,7 @@ "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" }, { @@ -74,6 +81,7 @@ "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" }, { @@ -81,6 +89,7 @@ "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" }, { @@ -88,6 +97,7 @@ "ident": "electronics", "name": "electronics", "description": "Your skill in dealing with electrical systems, used in the craft and repair of objects with electrical components. This skill is an important part of installing and managing bionic implants.", + "companion_industry_rank_factor": 1, "display_category": "display_crafting" }, { @@ -96,6 +106,8 @@ "name": "archery", "description": "Your skill in using bow weapons, from hand-carved self bows to complex compound bows. Quiet and effective, they require strength of body and sight to wield, and are not terribly accurate over a long distance.", "tags": [ "combat_skill" ], + "companion_combat_rank_factor": 1, + "companion_survival_rank_factor": 1, "display_category": "display_ranged" }, { @@ -160,6 +172,7 @@ "name": "melee", "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" }, { @@ -168,6 +181,7 @@ "name": "bashing weapons", "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" }, { @@ -176,6 +190,7 @@ "name": "cutting weapons", "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" }, { @@ -191,6 +206,7 @@ "name": "piercing weapons", "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" }, { @@ -199,6 +215,8 @@ "name": "unarmed combat", "description": "Your skill in hand-to-hand fighting. For the unskilled, it's a good way to get hurt, but those with enough practice can perform special blows and techniques to quickly dispatch enemies.", "tags": [ "combat_skill" ], + "companion_combat_rank_factor": 1, + "companion_survival_rank_factor": 1, "display_category": "display_melee" }, { diff --git a/src/mission_companion.cpp b/src/mission_companion.cpp index 1b3d19abcd9bd..120e398cd5d9a 100644 --- a/src/mission_companion.cpp +++ b/src/mission_companion.cpp @@ -1813,27 +1813,27 @@ std::vector talk_function::companion_list( const npc &p, const std::str static int companion_combat_rank( const npc &p ) { int combat = 2 * p.get_dex() + 3 * p.get_str() + 2 * p.get_per() + p.get_int(); - combat += p.get_skill_level( skill_archery ) + p.get_skill_level( skill_bashing ) + - p.get_skill_level( skill_cutting ) + p.get_skill_level( skill_melee ) + - p.get_skill_level( skill_stabbing ) + p.get_skill_level( skill_unarmed ); + for( const Skill &sk : Skill::skills ) { + combat += p.get_skill_level( sk.ident() ) * sk.companion_combat_rank_factor(); + } return combat * std::min( p.get_dex(), 32 ) * std::min( p.get_str(), 32 ) / 64; } static int companion_survival_rank( const npc &p ) { int survival = 2 * p.get_dex() + p.get_str() + 2 * p.get_per() + 1.5 * p.get_int(); - survival += p.get_skill_level( skill_archery ) + p.get_skill_level( skill_firstaid ) + - p.get_skill_level( skill_speech ) + p.get_skill_level( skill_survival ) + - p.get_skill_level( skill_traps ) + p.get_skill_level( skill_unarmed ); + for( const Skill &sk : Skill::skills ) { + survival += p.get_skill_level( sk.ident() ) * sk.companion_survival_rank_factor(); + } return survival * std::min( p.get_dex(), 32 ) * std::min( p.get_per(), 32 ) / 64; } static int companion_industry_rank( const npc &p ) { int industry = p.get_dex() + p.get_str() + p.get_per() + 3 * p.get_int(); - industry += p.get_skill_level( skill_cooking ) + p.get_skill_level( skill_electronics ) + - p.get_skill_level( skill_fabrication ) + p.get_skill_level( skill_mechanics ) + - p.get_skill_level( skill_tailor ); + for( const Skill &sk : Skill::skills ) { + industry += p.get_skill_level( sk.ident() ) * sk.companion_industry_rank_factor(); + } return industry * std::min( p.get_int(), 32 ) / 8 ; } diff --git a/src/skill.cpp b/src/skill.cpp index 242b72a7f2e24..6b33df71e62d6 100644 --- a/src/skill.cpp +++ b/src/skill.cpp @@ -96,7 +96,11 @@ void Skill::load_skill( JsonObject &jsobj ) jsobj.read( "name", name ); jsobj.read( "description", desc ); skill_displayType_id display_type = skill_displayType_id( jsobj.get_string( "display_category" ) ); - const Skill sk( ident, name, desc, jsobj.get_tags( "tags" ), display_type ); + 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 ); if( sk.is_contextual_skill() ) { contextual_skills[sk.ident()] = sk; diff --git a/src/skill.h b/src/skill.h index 71a6771034ae2..fc4a597176423 100644 --- a/src/skill.h +++ b/src/skill.h @@ -30,6 +30,9 @@ class Skill skill_displayType_id _display_type; // these are not real skills, they depend on context static std::map contextual_skills; + int _companion_combat_rank_factor; + int _companion_survival_rank_factor; + int _companion_industry_rank_factor; public: static std::vector skills; static void load_skill( JsonObject &jsobj ); @@ -59,6 +62,15 @@ class Skill skill_displayType_id display_category() const { return _display_type; } + int companion_combat_rank_factor() const { + return _companion_combat_rank_factor; + } + int companion_survival_rank_factor() const { + return _companion_survival_rank_factor; + } + int companion_industry_rank_factor() const { + return _companion_industry_rank_factor; + } bool operator==( const Skill &b ) const { return this->_ident == b._ident;