Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tools that use UPS conversion mods #31766

Merged
merged 6 commits into from
Jun 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions src/iuse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2198,7 +2198,7 @@ int iuse::water_purifier( player *p, item *it, bool, const tripoint & )

int iuse::radio_off( player *p, item *it, bool, const tripoint & )
{
if( !it->ammo_sufficient() ) {
if( !it->units_sufficient( *p ) ) {
p->add_msg_if_player( _( "It's dead." ) );
} else {
p->add_msg_if_player( _( "You turn the radio on." ) );
Expand Down Expand Up @@ -2321,7 +2321,7 @@ int iuse::radio_on( player *p, item *it, bool t, const tripoint &pos )

int iuse::noise_emitter_off( player *p, item *it, bool, const tripoint & )
{
if( !it->ammo_sufficient() ) {
if( !it->units_sufficient( *p ) ) {
p->add_msg_if_player( _( "It's dead." ) );
} else {
p->add_msg_if_player( _( "You turn the noise emitter on." ) );
Expand Down Expand Up @@ -3895,7 +3895,7 @@ int iuse::portal( player *p, item *it, bool, const tripoint & )

int iuse::tazer( player *p, item *it, bool, const tripoint &pos )
{
if( !it->ammo_sufficient() ) {
if( !it->units_sufficient( *p ) ) {
return 0;
}

Expand Down Expand Up @@ -3988,7 +3988,7 @@ int iuse::shocktonfa_off( player *p, item *it, bool t, const tripoint &pos )
return iuse::tazer2( p, it, t, pos );
}
case 1: {
if( !it->ammo_sufficient() ) {
if( !it->units_sufficient( *p ) ) {
p->add_msg_if_player( m_info, _( "The batteries are dead." ) );
return 0;
} else {
Expand All @@ -4006,7 +4006,7 @@ int iuse::shocktonfa_on( player *p, item *it, bool t, const tripoint &pos )
if( t ) { // Effects while simply on

} else {
if( !it->ammo_sufficient() ) {
if( !it->units_sufficient( *p ) ) {
p->add_msg_if_player( m_info, _( "Your tactical tonfa is out of power." ) );
it->convert( "shocktonfa_off" ).active = false;
} else {
Expand All @@ -4030,7 +4030,7 @@ int iuse::shocktonfa_on( player *p, item *it, bool t, const tripoint &pos )

int iuse::mp3( player *p, item *it, bool, const tripoint & )
{
if( !it->ammo_sufficient() ) {
if( !it->units_sufficient( *p ) ) {
p->add_msg_if_player( m_info, _( "The device's batteries are dead." ) );
} else if( p->has_active_item( "mp3_on" ) || p->has_active_item( "smartphone_music" ) ) {
p->add_msg_if_player( m_info, _( "You are already listening to music!" ) );
Expand Down Expand Up @@ -4425,7 +4425,7 @@ int iuse::vibe( player *p, item *it, bool, const tripoint & )
p->add_msg_if_player( m_info, _( "It's waterproof, but oxygen maybe?" ) );
return 0;
}
if( !it->ammo_sufficient() ) {
if( !it->units_sufficient( *p ) ) {
p->add_msg_if_player( m_info, _( "The %s's batteries are dead." ), it->tname() );
return 0;
}
Expand Down Expand Up @@ -5356,7 +5356,7 @@ int iuse::heat_food( player *p, item *it, bool, const tripoint & )

int iuse::hotplate( player *p, item *it, bool, const tripoint & )
{
if( it->typeId() != "atomic_coffeepot" && ( !it->ammo_sufficient() ) ) {
if( it->typeId() != "atomic_coffeepot" && ( !it->units_sufficient( *p )) ) {
p->add_msg_if_player( m_info, _( "The %s's batteries are dead." ), it->tname() );
return 0;
}
Expand Down Expand Up @@ -5566,7 +5566,7 @@ int iuse::radglove( player *p, item *it, bool, const tripoint & )
p->add_msg_if_player( m_info,
_( "You must wear the radiation biomonitor before you can activate it." ) );
return 0;
} else if( !it->ammo_sufficient() ) {
} else if( !it->units_sufficient( *p ) ) {
p->add_msg_if_player( m_info, _( "The radiation biomonitor needs batteries to function." ) );
return 0;
} else {
Expand Down Expand Up @@ -5620,7 +5620,7 @@ int iuse::contacts( player *p, item *it, bool, const tripoint & )

int iuse::talking_doll( player *p, item *it, bool, const tripoint & )
{
if( !it->ammo_sufficient() ) {
if( !it->units_sufficient( *p ) ) {
p->add_msg_if_player( m_info, _( "The %s's batteries are dead." ), it->tname() );
return 0;
}
Expand Down Expand Up @@ -5887,7 +5887,7 @@ bool iuse::robotcontrol_can_target( player *p, const monster &m )

int iuse::robotcontrol( player *p, item *it, bool, const tripoint & )
{
if( !it->ammo_sufficient() ) {
if( !it->units_sufficient( *p ) ) {
p->add_msg_if_player( _( "The %s's batteries are dead." ), it->tname() );
return 0;

Expand Down Expand Up @@ -7864,7 +7864,7 @@ static void sendRadioSignal( player &p, const std::string &signal )
int iuse::radiocontrol( player *p, item *it, bool t, const tripoint & )
{
if( t ) {
if( !it->ammo_sufficient() ) {
if( !it->units_sufficient( *p ) ) {
it->active = false;
p->remove_value( "remote_controlling" );
} else if( p->get_value( "remote_controlling" ).empty() ) {
Expand Down Expand Up @@ -8043,7 +8043,7 @@ int iuse::remoteveh( player *p, item *it, bool t, const tripoint &pos )
vehicle *remote = g->remoteveh();
if( t ) {
bool stop = false;
if( !it->ammo_sufficient() ) {
if( !it->units_sufficient( *p ) ) {
p->add_msg_if_player( m_bad, _( "The remote control's battery goes dead." ) );
stop = true;
} else if( remote == nullptr ) {
Expand Down Expand Up @@ -8178,7 +8178,7 @@ int iuse::multicooker( player *p, item *it, bool t, const tripoint &pos )
static const int charges_to_start = 50;

if( t ) {
if( !it->ammo_sufficient() ) {
if( !it->units_sufficient( *p ) ) {
it->active = false;
return 0;
}
Expand Down
6 changes: 3 additions & 3 deletions src/iuse_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ int iuse_transform::use( player &p, item &it, bool t, const tripoint &pos ) cons
p.add_msg_if_player( m_info, _( "You need to wear the %1$s before activating it." ), it.tname() );
return 0;
}
if( need_charges && it.ammo_remaining() < need_charges ) {
if( need_charges && it.units_remaining( p ) < need_charges ) {
if( possess ) {
p.add_msg_if_player( m_info, need_charges_msg, it.tname() );
}
Expand Down Expand Up @@ -1718,7 +1718,7 @@ ret_val<bool> cauterize_actor::can_use( const player &p, const item &it, bool,
_( "You need a source of flame (4 charges worth) before you can cauterize yourself." ) );
}
} else {
if( !it.ammo_sufficient() ) {
if( !it.units_sufficient( p ) ) {
return ret_val<bool>::make_failure( _( "You need at least %d charges to cauterize wounds." ),
it.ammo_required() );
}
Expand Down Expand Up @@ -2740,7 +2740,7 @@ bool repair_item_actor::can_use_tool( const player &p, const item &tool, bool pr
}
return false;
}
if( !tool.ammo_sufficient() ) {
if( !tool.units_sufficient( p ) ) {
if( print_msg ) {
p.add_msg_if_player( m_info, _( "Your tool does not have enough charges to do that." ) );
}
Expand Down