Created
November 26, 2012 17:58
-
-
Save saqirmdev/4149661 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Fix Cautarize Spell_mage.cpp | |
@40,58 && enum MageSpells | |
+ SPELL_MAGE_CAUTERIZE = 86949, | |
+ SPELL_MAGE_CAUTERIZE_DOT = 87023, | |
@78,1 && void(); | |
+// Cauterize | |
+class spell_mag_cauterize : public SpellScriptLoader | |
+{ | |
+ public: | |
+ spell_mag_cauterize() : SpellScriptLoader("spell_mag_cauterize") { } | |
+ | |
+ class spell_mag_cauterize_AuraScript : public AuraScript | |
+ { | |
+ PrepareAuraScript(spell_mag_cauterize_AuraScript); | |
+ | |
+ uint32 absorbChance; | |
+ | |
+ bool Validate(SpellInfo const* /*spellEntry*/) | |
+ { | |
+ if (!sSpellMgr->GetSpellInfo(SPELL_MAGE_CAUTERIZE)) | |
+ return false; | |
+ return true; | |
+ } | |
+ | |
+ bool Load() | |
+ { | |
+ absorbChance = GetSpellInfo()->Effects[EFFECT_0].CalcValue(); | |
+ return GetUnitOwner()->ToPlayer(); | |
+ } | |
+ | |
+ void CalculateAmount(AuraEffect const* /*aurEff*/, int32 & amount, bool & /*canBeRecalculated*/) | |
+ { | |
+ // Set absorbtion amount to unlimited | |
+ amount = -1; | |
+ } | |
+ | |
+ void Absorb(AuraEffect* /*aurEff*/, DamageInfo & dmgInfo, uint32 & absorbAmount) | |
+ { | |
+ Player* target = GetTarget()->ToPlayer(); | |
+ if (dmgInfo.GetDamage() < target->GetHealth() || target->HasSpellCooldown(SPELL_MAGE_CAUTERIZE) || !roll_chance_i(absorbChance)) | |
+ return; | |
+ | |
+ target->CastSpell(target, SPELL_MAGE_CAUTERIZE_DOT, true); | |
+ target->SetHealth(target->CountPctFromMaxHealth(40)); | |
+ target->AddSpellCooldown(SPELL_MAGE_CAUTERIZE, 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 Register() | |
+ { | |
+ DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_mag_cauterize_AuraScript::CalculateAmount, EFFECT_0, SPELL_AURA_SCHOOL_ABSORB); | |
+ OnEffectAbsorb += AuraEffectAbsorbFn(spell_mag_cauterize_AuraScript::Absorb, EFFECT_0); | |
+ } | |
+ }; | |
+ | |
+ AuraScript* GetAuraScript() const | |
+ { | |
+ return new spell_mag_cauterize_AuraScript(); | |
+ } | |
+ }; | |
@469,31 && void AddSC_mage_spell_scripts() | |
+ new spell_mag_cauterize(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment