diff options
46 files changed, 1576 insertions, 425 deletions
diff --git a/sql/updates/world/2013_07_23_00_world_misc.sql b/sql/updates/world/2013_07_23_00_world_misc.sql new file mode 100644 index 00000000000..8e69c7bb785 --- /dev/null +++ b/sql/updates/world/2013_07_23_00_world_misc.sql @@ -0,0 +1,7 @@ +UPDATE `gameobject_template` SET `flags`=48, `ScriptName`='go_activation_crystal' WHERE `entry`=193611; + +UPDATE `creature_template` SET `flags_extra`=130, `ScriptName`='npc_violet_hold_arcane_sphere' WHERE `entry`=30837; + +DELETE FROM `conditions` WHERE `SourceTypeOrReferenceId`=13 AND `SourceGroup`=1 AND `SourceEntry`=57930; +INSERT INTO `conditions` (`SourceTypeOrReferenceId`, `SourceGroup`, `SourceEntry`, `SourceId`, `ElseGroup`, `ConditionTypeOrReference`, `ConditionTarget`, `ConditionValue1`, `ConditionValue2`, `ConditionValue3`, `NegativeCondition`, `ErrorType`, `ErrorTextId`, `ScriptName`, `Comment`) VALUES +(13, 1, 57930, 0, 0, 32, 0, 16, 0, 0, 1, 0, 0, '', 'Spell Arcane Lightning hit players'); diff --git a/sql/updates/world/2013_07_23_02_world_creature_template.sql b/sql/updates/world/2013_07_23_02_world_creature_template.sql new file mode 100644 index 00000000000..b55999040f1 --- /dev/null +++ b/sql/updates/world/2013_07_23_02_world_creature_template.sql @@ -0,0 +1 @@ +UPDATE `creature_template` SET `InhabitType` = 5 WHERE `entry` = 10184; diff --git a/sql/updates/world/2013_07_24_00_world_spell_script_names.sql b/sql/updates/world/2013_07_24_00_world_spell_script_names.sql new file mode 100644 index 00000000000..8c156fb2e57 --- /dev/null +++ b/sql/updates/world/2013_07_24_00_world_spell_script_names.sql @@ -0,0 +1,11 @@ +DELETE FROM `spell_script_names` WHERE `spell_id` IN (63310,50421,23780,33896,37594,37705,23551,23552,23572); +INSERT INTO `spell_script_names`(`spell_id`, `ScriptName`) VALUES +(63310,'spell_warl_glyph_of_shadowflame'), +(50421,'spell_dk_scent_of_blood'), +(23780,'spell_item_aegis_of_preservation'), +(33896,'spell_item_desperate_defense'), +(37594,'spell_pri_item_greater_heal_refund'), +(37705,'spell_pal_item_healing_discount'), +(23551,'spell_sha_item_lightning_shield'), +(23552,'spell_sha_item_lightning_shield_trigger'), +(23572,'spell_sha_item_mana_surge'); diff --git a/sql/updates/world/2013_07_24_01_world_spell_ranks.sql b/sql/updates/world/2013_07_24_01_world_spell_ranks.sql new file mode 100644 index 00000000000..db1d9803596 --- /dev/null +++ b/sql/updates/world/2013_07_24_01_world_spell_ranks.sql @@ -0,0 +1,682 @@ +DELETE FROM `spell_ranks` WHERE `first_spell_id` IN ( +5923, +5952, +9452, +9453, +9799, +11069, +11070, +11071, +11078, +11083, +11094, +11095, +11100, +11103, +11108, +11115, +11119, +11124, +11151, +11160, +11170, +11175, +11180, +11185, +11189, +11190, +11207, +11210, +11213, +11222, +11232, +11237, +11242, +11247, +11252, +11255, +12163, +12281, +12282, +12284, +12285, +12286, +12287, +12289, +12290, +12295, +12297, +12298, +12299, +12300, +12301, +12308, +12311, +12312, +12313, +12317, +12318, +12319, +12320, +12321, +12322, +12324, +12329, +12700, +12797, +12834, +12862, +13705, +13706, +13709, +13712, +13713, +13715, +13732, +13733, +13741, +13742, +13743, +13754, +13958, +13960, +13975, +13976, +13981, +13983, +14057, +14076, +14079, +14082, +14113, +14128, +14138, +14144, +14156, +14158, +14162, +14165, +14168, +14171, +14174, +14179, +14186, +14520, +14521, +14522, +14523, +14531, +14747, +14748, +14749, +14750, +14889, +14892, +14898, +14901, +14908, +14909, +14910, +14911, +14912, +14913, +15058, +15257, +15259, +15260, +15270, +15273, +15274, +15275, +15318, +15337, +15392, +16035, +16038, +16039, +16040, +16043, +16086, +16089, +16173, +16176, +16178, +16179, +16180, +16181, +16182, +16184, +16187, +16194, +16252, +16254, +16255, +16256, +16258, +16259, +16261, +16262, +16266, +16462, +16487, +16493, +16513, +16538, +16578, +16757, +16814, +16819, +16821, +16833, +16836, +16845, +16850, +16858, +16880, +16896, +16909, +16929, +16934, +16940, +16942, +16947, +16966, +16972, +16998, +17002, +17003, +17050, +17056, +17063, +17069, +17074, +17104, +17106, +17111, +17118, +17123, +17322, +17485, +17778, +17783, +17788, +17793, +17804, +17810, +17815, +17917, +17927, +17954, +17959, +18094, +18096, +18119, +18126, +18135, +18174, +18179, +18182, +18213, +18218, +18271, +18427, +18459, +18462, +18530, +18551, +18692, +18694, +18697, +18703, +18705, +18709, +18731, +18754, +18767, +18769, +18827, +19159, +19168, +19184, +19255, +19286, +19290, +19295, +19370, +19376, +19407, +19416, +19421, +19426, +19454, +19461, +19464, +19485, +19498, +19507, +19549, +19552, +19559, +19572, +19578, +19583, +19590, +19598, +19609, +19616, +19621, +20042, +20049, +20060, +20096, +20101, +20111, +20117, +20127, +20138, +20143, +20174, +20177, +20196, +20205, +20210, +20224, +20234, +20237, +20244, +20254, +20257, +20262, +20335, +20359, +20468, +20487, +20500, +20502, +20504, +23584, +23785, +24443, +24968, +25956, +26022, +27789, +27811, +27839, +27900, +28574, +28996, +28999, +29062, +29074, +29082, +29140, +29187, +29192, +29206, +29438, +29441, +29447, +29590, +29593, +29598, +29721, +29723, +29759, +29787, +29834, +29836, +29888, +30054, +30060, +30143, +30160, +30242, +30288, +30293, +30299, +30319, +30664, +30672, +30675, +30802, +30812, +30816, +30864, +30867, +30872, +30881, +30892, +30894, +30902, +30919, +31122, +31124, +31130, +31208, +31211, +31216, +31221, +31226, +31228, +31234, +31244, +31380, +31569, +31571, +31574, +31579, +31584, +31638, +31641, +31656, +31667, +31670, +31674, +31679, +31682, +31785, +31822, +31825, +31828, +31833, +31837, +31844, +31848, +31850, +31858, +31866, +31871, +31876, +31879, +32043, +32381, +32385, +32477, +33142, +33150, +33158, +33167, +33186, +33191, +33201, +33213, +33221, +33589, +33592, +33597, +33600, +33603, +33851, +33853, +33859, +33872, +33879, +33881, +33886, +34151, +34293, +34297, +34453, +34455, +34462, +34466, +34475, +34482, +34485, +34491, +34494, +34497, +34500, +34506, +34753, +34908, +34935, +34948, +34950, +35029, +35100, +35104, +35363, +35446, +35541, +35578, +35691, +37116, +44378, +44394, +44397, +44400, +44404, +44442, +44445, +44449, +44543, +44546, +44557, +44566, +44745, +45234, +46854, +46859, +46865, +46867, +46908, +46910, +46913, +46945, +46951, +47195, +47198, +47201, +47220, +47230, +47236, +47245, +47258, +47266, +47294, +47507, +47509, +47516, +47535, +47558, +47562, +47569, +47573, +47580, +47586, +48384, +48389, +48409, +48411, +48432, +48483, +48488, +48492, +48496, +48506, +48516, +48532, +48535, +48539, +48962, +48963, +48965, +48977, +48978, +48979, +48985, +48987, +48988, +48997, +49004, +49006, +49013, +49015, +49018, +49023, +49024, +49027, +49032, +49036, +49042, +49137, +49140, +49145, +49146, +49149, +49175, +49182, +49186, +49188, +49189, +49200, +49202, +49208, +49217, +49219, +49220, +49223, +49224, +49226, +49455, +49467, +49471, +49588, +50040, +50117, +50187, +50365, +50384, +50391, +50685, +50880, +51099, +51123, +51179, +51459, +51466, +51468, +51474, +51480, +51483, +51521, +51523, +51525, +51528, +51554, +51556, +51560, +51562, +51625, +51627, +51632, +51634, +51664, +51672, +51682, +51685, +51692, +51698, +51708, +51745, +51883, +52234, +52783, +52795, +53137, +53175, +53178, +53180, +53182, +53186, +53203, +53215, +53221, +53228, +53234, +53241, +53252, +53256, +53262, +53290, +53295, +53298, +53302, +53375, +53379, +53380, +53409, +53427, +53450, +53481, +53483, +53486, +53501, +53511, +53514, +53527, +53551, +53554, +53556, +53569, +53583, +53590, +53620, +53660, +53671, +53695, +53709, +53754, +54037, +54117, +54347, +54639, +54747, +55061, +55091, +55107, +55129, +55620, +55666, +56314, +56333, +56339, +56342, +56636, +56927, +57470, +57810, +57849, +57873, +57878, +58414, +58872, +59088, +61154, +61216, +61680, +61682, +61686, +61689, +62097, +62758, +62759, +62764, +62905, +63117, +63156, +63349, +63370, +63373, +63410, +63504, +63534, +63625, +63646, +63730, +64127, +64353, +65661, +66799); diff --git a/sql/updates/world/2013_07_24_02_world_trinity_strings.sql b/sql/updates/world/2013_07_24_02_world_trinity_strings.sql new file mode 100644 index 00000000000..b14e60c2c9d --- /dev/null +++ b/sql/updates/world/2013_07_24_02_world_trinity_strings.sql @@ -0,0 +1,3 @@ +DELETE FROM `trinity_string` WHERE entry = 850; +INSERT INTO `trinity_string` (entry, content_default, content_loc1, content_loc2, content_loc3, content_loc4, content_loc5, content_loc6, content_loc7, content_loc8) VALUES +(850, '├─ Rank: %s (ID: %u)', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); diff --git a/src/server/game/AI/CoreAI/PetAI.cpp b/src/server/game/AI/CoreAI/PetAI.cpp index 2a13e5c71bf..4d657ec2b2b 100644 --- a/src/server/game/AI/CoreAI/PetAI.cpp +++ b/src/server/game/AI/CoreAI/PetAI.cpp @@ -260,15 +260,15 @@ void PetAI::UpdateAI(uint32 diff) void PetAI::UpdateAllies() { - Unit* owner = me->GetCharmerOrOwner(); - Group* group = NULL; - - m_updateAlliesTimer = 10*IN_MILLISECONDS; //update friendly targets every 10 seconds, lesser checks increase performance + m_updateAlliesTimer = 10 * IN_MILLISECONDS; // update friendly targets every 10 seconds, lesser checks increase performance + Unit* owner = me->GetCharmerOrOwner(); if (!owner) return; - else if (owner->GetTypeId() == TYPEID_PLAYER) - group = owner->ToPlayer()->GetGroup(); + + Group* group = NULL; + if (Player* player = owner->ToPlayer()) + group = player->GetGroup(); //only pet and owner/not in group->ok if (m_AllySet.size() == 2 && !group) @@ -285,7 +285,7 @@ void PetAI::UpdateAllies() for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next()) { Player* Target = itr->GetSource(); - if (!Target || !group->SameSubGroup((Player*)owner, Target)) + if (!Target || !group->SameSubGroup(owner->ToPlayer(), Target)) continue; if (Target->GetGUID() == owner->GetGUID()) diff --git a/src/server/game/AI/CoreAI/TotemAI.cpp b/src/server/game/AI/CoreAI/TotemAI.cpp index d8644c50b35..bc865b8b6aa 100644 --- a/src/server/game/AI/CoreAI/TotemAI.cpp +++ b/src/server/game/AI/CoreAI/TotemAI.cpp @@ -98,12 +98,14 @@ void TotemAI::UpdateAI(uint32 /*diff*/) void TotemAI::AttackStart(Unit* /*victim*/) { // Sentry totem sends ping on attack - if (me->GetEntry() == SENTRY_TOTEM_ENTRY && me->GetOwner()->GetTypeId() == TYPEID_PLAYER) - { - WorldPacket data(MSG_MINIMAP_PING, (8+4+4)); - data << me->GetGUID(); - data << me->GetPositionX(); - data << me->GetPositionY(); - ((Player*)me->GetOwner())->GetSession()->SendPacket(&data); - } + if (me->GetEntry() == SENTRY_TOTEM_ENTRY) + if (Unit* owner = me->GetOwner()) + if (Player* player = owner->ToPlayer()) + { + WorldPacket data(MSG_MINIMAP_PING, (8+4+4)); + data << me->GetGUID(); + data << me->GetPositionX(); + data << me->GetPositionY(); + player->GetSession()->SendPacket(&data); + } } diff --git a/src/server/game/AI/ScriptedAI/ScriptedEscortAI.h b/src/server/game/AI/ScriptedAI/ScriptedEscortAI.h index 4a350acab2c..919b24a916c 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedEscortAI.h +++ b/src/server/game/AI/ScriptedAI/ScriptedEscortAI.h @@ -92,7 +92,7 @@ struct npc_escortAI : public ScriptedAI uint64 GetEventStarterGUID() { return m_uiPlayerGUID; } protected: - Player* GetPlayerForEscort() { return (Player*)Unit::GetUnit(*me, m_uiPlayerGUID); } + Player* GetPlayerForEscort() { return ObjectAccessor::GetPlayer(*me, m_uiPlayerGUID); } private: bool AssistPlayerInCombat(Unit* who); diff --git a/src/server/game/Battlegrounds/Battleground.cpp b/src/server/game/Battlegrounds/Battleground.cpp index 4c2fc571ee3..ca9f8f5891b 100644 --- a/src/server/game/Battlegrounds/Battleground.cpp +++ b/src/server/game/Battlegrounds/Battleground.cpp @@ -1425,6 +1425,29 @@ void Battleground::RemovePlayerFromResurrectQueue(uint64 player_guid) } } +void Battleground::RelocateDeadPlayers(uint32 queueIndex) +{ + // Those who are waiting to resurrect at this node are taken to the closest own node's graveyard + std::vector<uint64>& ghostList = m_ReviveQueue[queueIndex]; + if (!ghostList.empty()) + { + WorldSafeLocsEntry const* closestGrave = NULL; + for (std::vector<uint64>::const_iterator itr = ghostList.begin(); itr != ghostList.end(); ++itr) + { + Player* player = ObjectAccessor::FindPlayer(*itr); + if (!player) + continue; + + if (!closestGrave) + closestGrave = GetClosestGraveYard(player); + + if (closestGrave) + player->TeleportTo(GetMapId(), closestGrave->x, closestGrave->y, closestGrave->z, player->GetOrientation()); + } + ghostList.clear(); + } +} + bool Battleground::AddObject(uint32 type, uint32 entry, float x, float y, float z, float o, float rotation0, float rotation1, float rotation2, float rotation3, uint32 /*respawnTime*/) { // If the assert is called, means that BgObjects must be resized! diff --git a/src/server/game/Battlegrounds/Battleground.h b/src/server/game/Battlegrounds/Battleground.h index dd8fbb6710c..8bcd5d8683c 100644 --- a/src/server/game/Battlegrounds/Battleground.h +++ b/src/server/game/Battlegrounds/Battleground.h @@ -375,6 +375,9 @@ class Battleground void AddPlayerToResurrectQueue(uint64 npc_guid, uint64 player_guid); void RemovePlayerFromResurrectQueue(uint64 player_guid); + /// Relocate all players in ReviveQueue to the closest graveyard + void RelocateDeadPlayers(uint32 queueIndex); + void StartBattleground(); GameObject* GetBGObject(uint32 type); diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp index f986a52e3c9..bef0e995988 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp @@ -397,24 +397,7 @@ void BattlegroundAB::_NodeDeOccupied(uint8 node) if (node < BG_AB_DYNAMIC_NODES_COUNT)//only dynamic nodes, no start points DelCreature(node+7);//NULL checks are in DelCreature! 0-6 spirit guides - // Those who are waiting to resurrect at this node are taken to the closest own node's graveyard - std::vector<uint64> ghost_list = m_ReviveQueue[BgCreatures[node]]; - if (!ghost_list.empty()) - { - WorldSafeLocsEntry const* ClosestGrave = NULL; - for (std::vector<uint64>::const_iterator itr = ghost_list.begin(); itr != ghost_list.end(); ++itr) - { - Player* player = ObjectAccessor::FindPlayer(*itr); - if (!player) - continue; - - if (!ClosestGrave) // cache - ClosestGrave = GetClosestGraveYard(player); - - if (ClosestGrave) - player->TeleportTo(GetMapId(), ClosestGrave->x, ClosestGrave->y, ClosestGrave->z, player->GetOrientation()); - } - } + RelocateDeadPlayers(BgCreatures[node]); if (BgCreatures[node]) DelCreature(node); diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp index 5dc20ab8f07..a72b1eb4eb1 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp @@ -1049,25 +1049,8 @@ void BattlegroundAV::EventPlayerAssaultsPoint(Player* player, uint32 object) //spawning/despawning of aura SpawnBGObject(BG_AV_OBJECT_AURA_N_FIRSTAID_STATION+3*node, RESPAWN_IMMEDIATELY); //neutral aura spawn SpawnBGObject(BG_AV_OBJECT_AURA_A_FIRSTAID_STATION+GetTeamIndexByTeamId(owner)+3*node, RESPAWN_ONE_DAY); //teeamaura despawn - // Those who are waiting to resurrect at this object are taken to the closest own object's graveyard - std::vector<uint64> ghost_list = m_ReviveQueue[BgCreatures[node]]; - if (!ghost_list.empty()) - { - Player* waitingPlayer; // player waiting at graveyard for resurrection - WorldSafeLocsEntry const* closestGrave = NULL; - for (std::vector<uint64>::iterator itr = ghost_list.begin(); itr != ghost_list.end(); ++itr) - { - waitingPlayer = ObjectAccessor::FindPlayer(*ghost_list.begin()); - if (!waitingPlayer) - continue; - - if (!closestGrave) - closestGrave = GetClosestGraveYard(waitingPlayer); - else - waitingPlayer->TeleportTo(GetMapId(), closestGrave->x, closestGrave->y, closestGrave->z, player->GetOrientation()); - } - m_ReviveQueue[BgCreatures[node]].clear(); - } + + RelocateDeadPlayers(BgCreatures[node]); } DePopulateNode(node); } diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp index 983c690523e..d9708ac5d84 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp @@ -481,28 +481,6 @@ void BattlegroundIC::EndBattleground(uint32 winner) Battleground::EndBattleground(winner); } -void BattlegroundIC::RealocatePlayers(ICNodePointType nodeType) -{ - // Those who are waiting to resurrect at this node are taken to the closest own node's graveyard - std::vector<uint64> ghost_list = m_ReviveQueue[BgCreatures[BG_IC_NPC_SPIRIT_GUIDE_1+nodeType-2]]; - if (!ghost_list.empty()) - { - WorldSafeLocsEntry const* ClosestGrave = NULL; - for (std::vector<uint64>::const_iterator itr = ghost_list.begin(); itr != ghost_list.end(); ++itr) - { - Player* player = ObjectAccessor::FindPlayer(*itr); - if (!player) - continue; - - if (!ClosestGrave) // cache - ClosestGrave = GetClosestGraveYard(player); - - if (ClosestGrave) - player->TeleportTo(GetMapId(), ClosestGrave->x, ClosestGrave->y, ClosestGrave->z, player->GetOrientation()); - } - } -} - void BattlegroundIC::EventPlayerClickedOnFlag(Player* player, GameObject* target_obj) { if (GetStatus() != STATUS_IN_PROGRESS) @@ -531,7 +509,7 @@ void BattlegroundIC::EventPlayerClickedOnFlag(Player* player, GameObject* target nodePoint[i].timer = BANNER_STATE_CHANGE_TIME; // 1 minute for last change (real faction banner) nodePoint[i].needChange = true; - RealocatePlayers(nodePoint[i].nodeType); + RelocateDeadPlayers(BgCreatures[BG_IC_NPC_SPIRIT_GUIDE_1 + nodePoint[i].nodeType - 2]); // if we are here means that the point has been lost, or it is the first capture diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundIC.h b/src/server/game/Battlegrounds/Zones/BattlegroundIC.h index 7845c002155..f25fbe297b3 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundIC.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundIC.h @@ -950,7 +950,6 @@ class BattlegroundIC : public Battleground return uws; } - void RealocatePlayers(ICNodePointType nodeType); void UpdateNodeWorldState(ICNodePoint* nodePoint); void HandleCapturedNodes(ICNodePoint* nodePoint, bool recapture); void HandleContestedNodes(ICNodePoint* nodePoint); diff --git a/src/server/game/Entities/Pet/Pet.cpp b/src/server/game/Entities/Pet/Pet.cpp index 729a5466fe3..4c8d48222e5 100644 --- a/src/server/game/Entities/Pet/Pet.cpp +++ b/src/server/game/Entities/Pet/Pet.cpp @@ -372,7 +372,7 @@ void Pet::SavePetToDB(PetSaveMode mode) if (!IS_PLAYER_GUID(GetOwnerGUID())) return; - Player* owner = (Player*)GetOwner(); + Player* owner = GetOwner(); if (!owner) return; @@ -1142,7 +1142,7 @@ void Pet::_LoadSpellCooldowns() while (result->NextRow()); if (!m_CreatureSpellCooldowns.empty() && GetOwner()) - ((Player*)GetOwner())->GetSession()->SendPacket(&data); + GetOwner()->GetSession()->SendPacket(&data); } } diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 358f9417258..8f1669910e7 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -22725,8 +22725,8 @@ void Player::resetSpells(bool myClassOnly) continue; // skip spells with first rank learned as talent (and all talents then also) - uint32 first_rank = sSpellMgr->GetFirstSpellInChain(spellInfo->Id); - if (GetTalentSpellCost(first_rank) > 0) + uint32 firstRank = spellInfo->GetFirstRankSpell()->Id; + if (GetTalentSpellCost(firstRank) > 0) continue; // skip broken spells @@ -22796,15 +22796,14 @@ void Player::learnQuestRewardedSpells(Quest const* quest) uint32 learned_0 = spellInfo->Effects[0].TriggerSpell; if (sSpellMgr->GetSpellRank(learned_0) > 1 && !HasSpell(learned_0)) { - // not have first rank learned (unlearned prof?) - uint32 first_spell = sSpellMgr->GetFirstSpellInChain(learned_0); - if (!HasSpell(first_spell)) - return; - SpellInfo const* learnedInfo = sSpellMgr->GetSpellInfo(learned_0); if (!learnedInfo) return; + // not have first rank learned (unlearned prof?) + if (!HasSpell(learnedInfo->GetFirstRankSpell()->Id)) + return; + SpellsRequiringSpellMapBounds spellsRequired = sSpellMgr->GetSpellsRequiredForSpellBounds(learned_0); for (SpellsRequiringSpellMap::const_iterator itr2 = spellsRequired.first; itr2 != spellsRequired.second; ++itr2) { diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 021b86d4b51..0b660c1bb9a 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -5733,12 +5733,6 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere } switch (dummySpell->Id) { - // Glyph of Shadowflame - case 63310: - { - triggered_spell_id = 63311; - break; - } // Nightfall case 18094: case 18095: @@ -7712,12 +7706,6 @@ bool Unit::HandleProcTriggerSpell(Unit* victim, uint32 damage, AuraEffect* trigg case SPELLFAMILY_GENERIC: switch (auraSpellInfo->Id) { - case 23780: // Aegis of Preservation (Aegis of Preservation trinket) - trigger_spell_id = 23781; - break; - case 33896: // Desperate Defense (Stonescythe Whelp, Stonescythe Alpha, Stonescythe Ambusher) - trigger_spell_id = 33898; - break; case 43820: // Charm of the Witch Doctor (Amani Charm of the Witch Doctor trinket) // Pct value stored in dummy basepoints0 = victim->GetCreateHealth() * auraSpellInfo->Effects[1].CalcValue() / 100; @@ -7800,14 +7788,6 @@ bool Unit::HandleProcTriggerSpell(Unit* victim, uint32 damage, AuraEffect* trigg } } break; - case SPELLFAMILY_WARRIOR: - if (auraSpellInfo->Id == 50421) // Scent of Blood - { - CastSpell(this, 50422, true); - RemoveAuraFromStack(auraSpellInfo->Id); - return false; - } - break; case SPELLFAMILY_WARLOCK: { // Drain Soul @@ -7853,11 +7833,8 @@ bool Unit::HandleProcTriggerSpell(Unit* victim, uint32 damage, AuraEffect* trigg } case SPELLFAMILY_PRIEST: { - // Greater Heal Refund - if (auraSpellInfo->Id == 37594) - trigger_spell_id = 37595; // Blessed Recovery - else if (auraSpellInfo->SpellIconID == 1875) + if (auraSpellInfo->SpellIconID == 1875) { switch (auraSpellInfo->Id) { @@ -7949,13 +7926,6 @@ bool Unit::HandleProcTriggerSpell(Unit* victim, uint32 damage, AuraEffect* trigg { switch (auraSpellInfo->Id) { - // Healing Discount - case 37705: - { - trigger_spell_id = 37706; - target = this; - break; - } // Soul Preserver case 60510: { @@ -8062,29 +8032,6 @@ bool Unit::HandleProcTriggerSpell(Unit* victim, uint32 damage, AuraEffect* trigg { switch (auraSpellInfo->Id) { - // Lightning Shield (The Ten Storms set) - case 23551: - { - trigger_spell_id = 23552; - target = victim; - break; - } - // Damage from Lightning Shield (The Ten Storms set) - case 23552: - { - trigger_spell_id = 27635; - break; - } - // Mana Surge (The Earthfury set) - case 23572: - { - if (!procSpell) - return false; - basepoints0 = int32(CalculatePct(procSpell->ManaCost, 35)); - trigger_spell_id = 23571; - target = this; - break; - } case 30881: // Nature's Guardian Rank 1 case 30883: // Nature's Guardian Rank 2 case 30884: // Nature's Guardian Rank 3 @@ -9264,16 +9211,17 @@ Player* Unit::GetCharmerOrOwnerPlayerOrPlayerItself() const if (IS_PLAYER_GUID(guid)) return ObjectAccessor::GetPlayer(*this, guid); - return GetTypeId() == TYPEID_PLAYER ? (Player*)this : NULL; + return const_cast<Unit*>(this)->ToPlayer(); } Player* Unit::GetAffectingPlayer() const { if (!GetCharmerOrOwnerGUID()) - return GetTypeId() == TYPEID_PLAYER ? (Player*)this : NULL; + return const_cast<Unit*>(this)->ToPlayer(); if (Unit* owner = GetCharmerOrOwner()) return owner->GetCharmerOrOwnerPlayerOrPlayerItself(); + return NULL; } @@ -14386,13 +14334,14 @@ uint64 Unit::GetCharmerOrOwnerOrOwnGUID() const Player* Unit::GetSpellModOwner() const { - if (GetTypeId() == TYPEID_PLAYER) - return (Player*)this; + if (Player* player = const_cast<Unit*>(this)->ToPlayer()) + return player; + if (ToCreature()->IsPet() || ToCreature()->IsTotem()) { - Unit* owner = GetOwner(); - if (owner && owner->GetTypeId() == TYPEID_PLAYER) - return (Player*)owner; + if (Unit* owner = GetOwner()) + if (Player* player = owner->ToPlayer()) + return player; } return NULL; } @@ -14904,7 +14853,7 @@ Pet* Unit::CreateTamedPetFrom(Creature* creatureTarget, uint32 spell_id) if (GetTypeId() != TYPEID_PLAYER) return NULL; - Pet* pet = new Pet((Player*)this, HUNTER_PET); + Pet* pet = new Pet(ToPlayer(), HUNTER_PET); if (!pet->CreateBaseAtCreature(creatureTarget)) { @@ -14928,7 +14877,7 @@ Pet* Unit::CreateTamedPetFrom(uint32 creatureEntry, uint32 spell_id) if (!creatureInfo) return NULL; - Pet* pet = new Pet((Player*)this, HUNTER_PET); + Pet* pet = new Pet(ToPlayer(), HUNTER_PET); if (!pet->CreateBaseAtCreatureInfo(creatureInfo, this) || !InitTamedPet(pet, getLevel(), spell_id)) { @@ -15404,8 +15353,8 @@ void Unit::Kill(Unit* victim, bool durabilityLoss) { if (Battleground* bg = player->GetBattleground()) { - if (victim->GetTypeId() == TYPEID_PLAYER) - bg->HandleKillPlayer((Player*)victim, player); + if (Player* playerVictim = victim->ToPlayer()) + bg->HandleKillPlayer(playerVictim, player); else bg->HandleKillUnit(victim->ToCreature(), player); } @@ -16368,14 +16317,15 @@ void Unit::UpdateObjectVisibility(bool forced) void Unit::KnockbackFrom(float x, float y, float speedXY, float speedZ) { - Player* player = NULL; - if (GetTypeId() == TYPEID_PLAYER) - player = (Player*)this; - else if (Unit* charmer = GetCharmer()) + Player* player = ToPlayer(); + if (!player) { - player = charmer->ToPlayer(); - if (player && player->m_mover != this) - player = NULL; + if (Unit* charmer = GetCharmer()) + { + player = charmer->ToPlayer(); + if (player && player->m_mover != this) + player = NULL; + } } if (!player) diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index 8a970963c37..bc9934c63eb 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -4888,7 +4888,7 @@ void ObjectMgr::LoadSpellScriptNames() while (spellInfo) { _spellScriptsStore.insert(SpellScriptsContainer::value_type(spellInfo->Id, GetScriptId(scriptName))); - spellInfo = sSpellMgr->GetSpellInfo(spellInfo->Id)->GetNextRankSpell(); + spellInfo = spellInfo->GetNextRankSpell(); } } else @@ -8362,15 +8362,6 @@ bool ObjectMgr::IsVendorItemValid(uint32 vendor_entry, uint32 item_id, int32 max return false; } - if (vItems->GetItemCount() >= MAX_VENDOR_ITEMS) - { - if (player) - ChatHandler(player->GetSession()).SendSysMessage(LANG_COMMAND_ADDVENDORITEMITEMS); - else - TC_LOG_ERROR(LOG_FILTER_SQL, "Table `npc_vendor` has too many items (%u >= %i) for vendor (Entry: %u), ignore", vItems->GetItemCount(), MAX_VENDOR_ITEMS, vendor_entry); - return false; - } - return true; } diff --git a/src/server/game/Grids/Notifiers/GridNotifiers.cpp b/src/server/game/Grids/Notifiers/GridNotifiers.cpp index e717389e919..b8ab75f213b 100644 --- a/src/server/game/Grids/Notifiers/GridNotifiers.cpp +++ b/src/server/game/Grids/Notifiers/GridNotifiers.cpp @@ -106,10 +106,10 @@ void VisibleChangesNotifier::Visit(CreatureMapType &m) void VisibleChangesNotifier::Visit(DynamicObjectMapType &m) { for (DynamicObjectMapType::iterator iter = m.begin(); iter != m.end(); ++iter) - if (IS_PLAYER_GUID(iter->GetSource()->GetCasterGUID())) - if (Player* caster = (Player*)iter->GetSource()->GetCaster()) - if (caster->m_seer == iter->GetSource()) - caster->UpdateVisibilityOf(&i_object); + if (Unit* caster = iter->GetSource()->GetCaster()) + if (Player* player = caster->ToPlayer()) + if (player->m_seer == iter->GetSource()) + player->UpdateVisibilityOf(&i_object); } inline void CreatureUnitRelocationWorker(Creature* c, Unit* u) @@ -299,12 +299,12 @@ void MessageDistDeliverer::Visit(DynamicObjectMapType &m) if (target->GetExactDist2dSq(i_source) > i_distSq) continue; - if (IS_PLAYER_GUID(target->GetCasterGUID())) + if (Unit* caster = target->GetCaster()) { // Send packet back to the caster if the caster has vision of dynamic object - Player* caster = (Player*)target->GetCaster(); - if (caster && caster->m_seer == target) - SendPacket(caster); + Player* player = caster->ToPlayer(); + if (player && player->m_seer == target) + SendPacket(player); } } } diff --git a/src/server/game/Grids/Notifiers/GridNotifiers.h b/src/server/game/Grids/Notifiers/GridNotifiers.h index f9d179795bc..0addcfc087c 100644 --- a/src/server/game/Grids/Notifiers/GridNotifiers.h +++ b/src/server/game/Grids/Notifiers/GridNotifiers.h @@ -130,10 +130,14 @@ namespace Trinity Player const* skipped_receiver; MessageDistDeliverer(WorldObject* src, WorldPacket* msg, float dist, bool own_team_only = false, Player const* skipped = NULL) : i_source(src), i_message(msg), i_phaseMask(src->GetPhaseMask()), i_distSq(dist * dist) - , team((own_team_only && src->GetTypeId() == TYPEID_PLAYER) ? ((Player*)src)->GetTeam() : 0) + , team(0) , skipped_receiver(skipped) { + if (own_team_only) + if (Player* player = src->ToPlayer()) + team = player->GetTeam(); } + void Visit(PlayerMapType &m); void Visit(CreatureMapType &m); void Visit(DynamicObjectMapType &m); diff --git a/src/server/game/Handlers/ItemHandler.cpp b/src/server/game/Handlers/ItemHandler.cpp index 90c1bc4599f..5f458edbb07 100644 --- a/src/server/game/Handlers/ItemHandler.cpp +++ b/src/server/game/Handlers/ItemHandler.cpp @@ -784,8 +784,6 @@ void WorldSession::SendListInventory(uint64 vendorGuid) continue; } - ++count; - // reputation discount int32 price = item->IsGoldRequired(itemTemplate) ? uint32(floor(itemTemplate->BuyPrice * discountMod)) : 0; @@ -797,6 +795,9 @@ void WorldSession::SendListInventory(uint64 vendorGuid) data << uint32(itemTemplate->MaxDurability); data << uint32(itemTemplate->BuyCount); data << uint32(item->ExtendedCost); + + if (++count >= MAX_VENDOR_ITEMS) + break; } } } diff --git a/src/server/game/Handlers/PetHandler.cpp b/src/server/game/Handlers/PetHandler.cpp index 9d210201730..84bdaf4104f 100644 --- a/src/server/game/Handlers/PetHandler.cpp +++ b/src/server/game/Handlers/PetHandler.cpp @@ -329,19 +329,19 @@ void WorldSession::HandlePetActionHelper(Unit* pet, uint64 guid1, uint32 spellid if (unit_target) { pet->SetInFront(unit_target); - if (unit_target->GetTypeId() == TYPEID_PLAYER) - pet->SendUpdateToPlayer((Player*)unit_target); + if (Player* player = unit_target->ToPlayer()) + pet->SendUpdateToPlayer(player); } else if (Unit* unit_target2 = spell->m_targets.GetUnitTarget()) { pet->SetInFront(unit_target2); - if (unit_target2->GetTypeId() == TYPEID_PLAYER) - pet->SendUpdateToPlayer((Player*)unit_target2); + if (Player* player = unit_target2->ToPlayer()) + pet->SendUpdateToPlayer(player); } if (Unit* powner = pet->GetCharmerOrOwner()) - if (powner->GetTypeId() == TYPEID_PLAYER) - pet->SendUpdateToPlayer(powner->ToPlayer()); + if (Player* player = powner->ToPlayer()) + pet->SendUpdateToPlayer(player); result = SPELL_CAST_OK; } @@ -620,9 +620,9 @@ void WorldSession::HandlePetRename(WorldPacket& recvData) pet->SetName(name); - Unit* owner = pet->GetOwner(); - if (owner && (owner->GetTypeId() == TYPEID_PLAYER) && owner->ToPlayer()->GetGroup()) - owner->ToPlayer()->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_NAME); + Player* owner = pet->GetOwner(); + if (owner && owner->GetGroup()) + owner->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_NAME); pet->RemoveByteFlag(UNIT_FIELD_BYTES_2, 2, UNIT_CAN_BE_RENAMED); diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index a361d54bbc8..20b6e67c5db 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -4999,20 +4999,19 @@ void AuraEffect::HandleForceReaction(AuraApplication const* aurApp, uint8 mode, Unit* target = aurApp->GetTarget(); - if (target->GetTypeId() != TYPEID_PLAYER) + Player* player = target->ToPlayer(); + if (!player) return; - Player* player = (Player*)target; - - uint32 faction_id = GetMiscValue(); - ReputationRank faction_rank = ReputationRank(m_amount); + uint32 factionId = GetMiscValue(); + ReputationRank factionRank = ReputationRank(m_amount); - player->GetReputationMgr().ApplyForceReaction(faction_id, faction_rank, apply); + player->GetReputationMgr().ApplyForceReaction(factionId, factionRank, apply); player->GetReputationMgr().SendForceReactions(); // stop fighting if at apply forced rank friendly or at remove real rank friendly - if ((apply && faction_rank >= REP_FRIENDLY) || (!apply && player->GetReputationRank(faction_id) >= REP_FRIENDLY)) - player->StopAttackFaction(faction_id); + if ((apply && factionRank >= REP_FRIENDLY) || (!apply && player->GetReputationRank(factionId) >= REP_FRIENDLY)) + player->StopAttackFaction(factionId); } void AuraEffect::HandleAuraEmpathy(AuraApplication const* aurApp, uint8 mode, bool apply) const @@ -5078,11 +5077,10 @@ void AuraEffect::HandleAuraConvertRune(AuraApplication const* aurApp, uint8 mode Unit* target = aurApp->GetTarget(); - if (target->GetTypeId() != TYPEID_PLAYER) + Player* player = target->ToPlayer(); + if (!player) return; - Player* player = (Player*)target; - if (player->getClass() != CLASS_DEATH_KNIGHT) return; diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp index 32ccaf028ad..65b644fa082 100644 --- a/src/server/game/Spells/Auras/SpellAuras.cpp +++ b/src/server/game/Spells/Auras/SpellAuras.cpp @@ -347,6 +347,14 @@ m_isRemoved(false), m_isSingleTarget(false), m_isUsingCharges(false) // m_casterLevel = cast item level/caster level, caster level should be saved to db, confirmed with sniffs } +AuraScript* Aura::GetScriptByName(std::string const& scriptName) const +{ + for (std::list<AuraScript*>::const_iterator itr = m_loadedScripts.begin(); itr != m_loadedScripts.end(); ++itr) + if ((*itr)->_GetScriptName()->compare(scriptName) == 0) + return *itr; + return NULL; +} + void Aura::_InitEffects(uint8 effMask, Unit* caster, int32 *baseAmount) { // shouldn't be in constructor - functions in AuraEffect::AuraEffect use polymorphism @@ -1071,7 +1079,7 @@ void Aura::HandleAuraSpecificMods(AuraApplication const* aurApp, Unit* caster, b for (SpellAreaForAreaMap::const_iterator itr = saBounds.first; itr != saBounds.second; ++itr) { // some auras remove at aura remove - if (!itr->second->IsFitToRequirements((Player*)target, zone, area)) + if (!itr->second->IsFitToRequirements(target->ToPlayer(), zone, area)) target->RemoveAurasDueToSpell(itr->second->spellId); // some auras applied at aura apply else if (itr->second->autocast) diff --git a/src/server/game/Spells/Auras/SpellAuras.h b/src/server/game/Spells/Auras/SpellAuras.h index 56927a09ae6..e865d415438 100644 --- a/src/server/game/Spells/Auras/SpellAuras.h +++ b/src/server/game/Spells/Auras/SpellAuras.h @@ -234,6 +234,8 @@ class Aura bool CallScriptEffectProcHandlers(AuraEffect const* aurEff, AuraApplication const* aurApp, ProcEventInfo& eventInfo); void CallScriptAfterEffectProcHandlers(AuraEffect const* aurEff, AuraApplication const* aurApp, ProcEventInfo& eventInfo); + AuraScript* GetScriptByName(std::string const& scriptName) const; + std::list<AuraScript*> m_loadedScripts; private: void _DeleteRemovedApplications(); diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index a26c0356907..c6227639608 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -2154,7 +2154,7 @@ void Spell::AddUnitTarget(Unit* target, uint32 effectMask, bool checkIfValid /*= ihit->scaleAura = false; if (m_auraScaleMask && ihit->effectMask == m_auraScaleMask && m_caster != target) { - SpellInfo const* auraSpell = sSpellMgr->GetSpellInfo(sSpellMgr->GetFirstSpellInChain(m_spellInfo->Id)); + SpellInfo const* auraSpell = m_spellInfo->GetFirstRankSpell(); if (uint32(target->getLevel() + 10) >= auraSpell->SpellLevel) ihit->scaleAura = true; } @@ -2175,7 +2175,7 @@ void Spell::AddUnitTarget(Unit* target, uint32 effectMask, bool checkIfValid /*= targetInfo.scaleAura = false; if (m_auraScaleMask && targetInfo.effectMask == m_auraScaleMask && m_caster != target) { - SpellInfo const* auraSpell = sSpellMgr->GetSpellInfo(sSpellMgr->GetFirstSpellInChain(m_spellInfo->Id)); + SpellInfo const* auraSpell = m_spellInfo->GetFirstRankSpell(); if (uint32(target->getLevel() + 10) >= auraSpell->SpellLevel) targetInfo.scaleAura = true; } @@ -3542,11 +3542,10 @@ void Spell::_handle_finish_phase() void Spell::SendSpellCooldown() { - if (m_caster->GetTypeId() != TYPEID_PLAYER) + Player* _player = m_caster->ToPlayer(); + if (!_player) return; - Player* _player = (Player*)m_caster; - // mana/health/etc potions, disabled by client (until combat out as declarate) if (m_CastItem && m_CastItem->IsPotion()) { @@ -4343,7 +4342,11 @@ void Spell::SendResurrectRequest(Player* target) void Spell::TakeCastItem() { - if (!m_CastItem || m_caster->GetTypeId() != TYPEID_PLAYER) + if (!m_CastItem) + return; + + Player* player = m_caster->ToPlayer(); + if (!player) return; // not remove cast item at triggered spell (equipping, weapon damage, etc) @@ -4381,7 +4384,7 @@ void Spell::TakeCastItem() (charges > 0) ? --charges : ++charges; // abs(charges) less at 1 after use if (proto->Stackable == 1) m_CastItem->SetSpellCharges(i, charges); - m_CastItem->SetState(ITEM_CHANGED, (Player*)m_caster); + m_CastItem->SetState(ITEM_CHANGED, player); } // all charges used @@ -4501,16 +4504,14 @@ SpellCastResult Spell::CheckRuneCost(uint32 runeCostID) if (m_spellInfo->PowerType != POWER_RUNE || !runeCostID) return SPELL_CAST_OK; - if (m_caster->GetTypeId() != TYPEID_PLAYER) + Player* player = m_caster->ToPlayer(); + if (!player) return SPELL_CAST_OK; - Player* player = (Player*)m_caster; - if (player->getClass() != CLASS_DEATH_KNIGHT) return SPELL_CAST_OK; SpellRuneCostEntry const* src = sSpellRuneCostStore.LookupEntry(runeCostID); - if (!src) return SPELL_CAST_OK; @@ -5851,11 +5852,10 @@ SpellCastResult Spell::CheckPower() SpellCastResult Spell::CheckItems() { - if (m_caster->GetTypeId() != TYPEID_PLAYER) + Player* player = m_caster->ToPlayer(); + if (!player) return SPELL_CAST_OK; - Player* p_caster = (Player*)m_caster; - if (!m_CastItem) { if (m_castItemGUID) @@ -5864,14 +5864,14 @@ SpellCastResult Spell::CheckItems() else { uint32 itemid = m_CastItem->GetEntry(); - if (!p_caster->HasItemCount(itemid)) + if (!player->HasItemCount(itemid)) return SPELL_FAILED_ITEM_NOT_READY; ItemTemplate const* proto = m_CastItem->GetTemplate(); if (!proto) return SPELL_FAILED_ITEM_NOT_READY; - for (int i = 0; i < MAX_ITEM_SPELLS; ++i) + for (uint8 i = 0; i < MAX_ITEM_SPELLS; ++i) if (proto->Spells[i].SpellCharges) if (m_CastItem->GetSpellCharges(i) == 0) return SPELL_FAILED_NO_CHARGES_REMAIN; @@ -5881,10 +5881,10 @@ SpellCastResult Spell::CheckItems() { // such items should only fail if there is no suitable effect at all - see Rejuvenation Potions for example SpellCastResult failReason = SPELL_CAST_OK; - for (int i = 0; i < MAX_SPELL_EFFECTS; i++) + for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) { - // skip check, pet not required like checks, and for TARGET_UNIT_PET m_targets.GetUnitTarget() is not the real target but the caster - if (m_spellInfo->Effects[i].TargetA.GetTarget() == TARGET_UNIT_PET) + // skip check, pet not required like checks, and for TARGET_UNIT_PET m_targets.GetUnitTarget() is not the real target but the caster + if (m_spellInfo->Effects[i].TargetA.GetTarget() == TARGET_UNIT_PET) continue; if (m_spellInfo->Effects[i].Effect == SPELL_EFFECT_HEAL) @@ -5931,9 +5931,6 @@ SpellCastResult Spell::CheckItems() // check target item if (m_targets.GetItemTargetGUID()) { - if (m_caster->GetTypeId() != TYPEID_PLAYER) - return SPELL_FAILED_BAD_TARGETS; - if (!m_targets.GetItemTarget()) return SPELL_FAILED_ITEM_GONE; @@ -5944,7 +5941,7 @@ SpellCastResult Spell::CheckItems() else { if (!(_triggeredCastFlags & TRIGGERED_IGNORE_EQUIPPED_ITEM_REQUIREMENT)) - if (m_caster->GetTypeId() == TYPEID_PLAYER && !m_caster->ToPlayer()->HasItemFitToSpellRequirements(m_spellInfo)) + if (!player->HasItemFitToSpellRequirements(m_spellInfo)) return SPELL_FAILED_EQUIPPED_ITEM_CLASS; } @@ -5971,7 +5968,7 @@ SpellCastResult Spell::CheckItems() // do not take reagents for these item casts if (!(m_CastItem && m_CastItem->GetTemplate()->Flags & ITEM_PROTO_FLAG_TRIGGERED_CAST)) { - bool checkReagents = !(_triggeredCastFlags & TRIGGERED_IGNORE_POWER_AND_REAGENT_COST) && !p_caster->CanNoReagentCast(m_spellInfo); + bool checkReagents = !(_triggeredCastFlags & TRIGGERED_IGNORE_POWER_AND_REAGENT_COST) && !player->CanNoReagentCast(m_spellInfo); // Not own traded item (in trader trade slot) requires reagents even if triggered spell if (!checkReagents) if (Item* targetItem = m_targets.GetItemTarget()) @@ -5995,7 +5992,7 @@ SpellCastResult Spell::CheckItems() ItemTemplate const* proto = m_CastItem->GetTemplate(); if (!proto) return SPELL_FAILED_ITEM_NOT_READY; - for (int s=0; s < MAX_ITEM_PROTO_SPELLS; ++s) + for (uint8 s = 0; s < MAX_ITEM_PROTO_SPELLS; ++s) { // CastItem will be used up and does not count as reagent int32 charges = m_CastItem->GetSpellCharges(s); @@ -6006,35 +6003,36 @@ SpellCastResult Spell::CheckItems() } } } - if (!p_caster->HasItemCount(itemid, itemcount)) + if (!player->HasItemCount(itemid, itemcount)) return SPELL_FAILED_REAGENTS; } } // check totem-item requirements (items presence in inventory) uint32 totems = 2; - for (int i = 0; i < 2; ++i) + for (uint8 i = 0; i < 2; ++i) { if (m_spellInfo->Totem[i] != 0) { - if (p_caster->HasItemCount(m_spellInfo->Totem[i])) + if (player->HasItemCount(m_spellInfo->Totem[i])) { totems -= 1; continue; } - }else - totems -= 1; + } + else + totems -= 1; } if (totems != 0) return SPELL_FAILED_TOTEMS; //0x7C // Check items for TotemCategory (items presence in inventory) uint32 TotemCategory = 2; - for (int i= 0; i < 2; ++i) + for (uint8 i = 0; i < 2; ++i) { if (m_spellInfo->TotemCategory[i] != 0) { - if (p_caster->HasItemTotemCategory(m_spellInfo->TotemCategory[i])) + if (player->HasItemTotemCategory(m_spellInfo->TotemCategory[i])) { TotemCategory -= 1; continue; @@ -6048,7 +6046,7 @@ SpellCastResult Spell::CheckItems() } // special checks for spell effects - for (int i = 0; i < MAX_SPELL_EFFECTS; i++) + for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) { switch (m_spellInfo->Effects[i].Effect) { @@ -6058,24 +6056,24 @@ SpellCastResult Spell::CheckItems() if (!IsTriggered() && m_spellInfo->Effects[i].ItemType) { ItemPosCountVec dest; - InventoryResult msg = p_caster->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, m_spellInfo->Effects[i].ItemType, 1); + InventoryResult msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, m_spellInfo->Effects[i].ItemType, 1); if (msg != EQUIP_ERR_OK) { ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(m_spellInfo->Effects[i].ItemType); /// @todo Needs review if (pProto && !(pProto->ItemLimitCategory)) { - p_caster->SendEquipError(msg, NULL, NULL, m_spellInfo->Effects[i].ItemType); + player->SendEquipError(msg, NULL, NULL, m_spellInfo->Effects[i].ItemType); return SPELL_FAILED_DONT_REPORT; } else { if (!(m_spellInfo->SpellFamilyName == SPELLFAMILY_MAGE && (m_spellInfo->SpellFamilyFlags[0] & 0x40000000))) return SPELL_FAILED_TOO_MANY_OF_ITEM; - else if (!(p_caster->HasItemCount(m_spellInfo->Effects[i].ItemType))) + else if (!(player->HasItemCount(m_spellInfo->Effects[i].ItemType))) return SPELL_FAILED_TOO_MANY_OF_ITEM; else - p_caster->CastSpell(m_caster, m_spellInfo->Effects[EFFECT_1].CalcValue(), false); // move this to anywhere + player->CastSpell(m_caster, m_spellInfo->Effects[EFFECT_1].CalcValue(), false); // move this to anywhere return SPELL_FAILED_DONT_REPORT; } } @@ -6093,10 +6091,10 @@ SpellCastResult Spell::CheckItems() if (m_CastItem && m_CastItem->GetTemplate()->Flags & ITEM_PROTO_FLAG_TRIGGERED_CAST) return SPELL_FAILED_TOTEM_CATEGORY; ItemPosCountVec dest; - InventoryResult msg = p_caster->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, m_spellInfo->Effects[i].ItemType, 1); + InventoryResult msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, m_spellInfo->Effects[i].ItemType, 1); if (msg != EQUIP_ERR_OK) { - p_caster->SendEquipError(msg, NULL, NULL, m_spellInfo->Effects[i].ItemType); + player->SendEquipError(msg, NULL, NULL, m_spellInfo->Effects[i].ItemType); return SPELL_FAILED_DONT_REPORT; } } @@ -6177,7 +6175,7 @@ SpellCastResult Spell::CheckItems() uint32 item_disenchantskilllevel = itemProto->RequiredDisenchantSkill; if (item_disenchantskilllevel == uint32(-1)) return SPELL_FAILED_CANT_BE_DISENCHANTED; - if (item_disenchantskilllevel > p_caster->GetSkillValue(SKILL_ENCHANTING)) + if (item_disenchantskilllevel > player->GetSkillValue(SKILL_ENCHANTING)) return SPELL_FAILED_LOW_CASTLEVEL; if (item_quality > 4 || item_quality < 2) return SPELL_FAILED_CANT_BE_DISENCHANTED; @@ -6199,7 +6197,7 @@ SpellCastResult Spell::CheckItems() return SPELL_FAILED_CANT_BE_PROSPECTED; //Check for enough skill in jewelcrafting uint32 item_prospectingskilllevel = m_targets.GetItemTarget()->GetTemplate()->RequiredSkillRank; - if (item_prospectingskilllevel >p_caster->GetSkillValue(SKILL_JEWELCRAFTING)) + if (item_prospectingskilllevel >player->GetSkillValue(SKILL_JEWELCRAFTING)) return SPELL_FAILED_LOW_CASTLEVEL; //make sure the player has the required ores in inventory if (m_targets.GetItemTarget()->GetCount() < 5) @@ -6222,7 +6220,7 @@ SpellCastResult Spell::CheckItems() return SPELL_FAILED_CANT_BE_MILLED; //Check for enough skill in inscription uint32 item_millingskilllevel = m_targets.GetItemTarget()->GetTemplate()->RequiredSkillRank; - if (item_millingskilllevel >p_caster->GetSkillValue(SKILL_INSCRIPTION)) + if (item_millingskilllevel > player->GetSkillValue(SKILL_INSCRIPTION)) return SPELL_FAILED_LOW_CASTLEVEL; //make sure the player has the required herbs in inventory if (m_targets.GetItemTarget()->GetCount() < 5) @@ -6236,13 +6234,10 @@ SpellCastResult Spell::CheckItems() case SPELL_EFFECT_WEAPON_DAMAGE: case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL: { - if (m_caster->GetTypeId() != TYPEID_PLAYER) - return SPELL_FAILED_TARGET_NOT_PLAYER; - if (m_attackType != RANGED_ATTACK) break; - Item* pItem = m_caster->ToPlayer()->GetWeaponForAttack(m_attackType); + Item* pItem = player->GetWeaponForAttack(m_attackType); if (!pItem || pItem->IsBroken()) return SPELL_FAILED_EQUIPPED_ITEM; @@ -6251,15 +6246,15 @@ SpellCastResult Spell::CheckItems() case ITEM_SUBCLASS_WEAPON_THROWN: { uint32 ammo = pItem->GetEntry(); - if (!m_caster->ToPlayer()->HasItemCount(ammo)) + if (!player->HasItemCount(ammo)) return SPELL_FAILED_NO_AMMO; - }; - break; + break; + } case ITEM_SUBCLASS_WEAPON_GUN: case ITEM_SUBCLASS_WEAPON_BOW: case ITEM_SUBCLASS_WEAPON_CROSSBOW: { - uint32 ammo = m_caster->ToPlayer()->GetUInt32Value(PLAYER_AMMO_ID); + uint32 ammo = player->GetUInt32Value(PLAYER_AMMO_ID); if (!ammo) { // Requires No Ammo @@ -6292,12 +6287,13 @@ SpellCastResult Spell::CheckItems() return SPELL_FAILED_NO_AMMO; } - if (!m_caster->ToPlayer()->HasItemCount(ammo)) + if (!player->HasItemCount(ammo)) { - m_caster->ToPlayer()->SetUInt32Value(PLAYER_AMMO_ID, 0); + player->SetUInt32Value(PLAYER_AMMO_ID, 0); return SPELL_FAILED_NO_AMMO; } - }; break; + break; + } case ITEM_SUBCLASS_WEAPON_WAND: break; default: @@ -6313,7 +6309,7 @@ SpellCastResult Spell::CheckItems() if (!pProto) return SPELL_FAILED_ITEM_AT_MAX_CHARGES; - if (Item* pitem = p_caster->GetItemByEntry(item_id)) + if (Item* pitem = player->GetItemByEntry(item_id)) { for (int x = 0; x < MAX_ITEM_PROTO_SPELLS; ++x) if (pProto->Spells[x].SpellCharges != 0 && pitem->GetSpellCharges(x) == pProto->Spells[x].SpellCharges) diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index 22940c3f930..38d31a89e86 100644 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -562,9 +562,9 @@ void Spell::EffectSchoolDMG(SpellEffIndex effIndex) // Eviscerate else if (m_spellInfo->SpellFamilyFlags[0] & 0x00020000) { - if (m_caster->GetTypeId() == TYPEID_PLAYER) + if (Player* player = m_caster->ToPlayer()) { - if (uint32 combo = ((Player*)m_caster)->GetComboPoints()) + if (uint32 combo = player->GetComboPoints()) { float ap = m_caster->GetTotalAttackPowerValue(BASE_ATTACK); damage += irand(int32(ap * combo * 0.03f), int32(ap * combo * 0.07f)); @@ -2722,30 +2722,30 @@ void Spell::EffectEnchantItemPerm(SpellEffIndex effIndex) if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET) return; - if (m_caster->GetTypeId() != TYPEID_PLAYER) - return; if (!itemTarget) return; - Player* p_caster = (Player*)m_caster; + Player* player = m_caster->ToPlayer(); + if (!player) + return; // Handle vellums if (itemTarget->IsWeaponVellum() || itemTarget->IsArmorVellum()) { // destroy one vellum from stack uint32 count = 1; - p_caster->DestroyItemCount(itemTarget, count, true); - unitTarget=p_caster; + player->DestroyItemCount(itemTarget, count, true); + unitTarget = player; // and add a scroll DoCreateItem(effIndex, m_spellInfo->Effects[effIndex].ItemType); - itemTarget=NULL; + itemTarget = NULL; m_targets.SetItemTarget(NULL); } else { // do not increase skill if vellum used if (!(m_CastItem && m_CastItem->GetTemplate()->Flags & ITEM_PROTO_FLAG_TRIGGERED_CAST)) - p_caster->UpdateCraftSkill(m_spellInfo->Id); + player->UpdateCraftSkill(m_spellInfo->Id); uint32 enchant_id = m_spellInfo->Effects[effIndex].MiscValue; if (!enchant_id) @@ -2760,10 +2760,10 @@ void Spell::EffectEnchantItemPerm(SpellEffIndex effIndex) if (!item_owner) return; - if (item_owner != p_caster && p_caster->GetSession()->HasPermission(RBAC_PERM_LOG_GM_TRADE)) + if (item_owner != player && player->GetSession()->HasPermission(RBAC_PERM_LOG_GM_TRADE)) { - sLog->outCommand(p_caster->GetSession()->GetAccountId(), "GM %s (Account: %u) enchanting(perm): %s (Entry: %d) for player: %s (Account: %u)", - p_caster->GetName().c_str(), p_caster->GetSession()->GetAccountId(), + sLog->outCommand(player->GetSession()->GetAccountId(), "GM %s (Account: %u) enchanting(perm): %s (Entry: %d) for player: %s (Account: %u)", + player->GetName().c_str(), player->GetSession()->GetAccountId(), itemTarget->GetTemplate()->Name1.c_str(), itemTarget->GetEntry(), item_owner->GetName().c_str(), item_owner->GetSession()->GetAccountId()); } @@ -2786,19 +2786,19 @@ void Spell::EffectEnchantItemPrismatic(SpellEffIndex effIndex) if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET) return; - if (m_caster->GetTypeId() != TYPEID_PLAYER) - return; if (!itemTarget) return; - Player* p_caster = (Player*)m_caster; + Player* player = m_caster->ToPlayer(); + if (!player) + return; - uint32 enchant_id = m_spellInfo->Effects[effIndex].MiscValue; - if (!enchant_id) + uint32 enchantId = m_spellInfo->Effects[effIndex].MiscValue; + if (!enchantId) return; - SpellItemEnchantmentEntry const* pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id); - if (!pEnchant) + SpellItemEnchantmentEntry const* enchant = sSpellItemEnchantmentStore.LookupEntry(enchantId); + if (!enchant) return; // support only enchantings with add socket in this slot @@ -2806,7 +2806,7 @@ void Spell::EffectEnchantItemPrismatic(SpellEffIndex effIndex) bool add_socket = false; for (uint8 i = 0; i < MAX_ITEM_ENCHANTMENT_EFFECTS; ++i) { - if (pEnchant->type[i] == ITEM_ENCHANTMENT_TYPE_PRISMATIC_SOCKET) + if (enchant->type[i] == ITEM_ENCHANTMENT_TYPE_PRISMATIC_SOCKET) { add_socket = true; break; @@ -2825,10 +2825,10 @@ void Spell::EffectEnchantItemPrismatic(SpellEffIndex effIndex) if (!item_owner) return; - if (item_owner != p_caster && p_caster->GetSession()->HasPermission(RBAC_PERM_LOG_GM_TRADE)) + if (item_owner != player && player->GetSession()->HasPermission(RBAC_PERM_LOG_GM_TRADE)) { - sLog->outCommand(p_caster->GetSession()->GetAccountId(), "GM %s (Account: %u) enchanting(perm): %s (Entry: %d) for player: %s (Account: %u)", - p_caster->GetName().c_str(), p_caster->GetSession()->GetAccountId(), + sLog->outCommand(player->GetSession()->GetAccountId(), "GM %s (Account: %u) enchanting(perm): %s (Entry: %d) for player: %s (Account: %u)", + player->GetName().c_str(), player->GetSession()->GetAccountId(), itemTarget->GetTemplate()->Name1.c_str(), itemTarget->GetEntry(), item_owner->GetName().c_str(), item_owner->GetSession()->GetAccountId()); } @@ -2836,7 +2836,7 @@ void Spell::EffectEnchantItemPrismatic(SpellEffIndex effIndex) // remove old enchanting before applying new if equipped item_owner->ApplyEnchantment(itemTarget, PRISMATIC_ENCHANTMENT_SLOT, false); - itemTarget->SetEnchantment(PRISMATIC_ENCHANTMENT_SLOT, enchant_id, 0, 0, m_caster->GetGUID()); + itemTarget->SetEnchantment(PRISMATIC_ENCHANTMENT_SLOT, enchantId, 0, 0, m_caster->GetGUID()); // add new enchanting if equipped item_owner->ApplyEnchantment(itemTarget, PRISMATIC_ENCHANTMENT_SLOT, true); @@ -2850,11 +2850,10 @@ void Spell::EffectEnchantItemTmp(SpellEffIndex effIndex) if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET) return; - if (m_caster->GetTypeId() != TYPEID_PLAYER) + Player* player = m_caster->ToPlayer(); + if (!player) return; - Player* p_caster = (Player*)m_caster; - // Rockbiter Weapon apply to both weapon if (!itemTarget) return; @@ -2894,7 +2893,7 @@ void Spell::EffectEnchantItemTmp(SpellEffIndex effIndex) for (int j = BASE_ATTACK; j <= OFF_ATTACK; ++j) { - if (Item* item = p_caster->GetWeaponForAttack(WeaponAttackType(j))) + if (Item* item = player->GetWeaponForAttack(WeaponAttackType(j))) { if (item->IsFitToSpellRequirements(m_spellInfo)) { @@ -2959,10 +2958,10 @@ void Spell::EffectEnchantItemTmp(SpellEffIndex effIndex) if (!item_owner) return; - if (item_owner != p_caster && p_caster->GetSession()->HasPermission(RBAC_PERM_LOG_GM_TRADE)) + if (item_owner != player && player->GetSession()->HasPermission(RBAC_PERM_LOG_GM_TRADE)) { - sLog->outCommand(p_caster->GetSession()->GetAccountId(), "GM %s (Account: %u) enchanting(temp): %s (Entry: %d) for player: %s (Account: %u)", - p_caster->GetName().c_str(), p_caster->GetSession()->GetAccountId(), + sLog->outCommand(player->GetSession()->GetAccountId(), "GM %s (Account: %u) enchanting(temp): %s (Entry: %d) for player: %s (Account: %u)", + player->GetName().c_str(), player->GetSession()->GetAccountId(), itemTarget->GetTemplate()->Name1.c_str(), itemTarget->GetEntry(), item_owner->GetName().c_str(), item_owner->GetSession()->GetAccountId()); } @@ -4387,21 +4386,20 @@ void Spell::EffectStuck(SpellEffIndex /*effIndex*/) if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT) return; - if (!m_caster || m_caster->GetTypeId() != TYPEID_PLAYER) - return; - if (!sWorld->getBoolConfig(CONFIG_CAST_UNSTUCK)) return; - Player* target = (Player*)m_caster; + Player* player = m_caster->ToPlayer(); + if (!player) + return; TC_LOG_DEBUG(LOG_FILTER_SPELLS_AURAS, "Spell Effect: Stuck"); - TC_LOG_INFO(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()); + TC_LOG_INFO(LOG_FILTER_SPELLS_AURAS, "Player %s (guid %u) used auto-unstuck future at map %u (%f, %f, %f)", player->GetName().c_str(), player->GetGUIDLow(), player->GetMapId(), player->GetPositionX(), player->GetPositionY(), player->GetPositionZ()); - if (target->IsInFlight()) + if (player->IsInFlight()) return; - target->TeleportTo(target->GetStartPosition(), TELE_TO_SPELL); + player->TeleportTo(player->GetStartPosition(), TELE_TO_SPELL); // homebind location is loaded always // target->TeleportTo(target->m_homebindMapId, target->m_homebindX, target->m_homebindY, target->m_homebindZ, target->GetOrientation(), (m_caster == m_caster ? TELE_TO_SPELL : 0)); @@ -4409,7 +4407,7 @@ void Spell::EffectStuck(SpellEffIndex /*effIndex*/) SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(8690); if (!spellInfo) return; - Spell spell(target, spellInfo, TRIGGERED_FULL_MASK); + Spell spell(player, spellInfo, TRIGGERED_FULL_MASK); spell.SendSpellCooldown(); } @@ -4459,10 +4457,12 @@ void Spell::EffectApplyGlyph(SpellEffIndex effIndex) if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT) return; - if (m_caster->GetTypeId() != TYPEID_PLAYER || m_glyphIndex >= MAX_GLYPH_SLOT_INDEX) + if (m_glyphIndex >= MAX_GLYPH_SLOT_INDEX) return; - Player* player = (Player*)m_caster; + Player* player = m_caster->ToPlayer(); + if (!player) + return; // glyph sockets level requirement uint8 minLevel = 0; @@ -5388,10 +5388,10 @@ void Spell::EffectProspecting(SpellEffIndex /*effIndex*/) if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET) return; - if (m_caster->GetTypeId() != TYPEID_PLAYER) + Player* player = m_caster->ToPlayer(); + if (!player) return; - Player* p_caster = (Player*)m_caster; if (!itemTarget || !(itemTarget->GetTemplate()->Flags & ITEM_PROTO_FLAG_PROSPECTABLE)) return; @@ -5400,12 +5400,12 @@ void Spell::EffectProspecting(SpellEffIndex /*effIndex*/) if (sWorld->getBoolConfig(CONFIG_SKILL_PROSPECTING)) { - uint32 SkillValue = p_caster->GetPureSkillValue(SKILL_JEWELCRAFTING); + uint32 SkillValue = player->GetPureSkillValue(SKILL_JEWELCRAFTING); uint32 reqSkillValue = itemTarget->GetTemplate()->RequiredSkillRank; - p_caster->UpdateGatherSkill(SKILL_JEWELCRAFTING, SkillValue, reqSkillValue); + player->UpdateGatherSkill(SKILL_JEWELCRAFTING, SkillValue, reqSkillValue); } - m_caster->ToPlayer()->SendLoot(itemTarget->GetGUID(), LOOT_PROSPECTING); + player->SendLoot(itemTarget->GetGUID(), LOOT_PROSPECTING); } void Spell::EffectMilling(SpellEffIndex /*effIndex*/) @@ -5413,10 +5413,10 @@ void Spell::EffectMilling(SpellEffIndex /*effIndex*/) if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET) return; - if (m_caster->GetTypeId() != TYPEID_PLAYER) + Player* player = m_caster->ToPlayer(); + if (!player) return; - Player* p_caster = (Player*)m_caster; if (!itemTarget || !(itemTarget->GetTemplate()->Flags & ITEM_PROTO_FLAG_MILLABLE)) return; @@ -5425,12 +5425,12 @@ void Spell::EffectMilling(SpellEffIndex /*effIndex*/) if (sWorld->getBoolConfig(CONFIG_SKILL_MILLING)) { - uint32 SkillValue = p_caster->GetPureSkillValue(SKILL_INSCRIPTION); + uint32 SkillValue = player->GetPureSkillValue(SKILL_INSCRIPTION); uint32 reqSkillValue = itemTarget->GetTemplate()->RequiredSkillRank; - p_caster->UpdateGatherSkill(SKILL_INSCRIPTION, SkillValue, reqSkillValue); + player->UpdateGatherSkill(SKILL_INSCRIPTION, SkillValue, reqSkillValue); } - m_caster->ToPlayer()->SendLoot(itemTarget->GetGUID(), LOOT_MILLING); + player->SendLoot(itemTarget->GetGUID(), LOOT_MILLING); } void Spell::EffectSkill(SpellEffIndex /*effIndex*/) @@ -5470,10 +5470,13 @@ void Spell::EffectSkinPlayerCorpse(SpellEffIndex /*effIndex*/) return; TC_LOG_DEBUG(LOG_FILTER_SPELLS_AURAS, "Effect: SkinPlayerCorpse"); - if ((m_caster->GetTypeId() != TYPEID_PLAYER) || (unitTarget->GetTypeId() != TYPEID_PLAYER) || (unitTarget->IsAlive())) + + Player* player = m_caster->ToPlayer(); + Player* target = unitTarget->ToPlayer(); + if (!player || !target || target->IsAlive()) return; - unitTarget->ToPlayer()->RemovedInsignia((Player*)m_caster); + target->RemovedInsignia(player); } void Spell::EffectStealBeneficialBuff(SpellEffIndex effIndex) diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp index 7b162b5abf0..7775674f122 100644 --- a/src/server/game/Spells/SpellMgr.cpp +++ b/src/server/game/Spells/SpellMgr.cpp @@ -1187,23 +1187,88 @@ bool SpellArea::IsFitToRequirements(Player const* player, uint32 newZone, uint32 return true; } -void SpellMgr::LoadSpellRanks() +void SpellMgr::UnloadSpellInfoChains() { - uint32 oldMSTime = getMSTime(); + for (SpellChainMap::iterator itr = mSpellChains.begin(); itr != mSpellChains.end(); ++itr) + mSpellInfoMap[itr->first]->ChainEntry = NULL; + + mSpellChains.clear(); +} +void SpellMgr::LoadSpellTalentRanks() +{ // cleanup core data before reload - remove reference to ChainNode from SpellInfo - for (SpellChainMap::iterator itr = mSpellChains.begin(); itr != mSpellChains.end(); ++itr) + UnloadSpellInfoChains(); + + for (uint32 i = 0; i < sTalentStore.GetNumRows(); ++i) { - mSpellInfoMap[itr->first]->ChainEntry = NULL; + TalentEntry const* talentInfo = sTalentStore.LookupEntry(i); + if (!talentInfo) + continue; + + SpellInfo const* lastSpell = NULL; + for (uint8 rank = MAX_TALENT_RANK - 1; rank > 0; --rank) + { + if (talentInfo->RankID[rank]) + { + lastSpell = GetSpellInfo(talentInfo->RankID[rank]); + break; + } + } + + if (!lastSpell) + continue; + + SpellInfo const* firstSpell = GetSpellInfo(talentInfo->RankID[0]); + if (!firstSpell) + { + TC_LOG_ERROR(LOG_FILTER_SPELLS_AURAS, "SpellMgr::LoadSpellTalentRanks: First Rank Spell %u for TalentEntry %u does not exist.", talentInfo->RankID[0], i); + continue; + } + + SpellInfo const* prevSpell = NULL; + for (uint8 rank = 0; rank < MAX_TALENT_RANK; ++rank) + { + uint32 spellId = talentInfo->RankID[rank]; + if (!spellId) + break; + + SpellInfo const* currentSpell = GetSpellInfo(spellId); + if (!currentSpell) + { + TC_LOG_ERROR(LOG_FILTER_SPELLS_AURAS, "SpellMgr::LoadSpellTalentRanks: Spell %u (Rank: %u) for TalentEntry %u does not exist.", spellId, rank + 1, i); + break; + } + + SpellChainNode node; + node.first = firstSpell; + node.last = lastSpell; + node.rank = rank + 1; + + node.prev = prevSpell; + node.next = node.rank < MAX_TALENT_RANK ? GetSpellInfo(talentInfo->RankID[rank + 1]) : NULL; + + mSpellChains[spellId] = node; + mSpellInfoMap[spellId]->ChainEntry = &mSpellChains[spellId]; + + prevSpell = currentSpell; + } } - mSpellChains.clear(); +} + +void SpellMgr::LoadSpellRanks() +{ + // cleanup data and load spell ranks for talents from dbc + LoadSpellTalentRanks(); + + uint32 oldMSTime = getMSTime(); + // 0 1 2 QueryResult result = WorldDatabase.Query("SELECT first_spell_id, spell_id, rank from spell_ranks ORDER BY first_spell_id, rank"); if (!result) { TC_LOG_INFO(LOG_FILTER_SERVER_LOADING, ">> Loaded 0 spell rank records. DB table `spell_ranks` is empty."); - return; } @@ -1280,6 +1345,10 @@ void SpellMgr::LoadSpellRanks() { ++count; int32 addedSpell = itr->first; + + if (mSpellInfoMap[addedSpell]->ChainEntry) + TC_LOG_ERROR(LOG_FILTER_SQL, "Spell %u (rank: %u, first: %u) listed in `spell_ranks` has already ChainEntry from dbc.", addedSpell, itr->second, lastSpell); + mSpellChains[addedSpell].first = GetSpellInfo(lastSpell); mSpellChains[addedSpell].last = GetSpellInfo(rankChain.back().first); mSpellChains[addedSpell].rank = itr->second; @@ -1296,10 +1365,10 @@ void SpellMgr::LoadSpellRanks() mSpellChains[addedSpell].next = GetSpellInfo(itr->first); } while (true); - } while (!finished); + } + while (!finished); TC_LOG_INFO(LOG_FILTER_SERVER_LOADING, ">> Loaded %u spell rank records in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); - } void SpellMgr::LoadSpellRequired() diff --git a/src/server/game/Spells/SpellMgr.h b/src/server/game/Spells/SpellMgr.h index b7a3294efe3..6220ece3ded 100644 --- a/src/server/game/Spells/SpellMgr.h +++ b/src/server/game/Spells/SpellMgr.h @@ -696,6 +696,8 @@ class SpellMgr public: // Loading data at server startup + void UnloadSpellInfoChains(); + void LoadSpellTalentRanks(); void LoadSpellRanks(); void LoadSpellRequired(); void LoadSpellLearnSkills(); diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp index fc7f1fac352..f6ee0faaa31 100644 --- a/src/server/scripts/Commands/cs_debug.cpp +++ b/src/server/scripts/Commands/cs_debug.cpp @@ -258,7 +258,7 @@ public: if (!unit || (unit->GetTypeId() != TYPEID_PLAYER)) player = handler->GetSession()->GetPlayer(); else - player = (Player*)unit; + player = unit->ToPlayer(); if (!unit) unit = player; diff --git a/src/server/scripts/Commands/cs_honor.cpp b/src/server/scripts/Commands/cs_honor.cpp index 9732e2557e9..75c7fcf71e2 100644 --- a/src/server/scripts/Commands/cs_honor.cpp +++ b/src/server/scripts/Commands/cs_honor.cpp @@ -90,8 +90,9 @@ public: } // check online security - if (target->GetTypeId() == TYPEID_PLAYER && handler->HasLowerSecurity((Player*)target, 0)) - return false; + if (Player* player = target->ToPlayer()) + if (handler->HasLowerSecurity(player, 0)) + return false; handler->GetSession()->GetPlayer()->RewardHonor(target, 1); return true; diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp index 4e1427dabd2..6c7e8386bdf 100644 --- a/src/server/scripts/Commands/cs_misc.cpp +++ b/src/server/scripts/Commands/cs_misc.cpp @@ -655,11 +655,9 @@ public: return false; } - if (target->GetTypeId() == TYPEID_PLAYER) - { - if (handler->HasLowerSecurity((Player*)target, 0, false)) + if (Player* player = target->ToPlayer()) + if (handler->HasLowerSecurity(player, 0, false)) return false; - } if (target->IsAlive()) { @@ -1589,6 +1587,7 @@ public: // Guild data print variables defined so that they exist, but are not necessarily used uint32 guildId = 0; + uint8 guildRankId = 0; std::string guildName; std::string guildRank; std::string note; @@ -1755,8 +1754,9 @@ public: guildId = fields[0].GetUInt32(); guildName = fields[1].GetString(); guildRank = fields[2].GetString(); - note = fields[3].GetString(); - officeNote = fields[4].GetString(); + guildRankId = fields[3].GetUInt8(); + note = fields[4].GetString(); + officeNote = fields[5].GetString(); } } } @@ -1765,7 +1765,7 @@ public: // Output I. LANG_PINFO_PLAYER handler->PSendSysMessage(LANG_PINFO_PLAYER, target ? "" : handler->GetTrinityString(LANG_OFFLINE), nameLink.c_str(), lowguid); - // Output II. LANG_PINFO_GM_ACTIVE + // Output II. LANG_PINFO_GM_ACTIVE if character is gamemaster if (target && target->IsGameMaster()) handler->PSendSysMessage(LANG_PINFO_GM_ACTIVE); @@ -1832,7 +1832,7 @@ public: if (!guildName.empty()) { handler->PSendSysMessage(LANG_PINFO_CHR_GUILD, guildName.c_str(), guildId); - handler->PSendSysMessage(LANG_PINFO_CHR_GUILD_RANK, guildRank.c_str()); + handler->PSendSysMessage(LANG_PINFO_CHR_GUILD_RANK, guildRank.c_str(), uint32(guildRankId)); if (!note.empty()) handler->PSendSysMessage(LANG_PINFO_CHR_GUILD_NOTE, note.c_str()); if (!officeNote.empty()) @@ -2227,11 +2227,9 @@ public: return false; } - if (target->GetTypeId() == TYPEID_PLAYER) - { - if (handler->HasLowerSecurity((Player*)target, 0, false)) + if (Player* player = target->ToPlayer()) + if (handler->HasLowerSecurity(player, 0, false)) return false; - } if (!target->IsAlive()) return true; diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp index ddcd4c7d824..2895e85de71 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp @@ -545,11 +545,12 @@ public: bool OnGossipHello(Player* player, GameObject* go) OVERRIDE { - uint8 SpectralPlayers = 0; Map* map = go->GetMap(); if (!map->IsDungeon()) return true; +#if MAX_PLAYERS_IN_SPECTRAL_REALM > 0 + uint8 SpectralPlayers = 0; Map::PlayerList const &PlayerList = map->GetPlayers(); for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) { @@ -558,9 +559,13 @@ public: } if (player->HasAura(AURA_SPECTRAL_EXHAUSTION) || SpectralPlayers >= MAX_PLAYERS_IN_SPECTRAL_REALM) + { player->GetSession()->SendNotification(GO_FAILED); - else - player->CastSpell(player, SPELL_TELEPORT_SPECTRAL, true); + return true; + } +#endif + + player->CastSpell(player, SPELL_TELEPORT_SPECTRAL, true); return true; } }; diff --git a/src/server/scripts/Kalimdor/OnyxiasLair/boss_onyxia.cpp b/src/server/scripts/Kalimdor/OnyxiasLair/boss_onyxia.cpp index afcbf1f0046..0adc6190d4b 100644 --- a/src/server/scripts/Kalimdor/OnyxiasLair/boss_onyxia.cpp +++ b/src/server/scripts/Kalimdor/OnyxiasLair/boss_onyxia.cpp @@ -413,7 +413,7 @@ public: } break; case EVENT_MOVEMENT: // Phase PHASE_BREATH - if (!IsMoving) + if (!IsMoving && !(me->HasUnitState(UNIT_STATE_CASTING))) { SetNextRandomPoint(); PointData = GetMoveData(); diff --git a/src/server/scripts/Northrend/VioletHold/instance_violet_hold.cpp b/src/server/scripts/Northrend/VioletHold/instance_violet_hold.cpp index 2c65300cd4c..483d243c51d 100644 --- a/src/server/scripts/Northrend/VioletHold/instance_violet_hold.cpp +++ b/src/server/scripts/Northrend/VioletHold/instance_violet_hold.cpp @@ -61,12 +61,7 @@ enum AzureSaboteurSpells enum CrystalSpells { - SPELL_ARCANE_LIGHTNING = 57912 -}; - -enum Events -{ - EVENT_ACTIVATE_CRYSTAL = 20001 + SPELL_ARCANE_LIGHTNING = 57930 }; const Position PortalLocation[] = @@ -79,6 +74,7 @@ const Position PortalLocation[] = {1908.31f, 809.657f, 38.7037f, 3.08701f} // WP 6 }; +const Position ArcaneSphere = {1887.060059f, 806.151001f, 61.321602f, 0.0f}; const Position BossStartMove1 = {1894.684448f, 739.390503f, 47.668003f, 0.0f}; const Position BossStartMove2 = {1875.173950f, 860.832703f, 43.333565f, 0.0f}; const Position BossStartMove21 = {1858.854614f, 855.071411f, 43.333565f, 0.0f}; @@ -140,7 +136,7 @@ public: uint64 uiTeleportationPortal; uint64 uiSaboteurPortal; - uint64 uiActivationCrystal[3]; + uint64 uiActivationCrystal[4]; uint32 uiActivationTimer; uint32 uiCyanigosaEventTimer; @@ -308,7 +304,7 @@ public: uiMainDoor = go->GetGUID(); break; case GO_ACTIVATION_CRYSTAL: - if (uiCountActivationCrystals < 3) + if (uiCountActivationCrystals < 4) uiActivationCrystal[uiCountActivationCrystals++] = go->GetGUID(); break; } @@ -397,10 +393,13 @@ public: uiMainEventPhase = data; if (data == IN_PROGRESS) // Start event { - if (GameObject* pMainDoor = instance->GetGameObject(uiMainDoor)) - pMainDoor->SetGoState(GO_STATE_READY); + if (GameObject* mainDoor = instance->GetGameObject(uiMainDoor)) + mainDoor->SetGoState(GO_STATE_READY); uiWaveCount = 1; bActive = true; + for (int i = 0; i < 4; ++i) + if (GameObject* crystal = instance->GetGameObject(uiActivationCrystal[i])) + crystal->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); uiRemoveNpc = 0; // might not have been reset after a wipe on a boss. } break; @@ -700,7 +699,7 @@ public: } // if main event is in progress and players have wiped then reset instance - if ( uiMainEventPhase == IN_PROGRESS && CheckWipe()) + if (uiMainEventPhase == IN_PROGRESS && CheckWipe()) { SetData(DATA_REMOVE_NPC, 1); StartBossEncounter(uiFirstBoss, false); @@ -710,6 +709,10 @@ public: SetData(DATA_WAVE_COUNT, 0); uiMainEventPhase = NOT_STARTED; + for (int i = 0; i < 4; ++i) + if (GameObject* crystal = instance->GetGameObject(uiActivationCrystal[i])) + crystal->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); + if (Creature* pSinclari = instance->GetCreature(uiSinclari)) { pSinclari->SetVisible(true); @@ -791,13 +794,29 @@ public: void ActivateCrystal() { + // just to make things easier we'll get the gameobject from the map + GameObject* invoker = instance->GetGameObject(uiActivationCrystal[0]); + if (!invoker) + return; + + SpellInfo const* spellInfoLightning = sSpellMgr->GetSpellInfo(SPELL_ARCANE_LIGHTNING); + if (!spellInfoLightning) + return; + + // the orb + TempSummon* trigger = invoker->SummonCreature(NPC_DEFENSE_SYSTEM, ArcaneSphere, TEMPSUMMON_MANUAL_DESPAWN, 0); + if (!trigger) + return; + + // visuals + trigger->CastSpell(trigger, spellInfoLightning, true, 0, 0, trigger->GetGUID()); + // Kill all mobs registered with SetData64(ADD_TRASH_MOB) - /// @todo All visual, spells etc for (std::set<uint64>::const_iterator itr = trashMobs.begin(); itr != trashMobs.end(); ++itr) { Creature* creature = instance->GetCreature(*itr); if (creature && creature->IsAlive()) - creature->CastSpell(creature, SPELL_ARCANE_LIGHTNING, true); // Who should cast the spell? + trigger->Kill(creature); } } diff --git a/src/server/scripts/Northrend/VioletHold/violet_hold.cpp b/src/server/scripts/Northrend/VioletHold/violet_hold.cpp index d168a7277b9..0cec919737a 100644 --- a/src/server/scripts/Northrend/VioletHold/violet_hold.cpp +++ b/src/server/scripts/Northrend/VioletHold/violet_hold.cpp @@ -21,6 +21,9 @@ #include "ScriptedEscortAI.h" #include "violet_hold.h" #include "Player.h" +#include "SpellAuras.h" +#include "SpellAuraEffects.h" +#include "SpellScript.h" #define GOSSIP_START_EVENT "Get your people to safety, we'll keep the Blue Dragonflight's forces at bay." #define GOSSIP_ITEM_1 "Activate the crystals when we get in trouble, right" @@ -108,8 +111,8 @@ enum AzureStalkerSpells enum AzureSaboteurSpells { - SABOTEUR_SHIELD_DISRUPTION = 58291, - SABOTEUR_SHIELD_EFFECT = 45775 + SABOTEUR_SHIELD_DISRUPTION = 58291, + SABOTEUR_SHIELD_EFFECT = 45775 }; enum TrashDoorSpell @@ -119,13 +122,14 @@ enum TrashDoorSpell enum Spells { - SPELL_PORTAL_CHANNEL = 58012, - SPELL_CRYSTALL_ACTIVATION = 57804 + SPELL_PORTAL_CHANNEL = 58012, + SPELL_CRYSTAL_ACTIVATION = 57804, + SPELL_ARCANE_SPHERE_PASSIVE = 44263 }; enum Sinclari { - SAY_SINCLARI_1 = 0 + SAY_SINCLARI_1 = 0 }; float FirstPortalWPs [6][3] = @@ -1320,7 +1324,55 @@ public: DoMeleeAttackIfReady(); } }; +}; + + +class npc_violet_hold_arcane_sphere : public CreatureScript +{ +public: + npc_violet_hold_arcane_sphere() : CreatureScript("npc_violet_hold_arcane_sphere") { } + + struct npc_violet_hold_arcane_sphereAI : public ScriptedAI + { + npc_violet_hold_arcane_sphereAI(Creature* creature) : ScriptedAI(creature) { } + + uint32 DespawnTimer; + + void Reset() OVERRIDE + { + DespawnTimer = 3000; + + me->SetDisableGravity(true); + DoCast(me, SPELL_ARCANE_SPHERE_PASSIVE, true); + } + + void EnterCombat(Unit * /*who*/) OVERRIDE {} + + void UpdateAI(uint32 diff) OVERRIDE + { + if (DespawnTimer <= diff) + me->Kill(me); + else + DespawnTimer -= diff; + } + }; + CreatureAI* GetAI(Creature* creature) const OVERRIDE + { + return new npc_violet_hold_arcane_sphereAI(creature); + } +}; + +class go_activation_crystal : public GameObjectScript +{ +public: + go_activation_crystal() : GameObjectScript("go_activation_crystal") { } + + bool OnGossipHello(Player * /*player*/, GameObject* go) OVERRIDE + { + go->EventInform(EVENT_ACTIVATE_CRYSTAL); + return false; + } }; void AddSC_violet_hold() @@ -1336,4 +1388,6 @@ void AddSC_violet_hold() new npc_azure_raider(); new npc_azure_stalker(); new npc_azure_saboteur(); + new npc_violet_hold_arcane_sphere(); + new go_activation_crystal(); } diff --git a/src/server/scripts/Northrend/VioletHold/violet_hold.h b/src/server/scripts/Northrend/VioletHold/violet_hold.h index 014d3edff77..f288af43ed2 100644 --- a/src/server/scripts/Northrend/VioletHold/violet_hold.h +++ b/src/server/scripts/Northrend/VioletHold/violet_hold.h @@ -92,7 +92,8 @@ enum CreaturesIds CREATURE_CYANIGOSA = 31134, CREATURE_SINCLARI = 30658, CREATURE_SABOTEOUR = 31079, - NPC_VIOLET_HOLD_GUARD = 30659 + NPC_VIOLET_HOLD_GUARD = 30659, + NPC_DEFENSE_SYSTEM = 30837 }; enum WorldStateIds @@ -102,4 +103,9 @@ enum WorldStateIds WORLD_STATE_VH_WAVE_COUNT = 3810, }; +enum Events +{ + EVENT_ACTIVATE_CRYSTAL = 20001 +}; + #endif diff --git a/src/server/scripts/Northrend/zone_icecrown.cpp b/src/server/scripts/Northrend/zone_icecrown.cpp index 5802a2e4220..24452a5fb5f 100644 --- a/src/server/scripts/Northrend/zone_icecrown.cpp +++ b/src/server/scripts/Northrend/zone_icecrown.cpp @@ -1110,8 +1110,8 @@ class npc_margrave_dhakar : public CreatureScript private: EventMap _events; - uint64 _lichKingGuid; SummonList _summons; + uint64 _lichKingGuid; }; CreatureAI* GetAI(Creature* creature) const OVERRIDE diff --git a/src/server/scripts/Spells/spell_dk.cpp b/src/server/scripts/Spells/spell_dk.cpp index 0399134fddb..1ab3961a662 100644 --- a/src/server/scripts/Spells/spell_dk.cpp +++ b/src/server/scripts/Spells/spell_dk.cpp @@ -32,6 +32,7 @@ enum DeathKnightSpells SPELL_DK_BLACK_ICE_R1 = 49140, SPELL_DK_BLOOD_BOIL_TRIGGERED = 65658, SPELL_DK_BLOOD_GORGED_HEAL = 50454, + SPELL_DK_BLOOD_PRESENCE = 48266, SPELL_DK_CORPSE_EXPLOSION_TRIGGERED = 43999, SPELL_DK_CORPSE_EXPLOSION_VISUAL = 51270, SPELL_DK_DEATH_COIL_DAMAGE = 47632, @@ -39,21 +40,21 @@ enum DeathKnightSpells SPELL_DK_DEATH_STRIKE_HEAL = 45470, SPELL_DK_GHOUL_EXPLODE = 47496, SPELL_DK_GLYPH_OF_ICEBOUND_FORTITUDE = 58625, - SPELL_DK_RUNIC_POWER_ENERGIZE = 49088, - SPELL_DK_SCOURGE_STRIKE_TRIGGERED = 70890, - SPELL_DK_WILL_OF_THE_NECROPOLIS_TALENT_R1 = 49189, - SPELL_DK_WILL_OF_THE_NECROPOLIS_AURA_R1 = 52284, - SPELL_DK_BLOOD_PRESENCE = 48266, SPELL_DK_IMPROVED_BLOOD_PRESENCE_TRIGGERED = 63611, - SPELL_DK_UNHOLY_PRESENCE = 48265, SPELL_DK_IMPROVED_UNHOLY_PRESENCE_TRIGGERED = 63622, SPELL_DK_ITEM_SIGIL_VENGEFUL_HEART = 64962, SPELL_DK_ITEM_T8_MELEE_4P_BONUS = 64736, + SPELL_DK_RUNIC_POWER_ENERGIZE = 49088, + SPELL_DK_SCENT_OF_BLOOD = 50422, + SPELL_DK_SCOURGE_STRIKE_TRIGGERED = 70890, + SPELL_DK_UNHOLY_PRESENCE = 48265, + SPELL_DK_WILL_OF_THE_NECROPOLIS_TALENT_R1 = 49189, + SPELL_DK_WILL_OF_THE_NECROPOLIS_AURA_R1 = 52284 }; enum DeathKnightSpellIcons { - DK_ICON_ID_IMPROVED_DEATH_STRIKE = 2751, + DK_ICON_ID_IMPROVED_DEATH_STRIKE = 2751 }; // 50462 - Anti-Magic Shell (on raid member) @@ -807,6 +808,42 @@ class spell_dk_rune_tap_party : public SpellScriptLoader } }; +// 50421 - Scent of Blood +class spell_dk_scent_of_blood : public SpellScriptLoader +{ + public: + spell_dk_scent_of_blood() : SpellScriptLoader("spell_dk_scent_of_blood") { } + + class spell_dk_scent_of_blood_AuraScript : public AuraScript + { + PrepareAuraScript(spell_dk_scent_of_blood_AuraScript); + + bool Validate(SpellInfo const* /*spellInfo*/) OVERRIDE + { + if (!sSpellMgr->GetSpellInfo(SPELL_DK_SCENT_OF_BLOOD)) + return false; + return true; + } + + void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo) + { + PreventDefaultAction(); + GetTarget()->CastSpell(GetTarget(), SPELL_DK_SCENT_OF_BLOOD, true, NULL, aurEff); + GetTarget()->RemoveAuraFromStack(GetSpellInfo()->Id); + } + + void Register() OVERRIDE + { + OnEffectProc += AuraEffectProcFn(spell_dk_scent_of_blood_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_PROC_TRIGGER_SPELL); + } + }; + + AuraScript* GetAuraScript() const OVERRIDE + { + return new spell_dk_scent_of_blood_AuraScript(); + } +}; + // 55090 - Scourge Strike (55265, 55270, 55271) class spell_dk_scourge_strike : public SpellScriptLoader { @@ -953,11 +990,15 @@ class spell_dk_will_of_the_necropolis : public SpellScriptLoader bool Validate(SpellInfo const* spellInfo) OVERRIDE { + SpellInfo const* firstRankSpellInfo = sSpellMgr->GetSpellInfo(SPELL_DK_WILL_OF_THE_NECROPOLIS_AURA_R1); + if (!firstRankSpellInfo) + return false; + // can't use other spell than will of the necropolis due to spell_ranks dependency - if (sSpellMgr->GetFirstSpellInChain(SPELL_DK_WILL_OF_THE_NECROPOLIS_AURA_R1) != sSpellMgr->GetFirstSpellInChain(spellInfo->Id)) + if (!spellInfo->IsRankOf(firstRankSpellInfo)) return false; - uint8 rank = sSpellMgr->GetSpellRank(spellInfo->Id); + uint8 rank = spellInfo->GetRank(); if (!sSpellMgr->GetSpellWithRank(SPELL_DK_WILL_OF_THE_NECROPOLIS_TALENT_R1, rank, true)) return false; @@ -981,7 +1022,7 @@ class spell_dk_will_of_the_necropolis : public SpellScriptLoader void Absorb(AuraEffect* /*aurEff*/, DamageInfo & dmgInfo, uint32 & absorbAmount) { // min pct of hp is stored in effect 0 of talent spell - uint32 rank = sSpellMgr->GetSpellRank(GetSpellInfo()->Id); + uint8 rank = GetSpellInfo()->GetRank(); SpellInfo const* talentProto = sSpellMgr->GetSpellInfo(sSpellMgr->GetSpellWithRank(SPELL_DK_WILL_OF_THE_NECROPOLIS_TALENT_R1, rank)); int32 remainingHp = int32(GetTarget()->GetHealth() - dmgInfo.GetDamage()); @@ -1023,6 +1064,7 @@ void AddSC_deathknight_spell_scripts() new spell_dk_improved_blood_presence(); new spell_dk_improved_unholy_presence(); new spell_dk_rune_tap_party(); + new spell_dk_scent_of_blood(); new spell_dk_scourge_strike(); new spell_dk_spell_deflection(); new spell_dk_vampiric_blood(); diff --git a/src/server/scripts/Spells/spell_item.cpp b/src/server/scripts/Spells/spell_item.cpp index 9b8e7d489ce..64fc835bff9 100644 --- a/src/server/scripts/Spells/spell_item.cpp +++ b/src/server/scripts/Spells/spell_item.cpp @@ -73,6 +73,46 @@ class spell_item_trigger_spell : public SpellScriptLoader } }; +enum AegisOfPreservation +{ + SPELL_AEGIS_HEAL = 23781 +}; + +// 23780 - Aegis of Preservation +class spell_item_aegis_of_preservation : public SpellScriptLoader +{ + public: + spell_item_aegis_of_preservation() : SpellScriptLoader("spell_item_aegis_of_preservation") { } + + class spell_item_aegis_of_preservation_AuraScript : public AuraScript + { + PrepareAuraScript(spell_item_aegis_of_preservation_AuraScript); + + bool Validate(SpellInfo const* /*spellInfo*/) OVERRIDE + { + if (!sSpellMgr->GetSpellInfo(SPELL_AEGIS_HEAL)) + return false; + return true; + } + + void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo) + { + PreventDefaultAction(); + GetTarget()->CastSpell(GetTarget(), SPELL_AEGIS_HEAL, true, NULL, aurEff); + } + + void Register() OVERRIDE + { + OnEffectProc += AuraEffectProcFn(spell_item_aegis_of_preservation_AuraScript::HandleProc, EFFECT_1, SPELL_AURA_PROC_TRIGGER_SPELL); + } + }; + + AuraScript* GetAuraScript() const OVERRIDE + { + return new spell_item_aegis_of_preservation_AuraScript(); + } +}; + // 26400 - Arcane Shroud class spell_item_arcane_shroud : public SpellScriptLoader { @@ -217,6 +257,46 @@ class spell_item_defibrillate : public SpellScriptLoader uint32 _failSpell; }; +enum DesperateDefense +{ + SPELL_DESPERATE_RAGE = 33898 +}; + +// 33896 - Desperate Defense +class spell_item_desperate_defense : public SpellScriptLoader +{ + public: + spell_item_desperate_defense() : SpellScriptLoader("spell_item_desperate_defense") { } + + class spell_item_desperate_defense_AuraScript : public AuraScript + { + PrepareAuraScript(spell_item_desperate_defense_AuraScript); + + bool Validate(SpellInfo const* /*spellInfo*/) OVERRIDE + { + if (!sSpellMgr->GetSpellInfo(SPELL_DESPERATE_RAGE)) + return false; + return true; + } + + void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo) + { + PreventDefaultAction(); + GetTarget()->CastSpell(GetTarget(), SPELL_DESPERATE_RAGE, true, NULL, aurEff); + } + + void Register() OVERRIDE + { + OnEffectProc += AuraEffectProcFn(spell_item_desperate_defense_AuraScript::HandleProc, EFFECT_2, SPELL_AURA_PROC_TRIGGER_SPELL); + } + }; + + AuraScript* GetAuraScript() const OVERRIDE + { + return new spell_item_desperate_defense_AuraScript(); + } +}; + // http://www.wowhead.com/item=6522 Deviate Fish // 8063 Deviate Fish enum DeviateFishSpells @@ -523,15 +603,21 @@ class spell_item_necrotic_touch : public SpellScriptLoader return true; } + bool CheckProc(ProcEventInfo& eventInfo) + { + return eventInfo.GetProcTarget() && eventInfo.GetProcTarget()->IsAlive(); + } + void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo) { PreventDefaultAction(); int32 bp = CalculatePct(int32(eventInfo.GetDamageInfo()->GetDamage()), aurEff->GetAmount()); - GetTarget()->CastCustomSpell(SPELL_ITEM_NECROTIC_TOUCH_PROC, SPELLVALUE_BASE_POINT0, bp, GetTarget(), true, NULL, aurEff); + GetTarget()->CastCustomSpell(SPELL_ITEM_NECROTIC_TOUCH_PROC, SPELLVALUE_BASE_POINT0, bp, eventInfo.GetProcTarget(), true, NULL, aurEff); } void Register() OVERRIDE { + DoCheckProc += AuraCheckProcFn(spell_item_necrotic_touch_AuraScript::CheckProc); OnEffectProc += AuraEffectProcFn(spell_item_necrotic_touch_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_DUMMY); } }; @@ -2477,11 +2563,13 @@ void AddSC_item_spell_scripts() // 23075 Mithril Mechanical Dragonling new spell_item_trigger_spell("spell_item_mithril_mechanical_dragonling", SPELL_MITHRIL_MECHANICAL_DRAGONLING); + new spell_item_aegis_of_preservation(); new spell_item_arcane_shroud(); new spell_item_blessing_of_ancient_kings(); new spell_item_defibrillate("spell_item_goblin_jumper_cables", 67, SPELL_GOBLIN_JUMPER_CABLES_FAIL); new spell_item_defibrillate("spell_item_goblin_jumper_cables_xl", 50, SPELL_GOBLIN_JUMPER_CABLES_XL_FAIL); new spell_item_defibrillate("spell_item_gnomish_army_knife", 33); + new spell_item_desperate_defense(); new spell_item_deviate_fish(); new spell_item_flask_of_the_north(); new spell_item_gnomish_death_ray(); diff --git a/src/server/scripts/Spells/spell_paladin.cpp b/src/server/scripts/Spells/spell_paladin.cpp index fa3c6be7f72..9f50fc3abdf 100644 --- a/src/server/scripts/Spells/spell_paladin.cpp +++ b/src/server/scripts/Spells/spell_paladin.cpp @@ -55,6 +55,8 @@ enum PaladinSpells SPELL_PALADIN_HAND_OF_SACRIFICE = 6940, SPELL_PALADIN_DIVINE_SACRIFICE = 64205, + SPELL_PALADIN_ITEM_HEALING_TRANCE = 37706, + SPELL_PALADIN_GLYPH_OF_SALVATION = 63225, SPELL_PALADIN_RIGHTEOUS_DEFENSE_TAUNT = 31790, @@ -587,6 +589,41 @@ class spell_pal_hand_of_salvation : public SpellScriptLoader } }; +// 37705 - Healing Discount +class spell_pal_item_healing_discount : public SpellScriptLoader +{ + public: + spell_pal_item_healing_discount() : SpellScriptLoader("spell_pal_item_healing_discount") { } + + class spell_pal_item_healing_discount_AuraScript : public AuraScript + { + PrepareAuraScript(spell_pal_item_healing_discount_AuraScript); + + bool Validate(SpellInfo const* /*spellInfo*/) OVERRIDE + { + if (!sSpellMgr->GetSpellInfo(SPELL_PALADIN_ITEM_HEALING_TRANCE)) + return false; + return true; + } + + void HandleProc(AuraEffect const* aurEff, ProcEventInfo& /*eventInfo*/) + { + PreventDefaultAction(); + GetTarget()->CastSpell(GetTarget(), SPELL_PALADIN_ITEM_HEALING_TRANCE, true, NULL, aurEff); + } + + void Register() OVERRIDE + { + OnEffectProc += AuraEffectProcFn(spell_pal_item_healing_discount_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_PROC_TRIGGER_SPELL); + } + }; + + AuraScript* GetAuraScript() const OVERRIDE + { + return new spell_pal_item_healing_discount_AuraScript(); + } +}; + // -20473 - Holy Shock class spell_pal_holy_shock : public SpellScriptLoader { @@ -597,16 +634,17 @@ class spell_pal_holy_shock : public SpellScriptLoader { PrepareSpellScript(spell_pal_holy_shock_SpellScript); - bool Validate(SpellInfo const* spell) OVERRIDE + bool Validate(SpellInfo const* spellInfo) OVERRIDE { - if (!sSpellMgr->GetSpellInfo(SPELL_PALADIN_HOLY_SHOCK_R1)) + SpellInfo const* firstRankSpellInfo = sSpellMgr->GetSpellInfo(SPELL_PALADIN_HOLY_SHOCK_R1); + if (!firstRankSpellInfo) return false; // can't use other spell than holy shock due to spell_ranks dependency - if (sSpellMgr->GetFirstSpellInChain(SPELL_PALADIN_HOLY_SHOCK_R1) != sSpellMgr->GetFirstSpellInChain(spell->Id)) + if (!spellInfo->IsRankOf(firstRankSpellInfo)) return false; - uint8 rank = sSpellMgr->GetSpellRank(spell->Id); + uint8 rank = spellInfo->GetRank(); if (!sSpellMgr->GetSpellWithRank(SPELL_PALADIN_HOLY_SHOCK_R1_DAMAGE, rank, true) || !sSpellMgr->GetSpellWithRank(SPELL_PALADIN_HOLY_SHOCK_R1_HEALING, rank, true)) return false; @@ -618,11 +656,11 @@ class spell_pal_holy_shock : public SpellScriptLoader Unit* caster = GetCaster(); if (Unit* unitTarget = GetHitUnit()) { - uint8 rank = sSpellMgr->GetSpellRank(GetSpellInfo()->Id); + uint8 rank = GetSpellInfo()->GetRank(); if (caster->IsFriendlyTo(unitTarget)) - caster->CastSpell(unitTarget, sSpellMgr->GetSpellWithRank(SPELL_PALADIN_HOLY_SHOCK_R1_HEALING, rank), true, 0); + caster->CastSpell(unitTarget, sSpellMgr->GetSpellWithRank(SPELL_PALADIN_HOLY_SHOCK_R1_HEALING, rank), true); else - caster->CastSpell(unitTarget, sSpellMgr->GetSpellWithRank(SPELL_PALADIN_HOLY_SHOCK_R1_DAMAGE, rank), true, 0); + caster->CastSpell(unitTarget, sSpellMgr->GetSpellWithRank(SPELL_PALADIN_HOLY_SHOCK_R1_DAMAGE, rank), true); } } @@ -910,6 +948,7 @@ void AddSC_paladin_spell_scripts() new spell_pal_guarded_by_the_light(); new spell_pal_hand_of_sacrifice(); new spell_pal_hand_of_salvation(); + new spell_pal_item_healing_discount(); new spell_pal_holy_shock(); new spell_pal_judgement_of_command(); new spell_pal_lay_on_hands(); diff --git a/src/server/scripts/Spells/spell_priest.cpp b/src/server/scripts/Spells/spell_priest.cpp index cf52909ee3f..4d11f0a2d72 100644 --- a/src/server/scripts/Spells/spell_priest.cpp +++ b/src/server/scripts/Spells/spell_priest.cpp @@ -34,6 +34,7 @@ enum PriestSpells SPELL_PRIEST_GLYPH_OF_LIGHTWELL = 55673, SPELL_PRIEST_GLYPH_OF_PRAYER_OF_HEALING_HEAL = 56161, SPELL_PRIEST_GUARDIAN_SPIRIT_HEAL = 48153, + SPELL_PRIEST_ITEM_EFFICIENCY = 37595, SPELL_PRIEST_MANA_LEECH_PROC = 34650, SPELL_PRIEST_PENANCE_R1 = 47540, SPELL_PRIEST_PENANCE_R1_DAMAGE = 47758, @@ -197,6 +198,41 @@ class spell_pri_guardian_spirit : public SpellScriptLoader } }; +// 37594 - Greater Heal Refund +class spell_pri_item_greater_heal_refund : public SpellScriptLoader +{ + public: + spell_pri_item_greater_heal_refund() : SpellScriptLoader("spell_pri_item_greater_heal_refund") { } + + class spell_pri_item_greater_heal_refund_AuraScript : public AuraScript + { + PrepareAuraScript(spell_pri_item_greater_heal_refund_AuraScript); + + bool Validate(SpellInfo const* /*spellInfo*/) OVERRIDE + { + if (!sSpellMgr->GetSpellInfo(SPELL_PRIEST_ITEM_EFFICIENCY)) + return false; + return true; + } + + void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo) + { + PreventDefaultAction(); + GetTarget()->CastSpell(GetTarget(), SPELL_PRIEST_ITEM_EFFICIENCY, true, NULL, aurEff); + } + + void Register() OVERRIDE + { + OnEffectProc += AuraEffectProcFn(spell_pri_item_greater_heal_refund_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_PROC_TRIGGER_SPELL); + } + }; + + AuraScript* GetAuraScript() const OVERRIDE + { + return new spell_pri_item_greater_heal_refund_AuraScript(); + } +}; + // -7001 - Lightwell Renew class spell_pri_lightwell_renew : public SpellScriptLoader { @@ -382,13 +418,15 @@ class spell_pri_penance : public SpellScriptLoader bool Validate(SpellInfo const* spellInfo) OVERRIDE { - if (!sSpellMgr->GetSpellInfo(SPELL_PRIEST_PENANCE_R1)) + SpellInfo const* firstRankSpellInfo = sSpellMgr->GetSpellInfo(SPELL_PRIEST_PENANCE_R1); + if (!firstRankSpellInfo) return false; + // can't use other spell than this penance due to spell_ranks dependency - if (sSpellMgr->GetFirstSpellInChain(SPELL_PRIEST_PENANCE_R1) != sSpellMgr->GetFirstSpellInChain(spellInfo->Id)) + if (!spellInfo->IsRankOf(firstRankSpellInfo)) return false; - uint8 rank = sSpellMgr->GetSpellRank(spellInfo->Id); + uint8 rank = spellInfo->GetRank(); if (!sSpellMgr->GetSpellWithRank(SPELL_PRIEST_PENANCE_R1_DAMAGE, rank, true)) return false; if (!sSpellMgr->GetSpellWithRank(SPELL_PRIEST_PENANCE_R1_HEAL, rank, true)) @@ -405,12 +443,12 @@ class spell_pri_penance : public SpellScriptLoader if (!unitTarget->IsAlive()) return; - uint8 rank = sSpellMgr->GetSpellRank(GetSpellInfo()->Id); + uint8 rank = GetSpellInfo()->GetRank(); if (caster->IsFriendlyTo(unitTarget)) - caster->CastSpell(unitTarget, sSpellMgr->GetSpellWithRank(SPELL_PRIEST_PENANCE_R1_HEAL, rank), false, 0); + caster->CastSpell(unitTarget, sSpellMgr->GetSpellWithRank(SPELL_PRIEST_PENANCE_R1_HEAL, rank), false); else - caster->CastSpell(unitTarget, sSpellMgr->GetSpellWithRank(SPELL_PRIEST_PENANCE_R1_DAMAGE, rank), false, 0); + caster->CastSpell(unitTarget, sSpellMgr->GetSpellWithRank(SPELL_PRIEST_PENANCE_R1_DAMAGE, rank), false); } } @@ -491,12 +529,11 @@ class spell_pri_power_word_shield : public SpellScriptLoader if (dmgInfo.GetAttacker() == target) return; - if (Unit* caster = GetCaster()) - if (AuraEffect* talentAurEff = caster->GetAuraEffectOfRankedSpell(SPELL_PRIEST_REFLECTIVE_SHIELD_R1, EFFECT_0)) - { - int32 bp = CalculatePct(absorbAmount, talentAurEff->GetAmount()); - target->CastCustomSpell(dmgInfo.GetAttacker(), SPELL_PRIEST_REFLECTIVE_SHIELD_TRIGGERED, &bp, NULL, NULL, true, NULL, aurEff); - } + if (AuraEffect* talentAurEff = target->GetAuraEffectOfRankedSpell(SPELL_PRIEST_REFLECTIVE_SHIELD_R1, EFFECT_0)) + { + int32 bp = CalculatePct(absorbAmount, talentAurEff->GetAmount()); + target->CastCustomSpell(dmgInfo.GetAttacker(), SPELL_PRIEST_REFLECTIVE_SHIELD_TRIGGERED, &bp, NULL, NULL, true, NULL, aurEff); + } } void Register() OVERRIDE @@ -633,7 +670,7 @@ class spell_pri_vampiric_touch : public SpellScriptLoader { PrepareAuraScript(spell_pri_vampiric_touch_AuraScript); - bool Validate(SpellInfo const* /*spell*/) OVERRIDE + bool Validate(SpellInfo const* /*spellInfo*/) OVERRIDE { if (!sSpellMgr->GetSpellInfo(SPELL_PRIEST_VAMPIRIC_TOUCH_DISPEL)) return false; @@ -669,6 +706,7 @@ void AddSC_priest_spell_scripts() new spell_pri_divine_aegis(); new spell_pri_glyph_of_prayer_of_healing(); new spell_pri_guardian_spirit(); + new spell_pri_item_greater_heal_refund(); new spell_pri_lightwell_renew(); new spell_pri_mana_burn(); new spell_pri_mana_leech(); diff --git a/src/server/scripts/Spells/spell_shaman.cpp b/src/server/scripts/Spells/spell_shaman.cpp index 69e02a37272..3a02a8b8c09 100644 --- a/src/server/scripts/Spells/spell_shaman.cpp +++ b/src/server/scripts/Spells/spell_shaman.cpp @@ -41,6 +41,9 @@ enum ShamanSpells SPELL_SHAMAN_GLYPH_OF_HEALING_STREAM_TOTEM = 55456, SPELL_SHAMAN_GLYPH_OF_MANA_TIDE = 55441, SPELL_SHAMAN_GLYPH_OF_THUNDERSTORM = 62132, + SPELL_SHAMAN_ITEM_LIGHTNING_SHIELD = 23552, + SPELL_SHAMAN_ITEM_LIGHTNING_SHIELD_DAMAGE = 27635, + SPELL_SHAMAN_ITEM_MANA_SURGE = 23571, SPELL_SHAMAN_LAVA_FLOWS_R1 = 51480, SPELL_SHAMAN_LAVA_FLOWS_TRIGGERED_R1 = 64694, SPELL_SHAMAN_MANA_SPRING_TOTEM_ENERGIZE = 52032, @@ -55,8 +58,8 @@ enum ShamanSpells enum ShamanSpellIcons { - SHAMAN_ICON_ID_RESTORATIVE_TOTEMS = 338, - SHAMAN_ICON_ID_SHAMAN_LAVA_FLOW = 3087 + SHAMAN_ICON_ID_RESTORATIVE_TOTEMS = 338, + SHAMAN_ICON_ID_SHAMAN_LAVA_FLOW = 3087 }; // 52759 - Ancestral Awakening (Proc) @@ -128,8 +131,8 @@ class spell_sha_astral_shift : public SpellScriptLoader void Register() OVERRIDE { - DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_sha_astral_shift_AuraScript::CalculateAmount, EFFECT_0, SPELL_AURA_SCHOOL_ABSORB); - OnEffectAbsorb += AuraEffectAbsorbFn(spell_sha_astral_shift_AuraScript::Absorb, EFFECT_0); + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_sha_astral_shift_AuraScript::CalculateAmount, EFFECT_0, SPELL_AURA_SCHOOL_ABSORB); + OnEffectAbsorb += AuraEffectAbsorbFn(spell_sha_astral_shift_AuraScript::Absorb, EFFECT_0); } }; @@ -302,17 +305,22 @@ class spell_sha_earth_shield : public SpellScriptLoader } } - void HandleProc(AuraEffect const* aurEff, ProcEventInfo& /*eventInfo*/) + bool CheckProc(ProcEventInfo& /*eventInfo*/) { - PreventDefaultAction(); - //! HACK due to currenct proc system implementation if (Player* player = GetTarget()->ToPlayer()) if (player->HasSpellCooldown(SPELL_SHAMAN_EARTH_SHIELD_HEAL)) - return; + return false; + return true; + } + + void HandleProc(AuraEffect const* aurEff, ProcEventInfo& /*eventInfo*/) + { + PreventDefaultAction(); GetTarget()->CastCustomSpell(SPELL_SHAMAN_EARTH_SHIELD_HEAL, SPELLVALUE_BASE_POINT0, aurEff->GetAmount(), GetTarget(), true, NULL, aurEff, GetCasterGUID()); + /// @hack: due to currenct proc system implementation if (Player* player = GetTarget()->ToPlayer()) player->AddSpellCooldown(SPELL_SHAMAN_EARTH_SHIELD_HEAL, 0, time(NULL) + 3); } @@ -320,6 +328,7 @@ class spell_sha_earth_shield : public SpellScriptLoader void Register() OVERRIDE { DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_sha_earth_shield_AuraScript::CalculateAmount, EFFECT_0, SPELL_AURA_DUMMY); + DoCheckProc += AuraCheckProcFn(spell_sha_earth_shield_AuraScript::CheckProc); OnEffectProc += AuraEffectProcFn(spell_sha_earth_shield_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_DUMMY); } }; @@ -441,10 +450,11 @@ class spell_sha_fire_nova : public SpellScriptLoader bool Validate(SpellInfo const* spellInfo) OVERRIDE { - if (!sSpellMgr->GetSpellInfo(SPELL_SHAMAN_FIRE_NOVA_R1) || sSpellMgr->GetFirstSpellInChain(SPELL_SHAMAN_FIRE_NOVA_R1) != sSpellMgr->GetFirstSpellInChain(spellInfo->Id)) + SpellInfo const* firstRankSpellInfo = sSpellMgr->GetSpellInfo(SPELL_SHAMAN_FIRE_NOVA_R1); + if (!firstRankSpellInfo || !spellInfo->IsRankOf(firstRankSpellInfo)) return false; - uint8 rank = sSpellMgr->GetSpellRank(spellInfo->Id); + uint8 rank = spellInfo->GetRank(); if (!sSpellMgr->GetSpellWithRank(SPELL_SHAMAN_FIRE_NOVA_TRIGGERED_R1, rank, true)) return false; return true; @@ -464,15 +474,12 @@ class spell_sha_fire_nova : public SpellScriptLoader void HandleDummy(SpellEffIndex /*effIndex*/) { - if (Unit* caster = GetCaster()) + Unit* caster = GetCaster(); + if (Creature* totem = caster->GetMap()->GetCreature(caster->m_SummonSlot[1])) { - uint8 rank = sSpellMgr->GetSpellRank(GetSpellInfo()->Id); - if (uint32 spellId = sSpellMgr->GetSpellWithRank(SPELL_SHAMAN_FIRE_NOVA_TRIGGERED_R1, rank)) - { - Creature* totem = caster->GetMap()->GetCreature(caster->m_SummonSlot[1]); - if (totem && totem->IsTotem()) - caster->CastSpell(totem, spellId, true); - } + uint8 rank = GetSpellInfo()->GetRank(); + if (totem->IsTotem()) + caster->CastSpell(totem, sSpellMgr->GetSpellWithRank(SPELL_SHAMAN_FIRE_NOVA_TRIGGERED_R1, rank), true); } } @@ -514,10 +521,11 @@ class spell_sha_flame_shock : public SpellScriptLoader // Lava Flows if (AuraEffect const* aurEff = caster->GetDummyAuraEffect(SPELLFAMILY_SHAMAN, SHAMAN_ICON_ID_SHAMAN_LAVA_FLOW, EFFECT_0)) { - if (sSpellMgr->GetFirstSpellInChain(SPELL_SHAMAN_LAVA_FLOWS_R1) != sSpellMgr->GetFirstSpellInChain(aurEff->GetId())) + SpellInfo const* firstRankSpellInfo = sSpellMgr->GetSpellInfo(SPELL_SHAMAN_LAVA_FLOWS_R1); + if (!aurEff->GetSpellInfo()->IsRankOf(firstRankSpellInfo)) return; - uint8 rank = sSpellMgr->GetSpellRank(aurEff->GetId()); + uint8 rank = aurEff->GetSpellInfo()->GetRank(); caster->CastSpell(caster, sSpellMgr->GetSpellWithRank(SPELL_SHAMAN_LAVA_FLOWS_TRIGGERED_R1, rank), true); } } @@ -632,6 +640,120 @@ class spell_sha_heroism : public SpellScriptLoader } }; +// 23551 - Lightning Shield +class spell_sha_item_lightning_shield : public SpellScriptLoader +{ + public: + spell_sha_item_lightning_shield() : SpellScriptLoader("spell_sha_item_lightning_shield") { } + + class spell_sha_item_lightning_shield_AuraScript : public AuraScript + { + PrepareAuraScript(spell_sha_item_lightning_shield_AuraScript); + + bool Validate(SpellInfo const* /*spellInfo*/) OVERRIDE + { + if (!sSpellMgr->GetSpellInfo(SPELL_SHAMAN_ITEM_LIGHTNING_SHIELD)) + return false; + return true; + } + + void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo) + { + PreventDefaultAction(); + GetTarget()->CastSpell(eventInfo.GetProcTarget(), SPELL_SHAMAN_ITEM_LIGHTNING_SHIELD, true, NULL, aurEff); + } + + void Register() OVERRIDE + { + OnEffectProc += AuraEffectProcFn(spell_sha_item_lightning_shield_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_PROC_TRIGGER_SPELL); + } + }; + + AuraScript* GetAuraScript() const OVERRIDE + { + return new spell_sha_item_lightning_shield_AuraScript(); + } +}; + +// 23552 - Lightning Shield +class spell_sha_item_lightning_shield_trigger : public SpellScriptLoader +{ + public: + spell_sha_item_lightning_shield_trigger() : SpellScriptLoader("spell_sha_item_lightning_shield_trigger") { } + + class spell_sha_item_lightning_shield_trigger_AuraScript : public AuraScript + { + PrepareAuraScript(spell_sha_item_lightning_shield_trigger_AuraScript); + + bool Validate(SpellInfo const* /*spellInfo*/) OVERRIDE + { + if (!sSpellMgr->GetSpellInfo(SPELL_SHAMAN_ITEM_MANA_SURGE)) + return false; + return true; + } + + void HandleProc(AuraEffect const* aurEff, ProcEventInfo& /*eventInfo*/) + { + PreventDefaultAction(); + GetTarget()->CastSpell(GetTarget(), SPELL_SHAMAN_ITEM_LIGHTNING_SHIELD_DAMAGE, true, NULL, aurEff); + } + + void Register() OVERRIDE + { + OnEffectProc += AuraEffectProcFn(spell_sha_item_lightning_shield_trigger_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_PROC_TRIGGER_SPELL); + } + }; + + AuraScript* GetAuraScript() const OVERRIDE + { + return new spell_sha_item_lightning_shield_trigger_AuraScript(); + } +}; + +// 23572 - Mana Surge +class spell_sha_item_mana_surge : public SpellScriptLoader +{ + public: + spell_sha_item_mana_surge() : SpellScriptLoader("spell_sha_item_mana_surge") { } + + class spell_sha_item_mana_surge_AuraScript : public AuraScript + { + PrepareAuraScript(spell_sha_item_mana_surge_AuraScript); + + bool Validate(SpellInfo const* /*spellInfo*/) OVERRIDE + { + if (!sSpellMgr->GetSpellInfo(SPELL_SHAMAN_ITEM_LIGHTNING_SHIELD_DAMAGE)) + return false; + return true; + } + + bool CheckProc(ProcEventInfo& eventInfo) + { + return eventInfo.GetDamageInfo()->GetSpellInfo(); + } + + void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo) + { + PreventDefaultAction(); + int32 mana = eventInfo.GetDamageInfo()->GetSpellInfo()->CalcPowerCost(GetTarget(), eventInfo.GetSchoolMask()); + int32 damage = CalculatePct(mana, 35); + + GetTarget()->CastCustomSpell(SPELL_SHAMAN_ITEM_MANA_SURGE, SPELLVALUE_BASE_POINT0, damage, GetTarget(), true, NULL, aurEff); + } + + void Register() OVERRIDE + { + DoCheckProc += AuraCheckProcFn(spell_sha_item_mana_surge_AuraScript::CheckProc); + OnEffectProc += AuraEffectProcFn(spell_sha_item_mana_surge_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_PROC_TRIGGER_SPELL); + } + }; + + AuraScript* GetAuraScript() const OVERRIDE + { + return new spell_sha_item_mana_surge_AuraScript(); + } +}; + // 60103 - Lava Lash class spell_sha_lava_lash : public SpellScriptLoader { @@ -851,6 +973,9 @@ void AddSC_shaman_spell_scripts() new spell_sha_flame_shock(); new spell_sha_healing_stream_totem(); new spell_sha_heroism(); + new spell_sha_item_lightning_shield(); + new spell_sha_item_lightning_shield_trigger(); + new spell_sha_item_mana_surge(); new spell_sha_lava_lash(); new spell_sha_mana_spring_totem(); new spell_sha_mana_tide_totem(); diff --git a/src/server/scripts/Spells/spell_warlock.cpp b/src/server/scripts/Spells/spell_warlock.cpp index be060e32030..e6bfe3472cb 100644 --- a/src/server/scripts/Spells/spell_warlock.cpp +++ b/src/server/scripts/Spells/spell_warlock.cpp @@ -38,15 +38,16 @@ enum WarlockSpells SPELL_WARLOCK_DEMONIC_EMPOWERMENT_FELHUNTER = 54509, SPELL_WARLOCK_DEMONIC_EMPOWERMENT_IMP = 54444, SPELL_WARLOCK_FEL_SYNERGY_HEAL = 54181, + SPELL_WARLOCK_GLYPH_OF_SHADOWFLAME = 63311, SPELL_WARLOCK_GLYPH_OF_SIPHON_LIFE = 63106, + SPELL_WARLOCK_HAUNT = 48181, + SPELL_WARLOCK_HAUNT_HEAL = 48210, SPELL_WARLOCK_IMPROVED_HEALTHSTONE_R1 = 18692, SPELL_WARLOCK_IMPROVED_HEALTHSTONE_R2 = 18693, SPELL_WARLOCK_IMPROVED_HEALTH_FUNNEL_R1 = 18703, SPELL_WARLOCK_IMPROVED_HEALTH_FUNNEL_R2 = 18704, SPELL_WARLOCK_IMPROVED_HEALTH_FUNNEL_BUFF_R1 = 60955, SPELL_WARLOCK_IMPROVED_HEALTH_FUNNEL_BUFF_R2 = 60956, - SPELL_WARLOCK_HAUNT = 48181, - SPELL_WARLOCK_HAUNT_HEAL = 48210, SPELL_WARLOCK_LIFE_TAP_ENERGIZE = 31818, SPELL_WARLOCK_LIFE_TAP_ENERGIZE_2 = 32553, SPELL_WARLOCK_SOULSHATTER = 32835, @@ -135,7 +136,7 @@ class spell_warl_create_healthstone : public SpellScriptLoader { if (Player* caster = GetCaster()->ToPlayer()) { - uint8 spellRank = sSpellMgr->GetSpellRank(GetSpellInfo()->Id); + uint8 spellRank = GetSpellInfo()->GetRank(); ItemPosCountVec dest; InventoryResult msg = caster->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, iTypes[spellRank - 1][0], 1, NULL); if (msg != EQUIP_ERR_OK) @@ -165,7 +166,7 @@ class spell_warl_create_healthstone : public SpellScriptLoader break; } } - uint8 spellRank = sSpellMgr->GetSpellRank(GetSpellInfo()->Id); + uint8 spellRank = GetSpellInfo()->GetRank(); if (spellRank > 0 && spellRank <= 8) CreateItem(effIndex, iTypes[spellRank - 1][rank]); } @@ -205,7 +206,7 @@ class spell_warl_curse_of_doom : public SpellScriptLoader { PrepareAuraScript(spell_warl_curse_of_doom_AuraScript); - bool Validate(SpellInfo const* /*spell*/) OVERRIDE + bool Validate(SpellInfo const* /*spellInfo*/) OVERRIDE { if (!sSpellMgr->GetSpellInfo(SPELL_WARLOCK_CURSE_OF_DOOM_EFFECT)) return false; @@ -242,7 +243,7 @@ class spell_warl_curse_of_doom : public SpellScriptLoader } }; -// 48018 - Demonic Circle Summon +// 48018 - Demonic Circle: Summon class spell_warl_demonic_circle_summon : public SpellScriptLoader { public: @@ -294,7 +295,7 @@ class spell_warl_demonic_circle_summon : public SpellScriptLoader } }; -// 48020 - Demonic Circle Teleport +// 48020 - Demonic Circle: Teleport class spell_warl_demonic_circle_teleport : public SpellScriptLoader { public: @@ -464,6 +465,41 @@ class spell_warl_fel_synergy : public SpellScriptLoader } }; +// 63310 - Glyph of Shadowflame +class spell_warl_glyph_of_shadowflame : public SpellScriptLoader +{ + public: + spell_warl_glyph_of_shadowflame() : SpellScriptLoader("spell_warl_glyph_of_shadowflame") { } + + class spell_warl_glyph_of_shadowflame_AuraScript : public AuraScript + { + PrepareAuraScript(spell_warl_glyph_of_shadowflame_AuraScript); + + bool Validate(SpellInfo const* /*spellInfo*/) OVERRIDE + { + if (!sSpellMgr->GetSpellInfo(SPELL_WARLOCK_GLYPH_OF_SHADOWFLAME)) + return false; + return true; + } + + void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo) + { + PreventDefaultAction(); + GetTarget()->CastSpell(eventInfo.GetProcTarget(), SPELL_WARLOCK_GLYPH_OF_SHADOWFLAME, true, NULL, aurEff); + } + + void Register() OVERRIDE + { + OnEffectProc += AuraEffectProcFn(spell_warl_glyph_of_shadowflame_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_DUMMY); + } + }; + + AuraScript* GetAuraScript() const OVERRIDE + { + return new spell_warl_glyph_of_shadowflame_AuraScript(); + } +}; + // -48181 - Haunt class spell_warl_haunt : public SpellScriptLoader { @@ -491,7 +527,7 @@ class spell_warl_haunt : public SpellScriptLoader { PrepareAuraScript(spell_warl_haunt_AuraScript); - bool Validate(SpellInfo const* /*spell*/) OVERRIDE + bool Validate(SpellInfo const* /*spellInfo*/) OVERRIDE { if (!sSpellMgr->GetSpellInfo(SPELL_WARLOCK_HAUNT_HEAL)) return false; @@ -753,7 +789,7 @@ class spell_warl_siphon_life : public SpellScriptLoader bool CheckProc(ProcEventInfo& eventInfo) { - return eventInfo.GetDamageInfo()->GetDamage(); + return eventInfo.GetDamageInfo()->GetDamage() && GetTarget()->IsAlive(); } void OnProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo) @@ -791,7 +827,7 @@ class spell_warl_soulshatter : public SpellScriptLoader { PrepareSpellScript(spell_warl_soulshatter_SpellScript); - bool Validate(SpellInfo const* /*spell*/) OVERRIDE + bool Validate(SpellInfo const* /*spellInfo*/) OVERRIDE { if (!sSpellMgr->GetSpellInfo(SPELL_WARLOCK_SOULSHATTER)) return false; @@ -830,7 +866,7 @@ class spell_warl_unstable_affliction : public SpellScriptLoader { PrepareAuraScript(spell_warl_unstable_affliction_AuraScript); - bool Validate(SpellInfo const* /*spell*/) OVERRIDE + bool Validate(SpellInfo const* /*spellInfo*/) OVERRIDE { if (!sSpellMgr->GetSpellInfo(SPELL_WARLOCK_UNSTABLE_AFFLICTION_DISPEL)) return false; @@ -870,6 +906,7 @@ void AddSC_warlock_spell_scripts() new spell_warl_demonic_empowerment(); new spell_warl_everlasting_affliction(); new spell_warl_fel_synergy(); + new spell_warl_glyph_of_shadowflame(); new spell_warl_haunt(); new spell_warl_health_funnel(); new spell_warl_life_tap(); diff --git a/src/server/scripts/Spells/spell_warrior.cpp b/src/server/scripts/Spells/spell_warrior.cpp index 9e7ca75890f..78dcaaa669c 100644 --- a/src/server/scripts/Spells/spell_warrior.cpp +++ b/src/server/scripts/Spells/spell_warrior.cpp @@ -50,8 +50,11 @@ enum WarriorSpells SPELL_WARRIOR_UNRELENTING_ASSAULT_TRIGGER_1 = 64849, SPELL_WARRIOR_UNRELENTING_ASSAULT_TRIGGER_2 = 64850, SPELL_WARRIOR_VIGILANCE_PROC = 50725, - SPELL_WARRIOR_VIGILANCE_REDIRECT_THREAT = 59665, + SPELL_WARRIOR_VIGILANCE_REDIRECT_THREAT = 59665 +}; +enum MiscSpells +{ SPELL_PALADIN_BLESSING_OF_SANCTUARY = 20911, SPELL_PALADIN_GREATER_BLESSING_OF_SANCTUARY = 25899, SPELL_PRIEST_RENEWED_HOPE = 63944, @@ -60,7 +63,7 @@ enum WarriorSpells enum WarriorSpellIcons { - WARRIOR_ICON_ID_SUDDEN_DEATH = 1989, + WARRIOR_ICON_ID_SUDDEN_DEATH = 1989 }; // 23881 - Bloodthirst @@ -264,7 +267,7 @@ class spell_warr_deep_wounds : public SpellScriptLoader // apply percent damage mods damage = caster->SpellDamageBonusDone(target, GetSpellInfo(), damage, SPELL_DIRECT_DAMAGE); - ApplyPct(damage, 16 * sSpellMgr->GetSpellRank(GetSpellInfo()->Id)); + ApplyPct(damage, 16 * GetSpellInfo()->GetRank()); damage = target->SpellDamageBonusTaken(caster, GetSpellInfo(), damage, SPELL_DIRECT_DAMAGE); @@ -424,11 +427,9 @@ class spell_warr_last_stand : public SpellScriptLoader void HandleDummy(SpellEffIndex /*effIndex*/) { - if (Unit* caster = GetCaster()) - { - int32 healthModSpellBasePoints0 = int32(caster->CountPctFromMaxHealth(30)); - caster->CastCustomSpell(caster, SPELL_WARRIOR_LAST_STAND_TRIGGERED, &healthModSpellBasePoints0, NULL, NULL, true, NULL); - } + Unit* caster = GetCaster(); + int32 healthModSpellBasePoints0 = int32(caster->CountPctFromMaxHealth(GetEffectValue())); + caster->CastCustomSpell(caster, SPELL_WARRIOR_LAST_STAND_TRIGGERED, &healthModSpellBasePoints0, NULL, NULL, true, NULL); } void Register() OVERRIDE diff --git a/src/server/shared/Database/Implementation/CharacterDatabase.cpp b/src/server/shared/Database/Implementation/CharacterDatabase.cpp index 427ccfd5ebf..7e237614f62 100644 --- a/src/server/shared/Database/Implementation/CharacterDatabase.cpp +++ b/src/server/shared/Database/Implementation/CharacterDatabase.cpp @@ -105,7 +105,7 @@ void CharacterDatabaseConnection::DoPrepareStatements() PrepareStatement(CHAR_SEL_CHARACTER_SPELLCOOLDOWNS, "SELECT spell, item, time FROM character_spell_cooldown WHERE guid = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_SEL_CHARACTER_DECLINEDNAMES, "SELECT genitive, dative, accusative, instrumental, prepositional FROM character_declinedname WHERE guid = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_SEL_GUILD_MEMBER, "SELECT guildid, rank FROM guild_member WHERE guid = ?", CONNECTION_BOTH); - PrepareStatement(CHAR_SEL_GUILD_MEMBER_EXTENDED, "SELECT g.guildid, g.name, gr.rname, gm.pnote, gm.offnote " + PrepareStatement(CHAR_SEL_GUILD_MEMBER_EXTENDED, "SELECT g.guildid, g.name, gr.rname, gr.rid, gm.pnote, gm.offnote " "FROM guild g JOIN guild_member gm ON g.guildid = gm.guildid " "JOIN guild_rank gr ON g.guildid = gr.guildid AND gm.rank = gr.rid WHERE gm.guid = ?", CONNECTION_BOTH); PrepareStatement(CHAR_SEL_CHARACTER_ACHIEVEMENTS, "SELECT achievement, date FROM character_achievement WHERE guid = ?", CONNECTION_ASYNC); |
