void Absorb(AuraEffect* aurEff, DamageInfo & dmgInfo, uint32 & absorbAmount) { Unit* victim = GetTarget(); int32 remainingHealth = victim->GetHealth() - dmgInfo.GetDamage(); uint32 allowedHealth = victim->CountPctFromMaxHealth(3); if (victim->ToPlayer()->duel != NULL) return; // If damage kills us if (remainingHealth <= 0 && !victim->ToPlayer()->HasSpellCooldown(SPELL_EXECUTE_CD)) { // Cast healing spell, completely avoid damage absorbAmount = dmgInfo.GetDamage(); int32 healAmount = int32(victim->CountPctFromMaxHealth(uint32(healPct))); victim->CastCustomSpell(victim, SPELL_EXECUTE_HEAL, &healAmount, NULL, NULL, true, NULL, aurEff); victim->ToPlayer()->AddSpellCooldown(SPELL_EXECUTE_HEAL, 0, time(NULL) + 120); victim->AddAura(SPELL_EXECUTE_STUN, victim); victim->ToPlayer()->AddSpellCooldown(SPELL_EXECUTE_CD, 0, time(NULL) + 600); victim->ToPlayer()->AddSpellCooldown(SPELL_EXECUTE_STUN, 0, time(NULL) + 600); victim->AddAura(SPELL_EXECUTE_CD, victim); std::stringstream message; message << "Player " << victim->ToPlayer()->GetName() << " has been stunned."; sWorld->SendGMText(LANG_GM_ANNOUNCE_COLOR, victim->GetName().c_str(), message.str().c_str()); } }
void Absorb(AuraEffect * aurEff, DamageInfo & dmgInfo, uint32 & absorbAmount) { Unit * pVictim = GetTarget(); int32 remainingHealth = pVictim->GetHealth() - dmgInfo.GetDamage(); uint32 allowedHealth = pVictim->CountPctFromMaxHealth(35); // If damage kills us if (remainingHealth <= 0 && !pVictim->ToPlayer()->HasSpellCooldown(PAL_SPELL_ARDENT_DEFENDER_HEAL)) { // Cast healing spell, completely avoid damage absorbAmount = dmgInfo.GetDamage(); uint32 defenseSkillValue = pVictim->GetDefenseSkillValue(); // Max heal when defense skill denies critical hits from raid bosses // Formula: max defense at level + 140 (raiting from gear) uint32 reqDefForMaxHeal = pVictim->getLevel() * 5 + 140; float pctFromDefense = (defenseSkillValue >= reqDefForMaxHeal) ? 1.0f : float(defenseSkillValue) / float(reqDefForMaxHeal); int32 healAmount = int32(pVictim->CountPctFromMaxHealth(uint32(healPct * pctFromDefense))); pVictim->CastCustomSpell(pVictim, PAL_SPELL_ARDENT_DEFENDER_HEAL, &healAmount, NULL, NULL, true, NULL, aurEff); pVictim->ToPlayer()->AddSpellCooldown(PAL_SPELL_ARDENT_DEFENDER_HEAL, 0, time(NULL) + 120); } else if (remainingHealth < int32(allowedHealth)) { // Reduce damage that brings us under 35% (or full damage if we are already under 35%) by x% uint32 damageToReduce = (pVictim->GetHealth() < allowedHealth) ? dmgInfo.GetDamage() : allowedHealth - remainingHealth; absorbAmount = CalculatePctN(damageToReduce, absorbPct); } }
void Absorb(AuraEffect * aurEff, DamageInfo & dmgInfo, uint32 & absorbAmount) { Unit * target = GetTarget(); if (dmgInfo.GetDamage() < target->GetHealth()) return; if (target->ToPlayer()->HasSpellCooldown( ROG_SPELL_CHEAT_DEATH_COOLDOWN)) return; if (!roll_chance_i(absorbChance)) return; target->CastSpell(target, ROG_SPELL_CHEAT_DEATH_COOLDOWN, true); target->ToPlayer()->AddSpellCooldown(ROG_SPELL_CHEAT_DEATH_COOLDOWN, 0, time(NULL) + 60); uint32 health10 = target->CountPctFromMaxHealth(10); // hp > 10% - absorb hp till 10% if (target->GetHealth() > health10) absorbAmount = dmgInfo.GetDamage() - target->GetHealth() + health10; // hp lower than 10% - absorb everything else absorbAmount = dmgInfo.GetDamage(); }
void HandleScript(SpellEffIndex /*effIndex*/) { Unit* target = GetHitUnit(); int32 casterHpPct = (int32) GetCaster()->GetHealthPct(); uint32 newHp = target->CountPctFromMaxHealth(casterHpPct); if (newHp <= 0) newHp = target->GetMaxHealth() - 1; target->SetHealth(newHp); }
void Absorb(AuraEffect * /*aurEff*/, DamageInfo & dmgInfo, uint32 & absorbAmount) { Unit * target = GetTarget(); if (dmgInfo.GetDamage() < target->GetHealth()) return; int32 healAmount = int32(target->CountPctFromMaxHealth(healPct)); // remove the aura now, we don't want 40% healing bonus Remove(AURA_REMOVE_BY_ENEMY_SPELL); target->CastCustomSpell(target, PRI_SPELL_GUARDIAN_SPIRIT_HEAL, &healAmount, NULL, NULL, true); absorbAmount = dmgInfo.GetDamage(); }
void HandleDummy(SpellEffIndex /* effIndex */) { Unit* caster = GetCaster(); if (Unit* target = GetHitUnit()) { uint32 count = target->GetDiseasesByCaster(caster->GetGUID()); int32 bp = int32(count * caster->CountPctFromMaxHealth(int32(GetSpellInfo()->Effects[EFFECT_0].DamageMultiplier))); // Improved Death Strike if (AuraEffect const* aurEff = caster->GetAuraEffect(SPELL_AURA_ADD_PCT_MODIFIER, SPELLFAMILY_DEATHKNIGHT, ICON_ID_IMPROVED_DEATH_STRIKE, 0)) AddPctN(bp, caster->CalculateSpellDamage(caster, aurEff->GetSpellInfo(), 2)); caster->CastCustomSpell(caster, SPELL_DEATH_STRIKE_HEAL, &bp, NULL, NULL, false); } }
void SonicBoomEffect() { std::list<HostileReference *> t_list = me->getThreatManager().getThreatList(); for (std::list<HostileReference *>::const_iterator itr = t_list.begin(); itr!= t_list.end(); ++itr) { Unit *pTarget = Unit::GetUnit(*me, (*itr)->getUnitGuid()); if (pTarget && pTarget->GetTypeId() == TYPEID_PLAYER) { //Not do anything without aura, spell can be resisted! if (pTarget->HasAura(SPELL_SONIC_BOOM_CAST) && me->IsWithinDistInMap(pTarget, 34.0f)) { //This will be wrong calculation. Also, comments suggest it must deal damage pTarget->SetHealth(pTarget->CountPctFromMaxHealth(20)); } } } }
void Absorb(AuraEffect* aurEff, DamageInfo& dmgInfo, uint32& absorbAmount) { Unit* caster = GetCaster(); if (!caster) return; int32 remainingHealth = caster->GetHealth() - dmgInfo.GetDamage(); int32 cauterizeHeal = caster->CountPctFromMaxHealth(40); if (caster->ToPlayer()->HasSpellCooldown(SPELL_MAGE_CAUTERIZE_DAMAGE)) return; if (!roll_chance_i(absorbChance)) return; if (remainingHealth <= 0) { absorbAmount = dmgInfo.GetDamage(); caster->CastCustomSpell(caster, SPELL_MAGE_CAUTERIZE_DAMAGE, NULL,&cauterizeHeal, NULL, true, NULL, aurEff); caster->ToPlayer()->AddSpellCooldown(SPELL_MAGE_CAUTERIZE_DAMAGE, 0, time(NULL) + 60); } }
void AfterApply(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) { Unit* target = GetTarget(); int32 bp0 = target->CountPctFromMaxHealth(aurEff->GetAmount()); target->CastCustomSpell(target, SPELL_DRUID_SURVIVAL_INSTINCTS, &bp0, NULL, NULL, true); }
void HandleDummy(SpellEffIndex /*effIndex*/) { Unit* caster = GetCaster(); int32 healthModSpellBasePoints0 = int32(caster->CountPctFromMaxHealth(30)); caster->CastCustomSpell(caster, SPELL_HUNTER_PET_LAST_STAND_TRIGGERED, &healthModSpellBasePoints0, NULL, NULL, true, NULL); }
void TempSummon::InitStats(uint32 duration) { ASSERT(!isPet()); m_timer = duration; m_lifetime = duration; if (m_type == TEMPSUMMON_MANUAL_DESPAWN) m_type = (duration == 0) ? TEMPSUMMON_DEAD_DESPAWN : TEMPSUMMON_TIMED_DESPAWN; Unit* owner = GetSummoner(); if (owner && isTrigger() && m_spells[0]) { setFaction(owner->getFaction()); SetLevel(owner->getLevel()); if (owner->GetTypeId() == TYPEID_PLAYER) m_ControlledByPlayer = true; } if (!m_Properties) return; // Fix Force of Nature treants stats if (owner && owner->getClass() == CLASS_DRUID && owner->HasSpell(106737)) { float damage = 0.0f; switch (GetEntry()) { case ENTRY_TREANT_RESTO: case ENTRY_TREANT_BALANCE: SetMaxHealth(owner->CountPctFromMaxHealth(40)); break; case ENTRY_TREANT_GUARDIAN: SetMaxHealth(owner->CountPctFromMaxHealth(40)); // (Attack power / 14 * 2 * 0.75) * 0.2f damage = ((owner->GetTotalAttackPowerValue(BASE_ATTACK) / 14.0f) * 2.0f * 0.75f) * 0.2f; SetStatFloatValue(UNIT_FIELD_MINDAMAGE, damage); SetStatFloatValue(UNIT_FIELD_MAXDAMAGE, damage); case ENTRY_TREANT_FERAL: SetMaxHealth(owner->CountPctFromMaxHealth(40)); // Attack power / 14 * 2 * 0.75 damage = (owner->GetTotalAttackPowerValue(BASE_ATTACK) / 14.0f) * 2.0f * 0.75f; SetStatFloatValue(UNIT_FIELD_MINDAMAGE, damage); SetStatFloatValue(UNIT_FIELD_MAXDAMAGE, damage); default: break; } } if (owner) { if (uint32 slot = m_Properties->Slot) { if (owner->m_SummonSlot[slot] && owner->m_SummonSlot[slot] != GetGUID()) { Creature* oldSummon = GetMap()->GetCreature(owner->m_SummonSlot[slot]); if (oldSummon && oldSummon->IsSummon()) oldSummon->ToTempSummon()->UnSummon(); } owner->m_SummonSlot[slot] = GetGUID(); } } if (m_Properties->Faction) setFaction(m_Properties->Faction); else if (IsVehicle() && owner) // properties should be vehicle setFaction(owner->getFaction()); }
void Absorb(AuraEffect* aurEff, DamageInfo & dmgInfo, uint32 & absorbAmount) { Unit* victim = GetTarget(); int32 remainingHealth = victim->GetHealth() - dmgInfo.GetDamage(); uint32 allowedHealth = victim->CountPctFromMaxHealth(35); //npcbot - calc for bots if (victim->GetTypeId() == TYPEID_UNIT/* && victim->ToCreature()->IsNPCBot()*/) { if (remainingHealth <= 0 && !victim->ToCreature()->GetSpellHistory()->HasCooldown(PAL_SPELL_ARDENT_DEFENDER_HEAL)) { // Cast healing spell, completely avoid damage absorbAmount = dmgInfo.GetDamage(); uint32 defenseSkillValue = victim->GetDefenseSkillValue(); // Max heal when defense skill denies critical hits from raid bosses // Formula: max defense at level + 140 (raiting from gear) uint32 reqDefForMaxHeal = victim->getLevel() * 5 + 140; float pctFromDefense = (defenseSkillValue >= reqDefForMaxHeal) ? 1.0f : float(defenseSkillValue) / float(reqDefForMaxHeal); int32 healAmount = int32(victim->CountPctFromMaxHealth(int32(healPct * pctFromDefense))); victim->CastCustomSpell(victim, PAL_SPELL_ARDENT_DEFENDER_HEAL, &healAmount, NULL, NULL, true, NULL, aurEff); victim->ToCreature()->AddBotSpellCooldown(PAL_SPELL_ARDENT_DEFENDER_HEAL, 120 * IN_MILLISECONDS); } else if (remainingHealth < int32(allowedHealth)) { // Reduce damage that brings us under 35% (or full damage if we are already under 35%) by x% uint32 damageToReduce = (victim->GetHealth() < allowedHealth) ? dmgInfo.GetDamage() : allowedHealth - remainingHealth; absorbAmount = CalculatePct(damageToReduce, absorbPct); } return; } //end npcbot // If damage kills us if (remainingHealth <= 0 && !victim->GetSpellHistory()->HasCooldown(PAL_SPELL_ARDENT_DEFENDER_HEAL)) { // Cast healing spell, completely avoid damage absorbAmount = dmgInfo.GetDamage(); uint32 defenseSkillValue = victim->GetDefenseSkillValue(); // Max heal when defense skill denies critical hits from raid bosses // Formula: max defense at level + 140 (raiting from gear) uint32 reqDefForMaxHeal = victim->getLevel() * 5 + 140; float pctFromDefense = (defenseSkillValue >= reqDefForMaxHeal) ? 1.0f : float(defenseSkillValue) / float(reqDefForMaxHeal); int32 healAmount = int32(victim->CountPctFromMaxHealth(uint32(healPct * pctFromDefense))); victim->CastCustomSpell(victim, PAL_SPELL_ARDENT_DEFENDER_HEAL, &healAmount, NULL, NULL, true, NULL, aurEff); victim->GetSpellHistory()->AddCooldown(PAL_SPELL_ARDENT_DEFENDER_HEAL, 0, std::chrono::minutes(2)); } else if (remainingHealth < int32(allowedHealth)) { // Reduce damage that brings us under 35% (or full damage if we are already under 35%) by x% uint32 damageToReduce = (victim->GetHealth() < allowedHealth) ? dmgInfo.GetDamage() : allowedHealth - remainingHealth; absorbAmount = CalculatePct(damageToReduce, absorbPct); } }