2010-10-07 15:35:36 +02:00
/*
2012-01-01 00:32:13 +01:00
* Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
2010-10-07 15:35:36 +02:00
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
2008-10-11 14:16:25 -05:00
*/
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
#include "Common.h"
2010-06-08 17:01:03 -06:00
#include "DatabaseEnv.h"
2008-10-11 14:16:25 -05:00
#include "WorldPacket.h"
#include "Opcodes.h"
#include "Log.h"
#include "UpdateMask.h"
#include "World.h"
#include "ObjectMgr.h"
#include "SpellMgr.h"
#include "Player.h"
#include "SkillExtraItems.h"
#include "Unit.h"
#include "Spell.h"
#include "DynamicObject.h"
#include "SpellAuras.h"
2010-01-10 01:23:15 +01:00
#include "SpellAuraEffects.h"
2008-10-11 14:16:25 -05:00
#include "Group.h"
#include "UpdateData.h"
#include "MapManager.h"
#include "ObjectAccessor.h"
#include "SharedDefines.h"
#include "Pet.h"
#include "GameObject.h"
#include "GossipDef.h"
#include "Creature.h"
#include "Totem.h"
#include "CreatureAI.h"
2010-08-08 04:37:24 +02:00
#include "BattlegroundMgr.h"
#include "Battleground.h"
#include "BattlegroundEY.h"
#include "BattlegroundWS.h"
2008-10-14 11:57:03 -05:00
#include "OutdoorPvPMgr.h"
2008-10-11 14:16:25 -05:00
#include "Language.h"
#include "SocialMgr.h"
#include "Util.h"
2010-06-05 00:59:25 +02:00
#include "VMapFactory.h"
2008-10-11 14:16:25 -05:00
#include "TemporarySummon.h"
2008-11-15 15:11:31 -06:00
#include "CellImpl.h"
2008-12-21 12:33:03 -06:00
#include "GridNotifiers.h"
#include "GridNotifiersImpl.h"
2009-01-20 19:59:43 -06:00
#include "SkillDiscovery.h"
2009-03-10 15:28:51 -06:00
#include "Formulas.h"
2009-03-18 21:39:09 -06:00
#include "Vehicle.h"
2010-01-19 11:36:05 +01:00
#include "ScriptMgr.h"
2010-10-27 21:01:47 +02:00
#include "GameObjectAI.h"
2011-09-08 15:11:55 +02:00
#include "AccountMgr.h"
2011-09-30 18:41:30 +02:00
#include "InstanceScript.h"
2012-09-09 14:39:34 +02:00
#include "Guild.h"
#include "GuildMgr.h"
2012-11-20 12:30:30 +01:00
#include "ReputationMgr.h"
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
pEffect SpellEffects [ TOTAL_SPELL_EFFECTS ] =
{
& Spell :: EffectNULL , // 0
& Spell :: EffectInstaKill , // 1 SPELL_EFFECT_INSTAKILL
& Spell :: EffectSchoolDMG , // 2 SPELL_EFFECT_SCHOOL_DAMAGE
& Spell :: EffectDummy , // 3 SPELL_EFFECT_DUMMY
& Spell :: EffectUnused , // 4 SPELL_EFFECT_PORTAL_TELEPORT unused
& Spell :: EffectTeleportUnits , // 5 SPELL_EFFECT_TELEPORT_UNITS
& Spell :: EffectApplyAura , // 6 SPELL_EFFECT_APPLY_AURA
2011-09-13 14:15:35 +02:00
& Spell :: EffectEnvironmentalDMG , // 7 SPELL_EFFECT_ENVIRONMENTAL_DAMAGE
2008-10-11 14:16:25 -05:00
& Spell :: EffectPowerDrain , // 8 SPELL_EFFECT_POWER_DRAIN
& Spell :: EffectHealthLeech , // 9 SPELL_EFFECT_HEALTH_LEECH
& Spell :: EffectHeal , // 10 SPELL_EFFECT_HEAL
2010-04-18 23:20:07 +02:00
& Spell :: EffectBind , // 11 SPELL_EFFECT_BIND
2008-10-11 14:16:25 -05:00
& Spell :: EffectNULL , // 12 SPELL_EFFECT_PORTAL
& Spell :: EffectUnused , // 13 SPELL_EFFECT_RITUAL_BASE unused
& Spell :: EffectUnused , // 14 SPELL_EFFECT_RITUAL_SPECIALIZE unused
& Spell :: EffectUnused , // 15 SPELL_EFFECT_RITUAL_ACTIVATE_PORTAL unused
& Spell :: EffectQuestComplete , // 16 SPELL_EFFECT_QUEST_COMPLETE
& Spell :: EffectWeaponDmg , // 17 SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL
& Spell :: EffectResurrect , // 18 SPELL_EFFECT_RESURRECT
& Spell :: EffectAddExtraAttacks , // 19 SPELL_EFFECT_ADD_EXTRA_ATTACKS
& Spell :: EffectUnused , // 20 SPELL_EFFECT_DODGE one spell: Dodge
& Spell :: EffectUnused , // 21 SPELL_EFFECT_EVADE one spell: Evade (DND)
& Spell :: EffectParry , // 22 SPELL_EFFECT_PARRY
& Spell :: EffectBlock , // 23 SPELL_EFFECT_BLOCK one spell: Block
& Spell :: EffectCreateItem , // 24 SPELL_EFFECT_CREATE_ITEM
& Spell :: EffectUnused , // 25 SPELL_EFFECT_WEAPON
& Spell :: EffectUnused , // 26 SPELL_EFFECT_DEFENSE one spell: Defense
& Spell :: EffectPersistentAA , // 27 SPELL_EFFECT_PERSISTENT_AREA_AURA
& Spell :: EffectSummonType , // 28 SPELL_EFFECT_SUMMON
2010-07-21 02:06:51 +02:00
& Spell :: EffectLeap , // 29 SPELL_EFFECT_LEAP
2008-10-11 14:16:25 -05:00
& Spell :: EffectEnergize , // 30 SPELL_EFFECT_ENERGIZE
& Spell :: EffectWeaponDmg , // 31 SPELL_EFFECT_WEAPON_PERCENT_DAMAGE
& Spell :: EffectTriggerMissileSpell , // 32 SPELL_EFFECT_TRIGGER_MISSILE
& Spell :: EffectOpenLock , // 33 SPELL_EFFECT_OPEN_LOCK
& Spell :: EffectSummonChangeItem , // 34 SPELL_EFFECT_SUMMON_CHANGE_ITEM
& Spell :: EffectApplyAreaAura , // 35 SPELL_EFFECT_APPLY_AREA_AURA_PARTY
& Spell :: EffectLearnSpell , // 36 SPELL_EFFECT_LEARN_SPELL
& Spell :: EffectUnused , // 37 SPELL_EFFECT_SPELL_DEFENSE one spell: SPELLDEFENSE (DND)
& Spell :: EffectDispel , // 38 SPELL_EFFECT_DISPEL
& Spell :: EffectUnused , // 39 SPELL_EFFECT_LANGUAGE
& Spell :: EffectDualWield , // 40 SPELL_EFFECT_DUAL_WIELD
2009-04-11 22:41:15 -05:00
& Spell :: EffectJump , // 41 SPELL_EFFECT_JUMP
2010-07-19 21:24:09 +02:00
& Spell :: EffectJumpDest , // 42 SPELL_EFFECT_JUMP_DEST
2008-10-11 14:16:25 -05:00
& Spell :: EffectTeleUnitsFaceCaster , // 43 SPELL_EFFECT_TELEPORT_UNITS_FACE_CASTER
& Spell :: EffectLearnSkill , // 44 SPELL_EFFECT_SKILL_STEP
2012-10-26 21:13:00 +02:00
& Spell :: EffectPlayMovie , // 45 SPELL_EFFECT_PLAY_MOVIE
2010-07-19 22:52:21 +02:00
& Spell :: EffectUnused , // 46 SPELL_EFFECT_SPAWN clientside, unit appears as if it was just spawned
2008-10-11 14:16:25 -05:00
& Spell :: EffectTradeSkill , // 47 SPELL_EFFECT_TRADE_SKILL
& Spell :: EffectUnused , // 48 SPELL_EFFECT_STEALTH one spell: Base Stealth
& Spell :: EffectUnused , // 49 SPELL_EFFECT_DETECT one spell: Detect
& Spell :: EffectTransmitted , // 50 SPELL_EFFECT_TRANS_DOOR
& Spell :: EffectUnused , // 51 SPELL_EFFECT_FORCE_CRITICAL_HIT unused
2011-12-18 16:24:15 +00:00
& Spell :: EffectUnused , // 52 SPELL_EFFECT_GUARANTEE_HIT unused
2008-10-11 14:16:25 -05:00
& Spell :: EffectEnchantItemPerm , // 53 SPELL_EFFECT_ENCHANT_ITEM
& Spell :: EffectEnchantItemTmp , // 54 SPELL_EFFECT_ENCHANT_ITEM_TEMPORARY
& Spell :: EffectTameCreature , // 55 SPELL_EFFECT_TAMECREATURE
& Spell :: EffectSummonPet , // 56 SPELL_EFFECT_SUMMON_PET
& Spell :: EffectLearnPetSpell , // 57 SPELL_EFFECT_LEARN_PET_SPELL
& Spell :: EffectWeaponDmg , // 58 SPELL_EFFECT_WEAPON_DAMAGE
2009-06-23 14:44:16 +02:00
& Spell :: EffectCreateRandomItem , // 59 SPELL_EFFECT_CREATE_RANDOM_ITEM create item base at spell specific loot
2008-10-11 14:16:25 -05:00
& Spell :: EffectProficiency , // 60 SPELL_EFFECT_PROFICIENCY
& Spell :: EffectSendEvent , // 61 SPELL_EFFECT_SEND_EVENT
& Spell :: EffectPowerBurn , // 62 SPELL_EFFECT_POWER_BURN
& Spell :: EffectThreat , // 63 SPELL_EFFECT_THREAT
& Spell :: EffectTriggerSpell , // 64 SPELL_EFFECT_TRIGGER_SPELL
2008-12-24 09:58:26 -06:00
& Spell :: EffectApplyAreaAura , // 65 SPELL_EFFECT_APPLY_AREA_AURA_RAID
2009-12-26 18:25:49 +01:00
& Spell :: EffectRechargeManaGem , // 66 SPELL_EFFECT_CREATE_MANA_GEM (possibly recharge it, misc - is item ID)
2008-10-11 14:16:25 -05:00
& Spell :: EffectHealMaxHealth , // 67 SPELL_EFFECT_HEAL_MAX_HEALTH
& Spell :: EffectInterruptCast , // 68 SPELL_EFFECT_INTERRUPT_CAST
& Spell :: EffectDistract , // 69 SPELL_EFFECT_DISTRACT
& Spell :: EffectPull , // 70 SPELL_EFFECT_PULL one spell: Distract Move
& Spell :: EffectPickPocket , // 71 SPELL_EFFECT_PICKPOCKET
& Spell :: EffectAddFarsight , // 72 SPELL_EFFECT_ADD_FARSIGHT
2010-12-22 20:14:30 +02:00
& Spell :: EffectUntrainTalents , // 73 SPELL_EFFECT_UNTRAIN_TALENTS
2008-12-24 09:58:26 -06:00
& Spell :: EffectApplyGlyph , // 74 SPELL_EFFECT_APPLY_GLYPH
2008-10-11 14:16:25 -05:00
& Spell :: EffectHealMechanical , // 75 SPELL_EFFECT_HEAL_MECHANICAL one spell: Mechanical Patch Kit
& Spell :: EffectSummonObjectWild , // 76 SPELL_EFFECT_SUMMON_OBJECT_WILD
& Spell :: EffectScriptEffect , // 77 SPELL_EFFECT_SCRIPT_EFFECT
& Spell :: EffectUnused , // 78 SPELL_EFFECT_ATTACK
& Spell :: EffectSanctuary , // 79 SPELL_EFFECT_SANCTUARY
& Spell :: EffectAddComboPoints , // 80 SPELL_EFFECT_ADD_COMBO_POINTS
& Spell :: EffectUnused , // 81 SPELL_EFFECT_CREATE_HOUSE one spell: Create House (TEST)
& Spell :: EffectNULL , // 82 SPELL_EFFECT_BIND_SIGHT
& Spell :: EffectDuel , // 83 SPELL_EFFECT_DUEL
& Spell :: EffectStuck , // 84 SPELL_EFFECT_STUCK
& Spell :: EffectSummonPlayer , // 85 SPELL_EFFECT_SUMMON_PLAYER
& Spell :: EffectActivateObject , // 86 SPELL_EFFECT_ACTIVATE_OBJECT
2011-07-22 21:22:05 +02:00
& Spell :: EffectGameObjectDamage , // 87 SPELL_EFFECT_GAMEOBJECT_DAMAGE
& Spell :: EffectGameObjectRepair , // 88 SPELL_EFFECT_GAMEOBJECT_REPAIR
& Spell :: EffectGameObjectSetDestructionState , // 89 SPELL_EFFECT_GAMEOBJECT_SET_DESTRUCTION_STATE
2009-09-11 15:38:31 -07:00
& Spell :: EffectKillCreditPersonal , // 90 SPELL_EFFECT_KILL_CREDIT Kill credit but only for single person
2008-10-11 14:16:25 -05:00
& Spell :: EffectUnused , // 91 SPELL_EFFECT_THREAT_ALL one spell: zzOLDBrainwash
& Spell :: EffectEnchantHeldItem , // 92 SPELL_EFFECT_ENCHANT_HELD_ITEM
2010-01-13 10:27:44 +01:00
& Spell :: EffectForceDeselect , // 93 SPELL_EFFECT_FORCE_DESELECT
2008-10-11 14:16:25 -05:00
& Spell :: EffectSelfResurrect , // 94 SPELL_EFFECT_SELF_RESURRECT
& Spell :: EffectSkinning , // 95 SPELL_EFFECT_SKINNING
2009-05-04 12:11:54 -05:00
& Spell :: EffectCharge , // 96 SPELL_EFFECT_CHARGE
2009-12-17 12:23:01 +01:00
& Spell :: EffectCastButtons , // 97 SPELL_EFFECT_CAST_BUTTON (totem bar since 3.2.2a)
2008-10-11 14:16:25 -05:00
& Spell :: EffectKnockBack , // 98 SPELL_EFFECT_KNOCK_BACK
& Spell :: EffectDisEnchant , // 99 SPELL_EFFECT_DISENCHANT
& Spell :: EffectInebriate , //100 SPELL_EFFECT_INEBRIATE
& Spell :: EffectFeedPet , //101 SPELL_EFFECT_FEED_PET
& Spell :: EffectDismissPet , //102 SPELL_EFFECT_DISMISS_PET
& Spell :: EffectReputation , //103 SPELL_EFFECT_REPUTATION
& Spell :: EffectSummonObject , //104 SPELL_EFFECT_SUMMON_OBJECT_SLOT1
& Spell :: EffectSummonObject , //105 SPELL_EFFECT_SUMMON_OBJECT_SLOT2
& Spell :: EffectSummonObject , //106 SPELL_EFFECT_SUMMON_OBJECT_SLOT3
& Spell :: EffectSummonObject , //107 SPELL_EFFECT_SUMMON_OBJECT_SLOT4
& Spell :: EffectDispelMechanic , //108 SPELL_EFFECT_DISPEL_MECHANIC
& Spell :: EffectSummonDeadPet , //109 SPELL_EFFECT_SUMMON_DEAD_PET
& Spell :: EffectDestroyAllTotems , //110 SPELL_EFFECT_DESTROY_ALL_TOTEMS
& Spell :: EffectDurabilityDamage , //111 SPELL_EFFECT_DURABILITY_DAMAGE
2009-01-06 13:45:49 -06:00
& Spell :: EffectUnused , //112 SPELL_EFFECT_112
2008-10-11 14:16:25 -05:00
& Spell :: EffectResurrectNew , //113 SPELL_EFFECT_RESURRECT_NEW
& Spell :: EffectTaunt , //114 SPELL_EFFECT_ATTACK_ME
& Spell :: EffectDurabilityDamagePCT , //115 SPELL_EFFECT_DURABILITY_DAMAGE_PCT
& Spell :: EffectSkinPlayerCorpse , //116 SPELL_EFFECT_SKIN_PLAYER_CORPSE one spell: Remove Insignia, bg usage, required special corpse flags...
& Spell :: EffectSpiritHeal , //117 SPELL_EFFECT_SPIRIT_HEAL one spell: Spirit Heal
& Spell :: EffectSkill , //118 SPELL_EFFECT_SKILL professions and more
& Spell :: EffectApplyAreaAura , //119 SPELL_EFFECT_APPLY_AREA_AURA_PET
& Spell :: EffectUnused , //120 SPELL_EFFECT_TELEPORT_GRAVEYARD one spell: Graveyard Teleport Test
& Spell :: EffectWeaponDmg , //121 SPELL_EFFECT_NORMALIZED_WEAPON_DMG
& Spell :: EffectUnused , //122 SPELL_EFFECT_122 unused
& Spell :: EffectSendTaxi , //123 SPELL_EFFECT_SEND_TAXI taxi/flight related (misc value is taxi path id)
2010-08-09 02:31:42 +02:00
& Spell :: EffectPullTowards , //124 SPELL_EFFECT_PULL_TOWARDS
2008-10-11 14:16:25 -05:00
& Spell :: EffectModifyThreatPercent , //125 SPELL_EFFECT_MODIFY_THREAT_PERCENT
& Spell :: EffectStealBeneficialBuff , //126 SPELL_EFFECT_STEAL_BENEFICIAL_BUFF spell steal effect?
& Spell :: EffectProspecting , //127 SPELL_EFFECT_PROSPECTING Prospecting spell
& Spell :: EffectApplyAreaAura , //128 SPELL_EFFECT_APPLY_AREA_AURA_FRIEND
& Spell :: EffectApplyAreaAura , //129 SPELL_EFFECT_APPLY_AREA_AURA_ENEMY
2008-12-17 20:07:25 -06:00
& Spell :: EffectRedirectThreat , //130 SPELL_EFFECT_REDIRECT_THREAT
2011-03-07 21:13:18 +01:00
& Spell :: EffectPlayerNotification , //131 SPELL_EFFECT_PLAYER_NOTIFICATION sound id in misc value (SoundEntries.dbc)
2009-07-30 10:18:05 +08:00
& Spell :: EffectPlayMusic , //132 SPELL_EFFECT_PLAY_MUSIC sound id in misc value (SoundEntries.dbc)
2008-10-11 14:16:25 -05:00
& Spell :: EffectUnlearnSpecialization , //133 SPELL_EFFECT_UNLEARN_SPECIALIZATION unlearn profession specialization
& Spell :: EffectKillCredit , //134 SPELL_EFFECT_KILL_CREDIT misc value is creature entry
& Spell :: EffectNULL , //135 SPELL_EFFECT_CALL_PET
& Spell :: EffectHealPct , //136 SPELL_EFFECT_HEAL_PCT
2009-06-08 21:19:34 +02:00
& Spell :: EffectEnergizePct , //137 SPELL_EFFECT_ENERGIZE_PCT
2010-07-19 21:24:09 +02:00
& Spell :: EffectLeapBack , //138 SPELL_EFFECT_LEAP_BACK Leap back
2010-07-04 19:16:40 +02:00
& Spell :: EffectQuestClear , //139 SPELL_EFFECT_CLEAR_QUEST Reset quest status (miscValue - quest ID)
2008-10-11 14:16:25 -05:00
& Spell :: EffectForceCast , //140 SPELL_EFFECT_FORCE_CAST
2011-09-25 13:29:17 +02:00
& Spell :: EffectForceCast , //141 SPELL_EFFECT_FORCE_CAST_WITH_VALUE
& Spell :: EffectTriggerSpell , //142 SPELL_EFFECT_TRIGGER_SPELL_WITH_VALUE
2008-10-11 14:16:25 -05:00
& Spell :: EffectApplyAreaAura , //143 SPELL_EFFECT_APPLY_AREA_AURA_OWNER
2010-07-20 04:29:17 +02:00
& Spell :: EffectKnockBack , //144 SPELL_EFFECT_KNOCK_BACK_DEST
2010-08-09 02:31:42 +02:00
& Spell :: EffectPullTowards , //145 SPELL_EFFECT_PULL_TOWARDS_DEST Black Hole Effect
2008-12-24 09:58:26 -06:00
& Spell :: EffectActivateRune , //146 SPELL_EFFECT_ACTIVATE_RUNE
2008-10-11 14:16:25 -05:00
& Spell :: EffectQuestFail , //147 SPELL_EFFECT_QUEST_FAIL quest fail
2011-09-25 13:29:17 +02:00
& Spell :: EffectTriggerMissileSpell , //148 SPELL_EFFECT_TRIGGER_MISSILE_SPELL_WITH_VALUE
2010-07-19 19:22:05 +02:00
& Spell :: EffectChargeDest , //149 SPELL_EFFECT_CHARGE_DEST
2010-07-20 16:11:49 +02:00
& Spell :: EffectQuestStart , //150 SPELL_EFFECT_QUEST_START
2008-10-11 14:16:25 -05:00
& Spell :: EffectTriggerRitualOfSummoning , //151 SPELL_EFFECT_TRIGGER_SPELL_2
2011-08-03 09:28:12 -07:00
& Spell :: EffectSummonRaFFriend , //152 SPELL_EFFECT_SUMMON_RAF_FRIEND summon Refer-a-Friend
2010-07-20 22:55:28 +02:00
& Spell :: EffectCreateTamedPet , //153 SPELL_EFFECT_CREATE_TAMED_PET misc value is creature entry
2010-08-08 19:45:53 +02:00
& Spell :: EffectDiscoverTaxi , //154 SPELL_EFFECT_DISCOVER_TAXI
2008-12-24 09:58:26 -06:00
& Spell :: EffectTitanGrip , //155 SPELL_EFFECT_TITAN_GRIP Allows you to equip two-handed axes, maces and swords in one hand, but you attack $49152s1% slower than normal.
2009-02-03 19:12:17 -06:00
& Spell :: EffectEnchantItemPrismatic , //156 SPELL_EFFECT_ENCHANT_ITEM_PRISMATIC
2009-06-23 14:44:16 +02:00
& Spell :: EffectCreateItem2 , //157 SPELL_EFFECT_CREATE_ITEM_2 create item or create item template and replace by some randon spell loot item
2009-01-22 22:44:27 -06:00
& Spell :: EffectMilling , //158 SPELL_EFFECT_MILLING milling
2009-06-11 00:45:59 -05:00
& Spell :: EffectRenamePet , //159 SPELL_EFFECT_ALLOW_RENAME_PET allow rename pet once again
2010-07-20 16:11:49 +02:00
& Spell :: EffectNULL , //160 SPELL_EFFECT_160 1 spell - 45534
2009-08-14 17:24:52 -07:00
& Spell :: EffectSpecCount , //161 SPELL_EFFECT_TALENT_SPEC_COUNT second talent spec (learn/revert)
& Spell :: EffectActivateSpec , //162 SPELL_EFFECT_TALENT_SPEC_SELECT activate primary/secondary spec
2011-12-18 16:24:15 +00:00
& Spell :: EffectUnused , //163 SPELL_EFFECT_163 unused
2010-07-20 04:29:17 +02:00
& Spell :: EffectRemoveAura , //164 SPELL_EFFECT_REMOVE_AURA
2011-12-18 16:24:15 +00:00
& Spell :: EffectNULL , //165 SPELL_EFFECT_165
& Spell :: EffectNULL , //166 SPELL_EFFECT_166
& Spell :: EffectNULL , //167 SPELL_EFFECT_167
& Spell :: EffectNULL , //168 SPELL_EFFECT_168
& Spell :: EffectNULL , //169 SPELL_EFFECT_169
& Spell :: EffectNULL , //170 SPELL_EFFECT_170
& Spell :: EffectNULL , //171 SPELL_EFFECT_171
& Spell :: EffectNULL , //172 SPELL_EFFECT_172
& Spell :: EffectNULL , //173 SPELL_EFFECT_173
& Spell :: EffectNULL , //174 SPELL_EFFECT_174
& Spell :: EffectUnused , //175 SPELL_EFFECT_175 unused
& Spell :: EffectNULL , //176 SPELL_EFFECT_176
& Spell :: EffectNULL , //177 SPELL_EFFECT_177
2012-08-18 13:39:41 -05:00
& Spell :: EffectUnused , //178 SPELL_EFFECT_178 unused
2012-08-12 10:54:08 +03:00
& Spell :: EffectNULL , //179 SPELL_EFFECT_179
2012-08-18 13:39:41 -05:00
& Spell :: EffectUnused , //180 SPELL_EFFECT_180 unused
& Spell :: EffectUnused , //181 SPELL_EFFECT_181 unused
2012-08-12 10:54:08 +03:00
& Spell :: EffectNULL , //182 SPELL_EFFECT_182
2008-10-11 14:16:25 -05:00
};
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectNULL ( SpellEffIndex /*effIndex*/ )
2008-10-11 14:16:25 -05:00
{
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_SPELLS_AURAS , "WORLD: Spell Effect DUMMY" );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectUnused ( SpellEffIndex /*effIndex*/ )
2008-10-11 14:16:25 -05:00
{
2010-02-05 00:31:28 +01:00
// NOT USED BY ANY SPELL OR USELESS OR IMPLEMENTED IN DIFFERENT WAY IN TRINITY
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectResurrectNew ( SpellEffIndex effIndex )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2010-04-07 19:14:10 +02:00
if ( ! unitTarget || unitTarget -> isAlive ())
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( unitTarget -> GetTypeId () != TYPEID_PLAYER )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( ! unitTarget -> IsInWorld ())
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2011-10-07 19:45:43 -05:00
Player * target = unitTarget -> ToPlayer ();
2009-10-17 15:51:44 -07:00
2011-10-07 19:45:43 -05:00
if ( target -> isRessurectRequested ()) // already have one active request
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
uint32 health = damage ;
2011-07-26 23:09:28 +02:00
uint32 mana = m_spellInfo -> Effects [ effIndex ]. MiscValue ;
2011-10-07 19:45:43 -05:00
ExecuteLogEffectResurrect ( effIndex , target );
target -> setResurrectRequestData ( m_caster -> GetGUID (), m_caster -> GetMapId (), m_caster -> GetPositionX (), m_caster -> GetPositionY (), m_caster -> GetPositionZ (), health , mana );
SendResurrectRequest ( target );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectInstaKill ( SpellEffIndex /*effIndex*/ )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2009-10-15 11:50:11 -07:00
if ( ! unitTarget || ! unitTarget -> isAlive ())
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2012-09-01 00:36:26 +01:00
if ( unitTarget -> GetTypeId () == TYPEID_PLAYER )
if ( unitTarget -> ToPlayer () -> GetCommandStatus ( CHEAT_GOD ))
return ;
2010-04-07 19:14:10 +02:00
if ( m_caster == unitTarget ) // prevent interrupt message
2008-10-11 14:16:25 -05:00
finish ();
2009-10-17 15:51:44 -07:00
2010-08-28 00:30:07 +02:00
WorldPacket data ( SMSG_SPELLINSTAKILLLOG , 8 + 8 + 4 );
data << uint64 ( m_caster -> GetGUID ());
data << uint64 ( unitTarget -> GetGUID ());
data << uint32 ( m_spellInfo -> Id );
m_caster -> SendMessageToSet ( & data , true );
m_caster -> DealDamage ( unitTarget , unitTarget -> GetHealth (), NULL , NODAMAGE , SPELL_SCHOOL_MASK_NORMAL , NULL , false );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2011-09-13 14:15:35 +02:00
void Spell :: EffectEnvironmentalDMG ( SpellEffIndex /*effIndex*/ )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2011-07-27 21:23:15 +02:00
if ( ! unitTarget || ! unitTarget -> isAlive ())
return ;
2008-10-11 14:16:25 -05:00
uint32 absorb = 0 ;
uint32 resist = 0 ;
2009-10-17 15:51:44 -07:00
2011-07-27 21:23:15 +02:00
m_caster -> CalcAbsorbResist ( unitTarget , m_spellInfo -> GetSchoolMask (), SPELL_DIRECT_DAMAGE , damage , & absorb , & resist , m_spellInfo );
2009-10-17 15:51:44 -07:00
2011-07-27 21:23:15 +02:00
m_caster -> SendSpellNonMeleeDamageLog ( unitTarget , m_spellInfo -> Id , damage , m_spellInfo -> GetSchoolMask (), absorb , resist , false , 0 , false );
if ( unitTarget -> GetTypeId () == TYPEID_PLAYER )
unitTarget -> ToPlayer () -> EnvironmentalDamage ( DAMAGE_FIRE , damage );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2011-09-25 13:29:17 +02:00
void Spell :: EffectSchoolDMG ( SpellEffIndex effIndex )
2008-12-25 17:39:46 -06:00
{
2011-10-06 14:22:11 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_LAUNCH_TARGET )
2011-09-25 13:29:17 +02:00
return ;
2009-10-17 15:51:44 -07:00
2009-10-15 11:50:11 -07:00
if ( unitTarget && unitTarget -> isAlive ())
2008-10-11 14:16:25 -05:00
{
2012-08-30 22:44:33 +01:00
bool apply_direct_bonus = true ;
2009-10-15 11:50:11 -07:00
switch ( m_spellInfo -> SpellFamilyName )
2008-10-11 14:16:25 -05:00
{
case SPELLFAMILY_GENERIC :
{
2008-10-25 15:46:52 -05:00
// Meteor like spells (divided damage to targets)
2011-07-26 23:09:28 +02:00
if ( m_spellInfo -> AttributesCu & SPELL_ATTR0_CU_SHARE_DAMAGE )
2008-10-11 14:16:25 -05:00
{
2008-10-25 15:46:52 -05:00
uint32 count = 0 ;
2009-10-17 16:20:24 -07:00
for ( std :: list < TargetInfo >:: iterator ihit = m_UniqueTargetInfo . begin (); ihit != m_UniqueTargetInfo . end (); ++ ihit )
2010-08-27 19:36:27 +02:00
if ( ihit -> effectMask & ( 1 << effIndex ))
2008-10-25 15:46:52 -05:00
++ count ;
2009-10-17 15:51:44 -07:00
2008-10-25 15:46:52 -05:00
damage /= count ; // divide to all targets
}
2009-10-17 15:51:44 -07:00
2011-09-29 12:43:05 +02:00
switch ( m_spellInfo -> Id ) // better way to check unknown
2008-10-25 15:46:52 -05:00
{
2009-05-20 11:44:38 -05:00
// Consumption
2010-02-15 18:23:39 +01:00
case 28865 :
2009-12-17 12:23:01 +01:00
damage = ((( InstanceMap * ) m_caster -> GetMap ()) -> GetDifficulty () == REGULAR_DIFFICULTY ? 2750 : 4250 );
2009-05-18 15:04:05 -05:00
break ;
2008-10-11 14:16:25 -05:00
// percent from health with min
2010-02-15 18:23:39 +01:00
case 25599 : // Thundercrash
2008-10-11 14:16:25 -05:00
{
damage = unitTarget -> GetHealth () / 2 ;
2010-04-07 19:14:10 +02:00
if ( damage < 200 )
2008-10-11 14:16:25 -05:00
damage = 200 ;
break ;
}
2008-11-24 15:15:09 -06:00
// arcane charge. must only affect demons (also undead?)
2010-02-15 18:23:39 +01:00
case 45072 :
2008-10-19 14:47:43 -05:00
{
2010-04-07 19:14:10 +02:00
if ( unitTarget -> GetCreatureType () != CREATURE_TYPE_DEMON
2008-11-24 15:15:09 -06:00
&& unitTarget -> GetCreatureType () != CREATURE_TYPE_UNDEAD )
2008-10-19 14:47:43 -05:00
return ;
break ;
}
2009-12-25 13:10:54 -06:00
// Gargoyle Strike
2010-02-15 18:23:39 +01:00
case 51963 :
2009-12-26 14:46:19 -03:00
{
2009-12-17 09:10:04 +01:00
// about +4 base spell dmg per level
damage = ( m_caster -> getLevel () - 60 ) * 4 + 60 ;
break ;
}
2008-10-11 14:16:25 -05:00
}
break ;
}
case SPELLFAMILY_WARRIOR :
{
// Victory Rush
2012-09-09 11:42:31 -05:00
if ( m_spellInfo -> Id == 34428 )
2012-10-02 12:17:42 +02:00
ApplyPct ( damage , m_caster -> GetTotalAttackPowerValue ( BASE_ATTACK ));
2010-02-15 19:09:17 +01:00
// Shockwave
else if ( m_spellInfo -> Id == 46968 )
2009-05-06 18:33:19 +02:00
{
2010-04-11 11:43:23 +04:00
int32 pct = m_caster -> CalculateSpellDamage ( unitTarget , m_spellInfo , 2 );
2009-05-06 18:33:19 +02:00
if ( pct > 0 )
2012-10-02 12:17:42 +02:00
damage += int32 ( CalculatePct ( m_caster -> GetTotalAttackPowerValue ( BASE_ATTACK ), pct ));
2009-05-06 18:33:19 +02:00
break ;
}
2008-10-11 14:16:25 -05:00
break ;
}
case SPELLFAMILY_WARLOCK :
{
// Incinerate Rank 1 & 2
2010-04-07 23:25:02 +02:00
if (( m_spellInfo -> SpellFamilyFlags [ 1 ] & 0x000040 ) && m_spellInfo -> SpellIconID == 2128 )
2008-10-11 14:16:25 -05:00
{
2012-08-17 09:01:48 -05:00
// Incinerate does more dmg (dmg/6) if the target have Immolate debuff.
2009-07-24 09:59:33 +08:00
// Check aura state for speed but aura state set not only for Immolate spell
2010-04-07 19:14:10 +02:00
if ( unitTarget -> HasAuraState ( AURA_STATE_CONFLAGRATE ))
2009-07-24 09:59:33 +08:00
{
2010-01-10 01:23:15 +01:00
if ( unitTarget -> GetAuraEffect ( SPELL_AURA_PERIODIC_DAMAGE , SPELLFAMILY_WARLOCK , 0x4 , 0 , 0 ))
2012-08-17 09:01:48 -05:00
damage += damage / 6 ;
2010-12-20 00:35:11 +01:00
}
2009-06-12 13:01:42 +02:00
}
2008-10-11 14:16:25 -05:00
break ;
}
2008-12-29 17:27:50 -06:00
case SPELLFAMILY_PRIEST :
{
2009-12-17 12:23:01 +01:00
// Improved Mind Blast (Mind Blast in shadow form bonus)
2012-07-10 22:27:29 +02:00
if ( m_caster -> GetShapeshiftForm () == FORM_SHADOW && ( m_spellInfo -> SpellFamilyFlags [ 0 ] & 0x00002000 ))
2009-12-17 12:23:01 +01:00
{
2010-01-10 01:23:15 +01:00
Unit :: AuraEffectList const & ImprMindBlast = m_caster -> GetAuraEffectsByType ( SPELL_AURA_ADD_FLAT_MODIFIER );
2010-04-07 19:12:44 +02:00
for ( Unit :: AuraEffectList :: const_iterator i = ImprMindBlast . begin (); i != ImprMindBlast . end (); ++ i )
2009-12-17 12:23:01 +01:00
{
2011-07-26 23:09:28 +02:00
if (( * i ) -> GetSpellInfo () -> SpellFamilyName == SPELLFAMILY_PRIEST &&
(( * i ) -> GetSpellInfo () -> SpellIconID == 95 ))
2009-12-17 12:23:01 +01:00
{
2011-07-26 23:09:28 +02:00
int chance = ( * i ) -> GetSpellInfo () -> Effects [ EFFECT_1 ]. CalcValue ( m_caster );
2009-12-17 12:23:01 +01:00
if ( roll_chance_i ( chance ))
// Mind Trauma
2010-02-15 18:23:39 +01:00
m_caster -> CastSpell ( unitTarget , 48301 , true , 0 );
2009-12-17 12:23:01 +01:00
break ;
}
}
}
2008-12-29 17:27:50 -06:00
break ;
}
2008-10-11 14:16:25 -05:00
case SPELLFAMILY_DRUID :
{
// Ferocious Bite
2010-04-07 23:25:02 +02:00
if ( m_caster -> GetTypeId () == TYPEID_PLAYER && ( m_spellInfo -> SpellFamilyFlags [ 0 ] & 0x000800000 ) && m_spellInfo -> SpellVisual [ 0 ] == 6587 )
2008-10-11 14:16:25 -05:00
{
2012-08-17 09:01:48 -05:00
// converts each extra point of energy ( up to 25 energy ) into additional damage
int32 energy = - ( m_caster -> ModifyPower ( POWER_ENERGY , - 25 ));
// 25 energy = 100% more damage
2012-10-04 13:33:04 +02:00
AddPct ( damage , energy * 4 );
2009-08-28 14:03:18 +02:00
}
2008-10-11 14:16:25 -05:00
break ;
}
case SPELLFAMILY_ROGUE :
{
// Envenom
2011-12-16 08:15:55 +01:00
if ( m_spellInfo -> SpellFamilyFlags [ 1 ] & 0x00000008 )
2008-10-11 14:16:25 -05:00
{
2011-12-16 08:15:55 +01:00
if ( Player * player = m_caster -> ToPlayer ())
2008-10-11 14:16:25 -05:00
{
2011-12-16 08:15:55 +01:00
// consume from stack dozes not more that have combo-points
if ( uint32 combo = player -> GetComboPoints ())
2009-01-09 16:06:17 -06:00
{
2011-12-16 08:15:55 +01:00
// Lookup for Deadly poison (only attacker applied)
if ( AuraEffect const * aurEff = unitTarget -> GetAuraEffect ( SPELL_AURA_PERIODIC_DAMAGE , SPELLFAMILY_ROGUE , 0x00010000 , 0 , 0 , m_caster -> GetGUID ()))
2009-10-31 17:09:38 -07:00
{
2011-12-16 08:15:55 +01:00
// count consumed deadly poison doses at target
bool needConsume = true ;
uint32 spellId = aurEff -> GetId ();
uint32 doses = aurEff -> GetBase () -> GetStackAmount ();
if ( doses > combo )
doses = combo ;
// Master Poisoner
Unit :: AuraEffectList const & auraList = player -> GetAuraEffectsByType ( SPELL_AURA_MOD_AURA_DURATION_BY_DISPEL_NOT_STACK );
for ( Unit :: AuraEffectList :: const_iterator iter = auraList . begin (); iter != auraList . end (); ++ iter )
2009-10-31 17:09:38 -07:00
{
2011-12-16 08:15:55 +01:00
if (( * iter ) -> GetSpellInfo () -> SpellFamilyName == SPELLFAMILY_ROGUE && ( * iter ) -> GetSpellInfo () -> SpellIconID == 1960 )
{
uint32 chance = ( * iter ) -> GetSpellInfo () -> Effects [ EFFECT_2 ]. CalcValue ( m_caster );
2009-10-31 17:09:38 -07:00
2011-12-16 08:15:55 +01:00
if ( chance && roll_chance_i ( chance ))
needConsume = false ;
2009-10-31 17:09:38 -07:00
2011-12-16 08:15:55 +01:00
break ;
}
2009-10-31 17:09:38 -07:00
}
2011-12-16 08:15:55 +01:00
if ( needConsume )
for ( uint32 i = 0 ; i < doses ; ++ i )
unitTarget -> RemoveAuraFromStack ( spellId );
damage *= doses ;
damage += int32 ( player -> GetTotalAttackPowerValue ( BASE_ATTACK ) * 0.09f * combo );
2009-10-31 17:09:38 -07:00
}
2011-12-16 08:15:55 +01:00
// Eviscerate and Envenom Bonus Damage (item set effect)
if ( m_caster -> HasAura ( 37169 ))
damage += combo * 40 ;
2008-10-11 14:16:25 -05:00
}
}
}
// Eviscerate
2011-12-16 08:15:55 +01:00
else if ( m_spellInfo -> SpellFamilyFlags [ 0 ] & 0x00020000 )
2008-10-11 14:16:25 -05:00
{
2011-12-16 08:15:55 +01:00
if ( m_caster -> GetTypeId () == TYPEID_PLAYER )
2008-10-11 14:16:25 -05:00
{
2011-12-16 08:15:55 +01:00
if ( uint32 combo = (( Player * ) m_caster ) -> GetComboPoints ())
{
float ap = m_caster -> GetTotalAttackPowerValue ( BASE_ATTACK );
damage += irand ( int32 ( ap * combo * 0.03f ), int32 ( ap * combo * 0.07f ));
2009-10-17 15:51:44 -07:00
2011-12-16 08:15:55 +01:00
// Eviscerate and Envenom Bonus Damage (item set effect)
if ( m_caster -> HasAura ( 37169 ))
damage += combo * 40 ;
}
2008-10-11 14:16:25 -05:00
}
}
break ;
}
case SPELLFAMILY_HUNTER :
{
2009-08-02 10:10:13 +08:00
//Gore
if ( m_spellInfo -> SpellIconID == 1578 )
{
2010-02-15 18:23:39 +01:00
if ( m_caster -> HasAura ( 57627 )) // Charge 6 sec post-affect
2009-08-02 10:10:13 +08:00
damage *= 2 ;
}
2008-10-11 14:16:25 -05:00
break ;
}
2009-07-06 00:51:50 +02:00
case SPELLFAMILY_DEATHKNIGHT :
{
// Blood Boil - bonus for diseased targets
2011-05-28 03:12:41 +07:00
if ( m_spellInfo -> SpellFamilyFlags [ 0 ] & 0x00040000 )
2009-07-06 00:51:50 +02:00
{
2011-05-28 03:12:41 +07:00
if ( unitTarget -> GetAuraEffect ( SPELL_AURA_PERIODIC_DAMAGE , SPELLFAMILY_DEATHKNIGHT , 0 , 0 , 0x00000002 , m_caster -> GetGUID ()))
{
damage += m_damage / 2 ;
damage += int32 ( m_caster -> GetTotalAttackPowerValue ( BASE_ATTACK ) * 0.035f );
}
2009-07-06 00:51:50 +02:00
}
break ;
}
2011-09-07 00:19:40 +02:00
case SPELLFAMILY_MAGE :
{
// Deep Freeze should deal damage to permanently stun-immune targets.
if ( m_spellInfo -> Id == 71757 )
2011-09-07 15:09:53 +02:00
if ( unitTarget -> GetTypeId () != TYPEID_UNIT || ! ( unitTarget -> IsImmunedToSpellEffect ( sSpellMgr -> GetSpellInfo ( 44572 ), 0 )))
2011-09-07 00:19:40 +02:00
return ;
break ;
}
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( m_originalCaster && damage > 0 && apply_direct_bonus )
2012-05-30 08:01:02 +02:00
{
damage = m_originalCaster -> SpellDamageBonusDone ( unitTarget , m_spellInfo , ( uint32 ) damage , SPELL_DIRECT_DAMAGE );
damage = unitTarget -> SpellDamageBonusTaken ( m_originalCaster , m_spellInfo , ( uint32 ) damage , SPELL_DIRECT_DAMAGE );
}
2009-10-17 15:51:44 -07:00
2009-01-10 09:29:22 -06:00
m_damage += damage ;
2008-10-11 14:16:25 -05:00
}
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectDummy ( SpellEffIndex effIndex )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2009-10-15 11:50:11 -07:00
if ( ! unitTarget && ! gameObjTarget && ! itemTarget )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2009-01-31 11:09:37 -06:00
uint32 spell_id = 0 ;
int32 bp = 0 ;
2009-06-18 14:17:11 +02:00
bool triggered = true ;
SpellCastTargets targets ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// selection by spell family
2009-10-15 11:50:11 -07:00
switch ( m_spellInfo -> SpellFamilyName )
2008-10-11 14:16:25 -05:00
{
case SPELLFAMILY_PALADIN :
2011-09-29 12:43:05 +02:00
switch ( m_spellInfo -> Id )
2009-04-09 14:58:25 +02:00
{
2008-10-11 14:16:25 -05:00
case 31789 : // Righteous Defense (step 1)
{
// Clear targets for eff 1
2009-10-31 16:00:47 -07:00
for ( std :: list < TargetInfo >:: iterator ihit = m_UniqueTargetInfo . begin (); ihit != m_UniqueTargetInfo . end (); ++ ihit )
2008-10-11 14:16:25 -05:00
ihit -> effectMask &= ~ ( 1 << 1 );
2009-10-17 15:51:44 -07:00
2009-12-17 12:23:01 +01:00
// not empty (checked), copy
2009-12-20 15:11:57 +01:00
Unit :: AttackerSet attackers = unitTarget -> getAttackers ();
2009-10-17 15:51:44 -07:00
2011-06-04 13:18:38 +03:00
// remove invalid attackers
2011-06-12 02:30:32 +02:00
for ( Unit :: AttackerSet :: iterator aItr = attackers . begin (); aItr != attackers . end ();)
2011-09-16 23:49:31 +02:00
if ( ! ( * aItr ) -> IsValidAttackTarget ( m_caster ))
2011-06-04 13:18:38 +03:00
attackers . erase ( aItr ++ );
else
++ aItr ;
2009-12-17 12:23:01 +01:00
// selected from list 3
2011-05-14 14:12:40 +02:00
uint32 maxTargets = std :: min < uint32 > ( 3 , attackers . size ());
for ( uint32 i = 0 ; i < maxTargets ; ++ i )
2008-10-11 14:16:25 -05:00
{
2012-05-30 08:01:02 +02:00
Unit * attacker = Trinity :: Containers :: SelectRandomContainerElement ( attackers );
2011-09-16 11:40:53 +02:00
AddUnitTarget ( attacker , 1 << 1 );
2011-09-15 21:28:40 +03:00
attackers . erase ( attacker );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// now let next effect cast spell at each target.
return ;
}
}
break ;
2009-03-04 00:19:55 +01:00
case SPELLFAMILY_DEATHKNIGHT :
2010-08-18 00:20:23 +06:00
switch ( m_spellInfo -> Id )
2009-04-11 22:41:15 -05:00
{
2012-02-18 12:12:49 +01:00
case 46584 : // Raise Dead
if ( m_caster -> GetTypeId () != TYPEID_PLAYER )
return ;
2009-10-17 15:51:44 -07:00
2012-02-18 12:12:49 +01:00
// Do we have talent Master of Ghouls?
if ( m_caster -> HasAura ( 52143 ))
// summon as pet
bp = 52150 ;
else
// or guardian
bp = 46585 ;
2009-10-17 15:51:44 -07:00
2012-02-18 12:12:49 +01:00
if ( m_targets . HasDst ())
2012-05-30 08:01:02 +02:00
targets . SetDst ( * m_targets . GetDstPos ());
2012-02-18 12:12:49 +01:00
else
{
targets . SetDst ( * m_caster );
// Corpse not found - take reagents (only not triggered cast can take them)
triggered = false ;
}
// Remove cooldown - summon spellls have category
m_caster -> ToPlayer () -> RemoveSpellCooldown ( m_spellInfo -> Id , true );
spell_id = 48289 ;
break ;
// Raise dead - take reagents and trigger summon spells
case 48289 :
if ( m_targets . HasDst ())
2012-05-30 08:01:02 +02:00
targets . SetDst ( * m_targets . GetDstPos ());
2012-02-18 12:12:49 +01:00
spell_id = CalculateDamage ( 0 , NULL );
break ;
2009-08-04 19:28:31 +02:00
}
2009-03-08 03:10:03 +01:00
break ;
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2009-04-03 16:59:01 -06:00
//spells triggered by dummy effect should not miss
2010-04-07 19:14:10 +02:00
if ( spell_id )
2009-04-03 16:59:01 -06:00
{
2011-09-15 14:08:17 +02:00
SpellInfo const * spellInfo = sSpellMgr -> GetSpellInfo ( spell_id );
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( ! spellInfo )
2009-04-03 16:59:01 -06:00
{
2012-08-03 14:20:18 +02:00
sLog -> outError ( LOG_FILTER_SPELLS_AURAS , "EffectDummy of spell %u: triggering unknown spell id %i \n " , m_spellInfo -> Id , spell_id );
2009-04-03 16:59:01 -06:00
return ;
}
2009-10-17 15:51:44 -07:00
2011-06-23 13:28:52 +02:00
targets . SetUnitTarget ( unitTarget );
2011-07-31 19:03:06 +02:00
Spell * spell = new Spell ( m_caster , spellInfo , triggered ? TRIGGERED_FULL_MASK : TRIGGERED_NONE , m_originalCasterGUID , true );
2010-08-27 06:40:23 +02:00
if ( bp ) spell -> SetSpellValue ( SPELLVALUE_BASE_POINT0 , bp );
2009-04-03 16:59:01 -06:00
spell -> prepare ( & targets );
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// pet auras
2011-04-29 20:47:02 +02:00
if ( PetAura const * petSpell = sSpellMgr -> GetPetAura ( m_spellInfo -> Id , effIndex ))
2008-10-11 14:16:25 -05:00
{
m_caster -> AddPetAura ( petSpell );
return ;
}
2009-10-17 15:51:44 -07:00
2010-07-24 21:51:25 +02:00
// normal DB scripted effect
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_SPELLS_AURAS , "Spell ScriptStart spellid %u in EffectDummy(%u)" , m_spellInfo -> Id , effIndex );
2010-08-28 21:01:16 +06:00
m_caster -> GetMap () -> ScriptsStart ( sSpellScripts , uint32 ( m_spellInfo -> Id | ( effIndex << 24 )), m_caster , unitTarget );
2010-07-24 21:51:25 +02:00
2009-03-13 18:34:46 -06:00
// Script based implementation. Must be used only for not good for implementation in core spell effects
// So called only for not proccessed cases
2010-04-07 19:14:10 +02:00
if ( gameObjTarget )
2010-12-22 21:25:23 +01:00
sScriptMgr -> OnDummyEffect ( m_caster , m_spellInfo -> Id , effIndex , gameObjTarget );
2010-04-07 19:14:10 +02:00
else if ( unitTarget && unitTarget -> GetTypeId () == TYPEID_UNIT )
2010-12-22 21:25:23 +01:00
sScriptMgr -> OnDummyEffect ( m_caster , m_spellInfo -> Id , effIndex , unitTarget -> ToCreature ());
2010-04-07 19:14:10 +02:00
else if ( itemTarget )
2010-12-22 21:25:23 +01:00
sScriptMgr -> OnDummyEffect ( m_caster , m_spellInfo -> Id , effIndex , itemTarget );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2011-09-25 13:29:17 +02:00
void Spell :: EffectTriggerSpell ( SpellEffIndex effIndex )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_LAUNCH_TARGET
&& effectHandleMode != SPELL_EFFECT_HANDLE_LAUNCH )
return ;
2011-07-26 23:09:28 +02:00
uint32 triggered_spell_id = m_spellInfo -> Effects [ effIndex ]. TriggerSpell ;
2009-10-17 15:51:44 -07:00
2011-09-25 13:29:17 +02:00
// todo: move those to spell scripts
if ( m_spellInfo -> Effects [ effIndex ]. Effect == SPELL_EFFECT_TRIGGER_SPELL
&& effectHandleMode == SPELL_EFFECT_HANDLE_LAUNCH_TARGET )
{
// special cases
2011-09-29 12:43:05 +02:00
switch ( triggered_spell_id )
2011-09-25 13:29:17 +02:00
{
// Vanish (not exist)
case 18461 :
{
unitTarget -> RemoveMovementImpairingAuras ();
unitTarget -> RemoveAurasByType ( SPELL_AURA_MOD_STALKED );
// If this spell is given to an NPC, it must handle the rest using its own AI
if ( unitTarget -> GetTypeId () != TYPEID_PLAYER )
return ;
// See if we already are stealthed. If so, we're done.
if ( unitTarget -> HasAura ( 1784 ))
return ;
// Reset cooldown on stealth if needed
if ( unitTarget -> ToPlayer () -> HasSpellCooldown ( 1784 ))
unitTarget -> ToPlayer () -> RemoveSpellCooldown ( 1784 );
2011-09-27 00:36:23 +02:00
unitTarget -> CastSpell ( unitTarget , 1784 , true );
return ;
2011-09-25 13:29:17 +02:00
}
// Demonic Empowerment -- succubus
case 54437 :
{
unitTarget -> RemoveMovementImpairingAuras ();
unitTarget -> RemoveAurasByType ( SPELL_AURA_MOD_STALKED );
unitTarget -> RemoveAurasByType ( SPELL_AURA_MOD_STUN );
// Cast Lesser Invisibility
2011-09-27 00:36:23 +02:00
unitTarget -> CastSpell ( unitTarget , 7870 , true );
return ;
2011-09-25 13:29:17 +02:00
}
// Brittle Armor - (need add max stack of 24575 Brittle Armor)
case 29284 :
{
// Brittle Armor
SpellInfo const * spell = sSpellMgr -> GetSpellInfo ( 24575 );
if ( ! spell )
return ;
for ( uint32 j = 0 ; j < spell -> StackAmount ; ++ j )
m_caster -> CastSpell ( unitTarget , spell -> Id , true );
return ;
}
// Mercurial Shield - (need add max stack of 26464 Mercurial Shield)
case 29286 :
{
// Mercurial Shield
SpellInfo const * spell = sSpellMgr -> GetSpellInfo ( 26464 );
if ( ! spell )
return ;
for ( uint32 j = 0 ; j < spell -> StackAmount ; ++ j )
m_caster -> CastSpell ( unitTarget , spell -> Id , true );
return ;
}
// Righteous Defense
case 31980 :
{
m_caster -> CastSpell ( unitTarget , 31790 , true );
return ;
}
// Cloak of Shadows
case 35729 :
{
uint32 dispelMask = SpellInfo :: GetDispelMask ( DISPEL_ALL );
Unit :: AuraApplicationMap & Auras = unitTarget -> GetAppliedAuras ();
for ( Unit :: AuraApplicationMap :: iterator iter = Auras . begin (); iter != Auras . end ();)
{
// remove all harmful spells on you...
SpellInfo const * spell = iter -> second -> GetBase () -> GetSpellInfo ();
if (( spell -> DmgClass == SPELL_DAMAGE_CLASS_MAGIC // only affect magic spells
|| (( spell -> GetDispelMask ()) & dispelMask ))
// ignore positive and passive auras
&& ! iter -> second -> IsPositive () && ! iter -> second -> GetBase () -> IsPassive ())
{
m_caster -> RemoveAura ( iter );
}
else
++ iter ;
}
return ;
}
}
}
2008-10-11 14:16:25 -05:00
// normal case
2011-09-15 14:08:17 +02:00
SpellInfo const * spellInfo = sSpellMgr -> GetSpellInfo ( triggered_spell_id );
2010-04-07 19:14:10 +02:00
if ( ! spellInfo )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
sLog -> outDebug ( LOG_FILTER_SPELLS_AURAS , "Spell::EffectTriggerSpell spell %u tried to trigger unknown spell %u" , m_spellInfo -> Id , triggered_spell_id );
2008-10-11 14:16:25 -05:00
return ;
}
2009-10-17 15:51:44 -07:00
2011-09-25 13:29:17 +02:00
SpellCastTargets targets ;
if ( effectHandleMode == SPELL_EFFECT_HANDLE_LAUNCH_TARGET )
{
if ( ! spellInfo -> NeedsToBeTriggeredByCaster ())
return ;
targets . SetUnitTarget ( unitTarget );
}
else //if (effectHandleMode == SPELL_EFFECT_HANDLE_LAUNCH)
{
2011-09-28 18:59:08 +02:00
if ( spellInfo -> NeedsToBeTriggeredByCaster () && ( m_spellInfo -> Effects [ effIndex ]. GetProvidedTargetMask () & TARGET_FLAG_UNIT_MASK ))
2011-09-25 13:29:17 +02:00
return ;
2011-07-26 23:09:28 +02:00
2011-09-25 13:29:17 +02:00
if ( spellInfo -> GetExplicitTargetMask () & TARGET_FLAG_DEST_LOCATION )
targets . SetDst ( m_targets );
targets . SetUnitTarget ( m_caster );
}
2010-04-07 18:09:10 +02:00
2011-09-25 13:29:17 +02:00
CustomSpellValues values ;
// set basepoints for trigger with value effect
if ( m_spellInfo -> Effects [ effIndex ]. Effect == SPELL_EFFECT_TRIGGER_SPELL_WITH_VALUE )
{
// maybe need to set value only when basepoints == 0?
values . AddSpellMod ( SPELLVALUE_BASE_POINT0 , damage );
values . AddSpellMod ( SPELLVALUE_BASE_POINT1 , damage );
values . AddSpellMod ( SPELLVALUE_BASE_POINT2 , damage );
}
// Remove spell cooldown (not category) if spell triggering spell with cooldown and same category
if ( m_caster -> GetTypeId () == TYPEID_PLAYER && m_spellInfo -> CategoryRecoveryTime && spellInfo -> CategoryRecoveryTime
&& m_spellInfo -> Category == spellInfo -> Category )
m_caster -> ToPlayer () -> RemoveSpellCooldown ( spellInfo -> Id );
// original caster guid only for GO cast
m_caster -> CastSpell ( targets , spellInfo , & values , TRIGGERED_FULL_MASK , NULL , NULL , m_originalCasterGUID );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2011-09-25 13:29:17 +02:00
void Spell :: EffectTriggerMissileSpell ( SpellEffIndex effIndex )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET
&& effectHandleMode != SPELL_EFFECT_HANDLE_HIT )
return ;
2011-07-26 23:09:28 +02:00
uint32 triggered_spell_id = m_spellInfo -> Effects [ effIndex ]. TriggerSpell ;
2009-10-17 15:51:44 -07:00
2011-09-25 13:29:17 +02:00
// normal case
SpellInfo const * spellInfo = sSpellMgr -> GetSpellInfo ( triggered_spell_id );
2010-04-07 19:14:10 +02:00
if ( ! spellInfo )
2008-10-11 14:16:25 -05:00
{
2012-05-30 08:01:02 +02:00
sLog -> outDebug ( LOG_FILTER_SPELLS_AURAS , "Spell::EffectTriggerMissileSpell spell %u tried to trigger unknown spell %u" , m_spellInfo -> Id , triggered_spell_id );
2008-10-11 14:16:25 -05:00
return ;
}
2009-10-17 15:51:44 -07:00
2011-09-25 13:29:17 +02:00
SpellCastTargets targets ;
if ( effectHandleMode == SPELL_EFFECT_HANDLE_HIT_TARGET )
{
if ( ! spellInfo -> NeedsToBeTriggeredByCaster ())
return ;
targets . SetUnitTarget ( unitTarget );
}
else //if (effectHandleMode == SPELL_EFFECT_HANDLE_HIT)
{
2011-09-28 18:59:08 +02:00
if ( spellInfo -> NeedsToBeTriggeredByCaster () && ( m_spellInfo -> Effects [ effIndex ]. GetProvidedTargetMask () & TARGET_FLAG_UNIT_MASK ))
2011-09-25 13:29:17 +02:00
return ;
if ( spellInfo -> GetExplicitTargetMask () & TARGET_FLAG_DEST_LOCATION )
targets . SetDst ( m_targets );
targets . SetUnitTarget ( m_caster );
}
CustomSpellValues values ;
// set basepoints for trigger with value effect
if ( m_spellInfo -> Effects [ effIndex ]. Effect == SPELL_EFFECT_TRIGGER_MISSILE_SPELL_WITH_VALUE )
{
// maybe need to set value only when basepoints == 0?
values . AddSpellMod ( SPELLVALUE_BASE_POINT0 , damage );
values . AddSpellMod ( SPELLVALUE_BASE_POINT1 , damage );
values . AddSpellMod ( SPELLVALUE_BASE_POINT2 , damage );
}
2009-10-17 15:51:44 -07:00
2011-09-25 13:29:17 +02:00
// Remove spell cooldown (not category) if spell triggering spell with cooldown and same category
if ( m_caster -> GetTypeId () == TYPEID_PLAYER && m_spellInfo -> CategoryRecoveryTime && spellInfo -> CategoryRecoveryTime
&& m_spellInfo -> Category == spellInfo -> Category )
m_caster -> ToPlayer () -> RemoveSpellCooldown ( spellInfo -> Id );
// original caster guid only for GO cast
m_caster -> CastSpell ( targets , spellInfo , & values , TRIGGERED_FULL_MASK , NULL , NULL , m_originalCasterGUID );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectForceCast ( SpellEffIndex effIndex )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2010-04-07 22:59:46 +02:00
if ( ! unitTarget )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2011-07-26 23:09:28 +02:00
uint32 triggered_spell_id = m_spellInfo -> Effects [ effIndex ]. TriggerSpell ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// normal case
2011-09-15 14:08:17 +02:00
SpellInfo const * spellInfo = sSpellMgr -> GetSpellInfo ( triggered_spell_id );
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( ! spellInfo )
2008-10-11 14:16:25 -05:00
{
2012-08-03 14:20:18 +02:00
sLog -> outError ( LOG_FILTER_SPELLS_AURAS , "Spell::EffectForceCast of spell %u: triggering unknown spell id %i" , m_spellInfo -> Id , triggered_spell_id );
2008-10-11 14:16:25 -05:00
return ;
}
2009-10-17 15:51:44 -07:00
2011-09-25 13:29:17 +02:00
if ( m_spellInfo -> Effects [ effIndex ]. Effect == SPELL_EFFECT_FORCE_CAST && damage )
2009-08-15 20:36:21 -05:00
{
2011-01-12 22:50:51 +01:00
switch ( m_spellInfo -> Id )
2009-08-15 20:36:21 -05:00
{
2011-07-07 18:02:04 +02:00
case 52588 : // Skeletal Gryphon Escape
2010-02-20 23:57:54 +01:00
case 48598 : // Ride Flamebringer Cue
2010-04-07 18:09:10 +02:00
unitTarget -> RemoveAura ( damage );
2010-02-20 23:57:54 +01:00
break ;
case 52463 : // Hide In Mine Car
case 52349 : // Overtake
unitTarget -> CastCustomSpell ( unitTarget , spellInfo -> Id , & damage , NULL , NULL , true , NULL , NULL , m_originalCasterGUID );
return ;
2009-08-15 20:36:21 -05:00
}
}
2010-07-19 22:52:21 +02:00
2011-09-25 13:29:17 +02:00
CustomSpellValues values ;
// set basepoints for trigger with value effect
if ( m_spellInfo -> Effects [ effIndex ]. Effect == SPELL_EFFECT_FORCE_CAST_WITH_VALUE )
2010-07-19 22:52:21 +02:00
{
2011-09-25 13:29:17 +02:00
// maybe need to set value only when basepoints == 0?
values . AddSpellMod ( SPELLVALUE_BASE_POINT0 , damage );
values . AddSpellMod ( SPELLVALUE_BASE_POINT1 , damage );
values . AddSpellMod ( SPELLVALUE_BASE_POINT2 , damage );
2010-07-19 22:52:21 +02:00
}
2010-12-27 11:06:53 +01:00
2011-09-25 13:29:17 +02:00
SpellCastTargets targets ;
targets . SetUnitTarget ( m_caster );
unitTarget -> CastSpell ( targets , spellInfo , & values , TRIGGERED_FULL_MASK );
2010-07-19 22:52:21 +02:00
}
2011-09-25 13:29:17 +02:00
void Spell :: EffectTriggerRitualOfSummoning ( SpellEffIndex effIndex )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2011-07-26 23:09:28 +02:00
uint32 triggered_spell_id = m_spellInfo -> Effects [ effIndex ]. TriggerSpell ;
2011-09-15 14:08:17 +02:00
SpellInfo const * spellInfo = sSpellMgr -> GetSpellInfo ( triggered_spell_id );
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( ! spellInfo )
2008-10-11 14:16:25 -05:00
{
2012-08-03 14:20:18 +02:00
sLog -> outError ( LOG_FILTER_SPELLS_AURAS , "EffectTriggerRitualOfSummoning of spell %u: triggering unknown spell id %i" , m_spellInfo -> Id , triggered_spell_id );
2008-10-11 14:16:25 -05:00
return ;
}
2009-10-17 15:51:44 -07:00
2011-09-25 13:29:17 +02:00
finish ();
2009-10-17 15:51:44 -07:00
2011-09-25 13:29:17 +02:00
m_caster -> CastSpell (( Unit * ) NULL , spellInfo , false );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectJump ( SpellEffIndex effIndex )
2010-07-19 21:24:09 +02:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_LAUNCH_TARGET )
return ;
2010-07-19 21:24:09 +02:00
if ( m_caster -> isInFlight ())
return ;
2011-09-25 13:29:17 +02:00
if ( ! unitTarget )
2010-07-19 21:24:09 +02:00
return ;
2011-09-25 13:29:17 +02:00
float x , y , z ;
unitTarget -> GetContactPoint ( m_caster , x , y , z , CONTACT_DISTANCE );
2010-07-19 21:24:09 +02:00
float speedXY , speedZ ;
2010-08-27 19:36:27 +02:00
CalculateJumpSpeeds ( effIndex , m_caster -> GetExactDist2d ( x , y ), speedXY , speedZ );
2010-07-19 21:24:09 +02:00
m_caster -> GetMotionMaster () -> MoveJump ( x , y , z , speedXY , speedZ );
}
2010-08-27 19:36:27 +02:00
void Spell :: EffectJumpDest ( SpellEffIndex effIndex )
2009-03-12 14:50:14 -06:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_LAUNCH )
return ;
2010-04-07 19:14:10 +02:00
if ( m_caster -> isInFlight ())
2009-03-12 14:50:14 -06:00
return ;
2009-10-17 15:51:44 -07:00
2011-09-25 13:29:17 +02:00
if ( ! m_targets . HasDst ())
return ;
2009-03-12 14:50:14 -06:00
// Init dest coordinates
2011-05-12 10:41:25 +02:00
float x , y , z ;
2012-05-30 08:01:02 +02:00
destTarget -> GetPosition ( x , y , z );
2009-10-17 15:51:44 -07:00
2010-07-19 21:24:09 +02:00
float speedXY , speedZ ;
2010-08-27 19:36:27 +02:00
CalculateJumpSpeeds ( effIndex , m_caster -> GetExactDist2d ( x , y ), speedXY , speedZ );
2010-07-19 21:24:09 +02:00
m_caster -> GetMotionMaster () -> MoveJump ( x , y , z , speedXY , speedZ );
}
void Spell :: CalculateJumpSpeeds ( uint8 i , float dist , float & speedXY , float & speedZ )
{
2011-07-26 23:09:28 +02:00
if ( m_spellInfo -> Effects [ i ]. MiscValue )
speedZ = float ( m_spellInfo -> Effects [ i ]. MiscValue ) / 10 ;
else if ( m_spellInfo -> Effects [ i ]. MiscValueB )
speedZ = float ( m_spellInfo -> Effects [ i ]. MiscValueB ) / 10 ;
2009-04-11 22:41:15 -05:00
else
speedZ = 10.0f ;
2010-07-19 21:24:09 +02:00
speedXY = dist * 10.0f / speedZ ;
2009-03-12 14:50:14 -06:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectTeleportUnits ( SpellEffIndex /*effIndex*/ )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2009-10-30 18:54:38 -07:00
if ( ! unitTarget || unitTarget -> isInFlight ())
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2010-06-20 04:34:58 +02:00
// Pre effects
uint8 uiMaxSafeLevel = 0 ;
switch ( m_spellInfo -> Id )
{
case 48129 : // Scroll of Recall
uiMaxSafeLevel = 40 ;
case 60320 : // Scroll of Recall II
if ( ! uiMaxSafeLevel )
uiMaxSafeLevel = 70 ;
case 60321 : // Scroll of Recal III
if ( ! uiMaxSafeLevel )
uiMaxSafeLevel = 80 ;
2010-08-08 19:45:53 +02:00
2010-06-20 04:34:58 +02:00
if ( unitTarget -> getLevel () > uiMaxSafeLevel )
{
2011-04-29 20:47:02 +02:00
unitTarget -> AddAura ( 60444 , unitTarget ); //Apply Lost! Aura
2012-09-13 15:19:52 +03:00
// ALLIANCE from 60323 to 60330 - HORDE from 60328 to 60335
uint32 spellId = 60323 ;
if ( m_caster -> ToPlayer () -> GetTeam () == HORDE )
spellId += 5 ;
spellId += urand ( 0 , 7 );
m_caster -> CastSpell ( m_caster , spellId , true );
2010-06-20 04:34:58 +02:00
return ;
}
break ;
2011-01-09 00:00:08 -03:00
case 66550 : // teleports outside (Isle of Conquest)
2011-10-07 19:45:43 -05:00
if ( Player * target = unitTarget -> ToPlayer ())
2011-01-09 00:00:08 -03:00
{
2011-10-07 19:45:43 -05:00
if ( target -> GetTeamId () == TEAM_ALLIANCE )
2011-06-23 13:28:52 +02:00
m_targets . SetDst ( 442.24f , - 835.25f , 44.30f , 0.06f , 628 );
2011-01-09 00:00:08 -03:00
else
2011-06-23 13:28:52 +02:00
m_targets . SetDst ( 1120.43f , - 762.11f , 47.92f , 2.94f , 628 );
2011-01-09 00:00:08 -03:00
}
break ;
case 66551 : // teleports inside (Isle of Conquest)
2011-10-07 19:45:43 -05:00
if ( Player * target = unitTarget -> ToPlayer ())
2011-01-09 00:00:08 -03:00
{
2011-10-07 19:45:43 -05:00
if ( target -> GetTeamId () == TEAM_ALLIANCE )
2011-06-23 13:28:52 +02:00
m_targets . SetDst ( 389.57f , - 832.38f , 48.65f , 3.00f , 628 );
2011-01-09 00:00:08 -03:00
else
2011-06-23 13:28:52 +02:00
m_targets . SetDst ( 1174.85f , - 763.24f , 48.72f , 6.26f , 628 );
2011-01-09 00:00:08 -03:00
}
break ;
2010-06-20 04:34:58 +02:00
}
2008-11-01 15:08:12 -05:00
// If not exist data for dest location - return
2009-10-30 18:54:38 -07:00
if ( ! m_targets . HasDst ())
2008-11-01 15:08:12 -05:00
{
2012-08-03 14:20:18 +02:00
sLog -> outError ( LOG_FILTER_SPELLS_AURAS , "Spell::EffectTeleportUnits - does not have destination for spell ID %u \n " , m_spellInfo -> Id );
2009-03-09 19:17:12 -06:00
return ;
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2009-03-09 19:17:12 -06:00
// Init dest coordinates
2012-05-30 08:01:02 +02:00
uint32 mapid = destTarget -> GetMapId ();
2009-11-07 18:47:11 +01:00
if ( mapid == MAPID_INVALID )
2009-10-30 18:54:38 -07:00
mapid = unitTarget -> GetMapId ();
2009-11-07 18:47:11 +01:00
float x , y , z , orientation ;
2012-05-30 08:01:02 +02:00
destTarget -> GetPosition ( x , y , z , orientation );
2011-06-23 13:28:52 +02:00
if ( ! orientation && m_targets . GetUnitTarget ())
orientation = m_targets . GetUnitTarget () -> GetOrientation ();
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_SPELLS_AURAS , "Spell::EffectTeleportUnits - teleport unit to %u %f %f %f %f \n " , mapid , x , y , z , orientation );
2009-10-17 15:51:44 -07:00
2009-11-07 18:47:11 +01:00
if ( mapid == unitTarget -> GetMapId ())
2009-03-13 18:28:10 -06:00
unitTarget -> NearTeleportTo ( x , y , z , orientation , unitTarget == m_caster );
2010-04-07 19:14:10 +02:00
else if ( unitTarget -> GetTypeId () == TYPEID_PLAYER )
2010-03-07 15:20:19 +01:00
unitTarget -> ToPlayer () -> TeleportTo ( mapid , x , y , z , orientation , unitTarget == m_caster ? TELE_TO_SPELL : 0 );
2009-10-17 15:51:44 -07:00
2011-08-16 19:44:18 +02:00
// post effects for TARGET_DEST_DB
2009-10-30 18:54:38 -07:00
switch ( m_spellInfo -> Id )
2008-10-11 14:16:25 -05:00
{
// Dimensional Ripper - Everlook
case 23442 :
{
int32 r = irand ( 0 , 119 );
2010-04-07 22:59:46 +02:00
if ( r >= 70 ) // 7/12 success
2008-10-11 14:16:25 -05:00
{
2010-04-07 22:59:46 +02:00
if ( r < 100 ) // 4/12 evil twin
2009-05-31 15:56:51 -05:00
m_caster -> CastSpell ( m_caster , 23445 , true );
2008-10-11 14:16:25 -05:00
else // 1/12 fire
2009-05-31 15:56:51 -05:00
m_caster -> CastSpell ( m_caster , 23449 , true );
2008-10-11 14:16:25 -05:00
}
return ;
}
// Ultrasafe Transporter: Toshley's Station
case 36941 :
{
2010-04-07 22:59:46 +02:00
if ( roll_chance_i ( 50 )) // 50% success
2008-10-11 14:16:25 -05:00
{
2009-05-31 15:56:51 -05:00
int32 rand_eff = urand ( 1 , 7 );
2010-04-07 22:59:46 +02:00
switch ( rand_eff )
2008-10-11 14:16:25 -05:00
{
case 1 :
// soul split - evil
2009-05-31 15:56:51 -05:00
m_caster -> CastSpell ( m_caster , 36900 , true );
2008-10-11 14:16:25 -05:00
break ;
case 2 :
// soul split - good
2009-05-31 15:56:51 -05:00
m_caster -> CastSpell ( m_caster , 36901 , true );
2008-10-11 14:16:25 -05:00
break ;
case 3 :
// Increase the size
2009-05-31 15:56:51 -05:00
m_caster -> CastSpell ( m_caster , 36895 , true );
2008-10-11 14:16:25 -05:00
break ;
case 4 :
// Decrease the size
2009-05-31 15:56:51 -05:00
m_caster -> CastSpell ( m_caster , 36893 , true );
2008-10-11 14:16:25 -05:00
break ;
case 5 :
// Transform
{
2010-04-07 22:59:46 +02:00
if ( m_caster -> ToPlayer () -> GetTeam () == ALLIANCE )
2009-05-31 15:56:51 -05:00
m_caster -> CastSpell ( m_caster , 36897 , true );
2008-10-11 14:16:25 -05:00
else
2009-05-31 15:56:51 -05:00
m_caster -> CastSpell ( m_caster , 36899 , true );
2008-10-11 14:16:25 -05:00
break ;
}
case 6 :
// chicken
2009-05-31 15:56:51 -05:00
m_caster -> CastSpell ( m_caster , 36940 , true );
2008-10-11 14:16:25 -05:00
break ;
case 7 :
// evil twin
2009-05-31 15:56:51 -05:00
m_caster -> CastSpell ( m_caster , 23445 , true );
2008-10-11 14:16:25 -05:00
break ;
}
}
return ;
}
// Dimensional Ripper - Area 52
case 36890 :
{
2010-04-07 22:59:46 +02:00
if ( roll_chance_i ( 50 )) // 50% success
2008-10-11 14:16:25 -05:00
{
2009-05-31 15:56:51 -05:00
int32 rand_eff = urand ( 1 , 4 );
2010-04-07 22:59:46 +02:00
switch ( rand_eff )
2008-10-11 14:16:25 -05:00
{
case 1 :
// soul split - evil
2009-05-31 15:56:51 -05:00
m_caster -> CastSpell ( m_caster , 36900 , true );
2008-10-11 14:16:25 -05:00
break ;
case 2 :
// soul split - good
2009-05-31 15:56:51 -05:00
m_caster -> CastSpell ( m_caster , 36901 , true );
2008-10-11 14:16:25 -05:00
break ;
case 3 :
// Increase the size
2009-05-31 15:56:51 -05:00
m_caster -> CastSpell ( m_caster , 36895 , true );
2008-10-11 14:16:25 -05:00
break ;
case 4 :
2010-10-04 20:32:10 +02:00
// Transform
2008-10-11 14:16:25 -05:00
{
2010-04-07 22:59:46 +02:00
if ( m_caster -> ToPlayer () -> GetTeam () == ALLIANCE )
2009-05-31 15:56:51 -05:00
m_caster -> CastSpell ( m_caster , 36897 , true );
2008-10-11 14:16:25 -05:00
else
2009-05-31 15:56:51 -05:00
m_caster -> CastSpell ( m_caster , 36899 , true );
2008-10-11 14:16:25 -05:00
break ;
}
}
}
return ;
}
}
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectApplyAura ( SpellEffIndex effIndex )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2010-02-07 18:16:53 +01:00
if ( ! m_spellAura || ! unitTarget )
2010-01-10 01:23:15 +01:00
return ;
2010-07-30 20:04:28 +02:00
ASSERT ( unitTarget == m_spellAura -> GetOwner ());
2010-08-27 19:36:27 +02:00
m_spellAura -> _ApplyEffectForTargets ( effIndex );
2009-05-02 17:43:41 +02:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectApplyAreaAura ( SpellEffIndex effIndex )
2009-05-02 17:43:41 +02:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2010-02-07 18:16:53 +01:00
if ( ! m_spellAura || ! unitTarget )
2010-01-10 01:23:15 +01:00
return ;
2010-07-30 20:04:28 +02:00
ASSERT ( unitTarget == m_spellAura -> GetOwner ());
2010-08-27 19:36:27 +02:00
m_spellAura -> _ApplyEffectForTargets ( effIndex );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectUnlearnSpecialization ( SpellEffIndex effIndex )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2010-04-07 19:14:10 +02:00
if ( ! unitTarget || unitTarget -> GetTypeId () != TYPEID_PLAYER )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2011-12-10 15:40:55 +01:00
Player * player = unitTarget -> ToPlayer ();
2011-07-26 23:09:28 +02:00
uint32 spellToUnlearn = m_spellInfo -> Effects [ effIndex ]. TriggerSpell ;
2009-10-17 15:51:44 -07:00
2011-12-10 15:40:55 +01:00
player -> removeSpell ( spellToUnlearn );
2009-10-17 15:51:44 -07:00
2011-12-10 16:26:04 +01:00
sLog -> outDebug ( LOG_FILTER_SPELLS_AURAS , "Spell: Player %u has unlearned spell %u from NpcGUID: %u" , player -> GetGUIDLow (), spellToUnlearn , m_caster -> GetGUIDLow ());
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectPowerDrain ( SpellEffIndex effIndex )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2011-07-26 23:09:28 +02:00
if ( m_spellInfo -> Effects [ effIndex ]. MiscValue < 0 || m_spellInfo -> Effects [ effIndex ]. MiscValue >= int8 ( MAX_POWERS ))
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2011-07-26 23:09:28 +02:00
Powers powerType = Powers ( m_spellInfo -> Effects [ effIndex ]. MiscValue );
2009-10-17 15:51:44 -07:00
2010-08-26 19:07:55 +02:00
if ( ! unitTarget || ! unitTarget -> isAlive () || unitTarget -> getPowerType () != powerType || damage < 0 )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2010-08-26 19:07:55 +02:00
// add spell damage bonus
2012-05-30 08:01:02 +02:00
damage = m_caster -> SpellDamageBonusDone ( unitTarget , m_spellInfo , uint32 ( damage ), SPELL_DIRECT_DAMAGE );
damage = unitTarget -> SpellDamageBonusTaken ( m_caster , m_spellInfo , uint32 ( damage ), SPELL_DIRECT_DAMAGE );
2009-10-17 15:51:44 -07:00
2012-12-20 19:22:14 +01:00
int32 newDamage = - ( unitTarget -> ModifyPower ( powerType , - damage ));
2009-10-17 15:51:44 -07:00
2010-08-27 17:49:32 +02:00
float gainMultiplier = 0.0f ;
2012-12-20 19:22:14 +01:00
// Don't restore from self drain
2010-08-26 19:07:55 +02:00
if ( m_caster != unitTarget )
2008-10-11 14:16:25 -05:00
{
2011-07-26 23:09:28 +02:00
gainMultiplier = m_spellInfo -> Effects [ effIndex ]. CalcValueMultiplier ( m_originalCaster , this );
2009-10-17 15:51:44 -07:00
2011-09-15 14:08:17 +02:00
int32 gain = int32 ( newDamage * gainMultiplier );
2009-10-17 15:51:44 -07:00
2010-08-26 19:07:55 +02:00
m_caster -> EnergizeBySpell ( m_caster , m_spellInfo -> Id , gain , powerType );
2008-10-11 14:16:25 -05:00
}
2010-08-27 19:36:27 +02:00
ExecuteLogEffectTakeTargetPower ( effIndex , unitTarget , powerType , newDamage , gainMultiplier );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectSendEvent ( SpellEffIndex effIndex )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
// we do not handle a flag dropping or clicking on flag in battleground by sendevent system
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET
&& effectHandleMode != SPELL_EFFECT_HANDLE_HIT )
return ;
2010-01-21 23:57:14 +01:00
2011-09-30 18:41:30 +02:00
WorldObject * target = NULL ;
2011-09-25 13:29:17 +02:00
2011-12-23 23:52:22 +01:00
// call events for object target if present
2011-09-25 13:29:17 +02:00
if ( effectHandleMode == SPELL_EFFECT_HANDLE_HIT_TARGET )
{
if ( unitTarget )
target = unitTarget ;
else if ( gameObjTarget )
target = gameObjTarget ;
}
2011-12-23 23:52:22 +01:00
else // if (effectHandleMode == SPELL_EFFECT_HANDLE_HIT)
2011-09-25 13:29:17 +02:00
{
2011-12-23 23:52:22 +01:00
// let's prevent executing effect handler twice in case when spell effect is capable of targeting an object
// this check was requested by scripters, but it has some downsides:
// now it's impossible to script (using sEventScripts) a cast which misses all targets
// or to have an ability to script the moment spell hits dest (in a case when there are object targets present)
if ( m_spellInfo -> Effects [ effIndex ]. GetProvidedTargetMask () & ( TARGET_FLAG_UNIT_MASK | TARGET_FLAG_GAMEOBJECT_MASK ))
return ;
// some spells have no target entries in dbc and they use focus target
2011-09-25 13:29:17 +02:00
if ( focusObject )
target = focusObject ;
// TODO: there should be a possibility to pass dest target to event script
}
sLog -> outDebug ( LOG_FILTER_SPELLS_AURAS , "Spell ScriptStart %u for spellid %u in EffectSendEvent " , m_spellInfo -> Effects [ effIndex ]. MiscValue , m_spellInfo -> Id );
2010-01-21 23:57:14 +01:00
2011-07-22 21:22:05 +02:00
if ( ZoneScript * zoneScript = m_caster -> GetZoneScript ())
2011-09-30 18:41:30 +02:00
zoneScript -> ProcessEvent ( target , m_spellInfo -> Effects [ effIndex ]. MiscValue );
else if ( InstanceScript * instanceScript = m_caster -> GetInstanceScript ()) // needed in case Player is the caster
instanceScript -> ProcessEvent ( target , m_spellInfo -> Effects [ effIndex ]. MiscValue );
2011-01-20 12:27:08 -03:00
2011-07-26 23:09:28 +02:00
m_caster -> GetMap () -> ScriptsStart ( sEventScripts , m_spellInfo -> Effects [ effIndex ]. MiscValue , m_caster , target );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectPowerBurn ( SpellEffIndex effIndex )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2011-07-26 23:09:28 +02:00
if ( m_spellInfo -> Effects [ effIndex ]. MiscValue < 0 || m_spellInfo -> Effects [ effIndex ]. MiscValue >= int8 ( MAX_POWERS ))
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2011-07-26 23:09:28 +02:00
Powers powerType = Powers ( m_spellInfo -> Effects [ effIndex ]. MiscValue );
2009-10-17 15:51:44 -07:00
2010-08-26 19:07:55 +02:00
if ( ! unitTarget || ! unitTarget -> isAlive () || unitTarget -> getPowerType () != powerType || damage < 0 )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2009-04-03 16:33:25 -06:00
// burn x% of target's mana, up to maximum of 2x% of caster's mana (Mana Burn)
2011-07-13 20:39:17 +02:00
if ( m_spellInfo -> Id == 8129 )
2009-04-03 16:33:25 -06:00
{
2012-10-02 12:17:42 +02:00
int32 maxDamage = int32 ( CalculatePct ( m_caster -> GetMaxPower ( powerType ), damage * 2 ));
damage = int32 ( CalculatePct ( unitTarget -> GetMaxPower ( powerType ), damage ));
2010-08-27 20:51:29 +02:00
damage = std :: min ( damage , maxDamage );
2009-04-03 16:33:25 -06:00
}
2009-10-17 15:51:44 -07:00
2012-12-20 19:22:14 +01:00
int32 newDamage = - ( unitTarget -> ModifyPower ( powerType , - damage ));
2009-10-17 15:51:44 -07:00
2010-08-26 19:07:55 +02:00
// NO - Not a typo - EffectPowerBurn uses effect value multiplier - not effect damage multiplier
2011-07-26 23:09:28 +02:00
float dmgMultiplier = m_spellInfo -> Effects [ effIndex ]. CalcValueMultiplier ( m_originalCaster , this );
2009-10-17 15:51:44 -07:00
2010-09-25 15:03:48 +02:00
// add log data before multiplication (need power amount, not damage)
ExecuteLogEffectTakeTargetPower ( effIndex , unitTarget , powerType , newDamage , 0.0f );
2009-10-17 15:51:44 -07:00
2011-09-15 14:08:17 +02:00
newDamage = int32 ( newDamage * dmgMultiplier );
2010-08-27 17:49:32 +02:00
2010-08-29 05:26:32 +02:00
m_damage += newDamage ;
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectHeal ( SpellEffIndex /*effIndex*/ )
2008-12-25 17:39:46 -06:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_LAUNCH_TARGET )
return ;
2009-10-17 15:51:44 -07:00
2010-04-07 22:59:46 +02:00
if ( unitTarget && unitTarget -> isAlive () && damage >= 0 )
2008-10-11 14:16:25 -05:00
{
// Try to get original caster
2011-06-20 04:04:20 +07:00
Unit * caster = m_originalCasterGUID ? m_originalCaster : m_caster ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// Skip if m_originalCaster not available
if ( ! caster )
return ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
int32 addhealth = damage ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// Vessel of the Naaru (Vial of the Sunwell trinket)
if ( m_spellInfo -> Id == 45064 )
{
// Amount of heal - depends from stacked Holy Energy
int damageAmount = 0 ;
2011-06-11 22:35:29 +02:00
if ( AuraEffect const * aurEff = m_caster -> GetAuraEffect ( 45062 , 0 ))
2009-08-08 16:18:05 +02:00
{
damageAmount += aurEff -> GetAmount ();
2008-10-11 14:16:25 -05:00
m_caster -> RemoveAurasDueToSpell ( 45062 );
2009-08-08 16:18:05 +02:00
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
addhealth += damageAmount ;
}
2011-11-02 19:23:59 +07:00
// Runic Healing Injector (heal increased by 25% for engineers - 3.2.0 patch change)
else if ( m_spellInfo -> Id == 67489 )
{
if ( Player * player = m_caster -> ToPlayer ())
2011-11-03 17:08:30 +07:00
if ( player -> HasSkill ( SKILL_ENGINEERING ))
2012-10-02 12:17:42 +02:00
AddPct ( addhealth , 25 );
2011-11-02 19:23:59 +07:00
}
2008-10-11 14:16:25 -05:00
// Swiftmend - consumes Regrowth or Rejuvenation
2009-03-18 19:53:36 +01:00
else if ( m_spellInfo -> TargetAuraState == AURA_STATE_SWIFTMEND && unitTarget -> HasAuraState ( AURA_STATE_SWIFTMEND , m_spellInfo , m_caster ))
2008-10-11 14:16:25 -05:00
{
2010-01-10 01:23:15 +01:00
Unit :: AuraEffectList const & RejorRegr = unitTarget -> GetAuraEffectsByType ( SPELL_AURA_PERIODIC_HEAL );
2008-10-11 14:16:25 -05:00
// find most short by duration
2011-09-15 14:08:17 +02:00
AuraEffect * targetAura = NULL ;
2009-10-17 16:20:24 -07:00
for ( Unit :: AuraEffectList :: const_iterator i = RejorRegr . begin (); i != RejorRegr . end (); ++ i )
2008-10-11 14:16:25 -05:00
{
2011-07-26 23:09:28 +02:00
if (( * i ) -> GetSpellInfo () -> SpellFamilyName == SPELLFAMILY_DRUID
&& ( * i ) -> GetSpellInfo () -> SpellFamilyFlags [ 0 ] & 0x50 )
2008-10-11 14:16:25 -05:00
{
2010-04-07 19:14:10 +02:00
if ( ! targetAura || ( * i ) -> GetBase () -> GetDuration () < targetAura -> GetBase () -> GetDuration ())
2008-10-11 14:16:25 -05:00
targetAura = * i ;
}
}
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( ! targetAura )
2008-10-11 14:16:25 -05:00
{
2012-08-03 14:20:18 +02:00
sLog -> outError ( LOG_FILTER_SPELLS_AURAS , "Target(GUID:" UI64FMTD ") has aurastate AURA_STATE_SWIFTMEND but no matching aura." , unitTarget -> GetGUID ());
2008-10-11 14:16:25 -05:00
return ;
}
2009-10-17 15:51:44 -07:00
2009-04-06 13:31:14 +02:00
int32 tickheal = targetAura -> GetAmount ();
2010-04-07 19:14:10 +02:00
if ( Unit * auraCaster = targetAura -> GetCaster ())
2012-05-30 08:01:02 +02:00
tickheal = auraCaster -> SpellHealingBonusDone ( unitTarget , targetAura -> GetSpellInfo (), tickheal , DOT );
2011-07-26 23:09:28 +02:00
//int32 tickheal = targetAura->GetSpellInfo()->EffectBasePoints[idx] + 1;
2008-12-13 10:12:22 -06:00
//It is said that talent bonus should not be included
2009-10-17 15:51:44 -07:00
2009-03-01 21:51:38 +01:00
int32 tickcount = 0 ;
2009-08-08 16:18:05 +02:00
// Rejuvenation
2011-07-26 23:09:28 +02:00
if ( targetAura -> GetSpellInfo () -> SpellFamilyFlags [ 0 ] & 0x10 )
2009-08-08 16:18:05 +02:00
tickcount = 4 ;
// Regrowth
2011-07-26 23:09:28 +02:00
else // if (targetAura->GetSpellInfo()->SpellFamilyFlags[0] & 0x40)
2009-08-08 16:18:05 +02:00
tickcount = 6 ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
addhealth += tickheal * tickcount ;
2009-10-17 15:51:44 -07:00
2009-04-06 18:00:16 +02:00
// Glyph of Swiftmend
2010-04-07 19:14:10 +02:00
if ( ! caster -> HasAura ( 54824 ))
2009-04-06 18:00:16 +02:00
unitTarget -> RemoveAura ( targetAura -> GetId (), targetAura -> GetCasterGUID ());
2009-10-17 15:51:44 -07:00
2008-12-13 10:12:22 -06:00
//addhealth += tickheal * tickcount;
2011-04-29 20:47:02 +02:00
//addhealth = caster->SpellHealingBonus(m_spellInfo, addhealth, HEAL, unitTarget);
2008-10-11 14:16:25 -05:00
}
2009-06-22 23:30:17 +02:00
// Death Pact - return pct of max health to caster
else if ( m_spellInfo -> SpellFamilyName == SPELLFAMILY_DEATHKNIGHT && m_spellInfo -> SpellFamilyFlags [ 0 ] & 0x00080000 )
2012-05-30 08:01:02 +02:00
addhealth = caster -> SpellHealingBonusDone ( unitTarget , m_spellInfo , int32 ( caster -> CountPctFromMaxHealth ( damage )), HEAL );
2008-10-11 14:16:25 -05:00
else
2012-05-30 08:01:02 +02:00
addhealth = caster -> SpellHealingBonusDone ( unitTarget , m_spellInfo , addhealth , HEAL );
addhealth = unitTarget -> SpellHealingBonusTaken ( caster , m_spellInfo , addhealth , HEAL );
2009-10-17 15:51:44 -07:00
2010-06-20 00:37:02 +02:00
// Remove Grievious bite if fully healed
if ( unitTarget -> HasAura ( 48920 ) && ( unitTarget -> GetHealth () + addhealth >= unitTarget -> GetMaxHealth ()))
unitTarget -> RemoveAura ( 48920 );
2008-12-25 17:39:46 -06:00
m_damage -= addhealth ;
2008-10-11 14:16:25 -05:00
}
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectHealPct ( SpellEffIndex /*effIndex*/ )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2010-08-28 23:01:04 +02:00
if ( ! unitTarget || ! unitTarget -> isAlive () || damage < 0 )
return ;
2009-10-17 15:51:44 -07:00
2010-08-28 23:01:04 +02:00
// Skip if m_originalCaster not available
if ( ! m_originalCaster )
return ;
2009-10-17 15:51:44 -07:00
2010-08-28 23:01:04 +02:00
// Rune Tap - Party
if ( m_spellInfo -> Id == 59754 && unitTarget == m_caster )
return ;
2009-10-17 15:51:44 -07:00
2012-05-30 08:01:02 +02:00
uint32 heal = m_originalCaster -> SpellHealingBonusDone ( unitTarget , m_spellInfo , unitTarget -> CountPctFromMaxHealth ( damage ), HEAL );
heal = unitTarget -> SpellHealingBonusTaken ( m_originalCaster , m_spellInfo , heal , HEAL );
m_healing += heal ;
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectHealMechanical ( SpellEffIndex /*effIndex*/ )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2010-08-28 23:01:04 +02:00
if ( ! unitTarget || ! unitTarget -> isAlive () || damage < 0 )
return ;
2009-10-17 15:51:44 -07:00
2010-08-28 23:01:04 +02:00
// Skip if m_originalCaster not available
if ( ! m_originalCaster )
return ;
2009-10-17 15:51:44 -07:00
2012-05-30 08:01:02 +02:00
uint32 heal = m_originalCaster -> SpellHealingBonusDone ( unitTarget , m_spellInfo , uint32 ( damage ), HEAL );
m_healing += unitTarget -> SpellHealingBonusTaken ( m_originalCaster , m_spellInfo , heal , HEAL );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectHealthLeech ( SpellEffIndex effIndex )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2010-08-26 19:07:55 +02:00
if ( ! unitTarget || ! unitTarget -> isAlive () || damage < 0 )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2012-05-30 08:01:02 +02:00
damage = m_caster -> SpellDamageBonusDone ( unitTarget , m_spellInfo , uint32 ( damage ), SPELL_DIRECT_DAMAGE );
damage = unitTarget -> SpellDamageBonusTaken ( m_caster , m_spellInfo , uint32 ( damage ), SPELL_DIRECT_DAMAGE );
2011-05-10 22:28:28 +07:00
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_SPELLS_AURAS , "HealthLeech :%i" , damage );
2009-10-17 15:51:44 -07:00
2011-07-26 23:09:28 +02:00
float healMultiplier = m_spellInfo -> Effects [ effIndex ]. CalcValueMultiplier ( m_originalCaster , this );
2009-10-17 15:51:44 -07:00
2010-09-02 15:34:36 +02:00
m_damage += damage ;
// get max possible damage, don't count overkill for heal
uint32 healthGain = uint32 ( - unitTarget -> GetHealthGain ( - damage ) * healMultiplier );
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( m_caster -> isAlive ())
2008-10-11 14:16:25 -05:00
{
2012-05-30 08:01:02 +02:00
healthGain = m_caster -> SpellHealingBonusDone ( m_caster , m_spellInfo , healthGain , HEAL );
healthGain = m_caster -> SpellHealingBonusTaken ( m_caster , m_spellInfo , healthGain , HEAL );
2010-09-02 15:34:36 +02:00
m_caster -> HealBySpell ( m_caster , m_spellInfo , uint32 ( healthGain ));
2008-10-11 14:16:25 -05:00
}
}
2009-10-17 15:51:44 -07:00
2010-04-19 09:26:37 +02:00
void Spell :: DoCreateItem ( uint32 /*i*/ , uint32 itemtype )
2008-10-11 14:16:25 -05:00
{
if ( ! unitTarget || unitTarget -> GetTypeId () != TYPEID_PLAYER )
return ;
2009-10-17 15:51:44 -07:00
2011-09-25 13:29:17 +02:00
Player * player = unitTarget -> ToPlayer ();
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
uint32 newitemid = itemtype ;
2011-09-15 14:08:17 +02:00
ItemTemplate const * pProto = sObjectMgr -> GetItemTemplate ( newitemid );
2010-04-07 19:14:10 +02:00
if ( ! pProto )
2008-10-11 14:16:25 -05:00
{
2010-04-07 22:59:46 +02:00
player -> SendEquipError ( EQUIP_ERR_ITEM_NOT_FOUND , NULL , NULL );
2008-10-11 14:16:25 -05:00
return ;
}
2009-10-17 15:51:44 -07:00
2009-08-12 20:36:55 -05:00
// bg reward have some special in code work
uint32 bgType = 0 ;
2011-09-29 12:43:05 +02:00
switch ( m_spellInfo -> Id )
2009-08-12 20:36:55 -05:00
{
case SPELL_AV_MARK_WINNER :
case SPELL_AV_MARK_LOSER :
bgType = BATTLEGROUND_AV ;
break ;
case SPELL_WS_MARK_WINNER :
case SPELL_WS_MARK_LOSER :
bgType = BATTLEGROUND_WS ;
break ;
case SPELL_AB_MARK_WINNER :
case SPELL_AB_MARK_LOSER :
bgType = BATTLEGROUND_AB ;
break ;
default :
break ;
}
2009-10-17 15:51:44 -07:00
2010-04-14 12:22:35 +04:00
uint32 num_to_add = damage ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
if ( num_to_add < 1 )
num_to_add = 1 ;
2009-01-03 11:06:51 -06:00
if ( num_to_add > pProto -> GetMaxStackSize ())
num_to_add = pProto -> GetMaxStackSize ();
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// init items_count to 1, since 1 item will be created regardless of specialization
int items_count = 1 ;
// the chance to create additional items
float additionalCreateChance = 0.0f ;
// the maximum number of created additional items
uint8 additionalMaxNum = 0 ;
// get the chance and maximum number for creating extra items
2010-04-07 22:59:46 +02:00
if ( canCreateExtraItems ( player , m_spellInfo -> Id , additionalCreateChance , additionalMaxNum ))
2008-10-11 14:16:25 -05:00
{
// roll with this chance till we roll not to create or we create the max num
2010-04-07 23:56:35 +02:00
while ( roll_chance_f ( additionalCreateChance ) && items_count <= additionalMaxNum )
2008-10-11 14:16:25 -05:00
++ items_count ;
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// really will be created more items
num_to_add *= items_count ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// can the player store the new item?
ItemPosCountVec dest ;
uint32 no_space = 0 ;
2011-04-29 16:48:15 +06:00
InventoryResult msg = player -> CanStoreNewItem ( NULL_BAG , NULL_SLOT , dest , newitemid , num_to_add , & no_space );
2010-04-07 22:59:46 +02:00
if ( msg != EQUIP_ERR_OK )
2008-10-11 14:16:25 -05:00
{
// convert to possible store amount
2012-08-20 15:54:55 +02:00
if ( msg == EQUIP_ERR_INV_FULL || msg == EQUIP_ERR_ITEM_MAX_COUNT )
2008-10-11 14:16:25 -05:00
num_to_add -= no_space ;
else
{
// if not created by another reason from full inventory or unique items amount limitation
2010-08-05 22:08:07 +06:00
player -> SendEquipError ( msg , NULL , NULL , newitemid );
2008-10-11 14:16:25 -05:00
return ;
}
}
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( num_to_add )
2008-10-11 14:16:25 -05:00
{
// create the new item and store it
2010-04-07 22:59:46 +02:00
Item * pItem = player -> StoreNewItem ( dest , newitemid , true , Item :: GenerateItemRandomPropertyId ( newitemid ));
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// was it successful? return error if not
2010-04-07 19:14:10 +02:00
if ( ! pItem )
2008-10-11 14:16:25 -05:00
{
2010-04-07 22:59:46 +02:00
player -> SendEquipError ( EQUIP_ERR_ITEM_NOT_FOUND , NULL , NULL );
2008-10-11 14:16:25 -05:00
return ;
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// set the "Crafted by ..." property of the item
2011-04-28 22:42:33 +02:00
if ( pItem -> GetTemplate () -> Class != ITEM_CLASS_CONSUMABLE && pItem -> GetTemplate () -> Class != ITEM_CLASS_QUEST && newitemid != 6265 && newitemid != 6948 )
2009-05-31 15:56:51 -05:00
pItem -> SetUInt32Value ( ITEM_FIELD_CREATOR , player -> GetGUIDLow ());
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// send info to the client
2012-09-05 17:17:45 +02:00
player -> SendNewItem ( pItem , num_to_add , true , bgType == 0 );
2009-10-17 15:51:44 -07:00
2012-11-07 23:21:19 +01:00
if ( pProto -> Quality > ITEM_QUALITY_EPIC || ( pProto -> Quality == ITEM_QUALITY_EPIC && pProto -> ItemLevel >= MinNewsItemLevel [ sWorld -> getIntConfig ( CONFIG_EXPANSION )]))
if ( Guild * guild = player -> GetGuild ())
guild -> AddGuildNews ( GUILD_NEWS_ITEM_CRAFTED , player -> GetGUID (), 0 , pProto -> ItemId );
2008-10-11 14:16:25 -05:00
// we succeeded in creating at least one item, so a levelup is possible
2010-04-07 19:14:10 +02:00
if ( bgType == 0 )
2009-08-12 20:36:55 -05:00
player -> UpdateCraftSkill ( m_spellInfo -> Id );
}
2009-10-17 15:51:44 -07:00
2009-08-12 20:36:55 -05:00
/*
// for battleground marks send by mail if not add all expected
2010-04-07 19:14:10 +02:00
if (no_space > 0 && bgType)
2009-08-12 20:36:55 -05:00
{
2010-12-22 21:25:23 +01:00
if (Battleground* bg = sBattlegroundMgr->GetBattlegroundTemplate(BattlegroundTypeId(bgType)))
2009-08-12 20:36:55 -05:00
bg->SendRewardMarkByMail(player, newitemid, no_space);
2009-04-06 21:14:51 +02:00
}
2009-10-17 16:20:24 -07:00
*/
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectCreateItem ( SpellEffIndex effIndex )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2011-07-26 23:09:28 +02:00
DoCreateItem ( effIndex , m_spellInfo -> Effects [ effIndex ]. ItemType );
ExecuteLogEffectCreateItem ( effIndex , m_spellInfo -> Effects [ effIndex ]. ItemType );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectCreateItem2 ( SpellEffIndex effIndex )
2009-02-05 23:02:07 -06:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
2009-05-24 11:17:41 -05:00
return ;
2011-09-25 13:29:17 +02:00
if ( ! unitTarget || unitTarget -> GetTypeId () != TYPEID_PLAYER )
return ;
Player * player = unitTarget -> ToPlayer ();
2009-10-17 15:51:44 -07:00
2011-07-26 23:09:28 +02:00
uint32 item_id = m_spellInfo -> Effects [ effIndex ]. ItemType ;
2009-10-17 15:51:44 -07:00
2010-04-11 11:24:05 +04:00
if ( item_id )
2010-08-27 19:36:27 +02:00
DoCreateItem ( effIndex , item_id );
2009-10-17 15:51:44 -07:00
2009-05-24 11:17:41 -05:00
// special case: fake item replaced by generate using spell_loot_template
2011-07-26 23:09:28 +02:00
if ( m_spellInfo -> IsLootCrafting ())
2009-02-05 23:02:07 -06:00
{
2010-04-11 11:24:05 +04:00
if ( item_id )
{
2012-10-23 13:11:08 +02:00
if ( ! player -> HasItemCount ( item_id ))
2010-04-11 11:24:05 +04:00
return ;
2009-10-17 15:51:44 -07:00
2010-04-11 11:24:05 +04:00
// remove reagent
uint32 count = 1 ;
player -> DestroyItemCount ( item_id , count , true );
2009-10-17 15:51:44 -07:00
2010-04-11 11:24:05 +04:00
// create some random items
player -> AutoStoreLoot ( m_spellInfo -> Id , LootTemplates_Spell );
2010-06-16 20:10:42 +02:00
}
else
player -> AutoStoreLoot ( m_spellInfo -> Id , LootTemplates_Spell ); // create some random items
2009-02-05 23:02:07 -06:00
}
2011-07-26 23:09:28 +02:00
// TODO: ExecuteLogEffectCreateItem(i, m_spellInfo->Effects[i].ItemType);
2009-02-05 23:02:07 -06:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectCreateRandomItem ( SpellEffIndex /*effIndex*/ )
2009-06-23 14:44:16 +02:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
2009-06-23 14:44:16 +02:00
return ;
2011-09-25 13:29:17 +02:00
if ( ! unitTarget || unitTarget -> GetTypeId () != TYPEID_PLAYER )
return ;
Player * player = unitTarget -> ToPlayer ();
2009-10-17 15:51:44 -07:00
2009-06-23 14:44:16 +02:00
// create some random items
player -> AutoStoreLoot ( m_spellInfo -> Id , LootTemplates_Spell );
2011-07-26 23:09:28 +02:00
// TODO: ExecuteLogEffectCreateItem(i, m_spellInfo->Effects[i].ItemType);
2009-06-23 14:44:16 +02:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectPersistentAA ( SpellEffIndex effIndex )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT )
return ;
2010-01-10 01:23:15 +01:00
if ( ! m_spellAura )
2009-08-27 16:41:10 -05:00
{
2011-06-20 04:04:20 +07:00
Unit * caster = m_caster -> GetEntry () == WORLD_TRIGGER ? m_originalCaster : m_caster ;
2011-07-26 23:09:28 +02:00
float radius = m_spellInfo -> Effects [ effIndex ]. CalcRadius ( caster );
2010-01-24 23:47:17 +01:00
// Caster not in world, might be spell triggered from aura removal
if ( ! caster -> IsInWorld ())
return ;
2011-12-20 17:05:08 -05:00
DynamicObject * dynObj = new DynamicObject ( false );
2012-10-20 00:02:32 +02:00
if ( ! dynObj -> CreateDynamicObject ( sObjectMgr -> GenerateLowGuid ( HIGHGUID_DYNAMICOBJECT ), caster , m_spellInfo , * destTarget , radius , DYNAMIC_OBJECT_AREA_SPELL ))
2010-01-10 01:23:15 +01:00
{
delete dynObj ;
return ;
}
2011-04-19 15:14:50 +02:00
2011-06-07 12:47:32 +02:00
if ( Aura * aura = Aura :: TryCreate ( m_spellInfo , MAX_EFFECT_MASK , dynObj , caster , & m_spellValue -> EffectBasePoints [ 0 ]))
2011-02-04 00:27:43 +01:00
{
2010-01-10 01:23:15 +01:00
m_spellAura = aura ;
2011-02-04 00:27:43 +01:00
m_spellAura -> _RegisterForTargets ();
}
2010-01-10 01:23:15 +01:00
else
return ;
2008-10-11 14:16:25 -05:00
}
2011-04-19 15:14:50 +02:00
2010-07-30 20:04:28 +02:00
ASSERT ( m_spellAura -> GetDynobjOwner ());
2010-08-27 19:36:27 +02:00
m_spellAura -> _ApplyEffectForTargets ( effIndex );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectEnergize ( SpellEffIndex effIndex )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2010-04-07 19:14:10 +02:00
if ( ! unitTarget )
2008-10-11 14:16:25 -05:00
return ;
2010-04-07 19:14:10 +02:00
if ( ! unitTarget -> isAlive ())
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2011-07-26 23:09:28 +02:00
if ( m_spellInfo -> Effects [ effIndex ]. MiscValue < 0 || m_spellInfo -> Effects [ effIndex ]. MiscValue >= int8 ( MAX_POWERS ))
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2011-07-26 23:09:28 +02:00
Powers power = Powers ( m_spellInfo -> Effects [ effIndex ]. MiscValue );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// Some level depends spells
2009-07-31 11:16:38 +08:00
int level_multiplier = 0 ;
2008-10-11 14:16:25 -05:00
int level_diff = 0 ;
switch ( m_spellInfo -> Id )
{
2009-07-31 11:16:38 +08:00
case 9512 : // Restore Energy
2008-10-11 14:16:25 -05:00
level_diff = m_caster -> getLevel () - 40 ;
2009-07-31 11:16:38 +08:00
level_multiplier = 2 ;
2008-10-11 14:16:25 -05:00
break ;
2009-07-31 11:16:38 +08:00
case 24571 : // Blood Fury
2008-10-11 14:16:25 -05:00
level_diff = m_caster -> getLevel () - 60 ;
2009-07-31 11:16:38 +08:00
level_multiplier = 10 ;
2008-10-11 14:16:25 -05:00
break ;
2009-07-31 11:16:38 +08:00
case 24532 : // Burst of Energy
2008-10-11 14:16:25 -05:00
level_diff = m_caster -> getLevel () - 60 ;
2009-07-31 11:16:38 +08:00
level_multiplier = 4 ;
2008-10-11 14:16:25 -05:00
break ;
2009-07-31 11:16:38 +08:00
case 31930 : // Judgements of the Wise
2012-08-17 09:48:53 -05:00
case 63375 : // Primal Wisdom
2009-12-18 11:28:12 +02:00
case 68082 : // Glyph of Seal of Command
2012-10-02 12:17:42 +02:00
damage = int32 ( CalculatePct ( unitTarget -> GetCreateMana (), damage ));
2009-08-13 14:36:50 +02:00
break ;
2011-11-02 19:23:59 +07:00
case 67490 : // Runic Mana Injector (mana gain increased by 25% for engineers - 3.2.0 patch change)
{
if ( Player * player = m_caster -> ToPlayer ())
2011-11-03 17:08:30 +07:00
if ( player -> HasSkill ( SKILL_ENGINEERING ))
2012-10-02 12:17:42 +02:00
AddPct ( damage , 25 );
2011-11-02 19:23:59 +07:00
break ;
}
2008-10-11 14:16:25 -05:00
default :
break ;
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
if ( level_diff > 0 )
2009-07-31 11:16:38 +08:00
damage -= level_multiplier * level_diff ;
2009-10-17 15:51:44 -07:00
2012-12-26 19:03:11 +01:00
if ( damage < 0 && power != POWER_ECLIPSE )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( unitTarget -> GetMaxPower ( power ) == 0 )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2009-06-14 10:16:55 -05:00
m_caster -> EnergizeBySpell ( unitTarget , m_spellInfo -> Id , damage , power );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// Mad Alchemist's Potion
2010-02-15 18:23:39 +01:00
if ( m_spellInfo -> Id == 45051 )
2008-10-11 14:16:25 -05:00
{
// find elixirs on target
2010-02-01 19:22:32 +01:00
bool guardianFound = false ;
bool battleFound = false ;
2010-01-10 01:23:15 +01:00
Unit :: AuraApplicationMap & Auras = unitTarget -> GetAppliedAuras ();
for ( Unit :: AuraApplicationMap :: iterator itr = Auras . begin (); itr != Auras . end (); ++ itr )
2008-10-11 14:16:25 -05:00
{
2010-01-10 01:23:15 +01:00
uint32 spell_id = itr -> second -> GetBase () -> GetId ();
2010-02-01 19:22:32 +01:00
if ( ! guardianFound )
2010-12-22 21:25:23 +01:00
if ( sSpellMgr -> IsSpellMemberOfSpellGroup ( spell_id , SPELL_GROUP_ELIXIR_GUARDIAN ))
2010-02-01 19:22:32 +01:00
guardianFound = true ;
if ( ! battleFound )
2010-12-22 21:25:23 +01:00
if ( sSpellMgr -> IsSpellMemberOfSpellGroup ( spell_id , SPELL_GROUP_ELIXIR_BATTLE ))
2010-02-01 19:22:32 +01:00
battleFound = true ;
if ( battleFound && guardianFound )
break ;
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// get all available elixirs by mask and spell level
2010-02-02 22:35:01 +01:00
std :: set < uint32 > avalibleElixirs ;
2010-02-01 19:22:32 +01:00
if ( ! guardianFound )
2010-12-22 21:25:23 +01:00
sSpellMgr -> GetSetOfSpellsInSpellGroup ( SPELL_GROUP_ELIXIR_GUARDIAN , avalibleElixirs );
2010-02-01 19:22:32 +01:00
if ( ! battleFound )
2010-12-22 21:25:23 +01:00
sSpellMgr -> GetSetOfSpellsInSpellGroup ( SPELL_GROUP_ELIXIR_BATTLE , avalibleElixirs );
2012-05-30 08:01:02 +02:00
for ( std :: set < uint32 >:: iterator itr = avalibleElixirs . begin (); itr != avalibleElixirs . end ();)
2010-02-01 19:22:32 +01:00
{
2011-09-15 14:08:17 +02:00
SpellInfo const * spellInfo = sSpellMgr -> GetSpellInfo ( * itr );
2011-07-26 23:09:28 +02:00
if ( spellInfo -> SpellLevel < m_spellInfo -> SpellLevel || spellInfo -> SpellLevel > unitTarget -> getLevel ())
2010-02-02 22:35:01 +01:00
avalibleElixirs . erase ( itr ++ );
2010-12-22 21:25:23 +01:00
else if ( sSpellMgr -> IsSpellMemberOfSpellGroup ( * itr , SPELL_GROUP_ELIXIR_SHATTRATH ))
2010-02-02 22:35:01 +01:00
avalibleElixirs . erase ( itr ++ );
2010-12-22 21:25:23 +01:00
else if ( sSpellMgr -> IsSpellMemberOfSpellGroup ( * itr , SPELL_GROUP_ELIXIR_UNSTABLE ))
2010-02-02 22:35:01 +01:00
avalibleElixirs . erase ( itr ++ );
else
++ itr ;
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-02-01 19:22:32 +01:00
if ( ! avalibleElixirs . empty ())
2008-10-11 14:16:25 -05:00
{
// cast random elixir on target
2012-05-30 08:01:02 +02:00
m_caster -> CastSpell ( unitTarget , Trinity :: Containers :: SelectRandomContainerElement ( avalibleElixirs ), true , m_CastItem );
2008-10-11 14:16:25 -05:00
}
}
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectEnergizePct ( SpellEffIndex effIndex )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2010-04-07 19:14:10 +02:00
if ( ! unitTarget )
2008-10-11 14:16:25 -05:00
return ;
2010-04-07 19:14:10 +02:00
if ( ! unitTarget -> isAlive ())
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2011-07-26 23:09:28 +02:00
if ( m_spellInfo -> Effects [ effIndex ]. MiscValue < 0 || m_spellInfo -> Effects [ effIndex ]. MiscValue >= int8 ( MAX_POWERS ))
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2011-07-26 23:09:28 +02:00
Powers power = Powers ( m_spellInfo -> Effects [ effIndex ]. MiscValue );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
uint32 maxPower = unitTarget -> GetMaxPower ( power );
2010-04-07 19:14:10 +02:00
if ( maxPower == 0 )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2012-10-02 12:17:42 +02:00
uint32 gain = CalculatePct ( maxPower , damage );
2009-06-14 10:16:55 -05:00
m_caster -> EnergizeBySpell ( unitTarget , m_spellInfo -> Id , gain , power );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
void Spell :: SendLoot ( uint64 guid , LootType loottype )
{
2010-12-26 16:35:29 +01:00
Player * player = m_caster -> ToPlayer ();
2008-10-11 14:16:25 -05:00
if ( ! player )
return ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
if ( gameObjTarget )
{
2011-01-18 20:02:28 +01:00
// Players shouldn't be able to loot gameobjects that are currently despawned
2011-01-20 03:06:51 +01:00
if ( ! gameObjTarget -> isSpawned () && ! player -> isGameMaster ())
2011-01-18 20:02:28 +01:00
{
2012-08-03 14:20:18 +02:00
sLog -> outError ( LOG_FILTER_SPELLS_AURAS , "Possible hacking attempt: Player %s [guid: %u] tried to loot a gameobject [entry: %u id: %u] which is on respawn time without being in GM mode!" ,
2012-10-24 13:29:34 +02:00
player -> GetName (). c_str (), player -> GetGUIDLow (), gameObjTarget -> GetEntry (), gameObjTarget -> GetGUIDLow ());
2011-01-18 20:02:28 +01:00
return ;
}
2010-12-26 16:35:29 +01:00
// special case, already has GossipHello inside so return and avoid calling twice
if ( gameObjTarget -> GetGoType () == GAMEOBJECT_TYPE_GOOBER )
{
gameObjTarget -> Use ( m_caster );
return ;
}
2010-12-22 21:25:23 +01:00
if ( sScriptMgr -> OnGossipHello ( player , gameObjTarget ))
2008-12-06 14:01:44 -06:00
return ;
2009-10-17 15:51:44 -07:00
2012-09-22 21:28:37 +02:00
if ( gameObjTarget -> AI () -> GossipHello ( player ))
return ;
2010-10-27 21:01:47 +02:00
2008-10-11 14:16:25 -05:00
switch ( gameObjTarget -> GetGoType ())
{
case GAMEOBJECT_TYPE_DOOR :
case GAMEOBJECT_TYPE_BUTTON :
2012-01-22 20:36:01 -05:00
gameObjTarget -> UseDoorOrButton ( 0 , false , player );
2009-07-31 10:48:34 +08:00
player -> GetMap () -> ScriptsStart ( sGameObjectScripts , gameObjTarget -> GetDBTableGUIDLow (), player , gameObjTarget );
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
case GAMEOBJECT_TYPE_QUESTGIVER :
2012-01-05 21:41:17 -05:00
player -> PrepareGossipMenu ( gameObjTarget , gameObjTarget -> GetGOInfo () -> questgiver . gossipID );
player -> SendPreparedGossip ( gameObjTarget );
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
case GAMEOBJECT_TYPE_SPELL_FOCUS :
// triggering linked GO
2010-04-07 19:14:10 +02:00
if ( uint32 trapEntry = gameObjTarget -> GetGOInfo () -> spellFocus . linkedTrapId )
2011-04-29 20:47:02 +02:00
gameObjTarget -> TriggeringLinkedGameObject ( trapEntry , m_caster );
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
case GAMEOBJECT_TYPE_CHEST :
// TODO: possible must be moved to loot release (in different from linked triggering)
if ( gameObjTarget -> GetGOInfo () -> chest . eventId )
{
2011-04-29 20:47:02 +02:00
sLog -> outDebug ( LOG_FILTER_SPELLS_AURAS , "Chest ScriptStart id %u for GO %u" , gameObjTarget -> GetGOInfo () -> chest . eventId , gameObjTarget -> GetDBTableGUIDLow ());
2009-07-31 10:48:34 +08:00
player -> GetMap () -> ScriptsStart ( sEventScripts , gameObjTarget -> GetGOInfo () -> chest . eventId , player , gameObjTarget );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// triggering linked GO
2010-04-07 19:14:10 +02:00
if ( uint32 trapEntry = gameObjTarget -> GetGOInfo () -> chest . linkedTrapId )
2011-04-29 20:47:02 +02:00
gameObjTarget -> TriggeringLinkedGameObject ( trapEntry , m_caster );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// Don't return, let loots been taken
2009-05-03 22:21:46 -05:00
default :
break ;
2008-10-11 14:16:25 -05:00
}
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// Send loot
player -> SendLoot ( guid , loottype );
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectOpenLock ( SpellEffIndex effIndex )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2010-12-22 20:18:34 +02:00
if ( m_caster -> GetTypeId () != TYPEID_PLAYER )
2008-10-11 14:16:25 -05:00
{
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_SPELLS_AURAS , "WORLD: Open Lock - No Player Caster!" );
2008-10-11 14:16:25 -05:00
return ;
}
2009-10-17 15:51:44 -07:00
2011-09-25 13:29:17 +02:00
Player * player = m_caster -> ToPlayer ();
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
uint32 lockId = 0 ;
uint64 guid = 0 ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// Get lockId
2010-04-07 19:14:10 +02:00
if ( gameObjTarget )
2008-10-11 14:16:25 -05:00
{
2011-04-28 22:54:30 +02:00
GameObjectTemplate const * goInfo = gameObjTarget -> GetGOInfo ();
2011-09-06 21:20:14 +01:00
// Arathi Basin banner opening. // TODO: Verify correctness of this check
2010-08-30 15:25:15 +02:00
if (( goInfo -> type == GAMEOBJECT_TYPE_BUTTON && goInfo -> button . noDamageImmune ) ||
( goInfo -> type == GAMEOBJECT_TYPE_GOOBER && goInfo -> goober . losOK ))
2008-10-11 14:16:25 -05:00
{
2010-08-08 04:37:24 +02:00
//CanUseBattlegroundObject() already called in CheckCast()
2008-10-11 14:16:25 -05:00
// in battleground check
2011-09-15 14:08:17 +02:00
if ( Battleground * bg = player -> GetBattleground ())
2011-09-06 21:20:14 +01:00
{
bg -> EventPlayerClickedOnFlag ( player , gameObjTarget );
return ;
}
2008-10-11 14:16:25 -05:00
}
else if ( goInfo -> type == GAMEOBJECT_TYPE_FLAGSTAND )
{
2010-08-08 04:37:24 +02:00
//CanUseBattlegroundObject() already called in CheckCast()
2008-10-11 14:16:25 -05:00
// in battleground check
2011-09-15 14:08:17 +02:00
if ( Battleground * bg = player -> GetBattleground ())
2008-10-11 14:16:25 -05:00
{
2010-05-26 11:34:37 +02:00
if ( bg -> GetTypeID ( true ) == BATTLEGROUND_EY )
2008-10-11 14:16:25 -05:00
bg -> EventPlayerClickedOnFlag ( player , gameObjTarget );
return ;
}
2012-09-05 17:17:45 +02:00
}
else if ( m_spellInfo -> Id == 1842 && gameObjTarget -> GetGOInfo () -> type == GAMEOBJECT_TYPE_TRAP && gameObjTarget -> GetOwner ())
2010-03-26 22:04:38 -03:00
{
2010-05-23 18:20:10 -03:00
gameObjTarget -> SetLootState ( GO_JUST_DEACTIVATED );
return ;
2008-10-11 14:16:25 -05:00
}
2009-12-18 13:41:30 -08:00
// TODO: Add script for spell 41920 - Filling, becouse server it freze when use this spell
2008-10-14 11:57:03 -05:00
// handle outdoor pvp object opening, return true if go was registered for handling
// these objects must have been spawned by outdoorpvp!
2010-12-22 21:25:23 +01:00
else if ( gameObjTarget -> GetGOInfo () -> type == GAMEOBJECT_TYPE_GOOBER && sOutdoorPvPMgr -> HandleOpenGo ( player , gameObjTarget -> GetGUID ()))
2008-10-14 11:57:03 -05:00
return ;
2009-07-16 12:06:07 +08:00
lockId = goInfo -> GetLockId ();
2008-10-11 14:16:25 -05:00
guid = gameObjTarget -> GetGUID ();
}
2010-04-07 19:14:10 +02:00
else if ( itemTarget )
2008-10-11 14:16:25 -05:00
{
2011-04-28 22:42:33 +02:00
lockId = itemTarget -> GetTemplate () -> LockID ;
2008-10-11 14:16:25 -05:00
guid = itemTarget -> GetGUID ();
}
else
{
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_SPELLS_AURAS , "WORLD: Open Lock - No GameObject/Item Target!" );
2008-10-11 14:16:25 -05:00
return ;
}
2009-10-17 15:51:44 -07:00
2009-03-15 17:54:24 -06:00
SkillType skillId = SKILL_NONE ;
int32 reqSkillValue = 0 ;
int32 skillValue ;
2009-10-17 15:51:44 -07:00
2009-05-31 15:56:51 -05:00
SpellCastResult res = CanOpenLock ( effIndex , lockId , skillId , reqSkillValue , skillValue );
2010-04-07 19:14:10 +02:00
if ( res != SPELL_CAST_OK )
2008-10-11 14:16:25 -05:00
{
2009-03-15 17:54:24 -06:00
SendCastResult ( res );
2008-10-11 14:16:25 -05:00
return ;
}
2009-10-17 15:51:44 -07:00
2010-08-04 10:34:30 +02:00
if ( gameObjTarget )
SendLoot ( guid , LOOT_SKINNING );
2012-09-05 17:17:45 +02:00
else if ( itemTarget )
2010-08-04 10:34:30 +02:00
itemTarget -> SetFlag ( ITEM_FIELD_FLAGS , ITEM_FLAG_UNLOCKED );
2009-10-17 15:51:44 -07:00
2009-03-16 12:00:14 -06:00
// not allow use skill grow at item base open
2010-04-07 19:14:10 +02:00
if ( ! m_CastItem && skillId != SKILL_NONE )
2008-10-11 14:16:25 -05:00
{
2009-03-15 17:54:24 -06:00
// update skill if really known
2010-04-07 19:14:10 +02:00
if ( uint32 pureSkillValue = player -> GetPureSkillValue ( skillId ))
2008-10-11 14:16:25 -05:00
{
2010-04-07 19:14:10 +02:00
if ( gameObjTarget )
2009-03-15 17:18:59 -06:00
{
2009-03-15 17:54:24 -06:00
// Allow one skill-up until respawned
2010-04-07 22:59:46 +02:00
if ( ! gameObjTarget -> IsInSkillupList ( player -> GetGUIDLow ()) &&
player -> UpdateGatherSkill ( skillId , pureSkillValue , reqSkillValue ))
gameObjTarget -> AddToSkillupList ( player -> GetGUIDLow ());
2009-03-15 17:54:24 -06:00
}
2010-04-07 19:14:10 +02:00
else if ( itemTarget )
2009-03-15 17:54:24 -06:00
{
// Do one skill-up
player -> UpdateGatherSkill ( skillId , pureSkillValue , reqSkillValue );
2009-03-15 17:18:59 -06:00
}
}
2008-10-11 14:16:25 -05:00
}
2010-08-27 17:49:32 +02:00
ExecuteLogEffectOpenLock ( effIndex , gameObjTarget ? ( Object * ) gameObjTarget : ( Object * ) itemTarget );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectSummonChangeItem ( SpellEffIndex effIndex )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT )
return ;
*Implement spells: 781, 13280, 32307, 40109, 47770, 47776, 49625, 49634, 51854, 64385, by Warhead
2009-10-31 04:28:02 -07:00
if ( m_caster -> GetTypeId () != TYPEID_PLAYER )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2011-09-25 13:29:17 +02:00
Player * player = m_caster -> ToPlayer ();
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// applied only to using item
*Implement spells: 781, 13280, 32307, 40109, 47770, 47776, 49625, 49634, 51854, 64385, by Warhead
2009-10-31 04:28:02 -07:00
if ( ! m_CastItem )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// ... only to item in own inventory/bank/equip_slot
*Implement spells: 781, 13280, 32307, 40109, 47770, 47776, 49625, 49634, 51854, 64385, by Warhead
2009-10-31 04:28:02 -07:00
if ( m_CastItem -> GetOwnerGUID () != player -> GetGUID ())
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2011-07-26 23:09:28 +02:00
uint32 newitemid = m_spellInfo -> Effects [ effIndex ]. ItemType ;
*Implement spells: 781, 13280, 32307, 40109, 47770, 47776, 49625, 49634, 51854, 64385, by Warhead
2009-10-31 04:28:02 -07:00
if ( ! newitemid )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
uint16 pos = m_CastItem -> GetPos ();
2009-10-17 15:51:44 -07:00
2011-09-15 14:08:17 +02:00
Item * pNewItem = Item :: CreateItem ( newitemid , 1 , player );
*Implement spells: 781, 13280, 32307, 40109, 47770, 47776, 49625, 49634, 51854, 64385, by Warhead
2009-10-31 04:28:02 -07:00
if ( ! pNewItem )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
*Implement spells: 781, 13280, 32307, 40109, 47770, 47776, 49625, 49634, 51854, 64385, by Warhead
2009-10-31 04:28:02 -07:00
for ( uint8 j = PERM_ENCHANTMENT_SLOT ; j <= TEMP_ENCHANTMENT_SLOT ; ++ j )
if ( m_CastItem -> GetEnchantmentId ( EnchantmentSlot ( j )))
2009-04-27 18:42:35 -05:00
pNewItem -> SetEnchantment ( EnchantmentSlot ( j ), m_CastItem -> GetEnchantmentId ( EnchantmentSlot ( j )), m_CastItem -> GetEnchantmentDuration ( EnchantmentSlot ( j )), m_CastItem -> GetEnchantmentCharges ( EnchantmentSlot ( j )));
2009-10-17 15:51:44 -07:00
*Implement spells: 781, 13280, 32307, 40109, 47770, 47776, 49625, 49634, 51854, 64385, by Warhead
2009-10-31 04:28:02 -07:00
if ( m_CastItem -> GetUInt32Value ( ITEM_FIELD_DURABILITY ) < m_CastItem -> GetUInt32Value ( ITEM_FIELD_MAXDURABILITY ))
2008-10-11 14:16:25 -05:00
{
2010-11-14 23:46:34 +02:00
double lossPercent = 1 - m_CastItem -> GetUInt32Value ( ITEM_FIELD_DURABILITY ) / double ( m_CastItem -> GetUInt32Value ( ITEM_FIELD_MAXDURABILITY ));
player -> DurabilityLoss ( pNewItem , lossPercent );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
*Implement spells: 781, 13280, 32307, 40109, 47770, 47776, 49625, 49634, 51854, 64385, by Warhead
2009-10-31 04:28:02 -07:00
if ( player -> IsInventoryPos ( pos ))
2008-10-11 14:16:25 -05:00
{
ItemPosCountVec dest ;
2011-04-29 16:48:15 +06:00
InventoryResult msg = player -> CanStoreItem ( m_CastItem -> GetBagSlot (), m_CastItem -> GetSlot (), dest , pNewItem , true );
*Implement spells: 781, 13280, 32307, 40109, 47770, 47776, 49625, 49634, 51854, 64385, by Warhead
2009-10-31 04:28:02 -07:00
if ( msg == EQUIP_ERR_OK )
2008-10-11 14:16:25 -05:00
{
2009-05-31 15:56:51 -05:00
player -> DestroyItem ( m_CastItem -> GetBagSlot (), m_CastItem -> GetSlot (), true );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// prevent crash at access and unexpected charges counting with item update queue corrupt
2011-06-23 13:28:52 +02:00
if ( m_CastItem == m_targets . GetItemTarget ())
m_targets . SetItemTarget ( NULL );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
m_CastItem = NULL ;
2009-10-17 15:51:44 -07:00
*Implement spells: 781, 13280, 32307, 40109, 47770, 47776, 49625, 49634, 51854, 64385, by Warhead
2009-10-31 04:28:02 -07:00
player -> StoreItem ( dest , pNewItem , true );
2008-10-11 14:16:25 -05:00
return ;
}
}
*Implement spells: 781, 13280, 32307, 40109, 47770, 47776, 49625, 49634, 51854, 64385, by Warhead
2009-10-31 04:28:02 -07:00
else if ( player -> IsBankPos ( pos ))
2008-10-11 14:16:25 -05:00
{
ItemPosCountVec dest ;
*Implement spells: 781, 13280, 32307, 40109, 47770, 47776, 49625, 49634, 51854, 64385, by Warhead
2009-10-31 04:28:02 -07:00
uint8 msg = player -> CanBankItem ( m_CastItem -> GetBagSlot (), m_CastItem -> GetSlot (), dest , pNewItem , true );
if ( msg == EQUIP_ERR_OK )
2008-10-11 14:16:25 -05:00
{
2009-05-31 15:56:51 -05:00
player -> DestroyItem ( m_CastItem -> GetBagSlot (), m_CastItem -> GetSlot (), true );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// prevent crash at access and unexpected charges counting with item update queue corrupt
2011-06-23 13:28:52 +02:00
if ( m_CastItem == m_targets . GetItemTarget ())
m_targets . SetItemTarget ( NULL );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
m_CastItem = NULL ;
2009-10-17 15:51:44 -07:00
*Implement spells: 781, 13280, 32307, 40109, 47770, 47776, 49625, 49634, 51854, 64385, by Warhead
2009-10-31 04:28:02 -07:00
player -> BankItem ( dest , pNewItem , true );
2008-10-11 14:16:25 -05:00
return ;
}
}
*Implement spells: 781, 13280, 32307, 40109, 47770, 47776, 49625, 49634, 51854, 64385, by Warhead
2009-10-31 04:28:02 -07:00
else if ( player -> IsEquipmentPos ( pos ))
2008-10-11 14:16:25 -05:00
{
uint16 dest ;
*Implement spells: 781, 13280, 32307, 40109, 47770, 47776, 49625, 49634, 51854, 64385, by Warhead
2009-10-31 04:28:02 -07:00
player -> DestroyItem ( m_CastItem -> GetBagSlot (), m_CastItem -> GetSlot (), true );
uint8 msg = player -> CanEquipItem ( m_CastItem -> GetSlot (), dest , pNewItem , true );
2012-08-20 15:54:55 +02:00
if ( msg == EQUIP_ERR_OK || msg == EQUIP_ERR_CLIENT_LOCKED_OUT )
2008-10-11 14:16:25 -05:00
{
2012-08-20 15:54:55 +02:00
if ( msg == EQUIP_ERR_CLIENT_LOCKED_OUT ) dest = EQUIPMENT_SLOT_MAINHAND ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// prevent crash at access and unexpected charges counting with item update queue corrupt
2011-06-23 13:28:52 +02:00
if ( m_CastItem == m_targets . GetItemTarget ())
m_targets . SetItemTarget ( NULL );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
m_CastItem = NULL ;
2009-10-17 15:51:44 -07:00
*Implement spells: 781, 13280, 32307, 40109, 47770, 47776, 49625, 49634, 51854, 64385, by Warhead
2009-10-31 04:28:02 -07:00
player -> EquipItem ( dest , pNewItem , true );
2008-10-11 14:16:25 -05:00
player -> AutoUnequipOffhandIfNeed ();
return ;
}
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// fail
delete pNewItem ;
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectProficiency ( SpellEffIndex /*effIndex*/ )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT )
return ;
if ( m_caster -> GetTypeId () != TYPEID_PLAYER )
2008-10-11 14:16:25 -05:00
return ;
2011-09-25 13:29:17 +02:00
Player * p_target = m_caster -> ToPlayer ();
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
uint32 subClassMask = m_spellInfo -> EquippedItemSubClassMask ;
2010-04-07 19:14:10 +02:00
if ( m_spellInfo -> EquippedItemClass == ITEM_CLASS_WEAPON && ! ( p_target -> GetWeaponProficiency () & subClassMask ))
2008-10-11 14:16:25 -05:00
{
p_target -> AddWeaponProficiency ( subClassMask );
2009-05-31 15:56:51 -05:00
p_target -> SendProficiency ( ITEM_CLASS_WEAPON , p_target -> GetWeaponProficiency ());
2008-10-11 14:16:25 -05:00
}
2010-04-07 19:14:10 +02:00
if ( m_spellInfo -> EquippedItemClass == ITEM_CLASS_ARMOR && ! ( p_target -> GetArmorProficiency () & subClassMask ))
2008-10-11 14:16:25 -05:00
{
p_target -> AddArmorProficiency ( subClassMask );
2009-05-31 15:56:51 -05:00
p_target -> SendProficiency ( ITEM_CLASS_ARMOR , p_target -> GetArmorProficiency ());
2008-10-11 14:16:25 -05:00
}
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectSummonType ( SpellEffIndex effIndex )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT )
return ;
2011-07-26 23:09:28 +02:00
uint32 entry = m_spellInfo -> Effects [ effIndex ]. MiscValue ;
2009-11-01 17:53:07 -08:00
if ( ! entry )
2009-03-20 14:01:46 -06:00
return ;
2009-10-17 15:51:44 -07:00
2011-09-15 14:08:17 +02:00
SummonPropertiesEntry const * properties = sSummonPropertiesStore . LookupEntry ( m_spellInfo -> Effects [ effIndex ]. MiscValueB );
2009-11-01 17:53:07 -08:00
if ( ! properties )
2009-03-25 16:20:30 -06:00
{
2012-08-03 14:20:18 +02:00
sLog -> outError ( LOG_FILTER_SPELLS_AURAS , "EffectSummonType: Unhandled summon type %u" , m_spellInfo -> Effects [ effIndex ]. MiscValueB );
2009-03-25 16:20:30 -06:00
return ;
}
2009-10-17 15:51:44 -07:00
2009-11-01 17:53:07 -08:00
if ( ! m_originalCaster )
2009-04-27 18:12:45 -05:00
return ;
2009-10-17 15:51:44 -07:00
2011-07-26 23:09:28 +02:00
int32 duration = m_spellInfo -> GetDuration ();
2009-11-01 17:53:07 -08:00
if ( Player * modOwner = m_originalCaster -> GetSpellModOwner ())
2009-04-27 18:12:45 -05:00
modOwner -> ApplySpellMod ( m_spellInfo -> Id , SPELLMOD_DURATION , duration );
2009-10-17 15:51:44 -07:00
2011-09-15 14:08:17 +02:00
TempSummon * summon = NULL ;
2009-10-17 15:51:44 -07:00
2012-02-09 20:26:30 +01:00
// determine how many units should be summoned
uint32 numSummons ;
// some spells need to summon many units, for those spells number of summons is stored in effect value
2012-02-10 11:32:33 +01:00
// however so far noone found a generic check to find all of those (there's no related data in summonproperties.dbc
2012-02-09 20:26:30 +01:00
// and in spell attributes, possibly we need to add a table for those)
// so here's a list of MiscValueB values, which is currently most generic check
switch ( properties -> Id )
{
case 64 :
case 61 :
case 1101 :
case 66 :
case 648 :
case 2301 :
case 1061 :
case 1261 :
case 629 :
case 181 :
case 715 :
2012-02-17 11:44:34 +01:00
case 1562 :
case 833 :
case 1161 :
2012-02-09 20:26:30 +01:00
numSummons = ( damage > 0 ) ? damage : 1 ;
break ;
default :
numSummons = 1 ;
break ;
}
2009-11-01 17:53:07 -08:00
switch ( properties -> Category )
2008-10-11 14:16:25 -05:00
{
2011-04-22 12:05:15 +02:00
case SUMMON_CATEGORY_WILD :
case SUMMON_CATEGORY_ALLY :
2011-04-24 10:22:58 +02:00
case SUMMON_CATEGORY_UNK :
2009-07-22 17:10:30 +02:00
if ( properties -> Flags & 512 )
2009-07-22 20:22:36 +02:00
{
2012-02-09 20:26:30 +01:00
SummonGuardian ( effIndex , entry , properties , numSummons );
2009-07-22 17:10:30 +02:00
break ;
2009-07-22 20:22:36 +02:00
}
2009-11-01 17:53:07 -08:00
switch ( properties -> Type )
2009-03-18 21:16:24 -06:00
{
2009-03-25 16:20:30 -06:00
case SUMMON_TYPE_PET :
case SUMMON_TYPE_GUARDIAN :
2009-12-14 01:51:12 +01:00
case SUMMON_TYPE_GUARDIAN2 :
2009-03-25 16:20:30 -06:00
case SUMMON_TYPE_MINION :
2012-02-09 20:26:30 +01:00
SummonGuardian ( effIndex , entry , properties , numSummons );
2009-03-18 21:16:24 -06:00
break ;
2011-04-22 12:05:15 +02:00
// Summons a vehicle, but doesn't force anyone to enter it (see SUMMON_CATEGORY_VEHICLE)
2009-03-25 16:20:30 -06:00
case SUMMON_TYPE_VEHICLE :
2009-04-22 17:50:26 -05:00
case SUMMON_TYPE_VEHICLE2 :
2012-05-30 08:01:02 +02:00
summon = m_caster -> GetMap () -> SummonCreature ( entry , * destTarget , properties , duration , m_originalCaster , m_spellInfo -> Id );
2009-03-18 21:16:24 -06:00
break ;
2012-12-26 04:34:40 +01:00
case SUMMON_TYPE_LIGHTWELL :
2009-03-25 16:20:30 -06:00
case SUMMON_TYPE_TOTEM :
2009-04-27 18:12:45 -05:00
{
2012-05-30 08:01:02 +02:00
summon = m_caster -> GetMap () -> SummonCreature ( entry , * destTarget , properties , duration , m_originalCaster , m_spellInfo -> Id );
2011-05-19 22:27:18 +02:00
if ( ! summon || ! summon -> isTotem ())
return ;
2011-05-19 01:24:53 +07:00
2011-05-19 22:27:18 +02:00
// Mana Tide Totem
if ( m_spellInfo -> Id == 16190 )
damage = m_caster -> CountPctFromMaxHealth ( 10 );
2009-10-17 15:51:44 -07:00
2011-05-19 22:27:18 +02:00
if ( damage ) // if not spell info, DB values used
{
summon -> SetMaxHealth ( damage );
summon -> SetHealth ( damage );
2009-04-27 18:12:45 -05:00
}
2009-03-25 16:20:30 -06:00
break ;
2009-04-27 18:12:45 -05:00
}
2009-03-25 16:20:30 -06:00
case SUMMON_TYPE_MINIPET :
2009-04-27 18:12:45 -05:00
{
2012-05-30 08:01:02 +02:00
summon = m_caster -> GetMap () -> SummonCreature ( entry , * destTarget , properties , duration , m_originalCaster , m_spellInfo -> Id );
2009-11-01 17:53:07 -08:00
if ( ! summon || ! summon -> HasUnitTypeMask ( UNIT_MASK_MINION ))
2009-04-27 18:12:45 -05:00
return ;
2009-10-17 15:51:44 -07:00
2012-05-30 08:01:02 +02:00
summon -> SelectLevel ( summon -> GetCreatureTemplate ()); // some summoned creaters have different from 1 DB data for level/hp
summon -> SetUInt32Value ( UNIT_NPC_FLAGS , summon -> GetCreatureTemplate () -> npcflag );
2009-10-17 15:51:44 -07:00
2012-02-03 18:46:05 +01:00
summon -> SetFlag ( UNIT_FIELD_FLAGS , UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC );
2009-10-17 15:51:44 -07:00
2009-05-12 10:11:54 -05:00
summon -> AI () -> EnterEvadeMode ();
2009-03-25 16:20:30 -06:00
break ;
2009-04-27 18:12:45 -05:00
}
2009-03-25 16:20:30 -06:00
default :
2009-04-27 18:12:45 -05:00
{
2011-07-26 23:09:28 +02:00
float radius = m_spellInfo -> Effects [ effIndex ]. CalcRadius ();
2009-10-17 15:51:44 -07:00
2011-04-22 12:05:15 +02:00
TempSummonType summonType = ( duration == 0 ) ? TEMPSUMMON_DEAD_DESPAWN : TEMPSUMMON_TIMED_DESPAWN ;
2012-02-09 20:26:30 +01:00
for ( uint32 count = 0 ; count < numSummons ; ++ count )
2009-04-27 18:12:45 -05:00
{
2012-05-30 08:01:02 +02:00
Position pos ;
if ( count == 0 )
pos = * destTarget ;
else
// randomize position for multiple summons
m_caster -> GetRandomPoint ( * destTarget , radius , pos );
2009-10-17 15:51:44 -07:00
2012-11-03 16:01:46 +01:00
summon = m_originalCaster -> SummonCreature ( entry , pos , summonType , duration );
2009-07-22 22:52:05 +02:00
if ( ! summon )
continue ;
2011-04-22 12:05:15 +02:00
2009-07-09 17:02:29 +02:00
if ( properties -> Category == SUMMON_CATEGORY_ALLY )
2009-08-14 22:25:12 -05:00
{
2012-07-22 14:20:26 +02:00
summon -> SetOwnerGUID ( m_originalCaster -> GetGUID ());
2009-07-11 13:03:06 +02:00
summon -> setFaction ( m_originalCaster -> getFaction ());
2009-08-26 19:28:21 -05:00
summon -> SetUInt32Value ( UNIT_CREATED_BY_SPELL , m_spellInfo -> Id );
2009-08-14 22:25:12 -05:00
}
2011-04-22 12:05:15 +02:00
2010-08-27 19:36:27 +02:00
ExecuteLogEffectSummonObject ( effIndex , summon );
2009-04-27 18:12:45 -05:00
}
2010-08-27 17:49:32 +02:00
return ;
2009-04-27 18:12:45 -05:00
}
} //switch
2008-10-11 14:16:25 -05:00
break ;
2009-03-25 16:20:30 -06:00
case SUMMON_CATEGORY_PET :
2012-02-09 20:26:30 +01:00
SummonGuardian ( effIndex , entry , properties , numSummons );
2009-03-25 16:20:30 -06:00
break ;
2009-05-25 22:52:08 -05:00
case SUMMON_CATEGORY_PUPPET :
2012-05-30 08:01:02 +02:00
summon = m_caster -> GetMap () -> SummonCreature ( entry , * destTarget , properties , duration , m_originalCaster , m_spellInfo -> Id );
2009-03-25 16:20:30 -06:00
break ;
2011-04-24 10:22:58 +02:00
case SUMMON_CATEGORY_VEHICLE :
2011-04-22 12:05:15 +02:00
// Summoning spells (usually triggered by npc_spellclick) that spawn a vehicle and that cause the clicker
// to cast a ride vehicle spell on the summoned unit.
2009-04-27 18:12:45 -05:00
float x , y , z ;
m_caster -> GetClosePoint ( x , y , z , DEFAULT_WORLD_OBJECT_SIZE );
2012-05-30 08:01:02 +02:00
summon = m_originalCaster -> GetMap () -> SummonCreature ( entry , * destTarget , properties , duration , m_caster , m_spellInfo -> Id );
2009-11-01 17:53:07 -08:00
if ( ! summon || ! summon -> IsVehicle ())
2009-04-27 18:12:45 -05:00
return ;
2009-10-17 15:51:44 -07:00
2011-04-22 12:05:15 +02:00
// The spell that this effect will trigger. It has SPELL_AURA_CONTROL_VEHICLE
2012-08-02 18:38:55 +02:00
uint32 spellId = VEHICLE_SPELL_RIDE_HARDCODED ;
SpellInfo const * spellInfo = sSpellMgr -> GetSpellInfo ( m_spellInfo -> Effects [ effIndex ]. CalcValue ());
if ( spellInfo && spellInfo -> HasAura ( SPELL_AURA_CONTROL_VEHICLE ))
spellId = spellInfo -> Id ;
2010-05-13 17:57:59 +02:00
2011-02-26 23:00:09 +01:00
// Hard coded enter vehicle spell
2012-08-02 18:38:55 +02:00
m_originalCaster -> CastSpell ( summon , spellId , true );
2011-02-26 23:00:09 +01:00
uint32 faction = properties -> Faction ;
if ( ! faction )
faction = m_originalCaster -> getFaction ();
summon -> setFaction ( faction );
2009-03-25 16:20:30 -06:00
break ;
2009-04-27 18:12:45 -05:00
}
2009-10-17 15:51:44 -07:00
2009-11-01 17:53:07 -08:00
if ( summon )
2010-06-07 01:59:04 +02:00
{
summon -> SetCreatorGUID ( m_originalCaster -> GetGUID ());
2010-08-27 19:36:27 +02:00
ExecuteLogEffectSummonObject ( effIndex , summon );
2010-06-07 01:59:04 +02:00
}
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectLearnSpell ( SpellEffIndex effIndex )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2009-11-01 17:53:07 -08:00
if ( ! unitTarget )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2009-11-01 17:53:07 -08:00
if ( unitTarget -> GetTypeId () != TYPEID_PLAYER )
2008-10-11 14:16:25 -05:00
{
2011-09-24 02:01:18 +02:00
if ( unitTarget -> ToPet ())
2010-08-27 19:36:27 +02:00
EffectLearnPetSpell ( effIndex );
2008-10-11 14:16:25 -05:00
return ;
}
2009-10-17 15:51:44 -07:00
2011-09-24 02:01:18 +02:00
Player * player = unitTarget -> ToPlayer ();
2009-10-17 15:51:44 -07:00
2011-07-26 23:09:28 +02:00
uint32 spellToLearn = ( m_spellInfo -> Id == 483 || m_spellInfo -> Id == 55884 ) ? damage : m_spellInfo -> Effects [ effIndex ]. TriggerSpell ;
2010-04-11 11:16:42 +04:00
player -> learnSpell ( spellToLearn , false );
2009-10-17 15:51:44 -07:00
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_SPELLS_AURAS , "Spell: Player %u has learned spell %u from NpcGUID=%u" , player -> GetGUIDLow (), spellToLearn , m_caster -> GetGUIDLow ());
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-01-10 12:08:58 +01:00
typedef std :: list < std :: pair < uint32 , uint64 > > DispelList ;
2010-08-27 19:36:27 +02:00
void Spell :: EffectDispel ( SpellEffIndex effIndex )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2010-04-07 19:14:10 +02:00
if ( ! unitTarget )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// Create dispel mask by dispel type
2011-07-26 23:09:28 +02:00
uint32 dispel_type = m_spellInfo -> Effects [ effIndex ]. MiscValue ;
uint32 dispelMask = SpellInfo :: GetDispelMask ( DispelType ( dispel_type ));
2010-08-06 21:32:42 -07:00
2012-05-30 08:01:02 +02:00
DispelChargesList dispel_list ;
unitTarget -> GetDispellableAuraList ( m_caster , dispelMask , dispel_list );
2009-09-04 10:01:52 -05:00
if ( dispel_list . empty ())
return ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// Ok if exist some buffs for dispel try dispel it
2009-09-04 10:01:52 -05:00
uint32 failCount = 0 ;
2011-05-05 19:06:11 -03:00
DispelChargesList success_list ;
2009-09-04 10:01:52 -05:00
WorldPacket dataFail ( SMSG_DISPEL_FAILED , 8 + 8 + 4 + 4 + damage * 4 );
// dispel N = damage buffs (or while exist buffs for dispel)
2010-05-25 10:36:33 +02:00
for ( int32 count = 0 ; count < damage && ! dispel_list . empty ();)
2008-10-11 14:16:25 -05:00
{
2009-09-04 10:01:52 -05:00
// Random select buff for dispel
2010-05-25 10:36:33 +02:00
DispelChargesList :: iterator itr = dispel_list . begin ();
2009-09-04 10:01:52 -05:00
std :: advance ( itr , urand ( 0 , dispel_list . size () - 1 ));
2009-10-17 15:51:44 -07:00
2011-07-26 23:09:28 +02:00
int32 chance = itr -> first -> CalcDispelChance ( unitTarget , ! unitTarget -> IsFriendlyTo ( m_caster ));
2010-05-25 10:36:33 +02:00
// 2.4.3 Patch Notes: "Dispel effects will no longer attempt to remove effects that have 100% dispel resistance."
2011-07-26 23:09:28 +02:00
if ( ! chance )
2009-04-06 13:31:14 +02:00
{
2009-09-04 10:01:52 -05:00
dispel_list . erase ( itr );
2010-05-25 10:36:33 +02:00
continue ;
2008-10-11 14:16:25 -05:00
}
2009-09-04 10:01:52 -05:00
else
2008-10-11 14:16:25 -05:00
{
2011-07-26 23:09:28 +02:00
if ( roll_chance_i ( chance ))
2008-10-11 14:16:25 -05:00
{
2011-05-05 19:06:11 -03:00
bool alreadyListed = false ;
for ( DispelChargesList :: iterator successItr = success_list . begin (); successItr != success_list . end (); ++ successItr )
{
if ( successItr -> first -> GetId () == itr -> first -> GetId ())
{
++ successItr -> second ;
alreadyListed = true ;
}
}
if ( ! alreadyListed )
success_list . push_back ( std :: make_pair ( itr -> first , 1 ));
2010-05-25 10:36:33 +02:00
-- itr -> second ;
if ( itr -> second <= 0 )
dispel_list . erase ( itr );
2008-10-11 14:16:25 -05:00
}
2010-05-25 10:36:33 +02:00
else
{
if ( ! failCount )
{
// Failed to dispell
dataFail << uint64 ( m_caster -> GetGUID ()); // Caster GUID
dataFail << uint64 ( unitTarget -> GetGUID ()); // Victim GUID
dataFail << uint32 ( m_spellInfo -> Id ); // dispel spell id
}
++ failCount ;
dataFail << uint32 ( itr -> first -> GetId ()); // Spell Id
}
++ count ;
2008-10-11 14:16:25 -05:00
}
}
2009-10-17 15:51:44 -07:00
2009-09-04 10:01:52 -05:00
if ( failCount )
m_caster -> SendMessageToSet ( & dataFail , true );
2009-10-17 15:51:44 -07:00
2009-09-04 10:01:52 -05:00
if ( success_list . empty ())
return ;
2009-10-17 15:51:44 -07:00
2011-05-05 19:06:11 -03:00
WorldPacket dataSuccess ( SMSG_SPELLDISPELLOG , 8 + 8 + 4 + 1 + 4 + success_list . size () * 5 );
2009-09-04 10:01:52 -05:00
// Send packet header
dataSuccess . append ( unitTarget -> GetPackGUID ()); // Victim GUID
dataSuccess . append ( m_caster -> GetPackGUID ()); // Caster GUID
dataSuccess << uint32 ( m_spellInfo -> Id ); // dispel spell id
dataSuccess << uint8 ( 0 ); // not used
dataSuccess << uint32 ( success_list . size ()); // count
2011-05-05 19:06:11 -03:00
for ( DispelChargesList :: iterator itr = success_list . begin (); itr != success_list . end (); ++ itr )
2009-09-04 10:01:52 -05:00
{
// Send dispelled spell info
2011-05-05 19:06:11 -03:00
dataSuccess << uint32 ( itr -> first -> GetId ()); // Spell Id
2009-09-04 10:01:52 -05:00
dataSuccess << uint8 ( 0 ); // 0 - dispelled !=0 cleansed
2012-02-04 13:32:40 +01:00
unitTarget -> RemoveAurasDueToSpellByDispel ( itr -> first -> GetId (), m_spellInfo -> Id , itr -> first -> GetCasterGUID (), m_caster , itr -> second );
2009-09-04 10:01:52 -05:00
}
m_caster -> SendMessageToSet ( & dataSuccess , true );
2009-10-17 15:51:44 -07:00
2009-09-04 10:01:52 -05:00
// On success dispel
// Devour Magic
if ( m_spellInfo -> SpellFamilyName == SPELLFAMILY_WARLOCK && m_spellInfo -> Category == SPELLCATEGORY_DEVOUR_MAGIC )
{
2012-08-17 00:10:19 +02:00
int32 heal_amount = m_spellInfo -> Effects [ EFFECT_1 ]. CalcValue ( m_caster );
2009-09-04 10:01:52 -05:00
m_caster -> CastCustomSpell ( m_caster , 19658 , & heal_amount , NULL , NULL , true );
2010-12-23 19:03:28 +01:00
// Glyph of Felhunter
2011-10-07 10:54:53 -05:00
if ( Unit * owner = m_caster -> GetOwner ())
if ( owner -> GetAura ( 56249 ))
owner -> CastCustomSpell ( owner , 19658 , & heal_amount , NULL , NULL , true );
2009-09-04 10:01:52 -05:00
}
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectDualWield ( SpellEffIndex /*effIndex*/ )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2008-10-29 20:00:21 -05:00
unitTarget -> SetCanDualWield ( true );
2009-11-01 17:53:07 -08:00
if ( unitTarget -> GetTypeId () == TYPEID_UNIT )
2010-03-07 18:30:53 +01:00
unitTarget -> ToCreature () -> UpdateDamagePhysical ( OFF_ATTACK );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-12-16 18:08:23 +01:00
void Spell :: EffectPull ( SpellEffIndex effIndex )
2008-10-11 14:16:25 -05:00
{
// TODO: create a proper pull towards distract spell center for distract
2010-12-16 18:08:23 +01:00
EffectNULL ( effIndex );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectDistract ( SpellEffIndex /*effIndex*/ )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2008-10-11 14:16:25 -05:00
// Check for possible target
if ( ! unitTarget || unitTarget -> isInCombat ())
return ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// target must be OK to do this
2012-02-03 19:12:41 +02:00
if ( unitTarget -> HasUnitState ( UNIT_STATE_CONFUSED | UNIT_STATE_STUNNED | UNIT_STATE_FLEEING ))
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2012-05-30 08:01:02 +02:00
unitTarget -> SetFacingTo ( unitTarget -> GetAngle ( destTarget ));
2012-02-03 19:12:41 +02:00
unitTarget -> ClearUnitState ( UNIT_STATE_MOVING );
2009-10-17 15:51:44 -07:00
2012-01-14 15:34:41 +01:00
if ( unitTarget -> GetTypeId () == TYPEID_UNIT )
2010-07-12 00:30:17 +02:00
unitTarget -> GetMotionMaster () -> MoveDistract ( damage * IN_MILLISECONDS );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectPickPocket ( SpellEffIndex /*effIndex*/ )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2009-11-01 17:53:07 -08:00
if ( m_caster -> GetTypeId () != TYPEID_PLAYER )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// victim must be creature and attackable
2009-11-01 17:53:07 -08:00
if ( ! unitTarget || unitTarget -> GetTypeId () != TYPEID_UNIT || m_caster -> IsFriendlyTo ( unitTarget ))
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// victim have to be alive and humanoid or undead
2009-11-01 17:53:07 -08:00
if ( unitTarget -> isAlive () && ( unitTarget -> GetCreatureTypeMask () & CREATURE_TYPEMASK_HUMANOID_OR_UNDEAD ) != 0 )
2011-04-29 20:47:02 +02:00
m_caster -> ToPlayer () -> SendLoot ( unitTarget -> GetGUID (), LOOT_PICKPOCKETING );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectAddFarsight ( SpellEffIndex effIndex )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT )
return ;
2008-11-14 20:40:35 -06:00
if ( m_caster -> GetTypeId () != TYPEID_PLAYER )
return ;
2009-10-17 15:51:44 -07:00
2011-07-26 23:09:28 +02:00
float radius = m_spellInfo -> Effects [ effIndex ]. CalcRadius ();
int32 duration = m_spellInfo -> GetDuration ();
2010-01-24 23:47:17 +01:00
// Caster not in world, might be spell triggered from aura removal
if ( ! m_caster -> IsInWorld ())
return ;
2011-04-19 15:14:50 +02:00
2011-12-20 17:05:08 -05:00
DynamicObject * dynObj = new DynamicObject ( true );
2012-10-20 00:02:32 +02:00
if ( ! dynObj -> CreateDynamicObject ( sObjectMgr -> GenerateLowGuid ( HIGHGUID_DYNAMICOBJECT ), m_caster , m_spellInfo , * destTarget , radius , DYNAMIC_OBJECT_FARSIGHT_FOCUS ))
2008-10-11 14:16:25 -05:00
{
delete dynObj ;
return ;
}
2011-04-19 15:14:50 +02:00
2010-01-10 01:23:15 +01:00
dynObj -> SetDuration ( duration );
2011-02-04 00:27:43 +01:00
dynObj -> SetCasterViewpoint ();
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-12-25 06:28:38 +01:00
void Spell :: EffectUntrainTalents ( SpellEffIndex /*effIndex*/ )
2010-12-22 20:14:30 +02:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2010-12-22 20:14:30 +02:00
if ( ! unitTarget || m_caster -> GetTypeId () == TYPEID_PLAYER )
return ;
if ( uint64 guid = m_caster -> GetGUID ()) // the trainer is the caster
unitTarget -> ToPlayer () -> SendTalentWipeConfirm ( guid );
}
2010-08-27 19:36:27 +02:00
void Spell :: EffectTeleUnitsFaceCaster ( SpellEffIndex effIndex )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2009-11-01 17:53:07 -08:00
if ( ! unitTarget )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2009-11-01 17:53:07 -08:00
if ( unitTarget -> isInFlight ())
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2011-07-26 23:09:28 +02:00
float dis = m_spellInfo -> Effects [ effIndex ]. CalcRadius ( m_caster );
2009-10-17 15:51:44 -07:00
2011-04-29 20:47:02 +02:00
float fx , fy , fz ;
m_caster -> GetClosePoint ( fx , fy , fz , unitTarget -> GetObjectSize (), dis );
2009-10-17 15:51:44 -07:00
2011-04-29 20:47:02 +02:00
unitTarget -> NearTeleportTo ( fx , fy , fz , - m_caster -> GetOrientation (), unitTarget == m_caster );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectLearnSkill ( SpellEffIndex effIndex )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2009-11-01 17:53:07 -08:00
if ( unitTarget -> GetTypeId () != TYPEID_PLAYER )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2009-11-01 17:53:07 -08:00
if ( damage < 0 )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2012-05-30 08:01:02 +02:00
uint32 skillid = m_spellInfo -> Effects [ effIndex ]. MiscValue ;
2010-03-07 15:20:19 +01:00
uint16 skillval = unitTarget -> ToPlayer () -> GetPureSkillValue ( skillid );
2011-07-26 23:09:28 +02:00
unitTarget -> ToPlayer () -> SetSkill ( skillid , m_spellInfo -> Effects [ effIndex ]. CalcValue (), skillval ? skillval : 1 , damage * 75 );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2012-10-26 21:13:00 +02:00
void Spell :: EffectPlayMovie ( SpellEffIndex effIndex )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2009-11-01 17:53:07 -08:00
if ( unitTarget -> GetTypeId () != TYPEID_PLAYER )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2012-10-26 21:13:00 +02:00
uint32 movieId = GetSpellInfo () -> Effects [ effIndex ]. MiscValue ;
if ( ! sMovieStore . LookupEntry ( movieId ))
2009-03-15 17:20:15 -06:00
return ;
2009-10-17 15:51:44 -07:00
2012-10-26 21:13:00 +02:00
unitTarget -> ToPlayer () -> SendMovieStart ( movieId );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectTradeSkill ( SpellEffIndex /*effIndex*/ )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT )
return ;
if ( m_caster -> GetTypeId () != TYPEID_PLAYER )
2008-10-11 14:16:25 -05:00
return ;
2011-07-26 23:09:28 +02:00
// uint32 skillid = m_spellInfo->Effects[i].MiscValue;
2010-03-07 15:20:19 +01:00
// uint16 skillmax = unitTarget->ToPlayer()->(skillid);
2011-09-25 13:29:17 +02:00
// m_caster->ToPlayer()->SetSkill(skillid, skillval?skillval:1, skillmax+75);
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectEnchantItemPerm ( SpellEffIndex effIndex )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2009-11-01 17:53:07 -08:00
if ( m_caster -> GetTypeId () != TYPEID_PLAYER )
2008-10-11 14:16:25 -05:00
return ;
if ( ! itemTarget )
return ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
Player * p_caster = ( Player * ) m_caster ;
2009-10-17 15:51:44 -07:00
2009-05-01 15:40:49 +02:00
// Handle vellums
2012-08-15 16:30:49 +01:00
if ( itemTarget -> IsVellum ())
2009-05-01 15:40:49 +02:00
{
// destroy one vellum from stack
2009-11-01 17:53:07 -08:00
uint32 count = 1 ;
2011-04-29 20:47:02 +02:00
p_caster -> DestroyItemCount ( itemTarget , count , true );
2009-05-01 17:21:16 +02:00
unitTarget = p_caster ;
2009-05-01 15:40:49 +02:00
// and add a scroll
2011-07-26 23:09:28 +02:00
DoCreateItem ( effIndex , m_spellInfo -> Effects [ effIndex ]. ItemType );
2009-05-01 15:40:49 +02:00
itemTarget = NULL ;
2011-06-23 13:28:52 +02:00
m_targets . SetItemTarget ( NULL );
2009-05-01 15:40:49 +02:00
}
else
{
2009-05-01 17:21:16 +02:00
// do not increase skill if vellum used
2011-04-28 22:42:33 +02:00
if ( ! ( m_CastItem && m_CastItem -> GetTemplate () -> Flags & ITEM_PROTO_FLAG_TRIGGERED_CAST ))
2009-05-01 17:21:16 +02:00
p_caster -> UpdateCraftSkill ( m_spellInfo -> Id );
2009-10-17 15:51:44 -07:00
2011-07-26 23:09:28 +02:00
uint32 enchant_id = m_spellInfo -> Effects [ effIndex ]. MiscValue ;
2009-05-01 15:40:49 +02:00
if ( ! enchant_id )
return ;
2009-10-17 15:51:44 -07:00
2011-09-15 14:08:17 +02:00
SpellItemEnchantmentEntry const * pEnchant = sSpellItemEnchantmentStore . LookupEntry ( enchant_id );
2010-04-07 19:14:10 +02:00
if ( ! pEnchant )
2009-05-01 15:40:49 +02:00
return ;
2010-10-07 14:00:52 +02:00
2009-05-01 15:40:49 +02:00
// item can be in trade slot and have owner diff. from caster
Player * item_owner = itemTarget -> GetOwner ();
2009-11-01 17:53:07 -08:00
if ( ! item_owner )
2009-05-01 15:40:49 +02:00
return ;
2009-10-17 15:51:44 -07:00
2011-09-08 15:11:55 +02:00
if ( item_owner != p_caster && ! AccountMgr :: IsPlayerAccount ( p_caster -> GetSession () -> GetSecurity ()) && sWorld -> getBoolConfig ( CONFIG_GM_LOG_TRADE ))
2009-05-01 15:40:49 +02:00
{
2011-04-29 20:47:02 +02:00
sLog -> outCommand ( p_caster -> GetSession () -> GetAccountId (), "GM %s (Account: %u) enchanting(perm): %s (Entry: %d) for player: %s (Account: %u)" ,
2012-10-24 13:29:34 +02:00
p_caster -> GetName (). c_str (), p_caster -> GetSession () -> GetAccountId (),
2011-04-29 19:59:40 +02:00
itemTarget -> GetTemplate () -> Name1 . c_str (), itemTarget -> GetEntry (),
2012-10-24 13:29:34 +02:00
item_owner -> GetName (). c_str (), item_owner -> GetSession () -> GetAccountId ());
2009-05-01 15:40:49 +02:00
}
2009-10-17 15:51:44 -07:00
2009-05-01 15:40:49 +02:00
// remove old enchanting before applying new if equipped
2011-04-29 20:47:02 +02:00
item_owner -> ApplyEnchantment ( itemTarget , PERM_ENCHANTMENT_SLOT , false );
2009-10-17 15:51:44 -07:00
2009-05-01 15:40:49 +02:00
itemTarget -> SetEnchantment ( PERM_ENCHANTMENT_SLOT , enchant_id , 0 , 0 );
2009-10-17 15:51:44 -07:00
2009-05-01 15:40:49 +02:00
// add new enchanting if equipped
2011-04-29 20:47:02 +02:00
item_owner -> ApplyEnchantment ( itemTarget , PERM_ENCHANTMENT_SLOT , true );
2010-09-21 21:55:16 +02:00
2012-06-23 12:31:46 +02:00
item_owner -> RemoveTradeableItem ( itemTarget );
2011-10-18 10:44:45 +02:00
itemTarget -> ClearSoulboundTradeable ( item_owner );
2009-05-01 15:40:49 +02:00
}
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectEnchantItemPrismatic ( SpellEffIndex effIndex )
2009-02-03 19:12:17 -06:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2009-11-01 17:53:07 -08:00
if ( m_caster -> GetTypeId () != TYPEID_PLAYER )
2009-02-03 19:12:17 -06:00
return ;
if ( ! itemTarget )
return ;
2009-10-17 15:51:44 -07:00
2009-02-03 19:12:17 -06:00
Player * p_caster = ( Player * ) m_caster ;
2009-10-17 15:51:44 -07:00
2011-07-26 23:09:28 +02:00
uint32 enchant_id = m_spellInfo -> Effects [ effIndex ]. MiscValue ;
2009-02-03 19:12:17 -06:00
if ( ! enchant_id )
return ;
2009-10-17 15:51:44 -07:00
2011-09-15 14:08:17 +02:00
SpellItemEnchantmentEntry const * pEnchant = sSpellItemEnchantmentStore . LookupEntry ( enchant_id );
2010-04-07 19:14:10 +02:00
if ( ! pEnchant )
2009-02-03 19:12:17 -06:00
return ;
2009-10-17 15:51:44 -07:00
2009-02-03 19:12:17 -06:00
// support only enchantings with add socket in this slot
{
bool add_socket = false ;
2010-09-28 08:21:51 +03:00
for ( uint8 i = 0 ; i < MAX_ITEM_ENCHANTMENT_EFFECTS ; ++ i )
2009-02-03 19:12:17 -06:00
{
2010-04-07 23:25:02 +02:00
if ( pEnchant -> type [ i ] == ITEM_ENCHANTMENT_TYPE_PRISMATIC_SOCKET )
2009-02-03 19:12:17 -06:00
{
add_socket = true ;
break ;
}
}
2010-04-07 19:14:10 +02:00
if ( ! add_socket )
2009-02-03 19:12:17 -06:00
{
2012-08-03 14:20:18 +02:00
sLog -> outError ( LOG_FILTER_SPELLS_AURAS , "Spell::EffectEnchantItemPrismatic: attempt apply enchant spell %u with SPELL_EFFECT_ENCHANT_ITEM_PRISMATIC (%u) but without ITEM_ENCHANTMENT_TYPE_PRISMATIC_SOCKET (%u), not suppoted yet." ,
2011-04-29 20:47:02 +02:00
m_spellInfo -> Id , SPELL_EFFECT_ENCHANT_ITEM_PRISMATIC , ITEM_ENCHANTMENT_TYPE_PRISMATIC_SOCKET );
2009-02-03 19:12:17 -06:00
return ;
}
}
2009-10-17 15:51:44 -07:00
2009-02-03 19:12:17 -06:00
// item can be in trade slot and have owner diff. from caster
Player * item_owner = itemTarget -> GetOwner ();
2009-11-01 17:53:07 -08:00
if ( ! item_owner )
2009-02-03 19:12:17 -06:00
return ;
2009-10-17 15:51:44 -07:00
2011-09-08 15:11:55 +02:00
if ( item_owner != p_caster && ! AccountMgr :: IsPlayerAccount ( p_caster -> GetSession () -> GetSecurity ()) && sWorld -> getBoolConfig ( CONFIG_GM_LOG_TRADE ))
2009-02-03 19:12:17 -06:00
{
2011-04-29 20:47:02 +02:00
sLog -> outCommand ( p_caster -> GetSession () -> GetAccountId (), "GM %s (Account: %u) enchanting(perm): %s (Entry: %d) for player: %s (Account: %u)" ,
2012-10-24 13:29:34 +02:00
p_caster -> GetName (). c_str (), p_caster -> GetSession () -> GetAccountId (),
2011-04-29 19:59:40 +02:00
itemTarget -> GetTemplate () -> Name1 . c_str (), itemTarget -> GetEntry (),
2012-10-24 13:29:34 +02:00
item_owner -> GetName (). c_str (), item_owner -> GetSession () -> GetAccountId ());
2009-02-03 19:12:17 -06:00
}
2009-10-17 15:51:44 -07:00
2009-02-03 19:12:17 -06:00
// remove old enchanting before applying new if equipped
2011-04-29 20:47:02 +02:00
item_owner -> ApplyEnchantment ( itemTarget , PRISMATIC_ENCHANTMENT_SLOT , false );
2009-10-17 15:51:44 -07:00
2009-02-03 19:12:17 -06:00
itemTarget -> SetEnchantment ( PRISMATIC_ENCHANTMENT_SLOT , enchant_id , 0 , 0 );
2009-10-17 15:51:44 -07:00
2009-02-03 19:12:17 -06:00
// add new enchanting if equipped
2011-04-29 20:47:02 +02:00
item_owner -> ApplyEnchantment ( itemTarget , PRISMATIC_ENCHANTMENT_SLOT , true );
2010-09-21 21:55:16 +02:00
2012-06-23 12:31:46 +02:00
item_owner -> RemoveTradeableItem ( itemTarget );
2011-10-18 10:44:45 +02:00
itemTarget -> ClearSoulboundTradeable ( item_owner );
2009-02-03 19:12:17 -06:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectEnchantItemTmp ( SpellEffIndex effIndex )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2009-11-01 17:53:07 -08:00
if ( m_caster -> GetTypeId () != TYPEID_PLAYER )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
Player * p_caster = ( Player * ) m_caster ;
2009-10-17 15:51:44 -07:00
2009-12-17 12:23:01 +01:00
if ( ! itemTarget )
return ;
2011-07-26 23:09:28 +02:00
uint32 enchant_id = m_spellInfo -> Effects [ effIndex ]. MiscValue ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
if ( ! enchant_id )
{
2012-08-03 14:20:18 +02:00
sLog -> outError ( LOG_FILTER_SPELLS_AURAS , "Spell %u Effect %u (SPELL_EFFECT_ENCHANT_ITEM_TEMPORARY) have 0 as enchanting id" , m_spellInfo -> Id , effIndex );
2008-10-11 14:16:25 -05:00
return ;
}
2009-10-17 15:51:44 -07:00
2011-09-15 14:08:17 +02:00
SpellItemEnchantmentEntry const * pEnchant = sSpellItemEnchantmentStore . LookupEntry ( enchant_id );
2009-11-01 17:53:07 -08:00
if ( ! pEnchant )
2008-10-11 14:16:25 -05:00
{
2012-08-03 14:20:18 +02:00
sLog -> outError ( LOG_FILTER_SPELLS_AURAS , "Spell %u Effect %u (SPELL_EFFECT_ENCHANT_ITEM_TEMPORARY) have not existed enchanting id %u " , m_spellInfo -> Id , effIndex , enchant_id );
2008-10-11 14:16:25 -05:00
return ;
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// select enchantment duration
uint32 duration ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// rogue family enchantments exception by duration
2009-11-01 17:53:07 -08:00
if ( m_spellInfo -> Id == 38615 )
2008-10-11 14:16:25 -05:00
duration = 1800 ; // 30 mins
// other rogue family enchantments always 1 hour (some have spell damage=0, but some have wrong data in EffBasePoints)
2009-11-01 17:53:07 -08:00
else if ( m_spellInfo -> SpellFamilyName == SPELLFAMILY_ROGUE )
2008-10-11 14:16:25 -05:00
duration = 3600 ; // 1 hour
// shaman family enchantments
2009-11-01 17:53:07 -08:00
else if ( m_spellInfo -> SpellFamilyName == SPELLFAMILY_SHAMAN )
2008-10-11 14:16:25 -05:00
duration = 1800 ; // 30 mins
// other cases with this SpellVisual already selected
2009-11-01 17:53:07 -08:00
else if ( m_spellInfo -> SpellVisual [ 0 ] == 215 )
2008-10-11 14:16:25 -05:00
duration = 1800 ; // 30 mins
2010-05-24 13:56:21 +02:00
// some fishing pole bonuses except Glow Worm which lasts full hour
else if ( m_spellInfo -> SpellVisual [ 0 ] == 563 && m_spellInfo -> Id != 64401 )
2008-10-11 14:16:25 -05:00
duration = 600 ; // 10 mins
// shaman rockbiter enchantments
2009-11-01 17:53:07 -08:00
else if ( m_spellInfo -> SpellVisual [ 0 ] == 0 )
2008-10-11 14:16:25 -05:00
duration = 1800 ; // 30 mins
2009-11-01 17:53:07 -08:00
else if ( m_spellInfo -> Id == 29702 )
2008-10-11 14:16:25 -05:00
duration = 300 ; // 5 mins
2009-11-01 17:53:07 -08:00
else if ( m_spellInfo -> Id == 37360 )
2008-10-11 14:16:25 -05:00
duration = 300 ; // 5 mins
// default case
else
duration = 3600 ; // 1 hour
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// item can be in trade slot and have owner diff. from caster
Player * item_owner = itemTarget -> GetOwner ();
2009-11-01 17:53:07 -08:00
if ( ! item_owner )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2011-09-08 15:11:55 +02:00
if ( item_owner != p_caster && ! AccountMgr :: IsPlayerAccount ( p_caster -> GetSession () -> GetSecurity ()) && sWorld -> getBoolConfig ( CONFIG_GM_LOG_TRADE ))
2008-11-25 16:36:50 -06:00
{
2011-04-29 20:47:02 +02:00
sLog -> outCommand ( p_caster -> GetSession () -> GetAccountId (), "GM %s (Account: %u) enchanting(temp): %s (Entry: %d) for player: %s (Account: %u)" ,
2012-10-24 13:29:34 +02:00
p_caster -> GetName (). c_str (), p_caster -> GetSession () -> GetAccountId (),
2011-04-29 19:59:40 +02:00
itemTarget -> GetTemplate () -> Name1 . c_str (), itemTarget -> GetEntry (),
2012-10-24 13:29:34 +02:00
item_owner -> GetName (). c_str (), item_owner -> GetSession () -> GetAccountId ());
2008-11-25 16:36:50 -06:00
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// remove old enchanting before applying new if equipped
2011-04-29 20:47:02 +02:00
item_owner -> ApplyEnchantment ( itemTarget , TEMP_ENCHANTMENT_SLOT , false );
2009-10-17 15:51:44 -07:00
2009-05-31 15:56:51 -05:00
itemTarget -> SetEnchantment ( TEMP_ENCHANTMENT_SLOT , enchant_id , duration * 1000 , 0 );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// add new enchanting if equipped
2009-05-31 15:56:51 -05:00
item_owner -> ApplyEnchantment ( itemTarget , TEMP_ENCHANTMENT_SLOT , true );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectTameCreature ( SpellEffIndex /*effIndex*/ )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2009-11-01 17:53:07 -08:00
if ( m_caster -> GetPetGUID ())
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2009-11-01 17:53:07 -08:00
if ( ! unitTarget )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2009-11-01 17:53:07 -08:00
if ( unitTarget -> GetTypeId () != TYPEID_UNIT )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2010-03-07 18:30:53 +01:00
Creature * creatureTarget = unitTarget -> ToCreature ();
2009-10-17 15:51:44 -07:00
2009-11-01 17:53:07 -08:00
if ( creatureTarget -> isPet ())
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2009-11-01 17:53:07 -08:00
if ( m_caster -> getClass () != CLASS_HUNTER )
2008-11-04 09:23:06 -06:00
return ;
2009-10-17 15:51:44 -07:00
2008-11-04 09:23:06 -06:00
// cast finish successfully
//SendChannelUpdate(0);
finish ();
2009-10-17 15:51:44 -07:00
2011-04-29 20:47:02 +02:00
Pet * pet = m_caster -> CreateTamedPetFrom ( creatureTarget , m_spellInfo -> Id );
2009-11-01 17:53:07 -08:00
if ( ! pet ) // in very specific state like near world end/etc.
2009-06-02 17:40:22 -05:00
return ;
2009-10-17 15:51:44 -07:00
2009-06-18 17:05:01 -05:00
// "kill" original creature
2011-01-02 21:33:37 +01:00
creatureTarget -> DespawnOrUnsummon ();
2009-10-17 15:51:44 -07:00
2009-11-01 17:53:07 -08:00
uint8 level = ( creatureTarget -> getLevel () < ( m_caster -> getLevel () - 5 )) ? ( m_caster -> getLevel () - 5 ) : creatureTarget -> getLevel ();
2009-10-17 15:51:44 -07:00
2008-11-04 09:23:06 -06:00
// prepare visual effect for levelup
2008-12-24 09:58:26 -06:00
pet -> SetUInt32Value ( UNIT_FIELD_LEVEL , level - 1 );
2009-10-17 15:51:44 -07:00
2008-11-04 09:23:06 -06:00
// add to world
2011-10-10 17:39:34 -04:00
pet -> GetMap () -> AddToMap ( pet -> ToCreature ());
2009-10-17 15:51:44 -07:00
2008-11-04 09:23:06 -06:00
// visual effect for levelup
2008-12-24 09:58:26 -06:00
pet -> SetUInt32Value ( UNIT_FIELD_LEVEL , level );
2009-10-17 15:51:44 -07:00
2008-11-04 09:23:06 -06:00
// caster have pet now
2009-05-02 19:24:22 -05:00
m_caster -> SetMinion ( pet , true );
2009-10-17 16:20:24 -07:00
2009-08-17 04:45:34 +02:00
pet -> InitTalentForLevel ();
2009-10-17 15:51:44 -07:00
2009-11-01 17:53:07 -08:00
if ( m_caster -> GetTypeId () == TYPEID_PLAYER )
2008-11-04 09:23:06 -06:00
{
pet -> SavePetToDB ( PET_SAVE_AS_CURRENT );
2010-03-07 15:20:19 +01:00
m_caster -> ToPlayer () -> PetSpellInitialize ();
2008-10-11 14:16:25 -05:00
}
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectSummonPet ( SpellEffIndex effIndex )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT )
return ;
2011-06-20 04:04:20 +07:00
Player * owner = NULL ;
2009-11-01 17:53:07 -08:00
if ( m_originalCaster )
2009-02-24 20:52:55 -06:00
{
2011-08-03 08:18:24 +02:00
owner = m_originalCaster -> ToPlayer ();
if ( ! owner && m_originalCaster -> ToCreature () -> isTotem ())
2009-02-24 20:52:55 -06:00
owner = m_originalCaster -> GetCharmerOrOwnerPlayerOrPlayerItself ();
}
2009-10-17 15:51:44 -07:00
2011-07-26 23:09:28 +02:00
uint32 petentry = m_spellInfo -> Effects [ effIndex ]. MiscValue ;
2009-10-17 15:51:44 -07:00
2009-11-01 17:53:07 -08:00
if ( ! owner )
2008-12-30 22:01:45 -06:00
{
2011-09-15 14:08:17 +02:00
SummonPropertiesEntry const * properties = sSummonPropertiesStore . LookupEntry ( 67 );
2010-04-07 19:14:10 +02:00
if ( properties )
2012-02-09 20:26:30 +01:00
SummonGuardian ( effIndex , petentry , properties , 1 );
2008-12-30 22:01:45 -06:00
return ;
}
2009-10-17 15:51:44 -07:00
2011-06-20 04:04:20 +07:00
Pet * OldSummon = owner -> GetPet ();
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// if pet requested type already exist
2009-11-01 17:53:07 -08:00
if ( OldSummon )
2008-10-11 14:16:25 -05:00
{
2009-11-01 17:53:07 -08:00
if ( petentry == 0 || OldSummon -> GetEntry () == petentry )
2008-10-11 14:16:25 -05:00
{
// pet in corpse state can't be summoned
2009-11-01 17:53:07 -08:00
if ( OldSummon -> isDead ())
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2010-07-30 20:04:28 +02:00
ASSERT ( OldSummon -> GetMap () == owner -> GetMap ());
2009-10-17 15:51:44 -07:00
2011-04-29 20:47:02 +02:00
//OldSummon->GetMap()->Remove(OldSummon->ToCreature(), false);
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
float px , py , pz ;
2009-02-24 20:52:55 -06:00
owner -> GetClosePoint ( px , py , pz , OldSummon -> GetObjectSize ());
2009-10-17 15:51:44 -07:00
2009-08-26 21:17:47 -05:00
OldSummon -> NearTeleportTo ( px , py , pz , OldSummon -> GetOrientation ());
//OldSummon->Relocate(px, py, pz, OldSummon->GetOrientation());
//OldSummon->SetMap(owner->GetMap());
2010-03-07 18:30:53 +01:00
//owner->GetMap()->Add(OldSummon->ToCreature());
2009-10-17 15:51:44 -07:00
2010-04-07 22:59:46 +02:00
if ( owner -> GetTypeId () == TYPEID_PLAYER && OldSummon -> isControlled ())
2010-03-07 15:20:19 +01:00
owner -> ToPlayer () -> PetSpellInitialize ();
2009-11-01 17:53:07 -08:00
2008-10-11 14:16:25 -05:00
return ;
}
2009-10-17 15:51:44 -07:00
2009-11-01 17:53:07 -08:00
if ( owner -> GetTypeId () == TYPEID_PLAYER )
2011-04-29 20:47:02 +02:00
owner -> ToPlayer () -> RemovePet ( OldSummon , ( OldSummon -> getPetType () == HUNTER_PET ? PET_SAVE_AS_DELETED : PET_SAVE_NOT_IN_SLOT ), false );
2008-10-11 14:16:25 -05:00
else
return ;
}
2009-10-17 15:51:44 -07:00
2009-02-24 20:52:55 -06:00
float x , y , z ;
owner -> GetClosePoint ( x , y , z , owner -> GetObjectSize ());
Pet * pet = owner -> SummonPet ( petentry , x , y , z , owner -> GetOrientation (), SUMMON_PET , 0 );
2009-11-01 17:53:07 -08:00
if ( ! pet )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2009-11-01 17:53:07 -08:00
if ( m_caster -> GetTypeId () == TYPEID_UNIT )
2008-10-11 14:16:25 -05:00
{
2010-03-07 18:30:53 +01:00
if ( m_caster -> ToCreature () -> isTotem ())
2009-03-05 18:48:56 -06:00
pet -> SetReactState ( REACT_AGGRESSIVE );
2008-11-18 19:40:06 -06:00
else
2009-03-05 18:48:56 -06:00
pet -> SetReactState ( REACT_DEFENSIVE );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2009-02-24 20:52:55 -06:00
pet -> SetUInt32Value ( UNIT_CREATED_BY_SPELL , m_spellInfo -> Id );
2009-10-17 15:51:44 -07:00
2009-02-24 20:52:55 -06:00
// generate new name for summon pet
2010-12-22 21:25:23 +01:00
std :: string new_name = sObjectMgr -> GeneratePetName ( petentry );
2009-11-01 17:53:07 -08:00
if ( ! new_name . empty ())
2009-02-24 20:52:55 -06:00
pet -> SetName ( new_name );
2010-08-27 17:49:32 +02:00
2010-08-27 19:36:27 +02:00
ExecuteLogEffectSummonObject ( effIndex , pet );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectLearnPetSpell ( SpellEffIndex effIndex )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2011-09-24 02:01:18 +02:00
if ( ! unitTarget )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2011-09-24 02:01:18 +02:00
if ( unitTarget -> ToPlayer ())
{
EffectLearnSpell ( effIndex );
2008-10-11 14:16:25 -05:00
return ;
2011-09-24 02:01:18 +02:00
}
Pet * pet = unitTarget -> ToPet ();
if ( ! pet )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2011-09-15 14:08:17 +02:00
SpellInfo const * learn_spellproto = sSpellMgr -> GetSpellInfo ( m_spellInfo -> Effects [ effIndex ]. TriggerSpell );
2009-11-01 17:53:07 -08:00
if ( ! learn_spellproto )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
pet -> learnSpell ( learn_spellproto -> Id );
pet -> SavePetToDB ( PET_SAVE_AS_CURRENT );
2011-09-24 02:01:18 +02:00
pet -> GetOwner () -> PetSpellInitialize ();
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectTaunt ( SpellEffIndex /*effIndex*/ )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2009-04-27 18:42:35 -05:00
if ( ! unitTarget )
return ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// this effect use before aura Taunt apply for prevent taunt already attacking target
// for spell as marked "non effective at already attacking target"
2010-04-07 19:14:10 +02:00
if ( ! unitTarget || ! unitTarget -> CanHaveThreatList ()
2009-04-17 18:08:52 -05:00
|| unitTarget -> getVictim () == m_caster )
2008-10-11 14:16:25 -05:00
{
2009-04-17 18:08:52 -05:00
SendCastResult ( SPELL_FAILED_DONT_REPORT );
return ;
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// Also use this effect to set the taunter's threat to the taunted creature's highest value
2009-11-01 17:53:07 -08:00
if ( unitTarget -> getThreatManager (). getCurrentVictim ())
2009-04-17 18:08:52 -05:00
{
float myThreat = unitTarget -> getThreatManager (). getThreat ( m_caster );
float itsThreat = unitTarget -> getThreatManager (). getCurrentVictim () -> getThreat ();
2009-11-01 17:53:07 -08:00
if ( itsThreat > myThreat )
2009-04-17 18:08:52 -05:00
unitTarget -> getThreatManager (). addThreat ( m_caster , itsThreat - myThreat );
}
2009-10-17 15:51:44 -07:00
2009-06-17 00:44:35 +02:00
//Set aggro victim to caster
2009-11-01 17:53:07 -08:00
if ( ! unitTarget -> getThreatManager (). getOnlineContainer (). empty ())
2010-03-09 11:11:10 +01:00
if ( HostileReference * forcedVictim = unitTarget -> getThreatManager (). getOnlineContainer (). getReferenceByTarget ( m_caster ))
2009-06-17 00:44:35 +02:00
unitTarget -> getThreatManager (). setCurrentVictim ( forcedVictim );
2009-10-17 15:51:44 -07:00
2010-03-07 18:30:53 +01:00
if ( unitTarget -> ToCreature () -> IsAIEnabled && ! unitTarget -> ToCreature () -> HasReactState ( REACT_PASSIVE ))
unitTarget -> ToCreature () -> AI () -> AttackStart ( m_caster );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2011-09-25 13:29:17 +02:00
void Spell :: EffectWeaponDmg ( SpellEffIndex effIndex )
2008-12-25 17:39:46 -06:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_LAUNCH_TARGET )
return ;
2009-10-17 15:51:44 -07:00
2011-08-03 08:18:24 +02:00
if ( ! unitTarget || ! unitTarget -> isAlive ())
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// multiple weapon dmg effect workaround
// execute only the last weapon damage
// and handle all effects at once
2010-09-28 08:21:51 +03:00
for ( uint32 j = effIndex + 1 ; j < MAX_SPELL_EFFECTS ; ++ j )
2008-10-11 14:16:25 -05:00
{
2011-07-26 23:09:28 +02:00
switch ( m_spellInfo -> Effects [ j ]. Effect )
2008-10-11 14:16:25 -05:00
{
case SPELL_EFFECT_WEAPON_DAMAGE :
case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL :
case SPELL_EFFECT_NORMALIZED_WEAPON_DMG :
case SPELL_EFFECT_WEAPON_PERCENT_DAMAGE :
2009-11-01 17:53:07 -08:00
return ; // we must calculate only at last weapon effect
2008-10-11 14:16:25 -05:00
break ;
}
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// some spell specific modifiers
float totalDamagePercentMod = 1.0f ; // applied to final bonus+weapon damage
2008-12-17 23:27:01 -06:00
int32 fixed_bonus = 0 ;
2008-10-11 14:16:25 -05:00
int32 spell_bonus = 0 ; // bonus specific for spell
2009-10-17 15:51:44 -07:00
2009-11-01 17:53:07 -08:00
switch ( m_spellInfo -> SpellFamilyName )
2008-10-11 14:16:25 -05:00
{
2010-08-18 17:19:47 +02:00
case SPELLFAMILY_GENERIC :
{
switch ( m_spellInfo -> Id )
{
case 69055 : // Saber Lash
case 70814 : // Saber Lash
{
uint32 count = 0 ;
for ( std :: list < TargetInfo >:: iterator ihit = m_UniqueTargetInfo . begin (); ihit != m_UniqueTargetInfo . end (); ++ ihit )
2010-08-27 19:36:27 +02:00
if ( ihit -> effectMask & ( 1 << effIndex ))
2010-08-18 17:19:47 +02:00
++ count ;
totalDamagePercentMod /= count ;
break ;
}
}
break ;
}
2008-10-11 14:16:25 -05:00
case SPELLFAMILY_WARRIOR :
{
2010-01-05 14:36:06 +03:00
// Devastate (player ones)
2009-11-01 17:53:07 -08:00
if ( m_spellInfo -> SpellFamilyFlags [ 1 ] & 0x40 )
2008-10-11 14:16:25 -05:00
{
2010-01-05 14:36:06 +03:00
// Player can apply only 58567 Sunder Armor effect.
bool needCast = ! unitTarget -> HasAura ( 58567 , m_caster -> GetGUID ());
if ( needCast )
m_caster -> CastSpell ( unitTarget , 58567 , true );
2009-10-17 15:51:44 -07:00
2011-09-15 14:08:17 +02:00
if ( Aura * aur = unitTarget -> GetAura ( 58567 , m_caster -> GetGUID ()))
2008-11-25 19:14:55 -06:00
{
2012-08-17 09:48:53 -05:00
if ( int32 num = ( needCast ? 0 : 1 ))
2010-01-10 01:23:15 +01:00
aur -> ModStackAmount ( num );
2010-01-05 14:36:06 +03:00
fixed_bonus += ( aur -> GetStackAmount () - 1 ) * CalculateDamage ( 2 , unitTarget );
2008-10-11 14:16:25 -05:00
}
}
break ;
}
case SPELLFAMILY_ROGUE :
{
2012-08-17 12:24:21 -05:00
// Hemorrhage
if ( m_spellInfo -> SpellFamilyFlags [ 0 ] & 0x2000000 )
2009-04-14 20:21:16 +02:00
{
2012-08-17 12:24:21 -05:00
if ( m_caster -> GetTypeId () == TYPEID_PLAYER )
m_caster -> ToPlayer () -> AddComboPoints ( unitTarget , 1 , this );
2009-04-14 20:21:16 +02:00
// 50% more damage with daggers
2009-11-01 17:53:07 -08:00
if ( m_caster -> GetTypeId () == TYPEID_PLAYER )
2010-03-07 15:20:19 +01:00
if ( Item * item = m_caster -> ToPlayer () -> GetWeaponForAttack ( m_attackType , true ))
2011-04-28 22:42:33 +02:00
if ( item -> GetTemplate () -> SubClass == ITEM_SUBCLASS_WEAPON_DAGGER )
2009-08-11 19:57:27 +02:00
totalDamagePercentMod *= 1.5f ;
2009-04-14 20:21:16 +02:00
}
2008-10-11 14:16:25 -05:00
break ;
}
case SPELLFAMILY_SHAMAN :
{
// Skyshatter Harness item set bonus
// Stormstrike
2011-09-15 14:08:17 +02:00
if ( AuraEffect * aurEff = m_caster -> IsScriptOverriden ( m_spellInfo , 5634 ))
2009-07-13 21:27:05 +02:00
m_caster -> CastSpell ( m_caster , 38430 , true , NULL , aurEff );
2008-12-17 23:27:01 -06:00
break ;
}
case SPELLFAMILY_DRUID :
{
// Mangle (Cat): CP
2010-04-07 19:14:10 +02:00
if ( m_spellInfo -> SpellFamilyFlags [ 1 ] & 0x400 )
2008-12-17 23:27:01 -06:00
{
2010-04-07 19:14:10 +02:00
if ( m_caster -> GetTypeId () == TYPEID_PLAYER )
2010-12-11 20:37:38 +06:00
m_caster -> ToPlayer () -> AddComboPoints ( unitTarget , 1 , this );
2008-12-17 23:27:01 -06:00
}
2009-06-28 19:39:15 +02:00
// Shred, Maul - Rend and Tear
2010-02-14 19:13:14 -07:00
else if ( m_spellInfo -> SpellFamilyFlags [ 0 ] & 0x00008800 && unitTarget -> HasAuraState ( AURA_STATE_BLEEDING ))
2009-06-28 19:39:15 +02:00
{
2010-01-10 01:23:15 +01:00
if ( AuraEffect const * rendAndTear = m_caster -> GetDummyAuraEffect ( SPELLFAMILY_DRUID , 2859 , 0 ))
2012-10-02 12:17:42 +02:00
AddPct ( totalDamagePercentMod , rendAndTear -> GetAmount ());
2009-06-28 19:39:15 +02:00
}
2008-12-17 23:27:01 -06:00
break ;
2008-10-11 14:16:25 -05:00
}
2009-12-20 17:25:10 -06:00
case SPELLFAMILY_HUNTER :
{
2010-01-13 09:54:03 +01:00
// Kill Shot - bonus damage from Ranged Attack Power
2010-04-07 19:14:10 +02:00
if ( m_spellInfo -> SpellFamilyFlags [ 1 ] & 0x800000 )
2012-08-17 12:24:21 -05:00
spell_bonus += int32 ( 0.45f * m_caster -> GetTotalAttackPowerValue ( RANGED_ATTACK ));
2009-12-20 17:25:10 -06:00
break ;
}
2009-06-13 17:28:38 +02:00
case SPELLFAMILY_DEATHKNIGHT :
{
2009-08-08 21:51:00 +02:00
// Blood Strike
2011-07-26 23:09:28 +02:00
if ( m_spellInfo -> SpellFamilyFlags [ 0 ] & 0x400000 )
2009-08-08 21:51:00 +02:00
{
2012-08-17 00:10:19 +02:00
float bonusPct = m_spellInfo -> Effects [ EFFECT_2 ]. CalcValue ( m_caster ) * unitTarget -> GetDiseasesByCaster ( m_caster -> GetGUID ()) / 2.0f ;
2012-06-14 22:36:56 +03:00
// Death Knight T8 Melee 4P Bonus
if ( AuraEffect const * aurEff = m_caster -> GetAuraEffect ( 64736 , EFFECT_0 ))
2012-10-02 12:17:42 +02:00
AddPct ( bonusPct , aurEff -> GetAmount ());
AddPct ( totalDamagePercentMod , bonusPct );
2010-12-04 10:31:14 +01:00
break ;
2009-08-08 21:51:00 +02:00
}
// Death Strike
2011-07-26 23:09:28 +02:00
if ( m_spellInfo -> SpellFamilyFlags [ 0 ] & 0x10 )
2009-08-08 21:51:00 +02:00
{
// Glyph of Death Strike
2012-08-17 12:24:21 -05:00
// 2% more damage per 5 runic power, up to a maximum of 40%
2011-06-11 22:35:29 +02:00
if ( AuraEffect const * aurEff = m_caster -> GetAuraEffect ( 59336 , EFFECT_0 ))
2012-08-17 12:24:21 -05:00
if ( uint32 runic = std :: min < uint32 > ( uint32 ( m_caster -> GetPower ( POWER_RUNIC_POWER ) / 2.5f ), aurEff -> GetSpellInfo () -> Effects [ EFFECT_1 ]. CalcValue ( m_caster )))
2012-10-02 12:17:42 +02:00
AddPct ( totalDamagePercentMod , runic );
2010-12-04 10:31:14 +01:00
break ;
2009-08-08 21:51:00 +02:00
}
2009-06-13 17:28:38 +02:00
// Obliterate (12.5% more damage per disease)
2011-07-26 23:09:28 +02:00
if ( m_spellInfo -> SpellFamilyFlags [ 1 ] & 0x20000 )
2009-06-14 20:07:12 +02:00
{
2012-08-17 12:24:21 -05:00
float bonusPct = m_spellInfo -> Effects [ EFFECT_2 ]. CalcValue ( m_caster ) * unitTarget -> GetDiseasesByCaster ( m_caster -> GetGUID (), false ) / 2.0f ;
2012-06-14 22:36:56 +03:00
// Death Knight T8 Melee 4P Bonus
if ( AuraEffect const * aurEff = m_caster -> GetAuraEffect ( 64736 , EFFECT_0 ))
2012-10-02 12:17:42 +02:00
AddPct ( bonusPct , aurEff -> GetAmount ());
AddPct ( totalDamagePercentMod , bonusPct );
2010-12-04 10:31:14 +01:00
break ;
2009-06-14 20:07:12 +02:00
}
2009-08-08 21:51:00 +02:00
// Blood-Caked Strike - Blood-Caked Blade
2010-12-04 10:31:14 +01:00
if ( m_spellInfo -> SpellIconID == 1736 )
{
2012-10-02 12:17:42 +02:00
AddPct ( totalDamagePercentMod , unitTarget -> GetDiseasesByCaster ( m_caster -> GetGUID ()) * 12.5f );
2010-12-04 10:31:14 +01:00
break ;
}
// Heart Strike
2011-07-26 23:09:28 +02:00
if ( m_spellInfo -> SpellFamilyFlags [ 0 ] & 0x1000000 )
2010-12-04 10:31:14 +01:00
{
2012-08-17 00:10:19 +02:00
float bonusPct = m_spellInfo -> Effects [ EFFECT_2 ]. CalcValue ( m_caster ) * unitTarget -> GetDiseasesByCaster ( m_caster -> GetGUID ());
2012-06-14 22:36:56 +03:00
// Death Knight T8 Melee 4P Bonus
if ( AuraEffect const * aurEff = m_caster -> GetAuraEffect ( 64736 , EFFECT_0 ))
2012-10-02 12:17:42 +02:00
AddPct ( bonusPct , aurEff -> GetAmount ());
2012-06-14 22:36:56 +03:00
2012-10-02 12:17:42 +02:00
AddPct ( totalDamagePercentMod , bonusPct );
2010-12-04 10:31:14 +01:00
break ;
}
2009-06-13 17:28:38 +02:00
break ;
}
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2008-12-17 23:27:01 -06:00
bool normalized = false ;
2010-12-11 20:37:38 +06:00
float weaponDamagePercentMod = 1.0f ;
2010-09-28 08:21:51 +03:00
for ( int j = 0 ; j < MAX_SPELL_EFFECTS ; ++ j )
2008-10-11 14:16:25 -05:00
{
2011-07-26 23:09:28 +02:00
switch ( m_spellInfo -> Effects [ j ]. Effect )
2008-10-11 14:16:25 -05:00
{
case SPELL_EFFECT_WEAPON_DAMAGE :
case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL :
2009-05-31 15:56:51 -05:00
fixed_bonus += CalculateDamage ( j , unitTarget );
2008-10-11 14:16:25 -05:00
break ;
case SPELL_EFFECT_NORMALIZED_WEAPON_DMG :
2009-05-31 15:56:51 -05:00
fixed_bonus += CalculateDamage ( j , unitTarget );
2008-10-11 14:16:25 -05:00
normalized = true ;
break ;
case SPELL_EFFECT_WEAPON_PERCENT_DAMAGE :
2012-10-02 12:17:42 +02:00
ApplyPct ( weaponDamagePercentMod , CalculateDamage ( j , unitTarget ));
2009-03-28 16:34:34 -06:00
break ;
2008-10-11 14:16:25 -05:00
default :
break ; // not weapon damage effect, just skip
}
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// apply to non-weapon bonus weapon total pct effect, weapon total flat effect included in weapon damage
2010-04-07 19:14:10 +02:00
if ( fixed_bonus || spell_bonus )
2008-10-11 14:16:25 -05:00
{
UnitMods unitMod ;
2010-12-11 20:37:38 +06:00
switch ( m_attackType )
2008-10-11 14:16:25 -05:00
{
default :
case BASE_ATTACK : unitMod = UNIT_MOD_DAMAGE_MAINHAND ; break ;
case OFF_ATTACK : unitMod = UNIT_MOD_DAMAGE_OFFHAND ; break ;
case RANGED_ATTACK : unitMod = UNIT_MOD_DAMAGE_RANGED ; break ;
}
2009-10-17 15:51:44 -07:00
2009-10-07 19:34:20 +02:00
float weapon_total_pct = 1.0f ;
2010-04-07 22:59:46 +02:00
if ( m_spellInfo -> SchoolMask & SPELL_SCHOOL_MASK_NORMAL )
2009-10-07 19:34:20 +02:00
weapon_total_pct = m_caster -> GetModifierValue ( unitMod , TOTAL_PCT );
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( fixed_bonus )
2008-12-17 23:27:01 -06:00
fixed_bonus = int32 ( fixed_bonus * weapon_total_pct );
2010-04-07 19:14:10 +02:00
if ( spell_bonus )
2008-12-17 23:27:01 -06:00
spell_bonus = int32 ( spell_bonus * weapon_total_pct );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2009-10-07 19:34:20 +02:00
int32 weaponDamage = m_caster -> CalculateDamage ( m_attackType , normalized , true );
2009-10-17 15:51:44 -07:00
2008-12-17 23:27:01 -06:00
// Sequence is important
2010-09-28 08:21:51 +03:00
for ( int j = 0 ; j < MAX_SPELL_EFFECTS ; ++ j )
2008-12-17 23:27:01 -06:00
{
// We assume that a spell have at most one fixed_bonus
// and at most one weaponDamagePercentMod
2011-09-29 12:43:05 +02:00
switch ( m_spellInfo -> Effects [ j ]. Effect )
2008-12-17 23:27:01 -06:00
{
case SPELL_EFFECT_WEAPON_DAMAGE :
case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL :
case SPELL_EFFECT_NORMALIZED_WEAPON_DMG :
weaponDamage += fixed_bonus ;
break ;
case SPELL_EFFECT_WEAPON_PERCENT_DAMAGE :
2011-09-15 14:08:17 +02:00
weaponDamage = int32 ( weaponDamage * weaponDamagePercentMod );
2008-12-17 23:27:01 -06:00
default :
break ; // not weapon damage effect, just skip
}
}
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( spell_bonus )
2008-12-17 23:27:01 -06:00
weaponDamage += spell_bonus ;
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( totalDamagePercentMod != 1.0f )
2011-09-15 14:08:17 +02:00
weaponDamage = int32 ( weaponDamage * totalDamagePercentMod );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// prevent negative damage
2010-12-11 20:37:38 +06:00
uint32 eff_damage ( std :: max ( weaponDamage , 0 ));
2009-10-17 15:51:44 -07:00
2008-11-26 15:14:03 -06:00
// Add melee damage bonuses (also check for negative)
2012-05-30 08:01:02 +02:00
uint32 damage = m_caster -> MeleeDamageBonusDone ( unitTarget , eff_damage , m_attackType , m_spellInfo );
m_damage += unitTarget -> MeleeDamageBonusTaken ( m_caster , damage , m_attackType , m_spellInfo );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectThreat ( SpellEffIndex /*effIndex*/ )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2010-04-07 19:14:10 +02:00
if ( ! unitTarget || ! unitTarget -> isAlive () || ! m_caster -> isAlive ())
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( ! unitTarget -> CanHaveThreatList ())
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
unitTarget -> AddThreat ( m_caster , float ( damage ));
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectHealMaxHealth ( SpellEffIndex /*effIndex*/ )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2010-08-28 23:01:04 +02:00
if ( ! unitTarget || ! unitTarget -> isAlive ())
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2012-05-30 08:01:02 +02:00
int32 addhealth = 0 ;
2010-02-14 19:13:14 -07:00
2010-08-28 23:01:04 +02:00
// damage == 0 - heal for caster max health
if ( damage == 0 )
2009-05-31 20:45:34 -05:00
addhealth = m_caster -> GetMaxHealth ();
else
addhealth = unitTarget -> GetMaxHealth () - unitTarget -> GetHealth ();
2010-08-28 23:01:04 +02:00
2012-05-30 08:01:02 +02:00
m_healing += addhealth ;
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectInterruptCast ( SpellEffIndex effIndex )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2010-08-28 23:01:04 +02:00
if ( ! unitTarget || ! unitTarget -> isAlive ())
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// TODO: not all spells that used this effect apply cooldown at school spells
// also exist case: apply cooldown to interrupted cast only and to all spells
2011-11-05 05:21:37 +07:00
// there is no CURRENT_AUTOREPEAT_SPELL spells that can be interrupted
for ( uint32 i = CURRENT_FIRST_NON_MELEE_SPELL ; i < CURRENT_AUTOREPEAT_SPELL ; ++ i )
2008-10-11 14:16:25 -05:00
{
2009-08-19 16:52:51 -05:00
if ( Spell * spell = unitTarget -> GetCurrentSpell ( CurrentSpellTypes ( i )))
2008-10-11 14:16:25 -05:00
{
2011-07-26 23:09:28 +02:00
SpellInfo const * curSpellInfo = spell -> m_spellInfo ;
2008-10-11 14:16:25 -05:00
// check if we can interrupt spell
2009-08-19 16:52:51 -05:00
if (( spell -> getState () == SPELL_STATE_CASTING
2011-11-05 05:33:52 +07:00
|| ( spell -> getState () == SPELL_STATE_PREPARING && spell -> GetCastTime () > 0.0f ))
2012-12-24 10:13:15 -05:00
&& ( curSpellInfo -> PreventionType == SPELL_PREVENTION_TYPE_SILENCE || curSpellInfo -> PreventionType == SPELL_PREVENTION_TYPE_UNK )
2011-11-05 05:21:37 +07:00
&& (( i == CURRENT_GENERIC_SPELL && curSpellInfo -> InterruptFlags & SPELL_INTERRUPT_FLAG_INTERRUPT )
|| ( i == CURRENT_CHANNELED_SPELL && curSpellInfo -> ChannelInterruptFlags & CHANNEL_INTERRUPT_FLAG_INTERRUPT )))
2008-10-11 14:16:25 -05:00
{
2010-04-07 19:14:10 +02:00
if ( m_originalCaster )
2008-12-15 09:55:57 -06:00
{
2012-08-03 01:27:39 +03:00
int32 duration = m_spellInfo -> GetDuration ();
unitTarget -> ProhibitSpellSchool ( curSpellInfo -> GetSchoolMask (), unitTarget -> ModSpellDuration ( m_spellInfo , unitTarget , duration , false , 1 << effIndex ));
2008-12-15 09:55:57 -06:00
}
2010-08-27 17:49:32 +02:00
ExecuteLogEffectInterruptCast ( effIndex , unitTarget , curSpellInfo -> Id );
2009-08-19 16:52:51 -05:00
unitTarget -> InterruptSpell ( CurrentSpellTypes ( i ), false );
2008-10-11 14:16:25 -05:00
}
}
}
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectSummonObjectWild ( SpellEffIndex effIndex )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT )
return ;
2011-07-26 23:09:28 +02:00
uint32 gameobject_id = m_spellInfo -> Effects [ effIndex ]. MiscValue ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
GameObject * pGameObj = new GameObject ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
WorldObject * target = focusObject ;
2010-04-07 22:59:46 +02:00
if ( ! target )
2008-10-11 14:16:25 -05:00
target = m_caster ;
2009-10-17 15:51:44 -07:00
2009-05-31 15:56:51 -05:00
float x , y , z ;
2010-04-07 19:14:10 +02:00
if ( m_targets . HasDst ())
2012-05-30 08:01:02 +02:00
destTarget -> GetPosition ( x , y , z );
2008-10-11 14:16:25 -05:00
else
2009-05-31 15:56:51 -05:00
m_caster -> GetClosePoint ( x , y , z , DEFAULT_WORLD_OBJECT_SIZE );
2009-10-17 15:51:44 -07:00
2011-09-15 14:08:17 +02:00
Map * map = target -> GetMap ();
2009-10-17 15:51:44 -07:00
2010-12-22 21:25:23 +01:00
if ( ! pGameObj -> Create ( sObjectMgr -> GenerateLowGuid ( HIGHGUID_GAMEOBJECT ), gameobject_id , map ,
2009-04-27 18:36:10 -05:00
m_caster -> GetPhaseMask (), x , y , z , target -> GetOrientation (), 0.0f , 0.0f , 0.0f , 0.0f , 100 , GO_STATE_READY ))
2008-10-11 14:16:25 -05:00
{
delete pGameObj ;
return ;
}
2009-10-17 15:51:44 -07:00
2011-07-26 23:09:28 +02:00
int32 duration = m_spellInfo -> GetDuration ();
2009-10-17 15:51:44 -07:00
2010-07-12 00:30:17 +02:00
pGameObj -> SetRespawnTime ( duration > 0 ? duration / IN_MILLISECONDS : 0 );
2008-10-11 14:16:25 -05:00
pGameObj -> SetSpellId ( m_spellInfo -> Id );
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
ExecuteLogEffectSummonObject ( effIndex , pGameObj );
2010-08-27 17:49:32 +02:00
2009-08-08 12:25:20 -05:00
// Wild object not have owner and check clickable by players
2011-10-10 17:39:34 -04:00
map -> AddToMap ( pGameObj );
2009-10-17 15:51:44 -07:00
2012-10-04 12:49:58 +02:00
if ( pGameObj -> GetGoType () == GAMEOBJECT_TYPE_FLAGDROP )
if ( Player * player = m_caster -> ToPlayer ())
if ( Battleground * bg = player -> GetBattleground ())
bg -> SetDroppedFlagGUID ( pGameObj -> GetGUID (), player -> GetTeam () == ALLIANCE ? TEAM_HORDE : TEAM_ALLIANCE );
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( uint32 linkedEntry = pGameObj -> GetGOInfo () -> GetLinkedGameObjectEntry ())
2008-10-11 14:16:25 -05:00
{
GameObject * linkedGO = new GameObject ;
2010-12-22 21:25:23 +01:00
if ( linkedGO -> Create ( sObjectMgr -> GenerateLowGuid ( HIGHGUID_GAMEOBJECT ), linkedEntry , map ,
2009-04-27 18:36:10 -05:00
m_caster -> GetPhaseMask (), x , y , z , target -> GetOrientation (), 0.0f , 0.0f , 0.0f , 0.0f , 100 , GO_STATE_READY ))
2008-10-11 14:16:25 -05:00
{
2010-07-12 00:30:17 +02:00
linkedGO -> SetRespawnTime ( duration > 0 ? duration / IN_MILLISECONDS : 0 );
2008-10-11 14:16:25 -05:00
linkedGO -> SetSpellId ( m_spellInfo -> Id );
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
ExecuteLogEffectSummonObject ( effIndex , linkedGO );
2010-08-27 17:49:32 +02:00
2009-08-08 12:25:20 -05:00
// Wild object not have owner and check clickable by players
2011-10-10 17:39:34 -04:00
map -> AddToMap ( linkedGO );
2008-10-11 14:16:25 -05:00
}
else
{
delete linkedGO ;
linkedGO = NULL ;
return ;
}
}
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectScriptEffect ( SpellEffIndex effIndex )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2008-10-11 14:16:25 -05:00
// TODO: we must implement hunter pet summon at login there (spell 6962)
2009-10-17 15:51:44 -07:00
2011-09-29 12:43:05 +02:00
switch ( m_spellInfo -> SpellFamilyName )
2008-10-11 14:16:25 -05:00
{
2009-01-20 19:59:43 -06:00
case SPELLFAMILY_GENERIC :
2008-12-06 14:01:44 -06:00
{
2011-09-29 12:43:05 +02:00
switch ( m_spellInfo -> Id )
2009-01-20 19:59:43 -06:00
{
2009-08-23 17:59:32 +02:00
// Glyph of Backstab
case 63975 :
{
2011-07-21 20:38:13 +07:00
// search our Rupture aura on target
2011-06-11 22:35:29 +02:00
if ( AuraEffect const * aurEff = unitTarget -> GetAuraEffect ( SPELL_AURA_PERIODIC_DAMAGE , SPELLFAMILY_ROGUE , 0x00100000 , 0 , 0 , m_caster -> GetGUID ()))
2009-08-23 17:59:32 +02:00
{
2010-01-10 01:23:15 +01:00
uint32 countMin = aurEff -> GetBase () -> GetMaxDuration ();
2011-07-21 20:38:13 +07:00
uint32 countMax = 12000 ; // this can be wrong, duration should be based on combo-points
2009-08-23 17:59:32 +02:00
countMax += m_caster -> HasAura ( 56801 ) ? 4000 : 0 ;
2009-10-17 15:51:44 -07:00
2009-08-23 17:59:32 +02:00
if ( countMin < countMax )
{
2011-07-21 20:38:13 +07:00
aurEff -> GetBase () -> SetDuration ( uint32 ( aurEff -> GetBase () -> GetDuration () + 3000 ));
aurEff -> GetBase () -> SetMaxDuration ( countMin + 2000 );
2009-08-23 17:59:32 +02:00
}
2009-10-17 15:51:44 -07:00
2009-08-23 17:59:32 +02:00
}
return ;
2011-07-21 20:38:13 +07:00
}
// Glyph of Scourge Strike
case 69961 :
{
Unit :: AuraEffectList const & mPeriodic = unitTarget -> GetAuraEffectsByType ( SPELL_AURA_PERIODIC_DAMAGE );
for ( Unit :: AuraEffectList :: const_iterator i = mPeriodic . begin (); i != mPeriodic . end (); ++ i )
{
AuraEffect const * aurEff = * i ;
2011-07-26 23:09:28 +02:00
SpellInfo const * spellInfo = aurEff -> GetSpellInfo ();
2011-07-21 20:38:13 +07:00
// search our Blood Plague and Frost Fever on target
if ( spellInfo -> SpellFamilyName == SPELLFAMILY_DEATHKNIGHT && spellInfo -> SpellFamilyFlags [ 2 ] & 0x2 &&
aurEff -> GetCasterGUID () == m_caster -> GetGUID ())
{
uint32 countMin = aurEff -> GetBase () -> GetMaxDuration ();
2011-07-26 23:09:28 +02:00
uint32 countMax = spellInfo -> GetMaxDuration ();
2011-07-21 20:38:13 +07:00
// this Glyph
countMax += 9000 ;
// talent Epidemic
if ( AuraEffect const * epidemic = m_caster -> GetAuraEffect ( SPELL_AURA_ADD_FLAT_MODIFIER , SPELLFAMILY_DEATHKNIGHT , 234 , EFFECT_0 ))
countMax += epidemic -> GetAmount ();
if ( countMin < countMax )
{
aurEff -> GetBase () -> SetDuration ( aurEff -> GetBase () -> GetDuration () + 3000 );
aurEff -> GetBase () -> SetMaxDuration ( countMin + 3000 );
}
}
}
return ;
2009-08-23 17:59:32 +02:00
}
2009-07-22 17:10:30 +02:00
case 45204 : // Clone Me!
2011-04-08 23:16:57 +03:00
m_caster -> CastSpell ( unitTarget , damage , true );
break ;
2009-08-12 20:47:54 -05:00
case 55693 : // Remove Collapsing Cave Aura
2010-04-07 19:14:10 +02:00
if ( ! unitTarget )
2009-08-12 20:47:54 -05:00
return ;
2011-07-26 23:09:28 +02:00
unitTarget -> RemoveAurasDueToSpell ( m_spellInfo -> Effects [ effIndex ]. CalcValue ());
2009-08-12 20:47:54 -05:00
break ;
2009-01-20 19:59:43 -06:00
// PX-238 Winter Wondervolt TRAP
case 26275 :
{
2009-01-21 16:18:57 -06:00
uint32 spells [ 4 ] = { 26272 , 26157 , 26273 , 26274 };
2009-10-17 15:51:44 -07:00
2009-01-21 16:18:57 -06:00
// check presence
2009-10-17 16:20:24 -07:00
for ( uint8 j = 0 ; j < 4 ; ++ j )
2011-04-29 20:47:02 +02:00
if ( unitTarget -> HasAuraEffect ( spells [ j ], 0 ))
2009-01-21 16:18:57 -06:00
return ;
2009-10-17 15:51:44 -07:00
2009-01-21 16:18:57 -06:00
// select spell
2011-04-29 20:47:02 +02:00
uint32 iTmpSpellId = spells [ urand ( 0 , 3 )];
2009-10-17 15:51:44 -07:00
2009-01-21 16:18:57 -06:00
// cast
2009-01-20 19:59:43 -06:00
unitTarget -> CastSpell ( unitTarget , iTmpSpellId , true );
return ;
}
// Bending Shinbone
case 8856 :
{
2010-04-07 19:14:10 +02:00
if ( ! itemTarget && m_caster -> GetTypeId () != TYPEID_PLAYER )
2009-01-20 19:59:43 -06:00
return ;
2009-10-17 15:51:44 -07:00
2012-06-03 02:35:00 +02:00
uint32 spell_id = roll_chance_i ( 20 ) ? 8854 : 8855 ;
2009-10-17 15:51:44 -07:00
2011-04-29 20:47:02 +02:00
m_caster -> CastSpell ( m_caster , spell_id , true , NULL );
2009-01-20 19:59:43 -06:00
return ;
}
// Brittle Armor - need remove one 24575 Brittle Armor aura
case 24590 :
2009-04-06 13:31:14 +02:00
unitTarget -> RemoveAuraFromStack ( 24575 );
2009-01-20 19:59:43 -06:00
return ;
// Mercurial Shield - need remove one 26464 Mercurial Shield aura
case 26465 :
2009-04-06 13:31:14 +02:00
unitTarget -> RemoveAuraFromStack ( 26464 );
2009-01-20 19:59:43 -06:00
return ;
// Shadow Flame (All script effects, not just end ones to prevent player from dodging the last triggered spell)
case 22539 :
case 22972 :
case 22975 :
case 22976 :
case 22977 :
case 22978 :
case 22979 :
case 22980 :
case 22981 :
case 22982 :
case 22983 :
case 22984 :
case 22985 :
{
2010-04-07 19:14:10 +02:00
if ( ! unitTarget || ! unitTarget -> isAlive ())
2009-01-20 19:59:43 -06:00
return ;
2009-10-17 15:51:44 -07:00
2009-01-20 19:59:43 -06:00
// Onyxia Scale Cloak
2010-04-07 19:14:10 +02:00
if ( unitTarget -> HasAura ( 22683 ))
2009-01-20 19:59:43 -06:00
return ;
2009-10-17 15:51:44 -07:00
2009-01-20 19:59:43 -06:00
// Shadow Flame
m_caster -> CastSpell ( unitTarget , 22682 , true );
return ;
}
// Piccolo of the Flaming Fire
case 17512 :
2008-10-11 14:16:25 -05:00
{
2010-04-07 19:14:10 +02:00
if ( ! unitTarget || unitTarget -> GetTypeId () != TYPEID_PLAYER )
2009-01-20 19:59:43 -06:00
return ;
unitTarget -> HandleEmoteCommand ( EMOTE_STATE_DANCE );
2009-03-09 18:09:00 -06:00
return ;
}
2009-05-16 14:49:58 -05:00
// Decimate
case 28374 :
case 54426 :
2010-04-07 19:14:10 +02:00
if ( unitTarget )
2009-05-16 14:49:58 -05:00
{
2010-08-26 01:20:57 +06:00
int32 damage = int32 ( unitTarget -> GetHealth ()) - int32 ( unitTarget -> CountPctFromMaxHealth ( 5 ));
2010-04-07 19:14:10 +02:00
if ( damage > 0 )
2009-05-16 14:49:58 -05:00
m_caster -> CastCustomSpell ( 28375 , SPELLVALUE_BASE_POINT0 , damage , unitTarget );
}
return ;
2009-01-20 19:59:43 -06:00
// Mirren's Drinking Hat
case 29830 :
{
uint32 item = 0 ;
2010-04-07 22:59:46 +02:00
switch ( urand ( 1 , 6 ))
2009-01-20 19:59:43 -06:00
{
2009-05-31 15:56:51 -05:00
case 1 :
case 2 :
case 3 :
item = 23584 ; break ; // Loch Modan Lager
case 4 :
case 5 :
item = 23585 ; break ; // Stouthammer Lite
2009-01-20 19:59:43 -06:00
case 6 :
2009-05-31 15:56:51 -05:00
item = 23586 ; break ; // Aerie Peak Pale Ale
2009-01-20 19:59:43 -06:00
}
if ( item )
2011-04-29 20:47:02 +02:00
DoCreateItem ( effIndex , item );
2009-01-20 19:59:43 -06:00
break ;
}
2012-06-03 02:35:00 +02:00
case 20589 : // Escape artist
case 30918 : // Improved Sprint
2009-12-24 13:01:39 +01:00
{
// Removes snares and roots.
unitTarget -> RemoveMovementImpairingAuras ();
break ;
}
*Implement spells: 781, 13280, 32307, 40109, 47770, 47776, 49625, 49634, 51854, 64385, by Warhead
2009-10-31 04:28:02 -07:00
// Plant Warmaul Ogre Banner
case 32307 :
2011-07-08 11:45:18 +02:00
if ( Player * caster = m_caster -> ToPlayer ())
2011-07-08 11:12:19 +02:00
{
caster -> RewardPlayerAndGroupAtEvent ( 18388 , unitTarget );
if ( Creature * target = unitTarget -> ToCreature ())
{
target -> setDeathState ( CORPSE );
target -> RemoveCorpse ();
}
}
*Implement spells: 781, 13280, 32307, 40109, 47770, 47776, 49625, 49634, 51854, 64385, by Warhead
2009-10-31 04:28:02 -07:00
break ;
2009-08-11 19:57:27 +02:00
// Mug Transformation
2009-01-20 19:59:43 -06:00
case 41931 :
{
2010-04-07 19:14:10 +02:00
if ( m_caster -> GetTypeId () != TYPEID_PLAYER )
2009-01-20 19:59:43 -06:00
return ;
2009-10-17 15:51:44 -07:00
2009-11-19 19:55:24 -08:00
uint8 bag = 19 ;
uint8 slot = 0 ;
2011-09-15 14:08:17 +02:00
Item * item = NULL ;
2009-10-17 15:51:44 -07:00
2010-08-30 15:25:15 +02:00
while ( bag ) // 256 = 0 due to var type
2009-01-20 19:59:43 -06:00
{
2010-03-07 15:20:19 +01:00
item = m_caster -> ToPlayer () -> GetItemByPos ( bag , slot );
2012-05-30 08:01:02 +02:00
if ( item && item -> GetEntry () == 38587 )
break ;
2009-11-19 19:55:24 -08:00
++ slot ;
2009-01-20 19:59:43 -06:00
if ( slot == 39 )
{
slot = 0 ;
2009-11-19 19:55:24 -08:00
++ bag ;
2009-01-20 19:59:43 -06:00
}
}
2010-08-30 15:25:15 +02:00
if ( bag )
2009-01-20 19:59:43 -06:00
{
2011-04-29 20:47:02 +02:00
if ( m_caster -> ToPlayer () -> GetItemByPos ( bag , slot ) -> GetCount () == 1 ) m_caster -> ToPlayer () -> RemoveItem ( bag , slot , true );
else m_caster -> ToPlayer () -> GetItemByPos ( bag , slot ) -> SetCount ( m_caster -> ToPlayer () -> GetItemByPos ( bag , slot ) -> GetCount () - 1 );
2009-01-20 19:59:43 -06:00
// Spell 42518 (Braufest - Gratisprobe des Braufest herstellen)
2009-11-19 19:55:24 -08:00
m_caster -> CastSpell ( m_caster , 42518 , true );
2009-01-20 19:59:43 -06:00
return ;
}
break ;
}
2009-11-19 19:55:24 -08:00
// Brutallus - Burn
case 45141 :
case 45151 :
{
//Workaround for Range ... should be global for every ScriptEffect
2011-07-26 23:09:28 +02:00
float radius = m_spellInfo -> Effects [ effIndex ]. CalcRadius ();
2009-11-19 19:55:24 -08:00
if ( unitTarget && unitTarget -> GetTypeId () == TYPEID_PLAYER && unitTarget -> GetDistance ( m_caster ) >= radius && ! unitTarget -> HasAura ( 46394 ) && unitTarget != m_caster )
unitTarget -> CastSpell ( unitTarget , 46394 , true );
break ;
}
2009-01-20 19:59:43 -06:00
// Goblin Weather Machine
case 46203 :
{
2010-04-07 19:14:10 +02:00
if ( ! unitTarget )
2009-01-20 19:59:43 -06:00
return ;
2009-10-17 15:51:44 -07:00
2009-04-27 18:42:35 -05:00
uint32 spellId = 0 ;
2011-09-29 12:43:05 +02:00
switch ( rand () % 4 )
2009-01-20 19:59:43 -06:00
{
2009-01-21 16:18:57 -06:00
case 0 : spellId = 46740 ; break ;
case 1 : spellId = 46739 ; break ;
case 2 : spellId = 46738 ; break ;
case 3 : spellId = 46736 ; break ;
2009-01-20 19:59:43 -06:00
}
unitTarget -> CastSpell ( unitTarget , spellId , true );
break ;
}
2011-04-29 20:47:02 +02:00
// 5, 000 Gold
2009-01-20 19:59:43 -06:00
case 46642 :
{
2010-04-07 19:14:10 +02:00
if ( ! unitTarget || unitTarget -> GetTypeId () != TYPEID_PLAYER )
2009-01-20 19:59:43 -06:00
return ;
2009-10-17 15:51:44 -07:00
2010-03-07 15:20:19 +01:00
unitTarget -> ToPlayer () -> ModifyMoney ( 5000 * GOLD );
2009-10-17 15:51:44 -07:00
2009-01-20 19:59:43 -06:00
break ;
}
*Implement spells: 781, 13280, 32307, 40109, 47770, 47776, 49625, 49634, 51854, 64385, by Warhead
2009-10-31 04:28:02 -07:00
// Roll Dice - Decahedral Dwarven Dice
case 47770 :
{
char buf [ 128 ];
2010-08-30 15:25:15 +02:00
const char * gender = "his" ;
2010-04-07 19:14:10 +02:00
if ( m_caster -> getGender () > 0 )
*Implement spells: 781, 13280, 32307, 40109, 47770, 47776, 49625, 49634, 51854, 64385, by Warhead
2009-10-31 04:28:02 -07:00
gender = "her" ;
2012-10-24 13:29:34 +02:00
sprintf ( buf , "%s rubs %s [Decahedral Dwarven Dice] between %s hands and rolls. One %u and one %u." , m_caster -> GetName (). c_str (), gender , gender , urand ( 1 , 10 ), urand ( 1 , 10 ));
*Implement spells: 781, 13280, 32307, 40109, 47770, 47776, 49625, 49634, 51854, 64385, by Warhead
2009-10-31 04:28:02 -07:00
m_caster -> MonsterTextEmote ( buf , 0 );
break ;
}
// Roll 'dem Bones - Worn Troll Dice
case 47776 :
{
char buf [ 128 ];
2010-08-30 15:25:15 +02:00
const char * gender = "his" ;
2010-04-07 19:14:10 +02:00
if ( m_caster -> getGender () > 0 )
*Implement spells: 781, 13280, 32307, 40109, 47770, 47776, 49625, 49634, 51854, 64385, by Warhead
2009-10-31 04:28:02 -07:00
gender = "her" ;
2012-10-24 13:29:34 +02:00
sprintf ( buf , "%s causually tosses %s [Worn Troll Dice]. One %u and one %u." , m_caster -> GetName (). c_str (), gender , urand ( 1 , 6 ), urand ( 1 , 6 ));
*Implement spells: 781, 13280, 32307, 40109, 47770, 47776, 49625, 49634, 51854, 64385, by Warhead
2009-10-31 04:28:02 -07:00
m_caster -> MonsterTextEmote ( buf , 0 );
break ;
}
2009-05-21 20:02:22 +02:00
// Vigilance
case 50725 :
{
2010-04-07 19:14:10 +02:00
if ( ! unitTarget || unitTarget -> GetTypeId () != TYPEID_PLAYER )
2009-05-21 20:02:22 +02:00
return ;
2009-10-17 15:51:44 -07:00
2009-05-21 20:02:22 +02:00
// Remove Taunt cooldown
2010-03-07 15:20:19 +01:00
unitTarget -> ToPlayer () -> RemoveSpellCooldown ( 355 , true );
2009-10-17 15:51:44 -07:00
2009-05-21 20:02:22 +02:00
return ;
}
2009-08-11 19:57:27 +02:00
// Death Knight Initiate Visual
case 51519 :
{
2010-04-07 19:14:10 +02:00
if ( ! unitTarget || unitTarget -> GetTypeId () != TYPEID_UNIT )
2009-08-11 19:57:27 +02:00
return ;
2009-10-17 15:51:44 -07:00
2009-08-11 19:57:27 +02:00
uint32 iTmpSpellId = 0 ;
switch ( unitTarget -> GetDisplayId ())
{
case 25369 : iTmpSpellId = 51552 ; break ; // bloodelf female
case 25373 : iTmpSpellId = 51551 ; break ; // bloodelf male
case 25363 : iTmpSpellId = 51542 ; break ; // draenei female
case 25357 : iTmpSpellId = 51541 ; break ; // draenei male
case 25361 : iTmpSpellId = 51537 ; break ; // dwarf female
case 25356 : iTmpSpellId = 51538 ; break ; // dwarf male
case 25372 : iTmpSpellId = 51550 ; break ; // forsaken female
case 25367 : iTmpSpellId = 51549 ; break ; // forsaken male
case 25362 : iTmpSpellId = 51540 ; break ; // gnome female
case 25359 : iTmpSpellId = 51539 ; break ; // gnome male
case 25355 : iTmpSpellId = 51534 ; break ; // human female
case 25354 : iTmpSpellId = 51520 ; break ; // human male
case 25360 : iTmpSpellId = 51536 ; break ; // nightelf female
case 25358 : iTmpSpellId = 51535 ; break ; // nightelf male
case 25368 : iTmpSpellId = 51544 ; break ; // orc female
case 25364 : iTmpSpellId = 51543 ; break ; // orc male
case 25371 : iTmpSpellId = 51548 ; break ; // tauren female
case 25366 : iTmpSpellId = 51547 ; break ; // tauren male
case 25370 : iTmpSpellId = 51545 ; break ; // troll female
case 25365 : iTmpSpellId = 51546 ; break ; // troll male
default : return ;
}
2009-10-17 15:51:44 -07:00
2009-08-11 19:57:27 +02:00
unitTarget -> CastSpell ( unitTarget , iTmpSpellId , true );
2010-03-07 18:30:53 +01:00
Creature * npc = unitTarget -> ToCreature ();
2009-08-11 19:57:27 +02:00
npc -> LoadEquipment ( npc -> GetEquipmentId ());
return ;
}
2009-01-20 19:59:43 -06:00
// Emblazon Runeblade
case 51770 :
{
2010-04-07 19:14:10 +02:00
if ( ! m_originalCaster )
2009-01-20 19:59:43 -06:00
return ;
2009-10-17 15:51:44 -07:00
2009-03-15 00:48:35 -06:00
m_originalCaster -> CastSpell ( m_originalCaster , damage , false );
2009-01-20 19:59:43 -06:00
break ;
}
*Implement spells: 781, 13280, 32307, 40109, 47770, 47776, 49625, 49634, 51854, 64385, by Warhead
2009-10-31 04:28:02 -07:00
// Deathbolt from Thalgran Blightbringer
// reflected by Freya's Ward
// Retribution by Sevenfold Retribution
case 51854 :
{
2010-12-22 20:18:34 +02:00
if ( ! unitTarget )
*Implement spells: 781, 13280, 32307, 40109, 47770, 47776, 49625, 49634, 51854, 64385, by Warhead
2009-10-31 04:28:02 -07:00
return ;
if ( unitTarget -> HasAura ( 51845 ))
unitTarget -> CastSpell ( m_caster , 51856 , true );
else
m_caster -> CastSpell ( unitTarget , 51855 , true );
break ;
}
2009-05-25 22:52:08 -05:00
// Summon Ghouls On Scarlet Crusade
case 51904 :
{
2010-04-07 19:14:10 +02:00
if ( ! m_targets . HasDst ())
2009-05-25 22:52:08 -05:00
return ;
2009-10-17 15:51:44 -07:00
2009-05-25 22:52:08 -05:00
float x , y , z ;
2011-07-26 23:09:28 +02:00
float radius = m_spellInfo -> Effects [ effIndex ]. CalcRadius ();
*Implement spells: 781, 13280, 32307, 40109, 47770, 47776, 49625, 49634, 51854, 64385, by Warhead
2009-10-31 04:28:02 -07:00
for ( uint8 i = 0 ; i < 15 ; ++ i )
2009-05-25 22:52:08 -05:00
{
2012-05-30 08:01:02 +02:00
m_caster -> GetRandomPoint ( * destTarget , radius , x , y , z );
2009-05-25 22:52:08 -05:00
m_caster -> CastSpell ( x , y , z , 54522 , true );
}
break ;
2009-05-27 23:33:21 -05:00
}
2009-08-05 17:00:01 +02:00
case 52173 : // Coyote Spirit Despawn
case 60243 : // Blood Parrot Despawn
2010-03-07 18:30:53 +01:00
if ( unitTarget -> GetTypeId () == TYPEID_UNIT && unitTarget -> ToCreature () -> isSummon ())
2010-03-27 16:08:14 +01:00
unitTarget -> ToTempSummon () -> UnSummon ();
2009-08-05 17:00:01 +02:00
return ;
2009-06-03 23:24:57 -05:00
case 52479 : // Gift of the Harvester
2010-04-07 19:14:10 +02:00
if ( unitTarget && m_originalCaster )
2009-06-03 23:24:57 -05:00
m_originalCaster -> CastSpell ( unitTarget , urand ( 0 , 1 ) ? damage : 52505 , true );
return ;
2009-06-14 21:05:37 -05:00
case 53110 : // Devour Humanoid
2010-04-07 19:14:10 +02:00
if ( unitTarget )
2009-06-14 21:05:37 -05:00
unitTarget -> CastSpell ( m_caster , damage , true );
return ;
2011-11-12 02:36:18 +07:00
case 57347 : // Retrieving (Wintergrasp RP-GG pickup spell)
{
if ( ! unitTarget || unitTarget -> GetTypeId () != TYPEID_UNIT || m_caster -> GetTypeId () != TYPEID_PLAYER )
return ;
unitTarget -> ToCreature () -> DespawnOrUnsummon ();
return ;
}
case 57349 : // Drop RP-GG (Wintergrasp RP-GG at death drop spell)
{
if ( m_caster -> GetTypeId () != TYPEID_PLAYER )
return ;
// Delete item from inventory at death
m_caster -> ToPlayer () -> DestroyItemCount ( damage , 5 , true );
return ;
}
2009-03-29 17:18:51 -06:00
case 58418 : // Portal to Orgrimmar
case 58420 : // Portal to Stormwind
{
2010-04-08 08:20:08 +02:00
if ( ! unitTarget || unitTarget -> GetTypeId () != TYPEID_PLAYER || effIndex != 0 )
2009-03-29 17:18:51 -06:00
return ;
2009-10-17 15:51:44 -07:00
2011-07-26 23:09:28 +02:00
uint32 spellID = m_spellInfo -> Effects [ EFFECT_0 ]. CalcValue ();
uint32 questID = m_spellInfo -> Effects [ EFFECT_1 ]. CalcValue ();
2009-10-17 15:51:44 -07:00
2011-01-13 23:06:59 +01:00
if ( unitTarget -> ToPlayer () -> GetQuestStatus ( questID ) == QUEST_STATUS_COMPLETE )
2009-03-29 17:18:51 -06:00
unitTarget -> CastSpell ( unitTarget , spellID , true );
2009-10-17 15:51:44 -07:00
2009-03-29 17:18:51 -06:00
return ;
}
2009-05-23 01:43:46 -05:00
case 58941 : // Rock Shards
2010-04-07 19:14:10 +02:00
if ( unitTarget && m_originalCaster )
2009-05-23 01:43:46 -05:00
{
2009-10-17 16:20:24 -07:00
for ( uint32 i = 0 ; i < 3 ; ++ i )
2009-05-23 01:43:46 -05:00
{
m_originalCaster -> CastSpell ( unitTarget , 58689 , true );
m_originalCaster -> CastSpell ( unitTarget , 58692 , true );
}
2010-04-07 19:14:10 +02:00
if ((( InstanceMap * ) m_originalCaster -> GetMap ()) -> GetDifficulty () == REGULAR_DIFFICULTY )
2009-05-23 01:43:46 -05:00
{
2009-12-17 12:23:01 +01:00
m_originalCaster -> CastSpell ( unitTarget , 58695 , true );
m_originalCaster -> CastSpell ( unitTarget , 58696 , true );
2009-05-23 01:43:46 -05:00
}
else
{
2009-12-17 12:23:01 +01:00
m_originalCaster -> CastSpell ( unitTarget , 60883 , true );
m_originalCaster -> CastSpell ( unitTarget , 60884 , true );
2009-05-23 01:43:46 -05:00
}
}
return ;
2009-08-05 17:00:01 +02:00
case 58983 : // Big Blizzard Bear
2009-08-05 16:00:36 +02:00
{
2010-04-07 19:14:10 +02:00
if ( ! unitTarget || unitTarget -> GetTypeId () != TYPEID_PLAYER )
2009-08-05 16:00:36 +02:00
return ;
2009-10-17 15:51:44 -07:00
2010-05-22 22:57:16 +02:00
// Prevent stacking of mounts and client crashes upon dismounting
2009-08-05 16:00:36 +02:00
unitTarget -> RemoveAurasByType ( SPELL_AURA_MOUNTED );
2009-10-17 15:51:44 -07:00
2010-05-22 22:57:16 +02:00
// Triggered spell id dependent on riding skill
2010-04-07 19:14:10 +02:00
if ( uint16 skillval = unitTarget -> ToPlayer () -> GetSkillValue ( SKILL_RIDING ))
2009-08-05 16:00:36 +02:00
{
if ( skillval >= 150 )
unitTarget -> CastSpell ( unitTarget , 58999 , true );
else
unitTarget -> CastSpell ( unitTarget , 58997 , true );
}
return ;
}
2010-09-06 12:22:19 +02:00
case 63845 : // Create Lance
{
if ( m_caster -> GetTypeId () != TYPEID_PLAYER )
return ;
if ( m_caster -> ToPlayer () -> GetTeam () == ALLIANCE )
m_caster -> CastSpell ( m_caster , 63914 , true );
else
m_caster -> CastSpell ( m_caster , 63919 , true );
return ;
}
2009-05-05 14:46:32 -05:00
case 59317 : // Teleporting
2012-09-06 11:00:37 -04:00
{
2009-05-05 14:46:32 -05:00
if ( ! unitTarget || unitTarget -> GetTypeId () != TYPEID_PLAYER )
return ;
2009-10-17 15:51:44 -07:00
2009-05-05 14:46:32 -05:00
// return from top
2010-03-07 15:20:19 +01:00
if ( unitTarget -> ToPlayer () -> GetAreaId () == 4637 )
2009-05-05 14:46:32 -05:00
unitTarget -> CastSpell ( unitTarget , 59316 , true );
// teleport atop
else
unitTarget -> CastSpell ( unitTarget , 59314 , true );
2009-10-17 15:51:44 -07:00
2009-05-05 14:46:32 -05:00
return ;
2009-01-20 19:59:43 -06:00
}
2009-08-28 11:26:20 -05:00
case 62482 : // Grab Crate
2009-12-17 13:07:38 +01:00
{
2010-04-07 19:14:10 +02:00
if ( unitTarget )
2009-08-28 11:26:20 -05:00
{
2011-08-18 20:24:46 +02:00
if ( Unit * seat = m_caster -> GetVehicleBase ())
2009-08-28 11:26:20 -05:00
{
2011-08-18 20:24:46 +02:00
if ( Unit * parent = seat -> GetVehicleBase ())
{
// TODO: a hack, range = 11, should after some time cast, otherwise too far
m_caster -> CastSpell ( parent , 62496 , true );
unitTarget -> CastSpell ( parent , m_spellInfo -> Effects [ EFFECT_0 ]. CalcValue ());
}
2009-08-28 11:26:20 -05:00
}
}
return ;
2009-12-17 12:23:01 +01:00
}
2009-08-17 02:53:39 +02:00
case 60123 : // Lightwell
2009-08-10 15:52:11 -05:00
{
2010-03-07 18:30:53 +01:00
if ( m_caster -> GetTypeId () != TYPEID_UNIT || ! m_caster -> ToCreature () -> isSummon ())
2009-08-17 02:53:39 +02:00
return ;
2009-10-17 15:51:44 -07:00
2009-08-17 02:53:39 +02:00
uint32 spell_heal ;
2009-10-17 15:51:44 -07:00
2011-09-29 12:43:05 +02:00
switch ( m_caster -> GetEntry ())
2009-08-17 02:53:39 +02:00
{
case 31897 : spell_heal = 7001 ; break ;
case 31896 : spell_heal = 27873 ; break ;
case 31895 : spell_heal = 27874 ; break ;
case 31894 : spell_heal = 28276 ; break ;
case 31893 : spell_heal = 48084 ; break ;
case 31883 : spell_heal = 48085 ; break ;
default :
2012-08-03 14:20:18 +02:00
sLog -> outError ( LOG_FILTER_SPELLS_AURAS , "Unknown Lightwell spell caster %u" , m_caster -> GetEntry ());
2009-08-17 02:53:39 +02:00
return ;
2009-08-10 15:52:11 -05:00
}
2009-10-17 15:51:44 -07:00
2011-06-07 17:25:34 +02:00
// proc a spellcast
2011-09-15 14:08:17 +02:00
if ( Aura * chargesAura = m_caster -> GetAura ( 59907 ))
2009-08-17 02:53:39 +02:00
{
2010-03-27 16:08:14 +01:00
m_caster -> CastSpell ( unitTarget , spell_heal , true , NULL , NULL , m_caster -> ToTempSummon () -> GetSummonerGUID ());
2011-06-07 17:25:34 +02:00
if ( chargesAura -> ModCharges ( - 1 ))
m_caster -> ToTempSummon () -> UnSummon ();
2009-08-17 02:53:39 +02:00
}
2011-06-15 20:46:49 +02:00
2009-08-23 01:08:09 -05:00
return ;
2009-08-10 15:52:11 -05:00
}
2009-09-14 13:34:23 -07:00
// Stoneclaw Totem
case 55328 : // Rank 1
case 55329 : // Rank 2
case 55330 : // Rank 3
case 55332 : // Rank 4
case 55333 : // Rank 5
case 55335 : // Rank 6
case 55278 : // Rank 7
case 58589 : // Rank 8
case 58590 : // Rank 9
case 58591 : // Rank 10
{
int32 basepoints0 = damage ;
// Cast Absorb on totems
2009-10-17 16:20:24 -07:00
for ( uint8 slot = SUMMON_SLOT_TOTEM ; slot < MAX_TOTEM_SLOT ; ++ slot )
2009-09-14 13:34:23 -07:00
{
2010-04-07 19:14:10 +02:00
if ( ! unitTarget -> m_SummonSlot [ slot ])
2009-09-14 13:34:23 -07:00
continue ;
2009-10-17 15:51:44 -07:00
2009-09-14 13:34:23 -07:00
Creature * totem = unitTarget -> GetMap () -> GetCreature ( unitTarget -> m_SummonSlot [ slot ]);
2010-04-07 19:14:10 +02:00
if ( totem && totem -> isTotem ())
2009-09-14 13:34:23 -07:00
{
m_caster -> CastCustomSpell ( totem , 55277 , & basepoints0 , NULL , NULL , true );
}
}
// Glyph of Stoneclaw Totem
2011-09-15 14:08:17 +02:00
if ( AuraEffect * aur = unitTarget -> GetAuraEffect ( 63298 , 0 ))
2009-09-14 13:34:23 -07:00
{
basepoints0 *= aur -> GetAmount ();
m_caster -> CastCustomSpell ( unitTarget , 55277 , & basepoints0 , NULL , NULL , true );
}
break ;
}
2009-12-27 18:01:34 -03:00
case 66545 : //Summon Memory
{
2011-04-29 20:47:02 +02:00
uint8 uiRandom = urand ( 0 , 25 );
uint32 uiSpells [ 26 ] = { 66704 , 66705 , 66706 , 66707 , 66709 , 66710 , 66711 , 66712 , 66713 , 66714 , 66715 , 66708 , 66708 , 66691 , 66692 , 66694 , 66695 , 66696 , 66697 , 66698 , 66699 , 66700 , 66701 , 66702 , 66703 , 66543 };
2009-12-27 18:01:34 -03:00
2011-04-29 20:47:02 +02:00
m_caster -> CastSpell ( m_caster , uiSpells [ uiRandom ], true );
2009-12-27 18:01:34 -03:00
break ;
}
2010-02-23 23:48:07 +01:00
case 45668 : // Ultra-Advanced Proto-Typical Shortening Blaster
{
if ( ! unitTarget || unitTarget -> GetTypeId () != TYPEID_UNIT )
return ;
2010-04-07 18:09:10 +02:00
2010-02-23 23:48:07 +01:00
if ( roll_chance_i ( 50 )) // chance unknown, using 50
return ;
2010-04-07 18:09:10 +02:00
2010-02-23 23:48:07 +01:00
static uint32 const spellPlayer [ 5 ] =
{
45674 , // Bigger!
45675 , // Shrunk
45678 , // Yellow
45682 , // Ghost
45684 // Polymorph
};
2010-04-07 18:09:10 +02:00
2012-05-30 08:01:02 +02:00
static uint32 const spellTarget [ 5 ] =
{
2010-02-23 23:48:07 +01:00
45673 , // Bigger!
45672 , // Shrunk
45677 , // Yellow
45681 , // Ghost
45683 // Polymorph
};
2010-04-07 18:09:10 +02:00
2011-04-29 20:47:02 +02:00
m_caster -> CastSpell ( m_caster , spellPlayer [ urand ( 0 , 4 )], true );
unitTarget -> CastSpell ( unitTarget , spellTarget [ urand ( 0 , 4 )], true );
2010-02-23 23:48:07 +01:00
break ;
}
2008-10-11 14:16:25 -05:00
}
break ;
}
2009-01-20 19:59:43 -06:00
case SPELLFAMILY_PALADIN :
2008-12-24 09:58:26 -06:00
{
2009-08-05 16:39:09 -05:00
// Judgement (seal trigger)
if ( m_spellInfo -> Category == SPELLCATEGORY_JUDGEMENT )
2008-12-24 09:58:26 -06:00
{
2010-04-07 19:14:10 +02:00
if ( ! unitTarget || ! unitTarget -> isAlive ())
2009-01-20 19:59:43 -06:00
return ;
uint32 spellId1 = 0 ;
uint32 spellId2 = 0 ;
2009-10-17 15:51:44 -07:00
2009-01-20 19:59:43 -06:00
// Judgement self add switch
switch ( m_spellInfo -> Id )
{
case 53407 : spellId1 = 20184 ; break ; // Judgement of Justice
case 20271 : // Judgement of Light
case 57774 : spellId1 = 20185 ; break ; // Judgement of Light
case 53408 : spellId1 = 20186 ; break ; // Judgement of Wisdom
default :
2012-08-03 14:20:18 +02:00
sLog -> outError ( LOG_FILTER_SPELLS_AURAS , "Unsupported Judgement (seal trigger) spell (Id: %u) in Spell::EffectScriptEffect" , m_spellInfo -> Id );
2009-01-20 19:59:43 -06:00
return ;
}
// all seals have aura dummy in 2 effect
2010-01-10 01:23:15 +01:00
Unit :: AuraApplicationMap & sealAuras = m_caster -> GetAppliedAuras ();
for ( Unit :: AuraApplicationMap :: iterator iter = sealAuras . begin (); iter != sealAuras . end ();)
2009-04-09 14:58:25 +02:00
{
2011-09-15 14:08:17 +02:00
Aura * aura = iter -> second -> GetBase ();
2011-07-26 23:09:28 +02:00
if ( aura -> GetSpellInfo () -> GetSpellSpecific () == SPELL_SPECIFIC_SEAL )
2009-04-09 14:58:25 +02:00
{
2011-09-15 14:08:17 +02:00
if ( AuraEffect * aureff = aura -> GetEffect ( 2 ))
2010-01-10 01:23:15 +01:00
if ( aureff -> GetAuraType () == SPELL_AURA_DUMMY )
2009-04-09 14:58:25 +02:00
{
2011-07-26 23:09:28 +02:00
if ( sSpellMgr -> GetSpellInfo ( aureff -> GetAmount ()))
2009-04-09 14:58:25 +02:00
spellId2 = aureff -> GetAmount ();
break ;
}
if ( ! spellId2 )
{
switch ( iter -> first )
{
2009-11-17 19:24:31 -08:00
// Seal of light, Seal of wisdom, Seal of justice
2009-04-09 14:58:25 +02:00
case 20165 :
case 20166 :
case 20164 :
2009-11-17 19:24:31 -08:00
spellId2 = 54158 ;
2009-04-09 14:58:25 +02:00
}
}
break ;
}
else
++ iter ;
2008-12-24 09:58:26 -06:00
}
2009-01-20 19:59:43 -06:00
if ( spellId1 )
m_caster -> CastSpell ( unitTarget , spellId1 , true );
if ( spellId2 )
m_caster -> CastSpell ( unitTarget , spellId2 , true );
2008-12-24 09:58:26 -06:00
return ;
}
}
2009-01-20 19:59:43 -06:00
case SPELLFAMILY_POTION :
2008-10-11 14:16:25 -05:00
{
2011-09-29 12:43:05 +02:00
switch ( m_spellInfo -> Id )
2009-01-14 00:35:13 -06:00
{
2009-01-20 19:59:43 -06:00
// Netherbloom
case 28702 :
{
2010-04-07 19:14:10 +02:00
if ( ! unitTarget )
2009-01-20 19:59:43 -06:00
return ;
// 25% chance of casting a random buff
2010-04-07 19:14:10 +02:00
if ( roll_chance_i ( 75 ))
2009-01-20 19:59:43 -06:00
return ;
2009-10-17 15:51:44 -07:00
2009-01-20 19:59:43 -06:00
// triggered spells are 28703 to 28707
// Note: some sources say, that there was the possibility of
// receiving a debuff. However, this seems to be removed by a patch.
const uint32 spellid = 28703 ;
2009-10-17 15:51:44 -07:00
2009-01-20 19:59:43 -06:00
// don't overwrite an existing aura
2009-10-17 16:20:24 -07:00
for ( uint8 i = 0 ; i < 5 ; ++ i )
2010-04-07 19:14:10 +02:00
if ( unitTarget -> HasAura ( spellid + i ))
2009-01-20 19:59:43 -06:00
return ;
unitTarget -> CastSpell ( unitTarget , spellid + urand ( 0 , 4 ), true );
break ;
}
2009-10-17 15:51:44 -07:00
2009-01-20 19:59:43 -06:00
// Nightmare Vine
case 28720 :
{
2010-04-07 19:14:10 +02:00
if ( ! unitTarget )
2009-01-20 19:59:43 -06:00
return ;
// 25% chance of casting Nightmare Pollen
2010-04-07 19:14:10 +02:00
if ( roll_chance_i ( 75 ))
2009-01-20 19:59:43 -06:00
return ;
unitTarget -> CastSpell ( unitTarget , 28721 , true );
break ;
}
2009-01-14 00:35:13 -06:00
}
2009-01-20 19:59:43 -06:00
break ;
2008-10-11 14:16:25 -05:00
}
2009-06-14 21:04:44 +02:00
case SPELLFAMILY_DEATHKNIGHT :
{
// Pestilence
2010-04-07 22:59:46 +02:00
if ( m_spellInfo -> SpellFamilyFlags [ 1 ] & 0x10000 )
2009-06-14 21:04:44 +02:00
{
// Get diseases on target of spell
2011-06-23 13:28:52 +02:00
if ( m_targets . GetUnitTarget () && // Glyph of Disease - cast on unit target too to refresh aura
( m_targets . GetUnitTarget () != unitTarget || m_caster -> GetAura ( 63334 )))
2009-06-14 21:04:44 +02:00
{
// And spread them on target
// Blood Plague
2011-06-23 13:28:52 +02:00
if ( m_targets . GetUnitTarget () -> GetAura ( 55078 ))
2009-06-14 21:04:44 +02:00
m_caster -> CastSpell ( unitTarget , 55078 , true );
// Frost Fever
2011-06-23 13:28:52 +02:00
if ( m_targets . GetUnitTarget () -> GetAura ( 55095 ))
2009-06-14 21:04:44 +02:00
m_caster -> CastSpell ( unitTarget , 55095 , true );
}
}
2009-06-18 14:17:11 +02:00
break ;
2009-06-14 21:04:44 +02:00
}
2009-07-27 17:32:56 +02:00
case SPELLFAMILY_WARRIOR :
{
// Shattering Throw
2009-12-17 12:23:01 +01:00
if ( m_spellInfo -> SpellFamilyFlags [ 1 ] & 0x00400000 )
2009-07-27 17:32:56 +02:00
{
2010-04-07 19:14:10 +02:00
if ( ! unitTarget )
2009-07-27 17:32:56 +02:00
return ;
// remove shields, will still display immune to damage part
2009-08-11 19:57:27 +02:00
unitTarget -> RemoveAurasWithMechanic ( 1 << MECHANIC_IMMUNE_SHIELD , AURA_REMOVE_BY_ENEMY_SPELL );
2009-07-27 17:32:56 +02:00
return ;
}
break ;
}
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// normal DB scripted effect
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_SPELLS_AURAS , "Spell ScriptStart spellid %u in EffectScriptEffect(%u)" , m_spellInfo -> Id , effIndex );
2010-08-28 21:01:16 +06:00
m_caster -> GetMap () -> ScriptsStart ( sSpellScripts , uint32 ( m_spellInfo -> Id | ( effIndex << 24 )), m_caster , unitTarget );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectSanctuary ( SpellEffIndex /*effIndex*/ )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2010-04-07 19:14:10 +02:00
if ( ! unitTarget )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2010-11-13 18:04:56 +01:00
unitTarget -> getHostileRefManager (). UpdateVisibility ();
2010-11-13 20:23:05 +01:00
Unit :: AttackerSet const & attackers = unitTarget -> getAttackers ();
for ( Unit :: AttackerSet :: const_iterator itr = attackers . begin (); itr != attackers . end ();)
{
if ( ! ( * itr ) -> canSeeOrDetect ( unitTarget ))
( * ( itr ++ )) -> AttackStop ();
else
++ itr ;
}
2010-11-13 18:04:56 +01:00
unitTarget -> m_lastSanctuaryTime = getMSTime ();
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// Vanish allows to remove all threat and cast regular stealth so other spells can be used
2010-04-07 19:14:10 +02:00
if ( m_caster -> GetTypeId () == TYPEID_PLAYER
2010-03-08 17:20:25 +01:00
&& m_spellInfo -> SpellFamilyName == SPELLFAMILY_ROGUE
&& ( m_spellInfo -> SpellFamilyFlags [ 0 ] & SPELLFAMILYFLAG_ROGUE_VANISH ))
2008-10-11 14:16:25 -05:00
{
2010-03-11 20:51:31 +01:00
m_caster -> ToPlayer () -> RemoveAurasByType ( SPELL_AURA_MOD_ROOT );
2009-12-26 14:46:19 -03:00
// Overkill
2010-04-07 19:14:10 +02:00
if ( m_caster -> ToPlayer () -> HasSpell ( 58426 ))
2009-12-24 12:55:29 +01:00
m_caster -> CastSpell ( m_caster , 58427 , true );
2008-10-11 14:16:25 -05:00
}
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectAddComboPoints ( SpellEffIndex /*effIndex*/ )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2010-04-07 19:14:10 +02:00
if ( ! unitTarget )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( ! m_caster -> m_movedPlayer )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( damage <= 0 )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2009-09-01 00:17:39 -05:00
m_caster -> m_movedPlayer -> AddComboPoints ( unitTarget , damage , this );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectDuel ( SpellEffIndex effIndex )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2010-12-22 20:18:34 +02:00
if ( ! unitTarget || m_caster -> GetTypeId () != TYPEID_PLAYER || unitTarget -> GetTypeId () != TYPEID_PLAYER )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2011-06-20 04:04:20 +07:00
Player * caster = m_caster -> ToPlayer ();
Player * target = unitTarget -> ToPlayer ();
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// caster or target already have requested duel
2010-04-07 22:59:46 +02:00
if ( caster -> duel || target -> duel || ! target -> GetSocial () || target -> GetSocial () -> HasIgnore ( caster -> GetGUIDLow ()))
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2011-05-29 02:40:37 +07:00
// Players can only fight a duel in zones with this flag
AreaTableEntry const * casterAreaEntry = GetAreaEntryByAreaID ( caster -> GetAreaId ());
if ( casterAreaEntry && ! ( casterAreaEntry -> flags & AREA_FLAG_ALLOW_DUELS ))
2008-10-11 14:16:25 -05:00
{
SendCastResult ( SPELL_FAILED_NO_DUELING ); // Dueling isn't allowed here
return ;
}
2009-10-17 15:51:44 -07:00
2011-05-29 02:40:37 +07:00
AreaTableEntry const * targetAreaEntry = GetAreaEntryByAreaID ( target -> GetAreaId ());
if ( targetAreaEntry && ! ( targetAreaEntry -> flags & AREA_FLAG_ALLOW_DUELS ))
2008-10-11 14:16:25 -05:00
{
SendCastResult ( SPELL_FAILED_NO_DUELING ); // Dueling isn't allowed here
return ;
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
//CREATE DUEL FLAG OBJECT
GameObject * pGameObj = new GameObject ;
2009-10-17 15:51:44 -07:00
2011-07-26 23:09:28 +02:00
uint32 gameobject_id = m_spellInfo -> Effects [ effIndex ]. MiscValue ;
2009-10-17 15:51:44 -07:00
2011-06-20 04:04:20 +07:00
Map * map = m_caster -> GetMap ();
2010-12-22 21:25:23 +01:00
if ( ! pGameObj -> Create ( sObjectMgr -> GenerateLowGuid ( HIGHGUID_GAMEOBJECT ), gameobject_id ,
2009-01-31 16:38:50 -06:00
map , m_caster -> GetPhaseMask (),
2011-09-29 12:43:05 +02:00
m_caster -> GetPositionX () + ( unitTarget -> GetPositionX () - m_caster -> GetPositionX ()) / 2 ,
m_caster -> GetPositionY () + ( unitTarget -> GetPositionY () - m_caster -> GetPositionY ()) / 2 ,
2008-10-11 14:16:25 -05:00
m_caster -> GetPositionZ (),
2009-04-27 18:36:10 -05:00
m_caster -> GetOrientation (), 0.0f , 0.0f , 0.0f , 0.0f , 0 , GO_STATE_READY ))
2008-10-11 14:16:25 -05:00
{
delete pGameObj ;
return ;
}
2009-10-17 15:51:44 -07:00
2010-04-07 22:59:46 +02:00
pGameObj -> SetUInt32Value ( GAMEOBJECT_FACTION , m_caster -> getFaction ());
pGameObj -> SetUInt32Value ( GAMEOBJECT_LEVEL , m_caster -> getLevel () + 1 );
2011-07-26 23:09:28 +02:00
int32 duration = m_spellInfo -> GetDuration ();
2010-07-12 00:30:17 +02:00
pGameObj -> SetRespawnTime ( duration > 0 ? duration / IN_MILLISECONDS : 0 );
2008-10-11 14:16:25 -05:00
pGameObj -> SetSpellId ( m_spellInfo -> Id );
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
ExecuteLogEffectSummonObject ( effIndex , pGameObj );
2010-08-27 17:49:32 +02:00
2008-10-11 14:16:25 -05:00
m_caster -> AddGameObject ( pGameObj );
2011-10-10 17:39:34 -04:00
map -> AddToMap ( pGameObj );
2008-10-11 14:16:25 -05:00
//END
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// Send request
2009-05-31 15:56:51 -05:00
WorldPacket data ( SMSG_DUEL_REQUESTED , 8 + 8 );
data << uint64 ( pGameObj -> GetGUID ());
data << uint64 ( caster -> GetGUID ());
2008-10-11 14:16:25 -05:00
caster -> GetSession () -> SendPacket ( & data );
target -> GetSession () -> SendPacket ( & data );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// create duel-info
2011-09-15 14:08:17 +02:00
DuelInfo * duel = new DuelInfo ;
2008-10-11 14:16:25 -05:00
duel -> initiator = caster ;
duel -> opponent = target ;
duel -> startTime = 0 ;
duel -> startTimer = 0 ;
2012-01-30 00:21:42 +01:00
duel -> isMounted = ( GetSpellInfo () -> Id == 62875 ); // Mounted Duel
2008-10-11 14:16:25 -05:00
caster -> duel = duel ;
2009-10-17 15:51:44 -07:00
2011-09-15 14:08:17 +02:00
DuelInfo * duel2 = new DuelInfo ;
2008-10-11 14:16:25 -05:00
duel2 -> initiator = caster ;
duel2 -> opponent = caster ;
duel2 -> startTime = 0 ;
duel2 -> startTimer = 0 ;
2012-01-30 00:21:42 +01:00
duel2 -> isMounted = ( GetSpellInfo () -> Id == 62875 ); // Mounted Duel
2008-10-11 14:16:25 -05:00
target -> duel = duel2 ;
2009-10-17 15:51:44 -07:00
2009-05-31 15:56:51 -05:00
caster -> SetUInt64Value ( PLAYER_DUEL_ARBITER , pGameObj -> GetGUID ());
target -> SetUInt64Value ( PLAYER_DUEL_ARBITER , pGameObj -> GetGUID ());
2010-09-13 01:42:14 +03:00
2010-12-22 21:25:23 +01:00
sScriptMgr -> OnPlayerDuelRequest ( target , caster );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectStuck ( SpellEffIndex /*effIndex*/ )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT )
return ;
if ( ! m_caster || m_caster -> GetTypeId () != TYPEID_PLAYER )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2010-12-23 23:25:44 +01:00
if ( ! sWorld -> getBoolConfig ( CONFIG_CAST_UNSTUCK ))
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2011-10-07 19:45:43 -05:00
Player * target = ( Player * ) m_caster ;
2009-10-17 15:51:44 -07:00
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_SPELLS_AURAS , "Spell Effect: Stuck" );
2012-10-24 13:29:34 +02:00
sLog -> outInfo ( LOG_FILTER_SPELLS_AURAS , "Player %s (guid %u) used auto-unstuck future at map %u (%f, %f, %f)" , target -> GetName (). c_str (), target -> GetGUIDLow (), m_caster -> GetMapId (), m_caster -> GetPositionX (), target -> GetPositionY (), target -> GetPositionZ ());
2009-10-17 15:51:44 -07:00
2011-10-07 19:45:43 -05:00
if ( target -> isInFlight ())
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2012-02-15 17:06:31 +01:00
target -> TeleportTo ( target -> GetStartPosition (), TELE_TO_SPELL );
2008-10-11 14:16:25 -05:00
// homebind location is loaded always
2011-10-07 19:45:43 -05:00
// target->TeleportTo(target->m_homebindMapId, target->m_homebindX, target->m_homebindY, target->m_homebindZ, target->GetOrientation(), (m_caster == m_caster ? TELE_TO_SPELL : 0));
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// Stuck spell trigger Hearthstone cooldown
2011-09-15 14:08:17 +02:00
SpellInfo const * spellInfo = sSpellMgr -> GetSpellInfo ( 8690 );
2010-04-07 19:14:10 +02:00
if ( ! spellInfo )
2008-10-11 14:16:25 -05:00
return ;
2011-10-07 19:45:43 -05:00
Spell spell ( target , spellInfo , TRIGGERED_FULL_MASK );
2008-10-11 14:16:25 -05:00
spell . SendSpellCooldown ();
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectSummonPlayer ( SpellEffIndex /*effIndex*/ )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
// workaround - this effect should not use target map
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2010-04-07 19:14:10 +02:00
if ( ! unitTarget || unitTarget -> GetTypeId () != TYPEID_PLAYER )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// Evil Twin (ignore player summon, but hide this for summoner)
2010-04-07 19:14:10 +02:00
if ( unitTarget -> HasAura ( 23445 ))
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2009-05-31 15:56:51 -05:00
float x , y , z ;
2012-02-10 11:32:33 +01:00
m_caster -> GetPosition ( x , y , z );
2009-10-17 15:51:44 -07:00
2011-04-29 20:47:02 +02:00
unitTarget -> ToPlayer () -> SetSummonPoint ( m_caster -> GetMapId (), x , y , z );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
WorldPacket data ( SMSG_SUMMON_REQUEST , 8 + 4 + 4 );
data << uint64 ( m_caster -> GetGUID ()); // summoner guid
data << uint32 ( m_caster -> GetZoneId ()); // summoner zone
2010-07-12 00:30:17 +02:00
data << uint32 ( MAX_PLAYER_SUMMON_DELAY * IN_MILLISECONDS ); // auto decline after msecs
2010-03-07 15:20:19 +01:00
unitTarget -> ToPlayer () -> GetSession () -> SendPacket ( & data );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2011-07-18 14:49:08 +02:00
void Spell :: EffectActivateObject ( SpellEffIndex /*effIndex*/ )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2010-04-07 19:14:10 +02:00
if ( ! gameObjTarget )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2011-07-05 02:58:14 +01:00
ScriptInfo activateCommand ;
activateCommand . command = SCRIPT_COMMAND_ACTIVATE_OBJECT ;
2009-10-17 15:51:44 -07:00
2011-07-26 23:09:28 +02:00
// int32 unk = m_spellInfo->Effects[effIndex].MiscValue; // This is set for EffectActivateObject spells; needs research
2009-10-17 15:51:44 -07:00
2011-07-05 02:58:14 +01:00
gameObjTarget -> GetMap () -> ScriptCommandStart ( activateCommand , 0 , m_caster , gameObjTarget );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectApplyGlyph ( SpellEffIndex effIndex )
2008-12-24 09:58:26 -06:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT )
return ;
2010-03-23 14:38:31 -05:00
if ( m_caster -> GetTypeId () != TYPEID_PLAYER || m_glyphIndex >= MAX_GLYPH_SLOT_INDEX )
2008-12-24 09:58:26 -06:00
return ;
2009-10-17 15:51:44 -07:00
2011-06-12 01:47:45 +02:00
Player * player = ( Player * ) m_caster ;
2009-10-17 15:51:44 -07:00
2010-09-08 06:11:32 +03:00
// glyph sockets level requirement
uint8 minLevel = 0 ;
switch ( m_glyphIndex )
{
case 0 :
2012-01-29 17:40:14 +01:00
case 1 :
case 6 : minLevel = 25 ; break ;
case 2 :
case 3 :
case 7 : minLevel = 50 ; break ;
case 4 :
case 5 :
case 8 : minLevel = 75 ; break ;
2010-09-08 06:11:32 +03:00
}
2012-01-29 17:40:14 +01:00
2010-09-08 06:11:32 +03:00
if ( minLevel && m_caster -> getLevel () < minLevel )
{
SendCastResult ( SPELL_FAILED_GLYPH_SOCKET_LOCKED );
return ;
}
2008-12-24 09:58:26 -06:00
// apply new one
2011-07-26 23:09:28 +02:00
if ( uint32 glyph = m_spellInfo -> Effects [ effIndex ]. MiscValue )
2008-12-24 09:58:26 -06:00
{
2011-09-15 14:08:17 +02:00
if ( GlyphPropertiesEntry const * gp = sGlyphPropertiesStore . LookupEntry ( glyph ))
2008-12-24 09:58:26 -06:00
{
2011-09-15 14:08:17 +02:00
if ( GlyphSlotEntry const * gs = sGlyphSlotStore . LookupEntry ( player -> GetGlyphSlot ( m_glyphIndex )))
2008-12-24 09:58:26 -06:00
{
2010-03-23 14:38:31 -05:00
if ( gp -> TypeFlags != gs -> TypeFlags )
2008-12-24 09:58:26 -06:00
{
SendCastResult ( SPELL_FAILED_INVALID_GLYPH );
2009-03-21 14:53:38 -06:00
return ; // glyph slot mismatch
}
}
2009-10-17 15:51:44 -07:00
2009-03-21 14:53:38 -06:00
// remove old glyph
2012-01-29 17:40:14 +01:00
if ( uint32 oldglyph = player -> GetGlyph ( player -> GetActiveSpec (), m_glyphIndex ))
2009-03-21 14:53:38 -06:00
{
2011-09-15 14:08:17 +02:00
if ( GlyphPropertiesEntry const * old_gp = sGlyphPropertiesStore . LookupEntry ( oldglyph ))
2009-03-21 14:53:38 -06:00
{
player -> RemoveAurasDueToSpell ( old_gp -> SpellId );
player -> SetGlyph ( m_glyphIndex , 0 );
2008-12-24 09:58:26 -06:00
}
}
2009-10-17 15:51:44 -07:00
2008-12-24 09:58:26 -06:00
player -> CastSpell ( m_caster , gp -> SpellId , true );
player -> SetGlyph ( m_glyphIndex , glyph );
2009-06-11 00:45:59 -05:00
player -> SendTalentsInfoData ( false );
2008-12-24 09:58:26 -06:00
}
}
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectEnchantHeldItem ( SpellEffIndex effIndex )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2008-10-11 14:16:25 -05:00
// this is only item spell effect applied to main-hand weapon of target player (players in area)
2010-04-07 19:14:10 +02:00
if ( ! unitTarget || unitTarget -> GetTypeId () != TYPEID_PLAYER )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
Player * item_owner = ( Player * ) unitTarget ;
Item * item = item_owner -> GetItemByPos ( INVENTORY_SLOT_BAG_0 , EQUIPMENT_SLOT_MAINHAND );
2009-10-17 15:51:44 -07:00
2010-04-07 22:59:46 +02:00
if ( ! item )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// must be equipped
2012-05-30 08:01:02 +02:00
if ( ! item -> IsEquipped ())
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2011-07-26 23:09:28 +02:00
if ( m_spellInfo -> Effects [ effIndex ]. MiscValue )
2008-10-11 14:16:25 -05:00
{
2011-07-26 23:09:28 +02:00
uint32 enchant_id = m_spellInfo -> Effects [ effIndex ]. MiscValue ;
int32 duration = m_spellInfo -> GetDuration (); //Try duration index first ..
2010-04-07 19:14:10 +02:00
if ( ! duration )
2008-12-25 17:39:46 -06:00
duration = damage ; //+1; //Base points after ..
2010-04-07 19:14:10 +02:00
if ( ! duration )
2008-10-11 14:16:25 -05:00
duration = 10 ; //10 seconds for enchants which don't have listed duration
2009-10-17 15:51:44 -07:00
2011-09-15 14:08:17 +02:00
SpellItemEnchantmentEntry const * pEnchant = sSpellItemEnchantmentStore . LookupEntry ( enchant_id );
2010-04-07 19:14:10 +02:00
if ( ! pEnchant )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// Always go to temp enchantment slot
EnchantmentSlot slot = TEMP_ENCHANTMENT_SLOT ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// Enchantment will not be applied if a different one already exists
2010-04-07 19:14:10 +02:00
if ( item -> GetEnchantmentId ( slot ) && item -> GetEnchantmentId ( slot ) != enchant_id )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// Apply the temporary enchantment
2010-07-12 00:30:17 +02:00
item -> SetEnchantment ( slot , enchant_id , duration * IN_MILLISECONDS , 0 );
2009-05-31 15:56:51 -05:00
item_owner -> ApplyEnchantment ( item , slot , true );
2008-10-11 14:16:25 -05:00
}
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectDisEnchant ( SpellEffIndex /*effIndex*/ )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2011-04-28 22:42:33 +02:00
if ( ! itemTarget || ! itemTarget -> GetTemplate () -> DisenchantID )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2012-06-03 02:35:00 +02:00
if ( Player * caster = m_caster -> ToPlayer ())
{
caster -> UpdateCraftSkill ( m_spellInfo -> Id );
caster -> SendLoot ( itemTarget -> GetGUID (), LOOT_DISENCHANTING );
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// item will be removed at disenchanting end
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectInebriate ( SpellEffIndex /*effIndex*/ )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2010-04-07 19:14:10 +02:00
if ( ! unitTarget || unitTarget -> GetTypeId () != TYPEID_PLAYER )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2012-08-07 17:45:10 +02:00
Player * player = unitTarget -> ToPlayer ();
uint8 currentDrunk = player -> GetDrunkValue ();
uint8 drunkMod = damage ;
if ( currentDrunk + drunkMod > 100 )
2012-01-03 13:15:33 +01:00
{
2012-08-07 17:45:10 +02:00
currentDrunk = 100 ;
if ( rand_chance () < 25.0f )
player -> CastSpell ( player , 67468 , false ); // Drunken Vomit
2012-01-03 13:15:33 +01:00
}
2008-10-11 14:16:25 -05:00
else
currentDrunk += drunkMod ;
2012-08-07 17:45:10 +02:00
2009-05-31 15:56:51 -05:00
player -> SetDrunkValue ( currentDrunk , m_CastItem ? m_CastItem -> GetEntry () : 0 );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectFeedPet ( SpellEffIndex effIndex )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2011-12-10 15:40:55 +01:00
Player * player = m_caster -> ToPlayer ();
if ( ! player )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2011-09-25 13:29:17 +02:00
Item * foodItem = itemTarget ;
2010-04-07 19:14:10 +02:00
if ( ! foodItem )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2011-12-10 15:40:55 +01:00
Pet * pet = player -> GetPet ();
2010-04-07 19:14:10 +02:00
if ( ! pet )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( ! pet -> isAlive ())
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2011-04-28 22:42:33 +02:00
int32 benefit = pet -> GetCurrentFoodBenefitLevel ( foodItem -> GetTemplate () -> ItemLevel );
2010-04-07 19:14:10 +02:00
if ( benefit <= 0 )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2010-09-02 22:04:08 +02:00
ExecuteLogEffectDestroyItem ( effIndex , foodItem -> GetEntry ());
2008-10-11 14:16:25 -05:00
uint32 count = 1 ;
2011-12-10 15:40:55 +01:00
player -> DestroyItemCount ( foodItem , count , true );
2008-10-11 14:16:25 -05:00
// TODO: fix crash when a spell has two effects, both pointed at the same item target
2009-10-17 15:51:44 -07:00
2011-07-26 23:09:28 +02:00
m_caster -> CastCustomSpell ( pet , m_spellInfo -> Effects [ effIndex ]. TriggerSpell , & benefit , NULL , NULL , true );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectDismissPet ( SpellEffIndex effIndex )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2011-09-25 13:29:17 +02:00
if ( ! unitTarget || ! unitTarget -> isPet ())
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2011-09-25 13:29:17 +02:00
Pet * pet = unitTarget -> ToPet ();
2010-08-27 19:36:27 +02:00
ExecuteLogEffectUnsummonObject ( effIndex , pet );
2011-09-25 13:29:17 +02:00
pet -> GetOwner () -> RemovePet ( pet , PET_SAVE_NOT_IN_SLOT );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectSummonObject ( SpellEffIndex effIndex )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT )
return ;
2011-07-26 23:09:28 +02:00
uint32 go_id = m_spellInfo -> Effects [ effIndex ]. MiscValue ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
uint8 slot = 0 ;
2011-09-29 12:43:05 +02:00
switch ( m_spellInfo -> Effects [ effIndex ]. Effect )
2008-10-11 14:16:25 -05:00
{
case SPELL_EFFECT_SUMMON_OBJECT_SLOT1 : slot = 0 ; break ;
case SPELL_EFFECT_SUMMON_OBJECT_SLOT2 : slot = 1 ; break ;
case SPELL_EFFECT_SUMMON_OBJECT_SLOT3 : slot = 2 ; break ;
case SPELL_EFFECT_SUMMON_OBJECT_SLOT4 : slot = 3 ; break ;
default : return ;
}
2009-10-17 15:51:44 -07:00
2009-07-30 11:45:51 +02:00
uint64 guid = m_caster -> m_ObjectSlot [ slot ];
2010-04-07 19:14:10 +02:00
if ( guid != 0 )
2008-10-11 14:16:25 -05:00
{
2009-07-30 11:45:51 +02:00
GameObject * obj = NULL ;
2010-04-07 22:59:46 +02:00
if ( m_caster )
2009-07-30 11:45:51 +02:00
obj = m_caster -> GetMap () -> GetGameObject ( guid );
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( obj )
2009-07-30 11:45:51 +02:00
{
// Recast case - null spell id to make auras not be removed on object remove from world
if ( m_spellInfo -> Id == obj -> GetSpellId ())
obj -> SetSpellId ( 0 );
m_caster -> RemoveGameObject ( obj , true );
}
2008-10-11 14:16:25 -05:00
m_caster -> m_ObjectSlot [ slot ] = 0 ;
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
GameObject * pGameObj = new GameObject ;
2009-10-17 15:51:44 -07:00
2009-05-31 15:56:51 -05:00
float x , y , z ;
2008-10-11 14:16:25 -05:00
// If dest location if present
2009-08-29 23:20:16 -05:00
if ( m_targets . HasDst ())
2012-05-30 08:01:02 +02:00
destTarget -> GetPosition ( x , y , z );
2008-10-11 14:16:25 -05:00
// Summon in random point all other units if location present
else
2009-05-31 15:56:51 -05:00
m_caster -> GetClosePoint ( x , y , z , DEFAULT_WORLD_OBJECT_SIZE );
2009-10-17 15:51:44 -07:00
2011-09-15 14:08:17 +02:00
Map * map = m_caster -> GetMap ();
2010-12-22 21:25:23 +01:00
if ( ! pGameObj -> Create ( sObjectMgr -> GenerateLowGuid ( HIGHGUID_GAMEOBJECT ), go_id , map ,
2009-04-27 18:36:10 -05:00
m_caster -> GetPhaseMask (), x , y , z , m_caster -> GetOrientation (), 0.0f , 0.0f , 0.0f , 0.0f , 0 , GO_STATE_READY ))
2008-10-11 14:16:25 -05:00
{
delete pGameObj ;
return ;
}
2009-10-17 15:51:44 -07:00
2011-04-29 20:47:02 +02:00
//pGameObj->SetUInt32Value(GAMEOBJECT_LEVEL, m_caster->getLevel());
2011-07-26 23:09:28 +02:00
int32 duration = m_spellInfo -> GetDuration ();
2010-07-12 00:30:17 +02:00
pGameObj -> SetRespawnTime ( duration > 0 ? duration / IN_MILLISECONDS : 0 );
2008-10-11 14:16:25 -05:00
pGameObj -> SetSpellId ( m_spellInfo -> Id );
m_caster -> AddGameObject ( pGameObj );
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
ExecuteLogEffectSummonObject ( effIndex , pGameObj );
2010-08-27 17:49:32 +02:00
2011-10-10 17:39:34 -04:00
map -> AddToMap ( pGameObj );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
m_caster -> m_ObjectSlot [ slot ] = pGameObj -> GetGUID ();
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectResurrect ( SpellEffIndex effIndex )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2010-04-07 19:14:10 +02:00
if ( ! unitTarget )
2008-10-11 14:16:25 -05:00
return ;
2010-04-07 19:14:10 +02:00
if ( unitTarget -> GetTypeId () != TYPEID_PLAYER )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( unitTarget -> isAlive ())
2008-10-11 14:16:25 -05:00
return ;
2010-04-07 19:14:10 +02:00
if ( ! unitTarget -> IsInWorld ())
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
switch ( m_spellInfo -> Id )
{
// Defibrillate (Goblin Jumper Cables) have 33% chance on success
case 8342 :
if ( roll_chance_i ( 67 ))
{
m_caster -> CastSpell ( m_caster , 8338 , true , m_CastItem );
return ;
}
break ;
// Defibrillate (Goblin Jumper Cables XL) have 50% chance on success
case 22999 :
if ( roll_chance_i ( 50 ))
{
m_caster -> CastSpell ( m_caster , 23055 , true , m_CastItem );
return ;
}
break ;
2011-06-12 02:30:32 +02:00
// Defibrillate (Gnomish Army Knife) have 67% chance on success_list
2010-06-20 00:55:54 +02:00
case 54732 :
if ( roll_chance_i ( 33 ))
{
return ;
}
break ;
2008-10-11 14:16:25 -05:00
default :
break ;
}
2009-10-17 15:51:44 -07:00
2011-10-07 19:45:43 -05:00
Player * target = unitTarget -> ToPlayer ();
2009-10-17 15:51:44 -07:00
2011-10-07 19:45:43 -05:00
if ( target -> isRessurectRequested ()) // already have one active request
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2011-10-07 19:45:43 -05:00
uint32 health = target -> CountPctFromMaxHealth ( damage );
2012-10-02 12:17:42 +02:00
uint32 mana = CalculatePct ( target -> GetMaxPower ( POWER_MANA ), damage );
2009-10-17 15:51:44 -07:00
2011-10-07 19:45:43 -05:00
ExecuteLogEffectResurrect ( effIndex , target );
2010-08-27 17:49:32 +02:00
2011-10-07 19:45:43 -05:00
target -> setResurrectRequestData ( m_caster -> GetGUID (), m_caster -> GetMapId (), m_caster -> GetPositionX (), m_caster -> GetPositionY (), m_caster -> GetPositionZ (), health , mana );
SendResurrectRequest ( target );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectAddExtraAttacks ( SpellEffIndex effIndex )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2010-08-27 17:49:32 +02:00
if ( ! unitTarget || ! unitTarget -> isAlive () || ! unitTarget -> getVictim ())
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2010-04-07 22:59:46 +02:00
if ( unitTarget -> m_extraAttacks )
2009-06-27 16:37:29 +02:00
return ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
unitTarget -> m_extraAttacks = damage ;
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
ExecuteLogEffectExtraAttacks ( effIndex , unitTarget -> getVictim (), damage );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectParry ( SpellEffIndex /*effIndex*/ )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT )
return ;
if ( m_caster -> GetTypeId () == TYPEID_PLAYER )
m_caster -> ToPlayer () -> SetCanParry ( true );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectBlock ( SpellEffIndex /*effIndex*/ )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT )
return ;
if ( m_caster -> GetTypeId () == TYPEID_PLAYER )
m_caster -> ToPlayer () -> SetCanBlock ( true );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectLeap ( SpellEffIndex /*effIndex*/ )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
if ( ! unitTarget || unitTarget -> isInFlight ())
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( ! m_targets . HasDst ())
2008-11-01 18:52:59 -05:00
return ;
2009-10-17 15:51:44 -07:00
2012-02-11 19:23:18 -05:00
Position pos ;
2012-05-30 08:01:02 +02:00
destTarget -> GetPosition ( & pos );
2012-02-11 19:23:18 -05:00
unitTarget -> GetFirstCollisionPosition ( pos , unitTarget -> GetDistance ( pos . GetPositionX (), pos . GetPositionY (), pos . GetPositionZ () + 2.0f ), 0.0f );
unitTarget -> NearTeleportTo ( pos . GetPositionX (), pos . GetPositionY (), pos . GetPositionZ (), pos . GetOrientation (), unitTarget == m_caster );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectReputation ( SpellEffIndex effIndex )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2010-08-09 11:33:31 -06:00
if ( ! unitTarget || unitTarget -> GetTypeId () != TYPEID_PLAYER )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2011-12-10 15:40:55 +01:00
Player * player = unitTarget -> ToPlayer ();
2009-10-17 15:51:44 -07:00
2012-12-02 16:32:44 +01:00
int32 repChange = damage ;
2009-10-17 15:51:44 -07:00
2012-12-02 16:32:44 +01:00
uint32 factionId = m_spellInfo -> Effects [ effIndex ]. MiscValue ;
2009-10-17 15:51:44 -07:00
2012-12-02 16:32:44 +01:00
FactionEntry const * factionEntry = sFactionStore . LookupEntry ( factionId );
2010-08-09 11:33:31 -06:00
if ( ! factionEntry )
return ;
2012-12-02 16:32:44 +01:00
repChange = player -> CalculateReputationGain ( REPUTATION_SOURCE_SPELL , 0 , repChange , factionId );
2010-08-09 11:33:31 -06:00
2012-12-02 16:32:44 +01:00
player -> GetReputationMgr (). ModifyReputation ( factionEntry , repChange );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectQuestComplete ( SpellEffIndex effIndex )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
if ( ! unitTarget || unitTarget -> GetTypeId () != TYPEID_PLAYER )
2010-01-25 20:45:02 +01:00
return ;
2011-09-25 13:29:17 +02:00
Player * player = unitTarget -> ToPlayer ();
2009-10-17 15:51:44 -07:00
2011-07-26 23:09:28 +02:00
uint32 questId = m_spellInfo -> Effects [ effIndex ]. MiscValue ;
2011-06-15 20:46:49 +02:00
if ( questId )
2010-07-04 19:16:40 +02:00
{
2011-06-15 20:46:49 +02:00
Quest const * quest = sObjectMgr -> GetQuestTemplate ( questId );
if ( ! quest )
2011-06-15 20:24:47 +03:00
return ;
2011-06-15 20:46:49 +02:00
uint16 logSlot = player -> FindQuestSlot ( questId );
if ( logSlot < MAX_QUEST_LOG_SIZE )
player -> AreaExploredOrEventHappens ( questId );
else if ( player -> CanTakeQuest ( quest , false )) // never rewarded before
player -> CompleteQuest ( questId ); // quest not in log - for internal use
2010-07-04 19:16:40 +02:00
}
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectForceDeselect ( SpellEffIndex /*effIndex*/ )
2010-01-13 10:27:44 +01:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT )
return ;
2010-01-13 18:22:31 +01:00
WorldPacket data ( SMSG_CLEAR_TARGET , 8 );
data << uint64 ( m_caster -> GetGUID ());
2010-01-13 10:27:44 +01:00
m_caster -> SendMessageToSet ( & data , true );
}
2010-08-27 19:36:27 +02:00
void Spell :: EffectSelfResurrect ( SpellEffIndex effIndex )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT )
2008-10-11 14:16:25 -05:00
return ;
2011-09-25 13:29:17 +02:00
if ( ! m_caster || m_caster -> isAlive ())
2008-10-11 14:16:25 -05:00
return ;
2011-09-25 13:29:17 +02:00
if ( m_caster -> GetTypeId () != TYPEID_PLAYER )
return ;
if ( ! m_caster -> IsInWorld ())
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
uint32 health = 0 ;
uint32 mana = 0 ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// flat case
2010-04-07 19:14:10 +02:00
if ( damage < 0 )
2008-10-11 14:16:25 -05:00
{
health = uint32 ( - damage );
2011-07-26 23:09:28 +02:00
mana = m_spellInfo -> Effects [ effIndex ]. MiscValue ;
2008-10-11 14:16:25 -05:00
}
// percent case
else
{
2011-09-25 13:29:17 +02:00
health = m_caster -> CountPctFromMaxHealth ( damage );
if ( m_caster -> GetMaxPower ( POWER_MANA ) > 0 )
2012-10-02 12:17:42 +02:00
mana = CalculatePct ( m_caster -> GetMaxPower ( POWER_MANA ), damage );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2011-11-07 11:06:39 -06:00
Player * player = m_caster -> ToPlayer ();
player -> ResurrectPlayer ( 0.0f );
2009-10-17 15:51:44 -07:00
2011-11-07 11:06:39 -06:00
player -> SetHealth ( health );
player -> SetPower ( POWER_MANA , mana );
player -> SetPower ( POWER_RAGE , 0 );
player -> SetPower ( POWER_ENERGY , player -> GetMaxPower ( POWER_ENERGY ));
2011-11-25 15:28:36 +01:00
player -> SetPower ( POWER_FOCUS , 0 );
2009-10-17 15:51:44 -07:00
2011-11-07 11:06:39 -06:00
player -> SpawnCorpseBones ();
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectSkinning ( SpellEffIndex /*effIndex*/ )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2010-04-07 22:59:46 +02:00
if ( unitTarget -> GetTypeId () != TYPEID_UNIT )
2008-10-11 14:16:25 -05:00
return ;
2010-12-22 20:18:34 +02:00
if ( m_caster -> GetTypeId () != TYPEID_PLAYER )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2010-03-07 18:30:53 +01:00
Creature * creature = unitTarget -> ToCreature ();
2008-10-11 14:16:25 -05:00
int32 targetLevel = creature -> getLevel ();
2009-10-17 15:51:44 -07:00
2012-05-30 08:01:02 +02:00
uint32 skill = creature -> GetCreatureTemplate () -> GetRequiredLootSkill ();
2009-10-17 15:51:44 -07:00
2011-04-29 20:47:02 +02:00
m_caster -> ToPlayer () -> SendLoot ( creature -> GetGUID (), LOOT_SKINNING );
2008-10-11 14:16:25 -05:00
creature -> RemoveFlag ( UNIT_FIELD_FLAGS , UNIT_FLAG_SKINNABLE );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
int32 reqValue = targetLevel < 10 ? 0 : targetLevel < 20 ? ( targetLevel - 10 ) * 10 : targetLevel * 5 ;
2009-10-17 15:51:44 -07:00
2010-03-07 15:20:19 +01:00
int32 skillValue = m_caster -> ToPlayer () -> GetPureSkillValue ( skill );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// Double chances for elites
2010-04-07 22:59:46 +02:00
m_caster -> ToPlayer () -> UpdateGatherSkill ( skill , skillValue , reqValue , creature -> isElite () ? 2 : 1 );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectCharge ( SpellEffIndex /*effIndex*/ )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode == SPELL_EFFECT_HANDLE_LAUNCH_TARGET )
{
if ( ! unitTarget )
return ;
2009-10-17 15:51:44 -07:00
2011-12-10 01:43:04 +01:00
float angle = unitTarget -> GetRelativeAngle ( m_caster );
Position pos ;
unitTarget -> GetContactPoint ( m_caster , pos . m_positionX , pos . m_positionY , pos . m_positionZ );
unitTarget -> GetFirstCollisionPosition ( pos , unitTarget -> GetObjectSize (), angle );
m_caster -> GetMotionMaster () -> MoveCharge ( pos . m_positionX , pos . m_positionY , pos . m_positionZ + unitTarget -> GetObjectSize ());
2011-09-25 13:29:17 +02:00
}
if ( effectHandleMode == SPELL_EFFECT_HANDLE_HIT_TARGET )
{
if ( ! unitTarget )
return ;
2009-10-17 15:51:44 -07:00
2011-09-25 13:29:17 +02:00
// not all charge effects used in negative spells
if ( ! m_spellInfo -> IsPositive () && m_caster -> GetTypeId () == TYPEID_PLAYER )
m_caster -> Attack ( unitTarget , true );
}
2009-07-01 17:36:34 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectChargeDest ( SpellEffIndex /*effIndex*/ )
2009-07-01 17:36:34 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_LAUNCH )
return ;
2010-04-07 19:14:10 +02:00
if ( m_targets . HasDst ())
2009-07-01 17:47:31 -05:00
{
2011-12-10 01:43:04 +01:00
Position pos ;
2012-05-30 08:01:02 +02:00
destTarget -> GetPosition ( & pos );
2011-12-10 01:43:04 +01:00
float angle = m_caster -> GetRelativeAngle ( pos . GetPositionX (), pos . GetPositionY ());
float dist = m_caster -> GetDistance ( pos );
m_caster -> GetFirstCollisionPosition ( pos , dist , angle );
m_caster -> GetMotionMaster () -> MoveCharge ( pos . m_positionX , pos . m_positionY , pos . m_positionZ );
2009-07-01 17:47:31 -05:00
}
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectKnockBack ( SpellEffIndex effIndex )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2010-04-07 19:14:10 +02:00
if ( ! unitTarget )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2011-05-07 22:16:30 +02:00
if ( Creature * creatureTarget = unitTarget -> ToCreature ())
if ( creatureTarget -> isWorldBoss () || creatureTarget -> IsDungeonBoss ())
return ;
2012-07-28 15:37:24 +02:00
// Spells with SPELL_EFFECT_KNOCK_BACK(like Thunderstorm) can't knoback target if target has ROOT/STUN
2012-07-28 23:19:45 +02:00
if ( unitTarget -> HasUnitState ( UNIT_STATE_ROOT | UNIT_STATE_STUNNED ))
2012-07-28 15:37:24 +02:00
return ;
2009-08-18 00:35:32 +02:00
// Typhoon
if ( m_spellInfo -> SpellFamilyName == SPELLFAMILY_DRUID && m_spellInfo -> SpellFamilyFlags [ 1 ] & 0x01000000 )
{
// Glyph of Typhoon
if ( m_caster -> HasAura ( 62135 ))
return ;
}
2009-10-17 15:51:44 -07:00
2009-08-18 00:35:32 +02:00
// Thunderstorm
if ( m_spellInfo -> SpellFamilyName == SPELLFAMILY_SHAMAN && m_spellInfo -> SpellFamilyFlags [ 1 ] & 0x00002000 )
{
// Glyph of Thunderstorm
if ( m_caster -> HasAura ( 62132 ))
return ;
}
2009-10-17 15:51:44 -07:00
2011-05-05 18:08:01 -03:00
// Instantly interrupt non melee spells being casted
if ( unitTarget -> IsNonMeleeSpellCasted ( true ))
unitTarget -> InterruptNonMeleeSpells ( true );
2011-09-30 18:24:12 +02:00
float ratio = 0.1f ;
2011-07-26 23:09:28 +02:00
float speedxy = float ( m_spellInfo -> Effects [ effIndex ]. MiscValue ) * ratio ;
2009-08-25 16:34:17 -05:00
float speedz = float ( damage ) * ratio ;
2010-04-07 19:14:10 +02:00
if ( speedxy < 0.1f && speedz < 0.1f )
2009-08-25 16:34:17 -05:00
return ;
2009-10-17 15:51:44 -07:00
2009-02-06 21:48:47 -06:00
float x , y ;
2011-07-26 23:09:28 +02:00
if ( m_spellInfo -> Effects [ effIndex ]. Effect == SPELL_EFFECT_KNOCK_BACK_DEST )
2010-07-20 04:29:17 +02:00
{
if ( m_targets . HasDst ())
2012-05-30 08:01:02 +02:00
destTarget -> GetPosition ( x , y );
2010-07-20 04:29:17 +02:00
else
return ;
}
2011-07-26 23:09:28 +02:00
else //if (m_spellInfo->Effects[i].Effect == SPELL_EFFECT_KNOCK_BACK)
2010-07-20 04:29:17 +02:00
{
2009-08-29 23:20:16 -05:00
m_caster -> GetPosition ( x , y );
2010-08-08 19:45:53 +02:00
}
2009-10-17 15:51:44 -07:00
2009-04-11 22:41:15 -05:00
unitTarget -> KnockbackFrom ( x , y , speedxy , speedz );
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectLeapBack ( SpellEffIndex effIndex )
2009-04-11 22:41:15 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_LAUNCH_TARGET )
return ;
if ( ! unitTarget )
return ;
2011-07-26 23:09:28 +02:00
float speedxy = float ( m_spellInfo -> Effects [ effIndex ]. MiscValue ) / 10 ;
2009-04-11 22:41:15 -05:00
float speedz = float ( damage / 10 );
2011-09-25 13:29:17 +02:00
//1891: Disengage
m_caster -> JumpTo ( speedxy , speedz , m_spellInfo -> SpellIconID != 1891 );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectQuestClear ( SpellEffIndex effIndex )
2010-07-04 19:16:40 +02:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2010-08-08 19:45:53 +02:00
2011-09-25 13:29:17 +02:00
if ( ! unitTarget || unitTarget -> GetTypeId () != TYPEID_PLAYER )
2010-07-04 19:16:40 +02:00
return ;
2011-10-07 11:08:09 -05:00
Player * player = unitTarget -> ToPlayer ();
2010-07-04 19:16:40 +02:00
2011-07-26 23:09:28 +02:00
uint32 quest_id = m_spellInfo -> Effects [ effIndex ]. MiscValue ;
2010-07-04 19:16:40 +02:00
2011-10-07 19:45:43 -05:00
Quest const * quest = sObjectMgr -> GetQuestTemplate ( quest_id );
2010-07-04 19:16:40 +02:00
2011-10-07 19:45:43 -05:00
if ( ! quest )
2010-07-04 19:16:40 +02:00
return ;
// Player has never done this quest
2011-10-07 11:08:09 -05:00
if ( player -> GetQuestStatus ( quest_id ) == QUEST_STATUS_NONE )
2010-07-04 19:16:40 +02:00
return ;
// remove all quest entries for 'entry' from quest log
for ( uint8 slot = 0 ; slot < MAX_QUEST_LOG_SIZE ; ++ slot )
{
2011-11-23 19:17:33 +01:00
uint32 logQuest = player -> GetQuestSlotQuestId ( slot );
if ( logQuest == quest_id )
2010-07-04 19:16:40 +02:00
{
2011-10-07 11:08:09 -05:00
player -> SetQuestSlot ( slot , 0 );
2010-07-04 19:16:40 +02:00
2011-11-23 19:17:33 +01:00
// we ignore unequippable quest items in this case, it's still be equipped
player -> TakeQuestSourceItem ( logQuest , false );
2010-07-04 19:16:40 +02:00
}
}
2011-10-07 11:08:09 -05:00
player -> RemoveActiveQuest ( quest_id );
player -> RemoveRewardedQuest ( quest_id );
2010-07-04 19:16:40 +02:00
}
2010-08-27 19:36:27 +02:00
void Spell :: EffectSendTaxi ( SpellEffIndex effIndex )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2010-04-07 19:14:10 +02:00
if ( ! unitTarget || unitTarget -> GetTypeId () != TYPEID_PLAYER )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2011-07-26 23:09:28 +02:00
unitTarget -> ToPlayer () -> ActivateTaxiPathTo ( m_spellInfo -> Effects [ effIndex ]. MiscValue , m_spellInfo -> Id );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectPullTowards ( SpellEffIndex effIndex )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2010-04-07 19:14:10 +02:00
if ( ! unitTarget )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2011-07-26 23:09:28 +02:00
float speedZ = ( float )( m_spellInfo -> Effects [ effIndex ]. CalcValue () / 10 );
float speedXY = ( float )( m_spellInfo -> Effects [ effIndex ]. MiscValue / 10 );
2010-08-09 02:31:42 +02:00
Position pos ;
2011-07-26 23:09:28 +02:00
if ( m_spellInfo -> Effects [ effIndex ]. Effect == SPELL_EFFECT_PULL_TOWARDS_DEST )
2010-08-09 02:31:42 +02:00
{
if ( m_targets . HasDst ())
2012-05-30 08:01:02 +02:00
pos . Relocate ( * destTarget );
2010-08-09 02:31:42 +02:00
else
return ;
}
2011-07-26 23:09:28 +02:00
else //if (m_spellInfo->Effects[i].Effect == SPELL_EFFECT_PULL_TOWARDS)
2010-08-09 02:31:42 +02:00
{
pos . Relocate ( m_caster );
}
unitTarget -> GetMotionMaster () -> MoveJump ( pos . GetPositionX (), pos . GetPositionY (), pos . GetPositionZ (), speedXY , speedZ );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectDispelMechanic ( SpellEffIndex effIndex )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2010-04-07 19:14:10 +02:00
if ( ! unitTarget )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2011-07-26 23:09:28 +02:00
uint32 mechanic = m_spellInfo -> Effects [ effIndex ]. MiscValue ;
2009-10-17 15:51:44 -07:00
2009-04-19 22:21:40 +02:00
std :: queue < std :: pair < uint32 , uint64 > > dispel_list ;
2009-10-17 15:51:44 -07:00
2010-01-10 20:09:44 +01:00
Unit :: AuraMap const & auras = unitTarget -> GetOwnedAuras ();
for ( Unit :: AuraMap :: const_iterator itr = auras . begin (); itr != auras . end (); ++ itr )
2009-04-13 18:56:29 +02:00
{
2011-09-15 14:08:17 +02:00
Aura * aura = itr -> second ;
2010-01-10 20:09:44 +01:00
if ( ! aura -> GetApplicationOfTarget ( unitTarget -> GetGUID ()))
continue ;
2011-07-26 23:09:28 +02:00
if ( roll_chance_i ( aura -> CalcDispelChance ( unitTarget , ! unitTarget -> IsFriendlyTo ( m_caster ))))
if (( aura -> GetSpellInfo () -> GetAllEffectsMechanicMask () & ( 1 << mechanic )))
dispel_list . push ( std :: make_pair ( aura -> GetId (), aura -> GetCasterGUID ()));
2009-04-13 18:56:29 +02:00
}
2009-10-17 15:51:44 -07:00
2009-10-17 16:20:24 -07:00
for (; dispel_list . size (); dispel_list . pop ())
2008-10-11 14:16:25 -05:00
{
2010-01-10 01:23:15 +01:00
unitTarget -> RemoveAura ( dispel_list . front (). first , dispel_list . front (). second , 0 , AURA_REMOVE_BY_ENEMY_SPELL );
2008-10-11 14:16:25 -05:00
}
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectSummonDeadPet ( SpellEffIndex /*effIndex*/ )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT )
return ;
2011-12-10 15:40:55 +01:00
Player * player = m_caster -> ToPlayer ();
if ( ! player )
2008-10-11 14:16:25 -05:00
return ;
2011-12-10 13:48:41 +01:00
2011-12-10 15:40:55 +01:00
Pet * pet = player -> GetPet ();
2012-05-30 08:01:02 +02:00
if ( pet && pet -> isAlive ())
2008-10-11 14:16:25 -05:00
return ;
2011-12-10 13:48:41 +01:00
2010-04-07 19:14:10 +02:00
if ( damage < 0 )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2011-04-29 20:47:02 +02:00
float x , y , z ;
2011-12-10 15:40:55 +01:00
player -> GetPosition ( x , y , z );
2012-05-30 08:01:02 +02:00
if ( ! pet )
{
player -> SummonPet ( 0 , x , y , z , player -> GetOrientation (), SUMMON_PET , 0 );
pet = player -> GetPet ();
}
if ( ! pet )
return ;
2011-12-10 15:40:55 +01:00
player -> GetMap () -> CreatureRelocation ( pet , x , y , z , player -> GetOrientation ());
2010-01-16 19:11:32 +03:00
2011-05-30 21:30:52 +03:00
pet -> SetUInt32Value ( UNIT_DYNAMIC_FLAGS , UNIT_DYNFLAG_NONE );
pet -> RemoveFlag ( UNIT_FIELD_FLAGS , UNIT_FLAG_SKINNABLE );
2010-04-07 22:59:46 +02:00
pet -> setDeathState ( ALIVE );
2012-02-03 19:12:41 +02:00
pet -> ClearUnitState ( uint32 ( UNIT_STATE_ALL_STATE ));
2010-08-26 01:20:57 +06:00
pet -> SetHealth ( pet -> CountPctFromMaxHealth ( damage ));
2009-10-17 15:51:44 -07:00
2009-04-06 22:08:12 -05:00
//pet->AIM_Initialize();
2011-12-10 15:40:55 +01:00
//player->PetSpellInitialize();
2008-10-11 14:16:25 -05:00
pet -> SavePetToDB ( PET_SAVE_AS_CURRENT );
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectDestroyAllTotems ( SpellEffIndex /*effIndex*/ )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT )
return ;
2009-05-06 17:00:11 -05:00
int32 mana = 0 ;
2009-10-17 16:20:24 -07:00
for ( uint8 slot = SUMMON_SLOT_TOTEM ; slot < MAX_TOTEM_SLOT ; ++ slot )
2008-10-11 14:16:25 -05:00
{
2010-04-07 19:14:10 +02:00
if ( ! m_caster -> m_SummonSlot [ slot ])
2008-10-11 14:16:25 -05:00
continue ;
2009-10-17 15:51:44 -07:00
2009-04-20 20:28:19 -05:00
Creature * totem = m_caster -> GetMap () -> GetCreature ( m_caster -> m_SummonSlot [ slot ]);
2010-04-07 19:14:10 +02:00
if ( totem && totem -> isTotem ())
2008-10-11 14:16:25 -05:00
{
uint32 spell_id = totem -> GetUInt32Value ( UNIT_CREATED_BY_SPELL );
2011-07-26 23:09:28 +02:00
SpellInfo const * spellInfo = sSpellMgr -> GetSpellInfo ( spell_id );
2010-04-07 19:14:10 +02:00
if ( spellInfo )
2009-04-12 01:29:56 +02:00
{
2011-07-26 23:09:28 +02:00
mana += spellInfo -> ManaCost ;
2012-10-02 12:17:42 +02:00
mana += int32 ( CalculatePct ( m_caster -> GetCreateMana (), spellInfo -> ManaCostPercentage ));
2009-04-12 01:29:56 +02:00
}
2010-03-10 07:58:11 +01:00
totem -> ToTotem () -> UnSummon ();
2008-10-11 14:16:25 -05:00
}
}
2012-10-02 12:17:42 +02:00
ApplyPct ( mana , damage );
2009-05-06 17:00:11 -05:00
if ( mana )
m_caster -> CastCustomSpell ( m_caster , 39104 , & mana , NULL , NULL , true );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectDurabilityDamage ( SpellEffIndex effIndex )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2010-04-07 19:14:10 +02:00
if ( ! unitTarget || unitTarget -> GetTypeId () != TYPEID_PLAYER )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2011-07-26 23:09:28 +02:00
int32 slot = m_spellInfo -> Effects [ effIndex ]. MiscValue ;
2009-10-17 15:51:44 -07:00
2012-11-25 11:13:39 +01:00
// -1 means all player equipped items and -2 all items
2010-04-07 19:14:10 +02:00
if ( slot < 0 )
2008-10-11 14:16:25 -05:00
{
2010-03-07 15:20:19 +01:00
unitTarget -> ToPlayer () -> DurabilityPointsLossAll ( damage , ( slot < - 1 ));
2012-11-25 11:13:39 +01:00
ExecuteLogEffectDurabilityDamage ( effIndex , unitTarget , - 1 , - 1 );
2008-10-11 14:16:25 -05:00
return ;
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// invalid slot value
2010-04-07 19:14:10 +02:00
if ( slot >= INVENTORY_SLOT_BAG_END )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( Item * item = unitTarget -> ToPlayer () -> GetItemByPos ( INVENTORY_SLOT_BAG_0 , slot ))
2012-10-20 00:02:32 +02:00
{
2010-03-07 15:20:19 +01:00
unitTarget -> ToPlayer () -> DurabilityPointsLoss ( item , damage );
2012-10-20 00:02:32 +02:00
ExecuteLogEffectDurabilityDamage ( effIndex , unitTarget , item -> GetEntry (), slot );
}
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectDurabilityDamagePCT ( SpellEffIndex effIndex )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2010-04-07 19:14:10 +02:00
if ( ! unitTarget || unitTarget -> GetTypeId () != TYPEID_PLAYER )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2011-07-26 23:09:28 +02:00
int32 slot = m_spellInfo -> Effects [ effIndex ]. MiscValue ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// FIXME: some spells effects have value -1/-2
// Possibly its mean -1 all player equipped items and -2 all items
2010-04-07 19:14:10 +02:00
if ( slot < 0 )
2008-10-11 14:16:25 -05:00
{
2010-12-11 20:37:38 +06:00
unitTarget -> ToPlayer () -> DurabilityLossAll ( float ( damage ) / 100.0f , ( slot < - 1 ));
2008-10-11 14:16:25 -05:00
return ;
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// invalid slot value
2010-04-07 19:14:10 +02:00
if ( slot >= INVENTORY_SLOT_BAG_END )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( damage <= 0 )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( Item * item = unitTarget -> ToPlayer () -> GetItemByPos ( INVENTORY_SLOT_BAG_0 , slot ))
2010-12-11 20:37:38 +06:00
unitTarget -> ToPlayer () -> DurabilityLoss ( item , float ( damage ) / 100.0f );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectModifyThreatPercent ( SpellEffIndex /*effIndex*/ )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2010-04-07 19:14:10 +02:00
if ( ! unitTarget )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
unitTarget -> getThreatManager (). modifyThreatPercent ( m_caster , damage );
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectTransmitted ( SpellEffIndex effIndex )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT )
return ;
2011-07-26 23:09:28 +02:00
uint32 name_id = m_spellInfo -> Effects [ effIndex ]. MiscValue ;
2009-10-17 15:51:44 -07:00
2011-04-28 22:54:30 +02:00
GameObjectTemplate const * goinfo = sObjectMgr -> GetGameObjectTemplate ( name_id );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
if ( ! goinfo )
{
2012-08-03 14:20:18 +02:00
sLog -> outError ( LOG_FILTER_SQL , "Gameobject (Entry: %u) not exist and not created at spell (ID: %u) cast" , name_id , m_spellInfo -> Id );
2008-10-11 14:16:25 -05:00
return ;
}
2009-10-17 15:51:44 -07:00
2009-05-31 15:56:51 -05:00
float fx , fy , fz ;
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( m_targets . HasDst ())
2012-05-30 08:01:02 +02:00
destTarget -> GetPosition ( fx , fy , fz );
2008-10-11 14:16:25 -05:00
//FIXME: this can be better check for most objects but still hack
2011-07-26 23:09:28 +02:00
else if ( m_spellInfo -> Effects [ effIndex ]. HasRadius () && m_spellInfo -> Speed == 0 )
2008-10-11 14:16:25 -05:00
{
2011-07-26 23:09:28 +02:00
float dis = m_spellInfo -> Effects [ effIndex ]. CalcRadius ( m_originalCaster );
2009-05-31 15:56:51 -05:00
m_caster -> GetClosePoint ( fx , fy , fz , DEFAULT_WORLD_OBJECT_SIZE , dis );
2008-10-11 14:16:25 -05:00
}
else
{
2009-02-14 15:56:04 +01:00
//GO is always friendly to it's creator, get range for friends
2011-07-26 23:09:28 +02:00
float min_dis = m_spellInfo -> GetMinRange ( true );
float max_dis = m_spellInfo -> GetMaxRange ( true );
2010-08-22 12:39:39 -07:00
float dis = ( float ) rand_norm () * ( max_dis - min_dis ) + min_dis ;
2009-10-17 15:51:44 -07:00
2009-05-31 15:56:51 -05:00
m_caster -> GetClosePoint ( fx , fy , fz , DEFAULT_WORLD_OBJECT_SIZE , dis );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2011-09-15 14:08:17 +02:00
Map * cMap = m_caster -> GetMap ();
2010-11-10 11:37:41 +01:00
if ( goinfo -> type == GAMEOBJECT_TYPE_FISHINGNODE || goinfo -> type == GAMEOBJECT_TYPE_FISHINGHOLE )
2008-10-11 14:16:25 -05:00
{
2010-06-05 00:59:25 +02:00
LiquidData liqData ;
2011-06-12 02:30:32 +02:00
if ( ! cMap -> IsInWater ( fx , fy , fz + 1.f /* -0.5f */ , & liqData )) // Hack to prevent fishing bobber from failing to land on fishing hole
2008-10-11 14:16:25 -05:00
{ // but this is not proper, we really need to ignore not materialized objects
SendCastResult ( SPELL_FAILED_NOT_HERE );
SendChannelUpdate ( 0 );
return ;
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// replace by water level in this case
2010-06-05 00:59:25 +02:00
//fz = cMap->GetWaterLevel(fx, fy);
fz = liqData . level ;
2008-10-11 14:16:25 -05:00
}
// if gameobject is summoning object, it should be spawned right on caster's position
2010-04-07 23:25:02 +02:00
else if ( goinfo -> type == GAMEOBJECT_TYPE_SUMMONING_RITUAL )
2008-10-11 14:16:25 -05:00
{
2009-05-31 15:56:51 -05:00
m_caster -> GetPosition ( fx , fy , fz );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
GameObject * pGameObj = new GameObject ;
2009-10-17 15:51:44 -07:00
2010-12-22 21:25:23 +01:00
if ( ! pGameObj -> Create ( sObjectMgr -> GenerateLowGuid ( HIGHGUID_GAMEOBJECT ), name_id , cMap ,
2009-04-27 18:36:10 -05:00
m_caster -> GetPhaseMask (), fx , fy , fz , m_caster -> GetOrientation (), 0.0f , 0.0f , 0.0f , 0.0f , 100 , GO_STATE_READY ))
2008-10-11 14:16:25 -05:00
{
delete pGameObj ;
return ;
}
2009-10-17 15:51:44 -07:00
2011-07-26 23:09:28 +02:00
int32 duration = m_spellInfo -> GetDuration ();
2009-10-17 15:51:44 -07:00
2011-09-29 12:43:05 +02:00
switch ( goinfo -> type )
2008-10-11 14:16:25 -05:00
{
case GAMEOBJECT_TYPE_FISHINGNODE :
{
2011-04-29 20:47:02 +02:00
m_caster -> SetUInt64Value ( UNIT_FIELD_CHANNEL_OBJECT , pGameObj -> GetGUID ());
2008-10-11 14:16:25 -05:00
m_caster -> AddGameObject ( pGameObj ); // will removed at spell cancel
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// end time of range when possible catch fish (FISHING_BOBBER_READY_TIME..GetDuration(m_spellInfo))
// start time == fish-FISHING_BOBBER_READY_TIME (0..GetDuration(m_spellInfo)-FISHING_BOBBER_READY_TIME)
2009-04-27 18:42:35 -05:00
int32 lastSec = 0 ;
2011-09-29 12:43:05 +02:00
switch ( urand ( 0 , 3 ))
2008-10-11 14:16:25 -05:00
{
case 0 : lastSec = 3 ; break ;
case 1 : lastSec = 7 ; break ;
case 2 : lastSec = 13 ; break ;
case 3 : lastSec = 17 ; break ;
}
2009-10-17 15:51:44 -07:00
2010-07-12 00:30:17 +02:00
duration = duration - lastSec * IN_MILLISECONDS + FISHING_BOBBER_READY_TIME * IN_MILLISECONDS ;
2008-10-11 14:16:25 -05:00
break ;
}
case GAMEOBJECT_TYPE_SUMMONING_RITUAL :
{
2010-04-07 19:14:10 +02:00
if ( m_caster -> GetTypeId () == TYPEID_PLAYER )
2008-10-11 14:16:25 -05:00
{
2010-11-10 11:37:41 +01:00
pGameObj -> AddUniqueUse ( m_caster -> ToPlayer ());
2011-08-03 08:18:24 +02:00
m_caster -> AddGameObject ( pGameObj ); // will be removed at spell cancel
2008-10-11 14:16:25 -05:00
}
break ;
}
2009-08-13 00:21:10 -05:00
case GAMEOBJECT_TYPE_DUEL_ARBITER : // 52991
m_caster -> AddGameObject ( pGameObj );
break ;
2008-10-11 14:16:25 -05:00
case GAMEOBJECT_TYPE_FISHINGHOLE :
case GAMEOBJECT_TYPE_CHEST :
default :
break ;
}
2009-10-17 15:51:44 -07:00
2010-07-12 00:30:17 +02:00
pGameObj -> SetRespawnTime ( duration > 0 ? duration / IN_MILLISECONDS : 0 );
2009-10-17 15:51:44 -07:00
2009-07-30 10:26:15 +08:00
pGameObj -> SetOwnerGUID ( m_caster -> GetGUID ());
2009-10-17 15:51:44 -07:00
2009-07-30 10:26:15 +08:00
//pGameObj->SetUInt32Value(GAMEOBJECT_LEVEL, m_caster->getLevel());
2008-10-11 14:16:25 -05:00
pGameObj -> SetSpellId ( m_spellInfo -> Id );
2009-10-17 15:51:44 -07:00
2010-08-27 17:49:32 +02:00
ExecuteLogEffectSummonObject ( effIndex , pGameObj );
2012-08-03 14:20:18 +02:00
sLog -> outDebug ( LOG_FILTER_SPELLS_AURAS , "AddObject at SpellEfects.cpp EffectTransmitted" );
2008-10-11 14:16:25 -05:00
//m_caster->AddGameObject(pGameObj);
//m_ObjToDel.push_back(pGameObj);
2009-10-17 15:51:44 -07:00
2011-10-10 17:39:34 -04:00
cMap -> AddToMap ( pGameObj );
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( uint32 linkedEntry = pGameObj -> GetGOInfo () -> GetLinkedGameObjectEntry ())
2008-10-11 14:16:25 -05:00
{
GameObject * linkedGO = new GameObject ;
2010-12-22 21:25:23 +01:00
if ( linkedGO -> Create ( sObjectMgr -> GenerateLowGuid ( HIGHGUID_GAMEOBJECT ), linkedEntry , cMap ,
2009-04-27 18:36:10 -05:00
m_caster -> GetPhaseMask (), fx , fy , fz , m_caster -> GetOrientation (), 0.0f , 0.0f , 0.0f , 0.0f , 100 , GO_STATE_READY ))
2008-10-11 14:16:25 -05:00
{
2010-07-12 00:30:17 +02:00
linkedGO -> SetRespawnTime ( duration > 0 ? duration / IN_MILLISECONDS : 0 );
2009-07-30 10:26:15 +08:00
//linkedGO->SetUInt32Value(GAMEOBJECT_LEVEL, m_caster->getLevel());
2008-10-11 14:16:25 -05:00
linkedGO -> SetSpellId ( m_spellInfo -> Id );
2009-07-30 10:26:15 +08:00
linkedGO -> SetOwnerGUID ( m_caster -> GetGUID ());
2009-10-17 15:51:44 -07:00
2010-08-27 17:49:32 +02:00
ExecuteLogEffectSummonObject ( effIndex , linkedGO );
2011-10-10 17:39:34 -04:00
linkedGO -> GetMap () -> AddToMap ( linkedGO );
2008-10-11 14:16:25 -05:00
}
else
{
delete linkedGO ;
linkedGO = NULL ;
return ;
}
}
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectProspecting ( SpellEffIndex /*effIndex*/ )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2010-04-07 19:14:10 +02:00
if ( m_caster -> GetTypeId () != TYPEID_PLAYER )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
Player * p_caster = ( Player * ) m_caster ;
2011-04-28 22:42:33 +02:00
if ( ! itemTarget || ! ( itemTarget -> GetTemplate () -> Flags & ITEM_PROTO_FLAG_PROSPECTABLE ))
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( itemTarget -> GetCount () < 5 )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2010-12-23 23:25:44 +01:00
if ( sWorld -> getBoolConfig ( CONFIG_SKILL_PROSPECTING ))
2008-10-11 14:16:25 -05:00
{
uint32 SkillValue = p_caster -> GetPureSkillValue ( SKILL_JEWELCRAFTING );
2011-04-28 22:42:33 +02:00
uint32 reqSkillValue = itemTarget -> GetTemplate () -> RequiredSkillRank ;
2008-10-11 14:16:25 -05:00
p_caster -> UpdateGatherSkill ( SKILL_JEWELCRAFTING , SkillValue , reqSkillValue );
}
2009-10-17 15:51:44 -07:00
2010-03-07 15:20:19 +01:00
m_caster -> ToPlayer () -> SendLoot ( itemTarget -> GetGUID (), LOOT_PROSPECTING );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectMilling ( SpellEffIndex /*effIndex*/ )
2008-12-24 09:58:26 -06:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2010-04-07 19:14:10 +02:00
if ( m_caster -> GetTypeId () != TYPEID_PLAYER )
2008-12-24 09:58:26 -06:00
return ;
2009-10-17 15:51:44 -07:00
2008-12-24 09:58:26 -06:00
Player * p_caster = ( Player * ) m_caster ;
2011-04-28 22:42:33 +02:00
if ( ! itemTarget || ! ( itemTarget -> GetTemplate () -> Flags & ITEM_PROTO_FLAG_MILLABLE ))
2008-12-24 09:58:26 -06:00
return ;
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( itemTarget -> GetCount () < 5 )
2008-12-24 09:58:26 -06:00
return ;
2009-10-17 15:51:44 -07:00
2010-12-23 23:25:44 +01:00
if ( sWorld -> getBoolConfig ( CONFIG_SKILL_MILLING ))
2008-12-24 09:58:26 -06:00
{
uint32 SkillValue = p_caster -> GetPureSkillValue ( SKILL_INSCRIPTION );
2011-04-28 22:42:33 +02:00
uint32 reqSkillValue = itemTarget -> GetTemplate () -> RequiredSkillRank ;
2008-12-24 09:58:26 -06:00
p_caster -> UpdateGatherSkill ( SKILL_INSCRIPTION , SkillValue , reqSkillValue );
}
2009-10-17 15:51:44 -07:00
2010-03-07 15:20:19 +01:00
m_caster -> ToPlayer () -> SendLoot ( itemTarget -> GetGUID (), LOOT_MILLING );
2008-12-24 09:58:26 -06:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectSkill ( SpellEffIndex /*effIndex*/ )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT )
return ;
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_SPELLS_AURAS , "WORLD: SkillEFFECT" );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-08 04:37:24 +02:00
/* There is currently no need for this effect. We handle it in Battleground.cpp
2008-10-11 14:16:25 -05:00
If we would handle the resurrection here, the spiritguide would instantly disappear as the
player revives, and so we wouldn't see the spirit heal visual effect on the npc.
This is why we use a half sec delay between the visual effect and the resurrection itself */
2010-08-27 19:36:27 +02:00
void Spell :: EffectSpiritHeal ( SpellEffIndex /*effIndex*/ )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
2008-10-11 14:16:25 -05:00
return ;
2011-09-25 13:29:17 +02:00
/*
2010-04-07 19:14:10 +02:00
if (unitTarget->GetTypeId() != TYPEID_PLAYER)
2008-10-11 14:16:25 -05:00
return;
2010-04-07 19:14:10 +02:00
if (!unitTarget->IsInWorld())
2008-10-11 14:16:25 -05:00
return;
2009-10-17 15:51:44 -07:00
2011-07-26 23:09:28 +02:00
//m_spellInfo->Effects[i].BasePoints; == 99 (percent?)
2010-03-07 15:20:19 +01:00
//unitTarget->ToPlayer()->setResurrect(m_caster->GetGUID(), unitTarget->GetPositionX(), unitTarget->GetPositionY(), unitTarget->GetPositionZ(), unitTarget->GetMaxHealth(), unitTarget->GetMaxPower(POWER_MANA));
unitTarget->ToPlayer()->ResurrectPlayer(1.0f);
unitTarget->ToPlayer()->SpawnCorpseBones();
2008-10-11 14:16:25 -05:00
*/
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// remove insignia spell effect
2010-08-27 19:36:27 +02:00
void Spell :: EffectSkinPlayerCorpse ( SpellEffIndex /*effIndex*/ )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_SPELLS_AURAS , "Effect: SkinPlayerCorpse" );
2010-04-07 22:59:46 +02:00
if (( m_caster -> GetTypeId () != TYPEID_PLAYER ) || ( unitTarget -> GetTypeId () != TYPEID_PLAYER ) || ( unitTarget -> isAlive ()))
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2010-04-07 22:59:46 +02:00
unitTarget -> ToPlayer () -> RemovedInsignia (( Player * ) m_caster );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectStealBeneficialBuff ( SpellEffIndex effIndex )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2011-02-20 20:16:34 +01:00
sLog -> outDebug ( LOG_FILTER_SPELLS_AURAS , "Effect: StealBeneficialBuff" );
2009-10-17 15:51:44 -07:00
2010-04-07 23:25:02 +02:00
if ( ! unitTarget || unitTarget == m_caster ) // can't steal from self
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2010-05-25 10:36:33 +02:00
DispelChargesList steal_list ;
2008-10-11 14:16:25 -05:00
// Create dispel mask by dispel type
2011-07-26 23:09:28 +02:00
uint32 dispelMask = SpellInfo :: GetDispelMask ( DispelType ( m_spellInfo -> Effects [ effIndex ]. MiscValue ));
2010-01-10 01:23:15 +01:00
Unit :: AuraMap const & auras = unitTarget -> GetOwnedAuras ();
2009-10-17 16:20:24 -07:00
for ( Unit :: AuraMap :: const_iterator itr = auras . begin (); itr != auras . end (); ++ itr )
2008-10-11 14:16:25 -05:00
{
2011-09-15 14:08:17 +02:00
Aura * aura = itr -> second ;
2010-01-10 20:09:44 +01:00
AuraApplication * aurApp = aura -> GetApplicationOfTarget ( unitTarget -> GetGUID ());
if ( ! aurApp )
continue ;
2011-07-26 23:09:28 +02:00
if (( aura -> GetSpellInfo () -> GetDispelMask ()) & dispelMask )
2008-10-11 14:16:25 -05:00
{
// Need check for passive? this
2011-07-26 23:09:28 +02:00
if ( ! aurApp -> IsPositive () || aura -> IsPassive () || aura -> GetSpellInfo () -> AttributesEx4 & SPELL_ATTR4_NOT_STEALABLE )
2010-01-10 12:08:58 +01:00
continue ;
2010-05-25 10:36:33 +02:00
// The charges / stack amounts don't count towards the total number of auras that can be dispelled.
// Ie: A dispel on a target with 5 stacks of Winters Chill and a Polymorph has 1 / (1 + 1) -> 50% chance to dispell
// Polymorph instead of 1 / (5 + 1) -> 16%.
2011-07-26 23:09:28 +02:00
bool dispel_charges = aura -> GetSpellInfo () -> AttributesEx7 & SPELL_ATTR7_DISPEL_CHARGES ;
2010-05-25 10:36:33 +02:00
uint8 charges = dispel_charges ? aura -> GetCharges () : aura -> GetStackAmount ();
if ( charges > 0 )
steal_list . push_back ( std :: make_pair ( aura , charges ));
2008-10-11 14:16:25 -05:00
}
}
2010-05-25 10:36:33 +02:00
if ( steal_list . empty ())
return ;
2008-10-11 14:16:25 -05:00
// Ok if exist some buffs for dispel try dispel it
2010-05-25 10:36:33 +02:00
uint32 failCount = 0 ;
DispelList success_list ;
WorldPacket dataFail ( SMSG_DISPEL_FAILED , 8 + 8 + 4 + 4 + damage * 4 );
// dispel N = damage buffs (or while exist buffs for dispel)
for ( int32 count = 0 ; count < damage && ! steal_list . empty ();)
2008-10-11 14:16:25 -05:00
{
2010-05-25 10:36:33 +02:00
// Random select buff for dispel
DispelChargesList :: iterator itr = steal_list . begin ();
std :: advance ( itr , urand ( 0 , steal_list . size () - 1 ));
2009-10-17 15:51:44 -07:00
2011-07-26 23:09:28 +02:00
int32 chance = itr -> first -> CalcDispelChance ( unitTarget , ! unitTarget -> IsFriendlyTo ( m_caster ));
2010-05-25 10:36:33 +02:00
// 2.4.3 Patch Notes: "Dispel effects will no longer attempt to remove effects that have 100% dispel resistance."
2011-07-26 23:09:28 +02:00
if ( ! chance )
2008-10-11 14:16:25 -05:00
{
2009-04-06 13:31:14 +02:00
steal_list . erase ( itr );
2010-05-25 10:36:33 +02:00
continue ;
2008-10-11 14:16:25 -05:00
}
2010-05-25 10:36:33 +02:00
else
2008-10-11 14:16:25 -05:00
{
2011-07-26 23:09:28 +02:00
if ( roll_chance_i ( chance ))
2008-10-11 14:16:25 -05:00
{
2010-05-25 10:36:33 +02:00
success_list . push_back ( std :: make_pair ( itr -> first -> GetId (), itr -> first -> GetCasterGUID ()));
-- itr -> second ;
if ( itr -> second <= 0 )
steal_list . erase ( itr );
2008-10-11 14:16:25 -05:00
}
2010-05-25 10:36:33 +02:00
else
{
if ( ! failCount )
{
// Failed to dispell
dataFail << uint64 ( m_caster -> GetGUID ()); // Caster GUID
dataFail << uint64 ( unitTarget -> GetGUID ()); // Victim GUID
dataFail << uint32 ( m_spellInfo -> Id ); // dispel spell id
}
++ failCount ;
dataFail << uint32 ( itr -> first -> GetId ()); // Spell Id
}
++ count ;
2008-10-11 14:16:25 -05:00
}
}
2010-05-25 10:36:33 +02:00
if ( failCount )
m_caster -> SendMessageToSet ( & dataFail , true );
if ( success_list . empty ())
return ;
WorldPacket dataSuccess ( SMSG_SPELLSTEALLOG , 8 + 8 + 4 + 1 + 4 + damage * 5 );
dataSuccess . append ( unitTarget -> GetPackGUID ()); // Victim GUID
dataSuccess . append ( m_caster -> GetPackGUID ()); // Caster GUID
dataSuccess << uint32 ( m_spellInfo -> Id ); // dispel spell id
dataSuccess << uint8 ( 0 ); // not used
dataSuccess << uint32 ( success_list . size ()); // count
for ( DispelList :: iterator itr = success_list . begin (); itr != success_list . end (); ++ itr )
{
dataSuccess << uint32 ( itr -> first ); // Spell Id
dataSuccess << uint8 ( 0 ); // 0 - steals !=0 transfers
unitTarget -> RemoveAurasDueToSpellBySteal ( itr -> first , itr -> second , m_caster );
}
m_caster -> SendMessageToSet ( & dataSuccess , true );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectKillCreditPersonal ( SpellEffIndex effIndex )
2009-09-11 15:38:31 -07:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2010-04-07 19:14:10 +02:00
if ( ! unitTarget || unitTarget -> GetTypeId () != TYPEID_PLAYER )
2009-09-11 15:38:31 -07:00
return ;
2009-10-17 15:51:44 -07:00
2011-07-26 23:09:28 +02:00
unitTarget -> ToPlayer () -> KilledMonsterCredit ( m_spellInfo -> Effects [ effIndex ]. MiscValue , 0 );
2009-09-11 15:38:31 -07:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectKillCredit ( SpellEffIndex effIndex )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2010-04-07 19:14:10 +02:00
if ( ! unitTarget || unitTarget -> GetTypeId () != TYPEID_PLAYER )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2011-07-26 23:09:28 +02:00
int32 creatureEntry = m_spellInfo -> Effects [ effIndex ]. MiscValue ;
2010-04-07 19:14:10 +02:00
if ( ! creatureEntry )
2009-05-05 12:27:11 -05:00
{
2010-04-07 19:14:10 +02:00
if ( m_spellInfo -> Id == 42793 ) // Burn Body
2009-05-05 12:27:11 -05:00
creatureEntry = 24008 ; // Fallen Combatant
}
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( creatureEntry )
2010-03-07 15:20:19 +01:00
unitTarget -> ToPlayer () -> RewardPlayerAndGroupAtEvent ( creatureEntry , unitTarget );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectQuestFail ( SpellEffIndex effIndex )
2008-10-11 14:16:25 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2010-04-07 19:14:10 +02:00
if ( ! unitTarget || unitTarget -> GetTypeId () != TYPEID_PLAYER )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2011-07-26 23:09:28 +02:00
unitTarget -> ToPlayer () -> FailQuest ( m_spellInfo -> Effects [ effIndex ]. MiscValue );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectQuestStart ( SpellEffIndex effIndex )
2010-07-20 16:11:49 +02:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2010-07-20 16:11:49 +02:00
if ( ! unitTarget || unitTarget -> GetTypeId () != TYPEID_PLAYER )
return ;
2011-06-11 22:35:29 +02:00
Player * player = unitTarget -> ToPlayer ();
2011-07-26 23:09:28 +02:00
if ( Quest const * qInfo = sObjectMgr -> GetQuestTemplate ( m_spellInfo -> Effects [ effIndex ]. MiscValue ))
2010-07-20 16:11:49 +02:00
{
if ( player -> CanTakeQuest ( qInfo , false ) && player -> CanAddQuest ( qInfo , false ))
{
player -> AddQuest ( qInfo , NULL );
}
}
}
2010-08-27 19:36:27 +02:00
void Spell :: EffectActivateRune ( SpellEffIndex effIndex )
2008-12-24 09:58:26 -06:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_LAUNCH )
return ;
2010-04-07 19:14:10 +02:00
if ( m_caster -> GetTypeId () != TYPEID_PLAYER )
2008-12-24 09:58:26 -06:00
return ;
2009-10-17 15:51:44 -07:00
2011-11-07 11:06:39 -06:00
Player * player = m_caster -> ToPlayer ();
2009-10-17 15:51:44 -07:00
2011-11-07 11:06:39 -06:00
if ( player -> getClass () != CLASS_DEATH_KNIGHT )
2008-12-24 09:58:26 -06:00
return ;
2009-10-17 15:51:44 -07:00
2010-01-23 16:06:06 +01:00
// needed later
2010-03-07 15:20:19 +01:00
m_runesState = m_caster -> ToPlayer () -> GetRunesState ();
2010-01-23 16:06:06 +01:00
uint32 count = damage ;
if ( count == 0 ) count = 1 ;
2010-04-07 19:12:44 +02:00
for ( uint32 j = 0 ; j < MAX_RUNES && count > 0 ; ++ j )
2008-12-24 09:58:26 -06:00
{
2011-11-07 11:06:39 -06:00
if ( player -> GetRuneCooldown ( j ) && player -> GetCurrentRune ( j ) == RuneType ( m_spellInfo -> Effects [ effIndex ]. MiscValue ))
2008-12-24 09:58:26 -06:00
{
2012-01-04 11:50:31 -05:00
if ( m_spellInfo -> Id == 45529 )
if ( player -> GetBaseRune ( j ) != RuneType ( m_spellInfo -> Effects [ effIndex ]. MiscValueB ))
continue ;
2011-11-07 11:06:39 -06:00
player -> SetRuneCooldown ( j , 0 );
2010-01-23 16:06:06 +01:00
-- count ;
}
}
2012-01-04 11:50:31 -05:00
// Blood Tap
if ( m_spellInfo -> Id == 45529 && count > 0 )
{
for ( uint32 l = 0 ; l < MAX_RUNES && count > 0 ; ++ l )
{
// Check if both runes are on cd as that is the only time when this needs to come into effect
if (( player -> GetRuneCooldown ( l ) && player -> GetCurrentRune ( l ) == RuneType ( m_spellInfo -> Effects [ effIndex ]. MiscValueB )) && ( player -> GetRuneCooldown ( l + 1 ) && player -> GetCurrentRune ( l + 1 ) == RuneType ( m_spellInfo -> Effects [ effIndex ]. MiscValueB )))
{
// Should always update the rune with the lowest cd
if ( player -> GetRuneCooldown ( l ) >= player -> GetRuneCooldown ( l + 1 ))
l ++ ;
player -> SetRuneCooldown ( l , 0 );
-- count ;
// is needed to push through to the client that the rune is active
player -> ResyncRunes ( MAX_RUNES );
}
else
break ;
}
}
2010-01-23 16:06:06 +01:00
// Empower rune weapon
if ( m_spellInfo -> Id == 47568 )
{
// Need to do this just once
2010-08-27 19:36:27 +02:00
if ( effIndex != 0 )
2010-01-23 16:06:06 +01:00
return ;
2010-04-07 19:12:44 +02:00
for ( uint32 i = 0 ; i < MAX_RUNES ; ++ i )
2010-01-23 16:06:06 +01:00
{
2011-11-07 11:06:39 -06:00
if ( player -> GetRuneCooldown ( i ) && ( player -> GetCurrentRune ( i ) == RUNE_FROST || player -> GetCurrentRune ( i ) == RUNE_DEATH ))
player -> SetRuneCooldown ( i , 0 );
2008-12-24 09:58:26 -06:00
}
}
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectCreateTamedPet ( SpellEffIndex effIndex )
2010-07-20 22:55:28 +02:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2010-07-20 22:55:28 +02:00
if ( ! unitTarget || unitTarget -> GetTypeId () != TYPEID_PLAYER || unitTarget -> GetPetGUID () || unitTarget -> getClass () != CLASS_HUNTER )
return ;
2011-07-26 23:09:28 +02:00
uint32 creatureEntry = m_spellInfo -> Effects [ effIndex ]. MiscValue ;
2011-06-20 04:04:20 +07:00
Pet * pet = unitTarget -> CreateTamedPetFrom ( creatureEntry , m_spellInfo -> Id );
2010-07-20 22:55:28 +02:00
if ( ! pet )
return ;
// add to world
2011-10-10 17:39:34 -04:00
pet -> GetMap () -> AddToMap ( pet -> ToCreature ());
2010-07-20 22:55:28 +02:00
// unitTarget has pet now
unitTarget -> SetMinion ( pet , true );
pet -> InitTalentForLevel ();
if ( unitTarget -> GetTypeId () == TYPEID_PLAYER )
{
pet -> SavePetToDB ( PET_SAVE_AS_CURRENT );
unitTarget -> ToPlayer () -> PetSpellInitialize ();
}
}
2010-08-27 19:36:27 +02:00
void Spell :: EffectDiscoverTaxi ( SpellEffIndex effIndex )
2010-07-20 18:27:18 +02:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2010-07-20 18:27:18 +02:00
if ( ! unitTarget || unitTarget -> GetTypeId () != TYPEID_PLAYER )
return ;
2011-07-26 23:09:28 +02:00
uint32 nodeid = m_spellInfo -> Effects [ effIndex ]. MiscValue ;
2010-07-20 18:27:18 +02:00
if ( sTaxiNodesStore . LookupEntry ( nodeid ))
unitTarget -> ToPlayer () -> GetSession () -> SendDiscoverNewTaxiNode ( nodeid );
}
2010-08-27 19:36:27 +02:00
void Spell :: EffectTitanGrip ( SpellEffIndex /*effIndex*/ )
2008-12-24 09:58:26 -06:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT )
return ;
if ( m_caster -> GetTypeId () == TYPEID_PLAYER )
m_caster -> ToPlayer () -> SetCanTitanGrip ( true );
2008-12-24 09:58:26 -06:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectRedirectThreat ( SpellEffIndex /*effIndex*/ )
2008-12-17 20:07:25 -06:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2010-04-07 19:14:10 +02:00
if ( unitTarget )
2008-12-17 20:07:25 -06:00
m_caster -> SetReducedThreatPercent (( uint32 ) damage , unitTarget -> GetGUID ());
2009-01-06 15:48:42 -06:00
}
2009-10-17 15:51:44 -07:00
2011-07-22 21:22:05 +02:00
void Spell :: EffectGameObjectDamage ( SpellEffIndex /*effIndex*/ )
2009-05-21 10:01:03 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2011-07-22 21:22:05 +02:00
if ( ! gameObjTarget )
return ;
2009-10-17 15:51:44 -07:00
2011-07-22 21:22:05 +02:00
Unit * caster = m_originalCaster ;
if ( ! caster )
return ;
2010-10-19 13:15:47 +02:00
2011-07-22 21:22:05 +02:00
FactionTemplateEntry const * casterFaction = caster -> getFactionTemplateEntry ();
FactionTemplateEntry const * targetFaction = sFactionTemplateStore . LookupEntry ( gameObjTarget -> GetUInt32Value ( GAMEOBJECT_FACTION ));
// Do not allow to damage GO's of friendly factions (ie: Wintergrasp Walls/Ulduar Storm Beacons)
if (( casterFaction && targetFaction && ! casterFaction -> IsFriendlyTo ( * targetFaction )) || ! targetFaction )
gameObjTarget -> ModifyHealth ( - damage , caster , GetSpellInfo () -> Id );
2009-05-21 10:01:03 -05:00
}
2009-10-17 15:51:44 -07:00
2011-07-22 21:22:05 +02:00
void Spell :: EffectGameObjectRepair ( SpellEffIndex /*effIndex*/ )
2009-05-21 10:01:03 -05:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2011-07-22 21:22:05 +02:00
if ( ! gameObjTarget )
return ;
gameObjTarget -> ModifyHealth ( damage , m_caster );
2009-05-21 10:01:03 -05:00
}
2009-10-17 15:51:44 -07:00
2011-07-22 21:22:05 +02:00
void Spell :: EffectGameObjectSetDestructionState ( SpellEffIndex effIndex )
2010-12-01 20:59:05 +02:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2011-07-22 21:22:05 +02:00
if ( ! gameObjTarget || ! m_originalCaster )
return ;
2010-12-01 20:59:05 +02:00
2011-07-22 21:22:05 +02:00
Player * player = m_originalCaster -> GetCharmerOrOwnerPlayerOrPlayerItself ();
2011-07-26 23:09:28 +02:00
gameObjTarget -> SetDestructibleState ( GameObjectDestructibleState ( m_spellInfo -> Effects [ effIndex ]. MiscValue ), player , true );
2010-12-01 20:59:05 +02:00
}
2012-02-09 20:26:30 +01:00
void Spell :: SummonGuardian ( uint32 i , uint32 entry , SummonPropertiesEntry const * properties , uint32 numGuardians )
2009-03-20 14:01:46 -06:00
{
2011-06-20 04:04:20 +07:00
Unit * caster = m_originalCaster ;
2009-11-01 17:53:07 -08:00
if ( ! caster )
2009-03-18 21:16:24 -06:00
return ;
2009-10-17 15:51:44 -07:00
2009-11-01 17:53:07 -08:00
if ( caster -> isTotem ())
2011-08-01 18:25:44 +02:00
caster = caster -> ToTotem () -> GetOwner ();
2009-10-17 15:51:44 -07:00
2009-03-20 14:01:46 -06:00
// in another case summon new
2009-11-01 17:53:07 -08:00
uint8 level = caster -> getLevel ();
2009-10-17 15:51:44 -07:00
2009-03-20 14:01:46 -06:00
// level of pet summoned using engineering item based at engineering skill level
2009-11-01 17:53:07 -08:00
if ( m_CastItem && caster -> GetTypeId () == TYPEID_PLAYER )
2011-09-15 14:08:17 +02:00
if ( ItemTemplate const * proto = m_CastItem -> GetTemplate ())
2011-11-02 19:13:51 +07:00
if ( proto -> RequiredSkill == SKILL_ENGINEERING )
if ( uint16 skill202 = caster -> ToPlayer () -> GetSkillValue ( SKILL_ENGINEERING ))
level = skill202 / 5 ;
2009-10-17 15:51:44 -07:00
2009-03-20 14:01:46 -06:00
float radius = 5.0f ;
2011-07-26 23:09:28 +02:00
int32 duration = m_spellInfo -> GetDuration ();
2012-02-10 11:32:33 +01:00
2010-04-07 19:14:10 +02:00
if ( Player * modOwner = m_originalCaster -> GetSpellModOwner ())
2009-10-15 08:34:19 -07:00
modOwner -> ApplySpellMod ( m_spellInfo -> Id , SPELLMOD_DURATION , duration );
2009-10-17 15:51:44 -07:00
2010-04-19 09:26:37 +02:00
//TempSummonType summonType = (duration == 0) ? TEMPSUMMON_DEAD_DESPAWN : TEMPSUMMON_TIMED_DESPAWN;
2011-09-15 14:08:17 +02:00
Map * map = caster -> GetMap ();
2009-10-17 15:51:44 -07:00
2012-02-09 20:26:30 +01:00
for ( uint32 count = 0 ; count < numGuardians ; ++ count )
2009-03-20 14:01:46 -06:00
{
2009-08-29 14:58:45 -05:00
Position pos ;
2012-05-30 08:01:02 +02:00
if ( count == 0 )
pos = * destTarget ;
else
// randomize position for multiple summons
m_caster -> GetRandomPoint ( * destTarget , radius , pos );
2009-10-17 15:51:44 -07:00
2011-09-15 14:08:17 +02:00
TempSummon * summon = map -> SummonCreature ( entry , pos , properties , duration , caster , m_spellInfo -> Id );
2009-11-01 17:53:07 -08:00
if ( ! summon )
2009-03-20 14:01:46 -06:00
return ;
2009-11-01 17:53:07 -08:00
if ( summon -> HasUnitTypeMask ( UNIT_MASK_GUARDIAN ))
2009-03-20 14:01:46 -06:00
(( Guardian * ) summon ) -> InitStatsForLevel ( level );
2009-10-17 15:51:44 -07:00
2011-04-27 16:22:42 +06:00
if ( properties && properties -> Category == SUMMON_CATEGORY_ALLY )
summon -> setFaction ( caster -> getFaction ());
2010-03-19 00:21:57 +01:00
if ( summon -> HasUnitTypeMask ( UNIT_MASK_MINION ) && m_targets . HasDst ())
2009-07-22 17:10:30 +02:00
(( Minion * ) summon ) -> SetFollowAngle ( m_caster -> GetAngle ( summon ));
2009-10-17 15:51:44 -07:00
2009-12-14 01:51:12 +01:00
if ( summon -> GetEntry () == 27893 )
2010-08-30 15:25:15 +02:00
{
2009-12-14 01:51:12 +01:00
if ( uint32 weapon = m_caster -> GetUInt32Value ( PLAYER_VISIBLE_ITEM_16_ENTRYID ))
{
summon -> SetDisplayId ( 11686 );
summon -> SetUInt32Value ( UNIT_VIRTUAL_ITEM_SLOT_ID , weapon );
}
else
summon -> SetDisplayId ( 1126 );
2010-08-30 15:25:15 +02:00
}
2009-12-17 12:23:01 +01:00
2009-05-12 10:11:54 -05:00
summon -> AI () -> EnterEvadeMode ();
2010-08-27 17:49:32 +02:00
ExecuteLogEffectSummonObject ( i , summon );
2009-03-20 14:01:46 -06:00
}
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectRenamePet ( SpellEffIndex /*effIndex*/ )
2009-01-22 22:44:27 -06:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2009-01-22 22:44:27 -06:00
if ( ! unitTarget || unitTarget -> GetTypeId () != TYPEID_UNIT ||
2010-03-07 18:30:53 +01:00
! unitTarget -> ToCreature () -> isPet () || (( Pet * ) unitTarget ) -> getPetType () != HUNTER_PET )
2009-01-22 22:44:27 -06:00
return ;
2009-10-17 15:51:44 -07:00
2010-11-07 22:23:12 +01:00
unitTarget -> SetByteFlag ( UNIT_FIELD_BYTES_2 , 2 , UNIT_CAN_BE_RENAMED );
2009-07-30 10:18:05 +08:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectPlayMusic ( SpellEffIndex effIndex )
2009-07-30 10:18:05 +08:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2009-11-01 17:53:07 -08:00
if ( ! unitTarget || unitTarget -> GetTypeId () != TYPEID_PLAYER )
2009-07-30 10:18:05 +08:00
return ;
2009-10-17 15:51:44 -07:00
2011-07-26 23:09:28 +02:00
uint32 soundid = m_spellInfo -> Effects [ effIndex ]. MiscValue ;
2009-10-17 15:51:44 -07:00
2009-07-30 10:18:05 +08:00
if ( ! sSoundEntriesStore . LookupEntry ( soundid ))
{
2012-08-03 14:20:18 +02:00
sLog -> outError ( LOG_FILTER_SPELLS_AURAS , "EffectPlayMusic: Sound (Id: %u) not exist in spell %u." , soundid , m_spellInfo -> Id );
2009-07-30 10:18:05 +08:00
return ;
}
2009-10-17 15:51:44 -07:00
2009-07-30 10:18:05 +08:00
WorldPacket data ( SMSG_PLAY_MUSIC , 4 );
data << uint32 ( soundid );
2012-11-02 00:17:59 +01:00
data << uint64 ( unitTarget -> GetGUID ());
2010-03-07 15:20:19 +01:00
unitTarget -> ToPlayer () -> GetSession () -> SendPacket ( & data );
2009-07-30 10:18:05 +08:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectSpecCount ( SpellEffIndex /*effIndex*/ )
2009-08-14 17:24:52 -07:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2009-11-01 17:53:07 -08:00
if ( ! unitTarget || unitTarget -> GetTypeId () != TYPEID_PLAYER )
2009-08-14 17:24:52 -07:00
return ;
2009-10-17 15:51:44 -07:00
2010-03-07 15:20:19 +01:00
unitTarget -> ToPlayer () -> UpdateSpecCount ( damage );
2009-08-14 17:24:52 -07:00
}
2009-10-17 15:51:44 -07:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectActivateSpec ( SpellEffIndex /*effIndex*/ )
2009-08-14 17:24:52 -07:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2009-11-01 17:53:07 -08:00
if ( ! unitTarget || unitTarget -> GetTypeId () != TYPEID_PLAYER )
2009-08-14 17:24:52 -07:00
return ;
2009-10-17 15:51:44 -07:00
2010-03-07 15:20:19 +01:00
unitTarget -> ToPlayer () -> ActivateSpec ( damage - 1 ); // damage is 1 or 2, spec is 0 or 1
2009-08-14 17:24:52 -07:00
}
2011-03-07 21:13:18 +01:00
void Spell :: EffectPlayerNotification ( SpellEffIndex effIndex )
2010-01-10 01:23:15 +01:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2010-01-10 01:23:15 +01:00
if ( ! unitTarget || unitTarget -> GetTypeId () != TYPEID_PLAYER )
return ;
2011-09-29 12:43:05 +02:00
switch ( m_spellInfo -> Id )
2010-01-10 01:23:15 +01:00
{
case 58730 : // Restricted Flight Area
case 58600 : // Restricted Flight Area
2010-03-11 20:51:31 +01:00
unitTarget -> ToPlayer () -> GetSession () -> SendNotification ( LANG_ZONE_NOFLYZONE );
2012-08-21 23:40:38 +01:00
unitTarget -> PlayDirectSound ( 9417 ); // Fel Reaver sound
2010-01-10 01:23:15 +01:00
break ;
}
2011-03-07 21:13:18 +01:00
2011-07-26 23:09:28 +02:00
uint32 soundid = m_spellInfo -> Effects [ effIndex ]. MiscValue ;
2011-03-07 21:13:18 +01:00
if ( ! sSoundEntriesStore . LookupEntry ( soundid ))
{
2012-08-03 14:20:18 +02:00
sLog -> outError ( LOG_FILTER_SPELLS_AURAS , "EffectPlayerNotification: Sound (Id: %u) not exist in spell %u." , soundid , m_spellInfo -> Id );
2011-03-07 21:13:18 +01:00
return ;
}
WorldPacket data ( SMSG_PLAY_SOUND , 4 );
data << uint32 ( soundid );
unitTarget -> ToPlayer () -> GetSession () -> SendPacket ( & data );
2010-01-10 01:23:15 +01:00
}
2010-08-27 19:36:27 +02:00
void Spell :: EffectRemoveAura ( SpellEffIndex effIndex )
2010-07-20 04:29:17 +02:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2010-07-20 04:29:17 +02:00
if ( ! unitTarget )
return ;
// there may be need of specifying casterguid of removed auras
2011-07-26 23:09:28 +02:00
unitTarget -> RemoveAurasDueToSpell ( m_spellInfo -> Effects [ effIndex ]. TriggerSpell );
2010-07-20 04:29:17 +02:00
}
2010-08-27 19:36:27 +02:00
void Spell :: EffectCastButtons ( SpellEffIndex effIndex )
2009-12-17 12:23:01 +01:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT )
return ;
if ( m_caster -> GetTypeId () != TYPEID_PLAYER )
2009-12-17 12:23:01 +01:00
return ;
2011-06-20 04:04:20 +07:00
Player * p_caster = m_caster -> ToPlayer ();
2011-07-26 23:09:28 +02:00
uint32 button_id = m_spellInfo -> Effects [ effIndex ]. MiscValue + 132 ;
uint32 n_buttons = m_spellInfo -> Effects [ effIndex ]. MiscValueB ;
2009-12-17 12:23:01 +01:00
2011-08-03 08:18:24 +02:00
for (; n_buttons ; -- n_buttons , ++ button_id )
2009-12-17 12:23:01 +01:00
{
2010-04-28 16:08:31 +02:00
ActionButton const * ab = p_caster -> GetActionButton ( button_id );
2010-04-29 11:35:31 +02:00
if ( ! ab || ab -> GetType () != ACTION_BUTTON_SPELL )
continue ;
2009-12-17 12:23:01 +01:00
2011-09-05 15:21:37 +02:00
//! Action button data is unverified when it's set so it can be "hacked"
2011-07-31 14:10:47 +02:00
//! to contain invalid spells, so filter here.
2010-04-28 16:08:31 +02:00
uint32 spell_id = ab -> GetAction ();
if ( ! spell_id )
continue ;
2011-09-15 14:08:17 +02:00
SpellInfo const * spellInfo = sSpellMgr -> GetSpellInfo ( spell_id );
2011-07-31 14:10:47 +02:00
if ( ! spellInfo )
2010-04-28 16:08:31 +02:00
continue ;
2009-12-17 12:23:01 +01:00
2011-07-31 14:10:47 +02:00
if ( ! p_caster -> HasSpell ( spell_id ) || p_caster -> HasSpellCooldown ( spell_id ))
continue ;
2012-11-12 12:07:16 +01:00
if ( ! ( spellInfo -> AttributesEx9 & SPELL_ATTR9_SUMMON_PLAYER_TOTEM ))
2011-07-31 14:10:47 +02:00
continue ;
2011-09-05 14:01:50 +02:00
2011-11-25 18:54:59 +01:00
int32 cost = spellInfo -> CalcPowerCost ( m_caster , spellInfo -> GetSchoolMask ());
2010-04-28 16:08:31 +02:00
if ( m_caster -> GetPower ( POWER_MANA ) < cost )
2011-07-31 19:03:06 +02:00
continue ;
2009-12-17 12:23:01 +01:00
2011-07-31 23:47:11 +02:00
TriggerCastFlags triggerFlags = TriggerCastFlags ( TRIGGERED_IGNORE_GCD | TRIGGERED_IGNORE_CAST_IN_PROGRESS | TRIGGERED_CAST_DIRECTLY );
2011-09-25 13:29:17 +02:00
m_caster -> CastSpell ( m_caster , spell_id , triggerFlags );
2009-12-17 12:23:01 +01:00
}
}
2009-12-26 18:25:49 +01:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectRechargeManaGem ( SpellEffIndex /*effIndex*/ )
2009-12-26 18:25:49 +01:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2010-04-07 19:14:10 +02:00
if ( ! unitTarget || unitTarget -> GetTypeId () != TYPEID_PLAYER )
2009-12-26 18:25:49 +01:00
return ;
2011-06-12 01:47:45 +02:00
Player * player = m_caster -> ToPlayer ();
2009-12-26 18:25:49 +01:00
if ( ! player )
return ;
2011-07-26 23:09:28 +02:00
uint32 item_id = m_spellInfo -> Effects [ EFFECT_0 ]. ItemType ;
2009-12-26 18:25:49 +01:00
2011-09-15 14:08:17 +02:00
ItemTemplate const * pProto = sObjectMgr -> GetItemTemplate ( item_id );
2010-04-07 19:14:10 +02:00
if ( ! pProto )
2009-12-26 18:25:49 +01:00
{
2010-04-07 22:59:46 +02:00
player -> SendEquipError ( EQUIP_ERR_ITEM_NOT_FOUND , NULL , NULL );
2009-12-26 18:25:49 +01:00
return ;
}
if ( Item * pItem = player -> GetItemByEntry ( item_id ))
{
2010-04-07 19:12:44 +02:00
for ( int x = 0 ; x < MAX_ITEM_PROTO_SPELLS ; ++ x )
2011-04-29 20:47:02 +02:00
pItem -> SetSpellCharges ( x , pProto -> Spells [ x ]. SpellCharges );
pItem -> SetState ( ITEM_CHANGED , player );
2009-12-26 18:25:49 +01:00
}
}
2010-04-18 23:20:07 +02:00
2010-08-27 19:36:27 +02:00
void Spell :: EffectBind ( SpellEffIndex effIndex )
2010-04-18 23:20:07 +02:00
{
2011-09-25 13:29:17 +02:00
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2010-04-18 23:20:07 +02:00
if ( ! unitTarget || unitTarget -> GetTypeId () != TYPEID_PLAYER )
return ;
2010-12-03 13:54:00 +01:00
Player * player = unitTarget -> ToPlayer ();
2010-04-18 23:20:07 +02:00
2012-12-08 23:46:16 +01:00
WorldLocation homeLoc ;
uint32 areaId = player -> GetAreaId ();
2010-04-18 23:20:07 +02:00
2012-12-08 23:46:16 +01:00
if ( m_spellInfo -> Effects [ effIndex ]. MiscValue )
areaId = m_spellInfo -> Effects [ effIndex ]. MiscValue ;
if ( m_targets . HasDst ())
homeLoc . WorldRelocate ( * destTarget );
2010-04-18 23:20:07 +02:00
else
{
2012-12-08 23:46:16 +01:00
player -> GetPosition ( & homeLoc );
homeLoc . m_mapId = player -> GetMapId ();
2010-04-18 23:20:07 +02:00
}
2012-12-08 23:46:16 +01:00
player -> SetHomebind ( homeLoc , areaId );
2010-04-18 23:20:07 +02:00
// binding
2010-12-03 13:54:00 +01:00
WorldPacket data ( SMSG_BINDPOINTUPDATE , ( 4 + 4 + 4 + 4 + 4 ));
2012-12-08 23:46:16 +01:00
data << float ( homeLoc . GetPositionX ());
data << float ( homeLoc . GetPositionY ());
data << float ( homeLoc . GetPositionZ ());
data << uint32 ( homeLoc . GetMapId ());
data << uint32 ( areaId );
2010-12-03 13:54:00 +01:00
player -> SendDirectMessage ( & data );
2010-04-18 23:20:07 +02:00
2012-12-08 23:46:16 +01:00
sLog -> outDebug ( LOG_FILTER_SPELLS_AURAS , "EffectBind: New homebind X: %f, Y: %f, Z: %f, MapId: %u, AreaId: %u" ,
homeLoc . GetPositionX (), homeLoc . GetPositionY (), homeLoc . GetPositionZ (), homeLoc . GetMapId (), areaId );
2010-04-18 23:20:07 +02:00
// zone update
data . Initialize ( SMSG_PLAYERBOUND , 8 + 4 );
data << uint64 ( player -> GetGUID ());
2012-12-08 23:46:16 +01:00
data << uint32 ( areaId );
2011-06-12 02:30:32 +02:00
player -> SendDirectMessage ( & data );
2010-04-18 23:20:07 +02:00
}
2011-08-03 09:28:12 -07:00
2011-09-25 13:29:17 +02:00
void Spell :: EffectSummonRaFFriend ( SpellEffIndex effIndex )
{
if ( effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET )
return ;
2011-08-03 09:28:12 -07:00
2011-08-04 13:16:09 +02:00
if ( m_caster -> GetTypeId () != TYPEID_PLAYER || ! unitTarget || unitTarget -> GetTypeId () != TYPEID_PLAYER )
2011-08-03 09:28:12 -07:00
return ;
2011-08-03 15:21:08 -07:00
m_caster -> CastSpell ( unitTarget , m_spellInfo -> Effects [ effIndex ]. TriggerSpell , true );
2011-08-03 09:28:12 -07:00
}