Skip to content

Commit

Permalink
fix gun cleaning redundancy (#36060)
Browse files Browse the repository at this point in the history
  • Loading branch information
misterprimus authored and kevingranade committed Dec 13, 2019
1 parent e85b7a7 commit 8380bc8
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 0 deletions.
2 changes: 2 additions & 0 deletions data/json/items/gun/faults_gun.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"success_msg": "You clean and lubricate your %s.",
"time": "55 m",
"skills": [ { "id": "mechanics", "level": 1 } ],
"also_mends": "fault_gun_unlubricated",
"requirements": {
"qualities": [ { "id": "SCREW", "level": 1 } ],
"tools": [ [ [ "pipe_cleaner", -1 ], [ "small_repairkit", -1 ], [ "large_repairkit", -1 ] ] ],
Expand Down Expand Up @@ -134,6 +135,7 @@
"success_msg": "You clean and lubricate your %s.",
"time": "55 m",
"skills": [ { "id": "mechanics", "level": 1 } ],
"also_mends": "fault_gun_unlubricated",
"requirements": {
"qualities": [ { "id": "SCREW", "level": 1 } ],
"tools": [ [ [ "pipe_cleaner", -1 ], [ "small_repairkit", -1 ], [ "large_repairkit", -1 ] ] ],
Expand Down
14 changes: 14 additions & 0 deletions doc/JSON_FLAGS.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
+ [Flags](#flags-3)
* [Guns](#guns)
+ [Firing modes](#firing-modes)
+ [Faults](#faults)
- [Flags](#flags)
- [Parameters](#parameters)
* [Magazines](#magazines)
* [MAP SPECIALS](#map-specials)
* [Material Phases](#material-phases)
Expand Down Expand Up @@ -714,6 +717,17 @@ List of known flags, used in both `terrain.json` and `furniture.json`.
- ```NPC_AVOID``` NPC's will not attempt to use this mode
- ```SIMULTANEOUS``` All rounds fired concurrently (not sequentially) with recoil added only once (at the end)
### Faults
#### Flags
- ```SILENT``` Makes the "faulty " text NOT appear next to item on general UI. Otherwise the fault works the same.
#### Parameters
- ```turns_into``` Causes this fault to apply to the item just mended.
- ```also_mends``` Causes this fault to be mended (in addition to fault selected) once that fault is mended.
## Magazines
Expand Down
4 changes: 4 additions & 0 deletions src/activity_handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2582,6 +2582,10 @@ void activity_handlers::mend_item_finish( player_activity *act, player *p )
target->faults.erase( *f );
if( method->turns_into ) {
target->faults.emplace( *method->turns_into );
}
// also_mends removes not just the fault picked to be mended, but this as well.
if( method->also_mends ) {
target->faults.erase( *method->also_mends );
}
if( act->name == "fault_gun_blackpowder" || act->name == "fault_gun_dirt" ) {
target->set_var( "dirt", 0 );
Expand Down
5 changes: 5 additions & 0 deletions src/fault.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ void fault::load_fault( const JsonObject &jo )
}

optional( jo_method, false, "turns_into", m.turns_into, cata::nullopt );
optional( jo_method, false, "also_mends", m.also_mends, cata::nullopt );

f.mending_methods_.emplace( m.id, m );
}
Expand Down Expand Up @@ -116,6 +117,10 @@ void fault::check_consistency()
debugmsg( "fault %s has invalid turns_into fault id %s for mending method %s",
f.second.id_.str(), m.second.turns_into->str(), m.first );
}
if( m.second.also_mends && !m.second.also_mends->is_valid() ) {
debugmsg( "fault %s has invalid also_mends fault id %s for mending method %s",
f.second.id_.str(), m.second.also_mends->str(), m.first );
}
}
}
}
1 change: 1 addition & 0 deletions src/fault.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ struct mending_method {
std::map<skill_id, int> skills;
requirement_id requirements;
cata::optional<fault_id> turns_into;
cata::optional<fault_id> also_mends;
};

class fault
Expand Down
4 changes: 4 additions & 0 deletions src/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4509,6 +4509,10 @@ void player::mend_item( item_location &&obj, bool interactive )
descr << string_format( _( "Turns into: <color_cyan>%s</color>\n" ),
method.turns_into->obj().name() );
}
if( method.also_mends ) {
descr << string_format( _( "Also mends: <color_cyan>%s</color>\n" ),
method.also_mends->obj().name() );
}
descr << string_format( _( "Time required: <color_cyan>%s</color>\n" ),
to_string_approx( method.time ) );
if( method.skills.empty() ) {
Expand Down

0 comments on commit 8380bc8

Please sign in to comment.