Skip to content

Commit

Permalink
Jsonize crafting skill penalty from mutations (#36565)
Browse files Browse the repository at this point in the history
* Jsonize crafting skill penalty from mutations
* Halve the penalty from paws mutations
  • Loading branch information
Fris0uman authored and kevingranade committed Dec 31, 2019
1 parent b693d93 commit 528f49b
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 12 deletions.
12 changes: 12 additions & 0 deletions data/json/mutations/mutations.json
Original file line number Diff line number Diff line change
Expand Up @@ -4854,6 +4854,7 @@
"description": "Your hands have fused into quasi-paws. Fine manipulation is a challenge: permanent hand encumbrance of 10, difficulty with delicate craftwork, and your gloves don't fit. But they handle water better.",
"encumbrance_always": [ [ "HAND_L", 10 ], [ "HAND_R", 10 ] ],
"restricts_gear": [ "HAND_L", "HAND_R" ],
"craft_skill_bonus": [ [ "electronics", -2 ], [ "tailor", -2 ], [ "mechanics", -2 ] ],
"types": [ "HANDS" ],
"prereqs": [ "CLAWS", "CLAWS_RETRACT", "CLAWS_RAT" ],
"cancels": [ "TALONS" ],
Expand All @@ -4869,6 +4870,17 @@
"ugliness": 3,
"mixed_effect": true,
"description": "Your paws are much larger now. Manual dexterity is difficult: permanent hand encumbrance of 20, serious problems crafting, and no gloves. But you can swim more effectively.",
"craft_skill_bonus": [
[ "electronics", -4 ],
[ "tailor", -4 ],
[ "mechanics", -4 ],
[ "firstaid", -2 ],
[ "computer", -2 ],
[ "traps", -2 ],
[ "fabrication", -2 ],
[ "cooking", -2 ],
[ "survival", -2 ]
],
"encumbrance_always": [ [ "HAND_L", 20 ], [ "HAND_R", 20 ] ],
"restricts_gear": [ "HAND_L", "HAND_R" ],
"types": [ "HANDS" ],
Expand Down
1 change: 1 addition & 0 deletions doc/JSON_INFO.md
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,7 @@ Note that even though most statistics yield an integer, you should still use
"good": 1 } ] // "neutral/good/ignored" // Good increases pos and cancels neg, neut cancels neg, ignored cancels both
"vitamin_rates": [ [ "vitC", -1200 ] ], // How much extra vitamins do you consume per minute. Negative values mean production
"vitamins_absorb_multi": [ [ "flesh", [ [ "vitA", 0 ], [ "vitB", 0 ], [ "vitC", 0 ], [ "calcium", 0 ], [ "iron", 0 ] ], [ "all", [ [ "vitA", 2 ], [ "vitB", 2 ], [ "vitC", 2 ], [ "calcium", 2 ], [ "iron", 2 ] ] ] ], // multiplier of vitamin absorption based on material. "all" is every material. supports multiple materials.
"craft_skill_bonus": [ [ "electronics", -2 ], [ "tailor", -2 ], [ "mechanics", -2 ] ], // Skill affected by the mutation and their bonuses. Bonuses can be negative, a bonus of 4 is worth 1 full skill level.
"restricts_gear" : [ "TORSO" ], //list of bodyparts that get restricted by this mutation
"allow_soft_gear" : true, //If there is a list of 'restricts_gear' this sets if the location still allows items made out of soft materials (Only one of the types need to be soft for it to be considered soft). (default: false)
"destroys_gear" : true, //If true, destroys the gear in the 'restricts_gear' location when mutated into. (default: false)
Expand Down
18 changes: 6 additions & 12 deletions src/crafting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "map.h"
#include "map_iterator.h"
#include "messages.h"
#include "mutation.h"
#include "npc.h"
#include "options.h"
#include "output.h"
Expand Down Expand Up @@ -73,8 +74,6 @@ static const efftype_id effect_contacts( "contacts" );
void drop_or_handle( const item &newit, player &p );

static const trait_id trait_DEBUG_HS( "DEBUG_HS" );
static const trait_id trait_PAWS_LARGE( "PAWS_LARGE" );
static const trait_id trait_PAWS( "PAWS" );
static const trait_id trait_BURROW( "BURROW" );

static bool crafting_allowed( const player &p, const recipe &rec )
Expand Down Expand Up @@ -923,17 +922,12 @@ double player::crafting_success_roll( const recipe &making ) const

// It's tough to craft with paws. Fortunately it's just a matter of grip and fine-motor,
// not inability to see what you're doing
if( has_trait( trait_PAWS ) || has_trait( trait_PAWS_LARGE ) ) {
int paws_rank_penalty = 0;
if( has_trait( trait_PAWS_LARGE ) ) {
paws_rank_penalty += 1;
}
if( making.skill_used == skill_id( "electronics" )
|| making.skill_used == skill_id( "tailor" )
|| making.skill_used == skill_id( "mechanics" ) ) {
paws_rank_penalty += 1;
for( const std::pair< trait_id, trait_data > &mut : my_mutations ) {
for( const std::pair<skill_id, int> &skib : mut.first->craft_skill_bonus ) {
if( making.skill_used == skib.first ) {
skill_dice += skib.second;
}
}
skill_dice -= paws_rank_penalty * 4;
}

// Sides on dice is 16 plus your current intelligence
Expand Down
3 changes: 3 additions & 0 deletions src/mutation.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ struct mutation_branch {
cata::optional<int> scent_mask;
int bleed_resist = 0;

/**Map of crafting skills modifiers, can be negative*/
std::map<skill_id, int> craft_skill_bonus;

/**What do you smell like*/
cata::optional<scenttype_id> scent_typeid;

Expand Down
9 changes: 9 additions & 0 deletions src/mutation_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,15 @@ void mutation_branch::load( const JsonObject &jo, const std::string & )
spells_learned.emplace( sp, ja.next_int() );
}

for( JsonArray ja : jo.get_array( "craft_skill_bonus" ) ) {
const skill_id skid( ja.next_string() );
if( skid.is_valid() ) {
craft_skill_bonus.emplace( skid, ja.next_int() );
} else {
jo.throw_error( "invalid skill_id" );
}
}

for( JsonArray ja : jo.get_array( "lumination" ) ) {
const body_part bp = get_body_part_token( ja.next_string() );
lumination.emplace( bp, ja.next_float() );
Expand Down

0 comments on commit 528f49b

Please sign in to comment.