Skip to content
Permalink
Browse files

[Shaman] Add Elemental pet related expressions to the module

With syntax "pet.(primal_|)(fire|earth|storm)_elemental.(remains|active)

The "primal" prefix will force the elemental type to be explicitly the
primal version, i.e., if the actor does not have Primal Elementalist
talented, the expressions will return their "false" equivalent value.

The `active` expression will return 0.0 if the selected elemental is not
active, and 1.0 otherwise. The `remains` expression will return the
remaining duration of the selected elemental in seconds, or 0.0 if the
elemental is not active.
  • Loading branch information
navv1234 committed Dec 1, 2019
1 parent a387863 commit f064bcc7423b05a3a930be47a376ba603ad99d68
Showing with 66 additions and 0 deletions.
  1. +66 −0 engine/class_modules/sc_shaman.cpp
@@ -155,6 +155,13 @@ enum wolf_type_e
LIGHTNING_WOLF
};

enum class elemental
{
FIRE,
EARTH,
STORM,
};

enum imbue_e
{
IMBUE_NONE = 0,
@@ -6728,6 +6735,65 @@ std::unique_ptr<expr_t> shaman_t::create_expression( const std::string& name )
{
std::vector<std::string> splits = util::string_split( name, "." );

if ( splits.size() >= 3 && util::str_compare_ci( splits[ 0 ], "pet" ) )
{
auto require_primal = splits[ 1 ].find( "primal_" ) != std::string::npos;
auto et = elemental::FIRE;
if ( util::str_in_str_ci( splits[ 1 ], "fire" ) )
{
et = elemental::FIRE;
}
else if ( util::str_in_str_ci( splits[ 1 ], "earth" ) )
{
et = elemental::EARTH;
}
else if ( util::str_in_str_ci( splits[ 1 ], "storm" ) )
{
et = elemental::STORM;
}
else
{
return player_t::create_expression( name );
}

const pet_t* p = nullptr;
auto pe = require_primal || talent.primal_elementalist->ok() == true;
switch ( et )
{
case elemental::FIRE:
p = pe ? pet.pet_fire_elemental : pet.guardian_fire_elemental;
break;
case elemental::EARTH:
p = pe ? pet.pet_earth_elemental : pet.guardian_earth_elemental;
break;
case elemental::STORM:
p = pe ? pet.pet_storm_elemental : pet.guardian_storm_elemental;
break;
}

if ( !p )
{
return expr_t::create_constant( name, 0.0 );
}

if ( util::str_compare_ci( splits[ 2 ], "active" ) )
{
return make_fn_expr( name, [p]() {
return static_cast<double>( !p->is_sleeping() );
} );
}
else if ( util::str_compare_ci( splits[ 2 ], "remains" ) )
{
return make_fn_expr( name, [p]() {
return p->expiration->remains().total_seconds();
} );
}
else
{
return player_t::create_expression( name );
}
}

if ( util::str_compare_ci( splits[ 0 ], "feral_spirit" ) )
{
if ( talent.elemental_spirits->ok() && !find_action( "feral_spirit" ) )

0 comments on commit f064bcc

Please sign in to comment.
You can’t perform that action at this time.