tjc12821

Untitled

Aug 29th, 2016
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 8.98 KB | None | 0 0
  1. // Execute ==================================================================
  2.  
  3. struct execute_sweep_t: public warrior_attack_t
  4. {
  5.   double original;
  6.   bool free;
  7.   execute_sweep_t( warrior_t* p, double original_cost, bool was_it_free ):
  8.     warrior_attack_t( "execute", p, p -> spec.execute ), original( original_cost ), free( was_it_free )
  9.   {
  10.     weapon = &( p -> main_hand_weapon );
  11.  
  12.     base_crit += p -> artifact.deathblow.percent();
  13.     base_crit += p -> artifact.deathdealer.percent();
  14.     energize_amount = 0;
  15.   }
  16.  
  17.   double action_multiplier() const override
  18.   {
  19.     double am = warrior_attack_t::action_multiplier();
  20.  
  21.     if ( p() -> mastery.colossal_might -> ok() )
  22.     {
  23.       am *= 4.0 * ( std::min( 40.0, ( free ? 40.0 : original ) ) / 40 );
  24.     }
  25.  
  26.     am *= 1.0 + p() -> buff.shattered_defenses -> stack_value();
  27.  
  28.     return am;
  29.   }
  30.  
  31.   double composite_crit_chance() const override
  32.   {
  33.     double cc = warrior_attack_t::composite_crit_chance();
  34.  
  35.     if ( p() -> buff.shattered_defenses -> check() )
  36.     {
  37.       cc += p() -> buff.shattered_defenses -> data().effectN( 2 ).percent();
  38.     }
  39.  
  40.     return cc;
  41.   }
  42.  
  43.   double cost() const override
  44.   {
  45.     return 0;
  46.   }
  47.  
  48.   void execute() override
  49.   {
  50.     warrior_attack_t::execute();
  51.     p() -> execute_sweeping_strike = nullptr;
  52.   }
  53.  
  54.   void impact( action_state_t* s ) override
  55.   {
  56.     warrior_attack_t::impact( s );
  57.  
  58.     if ( s -> result == RESULT_CRIT )
  59.     {
  60.       arms_t19_4p( *s );
  61.     }
  62.   }
  63. };
  64.  
  65. struct sweeping_execute_t: public event_t
  66. {
  67.   timespan_t duration;
  68.   execute_sweep_t* execute_sweep;
  69.   player_t* original_target;
  70.   warrior_t* warrior;
  71.   sweeping_execute_t( warrior_t*p, double cost, bool free, player_t* target ):
  72.     event_t( *p -> sim ), execute_sweep( nullptr ), original_target( target ), warrior( p )
  73.   {
  74.     duration = next_execute();
  75.     add_event( duration );
  76.     execute_sweep = new execute_sweep_t( p, cost, free );
  77.   }
  78.  
  79.   timespan_t next_execute() const
  80.   {
  81.     return timespan_t::from_millis( 500 );
  82.   }
  83.  
  84.   void execute() override
  85.   {
  86.     player_t* new_target = nullptr;
  87.     // Gotta find a target for this bastard to hit. Also if the target dies in the 0.5 seconds between the original execute and this, we don't want to continue.
  88.     for ( size_t i = 0; execute_sweep -> target_cache.list.size() <= i; ++i )
  89.     {
  90.       if ( execute_sweep -> target_cache.list[i] == original_target )
  91.         continue;
  92.       new_target = execute_sweep -> target_cache.list[i];
  93.     }
  94.     if ( new_target )
  95.     {
  96.       execute_sweep -> target = new_target;
  97.       execute_sweep -> execute();
  98.     }
  99.     else
  100.     {
  101.       warrior -> execute_sweeping_strike = nullptr;
  102.     }
  103.   }
  104. };
  105.  
  106. struct execute_off_hand_t: public warrior_attack_t
  107. {
  108.   execute_off_hand_t( warrior_t* p, const char* name, const spell_data_t* s ):
  109.     warrior_attack_t( name, p, s )
  110.   {
  111.     dual = true;
  112.     may_miss = may_dodge = may_parry = may_block = false;
  113.     weapon = &( p -> off_hand_weapon );
  114.  
  115.     if ( p -> main_hand_weapon.group() == WEAPON_1H &&
  116.          p -> off_hand_weapon.group() == WEAPON_1H )
  117.     {
  118.       weapon_multiplier *= 1.0 + p -> spec.singleminded_fury -> effectN( 3 ).percent();
  119.     }
  120.     base_crit += p -> artifact.deathdealer.percent();
  121.   }
  122.  
  123.   double action_multiplier() const override
  124.   {
  125.     double am = warrior_attack_t::action_multiplier();
  126.  
  127.     am *= 1.0 + p() -> buff.juggernaut -> stack_value();
  128.  
  129.     return am;
  130.   }
  131.  
  132.   void impact( action_state_t* s ) override
  133.   {
  134.     warrior_attack_t::impact( s );
  135.  
  136.     if ( s -> result == RESULT_CRIT )
  137.     {
  138.       p() -> buff.massacre -> trigger();
  139.       if ( p() -> execute_enrage )
  140.       {
  141.         p() -> enrage();
  142.       }
  143.     }
  144.   }
  145. };
  146.  
  147. struct execute_t: public warrior_attack_t
  148. {
  149.   execute_off_hand_t* oh_attack;
  150.   double max_rage;
  151.   execute_t( warrior_t* p, const std::string& options_str ):
  152.     warrior_attack_t( "execute", p, p -> spec.execute ), oh_attack( nullptr ),
  153.     max_rage( 0 )
  154.   {
  155.     parse_options( options_str );
  156.     weapon = &( p -> main_hand_weapon );
  157.  
  158.     if ( p -> specialization() == WARRIOR_FURY )
  159.     {
  160.       oh_attack = new execute_off_hand_t( p, "execute_offhand", p -> find_spell( 163558 ) );
  161.       add_child( oh_attack );
  162.       if ( p -> main_hand_weapon.group() == WEAPON_1H &&
  163.            p -> off_hand_weapon.group() == WEAPON_1H )
  164.       {
  165.         weapon_multiplier *= 1.0 + p -> spec.singleminded_fury -> effectN( 3 ).percent();
  166.       }
  167.     }
  168.  
  169.     base_crit += p -> artifact.deathblow.percent();
  170.     base_crit += p -> artifact.deathdealer.percent();
  171.     energize_amount = 0;
  172.     max_rage = p -> talents.dauntless -> ok() ? 32 : 40;
  173.   }
  174.  
  175.   double action_multiplier() const override
  176.   {
  177.     double am = warrior_attack_t::action_multiplier();
  178.  
  179.     if ( p() -> mastery.colossal_might -> ok() )
  180.     {
  181.       bool free = ( p() -> buff.ayalas_stone_heart -> up() || p() -> buff.battle_cry_deadly_calm -> up() );
  182.       am *= 4.0 * ( std::min( max_rage, ( free ? max_rage : p() -> resources.current[RESOURCE_RAGE] ) ) / max_rage );
  183.     }
  184.     else if ( p() -> has_shield_equipped() )
  185.     { am *= 1.0 + p() -> spec.protection -> effectN( 2 ).percent(); }
  186.  
  187.     am *= 1.0 + p() -> buff.shattered_defenses -> stack_value();
  188.  
  189.     am *= 1.0 + p() -> buff.juggernaut -> stack_value();
  190.  
  191.     return am;
  192.   }
  193.  
  194.   double composite_crit_chance() const override
  195.   {
  196.     double cc = warrior_attack_t::composite_crit_chance();
  197.  
  198.     if ( p() -> buff.shattered_defenses -> check() )
  199.     {
  200.       cc += p() -> buff.shattered_defenses -> data().effectN( 2 ).percent();
  201.     }
  202.  
  203.     return cc;
  204.   }
  205.  
  206.   double tactician_cost() const override
  207.   {
  208.     double c = 0;
  209.  
  210.     c = std::min( max_rage, std::max( p() -> resources.current[RESOURCE_RAGE], c ) );
  211.  
  212.     if ( p() -> talents.dauntless -> ok() )
  213.     {
  214.       c /= 1.0 + p() -> talents.dauntless -> effectN( 1 ).percent();
  215.     }
  216.  
  217.     if ( sim -> log )
  218.     {
  219.       sim -> out_debug.printf( "Rage used to calculate tactician chance from ability %s: %4.4f, actual rage used: %4.4f",
  220.                                    name(),
  221.                                    c,
  222.                                    cost() );
  223.     }
  224.  
  225.     return c;
  226.   }
  227.  
  228.   double cost() const override
  229.   {
  230.     double c = warrior_attack_t::cost();
  231.  
  232.     if ( p() -> buff.ayalas_stone_heart -> check() )
  233.     {
  234.       return c *= 1.0 + p() -> buff.ayalas_stone_heart -> data().effectN( 2 ).percent();
  235.     }
  236.  
  237.     if ( p() -> buff.battle_cry_deadly_calm -> check() )
  238.     {
  239.       return c *= 1.0 + p() -> talents.deadly_calm  -> effectN( 1 ).percent();
  240.     }
  241.  
  242.     if ( p() -> mastery.colossal_might -> ok() ) // Arms
  243.     {
  244.       c = std::min( max_rage, std::max( p() -> resources.current[RESOURCE_RAGE], c ) );
  245.       c *= 1.0 + p() -> buff.precise_strikes -> check_value();
  246.     }
  247.     else if ( p() -> buff.sense_death -> check() ) // Fury
  248.     {
  249.       c *= 1.0 + p() -> buff.sense_death -> data().effectN( 1 ).percent();
  250.     }
  251.  
  252.     return c;
  253.   }
  254.  
  255.   void execute() override
  256.   {
  257.     warrior_attack_t::execute();
  258.  
  259.     if ( p() -> cooldown.rage_of_the_valarjar_icd -> up() && p() -> buff.berserking_driver -> trigger() )
  260.     {
  261.       p() -> cooldown.rage_of_the_valarjar_icd -> start();
  262.     }
  263.     p() -> buff.sense_death -> expire();
  264.     p() -> buff.sense_death -> trigger();
  265.  
  266.     if ( p() -> specialization() == WARRIOR_FURY && result_is_hit( execute_state -> result ) &&
  267.          p() -> off_hand_weapon.type != WEAPON_NONE ) // If MH fails to land, or if there is no OH weapon for Fury, oh attack does not execute.
  268.       oh_attack -> execute();
  269.  
  270.     p() -> buff.shattered_defenses -> expire();
  271.     p() -> buff.precise_strikes -> expire();
  272.     p() -> buff.juggernaut -> trigger( 1 );
  273.  
  274.     if ( p() -> talents.sweeping_strikes -> ok() && target_cache.list.size() > 1 )
  275.     {
  276.       p() -> execute_sweeping_strike = new ( *sim ) sweeping_execute_t( p(),
  277.                                                                         resource_consumed,
  278.                                                                         p() -> buff.ayalas_stone_heart -> up(),
  279.                                                                         execute_state -> target );
  280.     }
  281.     p() -> buff.ayalas_stone_heart -> expire();
  282.   }
  283.  
  284.   void impact( action_state_t* s ) override
  285.   {
  286.     warrior_attack_t::impact( s );
  287.  
  288.     if ( s -> result == RESULT_CRIT )
  289.     {
  290.       p() -> buff.massacre -> trigger();
  291.       arms_t19_4p( *s );
  292.       if ( p() -> execute_enrage && p() -> specialization() == WARRIOR_FURY )
  293.       {
  294.         p() -> enrage();
  295.       }
  296.     }
  297.   }
  298.  
  299.   bool ready() override
  300.   {
  301.     if ( p() -> main_hand_weapon.type == WEAPON_NONE )
  302.     {
  303.       return false;
  304.     }
  305.  
  306.     if ( p() -> buff.ayalas_stone_heart -> check() )
  307.     {
  308.       return warrior_attack_t::ready();
  309.     }
  310.  
  311.     // Call warrior_attack_t::ready() first for proper targeting support.
  312.     if ( warrior_attack_t::ready() && target -> health_percentage() <= 20 )
  313.     {
  314.       return true;
  315.     }
  316.     else
  317.     {
  318.       return false;
  319.     }
  320.   }
  321. };
Add Comment
Please, Sign In to add comment