SimulationCraft
SimulationCraft is a tool to explore combat mechanics in the popular MMO RPG World of Warcraft (tm).
cooldown_t Struct Reference

Public Member Functions

 cooldown_t (util::string_view name, player_t &)
 
 cooldown_t (util::string_view name, sim_t &)
 
void adjust (timespan_t, bool requires_reaction=true)
 
void adjust_recharge_multiplier ()
 Adjust the recharge multiplier of a dynamic cooldown. More...
 
void adjust_base_duration ()
 Adjust the base duration of a dynamic cooldown. More...
 
void reset (bool require_reaction, int charges_=1)
 
void start (action_t *action, timespan_t override=timespan_t::min(), timespan_t delay=timespan_t::zero())
 
void start (timespan_t override=timespan_t::min(), timespan_t delay=timespan_t::zero())
 
void reset_init ()
 
timespan_t remains () const
 
timespan_t current_charge_remains () const
 
bool up () const
 
bool down () const
 
bool ongoing () const
 
bool is_ready () const
 
timespan_t queue_delay () const
 
timespan_t queueable () const
 
double charges_fractional () const
 
void update_ready_thresholds ()
 
const std::string & name () const
 
std::unique_ptr< expr_tcreate_expression (util::string_view name_str)
 
void add_execute_type (execute_type e)
 
void set_max_charges (int new_max_charges)
 Adjust maximum charges for a cooldown Takes the cooldown and new maximum charge count Function depends on the internal working of cooldown_t::reset. More...
 
void adjust_max_charges (int charge_change)
 

Static Public Member Functions

static timespan_t ready_init ()
 
static timespan_t cooldown_duration (const cooldown_t *cd)
 

Public Attributes

sim_tsim
 
player_tplayer
 
std::string name_str
 
timespan_t duration
 
timespan_t ready
 
timespan_t reset_react
 
int charges
 
event_trecharge_event
 
event_tready_trigger_event
 
timespan_t last_start
 
timespan_t last_charged
 
bool hasted
 
action_taction
 
bool allow_precombat
 
unsigned execute_types_mask
 
int current_charge
 
double recharge_multiplier
 
timespan_t base_duration
 

Friends

void sc_format_to (const cooldown_t &, fmt::format_context::iterator)
 

Member Function Documentation

◆ adjust_base_duration()

void cooldown_t::adjust_base_duration ( )

Adjust the base duration of a dynamic cooldown.

Adjust a dynamic cooldown duration based on the current action associated with the cooldown. Actions are associated by start() calls.

◆ adjust_recharge_multiplier()

void cooldown_t::adjust_recharge_multiplier ( )

Adjust the recharge multiplier of a dynamic cooldown.

Adjust a dynamic cooldown (reduction) multiplier based on the current action associated with the cooldown. Actions are associated by start() calls.

◆ set_max_charges()

void cooldown_t::set_max_charges ( int  new_max_charges)

Adjust maximum charges for a cooldown Takes the cooldown and new maximum charge count Function depends on the internal working of cooldown_t::reset.

If the cooldown ongoing we can assume that the action isn't a nullptr as otherwise the action would not be ongoing. If it has no action we cannot call cooldown->start which means we cannot set fractional charges. However, a cooldown is not ongoing at maximum charges. if we have maximum charges then the number of charges will only ever change equal to the change in maximum charges. This means we'll never need to use cooldown->start to handle the case where cooldown is not ongoing and cooldown->reset is satisfactory.

If our new max charges is less than current max charges, we have lost maximum charges. If we have lost maximum charges, we'll also lose current charges for charges lost but we'll keep current cooldown progress.

Otherwise, we have gained maximum charges. Gaining maximum charges will give us those charges.

This loop is used to remove all of the charges and start the cooldown recovery event properly. It does it by repetitively calling cooldown->start which will remove a current charge and restart the event timers.

Use adjust to go from 0 charges and 0 cooldown progress to the previously calculated charges we should have after changing max charges by making the cooldown advance in time by the multiple of the cooldown.