Skip to content

Commit

Permalink
[Gear] Best-in-Slots, fix stat gain/loss functions
Browse files Browse the repository at this point in the history
  • Loading branch information
nyterage committed Jan 20, 2025
1 parent c7a400c commit d535c46
Showing 1 changed file with 30 additions and 6 deletions.
36 changes: 30 additions & 6 deletions engine/player/unique_gear_thewarwithin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7395,18 +7395,42 @@ void best_in_slots( special_effect_t& effect )

double randomize_stat_value()
{
return default_value * rng().range( range_min, range_max );
double val = default_value * rng().range( range_min, range_max );
for ( auto& buff_stat : stats )
{
double delta = val - buff_stat.current_value;
buff_stat.current_value = val;
buff_stat.amount = val;
if ( delta > 0 )
{
player->stat_gain( buff_stat.stat, delta, stat_gain, nullptr, buff_duration() > timespan_t::zero() );
}
else if ( delta < 0 )
{
player->stat_loss( buff_stat.stat, std::fabs( delta ), stat_gain, nullptr,
buff_duration() > timespan_t::zero() );
}
}
return val;
}

void start( int s, double, timespan_t d ) override
void bump( int stacks, double ) override
{
double val = randomize_stat_value();
stat_buff_t::start( s, val, d );
buff_t::bump( stacks, randomize_stat_value() );
}

void bump( int stacks, double ) override
void expire_override( int s, timespan_t d ) override
{
buff_t::bump( stacks, randomize_stat_value() );
for ( auto& buff_stat : stats )
{
player->stat_loss( buff_stat.stat, buff_stat.current_value, stat_gain, nullptr,
buff_duration() > timespan_t::zero() );

buff_stat.current_value = 0;
}

// Purposely skip over stat_buff_t::expire_override() as we do the lost stat calculations manually
buff_t::expire_override( s, d );
}
};

Expand Down

0 comments on commit d535c46

Please sign in to comment.