Skip to content

Commit

Permalink
Add flags to prevent modification of vehicle parts
Browse files Browse the repository at this point in the history
  • Loading branch information
anothersimulacrum committed May 6, 2020
1 parent f530cda commit b85c65b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 15 deletions.
14 changes: 1 addition & 13 deletions data/json/vehicleparts/rotor.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"color": "light_blue",
"broken_symbol": "O",
"broken_color": "light_gray",
"flags": [ "ROTOR" ],
"flags": [ "ROTOR", "NO_INSTALL_PLAYER", "NO_UNINSTALL", "NO_REPAIR" ],
"description": "A set of aerofoil helicopter rotors, when spun at high speed, they generate thrust via lift."
},
{
Expand All @@ -18,12 +18,6 @@
"item": "heavy_duty_military_rotor",
"//": "rotor diameter is in meters",
"rotor_diameter": 15,
"//": "difficulty is artificially high to prevent homemade helicopters - for the moment",
"requirements": {
"install": { "skills": [ [ "mechanics", 30 ] ], "time": "2 h", "using": [ [ "welding_standard", 20 ] ] },
"removal": { "skills": [ [ "mechanics", 30 ] ], "time": "2 h", "using": [ [ "vehicle_weld_removal", 4 ] ] },
"repair": { "skills": [ [ "mechanics", 30 ] ], "time": "2 h", "using": [ [ "welding_standard", 20 ] ] }
},
"durability": 450,
"description": "A set of four military-grade helicopter rotor blades, used to provide lift by rotation.",
"damage_modifier": 80,
Expand All @@ -38,12 +32,6 @@
"item": "small_helicopter_rotor",
"//": "rotor diameter is in meters",
"rotor_diameter": 8,
"//": "difficulty is artificially high to prevent homemade helicopters - for the moment",
"requirements": {
"install": { "skills": [ [ "mechanics", 30 ] ], "time": "2 h", "using": [ [ "welding_standard", 20 ] ] },
"removal": { "skills": [ [ "mechanics", 30 ] ], "time": "2 h", "using": [ [ "vehicle_weld_removal", 4 ] ] },
"repair": { "skills": [ [ "mechanics", 30 ] ], "time": "2 h", "using": [ [ "welding_standard", 20 ] ] }
},
"durability": 100,
"description": "A set of four military-grade helicopter rotor blades, used to provide lift by rotation.",
"damage_modifier": 80,
Expand Down
3 changes: 3 additions & 0 deletions doc/JSON_FLAGS.md
Original file line number Diff line number Diff line change
Expand Up @@ -1384,6 +1384,9 @@ Those flags are added by the game code to specific items (that specific welder,
- ```NAILABLE``` Attached with nails
- ```NEEDS_BATTERY_MOUNT```
- ```NOINSTALL``` Cannot be installed.
- ```NO_INSTALL_PLAYER``` Cannot be installed by a player, but can be installed on vehicles.
- ```NO_UNINSTALL``` Cannot be unintalled
- ```NO_REPAIR``` Cannot be repaired
- ```NO_JACK```
- ```OBSTACLE``` Cannot walk through part, unless the part is also ```OPENABLE```.
- ```ODDTURN``` Only on during odd turns.
Expand Down
23 changes: 21 additions & 2 deletions src/veh_interact.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,15 @@ bool veh_interact::can_install_part()
if( is_drive_conflict() ) {
return false;
}
if( sel_vpart_info->has_flag( "NO_INSTALL_PLAYER" ) ) {
werase( w_msg );
// NOLINTNEXTLINE(cata-use-named-point-constants)
fold_and_print( w_msg, point( 1, 0 ), getmaxx( w_msg ) - 2, c_light_red,
_( "This part cannot be installed.\n" ) );
wrefresh( w_msg );
return false;
}

if( sel_vpart_info->has_flag( "FUNNEL" ) ) {
if( std::none_of( parts_here.begin(), parts_here.end(), [&]( const int e ) {
return veh->parts[e].is_tank();
Expand Down Expand Up @@ -1180,11 +1189,12 @@ bool veh_interact::do_repair( std::string &msg )
if( pt.is_broken() ) {
ok = format_reqs( nmsg, vp.install_requirements(), vp.install_skills, vp.install_time( g->u ) );
} else {
if( !vp.repair_requirements().is_empty() && pt.base.max_damage() > 0 ) {
if( !vp.has_flag( "NO_REPAIR" ) && !vp.repair_requirements().is_empty() &&
pt.base.max_damage() > 0 ) {
ok = format_reqs( nmsg, vp.repair_requirements() * pt.base.damage_level( 4 ), vp.repair_skills,
vp.repair_time( g->u ) * pt.base.damage() / pt.base.max_damage() );
} else {
nmsg += colorize( _( "This part cannot be repaired" ), c_light_red );
nmsg += colorize( _( "This part cannot be repaired.\n" ), c_light_red );
ok = false;
}
}
Expand Down Expand Up @@ -1718,6 +1728,15 @@ bool veh_interact::can_remove_part( int idx, const player &p )
sel_vpart_info = &sel_vehicle_part->info();
std::string msg;

if( sel_vpart_info->has_flag( "NO_UNINSTALL" ) ) {
werase( w_msg );
// NOLINTNEXTLINE(cata-use-named-point-constants)
fold_and_print( w_msg, point( 1, 0 ), getmaxx( w_msg ) - 2, c_light_red,
_( "This part cannot be uninstalled.\n" ) );
wrefresh( w_msg );
return false;
}

if( sel_vehicle_part->is_broken() ) {
msg += string_format(
_( "<color_white>Removing the broken %1$s may yield some fragments.</color>\n" ),
Expand Down

0 comments on commit b85c65b

Please sign in to comment.