Skip to content

Commit

Permalink
[Player] use range( vector ) helper
Browse files Browse the repository at this point in the history
  • Loading branch information
gastank committed Sep 25, 2024
1 parent b8dfa96 commit bea2093
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
3 changes: 1 addition & 2 deletions engine/player/pet_spawner_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -705,8 +705,7 @@ T* pet_spawner_t<T, O>::replacement_pet()
case pet_replacement_strategy::REPLACE_OLDEST:
return active_pet_min_remains();
case pet_replacement_strategy::REPLACE_RANDOM:
return m_active_pets[ static_cast<unsigned>(
m_owner->rng().range( 0.0, as<double>( m_active_pets.size() ) ) ) ];
return m_owner->rng().range( m_active_pets );
default:
return nullptr;
}
Expand Down
9 changes: 3 additions & 6 deletions engine/player/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8840,8 +8840,7 @@ struct ancestral_call_t : public racial_spell_t
{
racial_spell_t::execute();

auto& buffs = player->buffs.ancestral_call;
buffs[ rng().range( buffs.size() ) ] -> trigger();
rng().range( player->buffs.ancestral_call )->trigger();
}
};

Expand Down Expand Up @@ -13701,17 +13700,15 @@ action_t* player_t::select_action( const action_priority_list_t& list,

if ( list.random == 1 )
{
size_t random = rng().range( a_list.size() );
a = a_list[ random ];
a = rng().range( a_list );
}
else
{
double skill = list.player->current.skill - list.player->current.skill_debuff;
if ( skill != 1 && rng().roll( ( 1 - skill ) * 0.5 ) )
{
size_t max_random_attempts = static_cast<size_t>( a_list.size() * ( skill * 0.5 ) );
size_t random = rng().range( a_list.size() );
a = a_list[ random ];
a = rng().range( a_list );
attempted_random++;
// Limit the amount of attempts to select a random action based on skill, then bail out and try again in 100
// ms.
Expand Down

0 comments on commit bea2093

Please sign in to comment.