Skip to content

Commit

Permalink
Optional worldmod to disable lifting requirements (strength and lifti…
Browse files Browse the repository at this point in the history
…ng quality) (#42)

* Initial implementation of mod

Based on previous attempt:
CleverRaven/Cataclysm-DDA#24053

* Astyle modinfo.json

* do not check aid or strength when installing parts

* Astyling

* Do not display lifting and strength requirements if disabled

Happy to remove the string if needed

* No string for disabled requirements

Might require further investigation into the display of 'Additional Requirements'

* Json Styling

Windows defender was preventing make style-json from running correctly

* Only display additional requirements if they exist

* Show jacking when required, remove irrelevant calculations

* Astyle
  • Loading branch information
Coolthulhu authored Sep 3, 2020
2 parents 62da310 + f87fc98 commit 125d49d
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 33 deletions.
15 changes: 15 additions & 0 deletions data/mods/No_Lift_Requirements/modinfo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[
{
"type": "MOD_INFO",
"ident": "disable_lifting",
"name": "No Lifting Reqs",
"authors": "Wad67",
"description": "Strength checks and lifting qualities are no longer required for installing or removing vehicle parts.",
"category": "rebalance",
"dependencies": [ "dda" ]
},
{
"type": "WORLD_OPTION",
"options": [ "DISABLE_LIFTING" ]
}
]
6 changes: 6 additions & 0 deletions src/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2168,6 +2168,12 @@ void options_manager::add_options_world_default()
{ { "any", translate_marker( "Any" ) }, { "multi_pool", translate_marker( "Multi-pool only" ) }, { "no_freeform", translate_marker( "No freeform" ) } },
"any"
);

add( "DISABLE_LIFTING", "world_default",
translate_marker( "Disables lifting requirements for vehicle parts." ),
translate_marker( "If true, strength checks and/or lifting qualities no longer need to be met in order to change parts." ),
false, COPT_ALWAYS_HIDE
);
}

void options_manager::add_options_android()
Expand Down
93 changes: 60 additions & 33 deletions src/veh_interact.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "monster.h"
#include "npc.h"
#include "optional.h"
#include "options.h"
#include "output.h"
#include "overmapbuffer.h"
#include "pimpl.h"
Expand Down Expand Up @@ -733,26 +734,27 @@ bool veh_interact::can_install_part()
bool ok = format_reqs( msg, reqs, sel_vpart_info->install_skills,
sel_vpart_info->install_time( g->u ) );

msg += _( "<color_white>Additional requirements:</color>\n" );
std::string additional_requirements;
bool lifting_or_jacking_required = false;

if( dif_eng > 0 ) {
if( g->u.get_skill_level( skill_mechanics ) < dif_eng ) {
ok = false;
}
//~ %1$s represents the internal color name which shouldn't be translated, %2$s is skill name, and %3$i is skill level
msg += string_format( _( "> %1$s%2$s %3$i</color> for extra engines." ),
status_color( g->u.get_skill_level( skill_mechanics ) >= dif_eng ),
skill_mechanics.obj().name(), dif_eng ) + "\n";
additional_requirements += string_format( _( "> %1$s%2$s %3$i</color> for extra engines." ),
status_color( g->u.get_skill_level( skill_mechanics ) >= dif_eng ),
skill_mechanics.obj().name(), dif_eng ) + "\n";
}

if( dif_steering > 0 ) {
if( g->u.get_skill_level( skill_mechanics ) < dif_steering ) {
ok = false;
}
//~ %1$s represents the internal color name which shouldn't be translated, %2$s is skill name, and %3$i is skill level
msg += string_format( _( "> %1$s%2$s %3$i</color> for extra steering axles." ),
status_color( g->u.get_skill_level( skill_mechanics ) >= dif_steering ),
skill_mechanics.obj().name(), dif_steering ) + "\n";
additional_requirements += string_format( _( "> %1$s%2$s %3$i</color> for extra steering axles." ),
status_color( g->u.get_skill_level( skill_mechanics ) >= dif_steering ),
skill_mechanics.obj().name(), dif_steering ) + "\n";
}

int lvl = 0;
Expand All @@ -762,12 +764,17 @@ bool veh_interact::can_install_part()
bool use_str = false;
item base( sel_vpart_info->item );
if( sel_vpart_info->has_flag( "NEEDS_JACKING" ) ) {
lifting_or_jacking_required = true;
qual = qual_JACK;
lvl = jack_quality( *veh );
str = veh->lift_strength();
use_aid = ( max_jack >= lvl ) || can_self_jack();
use_str = g->u.can_lift( *veh );
} else if( get_option<bool>( "DISABLE_LIFTING" ) ) {
use_aid = true;
use_str = true;
} else {
lifting_or_jacking_required = true;
qual = qual_LIFT;
lvl = std::ceil( units::quantity<double, units::mass::unit_type>( base.weight() ) /
TOOL_LIFT_FACTOR );
Expand All @@ -785,17 +792,24 @@ bool veh_interact::can_install_part()

const auto helpers = g->u.get_crafting_helpers();
std::string str_string;
if( !helpers.empty() ) {
str_string = string_format( _( "strength ( assisted ) %d" ), str );
} else {
str_string = string_format( _( "strength %d" ), str );
if( lifting_or_jacking_required ) {
if( !helpers.empty() ) {
str_string = string_format( _( "strength ( assisted ) %d" ), str );
} else {
str_string = string_format( _( "strength %d" ), str );
}

//~ %1$s is quality name, %2$d is quality level
std::string aid_string = string_format( _( "1 tool with %1$s %2$d" ),
qual.obj().name, lvl );
additional_requirements += string_format( _( "> %1$s <color_white>OR</color> %2$s" ),
colorize( aid_string, aid_color ),
colorize( str_string, str_color ) ) + "\n";
}
if( !additional_requirements.empty() ) {
msg += _( "<color_white>Additional requirements:</color>\n" );
msg += additional_requirements;
}
//~ %1$s is quality name, %2$d is quality level
std::string aid_string = string_format( _( "1 tool with %1$s %2$d" ),
qual.obj().name, lvl );
msg += string_format( _( "> %1$s <color_white>OR</color> %2$s" ),
colorize( aid_string, aid_color ),
colorize( str_string, str_color ) ) + "\n";

sel_vpart_info->format_description( msg, c_light_gray, getmaxx( w_msg ) - 4 );

Expand Down Expand Up @@ -1725,8 +1739,8 @@ bool veh_interact::can_remove_part( int idx, const player &p )
const auto reqs = sel_vpart_info->removal_requirements();
bool ok = format_reqs( msg, reqs, sel_vpart_info->removal_skills,
sel_vpart_info->removal_time( p ) );

msg += _( "<color_white>Additional requirements:</color>\n" );
std::string additional_requirements;
bool lifting_or_jacking_required = false;

int lvl = 0;
int str = 0;
Expand All @@ -1735,12 +1749,17 @@ bool veh_interact::can_remove_part( int idx, const player &p )
bool use_str = false;
item base( sel_vpart_info->item );
if( sel_vpart_info->has_flag( "NEEDS_JACKING" ) ) {
lifting_or_jacking_required = true;
qual = qual_JACK;
lvl = jack_quality( *veh );
str = veh->lift_strength();
use_aid = ( max_jack >= lvl ) || can_self_jack();
use_str = g->u.can_lift( *veh );
} else {
} else if( get_option<bool>( "DISABLE_LIFTING" ) ) {
use_aid = true;
use_str = true;
} else {
lifting_or_jacking_required = true;
qual = qual_LIFT;
lvl = std::ceil( units::quantity<double, units::mass::unit_type>( base.weight() ) /
TOOL_LIFT_FACTOR );
Expand All @@ -1753,24 +1772,32 @@ bool veh_interact::can_remove_part( int idx, const player &p )
ok = false;
}
const auto helpers = g->u.get_crafting_helpers();
if( !helpers.empty() ) {
msg += string_format(
//~ %1$s represents the internal color name which shouldn't be translated, %2$s is the tool quality, %3$i is tool level, %4$s is the internal color name which shouldn't be translated and %5$i is the character's strength
_( "> %1$s1 tool with %2$s %3$i</color> <color_white>OR</color> %4$sstrength ( assisted ) %5$i</color>" ),
status_color( use_aid ), qual.obj().name, lvl,
status_color( use_str ), str ) + "\n";
} else {
msg += string_format(
//~ %1$s represents the internal color name which shouldn't be translated, %2$s is the tool quality, %3$i is tool level, %4$s is the internal color name which shouldn't be translated and %5$i is the character's strength
_( "> %1$s1 tool with %2$s %3$i</color> <color_white>OR</color> %4$sstrength %5$i</color>" ),
status_color( use_aid ), qual.obj().name, lvl,
status_color( use_str ), str ) + "\n";
if( lifting_or_jacking_required ) {
if( !helpers.empty() ) {
additional_requirements += string_format(
//~ %1$s represents the internal color name which shouldn't be translated, %2$s is the tool quality, %3$i is tool level, %4$s is the internal color name which shouldn't be translated and %5$i is the character's strength
_( "> %1$s1 tool with %2$s %3$i</color> <color_white>OR</color> %4$sstrength ( assisted ) %5$i</color>" ),
status_color( use_aid ), qual.obj().name, lvl,
status_color( use_str ), str ) + "\n";
} else {
additional_requirements += string_format(
//~ %1$s represents the internal color name which shouldn't be translated, %2$s is the tool quality, %3$i is tool level, %4$s is the internal color name which shouldn't be translated and %5$i is the character's strength
_( "> %1$s1 tool with %2$s %3$i</color> <color_white>OR</color> %4$sstrength %5$i</color>" ),
status_color( use_aid ), qual.obj().name, lvl,
status_color( use_str ), str ) + "\n";
}
}
std::string reason;
if( !veh->can_unmount( idx, reason ) ) {
//~ %1$s represents the internal color name which shouldn't be translated, %2$s is pre-translated reason
msg += string_format( _( "> %1$s%2$s</color>" ), status_color( false ), reason ) + "\n";
additional_requirements += string_format( _( "> %1$s%2$s</color>" ), status_color( false ),
reason ) + "\n";
ok = false;

}
if( !additional_requirements.empty() ) {
msg += _( "<color_white>Additional requirements:</color>\n" );
msg += additional_requirements;
}
const nc_color desc_color = sel_vehicle_part->is_broken() ? c_dark_gray : c_light_gray;
sel_vehicle_part->info().format_description( msg, desc_color, getmaxx( w_msg ) - 4 );
Expand Down

0 comments on commit 125d49d

Please sign in to comment.