Advertisement
Kojiyama

Trigger Hand of Fate

May 21st, 2024
752
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.79 KB | None | 0 0
  1. template <typename Base>
  2. void actions::rogue_action_t<Base>::trigger_hand_of_fate( const action_state_t* state, bool biased, bool trigger_inevitable )
  3. {
  4.   if ( !p()->talent.fatebound.hand_of_fate->ok() )
  5.     return;
  6.  
  7.   if ( cast_state( state )->get_combo_points() < p()->talent.fatebound.hand_of_fate->effectN( 1 ).base_value() )
  8.     return;
  9.  
  10.   const bool double_jeopardy = p()->buffs.double_jeopardy->check();
  11.   bool trigger_heads = false;
  12.   bool trigger_tails = false;
  13.  
  14.   if ( p()->buffs.edge_case->check() )
  15.   {
  16.     p()->buffs.edge_case->expire();
  17.     trigger_heads = trigger_tails = true;
  18.   }
  19.   else if ( p()->buffs.fatebound_coin_tails->check() == p()->buffs.fatebound_coin_heads->check() )
  20.   {
  21.     trigger_heads = !(trigger_tails = p()->rng().roll( 0.5 ));
  22.   }
  23.   else
  24.   {
  25.     double matching_odds = 0.5;
  26.     if ( biased )
  27.     {
  28.       // TODO: Validate how these stack with the presumed base 50/50 chance and one another
  29.       if ( p()->talent.fatebound.mean_streak->ok() )
  30.       {
  31.         matching_odds += matching_odds * p()->talent.fatebound.mean_streak->effectN( 1 ).percent();
  32.       }
  33.       if ( p()->talent.fatebound.destiny_defined->ok() )
  34.       {
  35.         matching_odds += p()->talent.fatebound.destiny_defined->effectN( 3 ).percent();
  36.       }
  37.     }
  38.     if ( p()->talent.fatebound.inevitability->ok() && trigger_inevitable )
  39.     {
  40.       // TODO: Inevitable flips when you have both coins don't always produce a flip
  41.       // for the coin with the higher coin count. There may be an underlying "order" to an
  42.       // edge result that is respected; but it's probably just a bug because it makes no sense.
  43.       matching_odds = 1.0;
  44.     }
  45.  
  46.     const bool is_match = p()->rng().roll( matching_odds );
  47.     const bool current_is_heads = p()->buffs.fatebound_coin_heads->check() > p()->buffs.fatebound_coin_tails->check();
  48.     trigger_tails = !(trigger_heads = ( current_is_heads && is_match ));
  49.   }
  50.  
  51.   if ( trigger_heads )
  52.   {
  53.     p()->buffs.fatebound_coin_heads->increment( 1 + double_jeopardy );
  54.     if ( !trigger_tails )
  55.       p()->buffs.fatebound_coin_tails->expire();
  56.   }
  57.  
  58.   if ( trigger_tails )
  59.   {
  60.     p()->buffs.fatebound_coin_tails->increment();
  61.     if ( !trigger_heads )
  62.       p()->buffs.fatebound_coin_heads->expire();
  63.  
  64.     if ( !ab::is_precombat )
  65.     {
  66.       auto tails_action = ( p()->talent.fatebound.delivered_doom->ok() && p()->sim->target_non_sleeping_list.size() <= 1 )
  67.         ? p()->active.fatebound.fatebound_coin_tails_delivered
  68.         : p()->active.fatebound.fatebound_coin_tails;
  69.       tails_action->execute_on_target( state->target );
  70.  
  71.       if ( double_jeopardy )
  72.       {
  73.         p()->buffs.fatebound_coin_tails->increment();
  74.         tails_action->execute_on_target( state->target );
  75.       }
  76.     }
  77.   }
  78.  
  79.   p()->buffs.double_jeopardy->expire();
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement