Skip to content

Commit

Permalink
Jsonize skill companion rank factors
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhilkinSerg committed Dec 3, 2019
1 parent 4b3ee08 commit 3be6e22
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 15 deletions.
19 changes: 19 additions & 0 deletions data/json/skills.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
{
Expand All @@ -25,20 +26,24 @@
"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"
},
{
"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"
},
{
"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"
},
{
Expand All @@ -60,34 +65,39 @@
"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"
},
{
"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"
},
{
"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"
},
{
"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"
},
{
"type": "skill",
"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"
},
{
Expand All @@ -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"
},
{
Expand Down Expand Up @@ -160,6 +172,8 @@
"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,
"companion_combat_rank_factor": 1,
"display_category": "display_melee"
},
{
Expand All @@ -168,6 +182,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"
},
{
Expand All @@ -176,6 +191,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"
},
{
Expand All @@ -191,6 +207,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"
},
{
Expand All @@ -199,6 +216,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"
},
{
Expand Down
18 changes: 9 additions & 9 deletions src/mission_companion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1813,27 +1813,27 @@ std::vector<npc_ptr> 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 ;
}

Expand Down
6 changes: 3 additions & 3 deletions src/skill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ void Skill::load_skill( JsonObject &jsobj )
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_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;
Expand Down
15 changes: 12 additions & 3 deletions src/skill.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ class Skill
skill_displayType_id _display_type;
// these are not real skills, they depend on context
static std::map<skill_id, Skill> contextual_skills;
int companion_combat_rank_factor;
int companion_survival_rank_factor;
int companion_industry_rank_factor;
int _companion_combat_rank_factor;
int _companion_survival_rank_factor;
int _companion_industry_rank_factor;
public:
static std::vector<Skill> skills;
static void load_skill( JsonObject &jsobj );
Expand Down Expand Up @@ -62,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;
Expand Down

0 comments on commit 3be6e22

Please sign in to comment.