Advertisement
Guest User

Untitled

a guest
Feb 1st, 2020
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.48 KB | None | 0 0
  1. struct melee_t: public warrior_attack_t
  2. {
  3.   bool mh_lost_melee_contact, oh_lost_melee_contact;
  4.   double base_rage_generation, arms_rage_multiplier, fury_rage_multiplier;
  5.   devastate_t* devastator;
  6.   melee_t( const std::string& name, warrior_t* p ):
  7.     warrior_attack_t( name, p, spell_data_t::nil() ),
  8.     mh_lost_melee_contact( true ), oh_lost_melee_contact( true ),
  9.     // patch notes said 10% buff so that would be 4.0 -> 4.4
  10.     // however in game testing suggest that actual value is 4.286
  11.     // with 3.6 speed weapon, we generate 27 rage on hit, not 27.72
  12.     // and crits generate 35 not 36
  13.     base_rage_generation( 1.75 ), arms_rage_multiplier( 4.286 ), fury_rage_multiplier( 0.80 ),
  14.     devastator( nullptr )
  15.   {
  16.     school = SCHOOL_PHYSICAL;
  17.     special = false;
  18.     background = repeating = may_glance = true;
  19.     trigger_gcd = timespan_t::zero();
  20.     if ( p -> dual_wield() )
  21.     {
  22.       base_hit -= 0.19;
  23.     }
  24.     if ( p -> talents.devastator -> ok() )
  25.     {
  26.       devastator = new devastate_t( p, "" );
  27.       add_child( devastator );
  28.     }
  29.   }
  30.  
  31.   void reset() override
  32.   {
  33.     warrior_attack_t::reset();
  34.     mh_lost_melee_contact = oh_lost_melee_contact = true;
  35.   }
  36.  
  37.   timespan_t execute_time() const override
  38.   {
  39.     timespan_t t = warrior_attack_t::execute_time();
  40.     if ( weapon -> slot == SLOT_MAIN_HAND && mh_lost_melee_contact )
  41.     {
  42.       return timespan_t::zero(); // If contact is lost, the attack is instant.
  43.     }
  44.     else if ( weapon -> slot == SLOT_OFF_HAND && oh_lost_melee_contact ) // Also used for the first attack.
  45.     {
  46.       return timespan_t::zero();
  47.     }
  48.     else
  49.     {
  50.       return t;
  51.     }
  52.   }
  53.  
  54.   void schedule_execute( action_state_t* s ) override
  55.   {
  56.     warrior_attack_t::schedule_execute( s );
  57.     if ( weapon -> slot == SLOT_MAIN_HAND )
  58.     {
  59.       mh_lost_melee_contact = false;
  60.     }
  61.     else if ( weapon -> slot == SLOT_OFF_HAND )
  62.     {
  63.       oh_lost_melee_contact = false;
  64.     }
  65.   }
  66.  
  67.   double composite_hit() const override
  68.   {
  69.     if ( p() -> artifact.focus_in_chaos.rank() && p() -> buff.enrage -> up() )
  70.     {
  71.       return 1.0;
  72.     }
  73.     return warrior_attack_t::composite_hit();
  74.   }
  75.  
  76.   void execute() override
  77.   {
  78.     if ( p() -> current.distance_to_move > 5 )
  79.     { // Cancel autoattacks, auto_attack_t will restart them when we're back in range.
  80.       if ( weapon -> slot == SLOT_MAIN_HAND )
  81.       {
  82.         p() -> proc.delayed_auto_attack -> occur();
  83.         mh_lost_melee_contact = true;
  84.         player -> main_hand_attack -> cancel();
  85.       }
  86.       else
  87.       {
  88.         p() -> proc.delayed_auto_attack -> occur();
  89.         oh_lost_melee_contact = true;
  90.         player -> off_hand_attack -> cancel();
  91.       }
  92.     }
  93.     else
  94.     {
  95.       warrior_attack_t::execute();
  96.  
  97.       if ( result_is_hit( execute_state -> result ) )
  98.       {
  99.         if ( p() -> specialization() == WARRIOR_PROTECTION )
  100.         {
  101.           if ( p() -> talents.devastator -> ok() )
  102.           {
  103.             p() -> resource_gain( RESOURCE_RAGE,
  104.                                   p() -> talents.devastator -> effectN( 1 ).trigger() -> effectN( 3 ).resource( RESOURCE_RAGE ),
  105.                                   p() -> gain.melee_main_hand );
  106.             devastator -> target = execute_state -> target;
  107.             devastator -> schedule_execute();
  108.           }
  109.         }
  110.         else
  111.         {
  112.           trigger_rage_gain( execute_state );
  113.         }
  114.       }
  115.     }
  116.   }
  117.  
  118.   void trigger_rage_gain( action_state_t* s )
  119.   {
  120.     double rage_gain = weapon -> swing_time.total_seconds() * base_rage_generation;
  121.  
  122.     if ( p() -> specialization() == WARRIOR_ARMS )
  123.     {
  124.       rage_gain *= arms_rage_multiplier;
  125.       if ( s -> result == RESULT_CRIT )
  126.         rage_gain *= 1.3;
  127.     }
  128.     else
  129.     {
  130.       rage_gain *= fury_rage_multiplier;
  131.       if ( weapon -> slot == SLOT_OFF_HAND )
  132.       {
  133.         rage_gain *= 0.5;
  134.       }
  135.       rage_gain *= 1.0 + p() -> talents.endless_rage -> effectN( 1 ).percent();
  136.     }
  137.  
  138.     rage_gain = util::round( rage_gain, 1 );
  139.  
  140.     if ( p() -> specialization() == WARRIOR_ARMS && s -> result == RESULT_CRIT )
  141.     {
  142.       p() -> resource_gain( RESOURCE_RAGE,
  143.                             rage_gain,
  144.                             p() -> gain.melee_crit );
  145.     }
  146.     else
  147.     {
  148.       p() -> resource_gain( RESOURCE_RAGE,
  149.                             rage_gain,
  150.                             weapon -> slot == SLOT_OFF_HAND ? p() -> gain.melee_off_hand : p() -> gain.melee_main_hand );
  151.     }
  152.   }
  153. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement