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: power armor actually benefits from advanced UPS efficiency, adjust efficiency ratio #4842

Merged
merged 8 commits into from
Jun 20, 2024
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
2 changes: 1 addition & 1 deletion src/bionics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1475,7 +1475,7 @@ int Character::consume_remote_fuel( int amount )
use_charges( itype_UPS_off, unconsumed_amount, used_ups );
unconsumed_amount -= 1;
} else if( has_charges( itype_adv_UPS_off, unconsumed_amount, used_ups ) ) {
use_charges( itype_adv_UPS_off, roll_remainder( unconsumed_amount * 0.6 ), used_ups );
use_charges( itype_adv_UPS_off, roll_remainder( unconsumed_amount * 0.5 ), used_ups );
unconsumed_amount -= 1;
}
}
Expand Down
9 changes: 6 additions & 3 deletions src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10238,12 +10238,15 @@ std::vector<detached_ptr<item>> Character::use_charges( const itype_id &what, in
qty -= std::min( qty, bio );
}

int adv = charges_of( itype_adv_UPS_off, static_cast<int>( std::ceil( qty * 0.6 ) ) );
int adv = charges_of( itype_adv_UPS_off, static_cast<int>( std::ceil( qty * 0.5 ) ) );
if( adv > 0 ) {
std::vector<detached_ptr<item>> found = use_charges( itype_adv_UPS_off, adv );
int adv_odd = x_in_y( qty % 2, 2 );
// qty % 2 returns 1 if odd and 0 if even, giving a 50% chance of consuming one less charge if odd, 0 otherwise.
// (eg: if 5, consumes either 2 or 3)
std::vector<detached_ptr<item>> found = use_charges( itype_adv_UPS_off, adv - adv_odd );
res.insert( res.end(), std::make_move_iterator( found.begin() ),
std::make_move_iterator( found.end() ) );
qty -= std::min( qty, static_cast<int>( adv / 0.6 ) );
qty -= std::min( qty, static_cast<int>( adv / 0.5 ) );
}

int ups = charges_of( itype_UPS_off, qty );
Expand Down
4 changes: 2 additions & 2 deletions src/character_turn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,7 @@ void Character::process_items()
if( identifier == itype_UPS_off ) {
ch_UPS += it.ammo_remaining();
} else if( identifier == itype_adv_UPS_off ) {
ch_UPS += it.ammo_remaining() / 0.6;
ch_UPS += it.ammo_remaining() / 0.5;
}
if( it.has_flag( flag_USE_UPS ) && it.charges < it.type->maximum_charges() ) {
active_held_items.push_back( index );
Expand All @@ -891,7 +891,7 @@ void Character::process_items()
if( identifier == itype_UPS_off ) {
ch_UPS += w->ammo_remaining();
} else if( identifier == itype_adv_UPS_off ) {
ch_UPS += w->ammo_remaining() / 0.6;
ch_UPS += w->ammo_remaining() / 0.5;
}
if( !update_required && w->encumbrance_update_ ) {
update_required = true;
Expand Down
2 changes: 1 addition & 1 deletion src/ranged.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3781,7 +3781,7 @@ auto ranged::gunmode_checks_weapon( avatar &you, const map &m, std::vector<std::

if( gmode->get_gun_ups_drain() > 0 ) {
const int ups_drain = gmode->get_gun_ups_drain();
const int adv_ups_drain = std::max( 1, ups_drain * 3 / 5 );
const int adv_ups_drain = std::max( 1, ups_drain / 2 );
bool is_mech_weapon = false;
if( you.is_mounted() ) {
monster *mons = get_player_character().mounted_creature.get();
Expand Down
4 changes: 2 additions & 2 deletions src/visitable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,7 @@ int visitable<inventory>::charges_of( const itype_id &what, int limit,
if( what == itype_UPS ) {
int qty = 0;
qty = sum_no_wrap( qty, charges_of( itype_UPS_off ) );
qty = sum_no_wrap( qty, static_cast<int>( charges_of( itype_adv_UPS_off ) / 0.6 ) );
qty = sum_no_wrap( qty, static_cast<int>( charges_of( itype_adv_UPS_off ) / 0.5 ) );
return std::min( qty, limit );
}
const auto &binned = static_cast<const inventory *>( this )->get_binned_items();
Expand Down Expand Up @@ -1074,7 +1074,7 @@ int visitable<Character>::charges_of( const itype_id &what, int limit,
if( what == itype_UPS ) {
int qty = 0;
qty = sum_no_wrap( qty, charges_of( itype_UPS_off ) );
qty = sum_no_wrap( qty, static_cast<int>( charges_of( itype_adv_UPS_off ) / 0.6 ) );
qty = sum_no_wrap( qty, static_cast<int>( charges_of( itype_adv_UPS_off ) / 0.5 ) );
if( p && p->has_active_bionic( bio_ups ) ) {
qty = sum_no_wrap( qty, units::to_kilojoule( p->get_power_level() ) );
}
Expand Down
Loading