Skip to content

Commit 48ef800

Browse files
committed
[Gear] update ovinax's mercurial egg stat value calculation
no longer differs when increasing vs decreasing, but still off by +/-2 due to unknown bad rounding
1 parent bcdbcee commit 48ef800

File tree

1 file changed

+5
-33
lines changed

1 file changed

+5
-33
lines changed

engine/player/unique_gear_thewarwithin.cpp

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1562,46 +1562,27 @@ void ovinaxs_mercurial_egg( special_effect_t& effect )
15621562
{
15631563
double cap_mul;
15641564
int cap;
1565-
double original_amount;
15661565

15671566
ovinax_stat_buff_t( player_t* p, std::string_view n, const spell_data_t* s, const spell_data_t* data )
15681567
: stat_buff_t( p, n, s ),
15691568
cap_mul( 1.0 - data->effectN( 4 ).percent() ),
15701569
cap( as<int>( data->effectN( 5 ).base_value() ) )
15711570
{}
15721571

1573-
void reset() override
1574-
{
1575-
stat_buff_t::reset();
1576-
stats[ 0 ].amount = original_amount;
1577-
}
1578-
1579-
void _initialize()
1580-
{
1581-
// assume each buff has a single stat. refactor if this changes.
1582-
assert( stats.size() == 1 );
1583-
original_amount = stats[ 0 ].amount;
1584-
}
1585-
15861572
// values can be off by a +/-2 due to unknown rounding being performed by the in-game script
1587-
void recalculate_stat_amount( int stacks = 0 )
1573+
double buff_stat_stack_amount( const buff_stat_t& stat, int s ) const override
15881574
{
1589-
auto s = stacks ? stacks : check();
1590-
if ( !s )
1591-
return;
1592-
1593-
if ( s <= cap )
1594-
stats[ 0 ].amount = original_amount;
1595-
else
1596-
stats[ 0 ].amount = original_amount * ( cap + ( s - cap ) * cap_mul ) / s;
1575+
double val = std::max( 1.0, std::fabs( stat.amount ) );
1576+
double stack = s <= cap ? s : cap + ( s - cap ) * cap_mul;
1577+
// TODO: confirm truncation happens on final amount, and not per stack amount
1578+
return std::copysign( std::trunc( stack * val + 1e-3 ), stat.amount );
15971579
}
15981580
};
15991581

16001582
// setup stat buffs
16011583
auto primary = create_buff<ovinax_stat_buff_t>( effect.player, effect.player->find_spell( 449578 ), data );
16021584
primary->set_stat_from_effect_type( A_MOD_STAT, data->effectN( 1 ).average( effect ) )
16031585
->set_constant_behavior( buff_constant_behavior::NEVER_CONSTANT );
1604-
primary->_initialize();
16051586

16061587
static constexpr std::array<unsigned, 4> buff_ids = { 449595, 449594, 449581, 449593 };
16071588

@@ -1617,7 +1598,6 @@ void ovinaxs_mercurial_egg( special_effect_t& effect )
16171598
buff->set_stat_from_effect_type( A_MOD_RATING, data->effectN( 2 ).average( effect ) )
16181599
->set_name_reporting( stat_str )
16191600
->set_constant_behavior( buff_constant_behavior::NEVER_CONSTANT );
1620-
buff->_initialize();
16211601

16221602
secondaries[ secondary_ratings[ i ] ] = buff;
16231603
}
@@ -1633,12 +1613,6 @@ void ovinaxs_mercurial_egg( special_effect_t& effect )
16331613
if ( halt->check() )
16341614
return;
16351615

1636-
// recalculate stat amounts first before making stack adjustments. because recalculation changes the basic
1637-
// per-stack amount of the buff, this results in different post-adjustment total amounts depending if the stack is
1638-
// increasing or decreasing until the next tick.
1639-
primary->recalculate_stat_amount();
1640-
range::for_each( secondaries, []( const auto& b ) { b.second->recalculate_stat_amount(); } );
1641-
16421616
// if player is moving decrement stack. if player is above desired primary stack and not casting, assume player
16431617
// will sidestep to try to decrement.
16441618
auto desired = p->thewarwithin_opts.ovinaxs_mercurial_egg_desired_primary_stacks;
@@ -1686,14 +1660,12 @@ void ovinaxs_mercurial_egg( special_effect_t& effect )
16861660

16871661
if ( p_stacks )
16881662
{
1689-
primary->recalculate_stat_amount( p_stacks );
16901663
primary->trigger( p_stacks );
16911664
}
16921665

16931666
if ( s_stacks )
16941667
{
16951668
auto buff = secondaries.at( util::highest_stat( p, secondary_ratings ) );
1696-
buff->recalculate_stat_amount( s_stacks );
16971669
buff->trigger( s_stacks );
16981670
}
16991671

0 commit comments

Comments
 (0)