[37] | 1 | /* |
---|
[102] | 2 | * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/> |
---|
| 3 | * |
---|
[44] | 4 | * Copyright (C) 2008 Trinity <http://www.trinitycore.org/> |
---|
[37] | 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 |
---|
[161] | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
[37] | 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 |
---|
[161] | 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
[37] | 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" |
---|
[44] | 45 | #include "OutdoorPvP.h" |
---|
| 46 | #include "OutdoorPvPMgr.h" |
---|
[37] | 47 | #include "CreatureAI.h" |
---|
| 48 | #include "Util.h" |
---|
| 49 | #include "GridNotifiers.h" |
---|
| 50 | #include "GridNotifiersImpl.h" |
---|
| 51 | #include "CellImpl.h" |
---|
[174] | 52 | #include "TemporarySummon.h" |
---|
[37] | 53 | |
---|
| 54 | #define NULL_AURA_SLOT 0xFF |
---|
| 55 | |
---|
| 56 | pAuraHandler AuraHandler[TOTAL_AURAS]= |
---|
| 57 | { |
---|
| 58 | &Aura::HandleNULL, // 0 SPELL_AURA_NONE |
---|
| 59 | &Aura::HandleBindSight, // 1 SPELL_AURA_BIND_SIGHT |
---|
| 60 | &Aura::HandleModPossess, // 2 SPELL_AURA_MOD_POSSESS |
---|
| 61 | &Aura::HandlePeriodicDamage, // 3 SPELL_AURA_PERIODIC_DAMAGE |
---|
| 62 | &Aura::HandleAuraDummy, // 4 SPELL_AURA_DUMMY |
---|
| 63 | &Aura::HandleModConfuse, // 5 SPELL_AURA_MOD_CONFUSE |
---|
| 64 | &Aura::HandleModCharm, // 6 SPELL_AURA_MOD_CHARM |
---|
| 65 | &Aura::HandleModFear, // 7 SPELL_AURA_MOD_FEAR |
---|
| 66 | &Aura::HandlePeriodicHeal, // 8 SPELL_AURA_PERIODIC_HEAL |
---|
| 67 | &Aura::HandleModAttackSpeed, // 9 SPELL_AURA_MOD_ATTACKSPEED |
---|
| 68 | &Aura::HandleModThreat, // 10 SPELL_AURA_MOD_THREAT |
---|
| 69 | &Aura::HandleModTaunt, // 11 SPELL_AURA_MOD_TAUNT |
---|
| 70 | &Aura::HandleAuraModStun, // 12 SPELL_AURA_MOD_STUN |
---|
| 71 | &Aura::HandleModDamageDone, // 13 SPELL_AURA_MOD_DAMAGE_DONE |
---|
| 72 | &Aura::HandleNoImmediateEffect, // 14 SPELL_AURA_MOD_DAMAGE_TAKEN implemented in Unit::MeleeDamageBonus and Unit::SpellDamageBonus |
---|
| 73 | &Aura::HandleNoImmediateEffect, // 15 SPELL_AURA_DAMAGE_SHIELD implemented in Unit::DoAttackDamage |
---|
| 74 | &Aura::HandleModStealth, // 16 SPELL_AURA_MOD_STEALTH |
---|
| 75 | &Aura::HandleNoImmediateEffect, // 17 SPELL_AURA_MOD_STEALTH_DETECT |
---|
| 76 | &Aura::HandleInvisibility, // 18 SPELL_AURA_MOD_INVISIBILITY |
---|
| 77 | &Aura::HandleInvisibilityDetect, // 19 SPELL_AURA_MOD_INVISIBILITY_DETECTION |
---|
| 78 | &Aura::HandleAuraModTotalHealthPercentRegen, // 20 SPELL_AURA_OBS_MOD_HEALTH |
---|
| 79 | &Aura::HandleAuraModTotalManaPercentRegen, // 21 SPELL_AURA_OBS_MOD_MANA |
---|
| 80 | &Aura::HandleAuraModResistance, // 22 SPELL_AURA_MOD_RESISTANCE |
---|
| 81 | &Aura::HandlePeriodicTriggerSpell, // 23 SPELL_AURA_PERIODIC_TRIGGER_SPELL |
---|
| 82 | &Aura::HandlePeriodicEnergize, // 24 SPELL_AURA_PERIODIC_ENERGIZE |
---|
| 83 | &Aura::HandleAuraModPacify, // 25 SPELL_AURA_MOD_PACIFY |
---|
| 84 | &Aura::HandleAuraModRoot, // 26 SPELL_AURA_MOD_ROOT |
---|
| 85 | &Aura::HandleAuraModSilence, // 27 SPELL_AURA_MOD_SILENCE |
---|
| 86 | &Aura::HandleNoImmediateEffect, // 28 SPELL_AURA_REFLECT_SPELLS implement in Unit::SpellHitResult |
---|
| 87 | &Aura::HandleAuraModStat, // 29 SPELL_AURA_MOD_STAT |
---|
| 88 | &Aura::HandleAuraModSkill, // 30 SPELL_AURA_MOD_SKILL |
---|
| 89 | &Aura::HandleAuraModIncreaseSpeed, // 31 SPELL_AURA_MOD_INCREASE_SPEED |
---|
| 90 | &Aura::HandleAuraModIncreaseMountedSpeed, // 32 SPELL_AURA_MOD_INCREASE_MOUNTED_SPEED |
---|
| 91 | &Aura::HandleAuraModDecreaseSpeed, // 33 SPELL_AURA_MOD_DECREASE_SPEED |
---|
| 92 | &Aura::HandleAuraModIncreaseHealth, // 34 SPELL_AURA_MOD_INCREASE_HEALTH |
---|
| 93 | &Aura::HandleAuraModIncreaseEnergy, // 35 SPELL_AURA_MOD_INCREASE_ENERGY |
---|
| 94 | &Aura::HandleAuraModShapeshift, // 36 SPELL_AURA_MOD_SHAPESHIFT |
---|
| 95 | &Aura::HandleAuraModEffectImmunity, // 37 SPELL_AURA_EFFECT_IMMUNITY |
---|
| 96 | &Aura::HandleAuraModStateImmunity, // 38 SPELL_AURA_STATE_IMMUNITY |
---|
| 97 | &Aura::HandleAuraModSchoolImmunity, // 39 SPELL_AURA_SCHOOL_IMMUNITY |
---|
| 98 | &Aura::HandleAuraModDmgImmunity, // 40 SPELL_AURA_DAMAGE_IMMUNITY |
---|
| 99 | &Aura::HandleAuraModDispelImmunity, // 41 SPELL_AURA_DISPEL_IMMUNITY |
---|
| 100 | &Aura::HandleAuraProcTriggerSpell, // 42 SPELL_AURA_PROC_TRIGGER_SPELL implemented in Unit::ProcDamageAndSpellFor and Unit::HandleProcTriggerSpell |
---|
| 101 | &Aura::HandleNoImmediateEffect, // 43 SPELL_AURA_PROC_TRIGGER_DAMAGE implemented in Unit::ProcDamageAndSpellFor |
---|
| 102 | &Aura::HandleAuraTrackCreatures, // 44 SPELL_AURA_TRACK_CREATURES |
---|
| 103 | &Aura::HandleAuraTrackResources, // 45 SPELL_AURA_TRACK_RESOURCES |
---|
| 104 | &Aura::HandleUnused, // 46 SPELL_AURA_MOD_PARRY_SKILL obsolete? |
---|
| 105 | &Aura::HandleAuraModParryPercent, // 47 SPELL_AURA_MOD_PARRY_PERCENT |
---|
| 106 | &Aura::HandleUnused, // 48 SPELL_AURA_MOD_DODGE_SKILL obsolete? |
---|
| 107 | &Aura::HandleAuraModDodgePercent, // 49 SPELL_AURA_MOD_DODGE_PERCENT |
---|
| 108 | &Aura::HandleUnused, // 50 SPELL_AURA_MOD_BLOCK_SKILL obsolete? |
---|
| 109 | &Aura::HandleAuraModBlockPercent, // 51 SPELL_AURA_MOD_BLOCK_PERCENT |
---|
| 110 | &Aura::HandleAuraModCritPercent, // 52 SPELL_AURA_MOD_CRIT_PERCENT |
---|
| 111 | &Aura::HandlePeriodicLeech, // 53 SPELL_AURA_PERIODIC_LEECH |
---|
| 112 | &Aura::HandleModHitChance, // 54 SPELL_AURA_MOD_HIT_CHANCE |
---|
| 113 | &Aura::HandleModSpellHitChance, // 55 SPELL_AURA_MOD_SPELL_HIT_CHANCE |
---|
| 114 | &Aura::HandleAuraTransform, // 56 SPELL_AURA_TRANSFORM |
---|
| 115 | &Aura::HandleModSpellCritChance, // 57 SPELL_AURA_MOD_SPELL_CRIT_CHANCE |
---|
| 116 | &Aura::HandleAuraModIncreaseSwimSpeed, // 58 SPELL_AURA_MOD_INCREASE_SWIM_SPEED |
---|
| 117 | &Aura::HandleNoImmediateEffect, // 59 SPELL_AURA_MOD_DAMAGE_DONE_CREATURE implemented in Unit::MeleeDamageBonus and Unit::SpellDamageBonus |
---|
| 118 | &Aura::HandleAuraModPacifyAndSilence, // 60 SPELL_AURA_MOD_PACIFY_SILENCE |
---|
| 119 | &Aura::HandleAuraModScale, // 61 SPELL_AURA_MOD_SCALE |
---|
| 120 | &Aura::HandleNULL, // 62 SPELL_AURA_PERIODIC_HEALTH_FUNNEL |
---|
| 121 | &Aura::HandleUnused, // 63 SPELL_AURA_PERIODIC_MANA_FUNNEL obsolete? |
---|
| 122 | &Aura::HandlePeriodicManaLeech, // 64 SPELL_AURA_PERIODIC_MANA_LEECH |
---|
| 123 | &Aura::HandleModCastingSpeed, // 65 SPELL_AURA_MOD_CASTING_SPEED |
---|
| 124 | &Aura::HandleFeignDeath, // 66 SPELL_AURA_FEIGN_DEATH |
---|
| 125 | &Aura::HandleAuraModDisarm, // 67 SPELL_AURA_MOD_DISARM |
---|
| 126 | &Aura::HandleAuraModStalked, // 68 SPELL_AURA_MOD_STALKED |
---|
| 127 | &Aura::HandleSchoolAbsorb, // 69 SPELL_AURA_SCHOOL_ABSORB implemented in Unit::CalcAbsorbResist |
---|
| 128 | &Aura::HandleUnused, // 70 SPELL_AURA_EXTRA_ATTACKS Useless, used by only one spell that has only visual effect |
---|
| 129 | &Aura::HandleModSpellCritChanceShool, // 71 SPELL_AURA_MOD_SPELL_CRIT_CHANCE_SCHOOL |
---|
| 130 | &Aura::HandleModPowerCostPCT, // 72 SPELL_AURA_MOD_POWER_COST_SCHOOL_PCT |
---|
| 131 | &Aura::HandleModPowerCost, // 73 SPELL_AURA_MOD_POWER_COST_SCHOOL |
---|
| 132 | &Aura::HandleNoImmediateEffect, // 74 SPELL_AURA_REFLECT_SPELLS_SCHOOL implemented in Unit::SpellHitResult |
---|
| 133 | &Aura::HandleNoImmediateEffect, // 75 SPELL_AURA_MOD_LANGUAGE |
---|
| 134 | &Aura::HandleFarSight, // 76 SPELL_AURA_FAR_SIGHT |
---|
| 135 | &Aura::HandleModMechanicImmunity, // 77 SPELL_AURA_MECHANIC_IMMUNITY |
---|
| 136 | &Aura::HandleAuraMounted, // 78 SPELL_AURA_MOUNTED |
---|
| 137 | &Aura::HandleModDamagePercentDone, // 79 SPELL_AURA_MOD_DAMAGE_PERCENT_DONE |
---|
| 138 | &Aura::HandleModPercentStat, // 80 SPELL_AURA_MOD_PERCENT_STAT |
---|
| 139 | &Aura::HandleNoImmediateEffect, // 81 SPELL_AURA_SPLIT_DAMAGE_PCT |
---|
| 140 | &Aura::HandleWaterBreathing, // 82 SPELL_AURA_WATER_BREATHING |
---|
| 141 | &Aura::HandleModBaseResistance, // 83 SPELL_AURA_MOD_BASE_RESISTANCE |
---|
| 142 | &Aura::HandleModRegen, // 84 SPELL_AURA_MOD_REGEN |
---|
| 143 | &Aura::HandleModPowerRegen, // 85 SPELL_AURA_MOD_POWER_REGEN |
---|
| 144 | &Aura::HandleChannelDeathItem, // 86 SPELL_AURA_CHANNEL_DEATH_ITEM |
---|
| 145 | &Aura::HandleNoImmediateEffect, // 87 SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN implemented in Unit::MeleeDamageBonus and Unit::SpellDamageBonus |
---|
| 146 | &Aura::HandleNoImmediateEffect, // 88 SPELL_AURA_MOD_HEALTH_REGEN_PERCENT |
---|
| 147 | &Aura::HandlePeriodicDamagePCT, // 89 SPELL_AURA_PERIODIC_DAMAGE_PERCENT |
---|
| 148 | &Aura::HandleUnused, // 90 SPELL_AURA_MOD_RESIST_CHANCE Useless |
---|
| 149 | &Aura::HandleNoImmediateEffect, // 91 SPELL_AURA_MOD_DETECT_RANGE implemented in Creature::GetAttackDistance |
---|
| 150 | &Aura::HandlePreventFleeing, // 92 SPELL_AURA_PREVENTS_FLEEING |
---|
| 151 | &Aura::HandleModUnattackable, // 93 SPELL_AURA_MOD_UNATTACKABLE |
---|
| 152 | &Aura::HandleNoImmediateEffect, // 94 SPELL_AURA_INTERRUPT_REGEN implemented in Player::RegenerateAll |
---|
| 153 | &Aura::HandleAuraGhost, // 95 SPELL_AURA_GHOST |
---|
| 154 | &Aura::HandleNoImmediateEffect, // 96 SPELL_AURA_SPELL_MAGNET implemented in Spell::SelectMagnetTarget |
---|
| 155 | &Aura::HandleManaShield, // 97 SPELL_AURA_MANA_SHIELD implemented in Unit::CalcAbsorbResist |
---|
| 156 | &Aura::HandleAuraModSkill, // 98 SPELL_AURA_MOD_SKILL_TALENT |
---|
| 157 | &Aura::HandleAuraModAttackPower, // 99 SPELL_AURA_MOD_ATTACK_POWER |
---|
| 158 | &Aura::HandleUnused, //100 SPELL_AURA_AURAS_VISIBLE obsolete? all player can see all auras now |
---|
| 159 | &Aura::HandleModResistancePercent, //101 SPELL_AURA_MOD_RESISTANCE_PCT |
---|
| 160 | &Aura::HandleNoImmediateEffect, //102 SPELL_AURA_MOD_MELEE_ATTACK_POWER_VERSUS implemented in Unit::MeleeDamageBonus |
---|
| 161 | &Aura::HandleAuraModTotalThreat, //103 SPELL_AURA_MOD_TOTAL_THREAT |
---|
| 162 | &Aura::HandleAuraWaterWalk, //104 SPELL_AURA_WATER_WALK |
---|
| 163 | &Aura::HandleAuraFeatherFall, //105 SPELL_AURA_FEATHER_FALL |
---|
| 164 | &Aura::HandleAuraHover, //106 SPELL_AURA_HOVER |
---|
| 165 | &Aura::HandleAddModifier, //107 SPELL_AURA_ADD_FLAT_MODIFIER |
---|
| 166 | &Aura::HandleAddModifier, //108 SPELL_AURA_ADD_PCT_MODIFIER |
---|
| 167 | &Aura::HandleNoImmediateEffect, //109 SPELL_AURA_ADD_TARGET_TRIGGER |
---|
| 168 | &Aura::HandleModPowerRegenPCT, //110 SPELL_AURA_MOD_POWER_REGEN_PERCENT |
---|
| 169 | &Aura::HandleNULL, //111 SPELL_AURA_ADD_CASTER_HIT_TRIGGER |
---|
| 170 | &Aura::HandleNoImmediateEffect, //112 SPELL_AURA_OVERRIDE_CLASS_SCRIPTS |
---|
| 171 | &Aura::HandleNoImmediateEffect, //113 SPELL_AURA_MOD_RANGED_DAMAGE_TAKEN implemented in Unit::MeleeDamageBonus |
---|
| 172 | &Aura::HandleNoImmediateEffect, //114 SPELL_AURA_MOD_RANGED_DAMAGE_TAKEN_PCT implemented in Unit::MeleeDamageBonus |
---|
| 173 | &Aura::HandleAuraHealing, //115 SPELL_AURA_MOD_HEALING |
---|
| 174 | &Aura::HandleNoImmediateEffect, //116 SPELL_AURA_MOD_REGEN_DURING_COMBAT |
---|
| 175 | &Aura::HandleNoImmediateEffect, //117 SPELL_AURA_MOD_MECHANIC_RESISTANCE implemented in Unit::MagicSpellHitResult |
---|
| 176 | &Aura::HandleAuraHealingPct, //118 SPELL_AURA_MOD_HEALING_PCT |
---|
| 177 | &Aura::HandleUnused, //119 SPELL_AURA_SHARE_PET_TRACKING useless |
---|
| 178 | &Aura::HandleAuraUntrackable, //120 SPELL_AURA_UNTRACKABLE |
---|
| 179 | &Aura::HandleAuraEmpathy, //121 SPELL_AURA_EMPATHY |
---|
| 180 | &Aura::HandleModOffhandDamagePercent, //122 SPELL_AURA_MOD_OFFHAND_DAMAGE_PCT |
---|
| 181 | &Aura::HandleModTargetResistance, //123 SPELL_AURA_MOD_TARGET_RESISTANCE |
---|
| 182 | &Aura::HandleAuraModRangedAttackPower, //124 SPELL_AURA_MOD_RANGED_ATTACK_POWER |
---|
| 183 | &Aura::HandleNoImmediateEffect, //125 SPELL_AURA_MOD_MELEE_DAMAGE_TAKEN implemented in Unit::MeleeDamageBonus |
---|
| 184 | &Aura::HandleNoImmediateEffect, //126 SPELL_AURA_MOD_MELEE_DAMAGE_TAKEN_PCT implemented in Unit::MeleeDamageBonus |
---|
| 185 | &Aura::HandleNoImmediateEffect, //127 SPELL_AURA_RANGED_ATTACK_POWER_ATTACKER_BONUS implemented in Unit::MeleeDamageBonus |
---|
| 186 | &Aura::HandleModPossessPet, //128 SPELL_AURA_MOD_POSSESS_PET |
---|
| 187 | &Aura::HandleAuraModIncreaseSpeed, //129 SPELL_AURA_MOD_SPEED_ALWAYS |
---|
| 188 | &Aura::HandleAuraModIncreaseMountedSpeed, //130 SPELL_AURA_MOD_MOUNTED_SPEED_ALWAYS |
---|
| 189 | &Aura::HandleNoImmediateEffect, //131 SPELL_AURA_MOD_RANGED_ATTACK_POWER_VERSUS implemented in Unit::MeleeDamageBonus |
---|
| 190 | &Aura::HandleAuraModIncreaseEnergyPercent, //132 SPELL_AURA_MOD_INCREASE_ENERGY_PERCENT |
---|
| 191 | &Aura::HandleAuraModIncreaseHealthPercent, //133 SPELL_AURA_MOD_INCREASE_HEALTH_PERCENT |
---|
| 192 | &Aura::HandleAuraModRegenInterrupt, //134 SPELL_AURA_MOD_MANA_REGEN_INTERRUPT |
---|
| 193 | &Aura::HandleModHealingDone, //135 SPELL_AURA_MOD_HEALING_DONE |
---|
| 194 | &Aura::HandleAuraHealingPct, //136 SPELL_AURA_MOD_HEALING_DONE_PERCENT implemented in Unit::SpellHealingBonus |
---|
| 195 | &Aura::HandleModTotalPercentStat, //137 SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE |
---|
| 196 | &Aura::HandleHaste, //138 SPELL_AURA_MOD_HASTE |
---|
| 197 | &Aura::HandleForceReaction, //139 SPELL_AURA_FORCE_REACTION |
---|
| 198 | &Aura::HandleAuraModRangedHaste, //140 SPELL_AURA_MOD_RANGED_HASTE |
---|
| 199 | &Aura::HandleRangedAmmoHaste, //141 SPELL_AURA_MOD_RANGED_AMMO_HASTE |
---|
| 200 | &Aura::HandleAuraModBaseResistancePCT, //142 SPELL_AURA_MOD_BASE_RESISTANCE_PCT |
---|
| 201 | &Aura::HandleAuraModResistanceExclusive, //143 SPELL_AURA_MOD_RESISTANCE_EXCLUSIVE |
---|
| 202 | &Aura::HandleNoImmediateEffect, //144 SPELL_AURA_SAFE_FALL implemented in WorldSession::HandleMovementOpcodes |
---|
| 203 | &Aura::HandleUnused, //145 SPELL_AURA_CHARISMA obsolete? |
---|
| 204 | &Aura::HandleUnused, //146 SPELL_AURA_PERSUADED obsolete? |
---|
| 205 | &Aura::HandleNULL, //147 SPELL_AURA_ADD_CREATURE_IMMUNITY |
---|
| 206 | &Aura::HandleAuraRetainComboPoints, //148 SPELL_AURA_RETAIN_COMBO_POINTS |
---|
| 207 | &Aura::HandleNoImmediateEffect, //149 SPELL_AURA_RESIST_PUSHBACK |
---|
| 208 | &Aura::HandleShieldBlockValue, //150 SPELL_AURA_MOD_SHIELD_BLOCKVALUE_PCT |
---|
| 209 | &Aura::HandleAuraTrackStealthed, //151 SPELL_AURA_TRACK_STEALTHED |
---|
| 210 | &Aura::HandleNoImmediateEffect, //152 SPELL_AURA_MOD_DETECTED_RANGE implemented in Creature::GetAttackDistance |
---|
| 211 | &Aura::HandleNoImmediateEffect, //153 SPELL_AURA_SPLIT_DAMAGE_FLAT |
---|
| 212 | &Aura::HandleNoImmediateEffect, //154 SPELL_AURA_MOD_STEALTH_LEVEL |
---|
| 213 | &Aura::HandleNoImmediateEffect, //155 SPELL_AURA_MOD_WATER_BREATHING |
---|
| 214 | &Aura::HandleNoImmediateEffect, //156 SPELL_AURA_MOD_REPUTATION_GAIN |
---|
| 215 | &Aura::HandleNULL, //157 SPELL_AURA_PET_DAMAGE_MULTI |
---|
| 216 | &Aura::HandleShieldBlockValue, //158 SPELL_AURA_MOD_SHIELD_BLOCKVALUE |
---|
| 217 | &Aura::HandleNoImmediateEffect, //159 SPELL_AURA_NO_PVP_CREDIT only for Honorless Target spell |
---|
| 218 | &Aura::HandleNoImmediateEffect, //160 SPELL_AURA_MOD_AOE_AVOIDANCE implemended in Unit::MagicSpellHitResult |
---|
| 219 | &Aura::HandleNoImmediateEffect, //161 SPELL_AURA_MOD_HEALTH_REGEN_IN_COMBAT |
---|
| 220 | &Aura::HandleAuraPowerBurn, //162 SPELL_AURA_POWER_BURN_MANA |
---|
| 221 | &Aura::HandleNoImmediateEffect, //163 SPELL_AURA_MOD_CRIT_DAMAGE_BONUS_MELEE |
---|
| 222 | &Aura::HandleUnused, //164 useless, only one test spell |
---|
| 223 | &Aura::HandleAuraAttackPowerAttacker, //165 SPELL_AURA_MELEE_ATTACK_POWER_ATTACKER_BONUS implemented in Unit::MeleeDamageBonus |
---|
| 224 | &Aura::HandleAuraModAttackPowerPercent, //166 SPELL_AURA_MOD_ATTACK_POWER_PCT |
---|
| 225 | &Aura::HandleAuraModRangedAttackPowerPercent, //167 SPELL_AURA_MOD_RANGED_ATTACK_POWER_PCT |
---|
| 226 | &Aura::HandleNoImmediateEffect, //168 SPELL_AURA_MOD_DAMAGE_DONE_VERSUS implemented in Unit::SpellDamageBonus, Unit::MeleeDamageBonus |
---|
| 227 | &Aura::HandleNoImmediateEffect, //169 SPELL_AURA_MOD_CRIT_PERCENT_VERSUS implemented in Unit::DealDamageBySchool, Unit::DoAttackDamage, Unit::SpellCriticalBonus |
---|
| 228 | &Aura::HandleNULL, //170 SPELL_AURA_DETECT_AMORE only for Detect Amore spell |
---|
| 229 | &Aura::HandleAuraModIncreaseSpeed, //171 SPELL_AURA_MOD_SPEED_NOT_STACK |
---|
| 230 | &Aura::HandleAuraModIncreaseMountedSpeed, //172 SPELL_AURA_MOD_MOUNTED_SPEED_NOT_STACK |
---|
| 231 | &Aura::HandleUnused, //173 SPELL_AURA_ALLOW_CHAMPION_SPELLS only for Proclaim Champion spell |
---|
| 232 | &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) |
---|
| 233 | &Aura::HandleModSpellHealingPercentFromStat, //175 SPELL_AURA_MOD_SPELL_HEALING_OF_STAT_PERCENT implemented in Unit::SpellBaseHealingBonus |
---|
| 234 | &Aura::HandleSpiritOfRedemption, //176 SPELL_AURA_SPIRIT_OF_REDEMPTION only for Spirit of Redemption spell, die at aura end |
---|
| 235 | &Aura::HandleNULL, //177 SPELL_AURA_AOE_CHARM |
---|
| 236 | &Aura::HandleNoImmediateEffect, //178 SPELL_AURA_MOD_DEBUFF_RESISTANCE implemented in Unit::MagicSpellHitResult |
---|
| 237 | &Aura::HandleNoImmediateEffect, //179 SPELL_AURA_MOD_ATTACKER_SPELL_CRIT_CHANCE implemented in Unit::SpellCriticalBonus |
---|
| 238 | &Aura::HandleNoImmediateEffect, //180 SPELL_AURA_MOD_FLAT_SPELL_DAMAGE_VERSUS implemented in Unit::SpellDamageBonus |
---|
| 239 | &Aura::HandleUnused, //181 SPELL_AURA_MOD_FLAT_SPELL_CRIT_DAMAGE_VERSUS unused |
---|
| 240 | &Aura::HandleAuraModResistenceOfStatPercent, //182 SPELL_AURA_MOD_RESISTANCE_OF_STAT_PERCENT |
---|
| 241 | &Aura::HandleNULL, //183 SPELL_AURA_MOD_CRITICAL_THREAT |
---|
| 242 | &Aura::HandleNoImmediateEffect, //184 SPELL_AURA_MOD_ATTACKER_MELEE_HIT_CHANCE implemented in Unit::RollMeleeOutcomeAgainst |
---|
| 243 | &Aura::HandleNoImmediateEffect, //185 SPELL_AURA_MOD_ATTACKER_RANGED_HIT_CHANCE implemented in Unit::RollMeleeOutcomeAgainst |
---|
| 244 | &Aura::HandleNoImmediateEffect, //186 SPELL_AURA_MOD_ATTACKER_SPELL_HIT_CHANCE implemented in Unit::MagicSpellHitResult |
---|
| 245 | &Aura::HandleNoImmediateEffect, //187 SPELL_AURA_MOD_ATTACKER_MELEE_CRIT_CHANCE implemended in Unit::GetUnitCriticalChance |
---|
| 246 | &Aura::HandleNoImmediateEffect, //188 SPELL_AURA_MOD_ATTACKER_RANGED_CRIT_CHANCE implemented in Unit::GetUnitCriticalChance |
---|
| 247 | &Aura::HandleModRating, //189 SPELL_AURA_MOD_RATING |
---|
| 248 | &Aura::HandleNULL, //190 SPELL_AURA_MOD_FACTION_REPUTATION_GAIN |
---|
| 249 | &Aura::HandleAuraModUseNormalSpeed, //191 SPELL_AURA_USE_NORMAL_MOVEMENT_SPEED |
---|
| 250 | &Aura::HandleModMeleeRangedSpeedPct, //192 SPELL_AURA_HASTE_MELEE |
---|
| 251 | &Aura::HandleModCombatSpeedPct, //193 SPELL_AURA_MELEE_SLOW (in fact combat (any type attack) speed pct) |
---|
| 252 | &Aura::HandleUnused, //194 SPELL_AURA_MOD_DEPRICATED_1 not used now (old SPELL_AURA_MOD_SPELL_DAMAGE_OF_INTELLECT) |
---|
| 253 | &Aura::HandleUnused, //195 SPELL_AURA_MOD_DEPRICATED_2 not used now (old SPELL_AURA_MOD_SPELL_HEALING_OF_INTELLECT) |
---|
| 254 | &Aura::HandleNULL, //196 SPELL_AURA_MOD_COOLDOWN |
---|
| 255 | &Aura::HandleNoImmediateEffect, //197 SPELL_AURA_MOD_ATTACKER_SPELL_AND_WEAPON_CRIT_CHANCE implemented in Unit::SpellCriticalBonus Unit::GetUnitCriticalChance |
---|
| 256 | &Aura::HandleUnused, //198 SPELL_AURA_MOD_ALL_WEAPON_SKILLS |
---|
| 257 | &Aura::HandleNoImmediateEffect, //199 SPELL_AURA_MOD_INCREASES_SPELL_PCT_TO_HIT implemented in Unit::MagicSpellHitResult |
---|
| 258 | &Aura::HandleNoImmediateEffect, //200 SPELL_AURA_MOD_XP_PCT implemented in Player::GiveXP |
---|
| 259 | &Aura::HandleAuraAllowFlight, //201 SPELL_AURA_FLY this aura enable flight mode... |
---|
| 260 | &Aura::HandleNoImmediateEffect, //202 SPELL_AURA_CANNOT_BE_DODGED implemented in Unit::RollPhysicalOutcomeAgainst |
---|
| 261 | &Aura::HandleNoImmediateEffect, //203 SPELL_AURA_MOD_ATTACKER_MELEE_CRIT_DAMAGE implemented in Unit::DoAttackDamage |
---|
| 262 | &Aura::HandleNoImmediateEffect, //204 SPELL_AURA_MOD_ATTACKER_RANGED_CRIT_DAMAGE implemented in Unit::DoAttackDamage |
---|
| 263 | &Aura::HandleNULL, //205 vulnerable to school dmg? |
---|
| 264 | &Aura::HandleNULL, //206 SPELL_AURA_MOD_SPEED_MOUNTED |
---|
| 265 | &Aura::HandleAuraModIncreaseFlightSpeed, //207 SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED |
---|
| 266 | &Aura::HandleAuraModIncreaseFlightSpeed, //208 SPELL_AURA_MOD_SPEED_FLIGHT, used only in spell: Flight Form (Passive) |
---|
| 267 | &Aura::HandleAuraModIncreaseFlightSpeed, //209 SPELL_AURA_MOD_FLIGHT_SPEED_ALWAYS |
---|
| 268 | &Aura::HandleNULL, //210 Commentator's Command |
---|
| 269 | &Aura::HandleAuraModIncreaseFlightSpeed, //211 SPELL_AURA_MOD_FLIGHT_SPEED_NOT_STACK |
---|
| 270 | &Aura::HandleAuraModRangedAttackPowerOfStatPercent, //212 SPELL_AURA_MOD_RANGED_ATTACK_POWER_OF_STAT_PERCENT |
---|
| 271 | &Aura::HandleNoImmediateEffect, //213 SPELL_AURA_MOD_RAGE_FROM_DAMAGE_DEALT implemented in Player::RewardRage |
---|
| 272 | &Aura::HandleNULL, //214 Tamed Pet Passive |
---|
| 273 | &Aura::HandleArenaPreparation, //215 SPELL_AURA_ARENA_PREPARATION |
---|
| 274 | &Aura::HandleModCastingSpeed, //216 SPELL_AURA_HASTE_SPELLS |
---|
| 275 | &Aura::HandleUnused, //217 unused |
---|
| 276 | &Aura::HandleAuraModRangedHaste, //218 SPELL_AURA_HASTE_RANGED |
---|
| 277 | &Aura::HandleModManaRegen, //219 SPELL_AURA_MOD_MANA_REGEN_FROM_STAT |
---|
| 278 | &Aura::HandleNULL, //220 SPELL_AURA_MOD_RATING_FROM_STAT |
---|
| 279 | &Aura::HandleNULL, //221 ignored |
---|
| 280 | &Aura::HandleUnused, //222 unused |
---|
| 281 | &Aura::HandleNULL, //223 Cold Stare |
---|
| 282 | &Aura::HandleUnused, //224 unused |
---|
| 283 | &Aura::HandleNoImmediateEffect, //225 SPELL_AURA_PRAYER_OF_MENDING |
---|
| 284 | &Aura::HandleAuraPeriodicDummy, //226 SPELL_AURA_PERIODIC_DUMMY |
---|
| 285 | &Aura::HandleNULL, //227 periodic trigger spell |
---|
| 286 | &Aura::HandleNoImmediateEffect, //228 stealth detection |
---|
| 287 | &Aura::HandleNULL, //229 SPELL_AURA_MOD_AOE_DAMAGE_AVOIDANCE |
---|
| 288 | &Aura::HandleAuraModIncreaseMaxHealth, //230 Commanding Shout |
---|
| 289 | &Aura::HandleNULL, //231 |
---|
| 290 | &Aura::HandleNoImmediateEffect, //232 SPELL_AURA_MECHANIC_DURATION_MOD implement in Unit::CalculateSpellDuration |
---|
| 291 | &Aura::HandleNULL, //233 set model id to the one of the creature with id m_modifier.m_miscvalue |
---|
| 292 | &Aura::HandleNoImmediateEffect, //234 SPELL_AURA_MECHANIC_DURATION_MOD_NOT_STACK implement in Unit::CalculateSpellDuration |
---|
| 293 | &Aura::HandleAuraModDispelResist, //235 SPELL_AURA_MOD_DISPEL_RESIST implement in Unit::MagicSpellHitResult |
---|
| 294 | &Aura::HandleUnused, //236 unused |
---|
| 295 | &Aura::HandleModSpellDamagePercentFromAttackPower, //237 SPELL_AURA_MOD_SPELL_DAMAGE_OF_ATTACK_POWER implemented in Unit::SpellBaseDamageBonus |
---|
| 296 | &Aura::HandleModSpellHealingPercentFromAttackPower, //238 SPELL_AURA_MOD_SPELL_HEALING_OF_ATTACK_POWER implemented in Unit::SpellBaseHealingBonus |
---|
| 297 | &Aura::HandleAuraModScale, //239 SPELL_AURA_MOD_SCALE_2 only in Noggenfogger Elixir (16595) before 2.3.0 aura 61 |
---|
| 298 | &Aura::HandleAuraModExpertise, //240 SPELL_AURA_MOD_EXPERTISE |
---|
| 299 | &Aura::HandleForceMoveForward, //241 Forces the player to move forward |
---|
| 300 | &Aura::HandleUnused, //242 SPELL_AURA_MOD_SPELL_DAMAGE_FROM_HEALING |
---|
| 301 | &Aura::HandleUnused, //243 used by two test spells |
---|
| 302 | &Aura::HandleComprehendLanguage, //244 Comprehend language |
---|
| 303 | &Aura::HandleUnused, //245 SPELL_AURA_MOD_DURATION_OF_MAGIC_EFFECTS |
---|
| 304 | &Aura::HandleUnused, //246 unused |
---|
| 305 | &Aura::HandleUnused, //247 unused |
---|
| 306 | &Aura::HandleNoImmediateEffect, //248 SPELL_AURA_MOD_COMBAT_RESULT_CHANCE implemented in Unit::RollMeleeOutcomeAgainst |
---|
| 307 | &Aura::HandleNULL, //249 |
---|
| 308 | &Aura::HandleAuraModIncreaseHealth, //250 SPELL_AURA_MOD_INCREASE_HEALTH_2 |
---|
| 309 | &Aura::HandleNULL, //251 SPELL_AURA_MOD_ENEMY_DODGE |
---|
| 310 | &Aura::HandleUnused, //252 unused |
---|
| 311 | &Aura::HandleUnused, //253 unused |
---|
| 312 | &Aura::HandleUnused, //254 unused |
---|
| 313 | &Aura::HandleUnused, //255 unused |
---|
| 314 | &Aura::HandleUnused, //256 unused |
---|
| 315 | &Aura::HandleUnused, //257 unused |
---|
| 316 | &Aura::HandleUnused, //258 unused |
---|
| 317 | &Aura::HandleUnused, //259 unused |
---|
| 318 | &Aura::HandleUnused, //260 unused |
---|
| 319 | &Aura::HandleNULL //261 SPELL_AURA_261 some phased state (44856 spell) |
---|
| 320 | }; |
---|
| 321 | |
---|
| 322 | Aura::Aura(SpellEntry const* spellproto, uint32 eff, int32 *currentBasePoints, Unit *target, Unit *caster, Item* castItem) : |
---|
| 323 | m_procCharges(0), m_spellmod(NULL), m_effIndex(eff), m_caster_guid(0), m_target(target), |
---|
| 324 | m_timeCla(1000), m_castItemGuid(castItem?castItem->GetGUID():0), m_auraSlot(MAX_AURAS), |
---|
| 325 | m_positive(false), m_permanent(false), m_isPeriodic(false), m_isTrigger(false), m_isAreaAura(false), |
---|
| 326 | m_isPersistent(false), m_updated(false), m_removeMode(AURA_REMOVE_BY_DEFAULT), m_isRemovedOnShapeLost(true), m_in_use(false), |
---|
| 327 | m_periodicTimer(0), m_PeriodicEventId(0), m_AuraDRGroup(DIMINISHING_NONE) |
---|
| 328 | { |
---|
| 329 | assert(target); |
---|
| 330 | |
---|
| 331 | assert(spellproto && spellproto == sSpellStore.LookupEntry( spellproto->Id ) && "`info` must be pointer to sSpellStore element"); |
---|
| 332 | |
---|
| 333 | m_spellProto = spellproto; |
---|
| 334 | |
---|
| 335 | m_currentBasePoints = currentBasePoints ? *currentBasePoints : m_spellProto->EffectBasePoints[eff]; |
---|
| 336 | |
---|
| 337 | m_isPassive = IsPassiveSpell(GetId()); |
---|
| 338 | m_positive = IsPositiveEffect(GetId(), m_effIndex); |
---|
| 339 | |
---|
| 340 | m_applyTime = time(NULL); |
---|
| 341 | |
---|
| 342 | int32 damage; |
---|
| 343 | if(!caster) |
---|
| 344 | { |
---|
| 345 | m_caster_guid = target->GetGUID(); |
---|
| 346 | damage = m_currentBasePoints+1; // stored value-1 |
---|
| 347 | m_maxduration = target->CalculateSpellDuration(m_spellProto, m_effIndex, target); |
---|
| 348 | } |
---|
| 349 | else |
---|
| 350 | { |
---|
| 351 | m_caster_guid = caster->GetGUID(); |
---|
| 352 | |
---|
| 353 | damage = caster->CalculateSpellDamage(m_spellProto,m_effIndex,m_currentBasePoints,target); |
---|
| 354 | m_maxduration = caster->CalculateSpellDuration(m_spellProto, m_effIndex, target); |
---|
| 355 | |
---|
| 356 | if (!damage && castItem && castItem->GetItemSuffixFactor()) |
---|
| 357 | { |
---|
| 358 | ItemRandomSuffixEntry const *item_rand_suffix = sItemRandomSuffixStore.LookupEntry(abs(castItem->GetItemRandomPropertyId())); |
---|
| 359 | if(item_rand_suffix) |
---|
| 360 | { |
---|
| 361 | for (int k=0; k<3; k++) |
---|
| 362 | { |
---|
| 363 | SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(item_rand_suffix->enchant_id[k]); |
---|
| 364 | if(pEnchant) |
---|
| 365 | { |
---|
| 366 | for (int t=0; t<3; t++) |
---|
| 367 | if(pEnchant->spellid[t] == m_spellProto->Id) |
---|
| 368 | { |
---|
| 369 | damage = uint32((item_rand_suffix->prefix[k]*castItem->GetItemSuffixFactor()) / 10000 ); |
---|
| 370 | break; |
---|
| 371 | } |
---|
| 372 | } |
---|
| 373 | |
---|
| 374 | if(damage) |
---|
| 375 | break; |
---|
| 376 | } |
---|
| 377 | } |
---|
| 378 | } |
---|
| 379 | } |
---|
| 380 | |
---|
| 381 | if(m_maxduration == -1 || m_isPassive && m_spellProto->DurationIndex == 0) |
---|
| 382 | m_permanent = true; |
---|
| 383 | |
---|
| 384 | Player* modOwner = caster ? caster->GetSpellModOwner() : NULL; |
---|
| 385 | |
---|
| 386 | if(!m_permanent && modOwner) |
---|
| 387 | modOwner->ApplySpellMod(GetId(), SPELLMOD_DURATION, m_maxduration); |
---|
| 388 | |
---|
| 389 | m_duration = m_maxduration; |
---|
| 390 | |
---|
| 391 | if(modOwner) |
---|
| 392 | modOwner->ApplySpellMod(GetId(), SPELLMOD_ACTIVATION_TIME, m_periodicTimer); |
---|
| 393 | |
---|
| 394 | 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); |
---|
| 395 | |
---|
| 396 | m_effIndex = eff; |
---|
| 397 | SetModifier(AuraType(m_spellProto->EffectApplyAuraName[eff]), damage, m_spellProto->EffectAmplitude[eff], m_spellProto->EffectMiscValue[eff]); |
---|
| 398 | |
---|
| 399 | m_isDeathPersist = IsDeathPersistentSpell(m_spellProto); |
---|
| 400 | |
---|
| 401 | if(m_spellProto->procCharges) |
---|
| 402 | { |
---|
| 403 | m_procCharges = m_spellProto->procCharges; |
---|
| 404 | |
---|
| 405 | if(modOwner) |
---|
| 406 | modOwner->ApplySpellMod(GetId(), SPELLMOD_CHARGES, m_procCharges); |
---|
| 407 | } |
---|
| 408 | else |
---|
| 409 | m_procCharges = -1; |
---|
| 410 | |
---|
| 411 | m_isRemovedOnShapeLost = (m_caster_guid==m_target->GetGUID() && m_spellProto->Stances && |
---|
| 412 | !(m_spellProto->AttributesEx2 & 0x80000) && !(m_spellProto->Attributes & 0x10000)); |
---|
| 413 | } |
---|
| 414 | |
---|
| 415 | Aura::~Aura() |
---|
| 416 | { |
---|
| 417 | } |
---|
| 418 | |
---|
| 419 | AreaAura::AreaAura(SpellEntry const* spellproto, uint32 eff, int32 *currentBasePoints, Unit *target, |
---|
| 420 | Unit *caster, Item* castItem) : Aura(spellproto, eff, currentBasePoints, target, caster, castItem) |
---|
| 421 | { |
---|
| 422 | m_isAreaAura = true; |
---|
| 423 | |
---|
| 424 | // caster==NULL in constructor args if target==caster in fact |
---|
| 425 | Unit* caster_ptr = caster ? caster : target; |
---|
| 426 | |
---|
| 427 | m_radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(GetSpellProto()->EffectRadiusIndex[m_effIndex])); |
---|
| 428 | if(Player* modOwner = caster_ptr->GetSpellModOwner()) |
---|
| 429 | modOwner->ApplySpellMod(GetId(), SPELLMOD_RADIUS, m_radius); |
---|
| 430 | |
---|
| 431 | switch(spellproto->Effect[eff]) |
---|
| 432 | { |
---|
| 433 | case SPELL_EFFECT_APPLY_AREA_AURA_PARTY: |
---|
| 434 | m_areaAuraType = AREA_AURA_PARTY; |
---|
| 435 | if(target->GetTypeId() == TYPEID_UNIT && ((Creature*)target)->isTotem()) |
---|
| 436 | m_modifier.m_auraname = SPELL_AURA_NONE; |
---|
| 437 | break; |
---|
| 438 | case SPELL_EFFECT_APPLY_AREA_AURA_FRIEND: |
---|
| 439 | m_areaAuraType = AREA_AURA_FRIEND; |
---|
| 440 | break; |
---|
| 441 | case SPELL_EFFECT_APPLY_AREA_AURA_ENEMY: |
---|
| 442 | m_areaAuraType = AREA_AURA_ENEMY; |
---|
| 443 | if(target == caster_ptr) |
---|
| 444 | m_modifier.m_auraname = SPELL_AURA_NONE; // Do not do any effect on self |
---|
| 445 | break; |
---|
| 446 | case SPELL_EFFECT_APPLY_AREA_AURA_PET: |
---|
| 447 | m_areaAuraType = AREA_AURA_PET; |
---|
| 448 | break; |
---|
| 449 | case SPELL_EFFECT_APPLY_AREA_AURA_OWNER: |
---|
| 450 | m_areaAuraType = AREA_AURA_OWNER; |
---|
| 451 | if(target == caster_ptr) |
---|
| 452 | m_modifier.m_auraname = SPELL_AURA_NONE; |
---|
| 453 | break; |
---|
| 454 | default: |
---|
| 455 | sLog.outError("Wrong spell effect in AreaAura constructor"); |
---|
| 456 | ASSERT(false); |
---|
| 457 | break; |
---|
| 458 | } |
---|
| 459 | } |
---|
| 460 | |
---|
| 461 | AreaAura::~AreaAura() |
---|
| 462 | { |
---|
| 463 | } |
---|
| 464 | |
---|
| 465 | PersistentAreaAura::PersistentAreaAura(SpellEntry const* spellproto, uint32 eff, int32 *currentBasePoints, Unit *target, |
---|
| 466 | Unit *caster, Item* castItem) : Aura(spellproto, eff, currentBasePoints, target, caster, castItem) |
---|
| 467 | { |
---|
| 468 | m_isPersistent = true; |
---|
| 469 | } |
---|
| 470 | |
---|
| 471 | PersistentAreaAura::~PersistentAreaAura() |
---|
| 472 | { |
---|
| 473 | } |
---|
| 474 | |
---|
| 475 | Aura* CreateAura(SpellEntry const* spellproto, uint32 eff, int32 *currentBasePoints, Unit *target, Unit *caster, Item* castItem) |
---|
| 476 | { |
---|
| 477 | if (IsAreaAuraEffect(spellproto->Effect[eff])) |
---|
| 478 | return new AreaAura(spellproto, eff, currentBasePoints, target, caster, castItem); |
---|
| 479 | |
---|
| 480 | return new Aura(spellproto, eff, currentBasePoints, target, caster, castItem); |
---|
| 481 | } |
---|
| 482 | |
---|
| 483 | Unit* Aura::GetCaster() const |
---|
| 484 | { |
---|
| 485 | if(m_caster_guid==m_target->GetGUID()) |
---|
| 486 | return m_target; |
---|
| 487 | |
---|
| 488 | //return ObjectAccessor::GetUnit(*m_target,m_caster_guid); |
---|
| 489 | //must return caster even if it's in another grid/map |
---|
| 490 | Unit *unit = ObjectAccessor::GetObjectInWorld(m_caster_guid, (Unit*)NULL); |
---|
| 491 | return unit && unit->IsInWorld() ? unit : NULL; |
---|
| 492 | } |
---|
| 493 | |
---|
| 494 | void Aura::SetModifier(AuraType t, int32 a, uint32 pt, int32 miscValue) |
---|
| 495 | { |
---|
| 496 | m_modifier.m_auraname = t; |
---|
| 497 | m_modifier.m_amount = a; |
---|
| 498 | m_modifier.m_miscvalue = miscValue; |
---|
| 499 | m_modifier.periodictime = pt; |
---|
| 500 | } |
---|
| 501 | |
---|
| 502 | void Aura::Update(uint32 diff) |
---|
| 503 | { |
---|
| 504 | if (m_duration > 0) |
---|
| 505 | { |
---|
| 506 | m_duration -= diff; |
---|
| 507 | if (m_duration < 0) |
---|
| 508 | m_duration = 0; |
---|
| 509 | m_timeCla -= diff; |
---|
| 510 | |
---|
| 511 | // GetEffIndex()==0 prevent double/triple apply manaPerSecond/manaPerSecondPerLevel to same spell with many auras |
---|
| 512 | // all spells with manaPerSecond/manaPerSecondPerLevel have aura in effect 0 |
---|
| 513 | if(GetEffIndex()==0 && m_timeCla <= 0) |
---|
| 514 | { |
---|
| 515 | if(Unit* caster = GetCaster()) |
---|
| 516 | { |
---|
| 517 | Powers powertype = Powers(m_spellProto->powerType); |
---|
| 518 | int32 manaPerSecond = m_spellProto->manaPerSecond + m_spellProto->manaPerSecondPerLevel * caster->getLevel(); |
---|
| 519 | m_timeCla = 1000; |
---|
| 520 | if (manaPerSecond) |
---|
| 521 | { |
---|
| 522 | if(powertype==POWER_HEALTH) |
---|
| 523 | caster->ModifyHealth(-manaPerSecond); |
---|
| 524 | else |
---|
| 525 | caster->ModifyPower(powertype,-manaPerSecond); |
---|
| 526 | } |
---|
| 527 | } |
---|
| 528 | } |
---|
| 529 | } |
---|
| 530 | |
---|
[174] | 531 | // Channeled aura required check distance from caster except in possessed cases |
---|
| 532 | if(IsChanneledSpell(m_spellProto) && m_caster_guid != m_target->GetGUID() && !m_target->isPossessed()) |
---|
[37] | 533 | { |
---|
| 534 | Unit* caster = GetCaster(); |
---|
| 535 | if(!caster) |
---|
| 536 | { |
---|
| 537 | m_target->RemoveAura(GetId(),GetEffIndex()); |
---|
| 538 | return; |
---|
| 539 | } |
---|
| 540 | |
---|
| 541 | // Get spell range |
---|
| 542 | float radius; |
---|
| 543 | SpellModOp mod; |
---|
| 544 | if (m_spellProto->EffectRadiusIndex[GetEffIndex()]) |
---|
| 545 | { |
---|
| 546 | radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellProto->EffectRadiusIndex[GetEffIndex()])); |
---|
| 547 | mod = SPELLMOD_RADIUS; |
---|
| 548 | } |
---|
| 549 | else |
---|
| 550 | { |
---|
| 551 | radius = GetSpellMaxRange(sSpellRangeStore.LookupEntry(m_spellProto->rangeIndex)); |
---|
| 552 | mod = SPELLMOD_RANGE; |
---|
| 553 | } |
---|
| 554 | |
---|
| 555 | if(Player* modOwner = caster->GetSpellModOwner()) |
---|
| 556 | modOwner->ApplySpellMod(GetId(), mod, radius,NULL); |
---|
| 557 | |
---|
| 558 | if(!caster->IsWithinDistInMap(m_target,radius)) |
---|
| 559 | { |
---|
| 560 | m_target->RemoveAura(GetId(),GetEffIndex()); |
---|
| 561 | return; |
---|
| 562 | } |
---|
| 563 | } |
---|
| 564 | |
---|
| 565 | if(m_isPeriodic && (m_duration >= 0 || m_isPassive || m_permanent)) |
---|
| 566 | { |
---|
| 567 | m_periodicTimer -= diff; |
---|
| 568 | if(m_periodicTimer <= 0) // tick also at m_periodicTimer==0 to prevent lost last tick in case max m_duration == (max m_periodicTimer)*N |
---|
| 569 | { |
---|
| 570 | if( m_modifier.m_auraname == SPELL_AURA_MOD_REGEN || |
---|
| 571 | m_modifier.m_auraname == SPELL_AURA_MOD_POWER_REGEN || |
---|
| 572 | // Cannibalize, eating items and other spells |
---|
| 573 | m_modifier.m_auraname == SPELL_AURA_OBS_MOD_HEALTH || |
---|
| 574 | // Eating items and other spells |
---|
| 575 | m_modifier.m_auraname == SPELL_AURA_OBS_MOD_MANA ) |
---|
| 576 | { |
---|
| 577 | ApplyModifier(true); |
---|
| 578 | return; |
---|
| 579 | } |
---|
| 580 | // update before applying (aura can be removed in TriggerSpell or PeriodicTick calls) |
---|
| 581 | m_periodicTimer += m_modifier.periodictime; |
---|
| 582 | |
---|
| 583 | if(m_isTrigger) |
---|
| 584 | TriggerSpell(); |
---|
| 585 | else |
---|
| 586 | PeriodicTick(); |
---|
| 587 | } |
---|
| 588 | } |
---|
| 589 | } |
---|
| 590 | |
---|
| 591 | void AreaAura::Update(uint32 diff) |
---|
| 592 | { |
---|
| 593 | // update for the caster of the aura |
---|
| 594 | if(m_caster_guid == m_target->GetGUID()) |
---|
| 595 | { |
---|
| 596 | Unit* caster = m_target; |
---|
| 597 | |
---|
| 598 | if( !caster->hasUnitState(UNIT_STAT_ISOLATED) ) |
---|
| 599 | { |
---|
| 600 | Unit* owner = caster->GetCharmerOrOwner(); |
---|
| 601 | if (!owner) |
---|
| 602 | owner = caster; |
---|
| 603 | std::list<Unit *> targets; |
---|
| 604 | |
---|
| 605 | switch(m_areaAuraType) |
---|
| 606 | { |
---|
| 607 | case AREA_AURA_PARTY: |
---|
| 608 | { |
---|
| 609 | Group *pGroup = NULL; |
---|
| 610 | |
---|
| 611 | if (owner->GetTypeId() == TYPEID_PLAYER) |
---|
| 612 | pGroup = ((Player*)owner)->GetGroup(); |
---|
| 613 | |
---|
| 614 | if( pGroup) |
---|
| 615 | { |
---|
| 616 | uint8 subgroup = ((Player*)owner)->GetSubGroup(); |
---|
| 617 | for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next()) |
---|
| 618 | { |
---|
| 619 | Player* Target = itr->getSource(); |
---|
| 620 | if(Target && Target->isAlive() && Target->GetSubGroup()==subgroup && caster->IsFriendlyTo(Target)) |
---|
| 621 | { |
---|
| 622 | if(caster->IsWithinDistInMap(Target, m_radius)) |
---|
| 623 | targets.push_back(Target); |
---|
| 624 | Pet *pet = Target->GetPet(); |
---|
| 625 | if(pet && pet->isAlive() && caster->IsWithinDistInMap(pet, m_radius)) |
---|
| 626 | targets.push_back(pet); |
---|
| 627 | } |
---|
| 628 | } |
---|
| 629 | } |
---|
| 630 | else |
---|
| 631 | { |
---|
| 632 | // add owner |
---|
| 633 | if( owner != caster && caster->IsWithinDistInMap(owner, m_radius) ) |
---|
| 634 | targets.push_back(owner); |
---|
| 635 | // add caster's pet |
---|
| 636 | Unit* pet = caster->GetPet(); |
---|
| 637 | if( pet && caster->IsWithinDistInMap(pet, m_radius)) |
---|
| 638 | targets.push_back(pet); |
---|
| 639 | } |
---|
| 640 | break; |
---|
| 641 | } |
---|
| 642 | case AREA_AURA_FRIEND: |
---|
| 643 | { |
---|
[44] | 644 | CellPair p(Trinity::ComputeCellPair(caster->GetPositionX(), caster->GetPositionY())); |
---|
[37] | 645 | Cell cell(p); |
---|
| 646 | cell.data.Part.reserved = ALL_DISTRICT; |
---|
| 647 | cell.SetNoCreate(); |
---|
| 648 | |
---|
[44] | 649 | Trinity::AnyFriendlyUnitInObjectRangeCheck u_check(caster, owner, m_radius); |
---|
| 650 | Trinity::UnitListSearcher<Trinity::AnyFriendlyUnitInObjectRangeCheck> searcher(targets, u_check); |
---|
| 651 | TypeContainerVisitor<Trinity::UnitListSearcher<Trinity::AnyFriendlyUnitInObjectRangeCheck>, WorldTypeMapContainer > world_unit_searcher(searcher); |
---|
| 652 | TypeContainerVisitor<Trinity::UnitListSearcher<Trinity::AnyFriendlyUnitInObjectRangeCheck>, GridTypeMapContainer > grid_unit_searcher(searcher); |
---|
[37] | 653 | CellLock<GridReadGuard> cell_lock(cell, p); |
---|
| 654 | cell_lock->Visit(cell_lock, world_unit_searcher, *MapManager::Instance().GetMap(caster->GetMapId(), caster)); |
---|
| 655 | cell_lock->Visit(cell_lock, grid_unit_searcher, *MapManager::Instance().GetMap(caster->GetMapId(), caster)); |
---|
| 656 | break; |
---|
| 657 | } |
---|
| 658 | case AREA_AURA_ENEMY: |
---|
| 659 | { |
---|
[44] | 660 | CellPair p(Trinity::ComputeCellPair(caster->GetPositionX(), caster->GetPositionY())); |
---|
[37] | 661 | Cell cell(p); |
---|
| 662 | cell.data.Part.reserved = ALL_DISTRICT; |
---|
| 663 | cell.SetNoCreate(); |
---|
| 664 | |
---|
[44] | 665 | Trinity::AnyAoETargetUnitInObjectRangeCheck u_check(caster, owner, m_radius); // No GetCharmer in searcher |
---|
| 666 | Trinity::UnitListSearcher<Trinity::AnyAoETargetUnitInObjectRangeCheck> searcher(targets, u_check); |
---|
| 667 | TypeContainerVisitor<Trinity::UnitListSearcher<Trinity::AnyAoETargetUnitInObjectRangeCheck>, WorldTypeMapContainer > world_unit_searcher(searcher); |
---|
| 668 | TypeContainerVisitor<Trinity::UnitListSearcher<Trinity::AnyAoETargetUnitInObjectRangeCheck>, GridTypeMapContainer > grid_unit_searcher(searcher); |
---|
[37] | 669 | CellLock<GridReadGuard> cell_lock(cell, p); |
---|
| 670 | cell_lock->Visit(cell_lock, world_unit_searcher, *MapManager::Instance().GetMap(caster->GetMapId(), caster)); |
---|
| 671 | cell_lock->Visit(cell_lock, grid_unit_searcher, *MapManager::Instance().GetMap(caster->GetMapId(), caster)); |
---|
| 672 | break; |
---|
| 673 | } |
---|
| 674 | case AREA_AURA_OWNER: |
---|
| 675 | case AREA_AURA_PET: |
---|
| 676 | { |
---|
| 677 | if(owner != caster) |
---|
| 678 | targets.push_back(owner); |
---|
| 679 | break; |
---|
| 680 | } |
---|
| 681 | } |
---|
| 682 | |
---|
| 683 | for(std::list<Unit *>::iterator tIter = targets.begin(); tIter != targets.end(); tIter++) |
---|
| 684 | { |
---|
| 685 | if((*tIter)->HasAura(GetId(), m_effIndex)) |
---|
| 686 | continue; |
---|
| 687 | |
---|
| 688 | if(SpellEntry const *actualSpellInfo = spellmgr.SelectAuraRankForPlayerLevel(GetSpellProto(), (*tIter)->getLevel())) |
---|
| 689 | { |
---|
| 690 | int32 actualBasePoints = m_currentBasePoints; |
---|
| 691 | // recalculate basepoints for lower rank (all AreaAura spell not use custom basepoints?) |
---|
| 692 | if(actualSpellInfo != GetSpellProto()) |
---|
| 693 | actualBasePoints = actualSpellInfo->EffectBasePoints[m_effIndex]; |
---|
| 694 | AreaAura *aur = new AreaAura(actualSpellInfo, m_effIndex, &actualBasePoints, (*tIter), caster, NULL); |
---|
| 695 | (*tIter)->AddAura(aur); |
---|
| 696 | } |
---|
| 697 | } |
---|
| 698 | } |
---|
| 699 | Aura::Update(diff); |
---|
| 700 | } |
---|
| 701 | else // aura at non-caster |
---|
| 702 | { |
---|
| 703 | Unit * tmp_target = m_target; |
---|
| 704 | Unit* caster = GetCaster(); |
---|
| 705 | uint32 tmp_spellId = GetId(), tmp_effIndex = m_effIndex; |
---|
| 706 | |
---|
| 707 | // WARNING: the aura may get deleted during the update |
---|
| 708 | // DO NOT access its members after update! |
---|
| 709 | Aura::Update(diff); |
---|
| 710 | |
---|
| 711 | // remove aura if out-of-range from caster (after teleport for example) |
---|
| 712 | // or caster is isolated or caster no longer has the aura |
---|
| 713 | // or caster is (no longer) friendly |
---|
| 714 | bool needFriendly = (m_areaAuraType == AREA_AURA_ENEMY ? false : true); |
---|
| 715 | if( !caster || caster->hasUnitState(UNIT_STAT_ISOLATED) || |
---|
| 716 | !caster->IsWithinDistInMap(tmp_target, m_radius) || |
---|
| 717 | !caster->HasAura(tmp_spellId, tmp_effIndex) || |
---|
| 718 | caster->IsFriendlyTo(tmp_target) != needFriendly |
---|
| 719 | ) |
---|
| 720 | { |
---|
| 721 | tmp_target->RemoveAura(tmp_spellId, tmp_effIndex); |
---|
| 722 | } |
---|
| 723 | else if( m_areaAuraType == AREA_AURA_PARTY) // check if in same sub group |
---|
| 724 | { |
---|
| 725 | // not check group if target == owner or target == pet |
---|
| 726 | if (caster->GetCharmerOrOwnerGUID() != tmp_target->GetGUID() && caster->GetGUID() != tmp_target->GetCharmerOrOwnerGUID()) |
---|
| 727 | { |
---|
| 728 | Player* check = caster->GetCharmerOrOwnerPlayerOrPlayerItself(); |
---|
| 729 | |
---|
| 730 | Group *pGroup = check ? check->GetGroup() : NULL; |
---|
| 731 | if( pGroup ) |
---|
| 732 | { |
---|
| 733 | Player* checkTarget = tmp_target->GetCharmerOrOwnerPlayerOrPlayerItself(); |
---|
| 734 | if(!checkTarget || !pGroup->SameSubGroup(check, checkTarget)) |
---|
| 735 | tmp_target->RemoveAura(tmp_spellId, tmp_effIndex); |
---|
| 736 | } |
---|
| 737 | else |
---|
| 738 | tmp_target->RemoveAura(tmp_spellId, tmp_effIndex); |
---|
| 739 | } |
---|
| 740 | } |
---|
| 741 | else if( m_areaAuraType == AREA_AURA_PET || m_areaAuraType == AREA_AURA_OWNER ) |
---|
| 742 | { |
---|
| 743 | if( tmp_target->GetGUID() != caster->GetCharmerOrOwnerGUID() ) |
---|
| 744 | tmp_target->RemoveAura(tmp_spellId, tmp_effIndex); |
---|
| 745 | } |
---|
| 746 | } |
---|
| 747 | } |
---|
| 748 | |
---|
| 749 | void PersistentAreaAura::Update(uint32 diff) |
---|
| 750 | { |
---|
| 751 | bool remove = false; |
---|
| 752 | |
---|
| 753 | // remove the aura if its caster or the dynamic object causing it was removed |
---|
| 754 | // or if the target moves too far from the dynamic object |
---|
| 755 | Unit *caster = GetCaster(); |
---|
| 756 | if (caster) |
---|
| 757 | { |
---|
| 758 | DynamicObject *dynObj = caster->GetDynObject(GetId(), GetEffIndex()); |
---|
| 759 | if (dynObj) |
---|
| 760 | { |
---|
| 761 | if (!m_target->IsWithinDistInMap(dynObj, dynObj->GetRadius())) |
---|
| 762 | remove = true; |
---|
| 763 | } |
---|
| 764 | else |
---|
| 765 | remove = true; |
---|
| 766 | } |
---|
| 767 | else |
---|
| 768 | remove = true; |
---|
| 769 | |
---|
| 770 | Unit *tmp_target = m_target; |
---|
| 771 | uint32 tmp_id = GetId(), tmp_index = GetEffIndex(); |
---|
| 772 | |
---|
| 773 | // WARNING: the aura may get deleted during the update |
---|
| 774 | // DO NOT access its members after update! |
---|
| 775 | Aura::Update(diff); |
---|
| 776 | |
---|
| 777 | if(remove) |
---|
| 778 | tmp_target->RemoveAura(tmp_id, tmp_index); |
---|
| 779 | } |
---|
| 780 | |
---|
| 781 | void Aura::ApplyModifier(bool apply, bool Real) |
---|
| 782 | { |
---|
| 783 | AuraType aura = m_modifier.m_auraname; |
---|
| 784 | |
---|
| 785 | m_in_use = true; |
---|
| 786 | if(aura<TOTAL_AURAS) |
---|
| 787 | (*this.*AuraHandler [aura])(apply,Real); |
---|
| 788 | m_in_use = false; |
---|
| 789 | } |
---|
| 790 | |
---|
| 791 | void Aura::UpdateAuraDuration() |
---|
| 792 | { |
---|
| 793 | if(m_auraSlot >= MAX_AURAS || m_isPassive) |
---|
| 794 | return; |
---|
| 795 | |
---|
| 796 | if( m_target->GetTypeId() == TYPEID_PLAYER) |
---|
| 797 | { |
---|
| 798 | WorldPacket data(SMSG_UPDATE_AURA_DURATION, 5); |
---|
| 799 | data << (uint8)m_auraSlot << (uint32)m_duration; |
---|
| 800 | ((Player*)m_target)->SendDirectMessage(&data); |
---|
| 801 | |
---|
| 802 | data.Initialize(SMSG_SET_EXTRA_AURA_INFO, (8+1+4+4+4)); |
---|
| 803 | data.append(m_target->GetPackGUID()); |
---|
| 804 | data << uint8(m_auraSlot); |
---|
| 805 | data << uint32(GetId()); |
---|
| 806 | data << uint32(GetAuraMaxDuration()); |
---|
| 807 | data << uint32(GetAuraDuration()); |
---|
| 808 | ((Player*)m_target)->SendDirectMessage(&data); |
---|
| 809 | } |
---|
| 810 | |
---|
| 811 | // not send in case player loading (will not work anyway until player not added to map), sent in visibility change code |
---|
| 812 | if(m_target->GetTypeId() == TYPEID_PLAYER && ((Player*)m_target)->GetSession()->PlayerLoading()) |
---|
| 813 | return; |
---|
| 814 | |
---|
| 815 | Unit* caster = GetCaster(); |
---|
| 816 | |
---|
| 817 | if(caster && caster->GetTypeId() == TYPEID_PLAYER && caster != m_target) |
---|
| 818 | SendAuraDurationForCaster((Player*)caster); |
---|
| 819 | } |
---|
| 820 | |
---|
| 821 | void Aura::SendAuraDurationForCaster(Player* caster) |
---|
| 822 | { |
---|
| 823 | WorldPacket data(SMSG_SET_EXTRA_AURA_INFO_NEED_UPDATE, (8+1+4+4+4)); |
---|
| 824 | data.append(m_target->GetPackGUID()); |
---|
| 825 | data << uint8(m_auraSlot); |
---|
| 826 | data << uint32(GetId()); |
---|
| 827 | data << uint32(GetAuraMaxDuration()); // full |
---|
| 828 | data << uint32(GetAuraDuration()); // remain |
---|
| 829 | caster->GetSession()->SendPacket(&data); |
---|
| 830 | } |
---|
| 831 | |
---|
| 832 | void Aura::_AddAura() |
---|
| 833 | { |
---|
| 834 | if (!GetId()) |
---|
| 835 | return; |
---|
| 836 | if(!m_target) |
---|
| 837 | return; |
---|
| 838 | |
---|
| 839 | // we can found aura in NULL_AURA_SLOT and then need store state instead check slot != NULL_AURA_SLOT |
---|
| 840 | bool samespell = false; |
---|
| 841 | bool secondaura = false; |
---|
| 842 | uint8 slot = NULL_AURA_SLOT; |
---|
| 843 | |
---|
| 844 | for(uint8 i = 0; i < 3; i++) |
---|
| 845 | { |
---|
| 846 | Unit::spellEffectPair spair = Unit::spellEffectPair(GetId(), i); |
---|
| 847 | for(Unit::AuraMap::const_iterator itr = m_target->GetAuras().lower_bound(spair); itr != m_target->GetAuras().upper_bound(spair); ++itr) |
---|
| 848 | { |
---|
| 849 | // allow use single slot only by auras from same caster |
---|
| 850 | if(itr->second->GetCasterGUID()==GetCasterGUID()) |
---|
| 851 | { |
---|
| 852 | samespell = true; |
---|
| 853 | if (m_effIndex > itr->second->GetEffIndex()) |
---|
| 854 | secondaura = true; |
---|
| 855 | slot = itr->second->GetAuraSlot(); |
---|
| 856 | break; |
---|
| 857 | } |
---|
| 858 | } |
---|
| 859 | |
---|
| 860 | if(samespell) |
---|
| 861 | break; |
---|
| 862 | } |
---|
| 863 | |
---|
| 864 | // not call total regen auras at adding |
---|
| 865 | switch (m_modifier.m_auraname) |
---|
| 866 | { |
---|
| 867 | case SPELL_AURA_OBS_MOD_HEALTH: |
---|
| 868 | case SPELL_AURA_OBS_MOD_MANA: |
---|
| 869 | m_periodicTimer = m_modifier.periodictime; |
---|
| 870 | break; |
---|
| 871 | case SPELL_AURA_MOD_REGEN: |
---|
| 872 | case SPELL_AURA_MOD_POWER_REGEN: |
---|
| 873 | case SPELL_AURA_MOD_MANA_REGEN_FROM_STAT: |
---|
| 874 | m_periodicTimer = 5000; |
---|
| 875 | break; |
---|
| 876 | } |
---|
| 877 | |
---|
| 878 | // register aura |
---|
| 879 | if (getDiminishGroup() != DIMINISHING_NONE ) |
---|
| 880 | m_target->ApplyDiminishingAura(getDiminishGroup(),true); |
---|
| 881 | |
---|
| 882 | Unit* caster = GetCaster(); |
---|
| 883 | |
---|
| 884 | // passive auras (except totem auras) do not get placed in the slots |
---|
| 885 | // area auras with SPELL_AURA_NONE are not shown on target |
---|
| 886 | if((!m_isPassive || (caster && caster->GetTypeId() == TYPEID_UNIT && ((Creature*)caster)->isTotem())) && |
---|
| 887 | (m_spellProto->Effect[GetEffIndex()] != SPELL_EFFECT_APPLY_AREA_AURA_ENEMY || m_target != caster)) |
---|
| 888 | { |
---|
| 889 | if(!samespell) // new slot need |
---|
| 890 | { |
---|
| 891 | if (IsPositive()) // empty positive slot |
---|
| 892 | { |
---|
| 893 | for (uint8 i = 0; i < MAX_POSITIVE_AURAS; i++) |
---|
| 894 | { |
---|
| 895 | if (m_target->GetUInt32Value((uint16)(UNIT_FIELD_AURA + i)) == 0) |
---|
| 896 | { |
---|
| 897 | slot = i; |
---|
| 898 | break; |
---|
| 899 | } |
---|
| 900 | } |
---|
| 901 | } |
---|
| 902 | else // empty negative slot |
---|
| 903 | { |
---|
| 904 | for (uint8 i = MAX_POSITIVE_AURAS; i < MAX_AURAS; i++) |
---|
| 905 | { |
---|
| 906 | if (m_target->GetUInt32Value((uint16)(UNIT_FIELD_AURA + i)) == 0) |
---|
| 907 | { |
---|
| 908 | slot = i; |
---|
| 909 | break; |
---|
| 910 | } |
---|
| 911 | } |
---|
| 912 | } |
---|
| 913 | |
---|
| 914 | SetAuraSlot( slot ); |
---|
| 915 | |
---|
| 916 | // Not update fields for not first spell's aura, all data already in fields |
---|
| 917 | if(!secondaura) |
---|
| 918 | { |
---|
| 919 | if(slot < MAX_AURAS) // slot found |
---|
| 920 | { |
---|
| 921 | SetAura(slot, false); |
---|
| 922 | SetAuraFlag(slot, true); |
---|
| 923 | SetAuraLevel(slot,caster ? caster->getLevel() : sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)); |
---|
| 924 | UpdateAuraCharges(); |
---|
| 925 | |
---|
| 926 | // update for out of range group members |
---|
| 927 | m_target->UpdateAuraForGroup(slot); |
---|
| 928 | } |
---|
| 929 | |
---|
| 930 | UpdateAuraDuration(); |
---|
| 931 | } |
---|
| 932 | } |
---|
| 933 | else // use found slot |
---|
| 934 | { |
---|
| 935 | SetAuraSlot( slot ); |
---|
| 936 | // Not recalculate stack count for second aura of the same spell |
---|
| 937 | if (!secondaura) |
---|
| 938 | UpdateSlotCounterAndDuration(true); |
---|
| 939 | } |
---|
| 940 | |
---|
| 941 | // Update Seals information |
---|
| 942 | if( IsSealSpell(GetSpellProto()) ) |
---|
| 943 | m_target->ModifyAuraState(AURA_STATE_JUDGEMENT, true); |
---|
| 944 | |
---|
| 945 | // Conflagrate aura state |
---|
| 946 | if (GetSpellProto()->SpellFamilyName == SPELLFAMILY_WARLOCK && (GetSpellProto()->SpellFamilyFlags & 4)) |
---|
| 947 | m_target->ModifyAuraState(AURA_STATE_IMMOLATE, true); |
---|
| 948 | |
---|
| 949 | if(GetSpellProto()->SpellFamilyName == SPELLFAMILY_DRUID |
---|
| 950 | && (GetSpellProto()->SpellFamilyFlags == 0x40 || GetSpellProto()->SpellFamilyFlags == 0x10)) |
---|
| 951 | { |
---|
| 952 | m_target->ModifyAuraState(AURA_STATE_SWIFTMEND, true); |
---|
| 953 | } |
---|
| 954 | } |
---|
| 955 | } |
---|
| 956 | |
---|
| 957 | void Aura::_RemoveAura() |
---|
| 958 | { |
---|
| 959 | // Remove all triggered by aura spells vs unlimited duration |
---|
| 960 | // except same aura replace case |
---|
| 961 | if(m_removeMode!=AURA_REMOVE_BY_STACK) |
---|
| 962 | CleanupTriggeredSpells(); |
---|
| 963 | |
---|
| 964 | Unit* caster = GetCaster(); |
---|
| 965 | |
---|
| 966 | if(caster && IsPersistent()) |
---|
| 967 | { |
---|
| 968 | DynamicObject *dynObj = caster->GetDynObject(GetId(), GetEffIndex()); |
---|
| 969 | if (dynObj) |
---|
| 970 | dynObj->RemoveAffected(m_target); |
---|
| 971 | } |
---|
| 972 | |
---|
| 973 | // unregister aura |
---|
| 974 | if (getDiminishGroup() != DIMINISHING_NONE ) |
---|
| 975 | m_target->ApplyDiminishingAura(getDiminishGroup(),false); |
---|
| 976 | |
---|
| 977 | //passive auras do not get put in slots |
---|
| 978 | // Note: but totem can be not accessible for aura target in time remove (to far for find in grid) |
---|
| 979 | //if(m_isPassive && !(caster && caster->GetTypeId() == TYPEID_UNIT && ((Creature*)caster)->isTotem())) |
---|
| 980 | // return; |
---|
| 981 | |
---|
| 982 | uint8 slot = GetAuraSlot(); |
---|
| 983 | |
---|
| 984 | if(slot >= MAX_AURAS) // slot not set |
---|
| 985 | return; |
---|
| 986 | |
---|
| 987 | if(m_target->GetUInt32Value((uint16)(UNIT_FIELD_AURA + slot)) == 0) |
---|
| 988 | return; |
---|
| 989 | |
---|
| 990 | bool samespell = false; |
---|
| 991 | bool sameaura = false; |
---|
| 992 | |
---|
| 993 | // find other aura in same slot (current already removed from list) |
---|
| 994 | for(uint8 i = 0; i < 3; i++) |
---|
| 995 | { |
---|
| 996 | Unit::spellEffectPair spair = Unit::spellEffectPair(GetId(), i); |
---|
| 997 | for(Unit::AuraMap::const_iterator itr = m_target->GetAuras().lower_bound(spair); itr != m_target->GetAuras().upper_bound(spair); ++itr) |
---|
| 998 | { |
---|
| 999 | if(itr->second->GetAuraSlot()==slot) |
---|
| 1000 | { |
---|
| 1001 | samespell = true; |
---|
| 1002 | |
---|
| 1003 | if(GetEffIndex()==i) |
---|
| 1004 | sameaura = true; |
---|
| 1005 | |
---|
| 1006 | break; |
---|
| 1007 | } |
---|
| 1008 | } |
---|
| 1009 | if(samespell) |
---|
| 1010 | break; |
---|
| 1011 | } |
---|
| 1012 | |
---|
| 1013 | // only remove icon when the last aura of the spell is removed (current aura already removed from list) |
---|
| 1014 | if (!samespell) |
---|
| 1015 | { |
---|
| 1016 | SetAura(slot, true); |
---|
| 1017 | SetAuraFlag(slot, false); |
---|
| 1018 | SetAuraLevel(slot,caster ? caster->getLevel() : sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)); |
---|
| 1019 | |
---|
| 1020 | SetAuraApplication(slot, 0); |
---|
| 1021 | // update for out of range group members |
---|
| 1022 | m_target->UpdateAuraForGroup(slot); |
---|
| 1023 | |
---|
| 1024 | if( IsSealSpell(GetSpellProto()) ) |
---|
| 1025 | m_target->ModifyAuraState(AURA_STATE_JUDGEMENT,false); |
---|
| 1026 | |
---|
| 1027 | // Conflagrate aura state |
---|
| 1028 | if (GetSpellProto()->SpellFamilyName == SPELLFAMILY_WARLOCK && (GetSpellProto()->SpellFamilyFlags & 4)) |
---|
| 1029 | m_target->ModifyAuraState(AURA_STATE_IMMOLATE, false); |
---|
| 1030 | |
---|
| 1031 | // Swiftmend aura state |
---|
| 1032 | if(GetSpellProto()->SpellFamilyName == SPELLFAMILY_DRUID |
---|
| 1033 | && (GetSpellProto()->SpellFamilyFlags == 0x40 || GetSpellProto()->SpellFamilyFlags == 0x10)) |
---|
| 1034 | { |
---|
| 1035 | bool found = false; |
---|
| 1036 | Unit::AuraList const& RejorRegr = m_target->GetAurasByType(SPELL_AURA_PERIODIC_HEAL); |
---|
| 1037 | for(Unit::AuraList::const_iterator i = RejorRegr.begin(); i != RejorRegr.end(); ++i) |
---|
| 1038 | { |
---|
| 1039 | if((*i)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_DRUID |
---|
| 1040 | && ((*i)->GetSpellProto()->SpellFamilyFlags == 0x40 || (*i)->GetSpellProto()->SpellFamilyFlags == 0x10) ) |
---|
| 1041 | { |
---|
| 1042 | found = true; |
---|
| 1043 | break; |
---|
| 1044 | } |
---|
| 1045 | } |
---|
| 1046 | if(!found) |
---|
| 1047 | m_target->ModifyAuraState(AURA_STATE_SWIFTMEND, false); |
---|
| 1048 | } |
---|
| 1049 | |
---|
| 1050 | // reset cooldown state for spells |
---|
| 1051 | if(caster && caster->GetTypeId() == TYPEID_PLAYER) |
---|
| 1052 | { |
---|
| 1053 | if ( GetSpellProto()->Attributes & SPELL_ATTR_DISABLED_WHILE_ACTIVE ) |
---|
| 1054 | ((Player*)caster)->SendCooldownEvent(GetSpellProto()); |
---|
| 1055 | } |
---|
| 1056 | } |
---|
| 1057 | else if(sameaura) // decrease count for spell, only for same aura effect, or this spell auras in remove proccess. |
---|
| 1058 | UpdateSlotCounterAndDuration(false); |
---|
| 1059 | } |
---|
| 1060 | |
---|
| 1061 | void Aura::SetAuraFlag(uint32 slot, bool add) |
---|
| 1062 | { |
---|
| 1063 | uint32 index = slot / 4; |
---|
| 1064 | uint32 byte = (slot % 4) * 8; |
---|
| 1065 | uint32 val = m_target->GetUInt32Value(UNIT_FIELD_AURAFLAGS + index); |
---|
| 1066 | val &= ~((uint32)AFLAG_MASK << byte); |
---|
| 1067 | if(add) |
---|
| 1068 | { |
---|
| 1069 | if (IsPositive()) |
---|
| 1070 | val |= ((uint32)AFLAG_POSITIVE << byte); |
---|
| 1071 | else |
---|
| 1072 | val |= ((uint32)AFLAG_NEGATIVE << byte); |
---|
| 1073 | } |
---|
| 1074 | m_target->SetUInt32Value(UNIT_FIELD_AURAFLAGS + index, val); |
---|
| 1075 | } |
---|
| 1076 | |
---|
| 1077 | void Aura::SetAuraLevel(uint32 slot,uint32 level) |
---|
| 1078 | { |
---|
| 1079 | uint32 index = slot / 4; |
---|
| 1080 | uint32 byte = (slot % 4) * 8; |
---|
| 1081 | uint32 val = m_target->GetUInt32Value(UNIT_FIELD_AURALEVELS + index); |
---|
| 1082 | val &= ~(0xFF << byte); |
---|
| 1083 | val |= (level << byte); |
---|
| 1084 | m_target->SetUInt32Value(UNIT_FIELD_AURALEVELS + index, val); |
---|
| 1085 | } |
---|
| 1086 | |
---|
| 1087 | void Aura::SetAuraApplication(uint32 slot, int8 count) |
---|
| 1088 | { |
---|
| 1089 | uint32 index = slot / 4; |
---|
| 1090 | uint32 byte = (slot % 4) * 8; |
---|
| 1091 | uint32 val = m_target->GetUInt32Value(UNIT_FIELD_AURAAPPLICATIONS + index); |
---|
| 1092 | val &= ~(0xFF << byte); |
---|
| 1093 | val |= ((uint8(count)) << byte); |
---|
| 1094 | m_target->SetUInt32Value(UNIT_FIELD_AURAAPPLICATIONS + index, val); |
---|
| 1095 | } |
---|
| 1096 | |
---|
| 1097 | void Aura::UpdateSlotCounterAndDuration(bool add) |
---|
| 1098 | { |
---|
| 1099 | uint8 slot = GetAuraSlot(); |
---|
| 1100 | if(slot >= MAX_AURAS) |
---|
| 1101 | return; |
---|
| 1102 | |
---|
| 1103 | // calculate amount of similar auras by same effect index (similar different spells) |
---|
| 1104 | int8 count = 0; |
---|
| 1105 | |
---|
| 1106 | // calculate auras and update durations in case aura adding |
---|
| 1107 | Unit::AuraList const& aura_list = m_target->GetAurasByType(GetModifier()->m_auraname); |
---|
| 1108 | for(Unit::AuraList::const_iterator i = aura_list.begin();i != aura_list.end(); ++i) |
---|
| 1109 | { |
---|
| 1110 | if( (*i)->GetId()==GetId() && (*i)->GetEffIndex()==m_effIndex && |
---|
| 1111 | (*i)->GetCasterGUID()==GetCasterGUID() ) |
---|
| 1112 | { |
---|
| 1113 | ++count; |
---|
| 1114 | |
---|
| 1115 | if(add) |
---|
| 1116 | (*i)->SetAuraDuration(GetAuraDuration()); |
---|
| 1117 | } |
---|
| 1118 | } |
---|
| 1119 | |
---|
| 1120 | // at aura add aura not added yet, at aura remove aura already removed |
---|
| 1121 | // in field stored (count-1) |
---|
| 1122 | if(!add) |
---|
| 1123 | --count; |
---|
| 1124 | |
---|
| 1125 | SetAuraApplication(slot, count); |
---|
| 1126 | |
---|
| 1127 | UpdateAuraDuration(); |
---|
| 1128 | } |
---|
| 1129 | |
---|
| 1130 | /*********************************************************/ |
---|
| 1131 | /*** BASIC AURA FUNCTION ***/ |
---|
| 1132 | /*********************************************************/ |
---|
| 1133 | void Aura::HandleAddModifier(bool apply, bool Real) |
---|
| 1134 | { |
---|
| 1135 | if(m_target->GetTypeId() != TYPEID_PLAYER || !Real) |
---|
| 1136 | return; |
---|
| 1137 | |
---|
| 1138 | SpellEntry const *spellInfo = GetSpellProto(); |
---|
| 1139 | if(!spellInfo) |
---|
| 1140 | return; |
---|
| 1141 | |
---|
| 1142 | if(m_modifier.m_miscvalue >= MAX_SPELLMOD) |
---|
| 1143 | return; |
---|
| 1144 | |
---|
| 1145 | if (apply) |
---|
| 1146 | { |
---|
| 1147 | // Add custom charges for some mod aura |
---|
| 1148 | switch (m_spellProto->Id) |
---|
| 1149 | { |
---|
| 1150 | case 17941: // Shadow Trance |
---|
| 1151 | case 22008: // Netherwind Focus |
---|
| 1152 | case 34936: // Backlash |
---|
| 1153 | m_procCharges = 1; |
---|
| 1154 | break; |
---|
| 1155 | } |
---|
| 1156 | |
---|
| 1157 | SpellModifier *mod = new SpellModifier; |
---|
| 1158 | mod->op = SpellModOp(m_modifier.m_miscvalue); |
---|
| 1159 | mod->value = m_modifier.m_amount; |
---|
| 1160 | mod->type = SpellModType(m_modifier.m_auraname); // SpellModType value == spell aura types |
---|
| 1161 | mod->spellId = GetId(); |
---|
| 1162 | mod->effectId = m_effIndex; |
---|
| 1163 | mod->lastAffected = NULL; |
---|
| 1164 | |
---|
| 1165 | uint64 spellAffectMask = spellmgr.GetSpellAffectMask(GetId(), m_effIndex); |
---|
| 1166 | |
---|
| 1167 | if (spellAffectMask) |
---|
| 1168 | mod->mask = spellAffectMask; |
---|
| 1169 | else |
---|
| 1170 | mod->mask = spellInfo->EffectItemType[m_effIndex]; |
---|
| 1171 | |
---|
| 1172 | if (m_procCharges > 0) |
---|
| 1173 | mod->charges = m_procCharges; |
---|
| 1174 | else |
---|
| 1175 | mod->charges = 0; |
---|
| 1176 | |
---|
| 1177 | m_spellmod = mod; |
---|
| 1178 | } |
---|
| 1179 | |
---|
| 1180 | uint64 spellFamilyMask = m_spellmod->mask; |
---|
| 1181 | |
---|
| 1182 | ((Player*)m_target)->AddSpellMod(m_spellmod, apply); |
---|
| 1183 | |
---|
| 1184 | // reapply some passive spells after add/remove related spellmods |
---|
| 1185 | if(spellInfo->SpellFamilyName==SPELLFAMILY_WARRIOR && (spellFamilyMask & 0x0000100000000000LL)) |
---|
| 1186 | { |
---|
| 1187 | m_target->RemoveAurasDueToSpell(45471); |
---|
| 1188 | |
---|
| 1189 | if(apply) |
---|
| 1190 | m_target->CastSpell(m_target,45471,true); |
---|
| 1191 | } |
---|
| 1192 | } |
---|
| 1193 | |
---|
| 1194 | void Aura::TriggerSpell() |
---|
| 1195 | { |
---|
| 1196 | Unit* caster = GetCaster(); |
---|
| 1197 | Unit* target = GetTriggerTarget(); |
---|
| 1198 | |
---|
| 1199 | if(!caster || !target) |
---|
| 1200 | return; |
---|
| 1201 | |
---|
| 1202 | // generic casting code with custom spells and target/caster customs |
---|
| 1203 | uint32 trigger_spell_id = GetSpellProto()->EffectTriggerSpell[m_effIndex]; |
---|
| 1204 | |
---|
| 1205 | uint64 originalCasterGUID = GetCasterGUID(); |
---|
| 1206 | |
---|
| 1207 | SpellEntry const *triggredSpellInfo = sSpellStore.LookupEntry(trigger_spell_id); |
---|
| 1208 | SpellEntry const *auraSpellInfo = GetSpellProto(); |
---|
| 1209 | uint32 auraId = auraSpellInfo->Id; |
---|
| 1210 | |
---|
| 1211 | // specific code for cases with no trigger spell provided in field |
---|
| 1212 | if (triggredSpellInfo == NULL) |
---|
| 1213 | { |
---|
| 1214 | switch(auraSpellInfo->SpellFamilyName) |
---|
| 1215 | { |
---|
| 1216 | case SPELLFAMILY_GENERIC: |
---|
| 1217 | { |
---|
| 1218 | switch(auraId) |
---|
| 1219 | { |
---|
| 1220 | // Firestone Passive (1-5 rangs) |
---|
| 1221 | case 758: |
---|
| 1222 | case 17945: |
---|
| 1223 | case 17947: |
---|
| 1224 | case 17949: |
---|
| 1225 | case 27252: |
---|
| 1226 | { |
---|
| 1227 | if (caster->GetTypeId()!=TYPEID_PLAYER) |
---|
| 1228 | return; |
---|
| 1229 | Item* item = ((Player*)caster)->GetWeaponForAttack(BASE_ATTACK); |
---|
| 1230 | if (!item) |
---|
| 1231 | return; |
---|
| 1232 | uint32 enchant_id = 0; |
---|
| 1233 | switch (GetId()) |
---|
| 1234 | { |
---|
| 1235 | case 758: enchant_id = 1803; break; // Rank 1 |
---|
| 1236 | case 17945: enchant_id = 1823; break; // Rank 2 |
---|
| 1237 | case 17947: enchant_id = 1824; break; // Rank 3 |
---|
| 1238 | case 17949: enchant_id = 1825; break; // Rank 4 |
---|
| 1239 | case 27252: enchant_id = 2645; break; // Rank 5 |
---|
| 1240 | default: |
---|
| 1241 | return; |
---|
| 1242 | } |
---|
| 1243 | // remove old enchanting before applying new |
---|
| 1244 | ((Player*)caster)->ApplyEnchantment(item,TEMP_ENCHANTMENT_SLOT,false); |
---|
| 1245 | item->SetEnchantment(TEMP_ENCHANTMENT_SLOT, enchant_id, m_modifier.periodictime+1000, 0); |
---|
| 1246 | // add new enchanting |
---|
| 1247 | ((Player*)caster)->ApplyEnchantment(item,TEMP_ENCHANTMENT_SLOT,true); |
---|
| 1248 | return; |
---|
| 1249 | } |
---|
| 1250 | // // Periodic Mana Burn |
---|
| 1251 | // case 812: break; |
---|
| 1252 | // // Polymorphic Ray |
---|
| 1253 | // case 6965: break; |
---|
| 1254 | // // Fire Nova (1-7 Rangs) |
---|
| 1255 | // case 8350: |
---|
| 1256 | // case 8508: |
---|
| 1257 | // case 8509: |
---|
| 1258 | // case 11312: |
---|
| 1259 | // case 11313: |
---|
| 1260 | // case 25540: |
---|
| 1261 | // case 25544: |
---|
| 1262 | // break; |
---|
| 1263 | // Thaumaturgy Channel |
---|
| 1264 | case 9712: trigger_spell_id = 21029; break; |
---|
| 1265 | // // Egan's Blaster |
---|
| 1266 | // case 17368: break; |
---|
| 1267 | // // Haunted |
---|
| 1268 | // case 18347: break; |
---|
| 1269 | // // Ranshalla Waiting |
---|
| 1270 | // case 18953: break; |
---|
| 1271 | // // Inferno |
---|
| 1272 | // case 19695: break; |
---|
| 1273 | // // Frostwolf Muzzle DND |
---|
| 1274 | // case 21794: break; |
---|
| 1275 | // // Alterac Ram Collar DND |
---|
| 1276 | // case 21866: break; |
---|
| 1277 | // // Celebras Waiting |
---|
| 1278 | // case 21916: break; |
---|
| 1279 | // Brood Affliction: Bronze |
---|
| 1280 | case 23170: |
---|
| 1281 | { |
---|
| 1282 | m_target->CastSpell(m_target, 23171, true, 0, this); |
---|
| 1283 | return; |
---|
| 1284 | } |
---|
| 1285 | // // Mark of Frost |
---|
| 1286 | // case 23184: break; |
---|
| 1287 | // Restoration |
---|
| 1288 | case 23493: |
---|
| 1289 | { |
---|
| 1290 | int32 heal = caster->GetMaxHealth() / 10; |
---|
| 1291 | caster->ModifyHealth( heal ); |
---|
| 1292 | caster->SendHealSpellLog(caster, 23493, heal); |
---|
| 1293 | |
---|
| 1294 | int32 mana = caster->GetMaxPower(POWER_MANA); |
---|
| 1295 | if (mana) |
---|
| 1296 | { |
---|
| 1297 | mana /= 10; |
---|
| 1298 | caster->ModifyPower( POWER_MANA, mana ); |
---|
| 1299 | caster->SendEnergizeSpellLog(caster, 23493, mana, POWER_MANA); |
---|
| 1300 | } |
---|
| 1301 | break; |
---|
| 1302 | } |
---|
| 1303 | // // Stoneclaw Totem Passive TEST |
---|
| 1304 | // case 23792: break; |
---|
| 1305 | // // Axe Flurry |
---|
| 1306 | // case 24018: break; |
---|
| 1307 | // // Mark of Arlokk |
---|
| 1308 | // case 24210: break; |
---|
| 1309 | // // Restoration |
---|
| 1310 | // case 24379: break; |
---|
| 1311 | // // Happy Pet |
---|
| 1312 | // case 24716: break; |
---|
| 1313 | // // Dream Fog |
---|
| 1314 | // case 24780: break; |
---|
| 1315 | // // Cannon Prep |
---|
| 1316 | // case 24832: break; |
---|
| 1317 | // // Shadow Bolt Whirl |
---|
| 1318 | // case 24834: break; |
---|
| 1319 | // // Stink Trap |
---|
| 1320 | // case 24918: break; |
---|
| 1321 | // // Mark of Nature |
---|
| 1322 | // case 25041: break; |
---|
| 1323 | // // Agro Drones |
---|
| 1324 | // case 25152: break; |
---|
| 1325 | // // Consume |
---|
| 1326 | // case 25371: break; |
---|
| 1327 | // // Pain Spike |
---|
| 1328 | // case 25572: break; |
---|
| 1329 | // // Rotate 360 |
---|
| 1330 | // case 26009: break; |
---|
| 1331 | // // Rotate -360 |
---|
| 1332 | // case 26136: break; |
---|
| 1333 | // // Consume |
---|
| 1334 | // case 26196: break; |
---|
| 1335 | // // Berserk |
---|
| 1336 | // case 26615: break; |
---|
| 1337 | // // Defile |
---|
| 1338 | // case 27177: break; |
---|
| 1339 | // // Teleport: IF/UC |
---|
| 1340 | // case 27601: break; |
---|
| 1341 | // // Five Fat Finger Exploding Heart Technique |
---|
| 1342 | // case 27673: break; |
---|
| 1343 | // // Nitrous Boost |
---|
| 1344 | // case 27746: break; |
---|
| 1345 | // // Steam Tank Passive |
---|
| 1346 | // case 27747: break; |
---|
| 1347 | // // Frost Blast |
---|
| 1348 | // case 27808: break; |
---|
| 1349 | // // Detonate Mana |
---|
| 1350 | // case 27819: break; |
---|
| 1351 | // // Controller Timer |
---|
| 1352 | // case 28095: break; |
---|
| 1353 | // // Stalagg Chain |
---|
| 1354 | // case 28096: break; |
---|
| 1355 | // // Stalagg Tesla Passive |
---|
| 1356 | // case 28097: break; |
---|
| 1357 | // // Feugen Tesla Passive |
---|
| 1358 | // case 28109: break; |
---|
| 1359 | // // Feugen Chain |
---|
| 1360 | // case 28111: break; |
---|
| 1361 | // // Mark of Didier |
---|
| 1362 | // case 28114: break; |
---|
| 1363 | // // Communique Timer, camp |
---|
| 1364 | // case 28346: break; |
---|
| 1365 | // // Icebolt |
---|
| 1366 | // case 28522: break; |
---|
| 1367 | // // Silithyst |
---|
| 1368 | // case 29519: break; |
---|
| 1369 | // // Inoculate Nestlewood Owlkin |
---|
| 1370 | case 29528: trigger_spell_id = 28713; break; |
---|
| 1371 | // // Overload |
---|
| 1372 | // case 29768: break; |
---|
| 1373 | // // Return Fire |
---|
| 1374 | // case 29788: break; |
---|
| 1375 | // // Return Fire |
---|
| 1376 | // case 29793: break; |
---|
| 1377 | // // Return Fire |
---|
| 1378 | // case 29794: break; |
---|
| 1379 | // // Guardian of Icecrown Passive |
---|
| 1380 | // case 29897: break; |
---|
| 1381 | // Feed Captured Animal |
---|
| 1382 | case 29917: trigger_spell_id = 29916; break; |
---|
| 1383 | // // Flame Wreath |
---|
| 1384 | // case 29946: break; |
---|
| 1385 | // // Flame Wreath |
---|
| 1386 | // case 29947: break; |
---|
| 1387 | // // Mind Exhaustion Passive |
---|
| 1388 | // case 30025: break; |
---|
| 1389 | // // Nether Beam - Serenity |
---|
| 1390 | // case 30401: break; |
---|
| 1391 | // Extract Gas |
---|
| 1392 | case 30427: |
---|
| 1393 | { |
---|
| 1394 | // move loot to player inventory and despawn target |
---|
| 1395 | if(caster->GetTypeId() ==TYPEID_PLAYER && |
---|
| 1396 | target->GetTypeId() == TYPEID_UNIT && |
---|
| 1397 | ((Creature*)target)->GetCreatureInfo()->type == CREATURE_TYPE_GAS_CLOUD) |
---|
| 1398 | { |
---|
| 1399 | Player* player = (Player*)caster; |
---|
| 1400 | Creature* creature = (Creature*)target; |
---|
| 1401 | // missing lootid has been reported on startup - just return |
---|
| 1402 | if (!creature->GetCreatureInfo()->SkinLootId) |
---|
| 1403 | { |
---|
| 1404 | return; |
---|
| 1405 | } |
---|
| 1406 | Loot *loot = &creature->loot; |
---|
| 1407 | loot->clear(); |
---|
| 1408 | loot->FillLoot(creature->GetCreatureInfo()->SkinLootId, LootTemplates_Skinning, NULL); |
---|
| 1409 | for(uint8 i=0;i<loot->items.size();i++) |
---|
| 1410 | { |
---|
| 1411 | LootItem *item = loot->LootItemInSlot(i,player); |
---|
| 1412 | ItemPosCountVec dest; |
---|
| 1413 | uint8 msg = player->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, item->itemid, item->count ); |
---|
| 1414 | if ( msg == EQUIP_ERR_OK ) |
---|
| 1415 | { |
---|
| 1416 | Item * newitem = player->StoreNewItem( dest, item->itemid, true, item->randomPropertyId); |
---|
| 1417 | |
---|
| 1418 | player->SendNewItem(newitem, uint32(item->count), false, false, true); |
---|
| 1419 | } |
---|
| 1420 | else |
---|
| 1421 | player->SendEquipError( msg, NULL, NULL ); |
---|
| 1422 | } |
---|
| 1423 | creature->setDeathState(JUST_DIED); |
---|
| 1424 | creature->RemoveCorpse(); |
---|
| 1425 | creature->SetHealth(0); // just for nice GM-mode view |
---|
| 1426 | } |
---|
| 1427 | return; |
---|
| 1428 | break; |
---|
| 1429 | } |
---|
| 1430 | // Quake |
---|
| 1431 | case 30576: trigger_spell_id = 30571; break; |
---|
| 1432 | // // Burning Maul |
---|
| 1433 | // case 30598: break; |
---|
| 1434 | // // Regeneration |
---|
| 1435 | // case 30799: |
---|
| 1436 | // case 30800: |
---|
| 1437 | // case 30801: |
---|
| 1438 | // break; |
---|
| 1439 | // // Despawn Self - Smoke cloud |
---|
| 1440 | // case 31269: break; |
---|
| 1441 | // // Time Rift Periodic |
---|
| 1442 | // case 31320: break; |
---|
| 1443 | // // Corrupt Medivh |
---|
| 1444 | // case 31326: break; |
---|
| 1445 | // Doom |
---|
| 1446 | case 31347: |
---|
| 1447 | { |
---|
| 1448 | m_target->CastSpell(m_target,31350,true); |
---|
| 1449 | m_target->DealDamage(m_target, m_target->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); |
---|
| 1450 | return; |
---|
| 1451 | } |
---|
| 1452 | // Spellcloth |
---|
| 1453 | case 31373: |
---|
| 1454 | { |
---|
| 1455 | // Summon Elemental after create item |
---|
| 1456 | caster->SummonCreature(17870, 0, 0, 0, caster->GetOrientation(), TEMPSUMMON_DEAD_DESPAWN, 0); |
---|
| 1457 | return; |
---|
| 1458 | } |
---|
| 1459 | // // Bloodmyst Tesla |
---|
| 1460 | // case 31611: break; |
---|
| 1461 | // // Doomfire |
---|
| 1462 | // case 31944: break; |
---|
| 1463 | // // Teleport Test |
---|
| 1464 | // case 32236: break; |
---|
| 1465 | // // Earthquake |
---|
| 1466 | // case 32686: break; |
---|
| 1467 | // // Possess |
---|
| 1468 | // case 33401: break; |
---|
| 1469 | // // Draw Shadows |
---|
| 1470 | // case 33563: break; |
---|
| 1471 | // // Murmur's Touch |
---|
| 1472 | // case 33711: break; |
---|
| 1473 | // Flame Quills |
---|
| 1474 | case 34229: |
---|
| 1475 | { |
---|
| 1476 | // cast 24 spells 34269-34289, 34314-34316 |
---|
| 1477 | for(uint32 spell_id = 34269; spell_id != 34290; ++spell_id) |
---|
| 1478 | caster->CastSpell(m_target,spell_id,true); |
---|
| 1479 | for(uint32 spell_id = 34314; spell_id != 34317; ++spell_id) |
---|
| 1480 | caster->CastSpell(m_target,spell_id,true); |
---|
| 1481 | return; |
---|
| 1482 | } |
---|
| 1483 | // // Gravity Lapse |
---|
| 1484 | // case 34480: break; |
---|
| 1485 | // // Tornado |
---|
| 1486 | // case 34683: break; |
---|
| 1487 | // // Frostbite Rotate |
---|
| 1488 | // case 34748: break; |
---|
| 1489 | // // Arcane Flurry |
---|
| 1490 | // case 34821: break; |
---|
| 1491 | // // Interrupt Shutdown |
---|
| 1492 | // case 35016: break; |
---|
| 1493 | // // Interrupt Shutdown |
---|
| 1494 | // case 35176: break; |
---|
| 1495 | // // Inferno |
---|
| 1496 | // case 35268: break; |
---|
| 1497 | // // Salaadin's Tesla |
---|
| 1498 | // case 35515: break; |
---|
| 1499 | // // Ethereal Channel (Red) |
---|
| 1500 | // case 35518: break; |
---|
| 1501 | // // Nether Vapor |
---|
| 1502 | // case 35879: break; |
---|
| 1503 | // // Dark Portal Storm |
---|
| 1504 | // case 36018: break; |
---|
| 1505 | // // Burning Maul |
---|
| 1506 | // case 36056: break; |
---|
| 1507 | // // Living Grove Defender Lifespan |
---|
| 1508 | // case 36061: break; |
---|
| 1509 | // // Professor Dabiri Talks |
---|
| 1510 | // case 36064: break; |
---|
| 1511 | // // Kael Gaining Power |
---|
| 1512 | // case 36091: break; |
---|
| 1513 | // // They Must Burn Bomb Aura |
---|
| 1514 | // case 36344: break; |
---|
| 1515 | // // They Must Burn Bomb Aura (self) |
---|
| 1516 | // case 36350: break; |
---|
| 1517 | // // Stolen Ravenous Ravager Egg |
---|
| 1518 | // case 36401: break; |
---|
| 1519 | // // Activated Cannon |
---|
| 1520 | // case 36410: break; |
---|
| 1521 | // // Stolen Ravenous Ravager Egg |
---|
| 1522 | // case 36418: break; |
---|
| 1523 | // // Enchanted Weapons |
---|
| 1524 | // case 36510: break; |
---|
| 1525 | // // Cursed Scarab Periodic |
---|
| 1526 | // case 36556: break; |
---|
| 1527 | // // Cursed Scarab Despawn Periodic |
---|
| 1528 | // case 36561: break; |
---|
| 1529 | // // Vision Guide |
---|
| 1530 | // case 36573: break; |
---|
| 1531 | // // Cannon Charging (platform) |
---|
| 1532 | // case 36785: break; |
---|
| 1533 | // // Cannon Charging (self) |
---|
| 1534 | // case 36860: break; |
---|
| 1535 | // Remote Toy |
---|
| 1536 | case 37027: trigger_spell_id = 37029; break; |
---|
| 1537 | // // Mark of Death |
---|
| 1538 | // case 37125: break; |
---|
| 1539 | // // Arcane Flurry |
---|
| 1540 | // case 37268: break; |
---|
| 1541 | // // Spout |
---|
| 1542 | // case 37429: break; |
---|
| 1543 | // // Spout |
---|
| 1544 | // case 37430: break; |
---|
| 1545 | // // Karazhan - Chess NPC AI, Snapshot timer |
---|
| 1546 | // case 37440: break; |
---|
| 1547 | // // Karazhan - Chess NPC AI, action timer |
---|
| 1548 | // case 37504: break; |
---|
| 1549 | // // Karazhan - Chess: Is Square OCCUPIED aura (DND) |
---|
| 1550 | // case 39400: break; |
---|
| 1551 | // // Banish |
---|
| 1552 | // case 37546: break; |
---|
| 1553 | // // Shriveling Gaze |
---|
| 1554 | // case 37589: break; |
---|
| 1555 | // // Fake Aggro Radius (2 yd) |
---|
| 1556 | // case 37815: break; |
---|
| 1557 | // // Corrupt Medivh |
---|
| 1558 | // case 37853: break; |
---|
| 1559 | // Eye of Grillok |
---|
| 1560 | case 38495: |
---|
| 1561 | { |
---|
| 1562 | m_target->CastSpell(m_target, 38530, true); |
---|
| 1563 | return; |
---|
| 1564 | } |
---|
| 1565 | // Absorb Eye of Grillok (Zezzak's Shard) |
---|
| 1566 | case 38554: |
---|
| 1567 | { |
---|
| 1568 | if(m_target->GetTypeId() != TYPEID_UNIT) |
---|
| 1569 | return; |
---|
| 1570 | |
---|
| 1571 | caster->CastSpell(caster, 38495, true); |
---|
| 1572 | |
---|
| 1573 | Creature* creatureTarget = (Creature*)m_target; |
---|
| 1574 | |
---|
| 1575 | creatureTarget->setDeathState(JUST_DIED); |
---|
| 1576 | creatureTarget->RemoveCorpse(); |
---|
| 1577 | creatureTarget->SetHealth(0); // just for nice GM-mode view |
---|
| 1578 | return; |
---|
| 1579 | } |
---|
| 1580 | // // Magic Sucker Device timer |
---|
| 1581 | // case 38672: break; |
---|
| 1582 | // // Tomb Guarding Charging |
---|
| 1583 | // case 38751: break; |
---|
| 1584 | // // Murmur's Touch |
---|
| 1585 | // case 38794: break; |
---|
| 1586 | // // Activate Nether-wraith Beacon (31742 Nether-wraith Beacon item) |
---|
| 1587 | // case 39105: break; |
---|
| 1588 | // // Drain World Tree Visual |
---|
| 1589 | // case 39140: break; |
---|
| 1590 | // // Quest - Dustin's Undead Dragon Visual aura |
---|
| 1591 | // case 39259: break; |
---|
| 1592 | // // Hellfire - The Exorcism, Jules releases darkness, aura |
---|
| 1593 | // case 39306: break; |
---|
| 1594 | // // Inferno |
---|
| 1595 | // case 39346: break; |
---|
| 1596 | // // Enchanted Weapons |
---|
| 1597 | // case 39489: break; |
---|
| 1598 | // // Shadow Bolt Whirl |
---|
| 1599 | // case 39630: break; |
---|
| 1600 | // // Shadow Bolt Whirl |
---|
| 1601 | // case 39634: break; |
---|
| 1602 | // // Shadow Inferno |
---|
| 1603 | // case 39645: break; |
---|
| 1604 | // Tear of Azzinoth Summon Channel - it's not really supposed to do anything,and this only prevents the console spam |
---|
| 1605 | case 39857: trigger_spell_id = 39856; break; |
---|
| 1606 | // // Soulgrinder Ritual Visual (Smashed) |
---|
| 1607 | // case 39974: break; |
---|
| 1608 | // // Simon Game Pre-game timer |
---|
| 1609 | // case 40041: break; |
---|
| 1610 | // // Knockdown Fel Cannon: The Aggro Check Aura |
---|
| 1611 | // case 40113: break; |
---|
| 1612 | // // Spirit Lance |
---|
| 1613 | // case 40157: break; |
---|
| 1614 | // // Demon Transform 2 |
---|
| 1615 | // case 40398: break; |
---|
| 1616 | // // Demon Transform 1 |
---|
| 1617 | // case 40511: break; |
---|
| 1618 | // // Ancient Flames |
---|
| 1619 | // case 40657: break; |
---|
| 1620 | // // Ethereal Ring Cannon: Cannon Aura |
---|
| 1621 | // case 40734: break; |
---|
| 1622 | // // Cage Trap |
---|
| 1623 | // case 40760: break; |
---|
| 1624 | // // Random Periodic |
---|
| 1625 | // case 40867: break; |
---|
| 1626 | // // Prismatic Shield |
---|
| 1627 | // case 40879: break; |
---|
[57] | 1628 | // Aura of Desire |
---|
| 1629 | case 41350: |
---|
| 1630 | { |
---|
| 1631 | Unit::AuraList const& mMod = m_target->GetAurasByType(SPELL_AURA_MOD_INCREASE_ENERGY_PERCENT); |
---|
| 1632 | for(Unit::AuraList::const_iterator i = mMod.begin(); i != mMod.end(); ++i) |
---|
| 1633 | { |
---|
| 1634 | if ((*i)->GetId() == 41350) |
---|
| 1635 | { |
---|
| 1636 | (*i)->ApplyModifier(false); |
---|
| 1637 | (*i)->GetModifier()->m_amount -= 5; |
---|
| 1638 | (*i)->ApplyModifier(true); |
---|
| 1639 | break; |
---|
| 1640 | } |
---|
| 1641 | } |
---|
| 1642 | }break; |
---|
[37] | 1643 | // // Dementia |
---|
| 1644 | // case 41404: break; |
---|
| 1645 | // // Chaos Form |
---|
| 1646 | // case 41629: break; |
---|
| 1647 | // // Alert Drums |
---|
| 1648 | // case 42177: break; |
---|
| 1649 | // // Spout |
---|
| 1650 | // case 42581: break; |
---|
| 1651 | // // Spout |
---|
| 1652 | // case 42582: break; |
---|
| 1653 | // // Return to the Spirit Realm |
---|
| 1654 | // case 44035: break; |
---|
| 1655 | // // Curse of Boundless Agony |
---|
| 1656 | // case 45050: break; |
---|
| 1657 | // // Earthquake |
---|
| 1658 | // case 46240: break; |
---|
| 1659 | // Personalized Weather |
---|
| 1660 | case 46736: trigger_spell_id = 46737; break; |
---|
| 1661 | // // Stay Submerged |
---|
| 1662 | // case 46981: break; |
---|
| 1663 | // // Dragonblight Ram |
---|
| 1664 | // case 47015: break; |
---|
| 1665 | // // Party G.R.E.N.A.D.E. |
---|
| 1666 | // case 51510: break; |
---|
| 1667 | default: |
---|
| 1668 | break; |
---|
| 1669 | } |
---|
| 1670 | break; |
---|
| 1671 | } |
---|
| 1672 | case SPELLFAMILY_MAGE: |
---|
| 1673 | { |
---|
| 1674 | switch(auraId) |
---|
| 1675 | { |
---|
| 1676 | // Invisibility |
---|
| 1677 | case 66: |
---|
| 1678 | { |
---|
| 1679 | if(!m_duration) |
---|
| 1680 | m_target->CastSpell(m_target, 32612, true, NULL, this); |
---|
| 1681 | return; |
---|
| 1682 | } |
---|
| 1683 | default: |
---|
| 1684 | break; |
---|
| 1685 | } |
---|
| 1686 | break; |
---|
| 1687 | } |
---|
| 1688 | // case SPELLFAMILY_WARRIOR: |
---|
| 1689 | // { |
---|
| 1690 | // switch(auraId) |
---|
| 1691 | // { |
---|
| 1692 | // // Wild Magic |
---|
| 1693 | // case 23410: break; |
---|
| 1694 | // // Corrupted Totems |
---|
| 1695 | // case 23425: break; |
---|
| 1696 | // default: |
---|
| 1697 | // break; |
---|
| 1698 | // } |
---|
| 1699 | // break; |
---|
| 1700 | // } |
---|
| 1701 | // case SPELLFAMILY_PRIEST: |
---|
| 1702 | // { |
---|
| 1703 | // switch(auraId) |
---|
| 1704 | // { |
---|
| 1705 | // // Blue Beam |
---|
| 1706 | // case 32930: break; |
---|
| 1707 | // // Fury of the Dreghood Elders |
---|
| 1708 | // case 35460: break; |
---|
| 1709 | // default: |
---|
| 1710 | // break; |
---|
| 1711 | // } |
---|
| 1712 | // break; |
---|
| 1713 | // } |
---|
| 1714 | case SPELLFAMILY_DRUID: |
---|
| 1715 | { |
---|
| 1716 | switch(auraId) |
---|
| 1717 | { |
---|
| 1718 | // Cat Form |
---|
| 1719 | // trigger_spell_id not set and unknown effect triggered in this case, ignoring for while |
---|
| 1720 | case 768: |
---|
| 1721 | return; |
---|
| 1722 | // Frenzied Regeneration |
---|
| 1723 | case 22842: |
---|
| 1724 | case 22895: |
---|
| 1725 | case 22896: |
---|
| 1726 | case 26999: |
---|
| 1727 | { |
---|
| 1728 | int32 LifePerRage = GetModifier()->m_amount; |
---|
| 1729 | |
---|
| 1730 | int32 lRage = m_target->GetPower(POWER_RAGE); |
---|
| 1731 | if(lRage > 100) // rage stored as rage*10 |
---|
| 1732 | lRage = 100; |
---|
| 1733 | m_target->ModifyPower(POWER_RAGE, -lRage); |
---|
| 1734 | int32 FRTriggerBasePoints = int32(lRage*LifePerRage/10); |
---|
| 1735 | m_target->CastCustomSpell(m_target,22845,&FRTriggerBasePoints,NULL,NULL,true,NULL,this); |
---|
| 1736 | return; |
---|
| 1737 | } |
---|
| 1738 | default: |
---|
| 1739 | break; |
---|
| 1740 | } |
---|
| 1741 | break; |
---|
| 1742 | } |
---|
| 1743 | |
---|
| 1744 | // case SPELLFAMILY_HUNTER: |
---|
| 1745 | // { |
---|
| 1746 | // switch(auraId) |
---|
| 1747 | // { |
---|
| 1748 | // //Frost Trap Aura |
---|
| 1749 | // case 13810: |
---|
| 1750 | // return; |
---|
| 1751 | // //Rizzle's Frost Trap |
---|
| 1752 | // case 39900: |
---|
| 1753 | // return; |
---|
| 1754 | // // Tame spells |
---|
| 1755 | // case 19597: // Tame Ice Claw Bear |
---|
| 1756 | // case 19676: // Tame Snow Leopard |
---|
| 1757 | // case 19677: // Tame Large Crag Boar |
---|
| 1758 | // case 19678: // Tame Adult Plainstrider |
---|
| 1759 | // case 19679: // Tame Prairie Stalker |
---|
| 1760 | // case 19680: // Tame Swoop |
---|
| 1761 | // case 19681: // Tame Dire Mottled Boar |
---|
| 1762 | // case 19682: // Tame Surf Crawler |
---|
| 1763 | // case 19683: // Tame Armored Scorpid |
---|
| 1764 | // case 19684: // Tame Webwood Lurker |
---|
| 1765 | // case 19685: // Tame Nightsaber Stalker |
---|
| 1766 | // case 19686: // Tame Strigid Screecher |
---|
| 1767 | // case 30100: // Tame Crazed Dragonhawk |
---|
| 1768 | // case 30103: // Tame Elder Springpaw |
---|
| 1769 | // case 30104: // Tame Mistbat |
---|
| 1770 | // case 30647: // Tame Barbed Crawler |
---|
| 1771 | // case 30648: // Tame Greater Timberstrider |
---|
| 1772 | // case 30652: // Tame Nightstalker |
---|
| 1773 | // return; |
---|
| 1774 | // default: |
---|
| 1775 | // break; |
---|
| 1776 | // } |
---|
| 1777 | // break; |
---|
| 1778 | // } |
---|
| 1779 | case SPELLFAMILY_SHAMAN: |
---|
| 1780 | { |
---|
| 1781 | switch(auraId) |
---|
| 1782 | { |
---|
| 1783 | // Lightning Shield (The Earthshatterer set trigger after cast Lighting Shield) |
---|
| 1784 | case 28820: |
---|
| 1785 | { |
---|
| 1786 | // Need remove self if Lightning Shield not active |
---|
| 1787 | Unit::AuraMap const& auras = target->GetAuras(); |
---|
| 1788 | for(Unit::AuraMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) |
---|
| 1789 | { |
---|
| 1790 | SpellEntry const* spell = itr->second->GetSpellProto(); |
---|
| 1791 | if( spell->SpellFamilyName == SPELLFAMILY_SHAMAN && |
---|
| 1792 | spell->SpellFamilyFlags & 0x0000000000000400L) |
---|
| 1793 | return; |
---|
| 1794 | } |
---|
| 1795 | target->RemoveAurasDueToSpell(28820); |
---|
| 1796 | return; |
---|
| 1797 | } |
---|
| 1798 | // Totemic Mastery (Skyshatter Regalia (Shaman Tier 6) - bonus) |
---|
| 1799 | case 38443: |
---|
| 1800 | { |
---|
| 1801 | bool all = true; |
---|
| 1802 | for(int i = 0; i < MAX_TOTEM; ++i) |
---|
| 1803 | { |
---|
| 1804 | if(!caster->m_TotemSlot[i]) |
---|
| 1805 | { |
---|
| 1806 | all = false; |
---|
| 1807 | break; |
---|
| 1808 | } |
---|
| 1809 | } |
---|
| 1810 | |
---|
| 1811 | if(all) |
---|
| 1812 | caster->CastSpell(caster,38437,true); |
---|
| 1813 | else |
---|
| 1814 | caster->RemoveAurasDueToSpell(38437); |
---|
| 1815 | return; |
---|
| 1816 | } |
---|
| 1817 | default: |
---|
| 1818 | break; |
---|
| 1819 | } |
---|
| 1820 | break; |
---|
| 1821 | } |
---|
| 1822 | default: |
---|
| 1823 | break; |
---|
| 1824 | } |
---|
| 1825 | // Reget trigger spell proto |
---|
| 1826 | triggredSpellInfo = sSpellStore.LookupEntry(trigger_spell_id); |
---|
| 1827 | if(triggredSpellInfo == NULL) |
---|
| 1828 | { |
---|
| 1829 | sLog.outError("Aura::TriggerSpell: Spell %u have 0 in EffectTriggered[%d], not handled custom case?",GetId(),GetEffIndex()); |
---|
| 1830 | return; |
---|
| 1831 | } |
---|
| 1832 | } |
---|
| 1833 | else |
---|
| 1834 | { |
---|
| 1835 | // Spell exist but require costum code |
---|
| 1836 | switch(auraId) |
---|
| 1837 | { |
---|
| 1838 | // Curse of Idiocy |
---|
| 1839 | case 1010: |
---|
| 1840 | { |
---|
| 1841 | // TODO: spell casted by result in correct way mostly |
---|
| 1842 | // BUT: |
---|
| 1843 | // 1) target show casting at each triggered cast: target don't must show casting animation for any triggered spell |
---|
| 1844 | // but must show affect apply like item casting |
---|
| 1845 | // 2) maybe aura must be replace by new with accumulative stat mods insteed stacking |
---|
| 1846 | |
---|
| 1847 | // prevent cast by triggered auras |
---|
| 1848 | if(m_caster_guid == m_target->GetGUID()) |
---|
| 1849 | return; |
---|
| 1850 | |
---|
| 1851 | // stop triggering after each affected stats lost > 90 |
---|
| 1852 | int32 intelectLoss = 0; |
---|
| 1853 | int32 spiritLoss = 0; |
---|
| 1854 | |
---|
| 1855 | Unit::AuraList const& mModStat = m_target->GetAurasByType(SPELL_AURA_MOD_STAT); |
---|
| 1856 | for(Unit::AuraList::const_iterator i = mModStat.begin(); i != mModStat.end(); ++i) |
---|
| 1857 | { |
---|
| 1858 | if ((*i)->GetId() == 1010) |
---|
| 1859 | { |
---|
| 1860 | switch((*i)->GetModifier()->m_miscvalue) |
---|
| 1861 | { |
---|
| 1862 | case STAT_INTELLECT: intelectLoss += (*i)->GetModifier()->m_amount; break; |
---|
| 1863 | case STAT_SPIRIT: spiritLoss += (*i)->GetModifier()->m_amount; break; |
---|
| 1864 | default: break; |
---|
| 1865 | } |
---|
| 1866 | } |
---|
| 1867 | } |
---|
| 1868 | |
---|
| 1869 | if(intelectLoss <= -90 && spiritLoss <= -90) |
---|
| 1870 | return; |
---|
| 1871 | |
---|
| 1872 | caster = target; |
---|
| 1873 | originalCasterGUID = 0; |
---|
| 1874 | break; |
---|
| 1875 | } |
---|
| 1876 | // Mana Tide |
---|
| 1877 | case 16191: |
---|
| 1878 | { |
---|
| 1879 | caster->CastCustomSpell(target, trigger_spell_id, &m_modifier.m_amount, NULL, NULL, true, NULL, this, originalCasterGUID); |
---|
| 1880 | return; |
---|
| 1881 | } |
---|
| 1882 | } |
---|
| 1883 | } |
---|
[162] | 1884 | m_target->CastSpell(target, triggredSpellInfo, true, 0, this, originalCasterGUID); |
---|
| 1885 | /*// All ok cast by default case |
---|
[139] | 1886 | Spell *spell = new Spell(m_target, triggredSpellInfo, true, originalCasterGUID ); |
---|
[37] | 1887 | |
---|
| 1888 | SpellCastTargets targets; |
---|
| 1889 | targets.setUnitTarget( target ); |
---|
| 1890 | |
---|
| 1891 | // if spell create dynamic object extract area from it |
---|
| 1892 | if(DynamicObject* dynObj = caster->GetDynObject(GetId())) |
---|
| 1893 | targets.setDestination(dynObj->GetPositionX(),dynObj->GetPositionY(),dynObj->GetPositionZ()); |
---|
| 1894 | |
---|
[162] | 1895 | spell->prepare(&targets, this);*/ |
---|
[37] | 1896 | } |
---|
| 1897 | |
---|
| 1898 | /*********************************************************/ |
---|
| 1899 | /*** AURA EFFECTS ***/ |
---|
| 1900 | /*********************************************************/ |
---|
| 1901 | |
---|
| 1902 | void Aura::HandleAuraDummy(bool apply, bool Real) |
---|
| 1903 | { |
---|
| 1904 | // spells required only Real aura add/remove |
---|
| 1905 | if(!Real) |
---|
| 1906 | return; |
---|
| 1907 | |
---|
| 1908 | Unit* caster = GetCaster(); |
---|
| 1909 | |
---|
| 1910 | // AT APPLY |
---|
| 1911 | if(apply) |
---|
| 1912 | { |
---|
| 1913 | switch(GetId()) |
---|
| 1914 | { |
---|
| 1915 | case 1515: // Tame beast |
---|
| 1916 | // FIX_ME: this is 2.0.12 threat effect replaced in 2.1.x by dummy aura, must be checked for correctness |
---|
| 1917 | if( caster && m_target->CanHaveThreatList()) |
---|
| 1918 | m_target->AddThreat(caster, 10.0f); |
---|
| 1919 | return; |
---|
| 1920 | case 13139: // net-o-matic |
---|
| 1921 | // root to self part of (root_target->charge->root_self sequence |
---|
| 1922 | if(caster) |
---|
| 1923 | caster->CastSpell(caster,13138,true,NULL,this); |
---|
| 1924 | return; |
---|
| 1925 | case 39850: // Rocket Blast |
---|
| 1926 | if(roll_chance_i(20)) // backfire stun |
---|
| 1927 | m_target->CastSpell(m_target, 51581, true, NULL, this); |
---|
| 1928 | return; |
---|
[73] | 1929 | case 43873: // Headless Horseman Laugh |
---|
| 1930 | if(caster->GetTypeId() == TYPEID_PLAYER) |
---|
[74] | 1931 | ((Player*)caster)->SendPlaySound(11965, false); |
---|
[73] | 1932 | return; |
---|
[37] | 1933 | case 46354: // Blood Elf Illusion |
---|
| 1934 | if(caster) |
---|
| 1935 | { |
---|
| 1936 | switch(caster->getGender()) |
---|
| 1937 | { |
---|
| 1938 | case GENDER_FEMALE: |
---|
| 1939 | caster->CastSpell(m_target,46356,true,NULL,this); |
---|
| 1940 | break; |
---|
| 1941 | case GENDER_MALE: |
---|
| 1942 | caster->CastSpell(m_target,46355,true,NULL,this); |
---|
| 1943 | break; |
---|
| 1944 | default: |
---|
| 1945 | break; |
---|
| 1946 | } |
---|
| 1947 | } |
---|
| 1948 | return; |
---|
| 1949 | case 46699: // Requires No Ammo |
---|
| 1950 | if(m_target->GetTypeId()==TYPEID_PLAYER) |
---|
| 1951 | ((Player*)m_target)->RemoveAmmo(); // not use ammo and not allow use |
---|
| 1952 | return; |
---|
| 1953 | } |
---|
| 1954 | |
---|
| 1955 | // Earth Shield |
---|
| 1956 | if ( caster && GetSpellProto()->SpellFamilyName == SPELLFAMILY_SHAMAN && (GetSpellProto()->SpellFamilyFlags & 0x40000000000LL)) |
---|
| 1957 | { |
---|
| 1958 | // prevent double apply bonuses |
---|
| 1959 | if(m_target->GetTypeId()!=TYPEID_PLAYER || !((Player*)m_target)->GetSession()->PlayerLoading()) |
---|
| 1960 | m_modifier.m_amount = caster->SpellHealingBonus(GetSpellProto(), m_modifier.m_amount, SPELL_DIRECT_DAMAGE, m_target); |
---|
| 1961 | return; |
---|
| 1962 | } |
---|
| 1963 | } |
---|
| 1964 | // AT REMOVE |
---|
| 1965 | else |
---|
| 1966 | { |
---|
| 1967 | if( m_target->GetTypeId() == TYPEID_PLAYER && |
---|
| 1968 | ( GetSpellProto()->Effect[0]==72 || GetSpellProto()->Effect[0]==6 && |
---|
| 1969 | ( GetSpellProto()->EffectApplyAuraName[0]==1 || GetSpellProto()->EffectApplyAuraName[0]==128 ) ) ) |
---|
| 1970 | { |
---|
| 1971 | // spells with SpellEffect=72 and aura=4: 6196, 6197, 21171, 21425 |
---|
| 1972 | m_target->SetUInt64Value(PLAYER_FARSIGHT, 0); |
---|
| 1973 | WorldPacket data(SMSG_CLEAR_FAR_SIGHT_IMMEDIATE, 0); |
---|
| 1974 | ((Player*)m_target)->GetSession()->SendPacket(&data); |
---|
| 1975 | return; |
---|
| 1976 | } |
---|
| 1977 | |
---|
| 1978 | if( (IsQuestTameSpell(GetId())) && caster && caster->isAlive() && m_target->isAlive()) |
---|
| 1979 | { |
---|
| 1980 | uint32 finalSpelId = 0; |
---|
| 1981 | switch(GetId()) |
---|
| 1982 | { |
---|
| 1983 | case 19548: finalSpelId = 19597; break; |
---|
| 1984 | case 19674: finalSpelId = 19677; break; |
---|
| 1985 | case 19687: finalSpelId = 19676; break; |
---|
| 1986 | case 19688: finalSpelId = 19678; break; |
---|
| 1987 | case 19689: finalSpelId = 19679; break; |
---|
| 1988 | case 19692: finalSpelId = 19680; break; |
---|
| 1989 | case 19693: finalSpelId = 19684; break; |
---|
| 1990 | case 19694: finalSpelId = 19681; break; |
---|
| 1991 | case 19696: finalSpelId = 19682; break; |
---|
| 1992 | case 19697: finalSpelId = 19683; break; |
---|
| 1993 | case 19699: finalSpelId = 19685; break; |
---|
| 1994 | case 19700: finalSpelId = 19686; break; |
---|
| 1995 | case 30646: finalSpelId = 30647; break; |
---|
| 1996 | case 30653: finalSpelId = 30648; break; |
---|
| 1997 | case 30654: finalSpelId = 30652; break; |
---|
| 1998 | case 30099: finalSpelId = 30100; break; |
---|
| 1999 | case 30102: finalSpelId = 30103; break; |
---|
| 2000 | case 30105: finalSpelId = 30104; break; |
---|
| 2001 | } |
---|
| 2002 | |
---|
| 2003 | if(finalSpelId) |
---|
| 2004 | caster->CastSpell(m_target,finalSpelId,true,NULL,this); |
---|
| 2005 | return; |
---|
| 2006 | } |
---|
[174] | 2007 | |
---|
[37] | 2008 | // Dark Fiend |
---|
| 2009 | if(GetId()==45934) |
---|
| 2010 | { |
---|
| 2011 | // Kill target if dispeled |
---|
| 2012 | if (m_removeMode==AURA_REMOVE_BY_DISPEL) |
---|
| 2013 | m_target->DealDamage(m_target, m_target->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); |
---|
| 2014 | return; |
---|
| 2015 | } |
---|
| 2016 | |
---|
| 2017 | // Burning Winds |
---|
| 2018 | if(GetId()==46308) // casted only at creatures at spawn |
---|
| 2019 | { |
---|
| 2020 | m_target->CastSpell(m_target,47287,true,NULL,this); |
---|
| 2021 | return; |
---|
| 2022 | } |
---|
[174] | 2023 | |
---|
| 2024 | // Eye of Kilrogg, unsummon eye when aura is gone |
---|
| 2025 | if(GetId() == 126 && caster->GetTypeId() == TYPEID_PLAYER && caster->GetCharm()) |
---|
| 2026 | { |
---|
| 2027 | ((TemporarySummon*)caster->GetCharm())->UnSummon(); |
---|
| 2028 | return; |
---|
| 2029 | } |
---|
[37] | 2030 | } |
---|
| 2031 | |
---|
| 2032 | // AT APPLY & REMOVE |
---|
| 2033 | |
---|
| 2034 | switch(m_spellProto->SpellFamilyName) |
---|
| 2035 | { |
---|
| 2036 | case SPELLFAMILY_GENERIC: |
---|
| 2037 | { |
---|
| 2038 | // Unstable Power |
---|
| 2039 | if( GetId()==24658 ) |
---|
| 2040 | { |
---|
| 2041 | uint32 spellId = 24659; |
---|
| 2042 | if (apply) |
---|
| 2043 | { |
---|
| 2044 | const SpellEntry *spell = sSpellStore.LookupEntry(spellId); |
---|
| 2045 | if (!spell) |
---|
| 2046 | return; |
---|
| 2047 | for (int i=0; i < spell->StackAmount; ++i) |
---|
| 2048 | caster->CastSpell(m_target, spell->Id, true, NULL, NULL, GetCasterGUID()); |
---|
| 2049 | return; |
---|
| 2050 | } |
---|
| 2051 | m_target->RemoveAurasDueToSpell(spellId); |
---|
| 2052 | return; |
---|
| 2053 | } |
---|
| 2054 | // Restless Strength |
---|
| 2055 | if( GetId()==24661 ) |
---|
| 2056 | { |
---|
| 2057 | uint32 spellId = 24662; |
---|
| 2058 | if (apply) |
---|
| 2059 | { |
---|
| 2060 | const SpellEntry *spell = sSpellStore.LookupEntry(spellId); |
---|
| 2061 | if (!spell) |
---|
| 2062 | return; |
---|
| 2063 | for (int i=0; i < spell->StackAmount; ++i) |
---|
| 2064 | caster->CastSpell(m_target, spell->Id, true, NULL, NULL, GetCasterGUID()); |
---|
| 2065 | return; |
---|
| 2066 | } |
---|
| 2067 | m_target->RemoveAurasDueToSpell(spellId); |
---|
| 2068 | return; |
---|
| 2069 | } |
---|
| 2070 | // Victorious |
---|
| 2071 | if(GetId()==32216 && m_target->getClass()==CLASS_WARRIOR) |
---|
| 2072 | { |
---|
| 2073 | m_target->ModifyAuraState(AURA_STATE_WARRIOR_VICTORY_RUSH, apply); |
---|
| 2074 | return; |
---|
| 2075 | } |
---|
| 2076 | //Summon Fire Elemental |
---|
| 2077 | if (GetId() == 40133 && caster) |
---|
| 2078 | { |
---|
| 2079 | Unit *owner = caster->GetOwner(); |
---|
| 2080 | if (owner && owner->GetTypeId() == TYPEID_PLAYER) |
---|
| 2081 | { |
---|
| 2082 | if(apply) |
---|
| 2083 | owner->CastSpell(owner,8985,true); |
---|
| 2084 | else |
---|
| 2085 | ((Player*)owner)->RemovePet(NULL, PET_SAVE_NOT_IN_SLOT, true); |
---|
| 2086 | } |
---|
| 2087 | return; |
---|
| 2088 | } |
---|
| 2089 | |
---|
| 2090 | //Summon Earth Elemental |
---|
| 2091 | if (GetId() == 40132 && caster) |
---|
| 2092 | { |
---|
| 2093 | Unit *owner = caster->GetOwner(); |
---|
| 2094 | if (owner && owner->GetTypeId() == TYPEID_PLAYER) |
---|
| 2095 | { |
---|
| 2096 | if(apply) |
---|
| 2097 | owner->CastSpell(owner,19704,true); |
---|
| 2098 | else |
---|
| 2099 | ((Player*)owner)->RemovePet(NULL, PET_SAVE_NOT_IN_SLOT, true); |
---|
| 2100 | } |
---|
| 2101 | return; |
---|
| 2102 | } |
---|
| 2103 | break; |
---|
| 2104 | } |
---|
| 2105 | case SPELLFAMILY_MAGE: |
---|
| 2106 | { |
---|
| 2107 | // Hypothermia |
---|
| 2108 | if( GetId()==41425 ) |
---|
| 2109 | { |
---|
| 2110 | m_target->ModifyAuraState(AURA_STATE_HYPOTHERMIA,apply); |
---|
| 2111 | return; |
---|
| 2112 | } |
---|
| 2113 | break; |
---|
| 2114 | } |
---|
| 2115 | case SPELLFAMILY_DRUID: |
---|
| 2116 | { |
---|
| 2117 | // Lifebloom |
---|
| 2118 | if ( GetSpellProto()->SpellFamilyFlags & 0x1000000000LL ) |
---|
| 2119 | { |
---|
| 2120 | if ( apply ) |
---|
| 2121 | { |
---|
| 2122 | if ( caster ) |
---|
| 2123 | // prevent double apply bonuses |
---|
| 2124 | if(m_target->GetTypeId()!=TYPEID_PLAYER || !((Player*)m_target)->GetSession()->PlayerLoading()) |
---|
| 2125 | m_modifier.m_amount = caster->SpellHealingBonus(GetSpellProto(), m_modifier.m_amount, SPELL_DIRECT_DAMAGE, m_target); |
---|
| 2126 | } |
---|
| 2127 | else |
---|
| 2128 | { |
---|
| 2129 | // Final heal only on dispelled or duration end |
---|
| 2130 | if ( !(GetAuraDuration() <= 0 || m_removeMode==AURA_REMOVE_BY_DISPEL) ) |
---|
| 2131 | return; |
---|
| 2132 | |
---|
| 2133 | // have a look if there is still some other Lifebloom dummy aura |
---|
| 2134 | Unit::AuraList auras = m_target->GetAurasByType(SPELL_AURA_DUMMY); |
---|
| 2135 | for(Unit::AuraList::iterator itr = auras.begin(); itr!=auras.end(); itr++) |
---|
| 2136 | if((*itr)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_DRUID && |
---|
| 2137 | (*itr)->GetSpellProto()->SpellFamilyFlags & 0x1000000000LL) |
---|
| 2138 | return; |
---|
| 2139 | |
---|
| 2140 | // final heal |
---|
| 2141 | m_target->CastCustomSpell(m_target,33778,&m_modifier.m_amount,NULL,NULL,true,NULL,this,GetCasterGUID()); |
---|
| 2142 | } |
---|
| 2143 | return; |
---|
| 2144 | } |
---|
| 2145 | |
---|
| 2146 | // Predatory Strikes |
---|
| 2147 | if(m_target->GetTypeId()==TYPEID_PLAYER && GetSpellProto()->SpellIconID == 1563) |
---|
| 2148 | { |
---|
| 2149 | ((Player*)m_target)->UpdateAttackPowerAndDamage(); |
---|
| 2150 | return; |
---|
| 2151 | } |
---|
| 2152 | // Idol of the Emerald Queen |
---|
| 2153 | if ( GetId() == 34246 && m_target->GetTypeId()==TYPEID_PLAYER ) |
---|
| 2154 | { |
---|
| 2155 | if(apply) |
---|
| 2156 | { |
---|
| 2157 | SpellModifier *mod = new SpellModifier; |
---|
| 2158 | mod->op = SPELLMOD_DOT; |
---|
| 2159 | mod->value = m_modifier.m_amount/7; |
---|
| 2160 | mod->type = SPELLMOD_FLAT; |
---|
| 2161 | mod->spellId = GetId(); |
---|
| 2162 | mod->effectId = m_effIndex; |
---|
| 2163 | mod->lastAffected = NULL; |
---|
| 2164 | mod->mask = 0x001000000000LL; |
---|
| 2165 | mod->charges = 0; |
---|
| 2166 | |
---|
| 2167 | m_spellmod = mod; |
---|
| 2168 | } |
---|
| 2169 | |
---|
| 2170 | ((Player*)m_target)->AddSpellMod(m_spellmod, apply); |
---|
| 2171 | return; |
---|
| 2172 | } |
---|
| 2173 | break; |
---|
| 2174 | } |
---|
| 2175 | case SPELLFAMILY_HUNTER: |
---|
| 2176 | { |
---|
| 2177 | // Improved Aspect of the Viper |
---|
| 2178 | if( GetId()==38390 && m_target->GetTypeId()==TYPEID_PLAYER ) |
---|
| 2179 | { |
---|
| 2180 | if(apply) |
---|
| 2181 | { |
---|
| 2182 | // + effect value for Aspect of the Viper |
---|
| 2183 | SpellModifier *mod = new SpellModifier; |
---|
| 2184 | mod->op = SPELLMOD_EFFECT1; |
---|
| 2185 | mod->value = m_modifier.m_amount; |
---|
| 2186 | mod->type = SPELLMOD_FLAT; |
---|
| 2187 | mod->spellId = GetId(); |
---|
| 2188 | mod->effectId = m_effIndex; |
---|
| 2189 | mod->lastAffected = NULL; |
---|
| 2190 | mod->mask = 0x4000000000000LL; |
---|
| 2191 | mod->charges = 0; |
---|
| 2192 | |
---|
| 2193 | m_spellmod = mod; |
---|
| 2194 | } |
---|
| 2195 | |
---|
| 2196 | ((Player*)m_target)->AddSpellMod(m_spellmod, apply); |
---|
| 2197 | return; |
---|
| 2198 | } |
---|
| 2199 | break; |
---|
| 2200 | } |
---|
| 2201 | case SPELLFAMILY_SHAMAN: |
---|
| 2202 | { |
---|
| 2203 | // Improved Weapon Totems |
---|
| 2204 | if( GetSpellProto()->SpellIconID == 57 && m_target->GetTypeId()==TYPEID_PLAYER ) |
---|
| 2205 | { |
---|
| 2206 | if(apply) |
---|
| 2207 | { |
---|
| 2208 | SpellModifier *mod = new SpellModifier; |
---|
| 2209 | mod->op = SPELLMOD_EFFECT1; |
---|
| 2210 | mod->value = m_modifier.m_amount; |
---|
| 2211 | mod->type = SPELLMOD_PCT; |
---|
| 2212 | mod->spellId = GetId(); |
---|
| 2213 | mod->effectId = m_effIndex; |
---|
| 2214 | mod->lastAffected = NULL; |
---|
| 2215 | switch (m_effIndex) |
---|
| 2216 | { |
---|
| 2217 | case 0: |
---|
| 2218 | mod->mask = 0x00200000000LL; // Windfury Totem |
---|
| 2219 | break; |
---|
| 2220 | case 1: |
---|
| 2221 | mod->mask = 0x00400000000LL; // Flametongue Totem |
---|
| 2222 | break; |
---|
| 2223 | } |
---|
| 2224 | mod->charges = 0; |
---|
| 2225 | |
---|
| 2226 | m_spellmod = mod; |
---|
| 2227 | } |
---|
| 2228 | |
---|
| 2229 | ((Player*)m_target)->AddSpellMod(m_spellmod, apply); |
---|
| 2230 | return; |
---|
| 2231 | } |
---|
| 2232 | break; |
---|
| 2233 | } |
---|
| 2234 | } |
---|
| 2235 | |
---|
| 2236 | // pet auras |
---|
| 2237 | if(PetAura const* petSpell = spellmgr.GetPetAura(GetId())) |
---|
| 2238 | { |
---|
| 2239 | if(apply) |
---|
| 2240 | m_target->AddPetAura(petSpell); |
---|
| 2241 | else |
---|
| 2242 | m_target->RemovePetAura(petSpell); |
---|
| 2243 | return; |
---|
| 2244 | } |
---|
| 2245 | } |
---|
| 2246 | |
---|
| 2247 | void Aura::HandleAuraPeriodicDummy(bool apply, bool Real) |
---|
| 2248 | { |
---|
| 2249 | // spells required only Real aura add/remove |
---|
| 2250 | if(!Real) |
---|
| 2251 | return; |
---|
| 2252 | |
---|
| 2253 | SpellEntry const*spell = GetSpellProto(); |
---|
| 2254 | switch( spell->SpellFamilyName) |
---|
| 2255 | { |
---|
| 2256 | case SPELLFAMILY_ROGUE: |
---|
| 2257 | { |
---|
| 2258 | // Master of Subtlety |
---|
| 2259 | if (spell->Id==31666 && !apply && Real) |
---|
| 2260 | { |
---|
| 2261 | m_target->RemoveAurasDueToSpell(31665); |
---|
| 2262 | break; |
---|
| 2263 | } |
---|
| 2264 | break; |
---|
| 2265 | } |
---|
| 2266 | case SPELLFAMILY_HUNTER: |
---|
| 2267 | { |
---|
| 2268 | // Aspect of the Viper |
---|
| 2269 | if (spell->SpellFamilyFlags&0x0004000000000000LL) |
---|
| 2270 | { |
---|
| 2271 | // Update regen on remove |
---|
| 2272 | if (!apply && m_target->GetTypeId() == TYPEID_PLAYER) |
---|
| 2273 | ((Player*)m_target)->UpdateManaRegen(); |
---|
| 2274 | break; |
---|
| 2275 | } |
---|
| 2276 | break; |
---|
| 2277 | } |
---|
| 2278 | } |
---|
| 2279 | |
---|
| 2280 | m_isPeriodic = apply; |
---|
| 2281 | } |
---|
| 2282 | |
---|
| 2283 | void Aura::HandleAuraMounted(bool apply, bool Real) |
---|
| 2284 | { |
---|
| 2285 | if(apply) |
---|
| 2286 | { |
---|
| 2287 | CreatureInfo const* ci = objmgr.GetCreatureTemplate(m_modifier.m_miscvalue); |
---|
| 2288 | if(!ci) |
---|
| 2289 | { |
---|
| 2290 | sLog.outErrorDb("AuraMounted: `creature_template`='%u' not found in database (only need it modelid)", m_modifier.m_miscvalue); |
---|
| 2291 | return; |
---|
| 2292 | } |
---|
| 2293 | |
---|
| 2294 | uint32 team = 0; |
---|
| 2295 | if (m_target->GetTypeId()==TYPEID_PLAYER) |
---|
| 2296 | team = ((Player*)m_target)->GetTeam(); |
---|
| 2297 | |
---|
| 2298 | uint32 display_id = objmgr.ChooseDisplayId(team,ci); |
---|
| 2299 | CreatureModelInfo const *minfo = objmgr.GetCreatureModelRandomGender(display_id); |
---|
| 2300 | if (minfo) |
---|
| 2301 | display_id = minfo->modelid; |
---|
| 2302 | |
---|
| 2303 | m_target->Mount(display_id); |
---|
| 2304 | } |
---|
| 2305 | else |
---|
| 2306 | { |
---|
| 2307 | m_target->Unmount(); |
---|
| 2308 | } |
---|
| 2309 | } |
---|
| 2310 | |
---|
| 2311 | void Aura::HandleAuraWaterWalk(bool apply, bool Real) |
---|
| 2312 | { |
---|
| 2313 | // only at real add/remove aura |
---|
| 2314 | if(!Real) |
---|
| 2315 | return; |
---|
| 2316 | |
---|
| 2317 | WorldPacket data; |
---|
| 2318 | if(apply) |
---|
| 2319 | data.Initialize(SMSG_MOVE_WATER_WALK, 8+4); |
---|
| 2320 | else |
---|
| 2321 | data.Initialize(SMSG_MOVE_LAND_WALK, 8+4); |
---|
| 2322 | data.append(m_target->GetPackGUID()); |
---|
| 2323 | data << uint32(0); |
---|
| 2324 | m_target->SendMessageToSet(&data,true); |
---|
| 2325 | } |
---|
| 2326 | |
---|
| 2327 | void Aura::HandleAuraFeatherFall(bool apply, bool Real) |
---|
| 2328 | { |
---|
| 2329 | // only at real add/remove aura |
---|
| 2330 | if(!Real) |
---|
| 2331 | return; |
---|
| 2332 | |
---|
| 2333 | WorldPacket data; |
---|
| 2334 | if(apply) |
---|
| 2335 | data.Initialize(SMSG_MOVE_FEATHER_FALL, 8+4); |
---|
| 2336 | else |
---|
| 2337 | data.Initialize(SMSG_MOVE_NORMAL_FALL, 8+4); |
---|
| 2338 | data.append(m_target->GetPackGUID()); |
---|
| 2339 | data << (uint32)0; |
---|
| 2340 | m_target->SendMessageToSet(&data,true); |
---|
| 2341 | } |
---|
| 2342 | |
---|
| 2343 | void Aura::HandleAuraHover(bool apply, bool Real) |
---|
| 2344 | { |
---|
| 2345 | // only at real add/remove aura |
---|
| 2346 | if(!Real) |
---|
| 2347 | return; |
---|
| 2348 | |
---|
| 2349 | WorldPacket data; |
---|
| 2350 | if(apply) |
---|
| 2351 | data.Initialize(SMSG_MOVE_SET_HOVER, 8+4); |
---|
| 2352 | else |
---|
| 2353 | data.Initialize(SMSG_MOVE_UNSET_HOVER, 8+4); |
---|
| 2354 | data.append(m_target->GetPackGUID()); |
---|
| 2355 | data << uint32(0); |
---|
| 2356 | m_target->SendMessageToSet(&data,true); |
---|
| 2357 | } |
---|
| 2358 | |
---|
| 2359 | void Aura::HandleWaterBreathing(bool apply, bool Real) |
---|
| 2360 | { |
---|
| 2361 | if(apply) |
---|
| 2362 | m_target->waterbreath = true; |
---|
| 2363 | else if(m_target->GetAurasByType(SPELL_AURA_WATER_BREATHING).empty()) |
---|
| 2364 | { |
---|
| 2365 | m_target->waterbreath = false; |
---|
| 2366 | |
---|
| 2367 | // update for enable timer in case not moving target |
---|
| 2368 | if(m_target->GetTypeId()==TYPEID_PLAYER && m_target->IsInWorld()) |
---|
| 2369 | { |
---|
| 2370 | ((Player*)m_target)->UpdateUnderwaterState(m_target->GetMap(),m_target->GetPositionX(),m_target->GetPositionY(),m_target->GetPositionZ()); |
---|
| 2371 | ((Player*)m_target)->HandleDrowning(); |
---|
| 2372 | } |
---|
| 2373 | } |
---|
| 2374 | } |
---|
| 2375 | |
---|
| 2376 | void Aura::HandleAuraModShapeshift(bool apply, bool Real) |
---|
| 2377 | { |
---|
| 2378 | if(!Real) |
---|
| 2379 | return; |
---|
| 2380 | |
---|
| 2381 | uint32 modelid = 0; |
---|
| 2382 | Powers PowerType = POWER_MANA; |
---|
| 2383 | ShapeshiftForm form = ShapeshiftForm(m_modifier.m_miscvalue); |
---|
| 2384 | switch(form) |
---|
| 2385 | { |
---|
| 2386 | case FORM_CAT: |
---|
| 2387 | if(Player::TeamForRace(m_target->getRace())==ALLIANCE) |
---|
| 2388 | modelid = 892; |
---|
| 2389 | else |
---|
| 2390 | modelid = 8571; |
---|
| 2391 | PowerType = POWER_ENERGY; |
---|
| 2392 | break; |
---|
| 2393 | case FORM_TRAVEL: |
---|
| 2394 | modelid = 632; |
---|
| 2395 | break; |
---|
| 2396 | case FORM_AQUA: |
---|
| 2397 | if(Player::TeamForRace(m_target->getRace())==ALLIANCE) |
---|
| 2398 | modelid = 2428; |
---|
| 2399 | else |
---|
| 2400 | modelid = 2428; |
---|
| 2401 | break; |
---|
| 2402 | case FORM_BEAR: |
---|
| 2403 | if(Player::TeamForRace(m_target->getRace())==ALLIANCE) |
---|
| 2404 | modelid = 2281; |
---|
| 2405 | else |
---|
| 2406 | modelid = 2289; |
---|
| 2407 | PowerType = POWER_RAGE; |
---|
| 2408 | break; |
---|
| 2409 | case FORM_GHOUL: |
---|
| 2410 | if(Player::TeamForRace(m_target->getRace())==ALLIANCE) |
---|
| 2411 | modelid = 10045; |
---|
| 2412 | break; |
---|
| 2413 | case FORM_DIREBEAR: |
---|
| 2414 | if(Player::TeamForRace(m_target->getRace())==ALLIANCE) |
---|
| 2415 | modelid = 2281; |
---|
| 2416 | else |
---|
| 2417 | modelid = 2289; |
---|
| 2418 | PowerType = POWER_RAGE; |
---|
| 2419 | break; |
---|
| 2420 | case FORM_CREATUREBEAR: |
---|
| 2421 | modelid = 902; |
---|
| 2422 | break; |
---|
| 2423 | case FORM_GHOSTWOLF: |
---|
| 2424 | modelid = 4613; |
---|
| 2425 | break; |
---|
| 2426 | case FORM_FLIGHT: |
---|
| 2427 | if(Player::TeamForRace(m_target->getRace())==ALLIANCE) |
---|
| 2428 | modelid = 20857; |
---|
| 2429 | else |
---|
| 2430 | modelid = 20872; |
---|
| 2431 | break; |
---|
| 2432 | case FORM_MOONKIN: |
---|
| 2433 | if(Player::TeamForRace(m_target->getRace())==ALLIANCE) |
---|
| 2434 | modelid = 15374; |
---|
| 2435 | else |
---|
| 2436 | modelid = 15375; |
---|
| 2437 | break; |
---|
| 2438 | case FORM_FLIGHT_EPIC: |
---|
| 2439 | if(Player::TeamForRace(m_target->getRace())==ALLIANCE) |
---|
| 2440 | modelid = 21243; |
---|
| 2441 | else |
---|
| 2442 | modelid = 21244; |
---|
| 2443 | break; |
---|
| 2444 | case FORM_AMBIENT: |
---|
| 2445 | case FORM_SHADOW: |
---|
| 2446 | case FORM_STEALTH: |
---|
| 2447 | break; |
---|
| 2448 | case FORM_TREE: |
---|
| 2449 | modelid = 864; |
---|
| 2450 | break; |
---|
| 2451 | case FORM_BATTLESTANCE: |
---|
| 2452 | case FORM_BERSERKERSTANCE: |
---|
| 2453 | case FORM_DEFENSIVESTANCE: |
---|
| 2454 | PowerType = POWER_RAGE; |
---|
| 2455 | break; |
---|
| 2456 | case FORM_SPIRITOFREDEMPTION: |
---|
| 2457 | modelid = 16031; |
---|
| 2458 | break; |
---|
| 2459 | default: |
---|
| 2460 | sLog.outError("Auras: Unknown Shapeshift Type: %u", m_modifier.m_miscvalue); |
---|
| 2461 | } |
---|
| 2462 | |
---|
| 2463 | // remove polymorph before changing display id to keep new display id |
---|
| 2464 | switch ( form ) |
---|
| 2465 | { |
---|
| 2466 | case FORM_CAT: |
---|
| 2467 | case FORM_TREE: |
---|
| 2468 | case FORM_TRAVEL: |
---|
| 2469 | case FORM_AQUA: |
---|
| 2470 | case FORM_BEAR: |
---|
| 2471 | case FORM_DIREBEAR: |
---|
| 2472 | case FORM_FLIGHT_EPIC: |
---|
| 2473 | case FORM_FLIGHT: |
---|
| 2474 | case FORM_MOONKIN: |
---|
| 2475 | // remove movement affects |
---|
| 2476 | m_target->RemoveSpellsCausingAura(SPELL_AURA_MOD_ROOT); |
---|
| 2477 | m_target->RemoveSpellsCausingAura(SPELL_AURA_MOD_DECREASE_SPEED); |
---|
| 2478 | |
---|
| 2479 | // and polymorphic affects |
---|
| 2480 | if(m_target->IsPolymorphed()) |
---|
| 2481 | m_target->RemoveAurasDueToSpell(m_target->getTransForm()); |
---|
| 2482 | break; |
---|
| 2483 | default: |
---|
| 2484 | break; |
---|
| 2485 | } |
---|
| 2486 | |
---|
| 2487 | if(apply) |
---|
| 2488 | { |
---|
| 2489 | // remove other shapeshift before applying a new one |
---|
| 2490 | if(m_target->m_ShapeShiftFormSpellId) |
---|
| 2491 | m_target->RemoveAurasDueToSpell(m_target->m_ShapeShiftFormSpellId,this); |
---|
| 2492 | |
---|
| 2493 | m_target->SetByteValue(UNIT_FIELD_BYTES_2, 3, form); |
---|
| 2494 | |
---|
| 2495 | if(modelid > 0) |
---|
| 2496 | m_target->SetDisplayId(modelid); |
---|
| 2497 | |
---|
| 2498 | if(PowerType != POWER_MANA) |
---|
| 2499 | { |
---|
| 2500 | // reset power to default values only at power change |
---|
| 2501 | if(m_target->getPowerType()!=PowerType) |
---|
| 2502 | m_target->setPowerType(PowerType); |
---|
| 2503 | |
---|
| 2504 | switch(form) |
---|
| 2505 | { |
---|
| 2506 | case FORM_CAT: |
---|
| 2507 | case FORM_BEAR: |
---|
| 2508 | case FORM_DIREBEAR: |
---|
| 2509 | { |
---|
| 2510 | // get furor proc chance |
---|
| 2511 | uint32 FurorChance = 0; |
---|
| 2512 | Unit::AuraList const& mDummy = m_target->GetAurasByType(SPELL_AURA_DUMMY); |
---|
| 2513 | for(Unit::AuraList::const_iterator i = mDummy.begin(); i != mDummy.end(); ++i) |
---|
| 2514 | { |
---|
| 2515 | if ((*i)->GetSpellProto()->SpellIconID == 238) |
---|
| 2516 | { |
---|
| 2517 | FurorChance = (*i)->GetModifier()->m_amount; |
---|
| 2518 | break; |
---|
| 2519 | } |
---|
| 2520 | } |
---|
| 2521 | |
---|
| 2522 | if (m_modifier.m_miscvalue == FORM_CAT) |
---|
| 2523 | { |
---|
| 2524 | m_target->SetPower(POWER_ENERGY,0); |
---|
| 2525 | if(urand(1,100) <= FurorChance) |
---|
| 2526 | m_target->CastSpell(m_target,17099,true,NULL,this); |
---|
| 2527 | } |
---|
| 2528 | else |
---|
| 2529 | { |
---|
| 2530 | m_target->SetPower(POWER_RAGE,0); |
---|
| 2531 | if(urand(1,100) <= FurorChance) |
---|
| 2532 | m_target->CastSpell(m_target,17057,true,NULL,this); |
---|
| 2533 | } |
---|
| 2534 | break; |
---|
| 2535 | } |
---|
| 2536 | case FORM_BATTLESTANCE: |
---|
| 2537 | case FORM_DEFENSIVESTANCE: |
---|
| 2538 | case FORM_BERSERKERSTANCE: |
---|
| 2539 | { |
---|
| 2540 | uint32 Rage_val = 0; |
---|
| 2541 | // Stance mastery + Tactical mastery (both passive, and last have aura only in defense stance, but need apply at any stance switch) |
---|
| 2542 | if(m_target->GetTypeId() == TYPEID_PLAYER) |
---|
| 2543 | { |
---|
| 2544 | PlayerSpellMap const& sp_list = ((Player *)m_target)->GetSpellMap(); |
---|
| 2545 | for (PlayerSpellMap::const_iterator itr = sp_list.begin(); itr != sp_list.end(); ++itr) |
---|
| 2546 | { |
---|
| 2547 | if(itr->second->state == PLAYERSPELL_REMOVED) continue; |
---|
| 2548 | SpellEntry const *spellInfo = sSpellStore.LookupEntry(itr->first); |
---|
| 2549 | if (spellInfo && spellInfo->SpellFamilyName == SPELLFAMILY_WARRIOR && spellInfo->SpellIconID == 139) |
---|
| 2550 | Rage_val += m_target->CalculateSpellDamage(spellInfo,0,spellInfo->EffectBasePoints[0],m_target) * 10; |
---|
| 2551 | } |
---|
| 2552 | } |
---|
| 2553 | |
---|
| 2554 | if (m_target->GetPower(POWER_RAGE) > Rage_val) |
---|
| 2555 | m_target->SetPower(POWER_RAGE,Rage_val); |
---|
| 2556 | break; |
---|
| 2557 | } |
---|
| 2558 | default: |
---|
| 2559 | break; |
---|
| 2560 | } |
---|
| 2561 | } |
---|
| 2562 | |
---|
| 2563 | m_target->m_ShapeShiftFormSpellId = GetId(); |
---|
| 2564 | m_target->m_form = form; |
---|
| 2565 | } |
---|
| 2566 | else |
---|
| 2567 | { |
---|
| 2568 | m_target->SetDisplayId(m_target->GetNativeDisplayId()); |
---|
| 2569 | m_target->SetByteValue(UNIT_FIELD_BYTES_2, 3, FORM_NONE); |
---|
| 2570 | if(m_target->getClass() == CLASS_DRUID) |
---|
| 2571 | m_target->setPowerType(POWER_MANA); |
---|
| 2572 | m_target->m_ShapeShiftFormSpellId = 0; |
---|
| 2573 | m_target->m_form = FORM_NONE; |
---|
| 2574 | |
---|
| 2575 | switch(form) |
---|
| 2576 | { |
---|
| 2577 | // Nordrassil Harness - bonus |
---|
| 2578 | case FORM_BEAR: |
---|
| 2579 | case FORM_DIREBEAR: |
---|
| 2580 | case FORM_CAT: |
---|
| 2581 | { |
---|
| 2582 | if(Aura* dummy = m_target->GetDummyAura(37315) ) |
---|
| 2583 | m_target->CastSpell(m_target,37316,true,NULL,dummy); |
---|
| 2584 | break; |
---|
| 2585 | } |
---|
| 2586 | // Nordrassil Regalia - bonus |
---|
| 2587 | case FORM_MOONKIN: |
---|
| 2588 | { |
---|
| 2589 | if(Aura* dummy = m_target->GetDummyAura(37324) ) |
---|
| 2590 | m_target->CastSpell(m_target,37325,true,NULL,dummy); |
---|
| 2591 | break; |
---|
| 2592 | } |
---|
| 2593 | } |
---|
| 2594 | } |
---|
| 2595 | |
---|
| 2596 | // adding/removing linked auras |
---|
| 2597 | // add/remove the shapeshift aura's boosts |
---|
| 2598 | HandleShapeshiftBoosts(apply); |
---|
| 2599 | |
---|
| 2600 | if(m_target->GetTypeId()==TYPEID_PLAYER) |
---|
| 2601 | ((Player*)m_target)->InitDataForForm(); |
---|
| 2602 | } |
---|
| 2603 | |
---|
| 2604 | void Aura::HandleAuraTransform(bool apply, bool Real) |
---|
| 2605 | { |
---|
| 2606 | if (apply) |
---|
| 2607 | { |
---|
| 2608 | // special case (spell specific functionality) |
---|
| 2609 | if(m_modifier.m_miscvalue==0) |
---|
| 2610 | { |
---|
| 2611 | // player applied only |
---|
| 2612 | if(m_target->GetTypeId()!=TYPEID_PLAYER) |
---|
| 2613 | return; |
---|
| 2614 | |
---|
| 2615 | switch(GetId()) |
---|
| 2616 | { |
---|
| 2617 | // Orb of Deception |
---|
| 2618 | case 16739: |
---|
| 2619 | { |
---|
| 2620 | uint32 orb_model = m_target->GetNativeDisplayId(); |
---|
| 2621 | switch(orb_model) |
---|
| 2622 | { |
---|
| 2623 | // Troll Female |
---|
| 2624 | case 1479: m_target->SetDisplayId(10134); break; |
---|
| 2625 | // Troll Male |
---|
| 2626 | case 1478: m_target->SetDisplayId(10135); break; |
---|
| 2627 | // Tauren Male |
---|
| 2628 | case 59: m_target->SetDisplayId(10136); break; |
---|
| 2629 | // Human Male |
---|
| 2630 | case 49: m_target->SetDisplayId(10137); break; |
---|
| 2631 | // Human Female |
---|
| 2632 | case 50: m_target->SetDisplayId(10138); break; |
---|
| 2633 | // Orc Male |
---|
| 2634 | case 51: m_target->SetDisplayId(10139); break; |
---|
| 2635 | // Orc Female |
---|
| 2636 | case 52: m_target->SetDisplayId(10140); break; |
---|
| 2637 | // Dwarf Male |
---|
| 2638 | case 53: m_target->SetDisplayId(10141); break; |
---|
| 2639 | // Dwarf Female |
---|
| 2640 | case 54: m_target->SetDisplayId(10142); break; |
---|
| 2641 | // NightElf Male |
---|
| 2642 | case 55: m_target->SetDisplayId(10143); break; |
---|
| 2643 | // NightElf Female |
---|
| 2644 | case 56: m_target->SetDisplayId(10144); break; |
---|
| 2645 | // Undead Female |
---|
| 2646 | case 58: m_target->SetDisplayId(10145); break; |
---|
| 2647 | // Undead Male |
---|
| 2648 | case 57: m_target->SetDisplayId(10146); break; |
---|
| 2649 | // Tauren Female |
---|
| 2650 | case 60: m_target->SetDisplayId(10147); break; |
---|
| 2651 | // Gnome Male |
---|
| 2652 | case 1563: m_target->SetDisplayId(10148); break; |
---|
| 2653 | // Gnome Female |
---|
| 2654 | case 1564: m_target->SetDisplayId(10149); break; |
---|
| 2655 | // BloodElf Female |
---|
| 2656 | case 15475: m_target->SetDisplayId(17830); break; |
---|
| 2657 | // BloodElf Male |
---|
| 2658 | case 15476: m_target->SetDisplayId(17829); break; |
---|
| 2659 | // Dranei Female |
---|
| 2660 | case 16126: m_target->SetDisplayId(17828); break; |
---|
| 2661 | // Dranei Male |
---|
| 2662 | case 16125: m_target->SetDisplayId(17827); break; |
---|
| 2663 | default: break; |
---|
| 2664 | } |
---|
| 2665 | break; |
---|
| 2666 | } |
---|
| 2667 | // Murloc costume |
---|
| 2668 | case 42365: m_target->SetDisplayId(21723); break; |
---|
| 2669 | default: break; |
---|
| 2670 | } |
---|
| 2671 | } |
---|
| 2672 | else |
---|
| 2673 | { |
---|
| 2674 | CreatureInfo const * ci = objmgr.GetCreatureTemplate(m_modifier.m_miscvalue); |
---|
| 2675 | if(!ci) |
---|
| 2676 | { |
---|
| 2677 | //pig pink ^_^ |
---|
| 2678 | m_target->SetDisplayId(16358); |
---|
| 2679 | sLog.outError("Auras: unknown creature id = %d (only need its modelid) Form Spell Aura Transform in Spell ID = %d", m_modifier.m_miscvalue, GetId()); |
---|
| 2680 | } |
---|
| 2681 | else |
---|
| 2682 | { |
---|
[123] | 2683 | if (uint32 modelid = ci->GetRandomValidModelId()) m_target->SetDisplayId(modelid); |
---|
[37] | 2684 | |
---|
| 2685 | // Dragonmaw Illusion (set mount model also) |
---|
| 2686 | if(GetId()==42016 && m_target->GetMountID() && !m_target->GetAurasByType(SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED).empty()) |
---|
| 2687 | m_target->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID,16314); |
---|
| 2688 | } |
---|
| 2689 | m_target->setTransForm(GetId()); |
---|
| 2690 | } |
---|
| 2691 | |
---|
| 2692 | // polymorph case |
---|
| 2693 | if( Real && m_target->GetTypeId() == TYPEID_PLAYER && m_target->IsPolymorphed()) |
---|
| 2694 | { |
---|
| 2695 | // for players, start regeneration after 1s (in polymorph fast regeneration case) |
---|
| 2696 | // only if caster is Player (after patch 2.4.2) |
---|
| 2697 | if(IS_PLAYER_GUID(GetCasterGUID()) ) |
---|
| 2698 | ((Player*)m_target)->setRegenTimer(1000); |
---|
| 2699 | |
---|
| 2700 | //dismount polymorphed target (after patch 2.4.2) |
---|
| 2701 | if (m_target->IsMounted()) |
---|
| 2702 | m_target->RemoveSpellsCausingAura(SPELL_AURA_MOUNTED); |
---|
| 2703 | } |
---|
| 2704 | } |
---|
| 2705 | else |
---|
| 2706 | { |
---|
| 2707 | Unit::AuraList const& otherTransforms = m_target->GetAurasByType(SPELL_AURA_TRANSFORM); |
---|
| 2708 | if(otherTransforms.empty()) |
---|
| 2709 | { |
---|
| 2710 | m_target->SetDisplayId(m_target->GetNativeDisplayId()); |
---|
| 2711 | m_target->setTransForm(0); |
---|
| 2712 | } |
---|
| 2713 | else |
---|
| 2714 | { |
---|
| 2715 | // look for other transform auras |
---|
| 2716 | Aura* handledAura = *otherTransforms.begin(); |
---|
| 2717 | for(Unit::AuraList::const_iterator i = otherTransforms.begin();i != otherTransforms.end(); ++i) |
---|
| 2718 | { |
---|
| 2719 | // negative auras are prefered |
---|
| 2720 | if(!IsPositiveSpell((*i)->GetSpellProto()->Id)) |
---|
| 2721 | { |
---|
| 2722 | handledAura = *i; |
---|
| 2723 | break; |
---|
| 2724 | } |
---|
| 2725 | } |
---|
| 2726 | handledAura->ApplyModifier(true); |
---|
| 2727 | } |
---|
| 2728 | |
---|
| 2729 | // Dragonmaw Illusion (restore mount model) |
---|
| 2730 | if(GetId()==42016 && m_target->GetMountID()==16314) |
---|
| 2731 | { |
---|
| 2732 | if(!m_target->GetAurasByType(SPELL_AURA_MOUNTED).empty()) |
---|
| 2733 | { |
---|
| 2734 | uint32 cr_id = m_target->GetAurasByType(SPELL_AURA_MOUNTED).front()->GetModifier()->m_miscvalue; |
---|
| 2735 | if(CreatureInfo const* ci = objmgr.GetCreatureTemplate(cr_id)) |
---|
| 2736 | { |
---|
| 2737 | uint32 team = 0; |
---|
| 2738 | if (m_target->GetTypeId()==TYPEID_PLAYER) |
---|
| 2739 | team = ((Player*)m_target)->GetTeam(); |
---|
| 2740 | |
---|
| 2741 | uint32 display_id = objmgr.ChooseDisplayId(team,ci); |
---|
| 2742 | CreatureModelInfo const *minfo = objmgr.GetCreatureModelRandomGender(display_id); |
---|
| 2743 | if (minfo) |
---|
| 2744 | display_id = minfo->modelid; |
---|
| 2745 | |
---|
| 2746 | m_target->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID,display_id); |
---|
| 2747 | } |
---|
| 2748 | } |
---|
| 2749 | } |
---|
| 2750 | } |
---|
| 2751 | } |
---|
| 2752 | |
---|
| 2753 | void Aura::HandleForceReaction(bool apply, bool Real) |
---|
| 2754 | { |
---|
| 2755 | if(m_target->GetTypeId() != TYPEID_PLAYER) |
---|
| 2756 | return; |
---|
| 2757 | |
---|
| 2758 | if(!Real) |
---|
| 2759 | return; |
---|
| 2760 | |
---|
| 2761 | Player* player = (Player*)m_target; |
---|
| 2762 | |
---|
| 2763 | uint32 faction_id = m_modifier.m_miscvalue; |
---|
| 2764 | uint32 faction_rank = m_modifier.m_amount; |
---|
| 2765 | |
---|
| 2766 | if(apply) |
---|
| 2767 | player->m_forcedReactions[faction_id] = ReputationRank(faction_rank); |
---|
| 2768 | else |
---|
| 2769 | player->m_forcedReactions.erase(faction_id); |
---|
| 2770 | |
---|
| 2771 | WorldPacket data; |
---|
| 2772 | data.Initialize(SMSG_SET_FORCED_REACTIONS, 4+player->m_forcedReactions.size()*(4+4)); |
---|
| 2773 | data << uint32(player->m_forcedReactions.size()); |
---|
| 2774 | for(ForcedReactions::const_iterator itr = player->m_forcedReactions.begin(); itr != player->m_forcedReactions.end(); ++itr) |
---|
| 2775 | { |
---|
| 2776 | data << uint32(itr->first); // faction_id (Faction.dbc) |
---|
| 2777 | data << uint32(itr->second); // reputation rank |
---|
| 2778 | } |
---|
| 2779 | player->SendDirectMessage(&data); |
---|
| 2780 | } |
---|
| 2781 | |
---|
| 2782 | void Aura::HandleAuraModSkill(bool apply, bool Real) |
---|
| 2783 | { |
---|
| 2784 | if(m_target->GetTypeId() != TYPEID_PLAYER) |
---|
| 2785 | return; |
---|
| 2786 | |
---|
| 2787 | uint32 prot=GetSpellProto()->EffectMiscValue[m_effIndex]; |
---|
| 2788 | int32 points = GetModifier()->m_amount; |
---|
| 2789 | |
---|
| 2790 | ((Player*)m_target)->ModifySkillBonus(prot,(apply ? points: -points),m_modifier.m_auraname==SPELL_AURA_MOD_SKILL_TALENT); |
---|
| 2791 | if(prot == SKILL_DEFENSE) |
---|
| 2792 | ((Player*)m_target)->UpdateDefenseBonusesMod(); |
---|
| 2793 | } |
---|
| 2794 | |
---|
| 2795 | void Aura::HandleChannelDeathItem(bool apply, bool Real) |
---|
| 2796 | { |
---|
| 2797 | if(Real && !apply) |
---|
| 2798 | { |
---|
| 2799 | Unit* caster = GetCaster(); |
---|
| 2800 | Unit* victim = GetTarget(); |
---|
| 2801 | if(!caster || caster->GetTypeId() != TYPEID_PLAYER || !victim || m_removeMode!=AURA_REMOVE_BY_DEATH) |
---|
| 2802 | return; |
---|
| 2803 | |
---|
| 2804 | SpellEntry const *spellInfo = GetSpellProto(); |
---|
| 2805 | if(spellInfo->EffectItemType[m_effIndex] == 0) |
---|
| 2806 | return; |
---|
| 2807 | |
---|
| 2808 | // Soul Shard only from non-grey units |
---|
| 2809 | if( spellInfo->EffectItemType[m_effIndex] == 6265 && |
---|
[44] | 2810 | (victim->getLevel() <= Trinity::XP::GetGrayLevel(caster->getLevel()) || |
---|
[37] | 2811 | victim->GetTypeId()==TYPEID_UNIT && !((Player*)caster)->isAllowedToLoot((Creature*)victim)) ) |
---|
| 2812 | return; |
---|
| 2813 | ItemPosCountVec dest; |
---|
| 2814 | uint8 msg = ((Player*)caster)->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, spellInfo->EffectItemType[m_effIndex], 1 ); |
---|
| 2815 | if( msg != EQUIP_ERR_OK ) |
---|
| 2816 | { |
---|
| 2817 | ((Player*)caster)->SendEquipError( msg, NULL, NULL ); |
---|
| 2818 | return; |
---|
| 2819 | } |
---|
| 2820 | |
---|
| 2821 | Item* newitem = ((Player*)caster)->StoreNewItem(dest, spellInfo->EffectItemType[m_effIndex], true); |
---|
| 2822 | ((Player*)caster)->SendNewItem(newitem, 1, true, false); |
---|
| 2823 | } |
---|
| 2824 | } |
---|
| 2825 | |
---|
| 2826 | void Aura::HandleBindSight(bool apply, bool Real) |
---|
| 2827 | { |
---|
| 2828 | Unit* caster = GetCaster(); |
---|
| 2829 | if(!caster || caster->GetTypeId() != TYPEID_PLAYER) |
---|
| 2830 | return; |
---|
| 2831 | |
---|
| 2832 | caster->SetUInt64Value(PLAYER_FARSIGHT,apply ? m_target->GetGUID() : 0); |
---|
| 2833 | } |
---|
| 2834 | |
---|
| 2835 | void Aura::HandleFarSight(bool apply, bool Real) |
---|
| 2836 | { |
---|
| 2837 | Unit* caster = GetCaster(); |
---|
| 2838 | if(!caster || caster->GetTypeId() != TYPEID_PLAYER) |
---|
| 2839 | return; |
---|
| 2840 | |
---|
| 2841 | caster->SetUInt64Value(PLAYER_FARSIGHT,apply ? m_modifier.m_miscvalue : 0); |
---|
| 2842 | } |
---|
| 2843 | |
---|
| 2844 | void Aura::HandleAuraTrackCreatures(bool apply, bool Real) |
---|
| 2845 | { |
---|
| 2846 | if(m_target->GetTypeId()!=TYPEID_PLAYER) |
---|
| 2847 | return; |
---|
| 2848 | |
---|
| 2849 | if(apply) |
---|
| 2850 | m_target->RemoveNoStackAurasDueToAura(this); |
---|
| 2851 | m_target->SetUInt32Value(PLAYER_TRACK_CREATURES, apply ? ((uint32)1)<<(m_modifier.m_miscvalue-1) : 0 ); |
---|
| 2852 | } |
---|
| 2853 | |
---|
| 2854 | void Aura::HandleAuraTrackResources(bool apply, bool Real) |
---|
| 2855 | { |
---|
| 2856 | if(m_target->GetTypeId()!=TYPEID_PLAYER) |
---|
| 2857 | return; |
---|
| 2858 | |
---|
| 2859 | if(apply) |
---|
| 2860 | m_target->RemoveNoStackAurasDueToAura(this); |
---|
| 2861 | m_target->SetUInt32Value(PLAYER_TRACK_RESOURCES, apply ? ((uint32)1)<<(m_modifier.m_miscvalue-1): 0 ); |
---|
| 2862 | } |
---|
| 2863 | |
---|
| 2864 | void Aura::HandleAuraTrackStealthed(bool apply, bool Real) |
---|
| 2865 | { |
---|
| 2866 | if(m_target->GetTypeId()!=TYPEID_PLAYER) |
---|
| 2867 | return; |
---|
| 2868 | |
---|
| 2869 | if(apply) |
---|
| 2870 | m_target->RemoveNoStackAurasDueToAura(this); |
---|
| 2871 | |
---|
| 2872 | m_target->ApplyModFlag(PLAYER_FIELD_BYTES,PLAYER_FIELD_BYTE_TRACK_STEALTHED,apply); |
---|
| 2873 | } |
---|
| 2874 | |
---|
| 2875 | void Aura::HandleAuraModScale(bool apply, bool Real) |
---|
| 2876 | { |
---|
| 2877 | m_target->ApplyPercentModFloatValue(OBJECT_FIELD_SCALE_X,m_modifier.m_amount,apply); |
---|
| 2878 | } |
---|
| 2879 | |
---|
| 2880 | void Aura::HandleModPossess(bool apply, bool Real) |
---|
| 2881 | { |
---|
| 2882 | if(!Real) |
---|
| 2883 | return; |
---|
| 2884 | |
---|
| 2885 | if(m_target->getLevel() > m_modifier.m_amount) |
---|
| 2886 | return; |
---|
| 2887 | |
---|
| 2888 | // not possess yourself |
---|
| 2889 | if(GetCasterGUID() == m_target->GetGUID()) |
---|
| 2890 | return; |
---|
| 2891 | |
---|
| 2892 | Unit* caster = GetCaster(); |
---|
| 2893 | if(!caster) |
---|
| 2894 | return; |
---|
| 2895 | |
---|
| 2896 | if( apply ) |
---|
| 2897 | { |
---|
[174] | 2898 | if (caster->GetTypeId() == TYPEID_PLAYER) |
---|
| 2899 | ((Player*)caster)->Possess(m_target); |
---|
[37] | 2900 | } |
---|
| 2901 | else |
---|
[174] | 2902 | m_target->UnpossessSelf(true); |
---|
[37] | 2903 | } |
---|
| 2904 | |
---|
| 2905 | void Aura::HandleModPossessPet(bool apply, bool Real) |
---|
| 2906 | { |
---|
| 2907 | if(!Real) |
---|
| 2908 | return; |
---|
| 2909 | |
---|
| 2910 | Unit* caster = GetCaster(); |
---|
| 2911 | if(!caster || caster->GetTypeId() != TYPEID_PLAYER) |
---|
| 2912 | return; |
---|
| 2913 | if(caster->GetPet() != m_target) |
---|
| 2914 | return; |
---|
| 2915 | |
---|
| 2916 | if(apply) |
---|
| 2917 | { |
---|
[174] | 2918 | ((Player*)caster)->Possess(m_target); |
---|
[37] | 2919 | } |
---|
| 2920 | else |
---|
| 2921 | { |
---|
[174] | 2922 | ((Player*)caster)->RemovePossess(false); |
---|
[37] | 2923 | } |
---|
| 2924 | } |
---|
| 2925 | |
---|
| 2926 | void Aura::HandleModCharm(bool apply, bool Real) |
---|
| 2927 | { |
---|
| 2928 | if(!Real) |
---|
| 2929 | return; |
---|
| 2930 | |
---|
| 2931 | // not charm yourself |
---|
| 2932 | if(GetCasterGUID() == m_target->GetGUID()) |
---|
| 2933 | return; |
---|
| 2934 | |
---|
| 2935 | Unit* caster = GetCaster(); |
---|
| 2936 | if(!caster) |
---|
| 2937 | return; |
---|
| 2938 | |
---|
| 2939 | if(int32(m_target->getLevel()) <= m_modifier.m_amount) |
---|
| 2940 | { |
---|
| 2941 | if( apply ) |
---|
| 2942 | { |
---|
| 2943 | m_target->SetCharmerGUID(GetCasterGUID()); |
---|
| 2944 | m_target->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE,caster->getFaction()); |
---|
| 2945 | m_target->CastStop(m_target==caster ? GetId() : 0); |
---|
| 2946 | caster->SetCharm(m_target); |
---|
| 2947 | |
---|
| 2948 | m_target->CombatStop(); |
---|
| 2949 | m_target->DeleteThreatList(); |
---|
| 2950 | |
---|
| 2951 | if(m_target->GetTypeId() == TYPEID_UNIT) |
---|
| 2952 | { |
---|
| 2953 | ((Creature*)m_target)->AIM_Initialize(); |
---|
| 2954 | CharmInfo *charmInfo = ((Creature*)m_target)->InitCharmInfo(m_target); |
---|
| 2955 | charmInfo->InitCharmCreateSpells(); |
---|
| 2956 | charmInfo->SetReactState( REACT_DEFENSIVE ); |
---|
| 2957 | |
---|
| 2958 | if(caster->GetTypeId() == TYPEID_PLAYER && caster->getClass() == CLASS_WARLOCK) |
---|
| 2959 | { |
---|
| 2960 | CreatureInfo const *cinfo = ((Creature*)m_target)->GetCreatureInfo(); |
---|
| 2961 | if(cinfo && cinfo->type == CREATURE_TYPE_DEMON) |
---|
| 2962 | { |
---|
| 2963 | //to prevent client crash |
---|
| 2964 | m_target->SetFlag(UNIT_FIELD_BYTES_0, 2048); |
---|
| 2965 | //just to enable stat window |
---|
| 2966 | charmInfo->SetPetNumber(objmgr.GeneratePetNumber(), true); |
---|
| 2967 | //if charmed two demons the same session, the 2nd gets the 1st one's name |
---|
| 2968 | m_target->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, time(NULL)); |
---|
| 2969 | } |
---|
| 2970 | } |
---|
| 2971 | } |
---|
| 2972 | |
---|
| 2973 | if(caster->GetTypeId() == TYPEID_PLAYER) |
---|
| 2974 | { |
---|
| 2975 | ((Player*)caster)->CharmSpellInitialize(); |
---|
| 2976 | } |
---|
| 2977 | } |
---|
| 2978 | else |
---|
| 2979 | { |
---|
| 2980 | m_target->SetCharmerGUID(0); |
---|
| 2981 | |
---|
| 2982 | if(m_target->GetTypeId() == TYPEID_PLAYER) |
---|
| 2983 | ((Player*)m_target)->setFactionForRace(m_target->getRace()); |
---|
| 2984 | else |
---|
| 2985 | { |
---|
| 2986 | CreatureInfo const *cinfo = ((Creature*)m_target)->GetCreatureInfo(); |
---|
| 2987 | |
---|
| 2988 | // restore faction |
---|
| 2989 | if(((Creature*)m_target)->isPet()) |
---|
| 2990 | { |
---|
| 2991 | if(Unit* owner = m_target->GetOwner()) |
---|
| 2992 | m_target->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE,owner->getFaction()); |
---|
| 2993 | else if(cinfo) |
---|
| 2994 | m_target->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE,cinfo->faction_A); |
---|
| 2995 | } |
---|
| 2996 | else if(cinfo) // normal creature |
---|
| 2997 | m_target->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE,cinfo->faction_A); |
---|
| 2998 | |
---|
| 2999 | // restore UNIT_FIELD_BYTES_0 |
---|
| 3000 | if(cinfo && caster->GetTypeId() == TYPEID_PLAYER && caster->getClass() == CLASS_WARLOCK && cinfo->type == CREATURE_TYPE_DEMON) |
---|
| 3001 | { |
---|
| 3002 | CreatureDataAddon const *cainfo = ((Creature*)m_target)->GetCreatureAddon(); |
---|
| 3003 | if(cainfo && cainfo->bytes0 != 0) |
---|
| 3004 | m_target->SetUInt32Value(UNIT_FIELD_BYTES_0, cainfo->bytes0); |
---|
| 3005 | else |
---|
| 3006 | m_target->RemoveFlag(UNIT_FIELD_BYTES_0, 2048); |
---|
| 3007 | |
---|
| 3008 | if(m_target->GetCharmInfo()) |
---|
| 3009 | m_target->GetCharmInfo()->SetPetNumber(0, true); |
---|
| 3010 | else |
---|
| 3011 | sLog.outError("Aura::HandleModCharm: target="I64FMTD" with typeid=%d has a charm aura but no charm info!", m_target->GetGUID(), m_target->GetTypeId()); |
---|
| 3012 | } |
---|
| 3013 | } |
---|
| 3014 | |
---|
| 3015 | caster->SetCharm(0); |
---|
| 3016 | |
---|
| 3017 | if(caster->GetTypeId() == TYPEID_PLAYER) |
---|
| 3018 | { |
---|
| 3019 | WorldPacket data(SMSG_PET_SPELLS, 8); |
---|
| 3020 | data << uint64(0); |
---|
| 3021 | ((Player*)caster)->GetSession()->SendPacket(&data); |
---|
| 3022 | } |
---|
| 3023 | if(m_target->GetTypeId() == TYPEID_UNIT) |
---|
| 3024 | { |
---|
| 3025 | ((Creature*)m_target)->AIM_Initialize(); |
---|
| 3026 | if (((Creature*)m_target)->AI()) |
---|
| 3027 | ((Creature*)m_target)->AI()->AttackStart(caster); |
---|
| 3028 | } |
---|
| 3029 | } |
---|
| 3030 | } |
---|
| 3031 | } |
---|
| 3032 | |
---|
| 3033 | void Aura::HandleModConfuse(bool apply, bool Real) |
---|
| 3034 | { |
---|
| 3035 | if(!Real) |
---|
| 3036 | return; |
---|
| 3037 | |
---|
| 3038 | m_target->SetConfused(apply, GetCasterGUID(), GetId()); |
---|
| 3039 | } |
---|
| 3040 | |
---|
| 3041 | void Aura::HandleModFear(bool apply, bool Real) |
---|
| 3042 | { |
---|
| 3043 | if (!Real) |
---|
| 3044 | return; |
---|
| 3045 | |
---|
| 3046 | m_target->SetFeared(apply, GetCasterGUID(), GetId()); |
---|
| 3047 | } |
---|
| 3048 | |
---|
| 3049 | void Aura::HandleFeignDeath(bool apply, bool Real) |
---|
| 3050 | { |
---|
| 3051 | if(!Real) |
---|
| 3052 | return; |
---|
| 3053 | |
---|
| 3054 | if(m_target->GetTypeId() != TYPEID_PLAYER) |
---|
| 3055 | return; |
---|
| 3056 | |
---|
| 3057 | if( apply ) |
---|
| 3058 | { |
---|
| 3059 | /* |
---|
| 3060 | WorldPacket data(SMSG_FEIGN_DEATH_RESISTED, 9); |
---|
| 3061 | data<<m_target->GetGUID(); |
---|
| 3062 | data<<uint8(0); |
---|
| 3063 | m_target->SendMessageToSet(&data,true); |
---|
| 3064 | */ |
---|
| 3065 | // blizz like 2.0.x |
---|
| 3066 | m_target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNKNOWN6); |
---|
| 3067 | // blizz like 2.0.x |
---|
| 3068 | m_target->SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FEIGN_DEATH); |
---|
| 3069 | // blizz like 2.0.x |
---|
| 3070 | m_target->SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_DEAD); |
---|
| 3071 | |
---|
| 3072 | m_target->addUnitState(UNIT_STAT_DIED); |
---|
| 3073 | m_target->CombatStop(); |
---|
| 3074 | |
---|
| 3075 | // prevent interrupt message |
---|
| 3076 | if(m_caster_guid==m_target->GetGUID() && m_target->m_currentSpells[CURRENT_GENERIC_SPELL]) |
---|
| 3077 | m_target->m_currentSpells[CURRENT_GENERIC_SPELL]->finish(); |
---|
| 3078 | m_target->InterruptNonMeleeSpells(true); |
---|
| 3079 | m_target->getHostilRefManager().deleteReferences(); |
---|
| 3080 | } |
---|
| 3081 | else |
---|
| 3082 | { |
---|
| 3083 | /* |
---|
| 3084 | WorldPacket data(SMSG_FEIGN_DEATH_RESISTED, 9); |
---|
| 3085 | data<<m_target->GetGUID(); |
---|
| 3086 | data<<uint8(1); |
---|
| 3087 | m_target->SendMessageToSet(&data,true); |
---|
| 3088 | */ |
---|
| 3089 | // blizz like 2.0.x |
---|
| 3090 | m_target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNKNOWN6); |
---|
| 3091 | // blizz like 2.0.x |
---|
| 3092 | m_target->RemoveFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FEIGN_DEATH); |
---|
| 3093 | // blizz like 2.0.x |
---|
| 3094 | m_target->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_DEAD); |
---|
| 3095 | |
---|
| 3096 | m_target->clearUnitState(UNIT_STAT_DIED); |
---|
| 3097 | } |
---|
| 3098 | } |
---|
| 3099 | |
---|
| 3100 | void Aura::HandleAuraModDisarm(bool apply, bool Real) |
---|
| 3101 | { |
---|
| 3102 | if(!Real) |
---|
| 3103 | return; |
---|
| 3104 | |
---|
| 3105 | if(!apply && m_target->HasAuraType(SPELL_AURA_MOD_DISARM)) |
---|
| 3106 | return; |
---|
| 3107 | |
---|
| 3108 | // not sure for it's correctness |
---|
| 3109 | if(apply) |
---|
| 3110 | m_target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISARMED); |
---|
| 3111 | else |
---|
| 3112 | m_target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISARMED); |
---|
| 3113 | |
---|
| 3114 | // only at real add/remove aura |
---|
| 3115 | if (m_target->GetTypeId() != TYPEID_PLAYER) |
---|
| 3116 | return; |
---|
| 3117 | |
---|
| 3118 | // main-hand attack speed already set to special value for feral form already and don't must chnage and reset at remove. |
---|
| 3119 | if (((Player *)m_target)->IsInFeralForm()) |
---|
| 3120 | return; |
---|
| 3121 | |
---|
| 3122 | if (apply) |
---|
| 3123 | m_target->SetAttackTime(BASE_ATTACK,BASE_ATTACK_TIME); |
---|
| 3124 | else |
---|
| 3125 | ((Player *)m_target)->SetRegularAttackTime(); |
---|
| 3126 | |
---|
| 3127 | m_target->UpdateDamagePhysical(BASE_ATTACK); |
---|
| 3128 | } |
---|
| 3129 | |
---|
| 3130 | void Aura::HandleAuraModStun(bool apply, bool Real) |
---|
| 3131 | { |
---|
| 3132 | if(!Real) |
---|
| 3133 | return; |
---|
| 3134 | |
---|
| 3135 | if (apply) |
---|
| 3136 | { |
---|
| 3137 | m_target->addUnitState(UNIT_STAT_STUNNED); |
---|
| 3138 | m_target->SetUInt64Value(UNIT_FIELD_TARGET, 0); |
---|
| 3139 | |
---|
| 3140 | m_target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_ROTATE); |
---|
| 3141 | m_target->CastStop(m_target->GetGUID() == GetCasterGUID() ? GetId() : 0); |
---|
| 3142 | |
---|
| 3143 | // Creature specific |
---|
| 3144 | if(m_target->GetTypeId() != TYPEID_PLAYER) |
---|
| 3145 | ((Creature*)m_target)->StopMoving(); |
---|
| 3146 | else |
---|
| 3147 | m_target->SetUnitMovementFlags(0); //Clear movement flags |
---|
| 3148 | |
---|
| 3149 | WorldPacket data(SMSG_FORCE_MOVE_ROOT, 8); |
---|
| 3150 | |
---|
| 3151 | data.append(m_target->GetPackGUID()); |
---|
| 3152 | data << uint32(0); |
---|
| 3153 | m_target->SendMessageToSet(&data,true); |
---|
| 3154 | } |
---|
| 3155 | else |
---|
| 3156 | { |
---|
| 3157 | // Real remove called after current aura remove from lists, check if other similar auras active |
---|
| 3158 | if(m_target->HasAuraType(SPELL_AURA_MOD_STUN)) |
---|
| 3159 | return; |
---|
| 3160 | |
---|
| 3161 | m_target->clearUnitState(UNIT_STAT_STUNNED); |
---|
| 3162 | m_target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_ROTATE); |
---|
| 3163 | |
---|
| 3164 | if(!m_target->hasUnitState(UNIT_STAT_ROOT)) // prevent allow move if have also root effect |
---|
| 3165 | { |
---|
| 3166 | if(m_target->getVictim() && m_target->isAlive()) |
---|
| 3167 | m_target->SetUInt64Value(UNIT_FIELD_TARGET,m_target->getVictim()->GetGUID() ); |
---|
| 3168 | |
---|
| 3169 | WorldPacket data(SMSG_FORCE_MOVE_UNROOT, 8+4); |
---|
| 3170 | data.append(m_target->GetPackGUID()); |
---|
| 3171 | data << uint32(0); |
---|
| 3172 | m_target->SendMessageToSet(&data,true); |
---|
| 3173 | } |
---|
| 3174 | |
---|
| 3175 | // Wyvern Sting |
---|
| 3176 | if (GetSpellProto()->SpellFamilyName == SPELLFAMILY_HUNTER && GetSpellProto()->SpellIconID == 1721) |
---|
| 3177 | { |
---|
| 3178 | Unit* caster = GetCaster(); |
---|
| 3179 | if( !caster || caster->GetTypeId()!=TYPEID_PLAYER ) |
---|
| 3180 | return; |
---|
| 3181 | |
---|
| 3182 | uint32 spell_id = 0; |
---|
| 3183 | |
---|
| 3184 | switch(GetId()) |
---|
| 3185 | { |
---|
| 3186 | case 19386: spell_id = 24131; break; |
---|
| 3187 | case 24132: spell_id = 24134; break; |
---|
| 3188 | case 24133: spell_id = 24135; break; |
---|
| 3189 | case 27068: spell_id = 27069; break; |
---|
| 3190 | default: |
---|
| 3191 | sLog.outError("Spell selection called for unexpected original spell %u, new spell for this spell family?",GetId()); |
---|
| 3192 | return; |
---|
| 3193 | } |
---|
| 3194 | |
---|
| 3195 | SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell_id); |
---|
| 3196 | |
---|
| 3197 | if(!spellInfo) |
---|
| 3198 | return; |
---|
| 3199 | |
---|
| 3200 | caster->CastSpell(m_target,spellInfo,true,NULL,this); |
---|
| 3201 | return; |
---|
| 3202 | } |
---|
| 3203 | } |
---|
| 3204 | } |
---|
| 3205 | |
---|
| 3206 | void Aura::HandleModStealth(bool apply, bool Real) |
---|
| 3207 | { |
---|
| 3208 | if(apply) |
---|
| 3209 | { |
---|
[44] | 3210 | if(Real && m_target->GetTypeId()==TYPEID_PLAYER) |
---|
| 3211 | { |
---|
| 3212 | // drop flag at stealth in bg |
---|
| 3213 | if(((Player*)m_target)->InBattleGround()) |
---|
| 3214 | { |
---|
| 3215 | if(BattleGround *bg = ((Player*)m_target)->GetBattleGround()) |
---|
| 3216 | bg->EventPlayerDroppedFlag((Player*)m_target); |
---|
| 3217 | } |
---|
| 3218 | // remove player from the objective's active player count at stealth |
---|
| 3219 | if(OutdoorPvP * pvp = ((Player*)m_target)->GetOutdoorPvP()) |
---|
| 3220 | pvp->HandlePlayerActivityChanged((Player*)m_target); |
---|
| 3221 | } |
---|
[37] | 3222 | |
---|
| 3223 | // only at real aura add |
---|
| 3224 | if(Real) |
---|
| 3225 | { |
---|
| 3226 | m_target->SetByteValue(UNIT_FIELD_BYTES_1, 2, 0x02); |
---|
| 3227 | if(m_target->GetTypeId()==TYPEID_PLAYER) |
---|
| 3228 | m_target->SetFlag(PLAYER_FIELD_BYTES2, 0x2000); |
---|
| 3229 | |
---|
| 3230 | // apply only if not in GM invisibility (and overwrite invisibility state) |
---|
| 3231 | if(m_target->GetVisibility()!=VISIBILITY_OFF) |
---|
| 3232 | { |
---|
| 3233 | m_target->SetVisibility(VISIBILITY_GROUP_NO_DETECT); |
---|
| 3234 | m_target->SetVisibility(VISIBILITY_GROUP_STEALTH); |
---|
| 3235 | } |
---|
| 3236 | |
---|
| 3237 | // for RACE_NIGHTELF stealth |
---|
| 3238 | if(m_target->GetTypeId()==TYPEID_PLAYER && GetId()==20580) |
---|
| 3239 | m_target->CastSpell(m_target, 21009, true, NULL, this); |
---|
| 3240 | } |
---|
| 3241 | } |
---|
| 3242 | else |
---|
| 3243 | { |
---|
| 3244 | // only at real aura remove |
---|
| 3245 | if(Real) |
---|
| 3246 | { |
---|
| 3247 | // for RACE_NIGHTELF stealth |
---|
| 3248 | if(m_target->GetTypeId()==TYPEID_PLAYER && GetId()==20580) |
---|
| 3249 | m_target->RemoveAurasDueToSpell(21009); |
---|
| 3250 | |
---|
| 3251 | // if last SPELL_AURA_MOD_STEALTH and no GM invisibility |
---|
| 3252 | if(!m_target->HasAuraType(SPELL_AURA_MOD_STEALTH) && m_target->GetVisibility()!=VISIBILITY_OFF) |
---|
| 3253 | { |
---|
| 3254 | m_target->SetByteValue(UNIT_FIELD_BYTES_1, 2, 0x00); |
---|
| 3255 | if(m_target->GetTypeId()==TYPEID_PLAYER) |
---|
| 3256 | m_target->RemoveFlag(PLAYER_FIELD_BYTES2, 0x2000); |
---|
| 3257 | |
---|
| 3258 | // restore invisibility if any |
---|
| 3259 | if(m_target->HasAuraType(SPELL_AURA_MOD_INVISIBILITY)) |
---|
| 3260 | { |
---|
| 3261 | m_target->SetVisibility(VISIBILITY_GROUP_NO_DETECT); |
---|
| 3262 | m_target->SetVisibility(VISIBILITY_GROUP_INVISIBILITY); |
---|
| 3263 | } |
---|
| 3264 | else |
---|
[44] | 3265 | { |
---|
[37] | 3266 | m_target->SetVisibility(VISIBILITY_ON); |
---|
[44] | 3267 | if(m_target->GetTypeId() == TYPEID_PLAYER) |
---|
| 3268 | if(OutdoorPvP * pvp = ((Player*)m_target)->GetOutdoorPvP()) |
---|
| 3269 | pvp->HandlePlayerActivityChanged((Player*)m_target); |
---|
| 3270 | } |
---|
[37] | 3271 | } |
---|
| 3272 | } |
---|
| 3273 | } |
---|
| 3274 | |
---|
| 3275 | // Master of Subtlety |
---|
| 3276 | Unit::AuraList const& mDummyAuras = m_target->GetAurasByType(SPELL_AURA_DUMMY); |
---|
| 3277 | for(Unit::AuraList::const_iterator i = mDummyAuras.begin();i != mDummyAuras.end(); ++i) |
---|
| 3278 | { |
---|
| 3279 | if ((*i)->GetSpellProto()->SpellIconID == 2114) |
---|
| 3280 | { |
---|
| 3281 | if (apply) |
---|
| 3282 | { |
---|
| 3283 | int32 bp = (*i)->GetModifier()->m_amount; |
---|
| 3284 | m_target->CastCustomSpell(m_target,31665,&bp,NULL,NULL,true); |
---|
| 3285 | } |
---|
| 3286 | else |
---|
| 3287 | m_target->CastSpell(m_target,31666,true); |
---|
| 3288 | break; |
---|
| 3289 | } |
---|
| 3290 | } |
---|
| 3291 | } |
---|
| 3292 | |
---|
| 3293 | void Aura::HandleInvisibility(bool apply, bool Real) |
---|
| 3294 | { |
---|
| 3295 | if(apply) |
---|
| 3296 | { |
---|
| 3297 | m_target->m_invisibilityMask |= (1 << m_modifier.m_miscvalue); |
---|
| 3298 | |
---|
| 3299 | if(Real && m_target->GetTypeId()==TYPEID_PLAYER) |
---|
| 3300 | { |
---|
| 3301 | // apply glow vision |
---|
| 3302 | m_target->SetFlag(PLAYER_FIELD_BYTES2,PLAYER_FIELD_BYTE2_INVISIBILITY_GLOW); |
---|
[44] | 3303 | // remove player from the objective's active player count at invisibility |
---|
| 3304 | if(OutdoorPvP * pvp = ((Player*)m_target)->GetOutdoorPvP()) |
---|
| 3305 | pvp->HandlePlayerActivityChanged((Player*)m_target); |
---|
[37] | 3306 | |
---|
| 3307 | // drop flag at invisible in bg |
---|
| 3308 | if(((Player*)m_target)->InBattleGround()) |
---|
| 3309 | if(BattleGround *bg = ((Player*)m_target)->GetBattleGround()) |
---|
| 3310 | bg->EventPlayerDroppedFlag((Player*)m_target); |
---|
| 3311 | } |
---|
| 3312 | |
---|
| 3313 | // apply only if not in GM invisibility and not stealth |
---|
| 3314 | if(m_target->GetVisibility()==VISIBILITY_ON) |
---|
| 3315 | { |
---|
| 3316 | // Aura not added yet but visibility code expect temporary add aura |
---|
| 3317 | m_target->SetVisibility(VISIBILITY_GROUP_NO_DETECT); |
---|
| 3318 | m_target->SetVisibility(VISIBILITY_GROUP_INVISIBILITY); |
---|
| 3319 | } |
---|
| 3320 | } |
---|
| 3321 | else |
---|
| 3322 | { |
---|
| 3323 | // recalculate value at modifier remove (current aura already removed) |
---|
| 3324 | m_target->m_invisibilityMask = 0; |
---|
| 3325 | Unit::AuraList const& auras = m_target->GetAurasByType(SPELL_AURA_MOD_INVISIBILITY); |
---|
| 3326 | for(Unit::AuraList::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) |
---|
| 3327 | m_target->m_invisibilityMask |= (1 << m_modifier.m_miscvalue); |
---|
| 3328 | |
---|
| 3329 | // only at real aura remove and if not have different invisibility auras. |
---|
| 3330 | if(Real && m_target->m_invisibilityMask==0) |
---|
| 3331 | { |
---|
| 3332 | // remove glow vision |
---|
| 3333 | if(m_target->GetTypeId() == TYPEID_PLAYER) |
---|
| 3334 | m_target->RemoveFlag(PLAYER_FIELD_BYTES2,PLAYER_FIELD_BYTE2_INVISIBILITY_GLOW); |
---|
| 3335 | |
---|
| 3336 | // apply only if not in GM invisibility & not stealthed while invisible |
---|
| 3337 | if(m_target->GetVisibility()!=VISIBILITY_OFF) |
---|
| 3338 | { |
---|
| 3339 | // if have stealth aura then already have stealth visibility |
---|
| 3340 | if(!m_target->HasAuraType(SPELL_AURA_MOD_STEALTH)) |
---|
[44] | 3341 | { |
---|
[37] | 3342 | m_target->SetVisibility(VISIBILITY_ON); |
---|
[44] | 3343 | if(m_target->GetTypeId() == TYPEID_PLAYER) |
---|
| 3344 | if(OutdoorPvP * pvp = ((Player*)m_target)->GetOutdoorPvP()) |
---|
| 3345 | pvp->HandlePlayerActivityChanged((Player*)m_target); |
---|
| 3346 | } |
---|
[37] | 3347 | } |
---|
| 3348 | } |
---|
| 3349 | } |
---|
| 3350 | } |
---|
| 3351 | |
---|
| 3352 | void Aura::HandleInvisibilityDetect(bool apply, bool Real) |
---|
| 3353 | { |
---|
| 3354 | if(apply) |
---|
| 3355 | { |
---|
| 3356 | m_target->m_detectInvisibilityMask |= (1 << m_modifier.m_miscvalue); |
---|
| 3357 | } |
---|
| 3358 | else |
---|
| 3359 | { |
---|
| 3360 | // recalculate value at modifier remove (current aura already removed) |
---|
| 3361 | m_target->m_detectInvisibilityMask = 0; |
---|
| 3362 | Unit::AuraList const& auras = m_target->GetAurasByType(SPELL_AURA_MOD_INVISIBILITY_DETECTION); |
---|
| 3363 | for(Unit::AuraList::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) |
---|
| 3364 | m_target->m_detectInvisibilityMask |= (1 << m_modifier.m_miscvalue); |
---|
| 3365 | } |
---|
| 3366 | if(Real && m_target->GetTypeId()==TYPEID_PLAYER) |
---|
| 3367 | ObjectAccessor::UpdateVisibilityForPlayer((Player*)m_target); |
---|
| 3368 | } |
---|
| 3369 | |
---|
| 3370 | void Aura::HandleAuraModRoot(bool apply, bool Real) |
---|
| 3371 | { |
---|
| 3372 | // only at real add/remove aura |
---|
| 3373 | if(!Real) |
---|
| 3374 | return; |
---|
| 3375 | |
---|
| 3376 | uint32 apply_stat = UNIT_STAT_ROOT; |
---|
| 3377 | if (apply) |
---|
| 3378 | { |
---|
| 3379 | m_target->addUnitState(UNIT_STAT_ROOT); |
---|
| 3380 | m_target->SetUInt64Value (UNIT_FIELD_TARGET, 0); |
---|
| 3381 | // probably wrong |
---|
| 3382 | m_target->SetFlag(UNIT_FIELD_FLAGS,(apply_stat<<16)); |
---|
| 3383 | |
---|
| 3384 | //Save last orientation |
---|
| 3385 | if( m_target->getVictim() ) |
---|
| 3386 | m_target->SetOrientation(m_target->GetAngle(m_target->getVictim())); |
---|
| 3387 | |
---|
| 3388 | if(m_target->GetTypeId() == TYPEID_PLAYER) |
---|
| 3389 | { |
---|
| 3390 | WorldPacket data(SMSG_FORCE_MOVE_ROOT, 10); |
---|
| 3391 | data.append(m_target->GetPackGUID()); |
---|
| 3392 | data << (uint32)2; |
---|
| 3393 | m_target->SendMessageToSet(&data,true); |
---|
| 3394 | |
---|
| 3395 | //Clear unit movement flags |
---|
| 3396 | m_target->SetUnitMovementFlags(0); |
---|
| 3397 | } |
---|
| 3398 | else |
---|
| 3399 | ((Creature *)m_target)->StopMoving(); |
---|
| 3400 | } |
---|
| 3401 | else |
---|
| 3402 | { |
---|
| 3403 | // Real remove called after current aura remove from lists, check if other similar auras active |
---|
| 3404 | if(m_target->HasAuraType(SPELL_AURA_MOD_ROOT)) |
---|
| 3405 | return; |
---|
| 3406 | |
---|
| 3407 | m_target->clearUnitState(UNIT_STAT_ROOT); |
---|
| 3408 | // probably wrong |
---|
| 3409 | m_target->RemoveFlag(UNIT_FIELD_FLAGS,(apply_stat<<16)); |
---|
| 3410 | |
---|
| 3411 | if(!m_target->hasUnitState(UNIT_STAT_STUNNED)) // prevent allow move if have also stun effect |
---|
| 3412 | { |
---|
| 3413 | if(m_target->getVictim() && m_target->isAlive()) |
---|
| 3414 | m_target->SetUInt64Value (UNIT_FIELD_TARGET,m_target->getVictim()->GetGUID() ); |
---|
| 3415 | |
---|
| 3416 | if(m_target->GetTypeId() == TYPEID_PLAYER) |
---|
| 3417 | { |
---|
| 3418 | WorldPacket data(SMSG_FORCE_MOVE_UNROOT, 10); |
---|
| 3419 | data.append(m_target->GetPackGUID()); |
---|
| 3420 | data << (uint32)2; |
---|
| 3421 | m_target->SendMessageToSet(&data,true); |
---|
| 3422 | } |
---|
| 3423 | } |
---|
| 3424 | } |
---|
| 3425 | } |
---|
| 3426 | |
---|
| 3427 | void Aura::HandleAuraModSilence(bool apply, bool Real) |
---|
| 3428 | { |
---|
| 3429 | // only at real add/remove aura |
---|
| 3430 | if(!Real) |
---|
| 3431 | return; |
---|
| 3432 | |
---|
| 3433 | if(apply) |
---|
| 3434 | { |
---|
| 3435 | m_target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED); |
---|
| 3436 | // Stop cast only spells vs PreventionType == SPELL_PREVENTION_TYPE_SILENCE |
---|
| 3437 | for (uint32 i = CURRENT_MELEE_SPELL; i < CURRENT_MAX_SPELL;i++) |
---|
| 3438 | { |
---|
| 3439 | Spell* currentSpell = m_target->m_currentSpells[i]; |
---|
| 3440 | if (currentSpell && currentSpell->m_spellInfo->PreventionType == SPELL_PREVENTION_TYPE_SILENCE) |
---|
| 3441 | { |
---|
| 3442 | uint32 state = currentSpell->getState(); |
---|
| 3443 | // Stop spells on prepere or casting state |
---|
| 3444 | if ( state == SPELL_STATE_PREPARING || state == SPELL_STATE_CASTING ) |
---|
| 3445 | { |
---|
| 3446 | currentSpell->cancel(); |
---|
[173] | 3447 | currentSpell->SetReferencedFromCurrent(false); |
---|
[37] | 3448 | m_target->m_currentSpells[i] = NULL; |
---|
| 3449 | } |
---|
| 3450 | } |
---|
| 3451 | } |
---|
| 3452 | |
---|
| 3453 | switch (GetId()) |
---|
| 3454 | { |
---|
| 3455 | // Arcane Torrent (Energy) |
---|
| 3456 | case 25046: |
---|
| 3457 | { |
---|
| 3458 | Unit * caster = GetCaster(); |
---|
| 3459 | if (!caster) |
---|
| 3460 | return; |
---|
| 3461 | |
---|
| 3462 | // Search Mana Tap auras on caster |
---|
| 3463 | int32 energy = 0; |
---|
| 3464 | Unit::AuraList const& m_dummyAuras = caster->GetAurasByType(SPELL_AURA_DUMMY); |
---|
| 3465 | for(Unit::AuraList::const_iterator i = m_dummyAuras.begin(); i != m_dummyAuras.end(); ++i) |
---|
| 3466 | if ((*i)->GetId() == 28734) |
---|
| 3467 | ++energy; |
---|
| 3468 | if (energy) |
---|
| 3469 | { |
---|
| 3470 | energy *= 10; |
---|
| 3471 | caster->CastCustomSpell(caster, 25048, &energy, NULL, NULL, true); |
---|
| 3472 | caster->RemoveAurasDueToSpell(28734); |
---|
| 3473 | } |
---|
| 3474 | } |
---|
| 3475 | } |
---|
| 3476 | } |
---|
| 3477 | else |
---|
| 3478 | { |
---|
| 3479 | // Real remove called after current aura remove from lists, check if other similar auras active |
---|
| 3480 | if(m_target->HasAuraType(SPELL_AURA_MOD_SILENCE)) |
---|
| 3481 | return; |
---|
| 3482 | |
---|
| 3483 | m_target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED); |
---|
| 3484 | } |
---|
| 3485 | } |
---|
| 3486 | |
---|
| 3487 | void Aura::HandleModThreat(bool apply, bool Real) |
---|
| 3488 | { |
---|
| 3489 | // only at real add/remove aura |
---|
| 3490 | if(!Real) |
---|
| 3491 | return; |
---|
| 3492 | |
---|
| 3493 | if(!m_target->isAlive()) |
---|
| 3494 | return; |
---|
| 3495 | |
---|
| 3496 | Unit* caster = GetCaster(); |
---|
| 3497 | |
---|
| 3498 | if(!caster || !caster->isAlive()) |
---|
| 3499 | return; |
---|
| 3500 | |
---|
| 3501 | int level_diff = 0; |
---|
| 3502 | int multiplier = 0; |
---|
| 3503 | switch (GetId()) |
---|
| 3504 | { |
---|
| 3505 | // Arcane Shroud |
---|
| 3506 | case 26400: |
---|
| 3507 | level_diff = m_target->getLevel() - 60; |
---|
| 3508 | multiplier = 2; |
---|
| 3509 | break; |
---|
| 3510 | // The Eye of Diminution |
---|
| 3511 | case 28862: |
---|
| 3512 | level_diff = m_target->getLevel() - 60; |
---|
| 3513 | multiplier = 1; |
---|
| 3514 | break; |
---|
| 3515 | } |
---|
| 3516 | if (level_diff > 0) |
---|
| 3517 | m_modifier.m_amount += multiplier * level_diff; |
---|
| 3518 | |
---|
| 3519 | for(int8 x=0;x < MAX_SPELL_SCHOOL;x++) |
---|
| 3520 | { |
---|
| 3521 | if(m_modifier.m_miscvalue & int32(1<<x)) |
---|
| 3522 | { |
---|
| 3523 | if(m_target->GetTypeId() == TYPEID_PLAYER) |
---|
| 3524 | ApplyPercentModFloatVar(m_target->m_threatModifier[x], m_positive ? m_modifier.m_amount : -m_modifier.m_amount, apply); |
---|
| 3525 | } |
---|
| 3526 | } |
---|
| 3527 | } |
---|
| 3528 | |
---|
| 3529 | void Aura::HandleAuraModTotalThreat(bool apply, bool Real) |
---|
| 3530 | { |
---|
| 3531 | // only at real add/remove aura |
---|
| 3532 | if(!Real) |
---|
| 3533 | return; |
---|
| 3534 | |
---|
| 3535 | if(!m_target->isAlive() || m_target->GetTypeId()!= TYPEID_PLAYER) |
---|
| 3536 | return; |
---|
| 3537 | |
---|
| 3538 | Unit* caster = GetCaster(); |
---|
| 3539 | |
---|
| 3540 | if(!caster || !caster->isAlive()) |
---|
| 3541 | return; |
---|
| 3542 | |
---|
| 3543 | float threatMod = 0.0f; |
---|
| 3544 | if(apply) |
---|
| 3545 | threatMod = float(m_modifier.m_amount); |
---|
| 3546 | else |
---|
| 3547 | threatMod = float(-m_modifier.m_amount); |
---|
| 3548 | |
---|
| 3549 | m_target->getHostilRefManager().threatAssist(caster, threatMod); |
---|
| 3550 | } |
---|
| 3551 | |
---|
| 3552 | void Aura::HandleModTaunt(bool apply, bool Real) |
---|
| 3553 | { |
---|
| 3554 | // only at real add/remove aura |
---|
| 3555 | if(!Real) |
---|
| 3556 | return; |
---|
| 3557 | |
---|
| 3558 | if(!m_target->isAlive() || !m_target->CanHaveThreatList()) |
---|
| 3559 | return; |
---|
| 3560 | |
---|
| 3561 | Unit* caster = GetCaster(); |
---|
| 3562 | |
---|
| 3563 | if(!caster || !caster->isAlive() || caster->GetTypeId() != TYPEID_PLAYER) |
---|
| 3564 | return; |
---|
| 3565 | |
---|
| 3566 | if(apply) |
---|
| 3567 | m_target->TauntApply(caster); |
---|
| 3568 | else |
---|
| 3569 | { |
---|
| 3570 | // When taunt aura fades out, mob will switch to previous target if current has less than 1.1 * secondthreat |
---|
| 3571 | m_target->TauntFadeOut(caster); |
---|
| 3572 | } |
---|
| 3573 | } |
---|
| 3574 | |
---|
| 3575 | /*********************************************************/ |
---|
| 3576 | /*** MODIFY SPEED ***/ |
---|
| 3577 | /*********************************************************/ |
---|
| 3578 | void Aura::HandleAuraModIncreaseSpeed(bool apply, bool Real) |
---|
| 3579 | { |
---|
| 3580 | // all applied/removed only at real aura add/remove |
---|
| 3581 | if(!Real) |
---|
| 3582 | return; |
---|
| 3583 | |
---|
| 3584 | m_target->UpdateSpeed(MOVE_RUN, true); |
---|
| 3585 | } |
---|
| 3586 | |
---|
| 3587 | void Aura::HandleAuraModIncreaseMountedSpeed(bool apply, bool Real) |
---|
| 3588 | { |
---|
| 3589 | // all applied/removed only at real aura add/remove |
---|
| 3590 | if(!Real) |
---|
| 3591 | return; |
---|
| 3592 | |
---|
| 3593 | m_target->UpdateSpeed(MOVE_RUN, true); |
---|
| 3594 | } |
---|
| 3595 | |
---|
| 3596 | void Aura::HandleAuraModIncreaseFlightSpeed(bool apply, bool Real) |
---|
| 3597 | { |
---|
| 3598 | // all applied/removed only at real aura add/remove |
---|
| 3599 | if(!Real) |
---|
| 3600 | return; |
---|
| 3601 | |
---|
| 3602 | // Enable Fly mode for flying mounts |
---|
| 3603 | if (m_modifier.m_auraname == SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED) |
---|
| 3604 | { |
---|
| 3605 | WorldPacket data; |
---|
| 3606 | if(apply) |
---|
| 3607 | data.Initialize(SMSG_MOVE_SET_CAN_FLY, 12); |
---|
| 3608 | else |
---|
| 3609 | data.Initialize(SMSG_MOVE_UNSET_CAN_FLY, 12); |
---|
| 3610 | data.append(m_target->GetPackGUID()); |
---|
| 3611 | data << uint32(0); // unknown |
---|
| 3612 | m_target->SendMessageToSet(&data, true); |
---|
| 3613 | |
---|
| 3614 | //Players on flying mounts must be immune to polymorph |
---|
| 3615 | if (m_target->GetTypeId()==TYPEID_PLAYER) |
---|
| 3616 | m_target->ApplySpellImmune(GetId(),IMMUNITY_MECHANIC,MECHANIC_POLYMORPH,apply); |
---|
| 3617 | |
---|
| 3618 | // Dragonmaw Illusion (overwrite mount model, mounted aura already applied) |
---|
| 3619 | if( apply && m_target->HasAura(42016,0) && m_target->GetMountID()) |
---|
| 3620 | m_target->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID,16314); |
---|
| 3621 | } |
---|
| 3622 | |
---|
| 3623 | m_target->UpdateSpeed(MOVE_FLY, true); |
---|
| 3624 | } |
---|
| 3625 | |
---|
| 3626 | void Aura::HandleAuraModIncreaseSwimSpeed(bool apply, bool Real) |
---|
| 3627 | { |
---|
| 3628 | // all applied/removed only at real aura add/remove |
---|
| 3629 | if(!Real) |
---|
| 3630 | return; |
---|
| 3631 | |
---|
| 3632 | m_target->UpdateSpeed(MOVE_SWIM, true); |
---|
| 3633 | } |
---|
| 3634 | |
---|
| 3635 | void Aura::HandleAuraModDecreaseSpeed(bool apply, bool Real) |
---|
| 3636 | { |
---|
| 3637 | // all applied/removed only at real aura add/remove |
---|
| 3638 | if(!Real) |
---|
| 3639 | return; |
---|
| 3640 | |
---|
| 3641 | m_target->UpdateSpeed(MOVE_RUN, true); |
---|
| 3642 | m_target->UpdateSpeed(MOVE_SWIM, true); |
---|
| 3643 | m_target->UpdateSpeed(MOVE_FLY, true); |
---|
| 3644 | } |
---|
| 3645 | |
---|
| 3646 | void Aura::HandleAuraModUseNormalSpeed(bool apply, bool Real) |
---|
| 3647 | { |
---|
| 3648 | // all applied/removed only at real aura add/remove |
---|
| 3649 | if(!Real) |
---|
| 3650 | return; |
---|
| 3651 | |
---|
| 3652 | m_target->UpdateSpeed(MOVE_RUN, true); |
---|
| 3653 | m_target->UpdateSpeed(MOVE_SWIM, true); |
---|
| 3654 | m_target->UpdateSpeed(MOVE_FLY, true); |
---|
| 3655 | } |
---|
| 3656 | |
---|
| 3657 | /*********************************************************/ |
---|
| 3658 | /*** IMMUNITY ***/ |
---|
| 3659 | /*********************************************************/ |
---|
| 3660 | |
---|
| 3661 | void Aura::HandleModMechanicImmunity(bool apply, bool Real) |
---|
| 3662 | { |
---|
| 3663 | uint32 mechanic = 1 << m_modifier.m_miscvalue; |
---|
| 3664 | |
---|
| 3665 | //immune movement impairment and loss of control |
---|
| 3666 | if(GetId()==42292) |
---|
| 3667 | mechanic=IMMUNE_TO_MOVEMENT_IMPAIRMENT_AND_LOSS_CONTROL_MASK; |
---|
| 3668 | |
---|
| 3669 | if(apply && GetSpellProto()->AttributesEx & SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY) |
---|
| 3670 | { |
---|
| 3671 | Unit::AuraMap& Auras = m_target->GetAuras(); |
---|
| 3672 | for(Unit::AuraMap::iterator iter = Auras.begin(), next; iter != Auras.end(); iter = next) |
---|
| 3673 | { |
---|
| 3674 | next = iter; |
---|
| 3675 | ++next; |
---|
| 3676 | SpellEntry const *spell = iter->second->GetSpellProto(); |
---|
| 3677 | if (!( spell->Attributes & SPELL_ATTR_UNAFFECTED_BY_INVULNERABILITY) // spells unaffected by invulnerability |
---|
| 3678 | && !iter->second->IsPositive() // only remove negative spells |
---|
| 3679 | && spell->Id != GetId()) |
---|
| 3680 | { |
---|
| 3681 | //check for mechanic mask |
---|
| 3682 | if(GetSpellMechanicMask(spell, iter->second->GetEffIndex()) & mechanic) |
---|
| 3683 | { |
---|
| 3684 | m_target->RemoveAurasDueToSpell(spell->Id); |
---|
| 3685 | if(Auras.empty()) |
---|
| 3686 | break; |
---|
| 3687 | else |
---|
| 3688 | next = Auras.begin(); |
---|
| 3689 | } |
---|
| 3690 | } |
---|
| 3691 | } |
---|
| 3692 | } |
---|
| 3693 | |
---|
| 3694 | m_target->ApplySpellImmune(GetId(),IMMUNITY_MECHANIC,m_modifier.m_miscvalue,apply); |
---|
| 3695 | |
---|
| 3696 | // special cases |
---|
| 3697 | switch(m_modifier.m_miscvalue) |
---|
| 3698 | { |
---|
| 3699 | case MECHANIC_INVULNERABILITY: |
---|
| 3700 | m_target->ModifyAuraState(AURA_STATE_FORBEARANCE,apply); |
---|
| 3701 | break; |
---|
| 3702 | case MECHANIC_SHIELD: |
---|
| 3703 | m_target->ModifyAuraState(AURA_STATE_WEAKENED_SOUL,apply); |
---|
| 3704 | break; |
---|
| 3705 | } |
---|
| 3706 | |
---|
| 3707 | // Bestial Wrath |
---|
[104] | 3708 | if ( GetSpellProto()->SpellFamilyName == SPELLFAMILY_HUNTER && GetSpellProto()->Id == 19574) |
---|
[37] | 3709 | { |
---|
| 3710 | // The Beast Within cast on owner if talent present |
---|
| 3711 | if ( Unit* owner = m_target->GetOwner() ) |
---|
| 3712 | { |
---|
| 3713 | // Search talent |
---|
| 3714 | Unit::AuraList const& m_dummyAuras = owner->GetAurasByType(SPELL_AURA_DUMMY); |
---|
| 3715 | for(Unit::AuraList::const_iterator i = m_dummyAuras.begin(); i != m_dummyAuras.end(); ++i) |
---|
| 3716 | { |
---|
| 3717 | if ( (*i)->GetSpellProto()->SpellIconID == 2229 ) |
---|
| 3718 | { |
---|
| 3719 | if (apply) |
---|
| 3720 | owner->CastSpell(owner, 34471, true, 0, this); |
---|
| 3721 | else |
---|
| 3722 | owner->RemoveAurasDueToSpell(34471); |
---|
| 3723 | break; |
---|
| 3724 | } |
---|
| 3725 | } |
---|
| 3726 | } |
---|
| 3727 | } |
---|
| 3728 | |
---|
| 3729 | // The Beast Within and Bestial Wrath - immunity |
---|
| 3730 | if(GetId() == 19574 || GetId() == 34471) |
---|
| 3731 | { |
---|
| 3732 | if(apply) |
---|
| 3733 | { |
---|
| 3734 | m_target->CastSpell(m_target,24395,true); |
---|
| 3735 | m_target->CastSpell(m_target,24396,true); |
---|
| 3736 | m_target->CastSpell(m_target,24397,true); |
---|
| 3737 | m_target->CastSpell(m_target,26592,true); |
---|
| 3738 | } |
---|
| 3739 | else |
---|
| 3740 | { |
---|
| 3741 | m_target->RemoveAurasDueToSpell(24395); |
---|
| 3742 | m_target->RemoveAurasDueToSpell(24396); |
---|
| 3743 | m_target->RemoveAurasDueToSpell(24397); |
---|
| 3744 | m_target->RemoveAurasDueToSpell(26592); |
---|
| 3745 | } |
---|
| 3746 | } |
---|
| 3747 | } |
---|
| 3748 | |
---|
| 3749 | void Aura::HandleAuraModEffectImmunity(bool apply, bool Real) |
---|
| 3750 | { |
---|
| 3751 | if(!apply) |
---|
| 3752 | { |
---|
| 3753 | if(m_target->GetTypeId() == TYPEID_PLAYER) |
---|
| 3754 | { |
---|
| 3755 | if(((Player*)m_target)->InBattleGround()) |
---|
| 3756 | { |
---|
| 3757 | BattleGround *bg = ((Player*)m_target)->GetBattleGround(); |
---|
| 3758 | if(bg) |
---|
| 3759 | { |
---|
| 3760 | switch(bg->GetTypeID()) |
---|
| 3761 | { |
---|
| 3762 | case BATTLEGROUND_AV: |
---|
| 3763 | { |
---|
| 3764 | break; |
---|
| 3765 | } |
---|
| 3766 | case BATTLEGROUND_WS: |
---|
| 3767 | { |
---|
| 3768 | // Warsong Flag, horde // Silverwing Flag, alliance |
---|
| 3769 | if(GetId() == 23333 || GetId() == 23335) |
---|
| 3770 | bg->EventPlayerDroppedFlag(((Player*)m_target)); |
---|
| 3771 | break; |
---|
| 3772 | } |
---|
| 3773 | case BATTLEGROUND_AB: |
---|
| 3774 | { |
---|
| 3775 | break; |
---|
| 3776 | } |
---|
| 3777 | case BATTLEGROUND_EY: |
---|
| 3778 | { |
---|
| 3779 | if(GetId() == 34976) |
---|
| 3780 | bg->EventPlayerDroppedFlag(((Player*)m_target)); |
---|
| 3781 | break; |
---|
| 3782 | } |
---|
| 3783 | } |
---|
| 3784 | } |
---|
| 3785 | } |
---|
[44] | 3786 | else |
---|
| 3787 | sOutdoorPvPMgr.HandleDropFlag((Player*)m_target,GetSpellProto()->Id); |
---|
[37] | 3788 | } |
---|
| 3789 | } |
---|
| 3790 | |
---|
| 3791 | m_target->ApplySpellImmune(GetId(),IMMUNITY_EFFECT,m_modifier.m_miscvalue,apply); |
---|
| 3792 | } |
---|
| 3793 | |
---|
| 3794 | void Aura::HandleAuraModStateImmunity(bool apply, bool Real) |
---|
| 3795 | { |
---|
| 3796 | if(apply && Real && GetSpellProto()->AttributesEx & SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY) |
---|
| 3797 | { |
---|
| 3798 | Unit::AuraList const& auraList = m_target->GetAurasByType(AuraType(m_modifier.m_miscvalue)); |
---|
| 3799 | for(Unit::AuraList::const_iterator itr = auraList.begin(); itr != auraList.end();) |
---|
| 3800 | { |
---|
| 3801 | if (auraList.front() != this) // skip itself aura (it already added) |
---|
| 3802 | { |
---|
| 3803 | m_target->RemoveAurasDueToSpell(auraList.front()->GetId()); |
---|
| 3804 | itr = auraList.begin(); |
---|
| 3805 | } |
---|
| 3806 | else |
---|
| 3807 | ++itr; |
---|
| 3808 | } |
---|
| 3809 | } |
---|
| 3810 | |
---|
| 3811 | m_target->ApplySpellImmune(GetId(),IMMUNITY_STATE,m_modifier.m_miscvalue,apply); |
---|
| 3812 | } |
---|
| 3813 | |
---|
| 3814 | void Aura::HandleAuraModSchoolImmunity(bool apply, bool Real) |
---|
| 3815 | { |
---|
| 3816 | m_target->ApplySpellImmune(GetId(),IMMUNITY_SCHOOL,m_modifier.m_miscvalue,apply); |
---|
| 3817 | |
---|
| 3818 | if(Real && apply && GetSpellProto()->AttributesEx & SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY) |
---|
| 3819 | { |
---|
| 3820 | if(IsPositiveSpell(GetId())) //Only positive immunity removes auras |
---|
| 3821 | { |
---|
| 3822 | uint32 school_mask = m_modifier.m_miscvalue; |
---|
| 3823 | Unit::AuraMap& Auras = m_target->GetAuras(); |
---|
| 3824 | for(Unit::AuraMap::iterator iter = Auras.begin(), next; iter != Auras.end(); iter = next) |
---|
| 3825 | { |
---|
| 3826 | next = iter; |
---|
| 3827 | ++next; |
---|
| 3828 | SpellEntry const *spell = iter->second->GetSpellProto(); |
---|
| 3829 | if((GetSpellSchoolMask(spell) & school_mask)//Check for school mask |
---|
| 3830 | && !( spell->Attributes & SPELL_ATTR_UNAFFECTED_BY_INVULNERABILITY) //Spells unaffected by invulnerability |
---|
| 3831 | && !iter->second->IsPositive() //Don't remove positive spells |
---|
| 3832 | && spell->Id != GetId() ) //Don't remove self |
---|
| 3833 | { |
---|
| 3834 | m_target->RemoveAurasDueToSpell(spell->Id); |
---|
| 3835 | if(Auras.empty()) |
---|
| 3836 | break; |
---|
| 3837 | else |
---|
| 3838 | next = Auras.begin(); |
---|
| 3839 | } |
---|
| 3840 | } |
---|
| 3841 | } |
---|
| 3842 | } |
---|
| 3843 | if( Real && GetSpellProto()->Mechanic == MECHANIC_BANISH ) |
---|
| 3844 | { |
---|
| 3845 | if( apply ) |
---|
| 3846 | m_target->addUnitState(UNIT_STAT_ISOLATED); |
---|
| 3847 | else |
---|
| 3848 | m_target->clearUnitState(UNIT_STAT_ISOLATED); |
---|
| 3849 | } |
---|
| 3850 | } |
---|
| 3851 | |
---|
| 3852 | void Aura::HandleAuraModDmgImmunity(bool apply, bool Real) |
---|
| 3853 | { |
---|
| 3854 | m_target->ApplySpellImmune(GetId(),IMMUNITY_DAMAGE,m_modifier.m_miscvalue,apply); |
---|
| 3855 | } |
---|
| 3856 | |
---|
| 3857 | void Aura::HandleAuraModDispelImmunity(bool apply, bool Real) |
---|
| 3858 | { |
---|
| 3859 | // all applied/removed only at real aura add/remove |
---|
| 3860 | if(!Real) |
---|
| 3861 | return; |
---|
| 3862 | |
---|
| 3863 | m_target->ApplySpellDispelImmunity(m_spellProto, DispelType(m_modifier.m_miscvalue), apply); |
---|
| 3864 | } |
---|
| 3865 | |
---|
| 3866 | void Aura::HandleAuraProcTriggerSpell(bool apply, bool Real) |
---|
| 3867 | { |
---|
| 3868 | if(!Real) |
---|
| 3869 | return; |
---|
| 3870 | |
---|
| 3871 | if(apply) |
---|
| 3872 | { |
---|
| 3873 | // some spell have charges by functionality not have its in spell data |
---|
| 3874 | switch (GetId()) |
---|
| 3875 | { |
---|
| 3876 | case 28200: // Ascendance (Talisman of Ascendance trinket) |
---|
| 3877 | m_procCharges = 6; |
---|
| 3878 | UpdateAuraCharges(); |
---|
| 3879 | break; |
---|
| 3880 | default: break; |
---|
| 3881 | } |
---|
| 3882 | } |
---|
| 3883 | } |
---|
| 3884 | |
---|
| 3885 | void Aura::HandleAuraModStalked(bool apply, bool Real) |
---|
| 3886 | { |
---|
| 3887 | // used by spells: Hunter's Mark, Mind Vision, Syndicate Tracker (MURP) DND |
---|
| 3888 | if(apply) |
---|
| 3889 | m_target->SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_TRACK_UNIT); |
---|
| 3890 | else |
---|
| 3891 | m_target->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_TRACK_UNIT); |
---|
| 3892 | } |
---|
| 3893 | |
---|
| 3894 | /*********************************************************/ |
---|
| 3895 | /*** PERIODIC ***/ |
---|
| 3896 | /*********************************************************/ |
---|
| 3897 | |
---|
| 3898 | void Aura::HandlePeriodicTriggerSpell(bool apply, bool Real) |
---|
| 3899 | { |
---|
| 3900 | if (m_periodicTimer <= 0) |
---|
| 3901 | m_periodicTimer += m_modifier.periodictime; |
---|
| 3902 | |
---|
| 3903 | m_isPeriodic = apply; |
---|
| 3904 | m_isTrigger = apply; |
---|
| 3905 | |
---|
| 3906 | // Curse of the Plaguebringer |
---|
| 3907 | if (!apply && m_spellProto->Id == 29213 && m_removeMode!=AURA_REMOVE_BY_DISPEL) |
---|
| 3908 | { |
---|
| 3909 | // Cast Wrath of the Plaguebringer if not dispelled |
---|
| 3910 | m_target->CastSpell(m_target, 29214, true, 0, this); |
---|
| 3911 | } |
---|
| 3912 | } |
---|
| 3913 | |
---|
| 3914 | void Aura::HandlePeriodicEnergize(bool apply, bool Real) |
---|
| 3915 | { |
---|
| 3916 | if (m_periodicTimer <= 0) |
---|
| 3917 | m_periodicTimer += m_modifier.periodictime; |
---|
| 3918 | |
---|
| 3919 | m_isPeriodic = apply; |
---|
| 3920 | } |
---|
| 3921 | |
---|
| 3922 | void Aura::HandlePeriodicHeal(bool apply, bool Real) |
---|
| 3923 | { |
---|
| 3924 | if (m_periodicTimer <= 0) |
---|
| 3925 | m_periodicTimer += m_modifier.periodictime; |
---|
| 3926 | |
---|
| 3927 | m_isPeriodic = apply; |
---|
| 3928 | |
---|
| 3929 | // only at real apply |
---|
| 3930 | if (Real && apply && GetSpellProto()->Mechanic == MECHANIC_BANDAGE) |
---|
| 3931 | { |
---|
| 3932 | // provided m_target as original caster to prevent apply aura caster selection for this negative buff |
---|
| 3933 | m_target->CastSpell(m_target,11196,true,NULL,this,m_target->GetGUID()); |
---|
| 3934 | } |
---|
| 3935 | |
---|
| 3936 | // For prevent double apply bonuses |
---|
| 3937 | bool loading = (m_target->GetTypeId() == TYPEID_PLAYER && ((Player*)m_target)->GetSession()->PlayerLoading()); |
---|
| 3938 | |
---|
| 3939 | if(!loading && apply) |
---|
| 3940 | { |
---|
| 3941 | switch (m_spellProto->SpellFamilyName) |
---|
| 3942 | { |
---|
| 3943 | case SPELLFAMILY_DRUID: |
---|
| 3944 | { |
---|
| 3945 | // Rejuvenation |
---|
| 3946 | if(m_spellProto->SpellFamilyFlags & 0x0000000000000010LL) |
---|
| 3947 | { |
---|
| 3948 | if(Unit* caster = GetCaster()) |
---|
| 3949 | { |
---|
| 3950 | Unit::AuraList const& classScripts = caster->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); |
---|
| 3951 | for(Unit::AuraList::const_iterator k = classScripts.begin(); k != classScripts.end(); ++k) |
---|
| 3952 | { |
---|
| 3953 | int32 tickcount = GetSpellDuration(m_spellProto) / m_spellProto->EffectAmplitude[m_effIndex]; |
---|
| 3954 | switch((*k)->GetModifier()->m_miscvalue) |
---|
| 3955 | { |
---|
| 3956 | case 4953: // Increased Rejuvenation Healing - Harold's Rejuvenating Broach Aura |
---|
| 3957 | case 4415: // Increased Rejuvenation Healing - Idol of Rejuvenation Aura |
---|
| 3958 | { |
---|
| 3959 | m_modifier.m_amount += (*k)->GetModifier()->m_amount / tickcount; |
---|
| 3960 | break; |
---|
| 3961 | } |
---|
| 3962 | } |
---|
| 3963 | } |
---|
| 3964 | } |
---|
| 3965 | } |
---|
| 3966 | } |
---|
| 3967 | } |
---|
| 3968 | } |
---|
| 3969 | } |
---|
| 3970 | |
---|
| 3971 | void Aura::HandlePeriodicDamage(bool apply, bool Real) |
---|
| 3972 | { |
---|
| 3973 | // spells required only Real aura add/remove |
---|
| 3974 | if(!Real) |
---|
| 3975 | return; |
---|
| 3976 | |
---|
| 3977 | if (m_periodicTimer <= 0) |
---|
| 3978 | m_periodicTimer += m_modifier.periodictime; |
---|
| 3979 | |
---|
| 3980 | m_isPeriodic = apply; |
---|
| 3981 | |
---|
| 3982 | // For prevent double apply bonuses |
---|
| 3983 | bool loading = (m_target->GetTypeId() == TYPEID_PLAYER && ((Player*)m_target)->GetSession()->PlayerLoading()); |
---|
| 3984 | |
---|
| 3985 | Unit *caster = GetCaster(); |
---|
| 3986 | |
---|
| 3987 | switch (m_spellProto->SpellFamilyName) |
---|
| 3988 | { |
---|
| 3989 | case SPELLFAMILY_GENERIC: |
---|
| 3990 | { |
---|
| 3991 | // Pounce Bleed |
---|
| 3992 | if ( m_spellProto->SpellIconID == 147 && m_spellProto->SpellVisual == 0 ) |
---|
| 3993 | { |
---|
| 3994 | // $AP*0.18/6 bonus per tick |
---|
| 3995 | if (apply && !loading && caster) |
---|
| 3996 | m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(BASE_ATTACK) * 3 / 100); |
---|
| 3997 | return; |
---|
| 3998 | } |
---|
| 3999 | break; |
---|
| 4000 | } |
---|
| 4001 | case SPELLFAMILY_WARRIOR: |
---|
| 4002 | { |
---|
| 4003 | // Rend |
---|
| 4004 | if (m_spellProto->SpellFamilyFlags & 0x0000000000000020LL) |
---|
| 4005 | { |
---|
| 4006 | // 0.00743*(($MWB+$mwb)/2+$AP/14*$MWS) bonus per tick |
---|
| 4007 | if (apply && !loading && caster) |
---|
| 4008 | { |
---|
| 4009 | float ap = caster->GetTotalAttackPowerValue(BASE_ATTACK); |
---|
| 4010 | int32 mws = caster->GetAttackTime(BASE_ATTACK); |
---|
| 4011 | float mwb_min = caster->GetWeaponDamageRange(BASE_ATTACK,MINDAMAGE); |
---|
| 4012 | float mwb_max = caster->GetWeaponDamageRange(BASE_ATTACK,MAXDAMAGE); |
---|
| 4013 | // WARNING! in 3.0 multipler 0.00743f change to 0.6 |
---|
| 4014 | m_modifier.m_amount+=int32(((mwb_min+mwb_max)/2+ap*mws/14000)*0.00743f); |
---|
| 4015 | } |
---|
| 4016 | return; |
---|
| 4017 | } |
---|
| 4018 | break; |
---|
| 4019 | } |
---|
| 4020 | case SPELLFAMILY_DRUID: |
---|
| 4021 | { |
---|
| 4022 | // Rake |
---|
| 4023 | if (m_spellProto->SpellFamilyFlags & 0x0000000000001000LL) |
---|
| 4024 | { |
---|
| 4025 | // $AP*0.06/3 bonus per tick |
---|
| 4026 | if (apply && !loading && caster) |
---|
| 4027 | m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(BASE_ATTACK) * 2 / 100); |
---|
| 4028 | return; |
---|
| 4029 | } |
---|
| 4030 | // Lacerate |
---|
| 4031 | if (m_spellProto->SpellFamilyFlags & 0x000000010000000000LL) |
---|
| 4032 | { |
---|
| 4033 | // $AP*0.05/5 bonus per tick |
---|
| 4034 | if (apply && !loading && caster) |
---|
| 4035 | m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(BASE_ATTACK) / 100); |
---|
| 4036 | return; |
---|
| 4037 | } |
---|
| 4038 | // Rip |
---|
| 4039 | if (m_spellProto->SpellFamilyFlags & 0x000000000000800000LL) |
---|
| 4040 | { |
---|
| 4041 | // $AP * min(0.06*$cp, 0.24)/6 [Yes, there is no difference, wheather 4 or 5 CPs are being used] |
---|
| 4042 | if (apply && !loading && caster && caster->GetTypeId() == TYPEID_PLAYER) |
---|
| 4043 | { |
---|
| 4044 | uint8 cp = ((Player*)caster)->GetComboPoints(); |
---|
| 4045 | |
---|
| 4046 | // Idol of Feral Shadows. Cant be handled as SpellMod in SpellAura:Dummy due its dependency from CPs |
---|
| 4047 | Unit::AuraList const& dummyAuras = caster->GetAurasByType(SPELL_AURA_DUMMY); |
---|
| 4048 | for(Unit::AuraList::const_iterator itr = dummyAuras.begin(); itr != dummyAuras.end(); ++itr) |
---|
| 4049 | { |
---|
| 4050 | if((*itr)->GetId()==34241) |
---|
| 4051 | { |
---|
| 4052 | m_modifier.m_amount += cp * (*itr)->GetModifier()->m_amount; |
---|
| 4053 | break; |
---|
| 4054 | } |
---|
| 4055 | } |
---|
| 4056 | |
---|
| 4057 | if (cp > 4) cp = 4; |
---|
| 4058 | m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(BASE_ATTACK) * cp / 100); |
---|
| 4059 | } |
---|
| 4060 | return; |
---|
| 4061 | } |
---|
| 4062 | break; |
---|
| 4063 | } |
---|
| 4064 | case SPELLFAMILY_ROGUE: |
---|
| 4065 | { |
---|
| 4066 | // Deadly poison aura state |
---|
| 4067 | if((m_spellProto->SpellFamilyFlags & 0x10000) && m_spellProto->SpellVisual==5100) |
---|
| 4068 | { |
---|
| 4069 | if(apply) |
---|
| 4070 | m_target->ModifyAuraState(AURA_STATE_DEADLY_POISON,true); |
---|
| 4071 | else |
---|
| 4072 | { |
---|
| 4073 | // current aura already removed, search present of another |
---|
| 4074 | bool found = false; |
---|
| 4075 | Unit::AuraList const& auras = m_target->GetAurasByType(SPELL_AURA_PERIODIC_DAMAGE); |
---|
| 4076 | for(Unit::AuraList::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) |
---|
| 4077 | { |
---|
| 4078 | SpellEntry const* itr_spell = (*itr)->GetSpellProto(); |
---|
| 4079 | if(itr_spell && itr_spell->SpellFamilyName==SPELLFAMILY_ROGUE && (itr_spell->SpellFamilyFlags & 0x10000) && itr_spell->SpellVisual==5100) |
---|
| 4080 | { |
---|
| 4081 | found = true; |
---|
| 4082 | break; |
---|
| 4083 | } |
---|
| 4084 | } |
---|
| 4085 | // this has been last deadly poison aura |
---|
| 4086 | if(!found) |
---|
| 4087 | m_target->ModifyAuraState(AURA_STATE_DEADLY_POISON,false); |
---|
| 4088 | } |
---|
| 4089 | return; |
---|
| 4090 | } |
---|
| 4091 | // Rupture |
---|
| 4092 | if (m_spellProto->SpellFamilyFlags & 0x000000000000100000LL) |
---|
| 4093 | { |
---|
| 4094 | // Dmg/tick = $AP*min(0.01*$cp, 0.03) [Like Rip: only the first three CP inrease the contribution from AP] |
---|
| 4095 | if (apply && !loading && caster && caster->GetTypeId() == TYPEID_PLAYER) |
---|
| 4096 | { |
---|
| 4097 | uint8 cp = ((Player*)caster)->GetComboPoints(); |
---|
| 4098 | if (cp > 3) cp = 3; |
---|
| 4099 | m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(BASE_ATTACK) * cp / 100); |
---|
| 4100 | } |
---|
| 4101 | return; |
---|
| 4102 | } |
---|
| 4103 | // Garrote |
---|
| 4104 | if (m_spellProto->SpellFamilyFlags & 0x000000000000000100LL) |
---|
| 4105 | { |
---|
| 4106 | // $AP*0.18/6 bonus per tick |
---|
| 4107 | if (apply && !loading && caster) |
---|
| 4108 | m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(BASE_ATTACK) * 3 / 100); |
---|
| 4109 | return; |
---|
| 4110 | } |
---|
| 4111 | break; |
---|
| 4112 | } |
---|
| 4113 | case SPELLFAMILY_HUNTER: |
---|
| 4114 | { |
---|
| 4115 | // Serpent Sting |
---|
| 4116 | if (m_spellProto->SpellFamilyFlags & 0x0000000000004000LL) |
---|
| 4117 | { |
---|
| 4118 | // $RAP*0.1/5 bonus per tick |
---|
| 4119 | if (apply && !loading && caster) |
---|
| 4120 | m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(RANGED_ATTACK) * 10 / 500); |
---|
| 4121 | return; |
---|
| 4122 | } |
---|
| 4123 | // Immolation Trap |
---|
| 4124 | if (m_spellProto->SpellFamilyFlags & 0x0000000000000004LL && m_spellProto->SpellIconID == 678) |
---|
| 4125 | { |
---|
| 4126 | // $RAP*0.1/5 bonus per tick |
---|
| 4127 | if (apply && !loading && caster) |
---|
| 4128 | m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(RANGED_ATTACK) * 10 / 500); |
---|
| 4129 | return; |
---|
| 4130 | } |
---|
| 4131 | break; |
---|
| 4132 | } |
---|
| 4133 | case SPELLFAMILY_PALADIN: |
---|
| 4134 | { |
---|
| 4135 | // Consecration |
---|
| 4136 | if (m_spellProto->SpellFamilyFlags & 0x0000000000000020LL) |
---|
| 4137 | { |
---|
| 4138 | if (apply && !loading) |
---|
| 4139 | { |
---|
| 4140 | if(Unit* caster = GetCaster()) |
---|
| 4141 | { |
---|
| 4142 | Unit::AuraList const& classScripts = caster->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); |
---|
| 4143 | for(Unit::AuraList::const_iterator k = classScripts.begin(); k != classScripts.end(); ++k) |
---|
| 4144 | { |
---|
| 4145 | int32 tickcount = GetSpellDuration(m_spellProto) / m_spellProto->EffectAmplitude[m_effIndex]; |
---|
| 4146 | switch((*k)->GetModifier()->m_miscvalue) |
---|
| 4147 | { |
---|
| 4148 | case 5147: // Improved Consecration - Libram of the Eternal Rest |
---|
| 4149 | { |
---|
| 4150 | m_modifier.m_amount += (*k)->GetModifier()->m_amount / tickcount; |
---|
| 4151 | break; |
---|
| 4152 | } |
---|
| 4153 | } |
---|
| 4154 | } |
---|
| 4155 | } |
---|
| 4156 | } |
---|
| 4157 | return; |
---|
| 4158 | } |
---|
| 4159 | break; |
---|
| 4160 | } |
---|
| 4161 | default: |
---|
| 4162 | break; |
---|
| 4163 | } |
---|
| 4164 | } |
---|
| 4165 | |
---|
| 4166 | void Aura::HandlePeriodicDamagePCT(bool apply, bool Real) |
---|
| 4167 | { |
---|
| 4168 | if (m_periodicTimer <= 0) |
---|
| 4169 | m_periodicTimer += m_modifier.periodictime; |
---|
| 4170 | |
---|
| 4171 | m_isPeriodic = apply; |
---|
| 4172 | } |
---|
| 4173 | |
---|
| 4174 | void Aura::HandlePeriodicLeech(bool apply, bool Real) |
---|
| 4175 | { |
---|
| 4176 | if (m_periodicTimer <= 0) |
---|
| 4177 | m_periodicTimer += m_modifier.periodictime; |
---|
| 4178 | |
---|
| 4179 | m_isPeriodic = apply; |
---|
| 4180 | } |
---|
| 4181 | |
---|
| 4182 | void Aura::HandlePeriodicManaLeech(bool apply, bool Real) |
---|
| 4183 | { |
---|
| 4184 | if (m_periodicTimer <= 0) |
---|
| 4185 | m_periodicTimer += m_modifier.periodictime; |
---|
| 4186 | |
---|
| 4187 | m_isPeriodic = apply; |
---|
| 4188 | } |
---|
| 4189 | |
---|
| 4190 | /*********************************************************/ |
---|
| 4191 | /*** MODIFY STATS ***/ |
---|
| 4192 | /*********************************************************/ |
---|
| 4193 | |
---|
| 4194 | /********************************/ |
---|
| 4195 | /*** RESISTANCE ***/ |
---|
| 4196 | /********************************/ |
---|
| 4197 | |
---|
| 4198 | void Aura::HandleAuraModResistanceExclusive(bool apply, bool Real) |
---|
| 4199 | { |
---|
| 4200 | for(int8 x = SPELL_SCHOOL_NORMAL; x < MAX_SPELL_SCHOOL;x++) |
---|
| 4201 | { |
---|
| 4202 | if(m_modifier.m_miscvalue & int32(1<<x)) |
---|
| 4203 | { |
---|
| 4204 | m_target->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + x), BASE_VALUE, float(m_modifier.m_amount), apply); |
---|
| 4205 | if(m_target->GetTypeId() == TYPEID_PLAYER) |
---|
| 4206 | m_target->ApplyResistanceBuffModsMod(SpellSchools(x),m_positive,m_modifier.m_amount, apply); |
---|
| 4207 | } |
---|
| 4208 | } |
---|
| 4209 | } |
---|
| 4210 | |
---|
| 4211 | void Aura::HandleAuraModResistance(bool apply, bool Real) |
---|
| 4212 | { |
---|
| 4213 | for(int8 x = SPELL_SCHOOL_NORMAL; x < MAX_SPELL_SCHOOL;x++) |
---|
| 4214 | { |
---|
| 4215 | if(m_modifier.m_miscvalue & int32(1<<x)) |
---|
| 4216 | { |
---|
| 4217 | m_target->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + x), TOTAL_VALUE, float(m_modifier.m_amount), apply); |
---|
| 4218 | if(m_target->GetTypeId() == TYPEID_PLAYER || ((Creature*)m_target)->isPet()) |
---|
| 4219 | m_target->ApplyResistanceBuffModsMod(SpellSchools(x),m_positive,m_modifier.m_amount, apply); |
---|
| 4220 | } |
---|
| 4221 | } |
---|
| 4222 | |
---|
| 4223 | // Faerie Fire (druid versions) |
---|
| 4224 | if( m_spellProto->SpellIconID == 109 && |
---|
| 4225 | m_spellProto->SpellFamilyName == SPELLFAMILY_DRUID && |
---|
| 4226 | m_spellProto->SpellFamilyFlags & 0x0000000000000400LL ) |
---|
| 4227 | { |
---|
| 4228 | m_target->ModifyAuraState(AURA_STATE_FAERIE_FIRE,apply); |
---|
| 4229 | } |
---|
| 4230 | } |
---|
| 4231 | |
---|
| 4232 | void Aura::HandleAuraModBaseResistancePCT(bool apply, bool Real) |
---|
| 4233 | { |
---|
| 4234 | // only players have base stats |
---|
| 4235 | if(m_target->GetTypeId() != TYPEID_PLAYER) |
---|
| 4236 | { |
---|
| 4237 | //pets only have base armor |
---|
| 4238 | if(((Creature*)m_target)->isPet() && (m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_NORMAL)) |
---|
| 4239 | m_target->HandleStatModifier(UNIT_MOD_ARMOR, BASE_PCT, float(m_modifier.m_amount), apply); |
---|
| 4240 | } |
---|
| 4241 | else |
---|
| 4242 | { |
---|
| 4243 | for(int8 x = SPELL_SCHOOL_NORMAL; x < MAX_SPELL_SCHOOL;x++) |
---|
| 4244 | { |
---|
| 4245 | if(m_modifier.m_miscvalue & int32(1<<x)) |
---|
| 4246 | m_target->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + x), BASE_PCT, float(m_modifier.m_amount), apply); |
---|
| 4247 | } |
---|
| 4248 | } |
---|
| 4249 | } |
---|
| 4250 | |
---|
| 4251 | void Aura::HandleModResistancePercent(bool apply, bool Real) |
---|
| 4252 | { |
---|
| 4253 | for(int8 i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; i++) |
---|
| 4254 | { |
---|
| 4255 | if(m_modifier.m_miscvalue & int32(1<<i)) |
---|
| 4256 | { |
---|
| 4257 | m_target->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + i), TOTAL_PCT, float(m_modifier.m_amount), apply); |
---|
| 4258 | if(m_target->GetTypeId() == TYPEID_PLAYER || ((Creature*)m_target)->isPet()) |
---|
| 4259 | { |
---|
| 4260 | m_target->ApplyResistanceBuffModsPercentMod(SpellSchools(i),true,m_modifier.m_amount, apply); |
---|
| 4261 | m_target->ApplyResistanceBuffModsPercentMod(SpellSchools(i),false,m_modifier.m_amount, apply); |
---|
| 4262 | } |
---|
| 4263 | } |
---|
| 4264 | } |
---|
| 4265 | } |
---|
| 4266 | |
---|
| 4267 | void Aura::HandleModBaseResistance(bool apply, bool Real) |
---|
| 4268 | { |
---|
| 4269 | // only players have base stats |
---|
| 4270 | if(m_target->GetTypeId() != TYPEID_PLAYER) |
---|
| 4271 | { |
---|
| 4272 | //only pets have base stats |
---|
| 4273 | if(((Creature*)m_target)->isPet() && (m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_NORMAL)) |
---|
| 4274 | m_target->HandleStatModifier(UNIT_MOD_ARMOR, TOTAL_VALUE, float(m_modifier.m_amount), apply); |
---|
| 4275 | } |
---|
| 4276 | else |
---|
| 4277 | { |
---|
| 4278 | for(int i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; i++) |
---|
| 4279 | if(m_modifier.m_miscvalue & (1<<i)) |
---|
| 4280 | m_target->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + i), TOTAL_VALUE, float(m_modifier.m_amount), apply); |
---|
| 4281 | } |
---|
| 4282 | } |
---|
| 4283 | |
---|
| 4284 | /********************************/ |
---|
| 4285 | /*** STAT ***/ |
---|
| 4286 | /********************************/ |
---|
| 4287 | |
---|
| 4288 | void Aura::HandleAuraModStat(bool apply, bool Real) |
---|
| 4289 | { |
---|
| 4290 | if (m_modifier.m_miscvalue < -2 || m_modifier.m_miscvalue > 4) |
---|
| 4291 | { |
---|
| 4292 | sLog.outError("WARNING: Spell %u effect %u have unsupported misc value (%i) for SPELL_AURA_MOD_STAT ",GetId(),GetEffIndex(),m_modifier.m_miscvalue); |
---|
| 4293 | return; |
---|
| 4294 | } |
---|
| 4295 | |
---|
| 4296 | for(int32 i = STAT_STRENGTH; i < MAX_STATS; i++) |
---|
| 4297 | { |
---|
| 4298 | // -1 or -2 is all stats ( misc < -2 checked in function beginning ) |
---|
| 4299 | if (m_modifier.m_miscvalue < 0 || m_modifier.m_miscvalue == i) |
---|
| 4300 | { |
---|
| 4301 | //m_target->ApplyStatMod(Stats(i), m_modifier.m_amount,apply); |
---|
| 4302 | m_target->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START + i), TOTAL_VALUE, float(m_modifier.m_amount), apply); |
---|
| 4303 | if(m_target->GetTypeId() == TYPEID_PLAYER || ((Creature*)m_target)->isPet()) |
---|
| 4304 | m_target->ApplyStatBuffMod(Stats(i),m_modifier.m_amount,apply); |
---|
| 4305 | } |
---|
| 4306 | } |
---|
| 4307 | } |
---|
| 4308 | |
---|
| 4309 | void Aura::HandleModPercentStat(bool apply, bool Real) |
---|
| 4310 | { |
---|
| 4311 | if (m_modifier.m_miscvalue < -1 || m_modifier.m_miscvalue > 4) |
---|
| 4312 | { |
---|
| 4313 | sLog.outError("WARNING: Misc Value for SPELL_AURA_MOD_PERCENT_STAT not valid"); |
---|
| 4314 | return; |
---|
| 4315 | } |
---|
| 4316 | |
---|
| 4317 | // only players have base stats |
---|
| 4318 | if (m_target->GetTypeId() != TYPEID_PLAYER) |
---|
| 4319 | return; |
---|
| 4320 | |
---|
| 4321 | for (int32 i = STAT_STRENGTH; i < MAX_STATS; ++i) |
---|
| 4322 | { |
---|
| 4323 | if(m_modifier.m_miscvalue == i || m_modifier.m_miscvalue == -1) |
---|
| 4324 | m_target->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START + i), BASE_PCT, float(m_modifier.m_amount), apply); |
---|
| 4325 | } |
---|
| 4326 | } |
---|
| 4327 | |
---|
| 4328 | void Aura::HandleModSpellDamagePercentFromStat(bool apply, bool Real) |
---|
| 4329 | { |
---|
| 4330 | if(m_target->GetTypeId() != TYPEID_PLAYER) |
---|
| 4331 | return; |
---|
| 4332 | |
---|
| 4333 | // Magic damage modifiers implemented in Unit::SpellDamageBonus |
---|
| 4334 | // This information for client side use only |
---|
| 4335 | // Recalculate bonus |
---|
| 4336 | ((Player*)m_target)->UpdateSpellDamageAndHealingBonus(); |
---|
| 4337 | } |
---|
| 4338 | |
---|
| 4339 | void Aura::HandleModSpellHealingPercentFromStat(bool apply, bool Real) |
---|
| 4340 | { |
---|
| 4341 | if(m_target->GetTypeId() != TYPEID_PLAYER) |
---|
| 4342 | return; |
---|
| 4343 | |
---|
| 4344 | // Recalculate bonus |
---|
| 4345 | ((Player*)m_target)->UpdateSpellDamageAndHealingBonus(); |
---|
| 4346 | } |
---|
| 4347 | |
---|
| 4348 | void Aura::HandleAuraModDispelResist(bool apply, bool Real) |
---|
| 4349 | { |
---|
| 4350 | if(!Real || !apply) |
---|
| 4351 | return; |
---|
| 4352 | |
---|
| 4353 | if(GetId()==33206) |
---|
| 4354 | m_target->CastSpell(m_target,44416,true,NULL,this,GetCasterGUID()); |
---|
| 4355 | } |
---|
| 4356 | |
---|
| 4357 | void Aura::HandleModSpellDamagePercentFromAttackPower(bool apply, bool Real) |
---|
| 4358 | { |
---|
| 4359 | if(m_target->GetTypeId() != TYPEID_PLAYER) |
---|
| 4360 | return; |
---|
| 4361 | |
---|
| 4362 | // Magic damage modifiers implemented in Unit::SpellDamageBonus |
---|
| 4363 | // This information for client side use only |
---|
| 4364 | // Recalculate bonus |
---|
| 4365 | ((Player*)m_target)->UpdateSpellDamageAndHealingBonus(); |
---|
| 4366 | } |
---|
| 4367 | |
---|
| 4368 | void Aura::HandleModSpellHealingPercentFromAttackPower(bool apply, bool Real) |
---|
| 4369 | { |
---|
| 4370 | if(m_target->GetTypeId() != TYPEID_PLAYER) |
---|
| 4371 | return; |
---|
| 4372 | |
---|
| 4373 | // Recalculate bonus |
---|
| 4374 | ((Player*)m_target)->UpdateSpellDamageAndHealingBonus(); |
---|
| 4375 | } |
---|
| 4376 | |
---|
| 4377 | void Aura::HandleModHealingDone(bool apply, bool Real) |
---|
| 4378 | { |
---|
| 4379 | if(m_target->GetTypeId() != TYPEID_PLAYER) |
---|
| 4380 | return; |
---|
| 4381 | // implemented in Unit::SpellHealingBonus |
---|
| 4382 | // this information is for client side only |
---|
| 4383 | ((Player*)m_target)->UpdateSpellDamageAndHealingBonus(); |
---|
| 4384 | } |
---|
| 4385 | |
---|
| 4386 | void Aura::HandleModTotalPercentStat(bool apply, bool Real) |
---|
| 4387 | { |
---|
| 4388 | if (m_modifier.m_miscvalue < -1 || m_modifier.m_miscvalue > 4) |
---|
| 4389 | { |
---|
| 4390 | sLog.outError("WARNING: Misc Value for SPELL_AURA_MOD_PERCENT_STAT not valid"); |
---|
| 4391 | return; |
---|
| 4392 | } |
---|
| 4393 | |
---|
| 4394 | //save current and max HP before applying aura |
---|
| 4395 | uint32 curHPValue = m_target->GetHealth(); |
---|
| 4396 | uint32 maxHPValue = m_target->GetMaxHealth(); |
---|
| 4397 | |
---|
| 4398 | for (int32 i = STAT_STRENGTH; i < MAX_STATS; i++) |
---|
| 4399 | { |
---|
| 4400 | if(m_modifier.m_miscvalue == i || m_modifier.m_miscvalue == -1) |
---|
| 4401 | { |
---|
| 4402 | m_target->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START + i), TOTAL_PCT, float(m_modifier.m_amount), apply); |
---|
| 4403 | if(m_target->GetTypeId() == TYPEID_PLAYER || ((Creature*)m_target)->isPet()) |
---|
| 4404 | m_target->ApplyStatPercentBuffMod(Stats(i), m_modifier.m_amount, apply ); |
---|
| 4405 | } |
---|
| 4406 | } |
---|
| 4407 | |
---|
| 4408 | //recalculate current HP/MP after applying aura modifications (only for spells with 0x10 flag) |
---|
| 4409 | if ((m_modifier.m_miscvalue == STAT_STAMINA) && (maxHPValue > 0) && (m_spellProto->Attributes & 0x10)) |
---|
| 4410 | { |
---|
| 4411 | // newHP = (curHP / maxHP) * newMaxHP = (newMaxHP * curHP) / maxHP -> which is better because no int -> double -> int conversion is needed |
---|
| 4412 | uint32 newHPValue = (m_target->GetMaxHealth() * curHPValue) / maxHPValue; |
---|
| 4413 | m_target->SetHealth(newHPValue); |
---|
| 4414 | } |
---|
| 4415 | } |
---|
| 4416 | |
---|
| 4417 | void Aura::HandleAuraModResistenceOfStatPercent(bool apply, bool Real) |
---|
| 4418 | { |
---|
| 4419 | if(m_target->GetTypeId() != TYPEID_PLAYER) |
---|
| 4420 | return; |
---|
| 4421 | |
---|
| 4422 | if(m_modifier.m_miscvalue != SPELL_SCHOOL_MASK_NORMAL) |
---|
| 4423 | { |
---|
| 4424 | // support required adding replace UpdateArmor by loop by UpdateResistence at intelect update |
---|
| 4425 | // and include in UpdateResistence same code as in UpdateArmor for aura mod apply. |
---|
| 4426 | sLog.outError("Aura SPELL_AURA_MOD_RESISTANCE_OF_STAT_PERCENT(182) need adding support for non-armor resistences!"); |
---|
| 4427 | return; |
---|
| 4428 | } |
---|
| 4429 | |
---|
| 4430 | // Recalculate Armor |
---|
| 4431 | m_target->UpdateArmor(); |
---|
| 4432 | } |
---|
| 4433 | |
---|
| 4434 | /********************************/ |
---|
| 4435 | /*** HEAL & ENERGIZE ***/ |
---|
| 4436 | /********************************/ |
---|
| 4437 | void Aura::HandleAuraModTotalHealthPercentRegen(bool apply, bool Real) |
---|
| 4438 | { |
---|
| 4439 | /* |
---|
| 4440 | Need additional checking for auras who reduce or increase healing, magic effect like Dumpen Magic, |
---|
| 4441 | so this aura not fully working. |
---|
| 4442 | */ |
---|
| 4443 | if(apply) |
---|
| 4444 | { |
---|
| 4445 | if(!m_target->isAlive()) |
---|
| 4446 | return; |
---|
| 4447 | |
---|
| 4448 | if((GetSpellProto()->AuraInterruptFlags & AURA_INTERRUPT_FLAG_NOT_SEATED) && !m_target->IsSitState()) |
---|
| 4449 | m_target->SetStandState(PLAYER_STATE_SIT); |
---|
| 4450 | |
---|
| 4451 | if(m_periodicTimer <= 0) |
---|
| 4452 | { |
---|
| 4453 | m_periodicTimer += m_modifier.periodictime; |
---|
| 4454 | |
---|
| 4455 | if(m_target->GetHealth() < m_target->GetMaxHealth()) |
---|
| 4456 | { |
---|
| 4457 | // PeriodicTick can cast triggered spells with stats changes |
---|
| 4458 | PeriodicTick(); |
---|
| 4459 | } |
---|
| 4460 | } |
---|
| 4461 | } |
---|
| 4462 | |
---|
| 4463 | m_isPeriodic = apply; |
---|
| 4464 | } |
---|
| 4465 | |
---|
| 4466 | void Aura::HandleAuraModTotalManaPercentRegen(bool apply, bool Real) |
---|
| 4467 | { |
---|
| 4468 | if((GetSpellProto()->AuraInterruptFlags & AURA_INTERRUPT_FLAG_NOT_SEATED) && apply && !m_target->IsSitState()) |
---|
| 4469 | m_target->SetStandState(PLAYER_STATE_SIT); |
---|
| 4470 | if(apply) |
---|
| 4471 | { |
---|
| 4472 | if(m_modifier.periodictime == 0) |
---|
| 4473 | m_modifier.periodictime = 1000; |
---|
| 4474 | if(m_periodicTimer <= 0 && m_target->getPowerType() == POWER_MANA) |
---|
| 4475 | { |
---|
| 4476 | m_periodicTimer += m_modifier.periodictime; |
---|
| 4477 | |
---|
| 4478 | if(m_target->GetPower(POWER_MANA) < m_target->GetMaxPower(POWER_MANA)) |
---|
| 4479 | { |
---|
| 4480 | // PeriodicTick can cast triggered spells with stats changes |
---|
| 4481 | PeriodicTick(); |
---|
| 4482 | } |
---|
| 4483 | } |
---|
| 4484 | } |
---|
| 4485 | |
---|
| 4486 | m_isPeriodic = apply; |
---|
| 4487 | } |
---|
| 4488 | |
---|
| 4489 | void Aura::HandleModRegen(bool apply, bool Real) // eating |
---|
| 4490 | { |
---|
| 4491 | if(apply) |
---|
| 4492 | { |
---|
| 4493 | if(!m_target->isAlive()) |
---|
| 4494 | return; |
---|
| 4495 | |
---|
| 4496 | if ((GetSpellProto()->AuraInterruptFlags & AURA_INTERRUPT_FLAG_NOT_SEATED) && !m_target->IsSitState()) |
---|
| 4497 | m_target->SetStandState(PLAYER_STATE_SIT); |
---|
| 4498 | |
---|
| 4499 | if(m_periodicTimer <= 0) |
---|
| 4500 | { |
---|
| 4501 | m_periodicTimer += 5000; |
---|
| 4502 | int32 gain = m_target->ModifyHealth(m_modifier.m_amount); |
---|
| 4503 | Unit *caster = GetCaster(); |
---|
| 4504 | if (caster) |
---|
| 4505 | { |
---|
| 4506 | SpellEntry const *spellProto = GetSpellProto(); |
---|
| 4507 | if (spellProto) |
---|
| 4508 | m_target->getHostilRefManager().threatAssist(caster, float(gain) * 0.5f, spellProto); |
---|
| 4509 | } |
---|
| 4510 | } |
---|
| 4511 | } |
---|
| 4512 | |
---|
| 4513 | m_isPeriodic = apply; |
---|
| 4514 | } |
---|
| 4515 | |
---|
| 4516 | void Aura::HandleModPowerRegen(bool apply, bool Real) // drinking |
---|
| 4517 | { |
---|
| 4518 | if ((GetSpellProto()->AuraInterruptFlags & AURA_INTERRUPT_FLAG_NOT_SEATED) && apply && !m_target->IsSitState()) |
---|
| 4519 | m_target->SetStandState(PLAYER_STATE_SIT); |
---|
| 4520 | |
---|
| 4521 | if(apply && m_periodicTimer <= 0) |
---|
| 4522 | { |
---|
| 4523 | m_periodicTimer += 2000; |
---|
| 4524 | |
---|
| 4525 | Powers pt = m_target->getPowerType(); |
---|
| 4526 | if(int32(pt) != m_modifier.m_miscvalue) |
---|
| 4527 | return; |
---|
| 4528 | |
---|
| 4529 | if ( GetSpellProto()->AuraInterruptFlags & AURA_INTERRUPT_FLAG_NOT_SEATED ) |
---|
| 4530 | { |
---|
| 4531 | // eating anim |
---|
| 4532 | m_target->HandleEmoteCommand(EMOTE_ONESHOT_EAT); |
---|
| 4533 | } |
---|
| 4534 | else if( GetId() == 20577 ) |
---|
| 4535 | { |
---|
| 4536 | // cannibalize anim |
---|
| 4537 | m_target->HandleEmoteCommand(398); |
---|
| 4538 | } |
---|
| 4539 | |
---|
| 4540 | // Warrior talent, gain 1 rage every 3 seconds while in combat |
---|
| 4541 | if(pt == POWER_RAGE && m_target->isInCombat()) |
---|
| 4542 | { |
---|
| 4543 | m_target->ModifyPower(pt, m_modifier.m_amount*10/17); |
---|
| 4544 | m_periodicTimer += 1000; |
---|
| 4545 | } |
---|
| 4546 | } |
---|
| 4547 | m_isPeriodic = apply; |
---|
| 4548 | if (Real && m_target->GetTypeId() == TYPEID_PLAYER && m_modifier.m_miscvalue == POWER_MANA) |
---|
| 4549 | ((Player*)m_target)->UpdateManaRegen(); |
---|
| 4550 | } |
---|
| 4551 | |
---|
| 4552 | void Aura::HandleModPowerRegenPCT(bool apply, bool Real) |
---|
| 4553 | { |
---|
| 4554 | // spells required only Real aura add/remove |
---|
| 4555 | if(!Real) |
---|
| 4556 | return; |
---|
| 4557 | |
---|
| 4558 | if (m_target->GetTypeId() != TYPEID_PLAYER) |
---|
| 4559 | return; |
---|
| 4560 | |
---|
| 4561 | // Update manaregen value |
---|
| 4562 | if (m_modifier.m_miscvalue == POWER_MANA) |
---|
| 4563 | ((Player*)m_target)->UpdateManaRegen(); |
---|
| 4564 | } |
---|
| 4565 | |
---|
| 4566 | void Aura::HandleModManaRegen(bool apply, bool Real) |
---|
| 4567 | { |
---|
| 4568 | // spells required only Real aura add/remove |
---|
| 4569 | if(!Real) |
---|
| 4570 | return; |
---|
| 4571 | |
---|
| 4572 | if (m_target->GetTypeId() != TYPEID_PLAYER) |
---|
| 4573 | return; |
---|
| 4574 | |
---|
| 4575 | //Note: an increase in regen does NOT cause threat. |
---|
| 4576 | ((Player*)m_target)->UpdateManaRegen(); |
---|
| 4577 | } |
---|
| 4578 | |
---|
| 4579 | void Aura::HandleComprehendLanguage(bool apply, bool Real) |
---|
| 4580 | { |
---|
| 4581 | if(apply) |
---|
| 4582 | m_target->SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_COMPREHEND_LANG); |
---|
| 4583 | else |
---|
| 4584 | m_target->RemoveFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_COMPREHEND_LANG); |
---|
| 4585 | } |
---|
| 4586 | |
---|
| 4587 | void Aura::HandleAuraModIncreaseHealth(bool apply, bool Real) |
---|
| 4588 | { |
---|
[161] | 4589 | if(Real) |
---|
[37] | 4590 | { |
---|
[161] | 4591 | if(apply) |
---|
[37] | 4592 | { |
---|
[161] | 4593 | m_target->HandleStatModifier(UNIT_MOD_HEALTH, TOTAL_VALUE, float(m_modifier.m_amount), apply); |
---|
| 4594 | m_target->ModifyHealth(m_modifier.m_amount); |
---|
[37] | 4595 | } |
---|
[161] | 4596 | else |
---|
| 4597 | { |
---|
| 4598 | if (int32(m_target->GetHealth()) > m_modifier.m_amount) |
---|
| 4599 | m_target->ModifyHealth(-m_modifier.m_amount); |
---|
| 4600 | else |
---|
| 4601 | m_target->SetHealth(1); |
---|
| 4602 | m_target->HandleStatModifier(UNIT_MOD_HEALTH, TOTAL_VALUE, float(m_modifier.m_amount), apply); |
---|
| 4603 | } |
---|
[37] | 4604 | } |
---|
| 4605 | } |
---|
| 4606 | |
---|
| 4607 | void Aura::HandleAuraModIncreaseMaxHealth(bool apply, bool Real) |
---|
| 4608 | { |
---|
| 4609 | uint32 oldhealth = m_target->GetHealth(); |
---|
| 4610 | double healthPercentage = (double)oldhealth / (double)m_target->GetMaxHealth(); |
---|
| 4611 | |
---|
| 4612 | m_target->HandleStatModifier(UNIT_MOD_HEALTH, TOTAL_VALUE, float(m_modifier.m_amount), apply); |
---|
| 4613 | |
---|
| 4614 | // refresh percentage |
---|
| 4615 | if(oldhealth > 0) |
---|
| 4616 | { |
---|
| 4617 | uint32 newhealth = uint32(ceil((double)m_target->GetMaxHealth() * healthPercentage)); |
---|
| 4618 | if(newhealth==0) |
---|
| 4619 | newhealth = 1; |
---|
| 4620 | |
---|
| 4621 | m_target->SetHealth(newhealth); |
---|
| 4622 | } |
---|
| 4623 | } |
---|
| 4624 | |
---|
| 4625 | void Aura::HandleAuraModIncreaseEnergy(bool apply, bool Real) |
---|
| 4626 | { |
---|
| 4627 | Powers powerType = m_target->getPowerType(); |
---|
| 4628 | if(int32(powerType) != m_modifier.m_miscvalue) |
---|
| 4629 | return; |
---|
| 4630 | |
---|
| 4631 | m_target->HandleStatModifier(UnitMods(UNIT_MOD_POWER_START + powerType), TOTAL_VALUE, float(m_modifier.m_amount), apply); |
---|
| 4632 | } |
---|
| 4633 | |
---|
| 4634 | void Aura::HandleAuraModIncreaseEnergyPercent(bool apply, bool Real) |
---|
| 4635 | { |
---|
| 4636 | Powers powerType = m_target->getPowerType(); |
---|
| 4637 | if(int32(powerType) != m_modifier.m_miscvalue) |
---|
| 4638 | return; |
---|
| 4639 | |
---|
| 4640 | m_target->HandleStatModifier(UnitMods(UNIT_MOD_POWER_START + powerType), TOTAL_PCT, float(m_modifier.m_amount), apply); |
---|
| 4641 | } |
---|
| 4642 | |
---|
| 4643 | void Aura::HandleAuraModIncreaseHealthPercent(bool apply, bool Real) |
---|
| 4644 | { |
---|
| 4645 | //m_target->ApplyMaxHealthPercentMod(m_modifier.m_amount,apply); |
---|
| 4646 | m_target->HandleStatModifier(UNIT_MOD_HEALTH, TOTAL_PCT, float(m_modifier.m_amount), apply); |
---|
| 4647 | } |
---|
| 4648 | |
---|
| 4649 | /********************************/ |
---|
| 4650 | /*** FIGHT ***/ |
---|
| 4651 | /********************************/ |
---|
| 4652 | |
---|
| 4653 | void Aura::HandleAuraModParryPercent(bool apply, bool Real) |
---|
| 4654 | { |
---|
| 4655 | if(m_target->GetTypeId()!=TYPEID_PLAYER) |
---|
| 4656 | return; |
---|
| 4657 | |
---|
| 4658 | ((Player*)m_target)->UpdateParryPercentage(); |
---|
| 4659 | } |
---|
| 4660 | |
---|
| 4661 | void Aura::HandleAuraModDodgePercent(bool apply, bool Real) |
---|
| 4662 | { |
---|
| 4663 | if(m_target->GetTypeId()!=TYPEID_PLAYER) |
---|
| 4664 | return; |
---|
| 4665 | |
---|
| 4666 | ((Player*)m_target)->UpdateDodgePercentage(); |
---|
| 4667 | //sLog.outError("BONUS DODGE CHANCE: + %f", float(m_modifier.m_amount)); |
---|
| 4668 | } |
---|
| 4669 | |
---|
| 4670 | void Aura::HandleAuraModBlockPercent(bool apply, bool Real) |
---|
| 4671 | { |
---|
| 4672 | if(m_target->GetTypeId()!=TYPEID_PLAYER) |
---|
| 4673 | return; |
---|
| 4674 | |
---|
| 4675 | ((Player*)m_target)->UpdateBlockPercentage(); |
---|
| 4676 | //sLog.outError("BONUS BLOCK CHANCE: + %f", float(m_modifier.m_amount)); |
---|
| 4677 | } |
---|
| 4678 | |
---|
| 4679 | void Aura::HandleAuraModRegenInterrupt(bool apply, bool Real) |
---|
| 4680 | { |
---|
| 4681 | // spells required only Real aura add/remove |
---|
| 4682 | if(!Real) |
---|
| 4683 | return; |
---|
| 4684 | |
---|
| 4685 | if(m_target->GetTypeId()!=TYPEID_PLAYER) |
---|
| 4686 | return; |
---|
| 4687 | |
---|
| 4688 | ((Player*)m_target)->UpdateManaRegen(); |
---|
| 4689 | } |
---|
| 4690 | |
---|
| 4691 | void Aura::HandleAuraModCritPercent(bool apply, bool Real) |
---|
| 4692 | { |
---|
| 4693 | if(m_target->GetTypeId()!=TYPEID_PLAYER) |
---|
| 4694 | return; |
---|
| 4695 | |
---|
| 4696 | // apply item specific bonuses for already equipped weapon |
---|
| 4697 | if(Real) |
---|
| 4698 | { |
---|
| 4699 | for(int i = 0; i < MAX_ATTACK; ++i) |
---|
| 4700 | if(Item* pItem = ((Player*)m_target)->GetWeaponForAttack(WeaponAttackType(i))) |
---|
| 4701 | ((Player*)m_target)->_ApplyWeaponDependentAuraCritMod(pItem,WeaponAttackType(i),this,apply); |
---|
| 4702 | } |
---|
| 4703 | |
---|
| 4704 | // mods must be applied base at equipped weapon class and subclass comparison |
---|
| 4705 | // with spell->EquippedItemClass and EquippedItemSubClassMask and EquippedItemInventoryTypeMask |
---|
| 4706 | // m_modifier.m_miscvalue comparison with item generated damage types |
---|
| 4707 | |
---|
| 4708 | if (GetSpellProto()->EquippedItemClass == -1) |
---|
| 4709 | { |
---|
| 4710 | ((Player*)m_target)->HandleBaseModValue(CRIT_PERCENTAGE, FLAT_MOD, float (m_modifier.m_amount), apply); |
---|
| 4711 | ((Player*)m_target)->HandleBaseModValue(OFFHAND_CRIT_PERCENTAGE, FLAT_MOD, float (m_modifier.m_amount), apply); |
---|
| 4712 | ((Player*)m_target)->HandleBaseModValue(RANGED_CRIT_PERCENTAGE, FLAT_MOD, float (m_modifier.m_amount), apply); |
---|
| 4713 | } |
---|
| 4714 | else |
---|
| 4715 | { |
---|
| 4716 | // done in Player::_ApplyWeaponDependentAuraMods |
---|
| 4717 | } |
---|
| 4718 | } |
---|
| 4719 | |
---|
| 4720 | void Aura::HandleModHitChance(bool apply, bool Real) |
---|
| 4721 | { |
---|
| 4722 | m_target->m_modMeleeHitChance += apply ? m_modifier.m_amount : (-m_modifier.m_amount); |
---|
| 4723 | m_target->m_modRangedHitChance += apply ? m_modifier.m_amount : (-m_modifier.m_amount); |
---|
| 4724 | } |
---|
| 4725 | |
---|
| 4726 | void Aura::HandleModSpellHitChance(bool apply, bool Real) |
---|
| 4727 | { |
---|
| 4728 | m_target->m_modSpellHitChance += apply ? m_modifier.m_amount: (-m_modifier.m_amount); |
---|
| 4729 | } |
---|
| 4730 | |
---|
| 4731 | void Aura::HandleModSpellCritChance(bool apply, bool Real) |
---|
| 4732 | { |
---|
| 4733 | // spells required only Real aura add/remove |
---|
| 4734 | if(!Real) |
---|
| 4735 | return; |
---|
| 4736 | |
---|
| 4737 | if(m_target->GetTypeId() == TYPEID_PLAYER) |
---|
| 4738 | { |
---|
| 4739 | ((Player*)m_target)->UpdateAllSpellCritChances(); |
---|
| 4740 | } |
---|
| 4741 | else |
---|
| 4742 | { |
---|
| 4743 | m_target->m_baseSpellCritChance += apply ? m_modifier.m_amount:(-m_modifier.m_amount); |
---|
| 4744 | } |
---|
| 4745 | } |
---|
| 4746 | |
---|
| 4747 | void Aura::HandleModSpellCritChanceShool(bool apply, bool Real) |
---|
| 4748 | { |
---|
| 4749 | // spells required only Real aura add/remove |
---|
| 4750 | if(!Real) |
---|
| 4751 | return; |
---|
| 4752 | |
---|
| 4753 | if(m_target->GetTypeId() != TYPEID_PLAYER) |
---|
| 4754 | return; |
---|
| 4755 | |
---|
| 4756 | for(int school = SPELL_SCHOOL_NORMAL; school < MAX_SPELL_SCHOOL; ++school) |
---|
| 4757 | if (m_modifier.m_miscvalue & (1<<school)) |
---|
| 4758 | ((Player*)m_target)->UpdateSpellCritChance(school); |
---|
| 4759 | } |
---|
| 4760 | |
---|
| 4761 | /********************************/ |
---|
| 4762 | /*** ATTACK SPEED ***/ |
---|
| 4763 | /********************************/ |
---|
| 4764 | |
---|
| 4765 | void Aura::HandleModCastingSpeed(bool apply, bool Real) |
---|
| 4766 | { |
---|
| 4767 | m_target->ApplyCastTimePercentMod(m_modifier.m_amount,apply); |
---|
| 4768 | } |
---|
| 4769 | |
---|
| 4770 | void Aura::HandleModMeleeRangedSpeedPct(bool apply, bool Real) |
---|
| 4771 | { |
---|
| 4772 | m_target->ApplyAttackTimePercentMod(BASE_ATTACK,m_modifier.m_amount,apply); |
---|
| 4773 | m_target->ApplyAttackTimePercentMod(OFF_ATTACK,m_modifier.m_amount,apply); |
---|
| 4774 | m_target->ApplyAttackTimePercentMod(RANGED_ATTACK, m_modifier.m_amount, apply); |
---|
| 4775 | } |
---|
| 4776 | |
---|
| 4777 | void Aura::HandleModCombatSpeedPct(bool apply, bool Real) |
---|
| 4778 | { |
---|
| 4779 | m_target->ApplyCastTimePercentMod(m_modifier.m_amount,apply); |
---|
| 4780 | m_target->ApplyAttackTimePercentMod(BASE_ATTACK,m_modifier.m_amount,apply); |
---|
| 4781 | m_target->ApplyAttackTimePercentMod(OFF_ATTACK,m_modifier.m_amount,apply); |
---|
| 4782 | m_target->ApplyAttackTimePercentMod(RANGED_ATTACK, m_modifier.m_amount, apply); |
---|
| 4783 | } |
---|
| 4784 | |
---|
| 4785 | void Aura::HandleModAttackSpeed(bool apply, bool Real) |
---|
| 4786 | { |
---|
| 4787 | if(!m_target->isAlive() ) |
---|
| 4788 | return; |
---|
| 4789 | |
---|
| 4790 | m_target->ApplyAttackTimePercentMod(BASE_ATTACK,m_modifier.m_amount,apply); |
---|
| 4791 | } |
---|
| 4792 | |
---|
| 4793 | void Aura::HandleHaste(bool apply, bool Real) |
---|
| 4794 | { |
---|
| 4795 | m_target->ApplyAttackTimePercentMod(BASE_ATTACK, m_modifier.m_amount,apply); |
---|
| 4796 | m_target->ApplyAttackTimePercentMod(OFF_ATTACK, m_modifier.m_amount,apply); |
---|
| 4797 | m_target->ApplyAttackTimePercentMod(RANGED_ATTACK,m_modifier.m_amount,apply); |
---|
| 4798 | } |
---|
| 4799 | |
---|
| 4800 | void Aura::HandleAuraModRangedHaste(bool apply, bool Real) |
---|
| 4801 | { |
---|
| 4802 | m_target->ApplyAttackTimePercentMod(RANGED_ATTACK, m_modifier.m_amount, apply); |
---|
| 4803 | } |
---|
| 4804 | |
---|
| 4805 | void Aura::HandleRangedAmmoHaste(bool apply, bool Real) |
---|
| 4806 | { |
---|
| 4807 | if(m_target->GetTypeId() != TYPEID_PLAYER) |
---|
| 4808 | return; |
---|
| 4809 | m_target->ApplyAttackTimePercentMod(RANGED_ATTACK,m_modifier.m_amount, apply); |
---|
| 4810 | } |
---|
| 4811 | |
---|
| 4812 | /********************************/ |
---|
| 4813 | /*** ATTACK POWER ***/ |
---|
| 4814 | /********************************/ |
---|
| 4815 | |
---|
| 4816 | void Aura::HandleAuraModAttackPower(bool apply, bool Real) |
---|
| 4817 | { |
---|
| 4818 | m_target->HandleStatModifier(UNIT_MOD_ATTACK_POWER, TOTAL_VALUE, float(m_modifier.m_amount), apply); |
---|
| 4819 | } |
---|
| 4820 | |
---|
| 4821 | void Aura::HandleAuraModRangedAttackPower(bool apply, bool Real) |
---|
| 4822 | { |
---|
| 4823 | if((m_target->getClassMask() & CLASSMASK_WAND_USERS)!=0) |
---|
| 4824 | return; |
---|
| 4825 | |
---|
| 4826 | m_target->HandleStatModifier(UNIT_MOD_ATTACK_POWER_RANGED, TOTAL_VALUE, float(m_modifier.m_amount), apply); |
---|
| 4827 | } |
---|
| 4828 | |
---|
| 4829 | void Aura::HandleAuraAttackPowerAttacker(bool apply, bool Real) |
---|
| 4830 | { |
---|
| 4831 | // spells required only Real aura add/remove |
---|
| 4832 | if(!Real) |
---|
| 4833 | return; |
---|
| 4834 | Unit *caster = GetCaster(); |
---|
| 4835 | |
---|
| 4836 | if (!caster) |
---|
| 4837 | return; |
---|
| 4838 | |
---|
| 4839 | // Hunter's Mark |
---|
| 4840 | if (m_spellProto->SpellFamilyName == SPELLFAMILY_HUNTER && m_spellProto->SpellFamilyFlags & 0x0000000000000400LL) |
---|
| 4841 | { |
---|
| 4842 | // Check Improved Hunter's Mark bonus on caster |
---|
| 4843 | Unit::AuraList const& mOverrideClassScript = caster->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); |
---|
| 4844 | for(Unit::AuraList::const_iterator i = mOverrideClassScript.begin(); i != mOverrideClassScript.end(); ++i) |
---|
| 4845 | { |
---|
| 4846 | Modifier* mod = (*i)->GetModifier(); |
---|
| 4847 | // mproved Hunter's Mark script from 5236 to 5240 |
---|
| 4848 | if (mod->m_miscvalue >= 5236 && mod->m_miscvalue <= 5240) |
---|
| 4849 | { |
---|
| 4850 | // Get amount of ranged bonus for this spell.. |
---|
| 4851 | int32 ranged_bonus = caster->CalculateSpellDamage(m_spellProto, 1, m_spellProto->EffectBasePoints[1], m_target); |
---|
| 4852 | // Set melee attack power bonus % from ranged depends from Improved mask aura |
---|
| 4853 | m_modifier.m_amount = mod->m_amount * ranged_bonus / 100; |
---|
| 4854 | m_currentBasePoints = m_modifier.m_amount; |
---|
| 4855 | break; |
---|
| 4856 | } |
---|
| 4857 | } |
---|
| 4858 | return; |
---|
| 4859 | } |
---|
| 4860 | } |
---|
| 4861 | |
---|
| 4862 | void Aura::HandleAuraModAttackPowerPercent(bool apply, bool Real) |
---|
| 4863 | { |
---|
| 4864 | //UNIT_FIELD_ATTACK_POWER_MULTIPLIER = multiplier - 1 |
---|
| 4865 | m_target->HandleStatModifier(UNIT_MOD_ATTACK_POWER, TOTAL_PCT, float(m_modifier.m_amount), apply); |
---|
| 4866 | } |
---|
| 4867 | |
---|
| 4868 | void Aura::HandleAuraModRangedAttackPowerPercent(bool apply, bool Real) |
---|
| 4869 | { |
---|
| 4870 | if((m_target->getClassMask() & CLASSMASK_WAND_USERS)!=0) |
---|
| 4871 | return; |
---|
| 4872 | |
---|
| 4873 | //UNIT_FIELD_RANGED_ATTACK_POWER_MULTIPLIER = multiplier - 1 |
---|
| 4874 | m_target->HandleStatModifier(UNIT_MOD_ATTACK_POWER_RANGED, TOTAL_PCT, float(m_modifier.m_amount), apply); |
---|
| 4875 | } |
---|
| 4876 | |
---|
| 4877 | void Aura::HandleAuraModRangedAttackPowerOfStatPercent(bool apply, bool Real) |
---|
| 4878 | { |
---|
| 4879 | // spells required only Real aura add/remove |
---|
| 4880 | if(!Real) |
---|
| 4881 | return; |
---|
| 4882 | |
---|
| 4883 | if(m_target->GetTypeId() == TYPEID_PLAYER && (m_target->getClassMask() & CLASSMASK_WAND_USERS)!=0) |
---|
| 4884 | return; |
---|
| 4885 | |
---|
| 4886 | if(m_modifier.m_miscvalue != STAT_INTELLECT) |
---|
| 4887 | { |
---|
| 4888 | // support required adding UpdateAttackPowerAndDamage calls at stat update |
---|
| 4889 | sLog.outError("Aura SPELL_AURA_MOD_RANGED_ATTACK_POWER_OF_STAT_PERCENT (212) need support non-intelect stats!"); |
---|
| 4890 | return; |
---|
| 4891 | } |
---|
| 4892 | |
---|
| 4893 | // Recalculate bonus |
---|
| 4894 | ((Player*)m_target)->UpdateAttackPowerAndDamage(true); |
---|
| 4895 | } |
---|
| 4896 | |
---|
| 4897 | /********************************/ |
---|
| 4898 | /*** DAMAGE BONUS ***/ |
---|
| 4899 | /********************************/ |
---|
| 4900 | void Aura::HandleModDamageDone(bool apply, bool Real) |
---|
| 4901 | { |
---|
| 4902 | // apply item specific bonuses for already equipped weapon |
---|
| 4903 | if(Real && m_target->GetTypeId()==TYPEID_PLAYER) |
---|
| 4904 | { |
---|
| 4905 | for(int i = 0; i < MAX_ATTACK; ++i) |
---|
| 4906 | if(Item* pItem = ((Player*)m_target)->GetWeaponForAttack(WeaponAttackType(i))) |
---|
| 4907 | ((Player*)m_target)->_ApplyWeaponDependentAuraDamageMod(pItem,WeaponAttackType(i),this,apply); |
---|
| 4908 | } |
---|
| 4909 | |
---|
| 4910 | // m_modifier.m_miscvalue is bitmask of spell schools |
---|
| 4911 | // 1 ( 0-bit ) - normal school damage (SPELL_SCHOOL_MASK_NORMAL) |
---|
| 4912 | // 126 - full bitmask all magic damages (SPELL_SCHOOL_MASK_MAGIC) including wands |
---|
| 4913 | // 127 - full bitmask any damages |
---|
| 4914 | // |
---|
| 4915 | // mods must be applied base at equipped weapon class and subclass comparison |
---|
| 4916 | // with spell->EquippedItemClass and EquippedItemSubClassMask and EquippedItemInventoryTypeMask |
---|
| 4917 | // m_modifier.m_miscvalue comparison with item generated damage types |
---|
| 4918 | |
---|
| 4919 | if((m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_NORMAL) != 0) |
---|
| 4920 | { |
---|
| 4921 | // apply generic physical damage bonuses including wand case |
---|
| 4922 | if (GetSpellProto()->EquippedItemClass == -1 || m_target->GetTypeId() != TYPEID_PLAYER) |
---|
| 4923 | { |
---|
| 4924 | m_target->HandleStatModifier(UNIT_MOD_DAMAGE_MAINHAND, TOTAL_VALUE, float(m_modifier.m_amount), apply); |
---|
| 4925 | m_target->HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND, TOTAL_VALUE, float(m_modifier.m_amount), apply); |
---|
| 4926 | m_target->HandleStatModifier(UNIT_MOD_DAMAGE_RANGED, TOTAL_VALUE, float(m_modifier.m_amount), apply); |
---|
| 4927 | } |
---|
| 4928 | else |
---|
| 4929 | { |
---|
| 4930 | // done in Player::_ApplyWeaponDependentAuraMods |
---|
| 4931 | } |
---|
| 4932 | |
---|
| 4933 | if(m_target->GetTypeId() == TYPEID_PLAYER) |
---|
| 4934 | { |
---|
| 4935 | if(m_positive) |
---|
| 4936 | m_target->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS,m_modifier.m_amount,apply); |
---|
| 4937 | else |
---|
| 4938 | m_target->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG,m_modifier.m_amount,apply); |
---|
| 4939 | } |
---|
| 4940 | } |
---|
| 4941 | |
---|
| 4942 | // Skip non magic case for speedup |
---|
| 4943 | if((m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_MAGIC) == 0) |
---|
| 4944 | return; |
---|
| 4945 | |
---|
| 4946 | if( GetSpellProto()->EquippedItemClass != -1 || GetSpellProto()->EquippedItemInventoryTypeMask != 0 ) |
---|
| 4947 | { |
---|
| 4948 | // wand magic case (skip generic to all item spell bonuses) |
---|
| 4949 | // done in Player::_ApplyWeaponDependentAuraMods |
---|
| 4950 | |
---|
| 4951 | // Skip item specific requirements for not wand magic damage |
---|
| 4952 | return; |
---|
| 4953 | } |
---|
| 4954 | |
---|
| 4955 | // Magic damage modifiers implemented in Unit::SpellDamageBonus |
---|
| 4956 | // This information for client side use only |
---|
| 4957 | if(m_target->GetTypeId() == TYPEID_PLAYER) |
---|
| 4958 | { |
---|
| 4959 | if(m_positive) |
---|
| 4960 | { |
---|
| 4961 | for(int i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; i++) |
---|
| 4962 | { |
---|
| 4963 | if((m_modifier.m_miscvalue & (1<<i)) != 0) |
---|
| 4964 | m_target->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS+i,m_modifier.m_amount,apply); |
---|
| 4965 | } |
---|
| 4966 | } |
---|
| 4967 | else |
---|
| 4968 | { |
---|
| 4969 | for(int i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; i++) |
---|
| 4970 | { |
---|
| 4971 | if((m_modifier.m_miscvalue & (1<<i)) != 0) |
---|
| 4972 | m_target->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG+i,m_modifier.m_amount,apply); |
---|
| 4973 | } |
---|
| 4974 | } |
---|
| 4975 | Pet* pet = m_target->GetPet(); |
---|
| 4976 | if(pet) |
---|
| 4977 | pet->UpdateAttackPowerAndDamage(); |
---|
| 4978 | } |
---|
| 4979 | } |
---|
| 4980 | |
---|
| 4981 | void Aura::HandleModDamagePercentDone(bool apply, bool Real) |
---|
| 4982 | { |
---|
| 4983 | sLog.outDebug("AURA MOD DAMAGE type:%u negative:%u", m_modifier.m_miscvalue, m_positive ? 0 : 1); |
---|
| 4984 | |
---|
| 4985 | // apply item specific bonuses for already equipped weapon |
---|
| 4986 | if(Real && m_target->GetTypeId()==TYPEID_PLAYER) |
---|
| 4987 | { |
---|
| 4988 | for(int i = 0; i < MAX_ATTACK; ++i) |
---|
| 4989 | if(Item* pItem = ((Player*)m_target)->GetWeaponForAttack(WeaponAttackType(i))) |
---|
| 4990 | ((Player*)m_target)->_ApplyWeaponDependentAuraDamageMod(pItem,WeaponAttackType(i),this,apply); |
---|
| 4991 | } |
---|
| 4992 | |
---|
| 4993 | // m_modifier.m_miscvalue is bitmask of spell schools |
---|
| 4994 | // 1 ( 0-bit ) - normal school damage (SPELL_SCHOOL_MASK_NORMAL) |
---|
| 4995 | // 126 - full bitmask all magic damages (SPELL_SCHOOL_MASK_MAGIC) including wand |
---|
| 4996 | // 127 - full bitmask any damages |
---|
| 4997 | // |
---|
| 4998 | // mods must be applied base at equipped weapon class and subclass comparison |
---|
| 4999 | // with spell->EquippedItemClass and EquippedItemSubClassMask and EquippedItemInventoryTypeMask |
---|
| 5000 | // m_modifier.m_miscvalue comparison with item generated damage types |
---|
| 5001 | |
---|
| 5002 | if((m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_NORMAL) != 0) |
---|
| 5003 | { |
---|
| 5004 | // apply generic physical damage bonuses including wand case |
---|
| 5005 | if (GetSpellProto()->EquippedItemClass == -1 || m_target->GetTypeId() != TYPEID_PLAYER) |
---|
| 5006 | { |
---|
| 5007 | m_target->HandleStatModifier(UNIT_MOD_DAMAGE_MAINHAND, TOTAL_PCT, float(m_modifier.m_amount), apply); |
---|
| 5008 | m_target->HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND, TOTAL_PCT, float(m_modifier.m_amount), apply); |
---|
| 5009 | m_target->HandleStatModifier(UNIT_MOD_DAMAGE_RANGED, TOTAL_PCT, float(m_modifier.m_amount), apply); |
---|
| 5010 | } |
---|
| 5011 | else |
---|
| 5012 | { |
---|
| 5013 | // done in Player::_ApplyWeaponDependentAuraMods |
---|
| 5014 | } |
---|
| 5015 | // For show in client |
---|
| 5016 | if(m_target->GetTypeId() == TYPEID_PLAYER) |
---|
| 5017 | m_target->ApplyModSignedFloatValue(PLAYER_FIELD_MOD_DAMAGE_DONE_PCT,m_modifier.m_amount/100.0f,apply); |
---|
| 5018 | } |
---|
| 5019 | |
---|
| 5020 | // Skip non magic case for speedup |
---|
| 5021 | if((m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_MAGIC) == 0) |
---|
| 5022 | return; |
---|
| 5023 | |
---|
| 5024 | if( GetSpellProto()->EquippedItemClass != -1 || GetSpellProto()->EquippedItemInventoryTypeMask != 0 ) |
---|
| 5025 | { |
---|
| 5026 | // wand magic case (skip generic to all item spell bonuses) |
---|
| 5027 | // done in Player::_ApplyWeaponDependentAuraMods |
---|
| 5028 | |
---|
| 5029 | // Skip item specific requirements for not wand magic damage |
---|
| 5030 | return; |
---|
| 5031 | } |
---|
| 5032 | |
---|
| 5033 | // Magic damage percent modifiers implemented in Unit::SpellDamageBonus |
---|
| 5034 | // Send info to client |
---|
| 5035 | if(m_target->GetTypeId() == TYPEID_PLAYER) |
---|
| 5036 | for(int i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i) |
---|
| 5037 | m_target->ApplyModSignedFloatValue(PLAYER_FIELD_MOD_DAMAGE_DONE_PCT+i,m_modifier.m_amount/100.0f,apply); |
---|
| 5038 | } |
---|
| 5039 | |
---|
| 5040 | void Aura::HandleModOffhandDamagePercent(bool apply, bool Real) |
---|
| 5041 | { |
---|
| 5042 | // spells required only Real aura add/remove |
---|
| 5043 | if(!Real) |
---|
| 5044 | return; |
---|
| 5045 | |
---|
| 5046 | sLog.outDebug("AURA MOD OFFHAND DAMAGE"); |
---|
| 5047 | |
---|
| 5048 | m_target->HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND, TOTAL_PCT, float(m_modifier.m_amount), apply); |
---|
| 5049 | } |
---|
| 5050 | |
---|
| 5051 | /********************************/ |
---|
| 5052 | /*** POWER COST ***/ |
---|
| 5053 | /********************************/ |
---|
| 5054 | |
---|
| 5055 | void Aura::HandleModPowerCostPCT(bool apply, bool Real) |
---|
| 5056 | { |
---|
| 5057 | // spells required only Real aura add/remove |
---|
| 5058 | if(!Real) |
---|
| 5059 | return; |
---|
| 5060 | |
---|
| 5061 | float amount = m_modifier.m_amount/100.0f; |
---|
| 5062 | for(int i = 0; i < MAX_SPELL_SCHOOL; ++i) |
---|
| 5063 | if(m_modifier.m_miscvalue & (1<<i)) |
---|
| 5064 | m_target->ApplyModSignedFloatValue(UNIT_FIELD_POWER_COST_MULTIPLIER+i,amount,apply); |
---|
| 5065 | } |
---|
| 5066 | |
---|
| 5067 | void Aura::HandleModPowerCost(bool apply, bool Real) |
---|
| 5068 | { |
---|
| 5069 | // spells required only Real aura add/remove |
---|
| 5070 | if(!Real) |
---|
| 5071 | return; |
---|
| 5072 | |
---|
| 5073 | for(int i = 0; i < MAX_SPELL_SCHOOL; ++i) |
---|
| 5074 | if(m_modifier.m_miscvalue & (1<<i)) |
---|
| 5075 | m_target->ApplyModInt32Value(UNIT_FIELD_POWER_COST_MODIFIER+i,m_modifier.m_amount,apply); |
---|
| 5076 | } |
---|
| 5077 | |
---|
| 5078 | /*********************************************************/ |
---|
| 5079 | /*** OTHERS ***/ |
---|
| 5080 | /*********************************************************/ |
---|
| 5081 | |
---|
| 5082 | void Aura::HandleShapeshiftBoosts(bool apply) |
---|
| 5083 | { |
---|
| 5084 | uint32 spellId = 0; |
---|
| 5085 | uint32 spellId2 = 0; |
---|
| 5086 | uint32 HotWSpellId = 0; |
---|
| 5087 | |
---|
| 5088 | switch(GetModifier()->m_miscvalue) |
---|
| 5089 | { |
---|
| 5090 | case FORM_CAT: |
---|
| 5091 | spellId = 3025; |
---|
| 5092 | HotWSpellId = 24900; |
---|
| 5093 | break; |
---|
| 5094 | case FORM_TREE: |
---|
| 5095 | spellId = 5420; |
---|
| 5096 | break; |
---|
| 5097 | case FORM_TRAVEL: |
---|
| 5098 | spellId = 5419; |
---|
| 5099 | break; |
---|
| 5100 | case FORM_AQUA: |
---|
| 5101 | spellId = 5421; |
---|
| 5102 | break; |
---|
| 5103 | case FORM_BEAR: |
---|
| 5104 | spellId = 1178; |
---|
| 5105 | spellId2 = 21178; |
---|
| 5106 | HotWSpellId = 24899; |
---|
| 5107 | break; |
---|
| 5108 | case FORM_DIREBEAR: |
---|
| 5109 | spellId = 9635; |
---|
| 5110 | spellId2 = 21178; |
---|
| 5111 | HotWSpellId = 24899; |
---|
| 5112 | break; |
---|
| 5113 | case FORM_BATTLESTANCE: |
---|
| 5114 | spellId = 21156; |
---|
| 5115 | break; |
---|
| 5116 | case FORM_DEFENSIVESTANCE: |
---|
| 5117 | spellId = 7376; |
---|
| 5118 | break; |
---|
| 5119 | case FORM_BERSERKERSTANCE: |
---|
| 5120 | spellId = 7381; |
---|
| 5121 | break; |
---|
| 5122 | case FORM_MOONKIN: |
---|
| 5123 | spellId = 24905; |
---|
| 5124 | // aura from effect trigger spell |
---|
| 5125 | spellId2 = 24907; |
---|
| 5126 | break; |
---|
| 5127 | case FORM_FLIGHT: |
---|
| 5128 | spellId = 33948; |
---|
| 5129 | break; |
---|
| 5130 | case FORM_FLIGHT_EPIC: |
---|
| 5131 | spellId = 40122; |
---|
| 5132 | spellId2 = 40121; |
---|
| 5133 | break; |
---|
| 5134 | case FORM_SPIRITOFREDEMPTION: |
---|
| 5135 | spellId = 27792; |
---|
| 5136 | spellId2 = 27795; // must be second, this important at aura remove to prevent to early iterator invalidation. |
---|
| 5137 | break; |
---|
| 5138 | case FORM_GHOSTWOLF: |
---|
| 5139 | case FORM_AMBIENT: |
---|
| 5140 | case FORM_GHOUL: |
---|
| 5141 | case FORM_SHADOW: |
---|
| 5142 | case FORM_STEALTH: |
---|
| 5143 | case FORM_CREATURECAT: |
---|
| 5144 | case FORM_CREATUREBEAR: |
---|
| 5145 | spellId = 0; |
---|
| 5146 | break; |
---|
| 5147 | } |
---|
| 5148 | |
---|
| 5149 | uint32 form = GetModifier()->m_miscvalue-1; |
---|
| 5150 | |
---|
| 5151 | if(apply) |
---|
| 5152 | { |
---|
| 5153 | if (spellId) m_target->CastSpell(m_target, spellId, true, NULL, this ); |
---|
| 5154 | if (spellId2) m_target->CastSpell(m_target, spellId2, true, NULL, this); |
---|
| 5155 | |
---|
| 5156 | if(m_target->GetTypeId() == TYPEID_PLAYER) |
---|
| 5157 | { |
---|
| 5158 | const PlayerSpellMap& sp_list = ((Player *)m_target)->GetSpellMap(); |
---|
| 5159 | for (PlayerSpellMap::const_iterator itr = sp_list.begin(); itr != sp_list.end(); ++itr) |
---|
| 5160 | { |
---|
| 5161 | if(itr->second->state == PLAYERSPELL_REMOVED) continue; |
---|
| 5162 | if(itr->first==spellId || itr->first==spellId2) continue; |
---|
| 5163 | SpellEntry const *spellInfo = sSpellStore.LookupEntry(itr->first); |
---|
| 5164 | if (!spellInfo || !(spellInfo->Attributes & ((1<<6) | (1<<7)))) continue; |
---|
| 5165 | if (spellInfo->Stances & (1<<form)) |
---|
| 5166 | m_target->CastSpell(m_target, itr->first, true, NULL, this); |
---|
| 5167 | } |
---|
| 5168 | //LotP |
---|
| 5169 | if (((Player*)m_target)->HasSpell(17007)) |
---|
| 5170 | { |
---|
| 5171 | SpellEntry const *spellInfo = sSpellStore.LookupEntry(24932); |
---|
| 5172 | if (spellInfo && spellInfo->Stances & (1<<form)) |
---|
| 5173 | m_target->CastSpell(m_target, 24932, true, NULL, this); |
---|
| 5174 | } |
---|
| 5175 | // HotW |
---|
| 5176 | if (HotWSpellId) |
---|
| 5177 | { |
---|
| 5178 | Unit::AuraList const& mModTotalStatPct = m_target->GetAurasByType(SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE); |
---|
| 5179 | for(Unit::AuraList::const_iterator i = mModTotalStatPct.begin(); i != mModTotalStatPct.end(); ++i) |
---|
| 5180 | { |
---|
| 5181 | if ((*i)->GetSpellProto()->SpellIconID == 240 && (*i)->GetModifier()->m_miscvalue == 3) |
---|
| 5182 | { |
---|
| 5183 | int32 HotWMod = (*i)->GetModifier()->m_amount; |
---|
| 5184 | if(GetModifier()->m_miscvalue == FORM_CAT) |
---|
| 5185 | HotWMod /= 2; |
---|
| 5186 | |
---|
| 5187 | m_target->CastCustomSpell(m_target, HotWSpellId, &HotWMod, NULL, NULL, true, NULL, this); |
---|
| 5188 | break; |
---|
| 5189 | } |
---|
| 5190 | } |
---|
| 5191 | } |
---|
| 5192 | } |
---|
| 5193 | } |
---|
| 5194 | else |
---|
| 5195 | { |
---|
| 5196 | m_target->RemoveAurasDueToSpell(spellId); |
---|
| 5197 | m_target->RemoveAurasDueToSpell(spellId2); |
---|
| 5198 | |
---|
| 5199 | Unit::AuraMap& tAuras = m_target->GetAuras(); |
---|
| 5200 | for (Unit::AuraMap::iterator itr = tAuras.begin(); itr != tAuras.end();) |
---|
| 5201 | { |
---|
| 5202 | if (itr->second->IsRemovedOnShapeLost()) |
---|
| 5203 | { |
---|
| 5204 | m_target->RemoveAurasDueToSpell(itr->second->GetId()); |
---|
| 5205 | itr = tAuras.begin(); |
---|
| 5206 | } |
---|
| 5207 | else |
---|
| 5208 | { |
---|
| 5209 | ++itr; |
---|
| 5210 | } |
---|
| 5211 | } |
---|
| 5212 | } |
---|
| 5213 | |
---|
| 5214 | /*double healthPercentage = (double)m_target->GetHealth() / (double)m_target->GetMaxHealth(); |
---|
| 5215 | m_target->SetHealth(uint32(ceil((double)m_target->GetMaxHealth() * healthPercentage)));*/ |
---|
| 5216 | } |
---|
| 5217 | |
---|
| 5218 | void Aura::HandleAuraEmpathy(bool apply, bool Real) |
---|
| 5219 | { |
---|
| 5220 | if(m_target->GetTypeId() != TYPEID_UNIT) |
---|
| 5221 | return; |
---|
| 5222 | |
---|
| 5223 | CreatureInfo const * ci = objmgr.GetCreatureTemplate(m_target->GetEntry()); |
---|
| 5224 | if(ci && ci->type == CREATURE_TYPE_BEAST) |
---|
| 5225 | m_target->ApplyModUInt32Value(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_SPECIALINFO, apply); |
---|
| 5226 | } |
---|
| 5227 | |
---|
| 5228 | void Aura::HandleAuraUntrackable(bool apply, bool Real) |
---|
| 5229 | { |
---|
| 5230 | if(apply) |
---|
| 5231 | m_target->SetFlag(UNIT_FIELD_BYTES_1, PLAYER_STATE_FLAG_UNTRACKABLE); |
---|
| 5232 | else |
---|
| 5233 | m_target->RemoveFlag(UNIT_FIELD_BYTES_1, PLAYER_STATE_FLAG_UNTRACKABLE); |
---|
| 5234 | } |
---|
| 5235 | |
---|
| 5236 | void Aura::HandleAuraModPacify(bool apply, bool Real) |
---|
| 5237 | { |
---|
| 5238 | if(m_target->GetTypeId() != TYPEID_PLAYER) |
---|
| 5239 | return; |
---|
| 5240 | |
---|
| 5241 | if(apply) |
---|
| 5242 | m_target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED); |
---|
| 5243 | else |
---|
| 5244 | m_target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED); |
---|
| 5245 | } |
---|
| 5246 | |
---|
| 5247 | void Aura::HandleAuraModPacifyAndSilence(bool apply, bool Real) |
---|
| 5248 | { |
---|
| 5249 | HandleAuraModPacify(apply,Real); |
---|
| 5250 | HandleAuraModSilence(apply,Real); |
---|
| 5251 | } |
---|
| 5252 | |
---|
| 5253 | void Aura::HandleAuraGhost(bool apply, bool Real) |
---|
| 5254 | { |
---|
| 5255 | if(m_target->GetTypeId() != TYPEID_PLAYER) |
---|
| 5256 | return; |
---|
| 5257 | |
---|
| 5258 | if(apply) |
---|
| 5259 | { |
---|
| 5260 | m_target->SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST); |
---|
| 5261 | } |
---|
| 5262 | else |
---|
| 5263 | { |
---|
| 5264 | m_target->RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST); |
---|
| 5265 | } |
---|
| 5266 | } |
---|
| 5267 | |
---|
| 5268 | void Aura::HandleAuraAllowFlight(bool apply, bool Real) |
---|
| 5269 | { |
---|
| 5270 | // all applied/removed only at real aura add/remove |
---|
| 5271 | if(!Real) |
---|
| 5272 | return; |
---|
| 5273 | |
---|
| 5274 | // allow fly |
---|
| 5275 | WorldPacket data; |
---|
| 5276 | if(apply) |
---|
| 5277 | data.Initialize(SMSG_MOVE_SET_CAN_FLY, 12); |
---|
| 5278 | else |
---|
| 5279 | data.Initialize(SMSG_MOVE_UNSET_CAN_FLY, 12); |
---|
| 5280 | data.append(m_target->GetPackGUID()); |
---|
| 5281 | data << uint32(0); // unk |
---|
| 5282 | m_target->SendMessageToSet(&data, true); |
---|
| 5283 | } |
---|
| 5284 | |
---|
| 5285 | void Aura::HandleModRating(bool apply, bool Real) |
---|
| 5286 | { |
---|
| 5287 | // spells required only Real aura add/remove |
---|
| 5288 | if(!Real) |
---|
| 5289 | return; |
---|
| 5290 | |
---|
| 5291 | if(m_target->GetTypeId() != TYPEID_PLAYER) |
---|
| 5292 | return; |
---|
| 5293 | |
---|
| 5294 | for (uint32 rating = 0; rating < MAX_COMBAT_RATING; ++rating) |
---|
| 5295 | if (m_modifier.m_miscvalue & (1 << rating)) |
---|
| 5296 | ((Player*)m_target)->ApplyRatingMod(CombatRating(rating), m_modifier.m_amount, apply); |
---|
| 5297 | } |
---|
| 5298 | |
---|
| 5299 | void Aura::HandleForceMoveForward(bool apply, bool Real) |
---|
| 5300 | { |
---|
| 5301 | if(!Real || m_target->GetTypeId() != TYPEID_PLAYER) |
---|
| 5302 | return; |
---|
| 5303 | if(apply) |
---|
| 5304 | m_target->SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FORCE_MOVE); |
---|
| 5305 | else |
---|
| 5306 | m_target->RemoveFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FORCE_MOVE); |
---|
| 5307 | } |
---|
| 5308 | |
---|
| 5309 | void Aura::HandleAuraModExpertise(bool apply, bool Real) |
---|
| 5310 | { |
---|
| 5311 | if(m_target->GetTypeId() != TYPEID_PLAYER) |
---|
| 5312 | return; |
---|
| 5313 | |
---|
| 5314 | ((Player*)m_target)->UpdateExpertise(BASE_ATTACK); |
---|
| 5315 | ((Player*)m_target)->UpdateExpertise(OFF_ATTACK); |
---|
| 5316 | } |
---|
| 5317 | |
---|
| 5318 | void Aura::HandleModTargetResistance(bool apply, bool Real) |
---|
| 5319 | { |
---|
| 5320 | // spells required only Real aura add/remove |
---|
| 5321 | if(!Real) |
---|
| 5322 | return; |
---|
| 5323 | // applied to damage as HandleNoImmediateEffect in Unit::CalcAbsorbResist and Unit::CalcArmorReducedDamage |
---|
| 5324 | |
---|
| 5325 | // show armor penetration |
---|
| 5326 | if (m_target->GetTypeId() == TYPEID_PLAYER && (m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_NORMAL)) |
---|
| 5327 | m_target->ApplyModInt32Value(PLAYER_FIELD_MOD_TARGET_PHYSICAL_RESISTANCE,m_modifier.m_amount, apply); |
---|
| 5328 | |
---|
| 5329 | // show as spell penetration only full spell penetration bonuses (all resistances except armor and holy |
---|
| 5330 | if (m_target->GetTypeId() == TYPEID_PLAYER && (m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_SPELL)==SPELL_SCHOOL_MASK_SPELL) |
---|
| 5331 | m_target->ApplyModInt32Value(PLAYER_FIELD_MOD_TARGET_RESISTANCE,m_modifier.m_amount, apply); |
---|
| 5332 | } |
---|
| 5333 | |
---|
| 5334 | //HandleNoImmediateEffect auras implementation to support new stat system |
---|
| 5335 | void Aura::HandleAuraHealing(bool apply, bool Real) |
---|
| 5336 | { |
---|
| 5337 | //m_target->HandleStatModifier(UNIT_MOD_HEALING, TOTAL_VALUE, float(m_modifier.m_amount), apply); |
---|
| 5338 | } |
---|
| 5339 | |
---|
| 5340 | void Aura::HandleAuraHealingPct(bool apply, bool Real) |
---|
| 5341 | { |
---|
| 5342 | //m_target->HandleStatModifier(UNIT_MOD_HEALING, TOTAL_PCT, float(m_modifier.m_amount), apply); |
---|
| 5343 | } |
---|
| 5344 | |
---|
| 5345 | void Aura::HandleShieldBlockValue(bool apply, bool Real) |
---|
| 5346 | { |
---|
| 5347 | BaseModType modType = FLAT_MOD; |
---|
| 5348 | if(m_modifier.m_auraname == SPELL_AURA_MOD_SHIELD_BLOCKVALUE_PCT) |
---|
| 5349 | modType = PCT_MOD; |
---|
| 5350 | |
---|
| 5351 | if(m_target->GetTypeId() == TYPEID_PLAYER) |
---|
| 5352 | ((Player*)m_target)->HandleBaseModValue(SHIELD_BLOCK_VALUE, modType, float(m_modifier.m_amount), apply); |
---|
| 5353 | } |
---|
| 5354 | |
---|
| 5355 | void Aura::HandleAuraRetainComboPoints(bool apply, bool Real) |
---|
| 5356 | { |
---|
| 5357 | // spells required only Real aura add/remove |
---|
| 5358 | if(!Real) |
---|
| 5359 | return; |
---|
| 5360 | |
---|
| 5361 | if(m_target->GetTypeId() != TYPEID_PLAYER) |
---|
| 5362 | return; |
---|
| 5363 | |
---|
| 5364 | Player *target = (Player*)m_target; |
---|
| 5365 | |
---|
| 5366 | // combo points was added in SPELL_EFFECT_ADD_COMBO_POINTS handler |
---|
| 5367 | // remove only if aura expire by time (in case combo points amount change aura removed without combo points lost) |
---|
| 5368 | if( !apply && m_duration==0 && target->GetComboTarget()) |
---|
| 5369 | if(Unit* unit = ObjectAccessor::GetUnit(*m_target,target->GetComboTarget())) |
---|
| 5370 | target->AddComboPoints(unit, -m_modifier.m_amount); |
---|
| 5371 | } |
---|
| 5372 | |
---|
| 5373 | void Aura::HandleModUnattackable( bool Apply, bool Real ) |
---|
| 5374 | { |
---|
| 5375 | if(Real && Apply) |
---|
| 5376 | m_target->CombatStop(); |
---|
| 5377 | |
---|
| 5378 | m_target->ApplyModFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE,Apply); |
---|
| 5379 | } |
---|
| 5380 | |
---|
| 5381 | void Aura::HandleSpiritOfRedemption( bool apply, bool Real ) |
---|
| 5382 | { |
---|
| 5383 | // spells required only Real aura add/remove |
---|
| 5384 | if(!Real) |
---|
| 5385 | return; |
---|
| 5386 | |
---|
| 5387 | // prepare spirit state |
---|
| 5388 | if(apply) |
---|
| 5389 | { |
---|
| 5390 | if(m_target->GetTypeId()==TYPEID_PLAYER) |
---|
| 5391 | { |
---|
| 5392 | // disable breath/etc timers |
---|
| 5393 | ((Player*)m_target)->StopMirrorTimers(); |
---|
| 5394 | |
---|
| 5395 | // set stand state (expected in this form) |
---|
| 5396 | if(!m_target->IsStandState()) |
---|
| 5397 | m_target->SetStandState(PLAYER_STATE_NONE); |
---|
| 5398 | } |
---|
| 5399 | |
---|
| 5400 | m_target->SetHealth(1); |
---|
| 5401 | } |
---|
| 5402 | // die at aura end |
---|
| 5403 | else |
---|
| 5404 | m_target->DealDamage(m_target, m_target->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, GetSpellProto(), false); |
---|
| 5405 | } |
---|
| 5406 | |
---|
| 5407 | void Aura::CleanupTriggeredSpells() |
---|
| 5408 | { |
---|
| 5409 | uint32 tSpellId = m_spellProto->EffectTriggerSpell[GetEffIndex()]; |
---|
| 5410 | if(!tSpellId) |
---|
| 5411 | return; |
---|
| 5412 | |
---|
| 5413 | SpellEntry const* tProto = sSpellStore.LookupEntry(tSpellId); |
---|
| 5414 | if(!tProto) |
---|
| 5415 | return; |
---|
| 5416 | |
---|
| 5417 | if(GetSpellDuration(tProto) != -1) |
---|
| 5418 | return; |
---|
| 5419 | |
---|
| 5420 | // needed for spell 43680, maybe others |
---|
| 5421 | // TODO: is there a spell flag, which can solve this in a more sophisticated way? |
---|
| 5422 | if(m_spellProto->EffectApplyAuraName[GetEffIndex()] == SPELL_AURA_PERIODIC_TRIGGER_SPELL && |
---|
| 5423 | GetSpellDuration(m_spellProto) == m_spellProto->EffectAmplitude[GetEffIndex()]) |
---|
| 5424 | return; |
---|
| 5425 | m_target->RemoveAurasDueToSpell(tSpellId); |
---|
| 5426 | } |
---|
| 5427 | |
---|
| 5428 | void Aura::HandleAuraPowerBurn(bool apply, bool Real) |
---|
| 5429 | { |
---|
| 5430 | if (m_periodicTimer <= 0) |
---|
| 5431 | m_periodicTimer += m_modifier.periodictime; |
---|
| 5432 | |
---|
| 5433 | m_isPeriodic = apply; |
---|
| 5434 | } |
---|
| 5435 | |
---|
| 5436 | void Aura::HandleSchoolAbsorb(bool apply, bool Real) |
---|
| 5437 | { |
---|
| 5438 | if(!Real) |
---|
| 5439 | return; |
---|
| 5440 | |
---|
| 5441 | // prevent double apply bonuses |
---|
| 5442 | if(apply && (m_target->GetTypeId()!=TYPEID_PLAYER || !((Player*)m_target)->GetSession()->PlayerLoading())) |
---|
| 5443 | { |
---|
| 5444 | if(Unit* caster = GetCaster()) |
---|
| 5445 | { |
---|
| 5446 | float DoneActualBenefit = 0.0f; |
---|
| 5447 | switch(m_spellProto->SpellFamilyName) |
---|
| 5448 | { |
---|
| 5449 | case SPELLFAMILY_PRIEST: |
---|
| 5450 | if(m_spellProto->SpellFamilyFlags == 0x1) //PW:S |
---|
| 5451 | { |
---|
| 5452 | //+30% from +healing bonus |
---|
| 5453 | DoneActualBenefit = caster->SpellBaseHealingBonus(GetSpellSchoolMask(m_spellProto)) * 0.3f; |
---|
| 5454 | break; |
---|
| 5455 | } |
---|
| 5456 | break; |
---|
| 5457 | case SPELLFAMILY_MAGE: |
---|
| 5458 | if(m_spellProto->SpellFamilyFlags == 0x80100 || m_spellProto->SpellFamilyFlags == 0x8 || m_spellProto->SpellFamilyFlags == 0x100000000LL) |
---|
| 5459 | { |
---|
| 5460 | //frost ward, fire ward, ice barrier |
---|
| 5461 | //+10% from +spd bonus |
---|
| 5462 | DoneActualBenefit = caster->SpellBaseDamageBonus(GetSpellSchoolMask(m_spellProto)) * 0.1f; |
---|
| 5463 | break; |
---|
| 5464 | } |
---|
| 5465 | break; |
---|
| 5466 | case SPELLFAMILY_WARLOCK: |
---|
| 5467 | if(m_spellProto->SpellFamilyFlags == 0x00) |
---|
| 5468 | { |
---|
| 5469 | //shadow ward |
---|
| 5470 | //+10% from +spd bonus |
---|
| 5471 | DoneActualBenefit = caster->SpellBaseDamageBonus(GetSpellSchoolMask(m_spellProto)) * 0.1f; |
---|
| 5472 | break; |
---|
| 5473 | } |
---|
| 5474 | break; |
---|
| 5475 | default: |
---|
| 5476 | break; |
---|
| 5477 | } |
---|
| 5478 | |
---|
| 5479 | DoneActualBenefit *= caster->CalculateLevelPenalty(GetSpellProto()); |
---|
| 5480 | |
---|
| 5481 | m_modifier.m_amount += (int32)DoneActualBenefit; |
---|
| 5482 | } |
---|
| 5483 | } |
---|
| 5484 | } |
---|
| 5485 | |
---|
| 5486 | void Aura::PeriodicTick() |
---|
| 5487 | { |
---|
| 5488 | if(!m_target->isAlive()) |
---|
| 5489 | return; |
---|
| 5490 | |
---|
| 5491 | switch(m_modifier.m_auraname) |
---|
| 5492 | { |
---|
| 5493 | case SPELL_AURA_PERIODIC_DAMAGE: |
---|
| 5494 | case SPELL_AURA_PERIODIC_DAMAGE_PERCENT: |
---|
| 5495 | { |
---|
| 5496 | Unit *pCaster = GetCaster(); |
---|
| 5497 | if(!pCaster) |
---|
| 5498 | return; |
---|
| 5499 | |
---|
| 5500 | if( GetSpellProto()->Effect[GetEffIndex()]==SPELL_EFFECT_PERSISTENT_AREA_AURA && |
---|
| 5501 | pCaster->SpellHitResult(m_target,GetSpellProto(),false)!=SPELL_MISS_NONE) |
---|
| 5502 | return; |
---|
| 5503 | |
---|
| 5504 | // Check for immune (not use charges) |
---|
| 5505 | if(m_target->IsImmunedToDamage(GetSpellSchoolMask(GetSpellProto()))) |
---|
| 5506 | return; |
---|
| 5507 | |
---|
| 5508 | // some auras remove at specific health level or more |
---|
| 5509 | if(m_modifier.m_auraname==SPELL_AURA_PERIODIC_DAMAGE) |
---|
| 5510 | { |
---|
| 5511 | switch(GetId()) |
---|
| 5512 | { |
---|
| 5513 | case 43093: case 31956: case 38801: |
---|
| 5514 | case 35321: case 38363: case 39215: |
---|
| 5515 | if(m_target->GetHealth() == m_target->GetMaxHealth() ) |
---|
| 5516 | { |
---|
| 5517 | m_target->RemoveAurasDueToSpell(GetId()); |
---|
| 5518 | return; |
---|
| 5519 | } |
---|
| 5520 | break; |
---|
| 5521 | case 38772: |
---|
| 5522 | { |
---|
| 5523 | uint32 percent = |
---|
| 5524 | GetEffIndex() < 2 && GetSpellProto()->Effect[GetEffIndex()]==SPELL_EFFECT_DUMMY ? |
---|
| 5525 | pCaster->CalculateSpellDamage(GetSpellProto(),GetEffIndex()+1,GetSpellProto()->EffectBasePoints[GetEffIndex()+1],m_target) : |
---|
| 5526 | 100; |
---|
| 5527 | if(m_target->GetHealth()*100 >= m_target->GetMaxHealth()*percent ) |
---|
| 5528 | { |
---|
| 5529 | m_target->RemoveAurasDueToSpell(GetId()); |
---|
| 5530 | return; |
---|
| 5531 | } |
---|
| 5532 | break; |
---|
| 5533 | } |
---|
[57] | 5534 | case 41337:// aura of anger |
---|
| 5535 | { |
---|
| 5536 | Unit::AuraList const& mMod = m_target->GetAurasByType(SPELL_AURA_MOD_DAMAGE_PERCENT_DONE); |
---|
| 5537 | for(Unit::AuraList::const_iterator i = mMod.begin(); i != mMod.end(); ++i) |
---|
| 5538 | { |
---|
| 5539 | if ((*i)->GetId() == 41337) |
---|
| 5540 | { |
---|
| 5541 | (*i)->ApplyModifier(false); |
---|
| 5542 | (*i)->GetModifier()->m_amount += 5; |
---|
| 5543 | (*i)->ApplyModifier(true); |
---|
| 5544 | break; |
---|
| 5545 | } |
---|
| 5546 | } |
---|
| 5547 | m_modifier.m_amount += 100; |
---|
| 5548 | }break; |
---|
[37] | 5549 | default: |
---|
| 5550 | break; |
---|
| 5551 | } |
---|
| 5552 | } |
---|
| 5553 | |
---|
| 5554 | uint32 absorb=0; |
---|
| 5555 | uint32 resist=0; |
---|
| 5556 | CleanDamage cleanDamage = CleanDamage(0, BASE_ATTACK, MELEE_HIT_NORMAL ); |
---|
| 5557 | |
---|
| 5558 | // ignore non positive values (can be result apply spellmods to aura damage |
---|
| 5559 | uint32 amount = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0; |
---|
| 5560 | |
---|
| 5561 | uint32 pdamage; |
---|
| 5562 | |
---|
| 5563 | if(m_modifier.m_auraname == SPELL_AURA_PERIODIC_DAMAGE) |
---|
| 5564 | { |
---|
| 5565 | pdamage = amount; |
---|
| 5566 | |
---|
| 5567 | // Calculate armor mitigation if it is a physical spell |
---|
| 5568 | // But not for bleed mechanic spells |
---|
| 5569 | if ( GetSpellSchoolMask(GetSpellProto()) & SPELL_SCHOOL_MASK_NORMAL && |
---|
| 5570 | GetEffectMechanic(GetSpellProto(), m_effIndex) != MECHANIC_BLEED) |
---|
| 5571 | { |
---|
| 5572 | uint32 pdamageReductedArmor = pCaster->CalcArmorReducedDamage(m_target, pdamage); |
---|
| 5573 | cleanDamage.damage += pdamage - pdamageReductedArmor; |
---|
| 5574 | pdamage = pdamageReductedArmor; |
---|
| 5575 | } |
---|
| 5576 | |
---|
| 5577 | pdamage = pCaster->SpellDamageBonus(m_target,GetSpellProto(),pdamage,DOT); |
---|
| 5578 | |
---|
| 5579 | // Curse of Agony damage-per-tick calculation |
---|
| 5580 | if (GetSpellProto()->SpellFamilyName==SPELLFAMILY_WARLOCK && (GetSpellProto()->SpellFamilyFlags & 0x0000000000000400LL) && GetSpellProto()->SpellIconID==544) |
---|
| 5581 | { |
---|
| 5582 | // 1..4 ticks, 1/2 from normal tick damage |
---|
| 5583 | if (m_duration>=((m_maxduration-m_modifier.periodictime)*2/3)) |
---|
| 5584 | pdamage = pdamage/2; |
---|
| 5585 | // 9..12 ticks, 3/2 from normal tick damage |
---|
| 5586 | else if(m_duration<((m_maxduration-m_modifier.periodictime)/3)) |
---|
| 5587 | pdamage += (pdamage+1)/2; // +1 prevent 0.5 damage possible lost at 1..4 ticks |
---|
| 5588 | // 5..8 ticks have normal tick damage |
---|
| 5589 | } |
---|
| 5590 | } |
---|
| 5591 | else |
---|
| 5592 | pdamage = uint32(m_target->GetMaxHealth()*amount/100); |
---|
| 5593 | |
---|
| 5594 | //As of 2.2 resilience reduces damage from DoT ticks as much as the chance to not be critically hit |
---|
| 5595 | // Reduce dot damage from resilience for players |
---|
| 5596 | if (m_target->GetTypeId()==TYPEID_PLAYER) |
---|
| 5597 | pdamage-=((Player*)m_target)->GetDotDamageReduction(pdamage); |
---|
| 5598 | |
---|
| 5599 | pCaster->CalcAbsorbResist(m_target, GetSpellSchoolMask(GetSpellProto()), DOT, pdamage, &absorb, &resist); |
---|
| 5600 | |
---|
| 5601 | sLog.outDetail("PeriodicTick: %u (TypeId: %u) attacked %u (TypeId: %u) for %u dmg inflicted by %u abs is %u", |
---|
| 5602 | GetCasterGUID(), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target->GetGUIDLow(), m_target->GetTypeId(), pdamage, GetId(),absorb); |
---|
| 5603 | |
---|
| 5604 | WorldPacket data(SMSG_PERIODICAURALOG, (21+16));// we guess size |
---|
| 5605 | data.append(m_target->GetPackGUID()); |
---|
| 5606 | data.appendPackGUID(GetCasterGUID()); |
---|
| 5607 | data << uint32(GetId()); |
---|
| 5608 | data << uint32(1); |
---|
| 5609 | data << uint32(m_modifier.m_auraname); |
---|
| 5610 | data << (uint32)pdamage; |
---|
| 5611 | data << (uint32)GetSpellSchoolMask(GetSpellProto()); // will be mask in 2.4.x |
---|
| 5612 | data << (uint32)absorb; |
---|
| 5613 | data << (uint32)resist; |
---|
| 5614 | m_target->SendMessageToSet(&data,true); |
---|
| 5615 | |
---|
| 5616 | Unit* target = m_target; // aura can be deleted in DealDamage |
---|
| 5617 | SpellEntry const* spellProto = GetSpellProto(); |
---|
| 5618 | |
---|
| 5619 | pCaster->DealDamage(m_target, (pdamage <= absorb+resist) ? 0 : (pdamage-absorb-resist), &cleanDamage, DOT, GetSpellSchoolMask(GetSpellProto()), GetSpellProto(), true); |
---|
| 5620 | |
---|
| 5621 | // DO NOT ACCESS MEMBERS OF THE AURA FROM NOW ON (DealDamage can delete aura) |
---|
| 5622 | |
---|
| 5623 | pCaster->ProcDamageAndSpell(target, PROC_FLAG_HIT_SPELL, PROC_FLAG_TAKE_DAMAGE, (pdamage <= absorb+resist) ? 0 : (pdamage-absorb-resist), GetSpellSchoolMask(spellProto), spellProto); |
---|
| 5624 | break; |
---|
| 5625 | } |
---|
| 5626 | case SPELL_AURA_PERIODIC_LEECH: |
---|
| 5627 | { |
---|
| 5628 | Unit *pCaster = GetCaster(); |
---|
| 5629 | if(!pCaster) |
---|
| 5630 | return; |
---|
| 5631 | |
---|
| 5632 | if(!pCaster->isAlive()) |
---|
| 5633 | return; |
---|
| 5634 | |
---|
| 5635 | if( GetSpellProto()->Effect[GetEffIndex()]==SPELL_EFFECT_PERSISTENT_AREA_AURA && |
---|
| 5636 | pCaster->SpellHitResult(m_target,GetSpellProto(),false)!=SPELL_MISS_NONE) |
---|
| 5637 | return; |
---|
| 5638 | |
---|
| 5639 | // Check for immune (not use charges) |
---|
| 5640 | if(m_target->IsImmunedToDamage(GetSpellSchoolMask(GetSpellProto()))) |
---|
| 5641 | return; |
---|
| 5642 | |
---|
| 5643 | uint32 absorb=0; |
---|
| 5644 | uint32 resist=0; |
---|
| 5645 | CleanDamage cleanDamage = CleanDamage(0, BASE_ATTACK, MELEE_HIT_NORMAL ); |
---|
| 5646 | |
---|
| 5647 | uint32 pdamage = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0; |
---|
| 5648 | |
---|
| 5649 | //Calculate armor mitigation if it is a physical spell |
---|
| 5650 | if (GetSpellSchoolMask(GetSpellProto()) & SPELL_SCHOOL_MASK_NORMAL) |
---|
| 5651 | { |
---|
| 5652 | uint32 pdamageReductedArmor = pCaster->CalcArmorReducedDamage(m_target, pdamage); |
---|
| 5653 | cleanDamage.damage += pdamage - pdamageReductedArmor; |
---|
| 5654 | pdamage = pdamageReductedArmor; |
---|
| 5655 | } |
---|
| 5656 | |
---|
| 5657 | pdamage = pCaster->SpellDamageBonus(m_target,GetSpellProto(),pdamage,DOT); |
---|
| 5658 | |
---|
| 5659 | // talent Soul Siphon add bonus to Drain Life spells |
---|
| 5660 | if( GetSpellProto()->SpellFamilyName == SPELLFAMILY_WARLOCK && (GetSpellProto()->SpellFamilyFlags & 0x8) ) |
---|
| 5661 | { |
---|
| 5662 | // find talent max bonus percentage |
---|
| 5663 | Unit::AuraList const& mClassScriptAuras = pCaster->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); |
---|
| 5664 | for(Unit::AuraList::const_iterator i = mClassScriptAuras.begin(); i != mClassScriptAuras.end(); ++i) |
---|
| 5665 | { |
---|
| 5666 | if ((*i)->GetModifier()->m_miscvalue == 4992 || (*i)->GetModifier()->m_miscvalue == 4993) |
---|
| 5667 | { |
---|
| 5668 | if((*i)->GetEffIndex()!=1) |
---|
| 5669 | { |
---|
| 5670 | sLog.outError("Expected spell %u structure change, need code update",(*i)->GetId()); |
---|
| 5671 | break; |
---|
| 5672 | } |
---|
| 5673 | |
---|
| 5674 | // effect 1 m_amount |
---|
| 5675 | int32 maxPercent = (*i)->GetModifier()->m_amount; |
---|
| 5676 | // effect 0 m_amount |
---|
| 5677 | int32 stepPercent = pCaster->CalculateSpellDamage((*i)->GetSpellProto(),0,(*i)->GetSpellProto()->EffectBasePoints[0],pCaster); |
---|
| 5678 | |
---|
| 5679 | // count affliction effects and calc additional damage in percentage |
---|
| 5680 | int32 modPercent = 0; |
---|
| 5681 | Unit::AuraMap const& victimAuras = m_target->GetAuras(); |
---|
| 5682 | for (Unit::AuraMap::const_iterator itr = victimAuras.begin(); itr != victimAuras.end(); ++itr) |
---|
| 5683 | { |
---|
| 5684 | Aura* aura = itr->second; |
---|
| 5685 | if (aura->IsPositive())continue; |
---|
| 5686 | SpellEntry const* m_spell = aura->GetSpellProto(); |
---|
| 5687 | if (m_spell->SpellFamilyName != SPELLFAMILY_WARLOCK) |
---|
| 5688 | continue; |
---|
| 5689 | |
---|
| 5690 | SkillLineAbilityMap::const_iterator lower = spellmgr.GetBeginSkillLineAbilityMap(m_spell->Id); |
---|
| 5691 | SkillLineAbilityMap::const_iterator upper = spellmgr.GetEndSkillLineAbilityMap(m_spell->Id); |
---|
| 5692 | |
---|
| 5693 | for(SkillLineAbilityMap::const_iterator _spell_idx = lower; _spell_idx != upper; ++_spell_idx) |
---|
| 5694 | { |
---|
| 5695 | if(_spell_idx->second->skillId == SKILL_AFFLICTION) |
---|
| 5696 | { |
---|
| 5697 | modPercent += stepPercent; |
---|
| 5698 | if (modPercent >= maxPercent) |
---|
| 5699 | { |
---|
| 5700 | modPercent = maxPercent; |
---|
| 5701 | break; |
---|
| 5702 | } |
---|
| 5703 | } |
---|
| 5704 | } |
---|
| 5705 | } |
---|
| 5706 | pdamage += (pdamage*modPercent/100); |
---|
| 5707 | break; |
---|
| 5708 | } |
---|
| 5709 | } |
---|
| 5710 | } |
---|
| 5711 | |
---|
| 5712 | //As of 2.2 resilience reduces damage from DoT ticks as much as the chance to not be critically hit |
---|
| 5713 | // Reduce dot damage from resilience for players |
---|
| 5714 | if (m_target->GetTypeId()==TYPEID_PLAYER) |
---|
| 5715 | pdamage-=((Player*)m_target)->GetDotDamageReduction(pdamage); |
---|
| 5716 | |
---|
| 5717 | pCaster->CalcAbsorbResist(m_target, GetSpellSchoolMask(GetSpellProto()), DOT, pdamage, &absorb, &resist); |
---|
| 5718 | |
---|
| 5719 | if(m_target->GetHealth() < pdamage) |
---|
| 5720 | pdamage = uint32(m_target->GetHealth()); |
---|
| 5721 | |
---|
| 5722 | sLog.outDetail("PeriodicTick: %u (TypeId: %u) health leech of %u (TypeId: %u) for %u dmg inflicted by %u abs is %u", |
---|
| 5723 | GetCasterGUID(), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target->GetGUIDLow(), m_target->GetTypeId(), pdamage, GetId(),absorb); |
---|
| 5724 | |
---|
| 5725 | pCaster->SendSpellNonMeleeDamageLog(m_target, GetId(), pdamage, GetSpellSchoolMask(GetSpellProto()), absorb, resist, false, 0); |
---|
| 5726 | |
---|
| 5727 | |
---|
| 5728 | Unit* target = m_target; // aura can be deleted in DealDamage |
---|
| 5729 | SpellEntry const* spellProto = GetSpellProto(); |
---|
| 5730 | float multiplier = spellProto->EffectMultipleValue[GetEffIndex()] > 0 ? spellProto->EffectMultipleValue[GetEffIndex()] : 1; |
---|
| 5731 | |
---|
| 5732 | uint32 new_damage = pCaster->DealDamage(m_target, (pdamage <= absorb+resist) ? 0 : (pdamage-absorb-resist), &cleanDamage, DOT, GetSpellSchoolMask(GetSpellProto()), GetSpellProto(), false); |
---|
| 5733 | |
---|
| 5734 | // DO NOT ACCESS MEMBERS OF THE AURA FROM NOW ON (DealDamage can delete aura) |
---|
| 5735 | |
---|
| 5736 | pCaster->ProcDamageAndSpell(target, PROC_FLAG_HIT_SPELL, PROC_FLAG_TAKE_DAMAGE, new_damage, GetSpellSchoolMask(spellProto), spellProto); |
---|
| 5737 | if (!target->isAlive() && pCaster->IsNonMeleeSpellCasted(false)) |
---|
| 5738 | { |
---|
| 5739 | for (uint32 i = CURRENT_FIRST_NON_MELEE_SPELL; i < CURRENT_MAX_SPELL; i++) |
---|
| 5740 | { |
---|
| 5741 | if (pCaster->m_currentSpells[i] && pCaster->m_currentSpells[i]->m_spellInfo->Id == spellProto->Id) |
---|
| 5742 | pCaster->m_currentSpells[i]->cancel(); |
---|
| 5743 | } |
---|
| 5744 | } |
---|
| 5745 | |
---|
| 5746 | |
---|
| 5747 | if(Player *modOwner = pCaster->GetSpellModOwner()) |
---|
| 5748 | modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_MULTIPLE_VALUE, multiplier); |
---|
| 5749 | |
---|
| 5750 | uint32 heal = pCaster->SpellHealingBonus(spellProto, uint32(new_damage * multiplier), DOT, pCaster); |
---|
| 5751 | |
---|
| 5752 | int32 gain = pCaster->ModifyHealth(heal); |
---|
| 5753 | pCaster->getHostilRefManager().threatAssist(pCaster, gain * 0.5f, spellProto); |
---|
| 5754 | |
---|
| 5755 | pCaster->SendHealSpellLog(pCaster, spellProto->Id, heal); |
---|
| 5756 | break; |
---|
| 5757 | } |
---|
| 5758 | case SPELL_AURA_PERIODIC_HEAL: |
---|
| 5759 | case SPELL_AURA_OBS_MOD_HEALTH: |
---|
| 5760 | { |
---|
| 5761 | Unit *pCaster = GetCaster(); |
---|
| 5762 | if(!pCaster) |
---|
| 5763 | return; |
---|
| 5764 | |
---|
| 5765 | // heal for caster damage (must be alive) |
---|
| 5766 | if(m_target != pCaster && GetSpellProto()->SpellVisual==163 && !pCaster->isAlive()) |
---|
| 5767 | return; |
---|
| 5768 | |
---|
| 5769 | // ignore non positive values (can be result apply spellmods to aura damage |
---|
| 5770 | uint32 amount = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0; |
---|
| 5771 | |
---|
| 5772 | uint32 pdamage; |
---|
| 5773 | |
---|
| 5774 | if(m_modifier.m_auraname==SPELL_AURA_OBS_MOD_HEALTH) |
---|
| 5775 | pdamage = uint32(m_target->GetMaxHealth() * amount/100); |
---|
| 5776 | else |
---|
| 5777 | pdamage = amount; |
---|
| 5778 | |
---|
| 5779 | pdamage = pCaster->SpellHealingBonus(GetSpellProto(), pdamage, DOT, m_target); |
---|
| 5780 | |
---|
| 5781 | sLog.outDetail("PeriodicTick: %u (TypeId: %u) heal of %u (TypeId: %u) for %u health inflicted by %u", |
---|
| 5782 | GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target->GetGUIDLow(), m_target->GetTypeId(), pdamage, GetId()); |
---|
| 5783 | |
---|
| 5784 | WorldPacket data(SMSG_PERIODICAURALOG, (21+16));// we guess size |
---|
| 5785 | data.append(m_target->GetPackGUID()); |
---|
| 5786 | data.appendPackGUID(GetCasterGUID()); |
---|
| 5787 | data << uint32(GetId()); |
---|
| 5788 | data << uint32(1); |
---|
| 5789 | data << uint32(m_modifier.m_auraname); |
---|
| 5790 | data << (uint32)pdamage; |
---|
| 5791 | m_target->SendMessageToSet(&data,true); |
---|
| 5792 | |
---|
| 5793 | int32 gain = m_target->ModifyHealth(pdamage); |
---|
| 5794 | |
---|
| 5795 | // add HoTs to amount healed in bgs |
---|
| 5796 | if( pCaster->GetTypeId() == TYPEID_PLAYER ) |
---|
| 5797 | if( BattleGround *bg = ((Player*)pCaster)->GetBattleGround() ) |
---|
| 5798 | bg->UpdatePlayerScore(((Player*)pCaster), SCORE_HEALING_DONE, gain); |
---|
| 5799 | |
---|
| 5800 | //Do check before because m_modifier.auraName can be invalidate by DealDamage. |
---|
| 5801 | bool procSpell = (m_modifier.m_auraname == SPELL_AURA_PERIODIC_HEAL && m_target != pCaster); |
---|
| 5802 | |
---|
| 5803 | m_target->getHostilRefManager().threatAssist(pCaster, float(gain) * 0.5f, GetSpellProto()); |
---|
| 5804 | |
---|
| 5805 | Unit* target = m_target; // aura can be deleted in DealDamage |
---|
| 5806 | SpellEntry const* spellProto = GetSpellProto(); |
---|
| 5807 | bool haveCastItem = GetCastItemGUID()!=0; |
---|
| 5808 | |
---|
| 5809 | // heal for caster damage |
---|
| 5810 | if(m_target!=pCaster && spellProto->SpellVisual==163) |
---|
| 5811 | { |
---|
| 5812 | uint32 dmg = spellProto->manaPerSecond; |
---|
| 5813 | if(pCaster->GetHealth() <= dmg && pCaster->GetTypeId()==TYPEID_PLAYER) |
---|
| 5814 | { |
---|
| 5815 | pCaster->RemoveAurasDueToSpell(GetId()); |
---|
| 5816 | |
---|
| 5817 | // finish current generic/channeling spells, don't affect autorepeat |
---|
| 5818 | if(pCaster->m_currentSpells[CURRENT_GENERIC_SPELL]) |
---|
| 5819 | { |
---|
| 5820 | pCaster->m_currentSpells[CURRENT_GENERIC_SPELL]->finish(); |
---|
| 5821 | } |
---|
| 5822 | if(pCaster->m_currentSpells[CURRENT_CHANNELED_SPELL]) |
---|
| 5823 | { |
---|
| 5824 | pCaster->m_currentSpells[CURRENT_CHANNELED_SPELL]->SendChannelUpdate(0); |
---|
| 5825 | pCaster->m_currentSpells[CURRENT_CHANNELED_SPELL]->finish(); |
---|
| 5826 | } |
---|
| 5827 | } |
---|
| 5828 | else |
---|
| 5829 | { |
---|
| 5830 | pCaster->SendSpellNonMeleeDamageLog(pCaster, GetId(), gain, GetSpellSchoolMask(GetSpellProto()), 0, 0, false, 0, false); |
---|
| 5831 | |
---|
| 5832 | CleanDamage cleanDamage = CleanDamage(0, BASE_ATTACK, MELEE_HIT_NORMAL ); |
---|
| 5833 | pCaster->DealDamage(pCaster, gain, &cleanDamage, NODAMAGE, GetSpellSchoolMask(GetSpellProto()), GetSpellProto(), true); |
---|
| 5834 | } |
---|
| 5835 | } |
---|
| 5836 | |
---|
| 5837 | // ignore item heals |
---|
| 5838 | if(procSpell && !haveCastItem) |
---|
| 5839 | pCaster->ProcDamageAndSpell(target,PROC_FLAG_HEAL, PROC_FLAG_HEALED, pdamage, SPELL_SCHOOL_MASK_NONE, spellProto); |
---|
| 5840 | break; |
---|
| 5841 | } |
---|
| 5842 | case SPELL_AURA_PERIODIC_MANA_LEECH: |
---|
| 5843 | { |
---|
| 5844 | Unit *pCaster = GetCaster(); |
---|
| 5845 | if(!pCaster) |
---|
| 5846 | return; |
---|
| 5847 | |
---|
| 5848 | if(!pCaster->isAlive()) |
---|
| 5849 | return; |
---|
| 5850 | |
---|
| 5851 | if( GetSpellProto()->Effect[GetEffIndex()]==SPELL_EFFECT_PERSISTENT_AREA_AURA && |
---|
| 5852 | pCaster->SpellHitResult(m_target,GetSpellProto(),false)!=SPELL_MISS_NONE) |
---|
| 5853 | return; |
---|
| 5854 | |
---|
| 5855 | // Check for immune (not use charges) |
---|
| 5856 | if(m_target->IsImmunedToDamage(GetSpellSchoolMask(GetSpellProto()))) |
---|
| 5857 | return; |
---|
| 5858 | |
---|
| 5859 | // ignore non positive values (can be result apply spellmods to aura damage |
---|
| 5860 | uint32 pdamage = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0; |
---|
| 5861 | |
---|
| 5862 | sLog.outDetail("PeriodicTick: %u (TypeId: %u) power leech of %u (TypeId: %u) for %u dmg inflicted by %u", |
---|
| 5863 | GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target->GetGUIDLow(), m_target->GetTypeId(), pdamage, GetId()); |
---|
| 5864 | |
---|
| 5865 | if(m_modifier.m_miscvalue < 0 || m_modifier.m_miscvalue > 4) |
---|
| 5866 | break; |
---|
| 5867 | |
---|
| 5868 | Powers power = Powers(m_modifier.m_miscvalue); |
---|
| 5869 | |
---|
| 5870 | // power type might have changed between aura applying and tick (druid's shapeshift) |
---|
| 5871 | if(m_target->getPowerType() != power) |
---|
| 5872 | break; |
---|
| 5873 | |
---|
| 5874 | int32 drain_amount = m_target->GetPower(power) > pdamage ? pdamage : m_target->GetPower(power); |
---|
| 5875 | |
---|
| 5876 | // resilience reduce mana draining effect at spell crit damage reduction (added in 2.4) |
---|
| 5877 | if (power == POWER_MANA && m_target->GetTypeId() == TYPEID_PLAYER) |
---|
| 5878 | drain_amount -= ((Player*)m_target)->GetSpellCritDamageReduction(drain_amount); |
---|
| 5879 | |
---|
| 5880 | m_target->ModifyPower(power, -drain_amount); |
---|
| 5881 | |
---|
| 5882 | float gain_multiplier = 0; |
---|
| 5883 | |
---|
| 5884 | if(pCaster->GetMaxPower(power) > 0) |
---|
| 5885 | { |
---|
| 5886 | gain_multiplier = GetSpellProto()->EffectMultipleValue[GetEffIndex()]; |
---|
| 5887 | |
---|
| 5888 | if(Player *modOwner = pCaster->GetSpellModOwner()) |
---|
| 5889 | modOwner->ApplySpellMod(GetId(), SPELLMOD_MULTIPLE_VALUE, gain_multiplier); |
---|
| 5890 | } |
---|
| 5891 | |
---|
| 5892 | WorldPacket data(SMSG_PERIODICAURALOG, (21+16));// we guess size |
---|
| 5893 | data.append(m_target->GetPackGUID()); |
---|
| 5894 | data.appendPackGUID(GetCasterGUID()); |
---|
| 5895 | data << uint32(GetId()); |
---|
| 5896 | data << uint32(1); |
---|
| 5897 | data << uint32(m_modifier.m_auraname); |
---|
| 5898 | data << (uint32)power; // power type |
---|
| 5899 | data << (uint32)drain_amount; |
---|
| 5900 | data << (float)gain_multiplier; |
---|
| 5901 | m_target->SendMessageToSet(&data,true); |
---|
| 5902 | |
---|
| 5903 | int32 gain_amount = int32(drain_amount*gain_multiplier); |
---|
| 5904 | |
---|
| 5905 | if(gain_amount) |
---|
| 5906 | { |
---|
| 5907 | int32 gain = pCaster->ModifyPower(power,gain_amount); |
---|
| 5908 | m_target->AddThreat(pCaster, float(gain) * 0.5f, GetSpellSchoolMask(GetSpellProto()), GetSpellProto()); |
---|
| 5909 | } |
---|
| 5910 | break; |
---|
| 5911 | } |
---|
| 5912 | case SPELL_AURA_PERIODIC_ENERGIZE: |
---|
| 5913 | { |
---|
| 5914 | // ignore non positive values (can be result apply spellmods to aura damage |
---|
| 5915 | uint32 pdamage = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0; |
---|
| 5916 | |
---|
| 5917 | sLog.outDetail("PeriodicTick: %u (TypeId: %u) energize %u (TypeId: %u) for %u dmg inflicted by %u", |
---|
| 5918 | GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target->GetGUIDLow(), m_target->GetTypeId(), pdamage, GetId()); |
---|
| 5919 | |
---|
| 5920 | if(m_modifier.m_miscvalue < 0 || m_modifier.m_miscvalue > 4) |
---|
| 5921 | break; |
---|
| 5922 | |
---|
| 5923 | Powers power = Powers(m_modifier.m_miscvalue); |
---|
| 5924 | |
---|
| 5925 | if(m_target->GetMaxPower(power) == 0) |
---|
| 5926 | break; |
---|
| 5927 | |
---|
| 5928 | WorldPacket data(SMSG_PERIODICAURALOG, (21+16));// we guess size |
---|
| 5929 | data.append(m_target->GetPackGUID()); |
---|
| 5930 | data.appendPackGUID(GetCasterGUID()); |
---|
| 5931 | data << uint32(GetId()); |
---|
| 5932 | data << uint32(1); |
---|
| 5933 | data << uint32(m_modifier.m_auraname); |
---|
| 5934 | data << (uint32)power; // power type |
---|
| 5935 | data << (uint32)pdamage; |
---|
| 5936 | m_target->SendMessageToSet(&data,true); |
---|
| 5937 | |
---|
| 5938 | int32 gain = m_target->ModifyPower(power,pdamage); |
---|
| 5939 | |
---|
| 5940 | if(Unit* pCaster = GetCaster()) |
---|
| 5941 | m_target->getHostilRefManager().threatAssist(pCaster, float(gain) * 0.5f, GetSpellProto()); |
---|
| 5942 | break; |
---|
| 5943 | } |
---|
| 5944 | case SPELL_AURA_OBS_MOD_MANA: |
---|
| 5945 | { |
---|
| 5946 | // ignore non positive values (can be result apply spellmods to aura damage |
---|
| 5947 | uint32 amount = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0; |
---|
| 5948 | |
---|
| 5949 | uint32 pdamage = uint32(m_target->GetMaxPower(POWER_MANA) * amount/100); |
---|
| 5950 | |
---|
| 5951 | sLog.outDetail("PeriodicTick: %u (TypeId: %u) energize %u (TypeId: %u) for %u mana inflicted by %u", |
---|
| 5952 | GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target->GetGUIDLow(), m_target->GetTypeId(), pdamage, GetId()); |
---|
| 5953 | |
---|
| 5954 | if(m_target->GetMaxPower(POWER_MANA) == 0) |
---|
| 5955 | break; |
---|
| 5956 | |
---|
| 5957 | WorldPacket data(SMSG_PERIODICAURALOG, (21+16));// we guess size |
---|
| 5958 | data.append(m_target->GetPackGUID()); |
---|
| 5959 | data.appendPackGUID(GetCasterGUID()); |
---|
| 5960 | data << uint32(GetId()); |
---|
| 5961 | data << uint32(1); |
---|
| 5962 | data << uint32(m_modifier.m_auraname); |
---|
| 5963 | data << (uint32)0; // ? |
---|
| 5964 | data << (uint32)pdamage; |
---|
| 5965 | m_target->SendMessageToSet(&data,true); |
---|
| 5966 | |
---|
| 5967 | int32 gain = m_target->ModifyPower(POWER_MANA, pdamage); |
---|
| 5968 | |
---|
| 5969 | if(Unit* pCaster = GetCaster()) |
---|
| 5970 | m_target->getHostilRefManager().threatAssist(pCaster, float(gain) * 0.5f, GetSpellProto()); |
---|
| 5971 | break; |
---|
| 5972 | } |
---|
| 5973 | case SPELL_AURA_POWER_BURN_MANA: |
---|
| 5974 | { |
---|
| 5975 | Unit *pCaster = GetCaster(); |
---|
| 5976 | if(!pCaster) |
---|
| 5977 | return; |
---|
| 5978 | |
---|
| 5979 | // Check for immune (not use charges) |
---|
| 5980 | if(m_target->IsImmunedToDamage(GetSpellSchoolMask(GetSpellProto()))) |
---|
| 5981 | return; |
---|
| 5982 | |
---|
| 5983 | int32 pdamage = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0; |
---|
| 5984 | |
---|
| 5985 | Powers powerType = Powers(m_modifier.m_miscvalue); |
---|
| 5986 | |
---|
| 5987 | if(!m_target->isAlive() || m_target->getPowerType() != powerType) |
---|
| 5988 | return; |
---|
| 5989 | |
---|
| 5990 | // resilience reduce mana draining effect at spell crit damage reduction (added in 2.4) |
---|
| 5991 | if (powerType == POWER_MANA && m_target->GetTypeId() == TYPEID_PLAYER) |
---|
| 5992 | pdamage -= ((Player*)m_target)->GetSpellCritDamageReduction(pdamage); |
---|
| 5993 | |
---|
| 5994 | uint32 gain = uint32(-m_target->ModifyPower(powerType, -pdamage)); |
---|
| 5995 | |
---|
| 5996 | gain = uint32(gain * GetSpellProto()->EffectMultipleValue[GetEffIndex()]); |
---|
| 5997 | |
---|
| 5998 | //maybe has to be sent different to client, but not by SMSG_PERIODICAURALOG |
---|
| 5999 | pCaster->SpellNonMeleeDamageLog(m_target, GetId(), gain); |
---|
| 6000 | break; |
---|
| 6001 | } |
---|
| 6002 | // Here tick dummy auras |
---|
| 6003 | case SPELL_AURA_PERIODIC_DUMMY: |
---|
| 6004 | { |
---|
| 6005 | PeriodicDummyTick(); |
---|
| 6006 | break; |
---|
| 6007 | } |
---|
| 6008 | default: |
---|
| 6009 | break; |
---|
| 6010 | } |
---|
| 6011 | } |
---|
| 6012 | |
---|
| 6013 | void Aura::PeriodicDummyTick() |
---|
| 6014 | { |
---|
| 6015 | SpellEntry const* spell = GetSpellProto(); |
---|
| 6016 | switch (spell->Id) |
---|
| 6017 | { |
---|
| 6018 | // Drink |
---|
| 6019 | case 430: |
---|
| 6020 | case 431: |
---|
| 6021 | case 432: |
---|
| 6022 | case 1133: |
---|
| 6023 | case 1135: |
---|
| 6024 | case 1137: |
---|
| 6025 | case 10250: |
---|
| 6026 | case 22734: |
---|
| 6027 | case 27089: |
---|
| 6028 | case 34291: |
---|
| 6029 | case 43706: |
---|
| 6030 | case 46755: |
---|
| 6031 | { |
---|
| 6032 | if (m_target->GetTypeId() != TYPEID_PLAYER) |
---|
| 6033 | return; |
---|
| 6034 | // Search SPELL_AURA_MOD_POWER_REGEN aura for this spell and add bonus |
---|
| 6035 | Unit::AuraList const& aura = m_target->GetAurasByType(SPELL_AURA_MOD_POWER_REGEN); |
---|
| 6036 | for(Unit::AuraList::const_iterator i = aura.begin(); i != aura.end(); ++i) |
---|
| 6037 | { |
---|
| 6038 | if ((*i)->GetId() == GetId()) |
---|
| 6039 | { |
---|
| 6040 | // Get tick number |
---|
| 6041 | int32 tick = (m_maxduration - m_duration) / m_modifier.periodictime; |
---|
| 6042 | // Default case (not on arenas) |
---|
| 6043 | if (tick == 0) |
---|
| 6044 | { |
---|
| 6045 | (*i)->GetModifier()->m_amount = m_modifier.m_amount; |
---|
| 6046 | ((Player*)m_target)->UpdateManaRegen(); |
---|
| 6047 | // Disable continue |
---|
| 6048 | m_isPeriodic = false; |
---|
| 6049 | } |
---|
| 6050 | return; |
---|
| 6051 | //********************************************** |
---|
| 6052 | // Code commended since arena patch not added |
---|
| 6053 | // This feature uses only in arenas |
---|
| 6054 | //********************************************** |
---|
| 6055 | // Here need increase mana regen per tick (6 second rule) |
---|
| 6056 | // on 0 tick - 0 (handled in 2 second) |
---|
| 6057 | // on 1 tick - 166% (handled in 4 second) |
---|
| 6058 | // on 2 tick - 133% (handled in 6 second) |
---|
| 6059 | // Not need update after 3 tick |
---|
| 6060 | /* |
---|
| 6061 | if (tick > 3) |
---|
| 6062 | return; |
---|
| 6063 | // Apply bonus for 0 - 3 tick |
---|
| 6064 | switch (tick) |
---|
| 6065 | { |
---|
| 6066 | case 0: // 0% |
---|
| 6067 | (*i)->GetModifier()->m_amount = m_modifier.m_amount = 0; |
---|
| 6068 | break; |
---|
| 6069 | case 1: // 166% |
---|
| 6070 | (*i)->GetModifier()->m_amount = m_modifier.m_amount * 5 / 3; |
---|
| 6071 | break; |
---|
| 6072 | case 2: // 133% |
---|
| 6073 | (*i)->GetModifier()->m_amount = m_modifier.m_amount * 4 / 3; |
---|
| 6074 | break; |
---|
| 6075 | default: // 100% - normal regen |
---|
| 6076 | (*i)->GetModifier()->m_amount = m_modifier.m_amount; |
---|
| 6077 | break; |
---|
| 6078 | } |
---|
| 6079 | ((Player*)m_target)->UpdateManaRegen(); |
---|
| 6080 | return;*/ |
---|
| 6081 | } |
---|
| 6082 | } |
---|
| 6083 | return; |
---|
| 6084 | } |
---|
| 6085 | // // Panda |
---|
| 6086 | // case 19230: break; |
---|
| 6087 | // // Master of Subtlety |
---|
| 6088 | // case 31666: break; |
---|
| 6089 | // // Gossip NPC Periodic - Talk |
---|
| 6090 | // case 33208: break; |
---|
| 6091 | // // Gossip NPC Periodic - Despawn |
---|
| 6092 | // case 33209: break; |
---|
| 6093 | // // Force of Nature |
---|
| 6094 | // case 33831: break; |
---|
| 6095 | // Aspect of the Viper |
---|
| 6096 | case 34074: |
---|
| 6097 | { |
---|
| 6098 | if (m_target->GetTypeId() != TYPEID_PLAYER) |
---|
| 6099 | return; |
---|
| 6100 | // Should be manauser |
---|
| 6101 | if (m_target->getPowerType()!=POWER_MANA) |
---|
| 6102 | return; |
---|
| 6103 | Unit *caster = GetCaster(); |
---|
| 6104 | if (!caster) |
---|
| 6105 | return; |
---|
| 6106 | // Regen amount is max (100% from spell) on 21% or less mana and min on 92.5% or greater mana (20% from spell) |
---|
| 6107 | int mana = m_target->GetPower(POWER_MANA); |
---|
| 6108 | int max_mana = m_target->GetMaxPower(POWER_MANA); |
---|
| 6109 | int32 base_regen = caster->CalculateSpellDamage(m_spellProto, m_effIndex, m_currentBasePoints, m_target); |
---|
| 6110 | float regen_pct = 1.20f - 1.1f * mana / max_mana; |
---|
| 6111 | if (regen_pct > 1.0f) regen_pct = 1.0f; |
---|
| 6112 | else if (regen_pct < 0.2f) regen_pct = 0.2f; |
---|
| 6113 | m_modifier.m_amount = int32 (base_regen * regen_pct); |
---|
| 6114 | ((Player*)m_target)->UpdateManaRegen(); |
---|
| 6115 | return; |
---|
| 6116 | } |
---|
| 6117 | // // Steal Weapon |
---|
| 6118 | // case 36207: break; |
---|
| 6119 | // // Simon Game START timer, (DND) |
---|
| 6120 | // case 39993: break; |
---|
| 6121 | // // Harpooner's Mark |
---|
| 6122 | // case 40084: break; |
---|
| 6123 | // // Knockdown Fel Cannon: break; The Aggro Burst |
---|
| 6124 | // case 40119: break; |
---|
| 6125 | // // Old Mount Spell |
---|
| 6126 | // case 40154: break; |
---|
| 6127 | // // Magnetic Pull |
---|
| 6128 | // case 40581: break; |
---|
| 6129 | // // Ethereal Ring: break; The Bolt Burst |
---|
| 6130 | // case 40801: break; |
---|
| 6131 | // // Crystal Prison |
---|
| 6132 | // case 40846: break; |
---|
| 6133 | // // Copy Weapon |
---|
| 6134 | // case 41054: break; |
---|
| 6135 | // // Ethereal Ring Visual, Lightning Aura |
---|
| 6136 | // case 41477: break; |
---|
| 6137 | // // Ethereal Ring Visual, Lightning Aura (Fork) |
---|
| 6138 | // case 41525: break; |
---|
| 6139 | // // Ethereal Ring Visual, Lightning Jumper Aura |
---|
| 6140 | // case 41567: break; |
---|
| 6141 | // // No Man's Land |
---|
| 6142 | // case 41955: break; |
---|
| 6143 | // // Headless Horseman - Fire |
---|
| 6144 | // case 42074: break; |
---|
| 6145 | // // Headless Horseman - Visual - Large Fire |
---|
| 6146 | // case 42075: break; |
---|
| 6147 | // // Headless Horseman - Start Fire, Periodic Aura |
---|
| 6148 | // case 42140: break; |
---|
| 6149 | // // Ram Speed Boost |
---|
| 6150 | // case 42152: break; |
---|
| 6151 | // // Headless Horseman - Fires Out Victory Aura |
---|
| 6152 | // case 42235: break; |
---|
| 6153 | // // Pumpkin Life Cycle |
---|
| 6154 | // case 42280: break; |
---|
| 6155 | // // Brewfest Request Chick Chuck Mug Aura |
---|
| 6156 | // case 42537: break; |
---|
| 6157 | // // Squashling |
---|
| 6158 | // case 42596: break; |
---|
| 6159 | // // Headless Horseman Climax, Head: Periodic |
---|
| 6160 | // case 42603: break; |
---|
| 6161 | // // Fire Bomb |
---|
| 6162 | // case 42621: break; |
---|
| 6163 | // // Headless Horseman - Conflagrate, Periodic Aura |
---|
| 6164 | // case 42637: break; |
---|
| 6165 | // // Headless Horseman - Create Pumpkin Treats Aura |
---|
| 6166 | // case 42774: break; |
---|
| 6167 | // // Headless Horseman Climax - Summoning Rhyme Aura |
---|
| 6168 | // case 42879: break; |
---|
| 6169 | // // Tricky Treat |
---|
| 6170 | // case 42919: break; |
---|
| 6171 | // // Giddyup! |
---|
| 6172 | // case 42924: break; |
---|
| 6173 | // // Ram - Trot |
---|
| 6174 | // case 42992: break; |
---|
| 6175 | // // Ram - Canter |
---|
| 6176 | // case 42993: break; |
---|
| 6177 | // // Ram - Gallop |
---|
| 6178 | // case 42994: break; |
---|
| 6179 | // // Ram Level - Neutral |
---|
| 6180 | // case 43310: break; |
---|
| 6181 | // // Headless Horseman - Maniacal Laugh, Maniacal, Delayed 17 |
---|
| 6182 | // case 43884: break; |
---|
| 6183 | // // Headless Horseman - Maniacal Laugh, Maniacal, other, Delayed 17 |
---|
| 6184 | // case 44000: break; |
---|
| 6185 | // // Energy Feedback |
---|
| 6186 | // case 44328: break; |
---|
| 6187 | // // Romantic Picnic |
---|
| 6188 | // case 45102: break; |
---|
| 6189 | // // Romantic Picnic |
---|
| 6190 | // case 45123: break; |
---|
| 6191 | // // Looking for Love |
---|
| 6192 | // case 45124: break; |
---|
| 6193 | // // Kite - Lightning Strike Kite Aura |
---|
| 6194 | // case 45197: break; |
---|
| 6195 | // // Rocket Chicken |
---|
| 6196 | // case 45202: break; |
---|
| 6197 | // // Copy Offhand Weapon |
---|
| 6198 | // case 45205: break; |
---|
| 6199 | // // Upper Deck - Kite - Lightning Periodic Aura |
---|
| 6200 | // case 45207: break; |
---|
| 6201 | // // Kite -Sky Lightning Strike Kite Aura |
---|
| 6202 | // case 45251: break; |
---|
| 6203 | // // Ribbon Pole Dancer Check Aura |
---|
| 6204 | // case 45390: break; |
---|
| 6205 | // // Holiday - Midsummer, Ribbon Pole Periodic Visual |
---|
| 6206 | // case 45406: break; |
---|
| 6207 | // // Parachute |
---|
| 6208 | // case 45472: break; |
---|
| 6209 | // // Alliance Flag, Extra Damage Debuff |
---|
| 6210 | // case 45898: break; |
---|
| 6211 | // // Horde Flag, Extra Damage Debuff |
---|
| 6212 | // case 45899: break; |
---|
| 6213 | // // Ahune - Summoning Rhyme Aura |
---|
| 6214 | // case 45926: break; |
---|
| 6215 | // // Ahune - Slippery Floor |
---|
| 6216 | // case 45945: break; |
---|
| 6217 | // // Ahune's Shield |
---|
| 6218 | // case 45954: break; |
---|
| 6219 | // // Nether Vapor Lightning |
---|
| 6220 | // case 45960: break; |
---|
| 6221 | // // Darkness |
---|
| 6222 | // case 45996: break; |
---|
| 6223 | // // Summon Blood Elves Periodic |
---|
| 6224 | // case 46041: break; |
---|
| 6225 | // // Transform Visual Missile Periodic |
---|
| 6226 | // case 46205: break; |
---|
| 6227 | // // Find Opening Beam End |
---|
| 6228 | // case 46333: break; |
---|
| 6229 | // // Ice Spear Control Aura |
---|
| 6230 | // case 46371: break; |
---|
| 6231 | // // Hailstone Chill |
---|
| 6232 | // case 46458: break; |
---|
| 6233 | // // Hailstone Chill, Internal |
---|
| 6234 | // case 46465: break; |
---|
| 6235 | // // Chill, Internal Shifter |
---|
| 6236 | // case 46549: break; |
---|
| 6237 | // // Summon Ice Spear Knockback Delayer |
---|
| 6238 | // case 46878: break; |
---|
| 6239 | // // Burninate Effect |
---|
| 6240 | // case 47214: break; |
---|
| 6241 | // // Fizzcrank Practice Parachute |
---|
| 6242 | // case 47228: break; |
---|
| 6243 | // // Send Mug Control Aura |
---|
| 6244 | // case 47369: break; |
---|
| 6245 | // // Direbrew's Disarm (precast) |
---|
| 6246 | // case 47407: break; |
---|
| 6247 | // // Mole Machine Port Schedule |
---|
| 6248 | // case 47489: break; |
---|
| 6249 | // // Mole Machine Portal Schedule |
---|
| 6250 | // case 49466: break; |
---|
| 6251 | // // Drink Coffee |
---|
| 6252 | // case 49472: break; |
---|
| 6253 | // // Listening to Music |
---|
| 6254 | // case 50493: break; |
---|
| 6255 | // // Love Rocket Barrage |
---|
| 6256 | // case 50530: break; |
---|
| 6257 | default: |
---|
| 6258 | break; |
---|
| 6259 | } |
---|
| 6260 | } |
---|
| 6261 | |
---|
| 6262 | void Aura::HandlePreventFleeing(bool apply, bool Real) |
---|
| 6263 | { |
---|
| 6264 | if(!Real) |
---|
| 6265 | return; |
---|
| 6266 | |
---|
| 6267 | Unit::AuraList const& fearAuras = m_target->GetAurasByType(SPELL_AURA_MOD_FEAR); |
---|
| 6268 | if( !fearAuras.empty() ) |
---|
| 6269 | { |
---|
| 6270 | if (apply) |
---|
| 6271 | m_target->SetFeared(false, fearAuras.front()->GetCasterGUID()); |
---|
| 6272 | else |
---|
| 6273 | m_target->SetFeared(true); |
---|
| 6274 | } |
---|
| 6275 | } |
---|
| 6276 | |
---|
| 6277 | void Aura::HandleManaShield(bool apply, bool Real) |
---|
| 6278 | { |
---|
| 6279 | if(!Real) |
---|
| 6280 | return; |
---|
| 6281 | |
---|
| 6282 | // prevent double apply bonuses |
---|
| 6283 | if(apply && (m_target->GetTypeId()!=TYPEID_PLAYER || !((Player*)m_target)->GetSession()->PlayerLoading())) |
---|
| 6284 | { |
---|
| 6285 | if(Unit* caster = GetCaster()) |
---|
| 6286 | { |
---|
| 6287 | float DoneActualBenefit = 0.0f; |
---|
| 6288 | switch(m_spellProto->SpellFamilyName) |
---|
| 6289 | { |
---|
| 6290 | case SPELLFAMILY_MAGE: |
---|
| 6291 | if(m_spellProto->SpellFamilyFlags & 0x8000) |
---|
| 6292 | { |
---|
| 6293 | // Mana Shield |
---|
| 6294 | // +50% from +spd bonus |
---|
| 6295 | DoneActualBenefit = caster->SpellBaseDamageBonus(GetSpellSchoolMask(m_spellProto)) * 0.5f; |
---|
| 6296 | break; |
---|
| 6297 | } |
---|
| 6298 | break; |
---|
| 6299 | default: |
---|
| 6300 | break; |
---|
| 6301 | } |
---|
| 6302 | |
---|
| 6303 | DoneActualBenefit *= caster->CalculateLevelPenalty(GetSpellProto()); |
---|
| 6304 | |
---|
| 6305 | m_modifier.m_amount += (int32)DoneActualBenefit; |
---|
| 6306 | } |
---|
| 6307 | } |
---|
| 6308 | } |
---|
| 6309 | |
---|
| 6310 | void Aura::HandleArenaPreparation(bool apply, bool Real) |
---|
| 6311 | { |
---|
| 6312 | if(!Real) |
---|
| 6313 | return; |
---|
| 6314 | |
---|
| 6315 | if(apply) |
---|
| 6316 | m_target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PREPARATION); |
---|
| 6317 | else |
---|
| 6318 | m_target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PREPARATION); |
---|
| 6319 | } |
---|