Skip to content

Commit

Permalink
[Cooldown] Implement "full_recharge_time" expression that returns the…
Browse files Browse the repository at this point in the history
… number of seconds until the action is fully recharged.
  • Loading branch information
aggixx committed Oct 4, 2016
1 parent b4789b0 commit eeae9e1
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 13 deletions.
18 changes: 5 additions & 13 deletions engine/action/sc_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2658,19 +2658,11 @@ expr_t* action_t::create_expression( const std::string& name_str )

return new persistent_multiplier_expr_t( this );
}
else if ( name_str == "charges" )
{
return cooldown -> create_expression( this, name_str );
}
else if ( name_str == "charges_fractional" )
{
return cooldown -> create_expression( this, name_str );
}
else if ( name_str == "max_charges" )
{
return cooldown -> create_expression( this, name_str );
}
else if ( name_str == "recharge_time" )
else if ( name_str == "charges"
|| name_str == "charges_fractional"
|| name_str == "max_charges"
|| name_str == "recharge_time"
|| name_str == "full_recharge_time" )
{
return cooldown -> create_expression( this, name_str );
}
Expand Down
22 changes: 22 additions & 0 deletions engine/sim/sc_cooldown.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,28 @@ expr_t* cooldown_t::create_expression( action_t*, const std::string& name_str )
};
return new recharge_time_expr_t( this );
}
else if ( name_str == "full_recharge_time" )
{
struct full_recharge_time_expr_t : public expr_t
{
const cooldown_t* cd;
full_recharge_time_expr_t( const cooldown_t* c ) :
expr_t( "full_recharge_time" ), cd( c )
{ }

virtual double evaluate() override
{
if ( cd -> recharge_event )
{
return cd -> current_charge_remains().total_seconds() +
( cd -> charges - cd -> current_charge - 1 ) * cd -> duration.total_seconds();
}
else
return 0;
}
};
return new full_recharge_time_expr_t( this );
}
else if ( name_str == "max_charges" )
return make_ref_expr( name_str, charges );

Expand Down

0 comments on commit eeae9e1

Please sign in to comment.