Skip to content

Commit

Permalink
[Player] deprecate old talent system
Browse files Browse the repository at this point in the history
Old grid/number based talent system methods are removed from player_t and isolated in player_talent_points_t.

player_t::talent_points will return a nullptr.
  • Loading branch information
gastank committed Aug 27, 2024
1 parent afe152d commit 8130e51
Show file tree
Hide file tree
Showing 11 changed files with 175 additions and 223 deletions.
2 changes: 1 addition & 1 deletion engine/class_modules/paladin/sc_paladin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@ struct lay_on_hands_t : public paladin_heal_t
struct blinding_light_t : public paladin_spell_t
{
blinding_light_t( paladin_t* p, util::string_view options_str )
: paladin_spell_t( "blinding_light", p, p->find_talent_spell( "Blinding Light" ) )
: paladin_spell_t( "blinding_light", p, p->talents.blinding_light )
{
parse_options( options_str );

Expand Down
24 changes: 12 additions & 12 deletions engine/class_modules/paladin/sc_paladin_holy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -570,22 +570,22 @@ void paladin_t::create_buffs_holy()
void paladin_t::init_spells_holy()
{
// Talents
talents.crusaders_might = find_talent_spell( "Crusader's Might" );
talents.bestow_faith = find_talent_spell( "Bestow Faith" );
talents.lights_hammer = find_talent_spell( "Light's Hammer" );
talents.crusaders_might = find_talent_spell( talent_tree::SPECIALIZATION, "Crusader's Might" );
talents.bestow_faith = find_talent_spell( talent_tree::SPECIALIZATION, "Bestow Faith" );
talents.lights_hammer = find_talent_spell( talent_tree::SPECIALIZATION, "Light's Hammer" );

talents.saved_by_the_light = find_talent_spell( "Saved by the Light" );
talents.judgment_of_light = find_talent_spell( "Judgment of Light" );
talents.holy_prism = find_talent_spell( "Holy Prism" );
talents.saved_by_the_light = find_talent_spell( talent_tree::SPECIALIZATION, "Saved by the Light" );
talents.judgment_of_light = find_talent_spell( talent_tree::SPECIALIZATION, "Judgment of Light" );
talents.holy_prism = find_talent_spell( talent_tree::SPECIALIZATION, "Holy Prism" );

talents.rule_of_law = find_talent_spell( "Rule of Law" );
talents.rule_of_law = find_talent_spell( talent_tree::SPECIALIZATION, "Rule of Law" );

talents.avenging_crusader = find_talent_spell( "Avenging Crusader" );
talents.awakening = find_talent_spell( "Awakening" );
talents.avenging_crusader = find_talent_spell( talent_tree::SPECIALIZATION, "Avenging Crusader" );
talents.awakening = find_talent_spell( talent_tree::SPECIALIZATION, "Awakening" );

talents.glimmer_of_light = find_talent_spell( "Glimmer of Light" );
talents.beacon_of_faith = find_talent_spell( "Beacon of Faith" );
talents.beacon_of_virtue = find_talent_spell( "Beacon of Virtue" );
talents.glimmer_of_light = find_talent_spell( talent_tree::SPECIALIZATION, "Glimmer of Light" );
talents.beacon_of_faith = find_talent_spell( talent_tree::SPECIALIZATION, "Beacon of Faith" );
talents.beacon_of_virtue = find_talent_spell( talent_tree::SPECIALIZATION, "Beacon of Virtue" );

// Spec passives and useful spells
spec.holy_paladin = find_specialization_spell( "Holy Paladin" );
Expand Down
2 changes: 1 addition & 1 deletion engine/class_modules/sc_shaman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8420,7 +8420,7 @@ struct ascendance_t : public shaman_spell_t
lava_burst_t* lvb;

ascendance_t( shaman_t* player, util::string_view name_str, util::string_view options_str = {} ) :
shaman_spell_t( name_str, player, player->find_talent_spell( "Ascendance", player->specialization(), false, false ) ),
shaman_spell_t( name_str, player, player->talent.ascendance ),
ascendance_damage( nullptr ), lvb( nullptr )
{
parse_options( options_str );
Expand Down
20 changes: 0 additions & 20 deletions engine/player/action_priority_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,23 +110,3 @@ action_priority_t* action_priority_list_t::add_action( const player_t* p, util::
s = p->find_specialization_spell( name );
return add_action( p, s, util::tokenize_fn( s->name_cstr() ), action_options, comment );
}

/**
* @brief add talent action to action list & check talent availability
*
* Check the availability of a talent spell of "name" and the validity of it's
* spell data before anything goes to action priority list. Note that this will
* ignore the actual talent check so we can make action list entries for
* talents, even though the profile does not have a talent.
*
* In addition, the method automatically checks for the presence of an if
* expression that includes the "talent guard", i.e., "talent.X.enabled" in it.
* If omitted, it will be automatically added to the if expression (or
* if expression will be created if it is missing).
*/
action_priority_t* action_priority_list_t::add_talent( const player_t* p, util::string_view name,
util::string_view action_options, util::string_view comment )
{
const spell_data_t* s = p->find_talent_spell( name, SPEC_NONE, false, false );
return add_action( p, s, util::tokenize_fn( s->name_cstr() ), action_options, comment );
}
2 changes: 0 additions & 2 deletions engine/player/action_priority_list.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ struct action_priority_list_t
util::string_view action_options = {}, util::string_view comment = {});
action_priority_t* add_action(const player_t* p, util::string_view name, util::string_view action_options = {},
util::string_view comment = {});
action_priority_t* add_talent(const player_t* p, util::string_view name, util::string_view action_options = {},
util::string_view comment = {});
action_priority_t* add_run_action_list(action_priority_list_t* run_action_list, util::string_view action_options = {}, util::string_view comment = {});
action_priority_t* add_run_action_list(const player_t* p, const spell_data_t* s, action_priority_list_t* run_action_list, util::string_view action_options = {}, util::string_view comment = {});

Expand Down
120 changes: 12 additions & 108 deletions engine/player/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1030,7 +1030,8 @@ player_t::player_t( sim_t* s, player_e t, util::string_view n, race_e r )
cooldown_tolerance_( timespan_t::min() ),
dbc( new dbc_t(*(s->dbc)) ),
dbc_override( sim->dbc_override.get() ),
talent_points( new player_talent_points_t()),
// talent_points( new player_talent_points_t()),
talent_points( nullptr ),
profession(),
azerite( nullptr ),
base(),
Expand Down Expand Up @@ -10235,26 +10236,6 @@ action_t* player_t::create_action( util::string_view name, util::string_view opt
return consumable::create_action( this, name, options_str );
}

void player_t::parse_talents_numbers( util::string_view talent_string )
{
talent_points->clear();

int i_max = std::min( static_cast<int>( talent_string.size() ), MAX_TALENT_ROWS );

for ( int i = 0; i < i_max; ++i )
{
char c = talent_string[ i ];
if ( c < '0' || c > ( '0' + MAX_TALENT_COLS ) )
{
throw std::runtime_error(fmt::format("Illegal character '{}' in talent encoding.", c ));
}
if ( c > '0' )
talent_points->select_row_col( i, c - '1' );
}

create_talents_numbers();
}

pet_t* player_t::create_pet( util::string_view, util::string_view )
{
return nullptr;
Expand Down Expand Up @@ -10316,16 +10297,6 @@ double player_t::get_attribute( attribute_e a ) const
return util::floor( composite_attribute( a ) * composite_attribute_multiplier( a ) );
}

void player_t::create_talents_numbers()
{
talents_str.clear();

for ( int j = 0; j < MAX_TALENT_ROWS; j++ )
{
talents_str += util::to_string( talent_points->choice( j ) + 1 );
}
}

static bool parse_min_gcd( sim_t* sim, util::string_view name, util::string_view value )
{
if ( name != "min_gcd" )
Expand Down Expand Up @@ -10374,23 +10345,6 @@ void player_t::replace_spells()
} );
}

// Search talents for spells to replace.
for ( int j = 0; j < MAX_TALENT_ROWS; j++ )
{
for ( int i = 0; i < MAX_TALENT_COLS; i++ )
{
if ( talent_points->has_row_col( j, i ) && true_level < 20 + ( j == 0 ? -1 : j ) * 5 )
{
const talent_data_t* td = talent_data_t::find( type, j, i, specialization(), dbc->ptr );
if ( td && td->replace_id() )
{
dbc->replace_id( td->replace_id(), td->spell_id() );
break;
}
}
}
}

// Search general spells for spells to replace (a spell you learn earlier might be
// replaced by one you learn later)
if ( _spec != SPEC_NONE )
Expand Down Expand Up @@ -10465,58 +10419,6 @@ void player_t::replace_spells()
}
}

/**
* Retrieves the Spell Data Associated with a given talent.
*
* If the player does not have have the talent activated, or the talent is not found,
* spell_data_t::not_found() is returned.
* The talent search by name is case sensitive, including all special characters!
*/
const spell_data_t* player_t::find_talent_spell( util::string_view n, specialization_e s, bool name_tokenized,
bool check_validity ) const
{
if ( s == SPEC_NONE )
{
s = specialization();
}

// Get a talent's spell id for a given talent name
unsigned spell_id = dbc->talent_ability_id( type, s, n, name_tokenized );

if ( !spell_id )
{
sim->print_debug( "Player {}: Can't find talent with name '{}'.", name(), n );
return spell_data_t::not_found();
}

for ( int j = 0; j < MAX_TALENT_ROWS; j++ )
{
for ( int i = 0; i < MAX_TALENT_COLS; i++ )
{
auto td = talent_data_t::find( type, j, i, s, dbc->ptr );
if ( !td )
continue;
auto spell = dbc::find_spell( this, td->spell_id() );

// Loop through all our classes talents, and check if their spell's id match the one we maped to the given
// talent name
if ( td && ( td->spell_id() == spell_id ) )
{
// check if we have the talent enabled or not
// Level tiers are hardcoded here which means they will need to changed when levels change
if ( check_validity &&
( !talent_points->validate( spell, j, i ) || true_level < 20 + ( j == 0 ? -1 : j ) * 5 ) )
return spell_data_t::not_found();

return spell;
}
}
}

/* Talent not enabled */
return spell_data_t::not_found();
}

static player_talent_t create_talent_obj( const player_t* player, const trait_data_t* trait )
{
auto it = range::find_if( player->player_traits, [ trait ]( const auto& entry ) {
Expand Down Expand Up @@ -10809,40 +10711,42 @@ void player_t::vision_of_perfection_proc()
* Tries to find spell data by name.
*
* It does this by going through various spell lists in following order:
* class spell, specialization spell, mastery spell, talent spell, racial spell, pet_spell
* class spell, specialization spell, mastery spell, class/spec/hero talent spell, racial spell, pet_spell
*/
const spell_data_t* player_t::find_spell( util::string_view name, specialization_e s ) const
{
const spell_data_t* sp = find_class_spell( name, s );
assert( sp );
if ( sp->ok() )
return sp;

sp = find_specialization_spell( name );
assert( sp );
if ( sp->ok() )
return sp;

if ( s != SPEC_NONE )
{
sp = find_mastery_spell( s );
assert( sp );
if ( sp->ok() )
return sp;
}

sp = find_talent_spell( name );
assert( sp );
sp = find_talent_spell( talent_tree::CLASS, name );
if ( sp->ok() )
return sp;

sp = find_talent_spell( talent_tree::SPECIALIZATION, name );
if ( sp->ok() )
return sp;

sp = find_talent_spell( talent_tree::HERO, name );
if ( sp->ok() )
return sp;

sp = find_racial_spell( name );
assert( sp );
if ( sp->ok() )
return sp;

sp = find_pet_spell( name );
assert( sp );
if ( sp->ok() )
return sp;

Expand Down
4 changes: 1 addition & 3 deletions engine/player/player.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ struct player_t : public actor_t
std::vector<stat_e> stat_timelines;

// Obsolete grid/number based talent system
// Currently not created and will return nullptr
std::unique_ptr<player_talent_points_t> talent_points;

// Player selected (trait entry id, rank) tuples
Expand Down Expand Up @@ -888,7 +889,6 @@ struct player_t : public actor_t
double get_stat_value(stat_e);
void stat_gain( stat_e stat, double amount, gain_t* g = nullptr, action_t* a = nullptr, bool temporary = false );
void stat_loss( stat_e stat, double amount, gain_t* g = nullptr, action_t* a = nullptr, bool temporary = false );
void create_talents_numbers();
void clear_action_priority_lists() const;
void copy_action_priority_list( util::string_view old_list, util::string_view new_list );
void change_position( position_e );
Expand All @@ -897,7 +897,6 @@ struct player_t : public actor_t
bool add_action( util::string_view action, util::string_view options = {}, util::string_view alist = "default" );
bool add_action( const spell_data_t* s, util::string_view options = {}, util::string_view alist = "default" );
void add_option( std::unique_ptr<option_t> o );
void parse_talents_numbers( util::string_view talent_string );
void parse_temporary_enchants();

bool is_moving() const;
Expand Down Expand Up @@ -966,7 +965,6 @@ struct player_t : public actor_t
const spell_data_t* find_rank_spell( util::string_view name, util::string_view rank,
specialization_e s = SPEC_NONE ) const;
const spell_data_t* find_pet_spell( util::string_view name ) const;
const spell_data_t* find_talent_spell( util::string_view name, specialization_e s = SPEC_NONE, bool name_tokenized = false, bool check_validity = true ) const;
player_talent_t find_talent_spell( talent_tree tree, util::string_view name, specialization_e s = SPEC_NONE, bool name_tokenized = false ) const;
player_talent_t find_talent_spell( talent_tree tree, unsigned spell_id, specialization_e s = SPEC_NONE ) const;
player_talent_t find_talent_spell( unsigned talent_entry_id ) const;
Expand Down
Loading

0 comments on commit 8130e51

Please sign in to comment.