Guest User

spellauraeffects.cpp

a guest
Jan 12th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.44 KB | None | 0 0
  1. ---------- SpellAuraEffects.cpp --------------------
  2.  
  3. -- Under void AuraEffect::HandleAuraModIncreaseHealth(AuraApplication const* aurApp, uint8 mode, bool apply) const --
  4. {
  5.     if (!(mode & (AURA_EFFECT_HANDLE_CHANGE_AMOUNT_MASK | AURA_EFFECT_HANDLE_STAT)))
  6.         return;
  7.  
  8.     Unit* target = aurApp->GetTarget();
  9.  
  10.     float amount = GetAmount();
  11.  
  12.     // Special case of the Frenzied Regeneration the BP in dbc correspond to the porciento (bp = 30)
  13.     if (aurApp->GetBase()->GetSpellInfo()->Id == 22842)
  14.     {
  15.         if (apply)
  16.             // We calculate the ammount that corresponds to 30 % when the aura is applied
  17.             amount = target->GetMaxHealth() * amount / 100;
  18.         else
  19.             // We calculate the original HP when the aura is removed
  20.             amount = target->GetMaxHealth() * amount / (100 + amount);
  21.     }
  22.  
  23.     if (apply)
  24.     {
  25.         target->HandleStatModifier(UNIT_MOD_HEALTH, TOTAL_VALUE, float(GetAmount()), apply);
  26.         // Frenzied Regeneration
  27.         if (aurApp->GetBase()->GetSpellInfo()->Id == 22842)
  28.         {
  29.             // "increases health to 30% (if below that value)"
  30.             if (target->GetHealth() < amount)
  31.                 target->SetHealth(amount);
  32.         }
  33.         else
  34.             target->ModifyHealth(amount);
  35.     }
  36.     else
  37.     {
  38.         if (target->GetHealth() > 0)
  39.         {
  40.             int32 value = std::min<int32>(target->GetHealth() - 1, GetAmount());
  41.             target->ModifyHealth(-value);
  42.         }
  43.         target->HandleStatModifier(UNIT_MOD_HEALTH, TOTAL_VALUE, float(GetAmount()), apply);
  44.     }
  45. }
  46.  
  47.  
  48. ----- Insert ---------
  49. case SPELL_AURA_MOD_INCREASE_HEALTH_2:
  50.         {
  51.             switch (GetId())
  52.             {
  53.                 // Frenzied Regeneration
  54.             case 22842:
  55.             {
  56.                 if (caster->GetShapeshiftForm() == FORM_BEAR)
  57.                     amount = GetBase()->GetUnitOwner()->CountPctFromMaxHealth(30);
  58.                 break;
  59.             }
  60.                 // Mass Regeneration
  61.             case 105737:
  62.             {
  63.                 if (caster->GetShapeshiftForm() == FORM_BEAR)
  64.                     amount = GetBase()->GetUnitOwner()->CountPctFromMaxHealth(15);
  65.             }
  66.             }
  67.             break;
  68.         }
  69.  
  70. ---- under SPELL_FAMILY_DRUID --------
  71.    // Frenzied Regeneration
  72.             case 22842:
  73.             {
  74.                 // Converts up to 10 rage per second into health for $d.  Each point of rage is converted into ${$m2/10}.1% of max health.
  75.                 // Should be manauser
  76.                 if (target->getPowerType() != POWER_RAGE)
  77.                     break;
  78.                 uint32 rage = target->GetPower(POWER_RAGE);
  79.                 // Nothing todo
  80.                 if (rage == 0)
  81.                     break;
  82.                 int32 mod = (rage < 100) ? rage : 100;
  83.                 int32 points = target->CalculateSpellDamage(target, GetSpellInfo(), 1);
  84.                 int32 regen = (target->GetMaxHealth() * (mod * points / 10) / 100) / 210;
  85.                 target->CastCustomSpell(target, 22845, &regen, 0, 0, true, 0, this);
  86.                 target->SetPower(POWER_RAGE, rage - mod);
  87.                 // Mass Regeneration
  88.                 if (target->HasAura(105735))
  89.                     // Mass Regeneration
  90.                     target->CastCustomSpell(target, 105739, &regen, NULL, NULL, true, NULL, this);
  91.                 target->SetPower(POWER_RAGE, rage - mod);
  92.                     break;
Advertisement
Add Comment
Please, Sign In to add comment