Skip to content

Commit

Permalink
Merge pull request CleverRaven#15424 from Coolthulhu/sewing-alter
Browse files Browse the repository at this point in the history
[CR]Item repair rebalance and modifications
  • Loading branch information
Rivet-the-Zombie committed Feb 17, 2016
2 parents 9bca3bd + 7674084 commit ff691e8
Show file tree
Hide file tree
Showing 5 changed files with 212 additions and 67 deletions.
16 changes: 8 additions & 8 deletions data/json/items/tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@
"cotton", "leather", "wool", "fur", "nomex"
],
"skill": "tailor",
"cost_scaling": 0,
"cost_scaling": 0.1,
"tool_quality": 0,
"move_cost": 1000
}
Expand Down Expand Up @@ -327,7 +327,7 @@
"cotton", "leather", "wool", "fur", "nomex", "neoprene"
],
"skill": "tailor",
"cost_scaling": 0,
"cost_scaling": 0.1,
"tool_quality": 1,
"move_cost": 800
},
Expand Down Expand Up @@ -1727,7 +1727,7 @@
"kevlar", "plastic", "iron", "steel", "hardsteel", "aluminum", "copper"
],
"skill": "mechanics",
"cost_scaling": 0.25,
"cost_scaling": 0.1,
"move_cost": 1500
},
{
Expand Down Expand Up @@ -4643,7 +4643,7 @@
"kevlar", "plastic", "iron", "steel", "hardsteel", "aluminum", "copper"
],
"skill": "mechanics",
"cost_scaling": 0.25,
"cost_scaling": 0.1,
"move_cost": 500,
"tool_quality": 3
},
Expand Down Expand Up @@ -6661,7 +6661,7 @@
"cotton", "leather", "wool", "fur", "nomex"
],
"skill": "tailor",
"cost_scaling": 0,
"cost_scaling": 0.1,
"tool_quality": -1,
"move_cost": 1300
}
Expand Down Expand Up @@ -6692,7 +6692,7 @@
"cotton", "leather", "wool", "fur", "nomex"
],
"skill": "tailor",
"cost_scaling": 0,
"cost_scaling": 0.1,
"tool_quality": -1,
"move_cost": 1500
}
Expand Down Expand Up @@ -7793,7 +7793,7 @@
"kevlar", "plastic", "iron", "steel", "hardsteel", "aluminum", "copper"
],
"skill": "mechanics",
"cost_scaling": 0.25,
"cost_scaling": 0.1,
"move_cost": 1000,
"tool_quality": 3
},
Expand Down Expand Up @@ -11000,7 +11000,7 @@
"neoprene", "nomex"
],
"skill": "tailor",
"cost_scaling": 0,
"cost_scaling": 0.1,
"tool_quality": 0,
"move_cost": 1200
}
Expand Down
16 changes: 13 additions & 3 deletions src/activity_handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1387,10 +1387,10 @@ enum repeat_type : int {
REPEAT_CANCEL // Stop repeating
};

repeat_type repeat_menu( repeat_type last_selection )
repeat_type repeat_menu( const std::string &title, repeat_type last_selection )
{
uimenu rmenu;
rmenu.text = _("Repeat repairing?");
rmenu.text = title;
rmenu.addentry( REPEAT_ONCE, true, '1', _("Repeat once") );
rmenu.addentry( REPEAT_FOREVER, true, '2', _("Repeat as long as you can") );
rmenu.addentry( REPEAT_FULL, true, '3', _("Repeat until fully repaired, but don't reinforce") );
Expand Down Expand Up @@ -1529,7 +1529,17 @@ void activity_handlers::repair_item_finish( player_activity *act, player *p )

if( need_input ) {
g->draw();
repeat_type answer = repeat_menu( repeat );
auto action_type = actor->default_action( fix );
const auto chance = actor->repair_chance( *p, fix, action_type );
if( chance.first <= 0.0f ) {
action_type = repair_item_actor::RT_PRACTICE;
}

const std::string title = string_format(
_("%s\nSuccess chance %.1f\nDamage chance %.1f"),
repair_item_actor::action_description( action_type ).c_str(),
100.0f * chance.first, 100.0f * chance.second );
repeat_type answer = repeat_menu( title, repeat );
if( answer == REPEAT_CANCEL ) {
act->type = ACT_NULL;
return;
Expand Down
43 changes: 23 additions & 20 deletions src/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2728,24 +2728,21 @@ int item::get_encumber() const
if( item::item_tags.count("FIT") ) {
encumber = std::max( encumber / 2, encumber - 10 );
}
// Good items to test this stuff on:
// Hoodies (3 thickness), jumpsuits (2 thickness, 3 encumbrance),
// Nomes socks (2 thickness, 0 encumbrance)
// When a common item has 90%+ coverage, 15/15 protection and <=5 encumbrance,
// it's a sure sign something has to be nerfed.

const int thickness = get_thickness();
const int coverage = get_coverage();
if( item::item_tags.count("wooled") ) {
encumber += 3;
encumber += 1 + 3 * coverage / 100;
}
if( item::item_tags.count("furred") ){
encumber += 5;
encumber += 1 + 4 * coverage / 100;
}
// Don't let dual-armor-modded items get below 10 encumbrance after fitting
// Also prevent 0 encumbrance armored underwear

if( item::item_tags.count("leather_padded") ) {
encumber = std::max( 15, encumber + 7 );
encumber += thickness * coverage / 100 + 5;
}
if( item::item_tags.count("kevlar_padded") ) {
encumber = std::max( 13, encumber + 5 );
encumber += thickness * coverage / 100 + 5;
}

return encumber;
Expand Down Expand Up @@ -2796,13 +2793,15 @@ int item::get_warmth() const
// it_armor::warmth is signed char
int result = static_cast<int>( t->warmth );

if (item::item_tags.count("furred") > 0){
fur_lined = 35 * (float(get_coverage()) / 100);
if( item::item_tags.count("furred") > 0 ) {
fur_lined = 35 * get_coverage() / 100;
}
if (item::item_tags.count("wooled") > 0){
wool_lined = 20 * (float(get_coverage()) / 100);

if( item::item_tags.count("wooled") > 0 ) {
wool_lined = 20 * get_coverage() / 100;
}
return result + fur_lined + wool_lined;

return result + fur_lined + wool_lined;
}


Expand Down Expand Up @@ -2893,7 +2892,7 @@ long item::num_charges()
return 0;
}

int item::bash_resist(bool /*to_self*/) const
int item::bash_resist( bool to_self ) const
{
float resist = 0;
float l_padding = 0;
Expand Down Expand Up @@ -2922,7 +2921,9 @@ int item::bash_resist(bool /*to_self*/) const
// Armor gets an additional multiplier.
if (is_armor()) {
// base resistance
eff_thickness = ((get_thickness() - damage <= 0) ? 1 : (get_thickness() - damage));
// Don't give reinforced items +armor, just more resistance to ripping
const int eff_damage = std::max( to_self ? -1 : 0, damage );
eff_thickness = ((get_thickness() - eff_damage <= 0) ? 1 : (get_thickness() - eff_damage));
}

for (auto mat : mat_types) {
Expand All @@ -2934,7 +2935,7 @@ int item::bash_resist(bool /*to_self*/) const
return lround((resist * eff_thickness * adjustment) + l_padding + k_padding);
}

int item::cut_resist(bool /*to_self*/) const
int item::cut_resist( bool to_self ) const
{
float resist = 0;
float l_padding = 0;
Expand Down Expand Up @@ -2964,7 +2965,9 @@ int item::cut_resist(bool /*to_self*/) const
// Armor gets an additional multiplier.
if (is_armor()) {
// base resistance
eff_thickness = ((get_thickness() - damage <= 0) ? 1 : (get_thickness() - damage));
// Don't give reinforced items +armor, just more resistance to ripping
const int eff_damage = std::max( to_self ? -1 : 0, damage );
eff_thickness = ((get_thickness() - eff_damage <= 0) ? 1 : (get_thickness() - eff_damage));
}

for (auto mat : mat_types) {
Expand Down
Loading

0 comments on commit ff691e8

Please sign in to comment.