| 1 | /* |
|---|
| 2 | * Copyright (C) 2008 Trinity <http://www.trinitycore.org/> |
|---|
| 3 | * |
|---|
| 4 | * Thanks to the original authors: MaNGOS <http://www.mangosproject.org/> |
|---|
| 5 | * |
|---|
| 6 | * This program is free software; you can redistribute it and/or modify |
|---|
| 7 | * it under the terms of the GNU General Public License as published by |
|---|
| 8 | * the Free Software Foundation; either version 2 of the License, or |
|---|
| 9 | * (at your option) any later version. |
|---|
| 10 | * |
|---|
| 11 | * This program is distributed in the hope that it will be useful, |
|---|
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 14 | * GNU General Public License for more details. |
|---|
| 15 | * |
|---|
| 16 | * You should have received a copy of the GNU General Public License |
|---|
| 17 | * along with this program; if not, write to the Free Software |
|---|
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 19 | */ |
|---|
| 20 | |
|---|
| 21 | #include "Common.h" |
|---|
| 22 | #include "Database/DatabaseEnv.h" |
|---|
| 23 | #include "WorldPacket.h" |
|---|
| 24 | #include "WorldSession.h" |
|---|
| 25 | #include "Opcodes.h" |
|---|
| 26 | #include "Log.h" |
|---|
| 27 | #include "UpdateMask.h" |
|---|
| 28 | #include "World.h" |
|---|
| 29 | #include "ObjectMgr.h" |
|---|
| 30 | #include "SpellMgr.h" |
|---|
| 31 | #include "Player.h" |
|---|
| 32 | #include "Unit.h" |
|---|
| 33 | #include "Spell.h" |
|---|
| 34 | #include "SpellAuras.h" |
|---|
| 35 | #include "DynamicObject.h" |
|---|
| 36 | #include "Group.h" |
|---|
| 37 | #include "UpdateData.h" |
|---|
| 38 | #include "MapManager.h" |
|---|
| 39 | #include "ObjectAccessor.h" |
|---|
| 40 | #include "Policies/SingletonImp.h" |
|---|
| 41 | #include "Totem.h" |
|---|
| 42 | #include "Creature.h" |
|---|
| 43 | #include "Formulas.h" |
|---|
| 44 | #include "BattleGround.h" |
|---|
| 45 | #include "OutdoorPvP.h" |
|---|
| 46 | #include "OutdoorPvPMgr.h" |
|---|
| 47 | #include "CreatureAI.h" |
|---|
| 48 | #include "Util.h" |
|---|
| 49 | #include "GridNotifiers.h" |
|---|
| 50 | #include "GridNotifiersImpl.h" |
|---|
| 51 | #include "CellImpl.h" |
|---|
| 52 | |
|---|
| 53 | #define NULL_AURA_SLOT 0xFF |
|---|
| 54 | |
|---|
| 55 | pAuraHandler AuraHandler[TOTAL_AURAS]= |
|---|
| 56 | { |
|---|
| 57 | &Aura::HandleNULL, // 0 SPELL_AURA_NONE |
|---|
| 58 | &Aura::HandleBindSight, // 1 SPELL_AURA_BIND_SIGHT |
|---|
| 59 | &Aura::HandleModPossess, // 2 SPELL_AURA_MOD_POSSESS |
|---|
| 60 | &Aura::HandlePeriodicDamage, // 3 SPELL_AURA_PERIODIC_DAMAGE |
|---|
| 61 | &Aura::HandleAuraDummy, // 4 SPELL_AURA_DUMMY |
|---|
| 62 | &Aura::HandleModConfuse, // 5 SPELL_AURA_MOD_CONFUSE |
|---|
| 63 | &Aura::HandleModCharm, // 6 SPELL_AURA_MOD_CHARM |
|---|
| 64 | &Aura::HandleModFear, // 7 SPELL_AURA_MOD_FEAR |
|---|
| 65 | &Aura::HandlePeriodicHeal, // 8 SPELL_AURA_PERIODIC_HEAL |
|---|
| 66 | &Aura::HandleModAttackSpeed, // 9 SPELL_AURA_MOD_ATTACKSPEED |
|---|
| 67 | &Aura::HandleModThreat, // 10 SPELL_AURA_MOD_THREAT |
|---|
| 68 | &Aura::HandleModTaunt, // 11 SPELL_AURA_MOD_TAUNT |
|---|
| 69 | &Aura::HandleAuraModStun, // 12 SPELL_AURA_MOD_STUN |
|---|
| 70 | &Aura::HandleModDamageDone, // 13 SPELL_AURA_MOD_DAMAGE_DONE |
|---|
| 71 | &Aura::HandleNoImmediateEffect, // 14 SPELL_AURA_MOD_DAMAGE_TAKEN implemented in Unit::MeleeDamageBonus and Unit::SpellDamageBonus |
|---|
| 72 | &Aura::HandleNoImmediateEffect, // 15 SPELL_AURA_DAMAGE_SHIELD implemented in Unit::DoAttackDamage |
|---|
| 73 | &Aura::HandleModStealth, // 16 SPELL_AURA_MOD_STEALTH |
|---|
| 74 | &Aura::HandleNoImmediateEffect, // 17 SPELL_AURA_MOD_STEALTH_DETECT |
|---|
| 75 | &Aura::HandleInvisibility, // 18 SPELL_AURA_MOD_INVISIBILITY |
|---|
| 76 | &Aura::HandleInvisibilityDetect, // 19 SPELL_AURA_MOD_INVISIBILITY_DETECTION |
|---|
| 77 | &Aura::HandleAuraModTotalHealthPercentRegen, // 20 SPELL_AURA_OBS_MOD_HEALTH |
|---|
| 78 | &Aura::HandleAuraModTotalManaPercentRegen, // 21 SPELL_AURA_OBS_MOD_MANA |
|---|
| 79 | &Aura::HandleAuraModResistance, // 22 SPELL_AURA_MOD_RESISTANCE |
|---|
| 80 | &Aura::HandlePeriodicTriggerSpell, // 23 SPELL_AURA_PERIODIC_TRIGGER_SPELL |
|---|
| 81 | &Aura::HandlePeriodicEnergize, // 24 SPELL_AURA_PERIODIC_ENERGIZE |
|---|
| 82 | &Aura::HandleAuraModPacify, // 25 SPELL_AURA_MOD_PACIFY |
|---|
| 83 | &Aura::HandleAuraModRoot, // 26 SPELL_AURA_MOD_ROOT |
|---|
| 84 | &Aura::HandleAuraModSilence, // 27 SPELL_AURA_MOD_SILENCE |
|---|
| 85 | &Aura::HandleNoImmediateEffect, // 28 SPELL_AURA_REFLECT_SPELLS implement in Unit::SpellHitResult |
|---|
| 86 | &Aura::HandleAuraModStat, // 29 SPELL_AURA_MOD_STAT |
|---|
| 87 | &Aura::HandleAuraModSkill, // 30 SPELL_AURA_MOD_SKILL |
|---|
| 88 | &Aura::HandleAuraModIncreaseSpeed, // 31 SPELL_AURA_MOD_INCREASE_SPEED |
|---|
| 89 | &Aura::HandleAuraModIncreaseMountedSpeed, // 32 SPELL_AURA_MOD_INCREASE_MOUNTED_SPEED |
|---|
| 90 | &Aura::HandleAuraModDecreaseSpeed, // 33 SPELL_AURA_MOD_DECREASE_SPEED |
|---|
| 91 | &Aura::HandleAuraModIncreaseHealth, // 34 SPELL_AURA_MOD_INCREASE_HEALTH |
|---|
| 92 | &Aura::HandleAuraModIncreaseEnergy, // 35 SPELL_AURA_MOD_INCREASE_ENERGY |
|---|
| 93 | &Aura::HandleAuraModShapeshift, // 36 SPELL_AURA_MOD_SHAPESHIFT |
|---|
| 94 | &Aura::HandleAuraModEffectImmunity, // 37 SPELL_AURA_EFFECT_IMMUNITY |
|---|
| 95 | &Aura::HandleAuraModStateImmunity, // 38 SPELL_AURA_STATE_IMMUNITY |
|---|
| 96 | &Aura::HandleAuraModSchoolImmunity, // 39 SPELL_AURA_SCHOOL_IMMUNITY |
|---|
| 97 | &Aura::HandleAuraModDmgImmunity, // 40 SPELL_AURA_DAMAGE_IMMUNITY |
|---|
| 98 | &Aura::HandleAuraModDispelImmunity, // 41 SPELL_AURA_DISPEL_IMMUNITY |
|---|
| 99 | &Aura::HandleAuraProcTriggerSpell, // 42 SPELL_AURA_PROC_TRIGGER_SPELL implemented in Unit::ProcDamageAndSpellFor and Unit::HandleProcTriggerSpell |
|---|
| 100 | &Aura::HandleNoImmediateEffect, // 43 SPELL_AURA_PROC_TRIGGER_DAMAGE implemented in Unit::ProcDamageAndSpellFor |
|---|
| 101 | &Aura::HandleAuraTrackCreatures, // 44 SPELL_AURA_TRACK_CREATURES |
|---|
| 102 | &Aura::HandleAuraTrackResources, // 45 SPELL_AURA_TRACK_RESOURCES |
|---|
| 103 | &Aura::HandleUnused, // 46 SPELL_AURA_MOD_PARRY_SKILL obsolete? |
|---|
| 104 | &Aura::HandleAuraModParryPercent, // 47 SPELL_AURA_MOD_PARRY_PERCENT |
|---|
| 105 | &Aura::HandleUnused, // 48 SPELL_AURA_MOD_DODGE_SKILL obsolete? |
|---|
| 106 | &Aura::HandleAuraModDodgePercent, // 49 SPELL_AURA_MOD_DODGE_PERCENT |
|---|
| 107 | &Aura::HandleUnused, // 50 SPELL_AURA_MOD_BLOCK_SKILL obsolete? |
|---|
| 108 | &Aura::HandleAuraModBlockPercent, // 51 SPELL_AURA_MOD_BLOCK_PERCENT |
|---|
| 109 | &Aura::HandleAuraModCritPercent, // 52 SPELL_AURA_MOD_CRIT_PERCENT |
|---|
| 110 | &Aura::HandlePeriodicLeech, // 53 SPELL_AURA_PERIODIC_LEECH |
|---|
| 111 | &Aura::HandleModHitChance, // 54 SPELL_AURA_MOD_HIT_CHANCE |
|---|
| 112 | &Aura::HandleModSpellHitChance, // 55 SPELL_AURA_MOD_SPELL_HIT_CHANCE |
|---|
| 113 | &Aura::HandleAuraTransform, // 56 SPELL_AURA_TRANSFORM |
|---|
| 114 | &Aura::HandleModSpellCritChance, // 57 SPELL_AURA_MOD_SPELL_CRIT_CHANCE |
|---|
| 115 | &Aura::HandleAuraModIncreaseSwimSpeed, // 58 SPELL_AURA_MOD_INCREASE_SWIM_SPEED |
|---|
| 116 | &Aura::HandleNoImmediateEffect, // 59 SPELL_AURA_MOD_DAMAGE_DONE_CREATURE implemented in Unit::MeleeDamageBonus and Unit::SpellDamageBonus |
|---|
| 117 | &Aura::HandleAuraModPacifyAndSilence, // 60 SPELL_AURA_MOD_PACIFY_SILENCE |
|---|
| 118 | &Aura::HandleAuraModScale, // 61 SPELL_AURA_MOD_SCALE |
|---|
| 119 | &Aura::HandleNULL, // 62 SPELL_AURA_PERIODIC_HEALTH_FUNNEL |
|---|
| 120 | &Aura::HandleUnused, // 63 SPELL_AURA_PERIODIC_MANA_FUNNEL obsolete? |
|---|
| 121 | &Aura::HandlePeriodicManaLeech, // 64 SPELL_AURA_PERIODIC_MANA_LEECH |
|---|
| 122 | &Aura::HandleModCastingSpeed, // 65 SPELL_AURA_MOD_CASTING_SPEED |
|---|
| 123 | &Aura::HandleFeignDeath, // 66 SPELL_AURA_FEIGN_DEATH |
|---|
| 124 | &Aura::HandleAuraModDisarm, // 67 SPELL_AURA_MOD_DISARM |
|---|
| 125 | &Aura::HandleAuraModStalked, // 68 SPELL_AURA_MOD_STALKED |
|---|
| 126 | &Aura::HandleSchoolAbsorb, // 69 SPELL_AURA_SCHOOL_ABSORB implemented in Unit::CalcAbsorbResist |
|---|
| 127 | &Aura::HandleUnused, // 70 SPELL_AURA_EXTRA_ATTACKS Useless, used by only one spell that has only visual effect |
|---|
| 128 | &Aura::HandleModSpellCritChanceShool, // 71 SPELL_AURA_MOD_SPELL_CRIT_CHANCE_SCHOOL |
|---|
| 129 | &Aura::HandleModPowerCostPCT, // 72 SPELL_AURA_MOD_POWER_COST_SCHOOL_PCT |
|---|
| 130 | &Aura::HandleModPowerCost, // 73 SPELL_AURA_MOD_POWER_COST_SCHOOL |
|---|
| 131 | &Aura::HandleNoImmediateEffect, // 74 SPELL_AURA_REFLECT_SPELLS_SCHOOL implemented in Unit::SpellHitResult |
|---|
| 132 | &Aura::HandleNoImmediateEffect, // 75 SPELL_AURA_MOD_LANGUAGE |
|---|
| 133 | &Aura::HandleFarSight, // 76 SPELL_AURA_FAR_SIGHT |
|---|
| 134 | &Aura::HandleModMechanicImmunity, // 77 SPELL_AURA_MECHANIC_IMMUNITY |
|---|
| 135 | &Aura::HandleAuraMounted, // 78 SPELL_AURA_MOUNTED |
|---|
| 136 | &Aura::HandleModDamagePercentDone, // 79 SPELL_AURA_MOD_DAMAGE_PERCENT_DONE |
|---|
| 137 | &Aura::HandleModPercentStat, // 80 SPELL_AURA_MOD_PERCENT_STAT |
|---|
| 138 | &Aura::HandleNoImmediateEffect, // 81 SPELL_AURA_SPLIT_DAMAGE_PCT |
|---|
| 139 | &Aura::HandleWaterBreathing, // 82 SPELL_AURA_WATER_BREATHING |
|---|
| 140 | &Aura::HandleModBaseResistance, // 83 SPELL_AURA_MOD_BASE_RESISTANCE |
|---|
| 141 | &Aura::HandleModRegen, // 84 SPELL_AURA_MOD_REGEN |
|---|
| 142 | &Aura::HandleModPowerRegen, // 85 SPELL_AURA_MOD_POWER_REGEN |
|---|
| 143 | &Aura::HandleChannelDeathItem, // 86 SPELL_AURA_CHANNEL_DEATH_ITEM |
|---|
| 144 | &Aura::HandleNoImmediateEffect, // 87 SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN implemented in Unit::MeleeDamageBonus and Unit::SpellDamageBonus |
|---|
| 145 | &Aura::HandleNoImmediateEffect, // 88 SPELL_AURA_MOD_HEALTH_REGEN_PERCENT |
|---|
| 146 | &Aura::HandlePeriodicDamagePCT, // 89 SPELL_AURA_PERIODIC_DAMAGE_PERCENT |
|---|
| 147 | &Aura::HandleUnused, // 90 SPELL_AURA_MOD_RESIST_CHANCE Useless |
|---|
| 148 | &Aura::HandleNoImmediateEffect, // 91 SPELL_AURA_MOD_DETECT_RANGE implemented in Creature::GetAttackDistance |
|---|
| 149 | &Aura::HandlePreventFleeing, // 92 SPELL_AURA_PREVENTS_FLEEING |
|---|
| 150 | &Aura::HandleModUnattackable, // 93 SPELL_AURA_MOD_UNATTACKABLE |
|---|
| 151 | &Aura::HandleNoImmediateEffect, // 94 SPELL_AURA_INTERRUPT_REGEN implemented in Player::RegenerateAll |
|---|
| 152 | &Aura::HandleAuraGhost, // 95 SPELL_AURA_GHOST |
|---|
| 153 | &Aura::HandleNoImmediateEffect, // 96 SPELL_AURA_SPELL_MAGNET implemented in Spell::SelectMagnetTarget |
|---|
| 154 | &Aura::HandleManaShield, // 97 SPELL_AURA_MANA_SHIELD implemented in Unit::CalcAbsorbResist |
|---|
| 155 | &Aura::HandleAuraModSkill, // 98 SPELL_AURA_MOD_SKILL_TALENT |
|---|
| 156 | &Aura::HandleAuraModAttackPower, // 99 SPELL_AURA_MOD_ATTACK_POWER |
|---|
| 157 | &Aura::HandleUnused, //100 SPELL_AURA_AURAS_VISIBLE obsolete? all player can see all auras now |
|---|
| 158 | &Aura::HandleModResistancePercent, //101 SPELL_AURA_MOD_RESISTANCE_PCT |
|---|
| 159 | &Aura::HandleNoImmediateEffect, //102 SPELL_AURA_MOD_MELEE_ATTACK_POWER_VERSUS implemented in Unit::MeleeDamageBonus |
|---|
| 160 | &Aura::HandleAuraModTotalThreat, //103 SPELL_AURA_MOD_TOTAL_THREAT |
|---|
| 161 | &Aura::HandleAuraWaterWalk, //104 SPELL_AURA_WATER_WALK |
|---|
| 162 | &Aura::HandleAuraFeatherFall, //105 SPELL_AURA_FEATHER_FALL |
|---|
| 163 | &Aura::HandleAuraHover, //106 SPELL_AURA_HOVER |
|---|
| 164 | &Aura::HandleAddModifier, //107 SPELL_AURA_ADD_FLAT_MODIFIER |
|---|
| 165 | &Aura::HandleAddModifier, //108 SPELL_AURA_ADD_PCT_MODIFIER |
|---|
| 166 | &Aura::HandleNoImmediateEffect, //109 SPELL_AURA_ADD_TARGET_TRIGGER |
|---|
| 167 | &Aura::HandleModPowerRegenPCT, //110 SPELL_AURA_MOD_POWER_REGEN_PERCENT |
|---|
| 168 | &Aura::HandleNULL, //111 SPELL_AURA_ADD_CASTER_HIT_TRIGGER |
|---|
| 169 | &Aura::HandleNoImmediateEffect, //112 SPELL_AURA_OVERRIDE_CLASS_SCRIPTS |
|---|
| 170 | &Aura::HandleNoImmediateEffect, //113 SPELL_AURA_MOD_RANGED_DAMAGE_TAKEN implemented in Unit::MeleeDamageBonus |
|---|
| 171 | &Aura::HandleNoImmediateEffect, //114 SPELL_AURA_MOD_RANGED_DAMAGE_TAKEN_PCT implemented in Unit::MeleeDamageBonus |
|---|
| 172 | &Aura::HandleAuraHealing, //115 SPELL_AURA_MOD_HEALING |
|---|
| 173 | &Aura::HandleNoImmediateEffect, //116 SPELL_AURA_MOD_REGEN_DURING_COMBAT |
|---|
| 174 | &Aura::HandleNoImmediateEffect, //117 SPELL_AURA_MOD_MECHANIC_RESISTANCE implemented in Unit::MagicSpellHitResult |
|---|
| 175 | &Aura::HandleAuraHealingPct, //118 SPELL_AURA_MOD_HEALING_PCT |
|---|
| 176 | &Aura::HandleUnused, //119 SPELL_AURA_SHARE_PET_TRACKING useless |
|---|
| 177 | &Aura::HandleAuraUntrackable, //120 SPELL_AURA_UNTRACKABLE |
|---|
| 178 | &Aura::HandleAuraEmpathy, //121 SPELL_AURA_EMPATHY |
|---|
| 179 | &Aura::HandleModOffhandDamagePercent, //122 SPELL_AURA_MOD_OFFHAND_DAMAGE_PCT |
|---|
| 180 | &Aura::HandleModTargetResistance, //123 SPELL_AURA_MOD_TARGET_RESISTANCE |
|---|
| 181 | &Aura::HandleAuraModRangedAttackPower, //124 SPELL_AURA_MOD_RANGED_ATTACK_POWER |
|---|
| 182 | &Aura::HandleNoImmediateEffect, //125 SPELL_AURA_MOD_MELEE_DAMAGE_TAKEN implemented in Unit::MeleeDamageBonus |
|---|
| 183 | &Aura::HandleNoImmediateEffect, //126 SPELL_AURA_MOD_MELEE_DAMAGE_TAKEN_PCT implemented in Unit::MeleeDamageBonus |
|---|
| 184 | &Aura::HandleNoImmediateEffect, //127 SPELL_AURA_RANGED_ATTACK_POWER_ATTACKER_BONUS implemented in Unit::MeleeDamageBonus |
|---|
| 185 | &Aura::HandleModPossessPet, //128 SPELL_AURA_MOD_POSSESS_PET |
|---|
| 186 | &Aura::HandleAuraModIncreaseSpeed, //129 SPELL_AURA_MOD_SPEED_ALWAYS |
|---|
| 187 | &Aura::HandleAuraModIncreaseMountedSpeed, //130 SPELL_AURA_MOD_MOUNTED_SPEED_ALWAYS |
|---|
| 188 | &Aura::HandleNoImmediateEffect, //131 SPELL_AURA_MOD_RANGED_ATTACK_POWER_VERSUS implemented in Unit::MeleeDamageBonus |
|---|
| 189 | &Aura::HandleAuraModIncreaseEnergyPercent, //132 SPELL_AURA_MOD_INCREASE_ENERGY_PERCENT |
|---|
| 190 | &Aura::HandleAuraModIncreaseHealthPercent, //133 SPELL_AURA_MOD_INCREASE_HEALTH_PERCENT |
|---|
| 191 | &Aura::HandleAuraModRegenInterrupt, //134 SPELL_AURA_MOD_MANA_REGEN_INTERRUPT |
|---|
| 192 | &Aura::HandleModHealingDone, //135 SPELL_AURA_MOD_HEALING_DONE |
|---|
| 193 | &Aura::HandleAuraHealingPct, //136 SPELL_AURA_MOD_HEALING_DONE_PERCENT implemented in Unit::SpellHealingBonus |
|---|
| 194 | &Aura::HandleModTotalPercentStat, //137 SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE |
|---|
| 195 | &Aura::HandleHaste, //138 SPELL_AURA_MOD_HASTE |
|---|
| 196 | &Aura::HandleForceReaction, //139 SPELL_AURA_FORCE_REACTION |
|---|
| 197 | &Aura::HandleAuraModRangedHaste, //140 SPELL_AURA_MOD_RANGED_HASTE |
|---|
| 198 | &Aura::HandleRangedAmmoHaste, //141 SPELL_AURA_MOD_RANGED_AMMO_HASTE |
|---|
| 199 | &Aura::HandleAuraModBaseResistancePCT, //142 SPELL_AURA_MOD_BASE_RESISTANCE_PCT |
|---|
| 200 | &Aura::HandleAuraModResistanceExclusive, //143 SPELL_AURA_MOD_RESISTANCE_EXCLUSIVE |
|---|
| 201 | &Aura::HandleNoImmediateEffect, //144 SPELL_AURA_SAFE_FALL implemented in WorldSession::HandleMovementOpcodes |
|---|
| 202 | &Aura::HandleUnused, //145 SPELL_AURA_CHARISMA obsolete? |
|---|
| 203 | &Aura::HandleUnused, //146 SPELL_AURA_PERSUADED obsolete? |
|---|
| 204 | &Aura::HandleNULL, //147 SPELL_AURA_ADD_CREATURE_IMMUNITY |
|---|
| 205 | &Aura::HandleAuraRetainComboPoints, //148 SPELL_AURA_RETAIN_COMBO_POINTS |
|---|
| 206 | &Aura::HandleNoImmediateEffect, //149 SPELL_AURA_RESIST_PUSHBACK |
|---|
| 207 | &Aura::HandleShieldBlockValue, //150 SPELL_AURA_MOD_SHIELD_BLOCKVALUE_PCT |
|---|
| 208 | &Aura::HandleAuraTrackStealthed, //151 SPELL_AURA_TRACK_STEALTHED |
|---|
| 209 | &Aura::HandleNoImmediateEffect, //152 SPELL_AURA_MOD_DETECTED_RANGE implemented in Creature::GetAttackDistance |
|---|
| 210 | &Aura::HandleNoImmediateEffect, //153 SPELL_AURA_SPLIT_DAMAGE_FLAT |
|---|
| 211 | &Aura::HandleNoImmediateEffect, //154 SPELL_AURA_MOD_STEALTH_LEVEL |
|---|
| 212 | &Aura::HandleNoImmediateEffect, //155 SPELL_AURA_MOD_WATER_BREATHING |
|---|
| 213 | &Aura::HandleNoImmediateEffect, //156 SPELL_AURA_MOD_REPUTATION_GAIN |
|---|
| 214 | &Aura::HandleNULL, //157 SPELL_AURA_PET_DAMAGE_MULTI |
|---|
| 215 | &Aura::HandleShieldBlockValue, //158 SPELL_AURA_MOD_SHIELD_BLOCKVALUE |
|---|
| 216 | &Aura::HandleNoImmediateEffect, //159 SPELL_AURA_NO_PVP_CREDIT only for Honorless Target spell |
|---|
| 217 | &Aura::HandleNoImmediateEffect, //160 SPELL_AURA_MOD_AOE_AVOIDANCE implemended in Unit::MagicSpellHitResult |
|---|
| 218 | &Aura::HandleNoImmediateEffect, //161 SPELL_AURA_MOD_HEALTH_REGEN_IN_COMBAT |
|---|
| 219 | &Aura::HandleAuraPowerBurn, //162 SPELL_AURA_POWER_BURN_MANA |
|---|
| 220 | &Aura::HandleNoImmediateEffect, //163 SPELL_AURA_MOD_CRIT_DAMAGE_BONUS_MELEE |
|---|
| 221 | &Aura::HandleUnused, //164 useless, only one test spell |
|---|
| 222 | &Aura::HandleAuraAttackPowerAttacker, //165 SPELL_AURA_MELEE_ATTACK_POWER_ATTACKER_BONUS implemented in Unit::MeleeDamageBonus |
|---|
| 223 | &Aura::HandleAuraModAttackPowerPercent, //166 SPELL_AURA_MOD_ATTACK_POWER_PCT |
|---|
| 224 | &Aura::HandleAuraModRangedAttackPowerPercent, //167 SPELL_AURA_MOD_RANGED_ATTACK_POWER_PCT |
|---|
| 225 | &Aura::HandleNoImmediateEffect, //168 SPELL_AURA_MOD_DAMAGE_DONE_VERSUS implemented in Unit::SpellDamageBonus, Unit::MeleeDamageBonus |
|---|
| 226 | &Aura::HandleNoImmediateEffect, //169 SPELL_AURA_MOD_CRIT_PERCENT_VERSUS implemented in Unit::DealDamageBySchool, Unit::DoAttackDamage, Unit::SpellCriticalBonus |
|---|
| 227 | &Aura::HandleNULL, //170 SPELL_AURA_DETECT_AMORE only for Detect Amore spell |
|---|
| 228 | &Aura::HandleAuraModIncreaseSpeed, //171 SPELL_AURA_MOD_SPEED_NOT_STACK |
|---|
| 229 | &Aura::HandleAuraModIncreaseMountedSpeed, //172 SPELL_AURA_MOD_MOUNTED_SPEED_NOT_STACK |
|---|
| 230 | &Aura::HandleUnused, //173 SPELL_AURA_ALLOW_CHAMPION_SPELLS only for Proclaim Champion spell |
|---|
| 231 | &Aura::HandleModSpellDamagePercentFromStat, //174 SPELL_AURA_MOD_SPELL_DAMAGE_OF_STAT_PERCENT implemented in Unit::SpellBaseDamageBonus (by defeult intelect, dependent from SPELL_AURA_MOD_SPELL_HEALING_OF_STAT_PERCENT) |
|---|
| 232 | &Aura::HandleModSpellHealingPercentFromStat, //175 SPELL_AURA_MOD_SPELL_HEALING_OF_STAT_PERCENT implemented in Unit::SpellBaseHealingBonus |
|---|
| 233 | &Aura::HandleSpiritOfRedemption, //176 SPELL_AURA_SPIRIT_OF_REDEMPTION only for Spirit of Redemption spell, die at aura end |
|---|
| 234 | &Aura::HandleNULL, //177 SPELL_AURA_AOE_CHARM |
|---|
| 235 | &Aura::HandleNoImmediateEffect, //178 SPELL_AURA_MOD_DEBUFF_RESISTANCE implemented in Unit::MagicSpellHitResult |
|---|
| 236 | &Aura::HandleNoImmediateEffect, //179 SPELL_AURA_MOD_ATTACKER_SPELL_CRIT_CHANCE implemented in Unit::SpellCriticalBonus |
|---|
| 237 | &Aura::HandleNoImmediateEffect, //180 SPELL_AURA_MOD_FLAT_SPELL_DAMAGE_VERSUS implemented in Unit::SpellDamageBonus |
|---|
| 238 | &Aura::HandleUnused, //181 SPELL_AURA_MOD_FLAT_SPELL_CRIT_DAMAGE_VERSUS unused |
|---|
| 239 | &Aura::HandleAuraModResistenceOfStatPercent, //182 SPELL_AURA_MOD_RESISTANCE_OF_STAT_PERCENT |
|---|
| 240 | &Aura::HandleNULL, //183 SPELL_AURA_MOD_CRITICAL_THREAT |
|---|
| 241 | &Aura::HandleNoImmediateEffect, //184 SPELL_AURA_MOD_ATTACKER_MELEE_HIT_CHANCE implemented in Unit::RollMeleeOutcomeAgainst |
|---|
| 242 | &Aura::HandleNoImmediateEffect, //185 SPELL_AURA_MOD_ATTACKER_RANGED_HIT_CHANCE implemented in Unit::RollMeleeOutcomeAgainst |
|---|
| 243 | &Aura::HandleNoImmediateEffect, //186 SPELL_AURA_MOD_ATTACKER_SPELL_HIT_CHANCE implemented in Unit::MagicSpellHitResult |
|---|
| 244 | &Aura::HandleNoImmediateEffect, //187 SPELL_AURA_MOD_ATTACKER_MELEE_CRIT_CHANCE implemended in Unit::GetUnitCriticalChance |
|---|
| 245 | &Aura::HandleNoImmediateEffect, //188 SPELL_AURA_MOD_ATTACKER_RANGED_CRIT_CHANCE implemented in Unit::GetUnitCriticalChance |
|---|
| 246 | &Aura::HandleModRating, //189 SPELL_AURA_MOD_RATING |
|---|
| 247 | &Aura::HandleNULL, //190 SPELL_AURA_MOD_FACTION_REPUTATION_GAIN |
|---|
| 248 | &Aura::HandleAuraModUseNormalSpeed, //191 SPELL_AURA_USE_NORMAL_MOVEMENT_SPEED |
|---|
| 249 | &Aura::HandleModMeleeRangedSpeedPct, //192 SPELL_AURA_HASTE_MELEE |
|---|
| 250 | &Aura::HandleModCombatSpeedPct, //193 SPELL_AURA_MELEE_SLOW (in fact combat (any type attack) speed pct) |
|---|
| 251 | &Aura::HandleUnused, //194 SPELL_AURA_MOD_DEPRICATED_1 not used now (old SPELL_AURA_MOD_SPELL_DAMAGE_OF_INTELLECT) |
|---|
| 252 | &Aura::HandleUnused, //195 SPELL_AURA_MOD_DEPRICATED_2 not used now (old SPELL_AURA_MOD_SPELL_HEALING_OF_INTELLECT) |
|---|
| 253 | &Aura::HandleNULL, //196 SPELL_AURA_MOD_COOLDOWN |
|---|
| 254 | &Aura::HandleNoImmediateEffect, //197 SPELL_AURA_MOD_ATTACKER_SPELL_AND_WEAPON_CRIT_CHANCE implemented in Unit::SpellCriticalBonus Unit::GetUnitCriticalChance |
|---|
| 255 | &Aura::HandleUnused, //198 SPELL_AURA_MOD_ALL_WEAPON_SKILLS |
|---|
| 256 | &Aura::HandleNoImmediateEffect, //199 SPELL_AURA_MOD_INCREASES_SPELL_PCT_TO_HIT implemented in Unit::MagicSpellHitResult |
|---|
| 257 | &Aura::HandleNoImmediateEffect, //200 SPELL_AURA_MOD_XP_PCT implemented in Player::GiveXP |
|---|
| 258 | &Aura::HandleAuraAllowFlight, //201 SPELL_AURA_FLY this aura enable flight mode... |
|---|
| 259 | &Aura::HandleNoImmediateEffect, //202 SPELL_AURA_CANNOT_BE_DODGED implemented in Unit::RollPhysicalOutcomeAgainst |
|---|
| 260 | &Aura::HandleNoImmediateEffect, //203 SPELL_AURA_MOD_ATTACKER_MELEE_CRIT_DAMAGE implemented in Unit::DoAttackDamage |
|---|
| 261 | &Aura::HandleNoImmediateEffect, //204 SPELL_AURA_MOD_ATTACKER_RANGED_CRIT_DAMAGE implemented in Unit::DoAttackDamage |
|---|
| 262 | &Aura::HandleNULL, //205 vulnerable to school dmg? |
|---|
| 263 | &Aura::HandleNULL, //206 SPELL_AURA_MOD_SPEED_MOUNTED |
|---|
| 264 | &Aura::HandleAuraModIncreaseFlightSpeed, //207 SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED |
|---|
| 265 | &Aura::HandleAuraModIncreaseFlightSpeed, //208 SPELL_AURA_MOD_SPEED_FLIGHT, used only in spell: Flight Form (Passive) |
|---|
| 266 | &Aura::HandleAuraModIncreaseFlightSpeed, //209 SPELL_AURA_MOD_FLIGHT_SPEED_ALWAYS |
|---|
| 267 | &Aura::HandleNULL, //210 Commentator's Command |
|---|
| 268 | &Aura::HandleAuraModIncreaseFlightSpeed, //211 SPELL_AURA_MOD_FLIGHT_SPEED_NOT_STACK |
|---|
| 269 | &Aura::HandleAuraModRangedAttackPowerOfStatPercent, //212 SPELL_AURA_MOD_RANGED_ATTACK_POWER_OF_STAT_PERCENT |
|---|
| 270 | &Aura::HandleNoImmediateEffect, //213 SPELL_AURA_MOD_RAGE_FROM_DAMAGE_DEALT implemented in Player::RewardRage |
|---|
| 271 | &Aura::HandleNULL, //214 Tamed Pet Passive |
|---|
| 272 | &Aura::HandleArenaPreparation, //215 SPELL_AURA_ARENA_PREPARATION |
|---|
| 273 | &Aura::HandleModCastingSpeed, //216 SPELL_AURA_HASTE_SPELLS |
|---|
| 274 | &Aura::HandleUnused, //217 unused |
|---|
| 275 | &Aura::HandleAuraModRangedHaste, //218 SPELL_AURA_HASTE_RANGED |
|---|
| 276 | &Aura::HandleModManaRegen, //219 SPELL_AURA_MOD_MANA_REGEN_FROM_STAT |
|---|
| 277 | &Aura::HandleNULL, //220 SPELL_AURA_MOD_RATING_FROM_STAT |
|---|
| 278 | &Aura::HandleNULL, //221 ignored |
|---|
| 279 | &Aura::HandleUnused, //222 unused |
|---|
| 280 | &Aura::HandleNULL, //223 Cold Stare |
|---|
| 281 | &Aura::HandleUnused, //224 unused |
|---|
| 282 | &Aura::HandleNoImmediateEffect, //225 SPELL_AURA_PRAYER_OF_MENDING |
|---|
| 283 | &Aura::HandleAuraPeriodicDummy, //226 SPELL_AURA_PERIODIC_DUMMY |
|---|
| 284 | &Aura::HandleNULL, //227 periodic trigger spell |
|---|
| 285 | &Aura::HandleNoImmediateEffect, //228 stealth detection |
|---|
| 286 | &Aura::HandleNULL, //229 SPELL_AURA_MOD_AOE_DAMAGE_AVOIDANCE |
|---|
| 287 | &Aura::HandleAuraModIncreaseMaxHealth, //230 Commanding Shout |
|---|
| 288 | &Aura::HandleNULL, //231 |
|---|
| 289 | &Aura::HandleNoImmediateEffect, //232 SPELL_AURA_MECHANIC_DURATION_MOD implement in Unit::CalculateSpellDuration |
|---|
| 290 | &Aura::HandleNULL, //233 set model id to the one of the creature with id m_modifier.m_miscvalue |
|---|
| 291 | &Aura::HandleNoImmediateEffect, //234 SPELL_AURA_MECHANIC_DURATION_MOD_NOT_STACK implement in Unit::CalculateSpellDuration |
|---|
| 292 | &Aura::HandleAuraModDispelResist, //235 SPELL_AURA_MOD_DISPEL_RESIST implement in Unit::MagicSpellHitResult |
|---|
| 293 | &Aura::HandleUnused, //236 unused |
|---|
| 294 | &Aura::HandleModSpellDamagePercentFromAttackPower, //237 SPELL_AURA_MOD_SPELL_DAMAGE_OF_ATTACK_POWER implemented in Unit::SpellBaseDamageBonus |
|---|
| 295 | &Aura::HandleModSpellHealingPercentFromAttackPower, //238 SPELL_AURA_MOD_SPELL_HEALING_OF_ATTACK_POWER implemented in Unit::SpellBaseHealingBonus |
|---|
| 296 | &Aura::HandleAuraModScale, //239 SPELL_AURA_MOD_SCALE_2 only in Noggenfogger Elixir (16595) before 2.3.0 aura 61 |
|---|
| 297 | &Aura::HandleAuraModExpertise, //240 SPELL_AURA_MOD_EXPERTISE |
|---|
| 298 | &Aura::HandleForceMoveForward, //241 Forces the player to move forward |
|---|
| 299 | &Aura::HandleUnused, //242 SPELL_AURA_MOD_SPELL_DAMAGE_FROM_HEALING |
|---|
| 300 | &Aura::HandleUnused, //243 used by two test spells |
|---|
| 301 | &Aura::HandleComprehendLanguage, //244 Comprehend language |
|---|
| 302 | &Aura::HandleUnused, //245 SPELL_AURA_MOD_DURATION_OF_MAGIC_EFFECTS |
|---|
| 303 | &Aura::HandleUnused, //246 unused |
|---|
| 304 | &Aura::HandleUnused, //247 unused |
|---|
| 305 | &Aura::HandleNoImmediateEffect, //248 SPELL_AURA_MOD_COMBAT_RESULT_CHANCE implemented in Unit::RollMeleeOutcomeAgainst |
|---|
| 306 | &Aura::HandleNULL, //249 |
|---|
| 307 | &Aura::HandleAuraModIncreaseHealth, //250 SPELL_AURA_MOD_INCREASE_HEALTH_2 |
|---|
| 308 | &Aura::HandleNULL, //251 SPELL_AURA_MOD_ENEMY_DODGE |
|---|
| 309 | &Aura::HandleUnused, //252 unused |
|---|
| 310 | &Aura::HandleUnused, //253 unused |
|---|
| 311 | &Aura::HandleUnused, //254 unused |
|---|
| 312 | &Aura::HandleUnused, //255 unused |
|---|
| 313 | &Aura::HandleUnused, //256 unused |
|---|
| 314 | &Aura::HandleUnused, //257 unused |
|---|
| 315 | &Aura::HandleUnused, //258 unused |
|---|
| 316 | &Aura::HandleUnused, //259 unused |
|---|
| 317 | &Aura::HandleUnused, //260 unused |
|---|
| 318 | &Aura::HandleNULL //261 SPELL_AURA_261 some phased state (44856 spell) |
|---|
| 319 | }; |
|---|
| 320 | |
|---|
| 321 | Aura::Aura(SpellEntry const* spellproto, uint32 eff, int32 *currentBasePoints, Unit *target, Unit *caster, Item* castItem) : |
|---|
| 322 | m_procCharges(0), m_spellmod(NULL), m_effIndex(eff), m_caster_guid(0), m_target(target), |
|---|
| 323 | m_timeCla(1000), m_castItemGuid(castItem?castItem->GetGUID():0), m_auraSlot(MAX_AURAS), |
|---|
| 324 | m_positive(false), m_permanent(false), m_isPeriodic(false), m_isTrigger(false), m_isAreaAura(false), |
|---|
| 325 | m_isPersistent(false), m_updated(false), m_removeMode(AURA_REMOVE_BY_DEFAULT), m_isRemovedOnShapeLost(true), m_in_use(false), |
|---|
| 326 | m_periodicTimer(0), m_PeriodicEventId(0), m_AuraDRGroup(DIMINISHING_NONE) |
|---|
| 327 | { |
|---|
| 328 | assert(target); |
|---|
| 329 | |
|---|
| 330 | assert(spellproto && spellproto == sSpellStore.LookupEntry( spellproto->Id ) && "`info` must be pointer to sSpellStore element"); |
|---|
| 331 | |
|---|
| 332 | m_spellProto = spellproto; |
|---|
| 333 | |
|---|
| 334 | m_currentBasePoints = currentBasePoints ? *currentBasePoints : m_spellProto->EffectBasePoints[eff]; |
|---|
| 335 | |
|---|
| 336 | m_isPassive = IsPassiveSpell(GetId()); |
|---|
| 337 | m_positive = IsPositiveEffect(GetId(), m_effIndex); |
|---|
| 338 | |
|---|
| 339 | m_applyTime = time(NULL); |
|---|
| 340 | |
|---|
| 341 | int32 damage; |
|---|
| 342 | if(!caster) |
|---|
| 343 | { |
|---|
| 344 | m_caster_guid = target->GetGUID(); |
|---|
| 345 | damage = m_currentBasePoints+1; // stored value-1 |
|---|
| 346 | m_maxduration = target->CalculateSpellDuration(m_spellProto, m_effIndex, target); |
|---|
| 347 | } |
|---|
| 348 | else |
|---|
| 349 | { |
|---|
| 350 | m_caster_guid = caster->GetGUID(); |
|---|
| 351 | |
|---|
| 352 | damage = caster->CalculateSpellDamage(m_spellProto,m_effIndex,m_currentBasePoints,target); |
|---|
| 353 | m_maxduration = caster->CalculateSpellDuration(m_spellProto, m_effIndex, target); |
|---|
| 354 | |
|---|
| 355 | if (!damage && castItem && castItem->GetItemSuffixFactor()) |
|---|
| 356 | { |
|---|
| 357 | ItemRandomSuffixEntry const *item_rand_suffix = sItemRandomSuffixStore.LookupEntry(abs(castItem->GetItemRandomPropertyId())); |
|---|
| 358 | if(item_rand_suffix) |
|---|
| 359 | { |
|---|
| 360 | for (int k=0; k<3; k++) |
|---|
| 361 | { |
|---|
| 362 | SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(item_rand_suffix->enchant_id[k]); |
|---|
| 363 | if(pEnchant) |
|---|
| 364 | { |
|---|
| 365 | for (int t=0; t<3; t++) |
|---|
| 366 | if(pEnchant->spellid[t] == m_spellProto->Id) |
|---|
| 367 | { |
|---|
| 368 | damage = uint32((item_rand_suffix->prefix[k]*castItem->GetItemSuffixFactor()) / 10000 ); |
|---|
| 369 | break; |
|---|
| 370 | } |
|---|
| 371 | } |
|---|
| 372 | |
|---|
| 373 | if(damage) |
|---|
| 374 | break; |
|---|
| 375 | } |
|---|
| 376 | } |
|---|
| 377 | } |
|---|
| 378 | } |
|---|
| 379 | |
|---|
| 380 | if(m_maxduration == -1 || m_isPassive && m_spellProto->DurationIndex == 0) |
|---|
| 381 | m_permanent = true; |
|---|
| 382 | |
|---|
| 383 | Player* modOwner = caster ? caster->GetSpellModOwner() : NULL; |
|---|
| 384 | |
|---|
| 385 | if(!m_permanent && modOwner) |
|---|
| 386 | modOwner->ApplySpellMod(GetId(), SPELLMOD_DURATION, m_maxduration); |
|---|
| 387 | |
|---|
| 388 | m_duration = m_maxduration; |
|---|
| 389 | |
|---|
| 390 | if(modOwner) |
|---|
| 391 | modOwner->ApplySpellMod(GetId(), SPELLMOD_ACTIVATION_TIME, m_periodicTimer); |
|---|
| 392 | |
|---|
| 393 | sLog.outDebug("Aura: construct Spellid : %u, Aura : %u Duration : %d Target : %d Damage : %d", m_spellProto->Id, m_spellProto->EffectApplyAuraName[eff], m_maxduration, m_spellProto->EffectImplicitTargetA[eff],damage); |
|---|
| 394 | |
|---|
| 395 | m_effIndex = eff; |
|---|
| 396 | SetModifier(AuraType(m_spellProto->EffectApplyAuraName[eff]), damage, m_spellProto->EffectAmplitude[eff], m_spellProto->EffectMiscValue[eff]); |
|---|
| 397 | |
|---|
| 398 | m_isDeathPersist = IsDeathPersistentSpell(m_spellProto); |
|---|
| 399 | |
|---|
| 400 | if(m_spellProto->procCharges) |
|---|
| 401 | { |
|---|
| 402 | m_procCharges = m_spellProto->procCharges; |
|---|
| 403 | |
|---|
| 404 | if(modOwner) |
|---|
| 405 | modOwner->ApplySpellMod(GetId(), SPELLMOD_CHARGES, m_procCharges); |
|---|
| 406 | } |
|---|
| 407 | else |
|---|
| 408 | m_procCharges = -1; |
|---|
| 409 | |
|---|
| 410 | m_isRemovedOnShapeLost = (m_caster_guid==m_target->GetGUID() && m_spellProto->Stances && |
|---|
| 411 | !(m_spellProto->AttributesEx2 & 0x80000) && !(m_spellProto->Attributes & 0x10000)); |
|---|
| 412 | } |
|---|
| 413 | |
|---|
| 414 | Aura::~Aura() |
|---|
| 415 | { |
|---|
| 416 | } |
|---|
| 417 | |
|---|
| 418 | AreaAura::AreaAura(SpellEntry const* spellproto, uint32 eff, int32 *currentBasePoints, Unit *target, |
|---|
| 419 | Unit *caster, Item* castItem) : Aura(spellproto, eff, currentBasePoints, target, caster, castItem) |
|---|
| 420 | { |
|---|
| 421 | m_isAreaAura = true; |
|---|
| 422 | |
|---|
| 423 | // caster==NULL in constructor args if target==caster in fact |
|---|
| 424 | Unit* caster_ptr = caster ? caster : target; |
|---|
| 425 | |
|---|
| 426 | m_radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(GetSpellProto()->EffectRadiusIndex[m_effIndex])); |
|---|
| 427 | if(Player* modOwner = caster_ptr->GetSpellModOwner()) |
|---|
| 428 | modOwner->ApplySpellMod(GetId(), SPELLMOD_RADIUS, m_radius); |
|---|
| 429 | |
|---|
| 430 | switch(spellproto->Effect[eff]) |
|---|
| 431 | { |
|---|
| 432 | case SPELL_EFFECT_APPLY_AREA_AURA_PARTY: |
|---|
| 433 | m_areaAuraType = AREA_AURA_PARTY; |
|---|
| 434 | if(target->GetTypeId() == TYPEID_UNIT && ((Creature*)target)->isTotem()) |
|---|
| 435 | m_modifier.m_auraname = SPELL_AURA_NONE; |
|---|
| 436 | break; |
|---|
| 437 | case SPELL_EFFECT_APPLY_AREA_AURA_FRIEND: |
|---|
| 438 | m_areaAuraType = AREA_AURA_FRIEND; |
|---|
| 439 | break; |
|---|
| 440 | case SPELL_EFFECT_APPLY_AREA_AURA_ENEMY: |
|---|
| 441 | m_areaAuraType = AREA_AURA_ENEMY; |
|---|
| 442 | if(target == caster_ptr) |
|---|
| 443 | m_modifier.m_auraname = SPELL_AURA_NONE; // Do not do any effect on self |
|---|
| 444 | break; |
|---|
| 445 | case SPELL_EFFECT_APPLY_AREA_AURA_PET: |
|---|
| 446 | m_areaAuraType = AREA_AURA_PET; |
|---|
| 447 | break; |
|---|
| 448 | case SPELL_EFFECT_APPLY_AREA_AURA_OWNER: |
|---|
| 449 | m_areaAuraType = AREA_AURA_OWNER; |
|---|
| 450 | if(target == caster_ptr) |
|---|
| 451 | m_modifier.m_auraname = SPELL_AURA_NONE; |
|---|
| 452 | break; |
|---|
| 453 | default: |
|---|
| 454 | sLog.outError("Wrong spell effect in AreaAura constructor"); |
|---|
| 455 | ASSERT(false); |
|---|
| 456 | break; |
|---|
| 457 | } |
|---|
| 458 | } |
|---|
| 459 | |
|---|
| 460 | AreaAura::~AreaAura() |
|---|
| 461 | { |
|---|
| 462 | } |
|---|
| 463 | |
|---|
| 464 | PersistentAreaAura::PersistentAreaAura(SpellEntry const* spellproto, uint32 eff, int32 *currentBasePoints, Unit *target, |
|---|
| 465 | Unit *caster, Item* castItem) : Aura(spellproto, eff, currentBasePoints, target, caster, castItem) |
|---|
| 466 | { |
|---|
| 467 | m_isPersistent = true; |
|---|
| 468 | } |
|---|
| 469 | |
|---|
| 470 | PersistentAreaAura::~PersistentAreaAura() |
|---|
| 471 | { |
|---|
| 472 | } |
|---|
| 473 | |
|---|
| 474 | SingleEnemyTargetAura::SingleEnemyTargetAura(SpellEntry const* spellproto, uint32 eff, int32 *currentBasePoints, Unit *target, |
|---|
| 475 | Unit *caster, Item* castItem) : Aura(spellproto, eff, currentBasePoints, target, caster, castItem) |
|---|
| 476 | { |
|---|
| 477 | if (caster) |
|---|
| 478 | m_casters_target_guid = caster->GetTypeId()==TYPEID_PLAYER ? ((Player*)caster)->GetSelection() : caster->GetUInt64Value(UNIT_FIELD_TARGET); |
|---|
| 479 | else |
|---|
| 480 | m_casters_target_guid = 0; |
|---|
| 481 | } |
|---|
| 482 | |
|---|
| 483 | SingleEnemyTargetAura::~SingleEnemyTargetAura() |
|---|
| 484 | { |
|---|
| 485 | } |
|---|
| 486 | |
|---|
| 487 | Unit* SingleEnemyTargetAura::GetTriggerTarget() const |
|---|
| 488 | { |
|---|
| 489 | return ObjectAccessor::GetUnit(*m_target, m_casters_target_guid); |
|---|
| 490 | } |
|---|
| 491 | |
|---|
| 492 | Aura* CreateAura(SpellEntry const* spellproto, uint32 eff, int32 *currentBasePoints, Unit *target, Unit *caster, Item* castItem) |
|---|
| 493 | { |
|---|
| 494 | if (IsAreaAuraEffect(spellproto->Effect[eff])) |
|---|
| 495 | return new AreaAura(spellproto, eff, currentBasePoints, target, caster, castItem); |
|---|
| 496 | |
|---|
| 497 | uint32 triggeredSpellId = spellproto->EffectTriggerSpell[eff]; |
|---|
| 498 | |
|---|
| 499 | SpellEntry const* triggredSpellInfo = sSpellStore.LookupEntry(triggeredSpellId); |
|---|
| 500 | if (triggredSpellInfo) |
|---|
| 501 | for (int i = 0; i < 3; ++i) |
|---|
| 502 | if (triggredSpellInfo->EffectImplicitTargetA[i] == TARGET_SINGLE_ENEMY) |
|---|
| 503 | return new SingleEnemyTargetAura(spellproto, eff, currentBasePoints, target, caster, castItem); |
|---|
| 504 | |
|---|
| 505 | return new Aura(spellproto, eff, currentBasePoints, target, caster, castItem); |
|---|
| 506 | } |
|---|
| 507 | |
|---|
| 508 | Unit* Aura::GetCaster() const |
|---|
| 509 | { |
|---|
| 510 | if(m_caster_guid==m_target->GetGUID()) |
|---|
| 511 | return m_target; |
|---|
| 512 | |
|---|
| 513 | //return ObjectAccessor::GetUnit(*m_target,m_caster_guid); |
|---|
| 514 | //must return caster even if it's in another grid/map |
|---|
| 515 | Unit *unit = ObjectAccessor::GetObjectInWorld(m_caster_guid, (Unit*)NULL); |
|---|
| 516 | return unit && unit->IsInWorld() ? unit : NULL; |
|---|
| 517 | } |
|---|
| 518 | |
|---|
| 519 | void Aura::SetModifier(AuraType t, int32 a, uint32 pt, int32 miscValue) |
|---|
| 520 | { |
|---|
| 521 | m_modifier.m_auraname = t; |
|---|
| 522 | m_modifier.m_amount = a; |
|---|
| 523 | m_modifier.m_miscvalue = miscValue; |
|---|
| 524 | m_modifier.periodictime = pt; |
|---|
| 525 | } |
|---|
| 526 | |
|---|
| 527 | void Aura::Update(uint32 diff) |
|---|
| 528 | { |
|---|
| 529 | if (m_duration > 0) |
|---|
| 530 | { |
|---|
| 531 | m_duration -= diff; |
|---|
| 532 | if (m_duration < 0) |
|---|
| 533 | m_duration = 0; |
|---|
| 534 | m_timeCla -= diff; |
|---|
| 535 | |
|---|
| 536 | // GetEffIndex()==0 prevent double/triple apply manaPerSecond/manaPerSecondPerLevel to same spell with many auras |
|---|
| 537 | // all spells with manaPerSecond/manaPerSecondPerLevel have aura in effect 0 |
|---|
| 538 | if(GetEffIndex()==0 && m_timeCla <= 0) |
|---|
| 539 | { |
|---|
| 540 | if(Unit* caster = GetCaster()) |
|---|
| 541 | { |
|---|
| 542 | Powers powertype = Powers(m_spellProto->powerType); |
|---|
| 543 | int32 manaPerSecond = m_spellProto->manaPerSecond + m_spellProto->manaPerSecondPerLevel * caster->getLevel(); |
|---|
| 544 | m_timeCla = 1000; |
|---|
| 545 | if (manaPerSecond) |
|---|
| 546 | { |
|---|
| 547 | if(powertype==POWER_HEALTH) |
|---|
| 548 | caster->ModifyHealth(-manaPerSecond); |
|---|
| 549 | else |
|---|
| 550 | caster->ModifyPower(powertype,-manaPerSecond); |
|---|
| 551 | } |
|---|
| 552 | } |
|---|
| 553 | } |
|---|
| 554 | } |
|---|
| 555 | |
|---|
| 556 | // Channeled aura required check distance from caster |
|---|
| 557 | if(IsChanneledSpell(m_spellProto) && m_caster_guid != m_target->GetGUID()) |
|---|
| 558 | { |
|---|
| 559 | Unit* caster = GetCaster(); |
|---|
| 560 | if(!caster) |
|---|
| 561 | { |
|---|
| 562 | m_target->RemoveAura(GetId(),GetEffIndex()); |
|---|
| 563 | return; |
|---|
| 564 | } |
|---|
| 565 | |
|---|
| 566 | // Get spell range |
|---|
| 567 | float radius; |
|---|
| 568 | SpellModOp mod; |
|---|
| 569 | if (m_spellProto->EffectRadiusIndex[GetEffIndex()]) |
|---|
| 570 | { |
|---|
| 571 | radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellProto->EffectRadiusIndex[GetEffIndex()])); |
|---|
| 572 | mod = SPELLMOD_RADIUS; |
|---|
| 573 | } |
|---|
| 574 | else |
|---|
| 575 | { |
|---|
| 576 | radius = GetSpellMaxRange(sSpellRangeStore.LookupEntry(m_spellProto->rangeIndex)); |
|---|
| 577 | mod = SPELLMOD_RANGE; |
|---|
| 578 | } |
|---|
| 579 | |
|---|
| 580 | if(Player* modOwner = caster->GetSpellModOwner()) |
|---|
| 581 | modOwner->ApplySpellMod(GetId(), mod, radius,NULL); |
|---|
| 582 | |
|---|
| 583 | if(!caster->IsWithinDistInMap(m_target,radius)) |
|---|
| 584 | { |
|---|
| 585 | m_target->RemoveAura(GetId(),GetEffIndex()); |
|---|
| 586 | return; |
|---|
| 587 | } |
|---|
| 588 | } |
|---|
| 589 | |
|---|
| 590 | if(m_isPeriodic && (m_duration >= 0 || m_isPassive || m_permanent)) |
|---|
| 591 | { |
|---|
| 592 | m_periodicTimer -= diff; |
|---|
| 593 | if(m_periodicTimer <= 0) // tick also at m_periodicTimer==0 to prevent lost last tick in case max m_duration == (max m_periodicTimer)*N |
|---|
| 594 | { |
|---|
| 595 | if( m_modifier.m_auraname == SPELL_AURA_MOD_REGEN || |
|---|
| 596 | m_modifier.m_auraname == SPELL_AURA_MOD_POWER_REGEN || |
|---|
| 597 | // Cannibalize, eating items and other spells |
|---|
| 598 | m_modifier.m_auraname == SPELL_AURA_OBS_MOD_HEALTH || |
|---|
| 599 | // Eating items and other spells |
|---|
| 600 | m_modifier.m_auraname == SPELL_AURA_OBS_MOD_MANA ) |
|---|
| 601 | { |
|---|
| 602 | ApplyModifier(true); |
|---|
| 603 | return; |
|---|
| 604 | } |
|---|
| 605 | // update before applying (aura can be removed in TriggerSpell or PeriodicTick calls) |
|---|
| 606 | m_periodicTimer += m_modifier.periodictime; |
|---|
| 607 | |
|---|
| 608 | if(m_isTrigger) |
|---|
| 609 | TriggerSpell(); |
|---|
| 610 | else |
|---|
| 611 | PeriodicTick(); |
|---|
| 612 | } |
|---|
| 613 | } |
|---|
| 614 | } |
|---|
| 615 | |
|---|
| 616 | void AreaAura::Update(uint32 diff) |
|---|
| 617 | { |
|---|
| 618 | // update for the caster of the aura |
|---|
| 619 | if(m_caster_guid == m_target->GetGUID()) |
|---|
| 620 | { |
|---|
| 621 | Unit* caster = m_target; |
|---|
| 622 | |
|---|
| 623 | if( !caster->hasUnitState(UNIT_STAT_ISOLATED) ) |
|---|
| 624 | { |
|---|
| 625 | Unit* owner = caster->GetCharmerOrOwner(); |
|---|
| 626 | if (!owner) |
|---|
| 627 | owner = caster; |
|---|
| 628 | std::list<Unit *> targets; |
|---|
| 629 | |
|---|
| 630 | switch(m_areaAuraType) |
|---|
| 631 | { |
|---|
| 632 | case AREA_AURA_PARTY: |
|---|
| 633 | { |
|---|
| 634 | Group *pGroup = NULL; |
|---|
| 635 | |
|---|
| 636 | if (owner->GetTypeId() == TYPEID_PLAYER) |
|---|
| 637 | pGroup = ((Player*)owner)->GetGroup(); |
|---|
| 638 | |
|---|
| 639 | if( pGroup) |
|---|
| 640 | { |
|---|
| 641 | uint8 subgroup = ((Player*)owner)->GetSubGroup(); |
|---|
| 642 | for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next()) |
|---|
| 643 | { |
|---|
| 644 | Player* Target = itr->getSource(); |
|---|
| 645 | if(Target && Target->isAlive() && Target->GetSubGroup()==subgroup && caster->IsFriendlyTo(Target)) |
|---|
| 646 | { |
|---|
| 647 | if(caster->IsWithinDistInMap(Target, m_radius)) |
|---|
| 648 | targets.push_back(Target); |
|---|
| 649 | Pet *pet = Target->GetPet(); |
|---|
| 650 | if(pet && pet->isAlive() && caster->IsWithinDistInMap(pet, m_radius)) |
|---|
| 651 | targets.push_back(pet); |
|---|
| 652 | } |
|---|
| 653 | } |
|---|
| 654 | } |
|---|
| 655 | else |
|---|
| 656 | { |
|---|
| 657 | // add owner |
|---|
| 658 | if( owner != caster && caster->IsWithinDistInMap(owner, m_radius) ) |
|---|
| 659 | targets.push_back(owner); |
|---|
| 660 | // add caster's pet |
|---|
| 661 | Unit* pet = caster->GetPet(); |
|---|
| 662 | if( pet && caster->IsWithinDistInMap(pet, m_radius)) |
|---|
| 663 | targets.push_back(pet); |
|---|
| 664 | } |
|---|
| 665 | break; |
|---|
| 666 | } |
|---|
| 667 | case AREA_AURA_FRIEND: |
|---|
| 668 | { |
|---|
| 669 | CellPair p(Trinity::ComputeCellPair(caster->GetPositionX(), caster->GetPositionY())); |
|---|
| 670 | Cell cell(p); |
|---|
| 671 | cell.data.Part.reserved = ALL_DISTRICT; |
|---|
| 672 | cell.SetNoCreate(); |
|---|
| 673 | |
|---|
| 674 | Trinity::AnyFriendlyUnitInObjectRangeCheck u_check(caster, owner, m_radius); |
|---|
| 675 | Trinity::UnitListSearcher<Trinity::AnyFriendlyUnitInObjectRangeCheck> searcher(targets, u_check); |
|---|
| 676 | TypeContainerVisitor<Trinity::UnitListSearcher<Trinity::AnyFriendlyUnitInObjectRangeCheck>, WorldTypeMapContainer > world_unit_searcher(searcher); |
|---|
| 677 | TypeContainerVisitor<Trinity::UnitListSearcher<Trinity::AnyFriendlyUnitInObjectRangeCheck>, GridTypeMapContainer > grid_unit_searcher(searcher); |
|---|
| 678 | CellLock<GridReadGuard> cell_lock(cell, p); |
|---|
| 679 | cell_lock->Visit(cell_lock, world_unit_searcher, *MapManager::Instance().GetMap(caster->GetMapId(), caster)); |
|---|
| 680 | cell_lock->Visit(cell_lock, grid_unit_searcher, *MapManager::Instance().GetMap(caster->GetMapId(), caster)); |
|---|
| 681 | break; |
|---|
| 682 | } |
|---|
| 683 | case AREA_AURA_ENEMY: |
|---|
| 684 | { |
|---|
| 685 | CellPair p(Trinity::ComputeCellPair(caster->GetPositionX(), caster->GetPositionY())); |
|---|
| 686 | Cell cell(p); |
|---|
| 687 | cell.data.Part.reserved = ALL_DISTRICT; |
|---|
| 688 | cell.SetNoCreate(); |
|---|
| 689 | |
|---|
| 690 | Trinity::AnyAoETargetUnitInObjectRangeCheck u_check(caster, owner, m_radius); // No GetCharmer in searcher |
|---|
| 691 | Trinity::UnitListSearcher<Trinity::AnyAoETargetUnitInObjectRangeCheck> searcher(targets, u_check); |
|---|
| 692 | TypeContainerVisitor<Trinity::UnitListSearcher<Trinity::AnyAoETargetUnitInObjectRangeCheck>, WorldTypeMapContainer > world_unit_searcher(searcher); |
|---|
| 693 | TypeContainerVisitor<Trinity::UnitListSearcher<Trinity::AnyAoETargetUnitInObjectRangeCheck>, GridTypeMapContainer > grid_unit_searcher(searcher); |
|---|
| 694 | CellLock<GridReadGuard> cell_lock(cell, p); |
|---|
| 695 | cell_lock->Visit(cell_lock, world_unit_searcher, *MapManager::Instance().GetMap(caster->GetMapId(), caster)); |
|---|
| 696 | cell_lock->Visit(cell_lock, grid_unit_searcher, *MapManager::Instance().GetMap(caster->GetMapId(), caster)); |
|---|
| 697 | break; |
|---|
| 698 | } |
|---|
| 699 | case AREA_AURA_OWNER: |
|---|
| 700 | case AREA_AURA_PET: |
|---|
| 701 | { |
|---|
| 702 | if(owner != caster) |
|---|
| 703 | targets.push_back(owner); |
|---|
| 704 | break; |
|---|
| 705 | } |
|---|
| 706 | } |
|---|
| 707 | |
|---|
| 708 | for(std::list<Unit *>::iterator tIter = targets.begin(); tIter != targets.end(); tIter++) |
|---|
| 709 | { |
|---|
| 710 | if((*tIter)->HasAura(GetId(), m_effIndex)) |
|---|
| 711 | continue; |
|---|
| 712 | |
|---|
| 713 | if(SpellEntry const *actualSpellInfo = spellmgr.SelectAuraRankForPlayerLevel(GetSpellProto(), (*tIter)->getLevel())) |
|---|
| 714 | { |
|---|
| 715 | int32 actualBasePoints = m_currentBasePoints; |
|---|
| 716 | // recalculate basepoints for lower rank (all AreaAura spell not use custom basepoints?) |
|---|
| 717 | if(actualSpellInfo != GetSpellProto()) |
|---|
| 718 | actualBasePoints = actualSpellInfo->EffectBasePoints[m_effIndex]; |
|---|
| 719 | AreaAura *aur = new AreaAura(actualSpellInfo, m_effIndex, &actualBasePoints, (*tIter), caster, NULL); |
|---|
| 720 | (*tIter)->AddAura(aur); |
|---|
| 721 | } |
|---|
| 722 | } |
|---|
| 723 | } |
|---|
| 724 | Aura::Update(diff); |
|---|
| 725 | } |
|---|
| 726 | else // aura at non-caster |
|---|
| 727 | { |
|---|
| 728 | Unit * tmp_target = m_target; |
|---|
| 729 | Unit* caster = GetCaster(); |
|---|
| 730 | uint32 tmp_spellId = GetId(), tmp_effIndex = m_effIndex; |
|---|
| 731 | |
|---|
| 732 | // WARNING: the aura may get deleted during the update |
|---|
| 733 | // DO NOT access its members after update! |
|---|
| 734 | Aura::Update(diff); |
|---|
| 735 | |
|---|
| 736 | // remove aura if out-of-range from caster (after teleport for example) |
|---|
| 737 | // or caster is isolated or caster no longer has the aura |
|---|
| 738 | // or caster is (no longer) friendly |
|---|
| 739 | bool needFriendly = (m_areaAuraType == AREA_AURA_ENEMY ? false : true); |
|---|
| 740 | if( !caster || caster->hasUnitState(UNIT_STAT_ISOLATED) || |
|---|
| 741 | !caster->IsWithinDistInMap(tmp_target, m_radius) || |
|---|
| 742 | !caster->HasAura(tmp_spellId, tmp_effIndex) || |
|---|
| 743 | caster->IsFriendlyTo(tmp_target) != needFriendly |
|---|
| 744 | ) |
|---|
| 745 | { |
|---|
| 746 | tmp_target->RemoveAura(tmp_spellId, tmp_effIndex); |
|---|
| 747 | } |
|---|
| 748 | else if( m_areaAuraType == AREA_AURA_PARTY) // check if in same sub group |
|---|
| 749 | { |
|---|
| 750 | // not check group if target == owner or target == pet |
|---|
| 751 | if (caster->GetCharmerOrOwnerGUID() != tmp_target->GetGUID() && caster->GetGUID() != tmp_target->GetCharmerOrOwnerGUID()) |
|---|
| 752 | { |
|---|
| 753 | Player* check = caster->GetCharmerOrOwnerPlayerOrPlayerItself(); |
|---|
| 754 | |
|---|
| 755 | Group *pGroup = check ? check->GetGroup() : NULL; |
|---|
| 756 | if( pGroup ) |
|---|
| 757 | { |
|---|
| 758 | Player* checkTarget = tmp_target->GetCharmerOrOwnerPlayerOrPlayerItself(); |
|---|
| 759 | if(!checkTarget || !pGroup->SameSubGroup(check, checkTarget)) |
|---|
| 760 | tmp_target->RemoveAura(tmp_spellId, tmp_effIndex); |
|---|
| 761 | } |
|---|
| 762 | else |
|---|
| 763 | tmp_target->RemoveAura(tmp_spellId, tmp_effIndex); |
|---|
| 764 | } |
|---|
| 765 | } |
|---|
| 766 | else if( m_areaAuraType == AREA_AURA_PET || m_areaAuraType == AREA_AURA_OWNER ) |
|---|
| 767 | { |
|---|
| 768 | if( tmp_target->GetGUID() != caster->GetCharmerOrOwnerGUID() ) |
|---|
| 769 | tmp_target->RemoveAura(tmp_spellId, tmp_effIndex); |
|---|
| 770 | } |
|---|
| 771 | } |
|---|
| 772 | } |
|---|
| 773 | |
|---|
| 774 | void PersistentAreaAura::Update(uint32 diff) |
|---|
| 775 | { |
|---|
| 776 | bool remove = false; |
|---|
| 777 | |
|---|
| 778 | // remove the aura if its caster or the dynamic object causing it was removed |
|---|
| 779 | // or if the target moves too far from the dynamic object |
|---|
| 780 | Unit *caster = GetCaster(); |
|---|
| 781 | if (caster) |
|---|
| 782 | { |
|---|
| 783 | DynamicObject *dynObj = caster->GetDynObject(GetId(), GetEffIndex()); |
|---|
| 784 | if (dynObj) |
|---|
| 785 | { |
|---|
| 786 | if (!m_target->IsWithinDistInMap(dynObj, dynObj->GetRadius())) |
|---|
| 787 | remove = true; |
|---|
| 788 | } |
|---|
| 789 | else |
|---|
| 790 | remove = true; |
|---|
| 791 | } |
|---|
| 792 | else |
|---|
| 793 | remove = true; |
|---|
| 794 | |
|---|
| 795 | Unit *tmp_target = m_target; |
|---|
| 796 | uint32 tmp_id = GetId(), tmp_index = GetEffIndex(); |
|---|
| 797 | |
|---|
| 798 | // WARNING: the aura may get deleted during the update |
|---|
| 799 | // DO NOT access its members after update! |
|---|
| 800 | Aura::Update(diff); |
|---|
| 801 | |
|---|
| 802 | if(remove) |
|---|
| 803 | tmp_target->RemoveAura(tmp_id, tmp_index); |
|---|
| 804 | } |
|---|
| 805 | |
|---|
| 806 | void Aura::ApplyModifier(bool apply, bool Real) |
|---|
| 807 | { |
|---|
| 808 | AuraType aura = m_modifier.m_auraname; |
|---|
| 809 | |
|---|
| 810 | m_in_use = true; |
|---|
| 811 | if(aura<TOTAL_AURAS) |
|---|
| 812 | (*this.*AuraHandler [aura])(apply,Real); |
|---|
| 813 | m_in_use = false; |
|---|
| 814 | } |
|---|
| 815 | |
|---|
| 816 | void Aura::UpdateAuraDuration() |
|---|
| 817 | { |
|---|
| 818 | if(m_auraSlot >= MAX_AURAS || m_isPassive) |
|---|
| 819 | return; |
|---|
| 820 | |
|---|
| 821 | if( m_target->GetTypeId() == TYPEID_PLAYER) |
|---|
| 822 | { |
|---|
| 823 | WorldPacket data(SMSG_UPDATE_AURA_DURATION, 5); |
|---|
| 824 | data << (uint8)m_auraSlot << (uint32)m_duration; |
|---|
| 825 | ((Player*)m_target)->SendDirectMessage(&data); |
|---|
| 826 | |
|---|
| 827 | data.Initialize(SMSG_SET_EXTRA_AURA_INFO, (8+1+4+4+4)); |
|---|
| 828 | data.append(m_target->GetPackGUID()); |
|---|
| 829 | data << uint8(m_auraSlot); |
|---|
| 830 | data << uint32(GetId()); |
|---|
| 831 | data << uint32(GetAuraMaxDuration()); |
|---|
| 832 | data << uint32(GetAuraDuration()); |
|---|
| 833 | ((Player*)m_target)->SendDirectMessage(&data); |
|---|
| 834 | } |
|---|
| 835 | |
|---|
| 836 | // not send in case player loading (will not work anyway until player not added to map), sent in visibility change code |
|---|
| 837 | if(m_target->GetTypeId() == TYPEID_PLAYER && ((Player*)m_target)->GetSession()->PlayerLoading()) |
|---|
| 838 | return; |
|---|
| 839 | |
|---|
| 840 | Unit* caster = GetCaster(); |
|---|
| 841 | |
|---|
| 842 | if(caster && caster->GetTypeId() == TYPEID_PLAYER && caster != m_target) |
|---|
| 843 | SendAuraDurationForCaster((Player*)caster); |
|---|
| 844 | } |
|---|
| 845 | |
|---|
| 846 | void Aura::SendAuraDurationForCaster(Player* caster) |
|---|
| 847 | { |
|---|
| 848 | WorldPacket data(SMSG_SET_EXTRA_AURA_INFO_NEED_UPDATE, (8+1+4+4+4)); |
|---|
| 849 | data.append(m_target->GetPackGUID()); |
|---|
| 850 | data << uint8(m_auraSlot); |
|---|
| 851 | data << uint32(GetId()); |
|---|
| 852 | data << uint32(GetAuraMaxDuration()); // full |
|---|
| 853 | data << uint32(GetAuraDuration()); // remain |
|---|
| 854 | caster->GetSession()->SendPacket(&data); |
|---|
| 855 | } |
|---|
| 856 | |
|---|
| 857 | void Aura::_AddAura() |
|---|
| 858 | { |
|---|
| 859 | if (!GetId()) |
|---|
| 860 | return; |
|---|
| 861 | if(!m_target) |
|---|
| 862 | return; |
|---|
| 863 | |
|---|
| 864 | // we can found aura in NULL_AURA_SLOT and then need store state instead check slot != NULL_AURA_SLOT |
|---|
| 865 | bool samespell = false; |
|---|
| 866 | bool secondaura = false; |
|---|
| 867 | uint8 slot = NULL_AURA_SLOT; |
|---|
| 868 | |
|---|
| 869 | for(uint8 i = 0; i < 3; i++) |
|---|
| 870 | { |
|---|
| 871 | Unit::spellEffectPair spair = Unit::spellEffectPair(GetId(), i); |
|---|
| 872 | for(Unit::AuraMap::const_iterator itr = m_target->GetAuras().lower_bound(spair); itr != m_target->GetAuras().upper_bound(spair); ++itr) |
|---|
| 873 | { |
|---|
| 874 | // allow use single slot only by auras from same caster |
|---|
| 875 | if(itr->second->GetCasterGUID()==GetCasterGUID()) |
|---|
| 876 | { |
|---|
| 877 | samespell = true; |
|---|
| 878 | if (m_effIndex > itr->second->GetEffIndex()) |
|---|
| 879 | secondaura = true; |
|---|
| 880 | slot = itr->second->GetAuraSlot(); |
|---|
| 881 | break; |
|---|
| 882 | } |
|---|
| 883 | } |
|---|
| 884 | |
|---|
| 885 | if(samespell) |
|---|
| 886 | break; |
|---|
| 887 | } |
|---|
| 888 | |
|---|
| 889 | // not call total regen auras at adding |
|---|
| 890 | switch (m_modifier.m_auraname) |
|---|
| 891 | { |
|---|
| 892 | case SPELL_AURA_OBS_MOD_HEALTH: |
|---|
| 893 | case SPELL_AURA_OBS_MOD_MANA: |
|---|
| 894 | m_periodicTimer = m_modifier.periodictime; |
|---|
| 895 | break; |
|---|
| 896 | case SPELL_AURA_MOD_REGEN: |
|---|
| 897 | case SPELL_AURA_MOD_POWER_REGEN: |
|---|
| 898 | case SPELL_AURA_MOD_MANA_REGEN_FROM_STAT: |
|---|
| 899 | m_periodicTimer = 5000; |
|---|
| 900 | break; |
|---|
| 901 | } |
|---|
| 902 | |
|---|
| 903 | // register aura |
|---|
| 904 | if (getDiminishGroup() != DIMINISHING_NONE ) |
|---|
| 905 | m_target->ApplyDiminishingAura(getDiminishGroup(),true); |
|---|
| 906 | |
|---|
| 907 | Unit* caster = GetCaster(); |
|---|
| 908 | |
|---|
| 909 | // passive auras (except totem auras) do not get placed in the slots |
|---|
| 910 | // area auras with SPELL_AURA_NONE are not shown on target |
|---|
| 911 | if((!m_isPassive || (caster && caster->GetTypeId() == TYPEID_UNIT && ((Creature*)caster)->isTotem())) && |
|---|
| 912 | (m_spellProto->Effect[GetEffIndex()] != SPELL_EFFECT_APPLY_AREA_AURA_ENEMY || m_target != caster)) |
|---|
| 913 | { |
|---|
| 914 | if(!samespell) // new slot need |
|---|
| 915 | { |
|---|
| 916 | if (IsPositive()) // empty positive slot |
|---|
| 917 | { |
|---|
| 918 | for (uint8 i = 0; i < MAX_POSITIVE_AURAS; i++) |
|---|
| 919 | { |
|---|
| 920 | if (m_target->GetUInt32Value((uint16)(UNIT_FIELD_AURA + i)) == 0) |
|---|
| 921 | { |
|---|
| 922 | slot = i; |
|---|
| 923 | break; |
|---|
| 924 | } |
|---|
| 925 | } |
|---|
| 926 | } |
|---|
| 927 | else // empty negative slot |
|---|
| 928 | { |
|---|
| 929 | for (uint8 i = MAX_POSITIVE_AURAS; i < MAX_AURAS; i++) |
|---|
| 930 | { |
|---|
| 931 | if (m_target->GetUInt32Value((uint16)(UNIT_FIELD_AURA + i)) == 0) |
|---|
| 932 | { |
|---|
| 933 | slot = i; |
|---|
| 934 | break; |
|---|
| 935 | } |
|---|
| 936 | } |
|---|
| 937 | } |
|---|
| 938 | |
|---|
| 939 | SetAuraSlot( slot ); |
|---|
| 940 | |
|---|
| 941 | // Not update fields for not first spell's aura, all data already in fields |
|---|
| 942 | if(!secondaura) |
|---|
| 943 | { |
|---|
| 944 | if(slot < MAX_AURAS) // slot found |
|---|
| 945 | { |
|---|
| 946 | SetAura(slot, false); |
|---|
| 947 | SetAuraFlag(slot, true); |
|---|
| 948 | SetAuraLevel(slot,caster ? caster->getLevel() : sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)); |
|---|
| 949 | UpdateAuraCharges(); |
|---|
| 950 | |
|---|
| 951 | // update for out of range group members |
|---|
| 952 | m_target->UpdateAuraForGroup(slot); |
|---|
| 953 | } |
|---|
| 954 | |
|---|
| 955 | UpdateAuraDuration(); |
|---|
| 956 | } |
|---|
| 957 | } |
|---|
| 958 | else // use found slot |
|---|
| 959 | { |
|---|
| 960 | SetAuraSlot( slot ); |
|---|
| 961 | // Not recalculate stack count for second aura of the same spell |
|---|
| 962 | if (!secondaura) |
|---|
| 963 | UpdateSlotCounterAndDuration(true); |
|---|
| 964 | } |
|---|
| 965 | |
|---|
| 966 | // Update Seals information |
|---|
| 967 | if( IsSealSpell(GetSpellProto()) ) |
|---|
| 968 | m_target->ModifyAuraState(AURA_STATE_JUDGEMENT, true); |
|---|
| 969 | |
|---|
| 970 | // Conflagrate aura state |
|---|
| 971 | if (GetSpellProto()->SpellFamilyName == SPELLFAMILY_WARLOCK && (GetSpellProto()->SpellFamilyFlags & 4)) |
|---|
| 972 | m_target->ModifyAuraState(AURA_STATE_IMMOLATE, true); |
|---|
| 973 | |
|---|
| 974 | if(GetSpellProto()->SpellFamilyName == SPELLFAMILY_DRUID |
|---|
| 975 | && (GetSpellProto()->SpellFamilyFlags == 0x40 || GetSpellProto()->SpellFamilyFlags == 0x10)) |
|---|
| 976 | { |
|---|
| 977 | m_target->ModifyAuraState(AURA_STATE_SWIFTMEND, true); |
|---|
| 978 | } |
|---|
| 979 | } |
|---|
| 980 | } |
|---|
| 981 | |
|---|
| 982 | void Aura::_RemoveAura() |
|---|
| 983 | { |
|---|
| 984 | // Remove all triggered by aura spells vs unlimited duration |
|---|
| 985 | // except same aura replace case |
|---|
| 986 | if(m_removeMode!=AURA_REMOVE_BY_STACK) |
|---|
| 987 | CleanupTriggeredSpells(); |
|---|
| 988 | |
|---|
| 989 | Unit* caster = GetCaster(); |
|---|
| 990 | |
|---|
| 991 | if(caster && IsPersistent()) |
|---|
| 992 | { |
|---|
| 993 | DynamicObject *dynObj = caster->GetDynObject(GetId(), GetEffIndex()); |
|---|
| 994 | if (dynObj) |
|---|
| 995 | dynObj->RemoveAffected(m_target); |
|---|
| 996 | } |
|---|
| 997 | |
|---|
| 998 | // unregister aura |
|---|
| 999 | if (getDiminishGroup() != DIMINISHING_NONE ) |
|---|
| 1000 | m_target->ApplyDiminishingAura(getDiminishGroup(),false); |
|---|
| 1001 | |
|---|
| 1002 | //passive auras do not get put in slots |
|---|
| 1003 | // Note: but totem can be not accessible for aura target in time remove (to far for find in grid) |
|---|
| 1004 | //if(m_isPassive && !(caster && caster->GetTypeId() == TYPEID_UNIT && ((Creature*)caster)->isTotem())) |
|---|
| 1005 | // return; |
|---|
| 1006 | |
|---|
| 1007 | uint8 slot = GetAuraSlot(); |
|---|
| 1008 | |
|---|
| 1009 | if(slot >= MAX_AURAS) // slot not set |
|---|
| 1010 | return; |
|---|
| 1011 | |
|---|
| 1012 | if(m_target->GetUInt32Value((uint16)(UNIT_FIELD_AURA + slot)) == 0) |
|---|
| 1013 | return; |
|---|
| 1014 | |
|---|
| 1015 | bool samespell = false; |
|---|
| 1016 | bool sameaura = false; |
|---|
| 1017 | |
|---|
| 1018 | // find other aura in same slot (current already removed from list) |
|---|
| 1019 | for(uint8 i = 0; i < 3; i++) |
|---|
| 1020 | { |
|---|
| 1021 | Unit::spellEffectPair spair = Unit::spellEffectPair(GetId(), i); |
|---|
| 1022 | for(Unit::AuraMap::const_iterator itr = m_target->GetAuras().lower_bound(spair); itr != m_target->GetAuras().upper_bound(spair); ++itr) |
|---|
| 1023 | { |
|---|
| 1024 | if(itr->second->GetAuraSlot()==slot) |
|---|
| 1025 | { |
|---|
| 1026 | samespell = true; |
|---|
| 1027 | |
|---|
| 1028 | if(GetEffIndex()==i) |
|---|
| 1029 | sameaura = true; |
|---|
| 1030 | |
|---|
| 1031 | break; |
|---|
| 1032 | } |
|---|
| 1033 | } |
|---|
| 1034 | if(samespell) |
|---|
| 1035 | break; |
|---|
| 1036 | } |
|---|
| 1037 | |
|---|
| 1038 | // only remove icon when the last aura of the spell is removed (current aura already removed from list) |
|---|
| 1039 | if (!samespell) |
|---|
| 1040 | { |
|---|
| 1041 | SetAura(slot, true); |
|---|
| 1042 | SetAuraFlag(slot, false); |
|---|
| 1043 | SetAuraLevel(slot,caster ? caster->getLevel() : sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)); |
|---|
| 1044 | |
|---|
| 1045 | SetAuraApplication(slot, 0); |
|---|
| 1046 | // update for out of range group members |
|---|
| 1047 | m_target->UpdateAuraForGroup(slot); |
|---|
| 1048 | |
|---|
| 1049 | if( IsSealSpell(GetSpellProto()) ) |
|---|
| 1050 | m_target->ModifyAuraState(AURA_STATE_JUDGEMENT,false); |
|---|
| 1051 | |
|---|
| 1052 | // Conflagrate aura state |
|---|
| 1053 | if (GetSpellProto()->SpellFamilyName == SPELLFAMILY_WARLOCK && (GetSpellProto()->SpellFamilyFlags & 4)) |
|---|
| 1054 | m_target->ModifyAuraState(AURA_STATE_IMMOLATE, false); |
|---|
| 1055 | |
|---|
| 1056 | // Swiftmend aura state |
|---|
| 1057 | if(GetSpellProto()->SpellFamilyName == SPELLFAMILY_DRUID |
|---|
| 1058 | && (GetSpellProto()->SpellFamilyFlags == 0x40 || GetSpellProto()->SpellFamilyFlags == 0x10)) |
|---|
| 1059 | { |
|---|
| 1060 | bool found = false; |
|---|
| 1061 | Unit::AuraList const& RejorRegr = m_target->GetAurasByType(SPELL_AURA_PERIODIC_HEAL); |
|---|
| 1062 | for(Unit::AuraList::const_iterator i = RejorRegr.begin(); i != RejorRegr.end(); ++i) |
|---|
| 1063 | { |
|---|
| 1064 | if((*i)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_DRUID |
|---|
| 1065 | && ((*i)->GetSpellProto()->SpellFamilyFlags == 0x40 || (*i)->GetSpellProto()->SpellFamilyFlags == 0x10) ) |
|---|
| 1066 | { |
|---|
| 1067 | found = true; |
|---|
| 1068 | break; |
|---|
| 1069 | } |
|---|
| 1070 | } |
|---|
| 1071 | if(!found) |
|---|
| 1072 | m_target->ModifyAuraState(AURA_STATE_SWIFTMEND, false); |
|---|
| 1073 | } |
|---|
| 1074 | |
|---|
| 1075 | // reset cooldown state for spells |
|---|
| 1076 | if(caster && caster->GetTypeId() == TYPEID_PLAYER) |
|---|
| 1077 | { |
|---|
| 1078 | if ( GetSpellProto()->Attributes & SPELL_ATTR_DISABLED_WHILE_ACTIVE ) |
|---|
| 1079 | ((Player*)caster)->SendCooldownEvent(GetSpellProto()); |
|---|
| 1080 | } |
|---|
| 1081 | } |
|---|
| 1082 | else if(sameaura) // decrease count for spell, only for same aura effect, or this spell auras in remove proccess. |
|---|
| 1083 | UpdateSlotCounterAndDuration(false); |
|---|
| 1084 | } |
|---|
| 1085 | |
|---|
| 1086 | void Aura::SetAuraFlag(uint32 slot, bool add) |
|---|
| 1087 | { |
|---|
| 1088 | uint32 index = slot / 4; |
|---|
| 1089 | uint32 byte = (slot % 4) * 8; |
|---|
| 1090 | uint32 val = m_target->GetUInt32Value(UNIT_FIELD_AURAFLAGS + index); |
|---|
| 1091 | val &= ~((uint32)AFLAG_MASK << byte); |
|---|
| 1092 | if(add) |
|---|
| 1093 | { |
|---|
| 1094 | if (IsPositive()) |
|---|
| 1095 | val |= ((uint32)AFLAG_POSITIVE << byte); |
|---|
| 1096 | else |
|---|
| 1097 | val |= ((uint32)AFLAG_NEGATIVE << byte); |
|---|
| 1098 | } |
|---|
| 1099 | m_target->SetUInt32Value(UNIT_FIELD_AURAFLAGS + index, val); |
|---|
| 1100 | } |
|---|
| 1101 | |
|---|
| 1102 | void Aura::SetAuraLevel(uint32 slot,uint32 level) |
|---|
| 1103 | { |
|---|
| 1104 | uint32 index = slot / 4; |
|---|
| 1105 | uint32 byte = (slot % 4) * 8; |
|---|
| 1106 | uint32 val = m_target->GetUInt32Value(UNIT_FIELD_AURALEVELS + index); |
|---|
| 1107 | val &= ~(0xFF << byte); |
|---|
| 1108 | val |= (level << byte); |
|---|
| 1109 | m_target->SetUInt32Value(UNIT_FIELD_AURALEVELS + index, val); |
|---|
| 1110 | } |
|---|
| 1111 | |
|---|
| 1112 | void Aura::SetAuraApplication(uint32 slot, int8 count) |
|---|
| 1113 | { |
|---|
| 1114 | uint32 index = slot / 4; |
|---|
| 1115 | uint32 byte = (slot % 4) * 8; |
|---|
| 1116 | uint32 val = m_target->GetUInt32Value(UNIT_FIELD_AURAAPPLICATIONS + index); |
|---|
| 1117 | val &= ~(0xFF << byte); |
|---|
| 1118 | val |= ((uint8(count)) << byte); |
|---|
| 1119 | m_target->SetUInt32Value(UNIT_FIELD_AURAAPPLICATIONS + index, val); |
|---|
| 1120 | } |
|---|
| 1121 | |
|---|
| 1122 | void Aura::UpdateSlotCounterAndDuration(bool add) |
|---|
| 1123 | { |
|---|
| 1124 | uint8 slot = GetAuraSlot(); |
|---|
| 1125 | if(slot >= MAX_AURAS) |
|---|
| 1126 | return; |
|---|
| 1127 | |
|---|
| 1128 | // calculate amount of similar auras by same effect index (similar different spells) |
|---|
| 1129 | int8 count = 0; |
|---|
| 1130 | |
|---|
| 1131 | // calculate auras and update durations in case aura adding |
|---|
| 1132 | Unit::AuraList const& aura_list = m_target->GetAurasByType(GetModifier()->m_auraname); |
|---|
| 1133 | for(Unit::AuraList::const_iterator i = aura_list.begin();i != aura_list.end(); ++i) |
|---|
| 1134 | { |
|---|
| 1135 | if( (*i)->GetId()==GetId() && (*i)->GetEffIndex()==m_effIndex && |
|---|
| 1136 | (*i)->GetCasterGUID()==GetCasterGUID() ) |
|---|
| 1137 | { |
|---|
| 1138 | ++count; |
|---|
| 1139 | |
|---|
| 1140 | if(add) |
|---|
| 1141 | (*i)->SetAuraDuration(GetAuraDuration()); |
|---|
| 1142 | } |
|---|
| 1143 | } |
|---|
| 1144 | |
|---|
| 1145 | // at aura add aura not added yet, at aura remove aura already removed |
|---|
| 1146 | // in field stored (count-1) |
|---|
| 1147 | if(!add) |
|---|
| 1148 | --count; |
|---|
| 1149 | |
|---|
| 1150 | SetAuraApplication(slot, count); |
|---|
| 1151 | |
|---|
| 1152 | UpdateAuraDuration(); |
|---|
| 1153 | } |
|---|
| 1154 | |
|---|
| 1155 | /*********************************************************/ |
|---|
| 1156 | /*** BASIC AURA FUNCTION ***/ |
|---|
| 1157 | /*********************************************************/ |
|---|
| 1158 | void Aura::HandleAddModifier(bool apply, bool Real) |
|---|
| 1159 | { |
|---|
| 1160 | if(m_target->GetTypeId() != TYPEID_PLAYER || !Real) |
|---|
| 1161 | return; |
|---|
| 1162 | |
|---|
| 1163 | SpellEntry const *spellInfo = GetSpellProto(); |
|---|
| 1164 | if(!spellInfo) |
|---|
| 1165 | return; |
|---|
| 1166 | |
|---|
| 1167 | if(m_modifier.m_miscvalue >= MAX_SPELLMOD) |
|---|
| 1168 | return; |
|---|
| 1169 | |
|---|
| 1170 | if (apply) |
|---|
| 1171 | { |
|---|
| 1172 | // Add custom charges for some mod aura |
|---|
| 1173 | switch (m_spellProto->Id) |
|---|
| 1174 | { |
|---|
| 1175 | case 17941: // Shadow Trance |
|---|
| 1176 | case 22008: // Netherwind Focus |
|---|
| 1177 | case 34936: // Backlash |
|---|
| 1178 | m_procCharges = 1; |
|---|
| 1179 | break; |
|---|
| 1180 | } |
|---|
| 1181 | |
|---|
| 1182 | SpellModifier *mod = new SpellModifier; |
|---|
| 1183 | mod->op = SpellModOp(m_modifier.m_miscvalue); |
|---|
| 1184 | mod->value = m_modifier.m_amount; |
|---|
| 1185 | mod->type = SpellModType(m_modifier.m_auraname); // SpellModType value == spell aura types |
|---|
| 1186 | mod->spellId = GetId(); |
|---|
| 1187 | mod->effectId = m_effIndex; |
|---|
| 1188 | mod->lastAffected = NULL; |
|---|
| 1189 | |
|---|
| 1190 | uint64 spellAffectMask = spellmgr.GetSpellAffectMask(GetId(), m_effIndex); |
|---|
| 1191 | |
|---|
| 1192 | if (spellAffectMask) |
|---|
| 1193 | mod->mask = spellAffectMask; |
|---|
| 1194 | else |
|---|
| 1195 | mod->mask = spellInfo->EffectItemType[m_effIndex]; |
|---|
| 1196 | |
|---|
| 1197 | if (m_procCharges > 0) |
|---|
| 1198 | mod->charges = m_procCharges; |
|---|
| 1199 | else |
|---|
| 1200 | mod->charges = 0; |
|---|
| 1201 | |
|---|
| 1202 | m_spellmod = mod; |
|---|
| 1203 | } |
|---|
| 1204 | |
|---|
| 1205 | uint64 spellFamilyMask = m_spellmod->mask; |
|---|
| 1206 | |
|---|
| 1207 | ((Player*)m_target)->AddSpellMod(m_spellmod, apply); |
|---|
| 1208 | |
|---|
| 1209 | // reapply some passive spells after add/remove related spellmods |
|---|
| 1210 | if(spellInfo->SpellFamilyName==SPELLFAMILY_WARRIOR && (spellFamilyMask & 0x0000100000000000LL)) |
|---|
| 1211 | { |
|---|
| 1212 | m_target->RemoveAurasDueToSpell(45471); |
|---|
| 1213 | |
|---|
| 1214 | if(apply) |
|---|
| 1215 | m_target->CastSpell(m_target,45471,true); |
|---|
| 1216 | } |
|---|
| 1217 | } |
|---|
| 1218 | |
|---|
| 1219 | void Aura::TriggerSpell() |
|---|
| 1220 | { |
|---|
| 1221 | Unit* caster = GetCaster(); |
|---|
| 1222 | Unit* target = GetTriggerTarget(); |
|---|
| 1223 | |
|---|
| 1224 | if(!caster || !target) |
|---|
| 1225 | return; |
|---|
| 1226 | |
|---|
| 1227 | // generic casting code with custom spells and target/caster customs |
|---|
| 1228 | uint32 trigger_spell_id = GetSpellProto()->EffectTriggerSpell[m_effIndex]; |
|---|
| 1229 | |
|---|
| 1230 | uint64 originalCasterGUID = GetCasterGUID(); |
|---|
| 1231 | |
|---|
| 1232 | SpellEntry const *triggredSpellInfo = sSpellStore.LookupEntry(trigger_spell_id); |
|---|
| 1233 | SpellEntry const *auraSpellInfo = GetSpellProto(); |
|---|
| 1234 | uint32 auraId = auraSpellInfo->Id; |
|---|
| 1235 | |
|---|
| 1236 | // specific code for cases with no trigger spell provided in field |
|---|
| 1237 | if (triggredSpellInfo == NULL) |
|---|
| 1238 | { |
|---|
| 1239 | switch(auraSpellInfo->SpellFamilyName) |
|---|
| 1240 | { |
|---|
| 1241 | case SPELLFAMILY_GENERIC: |
|---|
| 1242 | { |
|---|
| 1243 | switch(auraId) |
|---|
| 1244 | { |
|---|
| 1245 | // Firestone Passive (1-5 rangs) |
|---|
| 1246 | case 758: |
|---|
| 1247 | case 17945: |
|---|
| 1248 | case 17947: |
|---|
| 1249 | case 17949: |
|---|
| 1250 | case 27252: |
|---|
| 1251 | { |
|---|
| 1252 | if (caster->GetTypeId()!=TYPEID_PLAYER) |
|---|
| 1253 | return; |
|---|
| 1254 | Item* item = ((Player*)caster)->GetWeaponForAttack(BASE_ATTACK); |
|---|
| 1255 | if (!item) |
|---|
| 1256 | return; |
|---|
| 1257 | uint32 enchant_id = 0; |
|---|
| 1258 | switch (GetId()) |
|---|
| 1259 | { |
|---|
| 1260 | case 758: enchant_id = 1803; break; // Rank 1 |
|---|
| 1261 | case 17945: enchant_id = 1823; break; // Rank 2 |
|---|
| 1262 | case 17947: enchant_id = 1824; break; // Rank 3 |
|---|
| 1263 | case 17949: enchant_id = 1825; break; // Rank 4 |
|---|
| 1264 | case 27252: enchant_id = 2645; break; // Rank 5 |
|---|
| 1265 | default: |
|---|
| 1266 | return; |
|---|
| 1267 | } |
|---|
| 1268 | // remove old enchanting before applying new |
|---|
| 1269 | ((Player*)caster)->ApplyEnchantment(item,TEMP_ENCHANTMENT_SLOT,false); |
|---|
| 1270 | item->SetEnchantment(TEMP_ENCHANTMENT_SLOT, enchant_id, m_modifier.periodictime+1000, 0); |
|---|
| 1271 | // add new enchanting |
|---|
| 1272 | ((Player*)caster)->ApplyEnchantment(item,TEMP_ENCHANTMENT_SLOT,true); |
|---|
| 1273 | return; |
|---|
| 1274 | } |
|---|
| 1275 | // // Periodic Mana Burn |
|---|
| 1276 | // case 812: break; |
|---|
| 1277 | // // Polymorphic Ray |
|---|
| 1278 | // case 6965: break; |
|---|
| 1279 | // // Fire Nova (1-7 Rangs) |
|---|
| 1280 | // case 8350: |
|---|
| 1281 | // case 8508: |
|---|
| 1282 | // case 8509: |
|---|
| 1283 | // case 11312: |
|---|
| 1284 | // case 11313: |
|---|
| 1285 | // case 25540: |
|---|
| 1286 | // case 25544: |
|---|
| 1287 | // break; |
|---|
| 1288 | // Thaumaturgy Channel |
|---|
| 1289 | case 9712: trigger_spell_id = 21029; break; |
|---|
| 1290 | // // Egan's Blaster |
|---|
| 1291 | // case 17368: break; |
|---|
| 1292 | // // Haunted |
|---|
| 1293 | // case 18347: break; |
|---|
| 1294 | // // Ranshalla Waiting |
|---|
| 1295 | // case 18953: break; |
|---|
| 1296 | // // Inferno |
|---|
| 1297 | // case 19695: break; |
|---|
| 1298 | // // Frostwolf Muzzle DND |
|---|
| 1299 | // case 21794: break; |
|---|
| 1300 | // // Alterac Ram Collar DND |
|---|
| 1301 | // case 21866: break; |
|---|
| 1302 | // // Celebras Waiting |
|---|
| 1303 | // case 21916: break; |
|---|
| 1304 | // Brood Affliction: Bronze |
|---|
| 1305 | case 23170: |
|---|
| 1306 | { |
|---|
| 1307 | m_target->CastSpell(m_target, 23171, true, 0, this); |
|---|
| 1308 | return; |
|---|
| 1309 | } |
|---|
| 1310 | // // Mark of Frost |
|---|
| 1311 | // case 23184: break; |
|---|
| 1312 | // Restoration |
|---|
| 1313 | case 23493: |
|---|
| 1314 | { |
|---|
| 1315 | int32 heal = caster->GetMaxHealth() / 10; |
|---|
| 1316 | caster->ModifyHealth( heal ); |
|---|
| 1317 | caster->SendHealSpellLog(caster, 23493, heal); |
|---|
| 1318 | |
|---|
| 1319 | int32 mana = caster->GetMaxPower(POWER_MANA); |
|---|
| 1320 | if (mana) |
|---|
| 1321 | { |
|---|
| 1322 | mana /= 10; |
|---|
| 1323 | caster->ModifyPower( POWER_MANA, mana ); |
|---|
| 1324 | caster->SendEnergizeSpellLog(caster, 23493, mana, POWER_MANA); |
|---|
| 1325 | } |
|---|
| 1326 | break; |
|---|
| 1327 | } |
|---|
| 1328 | // // Stoneclaw Totem Passive TEST |
|---|
| 1329 | // case 23792: break; |
|---|
| 1330 | // // Axe Flurry |
|---|
| 1331 | // case 24018: break; |
|---|
| 1332 | // // Mark of Arlokk |
|---|
| 1333 | // case 24210: break; |
|---|
| 1334 | // // Restoration |
|---|
| 1335 | // case 24379: break; |
|---|
| 1336 | // // Happy Pet |
|---|
| 1337 | // case 24716: break; |
|---|
| 1338 | // // Dream Fog |
|---|
| 1339 | // case 24780: break; |
|---|
| 1340 | // // Cannon Prep |
|---|
| 1341 | // case 24832: break; |
|---|
| 1342 | // // Shadow Bolt Whirl |
|---|
| 1343 | // case 24834: break; |
|---|
| 1344 | // // Stink Trap |
|---|
| 1345 | // case 24918: break; |
|---|
| 1346 | // // Mark of Nature |
|---|
| 1347 | // case 25041: break; |
|---|
| 1348 | // // Agro Drones |
|---|
| 1349 | // case 25152: break; |
|---|
| 1350 | // // Consume |
|---|
| 1351 | // case 25371: break; |
|---|
| 1352 | // // Pain Spike |
|---|
| 1353 | // case 25572: break; |
|---|
| 1354 | // // Rotate 360 |
|---|
| 1355 | // case 26009: break; |
|---|
| 1356 | // // Rotate -360 |
|---|
| 1357 | // case 26136: break; |
|---|
| 1358 | // // Consume |
|---|
| 1359 | // case 26196: break; |
|---|
| 1360 | // // Berserk |
|---|
| 1361 | // case 26615: break; |
|---|
| 1362 | // // Defile |
|---|
| 1363 | // case 27177: break; |
|---|
| 1364 | // // Teleport: IF/UC |
|---|
| 1365 | // case 27601: break; |
|---|
| 1366 | // // Five Fat Finger Exploding Heart Technique |
|---|
| 1367 | // case 27673: break; |
|---|
| 1368 | // // Nitrous Boost |
|---|
| 1369 | // case 27746: break; |
|---|
| 1370 | // // Steam Tank Passive |
|---|
| 1371 | // case 27747: break; |
|---|
| 1372 | // // Frost Blast |
|---|
| 1373 | // case 27808: break; |
|---|
| 1374 | // // Detonate Mana |
|---|
| 1375 | // case 27819: break; |
|---|
| 1376 | // // Controller Timer |
|---|
| 1377 | // case 28095: break; |
|---|
| 1378 | // // Stalagg Chain |
|---|
| 1379 | // case 28096: break; |
|---|
| 1380 | // // Stalagg Tesla Passive |
|---|
| 1381 | // case 28097: break; |
|---|
| 1382 | // // Feugen Tesla Passive |
|---|
| 1383 | // case 28109: break; |
|---|
| 1384 | // // Feugen Chain |
|---|
| 1385 | // case 28111: break; |
|---|
| 1386 | // // Mark of Didier |
|---|
| 1387 | // case 28114: break; |
|---|
| 1388 | // // Communique Timer, camp |
|---|
| 1389 | // case 28346: break; |
|---|
| 1390 | // // Icebolt |
|---|
| 1391 | // case 28522: break; |
|---|
| 1392 | // // Silithyst |
|---|
| 1393 | // case 29519: break; |
|---|
| 1394 | // // Inoculate Nestlewood Owlkin |
|---|
| 1395 | case 29528: trigger_spell_id = 28713; break; |
|---|
| 1396 | // // Overload |
|---|
| 1397 | // case 29768: break; |
|---|
| 1398 | // // Return Fire |
|---|
| 1399 | // case 29788: break; |
|---|
| 1400 | // // Return Fire |
|---|
| 1401 | // case 29793: break; |
|---|
| 1402 | // // Return Fire |
|---|
| 1403 | // case 29794: break; |
|---|
| 1404 | // // Guardian of Icecrown Passive |
|---|
| 1405 | // case 29897: break; |
|---|
| 1406 | // Feed Captured Animal |
|---|
| 1407 | case 29917: trigger_spell_id = 29916; break; |
|---|
| 1408 | // // Flame Wreath |
|---|
| 1409 | // case 29946: break; |
|---|
| 1410 | // // Flame Wreath |
|---|
| 1411 | // case 29947: break; |
|---|
| 1412 | // // Mind Exhaustion Passive |
|---|
| 1413 | // case 30025: break; |
|---|
| 1414 | // // Nether Beam - Serenity |
|---|
| 1415 | // case 30401: break; |
|---|
| 1416 | // Extract Gas |
|---|
| 1417 | case 30427: |
|---|
| 1418 | { |
|---|
| 1419 | // move loot to player inventory and despawn target |
|---|
| 1420 | if(caster->GetTypeId() ==TYPEID_PLAYER && |
|---|
| 1421 | target->GetTypeId() == TYPEID_UNIT && |
|---|
| 1422 | ((Creature*)target)->GetCreatureInfo()->type == CREATURE_TYPE_GAS_CLOUD) |
|---|
| 1423 | { |
|---|
| 1424 | Player* player = (Player*)caster; |
|---|
| 1425 | Creature* creature = (Creature*)target; |
|---|
| 1426 | // missing lootid has been reported on startup - just return |
|---|
| 1427 | if (!creature->GetCreatureInfo()->SkinLootId) |
|---|
| 1428 | { |
|---|
| 1429 | return; |
|---|
| 1430 | } |
|---|
| 1431 | Loot *loot = &creature->loot; |
|---|
| 1432 | loot->clear(); |
|---|
| 1433 | loot->FillLoot(creature->GetCreatureInfo()->SkinLootId, LootTemplates_Skinning, NULL); |
|---|
| 1434 | for(uint8 i=0;i<loot->items.size();i++) |
|---|
| 1435 | { |
|---|
| 1436 | LootItem *item = loot->LootItemInSlot(i,player); |
|---|
| 1437 | ItemPosCountVec dest; |
|---|
| 1438 | uint8 msg = player->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, item->itemid, item->count ); |
|---|
| 1439 | if ( msg == EQUIP_ERR_OK ) |
|---|
| 1440 | { |
|---|
| 1441 | Item * newitem = player->StoreNewItem( dest, item->itemid, true, item->randomPropertyId); |
|---|
| 1442 | |
|---|
| 1443 | player->SendNewItem(newitem, uint32(item->count), false, false, true); |
|---|
| 1444 | } |
|---|
| 1445 | else |
|---|
| 1446 | player->SendEquipError( msg, NULL, NULL ); |
|---|
| 1447 | } |
|---|
| 1448 | creature->setDeathState(JUST_DIED); |
|---|
| 1449 | creature->RemoveCorpse(); |
|---|
| 1450 | creature->SetHealth(0); // just for nice GM-mode view |
|---|
| 1451 | } |
|---|
| 1452 | return; |
|---|
| 1453 | break; |
|---|
| 1454 | } |
|---|
| 1455 | // Quake |
|---|
| 1456 | case 30576: trigger_spell_id = 30571; break; |
|---|
| 1457 | // // Burning Maul |
|---|
| 1458 | // case 30598: break; |
|---|
| 1459 | // // Regeneration |
|---|
| 1460 | // case 30799: |
|---|
| 1461 | // case 30800: |
|---|
| 1462 | // case 30801: |
|---|
| 1463 | // break; |
|---|
| 1464 | // // Despawn Self - Smoke cloud |
|---|
| 1465 | // case 31269: break; |
|---|
| 1466 | // // Time Rift Periodic |
|---|
| 1467 | // case 31320: break; |
|---|
| 1468 | // // Corrupt Medivh |
|---|
| 1469 | // case 31326: break; |
|---|
| 1470 | // Doom |
|---|
| 1471 | case 31347: |
|---|
| 1472 | { |
|---|
| 1473 | m_target->CastSpell(m_target,31350,true); |
|---|
| 1474 | m_target->DealDamage(m_target, m_target->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); |
|---|
| 1475 | return; |
|---|
| 1476 | } |
|---|
| 1477 | // Spellcloth |
|---|
| 1478 | case 31373: |
|---|
| 1479 | { |
|---|
| 1480 | // Summon Elemental after create item |
|---|
| 1481 | caster->SummonCreature(17870, 0, 0, 0, caster->GetOrientation(), TEMPSUMMON_DEAD_DESPAWN, 0); |
|---|
| 1482 | return; |
|---|
| 1483 | } |
|---|
| 1484 | // // Bloodmyst Tesla |
|---|
| 1485 | // case 31611: break; |
|---|
| 1486 | // // Doomfire |
|---|
| 1487 | // case 31944: break; |
|---|
| 1488 | // // Teleport Test |
|---|
| 1489 | // case 32236: break; |
|---|
| 1490 | // // Earthquake |
|---|
| 1491 | // case 32686: break; |
|---|
| 1492 | // // Possess |
|---|
| 1493 | // case 33401: break; |
|---|
| 1494 | // // Draw Shadows |
|---|
| 1495 | // case 33563: break; |
|---|
| 1496 | // // Murmur's Touch |
|---|
| 1497 | // case 33711: break; |
|---|
| 1498 | // Flame Quills |
|---|
| 1499 | case 34229: |
|---|
| 1500 | { |
|---|
| 1501 | // cast 24 spells 34269-34289, 34314-34316 |
|---|
| 1502 | for(uint32 spell_id = 34269; spell_id != 34290; ++spell_id) |
|---|
| 1503 | caster->CastSpell(m_target,spell_id,true); |
|---|
| 1504 | for(uint32 spell_id = 34314; spell_id != 34317; ++spell_id) |
|---|
| 1505 | caster->CastSpell(m_target,spell_id,true); |
|---|
| 1506 | return; |
|---|
| 1507 | } |
|---|
| 1508 | // // Gravity Lapse |
|---|
| 1509 | // case 34480: break; |
|---|
| 1510 | // // Tornado |
|---|
| 1511 | // case 34683: break; |
|---|
| 1512 | // // Frostbite Rotate |
|---|
| 1513 | // case 34748: break; |
|---|
| 1514 | // // Arcane Flurry |
|---|
| 1515 | // case 34821: break; |
|---|
| 1516 | // // Interrupt Shutdown |
|---|
| 1517 | // case 35016: break; |
|---|
| 1518 | // // Interrupt Shutdown |
|---|
| 1519 | // case 35176: break; |
|---|
| 1520 | // // Inferno |
|---|
| 1521 | // case 35268: break; |
|---|
| 1522 | // // Salaadin's Tesla |
|---|
| 1523 | // case 35515: break; |
|---|
| 1524 | // // Ethereal Channel (Red) |
|---|
| 1525 | // case 35518: break; |
|---|
| 1526 | // // Nether Vapor |
|---|
| 1527 | // case 35879: break; |
|---|
| 1528 | // // Dark Portal Storm |
|---|
| 1529 | // case 36018: break; |
|---|
| 1530 | // // Burning Maul |
|---|
| 1531 | // case 36056: break; |
|---|
| 1532 | // // Living Grove Defender Lifespan |
|---|
| 1533 | // case 36061: break; |
|---|
| 1534 | // // Professor Dabiri Talks |
|---|
| 1535 | // case 36064: break; |
|---|
| 1536 | // // Kael Gaining Power |
|---|
| 1537 | // case 36091: break; |
|---|
| 1538 | // // They Must Burn Bomb Aura |
|---|
| 1539 | // case 36344: break; |
|---|
| 1540 | // // They Must Burn Bomb Aura (self) |
|---|
| 1541 | // case 36350: break; |
|---|
| 1542 | // // Stolen Ravenous Ravager Egg |
|---|
| 1543 | // case 36401: break; |
|---|
| 1544 | // // Activated Cannon |
|---|
| 1545 | // case 36410: break; |
|---|
| 1546 | // // Stolen Ravenous Ravager Egg |
|---|
| 1547 | // case 36418: break; |
|---|
| 1548 | // // Enchanted Weapons |
|---|
| 1549 | // case 36510: break; |
|---|
| 1550 | // // Cursed Scarab Periodic |
|---|
| 1551 | // case 36556: break; |
|---|
| 1552 | // // Cursed Scarab Despawn Periodic |
|---|
| 1553 | // case 36561: break; |
|---|
| 1554 | // // Vision Guide |
|---|
| 1555 | // case 36573: break; |
|---|
| 1556 | // // Cannon Charging (platform) |
|---|
| 1557 | // case 36785: break; |
|---|
| 1558 | // // Cannon Charging (self) |
|---|
| 1559 | // case 36860: break; |
|---|
| 1560 | // Remote Toy |
|---|
| 1561 | case 37027: trigger_spell_id = 37029; break; |
|---|
| 1562 | // // Mark of Death |
|---|
| 1563 | // case 37125: break; |
|---|
| 1564 | // // Arcane Flurry |
|---|
| 1565 | // case 37268: break; |
|---|
| 1566 | // // Spout |
|---|
| 1567 | // case 37429: break; |
|---|
| 1568 | // // Spout |
|---|
| 1569 | // case 37430: break; |
|---|
| 1570 | // // Karazhan - Chess NPC AI, Snapshot timer |
|---|
| 1571 | // case 37440: break; |
|---|
| 1572 | // // Karazhan - Chess NPC AI, action timer |
|---|
| 1573 | // case 37504: break; |
|---|
| 1574 | // // Karazhan - Chess: Is Square OCCUPIED aura (DND) |
|---|
| 1575 | // case 39400: break; |
|---|
| 1576 | // // Banish |
|---|
| 1577 | // case 37546: break; |
|---|
| 1578 | // // Shriveling Gaze |
|---|
| 1579 | // case 37589: break; |
|---|
| 1580 | // // Fake Aggro Radius (2 yd) |
|---|
| 1581 | // case 37815: break; |
|---|
| 1582 | // // Corrupt Medivh |
|---|
| 1583 | // case 37853: break; |
|---|
| 1584 | // Eye of Grillok |
|---|
| 1585 | case 38495: |
|---|
| 1586 | { |
|---|
| 1587 | m_target->CastSpell(m_target, 38530, true); |
|---|
| 1588 | return; |
|---|
| 1589 | } |
|---|
| 1590 | // Absorb Eye of Grillok (Zezzak's Shard) |
|---|
| 1591 | case 38554: |
|---|
| 1592 | { |
|---|
| 1593 | if(m_target->GetTypeId() != TYPEID_UNIT) |
|---|
| 1594 | return; |
|---|
| 1595 | |
|---|
| 1596 | caster->CastSpell(caster, 38495, true); |
|---|
| 1597 | |
|---|
| 1598 | Creature* creatureTarget = (Creature*)m_target; |
|---|
| 1599 | |
|---|
| 1600 | creatureTarget->setDeathState(JUST_DIED); |
|---|
| 1601 | creatureTarget->RemoveCorpse(); |
|---|
| 1602 | creatureTarget->SetHealth(0); // just for nice GM-mode view |
|---|
| 1603 | return; |
|---|
| 1604 | } |
|---|
| 1605 | // // Magic Sucker Device timer |
|---|
| 1606 | // case 38672: break; |
|---|
| 1607 | // // Tomb Guarding Charging |
|---|
| 1608 | // case 38751: break; |
|---|
| 1609 | // // Murmur's Touch |
|---|
| 1610 | // case 38794: break; |
|---|
| 1611 | // // Activate Nether-wraith Beacon (31742 Nether-wraith Beacon item) |
|---|
| 1612 | // case 39105: break; |
|---|
| 1613 | // // Drain World Tree Visual |
|---|
| 1614 | // case 39140: break; |
|---|
| 1615 | // // Quest - Dustin's Undead Dragon Visual aura |
|---|
| 1616 | // case 39259: break; |
|---|
| 1617 | // // Hellfire - The Exorcism, Jules releases darkness, aura |
|---|
| 1618 | // case 39306: break; |
|---|
| 1619 | // // Inferno |
|---|
| 1620 | // case 39346: break; |
|---|
| 1621 | // // Enchanted Weapons |
|---|
| 1622 | // case 39489: break; |
|---|
| 1623 | // // Shadow Bolt Whirl |
|---|
| 1624 | // case 39630: break; |
|---|
| 1625 | // // Shadow Bolt Whirl |
|---|
| 1626 | // case 39634: break; |
|---|
| 1627 | // // Shadow Inferno |
|---|
| 1628 | // case 39645: break; |
|---|
| 1629 | // Tear of Azzinoth Summon Channel - it's not really supposed to do anything,and this only prevents the console spam |
|---|
| 1630 | case 39857: trigger_spell_id = 39856; break; |
|---|
| 1631 | // // Soulgrinder Ritual Visual (Smashed) |
|---|
| 1632 | // case 39974: break; |
|---|
| 1633 | // // Simon Game Pre-game timer |
|---|
| 1634 | // case 40041: break; |
|---|
| 1635 | // // Knockdown Fel Cannon: The Aggro Check Aura |
|---|
| 1636 | // case 40113: break; |
|---|
| 1637 | // // Spirit Lance |
|---|
| 1638 | // case 40157: break; |
|---|
| 1639 | // // Demon Transform 2 |
|---|
| 1640 | // case 40398: break; |
|---|
| 1641 | // // Demon Transform 1 |
|---|
| 1642 | // case 40511: break; |
|---|
| 1643 | // // Ancient Flames |
|---|
| 1644 | // case 40657: break; |
|---|
| 1645 | // // Ethereal Ring Cannon: Cannon Aura |
|---|
| 1646 | // case 40734: break; |
|---|
| 1647 | // // Cage Trap |
|---|
| 1648 | // case 40760: break; |
|---|
| 1649 | // // Random Periodic |
|---|
| 1650 | // case 40867: break; |
|---|
| 1651 | // // Prismatic Shield |
|---|
| 1652 | // case 40879: break; |
|---|
| 1653 | // Aura of Desire |
|---|
| 1654 | case 41350: |
|---|
| 1655 | { |
|---|
| 1656 | Unit::AuraList const& mMod = m_target->GetAurasByType(SPELL_AURA_MOD_INCREASE_ENERGY_PERCENT); |
|---|
| 1657 | for(Unit::AuraList::const_iterator i = mMod.begin(); i != mMod.end(); ++i) |
|---|
| 1658 | { |
|---|
| 1659 | if ((*i)->GetId() == 41350) |
|---|
| 1660 | { |
|---|
| 1661 | (*i)->ApplyModifier(false); |
|---|
| 1662 | (*i)->GetModifier()->m_amount -= 5; |
|---|
| 1663 | (*i)->ApplyModifier(true); |
|---|
| 1664 | break; |
|---|
| 1665 | } |
|---|
| 1666 | } |
|---|
| 1667 | }break; |
|---|
| 1668 | // // Dementia |
|---|
| 1669 | // case 41404: break; |
|---|
| 1670 | // // Chaos Form |
|---|
| 1671 | // case 41629: break; |
|---|
| 1672 | // // Alert Drums |
|---|
| 1673 | // case 42177: break; |
|---|
| 1674 | // // Spout |
|---|
| 1675 | // case 42581: break; |
|---|
| 1676 | // // Spout |
|---|
| 1677 | // case 42582: break; |
|---|
| 1678 | // // Return to the Spirit Realm |
|---|
| 1679 | // case 44035: break; |
|---|
| 1680 | // // Curse of Boundless Agony |
|---|
| 1681 | // case 45050: break; |
|---|
| 1682 | // // Earthquake |
|---|
| 1683 | // case 46240: break; |
|---|
| 1684 | // Personalized Weather |
|---|
| 1685 | case 46736: trigger_spell_id = 46737; break; |
|---|
| 1686 | // // Stay Submerged |
|---|
| 1687 | // case 46981: break; |
|---|
| 1688 | // // Dragonblight Ram |
|---|
| 1689 | // case 47015: break; |
|---|
| 1690 | // // Party G.R.E.N.A.D.E. |
|---|
| 1691 | // case 51510: break; |
|---|
| 1692 | default: |
|---|
| 1693 | break; |
|---|
| 1694 | } |
|---|
| 1695 | break; |
|---|
| 1696 | } |
|---|
| 1697 | case SPELLFAMILY_MAGE: |
|---|
| 1698 | { |
|---|
| 1699 | switch(auraId) |
|---|
| 1700 | { |
|---|
| 1701 | // Invisibility |
|---|
| 1702 | case 66: |
|---|
| 1703 | { |
|---|
| 1704 | if(!m_duration) |
|---|
| 1705 | m_target->CastSpell(m_target, 32612, true, NULL, this); |
|---|
| 1706 | return; |
|---|
| 1707 | } |
|---|
| 1708 | default: |
|---|
| 1709 | break; |
|---|
| 1710 | } |
|---|
| 1711 | break; |
|---|
| 1712 | } |
|---|
| 1713 | // case SPELLFAMILY_WARRIOR: |
|---|
| 1714 | // { |
|---|
| 1715 | // switch(auraId) |
|---|
| 1716 | // { |
|---|
| 1717 | // // Wild Magic |
|---|
| 1718 | // case 23410: break; |
|---|
| 1719 | // // Corrupted Totems |
|---|
| 1720 | // case 23425: break; |
|---|
| 1721 | // default: |
|---|
| 1722 | // break; |
|---|
| 1723 | // } |
|---|
| 1724 | // break; |
|---|
| 1725 | // } |
|---|
| 1726 | // case SPELLFAMILY_PRIEST: |
|---|
| 1727 | // { |
|---|
| 1728 | // switch(auraId) |
|---|
| 1729 | // { |
|---|
| 1730 | // // Blue Beam |
|---|
| 1731 | // case 32930: break; |
|---|
| 1732 | // // Fury of the Dreghood Elders |
|---|
| 1733 | // case 35460: break; |
|---|
| 1734 | // default: |
|---|
| 1735 | // break; |
|---|
| 1736 | // } |
|---|
| 1737 | // break; |
|---|
| 1738 | // } |
|---|
| 1739 | case SPELLFAMILY_DRUID: |
|---|
| 1740 | { |
|---|
| 1741 | switch(auraId) |
|---|
| 1742 | { |
|---|
| 1743 | // Cat Form |
|---|
| 1744 | // trigger_spell_id not set and unknown effect triggered in this case, ignoring for while |
|---|
| 1745 | case 768: |
|---|
| 1746 | return; |
|---|
| 1747 | // Frenzied Regeneration |
|---|
| 1748 | case 22842: |
|---|
| 1749 | case 22895: |
|---|
| 1750 | case 22896: |
|---|
| 1751 | case 26999: |
|---|
| 1752 | { |
|---|
| 1753 | int32 LifePerRage = GetModifier()->m_amount; |
|---|
| 1754 | |
|---|
| 1755 | int32 lRage = m_target->GetPower(POWER_RAGE); |
|---|
| 1756 | if(lRage > 100) // rage stored as rage*10 |
|---|
| 1757 | lRage = 100; |
|---|
| 1758 | m_target->ModifyPower(POWER_RAGE, -lRage); |
|---|
| 1759 | int32 FRTriggerBasePoints = int32(lRage*LifePerRage/10); |
|---|
| 1760 | m_target->CastCustomSpell(m_target,22845,&FRTriggerBasePoints,NULL,NULL,true,NULL,this); |
|---|
| 1761 | return; |
|---|
| 1762 | } |
|---|
| 1763 | default: |
|---|
| 1764 | break; |
|---|
| 1765 | } |
|---|
| 1766 | break; |
|---|
| 1767 | } |
|---|
| 1768 | |
|---|
| 1769 | // case SPELLFAMILY_HUNTER: |
|---|
| 1770 | // { |
|---|
| 1771 | // switch(auraId) |
|---|
| 1772 | // { |
|---|
| 1773 | // //Frost Trap Aura |
|---|
| 1774 | // case 13810: |
|---|
| 1775 | // return; |
|---|
| 1776 | // //Rizzle's Frost Trap |
|---|
| 1777 | // case 39900: |
|---|
| 1778 | // return; |
|---|
| 1779 | // // Tame spells |
|---|
| 1780 | // case 19597: // Tame Ice Claw Bear |
|---|
| 1781 | // case 19676: // Tame Snow Leopard |
|---|
| 1782 | // case 19677: // Tame Large Crag Boar |
|---|
| 1783 | // case 19678: // Tame Adult Plainstrider |
|---|
| 1784 | // case 19679: // Tame Prairie Stalker |
|---|
| 1785 | // case 19680: // Tame Swoop |
|---|
| 1786 | // case 19681: // Tame Dire Mottled Boar |
|---|
| 1787 | // case 19682: // Tame Surf Crawler |
|---|
| 1788 | // case 19683: // Tame Armored Scorpid |
|---|
| 1789 | // case 19684: // Tame Webwood Lurker |
|---|
| 1790 | // case 19685: // Tame Nightsaber Stalker |
|---|
| 1791 | // case 19686: // Tame Strigid Screecher |
|---|
| 1792 | // case 30100: // Tame Crazed Dragonhawk |
|---|
| 1793 | // case 30103: // Tame Elder Springpaw |
|---|
| 1794 | // case 30104: // Tame Mistbat |
|---|
| 1795 | // case 30647: // Tame Barbed Crawler |
|---|
| 1796 | // case 30648: // Tame Greater Timberstrider |
|---|
| 1797 | // case 30652: // Tame Nightstalker |
|---|
| 1798 | // return; |
|---|
| 1799 | // default: |
|---|
| 1800 | // break; |
|---|
| 1801 | // } |
|---|
| 1802 | // break; |
|---|
| 1803 | // } |
|---|
| 1804 | case SPELLFAMILY_SHAMAN: |
|---|
| 1805 | { |
|---|
| 1806 | switch(auraId) |
|---|
| 1807 | { |
|---|
| 1808 | // Lightning Shield (The Earthshatterer set trigger after cast Lighting Shield) |
|---|
| 1809 | case 28820: |
|---|
| 1810 | { |
|---|
| 1811 | // Need remove self if Lightning Shield not active |
|---|
| 1812 | Unit::AuraMap const& auras = target->GetAuras(); |
|---|
| 1813 | for(Unit::AuraMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) |
|---|
| 1814 | { |
|---|
| 1815 | SpellEntry const* spell = itr->second->GetSpellProto(); |
|---|
| 1816 | if( spell->SpellFamilyName == SPELLFAMILY_SHAMAN && |
|---|
| 1817 | spell->SpellFamilyFlags & 0x0000000000000400L) |
|---|
| 1818 | return; |
|---|
| 1819 | } |
|---|
| 1820 | target->RemoveAurasDueToSpell(28820); |
|---|
| 1821 | return; |
|---|
| 1822 | } |
|---|
| 1823 | // Totemic Mastery (Skyshatter Regalia (Shaman Tier 6) - bonus) |
|---|
| 1824 | case 38443: |
|---|
| 1825 | { |
|---|
| 1826 | bool all = true; |
|---|
| 1827 | for(int i = 0; i < MAX_TOTEM; ++i) |
|---|
| 1828 | { |
|---|
| 1829 | if(!caster->m_TotemSlot[i]) |
|---|
| 1830 | { |
|---|
| 1831 | all = false; |
|---|
| 1832 | break; |
|---|
| 1833 | } |
|---|
| 1834 | } |
|---|
| 1835 | |
|---|
| 1836 | if(all) |
|---|
| 1837 | caster->CastSpell(caster,38437,true); |
|---|
| 1838 | else |
|---|
| 1839 | caster->RemoveAurasDueToSpell(38437); |
|---|
| 1840 | return; |
|---|
| 1841 | } |
|---|
| 1842 | default: |
|---|
| 1843 | break; |
|---|
| 1844 | } |
|---|
| 1845 | break; |
|---|
| 1846 | } |
|---|
| 1847 | default: |
|---|
| 1848 | break; |
|---|
| 1849 | } |
|---|
| 1850 | // Reget trigger spell proto |
|---|
| 1851 | triggredSpellInfo = sSpellStore.LookupEntry(trigger_spell_id); |
|---|
| 1852 | if(triggredSpellInfo == NULL) |
|---|
| 1853 | { |
|---|
| 1854 | sLog.outError("Aura::TriggerSpell: Spell %u have 0 in EffectTriggered[%d], not handled custom case?",GetId(),GetEffIndex()); |
|---|
| 1855 | return; |
|---|
| 1856 | } |
|---|
| 1857 | } |
|---|
| 1858 | else |
|---|
| 1859 | { |
|---|
| 1860 | // Spell exist but require costum code |
|---|
| 1861 | switch(auraId) |
|---|
| 1862 | { |
|---|
| 1863 | // Curse of Idiocy |
|---|
| 1864 | case 1010: |
|---|
| 1865 | { |
|---|
| 1866 | // TODO: spell casted by result in correct way mostly |
|---|
| 1867 | // BUT: |
|---|
| 1868 | // 1) target show casting at each triggered cast: target don't must show casting animation for any triggered spell |
|---|
| 1869 | // but must show affect apply like item casting |
|---|
| 1870 | // 2) maybe aura must be replace by new with accumulative stat mods insteed stacking |
|---|
| 1871 | |
|---|
| 1872 | // prevent cast by triggered auras |
|---|
| 1873 | if(m_caster_guid == m_target->GetGUID()) |
|---|
| 1874 | return; |
|---|
| 1875 | |
|---|
| 1876 | // stop triggering after each affected stats lost > 90 |
|---|
| 1877 | int32 intelectLoss = 0; |
|---|
| 1878 | int32 spiritLoss = 0; |
|---|
| 1879 | |
|---|
| 1880 | Unit::AuraList const& mModStat = m_target->GetAurasByType(SPELL_AURA_MOD_STAT); |
|---|
| 1881 | for(Unit::AuraList::const_iterator i = mModStat.begin(); i != mModStat.end(); ++i) |
|---|
| 1882 | { |
|---|
| 1883 | if ((*i)->GetId() == 1010) |
|---|
| 1884 | { |
|---|
| 1885 | switch((*i)->GetModifier()->m_miscvalue) |
|---|
| 1886 | { |
|---|
| 1887 | case STAT_INTELLECT: intelectLoss += (*i)->GetModifier()->m_amount; break; |
|---|
| 1888 | case STAT_SPIRIT: spiritLoss += (*i)->GetModifier()->m_amount; break; |
|---|
| 1889 | default: break; |
|---|
| 1890 | } |
|---|
| 1891 | } |
|---|
| 1892 | } |
|---|
| 1893 | |
|---|
| 1894 | if(intelectLoss <= -90 && spiritLoss <= -90) |
|---|
| 1895 | return; |
|---|
| 1896 | |
|---|
| 1897 | caster = target; |
|---|
| 1898 | originalCasterGUID = 0; |
|---|
| 1899 | break; |
|---|
| 1900 | } |
|---|
| 1901 | // Mana Tide |
|---|
| 1902 | case 16191: |
|---|
| 1903 | { |
|---|
| 1904 | caster->CastCustomSpell(target, trigger_spell_id, &m_modifier.m_amount, NULL, NULL, true, NULL, this, originalCasterGUID); |
|---|
| 1905 | return; |
|---|
| 1906 | } |
|---|
| 1907 | } |
|---|
| 1908 | } |
|---|
| 1909 | // All ok cast by default case |
|---|
| 1910 | Spell *spell = new Spell(caster, triggredSpellInfo, true, originalCasterGUID ); |
|---|
| 1911 | |
|---|
| 1912 | SpellCastTargets targets; |
|---|
| 1913 | targets.setUnitTarget( target ); |
|---|
| 1914 | |
|---|
| 1915 | // if spell create dynamic object extract area from it |
|---|
| 1916 | if(DynamicObject* dynObj = caster->GetDynObject(GetId())) |
|---|
| 1917 | targets.setDestination(dynObj->GetPositionX(),dynObj->GetPositionY(),dynObj->GetPositionZ()); |
|---|
| 1918 | |
|---|
| 1919 | spell->prepare(&targets, this); |
|---|
| 1920 | } |
|---|
| 1921 | |
|---|
| 1922 | /*********************************************************/ |
|---|
| 1923 | /*** AURA EFFECTS ***/ |
|---|
| 1924 | /*********************************************************/ |
|---|
| 1925 | |
|---|
| 1926 | void Aura::HandleAuraDummy(bool apply, bool Real) |
|---|
| 1927 | { |
|---|
| 1928 | // spells required only Real aura add/remove |
|---|
| 1929 | if(!Real) |
|---|
| 1930 | return; |
|---|
| 1931 | |
|---|
| 1932 | Unit* caster = GetCaster(); |
|---|
| 1933 | |
|---|
| 1934 | // AT APPLY |
|---|
| 1935 | if(apply) |
|---|
| 1936 | { |
|---|
| 1937 | switch(GetId()) |
|---|
| 1938 | { |
|---|
| 1939 | case 1515: // Tame beast |
|---|
| 1940 | // FIX_ME: this is 2.0.12 threat effect replaced in 2.1.x by dummy aura, must be checked for correctness |
|---|
| 1941 | if( caster && m_target->CanHaveThreatList()) |
|---|
| 1942 | m_target->AddThreat(caster, 10.0f); |
|---|
| 1943 | return; |
|---|
| 1944 | case 13139: // net-o-matic |
|---|
| 1945 | // root to self part of (root_target->charge->root_self sequence |
|---|
| 1946 | if(caster) |
|---|
| 1947 | caster->CastSpell(caster,13138,true,NULL,this); |
|---|
| 1948 | return; |
|---|
| 1949 | case 39850: // Rocket Blast |
|---|
| 1950 | if(roll_chance_i(20)) // backfire stun |
|---|
| 1951 | m_target->CastSpell(m_target, 51581, true, NULL, this); |
|---|
| 1952 | return; |
|---|
| 1953 | case 43873: // Headless Horseman Laugh |
|---|
| 1954 | if(caster->GetTypeId() == TYPEID_PLAYER) |
|---|
| 1955 | { |
|---|
| 1956 | ((Player*)caster)->SendPlaySound(11965, false); |
|---|
| 1957 | } |
|---|
| 1958 | return; |
|---|
| 1959 | case 46354: // Blood Elf Illusion |
|---|
| 1960 | if(caster) |
|---|
| 1961 | { |
|---|
| 1962 | switch(caster->getGender()) |
|---|
| 1963 | { |
|---|
| 1964 | case GENDER_FEMALE: |
|---|
| 1965 | caster->CastSpell(m_target,46356,true,NULL,this); |
|---|
| 1966 | break; |
|---|
| 1967 | case GENDER_MALE: |
|---|
| 1968 | caster->CastSpell(m_target,46355,true,NULL,this); |
|---|
| 1969 | break; |
|---|
| 1970 | default: |
|---|
| 1971 | break; |
|---|
| 1972 | } |
|---|
| 1973 | } |
|---|
| 1974 | return; |
|---|
| 1975 | case 46699: // Requires No Ammo |
|---|
| 1976 | if(m_target->GetTypeId()==TYPEID_PLAYER) |
|---|
| 1977 | ((Player*)m_target)->RemoveAmmo(); // not use ammo and not allow use |
|---|
| 1978 | return; |
|---|
| 1979 | } |
|---|
| 1980 | |
|---|
| 1981 | // Earth Shield |
|---|
| 1982 | if ( caster && GetSpellProto()->SpellFamilyName == SPELLFAMILY_SHAMAN && (GetSpellProto()->SpellFamilyFlags & 0x40000000000LL)) |
|---|
| 1983 | { |
|---|
| 1984 | // prevent double apply bonuses |
|---|
| 1985 | if(m_target->GetTypeId()!=TYPEID_PLAYER || !((Player*)m_target)->GetSession()->PlayerLoading()) |
|---|
| 1986 | m_modifier.m_amount = caster->SpellHealingBonus(GetSpellProto(), m_modifier.m_amount, SPELL_DIRECT_DAMAGE, m_target); |
|---|
| 1987 | return; |
|---|
| 1988 | } |
|---|
| 1989 | } |
|---|
| 1990 | // AT REMOVE |
|---|
| 1991 | else |
|---|
| 1992 | { |
|---|
| 1993 | if( m_target->GetTypeId() == TYPEID_PLAYER && |
|---|
| 1994 | ( GetSpellProto()->Effect[0]==72 || GetSpellProto()->Effect[0]==6 && |
|---|
| 1995 | ( GetSpellProto()->EffectApplyAuraName[0]==1 || GetSpellProto()->EffectApplyAuraName[0]==128 ) ) ) |
|---|
| 1996 | { |
|---|
| 1997 | // spells with SpellEffect=72 and aura=4: 6196, 6197, 21171, 21425 |
|---|
| 1998 | m_target->SetUInt64Value(PLAYER_FARSIGHT, 0); |
|---|
| 1999 | WorldPacket data(SMSG_CLEAR_FAR_SIGHT_IMMEDIATE, 0); |
|---|
| 2000 | ((Player*)m_target)->GetSession()->SendPacket(&data); |
|---|
| 2001 | return; |
|---|
| 2002 | } |
|---|
| 2003 | |
|---|
| 2004 | if( (IsQuestTameSpell(GetId())) && caster && caster->isAlive() && m_target->isAlive()) |
|---|
| 2005 | { |
|---|
| 2006 | uint32 finalSpelId = 0; |
|---|
| 2007 | switch(GetId()) |
|---|
| 2008 | { |
|---|
| 2009 | case 19548: finalSpelId = 19597; break; |
|---|
| 2010 | case 19674: finalSpelId = 19677; break; |
|---|
| 2011 | case 19687: finalSpelId = 19676; break; |
|---|
| 2012 | case 19688: finalSpelId = 19678; break; |
|---|
| 2013 | case 19689: finalSpelId = 19679; break; |
|---|
| 2014 | case 19692: finalSpelId = 19680; break; |
|---|
| 2015 | case 19693: finalSpelId = 19684; break; |
|---|
| 2016 | case 19694: finalSpelId = 19681; break; |
|---|
| 2017 | case 19696: finalSpelId = 19682; break; |
|---|
| 2018 | case 19697: finalSpelId = 19683; break; |
|---|
| 2019 | case 19699: finalSpelId = 19685; break; |
|---|
| 2020 | case 19700: finalSpelId = 19686; break; |
|---|
| 2021 | case 30646: finalSpelId = 30647; break; |
|---|
| 2022 | case 30653: finalSpelId = 30648; break; |
|---|
| 2023 | case 30654: finalSpelId = 30652; break; |
|---|
| 2024 | case 30099: finalSpelId = 30100; break; |
|---|
| 2025 | case 30102: finalSpelId = 30103; break; |
|---|
| 2026 | case 30105: finalSpelId = 30104; break; |
|---|
| 2027 | } |
|---|
| 2028 | |
|---|
| 2029 | if(finalSpelId) |
|---|
| 2030 | caster->CastSpell(m_target,finalSpelId,true,NULL,this); |
|---|
| 2031 | return; |
|---|
| 2032 | } |
|---|
| 2033 | // Dark Fiend |
|---|
| 2034 | if(GetId()==45934) |
|---|
| 2035 | { |
|---|
| 2036 | // Kill target if dispeled |
|---|
| 2037 | if (m_removeMode==AURA_REMOVE_BY_DISPEL) |
|---|
| 2038 | m_target->DealDamage(m_target, m_target->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); |
|---|
| 2039 | return; |
|---|
| 2040 | } |
|---|
| 2041 | |
|---|
| 2042 | // Burning Winds |
|---|
| 2043 | if(GetId()==46308) // casted only at creatures at spawn |
|---|
| 2044 | { |
|---|
| 2045 | m_target->CastSpell(m_target,47287,true,NULL,this); |
|---|
| 2046 | return; |
|---|
| 2047 | } |
|---|
| 2048 | } |
|---|
| 2049 | |
|---|
| 2050 | // AT APPLY & REMOVE |
|---|
| 2051 | |
|---|
| 2052 | switch(m_spellProto->SpellFamilyName) |
|---|
| 2053 | { |
|---|
| 2054 | case SPELLFAMILY_GENERIC: |
|---|
| 2055 | { |
|---|
| 2056 | // Unstable Power |
|---|
| 2057 | if( GetId()==24658 ) |
|---|
| 2058 | { |
|---|
| 2059 | uint32 spellId = 24659; |
|---|
| 2060 | if (apply) |
|---|
| 2061 | { |
|---|
| 2062 | const SpellEntry *spell = sSpellStore.LookupEntry(spellId); |
|---|
| 2063 | if (!spell) |
|---|
| 2064 | return; |
|---|
| 2065 | for (int i=0; i < spell->StackAmount; ++i) |
|---|
| 2066 | caster->CastSpell(m_target, spell->Id, true, NULL, NULL, GetCasterGUID()); |
|---|
| 2067 | return; |
|---|
| 2068 | } |
|---|
| 2069 | m_target->RemoveAurasDueToSpell(spellId); |
|---|
| 2070 | return; |
|---|
| 2071 | } |
|---|
| 2072 | // Restless Strength |
|---|
| 2073 | if( GetId()==24661 ) |
|---|
| 2074 | { |
|---|
| 2075 | uint32 spellId = 24662; |
|---|
| 2076 | if (apply) |
|---|
| 2077 | { |
|---|
| 2078 | const SpellEntry *spell = sSpellStore.LookupEntry(spellId); |
|---|
| 2079 | if (!spell) |
|---|
| 2080 | return; |
|---|
| 2081 | for (int i=0; i < spell->StackAmount; ++i) |
|---|
| 2082 | caster->CastSpell(m_target, spell->Id, true, NULL, NULL, GetCasterGUID()); |
|---|
| 2083 | return; |
|---|
| 2084 | } |
|---|
| 2085 | m_target->RemoveAurasDueToSpell(spellId); |
|---|
| 2086 | return; |
|---|
| 2087 | } |
|---|
| 2088 | // Victorious |
|---|
| 2089 | if(GetId()==32216 && m_target->getClass()==CLASS_WARRIOR) |
|---|
| 2090 | { |
|---|
| 2091 | m_target->ModifyAuraState(AURA_STATE_WARRIOR_VICTORY_RUSH, apply); |
|---|
| 2092 | return; |
|---|
| 2093 | } |
|---|
| 2094 | //Summon Fire Elemental |
|---|
| 2095 | if (GetId() == 40133 && caster) |
|---|
| 2096 | { |
|---|
| 2097 | Unit *owner = caster->GetOwner(); |
|---|
| 2098 | if (owner && owner->GetTypeId() == TYPEID_PLAYER) |
|---|
| 2099 | { |
|---|
| 2100 | if(apply) |
|---|
| 2101 | owner->CastSpell(owner,8985,true); |
|---|
| 2102 | else |
|---|
| 2103 | ((Player*)owner)->RemovePet(NULL, PET_SAVE_NOT_IN_SLOT, true); |
|---|
| 2104 | } |
|---|
| 2105 | return; |
|---|
| 2106 | } |
|---|
| 2107 | |
|---|
| 2108 | //Summon Earth Elemental |
|---|
| 2109 | if (GetId() == 40132 && caster) |
|---|
| 2110 | { |
|---|
| 2111 | Unit *owner = caster->GetOwner(); |
|---|
| 2112 | if (owner && owner->GetTypeId() == TYPEID_PLAYER) |
|---|
| 2113 | { |
|---|
| 2114 | if(apply) |
|---|
| 2115 | owner->CastSpell(owner,19704,true); |
|---|
| 2116 | else |
|---|
| 2117 | ((Player*)owner)->RemovePet(NULL, PET_SAVE_NOT_IN_SLOT, true); |
|---|
| 2118 | } |
|---|
| 2119 | return; |
|---|
| 2120 | } |
|---|
| 2121 | break; |
|---|
| 2122 | } |
|---|
| 2123 | case SPELLFAMILY_MAGE: |
|---|
| 2124 | { |
|---|
| 2125 | // Hypothermia |
|---|
| 2126 | if( GetId()==41425 ) |
|---|
| 2127 | { |
|---|
| 2128 | m_target->ModifyAuraState(AURA_STATE_HYPOTHERMIA,apply); |
|---|
| 2129 | return; |
|---|
| 2130 | } |
|---|
| 2131 | break; |
|---|
| 2132 | } |
|---|
| 2133 | case SPELLFAMILY_DRUID: |
|---|
| 2134 | { |
|---|
| 2135 | // Lifebloom |
|---|
| 2136 | if ( GetSpellProto()->SpellFamilyFlags & 0x1000000000LL ) |
|---|
| 2137 | { |
|---|
| 2138 | if ( apply ) |
|---|
| 2139 | { |
|---|
| 2140 | if ( caster ) |
|---|
| 2141 | // prevent double apply bonuses |
|---|
| 2142 | if(m_target->GetTypeId()!=TYPEID_PLAYER || !((Player*)m_target)->GetSession()->PlayerLoading()) |
|---|
| 2143 | m_modifier.m_amount = caster->SpellHealingBonus(GetSpellProto(), m_modifier.m_amount, SPELL_DIRECT_DAMAGE, m_target); |
|---|
| 2144 | } |
|---|
| 2145 | else |
|---|
| 2146 | { |
|---|
| 2147 | // Final heal only on dispelled or duration end |
|---|
| 2148 | if ( !(GetAuraDuration() <= 0 || m_removeMode==AURA_REMOVE_BY_DISPEL) ) |
|---|
| 2149 | return; |
|---|
| 2150 | |
|---|
| 2151 | // have a look if there is still some other Lifebloom dummy aura |
|---|
| 2152 | Unit::AuraList auras = m_target->GetAurasByType(SPELL_AURA_DUMMY); |
|---|
| 2153 | for(Unit::AuraList::iterator itr = auras.begin(); itr!=auras.end(); itr++) |
|---|
| 2154 | if((*itr)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_DRUID && |
|---|
| 2155 | (*itr)->GetSpellProto()->SpellFamilyFlags & 0x1000000000LL) |
|---|
| 2156 | return; |
|---|
| 2157 | |
|---|
| 2158 | // final heal |
|---|
| 2159 | m_target->CastCustomSpell(m_target,33778,&m_modifier.m_amount,NULL,NULL,true,NULL,this,GetCasterGUID()); |
|---|
| 2160 | } |
|---|
| 2161 | return; |
|---|
| 2162 | } |
|---|
| 2163 | |
|---|
| 2164 | // Predatory Strikes |
|---|
| 2165 | if(m_target->GetTypeId()==TYPEID_PLAYER && GetSpellProto()->SpellIconID == 1563) |
|---|
| 2166 | { |
|---|
| 2167 | ((Player*)m_target)->UpdateAttackPowerAndDamage(); |
|---|
| 2168 | return; |
|---|
| 2169 | } |
|---|
| 2170 | // Idol of the Emerald Queen |
|---|
| 2171 | if ( GetId() == 34246 && m_target->GetTypeId()==TYPEID_PLAYER ) |
|---|
| 2172 | { |
|---|
| 2173 | if(apply) |
|---|
| 2174 | { |
|---|
| 2175 | SpellModifier *mod = new SpellModifier; |
|---|
| 2176 | mod->op = SPELLMOD_DOT; |
|---|
| 2177 | mod->value = m_modifier.m_amount/7; |
|---|
| 2178 | mod->type = SPELLMOD_FLAT; |
|---|
| 2179 | mod->spellId = GetId(); |
|---|
| 2180 | mod->effectId = m_effIndex; |
|---|
| 2181 | mod->lastAffected = NULL; |
|---|
| 2182 | mod->mask = 0x001000000000LL; |
|---|
| 2183 | mod->charges = 0; |
|---|
| 2184 | |
|---|
| 2185 | m_spellmod = mod; |
|---|
| 2186 | } |
|---|
| 2187 | |
|---|
| 2188 | ((Player*)m_target)->AddSpellMod(m_spellmod, apply); |
|---|
| 2189 | return; |
|---|
| 2190 | } |
|---|
| 2191 | break; |
|---|
| 2192 | } |
|---|
| 2193 | case SPELLFAMILY_HUNTER: |
|---|
| 2194 | { |
|---|
| 2195 | // Improved Aspect of the Viper |
|---|
| 2196 | if( GetId()==38390 && m_target->GetTypeId()==TYPEID_PLAYER ) |
|---|
| 2197 | { |
|---|
| 2198 | if(apply) |
|---|
| 2199 | { |
|---|
| 2200 | // + effect value for Aspect of the Viper |
|---|
| 2201 | SpellModifier *mod = new SpellModifier; |
|---|
| 2202 | mod->op = SPELLMOD_EFFECT1; |
|---|
| 2203 | mod->value = m_modifier.m_amount; |
|---|
| 2204 | mod->type = SPELLMOD_FLAT; |
|---|
| 2205 | mod->spellId = GetId(); |
|---|
| 2206 | mod->effectId = m_effIndex; |
|---|
| 2207 | mod->lastAffected = NULL; |
|---|
| 2208 | mod->mask = 0x4000000000000LL; |
|---|
| 2209 | mod->charges = 0; |
|---|
| 2210 | |
|---|
| 2211 | m_spellmod = mod; |
|---|
| 2212 | } |
|---|
| 2213 | |
|---|
| 2214 | ((Player*)m_target)->AddSpellMod(m_spellmod, apply); |
|---|
| 2215 | return; |
|---|
| 2216 | } |
|---|
| 2217 | break; |
|---|
| 2218 | } |
|---|
| 2219 | case SPELLFAMILY_SHAMAN: |
|---|
| 2220 | { |
|---|
| 2221 | // Improved Weapon Totems |
|---|
| 2222 | if( GetSpellProto()->SpellIconID == 57 && m_target->GetTypeId()==TYPEID_PLAYER ) |
|---|
| 2223 | { |
|---|
| 2224 | if(apply) |
|---|
| 2225 | { |
|---|
| 2226 | SpellModifier *mod = new SpellModifier; |
|---|
| 2227 | mod->op = SPELLMOD_EFFECT1; |
|---|
| 2228 | mod->value = m_modifier.m_amount; |
|---|
| 2229 | mod->type = SPELLMOD_PCT; |
|---|
| 2230 | mod->spellId = GetId(); |
|---|
| 2231 | mod->effectId = m_effIndex; |
|---|
| 2232 | mod->lastAffected = NULL; |
|---|
| 2233 | switch (m_effIndex) |
|---|
| 2234 | { |
|---|
| 2235 | case 0: |
|---|
| 2236 | mod->mask = 0x00200000000LL; // Windfury Totem |
|---|
| 2237 | break; |
|---|
| 2238 | case 1: |
|---|
| 2239 | mod->mask = 0x00400000000LL; // Flametongue Totem |
|---|
| 2240 | break; |
|---|
| 2241 | } |
|---|
| 2242 | mod->charges = 0; |
|---|
| 2243 | |
|---|
| 2244 | m_spellmod = mod; |
|---|
| 2245 | } |
|---|
| 2246 | |
|---|
| 2247 | ((Player*)m_target)->AddSpellMod(m_spellmod, apply); |
|---|
| 2248 | return; |
|---|
| 2249 | } |
|---|
| 2250 | break; |
|---|
| 2251 | } |
|---|
| 2252 | } |
|---|
| 2253 | |
|---|
| 2254 | // pet auras |
|---|
| 2255 | if(PetAura const* petSpell = spellmgr.GetPetAura(GetId())) |
|---|
| 2256 | { |
|---|
| 2257 | if(apply) |
|---|
| 2258 | m_target->AddPetAura(petSpell); |
|---|
| 2259 | else |
|---|
| 2260 | m_target->RemovePetAura(petSpell); |
|---|
| 2261 | return; |
|---|
| 2262 | } |
|---|
| 2263 | } |
|---|
| 2264 | |
|---|
| 2265 | void Aura::HandleAuraPeriodicDummy(bool apply, bool Real) |
|---|
| 2266 | { |
|---|
| 2267 | // spells required only Real aura add/remove |
|---|
| 2268 | if(!Real) |
|---|
| 2269 | return; |
|---|
| 2270 | |
|---|
| 2271 | SpellEntry const*spell = GetSpellProto(); |
|---|
| 2272 | switch( spell->SpellFamilyName) |
|---|
| 2273 | { |
|---|
| 2274 | case SPELLFAMILY_ROGUE: |
|---|
| 2275 | { |
|---|
| 2276 | // Master of Subtlety |
|---|
| 2277 | if (spell->Id==31666 && !apply && Real) |
|---|
| 2278 | { |
|---|
| 2279 | m_target->RemoveAurasDueToSpell(31665); |
|---|
| 2280 | break; |
|---|
| 2281 | } |
|---|
| 2282 | break; |
|---|
| 2283 | } |
|---|
| 2284 | case SPELLFAMILY_HUNTER: |
|---|
| 2285 | { |
|---|
| 2286 | // Aspect of the Viper |
|---|
| 2287 | if (spell->SpellFamilyFlags&0x0004000000000000LL) |
|---|
| 2288 | { |
|---|
| 2289 | // Update regen on remove |
|---|
| 2290 | if (!apply && m_target->GetTypeId() == TYPEID_PLAYER) |
|---|
| 2291 | ((Player*)m_target)->UpdateManaRegen(); |
|---|
| 2292 | break; |
|---|
| 2293 | } |
|---|
| 2294 | break; |
|---|
| 2295 | } |
|---|
| 2296 | } |
|---|
| 2297 | |
|---|
| 2298 | m_isPeriodic = apply; |
|---|
| 2299 | } |
|---|
| 2300 | |
|---|
| 2301 | void Aura::HandleAuraMounted(bool apply, bool Real) |
|---|
| 2302 | { |
|---|
| 2303 | if(apply) |
|---|
| 2304 | { |
|---|
| 2305 | CreatureInfo const* ci = objmgr.GetCreatureTemplate(m_modifier.m_miscvalue); |
|---|
| 2306 | if(!ci) |
|---|
| 2307 | { |
|---|
| 2308 | sLog.outErrorDb("AuraMounted: `creature_template`='%u' not found in database (only need it modelid)", m_modifier.m_miscvalue); |
|---|
| 2309 | return; |
|---|
| 2310 | } |
|---|
| 2311 | |
|---|
| 2312 | uint32 team = 0; |
|---|
| 2313 | if (m_target->GetTypeId()==TYPEID_PLAYER) |
|---|
| 2314 | team = ((Player*)m_target)->GetTeam(); |
|---|
| 2315 | |
|---|
| 2316 | uint32 display_id = objmgr.ChooseDisplayId(team,ci); |
|---|
| 2317 | CreatureModelInfo const *minfo = objmgr.GetCreatureModelRandomGender(display_id); |
|---|
| 2318 | if (minfo) |
|---|
| 2319 | display_id = minfo->modelid; |
|---|
| 2320 | |
|---|
| 2321 | m_target->Mount(display_id); |
|---|
| 2322 | } |
|---|
| 2323 | else |
|---|
| 2324 | { |
|---|
| 2325 | m_target->Unmount(); |
|---|
| 2326 | } |
|---|
| 2327 | } |
|---|
| 2328 | |
|---|
| 2329 | void Aura::HandleAuraWaterWalk(bool apply, bool Real) |
|---|
| 2330 | { |
|---|
| 2331 | // only at real add/remove aura |
|---|
| 2332 | if(!Real) |
|---|
| 2333 | return; |
|---|
| 2334 | |
|---|
| 2335 | WorldPacket data; |
|---|
| 2336 | if(apply) |
|---|
| 2337 | data.Initialize(SMSG_MOVE_WATER_WALK, 8+4); |
|---|
| 2338 | else |
|---|
| 2339 | data.Initialize(SMSG_MOVE_LAND_WALK, 8+4); |
|---|
| 2340 | data.append(m_target->GetPackGUID()); |
|---|
| 2341 | data << uint32(0); |
|---|
| 2342 | m_target->SendMessageToSet(&data,true); |
|---|
| 2343 | } |
|---|
| 2344 | |
|---|
| 2345 | void Aura::HandleAuraFeatherFall(bool apply, bool Real) |
|---|
| 2346 | { |
|---|
| 2347 | // only at real add/remove aura |
|---|
| 2348 | if(!Real) |
|---|
| 2349 | return; |
|---|
| 2350 | |
|---|
| 2351 | WorldPacket data; |
|---|
| 2352 | if(apply) |
|---|
| 2353 | data.Initialize(SMSG_MOVE_FEATHER_FALL, 8+4); |
|---|
| 2354 | else |
|---|
| 2355 | data.Initialize(SMSG_MOVE_NORMAL_FALL, 8+4); |
|---|
| 2356 | data.append(m_target->GetPackGUID()); |
|---|
| 2357 | data << (uint32)0; |
|---|
| 2358 | m_target->SendMessageToSet(&data,true); |
|---|
| 2359 | } |
|---|
| 2360 | |
|---|
| 2361 | void Aura::HandleAuraHover(bool apply, bool Real) |
|---|
| 2362 | { |
|---|
| 2363 | // only at real add/remove aura |
|---|
| 2364 | if(!Real) |
|---|
| 2365 | return; |
|---|
| 2366 | |
|---|
| 2367 | WorldPacket data; |
|---|
| 2368 | if(apply) |
|---|
| 2369 | data.Initialize(SMSG_MOVE_SET_HOVER, 8+4); |
|---|
| 2370 | else |
|---|
| 2371 | data.Initialize(SMSG_MOVE_UNSET_HOVER, 8+4); |
|---|
| 2372 | data.append(m_target->GetPackGUID()); |
|---|
| 2373 | data << uint32(0); |
|---|
| 2374 | m_target->SendMessageToSet(&data,true); |
|---|
| 2375 | } |
|---|
| 2376 | |
|---|
| 2377 | void Aura::HandleWaterBreathing(bool apply, bool Real) |
|---|
| 2378 | { |
|---|
| 2379 | if(apply) |
|---|
| 2380 | m_target->waterbreath = true; |
|---|
| 2381 | else if(m_target->GetAurasByType(SPELL_AURA_WATER_BREATHING).empty()) |
|---|
| 2382 | { |
|---|
| 2383 | m_target->waterbreath = false; |
|---|
| 2384 | |
|---|
| 2385 | // update for enable timer in case not moving target |
|---|
| 2386 | if(m_target->GetTypeId()==TYPEID_PLAYER && m_target->IsInWorld()) |
|---|
| 2387 | { |
|---|
| 2388 | ((Player*)m_target)->UpdateUnderwaterState(m_target->GetMap(),m_target->GetPositionX(),m_target->GetPositionY(),m_target->GetPositionZ()); |
|---|
| 2389 | ((Player*)m_target)->HandleDrowning(); |
|---|
| 2390 | } |
|---|
| 2391 | } |
|---|
| 2392 | } |
|---|
| 2393 | |
|---|
| 2394 | void Aura::HandleAuraModShapeshift(bool apply, bool Real) |
|---|
| 2395 | { |
|---|
| 2396 | if(!Real) |
|---|
| 2397 | return; |
|---|
| 2398 | |
|---|
| 2399 | uint32 modelid = 0; |
|---|
| 2400 | Powers PowerType = POWER_MANA; |
|---|
| 2401 | ShapeshiftForm form = ShapeshiftForm(m_modifier.m_miscvalue); |
|---|
| 2402 | switch(form) |
|---|
| 2403 | { |
|---|
| 2404 | case FORM_CAT: |
|---|
| 2405 | if(Player::TeamForRace(m_target->getRace())==ALLIANCE) |
|---|
| 2406 | modelid = 892; |
|---|
| 2407 | else |
|---|
| 2408 | modelid = 8571; |
|---|
| 2409 | PowerType = POWER_ENERGY; |
|---|
| 2410 | break; |
|---|
| 2411 | case FORM_TRAVEL: |
|---|
| 2412 | modelid = 632; |
|---|
| 2413 | break; |
|---|
| 2414 | case FORM_AQUA: |
|---|
| 2415 | if(Player::TeamForRace(m_target->getRace())==ALLIANCE) |
|---|
| 2416 | modelid = 2428; |
|---|
| 2417 | else |
|---|
| 2418 | modelid = 2428; |
|---|
| 2419 | break; |
|---|
| 2420 | case FORM_BEAR: |
|---|
| 2421 | if(Player::TeamForRace(m_target->getRace())==ALLIANCE) |
|---|
| 2422 | modelid = 2281; |
|---|
| 2423 | else |
|---|
| 2424 | modelid = 2289; |
|---|
| 2425 | PowerType = POWER_RAGE; |
|---|
| 2426 | break; |
|---|
| 2427 | case FORM_GHOUL: |
|---|
| 2428 | if(Player::TeamForRace(m_target->getRace())==ALLIANCE) |
|---|
| 2429 | modelid = 10045; |
|---|
| 2430 | break; |
|---|
| 2431 | case FORM_DIREBEAR: |
|---|
| 2432 | if(Player::TeamForRace(m_target->getRace())==ALLIANCE) |
|---|
| 2433 | modelid = 2281; |
|---|
| 2434 | else |
|---|
| 2435 | modelid = 2289; |
|---|
| 2436 | PowerType = POWER_RAGE; |
|---|
| 2437 | break; |
|---|
| 2438 | case FORM_CREATUREBEAR: |
|---|
| 2439 | modelid = 902; |
|---|
| 2440 | break; |
|---|
| 2441 | case FORM_GHOSTWOLF: |
|---|
| 2442 | modelid = 4613; |
|---|
| 2443 | break; |
|---|
| 2444 | case FORM_FLIGHT: |
|---|
| 2445 | if(Player::TeamForRace(m_target->getRace())==ALLIANCE) |
|---|
| 2446 | modelid = 20857; |
|---|
| 2447 | else |
|---|
| 2448 | modelid = 20872; |
|---|
| 2449 | break; |
|---|
| 2450 | case FORM_MOONKIN: |
|---|
| 2451 | if(Player::TeamForRace(m_target->getRace())==ALLIANCE) |
|---|
| 2452 | modelid = 15374; |
|---|
| 2453 | else |
|---|
| 2454 | modelid = 15375; |
|---|
| 2455 | break; |
|---|
| 2456 | case FORM_FLIGHT_EPIC: |
|---|
| 2457 | if(Player::TeamForRace(m_target->getRace())==ALLIANCE) |
|---|
| 2458 | modelid = 21243; |
|---|
| 2459 | else |
|---|
| 2460 | modelid = 21244; |
|---|
| 2461 | break; |
|---|
| 2462 | case FORM_AMBIENT: |
|---|
| 2463 | case FORM_SHADOW: |
|---|
| 2464 | case FORM_STEALTH: |
|---|
| 2465 | break; |
|---|
| 2466 | case FORM_TREE: |
|---|
| 2467 | modelid = 864; |
|---|
| 2468 | break; |
|---|
| 2469 | case FORM_BATTLESTANCE: |
|---|
| 2470 | case FORM_BERSERKERSTANCE: |
|---|
| 2471 | case FORM_DEFENSIVESTANCE: |
|---|
| 2472 | PowerType = POWER_RAGE; |
|---|
| 2473 | break; |
|---|
| 2474 | case FORM_SPIRITOFREDEMPTION: |
|---|
| 2475 | modelid = 16031; |
|---|
| 2476 | break; |
|---|
| 2477 | default: |
|---|
| 2478 | sLog.outError("Auras: Unknown Shapeshift Type: %u", m_modifier.m_miscvalue); |
|---|
| 2479 | } |
|---|
| 2480 | |
|---|
| 2481 | // remove polymorph before changing display id to keep new display id |
|---|
| 2482 | switch ( form ) |
|---|
| 2483 | { |
|---|
| 2484 | case FORM_CAT: |
|---|
| 2485 | case FORM_TREE: |
|---|
| 2486 | case FORM_TRAVEL: |
|---|
| 2487 | case FORM_AQUA: |
|---|
| 2488 | case FORM_BEAR: |
|---|
| 2489 | case FORM_DIREBEAR: |
|---|
| 2490 | case FORM_FLIGHT_EPIC: |
|---|
| 2491 | case FORM_FLIGHT: |
|---|
| 2492 | case FORM_MOONKIN: |
|---|
| 2493 | // remove movement affects |
|---|
| 2494 | m_target->RemoveSpellsCausingAura(SPELL_AURA_MOD_ROOT); |
|---|
| 2495 | m_target->RemoveSpellsCausingAura(SPELL_AURA_MOD_DECREASE_SPEED); |
|---|
| 2496 | |
|---|
| 2497 | // and polymorphic affects |
|---|
| 2498 | if(m_target->IsPolymorphed()) |
|---|
| 2499 | m_target->RemoveAurasDueToSpell(m_target->getTransForm()); |
|---|
| 2500 | break; |
|---|
| 2501 | default: |
|---|
| 2502 | break; |
|---|
| 2503 | } |
|---|
| 2504 | |
|---|
| 2505 | if(apply) |
|---|
| 2506 | { |
|---|
| 2507 | // remove other shapeshift before applying a new one |
|---|
| 2508 | if(m_target->m_ShapeShiftFormSpellId) |
|---|
| 2509 | { |
|---|
| 2510 | m_target->RemoveAurasDueToSpell(m_target->m_ShapeShiftFormSpellId,this); |
|---|
| 2511 | } |
|---|
| 2512 | |
|---|
| 2513 | m_target->SetByteValue(UNIT_FIELD_BYTES_2, 3, form); |
|---|
| 2514 | |
|---|
| 2515 | if(modelid > 0) |
|---|
| 2516 | { |
|---|
| 2517 | m_target->SetDisplayId(modelid); |
|---|
| 2518 | } |
|---|
| 2519 | |
|---|
| 2520 | if(PowerType != POWER_MANA) |
|---|
| 2521 | { |
|---|
| 2522 | // reset power to default values only at power change |
|---|
| 2523 | if(m_target->getPowerType()!=PowerType) |
|---|
| 2524 | m_target->setPowerType(PowerType); |
|---|
| 2525 | |
|---|
| 2526 | switch(form) |
|---|
| 2527 | { |
|---|
| 2528 | case FORM_CAT: |
|---|
| 2529 | case FORM_BEAR: |
|---|
| 2530 | case FORM_DIREBEAR: |
|---|
| 2531 | { |
|---|
| 2532 | // get furor proc chance |
|---|
| 2533 | uint32 FurorChance = 0; |
|---|
| 2534 | Unit::AuraList const& mDummy = m_target->GetAurasByType(SPELL_AURA_DUMMY); |
|---|
| 2535 | for(Unit::AuraList::const_iterator i = mDummy.begin(); i != mDummy.end(); ++i) |
|---|
| 2536 | { |
|---|
| 2537 | if ((*i)->GetSpellProto()->SpellIconID == 238) |
|---|
| 2538 | { |
|---|
| 2539 | FurorChance = (*i)->GetModifier()->m_amount; |
|---|
| 2540 | break; |
|---|
| 2541 | } |
|---|
| 2542 | } |
|---|
| 2543 | |
|---|
| 2544 | if (m_modifier.m_miscvalue == FORM_CAT) |
|---|
| 2545 | { |
|---|
| 2546 | m_target->SetPower(POWER_ENERGY,0); |
|---|
| 2547 | if(urand(1,100) <= FurorChance) |
|---|
| 2548 | { |
|---|
| 2549 | m_target->CastSpell(m_target,17099,true,NULL,this); |
|---|
| 2550 | } |
|---|
| 2551 | } |
|---|
| 2552 | else |
|---|
| 2553 | { |
|---|
| 2554 | m_target->SetPower(POWER_RAGE,0); |
|---|
| 2555 | if(urand(1,100) <= FurorChance) |
|---|
| 2556 | { |
|---|
| 2557 | m_target->CastSpell(m_target,17057,true,NULL,this); |
|---|
| 2558 | } |
|---|
| 2559 | } |
|---|
| 2560 | break; |
|---|
| 2561 | } |
|---|
| 2562 | case FORM_BATTLESTANCE: |
|---|
| 2563 | case FORM_DEFENSIVESTANCE: |
|---|
| 2564 | case FORM_BERSERKERSTANCE: |
|---|
| 2565 | { |
|---|
| 2566 | uint32 Rage_val = 0; |
|---|
| 2567 | // Stance mastery + Tactical mastery (both passive, and last have aura only in defense stance, but need apply at any stance switch) |
|---|
| 2568 | if(m_target->GetTypeId() == TYPEID_PLAYER) |
|---|
| 2569 | { |
|---|
| 2570 | PlayerSpellMap const& sp_list = ((Player *)m_target)->GetSpellMap(); |
|---|
| 2571 | for (PlayerSpellMap::const_iterator itr = sp_list.begin(); itr != sp_list.end(); ++itr) |
|---|
| 2572 | { |
|---|
| 2573 | if(itr->second->state == PLAYERSPELL_REMOVED) continue; |
|---|
| 2574 | SpellEntry const *spellInfo = sSpellStore.LookupEntry(itr->first); |
|---|
| 2575 | if (spellInfo && spellInfo->SpellFamilyName == SPELLFAMILY_WARRIOR && spellInfo->SpellIconID == 139) |
|---|
| 2576 | Rage_val += m_target->CalculateSpellDamage(spellInfo,0,spellInfo->EffectBasePoints[0],m_target) * 10; |
|---|
| 2577 | } |
|---|
| 2578 | } |
|---|
| 2579 | |
|---|
| 2580 | if (m_target->GetPower(POWER_RAGE) > Rage_val) |
|---|
| 2581 | m_target->SetPower(POWER_RAGE,Rage_val); |
|---|
| 2582 | break; |
|---|
| 2583 | } |
|---|
| 2584 | default: |
|---|
| 2585 | break; |
|---|
| 2586 | } |
|---|
| 2587 | } |
|---|
| 2588 | |
|---|
| 2589 | m_target->m_ShapeShiftFormSpellId = GetId(); |
|---|
| 2590 | m_target->m_form = form; |
|---|
| 2591 | } |
|---|
| 2592 | else |
|---|
| 2593 | { |
|---|
| 2594 | m_target->SetDisplayId(m_target->GetNativeDisplayId()); |
|---|
| 2595 | m_target->SetByteValue(UNIT_FIELD_BYTES_2, 3, FORM_NONE); |
|---|
| 2596 | if(m_target->getClass() == CLASS_DRUID) |
|---|
| 2597 | m_target->setPowerType(POWER_MANA); |
|---|
| 2598 | m_target->m_ShapeShiftFormSpellId = 0; |
|---|
| 2599 | m_target->m_form = FORM_NONE; |
|---|
| 2600 | |
|---|
| 2601 | switch(form) |
|---|
| 2602 | { |
|---|
| 2603 | // Nordrassil Harness - bonus |
|---|
| 2604 | case FORM_BEAR: |
|---|
| 2605 | case FORM_DIREBEAR: |
|---|
| 2606 | case FORM_CAT: |
|---|
| 2607 | { |
|---|
| 2608 | if(Aura* dummy = m_target->GetDummyAura(37315) ) |
|---|
| 2609 | m_target->CastSpell(m_target,37316,true,NULL,dummy); |
|---|
| 2610 | break; |
|---|
| 2611 | } |
|---|
| 2612 | // Nordrassil Regalia - bonus |
|---|
| 2613 | case FORM_MOONKIN: |
|---|
| 2614 | { |
|---|
| 2615 | if(Aura* dummy = m_target->GetDummyAura(37324) ) |
|---|
| 2616 | m_target->CastSpell(m_target,37325,true,NULL,dummy); |
|---|
| 2617 | break; |
|---|
| 2618 | } |
|---|
| 2619 | } |
|---|
| 2620 | } |
|---|
| 2621 | |
|---|
| 2622 | // adding/removing linked auras |
|---|
| 2623 | // add/remove the shapeshift aura's boosts |
|---|
| 2624 | HandleShapeshiftBoosts(apply); |
|---|
| 2625 | |
|---|
| 2626 | if(m_target->GetTypeId()==TYPEID_PLAYER) |
|---|
| 2627 | ((Player*)m_target)->InitDataForForm(); |
|---|
| 2628 | } |
|---|
| 2629 | |
|---|
| 2630 | void Aura::HandleAuraTransform(bool apply, bool Real) |
|---|
| 2631 | { |
|---|
| 2632 | if (apply) |
|---|
| 2633 | { |
|---|
| 2634 | // special case (spell specific functionality) |
|---|
| 2635 | if(m_modifier.m_miscvalue==0) |
|---|
| 2636 | { |
|---|
| 2637 | // player applied only |
|---|
| 2638 | if(m_target->GetTypeId()!=TYPEID_PLAYER) |
|---|
| 2639 | return; |
|---|
| 2640 | |
|---|
| 2641 | switch(GetId()) |
|---|
| 2642 | { |
|---|
| 2643 | // Orb of Deception |
|---|
| 2644 | case 16739: |
|---|
| 2645 | { |
|---|
| 2646 | uint32 orb_model = m_target->GetNativeDisplayId(); |
|---|
| 2647 | switch(orb_model) |
|---|
| 2648 | { |
|---|
| 2649 | // Troll Female |
|---|
| 2650 | case 1479: m_target->SetDisplayId(10134); break; |
|---|
| 2651 | // Troll Male |
|---|
| 2652 | case 1478: m_target->SetDisplayId(10135); break; |
|---|
| 2653 | // Tauren Male |
|---|
| 2654 | case 59: m_target->SetDisplayId(10136); break; |
|---|
| 2655 | // Human Male |
|---|
| 2656 | case 49: m_target->SetDisplayId(10137); break; |
|---|
| 2657 | // Human Female |
|---|
| 2658 | case 50: m_target->SetDisplayId(10138); break; |
|---|
| 2659 | // Orc Male |
|---|
| 2660 | case 51: m_target->SetDisplayId(10139); break; |
|---|
| 2661 | // Orc Female |
|---|
| 2662 | case 52: m_target->SetDisplayId(10140); break; |
|---|
| 2663 | // Dwarf Male |
|---|
| 2664 | case 53: m_target->SetDisplayId(10141); break; |
|---|
| 2665 | // Dwarf Female |
|---|
| 2666 | case 54: m_target->SetDisplayId(10142); break; |
|---|
| 2667 | // NightElf Male |
|---|
| 2668 | case 55: m_target->SetDisplayId(10143); break; |
|---|
| 2669 | // NightElf Female |
|---|
| 2670 | case 56: m_target->SetDisplayId(10144); break; |
|---|
| 2671 | // Undead Female |
|---|
| 2672 | case 58: m_target->SetDisplayId(10145); break; |
|---|
| 2673 | // Undead Male |
|---|
| 2674 | case 57: m_target->SetDisplayId(10146); break; |
|---|
| 2675 | // Tauren Female |
|---|
| 2676 | case 60: m_target->SetDisplayId(10147); break; |
|---|
| 2677 | // Gnome Male |
|---|
| 2678 | case 1563: m_target->SetDisplayId(10148); break; |
|---|
| 2679 | // Gnome Female |
|---|
| 2680 | case 1564: m_target->SetDisplayId(10149); break; |
|---|
| 2681 | // BloodElf Female |
|---|
| 2682 | case 15475: m_target->SetDisplayId(17830); break; |
|---|
| 2683 | // BloodElf Male |
|---|
| 2684 | case 15476: m_target->SetDisplayId(17829); break; |
|---|
| 2685 | // Dranei Female |
|---|
| 2686 | case 16126: m_target->SetDisplayId(17828); break; |
|---|
| 2687 | // Dranei Male |
|---|
| 2688 | case 16125: m_target->SetDisplayId(17827); break; |
|---|
| 2689 | default: break; |
|---|
| 2690 | } |
|---|
| 2691 | break; |
|---|
| 2692 | } |
|---|
| 2693 | // Murloc costume |
|---|
| 2694 | case 42365: m_target->SetDisplayId(21723); break; |
|---|
| 2695 | default: break; |
|---|
| 2696 | } |
|---|
| 2697 | } |
|---|
| 2698 | else |
|---|
| 2699 | { |
|---|
| 2700 | CreatureInfo const * ci = objmgr.GetCreatureTemplate(m_modifier.m_miscvalue); |
|---|
| 2701 | if(!ci) |
|---|
| 2702 | { |
|---|
| 2703 | //pig pink ^_^ |
|---|
| 2704 | m_target->SetDisplayId(16358); |
|---|
| 2705 | sLog.outError("Auras: unknown creature id = %d (only need its modelid) Form Spell Aura Transform in Spell ID = %d", m_modifier.m_miscvalue, GetId()); |
|---|
| 2706 | } |
|---|
| 2707 | else |
|---|
| 2708 | { |
|---|
| 2709 | // Will use the default model here |
|---|
| 2710 | m_target->SetDisplayId(ci->DisplayID_A); |
|---|
| 2711 | |
|---|
| 2712 | // Dragonmaw Illusion (set mount model also) |
|---|
| 2713 | if(GetId()==42016 && m_target->GetMountID() && !m_target->GetAurasByType(SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED).empty()) |
|---|
| 2714 | m_target->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID,16314); |
|---|
| 2715 | } |
|---|
| 2716 | m_target->setTransForm(GetId()); |
|---|
| 2717 | } |
|---|
| 2718 | |
|---|
| 2719 | // polymorph case |
|---|
| 2720 | if( Real && m_target->GetTypeId() == TYPEID_PLAYER && m_target->IsPolymorphed()) |
|---|
| 2721 | { |
|---|
| 2722 | // for players, start regeneration after 1s (in polymorph fast regeneration case) |
|---|
| 2723 | // only if caster is Player (after patch 2.4.2) |
|---|
| 2724 | if(IS_PLAYER_GUID(GetCasterGUID()) ) |
|---|
| 2725 | ((Player*)m_target)->setRegenTimer(1000); |
|---|
| 2726 | |
|---|
| 2727 | //dismount polymorphed target (after patch 2.4.2) |
|---|
| 2728 | if (m_target->IsMounted()) |
|---|
| 2729 | m_target->RemoveSpellsCausingAura(SPELL_AURA_MOUNTED); |
|---|
| 2730 | } |
|---|
| 2731 | } |
|---|
| 2732 | else |
|---|
| 2733 | { |
|---|
| 2734 | Unit::AuraList const& otherTransforms = m_target->GetAurasByType(SPELL_AURA_TRANSFORM); |
|---|
| 2735 | if(otherTransforms.empty()) |
|---|
| 2736 | { |
|---|
| 2737 | m_target->SetDisplayId(m_target->GetNativeDisplayId()); |
|---|
| 2738 | m_target->setTransForm(0); |
|---|
| 2739 | } |
|---|
| 2740 | else |
|---|
| 2741 | { |
|---|
| 2742 | // look for other transform auras |
|---|
| 2743 | Aura* handledAura = *otherTransforms.begin(); |
|---|
| 2744 | for(Unit::AuraList::const_iterator i = otherTransforms.begin();i != otherTransforms.end(); ++i) |
|---|
| 2745 | { |
|---|
| 2746 | // negative auras are prefered |
|---|
| 2747 | if(!IsPositiveSpell((*i)->GetSpellProto()->Id)) |
|---|
| 2748 | { |
|---|
| 2749 | handledAura = *i; |
|---|
| 2750 | break; |
|---|
| 2751 | } |
|---|
| 2752 | } |
|---|
| 2753 | handledAura->ApplyModifier(true); |
|---|
| 2754 | } |
|---|
| 2755 | |
|---|
| 2756 | // Dragonmaw Illusion (restore mount model) |
|---|
| 2757 | if(GetId()==42016 && m_target->GetMountID()==16314) |
|---|
| 2758 | { |
|---|
| 2759 | if(!m_target->GetAurasByType(SPELL_AURA_MOUNTED).empty()) |
|---|
| 2760 | { |
|---|
| 2761 | uint32 cr_id = m_target->GetAurasByType(SPELL_AURA_MOUNTED).front()->GetModifier()->m_miscvalue; |
|---|
| 2762 | if(CreatureInfo const* ci = objmgr.GetCreatureTemplate(cr_id)) |
|---|
| 2763 | { |
|---|
| 2764 | uint32 team = 0; |
|---|
| 2765 | if (m_target->GetTypeId()==TYPEID_PLAYER) |
|---|
| 2766 | team = ((Player*)m_target)->GetTeam(); |
|---|
| 2767 | |
|---|
| 2768 | uint32 display_id = objmgr.ChooseDisplayId(team,ci); |
|---|
| 2769 | CreatureModelInfo const *minfo = objmgr.GetCreatureModelRandomGender(display_id); |
|---|
| 2770 | if (minfo) |
|---|
| 2771 | display_id = minfo->modelid; |
|---|
| 2772 | |
|---|
| 2773 | m_target->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID,display_id); |
|---|
| 2774 | } |
|---|
| 2775 | } |
|---|
| 2776 | } |
|---|
| 2777 | } |
|---|
| 2778 | } |
|---|
| 2779 | |
|---|
| 2780 | void Aura::HandleForceReaction(bool apply, bool Real) |
|---|
| 2781 | { |
|---|
| 2782 | if(m_target->GetTypeId() != TYPEID_PLAYER) |
|---|
| 2783 | return; |
|---|
| 2784 | |
|---|
| 2785 | if(!Real) |
|---|
| 2786 | return; |
|---|
| 2787 | |
|---|
| 2788 | Player* player = (Player*)m_target; |
|---|
| 2789 | |
|---|
| 2790 | uint32 faction_id = m_modifier.m_miscvalue; |
|---|
| 2791 | uint32 faction_rank = m_modifier.m_amount; |
|---|
| 2792 | |
|---|
| 2793 | if(apply) |
|---|
| 2794 | player->m_forcedReactions[faction_id] = ReputationRank(faction_rank); |
|---|
| 2795 | else |
|---|
| 2796 | player->m_forcedReactions.erase(faction_id); |
|---|
| 2797 | |
|---|
| 2798 | WorldPacket data; |
|---|
| 2799 | data.Initialize(SMSG_SET_FORCED_REACTIONS, 4+player->m_forcedReactions.size()*(4+4)); |
|---|
| 2800 | data << uint32(player->m_forcedReactions.size()); |
|---|
| 2801 | for(ForcedReactions::const_iterator itr = player->m_forcedReactions.begin(); itr != player->m_forcedReactions.end(); ++itr) |
|---|
| 2802 | { |
|---|
| 2803 | data << uint32(itr->first); // faction_id (Faction.dbc) |
|---|
| 2804 | data << uint32(itr->second); // reputation rank |
|---|
| 2805 | } |
|---|
| 2806 | player->SendDirectMessage(&data); |
|---|
| 2807 | } |
|---|
| 2808 | |
|---|
| 2809 | void Aura::HandleAuraModSkill(bool apply, bool Real) |
|---|
| 2810 | { |
|---|
| 2811 | if(m_target->GetTypeId() != TYPEID_PLAYER) |
|---|
| 2812 | return; |
|---|
| 2813 | |
|---|
| 2814 | uint32 prot=GetSpellProto()->EffectMiscValue[m_effIndex]; |
|---|
| 2815 | int32 points = GetModifier()->m_amount; |
|---|
| 2816 | |
|---|
| 2817 | ((Player*)m_target)->ModifySkillBonus(prot,(apply ? points: -points),m_modifier.m_auraname==SPELL_AURA_MOD_SKILL_TALENT); |
|---|
| 2818 | if(prot == SKILL_DEFENSE) |
|---|
| 2819 | ((Player*)m_target)->UpdateDefenseBonusesMod(); |
|---|
| 2820 | } |
|---|
| 2821 | |
|---|
| 2822 | void Aura::HandleChannelDeathItem(bool apply, bool Real) |
|---|
| 2823 | { |
|---|
| 2824 | if(Real && !apply) |
|---|
| 2825 | { |
|---|
| 2826 | Unit* caster = GetCaster(); |
|---|
| 2827 | Unit* victim = GetTarget(); |
|---|
| 2828 | if(!caster || caster->GetTypeId() != TYPEID_PLAYER || !victim || m_removeMode!=AURA_REMOVE_BY_DEATH) |
|---|
| 2829 | return; |
|---|
| 2830 | |
|---|
| 2831 | SpellEntry const *spellInfo = GetSpellProto(); |
|---|
| 2832 | if(spellInfo->EffectItemType[m_effIndex] == 0) |
|---|
| 2833 | return; |
|---|
| 2834 | |
|---|
| 2835 | // Soul Shard only from non-grey units |
|---|
| 2836 | if( spellInfo->EffectItemType[m_effIndex] == 6265 && |
|---|
| 2837 | (victim->getLevel() <= Trinity::XP::GetGrayLevel(caster->getLevel()) || |
|---|
| 2838 | victim->GetTypeId()==TYPEID_UNIT && !((Player*)caster)->isAllowedToLoot((Creature*)victim)) ) |
|---|
| 2839 | return; |
|---|
| 2840 | ItemPosCountVec dest; |
|---|
| 2841 | uint8 msg = ((Player*)caster)->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, spellInfo->EffectItemType[m_effIndex], 1 ); |
|---|
| 2842 | if( msg != EQUIP_ERR_OK ) |
|---|
| 2843 | { |
|---|
| 2844 | ((Player*)caster)->SendEquipError( msg, NULL, NULL ); |
|---|
| 2845 | return; |
|---|
| 2846 | } |
|---|
| 2847 | |
|---|
| 2848 | Item* newitem = ((Player*)caster)->StoreNewItem(dest, spellInfo->EffectItemType[m_effIndex], true); |
|---|
| 2849 | ((Player*)caster)->SendNewItem(newitem, 1, true, false); |
|---|
| 2850 | } |
|---|
| 2851 | } |
|---|
| 2852 | |
|---|
| 2853 | void Aura::HandleBindSight(bool apply, bool Real) |
|---|
| 2854 | { |
|---|
| 2855 | Unit* caster = GetCaster(); |
|---|
| 2856 | if(!caster || caster->GetTypeId() != TYPEID_PLAYER) |
|---|
| 2857 | return; |
|---|
| 2858 | |
|---|
| 2859 | caster->SetUInt64Value(PLAYER_FARSIGHT,apply ? m_target->GetGUID() : 0); |
|---|
| 2860 | } |
|---|
| 2861 | |
|---|
| 2862 | void Aura::HandleFarSight(bool apply, bool Real) |
|---|
| 2863 | { |
|---|
| 2864 | Unit* caster = GetCaster(); |
|---|
| 2865 | if(!caster || caster->GetTypeId() != TYPEID_PLAYER) |
|---|
| 2866 | return; |
|---|
| 2867 | |
|---|
| 2868 | caster->SetUInt64Value(PLAYER_FARSIGHT,apply ? m_modifier.m_miscvalue : 0); |
|---|
| 2869 | } |
|---|
| 2870 | |
|---|
| 2871 | void Aura::HandleAuraTrackCreatures(bool apply, bool Real) |
|---|
| 2872 | { |
|---|
| 2873 | if(m_target->GetTypeId()!=TYPEID_PLAYER) |
|---|
| 2874 | return; |
|---|
| 2875 | |
|---|
| 2876 | if(apply) |
|---|
| 2877 | m_target->RemoveNoStackAurasDueToAura(this); |
|---|
| 2878 | m_target->SetUInt32Value(PLAYER_TRACK_CREATURES, apply ? ((uint32)1)<<(m_modifier.m_miscvalue-1) : 0 ); |
|---|
| 2879 | } |
|---|
| 2880 | |
|---|
| 2881 | void Aura::HandleAuraTrackResources(bool apply, bool Real) |
|---|
| 2882 | { |
|---|
| 2883 | if(m_target->GetTypeId()!=TYPEID_PLAYER) |
|---|
| 2884 | return; |
|---|
| 2885 | |
|---|
| 2886 | if(apply) |
|---|
| 2887 | m_target->RemoveNoStackAurasDueToAura(this); |
|---|
| 2888 | m_target->SetUInt32Value(PLAYER_TRACK_RESOURCES, apply ? ((uint32)1)<<(m_modifier.m_miscvalue-1): 0 ); |
|---|
| 2889 | } |
|---|
| 2890 | |
|---|
| 2891 | void Aura::HandleAuraTrackStealthed(bool apply, bool Real) |
|---|
| 2892 | { |
|---|
| 2893 | if(m_target->GetTypeId()!=TYPEID_PLAYER) |
|---|
| 2894 | return; |
|---|
| 2895 | |
|---|
| 2896 | if(apply) |
|---|
| 2897 | m_target->RemoveNoStackAurasDueToAura(this); |
|---|
| 2898 | |
|---|
| 2899 | m_target->ApplyModFlag(PLAYER_FIELD_BYTES,PLAYER_FIELD_BYTE_TRACK_STEALTHED,apply); |
|---|
| 2900 | } |
|---|
| 2901 | |
|---|
| 2902 | void Aura::HandleAuraModScale(bool apply, bool Real) |
|---|
| 2903 | { |
|---|
| 2904 | m_target->ApplyPercentModFloatValue(OBJECT_FIELD_SCALE_X,m_modifier.m_amount,apply); |
|---|
| 2905 | } |
|---|
| 2906 | |
|---|
| 2907 | void Aura::HandleModPossess(bool apply, bool Real) |
|---|
| 2908 | { |
|---|
| 2909 | if(!Real) |
|---|
| 2910 | return; |
|---|
| 2911 | |
|---|
| 2912 | if(m_target->getLevel() > m_modifier.m_amount) |
|---|
| 2913 | return; |
|---|
| 2914 | |
|---|
| 2915 | // not possess yourself |
|---|
| 2916 | if(GetCasterGUID() == m_target->GetGUID()) |
|---|
| 2917 | return; |
|---|
| 2918 | |
|---|
| 2919 | Unit* caster = GetCaster(); |
|---|
| 2920 | if(!caster) |
|---|
| 2921 | return; |
|---|
| 2922 | |
|---|
| 2923 | if( apply ) |
|---|
| 2924 | { |
|---|
| 2925 | m_target->SetCharmerGUID(GetCasterGUID()); |
|---|
| 2926 | m_target->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE,caster->getFaction()); |
|---|
| 2927 | caster->SetCharm(m_target); |
|---|
| 2928 | |
|---|
| 2929 | m_target->CombatStop(); |
|---|
| 2930 | m_target->DeleteThreatList(); |
|---|
| 2931 | if(m_target->GetTypeId() == TYPEID_UNIT) |
|---|
| 2932 | { |
|---|
| 2933 | m_target->StopMoving(); |
|---|
| 2934 | m_target->GetMotionMaster()->Clear(); |
|---|
| 2935 | m_target->GetMotionMaster()->MoveIdle(); |
|---|
| 2936 | CharmInfo *charmInfo = ((Creature*)m_target)->InitCharmInfo(m_target); |
|---|
| 2937 | charmInfo->InitPossessCreateSpells(); |
|---|
| 2938 | } |
|---|
| 2939 | |
|---|
| 2940 | if(caster->GetTypeId() == TYPEID_PLAYER) |
|---|
| 2941 | { |
|---|
| 2942 | ((Player*)caster)->PossessSpellInitialize(); |
|---|
| 2943 | } |
|---|
| 2944 | } |
|---|
| 2945 | else |
|---|
| 2946 | { |
|---|
| 2947 | m_target->SetCharmerGUID(0); |
|---|
| 2948 | |
|---|
| 2949 | if(m_target->GetTypeId() == TYPEID_PLAYER) |
|---|
| 2950 | { |
|---|
| 2951 | ((Player*)m_target)->setFactionForRace(m_target->getRace()); |
|---|
| 2952 | } |
|---|
| 2953 | else if(m_target->GetTypeId() == TYPEID_UNIT) |
|---|
| 2954 | { |
|---|
| 2955 | CreatureInfo const *cinfo = ((Creature*)m_target)->GetCreatureInfo(); |
|---|
| 2956 | m_target->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE,cinfo->faction_A); |
|---|
| 2957 | } |
|---|
| 2958 | |
|---|
| 2959 | caster->SetCharm(0); |
|---|
| 2960 | |
|---|
| 2961 | if(caster->GetTypeId() == TYPEID_PLAYER) |
|---|
| 2962 | { |
|---|
| 2963 | WorldPacket data(SMSG_PET_SPELLS, 8); |
|---|
| 2964 | data << uint64(0); |
|---|
| 2965 | ((Player*)caster)->GetSession()->SendPacket(&data); |
|---|
| 2966 | } |
|---|
| 2967 | if(m_target->GetTypeId() == TYPEID_UNIT) |
|---|
| 2968 | { |
|---|
| 2969 | ((Creature*)m_target)->AIM_Initialize(); |
|---|
| 2970 | |
|---|
| 2971 | if (((Creature*)m_target)->AI()) |
|---|
| 2972 | ((Creature*)m_target)->AI()->AttackStart(caster); |
|---|
| 2973 | } |
|---|
| 2974 | } |
|---|
| 2975 | if(caster->GetTypeId() == TYPEID_PLAYER) |
|---|
| 2976 | caster->SetUInt64Value(PLAYER_FARSIGHT,apply ? m_target->GetGUID() : 0); |
|---|
| 2977 | } |
|---|
| 2978 | |
|---|
| 2979 | void Aura::HandleModPossessPet(bool apply, bool Real) |
|---|
| 2980 | { |
|---|
| 2981 | if(!Real) |
|---|
| 2982 | return; |
|---|
| 2983 | |
|---|
| 2984 | Unit* caster = GetCaster(); |
|---|
| 2985 | if(!caster || caster->GetTypeId() != TYPEID_PLAYER) |
|---|
| 2986 | return; |
|---|
| 2987 | if(caster->GetPet() != m_target) |
|---|
| 2988 | return; |
|---|
| 2989 | |
|---|
| 2990 | if(apply) |
|---|
| 2991 | { |
|---|
| 2992 | caster->SetUInt64Value(PLAYER_FARSIGHT, m_target->GetGUID()); |
|---|
| 2993 | m_target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNKNOWN5); |
|---|
| 2994 | } |
|---|
| 2995 | else |
|---|
| 2996 | { |
|---|
| 2997 | caster->SetUInt64Value(PLAYER_FARSIGHT, 0); |
|---|
| 2998 | m_target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNKNOWN5); |
|---|
| 2999 | } |
|---|
| 3000 | } |
|---|
| 3001 | |
|---|
| 3002 | void Aura::HandleModCharm(bool apply, bool Real) |
|---|
| 3003 | { |
|---|
| 3004 | if(!Real) |
|---|
| 3005 | return; |
|---|
| 3006 | |
|---|
| 3007 | // not charm yourself |
|---|
| 3008 | if(GetCasterGUID() == m_target->GetGUID()) |
|---|
| 3009 | return; |
|---|
| 3010 | |
|---|
| 3011 | Unit* caster = GetCaster(); |
|---|
| 3012 | if(!caster) |
|---|
| 3013 | return; |
|---|
| 3014 | |
|---|
| 3015 | if(int32(m_target->getLevel()) <= m_modifier.m_amount) |
|---|
| 3016 | { |
|---|
| 3017 | if( apply ) |
|---|
| 3018 | { |
|---|
| 3019 | m_target->SetCharmerGUID(GetCasterGUID()); |
|---|
| 3020 | m_target->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE,caster->getFaction()); |
|---|
| 3021 | m_target->CastStop(m_target==caster ? GetId() : 0); |
|---|
| 3022 | caster->SetCharm(m_target); |
|---|
| 3023 | |
|---|
| 3024 | m_target->CombatStop(); |
|---|
| 3025 | m_target->DeleteThreatList(); |
|---|
| 3026 | |
|---|
| 3027 | if(m_target->GetTypeId() == TYPEID_UNIT) |
|---|
| 3028 | { |
|---|
| 3029 | ((Creature*)m_target)->AIM_Initialize(); |
|---|
| 3030 | CharmInfo *charmInfo = ((Creature*)m_target)->InitCharmInfo(m_target); |
|---|
| 3031 | charmInfo->InitCharmCreateSpells(); |
|---|
| 3032 | charmInfo->SetReactState( REACT_DEFENSIVE ); |
|---|
| 3033 | |
|---|
| 3034 | if(caster->GetTypeId() == TYPEID_PLAYER && caster->getClass() == CLASS_WARLOCK) |
|---|
| 3035 | { |
|---|
| 3036 | CreatureInfo const *cinfo = ((Creature*)m_target)->GetCreatureInfo(); |
|---|
| 3037 | if(cinfo && cinfo->type == CREATURE_TYPE_DEMON) |
|---|
| 3038 | { |
|---|
| 3039 | //to prevent client crash |
|---|
| 3040 | m_target->SetFlag(UNIT_FIELD_BYTES_0, 2048); |
|---|
| 3041 | //just to enable stat window |
|---|
| 3042 | charmInfo->SetPetNumber(objmgr.GeneratePetNumber(), true); |
|---|
| 3043 | //if charmed two demons the same session, the 2nd gets the 1st one's name |
|---|
| 3044 | m_target->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, time(NULL)); |
|---|
| 3045 | } |
|---|
| 3046 | } |
|---|
| 3047 | } |
|---|
| 3048 | |
|---|
| 3049 | if(caster->GetTypeId() == TYPEID_PLAYER) |
|---|
| 3050 | { |
|---|
| 3051 | ((Player*)caster)->CharmSpellInitialize(); |
|---|
| 3052 | } |
|---|
| 3053 | } |
|---|
| 3054 | else |
|---|
| 3055 | { |
|---|
| 3056 | m_target->SetCharmerGUID(0); |
|---|
| 3057 | |
|---|
| 3058 | if(m_target->GetTypeId() == TYPEID_PLAYER) |
|---|
| 3059 | { |
|---|
| 3060 | ((Player*)m_target)->setFactionForRace(m_target->getRace()); |
|---|
| 3061 | } |
|---|
| 3062 | else |
|---|
| 3063 | { |
|---|
| 3064 | CreatureInfo const *cinfo = ((Creature*)m_target)->GetCreatureInfo(); |
|---|
| 3065 | |
|---|
| 3066 | // restore faction |
|---|
| 3067 | if(((Creature*)m_target)->isPet()) |
|---|
| 3068 | { |
|---|
| 3069 | if(Unit* owner = m_target->GetOwner()) |
|---|
| 3070 | m_target->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE,owner->getFaction()); |
|---|
| 3071 | else if(cinfo) |
|---|
| 3072 | m_target->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE,cinfo->faction_A); |
|---|
| 3073 | } |
|---|
| 3074 | else if(cinfo) // normal creature |
|---|
| 3075 | m_target->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE,cinfo->faction_A); |
|---|
| 3076 | |
|---|
| 3077 | // restore UNIT_FIELD_BYTES_0 |
|---|
| 3078 | if(cinfo && caster->GetTypeId() == TYPEID_PLAYER && caster->getClass() == CLASS_WARLOCK && cinfo->type == CREATURE_TYPE_DEMON) |
|---|
| 3079 | { |
|---|
| 3080 | CreatureDataAddon const *cainfo = ((Creature*)m_target)->GetCreatureAddon(); |
|---|
| 3081 | if(cainfo && cainfo->bytes0 != 0) |
|---|
| 3082 | m_target->SetUInt32Value(UNIT_FIELD_BYTES_0, cainfo->bytes0); |
|---|
| 3083 | else |
|---|
| 3084 | m_target->RemoveFlag(UNIT_FIELD_BYTES_0, 2048); |
|---|
| 3085 | |
|---|
| 3086 | if(m_target->GetCharmInfo()) |
|---|
| 3087 | m_target->GetCharmInfo()->SetPetNumber(0, true); |
|---|
| 3088 | else |
|---|
| 3089 | sLog.outError("Aura::HandleModCharm: target="I64FMTD" with typeid=%d has a charm aura but no charm info!", m_target->GetGUID(), m_target->GetTypeId()); |
|---|
| 3090 | } |
|---|
| 3091 | } |
|---|
| 3092 | |
|---|
| 3093 | caster->SetCharm(0); |
|---|
| 3094 | |
|---|
| 3095 | if(caster->GetTypeId() == TYPEID_PLAYER) |
|---|
| 3096 | { |
|---|
| 3097 | WorldPacket data(SMSG_PET_SPELLS, 8); |
|---|
| 3098 | data << uint64(0); |
|---|
| 3099 | ((Player*)caster)->GetSession()->SendPacket(&data); |
|---|
| 3100 | } |
|---|
| 3101 | if(m_target->GetTypeId() == TYPEID_UNIT) |
|---|
| 3102 | { |
|---|
| 3103 | ((Creature*)m_target)->AIM_Initialize(); |
|---|
| 3104 | if (((Creature*)m_target)->AI()) |
|---|
| 3105 | ((Creature*)m_target)->AI()->AttackStart(caster); |
|---|
| 3106 | } |
|---|
| 3107 | } |
|---|
| 3108 | } |
|---|
| 3109 | } |
|---|
| 3110 | |
|---|
| 3111 | void Aura::HandleModConfuse(bool apply, bool Real) |
|---|
| 3112 | { |
|---|
| 3113 | if(!Real) |
|---|
| 3114 | return; |
|---|
| 3115 | |
|---|
| 3116 | m_target->SetConfused(apply, GetCasterGUID(), GetId()); |
|---|
| 3117 | } |
|---|
| 3118 | |
|---|
| 3119 | void Aura::HandleModFear(bool apply, bool Real) |
|---|
| 3120 | { |
|---|
| 3121 | if (!Real) |
|---|
| 3122 | return; |
|---|
| 3123 | |
|---|
| 3124 | m_target->SetFeared(apply, GetCasterGUID(), GetId()); |
|---|
| 3125 | } |
|---|
| 3126 | |
|---|
| 3127 | void Aura::HandleFeignDeath(bool apply, bool Real) |
|---|
| 3128 | { |
|---|
| 3129 | if(!Real) |
|---|
| 3130 | return; |
|---|
| 3131 | |
|---|
| 3132 | if(m_target->GetTypeId() != TYPEID_PLAYER) |
|---|
| 3133 | return; |
|---|
| 3134 | |
|---|
| 3135 | if( apply ) |
|---|
| 3136 | { |
|---|
| 3137 | /* |
|---|
| 3138 | WorldPacket data(SMSG_FEIGN_DEATH_RESISTED, 9); |
|---|
| 3139 | data<<m_target->GetGUID(); |
|---|
| 3140 | data<<uint8(0); |
|---|
| 3141 | m_target->SendMessageToSet(&data,true); |
|---|
| 3142 | */ |
|---|
| 3143 | // blizz like 2.0.x |
|---|
| 3144 | m_target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNKNOWN6); |
|---|
| 3145 | // blizz like 2.0.x |
|---|
| 3146 | m_target->SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FEIGN_DEATH); |
|---|
| 3147 | // blizz like 2.0.x |
|---|
| 3148 | m_target->SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_DEAD); |
|---|
| 3149 | |
|---|
| 3150 | m_target->addUnitState(UNIT_STAT_DIED); |
|---|
| 3151 | m_target->CombatStop(); |
|---|
| 3152 | |
|---|
| 3153 | // prevent interrupt message |
|---|
| 3154 | if(m_caster_guid==m_target->GetGUID() && m_target->m_currentSpells[CURRENT_GENERIC_SPELL]) |
|---|
| 3155 | m_target->m_currentSpells[CURRENT_GENERIC_SPELL]->finish(); |
|---|
| 3156 | m_target->InterruptNonMeleeSpells(true); |
|---|
| 3157 | m_target->getHostilRefManager().deleteReferences(); |
|---|
| 3158 | } |
|---|
| 3159 | else |
|---|
| 3160 | { |
|---|
| 3161 | /* |
|---|
| 3162 | WorldPacket data(SMSG_FEIGN_DEATH_RESISTED, 9); |
|---|
| 3163 | data<<m_target->GetGUID(); |
|---|
| 3164 | data<<uint8(1); |
|---|
| 3165 | m_target->SendMessageToSet(&data,true); |
|---|
| 3166 | */ |
|---|
| 3167 | // blizz like 2.0.x |
|---|
| 3168 | m_target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNKNOWN6); |
|---|
| 3169 | // blizz like 2.0.x |
|---|
| 3170 | m_target->RemoveFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FEIGN_DEATH); |
|---|
| 3171 | // blizz like 2.0.x |
|---|
| 3172 | m_target->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_DEAD); |
|---|
| 3173 | |
|---|
| 3174 | m_target->clearUnitState(UNIT_STAT_DIED); |
|---|
| 3175 | } |
|---|
| 3176 | } |
|---|
| 3177 | |
|---|
| 3178 | void Aura::HandleAuraModDisarm(bool apply, bool Real) |
|---|
| 3179 | { |
|---|
| 3180 | if(!Real) |
|---|
| 3181 | return; |
|---|
| 3182 | |
|---|
| 3183 | if(!apply && m_target->HasAuraType(SPELL_AURA_MOD_DISARM)) |
|---|
| 3184 | return; |
|---|
| 3185 | |
|---|
| 3186 | // not sure for it's correctness |
|---|
| 3187 | if(apply) |
|---|
| 3188 | m_target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISARMED); |
|---|
| 3189 | else |
|---|
| 3190 | m_target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISARMED); |
|---|
| 3191 | |
|---|
| 3192 | // only at real add/remove aura |
|---|
| 3193 | if (m_target->GetTypeId() != TYPEID_PLAYER) |
|---|
| 3194 | return; |
|---|
| 3195 | |
|---|
| 3196 | // main-hand attack speed already set to special value for feral form already and don't must chnage and reset at remove. |
|---|
| 3197 | if (((Player *)m_target)->IsInFeralForm()) |
|---|
| 3198 | return; |
|---|
| 3199 | |
|---|
| 3200 | if (apply) |
|---|
| 3201 | m_target->SetAttackTime(BASE_ATTACK,BASE_ATTACK_TIME); |
|---|
| 3202 | else |
|---|
| 3203 | ((Player *)m_target)->SetRegularAttackTime(); |
|---|
| 3204 | |
|---|
| 3205 | m_target->UpdateDamagePhysical(BASE_ATTACK); |
|---|
| 3206 | } |
|---|
| 3207 | |
|---|
| 3208 | void Aura::HandleAuraModStun(bool apply, bool Real) |
|---|
| 3209 | { |
|---|
| 3210 | if(!Real) |
|---|
| 3211 | return; |
|---|
| 3212 | |
|---|
| 3213 | if (apply) |
|---|
| 3214 | { |
|---|
| 3215 | m_target->addUnitState(UNIT_STAT_STUNNED); |
|---|
| 3216 | m_target->SetUInt64Value(UNIT_FIELD_TARGET, 0); |
|---|
| 3217 | |
|---|
| 3218 | m_target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_ROTATE); |
|---|
| 3219 | m_target->CastStop(m_target->GetGUID() == GetCasterGUID() ? GetId() : 0); |
|---|
| 3220 | |
|---|
| 3221 | // Creature specific |
|---|
| 3222 | if(m_target->GetTypeId() != TYPEID_PLAYER) |
|---|
| 3223 | ((Creature*)m_target)->StopMoving(); |
|---|
| 3224 | else |
|---|
| 3225 | m_target->SetUnitMovementFlags(0); //Clear movement flags |
|---|
| 3226 | |
|---|
| 3227 | WorldPacket data(SMSG_FORCE_MOVE_ROOT, 8); |
|---|
| 3228 | |
|---|
| 3229 | data.append(m_target->GetPackGUID()); |
|---|
| 3230 | data << uint32(0); |
|---|
| 3231 | m_target->SendMessageToSet(&data,true); |
|---|
| 3232 | } |
|---|
| 3233 | else |
|---|
| 3234 | { |
|---|
| 3235 | // Real remove called after current aura remove from lists, check if other similar auras active |
|---|
| 3236 | if(m_target->HasAuraType(SPELL_AURA_MOD_STUN)) |
|---|
| 3237 | return; |
|---|
| 3238 | |
|---|
| 3239 | m_target->clearUnitState(UNIT_STAT_STUNNED); |
|---|
| 3240 | m_target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_ROTATE); |
|---|
| 3241 | |
|---|
| 3242 | if(!m_target->hasUnitState(UNIT_STAT_ROOT)) // prevent allow move if have also root effect |
|---|
| 3243 | { |
|---|
| 3244 | if(m_target->getVictim() && m_target->isAlive()) |
|---|
| 3245 | m_target->SetUInt64Value(UNIT_FIELD_TARGET,m_target->getVictim()->GetGUID() ); |
|---|
| 3246 | |
|---|
| 3247 | WorldPacket data(SMSG_FORCE_MOVE_UNROOT, 8+4); |
|---|
| 3248 | data.append(m_target->GetPackGUID()); |
|---|
| 3249 | data << uint32(0); |
|---|
| 3250 | m_target->SendMessageToSet(&data,true); |
|---|
| 3251 | } |
|---|
| 3252 | |
|---|
| 3253 | // Wyvern Sting |
|---|
| 3254 | if (GetSpellProto()->SpellFamilyName == SPELLFAMILY_HUNTER && GetSpellProto()->SpellIconID == 1721) |
|---|
| 3255 | { |
|---|
| 3256 | Unit* caster = GetCaster(); |
|---|
| 3257 | if( !caster || caster->GetTypeId()!=TYPEID_PLAYER ) |
|---|
| 3258 | return; |
|---|
| 3259 | |
|---|
| 3260 | uint32 spell_id = 0; |
|---|
| 3261 | |
|---|
| 3262 | switch(GetId()) |
|---|
| 3263 | { |
|---|
| 3264 | case 19386: spell_id = 24131; break; |
|---|
| 3265 | case 24132: spell_id = 24134; break; |
|---|
| 3266 | case 24133: spell_id = 24135; break; |
|---|
| 3267 | case 27068: spell_id = 27069; break; |
|---|
| 3268 | default: |
|---|
| 3269 | sLog.outError("Spell selection called for unexpected original spell %u, new spell for this spell family?",GetId()); |
|---|
| 3270 | return; |
|---|
| 3271 | } |
|---|
| 3272 | |
|---|
| 3273 | SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell_id); |
|---|
| 3274 | |
|---|
| 3275 | if(!spellInfo) |
|---|
| 3276 | return; |
|---|
| 3277 | |
|---|
| 3278 | caster->CastSpell(m_target,spellInfo,true,NULL,this); |
|---|
| 3279 | return; |
|---|
| 3280 | } |
|---|
| 3281 | } |
|---|
| 3282 | } |
|---|
| 3283 | |
|---|
| 3284 | void Aura::HandleModStealth(bool apply, bool Real) |
|---|
| 3285 | { |
|---|
| 3286 | if(apply) |
|---|
| 3287 | { |
|---|
| 3288 | if(Real && m_target->GetTypeId()==TYPEID_PLAYER) |
|---|
| 3289 | { |
|---|
| 3290 | // drop flag at stealth in bg |
|---|
| 3291 | if(((Player*)m_target)->InBattleGround()) |
|---|
| 3292 | { |
|---|
| 3293 | if(BattleGround *bg = ((Player*)m_target)->GetBattleGround()) |
|---|
| 3294 | bg->EventPlayerDroppedFlag((Player*)m_target); |
|---|
| 3295 | } |
|---|
| 3296 | // remove player from the objective's active player count at stealth |
|---|
| 3297 | if(OutdoorPvP * pvp = ((Player*)m_target)->GetOutdoorPvP()) |
|---|
| 3298 | pvp->HandlePlayerActivityChanged((Player*)m_target); |
|---|
| 3299 | } |
|---|
| 3300 | |
|---|
| 3301 | // only at real aura add |
|---|
| 3302 | if(Real) |
|---|
| 3303 | { |
|---|
| 3304 | m_target->SetByteValue(UNIT_FIELD_BYTES_1, 2, 0x02); |
|---|
| 3305 | if(m_target->GetTypeId()==TYPEID_PLAYER) |
|---|
| 3306 | m_target->SetFlag(PLAYER_FIELD_BYTES2, 0x2000); |
|---|
| 3307 | |
|---|
| 3308 | // apply only if not in GM invisibility (and overwrite invisibility state) |
|---|
| 3309 | if(m_target->GetVisibility()!=VISIBILITY_OFF) |
|---|
| 3310 | { |
|---|
| 3311 | m_target->SetVisibility(VISIBILITY_GROUP_NO_DETECT); |
|---|
| 3312 | m_target->SetVisibility(VISIBILITY_GROUP_STEALTH); |
|---|
| 3313 | } |
|---|
| 3314 | |
|---|
| 3315 | // for RACE_NIGHTELF stealth |
|---|
| 3316 | if(m_target->GetTypeId()==TYPEID_PLAYER && GetId()==20580) |
|---|
| 3317 | m_target->CastSpell(m_target, 21009, true, NULL, this); |
|---|
| 3318 | } |
|---|
| 3319 | } |
|---|
| 3320 | else |
|---|
| 3321 | { |
|---|
| 3322 | // only at real aura remove |
|---|
| 3323 | if(Real) |
|---|
| 3324 | { |
|---|
| 3325 | // for RACE_NIGHTELF stealth |
|---|
| 3326 | if(m_target->GetTypeId()==TYPEID_PLAYER && GetId()==20580) |
|---|
| 3327 | m_target->RemoveAurasDueToSpell(21009); |
|---|
| 3328 | |
|---|
| 3329 | // if last SPELL_AURA_MOD_STEALTH and no GM invisibility |
|---|
| 3330 | if(!m_target->HasAuraType(SPELL_AURA_MOD_STEALTH) && m_target->GetVisibility()!=VISIBILITY_OFF) |
|---|
| 3331 | { |
|---|
| 3332 | m_target->SetByteValue(UNIT_FIELD_BYTES_1, 2, 0x00); |
|---|
| 3333 | if(m_target->GetTypeId()==TYPEID_PLAYER) |
|---|
| 3334 | m_target->RemoveFlag(PLAYER_FIELD_BYTES2, 0x2000); |
|---|
| 3335 | |
|---|
| 3336 | // restore invisibility if any |
|---|
| 3337 | if(m_target->HasAuraType(SPELL_AURA_MOD_INVISIBILITY)) |
|---|
| 3338 | { |
|---|
| 3339 | m_target->SetVisibility(VISIBILITY_GROUP_NO_DETECT); |
|---|
| 3340 | m_target->SetVisibility(VISIBILITY_GROUP_INVISIBILITY); |
|---|
| 3341 | } |
|---|
| 3342 | else |
|---|
| 3343 | { |
|---|
| 3344 | m_target->SetVisibility(VISIBILITY_ON); |
|---|
| 3345 | if(m_target->GetTypeId() == TYPEID_PLAYER) |
|---|
| 3346 | if(OutdoorPvP * pvp = ((Player*)m_target)->GetOutdoorPvP()) |
|---|
| 3347 | pvp->HandlePlayerActivityChanged((Player*)m_target); |
|---|
| 3348 | } |
|---|
| 3349 | } |
|---|
| 3350 | } |
|---|
| 3351 | } |
|---|
| 3352 | |
|---|
| 3353 | // Master of Subtlety |
|---|
| 3354 | Unit::AuraList const& mDummyAuras = m_target->GetAurasByType(SPELL_AURA_DUMMY); |
|---|
| 3355 | for(Unit::AuraList::const_iterator i = mDummyAuras.begin();i != mDummyAuras.end(); ++i) |
|---|
| 3356 | { |
|---|
| 3357 | if ((*i)->GetSpellProto()->SpellIconID == 2114) |
|---|
| 3358 | { |
|---|
| 3359 | if (apply) |
|---|
| 3360 | { |
|---|
| 3361 | int32 bp = (*i)->GetModifier()->m_amount; |
|---|
| 3362 | m_target->CastCustomSpell(m_target,31665,&bp,NULL,NULL,true); |
|---|
| 3363 | } |
|---|
| 3364 | else |
|---|
| 3365 | m_target->CastSpell(m_target,31666,true); |
|---|
| 3366 | break; |
|---|
| 3367 | } |
|---|
| 3368 | } |
|---|
| 3369 | } |
|---|
| 3370 | |
|---|
| 3371 | void Aura::HandleInvisibility(bool apply, bool Real) |
|---|
| 3372 | { |
|---|
| 3373 | if(apply) |
|---|
| 3374 | { |
|---|
| 3375 | m_target->m_invisibilityMask |= (1 << m_modifier.m_miscvalue); |
|---|
| 3376 | |
|---|
| 3377 | if(Real && m_target->GetTypeId()==TYPEID_PLAYER) |
|---|
| 3378 | { |
|---|
| 3379 | // apply glow vision |
|---|
| 3380 | m_target->SetFlag(PLAYER_FIELD_BYTES2,PLAYER_FIELD_BYTE2_INVISIBILITY_GLOW); |
|---|
| 3381 | // remove player from the objective's active player count at invisibility |
|---|
| 3382 | if(OutdoorPvP * pvp = ((Player*)m_target)->GetOutdoorPvP()) |
|---|
| 3383 | pvp->HandlePlayerActivityChanged((Player*)m_target); |
|---|
| 3384 | |
|---|
| 3385 | // drop flag at invisible in bg |
|---|
| 3386 | if(((Player*)m_target)->InBattleGround()) |
|---|
| 3387 | if(BattleGround *bg = ((Player*)m_target)->GetBattleGround()) |
|---|
| 3388 | bg->EventPlayerDroppedFlag((Player*)m_target); |
|---|
| 3389 | } |
|---|
| 3390 | |
|---|
| 3391 | // apply only if not in GM invisibility and not stealth |
|---|
| 3392 | if(m_target->GetVisibility()==VISIBILITY_ON) |
|---|
| 3393 | { |
|---|
| 3394 | // Aura not added yet but visibility code expect temporary add aura |
|---|
| 3395 | m_target->SetVisibility(VISIBILITY_GROUP_NO_DETECT); |
|---|
| 3396 | m_target->SetVisibility(VISIBILITY_GROUP_INVISIBILITY); |
|---|
| 3397 | } |
|---|
| 3398 | } |
|---|
| 3399 | else |
|---|
| 3400 | { |
|---|
| 3401 | // recalculate value at modifier remove (current aura already removed) |
|---|
| 3402 | m_target->m_invisibilityMask = 0; |
|---|
| 3403 | Unit::AuraList const& auras = m_target->GetAurasByType(SPELL_AURA_MOD_INVISIBILITY); |
|---|
| 3404 | for(Unit::AuraList::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) |
|---|
| 3405 | m_target->m_invisibilityMask |= (1 << m_modifier.m_miscvalue); |
|---|
| 3406 | |
|---|
| 3407 | // only at real aura remove and if not have different invisibility auras. |
|---|
| 3408 | if(Real && m_target->m_invisibilityMask==0) |
|---|
| 3409 | { |
|---|
| 3410 | // remove glow vision |
|---|
| 3411 | if(m_target->GetTypeId() == TYPEID_PLAYER) |
|---|
| 3412 | m_target->RemoveFlag(PLAYER_FIELD_BYTES2,PLAYER_FIELD_BYTE2_INVISIBILITY_GLOW); |
|---|
| 3413 | |
|---|
| 3414 | // apply only if not in GM invisibility & not stealthed while invisible |
|---|
| 3415 | if(m_target->GetVisibility()!=VISIBILITY_OFF) |
|---|
| 3416 | { |
|---|
| 3417 | // if have stealth aura then already have stealth visibility |
|---|
| 3418 | if(!m_target->HasAuraType(SPELL_AURA_MOD_STEALTH)) |
|---|
| 3419 | { |
|---|
| 3420 | m_target->SetVisibility(VISIBILITY_ON); |
|---|
| 3421 | if(m_target->GetTypeId() == TYPEID_PLAYER) |
|---|
| 3422 | if(OutdoorPvP * pvp = ((Player*)m_target)->GetOutdoorPvP()) |
|---|
| 3423 | pvp->HandlePlayerActivityChanged((Player*)m_target); |
|---|
| 3424 | } |
|---|
| 3425 | } |
|---|
| 3426 | } |
|---|
| 3427 | } |
|---|
| 3428 | } |
|---|
| 3429 | |
|---|
| 3430 | void Aura::HandleInvisibilityDetect(bool apply, bool Real) |
|---|
| 3431 | { |
|---|
| 3432 | if(apply) |
|---|
| 3433 | { |
|---|
| 3434 | m_target->m_detectInvisibilityMask |= (1 << m_modifier.m_miscvalue); |
|---|
| 3435 | } |
|---|
| 3436 | else |
|---|
| 3437 | { |
|---|
| 3438 | // recalculate value at modifier remove (current aura already removed) |
|---|
| 3439 | m_target->m_detectInvisibilityMask = 0; |
|---|
| 3440 | Unit::AuraList const& auras = m_target->GetAurasByType(SPELL_AURA_MOD_INVISIBILITY_DETECTION); |
|---|
| 3441 | for(Unit::AuraList::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) |
|---|
| 3442 | m_target->m_detectInvisibilityMask |= (1 << m_modifier.m_miscvalue); |
|---|
| 3443 | } |
|---|
| 3444 | if(Real && m_target->GetTypeId()==TYPEID_PLAYER) |
|---|
| 3445 | ObjectAccessor::UpdateVisibilityForPlayer((Player*)m_target); |
|---|
| 3446 | } |
|---|
| 3447 | |
|---|
| 3448 | void Aura::HandleAuraModRoot(bool apply, bool Real) |
|---|
| 3449 | { |
|---|
| 3450 | // only at real add/remove aura |
|---|
| 3451 | if(!Real) |
|---|
| 3452 | return; |
|---|
| 3453 | |
|---|
| 3454 | uint32 apply_stat = UNIT_STAT_ROOT; |
|---|
| 3455 | if (apply) |
|---|
| 3456 | { |
|---|
| 3457 | m_target->addUnitState(UNIT_STAT_ROOT); |
|---|
| 3458 | m_target->SetUInt64Value (UNIT_FIELD_TARGET, 0); |
|---|
| 3459 | // probably wrong |
|---|
| 3460 | m_target->SetFlag(UNIT_FIELD_FLAGS,(apply_stat<<16)); |
|---|
| 3461 | |
|---|
| 3462 | //Save last orientation |
|---|
| 3463 | if( m_target->getVictim() ) |
|---|
| 3464 | m_target->SetOrientation(m_target->GetAngle(m_target->getVictim())); |
|---|
| 3465 | |
|---|
| 3466 | if(m_target->GetTypeId() == TYPEID_PLAYER) |
|---|
| 3467 | { |
|---|
| 3468 | WorldPacket data(SMSG_FORCE_MOVE_ROOT, 10); |
|---|
| 3469 | data.append(m_target->GetPackGUID()); |
|---|
| 3470 | data << (uint32)2; |
|---|
| 3471 | m_target->SendMessageToSet(&data,true); |
|---|
| 3472 | |
|---|
| 3473 | //Clear unit movement flags |
|---|
| 3474 | m_target->SetUnitMovementFlags(0); |
|---|
| 3475 | } |
|---|
| 3476 | else |
|---|
| 3477 | ((Creature *)m_target)->StopMoving(); |
|---|
| 3478 | } |
|---|
| 3479 | else |
|---|
| 3480 | { |
|---|
| 3481 | // Real remove called after current aura remove from lists, check if other similar auras active |
|---|
| 3482 | if(m_target->HasAuraType(SPELL_AURA_MOD_ROOT)) |
|---|
| 3483 | return; |
|---|
| 3484 | |
|---|
| 3485 | m_target->clearUnitState(UNIT_STAT_ROOT); |
|---|
| 3486 | // probably wrong |
|---|
| 3487 | m_target->RemoveFlag(UNIT_FIELD_FLAGS,(apply_stat<<16)); |
|---|
| 3488 | |
|---|
| 3489 | if(!m_target->hasUnitState(UNIT_STAT_STUNNED)) // prevent allow move if have also stun effect |
|---|
| 3490 | { |
|---|
| 3491 | if(m_target->getVictim() && m_target->isAlive()) |
|---|
| 3492 | m_target->SetUInt64Value (UNIT_FIELD_TARGET,m_target->getVictim()->GetGUID() ); |
|---|
| 3493 | |
|---|
| 3494 | if(m_target->GetTypeId() == TYPEID_PLAYER) |
|---|
| 3495 | { |
|---|
| 3496 | WorldPacket data(SMSG_FORCE_MOVE_UNROOT, 10); |
|---|
| 3497 | data.append(m_target->GetPackGUID()); |
|---|
| 3498 | data << (uint32)2; |
|---|
| 3499 | m_target->SendMessageToSet(&data,true); |
|---|
| 3500 | } |
|---|
| 3501 | } |
|---|
| 3502 | } |
|---|
| 3503 | } |
|---|
| 3504 | |
|---|
| 3505 | void Aura::HandleAuraModSilence(bool apply, bool Real) |
|---|
| 3506 | { |
|---|
| 3507 | // only at real add/remove aura |
|---|
| 3508 | if(!Real) |
|---|
| 3509 | return; |
|---|
| 3510 | |
|---|
| 3511 | if(apply) |
|---|
| 3512 | { |
|---|
| 3513 | m_target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED); |
|---|
| 3514 | // Stop cast only spells vs PreventionType == SPELL_PREVENTION_TYPE_SILENCE |
|---|
| 3515 | for (uint32 i = CURRENT_MELEE_SPELL; i < CURRENT_MAX_SPELL;i++) |
|---|
| 3516 | { |
|---|
| 3517 | Spell* currentSpell = m_target->m_currentSpells[i]; |
|---|
| 3518 | if (currentSpell && currentSpell->m_spellInfo->PreventionType == SPELL_PREVENTION_TYPE_SILENCE) |
|---|
| 3519 | { |
|---|
| 3520 | uint32 state = currentSpell->getState(); |
|---|
| 3521 | // Stop spells on prepere or casting state |
|---|
| 3522 | if ( state == SPELL_STATE_PREPARING || state == SPELL_STATE_CASTING ) |
|---|
| 3523 | { |
|---|
| 3524 | currentSpell->cancel(); |
|---|
| 3525 | currentSpell->SetDeletable(true); |
|---|
| 3526 | m_target->m_currentSpells[i] = NULL; |
|---|
| 3527 | } |
|---|
| 3528 | } |
|---|
| 3529 | } |
|---|
| 3530 | |
|---|
| 3531 | switch (GetId()) |
|---|
| 3532 | { |
|---|
| 3533 | // Arcane Torrent (Energy) |
|---|
| 3534 | case 25046: |
|---|
| 3535 | { |
|---|
| 3536 | Unit * caster = GetCaster(); |
|---|
| 3537 | if (!caster) |
|---|
| 3538 | return; |
|---|
| 3539 | |
|---|
| 3540 | // Search Mana Tap auras on caster |
|---|
| 3541 | int32 energy = 0; |
|---|
| 3542 | Unit::AuraList const& m_dummyAuras = caster->GetAurasByType(SPELL_AURA_DUMMY); |
|---|
| 3543 | for(Unit::AuraList::const_iterator i = m_dummyAuras.begin(); i != m_dummyAuras.end(); ++i) |
|---|
| 3544 | if ((*i)->GetId() == 28734) |
|---|
| 3545 | ++energy; |
|---|
| 3546 | if (energy) |
|---|
| 3547 | { |
|---|
| 3548 | energy *= 10; |
|---|
| 3549 | caster->CastCustomSpell(caster, 25048, &energy, NULL, NULL, true); |
|---|
| 3550 | caster->RemoveAurasDueToSpell(28734); |
|---|
| 3551 | } |
|---|
| 3552 | } |
|---|
| 3553 | } |
|---|
| 3554 | } |
|---|
| 3555 | else |
|---|
| 3556 | { |
|---|
| 3557 | // Real remove called after current aura remove from lists, check if other similar auras active |
|---|
| 3558 | if(m_target->HasAuraType(SPELL_AURA_MOD_SILENCE)) |
|---|
| 3559 | return; |
|---|
| 3560 | |
|---|
| 3561 | m_target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED); |
|---|
| 3562 | } |
|---|
| 3563 | } |
|---|
| 3564 | |
|---|
| 3565 | void Aura::HandleModThreat(bool apply, bool Real) |
|---|
| 3566 | { |
|---|
| 3567 | // only at real add/remove aura |
|---|
| 3568 | if(!Real) |
|---|
| 3569 | return; |
|---|
| 3570 | |
|---|
| 3571 | if(!m_target->isAlive()) |
|---|
| 3572 | return; |
|---|
| 3573 | |
|---|
| 3574 | Unit* caster = GetCaster(); |
|---|
| 3575 | |
|---|
| 3576 | if(!caster || !caster->isAlive()) |
|---|
| 3577 | return; |
|---|
| 3578 | |
|---|
| 3579 | int level_diff = 0; |
|---|
| 3580 | int multiplier = 0; |
|---|
| 3581 | switch (GetId()) |
|---|
| 3582 | { |
|---|
| 3583 | // Arcane Shroud |
|---|
| 3584 | case 26400: |
|---|
| 3585 | level_diff = m_target->getLevel() - 60; |
|---|
| 3586 | multiplier = 2; |
|---|
| 3587 | break; |
|---|
| 3588 | // The Eye of Diminution |
|---|
| 3589 | case 28862: |
|---|
| 3590 | level_diff = m_target->getLevel() - 60; |
|---|
| 3591 | multiplier = 1; |
|---|
| 3592 | break; |
|---|
| 3593 | } |
|---|
| 3594 | if (level_diff > 0) |
|---|
| 3595 | m_modifier.m_amount += multiplier * level_diff; |
|---|
| 3596 | |
|---|
| 3597 | for(int8 x=0;x < MAX_SPELL_SCHOOL;x++) |
|---|
| 3598 | { |
|---|
| 3599 | if(m_modifier.m_miscvalue & int32(1<<x)) |
|---|
| 3600 | { |
|---|
| 3601 | if(m_target->GetTypeId() == TYPEID_PLAYER) |
|---|
| 3602 | ApplyPercentModFloatVar(m_target->m_threatModifier[x], m_positive ? m_modifier.m_amount : -m_modifier.m_amount, apply); |
|---|
| 3603 | } |
|---|
| 3604 | } |
|---|
| 3605 | } |
|---|
| 3606 | |
|---|
| 3607 | void Aura::HandleAuraModTotalThreat(bool apply, bool Real) |
|---|
| 3608 | { |
|---|
| 3609 | // only at real add/remove aura |
|---|
| 3610 | if(!Real) |
|---|
| 3611 | return; |
|---|
| 3612 | |
|---|
| 3613 | if(!m_target->isAlive() || m_target->GetTypeId()!= TYPEID_PLAYER) |
|---|
| 3614 | return; |
|---|
| 3615 | |
|---|
| 3616 | Unit* caster = GetCaster(); |
|---|
| 3617 | |
|---|
| 3618 | if(!caster || !caster->isAlive()) |
|---|
| 3619 | return; |
|---|
| 3620 | |
|---|
| 3621 | float threatMod = 0.0f; |
|---|
| 3622 | if(apply) |
|---|
| 3623 | threatMod = float(m_modifier.m_amount); |
|---|
| 3624 | else |
|---|
| 3625 | threatMod = float(-m_modifier.m_amount); |
|---|
| 3626 | |
|---|
| 3627 | m_target->getHostilRefManager().threatAssist(caster, threatMod); |
|---|
| 3628 | } |
|---|
| 3629 | |
|---|
| 3630 | void Aura::HandleModTaunt(bool apply, bool Real) |
|---|
| 3631 | { |
|---|
| 3632 | // only at real add/remove aura |
|---|
| 3633 | if(!Real) |
|---|
| 3634 | return; |
|---|
| 3635 | |
|---|
| 3636 | if(!m_target->isAlive() || !m_target->CanHaveThreatList()) |
|---|
| 3637 | return; |
|---|
| 3638 | |
|---|
| 3639 | Unit* caster = GetCaster(); |
|---|
| 3640 | |
|---|
| 3641 | if(!caster || !caster->isAlive() || caster->GetTypeId() != TYPEID_PLAYER) |
|---|
| 3642 | return; |
|---|
| 3643 | |
|---|
| 3644 | if(apply) |
|---|
| 3645 | { |
|---|
| 3646 | m_target->TauntApply(caster); |
|---|
| 3647 | } |
|---|
| 3648 | else |
|---|
| 3649 | { |
|---|
| 3650 | // When taunt aura fades out, mob will switch to previous target if current has less than 1.1 * secondthreat |
|---|
| 3651 | m_target->TauntFadeOut(caster); |
|---|
| 3652 | } |
|---|
| 3653 | } |
|---|
| 3654 | |
|---|
| 3655 | /*********************************************************/ |
|---|
| 3656 | /*** MODIFY SPEED ***/ |
|---|
| 3657 | /*********************************************************/ |
|---|
| 3658 | void Aura::HandleAuraModIncreaseSpeed(bool apply, bool Real) |
|---|
| 3659 | { |
|---|
| 3660 | // all applied/removed only at real aura add/remove |
|---|
| 3661 | if(!Real) |
|---|
| 3662 | return; |
|---|
| 3663 | |
|---|
| 3664 | m_target->UpdateSpeed(MOVE_RUN, true); |
|---|
| 3665 | } |
|---|
| 3666 | |
|---|
| 3667 | void Aura::HandleAuraModIncreaseMountedSpeed(bool apply, bool Real) |
|---|
| 3668 | { |
|---|
| 3669 | // all applied/removed only at real aura add/remove |
|---|
| 3670 | if(!Real) |
|---|
| 3671 | return; |
|---|
| 3672 | |
|---|
| 3673 | m_target->UpdateSpeed(MOVE_RUN, true); |
|---|
| 3674 | } |
|---|
| 3675 | |
|---|
| 3676 | void Aura::HandleAuraModIncreaseFlightSpeed(bool apply, bool Real) |
|---|
| 3677 | { |
|---|
| 3678 | // all applied/removed only at real aura add/remove |
|---|
| 3679 | if(!Real) |
|---|
| 3680 | return; |
|---|
| 3681 | |
|---|
| 3682 | // Enable Fly mode for flying mounts |
|---|
| 3683 | if (m_modifier.m_auraname == SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED) |
|---|
| 3684 | { |
|---|
| 3685 | WorldPacket data; |
|---|
| 3686 | if(apply) |
|---|
| 3687 | data.Initialize(SMSG_MOVE_SET_CAN_FLY, 12); |
|---|
| 3688 | else |
|---|
| 3689 | data.Initialize(SMSG_MOVE_UNSET_CAN_FLY, 12); |
|---|
| 3690 | data.append(m_target->GetPackGUID()); |
|---|
| 3691 | data << uint32(0); // unknown |
|---|
| 3692 | m_target->SendMessageToSet(&data, true); |
|---|
| 3693 | |
|---|
| 3694 | //Players on flying mounts must be immune to polymorph |
|---|
| 3695 | if (m_target->GetTypeId()==TYPEID_PLAYER) |
|---|
| 3696 | m_target->ApplySpellImmune(GetId(),IMMUNITY_MECHANIC,MECHANIC_POLYMORPH,apply); |
|---|
| 3697 | |
|---|
| 3698 | // Dragonmaw Illusion (overwrite mount model, mounted aura already applied) |
|---|
| 3699 | if( apply && m_target->HasAura(42016,0) && m_target->GetMountID()) |
|---|
| 3700 | m_target->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID,16314); |
|---|
| 3701 | } |
|---|
| 3702 | |
|---|
| 3703 | m_target->UpdateSpeed(MOVE_FLY, true); |
|---|
| 3704 | } |
|---|
| 3705 | |
|---|
| 3706 | void Aura::HandleAuraModIncreaseSwimSpeed(bool apply, bool Real) |
|---|
| 3707 | { |
|---|
| 3708 | // all applied/removed only at real aura add/remove |
|---|
| 3709 | if(!Real) |
|---|
| 3710 | return; |
|---|
| 3711 | |
|---|
| 3712 | m_target->UpdateSpeed(MOVE_SWIM, true); |
|---|
| 3713 | } |
|---|
| 3714 | |
|---|
| 3715 | void Aura::HandleAuraModDecreaseSpeed(bool apply, bool Real) |
|---|
| 3716 | { |
|---|
| 3717 | // all applied/removed only at real aura add/remove |
|---|
| 3718 | if(!Real) |
|---|
| 3719 | return; |
|---|
| 3720 | |
|---|
| 3721 | m_target->UpdateSpeed(MOVE_RUN, true); |
|---|
| 3722 | m_target->UpdateSpeed(MOVE_SWIM, true); |
|---|
| 3723 | m_target->UpdateSpeed(MOVE_FLY, true); |
|---|
| 3724 | } |
|---|
| 3725 | |
|---|
| 3726 | void Aura::HandleAuraModUseNormalSpeed(bool apply, bool Real) |
|---|
| 3727 | { |
|---|
| 3728 | // all applied/removed only at real aura add/remove |
|---|
| 3729 | if(!Real) |
|---|
| 3730 | return; |
|---|
| 3731 | |
|---|
| 3732 | m_target->UpdateSpeed(MOVE_RUN, true); |
|---|
| 3733 | m_target->UpdateSpeed(MOVE_SWIM, true); |
|---|
| 3734 | m_target->UpdateSpeed(MOVE_FLY, true); |
|---|
| 3735 | } |
|---|
| 3736 | |
|---|
| 3737 | /*********************************************************/ |
|---|
| 3738 | /*** IMMUNITY ***/ |
|---|
| 3739 | /*********************************************************/ |
|---|
| 3740 | |
|---|
| 3741 | void Aura::HandleModMechanicImmunity(bool apply, bool Real) |
|---|
| 3742 | { |
|---|
| 3743 | uint32 mechanic = 1 << m_modifier.m_miscvalue; |
|---|
| 3744 | |
|---|
| 3745 | //immune movement impairment and loss of control |
|---|
| 3746 | if(GetId()==42292) |
|---|
| 3747 | mechanic=IMMUNE_TO_MOVEMENT_IMPAIRMENT_AND_LOSS_CONTROL_MASK; |
|---|
| 3748 | |
|---|
| 3749 | if(apply && GetSpellProto()->AttributesEx & SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY) |
|---|
| 3750 | { |
|---|
| 3751 | Unit::AuraMap& Auras = m_target->GetAuras(); |
|---|
| 3752 | for(Unit::AuraMap::iterator iter = Auras.begin(), next; iter != Auras.end(); iter = next) |
|---|
| 3753 | { |
|---|
| 3754 | next = iter; |
|---|
| 3755 | ++next; |
|---|
| 3756 | SpellEntry const *spell = iter->second->GetSpellProto(); |
|---|
| 3757 | if (!( spell->Attributes & SPELL_ATTR_UNAFFECTED_BY_INVULNERABILITY) // spells unaffected by invulnerability |
|---|
| 3758 | && !iter->second->IsPositive() // only remove negative spells |
|---|
| 3759 | && spell->Id != GetId()) |
|---|
| 3760 | { |
|---|
| 3761 | //check for mechanic mask |
|---|
| 3762 | if(GetSpellMechanicMask(spell, iter->second->GetEffIndex()) & mechanic) |
|---|
| 3763 | { |
|---|
| 3764 | m_target->RemoveAurasDueToSpell(spell->Id); |
|---|
| 3765 | if(Auras.empty()) |
|---|
| 3766 | break; |
|---|
| 3767 | else |
|---|
| 3768 | next = Auras.begin(); |
|---|
| 3769 | } |
|---|
| 3770 | } |
|---|
| 3771 | } |
|---|
| 3772 | } |
|---|
| 3773 | |
|---|
| 3774 | m_target->ApplySpellImmune(GetId(),IMMUNITY_MECHANIC,m_modifier.m_miscvalue,apply); |
|---|
| 3775 | |
|---|
| 3776 | // special cases |
|---|
| 3777 | switch(m_modifier.m_miscvalue) |
|---|
| 3778 | { |
|---|
| 3779 | case MECHANIC_INVULNERABILITY: |
|---|
| 3780 | m_target->ModifyAuraState(AURA_STATE_FORBEARANCE,apply); |
|---|
| 3781 | break; |
|---|
| 3782 | case MECHANIC_SHIELD: |
|---|
| 3783 | m_target->ModifyAuraState(AURA_STATE_WEAKENED_SOUL,apply); |
|---|
| 3784 | break; |
|---|
| 3785 | } |
|---|
| 3786 | |
|---|
| 3787 | // Bestial Wrath |
|---|
| 3788 | if ( GetSpellProto()->SpellFamilyName == SPELLFAMILY_HUNTER && GetSpellProto()->SpellIconID == 1680) |
|---|
| 3789 | { |
|---|
| 3790 | // The Beast Within cast on owner if talent present |
|---|
| 3791 | if ( Unit* owner = m_target->GetOwner() ) |
|---|
| 3792 | { |
|---|
| 3793 | // Search talent |
|---|
| 3794 | Unit::AuraList const& m_dummyAuras = owner->GetAurasByType(SPELL_AURA_DUMMY); |
|---|
| 3795 | for(Unit::AuraList::const_iterator i = m_dummyAuras.begin(); i != m_dummyAuras.end(); ++i) |
|---|
| 3796 | { |
|---|
| 3797 | if ( (*i)->GetSpellProto()->SpellIconID == 2229 ) |
|---|
| 3798 | { |
|---|
| 3799 | if (apply) |
|---|
| 3800 | owner->CastSpell(owner, 34471, true, 0, this); |
|---|
| 3801 | else |
|---|
| 3802 | owner->RemoveAurasDueToSpell(34471); |
|---|
| 3803 | break; |
|---|
| 3804 | } |
|---|
| 3805 | } |
|---|
| 3806 | } |
|---|
| 3807 | } |
|---|
| 3808 | |
|---|
| 3809 | // The Beast Within and Bestial Wrath - immunity |
|---|
| 3810 | if(GetId() == 19574 || GetId() == 34471) |
|---|
| 3811 | { |
|---|
| 3812 | if(apply) |
|---|
| 3813 | { |
|---|
| 3814 | m_target->CastSpell(m_target,24395,true); |
|---|
| 3815 | m_target->CastSpell(m_target,24396,true); |
|---|
| 3816 | m_target->CastSpell(m_target,24397,true); |
|---|
| 3817 | m_target->CastSpell(m_target,26592,true); |
|---|
| 3818 | } |
|---|
| 3819 | else |
|---|
| 3820 | { |
|---|
| 3821 | m_target->RemoveAurasDueToSpell(24395); |
|---|
| 3822 | m_target->RemoveAurasDueToSpell(24396); |
|---|
| 3823 | m_target->RemoveAurasDueToSpell(24397); |
|---|
| 3824 | m_target->RemoveAurasDueToSpell(26592); |
|---|
| 3825 | } |
|---|
| 3826 | } |
|---|
| 3827 | } |
|---|
| 3828 | |
|---|
| 3829 | void Aura::HandleAuraModEffectImmunity(bool apply, bool Real) |
|---|
| 3830 | { |
|---|
| 3831 | if(!apply) |
|---|
| 3832 | { |
|---|
| 3833 | if(m_target->GetTypeId() == TYPEID_PLAYER) |
|---|
| 3834 | { |
|---|
| 3835 | if(((Player*)m_target)->InBattleGround()) |
|---|
| 3836 | { |
|---|
| 3837 | BattleGround *bg = ((Player*)m_target)->GetBattleGround(); |
|---|
| 3838 | if(bg) |
|---|
| 3839 | { |
|---|
| 3840 | switch(bg->GetTypeID()) |
|---|
| 3841 | { |
|---|
| 3842 | case BATTLEGROUND_AV: |
|---|
| 3843 | { |
|---|
| 3844 | break; |
|---|
| 3845 | } |
|---|
| 3846 | case BATTLEGROUND_WS: |
|---|
| 3847 | { |
|---|
| 3848 | // Warsong Flag, horde // Silverwing Flag, alliance |
|---|
| 3849 | if(GetId() == 23333 || GetId() == 23335) |
|---|
| 3850 | bg->EventPlayerDroppedFlag(((Player*)m_target)); |
|---|
| 3851 | break; |
|---|
| 3852 | } |
|---|
| 3853 | case BATTLEGROUND_AB: |
|---|
| 3854 | { |
|---|
| 3855 | break; |
|---|
| 3856 | } |
|---|
| 3857 | case BATTLEGROUND_EY: |
|---|
| 3858 | { |
|---|
| 3859 | if(GetId() == 34976) |
|---|
| 3860 | bg->EventPlayerDroppedFlag(((Player*)m_target)); |
|---|
| 3861 | break; |
|---|
| 3862 | } |
|---|
| 3863 | } |
|---|
| 3864 | } |
|---|
| 3865 | } |
|---|
| 3866 | else |
|---|
| 3867 | sOutdoorPvPMgr.HandleDropFlag((Player*)m_target,GetSpellProto()->Id); |
|---|
| 3868 | } |
|---|
| 3869 | } |
|---|
| 3870 | |
|---|
| 3871 | m_target->ApplySpellImmune(GetId(),IMMUNITY_EFFECT,m_modifier.m_miscvalue,apply); |
|---|
| 3872 | } |
|---|
| 3873 | |
|---|
| 3874 | void Aura::HandleAuraModStateImmunity(bool apply, bool Real) |
|---|
| 3875 | { |
|---|
| 3876 | if(apply && Real && GetSpellProto()->AttributesEx & SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY) |
|---|
| 3877 | { |
|---|
| 3878 | Unit::AuraList const& auraList = m_target->GetAurasByType(AuraType(m_modifier.m_miscvalue)); |
|---|
| 3879 | for(Unit::AuraList::const_iterator itr = auraList.begin(); itr != auraList.end();) |
|---|
| 3880 | { |
|---|
| 3881 | if (auraList.front() != this) // skip itself aura (it already added) |
|---|
| 3882 | { |
|---|
| 3883 | m_target->RemoveAurasDueToSpell(auraList.front()->GetId()); |
|---|
| 3884 | itr = auraList.begin(); |
|---|
| 3885 | } |
|---|
| 3886 | else |
|---|
| 3887 | ++itr; |
|---|
| 3888 | } |
|---|
| 3889 | } |
|---|
| 3890 | |
|---|
| 3891 | m_target->ApplySpellImmune(GetId(),IMMUNITY_STATE,m_modifier.m_miscvalue,apply); |
|---|
| 3892 | } |
|---|
| 3893 | |
|---|
| 3894 | void Aura::HandleAuraModSchoolImmunity(bool apply, bool Real) |
|---|
| 3895 | { |
|---|
| 3896 | m_target->ApplySpellImmune(GetId(),IMMUNITY_SCHOOL,m_modifier.m_miscvalue,apply); |
|---|
| 3897 | |
|---|
| 3898 | if(Real && apply && GetSpellProto()->AttributesEx & SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY) |
|---|
| 3899 | { |
|---|
| 3900 | if(IsPositiveSpell(GetId())) //Only positive immunity removes auras |
|---|
| 3901 | { |
|---|
| 3902 | uint32 school_mask = m_modifier.m_miscvalue; |
|---|
| 3903 | Unit::AuraMap& Auras = m_target->GetAuras(); |
|---|
| 3904 | for(Unit::AuraMap::iterator iter = Auras.begin(), next; iter != Auras.end(); iter = next) |
|---|
| 3905 | { |
|---|
| 3906 | next = iter; |
|---|
| 3907 | ++next; |
|---|
| 3908 | SpellEntry const *spell = iter->second->GetSpellProto(); |
|---|
| 3909 | if((GetSpellSchoolMask(spell) & school_mask)//Check for school mask |
|---|
| 3910 | && !( spell->Attributes & SPELL_ATTR_UNAFFECTED_BY_INVULNERABILITY) //Spells unaffected by invulnerability |
|---|
| 3911 | && !iter->second->IsPositive() //Don't remove positive spells |
|---|
| 3912 | && spell->Id != GetId() ) //Don't remove self |
|---|
| 3913 | { |
|---|
| 3914 | m_target->RemoveAurasDueToSpell(spell->Id); |
|---|
| 3915 | if(Auras.empty()) |
|---|
| 3916 | break; |
|---|
| 3917 | else |
|---|
| 3918 | next = Auras.begin(); |
|---|
| 3919 | } |
|---|
| 3920 | } |
|---|
| 3921 | } |
|---|
| 3922 | } |
|---|
| 3923 | if( Real && GetSpellProto()->Mechanic == MECHANIC_BANISH ) |
|---|
| 3924 | { |
|---|
| 3925 | if( apply ) |
|---|
| 3926 | m_target->addUnitState(UNIT_STAT_ISOLATED); |
|---|
| 3927 | else |
|---|
| 3928 | m_target->clearUnitState(UNIT_STAT_ISOLATED); |
|---|
| 3929 | } |
|---|
| 3930 | } |
|---|
| 3931 | |
|---|
| 3932 | void Aura::HandleAuraModDmgImmunity(bool apply, bool Real) |
|---|
| 3933 | { |
|---|
| 3934 | m_target->ApplySpellImmune(GetId(),IMMUNITY_DAMAGE,m_modifier.m_miscvalue,apply); |
|---|
| 3935 | } |
|---|
| 3936 | |
|---|
| 3937 | void Aura::HandleAuraModDispelImmunity(bool apply, bool Real) |
|---|
| 3938 | { |
|---|
| 3939 | // all applied/removed only at real aura add/remove |
|---|
| 3940 | if(!Real) |
|---|
| 3941 | return; |
|---|
| 3942 | |
|---|
| 3943 | m_target->ApplySpellDispelImmunity(m_spellProto, DispelType(m_modifier.m_miscvalue), apply); |
|---|
| 3944 | } |
|---|
| 3945 | |
|---|
| 3946 | void Aura::HandleAuraProcTriggerSpell(bool apply, bool Real) |
|---|
| 3947 | { |
|---|
| 3948 | if(!Real) |
|---|
| 3949 | return; |
|---|
| 3950 | |
|---|
| 3951 | if(apply) |
|---|
| 3952 | { |
|---|
| 3953 | // some spell have charges by functionality not have its in spell data |
|---|
| 3954 | switch (GetId()) |
|---|
| 3955 | { |
|---|
| 3956 | case 28200: // Ascendance (Talisman of Ascendance trinket) |
|---|
| 3957 | m_procCharges = 6; |
|---|
| 3958 | UpdateAuraCharges(); |
|---|
| 3959 | break; |
|---|
| 3960 | default: break; |
|---|
| 3961 | } |
|---|
| 3962 | } |
|---|
| 3963 | } |
|---|
| 3964 | |
|---|
| 3965 | void Aura::HandleAuraModStalked(bool apply, bool Real) |
|---|
| 3966 | { |
|---|
| 3967 | // used by spells: Hunter's Mark, Mind Vision, Syndicate Tracker (MURP) DND |
|---|
| 3968 | if(apply) |
|---|
| 3969 | m_target->SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_TRACK_UNIT); |
|---|
| 3970 | else |
|---|
| 3971 | m_target->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_TRACK_UNIT); |
|---|
| 3972 | } |
|---|
| 3973 | |
|---|
| 3974 | /*********************************************************/ |
|---|
| 3975 | /*** PERIODIC ***/ |
|---|
| 3976 | /*********************************************************/ |
|---|
| 3977 | |
|---|
| 3978 | void Aura::HandlePeriodicTriggerSpell(bool apply, bool Real) |
|---|
| 3979 | { |
|---|
| 3980 | if (m_periodicTimer <= 0) |
|---|
| 3981 | m_periodicTimer += m_modifier.periodictime; |
|---|
| 3982 | |
|---|
| 3983 | m_isPeriodic = apply; |
|---|
| 3984 | m_isTrigger = apply; |
|---|
| 3985 | |
|---|
| 3986 | // Curse of the Plaguebringer |
|---|
| 3987 | if (!apply && m_spellProto->Id == 29213 && m_removeMode!=AURA_REMOVE_BY_DISPEL) |
|---|
| 3988 | { |
|---|
| 3989 | // Cast Wrath of the Plaguebringer if not dispelled |
|---|
| 3990 | m_target->CastSpell(m_target, 29214, true, 0, this); |
|---|
| 3991 | } |
|---|
| 3992 | } |
|---|
| 3993 | |
|---|
| 3994 | void Aura::HandlePeriodicEnergize(bool apply, bool Real) |
|---|
| 3995 | { |
|---|
| 3996 | if (m_periodicTimer <= 0) |
|---|
| 3997 | m_periodicTimer += m_modifier.periodictime; |
|---|
| 3998 | |
|---|
| 3999 | m_isPeriodic = apply; |
|---|
| 4000 | } |
|---|
| 4001 | |
|---|
| 4002 | void Aura::HandlePeriodicHeal(bool apply, bool Real) |
|---|
| 4003 | { |
|---|
| 4004 | if (m_periodicTimer <= 0) |
|---|
| 4005 | m_periodicTimer += m_modifier.periodictime; |
|---|
| 4006 | |
|---|
| 4007 | m_isPeriodic = apply; |
|---|
| 4008 | |
|---|
| 4009 | // only at real apply |
|---|
| 4010 | if (Real && apply && GetSpellProto()->Mechanic == MECHANIC_BANDAGE) |
|---|
| 4011 | { |
|---|
| 4012 | // provided m_target as original caster to prevent apply aura caster selection for this negative buff |
|---|
| 4013 | m_target->CastSpell(m_target,11196,true,NULL,this,m_target->GetGUID()); |
|---|
| 4014 | } |
|---|
| 4015 | |
|---|
| 4016 | // For prevent double apply bonuses |
|---|
| 4017 | bool loading = (m_target->GetTypeId() == TYPEID_PLAYER && ((Player*)m_target)->GetSession()->PlayerLoading()); |
|---|
| 4018 | |
|---|
| 4019 | if(!loading && apply) |
|---|
| 4020 | { |
|---|
| 4021 | switch (m_spellProto->SpellFamilyName) |
|---|
| 4022 | { |
|---|
| 4023 | case SPELLFAMILY_DRUID: |
|---|
| 4024 | { |
|---|
| 4025 | // Rejuvenation |
|---|
| 4026 | if(m_spellProto->SpellFamilyFlags & 0x0000000000000010LL) |
|---|
| 4027 | { |
|---|
| 4028 | if(Unit* caster = GetCaster()) |
|---|
| 4029 | { |
|---|
| 4030 | Unit::AuraList const& classScripts = caster->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); |
|---|
| 4031 | for(Unit::AuraList::const_iterator k = classScripts.begin(); k != classScripts.end(); ++k) |
|---|
| 4032 | { |
|---|
| 4033 | int32 tickcount = GetSpellDuration(m_spellProto) / m_spellProto->EffectAmplitude[m_effIndex]; |
|---|
| 4034 | switch((*k)->GetModifier()->m_miscvalue) |
|---|
| 4035 | { |
|---|
| 4036 | case 4953: // Increased Rejuvenation Healing - Harold's Rejuvenating Broach Aura |
|---|
| 4037 | case 4415: // Increased Rejuvenation Healing - Idol of Rejuvenation Aura |
|---|
| 4038 | { |
|---|
| 4039 | m_modifier.m_amount += (*k)->GetModifier()->m_amount / tickcount; |
|---|
| 4040 | break; |
|---|
| 4041 | } |
|---|
| 4042 | } |
|---|
| 4043 | } |
|---|
| 4044 | } |
|---|
| 4045 | } |
|---|
| 4046 | } |
|---|
| 4047 | } |
|---|
| 4048 | } |
|---|
| 4049 | } |
|---|
| 4050 | |
|---|
| 4051 | void Aura::HandlePeriodicDamage(bool apply, bool Real) |
|---|
| 4052 | { |
|---|
| 4053 | // spells required only Real aura add/remove |
|---|
| 4054 | if(!Real) |
|---|
| 4055 | return; |
|---|
| 4056 | |
|---|
| 4057 | if (m_periodicTimer <= 0) |
|---|
| 4058 | m_periodicTimer += m_modifier.periodictime; |
|---|
| 4059 | |
|---|
| 4060 | m_isPeriodic = apply; |
|---|
| 4061 | |
|---|
| 4062 | // For prevent double apply bonuses |
|---|
| 4063 | bool loading = (m_target->GetTypeId() == TYPEID_PLAYER && ((Player*)m_target)->GetSession()->PlayerLoading()); |
|---|
| 4064 | |
|---|
| 4065 | Unit *caster = GetCaster(); |
|---|
| 4066 | |
|---|
| 4067 | switch (m_spellProto->SpellFamilyName) |
|---|
| 4068 | { |
|---|
| 4069 | case SPELLFAMILY_GENERIC: |
|---|
| 4070 | { |
|---|
| 4071 | // Pounce Bleed |
|---|
| 4072 | if ( m_spellProto->SpellIconID == 147 && m_spellProto->SpellVisual == 0 ) |
|---|
| 4073 | { |
|---|
| 4074 | // $AP*0.18/6 bonus per tick |
|---|
| 4075 | if (apply && !loading && caster) |
|---|
| 4076 | m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(BASE_ATTACK) * 3 / 100); |
|---|
| 4077 | return; |
|---|
| 4078 | } |
|---|
| 4079 | break; |
|---|
| 4080 | } |
|---|
| 4081 | case SPELLFAMILY_WARRIOR: |
|---|
| 4082 | { |
|---|
| 4083 | // Rend |
|---|
| 4084 | if (m_spellProto->SpellFamilyFlags & 0x0000000000000020LL) |
|---|
| 4085 | { |
|---|
| 4086 | // 0.00743*(($MWB+$mwb)/2+$AP/14*$MWS) bonus per tick |
|---|
| 4087 | if (apply && !loading && caster) |
|---|
| 4088 | { |
|---|
| 4089 | float ap = caster->GetTotalAttackPowerValue(BASE_ATTACK); |
|---|
| 4090 | int32 mws = caster->GetAttackTime(BASE_ATTACK); |
|---|
| 4091 | float mwb_min = caster->GetWeaponDamageRange(BASE_ATTACK,MINDAMAGE); |
|---|
| 4092 | float mwb_max = caster->GetWeaponDamageRange(BASE_ATTACK,MAXDAMAGE); |
|---|
| 4093 | // WARNING! in 3.0 multipler 0.00743f change to 0.6 |
|---|
| 4094 | m_modifier.m_amount+=int32(((mwb_min+mwb_max)/2+ap*mws/14000)*0.00743f); |
|---|
| 4095 | } |
|---|
| 4096 | return; |
|---|
| 4097 | } |
|---|
| 4098 | break; |
|---|
| 4099 | } |
|---|
| 4100 | case SPELLFAMILY_DRUID: |
|---|
| 4101 | { |
|---|
| 4102 | // Rake |
|---|
| 4103 | if (m_spellProto->SpellFamilyFlags & 0x0000000000001000LL) |
|---|
| 4104 | { |
|---|
| 4105 | // $AP*0.06/3 bonus per tick |
|---|
| 4106 | if (apply && !loading && caster) |
|---|
| 4107 | m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(BASE_ATTACK) * 2 / 100); |
|---|
| 4108 | return; |
|---|
| 4109 | } |
|---|
| 4110 | // Lacerate |
|---|
| 4111 | if (m_spellProto->SpellFamilyFlags & 0x000000010000000000LL) |
|---|
| 4112 | { |
|---|
| 4113 | // $AP*0.05/5 bonus per tick |
|---|
| 4114 | if (apply && !loading && caster) |
|---|
| 4115 | m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(BASE_ATTACK) / 100); |
|---|
| 4116 | return; |
|---|
| 4117 | } |
|---|
| 4118 | // Rip |
|---|
| 4119 | if (m_spellProto->SpellFamilyFlags & 0x000000000000800000LL) |
|---|
| 4120 | { |
|---|
| 4121 | // $AP * min(0.06*$cp, 0.24)/6 [Yes, there is no difference, wheather 4 or 5 CPs are being used] |
|---|
| 4122 | if (apply && !loading && caster && caster->GetTypeId() == TYPEID_PLAYER) |
|---|
| 4123 | { |
|---|
| 4124 | uint8 cp = ((Player*)caster)->GetComboPoints(); |
|---|
| 4125 | |
|---|
| 4126 | // Idol of Feral Shadows. Cant be handled as SpellMod in SpellAura:Dummy due its dependency from CPs |
|---|
| 4127 | Unit::AuraList const& dummyAuras = caster->GetAurasByType(SPELL_AURA_DUMMY); |
|---|
| 4128 | for(Unit::AuraList::const_iterator itr = dummyAuras.begin(); itr != dummyAuras.end(); ++itr) |
|---|
| 4129 | { |
|---|
| 4130 | if((*itr)->GetId()==34241) |
|---|
| 4131 | { |
|---|
| 4132 | m_modifier.m_amount += cp * (*itr)->GetModifier()->m_amount; |
|---|
| 4133 | break; |
|---|
| 4134 | } |
|---|
| 4135 | } |
|---|
| 4136 | |
|---|
| 4137 | if (cp > 4) cp = 4; |
|---|
| 4138 | m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(BASE_ATTACK) * cp / 100); |
|---|
| 4139 | } |
|---|
| 4140 | return; |
|---|
| 4141 | } |
|---|
| 4142 | break; |
|---|
| 4143 | } |
|---|
| 4144 | case SPELLFAMILY_ROGUE: |
|---|
| 4145 | { |
|---|
| 4146 | // Deadly poison aura state |
|---|
| 4147 | if((m_spellProto->SpellFamilyFlags & 0x10000) && m_spellProto->SpellVisual==5100) |
|---|
| 4148 | { |
|---|
| 4149 | if(apply) |
|---|
| 4150 | m_target->ModifyAuraState(AURA_STATE_DEADLY_POISON,true); |
|---|
| 4151 | else |
|---|
| 4152 | { |
|---|
| 4153 | // current aura already removed, search present of another |
|---|
| 4154 | bool found = false; |
|---|
| 4155 | Unit::AuraList const& auras = m_target->GetAurasByType(SPELL_AURA_PERIODIC_DAMAGE); |
|---|
| 4156 | for(Unit::AuraList::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) |
|---|
| 4157 | { |
|---|
| 4158 | SpellEntry const* itr_spell = (*itr)->GetSpellProto(); |
|---|
| 4159 | if(itr_spell && itr_spell->SpellFamilyName==SPELLFAMILY_ROGUE && (itr_spell->SpellFamilyFlags & 0x10000) && itr_spell->SpellVisual==5100) |
|---|
| 4160 | { |
|---|
| 4161 | found = true; |
|---|
| 4162 | break; |
|---|
| 4163 | } |
|---|
| 4164 | } |
|---|
| 4165 | // this has been last deadly poison aura |
|---|
| 4166 | if(!found) |
|---|
| 4167 | m_target->ModifyAuraState(AURA_STATE_DEADLY_POISON,false); |
|---|
| 4168 | } |
|---|
| 4169 | return; |
|---|
| 4170 | } |
|---|
| 4171 | // Rupture |
|---|
| 4172 | if (m_spellProto->SpellFamilyFlags & 0x000000000000100000LL) |
|---|
| 4173 | { |
|---|
| 4174 | // Dmg/tick = $AP*min(0.01*$cp, 0.03) [Like Rip: only the first three CP inrease the contribution from AP] |
|---|
| 4175 | if (apply && !loading && caster && caster->GetTypeId() == TYPEID_PLAYER) |
|---|
| 4176 | { |
|---|
| 4177 | uint8 cp = ((Player*)caster)->GetComboPoints(); |
|---|
| 4178 | if (cp > 3) cp = 3; |
|---|
| 4179 | m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(BASE_ATTACK) * cp / 100); |
|---|
| 4180 | } |
|---|
| 4181 | return; |
|---|
| 4182 | } |
|---|
| 4183 | // Garrote |
|---|
| 4184 | if (m_spellProto->SpellFamilyFlags & 0x000000000000000100LL) |
|---|
| 4185 | { |
|---|
| 4186 | // $AP*0.18/6 bonus per tick |
|---|
| 4187 | if (apply && !loading && caster) |
|---|
| 4188 | m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(BASE_ATTACK) * 3 / 100); |
|---|
| 4189 | return; |
|---|
| 4190 | } |
|---|
| 4191 | break; |
|---|
| 4192 | } |
|---|
| 4193 | case SPELLFAMILY_HUNTER: |
|---|
| 4194 | { |
|---|
| 4195 | // Serpent Sting |
|---|
| 4196 | if (m_spellProto->SpellFamilyFlags & 0x0000000000004000LL) |
|---|
| 4197 | { |
|---|
| 4198 | // $RAP*0.1/5 bonus per tick |
|---|
| 4199 | if (apply && !loading && caster) |
|---|
| 4200 | m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(RANGED_ATTACK) * 10 / 500); |
|---|
| 4201 | return; |
|---|
| 4202 | } |
|---|
| 4203 | // Immolation Trap |
|---|
| 4204 | if (m_spellProto->SpellFamilyFlags & 0x0000000000000004LL && m_spellProto->SpellIconID == 678) |
|---|
| 4205 | { |
|---|
| 4206 | // $RAP*0.1/5 bonus per tick |
|---|
| 4207 | if (apply && !loading && caster) |
|---|
| 4208 | m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(RANGED_ATTACK) * 10 / 500); |
|---|
| 4209 | return; |
|---|
| 4210 | } |
|---|
| 4211 | break; |
|---|
| 4212 | } |
|---|
| 4213 | case SPELLFAMILY_PALADIN: |
|---|
| 4214 | { |
|---|
| 4215 | // Consecration |
|---|
| 4216 | if (m_spellProto->SpellFamilyFlags & 0x0000000000000020LL) |
|---|
| 4217 | { |
|---|
| 4218 | if (apply && !loading) |
|---|
| 4219 | { |
|---|
| 4220 | if(Unit* caster = GetCaster()) |
|---|
| 4221 | { |
|---|
| 4222 | Unit::AuraList const& classScripts = caster->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); |
|---|
| 4223 | for(Unit::AuraList::const_iterator k = classScripts.begin(); k != classScripts.end(); ++k) |
|---|
| 4224 | { |
|---|
| 4225 | int32 tickcount = GetSpellDuration(m_spellProto) / m_spellProto->EffectAmplitude[m_effIndex]; |
|---|
| 4226 | switch((*k)->GetModifier()->m_miscvalue) |
|---|
| 4227 | { |
|---|
| 4228 | case 5147: // Improved Consecration - Libram of the Eternal Rest |
|---|
| 4229 | { |
|---|
| 4230 | m_modifier.m_amount += (*k)->GetModifier()->m_amount / tickcount; |
|---|
| 4231 | break; |
|---|
| 4232 | } |
|---|
| 4233 | } |
|---|
| 4234 | } |
|---|
| 4235 | } |
|---|
| 4236 | } |
|---|
| 4237 | return; |
|---|
| 4238 | } |
|---|
| 4239 | break; |
|---|
| 4240 | } |
|---|
| 4241 | default: |
|---|
| 4242 | break; |
|---|
| 4243 | } |
|---|
| 4244 | } |
|---|
| 4245 | |
|---|
| 4246 | void Aura::HandlePeriodicDamagePCT(bool apply, bool Real) |
|---|
| 4247 | { |
|---|
| 4248 | if (m_periodicTimer <= 0) |
|---|
| 4249 | m_periodicTimer += m_modifier.periodictime; |
|---|
| 4250 | |
|---|
| 4251 | m_isPeriodic = apply; |
|---|
| 4252 | } |
|---|
| 4253 | |
|---|
| 4254 | void Aura::HandlePeriodicLeech(bool apply, bool Real) |
|---|
| 4255 | { |
|---|
| 4256 | if (m_periodicTimer <= 0) |
|---|
| 4257 | m_periodicTimer += m_modifier.periodictime; |
|---|
| 4258 | |
|---|
| 4259 | m_isPeriodic = apply; |
|---|
| 4260 | } |
|---|
| 4261 | |
|---|
| 4262 | void Aura::HandlePeriodicManaLeech(bool apply, bool Real) |
|---|
| 4263 | { |
|---|
| 4264 | if (m_periodicTimer <= 0) |
|---|
| 4265 | m_periodicTimer += m_modifier.periodictime; |
|---|
| 4266 | |
|---|
| 4267 | m_isPeriodic = apply; |
|---|
| 4268 | } |
|---|
| 4269 | |
|---|
| 4270 | /*********************************************************/ |
|---|
| 4271 | /*** MODIFY STATS ***/ |
|---|
| 4272 | /*********************************************************/ |
|---|
| 4273 | |
|---|
| 4274 | /********************************/ |
|---|
| 4275 | /*** RESISTANCE ***/ |
|---|
| 4276 | /********************************/ |
|---|
| 4277 | |
|---|
| 4278 | void Aura::HandleAuraModResistanceExclusive(bool apply, bool Real) |
|---|
| 4279 | { |
|---|
| 4280 | for(int8 x = SPELL_SCHOOL_NORMAL; x < MAX_SPELL_SCHOOL;x++) |
|---|
| 4281 | { |
|---|
| 4282 | if(m_modifier.m_miscvalue & int32(1<<x)) |
|---|
| 4283 | { |
|---|
| 4284 | m_target->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + x), BASE_VALUE, float(m_modifier.m_amount), apply); |
|---|
| 4285 | if(m_target->GetTypeId() == TYPEID_PLAYER) |
|---|
| 4286 | m_target->ApplyResistanceBuffModsMod(SpellSchools(x),m_positive,m_modifier.m_amount, apply); |
|---|
| 4287 | } |
|---|
| 4288 | } |
|---|
| 4289 | } |
|---|
| 4290 | |
|---|
| 4291 | void Aura::HandleAuraModResistance(bool apply, bool Real) |
|---|
| 4292 | { |
|---|
| 4293 | for(int8 x = SPELL_SCHOOL_NORMAL; x < MAX_SPELL_SCHOOL;x++) |
|---|
| 4294 | { |
|---|
| 4295 | if(m_modifier.m_miscvalue & int32(1<<x)) |
|---|
| 4296 | { |
|---|
| 4297 | m_target->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + x), TOTAL_VALUE, float(m_modifier.m_amount), apply); |
|---|
| 4298 | if(m_target->GetTypeId() == TYPEID_PLAYER || ((Creature*)m_target)->isPet()) |
|---|
| 4299 | m_target->ApplyResistanceBuffModsMod(SpellSchools(x),m_positive,m_modifier.m_amount, apply); |
|---|
| 4300 | } |
|---|
| 4301 | } |
|---|
| 4302 | |
|---|
| 4303 | // Faerie Fire (druid versions) |
|---|
| 4304 | if( m_spellProto->SpellIconID == 109 && |
|---|
| 4305 | m_spellProto->SpellFamilyName == SPELLFAMILY_DRUID && |
|---|
| 4306 | m_spellProto->SpellFamilyFlags & 0x0000000000000400LL ) |
|---|
| 4307 | { |
|---|
| 4308 | m_target->ModifyAuraState(AURA_STATE_FAERIE_FIRE,apply); |
|---|
| 4309 | } |
|---|
| 4310 | } |
|---|
| 4311 | |
|---|
| 4312 | void Aura::HandleAuraModBaseResistancePCT(bool apply, bool Real) |
|---|
| 4313 | { |
|---|
| 4314 | // only players have base stats |
|---|
| 4315 | if(m_target->GetTypeId() != TYPEID_PLAYER) |
|---|
| 4316 | { |
|---|
| 4317 | //pets only have base armor |
|---|
| 4318 | if(((Creature*)m_target)->isPet() && (m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_NORMAL)) |
|---|
| 4319 | { |
|---|
| 4320 | m_target->HandleStatModifier(UNIT_MOD_ARMOR, BASE_PCT, float(m_modifier.m_amount), apply); |
|---|
| 4321 | } |
|---|
| 4322 | } |
|---|
| 4323 | else |
|---|
| 4324 | { |
|---|
| 4325 | for(int8 x = SPELL_SCHOOL_NORMAL; x < MAX_SPELL_SCHOOL;x++) |
|---|
| 4326 | { |
|---|
| 4327 | if(m_modifier.m_miscvalue & int32(1<<x)) |
|---|
| 4328 | { |
|---|
| 4329 | m_target->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + x), BASE_PCT, float(m_modifier.m_amount), apply); |
|---|
| 4330 | } |
|---|
| 4331 | } |
|---|
| 4332 | } |
|---|
| 4333 | } |
|---|
| 4334 | |
|---|
| 4335 | void Aura::HandleModResistancePercent(bool apply, bool Real) |
|---|
| 4336 | { |
|---|
| 4337 | for(int8 i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; i++) |
|---|
| 4338 | { |
|---|
| 4339 | if(m_modifier.m_miscvalue & int32(1<<i)) |
|---|
| 4340 | { |
|---|
| 4341 | m_target->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + i), TOTAL_PCT, float(m_modifier.m_amount), apply); |
|---|
| 4342 | if(m_target->GetTypeId() == TYPEID_PLAYER || ((Creature*)m_target)->isPet()) |
|---|
| 4343 | { |
|---|
| 4344 | m_target->ApplyResistanceBuffModsPercentMod(SpellSchools(i),true,m_modifier.m_amount, apply); |
|---|
| 4345 | m_target->ApplyResistanceBuffModsPercentMod(SpellSchools(i),false,m_modifier.m_amount, apply); |
|---|
| 4346 | } |
|---|
| 4347 | } |
|---|
| 4348 | } |
|---|
| 4349 | } |
|---|
| 4350 | |
|---|
| 4351 | void Aura::HandleModBaseResistance(bool apply, bool Real) |
|---|
| 4352 | { |
|---|
| 4353 | // only players have base stats |
|---|
| 4354 | if(m_target->GetTypeId() != TYPEID_PLAYER) |
|---|
| 4355 | { |
|---|
| 4356 | //only pets have base stats |
|---|
| 4357 | if(((Creature*)m_target)->isPet() && (m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_NORMAL)) |
|---|
| 4358 | m_target->HandleStatModifier(UNIT_MOD_ARMOR, TOTAL_VALUE, float(m_modifier.m_amount), apply); |
|---|
| 4359 | } |
|---|
| 4360 | else |
|---|
| 4361 | { |
|---|
| 4362 | for(int i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; i++) |
|---|
| 4363 | if(m_modifier.m_miscvalue & (1<<i)) |
|---|
| 4364 | m_target->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + i), TOTAL_VALUE, float(m_modifier.m_amount), apply); |
|---|
| 4365 | } |
|---|
| 4366 | } |
|---|
| 4367 | |
|---|
| 4368 | /********************************/ |
|---|
| 4369 | /*** STAT ***/ |
|---|
| 4370 | /********************************/ |
|---|
| 4371 | |
|---|
| 4372 | void Aura::HandleAuraModStat(bool apply, bool Real) |
|---|
| 4373 | { |
|---|
| 4374 | if (m_modifier.m_miscvalue < -2 || m_modifier.m_miscvalue > 4) |
|---|
| 4375 | { |
|---|
| 4376 | sLog.outError("WARNING: Spell %u effect %u have unsupported misc value (%i) for SPELL_AURA_MOD_STAT ",GetId(),GetEffIndex(),m_modifier.m_miscvalue); |
|---|
| 4377 | return; |
|---|
| 4378 | } |
|---|
| 4379 | |
|---|
| 4380 | for(int32 i = STAT_STRENGTH; i < MAX_STATS; i++) |
|---|
| 4381 | { |
|---|
| 4382 | // -1 or -2 is all stats ( misc < -2 checked in function beginning ) |
|---|
| 4383 | if (m_modifier.m_miscvalue < 0 || m_modifier.m_miscvalue == i) |
|---|
| 4384 | { |
|---|
| 4385 | //m_target->ApplyStatMod(Stats(i), m_modifier.m_amount,apply); |
|---|
| 4386 | m_target->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START + i), TOTAL_VALUE, float(m_modifier.m_amount), apply); |
|---|
| 4387 | if(m_target->GetTypeId() == TYPEID_PLAYER || ((Creature*)m_target)->isPet()) |
|---|
| 4388 | m_target->ApplyStatBuffMod(Stats(i),m_modifier.m_amount,apply); |
|---|
| 4389 | } |
|---|
| 4390 | } |
|---|
| 4391 | } |
|---|
| 4392 | |
|---|
| 4393 | void Aura::HandleModPercentStat(bool apply, bool Real) |
|---|
| 4394 | { |
|---|
| 4395 | if (m_modifier.m_miscvalue < -1 || m_modifier.m_miscvalue > 4) |
|---|
| 4396 | { |
|---|
| 4397 | sLog.outError("WARNING: Misc Value for SPELL_AURA_MOD_PERCENT_STAT not valid"); |
|---|
| 4398 | return; |
|---|
| 4399 | } |
|---|
| 4400 | |
|---|
| 4401 | // only players have base stats |
|---|
| 4402 | if (m_target->GetTypeId() != TYPEID_PLAYER) |
|---|
| 4403 | return; |
|---|
| 4404 | |
|---|
| 4405 | for (int32 i = STAT_STRENGTH; i < MAX_STATS; ++i) |
|---|
| 4406 | { |
|---|
| 4407 | if(m_modifier.m_miscvalue == i || m_modifier.m_miscvalue == -1) |
|---|
| 4408 | { |
|---|
| 4409 | m_target->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START + i), BASE_PCT, float(m_modifier.m_amount), apply); |
|---|
| 4410 | } |
|---|
| 4411 | } |
|---|
| 4412 | } |
|---|
| 4413 | |
|---|
| 4414 | void Aura::HandleModSpellDamagePercentFromStat(bool apply, bool Real) |
|---|
| 4415 | { |
|---|
| 4416 | if(m_target->GetTypeId() != TYPEID_PLAYER) |
|---|
| 4417 | return; |
|---|
| 4418 | |
|---|
| 4419 | // Magic damage modifiers implemented in Unit::SpellDamageBonus |
|---|
| 4420 | // This information for client side use only |
|---|
| 4421 | // Recalculate bonus |
|---|
| 4422 | ((Player*)m_target)->UpdateSpellDamageAndHealingBonus(); |
|---|
| 4423 | } |
|---|
| 4424 | |
|---|
| 4425 | void Aura::HandleModSpellHealingPercentFromStat(bool apply, bool Real) |
|---|
| 4426 | { |
|---|
| 4427 | if(m_target->GetTypeId() != TYPEID_PLAYER) |
|---|
| 4428 | return; |
|---|
| 4429 | |
|---|
| 4430 | // Recalculate bonus |
|---|
| 4431 | ((Player*)m_target)->UpdateSpellDamageAndHealingBonus(); |
|---|
| 4432 | } |
|---|
| 4433 | |
|---|
| 4434 | void Aura::HandleAuraModDispelResist(bool apply, bool Real) |
|---|
| 4435 | { |
|---|
| 4436 | if(!Real || !apply) |
|---|
| 4437 | return; |
|---|
| 4438 | |
|---|
| 4439 | if(GetId()==33206) |
|---|
| 4440 | m_target->CastSpell(m_target,44416,true,NULL,this,GetCasterGUID()); |
|---|
| 4441 | } |
|---|
| 4442 | |
|---|
| 4443 | void Aura::HandleModSpellDamagePercentFromAttackPower(bool apply, bool Real) |
|---|
| 4444 | { |
|---|
| 4445 | if(m_target->GetTypeId() != TYPEID_PLAYER) |
|---|
| 4446 | return; |
|---|
| 4447 | |
|---|
| 4448 | // Magic damage modifiers implemented in Unit::SpellDamageBonus |
|---|
| 4449 | // This information for client side use only |
|---|
| 4450 | // Recalculate bonus |
|---|
| 4451 | ((Player*)m_target)->UpdateSpellDamageAndHealingBonus(); |
|---|
| 4452 | } |
|---|
| 4453 | |
|---|
| 4454 | void Aura::HandleModSpellHealingPercentFromAttackPower(bool apply, bool Real) |
|---|
| 4455 | { |
|---|
| 4456 | if(m_target->GetTypeId() != TYPEID_PLAYER) |
|---|
| 4457 | return; |
|---|
| 4458 | |
|---|
| 4459 | // Recalculate bonus |
|---|
| 4460 | ((Player*)m_target)->UpdateSpellDamageAndHealingBonus(); |
|---|
| 4461 | } |
|---|
| 4462 | |
|---|
| 4463 | void Aura::HandleModHealingDone(bool apply, bool Real) |
|---|
| 4464 | { |
|---|
| 4465 | if(m_target->GetTypeId() != TYPEID_PLAYER) |
|---|
| 4466 | return; |
|---|
| 4467 | // implemented in Unit::SpellHealingBonus |
|---|
| 4468 | // this information is for client side only |
|---|
| 4469 | ((Player*)m_target)->UpdateSpellDamageAndHealingBonus(); |
|---|
| 4470 | } |
|---|
| 4471 | |
|---|
| 4472 | void Aura::HandleModTotalPercentStat(bool apply, bool Real) |
|---|
| 4473 | { |
|---|
| 4474 | if (m_modifier.m_miscvalue < -1 || m_modifier.m_miscvalue > 4) |
|---|
| 4475 | { |
|---|
| 4476 | sLog.outError("WARNING: Misc Value for SPELL_AURA_MOD_PERCENT_STAT not valid"); |
|---|
| 4477 | return; |
|---|
| 4478 | } |
|---|
| 4479 | |
|---|
| 4480 | //save current and max HP before applying aura |
|---|
| 4481 | uint32 curHPValue = m_target->GetHealth(); |
|---|
| 4482 | uint32 maxHPValue = m_target->GetMaxHealth(); |
|---|
| 4483 | |
|---|
| 4484 | for (int32 i = STAT_STRENGTH; i < MAX_STATS; i++) |
|---|
| 4485 | { |
|---|
| 4486 | if(m_modifier.m_miscvalue == i || m_modifier.m_miscvalue == -1) |
|---|
| 4487 | { |
|---|
| 4488 | m_target->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START + i), TOTAL_PCT, float(m_modifier.m_amount), apply); |
|---|
| 4489 | if(m_target->GetTypeId() == TYPEID_PLAYER || ((Creature*)m_target)->isPet()) |
|---|
| 4490 | m_target->ApplyStatPercentBuffMod(Stats(i), m_modifier.m_amount, apply ); |
|---|
| 4491 | } |
|---|
| 4492 | } |
|---|
| 4493 | |
|---|
| 4494 | //recalculate current HP/MP after applying aura modifications (only for spells with 0x10 flag) |
|---|
| 4495 | if ((m_modifier.m_miscvalue == STAT_STAMINA) && (maxHPValue > 0) && (m_spellProto->Attributes & 0x10)) |
|---|
| 4496 | { |
|---|
| 4497 | // newHP = (curHP / maxHP) * newMaxHP = (newMaxHP * curHP) / maxHP -> which is better because no int -> double -> int conversion is needed |
|---|
| 4498 | uint32 newHPValue = (m_target->GetMaxHealth() * curHPValue) / maxHPValue; |
|---|
| 4499 | m_target->SetHealth(newHPValue); |
|---|
| 4500 | } |
|---|
| 4501 | } |
|---|
| 4502 | |
|---|
| 4503 | void Aura::HandleAuraModResistenceOfStatPercent(bool apply, bool Real) |
|---|
| 4504 | { |
|---|
| 4505 | if(m_target->GetTypeId() != TYPEID_PLAYER) |
|---|
| 4506 | return; |
|---|
| 4507 | |
|---|
| 4508 | if(m_modifier.m_miscvalue != SPELL_SCHOOL_MASK_NORMAL) |
|---|
| 4509 | { |
|---|
| 4510 | // support required adding replace UpdateArmor by loop by UpdateResistence at intelect update |
|---|
| 4511 | // and include in UpdateResistence same code as in UpdateArmor for aura mod apply. |
|---|
| 4512 | sLog.outError("Aura SPELL_AURA_MOD_RESISTANCE_OF_STAT_PERCENT(182) need adding support for non-armor resistences!"); |
|---|
| 4513 | return; |
|---|
| 4514 | } |
|---|
| 4515 | |
|---|
| 4516 | // Recalculate Armor |
|---|
| 4517 | m_target->UpdateArmor(); |
|---|
| 4518 | } |
|---|
| 4519 | |
|---|
| 4520 | /********************************/ |
|---|
| 4521 | /*** HEAL & ENERGIZE ***/ |
|---|
| 4522 | /********************************/ |
|---|
| 4523 | void Aura::HandleAuraModTotalHealthPercentRegen(bool apply, bool Real) |
|---|
| 4524 | { |
|---|
| 4525 | /* |
|---|
| 4526 | Need additional checking for auras who reduce or increase healing, magic effect like Dumpen Magic, |
|---|
| 4527 | so this aura not fully working. |
|---|
| 4528 | */ |
|---|
| 4529 | if(apply) |
|---|
| 4530 | { |
|---|
| 4531 | if(!m_target->isAlive()) |
|---|
| 4532 | return; |
|---|
| 4533 | |
|---|
| 4534 | if((GetSpellProto()->AuraInterruptFlags & AURA_INTERRUPT_FLAG_NOT_SEATED) && !m_target->IsSitState()) |
|---|
| 4535 | m_target->SetStandState(PLAYER_STATE_SIT); |
|---|
| 4536 | |
|---|
| 4537 | if(m_periodicTimer <= 0) |
|---|
| 4538 | { |
|---|
| 4539 | m_periodicTimer += m_modifier.periodictime; |
|---|
| 4540 | |
|---|
| 4541 | if(m_target->GetHealth() < m_target->GetMaxHealth()) |
|---|
| 4542 | { |
|---|
| 4543 | // PeriodicTick can cast triggered spells with stats changes |
|---|
| 4544 | PeriodicTick(); |
|---|
| 4545 | } |
|---|
| 4546 | } |
|---|
| 4547 | } |
|---|
| 4548 | |
|---|
| 4549 | m_isPeriodic = apply; |
|---|
| 4550 | } |
|---|
| 4551 | |
|---|
| 4552 | void Aura::HandleAuraModTotalManaPercentRegen(bool apply, bool Real) |
|---|
| 4553 | { |
|---|
| 4554 | if((GetSpellProto()->AuraInterruptFlags & AURA_INTERRUPT_FLAG_NOT_SEATED) && apply && !m_target->IsSitState()) |
|---|
| 4555 | m_target->SetStandState(PLAYER_STATE_SIT); |
|---|
| 4556 | if(apply) |
|---|
| 4557 | { |
|---|
| 4558 | if(m_modifier.periodictime == 0) |
|---|
| 4559 | m_modifier.periodictime = 1000; |
|---|
| 4560 | if(m_periodicTimer <= 0 && m_target->getPowerType() == POWER_MANA) |
|---|
| 4561 | { |
|---|
| 4562 | m_periodicTimer += m_modifier.periodictime; |
|---|
| 4563 | |
|---|
| 4564 | if(m_target->GetPower(POWER_MANA) < m_target->GetMaxPower(POWER_MANA)) |
|---|
| 4565 | { |
|---|
| 4566 | // PeriodicTick can cast triggered spells with stats changes |
|---|
| 4567 | PeriodicTick(); |
|---|
| 4568 | } |
|---|
| 4569 | } |
|---|
| 4570 | } |
|---|
| 4571 | |
|---|
| 4572 | m_isPeriodic = apply; |
|---|
| 4573 | } |
|---|
| 4574 | |
|---|
| 4575 | void Aura::HandleModRegen(bool apply, bool Real) // eating |
|---|
| 4576 | { |
|---|
| 4577 | if(apply) |
|---|
| 4578 | { |
|---|
| 4579 | if(!m_target->isAlive()) |
|---|
| 4580 | return; |
|---|
| 4581 | |
|---|
| 4582 | if ((GetSpellProto()->AuraInterruptFlags & AURA_INTERRUPT_FLAG_NOT_SEATED) && !m_target->IsSitState()) |
|---|
| 4583 | m_target->SetStandState(PLAYER_STATE_SIT); |
|---|
| 4584 | |
|---|
| 4585 | if(m_periodicTimer <= 0) |
|---|
| 4586 | { |
|---|
| 4587 | m_periodicTimer += 5000; |
|---|
| 4588 | int32 gain = m_target->ModifyHealth(m_modifier.m_amount); |
|---|
| 4589 | Unit *caster = GetCaster(); |
|---|
| 4590 | if (caster) |
|---|
| 4591 | { |
|---|
| 4592 | SpellEntry const *spellProto = GetSpellProto(); |
|---|
| 4593 | if (spellProto) |
|---|
| 4594 | m_target->getHostilRefManager().threatAssist(caster, float(gain) * 0.5f, spellProto); |
|---|
| 4595 | } |
|---|
| 4596 | } |
|---|
| 4597 | } |
|---|
| 4598 | |
|---|
| 4599 | m_isPeriodic = apply; |
|---|
| 4600 | } |
|---|
| 4601 | |
|---|
| 4602 | void Aura::HandleModPowerRegen(bool apply, bool Real) // drinking |
|---|
| 4603 | { |
|---|
| 4604 | if ((GetSpellProto()->AuraInterruptFlags & AURA_INTERRUPT_FLAG_NOT_SEATED) && apply && !m_target->IsSitState()) |
|---|
| 4605 | m_target->SetStandState(PLAYER_STATE_SIT); |
|---|
| 4606 | |
|---|
| 4607 | if(apply && m_periodicTimer <= 0) |
|---|
| 4608 | { |
|---|
| 4609 | m_periodicTimer += 2000; |
|---|
| 4610 | |
|---|
| 4611 | Powers pt = m_target->getPowerType(); |
|---|
| 4612 | if(int32(pt) != m_modifier.m_miscvalue) |
|---|
| 4613 | return; |
|---|
| 4614 | |
|---|
| 4615 | if ( GetSpellProto()->AuraInterruptFlags & AURA_INTERRUPT_FLAG_NOT_SEATED ) |
|---|
| 4616 | { |
|---|
| 4617 | // eating anim |
|---|
| 4618 | m_target->HandleEmoteCommand(EMOTE_ONESHOT_EAT); |
|---|
| 4619 | } |
|---|
| 4620 | else if( GetId() == 20577 ) |
|---|
| 4621 | { |
|---|
| 4622 | // cannibalize anim |
|---|
| 4623 | m_target->HandleEmoteCommand(398); |
|---|
| 4624 | } |
|---|
| 4625 | |
|---|
| 4626 | // Warrior talent, gain 1 rage every 3 seconds while in combat |
|---|
| 4627 | if(pt == POWER_RAGE && m_target->isInCombat()) |
|---|
| 4628 | { |
|---|
| 4629 | m_target->ModifyPower(pt, m_modifier.m_amount*10/17); |
|---|
| 4630 | m_periodicTimer += 1000; |
|---|
| 4631 | } |
|---|
| 4632 | } |
|---|
| 4633 | m_isPeriodic = apply; |
|---|
| 4634 | if (Real && m_target->GetTypeId() == TYPEID_PLAYER && m_modifier.m_miscvalue == POWER_MANA) |
|---|
| 4635 | ((Player*)m_target)->UpdateManaRegen(); |
|---|
| 4636 | } |
|---|
| 4637 | |
|---|
| 4638 | void Aura::HandleModPowerRegenPCT(bool apply, bool Real) |
|---|
| 4639 | { |
|---|
| 4640 | // spells required only Real aura add/remove |
|---|
| 4641 | if(!Real) |
|---|
| 4642 | return; |
|---|
| 4643 | |
|---|
| 4644 | if (m_target->GetTypeId() != TYPEID_PLAYER) |
|---|
| 4645 | return; |
|---|
| 4646 | |
|---|
| 4647 | // Update manaregen value |
|---|
| 4648 | if (m_modifier.m_miscvalue == POWER_MANA) |
|---|
| 4649 | ((Player*)m_target)->UpdateManaRegen(); |
|---|
| 4650 | } |
|---|
| 4651 | |
|---|
| 4652 | void Aura::HandleModManaRegen(bool apply, bool Real) |
|---|
| 4653 | { |
|---|
| 4654 | // spells required only Real aura add/remove |
|---|
| 4655 | if(!Real) |
|---|
| 4656 | return; |
|---|
| 4657 | |
|---|
| 4658 | if (m_target->GetTypeId() != TYPEID_PLAYER) |
|---|
| 4659 | return; |
|---|
| 4660 | |
|---|
| 4661 | //Note: an increase in regen does NOT cause threat. |
|---|
| 4662 | ((Player*)m_target)->UpdateManaRegen(); |
|---|
| 4663 | } |
|---|
| 4664 | |
|---|
| 4665 | void Aura::HandleComprehendLanguage(bool apply, bool Real) |
|---|
| 4666 | { |
|---|
| 4667 | if(apply) |
|---|
| 4668 | m_target->SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_COMPREHEND_LANG); |
|---|
| 4669 | else |
|---|
| 4670 | m_target->RemoveFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_COMPREHEND_LANG); |
|---|
| 4671 | } |
|---|
| 4672 | |
|---|
| 4673 | void Aura::HandleAuraModIncreaseHealth(bool apply, bool Real) |
|---|
| 4674 | { |
|---|
| 4675 | // Special case with temporary increase max/current health |
|---|
| 4676 | switch(GetId()) |
|---|
| 4677 | { |
|---|
| 4678 | case 12976: // Warrior Last Stand triggered spell |
|---|
| 4679 | case 28726: // Nightmare Seed ( Nightmare Seed ) |
|---|
| 4680 | case 34511: // Valor (Bulwark of Kings, Bulwark of the Ancient Kings) |
|---|
| 4681 | case 44055: // Tremendous Fortitude (Battlemaster's Alacrity) |
|---|
| 4682 | { |
|---|
| 4683 | if(Real) |
|---|
| 4684 | { |
|---|
| 4685 | if(apply) |
|---|
| 4686 | { |
|---|
| 4687 | m_target->HandleStatModifier(UNIT_MOD_HEALTH, TOTAL_VALUE, float(m_modifier.m_amount), apply); |
|---|
| 4688 | m_target->ModifyHealth(m_modifier.m_amount); |
|---|
| 4689 | } |
|---|
| 4690 | else |
|---|
| 4691 | { |
|---|
| 4692 | if (int32(m_target->GetHealth()) > m_modifier.m_amount) |
|---|
| 4693 | m_target->ModifyHealth(-m_modifier.m_amount); |
|---|
| 4694 | else |
|---|
| 4695 | m_target->SetHealth(1); |
|---|
| 4696 | m_target->HandleStatModifier(UNIT_MOD_HEALTH, TOTAL_VALUE, float(m_modifier.m_amount), apply); |
|---|
| 4697 | } |
|---|
| 4698 | } |
|---|
| 4699 | return; |
|---|
| 4700 | } |
|---|
| 4701 | } |
|---|
| 4702 | |
|---|
| 4703 | // generic case |
|---|
| 4704 | m_target->HandleStatModifier(UNIT_MOD_HEALTH, TOTAL_VALUE, float(m_modifier.m_amount), apply); |
|---|
| 4705 | } |
|---|
| 4706 | |
|---|
| 4707 | void Aura::HandleAuraModIncreaseMaxHealth(bool apply, bool Real) |
|---|
| 4708 | { |
|---|
| 4709 | uint32 oldhealth = m_target->GetHealth(); |
|---|
| 4710 | double healthPercentage = (double)oldhealth / (double)m_target->GetMaxHealth(); |
|---|
| 4711 | |
|---|
| 4712 | m_target->HandleStatModifier(UNIT_MOD_HEALTH, TOTAL_VALUE, float(m_modifier.m_amount), apply); |
|---|
| 4713 | |
|---|
| 4714 | // refresh percentage |
|---|
| 4715 | if(oldhealth > 0) |
|---|
| 4716 | { |
|---|
| 4717 | uint32 newhealth = uint32(ceil((double)m_target->GetMaxHealth() * healthPercentage)); |
|---|
| 4718 | if(newhealth==0) |
|---|
| 4719 | newhealth = 1; |
|---|
| 4720 | |
|---|
| 4721 | m_target->SetHealth(newhealth); |
|---|
| 4722 | } |
|---|
| 4723 | } |
|---|
| 4724 | |
|---|
| 4725 | void Aura::HandleAuraModIncreaseEnergy(bool apply, bool Real) |
|---|
| 4726 | { |
|---|
| 4727 | Powers powerType = m_target->getPowerType(); |
|---|
| 4728 | if(int32(powerType) != m_modifier.m_miscvalue) |
|---|
| 4729 | return; |
|---|
| 4730 | |
|---|
| 4731 | m_target->HandleStatModifier(UnitMods(UNIT_MOD_POWER_START + powerType), TOTAL_VALUE, float(m_modifier.m_amount), apply); |
|---|
| 4732 | } |
|---|
| 4733 | |
|---|
| 4734 | void Aura::HandleAuraModIncreaseEnergyPercent(bool apply, bool Real) |
|---|
| 4735 | { |
|---|
| 4736 | Powers powerType = m_target->getPowerType(); |
|---|
| 4737 | if(int32(powerType) != m_modifier.m_miscvalue) |
|---|
| 4738 | return; |
|---|
| 4739 | |
|---|
| 4740 | m_target->HandleStatModifier(UnitMods(UNIT_MOD_POWER_START + powerType), TOTAL_PCT, float(m_modifier.m_amount), apply); |
|---|
| 4741 | } |
|---|
| 4742 | |
|---|
| 4743 | void Aura::HandleAuraModIncreaseHealthPercent(bool apply, bool Real) |
|---|
| 4744 | { |
|---|
| 4745 | //m_target->ApplyMaxHealthPercentMod(m_modifier.m_amount,apply); |
|---|
| 4746 | m_target->HandleStatModifier(UNIT_MOD_HEALTH, TOTAL_PCT, float(m_modifier.m_amount), apply); |
|---|
| 4747 | } |
|---|
| 4748 | |
|---|
| 4749 | /********************************/ |
|---|
| 4750 | /*** FIGHT ***/ |
|---|
| 4751 | /********************************/ |
|---|
| 4752 | |
|---|
| 4753 | void Aura::HandleAuraModParryPercent(bool apply, bool Real) |
|---|
| 4754 | { |
|---|
| 4755 | if(m_target->GetTypeId()!=TYPEID_PLAYER) |
|---|
| 4756 | return; |
|---|
| 4757 | |
|---|
| 4758 | ((Player*)m_target)->UpdateParryPercentage(); |
|---|
| 4759 | } |
|---|
| 4760 | |
|---|
| 4761 | void Aura::HandleAuraModDodgePercent(bool apply, bool Real) |
|---|
| 4762 | { |
|---|
| 4763 | if(m_target->GetTypeId()!=TYPEID_PLAYER) |
|---|
| 4764 | return; |
|---|
| 4765 | |
|---|
| 4766 | ((Player*)m_target)->UpdateDodgePercentage(); |
|---|
| 4767 | //sLog.outError("BONUS DODGE CHANCE: + %f", float(m_modifier.m_amount)); |
|---|
| 4768 | } |
|---|
| 4769 | |
|---|
| 4770 | void Aura::HandleAuraModBlockPercent(bool apply, bool Real) |
|---|
| 4771 | { |
|---|
| 4772 | if(m_target->GetTypeId()!=TYPEID_PLAYER) |
|---|
| 4773 | return; |
|---|
| 4774 | |
|---|
| 4775 | ((Player*)m_target)->UpdateBlockPercentage(); |
|---|
| 4776 | //sLog.outError("BONUS BLOCK CHANCE: + %f", float(m_modifier.m_amount)); |
|---|
| 4777 | } |
|---|
| 4778 | |
|---|
| 4779 | void Aura::HandleAuraModRegenInterrupt(bool apply, bool Real) |
|---|
| 4780 | { |
|---|
| 4781 | // spells required only Real aura add/remove |
|---|
| 4782 | if(!Real) |
|---|
| 4783 | return; |
|---|
| 4784 | |
|---|
| 4785 | if(m_target->GetTypeId()!=TYPEID_PLAYER) |
|---|
| 4786 | return; |
|---|
| 4787 | |
|---|
| 4788 | ((Player*)m_target)->UpdateManaRegen(); |
|---|
| 4789 | } |
|---|
| 4790 | |
|---|
| 4791 | void Aura::HandleAuraModCritPercent(bool apply, bool Real) |
|---|
| 4792 | { |
|---|
| 4793 | if(m_target->GetTypeId()!=TYPEID_PLAYER) |
|---|
| 4794 | return; |
|---|
| 4795 | |
|---|
| 4796 | // apply item specific bonuses for already equipped weapon |
|---|
| 4797 | if(Real) |
|---|
| 4798 | { |
|---|
| 4799 | for(int i = 0; i < MAX_ATTACK; ++i) |
|---|
| 4800 | if(Item* pItem = ((Player*)m_target)->GetWeaponForAttack(WeaponAttackType(i))) |
|---|
| 4801 | ((Player*)m_target)->_ApplyWeaponDependentAuraCritMod(pItem,WeaponAttackType(i),this,apply); |
|---|
| 4802 | } |
|---|
| 4803 | |
|---|
| 4804 | // mods must be applied base at equipped weapon class and subclass comparison |
|---|
| 4805 | // with spell->EquippedItemClass and EquippedItemSubClassMask and EquippedItemInventoryTypeMask |
|---|
| 4806 | // m_modifier.m_miscvalue comparison with item generated damage types |
|---|
| 4807 | |
|---|
| 4808 | if (GetSpellProto()->EquippedItemClass == -1) |
|---|
| 4809 | { |
|---|
| 4810 | ((Player*)m_target)->HandleBaseModValue(CRIT_PERCENTAGE, FLAT_MOD, float (m_modifier.m_amount), apply); |
|---|
| 4811 | ((Player*)m_target)->HandleBaseModValue(OFFHAND_CRIT_PERCENTAGE, FLAT_MOD, float (m_modifier.m_amount), apply); |
|---|
| 4812 | ((Player*)m_target)->HandleBaseModValue(RANGED_CRIT_PERCENTAGE, FLAT_MOD, float (m_modifier.m_amount), apply); |
|---|
| 4813 | } |
|---|
| 4814 | else |
|---|
| 4815 | { |
|---|
| 4816 | // done in Player::_ApplyWeaponDependentAuraMods |
|---|
| 4817 | } |
|---|
| 4818 | } |
|---|
| 4819 | |
|---|
| 4820 | void Aura::HandleModHitChance(bool apply, bool Real) |
|---|
| 4821 | { |
|---|
| 4822 | m_target->m_modMeleeHitChance += apply ? m_modifier.m_amount : (-m_modifier.m_amount); |
|---|
| 4823 | m_target->m_modRangedHitChance += apply ? m_modifier.m_amount : (-m_modifier.m_amount); |
|---|
| 4824 | } |
|---|
| 4825 | |
|---|
| 4826 | void Aura::HandleModSpellHitChance(bool apply, bool Real) |
|---|
| 4827 | { |
|---|
| 4828 | m_target->m_modSpellHitChance += apply ? m_modifier.m_amount: (-m_modifier.m_amount); |
|---|
| 4829 | } |
|---|
| 4830 | |
|---|
| 4831 | void Aura::HandleModSpellCritChance(bool apply, bool Real) |
|---|
| 4832 | { |
|---|
| 4833 | // spells required only Real aura add/remove |
|---|
| 4834 | if(!Real) |
|---|
| 4835 | return; |
|---|
| 4836 | |
|---|
| 4837 | if(m_target->GetTypeId() == TYPEID_PLAYER) |
|---|
| 4838 | { |
|---|
| 4839 | ((Player*)m_target)->UpdateAllSpellCritChances(); |
|---|
| 4840 | } |
|---|
| 4841 | else |
|---|
| 4842 | { |
|---|
| 4843 | m_target->m_baseSpellCritChance += apply ? m_modifier.m_amount:(-m_modifier.m_amount); |
|---|
| 4844 | } |
|---|
| 4845 | } |
|---|
| 4846 | |
|---|
| 4847 | void Aura::HandleModSpellCritChanceShool(bool apply, bool Real) |
|---|
| 4848 | { |
|---|
| 4849 | // spells required only Real aura add/remove |
|---|
| 4850 | if(!Real) |
|---|
| 4851 | return; |
|---|
| 4852 | |
|---|
| 4853 | if(m_target->GetTypeId() != TYPEID_PLAYER) |
|---|
| 4854 | return; |
|---|
| 4855 | |
|---|
| 4856 | for(int school = SPELL_SCHOOL_NORMAL; school < MAX_SPELL_SCHOOL; ++school) |
|---|
| 4857 | if (m_modifier.m_miscvalue & (1<<school)) |
|---|
| 4858 | ((Player*)m_target)->UpdateSpellCritChance(school); |
|---|
| 4859 | } |
|---|
| 4860 | |
|---|
| 4861 | /********************************/ |
|---|
| 4862 | /*** ATTACK SPEED ***/ |
|---|
| 4863 | /********************************/ |
|---|
| 4864 | |
|---|
| 4865 | void Aura::HandleModCastingSpeed(bool apply, bool Real) |
|---|
| 4866 | { |
|---|
| 4867 | m_target->ApplyCastTimePercentMod(m_modifier.m_amount,apply); |
|---|
| 4868 | } |
|---|
| 4869 | |
|---|
| 4870 | void Aura::HandleModMeleeRangedSpeedPct(bool apply, bool Real) |
|---|
| 4871 | { |
|---|
| 4872 | m_target->ApplyAttackTimePercentMod(BASE_ATTACK,m_modifier.m_amount,apply); |
|---|
| 4873 | m_target->ApplyAttackTimePercentMod(OFF_ATTACK,m_modifier.m_amount,apply); |
|---|
| 4874 | m_target->ApplyAttackTimePercentMod(RANGED_ATTACK, m_modifier.m_amount, apply); |
|---|
| 4875 | } |
|---|
| 4876 | |
|---|
| 4877 | void Aura::HandleModCombatSpeedPct(bool apply, bool Real) |
|---|
| 4878 | { |
|---|
| 4879 | m_target->ApplyCastTimePercentMod(m_modifier.m_amount,apply); |
|---|
| 4880 | m_target->ApplyAttackTimePercentMod(BASE_ATTACK,m_modifier.m_amount,apply); |
|---|
| 4881 | m_target->ApplyAttackTimePercentMod(OFF_ATTACK,m_modifier.m_amount,apply); |
|---|
| 4882 | m_target->ApplyAttackTimePercentMod(RANGED_ATTACK, m_modifier.m_amount, apply); |
|---|
| 4883 | } |
|---|
| 4884 | |
|---|
| 4885 | void Aura::HandleModAttackSpeed(bool apply, bool Real) |
|---|
| 4886 | { |
|---|
| 4887 | if(!m_target->isAlive() ) |
|---|
| 4888 | return; |
|---|
| 4889 | |
|---|
| 4890 | m_target->ApplyAttackTimePercentMod(BASE_ATTACK,m_modifier.m_amount,apply); |
|---|
| 4891 | } |
|---|
| 4892 | |
|---|
| 4893 | void Aura::HandleHaste(bool apply, bool Real) |
|---|
| 4894 | { |
|---|
| 4895 | m_target->ApplyAttackTimePercentMod(BASE_ATTACK, m_modifier.m_amount,apply); |
|---|
| 4896 | m_target->ApplyAttackTimePercentMod(OFF_ATTACK, m_modifier.m_amount,apply); |
|---|
| 4897 | m_target->ApplyAttackTimePercentMod(RANGED_ATTACK,m_modifier.m_amount,apply); |
|---|
| 4898 | } |
|---|
| 4899 | |
|---|
| 4900 | void Aura::HandleAuraModRangedHaste(bool apply, bool Real) |
|---|
| 4901 | { |
|---|
| 4902 | m_target->ApplyAttackTimePercentMod(RANGED_ATTACK, m_modifier.m_amount, apply); |
|---|
| 4903 | } |
|---|
| 4904 | |
|---|
| 4905 | void Aura::HandleRangedAmmoHaste(bool apply, bool Real) |
|---|
| 4906 | { |
|---|
| 4907 | if(m_target->GetTypeId() != TYPEID_PLAYER) |
|---|
| 4908 | return; |
|---|
| 4909 | m_target->ApplyAttackTimePercentMod(RANGED_ATTACK,m_modifier.m_amount, apply); |
|---|
| 4910 | } |
|---|
| 4911 | |
|---|
| 4912 | /********************************/ |
|---|
| 4913 | /*** ATTACK POWER ***/ |
|---|
| 4914 | /********************************/ |
|---|
| 4915 | |
|---|
| 4916 | void Aura::HandleAuraModAttackPower(bool apply, bool Real) |
|---|
| 4917 | { |
|---|
| 4918 | m_target->HandleStatModifier(UNIT_MOD_ATTACK_POWER, TOTAL_VALUE, float(m_modifier.m_amount), apply); |
|---|
| 4919 | } |
|---|
| 4920 | |
|---|
| 4921 | void Aura::HandleAuraModRangedAttackPower(bool apply, bool Real) |
|---|
| 4922 | { |
|---|
| 4923 | if((m_target->getClassMask() & CLASSMASK_WAND_USERS)!=0) |
|---|
| 4924 | return; |
|---|
| 4925 | |
|---|
| 4926 | m_target->HandleStatModifier(UNIT_MOD_ATTACK_POWER_RANGED, TOTAL_VALUE, float(m_modifier.m_amount), apply); |
|---|
| 4927 | } |
|---|
| 4928 | |
|---|
| 4929 | void Aura::HandleAuraAttackPowerAttacker(bool apply, bool Real) |
|---|
| 4930 | { |
|---|
| 4931 | // spells required only Real aura add/remove |
|---|
| 4932 | if(!Real) |
|---|
| 4933 | return; |
|---|
| 4934 | Unit *caster = GetCaster(); |
|---|
| 4935 | |
|---|
| 4936 | if (!caster) |
|---|
| 4937 | return; |
|---|
| 4938 | |
|---|
| 4939 | // Hunter's Mark |
|---|
| 4940 | if (m_spellProto->SpellFamilyName == SPELLFAMILY_HUNTER && m_spellProto->SpellFamilyFlags & 0x0000000000000400LL) |
|---|
| 4941 | { |
|---|
| 4942 | // Check Improved Hunter's Mark bonus on caster |
|---|
| 4943 | Unit::AuraList const& mOverrideClassScript = caster->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); |
|---|
| 4944 | for(Unit::AuraList::const_iterator i = mOverrideClassScript.begin(); i != mOverrideClassScript.end(); ++i) |
|---|
| 4945 | { |
|---|
| 4946 | Modifier* mod = (*i)->GetModifier(); |
|---|
| 4947 | // mproved Hunter's Mark script from 5236 to 5240 |
|---|
| 4948 | if (mod->m_miscvalue >= 5236 && mod->m_miscvalue <= 5240) |
|---|
| 4949 | { |
|---|
| 4950 | // Get amount of ranged bonus for this spell.. |
|---|
| 4951 | int32 ranged_bonus = caster->CalculateSpellDamage(m_spellProto, 1, m_spellProto->EffectBasePoints[1], m_target); |
|---|
| 4952 | // Set melee attack power bonus % from ranged depends from Improved mask aura |
|---|
| 4953 | m_modifier.m_amount = mod->m_amount * ranged_bonus / 100; |
|---|
| 4954 | m_currentBasePoints = m_modifier.m_amount; |
|---|
| 4955 | break; |
|---|
| 4956 | } |
|---|
| 4957 | } |
|---|
| 4958 | return; |
|---|
| 4959 | } |
|---|
| 4960 | } |
|---|
| 4961 | |
|---|
| 4962 | void Aura::HandleAuraModAttackPowerPercent(bool apply, bool Real) |
|---|
| 4963 | { |
|---|
| 4964 | //UNIT_FIELD_ATTACK_POWER_MULTIPLIER = multiplier - 1 |
|---|
| 4965 | m_target->HandleStatModifier(UNIT_MOD_ATTACK_POWER, TOTAL_PCT, float(m_modifier.m_amount), apply); |
|---|
| 4966 | } |
|---|
| 4967 | |
|---|
| 4968 | void Aura::HandleAuraModRangedAttackPowerPercent(bool apply, bool Real) |
|---|
| 4969 | { |
|---|
| 4970 | if((m_target->getClassMask() & CLASSMASK_WAND_USERS)!=0) |
|---|
| 4971 | return; |
|---|
| 4972 | |
|---|
| 4973 | //UNIT_FIELD_RANGED_ATTACK_POWER_MULTIPLIER = multiplier - 1 |
|---|
| 4974 | m_target->HandleStatModifier(UNIT_MOD_ATTACK_POWER_RANGED, TOTAL_PCT, float(m_modifier.m_amount), apply); |
|---|
| 4975 | } |
|---|
| 4976 | |
|---|
| 4977 | void Aura::HandleAuraModRangedAttackPowerOfStatPercent(bool apply, bool Real) |
|---|
| 4978 | { |
|---|
| 4979 | // spells required only Real aura add/remove |
|---|
| 4980 | if(!Real) |
|---|
| 4981 | return; |
|---|
| 4982 | |
|---|
| 4983 | if(m_target->GetTypeId() == TYPEID_PLAYER && (m_target->getClassMask() & CLASSMASK_WAND_USERS)!=0) |
|---|
| 4984 | return; |
|---|
| 4985 | |
|---|
| 4986 | if(m_modifier.m_miscvalue != STAT_INTELLECT) |
|---|
| 4987 | { |
|---|
| 4988 | // support required adding UpdateAttackPowerAndDamage calls at stat update |
|---|
| 4989 | sLog.outError("Aura SPELL_AURA_MOD_RANGED_ATTACK_POWER_OF_STAT_PERCENT (212) need support non-intelect stats!"); |
|---|
| 4990 | return; |
|---|
| 4991 | } |
|---|
| 4992 | |
|---|
| 4993 | // Recalculate bonus |
|---|
| 4994 | ((Player*)m_target)->UpdateAttackPowerAndDamage(true); |
|---|
| 4995 | } |
|---|
| 4996 | |
|---|
| 4997 | /********************************/ |
|---|
| 4998 | /*** DAMAGE BONUS ***/ |
|---|
| 4999 | /********************************/ |
|---|
| 5000 | void Aura::HandleModDamageDone(bool apply, bool Real) |
|---|
| 5001 | { |
|---|
| 5002 | // apply item specific bonuses for already equipped weapon |
|---|
| 5003 | if(Real && m_target->GetTypeId()==TYPEID_PLAYER) |
|---|
| 5004 | { |
|---|
| 5005 | for(int i = 0; i < MAX_ATTACK; ++i) |
|---|
| 5006 | if(Item* pItem = ((Player*)m_target)->GetWeaponForAttack(WeaponAttackType(i))) |
|---|
| 5007 | ((Player*)m_target)->_ApplyWeaponDependentAuraDamageMod(pItem,WeaponAttackType(i),this,apply); |
|---|
| 5008 | } |
|---|
| 5009 | |
|---|
| 5010 | // m_modifier.m_miscvalue is bitmask of spell schools |
|---|
| 5011 | // 1 ( 0-bit ) - normal school damage (SPELL_SCHOOL_MASK_NORMAL) |
|---|
| 5012 | // 126 - full bitmask all magic damages (SPELL_SCHOOL_MASK_MAGIC) including wands |
|---|
| 5013 | // 127 - full bitmask any damages |
|---|
| 5014 | // |
|---|
| 5015 | // mods must be applied base at equipped weapon class and subclass comparison |
|---|
| 5016 | // with spell->EquippedItemClass and EquippedItemSubClassMask and EquippedItemInventoryTypeMask |
|---|
| 5017 | // m_modifier.m_miscvalue comparison with item generated damage types |
|---|
| 5018 | |
|---|
| 5019 | if((m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_NORMAL) != 0) |
|---|
| 5020 | { |
|---|
| 5021 | // apply generic physical damage bonuses including wand case |
|---|
| 5022 | if (GetSpellProto()->EquippedItemClass == -1 || m_target->GetTypeId() != TYPEID_PLAYER) |
|---|
| 5023 | { |
|---|
| 5024 | m_target->HandleStatModifier(UNIT_MOD_DAMAGE_MAINHAND, TOTAL_VALUE, float(m_modifier.m_amount), apply); |
|---|
| 5025 | m_target->HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND, TOTAL_VALUE, float(m_modifier.m_amount), apply); |
|---|
| 5026 | m_target->HandleStatModifier(UNIT_MOD_DAMAGE_RANGED, TOTAL_VALUE, float(m_modifier.m_amount), apply); |
|---|
| 5027 | } |
|---|
| 5028 | else |
|---|
| 5029 | { |
|---|
| 5030 | // done in Player::_ApplyWeaponDependentAuraMods |
|---|
| 5031 | } |
|---|
| 5032 | |
|---|
| 5033 | if(m_target->GetTypeId() == TYPEID_PLAYER) |
|---|
| 5034 | { |
|---|
| 5035 | if(m_positive) |
|---|
| 5036 | m_target->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS,m_modifier.m_amount,apply); |
|---|
| 5037 | else |
|---|
| 5038 | m_target->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG,m_modifier.m_amount,apply); |
|---|
| 5039 | } |
|---|
| 5040 | } |
|---|
| 5041 | |
|---|
| 5042 | // Skip non magic case for speedup |
|---|
| 5043 | if((m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_MAGIC) == 0) |
|---|
| 5044 | return; |
|---|
| 5045 | |
|---|
| 5046 | if( GetSpellProto()->EquippedItemClass != -1 || GetSpellProto()->EquippedItemInventoryTypeMask != 0 ) |
|---|
| 5047 | { |
|---|
| 5048 | // wand magic case (skip generic to all item spell bonuses) |
|---|
| 5049 | // done in Player::_ApplyWeaponDependentAuraMods |
|---|
| 5050 | |
|---|
| 5051 | // Skip item specific requirements for not wand magic damage |
|---|
| 5052 | return; |
|---|
| 5053 | } |
|---|
| 5054 | |
|---|
| 5055 | // Magic damage modifiers implemented in Unit::SpellDamageBonus |
|---|
| 5056 | // This information for client side use only |
|---|
| 5057 | if(m_target->GetTypeId() == TYPEID_PLAYER) |
|---|
| 5058 | { |
|---|
| 5059 | if(m_positive) |
|---|
| 5060 | { |
|---|
| 5061 | for(int i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; i++) |
|---|
| 5062 | { |
|---|
| 5063 | if((m_modifier.m_miscvalue & (1<<i)) != 0) |
|---|
| 5064 | m_target->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS+i,m_modifier.m_amount,apply); |
|---|
| 5065 | } |
|---|
| 5066 | } |
|---|
| 5067 | else |
|---|
| 5068 | { |
|---|
| 5069 | for(int i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; i++) |
|---|
| 5070 | { |
|---|
| 5071 | if((m_modifier.m_miscvalue & (1<<i)) != 0) |
|---|
| 5072 | m_target->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG+i,m_modifier.m_amount,apply); |
|---|
| 5073 | } |
|---|
| 5074 | } |
|---|
| 5075 | Pet* pet = m_target->GetPet(); |
|---|
| 5076 | if(pet) |
|---|
| 5077 | pet->UpdateAttackPowerAndDamage(); |
|---|
| 5078 | } |
|---|
| 5079 | } |
|---|
| 5080 | |
|---|
| 5081 | void Aura::HandleModDamagePercentDone(bool apply, bool Real) |
|---|
| 5082 | { |
|---|
| 5083 | sLog.outDebug("AURA MOD DAMAGE type:%u negative:%u", m_modifier.m_miscvalue, m_positive ? 0 : 1); |
|---|
| 5084 | |
|---|
| 5085 | // apply item specific bonuses for already equipped weapon |
|---|
| 5086 | if(Real && m_target->GetTypeId()==TYPEID_PLAYER) |
|---|
| 5087 | { |
|---|
| 5088 | for(int i = 0; i < MAX_ATTACK; ++i) |
|---|
| 5089 | if(Item* pItem = ((Player*)m_target)->GetWeaponForAttack(WeaponAttackType(i))) |
|---|
| 5090 | ((Player*)m_target)->_ApplyWeaponDependentAuraDamageMod(pItem,WeaponAttackType(i),this,apply); |
|---|
| 5091 | } |
|---|
| 5092 | |
|---|
| 5093 | // m_modifier.m_miscvalue is bitmask of spell schools |
|---|
| 5094 | // 1 ( 0-bit ) - normal school damage (SPELL_SCHOOL_MASK_NORMAL) |
|---|
| 5095 | // 126 - full bitmask all magic damages (SPELL_SCHOOL_MASK_MAGIC) including wand |
|---|
| 5096 | // 127 - full bitmask any damages |
|---|
| 5097 | // |
|---|
| 5098 | // mods must be applied base at equipped weapon class and subclass comparison |
|---|
| 5099 | // with spell->EquippedItemClass and EquippedItemSubClassMask and EquippedItemInventoryTypeMask |
|---|
| 5100 | // m_modifier.m_miscvalue comparison with item generated damage types |
|---|
| 5101 | |
|---|
| 5102 | if((m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_NORMAL) != 0) |
|---|
| 5103 | { |
|---|
| 5104 | // apply generic physical damage bonuses including wand case |
|---|
| 5105 | if (GetSpellProto()->EquippedItemClass == -1 || m_target->GetTypeId() != TYPEID_PLAYER) |
|---|
| 5106 | { |
|---|
| 5107 | m_target->HandleStatModifier(UNIT_MOD_DAMAGE_MAINHAND, TOTAL_PCT, float(m_modifier.m_amount), apply); |
|---|
| 5108 | m_target->HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND, TOTAL_PCT, float(m_modifier.m_amount), apply); |
|---|
| 5109 | m_target->HandleStatModifier(UNIT_MOD_DAMAGE_RANGED, TOTAL_PCT, float(m_modifier.m_amount), apply); |
|---|
| 5110 | } |
|---|
| 5111 | else |
|---|
| 5112 | { |
|---|
| 5113 | // done in Player::_ApplyWeaponDependentAuraMods |
|---|
| 5114 | } |
|---|
| 5115 | // For show in client |
|---|
| 5116 | if(m_target->GetTypeId() == TYPEID_PLAYER) |
|---|
| 5117 | m_target->ApplyModSignedFloatValue(PLAYER_FIELD_MOD_DAMAGE_DONE_PCT,m_modifier.m_amount/100.0f,apply); |
|---|
| 5118 | } |
|---|
| 5119 | |
|---|
| 5120 | // Skip non magic case for speedup |
|---|
| 5121 | if((m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_MAGIC) == 0) |
|---|
| 5122 | return; |
|---|
| 5123 | |
|---|
| 5124 | if( GetSpellProto()->EquippedItemClass != -1 || GetSpellProto()->EquippedItemInventoryTypeMask != 0 ) |
|---|
| 5125 | { |
|---|
| 5126 | // wand magic case (skip generic to all item spell bonuses) |
|---|
| 5127 | // done in Player::_ApplyWeaponDependentAuraMods |
|---|
| 5128 | |
|---|
| 5129 | // Skip item specific requirements for not wand magic damage |
|---|
| 5130 | return; |
|---|
| 5131 | } |
|---|
| 5132 | |
|---|
| 5133 | // Magic damage percent modifiers implemented in Unit::SpellDamageBonus |
|---|
| 5134 | // Send info to client |
|---|
| 5135 | if(m_target->GetTypeId() == TYPEID_PLAYER) |
|---|
| 5136 | for(int i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i) |
|---|
| 5137 | m_target->ApplyModSignedFloatValue(PLAYER_FIELD_MOD_DAMAGE_DONE_PCT+i,m_modifier.m_amount/100.0f,apply); |
|---|
| 5138 | } |
|---|
| 5139 | |
|---|
| 5140 | void Aura::HandleModOffhandDamagePercent(bool apply, bool Real) |
|---|
| 5141 | { |
|---|
| 5142 | // spells required only Real aura add/remove |
|---|
| 5143 | if(!Real) |
|---|
| 5144 | return; |
|---|
| 5145 | |
|---|
| 5146 | sLog.outDebug("AURA MOD OFFHAND DAMAGE"); |
|---|
| 5147 | |
|---|
| 5148 | m_target->HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND, TOTAL_PCT, float(m_modifier.m_amount), apply); |
|---|
| 5149 | } |
|---|
| 5150 | |
|---|
| 5151 | /********************************/ |
|---|
| 5152 | /*** POWER COST ***/ |
|---|
| 5153 | /********************************/ |
|---|
| 5154 | |
|---|
| 5155 | void Aura::HandleModPowerCostPCT(bool apply, bool Real) |
|---|
| 5156 | { |
|---|
| 5157 | // spells required only Real aura add/remove |
|---|
| 5158 | if(!Real) |
|---|
| 5159 | return; |
|---|
| 5160 | |
|---|
| 5161 | float amount = m_modifier.m_amount/100.0f; |
|---|
| 5162 | for(int i = 0; i < MAX_SPELL_SCHOOL; ++i) |
|---|
| 5163 | if(m_modifier.m_miscvalue & (1<<i)) |
|---|
| 5164 | m_target->ApplyModSignedFloatValue(UNIT_FIELD_POWER_COST_MULTIPLIER+i,amount,apply); |
|---|
| 5165 | } |
|---|
| 5166 | |
|---|
| 5167 | void Aura::HandleModPowerCost(bool apply, bool Real) |
|---|
| 5168 | { |
|---|
| 5169 | // spells required only Real aura add/remove |
|---|
| 5170 | if(!Real) |
|---|
| 5171 | return; |
|---|
| 5172 | |
|---|
| 5173 | for(int i = 0; i < MAX_SPELL_SCHOOL; ++i) |
|---|
| 5174 | if(m_modifier.m_miscvalue & (1<<i)) |
|---|
| 5175 | m_target->ApplyModInt32Value(UNIT_FIELD_POWER_COST_MODIFIER+i,m_modifier.m_amount,apply); |
|---|
| 5176 | } |
|---|
| 5177 | |
|---|
| 5178 | /*********************************************************/ |
|---|
| 5179 | /*** OTHERS ***/ |
|---|
| 5180 | /*********************************************************/ |
|---|
| 5181 | |
|---|
| 5182 | void Aura::HandleShapeshiftBoosts(bool apply) |
|---|
| 5183 | { |
|---|
| 5184 | uint32 spellId = 0; |
|---|
| 5185 | uint32 spellId2 = 0; |
|---|
| 5186 | uint32 HotWSpellId = 0; |
|---|
| 5187 | |
|---|
| 5188 | switch(GetModifier()->m_miscvalue) |
|---|
| 5189 | { |
|---|
| 5190 | case FORM_CAT: |
|---|
| 5191 | spellId = 3025; |
|---|
| 5192 | HotWSpellId = 24900; |
|---|
| 5193 | break; |
|---|
| 5194 | case FORM_TREE: |
|---|
| 5195 | spellId = 5420; |
|---|
| 5196 | break; |
|---|
| 5197 | case FORM_TRAVEL: |
|---|
| 5198 | spellId = 5419; |
|---|
| 5199 | break; |
|---|
| 5200 | case FORM_AQUA: |
|---|
| 5201 | spellId = 5421; |
|---|
| 5202 | break; |
|---|
| 5203 | case FORM_BEAR: |
|---|
| 5204 | spellId = 1178; |
|---|
| 5205 | spellId2 = 21178; |
|---|
| 5206 | HotWSpellId = 24899; |
|---|
| 5207 | break; |
|---|
| 5208 | case FORM_DIREBEAR: |
|---|
| 5209 | spellId = 9635; |
|---|
| 5210 | spellId2 = 21178; |
|---|
| 5211 | HotWSpellId = 24899; |
|---|
| 5212 | break; |
|---|
| 5213 | case FORM_BATTLESTANCE: |
|---|
| 5214 | spellId = 21156; |
|---|
| 5215 | break; |
|---|
| 5216 | case FORM_DEFENSIVESTANCE: |
|---|
| 5217 | spellId = 7376; |
|---|
| 5218 | break; |
|---|
| 5219 | case FORM_BERSERKERSTANCE: |
|---|
| 5220 | spellId = 7381; |
|---|
| 5221 | break; |
|---|
| 5222 | case FORM_MOONKIN: |
|---|
| 5223 | spellId = 24905; |
|---|
| 5224 | // aura from effect trigger spell |
|---|
| 5225 | spellId2 = 24907; |
|---|
| 5226 | break; |
|---|
| 5227 | case FORM_FLIGHT: |
|---|
| 5228 | spellId = 33948; |
|---|
| 5229 | break; |
|---|
| 5230 | case FORM_FLIGHT_EPIC: |
|---|
| 5231 | spellId = 40122; |
|---|
| 5232 | spellId2 = 40121; |
|---|
| 5233 | break; |
|---|
| 5234 | case FORM_SPIRITOFREDEMPTION: |
|---|
| 5235 | spellId = 27792; |
|---|
| 5236 | spellId2 = 27795; // must be second, this important at aura remove to prevent to early iterator invalidation. |
|---|
| 5237 | break; |
|---|
| 5238 | case FORM_GHOSTWOLF: |
|---|
| 5239 | case FORM_AMBIENT: |
|---|
| 5240 | case FORM_GHOUL: |
|---|
| 5241 | case FORM_SHADOW: |
|---|
| 5242 | case FORM_STEALTH: |
|---|
| 5243 | case FORM_CREATURECAT: |
|---|
| 5244 | case FORM_CREATUREBEAR: |
|---|
| 5245 | spellId = 0; |
|---|
| 5246 | break; |
|---|
| 5247 | } |
|---|
| 5248 | |
|---|
| 5249 | uint32 form = GetModifier()->m_miscvalue-1; |
|---|
| 5250 | |
|---|
| 5251 | if(apply) |
|---|
| 5252 | { |
|---|
| 5253 | if (spellId) m_target->CastSpell(m_target, spellId, true, NULL, this ); |
|---|
| 5254 | if (spellId2) m_target->CastSpell(m_target, spellId2, true, NULL, this); |
|---|
| 5255 | |
|---|
| 5256 | if(m_target->GetTypeId() == TYPEID_PLAYER) |
|---|
| 5257 | { |
|---|
| 5258 | const PlayerSpellMap& sp_list = ((Player *)m_target)->GetSpellMap(); |
|---|
| 5259 | for (PlayerSpellMap::const_iterator itr = sp_list.begin(); itr != sp_list.end(); ++itr) |
|---|
| 5260 | { |
|---|
| 5261 | if(itr->second->state == PLAYERSPELL_REMOVED) continue; |
|---|
| 5262 | if(itr->first==spellId || itr->first==spellId2) continue; |
|---|
| 5263 | SpellEntry const *spellInfo = sSpellStore.LookupEntry(itr->first); |
|---|
| 5264 | if (!spellInfo || !(spellInfo->Attributes & ((1<<6) | (1<<7)))) continue; |
|---|
| 5265 | if (spellInfo->Stances & (1<<form)) |
|---|
| 5266 | m_target->CastSpell(m_target, itr->first, true, NULL, this); |
|---|
| 5267 | } |
|---|
| 5268 | //LotP |
|---|
| 5269 | if (((Player*)m_target)->HasSpell(17007)) |
|---|
| 5270 | { |
|---|
| 5271 | SpellEntry const *spellInfo = sSpellStore.LookupEntry(24932); |
|---|
| 5272 | if (spellInfo && spellInfo->Stances & (1<<form)) |
|---|
| 5273 | m_target->CastSpell(m_target, 24932, true, NULL, this); |
|---|
| 5274 | } |
|---|
| 5275 | // HotW |
|---|
| 5276 | if (HotWSpellId) |
|---|
| 5277 | { |
|---|
| 5278 | Unit::AuraList const& mModTotalStatPct = m_target->GetAurasByType(SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE); |
|---|
| 5279 | for(Unit::AuraList::const_iterator i = mModTotalStatPct.begin(); i != mModTotalStatPct.end(); ++i) |
|---|
| 5280 | { |
|---|
| 5281 | if ((*i)->GetSpellProto()->SpellIconID == 240 && (*i)->GetModifier()->m_miscvalue == 3) |
|---|
| 5282 | { |
|---|
| 5283 | int32 HotWMod = (*i)->GetModifier()->m_amount; |
|---|
| 5284 | if(GetModifier()->m_miscvalue == FORM_CAT) |
|---|
| 5285 | HotWMod /= 2; |
|---|
| 5286 | |
|---|
| 5287 | m_target->CastCustomSpell(m_target, HotWSpellId, &HotWMod, NULL, NULL, true, NULL, this); |
|---|
| 5288 | break; |
|---|
| 5289 | } |
|---|
| 5290 | } |
|---|
| 5291 | } |
|---|
| 5292 | } |
|---|
| 5293 | } |
|---|
| 5294 | else |
|---|
| 5295 | { |
|---|
| 5296 | m_target->RemoveAurasDueToSpell(spellId); |
|---|
| 5297 | m_target->RemoveAurasDueToSpell(spellId2); |
|---|
| 5298 | |
|---|
| 5299 | Unit::AuraMap& tAuras = m_target->GetAuras(); |
|---|
| 5300 | for (Unit::AuraMap::iterator itr = tAuras.begin(); itr != tAuras.end();) |
|---|
| 5301 | { |
|---|
| 5302 | if (itr->second->IsRemovedOnShapeLost()) |
|---|
| 5303 | { |
|---|
| 5304 | m_target->RemoveAurasDueToSpell(itr->second->GetId()); |
|---|
| 5305 | itr = tAuras.begin(); |
|---|
| 5306 | } |
|---|
| 5307 | else |
|---|
| 5308 | { |
|---|
| 5309 | ++itr; |
|---|
| 5310 | } |
|---|
| 5311 | } |
|---|
| 5312 | } |
|---|
| 5313 | |
|---|
| 5314 | /*double healthPercentage = (double)m_target->GetHealth() / (double)m_target->GetMaxHealth(); |
|---|
| 5315 | m_target->SetHealth(uint32(ceil((double)m_target->GetMaxHealth() * healthPercentage)));*/ |
|---|
| 5316 | } |
|---|
| 5317 | |
|---|
| 5318 | void Aura::HandleAuraEmpathy(bool apply, bool Real) |
|---|
| 5319 | { |
|---|
| 5320 | if(m_target->GetTypeId() != TYPEID_UNIT) |
|---|
| 5321 | return; |
|---|
| 5322 | |
|---|
| 5323 | CreatureInfo const * ci = objmgr.GetCreatureTemplate(m_target->GetEntry()); |
|---|
| 5324 | if(ci && ci->type == CREATURE_TYPE_BEAST) |
|---|
| 5325 | { |
|---|
| 5326 | m_target->ApplyModUInt32Value(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_SPECIALINFO, apply); |
|---|
| 5327 | } |
|---|
| 5328 | } |
|---|
| 5329 | |
|---|
| 5330 | void Aura::HandleAuraUntrackable(bool apply, bool Real) |
|---|
| 5331 | { |
|---|
| 5332 | if(apply) |
|---|
| 5333 | m_target->SetFlag(UNIT_FIELD_BYTES_1, PLAYER_STATE_FLAG_UNTRACKABLE); |
|---|
| 5334 | else |
|---|
| 5335 | m_target->RemoveFlag(UNIT_FIELD_BYTES_1, PLAYER_STATE_FLAG_UNTRACKABLE); |
|---|
| 5336 | } |
|---|
| 5337 | |
|---|
| 5338 | void Aura::HandleAuraModPacify(bool apply, bool Real) |
|---|
| 5339 | { |
|---|
| 5340 | if(m_target->GetTypeId() != TYPEID_PLAYER) |
|---|
| 5341 | return; |
|---|
| 5342 | |
|---|
| 5343 | if(apply) |
|---|
| 5344 | m_target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED); |
|---|
| 5345 | else |
|---|
| 5346 | m_target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED); |
|---|
| 5347 | } |
|---|
| 5348 | |
|---|
| 5349 | void Aura::HandleAuraModPacifyAndSilence(bool apply, bool Real) |
|---|
| 5350 | { |
|---|
| 5351 | HandleAuraModPacify(apply,Real); |
|---|
| 5352 | HandleAuraModSilence(apply,Real); |
|---|
| 5353 | } |
|---|
| 5354 | |
|---|
| 5355 | void Aura::HandleAuraGhost(bool apply, bool Real) |
|---|
| 5356 | { |
|---|
| 5357 | if(m_target->GetTypeId() != TYPEID_PLAYER) |
|---|
| 5358 | return; |
|---|
| 5359 | |
|---|
| 5360 | if(apply) |
|---|
| 5361 | { |
|---|
| 5362 | m_target->SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST); |
|---|
| 5363 | } |
|---|
| 5364 | else |
|---|
| 5365 | { |
|---|
| 5366 | m_target->RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST); |
|---|
| 5367 | } |
|---|
| 5368 | } |
|---|
| 5369 | |
|---|
| 5370 | void Aura::HandleAuraAllowFlight(bool apply, bool Real) |
|---|
| 5371 | { |
|---|
| 5372 | // all applied/removed only at real aura add/remove |
|---|
| 5373 | if(!Real) |
|---|
| 5374 | return; |
|---|
| 5375 | |
|---|
| 5376 | // allow fly |
|---|
| 5377 | WorldPacket data; |
|---|
| 5378 | if(apply) |
|---|
| 5379 | data.Initialize(SMSG_MOVE_SET_CAN_FLY, 12); |
|---|
| 5380 | else |
|---|
| 5381 | data.Initialize(SMSG_MOVE_UNSET_CAN_FLY, 12); |
|---|
| 5382 | data.append(m_target->GetPackGUID()); |
|---|
| 5383 | data << uint32(0); // unk |
|---|
| 5384 | m_target->SendMessageToSet(&data, true); |
|---|
| 5385 | } |
|---|
| 5386 | |
|---|
| 5387 | void Aura::HandleModRating(bool apply, bool Real) |
|---|
| 5388 | { |
|---|
| 5389 | // spells required only Real aura add/remove |
|---|
| 5390 | if(!Real) |
|---|
| 5391 | return; |
|---|
| 5392 | |
|---|
| 5393 | if(m_target->GetTypeId() != TYPEID_PLAYER) |
|---|
| 5394 | return; |
|---|
| 5395 | |
|---|
| 5396 | for (uint32 rating = 0; rating < MAX_COMBAT_RATING; ++rating) |
|---|
| 5397 | if (m_modifier.m_miscvalue & (1 << rating)) |
|---|
| 5398 | ((Player*)m_target)->ApplyRatingMod(CombatRating(rating), m_modifier.m_amount, apply); |
|---|
| 5399 | } |
|---|
| 5400 | |
|---|
| 5401 | void Aura::HandleForceMoveForward(bool apply, bool Real) |
|---|
| 5402 | { |
|---|
| 5403 | if(!Real || m_target->GetTypeId() != TYPEID_PLAYER) |
|---|
| 5404 | return; |
|---|
| 5405 | if(apply) |
|---|
| 5406 | m_target->SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FORCE_MOVE); |
|---|
| 5407 | else |
|---|
| 5408 | m_target->RemoveFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FORCE_MOVE); |
|---|
| 5409 | } |
|---|
| 5410 | |
|---|
| 5411 | void Aura::HandleAuraModExpertise(bool apply, bool Real) |
|---|
| 5412 | { |
|---|
| 5413 | if(m_target->GetTypeId() != TYPEID_PLAYER) |
|---|
| 5414 | return; |
|---|
| 5415 | |
|---|
| 5416 | ((Player*)m_target)->UpdateExpertise(BASE_ATTACK); |
|---|
| 5417 | ((Player*)m_target)->UpdateExpertise(OFF_ATTACK); |
|---|
| 5418 | } |
|---|
| 5419 | |
|---|
| 5420 | void Aura::HandleModTargetResistance(bool apply, bool Real) |
|---|
| 5421 | { |
|---|
| 5422 | // spells required only Real aura add/remove |
|---|
| 5423 | if(!Real) |
|---|
| 5424 | return; |
|---|
| 5425 | // applied to damage as HandleNoImmediateEffect in Unit::CalcAbsorbResist and Unit::CalcArmorReducedDamage |
|---|
| 5426 | |
|---|
| 5427 | // show armor penetration |
|---|
| 5428 | if (m_target->GetTypeId() == TYPEID_PLAYER && (m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_NORMAL)) |
|---|
| 5429 | m_target->ApplyModInt32Value(PLAYER_FIELD_MOD_TARGET_PHYSICAL_RESISTANCE,m_modifier.m_amount, apply); |
|---|
| 5430 | |
|---|
| 5431 | // show as spell penetration only full spell penetration bonuses (all resistances except armor and holy |
|---|
| 5432 | if (m_target->GetTypeId() == TYPEID_PLAYER && (m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_SPELL)==SPELL_SCHOOL_MASK_SPELL) |
|---|
| 5433 | m_target->ApplyModInt32Value(PLAYER_FIELD_MOD_TARGET_RESISTANCE,m_modifier.m_amount, apply); |
|---|
| 5434 | } |
|---|
| 5435 | |
|---|
| 5436 | //HandleNoImmediateEffect auras implementation to support new stat system |
|---|
| 5437 | void Aura::HandleAuraHealing(bool apply, bool Real) |
|---|
| 5438 | { |
|---|
| 5439 | //m_target->HandleStatModifier(UNIT_MOD_HEALING, TOTAL_VALUE, float(m_modifier.m_amount), apply); |
|---|
| 5440 | } |
|---|
| 5441 | |
|---|
| 5442 | void Aura::HandleAuraHealingPct(bool apply, bool Real) |
|---|
| 5443 | { |
|---|
| 5444 | //m_target->HandleStatModifier(UNIT_MOD_HEALING, TOTAL_PCT, float(m_modifier.m_amount), apply); |
|---|
| 5445 | } |
|---|
| 5446 | |
|---|
| 5447 | void Aura::HandleShieldBlockValue(bool apply, bool Real) |
|---|
| 5448 | { |
|---|
| 5449 | BaseModType modType = FLAT_MOD; |
|---|
| 5450 | if(m_modifier.m_auraname == SPELL_AURA_MOD_SHIELD_BLOCKVALUE_PCT) |
|---|
| 5451 | modType = PCT_MOD; |
|---|
| 5452 | |
|---|
| 5453 | if(m_target->GetTypeId() == TYPEID_PLAYER) |
|---|
| 5454 | ((Player*)m_target)->HandleBaseModValue(SHIELD_BLOCK_VALUE, modType, float(m_modifier.m_amount), apply); |
|---|
| 5455 | } |
|---|
| 5456 | |
|---|
| 5457 | void Aura::HandleAuraRetainComboPoints(bool apply, bool Real) |
|---|
| 5458 | { |
|---|
| 5459 | // spells required only Real aura add/remove |
|---|
| 5460 | if(!Real) |
|---|
| 5461 | return; |
|---|
| 5462 | |
|---|
| 5463 | if(m_target->GetTypeId() != TYPEID_PLAYER) |
|---|
| 5464 | return; |
|---|
| 5465 | |
|---|
| 5466 | Player *target = (Player*)m_target; |
|---|
| 5467 | |
|---|
| 5468 | // combo points was added in SPELL_EFFECT_ADD_COMBO_POINTS handler |
|---|
| 5469 | // remove only if aura expire by time (in case combo points amount change aura removed without combo points lost) |
|---|
| 5470 | if( !apply && m_duration==0 && target->GetComboTarget()) |
|---|
| 5471 | if(Unit* unit = ObjectAccessor::GetUnit(*m_target,target->GetComboTarget())) |
|---|
| 5472 | target->AddComboPoints(unit, -m_modifier.m_amount); |
|---|
| 5473 | } |
|---|
| 5474 | |
|---|
| 5475 | void Aura::HandleModUnattackable( bool Apply, bool Real ) |
|---|
| 5476 | { |
|---|
| 5477 | if(Real && Apply) |
|---|
| 5478 | m_target->CombatStop(); |
|---|
| 5479 | |
|---|
| 5480 | m_target->ApplyModFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE,Apply); |
|---|
| 5481 | } |
|---|
| 5482 | |
|---|
| 5483 | void Aura::HandleSpiritOfRedemption( bool apply, bool Real ) |
|---|
| 5484 | { |
|---|
| 5485 | // spells required only Real aura add/remove |
|---|
| 5486 | if(!Real) |
|---|
| 5487 | return; |
|---|
| 5488 | |
|---|
| 5489 | // prepare spirit state |
|---|
| 5490 | if(apply) |
|---|
| 5491 | { |
|---|
| 5492 | if(m_target->GetTypeId()==TYPEID_PLAYER) |
|---|
| 5493 | { |
|---|
| 5494 | // disable breath/etc timers |
|---|
| 5495 | ((Player*)m_target)->StopMirrorTimers(); |
|---|
| 5496 | |
|---|
| 5497 | // set stand state (expected in this form) |
|---|
| 5498 | if(!m_target->IsStandState()) |
|---|
| 5499 | m_target->SetStandState(PLAYER_STATE_NONE); |
|---|
| 5500 | } |
|---|
| 5501 | |
|---|
| 5502 | m_target->SetHealth(1); |
|---|
| 5503 | } |
|---|
| 5504 | // die at aura end |
|---|
| 5505 | else |
|---|
| 5506 | m_target->DealDamage(m_target, m_target->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, GetSpellProto(), false); |
|---|
| 5507 | } |
|---|
| 5508 | |
|---|
| 5509 | void Aura::CleanupTriggeredSpells() |
|---|
| 5510 | { |
|---|
| 5511 | uint32 tSpellId = m_spellProto->EffectTriggerSpell[GetEffIndex()]; |
|---|
| 5512 | if(!tSpellId) |
|---|
| 5513 | return; |
|---|
| 5514 | |
|---|
| 5515 | SpellEntry const* tProto = sSpellStore.LookupEntry(tSpellId); |
|---|
| 5516 | if(!tProto) |
|---|
| 5517 | return; |
|---|
| 5518 | |
|---|
| 5519 | if(GetSpellDuration(tProto) != -1) |
|---|
| 5520 | return; |
|---|
| 5521 | |
|---|
| 5522 | // needed for spell 43680, maybe others |
|---|
| 5523 | // TODO: is there a spell flag, which can solve this in a more sophisticated way? |
|---|
| 5524 | if(m_spellProto->EffectApplyAuraName[GetEffIndex()] == SPELL_AURA_PERIODIC_TRIGGER_SPELL && |
|---|
| 5525 | GetSpellDuration(m_spellProto) == m_spellProto->EffectAmplitude[GetEffIndex()]) |
|---|
| 5526 | return; |
|---|
| 5527 | m_target->RemoveAurasDueToSpell(tSpellId); |
|---|
| 5528 | } |
|---|
| 5529 | |
|---|
| 5530 | void Aura::HandleAuraPowerBurn(bool apply, bool Real) |
|---|
| 5531 | { |
|---|
| 5532 | if (m_periodicTimer <= 0) |
|---|
| 5533 | m_periodicTimer += m_modifier.periodictime; |
|---|
| 5534 | |
|---|
| 5535 | m_isPeriodic = apply; |
|---|
| 5536 | } |
|---|
| 5537 | |
|---|
| 5538 | void Aura::HandleSchoolAbsorb(bool apply, bool Real) |
|---|
| 5539 | { |
|---|
| 5540 | if(!Real) |
|---|
| 5541 | return; |
|---|
| 5542 | |
|---|
| 5543 | // prevent double apply bonuses |
|---|
| 5544 | if(apply && (m_target->GetTypeId()!=TYPEID_PLAYER || !((Player*)m_target)->GetSession()->PlayerLoading())) |
|---|
| 5545 | { |
|---|
| 5546 | if(Unit* caster = GetCaster()) |
|---|
| 5547 | { |
|---|
| 5548 | float DoneActualBenefit = 0.0f; |
|---|
| 5549 | switch(m_spellProto->SpellFamilyName) |
|---|
| 5550 | { |
|---|
| 5551 | case SPELLFAMILY_PRIEST: |
|---|
| 5552 | if(m_spellProto->SpellFamilyFlags == 0x1) //PW:S |
|---|
| 5553 | { |
|---|
| 5554 | //+30% from +healing bonus |
|---|
| 5555 | DoneActualBenefit = caster->SpellBaseHealingBonus(GetSpellSchoolMask(m_spellProto)) * 0.3f; |
|---|
| 5556 | break; |
|---|
| 5557 | } |
|---|
| 5558 | break; |
|---|
| 5559 | case SPELLFAMILY_MAGE: |
|---|
| 5560 | if(m_spellProto->SpellFamilyFlags == 0x80100 || m_spellProto->SpellFamilyFlags == 0x8 || m_spellProto->SpellFamilyFlags == 0x100000000LL) |
|---|
| 5561 | { |
|---|
| 5562 | //frost ward, fire ward, ice barrier |
|---|
| 5563 | //+10% from +spd bonus |
|---|
| 5564 | DoneActualBenefit = caster->SpellBaseDamageBonus(GetSpellSchoolMask(m_spellProto)) * 0.1f; |
|---|
| 5565 | break; |
|---|
| 5566 | } |
|---|
| 5567 | break; |
|---|
| 5568 | case SPELLFAMILY_WARLOCK: |
|---|
| 5569 | if(m_spellProto->SpellFamilyFlags == 0x00) |
|---|
| 5570 | { |
|---|
| 5571 | //shadow ward |
|---|
| 5572 | //+10% from +spd bonus |
|---|
| 5573 | DoneActualBenefit = caster->SpellBaseDamageBonus(GetSpellSchoolMask(m_spellProto)) * 0.1f; |
|---|
| 5574 | break; |
|---|
| 5575 | } |
|---|
| 5576 | break; |
|---|
| 5577 | default: |
|---|
| 5578 | break; |
|---|
| 5579 | } |
|---|
| 5580 | |
|---|
| 5581 | DoneActualBenefit *= caster->CalculateLevelPenalty(GetSpellProto()); |
|---|
| 5582 | |
|---|
| 5583 | m_modifier.m_amount += (int32)DoneActualBenefit; |
|---|
| 5584 | } |
|---|
| 5585 | } |
|---|
| 5586 | } |
|---|
| 5587 | |
|---|
| 5588 | void Aura::PeriodicTick() |
|---|
| 5589 | { |
|---|
| 5590 | if(!m_target->isAlive()) |
|---|
| 5591 | return; |
|---|
| 5592 | |
|---|
| 5593 | switch(m_modifier.m_auraname) |
|---|
| 5594 | { |
|---|
| 5595 | case SPELL_AURA_PERIODIC_DAMAGE: |
|---|
| 5596 | case SPELL_AURA_PERIODIC_DAMAGE_PERCENT: |
|---|
| 5597 | { |
|---|
| 5598 | Unit *pCaster = GetCaster(); |
|---|
| 5599 | if(!pCaster) |
|---|
| 5600 | return; |
|---|
| 5601 | |
|---|
| 5602 | if( GetSpellProto()->Effect[GetEffIndex()]==SPELL_EFFECT_PERSISTENT_AREA_AURA && |
|---|
| 5603 | pCaster->SpellHitResult(m_target,GetSpellProto(),false)!=SPELL_MISS_NONE) |
|---|
| 5604 | return; |
|---|
| 5605 | |
|---|
| 5606 | // Check for immune (not use charges) |
|---|
| 5607 | if(m_target->IsImmunedToDamage(GetSpellSchoolMask(GetSpellProto()))) |
|---|
| 5608 | return; |
|---|
| 5609 | |
|---|
| 5610 | // some auras remove at specific health level or more |
|---|
| 5611 | if(m_modifier.m_auraname==SPELL_AURA_PERIODIC_DAMAGE) |
|---|
| 5612 | { |
|---|
| 5613 | switch(GetId()) |
|---|
| 5614 | { |
|---|
| 5615 | case 43093: case 31956: case 38801: |
|---|
| 5616 | case 35321: case 38363: case 39215: |
|---|
| 5617 | if(m_target->GetHealth() == m_target->GetMaxHealth() ) |
|---|
| 5618 | { |
|---|
| 5619 | m_target->RemoveAurasDueToSpell(GetId()); |
|---|
| 5620 | return; |
|---|
| 5621 | } |
|---|
| 5622 | break; |
|---|
| 5623 | case 38772: |
|---|
| 5624 | { |
|---|
| 5625 | uint32 percent = |
|---|
| 5626 | GetEffIndex() < 2 && GetSpellProto()->Effect[GetEffIndex()]==SPELL_EFFECT_DUMMY ? |
|---|
| 5627 | pCaster->CalculateSpellDamage(GetSpellProto(),GetEffIndex()+1,GetSpellProto()->EffectBasePoints[GetEffIndex()+1],m_target) : |
|---|
| 5628 | 100; |
|---|
| 5629 | if(m_target->GetHealth()*100 >= m_target->GetMaxHealth()*percent ) |
|---|
| 5630 | { |
|---|
| 5631 | m_target->RemoveAurasDueToSpell(GetId()); |
|---|
| 5632 | return; |
|---|
| 5633 | } |
|---|
| 5634 | break; |
|---|
| 5635 | } |
|---|
| 5636 | case 41337:// aura of anger |
|---|
| 5637 | { |
|---|
| 5638 | Unit::AuraList const& mMod = m_target->GetAurasByType(SPELL_AURA_MOD_DAMAGE_PERCENT_DONE); |
|---|
| 5639 | for(Unit::AuraList::const_iterator i = mMod.begin(); i != mMod.end(); ++i) |
|---|
| 5640 | { |
|---|
| 5641 | if ((*i)->GetId() == 41337) |
|---|
| 5642 | { |
|---|
| 5643 | (*i)->ApplyModifier(false); |
|---|
| 5644 | (*i)->GetModifier()->m_amount += 5; |
|---|
| 5645 | (*i)->ApplyModifier(true); |
|---|
| 5646 | break; |
|---|
| 5647 | } |
|---|
| 5648 | } |
|---|
| 5649 | m_modifier.m_amount += 100; |
|---|
| 5650 | }break; |
|---|
| 5651 | default: |
|---|
| 5652 | break; |
|---|
| 5653 | } |
|---|
| 5654 | } |
|---|
| 5655 | |
|---|
| 5656 | uint32 absorb=0; |
|---|
| 5657 | uint32 resist=0; |
|---|
| 5658 | CleanDamage cleanDamage = CleanDamage(0, BASE_ATTACK, MELEE_HIT_NORMAL ); |
|---|
| 5659 | |
|---|
| 5660 | // ignore non positive values (can be result apply spellmods to aura damage |
|---|
| 5661 | uint32 amount = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0; |
|---|
| 5662 | |
|---|
| 5663 | uint32 pdamage; |
|---|
| 5664 | |
|---|
| 5665 | if(m_modifier.m_auraname == SPELL_AURA_PERIODIC_DAMAGE) |
|---|
| 5666 | { |
|---|
| 5667 | pdamage = amount; |
|---|
| 5668 | |
|---|
| 5669 | // Calculate armor mitigation if it is a physical spell |
|---|
| 5670 | // But not for bleed mechanic spells |
|---|
| 5671 | if ( GetSpellSchoolMask(GetSpellProto()) & SPELL_SCHOOL_MASK_NORMAL && |
|---|
| 5672 | GetEffectMechanic(GetSpellProto(), m_effIndex) != MECHANIC_BLEED) |
|---|
| 5673 | { |
|---|
| 5674 | uint32 pdamageReductedArmor = pCaster->CalcArmorReducedDamage(m_target, pdamage); |
|---|
| 5675 | cleanDamage.damage += pdamage - pdamageReductedArmor; |
|---|
| 5676 | pdamage = pdamageReductedArmor; |
|---|
| 5677 | } |
|---|
| 5678 | |
|---|
| 5679 | pdamage = pCaster->SpellDamageBonus(m_target,GetSpellProto(),pdamage,DOT); |
|---|
| 5680 | |
|---|
| 5681 | // Curse of Agony damage-per-tick calculation |
|---|
| 5682 | if (GetSpellProto()->SpellFamilyName==SPELLFAMILY_WARLOCK && (GetSpellProto()->SpellFamilyFlags & 0x0000000000000400LL) && GetSpellProto()->SpellIconID==544) |
|---|
| 5683 | { |
|---|
| 5684 | // 1..4 ticks, 1/2 from normal tick damage |
|---|
| 5685 | if (m_duration>=((m_maxduration-m_modifier.periodictime)*2/3)) |
|---|
| 5686 | pdamage = pdamage/2; |
|---|
| 5687 | // 9..12 ticks, 3/2 from normal tick damage |
|---|
| 5688 | else if(m_duration<((m_maxduration-m_modifier.periodictime)/3)) |
|---|
| 5689 | pdamage += (pdamage+1)/2; // +1 prevent 0.5 damage possible lost at 1..4 ticks |
|---|
| 5690 | // 5..8 ticks have normal tick damage |
|---|
| 5691 | } |
|---|
| 5692 | } |
|---|
| 5693 | else |
|---|
| 5694 | pdamage = uint32(m_target->GetMaxHealth()*amount/100); |
|---|
| 5695 | |
|---|
| 5696 | //As of 2.2 resilience reduces damage from DoT ticks as much as the chance to not be critically hit |
|---|
| 5697 | // Reduce dot damage from resilience for players |
|---|
| 5698 | if (m_target->GetTypeId()==TYPEID_PLAYER) |
|---|
| 5699 | pdamage-=((Player*)m_target)->GetDotDamageReduction(pdamage); |
|---|
| 5700 | |
|---|
| 5701 | pCaster->CalcAbsorbResist(m_target, GetSpellSchoolMask(GetSpellProto()), DOT, pdamage, &absorb, &resist); |
|---|
| 5702 | |
|---|
| 5703 | sLog.outDetail("PeriodicTick: %u (TypeId: %u) attacked %u (TypeId: %u) for %u dmg inflicted by %u abs is %u", |
|---|
| 5704 | GetCasterGUID(), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target->GetGUIDLow(), m_target->GetTypeId(), pdamage, GetId(),absorb); |
|---|
| 5705 | |
|---|
| 5706 | WorldPacket data(SMSG_PERIODICAURALOG, (21+16));// we guess size |
|---|
| 5707 | data.append(m_target->GetPackGUID()); |
|---|
| 5708 | data.appendPackGUID(GetCasterGUID()); |
|---|
| 5709 | data << uint32(GetId()); |
|---|
| 5710 | data << uint32(1); |
|---|
| 5711 | data << uint32(m_modifier.m_auraname); |
|---|
| 5712 | data << (uint32)pdamage; |
|---|
| 5713 | data << (uint32)GetSpellSchoolMask(GetSpellProto()); // will be mask in 2.4.x |
|---|
| 5714 | data << (uint32)absorb; |
|---|
| 5715 | data << (uint32)resist; |
|---|
| 5716 | m_target->SendMessageToSet(&data,true); |
|---|
| 5717 | |
|---|
| 5718 | Unit* target = m_target; // aura can be deleted in DealDamage |
|---|
| 5719 | SpellEntry const* spellProto = GetSpellProto(); |
|---|
| 5720 | |
|---|
| 5721 | pCaster->DealDamage(m_target, (pdamage <= absorb+resist) ? 0 : (pdamage-absorb-resist), &cleanDamage, DOT, GetSpellSchoolMask(GetSpellProto()), GetSpellProto(), true); |
|---|
| 5722 | |
|---|
| 5723 | // DO NOT ACCESS MEMBERS OF THE AURA FROM NOW ON (DealDamage can delete aura) |
|---|
| 5724 | |
|---|
| 5725 | pCaster->ProcDamageAndSpell(target, PROC_FLAG_HIT_SPELL, PROC_FLAG_TAKE_DAMAGE, (pdamage <= absorb+resist) ? 0 : (pdamage-absorb-resist), GetSpellSchoolMask(spellProto), spellProto); |
|---|
| 5726 | break; |
|---|
| 5727 | } |
|---|
| 5728 | case SPELL_AURA_PERIODIC_LEECH: |
|---|
| 5729 | { |
|---|
| 5730 | Unit *pCaster = GetCaster(); |
|---|
| 5731 | if(!pCaster) |
|---|
| 5732 | return; |
|---|
| 5733 | |
|---|
| 5734 | if(!pCaster->isAlive()) |
|---|
| 5735 | return; |
|---|
| 5736 | |
|---|
| 5737 | if( GetSpellProto()->Effect[GetEffIndex()]==SPELL_EFFECT_PERSISTENT_AREA_AURA && |
|---|
| 5738 | pCaster->SpellHitResult(m_target,GetSpellProto(),false)!=SPELL_MISS_NONE) |
|---|
| 5739 | return; |
|---|
| 5740 | |
|---|
| 5741 | // Check for immune (not use charges) |
|---|
| 5742 | if(m_target->IsImmunedToDamage(GetSpellSchoolMask(GetSpellProto()))) |
|---|
| 5743 | return; |
|---|
| 5744 | |
|---|
| 5745 | uint32 absorb=0; |
|---|
| 5746 | uint32 resist=0; |
|---|
| 5747 | CleanDamage cleanDamage = CleanDamage(0, BASE_ATTACK, MELEE_HIT_NORMAL ); |
|---|
| 5748 | |
|---|
| 5749 | uint32 pdamage = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0; |
|---|
| 5750 | |
|---|
| 5751 | //Calculate armor mitigation if it is a physical spell |
|---|
| 5752 | if (GetSpellSchoolMask(GetSpellProto()) & SPELL_SCHOOL_MASK_NORMAL) |
|---|
| 5753 | { |
|---|
| 5754 | uint32 pdamageReductedArmor = pCaster->CalcArmorReducedDamage(m_target, pdamage); |
|---|
| 5755 | cleanDamage.damage += pdamage - pdamageReductedArmor; |
|---|
| 5756 | pdamage = pdamageReductedArmor; |
|---|
| 5757 | } |
|---|
| 5758 | |
|---|
| 5759 | pdamage = pCaster->SpellDamageBonus(m_target,GetSpellProto(),pdamage,DOT); |
|---|
| 5760 | |
|---|
| 5761 | // talent Soul Siphon add bonus to Drain Life spells |
|---|
| 5762 | if( GetSpellProto()->SpellFamilyName == SPELLFAMILY_WARLOCK && (GetSpellProto()->SpellFamilyFlags & 0x8) ) |
|---|
| 5763 | { |
|---|
| 5764 | // find talent max bonus percentage |
|---|
| 5765 | Unit::AuraList const& mClassScriptAuras = pCaster->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); |
|---|
| 5766 | for(Unit::AuraList::const_iterator i = mClassScriptAuras.begin(); i != mClassScriptAuras.end(); ++i) |
|---|
| 5767 | { |
|---|
| 5768 | if ((*i)->GetModifier()->m_miscvalue == 4992 || (*i)->GetModifier()->m_miscvalue == 4993) |
|---|
| 5769 | { |
|---|
| 5770 | if((*i)->GetEffIndex()!=1) |
|---|
| 5771 | { |
|---|
| 5772 | sLog.outError("Expected spell %u structure change, need code update",(*i)->GetId()); |
|---|
| 5773 | break; |
|---|
| 5774 | } |
|---|
| 5775 | |
|---|
| 5776 | // effect 1 m_amount |
|---|
| 5777 | int32 maxPercent = (*i)->GetModifier()->m_amount; |
|---|
| 5778 | // effect 0 m_amount |
|---|
| 5779 | int32 stepPercent = pCaster->CalculateSpellDamage((*i)->GetSpellProto(),0,(*i)->GetSpellProto()->EffectBasePoints[0],pCaster); |
|---|
| 5780 | |
|---|
| 5781 | // count affliction effects and calc additional damage in percentage |
|---|
| 5782 | int32 modPercent = 0; |
|---|
| 5783 | Unit::AuraMap const& victimAuras = m_target->GetAuras(); |
|---|
| 5784 | for (Unit::AuraMap::const_iterator itr = victimAuras.begin(); itr != victimAuras.end(); ++itr) |
|---|
| 5785 | { |
|---|
| 5786 | Aura* aura = itr->second; |
|---|
| 5787 | if (aura->IsPositive())continue; |
|---|
| 5788 | SpellEntry const* m_spell = aura->GetSpellProto(); |
|---|
| 5789 | if (m_spell->SpellFamilyName != SPELLFAMILY_WARLOCK) |
|---|
| 5790 | continue; |
|---|
| 5791 | |
|---|
| 5792 | SkillLineAbilityMap::const_iterator lower = spellmgr.GetBeginSkillLineAbilityMap(m_spell->Id); |
|---|
| 5793 | SkillLineAbilityMap::const_iterator upper = spellmgr.GetEndSkillLineAbilityMap(m_spell->Id); |
|---|
| 5794 | |
|---|
| 5795 | for(SkillLineAbilityMap::const_iterator _spell_idx = lower; _spell_idx != upper; ++_spell_idx) |
|---|
| 5796 | { |
|---|
| 5797 | if(_spell_idx->second->skillId == SKILL_AFFLICTION) |
|---|
| 5798 | { |
|---|
| 5799 | modPercent += stepPercent; |
|---|
| 5800 | if (modPercent >= maxPercent) |
|---|
| 5801 | { |
|---|
| 5802 | modPercent = maxPercent; |
|---|
| 5803 | break; |
|---|
| 5804 | } |
|---|
| 5805 | } |
|---|
| 5806 | } |
|---|
| 5807 | } |
|---|
| 5808 | pdamage += (pdamage*modPercent/100); |
|---|
| 5809 | break; |
|---|
| 5810 | } |
|---|
| 5811 | } |
|---|
| 5812 | } |
|---|
| 5813 | |
|---|
| 5814 | //As of 2.2 resilience reduces damage from DoT ticks as much as the chance to not be critically hit |
|---|
| 5815 | // Reduce dot damage from resilience for players |
|---|
| 5816 | if (m_target->GetTypeId()==TYPEID_PLAYER) |
|---|
| 5817 | pdamage-=((Player*)m_target)->GetDotDamageReduction(pdamage); |
|---|
| 5818 | |
|---|
| 5819 | pCaster->CalcAbsorbResist(m_target, GetSpellSchoolMask(GetSpellProto()), DOT, pdamage, &absorb, &resist); |
|---|
| 5820 | |
|---|
| 5821 | if(m_target->GetHealth() < pdamage) |
|---|
| 5822 | pdamage = uint32(m_target->GetHealth()); |
|---|
| 5823 | |
|---|
| 5824 | sLog.outDetail("PeriodicTick: %u (TypeId: %u) health leech of %u (TypeId: %u) for %u dmg inflicted by %u abs is %u", |
|---|
| 5825 | GetCasterGUID(), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target->GetGUIDLow(), m_target->GetTypeId(), pdamage, GetId(),absorb); |
|---|
| 5826 | |
|---|
| 5827 | pCaster->SendSpellNonMeleeDamageLog(m_target, GetId(), pdamage, GetSpellSchoolMask(GetSpellProto()), absorb, resist, false, 0); |
|---|
| 5828 | |
|---|
| 5829 | |
|---|
| 5830 | Unit* target = m_target; // aura can be deleted in DealDamage |
|---|
| 5831 | SpellEntry const* spellProto = GetSpellProto(); |
|---|
| 5832 | float multiplier = spellProto->EffectMultipleValue[GetEffIndex()] > 0 ? spellProto->EffectMultipleValue[GetEffIndex()] : 1; |
|---|
| 5833 | |
|---|
| 5834 | uint32 new_damage = pCaster->DealDamage(m_target, (pdamage <= absorb+resist) ? 0 : (pdamage-absorb-resist), &cleanDamage, DOT, GetSpellSchoolMask(GetSpellProto()), GetSpellProto(), false); |
|---|
| 5835 | |
|---|
| 5836 | // DO NOT ACCESS MEMBERS OF THE AURA FROM NOW ON (DealDamage can delete aura) |
|---|
| 5837 | |
|---|
| 5838 | pCaster->ProcDamageAndSpell(target, PROC_FLAG_HIT_SPELL, PROC_FLAG_TAKE_DAMAGE, new_damage, GetSpellSchoolMask(spellProto), spellProto); |
|---|
| 5839 | if (!target->isAlive() && pCaster->IsNonMeleeSpellCasted(false)) |
|---|
| 5840 | { |
|---|
| 5841 | for (uint32 i = CURRENT_FIRST_NON_MELEE_SPELL; i < CURRENT_MAX_SPELL; i++) |
|---|
| 5842 | { |
|---|
| 5843 | if (pCaster->m_currentSpells[i] && pCaster->m_currentSpells[i]->m_spellInfo->Id == spellProto->Id) |
|---|
| 5844 | pCaster->m_currentSpells[i]->cancel(); |
|---|
| 5845 | } |
|---|
| 5846 | } |
|---|
| 5847 | |
|---|
| 5848 | |
|---|
| 5849 | if(Player *modOwner = pCaster->GetSpellModOwner()) |
|---|
| 5850 | modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_MULTIPLE_VALUE, multiplier); |
|---|
| 5851 | |
|---|
| 5852 | uint32 heal = pCaster->SpellHealingBonus(spellProto, uint32(new_damage * multiplier), DOT, pCaster); |
|---|
| 5853 | |
|---|
| 5854 | int32 gain = pCaster->ModifyHealth(heal); |
|---|
| 5855 | pCaster->getHostilRefManager().threatAssist(pCaster, gain * 0.5f, spellProto); |
|---|
| 5856 | |
|---|
| 5857 | pCaster->SendHealSpellLog(pCaster, spellProto->Id, heal); |
|---|
| 5858 | break; |
|---|
| 5859 | } |
|---|
| 5860 | case SPELL_AURA_PERIODIC_HEAL: |
|---|
| 5861 | case SPELL_AURA_OBS_MOD_HEALTH: |
|---|
| 5862 | { |
|---|
| 5863 | Unit *pCaster = GetCaster(); |
|---|
| 5864 | if(!pCaster) |
|---|
| 5865 | return; |
|---|
| 5866 | |
|---|
| 5867 | // heal for caster damage (must be alive) |
|---|
| 5868 | if(m_target != pCaster && GetSpellProto()->SpellVisual==163 && !pCaster->isAlive()) |
|---|
| 5869 | return; |
|---|
| 5870 | |
|---|
| 5871 | // ignore non positive values (can be result apply spellmods to aura damage |
|---|
| 5872 | uint32 amount = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0; |
|---|
| 5873 | |
|---|
| 5874 | uint32 pdamage; |
|---|
| 5875 | |
|---|
| 5876 | if(m_modifier.m_auraname==SPELL_AURA_OBS_MOD_HEALTH) |
|---|
| 5877 | pdamage = uint32(m_target->GetMaxHealth() * amount/100); |
|---|
| 5878 | else |
|---|
| 5879 | pdamage = amount; |
|---|
| 5880 | |
|---|
| 5881 | pdamage = pCaster->SpellHealingBonus(GetSpellProto(), pdamage, DOT, m_target); |
|---|
| 5882 | |
|---|
| 5883 | sLog.outDetail("PeriodicTick: %u (TypeId: %u) heal of %u (TypeId: %u) for %u health inflicted by %u", |
|---|
| 5884 | GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target->GetGUIDLow(), m_target->GetTypeId(), pdamage, GetId()); |
|---|
| 5885 | |
|---|
| 5886 | WorldPacket data(SMSG_PERIODICAURALOG, (21+16));// we guess size |
|---|
| 5887 | data.append(m_target->GetPackGUID()); |
|---|
| 5888 | data.appendPackGUID(GetCasterGUID()); |
|---|
| 5889 | data << uint32(GetId()); |
|---|
| 5890 | data << uint32(1); |
|---|
| 5891 | data << uint32(m_modifier.m_auraname); |
|---|
| 5892 | data << (uint32)pdamage; |
|---|
| 5893 | m_target->SendMessageToSet(&data,true); |
|---|
| 5894 | |
|---|
| 5895 | int32 gain = m_target->ModifyHealth(pdamage); |
|---|
| 5896 | |
|---|
| 5897 | // add HoTs to amount healed in bgs |
|---|
| 5898 | if( pCaster->GetTypeId() == TYPEID_PLAYER ) |
|---|
| 5899 | if( BattleGround *bg = ((Player*)pCaster)->GetBattleGround() ) |
|---|
| 5900 | bg->UpdatePlayerScore(((Player*)pCaster), SCORE_HEALING_DONE, gain); |
|---|
| 5901 | |
|---|
| 5902 | //Do check before because m_modifier.auraName can be invalidate by DealDamage. |
|---|
| 5903 | bool procSpell = (m_modifier.m_auraname == SPELL_AURA_PERIODIC_HEAL && m_target != pCaster); |
|---|
| 5904 | |
|---|
| 5905 | m_target->getHostilRefManager().threatAssist(pCaster, float(gain) * 0.5f, GetSpellProto()); |
|---|
| 5906 | |
|---|
| 5907 | Unit* target = m_target; // aura can be deleted in DealDamage |
|---|
| 5908 | SpellEntry const* spellProto = GetSpellProto(); |
|---|
| 5909 | bool haveCastItem = GetCastItemGUID()!=0; |
|---|
| 5910 | |
|---|
| 5911 | // heal for caster damage |
|---|
| 5912 | if(m_target!=pCaster && spellProto->SpellVisual==163) |
|---|
| 5913 | { |
|---|
| 5914 | uint32 dmg = spellProto->manaPerSecond; |
|---|
| 5915 | if(pCaster->GetHealth() <= dmg && pCaster->GetTypeId()==TYPEID_PLAYER) |
|---|
| 5916 | { |
|---|
| 5917 | pCaster->RemoveAurasDueToSpell(GetId()); |
|---|
| 5918 | |
|---|
| 5919 | // finish current generic/channeling spells, don't affect autorepeat |
|---|
| 5920 | if(pCaster->m_currentSpells[CURRENT_GENERIC_SPELL]) |
|---|
| 5921 | { |
|---|
| 5922 | pCaster->m_currentSpells[CURRENT_GENERIC_SPELL]->finish(); |
|---|
| 5923 | } |
|---|
| 5924 | if(pCaster->m_currentSpells[CURRENT_CHANNELED_SPELL]) |
|---|
| 5925 | { |
|---|
| 5926 | pCaster->m_currentSpells[CURRENT_CHANNELED_SPELL]->SendChannelUpdate(0); |
|---|
| 5927 | pCaster->m_currentSpells[CURRENT_CHANNELED_SPELL]->finish(); |
|---|
| 5928 | } |
|---|
| 5929 | } |
|---|
| 5930 | else |
|---|
| 5931 | { |
|---|
| 5932 | pCaster->SendSpellNonMeleeDamageLog(pCaster, GetId(), gain, GetSpellSchoolMask(GetSpellProto()), 0, 0, false, 0, false); |
|---|
| 5933 | |
|---|
| 5934 | CleanDamage cleanDamage = CleanDamage(0, BASE_ATTACK, MELEE_HIT_NORMAL ); |
|---|
| 5935 | pCaster->DealDamage(pCaster, gain, &cleanDamage, NODAMAGE, GetSpellSchoolMask(GetSpellProto()), GetSpellProto(), true); |
|---|
| 5936 | } |
|---|
| 5937 | } |
|---|
| 5938 | |
|---|
| 5939 | // ignore item heals |
|---|
| 5940 | if(procSpell && !haveCastItem) |
|---|
| 5941 | pCaster->ProcDamageAndSpell(target,PROC_FLAG_HEAL, PROC_FLAG_HEALED, pdamage, SPELL_SCHOOL_MASK_NONE, spellProto); |
|---|
| 5942 | break; |
|---|
| 5943 | } |
|---|
| 5944 | case SPELL_AURA_PERIODIC_MANA_LEECH: |
|---|
| 5945 | { |
|---|
| 5946 | Unit *pCaster = GetCaster(); |
|---|
| 5947 | if(!pCaster) |
|---|
| 5948 | return; |
|---|
| 5949 | |
|---|
| 5950 | if(!pCaster->isAlive()) |
|---|
| 5951 | return; |
|---|
| 5952 | |
|---|
| 5953 | if( GetSpellProto()->Effect[GetEffIndex()]==SPELL_EFFECT_PERSISTENT_AREA_AURA && |
|---|
| 5954 | pCaster->SpellHitResult(m_target,GetSpellProto(),false)!=SPELL_MISS_NONE) |
|---|
| 5955 | return; |
|---|
| 5956 | |
|---|
| 5957 | // Check for immune (not use charges) |
|---|
| 5958 | if(m_target->IsImmunedToDamage(GetSpellSchoolMask(GetSpellProto()))) |
|---|
| 5959 | return; |
|---|
| 5960 | |
|---|
| 5961 | // ignore non positive values (can be result apply spellmods to aura damage |
|---|
| 5962 | uint32 pdamage = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0; |
|---|
| 5963 | |
|---|
| 5964 | sLog.outDetail("PeriodicTick: %u (TypeId: %u) power leech of %u (TypeId: %u) for %u dmg inflicted by %u", |
|---|
| 5965 | GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target->GetGUIDLow(), m_target->GetTypeId(), pdamage, GetId()); |
|---|
| 5966 | |
|---|
| 5967 | if(m_modifier.m_miscvalue < 0 || m_modifier.m_miscvalue > 4) |
|---|
| 5968 | break; |
|---|
| 5969 | |
|---|
| 5970 | Powers power = Powers(m_modifier.m_miscvalue); |
|---|
| 5971 | |
|---|
| 5972 | // power type might have changed between aura applying and tick (druid's shapeshift) |
|---|
| 5973 | if(m_target->getPowerType() != power) |
|---|
| 5974 | break; |
|---|
| 5975 | |
|---|
| 5976 | int32 drain_amount = m_target->GetPower(power) > pdamage ? pdamage : m_target->GetPower(power); |
|---|
| 5977 | |
|---|
| 5978 | // resilience reduce mana draining effect at spell crit damage reduction (added in 2.4) |
|---|
| 5979 | if (power == POWER_MANA && m_target->GetTypeId() == TYPEID_PLAYER) |
|---|
| 5980 | drain_amount -= ((Player*)m_target)->GetSpellCritDamageReduction(drain_amount); |
|---|
| 5981 | |
|---|
| 5982 | m_target->ModifyPower(power, -drain_amount); |
|---|
| 5983 | |
|---|
| 5984 | float gain_multiplier = 0; |
|---|
| 5985 | |
|---|
| 5986 | if(pCaster->GetMaxPower(power) > 0) |
|---|
| 5987 | { |
|---|
| 5988 | gain_multiplier = GetSpellProto()->EffectMultipleValue[GetEffIndex()]; |
|---|
| 5989 | |
|---|
| 5990 | if(Player *modOwner = pCaster->GetSpellModOwner()) |
|---|
| 5991 | modOwner->ApplySpellMod(GetId(), SPELLMOD_MULTIPLE_VALUE, gain_multiplier); |
|---|
| 5992 | } |
|---|
| 5993 | |
|---|
| 5994 | WorldPacket data(SMSG_PERIODICAURALOG, (21+16));// we guess size |
|---|
| 5995 | data.append(m_target->GetPackGUID()); |
|---|
| 5996 | data.appendPackGUID(GetCasterGUID()); |
|---|
| 5997 | data << uint32(GetId()); |
|---|
| 5998 | data << uint32(1); |
|---|
| 5999 | data << uint32(m_modifier.m_auraname); |
|---|
| 6000 | data << (uint32)power; // power type |
|---|
| 6001 | data << (uint32)drain_amount; |
|---|
| 6002 | data << (float)gain_multiplier; |
|---|
| 6003 | m_target->SendMessageToSet(&data,true); |
|---|
| 6004 | |
|---|
| 6005 | int32 gain_amount = int32(drain_amount*gain_multiplier); |
|---|
| 6006 | |
|---|
| 6007 | if(gain_amount) |
|---|
| 6008 | { |
|---|
| 6009 | int32 gain = pCaster->ModifyPower(power,gain_amount); |
|---|
| 6010 | m_target->AddThreat(pCaster, float(gain) * 0.5f, GetSpellSchoolMask(GetSpellProto()), GetSpellProto()); |
|---|
| 6011 | } |
|---|
| 6012 | break; |
|---|
| 6013 | } |
|---|
| 6014 | case SPELL_AURA_PERIODIC_ENERGIZE: |
|---|
| 6015 | { |
|---|
| 6016 | // ignore non positive values (can be result apply spellmods to aura damage |
|---|
| 6017 | uint32 pdamage = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0; |
|---|
| 6018 | |
|---|
| 6019 | sLog.outDetail("PeriodicTick: %u (TypeId: %u) energize %u (TypeId: %u) for %u dmg inflicted by %u", |
|---|
| 6020 | GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target->GetGUIDLow(), m_target->GetTypeId(), pdamage, GetId()); |
|---|
| 6021 | |
|---|
| 6022 | if(m_modifier.m_miscvalue < 0 || m_modifier.m_miscvalue > 4) |
|---|
| 6023 | break; |
|---|
| 6024 | |
|---|
| 6025 | Powers power = Powers(m_modifier.m_miscvalue); |
|---|
| 6026 | |
|---|
| 6027 | if(m_target->GetMaxPower(power) == 0) |
|---|
| 6028 | break; |
|---|
| 6029 | |
|---|
| 6030 | WorldPacket data(SMSG_PERIODICAURALOG, (21+16));// we guess size |
|---|
| 6031 | data.append(m_target->GetPackGUID()); |
|---|
| 6032 | data.appendPackGUID(GetCasterGUID()); |
|---|
| 6033 | data << uint32(GetId()); |
|---|
| 6034 | data << uint32(1); |
|---|
| 6035 | data << uint32(m_modifier.m_auraname); |
|---|
| 6036 | data << (uint32)power; // power type |
|---|
| 6037 | data << (uint32)pdamage; |
|---|
| 6038 | m_target->SendMessageToSet(&data,true); |
|---|
| 6039 | |
|---|
| 6040 | int32 gain = m_target->ModifyPower(power,pdamage); |
|---|
| 6041 | |
|---|
| 6042 | if(Unit* pCaster = GetCaster()) |
|---|
| 6043 | m_target->getHostilRefManager().threatAssist(pCaster, float(gain) * 0.5f, GetSpellProto()); |
|---|
| 6044 | break; |
|---|
| 6045 | } |
|---|
| 6046 | case SPELL_AURA_OBS_MOD_MANA: |
|---|
| 6047 | { |
|---|
| 6048 | // ignore non positive values (can be result apply spellmods to aura damage |
|---|
| 6049 | uint32 amount = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0; |
|---|
| 6050 | |
|---|
| 6051 | uint32 pdamage = uint32(m_target->GetMaxPower(POWER_MANA) * amount/100); |
|---|
| 6052 | |
|---|
| 6053 | sLog.outDetail("PeriodicTick: %u (TypeId: %u) energize %u (TypeId: %u) for %u mana inflicted by %u", |
|---|
| 6054 | GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target->GetGUIDLow(), m_target->GetTypeId(), pdamage, GetId()); |
|---|
| 6055 | |
|---|
| 6056 | if(m_target->GetMaxPower(POWER_MANA) == 0) |
|---|
| 6057 | break; |
|---|
| 6058 | |
|---|
| 6059 | WorldPacket data(SMSG_PERIODICAURALOG, (21+16));// we guess size |
|---|
| 6060 | data.append(m_target->GetPackGUID()); |
|---|
| 6061 | data.appendPackGUID(GetCasterGUID()); |
|---|
| 6062 | data << uint32(GetId()); |
|---|
| 6063 | data << uint32(1); |
|---|
| 6064 | data << uint32(m_modifier.m_auraname); |
|---|
| 6065 | data << (uint32)0; // ? |
|---|
| 6066 | data << (uint32)pdamage; |
|---|
| 6067 | m_target->SendMessageToSet(&data,true); |
|---|
| 6068 | |
|---|
| 6069 | int32 gain = m_target->ModifyPower(POWER_MANA, pdamage); |
|---|
| 6070 | |
|---|
| 6071 | if(Unit* pCaster = GetCaster()) |
|---|
| 6072 | m_target->getHostilRefManager().threatAssist(pCaster, float(gain) * 0.5f, GetSpellProto()); |
|---|
| 6073 | break; |
|---|
| 6074 | } |
|---|
| 6075 | case SPELL_AURA_POWER_BURN_MANA: |
|---|
| 6076 | { |
|---|
| 6077 | Unit *pCaster = GetCaster(); |
|---|
| 6078 | if(!pCaster) |
|---|
| 6079 | return; |
|---|
| 6080 | |
|---|
| 6081 | // Check for immune (not use charges) |
|---|
| 6082 | if(m_target->IsImmunedToDamage(GetSpellSchoolMask(GetSpellProto()))) |
|---|
| 6083 | return; |
|---|
| 6084 | |
|---|
| 6085 | int32 pdamage = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0; |
|---|
| 6086 | |
|---|
| 6087 | Powers powerType = Powers(m_modifier.m_miscvalue); |
|---|
| 6088 | |
|---|
| 6089 | if(!m_target->isAlive() || m_target->getPowerType() != powerType) |
|---|
| 6090 | return; |
|---|
| 6091 | |
|---|
| 6092 | // resilience reduce mana draining effect at spell crit damage reduction (added in 2.4) |
|---|
| 6093 | if (powerType == POWER_MANA && m_target->GetTypeId() == TYPEID_PLAYER) |
|---|
| 6094 | pdamage -= ((Player*)m_target)->GetSpellCritDamageReduction(pdamage); |
|---|
| 6095 | |
|---|
| 6096 | uint32 gain = uint32(-m_target->ModifyPower(powerType, -pdamage)); |
|---|
| 6097 | |
|---|
| 6098 | gain = uint32(gain * GetSpellProto()->EffectMultipleValue[GetEffIndex()]); |
|---|
| 6099 | |
|---|
| 6100 | //maybe has to be sent different to client, but not by SMSG_PERIODICAURALOG |
|---|
| 6101 | pCaster->SpellNonMeleeDamageLog(m_target, GetId(), gain); |
|---|
| 6102 | break; |
|---|
| 6103 | } |
|---|
| 6104 | // Here tick dummy auras |
|---|
| 6105 | case SPELL_AURA_PERIODIC_DUMMY: |
|---|
| 6106 | { |
|---|
| 6107 | PeriodicDummyTick(); |
|---|
| 6108 | break; |
|---|
| 6109 | } |
|---|
| 6110 | default: |
|---|
| 6111 | break; |
|---|
| 6112 | } |
|---|
| 6113 | } |
|---|
| 6114 | |
|---|
| 6115 | void Aura::PeriodicDummyTick() |
|---|
| 6116 | { |
|---|
| 6117 | SpellEntry const* spell = GetSpellProto(); |
|---|
| 6118 | switch (spell->Id) |
|---|
| 6119 | { |
|---|
| 6120 | // Drink |
|---|
| 6121 | case 430: |
|---|
| 6122 | case 431: |
|---|
| 6123 | case 432: |
|---|
| 6124 | case 1133: |
|---|
| 6125 | case 1135: |
|---|
| 6126 | case 1137: |
|---|
| 6127 | case 10250: |
|---|
| 6128 | case 22734: |
|---|
| 6129 | case 27089: |
|---|
| 6130 | case 34291: |
|---|
| 6131 | case 43706: |
|---|
| 6132 | case 46755: |
|---|
| 6133 | { |
|---|
| 6134 | if (m_target->GetTypeId() != TYPEID_PLAYER) |
|---|
| 6135 | return; |
|---|
| 6136 | // Search SPELL_AURA_MOD_POWER_REGEN aura for this spell and add bonus |
|---|
| 6137 | Unit::AuraList const& aura = m_target->GetAurasByType(SPELL_AURA_MOD_POWER_REGEN); |
|---|
| 6138 | for(Unit::AuraList::const_iterator i = aura.begin(); i != aura.end(); ++i) |
|---|
| 6139 | { |
|---|
| 6140 | if ((*i)->GetId() == GetId()) |
|---|
| 6141 | { |
|---|
| 6142 | // Get tick number |
|---|
| 6143 | int32 tick = (m_maxduration - m_duration) / m_modifier.periodictime; |
|---|
| 6144 | // Default case (not on arenas) |
|---|
| 6145 | if (tick == 0) |
|---|
| 6146 | { |
|---|
| 6147 | (*i)->GetModifier()->m_amount = m_modifier.m_amount; |
|---|
| 6148 | ((Player*)m_target)->UpdateManaRegen(); |
|---|
| 6149 | // Disable continue |
|---|
| 6150 | m_isPeriodic = false; |
|---|
| 6151 | } |
|---|
| 6152 | return; |
|---|
| 6153 | //********************************************** |
|---|
| 6154 | // Code commended since arena patch not added |
|---|
| 6155 | // This feature uses only in arenas |
|---|
| 6156 | //********************************************** |
|---|
| 6157 | // Here need increase mana regen per tick (6 second rule) |
|---|
| 6158 | // on 0 tick - 0 (handled in 2 second) |
|---|
| 6159 | // on 1 tick - 166% (handled in 4 second) |
|---|
| 6160 | // on 2 tick - 133% (handled in 6 second) |
|---|
| 6161 | // Not need update after 3 tick |
|---|
| 6162 | /* |
|---|
| 6163 | if (tick > 3) |
|---|
| 6164 | return; |
|---|
| 6165 | // Apply bonus for 0 - 3 tick |
|---|
| 6166 | switch (tick) |
|---|
| 6167 | { |
|---|
| 6168 | case 0: // 0% |
|---|
| 6169 | (*i)->GetModifier()->m_amount = m_modifier.m_amount = 0; |
|---|
| 6170 | break; |
|---|
| 6171 | case 1: // 166% |
|---|
| 6172 | (*i)->GetModifier()->m_amount = m_modifier.m_amount * 5 / 3; |
|---|
| 6173 | break; |
|---|
| 6174 | case 2: // 133% |
|---|
| 6175 | (*i)->GetModifier()->m_amount = m_modifier.m_amount * 4 / 3; |
|---|
| 6176 | break; |
|---|
| 6177 | default: // 100% - normal regen |
|---|
| 6178 | (*i)->GetModifier()->m_amount = m_modifier.m_amount; |
|---|
| 6179 | break; |
|---|
| 6180 | } |
|---|
| 6181 | ((Player*)m_target)->UpdateManaRegen(); |
|---|
| 6182 | return;*/ |
|---|
| 6183 | } |
|---|
| 6184 | } |
|---|
| 6185 | return; |
|---|
| 6186 | } |
|---|
| 6187 | // // Panda |
|---|
| 6188 | // case 19230: break; |
|---|
| 6189 | // // Master of Subtlety |
|---|
| 6190 | // case 31666: break; |
|---|
| 6191 | // // Gossip NPC Periodic - Talk |
|---|
| 6192 | // case 33208: break; |
|---|
| 6193 | // // Gossip NPC Periodic - Despawn |
|---|
| 6194 | // case 33209: break; |
|---|
| 6195 | // // Force of Nature |
|---|
| 6196 | // case 33831: break; |
|---|
| 6197 | // Aspect of the Viper |
|---|
| 6198 | case 34074: |
|---|
| 6199 | { |
|---|
| 6200 | if (m_target->GetTypeId() != TYPEID_PLAYER) |
|---|
| 6201 | return; |
|---|
| 6202 | // Should be manauser |
|---|
| 6203 | if (m_target->getPowerType()!=POWER_MANA) |
|---|
| 6204 | return; |
|---|
| 6205 | Unit *caster = GetCaster(); |
|---|
| 6206 | if (!caster) |
|---|
| 6207 | return; |
|---|
| 6208 | // Regen amount is max (100% from spell) on 21% or less mana and min on 92.5% or greater mana (20% from spell) |
|---|
| 6209 | int mana = m_target->GetPower(POWER_MANA); |
|---|
| 6210 | int max_mana = m_target->GetMaxPower(POWER_MANA); |
|---|
| 6211 | int32 base_regen = caster->CalculateSpellDamage(m_spellProto, m_effIndex, m_currentBasePoints, m_target); |
|---|
| 6212 | float regen_pct = 1.20f - 1.1f * mana / max_mana; |
|---|
| 6213 | if (regen_pct > 1.0f) regen_pct = 1.0f; |
|---|
| 6214 | else if (regen_pct < 0.2f) regen_pct = 0.2f; |
|---|
| 6215 | m_modifier.m_amount = int32 (base_regen * regen_pct); |
|---|
| 6216 | ((Player*)m_target)->UpdateManaRegen(); |
|---|
| 6217 | return; |
|---|
| 6218 | } |
|---|
| 6219 | // // Steal Weapon |
|---|
| 6220 | // case 36207: break; |
|---|
| 6221 | // // Simon Game START timer, (DND) |
|---|
| 6222 | // case 39993: break; |
|---|
| 6223 | // // Harpooner's Mark |
|---|
| 6224 | // case 40084: break; |
|---|
| 6225 | // // Knockdown Fel Cannon: break; The Aggro Burst |
|---|
| 6226 | // case 40119: break; |
|---|
| 6227 | // // Old Mount Spell |
|---|
| 6228 | // case 40154: break; |
|---|
| 6229 | // // Magnetic Pull |
|---|
| 6230 | // case 40581: break; |
|---|
| 6231 | // // Ethereal Ring: break; The Bolt Burst |
|---|
| 6232 | // case 40801: break; |
|---|
| 6233 | // // Crystal Prison |
|---|
| 6234 | // case 40846: break; |
|---|
| 6235 | // // Copy Weapon |
|---|
| 6236 | // case 41054: break; |
|---|
| 6237 | // // Ethereal Ring Visual, Lightning Aura |
|---|
| 6238 | // case 41477: break; |
|---|
| 6239 | // // Ethereal Ring Visual, Lightning Aura (Fork) |
|---|
| 6240 | // case 41525: break; |
|---|
| 6241 | // // Ethereal Ring Visual, Lightning Jumper Aura |
|---|
| 6242 | // case 41567: break; |
|---|
| 6243 | // // No Man's Land |
|---|
| 6244 | // case 41955: break; |
|---|
| 6245 | // // Headless Horseman - Fire |
|---|
| 6246 | // case 42074: break; |
|---|
| 6247 | // // Headless Horseman - Visual - Large Fire |
|---|
| 6248 | // case 42075: break; |
|---|
| 6249 | // // Headless Horseman - Start Fire, Periodic Aura |
|---|
| 6250 | // case 42140: break; |
|---|
| 6251 | // // Ram Speed Boost |
|---|
| 6252 | // case 42152: break; |
|---|
| 6253 | // // Headless Horseman - Fires Out Victory Aura |
|---|
| 6254 | // case 42235: break; |
|---|
| 6255 | // // Pumpkin Life Cycle |
|---|
| 6256 | // case 42280: break; |
|---|
| 6257 | // // Brewfest Request Chick Chuck Mug Aura |
|---|
| 6258 | // case 42537: break; |
|---|
| 6259 | // // Squashling |
|---|
| 6260 | // case 42596: break; |
|---|
| 6261 | // // Headless Horseman Climax, Head: Periodic |
|---|
| 6262 | // case 42603: break; |
|---|
| 6263 | // // Fire Bomb |
|---|
| 6264 | // case 42621: break; |
|---|
| 6265 | // // Headless Horseman - Conflagrate, Periodic Aura |
|---|
| 6266 | // case 42637: break; |
|---|
| 6267 | // // Headless Horseman - Create Pumpkin Treats Aura |
|---|
| 6268 | // case 42774: break; |
|---|
| 6269 | // // Headless Horseman Climax - Summoning Rhyme Aura |
|---|
| 6270 | // case 42879: break; |
|---|
| 6271 | // // Tricky Treat |
|---|
| 6272 | // case 42919: break; |
|---|
| 6273 | // // Giddyup! |
|---|
| 6274 | // case 42924: break; |
|---|
| 6275 | // // Ram - Trot |
|---|
| 6276 | // case 42992: break; |
|---|
| 6277 | // // Ram - Canter |
|---|
| 6278 | // case 42993: break; |
|---|
| 6279 | // // Ram - Gallop |
|---|
| 6280 | // case 42994: break; |
|---|
| 6281 | // // Ram Level - Neutral |
|---|
| 6282 | // case 43310: break; |
|---|
| 6283 | // // Headless Horseman - Maniacal Laugh, Maniacal, Delayed 17 |
|---|
| 6284 | // case 43884: break; |
|---|
| 6285 | // // Headless Horseman - Maniacal Laugh, Maniacal, other, Delayed 17 |
|---|
| 6286 | // case 44000: break; |
|---|
| 6287 | // // Energy Feedback |
|---|
| 6288 | // case 44328: break; |
|---|
| 6289 | // // Romantic Picnic |
|---|
| 6290 | // case 45102: break; |
|---|
| 6291 | // // Romantic Picnic |
|---|
| 6292 | // case 45123: break; |
|---|
| 6293 | // // Looking for Love |
|---|
| 6294 | // case 45124: break; |
|---|
| 6295 | // // Kite - Lightning Strike Kite Aura |
|---|
| 6296 | // case 45197: break; |
|---|
| 6297 | // // Rocket Chicken |
|---|
| 6298 | // case 45202: break; |
|---|
| 6299 | // // Copy Offhand Weapon |
|---|
| 6300 | // case 45205: break; |
|---|
| 6301 | // // Upper Deck - Kite - Lightning Periodic Aura |
|---|
| 6302 | // case 45207: break; |
|---|
| 6303 | // // Kite -Sky Lightning Strike Kite Aura |
|---|
| 6304 | // case 45251: break; |
|---|
| 6305 | // // Ribbon Pole Dancer Check Aura |
|---|
| 6306 | // case 45390: break; |
|---|
| 6307 | // // Holiday - Midsummer, Ribbon Pole Periodic Visual |
|---|
| 6308 | // case 45406: break; |
|---|
| 6309 | // // Parachute |
|---|
| 6310 | // case 45472: break; |
|---|
| 6311 | // // Alliance Flag, Extra Damage Debuff |
|---|
| 6312 | // case 45898: break; |
|---|
| 6313 | // // Horde Flag, Extra Damage Debuff |
|---|
| 6314 | // case 45899: break; |
|---|
| 6315 | // // Ahune - Summoning Rhyme Aura |
|---|
| 6316 | // case 45926: break; |
|---|
| 6317 | // // Ahune - Slippery Floor |
|---|
| 6318 | // case 45945: break; |
|---|
| 6319 | // // Ahune's Shield |
|---|
| 6320 | // case 45954: break; |
|---|
| 6321 | // // Nether Vapor Lightning |
|---|
| 6322 | // case 45960: break; |
|---|
| 6323 | // // Darkness |
|---|
| 6324 | // case 45996: break; |
|---|
| 6325 | // // Summon Blood Elves Periodic |
|---|
| 6326 | // case 46041: break; |
|---|
| 6327 | // // Transform Visual Missile Periodic |
|---|
| 6328 | // case 46205: break; |
|---|
| 6329 | // // Find Opening Beam End |
|---|
| 6330 | // case 46333: break; |
|---|
| 6331 | // // Ice Spear Control Aura |
|---|
| 6332 | // case 46371: break; |
|---|
| 6333 | // // Hailstone Chill |
|---|
| 6334 | // case 46458: break; |
|---|
| 6335 | // // Hailstone Chill, Internal |
|---|
| 6336 | // case 46465: break; |
|---|
| 6337 | // // Chill, Internal Shifter |
|---|
| 6338 | // case 46549: break; |
|---|
| 6339 | // // Summon Ice Spear Knockback Delayer |
|---|
| 6340 | // case 46878: break; |
|---|
| 6341 | // // Burninate Effect |
|---|
| 6342 | // case 47214: break; |
|---|
| 6343 | // // Fizzcrank Practice Parachute |
|---|
| 6344 | // case 47228: break; |
|---|
| 6345 | // // Send Mug Control Aura |
|---|
| 6346 | // case 47369: break; |
|---|
| 6347 | // // Direbrew's Disarm (precast) |
|---|
| 6348 | // case 47407: break; |
|---|
| 6349 | // // Mole Machine Port Schedule |
|---|
| 6350 | // case 47489: break; |
|---|
| 6351 | // // Mole Machine Portal Schedule |
|---|
| 6352 | // case 49466: break; |
|---|
| 6353 | // // Drink Coffee |
|---|
| 6354 | // case 49472: break; |
|---|
| 6355 | // // Listening to Music |
|---|
| 6356 | // case 50493: break; |
|---|
| 6357 | // // Love Rocket Barrage |
|---|
| 6358 | // case 50530: break; |
|---|
| 6359 | default: |
|---|
| 6360 | break; |
|---|
| 6361 | } |
|---|
| 6362 | } |
|---|
| 6363 | |
|---|
| 6364 | void Aura::HandlePreventFleeing(bool apply, bool Real) |
|---|
| 6365 | { |
|---|
| 6366 | if(!Real) |
|---|
| 6367 | return; |
|---|
| 6368 | |
|---|
| 6369 | Unit::AuraList const& fearAuras = m_target->GetAurasByType(SPELL_AURA_MOD_FEAR); |
|---|
| 6370 | if( !fearAuras.empty() ) |
|---|
| 6371 | { |
|---|
| 6372 | if (apply) |
|---|
| 6373 | m_target->SetFeared(false, fearAuras.front()->GetCasterGUID()); |
|---|
| 6374 | else |
|---|
| 6375 | m_target->SetFeared(true); |
|---|
| 6376 | } |
|---|
| 6377 | } |
|---|
| 6378 | |
|---|
| 6379 | void Aura::HandleManaShield(bool apply, bool Real) |
|---|
| 6380 | { |
|---|
| 6381 | if(!Real) |
|---|
| 6382 | return; |
|---|
| 6383 | |
|---|
| 6384 | // prevent double apply bonuses |
|---|
| 6385 | if(apply && (m_target->GetTypeId()!=TYPEID_PLAYER || !((Player*)m_target)->GetSession()->PlayerLoading())) |
|---|
| 6386 | { |
|---|
| 6387 | if(Unit* caster = GetCaster()) |
|---|
| 6388 | { |
|---|
| 6389 | float DoneActualBenefit = 0.0f; |
|---|
| 6390 | switch(m_spellProto->SpellFamilyName) |
|---|
| 6391 | { |
|---|
| 6392 | case SPELLFAMILY_MAGE: |
|---|
| 6393 | if(m_spellProto->SpellFamilyFlags & 0x8000) |
|---|
| 6394 | { |
|---|
| 6395 | // Mana Shield |
|---|
| 6396 | // +50% from +spd bonus |
|---|
| 6397 | DoneActualBenefit = caster->SpellBaseDamageBonus(GetSpellSchoolMask(m_spellProto)) * 0.5f; |
|---|
| 6398 | break; |
|---|
| 6399 | } |
|---|
| 6400 | break; |
|---|
| 6401 | default: |
|---|
| 6402 | break; |
|---|
| 6403 | } |
|---|
| 6404 | |
|---|
| 6405 | DoneActualBenefit *= caster->CalculateLevelPenalty(GetSpellProto()); |
|---|
| 6406 | |
|---|
| 6407 | m_modifier.m_amount += (int32)DoneActualBenefit; |
|---|
| 6408 | } |
|---|
| 6409 | } |
|---|
| 6410 | } |
|---|
| 6411 | |
|---|
| 6412 | void Aura::HandleArenaPreparation(bool apply, bool Real) |
|---|
| 6413 | { |
|---|
| 6414 | if(!Real) |
|---|
| 6415 | return; |
|---|
| 6416 | |
|---|
| 6417 | if(apply) |
|---|
| 6418 | m_target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PREPARATION); |
|---|
| 6419 | else |
|---|
| 6420 | m_target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PREPARATION); |
|---|
| 6421 | } |
|---|