diff options
24 files changed, 393 insertions, 207 deletions
diff --git a/dep/PackageList.txt b/dep/PackageList.txt index 4f52dfca906..f932591ae32 100644 --- a/dep/PackageList.txt +++ b/dep/PackageList.txt @@ -30,7 +30,7 @@ SFMT (SIMD-oriented Fast Mersenne Twister) utf8-cpp (UTF-8 with C++ in a Portable Way) http://utfcpp.sourceforge.net/ - Version: 2.3.2 + Version: 2.3.4 zlib (A Massively Spiffy Yet Delicately Unobtrusive Compression Library) http://www.zlib.net/ diff --git a/dep/utf8cpp/utf8/checked.h b/dep/utf8cpp/utf8/checked.h index 3b00644444c..13311551381 100644 --- a/dep/utf8cpp/utf8/checked.h +++ b/dep/utf8cpp/utf8/checked.h @@ -109,13 +109,13 @@ namespace utf8 case internal::NOT_ENOUGH_ROOM: throw not_enough_room(); case internal::INVALID_LEAD: - utf8::append (replacement, out); + out = utf8::append (replacement, out); ++start; break; case internal::INCOMPLETE_SEQUENCE: case internal::OVERLONG_SEQUENCE: case internal::INVALID_CODE_POINT: - utf8::append (replacement, out); + out = utf8::append (replacement, out); ++start; // just one replacement mark for the sequence while (start != end && utf8::internal::is_trail(*start)) @@ -270,7 +270,7 @@ namespace utf8 octet_iterator range_start; octet_iterator range_end; public: - iterator () {}; + iterator () {} explicit iterator (const octet_iterator& octet_it, const octet_iterator& range_start, const octet_iterator& range_end) : diff --git a/dep/utf8cpp/utf8/unchecked.h b/dep/utf8cpp/utf8/unchecked.h index b4547fad945..cb2427166b1 100644 --- a/dep/utf8cpp/utf8/unchecked.h +++ b/dep/utf8cpp/utf8/unchecked.h @@ -179,7 +179,7 @@ namespace utf8 class iterator : public std::iterator <std::bidirectional_iterator_tag, uint32_t> { octet_iterator it; public: - iterator () {}; + iterator () {} explicit iterator (const octet_iterator& octet_it): it(octet_it) {} // the default "big three" are OK octet_iterator base () const { return it; } diff --git a/sql/updates/world/2013_07_20_00_world_gameonject.sql b/sql/updates/world/2013_07_20_00_world_gameonject.sql new file mode 100644 index 00000000000..7262b76ffef --- /dev/null +++ b/sql/updates/world/2013_07_20_00_world_gameonject.sql @@ -0,0 +1,15 @@ +-- DTK instance entrance portals +DELETE FROM `gameobject` WHERE `guid`=151225; +SET @OGUID := 6120; -- (need 3) +DELETE FROM `gameobject` WHERE `guid` BETWEEN @OGUID+0 AND @OGUID+2; +INSERT INTO `gameobject` (`guid`,`id`,`map`,`spawnMask`,`phaseMask`,`position_x`,`position_y`,`position_z`,`orientation`,`rotation0`,`rotation1`,`rotation2`,`rotation3`,`spawntimesecs`,`animprogress`,`state`) VALUES +(@OGUID+0,192585,571,1,1,4774.532,-2020.723,232.3105,-1.579522,0,0,0.9999905,0.004363241,120,255,1), +(@OGUID+1,192776,571,1,1,4774.532,-2020.723,232.3105,-1.579522,0,0,0.9999905,0.004363241,120,255,1), +(@OGUID+2,192775,571,1,1,4774.532,-2020.723,232.3105,-1.579522,0,0,0.9999905,0.004363241,120,255,1); + +-- Gundrak south instance entrance portals +SET @OGUID := 5287; -- (need 2) +DELETE FROM `gameobject` WHERE `guid` BETWEEN @OGUID+0 AND @OGUID+1; +INSERT INTO `gameobject` (`guid`,`id`,`map`,`spawnMask`,`phaseMask`,`position_x`,`position_y`,`position_z`,`orientation`,`rotation0`,`rotation1`,`rotation2`,`rotation3`,`spawntimesecs`,`animprogress`,`state`) VALUES +(@OGUID+0,192635,571,1,1,6700.195,-4662.38,446.7864,3.909541,0,0,0.3746067,0.9271838,120,255,1), +(@OGUID+1,192170,571,1,1,6700.195,-4662.38,446.7864,3.909541,0,0,0.3746067,0.9271838,120,255,1); diff --git a/sql/updates/world/2013_07_20_01_world_misc.sql b/sql/updates/world/2013_07_20_01_world_misc.sql new file mode 100644 index 00000000000..273d9070930 --- /dev/null +++ b/sql/updates/world/2013_07_20_01_world_misc.sql @@ -0,0 +1,170 @@ +/* + # Collection of Feedback-PatchFixes / 20.07.2013 + # + # Including sql codestyle updates and check for accuracy. (one by one) + # by FireEmerald / Thx @DDuarte for the base pull request. + # + # Including: + # DB/Spell: Update: Correct Spell Power Coefficient (107.43%) for Tranquility | by lendan (@6232) + # DB/LOS: Add: Ignore LOS for Ignite Horde Siege Engine | by dr-j (@6718) + # DB/SmartAI: Update: Correct casted spell by Defias Rogue Wizard | by Rochet2 (@9976) + # DB/Quest: Fix: Bloody Imp-ossible! (10924) | by Kirkhammett (@10276) + # DB/Quest: Fix: Mistcaller Yngvar (14102) / Add missing event script and conditions. | (@3563) + # DB/SmartAI: Update: Give quest credit for The Ring of Blood: The Final Challenge (9977) | by JunkyBulgaria (@7724) + # DB/Waypoints: Add: Missing waypoints for Mmmrrrggglll | by Hobbilis (@9602) + # DB/Conditions: Add: Missing conditions for Displacing Temporal Rift | by FireEmerald +*/ + +-- DB/Spell: Update: Correct Spell Power Coefficient (107.43%) for Tranquility | by lendan (@6232) +SET @SPELL := 44203; -- Tranquility + +UPDATE `spell_bonus_data` SET `direct_bonus` = 1.0743 WHERE `entry` = @SPELL; + +-- DB/Quest: Fix: A Dire Situation (10506) | by Rohlik & Exodius (@6283) +SET @WOLF := 20058; -- Bloodmaul Dire Wolf +SET @SPELL_INVIS := 18950; -- Invisibility and Stealth Detection +SET @WOLF_TRIGGER := 21176; -- Bloodmaul Dire Wolf Trigger +SET @SPELL_POWDER := 36310; -- Rina's Diminution Powder + +DELETE FROM `creature_ai_scripts` WHERE `creature_id` = @WOLF; +UPDATE `creature_template` SET `AIName` = 'SmartAI' WHERE `entry` = @WOLF; + +DELETE FROM `smart_scripts` WHERE `entryorguid` = @WOLF AND `source_type` = 0; +INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES +(@WOLF, 0, 0, 0, 54, 0, 100, 0, 0, 0, 0, 0, 75, @SPELL_INVIS, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 'Bloodmaul Dire Wolf - On spawn - Add Invisibility and Stealth Detection Aura on self'); + +DELETE FROM `event_scripts` WHERE `id` = 13584; +INSERT INTO `event_scripts` (`id`, `delay`, `command`, `datalong`) VALUES +(13584, 2, 8, @WOLF_TRIGGER); + +DELETE FROM `conditions` WHERE `SourceTypeOrReferenceId` = 17 AND `SourceEntry` = @SPELL_POWDER; +INSERT INTO `conditions` (`SourceTypeOrReferenceId`,`SourceGroup`,`SourceEntry`,`ElseGroup`,`ConditionTypeOrReference`,`ConditionTarget`,`ConditionValue1`,`ConditionValue2`,`ConditionValue3`,`NegativeCondition`,`ErrorTextId`,`ScriptName`,`Comment`) VALUES +(17,0,@SPELL_POWDER,0,31,1,3,@WOLF,0,0,0,'', 'Rina''s Diminution Powder can be used only on Bloodmaul Dire Wolf'); + +-- DB/LOS: Add: Ignore LOS for Ignite Horde Siege Engine | by dr-j (@6718) +SET @IGNITE := 32979; -- Ignite Horde Siege Engine + +DELETE FROM `disables` WHERE `sourceType` = 0 AND `entry` = @IGNITE; +INSERT INTO `disables`(`sourceType`,`entry`,`flags`,`comment`) VALUES +(0,@IGNITE,64,'Ignore LOS on Ignite Horde Siege Engine'); + +-- DB/SmartAI: Update: Correct casted spell by Defias Rogue Wizard | by Rochet2 (@9976) +SET @WIZARD := 474; -- Rogue Wizard +SET @SPELL := 13322; -- Frostbolt + +UPDATE `smart_scripts` SET `action_param2`= @SPELL WHERE `entryorguid` = @WIZARD AND `source_type` = 0 AND `id` = 0 AND `link` = 0; + +-- DB/Quest: Fix: Bloody Imp-ossible! (10924) | by Kirkhammett (@10276) +SET @CHASER := 18884; -- Warp Chaser +SET @ZEPPIT := 22484; -- Zeppit +SET @SPELL_INVIS := 32942; -- Phasing Invisibility +SET @SPELL_CHARGE := 37417; -- Warp Charge +SET @SPELL_BITE := 32739; -- Venomous Bite +SET @SPELL_BLOOD := 39244; -- Gather Warp Chaser Blood + +UPDATE `creature_template` SET `AIName` = 'SmartAI' WHERE `entry` = @CHASER; +DELETE FROM `creature_ai_scripts` WHERE `creature_id` = @CHASER; + +DELETE FROM `smart_scripts` WHERE `entryorguid` = @CHASER; +INSERT INTO `smart_scripts` (`entryorguid`,`source_type`,`id`,`link`,`event_type`,`event_phase_mask`,`event_chance`,`event_flags`,`event_param1`,`event_param2`,`event_param3`,`event_param4`,`action_type`,`action_param1`,`action_param2`,`action_param3`,`action_param4`,`action_param5`,`action_param6`,`target_type`,`target_param1`,`target_param2`,`target_param3`,`target_x`,`target_y`,`target_z`,`target_o`,`comment`) VALUES +(@CHASER,0,0,0,11,0,100,0,0,0,0,0,11,@SPELL_INVIS,0,0,0,0,0,1,0,0,0,0,0,0,0, 'Warp Chaser - On Spawn - Cast Phasing Invisibility'), +(@CHASER,0,1,0,0,0,100,0,500,2000,7000,15000,11,@SPELL_CHARGE,0,0,0,0,0,2,0,0,0,0,0,0,0, 'Warp Chaser - In Combat - Cast Charge'), +(@CHASER,0,2,0,0,0,100,0,3000,5000,10000,15000,11,@SPELL_BITE,0,0,0,0,0,2,0,0,0,0,0,0,0, 'Warp Chaser - In Combat - Cast Venomous Bite'), +(@CHASER,0,3,0,6,0,100,0,0,0,0,0,45,1,1,0,0,0,0,19,@ZEPPIT,10,0,0,0,0,0, 'Warp Chaser - On Death - Set Data on Zeppit'); + +UPDATE `creature_template` SET `AIName` = 'SmartAI' WHERE `entry` = @ZEPPIT; +DELETE FROM `creature_ai_scripts` WHERE `creature_id` = @ZEPPIT; + +DELETE FROM `smart_scripts` WHERE `entryorguid` = @ZEPPIT; +INSERT INTO `smart_scripts` (`entryorguid`,`source_type`,`id`,`link`,`event_type`,`event_phase_mask`,`event_chance`,`event_flags`,`event_param1`,`event_param2`,`event_param3`,`event_param4`,`action_type`,`action_param1`,`action_param2`,`action_param3`,`action_param4`,`action_param5`,`action_param6`,`target_type`,`target_param1`,`target_param2`,`target_param3`,`target_x`,`target_y`,`target_z`,`target_o`,`comment`) VALUES +(@ZEPPIT,0,0,0,38,0,100,0,1,1,0,0,11,@SPELL_BLOOD,0,0,0,0,0,21,10,0,0,0,0,0,0, 'Zeppit - On Data Set - Cast on Master'); + +-- DB/Quest: Fix: Mistcaller Yngvar (14102) / Add missing event script and conditions. | (@3563) +SET @ENTRY := 34965; -- Mistcaller Yngvar +SET @SPELL := 66621; -- Summon the Mistcaller +SET @QUEST := 14102; -- Mistcaller Yngvar (Quest) + +DELETE FROM `event_scripts` WHERE `id` = 21997 AND `command` = 10; +INSERT INTO `event_scripts` (`id`,`delay`,`command`,`datalong`,`datalong2`,`dataint`,`x`,`y`,`z`,`o`) VALUES +(21997, 2, 10, @ENTRY, 120000, 0, 10181.96, 1183.417, 76.12115, 5.934119); + +DELETE FROM `conditions` WHERE `SourceTypeOrReferenceId` = 17 AND `SourceEntry` = @SPELL; +INSERT INTO `conditions` (SourceTypeOrReferenceId, SourceGroup, SourceEntry, SourceId, ElseGroup, ConditionTypeOrReference, ConditionValue1, ConditionValue2, ConditionValue3, NegativeCondition, ErrorType, comment ) VALUES +(17, 0, @SPELL, 0, 0, 29, @ENTRY, 40, 0, 1, 0, "Cant use Mistcallers Charm within 40 yards of Yngvar"), +(17, 0, @SPELL, 0, 0, 28, @QUEST, 0, 0, 1, 0, "Cant use Mistcallers Charm, if player has quest objective completed, but not yet rewarded."); + +-- DB/SmartAI: Update: Give quest credit for The Ring of Blood: The Final Challenge (9977) | by JunkyBulgaria (@7724) +SET @MOGOR := 18069; -- Mogor <Hero of the Warmaul> +SET @QUEST := 9977; -- The Ring of Blood: The Final Challenge + +DELETE FROM `smart_scripts` WHERE `entryorguid` = @MOGOR AND `source_type` = 0 AND `id` = 14; +INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES +(@MOGOR, 0, 14, 0, 6, 0, 100, 1, 0, 0, 0, 0, 15, @QUEST, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 'Mogor - On Death - Give Quest Credit'); + +-- DB/Waypoints: Add: Missing waypoints for Mmmrrrggglll | by Hobbilis (@9602) +SET @MURLOC := 15937; -- Mmmrrrggglll +SET @GUID := 41792; +SET @PATH := 417920; + +-- Set creature location +UPDATE `creature` SET `MovementType`=2,`position_x`=8869.872,`position_y`=-5775.960,`position_z`=0.405, `spawnDist`=0, `currentwaypoint`=1 WHERE `guid`=@GUID; +DELETE FROM `creature_addon` WHERE `guid`=@GUID; +INSERT INTO `creature_addon` (`guid`, `path_id`, `bytes2`) VALUES (@GUID, @PATH, 1); + +-- Waypoint Data +DELETE FROM `waypoint_data` WHERE `id`=@PATH; +INSERT INTO `waypoint_data` (`id`,`point`,`position_x`,`position_y`,`position_z`,`orientation`,`delay`,`move_flag`,`action`,`action_chance`,`wpguid`) VALUES +(@PATH, 1, 8880.688, -5754.608, 0.25531, 0, 0, 0, 0, 100, 0), +(@PATH, 2, 8873.341, -5735.012, 0.43308, 0, 0, 0, 0, 100, 0), +(@PATH, 3, 8862.790, -5722.625, 0.42263, 0, 0, 0, 0, 100, 0), +(@PATH, 4, 8846.429, -5720.661, 0.49396, 0, 0, 0, 0, 100, 0), +(@PATH, 5, 8836.920, -5726.737, 0.83736, 0, 0, 0, 0, 100, 0), +(@PATH, 6, 8828.789, -5743.622, 0.82590, 0, 0, 0, 0, 100, 0), +(@PATH, 7, 8818.041, -5755.890, 0.64673, 0, 0, 0, 0, 100, 0), +(@PATH, 8, 8804.548, -5762.792, 0.51199, 0, 0, 0, 0, 100, 0), +(@PATH, 9, 8791.789, -5762.271, 0.45083, 0, 0, 0, 0, 100, 0), +(@PATH, 10, 8777.225, -5753.970, 0.55571, 0, 0, 0, 0, 100, 0), +(@PATH, 11, 8776.860, -5738.229, 0.61609, 0, 0, 0, 0, 100, 0), +(@PATH, 12, 8785.234, -5722.790, 0.75764, 0, 0, 0, 0, 100, 0), +(@PATH, 13, 8786.402, -5701.790, 0.67103, 0, 0, 0, 0, 100, 0), +(@PATH, 14, 8771.277, -5696.080, 0.67596, 0, 0, 0, 0, 100, 0), +(@PATH, 15, 8758.604, -5694.220, 0.55669, 0, 0, 0, 0, 100, 0), +(@PATH, 16, 8746.010, -5704.514, 0.50786, 0, 0, 0, 0, 100, 0), +(@PATH, 17, 8735.815, -5722.942, 0.94607, 0, 0, 0, 0, 100, 0), +(@PATH, 18, 8720.269, -5730.856, 0.89406, 0, 0, 0, 0, 100, 0), +(@PATH, 19, 8706.965, -5730.076, 0.77437, 0, 0, 0, 0, 100, 0), +(@PATH, 20, 8693.575, -5720.971, 0.86999, 0, 0, 0, 0, 100, 0), +(@PATH, 21, 8679.183, -5710.540, 1.10842, 0, 0, 0, 0, 100, 0), +(@PATH, 22, 8656.022, -5704.337, 1.80973, 0, 0, 0, 0, 100, 0), +(@PATH, 23, 8640.976, -5691.507, 0.47690, 0, 0, 0, 0, 100, 0), +(@PATH, 24, 8635.418, -5689.706, 0.53144, 0, 0, 0, 0, 100, 0), +(@PATH, 25, 8620.438, -5687.679, 0.86486, 0, 0, 0, 0, 100, 0), +(@PATH, 26, 8601.687, -5688.443, 0.49338, 1.930, 36000, 0, 0, 100, 0), +(@PATH, 27, 8619.985, -5679.970, 0.75128, 0, 0, 0, 0, 100, 0), +(@PATH, 28, 8635.668, -5671.577, 0.53144, 0, 0, 0, 0, 100, 0), +(@PATH, 29, 8648.297, -5670.150, 0.49488, 0, 0, 0, 0, 100, 0), +(@PATH, 30, 8664.989, -5679.421, 0.55752, 0, 0, 0, 0, 100, 0), +(@PATH, 31, 8679.183, -5710.540, 1.10842, 0, 0, 0, 0, 100, 0), +(@PATH, 32, 8693.575, -5720.971, 0.86999, 0, 0, 0, 0, 100, 0), +(@PATH, 33, 8706.965, -5730.076, 0.77437, 0, 0, 0, 0, 100, 0), +(@PATH, 34, 8721.716, -5745.012, 0.62278, 0, 0, 0, 0, 100, 0), +(@PATH, 35, 8735.529, -5753.923, 1.24721, 0, 0, 0, 0, 100, 0), +(@PATH, 36, 8767.193, -5758.179, 0.50536, 0, 0, 0, 0, 100, 0), +(@PATH, 37, 8791.789, -5762.271, 0.45083, 0, 0, 0, 0, 100, 0), +(@PATH, 38, 8804.548, -5762.792, 0.51199, 0, 0, 0, 0, 100, 0), +(@PATH, 39, 8818.041, -5755.890, 0.64673, 0, 0, 0, 0, 100, 0), +(@PATH, 40, 8828.789, -5743.622, 0.82590, 0, 0, 0, 0, 100, 0), +(@PATH, 41, 8836.920, -5726.737, 0.83736, 0, 0, 0, 0, 100, 0), +(@PATH, 42, 8846.429, -5720.661, 0.49396, 0, 0, 0, 0, 100, 0), +(@PATH, 43, 8873.341, -5735.012, 0.43308, 0, 0, 0, 0, 100, 0), +(@PATH, 44, 8880.688, -5754.608, 0.25531, 6.105, 60000, 0, 0, 100, 0); + +-- DB/Conditions: Add: Missing conditions for Displacing Temporal Rift | by FireEmerald +SET @PARASITE := 10717; -- Temporal Parasite +SET @SPELL := 16613; -- Displacing Temporal Rift +SET @QUEST := 4971; -- A Matter of Time + +DELETE FROM `conditions` WHERE `SourceTypeOrReferenceId` = 17 AND `SourceEntry` = @SPELL; +INSERT INTO `conditions` (SourceTypeOrReferenceId, SourceGroup, SourceEntry, SourceId, ElseGroup, ConditionTypeOrReference, ConditionValue1, ConditionValue2, ConditionValue3, NegativeCondition, ErrorType, comment ) VALUES +(17, 0, @SPELL, 0, 0, 29, @PARASITE, 100, 0, 1, 0, "Cant use Temporal Displacer within 100 yards of Temporal Parasite"), +(17, 0, @SPELL, 0, 0, 28, @QUEST, 0, 0, 1, 0, "Cant use Temporal Displacer, if player has quest objective completed, but not yet rewarded"); 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/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/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 021b86d4b51..37a2b7db215 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -9264,16 +9264,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 +14387,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 +14906,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 +14930,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 +15406,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 +16370,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..817aafb18dc 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -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..2acf9087c06 100644 --- a/src/server/game/Spells/Auras/SpellAuras.cpp +++ b/src/server/game/Spells/Auras/SpellAuras.cpp @@ -1071,7 +1071,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/Spell.cpp b/src/server/game/Spells/Spell.cpp index a26c0356907..8976305445f 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -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/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..fd7bcaab1d3 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()) { @@ -2227,11 +2225,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/Northrend/zone_icecrown.cpp b/src/server/scripts/Northrend/zone_icecrown.cpp index a5d3ed7d0d5..24452a5fb5f 100644 --- a/src/server/scripts/Northrend/zone_icecrown.cpp +++ b/src/server/scripts/Northrend/zone_icecrown.cpp @@ -1035,11 +1035,12 @@ class npc_margrave_dhakar : public CreatureScript if (Creature* morbidus = me->FindNearestCreature(NPC_MORBIDUS, 50.0f, true)) { - Creature* lichKing = me->SummonCreature(NPC_LICH_KING, morbidus->GetPositionX()+10, morbidus->GetPositionY(), morbidus->GetPositionZ()); - _lichKingGuid = lichKing->GetGUID(); - lichKing = me->SummonCreature(NPC_LICH_KING, morbidus->GetPositionX()+10, morbidus->GetPositionY(), morbidus->GetPositionZ()); - lichKing->SetFacingTo(morbidus->GetOrientation()); - lichKing->CastSpell(lichKing, SPELL_SIMPLE_TELEPORT, true); + if (Creature* lichKing = me->SummonCreature(NPC_LICH_KING, morbidus->GetPositionX() + 10.0f, morbidus->GetPositionY(), morbidus->GetPositionZ())) + { + _lichKingGuid = lichKing->GetGUID(); + lichKing->SetFacingTo(morbidus->GetOrientation()); + lichKing->CastSpell(lichKing, SPELL_SIMPLE_TELEPORT, true); + } } _events.ScheduleEvent(EVENT_LK_SAY_1, 5000); @@ -1109,8 +1110,8 @@ class npc_margrave_dhakar : public CreatureScript private: EventMap _events; - uint64 _lichKingGuid; SummonList _summons; + uint64 _lichKingGuid; }; CreatureAI* GetAI(Creature* creature) const OVERRIDE |
