Skip to content

Commit 78572b4

Browse files
authored
Mech updates part 3: grabbing furniture and wielding items (cataclysmbn#2833)
* Mech Update part 3 * Almost forgot the stylin' * Update grab.cpp
1 parent 588ea97 commit 78572b4

File tree

7 files changed

+40
-15
lines changed

7 files changed

+40
-15
lines changed

data/json/monsters/mechsuits.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
"id": "mon_mech_lifter",
103103
"type": "MONSTER",
104104
"name": { "str": "X-01: 'Jack' Lifting Mech" },
105-
"description": "The Boeing-Daewoo LMES (Lifting Mechanical Exoskeleton Suit), a recent acquisition by the US military, it was designed to be piloted by an operator to load and unload heavy material, and for limited combat support roles, it was not deployed before the Cataclysm hit, though there were a few prototypes in the field. You may be able to hack it to accept you as its pilot. Like all mech-suits it can act as a UPS from its large battery.",
105+
"description": "The Boeing-Daewoo LMES (Lifting Mechanical Exoskeleton Suit), a recent acquisition by the US military, it was designed to be piloted by an operator to load and unload heavy material, and for limited combat support roles, it was not deployed before the Cataclysm hit, though there were a few prototypes in the field. It lacks any integral weaponry, but the user can fire from the open cockpit, even using the frame to support heavier firearms. You may be able to hack it to accept you as its pilot. Like all mech-suits it can act as a UPS from its large battery.",
106106
"default_faction": "mech_bot",
107107
"species": [ "ROBOT" ],
108108
"diff": 5,

src/character.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3116,10 +3116,6 @@ ret_val<bool> Character::can_wield( const item &it ) const
31163116
it.tname() );
31173117
}
31183118
}
3119-
if( is_mounted() && mount->has_flag( MF_RIDEABLE_MECH ) &&
3120-
mount->type->mech_weapon && it.typeId() != mount->type->mech_weapon ) {
3121-
return ret_val<bool>::make_failure( _( "You cannot wield anything while piloting a mech." ) );
3122-
}
31233119

31243120
return ret_val<bool>::make_success();
31253121
}

src/game.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9584,14 +9584,21 @@ bool game::grabbed_furn_move( const tripoint &dp )
95849584
furniture_contents_weight += contained_item.weight();
95859585
}
95869586
str_req += furniture_contents_weight / 4_kilogram;
9587+
int adjusted_str = u.get_str();
9588+
if( u.is_mounted() ) {
9589+
auto mons = u.mounted_creature.get();
9590+
if( mons->has_flag( MF_RIDEABLE_MECH ) && mons->mech_str_addition() != 0 ) {
9591+
adjusted_str = mons->mech_str_addition();
9592+
}
9593+
}
95879594
if( !canmove ) {
95889595
// TODO: What is something?
95899596
add_msg( _( "The %s collides with something." ), furntype.name() );
95909597
u.moves -= 50;
95919598
return true;
95929599
///\EFFECT_STR determines ability to drag furniture
9593-
} else if( str_req > u.get_str() &&
9594-
one_in( std::max( 20 - str_req - u.get_str(), 2 ) ) ) {
9600+
} else if( str_req > adjusted_str &&
9601+
one_in( std::max( 20 - str_req - adjusted_str, 2 ) ) ) {
95959602
add_msg( m_bad, _( "You strain yourself trying to move the heavy %s!" ),
95969603
furntype.name() );
95979604
u.moves -= 100;
@@ -9605,10 +9612,10 @@ bool game::grabbed_furn_move( const tripoint &dp )
96059612

96069613
u.moves -= str_req * 10;
96079614
// Additional penalty if we can't comfortably move it.
9608-
if( str_req > u.get_str() ) {
9615+
if( str_req > adjusted_str ) {
96099616
int move_penalty = std::pow( str_req, 2.0 ) + 100.0;
96109617
if( move_penalty <= 1000 ) {
9611-
if( u.get_str() >= str_req - 3 ) {
9618+
if( adjusted_str >= str_req - 3 ) {
96129619
u.moves -= std::max( 3000, move_penalty * 10 );
96139620
add_msg( m_bad, _( "The %s is really heavy!" ), furntype.name() );
96149621
if( one_in( 3 ) ) {

src/grab.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "map.h"
1111
#include "messages.h"
1212
#include "monster.h"
13+
#include "mtype.h"
1314
#include "point.h"
1415
#include "sounds.h"
1516
#include "vehicle.h"
@@ -154,7 +155,13 @@ bool game::grabbed_veh_move( const tripoint &dp )
154155
// for smaller vehicles, offroad_str_req_cap sanity-checks our results.
155156
int str_req = std::min( get_vehicle_str_requirement( grabbed_vehicle ),
156157
offroad_str_req_cap( grabbed_vehicle ) );
157-
const int str = u.get_str();
158+
int str = u.get_str();
159+
if( u.is_mounted() ) {
160+
auto mons = u.mounted_creature.get();
161+
if( mons->has_flag( MF_RIDEABLE_MECH ) && mons->mech_str_addition() != 0 ) {
162+
str = mons->mech_str_addition();
163+
}
164+
}
158165
add_msg( m_debug, "str_req: %d", str_req );
159166

160167
//final strength check and outcomes

src/handle_action.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1940,7 +1940,16 @@ bool game::handle_action()
19401940
if( u.has_active_mutation( trait_SHELL2 ) ) {
19411941
add_msg( m_info, _( "You can't grab things while you're in your shell." ) );
19421942
} else if( u.is_mounted() ) {
1943-
add_msg( m_info, _( "You can't grab things while you're riding." ) );
1943+
auto mon = u.mounted_creature.get();
1944+
if( !mon->has_flag( MF_RIDEABLE_MECH ) ) {
1945+
add_msg( m_info, _( "You can't grab things while you're riding." ) );
1946+
break;
1947+
} else if( !mon->type->mech_weapon.is_empty() ) {
1948+
add_msg( m_info, _( "Your mech doesn't have hands to grab with." ) );
1949+
break;
1950+
} else {
1951+
grab();
1952+
}
19441953
} else {
19451954
grab();
19461955
}

src/monexamine.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,10 +225,10 @@ bool monexamine::pet_menu( monster &z )
225225
}
226226
amenu.addentry( check_bat, false, 'c', _( "%s battery level is %d%%" ), z.get_name(),
227227
static_cast<int>( charge_percent ) );
228-
if( you.primary_weapon().is_null() && z.battery_item ) {
228+
if( ( you.primary_weapon().is_null() || z.type->mech_weapon.is_empty() ) && z.battery_item ) {
229229
amenu.addentry( mount, true, 'r', _( "Climb into the mech and take control" ) );
230-
} else if( !you.primary_weapon().is_null() ) {
231-
amenu.addentry( mount, false, 'r', _( "You cannot pilot the mech whilst wielding something" ) );
230+
} else if( !you.primary_weapon().is_null() && !z.type->mech_weapon.is_empty() ) {
231+
amenu.addentry( mount, false, 'r', _( "You cannot pilot this mech whilst wielding something" ) );
232232
} else if( !z.battery_item ) {
233233
amenu.addentry( mount, false, 'r', _( "This mech has a dead battery and won't turn on" ) );
234234
}

src/ranged.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3782,10 +3782,16 @@ bool ranged::gunmode_checks_weapon( avatar &you, const map &m, std::vector<std::
37823782
}
37833783

37843784
if( gmode->has_flag( flag_MOUNTED_GUN ) ) {
3785+
3786+
bool mech_mount = false;
3787+
if( you.is_mounted() && you.mounted_creature->has_flag( MF_RIDEABLE_MECH ) ) {
3788+
mech_mount = true;
3789+
}
3790+
37853791
const bool v_mountable = static_cast<bool>( m.veh_at( you.pos() ).part_with_feature( "MOUNTABLE",
37863792
true ) );
37873793
bool t_mountable = m.has_flag_ter_or_furn( flag_MOUNTABLE, you.pos() );
3788-
if( !t_mountable && !v_mountable && !( you.get_size() > MS_MEDIUM ) ) {
3794+
if( !mech_mount && !t_mountable && !v_mountable && !( you.get_size() > MS_MEDIUM ) ) {
37893795
messages.push_back( string_format(
37903796
_( "You must stand near acceptable terrain or furniture to fire the %s. A table, a mound of dirt, a broken window, etc." ),
37913797
gmode->tname() ) );

0 commit comments

Comments
 (0)