Skip to content

Commit

Permalink
[Druid] Create ticks_gained_on_refresh expression
Browse files Browse the repository at this point in the history
  • Loading branch information
Xanzara committed Aug 13, 2018
1 parent 140ab38 commit 0907b5b
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions engine/class_modules/sc_druid.cpp
Expand Up @@ -5173,6 +5173,14 @@ struct thrash_proxy_t : public druid_spell_t
{
thrash_cat = new cat_attacks::thrash_cat_t(p, options_str);
thrash_bear = new bear_attacks::thrash_bear_t(p, options_str);

//At the moment, both versions of these spells are the same
//(and only the cat version has a talent that changes this)
//so we use this spell data here. If this changes we will
//have to think of something more robust. These two are
//important for the "ticks_gained_on_refresh" expression to work
dot_duration = thrash_cat->dot_duration;
base_tick_time = thrash_cat->base_tick_time;
}

void execute() override
Expand All @@ -5185,6 +5193,13 @@ struct thrash_proxy_t : public druid_spell_t

}

dot_t* get_dot(player_t* t) override
{
if (p()->buff.bear_form->check())
return thrash_bear->get_dot(t);
return thrash_cat->get_dot(t);
}

bool ready() override
{
if ( p()->buff.cat_form->check() )
Expand Down Expand Up @@ -8673,6 +8688,34 @@ expr_t* druid_t::create_expression( const std::string& name_str )

std::vector<std::string> splits = util::string_split( name_str, "." );

if (splits[0] == "druid" && splits[2] == "ticks_gained_on_refresh")
{
// Since we know some action names don't map to the actual dot portion, lets add some exceptions
// this may have to be made more robust if other specs are interested in using it, but for now lets
// default any ambiguity to what would make most sense for ferals.
if (splits[1] == "rake") splits[1] = "rake_bleed";
if (specialization() == DRUID_FERAL && splits[1] == "moonfire") splits[1] = "lunar_inspiration";

action_t* action = find_action(splits[1]);
if (action)
return make_fn_expr(name_str, [action]() -> double {

dot_t* dot = action->get_dot();
double remaining_ticks = 0;
double potential_ticks = 0;
timespan_t duration = action->dot_duration;

if (dot->is_ticking())
{
remaining_ticks = dot->remains() / dot->current_action->tick_time(dot->state);
duration = action->calculate_dot_refresh_duration(dot, duration);
}
potential_ticks = duration / (action->base_tick_time * action->composite_haste());
return potential_ticks - remaining_ticks;
});
throw std::invalid_argument("invalid action");
}

if ( util::str_compare_ci( name_str, "astral_power" ) )
{
return make_ref_expr( name_str, resources.current[ RESOURCE_ASTRAL_POWER ] );
Expand Down

0 comments on commit 0907b5b

Please sign in to comment.