Skip to content

Commit

Permalink
fix(balance): repair chance rebalancing (#3731)
Browse files Browse the repository at this point in the history
* fix(balance): repair chance rebalancing

* Update json_info.md

* Woops

* Yeet dat table

(╯°□°)╯︵ ┻━┻

* Update iuse_actor.cpp
  • Loading branch information
chaosvolt authored Nov 26, 2023
1 parent e038b1c commit faa472c
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 19 deletions.
10 changes: 5 additions & 5 deletions data/json/items/tool/tailoring.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"item_action_type": "repair_fabric",
"materials": [ "cotton", "leather", "nylon", "wool", "fur", "faux_fur", "nomex", "kevlar", "gutskin" ],
"skill": "tailor",
"tool_quality": -1,
"tool_quality": 1,
"cost_scaling": 0.1,
"move_cost": 1300
},
Expand Down Expand Up @@ -101,7 +101,7 @@
"item_action_type": "repair_fabric",
"materials": [ "neoprene" ],
"skill": "tailor",
"tool_quality": 0,
"tool_quality": 1,
"cost_scaling": 0.1,
"move_cost": 1200
},
Expand Down Expand Up @@ -130,7 +130,7 @@
"item_action_type": "repair_fabric",
"materials": [ "cotton", "nylon", "leather", "wool", "fur", "faux_fur", "nomex", "gutskin" ],
"skill": "tailor",
"tool_quality": -1,
"tool_quality": 0,
"cost_scaling": 0.1,
"move_cost": 1500
},
Expand Down Expand Up @@ -160,7 +160,7 @@
"item_action_type": "repair_fabric",
"materials": [ "cotton", "leather", "nylon", "wool", "fur", "faux_fur", "nomex", "kevlar", "gutskin" ],
"skill": "tailor",
"tool_quality": 0,
"tool_quality": 2,
"cost_scaling": 0.1,
"move_cost": 1000
},
Expand Down Expand Up @@ -206,7 +206,7 @@
"item_action_type": "repair_fabric",
"materials": [ "cotton", "leather", "nylon", "wool", "fur", "faux_fur", "nomex", "kevlar", "neoprene", "gutskin" ],
"skill": "tailor",
"tool_quality": 1,
"tool_quality": 3,
"cost_scaling": 0.1,
"move_cost": 800
},
Expand Down
24 changes: 23 additions & 1 deletion doc/src/content/docs/en/mod/json/reference/json_info.md
Original file line number Diff line number Diff line change
Expand Up @@ -2414,7 +2414,29 @@ more structured function.
"done_message": "Place the beartrap on the %s.", // The message that appears after the trap has been placed. %s is replaced with the terrain name of the place where the trap has been put.
"practice": 4, // How much practice to the "traps" skill placing the trap gives.
"moves": 10 // (optional, default is 100): the move points that are used by placing the trap.
}
},
"use_action": {
{
"type": "repair_item", // Repair items. Skill, tool quality, and dexterity is checked against how hard that item is to craft/dissemble (which may be modified with repairs_like).
"item_action_type": "repair_fabric", // Points to an item_action JSON entry that determines the action's name in the use menu. Vanilla examples include repair_fabric and repair_metal.
"materials": [ // What materials can be repaired by this item. Materials.json defines what item is consumed when repairing items of that material.
"cotton",
"leather",
"nylon",
"wool",
"fur",
"faux_fur",
"nomex",
"kevlar",
"neoprene",
"gutskin"
],
"skill": "tailor", // What skill determines chance of success vs. risk of damaging the item further.
"tool_quality": 3, // Bonus from tool, 1.<X> times multiplier on skill. With 8 Dex, 10 skill plus 2 or more tool_quality allows any item in the game to be fully reinforced.
"cost_scaling": 0.1, // Reduces or increases how much raw material is needed per successful repair action, also affected by the item's volume.
"move_cost": 800 // How long between each roll for success or failure, 100 moves is 1 turn.
}
},
"use_action": {
"type": "sew_advanced", // Modify clothing
"materials": [ // materials to deal with.
Expand Down
19 changes: 6 additions & 13 deletions src/iuse_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3295,8 +3295,8 @@ std::pair<float, float> repair_item_actor::repair_chance(
action_difficulty = fix.max_damage() / itype::damage_scale;
break;
case RT_REINFORCE:
// Reinforcing is at least as hard as refitting
action_difficulty = std::max( fix.max_damage() / itype::damage_scale, recipe_difficulty );
// Reinforcing is 50% harder than refitting
action_difficulty = ( fix.max_damage() / itype::damage_scale ) + 2;
break;
case RT_PRACTICE:
// Skill gain scales with recipe difficulty, so practice difficulty should too
Expand All @@ -3306,18 +3306,11 @@ std::pair<float, float> repair_item_actor::repair_chance(
}

const int difficulty = recipe_difficulty + action_difficulty;
// Sample numbers:
// Item | Damage | Skill | Dex | Success | Failure
// Hoodie | 2 | 3 | 10 | 6% | 0%
// Hazmat | 1 | 10 | 10 | 8% | 0%
// Hazmat | 1 | 5 | 20 | 0% | 2%
// t-shirt| 4 | 1 | 5 | 2% | 3%
// Duster | 2 | 5 | 5 | 10% | 0%
// Duster | 2 | 2 | 10 | 4% | 1%
// Duster | Refit | 2 | 10 | 0% | N/A
float success_chance = ( 10 + 2 * skill - 2 * difficulty + tool_quality / 5.0f ) / 100.0f;
float success_chance = ( 10 + 2 * ( skill * ( 1 + tool_quality / 10.0f ) ) - 2 * difficulty ) /
100.0f;
/** @EFFECT_DEX reduces the chances of damaging an item when repairing */
float damage_chance = ( difficulty - skill - ( tool_quality + pl.dex_cur ) / 5.0f ) / 100.0f;
float damage_chance = ( difficulty - ( skill * ( 1 + tool_quality / 10.0f ) ) - pl.dex_cur /
5.0f ) / 100.0f;

damage_chance = std::max( 0.0f, std::min( 1.0f, damage_chance ) );
success_chance = std::max( 0.0f, std::min( 1.0f - damage_chance, success_chance ) );
Expand Down

0 comments on commit faa472c

Please sign in to comment.