From cfa97b39e6b63ed3e32edc47726b29c9ac5b1e21 Mon Sep 17 00:00:00 2001 From: Jose Joya Date: Tue, 8 Aug 2023 23:36:52 -0500 Subject: [PATCH] feat: Added Improvements over Aura effects (#125) --- .../Implementation/CharacterDatabase.cpp | 490 +- src/server/game/Entities/Pet/Pet.cpp | 696 ++- src/server/game/Entities/Player/Player.cpp | 1761 +++---- src/server/game/Entities/Player/Player.h | 2 + src/server/game/Entities/Unit/Unit.cpp | 1576 +++--- src/server/game/Entities/Unit/Unit.h | 4010 +++++++++------ src/server/game/Handlers/MovementHandler.cpp | 119 +- .../game/Spells/Auras/SpellAuraEffects.cpp | 167 +- .../game/Spells/Auras/SpellAuraEffects.h | 770 +-- src/server/game/Spells/Auras/SpellAuras.cpp | 809 +-- src/server/game/Spells/Auras/SpellAuras.h | 46 +- src/server/game/Spells/Spell.cpp | 20 +- src/server/game/Spells/SpellEffects.cpp | 2722 +++++----- src/server/scripts/Commands/cs_misc.cpp | 690 ++- .../MoltenCore/boss_ragnaros.cpp | 549 +- .../EasternKingdoms/Karazhan/karazhan.cpp | 321 +- .../SunwellPlateau/boss_brutallus.cpp | 215 +- .../SunwellPlateau/boss_felmyst.cpp | 502 +- .../SunwellPlateau/boss_kalecgos.cpp | 510 +- .../zone_western_plaguelands.cpp | 94 +- .../BattleForMountHyjal/boss_archimonde.cpp | 428 +- .../instance_culling_of_stratholme.cpp | 1280 +++-- .../CullingOfStratholme/npc_arthas.cpp | 2011 ++++---- .../TheBlackMorass/boss_aeonus.cpp | 80 +- .../TheBlackMorass/boss_chrono_lord_deja.cpp | 92 +- .../TheBlackMorass/boss_temporus.cpp | 88 +- .../instance_the_black_morass.cpp | 76 +- .../Kalimdor/Firelands/boss_lord_rhyolith.cpp | 888 ++-- .../Kalimdor/OnyxiasLair/boss_onyxia.cpp | 437 +- .../Kalimdor/RuinsOfAhnQiraj/boss_buru.cpp | 376 +- .../TempleOfAhnQiraj/boss_viscidus.cpp | 427 +- src/server/scripts/Maelstrom/Kezan/kezan.cpp | 112 +- .../ObsidianSanctum/obsidian_sanctum.cpp | 787 +-- .../boss_baltharus_the_warborn.cpp | 502 +- .../RubySanctum/boss_halion.cpp | 2 +- .../Gundrak/boss_drakkari_colossus.cpp | 485 +- .../boss_blood_prince_council.cpp | 1937 +++---- .../boss_valithria_dreamwalker.cpp | 2093 ++++---- .../IcecrownCitadel/icecrown_citadel.cpp | 2 +- .../boss_ioc_horde_alliance.cpp | 80 +- .../Northrend/Naxxramas/boss_faerlina.cpp | 361 +- .../Ulduar/HallsOfStone/halls_of_stone.cpp | 805 +-- .../Ulduar/boss_algalon_the_observer.cpp | 2021 ++++---- .../Northrend/Ulduar/Ulduar/boss_mimiron.cpp | 3891 +++++++------- .../Northrend/Ulduar/Ulduar/boss_xt002.cpp | 1455 +++--- .../Ulduar/Ulduar/boss_yogg_saron.cpp | 4568 +++++++++-------- .../scripts/Northrend/zone_borean_tundra.cpp | 1795 ++++--- .../scripts/Northrend/zone_grizzly_hills.cpp | 834 +-- .../boss_fathomlord_karathress.cpp | 273 +- .../boss_leotheras_the_blind.cpp | 251 +- .../TheSlavePens/boss_ahune.cpp | 596 +-- .../ShatteredHalls/shattered_halls.cpp | 329 +- .../Outland/TempestKeep/Eye/boss_alar.cpp | 826 +-- .../botanica/boss_warp_splinter.cpp | 289 +- .../Outland/zone_shadowmoon_valley.cpp | 833 +-- src/server/scripts/Spells/spell_dk.cpp | 419 +- src/server/scripts/Spells/spell_druid.cpp | 463 +- 57 files changed, 24820 insertions(+), 23441 deletions(-) diff --git a/src/server/database/Database/Implementation/CharacterDatabase.cpp b/src/server/database/Database/Implementation/CharacterDatabase.cpp index 947da2d5..b761bacb 100644 --- a/src/server/database/Database/Implementation/CharacterDatabase.cpp +++ b/src/server/database/Database/Implementation/CharacterDatabase.cpp @@ -31,7 +31,8 @@ void CharacterDatabaseConnection::DoPrepareStatements() PrepareStatement(CHAR_SEL_CHECK_GUID, "SELECT 1 FROM characters WHERE guid = ?", CONNECTION_SYNCH); PrepareStatement(CHAR_SEL_SUM_CHARS, "SELECT COUNT(guid) FROM characters WHERE account = ?", CONNECTION_BOTH); PrepareStatement(CHAR_SEL_CHAR_CREATE_INFO, "SELECT level, race, class FROM characters WHERE account = ? LIMIT 0, ?", CONNECTION_ASYNC); - PrepareStatement(CHAR_INS_CHARACTER_BAN, "INSERT INTO character_banned (guid, bandate, unbandate, bannedby, banreason, active) VALUES (?, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()+?, ?, ?, 1)", CONNECTION_ASYNC); + PrepareStatement( + CHAR_INS_CHARACTER_BAN, "INSERT INTO character_banned (guid, bandate, unbandate, bannedby, banreason, active) VALUES (?, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()+?, ?, ?, 1)", CONNECTION_ASYNC); PrepareStatement(CHAR_UPD_CHARACTER_BAN, "UPDATE character_banned SET active = 0 WHERE guid = ? AND active != 0", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_CHARACTER_BAN, "DELETE cb FROM character_banned cb INNER JOIN characters c ON c.guid = cb.guid WHERE c.account = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_SEL_BANINFO, "SELECT bandate, unbandate-bandate, active, unbandate, banreason, bannedby FROM character_banned WHERE guid = ? ORDER BY bandate ASC", CONNECTION_SYNCH); @@ -39,18 +40,24 @@ void CharacterDatabaseConnection::DoPrepareStatements() PrepareStatement(CHAR_SEL_BANINFO_LIST, "SELECT bandate, unbandate, bannedby, banreason FROM character_banned WHERE guid = ? ORDER BY unbandate", CONNECTION_SYNCH); PrepareStatement(CHAR_SEL_BANNED_NAME, "SELECT characters.name FROM characters, character_banned WHERE character_banned.guid = ? AND character_banned.guid = characters.guid", CONNECTION_SYNCH); PrepareStatement(CHAR_SEL_MAIL_LIST_COUNT, "SELECT COUNT(id) FROM mail WHERE receiver = ? ", CONNECTION_SYNCH); - PrepareStatement(CHAR_SEL_MAIL_LIST_INFO, "SELECT id, sender, (SELECT name FROM characters WHERE guid = sender) AS sendername, receiver, (SELECT name FROM characters WHERE guid = receiver) AS receivername, " - "subject, deliver_time, expire_time, money, has_items FROM mail WHERE receiver = ? ", CONNECTION_SYNCH); + PrepareStatement(CHAR_SEL_MAIL_LIST_INFO, + "SELECT id, sender, (SELECT name FROM characters WHERE guid = sender) AS sendername, receiver, (SELECT name FROM characters WHERE guid = receiver) AS receivername, " + "subject, deliver_time, expire_time, money, has_items FROM mail WHERE receiver = ? ", + CONNECTION_SYNCH); PrepareStatement(CHAR_SEL_MAIL_LIST_ITEMS, "SELECT itemEntry,count FROM item_instance WHERE guid = ?", CONNECTION_SYNCH); - PrepareStatement(CHAR_SEL_ENUM, "SELECT c.guid, c.name, c.race, c.class, c.gender, c.skin, c.face, c.hairStyle, c.hairColor, c.facialStyle, c.level, c.zone, c.map, c.position_x, c.position_y, c.position_z, " - "gm.guildid, c.playerFlags, c.at_login, cp.entry, cp.modelid, cp.level, c.equipmentCache, cb.guid, c.slot " - "FROM characters AS c LEFT JOIN character_pet AS cp ON c.guid = cp.owner AND cp.active = 1 LEFT JOIN guild_member AS gm ON c.guid = gm.guid " - "LEFT JOIN character_banned AS cb ON c.guid = cb.guid AND cb.active = 1 WHERE c.account = ? AND c.deleteInfos_Name IS NULL", CONNECTION_ASYNC); - PrepareStatement(CHAR_SEL_ENUM_DECLINED_NAME, "SELECT c.guid, c.name, c.race, c.class, c.gender, c.skin, c.face, c.hairStyle, c.hairColor, c.facialStyle, c.level, c.zone, c.map, " - "c.position_x, c.position_y, c.position_z, gm.guildid, c.playerFlags, c.at_login, cp.entry, cp.modelid, cp.level, c.equipmentCache, " - "cb.guid, c.slot, cd.genitive FROM characters AS c LEFT JOIN character_pet AS cp ON c.guid = cp.owner AND cp.active = 1 " - "LEFT JOIN character_declinedname AS cd ON c.guid = cd.guid LEFT JOIN guild_member AS gm ON c.guid = gm.guid " - "LEFT JOIN character_banned AS cb ON c.guid = cb.guid AND cb.active = 1 WHERE c.account = ? AND c.deleteInfos_Name IS NULL", CONNECTION_ASYNC); + PrepareStatement(CHAR_SEL_ENUM, + "SELECT c.guid, c.name, c.race, c.class, c.gender, c.skin, c.face, c.hairStyle, c.hairColor, c.facialStyle, c.level, c.zone, c.map, c.position_x, c.position_y, c.position_z, " + "gm.guildid, c.playerFlags, c.at_login, cp.entry, cp.modelid, cp.level, c.equipmentCache, cb.guid, c.slot " + "FROM characters AS c LEFT JOIN character_pet AS cp ON c.guid = cp.owner AND cp.active = 1 LEFT JOIN guild_member AS gm ON c.guid = gm.guid " + "LEFT JOIN character_banned AS cb ON c.guid = cb.guid AND cb.active = 1 WHERE c.account = ? AND c.deleteInfos_Name IS NULL", + CONNECTION_ASYNC); + PrepareStatement(CHAR_SEL_ENUM_DECLINED_NAME, + "SELECT c.guid, c.name, c.race, c.class, c.gender, c.skin, c.face, c.hairStyle, c.hairColor, c.facialStyle, c.level, c.zone, c.map, " + "c.position_x, c.position_y, c.position_z, gm.guildid, c.playerFlags, c.at_login, cp.entry, cp.modelid, cp.level, c.equipmentCache, " + "cb.guid, c.slot, cd.genitive FROM characters AS c LEFT JOIN character_pet AS cp ON c.guid = cp.owner AND cp.active = 1 " + "LEFT JOIN character_declinedname AS cd ON c.guid = cd.guid LEFT JOIN guild_member AS gm ON c.guid = gm.guid " + "LEFT JOIN character_banned AS cb ON c.guid = cb.guid AND cb.active = 1 WHERE c.account = ? AND c.deleteInfos_Name IS NULL", + CONNECTION_ASYNC); PrepareStatement(CHAR_SEL_FREE_NAME, "SELECT guid, name, at_login FROM characters WHERE guid = ? AND account = ? AND NOT EXISTS (SELECT NULL FROM characters WHERE name = ?)", CONNECTION_ASYNC); PrepareStatement(CHAR_SEL_CHAR_ZONE, "SELECT zone FROM characters WHERE guid = ?", CONNECTION_SYNCH); PrepareStatement(CHAR_SEL_CHARACTER_NAME_DATA, "SELECT race, class, gender, level, name FROM characters WHERE guid = ?", CONNECTION_SYNCH); @@ -61,20 +68,27 @@ void CharacterDatabaseConnection::DoPrepareStatements() PrepareStatement(CHAR_DEL_BATTLEGROUND_RANDOM, "DELETE FROM character_battleground_random WHERE guid = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_INS_BATTLEGROUND_RANDOM, "INSERT INTO character_battleground_random (guid) VALUES (?)", CONNECTION_ASYNC); - PrepareStatement(CHAR_SEL_CHARACTER, "SELECT c.guid, account, name, race, class, gender, level, xp, money, skin, face, hairStyle, hairColor, facialStyle, bankSlots, restState, playerFlags, " - "position_x, position_y, position_z, map, orientation, taximask, cinematic, totaltime, leveltime, rest_bonus, logout_time, is_logout_resting, resettalents_cost, " - "resettalents_time, talentTree, trans_x, trans_y, trans_z, trans_o, transguid, extra_flags, stable_slots, at_login, zone, online, death_expire_time, taxi_path, instance_mode_mask, " - "totalKills, todayKills, yesterdayKills, chosenTitle, watchedFaction, drunk, health, power1, power2, power3, power4, power5, instance_id, talentGroupsCount, activeTalentGroup, " - "exploredZones, equipmentCache, knownTitles, actionBars, grantableLevels, fishingSteps " - "FROM characters c LEFT JOIN character_fishingsteps cfs ON c.guid = cfs.guid WHERE c.guid = ?", CONNECTION_ASYNC); + PrepareStatement(CHAR_SEL_CHARACTER, + "SELECT c.guid, account, name, race, class, gender, level, xp, money, skin, face, hairStyle, hairColor, facialStyle, bankSlots, restState, playerFlags, " + "position_x, position_y, position_z, map, orientation, taximask, cinematic, totaltime, leveltime, rest_bonus, logout_time, is_logout_resting, resettalents_cost, " + "resettalents_time, talentTree, trans_x, trans_y, trans_z, trans_o, transguid, extra_flags, stable_slots, at_login, zone, online, death_expire_time, taxi_path, instance_mode_mask, " + "totalKills, todayKills, yesterdayKills, chosenTitle, watchedFaction, drunk, health, power1, power2, power3, power4, power5, instance_id, talentGroupsCount, activeTalentGroup, " + "exploredZones, equipmentCache, knownTitles, actionBars, grantableLevels, fishingSteps " + "FROM characters c LEFT JOIN character_fishingsteps cfs ON c.guid = cfs.guid WHERE c.guid = ?", + CONNECTION_ASYNC); PrepareStatement(CHAR_SEL_GROUP_MEMBER, "SELECT guid FROM group_member WHERE memberGuid = ?", CONNECTION_BOTH); - PrepareStatement(CHAR_SEL_CHARACTER_INSTANCE, "SELECT id, permanent, map, difficulty, extendState, resettime FROM character_instance LEFT JOIN instance ON instance = id WHERE guid = ?", CONNECTION_ASYNC); - PrepareStatement(CHAR_SEL_CHARACTER_AURAS, "SELECT casterGuid, spell, effectMask, recalculateMask, stackCount, amount0, amount1, amount2, " - "base_amount0, base_amount1, base_amount2, maxduration, remaintime, remaincharges FROM character_aura WHERE guid = ?", CONNECTION_ASYNC); + PrepareStatement( + CHAR_SEL_CHARACTER_INSTANCE, "SELECT id, permanent, map, difficulty, extendState, resettime FROM character_instance LEFT JOIN instance ON instance = id WHERE guid = ?", CONNECTION_ASYNC); + PrepareStatement(CHAR_SEL_CHARACTER_AURAS, + "SELECT casterGuid, spell, effectMask, recalculateMask, stackCount, amount0, amount1, amount2, " + "base_amount0, base_amount1, base_amount2, maxduration, remaintime, remaincharges, critChance, applyResilience FROM character_aura WHERE guid = ?", + CONNECTION_ASYNC); PrepareStatement(CHAR_SEL_CHARACTER_SPELL, "SELECT spell, active, disabled FROM character_spell WHERE guid = ?", CONNECTION_BOTH); - PrepareStatement(CHAR_SEL_CHARACTER_QUESTSTATUS, "SELECT quest, status, explored, timer, mobcount1, mobcount2, mobcount3, mobcount4, " - "itemcount1, itemcount2, itemcount3, itemcount4, itemcount5, itemcount6, playercount FROM character_queststatus WHERE guid = ? AND status <> 0", CONNECTION_ASYNC); + PrepareStatement(CHAR_SEL_CHARACTER_QUESTSTATUS, + "SELECT quest, status, explored, timer, mobcount1, mobcount2, mobcount3, mobcount4, " + "itemcount1, itemcount2, itemcount3, itemcount4, itemcount5, itemcount6, playercount FROM character_queststatus WHERE guid = ? AND status <> 0", + CONNECTION_ASYNC); PrepareStatement(CHAR_SEL_CHARACTER_QUESTSTATUS_DAILY, "SELECT quest, time FROM character_queststatus_daily WHERE guid = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_SEL_CHARACTER_QUESTSTATUS_WEEKLY, "SELECT quest FROM character_queststatus_weekly WHERE guid = ?", CONNECTION_ASYNC); @@ -100,23 +114,33 @@ void CharacterDatabaseConnection::DoPrepareStatements() PrepareStatement(CHAR_DEL_RESET_CHARACTER_REWARDSTATUS_LFG_DAILY, "DELETE FROM character_rewardstatus_lfg WHERE dailyReset = 1", CONNECTION_ASYNC); PrepareStatement(CHAR_SEL_CHARACTER_REPUTATION, "SELECT faction, standing, flags FROM character_reputation WHERE guid = ?", CONNECTION_ASYNC); - PrepareStatement(CHAR_SEL_CHARACTER_INVENTORY, "SELECT creatorGuid, giftCreatorGuid, count, duration, charges, flags, enchantments, randomPropertyType, randomPropertyId, durability, creationTime, text, bag, slot, " - "item, itemEntry FROM character_inventory ci JOIN item_instance ii ON ci.item = ii.guid WHERE ci.guid = ? ORDER BY bag, slot", CONNECTION_ASYNC); - PrepareStatement(CHAR_SEL_CHARACTER_ACTIONS, "SELECT a.button, a.action, a.type FROM character_action as a, characters as c WHERE a.guid = c.guid AND a.spec = c.activeTalentGroup AND a.guid = ? ORDER BY button", CONNECTION_ASYNC); + PrepareStatement(CHAR_SEL_CHARACTER_INVENTORY, + "SELECT creatorGuid, giftCreatorGuid, count, duration, charges, flags, enchantments, randomPropertyType, randomPropertyId, durability, creationTime, text, bag, slot, " + "item, itemEntry FROM character_inventory ci JOIN item_instance ii ON ci.item = ii.guid WHERE ci.guid = ? ORDER BY bag, slot", + CONNECTION_ASYNC); + PrepareStatement(CHAR_SEL_CHARACTER_ACTIONS, + "SELECT a.button, a.action, a.type FROM character_action as a, characters as c WHERE a.guid = c.guid AND a.spec = c.activeTalentGroup AND a.guid = ? ORDER BY button", CONNECTION_ASYNC); PrepareStatement(CHAR_SEL_MAIL_COUNT, "SELECT COUNT(*) FROM mail WHERE receiver = ?", CONNECTION_SYNCH); - PrepareStatement(CHAR_SEL_CHARACTER_SOCIALLIST, "SELECT friend, flags, note FROM character_social JOIN characters ON characters.guid = character_social.friend WHERE character_social.guid = ? AND deleteinfos_name IS NULL LIMIT 255", CONNECTION_ASYNC); + PrepareStatement(CHAR_SEL_CHARACTER_SOCIALLIST, + "SELECT friend, flags, note FROM character_social JOIN characters ON characters.guid = character_social.friend WHERE character_social.guid = ? AND deleteinfos_name IS NULL LIMIT 255", + CONNECTION_ASYNC); PrepareStatement(CHAR_SEL_CHARACTER_HOMEBIND, "SELECT mapId, zoneId, posX, posY, posZ FROM character_homebind WHERE guid = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_SEL_CHARACTER_SPELLCOOLDOWNS, "SELECT spell, item, time, categoryId, categoryEnd FROM character_spell_cooldown WHERE guid = ? AND time > UNIX_TIMESTAMP()", 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, 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_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); PrepareStatement(CHAR_SEL_CHARACTER_CRITERIAPROGRESS, "SELECT criteria, counter, date FROM character_achievement_progress WHERE guid = ?", CONNECTION_ASYNC); - PrepareStatement(CHAR_SEL_CHARACTER_EQUIPMENTSETS, "SELECT setguid, setindex, name, iconname, ignore_mask, item0, item1, item2, item3, item4, item5, item6, item7, item8, " - "item9, item10, item11, item12, item13, item14, item15, item16, item17, item18 FROM character_equipmentsets WHERE guid = ? ORDER BY setindex", CONNECTION_ASYNC); - PrepareStatement(CHAR_SEL_CHARACTER_BGDATA, "SELECT instanceId, team, joinX, joinY, joinZ, joinO, joinMapId, taxiStart, taxiEnd, mountSpell FROM character_battleground_data WHERE guid = ?", CONNECTION_ASYNC); + PrepareStatement(CHAR_SEL_CHARACTER_EQUIPMENTSETS, + "SELECT setguid, setindex, name, iconname, ignore_mask, item0, item1, item2, item3, item4, item5, item6, item7, item8, " + "item9, item10, item11, item12, item13, item14, item15, item16, item17, item18 FROM character_equipmentsets WHERE guid = ? ORDER BY setindex", + CONNECTION_ASYNC); + PrepareStatement( + CHAR_SEL_CHARACTER_BGDATA, "SELECT instanceId, team, joinX, joinY, joinZ, joinO, joinMapId, taxiStart, taxiEnd, mountSpell FROM character_battleground_data WHERE guid = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_SEL_CHARACTER_GLYPHS, "SELECT talentGroup, glyph1, glyph2, glyph3, glyph4, glyph5, glyph6, glyph7, glyph8, glyph9 FROM character_glyphs WHERE guid = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_SEL_CHARACTER_TALENTS, "SELECT spell, talentGroup FROM character_talent WHERE guid = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_SEL_CHARACTER_SKILLS, "SELECT skill, value, max FROM character_skills WHERE guid = ?", CONNECTION_BOTH); @@ -126,23 +150,38 @@ void CharacterDatabaseConnection::DoPrepareStatements() PrepareStatement(CHAR_SEL_ACCOUNT_INSTANCELOCKTIMES, "SELECT instanceId, releaseTime FROM account_instance_times WHERE accountId = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_SEL_CHARACTER_ACTIONS_SPEC, "SELECT button, action, type FROM character_action WHERE guid = ? AND spec = ? ORDER BY button", CONNECTION_ASYNC); - PrepareStatement(CHAR_SEL_MAILITEMS, "SELECT creatorGuid, giftCreatorGuid, count, duration, charges, flags, enchantments, randomPropertyType, randomPropertyId, durability, creationTime, text, item_guid, itemEntry, ii.owner_guid, m.id FROM mail_items mi INNER JOIN mail m ON mi.mail_id = m.id LEFT JOIN item_instance ii ON mi.item_guid = ii.guid WHERE m.receiver = ?", CONNECTION_ASYNC); - PrepareStatement(CHAR_SEL_AUCTION_ITEMS, "SELECT creatorGuid, giftCreatorGuid, count, duration, charges, flags, enchantments, randomPropertyType, randomPropertyId, durability, creationTime, text, itemguid, itemEntry FROM auctionhouse ah JOIN item_instance ii ON ah.itemguid = ii.guid", CONNECTION_SYNCH); - PrepareStatement(CHAR_SEL_AUCTIONS, "SELECT id, houseid, itemguid, itemEntry, count, itemowner, buyoutprice, time, buyguid, lastbid, startbid, deposit FROM auctionhouse ah INNER JOIN item_instance ii ON ii.guid = ah.itemguid", CONNECTION_SYNCH); - PrepareStatement(CHAR_INS_AUCTION, "INSERT INTO auctionhouse (id, houseid, itemguid, itemowner, buyoutprice, time, buyguid, lastbid, startbid, deposit) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); + PrepareStatement(CHAR_SEL_MAILITEMS, + "SELECT creatorGuid, giftCreatorGuid, count, duration, charges, flags, enchantments, randomPropertyType, randomPropertyId, durability, creationTime, text, item_guid, itemEntry, " + "ii.owner_guid, m.id FROM mail_items mi INNER JOIN mail m ON mi.mail_id = m.id LEFT JOIN item_instance ii ON mi.item_guid = ii.guid WHERE m.receiver = ?", + CONNECTION_ASYNC); + PrepareStatement(CHAR_SEL_AUCTION_ITEMS, + "SELECT creatorGuid, giftCreatorGuid, count, duration, charges, flags, enchantments, randomPropertyType, randomPropertyId, durability, creationTime, text, itemguid, itemEntry FROM " + "auctionhouse ah JOIN item_instance ii ON ah.itemguid = ii.guid", + CONNECTION_SYNCH); + PrepareStatement(CHAR_SEL_AUCTIONS, + "SELECT id, houseid, itemguid, itemEntry, count, itemowner, buyoutprice, time, buyguid, lastbid, startbid, deposit FROM auctionhouse ah INNER JOIN item_instance ii ON ii.guid = ah.itemguid", + CONNECTION_SYNCH); + PrepareStatement(CHAR_INS_AUCTION, "INSERT INTO auctionhouse (id, houseid, itemguid, itemowner, buyoutprice, time, buyguid, lastbid, startbid, deposit) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", + CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_AUCTION, "DELETE FROM auctionhouse WHERE id = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_SEL_AUCTION_BIDDERS, "SELECT id, bidderguid FROM auctionbidders", CONNECTION_SYNCH); PrepareStatement(CHAR_INS_AUCTION_BIDDERS, "INSERT IGNORE INTO auctionbidders (id, bidderguid) VALUES (?, ?)", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_AUCTION_BIDDERS, "DELETE FROM auctionbidders WHERE id = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_UPD_AUCTION_BID, "UPDATE auctionhouse SET buyguid = ?, lastbid = ? WHERE id = ?", CONNECTION_ASYNC); - PrepareStatement(CHAR_INS_MAIL, "INSERT INTO mail(id, messageType, stationery, mailTemplateId, sender, receiver, subject, body, has_items, expire_time, deliver_time, money, cod, checked) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); + PrepareStatement(CHAR_INS_MAIL, + "INSERT INTO mail(id, messageType, stationery, mailTemplateId, sender, receiver, subject, body, has_items, expire_time, deliver_time, money, cod, checked) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, " + "?, ?, ?, ?, ?)", + CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_MAIL_BY_ID, "DELETE FROM mail WHERE id = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_INS_MAIL_ITEM, "INSERT INTO mail_items(mail_id, item_guid, receiver) VALUES (?, ?, ?)", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_MAIL_ITEM, "DELETE FROM mail_items WHERE item_guid = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_INVALID_MAIL_ITEM, "DELETE FROM mail_items WHERE item_guid = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_EMPTY_EXPIRED_MAIL, "DELETE FROM mail WHERE expire_time < ? AND has_items = 0 AND body = ''", CONNECTION_ASYNC); PrepareStatement(CHAR_SEL_EXPIRED_MAIL, "SELECT id, messageType, sender, receiver, has_items, expire_time, cod, checked, mailTemplateId FROM mail WHERE expire_time < ?", CONNECTION_SYNCH); - PrepareStatement(CHAR_SEL_EXPIRED_MAIL_ITEMS, "SELECT item_guid, itemEntry, mail_id FROM mail_items mi INNER JOIN item_instance ii ON ii.guid = mi.item_guid LEFT JOIN mail mm ON mi.mail_id = mm.id WHERE mm.id IS NOT NULL AND mm.expire_time < ?", CONNECTION_SYNCH); + PrepareStatement(CHAR_SEL_EXPIRED_MAIL_ITEMS, + "SELECT item_guid, itemEntry, mail_id FROM mail_items mi INNER JOIN item_instance ii ON ii.guid = mi.item_guid LEFT JOIN mail mm ON mi.mail_id = mm.id WHERE mm.id IS NOT NULL AND " + "mm.expire_time < ?", + CONNECTION_SYNCH); PrepareStatement(CHAR_UPD_MAIL_RETURNED, "UPDATE mail SET sender = ?, receiver = ?, expire_time = ?, deliver_time = ?, cod = 0, checked = ? WHERE id = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_UPD_MAIL_ITEM_RECEIVER, "UPDATE mail_items SET receiver = ? WHERE item_guid = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_UPD_ITEM_OWNER, "UPDATE item_instance SET owner_guid = ? WHERE guid = ?", CONNECTION_ASYNC); @@ -152,8 +191,14 @@ void CharacterDatabaseConnection::DoPrepareStatements() PrepareStatement(CHAR_DEL_ITEM_BOP_TRADE, "DELETE FROM item_soulbound_trade_data WHERE itemGuid = ? LIMIT 1", CONNECTION_ASYNC); PrepareStatement(CHAR_INS_ITEM_BOP_TRADE, "INSERT INTO item_soulbound_trade_data VALUES (?, ?)", CONNECTION_ASYNC); PrepareStatement(CHAR_REP_INVENTORY_ITEM, "REPLACE INTO character_inventory (guid, bag, slot, item) VALUES (?, ?, ?, ?)", CONNECTION_ASYNC); - PrepareStatement(CHAR_REP_ITEM_INSTANCE, "REPLACE INTO item_instance (itemEntry, owner_guid, creatorGuid, giftCreatorGuid, count, duration, charges, flags, enchantments, randomPropertyType, randomPropertyId, durability, creationTime, text, guid) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); - PrepareStatement(CHAR_UPD_ITEM_INSTANCE, "UPDATE item_instance SET itemEntry = ?, owner_guid = ?, creatorGuid = ?, giftCreatorGuid = ?, count = ?, duration = ?, charges = ?, flags = ?, enchantments = ?, randomPropertyType = ?, randomPropertyId = ?, durability = ?, creationTime = ?, text = ? WHERE guid = ?", CONNECTION_ASYNC); + PrepareStatement(CHAR_REP_ITEM_INSTANCE, + "REPLACE INTO item_instance (itemEntry, owner_guid, creatorGuid, giftCreatorGuid, count, duration, charges, flags, enchantments, randomPropertyType, randomPropertyId, durability, " + "creationTime, text, guid) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", + CONNECTION_ASYNC); + PrepareStatement(CHAR_UPD_ITEM_INSTANCE, + "UPDATE item_instance SET itemEntry = ?, owner_guid = ?, creatorGuid = ?, giftCreatorGuid = ?, count = ?, duration = ?, charges = ?, flags = ?, enchantments = ?, randomPropertyType = ?, " + "randomPropertyId = ?, durability = ?, creationTime = ?, text = ? WHERE guid = ?", + CONNECTION_ASYNC); PrepareStatement(CHAR_UPD_ITEM_INSTANCE_ON_LOAD, "UPDATE item_instance SET duration = ?, flags = ?, durability = ? WHERE guid = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_ITEM_INSTANCE, "DELETE FROM item_instance WHERE guid = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_ITEM_INSTANCE_BY_OWNER, "DELETE FROM item_instance WHERE owner_guid = ?", CONNECTION_ASYNC); @@ -171,50 +216,57 @@ void CharacterDatabaseConnection::DoPrepareStatements() // Guild handling // 0: uint32, 1: string, 2: uint32, 3: string, 4: string, 5: uint64, 6-10: uint32, 11: uint64 - PrepareStatement(CHAR_INS_GUILD, "INSERT INTO guild (guildid, name, leaderguid, info, motd, createdate, EmblemStyle, EmblemColor, BorderStyle, BorderColor, BackgroundColor, BankMoney) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); + PrepareStatement(CHAR_INS_GUILD, + "INSERT INTO guild (guildid, name, leaderguid, info, motd, createdate, EmblemStyle, EmblemColor, BorderStyle, BorderColor, BackgroundColor, BankMoney) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, " + "?)", + CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_GUILD, "DELETE FROM guild WHERE guildid = ?", CONNECTION_ASYNC); // 0: uint32 // 0: string, 1: uint32 PrepareStatement(CHAR_UPD_GUILD_NAME, "UPDATE guild SET name = ? WHERE guildid = ?", CONNECTION_ASYNC); // 0: uint32, 1: uint32, 2: uint8, 4: string, 5: string - PrepareStatement(CHAR_INS_GUILD_MEMBER, "INSERT INTO guild_member (guildid, guid, `rank`, pnote, offnote, activity, weekActivity, weekReputation) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); - PrepareStatement(CHAR_DEL_GUILD_MEMBER, "DELETE FROM guild_member WHERE guid = ?", CONNECTION_ASYNC); // 0: uint32 + PrepareStatement( + CHAR_INS_GUILD_MEMBER, "INSERT INTO guild_member (guildid, guid, `rank`, pnote, offnote, activity, weekActivity, weekReputation) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); + PrepareStatement(CHAR_DEL_GUILD_MEMBER, "DELETE FROM guild_member WHERE guid = ?", CONNECTION_ASYNC); // 0: uint32 PrepareStatement(CHAR_DEL_GUILD_MEMBERS, "DELETE FROM guild_member WHERE guildid = ?", CONNECTION_ASYNC); // 0: uint32 // 0: uint32, 1: uint8, 3: string, 4: uint32, 5: uint32 PrepareStatement(CHAR_INS_GUILD_RANK, "INSERT INTO guild_rank (guildid, rid, rname, rights, BankMoneyPerDay) VALUES (?, ?, ?, ?, ?)", CONNECTION_ASYNC); - PrepareStatement(CHAR_DEL_GUILD_RANKS, "DELETE FROM guild_rank WHERE guildid = ?", CONNECTION_ASYNC); // 0: uint32 - PrepareStatement(CHAR_DEL_GUILD_RANK, "DELETE FROM guild_rank WHERE guildid = ? AND rid = ?", CONNECTION_ASYNC); // 0: uint32, 1: uint8 - PrepareStatement(CHAR_INS_GUILD_BANK_TAB, "INSERT INTO guild_bank_tab (guildid, TabId) VALUES (?, ?)", CONNECTION_ASYNC); // 0: uint32, 1: uint8 + PrepareStatement(CHAR_DEL_GUILD_RANKS, "DELETE FROM guild_rank WHERE guildid = ?", CONNECTION_ASYNC); // 0: uint32 + PrepareStatement(CHAR_DEL_GUILD_RANK, "DELETE FROM guild_rank WHERE guildid = ? AND rid = ?", CONNECTION_ASYNC); // 0: uint32, 1: uint8 + PrepareStatement(CHAR_INS_GUILD_BANK_TAB, "INSERT INTO guild_bank_tab (guildid, TabId) VALUES (?, ?)", CONNECTION_ASYNC); // 0: uint32, 1: uint8 PrepareStatement(CHAR_DEL_GUILD_BANK_TAB, "DELETE FROM guild_bank_tab WHERE guildid = ? AND TabId = ?", CONNECTION_ASYNC); // 0: uint32, 1: uint8 - PrepareStatement(CHAR_DEL_GUILD_BANK_TABS, "DELETE FROM guild_bank_tab WHERE guildid = ?", CONNECTION_ASYNC); // 0: uint32 + PrepareStatement(CHAR_DEL_GUILD_BANK_TABS, "DELETE FROM guild_bank_tab WHERE guildid = ?", CONNECTION_ASYNC); // 0: uint32 // 0: uint32, 1: uint8, 2: uint8, 3: uint32, 4: uint32 PrepareStatement(CHAR_INS_GUILD_BANK_ITEM, "INSERT INTO guild_bank_item (guildid, TabId, SlotId, item_guid) VALUES (?, ?, ?, ?)", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_GUILD_BANK_ITEM, "DELETE FROM guild_bank_item WHERE guildid = ? AND TabId = ? AND SlotId = ?", CONNECTION_ASYNC); // 0: uint32, 1: uint8, 2: uint8 - PrepareStatement(CHAR_DEL_GUILD_BANK_ITEMS, "DELETE FROM guild_bank_item WHERE guildid = ?", CONNECTION_ASYNC); // 0: uint32 + PrepareStatement(CHAR_DEL_GUILD_BANK_ITEMS, "DELETE FROM guild_bank_item WHERE guildid = ?", CONNECTION_ASYNC); // 0: uint32 // 0: uint32, 1: uint8, 2: uint8, 3: uint8, 4: uint32 - PrepareStatement(CHAR_INS_GUILD_BANK_RIGHT, "INSERT INTO guild_bank_right (guildid, TabId, rid, gbright, SlotPerDay) VALUES (?, ?, ?, ?, ?) " - "ON DUPLICATE KEY UPDATE gbright = VALUES(gbright), SlotPerDay = VALUES(SlotPerDay)", CONNECTION_ASYNC); - PrepareStatement(CHAR_DEL_GUILD_BANK_RIGHTS, "DELETE FROM guild_bank_right WHERE guildid = ?", CONNECTION_ASYNC); // 0: uint32 + PrepareStatement(CHAR_INS_GUILD_BANK_RIGHT, + "INSERT INTO guild_bank_right (guildid, TabId, rid, gbright, SlotPerDay) VALUES (?, ?, ?, ?, ?) " + "ON DUPLICATE KEY UPDATE gbright = VALUES(gbright), SlotPerDay = VALUES(SlotPerDay)", + CONNECTION_ASYNC); + PrepareStatement(CHAR_DEL_GUILD_BANK_RIGHTS, "DELETE FROM guild_bank_right WHERE guildid = ?", CONNECTION_ASYNC); // 0: uint32 PrepareStatement(CHAR_DEL_GUILD_BANK_RIGHTS_FOR_RANK, "DELETE FROM guild_bank_right WHERE guildid = ? AND rid = ?", CONNECTION_ASYNC); // 0: uint32, 1: uint8 // 0-1: uint32, 2-3: uint8, 4-5: uint32, 6: uint16, 7: uint8, 8: uint64 - PrepareStatement(CHAR_INS_GUILD_BANK_EVENTLOG, "INSERT INTO guild_bank_eventlog (guildid, LogGuid, TabId, EventType, PlayerGuid, ItemOrMoney, ItemStackCount, DestTabId, TimeStamp) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); + PrepareStatement(CHAR_INS_GUILD_BANK_EVENTLOG, + "INSERT INTO guild_bank_eventlog (guildid, LogGuid, TabId, EventType, PlayerGuid, ItemOrMoney, ItemStackCount, DestTabId, TimeStamp) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_GUILD_BANK_EVENTLOG, "DELETE FROM guild_bank_eventlog WHERE guildid = ? AND LogGuid = ? AND TabId = ?", CONNECTION_ASYNC); // 0: uint32, 1: uint32, 2: uint8 - PrepareStatement(CHAR_DEL_GUILD_BANK_EVENTLOGS, "DELETE FROM guild_bank_eventlog WHERE guildid = ?", CONNECTION_ASYNC); // 0: uint32 + PrepareStatement(CHAR_DEL_GUILD_BANK_EVENTLOGS, "DELETE FROM guild_bank_eventlog WHERE guildid = ?", CONNECTION_ASYNC); // 0: uint32 // 0-1: uint32, 2: uint8, 3-4: uint32, 5: uint8, 6: uint64 PrepareStatement(CHAR_INS_GUILD_EVENTLOG, "INSERT INTO guild_eventlog (guildid, LogGuid, EventType, PlayerGuid1, PlayerGuid2, NewRank, TimeStamp) VALUES (?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); - PrepareStatement(CHAR_DEL_GUILD_EVENTLOG, "DELETE FROM guild_eventlog WHERE guildid = ? AND LogGuid = ?", CONNECTION_ASYNC); // 0: uint32, 1: uint32 - PrepareStatement(CHAR_DEL_GUILD_EVENTLOGS, "DELETE FROM guild_eventlog WHERE guildid = ?", CONNECTION_ASYNC); // 0: uint32 - PrepareStatement(CHAR_UPD_GUILD_MEMBER_PNOTE, "UPDATE guild_member SET pnote = ? WHERE guid = ?", CONNECTION_ASYNC); // 0: string, 1: uint32 - PrepareStatement(CHAR_UPD_GUILD_MEMBER_OFFNOTE, "UPDATE guild_member SET offnote = ? WHERE guid = ?", CONNECTION_ASYNC); // 0: string, 1: uint32 - PrepareStatement(CHAR_UPD_GUILD_MEMBER_RANK, "UPDATE guild_member SET `rank` = ? WHERE guid = ?", CONNECTION_ASYNC); // 0: uint8, 1: uint32 + PrepareStatement(CHAR_DEL_GUILD_EVENTLOG, "DELETE FROM guild_eventlog WHERE guildid = ? AND LogGuid = ?", CONNECTION_ASYNC); // 0: uint32, 1: uint32 + PrepareStatement(CHAR_DEL_GUILD_EVENTLOGS, "DELETE FROM guild_eventlog WHERE guildid = ?", CONNECTION_ASYNC); // 0: uint32 + PrepareStatement(CHAR_UPD_GUILD_MEMBER_PNOTE, "UPDATE guild_member SET pnote = ? WHERE guid = ?", CONNECTION_ASYNC); // 0: string, 1: uint32 + PrepareStatement(CHAR_UPD_GUILD_MEMBER_OFFNOTE, "UPDATE guild_member SET offnote = ? WHERE guid = ?", CONNECTION_ASYNC); // 0: string, 1: uint32 + PrepareStatement(CHAR_UPD_GUILD_MEMBER_RANK, "UPDATE guild_member SET `rank` = ? WHERE guid = ?", CONNECTION_ASYNC); // 0: uint8, 1: uint32 PrepareStatement(CHAR_UPD_GUILD_MEMBER_ACTIVITY, "UPDATE guild_member SET activity = ?, weekActivity = ? WHERE guid = ?", CONNECTION_ASYNC); // 0: uint64, 1: uint64, 2: uint32 - PrepareStatement(CHAR_UPD_GUILD_MEMBER_WEEK_REPUTATION, "UPDATE guild_member SET weekReputation = ? WHERE guid = ?", CONNECTION_ASYNC); // 0: uint32, 1: uint32 - PrepareStatement(CHAR_RESET_GUILD_MEMBER_WEEK_ACTIVITY, "UPDATE guild_member SET weekActivity = 0 WHERE guid = ?", CONNECTION_ASYNC); // 0: uint32 - PrepareStatement(CHAR_RESET_GUILD_MEMBER_WEEK_REPUTATION, "UPDATE guild_member SET weekReputation = 0 WHERE guid = ?", CONNECTION_ASYNC); // 0: uint32 - PrepareStatement(CHAR_UPD_GUILD_MOTD, "UPDATE guild SET motd = ? WHERE guildid = ?", CONNECTION_ASYNC); // 0: string, 1: uint32 - PrepareStatement(CHAR_UPD_GUILD_INFO, "UPDATE guild SET info = ? WHERE guildid = ?", CONNECTION_ASYNC); // 0: string, 1: uint32 - PrepareStatement(CHAR_UPD_GUILD_LEADER, "UPDATE guild SET leaderguid = ? WHERE guildid = ?", CONNECTION_ASYNC); // 0: uint32, 1: uint32 - PrepareStatement(CHAR_UPD_GUILD_RANK_NAME, "UPDATE guild_rank SET rname = ? WHERE rid = ? AND guildid = ?", CONNECTION_ASYNC); // 0: string, 1: uint8, 2: uint32 - PrepareStatement(CHAR_UPD_GUILD_RANK_RIGHTS, "UPDATE guild_rank SET rights = ? WHERE rid = ? AND guildid = ?", CONNECTION_ASYNC); // 0: uint32, 1: uint8, 2: uint32 + PrepareStatement(CHAR_UPD_GUILD_MEMBER_WEEK_REPUTATION, "UPDATE guild_member SET weekReputation = ? WHERE guid = ?", CONNECTION_ASYNC); // 0: uint32, 1: uint32 + PrepareStatement(CHAR_RESET_GUILD_MEMBER_WEEK_ACTIVITY, "UPDATE guild_member SET weekActivity = 0 WHERE guid = ?", CONNECTION_ASYNC); // 0: uint32 + PrepareStatement(CHAR_RESET_GUILD_MEMBER_WEEK_REPUTATION, "UPDATE guild_member SET weekReputation = 0 WHERE guid = ?", CONNECTION_ASYNC); // 0: uint32 + PrepareStatement(CHAR_UPD_GUILD_MOTD, "UPDATE guild SET motd = ? WHERE guildid = ?", CONNECTION_ASYNC); // 0: string, 1: uint32 + PrepareStatement(CHAR_UPD_GUILD_INFO, "UPDATE guild SET info = ? WHERE guildid = ?", CONNECTION_ASYNC); // 0: string, 1: uint32 + PrepareStatement(CHAR_UPD_GUILD_LEADER, "UPDATE guild SET leaderguid = ? WHERE guildid = ?", CONNECTION_ASYNC); // 0: uint32, 1: uint32 + PrepareStatement(CHAR_UPD_GUILD_RANK_NAME, "UPDATE guild_rank SET rname = ? WHERE rid = ? AND guildid = ?", CONNECTION_ASYNC); // 0: string, 1: uint8, 2: uint32 + PrepareStatement(CHAR_UPD_GUILD_RANK_RIGHTS, "UPDATE guild_rank SET rights = ? WHERE rid = ? AND guildid = ?", CONNECTION_ASYNC); // 0: uint32, 1: uint8, 2: uint32 // 0-5: uint32 PrepareStatement(CHAR_UPD_GUILD_EMBLEM_INFO, "UPDATE guild SET EmblemStyle = ?, EmblemColor = ?, BorderStyle = ?, BorderColor = ?, BackgroundColor = ? WHERE guildid = ?", CONNECTION_ASYNC); // 0: string, 1: string, 2: uint32, 3: uint8 @@ -224,16 +276,21 @@ void CharacterDatabaseConnection::DoPrepareStatements() // 0: uint8, 1: uint32, 2: uint8, 3: uint32 PrepareStatement(CHAR_UPD_GUILD_BANK_EVENTLOG_TAB, "UPDATE guild_bank_eventlog SET TabId = ? WHERE guildid = ? AND TabId = ? AND LogGuid = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_UPD_GUILD_RANK_BANK_MONEY, "UPDATE guild_rank SET BankMoneyPerDay = ? WHERE rid = ? AND guildid = ?", CONNECTION_ASYNC); // 0: uint32, 1: uint8, 2: uint32 - PrepareStatement(CHAR_UPD_GUILD_BANK_TAB_TEXT, "UPDATE guild_bank_tab SET TabText = ? WHERE guildid = ? AND TabId = ?", CONNECTION_ASYNC); // 0: string, 1: uint32, 2: uint8 + PrepareStatement(CHAR_UPD_GUILD_BANK_TAB_TEXT, "UPDATE guild_bank_tab SET TabText = ? WHERE guildid = ? AND TabId = ?", CONNECTION_ASYNC); // 0: string, 1: uint32, 2: uint8 PrepareStatement(CHAR_INS_GUILD_MEMBER_WITHDRAW_TABS, - "INSERT INTO guild_member_withdraw (guid, tab0, tab1, tab2, tab3, tab4, tab5, tab6, tab7) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) " - "ON DUPLICATE KEY UPDATE tab0 = VALUES (tab0), tab1 = VALUES (tab1), tab2 = VALUES (tab2), tab3 = VALUES (tab3), tab4 = VALUES (tab4), tab5 = VALUES (tab5), tab6 = VALUES (tab6), tab7 = VALUES (tab7)", CONNECTION_ASYNC); + "INSERT INTO guild_member_withdraw (guid, tab0, tab1, tab2, tab3, tab4, tab5, tab6, tab7) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) " + "ON DUPLICATE KEY UPDATE tab0 = VALUES (tab0), tab1 = VALUES (tab1), tab2 = VALUES (tab2), tab3 = VALUES (tab3), tab4 = VALUES (tab4), tab5 = VALUES (tab5), tab6 = VALUES (tab6), tab7 = " + "VALUES (tab7)", + CONNECTION_ASYNC); PrepareStatement(CHAR_INS_GUILD_MEMBER_WITHDRAW_MONEY, "INSERT INTO guild_member_withdraw (guid, money) VALUES (?, ?) ON DUPLICATE KEY UPDATE money = VALUES (money)", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_GUILD_MEMBER_WITHDRAW, "TRUNCATE guild_member_withdraw", CONNECTION_ASYNC); // 0: uint32, 1: uint32, 2: uint32 - PrepareStatement(CHAR_SEL_CHAR_DATA_FOR_GUILD, "SELECT c.name, c.level, c.class, c.zone, c.account, c.achievementPoints, r.standing FROM characters c LEFT JOIN character_reputation r ON c.guid = r.guid AND r.faction = 1168 WHERE c.guid = ?", CONNECTION_SYNCH); + PrepareStatement(CHAR_SEL_CHAR_DATA_FOR_GUILD, + "SELECT c.name, c.level, c.class, c.zone, c.account, c.achievementPoints, r.standing FROM characters c LEFT JOIN character_reputation r ON c.guid = r.guid AND r.faction = 1168 WHERE c.guid = " + "?", + CONNECTION_SYNCH); PrepareStatement(CHAR_SEL_OLD_GUILD_DATA, "SELECT guildId, weekReputation FROM guild_old_member WHERE guid = ?", CONNECTION_SYNCH); PrepareStatement(CHAR_DEL_OLD_GUILD_DATA, "DELETE FROM guild_old_member WHERE guid = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_RESET_OLD_GUILD_WEEK_REPUTATION, "UPDATE guild_old_member SET weekReputation = 0", CONNECTION_ASYNC); @@ -249,11 +306,16 @@ void CharacterDatabaseConnection::DoPrepareStatements() PrepareStatement(CHAR_SEL_GUILD_ACHIEVEMENT_CRITERIA, "SELECT criteria, counter, date, completedGuid FROM guild_achievement_progress WHERE guildId = ?", CONNECTION_SYNCH); PrepareStatement(CHAR_UPD_GUILD_EXPERIENCE, "UPDATE guild SET level = ?, experience = ?, todayExperience = ? WHERE guildId = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_UPD_GUILD_RESET_TODAY_EXPERIENCE, "UPDATE guild SET todayExperience = 0", CONNECTION_ASYNC); - PrepareStatement(CHAR_INS_GUILD_NEWS, "INSERT INTO guild_newslog (guildid, LogGuid, EventType, PlayerGuid, Flags, Value, Timestamp) VALUES (?, ?, ?, ?, ?, ?, ?)" - " ON DUPLICATE KEY UPDATE LogGuid = VALUES (LogGuid), EventType = VALUES (EventType), PlayerGuid = VALUES (PlayerGuid), Flags = VALUES (Flags), Value = VALUES (Value), Timestamp = VALUES (Timestamp)", CONNECTION_ASYNC); + PrepareStatement(CHAR_INS_GUILD_NEWS, + "INSERT INTO guild_newslog (guildid, LogGuid, EventType, PlayerGuid, Flags, Value, Timestamp) VALUES (?, ?, ?, ?, ?, ?, ?)" + " ON DUPLICATE KEY UPDATE LogGuid = VALUES (LogGuid), EventType = VALUES (EventType), PlayerGuid = VALUES (PlayerGuid), Flags = VALUES (Flags), Value = VALUES (Value), Timestamp = VALUES " + "(Timestamp)", + CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_GUILD_NEWS, "DELETE FROM guild_newslog WHERE Timestamp < ?", CONNECTION_ASYNC); - PrepareStatement(CHAR_UPD_GUILD_CHALLENGE, "UPDATE guild SET completedDungeonChallenges = ?, completedRaidChallenges = ?, completedRatedBattlegroundChallenges = ? WHERE guildId = ?", CONNECTION_ASYNC); - PrepareStatement(CHAR_UPD_GUILD_RESET_CHALLENGE, "UPDATE guild SET completedDungeonChallenges = 0, completedRaidChallenges = 0, completedRatedBattlegroundChallenges = 0 WHERE guildId = ?", CONNECTION_ASYNC); + PrepareStatement( + CHAR_UPD_GUILD_CHALLENGE, "UPDATE guild SET completedDungeonChallenges = ?, completedRaidChallenges = ?, completedRatedBattlegroundChallenges = ? WHERE guildId = ?", CONNECTION_ASYNC); + PrepareStatement( + CHAR_UPD_GUILD_RESET_CHALLENGE, "UPDATE guild SET completedDungeonChallenges = 0, completedRaidChallenges = 0, completedRatedBattlegroundChallenges = 0 WHERE guildId = ?", CONNECTION_ASYNC); // Chat channel handling PrepareStatement(CHAR_SEL_CHANNEL, "SELECT name, announce, ownership, password, bannedList FROM channels WHERE name = ? AND team = ?", CONNECTION_SYNCH); @@ -264,22 +326,31 @@ void CharacterDatabaseConnection::DoPrepareStatements() PrepareStatement(CHAR_DEL_OLD_CHANNELS, "DELETE FROM channels WHERE ownership = 1 AND lastUsed + ? < UNIX_TIMESTAMP()", CONNECTION_ASYNC); // Equipmentsets - PrepareStatement(CHAR_UPD_EQUIP_SET, "UPDATE character_equipmentsets SET name=?, iconname=?, ignore_mask=?, item0=?, item1=?, item2=?, item3=?, " - "item4=?, item5=?, item6=?, item7=?, item8=?, item9=?, item10=?, item11=?, item12=?, item13=?, item14=?, item15=?, item16=?, " - "item17=?, item18=? WHERE guid=? AND setguid=? AND setindex=?", CONNECTION_ASYNC); - PrepareStatement(CHAR_INS_EQUIP_SET, "INSERT INTO character_equipmentsets (guid, setguid, setindex, name, iconname, ignore_mask, item0, item1, item2, item3, " - "item4, item5, item6, item7, item8, item9, item10, item11, item12, item13, item14, item15, item16, item17, item18) " - "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); + PrepareStatement(CHAR_UPD_EQUIP_SET, + "UPDATE character_equipmentsets SET name=?, iconname=?, ignore_mask=?, item0=?, item1=?, item2=?, item3=?, " + "item4=?, item5=?, item6=?, item7=?, item8=?, item9=?, item10=?, item11=?, item12=?, item13=?, item14=?, item15=?, item16=?, " + "item17=?, item18=? WHERE guid=? AND setguid=? AND setindex=?", + CONNECTION_ASYNC); + PrepareStatement(CHAR_INS_EQUIP_SET, + "INSERT INTO character_equipmentsets (guid, setguid, setindex, name, iconname, ignore_mask, item0, item1, item2, item3, " + "item4, item5, item6, item7, item8, item9, item10, item11, item12, item13, item14, item15, item16, item17, item18) " + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", + CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_EQUIP_SET, "DELETE FROM character_equipmentsets WHERE setguid=?", CONNECTION_ASYNC); // Auras - PrepareStatement(CHAR_INS_AURA, "INSERT INTO character_aura (guid, casterGuid, spell, effectMask, recalculateMask, stackCount, amount0, amount1, amount2, base_amount0, base_amount1, base_amount2, maxduration, remaintime, remaincharges) " - "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); + PrepareStatement(CHAR_INS_AURA, + "INSERT INTO character_aura (guid, casterGuid, spell, effectMask, recalculateMask, stackCount, amount0, amount1, amount2, base_amount0, base_amount1, base_amount2, maxduration, remaintime, " + "remaincharges, critChance, applyResilience) " + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", + CONNECTION_ASYNC); // Currency PrepareStatement(CHAR_SEL_PLAYER_CURRENCY, "SELECT Currency, Quantity, WeeklyQuantity, TrackedQuantity, Flags FROM character_currency WHERE CharacterGuid = ?", CONNECTION_ASYNC); - PrepareStatement(CHAR_UPD_PLAYER_CURRENCY, "UPDATE character_currency SET Quantity = ?, WeeklyQuantity = ?, TrackedQuantity = ?, Flags = ? WHERE CharacterGuid = ? AND Currency = ?", CONNECTION_ASYNC); - PrepareStatement(CHAR_REP_PLAYER_CURRENCY, "REPLACE INTO character_currency (CharacterGuid, Currency, Quantity, WeeklyQuantity, TrackedQuantity, Flags) VALUES (?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); + PrepareStatement( + CHAR_UPD_PLAYER_CURRENCY, "UPDATE character_currency SET Quantity = ?, WeeklyQuantity = ?, TrackedQuantity = ?, Flags = ? WHERE CharacterGuid = ? AND Currency = ?", CONNECTION_ASYNC); + PrepareStatement( + CHAR_REP_PLAYER_CURRENCY, "REPLACE INTO character_currency (CharacterGuid, Currency, Quantity, WeeklyQuantity, TrackedQuantity, Flags) VALUES (?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_PLAYER_CURRENCY, "DELETE FROM character_currency WHERE CharacterGuid = ?", CONNECTION_ASYNC); // Account data @@ -316,7 +387,8 @@ void CharacterDatabaseConnection::DoPrepareStatements() PrepareStatement(CHAR_DEL_PETITION_SIGNATURE, "DELETE FROM petition_sign WHERE playerguid = ? AND type = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_SEL_PETITION_BY_OWNER, "SELECT petitionguid FROM petition WHERE ownerguid = ? AND type = ?", CONNECTION_SYNCH); PrepareStatement(CHAR_SEL_PETITION_TYPE, "SELECT type FROM petition WHERE petitionguid = ?", CONNECTION_SYNCH); - PrepareStatement(CHAR_SEL_PETITION_SIGNATURES, "SELECT ownerguid, (SELECT COUNT(playerguid) FROM petition_sign WHERE petition_sign.petitionguid = ?) AS signs, type FROM petition WHERE petitionguid = ?", CONNECTION_SYNCH); + PrepareStatement(CHAR_SEL_PETITION_SIGNATURES, + "SELECT ownerguid, (SELECT COUNT(playerguid) FROM petition_sign WHERE petition_sign.petitionguid = ?) AS signs, type FROM petition WHERE petitionguid = ?", CONNECTION_SYNCH); PrepareStatement(CHAR_SEL_PETITION_SIG_BY_ACCOUNT, "SELECT playerguid FROM petition_sign WHERE player_account = ? AND petitionguid = ?", CONNECTION_SYNCH); PrepareStatement(CHAR_SEL_PETITION_OWNER_BY_GUID, "SELECT ownerguid FROM petition WHERE petitionguid = ?", CONNECTION_SYNCH); PrepareStatement(CHAR_SEL_PETITION_SIG_BY_GUID, "SELECT ownerguid, petitionguid FROM petition_sign WHERE playerguid = ?", CONNECTION_SYNCH); @@ -324,20 +396,25 @@ void CharacterDatabaseConnection::DoPrepareStatements() // Arena teams PrepareStatement(CHAR_SEL_CHARACTER_ARENAINFO, "SELECT arenaTeamId, weekGames, seasonGames, seasonWins, personalRating FROM arena_team_member WHERE guid = ?", CONNECTION_ASYNC); - PrepareStatement(CHAR_INS_ARENA_TEAM, "INSERT INTO arena_team (arenaTeamId, name, captainGuid, type, rating, backgroundColor, emblemStyle, emblemColor, borderStyle, borderColor) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); + PrepareStatement(CHAR_INS_ARENA_TEAM, + "INSERT INTO arena_team (arenaTeamId, name, captainGuid, type, rating, backgroundColor, emblemStyle, emblemColor, borderStyle, borderColor) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", + CONNECTION_ASYNC); PrepareStatement(CHAR_INS_ARENA_TEAM_MEMBER, "INSERT INTO arena_team_member (arenaTeamId, guid) VALUES (?, ?)", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_ARENA_TEAM, "DELETE FROM arena_team where arenaTeamId = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_ARENA_TEAM_MEMBERS, "DELETE FROM arena_team_member WHERE arenaTeamId = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_UPD_ARENA_TEAM_CAPTAIN, "UPDATE arena_team SET captainGuid = ? WHERE arenaTeamId = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_ARENA_TEAM_MEMBER, "DELETE FROM arena_team_member WHERE arenaTeamId = ? AND guid = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_UPD_ARENA_TEAM_STATS, "UPDATE arena_team SET rating = ?, weekGames = ?, weekWins = ?, seasonGames = ?, seasonWins = ?, `rank` = ? WHERE arenaTeamId = ?", CONNECTION_ASYNC); - PrepareStatement(CHAR_UPD_ARENA_TEAM_MEMBER, "UPDATE arena_team_member SET personalRating = ?, weekGames = ?, weekWins = ?, seasonGames = ?, seasonWins = ? WHERE arenaTeamId = ? AND guid = ?", CONNECTION_ASYNC); + PrepareStatement(CHAR_UPD_ARENA_TEAM_MEMBER, "UPDATE arena_team_member SET personalRating = ?, weekGames = ?, weekWins = ?, seasonGames = ?, seasonWins = ? WHERE arenaTeamId = ? AND guid = ?", + CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_CHARACTER_ARENA_STATS, "DELETE FROM character_arena_stats WHERE guid = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_REP_CHARACTER_ARENA_STATS, "REPLACE INTO character_arena_stats (guid, slot, matchMakerRating) VALUES (?, ?, ?)", CONNECTION_ASYNC); PrepareStatement(CHAR_UPD_ARENA_TEAM_NAME, "UPDATE arena_team SET name = ? WHERE arenaTeamId = ?", CONNECTION_ASYNC); // Character battleground data - PrepareStatement(CHAR_INS_PLAYER_BGDATA, "INSERT INTO character_battleground_data (guid, instanceId, team, joinX, joinY, joinZ, joinO, joinMapId, taxiStart, taxiEnd, mountSpell) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); + PrepareStatement(CHAR_INS_PLAYER_BGDATA, + "INSERT INTO character_battleground_data (guid, instanceId, team, joinX, joinY, joinZ, joinO, joinMapId, taxiStart, taxiEnd, mountSpell) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", + CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_PLAYER_BGDATA, "DELETE FROM character_battleground_data WHERE guid = ?", CONNECTION_ASYNC); // Character homebind @@ -346,11 +423,17 @@ void CharacterDatabaseConnection::DoPrepareStatements() PrepareStatement(CHAR_DEL_PLAYER_HOMEBIND, "DELETE FROM character_homebind WHERE guid = ?", CONNECTION_ASYNC); // Corpse - PrepareStatement(CHAR_SEL_CORPSES, "SELECT posX, posY, posZ, orientation, mapId, displayId, itemCache, bytes1, bytes2, flags, dynFlags, time, corpseType, instanceId, guid FROM corpse WHERE mapId = ? AND instanceId = ?", CONNECTION_SYNCH); - PrepareStatement(CHAR_INS_CORPSE, "INSERT INTO corpse (guid, posX, posY, posZ, orientation, mapId, displayId, itemCache, bytes1, bytes2, flags, dynFlags, time, corpseType, instanceId) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); + PrepareStatement(CHAR_SEL_CORPSES, + "SELECT posX, posY, posZ, orientation, mapId, displayId, itemCache, bytes1, bytes2, flags, dynFlags, time, corpseType, instanceId, guid FROM corpse WHERE mapId = ? AND instanceId = ?", + CONNECTION_SYNCH); + PrepareStatement(CHAR_INS_CORPSE, + "INSERT INTO corpse (guid, posX, posY, posZ, orientation, mapId, displayId, itemCache, bytes1, bytes2, flags, dynFlags, time, corpseType, instanceId) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, " + "?, ?, ?, ?)", + CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_CORPSE, "DELETE FROM corpse WHERE guid = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_CORPSES_FROM_MAP, "DELETE cp, c FROM corpse_phases cp INNER JOIN corpse c ON cp.OwnerGuid = c.guid WHERE c.mapId = ? AND c.instanceId = ?", CONNECTION_ASYNC); - PrepareStatement(CHAR_SEL_CORPSE_PHASES, "SELECT cp.OwnerGuid, cp.PhaseId FROM corpse_phases cp LEFT JOIN corpse c ON cp.OwnerGuid = c.guid WHERE c.mapId = ? AND c.instanceId = ?", CONNECTION_SYNCH); + PrepareStatement( + CHAR_SEL_CORPSE_PHASES, "SELECT cp.OwnerGuid, cp.PhaseId FROM corpse_phases cp LEFT JOIN corpse c ON cp.OwnerGuid = c.guid WHERE c.mapId = ? AND c.instanceId = ?", CONNECTION_SYNCH); PrepareStatement(CHAR_INS_CORPSE_PHASES, "INSERT INTO corpse_phases (OwnerGuid, PhaseId) VALUES (?, ?)", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_CORPSE_PHASES, "DELETE FROM corpse_phases WHERE OwnerGuid = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_SEL_CORPSE_LOCATION, "SELECT mapId, posX, posY, posZ, orientation FROM corpse WHERE guid = ?", CONNECTION_ASYNC); @@ -362,8 +445,14 @@ void CharacterDatabaseConnection::DoPrepareStatements() PrepareStatement(CHAR_DEL_ALL_RESPAWNS, "DELETE FROM respawn WHERE mapId = ? AND instanceId = ?", CONNECTION_ASYNC); // GM Tickets - PrepareStatement(CHAR_SEL_GM_TICKETS, "SELECT id, type, playerGuid, name, description, createTime, mapId, posX, posY, posZ, lastModifiedTime, closedBy, assignedTo, comment, response, completed, escalated, viewed, needMoreHelp FROM gm_ticket", CONNECTION_SYNCH); - PrepareStatement(CHAR_REP_GM_TICKET, "REPLACE INTO gm_ticket (id, type, playerGuid, name, description, createTime, mapId, posX, posY, posZ, lastModifiedTime, closedBy, assignedTo, comment, response, completed, escalated, viewed, needMoreHelp, resolvedBy) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); + PrepareStatement(CHAR_SEL_GM_TICKETS, + "SELECT id, type, playerGuid, name, description, createTime, mapId, posX, posY, posZ, lastModifiedTime, closedBy, assignedTo, comment, response, completed, escalated, viewed, needMoreHelp " + "FROM gm_ticket", + CONNECTION_SYNCH); + PrepareStatement(CHAR_REP_GM_TICKET, + "REPLACE INTO gm_ticket (id, type, playerGuid, name, description, createTime, mapId, posX, posY, posZ, lastModifiedTime, closedBy, assignedTo, comment, response, completed, escalated, " + "viewed, needMoreHelp, resolvedBy) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", + CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_GM_TICKET, "DELETE FROM gm_ticket WHERE id = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_PLAYER_GM_TICKETS, "DELETE FROM gm_ticket WHERE playerGuid = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_UPD_PLAYER_GM_TICKETS_ON_CHAR_DELETION, "UPDATE gm_ticket SET type = 2 WHERE playerGuid = ?", CONNECTION_ASYNC); @@ -378,21 +467,26 @@ void CharacterDatabaseConnection::DoPrepareStatements() PrepareStatement(CHAR_DEL_LFG_DATA, "DELETE FROM lfg_data WHERE guid = ?", CONNECTION_ASYNC); // Player saving - PrepareStatement(CHAR_INS_CHARACTER, "INSERT INTO characters (guid, account, name, race, class, gender, level, xp, money, skin, face, hairStyle, hairColor, facialStyle, bankSlots, restState, playerFlags, " - "map, instance_id, instance_mode_mask, position_x, position_y, position_z, orientation, trans_x, trans_y, trans_z, trans_o, transguid, " - "taximask, cinematic, " - "totaltime, leveltime, rest_bonus, logout_time, is_logout_resting, resettalents_cost, resettalents_time, talentTree, " - "extra_flags, stable_slots, at_login, zone, " - "death_expire_time, taxi_path, totalKills, " - "todayKills, yesterdayKills, chosenTitle, watchedFaction, drunk, health, power1, power2, power3, " - "power4, power5, latency, talentGroupsCount, activeTalentGroup, exploredZones, equipmentCache, knownTitles, actionBars, grantableLevels, achievementPoints) VALUES " - "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", CONNECTION_ASYNC); - PrepareStatement(CHAR_UPD_CHARACTER, "UPDATE characters SET name=?,race=?,class=?,gender=?,level=?,xp=?,money=?,skin=?,face=?,hairStyle=?,hairColor=?,facialStyle=?,bankSlots=?,restState=?,playerFlags=?," - "map=?,instance_id=?,instance_mode_mask=?,position_x=?,position_y=?,position_z=?,orientation=?,trans_x=?,trans_y=?,trans_z=?,trans_o=?,transguid=?,taximask=?,cinematic=?," - "totaltime=?,leveltime=?,rest_bonus=?,logout_time=?,is_logout_resting=?,resettalents_cost=?,resettalents_time=?,talentTree=?,extra_flags=?,stable_slots=?,at_login=?,zone=?,death_expire_time=?,taxi_path=?," - "totalKills=?,todayKills=?,yesterdayKills=?,chosenTitle=?," - "watchedFaction=?,drunk=?,health=?,power1=?,power2=?,power3=?,power4=?,power5=?,latency=?,talentGroupsCount=?,activeTalentGroup=?,exploredZones=?," - "equipmentCache=?,knownTitles=?,actionBars=?,grantableLevels=?,achievementPoints=?,online=? WHERE guid=?", CONNECTION_ASYNC); + PrepareStatement(CHAR_INS_CHARACTER, + "INSERT INTO characters (guid, account, name, race, class, gender, level, xp, money, skin, face, hairStyle, hairColor, facialStyle, bankSlots, restState, playerFlags, " + "map, instance_id, instance_mode_mask, position_x, position_y, position_z, orientation, trans_x, trans_y, trans_z, trans_o, transguid, " + "taximask, cinematic, " + "totaltime, leveltime, rest_bonus, logout_time, is_logout_resting, resettalents_cost, resettalents_time, talentTree, " + "extra_flags, stable_slots, at_login, zone, " + "death_expire_time, taxi_path, totalKills, " + "todayKills, yesterdayKills, chosenTitle, watchedFaction, drunk, health, power1, power2, power3, " + "power4, power5, latency, talentGroupsCount, activeTalentGroup, exploredZones, equipmentCache, knownTitles, actionBars, grantableLevels, achievementPoints) VALUES " + "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", + CONNECTION_ASYNC); + PrepareStatement(CHAR_UPD_CHARACTER, + "UPDATE characters SET name=?,race=?,class=?,gender=?,level=?,xp=?,money=?,skin=?,face=?,hairStyle=?,hairColor=?,facialStyle=?,bankSlots=?,restState=?,playerFlags=?," + "map=?,instance_id=?,instance_mode_mask=?,position_x=?,position_y=?,position_z=?,orientation=?,trans_x=?,trans_y=?,trans_z=?,trans_o=?,transguid=?,taximask=?,cinematic=?," + "totaltime=?,leveltime=?,rest_bonus=?,logout_time=?,is_logout_resting=?,resettalents_cost=?,resettalents_time=?,talentTree=?,extra_flags=?,stable_slots=?,at_login=?,zone=?,death_expire_time=?" + ",taxi_path=?," + "totalKills=?,todayKills=?,yesterdayKills=?,chosenTitle=?," + "watchedFaction=?,drunk=?,health=?,power1=?,power2=?,power3=?,power4=?,power5=?,latency=?,talentGroupsCount=?,activeTalentGroup=?,exploredZones=?," + "equipmentCache=?,knownTitles=?,actionBars=?,grantableLevels=?,achievementPoints=?,online=? WHERE guid=?", + CONNECTION_ASYNC); PrepareStatement(CHAR_UPD_ADD_AT_LOGIN_FLAG, "UPDATE characters SET at_login = at_login | ? WHERE guid = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_UPD_REM_AT_LOGIN_FLAG, "UPDATE characters set at_login = at_login & ~ ? WHERE guid = ?", CONNECTION_ASYNC); @@ -401,7 +495,10 @@ void CharacterDatabaseConnection::DoPrepareStatements() PrepareStatement(CHAR_UPD_PETITION_NAME, "UPDATE petition SET name = ? WHERE petitionguid = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_INS_PETITION_SIGNATURE, "INSERT INTO petition_sign (ownerguid, petitionguid, playerguid, player_account) VALUES (?, ?, ?, ?)", CONNECTION_ASYNC); PrepareStatement(CHAR_UPD_ACCOUNT_ONLINE, "UPDATE characters SET online = 0 WHERE account = ?", CONNECTION_ASYNC); - PrepareStatement(CHAR_INS_GROUP, "INSERT INTO `groups` (guid, leaderGuid, lootMethod, looterGuid, lootThreshold, icon1, icon2, icon3, icon4, icon5, icon6, icon7, icon8, groupType, difficulty, raidDifficulty, masterLooterGuid) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); + PrepareStatement(CHAR_INS_GROUP, + "INSERT INTO `groups` (guid, leaderGuid, lootMethod, looterGuid, lootThreshold, icon1, icon2, icon3, icon4, icon5, icon6, icon7, icon8, groupType, difficulty, raidDifficulty, " + "masterLooterGuid) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", + CONNECTION_ASYNC); PrepareStatement(CHAR_INS_GROUP_MEMBER, "INSERT INTO group_member (guid, memberGuid, memberFlags, subgroup, roles) VALUES(?, ?, ?, ?, ?)", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_GROUP_MEMBER, "DELETE FROM group_member WHERE memberGuid = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_GROUP_INSTANCE_PERM_BINDING, "DELETE FROM group_instance WHERE guid = ? AND instance = ?", CONNECTION_ASYNC); @@ -414,8 +511,10 @@ void CharacterDatabaseConnection::DoPrepareStatements() PrepareStatement(CHAR_DEL_ALL_GM_TICKETS, "TRUNCATE TABLE gm_ticket", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_INVALID_SPELL_TALENTS, "DELETE FROM character_talent WHERE spell = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_INVALID_SPELL_SPELLS, "DELETE FROM character_spell WHERE spell = ?", CONNECTION_ASYNC); - PrepareStatement(CHAR_UPD_DELETE_INFO, "UPDATE characters SET deleteInfos_Name = name, deleteInfos_Account = account, deleteDate = UNIX_TIMESTAMP(), name = '', account = 0 WHERE guid = ?", CONNECTION_ASYNC); - PrepareStatement(CHAR_UPD_RESTORE_DELETE_INFO, "UPDATE characters SET name = ?, account = ?, deleteDate = NULL, deleteInfos_Name = NULL, deleteInfos_Account = NULL WHERE deleteDate IS NOT NULL AND guid = ?", CONNECTION_ASYNC); + PrepareStatement( + CHAR_UPD_DELETE_INFO, "UPDATE characters SET deleteInfos_Name = name, deleteInfos_Account = account, deleteDate = UNIX_TIMESTAMP(), name = '', account = 0 WHERE guid = ?", CONNECTION_ASYNC); + PrepareStatement(CHAR_UPD_RESTORE_DELETE_INFO, + "UPDATE characters SET name = ?, account = ?, deleteDate = NULL, deleteInfos_Name = NULL, deleteInfos_Account = NULL WHERE deleteDate IS NOT NULL AND guid = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_UPD_ZONE, "UPDATE characters SET zone = ? WHERE guid = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_UPD_LEVEL, "UPDATE characters SET level = ?, xp = 0 WHERE guid = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_INVALID_ACHIEV_PROGRESS_CRITERIA, "DELETE FROM character_achievement_progress WHERE criteria = ?", CONNECTION_ASYNC); @@ -443,19 +542,27 @@ void CharacterDatabaseConnection::DoPrepareStatements() PrepareStatement(CHAR_INS_CHARACTER_SOCIAL, "INSERT INTO character_social (guid, friend, flags) VALUES (?, ?, ?)", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_CHARACTER_SOCIAL, "DELETE FROM character_social WHERE guid = ? AND friend = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_UPD_CHARACTER_SOCIAL_NOTE, "UPDATE character_social SET note = ? WHERE guid = ? AND friend = ?", CONNECTION_ASYNC); - PrepareStatement(CHAR_UPD_CHARACTER_POSITION, "UPDATE characters SET position_x = ?, position_y = ?, position_z = ?, orientation = ?, map = ?, zone = ?, trans_x = 0, trans_y = 0, trans_z = 0, transguid = 0, taxi_path = '', cinematic = 1 WHERE guid = ?", CONNECTION_ASYNC); - PrepareStatement(CHAR_UPD_CHARACTER_POSITION_BY_MAPID, "UPDATE characters SET position_x = ?, position_y = ?, position_z = ?, orientation = ?, map = ?, zone = ?, trans_x = 0, trans_y = 0, trans_z = 0, transguid = 0, taxi_path = '', cinematic = 1 WHERE guid = ? AND map = ?", CONNECTION_ASYNC); - PrepareStatement(CHAR_SEL_CHARACTER_AURA_FROZEN, "SELECT characters.name, character_aura.remainTime FROM characters LEFT JOIN character_aura ON (characters.guid = character_aura.guid) WHERE character_aura.spell = 9454", CONNECTION_SYNCH); + PrepareStatement(CHAR_UPD_CHARACTER_POSITION, + "UPDATE characters SET position_x = ?, position_y = ?, position_z = ?, orientation = ?, map = ?, zone = ?, trans_x = 0, trans_y = 0, trans_z = 0, transguid = 0, taxi_path = '', cinematic = 1 " + "WHERE guid = ?", + CONNECTION_ASYNC); + PrepareStatement(CHAR_UPD_CHARACTER_POSITION_BY_MAPID, + "UPDATE characters SET position_x = ?, position_y = ?, position_z = ?, orientation = ?, map = ?, zone = ?, trans_x = 0, trans_y = 0, trans_z = 0, transguid = 0, taxi_path = '', cinematic = 1 " + "WHERE guid = ? AND map = ?", + CONNECTION_ASYNC); + PrepareStatement(CHAR_SEL_CHARACTER_AURA_FROZEN, + "SELECT characters.name, character_aura.remainTime FROM characters LEFT JOIN character_aura ON (characters.guid = character_aura.guid) WHERE character_aura.spell = 9454", CONNECTION_SYNCH); PrepareStatement(CHAR_SEL_CHARACTER_ONLINE, "SELECT name, account, map, zone FROM characters WHERE online > 0", CONNECTION_SYNCH); PrepareStatement(CHAR_SEL_CHAR_DEL_INFO_BY_GUID, "SELECT guid, deleteInfos_Name, deleteInfos_Account, deleteDate FROM characters WHERE deleteDate IS NOT NULL AND guid = ?", CONNECTION_SYNCH); - PrepareStatement(CHAR_SEL_CHAR_DEL_INFO_BY_NAME, "SELECT guid, deleteInfos_Name, deleteInfos_Account, deleteDate FROM characters WHERE deleteDate IS NOT NULL AND deleteInfos_Name LIKE CONCAT('%%', ?, '%%')", CONNECTION_SYNCH); + PrepareStatement(CHAR_SEL_CHAR_DEL_INFO_BY_NAME, + "SELECT guid, deleteInfos_Name, deleteInfos_Account, deleteDate FROM characters WHERE deleteDate IS NOT NULL AND deleteInfos_Name LIKE CONCAT('%%', ?, '%%')", CONNECTION_SYNCH); PrepareStatement(CHAR_SEL_CHAR_DEL_INFO, "SELECT guid, deleteInfos_Name, deleteInfos_Account, deleteDate FROM characters WHERE deleteDate IS NOT NULL", CONNECTION_SYNCH); PrepareStatement(CHAR_SEL_CHARS_BY_ACCOUNT_ID, "SELECT guid FROM characters WHERE account = ?", CONNECTION_SYNCH); PrepareStatement(CHAR_SEL_CHAR_PINFO, "SELECT totaltime, level, money, account, race, class, map, zone, gender, health, playerFlags FROM characters WHERE guid = ?", CONNECTION_SYNCH); PrepareStatement(CHAR_SEL_PINFO_BANS, "SELECT unbandate, bandate = unbandate, bannedby, banreason FROM character_banned WHERE guid = ? AND active ORDER BY bandate ASC LIMIT 1", CONNECTION_SYNCH); - //0: lowGUID + // 0: lowGUID PrepareStatement(CHAR_SEL_PINFO_MAILS, "SELECT SUM(CASE WHEN (checked & 1) THEN 1 ELSE 0 END) AS 'readmail', COUNT(*) AS 'totalmail' FROM mail WHERE `receiver` = ?", CONNECTION_SYNCH); - //0: lowGUID + // 0: lowGUID PrepareStatement(CHAR_SEL_PINFO_XP, "SELECT a.xp, b.guid FROM characters a LEFT JOIN guild_member b ON a.guid = b.guid WHERE a.guid = ?", CONNECTION_SYNCH); PrepareStatement(CHAR_SEL_CHAR_HOMEBIND, "SELECT mapId, zoneId, posX, posY, posZ FROM character_homebind WHERE guid = ?", CONNECTION_SYNCH); PrepareStatement(CHAR_SEL_CHAR_GUID_NAME_BY_ACC, "SELECT guid, name FROM characters WHERE account = ?", CONNECTION_SYNCH); @@ -465,24 +572,37 @@ void CharacterDatabaseConnection::DoPrepareStatements() PrepareStatement(CHAR_SEL_CHAR_RACE_OR_FACTION_CHANGE_INFOS, "SELECT at_login, knownTitles FROM characters WHERE guid = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_SEL_INSTANCE, "SELECT data, completedEncounters FROM instance WHERE map = ? AND id = ?", CONNECTION_SYNCH); PrepareStatement(CHAR_SEL_PERM_BIND_BY_INSTANCE, "SELECT guid FROM character_instance WHERE instance = ? and permanent = 1", CONNECTION_SYNCH); - PrepareStatement(CHAR_SEL_CHAR_COD_ITEM_MAIL, "SELECT id, messageType, mailTemplateId, sender, subject, body, money, has_items FROM mail WHERE receiver = ? AND has_items <> 0 AND cod <> 0", CONNECTION_SYNCH); + PrepareStatement( + CHAR_SEL_CHAR_COD_ITEM_MAIL, "SELECT id, messageType, mailTemplateId, sender, subject, body, money, has_items FROM mail WHERE receiver = ? AND has_items <> 0 AND cod <> 0", CONNECTION_SYNCH); PrepareStatement(CHAR_SEL_CHAR_SOCIAL, "SELECT DISTINCT guid FROM character_social WHERE friend = ?", CONNECTION_SYNCH); PrepareStatement(CHAR_SEL_CHAR_OLD_CHARS, "SELECT guid, deleteInfos_Account FROM characters WHERE deleteDate IS NOT NULL AND deleteDate < ?", CONNECTION_SYNCH); - PrepareStatement(CHAR_SEL_MAIL, "SELECT id, messageType, sender, receiver, subject, body, expire_time, deliver_time, money, cod, checked, stationery, mailTemplateId FROM mail WHERE receiver = ? ORDER BY id DESC", CONNECTION_ASYNC); + PrepareStatement(CHAR_SEL_MAIL, + "SELECT id, messageType, sender, receiver, subject, body, expire_time, deliver_time, money, cod, checked, stationery, mailTemplateId FROM mail WHERE receiver = ? ORDER BY id DESC", + CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_CHAR_AURA_FROZEN, "DELETE FROM character_aura WHERE spell = 9454 AND guid = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_SEL_CHAR_INVENTORY_COUNT_ITEM, "SELECT COUNT(itemEntry) FROM character_inventory ci INNER JOIN item_instance ii ON ii.guid = ci.item WHERE itemEntry = ?", CONNECTION_SYNCH); PrepareStatement(CHAR_SEL_MAIL_COUNT_ITEM, "SELECT COUNT(itemEntry) FROM mail_items mi INNER JOIN item_instance ii ON ii.guid = mi.item_guid WHERE itemEntry = ?", CONNECTION_SYNCH); - PrepareStatement(CHAR_SEL_AUCTIONHOUSE_COUNT_ITEM,"SELECT COUNT(itemEntry) FROM auctionhouse ah INNER JOIN item_instance ii ON ii.guid = ah.itemguid WHERE itemEntry = ?", CONNECTION_SYNCH); + PrepareStatement(CHAR_SEL_AUCTIONHOUSE_COUNT_ITEM, "SELECT COUNT(itemEntry) FROM auctionhouse ah INNER JOIN item_instance ii ON ii.guid = ah.itemguid WHERE itemEntry = ?", CONNECTION_SYNCH); PrepareStatement(CHAR_SEL_GUILD_BANK_COUNT_ITEM, "SELECT COUNT(itemEntry) FROM guild_bank_item gbi INNER JOIN item_instance ii ON ii.guid = gbi.item_guid WHERE itemEntry = ?", CONNECTION_SYNCH); - PrepareStatement(CHAR_SEL_CHAR_INVENTORY_ITEM_BY_ENTRY, "SELECT ci.item, cb.slot AS bag, ci.slot, ci.guid, c.account, c.name FROM characters c " - "INNER JOIN character_inventory ci ON ci.guid = c.guid " - "INNER JOIN item_instance ii ON ii.guid = ci.item " - "LEFT JOIN character_inventory cb ON cb.item = ci.bag WHERE ii.itemEntry = ? LIMIT ?", CONNECTION_SYNCH); - PrepareStatement(CHAR_SEL_MAIL_ITEMS_BY_ENTRY, "SELECT mi.item_guid, m.sender, m.receiver, cs.account, cs.name, cr.account, cr.name " - "FROM mail m INNER JOIN mail_items mi ON mi.mail_id = m.id INNER JOIN item_instance ii ON ii.guid = mi.item_guid " - "INNER JOIN characters cs ON cs.guid = m.sender INNER JOIN characters cr ON cr.guid = m.receiver WHERE ii.itemEntry = ? LIMIT ?", CONNECTION_SYNCH); - PrepareStatement(CHAR_SEL_AUCTIONHOUSE_ITEM_BY_ENTRY, "SELECT ah.itemguid, ah.itemowner, c.account, c.name FROM auctionhouse ah INNER JOIN characters c ON c.guid = ah.itemowner INNER JOIN item_instance ii ON ii.guid = ah.itemguid WHERE ii.itemEntry = ? LIMIT ?", CONNECTION_SYNCH); - PrepareStatement(CHAR_SEL_GUILD_BANK_ITEM_BY_ENTRY, "SELECT gi.item_guid, gi.guildid, g.name FROM guild_bank_item gi INNER JOIN guild g ON g.guildid = gi.guildid INNER JOIN item_instance ii ON ii.guid = gi.item_guid WHERE ii.itemEntry = ? LIMIT ?", CONNECTION_SYNCH); + PrepareStatement(CHAR_SEL_CHAR_INVENTORY_ITEM_BY_ENTRY, + "SELECT ci.item, cb.slot AS bag, ci.slot, ci.guid, c.account, c.name FROM characters c " + "INNER JOIN character_inventory ci ON ci.guid = c.guid " + "INNER JOIN item_instance ii ON ii.guid = ci.item " + "LEFT JOIN character_inventory cb ON cb.item = ci.bag WHERE ii.itemEntry = ? LIMIT ?", + CONNECTION_SYNCH); + PrepareStatement(CHAR_SEL_MAIL_ITEMS_BY_ENTRY, + "SELECT mi.item_guid, m.sender, m.receiver, cs.account, cs.name, cr.account, cr.name " + "FROM mail m INNER JOIN mail_items mi ON mi.mail_id = m.id INNER JOIN item_instance ii ON ii.guid = mi.item_guid " + "INNER JOIN characters cs ON cs.guid = m.sender INNER JOIN characters cr ON cr.guid = m.receiver WHERE ii.itemEntry = ? LIMIT ?", + CONNECTION_SYNCH); + PrepareStatement(CHAR_SEL_AUCTIONHOUSE_ITEM_BY_ENTRY, + "SELECT ah.itemguid, ah.itemowner, c.account, c.name FROM auctionhouse ah INNER JOIN characters c ON c.guid = ah.itemowner INNER JOIN item_instance ii ON ii.guid = ah.itemguid WHERE " + "ii.itemEntry = ? LIMIT ?", + CONNECTION_SYNCH); + PrepareStatement(CHAR_SEL_GUILD_BANK_ITEM_BY_ENTRY, + "SELECT gi.item_guid, gi.guildid, g.name FROM guild_bank_item gi INNER JOIN guild g ON g.guildid = gi.guildid INNER JOIN item_instance ii ON ii.guid = gi.item_guid WHERE ii.itemEntry = ? " + "LIMIT ?", + CONNECTION_SYNCH); PrepareStatement(CHAR_DEL_CHAR_ACHIEVEMENT, "DELETE FROM character_achievement WHERE guid = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_CHAR_ACHIEVEMENT_PROGRESS, "DELETE FROM character_achievement_progress WHERE guid = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_INS_CHAR_ACHIEVEMENT, "INSERT INTO character_achievement (guid, achievement, date) VALUES (?, ?, ?)", CONNECTION_ASYNC); @@ -497,10 +617,15 @@ void CharacterDatabaseConnection::DoPrepareStatements() PrepareStatement(CHAR_INS_CHAR_GIFT, "INSERT INTO character_gifts (guid, item_guid, entry, flags) VALUES (?, ?, ?, ?)", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_INSTANCE_BY_INSTANCE, "DELETE FROM instance WHERE id = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_CHAR_INSTANCE_BY_INSTANCE, "DELETE FROM character_instance WHERE instance = ?", CONNECTION_ASYNC); - PrepareStatement(CHAR_DEL_EXPIRED_CHAR_INSTANCE_BY_MAP_DIFF, "DELETE FROM character_instance USING character_instance LEFT JOIN instance ON character_instance.instance = id WHERE (extendState = 0 or permanent = 0) and map = ? and difficulty = ?", CONNECTION_ASYNC); - PrepareStatement(CHAR_DEL_GROUP_INSTANCE_BY_MAP_DIFF, "DELETE FROM group_instance USING group_instance LEFT JOIN instance ON group_instance.instance = id WHERE map = ? and difficulty = ?", CONNECTION_ASYNC); - PrepareStatement(CHAR_DEL_EXPIRED_INSTANCE_BY_MAP_DIFF, "DELETE FROM instance WHERE map = ? and difficulty = ? and (SELECT guid FROM character_instance WHERE extendState != 0 AND instance = id LIMIT 1) IS NULL", CONNECTION_ASYNC); - PrepareStatement(CHAR_UPD_EXPIRE_CHAR_INSTANCE_BY_MAP_DIFF, "UPDATE character_instance LEFT JOIN instance ON character_instance.instance = id SET extendState = extendState-1 WHERE map = ? and difficulty = ?", CONNECTION_ASYNC); + PrepareStatement(CHAR_DEL_EXPIRED_CHAR_INSTANCE_BY_MAP_DIFF, + "DELETE FROM character_instance USING character_instance LEFT JOIN instance ON character_instance.instance = id WHERE (extendState = 0 or permanent = 0) and map = ? and difficulty = ?", + CONNECTION_ASYNC); + PrepareStatement( + CHAR_DEL_GROUP_INSTANCE_BY_MAP_DIFF, "DELETE FROM group_instance USING group_instance LEFT JOIN instance ON group_instance.instance = id WHERE map = ? and difficulty = ?", CONNECTION_ASYNC); + PrepareStatement(CHAR_DEL_EXPIRED_INSTANCE_BY_MAP_DIFF, + "DELETE FROM instance WHERE map = ? and difficulty = ? and (SELECT guid FROM character_instance WHERE extendState != 0 AND instance = id LIMIT 1) IS NULL", CONNECTION_ASYNC); + PrepareStatement(CHAR_UPD_EXPIRE_CHAR_INSTANCE_BY_MAP_DIFF, + "UPDATE character_instance LEFT JOIN instance ON character_instance.instance = id SET extendState = extendState-1 WHERE map = ? and difficulty = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_MAIL_ITEM_BY_ID, "DELETE FROM mail_items WHERE mail_id = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_INS_PETITION, "INSERT INTO petition (ownerguid, petitionguid, name, type) VALUES (?, ?, ?, ?)", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_PETITION_BY_GUID, "DELETE FROM petition WHERE petitionguid = ?", CONNECTION_ASYNC); @@ -517,7 +642,8 @@ void CharacterDatabaseConnection::DoPrepareStatements() PrepareStatement(CHAR_DEL_CHAR_SOCIAL_BY_FRIEND, "DELETE FROM character_social WHERE friend = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_CHAR_ACHIEVEMENT_BY_ACHIEVEMENT, "DELETE FROM character_achievement WHERE achievement = ? AND guid = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_UPD_CHAR_ACHIEVEMENT, "UPDATE character_achievement SET achievement = ? where achievement = ? AND guid = ?", CONNECTION_ASYNC); - PrepareStatement(CHAR_UPD_CHAR_INVENTORY_FACTION_CHANGE, "UPDATE item_instance ii, character_inventory ci SET ii.itemEntry = ? WHERE ii.itemEntry = ? AND ci.guid = ? AND ci.item = ii.guid", CONNECTION_ASYNC); + PrepareStatement( + CHAR_UPD_CHAR_INVENTORY_FACTION_CHANGE, "UPDATE item_instance ii, character_inventory ci SET ii.itemEntry = ? WHERE ii.itemEntry = ? AND ci.guid = ? AND ci.item = ii.guid", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_CHAR_SPELL_BY_SPELL, "DELETE FROM character_spell WHERE spell = ? AND guid = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_UPD_CHAR_SPELL_FACTION_CHANGE, "UPDATE character_spell SET spell = ? where spell = ? AND guid = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_SEL_CHAR_REP_BY_FACTION, "SELECT standing FROM character_reputation WHERE faction = ? AND guid = ?", CONNECTION_SYNCH); @@ -538,7 +664,9 @@ void CharacterDatabaseConnection::DoPrepareStatements() PrepareStatement(CHAR_DEL_CHAR_SPELL, "DELETE FROM character_spell WHERE guid = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_MAIL, "DELETE FROM mail WHERE receiver = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_MAIL_ITEMS, "DELETE FROM mail_items WHERE receiver = ?", CONNECTION_ASYNC); - PrepareStatement(CHAR_DEL_CHAR_ACHIEVEMENTS, "DELETE FROM character_achievement WHERE guid = ? AND achievement NOT BETWEEN '456' AND '467' AND achievement NOT BETWEEN '1400' AND '1427' AND achievement NOT IN(1463, 3117, 3259)", CONNECTION_ASYNC); + PrepareStatement(CHAR_DEL_CHAR_ACHIEVEMENTS, + "DELETE FROM character_achievement WHERE guid = ? AND achievement NOT BETWEEN '456' AND '467' AND achievement NOT BETWEEN '1400' AND '1427' AND achievement NOT IN(1463, 3117, 3259)", + CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_CHAR_EQUIPMENTSETS, "DELETE FROM character_equipmentsets WHERE guid = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_GUILD_EVENTLOG_BY_PLAYER, "DELETE FROM guild_eventlog WHERE PlayerGuid1 = ? OR PlayerGuid2 = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_GUILD_BANK_EVENTLOG_BY_PLAYER, "DELETE FROM guild_bank_eventlog WHERE PlayerGuid = ?", CONNECTION_ASYNC); @@ -552,7 +680,10 @@ void CharacterDatabaseConnection::DoPrepareStatements() PrepareStatement(CHAR_DEL_CHAR_INVENTORY_BY_ITEM, "DELETE FROM character_inventory WHERE item = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_CHAR_INVENTORY_BY_BAG_SLOT, "DELETE FROM character_inventory WHERE bag = ? AND slot = ? AND guid = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_UPD_MAIL, "UPDATE mail SET has_items = ?, expire_time = ?, deliver_time = ?, money = ?, cod = ?, checked = ? WHERE id = ?", CONNECTION_ASYNC); - PrepareStatement(CHAR_REP_CHAR_QUESTSTATUS, "REPLACE INTO character_queststatus (guid, quest, status, explored, timer, mobcount1, mobcount2, mobcount3, mobcount4, itemcount1, itemcount2, itemcount3, itemcount4, itemcount5, itemcount6, playercount) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); + PrepareStatement(CHAR_REP_CHAR_QUESTSTATUS, + "REPLACE INTO character_queststatus (guid, quest, status, explored, timer, mobcount1, mobcount2, mobcount3, mobcount4, itemcount1, itemcount2, itemcount3, itemcount4, itemcount5, itemcount6, " + "playercount) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", + CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_CHAR_QUESTSTATUS_BY_QUEST, "DELETE FROM character_queststatus WHERE guid = ? AND quest = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_INS_CHAR_QUESTSTATUS_REWARDED, "INSERT IGNORE INTO character_queststatus_rewarded (guid, quest, active) VALUES (?, ?, 1)", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_CHAR_QUESTSTATUS_REWARDED_BY_QUEST, "DELETE FROM character_queststatus_rewarded WHERE guid = ? AND quest = ?", CONNECTION_ASYNC); @@ -564,14 +695,17 @@ void CharacterDatabaseConnection::DoPrepareStatements() PrepareStatement(CHAR_UPD_CHAR_SKILLS, "UPDATE character_skills SET value = ?, max = ? WHERE guid = ? AND skill = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_INS_CHAR_SPELL, "INSERT INTO character_spell (guid, spell, active, disabled) VALUES (?, ?, ?, ?)", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_CHAR_STATS, "DELETE FROM character_stats WHERE guid = ?", CONNECTION_ASYNC); - PrepareStatement(CHAR_INS_CHAR_STATS, "INSERT INTO character_stats (guid, maxhealth, maxpower1, maxpower2, maxpower3, maxpower4, maxpower5, strength, agility, stamina, intellect, spirit, " - "armor, resHoly, resFire, resNature, resFrost, resShadow, resArcane, blockPct, dodgePct, parryPct, critPct, rangedCritPct, spellCritPct, attackPower, rangedAttackPower, " - "spellPower, resilience) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); + PrepareStatement(CHAR_INS_CHAR_STATS, + "INSERT INTO character_stats (guid, maxhealth, maxpower1, maxpower2, maxpower3, maxpower4, maxpower5, strength, agility, stamina, intellect, spirit, " + "armor, resHoly, resFire, resNature, resFrost, resShadow, resArcane, blockPct, dodgePct, parryPct, critPct, rangedCritPct, spellCritPct, attackPower, rangedAttackPower, " + "spellPower, resilience) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", + CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_PETITION_BY_OWNER, "DELETE FROM petition WHERE ownerguid = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_PETITION_SIGNATURE_BY_OWNER, "DELETE FROM petition_sign WHERE ownerguid = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_PETITION_BY_OWNER_AND_TYPE, "DELETE FROM petition WHERE ownerguid = ? AND type = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_PETITION_SIGNATURE_BY_OWNER_AND_TYPE, "DELETE FROM petition_sign WHERE ownerguid = ? AND type = ?", CONNECTION_ASYNC); - PrepareStatement(CHAR_INS_CHAR_GLYPHS, "INSERT INTO character_glyphs (guid, talentGroup, glyph1, glyph2, glyph3, glyph4, glyph5, glyph6, glyph7, glyph8, glyph9) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); + PrepareStatement(CHAR_INS_CHAR_GLYPHS, + "INSERT INTO character_glyphs (guid, talentGroup, glyph1, glyph2, glyph3, glyph4, glyph5, glyph6, glyph7, glyph8, glyph9) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_CHAR_TALENT_BY_SPELL_SPEC, "DELETE FROM character_talent WHERE guid = ? AND spell = ? AND talentGroup = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_INS_CHAR_TALENT, "INSERT INTO character_talent (guid, spell, talentGroup) VALUES (?, ?, ?)", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_CHAR_ACTION_EXCEPT_SPEC, "DELETE FROM character_action WHERE spec<>? AND guid = ?", CONNECTION_ASYNC); @@ -580,32 +714,45 @@ void CharacterDatabaseConnection::DoPrepareStatements() PrepareStatement(CHAR_UPD_CHAR_LIST_SLOT, "UPDATE characters SET slot = ? WHERE guid = ?", CONNECTION_ASYNC); // Void Storage - PrepareStatement(CHAR_SEL_CHAR_VOID_STORAGE, "SELECT itemId, itemEntry, slot, creatorGuid, randomPropertyType, randomProperty, suffixFactor FROM character_void_storage WHERE playerGuid = ?", CONNECTION_ASYNC); - PrepareStatement(CHAR_REP_CHAR_VOID_STORAGE_ITEM, "REPLACE INTO character_void_storage (itemId, playerGuid, itemEntry, slot, creatorGuid, randomPropertyType, randomProperty, suffixFactor) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); + PrepareStatement( + CHAR_SEL_CHAR_VOID_STORAGE, "SELECT itemId, itemEntry, slot, creatorGuid, randomPropertyType, randomProperty, suffixFactor FROM character_void_storage WHERE playerGuid = ?", CONNECTION_ASYNC); + PrepareStatement(CHAR_REP_CHAR_VOID_STORAGE_ITEM, + "REPLACE INTO character_void_storage (itemId, playerGuid, itemEntry, slot, creatorGuid, randomPropertyType, randomProperty, suffixFactor) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_CHAR_VOID_STORAGE_ITEM_BY_SLOT, "DELETE FROM character_void_storage WHERE slot = ? AND playerGuid = ?", CONNECTION_ASYNC); // CompactUnitFrame profiles - PrepareStatement(CHAR_SEL_CHAR_CUF_PROFILES, "SELECT id, name, frameHeight, frameWidth, sortBy, healthText, boolOptions, unk146, unk147, unk148, unk150, unk152, unk154 FROM character_cuf_profiles WHERE guid = ?", CONNECTION_ASYNC); - PrepareStatement(CHAR_REP_CHAR_CUF_PROFILES, "REPLACE INTO character_cuf_profiles (guid, id, name, frameHeight, frameWidth, sortBy, healthText, boolOptions, unk146, unk147, unk148, unk150, unk152, unk154) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); + PrepareStatement(CHAR_SEL_CHAR_CUF_PROFILES, + "SELECT id, name, frameHeight, frameWidth, sortBy, healthText, boolOptions, unk146, unk147, unk148, unk150, unk152, unk154 FROM character_cuf_profiles WHERE guid = ?", CONNECTION_ASYNC); + PrepareStatement(CHAR_REP_CHAR_CUF_PROFILES, + "REPLACE INTO character_cuf_profiles (guid, id, name, frameHeight, frameWidth, sortBy, healthText, boolOptions, unk146, unk147, unk148, unk150, unk152, unk154) VALUES (?, ?, ?, ?, ?, ?, ?, " + "?, ?, ?, ?, ?, ?, ?)", + CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_CHAR_CUF_PROFILES, "DELETE FROM character_cuf_profiles WHERE guid = ? and id = ?", CONNECTION_ASYNC); // Guild Finder - PrepareStatement(CHAR_REP_GUILD_FINDER_APPLICANT, "REPLACE INTO guild_finder_applicant (guildId, playerGuid, availability, classRole, interests, comment, submitTime) VALUES(?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); + PrepareStatement(CHAR_REP_GUILD_FINDER_APPLICANT, "REPLACE INTO guild_finder_applicant (guildId, playerGuid, availability, classRole, interests, comment, submitTime) VALUES(?, ?, ?, ?, ?, ?, ?)", + CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_GUILD_FINDER_APPLICANT, "DELETE FROM guild_finder_applicant WHERE guildId = ? AND playerGuid = ?", CONNECTION_ASYNC); - PrepareStatement(CHAR_REP_GUILD_FINDER_GUILD_SETTINGS, "REPLACE INTO guild_finder_guild_settings (guildId, availability, classRoles, interests, level, listed, comment) VALUES(?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); + PrepareStatement(CHAR_REP_GUILD_FINDER_GUILD_SETTINGS, + "REPLACE INTO guild_finder_guild_settings (guildId, availability, classRoles, interests, level, listed, comment) VALUES(?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_GUILD_FINDER_GUILD_SETTINGS, "DELETE FROM guild_finder_guild_settings WHERE guildId = ?", CONNECTION_ASYNC); // Items that hold loot or money - PrepareStatement(CHAR_SEL_ITEMCONTAINER_ITEMS, "SELECT container_id, item_id, item_count, follow_rules, ffa, blocked, counted, under_threshold, needs_quest, rnd_type, rnd_prop, rnd_suffix FROM item_loot_items", CONNECTION_SYNCH); + PrepareStatement(CHAR_SEL_ITEMCONTAINER_ITEMS, + "SELECT container_id, item_id, item_count, follow_rules, ffa, blocked, counted, under_threshold, needs_quest, rnd_type, rnd_prop, rnd_suffix FROM item_loot_items", CONNECTION_SYNCH); PrepareStatement(CHAR_DEL_ITEMCONTAINER_ITEMS, "DELETE FROM item_loot_items WHERE container_id = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_ITEMCONTAINER_ITEM, "DELETE FROM item_loot_items WHERE container_id = ? AND item_id = ? AND item_count = ?", CONNECTION_ASYNC); - PrepareStatement(CHAR_INS_ITEMCONTAINER_ITEMS, "INSERT INTO item_loot_items (container_id, item_id, item_count, follow_rules, ffa, blocked, counted, under_threshold, needs_quest, rnd_type, rnd_prop, rnd_suffix) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); + PrepareStatement(CHAR_INS_ITEMCONTAINER_ITEMS, + "INSERT INTO item_loot_items (container_id, item_id, item_count, follow_rules, ffa, blocked, counted, under_threshold, needs_quest, rnd_type, rnd_prop, rnd_suffix) VALUES (?, ?, ?, ?, ?, ?, " + "?, ?, ?, ?, ?, ?)", + CONNECTION_ASYNC); PrepareStatement(CHAR_SEL_ITEMCONTAINER_MONEY, "SELECT container_id, money FROM item_loot_money", CONNECTION_SYNCH); PrepareStatement(CHAR_DEL_ITEMCONTAINER_MONEY, "DELETE FROM item_loot_money WHERE container_id = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_INS_ITEMCONTAINER_MONEY, "INSERT INTO item_loot_money (container_id, money) VALUES (?, ?)", CONNECTION_ASYNC); // Calendar - PrepareStatement(CHAR_REP_CALENDAR_EVENT, "REPLACE INTO calendar_events (id, creator, title, description, type, dungeon, eventtime, flags, time2) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); + PrepareStatement( + CHAR_REP_CALENDAR_EVENT, "REPLACE INTO calendar_events (id, creator, title, description, type, dungeon, eventtime, flags, time2) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_CALENDAR_EVENT, "DELETE FROM calendar_events WHERE id = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_REP_CALENDAR_INVITE, "REPLACE INTO calendar_invites (id, event, invitee, sender, status, statustime, `rank`, text) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_CALENDAR_INVITE, "DELETE FROM calendar_invites WHERE id = ?", CONNECTION_ASYNC); @@ -615,12 +762,18 @@ void CharacterDatabaseConnection::DoPrepareStatements() PrepareStatement(CHAR_SEL_PET_SLOTS_DETAIL, "SELECT slot, id, entry, modelid, level, name FROM character_pet WHERE owner = ? AND slot >= ? AND slot <= ? ORDER BY slot", CONNECTION_ASYNC); PrepareStatement(CHAR_SEL_PET_ENTRY, "SELECT entry FROM character_pet WHERE owner = ? AND id = ? AND slot >= ? AND slot <= ?", CONNECTION_ASYNC); PrepareStatement(CHAR_SEL_PET_SLOT_BY_ID, "SELECT slot, id, entry FROM character_pet WHERE owner = ? AND id = ?", CONNECTION_ASYNC); - PrepareStatement(CHAR_SEL_PET_SPELL_LIST, "SELECT DISTINCT pet_spell.spell FROM pet_spell, character_pet WHERE character_pet.owner = ? AND character_pet.id = pet_spell.guid AND character_pet.id <> ?", CONNECTION_SYNCH); + PrepareStatement(CHAR_SEL_PET_SPELL_LIST, + "SELECT DISTINCT pet_spell.spell FROM pet_spell, character_pet WHERE character_pet.owner = ? AND character_pet.id = pet_spell.guid AND character_pet.id <> ?", CONNECTION_SYNCH); PrepareStatement(CHAR_SEL_CHAR_PETS, "SELECT id FROM character_pet WHERE owner = ?", CONNECTION_SYNCH); PrepareStatement(CHAR_DEL_CHAR_PET_DECLINEDNAME_BY_OWNER, "DELETE FROM character_pet_declinedname WHERE owner = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_CHAR_PET_DECLINEDNAME, "DELETE FROM character_pet_declinedname WHERE id = ?", CONNECTION_ASYNC); - PrepareStatement(CHAR_INS_CHAR_PET_DECLINEDNAME, "INSERT INTO character_pet_declinedname (id, owner, genitive, dative, accusative, instrumental, prepositional) VALUES (?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); - PrepareStatement(CHAR_SEL_PET_AURA, "SELECT casterGuid, spell, effectMask, recalculateMask, stackCount, amount0, amount1, amount2, base_amount0, base_amount1, base_amount2, maxDuration, remainTime, remainCharges FROM pet_aura WHERE guid = ?", CONNECTION_SYNCH); + PrepareStatement( + CHAR_INS_CHAR_PET_DECLINEDNAME, "INSERT INTO character_pet_declinedname (id, owner, genitive, dative, accusative, instrumental, prepositional) VALUES (?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); + PrepareStatement(CHAR_SEL_PET_AURA, + "SELECT casterGuid, spell, effectMask, recalculateMask, stackCount, amount0, amount1, amount2, base_amount0, base_amount1, base_amount2, maxDuration, remainTime, remainCharges, critChance, " + "applyResilience FROM pet_aura " + "WHERE guid = ?", + CONNECTION_SYNCH); PrepareStatement(CHAR_SEL_PET_SPELL, "SELECT spell, active FROM pet_spell WHERE guid = ?", CONNECTION_SYNCH); PrepareStatement(CHAR_SEL_PET_SPELL_COOLDOWN, "SELECT spell, time, categoryId, categoryEnd FROM pet_spell_cooldown WHERE guid = ? AND time > UNIX_TIMESTAMP()", CONNECTION_SYNCH); PrepareStatement(CHAR_SEL_PET_DECLINED_NAME, "SELECT genitive, dative, accusative, instrumental, prepositional FROM character_pet_declinedname WHERE owner = ? AND id = ?", CONNECTION_SYNCH); @@ -630,28 +783,41 @@ void CharacterDatabaseConnection::DoPrepareStatements() PrepareStatement(CHAR_INS_PET_SPELL_COOLDOWN, "INSERT INTO pet_spell_cooldown (guid, spell, time, categoryId, categoryEnd) VALUES (?, ?, ?, ?, ?)", CONNECTION_BOTH); PrepareStatement(CHAR_DEL_PET_SPELL_BY_SPELL, "DELETE FROM pet_spell WHERE guid = ? and spell = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_INS_PET_SPELL, "INSERT INTO pet_spell (guid, spell, active) VALUES (?, ?, ?)", CONNECTION_BOTH); - PrepareStatement(CHAR_INS_PET_AURA, "INSERT INTO pet_aura (guid, casterGuid, spell, effectMask, recalculateMask, stackCount, amount0, amount1, amount2, " - "base_amount0, base_amount1, base_amount2, maxDuration, remainTime, remainCharges) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_BOTH); + PrepareStatement(CHAR_INS_PET_AURA, + "INSERT INTO pet_aura (guid, casterGuid, spell, effectMask, recalculateMask, stackCount, amount0, amount1, amount2, " + "base_amount0, base_amount1, base_amount2, maxDuration, remainTime, remainCharges, critChance, applyResilience) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", + CONNECTION_BOTH); PrepareStatement(CHAR_DEL_CHAR_PET_BY_OWNER, "DELETE FROM character_pet WHERE owner = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_UPD_CHAR_PET_NAME, "UPDATE character_pet SET name = ?, renamed = 1 WHERE owner = ? AND id = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_UPD_CHAR_PET_SLOT_BY_SLOT, "UPDATE character_pet SET slot = ? WHERE owner = ? AND slot = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_UPD_CHAR_PET_SLOT_BY_ID, "UPDATE character_pet SET slot = ? WHERE owner = ? AND id = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_CHAR_PET_BY_ID, "DELETE FROM character_pet WHERE id = ?", CONNECTION_ASYNC); - PrepareStatement(CHAR_INS_PET, "INSERT INTO character_pet (id, entry, owner, modelid, level, exp, Reactstate, slot, name, renamed, active, curhealth, curmana, abdata, savetime, CreatedBySpell, PetType) " - "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); - PrepareStatement(CHAR_SEL_CHAR_ALL_PETS_DETAIL, "SELECT id, entry, owner, modelid, level, exp, Reactstate, slot, name, renamed, active, curhealth, curmana, abdata, savetime, CreatedBySpell, PetType FROM character_pet WHERE owner = ? ORDER BY slot", CONNECTION_ASYNC); + PrepareStatement(CHAR_INS_PET, + "INSERT INTO character_pet (id, entry, owner, modelid, level, exp, Reactstate, slot, name, renamed, active, curhealth, curmana, abdata, savetime, CreatedBySpell, PetType) " + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", + CONNECTION_ASYNC); + PrepareStatement(CHAR_SEL_CHAR_ALL_PETS_DETAIL, + "SELECT id, entry, owner, modelid, level, exp, Reactstate, slot, name, renamed, active, curhealth, curmana, abdata, savetime, CreatedBySpell, PetType FROM character_pet WHERE owner = ? ORDER " + "BY slot", + CONNECTION_ASYNC); // PvPstats PrepareStatement(CHAR_SEL_PVPSTATS_MAXID, "SELECT MAX(id) FROM pvpstats_battlegrounds", CONNECTION_SYNCH); PrepareStatement(CHAR_INS_PVPSTATS_BATTLEGROUND, "INSERT INTO pvpstats_battlegrounds (id, winner_faction, bracket_id, type, date) VALUES (?, ?, ?, ?, NOW())", CONNECTION_ASYNC); - PrepareStatement(CHAR_INS_PVPSTATS_PLAYER, "INSERT INTO pvpstats_players (battleground_id, character_guid, winner, score_killing_blows, score_deaths, score_honorable_kills, score_bonus_honor, score_damage_done, score_healing_done, attr_1, attr_2, attr_3, attr_4, attr_5) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); - PrepareStatement(CHAR_SEL_PVPSTATS_FACTIONS_OVERALL, "SELECT winner_faction, COUNT(*) AS count FROM pvpstats_battlegrounds WHERE DATEDIFF(NOW(), date) < 7 GROUP BY winner_faction ORDER BY winner_faction ASC", CONNECTION_SYNCH); + PrepareStatement(CHAR_INS_PVPSTATS_PLAYER, + "INSERT INTO pvpstats_players (battleground_id, character_guid, winner, score_killing_blows, score_deaths, score_honorable_kills, score_bonus_honor, score_damage_done, score_healing_done, " + "attr_1, attr_2, attr_3, attr_4, attr_5) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", + CONNECTION_ASYNC); + PrepareStatement(CHAR_SEL_PVPSTATS_FACTIONS_OVERALL, + "SELECT winner_faction, COUNT(*) AS count FROM pvpstats_battlegrounds WHERE DATEDIFF(NOW(), date) < 7 GROUP BY winner_faction ORDER BY winner_faction ASC", CONNECTION_SYNCH); // QuestTracker PrepareStatement(CHAR_INS_QUEST_TRACK, "INSERT INTO quest_tracker (id, character_guid, quest_accept_time, core_hash, core_revision) VALUES (?, ?, NOW(), ?, ?)", CONNECTION_ASYNC); PrepareStatement(CHAR_UPD_QUEST_TRACK_GM_COMPLETE, "UPDATE quest_tracker SET completed_by_gm = 1 WHERE id = ? AND character_guid = ? ORDER BY quest_accept_time DESC LIMIT 1", CONNECTION_ASYNC); - PrepareStatement(CHAR_UPD_QUEST_TRACK_COMPLETE_TIME, "UPDATE quest_tracker SET quest_complete_time = NOW() WHERE id = ? AND character_guid = ? ORDER BY quest_accept_time DESC LIMIT 1", CONNECTION_ASYNC); - PrepareStatement(CHAR_UPD_QUEST_TRACK_ABANDON_TIME, "UPDATE quest_tracker SET quest_abandon_time = NOW() WHERE id = ? AND character_guid = ? ORDER BY quest_accept_time DESC LIMIT 1", CONNECTION_ASYNC); + PrepareStatement( + CHAR_UPD_QUEST_TRACK_COMPLETE_TIME, "UPDATE quest_tracker SET quest_complete_time = NOW() WHERE id = ? AND character_guid = ? ORDER BY quest_accept_time DESC LIMIT 1", CONNECTION_ASYNC); + PrepareStatement( + CHAR_UPD_QUEST_TRACK_ABANDON_TIME, "UPDATE quest_tracker SET quest_abandon_time = NOW() WHERE id = ? AND character_guid = ? ORDER BY quest_accept_time DESC LIMIT 1", CONNECTION_ASYNC); // DeserterTracker PrepareStatement(CHAR_INS_DESERTER_TRACK, "INSERT INTO battleground_deserters (guid, type, datetime) VALUES (?, ?, NOW())", CONNECTION_ASYNC); diff --git a/src/server/game/Entities/Pet/Pet.cpp b/src/server/game/Entities/Pet/Pet.cpp index d215f7d4..45645464 100644 --- a/src/server/game/Entities/Pet/Pet.cpp +++ b/src/server/game/Entities/Pet/Pet.cpp @@ -15,30 +15,28 @@ * with this program. If not, see . */ +#include "Pet.h" #include "Common.h" #include "DatabaseEnv.h" +#include "Formulas.h" +#include "Group.h" #include "Log.h" -#include "WorldPacket.h" #include "ObjectMgr.h" +#include "Opcodes.h" #include "PhasingHandler.h" -#include "SpellMgr.h" -#include "Pet.h" -#include "Formulas.h" -#include "SpellHistory.h" -#include "SpellAuras.h" #include "SpellAuraEffects.h" +#include "SpellAuras.h" +#include "SpellHistory.h" +#include "SpellMgr.h" #include "Unit.h" #include "Util.h" -#include "Group.h" -#include "Opcodes.h" +#include "WorldPacket.h" #include "WorldSession.h" #define PET_XP_FACTOR 0.05f -Pet::Pet(Player* owner, PetType type) : - Guardian(nullptr, owner, true), m_usedTalentCount(0), m_removed(false), - m_petType(type), m_duration(0), m_auraRaidUpdateMask(0), m_loading(false), - m_declinedname(nullptr) +Pet::Pet(Player* owner, PetType type) + : Guardian(nullptr, owner, true), m_usedTalentCount(0), m_removed(false), m_petType(type), m_duration(0), m_auraRaidUpdateMask(0), m_loading(false), m_declinedname(nullptr) { ASSERT(GetOwner()); @@ -178,8 +176,7 @@ bool Pet::LoadPetData(Player* owner, uint32 petEntry, uint32 petnumber, bool cur if (!IsPositionValid()) { - LOG_ERROR("entities.pet", "Pet (guidlow %d, entry %d) not loaded. Suggested coordinates isn't valid (X: %f Y: %f)", - GetGUID().GetCounter(), GetEntry(), GetPositionX(), GetPositionY()); + LOG_ERROR("entities.pet", "Pet (guidlow %d, entry %d) not loaded. Suggested coordinates isn't valid (X: %f Y: %f)", GetGUID().GetCounter(), GetEntry(), GetPositionX(), GetPositionY()); return false; } @@ -197,22 +194,22 @@ bool Pet::LoadPetData(Player* owner, uint32 petEntry, uint32 petnumber, bool cur switch (getPetType()) { - case SUMMON_PET: - petlevel = owner->getLevel(); - SetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_CLASS, uint8(CLASS_MAGE)); - SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED); - break; - case HUNTER_PET: - SetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_CLASS, CLASS_WARRIOR); - SetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_GENDER, GENDER_NONE); - SetSheath(SHEATH_STATE_MELEE); - SetByteFlag(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PET_FLAGS, playerPetData->Renamed ? UNIT_CAN_BE_ABANDONED : UNIT_CAN_BE_RENAMED | UNIT_CAN_BE_ABANDONED); - SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED); - break; - default: - if (!IsPetGhoul()) - LOG_ERROR("entities.pet", "Pet have incorrect type (%u) for pet loading.", getPetType()); - break; + case SUMMON_PET: + petlevel = owner->getLevel(); + SetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_CLASS, uint8(CLASS_MAGE)); + SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED); + break; + case HUNTER_PET: + SetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_CLASS, CLASS_WARRIOR); + SetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_GENDER, GENDER_NONE); + SetSheath(SHEATH_STATE_MELEE); + SetByteFlag(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PET_FLAGS, playerPetData->Renamed ? UNIT_CAN_BE_ABANDONED : UNIT_CAN_BE_RENAMED | UNIT_CAN_BE_ABANDONED); + SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED); + break; + default: + if (!IsPetGhoul()) + LOG_ERROR("entities.pet", "Pet have incorrect type (%u) for pet loading.", getPetType()); + break; } SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, uint32(GameTime::GetGameTime())); // cast can't be helped here @@ -229,15 +226,14 @@ bool Pet::LoadPetData(Player* owner, uint32 petEntry, uint32 petnumber, bool cur if (!IsPositionValid()) { - LOG_ERROR("entities.pet", "Pet (guidlow %d, entry %d) not loaded. Suggested coordinates isn't valid (X: %f Y: %f)", - GetGUID().GetCounter(), GetEntry(), GetPositionX(), GetPositionY()); + LOG_ERROR("entities.pet", "Pet (guidlow %d, entry %d) not loaded. Suggested coordinates isn't valid (X: %f Y: %f)", GetGUID().GetCounter(), GetEntry(), GetPositionX(), GetPositionY()); return false; } SetReactState(ReactStates(playerPetData->Reactstate)); SetCanModifyStats(true); - if (getPetType() == SUMMON_PET && !current) //all (?) summon pets come with full health when called, but not when they are current + if (getPetType() == SUMMON_PET && !current) // all (?) summon pets come with full health when called, but not when they are current SetPower(POWER_MANA, GetMaxPower(POWER_MANA)); else { @@ -259,7 +255,7 @@ bool Pet::LoadPetData(Player* owner, uint32 petEntry, uint32 petnumber, bool cur /// @todo pets should be summoned from real cast instead of just faking it? if (summonSpellId) { - WorldPacket data(SMSG_SPELL_GO, (8+8+4+4+2)); + WorldPacket data(SMSG_SPELL_GO, (8 + 8 + 4 + 4 + 2)); data << owner->GetPackGUID(); data << owner->GetPackGUID(); data << uint8(0); @@ -273,7 +269,7 @@ bool Pet::LoadPetData(Player* owner, uint32 petEntry, uint32 petnumber, bool cur owner->SetMinion(this, true); map->AddToMap(ToCreature()); - InitTalentForLevel(); // set original talents points before spell loading + InitTalentForLevel(); // set original talents points before spell loading uint32 timediff = uint32(GameTime::GetGameTime() - playerPetData->Timediff); _LoadAuras(timediff); @@ -284,7 +280,7 @@ bool Pet::LoadPetData(Player* owner, uint32 petEntry, uint32 petnumber, bool cur m_charmInfo->LoadPetActionBar(playerPetData->Actionbar); _LoadSpells(); - InitTalentForLevel(); // re-init to check talent count + InitTalentForLevel(); // re-init to check talent count _LoadSpellCooldowns(); LearnPetPassives(); InitLevelupSpellsForLevel(); @@ -295,9 +291,9 @@ bool Pet::LoadPetData(Player* owner, uint32 petEntry, uint32 petnumber, bool cur CastPetScalingAuras(); } - CleanupActionBar(); // remove unknown spells from action bar after load + CleanupActionBar(); // remove unknown spells from action bar after load UpdateAllStats(); - SetFullHealth(); // Set full health and mana after pet scaling auras has been applied + SetFullHealth(); // Set full health and mana after pet scaling auras has been applied if (IsHunterPet()) CastSpell(this, SPELL_PET_ENERGIZE, true); @@ -338,7 +334,7 @@ bool Pet::LoadPetData(Player* owner, uint32 petEntry, uint32 petnumber, bool cur } } - //set last used pet number (for use in BG's) + // set last used pet number (for use in BG's) if (owner->GetTypeId() == TYPEID_PLAYER && isControlled() && !isTemporarySummoned() && (getPetType() == SUMMON_PET || getPetType() == HUNTER_PET)) owner->ToPlayer()->SetLastPetNumber(petId); @@ -458,7 +454,6 @@ void Pet::SavePetToDB(PetSaveMode mode) if (mode == PET_SAVE_NEW_PET) GetOwner()->AddToPlayerPetDataStore(playerPetData); - } // delete else @@ -498,7 +493,7 @@ void Pet::DeleteFromDB(ObjectGuid::LowType guidlow) CharacterDatabase.CommitTransaction(trans); } -void Pet::setDeathState(DeathState s) // overwrite virtual Creature::setDeathState and Unit::setDeathState +void Pet::setDeathState(DeathState s) // overwrite virtual Creature::setDeathState and Unit::setDeathState { Creature::setDeathState(s); if (getDeathState() == CORPSE) @@ -509,19 +504,19 @@ void Pet::setDeathState(DeathState s) // overwrite virtual SetUInt32Value(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_NONE); RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE); - //SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED); + // SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED); } } else if (getDeathState() == ALIVE) { - //RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED); + // RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED); CastPetAuras(true); } } void Pet::Update(uint32 diff) { - if (m_removed) // pet already removed, just wait in remove queue, no updates + if (m_removed) // pet already removed, just wait in remove queue, no updates return; if (m_loading) @@ -529,51 +524,51 @@ void Pet::Update(uint32 diff) switch (m_deathState) { - case CORPSE: + case CORPSE: + { + if (!IsHunterPet() || m_corpseRemoveTime <= GameTime::GetGameTime()) { - if (!IsHunterPet() || m_corpseRemoveTime <= GameTime::GetGameTime()) - { - Remove(PET_SAVE_DISMISS); //hunters' pets never get removed because of death, NEVER! - return; - } - break; + Remove(PET_SAVE_DISMISS); // hunters' pets never get removed because of death, NEVER! + return; } - case ALIVE: + break; + } + case ALIVE: + { + // unsummon pet that lost owner + Player* owner = GetOwner(); + if ((!IsWithinDistInMap(owner, GetMap()->GetVisibilityRange()) && !isPossessed()) || (isControlled() && !owner->GetPetGUID())) + // if (!owner || (!IsWithinDistInMap(owner, GetMap()->GetVisibilityDistance()) && (owner->GetCharmGUID() && (owner->GetCharmGUID() != GetGUID()))) || (isControlled() && !owner->GetPetGUID())) { - // unsummon pet that lost owner - Player* owner = GetOwner(); - if ((!IsWithinDistInMap(owner, GetMap()->GetVisibilityRange()) && !isPossessed()) || (isControlled() && !owner->GetPetGUID())) - //if (!owner || (!IsWithinDistInMap(owner, GetMap()->GetVisibilityDistance()) && (owner->GetCharmGUID() && (owner->GetCharmGUID() != GetGUID()))) || (isControlled() && !owner->GetPetGUID())) - { - Remove(PET_SAVE_DISMISS, true); - return; - } + Remove(PET_SAVE_DISMISS, true); + return; + } - if (isControlled()) + if (isControlled()) + { + if (owner->GetPetGUID() != GetGUID()) { - if (owner->GetPetGUID() != GetGUID()) - { - LOG_ERROR("entities.pet", "Pet %u is not pet of owner %s, removed", GetEntry(), GetOwner()->GetName().c_str()); - Remove(IsHunterPet() ? PET_SAVE_AS_DELETED : PET_SAVE_DISMISS); - return; - } + LOG_ERROR("entities.pet", "Pet %u is not pet of owner %s, removed", GetEntry(), GetOwner()->GetName().c_str()); + Remove(IsHunterPet() ? PET_SAVE_AS_DELETED : PET_SAVE_DISMISS); + return; } + } - if (m_duration > 0) + if (m_duration > 0) + { + if (uint32(m_duration) > diff) + m_duration -= diff; + else { - if (uint32(m_duration) > diff) - m_duration -= diff; - else - { - Remove(getPetType() != SUMMON_PET ? PET_SAVE_AS_DELETED : PET_SAVE_DISMISS); - return; - } + Remove(getPetType() != SUMMON_PET ? PET_SAVE_AS_DELETED : PET_SAVE_DISMISS); + return; } - - break; } - default: - break; + + break; + } + default: + break; } Creature::Update(diff); } @@ -599,7 +594,7 @@ void Pet::GivePetXP(uint32 xp) // If pet is detected to be at, or above(?) the players level, don't hand out XP if (petlevel >= maxlevel) - return; + return; uint32 nextLvlXP = GetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP); uint32 curXP = GetUInt32Value(UNIT_FIELD_PETEXPERIENCE); @@ -628,7 +623,7 @@ void Pet::GivePetLevel(uint8 level) if (!IsHunterPet()) { SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, 0); - SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, uint32(sObjectMgr->GetXPForLevel(level)*PET_XP_FACTOR)); + SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, uint32(sObjectMgr->GetXPForLevel(level) * PET_XP_FACTOR)); } InitStatsForLevel(level); @@ -647,8 +642,8 @@ bool Pet::CreateBaseAtCreature(Creature* creature) if (!IsPositionValid()) { - LOG_ERROR("entities.pet", "Pet (guidlow %d, entry %d) not created base at creature. Suggested coordinates isn't valid (X: %f Y: %f)", - GetGUID().GetCounter(), GetEntry(), GetPositionX(), GetPositionY()); + LOG_ERROR("entities.pet", "Pet (guidlow %d, entry %d) not created base at creature. Suggested coordinates isn't valid (X: %f Y: %f)", GetGUID().GetCounter(), GetEntry(), GetPositionX(), + GetPositionY()); return false; } @@ -692,7 +687,7 @@ bool Pet::CreateBaseAtTamed(CreatureTemplate const* cinfo, Map* map) SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, 0); SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, 0); - SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, uint32(sObjectMgr->GetXPForLevel(getLevel()+1)*PET_XP_FACTOR)); + SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, uint32(sObjectMgr->GetXPForLevel(getLevel() + 1) * PET_XP_FACTOR)); SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE); if (cinfo->type == CREATURE_TYPE_BEAST) @@ -714,27 +709,26 @@ bool Guardian::InitStatsForLevel(uint8 petlevel) SetLevel(petlevel); - //Determine pet type + // Determine pet type PetType petType = MAX_PET_TYPE; if (IsPet() && GetOwner()->GetTypeId() == TYPEID_PLAYER) { switch (m_owner->getClass()) { - case CLASS_WARLOCK: - case CLASS_SHAMAN: - case CLASS_DEATH_KNIGHT: - case CLASS_MAGE: - case CLASS_PRIEST: - petType = SUMMON_PET; - break; - case CLASS_HUNTER: - petType = HUNTER_PET; - m_unitTypeMask |= UNIT_MASK_HUNTER_PET; - break; - default: - LOG_ERROR("entities.pet", "Unknown type pet %u is summoned by player class %u", - GetEntry(), GetOwner()->getClass()); - break; + case CLASS_WARLOCK: + case CLASS_SHAMAN: + case CLASS_DEATH_KNIGHT: + case CLASS_MAGE: + case CLASS_PRIEST: + petType = SUMMON_PET; + break; + case CLASS_HUNTER: + petType = HUNTER_PET; + m_unitTypeMask |= UNIT_MASK_HUNTER_PET; + break; + default: + LOG_ERROR("entities.pet", "Unknown type pet %u is summoned by player class %u", GetEntry(), GetOwner()->getClass()); + break; } } @@ -749,7 +743,7 @@ bool Guardian::InitStatsForLevel(uint8 petlevel) SetFloatValue(UNIT_MOD_CAST_SPEED, 1.0f); SetFloatValue(UNIT_MOD_CAST_HASTE, 1.0f); - //scale + // scale SetObjectScale(GetNativeObjectScale()); // Resistance @@ -760,7 +754,7 @@ bool Guardian::InitStatsForLevel(uint8 petlevel) // Health, mana, armor and resistance PetLevelInfo const* pInfo = sObjectMgr->GetPetLevelInfo(creature_ID, petlevel); - if (pInfo) // exist in DB + if (pInfo) // exist in DB { SetCreateHealth(pInfo->health); SetCreateMana(pInfo->mana); @@ -771,7 +765,7 @@ bool Guardian::InitStatsForLevel(uint8 petlevel) for (uint8 stat = 0; stat < MAX_STATS; ++stat) SetCreateStat(Stats(stat), float(pInfo->stats[stat])); } - else // not exist in DB, use some default fake data + else // not exist in DB, use some default fake data { // remove elite bonuses included in DB values // remove elite bonuses included in DB values @@ -808,198 +802,197 @@ bool Guardian::InitStatsForLevel(uint8 petlevel) SetBonusDamage(0); switch (petType) { - case SUMMON_PET: + case SUMMON_PET: + { + SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float(petlevel - (petlevel / 4))); + SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float(petlevel + (petlevel / 4))); + break; + } + case HUNTER_PET: + { + SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, uint32(sObjectMgr->GetXPForLevel(petlevel) * PET_XP_FACTOR)); + // these formula may not be correct; however, it is designed to be close to what it should be + // this makes dps 0.5 of pets level + SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float(petlevel - (petlevel / 4))); + // damage range is then petlevel / 2 + SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float(petlevel + (petlevel / 4))); + // damage is increased afterwards as strength and pet scaling modify attack power + break; + } + default: + { + switch (GetEntry()) { - SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float(petlevel - (petlevel / 4))); - SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float(petlevel + (petlevel / 4))); + case ENTRY_TREANT: + { + float bonusDmg = GetOwner()->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_NATURE) * 0.15f; + SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float(petlevel * 2.5f - (petlevel / 2) + bonusDmg)); + SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float(petlevel * 2.5f + (petlevel / 2) + bonusDmg)); + SetCreateHealth(m_owner->CountPctFromMaxHealth(10)); break; } - case HUNTER_PET: + case ENTRY_EARTH_ELEMENTAL: { - SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, uint32(sObjectMgr->GetXPForLevel(petlevel) * PET_XP_FACTOR)); - //these formula may not be correct; however, it is designed to be close to what it should be - //this makes dps 0.5 of pets level - SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float(petlevel - (petlevel / 4))); - //damage range is then petlevel / 2 - SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float(petlevel + (petlevel / 4))); - //damage is increased afterwards as strength and pet scaling modify attack power + if (Unit* owner = m_owner->GetOwner()) + SetCreateHealth(owner->CountPctFromMaxHealth(75)); + + SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float(petlevel * 4 - petlevel)); + SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float(petlevel * 4 + petlevel)); break; } - default: + case ENTRY_FIRE_ELEMENTAL: { - switch (GetEntry()) + if (Unit* owner = m_owner->GetOwner()) { - case ENTRY_TREANT: - { - float bonusDmg = GetOwner()->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_NATURE) * 0.15f; - SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float(petlevel * 2.5f - (petlevel / 2) + bonusDmg)); - SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float(petlevel * 2.5f + (petlevel / 2) + bonusDmg)); - SetCreateHealth(m_owner->CountPctFromMaxHealth(10)); - break; - } - case ENTRY_EARTH_ELEMENTAL: - { - if (Unit* owner = m_owner->GetOwner()) - SetCreateHealth(owner->CountPctFromMaxHealth(75)); + SetCreateHealth(owner->CountPctFromMaxHealth(75)); + SetBonusDamage(int32(owner->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_FIRE) * 0.5f)); + } - SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float(petlevel * 4 - petlevel)); - SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float(petlevel * 4 + petlevel)); - break; - } - case ENTRY_FIRE_ELEMENTAL: - { - if (Unit* owner = m_owner->GetOwner()) - { - SetCreateHealth(owner->CountPctFromMaxHealth(75)); - SetBonusDamage(int32(owner->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_FIRE) * 0.5f)); - } - - SetCreateMana(28 + 10 * petlevel); - SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float(petlevel * 4 - petlevel)); - SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float(petlevel * 4 + petlevel)); - break; - } - case ENTRY_SHADOWFIEND: - { - SetCreateMana(28 + 10 * petlevel); - SetCreateHealth(28 + 30 * petlevel); - int32 bonus_dmg = int32(GetOwner()->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_SHADOW)* 0.375f); - SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float((petlevel * 4 - petlevel) + bonus_dmg)); - SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float((petlevel * 4 + petlevel) + bonus_dmg)); + SetCreateMana(28 + 10 * petlevel); + SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float(petlevel * 4 - petlevel)); + SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float(petlevel * 4 + petlevel)); + break; + } + case ENTRY_SHADOWFIEND: + { + SetCreateMana(28 + 10 * petlevel); + SetCreateHealth(28 + 30 * petlevel); + int32 bonus_dmg = int32(GetOwner()->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_SHADOW) * 0.375f); + SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float((petlevel * 4 - petlevel) + bonus_dmg)); + SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float((petlevel * 4 + petlevel) + bonus_dmg)); - break; - } - case ENTRY_VENOMOUS_SNAKE: - { - SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float((petlevel / 2) - 25)); - SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float((petlevel / 2) - 18)); - break; - } - case ENTRY_VIPER: - { - SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float(petlevel / 2 - 10)); - SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float(petlevel / 2)); - break; - } - case ENTRY_SPIRIT_WOLF: - { - SetCreateHealth(30 * petlevel); - float dmg_multiplier = 0.50f; - if (m_owner->GetAuraEffect(63271, 0)) // Glyph of Feral Spirit - dmg_multiplier = 0.80f; + break; + } + case ENTRY_VENOMOUS_SNAKE: + { + SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float((petlevel / 2) - 25)); + SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float((petlevel / 2) - 18)); + break; + } + case ENTRY_VIPER: + { + SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float(petlevel / 2 - 10)); + SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float(petlevel / 2)); + break; + } + case ENTRY_SPIRIT_WOLF: + { + SetCreateHealth(30 * petlevel); + float dmg_multiplier = 0.50f; + if (m_owner->GetAuraEffect(63271, 0)) // Glyph of Feral Spirit + dmg_multiplier = 0.80f; - SetBonusDamage(int32(m_owner->GetTotalAttackPowerValue(BASE_ATTACK) * dmg_multiplier)); + SetBonusDamage(int32(m_owner->GetTotalAttackPowerValue(BASE_ATTACK) * dmg_multiplier)); - // wolf attack speed is 1.5s - SetAttackTime(BASE_ATTACK, cinfo->BaseAttackTime); + // wolf attack speed is 1.5s + SetAttackTime(BASE_ATTACK, cinfo->BaseAttackTime); - SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float((petlevel * 4 - petlevel))); - SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float((petlevel * 4 + petlevel))); + SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float((petlevel * 4 - petlevel))); + SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float((petlevel * 4 + petlevel))); - // 14AP == 1dps, wolf's strike speed == 1.5s so dmg = AP / 14 * 1.5 - SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, m_owner->GetTotalAttackPowerValue(BASE_ATTACK) * dmg_multiplier / 14); - SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, m_owner->GetTotalAttackPowerValue(BASE_ATTACK) * dmg_multiplier / 14); + // 14AP == 1dps, wolf's strike speed == 1.5s so dmg = AP / 14 * 1.5 + SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, m_owner->GetTotalAttackPowerValue(BASE_ATTACK) * dmg_multiplier / 14); + SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, m_owner->GetTotalAttackPowerValue(BASE_ATTACK) * dmg_multiplier / 14); - SetStatFlatModifier(UNIT_MOD_ARMOR, BASE_VALUE, float(GetOwner()->GetArmor()) * 0.35f); // Bonus Armor (35% of player armor) - SetStatFlatModifier(UNIT_MOD_STAT_STAMINA, BASE_VALUE, float(GetOwner()->GetStat(STAT_STAMINA)) * 0.3f); // Bonus Stamina (30% of player stamina) - if (!HasAura(58877)) // Spirit Hunt - AddAura(58877, this); - if (!HasAura(61783)) // Feral Pet Scaling - AddAura(61783, this); - break; - } - case ENTRY_GARGOYLE: - { - SetCreateHealth(m_owner->CountPctFromMaxHealth(70)); - if (Player* owner = m_owner->ToPlayer()) - { - float bonus = owner->GetRatingBonusValue(CR_HASTE_MELEE); - bonus += owner->GetTotalAuraModifier(SPELL_AURA_MOD_MELEE_HASTE_3) + - owner->GetTotalAuraModifier(SPELL_AURA_MOD_MELEE_RANGED_HASTE); - ApplyCastTimePercentMod(bonus, true); - } - - SetBonusDamage(int32(GetOwner()->GetTotalAttackPowerValue(BASE_ATTACK) * 0.5f)); - SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float(petlevel - (petlevel / 4))); - SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float(petlevel + (petlevel / 4))); - break; - } - case ENTRY_BLOODWORM: - { - SetCreateHealth(m_owner->CountPctFromMaxHealth(18)); - SetAttackTime(BASE_ATTACK, 1400); - SetBonusDamage(int32(m_owner->GetTotalAttackPowerValue(BASE_ATTACK) * 0.006f)); - float minDamage = m_owner->GetTotalAttackPowerValue(BASE_ATTACK) * 0.05f; - float maxDamage = m_owner->GetTotalAttackPowerValue(BASE_ATTACK) * 0.05f; - SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, minDamage); - SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, maxDamage); - if (!HasAura(50453)) // Blood Siphon - CastSpell(this, 50453, true); - break; - } - case ENTRY_INFERNAL: - { - if (m_owner->GetTypeId() == TYPEID_PLAYER) // Infernal get 100% of owners spell, Immolation has his own coef. - SetBonusDamage(int32(m_owner->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_SPELL))); - - float mod = 1; - if (petlevel < 60) - mod = 5 + (petlevel - 50) / 4; - if (petlevel < 70) - mod = 10 + (petlevel - 70) / 4; - else if (petlevel <= 80) - mod = 15 + (petlevel - 80) / 2; - else - mod = 20 + (petlevel - 85) / 2; - if (mod < 0) - mod = 0; - float minDamage = (petlevel - (petlevel / 4)) * mod; - float maxDamage = (petlevel + (petlevel / 4)) * mod; - float attackPower = ((minDamage + maxDamage) /4) * 7; - SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, minDamage); - SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, maxDamage); - SetStatFlatModifier(UNIT_MOD_ATTACK_POWER, BASE_VALUE, attackPower); - SetCreateHealth(m_owner->CountPctFromMaxHealth(40)); - break; - } - case ENTRY_EBON_IMP: - SetBonusDamage(m_owner->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_FIRE)); - break; - case ENTRY_ARMY_OF_THE_DEAD_GHOUL: - { - SetCreateHealth(m_owner->CountPctFromMaxHealth(30)); - SetBonusDamage(int32(GetOwner()->GetTotalAttackPowerValue(BASE_ATTACK) * 0.5f)); - float minDamage = m_owner->GetTotalAttackPowerValue(BASE_ATTACK) * 0.05f; - float maxDamage = m_owner->GetTotalAttackPowerValue(BASE_ATTACK) * 0.05f; - SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, minDamage); - SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, maxDamage); - if (!HasAura(62137)) // Avoidance - CastSpell(this, 62137, true); - break; - } - case ENTRY_GHOUL: - if (!HasAura(62137)) // Avoidance - CastSpell(this, 62137, true); - break; - default: - { - /* ToDo: Check what 5f5d2028 broke/fixed and how much of Creature::UpdateLevelDependantStats() - * should be copied here (or moved to another method or if that function should be called here - * or not just for this default case) - */ - CreatureBaseStats const* stats = sObjectMgr->GetCreatureBaseStats(petlevel, cinfo->unit_class); - float basedamage = stats->GenerateBaseDamage(cinfo); - - float weaponBaseMinDamage = basedamage; - float weaponBaseMaxDamage = basedamage * 1.5f; - - SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, weaponBaseMinDamage); - SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, weaponBaseMaxDamage); - break; - } + SetStatFlatModifier(UNIT_MOD_ARMOR, BASE_VALUE, float(GetOwner()->GetArmor()) * 0.35f); // Bonus Armor (35% of player armor) + SetStatFlatModifier(UNIT_MOD_STAT_STAMINA, BASE_VALUE, float(GetOwner()->GetStat(STAT_STAMINA)) * 0.3f); // Bonus Stamina (30% of player stamina) + if (!HasAura(58877)) // Spirit Hunt + AddAura(58877, this); + if (!HasAura(61783)) // Feral Pet Scaling + AddAura(61783, this); + break; + } + case ENTRY_GARGOYLE: + { + SetCreateHealth(m_owner->CountPctFromMaxHealth(70)); + if (Player* owner = m_owner->ToPlayer()) + { + float bonus = owner->GetRatingBonusValue(CR_HASTE_MELEE); + bonus += owner->GetTotalAuraModifier(SPELL_AURA_MOD_MELEE_HASTE_3) + owner->GetTotalAuraModifier(SPELL_AURA_MOD_MELEE_RANGED_HASTE); + ApplyCastTimePercentMod(bonus, true); } + + SetBonusDamage(int32(GetOwner()->GetTotalAttackPowerValue(BASE_ATTACK) * 0.5f)); + SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float(petlevel - (petlevel / 4))); + SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float(petlevel + (petlevel / 4))); + break; + } + case ENTRY_BLOODWORM: + { + SetCreateHealth(m_owner->CountPctFromMaxHealth(18)); + SetAttackTime(BASE_ATTACK, 1400); + SetBonusDamage(int32(m_owner->GetTotalAttackPowerValue(BASE_ATTACK) * 0.006f)); + float minDamage = m_owner->GetTotalAttackPowerValue(BASE_ATTACK) * 0.05f; + float maxDamage = m_owner->GetTotalAttackPowerValue(BASE_ATTACK) * 0.05f; + SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, minDamage); + SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, maxDamage); + if (!HasAura(50453)) // Blood Siphon + CastSpell(this, 50453, true); break; } + case ENTRY_INFERNAL: + { + if (m_owner->GetTypeId() == TYPEID_PLAYER) // Infernal get 100% of owners spell, Immolation has his own coef. + SetBonusDamage(int32(m_owner->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_SPELL))); + + float mod = 1; + if (petlevel < 60) + mod = 5 + (petlevel - 50) / 4; + if (petlevel < 70) + mod = 10 + (petlevel - 70) / 4; + else if (petlevel <= 80) + mod = 15 + (petlevel - 80) / 2; + else + mod = 20 + (petlevel - 85) / 2; + if (mod < 0) + mod = 0; + float minDamage = (petlevel - (petlevel / 4)) * mod; + float maxDamage = (petlevel + (petlevel / 4)) * mod; + float attackPower = ((minDamage + maxDamage) / 4) * 7; + SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, minDamage); + SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, maxDamage); + SetStatFlatModifier(UNIT_MOD_ATTACK_POWER, BASE_VALUE, attackPower); + SetCreateHealth(m_owner->CountPctFromMaxHealth(40)); + break; + } + case ENTRY_EBON_IMP: + SetBonusDamage(m_owner->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_FIRE)); + break; + case ENTRY_ARMY_OF_THE_DEAD_GHOUL: + { + SetCreateHealth(m_owner->CountPctFromMaxHealth(30)); + SetBonusDamage(int32(GetOwner()->GetTotalAttackPowerValue(BASE_ATTACK) * 0.5f)); + float minDamage = m_owner->GetTotalAttackPowerValue(BASE_ATTACK) * 0.05f; + float maxDamage = m_owner->GetTotalAttackPowerValue(BASE_ATTACK) * 0.05f; + SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, minDamage); + SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, maxDamage); + if (!HasAura(62137)) // Avoidance + CastSpell(this, 62137, true); + break; + } + case ENTRY_GHOUL: + if (!HasAura(62137)) // Avoidance + CastSpell(this, 62137, true); + break; + default: + { + /* ToDo: Check what 5f5d2028 broke/fixed and how much of Creature::UpdateLevelDependantStats() + * should be copied here (or moved to another method or if that function should be called here + * or not just for this default case) + */ + CreatureBaseStats const* stats = sObjectMgr->GetCreatureBaseStats(petlevel, cinfo->unit_class); + float basedamage = stats->GenerateBaseDamage(cinfo); + + float weaponBaseMinDamage = basedamage; + float weaponBaseMaxDamage = basedamage * 1.5f; + + SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, weaponBaseMinDamage); + SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, weaponBaseMaxDamage); + break; + } + } + break; + } } UpdateAllStats(); @@ -1023,14 +1016,14 @@ bool Pet::HaveInDiet(ItemTemplate const* item) const return false; uint32 diet = cFamily->PetFoodMask; - uint32 FoodMask = 1 << (item->FoodType-1); + uint32 FoodMask = 1 << (item->FoodType - 1); return (diet & FoodMask) != 0; } uint32 Pet::GetCurrentFoodBenefitLevel(uint32 itemlevel) const { // -10 or greater food level - if (getLevel() <= itemlevel + 10) // possible to feed level 85 pet with ilevel 75 level food for full effect + if (getLevel() <= itemlevel + 10) // possible to feed level 85 pet with ilevel 75 level food for full effect return 50; // -10 to -20 else if (getLevel() <= itemlevel + 20) @@ -1040,7 +1033,7 @@ uint32 Pet::GetCurrentFoodBenefitLevel(uint32 itemlevel) const return 13; // -30 or more difference else - return 0; //food too low level + return 0; // food too low level } void Pet::_LoadSpellCooldowns() @@ -1065,8 +1058,7 @@ void Pet::_LoadSpells() Field* fields = result->Fetch(); addSpell(fields[0].GetUInt32(), ActiveStates(fields[1].GetUInt8()), PETSPELL_UNCHANGED); - } - while (result->NextRow()); + } while (result->NextRow()); } } @@ -1084,36 +1076,36 @@ void Pet::_SaveSpells(CharacterDatabaseTransaction& trans) switch (itr->second.state) { - case PETSPELL_REMOVED: - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PET_SPELL_BY_SPELL); - stmt->setUInt32(0, m_charmInfo->GetPetNumber()); - stmt->setUInt32(1, itr->first); - trans->Append(stmt); + case PETSPELL_REMOVED: + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PET_SPELL_BY_SPELL); + stmt->setUInt32(0, m_charmInfo->GetPetNumber()); + stmt->setUInt32(1, itr->first); + trans->Append(stmt); - m_spells.erase(itr); - continue; - case PETSPELL_CHANGED: - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PET_SPELL_BY_SPELL); - stmt->setUInt32(0, m_charmInfo->GetPetNumber()); - stmt->setUInt32(1, itr->first); - trans->Append(stmt); - - stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_PET_SPELL); - stmt->setUInt32(0, m_charmInfo->GetPetNumber()); - stmt->setUInt32(1, itr->first); - stmt->setUInt8(2, itr->second.active); - trans->Append(stmt); - - break; - case PETSPELL_NEW: - stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_PET_SPELL); - stmt->setUInt32(0, m_charmInfo->GetPetNumber()); - stmt->setUInt32(1, itr->first); - stmt->setUInt8(2, itr->second.active); - trans->Append(stmt); - break; - case PETSPELL_UNCHANGED: - continue; + m_spells.erase(itr); + continue; + case PETSPELL_CHANGED: + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PET_SPELL_BY_SPELL); + stmt->setUInt32(0, m_charmInfo->GetPetNumber()); + stmt->setUInt32(1, itr->first); + trans->Append(stmt); + + stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_PET_SPELL); + stmt->setUInt32(0, m_charmInfo->GetPetNumber()); + stmt->setUInt32(1, itr->first); + stmt->setUInt8(2, itr->second.active); + trans->Append(stmt); + + break; + case PETSPELL_NEW: + stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_PET_SPELL); + stmt->setUInt32(0, m_charmInfo->GetPetNumber()); + stmt->setUInt32(1, itr->first); + stmt->setUInt8(2, itr->second.active); + trans->Append(stmt); + break; + case PETSPELL_UNCHANGED: + continue; } itr->second.state = PETSPELL_UNCHANGED; } @@ -1151,6 +1143,8 @@ void Pet::_LoadAuras(uint32 timediff) int32 maxduration = fields[11].GetInt32(); int32 remaintime = fields[12].GetInt32(); uint8 remaincharges = fields[13].GetUInt8(); + float critChance = fields[14].GetFloat(); + bool applyResilience = fields[15].GetBool(); SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellid); if (!spellInfo) @@ -1162,10 +1156,10 @@ void Pet::_LoadAuras(uint32 timediff) // negative effects should continue counting down after logout if (remaintime != -1 && (!spellInfo->IsPositive() || spellInfo->HasAttribute(SPELL_ATTR4_FADES_WHILE_LOGGED_OUT))) { - if (remaintime/IN_MILLISECONDS <= int32(timediff)) + if (remaintime / IN_MILLISECONDS <= int32(timediff)) continue; - remaintime -= timediff*IN_MILLISECONDS; + remaintime -= timediff * IN_MILLISECONDS; } // prevent wrong values of remaincharges @@ -1184,12 +1178,11 @@ void Pet::_LoadAuras(uint32 timediff) aura->Remove(); continue; } - aura->SetLoadedState(maxduration, remaintime, remaincharges, stackcount, recalculatemask, &damage[0]); + aura->SetLoadedState(maxduration, remaintime, remaincharges, stackcount, recalculatemask, critChance, applyResilience, &damage[0]); aura->ApplyForTargets(); LOG_DEBUG("entities.pet", "Added aura spellid %u, effectmask %u", spellInfo->Id, effmask); } - } - while (result->NextRow()); + } while (result->NextRow()); } } @@ -1217,9 +1210,9 @@ void Pet::_SaveAuras(CharacterDatabaseTransaction& trans) { baseDamage[i] = aura->GetEffect(i)->GetBaseAmount(); damage[i] = aura->GetEffect(i)->GetAmount(); - effMask |= (1<GetEffect(i)->CanBeRecalculated()) - recalculateMask |= (1<setInt32(index++, itr->second->GetMaxDuration()); stmt->setInt32(index++, itr->second->GetDuration()); stmt->setUInt8(index++, itr->second->GetCharges()); + stmt->setFloat(index++, itr->second->GetCritChance()); + stmt->setBool(index++, itr->second->CanApplyResilience()); trans->Append(stmt); } @@ -1260,7 +1255,7 @@ bool Pet::addSpell(uint32 spellId, ActiveStates active /*= ACT_DECIDE*/, PetSpel if (!spellInfo) { // do pet spell book cleanup - if (state == PETSPELL_UNCHANGED) // spell load case + if (state == PETSPELL_UNCHANGED) // spell load case { LOG_ERROR("entities.pet", "Pet::addSpell: Non-existed in SpellStore spell #%u request, deleting for all pets in `pet_spell`.", spellId); @@ -1302,7 +1297,7 @@ bool Pet::addSpell(uint32 spellId, ActiveStates active /*= ACT_DECIDE*/, PetSpel newspell.state = state; newspell.type = type; - if (active == ACT_DECIDE) // active was not used before, so we save it's autocast/passive state here + if (active == ACT_DECIDE) // active was not used before, so we save it's autocast/passive state here { if (spellInfo->IsAutocastable()) newspell.active = ACT_ENABLED; @@ -1374,7 +1369,7 @@ bool Pet::addSpell(uint32 spellId, ActiveStates active /*= ACT_DECIDE*/, PetSpel // Do not go further if this Attribute exists if (spellInfo->HasAttribute(SPELL_ATTR4_HIDDEN_IN_SPELLBOOK) && !IsWarlockMinion()) - return true; + return true; if (spellInfo->IsPassive() && (!spellInfo->CasterAuraState || HasAuraState(AuraStateType(spellInfo->CasterAuraState)))) CastSpell(this, spellId, true); @@ -1390,7 +1385,7 @@ bool Pet::addSpell(uint32 spellId, ActiveStates active /*= ACT_DECIDE*/, PetSpel int32 free_points = GetMaxTalentPointsForLevel(getLevel()); m_usedTalentCount += talentCost; // update free talent points - free_points-=m_usedTalentCount; + free_points -= m_usedTalentCount; SetFreeTalentPoints(free_points > 0 ? free_points : 0); } return true; @@ -1423,10 +1418,10 @@ void Pet::InitLevelupSpellsForLevel() { // will called first if level down if (itr->first > level) - unlearnSpell(itr->second, true); // will learn prev rank if any + unlearnSpell(itr->second, true); // will learn prev rank if any // will called if level up else - learnSpell(itr->second); // will unlearn prev rank if any + learnSpell(itr->second); // will unlearn prev rank if any } } @@ -1496,7 +1491,7 @@ bool Pet::removeSpell(uint32 spell_id, bool learn_prev, bool clear_ab) if (learn_prev) { - if (uint32 prev_id = sSpellMgr->GetPrevSpellInChain (spell_id)) + if (uint32 prev_id = sSpellMgr->GetPrevSpellInChain(spell_id)) learnSpell(prev_id); else learn_prev = false; @@ -1730,7 +1725,7 @@ void Pet::ToggleAutocast(SpellInfo const* spellInfo, bool apply) if (apply) { for (i = 0; i < m_autospells.size() && m_autospells[i] != spellid; ++i) - ; // just search + ; // just search if (i == m_autospells.size()) { @@ -1748,7 +1743,7 @@ void Pet::ToggleAutocast(SpellInfo const* spellInfo, bool apply) { AutoSpellList::iterator itr2 = m_autospells.begin(); for (i = 0; i < m_autospells.size() && m_autospells[i] != spellid; ++i, ++itr2) - ; // just search + ; // just search if (i < m_autospells.size()) { @@ -1767,22 +1762,22 @@ bool Pet::IsPermanentPetFor(Player* owner) const { switch (getPetType()) { - case SUMMON_PET: - switch (owner->getClass()) - { - case CLASS_WARLOCK: - return GetCreatureTemplate()->type == CREATURE_TYPE_DEMON; - case CLASS_DEATH_KNIGHT: - return GetCreatureTemplate()->type == CREATURE_TYPE_UNDEAD; - case CLASS_MAGE: - return GetCreatureTemplate()->type == CREATURE_TYPE_ELEMENTAL; - default: - return false; - } - case HUNTER_PET: - return true; + case SUMMON_PET: + switch (owner->getClass()) + { + case CLASS_WARLOCK: + return GetCreatureTemplate()->type == CREATURE_TYPE_DEMON; + case CLASS_DEATH_KNIGHT: + return GetCreatureTemplate()->type == CREATURE_TYPE_UNDEAD; + case CLASS_MAGE: + return GetCreatureTemplate()->type == CREATURE_TYPE_ELEMENTAL; default: return false; + } + case HUNTER_PET: + return true; + default: + return false; } } @@ -1870,7 +1865,7 @@ void Pet::CastPetAura(PetAura const* aura) CastSpellExtraArgs args; args.TriggerFlags = TRIGGERED_FULL_MASK; - if (auraId == 35696) // Demonic Knowledge + if (auraId == 35696) // Demonic Knowledge args.SpellValueOverrides.AddMod(SPELLVALUE_BASE_POINT0, CalculatePct(aura->GetDamage(), GetStat(STAT_STAMINA) + GetStat(STAT_INTELLECT))); CastSpell(this, auraId, args); @@ -1903,13 +1898,13 @@ void Pet::SynchronizeLevelWithOwner() switch (getPetType()) { - // always same level - case SUMMON_PET: - case HUNTER_PET: - GivePetLevel(owner->getLevel()); - break; - default: - break; + // always same level + case SUMMON_PET: + case HUNTER_PET: + GivePetLevel(owner->getLevel()); + break; + default: + break; } } @@ -1970,8 +1965,7 @@ std::string Pet::GenerateActionBarData() const for (uint32 i = ACTION_BAR_INDEX_START; i < ACTION_BAR_INDEX_END; ++i) { - ss << uint32(m_charmInfo->GetActionBarEntry(i)->GetType()) << ' ' - << uint32(m_charmInfo->GetActionBarEntry(i)->GetAction()) << ' '; + ss << uint32(m_charmInfo->GetActionBarEntry(i)->GetType()) << ' ' << uint32(m_charmInfo->GetActionBarEntry(i)->GetAction()) << ' '; } return ss.str(); diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index c3b7a503..c8c04ae4 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -483,8 +483,7 @@ bool Player::Create(ObjectGuid::LowType guidlow, CharacterCreateInfo* createInfo return false; } - if (!ValidateAppearance(createInfo->Race, createInfo->Class, createInfo->Gender, createInfo->HairStyle, createInfo->HairColor, - createInfo->Face, createInfo->FacialHair, createInfo->Skin, true)) + if (!ValidateAppearance(createInfo->Race, createInfo->Class, createInfo->Gender, createInfo->HairStyle, createInfo->HairColor, createInfo->Face, createInfo->FacialHair, createInfo->Skin, true)) { LOG_INFO("entities.player.cheat", "Player::Create: Possible hacking attempt: Account %u tried to create a character named '%s' with invalid appearance " @@ -514,9 +513,7 @@ bool Player::Create(ObjectGuid::LowType guidlow, CharacterCreateInfo* createInfo SetByteValue(PLAYER_BYTES, PLAYER_BYTES_OFFSET_HAIR_STYLE_ID, createInfo->HairStyle); SetByteValue(PLAYER_BYTES, PLAYER_BYTES_OFFSET_HAIR_COLOR_ID, createInfo->HairColor); SetByteValue(PLAYER_BYTES_2, PLAYER_BYTES_2_OFFSET_FACIAL_STYLE, createInfo->FacialHair); - SetByteValue(PLAYER_BYTES_2, PLAYER_BYTES_2_OFFSET_REST_STATE, - (GetSession()->IsARecruiter() || GetSession()->GetRecruiterId() != 0) ? REST_STATE_RAF_LINKED - : REST_STATE_NOT_RAF_LINKED); + SetByteValue(PLAYER_BYTES_2, PLAYER_BYTES_2_OFFSET_REST_STATE, (GetSession()->IsARecruiter() || GetSession()->GetRecruiterId() != 0) ? REST_STATE_RAF_LINKED : REST_STATE_NOT_RAF_LINKED); SetByteValue(PLAYER_BYTES_3, PLAYER_BYTES_3_OFFSET_GENDER, createInfo->Gender); SetByteValue(PLAYER_BYTES_3, PLAYER_BYTES_3_OFFSET_ARENA_FACTION, 0); @@ -533,8 +530,7 @@ bool Player::Create(ObjectGuid::LowType guidlow, CharacterCreateInfo* createInfo SetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KILLS, 0); // set starting level - uint32 start_level = getClass() != CLASS_DEATH_KNIGHT ? sWorld->getIntConfig(CONFIG_START_PLAYER_LEVEL) - : sWorld->getIntConfig(CONFIG_START_DEATH_KNIGHT_PLAYER_LEVEL); + uint32 start_level = getClass() != CLASS_DEATH_KNIGHT ? sWorld->getIntConfig(CONFIG_START_PLAYER_LEVEL) : sWorld->getIntConfig(CONFIG_START_DEATH_KNIGHT_PLAYER_LEVEL); if (m_session->HasPermission(rbac::RBAC_PERM_USE_START_GM_LEVEL)) { @@ -575,13 +571,11 @@ bool Player::Create(ObjectGuid::LowType guidlow, CharacterCreateInfo* createInfo LearnCustomSpells(); // original action bar - for (PlayerCreateInfoActions::const_iterator action_itr = info->action.begin(); action_itr != info->action.end(); - ++action_itr) + for (PlayerCreateInfoActions::const_iterator action_itr = info->action.begin(); action_itr != info->action.end(); ++action_itr) addActionButton(action_itr->button, action_itr->action, action_itr->type); // original items - if (CharStartOutfitEntry const* oEntry = - sDBCManager.GetCharStartOutfitEntry(createInfo->Race, createInfo->Class, createInfo->Gender)) + if (CharStartOutfitEntry const* oEntry = sDBCManager.GetCharStartOutfitEntry(createInfo->Race, createInfo->Class, createInfo->Gender)) { for (int j = 0; j < MAX_OUTFIT_ITEMS; ++j) { @@ -660,9 +654,8 @@ bool Player::Create(ObjectGuid::LowType guidlow, CharacterCreateInfo* createInfo bool Player::StoreNewItemInBestSlots(uint32 titem_id, uint32 titem_amount) { - LOG_DEBUG("entities.player.items", - "Player::StoreNewItemInBestSlots: Player '%s' (%s) creates initial item (ItemID: %u, Count: %u)", GetName().c_str(), - GetGUID().ToString().c_str(), titem_id, titem_amount); + LOG_DEBUG("entities.player.items", "Player::StoreNewItemInBestSlots: Player '%s' (%s) creates initial item (ItemID: %u, Count: %u)", GetName().c_str(), GetGUID().ToString().c_str(), titem_id, + titem_amount); // attempt equip by one while (titem_amount > 0) @@ -735,9 +728,8 @@ uint32 Player::EnvironmentalDamage(EnviromentalDamage type, uint32 damage) case DAMAGE_LAVA: case DAMAGE_SLIME: { - DamageInfo dmgInfo(this, this, damage, nullptr, type == DAMAGE_LAVA ? SPELL_SCHOOL_MASK_FIRE : SPELL_SCHOOL_MASK_NATURE, - DIRECT_DAMAGE, BASE_ATTACK); - CalcAbsorbResist(dmgInfo); + DamageInfo dmgInfo(this, this, damage, nullptr, type == DAMAGE_LAVA ? SPELL_SCHOOL_MASK_FIRE : SPELL_SCHOOL_MASK_NATURE, DIRECT_DAMAGE, BASE_ATTACK); + Unit::CalcAbsorbResist(dmgInfo); absorb = dmgInfo.GetAbsorb(); resist = dmgInfo.GetResist(); damage = dmgInfo.GetDamage(); @@ -747,7 +739,7 @@ uint32 Player::EnvironmentalDamage(EnviromentalDamage type, uint32 damage) break; } - DealDamageMods(this, damage, &absorb); + Unit::DealDamageMods(this, damage, &absorb); WorldPackets::CombatLog::EnvironmentalDamageLog environmentalDamageLog; environmentalDamageLog.Victim = GetGUID(); @@ -757,14 +749,13 @@ uint32 Player::EnvironmentalDamage(EnviromentalDamage type, uint32 damage) environmentalDamageLog.Resisted = resist; SendMessageToSet(environmentalDamageLog.Write(), true); - uint32 final_damage = DealDamage(this, damage, nullptr, SELF_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, nullptr, false); + uint32 final_damage = Unit::DealDamage(this, this, damage, nullptr, SELF_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, nullptr, false); if (!IsAlive()) { if (type == DAMAGE_FALL) // DealDamage does not apply item durability loss from self-induced damage. { - LOG_DEBUG("entities.player", "Player::EnvironmentalDamage: Player '%s' (%s) fall to death, losing 10%% durability", - GetName().c_str(), GetGUID().ToString().c_str()); + LOG_DEBUG("entities.player", "Player::EnvironmentalDamage: Player '%s' (%s) fall to death, losing 10%% durability", GetName().c_str(), GetGUID().ToString().c_str()); DurabilityLossAll(0.10f, false); // durability lost message SendDurabilityLoss(this, 10); @@ -784,8 +775,7 @@ int32 Player::getMaxTimer(MirrorTimerType timer) const return MINUTE * IN_MILLISECONDS; case BREATH_TIMER: { - if (!IsAlive() || HasAuraType(SPELL_AURA_WATER_BREATHING) || - GetSession()->GetSecurity() >= AccountTypes(sWorld->getIntConfig(CONFIG_DISABLE_BREATHING))) + if (!IsAlive() || HasAuraType(SPELL_AURA_WATER_BREATHING) || GetSession()->GetSecurity() >= AccountTypes(sWorld->getIntConfig(CONFIG_DISABLE_BREATHING))) return DISABLED_MIRROR_TIMER; int32 UnderWaterTime = 3 * MINUTE * IN_MILLISECONDS; AuraEffectList const& mModWaterBreathing = GetAuraEffectsByType(SPELL_AURA_MOD_WATER_BREATHING); @@ -818,7 +808,10 @@ void Player::StopMirrorTimers() StopMirrorTimer(FIRE_TIMER); } -bool Player::IsMirrorTimerActive(MirrorTimerType type) const { return m_MirrorTimer[type] == getMaxTimer(type); } +bool Player::IsMirrorTimerActive(MirrorTimerType type) const +{ + return m_MirrorTimer[type] == getMaxTimer(type); +} void Player::HandleDrowning(uint32 time_diff) { @@ -1010,8 +1003,7 @@ void Player::Update(uint32 p_time) // Update cinematic location, if 500ms have passed and we're doing a cinematic now. _cinematicMgr->m_cinematicDiff += p_time; - if (_cinematicMgr->m_activeCinematicCameraId != 0 && - GetMSTimeDiffToNow(_cinematicMgr->m_lastCinematicCheck) > CINEMATIC_UPDATEDIFF) + if (_cinematicMgr->m_activeCinematicCameraId != 0 && GetMSTimeDiffToNow(_cinematicMgr->m_lastCinematicCheck) > CINEMATIC_UPDATEDIFF) { _cinematicMgr->m_lastCinematicCheck = GameTime::GetGameTimeMS(); _cinematicMgr->UpdateCinematicLocation(p_time); @@ -1229,8 +1221,7 @@ void Player::Update(uint32 p_time) { // m_nextSave reset in SaveToDB call SaveToDB(); - LOG_DEBUG( - "entities.player", "Player::Update: Player '%s' (%s) saved", GetName().c_str(), GetGUID().ToString().c_str()); + LOG_DEBUG("entities.player", "Player::Update: Player '%s' (%s) saved", GetName().c_str(), GetGUID().ToString().c_str()); ; } else @@ -1372,8 +1363,7 @@ void Player::setDeathState(DeathState s) { if (!cur) { - LOG_ERROR("entities.player", "Player::setDeathState: Attempt to kill a dead player '%s' (%s)", GetName().c_str(), - GetGUID().ToString().c_str()); + LOG_ERROR("entities.player", "Player::setDeathState: Attempt to kill a dead player '%s' (%s)", GetName().c_str(), GetGUID().ToString().c_str()); return; } @@ -1422,7 +1412,10 @@ void Player::ToggleAFK() LeaveBattleground(); } -void Player::ToggleDND() { ToggleFlag(PLAYER_FLAGS, PLAYER_FLAGS_DND); } +void Player::ToggleDND() +{ + ToggleFlag(PLAYER_FLAGS, PLAYER_FLAGS_DND); +} uint8 Player::GetChatTag() const { @@ -1447,16 +1440,13 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati LOG_ERROR("maps", "Player::TeleportTo: Invalid map (%d) or invalid coordinates (X: %f, Y: %f, Z: %f, O: %f) given when teleporting " "player '%s' (%s, MapID: %d, X: %f, Y: %f, Z: %f, O: %f).", - mapid, x, y, z, orientation, GetGUID().ToString().c_str(), GetName().c_str(), GetMapId(), GetPositionX(), - GetPositionY(), GetPositionZ(), GetOrientation()); + mapid, x, y, z, orientation, GetGUID().ToString().c_str(), GetName().c_str(), GetMapId(), GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation()); return false; } - if (!GetSession()->HasPermission(rbac::RBAC_PERM_SKIP_CHECK_DISABLE_MAP) && - DisableMgr::IsDisabledFor(DISABLE_TYPE_MAP, mapid, this)) + if (!GetSession()->HasPermission(rbac::RBAC_PERM_SKIP_CHECK_DISABLE_MAP) && DisableMgr::IsDisabledFor(DISABLE_TYPE_MAP, mapid, this)) { - LOG_INFO("entities.player.cheat", "Player::TeleportTo: Player '%s' (%s) tried to enter a forbidden map (MapID: %u)", - GetGUID().ToString().c_str(), GetName().c_str(), mapid); + LOG_INFO("entities.player.cheat", "Player::TeleportTo: Player '%s' (%s) tried to enter a forbidden map (MapID: %u)", GetGUID().ToString().c_str(), GetName().c_str(), mapid); SendTransferAborted(mapid, TRANSFER_ABORT_MAP_NOT_ALLOWED); return false; } @@ -1474,9 +1464,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati // client without expansion support if (GetSession()->GetExpansion() < mEntry->Expansion()) { - LOG_DEBUG("maps", - "Player '%s' (%s) using client without required expansion tried teleport to non accessible map (MapID: %u)", - GetName().c_str(), GetGUID().ToString().c_str(), mapid); + LOG_DEBUG("maps", "Player '%s' (%s) using client without required expansion tried teleport to non accessible map (MapID: %u)", GetName().c_str(), GetGUID().ToString().c_str(), mapid); if (TransportBase* transport = GetTransport()) { @@ -1489,8 +1477,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati return false; // normal client can't teleport to this map... } else - LOG_DEBUG("maps", "Player %s (%s) is being teleported to map (MapID: %u)", GetName().c_str(), - GetGUID().ToString().c_str(), mapid); + LOG_DEBUG("maps", "Player %s (%s) is being teleported to map (MapID: %u)", GetName().c_str(), GetGUID().ToString().c_str(), mapid); if (m_vehicle) ExitVehicle(); @@ -1815,9 +1802,8 @@ void Player::RemoveFromWorld() { if (WorldObject* viewpoint = GetViewpoint()) { - LOG_ERROR("entities.player", - "Player::RemoveFromWorld: Player '%s' (%s) has viewpoint (Entry:%u, Type: %u) when removed from world", - GetName().c_str(), GetGUID().ToString().c_str(), viewpoint->GetEntry(), viewpoint->GetTypeId()); + LOG_ERROR("entities.player", "Player::RemoveFromWorld: Player '%s' (%s) has viewpoint (Entry:%u, Type: %u) when removed from world", GetName().c_str(), GetGUID().ToString().c_str(), + viewpoint->GetEntry(), viewpoint->GetTypeId()); SetViewpoint(viewpoint, false); } } @@ -1894,14 +1880,12 @@ void Player::RegenerateAll(uint32 diff) for (auto itr = auraList.begin(); itr != auraList.end(); ++itr) { // Food emote comes above drinking emote if we have to decide (mage regen food for example) - if ((*itr)->GetBase()->HasEffectType(SPELL_AURA_MOD_REGEN) && - (*itr)->GetSpellInfo()->HasAuraInterruptFlag(SpellAuraInterruptFlags::Standing)) + if ((*itr)->GetBase()->HasEffectType(SPELL_AURA_MOD_REGEN) && (*itr)->GetSpellInfo()->HasAuraInterruptFlag(SpellAuraInterruptFlags::Standing)) { SendPlaySpellVisualKit(SPELL_VISUAL_KIT_FOOD, 0, 0); break; } - else if ((*itr)->GetBase()->HasEffectType(SPELL_AURA_MOD_POWER_REGEN) && - (*itr)->GetSpellInfo()->HasAuraInterruptFlag(SpellAuraInterruptFlags::Standing)) + else if ((*itr)->GetBase()->HasEffectType(SPELL_AURA_MOD_POWER_REGEN) && (*itr)->GetSpellInfo()->HasAuraInterruptFlag(SpellAuraInterruptFlags::Standing)) { SendPlaySpellVisualKit(SPELL_VISUAL_KIT_DRINK, 0, 0); break; @@ -1914,8 +1898,7 @@ void Player::RegenerateAll(uint32 diff) void Player::RegenerateHealth() { // Do not regenerate health when in combat, when not polymorphed or when any regeneration aura allows it - if (IsInCombat() && !IsPolymorphed() && !m_baseHealthRegen && !HasAuraType(SPELL_AURA_MOD_REGEN_DURING_COMBAT) && - !HasAuraType(SPELL_AURA_MOD_HEALTH_REGEN_IN_COMBAT)) + if (IsInCombat() && !IsPolymorphed() && !m_baseHealthRegen && !HasAuraType(SPELL_AURA_MOD_REGEN_DURING_COMBAT) && !HasAuraType(SPELL_AURA_MOD_HEALTH_REGEN_IN_COMBAT)) return; uint32 curValue = GetHealth(); @@ -2160,7 +2143,10 @@ void Player::SetGameMaster(bool on) UpdateObjectVisibility(); } -bool Player::CanBeGameMaster() const { return GetSession()->HasPermission(rbac::RBAC_PERM_COMMAND_GM); } +bool Player::CanBeGameMaster() const +{ + return GetSession()->HasPermission(rbac::RBAC_PERM_COMMAND_GM); +} void Player::SetGMVisible(bool on) { @@ -2232,8 +2218,7 @@ void Player::UninviteFromGroup() } } -void Player::RemoveFromGroup(Group* group, ObjectGuid guid, RemoveMethod method /*= GROUP_REMOVEMETHOD_DEFAULT*/, - ObjectGuid kicker /*= ObjectGuid::Empty*/, char const* reason /*= nullptr*/) +void Player::RemoveFromGroup(Group* group, ObjectGuid guid, RemoveMethod method /*= GROUP_REMOVEMETHOD_DEFAULT*/, ObjectGuid kicker /*= ObjectGuid::Empty*/, char const* reason /*= nullptr*/) { if (!group) return; @@ -2395,7 +2380,10 @@ void Player::GiveLevel(uint8 level) sScriptMgr->OnPlayerLevelChanged(this, oldLevel); } -bool Player::IsMaxLevel() const { return getLevel() >= GetUInt32Value(PLAYER_FIELD_MAX_LEVEL); } +bool Player::IsMaxLevel() const +{ + return getLevel() >= GetUInt32Value(PLAYER_FIELD_MAX_LEVEL); +} void Player::InitTalentForLevel() { @@ -2579,18 +2567,16 @@ void Player::InitStatsForLevel(bool reapplyMods) SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, 0); // cleanup unit flags (will be re-applied if need at aura load). - RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_REMOVE_CLIENT_CONTROL | UNIT_FLAG_NOT_ATTACKABLE_1 | - UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC | UNIT_FLAG_LOOTING | - UNIT_FLAG_PET_IN_COMBAT | UNIT_FLAG_SILENCED | UNIT_FLAG_PACIFIED | UNIT_FLAG_STUNNED | - UNIT_FLAG_IN_COMBAT | UNIT_FLAG_DISARMED | UNIT_FLAG_CONFUSED | UNIT_FLAG_FLEEING | - UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_SKINNABLE | UNIT_FLAG_MOUNT | UNIT_FLAG_TAXI_FLIGHT); + RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_REMOVE_CLIENT_CONTROL | UNIT_FLAG_NOT_ATTACKABLE_1 | UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC | UNIT_FLAG_LOOTING | + UNIT_FLAG_PET_IN_COMBAT | UNIT_FLAG_SILENCED | UNIT_FLAG_PACIFIED | UNIT_FLAG_STUNNED | UNIT_FLAG_IN_COMBAT | UNIT_FLAG_DISARMED | UNIT_FLAG_CONFUSED | + UNIT_FLAG_FLEEING | UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_SKINNABLE | UNIT_FLAG_MOUNT | UNIT_FLAG_TAXI_FLIGHT); SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED); // must be set SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_REGENERATE_POWER); // must be set // cleanup player flags (will be re-applied if need at aura load), to avoid have ghost flag without ghost aura, for example. - RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_AFK | PLAYER_FLAGS_DND | PLAYER_FLAGS_GM | PLAYER_FLAGS_GHOST | - PLAYER_FLAGS_DISABLE_CASTING_EXCEPT_ABILITIES | PLAYER_FLAGS_DISABLE_ATTACKING_EXCEPT_ABILITIES); + RemoveFlag( + PLAYER_FLAGS, PLAYER_FLAGS_AFK | PLAYER_FLAGS_DND | PLAYER_FLAGS_GM | PLAYER_FLAGS_GHOST | PLAYER_FLAGS_DISABLE_CASTING_EXCEPT_ABILITIES | PLAYER_FLAGS_DISABLE_ATTACKING_EXCEPT_ABILITIES); RemoveStandFlags(UNIT_STAND_FLAGS_ALL); // one form stealth modified bytes RemoveByteFlag(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG, UNIT_BYTE2_FLAG_FFA_PVP | UNIT_BYTE2_FLAG_SANCTUARY); @@ -2650,11 +2636,9 @@ void Player::RemoveMail(uint32 id) } } -void Player::SendMailResult(uint32 mailId, MailResponseType mailAction, MailResponseResult mailError, uint32 equipError, - ObjectGuid::LowType item_guid, uint32 item_count) const +void Player::SendMailResult(uint32 mailId, MailResponseType mailAction, MailResponseResult mailError, uint32 equipError, ObjectGuid::LowType item_guid, uint32 item_count) const { - WorldPacket data(SMSG_SEND_MAIL_RESULT, - (4 + 4 + 4 + (mailError == MAIL_ERR_EQUIP_ERROR ? 4 : (mailAction == MAIL_ITEM_TAKEN ? 4 + 4 : 0)))); + WorldPacket data(SMSG_SEND_MAIL_RESULT, (4 + 4 + 4 + (mailError == MAIL_ERR_EQUIP_ERROR ? 4 : (mailAction == MAIL_ITEM_TAKEN ? 4 + 4 : 0)))); data << uint32(mailId); data << uint32(mailAction); data << uint32(mailError); @@ -2792,8 +2776,7 @@ bool Player::AddTalent(uint32 spellId, uint8 spec, bool learning) return false; } -bool Player::AddSpell( - uint32 spellId, bool active, bool learning, bool dependent, bool disabled, bool loading /*= false*/, uint32 fromSkill /*= 0*/) +bool Player::AddSpell(uint32 spellId, bool active, bool learning, bool dependent, bool disabled, bool loading /*= false*/, uint32 fromSkill /*= 0*/) { SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId); if (!spellInfo) @@ -2861,8 +2844,7 @@ bool Player::AddSpell( } // not do anything if already known in expected state - if (itr->second.state != PLAYERSPELL_REMOVED && itr->second.active == active && itr->second.dependent == dependent && - itr->second.disabled == disabled) + if (itr->second.state != PLAYERSPELL_REMOVED && itr->second.active == active && itr->second.dependent == dependent && itr->second.disabled == disabled) { if (!IsInWorld() && !learning) // explicitly load from DB and then exist in it already and set correctly itr->second.state = PLAYERSPELL_UNCHANGED; @@ -2884,8 +2866,7 @@ bool Player::AddSpell( { itr->second.active = active; - if (!IsInWorld() && !learning && - !dependent_set) // explicitly load from DB and then exist in it already and set correctly + if (!IsInWorld() && !learning && !dependent_set) // explicitly load from DB and then exist in it already and set correctly itr->second.state = PLAYERSPELL_UNCHANGED; else if (itr->second.state != PLAYERSPELL_NEW) itr->second.state = PLAYERSPELL_CHANGED; @@ -2970,8 +2951,7 @@ bool Player::AddSpell( LearnSpell(prev_spell, true, fromSkill); } - std::pair inserted = - m_spells.emplace(std::piecewise_construct, std::forward_as_tuple(spellId), std::forward_as_tuple()); + std::pair inserted = m_spells.emplace(std::piecewise_construct, std::forward_as_tuple(spellId), std::forward_as_tuple()); PlayerSpell& newspell = inserted.first->second; // learning a previous rank might have given us this spell already from a skill autolearn, most likely with // PLAYERSPELL_NEW state we dont want to do double insert if this happened during load from db so we force state to @@ -3098,8 +3078,7 @@ bool Player::AddSpell( // Also added for runeforging. It's already confirmed this happens upon learning for Death Knights, not from character // creation. if ((_spell_idx->second->AcquireMethod == SKILL_LINE_ABILITY_LEARNED_ON_SKILL_LEARN && !HasSkill(pSkill->ID)) || - ((pSkill->ID == SKILL_LOCKPICKING || pSkill->ID == SKILL_RUNEFORGING) && - _spell_idx->second->TrivialSkillLineRankHigh == 0)) + ((pSkill->ID == SKILL_LOCKPICKING || pSkill->ID == SKILL_RUNEFORGING) && _spell_idx->second->TrivialSkillLineRankHigh == 0)) LearnDefaultSkill(pSkill->ID, 0); } } @@ -3164,8 +3143,7 @@ bool Player::HandlePassiveSpellLearn(SpellInfo const* spellInfo) // note: form passives activated with shapeshift spells be implemented by HandleShapeshiftBoosts instead of spell_learn_spell // talent dependent passives activated at form apply have proper stance data ShapeshiftForm form = GetShapeshiftForm(); - bool need_cast = (!spellInfo->Stances || (form && (spellInfo->Stances & (UI64LIT(1) << (form - 1)))) || - (!form && spellInfo->HasAttribute(SPELL_ATTR2_NOT_NEED_SHAPESHIFT))); + bool need_cast = (!spellInfo->Stances || (form && (spellInfo->Stances & (UI64LIT(1) << (form - 1)))) || (!form && spellInfo->HasAttribute(SPELL_ATTR2_NOT_NEED_SHAPESHIFT))); // Check EquippedItemClass // passive spells which apply aura and have an item requirement are to be added manually, instead of casted @@ -3226,8 +3204,7 @@ void Player::LearnSpell(uint32 spell_id, bool dependent, uint32 fromSkill /*= 0* } SpellsRequiringSpellMapBounds spellsRequiringSpell = sSpellMgr->GetSpellsRequiringSpellBounds(spell_id); - for (SpellsRequiringSpellMap::const_iterator itr2 = spellsRequiringSpell.first; itr2 != spellsRequiringSpell.second; - ++itr2) + for (SpellsRequiringSpellMap::const_iterator itr2 = spellsRequiringSpell.first; itr2 != spellsRequiringSpell.second; ++itr2) { PlayerSpellMap::iterator iter2 = m_spells.find(itr2->second); if (iter2 != m_spells.end() && iter2->second.disabled) @@ -3248,8 +3225,7 @@ void Player::RemoveSpell(uint32 spell_id, bool disabled, bool learn_low_rank) if (itr == m_spells.end()) return; - if (itr->second.state == PLAYERSPELL_REMOVED || (disabled && itr->second.disabled) || - itr->second.state == PLAYERSPELL_TEMPORARY) + if (itr->second.state == PLAYERSPELL_REMOVED || (disabled && itr->second.disabled) || itr->second.state == PLAYERSPELL_TEMPORARY) return; // unlearn non talent higher ranks (recursive) @@ -3440,8 +3416,7 @@ void Player::RemoveArenaSpellCooldowns(bool removeActivePetCooldowns) [](SpellHistory::CooldownStorageType::iterator itr) -> bool { SpellInfo const* spellInfo = sSpellMgr->AssertSpellInfo(itr->first); - return spellInfo->RecoveryTime < 10 * MINUTE * IN_MILLISECONDS && - spellInfo->CategoryRecoveryTime < 10 * MINUTE * IN_MILLISECONDS; + return spellInfo->RecoveryTime < 10 * MINUTE * IN_MILLISECONDS && spellInfo->CategoryRecoveryTime < 10 * MINUTE * IN_MILLISECONDS; }, true); @@ -3707,8 +3682,7 @@ void Player::DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRe else if (characterInfo) // To avoid a query, we select loaded data. If it doesn't exist, return. { // Define the required variables - uint32 charDelete_minLvl = sWorld->getIntConfig( - characterInfo->Class != CLASS_DEATH_KNIGHT ? CONFIG_CHARDELETE_MIN_LEVEL : CONFIG_CHARDELETE_DEATH_KNIGHT_MIN_LEVEL); + uint32 charDelete_minLvl = sWorld->getIntConfig(characterInfo->Class != CLASS_DEATH_KNIGHT ? CONFIG_CHARDELETE_MIN_LEVEL : CONFIG_CHARDELETE_DEATH_KNIGHT_MIN_LEVEL); // if we want to finalize the character removal or the character does not meet the level requirement of either heroic or // non-heroic settings, we set it to mode CHAR_DELETE_REMOVE @@ -3848,8 +3822,7 @@ void Player::DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRe { do { - if (Player* playerFriend = - ObjectAccessor::FindPlayer(ObjectGuid(HighGuid::Player, 0, (*resultFriends)[0].GetUInt32()))) + if (Player* playerFriend = ObjectAccessor::FindPlayer(ObjectGuid(HighGuid::Player, 0, (*resultFriends)[0].GetUInt32()))) { playerFriend->GetSocial()->RemoveFromSocialList(playerguid, SOCIAL_FLAG_ALL); sSocialMgr->SendFriendStatus(playerFriend, FRIEND_REMOVED, playerguid); @@ -4044,9 +4017,7 @@ void Player::DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRe break; } default: - LOG_INFO("entities.player.cheat", - "Player::DeleteFromDB: Tried to delete player (%s) with unsupported delete method (%u).", - playerguid.ToString().c_str(), charDelete_method); + LOG_INFO("entities.player.cheat", "Player::DeleteFromDB: Tried to delete player (%s) with unsupported delete method (%u).", playerguid.ToString().c_str(), charDelete_method); if (trans->GetSize() > 0) CharacterDatabase.CommitTransaction(trans); @@ -4086,8 +4057,7 @@ void Player::DeleteOldCharacters() */ void Player::DeleteOldCharacters(uint32 keepDays) { - LOG_INFO("entities.player", "Player::DeleteOldCharacters: Deleting all characters which have been deleted %u days before...", - keepDays); + LOG_INFO("entities.player", "Player::DeleteOldCharacters: Deleting all characters which have been deleted %u days before...", keepDays); CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_OLD_CHARS); stmt->setUInt32(0, uint32(GameTime::GetGameTime() - time_t(keepDays * DAY))); @@ -4095,8 +4065,7 @@ void Player::DeleteOldCharacters(uint32 keepDays) if (result) { - LOG_DEBUG( - "entities.player", "Player::DeleteOldCharacters: Found " UI64FMTD " character(s) to delete", result->GetRowCount()); + LOG_DEBUG("entities.player", "Player::DeleteOldCharacters: Found " UI64FMTD " character(s) to delete", result->GetRowCount()); do { Field* fields = result->Fetch(); @@ -4128,8 +4097,7 @@ void Player::BuildPlayerRepop() WorldLocation corpseLocation = GetCorpseLocation(); if (corpseLocation.GetMapId() == GetMapId()) { - LOG_ERROR("entities.player", "Player::BuildPlayerRepop: Player '%s' (%s) already has a corpse", GetName().c_str(), - GetGUID().ToString().c_str()); + LOG_ERROR("entities.player", "Player::BuildPlayerRepop: Player '%s' (%s) already has a corpse", GetName().c_str(), GetGUID().ToString().c_str()); return; } @@ -4137,8 +4105,7 @@ void Player::BuildPlayerRepop() Corpse* corpse = CreateCorpse(); if (!corpse) { - LOG_ERROR("entities.player", "Player::BuildPlayerRepop: Error creating corpse for player '%s' (%s)", GetName().c_str(), - GetGUID().ToString().c_str()); + LOG_ERROR("entities.player", "Player::BuildPlayerRepop: Error creating corpse for player '%s' (%s)", GetName().c_str(), GetGUID().ToString().c_str()); return; } GetMap()->AddToMap(corpse); @@ -4263,8 +4230,7 @@ void Player::KillPlayer() // SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_IN_PVP); SetUInt32Value(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_NONE); - ApplyModFlag(PLAYER_FIELD_BYTES, PLAYER_FIELD_BYTE_RELEASE_TIMER, - !sMapStore.LookupEntry(GetMapId())->Instanceable() && !HasAuraType(SPELL_AURA_PREVENT_RESURRECTION)); + ApplyModFlag(PLAYER_FIELD_BYTES, PLAYER_FIELD_BYTE_RELEASE_TIMER, !sMapStore.LookupEntry(GetMapId())->Instanceable() && !HasAuraType(SPELL_AURA_PREVENT_RESURRECTION)); // 6 minutes until repop at graveyard m_deathTimer = 6 * MINUTE * IN_MILLISECONDS; @@ -4369,7 +4335,10 @@ void Player::SpawnCorpseBones(bool triggerSave /*= true*/) SaveToDB(); // prevent loading as ghost without corpse } -Corpse* Player::GetCorpse() const { return GetMap()->GetCorpseByPlayer(GetGUID()); } +Corpse* Player::GetCorpse() const +{ + return GetMap()->GetCorpseByPlayer(GetGUID()); +} void Player::DurabilityLossAll(double percent, bool inventory) { @@ -4580,8 +4549,7 @@ void Player::DurabilityRepair(uint16 pos, bool takeCost, float discountMod) if (!HasEnoughMoney(uint64(cost))) { - LOG_DEBUG("entities.player.items", "Player::DurabilityRepair: Player '%s' (%s) has not enough money to repair item", - GetName().c_str(), GetGUID().ToString().c_str()); + LOG_DEBUG("entities.player.items", "Player::DurabilityRepair: Player '%s' (%s) has not enough money to repair item", GetName().c_str(), GetGUID().ToString().c_str()); return; } @@ -4606,8 +4574,7 @@ void Player::RepopAtGraveyard() AreaTableEntry const* zone = sAreaTableStore.LookupEntry(GetAreaId()); // Such zones are considered unreachable as a ghost and the player must be automatically revived - if ((!IsAlive() && zone && zone->Flags & AREA_FLAG_NEED_FLY) || GetTransport() || - GetPositionZ() < GetMap()->GetMinHeight(GetPhaseShift(), GetPositionX(), GetPositionY())) + if ((!IsAlive() && zone && zone->Flags & AREA_FLAG_NEED_FLY) || GetTransport() || GetPositionZ() < GetMap()->GetMinHeight(GetPhaseShift(), GetPositionX(), GetPositionY())) { ResurrectPlayer(0.5f); SpawnCorpseBones(); @@ -4634,8 +4601,7 @@ void Player::RepopAtGraveyard() if (ClosestGrave) { float const* orientation = sObjectMgr->GetGraveyardOrientation(ClosestGrave->ID); - TeleportTo(ClosestGrave->Continent, ClosestGrave->Loc.X, ClosestGrave->Loc.Y, ClosestGrave->Loc.Z, - orientation ? *orientation : GetOrientation()); + TeleportTo(ClosestGrave->Continent, ClosestGrave->Loc.X, ClosestGrave->Loc.Y, ClosestGrave->Loc.Z, orientation ? *orientation : GetOrientation()); if (isDead()) // not send if alive, because it used in TeleportTo() { WorldPackets::Misc::DeathReleaseLoc packet; @@ -4664,9 +4630,15 @@ bool Player::CanJoinConstantChannelInZone(ChatChannelsEntry const* channel, Area return true; } -void Player::JoinedChannel(Channel* c) { m_channels.push_back(c); } +void Player::JoinedChannel(Channel* c) +{ + m_channels.push_back(c); +} -void Player::LeftChannel(Channel* c) { m_channels.remove(c); } +void Player::LeftChannel(Channel* c) +{ + m_channels.remove(c); +} void Player::CleanupChannels() { @@ -4685,8 +4657,7 @@ void Player::CleanupChannels() cMgr->LeftChannel(ch->GetName()); } } - LOG_DEBUG("chat.system", "Player::CleanupChannels: Channels of player '%s' (%s) cleaned up.", GetName().c_str(), - GetGUID().ToString().c_str()); + LOG_DEBUG("chat.system", "Player::CleanupChannels: Channels of player '%s' (%s) cleaned up.", GetName().c_str(), GetGUID().ToString().c_str()); } void Player::UpdateLocalChannels(uint32 newZone) @@ -4779,8 +4750,7 @@ void Player::HandleBaseModFlatValue(BaseModGroup modGroup, float amount, bool ap { if (modGroup >= BASEMOD_END) { - LOG_ERROR("spells", "Player::HandleBaseModValue: Invalid BaseModGroup/BaseModType (%u/%u) for player '%s' (%s)", modGroup, - FLAT_MOD, GetName().c_str(), GetGUID().ToString().c_str()); + LOG_ERROR("spells", "Player::HandleBaseModValue: Invalid BaseModGroup/BaseModType (%u/%u) for player '%s' (%s)", modGroup, FLAT_MOD, GetName().c_str(), GetGUID().ToString().c_str()); return; } @@ -4792,8 +4762,7 @@ void Player::ApplyBaseModPctValue(BaseModGroup modGroup, float pct) { if (modGroup >= BASEMOD_END) { - LOG_ERROR("spells", "Player::HandleBaseModValue: Invalid BaseModGroup/BaseModType (%u/%u) for player '%s' (%s)", modGroup, - FLAT_MOD, GetName().c_str(), GetGUID().ToString().c_str()); + LOG_ERROR("spells", "Player::HandleBaseModValue: Invalid BaseModGroup/BaseModType (%u/%u) for player '%s' (%s)", modGroup, FLAT_MOD, GetName().c_str(), GetGUID().ToString().c_str()); return; } @@ -4847,8 +4816,7 @@ void Player::UpdateDamageDoneMods(WeaponAttackType attackType) for (uint8 slot = 0; slot < MAX_ENCHANTMENT_SLOT; ++slot) { - SpellItemEnchantmentEntry const* enchantmentEntry = - sSpellItemEnchantmentStore.LookupEntry(item->GetEnchantmentId(EnchantmentSlot(slot))); + SpellItemEnchantmentEntry const* enchantmentEntry = sSpellItemEnchantmentStore.LookupEntry(item->GetEnchantmentId(EnchantmentSlot(slot))); if (!enchantmentEntry) continue; @@ -4897,8 +4865,7 @@ float Player::GetBaseModValue(BaseModGroup modGroup, BaseModType modType) const { if (modGroup >= BASEMOD_END || modType >= MOD_END) { - LOG_ERROR("spells", "Player::GetBaseModValue: Invalid BaseModGroup/BaseModType (%u/%u) for player '%s' (%s)", modGroup, - modType, GetName().c_str(), GetGUID().ToString().c_str()); + LOG_ERROR("spells", "Player::GetBaseModValue: Invalid BaseModGroup/BaseModType (%u/%u) for player '%s' (%s)", modGroup, modType, GetName().c_str(), GetGUID().ToString().c_str()); return 0.0f; } @@ -4909,8 +4876,7 @@ float Player::GetTotalBaseModValue(BaseModGroup modGroup) const { if (modGroup >= BASEMOD_END) { - LOG_ERROR("spells", "Player::GetTotalBaseModValue: Invalid BaseModGroup (%u) for player '%s' (%s)", modGroup, - GetName().c_str(), GetGUID().ToString().c_str()); + LOG_ERROR("spells", "Player::GetTotalBaseModValue: Invalid BaseModGroup (%u) for player '%s' (%s)", modGroup, GetName().c_str(), GetGUID().ToString().c_str()); return 0.0f; } @@ -4983,8 +4949,7 @@ void Player::GetDodgeFromAgility(float& diminishing, float& nondiminishing) cons level = GT_MAX_LEVEL; // Dodge per agility is proportional to crit per agility, which is available from DBC files - GtChanceToMeleeCritEntry const* dodgeRatio = - sGtChanceToMeleeCritStore.LookupEntry((playerClass - 1) * GT_MAX_LEVEL + level - 1); + GtChanceToMeleeCritEntry const* dodgeRatio = sGtChanceToMeleeCritStore.LookupEntry((playerClass - 1) * GT_MAX_LEVEL + level - 1); if (!dodgeRatio || playerClass > MAX_CLASSES) return; @@ -5022,8 +4987,7 @@ float Player::GetRatingMultiplier(CombatRating cr) const GtCombatRatingsEntry const* Rating = sGtCombatRatingsStore.LookupEntry(cr * GT_MAX_LEVEL + level - 1); // gtOCTClassCombatRatingScalarStore.dbc starts with 1, CombatRating with zero, so cr+1 - GtOCTClassCombatRatingScalarEntry const* classRating = - sGtOCTClassCombatRatingScalarStore.LookupEntry((getClass() - 1) * GT_MAX_RATING + cr + 1); + GtOCTClassCombatRatingScalarEntry const* classRating = sGtOCTClassCombatRatingScalarStore.LookupEntry((getClass() - 1) * GT_MAX_RATING + cr + 1); if (!Rating || !classRating) return 1.0f; // By default use minimum coefficient (not must be called) @@ -5079,31 +5043,25 @@ void Player::ApplyRatingMod(CombatRating combatRating, int32 value, bool apply) case CR_HASTE_MELEE: { ApplyAttackTimePercentMod(BASE_ATTACK, m_baseRatingValue[combatRating] * GetRatingMultiplier(combatRating), false); - ApplyAttackTimePercentMod( - BASE_ATTACK, (m_baseRatingValue[combatRating] + (apply ? value : -value)) * GetRatingMultiplier(combatRating), true); + ApplyAttackTimePercentMod(BASE_ATTACK, (m_baseRatingValue[combatRating] + (apply ? value : -value)) * GetRatingMultiplier(combatRating), true); ApplyAttackTimePercentMod(OFF_ATTACK, m_baseRatingValue[combatRating] * GetRatingMultiplier(combatRating), false); - ApplyAttackTimePercentMod( - OFF_ATTACK, (m_baseRatingValue[combatRating] + (apply ? value : -value)) * GetRatingMultiplier(combatRating), true); + ApplyAttackTimePercentMod(OFF_ATTACK, (m_baseRatingValue[combatRating] + (apply ? value : -value)) * GetRatingMultiplier(combatRating), true); ApplyHasteRegenMod(BASE_ATTACK, m_baseRatingValue[combatRating] * GetRatingMultiplier(combatRating), false); - ApplyHasteRegenMod( - BASE_ATTACK, (m_baseRatingValue[combatRating] + (apply ? value : -value)) * GetRatingMultiplier(combatRating), true); + ApplyHasteRegenMod(BASE_ATTACK, (m_baseRatingValue[combatRating] + (apply ? value : -value)) * GetRatingMultiplier(combatRating), true); break; } case CR_HASTE_RANGED: { ApplyAttackTimePercentMod(RANGED_ATTACK, m_baseRatingValue[combatRating] * GetRatingMultiplier(combatRating), false); - ApplyAttackTimePercentMod(RANGED_ATTACK, - (m_baseRatingValue[combatRating] + (apply ? value : -value)) * GetRatingMultiplier(combatRating), true); + ApplyAttackTimePercentMod(RANGED_ATTACK, (m_baseRatingValue[combatRating] + (apply ? value : -value)) * GetRatingMultiplier(combatRating), true); ApplyHasteRegenMod(RANGED_ATTACK, m_baseRatingValue[combatRating] * GetRatingMultiplier(combatRating), false); - ApplyHasteRegenMod(RANGED_ATTACK, - (m_baseRatingValue[combatRating] + (apply ? value : -value)) * GetRatingMultiplier(combatRating), true); + ApplyHasteRegenMod(RANGED_ATTACK, (m_baseRatingValue[combatRating] + (apply ? value : -value)) * GetRatingMultiplier(combatRating), true); break; } case CR_HASTE_SPELL: { ApplyCastTimePercentMod(m_baseRatingValue[combatRating] * GetRatingMultiplier(combatRating), false); - ApplyCastTimePercentMod( - (m_baseRatingValue[combatRating] + (apply ? value : -value)) * GetRatingMultiplier(combatRating), true); + ApplyCastTimePercentMod((m_baseRatingValue[combatRating] + (apply ? value : -value)) * GetRatingMultiplier(combatRating), true); break; } default: @@ -5220,7 +5178,10 @@ void Player::SetRegularAttackTime() } } -void Player::StoreRaidMapDifficulty() { m_raidMapDifficulty = GetMap()->GetDifficulty(); } +void Player::StoreRaidMapDifficulty() +{ + m_raidMapDifficulty = GetMap()->GetDifficulty(); +} // skill+step, checking for max value bool Player::UpdateSkill(uint32 skill_id, uint32 step) @@ -5278,8 +5239,7 @@ inline int32 SkillGainChance(Player const* player, uint32 SkillValue, uint32 Gra bool Player::UpdateCraftSkill(uint32 spellid) { - LOG_DEBUG("entities.player.skills", "Player::UpdateCraftSkill: Player '%s' (%s), SpellID: %d", GetName().c_str(), - GetGUID().ToString().c_str(), spellid); + LOG_DEBUG("entities.player.skills", "Player::UpdateCraftSkill: Player '%s' (%s), SpellID: %d", GetName().c_str(), GetGUID().ToString().c_str(), spellid); SkillLineAbilityMapBounds bounds = sSpellMgr->GetSkillLineAbilityMapBounds(spellid); @@ -5303,18 +5263,15 @@ bool Player::UpdateCraftSkill(uint32 spellid) if (craft_skill_points) { craft_skill_points *= craft_skill_gain; - LOG_INFO("entities.player", "craft_skill_points is %u, spellID: %u, skillID: %u", craft_skill_points, spellid, - _spell_idx->second->SkillLine); + LOG_INFO("entities.player", "craft_skill_points is %u, spellID: %u, skillID: %u", craft_skill_points, spellid, _spell_idx->second->SkillLine); return UpdateSkillPro(_spell_idx->second->SkillLine, - SkillGainChance(this, SkillValue, _spell_idx->second->TrivialSkillLineRankHigh, - (_spell_idx->second->TrivialSkillLineRankHigh + _spell_idx->second->TrivialSkillLineRankLow) / 2, + SkillGainChance(this, SkillValue, _spell_idx->second->TrivialSkillLineRankHigh, (_spell_idx->second->TrivialSkillLineRankHigh + _spell_idx->second->TrivialSkillLineRankLow) / 2, _spell_idx->second->TrivialSkillLineRankLow), craft_skill_points); } return UpdateSkillPro(_spell_idx->second->SkillLine, - SkillGainChance(this, SkillValue, _spell_idx->second->TrivialSkillLineRankHigh, - (_spell_idx->second->TrivialSkillLineRankHigh + _spell_idx->second->TrivialSkillLineRankLow) / 2, + SkillGainChance(this, SkillValue, _spell_idx->second->TrivialSkillLineRankHigh, (_spell_idx->second->TrivialSkillLineRankHigh + _spell_idx->second->TrivialSkillLineRankLow) / 2, _spell_idx->second->TrivialSkillLineRankLow), craft_skill_gain); } @@ -5337,28 +5294,20 @@ bool Player::UpdateGatherSkill(uint32 SkillId, uint32 SkillValue, uint32 RedLeve case SKILL_LOCKPICKING: case SKILL_JEWELCRAFTING: case SKILL_INSCRIPTION: - return UpdateSkillPro(SkillId, - SkillGainChance(this, SkillValue, RedLevel + 100, RedLevel + 50, RedLevel + 25) * Multiplicator, - gathering_skill_gain); + return UpdateSkillPro(SkillId, SkillGainChance(this, SkillValue, RedLevel + 100, RedLevel + 50, RedLevel + 25) * Multiplicator, gathering_skill_gain); case SKILL_SKINNING: if (sWorld->getIntConfig(CONFIG_SKILL_CHANCE_SKINNING_STEPS) == 0) - return UpdateSkillPro(SkillId, - SkillGainChance(this, SkillValue, RedLevel + 100, RedLevel + 50, RedLevel + 25) * Multiplicator, - gathering_skill_gain); + return UpdateSkillPro(SkillId, SkillGainChance(this, SkillValue, RedLevel + 100, RedLevel + 50, RedLevel + 25) * Multiplicator, gathering_skill_gain); else return UpdateSkillPro(SkillId, - (SkillGainChance(this, SkillValue, RedLevel + 100, RedLevel + 50, RedLevel + 25) * Multiplicator) >> - (SkillValue / sWorld->getIntConfig(CONFIG_SKILL_CHANCE_SKINNING_STEPS)), + (SkillGainChance(this, SkillValue, RedLevel + 100, RedLevel + 50, RedLevel + 25) * Multiplicator) >> (SkillValue / sWorld->getIntConfig(CONFIG_SKILL_CHANCE_SKINNING_STEPS)), gathering_skill_gain); case SKILL_MINING: if (sWorld->getIntConfig(CONFIG_SKILL_CHANCE_MINING_STEPS) == 0) - return UpdateSkillPro(SkillId, - SkillGainChance(this, SkillValue, RedLevel + 100, RedLevel + 50, RedLevel + 25) * Multiplicator, - gathering_skill_gain); + return UpdateSkillPro(SkillId, SkillGainChance(this, SkillValue, RedLevel + 100, RedLevel + 50, RedLevel + 25) * Multiplicator, gathering_skill_gain); else return UpdateSkillPro(SkillId, - (SkillGainChance(this, SkillValue, RedLevel + 100, RedLevel + 50, RedLevel + 25) * Multiplicator) >> - (SkillValue / sWorld->getIntConfig(CONFIG_SKILL_CHANCE_MINING_STEPS)), + (SkillGainChance(this, SkillValue, RedLevel + 100, RedLevel + 50, RedLevel + 25) * Multiplicator) >> (SkillValue / sWorld->getIntConfig(CONFIG_SKILL_CHANCE_MINING_STEPS)), gathering_skill_gain); } return false; @@ -5378,8 +5327,7 @@ uint8 GetFishingStepsNeededToLevelUp(uint32 SkillValue) bool Player::UpdateFishingSkill() { - LOG_DEBUG("entities.player.skills", "Player::UpdateFishingSkill: Player '%s' (%s)", GetName().c_str(), - GetGUID().ToString().c_str()); + LOG_DEBUG("entities.player.skills", "Player::UpdateFishingSkill: Player '%s' (%s)", GetName().c_str(), GetGUID().ToString().c_str()); uint32 SkillValue = GetPureSkillValue(SKILL_FISHING); @@ -5421,9 +5369,7 @@ void Player::GiveXpForGather(uint32 const& skillId) else level = getLevel() + 3; - uint32 xp = - Firelands::XP::BaseGain(level, areaEntry->LevelRangeMax, sDBCManager.GetContentLevelsForMapAndZone(GetMapId(), zoneId)) * - 2; + uint32 xp = Firelands::XP::BaseGain(level, areaEntry->LevelRangeMax, sDBCManager.GetContentLevelsForMapAndZone(GetMapId(), zoneId)) * 2; if (!xp || levelDiff >= 20) return; @@ -5435,17 +5381,35 @@ void Player::GiveXpForGather(uint32 const& skillId) GiveXP(xp, nullptr); } -void Player::SurveyDigSite() { _archaeology->UseSite(); } +void Player::SurveyDigSite() +{ + _archaeology->UseSite(); +} -void Player::NotifyRequestResearchHistory() { _archaeology->SendResearchHistory(); } +void Player::NotifyRequestResearchHistory() +{ + _archaeology->SendResearchHistory(); +} -bool Player::ArchProjectCompleteable(uint16 projectId) { return _archaeology->ProjectCompleteable(projectId); } +bool Player::ArchProjectCompleteable(uint16 projectId) +{ + return _archaeology->ProjectCompleteable(projectId); +} -bool Player::HasArchProject(uint16 projectId) { return _archaeology->ProjectExists(projectId); } +bool Player::HasArchProject(uint16 projectId) +{ + return _archaeology->ProjectExists(projectId); +} -void Player::CompleteArchProject(uint16 projectId) { _archaeology->CompleteProject(projectId); } +void Player::CompleteArchProject(uint16 projectId) +{ + _archaeology->CompleteProject(projectId); +} -void Player::SetArchData(ArchData const& data) { _archaeology->SetArchData(data); } +void Player::SetArchData(ArchData const& data) +{ + _archaeology->SetArchData(data); +} bool Player::UpdateSkillPro(uint16 skillId, int32 chance, uint32 step) { @@ -5649,8 +5613,7 @@ void Player::SetSkill(uint16 id, uint16 step, uint16 newVal, uint16 maxVal) itr->second.uState = SKILL_UNCHANGED; // remove all spells that related to this skill - if (std::vector const* skillLineAbilities = - sDBCManager.GetSkillLineAbilitiesBySkill(id)) + if (std::vector const* skillLineAbilities = sDBCManager.GetSkillLineAbilitiesBySkill(id)) for (SkillLineAbilityEntry const* skillLineAbility : *skillLineAbilities) RemoveSpell(sSpellMgr->GetFirstSpellInChain(skillLineAbility->Spell)); @@ -5682,8 +5645,7 @@ void Player::SetSkill(uint16 id, uint16 step, uint16 newVal, uint16 maxVal) if (!skillSlot) { - LOG_ERROR("misc", "Tried to add skill %u but player %s (%s) cannot have additional skills", id, GetName().c_str(), - GetGUID().ToString().c_str()); + LOG_ERROR("misc", "Tried to add skill %u but player %s (%s) cannot have additional skills", id, GetName().c_str(), GetGUID().ToString().c_str()); return; } @@ -5898,17 +5860,15 @@ bool Player::IsActionButtonDataValid(uint8 button, uint32 action, uint8 type) co { if (button >= MAX_ACTION_BUTTONS) { - LOG_ERROR("entities.player", - "Player::IsActionButtonDataValid: Action %u not added into button %u for player %s (%s): button must be < %u", action, - button, GetName().c_str(), GetGUID().ToString().c_str(), MAX_ACTION_BUTTONS); + LOG_ERROR("entities.player", "Player::IsActionButtonDataValid: Action %u not added into button %u for player %s (%s): button must be < %u", action, button, GetName().c_str(), + GetGUID().ToString().c_str(), MAX_ACTION_BUTTONS); return false; } if (action >= MAX_ACTION_BUTTON_ACTION_VALUE) { - LOG_ERROR("entities.player", - "Player::IsActionButtonDataValid: Action %u not added into button %u for player %s (%s): action must be < %u", action, - button, GetName().c_str(), GetGUID().ToString().c_str(), MAX_ACTION_BUTTON_ACTION_VALUE); + LOG_ERROR("entities.player", "Player::IsActionButtonDataValid: Action %u not added into button %u for player %s (%s): action must be < %u", action, button, GetName().c_str(), + GetGUID().ToString().c_str(), MAX_ACTION_BUTTON_ACTION_VALUE); return false; } @@ -5936,9 +5896,8 @@ bool Player::IsActionButtonDataValid(uint8 button, uint32 action, uint8 type) co case ACTION_BUTTON_ITEM: if (!sObjectMgr->GetItemTemplate(action)) { - LOG_ERROR("entities.player", - "Player::IsActionButtonDataValid: Item action %u not added into button %u for player %s (%s): item not exist", - action, button, GetName().c_str(), GetGUID().ToString().c_str()); + LOG_ERROR("entities.player", "Player::IsActionButtonDataValid: Item action %u not added into button %u for player %s (%s): item not exist", action, button, GetName().c_str(), + GetGUID().ToString().c_str()); return false; } break; @@ -5967,8 +5926,7 @@ ActionButton* Player::addActionButton(uint8 button, uint32 action, uint8 type) // set data and update to CHANGED if not NEW ab.SetActionAndType(action, ActionButtonType(type)); - LOG_DEBUG("entities.player", "Player::AddActionButton: Player '%s' (%s) added action '%u' (type %u) to button '%u'", - GetName().c_str(), GetGUID().ToString().c_str(), action, type, button); + LOG_DEBUG("entities.player", "Player::AddActionButton: Player '%s' (%s) added action '%u' (type %u) to button '%u'", GetName().c_str(), GetGUID().ToString().c_str(), action, type, button); return &ab; } @@ -5983,8 +5941,7 @@ void Player::removeActionButton(uint8 button) else buttonItr->second.uState = ACTIONBUTTON_DELETED; // saved, will deleted at next save - LOG_DEBUG("entities.player", "Player::RemoveActionButton: Player '%s' (%s) removed action button '%u'", GetName().c_str(), - GetGUID().ToString().c_str(), button); + LOG_DEBUG("entities.player", "Player::RemoveActionButton: Player '%s' (%s) removed action button '%u'", GetName().c_str(), GetGUID().ToString().c_str(), button); } ActionButton const* Player::GetActionButton(uint8 button) @@ -6060,7 +6017,10 @@ void Player::SendMessageToSet(WorldPacket const* data, Player const* skipped_rcv Cell::VisitWorldObjects(this, notifier, GetVisibilityRange()); } -void Player::SendDirectMessage(WorldPacket const* data) const { m_session->SendPacket(data); } +void Player::SendDirectMessage(WorldPacket const* data) const +{ + m_session->SendPacket(data); +} void Player::SendCinematicStart(uint32 cinematicId) { @@ -6096,8 +6056,8 @@ void Player::CheckAreaExploreAndOutdoor() if (!areaEntry) { - LOG_ERROR("entities.player", "Player '%s' (%s) discovered unknown area (x: %f y: %f z: %f map: %u)", GetName().c_str(), - GetGUID().ToString().c_str(), GetPositionX(), GetPositionY(), GetPositionZ(), GetMapId()); + LOG_ERROR("entities.player", "Player '%s' (%s) discovered unknown area (x: %f y: %f z: %f map: %u)", GetName().c_str(), GetGUID().ToString().c_str(), GetPositionX(), GetPositionY(), + GetPositionZ(), GetMapId()); return; } @@ -6139,8 +6099,7 @@ void Player::CheckAreaExploreAndOutdoor() if (exploration_percent < 0) exploration_percent = 0; - XP = uint32(sObjectMgr->GetBaseXP(areaEntry->ExplorationLevel) * exploration_percent / 100 * - sWorld->getRate(RATE_XP_EXPLORE)); + XP = uint32(sObjectMgr->GetBaseXP(areaEntry->ExplorationLevel) * exploration_percent / 100 * sWorld->getRate(RATE_XP_EXPLORE)); } else { @@ -6150,16 +6109,14 @@ void Player::CheckAreaExploreAndOutdoor() if (sWorld->getIntConfig(CONFIG_MIN_DISCOVERED_SCALED_XP_RATIO)) { uint32 minScaledXP = - uint32(sObjectMgr->GetBaseXP(areaEntry->ExplorationLevel) * sWorld->getRate(RATE_XP_EXPLORE)) * - sWorld->getIntConfig(CONFIG_MIN_DISCOVERED_SCALED_XP_RATIO) / 100; + uint32(sObjectMgr->GetBaseXP(areaEntry->ExplorationLevel) * sWorld->getRate(RATE_XP_EXPLORE)) * sWorld->getIntConfig(CONFIG_MIN_DISCOVERED_SCALED_XP_RATIO) / 100; XP = std::max(minScaledXP, XP); } GiveXP(XP, nullptr); SendExplorationExperience(areaId, XP); } - LOG_DEBUG("entities.player", "Player '%s' (%s) discovered a new area: %u", GetName().c_str(), - GetGUID().ToString().c_str(), areaId); + LOG_DEBUG("entities.player", "Player '%s' (%s) discovered a new area: %u", GetName().c_str(), GetGUID().ToString().c_str(), areaId); } } } @@ -6175,8 +6132,7 @@ uint32 Player::TeamForRace(uint8 race) case 7: return ALLIANCE; } - LOG_ERROR( - "entities.player", "Race (%u) has wrong teamid (%u) in DBC: wrong DBC files?", uint32(race), rEntry->BaseLanguage); + LOG_ERROR("entities.player", "Race (%u) has wrong teamid (%u) in DBC: wrong DBC files?", uint32(race), rEntry->BaseLanguage); } else LOG_ERROR("entities.player", "Race (%u) not found in DBC: wrong DBC files?", uint32(race)); @@ -6199,8 +6155,7 @@ ReputationRank Player::GetReputationRank(uint32 faction) const } // Calculate total reputation percent player gain with quest/creature level -int32 Player::CalculateReputationGain( - ReputationSource source, uint32 creatureOrQuestLevel, int32 rep, int32 faction, bool noQuestBonus) +int32 Player::CalculateReputationGain(ReputationSource source, uint32 creatureOrQuestLevel, int32 rep, int32 faction, bool noQuestBonus) { float percent = 100.0f; @@ -6334,8 +6289,7 @@ void Player::RewardOnKill(Unit* victim, float rate) and usual reputation at the same time which is why we duplicate the reward and modify the 2nd */ bool secondaryReputationReward1 = - (GetExpansionForFaction(rewFactionEntry1->ParentFactionID) == EXPANSION_THE_BURNING_CRUSADE || - GetExpansionForFaction(Rew->RepFaction1) == EXPANSION_THE_BURNING_CRUSADE); + (GetExpansionForFaction(rewFactionEntry1->ParentFactionID) == EXPANSION_THE_BURNING_CRUSADE || GetExpansionForFaction(Rew->RepFaction1) == EXPANSION_THE_BURNING_CRUSADE); uint32 factionId1 = (ChampioningFaction && !secondaryReputationReward1) ? ChampioningFaction : Rew->RepFaction1; if (rewFactionEntry1->Expansion && !ChampioningFaction) @@ -6355,8 +6309,7 @@ void Player::RewardOnKill(Unit* victim, float rate) uint32 current_bonus_reputation_rank1 = GetReputationMgr().GetRank(bonusFactionEntry1); if (bonusFactionEntry1) - GetReputationMgr().ModifyReputation( - bonusFactionEntry1, donerep1, current_bonus_reputation_rank1 > Rew->ReputationMaxCap1); + GetReputationMgr().ModifyReputation(bonusFactionEntry1, donerep1, current_bonus_reputation_rank1 > Rew->ReputationMaxCap1); } } } @@ -6366,8 +6319,7 @@ void Player::RewardOnKill(Unit* victim, float rate) if (FactionEntry const* rewFactionEntry2 = sFactionStore.LookupEntry(Rew->RepFaction2)) { bool secondaryReputationReward2 = - (GetExpansionForFaction(rewFactionEntry2->ParentFactionID) == EXPANSION_THE_BURNING_CRUSADE || - GetExpansionForFaction(Rew->RepFaction1) == EXPANSION_THE_BURNING_CRUSADE); + (GetExpansionForFaction(rewFactionEntry2->ParentFactionID) == EXPANSION_THE_BURNING_CRUSADE || GetExpansionForFaction(Rew->RepFaction1) == EXPANSION_THE_BURNING_CRUSADE); uint32 factionId2 = (ChampioningFaction && secondaryReputationReward2) ? ChampioningFaction : Rew->RepFaction2; if (rewFactionEntry2->Expansion && !ChampioningFaction) @@ -6387,8 +6339,7 @@ void Player::RewardOnKill(Unit* victim, float rate) uint32 current_bonus_reputation_rank2 = GetReputationMgr().GetRank(bonusFactionEntry2); if (bonusFactionEntry2) - GetReputationMgr().ModifyReputation( - bonusFactionEntry2, donerep2, current_bonus_reputation_rank2 > Rew->ReputationMaxCap1); + GetReputationMgr().ModifyReputation(bonusFactionEntry2, donerep2, current_bonus_reputation_rank2 > Rew->ReputationMaxCap1); } } } @@ -6445,20 +6396,15 @@ void Player::RewardReputation(Quest const* quest) continue; if (quest->IsDaily()) - rep = CalculateReputationGain( - REPUTATION_SOURCE_DAILY_QUEST, GetQuestLevel(quest), rep, quest->RewardFactionId[i], noQuestBonus); + rep = CalculateReputationGain(REPUTATION_SOURCE_DAILY_QUEST, GetQuestLevel(quest), rep, quest->RewardFactionId[i], noQuestBonus); else if (quest->IsWeekly()) - rep = CalculateReputationGain( - REPUTATION_SOURCE_WEEKLY_QUEST, GetQuestLevel(quest), rep, quest->RewardFactionId[i], noQuestBonus); + rep = CalculateReputationGain(REPUTATION_SOURCE_WEEKLY_QUEST, GetQuestLevel(quest), rep, quest->RewardFactionId[i], noQuestBonus); else if (quest->IsMonthly()) - rep = CalculateReputationGain( - REPUTATION_SOURCE_MONTHLY_QUEST, GetQuestLevel(quest), rep, quest->RewardFactionId[i], noQuestBonus); + rep = CalculateReputationGain(REPUTATION_SOURCE_MONTHLY_QUEST, GetQuestLevel(quest), rep, quest->RewardFactionId[i], noQuestBonus); else if (quest->IsRepeatable()) - rep = CalculateReputationGain( - REPUTATION_SOURCE_REPEATABLE_QUEST, GetQuestLevel(quest), rep, quest->RewardFactionId[i], noQuestBonus); + rep = CalculateReputationGain(REPUTATION_SOURCE_REPEATABLE_QUEST, GetQuestLevel(quest), rep, quest->RewardFactionId[i], noQuestBonus); else - rep = CalculateReputationGain( - REPUTATION_SOURCE_QUEST, GetQuestLevel(quest), rep, quest->RewardFactionId[i], noQuestBonus); + rep = CalculateReputationGain(REPUTATION_SOURCE_QUEST, GetQuestLevel(quest), rep, quest->RewardFactionId[i], noQuestBonus); if (FactionEntry const* factionEntry = sFactionStore.LookupEntry(quest->RewardFactionId[i])) GetReputationMgr().ModifyReputation(factionEntry, rep); @@ -6639,8 +6585,7 @@ bool Player::RewardHonor(Unit* victim, uint32 groupsize, int32 honor, bool pvpto { // Check if allowed to receive it in current map uint8 MapType = sWorld->getIntConfig(CONFIG_PVP_TOKEN_MAP_TYPE); - if ((MapType == 1 && !InBattleground() && !IsFFAPvP()) || (MapType == 2 && !IsFFAPvP()) || - (MapType == 3 && !InBattleground())) + if ((MapType == 1 && !InBattleground() && !IsFFAPvP()) || (MapType == 2 && !IsFFAPvP()) || (MapType == 3 && !InBattleground())) return true; uint32 itemId = sWorld->getIntConfig(CONFIG_PVP_TOKEN_ID); @@ -6826,8 +6771,7 @@ bool Player::HasCurrency(uint32 id, uint32 count) const return itr != _currencyStorage.end() && itr->second.Quantity >= count; } -void Player::ModifyCurrency( - uint32 id, int32 count, bool printLog /* = true*/, bool ignoreMultipliers /* = false*/, bool isRefund /* = false*/) +void Player::ModifyCurrency(uint32 id, int32 count, bool printLog /* = true*/, bool ignoreMultipliers /* = false*/, bool isRefund /* = false*/) { if (!count) return; @@ -6934,8 +6878,7 @@ void Player::ModifyCurrency( return; } - if (itr->second.state == PLAYERCURRENCY_NEW && HasSkill(SKILL_ARCHAEOLOGY) && - currency->CategoryID == CURRENCY_CATEGORY_ARCHAEOLOGY) + if (itr->second.state == PLAYERCURRENCY_NEW && HasSkill(SKILL_ARCHAEOLOGY) && currency->CategoryID == CURRENCY_CATEGORY_ARCHAEOLOGY) _archaeology->ActivateBranch(sArchaeologyMgr->Currency2BranchId(currency->ID)); WorldPacket packet(SMSG_UPDATE_CURRENCY, 12); @@ -7011,8 +6954,7 @@ uint32 Player::GetCurrencyWeekCap(CurrencyTypesEntry const* currency) const { // original conquest not have week cap case CURRENCY_TYPE_CONQUEST_POINTS: - return std::max(GetCurrencyWeekCap(CURRENCY_TYPE_CONQUEST_META_ARENA, false), - GetCurrencyWeekCap(CURRENCY_TYPE_CONQUEST_META_RBG, false)); + return std::max(GetCurrencyWeekCap(CURRENCY_TYPE_CONQUEST_META_ARENA, false), GetCurrencyWeekCap(CURRENCY_TYPE_CONQUEST_META_RBG, false)); case CURRENCY_TYPE_CONQUEST_META_ARENA: // should add precision mod = 100 return Firelands::Currency::ConquestRatingCalculator(_maxPersonalArenaRate) * CURRENCY_PRECISION; @@ -7076,8 +7018,7 @@ void Player::SetInGuild(uint32 guildId) else SetGuidValue(OBJECT_FIELD_DATA, ObjectGuid::Empty); - ApplyModFlag( - PLAYER_FLAGS, PLAYER_FLAGS_GUILD_LEVEL_ENABLED, guildId != 0 && sWorld->getBoolConfig(CONFIG_GUILD_LEVELING_ENABLED)); + ApplyModFlag(PLAYER_FLAGS, PLAYER_FLAGS_GUILD_LEVEL_ENABLED, guildId != 0 && sWorld->getBoolConfig(CONFIG_GUILD_LEVELING_ENABLED)); SetUInt16Value(OBJECT_FIELD_TYPE, 1, guildId != 0); sCharacterCache->UpdateCharacterGuildId(GetGUID(), guildId); } @@ -7272,8 +7213,7 @@ void Player::UpdateHostileAreaState(AreaTableEntry const* area) { if (area) { - if (InBattleground() || area->Flags & AREA_FLAG_COMBAT || - (area->PvpCombatWorldStateID != -1 && sWorld->getWorldState(area->PvpCombatWorldStateID) != 0)) + if (InBattleground() || area->Flags & AREA_FLAG_COMBAT || (area->PvpCombatWorldStateID != -1 && sWorld->getWorldState(area->PvpCombatWorldStateID) != 0)) pvpInfo.IsInHostileArea = true; else if (sWorld->IsPvPRealm() || (area->Flags & AREA_FLAG_UNK3)) { @@ -7334,8 +7274,7 @@ void Player::CheckDuelDistance(time_t currTime) bool Player::IsOutdoorPvPActive() const { - return IsAlive() && !HasInvisibilityAura() && !HasStealthAura() && IsPvP() && !HasUnitMovementFlag(MOVEMENTFLAG_FLYING) && - !IsInFlight(); + return IsAlive() && !HasInvisibilityAura() && !HasStealthAura() && IsPvP() && !HasUnitMovementFlag(MOVEMENTFLAG_FLYING) && !IsInFlight(); } void Player::DuelComplete(DuelCompleteType type) @@ -7351,8 +7290,8 @@ void Player::DuelComplete(DuelCompleteType type) duel->isCompleted = true; duel->opponent->duel->isCompleted = true; - LOG_DEBUG("entities.unit", "Player::DuelComplete: Player '%s' (%s), Opponent: '%s' (%s)", GetName().c_str(), - GetGUID().ToString().c_str(), duel->opponent->GetName().c_str(), duel->opponent->GetGUID().ToString().c_str()); + LOG_DEBUG("entities.unit", "Player::DuelComplete: Player '%s' (%s), Opponent: '%s' (%s)", GetName().c_str(), GetGUID().ToString().c_str(), duel->opponent->GetName().c_str(), + duel->opponent->GetGUID().ToString().c_str()); WorldPacket data(SMSG_DUEL_COMPLETE, (1)); data << (uint8)((type != DUEL_INTERRUPTED) ? 1 : 0); @@ -7431,8 +7370,7 @@ void Player::DuelComplete(DuelCompleteType type) for (AuraApplicationMap::iterator i = myAuras.begin(); i != myAuras.end();) { Aura const* aura = i->second->GetBase(); - if (!i->second->IsPositive() && aura->GetCasterGUID() == duel->opponent->GetGUID() && - aura->GetApplyTime() >= duel->startTime) + if (!i->second->IsPositive() && aura->GetCasterGUID() == duel->opponent->GetGUID() && aura->GetApplyTime() >= duel->startTime) RemoveAura(i); else ++i; @@ -7479,8 +7417,7 @@ void Player::_ApplyItemMods(Item* item, uint8 slot, bool apply, bool updateItemA LOG_DEBUG("entities.player.items", "Player::_ApplyItemMods: Applying mods for item %s", item->GetGUID().ToString().c_str()); - if (proto->GetSocketColor( - 0)) // only (un)equipping of items with sockets can influence metagems, so no need to waste time with normal items + if (proto->GetSocketColor(0)) // only (un)equipping of items with sockets can influence metagems, so no need to waste time with normal items CorrectMetaGemEnchants(slot, apply); _ApplyItemBonuses(proto, slot, apply); @@ -7504,9 +7441,7 @@ void Player::_ApplyItemBonuses(ItemTemplate const* proto, uint8 slot, bool apply if (slot >= INVENTORY_SLOT_BAG_END || !proto) return; - ScalingStatDistributionEntry const* ssd = proto->GetScalingStatDistribution() - ? sScalingStatDistributionStore.LookupEntry(proto->GetScalingStatDistribution()) - : nullptr; + ScalingStatDistributionEntry const* ssd = proto->GetScalingStatDistribution() ? sScalingStatDistributionStore.LookupEntry(proto->GetScalingStatDistribution()) : nullptr; if (only_level_scale && !ssd) return; @@ -7732,9 +7667,7 @@ void Player::_ApplyItemBonuses(ItemTemplate const* proto, uint8 slot, bool apply WeaponAttackType attType = BASE_ATTACK; - if (slot == EQUIPMENT_SLOT_RANGED && - (proto->GetInventoryType() == INVTYPE_RANGED || proto->GetInventoryType() == INVTYPE_THROWN || - proto->GetInventoryType() == INVTYPE_RANGEDRIGHT)) + if (slot == EQUIPMENT_SLOT_RANGED && (proto->GetInventoryType() == INVTYPE_RANGED || proto->GetInventoryType() == INVTYPE_THROWN || proto->GetInventoryType() == INVTYPE_RANGEDRIGHT)) { attType = RANGED_ATTACK; } @@ -7752,9 +7685,7 @@ void Player::_ApplyWeaponDamage(uint8 slot, ItemTemplate const* proto, ScalingSt WeaponAttackType attType = BASE_ATTACK; float damage = 0.0f; - if (slot == EQUIPMENT_SLOT_RANGED && - (proto->GetInventoryType() == INVTYPE_RANGED || proto->GetInventoryType() == INVTYPE_THROWN || - proto->GetInventoryType() == INVTYPE_RANGEDRIGHT)) + if (slot == EQUIPMENT_SLOT_RANGED && (proto->GetInventoryType() == INVTYPE_RANGED || proto->GetInventoryType() == INVTYPE_THROWN || proto->GetInventoryType() == INVTYPE_RANGEDRIGHT)) { attType = RANGED_ATTACK; } @@ -7771,8 +7702,7 @@ void Player::_ApplyWeaponDamage(uint8 slot, ItemTemplate const* proto, ScalingSt if (ssv) { float damageMultiplier = 0.0f; - extraDPS = ssv->GetDPSAndDamageMultiplier( - proto->GetSubClass(), (proto->GetFlags2() & ITEM_FLAG2_CASTER_WEAPON) != 0, &damageMultiplier); + extraDPS = ssv->GetDPSAndDamageMultiplier(proto->GetSubClass(), (proto->GetFlags2() & ITEM_FLAG2_CASTER_WEAPON) != 0, &damageMultiplier); if (extraDPS) { float average = extraDPS * proto->GetDelay() / 1000.0f; @@ -7870,8 +7800,7 @@ void Player::UpdateWeaponDependentCritAuras(WeaponAttackType attackType) } float amount = 0.0f; - amount += GetTotalAuraModifier(SPELL_AURA_MOD_WEAPON_CRIT_PERCENT, - std::bind(&Unit::CheckAttackFitToAuraRequirement, this, attackType, std::placeholders::_1)); + amount += GetTotalAuraModifier(SPELL_AURA_MOD_WEAPON_CRIT_PERCENT, std::bind(&Unit::CheckAttackFitToAuraRequirement, this, attackType, std::placeholders::_1)); // these auras don't have item requirement (only Combat Expertise in 3.3.5a) amount += GetTotalAuraModifier(SPELL_AURA_MOD_CRIT_PCT); @@ -7971,8 +7900,8 @@ void Player::ApplyEquipSpell(SpellInfo const* spellInfo, Item* item, bool apply, return; } - LOG_DEBUG("entities.player", "Player::ApplyEquipSpell: Player '%s' (%s) cast %s equip spell (ID: %i)", GetName().c_str(), - GetGUID().ToString().c_str(), (item ? "item" : "itemset"), spellInfo->Id); + LOG_DEBUG( + "entities.player", "Player::ApplyEquipSpell: Player '%s' (%s) cast %s equip spell (ID: %i)", GetName().c_str(), GetGUID().ToString().c_str(), (item ? "item" : "itemset"), spellInfo->Id); CastSpell(this, spellInfo->Id, item); } @@ -8102,9 +8031,7 @@ void Player::CastItemCombatSpell(DamageInfo const& damageInfo, Item* item, ItemT SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(effect.SpellID); if (!spellInfo) { - LOG_ERROR("entities.player.items", - "Player::CastItemCombatSpell: Player '%s' (%s) cast unknown item spell (ID: %i)", GetName().c_str(), - GetGUID().ToString().c_str(), effect.SpellID); + LOG_ERROR("entities.player.items", "Player::CastItemCombatSpell: Player '%s' (%s) cast unknown item spell (ID: %i)", GetName().c_str(), GetGUID().ToString().c_str(), effect.SpellID); continue; } @@ -8165,9 +8092,8 @@ void Player::CastItemCombatSpell(DamageInfo const& damageInfo, Item* item, ItemT SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(pEnchant->EffectArg[s]); if (!spellInfo) { - LOG_ERROR("entities.player.items", - "Player::CastItemCombatSpell: Player '%s' (%s) cast unknown spell (EnchantID: %u, SpellID: %i), ignoring", - GetName().c_str(), GetGUID().ToString().c_str(), pEnchant->ID, pEnchant->EffectArg[s]); + LOG_ERROR("entities.player.items", "Player::CastItemCombatSpell: Player '%s' (%s) cast unknown spell (EnchantID: %u, SpellID: %i), ignoring", GetName().c_str(), + GetGUID().ToString().c_str(), pEnchant->ID, pEnchant->EffectArg[s]); continue; } @@ -8203,8 +8129,7 @@ void Player::CastItemCombatSpell(DamageInfo const& damageInfo, Item* item, ItemT for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) { if (spellInfo->Effects[i].IsEffect()) - args.AddSpellMod(static_cast(SPELLVALUE_BASE_POINT0 + i), - CalculatePct(spellInfo->Effects[i].CalcValue(this), effectPct)); + args.AddSpellMod(static_cast(SPELLVALUE_BASE_POINT0 + i), CalculatePct(spellInfo->Effects[i].CalcValue(this), effectPct)); } } @@ -8226,8 +8151,7 @@ void Player::CastItemUseSpell(Item* item, SpellCastTargets const& targets, uint8 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(learn_spell_id); if (!spellInfo) { - LOG_ERROR("entities.player", "Player::CastItemUseSpell: Item (Entry: %u) has wrong spell id %u, ignoring.", - proto->GetId(), learn_spell_id); + LOG_ERROR("entities.player", "Player::CastItemUseSpell: Item (Entry: %u) has wrong spell id %u, ignoring.", proto->GetId(), learn_spell_id); SendEquipError(EQUIP_ERR_INTERNAL_BAG_ERROR, item, nullptr); return; } @@ -8253,8 +8177,7 @@ void Player::CastItemUseSpell(Item* item, SpellCastTargets const& targets, uint8 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(effect.SpellID); if (!spellInfo) { - LOG_ERROR("entities.player", "Player::CastItemUseSpell: Item (Entry: %u) has wrong spell id %u, ignoring", - proto->GetId(), effect.SpellID); + LOG_ERROR("entities.player", "Player::CastItemUseSpell: Item (Entry: %u) has wrong spell id %u, ignoring", proto->GetId(), effect.SpellID); continue; } @@ -8284,8 +8207,7 @@ void Player::CastItemUseSpell(Item* item, SpellCastTargets const& targets, uint8 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(pEnchant->EffectArg[s]); if (!spellInfo) { - LOG_ERROR("entities.player", "Player::CastItemUseSpell: Enchant %i, cast unknown spell %i", pEnchant->ID, - pEnchant->EffectArg[s]); + LOG_ERROR("entities.player", "Player::CastItemUseSpell: Enchant %i, cast unknown spell %i", pEnchant->ID, pEnchant->EffectArg[s]); continue; } @@ -8455,8 +8377,7 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type) Loot* loot; PermissionTypes permission = ALL_PERMISSION; - LOG_DEBUG("loot", "Player::SendLoot: Player: '%s' (%s), Loot: %s", GetName().c_str(), GetGUID().ToString().c_str(), - guid.ToString().c_str()); + LOG_DEBUG("loot", "Player::SendLoot: Player: '%s' (%s), Loot: %s", GetName().c_str(), GetGUID().ToString().c_str(), guid.ToString().c_str()); if (guid.IsGameObject()) { GameObject* go = GetMap()->GetGameObject(guid); @@ -8475,9 +8396,7 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type) } else { - if (lootType != LOOT_FISHINGHOLE && - ((lootType != LOOT_FISHING && lootType != LOOT_FISHING_JUNK) || go->GetOwnerGUID() != GetGUID()) && - !go->IsWithinDistInMap(this)) + if (lootType != LOOT_FISHINGHOLE && ((lootType != LOOT_FISHING && lootType != LOOT_FISHING_JUNK) || go->GetOwnerGUID() != GetGUID()) && !go->IsWithinDistInMap(this)) return true; if (lootType == LOOT_CORPSE && go->GetRespawnTime() && go->isSpawnedByDefault()) @@ -8499,8 +8418,8 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type) // to avoid bugs, this rule covers spawned gameobjects only // Don't allow to regenerate chest loot inside instances and raids, to avoid exploits with duplicate boss loot being given // for some encounters - if (go->isSpawnedByDefault() && go->getLootState() == GO_ACTIVATED && !go->loot.isLooted() && - !go->GetMap()->Instanceable() && go->GetLootGenerationTime() + go->GetRespawnDelay() < GameTime::GetGameTime()) + if (go->isSpawnedByDefault() && go->getLootState() == GO_ACTIVATED && !go->loot.isLooted() && !go->GetMap()->Instanceable() && + go->GetLootGenerationTime() + go->GetRespawnDelay() < GameTime::GetGameTime()) go->SetLootState(GO_READY); if (go->getLootState() == GO_READY) @@ -8518,8 +8437,7 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type) loot->clear(); Group* group = GetGroup(); - bool groupRules = - (group && go->GetGOInfo()->type == GAMEOBJECT_TYPE_CHEST && go->GetGOInfo()->chest.groupLootRules); + bool groupRules = (group && go->GetGOInfo()->type == GAMEOBJECT_TYPE_CHEST && go->GetGOInfo()->chest.groupLootRules); // check current RR player and get next if necessary if (groupRules) @@ -8671,8 +8589,7 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type) // It may need a better formula // Now it works like this: lvl10: ~6copper, lvl70: ~9silver - bones->loot.gold = - uint32(urand(50, 150) * 0.016f * std::pow(float(pLevel) / 5.76f, 2.5f) * sWorld->getRate(RATE_DROP_MONEY)); + bones->loot.gold = uint32(urand(50, 150) * 0.016f * std::pow(float(pLevel) / 5.76f, 2.5f) * sWorld->getRate(RATE_DROP_MONEY)); } if (bones->lootRecipient != this) @@ -8685,8 +8602,7 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type) Creature* creature = GetMap()->GetCreature(guid); // must be in range and creature must be alive for pickpocket and must be dead for another loot - if (!creature || creature->IsAlive() != (loot_type == LOOT_PICKPOCKETING) || - !creature->IsWithinDistInMap(this, INTERACTION_DISTANCE)) + if (!creature || creature->IsAlive() != (loot_type == LOOT_PICKPOCKETING) || !creature->IsWithinDistInMap(this, INTERACTION_DISTANCE)) { SendLootRelease(guid); return; @@ -8865,7 +8781,10 @@ void Player::SendLootError(ObjectGuid guid, LootError error) const SendDirectMessage(lootResponse.Write()); } -void Player::SendNotifyLootMoneyRemoved() const { SendDirectMessage(WorldPackets::Loot::CoinRemoved().Write()); } +void Player::SendNotifyLootMoneyRemoved() const +{ + SendDirectMessage(WorldPackets::Loot::CoinRemoved().Write()); +} void Player::SendNotifyLootItemRemoved(uint8 lootSlot) const { @@ -8913,12 +8832,9 @@ void Player::SendInitWorldStates(uint32 zoneId, uint32 areaId) packet.Worldstates.emplace_back(2260, 0); // 5 packet.Worldstates.emplace_back(2259, 0); // 6 - packet.Worldstates.emplace_back( - 3191, int32(sWorld->getBoolConfig(CONFIG_ARENA_SEASON_IN_PROGRESS) ? sWorld->getIntConfig(CONFIG_ARENA_SEASON_ID) - : 0)); // 7 Current Season - Arena season in progress - // 0 - End of season - packet.Worldstates.emplace_back(3901, int32(sWorld->getIntConfig(CONFIG_ARENA_SEASON_ID) - - sWorld->getBoolConfig(CONFIG_ARENA_SEASON_IN_PROGRESS))); // 8 PreviousSeason + packet.Worldstates.emplace_back(3191, int32(sWorld->getBoolConfig(CONFIG_ARENA_SEASON_IN_PROGRESS) ? sWorld->getIntConfig(CONFIG_ARENA_SEASON_ID) : 0)); // 7 Current Season - Arena season in + // progress 0 - End of season + packet.Worldstates.emplace_back(3901, int32(sWorld->getIntConfig(CONFIG_ARENA_SEASON_ID) - sWorld->getBoolConfig(CONFIG_ARENA_SEASON_IN_PROGRESS))); // 8 PreviousSeason if (mapid == 530) // Outland { @@ -9100,38 +9016,35 @@ void Player::SendInitWorldStates(uint32 zoneId, uint32 areaId) bg->FillInitialWorldStates(packet); else { - packet.Worldstates.emplace_back(0xac1, 0x0); // 7 2753 Horde Bases - packet.Worldstates.emplace_back(0xac0, 0x0); // 8 2752 Alliance Bases - packet.Worldstates.emplace_back(0xab6, 0x0); // 9 2742 Mage Tower - Horde conflict - packet.Worldstates.emplace_back(0xab5, 0x0); // 10 2741 Mage Tower - Alliance conflict - packet.Worldstates.emplace_back(0xab4, 0x0); // 11 2740 Fel Reaver - Horde conflict - packet.Worldstates.emplace_back(0xab3, 0x0); // 12 2739 Fel Reaver - Alliance conflict - packet.Worldstates.emplace_back(0xab2, 0x0); // 13 2738 Draenei - Alliance conflict - packet.Worldstates.emplace_back(0xab1, 0x0); // 14 2737 Draenei - Horde conflict - packet.Worldstates.emplace_back(0xab0, 0x0); // 15 2736 unk // 0 at start - packet.Worldstates.emplace_back(0xaaf, 0x0); // 16 2735 unk // 0 at start - packet.Worldstates.emplace_back(0xaad, 0x0); // 17 2733 Draenei - Horde control - packet.Worldstates.emplace_back(0xaac, 0x0); // 18 2732 Draenei - Alliance control - packet.Worldstates.emplace_back(0xaab, 0x1); // 19 2731 Draenei uncontrolled (1 - yes, 0 - no) - packet.Worldstates.emplace_back(0xaaa, 0x0); // 20 2730 Mage Tower - Alliance control - packet.Worldstates.emplace_back(0xaa9, 0x0); // 21 2729 Mage Tower - Horde control - packet.Worldstates.emplace_back(0xaa8, 0x1); // 22 2728 Mage Tower uncontrolled (1 - yes, 0 - no) - packet.Worldstates.emplace_back(0xaa7, 0x0); // 23 2727 Fel Reaver - Horde control - packet.Worldstates.emplace_back(0xaa6, 0x0); // 24 2726 Fel Reaver - Alliance control - packet.Worldstates.emplace_back(0xaa5, 0x1); // 25 2725 Fel Reaver uncontrolled (1 - yes, 0 - no) - packet.Worldstates.emplace_back(0xaa4, 0x0); // 26 2724 Boold Elf - Horde control - packet.Worldstates.emplace_back(0xaa3, 0x0); // 27 2723 Boold Elf - Alliance control - packet.Worldstates.emplace_back(0xaa2, 0x1); // 28 2722 Boold Elf uncontrolled (1 - yes, 0 - no) - packet.Worldstates.emplace_back(0xac5, 0x1); // 29 2757 Flag (1 - show, 0 - hide) - doesn't work exactly this way! - packet.Worldstates.emplace_back( - 0xad2, 0x1); // 30 2770 Horde top-stats (1 - show, 0 - hide) // 02 -> horde picked up the flag - packet.Worldstates.emplace_back( - 0xad1, 0x1); // 31 2769 Alliance top-stats (1 - show, 0 - hide) // 02 -> alliance picked up the flag - packet.Worldstates.emplace_back(0xabe, 0x0); // 32 2750 Horde resources - packet.Worldstates.emplace_back(0xabd, 0x0); // 33 2749 Alliance resources - packet.Worldstates.emplace_back(0xa05, 0x8e); // 34 2565 unk, constant? - packet.Worldstates.emplace_back( - 0xaa0, 0x0); // 35 2720 Capturing progress-bar (100 -> empty (only grey), 0 -> blue|red (no grey), default 0) + packet.Worldstates.emplace_back(0xac1, 0x0); // 7 2753 Horde Bases + packet.Worldstates.emplace_back(0xac0, 0x0); // 8 2752 Alliance Bases + packet.Worldstates.emplace_back(0xab6, 0x0); // 9 2742 Mage Tower - Horde conflict + packet.Worldstates.emplace_back(0xab5, 0x0); // 10 2741 Mage Tower - Alliance conflict + packet.Worldstates.emplace_back(0xab4, 0x0); // 11 2740 Fel Reaver - Horde conflict + packet.Worldstates.emplace_back(0xab3, 0x0); // 12 2739 Fel Reaver - Alliance conflict + packet.Worldstates.emplace_back(0xab2, 0x0); // 13 2738 Draenei - Alliance conflict + packet.Worldstates.emplace_back(0xab1, 0x0); // 14 2737 Draenei - Horde conflict + packet.Worldstates.emplace_back(0xab0, 0x0); // 15 2736 unk // 0 at start + packet.Worldstates.emplace_back(0xaaf, 0x0); // 16 2735 unk // 0 at start + packet.Worldstates.emplace_back(0xaad, 0x0); // 17 2733 Draenei - Horde control + packet.Worldstates.emplace_back(0xaac, 0x0); // 18 2732 Draenei - Alliance control + packet.Worldstates.emplace_back(0xaab, 0x1); // 19 2731 Draenei uncontrolled (1 - yes, 0 - no) + packet.Worldstates.emplace_back(0xaaa, 0x0); // 20 2730 Mage Tower - Alliance control + packet.Worldstates.emplace_back(0xaa9, 0x0); // 21 2729 Mage Tower - Horde control + packet.Worldstates.emplace_back(0xaa8, 0x1); // 22 2728 Mage Tower uncontrolled (1 - yes, 0 - no) + packet.Worldstates.emplace_back(0xaa7, 0x0); // 23 2727 Fel Reaver - Horde control + packet.Worldstates.emplace_back(0xaa6, 0x0); // 24 2726 Fel Reaver - Alliance control + packet.Worldstates.emplace_back(0xaa5, 0x1); // 25 2725 Fel Reaver uncontrolled (1 - yes, 0 - no) + packet.Worldstates.emplace_back(0xaa4, 0x0); // 26 2724 Boold Elf - Horde control + packet.Worldstates.emplace_back(0xaa3, 0x0); // 27 2723 Boold Elf - Alliance control + packet.Worldstates.emplace_back(0xaa2, 0x1); // 28 2722 Boold Elf uncontrolled (1 - yes, 0 - no) + packet.Worldstates.emplace_back(0xac5, 0x1); // 29 2757 Flag (1 - show, 0 - hide) - doesn't work exactly this way! + packet.Worldstates.emplace_back(0xad2, 0x1); // 30 2770 Horde top-stats (1 - show, 0 - hide) // 02 -> horde picked up the flag + packet.Worldstates.emplace_back(0xad1, 0x1); // 31 2769 Alliance top-stats (1 - show, 0 - hide) // 02 -> alliance picked up the flag + packet.Worldstates.emplace_back(0xabe, 0x0); // 32 2750 Horde resources + packet.Worldstates.emplace_back(0xabd, 0x0); // 33 2749 Alliance resources + packet.Worldstates.emplace_back(0xa05, 0x8e); // 34 2565 unk, constant? + packet.Worldstates.emplace_back(0xaa0, 0x0); // 35 2720 Capturing progress-bar (100 -> empty (only grey), 0 -> blue|red (no grey), default 0) packet.Worldstates.emplace_back(0xa9f, 0x0); // 36 2719 Capturing progress-bar (0 - left, 100 - right) packet.Worldstates.emplace_back(0xa9e, 0x0); // 37 2718 Capturing progress-bar (1 - show, 0 - hide) packet.Worldstates.emplace_back(0xc0d, 0x17b); // 38 3085 unk @@ -9145,10 +9058,8 @@ void Player::SendInitWorldStates(uint32 zoneId, uint32 areaId) pvp->FillInitialWorldStates(packet); else { - packet.Worldstates.emplace_back( - 0x9ba, 0x1); // 10 // add ally tower main gui icon // maybe should be sent only on login? - packet.Worldstates.emplace_back( - 0x9b9, 0x1); // 11 // add horde tower main gui icon // maybe should be sent only on login? + packet.Worldstates.emplace_back(0x9ba, 0x1); // 10 // add ally tower main gui icon // maybe should be sent only on login? + packet.Worldstates.emplace_back(0x9b9, 0x1); // 11 // add horde tower main gui icon // maybe should be sent only on login? packet.Worldstates.emplace_back(0x9b5, 0x0); // 12 // show neutral broken hill icon // 2485 packet.Worldstates.emplace_back(0x9b4, 0x1); // 13 // show icon above broken hill // 2484 packet.Worldstates.emplace_back(0x9b3, 0x0); // 14 // show ally broken hill icon // 2483 @@ -9157,12 +9068,9 @@ void Player::SendInitWorldStates(uint32 zoneId, uint32 areaId) packet.Worldstates.emplace_back(0x9b0, 0x0); // 17 // show ally overlook icon // 2480 packet.Worldstates.emplace_back(0x9ae, 0x0); // 18 // horde pvp objectives captured // 2478 packet.Worldstates.emplace_back(0x9ac, 0x0); // 19 // ally pvp objectives captured // 2476 - packet.Worldstates.emplace_back( - 2475, 100); //: ally / horde slider grey area // show only in direct vicinity! - packet.Worldstates.emplace_back( - 2474, 50); //: ally / horde slider percentage, 100 for ally, 0 for horde // show only in direct vicinity! - packet.Worldstates.emplace_back( - 2473, 0); //: ally / horde slider display // show only in direct vicinity! + packet.Worldstates.emplace_back(2475, 100); //: ally / horde slider grey area // show only in direct vicinity! + packet.Worldstates.emplace_back(2474, 50); //: ally / horde slider percentage, 100 for ally, 0 for horde // show only in direct vicinity! + packet.Worldstates.emplace_back(2473, 0); //: ally / horde slider display // show only in direct vicinity! packet.Worldstates.emplace_back(0x9a8, 0x0); // 20 // show the neutral stadium icon // 2472 packet.Worldstates.emplace_back(0x9a7, 0x0); // 21 // show the ally stadium icon // 2471 packet.Worldstates.emplace_back(0x9a6, 0x1); // 22 // show the horde stadium icon // 2470 @@ -9602,8 +9510,8 @@ uint32 Player::GetXPRestBonus(uint32 xp) SetRestBonus(GetRestBonus() - rested_bonus); - LOG_DEBUG("entities.player", "Player::GetXPRestBonus: Player '%s' (%s) gain %u xp (+%u Rested Bonus). Rested points=%f", - GetGUID().ToString().c_str(), GetName().c_str(), xp + rested_bonus, rested_bonus, GetRestBonus()); + LOG_DEBUG("entities.player", "Player::GetXPRestBonus: Player '%s' (%s) gain %u xp (+%u Rested Bonus). Rested points=%f", GetGUID().ToString().c_str(), GetName().c_str(), xp + rested_bonus, + rested_bonus, GetRestBonus()); return rested_bonus; } @@ -9634,8 +9542,7 @@ void Player::ResetPetTalents() CharmInfo* charmInfo = pet->GetCharmInfo(); if (!charmInfo) { - LOG_ERROR("entities.player", "Object (GUID: %u TypeId: %u) is considered pet-like, but doesn't have charm info!", - pet->GetGUID().GetCounter(), pet->GetTypeId()); + LOG_ERROR("entities.player", "Object (GUID: %u TypeId: %u) is considered pet-like, but doesn't have charm info!", pet->GetGUID().GetCounter(), pet->GetTypeId()); return; } pet->resetTalents(); @@ -9771,8 +9678,7 @@ uint8 Player::FindEquipSlot(ItemTemplate const* proto, uint32 slot, bool swap) c { if (ItemTemplate const* mhWeaponProto = mhWeapon->GetTemplate()) { - if (mhWeaponProto->GetSubClass() == ITEM_SUBCLASS_WEAPON_POLEARM || - mhWeaponProto->GetSubClass() == ITEM_SUBCLASS_WEAPON_STAFF) + if (mhWeaponProto->GetSubClass() == ITEM_SUBCLASS_WEAPON_POLEARM || mhWeaponProto->GetSubClass() == ITEM_SUBCLASS_WEAPON_STAFF) { const_cast(this)->AutoUnequipOffhandIfNeed(true); break; @@ -9788,8 +9694,7 @@ uint8 Player::FindEquipSlot(ItemTemplate const* proto, uint32 slot, bool swap) c break; } } - if (CanDualWield() && CanTitanGrip() && proto->GetSubClass() != ITEM_SUBCLASS_WEAPON_POLEARM && - proto->GetSubClass() != ITEM_SUBCLASS_WEAPON_STAFF) + if (CanDualWield() && CanTitanGrip() && proto->GetSubClass() != ITEM_SUBCLASS_WEAPON_POLEARM && proto->GetSubClass() != ITEM_SUBCLASS_WEAPON_STAFF) slots[1] = EQUIPMENT_SLOT_OFFHAND; break; case INVTYPE_TABARD: @@ -9818,8 +9723,7 @@ uint8 Player::FindEquipSlot(ItemTemplate const* proto, uint32 slot, bool swap) c break; case INVTYPE_RELIC: { - if (playerClass == CLASS_PALADIN || playerClass == CLASS_DRUID || playerClass == CLASS_SHAMAN || - playerClass == CLASS_DEATH_KNIGHT) + if (playerClass == CLASS_PALADIN || playerClass == CLASS_DRUID || playerClass == CLASS_SHAMAN || playerClass == CLASS_DEATH_KNIGHT) slots[0] = EQUIPMENT_SLOT_RANGED; break; } @@ -10021,8 +9925,7 @@ Item* Player::GetUseableItemByPos(uint8 bag, uint8 slot) const Bag* Player::GetBagByPos(uint8 bag) const { - if ((bag >= INVENTORY_SLOT_BAG_START && bag < INVENTORY_SLOT_BAG_END) || - (bag >= BANK_SLOT_BAG_START && bag < BANK_SLOT_BAG_END)) + if ((bag >= INVENTORY_SLOT_BAG_START && bag < INVENTORY_SLOT_BAG_END) || (bag >= BANK_SLOT_BAG_START && bag < BANK_SLOT_BAG_END)) if (Item* item = GetItemByPos(INVENTORY_SLOT_BAG_0, bag)) return item->ToBag(); return nullptr; @@ -10345,8 +10248,7 @@ bool Player::HasGemWithLimitCategoryEquipped(uint32 limitCategory, uint32 count, return false; } -InventoryResult Player::CanTakeMoreSimilarItems( - uint32 entry, uint32 count, Item* pItem, uint32* no_space_count /*= nullptr*/, uint32* offendingItemId /*= nullptr*/) const +InventoryResult Player::CanTakeMoreSimilarItems(uint32 entry, uint32 count, Item* pItem, uint32* no_space_count /*= nullptr*/, uint32* offendingItemId /*= nullptr*/) const { ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(entry); if (!pProto) @@ -10407,8 +10309,7 @@ InventoryResult Player::CanTakeMoreSimilarItems(Item* pItem, uint32* itemLimitCa return CanTakeMoreSimilarItems(pItem->GetEntry(), pItem->GetCount(), pItem, nullptr, itemLimitCategory); } -InventoryResult Player::CanStoreNewItem( - uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 item, uint32 count, uint32* no_space_count /*= nullptr*/) const +InventoryResult Player::CanStoreNewItem(uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 item, uint32 count, uint32* no_space_count /*= nullptr*/) const { return CanStoreItem(bag, slot, dest, item, count, nullptr, false, no_space_count); } @@ -10449,8 +10350,7 @@ bool Player::HasItemTotemCategory(uint32 TotemCategory) const return false; } -InventoryResult Player::CanStoreItem_InSpecificSlot( - uint8 bag, uint8 slot, ItemPosCountVec& dest, ItemTemplate const* pProto, uint32& count, bool swap, Item* pSrcItem) const +InventoryResult Player::CanStoreItem_InSpecificSlot(uint8 bag, uint8 slot, ItemPosCountVec& dest, ItemTemplate const* pProto, uint32& count, bool swap, Item* pSrcItem) const { Item* pItem2 = GetItemByPos(bag, slot); @@ -10516,8 +10416,8 @@ InventoryResult Player::CanStoreItem_InSpecificSlot( return EQUIP_ERR_OK; } -InventoryResult Player::CanStoreItem_InBag(uint8 bag, ItemPosCountVec& dest, ItemTemplate const* pProto, uint32& count, - bool merge, bool non_specialized, Item* pSrcItem, uint8 skip_bag, uint8 skip_slot) const +InventoryResult Player::CanStoreItem_InBag( + uint8 bag, ItemPosCountVec& dest, ItemTemplate const* pProto, uint32& count, bool merge, bool non_specialized, Item* pSrcItem, uint8 skip_bag, uint8 skip_slot) const { // skip specific bag already processed in first called CanStoreItem_InBag if (bag == skip_bag) @@ -10586,8 +10486,8 @@ InventoryResult Player::CanStoreItem_InBag(uint8 bag, ItemPosCountVec& dest, Ite return EQUIP_ERR_OK; } -InventoryResult Player::CanStoreItem_InInventorySlots(uint8 slot_begin, uint8 slot_end, ItemPosCountVec& dest, - ItemTemplate const* pProto, uint32& count, bool merge, Item* pSrcItem, uint8 skip_bag, uint8 skip_slot) const +InventoryResult Player::CanStoreItem_InInventorySlots( + uint8 slot_begin, uint8 slot_end, ItemPosCountVec& dest, ItemTemplate const* pProto, uint32& count, bool merge, Item* pSrcItem, uint8 skip_bag, uint8 skip_slot) const { // this is never called for non-bag slots so we can do this if (pSrcItem && pSrcItem->IsNotEmptyBag()) @@ -10637,8 +10537,7 @@ InventoryResult Player::CanStoreItem_InInventorySlots(uint8 slot_begin, uint8 sl return EQUIP_ERR_OK; } -InventoryResult Player::CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 entry, uint32 count, Item* pItem, - bool swap, uint32* no_space_count) const +InventoryResult Player::CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 entry, uint32 count, Item* pItem, bool swap, uint32* no_space_count) const { LOG_DEBUG("entities.player.items", "Player::CanStoreItem: Bag: %u, Slot: %u, Item: %u, Count: %u", bag, slot, entry, count); @@ -10714,8 +10613,7 @@ InventoryResult Player::CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& des { if (bag == INVENTORY_SLOT_BAG_0) // inventory { - res = CanStoreItem_InInventorySlots( - INVENTORY_SLOT_ITEM_START, INVENTORY_SLOT_ITEM_END, dest, pProto, count, true, pItem, bag, slot); + res = CanStoreItem_InInventorySlots(INVENTORY_SLOT_ITEM_START, INVENTORY_SLOT_ITEM_END, dest, pProto, count, true, pItem, bag, slot); if (res != EQUIP_ERR_OK) { if (no_space_count) @@ -10762,8 +10660,7 @@ InventoryResult Player::CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& des // search free slot in bag for place to if (bag == INVENTORY_SLOT_BAG_0) // inventory { - res = CanStoreItem_InInventorySlots( - INVENTORY_SLOT_ITEM_START, INVENTORY_SLOT_ITEM_END, dest, pProto, count, false, pItem, bag, slot); + res = CanStoreItem_InInventorySlots(INVENTORY_SLOT_ITEM_START, INVENTORY_SLOT_ITEM_END, dest, pProto, count, false, pItem, bag, slot); if (res != EQUIP_ERR_OK) { if (no_space_count) @@ -10811,8 +10708,7 @@ InventoryResult Player::CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& des // search stack for merge to if (pProto->GetMaxStackSize() != 1) { - res = CanStoreItem_InInventorySlots( - INVENTORY_SLOT_ITEM_START, INVENTORY_SLOT_ITEM_END, dest, pProto, count, true, pItem, bag, slot); + res = CanStoreItem_InInventorySlots(INVENTORY_SLOT_ITEM_START, INVENTORY_SLOT_ITEM_END, dest, pProto, count, true, pItem, bag, slot); if (res != EQUIP_ERR_OK) { if (no_space_count) @@ -10895,8 +10791,7 @@ InventoryResult Player::CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& des // search free slot uint8 searchSlotStart = INVENTORY_SLOT_ITEM_START; // new bags can be directly equipped - if (!pItem && pProto->GetClass() == ITEM_CLASS_CONTAINER && pProto->GetSubClass() == ITEM_SUBCLASS_CONTAINER && - (pProto->GetBonding() == BIND_NONE || pProto->GetBonding() == BIND_ON_ACQUIRE)) + if (!pItem && pProto->GetClass() == ITEM_CLASS_CONTAINER && pProto->GetSubClass() == ITEM_SUBCLASS_CONTAINER && (pProto->GetBonding() == BIND_NONE || pProto->GetBonding() == BIND_ON_ACQUIRE)) searchSlotStart = INVENTORY_SLOT_BAG_START; res = CanStoreItem_InInventorySlots(searchSlotStart, INVENTORY_SLOT_ITEM_END, dest, pProto, count, false, pItem, bag, slot); @@ -10976,8 +10871,8 @@ InventoryResult Player::CanStoreItems(Item** items, int count, uint32* offending if (!item) continue; - LOG_DEBUG("entities.player.items", "Player::CanStoreItems: Player '%s' (%s), Index: %i ItemID: %u, Count: %u", - GetName().c_str(), GetGUID().ToString().c_str(), k + 1, item->GetEntry(), item->GetCount()); + LOG_DEBUG("entities.player.items", "Player::CanStoreItems: Player '%s' (%s), Index: %i ItemID: %u, Count: %u", GetName().c_str(), GetGUID().ToString().c_str(), k + 1, item->GetEntry(), + item->GetCount()); ItemTemplate const* pProto = item->GetTemplate(); // strange item @@ -11007,8 +10902,7 @@ InventoryResult Player::CanStoreItems(Item** items, int count, uint32* offending for (int t = INVENTORY_SLOT_ITEM_START; t < INVENTORY_SLOT_ITEM_END; ++t) { item2 = GetItemByPos(INVENTORY_SLOT_BAG_0, t); - if (item2 && item2->CanBeMergedPartlyWith(pProto) == EQUIP_ERR_OK && - inventoryCounts[t - INVENTORY_SLOT_ITEM_START] + item->GetCount() <= pProto->GetMaxStackSize()) + if (item2 && item2->CanBeMergedPartlyWith(pProto) == EQUIP_ERR_OK && inventoryCounts[t - INVENTORY_SLOT_ITEM_START] + item->GetCount() <= pProto->GetMaxStackSize()) { inventoryCounts[t - INVENTORY_SLOT_ITEM_START] += item->GetCount(); b_found = true; @@ -11027,8 +10921,7 @@ InventoryResult Player::CanStoreItems(Item** items, int count, uint32* offending for (uint32 j = 0; j < bag->GetBagSize(); j++) { item2 = GetItemByPos(t, j); - if (item2 && item2->CanBeMergedPartlyWith(pProto) == EQUIP_ERR_OK && - bagCounts[t - INVENTORY_SLOT_BAG_START][j] + item->GetCount() <= pProto->GetMaxStackSize()) + if (item2 && item2->CanBeMergedPartlyWith(pProto) == EQUIP_ERR_OK && bagCounts[t - INVENTORY_SLOT_BAG_START][j] + item->GetCount() <= pProto->GetMaxStackSize()) { bagCounts[t - INVENTORY_SLOT_BAG_START][j] += item->GetCount(); b_found = true; @@ -11054,9 +10947,7 @@ InventoryResult Player::CanStoreItems(Item** items, int count, uint32* offending pBagProto = bag->GetTemplate(); // not plain container check - if (pBagProto && - (pBagProto->GetClass() != ITEM_CLASS_CONTAINER || pBagProto->GetSubClass() != ITEM_SUBCLASS_CONTAINER) && - ItemCanGoIntoBag(pProto, pBagProto)) + if (pBagProto && (pBagProto->GetClass() != ITEM_CLASS_CONTAINER || pBagProto->GetSubClass() != ITEM_SUBCLASS_CONTAINER) && ItemCanGoIntoBag(pProto, pBagProto)) { for (uint32 j = 0; j < bag->GetBagSize(); j++) { @@ -11096,8 +10987,7 @@ InventoryResult Player::CanStoreItems(Item** items, int count, uint32* offending pBagProto = bag->GetTemplate(); // special bag already checked - if (pBagProto && - (pBagProto->GetClass() != ITEM_CLASS_CONTAINER || pBagProto->GetSubClass() != ITEM_SUBCLASS_CONTAINER)) + if (pBagProto && (pBagProto->GetClass() != ITEM_CLASS_CONTAINER || pBagProto->GetSubClass() != ITEM_SUBCLASS_CONTAINER)) continue; for (uint32 j = 0; j < bag->GetBagSize(); j++) @@ -11140,8 +11030,8 @@ InventoryResult Player::CanEquipItem(uint8 slot, uint16& dest, Item* pItem, bool dest = 0; if (pItem) { - LOG_DEBUG("entities.player.items", "Player::CanEquipItem: Player '%s' (%s), Slot: %u, Item: %u, Count: %u", - GetName().c_str(), GetGUID().ToString().c_str(), slot, pItem->GetEntry(), pItem->GetCount()); + LOG_DEBUG("entities.player.items", "Player::CanEquipItem: Player '%s' (%s), Slot: %u, Item: %u, Count: %u", GetName().c_str(), GetGUID().ToString().c_str(), slot, pItem->GetEntry(), + pItem->GetCount()); ItemTemplate const* pProto = pItem->GetTemplate(); if (pProto) { @@ -11181,18 +11071,14 @@ InventoryResult Player::CanEquipItem(uint8 slot, uint16& dest, Item* pItem, bool return EQUIP_ERR_NOT_DURING_ARENA_MATCH; } - if (IsInCombat() && (pProto->GetClass() == ITEM_CLASS_WEAPON || pProto->GetInventoryType() == INVTYPE_RELIC) && - m_weaponChangeTimer != 0) + if (IsInCombat() && (pProto->GetClass() == ITEM_CLASS_WEAPON || pProto->GetInventoryType() == INVTYPE_RELIC) && m_weaponChangeTimer != 0) return EQUIP_ERR_CLIENT_LOCKED_OUT; // maybe exist better err if (IsNonMeleeSpellCast(false)) return EQUIP_ERR_CLIENT_LOCKED_OUT; } - ScalingStatDistributionEntry const* ssd = - pProto->GetScalingStatDistribution() - ? sScalingStatDistributionStore.LookupEntry(pProto->GetScalingStatDistribution()) - : 0; + ScalingStatDistributionEntry const* ssd = pProto->GetScalingStatDistribution() ? sScalingStatDistributionStore.LookupEntry(pProto->GetScalingStatDistribution()) : 0; // check allowed level (extend range to upper values if MaxLevel more or equal max player level, this let GM set high // level with 1...max range items) if (ssd && ssd->Maxlevel < DEFAULT_MAX_LEVEL && ssd->Maxlevel < getLevel()) @@ -11250,8 +11136,7 @@ InventoryResult Player::CanEquipItem(uint8 slot, uint16& dest, Item* pItem, bool if (pBag != pItem) if (ItemTemplate const* pBagProto = pBag->GetTemplate()) if (pBagProto->GetClass() == pProto->GetClass() && (!swap || pBag->GetSlot() != eslot)) - return (pBagProto->GetSubClass() == ITEM_SUBCLASS_AMMO_POUCH) ? EQUIP_ERR_ONLY_ONE_AMMO - : EQUIP_ERR_ONLY_ONE_QUIVER; + return (pBagProto->GetSubClass() == ITEM_SUBCLASS_AMMO_POUCH) ? EQUIP_ERR_ONLY_ONE_AMMO : EQUIP_ERR_ONLY_ONE_QUIVER; uint32 type = pProto->GetInventoryType(); @@ -11291,10 +11176,8 @@ InventoryResult Player::CanEquipItem(uint8 slot, uint16& dest, Item* pItem, bool // offhand item must can be stored in inventory for offhand item and it also must be unequipped Item* offItem = GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND); ItemPosCountVec off_dest; - if (offItem && - (!not_loading || - CanUnequipItem(uint16(INVENTORY_SLOT_BAG_0) << 8 | EQUIPMENT_SLOT_OFFHAND, false) != EQUIP_ERR_OK || - CanStoreItem(NULL_BAG, NULL_SLOT, off_dest, offItem, false) != EQUIP_ERR_OK)) + if (offItem && (!not_loading || CanUnequipItem(uint16(INVENTORY_SLOT_BAG_0) << 8 | EQUIPMENT_SLOT_OFFHAND, false) != EQUIP_ERR_OK || + CanStoreItem(NULL_BAG, NULL_SLOT, off_dest, offItem, false) != EQUIP_ERR_OK)) return swap ? EQUIP_ERR_CANT_SWAP : EQUIP_ERR_INV_FULL; } } @@ -11318,8 +11201,8 @@ InventoryResult Player::CanUnequipItem(uint16 pos, bool swap) const if (!pItem) return EQUIP_ERR_OK; - LOG_DEBUG("entities.player.items", "Player::CanUnequipItem: Player '%s' (%s), Slot: %u, Item: %u, Count: %u", - GetName().c_str(), GetGUID().ToString().c_str(), pos, pItem->GetEntry(), pItem->GetCount()); + LOG_DEBUG( + "entities.player.items", "Player::CanUnequipItem: Player '%s' (%s), Slot: %u, Item: %u, Count: %u", GetName().c_str(), GetGUID().ToString().c_str(), pos, pItem->GetEntry(), pItem->GetCount()); ItemTemplate const* pProto = pItem->GetTemplate(); if (!pProto) @@ -11358,8 +11241,8 @@ InventoryResult Player::CanBankItem(uint8 bag, uint8 slot, ItemPosCountVec& dest uint32 count = pItem->GetCount(); - LOG_DEBUG("entities.player.items", "Player::CanBankItem: Player '%s' (%s), Bag: %u, Slot: %u, Item: %u, Count: %u", - GetName().c_str(), GetGUID().ToString().c_str(), bag, slot, pItem->GetEntry(), pItem->GetCount()); + LOG_DEBUG("entities.player.items", "Player::CanBankItem: Player '%s' (%s), Bag: %u, Slot: %u, Item: %u, Count: %u", GetName().c_str(), GetGUID().ToString().c_str(), bag, slot, pItem->GetEntry(), + pItem->GetCount()); ItemTemplate const* pProto = pItem->GetTemplate(); if (!pProto) return swap ? EQUIP_ERR_CANT_SWAP : EQUIP_ERR_ITEM_NOT_FOUND; @@ -11374,9 +11257,8 @@ InventoryResult Player::CanBankItem(uint8 bag, uint8 slot, ItemPosCountVec& dest // Currency Tokenizer are not supposed to be swapped out of their hidden bag if (pItem->IsCurrencyToken()) { - LOG_INFO("entities.player.cheat", - "Possible hacking attempt: Player %s (%s) tried to move token [%s entry: %u] out of the currency bag!", - GetName().c_str(), GetGUID().ToString().c_str(), pItem->GetGUID().ToString().c_str(), pProto->GetId()); + LOG_INFO("entities.player.cheat", "Possible hacking attempt: Player %s (%s) tried to move token [%s entry: %u] out of the currency bag!", GetName().c_str(), GetGUID().ToString().c_str(), + pItem->GetGUID().ToString().c_str(), pProto->GetId()); return EQUIP_ERR_CANT_SWAP; } @@ -11422,8 +11304,7 @@ InventoryResult Player::CanBankItem(uint8 bag, uint8 slot, ItemPosCountVec& dest { if (bag == INVENTORY_SLOT_BAG_0) { - res = CanStoreItem_InInventorySlots( - BANK_SLOT_ITEM_START, BANK_SLOT_ITEM_END, dest, pProto, count, true, pItem, bag, slot); + res = CanStoreItem_InInventorySlots(BANK_SLOT_ITEM_START, BANK_SLOT_ITEM_END, dest, pProto, count, true, pItem, bag, slot); if (res != EQUIP_ERR_OK) return res; @@ -11447,8 +11328,7 @@ InventoryResult Player::CanBankItem(uint8 bag, uint8 slot, ItemPosCountVec& dest // search free slot in bag if (bag == INVENTORY_SLOT_BAG_0) { - res = CanStoreItem_InInventorySlots( - BANK_SLOT_ITEM_START, BANK_SLOT_ITEM_END, dest, pProto, count, false, pItem, bag, slot); + res = CanStoreItem_InInventorySlots(BANK_SLOT_ITEM_START, BANK_SLOT_ITEM_END, dest, pProto, count, false, pItem, bag, slot); if (res != EQUIP_ERR_OK) return res; @@ -11475,8 +11355,7 @@ InventoryResult Player::CanBankItem(uint8 bag, uint8 slot, ItemPosCountVec& dest if (pProto->GetMaxStackSize() != 1) { // in slots - res = - CanStoreItem_InInventorySlots(BANK_SLOT_ITEM_START, BANK_SLOT_ITEM_END, dest, pProto, count, true, pItem, bag, slot); + res = CanStoreItem_InInventorySlots(BANK_SLOT_ITEM_START, BANK_SLOT_ITEM_END, dest, pProto, count, true, pItem, bag, slot); if (res != EQUIP_ERR_OK) return res; @@ -11546,8 +11425,7 @@ InventoryResult Player::CanUseItem(Item* pItem, bool not_loading) const { if (pItem) { - LOG_DEBUG("entities.player.items", "Player::CanUseItem: Player '%s' (%s), Item: %u", GetName().c_str(), - GetGUID().ToString().c_str(), pItem->GetEntry()); + LOG_DEBUG("entities.player.items", "Player::CanUseItem: Player '%s' (%s), Item: %u", GetName().c_str(), GetGUID().ToString().c_str(), pItem->GetEntry()); if (!IsAlive() && not_loading) return EQUIP_ERR_PLAYER_DEAD; @@ -11570,8 +11448,7 @@ InventoryResult Player::CanUseItem(Item* pItem, bool not_loading) const bool allowEquip = false; uint32 itemSkill = pItem->GetSkill(); // Armor that is binded to account can "morph" from plate to mail, etc. if skill is not learned yet. - if (pProto->GetQuality() == ITEM_QUALITY_HEIRLOOM && pProto->GetClass() == ITEM_CLASS_ARMOR && - !HasSkill(itemSkill)) + if (pProto->GetQuality() == ITEM_QUALITY_HEIRLOOM && pProto->GetClass() == ITEM_CLASS_ARMOR && !HasSkill(itemSkill)) { /// @todo when you right-click already equipped item it throws EQUIP_ERR_PROFICIENCY_NEEDED. // In fact it's a visual bug, everything works properly... I need sniffs of operations with @@ -11593,8 +11470,7 @@ InventoryResult Player::CanUseItem(Item* pItem, bool not_loading) const return EQUIP_ERR_PROFICIENCY_NEEDED; } - if (pProto->GetRequiredReputationFaction() && - uint32(GetReputationRank(pProto->GetRequiredReputationFaction())) < pProto->GetRequiredReputationRank()) + if (pProto->GetRequiredReputationFaction() && uint32(GetReputationRank(pProto->GetRequiredReputationFaction())) < pProto->GetRequiredReputationRank()) return EQUIP_ERR_CANT_EQUIP_REPUTATION; return EQUIP_ERR_OK; @@ -11610,8 +11486,7 @@ InventoryResult Player::CanUseItem(ItemTemplate const* proto) const if (!proto) return EQUIP_ERR_ITEM_NOT_FOUND; - if (((proto->GetFlags2() & ITEM_FLAG2_FACTION_HORDE) && GetTeam() != HORDE) || - (((proto->GetFlags2() & ITEM_FLAG2_FACTION_ALLIANCE) && GetTeam() != ALLIANCE))) + if (((proto->GetFlags2() & ITEM_FLAG2_FACTION_HORDE) && GetTeam() != HORDE) || (((proto->GetFlags2() & ITEM_FLAG2_FACTION_ALLIANCE) && GetTeam() != ALLIANCE))) return EQUIP_ERR_CANT_EQUIP_EVER; if ((proto->GetAllowableClass() & getClassMask()) == 0 || (proto->GetAllowableRace() & getRaceMask()) == 0) @@ -11657,10 +11532,8 @@ InventoryResult Player::CanRollForItemInLFG(ItemTemplate const* proto, WorldObje return EQUIP_ERR_ITEM_NOT_FOUND; // Used by group, function NeedBeforeGreed, to know if a prototype can be used by a player - const static uint32 item_weapon_skills[MAX_ITEM_SUBCLASS_WEAPON] = {SKILL_AXES, SKILL_2H_AXES, SKILL_BOWS, SKILL_GUNS, - SKILL_MACES, SKILL_2H_MACES, SKILL_POLEARMS, SKILL_SWORDS, SKILL_2H_SWORDS, 0, SKILL_STAVES, 0, 0, SKILL_FIST_WEAPONS, 0, - SKILL_DAGGERS, SKILL_THROWN, SKILL_ASSASSINATION, SKILL_CROSSBOWS, SKILL_WANDS, - SKILL_FISHING}; // Copy from function Item::GetSkill() + const static uint32 item_weapon_skills[MAX_ITEM_SUBCLASS_WEAPON] = {SKILL_AXES, SKILL_2H_AXES, SKILL_BOWS, SKILL_GUNS, SKILL_MACES, SKILL_2H_MACES, SKILL_POLEARMS, SKILL_SWORDS, SKILL_2H_SWORDS, + 0, SKILL_STAVES, 0, 0, SKILL_FIST_WEAPONS, 0, SKILL_DAGGERS, SKILL_THROWN, SKILL_ASSASSINATION, SKILL_CROSSBOWS, SKILL_WANDS, SKILL_FISHING}; // Copy from function Item::GetSkill() if ((proto->GetAllowableClass() & getClassMask()) == 0 || (proto->GetAllowableRace() & getRaceMask()) == 0) return EQUIP_ERR_CANT_EQUIP_EVER; @@ -11681,8 +11554,8 @@ InventoryResult Player::CanRollForItemInLFG(ItemTemplate const* proto, WorldObje if (proto->GetClass() == ITEM_CLASS_WEAPON && GetSkillValue(item_weapon_skills[proto->GetSubClass()]) == 0) return EQUIP_ERR_PROFICIENCY_NEEDED; - if (proto->GetClass() == ITEM_CLASS_ARMOR && proto->GetSubClass() > ITEM_SUBCLASS_ARMOR_MISCELLANEOUS && - proto->GetSubClass() < ITEM_SUBCLASS_ARMOR_BUCKLER && proto->GetInventoryType() != INVTYPE_CLOAK) + if (proto->GetClass() == ITEM_CLASS_ARMOR && proto->GetSubClass() > ITEM_SUBCLASS_ARMOR_MISCELLANEOUS && proto->GetSubClass() < ITEM_SUBCLASS_ARMOR_BUCKLER && + proto->GetInventoryType() != INVTYPE_CLOAK) { if (_class == CLASS_WARRIOR || _class == CLASS_PALADIN || _class == CLASS_DEATH_KNIGHT) { @@ -11718,8 +11591,7 @@ InventoryResult Player::CanRollForItemInLFG(ItemTemplate const* proto, WorldObje } // Return stored item (if stored to stack, it can diff. from pItem). And pItem ca be deleted in this case. -Item* Player::StoreNewItem(ItemPosCountVec const& dest, uint32 item, bool update, - ItemRandomEnchantmentId const& randomPropertyId /*= {}*/, GuidSet const& allowedLooters) +Item* Player::StoreNewItem(ItemPosCountVec const& dest, uint32 item, bool update, ItemRandomEnchantmentId const& randomPropertyId /*= {}*/, GuidSet const& allowedLooters) { uint32 count = 0; for (ItemPosCountVec::const_iterator itr = dest.begin(); itr != dest.end(); ++itr) @@ -11789,9 +11661,8 @@ Item* Player::_StoreItem(uint16 pos, Item* pItem, uint32 count, bool clone, bool uint8 bag = pos >> 8; uint8 slot = pos & 255; - LOG_DEBUG("entities.player.items", "Player::_StoreItem: Player '%s' (%s), Bag: %u, Slot: %u, Item: %u (%s), Count: %u", - GetName().c_str(), GetGUID().ToString().c_str(), bag, slot, pItem->GetEntry(), pItem->GetGUID().ToString().c_str(), - count); + LOG_DEBUG("entities.player.items", "Player::_StoreItem: Player '%s' (%s), Bag: %u, Slot: %u, Item: %u (%s), Count: %u", GetName().c_str(), GetGUID().ToString().c_str(), bag, slot, + pItem->GetEntry(), pItem->GetGUID().ToString().c_str(), count); Item* pItem2 = GetItemByPos(bag, slot); @@ -11805,8 +11676,7 @@ Item* Player::_StoreItem(uint16 pos, Item* pItem, uint32 count, bool clone, bool if (!pItem) return nullptr; - if (pItem->GetTemplate()->GetBonding() == BIND_ON_ACQUIRE || pItem->GetTemplate()->GetBonding() == BIND_QUEST || - (pItem->GetTemplate()->GetBonding() == BIND_ON_EQUIP && IsBagPos(pos))) + if (pItem->GetTemplate()->GetBonding() == BIND_ON_ACQUIRE || pItem->GetTemplate()->GetBonding() == BIND_QUEST || (pItem->GetTemplate()->GetBonding() == BIND_ON_EQUIP && IsBagPos(pos))) pItem->SetBinding(true); Bag* pBag = (bag == INVENTORY_SLOT_BAG_0) ? nullptr : GetBagByPos(bag); @@ -11843,8 +11713,7 @@ Item* Player::_StoreItem(uint16 pos, Item* pItem, uint32 count, bool clone, bool } else { - if (pItem2->GetTemplate()->GetBonding() == BIND_ON_ACQUIRE || pItem2->GetTemplate()->GetBonding() == BIND_QUEST || - (pItem2->GetTemplate()->GetBonding() == BIND_ON_EQUIP && IsBagPos(pos))) + if (pItem2->GetTemplate()->GetBonding() == BIND_ON_ACQUIRE || pItem2->GetTemplate()->GetBonding() == BIND_QUEST || (pItem2->GetTemplate()->GetBonding() == BIND_ON_EQUIP && IsBagPos(pos))) pItem2->SetBinding(true); pItem2->SetCount(pItem2->GetCount() + count); @@ -11918,17 +11787,14 @@ Item* Player::EquipItem(uint16 pos, Item* pItem, bool update) _ApplyItemMods(pItem, slot, true); - if (pProto && IsInCombat() && - (pProto->GetClass() == ITEM_CLASS_WEAPON || pProto->GetInventoryType() == INVTYPE_RELIC) && - m_weaponChangeTimer == 0) + if (pProto && IsInCombat() && (pProto->GetClass() == ITEM_CLASS_WEAPON || pProto->GetInventoryType() == INVTYPE_RELIC) && m_weaponChangeTimer == 0) { uint32 cooldownSpell = getClass() == CLASS_ROGUE ? 6123 : 6119; SpellInfo const* spellProto = sSpellMgr->GetSpellInfo(cooldownSpell); if (!spellProto) - LOG_ERROR("entities.player", - "Player::EquipItem: Weapon switch cooldown spell %u for player '%s' (%s) couldn't be found in Spell.dbc", - cooldownSpell, GetName().c_str(), GetGUID().ToString().c_str()); + LOG_ERROR("entities.player", "Player::EquipItem: Weapon switch cooldown spell %u for player '%s' (%s) couldn't be found in Spell.dbc", cooldownSpell, GetName().c_str(), + GetGUID().ToString().c_str()); else { m_weaponChangeTimer = spellProto->StartRecoveryTime; @@ -12047,12 +11913,10 @@ void Player::VisualizeItem(uint8 slot, Item* pItem) return; // check also BIND_ON_ACQUIRE and BIND_QUEST for .additem or .additemset case by GM (not binded at adding to inventory) - if (pItem->GetTemplate()->GetBonding() == BIND_ON_EQUIP || pItem->GetTemplate()->GetBonding() == BIND_ON_ACQUIRE || - pItem->GetTemplate()->GetBonding() == BIND_QUEST) + if (pItem->GetTemplate()->GetBonding() == BIND_ON_EQUIP || pItem->GetTemplate()->GetBonding() == BIND_ON_ACQUIRE || pItem->GetTemplate()->GetBonding() == BIND_QUEST) pItem->SetBinding(true); - LOG_DEBUG("entities.player.items", "Player::SetVisibleItemSlot: Player '%s' (%s), Slot: %u, Item: %u", GetName().c_str(), - GetGUID().ToString().c_str(), slot, pItem->GetEntry()); + LOG_DEBUG("entities.player.items", "Player::SetVisibleItemSlot: Player '%s' (%s), Slot: %u, Item: %u", GetName().c_str(), GetGUID().ToString().c_str(), slot, pItem->GetEntry()); m_items[slot] = pItem; SetGuidValue(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), pItem->GetGUID()); @@ -12067,7 +11931,10 @@ void Player::VisualizeItem(uint8 slot, Item* pItem) pItem->SetState(ITEM_CHANGED, this); } -Item* Player::BankItem(ItemPosCountVec const& dest, Item* pItem, bool update) { return StoreItem(dest, pItem, update); } +Item* Player::BankItem(ItemPosCountVec const& dest, Item* pItem, bool update) +{ + return StoreItem(dest, pItem, update); +} void Player::RemoveItem(uint8 bag, uint8 slot, bool update) { @@ -12079,8 +11946,7 @@ void Player::RemoveItem(uint8 bag, uint8 slot, bool update) Item* pItem = GetItemByPos(bag, slot); if (pItem) { - LOG_DEBUG("entities.player.items", "Player::RemoveItem: Player '%s' (%s), Bag: %u, Slot: %u, Item: %u", GetName().c_str(), - GetGUID().ToString().c_str(), bag, slot, pItem->GetEntry()); + LOG_DEBUG("entities.player.items", "Player::RemoveItem: Player '%s' (%s), Bag: %u, Slot: %u, Item: %u", GetName().c_str(), GetGUID().ToString().c_str(), bag, slot, pItem->GetEntry()); RemoveEnchantmentDurations(pItem); RemoveItemDurations(pItem); @@ -12115,8 +11981,7 @@ void Player::RemoveItem(uint8 bag, uint8 slot, bool update) { // clear main hand only enchantments for (uint32 enchantSlot = 0; enchantSlot < MAX_ENCHANTMENT_SLOT; ++enchantSlot) - if (SpellItemEnchantmentEntry const* enchantment = - sSpellItemEnchantmentStore.LookupEntry(pItem->GetEnchantmentId(EnchantmentSlot(enchantSlot)))) + if (SpellItemEnchantmentEntry const* enchantment = sSpellItemEnchantmentStore.LookupEntry(pItem->GetEnchantmentId(EnchantmentSlot(enchantSlot)))) if (enchantment->GetFlags().HasFlag(SpellItemEnchantmentFlags::MainhandOnly)) pItem->ClearEnchantment(EnchantmentSlot(enchantSlot)); } @@ -12183,8 +12048,7 @@ void Player::DestroyItem(uint8 bag, uint8 slot, bool update) Item* pItem = GetItemByPos(bag, slot); if (pItem) { - LOG_DEBUG("entities.player.items", "Player::DestroyItem: Player '%s' (%s), Bag: %u, Slot: %u, Item: %u", - GetName().c_str(), GetGUID().ToString().c_str(), bag, slot, pItem->GetEntry()); + LOG_DEBUG("entities.player.items", "Player::DestroyItem: Player '%s' (%s), Bag: %u, Slot: %u, Item: %u", GetName().c_str(), GetGUID().ToString().c_str(), bag, slot, pItem->GetEntry()); // Also remove all contained items if the item is a bag. // This if () prevents item saving crashes if the condition for a bag to be empty before being destroyed was bypassed // somehow. @@ -12264,8 +12128,7 @@ void Player::DestroyItem(uint8 bag, uint8 slot, bool update) void Player::DestroyItemCount(uint32 itemEntry, uint32 count, bool update, bool unequip_check) { - LOG_DEBUG("entities.player.items", "Player::DestroyItemCount: Player '%s' (%s), Item: %u, Count: %u", GetName().c_str(), - GetGUID().ToString().c_str(), itemEntry, count); + LOG_DEBUG("entities.player.items", "Player::DestroyItemCount: Player '%s' (%s), Item: %u, Count: %u", GetName().c_str(), GetGUID().ToString().c_str(), itemEntry, count); uint32 remcount = 0; // in inventory @@ -12458,8 +12321,7 @@ void Player::DestroyItemCount(uint32 itemEntry, uint32 count, bool update, bool void Player::DestroyZoneLimitedItem(bool update, uint32 new_zone) { - LOG_DEBUG("entities.player.items", "Player::DestroyZoneLimitedItem: In map %u and area %u for player '%s' (%s)", GetMapId(), - new_zone, GetName().c_str(), GetGUID().ToString().c_str()); + LOG_DEBUG("entities.player.items", "Player::DestroyZoneLimitedItem: In map %u and area %u for player '%s' (%s)", GetMapId(), new_zone, GetName().c_str(), GetGUID().ToString().c_str()); // in inventory for (uint8 i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; i++) @@ -12486,8 +12348,7 @@ void Player::DestroyConjuredItems(bool update) { // used when entering arena // destroys all conjured items - LOG_DEBUG("entities.player.items", "Player::DestroyConjuredItems: Player '%s' (%s)", GetName().c_str(), - GetGUID().ToString().c_str()); + LOG_DEBUG("entities.player.items", "Player::DestroyConjuredItems: Player '%s' (%s)", GetName().c_str(), GetGUID().ToString().c_str()); // in inventory for (uint8 i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; i++) @@ -12538,8 +12399,8 @@ void Player::DestroyItemCount(Item* pItem, uint32& count, bool update) if (!pItem) return; - LOG_DEBUG("entities.player.items", "Player::DestroyItemCount: Player '%s' (%s), Item (%s, Entry: %u), Count: %u", - GetName().c_str(), GetGUID().ToString().c_str(), pItem->GetGUID().ToString().c_str(), pItem->GetEntry(), count); + LOG_DEBUG("entities.player.items", "Player::DestroyItemCount: Player '%s' (%s), Item (%s, Entry: %u), Count: %u", GetName().c_str(), GetGUID().ToString().c_str(), + pItem->GetGUID().ToString().c_str(), pItem->GetEntry(), count); if (pItem->GetCount() <= count) { @@ -12602,8 +12463,8 @@ void Player::SplitItem(uint16 src, uint16 dst, uint32 count) return; } - LOG_DEBUG("entities.player.items", "Player::SplitItem: Player '%s' (%s), Bag: %u, Slot: %u, Item: %u, Count: %u", - GetName().c_str(), GetGUID().ToString().c_str(), dstbag, dstslot, pSrcItem->GetEntry(), count); + LOG_DEBUG("entities.player.items", "Player::SplitItem: Player '%s' (%s), Bag: %u, Slot: %u, Item: %u, Count: %u", GetName().c_str(), GetGUID().ToString().c_str(), dstbag, dstslot, + pSrcItem->GetEntry(), count); Item* pNewItem = pSrcItem->CloneItem(count, this); if (!pNewItem) { @@ -12688,8 +12549,7 @@ void Player::SwapItem(uint16 src, uint16 dst) if (!pSrcItem) return; - LOG_DEBUG("entities.player.items", "Player::SwapItem: Player '%s' (%s), Bag: %u, Slot: %u, Item: %u", GetName().c_str(), - GetGUID().ToString().c_str(), dstbag, dstslot, pSrcItem->GetEntry()); + LOG_DEBUG("entities.player.items", "Player::SwapItem: Player '%s' (%s), Bag: %u, Slot: %u, Item: %u", GetName().c_str(), GetGUID().ToString().c_str(), dstbag, dstslot, pSrcItem->GetEntry()); if (!IsAlive()) { @@ -12703,8 +12563,7 @@ void Player::SwapItem(uint16 src, uint16 dst) if (IsEquipmentPos(src) || IsBagPos(src)) { // bags can be swapped with empty bag slots, or with empty bag (items move possibility checked later) - InventoryResult msg = CanUnequipItem( - src, !IsBagPos(src) || IsBagPos(dst) || (pDstItem && pDstItem->ToBag() && pDstItem->ToBag()->IsEmpty())); + InventoryResult msg = CanUnequipItem(src, !IsBagPos(src) || IsBagPos(dst) || (pDstItem && pDstItem->ToBag() && pDstItem->ToBag()->IsEmpty())); if (msg != EQUIP_ERR_OK) { SendEquipError(msg, pSrcItem, pDstItem); @@ -12734,8 +12593,7 @@ void Player::SwapItem(uint16 src, uint16 dst) if (IsEquipmentPos(dst) || IsBagPos(dst)) { // bags can be swapped with empty bag slots, or with empty bag (items move possibility checked later) - InventoryResult msg = - CanUnequipItem(dst, !IsBagPos(dst) || IsBagPos(src) || (pSrcItem->ToBag() && pSrcItem->ToBag()->IsEmpty())); + InventoryResult msg = CanUnequipItem(dst, !IsBagPos(dst) || IsBagPos(src) || (pSrcItem->ToBag() && pSrcItem->ToBag()->IsEmpty())); if (msg != EQUIP_ERR_OK) { SendEquipError(msg, pSrcItem, pDstItem); @@ -12979,8 +12837,7 @@ void Player::SwapItem(uint16 src, uint16 dst) // if inventory item was moved, check if we can remove dependent auras, because they were not removed in Player::RemoveItem // (update was set to false) do this after swaps are done, we pass nullptr because both weapons could be swapped and none of // them should be ignored - if ((srcbag == INVENTORY_SLOT_BAG_0 && srcslot < INVENTORY_SLOT_BAG_END) || - (dstbag == INVENTORY_SLOT_BAG_0 && dstslot < INVENTORY_SLOT_BAG_END)) + if ((srcbag == INVENTORY_SLOT_BAG_0 && srcslot < INVENTORY_SLOT_BAG_END) || (dstbag == INVENTORY_SLOT_BAG_0 && dstslot < INVENTORY_SLOT_BAG_END)) ApplyItemDependentAuras((Item*)nullptr, false); // if player is moving bags and is looting an item inside this bag @@ -13060,8 +12917,7 @@ void Player::AddItemToBuyBackSlot(Item* pItem) } RemoveItemFromBuyBackSlot(slot, true); - LOG_DEBUG("entities.player.items", "Player::AddItemToBuyBackSlot: Player '%s' (%s), Item: %u, Slot: %u", - GetName().c_str(), GetGUID().ToString().c_str(), pItem->GetEntry(), slot); + LOG_DEBUG("entities.player.items", "Player::AddItemToBuyBackSlot: Player '%s' (%s), Item: %u, Slot: %u", GetName().c_str(), GetGUID().ToString().c_str(), pItem->GetEntry(), slot); m_items[slot] = pItem; time_t base = GameTime::GetGameTime(); @@ -13083,8 +12939,7 @@ void Player::AddItemToBuyBackSlot(Item* pItem) Item* Player::GetItemFromBuyBackSlot(uint32 slot) { - LOG_DEBUG("entities.player.items", "Player::GetItemFromBuyBackSlot: Player '%s' (%s), Slot: %u", GetName().c_str(), - GetGUID().ToString().c_str(), slot); + LOG_DEBUG("entities.player.items", "Player::GetItemFromBuyBackSlot: Player '%s' (%s), Slot: %u", GetName().c_str(), GetGUID().ToString().c_str(), slot); if (slot >= BUYBACK_SLOT_START && slot < BUYBACK_SLOT_END) return m_items[slot]; return nullptr; @@ -13092,8 +12947,7 @@ Item* Player::GetItemFromBuyBackSlot(uint32 slot) void Player::RemoveItemFromBuyBackSlot(uint32 slot, bool del) { - LOG_DEBUG("entities.player.items", "Player::RemoveItemFromBuyBackSlot: Player '%s' (%s), Slot: %u", GetName().c_str(), - GetGUID().ToString().c_str(), slot); + LOG_DEBUG("entities.player.items", "Player::RemoveItemFromBuyBackSlot: Player '%s' (%s), Slot: %u", GetName().c_str(), GetGUID().ToString().c_str(), slot); if (slot >= BUYBACK_SLOT_START && slot < BUYBACK_SLOT_END) { Item* pItem = m_items[slot]; @@ -13132,8 +12986,7 @@ void Player::SendEquipError(InventoryResult msg, Item* pItem, Item* pItem2, uint { data << uint64(pItem ? pItem->GetGUID() : ObjectGuid::Empty); data << uint64(pItem2 ? pItem2->GetGUID() : ObjectGuid::Empty); - data << uint8( - 0); // bag type subclass, used with EQUIP_ERR_EVENT_AUTOEQUIP_BIND_CONFIRM and EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG2 + data << uint8(0); // bag type subclass, used with EQUIP_ERR_EVENT_AUTOEQUIP_BIND_CONFIRM and EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG2 switch (msg) { @@ -13269,17 +13122,22 @@ void Player::UpdateSoulboundTradeItems() } } -void Player::AddTradeableItem(Item* item) { m_itemSoulboundTradeable.insert(item->GetGUID()); } +void Player::AddTradeableItem(Item* item) +{ + m_itemSoulboundTradeable.insert(item->GetGUID()); +} -void Player::RemoveTradeableItem(Item* item) { m_itemSoulboundTradeable.erase(item->GetGUID()); } +void Player::RemoveTradeableItem(Item* item) +{ + m_itemSoulboundTradeable.erase(item->GetGUID()); +} void Player::UpdateItemDuration(uint32 time, bool realtimeonly) { if (m_itemDuration.empty()) return; - LOG_DEBUG("entities.player.items", "Player::UpdateItemDuration: Player '%s' (%s), Time: %u, RealTimeOnly: %u", - GetName().c_str(), GetGUID().ToString().c_str(), time, realtimeonly); + LOG_DEBUG("entities.player.items", "Player::UpdateItemDuration: Player '%s' (%s), Time: %u, RealTimeOnly: %u", GetName().c_str(), GetGUID().ToString().c_str(), time, realtimeonly); for (ItemDurationList::const_iterator itr = m_itemDuration.begin(); itr != m_itemDuration.end();) { @@ -13727,14 +13585,11 @@ void Player::ApplyEnchantment(Item* item, EnchantmentSlot slot, bool apply, bool // If we're dealing with a gem inside a prismatic socket we need to check the prismatic socket requirements // rather than the gem requirements itself. If the socket has no color it is a prismatic socket. - if ((slot == SOCK_ENCHANTMENT_SLOT || slot == SOCK_ENCHANTMENT_SLOT_2 || slot == SOCK_ENCHANTMENT_SLOT_3) && - !item->GetTemplate()->GetSocketColor(slot - SOCK_ENCHANTMENT_SLOT)) + if ((slot == SOCK_ENCHANTMENT_SLOT || slot == SOCK_ENCHANTMENT_SLOT_2 || slot == SOCK_ENCHANTMENT_SLOT_3) && !item->GetTemplate()->GetSocketColor(slot - SOCK_ENCHANTMENT_SLOT)) { // Check if the requirements for the prismatic socket are met before applying the gem stats - SpellItemEnchantmentEntry const* pPrismaticEnchant = - sSpellItemEnchantmentStore.LookupEntry(item->GetEnchantmentId(PRISMATIC_ENCHANTMENT_SLOT)); - if (!pPrismaticEnchant || (pPrismaticEnchant->RequiredSkillID > 0 && - pPrismaticEnchant->RequiredSkillRank > GetSkillValue(pPrismaticEnchant->RequiredSkillID))) + SpellItemEnchantmentEntry const* pPrismaticEnchant = sSpellItemEnchantmentStore.LookupEntry(item->GetEnchantmentId(PRISMATIC_ENCHANTMENT_SLOT)); + if (!pPrismaticEnchant || (pPrismaticEnchant->RequiredSkillID > 0 && pPrismaticEnchant->RequiredSkillRank > GetSkillValue(pPrismaticEnchant->RequiredSkillID))) return; } @@ -13769,8 +13624,7 @@ void Player::ApplyEnchantment(Item* item, EnchantmentSlot slot, bool apply, bool // Random Property Exist - try found basepoints for spell (basepoints depends from item suffix factor) if (item->GetItemRandomPropertyId() < 0) { - ItemRandomSuffixEntry const* item_rand = - sItemRandomSuffixStore.LookupEntry(abs(item->GetItemRandomPropertyId())); + ItemRandomSuffixEntry const* item_rand = sItemRandomSuffixStore.LookupEntry(abs(item->GetItemRandomPropertyId())); if (item_rand) { // Search enchant_amount @@ -13800,8 +13654,7 @@ void Player::ApplyEnchantment(Item* item, EnchantmentSlot slot, bool apply, bool case ITEM_ENCHANTMENT_TYPE_RESISTANCE: if (!enchant_amount) { - ItemRandomSuffixEntry const* item_rand = - sItemRandomSuffixStore.LookupEntry(abs(item->GetItemRandomPropertyId())); + ItemRandomSuffixEntry const* item_rand = sItemRandomSuffixStore.LookupEntry(abs(item->GetItemRandomPropertyId())); if (item_rand) { for (int k = 0; k < MAX_ITEM_ENCHANTMENT_EFFECTS; ++k) @@ -13815,23 +13668,20 @@ void Player::ApplyEnchantment(Item* item, EnchantmentSlot slot, bool apply, bool } } - HandleStatFlatModifier( - UnitMods(UNIT_MOD_RESISTANCE_START + enchant_spell_id), TOTAL_VALUE, float(enchant_amount), apply); + HandleStatFlatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + enchant_spell_id), TOTAL_VALUE, float(enchant_amount), apply); break; case ITEM_ENCHANTMENT_TYPE_STAT: { if (!enchant_amount) { - ItemRandomSuffixEntry const* item_rand_suffix = - sItemRandomSuffixStore.LookupEntry(abs(item->GetItemRandomPropertyId())); + ItemRandomSuffixEntry const* item_rand_suffix = sItemRandomSuffixStore.LookupEntry(abs(item->GetItemRandomPropertyId())); if (item_rand_suffix) { for (int k = 0; k < 5; ++k) { if (item_rand_suffix->Enchantment[k] == enchant_id) { - enchant_amount = - uint32((item_rand_suffix->AllocationPct[k] * item->GetItemSuffixFactor()) / 10000); + enchant_amount = uint32((item_rand_suffix->AllocationPct[k] * item->GetItemSuffixFactor()) / 10000); break; } } @@ -14039,9 +13889,8 @@ void Player::ApplyEnchantment(Item* item, EnchantmentSlot slot, bool apply, bool // nothing do.. break; default: - LOG_ERROR("entities.player", - "Player::ApplyEnchantment: Unknown item enchantment (ID: %u, DisplayType: %u) for player '%s' (%s)", - enchant_id, enchant_display_type, GetName().c_str(), GetGUID().ToString().c_str()); + LOG_ERROR("entities.player", "Player::ApplyEnchantment: Unknown item enchantment (ID: %u, DisplayType: %u) for player '%s' (%s)", enchant_id, enchant_display_type, GetName().c_str(), + GetGUID().ToString().c_str()); break; } } @@ -14101,19 +13950,15 @@ void Player::UpdateSkillEnchantments(uint16 skill_id, uint16 curr_value, uint16 // If we're dealing with a gem inside a prismatic socket we need to check the prismatic socket requirements // rather than the gem requirements itself. If the socket has no color it is a prismatic socket. - if ((slot == SOCK_ENCHANTMENT_SLOT || slot == SOCK_ENCHANTMENT_SLOT_2 || slot == SOCK_ENCHANTMENT_SLOT_3) && - !m_items[i]->GetTemplate()->GetSocketColor(slot - SOCK_ENCHANTMENT_SLOT)) + if ((slot == SOCK_ENCHANTMENT_SLOT || slot == SOCK_ENCHANTMENT_SLOT_2 || slot == SOCK_ENCHANTMENT_SLOT_3) && !m_items[i]->GetTemplate()->GetSocketColor(slot - SOCK_ENCHANTMENT_SLOT)) { - SpellItemEnchantmentEntry const* pPrismaticEnchant = - sSpellItemEnchantmentStore.LookupEntry(m_items[i]->GetEnchantmentId(PRISMATIC_ENCHANTMENT_SLOT)); + SpellItemEnchantmentEntry const* pPrismaticEnchant = sSpellItemEnchantmentStore.LookupEntry(m_items[i]->GetEnchantmentId(PRISMATIC_ENCHANTMENT_SLOT)); if (pPrismaticEnchant && pPrismaticEnchant->RequiredSkillID == skill_id) { - if (curr_value < pPrismaticEnchant->RequiredSkillRank && - new_value >= pPrismaticEnchant->RequiredSkillRank) + if (curr_value < pPrismaticEnchant->RequiredSkillRank && new_value >= pPrismaticEnchant->RequiredSkillRank) ApplyEnchantment(m_items[i], EnchantmentSlot(slot), true); - else if (new_value < pPrismaticEnchant->RequiredSkillRank && - curr_value >= pPrismaticEnchant->RequiredSkillRank) + else if (new_value < pPrismaticEnchant->RequiredSkillRank && curr_value >= pPrismaticEnchant->RequiredSkillRank) ApplyEnchantment(m_items[i], EnchantmentSlot(slot), false); } } @@ -14208,8 +14053,7 @@ void Player::PrepareGossipMenu(WorldObject* source, uint32 menuId /*= 0*/, bool break; case GOSSIP_OPTION_LEARNDUALSPEC: case GOSSIP_OPTION_DUALSPEC_INFO: - if (!(GetSpecsCount() == 1 && creature->CanResetTalents(this) && - !(getLevel() < sWorld->getIntConfig(CONFIG_MIN_DUALSPEC_LEVEL)))) + if (!(GetSpecsCount() == 1 && creature->CanResetTalents(this) && !(getLevel() < sWorld->getIntConfig(CONFIG_MIN_DUALSPEC_LEVEL)))) canTalk = false; break; case GOSSIP_OPTION_UNLEARNTALENTS: @@ -14217,8 +14061,7 @@ void Player::PrepareGossipMenu(WorldObject* source, uint32 menuId /*= 0*/, bool canTalk = false; break; case GOSSIP_OPTION_UNLEARNPETTALENTS: - if (!GetPet() || GetPet()->getPetType() != HUNTER_PET || GetPet()->m_spells.size() <= 1 || - !creature->CanResetTalents(this)) + if (!GetPet() || GetPet()->getPetType() != HUNTER_PET || GetPet()->m_spells.size() <= 1 || !creature->CanResetTalents(this)) canTalk = false; break; case GOSSIP_OPTION_TAXIVENDOR: @@ -14255,8 +14098,7 @@ void Player::PrepareGossipMenu(WorldObject* source, uint32 menuId /*= 0*/, bool canTalk = false; break; default: - LOG_ERROR("sql.sql", "Creature entry %u has unknown gossip option %u for menu %u.", creature->GetEntry(), - itr->second.OptionType, itr->second.MenuID); + LOG_ERROR("sql.sql", "Creature entry %u has unknown gossip option %u for menu %u.", creature->GetEntry(), itr->second.OptionType, itr->second.MenuID); canTalk = false; break; } @@ -14297,22 +14139,19 @@ void Player::PrepareGossipMenu(WorldObject* source, uint32 menuId /*= 0*/, bool if (!optionBroadcastText) { /// Find localizations from database. - if (GossipMenuItemsLocale const* gossipMenuLocale = - sObjectMgr->GetGossipMenuItemsLocale(menuId, itr->second.OptionID)) + if (GossipMenuItemsLocale const* gossipMenuLocale = sObjectMgr->GetGossipMenuItemsLocale(menuId, itr->second.OptionID)) ObjectMgr::GetLocaleString(gossipMenuLocale->OptionText, locale, strOptionText); } if (!boxBroadcastText) { /// Find localizations from database. - if (GossipMenuItemsLocale const* gossipMenuLocale = - sObjectMgr->GetGossipMenuItemsLocale(menuId, itr->second.OptionID)) + if (GossipMenuItemsLocale const* gossipMenuLocale = sObjectMgr->GetGossipMenuItemsLocale(menuId, itr->second.OptionID)) ObjectMgr::GetLocaleString(gossipMenuLocale->BoxText, locale, strBoxText); } } - menu->GetGossipMenu().AddMenuItem(itr->second.OptionID, itr->second.OptionIcon, strOptionText, 0, - itr->second.OptionType, strBoxText, itr->second.BoxMoney, itr->second.BoxCoded); + menu->GetGossipMenu().AddMenuItem(itr->second.OptionID, itr->second.OptionIcon, strOptionText, 0, itr->second.OptionType, strBoxText, itr->second.BoxMoney, itr->second.BoxCoded); menu->GetGossipMenu().AddGossipMenuItemData(itr->second.OptionID, itr->second.ActionMenuID, itr->second.ActionPoiID); } } @@ -14372,8 +14211,7 @@ void Player::OnGossipSelect(WorldObject* source, uint32 gossipListId, uint32 men { if (gossipOptionId > GOSSIP_OPTION_QUESTGIVER) { - LOG_ERROR("entities.player", "Player '%s' (%s) requests invalid gossip option for GameObject (Entry: %u)", - GetName().c_str(), GetGUID().ToString().c_str(), source->GetEntry()); + LOG_ERROR("entities.player", "Player '%s' (%s) requests invalid gossip option for GameObject (Entry: %u)", GetName().c_str(), GetGUID().ToString().c_str(), source->GetEntry()); return; } } @@ -14425,8 +14263,7 @@ void Player::OnGossipSelect(WorldObject* source, uint32 gossipListId, uint32 men GetSession()->SendStablePet(guid); break; case GOSSIP_OPTION_TRAINER: - GetSession()->SendTrainerList( - source->ToCreature(), sObjectMgr->GetCreatureTrainerForGossipOption(source->GetEntry(), menuId, gossipListId)); + GetSession()->SendTrainerList(source->ToCreature(), sObjectMgr->GetCreatureTrainerForGossipOption(source->GetEntry(), menuId, gossipListId)); break; case GOSSIP_OPTION_LEARNDUALSPEC: if (GetSpecsCount() == 1 && getLevel() >= sWorld->getIntConfig(CONFIG_MIN_DUALSPEC_LEVEL)) @@ -14479,8 +14316,8 @@ void Player::OnGossipSelect(WorldObject* source, uint32 gossipListId, uint32 men if (bgTypeId == BATTLEGROUND_TYPE_NONE) { - LOG_ERROR("entities.player", "Player '%s' (%s) requested battlegroundlist from an invalid creature (%s)", - GetName().c_str(), GetGUID().ToString().c_str(), source->GetGUID().ToString().c_str()); + LOG_ERROR( + "entities.player", "Player '%s' (%s) requested battlegroundlist from an invalid creature (%s)", GetName().c_str(), GetGUID().ToString().c_str(), source->GetGUID().ToString().c_str()); return; } @@ -14618,8 +14455,7 @@ void Player::SendPreparedQuest(ObjectGuid guid) /// @todo verify if check for !quest->IsDaily() is really correct (possibly not) else { - Object* object = - ObjectAccessor::GetObjectByTypeMask(*this, guid, TYPEMASK_UNIT | TYPEMASK_GAMEOBJECT | TYPEMASK_ITEM); + Object* object = ObjectAccessor::GetObjectByTypeMask(*this, guid, TYPEMASK_UNIT | TYPEMASK_GAMEOBJECT | TYPEMASK_ITEM); if (!object || (!object->hasQuest(questId) && !object->hasInvolvedQuest(questId))) { PlayerTalkClass->SendCloseGossip(); @@ -14687,7 +14523,10 @@ void Player::SendPreparedQuest(ObjectGuid guid) } } -bool Player::IsActiveQuest(uint32 quest_id) const { return m_QuestStatus.find(quest_id) != m_QuestStatus.end(); } +bool Player::IsActiveQuest(uint32 quest_id) const +{ + return m_QuestStatus.find(quest_id) != m_QuestStatus.end(); +} Quest const* Player::GetNextQuest(ObjectGuid guid, Quest const* quest) const { @@ -14735,9 +14574,8 @@ Quest const* Player::GetNextQuest(ObjectGuid guid, Quest const* quest) const bool Player::CanSeeStartQuest(Quest const* quest) const { - if (!DisableMgr::IsDisabledFor(DISABLE_TYPE_QUEST, quest->GetQuestId(), this) && SatisfyQuestClass(quest, false) && - SatisfyQuestRace(quest, false) && SatisfyQuestSkill(quest, false) && SatisfyQuestExclusiveGroup(quest, false) && - SatisfyQuestReputation(quest, false) && SatisfyQuestDependentQuests(quest, false) && SatisfyQuestDay(quest, false) && + if (!DisableMgr::IsDisabledFor(DISABLE_TYPE_QUEST, quest->GetQuestId(), this) && SatisfyQuestClass(quest, false) && SatisfyQuestRace(quest, false) && SatisfyQuestSkill(quest, false) && + SatisfyQuestExclusiveGroup(quest, false) && SatisfyQuestReputation(quest, false) && SatisfyQuestDependentQuests(quest, false) && SatisfyQuestDay(quest, false) && SatisfyQuestWeek(quest, false) && SatisfyQuestMonth(quest, false) && SatisfyQuestSeasonal(quest, false)) { return getLevel() + sWorld->getIntConfig(CONFIG_QUEST_HIGH_LEVEL_HIDE_DIFF) >= quest->GetMinLevel(); @@ -14748,11 +14586,9 @@ bool Player::CanSeeStartQuest(Quest const* quest) const bool Player::CanTakeQuest(Quest const* quest, bool msg) const { - return !DisableMgr::IsDisabledFor(DISABLE_TYPE_QUEST, quest->GetQuestId(), this) && SatisfyQuestStatus(quest, msg) && - SatisfyQuestExclusiveGroup(quest, msg) && SatisfyQuestClass(quest, msg) && SatisfyQuestRace(quest, msg) && - SatisfyQuestLevel(quest, msg) && SatisfyQuestSkill(quest, msg) && SatisfyQuestReputation(quest, msg) && - SatisfyQuestDependentQuests(quest, msg) && SatisfyQuestTimed(quest, msg) && SatisfyQuestDay(quest, msg) && - SatisfyQuestWeek(quest, msg) && SatisfyQuestMonth(quest, msg) && SatisfyQuestSeasonal(quest, msg) && + return !DisableMgr::IsDisabledFor(DISABLE_TYPE_QUEST, quest->GetQuestId(), this) && SatisfyQuestStatus(quest, msg) && SatisfyQuestExclusiveGroup(quest, msg) && SatisfyQuestClass(quest, msg) && + SatisfyQuestRace(quest, msg) && SatisfyQuestLevel(quest, msg) && SatisfyQuestSkill(quest, msg) && SatisfyQuestReputation(quest, msg) && SatisfyQuestDependentQuests(quest, msg) && + SatisfyQuestTimed(quest, msg) && SatisfyQuestDay(quest, msg) && SatisfyQuestWeek(quest, msg) && SatisfyQuestMonth(quest, msg) && SatisfyQuestSeasonal(quest, msg) && SatisfyQuestConditions(quest, msg); } @@ -14860,8 +14696,7 @@ bool Player::CanCompleteRepeatableQuest(Quest const* quest) if (quest->HasSpecialFlag(QUEST_SPECIAL_FLAGS_DELIVER)) for (uint8 i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; i++) - if (quest->RequiredItemId[i] && quest->RequiredItemCount[i] && - !HasItemCount(quest->RequiredItemId[i], quest->RequiredItemCount[i])) + if (quest->RequiredItemId[i] && quest->RequiredItemCount[i] && !HasItemCount(quest->RequiredItemId[i], quest->RequiredItemCount[i])) return false; if (!CanRewardQuest(quest, false)) @@ -14877,8 +14712,7 @@ bool Player::CanRewardQuest(Quest const* quest, bool msg) return false; // daily quest can't be rewarded (25 daily quest already completed) - if (!SatisfyQuestDay(quest, true) || !SatisfyQuestWeek(quest, true) || !SatisfyQuestMonth(quest, true) || - !SatisfyQuestSeasonal(quest, true)) + if (!SatisfyQuestDay(quest, true) || !SatisfyQuestWeek(quest, true) || !SatisfyQuestMonth(quest, true) || !SatisfyQuestSeasonal(quest, true)) return false; // rewarded and not repeatable quest (only cheating case, then ignore without message) @@ -14984,8 +14818,7 @@ bool Player::CanRewardQuest(Quest const* quest, uint32 reward, bool msg) { if (quest->RewardChoiceItemId[reward]) { - InventoryResult res = CanStoreNewItem( - NULL_BAG, NULL_SLOT, dest, quest->RewardChoiceItemId[reward], quest->RewardChoiceItemCount[reward]); + InventoryResult res = CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, quest->RewardChoiceItemId[reward], quest->RewardChoiceItemCount[reward]); if (res != EQUIP_ERR_OK) { if (msg) @@ -15002,8 +14835,7 @@ bool Player::CanRewardQuest(Quest const* quest, uint32 reward, bool msg) { if (quest->RewardItemId[i]) { - InventoryResult res = - CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, quest->RewardItemId[i], quest->RewardItemIdCount[i]); + InventoryResult res = CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, quest->RewardItemId[i], quest->RewardItemIdCount[i]); if (res != EQUIP_ERR_OK) { if (msg) @@ -15162,8 +14994,7 @@ void Player::RewardQuest(Quest const* quest, uint32 reward, Object* questGiver, { if (ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(quest->RequiredItemId[i])) { - if (quest->RequiredItemCount[i] > 0 && itemTemplate->GetBonding() == BIND_QUEST && !quest->IsRepeatable() && - !HasQuestForItem(quest->RequiredItemId[i], quest_id, true)) + if (quest->RequiredItemCount[i] > 0 && itemTemplate->GetBonding() == BIND_QUEST && !quest->IsRepeatable() && !HasQuestForItem(quest->RequiredItemId[i], quest_id, true)) DestroyItemCount(quest->RequiredItemId[i], 9999, true); else DestroyItemCount(quest->RequiredItemId[i], quest->RequiredItemCount[i], true); @@ -15177,8 +15008,7 @@ void Player::RewardQuest(Quest const* quest, uint32 reward, Object* questGiver, { if (ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(quest->ItemDrop[i])) { - if (quest->ItemDropQuantity[i] > 0 && itemTemplate->GetBonding() == BIND_QUEST && !quest->IsRepeatable() && - !HasQuestForItem(quest->ItemDrop[i], quest_id)) + if (quest->ItemDropQuantity[i] > 0 && itemTemplate->GetBonding() == BIND_QUEST && !quest->IsRepeatable() && !HasQuestForItem(quest->ItemDrop[i], quest_id)) DestroyItemCount(quest->ItemDrop[i], 9999, true); else DestroyItemCount(quest->ItemDrop[i], quest->ItemDropQuantity[i], true); @@ -15299,11 +15129,9 @@ void Player::RewardQuest(Quest const* quest, uint32 reward, Object* questGiver, /// @todo Poor design of mail system CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction(); if (uint32 questMailSender = quest->GetRewMailSenderEntry()) - MailDraft(mail_template_id) - .SendMailTo(trans, this, questMailSender, MAIL_CHECK_MASK_HAS_BODY, quest->GetRewMailDelaySecs()); + MailDraft(mail_template_id).SendMailTo(trans, this, questMailSender, MAIL_CHECK_MASK_HAS_BODY, quest->GetRewMailDelaySecs()); else - MailDraft(mail_template_id) - .SendMailTo(trans, this, questGiver, MAIL_CHECK_MASK_HAS_BODY, quest->GetRewMailDelaySecs()); + MailDraft(mail_template_id).SendMailTo(trans, this, questGiver, MAIL_CHECK_MASK_HAS_BODY, quest->GetRewMailDelaySecs()); CharacterDatabase.CommitTransaction(trans); } @@ -15336,8 +15164,7 @@ void Player::RewardQuest(Quest const* quest, uint32 reward, Object* questGiver, if (quest->GetRewSpellCast() > 0) { SpellInfo const* spellInfo = ASSERT_NOTNULL(sSpellMgr->GetSpellInfo(quest->GetRewSpellCast())); - if (questGiver->isType(TYPEMASK_UNIT) && !spellInfo->HasEffect(SPELL_EFFECT_LEARN_SPELL) && - !spellInfo->HasEffect(SPELL_EFFECT_CREATE_ITEM) && !spellInfo->IsSelfCast() && + if (questGiver->isType(TYPEMASK_UNIT) && !spellInfo->HasEffect(SPELL_EFFECT_LEARN_SPELL) && !spellInfo->HasEffect(SPELL_EFFECT_CREATE_ITEM) && !spellInfo->IsSelfCast() && !quest->HasFlag(QUEST_FLAGS_PLAYER_CAST_ON_COMPLETE)) { if (Creature* creature = GetMap()->GetCreature(questGiver->GetGUID())) @@ -15349,8 +15176,7 @@ void Player::RewardQuest(Quest const* quest, uint32 reward, Object* questGiver, else if (quest->GetRewSpell() > 0) { SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(quest->GetRewSpell()); - if (questGiver->isType(TYPEMASK_UNIT) && !spellInfo->HasEffect(SPELL_EFFECT_LEARN_SPELL) && - !spellInfo->HasEffect(SPELL_EFFECT_CREATE_ITEM) && !spellInfo->IsSelfCast() && + if (questGiver->isType(TYPEMASK_UNIT) && !spellInfo->HasEffect(SPELL_EFFECT_LEARN_SPELL) && !spellInfo->HasEffect(SPELL_EFFECT_CREATE_ITEM) && !spellInfo->IsSelfCast() && !quest->HasFlag(QUEST_FLAGS_PLAYER_CAST_ON_COMPLETE)) { if (Creature* creature = GetMap()->GetCreature(questGiver->GetGUID())) @@ -15402,8 +15228,7 @@ void Player::FailQuest(uint32 questId) if (qStatus != QUEST_STATUS_INCOMPLETE) { // completed timed quest with no requirements - if (qStatus != QUEST_STATUS_COMPLETE || !quest->HasSpecialFlag(QUEST_SPECIAL_FLAGS_TIMED) || - !quest->HasSpecialFlag(QUEST_SPECIAL_FLAGS_COMPLETED_AT_START)) + if (qStatus != QUEST_STATUS_COMPLETE || !quest->HasSpecialFlag(QUEST_SPECIAL_FLAGS_TIMED) || !quest->HasSpecialFlag(QUEST_SPECIAL_FLAGS_COMPLETED_AT_START)) return; } @@ -15504,8 +15329,7 @@ bool Player::SatisfyQuestLevel(Quest const* qInfo, bool msg) const { if (msg) { - SendCanTakeQuestResponse( - INVALIDREASON_DONT_HAVE_REQ); // There doesn't seem to be a specific response for too high player level + SendCanTakeQuestResponse(INVALIDREASON_DONT_HAVE_REQ); // There doesn't seem to be a specific response for too high player level LOG_DEBUG("misc", "Player::SatisfyQuestLevel: Sent INVALIDREASON_DONT_HAVE_REQ (QuestID: %u) because player '%s' (%s) doesn't have " "the required (max) level.", @@ -15532,8 +15356,7 @@ bool Player::SatisfyQuestLog(bool msg) const bool Player::SatisfyQuestDependentQuests(Quest const* qInfo, bool msg) const { - return SatisfyQuestPreviousQuest(qInfo, msg) && SatisfyQuestDependentPreviousQuests(qInfo, msg) && - SatisfyQuestBreadcrumbQuest(qInfo, msg) && SatisfyQuestDependentBreadcrumbQuests(qInfo, msg); + return SatisfyQuestPreviousQuest(qInfo, msg) && SatisfyQuestDependentPreviousQuests(qInfo, msg) && SatisfyQuestBreadcrumbQuest(qInfo, msg) && SatisfyQuestDependentBreadcrumbQuests(qInfo, msg); } bool Player::SatisfyQuestPreviousQuest(Quest const* qInfo, bool msg) const @@ -15801,8 +15624,7 @@ bool Player::SatisfyQuestStatus(Quest const* qInfo, bool msg) const bool Player::SatisfyQuestConditions(Quest const* qInfo, bool msg) const { - if (!sConditionMgr->IsObjectMeetingNotGroupedConditions( - CONDITION_SOURCE_TYPE_QUEST_AVAILABLE, qInfo->GetQuestId(), const_cast(this))) + if (!sConditionMgr->IsObjectMeetingNotGroupedConditions(CONDITION_SOURCE_TYPE_QUEST_AVAILABLE, qInfo->GetQuestId(), const_cast(this))) { if (msg) { @@ -15868,8 +15690,7 @@ bool Player::SatisfyQuestExclusiveGroup(Quest const* qInfo, bool msg) const } // alternative quest already started or completed - but don't check rewarded states if both are repeatable - if (GetQuestStatus(exclude_Id) != QUEST_STATUS_NONE || - (!(qInfo->IsRepeatable() && Nquest->IsRepeatable()) && GetQuestRewardStatus(exclude_Id))) + if (GetQuestStatus(exclude_Id) != QUEST_STATUS_NONE || (!(qInfo->IsRepeatable() && Nquest->IsRepeatable()) && GetQuestRewardStatus(exclude_Id))) { if (msg) { @@ -16261,8 +16082,7 @@ QuestGiverStatus Player::GetQuestDialogStatus(Object* questgiver) { if (SatisfyQuestLevel(quest, false)) { - bool isNotLowLevelQuest = - getLevel() <= (GetQuestLevel(quest) + sWorld->getIntConfig(CONFIG_QUEST_LOW_LEVEL_HIDE_DIFF)); + bool isNotLowLevelQuest = getLevel() <= (GetQuestLevel(quest) + sWorld->getIntConfig(CONFIG_QUEST_LOW_LEVEL_HIDE_DIFF)); if (quest->IsRepeatable()) { if (quest->IsDaily()) @@ -16525,8 +16345,7 @@ void Player::ItemRemovedQuestCheck(uint32 entry, uint32 count) uint16 questStatusItemCount = q_status.ItemCount[j]; uint16 newItemCount = (count > questStatusItemCount) ? 0 : questStatusItemCount - count; - if (questStatusItemCount >= - reqItemCount) // we may have more than what the status shows, we don't need reduce by count + if (questStatusItemCount >= reqItemCount) // we may have more than what the status shows, we don't need reduce by count newItemCount = GetItemCount(entry, false); newItemCount = std::min(newItemCount, reqItemCount); @@ -16580,8 +16399,7 @@ void Player::KilledMonsterCredit(uint32 entry, ObjectGuid guid /*= ObjectGuid::E continue; // just if !ingroup || !noraidgroup || raidgroup QuestStatusData& q_status = m_QuestStatus[questid]; - if (q_status.Status == QUEST_STATUS_INCOMPLETE && - (!GetGroup() || !GetGroup()->isRaidGroup() || qInfo->IsAllowedInRaid(GetMap()->GetDifficulty()))) + if (q_status.Status == QUEST_STATUS_INCOMPLETE && (!GetGroup() || !GetGroup()->isRaidGroup() || qInfo->IsAllowedInRaid(GetMap()->GetDifficulty()))) { if (qInfo->HasSpecialFlag(QUEST_SPECIAL_FLAGS_KILL) /*&& !qInfo->HasSpecialFlag(QUEST_SPECIAL_FLAGS_CAST)*/) { @@ -16635,12 +16453,10 @@ void Player::KilledPlayerCredit(uint16 count) continue; // just if !ingroup || !noraidgroup || raidgroup QuestStatusData& q_status = m_QuestStatus[questid]; - if (q_status.Status == QUEST_STATUS_INCOMPLETE && - (!GetGroup() || !GetGroup()->isRaidGroup() || qInfo->IsAllowedInRaid(GetMap()->GetDifficulty()))) + if (q_status.Status == QUEST_STATUS_INCOMPLETE && (!GetGroup() || !GetGroup()->isRaidGroup() || qInfo->IsAllowedInRaid(GetMap()->GetDifficulty()))) { // PvP Killing quest require player to be in same zone as quest zone (only 2 quests so no doubt) - if (qInfo->HasSpecialFlag(QUEST_SPECIAL_FLAGS_PLAYER_KILL) && - GetZoneId() == static_cast(qInfo->GetZoneOrSort())) + if (qInfo->HasSpecialFlag(QUEST_SPECIAL_FLAGS_PLAYER_KILL) && GetZoneId() == static_cast(qInfo->GetZoneOrSort())) { KilledPlayerCreditForQuest(count, qInfo); break; // there is only one quest per zone @@ -16916,8 +16732,7 @@ bool Player::HasQuestForItem(uint32 itemid, uint32 excludeQuestId /* 0 */, bool // This part for ReqItem drop for (uint8 j = 0; j < QUEST_ITEM_OBJECTIVES_COUNT; ++j) { - if ((itemid == qinfo->RequiredItemId[j] && q_status.ItemCount[j] < qinfo->RequiredItemCount[j]) || - (turnIn && q_status.ItemCount[j] >= qinfo->RequiredItemCount[j])) + if ((itemid == qinfo->RequiredItemId[j] && q_status.ItemCount[j] < qinfo->RequiredItemCount[j]) || (turnIn && q_status.ItemCount[j] >= qinfo->RequiredItemCount[j])) return true; } // This part - for ReqSource @@ -16930,8 +16745,7 @@ bool Player::HasQuestForItem(uint32 itemid, uint32 excludeQuestId /* 0 */, bool uint32 ownedCount = GetItemCount(itemid, true); // 'unique' item - if ((pProto->GetMaxCount() && ownedCount < pProto->GetMaxCount()) || - (turnIn && ownedCount >= pProto->GetMaxCount())) + if ((pProto->GetMaxCount() && ownedCount < pProto->GetMaxCount()) || (turnIn && ownedCount >= pProto->GetMaxCount())) return true; // allows custom amount drop when not 0 @@ -17126,7 +16940,10 @@ bool Player::HasPvPForcingQuest() const /*** LOAD SYSTEM ***/ /*********************************************************/ -void Player::Initialize(ObjectGuid::LowType guid) { Object::_Create(guid, 0, HighGuid::Player); } +void Player::Initialize(ObjectGuid::LowType guid) +{ + Object::_Create(guid, 0, HighGuid::Player); +} void Player::_LoadDeclinedNames(PreparedQueryResult result) { @@ -17299,7 +17116,10 @@ float Player::GetFloatValueFromArray(Tokenizer const& data, uint16 index) return result; } -bool Player::IsLoading() const { return GetSession()->PlayerLoading(); } +bool Player::IsLoading() const +{ + return GetSession()->PlayerLoading(); +} bool Player::LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder const& holder) { @@ -17326,8 +17146,7 @@ bool Player::LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder const& hol { std::string name = ""; sCharacterCache->GetCharacterNameByGuid(guid, name); - LOG_ERROR("entities.player", "Player::LoadFromDB: Player '%s' (%s) not found in table `characters`, can't load. ", - name.c_str(), guid.ToString().c_str()); + LOG_ERROR("entities.player", "Player::LoadFromDB: Player '%s' (%s) not found in table `characters`, can't load. ", name.c_str(), guid.ToString().c_str()); return false; } @@ -17339,8 +17158,7 @@ bool Player::LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder const& hol // player should be able to load/delete character only with correct account! if (dbAccountId != GetSession()->GetAccountId()) { - LOG_ERROR("entities.player", "Player::LoadFromDB: Player (%s) loading from wrong account (is: %u, should be: %u)", - guid.ToString().c_str(), GetSession()->GetAccountId(), dbAccountId); + LOG_ERROR("entities.player", "Player::LoadFromDB: Player (%s) loading from wrong account (is: %u, should be: %u)", guid.ToString().c_str(), GetSession()->GetAccountId(), dbAccountId); return false; } @@ -17356,8 +17174,7 @@ bool Player::LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder const& hol // check name limitations if (ObjectMgr::CheckPlayerName(m_name, GetSession()->GetSessionDbcLocale()) != CHAR_NAME_SUCCESS || - (!GetSession()->HasPermission(rbac::RBAC_PERM_SKIP_CHECK_CHARACTER_CREATION_RESERVEDNAME) && - sObjectMgr->IsReservedName(m_name))) + (!GetSession()->HasPermission(rbac::RBAC_PERM_SKIP_CHECK_CHARACTER_CREATION_RESERVEDNAME) && sObjectMgr->IsReservedName(m_name))) { CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ADD_AT_LOGIN_FLAG); stmt->setUInt16(0, uint16(AT_LOGIN_RENAME)); @@ -17372,8 +17189,7 @@ bool Player::LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder const& hol uint8 gender = fields[5].GetUInt8(); if (!IsValidGender(gender)) { - LOG_ERROR("entities.player", "Player::LoadFromDB: Player (%s) has wrong gender (%u), can't load.", - guid.ToString().c_str(), gender); + LOG_ERROR("entities.player", "Player::LoadFromDB: Player (%s) has wrong gender (%u), can't load.", guid.ToString().c_str(), gender); return false; } @@ -17385,8 +17201,7 @@ bool Player::LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder const& hol PlayerInfo const* info = sObjectMgr->GetPlayerInfo(getRace(), getClass()); if (!info) { - LOG_ERROR("entities.player", "Player::LoadFromDB: Player (%s) has wrong race/class (%u/%u), can't load.", - guid.ToString().c_str(), getRace(), getClass()); + LOG_ERROR("entities.player", "Player::LoadFromDB: Player (%s) has wrong race/class (%u/%u), can't load.", guid.ToString().c_str(), getRace(), getClass()); return false; } @@ -17401,8 +17216,7 @@ bool Player::LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder const& hol // load achievements before anything else to prevent multiple gains for the same achievement/criteria on every loading (as // loading does call UpdateAchievementCriteria) - m_achievementMgr->LoadFromDB(holder.GetPreparedResult(PLAYER_LOGIN_QUERY_LOAD_ACHIEVEMENTS), - holder.GetPreparedResult(PLAYER_LOGIN_QUERY_LOAD_CRITERIA_PROGRESS)); + m_achievementMgr->LoadFromDB(holder.GetPreparedResult(PLAYER_LOGIN_QUERY_LOAD_ACHIEVEMENTS), holder.GetPreparedResult(PLAYER_LOGIN_QUERY_LOAD_CRITERIA_PROGRESS)); uint64 money = fields[8].GetUInt64(); if (money > MAX_MONEY_AMOUNT) @@ -17427,8 +17241,7 @@ bool Player::LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder const& hol GetByteValue(PLAYER_BYTES_2, PLAYER_BYTES_2_OFFSET_FACIAL_STYLE), // facial hair GetByteValue(PLAYER_BYTES, PLAYER_BYTES_OFFSET_SKIN_ID))) // skin color { - LOG_ERROR("entities.player", "Player::LoadFromDB: Player (%s) has wrong Appearance values (Hair/Skin/Color), can't load.", - guid.ToString().c_str()); + LOG_ERROR("entities.player", "Player::LoadFromDB: Player (%s) has wrong Appearance values (Hair/Skin/Color), can't load.", guid.ToString().c_str()); return false; } @@ -17485,11 +17298,11 @@ bool Player::LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder const& hol std::string taxi_nodes = fields[43].GetString(); -#define RelocateToHomebind() \ - { \ - mapId = m_homebindMapId; \ - instanceId = 0; \ - Relocate(m_homebindX, m_homebindY, m_homebindZ); \ +#define RelocateToHomebind() \ + { \ + mapId = m_homebindMapId; \ + instanceId = 0; \ + Relocate(m_homebindX, m_homebindY, m_homebindZ); \ } _LoadGroup(holder.GetPreparedResult(PLAYER_LOGIN_QUERY_LOAD_GROUP)); @@ -17546,8 +17359,7 @@ bool Player::LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder const& hol { map = currentBg->GetBgMap(); - BattlegroundQueueTypeId bgQueueTypeId = - sBattlegroundMgr->BGQueueTypeId(currentBg->GetTypeID(), currentBg->GetArenaType()); + BattlegroundQueueTypeId bgQueueTypeId = sBattlegroundMgr->BGQueueTypeId(currentBg->GetTypeID(), currentBg->GetArenaType()); AddBattlegroundQueueId(bgQueueTypeId); m_bgData.bgTypeID = currentBg->GetTypeID(); @@ -17620,8 +17432,7 @@ bool Player::LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder const& hol if (!Firelands::IsValidMapCoord(x, y, z, o) || // transport size limited - std::fabs(m_movementInfo.transport.pos.GetPositionX()) > 250.0f || - std::fabs(m_movementInfo.transport.pos.GetPositionY()) > 250.0f || + std::fabs(m_movementInfo.transport.pos.GetPositionX()) > 250.0f || std::fabs(m_movementInfo.transport.pos.GetPositionY()) > 250.0f || std::fabs(m_movementInfo.transport.pos.GetPositionZ()) > 250.0f) { LOG_ERROR("entities.player", @@ -17643,9 +17454,7 @@ bool Player::LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder const& hol } else { - LOG_ERROR("entities.player", - "Player::LoadFromDB: Player (%s) has problems with transport guid (%u). Teleport to bind location.", - guid.ToString().c_str(), transLowGUID); + LOG_ERROR("entities.player", "Player::LoadFromDB: Player (%s) has problems with transport guid (%u). Teleport to bind location.", guid.ToString().c_str(), transLowGUID); RelocateToHomebind(); } @@ -17670,16 +17479,12 @@ bool Player::LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder const& hol if (!nodeEntry) // don't know taxi start node, teleport to homebind { - LOG_ERROR("entities.player", - "Player::LoadFromDB: Player (%s) has wrong data in taxi destination list, teleport to homebind.", - GetGUID().ToString().c_str()); + LOG_ERROR("entities.player", "Player::LoadFromDB: Player (%s) has wrong data in taxi destination list, teleport to homebind.", GetGUID().ToString().c_str()); RelocateToHomebind(); } else // has start node, teleport to it { - LOG_ERROR("entities.player", - "Player::LoadFromDB: Player (%s) has too short taxi destination list, teleport to original node.", - GetGUID().ToString().c_str()); + LOG_ERROR("entities.player", "Player::LoadFromDB: Player (%s) has too short taxi destination list, teleport to original node.", GetGUID().ToString().c_str()); mapId = nodeEntry->ContinentID; Relocate(nodeEntry->Pos.X, nodeEntry->Pos.Y, nodeEntry->Pos.Z, 0.0f); } @@ -17736,8 +17541,7 @@ bool Player::LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder const& hol } else if (map->IsDungeon()) // if map is dungeon... { - if (Map::EnterState denyReason = - ((InstanceMap*)map)->CannotEnter(this)) // ... and can't enter map, then look for entry point. + if (Map::EnterState denyReason = ((InstanceMap*)map)->CannotEnter(this)) // ... and can't enter map, then look for entry point. { switch (denyReason) { @@ -17762,8 +17566,7 @@ bool Player::LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder const& hol areaTrigger = sObjectMgr->GetGoBackTrigger(mapId); check = true; } - else if (instanceId && - !sInstanceSaveMgr->GetInstanceSave(instanceId)) // ... and instance is reseted then look for entrance. + else if (instanceId && !sInstanceSaveMgr->GetInstanceSave(instanceId)) // ... and instance is reseted then look for entrance. { areaTrigger = sObjectMgr->GetMapEntranceTrigger(mapId); check = true; @@ -17783,9 +17586,8 @@ bool Player::LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder const& hol } else { - LOG_ERROR("entities.player", - "Player::LoadFromDB: Player '%s' (%s) Map: %u, X: %f, Y: %f, Z: %f, O: %f. Areatrigger not found.", - m_name.c_str(), guid.ToString().c_str(), mapId, GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation()); + LOG_ERROR("entities.player", "Player::LoadFromDB: Player '%s' (%s) Map: %u, X: %f, Y: %f, Z: %f, O: %f. Areatrigger not found.", m_name.c_str(), guid.ToString().c_str(), mapId, + GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation()); RelocateToHomebind(); map = nullptr; } @@ -17826,8 +17628,7 @@ bool Player::LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder const& hol time_t logoutTime = time_t(fields[27].GetUInt32()); // since last logout (in seconds) - uint32 time_diff = - uint32(now - logoutTime); // uint64 is excessive for a time_diff in seconds.. uint32 allows for 136~ year difference. + uint32 time_diff = uint32(now - logoutTime); // uint64 is excessive for a time_diff in seconds.. uint32 allows for 136~ year difference. // set value, including drunk invisibility detection // calculate sobering. after 15 minutes logged out, the player will be sober again @@ -17851,8 +17652,7 @@ bool Player::LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder const& hol if (GetSpecsCount() > MAX_TALENT_SPECS || GetActiveSpec() > MAX_TALENT_SPEC || GetSpecsCount() < MIN_TALENT_SPECS) { SetActiveSpec(0); - LOG_ERROR("entities.player", "Player %s(GUID: %u) has SpecCount = %u and ActiveSpec = %u.", GetName().c_str(), - GetGUID().GetCounter(), GetSpecsCount(), GetActiveSpec()); + LOG_ERROR("entities.player", "Player %s(GUID: %u) has SpecCount = %u and ActiveSpec = %u.", GetName().c_str(), GetGUID().GetCounter(), GetSpecsCount(), GetActiveSpec()); } // Only load selected specializations, learning mastery spells requires this @@ -17874,8 +17674,7 @@ bool Player::LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder const& hol m_stableSlots = fields[38].GetUInt8(); if (m_stableSlots > MAX_PET_STABLES) { - LOG_ERROR("entities.player", "Player::LoadFromDB: Player (%s) can't have more stable slots than %u, but has %u in DB", - GetGUID().ToString().c_str(), MAX_PET_STABLES, uint32(m_stableSlots)); + LOG_ERROR("entities.player", "Player::LoadFromDB: Player (%s) can't have more stable slots than %u, but has %u in DB", GetGUID().ToString().c_str(), MAX_PET_STABLES, uint32(m_stableSlots)); m_stableSlots = MAX_PET_STABLES; } @@ -17883,8 +17682,7 @@ bool Player::LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder const& hol if (HasAtLoginFlag(AT_LOGIN_RENAME)) { - LOG_INFO("entities.player.cheat", "Player::LoadFromDB: Player (%s) tried to login while forced to rename, can't load.'", - GetGUID().ToString().c_str()); + LOG_INFO("entities.player.cheat", "Player::LoadFromDB: Player (%s) tried to login while forced to rename, can't load.'", GetGUID().ToString().c_str()); return false; } @@ -17938,8 +17736,7 @@ bool Player::LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder const& hol float bubble0 = 0.031f; // speed collect rest bonus in offline, in logout, in tavern, city (section/in hour) float bubble1 = 0.125f; - float bubble = fields[28].GetUInt8() > 0 ? bubble1 * sWorld->getRate(RATE_REST_OFFLINE_IN_TAVERN_OR_CITY) - : bubble0 * sWorld->getRate(RATE_REST_OFFLINE_IN_WILDERNESS); + float bubble = fields[28].GetUInt8() > 0 ? bubble1 * sWorld->getRate(RATE_REST_OFFLINE_IN_TAVERN_OR_CITY) : bubble0 * sWorld->getRate(RATE_REST_OFFLINE_IN_WILDERNESS); SetRestBonus(GetRestBonus() + time_diff * ((float)GetUInt32Value(PLAYER_NEXT_LEVEL_XP) / 72000) * bubble); } @@ -17993,8 +17790,7 @@ bool Player::LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder const& hol _LoadActions(holder.GetPreparedResult(PLAYER_LOGIN_QUERY_LOAD_ACTIONS)); // unread mails and next delivery time, actual mails not loaded - _LoadMail( - holder.GetPreparedResult(PLAYER_LOGIN_QUERY_LOAD_MAILS), holder.GetPreparedResult(PLAYER_LOGIN_QUERY_LOAD_MAIL_ITEMS)); + _LoadMail(holder.GetPreparedResult(PLAYER_LOGIN_QUERY_LOAD_MAILS), holder.GetPreparedResult(PLAYER_LOGIN_QUERY_LOAD_MAIL_ITEMS)); m_social = sSocialMgr->LoadFromDB(holder.GetPreparedResult(PLAYER_LOGIN_QUERY_LOAD_SOCIAL_LIST), GetGUID()); @@ -18169,14 +17965,12 @@ void Player::_LoadCUFProfiles(PreparedQueryResult result) if (id > MAX_CUF_PROFILES) { - LOG_ERROR("entities.player", - "Player::_LoadCUFProfiles - Player (GUID: %u, name: %s) has an CUF profile with invalid id (id: %u), max is %i.", - GetGUID().GetCounter(), GetName().c_str(), id, MAX_CUF_PROFILES); + LOG_ERROR("entities.player", "Player::_LoadCUFProfiles - Player (GUID: %u, name: %s) has an CUF profile with invalid id (id: %u), max is %i.", GetGUID().GetCounter(), GetName().c_str(), + id, MAX_CUF_PROFILES); continue; } - _CUFProfiles[id] = Firelands::make_unique(name, frameHeight, frameWidth, sortBy, healthText, boolOptions, - topPoint, bottomPoint, leftPoint, topOffset, bottomOffset, leftOffset); + _CUFProfiles[id] = Firelands::make_unique(name, frameHeight, frameWidth, sortBy, healthText, boolOptions, topPoint, bottomPoint, leftPoint, topOffset, bottomOffset, leftOffset); } while (result->NextRow()); } @@ -18265,11 +18059,10 @@ void Player::_LoadAuras(PreparedQueryResult result, uint32 timediff) { LOG_DEBUG("entities.player.loading", "Player::_LoadAuras: Loading auras for %s", GetGUID().ToString().c_str()); - /* 0 1 2 3 4 5 6 - 7 8 9 10 QueryResult* result = CharacterDatabase.PQuery("SELECT casterGuid, spell, effectMask, - recalculateMask, stackCount, amount0, amount1, amount2, base_amount0, base_amount1, base_amount2, 11 12 13 - maxDuration, remainTime, remainCharges FROM character_aura WHERE guid = '%u'", - GetGUID().GetCounter()); + /* 0 1 2 3 4 5 6 7 8 9 10 + QueryResult* result = CharacterDatabase.PQuery("SELECT casterGuid, spell, effectMask, recalculateMask, stackCount, amount0, amount1, amount2, base_amount0, base_amount1, base_amount2, + 11 12 13 14 15 + maxDuration, remainTime, remainCharges, critChance, applyResilience FROM character_aura WHERE guid = '%u'", GetGUID().GetCounter()); */ if (result) @@ -18293,20 +18086,19 @@ void Player::_LoadAuras(PreparedQueryResult result, uint32 timediff) int32 maxduration = fields[11].GetInt32(); int32 remaintime = fields[12].GetInt32(); uint8 remaincharges = fields[13].GetUInt8(); + float critChance = fields[14].GetFloat(); + bool applyResilience = fields[15].GetBool(); SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellid); if (!spellInfo) { - LOG_ERROR("entities.player", "Player::_LoadAuras: Player '%s' (%s) has an invalid aura (SpellID: %u), ignoring.", - GetName().c_str(), GetGUID().ToString().c_str(), spellid); + LOG_ERROR("entities.player", "Player::_LoadAuras: Player '%s' (%s) has an invalid aura (SpellID: %u), ignoring.", GetName().c_str(), GetGUID().ToString().c_str(), spellid); continue; } // negative effects should continue counting down after logout if (remaintime != -1 && - ((!spellInfo->IsPositive() && spellInfo->Id != 15007) || - spellInfo->HasAttribute( - SPELL_ATTR4_FADES_WHILE_LOGGED_OUT))) // Resurrection sickness should not fade while logged out + ((!spellInfo->IsPositive() && spellInfo->Id != 15007) || spellInfo->HasAttribute(SPELL_ATTR4_FADES_WHILE_LOGGED_OUT))) // Resurrection sickness should not fade while logged out { if (remaintime / IN_MILLISECONDS <= int32(timediff)) continue; @@ -18333,10 +18125,10 @@ void Player::_LoadAuras(PreparedQueryResult result, uint32 timediff) continue; } - aura->SetLoadedState(maxduration, remaintime, remaincharges, stackcount, recalculatemask, &damage[0]); + aura->SetLoadedState(maxduration, remaintime, remaincharges, stackcount, recalculatemask, critChance, applyResilience, &damage[0]); aura->ApplyForTargets(); - LOG_DEBUG("entities.player", "Player::_LoadAuras: Added aura (SpellID: %u, EffectMask: %u) to player '%s (%s)", - spellInfo->Id, effmask, GetName().c_str(), GetGUID().ToString().c_str()); + LOG_DEBUG( + "entities.player", "Player::_LoadAuras: Added aura (SpellID: %u, EffectMask: %u) to player '%s (%s)", spellInfo->Id, effmask, GetName().c_str(), GetGUID().ToString().c_str()); } } while (result->NextRow()); } @@ -18364,14 +18156,11 @@ void Player::_LoadGlyphAuras() GetName().c_str(), GetGUID().ToString().c_str(), gp->GlyphSlotFlags, gs->Type); } else - LOG_ERROR("entities.player", - "Player::_LoadGlyphAuras: Player '%s' (%s) has not existing glyph slot entry %u on index %u", - GetName().c_str(), GetGUID().ToString().c_str(), GetGlyphSlot(i), i); + LOG_ERROR("entities.player", "Player::_LoadGlyphAuras: Player '%s' (%s) has not existing glyph slot entry %u on index %u", GetName().c_str(), GetGUID().ToString().c_str(), + GetGlyphSlot(i), i); } else - LOG_ERROR("entities.player", - "Player::_LoadGlyphAuras: Player '%s' (%s) has not existing glyph entry %u on index %u", GetName().c_str(), - GetGUID().ToString().c_str(), glyph, i); + LOG_ERROR("entities.player", "Player::_LoadGlyphAuras: Player '%s' (%s) has not existing glyph entry %u on index %u", GetName().c_str(), GetGUID().ToString().c_str(), glyph, i); // On any error remove glyph SetGlyph(i, 0); @@ -18391,10 +18180,8 @@ void Player::LoadCorpse(PreparedQueryResult result) else if (result) { Field* fields = result->Fetch(); - _corpseLocation.WorldRelocate( - fields[0].GetUInt16(), fields[1].GetFloat(), fields[2].GetFloat(), fields[3].GetFloat(), fields[4].GetFloat()); - ApplyModByteFlag(PLAYER_FIELD_BYTES, PLAYER_FIELD_BYTES_OFFSET_FLAGS, PLAYER_FIELD_BYTE_RELEASE_TIMER, - !sMapStore.LookupEntry(_corpseLocation.GetMapId())->Instanceable()); + _corpseLocation.WorldRelocate(fields[0].GetUInt16(), fields[1].GetFloat(), fields[2].GetFloat(), fields[3].GetFloat(), fields[4].GetFloat()); + ApplyModByteFlag(PLAYER_FIELD_BYTES, PLAYER_FIELD_BYTES_OFFSET_FLAGS, PLAYER_FIELD_BYTE_RELEASE_TIMER, !sMapStore.LookupEntry(_corpseLocation.GetMapId())->Instanceable()); } } @@ -18483,8 +18270,7 @@ void Player::_LoadInventory(PreparedQueryResult result, uint32 timeDiff) else if (invalidBagMap.find(bagGuid) != invalidBagMap.end()) { std::map::iterator invalidBagItr = invalidBagMap.find(bagGuid); - if (std::find(problematicItems.begin(), problematicItems.end(), invalidBagItr->second) != - problematicItems.end()) + if (std::find(problematicItems.begin(), problematicItems.end(), invalidBagItr->second) != problematicItems.end()) err = EQUIP_ERR_INTERNAL_BAG_ERROR; } else @@ -18492,8 +18278,7 @@ void Player::_LoadInventory(PreparedQueryResult result, uint32 timeDiff) LOG_ERROR("entities.player", "Player::_LoadInventory: Player '%s' (%s) has item (%s, entry: %u) which doesnt have a valid bag " "(Bag %u, slot: %u). Possible cheat?", - GetName().c_str(), GetGUID().ToString().c_str(), item->GetGUID().ToString().c_str(), item->GetEntry(), - bagGuid, slot); + GetName().c_str(), GetGUID().ToString().c_str(), item->GetGUID().ToString().c_str(), item->GetEntry(), bagGuid, slot); item->DeleteFromInventoryDB(trans); delete item; continue; @@ -18508,8 +18293,7 @@ void Player::_LoadInventory(PreparedQueryResult result, uint32 timeDiff) LOG_ERROR("entities.player", "Player::_LoadInventory: Player '%s' (%s) has item (%s, entry: %u) which can't be loaded into inventory " "(Bag %u, slot: %u) by reason %u. Item will be sent by mail.", - GetName().c_str(), GetGUID().ToString().c_str(), item->GetGUID().ToString().c_str(), item->GetEntry(), - bagGuid, slot, uint32(err)); + GetName().c_str(), GetGUID().ToString().c_str(), item->GetGUID().ToString().c_str(), item->GetEntry(), bagGuid, slot, uint32(err)); item->DeleteFromInventoryDB(trans); problematicItems.push_back(item); } @@ -18556,27 +18340,21 @@ void Player::_LoadVoidStorage(PreparedQueryResult result) if (!itemId) { - LOG_ERROR("entities.player", - "Player::_LoadVoidStorage - Player (GUID: %u, name: %s) has an item with an invalid id (item id: " UI64FMTD - ", entry: %u).", - GetGUID().GetCounter(), GetName().c_str(), itemId, itemEntry); + LOG_ERROR("entities.player", "Player::_LoadVoidStorage - Player (GUID: %u, name: %s) has an item with an invalid id (item id: " UI64FMTD ", entry: %u).", GetGUID().GetCounter(), + GetName().c_str(), itemId, itemEntry); continue; } if (!sObjectMgr->GetItemTemplate(itemEntry)) { - LOG_ERROR("entities.player", - "Player::_LoadVoidStorage - Player (GUID: %u, name: %s) has an item with an invalid entry (item id: " UI64FMTD - ", entry: %u).", - GetGUID().GetCounter(), GetName().c_str(), itemId, itemEntry); + LOG_ERROR("entities.player", "Player::_LoadVoidStorage - Player (GUID: %u, name: %s) has an item with an invalid entry (item id: " UI64FMTD ", entry: %u).", GetGUID().GetCounter(), + GetName().c_str(), itemId, itemEntry); continue; } if (slot >= VOID_STORAGE_MAX_SLOT) { - LOG_ERROR("entities.player", - "Player::_LoadVoidStorage - Player (GUID: %u, name: %s) has an item with an invalid slot (item id: " UI64FMTD - ", entry: %u, slot: %u).", + LOG_ERROR("entities.player", "Player::_LoadVoidStorage - Player (GUID: %u, name: %s) has an item with an invalid slot (item id: " UI64FMTD ", entry: %u, slot: %u).", GetGUID().GetCounter(), GetName().c_str(), itemId, itemEntry, slot); continue; } @@ -18614,8 +18392,7 @@ Item* Player::_LoadItem(CharacterDatabaseTransaction& trans, uint32 zoneId, uint LOG_DEBUG("entities.player.loading", "Player::_LoadInventory: player (GUID: %u, name: '%s', map: %u) has item (GUID: %u, entry: %u) limited to " "another map (%u). Deleting item.", - GetGUID().GetCounter(), GetName().c_str(), GetMapId(), item->GetGUID().GetCounter(), item->GetEntry(), - zoneId); + GetGUID().GetCounter(), GetName().c_str(), GetMapId(), item->GetGUID().GetCounter(), item->GetEntry(), zoneId); remove = true; } // "Conjured items disappear if you are logged out for more than 15 minutes" @@ -18634,8 +18411,7 @@ Item* Player::_LoadItem(CharacterDatabaseTransaction& trans, uint32 zoneId, uint LOG_DEBUG("entities.player.loading", "Player::_LoadInventory: player (GUID: %u, name: '%s') has item (GUID: %u, entry: %u) with expired " "refund time (%u). Deleting refund data and removing refundable flag.", - GetGUID().GetCounter(), GetName().c_str(), item->GetGUID().GetCounter(), item->GetEntry(), - item->GetPlayedTime(this)); + GetGUID().GetCounter(), GetName().c_str(), item->GetGUID().GetCounter(), item->GetEntry(), item->GetPlayedTime(this)); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_REFUND_INSTANCE); stmt->setUInt32(0, item->GetGUID().GetCounter()); @@ -18699,8 +18475,7 @@ Item* Player::_LoadItem(CharacterDatabaseTransaction& trans, uint32 zoneId, uint remove = true; GameEventMgr::GameEventDataMap const& events = sGameEventMgr->GetEventMap(); GameEventMgr::ActiveEvents const& activeEventsList = sGameEventMgr->GetActiveEventList(); - for (GameEventMgr::ActiveEvents::const_iterator itr = activeEventsList.begin(); itr != activeEventsList.end(); - ++itr) + for (GameEventMgr::ActiveEvents::const_iterator itr = activeEventsList.begin(); itr != activeEventsList.end(); ++itr) { if (uint32(events[*itr].holiday_id) == proto->GetHolidayID()) { @@ -18729,9 +18504,8 @@ Item* Player::_LoadItem(CharacterDatabaseTransaction& trans, uint32 zoneId, uint } else { - LOG_ERROR("entities.player", - "Player::_LoadInventory: player (GUID: %u, name: '%s') has an unknown item (entry: %u) in inventory. Deleting item.", - GetGUID().GetCounter(), GetName().c_str(), itemEntry); + LOG_ERROR("entities.player", "Player::_LoadInventory: player (GUID: %u, name: '%s') has an unknown item (entry: %u) in inventory. Deleting item.", GetGUID().GetCounter(), GetName().c_str(), + itemEntry); Item::DeleteFromInventoryDB(trans, itemGuid); Item::DeleteFromDB(trans, itemGuid); } @@ -18747,9 +18521,8 @@ Item* Player::_LoadMailedItem(ObjectGuid const& playerGuid, Player* player, uint ItemTemplate const* proto = sObjectMgr->GetItemTemplate(itemEntry); if (!proto) { - LOG_ERROR("entities.player", - "Player '%s' (%s) has unknown item in mailed items (GUID: %u, Entry: %u) in mail (%u), deleted.", - player ? player->GetName().c_str() : "", playerGuid.ToString().c_str(), itemGuid, itemEntry, mailId); + LOG_ERROR("entities.player", "Player '%s' (%s) has unknown item in mailed items (GUID: %u, Entry: %u) in mail (%u), deleted.", player ? player->GetName().c_str() : "", + playerGuid.ToString().c_str(), itemGuid, itemEntry, mailId); CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction(); @@ -18765,12 +18538,10 @@ Item* Player::_LoadMailedItem(ObjectGuid const& playerGuid, Player* player, uint Item* item = NewItemOrBag(proto); - ObjectGuid ownerGuid = - fields[14].GetUInt32() ? ObjectGuid::Create(fields[14].GetUInt32()) : ObjectGuid::Empty; + ObjectGuid ownerGuid = fields[14].GetUInt32() ? ObjectGuid::Create(fields[14].GetUInt32()) : ObjectGuid::Empty; if (!item->LoadFromDB(itemGuid, ownerGuid, fields, itemEntry)) { - LOG_ERROR("entities.player", "Player::_LoadMailedItems: Item (GUID: %u) in mail (%u) doesn't exist, deleted from mail.", - itemGuid, mailId); + LOG_ERROR("entities.player", "Player::_LoadMailedItems: Item (GUID: %u) in mail (%u) doesn't exist, deleted from mail.", itemGuid, mailId); CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_MAIL_ITEM); stmt->setUInt32(0, itemGuid); @@ -18821,8 +18592,7 @@ void Player::_LoadMail(PreparedQueryResult mailsResult, PreparedQueryResult mail if (m->mailTemplateId && !sMailTemplateStore.LookupEntry(m->mailTemplateId)) { - LOG_ERROR("entities.player", "Player::_LoadMail: Mail (%u) has nonexistent MailTemplateId (%u), remove at load", - m->messageID, m->mailTemplateId); + LOG_ERROR("entities.player", "Player::_LoadMail: Mail (%u) has nonexistent MailTemplateId (%u), remove at load", m->messageID, m->mailTemplateId); m->mailTemplateId = 0; } @@ -18979,7 +18749,10 @@ void Player::DeleteFromPlayerPetDataStore(uint32 petNumber) } } -void Player::AddToPlayerPetDataStore(PlayerPetData* playerPetData) { PlayerPetDataStore.push_back(playerPetData); } +void Player::AddToPlayerPetDataStore(PlayerPetData* playerPetData) +{ + PlayerPetDataStore.push_back(playerPetData); +} void Player::_LoadQuestStatus(PreparedQueryResult result) { @@ -19063,9 +18836,7 @@ void Player::_LoadQuestStatus(PreparedQueryResult result) ++slot; } - LOG_DEBUG("entities.player.loading", - "Player::_LoadQuestStatus: Quest status is {%u} for quest {%u} for player (%s)", questStatusData.Status, - quest_id, GetGUID().ToString().c_str()); + LOG_DEBUG("entities.player.loading", "Player::_LoadQuestStatus: Quest status is {%u} for quest {%u} for player (%s)", questStatusData.Status, quest_id, GetGUID().ToString().c_str()); } } while (result->NextRow()); } @@ -19128,9 +18899,7 @@ void Player::_LoadDailyQuestStatus(PreparedQueryResult result) if (quest_daily_idx >= PLAYER_MAX_DAILY_QUESTS) // max amount with exist data in query { - LOG_ERROR("entities.player", - "Player (GUID: %u) has more than 25 daily quest records in `charcter_queststatus_daily`", - GetGUID().GetCounter()); + LOG_ERROR("entities.player", "Player (GUID: %u) has more than 25 daily quest records in `charcter_queststatus_daily`", GetGUID().GetCounter()); break; } @@ -19146,9 +18915,8 @@ void Player::_LoadDailyQuestStatus(PreparedQueryResult result) SetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1 + quest_daily_idx, quest_id); ++quest_daily_idx; - LOG_DEBUG("entities.player.loading", - "Player::_LoadDailyQuestStatus: Loaded daily quest cooldown (QuestID: %u) for player '%s' (%s)", quest_id, - GetName().c_str(), GetGUID().ToString().c_str()); + LOG_DEBUG( + "entities.player.loading", "Player::_LoadDailyQuestStatus: Loaded daily quest cooldown (QuestID: %u) for player '%s' (%s)", quest_id, GetName().c_str(), GetGUID().ToString().c_str()); } while (result->NextRow()); } @@ -19171,9 +18939,8 @@ void Player::_LoadWeeklyQuestStatus(PreparedQueryResult result) m_weeklyquests.insert(quest_id); - LOG_DEBUG("entities.player.loading", - "Player::_LoadWeeklyQuestStatus: Loaded weekly quest cooldown (QuestID: %u) for player '%s' (%s)", quest_id, - GetName().c_str(), GetGUID().ToString().c_str()); + LOG_DEBUG("entities.player.loading", "Player::_LoadWeeklyQuestStatus: Loaded weekly quest cooldown (QuestID: %u) for player '%s' (%s)", quest_id, GetName().c_str(), + GetGUID().ToString().c_str()); } while (result->NextRow()); } @@ -19196,9 +18963,8 @@ void Player::_LoadSeasonalQuestStatus(PreparedQueryResult result) continue; m_seasonalquests[event_id].insert(quest_id); - LOG_DEBUG("entities.player.loading", - "Player::_LoadSeasonalQuestStatus: Loaded seasonal quest cooldown (QuestID: %u) for player '%s' (%s)", quest_id, - GetName().c_str(), GetGUID().ToString().c_str()); + LOG_DEBUG("entities.player.loading", "Player::_LoadSeasonalQuestStatus: Loaded seasonal quest cooldown (QuestID: %u) for player '%s' (%s)", quest_id, GetName().c_str(), + GetGUID().ToString().c_str()); } while (result->NextRow()); } @@ -19220,9 +18986,8 @@ void Player::_LoadMonthlyQuestStatus(PreparedQueryResult result) continue; m_monthlyquests.insert(quest_id); - LOG_DEBUG("entities.player.loading", - "Player::_LoadMonthlyQuestStatus: Loaded monthly quest cooldown (QuestID: %u) for player '%s' (%s)", quest_id, - GetName().c_str(), GetGUID().ToString().c_str()); + LOG_DEBUG("entities.player.loading", "Player::_LoadMonthlyQuestStatus: Loaded monthly quest cooldown (QuestID: %u) for player '%s' (%s)", quest_id, GetName().c_str(), + GetGUID().ToString().c_str()); } while (result->NextRow()); } @@ -19243,9 +19008,8 @@ void Player::_LoadLFGRewardStatus(PreparedQueryResult result) uint8 daily_reset = fields[2].GetUInt8(); m_lfgrewardstatus[dungeon_id] = LFGRewardInfo(reward_count, daily_reset); - LOG_DEBUG("entities.player.loading", - "Player::_LFGQuestStatus: Loaded LFG quest first reward cooldown (DungeonID: %u) for player '%s' (%s)", - dungeon_id, GetName().c_str(), GetGUID().ToString().c_str()); + LOG_DEBUG("entities.player.loading", "Player::_LFGQuestStatus: Loaded LFG quest first reward cooldown (DungeonID: %u) for player '%s' (%s)", dungeon_id, GetName().c_str(), + GetGUID().ToString().c_str()); } while (result->NextRow()); } @@ -19325,9 +19089,8 @@ void Player::_LoadBoundInstances(PreparedQueryResult result) if (!mapEntry || !mapEntry->IsDungeon()) { - LOG_ERROR("entities.player", - "Player::_LoadBoundInstances: Player '%s' (%s) has bind to not existed or not dungeon map %d (%s)", - GetName().c_str(), GetGUID().ToString().c_str(), mapId, mapname.c_str()); + LOG_ERROR("entities.player", "Player::_LoadBoundInstances: Player '%s' (%s) has bind to not existed or not dungeon map %d (%s)", GetName().c_str(), GetGUID().ToString().c_str(), mapId, + mapname.c_str()); deleteInstance = true; } else if (difficulty >= MAX_DIFFICULTY) @@ -19354,16 +19117,14 @@ void Player::_LoadBoundInstances(PreparedQueryResult result) LOG_ERROR("entities.player", "Player::_LoadBoundInstances: player '%s' (%s) is in group %s but has a non-permanent character bind to " "map %d (%s), %d, %d", - GetName().c_str(), GetGUID().ToString().c_str(), group->GetGUID().ToString().c_str(), mapId, - mapname.c_str(), instanceId, difficulty); + GetName().c_str(), GetGUID().ToString().c_str(), group->GetGUID().ToString().c_str(), mapId, mapname.c_str(), instanceId, difficulty); deleteInstance = true; } } if (deleteInstance) { - CharacterDatabasePreparedStatement* stmt = - CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_INSTANCE_BY_INSTANCE_GUID); + CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_INSTANCE_BY_INSTANCE_GUID); stmt->setUInt32(0, GetGUID().GetCounter()); stmt->setUInt32(1, instanceId); @@ -19374,8 +19135,7 @@ void Player::_LoadBoundInstances(PreparedQueryResult result) } // since non permanent binds are always solo bind, they can always be reset - if (InstanceSave* save = - sInstanceSaveMgr->AddInstanceSave(mapId, instanceId, Difficulty(difficulty), resetTime, !perm, true)) + if (InstanceSave* save = sInstanceSaveMgr->AddInstanceSave(mapId, instanceId, Difficulty(difficulty), resetTime, !perm, true)) BindToInstance(save, perm, extendState, true); } while (result->NextRow()); } @@ -19433,8 +19193,7 @@ void Player::UnbindInstance(BoundInstancesMap::iterator& itr, Difficulty difficu { if (!unload) { - CharacterDatabasePreparedStatement* stmt = - CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_INSTANCE_BY_INSTANCE_GUID); + CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_INSTANCE_BY_INSTANCE_GUID); stmt->setUInt32(0, GetGUID().GetCounter()); stmt->setUInt32(1, itr->second.save->GetInstanceId()); @@ -19455,8 +19214,7 @@ InstancePlayerBind* Player::BindToInstance(InstanceSave* save, bool permanent, B if (save) { InstancePlayerBind& bind = m_boundInstances[save->GetDifficulty()][save->GetMapId()]; - if (extendState == - EXTEND_STATE_KEEP) // special flag, keep the player's current extend state when updating for new boss down + if (extendState == EXTEND_STATE_KEEP) // special flag, keep the player's current extend state when updating for new boss down { if (save == bind.save) extendState = bind.extendState; @@ -19508,9 +19266,8 @@ InstancePlayerBind* Player::BindToInstance(InstanceSave* save, bool permanent, B bind.perm = permanent; bind.extendState = extendState; if (!load) - LOG_DEBUG("maps", - "Player::BindToInstance: Player '%s' (%s) is now bound to map (ID: %d, Instance: %d, Difficulty: %d)", - GetName().c_str(), GetGUID().ToString().c_str(), save->GetMapId(), save->GetInstanceId(), save->GetDifficulty()); + LOG_DEBUG("maps", "Player::BindToInstance: Player '%s' (%s) is now bound to map (ID: %d, Instance: %d, Difficulty: %d)", GetName().c_str(), GetGUID().ToString().c_str(), save->GetMapId(), + save->GetInstanceId(), save->GetDifficulty()); sScriptMgr->OnPlayerBindToInstance(this, save->GetDifficulty(), save->GetMapId(), permanent, extendState); return &bind; } @@ -19560,8 +19317,7 @@ void Player::SendRaidInfo() lockInfos.Heroic = (difficulty == RAID_DIFFICULTY_10MAN_HEROIC || difficulty == RAID_DIFFICULTY_25MAN_HEROIC); if (lockInfos.Heroic) - lockInfos.Difficulty = - difficulty == RAID_DIFFICULTY_10MAN_HEROIC ? RAID_DIFFICULTY_10MAN_NORMAL : RAID_DIFFICULTY_25MAN_NORMAL; + lockInfos.Difficulty = difficulty == RAID_DIFFICULTY_10MAN_HEROIC ? RAID_DIFFICULTY_10MAN_NORMAL : RAID_DIFFICULTY_25MAN_NORMAL; else lockInfos.Difficulty = difficulty; @@ -19570,9 +19326,7 @@ void Player::SendRaidInfo() if (bind.extendState != EXTEND_STATE_EXTENDED) lockInfos.TimeRemaining = save->GetResetTime() - now; else - lockInfos.TimeRemaining = - sInstanceSaveMgr->GetSubsequentResetTime(save->GetMapId(), save->GetDifficulty(), save->GetResetTime()) - - now; + lockInfos.TimeRemaining = sInstanceSaveMgr->GetSubsequentResetTime(save->GetMapId(), save->GetDifficulty(), save->GetResetTime()) - now; if (Map* map = sMapMgr->FindMap(save->GetMapId(), save->GetInstanceId())) if (InstanceScript* instanceScript = ((InstanceMap*)map)->GetInstanceScript()) @@ -19794,8 +19548,7 @@ bool Player::_LoadHomeBind(PreparedQueryResult result) PlayerInfo const* info = sObjectMgr->GetPlayerInfo(getRace(), getClass()); if (!info) { - LOG_ERROR("entities.player", "Player (Name %s) has incorrect race/class (%u/%u) pair. Can't be loaded.", - GetName().c_str(), uint32(getRace()), uint32(getClass())); + LOG_ERROR("entities.player", "Player (Name %s) has incorrect race/class (%u/%u) pair. Can't be loaded.", GetName().c_str(), uint32(getRace()), uint32(getClass())); return false; } @@ -19814,8 +19567,7 @@ bool Player::_LoadHomeBind(PreparedQueryResult result) MapEntry const* bindMapEntry = sMapStore.LookupEntry(m_homebindMapId); // accept saved data only for valid position (and non instanceable), and accessable - if (MapManager::IsValidMapCoord(m_homebindMapId, m_homebindX, m_homebindY, m_homebindZ) && - !bindMapEntry->Instanceable() && GetSession()->GetExpansion() >= bindMapEntry->Expansion()) + if (MapManager::IsValidMapCoord(m_homebindMapId, m_homebindX, m_homebindY, m_homebindZ) && !bindMapEntry->Instanceable() && GetSession()->GetExpansion() >= bindMapEntry->Expansion()) ok = true; else { @@ -19843,10 +19595,8 @@ bool Player::_LoadHomeBind(PreparedQueryResult result) CharacterDatabase.Execute(stmt); } - LOG_DEBUG("entities.player", - "Player::_LoadHomeBind: Setting home position (MapID: %u, AreaID: %u, X: %f, Y: %f, Z: %f) of player '%s' (%s)", - m_homebindMapId, m_homebindAreaId, m_homebindX, m_homebindY, m_homebindZ, GetName().c_str(), - GetGUID().ToString().c_str()); + LOG_DEBUG("entities.player", "Player::_LoadHomeBind: Setting home position (MapID: %u, AreaID: %u, X: %f, Y: %f, Z: %f) of player '%s' (%s)", m_homebindMapId, m_homebindAreaId, m_homebindX, + m_homebindY, m_homebindZ, GetName().c_str(), GetGUID().ToString().c_str()); return true; } @@ -19904,9 +19654,8 @@ void Player::SaveToDB(CharacterDatabaseTransaction trans, bool create /* = false stmt->setString(index++, GetName()); stmt->setUInt8(index++, getRace()); stmt->setUInt8(index++, getClass()); - stmt->setUInt8( - index++, GetByteValue(PLAYER_BYTES_3, PLAYER_BYTES_3_OFFSET_GENDER)); // save gender from PLAYER_BYTES_3, UNIT_BYTES_0 - // changes with every transform effect + stmt->setUInt8(index++, GetByteValue(PLAYER_BYTES_3, PLAYER_BYTES_3_OFFSET_GENDER)); // save gender from PLAYER_BYTES_3, UNIT_BYTES_0 + // changes with every transform effect stmt->setUInt8(index++, getLevel()); stmt->setUInt32(index++, GetUInt32Value(PLAYER_XP)); stmt->setUInt64(index++, GetMoney()); @@ -20026,9 +19775,8 @@ void Player::SaveToDB(CharacterDatabaseTransaction trans, bool create /* = false stmt->setString(index++, GetName()); stmt->setUInt8(index++, getRace()); stmt->setUInt8(index++, getClass()); - stmt->setUInt8( - index++, GetByteValue(PLAYER_BYTES_3, PLAYER_BYTES_3_OFFSET_GENDER)); // save gender from PLAYER_BYTES_3, UNIT_BYTES_0 - // changes with every transform effect + stmt->setUInt8(index++, GetByteValue(PLAYER_BYTES_3, PLAYER_BYTES_3_OFFSET_GENDER)); // save gender from PLAYER_BYTES_3, UNIT_BYTES_0 + // changes with every transform effect stmt->setUInt8(index++, getLevel()); stmt->setUInt32(index++, GetUInt32Value(PLAYER_XP)); stmt->setUInt64(index++, GetMoney()); @@ -20328,6 +20076,9 @@ void Player::_SaveAuras(CharacterDatabaseTransaction& trans) stmt->setInt32(index++, itr->second->GetMaxDuration()); stmt->setInt32(index++, itr->second->GetDuration()); stmt->setUInt8(index, itr->second->GetCharges()); + stmt->setUInt8(index++, itr->second->GetCharges()); + stmt->setFloat(index++, itr->second->GetCritChance()); + stmt->setBool(index++, itr->second->CanApplyResilience()); trans->Append(stmt); } } @@ -20385,9 +20136,8 @@ void Player::_SaveInventory(CharacterDatabaseTransaction& trans) } else { - LOG_ERROR("entities.player", - "Player::_SaveInventory: Can't find item (%s) in refundable storage for player '%s' (%s), removing.", - itr->ToString().c_str(), GetName().c_str(), GetGUID().ToString().c_str()); + LOG_ERROR("entities.player", "Player::_SaveInventory: Can't find item (%s) in refundable storage for player '%s' (%s), removing.", itr->ToString().c_str(), GetName().c_str(), + GetGUID().ToString().c_str()); m_refundableItems.erase(itr); } } @@ -20422,8 +20172,7 @@ void Player::_SaveInventory(CharacterDatabaseTransaction& trans) LOG_ERROR("entities.player", "Player::_SaveInventory: Player '%s' (%s) has incorrect values (Bag: %u, Slot: %u) for the item (%s, State: " "%d). The player doesn't have an item at that position.", - GetName().c_str(), GetGUID().ToString().c_str(), item->GetBagSlot(), item->GetSlot(), - item->GetGUID().ToString().c_str(), (int32)item->GetState()); + GetName().c_str(), GetGUID().ToString().c_str(), item->GetBagSlot(), item->GetSlot(), item->GetGUID().ToString().c_str(), (int32)item->GetState()); // according to the test that was just performed nothing should be in this slot, delete stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_INVENTORY_BY_BAG_SLOT); stmt->setUInt32(0, bagTestGUID); @@ -20446,8 +20195,7 @@ void Player::_SaveInventory(CharacterDatabaseTransaction& trans) LOG_ERROR("entities.player", "Player::_SaveInventory: Player '%s' (%s) has incorrect values (Bag: %u, Slot: %u) for the item (%s). %s is " "there instead!", - GetName().c_str(), GetGUID().ToString().c_str(), item->GetBagSlot(), item->GetSlot(), - item->GetGUID().ToString().c_str(), test->GetGUID().ToString().c_str()); + GetName().c_str(), GetGUID().ToString().c_str(), item->GetBagSlot(), item->GetSlot(), item->GetGUID().ToString().c_str(), test->GetGUID().ToString().c_str()); // save all changes to the item... if (item->GetState() != ITEM_NEW) // only for existing items, no duplicates item->SaveToDB(trans); @@ -20969,20 +20717,13 @@ void Player::outDebugValues() const LOG_DEBUG("entities.unit", "INTELLECT is: \t\t%f\t\tSPIRIT is: \t\t%f", GetStat(STAT_INTELLECT), GetStat(STAT_SPIRIT)); LOG_DEBUG("entities.unit", "STAMINA is: \t\t%f", GetStat(STAT_STAMINA)); LOG_DEBUG("entities.unit", "Armor is: \t\t%u\t\tBlock is: \t\t%f", GetArmor(), GetFloatValue(PLAYER_BLOCK_PERCENTAGE)); - LOG_DEBUG("entities.unit", "HolyRes is: \t\t%u\t\tFireRes is: \t\t%u", GetResistance(SPELL_SCHOOL_HOLY), - GetResistance(SPELL_SCHOOL_FIRE)); - LOG_DEBUG("entities.unit", "NatureRes is: \t\t%u\t\tFrostRes is: \t\t%u", GetResistance(SPELL_SCHOOL_NATURE), - GetResistance(SPELL_SCHOOL_FROST)); - LOG_DEBUG("entities.unit", "ShadowRes is: \t\t%u\t\tArcaneRes is: \t\t%u", GetResistance(SPELL_SCHOOL_SHADOW), - GetResistance(SPELL_SCHOOL_ARCANE)); - LOG_DEBUG("entities.unit", "MIN_DAMAGE is: \t\t%f\tMAX_DAMAGE is: \t\t%f", GetFloatValue(UNIT_FIELD_MINDAMAGE), - GetFloatValue(UNIT_FIELD_MAXDAMAGE)); - LOG_DEBUG("entities.unit", "MIN_OFFHAND_DAMAGE is: \t%f\tMAX_OFFHAND_DAMAGE is: \t%f", - GetFloatValue(UNIT_FIELD_MINOFFHANDDAMAGE), GetFloatValue(UNIT_FIELD_MAXOFFHANDDAMAGE)); - LOG_DEBUG("entities.unit", "MIN_RANGED_DAMAGE is: \t%f\tMAX_RANGED_DAMAGE is: \t%f", - GetFloatValue(UNIT_FIELD_MINRANGEDDAMAGE), GetFloatValue(UNIT_FIELD_MAXRANGEDDAMAGE)); - LOG_DEBUG("entities.unit", "ATTACK_TIME is: \t%u\t\tRANGE_ATTACK_TIME is: \t%u", GetAttackTime(BASE_ATTACK), - GetAttackTime(RANGED_ATTACK)); + LOG_DEBUG("entities.unit", "HolyRes is: \t\t%u\t\tFireRes is: \t\t%u", GetResistance(SPELL_SCHOOL_HOLY), GetResistance(SPELL_SCHOOL_FIRE)); + LOG_DEBUG("entities.unit", "NatureRes is: \t\t%u\t\tFrostRes is: \t\t%u", GetResistance(SPELL_SCHOOL_NATURE), GetResistance(SPELL_SCHOOL_FROST)); + LOG_DEBUG("entities.unit", "ShadowRes is: \t\t%u\t\tArcaneRes is: \t\t%u", GetResistance(SPELL_SCHOOL_SHADOW), GetResistance(SPELL_SCHOOL_ARCANE)); + LOG_DEBUG("entities.unit", "MIN_DAMAGE is: \t\t%f\tMAX_DAMAGE is: \t\t%f", GetFloatValue(UNIT_FIELD_MINDAMAGE), GetFloatValue(UNIT_FIELD_MAXDAMAGE)); + LOG_DEBUG("entities.unit", "MIN_OFFHAND_DAMAGE is: \t%f\tMAX_OFFHAND_DAMAGE is: \t%f", GetFloatValue(UNIT_FIELD_MINOFFHANDDAMAGE), GetFloatValue(UNIT_FIELD_MAXOFFHANDDAMAGE)); + LOG_DEBUG("entities.unit", "MIN_RANGED_DAMAGE is: \t%f\tMAX_RANGED_DAMAGE is: \t%f", GetFloatValue(UNIT_FIELD_MINRANGEDDAMAGE), GetFloatValue(UNIT_FIELD_MAXRANGEDDAMAGE)); + LOG_DEBUG("entities.unit", "ATTACK_TIME is: \t%u\t\tRANGE_ATTACK_TIME is: \t%u", GetAttackTime(BASE_ATTACK), GetAttackTime(RANGED_ATTACK)); } /*********************************************************/ @@ -21019,7 +20760,10 @@ void Player::UpdateSpeakTime() m_speakTime = current + sWorld->getIntConfig(CONFIG_CHATFLOOD_MESSAGE_DELAY); } -bool Player::CanSpeak() const { return GetSession()->m_muteTime <= time(nullptr); } +bool Player::CanSpeak() const +{ + return GetSession()->m_muteTime <= time(nullptr); +} /*********************************************************/ /*** LOW LEVEL FUNCTIONS:Notifiers ***/ @@ -21320,8 +21064,8 @@ void Player::RemovePet(Pet* pet, PetSaveMode mode, bool returnreagent) if (pet) { - LOG_DEBUG("entities.pet", "Player::RemovePet: Player '%s' (%s), Pet (Entry: %u, Mode: %u, ReturnReagent: %u)", - GetName().c_str(), GetGUID().ToString().c_str(), pet->GetEntry(), mode, returnreagent); + LOG_DEBUG( + "entities.pet", "Player::RemovePet: Player '%s' (%s), Pet (Entry: %u, Mode: %u, ReturnReagent: %u)", GetName().c_str(), GetGUID().ToString().c_str(), pet->GetEntry(), mode, returnreagent); if (pet->m_removed) return; @@ -21341,8 +21085,7 @@ void Player::RemovePet(Pet* pet, PetSaveMode mode, bool returnreagent) { ItemPosCountVec dest; // for succubus, voidwalker, felhunter and felguard credit soulshard when despawn // reason other than death (out of range, logout) - InventoryResult msg = - CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, spellInfo->Reagent[i], spellInfo->ReagentCount[i]); + InventoryResult msg = CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, spellInfo->Reagent[i], spellInfo->ReagentCount[i]); if (msg == EQUIP_ERR_OK) { Item* item = StoreNewItem(dest, spellInfo->Reagent[i], true); @@ -21439,12 +21182,11 @@ void Player::StopCastingCharm() if (GetCharmedGUID()) { - LOG_FATAL("entities.player", "Player::StopCastingCharm: Player '%s' (%s) is not able to uncharm unit (%s)", - GetName().c_str(), GetGUID().ToString().c_str(), GetCharmedGUID().ToString().c_str()); + LOG_FATAL( + "entities.player", "Player::StopCastingCharm: Player '%s' (%s) is not able to uncharm unit (%s)", GetName().c_str(), GetGUID().ToString().c_str(), GetCharmedGUID().ToString().c_str()); if (!charm->GetCharmerGUID().IsEmpty()) { - LOG_FATAL("entities.player", "Player::StopCastingCharm: Charmed unit has charmer %s", - charm->GetCharmerGUID().ToString().c_str()); + LOG_FATAL("entities.player", "Player::StopCastingCharm: Charmed unit has charmer %s", charm->GetCharmerGUID().ToString().c_str()); ABORT(); } @@ -21489,8 +21231,7 @@ void Player::TextEmote(std::string const& text, WorldObject const* /*= nullptr*/ WorldPacket data; ChatHandler::BuildChatPacket(data, CHAT_MSG_EMOTE, LANG_UNIVERSAL, this, this, _text); - SendMessageToSetInRange(&data, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE), true, - !GetSession()->HasPermission(rbac::RBAC_PERM_TWO_SIDE_INTERACTION_CHAT)); + SendMessageToSetInRange(&data, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE), true, !GetSession()->HasPermission(rbac::RBAC_PERM_TWO_SIDE_INTERACTION_CHAT)); } void Player::TextEmote(uint32 textId, WorldObject const* target /*= nullptr*/, bool /*isBossEmote = false*/) @@ -21524,8 +21265,7 @@ void Player::Whisper(std::string const& text, Language language, Player* target, sScriptMgr->OnPlayerChat(this, isBossWhisper ? CHAT_MSG_RAID_BOSS_WHISPER : CHAT_MSG_WHISPER, language, _text, target); WorldPacket data; - ChatHandler::BuildChatPacket( - data, isBossWhisper ? CHAT_MSG_RAID_BOSS_WHISPER : CHAT_MSG_WHISPER, Language(language), this, this, _text); + ChatHandler::BuildChatPacket(data, isBossWhisper ? CHAT_MSG_RAID_BOSS_WHISPER : CHAT_MSG_WHISPER, Language(language), this, this, _text); target->SendDirectMessage(&data); // rest stuff shouldn't happen in case of addon message @@ -21562,8 +21302,7 @@ void Player::Whisper(uint32 textId, Player* target, bool isBossWhisper) LocaleConstant locale = target->GetSession()->GetSessionDbLocaleIndex(); WorldPacket data; - ChatHandler::BuildChatPacket(data, isBossWhisper ? CHAT_MSG_RAID_BOSS_WHISPER : CHAT_MSG_WHISPER, LANG_UNIVERSAL, this, - target, bct->GetText(locale, getGender()), 0, "", locale); + ChatHandler::BuildChatPacket(data, isBossWhisper ? CHAT_MSG_RAID_BOSS_WHISPER : CHAT_MSG_WHISPER, LANG_UNIVERSAL, this, target, bct->GetText(locale, getGender()), 0, "", locale); target->SendDirectMessage(&data); } @@ -21580,7 +21319,10 @@ void Player::AddMItem(Item* it) mMitems[it->GetGUID().GetCounter()] = it; } -bool Player::RemoveMItem(uint32 id) { return mMitems.erase(id) ? true : false; } +bool Player::RemoveMItem(uint32 id) +{ + return mMitems.erase(id) ? true : false; +} void Player::SendOnCancelExpectedVehicleRideAura() const { @@ -21679,8 +21421,7 @@ void Player::PossessSpellInitialize() if (!charmInfo) { - LOG_ERROR("entities.player", "Player::PossessSpellInitialize: charm (%s) has no charminfo!", - charm->GetGUID().ToString().c_str()); + LOG_ERROR("entities.player", "Player::PossessSpellInitialize: charm (%s) has no charminfo!", charm->GetGUID().ToString().c_str()); return; } @@ -21727,9 +21468,8 @@ void Player::VehicleSpellInitialize() if (!sConditionMgr->IsObjectMeetingVehicleSpellConditions(vehicle->GetEntry(), spellId, this, vehicle)) { - LOG_DEBUG("condition", - "Player::VehicleSpellInitialize: Player '%s' (%s) doesn't meet conditions for vehicle (Entry: %u, Spell: %u)", - GetName().c_str(), GetGUID().ToString().c_str(), vehicle->ToCreature()->GetEntry(), spellId); + LOG_DEBUG("condition", "Player::VehicleSpellInitialize: Player '%s' (%s) doesn't meet conditions for vehicle (Entry: %u, Spell: %u)", GetName().c_str(), GetGUID().ToString().c_str(), + vehicle->ToCreature()->GetEntry(), spellId); data << uint16(0) << uint8(0) << uint8(i + 8); continue; } @@ -21759,8 +21499,8 @@ void Player::CharmSpellInitialize() CharmInfo* charmInfo = charm->GetCharmInfo(); if (!charmInfo) { - LOG_ERROR("entities.player", "Player::CharmSpellInitialize(): Player '%s' (%s) has a charm (%s) but no no charminfo!", - GetName().c_str(), GetGUID().ToString().c_str(), charm->GetGUID().ToString().c_str()); + LOG_ERROR("entities.player", "Player::CharmSpellInitialize(): Player '%s' (%s) has a charm (%s) but no no charminfo!", GetName().c_str(), GetGUID().ToString().c_str(), + charm->GetGUID().ToString().c_str()); return; } @@ -21935,8 +21675,7 @@ template FC_GAME_API void Player::ApplySpellMod(uint32 spellId, SpellModOp op, f void Player::AddSpellMod(SpellModifier* mod, bool apply) { - LOG_DEBUG("spells", "Player::AddSpellMod: Player '%s' (%s), SpellID: %d", GetName().c_str(), GetGUID().ToString().c_str(), - mod->spellId); + LOG_DEBUG("spells", "Player::AddSpellMod: Player '%s' (%s), SpellID: %d", GetName().c_str(), GetGUID().ToString().c_str(), mod->spellId); /// First, manipulate our spellmodifier container if (apply) @@ -22053,13 +21792,11 @@ void Player::SendSpellModifiers() const } flatMod.ModifierData.erase( - std::remove_if(flatMod.ModifierData.begin(), flatMod.ModifierData.end(), - [](WorldPackets::Spells::SpellModifierData const& mod) { return G3D::fuzzyEq(mod.ModifierValue, 0.0f); }), + std::remove_if(flatMod.ModifierData.begin(), flatMod.ModifierData.end(), [](WorldPackets::Spells::SpellModifierData const& mod) { return G3D::fuzzyEq(mod.ModifierValue, 0.0f); }), flatMod.ModifierData.end()); pctMod.ModifierData.erase( - std::remove_if(pctMod.ModifierData.begin(), pctMod.ModifierData.end(), - [](WorldPackets::Spells::SpellModifierData const& mod) { return G3D::fuzzyEq(mod.ModifierValue, 1.0f); }), + std::remove_if(pctMod.ModifierData.begin(), pctMod.ModifierData.end(), [](WorldPackets::Spells::SpellModifierData const& mod) { return G3D::fuzzyEq(mod.ModifierValue, 1.0f); }), pctMod.ModifierData.end()); flatMods.Modifiers.emplace_back(std::move(flatMod)); @@ -22263,8 +22000,7 @@ bool Player::ActivateTaxiPathTo(std::vector const& nodes, Creature* npc // only one mount ID for both sides. Probably not good to use 315 in case DBC nodes // change but I couldn't find a suitable alternative. OK to use class because only DK // can use this taxi. - uint32 mount_display_id = sObjectMgr->GetTaxiMountDisplayId( - sourcenode, GetTeam(), npc == nullptr || (sourcenode == 315 && getClass() == CLASS_DEATH_KNIGHT)); + uint32 mount_display_id = sObjectMgr->GetTaxiMountDisplayId(sourcenode, GetTeam(), npc == nullptr || (sourcenode == 315 && getClass() == CLASS_DEATH_KNIGHT)); // in spell case allow 0 model if ((mount_display_id == 0 && spellid == 0) || sourcepath == 0) @@ -22373,8 +22109,7 @@ void Player::ContinueTaxiFlight() const distNext = GetExactDistSq(node->Loc.X, node->Loc.Y, node->Loc.Z); - float distNodes = (node->Loc.X - prevNode->Loc.X) * (node->Loc.X - prevNode->Loc.X) + - (node->Loc.Y - prevNode->Loc.Y) * (node->Loc.Y - prevNode->Loc.Y) + + float distNodes = (node->Loc.X - prevNode->Loc.X) * (node->Loc.X - prevNode->Loc.X) + (node->Loc.Y - prevNode->Loc.Y) * (node->Loc.Y - prevNode->Loc.Y) + (node->Loc.Z - prevNode->Loc.Z) * (node->Loc.Z - prevNode->Loc.Z); if (distNext + distPrev < distNodes) @@ -22398,8 +22133,7 @@ void Player::SendTaxiNodeStatusMultiple() continue; if (!creature->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_FLIGHTMASTER)) continue; - uint32 nearestNode = sObjectMgr->GetNearestTaxiNode( - creature->GetPositionX(), creature->GetPositionY(), creature->GetPositionZ(), creature->GetMapId(), GetTeam()); + uint32 nearestNode = sObjectMgr->GetNearestTaxiNode(creature->GetPositionX(), creature->GetPositionY(), creature->GetPositionZ(), creature->GetMapId(), GetTeam()); if (!nearestNode) continue; WorldPacket data(SMSG_TAXINODE_STATUS, 9); @@ -22438,9 +22172,7 @@ void Player::InitDisplayIds() PlayerInfo const* info = sObjectMgr->GetPlayerInfo(getRace(), getClass()); if (!info) { - LOG_ERROR("entities.player", - "Player::InitDisplayIds: Player '%s' (%s) has incorrect race/class pair. Can't init display ids.", GetName().c_str(), - GetGUID().ToString().c_str()); + LOG_ERROR("entities.player", "Player::InitDisplayIds: Player '%s' (%s) has incorrect race/class pair. Can't init display ids.", GetName().c_str(), GetGUID().ToString().c_str()); return; } @@ -22456,13 +22188,12 @@ void Player::InitDisplayIds() SetNativeDisplayId(info->displayId_m); break; default: - LOG_ERROR("entities.player", "Player::InitDisplayIds: Player '%s' (%s) has invalid gender %u", GetName().c_str(), - GetGUID().ToString().c_str(), gender); + LOG_ERROR("entities.player", "Player::InitDisplayIds: Player '%s' (%s) has invalid gender %u", GetName().c_str(), GetGUID().ToString().c_str(), gender); } } -inline bool Player::_StoreOrEquipNewItem(uint32 vendorslot, uint32 item, uint32 count, uint8 bag, uint8 slot, int64 price, - ItemTemplate const* pProto, Creature* pVendor, VendorItem const* crItem, bool bStore) +inline bool Player::_StoreOrEquipNewItem( + uint32 vendorslot, uint32 item, uint32 count, uint8 bag, uint8 slot, int64 price, ItemTemplate const* pProto, Creature* pVendor, VendorItem const* crItem, bool bStore) { uint32 stacks = count / pProto->GetBuyCount(); ItemPosCountVec vDest; @@ -22544,8 +22275,7 @@ bool Player::BuyCurrencyFromVendorSlot(ObjectGuid vendorGuid, uint32 vendorSlot, Creature* creature = GetNPCIfCanInteractWith(vendorGuid, UNIT_NPC_FLAG_VENDOR); if (!creature) { - LOG_DEBUG("network", "WORLD: BuyCurrencyFromVendorSlot - %s not found or you can't interact with him.", - vendorGuid.ToString().c_str()); + LOG_DEBUG("network", "WORLD: BuyCurrencyFromVendorSlot - %s not found or you can't interact with him.", vendorGuid.ToString().c_str()); SendBuyError(BUY_ERR_DISTANCE_TOO_FAR, nullptr, currency, 0); return false; } @@ -22710,24 +22440,22 @@ bool Player::BuyItemFromVendorSlot(ObjectGuid vendorguid, uint32 vendorslot, uin return false; } - if (!IsGameMaster() && ((pProto->GetFlags2() & ITEM_FLAG2_FACTION_HORDE && GetTeam() == ALLIANCE) || - (pProto->GetFlags2() == ITEM_FLAG2_FACTION_ALLIANCE && GetTeam() == HORDE))) + if (!IsGameMaster() && ((pProto->GetFlags2() & ITEM_FLAG2_FACTION_HORDE && GetTeam() == ALLIANCE) || (pProto->GetFlags2() == ITEM_FLAG2_FACTION_ALLIANCE && GetTeam() == HORDE))) return false; Creature* creature = GetNPCIfCanInteractWith(vendorguid, UNIT_NPC_FLAG_VENDOR); if (!creature) { - LOG_DEBUG("network", "Player::BuyItemFromVendorSlot: Vendor (%s) not found or player '%s' (%s) can't interact with him.", - vendorguid.ToString().c_str(), GetName().c_str(), GetGUID().ToString().c_str()); + LOG_DEBUG("network", "Player::BuyItemFromVendorSlot: Vendor (%s) not found or player '%s' (%s) can't interact with him.", vendorguid.ToString().c_str(), GetName().c_str(), + GetGUID().ToString().c_str()); SendBuyError(BUY_ERR_DISTANCE_TOO_FAR, nullptr, item, 0); return false; } if (!sConditionMgr->IsObjectMeetingVendorItemConditions(creature->GetEntry(), item, this, creature)) { - LOG_DEBUG("condition", - "Player::BuyItemFromVendorSlot: Player '%s' (%s) doesn't meed conditions for creature (Entry: %u, Item: %u)", - GetName().c_str(), GetGUID().ToString().c_str(), creature->GetEntry(), item); + LOG_DEBUG("condition", "Player::BuyItemFromVendorSlot: Player '%s' (%s) doesn't meed conditions for creature (Entry: %u, Item: %u)", GetName().c_str(), GetGUID().ToString().c_str(), + creature->GetEntry(), item); SendBuyError(BUY_ERR_CANT_FIND_ITEM, creature, item, 0); return false; } @@ -22763,8 +22491,7 @@ bool Player::BuyItemFromVendorSlot(ObjectGuid vendorguid, uint32 vendorslot, uin } } - if (pProto->GetRequiredReputationFaction() && - (uint32(GetReputationRank(pProto->GetRequiredReputationFaction())) < pProto->GetRequiredReputationRank())) + if (pProto->GetRequiredReputationFaction() && (uint32(GetReputationRank(pProto->GetRequiredReputationFaction())) < pProto->GetRequiredReputationRank())) { SendBuyError(BUY_ERR_REPUTATION_REQUIRE, creature, item, 0); return false; @@ -22783,8 +22510,7 @@ bool Player::BuyItemFromVendorSlot(ObjectGuid vendorguid, uint32 vendorslot, uin ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(crItem->ExtendedCost); if (!iece) { - LOG_ERROR("entities.player", "Player::BuyItemFromVendorSlot: Item %u has wrong ExtendedCost field value %u", - pProto->GetId(), crItem->ExtendedCost); + LOG_ERROR("entities.player", "Player::BuyItemFromVendorSlot: Item %u has wrong ExtendedCost field value %u", pProto->GetId(), crItem->ExtendedCost); return false; } @@ -22864,16 +22590,14 @@ bool Player::BuyItemFromVendorSlot(ObjectGuid vendorguid, uint32 vendorslot, uin } uint64 price = 0; - if (crItem->IsGoldRequired(pProto) && - pProto->GetBuyPrice() > 0) // Assume price cannot be negative (do not know why it is int32) + if (crItem->IsGoldRequired(pProto) && pProto->GetBuyPrice() > 0) // Assume price cannot be negative (do not know why it is int32) { double buyPricePerItem = double(pProto->GetBuyPrice()) / pProto->GetBuyCount(); uint32 maxCount = MAX_MONEY_AMOUNT / buyPricePerItem; if (count > maxCount) { - LOG_INFO("entities.player.cheat", - "Player::BuyItemFromVendorSlot: Player '%s' (%s) tried to buy item (ItemID: %u, Count: %u), causing overflow", - GetName().c_str(), GetGUID().ToString().c_str(), pProto->GetId(), count); + LOG_INFO("entities.player.cheat", "Player::BuyItemFromVendorSlot: Player '%s' (%s) tried to buy item (ItemID: %u, Count: %u), causing overflow", GetName().c_str(), + GetGUID().ToString().c_str(), pProto->GetId(), count); count = maxCount; } price = uint64(buyPricePerItem * count); // it should not exceed MAX_MONEY_AMOUNT @@ -22914,9 +22638,7 @@ bool Player::BuyItemFromVendorSlot(ObjectGuid vendorguid, uint32 vendorslot, uin if (crItem->maxcount != 0) // bought { - if (pProto->GetQuality() > ITEM_QUALITY_EPIC || - (pProto->GetQuality() == ITEM_QUALITY_EPIC && - pProto->GetBaseItemLevel() >= MinNewsItemLevel[sWorld->getIntConfig(CONFIG_EXPANSION)])) + if (pProto->GetQuality() > ITEM_QUALITY_EPIC || (pProto->GetQuality() == ITEM_QUALITY_EPIC && pProto->GetBaseItemLevel() >= MinNewsItemLevel[sWorld->getIntConfig(CONFIG_EXPANSION)])) if (Guild* guild = GetGuild()) guild->AddGuildNews(GUILD_NEWS_ITEM_PURCHASED, GetGUID(), 0, item); return true; @@ -22972,8 +22694,7 @@ void Player::UpdateHomebindTime(uint32 time) m_HomebindTimer = 60000; // send message to player SendRaidGroupOnlyMessage(RAID_GROUP_ERR_REQUIREMENTS_UNMATCH, m_HomebindTimer); - LOG_DEBUG("maps", "Player::UpdateHomebindTime: Player '%s' (%s) will be teleported to homebind in 60 seconds", - GetName().c_str(), GetGUID().ToString().c_str()); + LOG_DEBUG("maps", "Player::UpdateHomebindTime: Player '%s' (%s) will be teleported to homebind in 60 seconds", GetName().c_str(), GetGUID().ToString().c_str()); } } @@ -23284,8 +23005,7 @@ void Player::GetLFGLeavePoint(Position* pos) { if (pos) { - pos->Relocate(m_bgData.leavePos.m_positionX, m_bgData.leavePos.m_positionY, m_bgData.leavePos.m_positionZ, - m_bgData.leavePos.GetOrientation()); + pos->Relocate(m_bgData.leavePos.m_positionX, m_bgData.leavePos.m_positionY, m_bgData.leavePos.m_positionZ, m_bgData.leavePos.GetOrientation()); _hasValidLFGLeavePoint = false; } } @@ -23293,8 +23013,7 @@ void Player::GetLFGLeavePoint(Position* pos) bool Player::HasValidLFGLeavePoint(uint32 mapid) { return _hasValidLFGLeavePoint && - MapManager::IsValidMapCoord(mapid, m_bgData.leavePos.m_positionX, m_bgData.leavePos.m_positionY, - m_bgData.leavePos.m_positionZ, m_bgData.leavePos.GetOrientation()); + MapManager::IsValidMapCoord(mapid, m_bgData.leavePos.m_positionX, m_bgData.leavePos.m_positionY, m_bgData.leavePos.m_positionZ, m_bgData.leavePos.GetOrientation()); } void Player::SetLFGLeavePoint() @@ -23309,7 +23028,10 @@ void Player::SetBGTeam(uint32 team) SetByteValue(PLAYER_BYTES_3, PLAYER_BYTES_3_OFFSET_ARENA_FACTION, uint8(team == ALLIANCE ? 1 : 0)); } -uint32 Player::GetBGTeam() const { return m_bgData.bgTeam ? m_bgData.bgTeam : GetTeam(); } +uint32 Player::GetBGTeam() const +{ + return m_bgData.bgTeam ? m_bgData.bgTeam : GetTeam(); +} void Player::LeaveBattleground(bool teleportToEntryPoint) { @@ -23334,8 +23056,7 @@ void Player::LeaveBattleground(bool teleportToEntryPoint) } // track if player leaves the BG while inside it - if (bg->isBattleground() && sWorld->getBoolConfig(CONFIG_BATTLEGROUND_TRACK_DESERTERS) && - (bg->GetStatus() == STATUS_IN_PROGRESS || bg->GetStatus() == STATUS_WAIT_JOIN)) + if (bg->isBattleground() && sWorld->getBoolConfig(CONFIG_BATTLEGROUND_TRACK_DESERTERS) && (bg->GetStatus() == STATUS_IN_PROGRESS || bg->GetStatus() == STATUS_WAIT_JOIN)) { CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_DESERTER_TRACK); stmt->setUInt32(0, GetGUID().GetCounter()); @@ -23381,8 +23102,7 @@ void Player::ReportedAfkBy(Player* reporter) return; // check if player has 'Idle' or 'Inactive' debuff - if (m_bgData.bgAfkReporter.find(reporter->GetGUID().GetCounter()) == m_bgData.bgAfkReporter.end() && !HasAura(43680) && - !HasAura(43681) && reporter->CanReportAfkDueToLimit()) + if (m_bgData.bgAfkReporter.find(reporter->GetGUID().GetCounter()) == m_bgData.bgAfkReporter.end() && !HasAura(43680) && !HasAura(43681) && reporter->CanReportAfkDueToLimit()) { m_bgData.bgAfkReporter.insert(reporter->GetGUID().GetCounter()); // by default 3 players have to complain to apply debuff @@ -23405,7 +23125,10 @@ WorldLocation Player::GetStartPosition() const return WorldLocation(mapId, info->positionX, info->positionY, info->positionZ, 0); } -bool Player::HaveAtClient(Object const* u) const { return u == this || m_clientGUIDs.find(u->GetGUID()) != m_clientGUIDs.end(); } +bool Player::HaveAtClient(Object const* u) const +{ + return u == this || m_clientGUIDs.find(u->GetGUID()) != m_clientGUIDs.end(); +} bool Player::IsNeverVisible() const { @@ -23481,7 +23204,9 @@ template <> inline void UpdateVisibilityOf_helper(GuidUnorderedSet& s64, Player* v.insert(target); } -template inline void BeforeVisibilityDestroy(T* /*t*/, Player* /*p*/) {} +template inline void BeforeVisibilityDestroy(T* /*t*/, Player* /*p*/) +{ +} template <> inline void BeforeVisibilityDestroy(Creature* t, Player* p) { @@ -23506,8 +23231,7 @@ void Player::UpdateVisibilityOf(WorldObject* target) m_clientGUIDs.erase(target->GetGUID()); #ifdef FC_DEBUG - LOG_DEBUG("maps", "Object %u (Type: %u) out of range for player %u. Distance = %f", target->GetGUID().GetCounter(), - target->GetTypeId(), GetGUID().GetCounter(), GetDistance(target)); + LOG_DEBUG("maps", "Object %u (Type: %u) out of range for player %u. Distance = %f", target->GetGUID().GetCounter(), target->GetTypeId(), GetGUID().GetCounter(), GetDistance(target)); #endif } } @@ -23519,8 +23243,7 @@ void Player::UpdateVisibilityOf(WorldObject* target) m_clientGUIDs.insert(target->GetGUID()); #ifdef FC_DEBUG - LOG_DEBUG("maps", "Object %u (Type: %u) is visible now for player %u. Distance = %f", target->GetGUID().GetCounter(), - target->GetTypeId(), GetGUID().GetCounter(), GetDistance(target)); + LOG_DEBUG("maps", "Object %u (Type: %u) is visible now for player %u. Distance = %f", target->GetGUID().GetCounter(), target->GetTypeId(), GetGUID().GetCounter(), GetDistance(target)); #endif // target aura duration for caster show only if target exist at caster client @@ -23547,8 +23270,7 @@ void Player::UpdateTriggerVisibility() { Creature* creature = GetMap()->GetCreature(*itr); // Update fields of triggers, transformed units or unselectable units (values dependent on GM state) - if (!creature || (!creature->IsTrigger() && !creature->HasAuraType(SPELL_AURA_TRANSFORM) && - !creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE))) + if (!creature || (!creature->IsTrigger() && !creature->HasAuraType(SPELL_AURA_TRANSFORM) && !creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE))) continue; creature->SetFieldNotifyFlag(UF_FLAG_PUBLIC); @@ -23600,9 +23322,8 @@ template void Player::UpdateVisibilityOf(T* target, UpdateData& data, m_clientGUIDs.erase(target->GetGUID()); #ifdef FC_DEBUG - LOG_DEBUG("maps", "Object %u (Type: %u, Entry: %u) is out of range for player %u. Distance = %f", - target->GetGUID().GetCounter(), target->GetTypeId(), target->GetEntry(), GetGUID().GetCounter(), - GetDistance(target)); + LOG_DEBUG("maps", "Object %u (Type: %u, Entry: %u) is out of range for player %u. Distance = %f", target->GetGUID().GetCounter(), target->GetTypeId(), target->GetEntry(), + GetGUID().GetCounter(), GetDistance(target)); #endif } } @@ -23614,9 +23335,8 @@ template void Player::UpdateVisibilityOf(T* target, UpdateData& data, UpdateVisibilityOf_helper(m_clientGUIDs, target, visibleNow); #ifdef FC_DEBUG - LOG_DEBUG("maps", "Object %u (Type: %u, Entry: %u) is visible now for player %u. Distance = %f", - target->GetGUID().GetCounter(), target->GetTypeId(), target->GetEntry(), GetGUID().GetCounter(), - GetDistance(target)); + LOG_DEBUG("maps", "Object %u (Type: %u, Entry: %u) is visible now for player %u. Distance = %f", target->GetGUID().GetCounter(), target->GetTypeId(), target->GetEntry(), + GetGUID().GetCounter(), GetDistance(target)); #endif } } @@ -23653,7 +23373,10 @@ void Player::UpdateVisibilityForPlayer() notifier.SendToSelf(); // send gathered data } -void Player::InitPrimaryProfessions() { SetFreePrimaryProfessions(sWorld->getIntConfig(CONFIG_MAX_PRIMARY_TRADE_SKILL)); } +void Player::InitPrimaryProfessions() +{ + SetFreePrimaryProfessions(sWorld->getIntConfig(CONFIG_MAX_PRIMARY_TRADE_SKILL)); +} bool Player::ModifyMoney(int64 amount, bool sendError /*= true*/) { @@ -23695,7 +23418,10 @@ void Player::SetMoney(uint64 value) UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_GOLD_VALUE_OWNED); } -bool Player::IsQuestRewarded(uint32 quest_id) const { return m_RewardedQuests.find(quest_id) != m_RewardedQuests.end(); } +bool Player::IsQuestRewarded(uint32 quest_id) const +{ + return m_RewardedQuests.find(quest_id) != m_RewardedQuests.end(); +} Unit* Player::GetSelectedUnit() const { @@ -23941,8 +23667,7 @@ void Player::SendInitialPacketsAfterAddToMap() // set some aura effects that send packet to player client after add player to map // SendMessageToSet not send it to player not it map, only for aura that not changed anything at re-apply // same auras state lost at far teleport, send it one more time in this case also - static const AuraType auratypes[] = {SPELL_AURA_MOD_FEAR, SPELL_AURA_TRANSFORM, SPELL_AURA_WATER_WALK, - SPELL_AURA_FEATHER_FALL, SPELL_AURA_HOVER, SPELL_AURA_SAFE_FALL, SPELL_AURA_FLY, + static const AuraType auratypes[] = {SPELL_AURA_MOD_FEAR, SPELL_AURA_TRANSFORM, SPELL_AURA_WATER_WALK, SPELL_AURA_FEATHER_FALL, SPELL_AURA_HOVER, SPELL_AURA_SAFE_FALL, SPELL_AURA_FLY, SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED, SPELL_AURA_NONE}; for (AuraType const* itr = &auratypes[0]; itr && itr[0] != SPELL_AURA_NONE; ++itr) { @@ -24132,8 +23857,7 @@ void Player::ResetSpells(bool myClassOnly) } else for (PlayerSpellMap::const_iterator iter = smap.begin(); iter != smap.end(); ++iter) - RemoveSpell( - iter->first, false, false); // only iter->first can be accessed, object by iter->second can be deleted already + RemoveSpell(iter->first, false, false); // only iter->first can be accessed, object by iter->second can be deleted already LearnDefaultSkills(); LearnCustomSpells(); @@ -24151,9 +23875,8 @@ void Player::LearnCustomSpells() for (PlayerCreateInfoSpells::const_iterator itr = info->customSpells.begin(); itr != info->customSpells.end(); ++itr) { uint32 tspell = *itr; - LOG_DEBUG("entities.player.loading", - "Player::LearnCustomSpells: Player '%s' (%s, Class: %u Race: %u): Adding initial spell (SpellID: %u)", - GetName().c_str(), GetGUID().ToString().c_str(), uint32(getClass()), uint32(getRace()), tspell); + LOG_DEBUG("entities.player.loading", "Player::LearnCustomSpells: Player '%s' (%s, Class: %u Race: %u): Adding initial spell (SpellID: %u)", GetName().c_str(), GetGUID().ToString().c_str(), + uint32(getClass()), uint32(getRace()), tspell); if (!IsInWorld()) // will send in INITIAL_SPELLS in list anyway at map add AddSpell(tspell, true, true, true, false); else // but send in normal spell in game learn case @@ -24182,8 +23905,7 @@ void Player::LearnDefaultSkill(uint32 skillId, uint16 rank) if (!rcInfo) return; - LOG_DEBUG("entities.player.loading", "PLAYER (Class: %u Race: %u): Adding initial skill, id = %u", uint32(getClass()), - uint32(getRace()), skillId); + LOG_DEBUG("entities.player.loading", "PLAYER (Class: %u Race: %u): Adding initial skill, id = %u", uint32(getClass()), uint32(getRace()), skillId); switch (GetSkillRangeType(rcInfo)) { case SKILL_RANGE_LANGUAGE: @@ -24272,8 +23994,7 @@ void Player::LearnQuestRewardedSpells(Quest const* quest) return; // profession specialization can be re-learned from npc - if (learnedInfo->Effects[0].Effect == SPELL_EFFECT_TRADE_SKILL && learnedInfo->Effects[1].Effect == 0 && - !learnedInfo->SpellLevel) + if (learnedInfo->Effects[0].Effect == SPELL_EFFECT_TRADE_SKILL && learnedInfo->Effects[1].Effect == 0 && !learnedInfo->SpellLevel) return; } @@ -24318,8 +24039,7 @@ void Player::LearnSkillRewardedSpells(uint32 skillId, uint32 skillValue) // AcquireMethod == 2 && NumSkillUps == 1 --> automatically learn riding skill spell, else we skip it (client shows riding // in spellbook as trainable). - if (skillId == SKILL_RIDING && - (ability->AcquireMethod != SKILL_LINE_ABILITY_LEARNED_ON_SKILL_LEARN || ability->NumSkillUps != 1)) + if (skillId == SKILL_RIDING && (ability->AcquireMethod != SKILL_LINE_ABILITY_LEARNED_ON_SKILL_LEARN || ability->NumSkillUps != 1)) continue; // Check race if set @@ -24610,7 +24330,10 @@ uint32 Player::GetBattlegroundQueueJoinTime(uint32 bgTypeId) const return GameTime::GetGameTimeMS(); } -void Player::AddBattlegroundQueueJoinTime(uint32 bgTypeId, uint32 joinTime) { m_bgData.bgQueuesJoinedTime[bgTypeId] = joinTime; } +void Player::AddBattlegroundQueueJoinTime(uint32 bgTypeId, uint32 joinTime) +{ + m_bgData.bgQueuesJoinedTime[bgTypeId] = joinTime; +} void Player::RemoveBattlegroundQueueJoinTime(uint32 bgTypeId) { @@ -24663,8 +24386,7 @@ uint32 Player::AddBattlegroundQueueId(BattlegroundQueueTypeId val) { for (uint8 i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i) { - if (m_bgBattlegroundQueueID[i].bgQueueTypeId == BATTLEGROUND_QUEUE_NONE || - m_bgBattlegroundQueueID[i].bgQueueTypeId == val) + if (m_bgBattlegroundQueueID[i].bgQueueTypeId == BATTLEGROUND_QUEUE_NONE || m_bgBattlegroundQueueID[i].bgQueueTypeId == val) { m_bgBattlegroundQueueID[i].bgQueueTypeId = val; m_bgBattlegroundQueueID[i].invitedToInstance = 0; @@ -24754,7 +24476,10 @@ float Player::GetReputationPriceDiscount(Creature const* creature) const return 1.0f - 0.05f * (rank - REP_NEUTRAL); } -Player* Player::GetTrader() const { return m_trade ? m_trade->GetTrader() : nullptr; } +Player* Player::GetTrader() const +{ + return m_trade ? m_trade->GetTrader() : nullptr; +} bool Player::IsSpellFitByClassAndRace(uint32 spell_id) const { @@ -24860,7 +24585,10 @@ void Player::UpdateVisibleGameobjectsOrSpellClicks() SendDirectMessage(&packet); } -bool Player::HasSummonPending() const { return m_summon_expire >= GameTime::GetGameTime(); } +bool Player::HasSummonPending() const +{ + return m_summon_expire >= GameTime::GetGameTime(); +} void Player::SendSummonRequestFrom(Unit* summoner) { @@ -24946,8 +24674,7 @@ void Player::AutoUnequipOffhandIfNeed(bool force /*= false*/) return; // unequip offhand weapon if player doesn't have dual wield anymore - if (!CanDualWield() && (offItem->GetTemplate()->GetInventoryType() == INVTYPE_WEAPONOFFHAND || - offItem->GetTemplate()->GetInventoryType() == INVTYPE_WEAPON)) + if (!CanDualWield() && (offItem->GetTemplate()->GetInventoryType() == INVTYPE_WEAPONOFFHAND || offItem->GetTemplate()->GetInventoryType() == INVTYPE_WEAPON)) force = true; // need unequip offhand for 2h-weapon without TitanGrip (in any from hands) @@ -24965,19 +24692,19 @@ void Player::AutoUnequipOffhandIfNeed(bool force /*= false*/) MoveItemFromInventory(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND, true); CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction(); offItem->DeleteFromInventoryDB(trans); // deletes item from character's inventory - offItem->SaveToDB( - trans); // recursive and not have transaction guard into self, item not in inventory and can be save standalone + offItem->SaveToDB(trans); // recursive and not have transaction guard into self, item not in inventory and can be save standalone std::string subject = GetSession()->GetFirelandsString(LANG_NOT_EQUIPPED_ITEM); - MailDraft(subject, "There were problems with equipping one or several items") - .AddItem(offItem) - .SendMailTo(trans, this, MailSender(this, MAIL_STATIONERY_GM), MAIL_CHECK_MASK_COPIED); + MailDraft(subject, "There were problems with equipping one or several items").AddItem(offItem).SendMailTo(trans, this, MailSender(this, MAIL_STATIONERY_GM), MAIL_CHECK_MASK_COPIED); CharacterDatabase.CommitTransaction(trans); } } -OutdoorPvP* Player::GetOutdoorPvP() const { return sOutdoorPvPMgr->GetOutdoorPvPToZoneId(GetZoneId()); } +OutdoorPvP* Player::GetOutdoorPvP() const +{ + return sOutdoorPvPMgr->GetOutdoorPvPToZoneId(GetZoneId()); +} bool Player::HasItemFitToSpellRequirements(SpellInfo const* spellInfo, Item const* ignoreItem) const { @@ -25028,8 +24755,7 @@ bool Player::HasItemFitToSpellRequirements(SpellInfo const* spellInfo, Item cons break; } default: - LOG_ERROR("entities.player", "Player::HasItemFitToSpellRequirements: Not handled spell requirement for item class %u", - spellInfo->EquippedItemClass); + LOG_ERROR("entities.player", "Player::HasItemFitToSpellRequirements: Not handled spell requirement for item class %u", spellInfo->EquippedItemClass); break; } @@ -25198,8 +24924,7 @@ bool Player::GetsRecruitAFriendBonus(bool forXP) // level difference must be small enough to get RaF bonus, UNLESS we are lower level if (player->getLevel() < getLevel()) - if (uint8(getLevel() - player->getLevel()) > - sWorld->getIntConfig(CONFIG_MAX_RECRUIT_A_FRIEND_BONUS_PLAYER_LEVEL_DIFFERENCE)) + if (uint8(getLevel() - player->getLevel()) > sWorld->getIntConfig(CONFIG_MAX_RECRUIT_A_FRIEND_BONUS_PLAYER_LEVEL_DIFFERENCE)) continue; } @@ -25320,8 +25045,8 @@ void Player::SetClientControl(Unit* target, bool allowMove) // don't allow possession to be overridden if (target->HasUnitState(UNIT_STATE_CHARMED) && (GetGUID() != target->GetCharmerGUID())) { - LOG_ERROR("entities.player", "Player '%s' attempt to client control '%s', which is charmed by GUID %s", GetName().c_str(), - target->GetName().c_str(), target->GetCharmerGUID().ToString().c_str()); + LOG_ERROR( + "entities.player", "Player '%s' attempt to client control '%s', which is charmed by GUID %s", GetName().c_str(), target->GetName().c_str(), target->GetCharmerGUID().ToString().c_str()); return; } @@ -25409,8 +25134,7 @@ void Player::UpdateCorpseReclaimDelay() { bool pvp = (m_ExtraFlags & PLAYER_EXTRA_PVP_DEATH) != 0; - if ((pvp && !sWorld->getBoolConfig(CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVP)) || - (!pvp && !sWorld->getBoolConfig(CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVE))) + if ((pvp && !sWorld->getBoolConfig(CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVP)) || (!pvp && !sWorld->getBoolConfig(CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVE))) return; time_t now = GameTime::GetGameTime(); @@ -25447,8 +25171,7 @@ int32 Player::CalculateCorpseReclaimDelay(bool load) const uint64 count = 0; - if ((pvp && sWorld->getBoolConfig(CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVP)) || - (!pvp && sWorld->getBoolConfig(CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVE))) + if ((pvp && sWorld->getBoolConfig(CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVP)) || (!pvp && sWorld->getBoolConfig(CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVE))) { count = (m_deathExpireTime - corpse->GetGhostTime()) / DEATH_EXPIRE_STEP; @@ -25491,8 +25214,7 @@ Player* Player::GetNextRandomRaidMember(float radius) Player* Target = itr->GetSource(); // IsHostileTo check duel and controlled by enemy - if (Target && Target != this && IsWithinDistInMap(Target, radius) && !Target->HasInvisibilityAura() && - !IsHostileTo(Target)) + if (Target && Target != this && IsWithinDistInMap(Target, radius) && !Target->HasInvisibilityAura() && !IsHostileTo(Target)) nearMembers.push_back(Target); } @@ -25553,7 +25275,10 @@ PartyResult Player::CanUninviteFromGroup(ObjectGuid guidMember) const return ERR_PARTY_RESULT_OK; } -bool Player::isUsingLfg() const { return sLFGMgr->GetState(GetGUID()) != lfg::LFG_STATE_NONE; } +bool Player::isUsingLfg() const +{ + return sLFGMgr->GetState(GetGUID()) != lfg::LFG_STATE_NONE; +} bool Player::inRandomLfgDungeon() const { @@ -25701,13 +25426,11 @@ void Player::SetViewpoint(WorldObject* target, bool apply) { if (apply) { - LOG_DEBUG("maps", "Player::CreateViewpoint: Player '%s' (%s) creates seer (Entry: %u, TypeId: %u).", GetName().c_str(), - GetGUID().ToString().c_str(), target->GetEntry(), target->GetTypeId()); + LOG_DEBUG("maps", "Player::CreateViewpoint: Player '%s' (%s) creates seer (Entry: %u, TypeId: %u).", GetName().c_str(), GetGUID().ToString().c_str(), target->GetEntry(), target->GetTypeId()); if (!AddGuidValue(PLAYER_FARSIGHT, target->GetGUID())) { - LOG_FATAL("entities.player", "Player::CreateViewpoint: Player '%s' (%s) cannot add new viewpoint!", GetName().c_str(), - GetGUID().ToString().c_str()); + LOG_FATAL("entities.player", "Player::CreateViewpoint: Player '%s' (%s) cannot add new viewpoint!", GetName().c_str(), GetGUID().ToString().c_str()); return; } @@ -25724,8 +25447,7 @@ void Player::SetViewpoint(WorldObject* target, bool apply) if (!RemoveGuidValue(PLAYER_FARSIGHT, target->GetGUID())) { - LOG_FATAL("entities.player", "Player::CreateViewpoint: Player '%s' (%s) cannot remove current viewpoint!", - GetName().c_str(), GetGUID().ToString().c_str()); + LOG_FATAL("entities.player", "Player::CreateViewpoint: Player '%s' (%s) cannot remove current viewpoint!", GetName().c_str(), GetGUID().ToString().c_str()); return; } @@ -25773,8 +25495,7 @@ bool Player::CanCaptureTowerPoint() const IsAlive()); // live player } -uint32 Player::GetBarberShopCost( - uint8 newhairstyle, uint8 newhaircolor, uint8 newfacialhair, BarberShopStyleEntry const* newSkin) const +uint32 Player::GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 newfacialhair, BarberShopStyleEntry const* newSkin) const { uint8 level = getLevel(); @@ -25786,8 +25507,7 @@ uint32 Player::GetBarberShopCost( uint8 facialhair = GetByteValue(PLAYER_BYTES_2, PLAYER_BYTES_2_OFFSET_FACIAL_STYLE); uint8 skincolor = GetByteValue(PLAYER_BYTES, PLAYER_BYTES_OFFSET_SKIN_ID); - if ((hairstyle == newhairstyle) && (haircolor == newhaircolor) && (facialhair == newfacialhair) && - (!newSkin || (newSkin->Data == skincolor))) + if ((hairstyle == newhairstyle) && (haircolor == newhaircolor) && (facialhair == newfacialhair) && (!newSkin || (newSkin->Data == skincolor))) return 0; GtBarberShopCostBaseEntry const* bsc = sGtBarberShopCostBaseStore.LookupEntry(level - 1); @@ -25862,7 +25582,10 @@ bool Player::HasTitle(uint32 bitIndex) const return HasFlag(PLAYER__FIELD_KNOWN_TITLES + fieldIndexOffset, flag); } -bool Player::HasTitle(CharTitlesEntry const* title) const { return HasTitle(title->Mask_ID); } +bool Player::HasTitle(CharTitlesEntry const* title) const +{ + return HasTitle(title->Mask_ID); +} void Player::SetTitle(CharTitlesEntry const* title, bool lost) { @@ -25921,8 +25644,7 @@ void Player::SetRuneConvertAura(uint8 index, AuraEffect const* aura, AuraType au m_runes->runes[index].ConvertAuraInfo = spellInfo; } -void Player::AddRuneByAuraEffect( - uint8 index, RuneType newType, AuraEffect const* aura, AuraType auraType, SpellInfo const* spellInfo) +void Player::AddRuneByAuraEffect(uint8 index, RuneType newType, AuraEffect const* aura, AuraType auraType, SpellInfo const* spellInfo) { SetRuneConvertAura(index, aura, auraType, spellInfo); ConvertRune(index, newType); @@ -26157,9 +25879,8 @@ void Player::StoreLootItem(uint8 lootSlot, Loot* loot, GameObject* go) if (ItemTemplate const* proto = sObjectMgr->GetItemTemplate(item->itemid)) if ((proto->GetQuality() > ITEM_QUALITY_EPIC // always log legendary items - || (proto->GetQuality() == ITEM_QUALITY_EPIC && - proto->GetBaseItemLevel() >= MinNewsItemLevel[sWorld->getIntConfig( - CONFIG_EXPANSION)])) // log epic items when within item level range + || + (proto->GetQuality() == ITEM_QUALITY_EPIC && proto->GetBaseItemLevel() >= MinNewsItemLevel[sWorld->getIntConfig(CONFIG_EXPANSION)])) // log epic items when within item level range && !proto->GetDuration()) // log items only when they are permanent (skipping legendary items from Kael'thas // encounter for example) if (Guild* guild = GetGuild()) @@ -26231,8 +25952,7 @@ void Player::_LoadSkills(PreparedQueryResult result) { if (mSkillStatus.size() >= PLAYER_MAX_SKILLS) // client limit { - LOG_ERROR("entities.player", "Player::_LoadSkills: Player '%s' (%s) has more than %u skills.", GetName().c_str(), - GetGUID().ToString().c_str(), PLAYER_MAX_SKILLS); + LOG_ERROR("entities.player", "Player::_LoadSkills: Player '%s' (%s) has more than %u skills.", GetName().c_str(), GetGUID().ToString().c_str(), PLAYER_MAX_SKILLS); break; } @@ -26271,9 +25991,7 @@ void Player::_LoadSkills(PreparedQueryResult result) auto skillItr = mSkillStatus.find(skill); if (skillItr == mSkillStatus.end()) - skillItr = - mSkillStatus.insert(SkillStatusMap::value_type(skill, SkillStatusData(mSkillStatus.size(), SKILL_UNCHANGED))) - .first; + skillItr = mSkillStatus.insert(SkillStatusMap::value_type(skill, SkillStatusData(mSkillStatus.size(), SKILL_UNCHANGED))).first; uint16 step = 0; @@ -26337,9 +26055,7 @@ InventoryResult Player::CanEquipUniqueItem(Item* pItem, uint8 eslot, uint32 limi continue; // include for check equip another gems with same limit category for not equipped item (and then not counted) - uint32 gem_limit_count = !pItem->IsEquipped() && pGem->GetItemLimitCategory() - ? pItem->GetGemCountWithLimitCategory(pGem->GetItemLimitCategory()) - : 1; + uint32 gem_limit_count = !pItem->IsEquipped() && pGem->GetItemLimitCategory() ? pItem->GetGemCountWithLimitCategory(pGem->GetItemLimitCategory()) : 1; if (InventoryResult res = CanEquipUniqueItem(pGem, eslot, gem_limit_count)) return res; @@ -26371,11 +26087,9 @@ InventoryResult Player::CanEquipUniqueItem(ItemTemplate const* itemProto, uint8 return EQUIP_ERR_ITEM_MAX_LIMIT_CATEGORY_EQUIPPED_EXCEEDED_IS; // there is an equip limit on this item - if (HasItemWithLimitCategoryEquipped( - itemProto->GetItemLimitCategory(), limitEntry->Quantity - limit_count + 1, except_slot)) + if (HasItemWithLimitCategoryEquipped(itemProto->GetItemLimitCategory(), limitEntry->Quantity - limit_count + 1, except_slot)) return EQUIP_ERR_ITEM_MAX_LIMIT_CATEGORY_EQUIPPED_EXCEEDED_IS; - else if (HasGemWithLimitCategoryEquipped( - itemProto->GetItemLimitCategory(), limitEntry->Quantity - limit_count + 1, except_slot)) + else if (HasGemWithLimitCategoryEquipped(itemProto->GetItemLimitCategory(), limitEntry->Quantity - limit_count + 1, except_slot)) return EQUIP_ERR_ITEM_MAX_COUNT_EQUIPPED_SOCKETED; } @@ -26396,8 +26110,8 @@ void Player::HandleFall(MovementInfo const& movementInfo) // Players with low fall distance, Feather Fall or physical immunity (charges used) are ignored // 14.57 can be calculated by resolving damageperc formula below to 0 - if (z_diff >= 14.57f && !isDead() && !IsGameMaster() && !HasAuraType(SPELL_AURA_HOVER) && - !HasAuraType(SPELL_AURA_FEATHER_FALL) && !HasAuraType(SPELL_AURA_FLY) && !IsImmunedToDamage(SPELL_SCHOOL_MASK_NORMAL)) + if (z_diff >= 14.57f && !isDead() && !IsGameMaster() && !HasAuraType(SPELL_AURA_HOVER) && !HasAuraType(SPELL_AURA_FEATHER_FALL) && !HasAuraType(SPELL_AURA_FLY) && + !IsImmunedToDamage(SPELL_SCHOOL_MASK_NORMAL)) { // Safe fall, fall height reduction int32 safe_fall = GetTotalAuraModifier(SPELL_AURA_SAFE_FALL); @@ -26434,8 +26148,8 @@ void Player::HandleFall(MovementInfo const& movementInfo) } // Z given by moveinfo, LastZ, FallTime, WaterZ, MapZ, Damage, Safefall reduction - LOG_DEBUG("entities.player", "FALLDAMAGE z=%f sz=%f pZ=%f FallTime=%d mZ=%f damage=%d SF=%d", - movementInfo.pos.GetPositionZ(), height, GetPositionZ(), movementInfo.jump.fallTime, height, damage, safe_fall); + LOG_DEBUG("entities.player", "FALLDAMAGE z=%f sz=%f pZ=%f FallTime=%d mZ=%f damage=%d SF=%d", movementInfo.pos.GetPositionZ(), height, GetPositionZ(), movementInfo.jump.fallTime, height, + damage, safe_fall); } } } @@ -26485,13 +26199,25 @@ void Player::SendMovementSetCollisionHeight(float height, UpdateCollisionHeightR MovementPacketSender::SendHeightChangeToMover(this, height, reason); } -void Player::ResetAchievements() { m_achievementMgr->Reset(); } +void Player::ResetAchievements() +{ + m_achievementMgr->Reset(); +} -void Player::SendRespondInspectAchievements(Player* player) const { m_achievementMgr->SendAchievementInfo(player); } +void Player::SendRespondInspectAchievements(Player* player) const +{ + m_achievementMgr->SendAchievementInfo(player); +} -uint32 Player::GetAchievementPoints() const { return m_achievementMgr->GetAchievementPoints(); } +uint32 Player::GetAchievementPoints() const +{ + return m_achievementMgr->GetAchievementPoints(); +} -bool Player::HasAchieved(uint32 achievementId) const { return m_achievementMgr->HasAchieved(achievementId); } +bool Player::HasAchieved(uint32 achievementId) const +{ + return m_achievementMgr->HasAchieved(achievementId); +} void Player::StartTimedAchievement(AchievementCriteriaTimedTypes type, uint32 entry, uint32 timeLost /* = 0*/) { @@ -26503,14 +26229,13 @@ void Player::RemoveTimedAchievement(AchievementCriteriaTimedTypes type, uint32 e m_achievementMgr->RemoveTimedAchievement(type, entry); } -void Player::ResetAchievementCriteria( - AchievementCriteriaCondition condition, uint64 value, bool evenIfCriteriaComplete /* = false*/) +void Player::ResetAchievementCriteria(AchievementCriteriaCondition condition, uint64 value, bool evenIfCriteriaComplete /* = false*/) { m_achievementMgr->ResetAchievementCriteria(condition, value, evenIfCriteriaComplete); } -void Player::UpdateAchievementCriteria(AchievementCriteriaTypes type, uint64 miscValue1 /*= 0*/, uint64 miscValue2 /*= 0*/, - uint64 miscValue3 /*= 0*/, Unit* unit /*= nullptr*/, GameObject* go /*= nullptr*/) +void Player::UpdateAchievementCriteria( + AchievementCriteriaTypes type, uint64 miscValue1 /*= 0*/, uint64 miscValue2 /*= 0*/, uint64 miscValue3 /*= 0*/, Unit* unit /*= nullptr*/, GameObject* go /*= nullptr*/) { m_achievementMgr->UpdateAchievementCriteria(type, miscValue1, miscValue2, miscValue3, unit, this); Guild* guild = sGuildMgr->GetGuildById(GetGuildId()); @@ -26525,7 +26250,10 @@ void Player::UpdateAchievementCriteria(AchievementCriteriaTypes type, uint64 mis guild->UpdateAchievementCriteria(type, miscValue1, miscValue2, miscValue3, unit, this, go); } -void Player::CompletedAchievement(AchievementEntry const* entry) { m_achievementMgr->CompletedAchievement(entry, this); } +void Player::CompletedAchievement(AchievementEntry const* entry) +{ + m_achievementMgr->CompletedAchievement(entry, this); +} bool Player::LearnTalent(uint32 talentId, uint32 talentRank) { @@ -26597,8 +26325,7 @@ bool Player::LearnTalent(uint32 talentId, uint32 talentRank) { for (uint32 i = 0; i < sTalentStore.GetNumRows(); i++) // Loop through all talents. { - if (TalentEntry const* tmpTalent = - sTalentStore.LookupEntry(i)) // Someday, someone needs to revamp the way talents are tracked + if (TalentEntry const* tmpTalent = sTalentStore.LookupEntry(i)) // Someday, someone needs to revamp the way talents are tracked { for (uint8 rank = 0; rank < MAX_TALENT_RANK; ++rank) { @@ -26845,7 +26572,10 @@ void Player::ResummonPetTemporaryUnSummonedIfAny() m_temporaryUnsummonedPetNumber = 0; } -bool Player::IsPetNeedBeTemporaryUnsummoned() const { return !IsInWorld() || !IsAlive() || IsMounted() /*+in flight*/; } +bool Player::IsPetNeedBeTemporaryUnsummoned() const +{ + return !IsInWorld() || !IsAlive() || IsMounted() /*+in flight*/; +} bool Player::CanSeeSpellClickOn(Creature const* c) const { @@ -26861,8 +26591,7 @@ bool Player::CanSeeSpellClickOn(Creature const* c) const if (!itr->second.IsFitToRequirements(this, c)) return false; - if (sConditionMgr->IsObjectMeetingSpellClickConditions( - c->GetEntry(), itr->second.spellId, const_cast(this), const_cast(c))) + if (sConditionMgr->IsObjectMeetingSpellClickConditions(c->GetEntry(), itr->second.spellId, const_cast(this), const_cast(c))) return true; } @@ -27114,9 +26843,8 @@ void Player::SetEquipmentSet(EquipmentSetInfo::EquipmentSetData const& eqSet) auto itr = _equipmentSets.find(eqSet.Guid); if (itr == _equipmentSets.end() || itr->second.Data.Guid != eqSet.Guid) { - LOG_ERROR("entities.player", - "Player::SetEquipmentSet: Player '%s' (%s) tried to save nonexistent equipment set " UI64FMTD " (index: %u)", - GetName().c_str(), GetGUID().ToString().c_str(), eqSet.Guid, eqSet.SetID); + LOG_ERROR("entities.player", "Player::SetEquipmentSet: Player '%s' (%s) tried to save nonexistent equipment set " UI64FMTD " (index: %u)", GetName().c_str(), GetGUID().ToString().c_str(), + eqSet.Guid, eqSet.SetID); return; } } @@ -27472,8 +27200,7 @@ void Player::ActivateSpec(uint8 spec) // skip non-existing talent ranks if (talentInfo->SpellRank[rank] == 0) continue; - RemoveSpell( - talentInfo->SpellRank[rank], true); // removes the talent, and all dependant, learned, and chained spells.. + RemoveSpell(talentInfo->SpellRank[rank], true); // removes the talent, and all dependant, learned, and chained spells.. if (SpellInfo const* _spellEntry = sSpellMgr->GetSpellInfo(talentInfo->SpellRank[rank])) for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) // search through the SpellInfo for valid trigger spells if (_spellEntry->Effects[i].TriggerSpell > 0 && _spellEntry->Effects[i].Effect == SPELL_EFFECT_LEARN_SPELL) @@ -27619,7 +27346,10 @@ uint32 Player::GetReputation(uint32 factionentry) const return GetReputationMgr().GetReputation(sFactionStore.LookupEntry(factionentry)); } -std::string Player::GetGuildName() const { return GetGuildId() ? sGuildMgr->GetGuildById(GetGuildId())->GetName() : ""; } +std::string Player::GetGuildName() const +{ + return GetGuildId() ? sGuildMgr->GetGuildById(GetGuildId())->GetName() : ""; +} void Player::SendDuelCountdown(uint32 counter) { @@ -27628,7 +27358,10 @@ void Player::SendDuelCountdown(uint32 counter) SendDirectMessage(&data); } -void Player::AddRefundReference(ObjectGuid it) { m_refundableItems.insert(it); } +void Player::AddRefundReference(ObjectGuid it) +{ + m_refundableItems.insert(it); +} void Player::DeleteRefundReference(ObjectGuid it) { @@ -27675,9 +27408,8 @@ void Player::SendRefundInfo(Item* item) data.FlushBits(); data.WriteByteSeq(guid[7]); - data << uint32( - std::max(0, 2 * HOUR * IN_MILLISECONDS - item->GetPlayedTime(this) * IN_MILLISECONDS)); // Refund Time Left - for (uint8 i = 0; i < MAX_ITEM_EXT_COST_ITEMS; ++i) // item cost data + data << uint32(std::max(0, 2 * HOUR * IN_MILLISECONDS - item->GetPlayedTime(this) * IN_MILLISECONDS)); // Refund Time Left + for (uint8 i = 0; i < MAX_ITEM_EXT_COST_ITEMS; ++i) // item cost data { data << uint32(iece->RequiredItemCount[i]); data << uint32(iece->RequiredItem[i]); @@ -27989,25 +27721,22 @@ float Player::GetAverageItemLevel() const break; } - getEffectiveItemLevel(static_cast(itemTemplate->GetBaseItemLevel()), - &itemLevelPerInvType[itemTemplate->GetInventoryType()], pEffective); + getEffectiveItemLevel(static_cast(itemTemplate->GetBaseItemLevel()), &itemLevelPerInvType[itemTemplate->GetInventoryType()], pEffective); } - uint32 maxRangedThrownRelicRangedRight = std::max({itemLevelPerInvType[INVTYPE_RANGED], - itemLevelPerInvType[INVTYPE_RANGEDRIGHT], itemLevelPerInvType[INVTYPE_RELIC], itemLevelPerInvType[INVTYPE_THROWN]}); + uint32 maxRangedThrownRelicRangedRight = + std::max({itemLevelPerInvType[INVTYPE_RANGED], itemLevelPerInvType[INVTYPE_RANGEDRIGHT], itemLevelPerInvType[INVTYPE_RELIC], itemLevelPerInvType[INVTYPE_THROWN]}); uint32 offHandItemLevel = 0; uint32 mainHandItemLevel = 0; - if (getClass() == CLASS_WARRIOR || getClass() == CLASS_ROGUE || getClass() == CLASS_SHAMAN || getClass() == CLASS_HUNTER || - getClass() == CLASS_DEATH_KNIGHT) + if (getClass() == CLASS_WARRIOR || getClass() == CLASS_ROGUE || getClass() == CLASS_SHAMAN || getClass() == CLASS_HUNTER || getClass() == CLASS_DEATH_KNIGHT) { uint8 const weaponSorterSize = 6; std::array weaponSorter; weaponSorter[0] = itemLevelPerInvType[INVTYPE_WEAPONMAINHAND]; - weaponSorter[1] = std::max({itemLevelPerInvType[INVTYPE_SHIELD], itemLevelPerInvType[INVTYPE_WEAPONOFFHAND], - itemLevelPerInvType[INVTYPE_HOLDABLE]}); + weaponSorter[1] = std::max({itemLevelPerInvType[INVTYPE_SHIELD], itemLevelPerInvType[INVTYPE_WEAPONOFFHAND], itemLevelPerInvType[INVTYPE_HOLDABLE]}); weaponSorter[2] = itemLevelPerInvType[INVTYPE_WEAPON]; weaponSorter[3] = weaponItemLevel; @@ -28160,8 +27889,7 @@ uint8 Player::AddVoidStorageItem(VoidStorageItem const& item) return 255; } - _voidStorageItems[slot] = - new VoidStorageItem(item.ItemId, item.ItemEntry, item.CreatorGuid, item.ItemRandomPropertyId, item.ItemSuffixFactor); + _voidStorageItems[slot] = new VoidStorageItem(item.ItemId, item.ItemEntry, item.CreatorGuid, item.ItemRandomPropertyId, item.ItemSuffixFactor); return slot; } @@ -28183,8 +27911,7 @@ void Player::AddVoidStorageItemAtSlot(uint8 slot, const VoidStorageItem& item) return; } - _voidStorageItems[slot] = - new VoidStorageItem(item.ItemId, item.ItemId, item.CreatorGuid, item.ItemRandomPropertyId, item.ItemSuffixFactor); + _voidStorageItems[slot] = new VoidStorageItem(item.ItemId, item.ItemId, item.CreatorGuid, item.ItemRandomPropertyId, item.ItemSuffixFactor); } void Player::DeleteVoidStorageItem(uint8 slot) @@ -28247,8 +27974,7 @@ std::string Player::GetMapAreaAndZoneString() const } std::ostringstream str; - str << "Map: " << GetMapId() << " (" << (FindMap() ? FindMap()->GetMapName() : "Unknown") << ") Area: " << areaId << " (" - << areaName.c_str() << ") Zone: " << zoneName.c_str(); + str << "Map: " << GetMapId() << " (" << (FindMap() ? FindMap()->GetMapName() : "Unknown") << ") Area: " << areaId << " (" << areaName.c_str() << ") Zone: " << zoneName.c_str(); return str.str(); } @@ -28272,8 +27998,8 @@ Pet* Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetTy pet->Relocate(x, y, z, ang); if (!pet->IsPositionValid()) { - LOG_ERROR("misc", "Player::SummonPet: Pet (%s, Entry: %d) not summoned. Suggested coordinates aren't valid (X: %f Y: %f)", - pet->GetGUID().ToString().c_str(), pet->GetEntry(), pet->GetPositionX(), pet->GetPositionY()); + LOG_ERROR("misc", "Player::SummonPet: Pet (%s, Entry: %d) not summoned. Suggested coordinates aren't valid (X: %f Y: %f)", pet->GetGUID().ToString().c_str(), pet->GetEntry(), + pet->GetPositionX(), pet->GetPositionY()); delete pet; return nullptr; } @@ -28319,8 +28045,7 @@ Pet* Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetTy pet->SetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_CLASS, CLASS_MAGE); pet->SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, 0); pet->SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, 1000); - pet->SetUInt32Value( - UNIT_FIELD_PET_NAME_TIMESTAMP, uint32(GameTime::GetGameTime())); // cast can't be helped in this case + pet->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, uint32(GameTime::GetGameTime())); // cast can't be helped in this case break; default: break; @@ -28334,8 +28059,7 @@ Pet* Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetTy pet->InitPetCreateSpells(); pet->SavePetToDB(PET_SAVE_NEW_PET); PetSpellInitialize(); - GetSession()->SendPetAdded( - pet->GetSlot(), pet->GetCharmInfo()->GetPetNumber(), pet->GetEntry(), pet->getLevel(), pet->GetName()); + GetSession()->SendPetAdded(pet->GetSlot(), pet->GetCharmInfo()->GetPetNumber(), pet->GetEntry(), pet->getLevel(), pet->GetName()); break; default: break; @@ -28365,28 +28089,30 @@ Pet* Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetTy return pet; } -bool Player::CanUseMastery() const { return HasSpell(MasterySpells[getClass()]); } +bool Player::CanUseMastery() const +{ + return HasSpell(MasterySpells[getClass()]); +} void Player::ValidateMovementInfo(MovementInfo* mi) { //! Anti-cheat checks. Please keep them in seperate if () blocks to maintain a clear overview. //! Might be subject to latency, so just remove improper flags. #ifdef FC_DEBUG -#define REMOVE_VIOLATING_FLAGS(check, maskToRemove) \ - { \ - if (check) \ - { \ - LOG_DEBUG("entities.unit", \ - "Player::ValidateMovementInfo: Violation of MovementFlags found (%s). " \ - "MovementFlags: %u, MovementFlags2: %u for player %s. Mask %u will be removed.", \ - STRINGIZE(check), mi->GetMovementFlags(), mi->GetExtraMovementFlags(), GetGUID().ToString().c_str(), \ - maskToRemove); \ - mi->RemoveMovementFlag((maskToRemove)); \ - } \ +#define REMOVE_VIOLATING_FLAGS(check, maskToRemove) \ + { \ + if (check) \ + { \ + LOG_DEBUG("entities.unit", \ + "Player::ValidateMovementInfo: Violation of MovementFlags found (%s). " \ + "MovementFlags: %u, MovementFlags2: %u for player %s. Mask %u will be removed.", \ + STRINGIZE(check), mi->GetMovementFlags(), mi->GetExtraMovementFlags(), GetGUID().ToString().c_str(), maskToRemove); \ + mi->RemoveMovementFlag((maskToRemove)); \ + } \ } #else -#define REMOVE_VIOLATING_FLAGS(check, maskToRemove) \ - if (check) \ +#define REMOVE_VIOLATING_FLAGS(check, maskToRemove) \ + if (check) \ mi->RemoveMovementFlag((maskToRemove)); #endif @@ -28396,8 +28122,7 @@ void Player::ValidateMovementInfo(MovementInfo* mi) return; } - Unit* mover = - GetCharmedOrSelf()->GetGUID() == mi->guid ? GetCharmedOrSelf() : ObjectAccessor::GetUnit(*GetCharmedOrSelf(), mi->guid); + Unit* mover = GetCharmedOrSelf()->GetGUID() == mi->guid ? GetCharmedOrSelf() : ObjectAccessor::GetUnit(*GetCharmedOrSelf(), mi->guid); if (!mover) { LOG_ERROR("entities.unit", @@ -28407,49 +28132,38 @@ void Player::ValidateMovementInfo(MovementInfo* mi) return; } - if (!GetCharmedOrSelf()->GetVehicleBase() || - !(GetCharmedOrSelf()->GetVehicle()->GetVehicleInfo()->Flags & VEHICLE_FLAG_FIXED_POSITION)) + if (!GetCharmedOrSelf()->GetVehicleBase() || !(GetCharmedOrSelf()->GetVehicle()->GetVehicleInfo()->Flags & VEHICLE_FLAG_FIXED_POSITION)) REMOVE_VIOLATING_FLAGS(mi->HasMovementFlag(MOVEMENTFLAG_ROOT), MOVEMENTFLAG_ROOT); /*! This must be a packet spoofing attempt. MOVEMENTFLAG_ROOT sent from the client is not valid in conjunction with any of the moving movement flags such as MOVEMENTFLAG_FORWARD. It will freeze clients that receive this player's movement info. */ - REMOVE_VIOLATING_FLAGS( - mi->HasMovementFlag(MOVEMENTFLAG_ROOT) && mi->HasMovementFlag(MOVEMENTFLAG_MASK_MOVING), MOVEMENTFLAG_MASK_MOVING); + REMOVE_VIOLATING_FLAGS(mi->HasMovementFlag(MOVEMENTFLAG_ROOT) && mi->HasMovementFlag(MOVEMENTFLAG_MASK_MOVING), MOVEMENTFLAG_MASK_MOVING); //! Cannot hover without SPELL_AURA_HOVER REMOVE_VIOLATING_FLAGS(mi->HasMovementFlag(MOVEMENTFLAG_HOVER) && !mover->HasAuraType(SPELL_AURA_HOVER), MOVEMENTFLAG_HOVER); //! Cannot ascend and descend at the same time - REMOVE_VIOLATING_FLAGS(mi->HasMovementFlag(MOVEMENTFLAG_ASCENDING) && mi->HasMovementFlag(MOVEMENTFLAG_DESCENDING), - MOVEMENTFLAG_ASCENDING | MOVEMENTFLAG_DESCENDING); + REMOVE_VIOLATING_FLAGS(mi->HasMovementFlag(MOVEMENTFLAG_ASCENDING) && mi->HasMovementFlag(MOVEMENTFLAG_DESCENDING), MOVEMENTFLAG_ASCENDING | MOVEMENTFLAG_DESCENDING); //! Cannot move left and right at the same time - REMOVE_VIOLATING_FLAGS(mi->HasMovementFlag(MOVEMENTFLAG_LEFT) && mi->HasMovementFlag(MOVEMENTFLAG_RIGHT), - MOVEMENTFLAG_LEFT | MOVEMENTFLAG_RIGHT); + REMOVE_VIOLATING_FLAGS(mi->HasMovementFlag(MOVEMENTFLAG_LEFT) && mi->HasMovementFlag(MOVEMENTFLAG_RIGHT), MOVEMENTFLAG_LEFT | MOVEMENTFLAG_RIGHT); //! Cannot strafe left and right at the same time - REMOVE_VIOLATING_FLAGS(mi->HasMovementFlag(MOVEMENTFLAG_STRAFE_LEFT) && mi->HasMovementFlag(MOVEMENTFLAG_STRAFE_RIGHT), - MOVEMENTFLAG_STRAFE_LEFT | MOVEMENTFLAG_STRAFE_RIGHT); + REMOVE_VIOLATING_FLAGS(mi->HasMovementFlag(MOVEMENTFLAG_STRAFE_LEFT) && mi->HasMovementFlag(MOVEMENTFLAG_STRAFE_RIGHT), MOVEMENTFLAG_STRAFE_LEFT | MOVEMENTFLAG_STRAFE_RIGHT); //! Cannot pitch up and down at the same time - REMOVE_VIOLATING_FLAGS(mi->HasMovementFlag(MOVEMENTFLAG_PITCH_UP) && mi->HasMovementFlag(MOVEMENTFLAG_PITCH_DOWN), - MOVEMENTFLAG_PITCH_UP | MOVEMENTFLAG_PITCH_DOWN); + REMOVE_VIOLATING_FLAGS(mi->HasMovementFlag(MOVEMENTFLAG_PITCH_UP) && mi->HasMovementFlag(MOVEMENTFLAG_PITCH_DOWN), MOVEMENTFLAG_PITCH_UP | MOVEMENTFLAG_PITCH_DOWN); //! Cannot move forwards and backwards at the same time - REMOVE_VIOLATING_FLAGS(mi->HasMovementFlag(MOVEMENTFLAG_FORWARD) && mi->HasMovementFlag(MOVEMENTFLAG_BACKWARD), - MOVEMENTFLAG_FORWARD | MOVEMENTFLAG_BACKWARD); + REMOVE_VIOLATING_FLAGS(mi->HasMovementFlag(MOVEMENTFLAG_FORWARD) && mi->HasMovementFlag(MOVEMENTFLAG_BACKWARD), MOVEMENTFLAG_FORWARD | MOVEMENTFLAG_BACKWARD); //! Cannot walk on water without SPELL_AURA_WATER_WALK except for ghosts - REMOVE_VIOLATING_FLAGS(mi->HasMovementFlag(MOVEMENTFLAG_WATERWALKING) && !mover->HasAuraType(SPELL_AURA_WATER_WALK) && - !mover->HasAuraType(SPELL_AURA_GHOST), - MOVEMENTFLAG_WATERWALKING); + REMOVE_VIOLATING_FLAGS(mi->HasMovementFlag(MOVEMENTFLAG_WATERWALKING) && !mover->HasAuraType(SPELL_AURA_WATER_WALK) && !mover->HasAuraType(SPELL_AURA_GHOST), MOVEMENTFLAG_WATERWALKING); //! Cannot feather fall without SPELL_AURA_FEATHER_FALL - REMOVE_VIOLATING_FLAGS( - mi->HasMovementFlag(MOVEMENTFLAG_FALLING_SLOW) && !GetCharmedOrSelf()->HasAuraType(SPELL_AURA_FEATHER_FALL), - MOVEMENTFLAG_FALLING_SLOW); + REMOVE_VIOLATING_FLAGS(mi->HasMovementFlag(MOVEMENTFLAG_FALLING_SLOW) && !GetCharmedOrSelf()->HasAuraType(SPELL_AURA_FEATHER_FALL), MOVEMENTFLAG_FALLING_SLOW); /*! Cannot fly if no fly auras present. Exception is being a GM. Note that we check for account level instead of Player::IsGameMaster() because in some @@ -28457,17 +28171,13 @@ void Player::ValidateMovementInfo(MovementInfo* mi) e.g. aerial combat. */ - REMOVE_VIOLATING_FLAGS(mi->HasMovementFlag(MOVEMENTFLAG_FLYING | MOVEMENTFLAG_CAN_FLY) && - GetSession()->GetSecurity() == SEC_PLAYER && !mover->HasAuraType(SPELL_AURA_FLY) && + REMOVE_VIOLATING_FLAGS(mi->HasMovementFlag(MOVEMENTFLAG_FLYING | MOVEMENTFLAG_CAN_FLY) && GetSession()->GetSecurity() == SEC_PLAYER && !mover->HasAuraType(SPELL_AURA_FLY) && !mover->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED), MOVEMENTFLAG_FLYING | MOVEMENTFLAG_CAN_FLY); - REMOVE_VIOLATING_FLAGS( - mi->HasMovementFlag(MOVEMENTFLAG_DISABLE_GRAVITY | MOVEMENTFLAG_CAN_FLY) && mi->HasMovementFlag(MOVEMENTFLAG_FALLING), - MOVEMENTFLAG_FALLING); + REMOVE_VIOLATING_FLAGS(mi->HasMovementFlag(MOVEMENTFLAG_DISABLE_GRAVITY | MOVEMENTFLAG_CAN_FLY) && mi->HasMovementFlag(MOVEMENTFLAG_FALLING), MOVEMENTFLAG_FALLING); - REMOVE_VIOLATING_FLAGS(mi->HasMovementFlag(MOVEMENTFLAG_SPLINE_ELEVATION) && G3D::fuzzyEq(mi->splineElevation, 0.0f), - MOVEMENTFLAG_SPLINE_ELEVATION); + REMOVE_VIOLATING_FLAGS(mi->HasMovementFlag(MOVEMENTFLAG_SPLINE_ELEVATION) && G3D::fuzzyEq(mi->splineElevation, 0.0f), MOVEMENTFLAG_SPLINE_ELEVATION); // Client first checks if spline elevation != 0, then verifies flag presence if (G3D::fuzzyNe(mi->splineElevation, 0.0f)) @@ -28481,8 +28191,7 @@ void Player::ReadMovementInfo(WorldPacket& data, MovementInfo* mi, Movement::Ext MovementStatusElements const* sequence = GetMovementStatusElementsSequence(static_cast(data.GetOpcode())); if (!sequence) { - LOG_ERROR("network", "Player::ReadMovementInfo: No movement sequence found for opcode %s", - GetOpcodeNameForLogging(static_cast(data.GetOpcode())).c_str()); + LOG_ERROR("network", "Player::ReadMovementInfo: No movement sequence found for opcode %s", GetOpcodeNameForLogging(static_cast(data.GetOpcode())).c_str()); return; } @@ -28706,8 +28415,7 @@ void Player::SendSupercededSpell(uint32 oldSpell, uint32 newSpell) const SendDirectMessage(packet.Write()); } -bool Player::ValidateAppearance(uint8 race, uint8 class_, uint8 gender, uint8 hairID, uint8 hairColor, uint8 faceID, - uint8 facialStyle, uint8 skinColor, bool create /*=false*/) +bool Player::ValidateAppearance(uint8 race, uint8 class_, uint8 gender, uint8 hairID, uint8 hairColor, uint8 faceID, uint8 facialStyle, uint8 skinColor, bool create /*=false*/) { // Check skin color // For Skin type is always 0 @@ -28716,8 +28424,7 @@ bool Player::ValidateAppearance(uint8 race, uint8 class_, uint8 gender, uint8 ha if (CharSectionsEntry const* entry2 = sDBCManager.GetCharSectionEntry(race, SECTION_TYPE_FACE, gender, faceID, skinColor)) { // Check DeathKnight exclusive - if (((entry->Flags & SECTION_FLAG_DEATH_KNIGHT) || (entry2->Flags & SECTION_FLAG_DEATH_KNIGHT)) && - class_ != CLASS_DEATH_KNIGHT) + if (((entry->Flags & SECTION_FLAG_DEATH_KNIGHT) || (entry2->Flags & SECTION_FLAG_DEATH_KNIGHT)) && class_ != CLASS_DEATH_KNIGHT) return false; if (create && !((entry->Flags & SECTION_FLAG_PLAYER) && (entry2->Flags & SECTION_FLAG_PLAYER))) return false; @@ -28729,8 +28436,7 @@ bool Player::ValidateAppearance(uint8 race, uint8 class_, uint8 gender, uint8 ha return false; // These combinations don't have an entry of Type SECTION_TYPE_FACIAL_HAIR, exclude them from that check - bool excludeCheck = (race == RACE_TAUREN) || (race == RACE_DRAENEI) || - (gender == GENDER_FEMALE && race != RACE_NIGHTELF && race != RACE_UNDEAD_PLAYER); + bool excludeCheck = (race == RACE_TAUREN) || (race == RACE_DRAENEI) || (gender == GENDER_FEMALE && race != RACE_NIGHTELF && race != RACE_UNDEAD_PLAYER); // Check Hair if (CharSectionsEntry const* entry = sDBCManager.GetCharSectionEntry(race, SECTION_TYPE_HAIR, gender, hairID, hairColor)) @@ -28742,8 +28448,7 @@ bool Player::ValidateAppearance(uint8 race, uint8 class_, uint8 gender, uint8 ha if (!excludeCheck) { - if (CharSectionsEntry const* entry2 = - sDBCManager.GetCharSectionEntry(race, SECTION_TYPE_FACIAL_HAIR, gender, facialStyle, hairColor)) + if (CharSectionsEntry const* entry2 = sDBCManager.GetCharSectionEntry(race, SECTION_TYPE_FACIAL_HAIR, gender, facialStyle, hairColor)) { if ((entry2->Flags & SECTION_FLAG_DEATH_KNIGHT) && class_ != CLASS_DEATH_KNIGHT) return false; @@ -28767,7 +28472,9 @@ bool Player::ValidateAppearance(uint8 race, uint8 class_, uint8 gender, uint8 ha struct CategoryCooldownInfo { - CategoryCooldownInfo(uint32 category, int32 cooldown) : Category(category), ModCooldown(cooldown) {} + CategoryCooldownInfo(uint32 category, int32 cooldown) : Category(category), ModCooldown(cooldown) + { + } uint32 Category = 0; ///< SpellCategory Id int32 ModCooldown = 0; ///< Reduced Cooldown in ms @@ -28782,8 +28489,7 @@ void Player::SendSpellCategoryCooldowns() const { uint32 categoryId = aurEff->GetMiscValue(); auto cItr = std::find_if(cooldowns.CategoryCooldowns.begin(), cooldowns.CategoryCooldowns.end(), - [categoryId](WorldPackets::Spells::CategoryCooldown::CategoryCooldownInfo const& cooldown) - { return cooldown.Category == categoryId; }); + [categoryId](WorldPackets::Spells::CategoryCooldown::CategoryCooldownInfo const& cooldown) { return cooldown.Category == categoryId; }); if (cItr == cooldowns.CategoryCooldowns.end()) cooldowns.CategoryCooldowns.emplace_back(categoryId, -aurEff->GetAmount()); @@ -28869,4 +28575,7 @@ void Player::SendTamePetFailure(PetTameFailureReason reason) SendDirectMessage(&data); } -GameClient* Player::GetGameClient() const { return GetSession()->GetGameClient(); } +GameClient* Player::GetGameClient() const +{ + return GetSession()->GetGameClient(); +} diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index 02662e66..8cd74d6a 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -2233,6 +2233,8 @@ class FC_GAME_API Player : public Unit, public GridObject return m_spellPenetrationItemMod; } + bool CanApplyResilience() const override { return true; } + float GetExpertiseDodgeOrParryReduction(WeaponAttackType attType) const; void UpdateBlockPercentage(); void UpdateCritPercentage(WeaponAttackType attType); diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index e400e9d8..f72d7d06 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -110,17 +110,15 @@ float playerBaseMoveSpeed[MAX_MOVE_TYPE] = { 3.14f // MOVE_PITCH_RATE }; -DamageInfo::DamageInfo(Unit* attacker, Unit* victim, uint32 damage, SpellInfo const* spellInfo, SpellSchoolMask schoolMask, - DamageEffectType damageType, WeaponAttackType attackType) - : m_attacker(attacker), m_victim(victim), m_damage(damage), m_spellInfo(spellInfo), m_schoolMask(schoolMask), - m_damageType(damageType), m_attackType(attackType), m_absorb(0), m_resist(0), m_block(0), m_hitMask(0) +DamageInfo::DamageInfo(Unit* attacker, Unit* victim, uint32 damage, SpellInfo const* spellInfo, SpellSchoolMask schoolMask, DamageEffectType damageType, WeaponAttackType attackType) + : m_attacker(attacker), m_victim(victim), m_damage(damage), m_spellInfo(spellInfo), m_schoolMask(schoolMask), m_damageType(damageType), m_attackType(attackType), m_absorb(0), m_resist(0), + m_block(0), m_hitMask(0) { } DamageInfo::DamageInfo(CalcDamageInfo const& dmgInfo) - : m_attacker(dmgInfo.attacker), m_victim(dmgInfo.target), m_damage(dmgInfo.damage), m_spellInfo(nullptr), - m_schoolMask(SpellSchoolMask(dmgInfo.damageSchoolMask)), m_damageType(DIRECT_DAMAGE), m_attackType(dmgInfo.attackType), - m_absorb(dmgInfo.absorb), m_resist(dmgInfo.resist), m_block(dmgInfo.blocked_amount), m_hitMask(0) + : m_attacker(dmgInfo.attacker), m_victim(dmgInfo.target), m_damage(dmgInfo.damage), m_spellInfo(nullptr), m_schoolMask(SpellSchoolMask(dmgInfo.damageSchoolMask)), m_damageType(DIRECT_DAMAGE), + m_attackType(dmgInfo.attackType), m_absorb(dmgInfo.absorb), m_resist(dmgInfo.resist), m_block(dmgInfo.blocked_amount), m_hitMask(0) { switch (dmgInfo.TargetState) { @@ -141,8 +139,7 @@ DamageInfo::DamageInfo(CalcDamageInfo const& dmgInfo) if (m_block) m_hitMask |= PROC_HIT_BLOCK; - bool const damageNullified = (dmgInfo.HitInfo & (HITINFO_FULL_ABSORB | HITINFO_FULL_RESIST)) != 0 || - (m_hitMask & (PROC_HIT_IMMUNE | PROC_HIT_FULL_BLOCK)) != 0; + bool const damageNullified = (dmgInfo.HitInfo & (HITINFO_FULL_ABSORB | HITINFO_FULL_RESIST)) != 0 || (m_hitMask & (PROC_HIT_IMMUNE | PROC_HIT_FULL_BLOCK)) != 0; switch (dmgInfo.hitOutCome) { case MELEE_HIT_MISS: @@ -171,13 +168,10 @@ DamageInfo::DamageInfo(CalcDamageInfo const& dmgInfo) } } -DamageInfo::DamageInfo( - SpellNonMeleeDamage const& spellNonMeleeDamage, DamageEffectType damageType, WeaponAttackType attackType, uint32 hitMask) - : m_attacker(spellNonMeleeDamage.attacker), m_victim(spellNonMeleeDamage.target), m_damage(spellNonMeleeDamage.damage), - m_spellInfo(sSpellMgr->GetSpellInfo(spellNonMeleeDamage.SpellID)), - m_schoolMask(SpellSchoolMask(spellNonMeleeDamage.schoolMask)), m_damageType(damageType), m_attackType(attackType), - m_absorb(spellNonMeleeDamage.absorb), m_resist(spellNonMeleeDamage.resist), m_block(spellNonMeleeDamage.blocked), - m_hitMask(hitMask) +DamageInfo::DamageInfo(SpellNonMeleeDamage const& spellNonMeleeDamage, DamageEffectType damageType, WeaponAttackType attackType, uint32 hitMask) + : m_attacker(spellNonMeleeDamage.attacker), m_victim(spellNonMeleeDamage.target), m_damage(spellNonMeleeDamage.damage), m_spellInfo(sSpellMgr->GetSpellInfo(spellNonMeleeDamage.SpellID)), + m_schoolMask(SpellSchoolMask(spellNonMeleeDamage.schoolMask)), m_damageType(damageType), m_attackType(attackType), m_absorb(spellNonMeleeDamage.absorb), m_resist(spellNonMeleeDamage.resist), + m_block(spellNonMeleeDamage.blocked), m_hitMask(hitMask) { if (spellNonMeleeDamage.blocked) m_hitMask |= PROC_HIT_BLOCK; @@ -224,11 +218,13 @@ void DamageInfo::BlockDamage(uint32 amount) } } -uint32 DamageInfo::GetHitMask() const { return m_hitMask; } +uint32 DamageInfo::GetHitMask() const +{ + return m_hitMask; +} HealInfo::HealInfo(Unit* healer, Unit* target, uint32 heal, SpellInfo const* spellInfo, SpellSchoolMask schoolMask) - : _healer(healer), _target(target), _heal(heal), _effectiveHeal(0), _absorb(0), _spellInfo(spellInfo), - _schoolMask(schoolMask), _hitMask(0) + : _healer(healer), _target(target), _heal(heal), _effectiveHeal(0), _absorb(0), _spellInfo(spellInfo), _schoolMask(schoolMask), _hitMask(0) { } @@ -242,12 +238,15 @@ void HealInfo::AbsorbHeal(uint32 amount) _hitMask |= PROC_HIT_ABSORB; } -uint32 HealInfo::GetHitMask() const { return _hitMask; } +uint32 HealInfo::GetHitMask() const +{ + return _hitMask; +} -ProcEventInfo::ProcEventInfo(Unit* actor, Unit* actionTarget, Unit* procTarget, uint32 typeMask, uint32 spellTypeMask, - uint32 spellPhaseMask, uint32 hitMask, Spell* spell, DamageInfo* damageInfo, HealInfo* healInfo) - : _actor(actor), _actionTarget(actionTarget), _procTarget(procTarget), _typeMask(typeMask), _spellTypeMask(spellTypeMask), - _spellPhaseMask(spellPhaseMask), _hitMask(hitMask), _spell(spell), _damageInfo(damageInfo), _healInfo(healInfo) +ProcEventInfo::ProcEventInfo( + Unit* actor, Unit* actionTarget, Unit* procTarget, uint32 typeMask, uint32 spellTypeMask, uint32 spellPhaseMask, uint32 hitMask, Spell* spell, DamageInfo* damageInfo, HealInfo* healInfo) + : _actor(actor), _actionTarget(actionTarget), _procTarget(procTarget), _typeMask(typeMask), _spellTypeMask(spellTypeMask), _spellPhaseMask(spellPhaseMask), _hitMask(hitMask), _spell(spell), + _damageInfo(damageInfo), _healInfo(healInfo) { } @@ -273,22 +272,22 @@ SpellSchoolMask ProcEventInfo::GetSchoolMask() const return SPELL_SCHOOL_MASK_NONE; } -DispelableAura::DispelableAura(Aura* aura, int32 dispelChance, uint8 dispelCharges) - : _aura(aura), _chance(dispelChance), _charges(dispelCharges) +DispelableAura::DispelableAura(Aura* aura, int32 dispelChance, uint8 dispelCharges) : _aura(aura), _chance(dispelChance), _charges(dispelCharges) { } DispelableAura::~DispelableAura() = default; -bool DispelableAura::RollDispel() const { return roll_chance_i(_chance); } +bool DispelableAura::RollDispel() const +{ + return roll_chance_i(_chance); +} Unit::Unit(bool isWorldObject) - : WorldObject(isWorldObject), m_lastSanctuaryTime(0), LastCharmerGUID(), m_ControlledByPlayer(false), - movespline(new Movement::MoveSpline()), m_AutoRepeatFirstCast(false), m_procDeep(0), m_removedAurasCount(0), - m_interruptMask(SpellAuraInterruptFlags::None), m_interruptMask2(SpellAuraInterruptFlags2::None), m_charmer(nullptr), - m_charmed(nullptr), i_motionMaster(new MotionMaster(this)), m_vehicle(nullptr), m_vehicleKit(nullptr), - m_unitTypeMask(UNIT_MASK_NONE), m_Diminishing(), m_isEngaged(false), m_combatManager(this), m_threatManager(this), - i_AI(nullptr), m_aiLocked(false), m_spellHistory(new SpellHistory(this)), _isIgnoringCombat(false), _scheduler(this) + : WorldObject(isWorldObject), m_lastSanctuaryTime(0), LastCharmerGUID(), m_ControlledByPlayer(false), movespline(new Movement::MoveSpline()), m_AutoRepeatFirstCast(false), m_procDeep(0), + m_removedAurasCount(0), m_interruptMask(SpellAuraInterruptFlags::None), m_interruptMask2(SpellAuraInterruptFlags2::None), m_charmer(nullptr), m_charmed(nullptr), + i_motionMaster(new MotionMaster(this)), m_vehicle(nullptr), m_vehicleKit(nullptr), m_unitTypeMask(UNIT_MASK_NONE), m_Diminishing(), m_isEngaged(false), m_combatManager(this), + m_threatManager(this), i_AI(nullptr), m_aiLocked(false), m_spellHistory(new SpellHistory(this)), _isIgnoringCombat(false), _scheduler(this) { m_objectType |= TYPEMASK_UNIT; m_objectTypeId = TYPEID_UNIT; @@ -699,9 +698,7 @@ bool Unit::HasBreakableByDamageAuraType(AuraType type, uint32 excludeAura) const { AuraEffectList const& auras = GetAuraEffectsByType(type); for (AuraEffectList::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) - if ((!excludeAura || - excludeAura != - (*itr)->GetSpellInfo()->Id) && // Avoid self interrupt of channeled Crowd Control spells like Seduction + if ((!excludeAura || excludeAura != (*itr)->GetSpellInfo()->Id) && // Avoid self interrupt of channeled Crowd Control spells like Seduction (*itr)->GetSpellInfo()->HasAuraInterruptFlag(SpellAuraInterruptFlags::Damage)) return true; return false; @@ -710,22 +707,17 @@ bool Unit::HasBreakableByDamageAuraType(AuraType type, uint32 excludeAura) const bool Unit::HasBreakableByDamageCrowdControlAura(Unit* excludeCasterChannel) const { uint32 excludeAura = 0; - if (Spell* currentChanneledSpell = - excludeCasterChannel ? excludeCasterChannel->GetCurrentSpell(CURRENT_CHANNELED_SPELL) : nullptr) - excludeAura = - currentChanneledSpell->GetSpellInfo()->Id; // Avoid self interrupt of channeled Crowd Control spells like Seduction - - return (HasBreakableByDamageAuraType(SPELL_AURA_MOD_CONFUSE, excludeAura) || - HasBreakableByDamageAuraType(SPELL_AURA_MOD_FEAR, excludeAura) || - HasBreakableByDamageAuraType(SPELL_AURA_MOD_STUN, excludeAura) || - HasBreakableByDamageAuraType(SPELL_AURA_MOD_ROOT, excludeAura) || + if (Spell* currentChanneledSpell = excludeCasterChannel ? excludeCasterChannel->GetCurrentSpell(CURRENT_CHANNELED_SPELL) : nullptr) + excludeAura = currentChanneledSpell->GetSpellInfo()->Id; // Avoid self interrupt of channeled Crowd Control spells like Seduction + + return (HasBreakableByDamageAuraType(SPELL_AURA_MOD_CONFUSE, excludeAura) || HasBreakableByDamageAuraType(SPELL_AURA_MOD_FEAR, excludeAura) || + HasBreakableByDamageAuraType(SPELL_AURA_MOD_STUN, excludeAura) || HasBreakableByDamageAuraType(SPELL_AURA_MOD_ROOT, excludeAura) || HasBreakableByDamageAuraType(SPELL_AURA_TRANSFORM, excludeAura)); } -void Unit::DealDamageMods(Unit const* victim, uint32& damage, uint32* absorb) const +/*static*/ void Unit::DealDamageMods(Unit const* victim, uint32& damage, uint32* absorb) { - if (!victim || !victim->IsAlive() || victim->HasUnitState(UNIT_STATE_IN_FLIGHT) || - (victim->GetTypeId() == TYPEID_UNIT && victim->ToCreature()->IsEvadingAttacks())) + if (!victim || !victim->IsAlive() || victim->HasUnitState(UNIT_STATE_IN_FLIGHT) || (victim->GetTypeId() == TYPEID_UNIT && victim->ToCreature()->IsEvadingAttacks())) { if (absorb) *absorb += damage; @@ -733,45 +725,44 @@ void Unit::DealDamageMods(Unit const* victim, uint32& damage, uint32* absorb) co } } -uint32 Unit::DealDamage(Unit* victim, uint32 damage, CleanDamage const* cleanDamage, DamageEffectType damagetype, - SpellSchoolMask damageSchoolMask, SpellInfo const* spellProto, bool durabilityLoss) +/*static*/ uint32 Unit::DealDamage( + Unit* attacker, Unit* victim, uint32 damage, CleanDamage const* cleanDamage, DamageEffectType damagetype, SpellSchoolMask damageSchoolMask, SpellInfo const* spellProto, bool durabilityLoss) { // Sparring Checks if (Creature* target = victim->ToCreature()) { - if (IsCreature() && !IsCharmedOwnedByPlayerOrPlayer()) + if (attacker->IsCreature() && !attacker->IsCharmedOwnedByPlayerOrPlayer()) { if (target->GetNoNpcDamageBelowPctHealthValue() != 0.0f) { if (damage >= target->GetHealth()) // First check: if we have a sparring limit we will never allow creatures to // kill the sparring victim damage = target->GetHealth() - 1; - else if (target->GetHealthPct() <= - target->GetNoNpcDamageBelowPctHealthValue()) // Second check: stop incomming damage when we have - // surpassed the health limit + else if (target->GetHealthPct() <= target->GetNoNpcDamageBelowPctHealthValue()) // Second check: stop incomming damage when we have + // surpassed the health limit damage = 0; } } } if (UnitAI* victimAI = victim->GetAI()) - victimAI->DamageTaken(this, damage); + victimAI->DamageTaken(attacker, damage); - if (UnitAI* attackerAI = GetAI()) + if (UnitAI* attackerAI = attacker->GetAI()) attackerAI->DamageDealt(victim, damage, damagetype); // Hook for OnDamage Event - sScriptMgr->OnDamage(this, victim, damage); + sScriptMgr->OnDamage(attacker, victim, damage); if (victim->GetTypeId() == TYPEID_PLAYER) { // Signal to pets that their owner was attacked - except when DOT. - if (this != victim && damagetype != DOT) + if (attacker != victim && damagetype != DOT) { for (Unit* controlled : victim->m_Controlled) if (Creature* cControlled = controlled->ToCreature()) if (CreatureAI* controlledAI = cControlled->AI()) - controlledAI->OwnerAttackedBy(this); + controlledAI->OwnerAttackedBy(attacker); } if (victim->ToPlayer()->GetCommandStatus(CHEAT_GOD)) @@ -811,19 +802,19 @@ uint32 Unit::DealDamage(Unit* victim, uint32 damage, CleanDamage const* cleanDam uint32 share = CalculatePct(damage, (*i)->GetAmount()); /// @todo check packets if damage is done by victim, or by attacker of victim - DealDamageMods(shareDamageTarget, share, nullptr); - DealDamage(shareDamageTarget, share, nullptr, NODAMAGE, spell->GetSchoolMask(), spell, false); + Unit::DealDamageMods(shareDamageTarget, share, nullptr); + Unit::DealDamage(attacker, shareDamageTarget, share, nullptr, NODAMAGE, spell->GetSchoolMask(), spell, false); } } // Rage from Damage made (only from direct weapon damage) - if (cleanDamage && damagetype == DIRECT_DAMAGE && this != victim && GetPowerType() == POWER_RAGE) + if (attacker && cleanDamage && damagetype == DIRECT_DAMAGE && attacker != victim && attacker->GetPowerType() == POWER_RAGE) { - uint32 rage = uint32((float)GetAttackTime(cleanDamage->attackType) / 1000 * 6.5f); + uint32 rage = uint32((float)attacker->GetAttackTime(cleanDamage->attackType) / 1000 * 6.5f); // Sentinel - if (victim->GetVictim() && victim->GetVictim() != this) - if (AuraEffect* aurEff = GetAuraEffect(SPELL_AURA_DUMMY, SPELLFAMILY_GENERIC, 1916, EFFECT_1)) + if (victim->GetVictim() && victim->GetVictim() != attacker) + if (AuraEffect* aurEff = attacker->GetAuraEffect(SPELL_AURA_DUMMY, SPELLFAMILY_GENERIC, 1916, EFFECT_1)) rage += CalculatePct(rage, aurEff->GetAmount()); switch (cleanDamage->attackType) @@ -832,7 +823,7 @@ uint32 Unit::DealDamage(Unit* victim, uint32 damage, CleanDamage const* cleanDam rage /= 2; [[fallthrough]]; case BASE_ATTACK: - RewardRage(rage, true); + attacker->RewardRage(rage, true); break; default: break; @@ -851,29 +842,33 @@ uint32 Unit::DealDamage(Unit* victim, uint32 damage, CleanDamage const* cleanDam LOG_DEBUG("entities.unit", "DealDamageStart"); uint32 health = victim->GetHealth(); - LOG_DEBUG( - "entities.unit", "%s dealt %u damage to %s", GetGUID().ToString().c_str(), damage, victim->GetGUID().ToString().c_str()); + LOG_DEBUG("entities.unit", "%s dealt %u damage to %s", attacker->GetGUID().ToString().c_str(), damage, victim->GetGUID().ToString().c_str()); // duel ends when player has 1 or less hp bool duel_hasEnded = false; bool duel_wasMounted = false; if (victim->GetTypeId() == TYPEID_PLAYER && victim->ToPlayer()->duel && damage >= (health - 1)) { + if (!attacker) + return 0; + // prevent kill only if killed in duel and killed by opponent or opponent controlled creature - if (victim->ToPlayer()->duel->opponent == GetControllingPlayer()) + if (victim->ToPlayer()->duel->opponent == attacker->GetControllingPlayer()) damage = health - 1; duel_hasEnded = true; } - else if (victim->IsVehicle() && damage >= (health - 1) && victim->GetCharmer() && - victim->GetCharmer()->GetTypeId() == TYPEID_PLAYER) + else if (victim->IsVehicle() && damage >= (health - 1) && victim->GetCharmer() && victim->GetCharmer()->GetTypeId() == TYPEID_PLAYER) { Player* victimRider = victim->GetCharmer()->ToPlayer(); if (victimRider && victimRider->duel && victimRider->duel->isMounted) { + if (!attacker) + return 0; + // prevent kill only if killed in duel and killed by opponent or opponent controlled creature - if (victimRider->duel->opponent == GetControllingPlayer()) + if (victimRider->duel->opponent == attacker->GetControllingPlayer()) damage = health - 1; duel_wasMounted = true; @@ -881,9 +876,9 @@ uint32 Unit::DealDamage(Unit* victim, uint32 damage, CleanDamage const* cleanDam } } - if (GetTypeId() == TYPEID_PLAYER && this != victim) + if (attacker && attacker != victim) { - Player* killer = ToPlayer(); + Player* killer = attacker->ToPlayer(); // in bg, count dmg if victim is also a player if (victim->GetTypeId() == TYPEID_PLAYER) @@ -899,26 +894,21 @@ uint32 Unit::DealDamage(Unit* victim, uint32 damage, CleanDamage const* cleanDam else if (!victim->IsControlledByPlayer() || victim->IsVehicle()) { if (!victim->ToCreature()->hasLootRecipient()) - victim->ToCreature()->SetLootRecipient(this); + victim->ToCreature()->SetLootRecipient(attacker); - if (IsControlledByPlayer() || - (ToTempSummon() && ToTempSummon()->GetSummoner() && ToTempSummon()->GetSummoner()->GetTypeId() == TYPEID_PLAYER)) + if (attacker->IsControlledByPlayer() || (attacker->ToTempSummon() && attacker->ToTempSummon()->GetSummoner() && attacker->ToTempSummon()->GetSummoner()->GetTypeId() == TYPEID_PLAYER)) victim->ToCreature()->LowerPlayerDamageReq(health < damage ? health : damage); } if (health <= damage) { - LOG_DEBUG("entities.unit", "DealDamage: victim just died"); - - if (victim->GetTypeId() == TYPEID_PLAYER && victim != this) + if (victim->GetTypeId() == TYPEID_PLAYER && victim != attacker) victim->ToPlayer()->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_TOTAL_DAMAGE_RECEIVED, health); - Kill(victim, durabilityLoss); + Unit::Kill(attacker, victim, durabilityLoss); } else { - LOG_DEBUG("entities.unit", "DealDamageAlive"); - if (victim->GetTypeId() == TYPEID_PLAYER) victim->ToPlayer()->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_TOTAL_DAMAGE_RECEIVED, damage); @@ -930,10 +920,9 @@ uint32 Unit::DealDamage(Unit* victim, uint32 damage, CleanDamage const* cleanDam if (victim->GetTypeId() != TYPEID_PLAYER) { // Part of Evade mechanics. DoT's and Thorns / Retribution Aura do not contribute to this - if (damagetype != DOT && damage > 0 && !victim->GetOwnerGUID().IsPlayer() && - (!spellProto || !spellProto->HasAura(SPELL_AURA_DAMAGE_SHIELD))) + if (damagetype != DOT && damage > 0 && !victim->GetOwnerGUID().IsPlayer() && (!spellProto || !spellProto->HasAura(SPELL_AURA_DAMAGE_SHIELD))) victim->ToCreature()->SetLastDamagedTime(GameTime::GetGameTime() + MAX_AGGRO_RESET_TIME); - victim->GetThreatManager().AddThreat(this, float(damage), spellProto); + victim->GetThreatManager().AddThreat(attacker, float(damage), spellProto); } else // victim is a player { @@ -946,26 +935,25 @@ uint32 Unit::DealDamage(Unit* victim, uint32 damage, CleanDamage const* cleanDam } // Rage from damage received - if (this != victim && victim->GetPowerType() == POWER_RAGE) + if (attacker != victim && victim->GetPowerType() == POWER_RAGE) { uint32 rage_damage = damage + (cleanDamage ? cleanDamage->absorbed_damage : 0); victim->RewardRage(rage_damage, false); } - if (GetTypeId() == TYPEID_PLAYER) + if (attacker && attacker->GetTypeId() == TYPEID_PLAYER) { // random durability for items (HIT DONE) if (roll_chance_f(sWorld->getRate(RATE_DURABILITY_LOSS_DAMAGE))) { EquipmentSlots slot = EquipmentSlots(urand(0, EQUIPMENT_SLOT_END - 1)); - ToPlayer()->DurabilityPointLossForEquipSlot(slot); + attacker->ToPlayer()->DurabilityPointLossForEquipSlot(slot); } } if (damagetype != NODAMAGE) { - if (victim != this && (!spellProto || !(spellProto->HasAttribute(SPELL_ATTR7_NO_PUSHBACK_ON_DAMAGE) || - spellProto->HasAttribute(SPELL_ATTR3_TREAT_AS_PERIODIC)))) + if (victim != attacker && (!spellProto || !(spellProto->HasAttribute(SPELL_ATTR7_NO_PUSHBACK_ON_DAMAGE) || spellProto->HasAttribute(SPELL_ATTR3_TREAT_AS_PERIODIC)))) { if (damagetype != DOT) { @@ -975,8 +963,7 @@ uint32 Unit::DealDamage(Unit* victim, uint32 damage, CleanDamage const* cleanDam { auto isCastInterrupted = [&]() { - if ((victim->IsPlayer() && - spell->m_spellInfo->InterruptFlags.HasFlag(SpellInterruptFlags::DamageCancelsPlayerOnly))) + if ((victim->IsPlayer() && spell->m_spellInfo->InterruptFlags.HasFlag(SpellInterruptFlags::DamageCancelsPlayerOnly))) return true; return false; @@ -987,8 +974,7 @@ uint32 Unit::DealDamage(Unit* victim, uint32 damage, CleanDamage const* cleanDam if (!damage) return false; - if ((victim->IsPlayer() && spell->m_spellInfo->InterruptFlags.HasFlag( - SpellInterruptFlags::DamagePushbackPlayerOnly))) + if ((victim->IsPlayer() && spell->m_spellInfo->InterruptFlags.HasFlag(SpellInterruptFlags::DamagePushbackPlayerOnly))) return true; return false; @@ -1004,8 +990,7 @@ uint32 Unit::DealDamage(Unit* victim, uint32 damage, CleanDamage const* cleanDam if (damage && victim->IsPlayer()) if (Spell* spell = victim->m_currentSpells[CURRENT_CHANNELED_SPELL]) - if (spell->getState() == SPELL_STATE_CASTING && - spell->m_spellInfo->HasChannelInterruptFlag(SpellAuraInterruptFlags::DamageChannelDuration)) + if (spell->getState() == SPELL_STATE_CASTING && spell->m_spellInfo->HasChannelInterruptFlag(SpellAuraInterruptFlags::DamageChannelDuration)) spell->DelayedChannel(); } } @@ -1070,8 +1055,7 @@ void Unit::CastSpell(WorldObject* target, uint32 spellId, CastSpellExtraArgs con targets.SetGOTarget(goTarget); else { - LOG_ERROR("entities.unit", "CastSpell: Invalid target %s passed to spell cast by %s", - target->GetGUID().ToString().c_str(), GetGUID().ToString().c_str()); + LOG_ERROR("entities.unit", "CastSpell: Invalid target %s passed to spell cast by %s", target->GetGUID().ToString().c_str(), GetGUID().ToString().c_str()); return; } } @@ -1085,8 +1069,7 @@ void Unit::CastSpell(Position const& dest, uint32 spellId, CastSpellExtraArgs co CastSpell(targets, spellId, args); } -void Unit::CalculateSpellDamageTaken( - SpellNonMeleeDamage* damageInfo, int32 damage, SpellInfo const* spellInfo, WeaponAttackType attackType, bool crit) +void Unit::CalculateSpellDamageTaken(SpellNonMeleeDamage* damageInfo, int32 damage, SpellInfo const* spellInfo, WeaponAttackType attackType, bool crit) { if (damage < 0) return; @@ -1100,8 +1083,8 @@ void Unit::CalculateSpellDamageTaken( // Spells with SPELL_ATTR4_FIXED_DAMAGE ignore resilience because their damage is based off another spell's damage. if (!spellInfo->HasAttribute(SPELL_ATTR4_FIXED_DAMAGE)) { - if (IsDamageReducedByArmor(damageSchoolMask, spellInfo)) - damage = CalcArmorReducedDamage(victim, damage, spellInfo, attackType); + if (Unit::IsDamageReducedByArmor(damageSchoolMask, spellInfo)) + damage = Unit::CalcArmorReducedDamage(this, victim, damage, spellInfo, attackType); bool blocked = false; // Per-school calc @@ -1141,8 +1124,7 @@ void Unit::CalculateSpellDamageTaken( critPctDamageMod += victim->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_MELEE_CRIT_DAMAGE); // Increase crit damage from SPELL_AURA_MOD_CRIT_DAMAGE_BONUS - critPctDamageMod += - (GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_CRIT_DAMAGE_BONUS, spellInfo->GetSchoolMask()) - 1.0f) * 100; + critPctDamageMod += (GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_CRIT_DAMAGE_BONUS, spellInfo->GetSchoolMask()) - 1.0f) * 100; if (critPctDamageMod != 0) AddPct(damage, critPctDamageMod); @@ -1167,7 +1149,8 @@ void Unit::CalculateSpellDamageTaken( damage -= damageInfo->blocked; } - ApplyResilience(victim, &damage); + if (CanApplyResilience()) + Unit::ApplyResilience(victim, &damage); break; } // Magical Attacks @@ -1181,7 +1164,8 @@ void Unit::CalculateSpellDamageTaken( damage = Unit::SpellCriticalDamageBonus(this, spellInfo, damage); } - ApplyResilience(victim, &damage); + if (CanApplyResilience()) + Unit::ApplyResilience(victim, &damage); break; } default: @@ -1198,7 +1182,7 @@ void Unit::CalculateSpellDamageTaken( damageInfo->damage = damage; DamageInfo dmgInfo(*damageInfo, SPELL_DIRECT_DAMAGE, BASE_ATTACK, PROC_HIT_NONE); - CalcAbsorbResist(dmgInfo); + Unit::CalcAbsorbResist(dmgInfo); damageInfo->absorb = dmgInfo.GetAbsorb(); damageInfo->resist = dmgInfo.GetResist(); @@ -1220,8 +1204,7 @@ void Unit::DealSpellDamage(SpellNonMeleeDamage* damageInfo, bool durabilityLoss) if (!victim) return; - if (!victim->IsAlive() || victim->HasUnitState(UNIT_STATE_IN_FLIGHT) || - (victim->GetTypeId() == TYPEID_UNIT && victim->ToCreature()->IsEvadingAttacks())) + if (!victim->IsAlive() || victim->HasUnitState(UNIT_STATE_IN_FLIGHT) || (victim->GetTypeId() == TYPEID_UNIT && victim->ToCreature()->IsEvadingAttacks())) return; SpellInfo const* spellProto = sSpellMgr->GetSpellInfo(damageInfo->SpellID); @@ -1233,8 +1216,7 @@ void Unit::DealSpellDamage(SpellNonMeleeDamage* damageInfo, bool durabilityLoss) // Call default DealDamage CleanDamage cleanDamage(damageInfo->cleanDamage, damageInfo->absorb, BASE_ATTACK, MELEE_HIT_NORMAL); - DealDamage(victim, damageInfo->damage, &cleanDamage, SPELL_DIRECT_DAMAGE, SpellSchoolMask(damageInfo->schoolMask), spellProto, - durabilityLoss); + Unit::DealDamage(this, victim, damageInfo->damage, &cleanDamage, SPELL_DIRECT_DAMAGE, SpellSchoolMask(damageInfo->schoolMask), spellProto, durabilityLoss); } /// @todo for melee need create structure as in @@ -1286,7 +1268,7 @@ void Unit::CalculateMeleeDamage(Unit* victim, uint32 damage, CalcDamageInfo* dam return; } - damage += CalculateDamage(damageInfo->attackType, false, true); + damage += Unit::CalculateDamage(damageInfo->attackType, false, true); // Add melee damage bonus damage = MeleeDamageBonusDone(damageInfo->target, damage, damageInfo->attackType); damage = damageInfo->target->MeleeDamageBonusTaken(this, damage, damageInfo->attackType); @@ -1295,9 +1277,9 @@ void Unit::CalculateMeleeDamage(Unit* victim, uint32 damage, CalcDamageInfo* dam sScriptMgr->ModifyMeleeDamage(damageInfo->target, damageInfo->attacker, damage); // Calculate armor reduction - if (IsDamageReducedByArmor((SpellSchoolMask)(damageInfo->damageSchoolMask))) + if (Unit::IsDamageReducedByArmor((SpellSchoolMask)(damageInfo->damageSchoolMask))) { - damageInfo->damage = CalcArmorReducedDamage(damageInfo->target, damage, nullptr, damageInfo->attackType); + damageInfo->damage = Unit::CalcArmorReducedDamage(damageInfo->attacker, damageInfo->target, damage, nullptr, damageInfo->attackType); damageInfo->cleanDamage += damage - damageInfo->damage; } else @@ -1356,9 +1338,7 @@ void Unit::CalculateMeleeDamage(Unit* victim, uint32 damage, CalcDamageInfo* dam damageInfo->TargetState = VICTIMSTATE_HIT; damageInfo->HitInfo |= HITINFO_BLOCK; // 30% damage blocked, double blocked amount if block is critical - damageInfo->blocked_amount = - CalculatePct(damageInfo->damage, damageInfo->target->isBlockCritical() ? damageInfo->target->GetBlockPercent() * 2 - : damageInfo->target->GetBlockPercent()); + damageInfo->blocked_amount = CalculatePct(damageInfo->damage, damageInfo->target->isBlockCritical() ? damageInfo->target->GetBlockPercent() * 2 : damageInfo->target->GetBlockPercent()); damageInfo->damage -= damageInfo->blocked_amount; damageInfo->cleanDamage += damageInfo->blocked_amount; break; @@ -1369,9 +1349,8 @@ void Unit::CalculateMeleeDamage(Unit* victim, uint32 damage, CalcDamageInfo* dam int32 leveldif = int32(victim->getLevelForTarget(this)) - int32(getLevel()); if (leveldif < 0) { - LOG_DEBUG("entities.unit", - "Unit::CalculateMeleeDamage: (Player) %s attacked %s. Glancing should never happen against lower level target", - GetGUID().ToString().c_str(), victim->GetGUID().ToString().c_str()); + LOG_DEBUG("entities.unit", "Unit::CalculateMeleeDamage: (Player) %s attacked %s. Glancing should never happen against lower level target", GetGUID().ToString().c_str(), + victim->GetGUID().ToString().c_str()); break; } if (leveldif == 0) @@ -1402,7 +1381,8 @@ void Unit::CalculateMeleeDamage(Unit* victim, uint32 damage, CalcDamageInfo* dam damageInfo->HitInfo |= HITINFO_AFFECTS_VICTIM; int32 resilienceReduction = damageInfo->damage; - ApplyResilience(victim, &resilienceReduction); + if (CanApplyResilience()) + Unit::ApplyResilience(victim, &resilienceReduction); resilienceReduction = damageInfo->damage - resilienceReduction; damageInfo->damage -= resilienceReduction; damageInfo->cleanDamage += resilienceReduction; @@ -1413,7 +1393,7 @@ void Unit::CalculateMeleeDamage(Unit* victim, uint32 damage, CalcDamageInfo* dam damageInfo->procVictim |= PROC_FLAG_TAKE_ANY_DAMAGE; // Calculate absorb & resists DamageInfo dmgInfo(*damageInfo); - CalcAbsorbResist(dmgInfo); + Unit::CalcAbsorbResist(dmgInfo); damageInfo->absorb = dmgInfo.GetAbsorb(); damageInfo->resist = dmgInfo.GetResist(); @@ -1433,13 +1413,10 @@ void Unit::DealMeleeDamage(CalcDamageInfo* damageInfo, bool durabilityLoss) { Unit* victim = damageInfo->target; - if (!victim->IsAlive() || victim->HasUnitState(UNIT_STATE_IN_FLIGHT) || - (victim->GetTypeId() == TYPEID_UNIT && victim->ToCreature()->IsEvadingAttacks())) + if (!victim->IsAlive() || victim->HasUnitState(UNIT_STATE_IN_FLIGHT) || (victim->GetTypeId() == TYPEID_UNIT && victim->ToCreature()->IsEvadingAttacks())) return; - if (damageInfo->TargetState == VICTIMSTATE_PARRY && - (GetTypeId() != TYPEID_UNIT || - (ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_NO_PARRY_HASTEN) == 0)) + if (damageInfo->TargetState == VICTIMSTATE_PARRY && (GetTypeId() != TYPEID_UNIT || (ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_NO_PARRY_HASTEN) == 0)) { // Get attack timers float offtime = float(victim->getAttackTimer(OFF_ATTACK)); @@ -1473,12 +1450,10 @@ void Unit::DealMeleeDamage(CalcDamageInfo* damageInfo, bool durabilityLoss) // Call default DealDamage CleanDamage cleanDamage(damageInfo->cleanDamage, damageInfo->absorb, damageInfo->attackType, damageInfo->hitOutCome); - DealDamage(victim, damageInfo->damage, &cleanDamage, DIRECT_DAMAGE, SpellSchoolMask(damageInfo->damageSchoolMask), nullptr, - durabilityLoss); + Unit::DealDamage(this, victim, damageInfo->damage, &cleanDamage, DIRECT_DAMAGE, SpellSchoolMask(damageInfo->damageSchoolMask), nullptr, durabilityLoss); // If this is a creature and it attacks from behind it has a probability to daze it's victim - if ((damageInfo->hitOutCome == MELEE_HIT_CRIT || damageInfo->hitOutCome == MELEE_HIT_CRUSHING || - damageInfo->hitOutCome == MELEE_HIT_NORMAL || damageInfo->hitOutCome == MELEE_HIT_GLANCING) && + if ((damageInfo->hitOutCome == MELEE_HIT_CRIT || damageInfo->hitOutCome == MELEE_HIT_CRUSHING || damageInfo->hitOutCome == MELEE_HIT_NORMAL || damageInfo->hitOutCome == MELEE_HIT_GLANCING) && GetTypeId() != TYPEID_PLAYER && !ToCreature()->IsControlledByPlayer() && !victim->HasInArc(float(M_PI), this) && (victim->GetTypeId() == TYPEID_PLAYER || !victim->ToCreature()->isWorldBoss()) && !victim->IsVehicle()) { @@ -1539,7 +1514,7 @@ void Unit::DealMeleeDamage(CalcDamageInfo* damageInfo, bool durabilityLoss) } // No Unit::CalcAbsorbResist here - opcode doesn't send that data - this damage is probably not affected by that - victim->DealDamageMods(this, damage, nullptr); + Unit::DealDamageMods(this, damage, nullptr); /// @todo Move this to a packet handler WorldPacket data(SMSG_SPELLDAMAGESHIELD, 8 + 8 + 4 + 4 + 4 + 4 + 4); @@ -1553,7 +1528,7 @@ void Unit::DealMeleeDamage(CalcDamageInfo* damageInfo, bool durabilityLoss) data << uint32(0); // FIX ME: Send resisted damage, both fully resisted and partly resisted victim->SendMessageToSet(&data, true); - victim->DealDamage(this, damage, nullptr, SPELL_DIRECT_DAMAGE, spellInfo->GetSchoolMask(), spellInfo, true); + Unit::DealDamage(victim, this, damage, nullptr, SPELL_DIRECT_DAMAGE, spellInfo->GetSchoolMask(), spellInfo, true); } } } @@ -1566,7 +1541,7 @@ void Unit::HandleEmoteCommand(uint32 anim_id) SendMessageToSet(&data, true); } -bool Unit::IsDamageReducedByArmor(SpellSchoolMask schoolMask, SpellInfo const* spellInfo /*= nullptr*/, int8 effIndex /*= -1*/) +/*static*/ bool Unit::IsDamageReducedByArmor(SpellSchoolMask schoolMask, SpellInfo const* spellInfo /*= nullptr*/, int8 effIndex /*= -1*/) { // only physical spells damage gets reduced by armor if ((schoolMask & SPELL_SCHOOL_MASK_NORMAL) == 0) @@ -1580,8 +1555,7 @@ bool Unit::IsDamageReducedByArmor(SpellSchoolMask schoolMask, SpellInfo const* s // bleeding effects are not reduced by armor if (effIndex != -1) { - if (spellInfo->Effects[effIndex].ApplyAuraName == SPELL_AURA_PERIODIC_DAMAGE || - spellInfo->Effects[effIndex].Effect == SPELL_EFFECT_SCHOOL_DAMAGE) + if (spellInfo->Effects[effIndex].ApplyAuraName == SPELL_AURA_PERIODIC_DAMAGE || spellInfo->Effects[effIndex].Effect == SPELL_EFFECT_SCHOOL_DAMAGE) if (spellInfo->GetEffectMechanicMask(effIndex) & (1 << MECHANIC_BLEED)) return false; } @@ -1610,39 +1584,40 @@ static float GetArmorReduction(float armor, uint8 attackerLevel) return temp * 100; } -uint32 Unit::CalcArmorReducedDamage( - Unit* victim, const uint32 damage, SpellInfo const* spellInfo, WeaponAttackType /*attackType*/) const +/*static*/ uint32 Unit::CalcArmorReducedDamage(Unit const* attacker, Unit* victim, const uint32 damage, SpellInfo const* spellInfo, WeaponAttackType /*attackType*/, uint8 attackerLevel /*= 0*/) { float armor = float(victim->GetArmor()); - // bypass enemy armor by SPELL_AURA_BYPASS_ARMOR_FOR_CASTER - int32 armorBypassPct = victim->GetTotalAuraModifier( - SPELL_AURA_BYPASS_ARMOR_FOR_CASTER, [&](AuraEffect const* aurEff) { return aurEff->GetCasterGUID() == GetGUID(); }); + if (attacker) + { + // bypass enemy armor by SPELL_AURA_BYPASS_ARMOR_FOR_CASTER + int32 armorBypassPct = victim->GetTotalAuraModifier(SPELL_AURA_BYPASS_ARMOR_FOR_CASTER, [&](AuraEffect const* aurEff) { return aurEff->GetCasterGUID() == attacker->GetGUID(); }); - armor = CalculatePct(armor, 100 - std::min(armorBypassPct, 100)); + armor = CalculatePct(armor, 100 - std::min(armorBypassPct, 100)); - // Ignore enemy armor by SPELL_AURA_MOD_TARGET_RESISTANCE aura - armor += GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_TARGET_RESISTANCE, SPELL_SCHOOL_MASK_NORMAL); + // Ignore enemy armor by SPELL_AURA_MOD_TARGET_RESISTANCE aura + armor += attacker->GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_TARGET_RESISTANCE, SPELL_SCHOOL_MASK_NORMAL); - if (spellInfo) - if (Player* modOwner = GetSpellModOwner()) - modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_IGNORE_ARMOR, armor); + if (spellInfo) + if (Player* modOwner = attacker->GetSpellModOwner()) + modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_IGNORE_ARMOR, armor); - for (AuraEffect const* aurEff : GetAuraEffectsByType(SPELL_AURA_MOD_IGNORE_TARGET_RESIST)) - { - if (aurEff->GetMiscValue() & SPELL_SCHOOL_MASK_NORMAL) - armor = std::floor(AddPct(armor, -aurEff->GetAmount())); - } + for (AuraEffect const* aurEff : attacker->GetAuraEffectsByType(SPELL_AURA_MOD_IGNORE_TARGET_RESIST)) + { + if (aurEff->GetMiscValue() & SPELL_SCHOOL_MASK_NORMAL) + armor = std::floor(AddPct(armor, -aurEff->GetAmount())); + } - if (armor < 0.0f) - armor = 0.0f; + if (armor < 0.0f) + armor = 0.0f; + } - float armorReduction = 100.f - GetArmorReduction(armor, getLevel()); + float armorReduction = 100.f - GetArmorReduction(armor, attacker ? attacker->getLevel() : attackerLevel); return std::max(CalculatePct(damage, armorReduction), 1); } -uint32 Unit::CalcSpellResistedDamage(Unit* victim, uint32 damage, SpellSchoolMask schoolMask, SpellInfo const* spellInfo) const +/*static*/ uint32 Unit::CalcSpellResistedDamage(Unit const* attacker, Unit* victim, uint32 damage, SpellSchoolMask schoolMask, SpellInfo const* spellInfo) { // Magic damage, check for resists if (!(schoolMask & SPELL_SCHOOL_MASK_MAGIC)) @@ -1667,7 +1642,7 @@ uint32 Unit::CalcSpellResistedDamage(Unit* victim, uint32 damage, SpellSchoolMas return 0; } - float const averageResist = CalculateAverageResistReduction(schoolMask, victim, spellInfo); + float const averageResist = Unit::CalculateAverageResistReduction(attacker, schoolMask, victim, spellInfo); float discreteResistProbability[11] = {}; if (averageResist <= 0.1f) @@ -1691,16 +1666,16 @@ uint32 Unit::CalcSpellResistedDamage(Unit* victim, uint32 damage, SpellSchoolMas break; float damageResisted = damage * resistance / 10.f; - if (damageResisted > 0.0f) // if any damage was resisted + if (damageResisted > 0.0f && attacker) // if any damage was resisted { - int32 ignoredResistance = GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_IGNORE_TARGET_RESIST, schoolMask); + int32 ignoredResistance = attacker->GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_IGNORE_TARGET_RESIST, schoolMask); ignoredResistance = std::min(ignoredResistance, 100); ApplyPct(damageResisted, 100 - ignoredResistance); // Spells with melee and magic school mask, decide whether resistance or armor absorb is higher if (spellInfo && spellInfo->HasAttribute(SPELL_ATTR0_CU_SCHOOLMASK_NORMAL_WITH_MAGIC)) { - uint32 damageAfterArmor = CalcArmorReducedDamage(victim, damage, spellInfo, BASE_ATTACK); + uint32 damageAfterArmor = Unit::CalcArmorReducedDamage(attacker, victim, damage, spellInfo, BASE_ATTACK); float armorReduction = damage - damageAfterArmor; // pick the lower one, the weakest resistance counts @@ -1712,20 +1687,23 @@ uint32 Unit::CalcSpellResistedDamage(Unit* victim, uint32 damage, SpellSchoolMas return uint32(damageResisted); } -float Unit::CalculateAverageResistReduction(SpellSchoolMask schoolMask, Unit const* victim, SpellInfo const* spellInfo) const +/*static*/ float Unit::CalculateAverageResistReduction(Unit const* attacker, SpellSchoolMask schoolMask, Unit const* victim, SpellInfo const* spellInfo) { float victimResistance = float(victim->GetResistance(schoolMask)); - // pets inherit 100% of masters penetration - // excluding traps - Player const* player = GetSpellModOwner(); - if (player && GetEntry() != WORLD_TRIGGER) + if (attacker) { - victimResistance += float(player->GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_TARGET_RESISTANCE, schoolMask)); - victimResistance -= float(player->GetSpellPenetrationItemMod()); + // pets inherit 100% of masters penetration + // excluding traps + Player const* player = attacker->GetSpellModOwner(); + if (player && attacker->GetEntry() != WORLD_TRIGGER) + { + victimResistance += float(player->GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_TARGET_RESISTANCE, schoolMask)); + victimResistance -= float(player->GetSpellPenetrationItemMod()); + } + else + victimResistance += float(attacker->GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_TARGET_RESISTANCE, schoolMask)); } - else - victimResistance += float(GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_TARGET_RESISTANCE, schoolMask)); // holy resistance exists in pve and comes from level difference, ignore template values if (schoolMask & SPELL_SCHOOL_MASK_HOLY) @@ -1738,8 +1716,8 @@ float Unit::CalculateAverageResistReduction(SpellSchoolMask schoolMask, Unit con victimResistance = std::max(victimResistance, 0.0f); // level-based resistance does not apply to binary spells, and cannot be overcome by spell penetration - if (!spellInfo || !spellInfo->HasAttribute(SPELL_ATTR0_CU_BINARY_SPELL)) - victimResistance += std::max((float(victim->getLevelForTarget(this)) - float(getLevelForTarget(victim))) * 5.0f, 0.0f); + if (attacker && (!spellInfo || !spellInfo->HasAttribute(SPELL_ATTR0_CU_BINARY_SPELL))) + victimResistance += std::max((float(victim->getLevelForTarget(attacker)) - float(attacker->getLevelForTarget(victim))) * 5.0f, 0.0f); static uint32 const BOSS_LEVEL = 83; static float const BOSS_RESISTANCE_CONSTANT = 510.0f; @@ -1754,29 +1732,30 @@ float Unit::CalculateAverageResistReduction(SpellSchoolMask schoolMask, Unit con return victimResistance / (victimResistance + resistanceConstant); } -void Unit::CalcAbsorbResist(DamageInfo& damageInfo) +/*static*/ void Unit::CalcAbsorbResist(DamageInfo& damageInfo) { if (!damageInfo.GetVictim() || !damageInfo.GetVictim()->IsAlive() || !damageInfo.GetDamage()) return; - uint32 resistedDamage = CalcSpellResistedDamage( - damageInfo.GetVictim(), damageInfo.GetDamage(), damageInfo.GetSchoolMask(), damageInfo.GetSpellInfo()); + uint32 resistedDamage = Unit::CalcSpellResistedDamage(damageInfo.GetAttacker(), damageInfo.GetVictim(), damageInfo.GetDamage(), damageInfo.GetSchoolMask(), damageInfo.GetSpellInfo()); damageInfo.ResistDamage(resistedDamage); // Ignore Absorption Auras - float auraAbsorbMod(GetMaxPositiveAuraModifierByMiscMask(SPELL_AURA_MOD_TARGET_ABSORB_SCHOOL, damageInfo.GetSchoolMask())); - - AuraEffectList const& abilityAbsorbAuras = GetAuraEffectsByType(SPELL_AURA_MOD_TARGET_ABILITY_ABSORB_SCHOOL); - for (AuraEffect const* aurEff : abilityAbsorbAuras) + float auraAbsorbMod = 0.f; + if (Unit* attacker = damageInfo.GetAttacker()) { - if (!(aurEff->GetMiscValue() & damageInfo.GetSchoolMask())) - continue; + auraAbsorbMod = attacker->GetMaxPositiveAuraModifierByMiscMask(SPELL_AURA_MOD_TARGET_ABSORB_SCHOOL, damageInfo.GetSchoolMask()); + auraAbsorbMod = std::max(auraAbsorbMod, static_cast(attacker->GetMaxPositiveAuraModifier(SPELL_AURA_MOD_TARGET_ABILITY_ABSORB_SCHOOL, + [&damageInfo](AuraEffect const* aurEff) -> bool + { + if (!(aurEff->GetMiscValue() & damageInfo.GetSchoolMask())) + return false; - if (!aurEff->IsAffectingSpell(damageInfo.GetSpellInfo())) - continue; + if (!aurEff->IsAffectingSpell(damageInfo.GetSpellInfo())) + return false; - if ((aurEff->GetAmount() > auraAbsorbMod)) - auraAbsorbMod = float(aurEff->GetAmount()); + return true; + }))); } RoundToInterval(auraAbsorbMod, 0.0f, 100.0f); @@ -1790,8 +1769,7 @@ void Unit::CalcAbsorbResist(DamageInfo& damageInfo) vSchoolAbsorbCopy.sort(Firelands::AbsorbAuraOrderPred()); // absorb without mana cost - for (AuraEffectList::iterator itr = vSchoolAbsorbCopy.begin(); - (itr != vSchoolAbsorbCopy.end()) && (damageInfo.GetDamage() > 0); ++itr) + for (AuraEffectList::iterator itr = vSchoolAbsorbCopy.begin(); (itr != vSchoolAbsorbCopy.end()) && (damageInfo.GetDamage() > 0); ++itr) { AuraEffect* absorbAurEff = *itr; // Check if aura was removed during iteration - we don't need to work on such auras @@ -1838,8 +1816,7 @@ void Unit::CalcAbsorbResist(DamageInfo& damageInfo) // absorb by mana cost AuraEffectList vManaShieldCopy(damageInfo.GetVictim()->GetAuraEffectsByType(SPELL_AURA_MANA_SHIELD)); - for (AuraEffectList::const_iterator itr = vManaShieldCopy.begin(); - (itr != vManaShieldCopy.end()) && (damageInfo.GetDamage() > 0); ++itr) + for (AuraEffectList::const_iterator itr = vManaShieldCopy.begin(); (itr != vManaShieldCopy.end()) && (damageInfo.GetDamage() > 0); ++itr) { AuraEffect* absorbAurEff = *itr; // Check if aura was removed during iteration - we don't need to work on such auras @@ -1860,8 +1837,7 @@ void Unit::CalcAbsorbResist(DamageInfo& damageInfo) bool defaultPrevented = false; - absorbAurEff->GetBase()->CallScriptEffectManaShieldHandlers( - absorbAurEff, aurApp, damageInfo, tempAbsorb, defaultPrevented); + absorbAurEff->GetBase()->CallScriptEffectManaShieldHandlers(absorbAurEff, aurApp, damageInfo, tempAbsorb, defaultPrevented); currentAbsorb = tempAbsorb; if (defaultPrevented) @@ -1873,8 +1849,7 @@ void Unit::CalcAbsorbResist(DamageInfo& damageInfo) int32 manaReduction = currentAbsorb; // lower absorb amount by talents - if (float manaMultiplier = - absorbAurEff->GetSpellInfo()->Effects[absorbAurEff->GetEffIndex()].CalcValueMultiplier(absorbAurEff->GetCaster())) + if (float manaMultiplier = absorbAurEff->GetSpellInfo()->Effects[absorbAurEff->GetEffIndex()].CalcValueMultiplier(absorbAurEff->GetCaster())) manaReduction = int32(float(manaReduction) * manaMultiplier); int32 manaTaken = -damageInfo.GetVictim()->ModifyPower(POWER_MANA, -manaReduction); @@ -1899,13 +1874,12 @@ void Unit::CalcAbsorbResist(DamageInfo& damageInfo) damageInfo.ModifyDamage(absorbIgnoringDamage); // split damage auras - only when not damaging self - if (damageInfo.GetVictim() != this) + if (damageInfo.GetVictim() != damageInfo.GetAttacker()) { // We're going to call functions which can modify content of the list during iteration over it's elements // Let's copy the list so we can prevent iterator invalidation AuraEffectList vSplitDamagePctCopy(damageInfo.GetVictim()->GetAuraEffectsByType(SPELL_AURA_SPLIT_DAMAGE_PCT)); - for (AuraEffectList::iterator itr = vSplitDamagePctCopy.begin(); - itr != vSplitDamagePctCopy.end() && damageInfo.GetDamage() > 0; ++itr) + for (AuraEffectList::iterator itr = vSplitDamagePctCopy.begin(); itr != vSplitDamagePctCopy.end() && damageInfo.GetDamage() > 0; ++itr) { // Check if aura was removed during iteration - we don't need to work on such auras AuraApplication const* aurApp = (*itr)->GetBase()->GetApplicationOfTarget(damageInfo.GetVictim()->GetGUID()); @@ -1938,30 +1912,31 @@ void Unit::CalcAbsorbResist(DamageInfo& damageInfo) } uint32 split_absorb = 0; - DealDamageMods(caster, splitDamage, &split_absorb); + Unit::DealDamageMods(caster, splitDamage, &split_absorb); - // Sparring Checks - if (Creature* target = damageInfo.GetVictim()->ToCreature()) - if (IsCreature() && !IsCharmedOwnedByPlayerOrPlayer()) - if (target->GetNoNpcDamageBelowPctHealthValue() != 0.0f) - if (target->GetHealthPct() <= target->GetNoNpcDamageBelowPctHealthValue()) - damageInfo.ModifyDamage(damageInfo.GetDamage() * -1); + if (Unit* attacker = damageInfo.GetAttacker()) + { + // Sparring Checks + if (Creature* target = damageInfo.GetVictim()->ToCreature()) + if (attacker->IsCreature() && !attacker->IsCharmedOwnedByPlayerOrPlayer()) + if (target->GetNoNpcDamageBelowPctHealthValue() != 0.0f) + if (target->GetHealthPct() <= target->GetNoNpcDamageBelowPctHealthValue()) + damageInfo.ModifyDamage(damageInfo.GetDamage() * -1); - SendSpellNonMeleeDamageLog( - caster, (*itr)->GetSpellInfo()->Id, splitDamage, damageInfo.GetSchoolMask(), split_absorb, 0, false, 0, false); + attacker->SendSpellNonMeleeDamageLog(caster, (*itr)->GetSpellInfo()->Id, splitDamage, damageInfo.GetSchoolMask(), split_absorb, 0, false, 0, false); + } CleanDamage cleanDamage = CleanDamage(splitDamage, 0, BASE_ATTACK, MELEE_HIT_NORMAL); - DealDamage( - caster, splitDamage, &cleanDamage, DIRECT_DAMAGE, damageInfo.GetSchoolMask(), (*itr)->GetSpellInfo(), false); + Unit::DealDamage(damageInfo.GetAttacker(), caster, splitDamage, &cleanDamage, DIRECT_DAMAGE, damageInfo.GetSchoolMask(), (*itr)->GetSpellInfo(), false); // break 'Fear' and similar auras - ProcSkillsAndAuras(caster, PROC_FLAG_NONE, PROC_FLAG_TAKE_HARMFUL_SPELL, PROC_SPELL_TYPE_DAMAGE, PROC_SPELL_PHASE_HIT, - PROC_HIT_NONE, nullptr, &damageInfo, nullptr); + Unit::ProcSkillsAndAuras( + damageInfo.GetAttacker(), caster, PROC_FLAG_NONE, PROC_FLAG_TAKE_HARMFUL_SPELL, PROC_SPELL_TYPE_DAMAGE, PROC_SPELL_PHASE_HIT, PROC_HIT_NONE, nullptr, &damageInfo, nullptr); } } } -void Unit::CalcHealAbsorb(HealInfo& healInfo) const +/*static*/ void Unit::CalcHealAbsorb(HealInfo& healInfo) { if (!healInfo.GetHeal()) return; @@ -2041,8 +2016,7 @@ void Unit::AttackerStateUpdate(Unit* victim, WeaponAttackType attType, bool extr if (attType != BASE_ATTACK && attType != OFF_ATTACK) return; // ignore ranged case - if (GetTypeId() == TYPEID_UNIT && !HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_POSSESSED) && - !HasFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_DISABLE_TURN)) + if (GetTypeId() == TYPEID_UNIT && !HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_POSSESSED) && !HasFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_DISABLE_TURN)) SetFacingToObject(victim, false); // update client side facing to face the target (prevents visual glitches when casting untargeted spells) @@ -2062,14 +2036,12 @@ void Unit::AttackerStateUpdate(Unit* victim, WeaponAttackType attType, bool extr if (!meleeAttackOverrides.empty()) { meleeAttackAuraEffect = meleeAttackOverrides.front(); - meleeAttackSpellId = - meleeAttackAuraEffect->GetSpellInfo()->Effects[meleeAttackAuraEffect->GetEffIndex()].TriggerSpell; + meleeAttackSpellId = meleeAttackAuraEffect->GetSpellInfo()->Effects[meleeAttackAuraEffect->GetEffIndex()].TriggerSpell; } } else { - auto itr = std::find_if(meleeAttackOverrides.begin(), meleeAttackOverrides.end(), - [&](AuraEffect const* aurEff) { return aurEff->GetAmount() != 0; }); + auto itr = std::find_if(meleeAttackOverrides.begin(), meleeAttackOverrides.end(), [&](AuraEffect const* aurEff) { return aurEff->GetAmount() != 0; }); if (itr != meleeAttackOverrides.end()) { @@ -2083,7 +2055,7 @@ void Unit::AttackerStateUpdate(Unit* victim, WeaponAttackType attType, bool extr CalcDamageInfo damageInfo; CalculateMeleeDamage(victim, 0, &damageInfo, attType); // Send log damage message to client - DealDamageMods(victim, damageInfo.damage, &damageInfo.absorb); + Unit::DealDamageMods(victim, damageInfo.damage, &damageInfo.absorb); // Sparring Checks if (Creature* target = victim->ToCreature()) @@ -2097,19 +2069,15 @@ void Unit::AttackerStateUpdate(Unit* victim, WeaponAttackType attType, bool extr DealMeleeDamage(&damageInfo, true); DamageInfo dmgInfo(damageInfo); - ProcSkillsAndAuras(damageInfo.target, damageInfo.procAttacker, damageInfo.procVictim, PROC_SPELL_TYPE_NONE, - PROC_SPELL_PHASE_NONE, dmgInfo.GetHitMask(), nullptr, &dmgInfo, nullptr); + Unit::ProcSkillsAndAuras( + damageInfo.attacker, damageInfo.target, damageInfo.procAttacker, damageInfo.procVictim, PROC_SPELL_TYPE_NONE, PROC_SPELL_PHASE_NONE, dmgInfo.GetHitMask(), nullptr, &dmgInfo, nullptr); if (GetTypeId() == TYPEID_PLAYER) - LOG_DEBUG("entities.unit", - "AttackerStateUpdate: (Player) %u attacked %u (TypeId: %u) for %u dmg, absorbed %u, blocked %u, resisted %u.", - GetGUID().GetCounter(), victim->GetGUID().GetCounter(), victim->GetTypeId(), damageInfo.damage, - damageInfo.absorb, damageInfo.blocked_amount, damageInfo.resist); + LOG_DEBUG("entities.unit", "AttackerStateUpdate: (Player) %u attacked %u (TypeId: %u) for %u dmg, absorbed %u, blocked %u, resisted %u.", GetGUID().GetCounter(), + victim->GetGUID().GetCounter(), victim->GetTypeId(), damageInfo.damage, damageInfo.absorb, damageInfo.blocked_amount, damageInfo.resist); else - LOG_DEBUG("entities.unit", - "AttackerStateUpdate: (NPC) %u attacked %u (TypeId: %u) for %u dmg, absorbed %u, blocked %u, resisted %u.", - GetGUID().GetCounter(), victim->GetGUID().GetCounter(), victim->GetTypeId(), damageInfo.damage, - damageInfo.absorb, damageInfo.blocked_amount, damageInfo.resist); + LOG_DEBUG("entities.unit", "AttackerStateUpdate: (NPC) %u attacked %u (TypeId: %u) for %u dmg, absorbed %u, blocked %u, resisted %u.", GetGUID().GetCounter(), + victim->GetGUID().GetCounter(), victim->GetTypeId(), damageInfo.damage, damageInfo.absorb, damageInfo.blocked_amount, damageInfo.resist); } else { @@ -2203,8 +2171,7 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst(const Unit* victim, WeaponAttackTy // 4. GLANCING // Max 40% chance to score a glancing blow against mobs of the same or higher level (only players and pets, not for ranged // weapons). - if ((GetTypeId() == TYPEID_PLAYER || IsPet()) && victim->GetTypeId() != TYPEID_PLAYER && !victim->IsPet() && - getLevel() <= victim->getLevelForTarget(this)) + if ((GetTypeId() == TYPEID_PLAYER || IsPet()) && victim->GetTypeId() != TYPEID_PLAYER && !victim->IsPet() && getLevel() <= victim->getLevelForTarget(this)) { // cap possible value (with bonuses > max skill) int32 skill = attackerMaxSkillValueForLevel; @@ -2235,8 +2202,7 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst(const Unit* victim, WeaponAttackTy // mobs can score crushing blows if they're 4 or more levels above victim if (getLevelForTarget(victim) >= victim->getLevelForTarget(this) + 4 && // can be from by creature (if can) or from controlled player that considered as creature - !IsControlledByPlayer() && - !(IsCreature() && ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_NO_CRUSH)) + !IsControlledByPlayer() && !(IsCreature() && ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_NO_CRUSH)) { // when their weapon skill is 15 or more above victim's defense skill tmp = victimMaxSkillValueForLevel; @@ -2308,20 +2274,16 @@ void Unit::SendMeleeAttackStop(Unit* victim) SendMessageToSet(WorldPackets::Combat::SAttackStop(this, victim).Write(), IsPlayer()); if (victim) - LOG_DEBUG("entities.unit", "%s %u stopped attacking %s %u", (GetTypeId() == TYPEID_PLAYER ? "Player" : "Creature"), - GetGUID().GetCounter(), (victim->GetTypeId() == TYPEID_PLAYER ? "player" : "creature"), - victim->GetGUID().GetCounter()); + LOG_DEBUG("entities.unit", "%s %u stopped attacking %s %u", (GetTypeId() == TYPEID_PLAYER ? "Player" : "Creature"), GetGUID().GetCounter(), + (victim->GetTypeId() == TYPEID_PLAYER ? "player" : "creature"), victim->GetGUID().GetCounter()); else - LOG_DEBUG("entities.unit", "%s %u stopped attacking", (GetTypeId() == TYPEID_PLAYER ? "Player" : "Creature"), - GetGUID().GetCounter()); + LOG_DEBUG("entities.unit", "%s %u stopped attacking", (GetTypeId() == TYPEID_PLAYER ? "Player" : "Creature"), GetGUID().GetCounter()); } bool Unit::isSpellBlocked(Unit* victim, SpellInfo const* spellProto) { // These spells can't be blocked - if (spellProto && - (spellProto->HasAttribute(SPELL_ATTR0_NO_ACTIVE_DEFENSE) || spellProto->HasAttribute(SPELL_ATTR3_IGNORE_HIT_RESULT) || - spellProto->HasAttribute(SPELL_ATTR8_CANT_BLOCK))) + if (spellProto && (spellProto->HasAttribute(SPELL_ATTR0_NO_ACTIVE_DEFENSE) || spellProto->HasAttribute(SPELL_ATTR3_IGNORE_HIT_RESULT) || spellProto->HasAttribute(SPELL_ATTR8_CANT_BLOCK))) return false; // Can't block when casting/controlled @@ -2415,18 +2377,11 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit* victim, SpellInfo const* spellInfo bool canBlock = !spellInfo->HasAttribute(SPELL_ATTR8_CANT_BLOCK); // if victim is casting or cc'd it can't avoid attacks - bool canUseDefenseWhileChanneling = victim->GetCurrentSpell(CURRENT_CHANNELED_SPELL) - ? victim->GetCurrentSpell(CURRENT_CHANNELED_SPELL) - ->GetSpellInfo() - ->HasAttribute(SPELL_ATTR10_ALLOW_DEFENSE_WHILE_CHANNELING) - : false; - bool canUseDefenseWhileCasting = victim->GetCurrentSpell(CURRENT_GENERIC_SPELL) - ? victim->GetCurrentSpell(CURRENT_GENERIC_SPELL) - ->GetSpellInfo() - ->HasAttribute(SPELL_ATTR10_ALLOW_DEFENSE_WHILE_CASTING) - : false; - if ((victim->IsNonMeleeSpellCast(false) || victim->HasUnitState(UNIT_STATE_CONTROLLED)) && !canUseDefenseWhileChanneling && - !canUseDefenseWhileCasting) + bool canUseDefenseWhileChanneling = + victim->GetCurrentSpell(CURRENT_CHANNELED_SPELL) ? victim->GetCurrentSpell(CURRENT_CHANNELED_SPELL)->GetSpellInfo()->HasAttribute(SPELL_ATTR10_ALLOW_DEFENSE_WHILE_CHANNELING) : false; + bool canUseDefenseWhileCasting = + victim->GetCurrentSpell(CURRENT_GENERIC_SPELL) ? victim->GetCurrentSpell(CURRENT_GENERIC_SPELL)->GetSpellInfo()->HasAttribute(SPELL_ATTR10_ALLOW_DEFENSE_WHILE_CASTING) : false; + if ((victim->IsNonMeleeSpellCast(false) || victim->HasUnitState(UNIT_STATE_CONTROLLED)) && !canUseDefenseWhileChanneling && !canUseDefenseWhileCasting) { canDodge = false; canParry = false; @@ -2441,8 +2396,7 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit* victim, SpellInfo const* spellInfo canBlock = false; // only if in front - if (!victim->HasUnitState(UNIT_STATE_CONTROLLED) && - (victim->HasInArc(float(M_PI), this) || victim->HasAuraType(SPELL_AURA_IGNORE_HIT_DIRECTION))) + if (!victim->HasUnitState(UNIT_STATE_CONTROLLED) && (victim->HasInArc(float(M_PI), this) || victim->HasAuraType(SPELL_AURA_IGNORE_HIT_DIRECTION))) { int32 deflect_chance = victim->GetTotalAuraModifier(SPELL_AURA_DEFLECT_SPELLS) * 100; tmp += deflect_chance; @@ -2490,8 +2444,7 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit* victim, SpellInfo const* spellInfo canParry = false; break; default: - LOG_DEBUG("entities.unit", "Spell %u SPELL_AURA_IGNORE_COMBAT_RESULT has unhandled state %d", aurEff->GetId(), - aurEff->GetMiscValue()); + LOG_DEBUG("entities.unit", "Spell %u SPELL_AURA_IGNORE_COMBAT_RESULT has unhandled state %d", aurEff->GetId(), aurEff->GetMiscValue()); break; } } @@ -2605,8 +2558,8 @@ SpellMissInfo Unit::MagicSpellHitResult(Unit* victim, SpellInfo const* spellInfo { // resistance chance for binary spells, equals to average damage reduction of non-binary spell if (spellInfo->HasAttribute(SPELL_ATTR0_CU_BINARY_SPELL) && (spellInfo->GetSchoolMask() & SPELL_SCHOOL_MASK_MAGIC)) - resist_chance += int32(CalculateAverageResistReduction(spellInfo->GetSchoolMask(), victim, spellInfo) * - 10000.f); // 100 for spell calculations, and 100 for return value percentage + resist_chance += + int32(Unit::CalculateAverageResistReduction(this, spellInfo->GetSchoolMask(), victim, spellInfo) * 10000.f); // 100 for spell calculations, and 100 for return value percentage } // Roll chance @@ -2614,8 +2567,7 @@ SpellMissInfo Unit::MagicSpellHitResult(Unit* victim, SpellInfo const* spellInfo return SPELL_MISS_RESIST; // cast by caster in front of victim - if (!victim->HasUnitState(UNIT_STATE_CONTROLLED) && - (victim->HasInArc(float(M_PI), this) || victim->HasAuraType(SPELL_AURA_IGNORE_HIT_DIRECTION))) + if (!victim->HasUnitState(UNIT_STATE_CONTROLLED) && (victim->HasInArc(float(M_PI), this) || victim->HasAuraType(SPELL_AURA_IGNORE_HIT_DIRECTION))) { int32 deflect_chance = victim->GetTotalAuraModifier(SPELL_AURA_DEFLECT_SPELLS) * 100; if (deflect_chance > 0 && rand < (tmp += deflect_chance)) @@ -2633,8 +2585,7 @@ SpellMissInfo Unit::MagicSpellHitResult(Unit* victim, SpellInfo const* spellInfo // Parry // For spells // Resist -SpellMissInfo Unit::SpellHitResult( - Unit* victim, SpellInfo const* spellInfo, bool canReflect /*= false*/, Optional effectMask /*= nullptr*/) +SpellMissInfo Unit::SpellHitResult(Unit* victim, SpellInfo const* spellInfo, bool canReflect /*= false*/, Optional effectMask /*= nullptr*/) { // Check for immune if (victim->IsImmunedToSpell(spellInfo, this, effectMask)) @@ -2748,8 +2699,7 @@ float Unit::GetUnitParryChance(WeaponAttackType attType, Unit const* victim) con { // Allow parries for creatures only if it's not a totem, does have a virtual item equipped and does not have // CREATURE_FLAG_EXTRA_NO_PARRY - if (!victim->IsTotem() && - (victim->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 0) || victim->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 1)) && + if (!victim->IsTotem() && (victim->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 0) || victim->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 1)) && !(victim->ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_NO_PARRY)) { chance += victim->GetTotalAuraModifier(SPELL_AURA_MOD_PARRY_PERCENT); @@ -2953,8 +2903,7 @@ void Unit::_UpdateAutoRepeatSpell() // check "realtime" interrupts // don't cancel spells which are affected by a SPELL_AURA_CAST_WHILE_WALKING effect - if (((GetTypeId() == TYPEID_PLAYER && ToPlayer()->isMoving()) || - IsNonMeleeSpellCast(false, false, true, autoRepeatSpellInfo->Id == 75)) && + if (((GetTypeId() == TYPEID_PLAYER && ToPlayer()->isMoving()) || IsNonMeleeSpellCast(false, false, true, autoRepeatSpellInfo->Id == 75)) && !HasAuraTypeWithAffectMask(SPELL_AURA_CAST_WHILE_WALKING, m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_spellInfo)) { // cancel wand shoot @@ -3068,15 +3017,13 @@ void Unit::SetCurrentCastSpell(Spell* pSpell) pSpell->m_selfContainer = &(m_currentSpells[pSpell->GetCurrentContainer()]); } -void Unit::InterruptSpell( - CurrentSpellTypes spellType, bool withDelayed, bool withInstant, Spell* interruptingSpell /* = nullptr */) +void Unit::InterruptSpell(CurrentSpellTypes spellType, bool withDelayed, bool withInstant, Spell* interruptingSpell /* = nullptr */) { Spell* spell = m_currentSpells[spellType]; if (!spell) return; - if ((withDelayed || spell->getState() != SPELL_STATE_DELAYED) && - (withInstant || spell->GetCastTime() > 0 || spell->getState() == SPELL_STATE_CASTING)) + if ((withDelayed || spell->getState() != SPELL_STATE_DELAYED) && (withInstant || spell->GetCastTime() > 0 || spell->getState() == SPELL_STATE_CASTING)) { // for example, do not let self-stun aura interrupt itself if (!spell->IsInterruptable()) @@ -3112,8 +3059,7 @@ void Unit::FinishSpell(CurrentSpellTypes spellType, bool ok /*= true*/) spell->finish(ok); } -bool Unit::IsNonMeleeSpellCast( - bool withDelayed, bool skipChanneled, bool skipAutorepeat, bool isAutoshoot, bool skipInstant) const +bool Unit::IsNonMeleeSpellCast(bool withDelayed, bool skipChanneled, bool skipAutorepeat, bool isAutoshoot, bool skipInstant) const { // We don't do loop here to explicitly show that melee spell is excluded. // Maybe later some special spells will be excluded too. @@ -3124,17 +3070,14 @@ bool Unit::IsNonMeleeSpellCast( { if (!skipInstant || m_currentSpells[CURRENT_GENERIC_SPELL]->GetCastTime()) { - if (!isAutoshoot || - !(m_currentSpells[CURRENT_GENERIC_SPELL]->m_spellInfo->HasAttribute(SPELL_ATTR2_NOT_RESET_AUTO_ACTIONS))) + if (!isAutoshoot || !(m_currentSpells[CURRENT_GENERIC_SPELL]->m_spellInfo->HasAttribute(SPELL_ATTR2_NOT_RESET_AUTO_ACTIONS))) return true; } } // channeled spells may be delayed, but they are still considered cast - if (!skipChanneled && m_currentSpells[CURRENT_CHANNELED_SPELL] && - (m_currentSpells[CURRENT_CHANNELED_SPELL]->getState() != SPELL_STATE_FINISHED)) + if (!skipChanneled && m_currentSpells[CURRENT_CHANNELED_SPELL] && (m_currentSpells[CURRENT_CHANNELED_SPELL]->getState() != SPELL_STATE_FINISHED)) { - if (!isAutoshoot || - !(m_currentSpells[CURRENT_CHANNELED_SPELL]->m_spellInfo->HasAttribute(SPELL_ATTR2_NOT_RESET_AUTO_ACTIONS))) + if (!isAutoshoot || !(m_currentSpells[CURRENT_CHANNELED_SPELL]->m_spellInfo->HasAttribute(SPELL_ATTR2_NOT_RESET_AUTO_ACTIONS))) return true; } // autorepeat spells may be finished or delayed, but they are still considered cast @@ -3144,22 +3087,18 @@ bool Unit::IsNonMeleeSpellCast( return false; } -void Unit::InterruptNonMeleeSpells( - bool withDelayed, uint32 spell_id, bool withInstant /* = true */, Spell* interruptingSpell /* = nullptr */) +void Unit::InterruptNonMeleeSpells(bool withDelayed, uint32 spell_id, bool withInstant /* = true */, Spell* interruptingSpell /* = nullptr */) { // generic spells are interrupted if they are not finished or delayed - if (m_currentSpells[CURRENT_GENERIC_SPELL] && - (!spell_id || m_currentSpells[CURRENT_GENERIC_SPELL]->m_spellInfo->Id == spell_id)) + if (m_currentSpells[CURRENT_GENERIC_SPELL] && (!spell_id || m_currentSpells[CURRENT_GENERIC_SPELL]->m_spellInfo->Id == spell_id)) InterruptSpell(CURRENT_GENERIC_SPELL, withDelayed, withInstant, interruptingSpell); // autorepeat spells are interrupted if they are not finished or delayed - if (m_currentSpells[CURRENT_AUTOREPEAT_SPELL] && - (!spell_id || m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_spellInfo->Id == spell_id)) + if (m_currentSpells[CURRENT_AUTOREPEAT_SPELL] && (!spell_id || m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_spellInfo->Id == spell_id)) InterruptSpell(CURRENT_AUTOREPEAT_SPELL, withDelayed, withInstant, interruptingSpell); // channeled spells are interrupted if they are not finished, even if they are delayed - if (m_currentSpells[CURRENT_CHANNELED_SPELL] && - (!spell_id || m_currentSpells[CURRENT_CHANNELED_SPELL]->m_spellInfo->Id == spell_id)) + if (m_currentSpells[CURRENT_CHANNELED_SPELL] && (!spell_id || m_currentSpells[CURRENT_CHANNELED_SPELL]->m_spellInfo->Id == spell_id)) InterruptSpell(CURRENT_CHANNELED_SPELL, true, true, interruptingSpell); } @@ -3194,14 +3133,19 @@ bool Unit::IsMovementPreventedByCasting() const return true; } -void Unit::AddSummonedCreature(ObjectGuid guid, uint32 entry) { m_SummonedCreatures[guid] = entry; } +void Unit::AddSummonedCreature(ObjectGuid guid, uint32 entry) +{ + m_SummonedCreatures[guid] = entry; +} -void Unit::RemoveSummonedCreature(ObjectGuid guid) { m_SummonedCreatures.erase(guid); } +void Unit::RemoveSummonedCreature(ObjectGuid guid) +{ + m_SummonedCreatures.erase(guid); +} Creature* Unit::GetSummonedCreatureByEntry(uint32 entry) { - auto itr = - std::find_if(m_SummonedCreatures.begin(), m_SummonedCreatures.end(), [entry](auto& p) { return p.second == entry; }); + auto itr = std::find_if(m_SummonedCreatures.begin(), m_SummonedCreatures.end(), [entry](auto& p) { return p.second == entry; }); if (itr == m_SummonedCreatures.end()) return nullptr; @@ -3234,9 +3178,15 @@ bool Unit::isInAccessiblePlaceFor(Creature const* c) const return c->CanWalk() || c->CanFly(); } -bool Unit::IsInWater() const { return GetLiquidStatus() & (LIQUID_MAP_IN_WATER | LIQUID_MAP_UNDER_WATER); } +bool Unit::IsInWater() const +{ + return GetLiquidStatus() & (LIQUID_MAP_IN_WATER | LIQUID_MAP_UNDER_WATER); +} -bool Unit::IsUnderWater() const { return GetLiquidStatus() & LIQUID_MAP_UNDER_WATER; } +bool Unit::IsUnderWater() const +{ + return GetLiquidStatus() & LIQUID_MAP_UNDER_WATER; +} void Unit::ProcessPositionDataChanged(PositionFullTerrainStatus const& data) { @@ -3276,10 +3226,13 @@ void Unit::ProcessTerrainStatusUpdate(ZLiquidStatus /*oldLiquidStatus*/, Optiona CastSpell(this, curLiquid->SpellID, true); } } -void Unit::DeMorph() { SetDisplayId(GetNativeDisplayId()); } +void Unit::DeMorph() +{ + SetDisplayId(GetNativeDisplayId()); +} -Aura* Unit::_TryStackingOrRefreshingExistingAura(SpellInfo const* newAura, uint8 effMask, Unit* caster, - int32* baseAmount /*= nullptr*/, Item* castItem /*= nullptr*/, ObjectGuid casterGUID /*= ObjectGuid::Empty*/) +Aura* Unit::_TryStackingOrRefreshingExistingAura( + SpellInfo const* newAura, uint8 effMask, Unit* caster, int32* baseAmount /*= nullptr*/, Item* castItem /*= nullptr*/, ObjectGuid casterGUID /*= ObjectGuid::Empty*/) { ASSERT(casterGUID || caster); @@ -3296,8 +3249,7 @@ Aura* Unit::_TryStackingOrRefreshingExistingAura(SpellInfo const* newAura, uint8 castItemGUID = castItem->GetGUID(); // find current aura from spell and change it's stackamount, or refresh it's duration - if (Aura* foundAura = GetOwnedAura(newAura->Id, casterGUID, - newAura->HasAttribute(SPELL_ATTR0_CU_ENCHANT_PROC) ? castItemGUID : ObjectGuid::Empty, 0)) + if (Aura* foundAura = GetOwnedAura(newAura->Id, casterGUID, newAura->HasAttribute(SPELL_ATTR0_CU_ENCHANT_PROC) ? castItemGUID : ObjectGuid::Empty, 0)) { // effect masks do not match // extremely rare case @@ -3347,13 +3299,11 @@ void Unit::_AddAura(UnitAura* aura, Unit* caster) if (aura->IsRemoved()) return; - aura->SetIsLimitedTarget(caster && (aura->GetSpellInfo()->IsSingleTarget() || aura->GetSpellInfo()->GetAuraTargetLimit() || - aura->HasEffectType(SPELL_AURA_CONTROL_VEHICLE))); + aura->SetIsLimitedTarget(caster && (aura->GetSpellInfo()->IsSingleTarget() || aura->GetSpellInfo()->GetAuraTargetLimit() || aura->HasEffectType(SPELL_AURA_CONTROL_VEHICLE))); if (aura->IsLimitedTarget()) { - ASSERT((IsInWorld() && !IsDuringRemoveFromWorld()) || (aura->GetCasterGUID() == GetGUID()) || - (IsLoading() && aura->HasEffectType(SPELL_AURA_CONTROL_VEHICLE))); + ASSERT((IsInWorld() && !IsDuringRemoveFromWorld()) || (aura->GetCasterGUID() == GetGUID()) || (IsLoading() && aura->HasEffectType(SPELL_AURA_CONTROL_VEHICLE))); /* @HACK: Player is not in world during loading auras. * Single target auras are not saved or loaded from database * but may be created as a result of aura links (player mounts with passengers) @@ -3406,8 +3356,7 @@ AuraApplication* Unit::_CreateAuraApplication(Aura* aura, uint8 effMask) uint32 aurId = aurSpellInfo->Id; // ghost spell check, allow apply any auras at player loading in ghost mode (will be cleanup after load) - if (!IsAlive() && !aurSpellInfo->IsDeathPersistent() && - (GetTypeId() != TYPEID_PLAYER || !ToPlayer()->GetSession()->PlayerLoading())) + if (!IsAlive() && !aurSpellInfo->IsDeathPersistent() && (GetTypeId() != TYPEID_PLAYER || !ToPlayer()->GetSession()->PlayerLoading())) return nullptr; Unit* caster = aura->GetCaster(); @@ -3515,8 +3464,7 @@ void Unit::_UnapplyAura(AuraApplicationMap::iterator& i, AuraRemoveFlags removeM { bool canBreak = false; // Get mask of all aurastates from remaining auras - for (AuraStateAurasMap::iterator itr = m_auraStateAuras.lower_bound(auraState); - itr != m_auraStateAuras.upper_bound(auraState) && !(auraStateFound && canBreak);) + for (AuraStateAurasMap::iterator itr = m_auraStateAuras.lower_bound(auraState); itr != m_auraStateAuras.upper_bound(auraState) && !(auraStateFound && canBreak);) { if (itr->second == aurApp) { @@ -3650,8 +3598,7 @@ void Unit::RemoveOwnedAura(AuraMap::iterator& i, AuraRemoveFlags removeMode) void Unit::RemoveOwnedAura(uint32 spellId, ObjectGuid casterGUID, uint8 reqEffMask, AuraRemoveFlags removeMode) { for (AuraMap::iterator itr = m_ownedAuras.lower_bound(spellId); itr != m_ownedAuras.upper_bound(spellId);) - if (((itr->second->GetEffectMask() & reqEffMask) == reqEffMask) && - (!casterGUID || itr->second->GetCasterGUID() == casterGUID)) + if (((itr->second->GetEffectMask() & reqEffMask) == reqEffMask) && (!casterGUID || itr->second->GetCasterGUID() == casterGUID)) { RemoveOwnedAura(itr, removeMode); itr = m_ownedAuras.lower_bound(spellId); @@ -3669,8 +3616,7 @@ void Unit::RemoveOwnedAura(Aura* aura, AuraRemoveFlags removeMode) if (removeMode == AuraRemoveFlags::None) { - LOG_ERROR("spells", "Unit::RemoveOwnedAura() called with unallowed removeMode AuraRemoveFlags::None, spellId %u", - aura->GetId()); + LOG_ERROR("spells", "Unit::RemoveOwnedAura() called with unallowed removeMode AuraRemoveFlags::None, spellId %u", aura->GetId()); return; } @@ -3694,8 +3640,7 @@ Aura* Unit::GetOwnedAura(uint32 spellId, ObjectGuid casterGUID, ObjectGuid itemC AuraMapBounds range = m_ownedAuras.equal_range(spellId); for (AuraMap::const_iterator itr = range.first; itr != range.second; ++itr) { - if (((itr->second->GetEffectMask() & reqEffMask) == reqEffMask) && - (!casterGUID || itr->second->GetCasterGUID() == casterGUID) && + if (((itr->second->GetEffectMask() & reqEffMask) == reqEffMask) && (!casterGUID || itr->second->GetCasterGUID() == casterGUID) && (!itemCasterGUID || itr->second->GetCastItemGUID() == itemCasterGUID) && (!except || except != itr->second)) { return itr->second; @@ -3879,8 +3824,7 @@ void Unit::RemoveAuraFromStack(uint32 spellId, ObjectGuid casterGUID, AuraRemove } } -void Unit::RemoveAurasDueToSpellByDispel( - uint32 spellId, uint32 dispellerSpellId, ObjectGuid casterGUID, Unit* dispeller, uint8 chargesRemoved /*= 1*/) +void Unit::RemoveAurasDueToSpellByDispel(uint32 spellId, uint32 dispellerSpellId, ObjectGuid casterGUID, Unit* dispeller, uint8 chargesRemoved /*= 1*/) { AuraMapBoundsNonConst range = m_ownedAuras.equal_range(spellId); for (AuraMap::iterator iter = range.first; iter != range.second;) @@ -3951,8 +3895,7 @@ void Unit::RemoveAurasDueToSpellBySteal(uint32 spellId, ObjectGuid casterGUID, U if (aura->IsLimitedTarget()) aura->UnregisterLimitedTarget(); - if (Aura* newAura = Aura::TryRefreshStackOrCreate( - aura->GetSpellInfo(), effMask, stealer, nullptr, &baseDamage[0], nullptr, aura->GetCasterGUID())) + if (Aura* newAura = Aura::TryRefreshStackOrCreate(aura->GetSpellInfo(), effMask, stealer, nullptr, &baseDamage[0], nullptr, aura->GetCasterGUID())) { // created aura must not be limited target aura, so stealer won't loose it on recast if (newAura->IsLimitedTarget()) @@ -3964,7 +3907,7 @@ void Unit::RemoveAurasDueToSpellBySteal(uint32 spellId, ObjectGuid casterGUID, U } // FIXME: using aura->GetMaxDuration() maybe not blizzlike but it fixes stealing of spells like Innervate newAura->SetLoadedState( - aura->GetMaxDuration(), int32(dur), stealCharge ? 1 : aura->GetCharges(), 1, recalculateMask, &damage[0]); + aura->GetMaxDuration(), int32(dur), stealCharge ? 1 : aura->GetCharges(), 1, recalculateMask, aura->GetCritChance(), aura->CanApplyResilience(), &damage[0]); newAura->ApplyForTargets(); } } @@ -4004,8 +3947,7 @@ void Unit::RemoveAurasByType(AuraType auraType, ObjectGuid casterGUID, Aura* exc ASSERT(aurApp); ++iter; - if (aura != except && (!casterGUID || aura->GetCasterGUID() == casterGUID) && - ((negative && !aurApp->IsPositive()) || (positive && aurApp->IsPositive()))) + if (aura != except && (!casterGUID || aura->GetCasterGUID() == casterGUID) && ((negative && !aurApp->IsPositive()) || (positive && aurApp->IsPositive()))) { uint32 removedAuras = m_removedAurasCount; RemoveAura(aurApp); @@ -4078,8 +4020,7 @@ void Unit::RemoveNotOwnLimitedTargetAuras(bool onPhaseChange /*= false*/) } } -template -bool IsInterruptFlagIgnoredForSpell(InterruptFlag /*flag*/, Unit const* /*unit*/, SpellInfo const* /*spellInfo*/) +template bool IsInterruptFlagIgnoredForSpell(InterruptFlag /*flag*/, Unit const* /*unit*/, SpellInfo const* /*spellInfo*/) { return false; } @@ -4089,8 +4030,7 @@ template <> bool IsInterruptFlagIgnoredForSpell(SpellAuraInterruptFlags flag, Un return flag == SpellAuraInterruptFlags::Moving && unit->HasAuraTypeWithAffectMask(SPELL_AURA_CAST_WHILE_WALKING, spellInfo); } -template -void Unit::RemoveAurasWithInterruptFlags(InterruptFlags flag, uint32 except, Spell* interruptingSpell /* = nullptr */) +template void Unit::RemoveAurasWithInterruptFlags(InterruptFlags flag, uint32 except, Spell* interruptingSpell /* = nullptr */) { if (!HasInterruptFlag(flag)) return; @@ -4100,8 +4040,7 @@ void Unit::RemoveAurasWithInterruptFlags(InterruptFlags flag, uint32 except, Spe { Aura* aura = (*iter)->GetBase(); ++iter; - if (aura->GetSpellInfo()->HasAuraInterruptFlag(flag) && (!except || aura->GetId() != except) && - !IsInterruptFlagIgnoredForSpell(flag, this, aura->GetSpellInfo())) + if (aura->GetSpellInfo()->HasAuraInterruptFlag(flag) && (!except || aura->GetId() != except) && !IsInterruptFlagIgnoredForSpell(flag, this, aura->GetSpellInfo())) { uint32 removedAuras = m_removedAurasCount; RemoveAura(aura); @@ -4112,20 +4051,17 @@ void Unit::RemoveAurasWithInterruptFlags(InterruptFlags flag, uint32 except, Spe // interrupt channeled spell if (Spell* spell = m_currentSpells[CURRENT_CHANNELED_SPELL]) - if (spell->getState() == SPELL_STATE_CASTING && spell->GetSpellInfo()->HasChannelInterruptFlag(flag) && - spell->GetSpellInfo()->Id != except && !IsInterruptFlagIgnoredForSpell(flag, this, spell->GetSpellInfo())) + if (spell->getState() == SPELL_STATE_CASTING && spell->GetSpellInfo()->HasChannelInterruptFlag(flag) && spell->GetSpellInfo()->Id != except && + !IsInterruptFlagIgnoredForSpell(flag, this, spell->GetSpellInfo())) InterruptNonMeleeSpells(false, 0, true, interruptingSpell); UpdateInterruptMask(); } -template FC_GAME_API void Unit::RemoveAurasWithInterruptFlags( - SpellAuraInterruptFlags flag, uint32 except, Spell* interruptingSpell); -template FC_GAME_API void Unit::RemoveAurasWithInterruptFlags( - SpellAuraInterruptFlags2 flag, uint32 except, Spell* interruptingSpell); +template FC_GAME_API void Unit::RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags flag, uint32 except, Spell* interruptingSpell); +template FC_GAME_API void Unit::RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags2 flag, uint32 except, Spell* interruptingSpell); -void Unit::RemoveAurasWithFamily( - SpellFamilyNames family, uint32 familyFlag1, uint32 familyFlag2, uint32 familyFlag3, ObjectGuid casterGUID) +void Unit::RemoveAurasWithFamily(SpellFamilyNames family, uint32 familyFlag1, uint32 familyFlag2, uint32 familyFlag3, ObjectGuid casterGUID) { for (AuraApplicationMap::iterator iter = m_appliedAuras.begin(); iter != m_appliedAuras.end();) { @@ -4133,8 +4069,7 @@ void Unit::RemoveAurasWithFamily( if (!casterGUID || aura->GetCasterGUID() == casterGUID) { SpellInfo const* spell = aura->GetSpellInfo(); - if (spell->SpellFamilyName == uint32(family) && - spell->SpellFamilyFlags.HasFlag(familyFlag1, familyFlag2, familyFlag3)) + if (spell->SpellFamilyName == uint32(family) && spell->SpellFamilyFlags.HasFlag(familyFlag1, familyFlag2, familyFlag3)) { RemoveAura(iter); continue; @@ -4191,8 +4126,7 @@ void Unit::RemoveAurasByShapeShift() for (AuraApplicationMap::iterator iter = m_appliedAuras.begin(); iter != m_appliedAuras.end();) { Aura const* aura = iter->second->GetBase(); - if ((aura->GetSpellInfo()->GetAllEffectsMechanicMask() & mechanic_mask) && - !aura->GetSpellInfo()->HasAttribute(SPELL_ATTR0_CU_AURA_CC)) + if ((aura->GetSpellInfo()->GetAllEffectsMechanicMask() & mechanic_mask) && !aura->GetSpellInfo()->HasAttribute(SPELL_ATTR0_CU_AURA_CC)) { RemoveAura(iter); continue; @@ -4258,12 +4192,10 @@ void Unit::RemoveArenaAuras() [](AuraApplication const* aurApp) { Aura const* aura = aurApp->GetBase(); - return (!aura->GetSpellInfo()->HasAttribute( - SPELL_ATTR4_DONT_REMOVE_IN_ARENA) // don't remove stances, shadowform, pally/hunter auras - && !aura->IsPassive() // don't remove passive auras - && (aurApp->IsPositive() || !aura->GetSpellInfo()->HasAttribute( - SPELL_ATTR3_DEATH_PERSISTENT))) || // not negative death persistent auras - aura->GetSpellInfo()->HasAttribute(SPELL_ATTR5_REMOVE_ON_ARENA_ENTER); // special marker, always remove + return (!aura->GetSpellInfo()->HasAttribute(SPELL_ATTR4_DONT_REMOVE_IN_ARENA) // don't remove stances, shadowform, pally/hunter auras + && !aura->IsPassive() // don't remove passive auras + && (aurApp->IsPositive() || !aura->GetSpellInfo()->HasAttribute(SPELL_ATTR3_DEATH_PERSISTENT))) || // not negative death persistent auras + aura->GetSpellInfo()->HasAttribute(SPELL_ATTR5_REMOVE_ON_ARENA_ENTER); // special marker, always remove }); } @@ -4392,8 +4324,7 @@ void Unit::DelayOwnedAuras(uint32 spellId, ObjectGuid caster, int32 delaytime) // update for out of range group members (on 1 slot use) aura->SetNeedClientUpdateForTargets(); - LOG_DEBUG("spells", "Aura %u partially interrupted on unit %u, new duration: %u ms", aura->GetId(), - GetGUID().GetCounter(), aura->GetDuration()); + LOG_DEBUG("spells", "Aura %u partially interrupted on unit %u, new duration: %u ms", aura->GetId(), GetGUID().GetCounter(), aura->GetDuration()); } } } @@ -4459,8 +4390,7 @@ AuraEffect* Unit::GetAuraEffect(AuraType type, SpellFamilyNames name, uint32 ico return nullptr; } -AuraEffect* Unit::GetAuraEffect(AuraType type, SpellFamilyNames family, uint32 familyFlag1, uint32 familyFlag2, - uint32 familyFlag3, ObjectGuid casterGUID) const +AuraEffect* Unit::GetAuraEffect(AuraType type, SpellFamilyNames family, uint32 familyFlag1, uint32 familyFlag2, uint32 familyFlag3, ObjectGuid casterGUID) const { AuraEffectList const& auras = GetAuraEffectsByType(type); for (AuraEffectList::const_iterator i = auras.begin(); i != auras.end(); ++i) @@ -4481,8 +4411,7 @@ AuraEffect* Unit::GetDummyAuraEffect(SpellFamilyNames name, uint32 iconId, uint8 return GetAuraEffect(SPELL_AURA_DUMMY, name, iconId, effIndex); } -AuraApplication* Unit::GetAuraApplication( - uint32 spellId, ObjectGuid casterGUID, ObjectGuid itemCasterGUID, uint8 reqEffMask, AuraApplication* except) const +AuraApplication* Unit::GetAuraApplication(uint32 spellId, ObjectGuid casterGUID, ObjectGuid itemCasterGUID, uint8 reqEffMask, AuraApplication* except) const { AuraApplicationMapBounds range = m_appliedAuras.equal_range(spellId); for (; range.first != range.second; ++range.first) @@ -4490,8 +4419,8 @@ AuraApplication* Unit::GetAuraApplication( AuraApplication* app = range.first->second; Aura const* aura = app->GetBase(); - if (((aura->GetEffectMask() & reqEffMask) == reqEffMask) && (!casterGUID || aura->GetCasterGUID() == casterGUID) && - (!itemCasterGUID || aura->GetCastItemGUID() == itemCasterGUID) && (!except || except != app)) + if (((aura->GetEffectMask() & reqEffMask) == reqEffMask) && (!casterGUID || aura->GetCasterGUID() == casterGUID) && (!itemCasterGUID || aura->GetCastItemGUID() == itemCasterGUID) && + (!except || except != app)) { return app; } @@ -4505,8 +4434,7 @@ Aura* Unit::GetAura(uint32 spellId, ObjectGuid casterGUID, ObjectGuid itemCaster return aurApp ? aurApp->GetBase() : nullptr; } -AuraApplication* Unit::GetAuraApplicationOfRankedSpell( - uint32 spellId, ObjectGuid casterGUID, ObjectGuid itemCasterGUID, uint8 reqEffMask, AuraApplication* except) const +AuraApplication* Unit::GetAuraApplicationOfRankedSpell(uint32 spellId, ObjectGuid casterGUID, ObjectGuid itemCasterGUID, uint8 reqEffMask, AuraApplication* except) const { uint32 rankSpell = sSpellMgr->GetFirstSpellInChain(spellId); while (rankSpell) @@ -4524,8 +4452,7 @@ Aura* Unit::GetAuraOfRankedSpell(uint32 spellId, ObjectGuid casterGUID, ObjectGu return aurApp ? aurApp->GetBase() : nullptr; } -void Unit::GetDispellableAuraList( - Unit* caster, uint32 dispelMask, DispelChargesList& dispelList, bool isReflect /*= false*/) const +void Unit::GetDispellableAuraList(Unit* caster, uint32 dispelMask, DispelChargesList& dispelList, bool isReflect /*= false*/) const { // we should not be able to dispel diseases if the target is affected by unholy blight if (dispelMask & (1 << DISPEL_DISEASE) && HasAura(50536)) @@ -4603,7 +4530,10 @@ bool Unit::HasAura(uint32 spellId, ObjectGuid casterGUID, ObjectGuid itemCasterG return false; } -bool Unit::HasAuraType(AuraType auraType) const { return (!m_modAuras[auraType].empty()); } +bool Unit::HasAuraType(AuraType auraType) const +{ + return (!m_modAuras[auraType].empty()); +} bool Unit::HasAuraTypeWithCaster(AuraType auraType, ObjectGuid caster) const { @@ -4647,8 +4577,7 @@ template bool Unit::HasNegativeAuraWithInterruptFlag(I for (AuraApplicationList::const_iterator iter = m_interruptableAuras.begin(); iter != m_interruptableAuras.end(); ++iter) { - if (!(*iter)->IsPositive() && (*iter)->GetBase()->GetSpellInfo()->HasAuraInterruptFlag(flag) && - (!guid || (*iter)->GetBase()->GetCasterGUID() == guid)) + if (!(*iter)->IsPositive() && (*iter)->GetBase()->GetSpellInfo()->HasAuraInterruptFlag(flag) && (!guid || (*iter)->GetBase()->GetCasterGUID() == guid)) return true; } return false; @@ -4770,8 +4699,7 @@ int32 Unit::GetTotalAuraModifier(AuraType auraType, std::functionAddSameEffectStackRuleSpellGroups( - aurEff->GetSpellInfo(), static_cast(auraType), aurEff->GetAmount(), sameEffectSpellGroup)) + if (!sSpellMgr->AddSameEffectStackRuleSpellGroups(aurEff->GetSpellInfo(), static_cast(auraType), aurEff->GetAmount(), sameEffectSpellGroup)) modifier += aurEff->GetAmount(); } } @@ -4798,8 +4726,7 @@ float Unit::GetTotalAuraMultiplier(AuraType auraType, std::functionAddSameEffectStackRuleSpellGroups( - aurEff->GetSpellInfo(), static_cast(auraType), aurEff->GetAmount(), sameEffectSpellGroup)) + if (!sSpellMgr->AddSameEffectStackRuleSpellGroups(aurEff->GetSpellInfo(), static_cast(auraType), aurEff->GetAmount(), sameEffectSpellGroup)) AddPct(multiplier, aurEff->GetAmount()); } } @@ -5276,17 +5203,17 @@ void Unit::SendSpellNonMeleeDamageLog(SpellNonMeleeDamage* log) data << uint8(log->schoolMask); // damage school data << uint32(log->absorb); // AbsorbedDamage data << uint32(log->resist); // resist - data << uint8(log->physicalLog); // if 1, then client show spell name (example: %s's ranged shot hit %s for %u school or %s - // suffers %u school damage from %s's spell_name - data << uint8(log->unused); // unused - data << uint32(log->blocked); // blocked + data << uint8(log->physicalLog); // if 1, then client show spell name (example: %s's ranged shot hit %s for %u school or %s + // suffers %u school damage from %s's spell_name + data << uint8(log->unused); // unused + data << uint32(log->blocked); // blocked data << uint32(log->HitInfo); data << uint8(0); // flag to use extend data SendMessageToSet(&data, true); } -void Unit::SendSpellNonMeleeDamageLog(Unit* target, uint32 SpellID, uint32 Damage, SpellSchoolMask damageSchoolMask, - uint32 AbsorbedDamage, uint32 Resist, bool PhysicalDamage, uint32 Blocked, bool CriticalHit) +void Unit::SendSpellNonMeleeDamageLog( + Unit* target, uint32 SpellID, uint32 Damage, SpellSchoolMask damageSchoolMask, uint32 AbsorbedDamage, uint32 Resist, bool PhysicalDamage, uint32 Blocked, bool CriticalHit) { SpellNonMeleeDamage log(this, target, SpellID, damageSchoolMask); log.damage = Damage - AbsorbedDamage - Resist - Blocked; @@ -5300,18 +5227,18 @@ void Unit::SendSpellNonMeleeDamageLog(Unit* target, uint32 SpellID, uint32 Damag SendSpellNonMeleeDamageLog(&log); } -void Unit::ProcSkillsAndAuras(Unit* actionTarget, uint32 typeMaskActor, uint32 typeMaskActionTarget, uint32 spellTypeMask, - uint32 spellPhaseMask, uint32 hitMask, Spell* spell, DamageInfo* damageInfo, HealInfo* healInfo) +/*static*/ void Unit::ProcSkillsAndAuras(Unit* actor, Unit* actionTarget, uint32 typeMaskActor, uint32 typeMaskActionTarget, uint32 spellTypeMask, uint32 spellPhaseMask, uint32 hitMask, Spell* spell, + DamageInfo* damageInfo, HealInfo* healInfo) { WeaponAttackType attType = damageInfo ? damageInfo->GetAttackType() : BASE_ATTACK; - if (typeMaskActor) - ProcSkillsAndReactives(false, actionTarget, typeMaskActor, hitMask, attType); + if (typeMaskActor && actor) + actor->ProcSkillsAndReactives(false, actionTarget, typeMaskActor, hitMask, attType); if (typeMaskActionTarget && actionTarget) - actionTarget->ProcSkillsAndReactives(true, this, typeMaskActionTarget, hitMask, attType); + actionTarget->ProcSkillsAndReactives(true, actor, typeMaskActionTarget, hitMask, attType); - TriggerAurasProcOnEvent( - actionTarget, typeMaskActor, typeMaskActionTarget, spellTypeMask, spellPhaseMask, hitMask, spell, damageInfo, healInfo); + if (actor) + actor->TriggerAurasProcOnEvent(actionTarget, typeMaskActor, typeMaskActionTarget, spellTypeMask, spellPhaseMask, hitMask, spell, damageInfo, healInfo); } void Unit::SendPeriodicAuraLog(SpellPeriodicAuraLogInfo* pInfo) @@ -5417,8 +5344,8 @@ void Unit::SendAttackStateUpdate(CalcDamageInfo* damageInfo) SendMessageToSet(packet.Write(), true); } -void Unit::SendAttackStateUpdate(uint32 HitInfo, Unit* target, uint8 /*SwingType*/, SpellSchoolMask damageSchoolMask, - uint32 Damage, uint32 AbsorbDamage, uint32 Resist, VictimState TargetState, uint32 BlockedAmount) +void Unit::SendAttackStateUpdate( + uint32 HitInfo, Unit* target, uint8 /*SwingType*/, SpellSchoolMask damageSchoolMask, uint32 Damage, uint32 AbsorbDamage, uint32 Resist, VictimState TargetState, uint32 BlockedAmount) { CalcDamageInfo dmgInfo; dmgInfo.HitInfo = HitInfo; @@ -5503,8 +5430,7 @@ void Unit::UpdateDisplayPower() { if (Vehicle* vehicle = GetVehicleKit()) { - if (PowerDisplayEntry const* powerDisplay = sPowerDisplayStore.LookupEntry( - vehicle->GetVehicleInfo()->PowerDisplayID[0])) // To-do: 4.x has 3 power display id fields. + if (PowerDisplayEntry const* powerDisplay = sPowerDisplayStore.LookupEntry(vehicle->GetVehicleInfo()->PowerDisplayID[0])) // To-do: 4.x has 3 power display id fields. displayPower = Powers(powerDisplay->ActualType); else if (getClass() == CLASS_ROGUE) displayPower = POWER_ENERGY; @@ -5537,14 +5463,11 @@ FactionTemplateEntry const* Unit::GetFactionTemplateEntry() const if (!entry) { if (Player const* player = ToPlayer()) - LOG_ERROR("entities.unit", "Player %s has invalid faction (faction template id) #%u", player->GetName().c_str(), - GetFaction()); + LOG_ERROR("entities.unit", "Player %s has invalid faction (faction template id) #%u", player->GetName().c_str(), GetFaction()); else if (Creature const* creature = ToCreature()) - LOG_ERROR("entities.unit", "Creature (template id: %u) has invalid faction (faction template id) #%u", - creature->GetCreatureTemplate()->Entry, GetFaction()); + LOG_ERROR("entities.unit", "Creature (template id: %u) has invalid faction (faction template id) #%u", creature->GetCreatureTemplate()->Entry, GetFaction()); else - LOG_ERROR("entities.unit", "Unit (name=%s, type=%u) has invalid faction (faction template id) #%u", GetName().c_str(), - uint32(GetTypeId()), GetFaction()); + LOG_ERROR("entities.unit", "Unit (name=%s, type=%u) has invalid faction (faction template id) #%u", GetName().c_str(), uint32(GetTypeId()), GetFaction()); ABORT(); } @@ -5569,15 +5492,13 @@ ReputationRank Unit::GetReactionTo(Unit const* target) const if (selfPlayerOwner) { if (FactionTemplateEntry const* targetFactionTemplateEntry = target->GetFactionTemplateEntry()) - if (ReputationRank const* repRank = - selfPlayerOwner->GetReputationMgr().GetForcedRankIfAny(targetFactionTemplateEntry)) + if (ReputationRank const* repRank = selfPlayerOwner->GetReputationMgr().GetForcedRankIfAny(targetFactionTemplateEntry)) return *repRank; } else if (targetPlayerOwner) { if (FactionTemplateEntry const* selfFactionTemplateEntry = GetFactionTemplateEntry()) - if (ReputationRank const* repRank = - targetPlayerOwner->GetReputationMgr().GetForcedRankIfAny(selfFactionTemplateEntry)) + if (ReputationRank const* repRank = targetPlayerOwner->GetReputationMgr().GetForcedRankIfAny(selfFactionTemplateEntry)) return *repRank; } @@ -5592,8 +5513,7 @@ ReputationRank Unit::GetReactionTo(Unit const* target) const return REP_FRIENDLY; // duel - always hostile to opponent - if (selfPlayerOwner->duel && selfPlayerOwner->duel->opponent == targetPlayerOwner && - selfPlayerOwner->duel->startTime != 0) + if (selfPlayerOwner->duel && selfPlayerOwner->duel->opponent == targetPlayerOwner && selfPlayerOwner->duel->startTime != 0) return REP_HOSTILE; // same group - checks dependant only on our faction - skip FFA_PVP for example @@ -5611,19 +5531,16 @@ ReputationRank Unit::GetReactionTo(Unit const* target) const { if (FactionTemplateEntry const* targetFactionTemplateEntry = target->GetFactionTemplateEntry()) { - if (ReputationRank const* repRank = - selfPlayerOwner->GetReputationMgr().GetForcedRankIfAny(targetFactionTemplateEntry)) + if (ReputationRank const* repRank = selfPlayerOwner->GetReputationMgr().GetForcedRankIfAny(targetFactionTemplateEntry)) return *repRank; if (!selfPlayerOwner->HasFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_IGNORE_REPUTATION)) { - if (FactionEntry const* targetFactionEntry = - sFactionStore.LookupEntry(targetFactionTemplateEntry->Faction)) + if (FactionEntry const* targetFactionEntry = sFactionStore.LookupEntry(targetFactionTemplateEntry->Faction)) { if (targetFactionEntry->CanHaveReputation()) { // check contested flags - if (targetFactionTemplateEntry->IsHostileToPvpActivePlayers() && - selfPlayerOwner->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_CONTESTED_PVP)) + if (targetFactionTemplateEntry->IsHostileToPvpActivePlayers() && selfPlayerOwner->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_CONTESTED_PVP)) return REP_HOSTILE; // if faction has reputation, hostile state depends only from AtWar state @@ -5652,8 +5569,7 @@ ReputationRank Unit::GetFactionReactionTo(FactionTemplateEntry const* factionTem if (Player const* targetPlayerOwner = target->GetAffectingPlayer()) { // check contested flags - if (factionTemplateEntry->IsHostileToPvpActivePlayers() && - targetPlayerOwner->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_CONTESTED_PVP)) + if (factionTemplateEntry->IsHostileToPvpActivePlayers() && targetPlayerOwner->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_CONTESTED_PVP)) return REP_HOSTILE; if (ReputationRank const* repRank = targetPlayerOwner->GetReputationMgr().GetForcedRankIfAny(factionTemplateEntry)) return *repRank; @@ -5684,9 +5600,15 @@ ReputationRank Unit::GetFactionReactionTo(FactionTemplateEntry const* factionTem return REP_NEUTRAL; } -bool Unit::IsHostileTo(Unit const* unit) const { return GetReactionTo(unit) <= REP_HOSTILE; } +bool Unit::IsHostileTo(Unit const* unit) const +{ + return GetReactionTo(unit) <= REP_HOSTILE; +} -bool Unit::IsFriendlyTo(Unit const* unit) const { return GetReactionTo(unit) >= REP_FRIENDLY; } +bool Unit::IsFriendlyTo(Unit const* unit) const +{ + return GetReactionTo(unit) >= REP_FRIENDLY; +} bool Unit::IsHostileToPlayers() const { @@ -5714,9 +5636,15 @@ bool Unit::IsNeutralToAll() const return my_faction->IsNeutralToAll(); } -void Unit::_addAttacker(Unit* pAttacker) { m_attackers.insert(pAttacker); } +void Unit::_addAttacker(Unit* pAttacker) +{ + m_attackers.insert(pAttacker); +} -void Unit::_removeAttacker(Unit* pAttacker) { m_attackers.erase(pAttacker); } +void Unit::_removeAttacker(Unit* pAttacker) +{ + m_attackers.erase(pAttacker); +} Unit* Unit::getAttackerForHelper() const // If someone wants to help, who to give them { @@ -5830,9 +5758,7 @@ bool Unit::Attack(Unit* victim, bool meleeAttack) // delay offhand weapon attack by 50% of the base attack time if (haveOffhandWeapon() && GetTypeId() != TYPEID_PLAYER) - setAttackTimer( - OFF_ATTACK, std::max(getAttackTimer(OFF_ATTACK), - getAttackTimer(BASE_ATTACK) + uint32(CalculatePct(GetFloatValue(UNIT_FIELD_BASEATTACKTIME), 50)))); + setAttackTimer(OFF_ATTACK, std::max(getAttackTimer(OFF_ATTACK), getAttackTimer(BASE_ATTACK) + uint32(CalculatePct(GetFloatValue(UNIT_FIELD_BASEATTACKTIME), 50)))); if (meleeAttack) SendMeleeAttackStart(victim); @@ -5998,8 +5924,7 @@ void Unit::ModifyAuraState(AuraStateType flag, bool apply) for (Unit::AuraApplicationMap::iterator itr = tAuras.begin(); itr != tAuras.end();) { SpellInfo const* spellProto = itr->second->GetBase()->GetSpellInfo(); - if (itr->second->GetBase()->GetCasterGUID() == GetGUID() && spellProto->CasterAuraState == uint32(flag) && - (spellProto->IsPassive() || flag != AURA_STATE_ENRAGE)) + if (itr->second->GetBase()->GetCasterGUID() == GetGUID() && spellProto->CasterAuraState == uint32(flag) && (spellProto->IsPassive() || flag != AURA_STATE_ENRAGE)) RemoveAura(itr); else ++itr; @@ -6057,8 +5982,7 @@ void Unit::SetOwnerGUID(ObjectGuid owner) // Update owner dependent fields Player* player = ObjectAccessor::GetPlayer(*this, owner); - if (!player || - !player->HaveAtClient(this)) // if player cannot see this unit yet, he will receive needed data with create object + if (!player || !player->HaveAtClient(this)) // if player cannot see this unit yet, he will receive needed data with create object return; SetFieldNotifyFlag(UF_FLAG_OWNER); @@ -6155,8 +6079,7 @@ void Unit::SetMinion(Minion* minion, bool apply) { if (!minion) { - LOG_ERROR( - "entities.unit", "Unit::SetMinion: Unit %s tried to reference a non existing minion", GetGUID().ToString().c_str()); + LOG_ERROR("entities.unit", "Unit::SetMinion: Unit %s tried to reference a non existing minion", GetGUID().ToString().c_str()); return; } @@ -6210,8 +6133,7 @@ void Unit::SetMinion(Minion* minion, bool apply) SetCritterGUID(minion->GetGUID()); // PvP, FFAPvP - minion->SetByteValue( - UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG, GetByteValue(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG)); + minion->SetByteValue(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG, GetByteValue(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG)); // Send infinity cooldown - client does that automatically but after relog cooldown needs to be set again SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(minion->GetUInt32Value(UNIT_CREATED_BY_SPELL)); @@ -6317,9 +6239,8 @@ void Unit::SetCharm(Unit* charm, bool apply) { if (GetTypeId() == TYPEID_PLAYER) { - ASSERT(AddGuidValue(UNIT_FIELD_CHARM, charm->GetGUID()), - "Player %s is trying to charm unit %u, but it already has a charmed unit %s", GetName().c_str(), - charm->GetEntry(), GetCharmedGUID().ToString().c_str()); + ASSERT(AddGuidValue(UNIT_FIELD_CHARM, charm->GetGUID()), "Player %s is trying to charm unit %u, but it already has a charmed unit %s", GetName().c_str(), charm->GetEntry(), + GetCharmedGUID().ToString().c_str()); m_charmed = charm; charm->m_ControlledByPlayer = true; @@ -6330,11 +6251,9 @@ void Unit::SetCharm(Unit* charm, bool apply) charm->m_ControlledByPlayer = false; // PvP, FFAPvP - charm->SetByteValue( - UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG, GetByteValue(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG)); + charm->SetByteValue(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG, GetByteValue(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG)); - ASSERT(charm->AddGuidValue(UNIT_FIELD_CHARMEDBY, GetGUID()), "Unit %u is being charmed, but it already has a charmer %s", - charm->GetEntry(), charm->GetCharmerGUID().ToString().c_str()); + ASSERT(charm->AddGuidValue(UNIT_FIELD_CHARMEDBY, GetGUID()), "Unit %u is being charmed, but it already has a charmer %s", charm->GetEntry(), charm->GetCharmerGUID().ToString().c_str()); charm->m_charmer = this; _isWalkingBeforeCharm = charm->IsWalking(); @@ -6349,15 +6268,12 @@ void Unit::SetCharm(Unit* charm, bool apply) if (GetTypeId() == TYPEID_PLAYER) { - ASSERT(RemoveGuidValue(UNIT_FIELD_CHARM, charm->GetGUID()), - "Player %s is trying to uncharm unit %u, but it has another charmed unit %s", GetName().c_str(), - charm->GetEntry(), GetCharmedGUID().ToString().c_str()); + ASSERT(RemoveGuidValue(UNIT_FIELD_CHARM, charm->GetGUID()), "Player %s is trying to uncharm unit %u, but it has another charmed unit %s", GetName().c_str(), charm->GetEntry(), + GetCharmedGUID().ToString().c_str()); m_charmed = nullptr; } - ASSERT(charm->RemoveGuidValue(UNIT_FIELD_CHARMEDBY, GetGUID()), - "Unit %u is being uncharmed, but it has another charmer %s", charm->GetEntry(), - charm->GetCharmerGUID().ToString().c_str()); + ASSERT(charm->RemoveGuidValue(UNIT_FIELD_CHARMEDBY, GetGUID()), "Unit %u is being uncharmed, but it has another charmer %s", charm->GetEntry(), charm->GetCharmerGUID().ToString().c_str()); charm->m_charmer = nullptr; if (charm->GetTypeId() == TYPEID_PLAYER) @@ -6370,8 +6286,7 @@ void Unit::SetCharm(Unit* charm, bool apply) { charm->m_ControlledByPlayer = true; charm->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED); - charm->SetByteValue(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG, - player->GetByteValue(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG)); + charm->SetByteValue(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG, player->GetByteValue(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG)); } else { @@ -6383,8 +6298,7 @@ void Unit::SetCharm(Unit* charm, bool apply) if (charm->IsWalking() != _isWalkingBeforeCharm) charm->SetWalk(_isWalkingBeforeCharm); - if (charm->GetTypeId() == TYPEID_PLAYER || !charm->ToCreature()->HasUnitTypeMask(UNIT_MASK_MINION) || - charm->GetOwnerOrCreatorGUID() != GetGUID()) + if (charm->GetTypeId() == TYPEID_PLAYER || !charm->ToCreature()->HasUnitTypeMask(UNIT_MASK_MINION) || charm->GetOwnerOrCreatorGUID() != GetGUID()) { m_Controlled.erase(charm); } @@ -6392,39 +6306,46 @@ void Unit::SetCharm(Unit* charm, bool apply) UpdatePetCombatState(); } -void Unit::DealHeal(HealInfo& healInfo) +/*static*/ void Unit::DealHeal(HealInfo& healInfo) { int32 gain = 0; + Unit* healer = healInfo.GetHealer(); Unit* victim = healInfo.GetTarget(); uint32 addhealth = healInfo.GetHeal(); - if (UnitAI* victimAI = victim->GetAI()) - victimAI->HealReceived(this, addhealth); + if (healer) + { + if (UnitAI* victimAI = victim->GetAI()) + victimAI->HealReceived(healer, addhealth); - if (UnitAI* healerAI = GetAI()) - healerAI->HealDone(victim, addhealth); + if (UnitAI* healerAI = healer->GetAI()) + healerAI->HealDone(victim, addhealth); + } if (addhealth) gain = victim->ModifyHealth(int32(addhealth)); // Hook for OnHeal Event - sScriptMgr->OnHeal(this, victim, (uint32&)gain); + sScriptMgr->OnHeal(healer, victim, (uint32&)gain); - Unit* unit = this; + Unit* unit = healer; - if (GetTypeId() == TYPEID_UNIT && IsTotem()) - unit = GetOwner(); + if (healer && healer->GetTypeId() == TYPEID_UNIT && healer->IsTotem()) + unit = healer->GetOwner(); - if (Player* player = unit->ToPlayer()) + if (unit) { - if (Battleground* bg = player->GetBattleground()) - bg->UpdatePlayerScore(player, SCORE_HEALING_DONE, gain); + if (Player* player = unit->ToPlayer()) + { + if (Battleground* bg = player->GetBattleground()) + bg->UpdatePlayerScore(player, SCORE_HEALING_DONE, gain); - // use the actual gain, as the overheal shall not be counted, skip gain 0 (it ignored anyway in to criteria) - if (gain) - player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HEALING_DONE, gain, 0, 0, victim); + // use the actual gain, as the overheal shall not be counted, skip gain 0 (it ignored anyway in to criteria) + if (gain) + player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HEALING_DONE, gain, 0, 0, victim); - player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HEAL_CAST, addhealth); + player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HEAL_CAST, addhealth); + } } if (Player* player = victim->ToPlayer()) @@ -6449,8 +6370,7 @@ bool Unit::IsMagnet() const Unit* Unit::GetMagicHitRedirectTarget(Unit* victim, SpellInfo const* spellInfo) { // Patch 1.2 notes: Spell Reflection no longer reflects abilities - if (spellInfo->HasAttribute(SPELL_ATTR0_IS_ABILITY) || spellInfo->HasAttribute(SPELL_ATTR1_CANT_BE_REDIRECTED) || - spellInfo->HasAttribute(SPELL_ATTR0_NO_IMMUNITIES)) + if (spellInfo->HasAttribute(SPELL_ATTR0_IS_ABILITY) || spellInfo->HasAttribute(SPELL_ATTR1_CANT_BE_REDIRECTED) || spellInfo->HasAttribute(SPELL_ATTR0_NO_IMMUNITIES)) return victim; Unit::AuraEffectList const& magnetAuras = victim->GetAuraEffectsByType(SPELL_AURA_SPELL_MAGNET); @@ -6463,8 +6383,7 @@ Unit* Unit::GetMagicHitRedirectTarget(Unit* victim, SpellInfo const* spellInfo) if (spellInfo->Speed > 0.0f) { // Set up missile speed based delay - uint32 delay = - uint32(std::floor(std::max(victim->GetDistance(this), 5.0f) / spellInfo->Speed * 1000.0f)); + uint32 delay = uint32(std::floor(std::max(victim->GetDistance(this), 5.0f) / spellInfo->Speed * 1000.0f)); // Schedule charge drop (*itr)->GetBase()->DropChargeDelayed(delay, AuraRemoveFlags::Expired); } @@ -6484,8 +6403,7 @@ Unit* Unit::GetMeleeHitRedirectTarget(Unit* victim, SpellInfo const* spellInfo) { if (Unit* magnet = (*i)->GetBase()->GetCaster()) if (_IsValidAttackTarget(magnet, spellInfo) && magnet->IsWithinLOSInMap(this) && - (!spellInfo || (spellInfo->CheckExplicitTarget(this, magnet) == SPELL_CAST_OK && - spellInfo->CheckTarget(this, magnet, false) == SPELL_CAST_OK))) + (!spellInfo || (spellInfo->CheckExplicitTarget(this, magnet) == SPELL_CAST_OK && spellInfo->CheckTarget(this, magnet, false) == SPELL_CAST_OK))) if (roll_chance_i((*i)->GetAmount())) { (*i)->GetBase()->DropCharge(AuraRemoveFlags::Expired); @@ -6521,25 +6439,27 @@ void Unit::RemoveAllControlled() else if (target->GetOwnerOrCreatorGUID() == GetGUID() && target->IsSummon()) target->ToTempSummon()->UnSummon(); else - LOG_ERROR("entities.unit", "Unit %u is trying to release unit %u which is neither charmed nor owned by it", - GetEntry(), target->GetEntry()); + LOG_ERROR("entities.unit", "Unit %u is trying to release unit %u which is neither charmed nor owned by it", GetEntry(), target->GetEntry()); } if (GetPetGUID()) LOG_FATAL("entities.unit", "Unit %u is not able to release its pet %s", GetEntry(), GetPetGUID().ToString().c_str()); if (GetMinionGUID()) - LOG_FATAL( - "entities.unit", "Unit %u is not able to release its minion %s", GetEntry(), GetMinionGUID().ToString().c_str()); + LOG_FATAL("entities.unit", "Unit %u is not able to release its minion %s", GetEntry(), GetMinionGUID().ToString().c_str()); if (GetCharmedGUID()) - LOG_FATAL( - "entities.unit", "Unit %u is not able to release its charm %s", GetEntry(), GetCharmedGUID().ToString().c_str()); - if (!IsPet()) // pets don't use the flag for this - RemoveFlag( - UNIT_FIELD_FLAGS, UNIT_FLAG_PET_IN_COMBAT); // m_controlled is now empty, so we know none of our minions are in combat + LOG_FATAL("entities.unit", "Unit %u is not able to release its charm %s", GetEntry(), GetCharmedGUID().ToString().c_str()); + if (!IsPet()) // pets don't use the flag for this + RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PET_IN_COMBAT); // m_controlled is now empty, so we know none of our minions are in combat } -bool Unit::isPossessedByPlayer() const { return HasUnitState(UNIT_STATE_POSSESSED) && GetCharmerGUID().IsPlayer(); } +bool Unit::isPossessedByPlayer() const +{ + return HasUnitState(UNIT_STATE_POSSESSED) && GetCharmerGUID().IsPlayer(); +} -bool Unit::isPossessing(Unit* u) const { return u->isPossessed() && GetCharmedGUID() == u->GetGUID(); } +bool Unit::isPossessing(Unit* u) const +{ + return u->isPossessed() && GetCharmedGUID() == u->GetGUID(); +} bool Unit::isPossessing() const { @@ -6630,7 +6550,10 @@ void Unit::RemovePlayerFromVision(Player* player) } } -void Unit::RemoveBindSightAuras() { RemoveAurasByType(SPELL_AURA_BIND_SIGHT); } +void Unit::RemoveBindSightAuras() +{ + RemoveAurasByType(SPELL_AURA_BIND_SIGHT); +} void Unit::RemoveCharmAuras() { @@ -6670,9 +6593,9 @@ void Unit::SendHealSpellLog(HealInfo& healInfo, bool critical /*= false*/) int32 Unit::HealBySpell(HealInfo& healInfo, bool critical /*= false*/) { // calculate heal absorb and reduce healing - CalcHealAbsorb(healInfo); + Unit::CalcHealAbsorb(healInfo); + Unit::DealHeal(healInfo); - DealHeal(healInfo); SendHealSpellLog(healInfo, critical); return healInfo.GetEffectiveHeal(); } @@ -6702,8 +6625,7 @@ void Unit::EnergizeBySpell(Unit* victim, SpellInfo const* spellInfo, int32 damag SendEnergizeSpellLog(victim, spellInfo->Id, damage, powerType); } -uint32 Unit::SpellDamageBonusDone( - Unit* victim, SpellInfo const* spellProto, uint32 pdamage, DamageEffectType damagetype, uint8 effIndex, uint32 stack) const +uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, uint32 pdamage, DamageEffectType damagetype, uint8 effIndex, uint32 stack) const { if (!spellProto || !victim || damagetype == DIRECT_DAMAGE) return pdamage; @@ -6783,8 +6705,7 @@ uint32 Unit::SpellDamageBonusDone( float spellPowerCoeff = spellProto->Effects[effIndex].BonusMultiplier; float attackPowerCoeff = spellProto->BonusCoefficient; - WeaponAttackType const attType = - (spellProto->IsRangedWeaponSpell() && spellProto->DmgClass != SPELL_DAMAGE_CLASS_MELEE) ? RANGED_ATTACK : BASE_ATTACK; + WeaponAttackType const attType = (spellProto->IsRangedWeaponSpell() && spellProto->DmgClass != SPELL_DAMAGE_CLASS_MELEE) ? RANGED_ATTACK : BASE_ATTACK; if (SpellBonusEntry const* bonus = sSpellMgr->GetSpellBonusData(spellProto->Id)) { @@ -6811,9 +6732,7 @@ uint32 Unit::SpellDamageBonusDone( if (attackPowerCoeff > 0.f) { - float APbonus = - float(victim->GetTotalAuraModifier(attType == BASE_ATTACK ? SPELL_AURA_MELEE_ATTACK_POWER_ATTACKER_BONUS - : SPELL_AURA_RANGED_ATTACK_POWER_ATTACKER_BONUS)); + float APbonus = float(victim->GetTotalAuraModifier(attType == BASE_ATTACK ? SPELL_AURA_MELEE_ATTACK_POWER_ATTACKER_BONUS : SPELL_AURA_RANGED_ATTACK_POWER_ATTACKER_BONUS)); APbonus += GetTotalAttackPowerValue(attType); DoneTotal += int32(attackPowerCoeff * stack * APbonus); } @@ -6871,12 +6790,10 @@ float Unit::SpellDamagePctDone(Unit* victim, SpellInfo const* spellProto, Damage { for (uint32 i = 0; i < MAX_SPELL_SCHOOL; ++i) if (spellProto->GetSchoolMask() & (1 << i)) - maxModDamagePercentSchool = - std::max(maxModDamagePercentSchool, GetFloatValue(PLAYER_FIELD_MOD_DAMAGE_DONE_PCT + i)); + maxModDamagePercentSchool = std::max(maxModDamagePercentSchool, GetFloatValue(PLAYER_FIELD_MOD_DAMAGE_DONE_PCT + i)); } else - maxModDamagePercentSchool = - GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_DAMAGE_PERCENT_DONE, spellProto->GetSchoolMask()); + maxModDamagePercentSchool = GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_DAMAGE_PERCENT_DONE, spellProto->GetSchoolMask()); DoneTotalMod *= maxModDamagePercentSchool; @@ -6959,8 +6876,7 @@ float Unit::SpellDamagePctDone(Unit* victim, SpellInfo const* spellProto, Damage // Add SPELL_AURA_MOD_DAMAGE_FROM_MANA percent bonus if (HasAuraType(SPELL_AURA_MOD_DAMAGE_FROM_MANA) && GetMaxPower(POWER_MANA)) { - float totalBonus = - (owner->GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_DAMAGE_FROM_MANA, spellProto->GetSchoolMask()) - 1.f) * 100.f; + float totalBonus = (owner->GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_DAMAGE_FROM_MANA, spellProto->GetSchoolMask()) - 1.f) * 100.f; float manaPct = 100.f * ((float)GetPower(POWER_MANA) / GetMaxPower(POWER_MANA)); if (totalBonus != 0.f && manaPct != 0.f) AddPct(DoneTotalMod, CalculatePct(totalBonus, manaPct)); @@ -6979,8 +6895,7 @@ float Unit::SpellDamagePctDone(Unit* victim, SpellInfo const* spellProto, Damage // Ice Lance if (spellProto->SpellIconID == 186) { - if (victim->HasAuraState(AURA_STATE_FROZEN, spellProto, this) || - GetAuraEffect(SPELL_AURA_ABILITY_IGNORE_AURASTATE, SPELLFAMILY_MAGE, 0, 0, 0x0000000A, GetGUID())) + if (victim->HasAuraState(AURA_STATE_FROZEN, spellProto, this) || GetAuraEffect(SPELL_AURA_ABILITY_IGNORE_AURASTATE, SPELLFAMILY_MAGE, 0, 0, 0x0000000A, GetGUID())) DoneTotalMod *= 2.0f; } @@ -7086,8 +7001,7 @@ uint32 Unit::SpellDamageBonusTaken(Unit* caster, SpellInfo const* spellProto, ui { TakenTotalMod *= GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_AOE_DAMAGE_AVOIDANCE, spellProto->SchoolMask); if (caster->IsCreature()) - TakenTotalMod *= - GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_CREATURE_AOE_DAMAGE_AVOIDANCE, spellProto->SchoolMask); + TakenTotalMod *= GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_CREATURE_AOE_DAMAGE_AVOIDANCE, spellProto->SchoolMask); } // From caster spells @@ -7163,8 +7077,7 @@ int32 Unit::SpellBaseDamageBonusDone(SpellSchoolMask schoolMask, bool withSpellP } // ... and attack power - DoneAdvertisedBenefit += static_cast(CalculatePct(GetTotalAttackPowerValue(BASE_ATTACK), - GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_SPELL_DAMAGE_OF_ATTACK_POWER, schoolMask))); + DoneAdvertisedBenefit += static_cast(CalculatePct(GetTotalAttackPowerValue(BASE_ATTACK), GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_SPELL_DAMAGE_OF_ATTACK_POWER, schoolMask))); } return DoneAdvertisedBenefit; @@ -7189,8 +7102,7 @@ int32 Unit::SpellBaseDamageBonusTaken(SpellInfo const* spellInfo) const return TakenAdvertisedBenefit; } -float Unit::SpellCritChanceDone( - SpellInfo const* spellInfo, SpellSchoolMask schoolMask, WeaponAttackType attackType /*= BASE_ATTACK*/) const +float Unit::SpellCritChanceDone(SpellInfo const* spellInfo, SpellSchoolMask schoolMask, WeaponAttackType attackType /*= BASE_ATTACK*/) const { //! Mobs can't crit with spells. (Except player controlled) if (GetTypeId() == TYPEID_UNIT && !GetSpellModOwner()) @@ -7236,8 +7148,7 @@ float Unit::SpellCritChanceDone( return std::max(crit_chance, 0.0f); } -float Unit::SpellCritChanceTaken(Unit const* caster, SpellInfo const* spellInfo, SpellSchoolMask schoolMask, float doneChance, - WeaponAttackType attackType /*= BASE_ATTACK*/) const +float Unit::SpellCritChanceTaken(Unit const* caster, SpellInfo const* spellInfo, SpellSchoolMask schoolMask, float doneChance, WeaponAttackType attackType /*= BASE_ATTACK*/) const { // not critting spell if (spellInfo->HasAttribute(SPELL_ATTR2_CANT_CRIT)) @@ -7274,8 +7185,7 @@ float Unit::SpellCritChanceTaken(Unit const* caster, SpellInfo const* spellInfo, if (HasAuraState(AURA_STATE_FROZEN, spellInfo, caster)) crit_chance *= (1 * aurEff->GetSpellInfo()->GetRank()); else if (spellInfo->SpellFamilyFlags[0] & 0x00020000 || spellInfo->SpellFamilyFlags[1] & 0x00100000) - if (GetAuraEffect( - SPELL_AURA_ABILITY_IGNORE_AURASTATE, SPELLFAMILY_MAGE, 0, 0, 0x0000000A, caster->GetGUID())) + if (GetAuraEffect(SPELL_AURA_ABILITY_IGNORE_AURASTATE, SPELLFAMILY_MAGE, 0, 0, 0x0000000A, caster->GetGUID())) crit_chance *= (1 * aurEff->GetSpellInfo()->GetRank()); break; case 57470: // Renewed Hope @@ -7369,8 +7279,7 @@ float Unit::SpellCritChanceTaken(Unit const* caster, SpellInfo const* spellInfo, { case SPELLFAMILY_DRUID: // Rend and Tear - bonus crit chance for Ferocious Bite on bleeding targets - if (spellInfo->SpellFamilyFlags[0] & 0x00800000 && spellInfo->SpellIconID == 1680 && - HasAuraState(AURA_STATE_BLEEDING)) + if (spellInfo->SpellFamilyFlags[0] & 0x00800000 && spellInfo->SpellIconID == 1680 && HasAuraState(AURA_STATE_BLEEDING)) { if (AuraEffect const* rendAndTear = caster->GetDummyAuraEffect(SPELLFAMILY_DRUID, 2859, 1)) crit_chance += rendAndTear->GetAmount(); @@ -7388,8 +7297,7 @@ float Unit::SpellCritChanceTaken(Unit const* caster, SpellInfo const* spellInfo, // Kill Command - Improved Kill Command if (spellInfo->SpellFamilyFlags[1] & 0x00000800) if (Player* player = caster->GetSpellModOwner()) - if (AuraEffect const* improvedKillCommand = - player->GetDummyAuraEffect(SPELLFAMILY_HUNTER, 2221, EFFECT_0)) + if (AuraEffect const* improvedKillCommand = player->GetDummyAuraEffect(SPELLFAMILY_HUNTER, 2221, EFFECT_0)) crit_chance += improvedKillCommand->GetAmount(); break; } @@ -7465,9 +7373,7 @@ float Unit::SpellCritChanceTaken(Unit const* caster, SpellInfo const* spellInfo, if (caster) { - crit_mod += - (caster->GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_CRIT_DAMAGE_BONUS, spellProto->GetSchoolMask()) - 1.0f) * - 100; + crit_mod += (caster->GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_CRIT_DAMAGE_BONUS, spellProto->GetSchoolMask()) - 1.0f) * 100; if (crit_bonus != 0) AddPct(crit_bonus, crit_mod); @@ -7498,8 +7404,7 @@ float Unit::SpellCritChanceTaken(Unit const* caster, SpellInfo const* spellInfo, return damage; } -uint32 Unit::SpellHealingBonusDone( - Unit* victim, SpellInfo const* spellProto, uint32 healamount, DamageEffectType damagetype, uint8 effIndex, uint32 stack) const +uint32 Unit::SpellHealingBonusDone(Unit* victim, SpellInfo const* spellProto, uint32 healamount, DamageEffectType damagetype, uint8 effIndex, uint32 stack) const { // For totems get healing bonus from owner (statue isn't totem in fact) if (GetTypeId() == TYPEID_UNIT && IsTotem()) @@ -7547,20 +7452,14 @@ uint32 Unit::SpellHealingBonusDone( coeff = bonus->dot_damage; if (bonus->ap_dot_bonus > 0) DoneTotal += int32( - bonus->ap_dot_bonus * stack * - GetTotalAttackPowerValue( - (spellProto->IsRangedWeaponSpell() && spellProto->DmgClass != SPELL_DAMAGE_CLASS_MELEE) ? RANGED_ATTACK - : BASE_ATTACK)); + bonus->ap_dot_bonus * stack * GetTotalAttackPowerValue((spellProto->IsRangedWeaponSpell() && spellProto->DmgClass != SPELL_DAMAGE_CLASS_MELEE) ? RANGED_ATTACK : BASE_ATTACK)); } else { coeff = bonus->direct_damage; if (bonus->ap_bonus > 0) - DoneTotal += int32( - bonus->ap_bonus * stack * - GetTotalAttackPowerValue( - (spellProto->IsRangedWeaponSpell() && spellProto->DmgClass != SPELL_DAMAGE_CLASS_MELEE) ? RANGED_ATTACK - : BASE_ATTACK)); + DoneTotal += + int32(bonus->ap_bonus * stack * GetTotalAttackPowerValue((spellProto->IsRangedWeaponSpell() && spellProto->DmgClass != SPELL_DAMAGE_CLASS_MELEE) ? RANGED_ATTACK : BASE_ATTACK)); } } else @@ -7574,8 +7473,7 @@ uint32 Unit::SpellHealingBonusDone( if (DoneAdvertisedBenefit) { if (coeff < 0.f) - coeff = CalculateDefaultCoefficient(spellProto, damagetype) * - 1.88f; // As wowwiki says: C = (Cast Time / 3.5) * 1.88 (for healing spells) + coeff = CalculateDefaultCoefficient(spellProto, damagetype) * 1.88f; // As wowwiki says: C = (Cast Time / 3.5) * 1.88 (for healing spells) if (Player* modOwner = GetSpellModOwner()) { @@ -7658,8 +7556,7 @@ float Unit::SpellHealingPctDone(Unit* victim, SpellInfo const* spellProto) const if (aura->GetCasterGUID() != GetGUID()) continue; - if (aura->GetSpellInfo()->SpellFamilyName == SPELLFAMILY_DRUID && - aura->GetSpellInfo()->SpellFamilyFlags.HasFlag(0x10 | 0x40, 0x10 | 0x4000000, 0)) + if (aura->GetSpellInfo()->SpellFamilyName == SPELLFAMILY_DRUID && aura->GetSpellInfo()->SpellFamilyFlags.HasFlag(0x10 | 0x40, 0x10 | 0x4000000, 0)) modPercent += overrideClassScripts->GetAmount() * aura->GetStackAmount(); } AddPct(DoneTotalMod, modPercent); @@ -7686,8 +7583,7 @@ float Unit::SpellHealingPctDone(Unit* victim, SpellInfo const* spellProto) const } float healthPctDiff = 100.f - victim->GetHealthPct(); - for (AuraEffect const* healingDonePctVsTargetHealth : - owner->GetAuraEffectsByType(SPELL_AURA_MOD_HEALING_DONE_PCT_VERSUS_TARGET_HEALTH)) + for (AuraEffect const* healingDonePctVsTargetHealth : owner->GetAuraEffectsByType(SPELL_AURA_MOD_HEALING_DONE_PCT_VERSUS_TARGET_HEALTH)) { if (!healingDonePctVsTargetHealth->IsAffectingSpell(spellProto)) continue; @@ -7698,8 +7594,7 @@ float Unit::SpellHealingPctDone(Unit* victim, SpellInfo const* spellProto) const return DoneTotalMod; } -uint32 Unit::SpellHealingBonusTaken( - Unit* caster, SpellInfo const* spellProto, uint32 healamount, DamageEffectType damagetype, uint32 stack) const +uint32 Unit::SpellHealingBonusTaken(Unit* caster, SpellInfo const* spellProto, uint32 healamount, DamageEffectType damagetype, uint32 stack) const { float TakenTotalMod = 1.0f; @@ -7754,8 +7649,7 @@ uint32 Unit::SpellHealingBonusTaken( if (TakenAdvertisedBenefit) { if (coeff < 0) - coeff = CalculateDefaultCoefficient(spellProto, damagetype) * int32(stack) * - 1.88f; // As wowwiki says: C = (Cast Time / 3.5) * 1.88 (for healing spells) + coeff = CalculateDefaultCoefficient(spellProto, damagetype) * int32(stack) * 1.88f; // As wowwiki says: C = (Cast Time / 3.5) * 1.88 (for healing spells) if (Player* modOwner = GetSpellModOwner()) { @@ -7832,8 +7726,7 @@ int32 Unit::SpellBaseHealingBonusDone(SpellSchoolMask schoolMask, bool withSpell } // ... and attack power - advertisedBenefit += CalculatePct(GetTotalAttackPowerValue(BASE_ATTACK), - GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_SPELL_HEALING_OF_ATTACK_POWER, schoolMask)); + advertisedBenefit += CalculatePct(GetTotalAttackPowerValue(BASE_ATTACK), GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_SPELL_HEALING_OF_ATTACK_POWER, schoolMask)); } return advertisedBenefit; } @@ -7877,8 +7770,7 @@ bool Unit::IsImmunedToDamage(SpellInfo const* spellInfo) const if (spellInfo->HasAttribute(SPELL_ATTR0_NO_IMMUNITIES) && spellInfo->HasAttribute(SPELL_ATTR3_IGNORE_HIT_RESULT)) return false; - if (spellInfo->HasAttribute(SPELL_ATTR1_UNAFFECTED_BY_SCHOOL_IMMUNE) || - spellInfo->HasAttribute(SPELL_ATTR2_UNAFFECTED_BY_AURA_SCHOOL_IMMUNE)) + if (spellInfo->HasAttribute(SPELL_ATTR1_UNAFFECTED_BY_SCHOOL_IMMUNE) || spellInfo->HasAttribute(SPELL_ATTR2_UNAFFECTED_BY_AURA_SCHOOL_IMMUNE)) return false; if (uint32 schoolMask = spellInfo->GetSchoolMask()) @@ -8048,8 +7940,7 @@ bool Unit::IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index, Unit return false; } -uint32 Unit::MeleeDamageBonusDone(Unit* victim, uint32 pdamage, WeaponAttackType attType, - SpellInfo const* spellProto /*= nullptr*/, bool useSpellBonusData /*= true*/) +uint32 Unit::MeleeDamageBonusDone(Unit* victim, uint32 pdamage, WeaponAttackType attType, SpellInfo const* spellProto /*= nullptr*/, bool useSpellBonusData /*= true*/) { if (!victim || pdamage == 0) return 0; @@ -8115,12 +8006,10 @@ uint32 Unit::MeleeDamageBonusDone(Unit* victim, uint32 pdamage, WeaponAttackType { for (uint32 i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i) if (spellProto->GetSchoolMask() & (1 << i)) - maxModDamagePercentSchool = - std::max(maxModDamagePercentSchool, GetFloatValue(PLAYER_FIELD_MOD_DAMAGE_DONE_PCT + i)); + maxModDamagePercentSchool = std::max(maxModDamagePercentSchool, GetFloatValue(PLAYER_FIELD_MOD_DAMAGE_DONE_PCT + i)); } else - maxModDamagePercentSchool = - GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_DAMAGE_PERCENT_DONE, spellProto->GetSchoolMask()); + maxModDamagePercentSchool = GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_DAMAGE_PERCENT_DONE, spellProto->GetSchoolMask()); DoneTotalMod *= maxModDamagePercentSchool; } @@ -8148,8 +8037,7 @@ uint32 Unit::MeleeDamageBonusDone(Unit* victim, uint32 pdamage, WeaponAttackType // Add SPELL_AURA_MOD_MELEE_DAMAGE_FROM_CASTER percent bonus // This aura name is a bit misleading but it's actually only suposed to increase melee auto attack damage - AddPct(DoneTotalMod, victim->GetTotalAuraMultiplier(SPELL_AURA_MOD_MELEE_DAMAGE_FROM_CASTER, - [this](AuraEffect const* effect) -> bool { return effect->GetCasterGUID() == GetGUID(); })); + AddPct(DoneTotalMod, victim->GetTotalAuraMultiplier(SPELL_AURA_MOD_MELEE_DAMAGE_FROM_CASTER, [this](AuraEffect const* effect) -> bool { return effect->GetCasterGUID() == GetGUID(); })); } // done scripted mod (take it from owner) @@ -8223,8 +8111,7 @@ uint32 Unit::MeleeDamageBonusTaken(Unit* attacker, uint32 pdamage, WeaponAttackT TakenTotalMod *= GetTotalAuraMultiplier(SPELL_AURA_MOD_DAMAGE_FROM_CASTER, [attacker, spellProto](AuraEffect const* aurEff) -> bool { - if (spellProto && spellProto->HasAttribute(SPELL_ATTR10_IGNORE_POSITIVE_DAMAGE_TAKEN_MODS) && - aurEff->GetAmount() > 0) + if (spellProto && spellProto->HasAttribute(SPELL_ATTR10_IGNORE_POSITIVE_DAMAGE_TAKEN_MODS) && aurEff->GetAmount() > 0) return false; if (aurEff->GetCasterGUID() == attacker->GetGUID() && aurEff->IsAffectingSpell(spellProto)) @@ -8244,8 +8131,7 @@ uint32 Unit::MeleeDamageBonusTaken(Unit* attacker, uint32 pdamage, WeaponAttackT TakenTotalMod *= GetTotalAuraMultiplier(SPELL_AURA_MOD_MECHANIC_DAMAGE_TAKEN_PERCENT, [mechanicMask, spellProto](AuraEffect const* aurEff) -> bool { - if (spellProto && spellProto->HasAttribute(SPELL_ATTR10_IGNORE_POSITIVE_DAMAGE_TAKEN_MODS) && - aurEff->GetAmount() > 0) + if (spellProto && spellProto->HasAttribute(SPELL_ATTR10_IGNORE_POSITIVE_DAMAGE_TAKEN_MODS) && aurEff->GetAmount() > 0) return false; if (mechanicMask & uint32(1 << (aurEff->GetMiscValue()))) @@ -8433,8 +8319,7 @@ void Unit::Dismount() // if we have charmed npc, remove stun also if (Unit* charm = player->GetCharmed()) - if (charm->GetTypeId() == TYPEID_UNIT && charm->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED) && - !charm->HasUnitState(UNIT_STATE_STUNNED)) + if (charm->GetTypeId() == TYPEID_UNIT && charm->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED) && !charm->HasUnitState(UNIT_STATE_STUNNED)) charm->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED); } } @@ -8499,12 +8384,10 @@ MountCapabilityEntry const* Unit::GetMountCapability(uint32 mountType) const continue; // Do not allow liquid restricted mounts on ground or in air - if (!(mountCapability->Flags & (MOUNT_CAPABILITY_FLAG_GROUND | MOUNT_CAPABILITY_FLAG_FLYING)) && !isUnderwater && - !isInWater) + if (!(mountCapability->Flags & (MOUNT_CAPABILITY_FLAG_GROUND | MOUNT_CAPABILITY_FLAG_FLYING)) && !isUnderwater && !isInWater) continue; - if (mountCapability->ReqMapID != -1 && int32(GetMapId()) != mountCapability->ReqMapID && - GetMap()->GetEntry()->ParentMapID != mountCapability->ReqMapID) + if (mountCapability->ReqMapID != -1 && int32(GetMapId()) != mountCapability->ReqMapID && GetMap()->GetEntry()->ParentMapID != mountCapability->ReqMapID) continue; if (mountCapability->ReqAreaID && !DBCManager::IsInArea(areaId, mountCapability->ReqAreaID)) @@ -8530,8 +8413,7 @@ void Unit::UpdateMountCapability() aurEff->RecalculateAmount(); if (!aurEff->GetAmount()) aurEff->GetBase()->Remove(); - else if (MountCapabilityEntry const* capability = - sMountCapabilityStore.LookupEntry(aurEff->GetAmount())) // aura may get removed by interrupt flag, reapply + else if (MountCapabilityEntry const* capability = sMountCapabilityStore.LookupEntry(aurEff->GetAmount())) // aura may get removed by interrupt flag, reapply if (!HasAura(capability->ModSpellAuraID)) CastSpell(this, capability->ModSpellAuraID, aurEff); } @@ -8539,10 +8421,8 @@ void Unit::UpdateMountCapability() bool Unit::IsServiceProvider() const { - return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_VENDOR | UNIT_NPC_FLAG_TRAINER | UNIT_NPC_FLAG_FLIGHTMASTER | - UNIT_NPC_FLAG_PETITIONER | UNIT_NPC_FLAG_BATTLEMASTER | UNIT_NPC_FLAG_BANKER | - UNIT_NPC_FLAG_INNKEEPER | UNIT_NPC_FLAG_SPIRITHEALER | UNIT_NPC_FLAG_SPIRITGUIDE | - UNIT_NPC_FLAG_TABARDDESIGNER | UNIT_NPC_FLAG_AUCTIONEER); + return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_VENDOR | UNIT_NPC_FLAG_TRAINER | UNIT_NPC_FLAG_FLIGHTMASTER | UNIT_NPC_FLAG_PETITIONER | UNIT_NPC_FLAG_BATTLEMASTER | UNIT_NPC_FLAG_BANKER | + UNIT_NPC_FLAG_INNKEEPER | UNIT_NPC_FLAG_SPIRITHEALER | UNIT_NPC_FLAG_SPIRITGUIDE | UNIT_NPC_FLAG_TABARDDESIGNER | UNIT_NPC_FLAG_AUCTIONEER); } void Unit::EngageWithTarget(Unit* enemy) @@ -8615,7 +8495,10 @@ void Unit::SetImmuneToNPC(bool apply, bool keepCombat) RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC); } -bool Unit::IsThreatened() const { return !m_threatManager.IsThreatListEmpty(); } +bool Unit::IsThreatened() const +{ + return !m_threatManager.IsThreatListEmpty(); +} bool Unit::isTargetableForAttack(bool checkFakeDeath) const { @@ -8631,7 +8514,10 @@ bool Unit::isTargetableForAttack(bool checkFakeDeath) const return !HasUnitState(UNIT_STATE_UNATTACKABLE) && (!checkFakeDeath || !HasUnitState(UNIT_STATE_DIED)); } -bool Unit::IsValidAttackTarget(Unit const* target) const { return _IsValidAttackTarget(target, nullptr); } +bool Unit::IsValidAttackTarget(Unit const* target) const +{ + return _IsValidAttackTarget(target, nullptr); +} // function based on function Unit::CanAttack from 13850 client bool Unit::_IsValidAttackTarget(Unit const* target, SpellInfo const* bySpell, WorldObject const* obj) const @@ -8643,8 +8529,7 @@ bool Unit::_IsValidAttackTarget(Unit const* target, SpellInfo const* bySpell, Wo return false; // can't attack unattackable units or GMs - if (target->HasUnitState(UNIT_STATE_UNATTACKABLE) || - (target->GetTypeId() == TYPEID_PLAYER && target->ToPlayer()->IsGameMaster())) + if (target->HasUnitState(UNIT_STATE_UNATTACKABLE) || (target->GetTypeId() == TYPEID_PLAYER && target->ToPlayer()->IsGameMaster())) return false; // visibility checks @@ -8659,9 +8544,7 @@ bool Unit::_IsValidAttackTarget(Unit const* target, SpellInfo const* bySpell, Wo else if (!obj) { // ignore stealth for aoe spells. Ignore stealth if target is player and unit in combat with same player - bool const ignoreStealthCheck = - (bySpell && bySpell->IsAffectingArea()) || - (target->GetTypeId() == TYPEID_PLAYER && target->HasStealthAura() && IsInCombatWith(target)); + bool const ignoreStealthCheck = (bySpell && bySpell->IsAffectingArea()) || (target->GetTypeId() == TYPEID_PLAYER && target->HasStealthAura() && IsInCombatWith(target)); if (!CanSeeOrDetect(target, ignoreStealthCheck)) return false; @@ -8674,8 +8557,7 @@ bool Unit::_IsValidAttackTarget(Unit const* target, SpellInfo const* bySpell, Wo return false; // can't attack untargetable - if ((!bySpell || !bySpell->HasAttribute(SPELL_ATTR6_CAN_TARGET_UNTARGETABLE)) && - target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE)) + if ((!bySpell || !bySpell->HasAttribute(SPELL_ATTR6_CAN_TARGET_UNTARGETABLE)) && target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE)) return false; if (Player const* playerAttacker = ToPlayer()) @@ -8685,10 +8567,8 @@ bool Unit::_IsValidAttackTarget(Unit const* target, SpellInfo const* bySpell, Wo } // check flags - if (target->HasFlag(UNIT_FIELD_FLAGS, - UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_TAXI_FLIGHT | UNIT_FLAG_NOT_ATTACKABLE_1 | UNIT_FLAG_NOT_ATTACKABLE_2) || - (!HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED) && target->IsImmuneToNPC()) || - (!target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED) && IsImmuneToNPC())) + if (target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_TAXI_FLIGHT | UNIT_FLAG_NOT_ATTACKABLE_1 | UNIT_FLAG_NOT_ATTACKABLE_2) || + (!HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED) && target->IsImmuneToNPC()) || (!target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED) && IsImmuneToNPC())) return false; if ((!bySpell || !bySpell->HasAttribute(SPELL_ATTR8_ATTACK_IGNORE_IMMUNE_TO_PC_FLAG)) && @@ -8699,8 +8579,7 @@ bool Unit::_IsValidAttackTarget(Unit const* target, SpellInfo const* bySpell, Wo return false; // CvC case - can attack each other only when one of them is hostile - if (!HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED) && - !target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED)) + if (!HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED) && !target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED)) return GetReactionTo(target) <= REP_HOSTILE || target->GetReactionTo(this) <= REP_HOSTILE; // PvP, PvC, CvP case @@ -8708,10 +8587,8 @@ bool Unit::_IsValidAttackTarget(Unit const* target, SpellInfo const* bySpell, Wo if (GetReactionTo(target) > REP_NEUTRAL || target->GetReactionTo(this) > REP_NEUTRAL) return false; - Player const* playerAffectingAttacker = - HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED) ? GetAffectingPlayer() : nullptr; - Player const* playerAffectingTarget = - target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED) ? target->GetAffectingPlayer() : nullptr; + Player const* playerAffectingAttacker = HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED) ? GetAffectingPlayer() : nullptr; + Player const* playerAffectingTarget = target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED) ? target->GetAffectingPlayer() : nullptr; // Not all neutral creatures can be attacked (even some unfriendly faction does not react aggresive to you, like Sporaggar) if ((playerAffectingAttacker && !playerAffectingTarget) || (!playerAffectingAttacker && playerAffectingTarget)) @@ -8738,14 +8615,12 @@ bool Unit::_IsValidAttackTarget(Unit const* target, SpellInfo const* bySpell, Wo // check duel - before sanctuary checks if (playerAffectingAttacker && playerAffectingTarget) - if (playerAffectingAttacker->duel && playerAffectingAttacker->duel->opponent == playerAffectingTarget && - playerAffectingAttacker->duel->startTime != 0) + if (playerAffectingAttacker->duel && playerAffectingAttacker->duel->opponent == playerAffectingTarget && playerAffectingAttacker->duel->startTime != 0) return true; // PvP case - can't attack when attacker or target are in sanctuary // however, 13850 client doesn't allow to attack when one of the unit's has sanctuary flag and is pvp - if (target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED) && - HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED) && + if (target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED) && HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED) && ((target->GetByteValue(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG) & UNIT_BYTE2_FLAG_SANCTUARY) || (GetByteValue(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG) & UNIT_BYTE2_FLAG_SANCTUARY))) return false; @@ -8759,13 +8634,15 @@ bool Unit::_IsValidAttackTarget(Unit const* target, SpellInfo const* bySpell, Wo if (IsFFAPvP() && target->IsFFAPvP()) return true; - return HasByteFlag(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG, UNIT_BYTE2_FLAG_UNK1) || - target->HasByteFlag(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG, UNIT_BYTE2_FLAG_UNK1); + return HasByteFlag(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG, UNIT_BYTE2_FLAG_UNK1) || target->HasByteFlag(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG, UNIT_BYTE2_FLAG_UNK1); } return true; } -bool Unit::IsValidAssistTarget(Unit const* target) const { return _IsValidAssistTarget(target, nullptr); } +bool Unit::IsValidAssistTarget(Unit const* target) const +{ + return _IsValidAssistTarget(target, nullptr); +} // function based on function Unit::CanAssist from 13850 client bool Unit::_IsValidAssistTarget(Unit const* target, SpellInfo const* bySpell) const @@ -8777,8 +8654,7 @@ bool Unit::_IsValidAssistTarget(Unit const* target, SpellInfo const* bySpell) co return true; // can't assist unattackable units or GMs - if (target->HasUnitState(UNIT_STATE_UNATTACKABLE) || - (target->GetTypeId() == TYPEID_PLAYER && target->ToPlayer()->IsGameMaster())) + if (target->HasUnitState(UNIT_STATE_UNATTACKABLE) || (target->GetTypeId() == TYPEID_PLAYER && target->ToPlayer()->IsGameMaster())) return false; // can't assist own vehicle or passenger @@ -8787,8 +8663,7 @@ bool Unit::_IsValidAssistTarget(Unit const* target, SpellInfo const* bySpell) co return false; // can't assist invisible - if ((!bySpell || !bySpell->HasAttribute(SPELL_ATTR6_CAN_TARGET_INVISIBLE)) && - !CanSeeOrDetect(target, bySpell && bySpell->IsAffectingArea())) + if ((!bySpell || !bySpell->HasAttribute(SPELL_ATTR6_CAN_TARGET_INVISIBLE)) && !CanSeeOrDetect(target, bySpell && bySpell->IsAffectingArea())) return false; // can't assist dead @@ -8796,8 +8671,7 @@ bool Unit::_IsValidAssistTarget(Unit const* target, SpellInfo const* bySpell) co return false; // can't assist untargetable - if ((!bySpell || !bySpell->HasAttribute(SPELL_ATTR6_CAN_TARGET_UNTARGETABLE)) && - target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE)) + if ((!bySpell || !bySpell->HasAttribute(SPELL_ATTR6_CAN_TARGET_UNTARGETABLE)) && target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE)) return false; if (!bySpell || !bySpell->HasAttribute(SPELL_ATTR6_ASSIST_IGNORE_IMMUNE_FLAG)) @@ -8842,20 +8716,17 @@ bool Unit::_IsValidAssistTarget(Unit const* target, SpellInfo const* bySpell) co return false; // can't assist player out of sanctuary from sanctuary if has pvp enabled if (target->GetByteValue(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG) & UNIT_BYTE2_FLAG_PVP) - if ((GetByteValue(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG) & UNIT_BYTE2_FLAG_SANCTUARY) && - !(target->GetByteValue(UNIT_FIELD_BYTES_2, 1) & UNIT_BYTE2_FLAG_SANCTUARY)) + if ((GetByteValue(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG) & UNIT_BYTE2_FLAG_SANCTUARY) && !(target->GetByteValue(UNIT_FIELD_BYTES_2, 1) & UNIT_BYTE2_FLAG_SANCTUARY)) return false; } } // PvC case - player can assist creature only if has specific type flags // !target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE) && - else if (HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED) && - (!bySpell || !bySpell->HasAttribute(SPELL_ATTR6_ASSIST_IGNORE_IMMUNE_FLAG)) && + else if (HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED) && (!bySpell || !bySpell->HasAttribute(SPELL_ATTR6_ASSIST_IGNORE_IMMUNE_FLAG)) && !((target->GetByteValue(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG) & UNIT_BYTE2_FLAG_PVP))) { if (Creature const* creatureTarget = target->ToCreature()) - return creatureTarget->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_TREAT_AS_RAID_UNIT || - creatureTarget->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_CAN_ASSIST; + return creatureTarget->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_TREAT_AS_RAID_UNIT || creatureTarget->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_CAN_ASSIST; } return true; } @@ -8993,8 +8864,7 @@ float Unit::GetPowerRegen(Powers powerType, bool isInCombat) const powerSlot = GetPowerIndex(powerType); if (powerSlot != MAX_POWERS) { - uint32 powerRegenIndex = - isInCombat ? UNIT_FIELD_POWER_REGEN_INTERRUPTED_FLAT_MODIFIER : UNIT_FIELD_POWER_REGEN_FLAT_MODIFIER; + uint32 powerRegenIndex = isInCombat ? UNIT_FIELD_POWER_REGEN_INTERRUPTED_FLAT_MODIFIER : UNIT_FIELD_POWER_REGEN_FLAT_MODIFIER; totalRegeneration = GetFloatValue(powerRegenIndex + powerSlot) + combatRegeneration; result = totalRegeneration; } @@ -9047,7 +8917,10 @@ bool Unit::IsAlwaysDetectableFor(WorldObject const* seer) const return false; } -bool Unit::IsVisible() const { return (m_serverSideVisibility.GetValue(SERVERSIDE_VISIBILITY_GM) > SEC_PLAYER) ? false : true; } +bool Unit::IsVisible() const +{ + return (m_serverSideVisibility.GetValue(SERVERSIDE_VISIBILITY_GM) > SEC_PLAYER) ? false : true; +} void Unit::SetVisible(bool x) { @@ -9116,8 +8989,7 @@ void Unit::UpdateSpeed(UnitMoveType mtype) stack_bonus = GetTotalAuraMultiplier(SPELL_AURA_MOD_MOUNTED_FLIGHT_SPEED_ALWAYS); } else // Use not mount (shapeshift for example) auras (should stack) - main_speed_mod = GetTotalAuraModifier(SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED) + - GetTotalAuraModifier(SPELL_AURA_MOD_INCREASE_VEHICLE_FLIGHT_SPEED); + main_speed_mod = GetTotalAuraModifier(SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED) + GetTotalAuraModifier(SPELL_AURA_MOD_INCREASE_VEHICLE_FLIGHT_SPEED); non_stack_bonus += GetMaxPositiveAuraModifier(SPELL_AURA_MOD_FLIGHT_SPEED_NOT_STACK) / 100.0f; @@ -9146,9 +9018,8 @@ void Unit::UpdateSpeed(UnitMoveType mtype) if (IsCreature()) { CreatureMovementInfo const& movementInfo = ToCreature()->GetCreatureMovementInfo(); - speed *= movementInfo.HasRunSpeedOverriden - ? (movementInfo.RunSpeed / baseMoveSpeed[MOVE_RUN]) - : ToCreature()->GetCreatureTemplate()->speed_run; // at this point, MOVE_WALK is never reached + speed *= + movementInfo.HasRunSpeedOverriden ? (movementInfo.RunSpeed / baseMoveSpeed[MOVE_RUN]) : ToCreature()->GetCreatureTemplate()->speed_run; // at this point, MOVE_WALK is never reached } // Normalize speed by 191 aura SPELL_AURA_USE_NORMAL_MOVEMENT_SPEED if need @@ -9184,8 +9055,7 @@ void Unit::UpdateSpeed(UnitMoveType mtype) if (!GetOwnerOrCreatorGUID().IsPlayer() && !IsHunterPet() && IsCreature()) { CreatureMovementInfo const& movementInfo = ToCreature()->GetCreatureMovementInfo(); - baseMinSpeed = movementInfo.HasRunSpeedOverriden ? (movementInfo.RunSpeed / baseMoveSpeed[MOVE_RUN]) - : ToCreature()->GetCreatureTemplate()->speed_run; + baseMinSpeed = movementInfo.HasRunSpeedOverriden ? (movementInfo.RunSpeed / baseMoveSpeed[MOVE_RUN]) : ToCreature()->GetCreatureTemplate()->speed_run; } float min_speed = CalculatePct(baseMinSpeed, minSpeedMod); @@ -9255,8 +9125,7 @@ void Unit::FollowTarget(Unit* target) { if (!target) { - LOG_ERROR("entities.unit", "Unit::FollowTarget: Unit (%s) tried to follow a non-existant target.", - GetGUID().ToString().c_str()); + LOG_ERROR("entities.unit", "Unit::FollowTarget: Unit (%s) tried to follow a non-existant target.", GetGUID().ToString().c_str()); return; } @@ -9399,17 +9268,18 @@ void Unit::setDeathState(DeathState s) void Unit::AtEnterCombat() { if (Spell* spell = m_currentSpells[CURRENT_GENERIC_SPELL]) - if (spell->getState() == SPELL_STATE_PREPARING && - spell->m_spellInfo->HasAttribute(SPELL_ATTR0_NOT_IN_COMBAT_ONLY_PEACEFUL) && + if (spell->getState() == SPELL_STATE_PREPARING && spell->m_spellInfo->HasAttribute(SPELL_ATTR0_NOT_IN_COMBAT_ONLY_PEACEFUL) && spell->m_spellInfo->InterruptFlags.HasFlag(SpellInterruptFlags::Combat)) InterruptNonMeleeSpells(false); RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags::EnteringCombat); - ProcSkillsAndAuras(nullptr, PROC_FLAG_ENTER_COMBAT, PROC_FLAG_NONE, PROC_SPELL_TYPE_MASK_ALL, PROC_SPELL_PHASE_NONE, - PROC_HIT_NONE, nullptr, nullptr, nullptr); + Unit::ProcSkillsAndAuras(this, nullptr, PROC_FLAG_ENTER_COMBAT, PROC_FLAG_NONE, PROC_SPELL_TYPE_MASK_ALL, PROC_SPELL_PHASE_NONE, PROC_HIT_NONE, nullptr, nullptr, nullptr); } -void Unit::AtExitCombat() { RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags::LeavingCombat); } +void Unit::AtExitCombat() +{ + RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags::LeavingCombat); +} void Unit::AtTargetAttacked(Unit* target, bool canInitialAggro) { @@ -9478,8 +9348,7 @@ float Unit::ApplyEffectModifiers(SpellInfo const* spellProto, uint8 effect_index } // function uses real base points (typically value - 1) -int32 Unit::CalculateSpellDamage( - Unit const* target, SpellInfo const* spellProto, uint8 effect_index, int32 const* basePoints) const +int32 Unit::CalculateSpellDamage(Unit const* target, SpellInfo const* spellProto, uint8 effect_index, int32 const* basePoints) const { return spellProto->Effects[effect_index].CalcValue(this, basePoints, target); } @@ -9510,8 +9379,7 @@ int32 Unit::ModSpellDuration(SpellInfo const* spellProto, Unit const* target, in // Find total mod value (negative bonus) int32 new_durationMod_always = target->GetTotalAuraModifierByMiscValue(SPELL_AURA_MECHANIC_DURATION_MOD, i); // Find max mod (negative bonus) - int32 new_durationMod_not_stack = - target->GetMaxNegativeAuraModifierByMiscValue(SPELL_AURA_MECHANIC_DURATION_MOD_NOT_STACK, i); + int32 new_durationMod_not_stack = target->GetMaxNegativeAuraModifierByMiscValue(SPELL_AURA_MECHANIC_DURATION_MOD_NOT_STACK, i); // Check if mods applied before were weaker if (new_durationMod_always < durationMod_always) durationMod_always = new_durationMod_always; @@ -9530,8 +9398,7 @@ int32 Unit::ModSpellDuration(SpellInfo const* spellProto, Unit const* target, in // there are only negative mods currently durationMod_always = target->GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_AURA_DURATION_BY_DISPEL, spellProto->Dispel); - durationMod_not_stack = - target->GetMaxNegativeAuraModifierByMiscValue(SPELL_AURA_MOD_AURA_DURATION_BY_DISPEL_NOT_STACK, spellProto->Dispel); + durationMod_not_stack = target->GetMaxNegativeAuraModifierByMiscValue(SPELL_AURA_MOD_AURA_DURATION_BY_DISPEL_NOT_STACK, spellProto->Dispel); durationMod = 0; if (durationMod_always > durationMod_not_stack) @@ -9551,8 +9418,7 @@ int32 Unit::ModSpellDuration(SpellInfo const* spellProto, Unit const* target, in if (target->GetTypeId() == TYPEID_PLAYER) { if (spellProto->SpellFamilyName == SPELLFAMILY_POTION && - (sSpellMgr->IsSpellMemberOfSpellGroup(spellProto->Id, SPELL_GROUP_ELIXIR_BATTLE) || - sSpellMgr->IsSpellMemberOfSpellGroup(spellProto->Id, SPELL_GROUP_ELIXIR_GUARDIAN))) + (sSpellMgr->IsSpellMemberOfSpellGroup(spellProto->Id, SPELL_GROUP_ELIXIR_BATTLE) || sSpellMgr->IsSpellMemberOfSpellGroup(spellProto->Id, SPELL_GROUP_ELIXIR_GUARDIAN))) { if (target->HasAura(53042) && target->HasSpell(spellProto->Effects[0].TriggerSpell)) duration *= 2; @@ -9590,8 +9456,7 @@ void Unit::ModSpellCastTime(SpellInfo const* spellInfo, int32& castTime, Spell* float castSpeedMod = 1; castSpeedMod = castSpeedMod - GetTotalAuraMultiplier(SPELL_AURA_HASTE_SPELLS) + 1.0f; - if (!(spellInfo->HasAttribute(SPELL_ATTR0_IS_ABILITY) || spellInfo->HasAttribute(SPELL_ATTR0_IS_TRADESKILL) || - spellInfo->HasAttribute(SPELL_ATTR3_NO_DONE_BONUS)) && + if (!(spellInfo->HasAttribute(SPELL_ATTR0_IS_ABILITY) || spellInfo->HasAttribute(SPELL_ATTR0_IS_TRADESKILL) || spellInfo->HasAttribute(SPELL_ATTR3_NO_DONE_BONUS)) && ((GetTypeId() == TYPEID_PLAYER && spellInfo->SpellFamilyName) || GetTypeId() == TYPEID_UNIT)) castTime = int32(float(castTime) * GetFloatValue(UNIT_MOD_CAST_SPEED)); else if (spellInfo->HasAttribute(SPELL_ATTR0_USES_RANGED_SLOT) && !spellInfo->HasAttribute(SPELL_ATTR2_AUTOREPEAT_FLAG)) @@ -9612,8 +9477,7 @@ void Unit::ModSpellDurationTime(SpellInfo const* spellInfo, int32& duration, Spe if (Player* modOwner = GetSpellModOwner()) modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_CASTING_TIME, duration, spell); - if (!(spellInfo->HasAttribute(SPELL_ATTR0_IS_ABILITY) || spellInfo->HasAttribute(SPELL_ATTR0_IS_TRADESKILL) || - spellInfo->HasAttribute(SPELL_ATTR3_NO_DONE_BONUS)) && + if (!(spellInfo->HasAttribute(SPELL_ATTR0_IS_ABILITY) || spellInfo->HasAttribute(SPELL_ATTR0_IS_TRADESKILL) || spellInfo->HasAttribute(SPELL_ATTR3_NO_DONE_BONUS)) && ((GetTypeId() == TYPEID_PLAYER && spellInfo->SpellFamilyName) || GetTypeId() == TYPEID_UNIT)) duration = int32(float(duration) * GetFloatValue(UNIT_MOD_CAST_SPEED)); else if (spellInfo->HasAttribute(SPELL_ATTR0_USES_RANGED_SLOT) && !spellInfo->HasAttribute(SPELL_ATTR2_AUTOREPEAT_FLAG)) @@ -9644,8 +9508,7 @@ void Unit::IncrDiminishing(SpellInfo const* auraSpellInfo, bool triggered) diminish.hitCount = currentLevel + 1; } -bool Unit::ApplyDiminishingToDuration( - SpellInfo const* auraSpellInfo, bool triggered, int32& duration, Unit* caster, DiminishingLevels previousLevel) const +bool Unit::ApplyDiminishingToDuration(SpellInfo const* auraSpellInfo, bool triggered, int32& duration, Unit* caster, DiminishingLevels previousLevel) const { DiminishingGroup const group = auraSpellInfo->GetDiminishingReturnsGroupForSpell(triggered); if (duration == -1 || group == DIMINISHING_NONE) @@ -9696,8 +9559,7 @@ bool Unit::ApplyDiminishingToDuration( } // Some diminishings applies to mobs too (for example, Stun) else if (auraSpellInfo->GetDiminishingReturnsGroupType(triggered) == DRTYPE_ALL || - (auraSpellInfo->GetDiminishingReturnsGroupType(triggered) == DRTYPE_PLAYER && - (targetOwner ? targetOwner->IsAffectedByDiminishingReturns() : IsAffectedByDiminishingReturns()))) + (auraSpellInfo->GetDiminishingReturnsGroupType(triggered) == DRTYPE_PLAYER && (targetOwner ? targetOwner->IsAffectedByDiminishingReturns() : IsAffectedByDiminishingReturns()))) { DiminishingLevels diminish = previousLevel; switch (diminish) @@ -9788,7 +9650,10 @@ uint32 Unit::GetCreatureTypeMask() const return (creatureType >= 1) ? (1 << (creatureType - 1)) : 0; } -void Unit::SetShapeshiftForm(ShapeshiftForm form) { SetByteValue(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_SHAPESHIFT_FORM, form); } +void Unit::SetShapeshiftForm(ShapeshiftForm form) +{ + SetByteValue(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_SHAPESHIFT_FORM, form); +} bool Unit::IsInFeralForm() const { @@ -9815,8 +9680,7 @@ bool Unit::IsInDisallowedMountForm() const if (!display) return true; - CreatureDisplayInfoExtraEntry const* displayExtra = - sCreatureDisplayInfoExtraStore.LookupEntry(display->ExtendedDisplayInfoID); + CreatureDisplayInfoExtraEntry const* displayExtra = sCreatureDisplayInfoExtraStore.LookupEntry(display->ExtendedDisplayInfoID); if (!displayExtra) return true; @@ -10051,8 +9915,7 @@ void Unit::UpdateDamagePctDoneMods(WeaponAttackType attackType) }); if (attackType == OFF_ATTACK) - factor *= GetTotalAuraMultiplier(SPELL_AURA_MOD_OFFHAND_DAMAGE_PCT, - std::bind(&Unit::CheckAttackFitToAuraRequirement, this, attackType, std::placeholders::_1)); + factor *= GetTotalAuraMultiplier(SPELL_AURA_MOD_OFFHAND_DAMAGE_PCT, std::bind(&Unit::CheckAttackFitToAuraRequirement, this, attackType, std::placeholders::_1)); SetStatPctModifier(unitMod, TOTAL_PCT, factor); } @@ -10177,8 +10040,7 @@ float Unit::GetTotalAttackPowerValue(WeaponAttackType attType) const { if (attType == RANGED_ATTACK) { - int32 ap = GetInt32Value(UNIT_FIELD_RANGED_ATTACK_POWER) + GetInt32Value(UNIT_FIELD_RANGED_ATTACK_POWER_MOD_POS) - - GetInt32Value(UNIT_FIELD_RANGED_ATTACK_POWER_MOD_NEG); + int32 ap = GetInt32Value(UNIT_FIELD_RANGED_ATTACK_POWER) + GetInt32Value(UNIT_FIELD_RANGED_ATTACK_POWER_MOD_POS) - GetInt32Value(UNIT_FIELD_RANGED_ATTACK_POWER_MOD_NEG); if (ap < 0) return 0.0f; @@ -10186,8 +10048,7 @@ float Unit::GetTotalAttackPowerValue(WeaponAttackType attType) const } else { - int32 ap = GetInt32Value(UNIT_FIELD_ATTACK_POWER) + GetInt32Value(UNIT_FIELD_ATTACK_POWER_MOD_POS) - - GetInt32Value(UNIT_FIELD_ATTACK_POWER_MOD_NEG); + int32 ap = GetInt32Value(UNIT_FIELD_ATTACK_POWER) + GetInt32Value(UNIT_FIELD_ATTACK_POWER_MOD_POS) - GetInt32Value(UNIT_FIELD_ATTACK_POWER_MOD_NEG); if (ap < 0) return 0.0f; @@ -10205,9 +10066,7 @@ float Unit::GetWeaponDamageRange(WeaponAttackType attType, WeaponDamageRange typ bool Unit::CanFreeMove() const { - return !HasUnitState(UNIT_STATE_CONFUSED | UNIT_STATE_FLEEING | UNIT_STATE_IN_FLIGHT | UNIT_STATE_ROOT | UNIT_STATE_STUNNED | - UNIT_STATE_DISTRACTED) && - GetOwnerOrCreatorGUID().IsEmpty(); + return !HasUnitState(UNIT_STATE_CONFUSED | UNIT_STATE_FLEEING | UNIT_STATE_IN_FLIGHT | UNIT_STATE_ROOT | UNIT_STATE_STUNNED | UNIT_STATE_DISTRACTED) && GetOwnerOrCreatorGUID().IsEmpty(); } void Unit::SetLevel(uint8 lvl) @@ -10379,10 +10238,7 @@ int32 Unit::GetCreatePowers(Powers power) const case POWER_FOCUS: if (GetTypeId() == TYPEID_PLAYER && getClass() == CLASS_HUNTER) return 100; - return ( - GetTypeId() == TYPEID_PLAYER || !((Creature const*)this)->IsPet() || ((Pet const*)this)->getPetType() != HUNTER_PET - ? 0 - : 100); + return (GetTypeId() == TYPEID_PLAYER || !((Creature const*)this)->IsPet() || ((Pet const*)this)->getPetType() != HUNTER_PET ? 0 : 100); case POWER_ENERGY: return 100; case POWER_RUNIC_POWER: @@ -10507,7 +10363,10 @@ void Unit::AIUpdateTick(uint32 diff) } } -void Unit::PushAI(UnitAI* newAI) { i_AIs.emplace(newAI); } +void Unit::PushAI(UnitAI* newAI) +{ + i_AIs.emplace(newAI); +} void Unit::SetAI(UnitAI* newAI) { @@ -10622,8 +10481,7 @@ void Unit::RemoveFromWorld() { if (owner->m_Controlled.find(this) != owner->m_Controlled.end()) { - LOG_FATAL("entities.unit", "Unit %u is in controlled list of %u when removed from world", GetEntry(), - owner->GetEntry()); + LOG_FATAL("entities.unit", "Unit %u is in controlled list of %u when removed from world", GetEntry(), owner->GetEntry()); ABORT(); } } @@ -10680,8 +10538,7 @@ void Unit::UpdateCharmAI() newAI = charmerAI->GetAIForCharmedPlayer(ToPlayer()); } else - LOG_ERROR("misc", "Attempt to assign charm AI to player %s who is charmed by non-creature %s.", - GetGUID().ToString().c_str(), GetCharmerGUID().ToString().c_str()); + LOG_ERROR("misc", "Attempt to assign charm AI to player %s who is charmed by non-creature %s.", GetGUID().ToString().c_str(), GetCharmerGUID().ToString().c_str()); } if (!newAI) // otherwise, we default to the generic one newAI = new SimpleCharmedPlayerAI(ToPlayer()); @@ -10728,9 +10585,8 @@ void Unit::DeleteCharmInfo() } CharmInfo::CharmInfo(Unit* unit) - : _unit(unit), _CommandState(COMMAND_FOLLOW), _petnumber(0), _oldReactState(REACT_PASSIVE), _isCommandAttack(false), - _isCommandFollow(false), _isAtStay(false), _isFollowing(false), _isReturning(false), _stayX(0.0f), _stayY(0.0f), - _stayZ(0.0f) + : _unit(unit), _CommandState(COMMAND_FOLLOW), _petnumber(0), _oldReactState(REACT_PASSIVE), _isCommandAttack(false), _isCommandFollow(false), _isAtStay(false), _isFollowing(false), + _isReturning(false), _stayX(0.0f), _stayY(0.0f), _stayZ(0.0f) { for (uint8 i = 0; i < MAX_SPELL_CHARM; ++i) _charmspells[i].SetActionAndType(0, ACT_DISABLED); @@ -10742,7 +10598,9 @@ CharmInfo::CharmInfo(Unit* unit) } } -CharmInfo::~CharmInfo() {} +CharmInfo::~CharmInfo() +{ +} void CharmInfo::RestoreState() { @@ -10888,8 +10746,7 @@ bool CharmInfo::AddSpellToActionBar(SpellInfo const* spellInfo, ActiveStates new uint8 j = (preferredSlot + i) % MAX_UNIT_ACTION_BAR_INDEX; if (!PetActionBar[j].GetAction() && PetActionBar[j].IsActionBarForSpell()) { - SetActionBar( - j, spell_id, newstate == ACT_DECIDE ? spellInfo->IsAutocastable() ? ACT_ENABLED : ACT_PASSIVE : newstate); + SetActionBar(j, spell_id, newstate == ACT_DECIDE ? spellInfo->IsAutocastable() ? ACT_ENABLED : ACT_PASSIVE : newstate); return true; } } @@ -10984,7 +10841,10 @@ void CharmInfo::SetSpellAutocast(SpellInfo const* spellInfo, bool state) } } -bool Unit::isFrozen() const { return HasAuraState(AURA_STATE_FROZEN); } +bool Unit::isFrozen() const +{ + return HasAuraState(AURA_STATE_FROZEN); +} uint32 createProcHitMask(SpellNonMeleeDamage* damageInfo, SpellMissInfo missCondition) { @@ -11044,8 +10904,7 @@ uint32 createProcHitMask(SpellNonMeleeDamage* damageInfo, SpellMissInfo missCond hitMask |= PROC_HIT_ABSORB; // Don't set hit/crit hitMask if damage is nullified - bool const damageNullified = - (damageInfo->HitInfo & (HITINFO_FULL_ABSORB | HITINFO_FULL_RESIST)) != 0 || (hitMask & PROC_HIT_FULL_BLOCK) != 0; + bool const damageNullified = (damageInfo->HitInfo & (HITINFO_FULL_ABSORB | HITINFO_FULL_RESIST)) != 0 || (hitMask & PROC_HIT_FULL_BLOCK) != 0; if (!damageNullified) { // On crit @@ -11126,8 +10985,7 @@ void Unit::ProcSkillsAndReactives(bool isVictim, Unit* procTarget, uint32 typeMa } } -void Unit::GetProcAurasTriggeredOnEvent( - AuraApplicationProcContainer& aurasTriggeringProc, AuraApplicationList* procAuras, ProcEventInfo& eventInfo) +void Unit::GetProcAurasTriggeredOnEvent(AuraApplicationProcContainer& aurasTriggeringProc, AuraApplicationList* procAuras, ProcEventInfo& eventInfo) { std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now(); @@ -11161,16 +11019,14 @@ void Unit::GetProcAurasTriggeredOnEvent( void Unit::TriggerAurasProcOnEvent(CalcDamageInfo& damageInfo) { DamageInfo dmgInfo = DamageInfo(damageInfo); - TriggerAurasProcOnEvent(damageInfo.target, damageInfo.procAttacker, damageInfo.procVictim, PROC_SPELL_TYPE_NONE, - PROC_SPELL_PHASE_NONE, dmgInfo.GetHitMask(), nullptr, &dmgInfo, nullptr); + TriggerAurasProcOnEvent(damageInfo.target, damageInfo.procAttacker, damageInfo.procVictim, PROC_SPELL_TYPE_NONE, PROC_SPELL_PHASE_NONE, dmgInfo.GetHitMask(), nullptr, &dmgInfo, nullptr); } -void Unit::TriggerAurasProcOnEvent(Unit* actionTarget, uint32 typeMaskActor, uint32 typeMaskActionTarget, uint32 spellTypeMask, - uint32 spellPhaseMask, uint32 hitMask, Spell* spell, DamageInfo* damageInfo, HealInfo* healInfo) +void Unit::TriggerAurasProcOnEvent( + Unit* actionTarget, uint32 typeMaskActor, uint32 typeMaskActionTarget, uint32 spellTypeMask, uint32 spellPhaseMask, uint32 hitMask, Spell* spell, DamageInfo* damageInfo, HealInfo* healInfo) { // prepare data for self trigger - ProcEventInfo myProcEventInfo( - this, actionTarget, actionTarget, typeMaskActor, spellTypeMask, spellPhaseMask, hitMask, spell, damageInfo, healInfo); + ProcEventInfo myProcEventInfo(this, actionTarget, actionTarget, typeMaskActor, spellTypeMask, spellPhaseMask, hitMask, spell, damageInfo, healInfo); if (typeMaskActor) { AuraApplicationProcContainer myAurasTriggeringProc; @@ -11194,8 +11050,7 @@ void Unit::TriggerAurasProcOnEvent(Unit* actionTarget, uint32 typeMaskActor, uin } // prepare data for target trigger - ProcEventInfo targetProcEventInfo( - this, actionTarget, this, typeMaskActionTarget, spellTypeMask, spellPhaseMask, hitMask, spell, damageInfo, healInfo); + ProcEventInfo targetProcEventInfo(this, actionTarget, this, typeMaskActionTarget, spellTypeMask, spellPhaseMask, hitMask, spell, damageInfo, healInfo); if (typeMaskActionTarget && actionTarget) { AuraApplicationProcContainer targetAurasTriggeringProc; @@ -11234,7 +11089,10 @@ void Unit::TriggerAurasProcOnEvent(ProcEventInfo& eventInfo, AuraApplicationProc SetCantProc(false); } -SpellSchoolMask Unit::GetMeleeDamageSchoolMask() const { return SPELL_SCHOOL_MASK_NORMAL; } +SpellSchoolMask Unit::GetMeleeDamageSchoolMask() const +{ + return SPELL_SCHOOL_MASK_NORMAL; +} ObjectGuid Unit::GetCharmerOrOwnerOrOwnGUID() const { @@ -11294,7 +11152,10 @@ void Unit::SendPetAIReaction(ObjectGuid guid) ///----------End of Pet responses methods---------- -void Unit::PropagateSpeedChange() { GetMotionMaster()->PropagateSpeedChange(); } +void Unit::PropagateSpeedChange() +{ + GetMotionMaster()->PropagateSpeedChange(); +} void Unit::StopMoving() { @@ -11335,8 +11196,7 @@ void Unit::ResumeMovement(uint32 timer /* = 0*/, uint8 slot /* = 0*/) bool Unit::IsSitState() const { uint8 s = GetStandState(); - return s == UNIT_STAND_STATE_SIT_CHAIR || s == UNIT_STAND_STATE_SIT_LOW_CHAIR || s == UNIT_STAND_STATE_SIT_MEDIUM_CHAIR || - s == UNIT_STAND_STATE_SIT_HIGH_CHAIR || s == UNIT_STAND_STATE_SIT; + return s == UNIT_STAND_STATE_SIT_CHAIR || s == UNIT_STAND_STATE_SIT_LOW_CHAIR || s == UNIT_STAND_STATE_SIT_MEDIUM_CHAIR || s == UNIT_STAND_STATE_SIT_HIGH_CHAIR || s == UNIT_STAND_STATE_SIT; } bool Unit::IsStandState() const @@ -11724,8 +11584,7 @@ uint32 Unit::GetCastingTimeForBonus(SpellInfo const* spellProto, DamageEffectTyp for (uint8 j = 0; j < MAX_SPELL_EFFECTS; ++j) { if (spellProto->Effects[j].Effect == SPELL_EFFECT_HEALTH_LEECH || - (spellProto->Effects[j].Effect == SPELL_EFFECT_APPLY_AURA && - spellProto->Effects[j].ApplyAuraName == SPELL_AURA_PERIODIC_LEECH)) + (spellProto->Effects[j].Effect == SPELL_EFFECT_APPLY_AURA && spellProto->Effects[j].ApplyAuraName == SPELL_AURA_PERIODIC_LEECH)) { CastingTime /= 2; break; @@ -11923,14 +11782,20 @@ void Unit::PlayOneShotAnimKitId(uint16 animKitId) SendMessageToSet(packet.Write(), true); } -void Unit::Kill(Unit* victim, bool durabilityLoss) +/*static*/ void Unit::Kill(Unit* attacker, Unit* victim, bool durabilityLoss /*= true*/) { // Prevent killing unit twice (and giving reward from kill twice) if (!victim->GetHealth()) return; + if (attacker && !attacker->IsInMap(victim)) + attacker = nullptr; + // find player: owner of controlled `this` or `this` itself maybe - Player* player = GetCharmerOrOwnerPlayerOrPlayerItself(); + Player* player = nullptr; + if (attacker) + player = attacker->GetCharmerOrOwnerPlayerOrPlayerItself(); + Creature* creature = victim->ToCreature(); bool isRewardAllowed = true; @@ -12044,26 +11909,24 @@ void Unit::Kill(Unit* victim, bool durabilityLoss) // Do KILL and KILLED procs. KILL proc is called only for the unit who landed the killing blow (and its owner - for pets and // totems) regardless of who tapped the victim - if (IsPet() || IsTotem()) + if (attacker && attacker->IsPet() || attacker->IsTotem()) { // proc only once for victim - if (Unit* owner = GetOwner()) - owner->ProcSkillsAndAuras(victim, PROC_FLAG_KILL, PROC_FLAG_NONE, PROC_SPELL_TYPE_MASK_ALL, PROC_SPELL_PHASE_NONE, - PROC_HIT_NONE, nullptr, nullptr, nullptr); + if (Unit* owner = attacker->GetOwner()) + Unit::ProcSkillsAndAuras(owner, victim, PROC_FLAG_KILL, PROC_FLAG_NONE, PROC_SPELL_TYPE_MASK_ALL, PROC_SPELL_PHASE_NONE, PROC_HIT_NONE, nullptr, nullptr, nullptr); } if (!victim->IsCritter()) - ProcSkillsAndAuras(victim, PROC_FLAG_KILL, PROC_FLAG_NONE, PROC_SPELL_TYPE_MASK_ALL, PROC_SPELL_PHASE_NONE, PROC_HIT_NONE, - nullptr, nullptr, nullptr); + Unit::ProcSkillsAndAuras(attacker, victim, PROC_FLAG_KILL, PROC_FLAG_NONE, PROC_SPELL_TYPE_MASK_ALL, PROC_SPELL_PHASE_NONE, PROC_HIT_NONE, nullptr, nullptr, nullptr); // Proc auras on death - must be before aura/combat remove - victim->ProcSkillsAndAuras(victim, PROC_FLAG_NONE, PROC_FLAG_DEATH, PROC_SPELL_TYPE_MASK_ALL, PROC_SPELL_PHASE_NONE, - PROC_HIT_NONE, nullptr, nullptr, nullptr); + Unit::ProcSkillsAndAuras(victim, victim, PROC_FLAG_NONE, PROC_FLAG_DEATH, PROC_SPELL_TYPE_MASK_ALL, PROC_SPELL_PHASE_NONE, PROC_HIT_NONE, nullptr, nullptr, nullptr); // update get killing blow achievements, must be done before setDeathState to be able to require auras on target // and before Spirit of Redemption as it also removes auras - if (Player* killerPlayer = GetCharmerOrOwnerPlayerOrPlayerItself()) - killerPlayer->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GET_KILLING_BLOWS, 1, 0, 0, victim); + if (attacker) + if (Player* killerPlayer = attacker->GetCharmerOrOwnerPlayerOrPlayerItself()) + killerPlayer->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GET_KILLING_BLOWS, 1, 0, 0, victim); LOG_DEBUG("entities.unit", "SET JUST_DIED"); victim->setDeathState(JUST_DIED); @@ -12091,8 +11954,7 @@ void Unit::Kill(Unit* victim, bool durabilityLoss) plrVictim->SetPvPDeath(player != nullptr); // only if not player and not controlled by player pet. And not at BG - if ((durabilityLoss && !player && !victim->ToPlayer()->InBattleground()) || - (player && sWorld->getBoolConfig(CONFIG_DURABILITY_LOSS_IN_PVP))) + if ((durabilityLoss && !player && !victim->ToPlayer()->InBattleground()) || (player && sWorld->getBoolConfig(CONFIG_DURABILITY_LOSS_IN_PVP))) { double baseLoss = sWorld->getRate(RATE_DURABILITY_LOSS_ON_DEATH); uint32 loss = uint32(baseLoss - (baseLoss * plrVictim->GetTotalAuraMultiplier(SPELL_AURA_MOD_DURABILITY_LOSS))); @@ -12100,11 +11962,11 @@ void Unit::Kill(Unit* victim, bool durabilityLoss) // Durability loss is calculated more accurately again for each item in Player::DurabilityLoss plrVictim->DurabilityLossAll(baseLoss, false); // durability lost message - SendDurabilityLoss(plrVictim, loss); + plrVictim->SendDurabilityLoss(plrVictim, loss); } // Call KilledUnit for creatures - if (IsCreature() && IsAIEnabled()) - ToCreature()->AI()->KilledUnit(victim); + if (attacker && attacker->IsCreature() && attacker->IsAIEnabled()) + attacker->ToCreature()->AI()->KilledUnit(victim); // last damage from non duel opponent or opponent controlled creature if (plrVictim->duel) @@ -12128,31 +11990,31 @@ void Unit::Kill(Unit* victim, bool durabilityLoss) } // Call KilledUnit for creatures, this needs to be called after the lootable flag is set - if (IsCreature() && IsAIEnabled()) - ToCreature()->AI()->KilledUnit(victim); + if (attacker->IsCreature() && attacker->IsAIEnabled()) + attacker->ToCreature()->AI()->KilledUnit(victim); // Call creature just died function if (CreatureAI* ai = creature->AI()) - ai->JustDied(this); + ai->JustDied(attacker); if (TempSummon* summon = creature->ToTempSummon()) if (Unit* summoner = summon->GetSummoner()) if (summoner->ToCreature() && summoner->IsAIEnabled()) - summoner->ToCreature()->AI()->SummonedCreatureDies(creature, this); + summoner->ToCreature()->AI()->SummonedCreatureDies(creature, attacker); // Dungeon specific stuff, only applies to players killing creatures if (creature->GetInstanceId()) { Map* instanceMap = creature->GetMap(); - Player* creditedPlayer = GetCharmerOrOwnerPlayerOrPlayerItself(); + Player* creditedPlayer = attacker->GetCharmerOrOwnerPlayerOrPlayerItself(); /// @todo do instance binding anyway if the charmer/owner is offline - if (instanceMap->IsDungeon() && (creditedPlayer || this == victim)) + if (instanceMap->IsDungeon() && ((attacker && attacker->GetCharmerOrOwnerPlayerOrPlayerItself()) || attacker == victim)) { if (instanceMap->IsRaidOrHeroicDungeon()) { if (creature->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_INSTANCE_BIND) - ((InstanceMap*)instanceMap)->PermBindAllPlayers(); + instanceMap->ToInstanceMap()->PermBindAllPlayers(); } else { @@ -12169,7 +12031,7 @@ void Unit::Kill(Unit* victim, bool durabilityLoss) // outdoor pvp things, do these after setting the death state, else the player activity notify won't work... doh... // handle player kill only if not suicide (spirit of redemption for example) - if (player && this != victim) + if (player && attacker != victim) { if (OutdoorPvP* pvp = player->GetOutdoorPvP()) pvp->HandleKill(player, victim); @@ -12195,26 +12057,29 @@ void Unit::Kill(Unit* victim, bool durabilityLoss) } // achievement stuff - if (victim->GetTypeId() == TYPEID_PLAYER) + if (attacker && victim->GetTypeId() == TYPEID_PLAYER) { - if (GetTypeId() == TYPEID_UNIT) - victim->ToPlayer()->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_KILLED_BY_CREATURE, GetEntry()); - else if (GetTypeId() == TYPEID_PLAYER && victim != this) - victim->ToPlayer()->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_KILLED_BY_PLAYER, 1, ToPlayer()->GetTeam()); + if (attacker->GetTypeId() == TYPEID_UNIT) + victim->ToPlayer()->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_KILLED_BY_CREATURE, attacker->GetEntry()); + else if (attacker->GetTypeId() == TYPEID_PLAYER && victim != attacker) + victim->ToPlayer()->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_KILLED_BY_PLAYER, 1, attacker->ToPlayer()->GetTeam()); } // Hook for OnPVPKill Event - if (Player* killerPlr = ToPlayer()) - { - if (Player* killedPlr = victim->ToPlayer()) - sScriptMgr->OnPVPKill(killerPlr, killedPlr); - else if (Creature* killedCre = victim->ToCreature()) - sScriptMgr->OnCreatureKill(killerPlr, killedCre); - } - else if (Creature* killerCre = ToCreature()) + if (attacker) { - if (Player* killed = victim->ToPlayer()) - sScriptMgr->OnPlayerKilledByCreature(killerCre, killed); + if (Player* killerPlr = attacker->ToPlayer()) + { + if (Player* killedPlr = victim->ToPlayer()) + sScriptMgr->OnPVPKill(killerPlr, killedPlr); + else if (Creature* killedCre = victim->ToCreature()) + sScriptMgr->OnCreatureKill(killerPlr, killedCre); + } + else if (Creature* killerCre = attacker->ToCreature()) + { + if (Player* killed = victim->ToPlayer()) + sScriptMgr->OnPlayerKilledByCreature(killerCre, killed); + } } } @@ -12272,8 +12137,7 @@ void Unit::SetControlled(bool apply, UnitState state) SetStunned(false); break; case UNIT_STATE_ROOT: - if (HasAuraType(SPELL_AURA_MOD_ROOT) || GetVehicle() || - (ToCreature() && ToCreature()->GetMovementTemplate().IsRooted())) + if (HasAuraType(SPELL_AURA_MOD_ROOT) || GetVehicle() || (ToCreature() && ToCreature()->GetMovementTemplate().IsRooted())) return; ClearUnitState(state); @@ -12392,8 +12256,7 @@ void Unit::SetFeared(bool apply) caster = ObjectAccessor::GetUnit(*this, fearAuras.front()->GetCasterGUID()); if (!caster) caster = getAttackerForHelper(); - GetMotionMaster()->MoveFleeing(caster, fearAuras.empty() ? sWorld->getIntConfig(CONFIG_CREATURE_FAMILY_FLEE_DELAY) - : 0); // caster == nullptr processed in MoveFleeing + GetMotionMaster()->MoveFleeing(caster, fearAuras.empty() ? sWorld->getIntConfig(CONFIG_CREATURE_FAMILY_FLEE_DELAY) : 0); // caster == nullptr processed in MoveFleeing } else { @@ -12453,13 +12316,12 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* au ASSERT(type != CHARM_TYPE_POSSESS || charmer->GetTypeId() == TYPEID_PLAYER); ASSERT((type == CHARM_TYPE_VEHICLE) == (GetVehicleKit() && GetVehicleKit()->IsControllableVehicle())); - LOG_DEBUG("entities.unit", "SetCharmedBy: charmer %u (GUID %u), charmed %u (GUID %u), type %u.", charmer->GetEntry(), - charmer->GetGUID().GetCounter(), GetEntry(), GetGUID().GetCounter(), uint32(type)); + LOG_DEBUG( + "entities.unit", "SetCharmedBy: charmer %u (GUID %u), charmed %u (GUID %u), type %u.", charmer->GetEntry(), charmer->GetGUID().GetCounter(), GetEntry(), GetGUID().GetCounter(), uint32(type)); if (this == charmer) { - LOG_FATAL("entities.unit", "Unit::SetCharmedBy: Unit %u (GUID %u) is trying to charm itself!", GetEntry(), - GetGUID().GetCounter()); + LOG_FATAL("entities.unit", "Unit::SetCharmedBy: Unit %u (GUID %u) is trying to charm itself!", GetEntry(), GetGUID().GetCounter()); return false; } @@ -12468,17 +12330,15 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* au if (GetTypeId() == TYPEID_PLAYER && ToPlayer()->GetTransport()) { - LOG_FATAL("entities.unit", "Unit::SetCharmedBy: Player on transport is trying to charm %u (GUID %u)", GetEntry(), - GetGUID().GetCounter()); + LOG_FATAL("entities.unit", "Unit::SetCharmedBy: Player on transport is trying to charm %u (GUID %u)", GetEntry(), GetGUID().GetCounter()); return false; } // Already charmed if (GetCharmerGUID()) { - LOG_FATAL("entities.unit", - "Unit::SetCharmedBy: %u (GUID %u) has already been charmed but %u (GUID %u) is trying to charm it!", GetEntry(), - GetGUID().GetCounter(), charmer->GetEntry(), charmer->GetGUID().GetCounter()); + LOG_FATAL("entities.unit", "Unit::SetCharmedBy: %u (GUID %u) has already been charmed but %u (GUID %u) is trying to charm it!", GetEntry(), GetGUID().GetCounter(), charmer->GetEntry(), + charmer->GetGUID().GetCounter()); return false; } @@ -12504,8 +12364,8 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* au // StopCastingCharm may remove a possessed pet? if (!IsInWorld()) { - LOG_FATAL("entities.unit", "Unit::SetCharmedBy: %u (GUID %u) is not in world but %u (GUID %u) is trying to charm it!", - GetEntry(), GetGUID().GetCounter(), charmer->GetEntry(), charmer->GetGUID().GetCounter()); + LOG_FATAL("entities.unit", "Unit::SetCharmedBy: %u (GUID %u) is not in world but %u (GUID %u) is trying to charm it!", GetEntry(), GetGUID().GetCounter(), charmer->GetEntry(), + charmer->GetGUID().GetCounter()); return false; } @@ -12682,8 +12542,7 @@ void Unit::RemoveCharmedBy(Unit* charmer) if (GetCharmInfo()) GetCharmInfo()->SetPetNumber(0, true); else - LOG_ERROR("entities.unit", "Aura::HandleModCharm: %s has a charm aura but no charm info!", - GetGUID().ToString().c_str()); + LOG_ERROR("entities.unit", "Aura::HandleModCharm: %s has a charm aura but no charm info!", GetGUID().ToString().c_str()); } } break; @@ -12770,9 +12629,15 @@ void Unit::RemoveVehicleKit(bool onRemoveFromWorld /*= false*/) RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK | UNIT_NPC_FLAG_PLAYER_VEHICLE); } -bool Unit::IsOnVehicle(Unit const* vehicle) const { return m_vehicle && m_vehicle == vehicle->GetVehicleKit(); } +bool Unit::IsOnVehicle(Unit const* vehicle) const +{ + return m_vehicle && m_vehicle == vehicle->GetVehicleKit(); +} -Unit* Unit::GetVehicleBase() const { return m_vehicle ? m_vehicle->GetBase() : nullptr; } +Unit* Unit::GetVehicleBase() const +{ + return m_vehicle ? m_vehicle->GetBase() : nullptr; +} Creature* Unit::GetVehicleCreatureBase() const { @@ -12812,10 +12677,8 @@ bool Unit::IsInPartyWith(Unit const* unit) const if (u1->GetTypeId() == TYPEID_PLAYER && u2->GetTypeId() == TYPEID_PLAYER) return u1->ToPlayer()->IsInSameGroupWith(u2->ToPlayer()); - else if ((u2->GetTypeId() == TYPEID_PLAYER && u1->GetTypeId() == TYPEID_UNIT && - u1->ToCreature()->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_TREAT_AS_RAID_UNIT) || - (u1->GetTypeId() == TYPEID_PLAYER && u2->GetTypeId() == TYPEID_UNIT && - u2->ToCreature()->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_TREAT_AS_RAID_UNIT)) + else if ((u2->GetTypeId() == TYPEID_PLAYER && u1->GetTypeId() == TYPEID_UNIT && u1->ToCreature()->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_TREAT_AS_RAID_UNIT) || + (u1->GetTypeId() == TYPEID_PLAYER && u2->GetTypeId() == TYPEID_UNIT && u2->ToCreature()->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_TREAT_AS_RAID_UNIT)) return true; return u1->GetTypeId() == TYPEID_UNIT && u2->GetTypeId() == TYPEID_UNIT && u1->GetFaction() == u2->GetFaction(); @@ -12833,10 +12696,8 @@ bool Unit::IsInRaidWith(Unit const* unit) const if (u1->GetTypeId() == TYPEID_PLAYER && u2->GetTypeId() == TYPEID_PLAYER) return u1->ToPlayer()->IsInSameRaidWith(u2->ToPlayer()); - else if ((u2->GetTypeId() == TYPEID_PLAYER && u1->GetTypeId() == TYPEID_UNIT && - u1->ToCreature()->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_TREAT_AS_RAID_UNIT) || - (u1->GetTypeId() == TYPEID_PLAYER && u2->GetTypeId() == TYPEID_UNIT && - u2->ToCreature()->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_TREAT_AS_RAID_UNIT)) + else if ((u2->GetTypeId() == TYPEID_PLAYER && u1->GetTypeId() == TYPEID_UNIT && u1->ToCreature()->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_TREAT_AS_RAID_UNIT) || + (u1->GetTypeId() == TYPEID_PLAYER && u2->GetTypeId() == TYPEID_UNIT && u2->ToCreature()->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_TREAT_AS_RAID_UNIT)) return true; return u1->GetTypeId() == TYPEID_UNIT && u2->GetTypeId() == TYPEID_UNIT && u1->GetFaction() == u2->GetFaction(); @@ -12956,8 +12817,8 @@ void Unit::SendPlaySpellVisualKit(uint32 id, uint32 type, uint32 duration) const SendMessageToSet(packet.Write(), IsPlayer()); } -void Unit::SendPlaySpellVisual(uint32 spellVisualId, Unit const* target /*= nullptr*/, Optional targetPosition /*= {}*/, - float travelSpeed /*= 0.f*/, uint16 missReason /*= 0*/, uint16 reflectStatus /*= 0*/, bool speedAsTime /*= false*/) const +void Unit::SendPlaySpellVisual(uint32 spellVisualId, Unit const* target /*= nullptr*/, Optional targetPosition /*= {}*/, float travelSpeed /*= 0.f*/, uint16 missReason /*= 0*/, + uint16 reflectStatus /*= 0*/, bool speedAsTime /*= false*/) const { if (!sSpellVisualStore.LookupEntry(spellVisualId)) return; @@ -13007,21 +12868,28 @@ void Unit::CancelSpellMissiles(uint32 spellId, bool reverseMissile /*= false*/) } } -void Unit::ApplyResilience(Unit const* victim, int32* damage) const +bool Unit::CanApplyResilience() const { - // player mounted on multi-passenger mount is also classified as vehicle - if (IsVehicle() || (victim->IsVehicle() && victim->GetTypeId() != TYPEID_PLAYER)) - return; + return !IsVehicle() && GetOwnerGUID().IsPlayer(); +} - // Don't consider resilience if not in PvP - player or pet - if (!GetCharmerOrOwnerPlayerOrPlayerItself()) +/*static*/ void Unit::ApplyResilience(Unit const* victim, int32* damage) +{ + // player mounted on multi-passenger mount is also classified as vehicle + if (victim->IsVehicle() && victim->GetTypeId() != TYPEID_PLAYER) return; Unit const* target = nullptr; if (victim->GetTypeId() == TYPEID_PLAYER) target = victim; - else if (victim->GetTypeId() == TYPEID_UNIT && victim->GetOwner() && victim->GetOwner()->GetTypeId() == TYPEID_PLAYER) - target = victim->GetOwner(); + else + { + if (Unit* owner = victim->GetOwner()) + { + if (owner->GetTypeId() == TYPEID_PLAYER) + target = owner; + } + } if (!target) return; @@ -13029,6 +12897,15 @@ void Unit::ApplyResilience(Unit const* victim, int32* damage) const *damage -= target->GetDamageReduction(*damage); } +int32 Unit::CalculateAOEAvoidance(int32 damage, uint32 schoolMask, Unit* caster) const +{ + damage = int32(float(damage) * GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_AOE_DAMAGE_AVOIDANCE, schoolMask)); + if (caster->GetTypeId() == TYPEID_UNIT) + damage = int32(float(damage) * GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_CREATURE_AOE_DAMAGE_AVOIDANCE, schoolMask)); + + return damage; +} + // Melee based spells can be miss, parry or dodge on this step // Crit or block - determined on damage calculation phase! (and can be both in some time) float Unit::MeleeSpellMissChance(Unit const* victim, WeaponAttackType attType, SpellInfo const* spellInfo /*= nullptr*/) const @@ -13635,8 +13512,7 @@ bool Unit::HandleSpellClick(Unit* clicker, int8 seatId) Unit* caster = (itr->second.castFlags & NPC_CLICK_CAST_CASTER_CLICKER) ? clicker : this; Unit* target = (itr->second.castFlags & NPC_CLICK_CAST_TARGET_CLICKER) ? clicker : this; - ObjectGuid origCasterGUID = - (itr->second.castFlags & NPC_CLICK_CAST_ORIG_CASTER_OWNER) ? GetOwnerOrCreatorGUID() : clicker->GetGUID(); + ObjectGuid origCasterGUID = (itr->second.castFlags & NPC_CLICK_CAST_ORIG_CASTER_OWNER) ? GetOwnerOrCreatorGUID() : clicker->GetGUID(); SpellInfo const* spellEntry = sSpellMgr->GetSpellInfo(itr->second.spellId); // if (!spellEntry) should be checked at npc_spellclick load @@ -13657,8 +13533,7 @@ bool Unit::HandleSpellClick(Unit* clicker, int8 seatId) if (!valid) { - LOG_ERROR("sql.sql", "Spell %u specified in npc_spellclick_spells is not a valid vehicle enter aura!", - itr->second.spellId); + LOG_ERROR("sql.sql", "Spell %u specified in npc_spellclick_spells is not a valid vehicle enter aura!", itr->second.spellId); continue; } @@ -13716,8 +13591,7 @@ void Unit::_EnterVehicle(Vehicle* vehicle, int8 seatId, AuraApplication const* a { if (m_vehicle != vehicle) { - LOG_DEBUG("entities.vehicle", "EnterVehicle: %u exit %u and enter %u.", GetEntry(), m_vehicle->GetBase()->GetEntry(), - vehicle->GetBase()->GetEntry()); + LOG_DEBUG("entities.vehicle", "EnterVehicle: %u exit %u and enter %u.", GetEntry(), m_vehicle->GetBase()->GetEntry(), vehicle->GetBase()->GetEntry()); ExitVehicle(); } else if (seatId >= 0 && seatId == GetTransSeat()) @@ -13751,8 +13625,7 @@ void Unit::_EnterVehicle(Vehicle* vehicle, int8 seatId, AuraApplication const* a // If vehicle flag for fixed position set (cannons), or if the following hardcoded units, then set state rooted // 30236 | Argent Cannon // 39759 | Tankbuster Cannon - if ((vehicle->GetVehicleInfo()->Flags & VEHICLE_FLAG_FIXED_POSITION) || vehicle->GetBase()->GetEntry() == 30236 || - vehicle->GetBase()->GetEntry() == 39759) + if ((vehicle->GetVehicleInfo()->Flags & VEHICLE_FLAG_FIXED_POSITION) || vehicle->GetBase()->GetEntry() == 30236 || vehicle->GetBase()->GetEntry() == 39759) SetControlled(true, UNIT_STATE_ROOT); ASSERT(!m_vehicle); @@ -13768,8 +13641,7 @@ void Unit::ChangeSeat(int8 seatId, bool next) if (seatId == GetTransSeat()) return; - SeatMap::const_iterator seat = - (seatId < 0 ? m_vehicle->GetNextEmptySeat(GetTransSeat(), next) : m_vehicle->Seats.find(seatId)); + SeatMap::const_iterator seat = (seatId < 0 ? m_vehicle->GetNextEmptySeat(GetTransSeat(), next) : m_vehicle->Seats.find(seatId)); // The second part of the check will only return true if seatId >= 0. @Vehicle::GetNextEmptySeat makes sure of that. if (seat == m_vehicle->Seats.end() || !seat->second.IsEmpty()) return; @@ -13860,11 +13732,9 @@ void Unit::_ExitVehicle(Position const* exitPosition) if (seatAddon) { if (seatAddon->ExitParameter == VehicleExitParameters::VehicleExitParamOffset) - pos.RelocateOffset( - {seatAddon->ExitParameterX, seatAddon->ExitParameterY, seatAddon->ExitParameterZ, seatAddon->ExitParameterO}); + pos.RelocateOffset({seatAddon->ExitParameterX, seatAddon->ExitParameterY, seatAddon->ExitParameterZ, seatAddon->ExitParameterO}); else if (seatAddon->ExitParameter == VehicleExitParameters::VehicleExitParamDest) - pos.Relocate( - {seatAddon->ExitParameterX, seatAddon->ExitParameterY, seatAddon->ExitParameterZ, seatAddon->ExitParameterO}); + pos.Relocate({seatAddon->ExitParameterX, seatAddon->ExitParameterY, seatAddon->ExitParameterZ, seatAddon->ExitParameterO}); } } @@ -13874,8 +13744,7 @@ void Unit::_ExitVehicle(Position const* exitPosition) // Creatures without inhabit type air should begin falling after exiting the vehicle if (GetTypeId() == TYPEID_UNIT && !CanFly() && - height > GetMap()->GetWaterOrGroundLevel(GetPhaseShift(), pos.GetPositionX(), pos.GetPositionY(), - pos.GetPositionZ() + vehicle->GetBase()->GetCollisionHeight(), &height)) + height > GetMap()->GetWaterOrGroundLevel(GetPhaseShift(), pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ() + vehicle->GetBase()->GetCollisionHeight(), &height)) init.SetFall(); init.MoveTo(pos.GetPositionX(), pos.GetPositionY(), height, false); @@ -13927,8 +13796,7 @@ void Unit::NearTeleportTo(Position const& pos, bool casting /*= false*/) if (GetTypeId() == TYPEID_PLAYER) { WorldLocation target(GetMapId(), pos); - ToPlayer()->TeleportTo(target, - TELE_TO_NOT_LEAVE_TRANSPORT | TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET | (casting ? TELE_TO_SPELL : 0)); + ToPlayer()->TeleportTo(target, TELE_TO_NOT_LEAVE_TRANSPORT | TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET | (casting ? TELE_TO_SPELL : 0)); } else { @@ -13938,8 +13806,7 @@ void Unit::NearTeleportTo(Position const& pos, bool casting /*= false*/) } } -void Unit::WriteMovementInfo( - WorldPacket& data, Movement::ExtraMovementStatusElement* extras /*= nullptr*/, uint32* movementCounter /*= nullptr*/) +void Unit::WriteMovementInfo(WorldPacket& data, Movement::ExtraMovementStatusElement* extras /*= nullptr*/, uint32* movementCounter /*= nullptr*/) { MovementInfo const& mi = m_movementInfo; @@ -13952,8 +13819,7 @@ void Unit::WriteMovementInfo( bool hasTransportTime2 = hasTransportData && m_movementInfo.transport.time2 != 0; bool hasTransportVehicleId = hasTransportData && m_movementInfo.transport.vehicleId != 0; - bool hasPitch = HasUnitMovementFlag(MovementFlags(MOVEMENTFLAG_SWIMMING | MOVEMENTFLAG_FLYING)) || - HasExtraUnitMovementFlag(MOVEMENTFLAG2_ALWAYS_ALLOW_PITCHING); + bool hasPitch = HasUnitMovementFlag(MovementFlags(MOVEMENTFLAG_SWIMMING | MOVEMENTFLAG_FLYING)) || HasExtraUnitMovementFlag(MOVEMENTFLAG2_ALWAYS_ALLOW_PITCHING); bool hasFallDirection = HasUnitMovementFlag(MOVEMENTFLAG_FALLING); bool hasFallData = hasFallDirection || m_movementInfo.jump.fallTime != 0; bool hasSplineElevation = HasUnitMovementFlag(MOVEMENTFLAG_SPLINE_ELEVATION); @@ -13961,8 +13827,7 @@ void Unit::WriteMovementInfo( MovementStatusElements const* sequence = GetMovementStatusElementsSequence(static_cast(data.GetOpcode())); if (!sequence) { - LOG_ERROR("network", "Unit::WriteMovementInfo: No movement sequence found for opcode %s", - GetOpcodeNameForLogging(static_cast(data.GetOpcode())).c_str()); + LOG_ERROR("network", "Unit::WriteMovementInfo: No movement sequence found for opcode %s", GetOpcodeNameForLogging(static_cast(data.GetOpcode())).c_str()); return; } @@ -14214,8 +14079,7 @@ bool Unit::UpdatePosition(float x, float y, float z, float orientation, bool tel // G3D::fuzzyEq won't help here, in some cases magnitudes differ by a little more than G3D::eps, but should be considered // equal - bool const relocated = (teleport || std::fabs(GetPositionX() - x) > 0.001f || std::fabs(GetPositionY() - y) > 0.001f || - std::fabs(GetPositionZ() - z) > 0.001f); + bool const relocated = (teleport || std::fabs(GetPositionX() - x) > 0.001f || std::fabs(GetPositionY() - y) > 0.001f || std::fabs(GetPositionZ() - z) > 0.001f); if (relocated) { @@ -14257,7 +14121,10 @@ void Unit::UpdateHeight(float newZ) GetVehicleKit()->RelocatePassengers(); } -void Unit::ClearPendingMovementChangeForType(MovementChangeType changeType) { m_pendingMovementChanges.erase(changeType); } +void Unit::ClearPendingMovementChangeForType(MovementChangeType changeType) +{ + m_pendingMovementChanges.erase(changeType); +} void Unit::AssignPendingMovementChange(MovementChangeType changeType, PlayerMovementPendingChange&& newChange) { @@ -14386,7 +14253,10 @@ void Unit::PurgeAndApplyPendingMovementChanges(bool informObservers /* = true */ m_pendingMovementChanges.clear(); } -PlayerMovementPendingChange::PlayerMovementPendingChange() { time = GameTime::GetGameTimeMS(); } +PlayerMovementPendingChange::PlayerMovementPendingChange() +{ + time = GameTime::GetGameTimeMS(); +} // baseRage means damage taken when attacker = false void Unit::RewardRage(uint32 baseRage, bool attacker) @@ -14456,8 +14326,8 @@ void Unit::OutDebugInfo() const { LOG_ERROR("entities.unit", "Unit::OutDebugInfo"); LOG_DEBUG("entities.unit", "%s name %s", GetGUID().ToString().c_str(), GetName().c_str()); - LOG_DEBUG("entities.unit", "Owner %s, Minion %s, Charmer %s, Charmed %s", GetOwnerOrCreatorGUID().ToString().c_str(), - GetMinionGUID().ToString().c_str(), GetCharmerGUID().ToString().c_str(), GetCharmedGUID().ToString().c_str()); + LOG_DEBUG("entities.unit", "Owner %s, Minion %s, Charmer %s, Charmed %s", GetOwnerOrCreatorGUID().ToString().c_str(), GetMinionGUID().ToString().c_str(), GetCharmerGUID().ToString().c_str(), + GetCharmedGUID().ToString().c_str()); LOG_DEBUG("entities.unit", "In world %u, unit type mask %u", (uint32)(IsInWorld() ? 1 : 0), m_unitTypeMask); if (IsInWorld()) LOG_DEBUG("entities.unit", "Mapid %u", GetMapId()); @@ -14501,11 +14371,9 @@ uint32 Unit::GetRemainingPeriodicAmount(ObjectGuid caster, uint32 spellId, AuraT AuraEffectList const& periodicAuras = GetAuraEffectsByType(auraType); for (AuraEffectList::const_iterator i = periodicAuras.begin(); i != periodicAuras.end(); ++i) { - if ((*i)->GetCasterGUID() != caster || (*i)->GetId() != spellId || (*i)->GetEffIndex() != effectIndex || - !(*i)->GetTotalTicks()) + if ((*i)->GetCasterGUID() != caster || (*i)->GetId() != spellId || (*i)->GetEffIndex() != effectIndex || !(*i)->GetTotalTicks()) continue; - amount += uint32(((*i)->GetAmount() * std::max((*i)->GetTotalTicks() - int32((*i)->GetTickNumber()), 0)) / - (*i)->GetTotalTicks()); + amount += uint32(((*i)->GetAmount() * std::max((*i)->GetTotalTicks() - int32((*i)->GetTickNumber()), 0)) / (*i)->GetTotalTicks()); break; } @@ -14530,13 +14398,25 @@ uint32 Unit::GetResistance(SpellSchoolMask mask) const return uint32(resist); } -void CharmInfo::SetIsCommandAttack(bool val) { _isCommandAttack = val; } +void CharmInfo::SetIsCommandAttack(bool val) +{ + _isCommandAttack = val; +} -bool CharmInfo::IsCommandAttack() { return _isCommandAttack; } +bool CharmInfo::IsCommandAttack() +{ + return _isCommandAttack; +} -void CharmInfo::SetIsCommandFollow(bool val) { _isCommandFollow = val; } +void CharmInfo::SetIsCommandFollow(bool val) +{ + _isCommandFollow = val; +} -bool CharmInfo::IsCommandFollow() { return _isCommandFollow; } +bool CharmInfo::IsCommandFollow() +{ + return _isCommandFollow; +} void CharmInfo::SaveStayPosition() { @@ -14559,19 +14439,40 @@ void CharmInfo::GetStayPosition(float& x, float& y, float& z) z = _stayZ; } -void CharmInfo::SetIsAtStay(bool val) { _isAtStay = val; } +void CharmInfo::SetIsAtStay(bool val) +{ + _isAtStay = val; +} -bool CharmInfo::IsAtStay() { return _isAtStay; } +bool CharmInfo::IsAtStay() +{ + return _isAtStay; +} -void CharmInfo::SetIsFollowing(bool val) { _isFollowing = val; } +void CharmInfo::SetIsFollowing(bool val) +{ + _isFollowing = val; +} -bool CharmInfo::IsFollowing() { return _isFollowing; } +bool CharmInfo::IsFollowing() +{ + return _isFollowing; +} -void CharmInfo::SetIsReturning(bool val) { _isReturning = val; } +void CharmInfo::SetIsReturning(bool val) +{ + _isReturning = val; +} -bool CharmInfo::IsReturning() { return _isReturning; } +bool CharmInfo::IsReturning() +{ + return _isReturning; +} -void Unit::SetOrientationTowards(WorldObject const* target) { SetOrientation(GetAngle(target)); } +void Unit::SetOrientationTowards(WorldObject const* target) +{ + SetOrientation(GetAngle(target)); +} void Unit::SetFacingTo(float ori, bool force) { @@ -14596,8 +14497,7 @@ void Unit::SetFacingToObject(WorldObject const* object, bool force) /// @todo figure out under what conditions creature will move towards object instead of facing it where it currently is. Movement::MoveSplineInit init(this); init.MoveTo(GetPositionX(), GetPositionY(), GetPositionZ(), false); - init.SetFacing( - GetAngle(object)); // when on transport, GetAngle will still return global coordinates (and angle) that needs transforming + init.SetFacing(GetAngle(object)); // when on transport, GetAngle will still return global coordinates (and angle) that needs transforming init.Launch(); } @@ -14833,7 +14733,10 @@ void Unit::SendMovementSetSplineAnim(AnimationTier anim) SendMessageToSet(packet.Write(), false); } -bool Unit::IsSplineEnabled() const { return movespline->Initialized() && !movespline->Finalized(); } +bool Unit::IsSplineEnabled() const +{ + return movespline->Initialized() && !movespline->Finalized(); +} void Unit::BuildValuesUpdate(uint8 updateType, ByteBuffer* data, Player* target) const { @@ -14872,8 +14775,7 @@ void Unit::BuildValuesUpdate(uint8 updateType, ByteBuffer* data, Player* target) for (uint16 index = 0; index < valCount; ++index) { if (_fieldNotifyFlags & flags[index] || ((flags[index] & visibleFlag) & UF_FLAG_SPECIAL_INFO) || - ((updateType == UPDATETYPE_VALUES ? _changesMask.GetBit(index) : m_uint32Values[index]) && - (flags[index] & visibleFlag)) || + ((updateType == UPDATETYPE_VALUES ? _changesMask.GetBit(index) : m_uint32Values[index]) && (flags[index] & visibleFlag)) || (index == UNIT_FIELD_AURASTATE && HasFlag(UNIT_FIELD_AURASTATE, PER_CASTER_AURA_STATE_MASK))) { updateMask.SetBit(index); @@ -14905,10 +14807,8 @@ void Unit::BuildValuesUpdate(uint8 updateType, ByteBuffer* data, Player* target) fieldBuffer << uint32(m_floatValues[index] < 0 ? 0 : m_floatValues[index]); } // there are some float values which may be negative or can't get negative due to other checks - else if ((index >= UNIT_FIELD_NEGSTAT0 && index <= UNIT_FIELD_NEGSTAT4) || - (index >= UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE && index <= (UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE + 6)) || - (index >= UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE && index <= (UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE + 6)) || - (index >= UNIT_FIELD_POSSTAT0 && index <= UNIT_FIELD_POSSTAT4)) + else if ((index >= UNIT_FIELD_NEGSTAT0 && index <= UNIT_FIELD_NEGSTAT4) || (index >= UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE && index <= (UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE + 6)) || + (index >= UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE && index <= (UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE + 6)) || (index >= UNIT_FIELD_POSSTAT0 && index <= UNIT_FIELD_POSSTAT4)) { fieldBuffer << uint32(m_floatValues[index]); } @@ -14933,8 +14833,7 @@ void Unit::BuildValuesUpdate(uint8 updateType, ByteBuffer* data, Player* target) if (SpellInfo const* transform = sSpellMgr->GetSpellInfo(getTransForm())) for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) if (transform->Effects[i].IsAura(SPELL_AURA_TRANSFORM)) - if (CreatureTemplate const* transformInfo = - sObjectMgr->GetCreatureTemplate(transform->Effects[i].MiscValue)) + if (CreatureTemplate const* transformInfo = sObjectMgr->GetCreatureTemplate(transform->Effects[i].MiscValue)) { cinfo = transformInfo; break; @@ -14975,8 +14874,7 @@ void Unit::BuildValuesUpdate(uint8 updateType, ByteBuffer* data, Player* target) // FG: pretend that OTHER players in own group are friendly ("blue") else if (index == UNIT_FIELD_BYTES_2 || index == UNIT_FIELD_FACTIONTEMPLATE) { - if (IsControlledByPlayer() && target != this && sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP) && - IsInRaidWith(target)) + if (IsControlledByPlayer() && target != this && sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP) && IsInRaidWith(target)) { FactionTemplateEntry const* ft1 = GetFactionTemplateEntry(); FactionTemplateEntry const* ft2 = target->GetFactionTemplateEntry(); @@ -14985,8 +14883,7 @@ void Unit::BuildValuesUpdate(uint8 updateType, ByteBuffer* data, Player* target) if (index == UNIT_FIELD_BYTES_2) // Allow targetting opposite faction in party when enabled in config fieldBuffer << (m_uint32Values[UNIT_FIELD_BYTES_2] & - ((UNIT_BYTE2_FLAG_SANCTUARY /*| UNIT_BYTE2_FLAG_AURAS | UNIT_BYTE2_FLAG_UNK5*/) - << 8)); // this flag is at uint8 offset 1 !! + ((UNIT_BYTE2_FLAG_SANCTUARY /*| UNIT_BYTE2_FLAG_AURAS | UNIT_BYTE2_FLAG_UNK5*/) << 8)); // this flag is at uint8 offset 1 !! else // pretend that all other HOSTILE players have own faction, to allow follow, heal, rezz (trade wont // work) @@ -15025,8 +14922,7 @@ void Unit::DestroyForPlayer(Player* target, bool /*onDeath = false*/) const WorldObject::DestroyForPlayer(target); } -int32 Unit::GetHighestExclusiveSameEffectSpellGroupValue( - AuraEffect const* aurEff, AuraType auraType, bool checkMiscValue /*= false*/, int32 miscValue /*= 0*/) const +int32 Unit::GetHighestExclusiveSameEffectSpellGroupValue(AuraEffect const* aurEff, AuraType auraType, bool checkMiscValue /*= false*/, int32 miscValue /*= 0*/) const { int32 val = 0; SpellSpellGroupMapBounds spellGroup = sSpellMgr->GetSpellSpellGroupMapBounds(aurEff->GetSpellInfo()->GetFirstRankSpell()->Id); @@ -15037,8 +14933,7 @@ int32 Unit::GetHighestExclusiveSameEffectSpellGroupValue( AuraEffectList const& auraEffList = GetAuraEffectsByType(auraType); for (AuraEffectList::const_iterator auraItr = auraEffList.begin(); auraItr != auraEffList.end(); ++auraItr) { - if (aurEff != (*auraItr) && (!checkMiscValue || (*auraItr)->GetMiscValue() == miscValue) && - sSpellMgr->IsSpellMemberOfSpellGroup((*auraItr)->GetSpellInfo()->Id, itr->second)) + if (aurEff != (*auraItr) && (!checkMiscValue || (*auraItr)->GetMiscValue() == miscValue) && sSpellMgr->IsSpellMemberOfSpellGroup((*auraItr)->GetSpellInfo()->Id, itr->second)) { // absolute value only if (abs(val) < abs((*auraItr)->GetAmount())) @@ -15054,15 +14949,13 @@ bool Unit::IsHighestExclusiveAura(Aura const* aura, bool removeOtherAuraApplicat { for (uint32 i = 0; i < MAX_SPELL_EFFECTS; ++i) if (AuraEffect const* aurEff = aura->GetEffect(i)) - if (!IsHighestExclusiveAuraEffect(aura->GetSpellInfo(), aurEff->GetAuraType(), aurEff->GetAmount(), - aura->GetEffectMask(), removeOtherAuraApplications)) + if (!IsHighestExclusiveAuraEffect(aura->GetSpellInfo(), aurEff->GetAuraType(), aurEff->GetAmount(), aura->GetEffectMask(), removeOtherAuraApplications)) return false; return true; } -bool Unit::IsHighestExclusiveAuraEffect(SpellInfo const* spellInfo, AuraType auraType, int32 effectAmount, uint8 auraEffectMask, - bool removeOtherAuraApplications /*= false*/) +bool Unit::IsHighestExclusiveAuraEffect(SpellInfo const* spellInfo, AuraType auraType, int32 effectAmount, uint8 auraEffectMask, bool removeOtherAuraApplications /*= false*/) { AuraEffectList const& auras = GetAuraEffectsByType(auraType); for (Unit::AuraEffectList::const_iterator itr = auras.begin(); itr != auras.end();) @@ -15070,14 +14963,12 @@ bool Unit::IsHighestExclusiveAuraEffect(SpellInfo const* spellInfo, AuraType aur AuraEffect const* existingAurEff = (*itr); ++itr; - if (sSpellMgr->CheckSpellGroupStackRules(spellInfo, existingAurEff->GetSpellInfo()) == - SPELL_GROUP_STACK_RULE_EXCLUSIVE_HIGHEST) + if (sSpellMgr->CheckSpellGroupStackRules(spellInfo, existingAurEff->GetSpellInfo()) == SPELL_GROUP_STACK_RULE_EXCLUSIVE_HIGHEST) { int32 diff = abs(effectAmount) - abs(existingAurEff->GetAmount()); if (!diff) for (int32 i = 0; i < MAX_SPELL_EFFECTS; ++i) - diff += int32((auraEffectMask & (1 << i)) >> i) - - int32((existingAurEff->GetBase()->GetEffectMask() & (1 << i)) >> i); + diff += int32((auraEffectMask & (1 << i)) >> i) - int32((existingAurEff->GetBase()->GetEffectMask() & (1 << i)) >> i); if (diff > 0) { @@ -15107,8 +14998,7 @@ void Unit::Talk(std::string const& text, ChatMsg msgType, Language language, flo { Firelands::CustomChatTextBuilder builder(this, msgType, text, language, target); Firelands::LocalizedPacketDo localizer(builder); - Firelands::PlayerDistWorker> worker( - this, textRange, localizer); + Firelands::PlayerDistWorker> worker(this, textRange, localizer); Cell::VisitWorldObjects(this, worker, textRange); } @@ -15124,8 +15014,7 @@ void Unit::Yell(std::string const& text, Language language, WorldObject const* t void Unit::TextEmote(std::string const& text, WorldObject const* target /*= nullptr*/, bool isBossEmote /*= false*/) { - Talk(text, isBossEmote ? CHAT_MSG_RAID_BOSS_EMOTE : CHAT_MSG_MONSTER_EMOTE, LANG_UNIVERSAL, - sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE), target); + Talk(text, isBossEmote ? CHAT_MSG_RAID_BOSS_EMOTE : CHAT_MSG_MONSTER_EMOTE, LANG_UNIVERSAL, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE), target); } void Unit::Whisper(std::string const& text, Language language, Player* target, bool isBossWhisper /*= false*/) @@ -15135,8 +15024,7 @@ void Unit::Whisper(std::string const& text, Language language, Player* target, b LocaleConstant locale = target->GetSession()->GetSessionDbLocaleIndex(); WorldPacket data; - ChatHandler::BuildChatPacket( - data, isBossWhisper ? CHAT_MSG_RAID_BOSS_WHISPER : CHAT_MSG_MONSTER_WHISPER, language, this, target, text, 0, "", locale); + ChatHandler::BuildChatPacket(data, isBossWhisper ? CHAT_MSG_RAID_BOSS_WHISPER : CHAT_MSG_MONSTER_WHISPER, language, this, target, text, 0, "", locale); target->SendDirectMessage(&data); } @@ -15166,8 +15054,7 @@ void Unit::Yell(uint32 textId, WorldObject const* target /*= nullptr*/) void Unit::TextEmote(uint32 textId, WorldObject const* target /*= nullptr*/, bool isBossEmote /*= false*/) { - Talk(textId, isBossEmote ? CHAT_MSG_RAID_BOSS_EMOTE : CHAT_MSG_MONSTER_EMOTE, - sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE), target); + Talk(textId, isBossEmote ? CHAT_MSG_RAID_BOSS_EMOTE : CHAT_MSG_MONSTER_EMOTE, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE), target); } void Unit::Whisper(uint32 textId, Player* target, bool isBossWhisper /*= false*/) @@ -15184,8 +15071,7 @@ void Unit::Whisper(uint32 textId, Player* target, bool isBossWhisper /*= false*/ LocaleConstant locale = target->GetSession()->GetSessionDbLocaleIndex(); WorldPacket data; - ChatHandler::BuildChatPacket(data, isBossWhisper ? CHAT_MSG_RAID_BOSS_WHISPER : CHAT_MSG_MONSTER_WHISPER, LANG_UNIVERSAL, - this, target, bct->GetText(locale, getGender()), 0, "", locale); + ChatHandler::BuildChatPacket(data, isBossWhisper ? CHAT_MSG_RAID_BOSS_WHISPER : CHAT_MSG_MONSTER_WHISPER, LANG_UNIVERSAL, this, target, bct->GetText(locale, getGender()), 0, "", locale); target->SendDirectMessage(&data); } @@ -15196,16 +15082,13 @@ float Unit::GetCollisionHeight() const if (IsMounted()) { - if (CreatureDisplayInfoEntry const* mountDisplayInfo = - sCreatureDisplayInfoStore.LookupEntry(GetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID))) + if (CreatureDisplayInfoEntry const* mountDisplayInfo = sCreatureDisplayInfoStore.LookupEntry(GetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID))) { if (CreatureModelDataEntry const* mountModelData = sCreatureModelDataStore.LookupEntry(mountDisplayInfo->ModelID)) { CreatureDisplayInfoEntry const* displayInfo = sCreatureDisplayInfoStore.AssertEntry(GetNativeDisplayId()); CreatureModelDataEntry const* modelData = sCreatureModelDataStore.AssertEntry(displayInfo->ModelID); - float const collisionHeight = - scaleMod * (mountModelData->MountHeight + - modelData->CollisionHeight * modelData->ModelScale * displayInfo->CreatureModelScale * 0.5f); + float const collisionHeight = scaleMod * (mountModelData->MountHeight + modelData->CollisionHeight * modelData->ModelScale * displayInfo->CreatureModelScale * 0.5f); return collisionHeight == 0.0f ? DEFAULT_COLLISION_HEIGHT : collisionHeight; } } @@ -15340,8 +15223,8 @@ void Unit::ProcessPendingSpellCastRequest() caster = charmer; } - if (caster->GetTypeId() == TYPEID_PLAYER && !caster->ToPlayer()->HasActiveSpell(spellInfo->Id) && - !spellInfo->IsRaidMarker() && !caster->ToPlayer()->HasArchProject(static_cast(spellInfo->ResearchProjectId))) + if (caster->GetTypeId() == TYPEID_PLAYER && !caster->ToPlayer()->HasActiveSpell(spellInfo->Id) && !spellInfo->IsRaidMarker() && + !caster->ToPlayer()->HasArchProject(static_cast(spellInfo->ResearchProjectId))) { bool allow = false; @@ -15480,8 +15363,7 @@ void Unit::ProcessItemCast(PendingSpellCastRequest const& castRequest, SpellCast } // only allow conjured consumable, bandage, poisons (all should have the 2^21 item flag set in DB) - if (proto->GetClass() == ITEM_CLASS_CONSUMABLE && !(proto->GetFlags() & ITEM_FLAG_IGNORE_DEFAULT_ARENA_RESTRICTIONS) && - player->InArena()) + if (proto->GetClass() == ITEM_CLASS_CONSUMABLE && !(proto->GetFlags() & ITEM_FLAG_IGNORE_DEFAULT_ARENA_RESTRICTIONS) && player->InArena()) { player->SendEquipError(EQUIP_ERR_NOT_DURING_ARENA_MATCH, item, nullptr); return; @@ -15510,8 +15392,7 @@ void Unit::ProcessItemCast(PendingSpellCastRequest const& castRequest, SpellCast } // check also BIND_ON_ACQUIRE and BIND_QUEST for .additem or .additemset case by GM (not binded at adding to inventory) - if (item->GetTemplate()->GetBonding() == BIND_ON_USE || item->GetTemplate()->GetBonding() == BIND_ON_ACQUIRE || - item->GetTemplate()->GetBonding() == BIND_QUEST) + if (item->GetTemplate()->GetBonding() == BIND_ON_USE || item->GetTemplate()->GetBonding() == BIND_ON_ACQUIRE || item->GetTemplate()->GetBonding() == BIND_QUEST) { if (!item->IsSoulBound()) { @@ -15530,7 +15411,10 @@ void Unit::ProcessItemCast(PendingSpellCastRequest const& castRequest, SpellCast } } -void Unit::SetGameClientMovingMe(GameClient* gameClientMovingMe) { _gameClientMovingMe = gameClientMovingMe; } +void Unit::SetGameClientMovingMe(GameClient* gameClientMovingMe) +{ + _gameClientMovingMe = gameClientMovingMe; +} void Unit::GetAttackableUnitListInRange(std::list& list, float fMaxSearchRange) const { @@ -15541,10 +15425,8 @@ void Unit::GetAttackableUnitListInRange(std::list& list, float fMaxSearch Firelands::AttackableUnitInObjectRangeCheck u_check(this, fMaxSearchRange); Firelands::UnitListSearcher searcher(this, list, u_check); - TypeContainerVisitor, WorldTypeMapContainer> - world_unit_searcher(searcher); - TypeContainerVisitor, GridTypeMapContainer> - grid_unit_searcher(searcher); + TypeContainerVisitor, WorldTypeMapContainer> world_unit_searcher(searcher); + TypeContainerVisitor, GridTypeMapContainer> grid_unit_searcher(searcher); cell.Visit(p, world_unit_searcher, *GetMap(), *this, fMaxSearchRange); cell.Visit(p, grid_unit_searcher, *GetMap(), *this, fMaxSearchRange); @@ -15559,10 +15441,8 @@ void Unit::GetFriendlyUnitListInRange(std::list& list, float fMaxSearchRa Firelands::AnyFriendlyUnitInObjectRangeCheck u_check(this, this, fMaxSearchRange, false, exceptSelf); Firelands::UnitListSearcher searcher(this, list, u_check); - TypeContainerVisitor, WorldTypeMapContainer> - world_unit_searcher(searcher); - TypeContainerVisitor, GridTypeMapContainer> - grid_unit_searcher(searcher); + TypeContainerVisitor, WorldTypeMapContainer> world_unit_searcher(searcher); + TypeContainerVisitor, GridTypeMapContainer> grid_unit_searcher(searcher); cell.Visit(p, world_unit_searcher, *GetMap(), *this, fMaxSearchRange); cell.Visit(p, grid_unit_searcher, *GetMap(), *this, fMaxSearchRange); @@ -15577,10 +15457,8 @@ void Unit::GetAreatriggerListInRange(std::list& list, float fMaxSe Firelands::AnyAreatriggerInObjectRangeCheck l_Check(this, fMaxSearchRange); Firelands::AreaTriggerListSearcher searcher(this, list, l_Check); - TypeContainerVisitor, WorldTypeMapContainer> - l_WorldSearcher(searcher); - TypeContainerVisitor, GridTypeMapContainer> - l_GridSearcher(searcher); + TypeContainerVisitor, WorldTypeMapContainer> l_WorldSearcher(searcher); + TypeContainerVisitor, GridTypeMapContainer> l_GridSearcher(searcher); l_Cell.Visit(l_Coords, l_WorldSearcher, *GetMap(), *this, fMaxSearchRange); l_Cell.Visit(l_Coords, l_GridSearcher, *GetMap(), *this, fMaxSearchRange); @@ -15595,10 +15473,8 @@ void Unit::GetAreaTriggerListWithSpellIDInRange(std::list& list, u Firelands::AnyAreatriggerInObjectRangeCheck l_Check(this, fMaxSearchRange); Firelands::AreaTriggerListSearcher searcher(this, list, l_Check); - TypeContainerVisitor, WorldTypeMapContainer> - l_WorldSearcher(searcher); - TypeContainerVisitor, GridTypeMapContainer> - l_GridSearcher(searcher); + TypeContainerVisitor, WorldTypeMapContainer> l_WorldSearcher(searcher); + TypeContainerVisitor, GridTypeMapContainer> l_GridSearcher(searcher); l_Cell.Visit(l_Coords, l_WorldSearcher, *GetMap(), *this, fMaxSearchRange); l_Cell.Visit(l_Coords, l_GridSearcher, *GetMap(), *this, fMaxSearchRange); diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index dab7c127..08124479 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -18,51 +18,51 @@ #ifndef __UNIT_H #define __UNIT_H -#include "Object.h" -#include "EventProcessor.h" #include "CombatManager.h" +#include "EventProcessor.h" +#include "Object.h" #include "SpellAuraDefines.h" #include "SpellDefines.h" +#include "SpellPacketsCommon.h" #include "TaskScheduler.h" #include "ThreatManager.h" #include "Timer.h" -#include "SpellPacketsCommon.h" #include "UnitDefines.h" #include "Util.h" #include #include #include -#include #include +#include -#define WORLD_TRIGGER 12999 +#define WORLD_TRIGGER 12999 -#define MAX_SPELL_CHARM 4 -#define MAX_SPELL_VEHICLE 6 -#define MAX_SPELL_POSSESS 8 -#define MAX_SPELL_CONTROL_BAR 10 +#define MAX_SPELL_CHARM 4 +#define MAX_SPELL_VEHICLE 6 +#define MAX_SPELL_POSSESS 8 +#define MAX_SPELL_CONTROL_BAR 10 #define MAX_AGGRO_RESET_TIME 10 // in seconds #define MAX_AGGRO_RADIUS 45.0f // yards enum VictimState { - VICTIMSTATE_INTACT = 0, // set when attacker misses - VICTIMSTATE_HIT = 1, // victim got clear/blocked hit - VICTIMSTATE_DODGE = 2, - VICTIMSTATE_PARRY = 3, - VICTIMSTATE_INTERRUPT = 4, - VICTIMSTATE_BLOCKS = 5, // unused? not set when blocked, even on full block - VICTIMSTATE_EVADES = 6, - VICTIMSTATE_IS_IMMUNE = 7, - VICTIMSTATE_DEFLECTS = 8 + VICTIMSTATE_INTACT = 0, // set when attacker misses + VICTIMSTATE_HIT = 1, // victim got clear/blocked hit + VICTIMSTATE_DODGE = 2, + VICTIMSTATE_PARRY = 3, + VICTIMSTATE_INTERRUPT = 4, + VICTIMSTATE_BLOCKS = 5, // unused? not set when blocked, even on full block + VICTIMSTATE_EVADES = 6, + VICTIMSTATE_IS_IMMUNE = 7, + VICTIMSTATE_DEFLECTS = 8 }; -//i would like to remove this: (it is defined in item.h +// i would like to remove this: (it is defined in item.h enum InventorySlot { - NULL_BAG = 0, - NULL_SLOT = 255 + NULL_BAG = 0, + NULL_SLOT = 255 }; struct AbstractPursuer; @@ -100,36 +100,45 @@ enum ZLiquidStatus : uint32; namespace Movement { - class ExtraMovementStatusElement; - class MoveSpline; -} +class ExtraMovementStatusElement; +class MoveSpline; +} // namespace Movement typedef std::list UnitList; class DispelableAura { - public: - DispelableAura(Aura* aura, int32 dispelChance, uint8 dispelCharges); - ~DispelableAura(); - - Aura* GetAura() const { return _aura; } - bool RollDispel() const; - uint8 GetDispelCharges() const { return _charges; } - - void IncrementCharges() { ++_charges; } - bool DecrementCharge() - { - if (!_charges) - return false; - - --_charges; - return _charges > 0; - } - - private: - Aura* _aura; - int32 _chance; - uint8 _charges; + public: + DispelableAura(Aura* aura, int32 dispelChance, uint8 dispelCharges); + ~DispelableAura(); + + Aura* GetAura() const + { + return _aura; + } + bool RollDispel() const; + uint8 GetDispelCharges() const + { + return _charges; + } + + void IncrementCharges() + { + ++_charges; + } + bool DecrementCharge() + { + if (!_charges) + return false; + + --_charges; + return _charges > 0; + } + + private: + Aura* _aura; + int32 _chance; + uint8 _charges; }; typedef std::vector DispelChargesList; @@ -157,24 +166,24 @@ enum WeaponDamageRange enum UnitMods { - UNIT_MOD_STAT_STRENGTH, // UNIT_MOD_STAT_STRENGTH..UNIT_MOD_STAT_SPIRIT must be in existed order, it's accessed by index values of Stats enum. + UNIT_MOD_STAT_STRENGTH, // UNIT_MOD_STAT_STRENGTH..UNIT_MOD_STAT_SPIRIT must be in existed order, it's accessed by index values of Stats enum. UNIT_MOD_STAT_AGILITY, UNIT_MOD_STAT_STAMINA, UNIT_MOD_STAT_INTELLECT, UNIT_MOD_STAT_SPIRIT, UNIT_MOD_HEALTH, - UNIT_MOD_MANA, // UNIT_MOD_MANA..UNIT_MOD_RUNIC_POWER must be in existed order, it's accessed by index values of Powers enum. + UNIT_MOD_MANA, // UNIT_MOD_MANA..UNIT_MOD_RUNIC_POWER must be in existed order, it's accessed by index values of Powers enum. UNIT_MOD_RAGE, UNIT_MOD_FOCUS, UNIT_MOD_ENERGY, - UNIT_MOD_UNUSED, // Old UNIT_MOD_HAPPINESS + UNIT_MOD_UNUSED, // Old UNIT_MOD_HAPPINESS UNIT_MOD_RUNE, UNIT_MOD_RUNIC_POWER, UNIT_MOD_SOUL_SHARDS, UNIT_MOD_ECLIPSE, UNIT_MOD_HOLY_POWER, UNIT_MOD_ALTERNATIVE, - UNIT_MOD_ARMOR, // UNIT_MOD_ARMOR..UNIT_MOD_RESISTANCE_ARCANE must be in existed order, it's accessed by index values of SpellSchools enum. + UNIT_MOD_ARMOR, // UNIT_MOD_ARMOR..UNIT_MOD_RESISTANCE_ARCANE must be in existed order, it's accessed by index values of SpellSchools enum. UNIT_MOD_RESISTANCE_HOLY, UNIT_MOD_RESISTANCE_FIRE, UNIT_MOD_RESISTANCE_NATURE, @@ -214,63 +223,62 @@ enum BaseModType enum DeathState { - ALIVE = 0, - JUST_DIED = 1, - CORPSE = 2, - DEAD = 3, + ALIVE = 0, + JUST_DIED = 1, + CORPSE = 2, + DEAD = 3, JUST_RESPAWNED = 4 }; enum UnitState : uint32 { - UNIT_STATE_DIED = 0x00000001, // player has fake death aura - UNIT_STATE_MELEE_ATTACKING = 0x00000002, // player is melee attacking someone - UNIT_STATE_CHARMED = 0x00000004, // having any kind of charm aura on self - UNIT_STATE_STUNNED = 0x00000008, - UNIT_STATE_ROAMING = 0x00000010, - UNIT_STATE_CHASE = 0x00000020, - UNIT_STATE_FOCUSING = 0x00000040, - UNIT_STATE_FLEEING = 0x00000080, - UNIT_STATE_IN_FLIGHT = 0x00000100, // player is in flight mode - UNIT_STATE_FOLLOW = 0x00000200, - UNIT_STATE_ROOT = 0x00000400, - UNIT_STATE_CONFUSED = 0x00000800, - UNIT_STATE_DISTRACTED = 0x00001000, - UNIT_STATE_ISOLATED = 0x00002000, // area auras do not affect other players - UNIT_STATE_ATTACK_PLAYER = 0x00004000, - UNIT_STATE_CASTING = 0x00008000, - UNIT_STATE_POSSESSED = 0x00010000, // being possessed by another unit - UNIT_STATE_CHARGING = 0x00020000, - UNIT_STATE_JUMPING = 0x00040000, - UNIT_STATE_MOVE = 0x00100000, - UNIT_STATE_ROTATING = 0x00200000, - UNIT_STATE_EVADE = 0x00400000, - UNIT_STATE_ROAMING_MOVE = 0x00800000, - UNIT_STATE_CONFUSED_MOVE = 0x01000000, - UNIT_STATE_FLEEING_MOVE = 0x02000000, - UNIT_STATE_CHASE_MOVE = 0x04000000, - UNIT_STATE_FOLLOW_MOVE = 0x08000000, - UNIT_STATE_IGNORE_PATHFINDING = 0x10000000, // do not use pathfinding in any MovementGenerator - - UNIT_STATE_ALL_STATE_SUPPORTED = UNIT_STATE_DIED | UNIT_STATE_MELEE_ATTACKING | UNIT_STATE_CHARMED | UNIT_STATE_STUNNED | UNIT_STATE_ROAMING | UNIT_STATE_CHASE - | UNIT_STATE_FOCUSING | UNIT_STATE_FLEEING | UNIT_STATE_IN_FLIGHT | UNIT_STATE_FOLLOW | UNIT_STATE_ROOT | UNIT_STATE_CONFUSED - | UNIT_STATE_DISTRACTED | UNIT_STATE_ISOLATED | UNIT_STATE_ATTACK_PLAYER | UNIT_STATE_CASTING - | UNIT_STATE_POSSESSED | UNIT_STATE_CHARGING | UNIT_STATE_JUMPING | UNIT_STATE_MOVE | UNIT_STATE_ROTATING - | UNIT_STATE_EVADE | UNIT_STATE_ROAMING_MOVE | UNIT_STATE_CONFUSED_MOVE | UNIT_STATE_FLEEING_MOVE - | UNIT_STATE_CHASE_MOVE | UNIT_STATE_FOLLOW_MOVE | UNIT_STATE_IGNORE_PATHFINDING, - - UNIT_STATE_UNATTACKABLE = UNIT_STATE_IN_FLIGHT, - UNIT_STATE_MOVING = UNIT_STATE_ROAMING_MOVE | UNIT_STATE_CONFUSED_MOVE | UNIT_STATE_FLEEING_MOVE | UNIT_STATE_CHASE_MOVE | UNIT_STATE_FOLLOW_MOVE, - UNIT_STATE_CONTROLLED = UNIT_STATE_CONFUSED | UNIT_STATE_STUNNED | UNIT_STATE_FLEEING, + UNIT_STATE_DIED = 0x00000001, // player has fake death aura + UNIT_STATE_MELEE_ATTACKING = 0x00000002, // player is melee attacking someone + UNIT_STATE_CHARMED = 0x00000004, // having any kind of charm aura on self + UNIT_STATE_STUNNED = 0x00000008, + UNIT_STATE_ROAMING = 0x00000010, + UNIT_STATE_CHASE = 0x00000020, + UNIT_STATE_FOCUSING = 0x00000040, + UNIT_STATE_FLEEING = 0x00000080, + UNIT_STATE_IN_FLIGHT = 0x00000100, // player is in flight mode + UNIT_STATE_FOLLOW = 0x00000200, + UNIT_STATE_ROOT = 0x00000400, + UNIT_STATE_CONFUSED = 0x00000800, + UNIT_STATE_DISTRACTED = 0x00001000, + UNIT_STATE_ISOLATED = 0x00002000, // area auras do not affect other players + UNIT_STATE_ATTACK_PLAYER = 0x00004000, + UNIT_STATE_CASTING = 0x00008000, + UNIT_STATE_POSSESSED = 0x00010000, // being possessed by another unit + UNIT_STATE_CHARGING = 0x00020000, + UNIT_STATE_JUMPING = 0x00040000, + UNIT_STATE_MOVE = 0x00100000, + UNIT_STATE_ROTATING = 0x00200000, + UNIT_STATE_EVADE = 0x00400000, + UNIT_STATE_ROAMING_MOVE = 0x00800000, + UNIT_STATE_CONFUSED_MOVE = 0x01000000, + UNIT_STATE_FLEEING_MOVE = 0x02000000, + UNIT_STATE_CHASE_MOVE = 0x04000000, + UNIT_STATE_FOLLOW_MOVE = 0x08000000, + UNIT_STATE_IGNORE_PATHFINDING = 0x10000000, // do not use pathfinding in any MovementGenerator + + UNIT_STATE_ALL_STATE_SUPPORTED = UNIT_STATE_DIED | UNIT_STATE_MELEE_ATTACKING | UNIT_STATE_CHARMED | UNIT_STATE_STUNNED | UNIT_STATE_ROAMING | UNIT_STATE_CHASE | UNIT_STATE_FOCUSING | + UNIT_STATE_FLEEING | UNIT_STATE_IN_FLIGHT | UNIT_STATE_FOLLOW | UNIT_STATE_ROOT | UNIT_STATE_CONFUSED | UNIT_STATE_DISTRACTED | UNIT_STATE_ISOLATED | + UNIT_STATE_ATTACK_PLAYER | UNIT_STATE_CASTING | UNIT_STATE_POSSESSED | UNIT_STATE_CHARGING | UNIT_STATE_JUMPING | UNIT_STATE_MOVE | UNIT_STATE_ROTATING | + UNIT_STATE_EVADE | UNIT_STATE_ROAMING_MOVE | UNIT_STATE_CONFUSED_MOVE | UNIT_STATE_FLEEING_MOVE | UNIT_STATE_CHASE_MOVE | UNIT_STATE_FOLLOW_MOVE | + UNIT_STATE_IGNORE_PATHFINDING, + + UNIT_STATE_UNATTACKABLE = UNIT_STATE_IN_FLIGHT, + UNIT_STATE_MOVING = UNIT_STATE_ROAMING_MOVE | UNIT_STATE_CONFUSED_MOVE | UNIT_STATE_FLEEING_MOVE | UNIT_STATE_CHASE_MOVE | UNIT_STATE_FOLLOW_MOVE, + UNIT_STATE_CONTROLLED = UNIT_STATE_CONFUSED | UNIT_STATE_STUNNED | UNIT_STATE_FLEEING, UNIT_STATE_CANT_CLIENT_CONTROL = UNIT_STATE_CHARMED | UNIT_STATE_FLEEING | UNIT_STATE_CONFUSED | UNIT_STATE_POSSESSED, - UNIT_STATE_LOST_CONTROL = UNIT_STATE_CONTROLLED | UNIT_STATE_JUMPING | UNIT_STATE_CHARGING, - UNIT_STATE_CANNOT_AUTOATTACK = UNIT_STATE_CONTROLLED | UNIT_STATE_CHARGING | UNIT_STATE_CASTING, - UNIT_STATE_SIGHTLESS = UNIT_STATE_LOST_CONTROL | UNIT_STATE_EVADE, - UNIT_STATE_CANNOT_TURN = UNIT_STATE_LOST_CONTROL | UNIT_STATE_ROTATING | UNIT_STATE_FOCUSING, - UNIT_STATE_NOT_MOVE = UNIT_STATE_ROOT | UNIT_STATE_STUNNED | UNIT_STATE_DIED | UNIT_STATE_DISTRACTED, - - UNIT_STATE_ALL_ERASABLE = UNIT_STATE_ALL_STATE_SUPPORTED & ~(UNIT_STATE_IGNORE_PATHFINDING), - UNIT_STATE_ALL_STATE = 0xffffffff + UNIT_STATE_LOST_CONTROL = UNIT_STATE_CONTROLLED | UNIT_STATE_JUMPING | UNIT_STATE_CHARGING, + UNIT_STATE_CANNOT_AUTOATTACK = UNIT_STATE_CONTROLLED | UNIT_STATE_CHARGING | UNIT_STATE_CASTING, + UNIT_STATE_SIGHTLESS = UNIT_STATE_LOST_CONTROL | UNIT_STATE_EVADE, + UNIT_STATE_CANNOT_TURN = UNIT_STATE_LOST_CONTROL | UNIT_STATE_ROTATING | UNIT_STATE_FOCUSING, + UNIT_STATE_NOT_MOVE = UNIT_STATE_ROOT | UNIT_STATE_STUNNED | UNIT_STATE_DIED | UNIT_STATE_DISTRACTED, + + UNIT_STATE_ALL_ERASABLE = UNIT_STATE_ALL_STATE_SUPPORTED & ~(UNIT_STATE_IGNORE_PATHFINDING), + UNIT_STATE_ALL_STATE = 0xffffffff }; FC_GAME_API extern float baseMoveSpeed[MAX_MOVE_TYPE]; @@ -312,7 +320,7 @@ struct PlayerMovementPendingChange uint32 time; float newValue = 0.0f; // used if speed or height change - bool apply = false; // used if movement flag change + bool apply = false; // used if movement flag change struct KnockbackInfo { float vcos = 0.0f; @@ -324,64 +332,66 @@ struct PlayerMovementPendingChange enum CombatRating { - CR_WEAPON_SKILL = 0, - CR_DEFENSE_SKILL = 1, // Removed in 4.0.1 - CR_DODGE = 2, - CR_PARRY = 3, - CR_BLOCK = 4, - CR_HIT_MELEE = 5, - CR_HIT_RANGED = 6, - CR_HIT_SPELL = 7, - CR_CRIT_MELEE = 8, - CR_CRIT_RANGED = 9, - CR_CRIT_SPELL = 10, - CR_HIT_TAKEN_MELEE = 11, // Deprecated since Cataclysm - CR_HIT_TAKEN_RANGED = 12, // Deprecated since Cataclysm - CR_HIT_TAKEN_SPELL = 13, // Deprecated since Cataclysm - CR_RESILIENCE_CRIT_TAKEN = 14, - CR_RESILIENCE_PLAYER_DAMAGE_TAKEN = 15, - CR_CRIT_TAKEN_SPELL = 16, // Deprecated since Cataclysm - CR_HASTE_MELEE = 17, - CR_HASTE_RANGED = 18, - CR_HASTE_SPELL = 19, - CR_WEAPON_SKILL_MAINHAND = 20, - CR_WEAPON_SKILL_OFFHAND = 21, - CR_WEAPON_SKILL_RANGED = 22, - CR_EXPERTISE = 23, - CR_ARMOR_PENETRATION = 24, - CR_MASTERY = 25, + CR_WEAPON_SKILL = 0, + CR_DEFENSE_SKILL = 1, // Removed in 4.0.1 + CR_DODGE = 2, + CR_PARRY = 3, + CR_BLOCK = 4, + CR_HIT_MELEE = 5, + CR_HIT_RANGED = 6, + CR_HIT_SPELL = 7, + CR_CRIT_MELEE = 8, + CR_CRIT_RANGED = 9, + CR_CRIT_SPELL = 10, + CR_HIT_TAKEN_MELEE = 11, // Deprecated since Cataclysm + CR_HIT_TAKEN_RANGED = 12, // Deprecated since Cataclysm + CR_HIT_TAKEN_SPELL = 13, // Deprecated since Cataclysm + CR_RESILIENCE_CRIT_TAKEN = 14, + CR_RESILIENCE_PLAYER_DAMAGE_TAKEN = 15, + CR_CRIT_TAKEN_SPELL = 16, // Deprecated since Cataclysm + CR_HASTE_MELEE = 17, + CR_HASTE_RANGED = 18, + CR_HASTE_SPELL = 19, + CR_WEAPON_SKILL_MAINHAND = 20, + CR_WEAPON_SKILL_OFFHAND = 21, + CR_WEAPON_SKILL_RANGED = 22, + CR_EXPERTISE = 23, + CR_ARMOR_PENETRATION = 24, + CR_MASTERY = 25, }; -#define MAX_COMBAT_RATING 26 +#define MAX_COMBAT_RATING 26 enum DamageEffectType : uint8 { - DIRECT_DAMAGE = 0, // used for normal weapon damage (not for class abilities or spells) - SPELL_DIRECT_DAMAGE = 1, // spell/class abilities damage - DOT = 2, - HEAL = 3, - NODAMAGE = 4, // used also in case when damage applied to health but not applied to spell channelInterruptFlags/etc - SELF_DAMAGE = 5 + DIRECT_DAMAGE = 0, // used for normal weapon damage (not for class abilities or spells) + SPELL_DIRECT_DAMAGE = 1, // spell/class abilities damage + DOT = 2, + HEAL = 3, + NODAMAGE = 4, // used also in case when damage applied to health but not applied to spell channelInterruptFlags/etc + SELF_DAMAGE = 5 }; enum UnitTypeMask { - UNIT_MASK_NONE = 0x00000000, - UNIT_MASK_SUMMON = 0x00000001, - UNIT_MASK_MINION = 0x00000002, - UNIT_MASK_GUARDIAN = 0x00000004, - UNIT_MASK_TOTEM = 0x00000008, - UNIT_MASK_PET = 0x00000010, - UNIT_MASK_VEHICLE = 0x00000020, - UNIT_MASK_PUPPET = 0x00000040, - UNIT_MASK_HUNTER_PET = 0x00000080, - UNIT_MASK_CONTROLABLE_GUARDIAN = 0x00000100, - UNIT_MASK_ACCESSORY = 0x00000200 + UNIT_MASK_NONE = 0x00000000, + UNIT_MASK_SUMMON = 0x00000001, + UNIT_MASK_MINION = 0x00000002, + UNIT_MASK_GUARDIAN = 0x00000004, + UNIT_MASK_TOTEM = 0x00000008, + UNIT_MASK_PET = 0x00000010, + UNIT_MASK_VEHICLE = 0x00000020, + UNIT_MASK_PUPPET = 0x00000040, + UNIT_MASK_HUNTER_PET = 0x00000080, + UNIT_MASK_CONTROLABLE_GUARDIAN = 0x00000100, + UNIT_MASK_ACCESSORY = 0x00000200 }; struct DiminishingReturn { - DiminishingReturn() : stack(0), hitTime(0), hitCount(DIMINISHING_LEVEL_1) { } + DiminishingReturn() : stack(0), hitTime(0), hitCount(DIMINISHING_LEVEL_1) + { + } void Clear() { @@ -390,37 +400,60 @@ struct DiminishingReturn hitCount = DIMINISHING_LEVEL_1; } - uint16 stack; - uint32 hitTime; - uint32 hitCount; + uint16 stack; + uint32 hitTime; + uint32 hitCount; }; enum MeleeHitOutcome : uint8 { - MELEE_HIT_EVADE, MELEE_HIT_MISS, MELEE_HIT_DODGE, MELEE_HIT_BLOCK, MELEE_HIT_PARRY, - MELEE_HIT_GLANCING, MELEE_HIT_CRIT, MELEE_HIT_CRUSHING, MELEE_HIT_NORMAL + MELEE_HIT_EVADE, + MELEE_HIT_MISS, + MELEE_HIT_DODGE, + MELEE_HIT_BLOCK, + MELEE_HIT_PARRY, + MELEE_HIT_GLANCING, + MELEE_HIT_CRIT, + MELEE_HIT_CRUSHING, + MELEE_HIT_NORMAL }; class DispelInfo { - public: - explicit DispelInfo(Unit* dispeller, uint32 dispellerSpellId, uint8 chargesRemoved) : - _dispellerUnit(dispeller), _dispellerSpell(dispellerSpellId), _chargesRemoved(chargesRemoved) { } - - Unit* GetDispeller() const { return _dispellerUnit; } - uint32 GetDispellerSpellId() const { return _dispellerSpell; } - uint8 GetRemovedCharges() const { return _chargesRemoved; } - void SetRemovedCharges(uint8 amount) { _chargesRemoved = amount; } - private: - Unit* _dispellerUnit; - uint32 _dispellerSpell; - uint8 _chargesRemoved; + public: + explicit DispelInfo(Unit* dispeller, uint32 dispellerSpellId, uint8 chargesRemoved) : _dispellerUnit(dispeller), _dispellerSpell(dispellerSpellId), _chargesRemoved(chargesRemoved) + { + } + + Unit* GetDispeller() const + { + return _dispellerUnit; + } + uint32 GetDispellerSpellId() const + { + return _dispellerSpell; + } + uint8 GetRemovedCharges() const + { + return _chargesRemoved; + } + void SetRemovedCharges(uint8 amount) + { + _chargesRemoved = amount; + } + + private: + Unit* _dispellerUnit; + uint32 _dispellerSpell; + uint8 _chargesRemoved; }; struct CleanDamage { - CleanDamage(uint32 mitigated, uint32 absorbed, WeaponAttackType _attackType, MeleeHitOutcome _hitOutCome) : - absorbed_damage(absorbed), mitigated_damage(mitigated), attackType(_attackType), hitOutCome(_hitOutCome) { } + CleanDamage(uint32 mitigated, uint32 absorbed, WeaponAttackType _attackType, MeleeHitOutcome _hitOutCome) + : absorbed_damage(absorbed), mitigated_damage(mitigated), attackType(_attackType), hitOutCome(_hitOutCome) + { + } uint32 absorbed_damage; uint32 mitigated_damage; @@ -434,114 +467,198 @@ struct SpellNonMeleeDamage; class FC_GAME_API DamageInfo { - private: - Unit* const m_attacker; - Unit* const m_victim; - uint32 m_damage; - SpellInfo const* const m_spellInfo; - SpellSchoolMask const m_schoolMask; - DamageEffectType const m_damageType; - WeaponAttackType m_attackType; - uint32 m_absorb; - uint32 m_resist; - uint32 m_block; - uint32 m_hitMask; - public: - DamageInfo(Unit* attacker, Unit* victim, uint32 damage, SpellInfo const* spellInfo, SpellSchoolMask schoolMask, DamageEffectType damageType, WeaponAttackType attackType); - explicit DamageInfo(CalcDamageInfo const& dmgInfo); - DamageInfo(SpellNonMeleeDamage const& spellNonMeleeDamage, DamageEffectType damageType, WeaponAttackType attackType, uint32 hitMask); - - void ModifyDamage(int32 amount); - void AbsorbDamage(uint32 amount); - void ResistDamage(uint32 amount); - void BlockDamage(uint32 amount); - - Unit* GetAttacker() const { return m_attacker; } - Unit* GetVictim() const { return m_victim; } - SpellInfo const* GetSpellInfo() const { return m_spellInfo; } - SpellSchoolMask GetSchoolMask() const { return m_schoolMask; } - DamageEffectType GetDamageType() const { return m_damageType; } - WeaponAttackType GetAttackType() const { return m_attackType; } - uint32 GetDamage() const { return m_damage; } - uint32 GetAbsorb() const { return m_absorb; } - uint32 GetResist() const { return m_resist; } - uint32 GetBlock() const { return m_block; } - - uint32 GetHitMask() const; + private: + Unit* const m_attacker; + Unit* const m_victim; + uint32 m_damage; + SpellInfo const* const m_spellInfo; + SpellSchoolMask const m_schoolMask; + DamageEffectType const m_damageType; + WeaponAttackType m_attackType; + uint32 m_absorb; + uint32 m_resist; + uint32 m_block; + uint32 m_hitMask; + + public: + DamageInfo(Unit* attacker, Unit* victim, uint32 damage, SpellInfo const* spellInfo, SpellSchoolMask schoolMask, DamageEffectType damageType, WeaponAttackType attackType); + explicit DamageInfo(CalcDamageInfo const& dmgInfo); + DamageInfo(SpellNonMeleeDamage const& spellNonMeleeDamage, DamageEffectType damageType, WeaponAttackType attackType, uint32 hitMask); + + void ModifyDamage(int32 amount); + void AbsorbDamage(uint32 amount); + void ResistDamage(uint32 amount); + void BlockDamage(uint32 amount); + + Unit* GetAttacker() const + { + return m_attacker; + } + Unit* GetVictim() const + { + return m_victim; + } + SpellInfo const* GetSpellInfo() const + { + return m_spellInfo; + } + SpellSchoolMask GetSchoolMask() const + { + return m_schoolMask; + } + DamageEffectType GetDamageType() const + { + return m_damageType; + } + WeaponAttackType GetAttackType() const + { + return m_attackType; + } + uint32 GetDamage() const + { + return m_damage; + } + uint32 GetAbsorb() const + { + return m_absorb; + } + uint32 GetResist() const + { + return m_resist; + } + uint32 GetBlock() const + { + return m_block; + } + + uint32 GetHitMask() const; }; class FC_GAME_API HealInfo { - private: - Unit* const _healer; - Unit* const _target; - uint32 _heal; - uint32 _effectiveHeal; - uint32 _absorb; - SpellInfo const* const _spellInfo; - SpellSchoolMask const _schoolMask; - uint32 _hitMask; - - public: - HealInfo(Unit* healer, Unit* target, uint32 heal, SpellInfo const* spellInfo, SpellSchoolMask schoolMask); - - void AbsorbHeal(uint32 amount); - void SetEffectiveHeal(uint32 amount) { _effectiveHeal = amount; } - - Unit* GetHealer() const { return _healer; } - Unit* GetTarget() const { return _target; } - uint32 GetHeal() const { return _heal; } - uint32 GetEffectiveHeal() const { return _effectiveHeal; } - uint32 GetAbsorb() const { return _absorb; } - SpellInfo const* GetSpellInfo() const { return _spellInfo; }; - SpellSchoolMask GetSchoolMask() const { return _schoolMask; }; - - uint32 GetHitMask() const; + private: + Unit* const _healer; + Unit* const _target; + uint32 _heal; + uint32 _effectiveHeal; + uint32 _absorb; + SpellInfo const* const _spellInfo; + SpellSchoolMask const _schoolMask; + uint32 _hitMask; + + public: + HealInfo(Unit* healer, Unit* target, uint32 heal, SpellInfo const* spellInfo, SpellSchoolMask schoolMask); + + void AbsorbHeal(uint32 amount); + void SetEffectiveHeal(uint32 amount) + { + _effectiveHeal = amount; + } + + Unit* GetHealer() const + { + return _healer; + } + Unit* GetTarget() const + { + return _target; + } + uint32 GetHeal() const + { + return _heal; + } + uint32 GetEffectiveHeal() const + { + return _effectiveHeal; + } + uint32 GetAbsorb() const + { + return _absorb; + } + SpellInfo const* GetSpellInfo() const + { + return _spellInfo; + }; + SpellSchoolMask GetSchoolMask() const + { + return _schoolMask; + }; + + uint32 GetHitMask() const; }; class FC_GAME_API ProcEventInfo { - public: - ProcEventInfo(Unit* actor, Unit* actionTarget, Unit* procTarget, uint32 typeMask, - uint32 spellTypeMask, uint32 spellPhaseMask, uint32 hitMask, - Spell* spell, DamageInfo* damageInfo, HealInfo* healInfo); - - Unit* GetActor() { return _actor; } - Unit* GetActionTarget() const { return _actionTarget; } - Unit* GetProcTarget() const { return _procTarget; } - - uint32 GetTypeMask() const { return _typeMask; } - uint32 GetSpellTypeMask() const { return _spellTypeMask; } - uint32 GetSpellPhaseMask() const { return _spellPhaseMask; } - uint32 GetHitMask() const { return _hitMask; } - - SpellInfo const* GetSpellInfo() const; - SpellSchoolMask GetSchoolMask() const; - - DamageInfo* GetDamageInfo() const { return _damageInfo; } - HealInfo* GetHealInfo() const { return _healInfo; } - - Spell const* GetProcSpell() const { return _spell; } - - private: - Unit* const _actor; - Unit* const _actionTarget; - Unit* const _procTarget; - uint32 _typeMask; - uint32 _spellTypeMask; - uint32 _spellPhaseMask; - uint32 _hitMask; - Spell* _spell; - DamageInfo* _damageInfo; - HealInfo* _healInfo; + public: + ProcEventInfo( + Unit* actor, Unit* actionTarget, Unit* procTarget, uint32 typeMask, uint32 spellTypeMask, uint32 spellPhaseMask, uint32 hitMask, Spell* spell, DamageInfo* damageInfo, HealInfo* healInfo); + + Unit* GetActor() + { + return _actor; + } + Unit* GetActionTarget() const + { + return _actionTarget; + } + Unit* GetProcTarget() const + { + return _procTarget; + } + + uint32 GetTypeMask() const + { + return _typeMask; + } + uint32 GetSpellTypeMask() const + { + return _spellTypeMask; + } + uint32 GetSpellPhaseMask() const + { + return _spellPhaseMask; + } + uint32 GetHitMask() const + { + return _hitMask; + } + + SpellInfo const* GetSpellInfo() const; + SpellSchoolMask GetSchoolMask() const; + + DamageInfo* GetDamageInfo() const + { + return _damageInfo; + } + HealInfo* GetHealInfo() const + { + return _healInfo; + } + + Spell const* GetProcSpell() const + { + return _spell; + } + + private: + Unit* const _actor; + Unit* const _actionTarget; + Unit* const _procTarget; + uint32 _typeMask; + uint32 _spellTypeMask; + uint32 _spellPhaseMask; + uint32 _hitMask; + Spell* _spell; + DamageInfo* _damageInfo; + HealInfo* _healInfo; }; // Struct for use in Unit::CalculateMeleeDamage // Need create structure like in SMSG_ATTACKERSTATEUPDATE opcode struct CalcDamageInfo { - Unit *attacker; // Attacker - Unit *target; // Target for damage + Unit* attacker; // Attacker + Unit* target; // Target for damage uint32 damageSchoolMask; uint32 damage; uint32 absorb; @@ -549,79 +666,90 @@ struct CalcDamageInfo uint32 blocked_amount; uint32 HitInfo; uint32 TargetState; -// Helper + // Helper WeaponAttackType attackType; // uint32 procAttacker; uint32 procVictim; - uint32 cleanDamage; // Used only for rage calculation - MeleeHitOutcome hitOutCome; /// @todo remove this field (need use TargetState) + uint32 cleanDamage; // Used only for rage calculation + MeleeHitOutcome hitOutCome; /// @todo remove this field (need use TargetState) }; // Spell damage info structure based on structure sending in SMSG_SPELLNONMELEEDAMAGELOG opcode struct FC_GAME_API SpellNonMeleeDamage { SpellNonMeleeDamage(Unit* _attacker, Unit* _target, uint32 _SpellID, uint32 _schoolMask) - : target(_target), attacker(_attacker), SpellID(_SpellID), damage(0), overkill(0), schoolMask(_schoolMask), - absorb(0), resist(0), physicalLog(false), unused(false), blocked(0), HitInfo(0), cleanDamage(0), fullBlock(false) - { } + : target(_target), attacker(_attacker), SpellID(_SpellID), damage(0), overkill(0), schoolMask(_schoolMask), absorb(0), resist(0), physicalLog(false), unused(false), blocked(0), HitInfo(0), + cleanDamage(0), fullBlock(false) + { + } - Unit *target; - Unit *attacker; + Unit* target; + Unit* attacker; uint32 SpellID; uint32 damage; uint32 overkill; uint32 schoolMask; uint32 absorb; uint32 resist; - bool physicalLog; - bool unused; + bool physicalLog; + bool unused; uint32 blocked; uint32 HitInfo; // Used for help uint32 cleanDamage; - bool fullBlock; + bool fullBlock; }; struct SpellPeriodicAuraLogInfo { SpellPeriodicAuraLogInfo(AuraEffect const* _auraEff, uint32 _damage, uint32 _overDamage, uint32 _absorb, uint32 _resist, float _multiplier, bool _critical) - : auraEff(_auraEff), damage(_damage), overDamage(_overDamage), absorb(_absorb), resist(_resist), multiplier(_multiplier), critical(_critical){ } + : auraEff(_auraEff), damage(_damage), overDamage(_overDamage), absorb(_absorb), resist(_resist), multiplier(_multiplier), critical(_critical) + { + } AuraEffect const* auraEff; uint32 damage; - uint32 overDamage; // overkill/overheal + uint32 overDamage; // overkill/overheal uint32 absorb; uint32 resist; - float multiplier; - bool critical; + float multiplier; + bool critical; }; uint32 createProcHitMask(SpellNonMeleeDamage* damageInfo, SpellMissInfo missCondition); enum CurrentSpellTypes : uint8 { - CURRENT_MELEE_SPELL = 0, - CURRENT_GENERIC_SPELL = 1, - CURRENT_CHANNELED_SPELL = 2, - CURRENT_AUTOREPEAT_SPELL = 3 + CURRENT_MELEE_SPELL = 0, + CURRENT_GENERIC_SPELL = 1, + CURRENT_CHANNELED_SPELL = 2, + CURRENT_AUTOREPEAT_SPELL = 3 }; #define CURRENT_FIRST_NON_MELEE_SPELL 1 -#define CURRENT_MAX_SPELL 4 +#define CURRENT_MAX_SPELL 4 #define UNIT_ACTION_BUTTON_ACTION(X) (uint32(X) & 0x00FFFFFF) -#define UNIT_ACTION_BUTTON_TYPE(X) ((uint32(X) & 0xFF000000) >> 24) +#define UNIT_ACTION_BUTTON_TYPE(X) ((uint32(X) & 0xFF000000) >> 24) #define MAKE_UNIT_ACTION_BUTTON(A, T) (uint32(A) | (uint32(T) << 24)) struct UnitActionBarEntry { - UnitActionBarEntry() : packedData(uint32(ACT_DISABLED) << 24) { } + UnitActionBarEntry() : packedData(uint32(ACT_DISABLED) << 24) + { + } uint32 packedData; // helper - ActiveStates GetType() const { return ActiveStates(UNIT_ACTION_BUTTON_TYPE(packedData)); } - uint32 GetAction() const { return UNIT_ACTION_BUTTON_ACTION(packedData); } + ActiveStates GetType() const + { + return ActiveStates(UNIT_ACTION_BUTTON_TYPE(packedData)); + } + uint32 GetAction() const + { + return UNIT_ACTION_BUTTON_ACTION(packedData); + } bool IsActionBarForSpell() const { ActiveStates Type = GetType(); @@ -670,74 +798,91 @@ enum ActionBarIndex ACTION_BAR_INDEX_END = 10 }; -#define MAX_UNIT_ACTION_BAR_INDEX (ACTION_BAR_INDEX_END-ACTION_BAR_INDEX_START) +#define MAX_UNIT_ACTION_BAR_INDEX (ACTION_BAR_INDEX_END - ACTION_BAR_INDEX_START) struct FC_GAME_API CharmInfo { - public: - explicit CharmInfo(Unit* unit); - ~CharmInfo(); - void RestoreState(); - uint32 GetPetNumber() const { return _petnumber; } - void SetPetNumber(uint32 petnumber, bool statwindow); - - void SetCommandState(CommandStates st) { _CommandState = st; } - CommandStates GetCommandState() const { return _CommandState; } - bool HasCommandState(CommandStates state) const { return (_CommandState == state); } - - void InitPossessCreateSpells(); - void InitCharmCreateSpells(); - void InitPetActionBar(); - void InitEmptyActionBar(bool withAttack = true); - - //return true if successful - bool AddSpellToActionBar(SpellInfo const* spellInfo, ActiveStates newstate = ACT_DECIDE, uint8 preferredSlot = 0); - bool RemoveSpellFromActionBar(uint32 spell_id); - void LoadPetActionBar(const std::string& data); - void BuildActionBar(WorldPacket* data); - void SetSpellAutocast(SpellInfo const* spellInfo, bool state); - void SetActionBar(uint8 index, uint32 spellOrAction, ActiveStates type) - { - PetActionBar[index].SetActionAndType(spellOrAction, type); - } - UnitActionBarEntry const* GetActionBarEntry(uint8 index) const { return &(PetActionBar[index]); } - - void ToggleCreatureAutocast(SpellInfo const* spellInfo, bool apply); - - CharmSpellInfo* GetCharmSpell(uint8 index) { return &(_charmspells[index]); } - - void SetIsCommandAttack(bool val); - bool IsCommandAttack(); - void SetIsCommandFollow(bool val); - bool IsCommandFollow(); - void SetIsAtStay(bool val); - bool IsAtStay(); - void SetIsFollowing(bool val); - bool IsFollowing(); - void SetIsReturning(bool val); - bool IsReturning(); - void SaveStayPosition(); - void GetStayPosition(float &x, float &y, float &z); - - private: - - Unit* _unit; - UnitActionBarEntry PetActionBar[MAX_UNIT_ACTION_BAR_INDEX]; - CharmSpellInfo _charmspells[4]; - CommandStates _CommandState; - uint32 _petnumber; - - //for restoration after charmed - ReactStates _oldReactState; - - bool _isCommandAttack; - bool _isCommandFollow; - bool _isAtStay; - bool _isFollowing; - bool _isReturning; - float _stayX; - float _stayY; - float _stayZ; + public: + explicit CharmInfo(Unit* unit); + ~CharmInfo(); + void RestoreState(); + uint32 GetPetNumber() const + { + return _petnumber; + } + void SetPetNumber(uint32 petnumber, bool statwindow); + + void SetCommandState(CommandStates st) + { + _CommandState = st; + } + CommandStates GetCommandState() const + { + return _CommandState; + } + bool HasCommandState(CommandStates state) const + { + return (_CommandState == state); + } + + void InitPossessCreateSpells(); + void InitCharmCreateSpells(); + void InitPetActionBar(); + void InitEmptyActionBar(bool withAttack = true); + + // return true if successful + bool AddSpellToActionBar(SpellInfo const* spellInfo, ActiveStates newstate = ACT_DECIDE, uint8 preferredSlot = 0); + bool RemoveSpellFromActionBar(uint32 spell_id); + void LoadPetActionBar(const std::string& data); + void BuildActionBar(WorldPacket* data); + void SetSpellAutocast(SpellInfo const* spellInfo, bool state); + void SetActionBar(uint8 index, uint32 spellOrAction, ActiveStates type) + { + PetActionBar[index].SetActionAndType(spellOrAction, type); + } + UnitActionBarEntry const* GetActionBarEntry(uint8 index) const + { + return &(PetActionBar[index]); + } + + void ToggleCreatureAutocast(SpellInfo const* spellInfo, bool apply); + + CharmSpellInfo* GetCharmSpell(uint8 index) + { + return &(_charmspells[index]); + } + + void SetIsCommandAttack(bool val); + bool IsCommandAttack(); + void SetIsCommandFollow(bool val); + bool IsCommandFollow(); + void SetIsAtStay(bool val); + bool IsAtStay(); + void SetIsFollowing(bool val); + bool IsFollowing(); + void SetIsReturning(bool val); + bool IsReturning(); + void SaveStayPosition(); + void GetStayPosition(float& x, float& y, float& z); + + private: + Unit* _unit; + UnitActionBarEntry PetActionBar[MAX_UNIT_ACTION_BAR_INDEX]; + CharmSpellInfo _charmspells[4]; + CommandStates _CommandState; + uint32 _petnumber; + + // for restoration after charmed + ReactStates _oldReactState; + + bool _isCommandAttack; + bool _isCommandFollow; + bool _isAtStay; + bool _isFollowing; + bool _isReturning; + float _stayX; + float _stayY; + float _stayZ; }; // for clearing special attacks @@ -745,19 +890,19 @@ struct FC_GAME_API CharmInfo enum ReactiveType { - REACTIVE_DEFENSE = 0, + REACTIVE_DEFENSE = 0, REACTIVE_HUNTER_PARRY = 1, - REACTIVE_OVERPOWER = 2 + REACTIVE_OVERPOWER = 2 }; #define MAX_REACTIVE 3 enum PlayerTotemType { - SUMMON_TYPE_TOTEM_FIRE = 63, + SUMMON_TYPE_TOTEM_FIRE = 63, SUMMON_TYPE_TOTEM_EARTH = 81, SUMMON_TYPE_TOTEM_WATER = 82, - SUMMON_TYPE_TOTEM_AIR = 83 + SUMMON_TYPE_TOTEM_AIR = 83 }; struct PositionUpdateInfo @@ -774,8 +919,7 @@ struct PositionUpdateInfo struct SpellCastRequestItemData { - SpellCastRequestItemData(uint8 bagSlot, uint8 slot, ObjectGuid castItem) : - BagSlot(bagSlot), Slot(slot), CastItem(castItem) + SpellCastRequestItemData(uint8 bagSlot, uint8 slot, ObjectGuid castItem) : BagSlot(bagSlot), Slot(slot), CastItem(castItem) { } @@ -786,8 +930,7 @@ struct SpellCastRequestItemData struct PendingSpellCastRequest { - PendingSpellCastRequest(WorldPackets::Spells::SpellCastRequest&& castRequest, Optional castItemData = {}) : - CastRequest(castRequest), CastItemData(castItemData) + PendingSpellCastRequest(WorldPackets::Spells::SpellCastRequest&& castRequest, Optional castItemData = {}) : CastRequest(castRequest), CastItemData(castItemData) { } @@ -797,1295 +940,2022 @@ struct PendingSpellCastRequest // delay time next attack to prevent client attack animation problems #define ATTACK_DISPLAY_DELAY 200 -#define MAX_PLAYER_STEALTH_DETECT_RANGE 30.0f // max distance for detection targets by player +#define MAX_PLAYER_STEALTH_DETECT_RANGE 30.0f // max distance for detection targets by player class FC_GAME_API Unit : public WorldObject { friend class WorldSession; - public: - typedef std::set AttackerSet; - typedef std::set ControlList; - typedef std::vector UnitVector; - - typedef std::multimap AuraMap; - typedef std::pair AuraMapBounds; - typedef std::pair AuraMapBoundsNonConst; - - typedef std::multimap AuraApplicationMap; - typedef std::pair AuraApplicationMapBounds; - typedef std::pair AuraApplicationMapBoundsNonConst; - - typedef std::multimap AuraStateAurasMap; - typedef std::pair AuraStateAurasMapBounds; - - typedef std::list AuraEffectList; - typedef std::list AuraList; - typedef std::list AuraApplicationList; - - typedef std::vector> AuraApplicationProcContainer; - typedef std::vector FormationFollowerGUIDContainer; - - typedef std::map VisibleAuraMap; - - typedef std::unordered_map AurasBySpellIdMap; - - virtual ~Unit(); - - bool IsAIEnabled() const { return (i_AI != nullptr); } - void AIUpdateTick(uint32 diff); - UnitAI* GetAI() const { return i_AI.get(); } - void ScheduleAIChange(); - void PushAI(UnitAI* newAI); - bool PopAI(); - protected: - void SetAI(UnitAI* newAI); - UnitAI* GetTopAI() const { return i_AIs.empty() ? nullptr : i_AIs.top().get(); } - void RefreshAI(); - UnitAI* GetScheduledChangeAI(); - bool HasScheduledAIChange() const; - - public: - void AddToWorld() override; - void RemoveFromWorld() override; - - void CleanupBeforeRemoveFromMap(bool finalCleanup); - void CleanupsBeforeDelete(bool finalCleanup = true) override; // used in ~Creature/~Player (or before mass creature delete to remove cross-references to already deleted units) - - virtual bool IsAffectedByDiminishingReturns() const { return (GetCharmerOrOwnerPlayerOrPlayerItself() != nullptr); } - DiminishingLevels GetDiminishing(DiminishingGroup group) const; - void IncrDiminishing(SpellInfo const* auraSpellInfo, bool triggered); - bool ApplyDiminishingToDuration(SpellInfo const* auraSpellInfo, bool triggered, int32& duration, Unit* caster, DiminishingLevels previousLevel) const; - void ApplyDiminishingAura(DiminishingGroup group, bool apply); - void ClearDiminishings(); - - // target dependent range checks - float GetSpellMaxRangeForTarget(Unit const* target, SpellInfo const* spellInfo) const; - float GetSpellMinRangeForTarget(Unit const* target, SpellInfo const* spellInfo) const; - - virtual void Update(uint32 time) override; - - void setAttackTimer(WeaponAttackType type, uint32 time) { m_attackTimer[type] = time; } - void resetAttackTimer(WeaponAttackType type = BASE_ATTACK); - uint32 getAttackTimer(WeaponAttackType type) const { return m_attackTimer[type]; } - bool isAttackReady(WeaponAttackType type = BASE_ATTACK) const { return m_attackTimer[type] == 0; } - bool haveOffhandWeapon() const; - bool CanDualWield() const { return m_canDualWield; } - virtual void SetCanDualWield(bool value) { m_canDualWield = value; } - float GetCombatReach() const override { return m_floatValues[UNIT_FIELD_COMBATREACH]; } - float GetBoundaryRadius() const { return m_floatValues[UNIT_FIELD_BOUNDINGRADIUS]; } - bool IsWithinCombatRange(Unit const* obj, float dist2compare) const; - bool IsWithinMeleeRange(Unit const* obj) const { return IsWithinMeleeRangeAt(GetPosition(), obj); } - bool IsWithinMeleeRangeAt(Position const& pos, Unit const* obj) const; - bool IsWithinBoundaryRadius(const Unit* obj) const; - float GetMeleeRange(Unit const* target) const; - virtual SpellSchoolMask GetMeleeDamageSchoolMask() const; - uint32 m_extraAttacks; - bool m_canDualWield; - - void _addAttacker(Unit* pAttacker); // must be called only from Unit::Attack(Unit*) - void _removeAttacker(Unit* pAttacker); // must be called only from Unit::AttackStop() - Unit* getAttackerForHelper() const; // If someone wants to help, who to give them - bool Attack(Unit* victim, bool meleeAttack); - void CastStop(uint32 except_spellid = 0); - bool AttackStop(); - void RemoveAllAttackers(); - AttackerSet const& getAttackers() const { return m_attackers; } - bool isAttackingPlayer() const; - Unit* GetVictim() const { return m_attacking; } - // Use this only when 100% sure there is a victim - Unit* EnsureVictim() const - { - ASSERT(m_attacking); - return m_attacking; - } - - void ValidateAttackersAndOwnTarget(); - void CombatStop(bool includingCast = false, bool mutualPvP = true); - void CombatStopWithPets(bool includingCast = false); - void StopAttackFaction(uint32 faction_id); - Unit* SelectNearbyTarget(Unit* exclude = nullptr, float dist = NOMINAL_MELEE_RANGE) const; - void SendMeleeAttackStop(Unit* victim = nullptr); - void SendMeleeAttackStart(Unit* victim); - - void AddUnitState(uint32 f) { m_state |= f; } - bool HasUnitState(const uint32 f) const { return (m_state & f) != 0; } - void ClearUnitState(uint32 f) { m_state &= ~f; } - bool CanFreeMove() const; - - virtual void UpdatePowerRegeneration(Powers /*powerType*/) { } - - uint32 HasUnitTypeMask(uint32 mask) const { return mask & m_unitTypeMask; } - void AddUnitTypeMask(uint32 mask) { m_unitTypeMask |= mask; } - bool IsSummon() const { return (m_unitTypeMask & UNIT_MASK_SUMMON) != 0; } - bool IsMinion() const { return (m_unitTypeMask & UNIT_MASK_MINION) != 0; } - bool IsGuardian() const { return (m_unitTypeMask & UNIT_MASK_GUARDIAN) != 0; } - bool IsPet() const { return (m_unitTypeMask & UNIT_MASK_PET) != 0; } - bool IsHunterPet() const{ return (m_unitTypeMask & UNIT_MASK_HUNTER_PET) != 0; } - bool IsTotem() const { return (m_unitTypeMask & UNIT_MASK_TOTEM) != 0; } - bool IsVehicle() const { return (m_unitTypeMask & UNIT_MASK_VEHICLE) != 0; } - bool IsControlableGuardian() const { return (m_unitTypeMask & UNIT_MASK_CONTROLABLE_GUARDIAN) != 0; } - - uint8 getLevel() const { return uint8(GetUInt32Value(UNIT_FIELD_LEVEL)); } - uint8 getLevelForTarget(WorldObject const* /*target*/) const override { return getLevel(); } - void SetLevel(uint8 lvl); - uint8 getRace() const { return GetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_RACE); } - uint32 getRaceMask() const { return 1 << (getRace()-1); } - uint8 getClass() const { return GetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_CLASS); } - uint32 getClassMask() const { return 1 << (getClass()-1); } - uint8 getGender() const { return GetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_GENDER); } - - float GetStat(Stats stat) const { return float(GetUInt32Value(UNIT_FIELD_STAT0+stat)); } - void SetStat(Stats stat, int32 val) { SetStatInt32Value(UNIT_FIELD_STAT0+stat, val); } - uint32 GetArmor() const { return GetResistance(SPELL_SCHOOL_NORMAL); } - void SetArmor(int32 val) { SetResistance(SPELL_SCHOOL_NORMAL, val); } - - uint32 GetResistance(SpellSchools school) const { return GetUInt32Value(UNIT_FIELD_RESISTANCES+school); } - uint32 GetResistance(SpellSchoolMask mask) const; - void SetResistance(SpellSchools school, int32 val) { SetStatInt32Value(UNIT_FIELD_RESISTANCES+school, val); } - float CalculateAverageResistReduction(SpellSchoolMask schoolMask, Unit const* victim, SpellInfo const* spellInfo = nullptr) const; - - uint32 GetHealth() const { return GetUInt32Value(UNIT_FIELD_HEALTH); } - uint32 GetMaxHealth() const { return GetUInt32Value(UNIT_FIELD_MAXHEALTH); } - - bool IsFullHealth() const { return GetHealth() == GetMaxHealth(); } - bool HealthBelowPct(int32 pct) const { return GetHealth() < CountPctFromMaxHealth(pct); } - bool HealthBelowPctDamaged(int32 pct, uint32 damage) const { return int64(GetHealth()) - int64(damage) < int64(CountPctFromMaxHealth(pct)); } - bool HealthAbovePct(int32 pct) const { return GetHealth() > CountPctFromMaxHealth(pct); } - bool HealthAbovePctHealed(int32 pct, uint32 heal) const { return uint64(GetHealth()) + uint64(heal) > CountPctFromMaxHealth(pct); } - float GetHealthPct() const { return GetMaxHealth() ? 100.f * GetHealth() / GetMaxHealth() : 0.0f; } - uint32 CountPctFromMaxHealth(int32 pct) const { return CalculatePct(GetMaxHealth(), pct); } - uint32 CountPctFromCurHealth(int32 pct) const { return CalculatePct(GetHealth(), pct); } - - void SetHealth(uint32 val); - void SetMaxHealth(uint32 val); - inline void SetFullHealth() { SetHealth(GetMaxHealth()); } - int32 ModifyHealth(int32 val); - int32 GetHealthGain(int32 dVal); - - Powers GetPowerType() const { return Powers(GetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_POWER_TYPE)); } - void SetPowerType(Powers power); - void UpdateDisplayPower(); - int32 GetPower(Powers power) const; - int32 GetMinPower(Powers power) const { return power == POWER_ECLIPSE ? -100 : 0; } - int32 GetMaxPower(Powers power) const; - int32 CountPctFromMaxPower(Powers power, int32 pct) const { return CalculatePct(GetMaxPower(power), pct); } - void SetPower(Powers power, int32 val, bool withPowerUpdate = true); - void SetMaxPower(Powers power, int32 val); - void SetPowerBarID(uint32 id) { _powerBarId = id; } - void Regenerate(Powers powerType, uint32 diff); - - inline void SetFullPower(Powers power) { SetPower(power, GetMaxPower(power)); } - - // returns the change in power - int32 ModifyPower(Powers power, int32 val, bool withPowerUpdate = true); - static float GetBasePowerRegen(uint32 powerBarId, Powers powerType, bool isInCombat); - float GetPowerRegen(Powers powerType, bool isInCombat) const; - - virtual void RegenerateHealth() { } - - uint32 GetAttackTime(WeaponAttackType att) const; - void SetAttackTime(WeaponAttackType att, uint32 val) { SetFloatValue(UNIT_FIELD_BASEATTACKTIME+att, val*m_modAttackSpeedPct[att]); } - void ApplyAttackTimePercentMod(WeaponAttackType att, float val, bool apply); - void ApplyHasteRegenMod(WeaponAttackType att, float val, bool apply); - void ApplyCastTimePercentMod(float val, bool apply, bool withCastHaste = true, bool withCastSpeed = true); - - SheathState GetSheath() const { return SheathState(GetByteValue(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_SHEATH_STATE)); } - virtual void SetSheath(SheathState sheathed); - - // faction template id - uint32 GetFaction() const { return GetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE); } - void SetFaction(uint32 faction) { SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, faction); } - FactionTemplateEntry const* GetFactionTemplateEntry() const; - - ReputationRank GetReactionTo(Unit const* target) const; - ReputationRank static GetFactionReactionTo(FactionTemplateEntry const* factionTemplateEntry, Unit const* target); - - bool IsHostileTo(Unit const* unit) const; - bool IsHostileToPlayers() const; - bool IsFriendlyTo(Unit const* unit) const; - bool IsNeutralToAll() const; - bool IsInPartyWith(Unit const* unit) const; - bool IsInRaidWith(Unit const* unit) const; - void GetPartyMembers(std::list &units); - bool IsContestedGuard() const; - bool IsPvP() const { return HasByteFlag(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG, UNIT_BYTE2_FLAG_PVP); } - bool IsFFAPvP() const { return HasByteFlag(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG, UNIT_BYTE2_FLAG_FFA_PVP); } - virtual void SetPvP(bool state); - - uint32 GetCreatureType() const; - uint32 GetCreatureTypeMask() const; - - uint8 GetStandState() const { return GetByteValue(UNIT_FIELD_BYTES_1, UNIT_BYTES_1_OFFSET_STAND_STATE); } - bool IsSitState() const; - bool IsStandState() const; - void SetStandState(uint8 state); - - void SetAnimationTier(AnimationTier tier, bool immediate = true); - AnimationTier GetAnimationTier() const { return static_cast(GetByteValue(UNIT_FIELD_BYTES_1, UNIT_BYTES_1_OFFSET_ANIM_TIER)); } - - void SetStandFlags(uint8 flags) { SetByteFlag(UNIT_FIELD_BYTES_1, UNIT_BYTES_1_OFFSET_VIS_FLAG, flags); } - void RemoveStandFlags(uint8 flags) { RemoveByteFlag(UNIT_FIELD_BYTES_1, UNIT_BYTES_1_OFFSET_VIS_FLAG, flags); } - - bool IsMounted() const { return HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_MOUNT); } - uint32 GetMountID() const { return GetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID); } - void Mount(uint32 mount, uint32 vehicleId = 0, uint32 creatureEntry = 0); - void Dismount(); - MountCapabilityEntry const* GetMountCapability(uint32 mountType) const; - void UpdateMountCapability(); - - void SendDurabilityLoss(Player* receiver, uint32 percent); - void PlayOneShotAnimKitId(uint16 animKitId); - - uint32 GetMaxSkillValueForLevel(Unit const* target = nullptr) const { return (target ? getLevelForTarget(target) : getLevel()) * 5; } - void DealDamageMods(Unit const* victim, uint32 &damage, uint32* absorb) const; - uint32 DealDamage(Unit* victim, uint32 damage, CleanDamage const* cleanDamage = nullptr, DamageEffectType damagetype = DIRECT_DAMAGE, SpellSchoolMask damageSchoolMask = SPELL_SCHOOL_MASK_NORMAL, SpellInfo const* spellProto = nullptr, bool durabilityLoss = true); - void Kill(Unit* victim, bool durabilityLoss = true); - void KillSelf(bool durabilityLoss = true) { Kill(this, durabilityLoss); } - void DealHeal(HealInfo& healInfo); - - void ProcSkillsAndAuras(Unit* actionTarget, uint32 typeMaskActor, uint32 typeMaskActionTarget, - uint32 spellTypeMask, uint32 spellPhaseMask, uint32 hitMask, Spell* spell, - DamageInfo* damageInfo, HealInfo* healInfo); - - void GetProcAurasTriggeredOnEvent(AuraApplicationProcContainer& aurasTriggeringProc, AuraApplicationList* procAuras, ProcEventInfo& eventInfo); - void TriggerAurasProcOnEvent(CalcDamageInfo& damageInfo); - void TriggerAurasProcOnEvent(Unit* actionTarget, uint32 typeMaskActor, uint32 typeMaskActionTarget, - uint32 spellTypeMask, uint32 spellPhaseMask, uint32 hitMask, Spell* spell, - DamageInfo* damageInfo, HealInfo* healInfo); - void TriggerAurasProcOnEvent(ProcEventInfo& eventInfo, AuraApplicationProcContainer& procAuras); - - void HandleEmoteCommand(uint32 anim_id); - void AttackerStateUpdate(Unit* victim, WeaponAttackType attType = BASE_ATTACK, bool extra = false); - - void CalculateMeleeDamage(Unit* victim, uint32 damage, CalcDamageInfo* damageInfo, WeaponAttackType attackType = BASE_ATTACK); - void DealMeleeDamage(CalcDamageInfo* damageInfo, bool durabilityLoss); - void HandleProcExtraAttackFor(Unit* victim); - - void CalculateSpellDamageTaken(SpellNonMeleeDamage* damageInfo, int32 damage, SpellInfo const* spellInfo, WeaponAttackType attackType = BASE_ATTACK, bool crit = false); - void DealSpellDamage(SpellNonMeleeDamage* damageInfo, bool durabilityLoss); - - // player or player's pet resilience (-1%) - uint32 GetDamageReduction(uint32 damage) const { return GetCombatRatingDamageReduction(CR_RESILIENCE_PLAYER_DAMAGE_TAKEN, 1.0f, 100.0f, damage); } - - void ApplyResilience(Unit const* victim, int32* damage) const; - - float MeleeSpellMissChance(Unit const* victim, WeaponAttackType attType, SpellInfo const* spellInfo = nullptr) const; - SpellMissInfo MeleeSpellHitResult(Unit* victim, SpellInfo const* spellInfo); - SpellMissInfo MagicSpellHitResult(Unit* victim, SpellInfo const* spellInfo); - SpellMissInfo SpellHitResult(Unit* victim, SpellInfo const* spellInfo, bool canReflect = false, Optional effectMask = {}); - - float GetUnitDodgeChance(WeaponAttackType attType, Unit const* victim) const; - float GetUnitParryChance(WeaponAttackType attType, Unit const* victim) const; - float GetUnitBlockChance(Unit const* victim) const; - float GetMeleeMissChance(Unit const* victim) const; - float GetUnitCriticalChanceDone(WeaponAttackType attackType) const; - float GetUnitCriticalChanceTaken(WeaponAttackType attackType, float critDone) const; - float GetUnitCriticalChanceAgainst(WeaponAttackType attackType, Unit const* victim) const; - int32 GetMechanicResistChance(SpellInfo const* spellInfo) const; - bool CanUseAttackType(uint8 attacktype) const; - - virtual uint32 GetBlockPercent() const { return 30; } - - float GetWeaponProcChance() const; - float GetPPMProcChance(uint32 WeaponSpeed, float PPM, SpellInfo const* spellProto) const; - - MeleeHitOutcome RollMeleeOutcomeAgainst (const Unit* victim, WeaponAttackType attType) const; - - bool IsVendor() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_VENDOR); } - bool IsTrainer() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_TRAINER); } - bool IsQuestGiver() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER); } - bool IsGossip() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); } - bool IsTaxi() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_FLIGHTMASTER); } - bool IsGuildMaster() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_PETITIONER); } - bool IsBattleMaster() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_BATTLEMASTER); } - bool IsBanker() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_BANKER); } - bool IsInnkeeper() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_INNKEEPER); } - bool IsSpiritHealer() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPIRITHEALER); } - bool IsSpiritGuide() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPIRITGUIDE); } - bool IsTabardDesigner()const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_TABARDDESIGNER); } - bool IsAuctioner() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_AUCTIONEER); } - bool IsArmorer() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_REPAIR); } - bool IsServiceProvider() const; - bool IsSpiritService() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPIRITHEALER | UNIT_NPC_FLAG_SPIRITGUIDE); } - bool IsCritter() const { return GetCreatureType() == CREATURE_TYPE_CRITTER; } - - bool IsInFlight() const { return HasUnitState(UNIT_STATE_IN_FLIGHT); } - - /// ====================== THREAT & COMBAT ==================== - bool CanHaveThreatList() const { return m_threatManager.CanHaveThreatList(); } - // This value can be different from IsInCombat, for example: - // - when a projectile spell is midair against a creature (combat on launch - threat+aggro on impact) - // - when the creature has no targets left, but the AI has not yet ceased engaged logic - virtual bool IsEngaged() const { return IsInCombat(); } - bool IsEngagedBy(Unit const* who) const { return CanHaveThreatList() ? IsThreatenedBy(who) : IsInCombatWith(who); } - void EngageWithTarget(Unit* who); // Adds target to threat list if applicable, otherwise just sets combat state - // Combat handling - CombatManager& GetCombatManager() { return m_combatManager; } - CombatManager const& GetCombatManager() const { return m_combatManager; } - void AtTargetAttacked(Unit* target, bool canInitialAggro); - - bool IsImmuneToAll() const { return IsImmuneToPC() && IsImmuneToNPC(); } - void SetImmuneToAll(bool apply, bool keepCombat); - virtual void SetImmuneToAll(bool apply) { SetImmuneToAll(apply, false); } - bool IsImmuneToPC() const { return HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); } - void SetImmuneToPC(bool apply, bool keepCombat); - virtual void SetImmuneToPC(bool apply) { SetImmuneToPC(apply, false); } - bool IsImmuneToNPC() const { return HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC); } - void SetImmuneToNPC(bool apply, bool keepCombat); - virtual void SetImmuneToNPC(bool apply) { SetImmuneToNPC(apply, false); } - - bool IsInCombat() const { return HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT); } - bool IsInCombatWith(Unit const* who) const { return who && m_combatManager.IsInCombatWith(who); } - void SetInCombatWith(Unit* enemy) { if (enemy) m_combatManager.SetInCombatWith(enemy); } - void ClearInCombat() { m_combatManager.EndAllCombat(); } - void UpdatePetCombatState(); - // Threat handling - bool IsThreatened() const; - bool IsThreatenedBy(Unit const* who) const { return who && m_threatManager.IsThreatenedBy(who, true); } - // Exposes the threat manager directly - be careful when interfacing with this - // As a general rule of thumb, any unit pointer MUST be null checked BEFORE passing it to threatmanager methods - // threatmanager will NOT null check your pointers for you - misuse = crash - ThreatManager& GetThreatManager() { return m_threatManager; } - ThreatManager const& GetThreatManager() const { return m_threatManager; } - - void SendClearTarget(); - - bool HasAuraTypeWithFamilyFlags(AuraType auraType, uint32 familyName, uint32 familyFlags) const; - bool virtual HasSpell(uint32 /*spellID*/) const { return false; } - bool HasBreakableByDamageAuraType(AuraType type, uint32 excludeAura = 0) const; - bool HasBreakableByDamageCrowdControlAura(Unit* excludeCasterChannel = nullptr) const; - - bool HasStealthAura() const { return HasAuraType(SPELL_AURA_MOD_STEALTH); } - bool HasInvisibilityAura() const { return HasAuraType(SPELL_AURA_MOD_INVISIBILITY); } - bool isFeared() const { return HasAuraType(SPELL_AURA_MOD_FEAR); } - bool isInRoots() const { return HasAuraType(SPELL_AURA_MOD_ROOT); } - bool IsPolymorphed() const; - - bool isFrozen() const; - - bool isTargetableForAttack(bool checkFakeDeath = true) const; - - bool IsValidAttackTarget(Unit const* target) const; - bool _IsValidAttackTarget(Unit const* target, SpellInfo const* bySpell, WorldObject const* obj = nullptr) const; - - bool IsValidAssistTarget(Unit const* target) const; - bool _IsValidAssistTarget(Unit const* target, SpellInfo const* bySpell) const; - - bool IsInWater() const; - bool IsUnderWater() const; - bool isInAccessiblePlaceFor(Creature const* c) const; - - void SendHealSpellLog(HealInfo& healInfo, bool critical = false); - int32 HealBySpell(HealInfo& healInfo, bool critical = false); - void SendEnergizeSpellLog(Unit* victim, uint32 spellId, int32 damage, Powers powerType); - void EnergizeBySpell(Unit* victim, uint32 spellId, int32 damage, Powers powerType); - void EnergizeBySpell(Unit* victim, SpellInfo const* spellInfo, int32 damage, Powers powerType); - - // CastSpell's third arg can be a variety of things - check out CastSpellExtraArgs' constructors! - void CastSpell(SpellCastTargets const& targets, uint32 spellId, CastSpellExtraArgs const& args = { }); - void CastSpell(WorldObject* target, uint32 spellId, CastSpellExtraArgs const& args = { }); - void CastSpell(Position const& dest, uint32 spellId, CastSpellExtraArgs const& args = { }); - - Aura* AddAura(uint32 spellId, Unit* target); - Aura* AddAura(SpellInfo const* spellInfo, uint8 effMask, Unit* target); - void SetAuraStack(uint32 spellId, Unit* target, uint32 stack); - void SendPlaySpellVisualKit(uint32 id, uint32 type, uint32 duration) const; - void SendPlaySpellVisual(uint32 spellVisualId, Unit const* target = nullptr, Optional targetPosition = {}, float travelSpeed = 0.f, uint16 missReason = 0, uint16 reflectStatus = 0, bool speedAsTime = false) const; - void CancelSpellMissiles(uint32 spellId, bool reverseMissile = false); - - void DeMorph(); - - void SendAttackStateUpdate(CalcDamageInfo* damageInfo); - void SendAttackStateUpdate(uint32 HitInfo, Unit* target, uint8 SwingType, SpellSchoolMask damageSchoolMask, uint32 Damage, uint32 AbsorbDamage, uint32 Resist, VictimState TargetState, uint32 BlockedAmount); - void SendSpellNonMeleeDamageLog(SpellNonMeleeDamage* log); - void SendSpellNonMeleeDamageLog(Unit* target, uint32 SpellID, uint32 Damage, SpellSchoolMask damageSchoolMask, uint32 AbsorbedDamage, uint32 Resist, bool PhysicalDamage, uint32 Blocked, bool CriticalHit = false); - void SendPeriodicAuraLog(SpellPeriodicAuraLogInfo* pInfo); - void SendSpellMiss(Unit* target, uint32 spellID, SpellMissInfo missInfo); - void SendSpellDamageResist(Unit* target, uint32 spellId); - void SendSpellDamageImmune(Unit* target, uint32 spellId); - - void NearTeleportTo(Position const& pos, bool casting = false); - void NearTeleportTo(float x, float y, float z, float orientation, bool casting = false) { NearTeleportTo(Position(x, y, z, orientation), casting); } - void SendTeleportPacket(Position const& pos); - virtual bool UpdatePosition(float x, float y, float z, float ang, bool teleport = false); - // returns true if unit's position really changed - virtual bool UpdatePosition(const Position &pos, bool teleport = false); - void UpdateOrientation(float orientation); - void UpdateHeight(float newZ); - - void SendMoveKnockBack(Player* player, float speedXY, float speedZ, float vcos, float vsin); - void KnockbackFrom(float x, float y, float speedXY, float speedZ); - void JumpTo(float speedXY, float speedZ, bool forward = true, Optional dest = {}); - void JumpTo(WorldObject* obj, float speedZ, bool withOrientation = false); - - void MonsterMoveWithSpeed(float x, float y, float z, float speed, bool generatePath = false, bool forceDestination = false); - - void SendSetPlayHoverAnim(bool enable); - void SendMovementSetSplineAnim(AnimationTier anim); - - bool IsGravityDisabled() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_DISABLE_GRAVITY); } - bool IsWalking() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_WALKING); } - bool IsHovering() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_HOVER); } - bool SetWalk(bool enable); - virtual bool SetDisableGravity(bool disable, bool packetOnly = false, bool updateAnimationTier = true); - bool SetFall(bool enable); - bool SetSwim(bool enable); - bool SetFlying(bool enable); - virtual bool SetCanFly(bool enable, bool packetOnly = false); - virtual bool SetCanTransitionBetweenSwimAndFly(bool enable); - bool SetWaterWalking(bool enable, bool packetOnly = false); - bool SetFeatherFall(bool enable, bool packetOnly = false); - virtual bool SetHover(bool enable, bool packetOnly = false, bool updateAnimationTier = true); - void SendSetVehicleRecId(uint32 vehicleId); - - // Sets the internal orientation value to face the provided target. Does NOT have clientside effects. - void SetOrientationTowards(WorldObject const* target); - // Launches a spline to face the given orientation. - void SetFacingTo(float const ori, bool force = true); - // Launches a spline to face the given object - void SetFacingToObject(WorldObject const* object, bool force = true); - - bool IsAlive() const { return (m_deathState == ALIVE); } - bool isDying() const { return (m_deathState == JUST_DIED); } - bool isDead() const { return (m_deathState == DEAD || m_deathState == CORPSE); } - DeathState getDeathState() const { return m_deathState; } - virtual void setDeathState(DeathState s); // overwrited in Creature/Player/Pet - - ObjectGuid GetOwnerGUID() const { return GetGuidValue(UNIT_FIELD_SUMMONEDBY); } - void SetOwnerGUID(ObjectGuid owner); - ObjectGuid GetCreatorGUID() const { return GetGuidValue(UNIT_FIELD_CREATEDBY); } - void SetCreatorGUID(ObjectGuid creator) { SetGuidValue(UNIT_FIELD_CREATEDBY, creator); } - ObjectGuid GetMinionGUID() const { return GetGuidValue(UNIT_FIELD_SUMMON); } - void SetMinionGUID(ObjectGuid guid) { SetGuidValue(UNIT_FIELD_SUMMON, guid); } - void SetPetGUID(ObjectGuid guid) { m_SummonSlot[SUMMON_SLOT_PET] = guid; } - ObjectGuid GetPetGUID() const { return m_SummonSlot[SUMMON_SLOT_PET]; } - void SetCritterGUID(ObjectGuid guid) { SetGuidValue(UNIT_FIELD_CRITTER, guid); } - ObjectGuid GetCritterGUID() const { return GetGuidValue(UNIT_FIELD_CRITTER); } - ObjectGuid GetOwnerOrCreatorGUID() const { return GetOwnerGUID() ? GetOwnerGUID() : GetCreatorGUID(); } - - ObjectGuid GetCharmerGUID() const { return GetGuidValue(UNIT_FIELD_CHARMEDBY); } - Unit* GetCharmer() const { return m_charmer; } - - ObjectGuid GetCharmedGUID() const { return GetGuidValue(UNIT_FIELD_CHARM); } - Unit* GetCharmed() const { return m_charmed; } - - bool IsControlledByPlayer() const { return m_ControlledByPlayer; } - Player* GetControllingPlayer() const; - ObjectGuid GetCharmerOrOwnerGUID() const { return IsCharmed() ? GetCharmerGUID() : GetOwnerGUID(); } - bool IsCharmedOwnedByPlayerOrPlayer() const { return GetCharmerOrOwnerOrOwnGUID().IsPlayer(); } - - ObjectGuid GetCharmerOrOwnerOrOwnGUID() const; - - Unit* GetOwner() const; - Guardian* GetGuardianPet() const; - Minion* GetFirstMinion() const; - Unit* GetCharmerOrOwner() const { return IsCharmed() ? GetCharmer() : GetOwner(); } - Unit* GetCharmerOrOwnerOrSelf() const; - Player* GetCharmerOrOwnerPlayerOrPlayerItself() const; - Player* GetAffectingPlayer() const; - - Player* GetSpellModOwner() const; - - void SetMinion(Minion *minion, bool apply); - void GetAllMinionsByEntry(std::list& Minions, uint32 entry); - void RemoveAllMinionsByEntry(uint32 entry); - void SetCharm(Unit* target, bool apply); - Unit* GetNextRandomRaidMemberOrPet(float radius); - bool SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* aurApp = nullptr); - void RemoveCharmedBy(Unit* charmer); - void RestoreFaction(); - - ControlList m_Controlled; - Unit* GetFirstControlled() const; - void RemoveAllControlled(); - - bool IsCharmed() const { return !GetCharmerGUID().IsEmpty(); } - bool IsCharming() const { return !GetCharmedGUID().IsEmpty(); } - bool isPossessed() const { return HasUnitState(UNIT_STATE_POSSESSED); } - bool isPossessedByPlayer() const; - bool isPossessing() const; - bool isPossessing(Unit* u) const; - - CharmInfo* GetCharmInfo() { return m_charmInfo; } - CharmInfo* InitCharmInfo(); - void DeleteCharmInfo(); - - // base client control of this unit (possess effects, vehicles and similar). Not affected by temporary CC. - bool IsCharmerOrSelfPlayer() const { return GetCharmerOrSelf()->IsPlayer(); } - Unit* GetCharmerOrSelf() const; - Player* GetCharmerOrSelfPlayer() const { return GetCharmerOrSelf()->ToPlayer();} - Unit* GetCharmedOrSelf() const { return IsCharming() ? GetCharmed() : const_cast(this); } - - // real time client control status of this unit (possess effects, vehicles and similar). For example, if this unit is a player temporarly under fear, it will return false. - bool IsMovedByClient() const { return _gameClientMovingMe != nullptr; } - bool IsMovedByServer() const { return !IsMovedByClient(); } - GameClient* GetGameClientMovingMe() const { return _gameClientMovingMe; } - void SetGameClientMovingMe(GameClient* gameClientMovingMe); - - SharedVisionList const& GetSharedVisionList() { return m_sharedVision; } - void AddPlayerToVision(Player* player); - void RemovePlayerFromVision(Player* player); - bool HasSharedVision() const { return !m_sharedVision.empty(); } - void RemoveBindSightAuras(); - void RemoveCharmAuras(); - - Pet* CreateTamedPetFrom(Creature* creatureTarget, uint32 spell_id = 0); - Pet* CreateTamedPetFrom(uint32 creatureEntry, uint32 spell_id = 0); - bool InitTamedPet(Pet* pet, uint8 level, uint32 spell_id); - - // aura apply/remove helpers - you should better not use these - Aura* _TryStackingOrRefreshingExistingAura(SpellInfo const* newAura, uint8 effMask, Unit* caster, int32* baseAmount = nullptr, Item* castItem = nullptr, ObjectGuid casterGUID = ObjectGuid::Empty); - void _AddAura(UnitAura* aura, Unit* caster); - AuraApplication * _CreateAuraApplication(Aura* aura, uint8 effMask); - void _ApplyAuraEffect(Aura* aura, uint8 effIndex); - void _ApplyAura(AuraApplication * aurApp, uint8 effMask); - void _UnapplyAura(AuraApplicationMap::iterator &i, AuraRemoveFlags removeMode); - void _UnapplyAura(AuraApplication * aurApp, AuraRemoveFlags removeMode); - void _RemoveNoStackAurasDueToAura(Aura* aura); - void _RegisterAuraEffect(AuraEffect* aurEff, bool apply); - - // m_ownedAuras container management - AuraMap & GetOwnedAuras() { return m_ownedAuras; } - AuraMap const& GetOwnedAuras() const { return m_ownedAuras; } - - void RemoveOwnedAura(AuraMap::iterator &i, AuraRemoveFlags removeMode = AuraRemoveFlags::ByDefault); - void RemoveOwnedAura(uint32 spellId, ObjectGuid casterGUID = ObjectGuid::Empty, uint8 reqEffMask = 0, AuraRemoveFlags removeMode = AuraRemoveFlags::ByDefault); - void RemoveOwnedAura(Aura* aura, AuraRemoveFlags removeMode = AuraRemoveFlags::ByDefault); - - Aura* GetOwnedAura(uint32 spellId, ObjectGuid casterGUID = ObjectGuid::Empty, ObjectGuid itemCasterGUID = ObjectGuid::Empty, uint8 reqEffMask = 0, Aura* except = nullptr) const; - - // m_appliedAuras container management - AuraApplicationMap & GetAppliedAuras() { return m_appliedAuras; } - AuraApplicationMap const& GetAppliedAuras() const { return m_appliedAuras; } - - void RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveFlags mode = AuraRemoveFlags::ByDefault); - void RemoveAura(uint32 spellId, ObjectGuid casterGUID = ObjectGuid::Empty, uint8 reqEffMask = 0, AuraRemoveFlags removeMode = AuraRemoveFlags::ByDefault); - void RemoveAura(AuraApplication * aurApp, AuraRemoveFlags mode = AuraRemoveFlags::ByDefault); - void RemoveAura(Aura* aur, AuraRemoveFlags mode = AuraRemoveFlags::ByDefault); - - // Convenience methods removing auras by predicate - void RemoveAppliedAuras(std::function const& check); - void RemoveOwnedAuras(std::function const& check); - - // Optimized overloads taking advantage of map key - void RemoveAppliedAuras(uint32 spellId, std::function const& check); - void RemoveOwnedAuras(uint32 spellId, std::function const& check); - - void RemoveAurasByType(AuraType auraType, std::function const& check); - - void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID = ObjectGuid::Empty, uint8 reqEffMask = 0, AuraRemoveFlags removeMode = AuraRemoveFlags::ByDefault); - void RemoveAuraFromStack(uint32 spellId, ObjectGuid casterGUID = ObjectGuid::Empty, AuraRemoveFlags removeMode = AuraRemoveFlags::ByDefault); - void RemoveAurasDueToSpellByDispel(uint32 spellId, uint32 dispellerSpellId, ObjectGuid casterGUID, Unit* dispeller, uint8 chargesRemoved = 1); - void RemoveAurasDueToSpellBySteal(uint32 spellId, ObjectGuid casterGUID, Unit* stealer); - void RemoveAurasDueToItemSpell(uint32 spellId, ObjectGuid castItemGuid); - void RemoveAurasByType(AuraType auraType, ObjectGuid casterGUID = ObjectGuid::Empty, Aura* except = nullptr, bool negative = true, bool positive = true); - void RemoveNotOwnLimitedTargetAuras(bool onPhaseChange = false); - template - void RemoveAurasWithInterruptFlags(InterruptFlags flag, uint32 except = 0, Spell* interruptingSpell = nullptr); - void RemoveAurasWithAttribute(uint32 flags); - void RemoveAurasWithFamily(SpellFamilyNames family, uint32 familyFlag1, uint32 familyFlag2, uint32 familyFlag3, ObjectGuid casterGUID); - void RemoveAurasWithMechanic(uint32 mechanic_mask, AuraRemoveFlags removemode = AuraRemoveFlags::ByDefault, uint32 except = 0); - void RemoveMovementImpairingAuras(bool withRoot); - void RemoveAurasByShapeShift(); - - void RemoveAreaAurasDueToLeaveWorld(); - void RemoveAllAuras(); - void RemoveArenaAuras(); - void RemoveAurasOnEvade(); - void RemoveAllAurasOnDeath(); - void RemoveAllAurasRequiringDeadTarget(); - void RemoveAllAurasExceptType(AuraType type); - void RemoveAllAurasExceptType(AuraType type1, AuraType type2); /// @todo: once we support variadic templates use them here - void RemoveAllGroupBuffsFromCaster(ObjectGuid casterGUID); - void DelayOwnedAuras(uint32 spellId, ObjectGuid caster, int32 delaytime); - - void _RemoveAllAuraStatMods(); - void _ApplyAllAuraStatMods(); - - AuraEffectList const& GetAuraEffectsByType(AuraType type) const { return m_modAuras[type]; } - AuraList& GetLimitedCastAuras(uint32 spellId) { return m_ltAuras[spellId]; } - AurasBySpellIdMap& GetAllLimitedCastAuras() { return m_ltAuras; } - bool HasLimitedTargetAuraForSpell(uint32 spellId) const; - - AuraEffect* GetAuraEffect(uint32 spellId, uint8 effIndex, ObjectGuid casterGUID = ObjectGuid::Empty) const; - AuraEffect* GetAuraEffectOfRankedSpell(uint32 spellId, uint8 effIndex, ObjectGuid casterGUID = ObjectGuid::Empty) const; - AuraEffect* GetAuraEffect(AuraType type, SpellFamilyNames name, uint32 iconId, uint8 effIndex) const; // spell mustn't have familyflags - AuraEffect* GetAuraEffect(AuraType type, SpellFamilyNames family, uint32 familyFlag1, uint32 familyFlag2, uint32 familyFlag3, ObjectGuid casterGUID = ObjectGuid::Empty) const; - AuraEffect* GetDummyAuraEffect(SpellFamilyNames name, uint32 iconId, uint8 effIndex) const; - - AuraApplication * GetAuraApplication(uint32 spellId, ObjectGuid casterGUID = ObjectGuid::Empty, ObjectGuid itemCasterGUID = ObjectGuid::Empty, uint8 reqEffMask = 0, AuraApplication * except = nullptr) const; - Aura* GetAura(uint32 spellId, ObjectGuid casterGUID = ObjectGuid::Empty, ObjectGuid itemCasterGUID = ObjectGuid::Empty, uint8 reqEffMask = 0) const; - - AuraApplication * GetAuraApplicationOfRankedSpell(uint32 spellId, ObjectGuid casterGUID = ObjectGuid::Empty, ObjectGuid itemCasterGUID = ObjectGuid::Empty, uint8 reqEffMask = 0, AuraApplication * except = nullptr) const; - Aura* GetAuraOfRankedSpell(uint32 spellId, ObjectGuid casterGUID = ObjectGuid::Empty, ObjectGuid itemCasterGUID = ObjectGuid::Empty, uint8 reqEffMask = 0) const; - - void GetDispellableAuraList(Unit* caster, uint32 dispelMask, DispelChargesList& dispelList, bool isReflect = false) const; - - bool HasAuraEffect(uint32 spellId, uint8 effIndex, ObjectGuid caster = ObjectGuid::Empty) const; - uint32 GetAuraCount(uint32 spellId) const; - bool HasAura(uint32 spellId, ObjectGuid casterGUID = ObjectGuid::Empty, ObjectGuid itemCasterGUID = ObjectGuid::Empty, uint8 reqEffMask = 0) const; - bool HasAuraType(AuraType auraType) const; - bool HasAuraTypeWithCaster(AuraType auraType, ObjectGuid caster) const; - bool HasAuraTypeWithMiscvalue(AuraType auraType, int32 miscValue) const; - bool HasAuraTypeWithAffectMask(AuraType auraType, SpellInfo const* affectedSpell) const; - bool HasAuraTypeWithValue(AuraType auraType, int32 value) const; - template - bool HasNegativeAuraWithInterruptFlag(InterruptFlags flag, ObjectGuid guid = ObjectGuid::Empty) const; - bool HasAuraWithMechanic(uint32 mechanicMask) const; - bool HasStrongerAuraWithDR(SpellInfo const* auraSpellInfo, Unit* caster, bool triggered) const; - - AuraEffect* IsScriptOverriden(SpellInfo const* spell, int32 script) const; - uint32 GetDiseasesByCaster(ObjectGuid casterGUID, bool remove = false); - uint32 GetDoTsByCaster(ObjectGuid casterGUID) const; - - int32 GetTotalAuraModifier(AuraType auraType) const; - float GetTotalAuraMultiplier(AuraType auraType) const; - int32 GetMaxPositiveAuraModifier(AuraType auraType) const; - int32 GetMaxNegativeAuraModifier(AuraType auraType) const; - - int32 GetTotalAuraModifier(AuraType auraType, std::function const& predicate) const; - float GetTotalAuraMultiplier(AuraType auraType, std::function const& predicate) const; - int32 GetMaxPositiveAuraModifier(AuraType auraType, std::function const& predicate) const; - int32 GetMaxNegativeAuraModifier(AuraType auraType, std::function const& predicate) const; - - int32 GetTotalAuraModifierByMiscMask(AuraType auraType, uint32 misc_mask) const; - float GetTotalAuraMultiplierByMiscMask(AuraType auraType, uint32 misc_mask) const; - int32 GetMaxPositiveAuraModifierByMiscMask(AuraType auraType, uint32 misc_mask, AuraEffect const* except = nullptr) const; - int32 GetMaxNegativeAuraModifierByMiscMask(AuraType auraType, uint32 misc_mask) const; - - int32 GetTotalAuraModifierByMiscValue(AuraType auraType, int32 misc_value) const; - float GetTotalAuraMultiplierByMiscValue(AuraType auraType, int32 misc_value) const; - int32 GetMaxPositiveAuraModifierByMiscValue(AuraType auraType, int32 misc_value) const; - int32 GetMaxNegativeAuraModifierByMiscValue(AuraType auraType, int32 misc_value) const; - - int32 GetTotalAuraModifierByAffectMask(AuraType auraType, SpellInfo const* affectedSpell) const; - float GetTotalAuraMultiplierByAffectMask(AuraType auraType, SpellInfo const* affectedSpell) const; - int32 GetMaxPositiveAuraModifierByAffectMask(AuraType auraType, SpellInfo const* affectedSpell) const; - int32 GetMaxNegativeAuraModifierByAffectMask(AuraType auraType, SpellInfo const* affectedSpell) const; - - void UpdateResistanceBuffModsMod(SpellSchools school); - void InitStatBuffMods(); - void UpdateStatBuffMod(Stats stat); - void SetCreateStat(Stats stat, float val) { m_createStats[stat] = val; } - void SetCreateHealth(uint32 val) { SetUInt32Value(UNIT_FIELD_BASE_HEALTH, val); } - uint32 GetCreateHealth() const { return GetUInt32Value(UNIT_FIELD_BASE_HEALTH); } - void SetCreateMana(uint32 val) { SetUInt32Value(UNIT_FIELD_BASE_MANA, val); } - uint32 GetCreateMana() const { return GetUInt32Value(UNIT_FIELD_BASE_MANA); } - int32 GetCreatePowers(Powers power) const; - float GetPosStat(Stats stat) const { return GetFloatValue(UNIT_FIELD_POSSTAT0+stat); } - float GetNegStat(Stats stat) const { return GetFloatValue(UNIT_FIELD_NEGSTAT0+stat); } - float GetCreateStat(Stats stat) const { return m_createStats[stat]; } - - ObjectGuid GetChannelObjectGuid() const { return GetGuidValue(UNIT_FIELD_CHANNEL_OBJECT); } - void SetChannelObjectGuid(ObjectGuid guid) { SetGuidValue(UNIT_FIELD_CHANNEL_OBJECT, guid); } - - void SetCurrentCastSpell(Spell* pSpell); - void InterruptSpell(CurrentSpellTypes spellType, bool withDelayed = true, bool withInstant = true, Spell* interruptingSpell = nullptr); - void FinishSpell(CurrentSpellTypes spellType, bool ok = true); - - // set withDelayed to true to account delayed spells as cast - // delayed+channeled spells are always accounted as cast - // we can skip channeled or delayed checks using flags - bool IsNonMeleeSpellCast(bool withDelayed, bool skipChanneled = false, bool skipAutorepeat = false, bool isAutoshoot = false, bool skipInstant = true) const; - - // set withDelayed to true to interrupt delayed spells too - // delayed+channeled spells are always interrupted - void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid = 0, bool withInstant = true, Spell* interruptingSpell = nullptr); - - Spell* GetCurrentSpell(CurrentSpellTypes spellType) const { return m_currentSpells[spellType]; } - Spell* GetCurrentSpell(uint32 spellType) const { return m_currentSpells[spellType]; } - Spell* FindCurrentSpellBySpellId(uint32 spell_id) const; - int32 GetCurrentSpellCastTime(uint32 spell_id) const; - SpellInfo const* GetCastSpellInfo(SpellInfo const* spellInfo) const; - - virtual bool HasSpellFocus(Spell const* /*focusSpell*/ = nullptr) const { return false; } - virtual bool IsMovementPreventedByCasting() const; - - SpellHistory* GetSpellHistory() { return m_spellHistory; } - SpellHistory const* GetSpellHistory() const { return m_spellHistory; } - - ObjectGuid m_SummonSlot[MAX_SUMMON_SLOT]; - ObjectGuid m_ObjectSlot[MAX_GAMEOBJECT_SLOT]; - - void AddSummonedCreature(ObjectGuid guid, uint32 entry); - void RemoveSummonedCreature(ObjectGuid guid); - Creature* GetSummonedCreatureByEntry(uint32 entry); - void UnsummonCreatureByEntry(uint32 entry, uint32 ms = 0); - - - ShapeshiftForm GetShapeshiftForm() const { return ShapeshiftForm(GetByteValue(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_SHAPESHIFT_FORM)); } - void SetShapeshiftForm(ShapeshiftForm form); - - bool IsInFeralForm() const; - - bool IsInDisallowedMountForm() const; - - float m_modMeleeHitChance; - float m_modRangedHitChance; - float m_modSpellHitChance; - int32 m_baseSpellCritChance; - - float m_modAttackSpeedPct[3]; - - // Event handler - EventProcessor m_Events; - - // stat system - // stat system - void HandleStatFlatModifier(UnitMods unitMod, UnitModifierFlatType modifierType, float amount, bool apply); - void ApplyStatPctModifier(UnitMods unitMod, UnitModifierPctType modifierType, float amount); - - void SetStatFlatModifier(UnitMods unitMod, UnitModifierFlatType modifierType, float val); - void SetStatPctModifier(UnitMods unitMod, UnitModifierPctType modifierType, float val); - - float GetFlatModifierValue(UnitMods unitMod, UnitModifierFlatType modifierType) const; - float GetPctModifierValue(UnitMods unitMod, UnitModifierPctType modifierType) const; - - void UpdateUnitMod(UnitMods unitMod); - - // only players have item requirements - virtual bool CheckAttackFitToAuraRequirement(WeaponAttackType /*attackType*/, AuraEffect const* /*aurEff*/) const { return true; } - - virtual void UpdateDamageDoneMods(WeaponAttackType attackType); - void UpdateAllDamageDoneMods(); - - void UpdateDamagePctDoneMods(WeaponAttackType attackType); - void UpdateAllDamagePctDoneMods(); - - float GetTotalStatValue(Stats stat) const; - float GetTotalAuraModValue(UnitMods unitMod) const; - SpellSchools GetSpellSchoolByAuraGroup(UnitMods unitMod) const; - Stats GetStatByAuraGroup(UnitMods unitMod) const; - Powers GetPowerTypeByAuraGroup(UnitMods unitMod) const; - bool CanModifyStats() const { return m_canModifyStats; } - void SetCanModifyStats(bool modifyStats) { m_canModifyStats = modifyStats; } - virtual bool UpdateStats(Stats stat) = 0; - virtual bool UpdateAllStats() = 0; - virtual void UpdateResistances(uint32 school) = 0; - virtual void UpdateAllResistances(); - virtual void UpdateArmor() = 0; - virtual void UpdateMaxHealth() = 0; - virtual void UpdateMaxPower(Powers power) = 0; - virtual uint32 GetPowerIndex(Powers power) const = 0; - virtual void UpdateAttackPowerAndDamage(bool ranged = false) = 0; - virtual void UpdateDamagePhysical(WeaponAttackType attType); - float GetTotalAttackPowerValue(WeaponAttackType attType) const; - float GetWeaponDamageRange(WeaponAttackType attType, WeaponDamageRange type) const; - void SetBaseWeaponDamage(WeaponAttackType attType, WeaponDamageRange damageRange, float value) { m_weaponDamage[attType][damageRange] = value; } - virtual void CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, bool addTotalPct, float& minDamage, float& maxDamage) const = 0; - uint32 CalculateDamage(WeaponAttackType attType, bool normalized, bool addTotalPct) const; - float GetAPMultiplier(WeaponAttackType attType, bool normalized) const; - - bool isInFrontInMap(Unit const* target, float distance, float arc = float(M_PI)) const; - bool isInBackInMap(Unit const* target, float distance, float arc = float(M_PI)) const; - - // Visibility system - bool IsVisible() const; - void SetVisible(bool x); - - // common function for visibility checks for player/creatures with detection code - void OnPhaseChange(); - void UpdateObjectVisibility(bool forced = true) override; - - SpellImmuneContainer m_spellImmune[MAX_SPELL_IMMUNITY]; - uint32 m_lastSanctuaryTime; - - VisibleAuraMap const* GetVisibleAuras() { return &m_visibleAuras; } - AuraApplication * GetVisibleAura(uint8 slot) const; - void SetVisibleAura(uint8 slot, AuraApplication * aur); - void RemoveVisibleAura(uint8 slot); - - bool HasInterruptFlag(SpellAuraInterruptFlags flags) const { return m_interruptMask.HasFlag(flags); } - bool HasInterruptFlag(SpellAuraInterruptFlags2 flags) const { return m_interruptMask2.HasFlag(flags); } - void AddInterruptMask(SpellAuraInterruptFlags flags, SpellAuraInterruptFlags2 flags2) - { - m_interruptMask |= flags; - m_interruptMask2 |= flags2; - } - void UpdateInterruptMask(); - - virtual float GetNativeObjectScale() const { return 1.0f; } - virtual void RecalculateObjectScale(); - uint32 GetDisplayId() const { return GetUInt32Value(UNIT_FIELD_DISPLAYID); } - virtual void SetDisplayId(uint32 modelId); - uint32 GetNativeDisplayId() const { return GetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID); } - void RestoreDisplayId(); - void SetNativeDisplayId(uint32 modelId) { SetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID, modelId); } - void setTransForm(uint32 spellid) { m_transform = spellid;} - uint32 getTransForm() const { return m_transform;} - - // DynamicObject management - void _RegisterDynObject(DynamicObject* dynObj); - void _UnregisterDynObject(DynamicObject* dynObj); - DynamicObject* GetDynObject(uint32 spellId) const; - std::vector GetDynObjects(uint32 spellId) const; - void RemoveDynObject(uint32 spellId); - void RemoveAllDynObjects(); - - GameObject* GetGameObject(uint32 spellId) const; - std::vector GetGameObjects(uint32 spellId) const; - void AddGameObject(GameObject* gameObj); - void RemoveGameObject(GameObject* gameObj, bool del); - void RemoveGameObject(uint32 spellid, bool del); - void RemoveAllGameObjects(); - - void ModifyAuraState(AuraStateType flag, bool apply); - uint32 BuildAuraStateUpdateForTarget(Unit* target) const; - bool HasAuraState(AuraStateType flag, SpellInfo const* spellProto = nullptr, Unit const* Caster = nullptr) const; - void UnsummonAllTotems(); - bool IsMagnet() const; - Unit* GetMagicHitRedirectTarget(Unit* victim, SpellInfo const* spellInfo); - Unit* GetMeleeHitRedirectTarget(Unit* victim, SpellInfo const* spellInfo = nullptr); - - int32 SpellBaseDamageBonusDone(SpellSchoolMask schoolMask, bool withSpellPowerPctMod = false) const; - int32 SpellBaseDamageBonusTaken(SpellInfo const* spellInfo) const; - uint32 SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, uint32 pdamage, DamageEffectType damagetype, uint8 effIndex, uint32 stack = 1) const; - float SpellDamagePctDone(Unit* victim, SpellInfo const* spellProto, DamageEffectType damagetype) const; - uint32 SpellDamageBonusTaken(Unit* caster, SpellInfo const* spellProto, uint32 pdamage, DamageEffectType damagetype) const; - int32 SpellBaseHealingBonusDone(SpellSchoolMask schoolMask, bool withSpellPowerPctMod = false) const; - int32 SpellBaseHealingBonusTaken(SpellSchoolMask schoolMask) const; - uint32 SpellHealingBonusDone(Unit* victim, SpellInfo const* spellProto, uint32 healamount, DamageEffectType damagetype, uint8 effIndex, uint32 stack = 1) const; - float SpellHealingPctDone(Unit* victim, SpellInfo const* spellProto) const; - uint32 SpellHealingBonusTaken(Unit* caster, SpellInfo const* spellProto, uint32 healamount, DamageEffectType damagetype, uint32 stack = 1) const; - - uint32 MeleeDamageBonusDone(Unit* pVictim, uint32 damage, WeaponAttackType attType, SpellInfo const* spellProto = nullptr, bool useSpellBonusData = true); - uint32 MeleeDamageBonusTaken(Unit* attacker, uint32 pdamage, WeaponAttackType attType, SpellInfo const* spellProto = nullptr); - - bool isSpellBlocked(Unit* victim, SpellInfo const* spellProto); - bool isBlockCritical(); - float SpellCritChanceDone(SpellInfo const* spellInfo, SpellSchoolMask schoolMask, WeaponAttackType attackType = BASE_ATTACK) const; - float SpellCritChanceTaken(Unit const* caster, SpellInfo const* spellInfo, SpellSchoolMask schoolMask, float doneChance, WeaponAttackType attackType = BASE_ATTACK) const; - static uint32 SpellCriticalDamageBonus(Unit const* caster, SpellInfo const* spellProto, uint32 damage); - static uint32 SpellCriticalHealingBonus(Unit const* caster, uint32 damage); - - uint32 GetCastingTimeForBonus(SpellInfo const* spellProto, DamageEffectType damagetype, uint32 CastingTime) const; - float CalculateDefaultCoefficient(SpellInfo const* spellInfo, DamageEffectType damagetype) const; - - uint32 GetRemainingPeriodicAmount(ObjectGuid caster, uint32 spellId, AuraType auraType, uint8 effectIndex = 0) const; - - void ApplySpellImmune(uint32 spellId, uint32 op, uint32 type, bool apply); - virtual bool IsImmunedToSpell(SpellInfo const* spellInfo, Unit* caster, Optional effectMask = {}) const; // redefined in Creature - uint32 GetSchoolImmunityMask() const; - uint32 GetDamageImmunityMask() const; - uint32 GetMechanicImmunityMask() const; - - bool IsImmunedToDamage(SpellSchoolMask meleeSchoolMask) const; - bool IsImmunedToDamage(SpellInfo const* spellInfo) const; - virtual bool IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index, Unit* caster) const; // redefined in Creature - - static bool IsDamageReducedByArmor(SpellSchoolMask damageSchoolMask, SpellInfo const* spellInfo = nullptr, int8 effIndex = -1); - uint32 CalcArmorReducedDamage(Unit* victim, const uint32 damage, SpellInfo const* spellInfo, WeaponAttackType attackType = MAX_ATTACK) const; - uint32 CalcSpellResistedDamage(Unit* victim, uint32 damage, SpellSchoolMask schoolMask, SpellInfo const* spellInfo) const; - void CalcAbsorbResist(DamageInfo& damageInfo); - void CalcHealAbsorb(HealInfo& healInfo) const; - - void UpdateSpeed(UnitMoveType mtype); - float GetSpeed(UnitMoveType mtype) const; - float GetSpeedRate(UnitMoveType mtype) const { return m_speed_rate[mtype]; } - void SetSpeed(UnitMoveType mtype, float newValue); - void SetSpeedRate(UnitMoveType mtype, float rate); - private: - void SetSpeedRateReal(UnitMoveType mtype, float rate); - - public: - float ApplyEffectModifiers(SpellInfo const* spellProto, uint8 effect_index, float value) const; - int32 CalculateSpellDamage(Unit const* target, SpellInfo const* spellProto, uint8 effect_index, int32 const* basePoints = nullptr) const; - int32 ModSpellDuration(SpellInfo const* spellProto, Unit const* target, int32 duration, bool positive, uint32 effectMask); - void ModSpellCastTime(SpellInfo const* spellProto, int32& castTime, Spell* spell = nullptr); - void ModSpellDurationTime(SpellInfo const* spellProto, int32& castTime, Spell* spell = nullptr); - - // Makes the unit follow the given target. Use this function above using the MotionMaster::MoveFollow for default follow behaivior. - void FollowTarget(Unit* target); - - FormationFollowerGUIDContainer GetFormationFollowers() { return _formationFollowers; } - void AddFormationFollower(Unit* follower) { _formationFollowers.push_back(follower->GetGUID()); } - void RemoveFormationFollower(Unit* follower); - bool HasFormationFollower(Unit* follower) const; - - void PursuerAdded(PursuingType type, AbstractPursuer* pursuer) { _unitsPursuingMe[AsUnderlyingType(type)].insert(pursuer); }; - void PursuerRemoved(PursuingType type, AbstractPursuer* pursuer) { _unitsPursuingMe[AsUnderlyingType(type)].erase(pursuer); }; - - // Sets the target of all stored AbstractPursuers to nullptr, allowing the involved movement generators to do safe nullptr checks - void RemoveAllPursuers(); - - MotionMaster* GetMotionMaster() { return i_motionMaster; } - MotionMaster const* GetMotionMaster() const { return i_motionMaster; } - - bool IsStopped() const { return !(HasUnitState(UNIT_STATE_MOVING)); } - void StopMoving(); - void PauseMovement(uint32 timer = 0, uint8 slot = 0, bool forced = true); // timer in ms - void ResumeMovement(uint32 timer = 0, uint8 slot = 0); // timer in ms - - void AddUnitMovementFlag(uint32 f) { m_movementInfo.AddMovementFlag(f); } - void RemoveUnitMovementFlag(uint32 f) { m_movementInfo.RemoveMovementFlag(f); } - bool HasUnitMovementFlag(uint32 f) const { return m_movementInfo.HasMovementFlag(f); } - uint32 GetUnitMovementFlags() const { return m_movementInfo.GetMovementFlags(); } - void SetUnitMovementFlags(uint32 f) { m_movementInfo.SetMovementFlags(f); } - - void AddExtraUnitMovementFlag(uint16 f) { m_movementInfo.AddExtraMovementFlag(f); } - void RemoveExtraUnitMovementFlag(uint16 f) { m_movementInfo.RemoveExtraMovementFlag(f); } - bool HasExtraUnitMovementFlag(uint16 f) const { return m_movementInfo.HasExtraMovementFlag(f); } - uint16 GetExtraUnitMovementFlags() const { return m_movementInfo.GetExtraMovementFlags(); } - void SetExtraUnitMovementFlags(uint16 f) { m_movementInfo.SetExtraMovementFlags(f); } - bool IsSplineEnabled() const; - - void SetControlled(bool apply, UnitState state); - void ApplyControlStatesIfNeeded(); - - void AddComboPointHolder(ObjectGuid lowguid) { m_ComboPointHolders.insert(lowguid); } - void RemoveComboPointHolder(ObjectGuid lowguid) { m_ComboPointHolders.erase(lowguid); } - void ClearComboPointHolders(); - - ///----------Pet responses methods----------------- - void SendPetActionFeedback (uint8 msg); - void SendPetTalk (uint32 pettalk); - void SendPetAIReaction(ObjectGuid guid); - ///----------End of Pet responses methods---------- - - void PropagateSpeedChange(); - - // reactive attacks - void ClearAllReactives(); - void StartReactiveTimer(ReactiveType reactive) { m_reactiveTimer[reactive] = REACTIVE_TIMER_START;} - void UpdateReactives(uint32 p_time); - - // group updates - void UpdateAuraForGroup(uint8 slot); - - // proc trigger system - bool CanProc() const { return !m_procDeep; } - void SetCantProc(bool apply); - - uint32 GetModelForForm(ShapeshiftForm form, uint32 spellId) const; - uint32 GetModelForTotem(PlayerTotemType totemType); - - friend class VehicleJoinEvent; - ObjectGuid LastCharmerGUID; - bool CreateVehicleKit(uint32 id, uint32 creatureEntry, bool loading = false); - void RemoveVehicleKit(bool onRemoveFromWorld = false); - Vehicle* GetVehicleKit()const { return m_vehicleKit; } - Vehicle* GetVehicle() const { return m_vehicle; } - void SetVehicle(Vehicle* vehicle) { m_vehicle = vehicle; } - bool IsOnVehicle(Unit const* vehicle) const; - Unit* GetVehicleBase() const; - Creature* GetVehicleCreatureBase() const; - ObjectGuid GetTransGUID() const override; - /// Returns the transport this unit is on directly (if on vehicle and transport, return vehicle) - TransportBase* GetDirectTransport() const; - - bool m_ControlledByPlayer; - - bool HandleSpellClick(Unit* clicker, int8 seatId = -1); - void EnterVehicle(Unit* base, int8 seatId = -1); - void ExitVehicle(Position const* exitPosition = nullptr); - void ChangeSeat(int8 seatId, bool next = true); - - // Should only be called by AuraEffect::HandleAuraControlVehicle(AuraApplication const* auraApp, uint8 mode, bool apply) const; - void _ExitVehicle(Position const* exitPosition = nullptr); - void _EnterVehicle(Vehicle* vehicle, int8 seatId, AuraApplication const* aurApp = nullptr); - - void WriteMovementInfo(WorldPacket& data, Movement::ExtraMovementStatusElement* extras = nullptr, uint32* movementCounter = nullptr); - - bool isMoving() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_MASK_MOVING); } - bool isTurning() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_MASK_TURNING); } - virtual bool CanFly() const = 0; - bool IsFlying() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_FLYING | MOVEMENTFLAG_DISABLE_GRAVITY); } - bool IsFalling() const; - virtual bool CanEnterWater() const = 0; - virtual bool CanSwim() const; - float GetHoverOffset() const - { - return HasUnitMovementFlag(MOVEMENTFLAG_HOVER) ? GetFloatValue(UNIT_FIELD_HOVERHEIGHT) : 0.0f; - } + public: + typedef std::set AttackerSet; + typedef std::set ControlList; + typedef std::vector UnitVector; - uint32 GetMovementCounterAndInc() { return m_movementCounter++; } - uint32 GetMovementCounter() { return m_movementCounter; } - void ClearPendingMovementChangeForType(MovementChangeType changeType); - void AssignPendingMovementChange(MovementChangeType changeType, PlayerMovementPendingChange&& newChange); - bool HasPendingMovementChange() const { return !m_pendingMovementChanges.empty(); } - PlayerMovementPendingChange const* GetPendingMovementChange(MovementChangeType changeType) const; - void PurgeAndApplyPendingMovementChanges(bool informObservers = true); + typedef std::multimap AuraMap; + typedef std::pair AuraMapBounds; + typedef std::pair AuraMapBoundsNonConst; - void RewardRage(uint32 baseRage, bool attacker); + typedef std::multimap AuraApplicationMap; + typedef std::pair AuraApplicationMapBounds; + typedef std::pair AuraApplicationMapBoundsNonConst; - void OutDebugInfo() const; - virtual bool IsLoading() const { return false; } - bool IsDuringRemoveFromWorld() const {return m_duringRemoveFromWorld;} + typedef std::multimap AuraStateAurasMap; + typedef std::pair AuraStateAurasMapBounds; - Pet* ToPet() { if (IsPet()) return reinterpret_cast(this); else return nullptr; } - Pet const* ToPet() const { if (IsPet()) return reinterpret_cast(this); else return nullptr; } + typedef std::list AuraEffectList; + typedef std::list AuraList; + typedef std::list AuraApplicationList; - Totem* ToTotem() { if (IsTotem()) return reinterpret_cast(this); else return nullptr; } - Totem const* ToTotem() const { if (IsTotem()) return reinterpret_cast(this); else return nullptr; } + typedef std::vector> AuraApplicationProcContainer; + typedef std::vector FormationFollowerGUIDContainer; - TempSummon* ToTempSummon() { if (IsSummon()) return reinterpret_cast(this); else return nullptr; } - TempSummon const* ToTempSummon() const { if (IsSummon()) return reinterpret_cast(this); else return nullptr; } + typedef std::map VisibleAuraMap; - ObjectGuid GetTarget() const { return GetGuidValue(UNIT_FIELD_TARGET); } - virtual void SetTarget(ObjectGuid /*guid*/) = 0; + typedef std::unordered_map AurasBySpellIdMap; - // Movement info - Movement::MoveSpline * movespline; + virtual ~Unit(); - int32 GetHighestExclusiveSameEffectSpellGroupValue(AuraEffect const* aurEff, AuraType auraType, bool checkMiscValue = false, int32 miscValue = 0) const; - bool IsHighestExclusiveAura(Aura const* aura, bool removeOtherAuraApplications = false); - bool IsHighestExclusiveAuraEffect(SpellInfo const* spellInfo, AuraType auraType, int32 effectAmount, uint8 auraEffectMask, bool removeOtherAuraApplications = false); - - virtual void Talk(std::string const& text, ChatMsg msgType, Language language, float textRange, WorldObject const* target); - virtual void Say(std::string const& text, Language language, WorldObject const* target = nullptr); - virtual void Yell(std::string const& text, Language language, WorldObject const* target = nullptr); - virtual void TextEmote(std::string const& text, WorldObject const* target = nullptr, bool isBossEmote = false); - virtual void Whisper(std::string const& text, Language language, Player* target, bool isBossWhisper = false); - virtual void Talk(uint32 textId, ChatMsg msgType, float textRange, WorldObject const* target); - virtual void Say(uint32 textId, WorldObject const* target = nullptr); - virtual void Yell(uint32 textId, WorldObject const* target = nullptr); - virtual void TextEmote(uint32 textId, WorldObject const* target = nullptr, bool isBossEmote = false); - virtual void Whisper(uint32 textId, Player* target, bool isBossWhisper = false); - - TaskScheduler& GetScheduler() { return _scheduler; } + bool IsAIEnabled() const + { + return (i_AI != nullptr); + } + void AIUpdateTick(uint32 diff); + UnitAI* GetAI() const + { + return i_AI.get(); + } + void ScheduleAIChange(); + void PushAI(UnitAI* newAI); + bool PopAI(); + protected: + void SetAI(UnitAI* newAI); + UnitAI* GetTopAI() const + { + return i_AIs.empty() ? nullptr : i_AIs.top().get(); + } + void RefreshAI(); + UnitAI* GetScheduledChangeAI(); + bool HasScheduledAIChange() const; - float GetCollisionHeight() const override; + public: + void AddToWorld() override; + void RemoveFromWorld() override; - // returns if the unit is allowed to enter combat - bool IsIgnoringCombat() const { return _isIgnoringCombat; } - // enables/disables combat permission of this unit - void SetIgnoringCombat(bool apply) { _isIgnoringCombat = apply; } + void CleanupBeforeRemoveFromMap(bool finalCleanup); + void CleanupsBeforeDelete(bool finalCleanup = true) override; // used in ~Creature/~Player (or before mass creature delete to remove cross-references to already deleted units) - // Queues up a spell cast request that has been received via packet and processes it whenever possible. - void RequestSpellCast(PendingSpellCastRequest castRequest, SpellInfo const* spellInfo); - void CancelPendingCastRequest(); - bool CanRequestSpellCast(SpellInfo const* spell) const; + virtual bool IsAffectedByDiminishingReturns() const + { + return (GetCharmerOrOwnerPlayerOrPlayerItself() != nullptr); + } + DiminishingLevels GetDiminishing(DiminishingGroup group) const; + void IncrDiminishing(SpellInfo const* auraSpellInfo, bool triggered); + bool ApplyDiminishingToDuration(SpellInfo const* auraSpellInfo, bool triggered, int32& duration, Unit* caster, DiminishingLevels previousLevel) const; + void ApplyDiminishingAura(DiminishingGroup group, bool apply); + void ClearDiminishings(); - void DestroyForPlayer(Player* target, bool onDeath = false) const override; + // target dependent range checks + float GetSpellMaxRangeForTarget(Unit const* target, SpellInfo const* spellInfo) const; + float GetSpellMinRangeForTarget(Unit const* target, SpellInfo const* spellInfo) const; - void GetAttackableUnitListInRange(std::list& list, float fMaxSearchRange) const; - void GetFriendlyUnitListInRange(std::list& list, float fMaxSearchRange, bool exceptSelf = false) const; - void GetAreatriggerListInRange(std::list& list, float fMaxSearchRange) const; - void GetAreaTriggerListWithSpellIDInRange(std::list& list, uint32 spellid, float fMaxSearchRange) const; + virtual void Update(uint32 time) override; - protected: - explicit Unit (bool isWorldObject); + void setAttackTimer(WeaponAttackType type, uint32 time) + { + m_attackTimer[type] = time; + } + void resetAttackTimer(WeaponAttackType type = BASE_ATTACK); + uint32 getAttackTimer(WeaponAttackType type) const + { + return m_attackTimer[type]; + } + bool isAttackReady(WeaponAttackType type = BASE_ATTACK) const + { + return m_attackTimer[type] == 0; + } + bool haveOffhandWeapon() const; + bool CanDualWield() const + { + return m_canDualWield; + } + virtual void SetCanDualWield(bool value) + { + m_canDualWield = value; + } + float GetCombatReach() const override + { + return m_floatValues[UNIT_FIELD_COMBATREACH]; + } + float GetBoundaryRadius() const + { + return m_floatValues[UNIT_FIELD_BOUNDINGRADIUS]; + } + bool IsWithinCombatRange(Unit const* obj, float dist2compare) const; + bool IsWithinMeleeRange(Unit const* obj) const + { + return IsWithinMeleeRangeAt(GetPosition(), obj); + } + bool IsWithinMeleeRangeAt(Position const& pos, Unit const* obj) const; + bool IsWithinBoundaryRadius(const Unit* obj) const; + float GetMeleeRange(Unit const* target) const; + virtual SpellSchoolMask GetMeleeDamageSchoolMask() const; + uint32 m_extraAttacks; + bool m_canDualWield; + + void _addAttacker(Unit* pAttacker); // must be called only from Unit::Attack(Unit*) + void _removeAttacker(Unit* pAttacker); // must be called only from Unit::AttackStop() + Unit* getAttackerForHelper() const; // If someone wants to help, who to give them + bool Attack(Unit* victim, bool meleeAttack); + void CastStop(uint32 except_spellid = 0); + bool AttackStop(); + void RemoveAllAttackers(); + AttackerSet const& getAttackers() const + { + return m_attackers; + } + bool isAttackingPlayer() const; + Unit* GetVictim() const + { + return m_attacking; + } + // Use this only when 100% sure there is a victim + Unit* EnsureVictim() const + { + ASSERT(m_attacking); + return m_attacking; + } - void BuildValuesUpdate(uint8 updatetype, ByteBuffer* data, Player* target) const override; + void ValidateAttackersAndOwnTarget(); + void CombatStop(bool includingCast = false, bool mutualPvP = true); + void CombatStopWithPets(bool includingCast = false); + void StopAttackFaction(uint32 faction_id); + Unit* SelectNearbyTarget(Unit* exclude = nullptr, float dist = NOMINAL_MELEE_RANGE) const; + void SendMeleeAttackStop(Unit* victim = nullptr); + void SendMeleeAttackStart(Unit* victim); - void _UpdateSpells(uint32 time); - void _DeleteRemovedAuras(); + void AddUnitState(uint32 f) + { + m_state |= f; + } + bool HasUnitState(const uint32 f) const + { + return (m_state & f) != 0; + } + void ClearUnitState(uint32 f) + { + m_state &= ~f; + } + bool CanFreeMove() const; - void _UpdateAutoRepeatSpell(); + virtual void UpdatePowerRegeneration(Powers /*powerType*/) + { + } - bool m_AutoRepeatFirstCast; + uint32 HasUnitTypeMask(uint32 mask) const + { + return mask & m_unitTypeMask; + } + void AddUnitTypeMask(uint32 mask) + { + m_unitTypeMask |= mask; + } + bool IsSummon() const + { + return (m_unitTypeMask & UNIT_MASK_SUMMON) != 0; + } + bool IsMinion() const + { + return (m_unitTypeMask & UNIT_MASK_MINION) != 0; + } + bool IsGuardian() const + { + return (m_unitTypeMask & UNIT_MASK_GUARDIAN) != 0; + } + bool IsPet() const + { + return (m_unitTypeMask & UNIT_MASK_PET) != 0; + } + bool IsHunterPet() const + { + return (m_unitTypeMask & UNIT_MASK_HUNTER_PET) != 0; + } + bool IsTotem() const + { + return (m_unitTypeMask & UNIT_MASK_TOTEM) != 0; + } + bool IsVehicle() const + { + return (m_unitTypeMask & UNIT_MASK_VEHICLE) != 0; + } + bool IsControlableGuardian() const + { + return (m_unitTypeMask & UNIT_MASK_CONTROLABLE_GUARDIAN) != 0; + } - uint32 m_attackTimer[MAX_ATTACK]; + uint8 getLevel() const + { + return uint8(GetUInt32Value(UNIT_FIELD_LEVEL)); + } + uint8 getLevelForTarget(WorldObject const* /*target*/) const override + { + return getLevel(); + } + void SetLevel(uint8 lvl); + uint8 getRace() const + { + return GetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_RACE); + } + uint32 getRaceMask() const + { + return 1 << (getRace() - 1); + } + uint8 getClass() const + { + return GetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_CLASS); + } + uint32 getClassMask() const + { + return 1 << (getClass() - 1); + } + uint8 getGender() const + { + return GetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_GENDER); + } - float m_createStats[MAX_STATS]; + float GetStat(Stats stat) const + { + return float(GetUInt32Value(UNIT_FIELD_STAT0 + stat)); + } + void SetStat(Stats stat, int32 val) + { + SetStatInt32Value(UNIT_FIELD_STAT0 + stat, val); + } + uint32 GetArmor() const + { + return GetResistance(SPELL_SCHOOL_NORMAL); + } + void SetArmor(int32 val) + { + SetResistance(SPELL_SCHOOL_NORMAL, val); + } - AttackerSet m_attackers; - Unit* m_attacking; + uint32 GetResistance(SpellSchools school) const + { + return GetUInt32Value(UNIT_FIELD_RESISTANCES + school); + } + uint32 GetResistance(SpellSchoolMask mask) const; + void SetResistance(SpellSchools school, int32 val) + { + SetStatInt32Value(UNIT_FIELD_RESISTANCES + school, val); + } + static float CalculateAverageResistReduction(Unit const* attacker, SpellSchoolMask schoolMask, Unit const* victim, SpellInfo const* spellInfo = nullptr); - DeathState m_deathState; + uint32 GetHealth() const + { + return GetUInt32Value(UNIT_FIELD_HEALTH); + } + uint32 GetMaxHealth() const + { + return GetUInt32Value(UNIT_FIELD_MAXHEALTH); + } - int32 m_procDeep; + bool IsFullHealth() const + { + return GetHealth() == GetMaxHealth(); + } + bool HealthBelowPct(int32 pct) const + { + return GetHealth() < CountPctFromMaxHealth(pct); + } + bool HealthBelowPctDamaged(int32 pct, uint32 damage) const + { + return int64(GetHealth()) - int64(damage) < int64(CountPctFromMaxHealth(pct)); + } + bool HealthAbovePct(int32 pct) const + { + return GetHealth() > CountPctFromMaxHealth(pct); + } + bool HealthAbovePctHealed(int32 pct, uint32 heal) const + { + return uint64(GetHealth()) + uint64(heal) > CountPctFromMaxHealth(pct); + } + float GetHealthPct() const + { + return GetMaxHealth() ? 100.f * GetHealth() / GetMaxHealth() : 0.0f; + } + uint32 CountPctFromMaxHealth(int32 pct) const + { + return CalculatePct(GetMaxHealth(), pct); + } + uint32 CountPctFromCurHealth(int32 pct) const + { + return CalculatePct(GetHealth(), pct); + } - typedef std::list DynObjectList; - DynObjectList m_dynObj; + void SetHealth(uint32 val); + void SetMaxHealth(uint32 val); + inline void SetFullHealth() + { + SetHealth(GetMaxHealth()); + } + int32 ModifyHealth(int32 val); + int32 GetHealthGain(int32 dVal); - typedef std::list GameObjectList; - GameObjectList m_gameObj; + Powers GetPowerType() const + { + return Powers(GetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_POWER_TYPE)); + } + void SetPowerType(Powers power); + void UpdateDisplayPower(); + int32 GetPower(Powers power) const; + int32 GetMinPower(Powers power) const + { + return power == POWER_ECLIPSE ? -100 : 0; + } + int32 GetMaxPower(Powers power) const; + int32 CountPctFromMaxPower(Powers power, int32 pct) const + { + return CalculatePct(GetMaxPower(power), pct); + } + void SetPower(Powers power, int32 val, bool withPowerUpdate = true); + void SetMaxPower(Powers power, int32 val); + void SetPowerBarID(uint32 id) + { + _powerBarId = id; + } + void Regenerate(Powers powerType, uint32 diff); - uint32 m_transform; + inline void SetFullPower(Powers power) + { + SetPower(power, GetMaxPower(power)); + } - Spell* m_currentSpells[CURRENT_MAX_SPELL]; + // returns the change in power + int32 ModifyPower(Powers power, int32 val, bool withPowerUpdate = true); + static float GetBasePowerRegen(uint32 powerBarId, Powers powerType, bool isInCombat); + float GetPowerRegen(Powers powerType, bool isInCombat) const; - AuraMap m_ownedAuras; - AuraApplicationMap m_appliedAuras; - AuraList m_removedAuras; - AuraMap::iterator m_auraUpdateIterator; - uint32 m_removedAurasCount; + virtual void RegenerateHealth() + { + } - AuraEffectList m_modAuras[TOTAL_AURAS]; - AurasBySpellIdMap m_ltAuras; // cast limited target auras - AuraApplicationList m_interruptableAuras; // auras which have interrupt mask applied on unit - AuraStateAurasMap m_auraStateAuras; // Used for improve performance of aura state checks on aura apply/remove - EnumFlag m_interruptMask; - EnumFlag m_interruptMask2; + uint32 GetAttackTime(WeaponAttackType att) const; + void SetAttackTime(WeaponAttackType att, uint32 val) + { + SetFloatValue(UNIT_FIELD_BASEATTACKTIME + att, val * m_modAttackSpeedPct[att]); + } + void ApplyAttackTimePercentMod(WeaponAttackType att, float val, bool apply); + void ApplyHasteRegenMod(WeaponAttackType att, float val, bool apply); + void ApplyCastTimePercentMod(float val, bool apply, bool withCastHaste = true, bool withCastSpeed = true); - float m_auraFlatModifiersGroup[UNIT_MOD_END][MODIFIER_TYPE_FLAT_END]; - float m_auraPctModifiersGroup[UNIT_MOD_END][MODIFIER_TYPE_PCT_END]; - float m_weaponDamage[MAX_ATTACK][2]; - bool m_canModifyStats; - VisibleAuraMap m_visibleAuras; + SheathState GetSheath() const + { + return SheathState(GetByteValue(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_SHEATH_STATE)); + } + virtual void SetSheath(SheathState sheathed); - float m_speed_rate[MAX_MOVE_TYPE]; + // faction template id + uint32 GetFaction() const + { + return GetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE); + } + void SetFaction(uint32 faction) + { + SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, faction); + } + FactionTemplateEntry const* GetFactionTemplateEntry() const; + + ReputationRank GetReactionTo(Unit const* target) const; + ReputationRank static GetFactionReactionTo(FactionTemplateEntry const* factionTemplateEntry, Unit const* target); + + bool IsHostileTo(Unit const* unit) const; + bool IsHostileToPlayers() const; + bool IsFriendlyTo(Unit const* unit) const; + bool IsNeutralToAll() const; + bool IsInPartyWith(Unit const* unit) const; + bool IsInRaidWith(Unit const* unit) const; + void GetPartyMembers(std::list& units); + bool IsContestedGuard() const; + bool IsPvP() const + { + return HasByteFlag(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG, UNIT_BYTE2_FLAG_PVP); + } + bool IsFFAPvP() const + { + return HasByteFlag(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG, UNIT_BYTE2_FLAG_FFA_PVP); + } + virtual void SetPvP(bool state); + + uint32 GetCreatureType() const; + uint32 GetCreatureTypeMask() const; + + uint8 GetStandState() const + { + return GetByteValue(UNIT_FIELD_BYTES_1, UNIT_BYTES_1_OFFSET_STAND_STATE); + } + bool IsSitState() const; + bool IsStandState() const; + void SetStandState(uint8 state); + + void SetAnimationTier(AnimationTier tier, bool immediate = true); + AnimationTier GetAnimationTier() const + { + return static_cast(GetByteValue(UNIT_FIELD_BYTES_1, UNIT_BYTES_1_OFFSET_ANIM_TIER)); + } + + void SetStandFlags(uint8 flags) + { + SetByteFlag(UNIT_FIELD_BYTES_1, UNIT_BYTES_1_OFFSET_VIS_FLAG, flags); + } + void RemoveStandFlags(uint8 flags) + { + RemoveByteFlag(UNIT_FIELD_BYTES_1, UNIT_BYTES_1_OFFSET_VIS_FLAG, flags); + } + + bool IsMounted() const + { + return HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_MOUNT); + } + uint32 GetMountID() const + { + return GetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID); + } + void Mount(uint32 mount, uint32 vehicleId = 0, uint32 creatureEntry = 0); + void Dismount(); + MountCapabilityEntry const* GetMountCapability(uint32 mountType) const; + void UpdateMountCapability(); + + void SendDurabilityLoss(Player* receiver, uint32 percent); + void PlayOneShotAnimKitId(uint16 animKitId); + + uint32 GetMaxSkillValueForLevel(Unit const* target = nullptr) const + { + return (target ? getLevelForTarget(target) : getLevel()) * 5; + } + static void DealDamageMods(Unit const* victim, uint32& damage, uint32* absorb); + static uint32 DealDamage(Unit* attacker, Unit* victim, uint32 damage, CleanDamage const* cleanDamage = nullptr, DamageEffectType damagetype = DIRECT_DAMAGE, + SpellSchoolMask damageSchoolMask = SPELL_SCHOOL_MASK_NORMAL, SpellInfo const* spellProto = nullptr, bool durabilityLoss = true); + static void Kill(Unit* attacker, Unit* victim, bool durabilityLoss = true); + void KillSelf(bool durabilityLoss = true) + { + Unit::Kill(this, this, durabilityLoss); + } + static void DealHeal(HealInfo& healInfo); + + static void ProcSkillsAndAuras(Unit* actor, Unit* actionTarget, uint32 typeMaskActor, uint32 typeMaskActionTarget, uint32 spellTypeMask, uint32 spellPhaseMask, uint32 hitMask, Spell* spell, + DamageInfo* damageInfo, HealInfo* healInfo); + + void GetProcAurasTriggeredOnEvent(AuraApplicationProcContainer& aurasTriggeringProc, AuraApplicationList* procAuras, ProcEventInfo& eventInfo); + void TriggerAurasProcOnEvent(CalcDamageInfo& damageInfo); + void TriggerAurasProcOnEvent( + Unit* actionTarget, uint32 typeMaskActor, uint32 typeMaskActionTarget, uint32 spellTypeMask, uint32 spellPhaseMask, uint32 hitMask, Spell* spell, DamageInfo* damageInfo, HealInfo* healInfo); + void TriggerAurasProcOnEvent(ProcEventInfo& eventInfo, AuraApplicationProcContainer& procAuras); + + void HandleEmoteCommand(uint32 anim_id); + void AttackerStateUpdate(Unit* victim, WeaponAttackType attType = BASE_ATTACK, bool extra = false); + + void CalculateMeleeDamage(Unit* victim, uint32 damage, CalcDamageInfo* damageInfo, WeaponAttackType attackType = BASE_ATTACK); + void DealMeleeDamage(CalcDamageInfo* damageInfo, bool durabilityLoss); + void HandleProcExtraAttackFor(Unit* victim); + + void CalculateSpellDamageTaken(SpellNonMeleeDamage* damageInfo, int32 damage, SpellInfo const* spellInfo, WeaponAttackType attackType = BASE_ATTACK, bool crit = false); + void DealSpellDamage(SpellNonMeleeDamage* damageInfo, bool durabilityLoss); + + // player or player's pet resilience (-1%) + uint32 GetDamageReduction(uint32 damage) const + { + return GetCombatRatingDamageReduction(CR_RESILIENCE_PLAYER_DAMAGE_TAKEN, 1.0f, 100.0f, damage); + } + + virtual bool CanApplyResilience() const; + static void ApplyResilience(Unit const* victim, int32* damage); + + int32 CalculateAOEAvoidance(int32 damage, uint32 schoolMask, Unit* caster) const; + + float MeleeSpellMissChance(Unit const* victim, WeaponAttackType attType, SpellInfo const* spellInfo = nullptr) const; + SpellMissInfo MeleeSpellHitResult(Unit* victim, SpellInfo const* spellInfo); + SpellMissInfo MagicSpellHitResult(Unit* victim, SpellInfo const* spellInfo); + SpellMissInfo SpellHitResult(Unit* victim, SpellInfo const* spellInfo, bool canReflect = false, Optional effectMask = {}); + + float GetUnitDodgeChance(WeaponAttackType attType, Unit const* victim) const; + float GetUnitParryChance(WeaponAttackType attType, Unit const* victim) const; + float GetUnitBlockChance(Unit const* victim) const; + float GetMeleeMissChance(Unit const* victim) const; + float GetUnitCriticalChanceDone(WeaponAttackType attackType) const; + float GetUnitCriticalChanceTaken(WeaponAttackType attackType, float critDone) const; + float GetUnitCriticalChanceAgainst(WeaponAttackType attackType, Unit const* victim) const; + int32 GetMechanicResistChance(SpellInfo const* spellInfo) const; + bool CanUseAttackType(uint8 attacktype) const; + + virtual uint32 GetBlockPercent() const + { + return 30; + } + + float GetWeaponProcChance() const; + float GetPPMProcChance(uint32 WeaponSpeed, float PPM, SpellInfo const* spellProto) const; + + MeleeHitOutcome RollMeleeOutcomeAgainst(const Unit* victim, WeaponAttackType attType) const; + + bool IsVendor() const + { + return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_VENDOR); + } + bool IsTrainer() const + { + return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_TRAINER); + } + bool IsQuestGiver() const + { + return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER); + } + bool IsGossip() const + { + return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); + } + bool IsTaxi() const + { + return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_FLIGHTMASTER); + } + bool IsGuildMaster() const + { + return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_PETITIONER); + } + bool IsBattleMaster() const + { + return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_BATTLEMASTER); + } + bool IsBanker() const + { + return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_BANKER); + } + bool IsInnkeeper() const + { + return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_INNKEEPER); + } + bool IsSpiritHealer() const + { + return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPIRITHEALER); + } + bool IsSpiritGuide() const + { + return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPIRITGUIDE); + } + bool IsTabardDesigner() const + { + return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_TABARDDESIGNER); + } + bool IsAuctioner() const + { + return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_AUCTIONEER); + } + bool IsArmorer() const + { + return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_REPAIR); + } + bool IsServiceProvider() const; + bool IsSpiritService() const + { + return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPIRITHEALER | UNIT_NPC_FLAG_SPIRITGUIDE); + } + bool IsCritter() const + { + return GetCreatureType() == CREATURE_TYPE_CRITTER; + } + + bool IsInFlight() const + { + return HasUnitState(UNIT_STATE_IN_FLIGHT); + } + + /// ====================== THREAT & COMBAT ==================== + bool CanHaveThreatList() const + { + return m_threatManager.CanHaveThreatList(); + } + // This value can be different from IsInCombat, for example: + // - when a projectile spell is midair against a creature (combat on launch - threat+aggro on impact) + // - when the creature has no targets left, but the AI has not yet ceased engaged logic + virtual bool IsEngaged() const + { + return IsInCombat(); + } + bool IsEngagedBy(Unit const* who) const + { + return CanHaveThreatList() ? IsThreatenedBy(who) : IsInCombatWith(who); + } + void EngageWithTarget(Unit* who); // Adds target to threat list if applicable, otherwise just sets combat state + // Combat handling + CombatManager& GetCombatManager() + { + return m_combatManager; + } + CombatManager const& GetCombatManager() const + { + return m_combatManager; + } + void AtTargetAttacked(Unit* target, bool canInitialAggro); + + bool IsImmuneToAll() const + { + return IsImmuneToPC() && IsImmuneToNPC(); + } + void SetImmuneToAll(bool apply, bool keepCombat); + virtual void SetImmuneToAll(bool apply) + { + SetImmuneToAll(apply, false); + } + bool IsImmuneToPC() const + { + return HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); + } + void SetImmuneToPC(bool apply, bool keepCombat); + virtual void SetImmuneToPC(bool apply) + { + SetImmuneToPC(apply, false); + } + bool IsImmuneToNPC() const + { + return HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC); + } + void SetImmuneToNPC(bool apply, bool keepCombat); + virtual void SetImmuneToNPC(bool apply) + { + SetImmuneToNPC(apply, false); + } + + bool IsInCombat() const + { + return HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT); + } + bool IsInCombatWith(Unit const* who) const + { + return who && m_combatManager.IsInCombatWith(who); + } + void SetInCombatWith(Unit* enemy) + { + if (enemy) + m_combatManager.SetInCombatWith(enemy); + } + void ClearInCombat() + { + m_combatManager.EndAllCombat(); + } + void UpdatePetCombatState(); + // Threat handling + bool IsThreatened() const; + bool IsThreatenedBy(Unit const* who) const + { + return who && m_threatManager.IsThreatenedBy(who, true); + } + // Exposes the threat manager directly - be careful when interfacing with this + // As a general rule of thumb, any unit pointer MUST be null checked BEFORE passing it to threatmanager methods + // threatmanager will NOT null check your pointers for you - misuse = crash + ThreatManager& GetThreatManager() + { + return m_threatManager; + } + ThreatManager const& GetThreatManager() const + { + return m_threatManager; + } + + void SendClearTarget(); + + bool HasAuraTypeWithFamilyFlags(AuraType auraType, uint32 familyName, uint32 familyFlags) const; + bool virtual HasSpell(uint32 /*spellID*/) const + { + return false; + } + bool HasBreakableByDamageAuraType(AuraType type, uint32 excludeAura = 0) const; + bool HasBreakableByDamageCrowdControlAura(Unit* excludeCasterChannel = nullptr) const; + + bool HasStealthAura() const + { + return HasAuraType(SPELL_AURA_MOD_STEALTH); + } + bool HasInvisibilityAura() const + { + return HasAuraType(SPELL_AURA_MOD_INVISIBILITY); + } + bool isFeared() const + { + return HasAuraType(SPELL_AURA_MOD_FEAR); + } + bool isInRoots() const + { + return HasAuraType(SPELL_AURA_MOD_ROOT); + } + bool IsPolymorphed() const; + + bool isFrozen() const; + + bool isTargetableForAttack(bool checkFakeDeath = true) const; + + bool IsValidAttackTarget(Unit const* target) const; + bool _IsValidAttackTarget(Unit const* target, SpellInfo const* bySpell, WorldObject const* obj = nullptr) const; + + bool IsValidAssistTarget(Unit const* target) const; + bool _IsValidAssistTarget(Unit const* target, SpellInfo const* bySpell) const; + + bool IsInWater() const; + bool IsUnderWater() const; + bool isInAccessiblePlaceFor(Creature const* c) const; + + void SendHealSpellLog(HealInfo& healInfo, bool critical = false); + int32 HealBySpell(HealInfo& healInfo, bool critical = false); + void SendEnergizeSpellLog(Unit* victim, uint32 spellId, int32 damage, Powers powerType); + void EnergizeBySpell(Unit* victim, uint32 spellId, int32 damage, Powers powerType); + void EnergizeBySpell(Unit* victim, SpellInfo const* spellInfo, int32 damage, Powers powerType); + + // CastSpell's third arg can be a variety of things - check out CastSpellExtraArgs' constructors! + void CastSpell(SpellCastTargets const& targets, uint32 spellId, CastSpellExtraArgs const& args = {}); + void CastSpell(WorldObject* target, uint32 spellId, CastSpellExtraArgs const& args = {}); + void CastSpell(Position const& dest, uint32 spellId, CastSpellExtraArgs const& args = {}); + + Aura* AddAura(uint32 spellId, Unit* target); + Aura* AddAura(SpellInfo const* spellInfo, uint8 effMask, Unit* target); + void SetAuraStack(uint32 spellId, Unit* target, uint32 stack); + void SendPlaySpellVisualKit(uint32 id, uint32 type, uint32 duration) const; + void SendPlaySpellVisual(uint32 spellVisualId, Unit const* target = nullptr, Optional targetPosition = {}, float travelSpeed = 0.f, uint16 missReason = 0, uint16 reflectStatus = 0, + bool speedAsTime = false) const; + void CancelSpellMissiles(uint32 spellId, bool reverseMissile = false); + + void DeMorph(); + + void SendAttackStateUpdate(CalcDamageInfo* damageInfo); + void SendAttackStateUpdate( + uint32 HitInfo, Unit* target, uint8 SwingType, SpellSchoolMask damageSchoolMask, uint32 Damage, uint32 AbsorbDamage, uint32 Resist, VictimState TargetState, uint32 BlockedAmount); + void SendSpellNonMeleeDamageLog(SpellNonMeleeDamage* log); + void SendSpellNonMeleeDamageLog( + Unit* target, uint32 SpellID, uint32 Damage, SpellSchoolMask damageSchoolMask, uint32 AbsorbedDamage, uint32 Resist, bool PhysicalDamage, uint32 Blocked, bool CriticalHit = false); + void SendPeriodicAuraLog(SpellPeriodicAuraLogInfo* pInfo); + void SendSpellMiss(Unit* target, uint32 spellID, SpellMissInfo missInfo); + void SendSpellDamageResist(Unit* target, uint32 spellId); + void SendSpellDamageImmune(Unit* target, uint32 spellId); + + void NearTeleportTo(Position const& pos, bool casting = false); + void NearTeleportTo(float x, float y, float z, float orientation, bool casting = false) + { + NearTeleportTo(Position(x, y, z, orientation), casting); + } + void SendTeleportPacket(Position const& pos); + virtual bool UpdatePosition(float x, float y, float z, float ang, bool teleport = false); + // returns true if unit's position really changed + virtual bool UpdatePosition(const Position& pos, bool teleport = false); + void UpdateOrientation(float orientation); + void UpdateHeight(float newZ); + + void SendMoveKnockBack(Player* player, float speedXY, float speedZ, float vcos, float vsin); + void KnockbackFrom(float x, float y, float speedXY, float speedZ); + void JumpTo(float speedXY, float speedZ, bool forward = true, Optional dest = {}); + void JumpTo(WorldObject* obj, float speedZ, bool withOrientation = false); + + void MonsterMoveWithSpeed(float x, float y, float z, float speed, bool generatePath = false, bool forceDestination = false); + + void SendSetPlayHoverAnim(bool enable); + void SendMovementSetSplineAnim(AnimationTier anim); + + bool IsGravityDisabled() const + { + return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_DISABLE_GRAVITY); + } + bool IsWalking() const + { + return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_WALKING); + } + bool IsHovering() const + { + return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_HOVER); + } + bool SetWalk(bool enable); + virtual bool SetDisableGravity(bool disable, bool packetOnly = false, bool updateAnimationTier = true); + bool SetFall(bool enable); + bool SetSwim(bool enable); + bool SetFlying(bool enable); + virtual bool SetCanFly(bool enable, bool packetOnly = false); + virtual bool SetCanTransitionBetweenSwimAndFly(bool enable); + bool SetWaterWalking(bool enable, bool packetOnly = false); + bool SetFeatherFall(bool enable, bool packetOnly = false); + virtual bool SetHover(bool enable, bool packetOnly = false, bool updateAnimationTier = true); + void SendSetVehicleRecId(uint32 vehicleId); + + // Sets the internal orientation value to face the provided target. Does NOT have clientside effects. + void SetOrientationTowards(WorldObject const* target); + // Launches a spline to face the given orientation. + void SetFacingTo(float const ori, bool force = true); + // Launches a spline to face the given object + void SetFacingToObject(WorldObject const* object, bool force = true); + + bool IsAlive() const + { + return (m_deathState == ALIVE); + } + bool isDying() const + { + return (m_deathState == JUST_DIED); + } + bool isDead() const + { + return (m_deathState == DEAD || m_deathState == CORPSE); + } + DeathState getDeathState() const + { + return m_deathState; + } + virtual void setDeathState(DeathState s); // overwrited in Creature/Player/Pet + + ObjectGuid GetOwnerGUID() const + { + return GetGuidValue(UNIT_FIELD_SUMMONEDBY); + } + void SetOwnerGUID(ObjectGuid owner); + ObjectGuid GetCreatorGUID() const + { + return GetGuidValue(UNIT_FIELD_CREATEDBY); + } + void SetCreatorGUID(ObjectGuid creator) + { + SetGuidValue(UNIT_FIELD_CREATEDBY, creator); + } + ObjectGuid GetMinionGUID() const + { + return GetGuidValue(UNIT_FIELD_SUMMON); + } + void SetMinionGUID(ObjectGuid guid) + { + SetGuidValue(UNIT_FIELD_SUMMON, guid); + } + void SetPetGUID(ObjectGuid guid) + { + m_SummonSlot[SUMMON_SLOT_PET] = guid; + } + ObjectGuid GetPetGUID() const + { + return m_SummonSlot[SUMMON_SLOT_PET]; + } + void SetCritterGUID(ObjectGuid guid) + { + SetGuidValue(UNIT_FIELD_CRITTER, guid); + } + ObjectGuid GetCritterGUID() const + { + return GetGuidValue(UNIT_FIELD_CRITTER); + } + ObjectGuid GetOwnerOrCreatorGUID() const + { + return GetOwnerGUID() ? GetOwnerGUID() : GetCreatorGUID(); + } + + ObjectGuid GetCharmerGUID() const + { + return GetGuidValue(UNIT_FIELD_CHARMEDBY); + } + Unit* GetCharmer() const + { + return m_charmer; + } + + ObjectGuid GetCharmedGUID() const + { + return GetGuidValue(UNIT_FIELD_CHARM); + } + Unit* GetCharmed() const + { + return m_charmed; + } + + bool IsControlledByPlayer() const + { + return m_ControlledByPlayer; + } + Player* GetControllingPlayer() const; + ObjectGuid GetCharmerOrOwnerGUID() const + { + return IsCharmed() ? GetCharmerGUID() : GetOwnerGUID(); + } + bool IsCharmedOwnedByPlayerOrPlayer() const + { + return GetCharmerOrOwnerOrOwnGUID().IsPlayer(); + } + + ObjectGuid GetCharmerOrOwnerOrOwnGUID() const; + + Unit* GetOwner() const; + Guardian* GetGuardianPet() const; + Minion* GetFirstMinion() const; + Unit* GetCharmerOrOwner() const + { + return IsCharmed() ? GetCharmer() : GetOwner(); + } + Unit* GetCharmerOrOwnerOrSelf() const; + Player* GetCharmerOrOwnerPlayerOrPlayerItself() const; + Player* GetAffectingPlayer() const; + + Player* GetSpellModOwner() const; + + void SetMinion(Minion* minion, bool apply); + void GetAllMinionsByEntry(std::list& Minions, uint32 entry); + void RemoveAllMinionsByEntry(uint32 entry); + void SetCharm(Unit* target, bool apply); + Unit* GetNextRandomRaidMemberOrPet(float radius); + bool SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* aurApp = nullptr); + void RemoveCharmedBy(Unit* charmer); + void RestoreFaction(); + + ControlList m_Controlled; + Unit* GetFirstControlled() const; + void RemoveAllControlled(); + + bool IsCharmed() const + { + return !GetCharmerGUID().IsEmpty(); + } + bool IsCharming() const + { + return !GetCharmedGUID().IsEmpty(); + } + bool isPossessed() const + { + return HasUnitState(UNIT_STATE_POSSESSED); + } + bool isPossessedByPlayer() const; + bool isPossessing() const; + bool isPossessing(Unit* u) const; + + CharmInfo* GetCharmInfo() + { + return m_charmInfo; + } + CharmInfo* InitCharmInfo(); + void DeleteCharmInfo(); + + // base client control of this unit (possess effects, vehicles and similar). Not affected by temporary CC. + bool IsCharmerOrSelfPlayer() const + { + return GetCharmerOrSelf()->IsPlayer(); + } + Unit* GetCharmerOrSelf() const; + Player* GetCharmerOrSelfPlayer() const + { + return GetCharmerOrSelf()->ToPlayer(); + } + Unit* GetCharmedOrSelf() const + { + return IsCharming() ? GetCharmed() : const_cast(this); + } + + // real time client control status of this unit (possess effects, vehicles and similar). For example, if this unit is a player temporarly under fear, it will return false. + bool IsMovedByClient() const + { + return _gameClientMovingMe != nullptr; + } + bool IsMovedByServer() const + { + return !IsMovedByClient(); + } + GameClient* GetGameClientMovingMe() const + { + return _gameClientMovingMe; + } + void SetGameClientMovingMe(GameClient* gameClientMovingMe); + + SharedVisionList const& GetSharedVisionList() + { + return m_sharedVision; + } + void AddPlayerToVision(Player* player); + void RemovePlayerFromVision(Player* player); + bool HasSharedVision() const + { + return !m_sharedVision.empty(); + } + void RemoveBindSightAuras(); + void RemoveCharmAuras(); + + Pet* CreateTamedPetFrom(Creature* creatureTarget, uint32 spell_id = 0); + Pet* CreateTamedPetFrom(uint32 creatureEntry, uint32 spell_id = 0); + bool InitTamedPet(Pet* pet, uint8 level, uint32 spell_id); + + // aura apply/remove helpers - you should better not use these + Aura* _TryStackingOrRefreshingExistingAura(SpellInfo const* newAura, uint8 effMask, Unit* caster, int32* baseAmount = nullptr, Item* castItem = nullptr, ObjectGuid casterGUID = ObjectGuid::Empty); + void _AddAura(UnitAura* aura, Unit* caster); + AuraApplication* _CreateAuraApplication(Aura* aura, uint8 effMask); + void _ApplyAuraEffect(Aura* aura, uint8 effIndex); + void _ApplyAura(AuraApplication* aurApp, uint8 effMask); + void _UnapplyAura(AuraApplicationMap::iterator& i, AuraRemoveFlags removeMode); + void _UnapplyAura(AuraApplication* aurApp, AuraRemoveFlags removeMode); + void _RemoveNoStackAurasDueToAura(Aura* aura); + void _RegisterAuraEffect(AuraEffect* aurEff, bool apply); + + // m_ownedAuras container management + AuraMap& GetOwnedAuras() + { + return m_ownedAuras; + } + AuraMap const& GetOwnedAuras() const + { + return m_ownedAuras; + } + + void RemoveOwnedAura(AuraMap::iterator& i, AuraRemoveFlags removeMode = AuraRemoveFlags::ByDefault); + void RemoveOwnedAura(uint32 spellId, ObjectGuid casterGUID = ObjectGuid::Empty, uint8 reqEffMask = 0, AuraRemoveFlags removeMode = AuraRemoveFlags::ByDefault); + void RemoveOwnedAura(Aura* aura, AuraRemoveFlags removeMode = AuraRemoveFlags::ByDefault); + + Aura* GetOwnedAura(uint32 spellId, ObjectGuid casterGUID = ObjectGuid::Empty, ObjectGuid itemCasterGUID = ObjectGuid::Empty, uint8 reqEffMask = 0, Aura* except = nullptr) const; + + // m_appliedAuras container management + AuraApplicationMap& GetAppliedAuras() + { + return m_appliedAuras; + } + AuraApplicationMap const& GetAppliedAuras() const + { + return m_appliedAuras; + } + + void RemoveAura(AuraApplicationMap::iterator& i, AuraRemoveFlags mode = AuraRemoveFlags::ByDefault); + void RemoveAura(uint32 spellId, ObjectGuid casterGUID = ObjectGuid::Empty, uint8 reqEffMask = 0, AuraRemoveFlags removeMode = AuraRemoveFlags::ByDefault); + void RemoveAura(AuraApplication* aurApp, AuraRemoveFlags mode = AuraRemoveFlags::ByDefault); + void RemoveAura(Aura* aur, AuraRemoveFlags mode = AuraRemoveFlags::ByDefault); + + // Convenience methods removing auras by predicate + void RemoveAppliedAuras(std::function const& check); + void RemoveOwnedAuras(std::function const& check); + + // Optimized overloads taking advantage of map key + void RemoveAppliedAuras(uint32 spellId, std::function const& check); + void RemoveOwnedAuras(uint32 spellId, std::function const& check); + + void RemoveAurasByType(AuraType auraType, std::function const& check); + + void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID = ObjectGuid::Empty, uint8 reqEffMask = 0, AuraRemoveFlags removeMode = AuraRemoveFlags::ByDefault); + void RemoveAuraFromStack(uint32 spellId, ObjectGuid casterGUID = ObjectGuid::Empty, AuraRemoveFlags removeMode = AuraRemoveFlags::ByDefault); + void RemoveAurasDueToSpellByDispel(uint32 spellId, uint32 dispellerSpellId, ObjectGuid casterGUID, Unit* dispeller, uint8 chargesRemoved = 1); + void RemoveAurasDueToSpellBySteal(uint32 spellId, ObjectGuid casterGUID, Unit* stealer); + void RemoveAurasDueToItemSpell(uint32 spellId, ObjectGuid castItemGuid); + void RemoveAurasByType(AuraType auraType, ObjectGuid casterGUID = ObjectGuid::Empty, Aura* except = nullptr, bool negative = true, bool positive = true); + void RemoveNotOwnLimitedTargetAuras(bool onPhaseChange = false); + template void RemoveAurasWithInterruptFlags(InterruptFlags flag, uint32 except = 0, Spell* interruptingSpell = nullptr); + void RemoveAurasWithAttribute(uint32 flags); + void RemoveAurasWithFamily(SpellFamilyNames family, uint32 familyFlag1, uint32 familyFlag2, uint32 familyFlag3, ObjectGuid casterGUID); + void RemoveAurasWithMechanic(uint32 mechanic_mask, AuraRemoveFlags removemode = AuraRemoveFlags::ByDefault, uint32 except = 0); + void RemoveMovementImpairingAuras(bool withRoot); + void RemoveAurasByShapeShift(); + + void RemoveAreaAurasDueToLeaveWorld(); + void RemoveAllAuras(); + void RemoveArenaAuras(); + void RemoveAurasOnEvade(); + void RemoveAllAurasOnDeath(); + void RemoveAllAurasRequiringDeadTarget(); + void RemoveAllAurasExceptType(AuraType type); + void RemoveAllAurasExceptType(AuraType type1, AuraType type2); /// @todo: once we support variadic templates use them here + void RemoveAllGroupBuffsFromCaster(ObjectGuid casterGUID); + void DelayOwnedAuras(uint32 spellId, ObjectGuid caster, int32 delaytime); + + void _RemoveAllAuraStatMods(); + void _ApplyAllAuraStatMods(); + + AuraEffectList const& GetAuraEffectsByType(AuraType type) const + { + return m_modAuras[type]; + } + AuraList& GetLimitedCastAuras(uint32 spellId) + { + return m_ltAuras[spellId]; + } + AurasBySpellIdMap& GetAllLimitedCastAuras() + { + return m_ltAuras; + } + bool HasLimitedTargetAuraForSpell(uint32 spellId) const; + + AuraEffect* GetAuraEffect(uint32 spellId, uint8 effIndex, ObjectGuid casterGUID = ObjectGuid::Empty) const; + AuraEffect* GetAuraEffectOfRankedSpell(uint32 spellId, uint8 effIndex, ObjectGuid casterGUID = ObjectGuid::Empty) const; + AuraEffect* GetAuraEffect(AuraType type, SpellFamilyNames name, uint32 iconId, uint8 effIndex) const; // spell mustn't have familyflags + AuraEffect* GetAuraEffect(AuraType type, SpellFamilyNames family, uint32 familyFlag1, uint32 familyFlag2, uint32 familyFlag3, ObjectGuid casterGUID = ObjectGuid::Empty) const; + AuraEffect* GetDummyAuraEffect(SpellFamilyNames name, uint32 iconId, uint8 effIndex) const; + + AuraApplication* GetAuraApplication( + uint32 spellId, ObjectGuid casterGUID = ObjectGuid::Empty, ObjectGuid itemCasterGUID = ObjectGuid::Empty, uint8 reqEffMask = 0, AuraApplication* except = nullptr) const; + Aura* GetAura(uint32 spellId, ObjectGuid casterGUID = ObjectGuid::Empty, ObjectGuid itemCasterGUID = ObjectGuid::Empty, uint8 reqEffMask = 0) const; + + AuraApplication* GetAuraApplicationOfRankedSpell( + uint32 spellId, ObjectGuid casterGUID = ObjectGuid::Empty, ObjectGuid itemCasterGUID = ObjectGuid::Empty, uint8 reqEffMask = 0, AuraApplication* except = nullptr) const; + Aura* GetAuraOfRankedSpell(uint32 spellId, ObjectGuid casterGUID = ObjectGuid::Empty, ObjectGuid itemCasterGUID = ObjectGuid::Empty, uint8 reqEffMask = 0) const; + + void GetDispellableAuraList(Unit* caster, uint32 dispelMask, DispelChargesList& dispelList, bool isReflect = false) const; + + bool HasAuraEffect(uint32 spellId, uint8 effIndex, ObjectGuid caster = ObjectGuid::Empty) const; + uint32 GetAuraCount(uint32 spellId) const; + bool HasAura(uint32 spellId, ObjectGuid casterGUID = ObjectGuid::Empty, ObjectGuid itemCasterGUID = ObjectGuid::Empty, uint8 reqEffMask = 0) const; + bool HasAuraType(AuraType auraType) const; + bool HasAuraTypeWithCaster(AuraType auraType, ObjectGuid caster) const; + bool HasAuraTypeWithMiscvalue(AuraType auraType, int32 miscValue) const; + bool HasAuraTypeWithAffectMask(AuraType auraType, SpellInfo const* affectedSpell) const; + bool HasAuraTypeWithValue(AuraType auraType, int32 value) const; + template bool HasNegativeAuraWithInterruptFlag(InterruptFlags flag, ObjectGuid guid = ObjectGuid::Empty) const; + bool HasAuraWithMechanic(uint32 mechanicMask) const; + bool HasStrongerAuraWithDR(SpellInfo const* auraSpellInfo, Unit* caster, bool triggered) const; + + AuraEffect* IsScriptOverriden(SpellInfo const* spell, int32 script) const; + uint32 GetDiseasesByCaster(ObjectGuid casterGUID, bool remove = false); + uint32 GetDoTsByCaster(ObjectGuid casterGUID) const; + + int32 GetTotalAuraModifier(AuraType auraType) const; + float GetTotalAuraMultiplier(AuraType auraType) const; + int32 GetMaxPositiveAuraModifier(AuraType auraType) const; + int32 GetMaxNegativeAuraModifier(AuraType auraType) const; + + int32 GetTotalAuraModifier(AuraType auraType, std::function const& predicate) const; + float GetTotalAuraMultiplier(AuraType auraType, std::function const& predicate) const; + int32 GetMaxPositiveAuraModifier(AuraType auraType, std::function const& predicate) const; + int32 GetMaxNegativeAuraModifier(AuraType auraType, std::function const& predicate) const; + + int32 GetTotalAuraModifierByMiscMask(AuraType auraType, uint32 misc_mask) const; + float GetTotalAuraMultiplierByMiscMask(AuraType auraType, uint32 misc_mask) const; + int32 GetMaxPositiveAuraModifierByMiscMask(AuraType auraType, uint32 misc_mask, AuraEffect const* except = nullptr) const; + int32 GetMaxNegativeAuraModifierByMiscMask(AuraType auraType, uint32 misc_mask) const; + + int32 GetTotalAuraModifierByMiscValue(AuraType auraType, int32 misc_value) const; + float GetTotalAuraMultiplierByMiscValue(AuraType auraType, int32 misc_value) const; + int32 GetMaxPositiveAuraModifierByMiscValue(AuraType auraType, int32 misc_value) const; + int32 GetMaxNegativeAuraModifierByMiscValue(AuraType auraType, int32 misc_value) const; + + int32 GetTotalAuraModifierByAffectMask(AuraType auraType, SpellInfo const* affectedSpell) const; + float GetTotalAuraMultiplierByAffectMask(AuraType auraType, SpellInfo const* affectedSpell) const; + int32 GetMaxPositiveAuraModifierByAffectMask(AuraType auraType, SpellInfo const* affectedSpell) const; + int32 GetMaxNegativeAuraModifierByAffectMask(AuraType auraType, SpellInfo const* affectedSpell) const; + + void UpdateResistanceBuffModsMod(SpellSchools school); + void InitStatBuffMods(); + void UpdateStatBuffMod(Stats stat); + void SetCreateStat(Stats stat, float val) + { + m_createStats[stat] = val; + } + void SetCreateHealth(uint32 val) + { + SetUInt32Value(UNIT_FIELD_BASE_HEALTH, val); + } + uint32 GetCreateHealth() const + { + return GetUInt32Value(UNIT_FIELD_BASE_HEALTH); + } + void SetCreateMana(uint32 val) + { + SetUInt32Value(UNIT_FIELD_BASE_MANA, val); + } + uint32 GetCreateMana() const + { + return GetUInt32Value(UNIT_FIELD_BASE_MANA); + } + int32 GetCreatePowers(Powers power) const; + float GetPosStat(Stats stat) const + { + return GetFloatValue(UNIT_FIELD_POSSTAT0 + stat); + } + float GetNegStat(Stats stat) const + { + return GetFloatValue(UNIT_FIELD_NEGSTAT0 + stat); + } + float GetCreateStat(Stats stat) const + { + return m_createStats[stat]; + } + + ObjectGuid GetChannelObjectGuid() const + { + return GetGuidValue(UNIT_FIELD_CHANNEL_OBJECT); + } + void SetChannelObjectGuid(ObjectGuid guid) + { + SetGuidValue(UNIT_FIELD_CHANNEL_OBJECT, guid); + } + + void SetCurrentCastSpell(Spell* pSpell); + void InterruptSpell(CurrentSpellTypes spellType, bool withDelayed = true, bool withInstant = true, Spell* interruptingSpell = nullptr); + void FinishSpell(CurrentSpellTypes spellType, bool ok = true); + + // set withDelayed to true to account delayed spells as cast + // delayed+channeled spells are always accounted as cast + // we can skip channeled or delayed checks using flags + bool IsNonMeleeSpellCast(bool withDelayed, bool skipChanneled = false, bool skipAutorepeat = false, bool isAutoshoot = false, bool skipInstant = true) const; + + // set withDelayed to true to interrupt delayed spells too + // delayed+channeled spells are always interrupted + void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid = 0, bool withInstant = true, Spell* interruptingSpell = nullptr); + + Spell* GetCurrentSpell(CurrentSpellTypes spellType) const + { + return m_currentSpells[spellType]; + } + Spell* GetCurrentSpell(uint32 spellType) const + { + return m_currentSpells[spellType]; + } + Spell* FindCurrentSpellBySpellId(uint32 spell_id) const; + int32 GetCurrentSpellCastTime(uint32 spell_id) const; + SpellInfo const* GetCastSpellInfo(SpellInfo const* spellInfo) const; + + virtual bool HasSpellFocus(Spell const* /*focusSpell*/ = nullptr) const + { + return false; + } + virtual bool IsMovementPreventedByCasting() const; + + SpellHistory* GetSpellHistory() + { + return m_spellHistory; + } + SpellHistory const* GetSpellHistory() const + { + return m_spellHistory; + } + + ObjectGuid m_SummonSlot[MAX_SUMMON_SLOT]; + ObjectGuid m_ObjectSlot[MAX_GAMEOBJECT_SLOT]; + + void AddSummonedCreature(ObjectGuid guid, uint32 entry); + void RemoveSummonedCreature(ObjectGuid guid); + Creature* GetSummonedCreatureByEntry(uint32 entry); + void UnsummonCreatureByEntry(uint32 entry, uint32 ms = 0); + + ShapeshiftForm GetShapeshiftForm() const + { + return ShapeshiftForm(GetByteValue(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_SHAPESHIFT_FORM)); + } + void SetShapeshiftForm(ShapeshiftForm form); + + bool IsInFeralForm() const; + + bool IsInDisallowedMountForm() const; + + float m_modMeleeHitChance; + float m_modRangedHitChance; + float m_modSpellHitChance; + int32 m_baseSpellCritChance; + + float m_modAttackSpeedPct[3]; + + // Event handler + EventProcessor m_Events; + + // stat system + // stat system + void HandleStatFlatModifier(UnitMods unitMod, UnitModifierFlatType modifierType, float amount, bool apply); + void ApplyStatPctModifier(UnitMods unitMod, UnitModifierPctType modifierType, float amount); + + void SetStatFlatModifier(UnitMods unitMod, UnitModifierFlatType modifierType, float val); + void SetStatPctModifier(UnitMods unitMod, UnitModifierPctType modifierType, float val); + + float GetFlatModifierValue(UnitMods unitMod, UnitModifierFlatType modifierType) const; + float GetPctModifierValue(UnitMods unitMod, UnitModifierPctType modifierType) const; + + void UpdateUnitMod(UnitMods unitMod); + + // only players have item requirements + virtual bool CheckAttackFitToAuraRequirement(WeaponAttackType /*attackType*/, AuraEffect const* /*aurEff*/) const + { + return true; + } + + virtual void UpdateDamageDoneMods(WeaponAttackType attackType); + void UpdateAllDamageDoneMods(); + + void UpdateDamagePctDoneMods(WeaponAttackType attackType); + void UpdateAllDamagePctDoneMods(); + + float GetTotalStatValue(Stats stat) const; + float GetTotalAuraModValue(UnitMods unitMod) const; + SpellSchools GetSpellSchoolByAuraGroup(UnitMods unitMod) const; + Stats GetStatByAuraGroup(UnitMods unitMod) const; + Powers GetPowerTypeByAuraGroup(UnitMods unitMod) const; + bool CanModifyStats() const + { + return m_canModifyStats; + } + void SetCanModifyStats(bool modifyStats) + { + m_canModifyStats = modifyStats; + } + virtual bool UpdateStats(Stats stat) = 0; + virtual bool UpdateAllStats() = 0; + virtual void UpdateResistances(uint32 school) = 0; + virtual void UpdateAllResistances(); + virtual void UpdateArmor() = 0; + virtual void UpdateMaxHealth() = 0; + virtual void UpdateMaxPower(Powers power) = 0; + virtual uint32 GetPowerIndex(Powers power) const = 0; + virtual void UpdateAttackPowerAndDamage(bool ranged = false) = 0; + virtual void UpdateDamagePhysical(WeaponAttackType attType); + float GetTotalAttackPowerValue(WeaponAttackType attType) const; + float GetWeaponDamageRange(WeaponAttackType attType, WeaponDamageRange type) const; + void SetBaseWeaponDamage(WeaponAttackType attType, WeaponDamageRange damageRange, float value) + { + m_weaponDamage[attType][damageRange] = value; + } + virtual void CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, bool addTotalPct, float& minDamage, float& maxDamage) const = 0; + uint32 CalculateDamage(WeaponAttackType attType, bool normalized, bool addTotalPct) const; + float GetAPMultiplier(WeaponAttackType attType, bool normalized) const; + + bool isInFrontInMap(Unit const* target, float distance, float arc = float(M_PI)) const; + bool isInBackInMap(Unit const* target, float distance, float arc = float(M_PI)) const; + + // Visibility system + bool IsVisible() const; + void SetVisible(bool x); + + // common function for visibility checks for player/creatures with detection code + void OnPhaseChange(); + void UpdateObjectVisibility(bool forced = true) override; + + SpellImmuneContainer m_spellImmune[MAX_SPELL_IMMUNITY]; + uint32 m_lastSanctuaryTime; + + VisibleAuraMap const* GetVisibleAuras() + { + return &m_visibleAuras; + } + AuraApplication* GetVisibleAura(uint8 slot) const; + void SetVisibleAura(uint8 slot, AuraApplication* aur); + void RemoveVisibleAura(uint8 slot); + + bool HasInterruptFlag(SpellAuraInterruptFlags flags) const + { + return m_interruptMask.HasFlag(flags); + } + bool HasInterruptFlag(SpellAuraInterruptFlags2 flags) const + { + return m_interruptMask2.HasFlag(flags); + } + void AddInterruptMask(SpellAuraInterruptFlags flags, SpellAuraInterruptFlags2 flags2) + { + m_interruptMask |= flags; + m_interruptMask2 |= flags2; + } + void UpdateInterruptMask(); + + virtual float GetNativeObjectScale() const + { + return 1.0f; + } + virtual void RecalculateObjectScale(); + uint32 GetDisplayId() const + { + return GetUInt32Value(UNIT_FIELD_DISPLAYID); + } + virtual void SetDisplayId(uint32 modelId); + uint32 GetNativeDisplayId() const + { + return GetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID); + } + void RestoreDisplayId(); + void SetNativeDisplayId(uint32 modelId) + { + SetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID, modelId); + } + void setTransForm(uint32 spellid) + { + m_transform = spellid; + } + uint32 getTransForm() const + { + return m_transform; + } + + // DynamicObject management + void _RegisterDynObject(DynamicObject* dynObj); + void _UnregisterDynObject(DynamicObject* dynObj); + DynamicObject* GetDynObject(uint32 spellId) const; + std::vector GetDynObjects(uint32 spellId) const; + void RemoveDynObject(uint32 spellId); + void RemoveAllDynObjects(); + + GameObject* GetGameObject(uint32 spellId) const; + std::vector GetGameObjects(uint32 spellId) const; + void AddGameObject(GameObject* gameObj); + void RemoveGameObject(GameObject* gameObj, bool del); + void RemoveGameObject(uint32 spellid, bool del); + void RemoveAllGameObjects(); + + void ModifyAuraState(AuraStateType flag, bool apply); + uint32 BuildAuraStateUpdateForTarget(Unit* target) const; + bool HasAuraState(AuraStateType flag, SpellInfo const* spellProto = nullptr, Unit const* Caster = nullptr) const; + void UnsummonAllTotems(); + bool IsMagnet() const; + Unit* GetMagicHitRedirectTarget(Unit* victim, SpellInfo const* spellInfo); + Unit* GetMeleeHitRedirectTarget(Unit* victim, SpellInfo const* spellInfo = nullptr); + + int32 SpellBaseDamageBonusDone(SpellSchoolMask schoolMask, bool withSpellPowerPctMod = false) const; + int32 SpellBaseDamageBonusTaken(SpellInfo const* spellInfo) const; + uint32 SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, uint32 pdamage, DamageEffectType damagetype, uint8 effIndex, uint32 stack = 1) const; + float SpellDamagePctDone(Unit* victim, SpellInfo const* spellProto, DamageEffectType damagetype) const; + uint32 SpellDamageBonusTaken(Unit* caster, SpellInfo const* spellProto, uint32 pdamage, DamageEffectType damagetype) const; + int32 SpellBaseHealingBonusDone(SpellSchoolMask schoolMask, bool withSpellPowerPctMod = false) const; + int32 SpellBaseHealingBonusTaken(SpellSchoolMask schoolMask) const; + uint32 SpellHealingBonusDone(Unit* victim, SpellInfo const* spellProto, uint32 healamount, DamageEffectType damagetype, uint8 effIndex, uint32 stack = 1) const; + float SpellHealingPctDone(Unit* victim, SpellInfo const* spellProto) const; + uint32 SpellHealingBonusTaken(Unit* caster, SpellInfo const* spellProto, uint32 healamount, DamageEffectType damagetype, uint32 stack = 1) const; + + uint32 MeleeDamageBonusDone(Unit* pVictim, uint32 damage, WeaponAttackType attType, SpellInfo const* spellProto = nullptr, bool useSpellBonusData = true); + uint32 MeleeDamageBonusTaken(Unit* attacker, uint32 pdamage, WeaponAttackType attType, SpellInfo const* spellProto = nullptr); + + bool isSpellBlocked(Unit* victim, SpellInfo const* spellProto); + bool isBlockCritical(); + float SpellCritChanceDone(SpellInfo const* spellInfo, SpellSchoolMask schoolMask, WeaponAttackType attackType = BASE_ATTACK) const; + float SpellCritChanceTaken(Unit const* caster, SpellInfo const* spellInfo, SpellSchoolMask schoolMask, float doneChance, WeaponAttackType attackType = BASE_ATTACK) const; + static uint32 SpellCriticalDamageBonus(Unit const* caster, SpellInfo const* spellProto, uint32 damage); + static uint32 SpellCriticalHealingBonus(Unit const* caster, uint32 damage); + + uint32 GetCastingTimeForBonus(SpellInfo const* spellProto, DamageEffectType damagetype, uint32 CastingTime) const; + float CalculateDefaultCoefficient(SpellInfo const* spellInfo, DamageEffectType damagetype) const; + + uint32 GetRemainingPeriodicAmount(ObjectGuid caster, uint32 spellId, AuraType auraType, uint8 effectIndex = 0) const; + + void ApplySpellImmune(uint32 spellId, uint32 op, uint32 type, bool apply); + virtual bool IsImmunedToSpell(SpellInfo const* spellInfo, Unit* caster, Optional effectMask = {}) const; // redefined in Creature + uint32 GetSchoolImmunityMask() const; + uint32 GetDamageImmunityMask() const; + uint32 GetMechanicImmunityMask() const; + + bool IsImmunedToDamage(SpellSchoolMask meleeSchoolMask) const; + bool IsImmunedToDamage(SpellInfo const* spellInfo) const; + virtual bool IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index, Unit* caster) const; // redefined in Creature + + static bool IsDamageReducedByArmor(SpellSchoolMask damageSchoolMask, SpellInfo const* spellInfo = nullptr, int8 effIndex = -1); + static uint32 CalcArmorReducedDamage(Unit const* attacker, Unit* victim, const uint32 damage, SpellInfo const* spellInfo, WeaponAttackType attackType = MAX_ATTACK, uint8 attackerLevel = 0); + static uint32 CalcSpellResistedDamage(Unit const* attacker, Unit* victim, uint32 damage, SpellSchoolMask schoolMask, SpellInfo const* spellInfo); + static void CalcAbsorbResist(DamageInfo& damageInfo); + static void CalcHealAbsorb(HealInfo& healInfo); + + void UpdateSpeed(UnitMoveType mtype); + float GetSpeed(UnitMoveType mtype) const; + float GetSpeedRate(UnitMoveType mtype) const + { + return m_speed_rate[mtype]; + } + void SetSpeed(UnitMoveType mtype, float newValue); + void SetSpeedRate(UnitMoveType mtype, float rate); + + private: + void SetSpeedRateReal(UnitMoveType mtype, float rate); + + public: + float ApplyEffectModifiers(SpellInfo const* spellProto, uint8 effect_index, float value) const; + int32 CalculateSpellDamage(Unit const* target, SpellInfo const* spellProto, uint8 effect_index, int32 const* basePoints = nullptr) const; + int32 ModSpellDuration(SpellInfo const* spellProto, Unit const* target, int32 duration, bool positive, uint32 effectMask); + void ModSpellCastTime(SpellInfo const* spellProto, int32& castTime, Spell* spell = nullptr); + void ModSpellDurationTime(SpellInfo const* spellProto, int32& castTime, Spell* spell = nullptr); + + // Makes the unit follow the given target. Use this function above using the MotionMaster::MoveFollow for default follow behaivior. + void FollowTarget(Unit* target); + + FormationFollowerGUIDContainer GetFormationFollowers() + { + return _formationFollowers; + } + void AddFormationFollower(Unit* follower) + { + _formationFollowers.push_back(follower->GetGUID()); + } + void RemoveFormationFollower(Unit* follower); + bool HasFormationFollower(Unit* follower) const; + + void PursuerAdded(PursuingType type, AbstractPursuer* pursuer) + { + _unitsPursuingMe[AsUnderlyingType(type)].insert(pursuer); + }; + void PursuerRemoved(PursuingType type, AbstractPursuer* pursuer) + { + _unitsPursuingMe[AsUnderlyingType(type)].erase(pursuer); + }; + + // Sets the target of all stored AbstractPursuers to nullptr, allowing the involved movement generators to do safe nullptr checks + void RemoveAllPursuers(); + + MotionMaster* GetMotionMaster() + { + return i_motionMaster; + } + MotionMaster const* GetMotionMaster() const + { + return i_motionMaster; + } + + bool IsStopped() const + { + return !(HasUnitState(UNIT_STATE_MOVING)); + } + void StopMoving(); + void PauseMovement(uint32 timer = 0, uint8 slot = 0, bool forced = true); // timer in ms + void ResumeMovement(uint32 timer = 0, uint8 slot = 0); // timer in ms + + void AddUnitMovementFlag(uint32 f) + { + m_movementInfo.AddMovementFlag(f); + } + void RemoveUnitMovementFlag(uint32 f) + { + m_movementInfo.RemoveMovementFlag(f); + } + bool HasUnitMovementFlag(uint32 f) const + { + return m_movementInfo.HasMovementFlag(f); + } + uint32 GetUnitMovementFlags() const + { + return m_movementInfo.GetMovementFlags(); + } + void SetUnitMovementFlags(uint32 f) + { + m_movementInfo.SetMovementFlags(f); + } + + void AddExtraUnitMovementFlag(uint16 f) + { + m_movementInfo.AddExtraMovementFlag(f); + } + void RemoveExtraUnitMovementFlag(uint16 f) + { + m_movementInfo.RemoveExtraMovementFlag(f); + } + bool HasExtraUnitMovementFlag(uint16 f) const + { + return m_movementInfo.HasExtraMovementFlag(f); + } + uint16 GetExtraUnitMovementFlags() const + { + return m_movementInfo.GetExtraMovementFlags(); + } + void SetExtraUnitMovementFlags(uint16 f) + { + m_movementInfo.SetExtraMovementFlags(f); + } + bool IsSplineEnabled() const; - Unit* m_charmer; // Unit that is charming ME - Unit* m_charmed; // Unit that is being charmed BY ME - CharmInfo* m_charmInfo; - SharedVisionList m_sharedVision; - GameClient* _gameClientMovingMe; + void SetControlled(bool apply, UnitState state); + void ApplyControlStatesIfNeeded(); - MotionMaster* i_motionMaster; + void AddComboPointHolder(ObjectGuid lowguid) + { + m_ComboPointHolders.insert(lowguid); + } + void RemoveComboPointHolder(ObjectGuid lowguid) + { + m_ComboPointHolders.erase(lowguid); + } + void ClearComboPointHolders(); + + ///----------Pet responses methods----------------- + void SendPetActionFeedback(uint8 msg); + void SendPetTalk(uint32 pettalk); + void SendPetAIReaction(ObjectGuid guid); + ///----------End of Pet responses methods---------- + + void PropagateSpeedChange(); + + // reactive attacks + void ClearAllReactives(); + void StartReactiveTimer(ReactiveType reactive) + { + m_reactiveTimer[reactive] = REACTIVE_TIMER_START; + } + void UpdateReactives(uint32 p_time); + + // group updates + void UpdateAuraForGroup(uint8 slot); + + // proc trigger system + bool CanProc() const + { + return !m_procDeep; + } + void SetCantProc(bool apply); + + uint32 GetModelForForm(ShapeshiftForm form, uint32 spellId) const; + uint32 GetModelForTotem(PlayerTotemType totemType); + + friend class VehicleJoinEvent; + ObjectGuid LastCharmerGUID; + bool CreateVehicleKit(uint32 id, uint32 creatureEntry, bool loading = false); + void RemoveVehicleKit(bool onRemoveFromWorld = false); + Vehicle* GetVehicleKit() const + { + return m_vehicleKit; + } + Vehicle* GetVehicle() const + { + return m_vehicle; + } + void SetVehicle(Vehicle* vehicle) + { + m_vehicle = vehicle; + } + bool IsOnVehicle(Unit const* vehicle) const; + Unit* GetVehicleBase() const; + Creature* GetVehicleCreatureBase() const; + ObjectGuid GetTransGUID() const override; + /// Returns the transport this unit is on directly (if on vehicle and transport, return vehicle) + TransportBase* GetDirectTransport() const; + + bool m_ControlledByPlayer; + + bool HandleSpellClick(Unit* clicker, int8 seatId = -1); + void EnterVehicle(Unit* base, int8 seatId = -1); + void ExitVehicle(Position const* exitPosition = nullptr); + void ChangeSeat(int8 seatId, bool next = true); + + // Should only be called by AuraEffect::HandleAuraControlVehicle(AuraApplication const* auraApp, uint8 mode, bool apply) const; + void _ExitVehicle(Position const* exitPosition = nullptr); + void _EnterVehicle(Vehicle* vehicle, int8 seatId, AuraApplication const* aurApp = nullptr); + + void WriteMovementInfo(WorldPacket& data, Movement::ExtraMovementStatusElement* extras = nullptr, uint32* movementCounter = nullptr); + + bool isMoving() const + { + return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_MASK_MOVING); + } + bool isTurning() const + { + return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_MASK_TURNING); + } + virtual bool CanFly() const = 0; + bool IsFlying() const + { + return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_FLYING | MOVEMENTFLAG_DISABLE_GRAVITY); + } + bool IsFalling() const; + virtual bool CanEnterWater() const = 0; + virtual bool CanSwim() const; - uint32 m_reactiveTimer[MAX_REACTIVE]; + float GetHoverOffset() const + { + return HasUnitMovementFlag(MOVEMENTFLAG_HOVER) ? GetFloatValue(UNIT_FIELD_HOVERHEIGHT) : 0.0f; + } - Vehicle* m_vehicle; - Vehicle* m_vehicleKit; + uint32 GetMovementCounterAndInc() + { + return m_movementCounter++; + } + uint32 GetMovementCounter() + { + return m_movementCounter; + } + void ClearPendingMovementChangeForType(MovementChangeType changeType); + void AssignPendingMovementChange(MovementChangeType changeType, PlayerMovementPendingChange&& newChange); + bool HasPendingMovementChange() const + { + return !m_pendingMovementChanges.empty(); + } + PlayerMovementPendingChange const* GetPendingMovementChange(MovementChangeType changeType) const; + void PurgeAndApplyPendingMovementChanges(bool informObservers = true); - uint32 m_unitTypeMask; - LiquidTypeEntry const* _lastLiquid; - uint32 _powerBarId; - float _powerFraction[MAX_POWERS_PER_CLASS]; - int32 _powerUpdateTimer; - int32 _healthRegenerationTimer; + void RewardRage(uint32 baseRage, bool attacker); - bool IsAlwaysVisibleFor(WorldObject const* seer) const override; - bool IsAlwaysDetectableFor(WorldObject const* seer) const override; + void OutDebugInfo() const; + virtual bool IsLoading() const + { + return false; + } + bool IsDuringRemoveFromWorld() const + { + return m_duringRemoveFromWorld; + } - void DisableSpline(); + Pet* ToPet() + { + if (IsPet()) + return reinterpret_cast(this); + else + return nullptr; + } + Pet const* ToPet() const + { + if (IsPet()) + return reinterpret_cast(this); + else + return nullptr; + } - void ProcessPositionDataChanged(PositionFullTerrainStatus const& data) override; - virtual void ProcessTerrainStatusUpdate(ZLiquidStatus oldLiquidStatus, Optional const& newLiquidData); + Totem* ToTotem() + { + if (IsTotem()) + return reinterpret_cast(this); + else + return nullptr; + } + Totem const* ToTotem() const + { + if (IsTotem()) + return reinterpret_cast(this); + else + return nullptr; + } - // notifiers - virtual void AtEnterCombat(); - virtual void AtExitCombat(); + TempSummon* ToTempSummon() + { + if (IsSummon()) + return reinterpret_cast(this); + else + return nullptr; + } + TempSummon const* ToTempSummon() const + { + if (IsSummon()) + return reinterpret_cast(this); + else + return nullptr; + } - virtual void AtEngage(Unit* /*target*/) {} - virtual void AtDisengage() {} + ObjectGuid GetTarget() const + { + return GetGuidValue(UNIT_FIELD_TARGET); + } + virtual void SetTarget(ObjectGuid /*guid*/) = 0; + + // Movement info + Movement::MoveSpline* movespline; + + int32 GetHighestExclusiveSameEffectSpellGroupValue(AuraEffect const* aurEff, AuraType auraType, bool checkMiscValue = false, int32 miscValue = 0) const; + bool IsHighestExclusiveAura(Aura const* aura, bool removeOtherAuraApplications = false); + bool IsHighestExclusiveAuraEffect(SpellInfo const* spellInfo, AuraType auraType, int32 effectAmount, uint8 auraEffectMask, bool removeOtherAuraApplications = false); + + virtual void Talk(std::string const& text, ChatMsg msgType, Language language, float textRange, WorldObject const* target); + virtual void Say(std::string const& text, Language language, WorldObject const* target = nullptr); + virtual void Yell(std::string const& text, Language language, WorldObject const* target = nullptr); + virtual void TextEmote(std::string const& text, WorldObject const* target = nullptr, bool isBossEmote = false); + virtual void Whisper(std::string const& text, Language language, Player* target, bool isBossWhisper = false); + virtual void Talk(uint32 textId, ChatMsg msgType, float textRange, WorldObject const* target); + virtual void Say(uint32 textId, WorldObject const* target = nullptr); + virtual void Yell(uint32 textId, WorldObject const* target = nullptr); + virtual void TextEmote(uint32 textId, WorldObject const* target = nullptr, bool isBossEmote = false); + virtual void Whisper(uint32 textId, Player* target, bool isBossWhisper = false); + + TaskScheduler& GetScheduler() + { + return _scheduler; + } - void InterruptMovementBasedAuras(); - void CheckPendingMovementAcks(); + float GetCollisionHeight() const override; - uint32 GetPowerUpdateInterval() const { return IsPlayer() ? PLAYER_POWER_UPDATE_INTERVAL : UNIT_POWER_UPDATE_INTERVAL; } - private: + // returns if the unit is allowed to enter combat + bool IsIgnoringCombat() const + { + return _isIgnoringCombat; + } + // enables/disables combat permission of this unit + void SetIgnoringCombat(bool apply) + { + _isIgnoringCombat = apply; + } - void UpdateSplineMovement(uint32 t_diff); - void UpdateSplinePosition(); + // Queues up a spell cast request that has been received via packet and processes it whenever possible. + void RequestSpellCast(PendingSpellCastRequest castRequest, SpellInfo const* spellInfo); + void CancelPendingCastRequest(); + bool CanRequestSpellCast(SpellInfo const* spell) const; - // player or player's pet - float GetCombatRatingReduction(CombatRating cr) const; - uint32 GetCombatRatingDamageReduction(CombatRating cr, float rate, float cap, uint32 damage) const; + void DestroyForPlayer(Player* target, bool onDeath = false) const override; - void ProcSkillsAndReactives(bool isVictim, Unit* procTarget, uint32 typeMask, uint32 hitMask, WeaponAttackType attType); + void GetAttackableUnitListInRange(std::list& list, float fMaxSearchRange) const; + void GetFriendlyUnitListInRange(std::list& list, float fMaxSearchRange, bool exceptSelf = false) const; + void GetAreatriggerListInRange(std::list& list, float fMaxSearchRange) const; + void GetAreaTriggerListWithSpellIDInRange(std::list& list, uint32 spellid, float fMaxSearchRange) const; - protected: - void SetFeared(bool apply); - void SetConfused(bool apply); - void SetStunned(bool apply); - void SetRooted(bool apply, bool packetOnly = false); + protected: + explicit Unit(bool isWorldObject); - private: - uint32 m_state; // Even derived shouldn't modify - TimeTrackerSmall m_splineSyncTimer; + void BuildValuesUpdate(uint8 updatetype, ByteBuffer* data, Player* target) const override; - DiminishingReturn m_Diminishing[DIMINISHING_MAX]; + void _UpdateSpells(uint32 time); + void _DeleteRemovedAuras(); - // Threat+combat management - bool m_isEngaged; - // Manage all Units that are threatened by us - friend class CombatManager; - CombatManager m_combatManager; - friend class ThreatManager; - ThreatManager m_threatManager; + void _UpdateAutoRepeatSpell(); - void UpdateCharmAI(); - void RestoreDisabledAI(); - typedef std::stack> UnitAIStack; - UnitAIStack i_AIs; - std::shared_ptr i_AI; - bool m_aiLocked; + bool m_AutoRepeatFirstCast; - GuidSet m_ComboPointHolders; + uint32 m_attackTimer[MAX_ATTACK]; - bool m_cleanupDone; // lock made to not add stuff after cleanup before delete - bool m_duringRemoveFromWorld; // lock made to not add stuff after begining removing from world + float m_createStats[MAX_STATS]; - uint32 _oldFactionId; ///< faction before charm - bool _isWalkingBeforeCharm; ///< Are we walking before we were charmed? + AttackerSet m_attackers; + Unit* m_attacking; - SpellHistory* m_spellHistory; + DeathState m_deathState; - TaskScheduler _scheduler; + int32 m_procDeep; - std::unordered_map m_SummonedCreatures; + typedef std::list DynObjectList; + DynObjectList m_dynObj; - PositionUpdateInfo _positionUpdateInfo; + typedef std::list GameObjectList; + GameObjectList m_gameObj; - FormationFollowerGUIDContainer _formationFollowers; + uint32 m_transform; - std::array, AsUnderlyingType(PursuingType::Max)> _unitsPursuingMe; + Spell* m_currentSpells[CURRENT_MAX_SPELL]; - bool _isIgnoringCombat; + AuraMap m_ownedAuras; + AuraApplicationMap m_appliedAuras; + AuraList m_removedAuras; + AuraMap::iterator m_auraUpdateIterator; + uint32 m_removedAurasCount; - Optional _pendingSpellCastRequest; - void ProcessPendingSpellCastRequest(); - void ProcessItemCast(PendingSpellCastRequest const& castRequest, SpellCastTargets const& targets); - bool CanExecutePendingSpellCastRequest(SpellInfo const* spellInfo) const; + AuraEffectList m_modAuras[TOTAL_AURAS]; + AurasBySpellIdMap m_ltAuras; // cast limited target auras + AuraApplicationList m_interruptableAuras; // auras which have interrupt mask applied on unit + AuraStateAurasMap m_auraStateAuras; // Used for improve performance of aura state checks on aura apply/remove + EnumFlag m_interruptMask; + EnumFlag m_interruptMask2; - /* Player Movement fields START*/ + float m_auraFlatModifiersGroup[UNIT_MOD_END][MODIFIER_TYPE_FLAT_END]; + float m_auraPctModifiersGroup[UNIT_MOD_END][MODIFIER_TYPE_PCT_END]; + float m_weaponDamage[MAX_ATTACK][2]; + bool m_canModifyStats; + VisibleAuraMap m_visibleAuras; - // when a player controls this unit, and when change is made to this unit which requires an ack from the client to be acted (change of speed for example), this movementCounter is incremented - uint32 m_movementCounter; - std::unordered_map m_pendingMovementChanges; + float m_speed_rate[MAX_MOVE_TYPE]; - /* Player Movement fields END*/ + Unit* m_charmer; // Unit that is charming ME + Unit* m_charmed; // Unit that is being charmed BY ME + CharmInfo* m_charmInfo; + SharedVisionList m_sharedVision; + GameClient* _gameClientMovingMe; + + MotionMaster* i_motionMaster; + + uint32 m_reactiveTimer[MAX_REACTIVE]; + + Vehicle* m_vehicle; + Vehicle* m_vehicleKit; + + uint32 m_unitTypeMask; + LiquidTypeEntry const* _lastLiquid; + uint32 _powerBarId; + float _powerFraction[MAX_POWERS_PER_CLASS]; + int32 _powerUpdateTimer; + int32 _healthRegenerationTimer; + + bool IsAlwaysVisibleFor(WorldObject const* seer) const override; + bool IsAlwaysDetectableFor(WorldObject const* seer) const override; + + void DisableSpline(); + + void ProcessPositionDataChanged(PositionFullTerrainStatus const& data) override; + virtual void ProcessTerrainStatusUpdate(ZLiquidStatus oldLiquidStatus, Optional const& newLiquidData); + + // notifiers + virtual void AtEnterCombat(); + virtual void AtExitCombat(); + + virtual void AtEngage(Unit* /*target*/) + { + } + virtual void AtDisengage() + { + } + + void InterruptMovementBasedAuras(); + void CheckPendingMovementAcks(); + + uint32 GetPowerUpdateInterval() const + { + return IsPlayer() ? PLAYER_POWER_UPDATE_INTERVAL : UNIT_POWER_UPDATE_INTERVAL; + } + + private: + void UpdateSplineMovement(uint32 t_diff); + void UpdateSplinePosition(); + + // player or player's pet + float GetCombatRatingReduction(CombatRating cr) const; + uint32 GetCombatRatingDamageReduction(CombatRating cr, float rate, float cap, uint32 damage) const; + + void ProcSkillsAndReactives(bool isVictim, Unit* procTarget, uint32 typeMask, uint32 hitMask, WeaponAttackType attType); + + protected: + void SetFeared(bool apply); + void SetConfused(bool apply); + void SetStunned(bool apply); + void SetRooted(bool apply, bool packetOnly = false); + + private: + uint32 m_state; // Even derived shouldn't modify + TimeTrackerSmall m_splineSyncTimer; + + DiminishingReturn m_Diminishing[DIMINISHING_MAX]; + + // Threat+combat management + bool m_isEngaged; + // Manage all Units that are threatened by us + friend class CombatManager; + CombatManager m_combatManager; + friend class ThreatManager; + ThreatManager m_threatManager; + + void UpdateCharmAI(); + void RestoreDisabledAI(); + typedef std::stack> UnitAIStack; + UnitAIStack i_AIs; + std::shared_ptr i_AI; + bool m_aiLocked; + + GuidSet m_ComboPointHolders; + + bool m_cleanupDone; // lock made to not add stuff after cleanup before delete + bool m_duringRemoveFromWorld; // lock made to not add stuff after begining removing from world + + uint32 _oldFactionId; ///< faction before charm + bool _isWalkingBeforeCharm; ///< Are we walking before we were charmed? + + SpellHistory* m_spellHistory; + + TaskScheduler _scheduler; + + std::unordered_map m_SummonedCreatures; + + PositionUpdateInfo _positionUpdateInfo; + + FormationFollowerGUIDContainer _formationFollowers; + + std::array, AsUnderlyingType(PursuingType::Max)> _unitsPursuingMe; + + bool _isIgnoringCombat; + + Optional _pendingSpellCastRequest; + void ProcessPendingSpellCastRequest(); + void ProcessItemCast(PendingSpellCastRequest const& castRequest, SpellCastTargets const& targets); + bool CanExecutePendingSpellCastRequest(SpellInfo const* spellInfo) const; + + /* Player Movement fields START*/ + + // when a player controls this unit, and when change is made to this unit which requires an ack from the client to be acted (change of speed for example), this movementCounter is incremented + uint32 m_movementCounter; + std::unordered_map m_pendingMovementChanges; + + /* Player Movement fields END*/ }; namespace Firelands { - // Binary predicate for sorting Units based on percent value of a power - class PowerPctOrderPred - { - public: - PowerPctOrderPred(Powers power, bool ascending = true) : _power(power), _ascending(ascending) { } - - bool operator()(WorldObject const* objA, WorldObject const* objB) const - { - Unit const* a = objA->ToUnit(); - Unit const* b = objB->ToUnit(); - float rA = (a && a->GetMaxPower(_power)) ? float(a->GetPower(_power)) / float(a->GetMaxPower(_power)) : 0.0f; - float rB = (b && b->GetMaxPower(_power)) ? float(b->GetPower(_power)) / float(b->GetMaxPower(_power)) : 0.0f; - return _ascending ? rA < rB : rA > rB; - } - - bool operator()(Unit const* a, Unit const* b) const - { - float rA = a->GetMaxPower(_power) ? float(a->GetPower(_power)) / float(a->GetMaxPower(_power)) : 0.0f; - float rB = b->GetMaxPower(_power) ? float(b->GetPower(_power)) / float(b->GetMaxPower(_power)) : 0.0f; - return _ascending ? rA < rB : rA > rB; - } - - private: - Powers const _power; - bool const _ascending; - }; +// Binary predicate for sorting Units based on percent value of a power +class PowerPctOrderPred +{ + public: + PowerPctOrderPred(Powers power, bool ascending = true) : _power(power), _ascending(ascending) + { + } - // Binary predicate for sorting Units based on percent value of health - class HealthPctOrderPred - { - public: - HealthPctOrderPred(bool ascending = true) : _ascending(ascending) { } - - bool operator()(WorldObject const* objA, WorldObject const* objB) const - { - Unit const* a = objA->ToUnit(); - Unit const* b = objB->ToUnit(); - float rA = (a && a->GetMaxHealth()) ? float(a->GetHealth()) / float(a->GetMaxHealth()) : 0.0f; - float rB = (b && b->GetMaxHealth()) ? float(b->GetHealth()) / float(b->GetMaxHealth()) : 0.0f; - return _ascending ? rA < rB : rA > rB; - } - - bool operator() (Unit const* a, Unit const* b) const - { - float rA = a->GetMaxHealth() ? float(a->GetHealth()) / float(a->GetMaxHealth()) : 0.0f; - float rB = b->GetMaxHealth() ? float(b->GetHealth()) / float(b->GetMaxHealth()) : 0.0f; - return _ascending ? rA < rB : rA > rB; - } - - private: - bool const _ascending; - }; -} + bool operator()(WorldObject const* objA, WorldObject const* objB) const + { + Unit const* a = objA->ToUnit(); + Unit const* b = objB->ToUnit(); + float rA = (a && a->GetMaxPower(_power)) ? float(a->GetPower(_power)) / float(a->GetMaxPower(_power)) : 0.0f; + float rB = (b && b->GetMaxPower(_power)) ? float(b->GetPower(_power)) / float(b->GetMaxPower(_power)) : 0.0f; + return _ascending ? rA < rB : rA > rB; + } + + bool operator()(Unit const* a, Unit const* b) const + { + float rA = a->GetMaxPower(_power) ? float(a->GetPower(_power)) / float(a->GetMaxPower(_power)) : 0.0f; + float rB = b->GetMaxPower(_power) ? float(b->GetPower(_power)) / float(b->GetMaxPower(_power)) : 0.0f; + return _ascending ? rA < rB : rA > rB; + } + + private: + Powers const _power; + bool const _ascending; +}; + +// Binary predicate for sorting Units based on percent value of health +class HealthPctOrderPred +{ + public: + HealthPctOrderPred(bool ascending = true) : _ascending(ascending) + { + } + + bool operator()(WorldObject const* objA, WorldObject const* objB) const + { + Unit const* a = objA->ToUnit(); + Unit const* b = objB->ToUnit(); + float rA = (a && a->GetMaxHealth()) ? float(a->GetHealth()) / float(a->GetMaxHealth()) : 0.0f; + float rB = (b && b->GetMaxHealth()) ? float(b->GetHealth()) / float(b->GetMaxHealth()) : 0.0f; + return _ascending ? rA < rB : rA > rB; + } + + bool operator()(Unit const* a, Unit const* b) const + { + float rA = a->GetMaxHealth() ? float(a->GetHealth()) / float(a->GetMaxHealth()) : 0.0f; + float rB = b->GetMaxHealth() ? float(b->GetHealth()) / float(b->GetMaxHealth()) : 0.0f; + return _ascending ? rA < rB : rA > rB; + } + + private: + bool const _ascending; +}; +} // namespace Firelands #endif diff --git a/src/server/game/Handlers/MovementHandler.cpp b/src/server/game/Handlers/MovementHandler.cpp index 61e5b6fd..71047043 100644 --- a/src/server/game/Handlers/MovementHandler.cpp +++ b/src/server/game/Handlers/MovementHandler.cpp @@ -16,35 +16,35 @@ */ #include "AnticheatMgr.h" +#include "Battleground.h" #include "Common.h" -#include "WorldPacket.h" -#include "WorldSession.h" -#include "ObjectAccessor.h" -#include "Opcodes.h" -#include "Log.h" #include "Corpse.h" #include "DBCStores.h" -#include "Player.h" +#include "GameClient.h" +#include "GameTime.h" +#include "InstanceSaveMgr.h" +#include "Log.h" #include "MapManager.h" #include "MotionMaster.h" #include "MovementGenerator.h" #include "MovementPacketSender.h" #include "MovementPackets.h" #include "MovementStructures.h" -#include "Transport.h" -#include "Battleground.h" -#include "InstanceSaveMgr.h" +#include "ObjectAccessor.h" #include "ObjectMgr.h" -#include "Vehicle.h" -#include "GameTime.h" -#include "GameClient.h" +#include "Opcodes.h" +#include "Player.h" #include "SpellAuraEffects.h" #include "SpellMgr.h" -#include +#include "Transport.h" +#include "Vehicle.h" +#include "WorldPacket.h" +#include "WorldSession.h" #include #include +#include -void WorldSession::HandleMoveWorldportAckOpcode(WorldPacket & /*recvData*/) +void WorldSession::HandleMoveWorldportAckOpcode(WorldPacket& /*recvData*/) { LOG_DEBUG("network", "WORLD: got MSG_MOVE_WORLDPORT_ACK."); HandleMoveWorldportAck(); @@ -85,7 +85,8 @@ void WorldSession::HandleMoveWorldportAck() if (GetPlayer()->IsInWorld()) { - LOG_ERROR("network", "%s %s is still in world when teleported from map %s (%u) to new map %s (%u)", GetPlayer()->GetGUID().ToString().c_str(), GetPlayer()->GetName().c_str(), oldMap->GetMapName(), oldMap->GetId(), newMap ? newMap->GetMapName() : "Unknown", loc.GetMapId()); + LOG_ERROR("network", "%s %s is still in world when teleported from map %s (%u) to new map %s (%u)", GetPlayer()->GetGUID().ToString().c_str(), GetPlayer()->GetName().c_str(), + oldMap->GetMapName(), oldMap->GetId(), newMap ? newMap->GetMapName() : "Unknown", loc.GetMapId()); oldMap->RemovePlayerFromMap(GetPlayer(), false); } @@ -94,7 +95,8 @@ void WorldSession::HandleMoveWorldportAck() // while the player is in transit, for example the map may get full if (!newMap || newMap->CannotEnter(GetPlayer())) { - LOG_ERROR("network", "Map %d (%s) could not be created for player %d (%s), porting player to homebind", loc.GetMapId(), newMap ? newMap->GetMapName() : "Unknown", GetPlayer()->GetGUID().GetCounter(), GetPlayer()->GetName().c_str()); + LOG_ERROR("network", "Map %d (%s) could not be created for player %d (%s), porting player to homebind", loc.GetMapId(), newMap ? newMap->GetMapName() : "Unknown", + GetPlayer()->GetGUID().GetCounter(), GetPlayer()->GetName().c_str()); GetPlayer()->TeleportTo(GetPlayer()->m_homebindMapId, GetPlayer()->m_homebindX, GetPlayer()->m_homebindY, GetPlayer()->m_homebindZ, GetPlayer()->GetOrientation()); return; } @@ -118,8 +120,8 @@ void WorldSession::HandleMoveWorldportAck() if (!GetPlayer()->GetMap()->AddPlayerToMap(GetPlayer())) { - LOG_ERROR("network", "WORLD: failed to teleport player %s (%d) to map %d (%s) because of unknown reason!", - GetPlayer()->GetName().c_str(), GetPlayer()->GetGUID().GetCounter(), loc.GetMapId(), newMap ? newMap->GetMapName() : "Unknown"); + LOG_ERROR("network", "WORLD: failed to teleport player %s (%d) to map %d (%s) because of unknown reason!", GetPlayer()->GetName().c_str(), GetPlayer()->GetGUID().GetCounter(), loc.GetMapId(), + newMap ? newMap->GetMapName() : "Unknown"); GetPlayer()->ResetMap(); GetPlayer()->SetMap(oldMap); GetPlayer()->TeleportTo(GetPlayer()->m_homebindMapId, GetPlayer()->m_homebindX, GetPlayer()->m_homebindY, GetPlayer()->m_homebindZ, GetPlayer()->GetOrientation()); @@ -218,7 +220,7 @@ void WorldSession::HandleMoveWorldportAck() // resummon pet GetPlayer()->ResummonPetTemporaryUnSummonedIfAny(); - //lets process all delayed operations on successful teleport + // lets process all delayed operations on successful teleport GetPlayer()->ProcessDelayedOperations(); } @@ -248,7 +250,6 @@ void WorldSession::HandleMoveTeleportAck(WorldPackets::Movement::MoveTeleportAck if (!plMover || !plMover->IsBeingTeleportedNear()) return; - plMover->SetSemaphoreTeleportNear(false); uint32 old_zone = plMover->GetZoneId(); @@ -282,7 +283,7 @@ void WorldSession::HandleMoveTeleportAck(WorldPackets::Movement::MoveTeleportAck // resummon pet GetPlayer()->ResummonPetTemporaryUnSummonedIfAny(); - //lets process all delayed operations on successful teleport + // lets process all delayed operations on successful teleport GetPlayer()->ProcessDelayedOperations(); } @@ -345,7 +346,7 @@ void WorldSession::HandleMovementOpcode(uint16 opcode, MovementInfo& movementInf return; if (!Firelands::IsValidMapCoord(movementInfo.pos.GetPositionX() + movementInfo.transport.pos.GetPositionX(), movementInfo.pos.GetPositionY() + movementInfo.transport.pos.GetPositionY(), - movementInfo.pos.GetPositionZ() + movementInfo.transport.pos.GetPositionZ(), movementInfo.pos.GetOrientation() + movementInfo.transport.pos.GetOrientation())) + movementInfo.pos.GetPositionZ() + movementInfo.transport.pos.GetPositionZ(), movementInfo.pos.GetOrientation() + movementInfo.transport.pos.GetOrientation())) return; // if we boarded a transport, add us to it @@ -375,7 +376,7 @@ void WorldSession::HandleMovementOpcode(uint16 opcode, MovementInfo& movementInf if (!mover->GetTransport() && !mover->GetVehicle()) movementInfo.transport.Reset(); } - else if (plrMover && plrMover->GetTransport()) // if we were on a transport, leave + else if (plrMover && plrMover->GetTransport()) // if we were on a transport, leave plrMover->GetTransport()->RemovePassenger(plrMover); // fall damage generation (ignore in flight case that can be triggered also at lags in moment teleportation to another map). @@ -428,7 +429,7 @@ void WorldSession::HandleMovementOpcode(uint16 opcode, MovementInfo& movementInf mover->WriteMovementInfo(data); mover->SendMessageToSet(&data, _player); - if (plrMover) // nothing is charmed, or player charmed + if (plrMover) // nothing is charmed, or player charmed { if (plrMover->IsSitState() && (movementInfo.flags & (MOVEMENTFLAG_MASK_MOVING | MOVEMENTFLAG_MASK_TURNING))) plrMover->SetStandState(UNIT_STAND_STATE_STAND); @@ -458,12 +459,12 @@ void WorldSession::HandleMovementOpcode(uint16 opcode, MovementInfo& movementInf if (opcode == MSG_MOVE_JUMP) { plrMover->RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags2::Jump); - plrMover->ProcSkillsAndAuras(nullptr, PROC_FLAG_JUMP, PROC_FLAG_NONE, PROC_SPELL_TYPE_MASK_ALL, PROC_SPELL_PHASE_NONE, PROC_HIT_NONE, nullptr, nullptr, nullptr); + Unit::ProcSkillsAndAuras(plrMover, nullptr, PROC_FLAG_JUMP, PROC_FLAG_NONE, PROC_SPELL_TYPE_MASK_ALL, PROC_SPELL_PHASE_NONE, PROC_HIT_NONE, nullptr, nullptr, nullptr); } } } -void WorldSession::HandleForceSpeedChangeAck(WorldPacket &recvData) +void WorldSession::HandleForceSpeedChangeAck(WorldPacket& recvData) { /* extract packet */ MovementInfo movementInfo; @@ -489,18 +490,36 @@ void WorldSession::HandleForceSpeedChangeAck(WorldPacket &recvData) UnitMoveType move_type; switch (recvData.GetOpcode()) { - case CMSG_MOVE_FORCE_WALK_SPEED_CHANGE_ACK: move_type = MOVE_WALK; break; - case CMSG_MOVE_FORCE_RUN_SPEED_CHANGE_ACK: move_type = MOVE_RUN; break; - case CMSG_MOVE_FORCE_RUN_BACK_SPEED_CHANGE_ACK: move_type = MOVE_RUN_BACK; break; - case CMSG_MOVE_FORCE_SWIM_SPEED_CHANGE_ACK: move_type = MOVE_SWIM; break; - case CMSG_MOVE_FORCE_SWIM_BACK_SPEED_CHANGE_ACK: move_type = MOVE_SWIM_BACK; break; - case CMSG_MOVE_FORCE_TURN_RATE_CHANGE_ACK: move_type = MOVE_TURN_RATE; break; - case CMSG_MOVE_FORCE_FLIGHT_SPEED_CHANGE_ACK: move_type = MOVE_FLIGHT; break; - case CMSG_MOVE_FORCE_FLIGHT_BACK_SPEED_CHANGE_ACK: move_type = MOVE_FLIGHT_BACK; break; - case CMSG_MOVE_FORCE_PITCH_RATE_CHANGE_ACK: move_type = MOVE_PITCH_RATE; break; - default: - LOG_ERROR("network", "WorldSession::HandleForceSpeedChangeAck: Unknown move type opcode: %s", GetOpcodeNameForLogging(static_cast(recvData.GetOpcode())).c_str()); - return; + case CMSG_MOVE_FORCE_WALK_SPEED_CHANGE_ACK: + move_type = MOVE_WALK; + break; + case CMSG_MOVE_FORCE_RUN_SPEED_CHANGE_ACK: + move_type = MOVE_RUN; + break; + case CMSG_MOVE_FORCE_RUN_BACK_SPEED_CHANGE_ACK: + move_type = MOVE_RUN_BACK; + break; + case CMSG_MOVE_FORCE_SWIM_SPEED_CHANGE_ACK: + move_type = MOVE_SWIM; + break; + case CMSG_MOVE_FORCE_SWIM_BACK_SPEED_CHANGE_ACK: + move_type = MOVE_SWIM_BACK; + break; + case CMSG_MOVE_FORCE_TURN_RATE_CHANGE_ACK: + move_type = MOVE_TURN_RATE; + break; + case CMSG_MOVE_FORCE_FLIGHT_SPEED_CHANGE_ACK: + move_type = MOVE_FLIGHT; + break; + case CMSG_MOVE_FORCE_FLIGHT_BACK_SPEED_CHANGE_ACK: + move_type = MOVE_FLIGHT_BACK; + break; + case CMSG_MOVE_FORCE_PITCH_RATE_CHANGE_ACK: + move_type = MOVE_PITCH_RATE; + break; + default: + LOG_ERROR("network", "WorldSession::HandleForceSpeedChangeAck: Unknown move type opcode: %s", GetOpcodeNameForLogging(static_cast(recvData.GetOpcode())).c_str()); + return; } MovementChangeType changeType = MovementPacketSender::GetChangeTypeByMoveType(move_type); @@ -515,8 +534,8 @@ void WorldSession::HandleForceSpeedChangeAck(WorldPacket &recvData) float speedSent = pendingChange->newValue; if (std::fabs(speedSent - speedReceived) > 0.01f) { - LOG_INFO("cheat", "WorldSession::HandleForceSpeedChangeAck: Player %s from account id %u kicked for incorrect data returned in an ack", - _player->GetName().c_str(), _player->GetSession()->GetAccountId()); + LOG_INFO("cheat", "WorldSession::HandleForceSpeedChangeAck: Player %s from account id %u kicked for incorrect data returned in an ack", _player->GetName().c_str(), + _player->GetSession()->GetAccountId()); _player->GetSession()->KickPlayer(); return; } @@ -544,7 +563,7 @@ void WorldSession::HandleSetActiveMoverOpcode(WorldPackets::Movement::SetActiveM client->SetActivelyMovedUnit(newActivelyMovedUnit); } -void WorldSession::HandleMoveNotActiveMover(WorldPacket &recvData) +void WorldSession::HandleMoveNotActiveMover(WorldPacket& recvData) { LOG_DEBUG("network", "WORLD: Recvd CMSG_MOVE_NOT_ACTIVE_MOVER"); @@ -701,8 +720,8 @@ void WorldSession::HandleMoveGravityDisableAck(WorldPacket& recvData) if (pendingChange->apply != disable) { - LOG_INFO("cheat", "WorldSession::HandleMoveGravityDisableAck: Player %s from account id %u kicked for incorrect data returned in an ack", - _player->GetName().c_str(), _player->GetSession()->GetAccountId()); + LOG_INFO("cheat", "WorldSession::HandleMoveGravityDisableAck: Player %s from account id %u kicked for incorrect data returned in an ack", _player->GetName().c_str(), + _player->GetSession()->GetAccountId()); _player->GetSession()->KickPlayer(); return; } @@ -714,11 +733,7 @@ void WorldSession::HandleMoveGravityDisableAck(WorldPacket& recvData) void WorldSession::HandleSetCollisionHeightAck(WorldPacket& recvData) { MovementInfo movementInfo; - static MovementStatusElements const extraElements[] = - { - MSEExtraFloat, - MSEExtraTwoBits - }; + static MovementStatusElements const extraElements[] = {MSEExtraFloat, MSEExtraTwoBits}; Movement::ExtraMovementStatusElement extra(extraElements); GetPlayer()->ReadMovementInfo(recvData, &movementInfo, &extra); @@ -735,8 +750,8 @@ void WorldSession::HandleSetCollisionHeightAck(WorldPacket& recvData) if (std::fabs(pendingChange->newValue - extra.Data.floatData) > 0.01f) { - LOG_INFO("cheat", "WorldSession::HandleSetCollisionHeightAck: Player %s from account id %u kicked for incorrect data returned in an ack", - _player->GetName().c_str(), _player->GetSession()->GetAccountId()); + LOG_INFO("cheat", "WorldSession::HandleSetCollisionHeightAck: Player %s from account id %u kicked for incorrect data returned in an ack", _player->GetName().c_str(), + _player->GetSession()->GetAccountId()); _player->GetSession()->KickPlayer(); return; } @@ -870,7 +885,7 @@ void WorldSession::ComputeNewClockDelta() using namespace boost::accumulators; - accumulator_set > latencyAccumulator; + accumulator_set> latencyAccumulator; for (auto pair : _timeSyncClockDeltaQueue) latencyAccumulator(pair.second); @@ -878,7 +893,7 @@ void WorldSession::ComputeNewClockDelta() uint32 latencyMedian = static_cast(std::round(median(latencyAccumulator))); uint32 latencyStandardDeviation = static_cast(std::round(sqrt(variance(latencyAccumulator)))); - accumulator_set > clockDeltasAfterFiltering; + accumulator_set> clockDeltasAfterFiltering; uint32 sampleSizeAfterFiltering = 0; for (auto pair : _timeSyncClockDeltaQueue) { diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index f48b4714..474eef15 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -56,7 +56,7 @@ class Aura; // in aura handler there should be check for modes: // AURA_EFFECT_HANDLE_REAL set // AURA_EFFECT_HANDLE_SEND_FOR_CLIENT_MASK set -// AURA_EFFECT_HANDLE_CHANGE_AMOUNT_MASK set - aura is recalculated or is just applied/removed - need to redo all things related to m_amount +// AURA_EFFECT_HANDLE_CHANGE_AMOUNT_MASK set - aura is recalculated or is just applied/removed - need to redo all things related to _amount // AURA_EFFECT_HANDLE_CHANGE_AMOUNT_SEND_FOR_CLIENT_MASK - logical or of above conditions // AURA_EFFECT_HANDLE_STAT - set when stats are reapplied // such checks will speedup firelands change amount/send for client operations @@ -438,12 +438,12 @@ pAuraEffectHandler AuraEffectHandler[TOTAL_AURAS] = { }; AuraEffect::AuraEffect(Aura* base, uint8 effIndex, int32* baseAmount, Unit* caster) - : m_base(base), m_spellInfo(base->GetSpellInfo()), m_baseAmount(baseAmount ? *baseAmount : m_spellInfo->Effects[effIndex].BasePoints), m_bonusAmount(0), m_donePct(1.0f), m_spellmod(nullptr), - m_periodicTimer(0), m_tickNumber(0), m_effIndex(effIndex), m_canBeRecalculated(true), m_isPeriodic(false) + : m_base(base), m_spellInfo(base->GetSpellInfo()), m_baseAmount(baseAmount ? *baseAmount : m_spellInfo->Effects[effIndex].BasePoints), m_spellmod(nullptr), m_periodicTimer(0), m_tickNumber(0), + m_effIndex(effIndex), m_canBeRecalculated(true), m_isPeriodic(false) { CalculatePeriodic(caster, true, false); - m_amount = CalculateAmount(caster); + _amount = CalculateAmount(caster); CalculateSpellMod(); } @@ -476,7 +476,7 @@ template void AuraEffect::GetApplicationList(Container& app void AuraEffect::SetAmount(int32 amount) { - m_amount = amount; + _amount = amount; m_canBeRecalculated = false; if (GetSpellInfo()->HasAttribute(SPELL_ATTR8_AURA_SEND_AMOUNT) || Aura::EffectTypeNeedsSendingAmount(GetAuraType())) @@ -721,7 +721,7 @@ void AuraEffect::ChangeAmount(int32 newAmount, bool mark, bool onStackOrReapply) if (handleMask & AURA_EFFECT_HANDLE_CHANGE_AMOUNT) { if (!mark) - m_amount = newAmount; + _amount = newAmount; else SetAmount(newAmount); CalculateSpellMod(); @@ -3084,9 +3084,9 @@ void AuraEffect::HandleAuraControlVehicle(AuraApplication const* aurApp, uint8 m // Currently spells that have base points 0 and DieSides 0 = "0/0" exception are pushed to -1, // however the idea of 0/0 is to ingore flag VEHICLE_SEAT_FLAG_CAN_ENTER_OR_EXIT and -1 checks for it, // so this break such spells or most of them. - // Current formula about m_amount: effect base points + dieside - 1 + // Current formula about _amount: effect base points + dieside - 1 // TO DO: Reasearch more about 0/0 and fix it. - caster->_EnterVehicle(target->GetVehicleKit(), m_amount - 1, aurApp); + caster->_EnterVehicle(target->GetVehicleKit(), _amount - 1, aurApp); } else { @@ -3095,7 +3095,7 @@ void AuraEffect::HandleAuraControlVehicle(AuraApplication const* aurApp, uint8 m if (GetId() == 53111) // Devour Humanoid { - target->Kill(caster); + Unit::Kill(target, caster); if (caster->GetTypeId() == TYPEID_UNIT) caster->ToCreature()->DespawnOrUnsummon(); } @@ -3550,7 +3550,7 @@ void AuraEffect::HandleModPercentStat(AuraApplication const* aurApp, uint8 mode, if (GetMiscValue() == i || GetMiscValue() == -1) { if (apply) - target->ApplyStatPctModifier(UnitMods(UNIT_MOD_STAT_START + i), BASE_PCT, float(m_amount)); + target->ApplyStatPctModifier(UnitMods(UNIT_MOD_STAT_START + i), BASE_PCT, float(GetAmount())); else { float amount = target->GetTotalAuraMultiplier(SPELL_AURA_MOD_PERCENT_STAT, @@ -4100,7 +4100,7 @@ void AuraEffect::HandleModCombatSpeedPct(AuraApplication const* aurApp, uint8 mo target->ApplyAttackTimePercentMod(OFF_ATTACK, float(spellGroupVal), !apply); target->ApplyAttackTimePercentMod(RANGED_ATTACK, float(spellGroupVal), !apply); } - target->ApplyCastTimePercentMod(float(m_amount), apply); + target->ApplyCastTimePercentMod(GetAmount(), apply); target->ApplyAttackTimePercentMod(BASE_ATTACK, float(GetAmount()), apply); target->ApplyAttackTimePercentMod(OFF_ATTACK, float(GetAmount()), apply); target->ApplyAttackTimePercentMod(RANGED_ATTACK, float(GetAmount()), apply); @@ -4303,7 +4303,7 @@ void AuraEffect::HandleOverrideSpellPowerByAttackPower(AuraApplication const* au if (!target) return; - target->ApplyModSignedFloatValue(PLAYER_FIELD_OVERRIDE_SPELL_POWER_BY_AP_PCT, float(m_amount), apply); + target->ApplyModSignedFloatValue(PLAYER_FIELD_OVERRIDE_SPELL_POWER_BY_AP_PCT, float(GetAmount()), apply); target->UpdateSpellDamageAndHealingBonus(); } @@ -4977,7 +4977,7 @@ void AuraEffect::HandleChannelDeathItem(AuraApplication const* aurApp, uint8 mod // Adding items uint32 noSpaceForCount = 0; - uint32 count = m_amount; + uint32 count = GetAmount(); ItemPosCountVec dest; InventoryResult msg = plCaster->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, GetSpellInfo()->Effects[m_effIndex].ItemType, count, &noSpaceForCount); @@ -5025,7 +5025,7 @@ void AuraEffect::HandleForceReaction(AuraApplication const* aurApp, uint8 mode, return; uint32 factionId = GetMiscValue(); - ReputationRank factionRank = ReputationRank(m_amount); + ReputationRank factionRank = ReputationRank(GetAmount()); player->GetReputationMgr().ApplyForceReaction(factionId, factionRank, apply); player->GetReputationMgr().SendForceReactions(); @@ -5116,7 +5116,7 @@ void AuraEffect::HandleAuraConvertRune(AuraApplication const* aurApp, uint8 mode * Amount is the number of runes that will be converted if available */ - uint32 runes = m_amount; + uint32 runes = GetAmount(); if (apply) { @@ -5379,7 +5379,7 @@ void AuraEffect::HandlePeriodicDummyAuraTick(Unit* target, Unit* caster) const if (caster) { CastSpellExtraArgs args; - args.SpellValueOverrides.AddMod(SpellValueMod(SPELLVALUE_BASE_POINT0), m_amount); + args.SpellValueOverrides.AddMod(SpellValueMod(SPELLVALUE_BASE_POINT0), GetAmount()); args.SetTriggeringAura(this); caster->CastSpell(target, 53352, args); } @@ -5416,7 +5416,7 @@ void AuraEffect::HandlePeriodicDummyAuraTick(Unit* target, Unit* caster) const { case 49016: // Hysteria uint32 damage = uint32(target->CountPctFromMaxHealth(1)); - target->DealDamage(target, damage, nullptr, NODAMAGE, SPELL_SCHOOL_MASK_NORMAL, nullptr, false); + Unit::DealDamage(target, target, damage, nullptr, NODAMAGE, SPELL_SCHOOL_MASK_NORMAL, nullptr, false); break; } // Blood of the North @@ -5644,7 +5644,7 @@ void AuraEffect::HandlePeriodicTriggerSpellAuraTick(Unit* target, Unit* caster) case 16191: { CastSpellExtraArgs args(this); - args.SpellValueOverrides.AddMod(SPELLVALUE_BASE_POINT0, m_amount); + args.SpellValueOverrides.AddMod(SPELLVALUE_BASE_POINT0, GetAmount()); args.SetTriggeringAura(this); target->CastSpell(target, triggerSpellId, args); return; @@ -5737,7 +5737,10 @@ void AuraEffect::HandlePeriodicTriggerSpellWithValueAuraTick(Unit* target, Unit* void AuraEffect::HandlePeriodicDamageAurasTick(Unit* target, Unit* caster) const { - if (!caster || !target->IsAlive()) + // dynobj auras must always have a caster + ASSERT(GetSpellInfo()->Effects[GetEffIndex()].Effect != SPELL_EFFECT_PERSISTENT_AREA_AURA || caster); + + if (!target->IsAlive()) return; if (target->HasUnitState(UNIT_STATE_ISOLATED) || target->IsImmunedToDamage(GetSpellInfo())) @@ -5848,18 +5851,27 @@ void AuraEffect::HandlePeriodicDamageAurasTick(Unit* target, Unit* caster) const // Calculate armor mitigation if (Unit::IsDamageReducedByArmor(GetSpellInfo()->GetSchoolMask(), GetSpellInfo(), GetEffIndex())) { - uint32 damageReductedArmor = caster->CalcArmorReducedDamage(target, damage, GetSpellInfo()); + uint32 damageReductedArmor = Unit::CalcArmorReducedDamage(caster, target, damage, GetSpellInfo()); cleanDamage.mitigated_damage += damage - damageReductedArmor; damage = damageReductedArmor; } - int32 dmg = damage; if (!GetSpellInfo()->HasAttribute(SPELL_ATTR4_FIXED_DAMAGE)) - caster->ApplyResilience(target, &dmg); + { + if (GetSpellInfo()->Effects[GetEffIndex()].IsTargetingArea() || GetSpellInfo()->Effects[GetEffIndex()].IsAreaAuraEffect() || + GetSpellInfo()->Effects[GetEffIndex()].Effect == SPELL_EFFECT_PERSISTENT_AREA_AURA) + damage = target->CalculateAOEAvoidance(damage, m_spellInfo->SchoolMask, caster); + } + + int32 dmg = damage; + + if (!GetSpellInfo()->HasAttribute(SPELL_ATTR4_FIXED_DAMAGE) && GetBase()->CanApplyResilience()) + Unit::ApplyResilience(target, &dmg); + damage = dmg; DamageInfo damageInfo(caster, target, damage, GetSpellInfo(), GetSpellInfo()->GetSchoolMask(), DOT, BASE_ATTACK); - caster->CalcAbsorbResist(damageInfo); + Unit::CalcAbsorbResist(damageInfo); damage = damageInfo.GetDamage(); uint32 absorb = damageInfo.GetAbsorb(); @@ -5867,7 +5879,7 @@ void AuraEffect::HandlePeriodicDamageAurasTick(Unit* target, Unit* caster) const LOG_DEBUG( "spells.periodic", "PeriodicTick: %s attacked %s for %u dmg inflicted by %u absorb is %u", GetCasterGUID().ToString().c_str(), target->GetGUID().ToString().c_str(), damage, GetId(), absorb); - caster->DealDamageMods(target, damage, &absorb); + Unit::DealDamageMods(target, damage, &absorb); // Set trigger flag uint32 procAttacker = PROC_FLAG_NONE, procVictim = PROC_FLAG_NONE; @@ -5891,13 +5903,16 @@ void AuraEffect::HandlePeriodicDamageAurasTick(Unit* target, Unit* caster) const SpellPeriodicAuraLogInfo pInfo(this, damage, overkill, absorb, resist, 0.0f, crit); target->SendPeriodicAuraLog(&pInfo); - caster->DealDamage(target, damage, &cleanDamage, DOT, GetSpellInfo()->GetSchoolMask(), GetSpellInfo(), true); + Unit::DealDamage(caster, target, damage, &cleanDamage, DOT, GetSpellInfo()->GetSchoolMask(), GetSpellInfo(), true); - caster->ProcSkillsAndAuras(target, procAttacker, procVictim, PROC_SPELL_TYPE_DAMAGE, PROC_SPELL_PHASE_HIT, hitMask, nullptr, &damageInfo, nullptr); + Unit::ProcSkillsAndAuras(caster, target, procAttacker, procVictim, PROC_SPELL_TYPE_DAMAGE, PROC_SPELL_PHASE_HIT, hitMask, nullptr, &damageInfo, nullptr); } void AuraEffect::HandlePeriodicHealthLeechAuraTick(Unit* target, Unit* caster) const { + // dynobj auras must always have a caster + ASSERT(GetSpellInfo()->Effects[GetEffIndex()].Effect != SPELL_EFFECT_PERSISTENT_AREA_AURA || caster); + if (!caster || !target->IsAlive()) return; @@ -5935,29 +5950,27 @@ void AuraEffect::HandlePeriodicHealthLeechAuraTick(Unit* target, Unit* caster) c // Calculate armor mitigation if (Unit::IsDamageReducedByArmor(GetSpellInfo()->GetSchoolMask(), GetSpellInfo(), GetEffIndex())) { - uint32 damageReductedArmor = caster->CalcArmorReducedDamage(target, damage, GetSpellInfo()); + uint32 damageReductedArmor = Unit::CalcArmorReducedDamage(caster, target, damage, GetSpellInfo()); cleanDamage.mitigated_damage += damage - damageReductedArmor; damage = damageReductedArmor; } - if (!m_spellInfo->HasAttribute(SPELL_ATTR4_FIXED_DAMAGE)) + if (!GetSpellInfo()->HasAttribute(SPELL_ATTR4_FIXED_DAMAGE)) { if (GetSpellInfo()->Effects[GetEffIndex()].IsTargetingArea() || GetSpellInfo()->Effects[GetEffIndex()].IsAreaAuraEffect() || GetSpellInfo()->Effects[GetEffIndex()].Effect == SPELL_EFFECT_PERSISTENT_AREA_AURA) { - damage = uint32(float(damage) * target->GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_AOE_DAMAGE_AVOIDANCE, m_spellInfo->SchoolMask)); - if (caster->GetTypeId() != TYPEID_PLAYER) - damage = uint32(float(damage) * target->GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_CREATURE_AOE_DAMAGE_AVOIDANCE, m_spellInfo->SchoolMask)); + damage = target->CalculateAOEAvoidance(damage, m_spellInfo->SchoolMask, caster); } } int32 dmg = damage; - if (!GetSpellInfo()->HasAttribute(SPELL_ATTR4_FIXED_DAMAGE)) - caster->ApplyResilience(target, &dmg); + if (!GetSpellInfo()->HasAttribute(SPELL_ATTR4_FIXED_DAMAGE) && GetBase()->CanApplyResilience()) + Unit::ApplyResilience(target, &dmg); damage = dmg; DamageInfo damageInfo(caster, target, damage, GetSpellInfo(), GetSpellInfo()->GetSchoolMask(), DOT, BASE_ATTACK); - caster->CalcAbsorbResist(damageInfo); + Unit::CalcAbsorbResist(damageInfo); uint32 absorb = damageInfo.GetAbsorb(); uint32 resist = damageInfo.GetResist(); @@ -5984,10 +5997,10 @@ void AuraEffect::HandlePeriodicHealthLeechAuraTick(Unit* target, Unit* caster) c procVictim |= PROC_FLAG_TAKE_ANY_DAMAGE; } - int32 new_damage = caster->DealDamage(target, damage, &cleanDamage, DOT, GetSpellInfo()->GetSchoolMask(), GetSpellInfo(), false); + int32 new_damage = Unit::DealDamage(caster, target, damage, &cleanDamage, DOT, GetSpellInfo()->GetSchoolMask(), GetSpellInfo(), false); if (caster->IsAlive()) { - caster->ProcSkillsAndAuras(target, procAttacker, procVictim, PROC_SPELL_TYPE_DAMAGE, PROC_SPELL_PHASE_HIT, hitMask, nullptr, &damageInfo, nullptr); + Unit::ProcSkillsAndAuras(caster, target, procAttacker, procVictim, PROC_SPELL_TYPE_DAMAGE, PROC_SPELL_PHASE_HIT, hitMask, nullptr, &damageInfo, nullptr); float gainMultiplier = GetSpellInfo()->Effects[GetEffIndex()].CalcValueMultiplier(caster); @@ -5998,7 +6011,7 @@ void AuraEffect::HandlePeriodicHealthLeechAuraTick(Unit* target, Unit* caster) c caster->HealBySpell(healInfo); caster->GetThreatManager().ForwardThreatForAssistingMe(caster, healInfo.GetEffectiveHeal() * 0.5f, GetSpellInfo()); - caster->ProcSkillsAndAuras(caster, PROC_FLAG_DEAL_PERIODIC, PROC_FLAG_TAKE_PERIODIC, PROC_SPELL_TYPE_HEAL, PROC_SPELL_PHASE_HIT, hitMask, nullptr, nullptr, &healInfo); + Unit::ProcSkillsAndAuras(caster, caster, PROC_FLAG_DEAL_PERIODIC, PROC_FLAG_TAKE_PERIODIC, PROC_SPELL_TYPE_HEAL, PROC_SPELL_PHASE_HIT, hitMask, nullptr, nullptr, &healInfo); } } @@ -6029,12 +6042,15 @@ void AuraEffect::HandlePeriodicHealthFunnelAuraTick(Unit* target, Unit* caster) HealInfo healInfo(caster, target, damage, GetSpellInfo(), GetSpellInfo()->GetSchoolMask()); caster->HealBySpell(healInfo); - caster->ProcSkillsAndAuras(target, PROC_FLAG_DEAL_PERIODIC, PROC_FLAG_TAKE_PERIODIC, PROC_SPELL_TYPE_HEAL, PROC_SPELL_PHASE_HIT, PROC_HIT_NORMAL, nullptr, nullptr, &healInfo); + Unit::ProcSkillsAndAuras(caster, target, PROC_FLAG_DEAL_PERIODIC, PROC_FLAG_TAKE_PERIODIC, PROC_SPELL_TYPE_HEAL, PROC_SPELL_PHASE_HIT, PROC_HIT_NORMAL, nullptr, nullptr, &healInfo); } void AuraEffect::HandlePeriodicHealAurasTick(Unit* target, Unit* caster) const { - if (!caster || !target->IsAlive()) + // dynobj auras must always have a caster + ASSERT(GetSpellInfo()->Effects[GetEffIndex()].Effect != SPELL_EFFECT_PERSISTENT_AREA_AURA || caster); + + if (!target->IsAlive()) return; if (target->HasUnitState(UNIT_STATE_ISOLATED)) @@ -6044,7 +6060,7 @@ void AuraEffect::HandlePeriodicHealAurasTick(Unit* target, Unit* caster) const } // heal for caster damage (must be alive) - if (target != caster && GetSpellInfo()->HasAttribute(SPELL_ATTR2_HEALTH_FUNNEL) && !caster->IsAlive()) + if (target != caster && GetSpellInfo()->HasAttribute(SPELL_ATTR2_HEALTH_FUNNEL) && (!caster || !caster->IsAlive())) return; // don't regen when permanent aura target has full power @@ -6053,57 +6069,23 @@ void AuraEffect::HandlePeriodicHealAurasTick(Unit* target, Unit* caster) const bool isAreaAura = m_spellInfo->Effects[m_effIndex].IsAreaAuraEffect() || m_spellInfo->Effects[m_effIndex].IsEffect(SPELL_EFFECT_PERSISTENT_AREA_AURA); // ignore negative values (can be result apply spellmods to aura damage - uint32 damage = std::max(GetAmount() + GetBonusAmount(), 0); // if isAreaAura == true, GetBonusAmount == 0. + uint32 damage = std::max(GetAmount(), 0); // Script Hook For HandlePeriodicHealAurasTick -- Allow scripts to change the Damage pre class mitigation calculations sScriptMgr->ModifyPeriodicDamageAurasTick(target, caster, damage); if (GetAuraType() == SPELL_AURA_OBS_MOD_HEALTH) { - // Taken mods - float TakenTotalMod = 1.0f; - - // Tenacity increase healing % taken - if (AuraEffect const* Tenacity = target->GetAuraEffect(58549, 0)) - AddPct(TakenTotalMod, Tenacity->GetAmount()); - - // Healing taken percent - float minval = (float)target->GetMaxNegativeAuraModifier(SPELL_AURA_MOD_HEALING_PCT); - if (minval) - AddPct(TakenTotalMod, minval); - - float maxval = (float)target->GetMaxPositiveAuraModifier(SPELL_AURA_MOD_HEALING_PCT); - if (maxval) - AddPct(TakenTotalMod, maxval); - - TakenTotalMod = std::max(TakenTotalMod, 0.0f); - damage = uint32(target->CountPctFromMaxHealth(damage)); - damage = uint32(damage * TakenTotalMod); } else { - // Wild Growth = amount + (6 - 2*doneTicks) * ticks* amount / 100 - if (m_spellInfo->SpellFamilyName == SPELLFAMILY_DRUID && m_spellInfo->SpellIconID == 2864) - { - int32 addition = int32(float(damage * GetTotalTicks()) * ((6 - float(2 * (GetTickNumber() - 1))) / 100)); - - // Item - Druid T10 Restoration 2P Bonus - if (AuraEffect* aurEff = caster->GetAuraEffect(70658, 0)) - // divided by 50 instead of 100 because calculated as for every 2 tick - addition += abs(int32((addition * aurEff->GetAmount()) / 50)); - - damage += addition; - } - - if (isAreaAura) + if (GetBase()->GetType() == DYNOBJ_AURA_TYPE) damage = caster->SpellHealingBonusDone(target, GetSpellInfo(), damage, DOT, GetEffIndex(), GetBase()->GetStackAmount()) * caster->SpellHealingPctDone(target, m_spellInfo); - else - damage = std::max(int32(damage * GetDonePct()), 0); - - damage = target->SpellHealingBonusTaken(caster, GetSpellInfo(), damage, DOT, GetBase()->GetStackAmount()); } + damage = target->SpellHealingBonusTaken(caster, GetSpellInfo(), damage, DOT, GetBase()->GetStackAmount()); + bool crit = false; if (CanPeriodicTickCrit(caster)) @@ -6117,13 +6099,14 @@ void AuraEffect::HandlePeriodicHealAurasTick(Unit* target, Unit* caster) const uint32 heal = damage; HealInfo healInfo(caster, target, damage, GetSpellInfo(), GetSpellInfo()->GetSchoolMask()); - caster->CalcHealAbsorb(healInfo); - caster->DealHeal(healInfo); + Unit::CalcHealAbsorb(healInfo); + Unit::DealHeal(healInfo); SpellPeriodicAuraLogInfo pInfo(this, heal, heal - healInfo.GetEffectiveHeal(), healInfo.GetAbsorb(), 0, 0.0f, crit); target->SendPeriodicAuraLog(&pInfo); - target->GetThreatManager().ForwardThreatForAssistingMe(caster, float(healInfo.GetEffectiveHeal()) * 0.5f, GetSpellInfo()); + if (caster) + target->GetThreatManager().ForwardThreatForAssistingMe(caster, float(healInfo.GetEffectiveHeal()) * 0.5f, GetSpellInfo()); bool haveCastItem = !GetBase()->GetCastItemGUID().IsEmpty(); @@ -6137,11 +6120,11 @@ void AuraEffect::HandlePeriodicHealAurasTick(Unit* target, Unit* caster) const funnelDamage = healInfo.GetEffectiveHeal(); uint32 funnelAbsorb = 0; - caster->DealDamageMods(caster, funnelDamage, &funnelAbsorb); + Unit::DealDamageMods(caster, funnelDamage, &funnelAbsorb); caster->SendSpellNonMeleeDamageLog(caster, GetId(), funnelDamage, GetSpellInfo()->GetSchoolMask(), funnelAbsorb, 0, false, 0, false); CleanDamage cleanDamage = CleanDamage(0, 0, BASE_ATTACK, MELEE_HIT_NORMAL); - caster->DealDamage(caster, funnelDamage, &cleanDamage, NODAMAGE, GetSpellInfo()->GetSchoolMask(), GetSpellInfo(), true); + Unit::DealDamage(caster, caster, funnelDamage, &cleanDamage, SELF_DAMAGE, GetSpellInfo()->GetSchoolMask(), GetSpellInfo(), true); } // %-based heal - does not proc auras @@ -6157,7 +6140,7 @@ void AuraEffect::HandlePeriodicHealAurasTick(Unit* target, Unit* caster) const uint32 hitMask = crit ? PROC_HIT_CRITICAL : PROC_HIT_NORMAL; // ignore item heals if (!haveCastItem) - caster->ProcSkillsAndAuras(target, procAttacker, procVictim, PROC_SPELL_TYPE_HEAL, PROC_SPELL_PHASE_HIT, hitMask, nullptr, nullptr, &healInfo); + Unit::ProcSkillsAndAuras(caster, target, procAttacker, procVictim, PROC_SPELL_TYPE_HEAL, PROC_SPELL_PHASE_HIT, hitMask, nullptr, nullptr, &healInfo); } void AuraEffect::HandlePeriodicManaLeechAuraTick(Unit* target, Unit* caster) const @@ -6177,10 +6160,10 @@ void AuraEffect::HandlePeriodicManaLeechAuraTick(Unit* target, Unit* caster) con return; // ignore negative values (can be result apply spellmods to aura damage - int32 drainAmount = std::max(m_amount, 0); + int32 drainAmount = std::max(GetAmount(), 0); // Special case: draining x% of mana (up to a maximum of 2*x% of the caster's maximum mana) - // It's mana percent cost spells, m_amount is percent drain from target + // It's mana percent cost spells, _amount is percent drain from target if (m_spellInfo->ManaCostPercentage) { // max value @@ -6247,7 +6230,7 @@ void AuraEffect::HandleObsModPowerAuraTick(Unit* target, Unit* caster) const return; // ignore negative values (can be result apply spellmods to aura damage - uint32 amount = std::max(m_amount, 0) * target->GetMaxPower(powerType) / 100; + uint32 amount = std::max(GetAmount(), 0) * target->GetMaxPower(powerType) / 100; LOG_DEBUG("spells.periodic", "PeriodicTick: %s energize %s for %u dmg inflicted by %u", GetCasterGUID().ToString().c_str(), target->GetGUID().ToString().c_str(), amount, GetId()); SpellPeriodicAuraLogInfo pInfo(this, amount, 0, 0, 0, 0.0f, false); @@ -6276,7 +6259,7 @@ void AuraEffect::HandlePeriodicEnergizeAuraTick(Unit* target, Unit* caster) cons return; // ignore negative values (can be result apply spellmods to aura damage - int32 amount = std::max(m_amount, 0); + int32 amount = std::max(GetAmount(), 0); SpellPeriodicAuraLogInfo pInfo(this, amount, 0, 0, 0, 0.0f, false); target->SendPeriodicAuraLog(&pInfo); @@ -6303,7 +6286,7 @@ void AuraEffect::HandlePeriodicPowerBurnAuraTick(Unit* target, Unit* caster) con } // ignore negative values (can be result apply spellmods to aura damage - int32 damage = std::max(m_amount, 0); + int32 damage = std::max(GetAmount(), 0); uint32 gain = uint32(-target->ModifyPower(powerType, -damage)); @@ -6315,7 +6298,7 @@ void AuraEffect::HandlePeriodicPowerBurnAuraTick(Unit* target, Unit* caster) con // no SpellDamageBonus for burn mana caster->CalculateSpellDamageTaken(&damageInfo, int32(gain * dmgMultiplier), spellProto); - caster->DealDamageMods(damageInfo.target, damageInfo.damage, &damageInfo.absorb); + Unit::DealDamageMods(damageInfo.target, damageInfo.damage, &damageInfo.absorb); caster->SendSpellNonMeleeDamageLog(&damageInfo); @@ -6339,7 +6322,7 @@ void AuraEffect::HandlePeriodicPowerBurnAuraTick(Unit* target, Unit* caster) con caster->DealSpellDamage(&damageInfo, true); DamageInfo dotDamageInfo(damageInfo, DOT, BASE_ATTACK, hitMask); - caster->ProcSkillsAndAuras(target, procAttacker, procVictim, spellTypeMask, PROC_SPELL_PHASE_HIT, hitMask, nullptr, &dotDamageInfo, nullptr); + Unit::ProcSkillsAndAuras(caster, target, procAttacker, procVictim, spellTypeMask, PROC_SPELL_PHASE_HIT, hitMask, nullptr, &dotDamageInfo, nullptr); } void AuraEffect::HandleBreakableCCAuraProc(AuraApplication* aurApp, ProcEventInfo& eventInfo) @@ -6415,7 +6398,7 @@ void AuraEffect::HandleProcTriggerDamageAuraProc(AuraApplication* aurApp, ProcEv uint32 damage = target->SpellDamageBonusDone(triggerTarget, GetSpellInfo(), GetAmount(), SPELL_DIRECT_DAMAGE, GetEffIndex()); damage = triggerTarget->SpellDamageBonusTaken(target, GetSpellInfo(), damage, SPELL_DIRECT_DAMAGE); target->CalculateSpellDamageTaken(&damageInfo, damage, GetSpellInfo()); - target->DealDamageMods(damageInfo.target, damageInfo.damage, &damageInfo.absorb); + Unit::DealDamageMods(damageInfo.target, damageInfo.damage, &damageInfo.absorb); target->SendSpellNonMeleeDamageLog(&damageInfo); LOG_DEBUG("spells", "AuraEffect::HandleProcTriggerDamageAuraProc: Triggering %u spell damage from aura %u proc", damage, GetId()); target->DealSpellDamage(&damageInfo, true); diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.h b/src/server/game/Spells/Auras/SpellAuraEffects.h index 6825e6fb..b3f30569 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.h +++ b/src/server/game/Spells/Auras/SpellAuraEffects.h @@ -24,366 +24,436 @@ class Aura; #include "SpellAuras.h" -typedef void(AuraEffect::*pAuraEffectHandler)(AuraApplication const* aurApp, uint8 mode, bool apply) const; +typedef void (AuraEffect::*pAuraEffectHandler)(AuraApplication const* aurApp, uint8 mode, bool apply) const; class FC_GAME_API AuraEffect { friend void Aura::_InitEffects(uint8 effMask, Unit* caster, int32* baseAmount); friend Aura* Unit::_TryStackingOrRefreshingExistingAura(SpellInfo const* newAura, uint8 effMask, Unit* caster, int32* baseAmount, Item* castItem, ObjectGuid casterGUID); friend Aura::~Aura(); - private: - ~AuraEffect(); - explicit AuraEffect(Aura* base, uint8 effIndex, int32 *baseAmount, Unit* caster); - public: - Unit* GetCaster() const { return GetBase()->GetCaster(); } - ObjectGuid GetCasterGUID() const { return GetBase()->GetCasterGUID(); } - Aura* GetBase() const { return m_base; } - - template - void GetTargetList(Container& targetContainer) const; - - template - void GetApplicationList(Container& applicationContainer) const; - - SpellInfo const* GetSpellInfo() const { return m_spellInfo; } - uint32 GetId() const { return m_spellInfo->Id; } - uint32 GetEffIndex() const { return m_effIndex; } - int32 GetBaseAmount() const { return m_baseAmount; } - int32 GetPeriodic() const { return m_effectPeriodicTimer; } - - int32 GetMiscValueB() const { return m_spellInfo->Effects[m_effIndex].MiscValueB; } - int32 GetMiscValue() const { return m_spellInfo->Effects[m_effIndex].MiscValue; } - AuraType GetAuraType() const { return (AuraType)m_spellInfo->Effects[m_effIndex].ApplyAuraName; } - int32 GetAmount() const { return m_amount; } - void SetAmount(int32 amount); - - int32 GetPeriodicTimer() const { return m_periodicTimer; } - void SetPeriodicTimer(int32 periodicTimer) { m_periodicTimer = periodicTimer; } - - int32 CalculateAmount(Unit* caster); - void CalculatePeriodic(Unit* caster, bool resetPeriodicTimer = true, bool load = false); - void CalculateSpellMod(); - void ChangeAmount(int32 newAmount, bool mark = true, bool onStackOrReapply = false); - void RecalculateAmount() { if (!CanBeRecalculated()) return; ChangeAmount(CalculateAmount(GetCaster()), false); } - void RecalculateAmount(Unit* caster) { if (!CanBeRecalculated()) return; ChangeAmount(CalculateAmount(caster), false); } - bool CanBeRecalculated() const { return m_canBeRecalculated; } - void SetCanBeRecalculated(bool val) { m_canBeRecalculated = val; } - void HandleEffect(AuraApplication * aurApp, uint8 mode, bool apply); - void HandleEffect(Unit* target, uint8 mode, bool apply); - void ApplySpellMod(Unit* target, bool apply); - - void SetBonusAmount(int32 val) { m_bonusAmount = val; } - int32 GetBonusAmount() const { return m_bonusAmount; } - void SetDonePct(float val) { m_donePct = val; } - float GetDonePct() const { return m_donePct; } - - void Update(uint32 diff, Unit* caster); - void UpdatePeriodic(Unit* caster); - - uint32 GetTickNumber() const { return m_tickNumber; } - int32 GetTotalTicks() const { return m_effectPeriodicTimer ? (GetBase()->GetMaxDuration() / m_effectPeriodicTimer) : 1;} - void ResetPeriodic(bool resetPeriodicTimer = false) { if (resetPeriodicTimer) m_periodicTimer = m_effectPeriodicTimer; m_tickNumber = 0;} - - bool IsPeriodic() const { return m_isPeriodic; } - void SetPeriodic(bool isPeriodic) { m_isPeriodic = isPeriodic; } - bool IsAffectingSpell(SpellInfo const* spell) const; - bool HasSpellClassMask() const { return m_spellInfo->Effects[m_effIndex].SpellClassMask; } - - void SendTickImmune(Unit* target, Unit* caster) const; - void PeriodicTick(AuraApplication* aurApp, Unit* caster) const; - - bool CheckEffectProc(AuraApplication* aurApp, ProcEventInfo& eventInfo) const; - void HandleProc(AuraApplication* aurApp, ProcEventInfo& eventInfo); - - // add/remove SPELL_AURA_MOD_SHAPESHIFT (36) linked auras - void HandleShapeshiftBoosts(Unit* target, bool apply) const; - - bool CanPeriodicTickCrit(Unit const* caster) const; - private: - Aura* const m_base; - - SpellInfo const* const m_spellInfo; - int32 const m_baseAmount; - - int32 m_amount; - int32 m_bonusAmount; - float m_donePct; - - SpellModifier* m_spellmod; - - int32 m_periodicTimer; - int32 m_effectPeriodicTimer; - uint32 m_tickNumber; - - uint8 const m_effIndex; - bool m_canBeRecalculated; - bool m_isPeriodic; - - float GetCritChanceFor(Unit const* caster, Unit const* target) const; - - public: - // aura effect apply/remove handlers - void HandleNULL(AuraApplication const* /*aurApp*/, uint8 /*mode*/, bool /*apply*/) const - { - // not implemented - } - void HandleUnused(AuraApplication const* /*aurApp*/, uint8 /*mode*/, bool /*apply*/) const - { - // useless - } - void HandleNoImmediateEffect(AuraApplication const* /*aurApp*/, uint8 /*mode*/, bool /*apply*/) const - { - // aura type not have immediate effect at add/remove and handled by ID in other code place - } - // visibility & phases - void HandleModInvisibilityDetect(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleModInvisibility(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleModStealth(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleModStealthLevel(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleModStealthDetect(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleDetectAmore(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleSpiritOfRedemption(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraGhost(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandlePhase(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandlePhaseGroup(AuraApplication const* aurApp, uint8 mode, bool apply) const; - - // unit model - void HandleAuraModShapeshift(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraTransform(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraModScale(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraCloneCaster(AuraApplication const* aurApp, uint8 mode, bool apply) const; - // fight - void HandleFeignDeath(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleModUnattackable(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraModDisarm(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraModSilence(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraModPacify(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraModPacifyAndSilence(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraDisableCastingExceptAbilities(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraDisableAttackingExceptAbilities(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraModNoActions(AuraApplication const* aurApp, uint8 mode, bool apply) const; - // tracking - void HandleAuraTrackResources(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraTrackCreatures(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraTrackStealthed(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraModStalked(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraUntrackable(AuraApplication const* aurApp, uint8 mode, bool apply) const; - // skills & talents - void HandleAuraModPetTalentsPoints(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraModSkill(AuraApplication const* aurApp, uint8 mode, bool apply) const; - // movement - void HandleAuraMounted(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraAllowFlight(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraWaterWalk(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraFeatherFall(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraHover(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleWaterBreathing(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleForceMoveForward(AuraApplication const* aurApp, uint8 mode, bool apply) const; - // threat - void HandleModThreat(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraModTotalThreat(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleModTaunt(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleModDetaunt(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraFixate(AuraApplication const* aurApp, uint8 mode, bool apply) const; - // control - void HandleModConfuse(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleModFear(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraModStun(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraModRoot(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandlePreventFleeing(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleStrangulate(AuraApplication const* aurApp, uint8 mode, bool apply) const; - // charm - void HandleModPossess(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleModCharm(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleCharmConvert(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraControlVehicle(AuraApplication const* aurApp, uint8 mode, bool apply) const; - // modify speed - void HandleAuraModIncreaseSpeed(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraModIncreaseMountedSpeed(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraModIncreaseFlightSpeed(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraModIncreaseSwimSpeed(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraModDecreaseSpeed(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraModUseNormalSpeed(AuraApplication const* aurApp, uint8 mode, bool apply) const; - // immunity - void HandleModMechanicImmunityMask(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleModMechanicImmunity(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraModEffectImmunity(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraModStateImmunity(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraModSchoolImmunity(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraModDmgImmunity(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraModDispelImmunity(AuraApplication const* aurApp, uint8 mode, bool apply) const; - // modify stats - // resistance - void HandleAuraModResistanceExclusive(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraModResistance(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraModBaseResistancePCT(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleModResistancePercent(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleModBaseResistance(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleModTargetResistance(AuraApplication const* aurApp, uint8 mode, bool apply) const; - // stat - void HandleAuraModStat(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleModPercentStat(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleModSpellDamagePercentFromStat(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleModSpellHealingPercentFromStat(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleModSpellDamagePercentFromAttackPower(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleModSpellHealingPercentFromAttackPower(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleModHealingDone(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleModTotalPercentStat(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraModResistenceOfStatPercent(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraModExpertise(AuraApplication const* aurApp, uint8 mode, bool apply) const; - // heal and energize - void HandleModPowerRegen(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleModPowerRegenPCT(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleModHealingPercent(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleModHealingDonePercent(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleModManaRegen(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraModIncreaseHealth(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraModIncreaseMaxHealth(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraModIncreaseEnergy(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraModIncreaseEnergyPercent(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraModIncreaseHealthPercent(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraIncreaseBaseHealthPercent(AuraApplication const* aurApp, uint8 mode, bool apply) const; - // fight - void HandleAuraModParryPercent(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraModDodgePercent(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraModBlockPercent(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraModRegenInterrupt(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraModWeaponCritPercent(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleModHitChance(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleModSpellHitChance(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleModSpellCritChance(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleModSpellCritChanceShool(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraModCritPct(AuraApplication const* aurApp, uint8 mode, bool apply) const; - // attack speed - void HandleModCastingSpeed(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleModMeleeRangedSpeedPct(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleModCombatSpeedPct(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleModAttackSpeed(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleModMeleeSpeedPct(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraModRangedHaste(AuraApplication const* aurApp, uint8 mode, bool apply) const; - // combat rating - void HandleModRating(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleModRatingFromStat(AuraApplication const* aurApp, uint8 mode, bool apply) const; - // attack power - void HandleAuraModAttackPower(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraModRangedAttackPower(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraModAttackPowerPercent(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraModRangedAttackPowerPercent(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraModAttackPowerOfArmor(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleOverrideSpellPowerByAttackPower(AuraApplication const* aurApp, uint8 mode, bool apply) const; - // damage bonus - void HandleModDamageDone(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleModDamagePercentDone(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleModOffhandDamagePercent(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleShieldBlockValue(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleShieldBlockValuePercent(AuraApplication const* aurApp, uint8 mode, bool apply) const; - // power cost - void HandleModPowerCostPCT(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleModPowerCost(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleArenaPreparation(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleNoReagentUseAura(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraRetainComboPoints(AuraApplication const* aurApp, uint8 mode, bool apply) const; - // others - void HandleAuraDummy(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleChannelDeathItem(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleBindSight(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleForceReaction(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraEmpathy(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraModFaction(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleComprehendLanguage(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraConvertRune(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraLinked(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraOpenStable(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraModFakeInebriation(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraOverrideSpells(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraSetVehicle(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandlePreventResurrection(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraModSpellPowerPct(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleMastery(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraForceWeather(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleEnableAltPower(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleModSpellCategoryCooldown(AuraApplication const* aurApp, uint8 mode, bool apply) const; - - // aura effect periodic tick handlers - void HandlePeriodicDummyAuraTick(Unit* target, Unit* caster) const; - void HandlePeriodicTriggerSpellAuraTick(Unit* target, Unit* caster) const; - void HandlePeriodicTriggerSpellWithValueAuraTick(Unit* target, Unit* caster) const; - void HandlePeriodicDamageAurasTick(Unit* target, Unit* caster) const; - void HandlePeriodicHealthLeechAuraTick(Unit* target, Unit* caster) const; - void HandlePeriodicHealthFunnelAuraTick(Unit* target, Unit* caster) const; - void HandlePeriodicHealAurasTick(Unit* target, Unit* caster) const; - void HandlePeriodicManaLeechAuraTick(Unit* target, Unit* caster) const; - void HandleObsModPowerAuraTick(Unit* target, Unit* caster) const; - void HandlePeriodicEnergizeAuraTick(Unit* target, Unit* caster) const; - void HandlePeriodicPowerBurnAuraTick(Unit* target, Unit* caster) const; - - // aura effect proc handlers - void HandleBreakableCCAuraProc(AuraApplication* aurApp, ProcEventInfo& eventInfo); - void HandleProcTriggerSpellAuraProc(AuraApplication* aurApp, ProcEventInfo& eventInfo); - void HandleProcTriggerSpellCopyAuraProc(AuraApplication* aurApp, ProcEventInfo& eventInfo); - void HandleProcTriggerSpellWithValueAuraProc(AuraApplication* aurApp, ProcEventInfo& eventInfo); - void HandleProcTriggerDamageAuraProc(AuraApplication* aurApp, ProcEventInfo& eventInfo); - void HandleRaidProcFromChargeAuraProc(AuraApplication* aurApp, ProcEventInfo& eventInfo); - void HandleRaidProcFromChargeWithValueAuraProc(AuraApplication* aurApp, ProcEventInfo& eventInfo); - void HandleProcOnPowerAmountAuraProc(AuraApplication* aurApp, ProcEventInfo& eventInfo); + + private: + ~AuraEffect(); + explicit AuraEffect(Aura* base, uint8 effIndex, int32* baseAmount, Unit* caster); + + public: + Unit* GetCaster() const + { + return GetBase()->GetCaster(); + } + ObjectGuid GetCasterGUID() const + { + return GetBase()->GetCasterGUID(); + } + Aura* GetBase() const + { + return m_base; + } + + template void GetTargetList(Container& targetContainer) const; + + template void GetApplicationList(Container& applicationContainer) const; + + SpellInfo const* GetSpellInfo() const + { + return m_spellInfo; + } + uint32 GetId() const + { + return m_spellInfo->Id; + } + uint32 GetEffIndex() const + { + return m_effIndex; + } + int32 GetBaseAmount() const + { + return m_baseAmount; + } + int32 GetPeriodic() const + { + return m_effectPeriodicTimer; + } + + int32 GetMiscValueB() const + { + return m_spellInfo->Effects[m_effIndex].MiscValueB; + } + int32 GetMiscValue() const + { + return m_spellInfo->Effects[m_effIndex].MiscValue; + } + AuraType GetAuraType() const + { + return (AuraType)m_spellInfo->Effects[m_effIndex].ApplyAuraName; + } + int32 GetAmount() const + { + return _amount; + } + void SetAmount(int32 amount); + + int32 GetPeriodicTimer() const + { + return m_periodicTimer; + } + void SetPeriodicTimer(int32 periodicTimer) + { + m_periodicTimer = periodicTimer; + } + + int32 CalculateAmount(Unit* caster); + void CalculatePeriodic(Unit* caster, bool resetPeriodicTimer = true, bool load = false); + void CalculateSpellMod(); + void ChangeAmount(int32 newAmount, bool mark = true, bool onStackOrReapply = false); + void RecalculateAmount() + { + if (!CanBeRecalculated()) + return; + ChangeAmount(CalculateAmount(GetCaster()), false); + } + void RecalculateAmount(Unit* caster) + { + if (!CanBeRecalculated()) + return; + ChangeAmount(CalculateAmount(caster), false); + } + bool CanBeRecalculated() const + { + return m_canBeRecalculated; + } + void SetCanBeRecalculated(bool val) + { + m_canBeRecalculated = val; + } + void HandleEffect(AuraApplication* aurApp, uint8 mode, bool apply); + void HandleEffect(Unit* target, uint8 mode, bool apply); + void ApplySpellMod(Unit* target, bool apply); + + void Update(uint32 diff, Unit* caster); + void UpdatePeriodic(Unit* caster); + + uint32 GetTickNumber() const + { + return m_tickNumber; + } + int32 GetTotalTicks() const + { + return m_effectPeriodicTimer ? (GetBase()->GetMaxDuration() / m_effectPeriodicTimer) : 1; + } + void ResetPeriodic(bool resetPeriodicTimer = false) + { + if (resetPeriodicTimer) + m_periodicTimer = m_effectPeriodicTimer; + m_tickNumber = 0; + } + + bool IsPeriodic() const + { + return m_isPeriodic; + } + void SetPeriodic(bool isPeriodic) + { + m_isPeriodic = isPeriodic; + } + bool IsAffectingSpell(SpellInfo const* spell) const; + bool HasSpellClassMask() const + { + return m_spellInfo->Effects[m_effIndex].SpellClassMask; + } + + void SendTickImmune(Unit* target, Unit* caster) const; + void PeriodicTick(AuraApplication* aurApp, Unit* caster) const; + + bool CheckEffectProc(AuraApplication* aurApp, ProcEventInfo& eventInfo) const; + void HandleProc(AuraApplication* aurApp, ProcEventInfo& eventInfo); + + // add/remove SPELL_AURA_MOD_SHAPESHIFT (36) linked auras + void HandleShapeshiftBoosts(Unit* target, bool apply) const; + + bool CanPeriodicTickCrit(Unit const* caster) const; + + private: + Aura* const m_base; + + SpellInfo const* const m_spellInfo; + int32 const m_baseAmount; + + int32 _amount; + + SpellModifier* m_spellmod; + + int32 m_periodicTimer; + int32 m_effectPeriodicTimer; + uint32 m_tickNumber; + + uint8 const m_effIndex; + bool m_canBeRecalculated; + bool m_isPeriodic; + + float GetCritChanceFor(Unit const* caster, Unit const* target) const; + + public: + // aura effect apply/remove handlers + void HandleNULL(AuraApplication const* /*aurApp*/, uint8 /*mode*/, bool /*apply*/) const + { + // not implemented + } + void HandleUnused(AuraApplication const* /*aurApp*/, uint8 /*mode*/, bool /*apply*/) const + { + // useless + } + void HandleNoImmediateEffect(AuraApplication const* /*aurApp*/, uint8 /*mode*/, bool /*apply*/) const + { + // aura type not have immediate effect at add/remove and handled by ID in other code place + } + // visibility & phases + void HandleModInvisibilityDetect(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleModInvisibility(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleModStealth(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleModStealthLevel(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleModStealthDetect(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleDetectAmore(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleSpiritOfRedemption(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraGhost(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandlePhase(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandlePhaseGroup(AuraApplication const* aurApp, uint8 mode, bool apply) const; + + // unit model + void HandleAuraModShapeshift(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraTransform(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraModScale(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraCloneCaster(AuraApplication const* aurApp, uint8 mode, bool apply) const; + // fight + void HandleFeignDeath(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleModUnattackable(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraModDisarm(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraModSilence(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraModPacify(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraModPacifyAndSilence(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraDisableCastingExceptAbilities(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraDisableAttackingExceptAbilities(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraModNoActions(AuraApplication const* aurApp, uint8 mode, bool apply) const; + // tracking + void HandleAuraTrackResources(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraTrackCreatures(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraTrackStealthed(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraModStalked(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraUntrackable(AuraApplication const* aurApp, uint8 mode, bool apply) const; + // skills & talents + void HandleAuraModPetTalentsPoints(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraModSkill(AuraApplication const* aurApp, uint8 mode, bool apply) const; + // movement + void HandleAuraMounted(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraAllowFlight(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraWaterWalk(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraFeatherFall(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraHover(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleWaterBreathing(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleForceMoveForward(AuraApplication const* aurApp, uint8 mode, bool apply) const; + // threat + void HandleModThreat(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraModTotalThreat(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleModTaunt(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleModDetaunt(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraFixate(AuraApplication const* aurApp, uint8 mode, bool apply) const; + // control + void HandleModConfuse(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleModFear(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraModStun(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraModRoot(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandlePreventFleeing(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleStrangulate(AuraApplication const* aurApp, uint8 mode, bool apply) const; + // charm + void HandleModPossess(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleModCharm(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleCharmConvert(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraControlVehicle(AuraApplication const* aurApp, uint8 mode, bool apply) const; + // modify speed + void HandleAuraModIncreaseSpeed(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraModIncreaseMountedSpeed(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraModIncreaseFlightSpeed(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraModIncreaseSwimSpeed(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraModDecreaseSpeed(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraModUseNormalSpeed(AuraApplication const* aurApp, uint8 mode, bool apply) const; + // immunity + void HandleModMechanicImmunityMask(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleModMechanicImmunity(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraModEffectImmunity(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraModStateImmunity(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraModSchoolImmunity(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraModDmgImmunity(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraModDispelImmunity(AuraApplication const* aurApp, uint8 mode, bool apply) const; + // modify stats + // resistance + void HandleAuraModResistanceExclusive(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraModResistance(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraModBaseResistancePCT(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleModResistancePercent(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleModBaseResistance(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleModTargetResistance(AuraApplication const* aurApp, uint8 mode, bool apply) const; + // stat + void HandleAuraModStat(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleModPercentStat(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleModSpellDamagePercentFromStat(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleModSpellHealingPercentFromStat(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleModSpellDamagePercentFromAttackPower(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleModSpellHealingPercentFromAttackPower(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleModHealingDone(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleModTotalPercentStat(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraModResistenceOfStatPercent(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraModExpertise(AuraApplication const* aurApp, uint8 mode, bool apply) const; + // heal and energize + void HandleModPowerRegen(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleModPowerRegenPCT(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleModHealingPercent(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleModHealingDonePercent(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleModManaRegen(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraModIncreaseHealth(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraModIncreaseMaxHealth(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraModIncreaseEnergy(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraModIncreaseEnergyPercent(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraModIncreaseHealthPercent(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraIncreaseBaseHealthPercent(AuraApplication const* aurApp, uint8 mode, bool apply) const; + // fight + void HandleAuraModParryPercent(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraModDodgePercent(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraModBlockPercent(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraModRegenInterrupt(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraModWeaponCritPercent(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleModHitChance(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleModSpellHitChance(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleModSpellCritChance(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleModSpellCritChanceShool(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraModCritPct(AuraApplication const* aurApp, uint8 mode, bool apply) const; + // attack speed + void HandleModCastingSpeed(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleModMeleeRangedSpeedPct(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleModCombatSpeedPct(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleModAttackSpeed(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleModMeleeSpeedPct(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraModRangedHaste(AuraApplication const* aurApp, uint8 mode, bool apply) const; + // combat rating + void HandleModRating(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleModRatingFromStat(AuraApplication const* aurApp, uint8 mode, bool apply) const; + // attack power + void HandleAuraModAttackPower(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraModRangedAttackPower(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraModAttackPowerPercent(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraModRangedAttackPowerPercent(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraModAttackPowerOfArmor(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleOverrideSpellPowerByAttackPower(AuraApplication const* aurApp, uint8 mode, bool apply) const; + // damage bonus + void HandleModDamageDone(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleModDamagePercentDone(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleModOffhandDamagePercent(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleShieldBlockValue(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleShieldBlockValuePercent(AuraApplication const* aurApp, uint8 mode, bool apply) const; + // power cost + void HandleModPowerCostPCT(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleModPowerCost(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleArenaPreparation(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleNoReagentUseAura(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraRetainComboPoints(AuraApplication const* aurApp, uint8 mode, bool apply) const; + // others + void HandleAuraDummy(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleChannelDeathItem(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleBindSight(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleForceReaction(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraEmpathy(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraModFaction(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleComprehendLanguage(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraConvertRune(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraLinked(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraOpenStable(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraModFakeInebriation(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraOverrideSpells(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraSetVehicle(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandlePreventResurrection(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraModSpellPowerPct(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleMastery(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleAuraForceWeather(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleEnableAltPower(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleModSpellCategoryCooldown(AuraApplication const* aurApp, uint8 mode, bool apply) const; + + // aura effect periodic tick handlers + void HandlePeriodicDummyAuraTick(Unit* target, Unit* caster) const; + void HandlePeriodicTriggerSpellAuraTick(Unit* target, Unit* caster) const; + void HandlePeriodicTriggerSpellWithValueAuraTick(Unit* target, Unit* caster) const; + void HandlePeriodicDamageAurasTick(Unit* target, Unit* caster) const; + void HandlePeriodicHealthLeechAuraTick(Unit* target, Unit* caster) const; + void HandlePeriodicHealthFunnelAuraTick(Unit* target, Unit* caster) const; + void HandlePeriodicHealAurasTick(Unit* target, Unit* caster) const; + void HandlePeriodicManaLeechAuraTick(Unit* target, Unit* caster) const; + void HandleObsModPowerAuraTick(Unit* target, Unit* caster) const; + void HandlePeriodicEnergizeAuraTick(Unit* target, Unit* caster) const; + void HandlePeriodicPowerBurnAuraTick(Unit* target, Unit* caster) const; + + // aura effect proc handlers + void HandleBreakableCCAuraProc(AuraApplication* aurApp, ProcEventInfo& eventInfo); + void HandleProcTriggerSpellAuraProc(AuraApplication* aurApp, ProcEventInfo& eventInfo); + void HandleProcTriggerSpellCopyAuraProc(AuraApplication* aurApp, ProcEventInfo& eventInfo); + void HandleProcTriggerSpellWithValueAuraProc(AuraApplication* aurApp, ProcEventInfo& eventInfo); + void HandleProcTriggerDamageAuraProc(AuraApplication* aurApp, ProcEventInfo& eventInfo); + void HandleRaidProcFromChargeAuraProc(AuraApplication* aurApp, ProcEventInfo& eventInfo); + void HandleRaidProcFromChargeWithValueAuraProc(AuraApplication* aurApp, ProcEventInfo& eventInfo); + void HandleProcOnPowerAmountAuraProc(AuraApplication* aurApp, ProcEventInfo& eventInfo); }; namespace Firelands { - // Binary predicate for sorting the priority of absorption aura effects - class AbsorbAuraOrderPred +// Binary predicate for sorting the priority of absorption aura effects +class AbsorbAuraOrderPred +{ + public: + AbsorbAuraOrderPred() { - public: - AbsorbAuraOrderPred() { } - bool operator() (AuraEffect* aurEffA, AuraEffect* aurEffB) const - { - SpellInfo const* spellProtoA = aurEffA->GetSpellInfo(); - SpellInfo const* spellProtoB = aurEffB->GetSpellInfo(); - - // Wards - if ((spellProtoA->SpellFamilyName == SPELLFAMILY_MAGE) || - (spellProtoA->SpellFamilyName == SPELLFAMILY_WARLOCK)) - if (spellProtoA->GetCategory() == 56) - return true; - if ((spellProtoB->SpellFamilyName == SPELLFAMILY_MAGE) || - (spellProtoB->SpellFamilyName == SPELLFAMILY_WARLOCK)) - if (spellProtoB->GetCategory() == 56) - return false; - - // Sacred Shield - if (spellProtoA->Id == 58597) - return true; - if (spellProtoB->Id == 58597) - return false; - - // Fel Blossom - if (spellProtoA->Id == 28527) - return true; - if (spellProtoB->Id == 28527) - return false; - - // Divine Aegis - if (spellProtoA->Id == 47753) - return true; - if (spellProtoB->Id == 47753) - return false; - - // Ice Barrier - if (spellProtoA->GetCategory() == 471) - return true; - if (spellProtoB->GetCategory() == 471) - return false; - - // Sacrifice - if ((spellProtoA->SpellFamilyName == SPELLFAMILY_WARLOCK) && - (spellProtoA->SpellIconID == 693)) - return true; - if ((spellProtoB->SpellFamilyName == SPELLFAMILY_WARLOCK) && - (spellProtoB->SpellIconID == 693)) - return false; - + } + bool operator()(AuraEffect* aurEffA, AuraEffect* aurEffB) const + { + SpellInfo const* spellProtoA = aurEffA->GetSpellInfo(); + SpellInfo const* spellProtoB = aurEffB->GetSpellInfo(); + + // Wards + if ((spellProtoA->SpellFamilyName == SPELLFAMILY_MAGE) || (spellProtoA->SpellFamilyName == SPELLFAMILY_WARLOCK)) + if (spellProtoA->GetCategory() == 56) + return true; + if ((spellProtoB->SpellFamilyName == SPELLFAMILY_MAGE) || (spellProtoB->SpellFamilyName == SPELLFAMILY_WARLOCK)) + if (spellProtoB->GetCategory() == 56) return false; - } - }; -} + + // Sacred Shield + if (spellProtoA->Id == 58597) + return true; + if (spellProtoB->Id == 58597) + return false; + + // Fel Blossom + if (spellProtoA->Id == 28527) + return true; + if (spellProtoB->Id == 28527) + return false; + + // Divine Aegis + if (spellProtoA->Id == 47753) + return true; + if (spellProtoB->Id == 47753) + return false; + + // Ice Barrier + if (spellProtoA->GetCategory() == 471) + return true; + if (spellProtoB->GetCategory() == 471) + return false; + + // Sacrifice + if ((spellProtoA->SpellFamilyName == SPELLFAMILY_WARLOCK) && (spellProtoA->SpellIconID == 693)) + return true; + if ((spellProtoB->SpellFamilyName == SPELLFAMILY_WARLOCK) && (spellProtoB->SpellIconID == 693)) + return false; + + return false; + } +}; +} // namespace Firelands #endif diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp index 343f7b9d..b40bdc19 100644 --- a/src/server/game/Spells/Auras/SpellAuras.cpp +++ b/src/server/game/Spells/Auras/SpellAuras.cpp @@ -15,8 +15,8 @@ * with this program. If not, see . */ -#include "Common.h" #include "CellImpl.h" +#include "Common.h" #include "Config.h" #include "DynamicObject.h" #include "EnumFlag.h" @@ -40,9 +40,8 @@ #include "World.h" #include "WorldPacket.h" -AuraApplication::AuraApplication(Unit* target, Unit* caster, Aura* aura, uint8 effMask): -_target(target), _base(aura), _removeMode(AuraRemoveFlags::None), _slot(MAX_AURAS), -_flags(AFLAG_NONE), _effectsToApply(effMask), _needClientUpdate(false) +AuraApplication::AuraApplication(Unit* target, Unit* caster, Aura* aura, uint8 effMask) + : _target(target), _base(aura), _removeMode(AuraRemoveFlags::None), _slot(MAX_AURAS), _flags(AFLAG_NONE), _effectsToApply(effMask), _needClientUpdate(false) { ASSERT(GetTarget() && GetBase()); @@ -51,7 +50,7 @@ _flags(AFLAG_NONE), _effectsToApply(effMask), _needClientUpdate(false) // Try find slot for aura uint8 slot = MAX_AURAS; // Lookup for auras already applied from spell - if (AuraApplication * foundAura = GetTarget()->GetAuraApplication(GetBase()->GetId(), GetBase()->GetCasterGUID(), GetBase()->GetCastItemGUID())) + if (AuraApplication* foundAura = GetTarget()->GetAuraApplication(GetBase()->GetId(), GetBase()->GetCasterGUID(), GetBase()->GetCastItemGUID())) { // allow use single slot only by auras from same caster slot = foundAura->GetSlot(); @@ -93,7 +92,7 @@ void AuraApplication::_Remove() if (slot >= MAX_AURAS) return; - if (AuraApplication * foundAura = _target->GetAuraApplication(GetBase()->GetId(), GetBase()->GetCasterGUID(), GetBase()->GetCastItemGUID())) + if (AuraApplication* foundAura = _target->GetAuraApplication(GetBase()->GetId(), GetBase()->GetCasterGUID(), GetBase()->GetCastItemGUID())) { // Reuse visible aura slot by aura which is still applied - prevent storing dead pointers if (slot == foundAura->GetSlot()) @@ -128,7 +127,7 @@ void AuraApplication::_InitFlags(Unit* caster, uint8 effMask) bool negativeFound = false; for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) { - if (((1<GetSpellInfo()->IsPositiveEffect(i)) + if (((1 << i) & effMask) && !GetBase()->GetSpellInfo()->IsPositiveEffect(i)) { negativeFound = true; break; @@ -143,7 +142,7 @@ void AuraApplication::_InitFlags(Unit* caster, uint8 effMask) bool positiveFound = false; for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) { - if (((1<GetSpellInfo()->IsPositiveEffect(i)) + if (((1 << i) & effMask) && GetBase()->GetSpellInfo()->IsPositiveEffect(i)) { positiveFound = true; break; @@ -161,19 +160,19 @@ void AuraApplication::_HandleEffect(uint8 effIndex, bool apply) AuraEffect* aurEff = GetBase()->GetEffect(effIndex); ASSERT(aurEff); ASSERT(HasEffect(effIndex) == (!apply)); - ASSERT((1<GetAuraType(), apply, aurEff->GetAmount()); if (apply) { - ASSERT(!(_flags & (1<HandleEffect(this, AURA_EFFECT_HANDLE_REAL, true); } else { - ASSERT(_flags & (1<HandleEffect(this, AURA_EFFECT_HANDLE_REAL, false); } SetNeedClientUpdate(); @@ -192,7 +191,6 @@ void AuraApplication::BuildUpdatePacket(WorldPackets::Spells::AuraInfo& auraInfo } ASSERT(_target->GetVisibleAura(_slot)); - Aura const* aura = GetBase(); auraData.SpellID = aura->GetId(); auraData.Flags = GetFlags(); @@ -217,7 +215,7 @@ void AuraApplication::BuildUpdatePacket(WorldPackets::Spells::AuraInfo& auraInfo if (auraData.Flags & AFLAG_ANY_EFFECT_AMOUNT_SENT) for (uint32 i = 0; i < MAX_SPELL_EFFECTS; ++i) if (AuraEffect const* effect = aura->GetEffect(i)) - if (HasEffect(i)) // Not all of aura's effects have to be applied on every target + if (HasEffect(i)) // Not all of aura's effects have to be applied on every target auraData.Points[i] = effect->GetAmount(); } @@ -242,30 +240,31 @@ uint8 Aura::BuildEffectMaskForOwner(SpellInfo const* spellProto, uint8 available uint8 effMask = 0; switch (owner->GetTypeId()) { - case TYPEID_UNIT: - case TYPEID_PLAYER: - for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) - { - if (spellProto->Effects[i].IsUnitOwnedAuraEffect()) - effMask |= 1 << i; - } - break; - case TYPEID_DYNAMICOBJECT: - for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) - { - if (spellProto->Effects[i].Effect == SPELL_EFFECT_PERSISTENT_AREA_AURA) - effMask |= 1 << i; - } - break; - default: - ABORT(); - break; + case TYPEID_UNIT: + case TYPEID_PLAYER: + for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) + { + if (spellProto->Effects[i].IsUnitOwnedAuraEffect()) + effMask |= 1 << i; + } + break; + case TYPEID_DYNAMICOBJECT: + for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) + { + if (spellProto->Effects[i].Effect == SPELL_EFFECT_PERSISTENT_AREA_AURA) + effMask |= 1 << i; + } + break; + default: + ABORT(); + break; } return effMask & availableEffectMask; } -Aura* Aura::TryRefreshStackOrCreate(SpellInfo const* spellproto, uint8 tryEffMask, WorldObject* owner, Unit* caster, int32* baseAmount /*= nullptr*/, Item* castItem /*= nullptr*/, ObjectGuid casterGUID /*= ObjectGuid::Empty*/, bool* refresh /*= nullptr*/) +Aura* Aura::TryRefreshStackOrCreate(SpellInfo const* spellproto, uint8 tryEffMask, WorldObject* owner, Unit* caster, int32* baseAmount /*= nullptr*/, Item* castItem /*= nullptr*/, + ObjectGuid casterGUID /*= ObjectGuid::Empty*/, bool* refresh /*= nullptr*/) { ASSERT(spellproto); ASSERT(owner); @@ -294,7 +293,8 @@ Aura* Aura::TryRefreshStackOrCreate(SpellInfo const* spellproto, uint8 tryEffMas return Create(spellproto, effMask, owner, caster, baseAmount, castItem, casterGUID); } -Aura* Aura::TryCreate(SpellInfo const* spellproto, uint8 tryEffMask, WorldObject* owner, Unit* caster, int32* baseAmount /*= nullptr*/, Item* castItem /*= nullptr*/, ObjectGuid casterGUID /*= ObjectGuid::Empty*/) +Aura* Aura::TryCreate( + SpellInfo const* spellproto, uint8 tryEffMask, WorldObject* owner, Unit* caster, int32* baseAmount /*= nullptr*/, Item* castItem /*= nullptr*/, ObjectGuid casterGUID /*= ObjectGuid::Empty*/) { ASSERT(spellproto); ASSERT(owner); @@ -335,16 +335,16 @@ Aura* Aura::Create(SpellInfo const* spellproto, uint8 effMask, WorldObject* owne Aura* aura = nullptr; switch (owner->GetTypeId()) { - case TYPEID_UNIT: - case TYPEID_PLAYER: - aura = new UnitAura(spellproto, effMask, owner, caster, baseAmount, castItem, casterGUID); - break; - case TYPEID_DYNAMICOBJECT: - aura = new DynObjAura(spellproto, effMask, owner, caster, baseAmount, castItem, casterGUID); - break; - default: - ABORT(); - return nullptr; + case TYPEID_UNIT: + case TYPEID_PLAYER: + aura = new UnitAura(spellproto, effMask, owner, caster, baseAmount, castItem, casterGUID); + break; + case TYPEID_DYNAMICOBJECT: + aura = new DynObjAura(spellproto, effMask, owner, caster, baseAmount, castItem, casterGUID); + break; + default: + ABORT(); + return nullptr; } // aura can be removed in Unit::_AddAura call @@ -353,13 +353,10 @@ Aura* Aura::Create(SpellInfo const* spellproto, uint8 effMask, WorldObject* owne return aura; } -Aura::Aura(SpellInfo const* spellproto, WorldObject* owner, Unit* caster, Item* castItem, ObjectGuid casterGUID) : -m_spellInfo(spellproto), m_casterGuid(casterGUID ? casterGUID : caster->GetGUID()), -m_castItemGuid(castItem ? castItem->GetGUID() : ObjectGuid::Empty), m_applyTime(GameTime::GetGameTime()), -m_owner(owner), m_timeCla(0), m_updateTargetMapInterval(0), -m_casterLevel(caster ? caster->getLevel() : m_spellInfo->SpellLevel), m_procCharges(0), m_stackAmount(1), -m_isRemoved(false), m_isLimitedTarget(false), m_isUsingCharges(false), m_dropEvent(nullptr), -m_procCooldown(std::chrono::steady_clock::time_point::min()) +Aura::Aura(SpellInfo const* spellproto, WorldObject* owner, Unit* caster, Item* castItem, ObjectGuid casterGUID) + : m_spellInfo(spellproto), m_casterGuid(casterGUID ? casterGUID : caster->GetGUID()), m_castItemGuid(castItem ? castItem->GetGUID() : ObjectGuid::Empty), m_applyTime(GameTime::GetGameTime()), + m_owner(owner), m_timeCla(0), m_updateTargetMapInterval(0), _casterInfo(), m_procCharges(0), m_stackAmount(1), m_isRemoved(false), m_isLimitedTarget(false), m_isUsingCharges(false), + m_dropEvent(nullptr), m_procCooldown(std::chrono::steady_clock::time_point::min()) { if (m_spellInfo->ManaPerSecond) m_timeCla = 1 * IN_MILLISECONDS; @@ -372,6 +369,13 @@ m_procCooldown(std::chrono::steady_clock::time_point::min()) m_isUsingCharges = m_procCharges != 0; memset(m_effects, 0, sizeof(m_effects)); // m_casterLevel = cast item level/caster level, caster level should be saved to db, confirmed with sniffs + _casterInfo.Level = m_spellInfo->SpellLevel; + if (caster) + { + _casterInfo.Level = caster->getLevel(); + _casterInfo.ApplyResilience = caster->CanApplyResilience(); + SaveCasterInfo(caster); + } } AuraScript* Aura::GetScriptByName(std::string const& scriptName) const @@ -382,7 +386,7 @@ AuraScript* Aura::GetScriptByName(std::string const& scriptName) const return nullptr; } -void Aura::_InitEffects(uint8 effMask, Unit* caster, int32 *baseAmount) +void Aura::_InitEffects(uint8 effMask, Unit* caster, int32* baseAmount) { // shouldn't be in constructor - functions in AuraEffect::AuraEffect use polymorphism for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) @@ -394,6 +398,54 @@ void Aura::_InitEffects(uint8 effMask, Unit* caster, int32 *baseAmount) } } +bool Aura::CanPeriodicTickCrit(Unit const* caster) const +{ + if (m_spellInfo->HasAttribute(SPELL_ATTR8_PERIODIC_CAN_CRIT)) + return true; + + return caster->HasAuraTypeWithAffectMask(SPELL_AURA_ABILITY_PERIODIC_CRIT, GetSpellInfo()); +} + +float Aura::CalcPeriodicCritChance(Unit const* caster) const +{ + Player* modOwner = caster->GetSpellModOwner(); + if (!modOwner || !CanPeriodicTickCrit(modOwner)) + return 0.f; + + float critChance = modOwner->SpellCritChanceDone(GetSpellInfo(), GetSpellInfo()->GetSchoolMask(), GetSpellInfo()->GetAttackType()); + return std::max(0.f, critChance); +} + +void Aura::SaveCasterInfo(Unit* caster) +{ + _casterInfo.CritChance = CalcPeriodicCritChance(caster); + + if (GetType() == UNIT_AURA_TYPE) + { + /* + * Get critical chance from last effect type (damage or healing) + * this could potentialy be wrong if any spell has both damage and heal periodics + * The only two spells in 3.3.5 with those conditions are 17484 and 50344 + * which shouldn't be allowed to crit, so we're fine + */ + for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) + { + switch (GetSpellInfo()->Effects[i].ApplyAuraName) + { + case SPELL_AURA_PERIODIC_HEAL: + _casterInfo.BonusDonePct = caster->SpellHealingPctDone(GetUnitOwner(), GetSpellInfo()); + break; + case SPELL_AURA_PERIODIC_DAMAGE: + case SPELL_AURA_PERIODIC_LEECH: + _casterInfo.BonusDonePct = caster->SpellDamagePctDone(GetUnitOwner(), GetSpellInfo(), DOT); + break; + default: + break; + } + } + } +} + Aura::~Aura() { // unload scripts @@ -405,7 +457,7 @@ Aura::~Aura() // free effects memory for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) - delete m_effects[i]; + delete m_effects[i]; ASSERT(m_applications.empty()); _DeleteRemovedApplications(); @@ -426,12 +478,12 @@ AuraObjectType Aura::GetType() const return (m_owner->GetTypeId() == TYPEID_DYNAMICOBJECT) ? DYNOBJ_AURA_TYPE : UNIT_AURA_TYPE; } -void Aura::_ApplyForTarget(Unit* target, Unit* caster, AuraApplication * auraApp) +void Aura::_ApplyForTarget(Unit* target, Unit* caster, AuraApplication* auraApp) { ASSERT(target); ASSERT(auraApp); // aura mustn't be already applied on target - ASSERT (!IsAppliedOnTarget(target->GetGUID()) && "Aura::_ApplyForTarget: aura musn't be already applied on target"); + ASSERT(!IsAppliedOnTarget(target->GetGUID()) && "Aura::_ApplyForTarget: aura musn't be already applied on target"); m_applications[target->GetGUID()] = auraApp; @@ -446,7 +498,7 @@ void Aura::_ApplyForTarget(Unit* target, Unit* caster, AuraApplication * auraApp } } -void Aura::_UnapplyForTarget(Unit* target, Unit* caster, AuraApplication * auraApp) +void Aura::_UnapplyForTarget(Unit* target, Unit* caster, AuraApplication* auraApp) { ASSERT(target); ASSERT(auraApp->GetRemoveMode().HasAnyFlag()); @@ -457,8 +509,8 @@ void Aura::_UnapplyForTarget(Unit* target, Unit* caster, AuraApplication * auraA /// @todo Figure out why this happens if (itr == m_applications.end()) { - LOG_ERROR("spells", "Aura::_UnapplyForTarget, target:%u, caster:%u, spell:%u was not found in owners application map!", - target->GetGUID().GetCounter(), caster ? caster->GetGUID().GetCounter() : 0, auraApp->GetBase()->GetSpellInfo()->Id); + LOG_ERROR("spells", "Aura::_UnapplyForTarget, target:%u, caster:%u, spell:%u was not found in owners application map!", target->GetGUID().GetCounter(), + caster ? caster->GetGUID().GetCounter() : 0, auraApp->GetBase()->GetSpellInfo()->Id); ABORT(); } @@ -479,13 +531,13 @@ void Aura::_UnapplyForTarget(Unit* target, Unit* caster, AuraApplication * auraA void Aura::_Remove(AuraRemoveFlags removeMode) { ASSERT(!m_isRemoved); - ASSERT(!EnumFlag{ removeMode }.HasFlag(AuraRemoveFlags::DontResetPeriodicTimer), "Aura must not be removed with AuraRemoveFlags::DontResetPeriodicTimer"); + ASSERT(!EnumFlag{removeMode}.HasFlag(AuraRemoveFlags::DontResetPeriodicTimer), "Aura must not be removed with AuraRemoveFlags::DontResetPeriodicTimer"); m_isRemoved = true; ApplicationMap::iterator appItr = m_applications.begin(); for (appItr = m_applications.begin(); appItr != m_applications.end();) { - AuraApplication * aurApp = appItr->second; + AuraApplication* aurApp = appItr->second; Unit* target = aurApp->GetTarget(); target->_UnapplyAura(aurApp, removeMode); appItr = m_applications.begin(); @@ -513,7 +565,7 @@ void Aura::UpdateTargetMap(Unit* caster, bool apply) std::deque targetsToRemove; // mark all auras as ready to remove - for (ApplicationMap::iterator appIter = m_applications.begin(); appIter != m_applications.end();++appIter) + for (ApplicationMap::iterator appIter = m_applications.begin(); appIter != m_applications.end(); ++appIter) { auto itr = targets.find(appIter->second->GetTarget()); // not found in current area - remove the aura @@ -532,7 +584,7 @@ void Aura::UpdateTargetMap(Unit* caster, bool apply) } // register auras for units - for (auto itr = targets.begin(); itr!= targets.end();) + for (auto itr = targets.begin(); itr != targets.end();) { // aura mustn't be already applied on target if (AuraApplication* aurApp = GetApplicationOfTarget(itr->first->GetGUID())) @@ -562,9 +614,7 @@ void Aura::UpdateTargetMap(Unit* caster, bool apply) if (itr->first->IsImmunedToSpellEffect(GetSpellInfo(), effIndex, caster)) itr->second &= ~(1 << effIndex); } - if (!itr->second - || itr->first->IsImmunedToSpell(GetSpellInfo(), caster) - || !CanBeAppliedOn(itr->first)) + if (!itr->second || itr->first->IsImmunedToSpell(GetSpellInfo(), caster) || !CanBeAppliedOn(itr->first)) addUnit = false; if (addUnit && !itr->first->IsHighestExclusiveAura(this, true)) @@ -601,9 +651,8 @@ void Aura::UpdateTargetMap(Unit* caster, bool apply) if (!GetOwner()->IsSelfOrInSameMap(itr->first)) { /// @todo There is a crash caused by shadowfiend load addon - LOG_FATAL("spells", "Aura %u: Owner %s (map %u) is not in the same map as target %s (map %u).", GetSpellInfo()->Id, - GetOwner()->GetName().c_str(), GetOwner()->IsInWorld() ? GetOwner()->GetMap()->GetId() : uint32(-1), - itr->first->GetName().c_str(), itr->first->IsInWorld() ? itr->first->GetMap()->GetId() : uint32(-1)); + LOG_FATAL("spells", "Aura %u: Owner %s (map %u) is not in the same map as target %s (map %u).", GetSpellInfo()->Id, GetOwner()->GetName().c_str(), + GetOwner()->IsInWorld() ? GetOwner()->GetMap()->GetId() : uint32(-1), itr->first->GetName().c_str(), itr->first->IsInWorld() ? itr->first->GetMap()->GetId() : uint32(-1)); ABORT(); } itr->first->_CreateAuraApplication(this, itr->second); @@ -620,7 +669,7 @@ void Aura::UpdateTargetMap(Unit* caster, bool apply) return; // apply aura effects for units - for (auto itr = targets.begin(); itr!= targets.end(); ++itr) + for (auto itr = targets.begin(); itr != targets.end(); ++itr) { if (AuraApplication* aurApp = GetApplicationOfTarget(itr->first->GetGUID())) { @@ -638,7 +687,7 @@ void Aura::_ApplyEffectForTargets(uint8 effIndex) UnitList targetList; for (ApplicationMap::iterator appIter = m_applications.begin(); appIter != m_applications.end(); ++appIter) { - if ((appIter->second->GetEffectsToApply() & (1<second->HasEffect(effIndex)) + if ((appIter->second->GetEffectsToApply() & (1 << effIndex)) && !appIter->second->HasEffect(effIndex)) targetList.push_back(appIter->second->GetTarget()); } @@ -1007,17 +1056,17 @@ bool Aura::CanBeSaved() const // so put here only these for which you are sure they get removed switch (GetId()) { - case 44413: // Incanter's Absorption - case 40075: // Fel Flak Fire - case 55849: // Power Spark - case 96206: // Nature's Bounty - case 81206: // Chakra: Sanctuary - case 81207: // Chakra: Sanctuary - case 81208: // Chakra: Serenity - case 81209: // Chakra: Chastise - case 68631: // Curse of the Worgen - case 89912: // Chakra Flow - return false; + case 44413: // Incanter's Absorption + case 40075: // Fel Flak Fire + case 55849: // Power Spark + case 96206: // Nature's Bounty + case 81206: // Chakra: Sanctuary + case 81207: // Chakra: Sanctuary + case 81208: // Chakra: Serenity + case 81209: // Chakra: Chastise + case 68631: // Curse of the Worgen + case 89912: // Chakra Flow + return false; } // When a druid logins, he doesnt have either eclipse power, nor the marker auras, nor the eclipse buffs. Dont save them. @@ -1040,8 +1089,8 @@ bool Aura::CanBeSentToClient() const if (!IsPassive() || GetSpellInfo()->HasAreaAuraEffect()) return true; - return HasEffectType(SPELL_AURA_ABILITY_IGNORE_AURASTATE) || HasEffectType(SPELL_AURA_CAST_WHILE_WALKING) - || HasEffectType(SPELL_AURA_OVERRIDE_ACTIONBAR_SPELLS) || HasEffectType(SPELL_AURA_MOD_SPELL_COOLDOWN_BY_HASTE); + return HasEffectType(SPELL_AURA_ABILITY_IGNORE_AURASTATE) || HasEffectType(SPELL_AURA_CAST_WHILE_WALKING) || HasEffectType(SPELL_AURA_OVERRIDE_ACTIONBAR_SPELLS) || + HasEffectType(SPELL_AURA_MOD_SPELL_COOLDOWN_BY_HASTE); } bool Aura::IsLimitedTargetWith(Aura const* aura) const @@ -1054,13 +1103,13 @@ bool Aura::IsLimitedTargetWith(Aura const* aura) const // spell with single target specific types switch (spec) { - case SPELL_SPECIFIC_JUDGEMENT: - case SPELL_SPECIFIC_MAGE_POLYMORPH: - if (aura->GetSpellInfo()->GetSpellSpecific() == spec) - return true; - break; - default: - break; + case SPELL_SPECIFIC_JUDGEMENT: + case SPELL_SPECIFIC_MAGE_POLYMORPH: + if (aura->GetSpellInfo()->GetSpellSpecific() == spec) + return true; + break; + default: + break; } if (HasEffectType(SPELL_AURA_CONTROL_VEHICLE) && aura->HasEffectType(SPELL_AURA_CONTROL_VEHICLE)) @@ -1098,13 +1147,15 @@ int32 Aura::CalcDispelChance(Unit const* auraTarget, bool offensive) const return 100 - resistChance; } -void Aura::SetLoadedState(int32 maxduration, int32 duration, int32 charges, uint8 stackamount, uint8 recalculateMask, int32 * amount) +void Aura::SetLoadedState(int32 maxduration, int32 duration, int32 charges, uint8 stackamount, uint8 recalculateMask, float critChance, bool applyResilience, int32* amount) { m_maxDuration = maxduration; m_duration = duration; m_procCharges = charges; m_isUsingCharges = m_procCharges != 0; m_stackAmount = stackamount; + SetCritChance(critChance); + SetCanApplyResilience(applyResilience); Unit* caster = GetCaster(); for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) { @@ -1133,12 +1184,12 @@ bool Aura::EffectTypeNeedsSendingAmount(AuraType type) { switch (type) { - case SPELL_AURA_OVERRIDE_ACTIONBAR_SPELLS: - case SPELL_AURA_OVERRIDE_ACTIONBAR_SPELLS_TRIGGERED: - case SPELL_AURA_MOD_SPELL_CATEGORY_COOLDOWN: - return true; - default: - break; + case SPELL_AURA_OVERRIDE_ACTIONBAR_SPELLS: + case SPELL_AURA_OVERRIDE_ACTIONBAR_SPELLS_TRIGGERED: + case SPELL_AURA_MOD_SPELL_CATEGORY_COOLDOWN: + return true; + default: + break; } return false; @@ -1146,16 +1197,16 @@ bool Aura::EffectTypeNeedsSendingAmount(AuraType type) void Aura::RecalculateAmountOfEffects() { - ASSERT (!IsRemoved()); + ASSERT(!IsRemoved()); Unit* caster = GetCaster(); for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) if (HasEffect(i)) m_effects[i]->RecalculateAmount(caster); } -void Aura::HandleAllEffects(AuraApplication * aurApp, uint8 mode, bool apply) +void Aura::HandleAllEffects(AuraApplication* aurApp, uint8 mode, bool apply) { - ASSERT (!IsRemoved()); + ASSERT(!IsRemoved()); for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) if (m_effects[i] && !IsRemoved()) m_effects[i]->HandleEffect(aurApp, mode, apply); @@ -1262,85 +1313,85 @@ void Aura::HandleAuraSpecificMods(AuraApplication const* aurApp, Unit* caster, b { switch (GetSpellInfo()->SpellFamilyName) { - case SPELLFAMILY_GENERIC: - switch (GetId()) - { - case 32474: // Buffeting Winds of Susurrus - if (target->GetTypeId() == TYPEID_PLAYER) - target->ToPlayer()->ActivateTaxiPathTo(506, GetId()); - break; - case 33572: // Gronn Lord's Grasp, becomes stoned - if (GetStackAmount() >= 5 && !target->HasAura(33652)) - target->CastSpell(target, 33652, true); - break; - case 50836: //Petrifying Grip, becomes stoned - if (GetStackAmount() >= 5 && !target->HasAura(50812)) - target->CastSpell(target, 50812, true); - break; - case 60970: // Heroic Fury (remove Intercept cooldown) - if (target->GetTypeId() == TYPEID_PLAYER) - target->GetSpellHistory()->ResetCooldown(20252, true); - break; - } + case SPELLFAMILY_GENERIC: + switch (GetId()) + { + case 32474: // Buffeting Winds of Susurrus + if (target->GetTypeId() == TYPEID_PLAYER) + target->ToPlayer()->ActivateTaxiPathTo(506, GetId()); break; - case SPELLFAMILY_DRUID: - if (!caster) - break; - // Rejuvenation - if (GetSpellInfo()->SpellFamilyFlags[0] & 0x10 && GetEffect(EFFECT_0)) + case 33572: // Gronn Lord's Grasp, becomes stoned + if (GetStackAmount() >= 5 && !target->HasAura(33652)) + target->CastSpell(target, 33652, true); + break; + case 50836: // Petrifying Grip, becomes stoned + if (GetStackAmount() >= 5 && !target->HasAura(50812)) + target->CastSpell(target, 50812, true); + break; + case 60970: // Heroic Fury (remove Intercept cooldown) + if (target->GetTypeId() == TYPEID_PLAYER) + target->GetSpellHistory()->ResetCooldown(20252, true); + break; + } + break; + case SPELLFAMILY_DRUID: + if (!caster) + break; + // Rejuvenation + if (GetSpellInfo()->SpellFamilyFlags[0] & 0x10 && GetEffect(EFFECT_0)) + { + // Druid T8 Restoration 4P Bonus + if (caster->HasAura(64760)) { - // Druid T8 Restoration 4P Bonus - if (caster->HasAura(64760)) - { - CastSpellExtraArgs args(GetEffect(EFFECT_0)); - args.SpellValueOverrides.AddMod(SPELLVALUE_BASE_POINT0, GetEffect(EFFECT_0)->GetAmount()); - caster->CastSpell(target, 64801, args); - } + CastSpellExtraArgs args(GetEffect(EFFECT_0)); + args.SpellValueOverrides.AddMod(SPELLVALUE_BASE_POINT0, GetEffect(EFFECT_0)->GetAmount()); + caster->CastSpell(target, 64801, args); } + } + break; + case SPELLFAMILY_MAGE: + if (!caster) break; - case SPELLFAMILY_MAGE: - if (!caster) - break; - /// @todo This should be moved to similar function in spell::hit - if (GetSpellInfo()->SpellFamilyFlags[0] & 0x01000000) + /// @todo This should be moved to similar function in spell::hit + if (GetSpellInfo()->SpellFamilyFlags[0] & 0x01000000) + { + // Polymorph Sound - Sheep && Penguin + if (GetSpellInfo()->SpellIconID == 82 && GetSpellInfo()->SpellVisual[0] == 12978) { - // Polymorph Sound - Sheep && Penguin - if (GetSpellInfo()->SpellIconID == 82 && GetSpellInfo()->SpellVisual[0] == 12978) - { - if (caster->HasAura(52648)) // Glyph of the Penguin - caster->CastSpell(target, 61635, true); - else if (caster->HasAura(57927)) // Glyph of the Monkey - caster->CastSpell(target, 89729, true); - else - caster->CastSpell(target, 61634, true); - } + if (caster->HasAura(52648)) // Glyph of the Penguin + caster->CastSpell(target, 61635, true); + else if (caster->HasAura(57927)) // Glyph of the Monkey + caster->CastSpell(target, 89729, true); + else + caster->CastSpell(target, 61634, true); } + } + break; + case SPELLFAMILY_PRIEST: + if (!caster) break; - case SPELLFAMILY_PRIEST: - if (!caster) - break; - // Power Word: Shield - else if (m_spellInfo->SpellFamilyFlags[0] & 0x1 && m_spellInfo->SpellFamilyFlags[2] & 0x400 && GetEffect(0)) + // Power Word: Shield + else if (m_spellInfo->SpellFamilyFlags[0] & 0x1 && m_spellInfo->SpellFamilyFlags[2] & 0x400 && GetEffect(0)) + { + // Glyph of Power Word: Shield + if (AuraEffect* glyph = caster->GetAuraEffect(55672, 0)) { - // Glyph of Power Word: Shield - if (AuraEffect* glyph = caster->GetAuraEffect(55672, 0)) - { - // instantly heal m_amount% of the absorb-value - int32 heal = glyph->GetAmount() * GetEffect(0)->GetAmount()/100; - CastSpellExtraArgs args(GetEffect(0)); - args.SpellValueOverrides.AddMod(SPELLVALUE_BASE_POINT0, heal); - caster->CastSpell(GetUnitOwner(), 56160, args); - } + // instantly heal m_amount% of the absorb-value + int32 heal = glyph->GetAmount() * GetEffect(0)->GetAmount() / 100; + CastSpellExtraArgs args(GetEffect(0)); + args.SpellValueOverrides.AddMod(SPELLVALUE_BASE_POINT0, heal); + caster->CastSpell(GetUnitOwner(), 56160, args); } - break; - case SPELLFAMILY_ROGUE: - // Sprint (skip non player cast spells by category) - if (GetSpellInfo()->SpellFamilyFlags[0] & 0x40 && GetSpellInfo()->GetCategory() == 44) - // in official maybe there is only one icon? - if (target->HasAura(58039)) // Glyph of Blurred Speed - target->CastSpell(target, 61922, true); // Sprint (waterwalk) - break; + } + break; + case SPELLFAMILY_ROGUE: + // Sprint (skip non player cast spells by category) + if (GetSpellInfo()->SpellFamilyFlags[0] & 0x40 && GetSpellInfo()->GetCategory() == 44) + // in official maybe there is only one icon? + if (target->HasAura(58039)) // Glyph of Blurred Speed + target->CastSpell(target, 61922, true); // Sprint (waterwalk) + break; } } // mods at aura remove @@ -1348,162 +1399,166 @@ void Aura::HandleAuraSpecificMods(AuraApplication const* aurApp, Unit* caster, b { switch (GetSpellInfo()->SpellFamilyName) { - case SPELLFAMILY_GENERIC: - switch (GetId()) - { - case 61987: // Avenging Wrath - // Remove the immunity shield marker on Avenging Wrath removal if Forbearance is not present - if (target->HasAura(61988) && !target->HasAura(25771)) - target->RemoveAura(61988); - break; - default: - break; - } + case SPELLFAMILY_GENERIC: + switch (GetId()) + { + case 61987: // Avenging Wrath + // Remove the immunity shield marker on Avenging Wrath removal if Forbearance is not present + if (target->HasAura(61988) && !target->HasAura(25771)) + target->RemoveAura(61988); break; - case SPELLFAMILY_MAGE: - switch (GetId()) - { - case 66: // Invisibility - { - if (!removeMode.HasFlag(AuraRemoveFlags::Expired)) - break; - - target->CastSpell(target, 32612, GetEffect(EFFECT_1)); - break; - } - default: - break; - } + default: break; - case SPELLFAMILY_WARLOCK: - if (!caster) + } + break; + case SPELLFAMILY_MAGE: + switch (GetId()) + { + case 66: // Invisibility + { + if (!removeMode.HasFlag(AuraRemoveFlags::Expired)) break; - // Improved Fear - if (GetSpellInfo()->SpellFamilyFlags[1] & 0x00000400) + + target->CastSpell(target, 32612, GetEffect(EFFECT_1)); + break; + } + default: + break; + } + break; + case SPELLFAMILY_WARLOCK: + if (!caster) + break; + // Improved Fear + if (GetSpellInfo()->SpellFamilyFlags[1] & 0x00000400) + { + if (AuraEffect* aurEff = caster->GetAuraEffect(SPELL_AURA_DUMMY, SPELLFAMILY_WARLOCK, 98, 0)) { - if (AuraEffect* aurEff = caster->GetAuraEffect(SPELL_AURA_DUMMY, SPELLFAMILY_WARLOCK, 98, 0)) + uint32 spellId = 0; + switch (aurEff->GetId()) { - uint32 spellId = 0; - switch (aurEff->GetId()) - { - case 53759: spellId = 60947; break; - case 53754: spellId = 60946; break; - default: - LOG_ERROR("spells", "Aura::HandleAuraSpecificMods: Unknown rank of Improved Fear (%d) found", aurEff->GetId()); - } - if (spellId) - caster->CastSpell(target, spellId, true); + case 53759: + spellId = 60947; + break; + case 53754: + spellId = 60946; + break; + default: + LOG_ERROR("spells", "Aura::HandleAuraSpecificMods: Unknown rank of Improved Fear (%d) found", aurEff->GetId()); } + if (spellId) + caster->CastSpell(target, spellId, true); } + } + break; + case SPELLFAMILY_PRIEST: + if (!caster) break; - case SPELLFAMILY_PRIEST: - if (!caster) - break; - // Power word: shield - if (removeMode.HasFlag(AuraRemoveFlags::ByEnemySpell) && GetSpellInfo()->SpellFamilyFlags[0] & 0x00000001) + // Power word: shield + if (removeMode.HasFlag(AuraRemoveFlags::ByEnemySpell) && GetSpellInfo()->SpellFamilyFlags[0] & 0x00000001) + { + // Rapture + if (Aura const* aura = caster->GetAuraOfRankedSpell(47535)) { - // Rapture - if (Aura const* aura = caster->GetAuraOfRankedSpell(47535)) + // check cooldown + if (caster->GetTypeId() == TYPEID_PLAYER) { - // check cooldown - if (caster->GetTypeId() == TYPEID_PLAYER) + if (caster->GetSpellHistory()->HasCooldown(aura->GetId())) { - if (caster->GetSpellHistory()->HasCooldown(aura->GetId())) - { - // This additional check is needed to add a minimal delay before cooldown in in effect - // to allow all bubbles broken by a single damage source proc mana return - if (caster->GetSpellHistory()->GetRemainingCooldown(aura->GetSpellInfo()) <= 11 * IN_MILLISECONDS) - break; - } - else // and add if needed - caster->GetSpellHistory()->AddCooldown(aura->GetId(), 0, std::chrono::seconds(12)); + // This additional check is needed to add a minimal delay before cooldown in in effect + // to allow all bubbles broken by a single damage source proc mana return + if (caster->GetSpellHistory()->GetRemainingCooldown(aura->GetSpellInfo()) <= 11 * IN_MILLISECONDS) + break; } + else // and add if needed + caster->GetSpellHistory()->AddCooldown(aura->GetId(), 0, std::chrono::seconds(12)); + } - // effect on caster - if (AuraEffect const* aurEff = aura->GetEffect(0)) - { - float multiplier = float(aurEff->GetAmount()); + // effect on caster + if (AuraEffect const* aurEff = aura->GetEffect(0)) + { + float multiplier = float(aurEff->GetAmount()); - CastSpellExtraArgs args(TRIGGERED_FULL_MASK); - args.SpellValueOverrides.AddBP0(CalculatePct(caster->GetMaxPower(POWER_MANA), multiplier)); - caster->CastSpell(caster, 47755, args); - } + CastSpellExtraArgs args(TRIGGERED_FULL_MASK); + args.SpellValueOverrides.AddBP0(CalculatePct(caster->GetMaxPower(POWER_MANA), multiplier)); + caster->CastSpell(caster, 47755, args); } } - break; - case SPELLFAMILY_ROGUE: - // Remove Vanish on stealth remove - if (GetId() == 1784) - target->RemoveAurasWithFamily(SPELLFAMILY_ROGUE, 0x0000800, 0, 0, target->GetGUID()); - break; - case SPELLFAMILY_PALADIN: - // Remove the immunity shield marker on Forbearance removal if AW marker is not present - if (GetId() == 25771 && target->HasAura(61988) && !target->HasAura(61987)) - target->RemoveAura(61988); - break; - case SPELLFAMILY_DEATHKNIGHT: - // Blood of the North - // Reaping - // Death Rune Mastery - if (GetSpellInfo()->SpellIconID == 3041 || GetSpellInfo()->SpellIconID == 22 || GetSpellInfo()->SpellIconID == 2622) - { - if (!GetEffect(0) || GetEffect(0)->GetAuraType() != SPELL_AURA_PERIODIC_DUMMY) - break; - if (target->GetTypeId() != TYPEID_PLAYER) - break; - if (target->ToPlayer()->getClass() != CLASS_DEATH_KNIGHT) - break; + } + break; + case SPELLFAMILY_ROGUE: + // Remove Vanish on stealth remove + if (GetId() == 1784) + target->RemoveAurasWithFamily(SPELLFAMILY_ROGUE, 0x0000800, 0, 0, target->GetGUID()); + break; + case SPELLFAMILY_PALADIN: + // Remove the immunity shield marker on Forbearance removal if AW marker is not present + if (GetId() == 25771 && target->HasAura(61988) && !target->HasAura(61987)) + target->RemoveAura(61988); + break; + case SPELLFAMILY_DEATHKNIGHT: + // Blood of the North + // Reaping + // Death Rune Mastery + if (GetSpellInfo()->SpellIconID == 3041 || GetSpellInfo()->SpellIconID == 22 || GetSpellInfo()->SpellIconID == 2622) + { + if (!GetEffect(0) || GetEffect(0)->GetAuraType() != SPELL_AURA_PERIODIC_DUMMY) + break; + if (target->GetTypeId() != TYPEID_PLAYER) + break; + if (target->ToPlayer()->getClass() != CLASS_DEATH_KNIGHT) + break; - // aura removed - remove death runes - target->ToPlayer()->RemoveRunesByAuraEffect(GetEffect(0)); - } - break; - case SPELLFAMILY_HUNTER: - // Glyph of Freezing Trap - if (GetSpellInfo()->SpellFamilyFlags[0] & 0x00000008) - if (caster && caster->HasAura(56845)) - target->CastSpell(target, 61394, true); - break; + // aura removed - remove death runes + target->ToPlayer()->RemoveRunesByAuraEffect(GetEffect(0)); + } + break; + case SPELLFAMILY_HUNTER: + // Glyph of Freezing Trap + if (GetSpellInfo()->SpellFamilyFlags[0] & 0x00000008) + if (caster && caster->HasAura(56845)) + target->CastSpell(target, 61394, true); + break; } } // mods at aura apply or remove switch (GetSpellInfo()->SpellFamilyName) { - case SPELLFAMILY_HUNTER: - switch (GetId()) + case SPELLFAMILY_HUNTER: + switch (GetId()) + { + case 19574: // Bestial Wrath + // The Beast Within cast on owner if talent present + if (Unit* owner = target->GetOwner()) { - case 19574: // Bestial Wrath - // The Beast Within cast on owner if talent present - if (Unit* owner = target->GetOwner()) - { - // Search talent - if (owner->HasAura(34692)) - { - if (apply) - owner->CastSpell(owner, 34471, GetEffect(EFFECT_0)); - else - owner->RemoveAurasDueToSpell(34471); - } - } - break; + // Search talent + if (owner->HasAura(34692)) + { + if (apply) + owner->CastSpell(owner, 34471, GetEffect(EFFECT_0)); + else + owner->RemoveAurasDueToSpell(34471); + } } break; - case SPELLFAMILY_PALADIN: - switch (GetId()) + } + break; + case SPELLFAMILY_PALADIN: + switch (GetId()) + { + case 31842: // Divine Favor + // Item - Paladin T10 Holy 2P Bonus + if (target->HasAura(70755)) { - case 31842: // Divine Favor - // Item - Paladin T10 Holy 2P Bonus - if (target->HasAura(70755)) - { - if (apply) - target->CastSpell(target, 71166, true); - else - target->RemoveAurasDueToSpell(71166); - } - break; + if (apply) + target->CastSpell(target, 71166, true); + else + target->RemoveAurasDueToSpell(71166); } break; + } + break; } } @@ -1569,24 +1624,23 @@ bool Aura::CanStackWith(Aura const* existingAura) const return sWorld->getBoolConfig(CONFIG_ALLOW_TRACK_BOTH_RESOURCES); // check spell specific stack rules - if (m_spellInfo->IsAuraExclusiveBySpecificWith(existingSpellInfo) - || (sameCaster && m_spellInfo->IsAuraExclusiveBySpecificPerCasterWith(existingSpellInfo))) + if (m_spellInfo->IsAuraExclusiveBySpecificWith(existingSpellInfo) || (sameCaster && m_spellInfo->IsAuraExclusiveBySpecificPerCasterWith(existingSpellInfo))) return false; // check spell group stack rules switch (sSpellMgr->CheckSpellGroupStackRules(m_spellInfo, existingSpellInfo)) { - case SPELL_GROUP_STACK_RULE_EXCLUSIVE: - case SPELL_GROUP_STACK_RULE_EXCLUSIVE_HIGHEST: // if it reaches this point, existing aura is lower/equal + case SPELL_GROUP_STACK_RULE_EXCLUSIVE: + case SPELL_GROUP_STACK_RULE_EXCLUSIVE_HIGHEST: // if it reaches this point, existing aura is lower/equal + return false; + case SPELL_GROUP_STACK_RULE_EXCLUSIVE_FROM_SAME_CASTER: + if (sameCaster) return false; - case SPELL_GROUP_STACK_RULE_EXCLUSIVE_FROM_SAME_CASTER: - if (sameCaster) - return false; - break; - case SPELL_GROUP_STACK_RULE_DEFAULT: - case SPELL_GROUP_STACK_RULE_EXCLUSIVE_SAME_EFFECT: - default: - break; + break; + case SPELL_GROUP_STACK_RULE_DEFAULT: + case SPELL_GROUP_STACK_RULE_EXCLUSIVE_SAME_EFFECT: + default: + break; } if (m_spellInfo->SpellFamilyName != existingSpellInfo->SpellFamilyName) @@ -1606,24 +1660,24 @@ bool Aura::CanStackWith(Aura const* existingAura) const { switch (m_spellInfo->Effects[i].ApplyAuraName) { - // DOT or HOT from different casters will stack - case SPELL_AURA_PERIODIC_DAMAGE: - case SPELL_AURA_PERIODIC_DUMMY: - case SPELL_AURA_PERIODIC_HEAL: - case SPELL_AURA_PERIODIC_TRIGGER_SPELL: - case SPELL_AURA_PERIODIC_ENERGIZE: - case SPELL_AURA_PERIODIC_MANA_LEECH: - case SPELL_AURA_PERIODIC_LEECH: - case SPELL_AURA_POWER_BURN: - case SPELL_AURA_OBS_MOD_POWER: - case SPELL_AURA_OBS_MOD_HEALTH: - case SPELL_AURA_PERIODIC_TRIGGER_SPELL_WITH_VALUE: - // periodic auras which target areas are not allowed to stack this way (replenishment for example) - if (m_spellInfo->Effects[i].IsTargetingArea() || existingSpellInfo->Effects[i].IsTargetingArea()) - break; - return true; - default: + // DOT or HOT from different casters will stack + case SPELL_AURA_PERIODIC_DAMAGE: + case SPELL_AURA_PERIODIC_DUMMY: + case SPELL_AURA_PERIODIC_HEAL: + case SPELL_AURA_PERIODIC_TRIGGER_SPELL: + case SPELL_AURA_PERIODIC_ENERGIZE: + case SPELL_AURA_PERIODIC_MANA_LEECH: + case SPELL_AURA_PERIODIC_LEECH: + case SPELL_AURA_POWER_BURN: + case SPELL_AURA_OBS_MOD_POWER: + case SPELL_AURA_OBS_MOD_HEALTH: + case SPELL_AURA_PERIODIC_TRIGGER_SPELL_WITH_VALUE: + // periodic auras which target areas are not allowed to stack this way (replenishment for example) + if (m_spellInfo->Effects[i].IsTargetingArea() || existingSpellInfo->Effects[i].IsTargetingArea()) break; + return true; + default: + break; } } } @@ -1634,11 +1688,11 @@ bool Aura::CanStackWith(Aura const* existingAura) const if (GetOwner()->ToUnit()) veh = GetOwner()->ToUnit()->GetVehicleKit(); - if (!veh) // We should probably just let it stack. Vehicle system will prevent undefined behaviour later + if (!veh) // We should probably just let it stack. Vehicle system will prevent undefined behaviour later return true; if (!veh->GetAvailableSeatCount()) - return false; // No empty seat available + return false; // No empty seat available return true; // Empty seat available (skip rest) } @@ -1684,7 +1738,8 @@ void Aura::PrepareProcToTrigger(AuraApplication* aurApp, ProcEventInfo& eventInf ASSERT(procEntry); // take one charge, aura expiration will be handled in Aura::TriggerProcOnEvent (if needed) - if (!(procEntry->AttributesMask & PROC_ATTR_USE_STACKS_FOR_CHARGES)&& IsUsingCharges() && (!eventInfo.GetSpellInfo() || !eventInfo.GetSpellInfo()->HasAttribute(SPELL_ATTR6_DONT_CONSUME_PROC_CHARGES))) + if (!(procEntry->AttributesMask & PROC_ATTR_USE_STACKS_FOR_CHARGES) && IsUsingCharges() && + (!eventInfo.GetSpellInfo() || !eventInfo.GetSpellInfo()->HasAttribute(SPELL_ATTR6_DONT_CONSUME_PROC_CHARGES))) { --m_procCharges; SetNeedClientUpdateForTargets(); @@ -1787,15 +1842,15 @@ uint8 Aura::GetProcEffectMask(AuraApplication* aurApp, ProcEventInfo& eventInfo, { switch (damageInfo->GetAttackType()) { - case BASE_ATTACK: - item = target->ToPlayer()->GetUseableItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND); - break; - case OFF_ATTACK: - item = target->ToPlayer()->GetUseableItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND); - break; - default: - item = target->ToPlayer()->GetUseableItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_RANGED); - break; + case BASE_ATTACK: + item = target->ToPlayer()->GetUseableItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND); + break; + case OFF_ATTACK: + item = target->ToPlayer()->GetUseableItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND); + break; + default: + item = target->ToPlayer()->GetUseableItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_RANGED); + break; } } } @@ -2032,7 +2087,7 @@ void Aura::CallScriptEffectUpdatePeriodicHandlers(AuraEffect* aurEff) } } -void Aura::CallScriptEffectCalcAmountHandlers(AuraEffect const* aurEff, int32 & amount, bool & canBeRecalculated) +void Aura::CallScriptEffectCalcAmountHandlers(AuraEffect const* aurEff, int32& amount, bool& canBeRecalculated) { for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr) { @@ -2046,7 +2101,7 @@ void Aura::CallScriptEffectCalcAmountHandlers(AuraEffect const* aurEff, int32 & } } -void Aura::CallScriptEffectCalcPeriodicHandlers(AuraEffect const* aurEff, bool & isPeriodic, int32 & amplitude) +void Aura::CallScriptEffectCalcPeriodicHandlers(AuraEffect const* aurEff, bool& isPeriodic, int32& amplitude) { for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr) { @@ -2060,7 +2115,7 @@ void Aura::CallScriptEffectCalcPeriodicHandlers(AuraEffect const* aurEff, bool & } } -void Aura::CallScriptEffectCalcSpellModHandlers(AuraEffect const* aurEff, SpellModifier* & spellMod) +void Aura::CallScriptEffectCalcSpellModHandlers(AuraEffect const* aurEff, SpellModifier*& spellMod) { for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr) { @@ -2074,7 +2129,7 @@ void Aura::CallScriptEffectCalcSpellModHandlers(AuraEffect const* aurEff, SpellM } } -void Aura::CallScriptEffectAbsorbHandlers(AuraEffect* aurEff, AuraApplication const* aurApp, DamageInfo & dmgInfo, uint32 & absorbAmount, bool& defaultPrevented) +void Aura::CallScriptEffectAbsorbHandlers(AuraEffect* aurEff, AuraApplication const* aurApp, DamageInfo& dmgInfo, uint32& absorbAmount, bool& defaultPrevented) { for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr) { @@ -2092,7 +2147,7 @@ void Aura::CallScriptEffectAbsorbHandlers(AuraEffect* aurEff, AuraApplication co } } -void Aura::CallScriptEffectAfterAbsorbHandlers(AuraEffect* aurEff, AuraApplication const* aurApp, DamageInfo & dmgInfo, uint32 & absorbAmount) +void Aura::CallScriptEffectAfterAbsorbHandlers(AuraEffect* aurEff, AuraApplication const* aurApp, DamageInfo& dmgInfo, uint32& absorbAmount) { for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr) { @@ -2106,7 +2161,7 @@ void Aura::CallScriptEffectAfterAbsorbHandlers(AuraEffect* aurEff, AuraApplicati } } -void Aura::CallScriptEffectManaShieldHandlers(AuraEffect* aurEff, AuraApplication const* aurApp, DamageInfo & dmgInfo, uint32 & absorbAmount, bool & /*defaultPrevented*/) +void Aura::CallScriptEffectManaShieldHandlers(AuraEffect* aurEff, AuraApplication const* aurApp, DamageInfo& dmgInfo, uint32& absorbAmount, bool& /*defaultPrevented*/) { for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr) { @@ -2120,7 +2175,7 @@ void Aura::CallScriptEffectManaShieldHandlers(AuraEffect* aurEff, AuraApplicatio } } -void Aura::CallScriptEffectAfterManaShieldHandlers(AuraEffect* aurEff, AuraApplication const* aurApp, DamageInfo & dmgInfo, uint32 & absorbAmount) +void Aura::CallScriptEffectAfterManaShieldHandlers(AuraEffect* aurEff, AuraApplication const* aurApp, DamageInfo& dmgInfo, uint32& absorbAmount) { for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr) { @@ -2134,7 +2189,7 @@ void Aura::CallScriptEffectAfterManaShieldHandlers(AuraEffect* aurEff, AuraAppli } } -void Aura::CallScriptEffectSplitHandlers(AuraEffect* aurEff, AuraApplication const* aurApp, DamageInfo & dmgInfo, uint32 & splitAmount) +void Aura::CallScriptEffectSplitHandlers(AuraEffect* aurEff, AuraApplication const* aurApp, DamageInfo& dmgInfo, uint32& splitAmount) { for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr) { @@ -2263,7 +2318,7 @@ void Aura::CallScriptAfterEffectProcHandlers(AuraEffect const* aurEff, AuraAppli } } -UnitAura::UnitAura(SpellInfo const* spellproto, uint8 effMask, WorldObject* owner, Unit* caster, int32 *baseAmount, Item* castItem, ObjectGuid casterGUID) +UnitAura::UnitAura(SpellInfo const* spellproto, uint8 effMask, WorldObject* owner, Unit* caster, int32* baseAmount, Item* castItem, ObjectGuid casterGUID) : Aura(spellproto, owner, caster, castItem, casterGUID) { m_AuraDRGroup = DIMINISHING_NONE; @@ -2272,7 +2327,7 @@ UnitAura::UnitAura(SpellInfo const* spellproto, uint8 effMask, WorldObject* owne GetUnitOwner()->_AddAura(this, caster); } -void UnitAura::_ApplyForTarget(Unit* target, Unit* caster, AuraApplication * aurApp) +void UnitAura::_ApplyForTarget(Unit* target, Unit* caster, AuraApplication* aurApp) { Aura::_ApplyForTarget(target, caster, aurApp); @@ -2281,7 +2336,7 @@ void UnitAura::_ApplyForTarget(Unit* target, Unit* caster, AuraApplication * aur target->ApplyDiminishingAura(group, true); } -void UnitAura::_UnapplyForTarget(Unit* target, Unit* caster, AuraApplication * aurApp) +void UnitAura::_UnapplyForTarget(Unit* target, Unit* caster, AuraApplication* aurApp) { Aura::_UnapplyForTarget(target, caster, aurApp); @@ -2330,30 +2385,30 @@ void UnitAura::FillTargetMap(std::unordered_map& targets, Unit* ca SpellTargetCheckTypes selectionType = TARGET_CHECK_DEFAULT; switch (GetSpellInfo()->Effects[effIndex].Effect) { - case SPELL_EFFECT_APPLY_AREA_AURA_PARTY: - selectionType = TARGET_CHECK_PARTY; - break; - case SPELL_EFFECT_APPLY_AREA_AURA_RAID: - selectionType = TARGET_CHECK_RAID; - break; - case SPELL_EFFECT_APPLY_AREA_AURA_FRIEND: - selectionType = TARGET_CHECK_ALLY; - break; - case SPELL_EFFECT_APPLY_AREA_AURA_ENEMY: - selectionType = TARGET_CHECK_ENEMY; - break; - case SPELL_EFFECT_APPLY_AREA_AURA_PET: - if (!condList || sConditionMgr->IsObjectMeetToConditions(GetUnitOwner(), ref, *condList)) - units.push_back(GetUnitOwner()); - [[fallthrough]]; - case SPELL_EFFECT_APPLY_AREA_AURA_OWNER: - { - if (Unit* owner = GetUnitOwner()->GetCharmerOrOwner()) - if (GetUnitOwner()->IsWithinDistInMap(owner, radius)) - if (!condList || sConditionMgr->IsObjectMeetToConditions(owner, ref, *condList)) - units.push_back(owner); - break; - } + case SPELL_EFFECT_APPLY_AREA_AURA_PARTY: + selectionType = TARGET_CHECK_PARTY; + break; + case SPELL_EFFECT_APPLY_AREA_AURA_RAID: + selectionType = TARGET_CHECK_RAID; + break; + case SPELL_EFFECT_APPLY_AREA_AURA_FRIEND: + selectionType = TARGET_CHECK_ALLY; + break; + case SPELL_EFFECT_APPLY_AREA_AURA_ENEMY: + selectionType = TARGET_CHECK_ENEMY; + break; + case SPELL_EFFECT_APPLY_AREA_AURA_PET: + if (!condList || sConditionMgr->IsObjectMeetToConditions(GetUnitOwner(), ref, *condList)) + units.push_back(GetUnitOwner()); + [[fallthrough]]; + case SPELL_EFFECT_APPLY_AREA_AURA_OWNER: + { + if (Unit* owner = GetUnitOwner()->GetCharmerOrOwner()) + if (GetUnitOwner()->IsWithinDistInMap(owner, radius)) + if (!condList || sConditionMgr->IsObjectMeetToConditions(owner, ref, *condList)) + units.push_back(owner); + break; + } } if (selectionType != TARGET_CHECK_DEFAULT) @@ -2375,7 +2430,7 @@ void UnitAura::FillTargetMap(std::unordered_map& targets, Unit* ca } } -DynObjAura::DynObjAura(SpellInfo const* spellproto, uint8 effMask, WorldObject* owner, Unit* caster, int32 *baseAmount, Item* castItem, ObjectGuid casterGUID) +DynObjAura::DynObjAura(SpellInfo const* spellproto, uint8 effMask, WorldObject* owner, Unit* caster, int32* baseAmount, Item* castItem, ObjectGuid casterGUID) : Aura(spellproto, owner, caster, castItem, casterGUID) { LoadScripts(); @@ -2411,10 +2466,10 @@ void DynObjAura::FillTargetMap(std::unordered_map& targets, Unit* continue; std::deque units; - if (GetSpellInfo()->Effects[effIndex].TargetB.GetTarget() == TARGET_DEST_DYNOBJ_ALLY - || GetSpellInfo()->Effects[effIndex].TargetB.GetTarget() == TARGET_UNIT_DEST_AREA_ALLY) + if (GetSpellInfo()->Effects[effIndex].TargetB.GetTarget() == TARGET_DEST_DYNOBJ_ALLY || GetSpellInfo()->Effects[effIndex].TargetB.GetTarget() == TARGET_UNIT_DEST_AREA_ALLY) { - Firelands::AnyFriendlyUnitInObjectRangeCheck u_check(GetDynobjOwner(), dynObjOwnerCaster, radius, m_spellInfo->HasAttribute(SPELL_ATTR3_ONLY_TARGET_PLAYERS), m_spellInfo->HasAttribute(SPELL_ATTR5_DONT_TARGET_PLAYERS)); + Firelands::AnyFriendlyUnitInObjectRangeCheck u_check( + GetDynobjOwner(), dynObjOwnerCaster, radius, m_spellInfo->HasAttribute(SPELL_ATTR3_ONLY_TARGET_PLAYERS), m_spellInfo->HasAttribute(SPELL_ATTR5_DONT_TARGET_PLAYERS)); Firelands::UnitListSearcher searcher(GetDynobjOwner(), units, u_check); Cell::VisitAllObjects(GetDynobjOwner(), searcher, radius); } diff --git a/src/server/game/Spells/Auras/SpellAuras.h b/src/server/game/Spells/Auras/SpellAuras.h index ea1ca312..d6a61d3c 100644 --- a/src/server/game/Spells/Auras/SpellAuras.h +++ b/src/server/game/Spells/Auras/SpellAuras.h @@ -132,6 +132,15 @@ class FC_GAME_API AuraApplication void ClientUpdate(bool remove = false); }; +// Caches some information about caster (because it may no longer exist) +struct CasterInfo +{ + float CritChance = 0.f; + float BonusDonePct = 0.f; + uint8 Level = 0; + bool ApplyResilience = false; +}; + class FC_GAME_API Aura { friend Aura* Unit::_TryStackingOrRefreshingExistingAura(SpellInfo const* newAura, uint8 effMask, Unit* caster, int32* baseAmount, Item* castItem, ObjectGuid casterGUID); @@ -147,6 +156,7 @@ class FC_GAME_API Aura static Aura* Create(SpellInfo const* spellproto, uint8 effMask, WorldObject* owner, Unit* caster, int32* baseAmount, Item* castItem, ObjectGuid casterGUID); explicit Aura(SpellInfo const* spellproto, WorldObject* owner, Unit* caster, Item* castItem, ObjectGuid casterGUID); void _InitEffects(uint8 effMask, Unit* caster, int32* baseAmount); + void SaveCasterInfo(Unit* caster); virtual ~Aura(); SpellInfo const* GetSpellInfo() const @@ -269,9 +279,33 @@ class FC_GAME_API Aura void SetStackAmount(uint8 num); bool ModStackAmount(int32 num, AuraRemoveFlags removeMode = AuraRemoveFlags::ByDefault); + bool CanApplyResilience() const + { + return _casterInfo.ApplyResilience; + } + void SetCanApplyResilience(bool val) + { + _casterInfo.ApplyResilience = val; + } uint8 GetCasterLevel() const { - return m_casterLevel; + return _casterInfo.Level; + } + float GetCritChance() const + { + return _casterInfo.CritChance; + } + void SetCritChance(float val) + { + _casterInfo.CritChance = val; + } + float GetDonePct() const + { + return _casterInfo.BonusDonePct; + } + void SetDonePct(float val) + { + _casterInfo.BonusDonePct = val; } bool HasMoreThanOneEffectForType(AuraType auraType) const; @@ -303,9 +337,11 @@ class FC_GAME_API Aura void UnregisterLimitedTarget(); int32 CalcDispelChance(Unit const* auraTarget, bool offensive) const; - void SetLoadedState(int32 maxduration, int32 duration, int32 charges, uint8 stackamount, uint8 recalculateMask, int32* amount); + void SetLoadedState(int32 maxduration, int32 duration, int32 charges, uint8 stackamount, uint8 recalculateMask, float critChance, bool applyResilience, int32* amount); // helpers for aura effects + bool CanPeriodicTickCrit(Unit const* caster) const; + float CalcPeriodicCritChance(Unit const* caster) const; bool HasEffect(uint8 effIndex) const { return GetEffect(effIndex) != nullptr; @@ -428,9 +464,9 @@ class FC_GAME_API Aura int32 m_timeCla; // Timer for power per sec calcultion int32 m_updateTargetMapInterval; // Timer for UpdateTargetMapOfEffect - uint8 const m_casterLevel; // Aura level (store caster level for correct show level dep amount) - uint8 m_procCharges; // Aura charges (0 for infinite) - uint8 m_stackAmount; // Aura stack amount + CasterInfo _casterInfo; + uint8 m_procCharges; // Aura charges (0 for infinite) + uint8 m_stackAmount; // Aura stack amount AuraEffect* m_effects[3]; ApplicationMap m_applications; diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index b36620ae..d7f83a35 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -2146,7 +2146,7 @@ class ProcReflectDelayed : public BasicEvent uint32 const spellPhaseMask = PROC_SPELL_PHASE_NONE; uint32 const hitMask = PROC_HIT_REFLECT; - caster->ProcSkillsAndAuras(_victim, typeMaskActor, typeMaskActionTarget, spellTypeMask, spellPhaseMask, hitMask, nullptr, nullptr, nullptr); + Unit::ProcSkillsAndAuras(caster, _victim, typeMaskActor, typeMaskActionTarget, spellTypeMask, spellPhaseMask, hitMask, nullptr, nullptr, nullptr); return true; } @@ -2661,7 +2661,7 @@ void Spell::DoAllEffectOnTarget(TargetInfo* target) // Do triggers for unit if (canTriggerCasterProcs || canTriggerTargetProcs) - caster->ProcSkillsAndAuras(unitTarget, procAttacker, procVictim, PROC_SPELL_TYPE_HEAL, PROC_SPELL_PHASE_HIT, hitMask, this, nullptr, &healInfo); + Unit::ProcSkillsAndAuras(caster, unitTarget, procAttacker, procVictim, PROC_SPELL_TYPE_HEAL, PROC_SPELL_PHASE_HIT, hitMask, this, nullptr, &healInfo); } // Do damage and triggers else if (m_damage > 0) @@ -2681,7 +2681,7 @@ void Spell::DoAllEffectOnTarget(TargetInfo* target) { // Add bonuses and fill damageInfo struct caster->CalculateSpellDamageTaken(&damageInfo, m_damage, m_spellInfo, m_attackType, target->crit); - caster->DealDamageMods(damageInfo.target, damageInfo.damage, &damageInfo.absorb); + Unit::DealDamageMods(damageInfo.target, damageInfo.damage, &damageInfo.absorb); if (Creature* target = damageInfo.target->ToCreature()) if (caster->IsCreature() && !caster->IsCharmedOwnedByPlayerOrPlayer()) @@ -2703,12 +2703,12 @@ void Spell::DoAllEffectOnTarget(TargetInfo* target) if (canTriggerCasterProcs || canTriggerTargetProcs) { DamageInfo spellDamageInfo(damageInfo, SPELL_DIRECT_DAMAGE, m_attackType, hitMask); - caster->ProcSkillsAndAuras(unitTarget, procAttacker, procVictim, PROC_SPELL_TYPE_DAMAGE, PROC_SPELL_PHASE_HIT, hitMask, this, &spellDamageInfo, nullptr); + Unit::ProcSkillsAndAuras(caster, unitTarget, procAttacker, procVictim, PROC_SPELL_TYPE_DAMAGE, PROC_SPELL_PHASE_HIT, hitMask, this, &spellDamageInfo, nullptr); // Pets and Guardians units should trigger procs for their owner as well if (caster->IsSummon() && (caster->IsGuardian() || caster->IsPet())) if (Unit* summoner = caster->ToTempSummon()->GetSummoner()) - summoner->ProcSkillsAndAuras(unitTarget, procAttacker, procVictim, PROC_SPELL_TYPE_DAMAGE, PROC_SPELL_PHASE_HIT, hitMask, this, &spellDamageInfo, nullptr); + Unit::ProcSkillsAndAuras(summoner, unitTarget, procAttacker, procVictim, PROC_SPELL_TYPE_DAMAGE, PROC_SPELL_PHASE_HIT, hitMask, this, &spellDamageInfo, nullptr); if (caster->GetTypeId() == TYPEID_PLAYER && !m_spellInfo->HasAttribute(SPELL_ATTR0_CANCELS_AUTO_ATTACK_COMBAT) && !m_spellInfo->HasAttribute(SPELL_ATTR4_CANT_TRIGGER_ITEM_SPELLS) && (m_spellInfo->DmgClass == SPELL_DAMAGE_CLASS_MELEE || m_spellInfo->DmgClass == SPELL_DAMAGE_CLASS_RANGED)) @@ -2725,7 +2725,7 @@ void Spell::DoAllEffectOnTarget(TargetInfo* target) if (canTriggerCasterProcs || canTriggerTargetProcs) { DamageInfo spellNoDamageInfo(damageInfo, NODAMAGE, m_attackType, hitMask); - caster->ProcSkillsAndAuras(unitTarget, procAttacker, procVictim, PROC_SPELL_TYPE_NO_DMG_HEAL, PROC_SPELL_PHASE_HIT, hitMask, this, &spellNoDamageInfo, nullptr); + Unit::ProcSkillsAndAuras(caster, unitTarget, procAttacker, procVictim, PROC_SPELL_TYPE_NO_DMG_HEAL, PROC_SPELL_PHASE_HIT, hitMask, this, &spellNoDamageInfo, nullptr); if (caster->GetTypeId() == TYPEID_PLAYER && !m_spellInfo->HasAttribute(SPELL_ATTR0_CANCELS_AUTO_ATTACK_COMBAT) && !m_spellInfo->HasAttribute(SPELL_ATTR4_CANT_TRIGGER_ITEM_SPELLS) && (m_spellInfo->DmgClass == SPELL_DAMAGE_CLASS_MELEE || m_spellInfo->DmgClass == SPELL_DAMAGE_CLASS_RANGED)) @@ -3700,7 +3700,7 @@ void Spell::_cast(bool skipCheck) m_originalCaster->RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags::ActionDelayed); m_originalCaster->RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags::ActionDelayed); - m_originalCaster->ProcSkillsAndAuras(nullptr, procAttacker, PROC_FLAG_NONE, PROC_SPELL_TYPE_MASK_ALL, PROC_SPELL_PHASE_CAST, hitMask, this, nullptr, nullptr); + Unit::ProcSkillsAndAuras(m_originalCaster, nullptr, procAttacker, PROC_FLAG_NONE, PROC_SPELL_TYPE_MASK_ALL, PROC_SPELL_PHASE_CAST, hitMask, this, nullptr, nullptr); // Call CreatureAI hook OnSuccessfulSpellCast if (Creature* caster = m_originalCaster->ToCreature()) @@ -3915,7 +3915,7 @@ void Spell::_handle_finish_phase() } } - m_originalCaster->ProcSkillsAndAuras(nullptr, procAttacker, PROC_FLAG_NONE, PROC_SPELL_TYPE_MASK_ALL, PROC_SPELL_PHASE_FINISH, m_hitMask, this, nullptr, nullptr); + Unit::ProcSkillsAndAuras(m_originalCaster, nullptr, procAttacker, PROC_FLAG_NONE, PROC_SPELL_TYPE_MASK_ALL, PROC_SPELL_PHASE_FINISH, m_hitMask, this, nullptr, nullptr); } void Spell::SendSpellCooldown() @@ -7840,9 +7840,7 @@ void Spell::DoAllEffectOnLaunchTarget(TargetInfo& targetInfo, float* multiplier) { if (m_spellInfo->Effects[i].IsTargetingArea() || m_spellInfo->Effects[i].IsAreaAuraEffect() || m_spellInfo->Effects[i].IsEffect(SPELL_EFFECT_PERSISTENT_AREA_AURA)) { - m_damage = int32(float(m_damage) * unit->GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_AOE_DAMAGE_AVOIDANCE, m_spellInfo->SchoolMask)); - if (m_caster->GetTypeId() != TYPEID_PLAYER) - m_damage = int32(float(m_damage) * unit->GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_CREATURE_AOE_DAMAGE_AVOIDANCE, m_spellInfo->SchoolMask)); + m_damage = unit->CalculateAOEAvoidance(m_damage, m_spellInfo->SchoolMask, m_caster); if (m_caster->GetTypeId() == TYPEID_PLAYER) { diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index 0bdb9aa7..52c6e9a7 100644 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -15,7 +15,6 @@ * with this program. If not, see . */ -#include "Spell.h" #include "AccountMgr.h" #include "AreaTrigger.h" #include "Battleground.h" @@ -26,10 +25,10 @@ #include "DatabaseEnv.h" #include "DynamicObject.h" #include "Formulas.h" +#include "GameClient.h" #include "GameEventSender.h" #include "GameObject.h" #include "GameObjectAI.h" -#include "GameClient.h" #include "GossipDef.h" #include "GridNotifiers.h" #include "Group.h" @@ -57,6 +56,7 @@ #include "SharedDefines.h" #include "SkillExtraItems.h" #include "SocialMgr.h" +#include "Spell.h" #include "SpellAuraEffects.h" #include "SpellAuras.h" #include "SpellHistory.h" @@ -71,191 +71,190 @@ #include "WorldPacket.h" #include "WorldSession.h" -pEffect SpellEffects[TOTAL_SPELL_EFFECTS]= -{ - &Spell::EffectNULL, // 0 - &Spell::EffectInstaKill, // 1 SPELL_EFFECT_INSTAKILL - &Spell::EffectSchoolDMG, // 2 SPELL_EFFECT_SCHOOL_DAMAGE - &Spell::EffectDummy, // 3 SPELL_EFFECT_DUMMY - &Spell::EffectUnused, // 4 SPELL_EFFECT_PORTAL_TELEPORT unused - &Spell::EffectTeleportUnits, // 5 SPELL_EFFECT_TELEPORT_UNITS - &Spell::EffectApplyAura, // 6 SPELL_EFFECT_APPLY_AURA - &Spell::EffectEnvironmentalDMG, // 7 SPELL_EFFECT_ENVIRONMENTAL_DAMAGE - &Spell::EffectPowerDrain, // 8 SPELL_EFFECT_POWER_DRAIN - &Spell::EffectHealthLeech, // 9 SPELL_EFFECT_HEALTH_LEECH - &Spell::EffectHeal, // 10 SPELL_EFFECT_HEAL - &Spell::EffectBind, // 11 SPELL_EFFECT_BIND - &Spell::EffectNULL, // 12 SPELL_EFFECT_PORTAL - &Spell::EffectUnused, // 13 SPELL_EFFECT_RITUAL_BASE unused - &Spell::EffectUnused, // 14 SPELL_EFFECT_RITUAL_SPECIALIZE unused - &Spell::EffectUnused, // 15 SPELL_EFFECT_RITUAL_ACTIVATE_PORTAL unused - &Spell::EffectQuestComplete, // 16 SPELL_EFFECT_QUEST_COMPLETE - &Spell::EffectWeaponDmg, // 17 SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL - &Spell::EffectResurrect, // 18 SPELL_EFFECT_RESURRECT - &Spell::EffectAddExtraAttacks, // 19 SPELL_EFFECT_ADD_EXTRA_ATTACKS - &Spell::EffectUnused, // 20 SPELL_EFFECT_DODGE one spell: Dodge - &Spell::EffectUnused, // 21 SPELL_EFFECT_EVADE one spell: Evade (DND) - &Spell::EffectParry, // 22 SPELL_EFFECT_PARRY - &Spell::EffectBlock, // 23 SPELL_EFFECT_BLOCK one spell: Block - &Spell::EffectCreateItem, // 24 SPELL_EFFECT_CREATE_ITEM - &Spell::EffectUnused, // 25 SPELL_EFFECT_WEAPON - &Spell::EffectUnused, // 26 SPELL_EFFECT_DEFENSE one spell: Defense - &Spell::EffectPersistentAA, // 27 SPELL_EFFECT_PERSISTENT_AREA_AURA - &Spell::EffectSummonType, // 28 SPELL_EFFECT_SUMMON - &Spell::EffectLeap, // 29 SPELL_EFFECT_LEAP - &Spell::EffectEnergize, // 30 SPELL_EFFECT_ENERGIZE - &Spell::EffectWeaponDmg, // 31 SPELL_EFFECT_WEAPON_PERCENT_DAMAGE - &Spell::EffectTriggerMissileSpell, // 32 SPELL_EFFECT_TRIGGER_MISSILE - &Spell::EffectOpenLock, // 33 SPELL_EFFECT_OPEN_LOCK - &Spell::EffectSummonChangeItem, // 34 SPELL_EFFECT_SUMMON_CHANGE_ITEM - &Spell::EffectApplyAreaAura, // 35 SPELL_EFFECT_APPLY_AREA_AURA_PARTY - &Spell::EffectLearnSpell, // 36 SPELL_EFFECT_LEARN_SPELL - &Spell::EffectUnused, // 37 SPELL_EFFECT_SPELL_DEFENSE one spell: SPELLDEFENSE (DND) - &Spell::EffectDispel, // 38 SPELL_EFFECT_DISPEL - &Spell::EffectUnused, // 39 SPELL_EFFECT_LANGUAGE - &Spell::EffectDualWield, // 40 SPELL_EFFECT_DUAL_WIELD - &Spell::EffectJump, // 41 SPELL_EFFECT_JUMP - &Spell::EffectJumpDest, // 42 SPELL_EFFECT_JUMP_DEST - &Spell::EffectTeleUnitsFaceCaster, // 43 SPELL_EFFECT_TELEPORT_UNITS_FACE_CASTER - &Spell::EffectLearnSkill, // 44 SPELL_EFFECT_SKILL_STEP - &Spell::EffectPlayMovie, // 45 SPELL_EFFECT_PLAY_MOVIE - &Spell::EffectUnused, // 46 SPELL_EFFECT_SPAWN clientside, unit appears as if it was just spawned - &Spell::EffectTradeSkill, // 47 SPELL_EFFECT_TRADE_SKILL - &Spell::EffectUnused, // 48 SPELL_EFFECT_STEALTH one spell: Base Stealth - &Spell::EffectUnused, // 49 SPELL_EFFECT_DETECT one spell: Detect - &Spell::EffectTransmitted, // 50 SPELL_EFFECT_TRANS_DOOR - &Spell::EffectUnused, // 51 SPELL_EFFECT_FORCE_CRITICAL_HIT unused - &Spell::EffectUnused, // 52 SPELL_EFFECT_GUARANTEE_HIT unused - &Spell::EffectEnchantItemPerm, // 53 SPELL_EFFECT_ENCHANT_ITEM - &Spell::EffectEnchantItemTmp, // 54 SPELL_EFFECT_ENCHANT_ITEM_TEMPORARY - &Spell::EffectTameCreature, // 55 SPELL_EFFECT_TAMECREATURE - &Spell::EffectSummonPet, // 56 SPELL_EFFECT_SUMMON_PET - &Spell::EffectLearnPetSpell, // 57 SPELL_EFFECT_LEARN_PET_SPELL - &Spell::EffectWeaponDmg, // 58 SPELL_EFFECT_WEAPON_DAMAGE - &Spell::EffectCreateRandomItem, // 59 SPELL_EFFECT_CREATE_RANDOM_ITEM create item base at spell specific loot - &Spell::EffectProficiency, // 60 SPELL_EFFECT_PROFICIENCY - &Spell::EffectSendEvent, // 61 SPELL_EFFECT_SEND_EVENT - &Spell::EffectPowerBurn, // 62 SPELL_EFFECT_POWER_BURN - &Spell::EffectThreat, // 63 SPELL_EFFECT_THREAT - &Spell::EffectTriggerSpell, // 64 SPELL_EFFECT_TRIGGER_SPELL - &Spell::EffectApplyAreaAura, // 65 SPELL_EFFECT_APPLY_AREA_AURA_RAID - &Spell::EffectRechargeManaGem, // 66 SPELL_EFFECT_CREATE_MANA_GEM (possibly recharge it, misc - is item ID) - &Spell::EffectHealMaxHealth, // 67 SPELL_EFFECT_HEAL_MAX_HEALTH - &Spell::EffectInterruptCast, // 68 SPELL_EFFECT_INTERRUPT_CAST - &Spell::EffectDistract, // 69 SPELL_EFFECT_DISTRACT - &Spell::EffectPull, // 70 SPELL_EFFECT_PULL one spell: Distract Move - &Spell::EffectPickPocket, // 71 SPELL_EFFECT_PICKPOCKET - &Spell::EffectAddFarsight, // 72 SPELL_EFFECT_ADD_FARSIGHT - &Spell::EffectUntrainTalents, // 73 SPELL_EFFECT_UNTRAIN_TALENTS - &Spell::EffectApplyGlyph, // 74 SPELL_EFFECT_APPLY_GLYPH - &Spell::EffectHealMechanical, // 75 SPELL_EFFECT_HEAL_MECHANICAL one spell: Mechanical Patch Kit - &Spell::EffectSummonObjectWild, // 76 SPELL_EFFECT_SUMMON_OBJECT_WILD - &Spell::EffectScriptEffect, // 77 SPELL_EFFECT_SCRIPT_EFFECT - &Spell::EffectUnused, // 78 SPELL_EFFECT_ATTACK - &Spell::EffectSanctuary, // 79 SPELL_EFFECT_SANCTUARY - &Spell::EffectAddComboPoints, // 80 SPELL_EFFECT_ADD_COMBO_POINTS - &Spell::EffectUnused, // 81 SPELL_EFFECT_CREATE_HOUSE one spell: Create House (TEST) - &Spell::EffectNULL, // 82 SPELL_EFFECT_BIND_SIGHT - &Spell::EffectDuel, // 83 SPELL_EFFECT_DUEL - &Spell::EffectStuck, // 84 SPELL_EFFECT_STUCK - &Spell::EffectSummonPlayer, // 85 SPELL_EFFECT_SUMMON_PLAYER - &Spell::EffectActivateObject, // 86 SPELL_EFFECT_ACTIVATE_OBJECT - &Spell::EffectGameObjectDamage, // 87 SPELL_EFFECT_GAMEOBJECT_DAMAGE - &Spell::EffectGameObjectRepair, // 88 SPELL_EFFECT_GAMEOBJECT_REPAIR - &Spell::EffectGameObjectSetDestructionState, // 89 SPELL_EFFECT_GAMEOBJECT_SET_DESTRUCTION_STATE - &Spell::EffectKillCreditPersonal, // 90 SPELL_EFFECT_KILL_CREDIT Kill credit but only for single person - &Spell::EffectUnused, // 91 SPELL_EFFECT_THREAT_ALL one spell: zzOLDBrainwash - &Spell::EffectEnchantHeldItem, // 92 SPELL_EFFECT_ENCHANT_HELD_ITEM - &Spell::EffectForceDeselect, // 93 SPELL_EFFECT_FORCE_DESELECT - &Spell::EffectSelfResurrect, // 94 SPELL_EFFECT_SELF_RESURRECT - &Spell::EffectSkinning, // 95 SPELL_EFFECT_SKINNING - &Spell::EffectCharge, // 96 SPELL_EFFECT_CHARGE - &Spell::EffectCastButtons, // 97 SPELL_EFFECT_CAST_BUTTON (totem bar since 3.2.2a) - &Spell::EffectKnockBack, // 98 SPELL_EFFECT_KNOCK_BACK - &Spell::EffectDisEnchant, // 99 SPELL_EFFECT_DISENCHANT - &Spell::EffectInebriate, //100 SPELL_EFFECT_INEBRIATE - &Spell::EffectFeedPet, //101 SPELL_EFFECT_FEED_PET - &Spell::EffectDismissPet, //102 SPELL_EFFECT_DISMISS_PET - &Spell::EffectReputation, //103 SPELL_EFFECT_REPUTATION - &Spell::EffectSummonObject, //104 SPELL_EFFECT_SUMMON_OBJECT_SLOT1 - &Spell::EffectSurvey, //105 SPELL_EFFECT_SUMMON_OBJECT_SLOT2 - &Spell::EffectSummonRaidMarker, //106 SPELL_EFFECT_SUMMON_OBJECT_SLOT3 - &Spell::EffectSummonObject, //107 SPELL_EFFECT_SUMMON_OBJECT_SLOT4 - &Spell::EffectDispelMechanic, //108 SPELL_EFFECT_DISPEL_MECHANIC - &Spell::EffectResurrectPet, //109 SPELL_EFFECT_RESURRECT_PET - &Spell::EffectDestroyAllTotems, //110 SPELL_EFFECT_DESTROY_ALL_TOTEMS - &Spell::EffectDurabilityDamage, //111 SPELL_EFFECT_DURABILITY_DAMAGE - &Spell::EffectUnused, //112 SPELL_EFFECT_112 - &Spell::EffectResurrectNew, //113 SPELL_EFFECT_RESURRECT_NEW - &Spell::EffectTaunt, //114 SPELL_EFFECT_ATTACK_ME - &Spell::EffectDurabilityDamagePCT, //115 SPELL_EFFECT_DURABILITY_DAMAGE_PCT - &Spell::EffectSkinPlayerCorpse, //116 SPELL_EFFECT_SKIN_PLAYER_CORPSE one spell: Remove Insignia, bg usage, required special corpse flags... - &Spell::EffectSpiritHeal, //117 SPELL_EFFECT_SPIRIT_HEAL one spell: Spirit Heal - &Spell::EffectSkill, //118 SPELL_EFFECT_SKILL professions and more - &Spell::EffectApplyAreaAura, //119 SPELL_EFFECT_APPLY_AREA_AURA_PET - &Spell::EffectUnused, //120 SPELL_EFFECT_TELEPORT_GRAVEYARD one spell: Graveyard Teleport Test - &Spell::EffectWeaponDmg, //121 SPELL_EFFECT_NORMALIZED_WEAPON_DMG - &Spell::EffectUnused, //122 SPELL_EFFECT_122 unused - &Spell::EffectSendTaxi, //123 SPELL_EFFECT_SEND_TAXI taxi/flight related (misc value is taxi path id) - &Spell::EffectPullTowards, //124 SPELL_EFFECT_PULL_TOWARDS - &Spell::EffectModifyThreatPercent, //125 SPELL_EFFECT_MODIFY_THREAT_PERCENT - &Spell::EffectStealBeneficialBuff, //126 SPELL_EFFECT_STEAL_BENEFICIAL_BUFF spell steal effect? - &Spell::EffectProspecting, //127 SPELL_EFFECT_PROSPECTING Prospecting spell - &Spell::EffectApplyAreaAura, //128 SPELL_EFFECT_APPLY_AREA_AURA_FRIEND - &Spell::EffectApplyAreaAura, //129 SPELL_EFFECT_APPLY_AREA_AURA_ENEMY - &Spell::EffectRedirectThreat, //130 SPELL_EFFECT_REDIRECT_THREAT - &Spell::EffectPlaySound, //131 SPELL_EFFECT_PLAY_SOUND sound id in misc value (SoundEntries.dbc) - &Spell::EffectPlayMusic, //132 SPELL_EFFECT_PLAY_MUSIC sound id in misc value (SoundEntries.dbc) - &Spell::EffectUnlearnSpecialization, //133 SPELL_EFFECT_UNLEARN_SPECIALIZATION unlearn profession specialization - &Spell::EffectKillCredit, //134 SPELL_EFFECT_KILL_CREDIT misc value is creature entry - &Spell::EffectNULL, //135 SPELL_EFFECT_CALL_PET - &Spell::EffectHealPct, //136 SPELL_EFFECT_HEAL_PCT - &Spell::EffectEnergizePct, //137 SPELL_EFFECT_ENERGIZE_PCT - &Spell::EffectLeapBack, //138 SPELL_EFFECT_LEAP_BACK Leap back - &Spell::EffectQuestClear, //139 SPELL_EFFECT_CLEAR_QUEST Reset quest status (miscValue - quest ID) - &Spell::EffectForceCast, //140 SPELL_EFFECT_FORCE_CAST - &Spell::EffectForceCast, //141 SPELL_EFFECT_FORCE_CAST_WITH_VALUE - &Spell::EffectTriggerSpell, //142 SPELL_EFFECT_TRIGGER_SPELL_WITH_VALUE - &Spell::EffectApplyAreaAura, //143 SPELL_EFFECT_APPLY_AREA_AURA_OWNER - &Spell::EffectKnockBack, //144 SPELL_EFFECT_KNOCK_BACK_DEST - &Spell::EffectPullTowardsDest, //145 SPELL_EFFECT_PULL_TOWARDS_DEST Black Hole Effect - &Spell::EffectActivateRune, //146 SPELL_EFFECT_ACTIVATE_RUNE - &Spell::EffectQuestFail, //147 SPELL_EFFECT_QUEST_FAIL quest fail - &Spell::EffectTriggerMissileSpell, //148 SPELL_EFFECT_TRIGGER_MISSILE_SPELL_WITH_VALUE - &Spell::EffectChargeDest, //149 SPELL_EFFECT_CHARGE_DEST - &Spell::EffectQuestStart, //150 SPELL_EFFECT_QUEST_START - &Spell::EffectTriggerRitualOfSummoning, //151 SPELL_EFFECT_TRIGGER_SPELL_2 - &Spell::EffectSummonRaFFriend, //152 SPELL_EFFECT_SUMMON_RAF_FRIEND summon Refer-a-Friend - &Spell::EffectCreateTamedPet, //153 SPELL_EFFECT_CREATE_TAMED_PET misc value is creature entry - &Spell::EffectDiscoverTaxi, //154 SPELL_EFFECT_DISCOVER_TAXI - &Spell::EffectTitanGrip, //155 SPELL_EFFECT_TITAN_GRIP Allows you to equip two-handed axes, maces and swords in one hand, but you attack $49152s1% slower than normal. - &Spell::EffectEnchantItemPrismatic, //156 SPELL_EFFECT_ENCHANT_ITEM_PRISMATIC - &Spell::EffectCreateItem2, //157 SPELL_EFFECT_CREATE_ITEM_2 create item or create item template and replace by some randon spell loot item - &Spell::EffectMilling, //158 SPELL_EFFECT_MILLING milling - &Spell::EffectRenamePet, //159 SPELL_EFFECT_ALLOW_RENAME_PET allow rename pet once again - &Spell::EffectForceCast, //160 SPELL_EFFECT_FORCE_CAST_2 - &Spell::EffectSpecCount, //161 SPELL_EFFECT_TALENT_SPEC_COUNT second talent spec (learn/revert) - &Spell::EffectActivateSpec, //162 SPELL_EFFECT_TALENT_SPEC_SELECT activate primary/secondary spec - &Spell::EffectUnused, //163 SPELL_EFFECT_163 unused - &Spell::EffectRemoveAura, //164 SPELL_EFFECT_REMOVE_AURA - &Spell::EffectDamageFromMaxHealthPCT, //165 SPELL_EFFECT_DAMAGE_FROM_MAX_HEALTH_PCT - &Spell::EffectGiveCurrency, //166 SPELL_EFFECT_GIVE_CURRENCY - &Spell::EffectUpdatePlayerPhase, //167 SPELL_EFFECT_UPDATE_PLAYER_PHASE - &Spell::EffectNULL, //168 SPELL_EFFECT_ALLOW_CONTROL_PET - &Spell::EffectDestroyItem, //169 SPELL_EFFECT_DESTROY_ITEM - &Spell::EffectUpdateZoneAurasAndPhases, //170 SPELL_EFFECT_UPDATE_ZONE_AURAS_AND_PHASES - &Spell::EffectSummonPersonalGameObject, //171 SPELL_EFFECT_SUMMON_PERSONAL_GAMEOBJECT - &Spell::EffectResurrectWithAura, //172 SPELL_EFFECT_RESURRECT_WITH_AURA - &Spell::EffectUnlockGuildVaultTab, //173 SPELL_EFFECT_UNLOCK_GUILD_VAULT_TAB - &Spell::EffectApplyAura, //174 SPELL_EFFECT_APPLY_AURA_2 - &Spell::EffectUnused, //175 SPELL_EFFECT_175 unused - &Spell::EffectSanctuary, //176 SPELL_EFFECT_SANCTUARY_2 - &Spell::EffectDespawnDynamicObject, //177 SPELL_EFFECT_DESPAWN_DYNOBJECT - &Spell::EffectUnused, //178 SPELL_EFFECT_178 unused - &Spell::EffectCreateAreaTrigger, //179 SPELL_EFFECT_CREATE_AREATRIGGER - &Spell::EffectUnused, //180 SPELL_EFFECT_UPDATE_AREATRIGGER - &Spell::EffectUnused, //181 SPELL_EFFECT_REMOVE_TALENT - &Spell::EffectNULL, //182 SPELL_EFFECT_DESPAWN_AREATRIGGER +pEffect SpellEffects[TOTAL_SPELL_EFFECTS] = { + &Spell::EffectNULL, // 0 + &Spell::EffectInstaKill, // 1 SPELL_EFFECT_INSTAKILL + &Spell::EffectSchoolDMG, // 2 SPELL_EFFECT_SCHOOL_DAMAGE + &Spell::EffectDummy, // 3 SPELL_EFFECT_DUMMY + &Spell::EffectUnused, // 4 SPELL_EFFECT_PORTAL_TELEPORT unused + &Spell::EffectTeleportUnits, // 5 SPELL_EFFECT_TELEPORT_UNITS + &Spell::EffectApplyAura, // 6 SPELL_EFFECT_APPLY_AURA + &Spell::EffectEnvironmentalDMG, // 7 SPELL_EFFECT_ENVIRONMENTAL_DAMAGE + &Spell::EffectPowerDrain, // 8 SPELL_EFFECT_POWER_DRAIN + &Spell::EffectHealthLeech, // 9 SPELL_EFFECT_HEALTH_LEECH + &Spell::EffectHeal, // 10 SPELL_EFFECT_HEAL + &Spell::EffectBind, // 11 SPELL_EFFECT_BIND + &Spell::EffectNULL, // 12 SPELL_EFFECT_PORTAL + &Spell::EffectUnused, // 13 SPELL_EFFECT_RITUAL_BASE unused + &Spell::EffectUnused, // 14 SPELL_EFFECT_RITUAL_SPECIALIZE unused + &Spell::EffectUnused, // 15 SPELL_EFFECT_RITUAL_ACTIVATE_PORTAL unused + &Spell::EffectQuestComplete, // 16 SPELL_EFFECT_QUEST_COMPLETE + &Spell::EffectWeaponDmg, // 17 SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL + &Spell::EffectResurrect, // 18 SPELL_EFFECT_RESURRECT + &Spell::EffectAddExtraAttacks, // 19 SPELL_EFFECT_ADD_EXTRA_ATTACKS + &Spell::EffectUnused, // 20 SPELL_EFFECT_DODGE one spell: Dodge + &Spell::EffectUnused, // 21 SPELL_EFFECT_EVADE one spell: Evade (DND) + &Spell::EffectParry, // 22 SPELL_EFFECT_PARRY + &Spell::EffectBlock, // 23 SPELL_EFFECT_BLOCK one spell: Block + &Spell::EffectCreateItem, // 24 SPELL_EFFECT_CREATE_ITEM + &Spell::EffectUnused, // 25 SPELL_EFFECT_WEAPON + &Spell::EffectUnused, // 26 SPELL_EFFECT_DEFENSE one spell: Defense + &Spell::EffectPersistentAA, // 27 SPELL_EFFECT_PERSISTENT_AREA_AURA + &Spell::EffectSummonType, // 28 SPELL_EFFECT_SUMMON + &Spell::EffectLeap, // 29 SPELL_EFFECT_LEAP + &Spell::EffectEnergize, // 30 SPELL_EFFECT_ENERGIZE + &Spell::EffectWeaponDmg, // 31 SPELL_EFFECT_WEAPON_PERCENT_DAMAGE + &Spell::EffectTriggerMissileSpell, // 32 SPELL_EFFECT_TRIGGER_MISSILE + &Spell::EffectOpenLock, // 33 SPELL_EFFECT_OPEN_LOCK + &Spell::EffectSummonChangeItem, // 34 SPELL_EFFECT_SUMMON_CHANGE_ITEM + &Spell::EffectApplyAreaAura, // 35 SPELL_EFFECT_APPLY_AREA_AURA_PARTY + &Spell::EffectLearnSpell, // 36 SPELL_EFFECT_LEARN_SPELL + &Spell::EffectUnused, // 37 SPELL_EFFECT_SPELL_DEFENSE one spell: SPELLDEFENSE (DND) + &Spell::EffectDispel, // 38 SPELL_EFFECT_DISPEL + &Spell::EffectUnused, // 39 SPELL_EFFECT_LANGUAGE + &Spell::EffectDualWield, // 40 SPELL_EFFECT_DUAL_WIELD + &Spell::EffectJump, // 41 SPELL_EFFECT_JUMP + &Spell::EffectJumpDest, // 42 SPELL_EFFECT_JUMP_DEST + &Spell::EffectTeleUnitsFaceCaster, // 43 SPELL_EFFECT_TELEPORT_UNITS_FACE_CASTER + &Spell::EffectLearnSkill, // 44 SPELL_EFFECT_SKILL_STEP + &Spell::EffectPlayMovie, // 45 SPELL_EFFECT_PLAY_MOVIE + &Spell::EffectUnused, // 46 SPELL_EFFECT_SPAWN clientside, unit appears as if it was just spawned + &Spell::EffectTradeSkill, // 47 SPELL_EFFECT_TRADE_SKILL + &Spell::EffectUnused, // 48 SPELL_EFFECT_STEALTH one spell: Base Stealth + &Spell::EffectUnused, // 49 SPELL_EFFECT_DETECT one spell: Detect + &Spell::EffectTransmitted, // 50 SPELL_EFFECT_TRANS_DOOR + &Spell::EffectUnused, // 51 SPELL_EFFECT_FORCE_CRITICAL_HIT unused + &Spell::EffectUnused, // 52 SPELL_EFFECT_GUARANTEE_HIT unused + &Spell::EffectEnchantItemPerm, // 53 SPELL_EFFECT_ENCHANT_ITEM + &Spell::EffectEnchantItemTmp, // 54 SPELL_EFFECT_ENCHANT_ITEM_TEMPORARY + &Spell::EffectTameCreature, // 55 SPELL_EFFECT_TAMECREATURE + &Spell::EffectSummonPet, // 56 SPELL_EFFECT_SUMMON_PET + &Spell::EffectLearnPetSpell, // 57 SPELL_EFFECT_LEARN_PET_SPELL + &Spell::EffectWeaponDmg, // 58 SPELL_EFFECT_WEAPON_DAMAGE + &Spell::EffectCreateRandomItem, // 59 SPELL_EFFECT_CREATE_RANDOM_ITEM create item base at spell specific loot + &Spell::EffectProficiency, // 60 SPELL_EFFECT_PROFICIENCY + &Spell::EffectSendEvent, // 61 SPELL_EFFECT_SEND_EVENT + &Spell::EffectPowerBurn, // 62 SPELL_EFFECT_POWER_BURN + &Spell::EffectThreat, // 63 SPELL_EFFECT_THREAT + &Spell::EffectTriggerSpell, // 64 SPELL_EFFECT_TRIGGER_SPELL + &Spell::EffectApplyAreaAura, // 65 SPELL_EFFECT_APPLY_AREA_AURA_RAID + &Spell::EffectRechargeManaGem, // 66 SPELL_EFFECT_CREATE_MANA_GEM (possibly recharge it, misc - is item ID) + &Spell::EffectHealMaxHealth, // 67 SPELL_EFFECT_HEAL_MAX_HEALTH + &Spell::EffectInterruptCast, // 68 SPELL_EFFECT_INTERRUPT_CAST + &Spell::EffectDistract, // 69 SPELL_EFFECT_DISTRACT + &Spell::EffectPull, // 70 SPELL_EFFECT_PULL one spell: Distract Move + &Spell::EffectPickPocket, // 71 SPELL_EFFECT_PICKPOCKET + &Spell::EffectAddFarsight, // 72 SPELL_EFFECT_ADD_FARSIGHT + &Spell::EffectUntrainTalents, // 73 SPELL_EFFECT_UNTRAIN_TALENTS + &Spell::EffectApplyGlyph, // 74 SPELL_EFFECT_APPLY_GLYPH + &Spell::EffectHealMechanical, // 75 SPELL_EFFECT_HEAL_MECHANICAL one spell: Mechanical Patch Kit + &Spell::EffectSummonObjectWild, // 76 SPELL_EFFECT_SUMMON_OBJECT_WILD + &Spell::EffectScriptEffect, // 77 SPELL_EFFECT_SCRIPT_EFFECT + &Spell::EffectUnused, // 78 SPELL_EFFECT_ATTACK + &Spell::EffectSanctuary, // 79 SPELL_EFFECT_SANCTUARY + &Spell::EffectAddComboPoints, // 80 SPELL_EFFECT_ADD_COMBO_POINTS + &Spell::EffectUnused, // 81 SPELL_EFFECT_CREATE_HOUSE one spell: Create House (TEST) + &Spell::EffectNULL, // 82 SPELL_EFFECT_BIND_SIGHT + &Spell::EffectDuel, // 83 SPELL_EFFECT_DUEL + &Spell::EffectStuck, // 84 SPELL_EFFECT_STUCK + &Spell::EffectSummonPlayer, // 85 SPELL_EFFECT_SUMMON_PLAYER + &Spell::EffectActivateObject, // 86 SPELL_EFFECT_ACTIVATE_OBJECT + &Spell::EffectGameObjectDamage, // 87 SPELL_EFFECT_GAMEOBJECT_DAMAGE + &Spell::EffectGameObjectRepair, // 88 SPELL_EFFECT_GAMEOBJECT_REPAIR + &Spell::EffectGameObjectSetDestructionState, // 89 SPELL_EFFECT_GAMEOBJECT_SET_DESTRUCTION_STATE + &Spell::EffectKillCreditPersonal, // 90 SPELL_EFFECT_KILL_CREDIT Kill credit but only for single person + &Spell::EffectUnused, // 91 SPELL_EFFECT_THREAT_ALL one spell: zzOLDBrainwash + &Spell::EffectEnchantHeldItem, // 92 SPELL_EFFECT_ENCHANT_HELD_ITEM + &Spell::EffectForceDeselect, // 93 SPELL_EFFECT_FORCE_DESELECT + &Spell::EffectSelfResurrect, // 94 SPELL_EFFECT_SELF_RESURRECT + &Spell::EffectSkinning, // 95 SPELL_EFFECT_SKINNING + &Spell::EffectCharge, // 96 SPELL_EFFECT_CHARGE + &Spell::EffectCastButtons, // 97 SPELL_EFFECT_CAST_BUTTON (totem bar since 3.2.2a) + &Spell::EffectKnockBack, // 98 SPELL_EFFECT_KNOCK_BACK + &Spell::EffectDisEnchant, // 99 SPELL_EFFECT_DISENCHANT + &Spell::EffectInebriate, // 100 SPELL_EFFECT_INEBRIATE + &Spell::EffectFeedPet, // 101 SPELL_EFFECT_FEED_PET + &Spell::EffectDismissPet, // 102 SPELL_EFFECT_DISMISS_PET + &Spell::EffectReputation, // 103 SPELL_EFFECT_REPUTATION + &Spell::EffectSummonObject, // 104 SPELL_EFFECT_SUMMON_OBJECT_SLOT1 + &Spell::EffectSurvey, // 105 SPELL_EFFECT_SUMMON_OBJECT_SLOT2 + &Spell::EffectSummonRaidMarker, // 106 SPELL_EFFECT_SUMMON_OBJECT_SLOT3 + &Spell::EffectSummonObject, // 107 SPELL_EFFECT_SUMMON_OBJECT_SLOT4 + &Spell::EffectDispelMechanic, // 108 SPELL_EFFECT_DISPEL_MECHANIC + &Spell::EffectResurrectPet, // 109 SPELL_EFFECT_RESURRECT_PET + &Spell::EffectDestroyAllTotems, // 110 SPELL_EFFECT_DESTROY_ALL_TOTEMS + &Spell::EffectDurabilityDamage, // 111 SPELL_EFFECT_DURABILITY_DAMAGE + &Spell::EffectUnused, // 112 SPELL_EFFECT_112 + &Spell::EffectResurrectNew, // 113 SPELL_EFFECT_RESURRECT_NEW + &Spell::EffectTaunt, // 114 SPELL_EFFECT_ATTACK_ME + &Spell::EffectDurabilityDamagePCT, // 115 SPELL_EFFECT_DURABILITY_DAMAGE_PCT + &Spell::EffectSkinPlayerCorpse, // 116 SPELL_EFFECT_SKIN_PLAYER_CORPSE one spell: Remove Insignia, bg usage, required special corpse flags... + &Spell::EffectSpiritHeal, // 117 SPELL_EFFECT_SPIRIT_HEAL one spell: Spirit Heal + &Spell::EffectSkill, // 118 SPELL_EFFECT_SKILL professions and more + &Spell::EffectApplyAreaAura, // 119 SPELL_EFFECT_APPLY_AREA_AURA_PET + &Spell::EffectUnused, // 120 SPELL_EFFECT_TELEPORT_GRAVEYARD one spell: Graveyard Teleport Test + &Spell::EffectWeaponDmg, // 121 SPELL_EFFECT_NORMALIZED_WEAPON_DMG + &Spell::EffectUnused, // 122 SPELL_EFFECT_122 unused + &Spell::EffectSendTaxi, // 123 SPELL_EFFECT_SEND_TAXI taxi/flight related (misc value is taxi path id) + &Spell::EffectPullTowards, // 124 SPELL_EFFECT_PULL_TOWARDS + &Spell::EffectModifyThreatPercent, // 125 SPELL_EFFECT_MODIFY_THREAT_PERCENT + &Spell::EffectStealBeneficialBuff, // 126 SPELL_EFFECT_STEAL_BENEFICIAL_BUFF spell steal effect? + &Spell::EffectProspecting, // 127 SPELL_EFFECT_PROSPECTING Prospecting spell + &Spell::EffectApplyAreaAura, // 128 SPELL_EFFECT_APPLY_AREA_AURA_FRIEND + &Spell::EffectApplyAreaAura, // 129 SPELL_EFFECT_APPLY_AREA_AURA_ENEMY + &Spell::EffectRedirectThreat, // 130 SPELL_EFFECT_REDIRECT_THREAT + &Spell::EffectPlaySound, // 131 SPELL_EFFECT_PLAY_SOUND sound id in misc value (SoundEntries.dbc) + &Spell::EffectPlayMusic, // 132 SPELL_EFFECT_PLAY_MUSIC sound id in misc value (SoundEntries.dbc) + &Spell::EffectUnlearnSpecialization, // 133 SPELL_EFFECT_UNLEARN_SPECIALIZATION unlearn profession specialization + &Spell::EffectKillCredit, // 134 SPELL_EFFECT_KILL_CREDIT misc value is creature entry + &Spell::EffectNULL, // 135 SPELL_EFFECT_CALL_PET + &Spell::EffectHealPct, // 136 SPELL_EFFECT_HEAL_PCT + &Spell::EffectEnergizePct, // 137 SPELL_EFFECT_ENERGIZE_PCT + &Spell::EffectLeapBack, // 138 SPELL_EFFECT_LEAP_BACK Leap back + &Spell::EffectQuestClear, // 139 SPELL_EFFECT_CLEAR_QUEST Reset quest status (miscValue - quest ID) + &Spell::EffectForceCast, // 140 SPELL_EFFECT_FORCE_CAST + &Spell::EffectForceCast, // 141 SPELL_EFFECT_FORCE_CAST_WITH_VALUE + &Spell::EffectTriggerSpell, // 142 SPELL_EFFECT_TRIGGER_SPELL_WITH_VALUE + &Spell::EffectApplyAreaAura, // 143 SPELL_EFFECT_APPLY_AREA_AURA_OWNER + &Spell::EffectKnockBack, // 144 SPELL_EFFECT_KNOCK_BACK_DEST + &Spell::EffectPullTowardsDest, // 145 SPELL_EFFECT_PULL_TOWARDS_DEST Black Hole Effect + &Spell::EffectActivateRune, // 146 SPELL_EFFECT_ACTIVATE_RUNE + &Spell::EffectQuestFail, // 147 SPELL_EFFECT_QUEST_FAIL quest fail + &Spell::EffectTriggerMissileSpell, // 148 SPELL_EFFECT_TRIGGER_MISSILE_SPELL_WITH_VALUE + &Spell::EffectChargeDest, // 149 SPELL_EFFECT_CHARGE_DEST + &Spell::EffectQuestStart, // 150 SPELL_EFFECT_QUEST_START + &Spell::EffectTriggerRitualOfSummoning, // 151 SPELL_EFFECT_TRIGGER_SPELL_2 + &Spell::EffectSummonRaFFriend, // 152 SPELL_EFFECT_SUMMON_RAF_FRIEND summon Refer-a-Friend + &Spell::EffectCreateTamedPet, // 153 SPELL_EFFECT_CREATE_TAMED_PET misc value is creature entry + &Spell::EffectDiscoverTaxi, // 154 SPELL_EFFECT_DISCOVER_TAXI + &Spell::EffectTitanGrip, // 155 SPELL_EFFECT_TITAN_GRIP Allows you to equip two-handed axes, maces and swords in one hand, but you attack $49152s1% slower than normal. + &Spell::EffectEnchantItemPrismatic, // 156 SPELL_EFFECT_ENCHANT_ITEM_PRISMATIC + &Spell::EffectCreateItem2, // 157 SPELL_EFFECT_CREATE_ITEM_2 create item or create item template and replace by some randon spell loot item + &Spell::EffectMilling, // 158 SPELL_EFFECT_MILLING milling + &Spell::EffectRenamePet, // 159 SPELL_EFFECT_ALLOW_RENAME_PET allow rename pet once again + &Spell::EffectForceCast, // 160 SPELL_EFFECT_FORCE_CAST_2 + &Spell::EffectSpecCount, // 161 SPELL_EFFECT_TALENT_SPEC_COUNT second talent spec (learn/revert) + &Spell::EffectActivateSpec, // 162 SPELL_EFFECT_TALENT_SPEC_SELECT activate primary/secondary spec + &Spell::EffectUnused, // 163 SPELL_EFFECT_163 unused + &Spell::EffectRemoveAura, // 164 SPELL_EFFECT_REMOVE_AURA + &Spell::EffectDamageFromMaxHealthPCT, // 165 SPELL_EFFECT_DAMAGE_FROM_MAX_HEALTH_PCT + &Spell::EffectGiveCurrency, // 166 SPELL_EFFECT_GIVE_CURRENCY + &Spell::EffectUpdatePlayerPhase, // 167 SPELL_EFFECT_UPDATE_PLAYER_PHASE + &Spell::EffectNULL, // 168 SPELL_EFFECT_ALLOW_CONTROL_PET + &Spell::EffectDestroyItem, // 169 SPELL_EFFECT_DESTROY_ITEM + &Spell::EffectUpdateZoneAurasAndPhases, // 170 SPELL_EFFECT_UPDATE_ZONE_AURAS_AND_PHASES + &Spell::EffectSummonPersonalGameObject, // 171 SPELL_EFFECT_SUMMON_PERSONAL_GAMEOBJECT + &Spell::EffectResurrectWithAura, // 172 SPELL_EFFECT_RESURRECT_WITH_AURA + &Spell::EffectUnlockGuildVaultTab, // 173 SPELL_EFFECT_UNLOCK_GUILD_VAULT_TAB + &Spell::EffectApplyAura, // 174 SPELL_EFFECT_APPLY_AURA_2 + &Spell::EffectUnused, // 175 SPELL_EFFECT_175 unused + &Spell::EffectSanctuary, // 176 SPELL_EFFECT_SANCTUARY_2 + &Spell::EffectDespawnDynamicObject, // 177 SPELL_EFFECT_DESPAWN_DYNOBJECT + &Spell::EffectUnused, // 178 SPELL_EFFECT_178 unused + &Spell::EffectCreateAreaTrigger, // 179 SPELL_EFFECT_CREATE_AREATRIGGER + &Spell::EffectUnused, // 180 SPELL_EFFECT_UPDATE_AREATRIGGER + &Spell::EffectUnused, // 181 SPELL_EFFECT_REMOVE_TALENT + &Spell::EffectNULL, // 182 SPELL_EFFECT_DESPAWN_AREATRIGGER }; void Spell::EffectNULL(SpellEffIndex /*effIndex*/) @@ -286,7 +285,7 @@ void Spell::EffectResurrectNew(SpellEffIndex effIndex) if (!player || player->IsAlive() || !player->IsInWorld()) return; - if (player->IsResurrectRequested()) // already have one active request + if (player->IsResurrectRequested()) // already have one active request return; uint32 health = damage; @@ -313,16 +312,16 @@ void Spell::EffectInstaKill(SpellEffIndex /*effIndex*/) if (unitTarget->ToPlayer()->GetCommandStatus(CHEAT_GOD)) return; - if (m_caster == unitTarget) // prevent interrupt message + if (m_caster == unitTarget) // prevent interrupt message finish(); - WorldPacket data(SMSG_SPELLINSTAKILLLOG, 8+8+4); + WorldPacket data(SMSG_SPELLINSTAKILLLOG, 8 + 8 + 4); data << uint64(m_caster->GetGUID()); data << uint64(unitTarget->GetGUID()); data << uint32(m_spellInfo->Id); m_caster->SendMessageToSet(&data, true); - m_caster->DealDamage(unitTarget, unitTarget->GetHealth(), nullptr, NODAMAGE, SPELL_SCHOOL_MASK_NORMAL, nullptr, false); + Unit::DealDamage(m_caster, unitTarget, unitTarget->GetHealth(), nullptr, NODAMAGE, SPELL_SCHOOL_MASK_NORMAL, nullptr, false); } void Spell::EffectEnvironmentalDMG(SpellEffIndex /*effIndex*/) @@ -339,7 +338,7 @@ void Spell::EffectEnvironmentalDMG(SpellEffIndex /*effIndex*/) else { DamageInfo damageInfo(m_caster, unitTarget, damage, m_spellInfo, m_spellInfo->GetSchoolMask(), SPELL_DIRECT_DAMAGE, BASE_ATTACK); - m_caster->CalcAbsorbResist(damageInfo); + Unit::CalcAbsorbResist(damageInfo); uint32 absorb = damageInfo.GetAbsorb(); uint32 resist = damageInfo.GetResist(); @@ -357,77 +356,76 @@ void Spell::EffectSchoolDMG(SpellEffIndex effIndex) bool apply_direct_bonus = true; switch (m_spellInfo->SpellFamilyName) { - case SPELLFAMILY_GENERIC: + case SPELLFAMILY_GENERIC: + { + // Meteor like spells (divided damage to targets) + if (m_spellInfo->HasAttribute(SPELL_ATTR0_CU_SHARE_DAMAGE)) { - // Meteor like spells (divided damage to targets) - if (m_spellInfo->HasAttribute(SPELL_ATTR0_CU_SHARE_DAMAGE)) - { - uint32 count = 0; - for (std::list::iterator ihit= m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit) - if (ihit->effectMask & (1<::iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit) + if (ihit->effectMask & (1 << effIndex)) + ++count; - damage /= count; // divide to all targets - } + damage /= count; // divide to all targets + } - switch (m_spellInfo->Id) // better way to check unknown - { - // Consumption - case 28865: - damage = (((InstanceMap*)m_caster->GetMap())->GetDifficulty() == REGULAR_DIFFICULTY ? 2750 : 4250); - break; - // percent from health with min - case 25599: // Thundercrash - { - damage = unitTarget->GetHealth() / 2; - if (damage < 200) - damage = 200; - break; - } - // arcane charge. must only affect demons (also undead?) - case 45072: - { - if (unitTarget->GetCreatureType() != CREATURE_TYPE_DEMON - && unitTarget->GetCreatureType() != CREATURE_TYPE_UNDEAD) - return; - break; - } - // Gargoyle Strike - case 51963: - { - // about +4 base spell dmg per level - damage = (m_caster->getLevel() - 60) * 4 + 60; - break; - } - case 88082: // Fireball (Mirror Image) - case 59638: // Frost Bolt (Mirror Image) - case 88084: // Arcane Blast (Mirror Image) - // Mage Mirror Images deal 50% of the coefficient's spell power bonus as bonus damage - if (Unit* owner = m_caster->ToTempSummon()->GetSummoner()) - damage = CalculatePct(owner->SpellDamageBonusDone(unitTarget, m_spellInfo, (uint32)damage, SPELL_DIRECT_DAMAGE, effIndex), 50); - break; - } + switch (m_spellInfo->Id) // better way to check unknown + { + // Consumption + case 28865: + damage = (((InstanceMap*)m_caster->GetMap())->GetDifficulty() == REGULAR_DIFFICULTY ? 2750 : 4250); + break; + // percent from health with min + case 25599: // Thundercrash + { + damage = unitTarget->GetHealth() / 2; + if (damage < 200) + damage = 200; + break; + } + // arcane charge. must only affect demons (also undead?) + case 45072: + { + if (unitTarget->GetCreatureType() != CREATURE_TYPE_DEMON && unitTarget->GetCreatureType() != CREATURE_TYPE_UNDEAD) + return; break; } - case SPELLFAMILY_DEATHKNIGHT: + // Gargoyle Strike + case 51963: + { + // about +4 base spell dmg per level + damage = (m_caster->getLevel() - 60) * 4 + 60; + break; + } + case 88082: // Fireball (Mirror Image) + case 59638: // Frost Bolt (Mirror Image) + case 88084: // Arcane Blast (Mirror Image) + // Mage Mirror Images deal 50% of the coefficient's spell power bonus as bonus damage + if (Unit* owner = m_caster->ToTempSummon()->GetSummoner()) + damage = CalculatePct(owner->SpellDamageBonusDone(unitTarget, m_spellInfo, (uint32)damage, SPELL_DIRECT_DAMAGE, effIndex), 50); + break; + } + break; + } + case SPELLFAMILY_DEATHKNIGHT: + { + // Blood Boil - bonus for diseased targets + if (m_spellInfo->SpellFamilyFlags[0] & 0x00040000) { - // Blood Boil - bonus for diseased targets - if (m_spellInfo->SpellFamilyFlags[0] & 0x00040000) + if (unitTarget->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_DEATHKNIGHT, 0, 0, 0x00000002, m_caster->GetGUID())) { - if (unitTarget->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_DEATHKNIGHT, 0, 0, 0x00000002, m_caster->GetGUID())) - { - damage += m_damage / 2; - damage += int32(m_caster->GetTotalAttackPowerValue(BASE_ATTACK) * 0.035f); - } + damage += m_damage / 2; + damage += int32(m_caster->GetTotalAttackPowerValue(BASE_ATTACK) * 0.035f); } - - // Merciless Combat (Icy Touch and Howling Blast) - if (m_spellInfo->SpellFamilyFlags[0] & 0x2 || m_spellInfo->SpellFamilyFlags[1] & 0x2) - if (unitTarget->GetHealthPct() < 35.0f) - if (AuraEffect const* mercilessCombat = m_caster->GetDummyAuraEffect(SPELLFAMILY_DEATHKNIGHT, 2656, 0)) - AddPct(damage, mercilessCombat->GetAmount()); - break; } + + // Merciless Combat (Icy Touch and Howling Blast) + if (m_spellInfo->SpellFamilyFlags[0] & 0x2 || m_spellInfo->SpellFamilyFlags[1] & 0x2) + if (unitTarget->GetHealthPct() < 35.0f) + if (AuraEffect const* mercilessCombat = m_caster->GetDummyAuraEffect(SPELLFAMILY_DEATHKNIGHT, 2656, 0)) + AddPct(damage, mercilessCombat->GetAmount()); + break; + } } if (m_originalCaster && damage > 0 && apply_direct_bonus) @@ -465,75 +463,73 @@ void Spell::EffectDummy(SpellEffIndex effIndex) void Spell::EffectTriggerSpell(SpellEffIndex effIndex) { - if (effectHandleMode != SPELL_EFFECT_HANDLE_LAUNCH_TARGET - && effectHandleMode != SPELL_EFFECT_HANDLE_LAUNCH) + if (effectHandleMode != SPELL_EFFECT_HANDLE_LAUNCH_TARGET && effectHandleMode != SPELL_EFFECT_HANDLE_LAUNCH) return; uint32 triggered_spell_id = m_spellInfo->Effects[effIndex].TriggerSpell; /// @todo move those to spell scripts - if (m_spellInfo->Effects[effIndex].Effect == SPELL_EFFECT_TRIGGER_SPELL - && effectHandleMode == SPELL_EFFECT_HANDLE_LAUNCH_TARGET) + if (m_spellInfo->Effects[effIndex].Effect == SPELL_EFFECT_TRIGGER_SPELL && effectHandleMode == SPELL_EFFECT_HANDLE_LAUNCH_TARGET) { // special cases switch (triggered_spell_id) { - // Vanish (not exist) - case 18461: - { - unitTarget->RemoveMovementImpairingAuras(true); - unitTarget->RemoveAurasByType(SPELL_AURA_MOD_STALKED); + // Vanish (not exist) + case 18461: + { + unitTarget->RemoveMovementImpairingAuras(true); + unitTarget->RemoveAurasByType(SPELL_AURA_MOD_STALKED); - // If this spell is given to an NPC, it must handle the rest using its own AI - if (unitTarget->GetTypeId() != TYPEID_PLAYER) - return; + // If this spell is given to an NPC, it must handle the rest using its own AI + if (unitTarget->GetTypeId() != TYPEID_PLAYER) + return; - // See if we already are stealthed. If so, we're done. - if (unitTarget->HasAura(1784)) - return; + // See if we already are stealthed. If so, we're done. + if (unitTarget->HasAura(1784)) + return; - // Reset cooldown on stealth if needed - if (unitTarget->GetSpellHistory()->HasCooldown(1784)) - unitTarget->GetSpellHistory()->ResetCooldown(1784); + // Reset cooldown on stealth if needed + if (unitTarget->GetSpellHistory()->HasCooldown(1784)) + unitTarget->GetSpellHistory()->ResetCooldown(1784); - unitTarget->CastSpell(unitTarget, 1784, true); - return; - } - // Demonic Empowerment -- succubus - case 54437: - { - unitTarget->RemoveMovementImpairingAuras(true); - unitTarget->RemoveAurasByType(SPELL_AURA_MOD_STALKED); - unitTarget->RemoveAurasByType(SPELL_AURA_MOD_STUN); + unitTarget->CastSpell(unitTarget, 1784, true); + return; + } + // Demonic Empowerment -- succubus + case 54437: + { + unitTarget->RemoveMovementImpairingAuras(true); + unitTarget->RemoveAurasByType(SPELL_AURA_MOD_STALKED); + unitTarget->RemoveAurasByType(SPELL_AURA_MOD_STUN); - // Cast Lesser Invisibility - unitTarget->CastSpell(unitTarget, 7870, true); + // Cast Lesser Invisibility + unitTarget->CastSpell(unitTarget, 7870, true); + return; + } + // Brittle Armor - (need add max stack of 24575 Brittle Armor) + case 29284: + { + // Brittle Armor + SpellInfo const* spell = sSpellMgr->GetSpellInfo(24575); + if (!spell) return; - } - // Brittle Armor - (need add max stack of 24575 Brittle Armor) - case 29284: - { - // Brittle Armor - SpellInfo const* spell = sSpellMgr->GetSpellInfo(24575); - if (!spell) - return; - for (uint32 j = 0; j < spell->StackAmount; ++j) - m_caster->CastSpell(unitTarget, spell->Id, true); + for (uint32 j = 0; j < spell->StackAmount; ++j) + m_caster->CastSpell(unitTarget, spell->Id, true); + return; + } + // Mercurial Shield - (need add max stack of 26464 Mercurial Shield) + case 29286: + { + // Mercurial Shield + SpellInfo const* spell = sSpellMgr->GetSpellInfo(26464); + if (!spell) return; - } - // Mercurial Shield - (need add max stack of 26464 Mercurial Shield) - case 29286: - { - // Mercurial Shield - SpellInfo const* spell = sSpellMgr->GetSpellInfo(26464); - if (!spell) - return; - for (uint32 j = 0; j < spell->StackAmount; ++j) - m_caster->CastSpell(unitTarget, spell->Id, true); - return; - } + for (uint32 j = 0; j < spell->StackAmount; ++j) + m_caster->CastSpell(unitTarget, spell->Id, true); + return; + } } } @@ -552,7 +548,7 @@ void Spell::EffectTriggerSpell(SpellEffIndex effIndex) return; targets.SetUnitTarget(unitTarget); } - else //if (effectHandleMode == SPELL_EFFECT_HANDLE_LAUNCH) + else // if (effectHandleMode == SPELL_EFFECT_HANDLE_LAUNCH) { if (spellInfo->NeedsToBeTriggeredByCaster(m_spellInfo) && (m_spellInfo->Effects[effIndex].GetProvidedTargetMask() & TARGET_FLAG_UNIT_MASK)) return; @@ -578,8 +574,7 @@ void Spell::EffectTriggerSpell(SpellEffIndex effIndex) void Spell::EffectTriggerMissileSpell(SpellEffIndex effIndex) { - if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET - && effectHandleMode != SPELL_EFFECT_HANDLE_HIT) + if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET && effectHandleMode != SPELL_EFFECT_HANDLE_HIT) return; uint32 triggered_spell_id = m_spellInfo->Effects[effIndex].TriggerSpell; @@ -599,7 +594,7 @@ void Spell::EffectTriggerMissileSpell(SpellEffIndex effIndex) return; targets.SetUnitTarget(unitTarget); } - else //if (effectHandleMode == SPELL_EFFECT_HANDLE_HIT) + else // if (effectHandleMode == SPELL_EFFECT_HANDLE_HIT) { if (spellInfo->NeedsToBeTriggeredByCaster(m_spellInfo) && (m_spellInfo->Effects[effIndex].GetProvidedTargetMask() & TARGET_FLAG_UNIT_MASK)) return; @@ -646,26 +641,26 @@ void Spell::EffectForceCast(SpellEffIndex effIndex) { switch (m_spellInfo->Id) { - case 52588: // Skeletal Gryphon Escape - case 48598: // Ride Flamebringer Cue - unitTarget->RemoveAura(damage); - break; - case 52463: // Hide In Mine Car - case 52349: // Overtake - { - CastSpellExtraArgs args(m_originalCasterGUID); - args.SpellValueOverrides.AddMod(SPELLVALUE_BASE_POINT0, damage); - unitTarget->CastSpell(unitTarget, spellInfo->Id, args); - return; - } + case 52588: // Skeletal Gryphon Escape + case 48598: // Ride Flamebringer Cue + unitTarget->RemoveAura(damage); + break; + case 52463: // Hide In Mine Car + case 52349: // Overtake + { + CastSpellExtraArgs args(m_originalCasterGUID); + args.SpellValueOverrides.AddMod(SPELLVALUE_BASE_POINT0, damage); + unitTarget->CastSpell(unitTarget, spellInfo->Id, args); + return; + } } } switch (spellInfo->Id) { - case 72298: // Malleable Goo Summon - unitTarget->CastSpell(unitTarget, spellInfo->Id, m_originalCasterGUID); - return; + case 72298: // Malleable Goo Summon + unitTarget->CastSpell(unitTarget, spellInfo->Id, m_originalCasterGUID); + return; } CastSpellExtraArgs args(TRIGGERED_FULL_MASK); @@ -778,7 +773,7 @@ void Spell::EffectJumpDest(SpellEffIndex effIndex) } } -void Spell::CalculateJumpSpeeds(uint8 i, float dist, float & speedXY, float & speedZ) +void Spell::CalculateJumpSpeeds(uint8 i, float dist, float& speedXY, float& speedZ) { float runSpeed = m_caster->IsControlledByPlayer() ? playerBaseMoveSpeed[MOVE_RUN] : baseMoveSpeed[MOVE_RUN]; if (Creature* creature = m_caster->ToCreature()) @@ -792,7 +787,7 @@ void Spell::CalculateJumpSpeeds(uint8 i, float dist, float & speedXY, float & sp float duration = dist / speedXY; float durationSqr = duration * duration; - float minHeight = m_spellInfo->Effects[i].MiscValue ? m_spellInfo->Effects[i].MiscValue / 10.0f : 0.5f; // Lower bound is blizzlike + float minHeight = m_spellInfo->Effects[i].MiscValue ? m_spellInfo->Effects[i].MiscValue / 10.0f : 0.5f; // Lower bound is blizzlike float maxHeight = m_spellInfo->Effects[i].MiscValueB ? m_spellInfo->Effects[i].MiscValueB / 10.0f : 1000.0f; // Upper bound is unknown float height; if (durationSqr < minHeight * 8 / Movement::gravity) @@ -842,97 +837,97 @@ void Spell::EffectTeleportUnits(SpellEffIndex /*effIndex*/) /// @todo: awful hacks, move this to spellscripts switch (m_spellInfo->Id) { - // Dimensional Ripper - Everlook - case 23442: + // Dimensional Ripper - Everlook + case 23442: + { + int32 r = irand(0, 119); + if (r >= 70) // 7/12 success { - int32 r = irand(0, 119); - if (r >= 70) // 7/12 success - { - if (r < 100) // 4/12 evil twin - m_caster->CastSpell(m_caster, 23445, true); - else // 1/12 fire - m_caster->CastSpell(m_caster, 23449, true); - } - return; + if (r < 100) // 4/12 evil twin + m_caster->CastSpell(m_caster, 23445, true); + else // 1/12 fire + m_caster->CastSpell(m_caster, 23449, true); } - // Ultrasafe Transporter: Toshley's Station - case 36941: + return; + } + // Ultrasafe Transporter: Toshley's Station + case 36941: + { + if (roll_chance_i(50)) // 50% success { - if (roll_chance_i(50)) // 50% success + int32 rand_eff = urand(1, 7); + switch (rand_eff) { - int32 rand_eff = urand(1, 7); - switch (rand_eff) + case 1: + // soul split - evil + m_caster->CastSpell(m_caster, 36900, true); + break; + case 2: + // soul split - good + m_caster->CastSpell(m_caster, 36901, true); + break; + case 3: + // Increase the size + m_caster->CastSpell(m_caster, 36895, true); + break; + case 4: + // Decrease the size + m_caster->CastSpell(m_caster, 36893, true); + break; + case 5: + // Transform { - case 1: - // soul split - evil - m_caster->CastSpell(m_caster, 36900, true); - break; - case 2: - // soul split - good - m_caster->CastSpell(m_caster, 36901, true); - break; - case 3: - // Increase the size - m_caster->CastSpell(m_caster, 36895, true); - break; - case 4: - // Decrease the size - m_caster->CastSpell(m_caster, 36893, true); - break; - case 5: - // Transform - { - if (m_caster->ToPlayer()->GetTeam() == ALLIANCE) - m_caster->CastSpell(m_caster, 36897, true); - else - m_caster->CastSpell(m_caster, 36899, true); - break; - } - case 6: - // chicken - m_caster->CastSpell(m_caster, 36940, true); - break; - case 7: - // evil twin - m_caster->CastSpell(m_caster, 23445, true); - break; + if (m_caster->ToPlayer()->GetTeam() == ALLIANCE) + m_caster->CastSpell(m_caster, 36897, true); + else + m_caster->CastSpell(m_caster, 36899, true); + break; } + case 6: + // chicken + m_caster->CastSpell(m_caster, 36940, true); + break; + case 7: + // evil twin + m_caster->CastSpell(m_caster, 23445, true); + break; } - return; } - // Dimensional Ripper - Area 52 - case 36890: + return; + } + // Dimensional Ripper - Area 52 + case 36890: + { + if (roll_chance_i(50)) // 50% success { - if (roll_chance_i(50)) // 50% success + int32 rand_eff = urand(1, 4); + switch (rand_eff) { - int32 rand_eff = urand(1, 4); - switch (rand_eff) + case 1: + // soul split - evil + m_caster->CastSpell(m_caster, 36900, true); + break; + case 2: + // soul split - good + m_caster->CastSpell(m_caster, 36901, true); + break; + case 3: + // Increase the size + m_caster->CastSpell(m_caster, 36895, true); + break; + case 4: + // Transform { - case 1: - // soul split - evil - m_caster->CastSpell(m_caster, 36900, true); - break; - case 2: - // soul split - good - m_caster->CastSpell(m_caster, 36901, true); - break; - case 3: - // Increase the size - m_caster->CastSpell(m_caster, 36895, true); - break; - case 4: - // Transform - { - if (m_caster->ToPlayer()->GetTeam() == ALLIANCE) - m_caster->CastSpell(m_caster, 36897, true); - else - m_caster->CastSpell(m_caster, 36899, true); - break; - } + if (m_caster->ToPlayer()->GetTeam() == ALLIANCE) + m_caster->CastSpell(m_caster, 36897, true); + else + m_caster->CastSpell(m_caster, 36899, true); + break; } } - return; } + return; + } } } @@ -954,7 +949,7 @@ void Spell::EffectApplyAreaAura(SpellEffIndex effIndex) if (!m_spellAura || !unitTarget) return; - ASSERT (unitTarget == m_spellAura->GetOwner()); + ASSERT(unitTarget == m_spellAura->GetOwner()); m_spellAura->_ApplyEffectForTargets(effIndex); } @@ -1000,7 +995,7 @@ void Spell::EffectPowerDrain(SpellEffIndex effIndex) { gainMultiplier = m_spellInfo->Effects[effIndex].CalcValueMultiplier(m_originalCaster, this); - int32 gain = int32(newDamage* gainMultiplier); + int32 gain = int32(newDamage * gainMultiplier); m_caster->EnergizeBySpell(m_caster, m_spellInfo, gain, powerType); } @@ -1010,8 +1005,7 @@ void Spell::EffectPowerDrain(SpellEffIndex effIndex) void Spell::EffectSendEvent(SpellEffIndex effIndex) { // we do not handle a flag dropping or clicking on flag in battleground by sendevent system - if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET - && effectHandleMode != SPELL_EFFECT_HANDLE_HIT) + if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET && effectHandleMode != SPELL_EFFECT_HANDLE_HIT) return; WorldObject* target = nullptr; @@ -1074,7 +1068,7 @@ void Spell::EffectPowerBurn(SpellEffIndex effIndex) // add log data before multiplication (need power amount, not damage) ExecuteLogEffectTakeTargetPower(effIndex, unitTarget, powerType, newDamage, 0.0f); - newDamage = int32(newDamage* dmgMultiplier); + newDamage = int32(newDamage * dmgMultiplier); m_damage += newDamage; } @@ -1102,7 +1096,7 @@ void Spell::EffectHeal(SpellEffIndex effIndex) int damageAmount = 0; if (AuraEffect const* aurEff = m_caster->GetAuraEffect(45062, 0)) { - damageAmount+= aurEff->GetAmount(); + damageAmount += aurEff->GetAmount(); m_caster->RemoveAurasDueToSpell(45062); } @@ -1123,8 +1117,7 @@ void Spell::EffectHeal(SpellEffIndex effIndex) AuraEffect* targetAura = nullptr; for (Unit::AuraEffectList::const_iterator i = RejorRegr.begin(); i != RejorRegr.end(); ++i) { - if ((*i)->GetSpellInfo()->SpellFamilyName == SPELLFAMILY_DRUID - && (*i)->GetSpellInfo()->SpellFamilyFlags[0] & 0x50) + if ((*i)->GetSpellInfo()->SpellFamilyName == SPELLFAMILY_DRUID && (*i)->GetSpellInfo()->SpellFamilyFlags[0] & 0x50) { if (!targetAura || (*i)->GetBase()->GetDuration() < targetAura->GetBase()->GetDuration()) targetAura = *i; @@ -1172,9 +1165,7 @@ void Spell::EffectHealPct(SpellEffIndex effIndex) return; uint32 heal = m_originalCaster->SpellHealingBonusDone(unitTarget, m_spellInfo, unitTarget->CountPctFromMaxHealth(damage), HEAL, effIndex); - heal = unitTarget->SpellHealingBonusTaken(m_originalCaster, m_spellInfo, heal, HEAL); - - m_healing += heal; + m_healing += unitTarget->SpellHealingBonusTaken(m_originalCaster, m_spellInfo, heal, HEAL); } void Spell::EffectHealMechanical(SpellEffIndex effIndex) @@ -1242,20 +1233,20 @@ void Spell::DoCreateItem(uint32 /*i*/, uint32 itemtype) uint32 bgType = 0; switch (m_spellInfo->Id) { - case SPELL_AV_MARK_WINNER: - case SPELL_AV_MARK_LOSER: - bgType = BATTLEGROUND_AV; - break; - case SPELL_WS_MARK_WINNER: - case SPELL_WS_MARK_LOSER: - bgType = BATTLEGROUND_WS; - break; - case SPELL_AB_MARK_WINNER: - case SPELL_AB_MARK_LOSER: - bgType = BATTLEGROUND_AB; - break; - default: - break; + case SPELL_AV_MARK_WINNER: + case SPELL_AV_MARK_LOSER: + bgType = BATTLEGROUND_AV; + break; + case SPELL_WS_MARK_WINNER: + case SPELL_WS_MARK_LOSER: + bgType = BATTLEGROUND_WS; + break; + case SPELL_AB_MARK_WINNER: + case SPELL_AB_MARK_LOSER: + bgType = BATTLEGROUND_AB; + break; + default: + break; } uint32 num_to_add = damage; @@ -1278,15 +1269,14 @@ void Spell::DoCreateItem(uint32 /*i*/, uint32 itemtype) /* == gem perfection handling over == */ - /* == profession specialization handling == */ // init items_count to 1, since 1 item will be created regardless of specialization - int items_count=1; + int items_count = 1; // the chance to create additional items - float additionalCreateChance=0.0f; + float additionalCreateChance = 0.0f; // the maximum number of created additional items - uint8 additionalMaxNum=0; + uint8 additionalMaxNum = 0; // get the chance and maximum number for creating extra items if (CanCreateExtraItems(player, m_spellInfo->Id, additionalCreateChance, additionalMaxNum)) // roll with this chance till we roll not to create or we create the max num @@ -1298,7 +1288,6 @@ void Spell::DoCreateItem(uint32 /*i*/, uint32 itemtype) /* == profession specialization handling over == */ - // can the player store the new item? ItemPosCountVec dest; uint32 no_space = 0; @@ -1358,14 +1347,14 @@ void Spell::DoCreateItem(uint32 /*i*/, uint32 itemtype) player->UpdateCraftSkill(m_spellInfo->Id); } -/* - // for battleground marks send by mail if not add all expected - if (no_space > 0 && bgType) - { - if (Battleground* bg = sBattlegroundMgr->GetBattlegroundTemplate(BattlegroundTypeId(bgType))) - bg->SendRewardMarkByMail(player, newitemid, no_space); - } -*/ + /* + // for battleground marks send by mail if not add all expected + if (no_space > 0 && bgType) + { + if (Battleground* bg = sBattlegroundMgr->GetBattlegroundTemplate(BattlegroundTypeId(bgType))) + bg->SendRewardMarkByMail(player, newitemid, no_space); + } + */ } void Spell::EffectCreateItem(SpellEffIndex effIndex) @@ -1408,7 +1397,7 @@ void Spell::EffectCreateItem2(SpellEffIndex effIndex) player->AutoStoreLoot(m_spellInfo->Id, LootTemplates_Spell); } else - player->AutoStoreLoot(m_spellInfo->Id, LootTemplates_Spell); // create some random items + player->AutoStoreLoot(m_spellInfo->Id, LootTemplates_Spell); // create some random items player->UpdateCraftSkill(m_spellInfo->Id); } @@ -1485,32 +1474,32 @@ void Spell::EffectEnergize(SpellEffIndex effIndex) int level_diff = 0; switch (m_spellInfo->Id) { - case 9512: // Restore Energy - level_diff = m_caster->getLevel() - 40; - level_multiplier = 2; - break; - case 24571: // Blood Fury - level_diff = m_caster->getLevel() - 60; - level_multiplier = 10; - break; - case 24532: // Burst of Energy - level_diff = m_caster->getLevel() - 60; - level_multiplier = 4; - break; - case 31930: // Judgements of the Wise - case 63375: // Primal Wisdom - case 68082: // Glyph of Seal of Command - damage = int32(CalculatePct(unitTarget->GetCreateMana(), damage)); - break; - case 67490: // Runic Mana Injector (mana gain increased by 25% for engineers - 3.2.0 patch change) - { - if (Player* player = m_caster->ToPlayer()) - if (player->HasSkill(SKILL_ENGINEERING)) - AddPct(damage, 25); - break; - } - default: - break; + case 9512: // Restore Energy + level_diff = m_caster->getLevel() - 40; + level_multiplier = 2; + break; + case 24571: // Blood Fury + level_diff = m_caster->getLevel() - 60; + level_multiplier = 10; + break; + case 24532: // Burst of Energy + level_diff = m_caster->getLevel() - 60; + level_multiplier = 4; + break; + case 31930: // Judgements of the Wise + case 63375: // Primal Wisdom + case 68082: // Glyph of Seal of Command + damage = int32(CalculatePct(unitTarget->GetCreateMana(), damage)); + break; + case 67490: // Runic Mana Injector (mana gain increased by 25% for engineers - 3.2.0 patch change) + { + if (Player* player = m_caster->ToPlayer()) + if (player->HasSkill(SKILL_ENGINEERING)) + AddPct(damage, 25); + break; + } + default: + break; } if (level_diff > 0) @@ -1556,7 +1545,7 @@ void Spell::SendLoot(ObjectGuid guid, LootType loottype) if (!gameObjTarget->isSpawned() && !player->IsGameMaster()) { LOG_INFO("entities.player.cheat", "Possible hacking attempt: Player %s [guid: %u] tried to loot a gameobject [entry: %u id: %u] which is on respawn timer without being in GM mode!", - player->GetName().c_str(), player->GetGUID().GetCounter(), gameObjTarget->GetEntry(), gameObjTarget->GetGUID().GetCounter()); + player->GetName().c_str(), player->GetGUID().GetCounter(), gameObjTarget->GetEntry(), gameObjTarget->GetGUID().GetCounter()); return; } // special case, already has GossipHello inside so return and avoid calling twice @@ -1572,38 +1561,38 @@ void Spell::SendLoot(ObjectGuid guid, LootType loottype) switch (gameObjTarget->GetGoType()) { - case GAMEOBJECT_TYPE_DOOR: - case GAMEOBJECT_TYPE_BUTTON: - gameObjTarget->UseDoorOrButton(0, false, player); - return; + case GAMEOBJECT_TYPE_DOOR: + case GAMEOBJECT_TYPE_BUTTON: + gameObjTarget->UseDoorOrButton(0, false, player); + return; - case GAMEOBJECT_TYPE_QUESTGIVER: - player->PrepareGossipMenu(gameObjTarget, gameObjTarget->GetGOInfo()->questgiver.gossipID, true); - player->SendPreparedGossip(gameObjTarget); - return; + case GAMEOBJECT_TYPE_QUESTGIVER: + player->PrepareGossipMenu(gameObjTarget, gameObjTarget->GetGOInfo()->questgiver.gossipID, true); + player->SendPreparedGossip(gameObjTarget); + return; - case GAMEOBJECT_TYPE_SPELL_FOCUS: - // triggering linked GO - if (uint32 trapEntry = gameObjTarget->GetGOInfo()->spellFocus.linkedTrapId) - gameObjTarget->TriggeringLinkedGameObject(trapEntry, m_caster); - return; + case GAMEOBJECT_TYPE_SPELL_FOCUS: + // triggering linked GO + if (uint32 trapEntry = gameObjTarget->GetGOInfo()->spellFocus.linkedTrapId) + gameObjTarget->TriggeringLinkedGameObject(trapEntry, m_caster); + return; - case GAMEOBJECT_TYPE_CHEST: - /// @todo possible must be moved to loot release (in different from linked triggering) - if (gameObjTarget->GetGOInfo()->chest.eventId) - { - LOG_DEBUG("spells", "Chest ScriptStart id %u for GO %u", gameObjTarget->GetGOInfo()->chest.eventId, gameObjTarget->GetSpawnId()); - GameEvents::Trigger(gameObjTarget->GetGOInfo()->chest.eventId, player, gameObjTarget); - } + case GAMEOBJECT_TYPE_CHEST: + /// @todo possible must be moved to loot release (in different from linked triggering) + if (gameObjTarget->GetGOInfo()->chest.eventId) + { + LOG_DEBUG("spells", "Chest ScriptStart id %u for GO %u", gameObjTarget->GetGOInfo()->chest.eventId, gameObjTarget->GetSpawnId()); + GameEvents::Trigger(gameObjTarget->GetGOInfo()->chest.eventId, player, gameObjTarget); + } - // triggering linked GO - if (uint32 trapEntry = gameObjTarget->GetGOInfo()->chest.linkedTrapId) - gameObjTarget->TriggeringLinkedGameObject(trapEntry, m_caster); + // triggering linked GO + if (uint32 trapEntry = gameObjTarget->GetGOInfo()->chest.linkedTrapId) + gameObjTarget->TriggeringLinkedGameObject(trapEntry, m_caster); - // Don't return, let loots been taken - break; - default: - break; + // Don't return, let loots been taken + break; + default: + break; } } @@ -1636,11 +1625,10 @@ void Spell::EffectOpenLock(SpellEffIndex effIndex) return; // Arathi Basin banner opening. /// @todo Verify correctness of this check - if ((goInfo->type == GAMEOBJECT_TYPE_BUTTON && goInfo->button.noDamageImmune) || - (goInfo->type == GAMEOBJECT_TYPE_GOOBER && goInfo->goober.losOK)) + if ((goInfo->type == GAMEOBJECT_TYPE_BUTTON && goInfo->button.noDamageImmune) || (goInfo->type == GAMEOBJECT_TYPE_GOOBER && goInfo->goober.losOK)) { - //CanUseBattlegroundObject() already called in CheckCast() - // in battleground check + // CanUseBattlegroundObject() already called in CheckCast() + // in battleground check if (Battleground* bg = player->GetBattleground()) { bg->EventPlayerClickedOnFlag(player, gameObjTarget); @@ -1649,8 +1637,8 @@ void Spell::EffectOpenLock(SpellEffIndex effIndex) } else if (goInfo->type == GAMEOBJECT_TYPE_FLAGSTAND) { - //CanUseBattlegroundObject() already called in CheckCast() - // in battleground check + // CanUseBattlegroundObject() already called in CheckCast() + // in battleground check if (Battleground* bg = player->GetBattleground()) { if (bg->GetTypeID(true) == BATTLEGROUND_EY) @@ -1715,8 +1703,7 @@ void Spell::EffectOpenLock(SpellEffIndex effIndex) if (gameObjTarget) { // Allow one skill-up until respawned - if (!gameObjTarget->IsInSkillupList(player->GetGUID().GetCounter()) && - player->UpdateGatherSkill(skillId, pureSkillValue, reqSkillValue)) + if (!gameObjTarget->IsInSkillupList(player->GetGUID().GetCounter()) && player->UpdateGatherSkill(skillId, pureSkillValue, reqSkillValue)) { gameObjTarget->AddToSkillupList(player->GetGUID().GetCounter()); player->GiveXpForGather(skillId); @@ -1762,7 +1749,8 @@ void Spell::EffectSummonChangeItem(SpellEffIndex effIndex) for (uint8 j = PERM_ENCHANTMENT_SLOT; j <= TEMP_ENCHANTMENT_SLOT; ++j) if (m_CastItem->GetEnchantmentId(EnchantmentSlot(j))) - pNewItem->SetEnchantment(EnchantmentSlot(j), m_CastItem->GetEnchantmentId(EnchantmentSlot(j)), m_CastItem->GetEnchantmentDuration(EnchantmentSlot(j)), m_CastItem->GetEnchantmentCharges(EnchantmentSlot(j))); + pNewItem->SetEnchantment( + EnchantmentSlot(j), m_CastItem->GetEnchantmentId(EnchantmentSlot(j)), m_CastItem->GetEnchantmentDuration(EnchantmentSlot(j)), m_CastItem->GetEnchantmentCharges(EnchantmentSlot(j))); if (m_CastItem->GetUInt32Value(ITEM_FIELD_DURABILITY) < m_CastItem->GetUInt32Value(ITEM_FIELD_MAXDURABILITY)) { @@ -1821,7 +1809,8 @@ void Spell::EffectSummonChangeItem(SpellEffIndex effIndex) if (msg == EQUIP_ERR_OK || msg == EQUIP_ERR_CLIENT_LOCKED_OUT) { - if (msg == EQUIP_ERR_CLIENT_LOCKED_OUT) dest = EQUIPMENT_SLOT_MAINHAND; + if (msg == EQUIP_ERR_CLIENT_LOCKED_OUT) + dest = EQUIPMENT_SLOT_MAINHAND; // prevent crash at access and unexpected charges counting with item update queue corrupt if (m_CastItem == m_targets.GetItemTarget()) @@ -1920,39 +1909,39 @@ void Spell::EffectSummonType(SpellEffIndex effIndex) { switch (SummonPropertiesParamType(*parameter)) { - case SummonPropertiesParamType::None: // Default behavior - break; - case SummonPropertiesParamType::Health: - extraArgs.SummonHealth = damage; - break; - case SummonPropertiesParamType::NumUnitsMin: // Minimum 1 - summonCount = std::max(damage, 1); - break; - case SummonPropertiesParamType::SeatNumber: - if (damage < MAX_VEHICLE_SEATS) - { - useHardcodedRideSpell = true; - extraArgs.SeatNumber = damage; - } - break; - case SummonPropertiesParamType::RideSpell: - if (sSpellMgr->GetSpellInfo(damage)) - extraArgs.RideSpell = damage; - else // There is one spell with RecID 161 (52200) that uses bp as ride spell while most spells do not so we can assume that this parameter falls back to the hardcoded spell - extraArgs.RideSpell = VEHICLE_SPELL_RIDE_HARDCODED; - break; - case SummonPropertiesParamType::CreatureLevel: - extraArgs.CreatureLevel = damage; - break; - case SummonPropertiesParamType::MaxSummons: // @todo: handle and research (number of allowed units in one summon slot?) - break; - case SummonPropertiesParamType::NumUnitsMax: // Fails if less than 1 - if (damage <= 0) - return; - summonCount = damage; - break; - default: - break; + case SummonPropertiesParamType::None: // Default behavior + break; + case SummonPropertiesParamType::Health: + extraArgs.SummonHealth = damage; + break; + case SummonPropertiesParamType::NumUnitsMin: // Minimum 1 + summonCount = std::max(damage, 1); + break; + case SummonPropertiesParamType::SeatNumber: + if (damage < MAX_VEHICLE_SEATS) + { + useHardcodedRideSpell = true; + extraArgs.SeatNumber = damage; + } + break; + case SummonPropertiesParamType::RideSpell: + if (sSpellMgr->GetSpellInfo(damage)) + extraArgs.RideSpell = damage; + else // There is one spell with RecID 161 (52200) that uses bp as ride spell while most spells do not so we can assume that this parameter falls back to the hardcoded spell + extraArgs.RideSpell = VEHICLE_SPELL_RIDE_HARDCODED; + break; + case SummonPropertiesParamType::CreatureLevel: + extraArgs.CreatureLevel = damage; + break; + case SummonPropertiesParamType::MaxSummons: // @todo: handle and research (number of allowed units in one summon slot?) + break; + case SummonPropertiesParamType::NumUnitsMax: // Fails if less than 1 + if (damage <= 0) + return; + summonCount = damage; + break; + default: + break; } } @@ -1976,7 +1965,6 @@ void Spell::EffectSummonType(SpellEffIndex effIndex) m_originalCaster->CastSpell(summon, VEHICLE_SPELL_RIDE_HARDCODED, CastSpellExtraArgs(true).AddSpellBP0(extraArgs.SeatNumber)); else if (extraArgs.RideSpell) m_originalCaster->CastSpell(summon, extraArgs.RideSpell, true); - } } } @@ -2015,7 +2003,7 @@ void Spell::EffectDispel(SpellEffIndex effIndex) // Create dispel mask by dispel type uint32 dispel_type = m_spellInfo->Effects[effIndex].MiscValue; - uint32 dispelMask = SpellInfo::GetDispelMask(DispelType(dispel_type)); + uint32 dispelMask = SpellInfo::GetDispelMask(DispelType(dispel_type)); DispelChargesList dispelList; unitTarget->GetDispellableAuraList(m_caster, dispelMask, dispelList, targetMissInfo == SPELL_MISS_REFLECT); @@ -2039,13 +2027,14 @@ void Spell::EffectDispel(SpellEffIndex effIndex) if (itr->RollDispel()) { - auto successItr = std::find_if(successList.begin(), successList.end(), [&itr](DispelableAura& dispelAura) -> bool - { - if (dispelAura.GetAura()->GetId() == itr->GetAura()->GetId() && dispelAura.GetAura()->GetCaster() == itr->GetAura()->GetCaster()) - return true; + auto successItr = std::find_if(successList.begin(), successList.end(), + [&itr](DispelableAura& dispelAura) -> bool + { + if (dispelAura.GetAura()->GetId() == itr->GetAura()->GetId() && dispelAura.GetAura()->GetCaster() == itr->GetAura()->GetCaster()) + return true; - return false; - }); + return false; + }); if (successItr == successList.end()) successList.emplace_back(itr->GetAura(), 0, 1); @@ -2063,12 +2052,12 @@ void Spell::EffectDispel(SpellEffIndex effIndex) if (!failCount) { // Failed to dispell - dataFail << uint64(m_caster->GetGUID()); // Caster GUID - dataFail << uint64(unitTarget->GetGUID()); // Victim GUID - dataFail << uint32(m_spellInfo->Id); // dispel spell id + dataFail << uint64(m_caster->GetGUID()); // Caster GUID + dataFail << uint64(unitTarget->GetGUID()); // Victim GUID + dataFail << uint32(m_spellInfo->Id); // dispel spell id } ++failCount; - dataFail << uint32(itr->GetAura()->GetId()); // Spell Id + dataFail << uint32(itr->GetAura()->GetId()); // Spell Id } ++count; } @@ -2081,16 +2070,16 @@ void Spell::EffectDispel(SpellEffIndex effIndex) WorldPacket dataSuccess(SMSG_SPELLDISPELLOG, 8 + 8 + 4 + 1 + 4 + successList.size() * 5); // Send packet header - dataSuccess << unitTarget->GetPackGUID(); // Victim GUID - dataSuccess << m_caster->GetPackGUID(); // Caster GUID - dataSuccess << uint32(m_spellInfo->Id); // dispel spell id - dataSuccess << uint8(0); // not used - dataSuccess << uint32(successList.size()); // count + dataSuccess << unitTarget->GetPackGUID(); // Victim GUID + dataSuccess << m_caster->GetPackGUID(); // Caster GUID + dataSuccess << uint32(m_spellInfo->Id); // dispel spell id + dataSuccess << uint8(0); // not used + dataSuccess << uint32(successList.size()); // count for (DispelChargesList::iterator itr = successList.begin(); itr != successList.end(); ++itr) { // Send dispelled spell info - dataSuccess << uint32(itr->GetAura()->GetId()); // Spell Id - dataSuccess << uint8(0); // 0 - dispelled !=0 cleansed + dataSuccess << uint32(itr->GetAura()->GetId()); // Spell Id + dataSuccess << uint8(0); // 0 - dispelled !=0 cleansed unitTarget->RemoveAurasDueToSpellByDispel(itr->GetAura()->GetId(), m_spellInfo->Id, itr->GetAura()->GetCasterGUID(), m_caster, itr->GetDispelCharges()); } m_caster->SendMessageToSet(&dataSuccess, true); @@ -2158,7 +2147,7 @@ void Spell::EffectPickPocket(SpellEffIndex /*effIndex*/) return; // victim have to be alive and humanoid or undead - if (unitTarget->IsAlive() && (unitTarget->GetCreatureTypeMask() &CREATURE_TYPEMASK_HUMANOID_OR_UNDEAD) != 0) + if (unitTarget->IsAlive() && (unitTarget->GetCreatureTypeMask() & CREATURE_TYPEMASK_HUMANOID_OR_UNDEAD) != 0) m_caster->ToPlayer()->SendLoot(unitTarget->GetGUID(), LOOT_PICKPOCKETING); } @@ -2314,10 +2303,9 @@ void Spell::EffectEnchantItemPerm(SpellEffIndex effIndex) if (item_owner != player && player->GetSession()->HasPermission(rbac::RBAC_PERM_LOG_GM_TRADE)) { - 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()->GetDefaultLocaleName(), itemTarget->GetEntry(), - item_owner->GetName().c_str(), item_owner->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()->GetDefaultLocaleName(), itemTarget->GetEntry(), item_owner->GetName().c_str(), + item_owner->GetSession()->GetAccountId()); } // remove old enchanting before applying new if equipped @@ -2366,7 +2354,9 @@ void Spell::EffectEnchantItemPrismatic(SpellEffIndex effIndex) } if (!add_socket) { - LOG_ERROR("spells", "Spell::EffectEnchantItemPrismatic: attempt to apply the enchant spell %u with SPELL_EFFECT_ENCHANT_ITEM_PRISMATIC (%u), but without ITEM_ENCHANTMENT_TYPE_PRISMATIC_SOCKET (%u), not supported yet.", + LOG_ERROR("spells", + "Spell::EffectEnchantItemPrismatic: attempt to apply the enchant spell %u with SPELL_EFFECT_ENCHANT_ITEM_PRISMATIC (%u), but without ITEM_ENCHANTMENT_TYPE_PRISMATIC_SOCKET (%u), not " + "supported yet.", m_spellInfo->Id, SPELL_EFFECT_ENCHANT_ITEM_PRISMATIC, ITEM_ENCHANTMENT_TYPE_PRISMATIC_SOCKET); return; } @@ -2379,10 +2369,8 @@ void Spell::EffectEnchantItemPrismatic(SpellEffIndex effIndex) if (item_owner != player && player->GetSession()->HasPermission(rbac::RBAC_PERM_LOG_GM_TRADE)) { - 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()->GetDefaultLocaleName(), itemTarget->GetEntry(), - item_owner->GetName().c_str(), item_owner->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()->GetDefaultLocaleName(), itemTarget->GetEntry(), item_owner->GetName().c_str(), item_owner->GetSession()->GetAccountId()); } // remove old enchanting before applying new if equipped @@ -2429,29 +2417,29 @@ void Spell::EffectEnchantItemTmp(SpellEffIndex effIndex) // rogue family enchantments exception by duration if (m_spellInfo->Id == 38615) - duration = 1800; // 30 mins + duration = 1800; // 30 mins // other rogue family enchantments always 1 hour (some have spell damage=0, but some have wrong data in EffBasePoints) else if (m_spellInfo->SpellFamilyName == SPELLFAMILY_ROGUE) - duration = 3600; // 1 hour + duration = 3600; // 1 hour // shaman family enchantments else if (m_spellInfo->SpellFamilyName == SPELLFAMILY_SHAMAN) - duration = 1800; // 30 mins + duration = 1800; // 30 mins // other cases with this SpellVisual already selected else if (m_spellInfo->SpellVisual[0] == 215) - duration = 1800; // 30 mins + duration = 1800; // 30 mins // some fishing pole bonuses except Glow Worm which lasts full hour else if (m_spellInfo->SpellVisual[0] == 563 && m_spellInfo->Id != 64401) - duration = 600; // 10 mins + duration = 600; // 10 mins // shaman rockbiter enchantments else if (m_spellInfo->SpellVisual[0] == 0) - duration = 1800; // 30 mins + duration = 1800; // 30 mins else if (m_spellInfo->Id == 29702) - duration = 300; // 5 mins + duration = 300; // 5 mins else if (m_spellInfo->Id == 37360) - duration = 300; // 5 mins + duration = 300; // 5 mins // default case else - duration = 3600; // 1 hour + duration = 3600; // 1 hour // item can be in trade slot and have owner diff. from caster Player* item_owner = itemTarget->GetOwner(); @@ -2460,10 +2448,8 @@ void Spell::EffectEnchantItemTmp(SpellEffIndex effIndex) if (item_owner != player && player->GetSession()->HasPermission(rbac::RBAC_PERM_LOG_GM_TRADE)) { - 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()->GetDefaultLocaleName(), itemTarget->GetEntry(), - item_owner->GetName().c_str(), item_owner->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()->GetDefaultLocaleName(), itemTarget->GetEntry(), item_owner->GetName().c_str(), item_owner->GetSession()->GetAccountId()); } // remove old enchanting before applying new if equipped @@ -2498,11 +2484,11 @@ void Spell::EffectTameCreature(SpellEffIndex /*effIndex*/) return; // cast finish successfully - //SendChannelUpdate(0); + // SendChannelUpdate(0); finish(); Pet* pet = m_caster->CreateTamedPetFrom(creatureTarget, m_spellInfo->Id); - if (!pet) // in very specific state like near world end/etc. + if (!pet) // in very specific state like near world end/etc. return; uint8 level = m_caster->getLevel(); @@ -2531,7 +2517,7 @@ void Spell::EffectTameCreature(SpellEffIndex /*effIndex*/) return; } } - // despawn tame target + // despawn tame target creatureTarget->DespawnOrUnsummon(); // visual effect for levelup @@ -2552,8 +2538,8 @@ void Spell::EffectSummonPet(SpellEffIndex effIndex) } // SUMMON_PET SummonPet's entries are at MiscValue, HunterPetSlot at BasePoints - uint32 petentry = (m_spellInfo->Effects[effIndex].MiscValue == 0 && m_spellInfo->Effects[effIndex].BasePoints <= PET_SLOT_LAST_ACTIVE_SLOT) ? - m_spellInfo->Effects[effIndex].BasePoints : m_spellInfo->Effects[effIndex].MiscValue; + uint32 petentry = (m_spellInfo->Effects[effIndex].MiscValue == 0 && m_spellInfo->Effects[effIndex].BasePoints <= PET_SLOT_LAST_ACTIVE_SLOT) ? m_spellInfo->Effects[effIndex].BasePoints + : m_spellInfo->Effects[effIndex].MiscValue; PetType petType = (m_spellInfo->Effects[effIndex].MiscValue == 0 && m_spellInfo->Effects[effIndex].BasePoints <= PET_SLOT_LAST_ACTIVE_SLOT) ? HUNTER_PET : SUMMON_PET; @@ -2587,20 +2573,19 @@ void Spell::EffectSummonPet(SpellEffIndex effIndex) ASSERT(OldSummon->GetMap() == owner->GetMap()); - //OldSummon->GetMap()->Remove(OldSummon->ToCreature(), false); + // OldSummon->GetMap()->Remove(OldSummon->ToCreature(), false); float px, py, pz; owner->GetClosePoint(px, py, pz, OldSummon->GetCombatReach()); OldSummon->NearTeleportTo(px, py, pz, OldSummon->GetOrientation()); - //OldSummon->Relocate(px, py, pz, OldSummon->GetOrientation()); - //OldSummon->SetMap(owner->GetMap()); - //owner->GetMap()->Add(OldSummon->ToCreature()); + // OldSummon->Relocate(px, py, pz, OldSummon->GetOrientation()); + // OldSummon->SetMap(owner->GetMap()); + // owner->GetMap()->Add(OldSummon->ToCreature()); if (OldSummon->getPetType() == SUMMON_PET) { OldSummon->SetHealth(OldSummon->GetMaxHealth()); - OldSummon->SetPower(OldSummon->GetPowerType(), - OldSummon->GetMaxPower(OldSummon->GetPowerType())); + OldSummon->SetPower(OldSummon->GetPowerType(), OldSummon->GetMaxPower(OldSummon->GetPowerType())); } if (owner->GetTypeId() == TYPEID_PLAYER && OldSummon->isControlled()) @@ -2718,7 +2703,7 @@ void Spell::EffectWeaponDmg(SpellEffIndex effIndex) useWeaponDamage = false; // some spell specific modifiers - float totalDamagePercentMod = 1.0f; // applied to final bonus+weapon damage + float totalDamagePercentMod = 1.0f; // applied to final bonus+weapon damage int32 fixed_bonus = 0; bool normalized = false; @@ -2727,19 +2712,19 @@ void Spell::EffectWeaponDmg(SpellEffIndex effIndex) { switch (m_spellInfo->Effects[j].Effect) { - case SPELL_EFFECT_WEAPON_DAMAGE: - case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL: - fixed_bonus += damage; - break; - case SPELL_EFFECT_NORMALIZED_WEAPON_DMG: - fixed_bonus += damage; - normalized = true; - break; - case SPELL_EFFECT_WEAPON_PERCENT_DAMAGE: - ApplyPct(weaponDamagePercentMod, damage); - break; - default: - break; // not weapon damage effect, just skip + case SPELL_EFFECT_WEAPON_DAMAGE: + case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL: + fixed_bonus += damage; + break; + case SPELL_EFFECT_NORMALIZED_WEAPON_DMG: + fixed_bonus += damage; + normalized = true; + break; + case SPELL_EFFECT_WEAPON_PERCENT_DAMAGE: + ApplyPct(weaponDamagePercentMod, damage); + break; + default: + break; // not weapon damage effect, just skip } } @@ -2747,105 +2732,104 @@ void Spell::EffectWeaponDmg(SpellEffIndex effIndex) { switch (m_spellInfo->SpellFamilyName) { - case SPELLFAMILY_ROGUE: + case SPELLFAMILY_ROGUE: + { + // Hemorrhage + if (m_spellInfo->SpellFamilyFlags[0] & 0x2000000) { - // Hemorrhage - if (m_spellInfo->SpellFamilyFlags[0] & 0x2000000) - { - if (m_caster->GetTypeId() == TYPEID_PLAYER) - m_caster->ToPlayer()->AddComboPoints(unitTarget, 1, this); - // 45% more damage with daggers - if (m_caster->GetTypeId() == TYPEID_PLAYER) - if (Item* item = m_caster->ToPlayer()->GetWeaponForAttack(m_attackType, true)) - if (item->GetTemplate()->GetSubClass() == ITEM_SUBCLASS_WEAPON_DAGGER) - totalDamagePercentMod *= 1.45f; - } - break; + if (m_caster->GetTypeId() == TYPEID_PLAYER) + m_caster->ToPlayer()->AddComboPoints(unitTarget, 1, this); + // 45% more damage with daggers + if (m_caster->GetTypeId() == TYPEID_PLAYER) + if (Item* item = m_caster->ToPlayer()->GetWeaponForAttack(m_attackType, true)) + if (item->GetTemplate()->GetSubClass() == ITEM_SUBCLASS_WEAPON_DAGGER) + totalDamagePercentMod *= 1.45f; } - case SPELLFAMILY_SHAMAN: + break; + } + case SPELLFAMILY_SHAMAN: + { + // Skyshatter Harness item set bonus + // Stormstrike + if (AuraEffect* aurEff = m_caster->IsScriptOverriden(m_spellInfo, 5634)) + m_caster->CastSpell(m_caster, 38430, aurEff); + break; + } + case SPELLFAMILY_DRUID: + { + // Mangle (Cat): CP + if (m_spellInfo->SpellFamilyFlags[1] & 0x400) + m_caster->CastSpell(unitTarget, 34071, true); + // Shred, Maul - Rend and Tear + else if (m_spellInfo->SpellFamilyFlags[0] & 0x00008800 && unitTarget->HasAuraState(AURA_STATE_BLEEDING)) { - // Skyshatter Harness item set bonus - // Stormstrike - if (AuraEffect* aurEff = m_caster->IsScriptOverriden(m_spellInfo, 5634)) - m_caster->CastSpell(m_caster, 38430, aurEff); - break; + if (AuraEffect const* rendAndTear = m_caster->GetDummyAuraEffect(SPELLFAMILY_DRUID, 2859, 0)) + AddPct(totalDamagePercentMod, rendAndTear->GetAmount()); } - case SPELLFAMILY_DRUID: + break; + } + case SPELLFAMILY_DEATHKNIGHT: + { + // Death Strike + if (m_spellInfo->SpellFamilyFlags[0] & 0x10) { - // Mangle (Cat): CP - if (m_spellInfo->SpellFamilyFlags[1] & 0x400) - m_caster->CastSpell(unitTarget, 34071, true); - // Shred, Maul - Rend and Tear - else if (m_spellInfo->SpellFamilyFlags[0] & 0x00008800 && unitTarget->HasAuraState(AURA_STATE_BLEEDING)) - { - if (AuraEffect const* rendAndTear = m_caster->GetDummyAuraEffect(SPELLFAMILY_DRUID, 2859, 0)) - AddPct(totalDamagePercentMod, rendAndTear->GetAmount()); - } - break; + // Glyph of Death Strike + // 2% more damage per 5 runic power, up to a maximum of 40% + if (AuraEffect const* aurEff = m_caster->GetAuraEffect(59336, EFFECT_0)) + if (uint32 runic = std::min(uint32(m_caster->GetPower(POWER_RUNIC_POWER) / 2.5f), aurEff->GetSpellInfo()->Effects[EFFECT_1].CalcValue(m_caster))) + AddPct(totalDamagePercentMod, runic); } - case SPELLFAMILY_DEATHKNIGHT: - { - // Death Strike - if (m_spellInfo->SpellFamilyFlags[0] & 0x10) - { - // Glyph of Death Strike - // 2% more damage per 5 runic power, up to a maximum of 40% - if (AuraEffect const* aurEff = m_caster->GetAuraEffect(59336, EFFECT_0)) - if (uint32 runic = std::min(uint32(m_caster->GetPower(POWER_RUNIC_POWER) / 2.5f), aurEff->GetSpellInfo()->Effects[EFFECT_1].CalcValue(m_caster))) - AddPct(totalDamagePercentMod, runic); - } - // Obliterate / Blood Strike / Blood-Caked Strike (12.5% more damage per disease) / Heart Strike (15% more damage per disease) - if (m_spellInfo->SpellFamilyFlags[1] & 0x20000 || m_spellInfo->SpellFamilyFlags[0] & 0x400000 - || m_spellInfo->SpellFamilyFlags[0] & 0x1000000 || m_spellInfo->Id == 50463) - { - float bonusPct = m_spellInfo->Effects[EFFECT_2].CalcValue(m_caster); - uint8 diseaseCount = unitTarget->GetDiseasesByCaster(m_caster->GetGUID(), false); + // Obliterate / Blood Strike / Blood-Caked Strike (12.5% more damage per disease) / Heart Strike (15% more damage per disease) + if (m_spellInfo->SpellFamilyFlags[1] & 0x20000 || m_spellInfo->SpellFamilyFlags[0] & 0x400000 || m_spellInfo->SpellFamilyFlags[0] & 0x1000000 || m_spellInfo->Id == 50463) + { + float bonusPct = m_spellInfo->Effects[EFFECT_2].CalcValue(m_caster); + uint8 diseaseCount = unitTarget->GetDiseasesByCaster(m_caster->GetGUID(), false); - if (m_spellInfo->SpellFamilyFlags[1] & 0x20000) // Obliterate - 50% of Basepoints as bonus - bonusPct *= 0.5f; - else if (m_spellInfo->SpellFamilyFlags[0] & 0x400000) // Blood Strike - 10% of Basepoints as bonus - bonusPct *= 0.1f; + if (m_spellInfo->SpellFamilyFlags[1] & 0x20000) // Obliterate - 50% of Basepoints as bonus + bonusPct *= 0.5f; + else if (m_spellInfo->SpellFamilyFlags[0] & 0x400000) // Blood Strike - 10% of Basepoints as bonus + bonusPct *= 0.1f; - float bonusAmount = bonusPct * diseaseCount; - // Death Knight T8 Melee 4P Bonus - if (AuraEffect const* aurEff = m_caster->GetAuraEffect(64736, EFFECT_0)) - AddPct(bonusAmount, aurEff->GetAmount()); + float bonusAmount = bonusPct * diseaseCount; + // Death Knight T8 Melee 4P Bonus + if (AuraEffect const* aurEff = m_caster->GetAuraEffect(64736, EFFECT_0)) + AddPct(bonusAmount, aurEff->GetAmount()); - AddPct(totalDamagePercentMod, bonusAmount); - } + AddPct(totalDamagePercentMod, bonusAmount); + } - // Blood-Caked Strike - Blood-Caked Blade - if (m_spellInfo->SpellIconID == 1736) - AddPct(totalDamagePercentMod, unitTarget->GetDiseasesByCaster(m_caster->GetGUID()) * 50.0f); + // Blood-Caked Strike - Blood-Caked Blade + if (m_spellInfo->SpellIconID == 1736) + AddPct(totalDamagePercentMod, unitTarget->GetDiseasesByCaster(m_caster->GetGUID()) * 50.0f); - // Merciless Combat (Obliterate and Frost Strike) - if (m_spellInfo->SpellFamilyFlags[1] & 0x20000 || m_spellInfo->SpellFamilyFlags[1] & 0x4) - if (unitTarget->GetHealthPct() < 35.0f) - if (AuraEffect const* mercilessCombat = m_caster->GetDummyAuraEffect(SPELLFAMILY_DEATHKNIGHT, 2656, 0)) - AddPct(totalDamagePercentMod, mercilessCombat->GetAmount()); - break; - } - case SPELLFAMILY_WARLOCK: + // Merciless Combat (Obliterate and Frost Strike) + if (m_spellInfo->SpellFamilyFlags[1] & 0x20000 || m_spellInfo->SpellFamilyFlags[1] & 0x4) + if (unitTarget->GetHealthPct() < 35.0f) + if (AuraEffect const* mercilessCombat = m_caster->GetDummyAuraEffect(SPELLFAMILY_DEATHKNIGHT, 2656, 0)) + AddPct(totalDamagePercentMod, mercilessCombat->GetAmount()); + break; + } + case SPELLFAMILY_WARLOCK: + { + if (useWeaponDamage) { - if (useWeaponDamage) + // Felstorm and Legion Strike + if (m_spellInfo->Id == 89753) { - // Felstorm and Legion Strike - if (m_spellInfo->Id == 89753) - { - if (m_caster->IsPet()) - if (Unit* owner = m_caster->GetOwner()) - m_damage += ((owner->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_SHADOW) * 0.5f) * 2) * 0.231f; - } - else if (m_spellInfo->Id == 30213) - { - if (m_caster->IsPet()) - if (Unit* owner = m_caster->GetOwner()) - m_damage += ((owner->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_SHADOW) * 0.5f) * 2) * 0.264f; - } + if (m_caster->IsPet()) + if (Unit* owner = m_caster->GetOwner()) + m_damage += ((owner->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_SHADOW) * 0.5f) * 2) * 0.231f; + } + else if (m_spellInfo->Id == 30213) + { + if (m_caster->IsPet()) + if (Unit* owner = m_caster->GetOwner()) + m_damage += ((owner->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_SHADOW) * 0.5f) * 2) * 0.264f; } - break; } + break; + } } } @@ -2857,10 +2841,16 @@ void Spell::EffectWeaponDmg(SpellEffIndex effIndex) UnitMods unitMod; switch (m_attackType) { - default: - case BASE_ATTACK: unitMod = UNIT_MOD_DAMAGE_MAINHAND; break; - case OFF_ATTACK: unitMod = UNIT_MOD_DAMAGE_OFFHAND; break; - case RANGED_ATTACK: unitMod = UNIT_MOD_DAMAGE_RANGED; break; + default: + case BASE_ATTACK: + unitMod = UNIT_MOD_DAMAGE_MAINHAND; + break; + case OFF_ATTACK: + unitMod = UNIT_MOD_DAMAGE_OFFHAND; + break; + case RANGED_ATTACK: + unitMod = UNIT_MOD_DAMAGE_RANGED; + break; } float weapon_total_pct = m_caster->GetPctModifierValue(unitMod, TOTAL_PCT); @@ -2872,16 +2862,16 @@ void Spell::EffectWeaponDmg(SpellEffIndex effIndex) switch (effectType) { - case SPELL_EFFECT_WEAPON_DAMAGE: - case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL: - case SPELL_EFFECT_NORMALIZED_WEAPON_DMG: - weaponDamage += fixed_bonus; - break; - case SPELL_EFFECT_WEAPON_PERCENT_DAMAGE: - weaponDamage = int32(weaponDamage * weaponDamagePercentMod); - break; - default: - break; + case SPELL_EFFECT_WEAPON_DAMAGE: + case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL: + case SPELL_EFFECT_NORMALIZED_WEAPON_DMG: + weaponDamage += fixed_bonus; + break; + case SPELL_EFFECT_WEAPON_PERCENT_DAMAGE: + weaponDamage = int32(weaponDamage * weaponDamagePercentMod); + break; + default: + break; } weaponDamage = int32(weaponDamage * totalDamagePercentMod); @@ -2948,9 +2938,7 @@ void Spell::EffectInterruptCast(SpellEffIndex effIndex) { SpellInfo const* curSpellInfo = spell->m_spellInfo; // check if we can interrupt spell - if ((spell->getState() == SPELL_STATE_CASTING - || (spell->getState() == SPELL_STATE_PREPARING && spell->GetCastTime() > 0.0f)) - && curSpellInfo->CanBeInterrupted(unitTarget)) + if ((spell->getState() == SPELL_STATE_CASTING || (spell->getState() == SPELL_STATE_PREPARING && spell->GetCastTime() > 0.0f)) && curSpellInfo->CanBeInterrupted(unitTarget)) { int32 duration = m_spellInfo->GetDuration(); duration = unitTarget->ModSpellDuration(m_spellInfo, unitTarget, duration, false, 1 << effIndex); @@ -2991,8 +2979,7 @@ void Spell::EffectSummonObjectWild(SpellEffIndex effIndex) Map* map = target->GetMap(); - if (!pGameObj->Create(map->GenerateLowGuid(), gameobject_id, map, - Position(x, y, z, o), rot, 255, GO_STATE_READY)) + if (!pGameObj->Create(map->GenerateLowGuid(), gameobject_id, map, Position(x, y, z, o), rot, 255, GO_STATE_READY)) { delete pGameObj; return; @@ -3002,7 +2989,7 @@ void Spell::EffectSummonObjectWild(SpellEffIndex effIndex) int32 duration = m_spellInfo->GetDuration(); - pGameObj->SetRespawnTime(duration > 0 ? duration/IN_MILLISECONDS : 0); + pGameObj->SetRespawnTime(duration > 0 ? duration / IN_MILLISECONDS : 0); pGameObj->SetSpellId(m_spellInfo->Id); ExecuteLogEffectSummonObject(effIndex, pGameObj); @@ -3013,7 +3000,7 @@ void Spell::EffectSummonObjectWild(SpellEffIndex effIndex) if (pGameObj->GetGoType() == GAMEOBJECT_TYPE_FLAGDROP) if (Player* player = m_caster->ToPlayer()) if (Battleground* bg = player->GetBattleground()) - bg->SetDroppedFlagGUID(pGameObj->GetGUID(), player->GetTeam() == ALLIANCE ? TEAM_HORDE: TEAM_ALLIANCE); + bg->SetDroppedFlagGUID(pGameObj->GetGUID(), player->GetTeam() == ALLIANCE ? TEAM_HORDE : TEAM_ALLIANCE); if (GameObject* linkedTrap = pGameObj->GetLinkedTrap()) { @@ -3048,450 +3035,513 @@ void Spell::EffectScriptEffect(SpellEffIndex effIndex) switch (m_spellInfo->SpellFamilyName) { - case SPELLFAMILY_GENERIC: + case SPELLFAMILY_GENERIC: + { + switch (m_spellInfo->Id) + { + // Glyph of Scourge Strike + case 69961: { - switch (m_spellInfo->Id) + Unit::AuraEffectList const& mPeriodic = unitTarget->GetAuraEffectsByType(SPELL_AURA_PERIODIC_DAMAGE); + for (Unit::AuraEffectList::const_iterator i = mPeriodic.begin(); i != mPeriodic.end(); ++i) { - // Glyph of Scourge Strike - case 69961: + AuraEffect const* aurEff = *i; + SpellInfo const* spellInfo = aurEff->GetSpellInfo(); + // search our Blood Plague and Frost Fever on target + if (spellInfo->SpellFamilyName == SPELLFAMILY_DEATHKNIGHT && spellInfo->SpellFamilyFlags[2] & 0x2 && aurEff->GetCasterGUID() == m_caster->GetGUID()) { - Unit::AuraEffectList const &mPeriodic = unitTarget->GetAuraEffectsByType(SPELL_AURA_PERIODIC_DAMAGE); - for (Unit::AuraEffectList::const_iterator i = mPeriodic.begin(); i != mPeriodic.end(); ++i) + uint32 countMin = aurEff->GetBase()->GetMaxDuration(); + uint32 countMax = spellInfo->GetMaxDuration(); + + // this Glyph + countMax += 9000; + // talent Epidemic + if (AuraEffect const* epidemic = m_caster->GetAuraEffect(SPELL_AURA_ADD_FLAT_MODIFIER, SPELLFAMILY_DEATHKNIGHT, 234, EFFECT_0)) + countMax += epidemic->GetAmount(); + + if (countMin < countMax) { - AuraEffect const* aurEff = *i; - SpellInfo const* spellInfo = aurEff->GetSpellInfo(); - // search our Blood Plague and Frost Fever on target - if (spellInfo->SpellFamilyName == SPELLFAMILY_DEATHKNIGHT && spellInfo->SpellFamilyFlags[2] & 0x2 && - aurEff->GetCasterGUID() == m_caster->GetGUID()) - { - uint32 countMin = aurEff->GetBase()->GetMaxDuration(); - uint32 countMax = spellInfo->GetMaxDuration(); - - // this Glyph - countMax += 9000; - // talent Epidemic - if (AuraEffect const* epidemic = m_caster->GetAuraEffect(SPELL_AURA_ADD_FLAT_MODIFIER, SPELLFAMILY_DEATHKNIGHT, 234, EFFECT_0)) - countMax += epidemic->GetAmount(); - - if (countMin < countMax) - { - aurEff->GetBase()->SetDuration(aurEff->GetBase()->GetDuration() + 3000); - aurEff->GetBase()->SetMaxDuration(countMin + 3000); - } - } + aurEff->GetBase()->SetDuration(aurEff->GetBase()->GetDuration() + 3000); + aurEff->GetBase()->SetMaxDuration(countMin + 3000); } - return; } - case 55693: // Remove Collapsing Cave Aura - if (!unitTarget) - return; - unitTarget->RemoveAurasDueToSpell(m_spellInfo->Effects[effIndex].CalcValue()); - break; - // Bending Shinbone - case 8856: - { - if (!itemTarget && m_caster->GetTypeId() != TYPEID_PLAYER) - return; + } + return; + } + case 55693: // Remove Collapsing Cave Aura + if (!unitTarget) + return; + unitTarget->RemoveAurasDueToSpell(m_spellInfo->Effects[effIndex].CalcValue()); + break; + // Bending Shinbone + case 8856: + { + if (!itemTarget && m_caster->GetTypeId() != TYPEID_PLAYER) + return; - uint32 spell_id = roll_chance_i(20) ? 8854 : 8855; - m_caster->CastSpell(m_caster, spell_id, true); - return; - } - // Brittle Armor - need remove one 24575 Brittle Armor aura - case 24590: - unitTarget->RemoveAuraFromStack(24575); - return; - // Mercurial Shield - need remove one 26464 Mercurial Shield aura - case 26465: - unitTarget->RemoveAuraFromStack(26464); - return; - // Shadow Flame (All script effects, not just end ones to prevent player from dodging the last triggered spell) - case 22539: - case 22972: - case 22975: - case 22976: - case 22977: - case 22978: - case 22979: - case 22980: - case 22981: - case 22982: - case 22983: - case 22984: - case 22985: - { - if (!unitTarget || !unitTarget->IsAlive()) - return; + uint32 spell_id = roll_chance_i(20) ? 8854 : 8855; + m_caster->CastSpell(m_caster, spell_id, true); + return; + } + // Brittle Armor - need remove one 24575 Brittle Armor aura + case 24590: + unitTarget->RemoveAuraFromStack(24575); + return; + // Mercurial Shield - need remove one 26464 Mercurial Shield aura + case 26465: + unitTarget->RemoveAuraFromStack(26464); + return; + // Shadow Flame (All script effects, not just end ones to prevent player from dodging the last triggered spell) + case 22539: + case 22972: + case 22975: + case 22976: + case 22977: + case 22978: + case 22979: + case 22980: + case 22981: + case 22982: + case 22983: + case 22984: + case 22985: + { + if (!unitTarget || !unitTarget->IsAlive()) + return; - // Onyxia Scale Cloak - if (unitTarget->HasAura(22683)) - return; + // Onyxia Scale Cloak + if (unitTarget->HasAura(22683)) + return; - // Shadow Flame - m_caster->CastSpell(unitTarget, 22682, true); - return; - } - // Mirren's Drinking Hat - case 29830: - { - uint32 item = 0; - switch (urand(1, 6)) - { - case 1: - case 2: - case 3: - item = 23584; break; // Loch Modan Lager - case 4: - case 5: - item = 23585; break; // Stouthammer Lite - case 6: - item = 23586; break; // Aerie Peak Pale Ale - } - if (item) - DoCreateItem(effIndex, item); - break; - } - case 20589: // Escape artist - case 30918: // Improved Sprint - { - // Removes snares and roots. - unitTarget->RemoveMovementImpairingAuras(true); - break; - } - // Plant Warmaul Ogre Banner - case 32307: - if (Player* caster = m_caster->ToPlayer()) - { - caster->RewardPlayerAndGroupAtEvent(18388, unitTarget); - if (Creature* target = unitTarget->ToCreature()) - target->DespawnOrUnsummon(); - } - break; - // Mug Transformation - case 41931: - { - if (m_caster->GetTypeId() != TYPEID_PLAYER) - return; + // Shadow Flame + m_caster->CastSpell(unitTarget, 22682, true); + return; + } + // Mirren's Drinking Hat + case 29830: + { + uint32 item = 0; + switch (urand(1, 6)) + { + case 1: + case 2: + case 3: + item = 23584; + break; // Loch Modan Lager + case 4: + case 5: + item = 23585; + break; // Stouthammer Lite + case 6: + item = 23586; + break; // Aerie Peak Pale Ale + } + if (item) + DoCreateItem(effIndex, item); + break; + } + case 20589: // Escape artist + case 30918: // Improved Sprint + { + // Removes snares and roots. + unitTarget->RemoveMovementImpairingAuras(true); + break; + } + // Plant Warmaul Ogre Banner + case 32307: + if (Player* caster = m_caster->ToPlayer()) + { + caster->RewardPlayerAndGroupAtEvent(18388, unitTarget); + if (Creature* target = unitTarget->ToCreature()) + target->DespawnOrUnsummon(); + } + break; + // Mug Transformation + case 41931: + { + if (m_caster->GetTypeId() != TYPEID_PLAYER) + return; - uint8 bag = 19; - uint8 slot = 0; - Item* item = nullptr; + uint8 bag = 19; + uint8 slot = 0; + Item* item = nullptr; - while (bag) // 256 = 0 due to var type - { - item = m_caster->ToPlayer()->GetItemByPos(bag, slot); - if (item && item->GetEntry() == 38587) - break; - - ++slot; - if (slot == 39) - { - slot = 0; - ++bag; - } - } - if (bag) - { - if (m_caster->ToPlayer()->GetItemByPos(bag, slot)->GetCount() == 1) m_caster->ToPlayer()->RemoveItem(bag, slot, true); - else m_caster->ToPlayer()->GetItemByPos(bag, slot)->SetCount(m_caster->ToPlayer()->GetItemByPos(bag, slot)->GetCount()-1); - // Spell 42518 (Braufest - Gratisprobe des Braufest herstellen) - m_caster->CastSpell(m_caster, 42518, true); - return; - } + while (bag) // 256 = 0 due to var type + { + item = m_caster->ToPlayer()->GetItemByPos(bag, slot); + if (item && item->GetEntry() == 38587) break; - } - // Brutallus - Burn - case 45141: - case 45151: - { - //Workaround for Range ... should be global for every ScriptEffect - float radius = m_spellInfo->Effects[effIndex].CalcRadius(); - if (unitTarget && unitTarget->GetTypeId() == TYPEID_PLAYER && unitTarget->GetDistance(m_caster) >= radius && !unitTarget->HasAura(46394) && unitTarget != m_caster) - unitTarget->CastSpell(unitTarget, 46394, true); - break; - } - // Goblin Weather Machine - case 46203: + ++slot; + if (slot == 39) { - if (!unitTarget) - return; - - uint32 spellId = 0; - switch (rand32() % 4) - { - case 0: spellId = 46740; break; - case 1: spellId = 46739; break; - case 2: spellId = 46738; break; - case 3: spellId = 46736; break; - } - unitTarget->CastSpell(unitTarget, spellId, true); - break; + slot = 0; + ++bag; } - // 5, 000 Gold - case 46642: - { - if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) - return; + } + if (bag) + { + if (m_caster->ToPlayer()->GetItemByPos(bag, slot)->GetCount() == 1) + m_caster->ToPlayer()->RemoveItem(bag, slot, true); + else + m_caster->ToPlayer()->GetItemByPos(bag, slot)->SetCount(m_caster->ToPlayer()->GetItemByPos(bag, slot)->GetCount() - 1); + // Spell 42518 (Braufest - Gratisprobe des Braufest herstellen) + m_caster->CastSpell(m_caster, 42518, true); + return; + } + break; + } + // Brutallus - Burn + case 45141: + case 45151: + { + // Workaround for Range ... should be global for every ScriptEffect + float radius = m_spellInfo->Effects[effIndex].CalcRadius(); + if (unitTarget && unitTarget->GetTypeId() == TYPEID_PLAYER && unitTarget->GetDistance(m_caster) >= radius && !unitTarget->HasAura(46394) && unitTarget != m_caster) + unitTarget->CastSpell(unitTarget, 46394, true); - unitTarget->ToPlayer()->ModifyMoney(5000 * GOLD); + break; + } + // Goblin Weather Machine + case 46203: + { + if (!unitTarget) + return; - break; - } - // Death Knight Initiate Visual - case 51519: - { - if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT) - return; + uint32 spellId = 0; + switch (rand32() % 4) + { + case 0: + spellId = 46740; + break; + case 1: + spellId = 46739; + break; + case 2: + spellId = 46738; + break; + case 3: + spellId = 46736; + break; + } + unitTarget->CastSpell(unitTarget, spellId, true); + break; + } + // 5, 000 Gold + case 46642: + { + if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + return; - uint32 iTmpSpellId = 0; - switch (unitTarget->GetDisplayId()) - { - case 25369: iTmpSpellId = 51552; break; // bloodelf female - case 25373: iTmpSpellId = 51551; break; // bloodelf male - case 25363: iTmpSpellId = 51542; break; // draenei female - case 25357: iTmpSpellId = 51541; break; // draenei male - case 25361: iTmpSpellId = 51537; break; // dwarf female - case 25356: iTmpSpellId = 51538; break; // dwarf male - case 25372: iTmpSpellId = 51550; break; // forsaken female - case 25367: iTmpSpellId = 51549; break; // forsaken male - case 25362: iTmpSpellId = 51540; break; // gnome female - case 25359: iTmpSpellId = 51539; break; // gnome male - case 25355: iTmpSpellId = 51534; break; // human female - case 25354: iTmpSpellId = 51520; break; // human male - case 25360: iTmpSpellId = 51536; break; // nightelf female - case 25358: iTmpSpellId = 51535; break; // nightelf male - case 25368: iTmpSpellId = 51544; break; // orc female - case 25364: iTmpSpellId = 51543; break; // orc male - case 25371: iTmpSpellId = 51548; break; // tauren female - case 25366: iTmpSpellId = 51547; break; // tauren male - case 25370: iTmpSpellId = 51545; break; // troll female - case 25365: iTmpSpellId = 51546; break; // troll male - default: return; - } + unitTarget->ToPlayer()->ModifyMoney(5000 * GOLD); - unitTarget->CastSpell(unitTarget, iTmpSpellId, true); - Creature* npc = unitTarget->ToCreature(); - npc->LoadEquipment(); - return; - } - // Deathbolt from Thalgran Blightbringer - // reflected by Freya's Ward - // Retribution by Sevenfold Retribution - case 51854: - { - if (!unitTarget) - return; - if (unitTarget->HasAura(51845)) - unitTarget->CastSpell(m_caster, 51856, true); - else - m_caster->CastSpell(unitTarget, 51855, true); - break; - } - // Summon Ghouls On Scarlet Crusade - case 51904: - { - if (!m_targets.HasDst()) - return; + break; + } + // Death Knight Initiate Visual + case 51519: + { + if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT) + return; - float x, y, z; - float radius = m_spellInfo->Effects[effIndex].CalcRadius(); - for (uint8 i = 0; i < 15; ++i) - { - m_caster->GetRandomPoint(*destTarget, radius, x, y, z); - m_caster->CastSpell({ x, y, z }, 54522, true); - } - break; - } - case 52173: // Coyote Spirit Despawn - case 60243: // Blood Parrot Despawn - if (unitTarget->GetTypeId() == TYPEID_UNIT && unitTarget->IsSummon()) - unitTarget->ToTempSummon()->UnSummon(); - return; - case 53110: // Devour Humanoid - if (unitTarget) - unitTarget->CastSpell(m_caster, damage, true); - return; - case 57347: // Retrieving (Wintergrasp RP-GG pickup spell) - { - if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT || m_caster->GetTypeId() != TYPEID_PLAYER) - return; + uint32 iTmpSpellId = 0; + switch (unitTarget->GetDisplayId()) + { + case 25369: + iTmpSpellId = 51552; + break; // bloodelf female + case 25373: + iTmpSpellId = 51551; + break; // bloodelf male + case 25363: + iTmpSpellId = 51542; + break; // draenei female + case 25357: + iTmpSpellId = 51541; + break; // draenei male + case 25361: + iTmpSpellId = 51537; + break; // dwarf female + case 25356: + iTmpSpellId = 51538; + break; // dwarf male + case 25372: + iTmpSpellId = 51550; + break; // forsaken female + case 25367: + iTmpSpellId = 51549; + break; // forsaken male + case 25362: + iTmpSpellId = 51540; + break; // gnome female + case 25359: + iTmpSpellId = 51539; + break; // gnome male + case 25355: + iTmpSpellId = 51534; + break; // human female + case 25354: + iTmpSpellId = 51520; + break; // human male + case 25360: + iTmpSpellId = 51536; + break; // nightelf female + case 25358: + iTmpSpellId = 51535; + break; // nightelf male + case 25368: + iTmpSpellId = 51544; + break; // orc female + case 25364: + iTmpSpellId = 51543; + break; // orc male + case 25371: + iTmpSpellId = 51548; + break; // tauren female + case 25366: + iTmpSpellId = 51547; + break; // tauren male + case 25370: + iTmpSpellId = 51545; + break; // troll female + case 25365: + iTmpSpellId = 51546; + break; // troll male + default: + return; + } - unitTarget->ToCreature()->DespawnOrUnsummon(); + unitTarget->CastSpell(unitTarget, iTmpSpellId, true); + Creature* npc = unitTarget->ToCreature(); + npc->LoadEquipment(); + return; + } + // Deathbolt from Thalgran Blightbringer + // reflected by Freya's Ward + // Retribution by Sevenfold Retribution + case 51854: + { + if (!unitTarget) + return; + if (unitTarget->HasAura(51845)) + unitTarget->CastSpell(m_caster, 51856, true); + else + m_caster->CastSpell(unitTarget, 51855, true); + break; + } + // Summon Ghouls On Scarlet Crusade + case 51904: + { + if (!m_targets.HasDst()) + return; - return; - } - case 57349: // Drop RP-GG (Wintergrasp RP-GG at death drop spell) - { - if (m_caster->GetTypeId() != TYPEID_PLAYER) - return; + float x, y, z; + float radius = m_spellInfo->Effects[effIndex].CalcRadius(); + for (uint8 i = 0; i < 15; ++i) + { + m_caster->GetRandomPoint(*destTarget, radius, x, y, z); + m_caster->CastSpell({x, y, z}, 54522, true); + } + break; + } + case 52173: // Coyote Spirit Despawn + case 60243: // Blood Parrot Despawn + if (unitTarget->GetTypeId() == TYPEID_UNIT && unitTarget->IsSummon()) + unitTarget->ToTempSummon()->UnSummon(); + return; + case 53110: // Devour Humanoid + if (unitTarget) + unitTarget->CastSpell(m_caster, damage, true); + return; + case 57347: // Retrieving (Wintergrasp RP-GG pickup spell) + { + if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT || m_caster->GetTypeId() != TYPEID_PLAYER) + return; - // Delete item from inventory at death - m_caster->ToPlayer()->DestroyItemCount(damage, 5, true); + unitTarget->ToCreature()->DespawnOrUnsummon(); - return; - } - case 58418: // Portal to Orgrimmar - case 58420: // Portal to Stormwind - { - if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER || effIndex != 0) - return; + return; + } + case 57349: // Drop RP-GG (Wintergrasp RP-GG at death drop spell) + { + if (m_caster->GetTypeId() != TYPEID_PLAYER) + return; - uint32 spellID = m_spellInfo->Effects[EFFECT_0].CalcValue(); - uint32 questID = m_spellInfo->Effects[EFFECT_1].CalcValue(); + // Delete item from inventory at death + m_caster->ToPlayer()->DestroyItemCount(damage, 5, true); - if (unitTarget->ToPlayer()->GetQuestStatus(questID) == QUEST_STATUS_COMPLETE) - unitTarget->CastSpell(unitTarget, spellID, true); + return; + } + case 58418: // Portal to Orgrimmar + case 58420: // Portal to Stormwind + { + if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER || effIndex != 0) + return; - return; - } - case 58983: // Big Blizzard Bear - { - if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) - return; + uint32 spellID = m_spellInfo->Effects[EFFECT_0].CalcValue(); + uint32 questID = m_spellInfo->Effects[EFFECT_1].CalcValue(); - // Prevent stacking of mounts and client crashes upon dismounting - unitTarget->RemoveAurasByType(SPELL_AURA_MOUNTED); + if (unitTarget->ToPlayer()->GetQuestStatus(questID) == QUEST_STATUS_COMPLETE) + unitTarget->CastSpell(unitTarget, spellID, true); - // Triggered spell id dependent on riding skill - if (uint16 skillval = unitTarget->ToPlayer()->GetSkillValue(SKILL_RIDING)) - { - if (skillval >= 150) - unitTarget->CastSpell(unitTarget, 58999, true); - else - unitTarget->CastSpell(unitTarget, 58997, true); - } - return; - } - case 59317: // Teleporting - { + return; + } + case 58983: // Big Blizzard Bear + { + if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + return; - if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) - return; + // Prevent stacking of mounts and client crashes upon dismounting + unitTarget->RemoveAurasByType(SPELL_AURA_MOUNTED); - // return from top - if (unitTarget->ToPlayer()->GetAreaId() == 4637) - unitTarget->CastSpell(unitTarget, 59316, true); - // teleport atop - else - unitTarget->CastSpell(unitTarget, 59314, true); + // Triggered spell id dependent on riding skill + if (uint16 skillval = unitTarget->ToPlayer()->GetSkillValue(SKILL_RIDING)) + { + if (skillval >= 150) + unitTarget->CastSpell(unitTarget, 58999, true); + else + unitTarget->CastSpell(unitTarget, 58997, true); + } + return; + } + case 59317: // Teleporting + { - return; - } - case 62482: // Grab Crate + if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + return; + + // return from top + if (unitTarget->ToPlayer()->GetAreaId() == 4637) + unitTarget->CastSpell(unitTarget, 59316, true); + // teleport atop + else + unitTarget->CastSpell(unitTarget, 59314, true); + + return; + } + case 62482: // Grab Crate + { + if (unitTarget) + { + if (Unit* seat = m_caster->GetVehicleBase()) { - if (unitTarget) + if (Unit* parent = seat->GetVehicleBase()) { - if (Unit* seat = m_caster->GetVehicleBase()) - { - if (Unit* parent = seat->GetVehicleBase()) - { - /// @todo a hack, range = 11, should after some time cast, otherwise too far - m_caster->CastSpell(parent, 62496, true); - unitTarget->CastSpell(parent, m_spellInfo->Effects[EFFECT_0].CalcValue()); - } - } + /// @todo a hack, range = 11, should after some time cast, otherwise too far + m_caster->CastSpell(parent, 62496, true); + unitTarget->CastSpell(parent, m_spellInfo->Effects[EFFECT_0].CalcValue()); } - return; } - case 60123: // Lightwell - { - if (m_caster->GetTypeId() != TYPEID_UNIT || !m_caster->IsSummon()) - return; + } + return; + } + case 60123: // Lightwell + { + if (m_caster->GetTypeId() != TYPEID_UNIT || !m_caster->IsSummon()) + return; - uint32 spell_heal; + uint32 spell_heal; - switch (m_caster->GetEntry()) - { - case 31897: spell_heal = 7001; break; - case 31896: spell_heal = 27873; break; - case 31895: spell_heal = 27874; break; - case 31894: spell_heal = 28276; break; - case 31893: spell_heal = 48084; break; - case 31883: spell_heal = 48085; break; - default: - LOG_ERROR("spells", "Unknown Lightwell spell caster %u.", m_caster->GetEntry()); - return; - } + switch (m_caster->GetEntry()) + { + case 31897: + spell_heal = 7001; + break; + case 31896: + spell_heal = 27873; + break; + case 31895: + spell_heal = 27874; + break; + case 31894: + spell_heal = 28276; + break; + case 31893: + spell_heal = 48084; + break; + case 31883: + spell_heal = 48085; + break; + default: + LOG_ERROR("spells", "Unknown Lightwell spell caster %u.", m_caster->GetEntry()); + return; + } - // proc a spellcast - if (Aura* chargesAura = m_caster->GetAura(59907)) - { - m_caster->CastSpell(unitTarget, spell_heal, m_caster->ToTempSummon()->GetSummonerGUID()); - if (chargesAura->ModCharges(-1)) - m_caster->ToTempSummon()->UnSummon(); - } + // proc a spellcast + if (Aura* chargesAura = m_caster->GetAura(59907)) + { + m_caster->CastSpell(unitTarget, spell_heal, m_caster->ToTempSummon()->GetSummonerGUID()); + if (chargesAura->ModCharges(-1)) + m_caster->ToTempSummon()->UnSummon(); + } - return; - } - // Stoneclaw Totem - case 55328: // Rank 1 - case 55329: // Rank 2 - case 55330: // Rank 3 - case 55332: // Rank 4 - case 55333: // Rank 5 - case 55335: // Rank 6 - case 55278: // Rank 7 - case 58589: // Rank 8 - case 58590: // Rank 9 - case 58591: // Rank 10 + return; + } + // Stoneclaw Totem + case 55328: // Rank 1 + case 55329: // Rank 2 + case 55330: // Rank 3 + case 55332: // Rank 4 + case 55333: // Rank 5 + case 55335: // Rank 6 + case 55278: // Rank 7 + case 58589: // Rank 8 + case 58590: // Rank 9 + case 58591: // Rank 10 + { + // Cast Absorb on totems + for (uint8 slot = SUMMON_SLOT_TOTEM_FIRE; slot < MAX_TOTEM_SLOT; ++slot) + { + if (!unitTarget->m_SummonSlot[slot]) + continue; + + Creature* totem = unitTarget->GetMap()->GetCreature(unitTarget->m_SummonSlot[slot]); + if (totem && totem->IsTotem()) { - // Cast Absorb on totems - for (uint8 slot = SUMMON_SLOT_TOTEM_FIRE; slot < MAX_TOTEM_SLOT; ++slot) - { - if (!unitTarget->m_SummonSlot[slot]) - continue; - - Creature* totem = unitTarget->GetMap()->GetCreature(unitTarget->m_SummonSlot[slot]); - if (totem && totem->IsTotem()) - { - CastSpellExtraArgs args(TRIGGERED_FULL_MASK); - args.SpellValueOverrides.AddMod(SPELLVALUE_BASE_POINT0, damage); - m_caster->CastSpell(totem, 55277, args); - } - } - // Glyph of Stoneclaw Totem - if (AuraEffect* aur=unitTarget->GetAuraEffect(63298, 0)) - { - CastSpellExtraArgs args(TRIGGERED_FULL_MASK); - args.SpellValueOverrides.AddMod(SPELLVALUE_BASE_POINT0, damage* aur->GetAmount()); - m_caster->CastSpell(unitTarget, 55277, args); - } - break; + CastSpellExtraArgs args(TRIGGERED_FULL_MASK); + args.SpellValueOverrides.AddMod(SPELLVALUE_BASE_POINT0, damage); + m_caster->CastSpell(totem, 55277, args); } - case 45668: // Ultra-Advanced Proto-Typical Shortening Blaster - { - if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT) - return; + } + // Glyph of Stoneclaw Totem + if (AuraEffect* aur = unitTarget->GetAuraEffect(63298, 0)) + { + CastSpellExtraArgs args(TRIGGERED_FULL_MASK); + args.SpellValueOverrides.AddMod(SPELLVALUE_BASE_POINT0, damage * aur->GetAmount()); + m_caster->CastSpell(unitTarget, 55277, args); + } + break; + } + case 45668: // Ultra-Advanced Proto-Typical Shortening Blaster + { + if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT) + return; - if (roll_chance_i(50)) // chance unknown, using 50 - return; + if (roll_chance_i(50)) // chance unknown, using 50 + return; - static uint32 const spellPlayer[5] = - { - 45674, // Bigger! - 45675, // Shrunk - 45678, // Yellow - 45682, // Ghost - 45684 // Polymorph - }; - - static uint32 const spellTarget[5] = - { - 45673, // Bigger! - 45672, // Shrunk - 45677, // Yellow - 45681, // Ghost - 45683 // Polymorph - }; - - m_caster->CastSpell(m_caster, spellPlayer[urand(0, 4)], true); - unitTarget->CastSpell(unitTarget, spellTarget[urand(0, 4)], true); - break; - } - } + static uint32 const spellPlayer[5] = { + 45674, // Bigger! + 45675, // Shrunk + 45678, // Yellow + 45682, // Ghost + 45684 // Polymorph + }; + + static uint32 const spellTarget[5] = { + 45673, // Bigger! + 45672, // Shrunk + 45677, // Yellow + 45681, // Ghost + 45683 // Polymorph + }; + + m_caster->CastSpell(m_caster, spellPlayer[urand(0, 4)], true); + unitTarget->CastSpell(unitTarget, spellTarget[urand(0, 4)], true); break; } + } + break; + } } // normal DB scripted effect @@ -3559,29 +3609,24 @@ void Spell::EffectDuel(SpellEffIndex effIndex) AreaTableEntry const* casterAreaEntry = sAreaTableStore.LookupEntry(caster->GetAreaId()); if (casterAreaEntry && !(casterAreaEntry->Flags & AREA_FLAG_ALLOW_DUELS)) { - SendCastResult(SPELL_FAILED_NO_DUELING); // Dueling isn't allowed here + SendCastResult(SPELL_FAILED_NO_DUELING); // Dueling isn't allowed here return; } AreaTableEntry const* targetAreaEntry = sAreaTableStore.LookupEntry(target->GetAreaId()); if (targetAreaEntry && !(targetAreaEntry->Flags & AREA_FLAG_ALLOW_DUELS)) { - SendCastResult(SPELL_FAILED_NO_DUELING); // Dueling isn't allowed here + SendCastResult(SPELL_FAILED_NO_DUELING); // Dueling isn't allowed here return; } - //CREATE DUEL FLAG OBJECT + // CREATE DUEL FLAG OBJECT GameObject* pGameObj = new GameObject(); uint32 gameobject_id = m_spellInfo->Effects[effIndex].MiscValue; - Position const pos = - { - m_caster->GetPositionX() + (unitTarget->GetPositionX() - m_caster->GetPositionX()) / 2, - m_caster->GetPositionY() + (unitTarget->GetPositionY() - m_caster->GetPositionY()) / 2, - m_caster->GetPositionZ(), - m_caster->GetOrientation() - }; + Position const pos = {m_caster->GetPositionX() + (unitTarget->GetPositionX() - m_caster->GetPositionX()) / 2, + m_caster->GetPositionY() + (unitTarget->GetPositionY() - m_caster->GetPositionY()) / 2, m_caster->GetPositionZ(), m_caster->GetOrientation()}; Map* map = m_caster->GetMap(); if (!pGameObj->Create(map->GenerateLowGuid(), gameobject_id, map, pos, QuaternionData(), 0, GO_STATE_READY)) @@ -3593,16 +3638,16 @@ void Spell::EffectDuel(SpellEffIndex effIndex) PhasingHandler::InheritPhaseShift(pGameObj, m_caster); pGameObj->SetFaction(m_caster->GetFaction()); - pGameObj->SetUInt32Value(GAMEOBJECT_LEVEL, m_caster->getLevel()+1); + pGameObj->SetUInt32Value(GAMEOBJECT_LEVEL, m_caster->getLevel() + 1); int32 duration = m_spellInfo->GetDuration(); - pGameObj->SetRespawnTime(duration > 0 ? duration/IN_MILLISECONDS : 0); + pGameObj->SetRespawnTime(duration > 0 ? duration / IN_MILLISECONDS : 0); pGameObj->SetSpellId(m_spellInfo->Id); ExecuteLogEffectSummonObject(effIndex, pGameObj); m_caster->AddGameObject(pGameObj); map->AddToMap(pGameObj); - //END + // END // Send request WorldPacket data(SMSG_DUEL_REQUESTED, 8 + 8); @@ -3612,21 +3657,21 @@ void Spell::EffectDuel(SpellEffIndex effIndex) target->SendDirectMessage(&data); // create duel-info - DuelInfo* duel = new DuelInfo; - duel->initiator = caster; - duel->opponent = target; - duel->startTime = 0; + DuelInfo* duel = new DuelInfo; + duel->initiator = caster; + duel->opponent = target; + duel->startTime = 0; duel->startTimer = 0; - duel->isMounted = (GetSpellInfo()->Id == 62875); // Mounted Duel - caster->duel = duel; + duel->isMounted = (GetSpellInfo()->Id == 62875); // Mounted Duel + caster->duel = duel; - DuelInfo* duel2 = new DuelInfo; - duel2->initiator = caster; - duel2->opponent = caster; - duel2->startTime = 0; + DuelInfo* duel2 = new DuelInfo; + duel2->initiator = caster; + duel2->opponent = caster; + duel2->startTime = 0; duel2->startTimer = 0; - duel2->isMounted = (GetSpellInfo()->Id == 62875); // Mounted Duel - target->duel = duel2; + duel2->isMounted = (GetSpellInfo()->Id == 62875); // Mounted Duel + target->duel = duel2; caster->SetGuidValue(PLAYER_DUEL_ARBITER, pGameObj->GetGUID()); target->SetGuidValue(PLAYER_DUEL_ARBITER, pGameObj->GetGUID()); @@ -3647,7 +3692,8 @@ void Spell::EffectStuck(SpellEffIndex /*effIndex*/) return; LOG_DEBUG("spells", "Spell Effect: Stuck"); - LOG_DEBUG("spells", "Player %s (guid %u) used the auto-unstuck feature at map %u (%f, %f, %f).", player->GetName().c_str(), player->GetGUID().GetCounter(), player->GetMapId(), player->GetPositionX(), player->GetPositionY(), player->GetPositionZ()); + LOG_DEBUG("spells", "Player %s (guid %u) used the auto-unstuck feature at map %u (%f, %f, %f).", player->GetName().c_str(), player->GetGUID().GetCounter(), player->GetMapId(), + player->GetPositionX(), player->GetPositionY(), player->GetPositionZ()); if (player->IsInFlight()) return; @@ -3664,7 +3710,7 @@ void Spell::EffectStuck(SpellEffIndex /*effIndex*/) // the player dies if hearthstone is in cooldown, else the player is teleported to home if (player->GetSpellHistory()->HasCooldown(8690)) { - player->Kill(player); + Unit::Kill(player, player); return; } @@ -3689,7 +3735,7 @@ void Spell::EffectSummonPlayer(SpellEffIndex /*effIndex*/) target->SendSummonRequestFrom(m_caster); } else if (Player* target = ObjectAccessor::FindPlayer(m_targets.GetOrigUnitTargetGUID())) - target->SendSummonRequestFrom(m_caster); + target->SendSummonRequestFrom(m_caster); } void Spell::EffectActivateObject(SpellEffIndex effIndex) @@ -3704,101 +3750,100 @@ void Spell::EffectActivateObject(SpellEffIndex effIndex) switch (action) { - case GameObjectActions::AnimateCustom0: - case GameObjectActions::AnimateCustom1: - case GameObjectActions::AnimateCustom2: - case GameObjectActions::AnimateCustom3: - gameObjTarget->SendCustomAnim(uint32(action) - uint32(GameObjectActions::AnimateCustom0)); - break; - case GameObjectActions::Disturb: // What's the difference with Open? - case GameObjectActions::Open: - gameObjTarget->Use(m_caster); - break; - case GameObjectActions::OpenAndUnlock: - gameObjTarget->UseDoorOrButton(0, false, m_caster); - [[fallthrough]]; - case GameObjectActions::Unlock: - case GameObjectActions::Lock: - gameObjTarget->ApplyModFlag(GAMEOBJECT_FLAGS, GO_FLAG_LOCKED, action == GameObjectActions::Lock); - break; - case GameObjectActions::Close: - case GameObjectActions::Rebuild: - gameObjTarget->ResetDoorOrButton(); - break; - case GameObjectActions::Despawn: - gameObjTarget->DespawnOrUnsummon(); - break; - case GameObjectActions::MakeInert: - case GameObjectActions::MakeActive: - gameObjTarget->ApplyModFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE, action == GameObjectActions::MakeInert); - break; - case GameObjectActions::CloseAndLock: - gameObjTarget->ResetDoorOrButton(); - gameObjTarget->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_LOCKED); - break; - case GameObjectActions::Destroy: - gameObjTarget->UseDoorOrButton(0, true, m_caster); - break; - case GameObjectActions::UseArtKit0: - case GameObjectActions::UseArtKit1: - case GameObjectActions::UseArtKit2: - case GameObjectActions::UseArtKit3: - case GameObjectActions::UseArtKit4: - { - GameObjectTemplateAddon const* templateAddon = gameObjTarget->GetTemplateAddon(); - - uint32 artKitIndex = uint32(action) - uint32(GameObjectActions::UseArtKit0); - // Non-sequential here - if (action == GameObjectActions::UseArtKit4) - artKitIndex = 4; - - uint32 artKitValue = 0; - if (templateAddon != nullptr) - artKitValue = templateAddon->artKits[artKitIndex]; - - if (artKitValue == 0) - LOG_ERROR("sql.sql", "GameObject %d hit by spell %d needs `artkit%d` in `gameobject_template_addon`", gameObjTarget->GetEntry(), m_spellInfo->Id, artKitIndex); - else - gameObjTarget->SetGoArtKit(artKitValue); - - break; - } - case GameObjectActions::PlayAnimKit: - gameObjTarget->PlayAnimKit(m_spellInfo->Effects[effIndex].MiscValueB); - break; - break; - case GameObjectActions::OpenAndPlayAnimKit: - gameObjTarget->Use(m_caster); - gameObjTarget->PlayAnimKit(m_spellInfo->Effects[effIndex].MiscValueB); - break; - case GameObjectActions::CloseAndPlayAnimKit: - gameObjTarget->ResetDoorOrButton(); - gameObjTarget->PlayAnimKit(m_spellInfo->Effects[effIndex].MiscValueB); - break; - case GameObjectActions::GoTo1stFloor: - case GameObjectActions::GoTo2ndFloor: - case GameObjectActions::GoTo3rdFloor: - case GameObjectActions::GoTo4thFloor: - case GameObjectActions::GoTo5thFloor: - case GameObjectActions::GoTo6thFloor: - case GameObjectActions::GoTo7thFloor: - case GameObjectActions::GoTo8thFloor: - case GameObjectActions::GoTo9thFloor: - case GameObjectActions::GoTo10thFloor: - static_assert(int32(GO_STATE_TRANSPORT_ACTIVE) == int32(GameObjectActions::GoTo1stFloor)); - if (gameObjTarget->GetGoType() == GAMEOBJECT_TYPE_TRANSPORT) - gameObjTarget->SetGoState(GOState(action)); - else - LOG_ERROR("spell", "Spell %d targeted non-transport gameobject for transport only action \"Go to Floor\" %d in effect %d", m_spellInfo->Id, int32(action), int32(effIndex)); - break; - case GameObjectActions::None: - LOG_FATAL("spell", "Spell %d has action type NONE in effect %d", m_spellInfo->Id, int32(effIndex)); - break; - default: - LOG_ERROR("spell", "Spell %d has unhandled action %d in effect %d", m_spellInfo->Id, int32(action), int32(effIndex)); - break; + case GameObjectActions::AnimateCustom0: + case GameObjectActions::AnimateCustom1: + case GameObjectActions::AnimateCustom2: + case GameObjectActions::AnimateCustom3: + gameObjTarget->SendCustomAnim(uint32(action) - uint32(GameObjectActions::AnimateCustom0)); + break; + case GameObjectActions::Disturb: // What's the difference with Open? + case GameObjectActions::Open: + gameObjTarget->Use(m_caster); + break; + case GameObjectActions::OpenAndUnlock: + gameObjTarget->UseDoorOrButton(0, false, m_caster); + [[fallthrough]]; + case GameObjectActions::Unlock: + case GameObjectActions::Lock: + gameObjTarget->ApplyModFlag(GAMEOBJECT_FLAGS, GO_FLAG_LOCKED, action == GameObjectActions::Lock); + break; + case GameObjectActions::Close: + case GameObjectActions::Rebuild: + gameObjTarget->ResetDoorOrButton(); + break; + case GameObjectActions::Despawn: + gameObjTarget->DespawnOrUnsummon(); + break; + case GameObjectActions::MakeInert: + case GameObjectActions::MakeActive: + gameObjTarget->ApplyModFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE, action == GameObjectActions::MakeInert); + break; + case GameObjectActions::CloseAndLock: + gameObjTarget->ResetDoorOrButton(); + gameObjTarget->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_LOCKED); + break; + case GameObjectActions::Destroy: + gameObjTarget->UseDoorOrButton(0, true, m_caster); + break; + case GameObjectActions::UseArtKit0: + case GameObjectActions::UseArtKit1: + case GameObjectActions::UseArtKit2: + case GameObjectActions::UseArtKit3: + case GameObjectActions::UseArtKit4: + { + GameObjectTemplateAddon const* templateAddon = gameObjTarget->GetTemplateAddon(); + + uint32 artKitIndex = uint32(action) - uint32(GameObjectActions::UseArtKit0); + // Non-sequential here + if (action == GameObjectActions::UseArtKit4) + artKitIndex = 4; + + uint32 artKitValue = 0; + if (templateAddon != nullptr) + artKitValue = templateAddon->artKits[artKitIndex]; + + if (artKitValue == 0) + LOG_ERROR("sql.sql", "GameObject %d hit by spell %d needs `artkit%d` in `gameobject_template_addon`", gameObjTarget->GetEntry(), m_spellInfo->Id, artKitIndex); + else + gameObjTarget->SetGoArtKit(artKitValue); + + break; + } + case GameObjectActions::PlayAnimKit: + gameObjTarget->PlayAnimKit(m_spellInfo->Effects[effIndex].MiscValueB); + break; + break; + case GameObjectActions::OpenAndPlayAnimKit: + gameObjTarget->Use(m_caster); + gameObjTarget->PlayAnimKit(m_spellInfo->Effects[effIndex].MiscValueB); + break; + case GameObjectActions::CloseAndPlayAnimKit: + gameObjTarget->ResetDoorOrButton(); + gameObjTarget->PlayAnimKit(m_spellInfo->Effects[effIndex].MiscValueB); + break; + case GameObjectActions::GoTo1stFloor: + case GameObjectActions::GoTo2ndFloor: + case GameObjectActions::GoTo3rdFloor: + case GameObjectActions::GoTo4thFloor: + case GameObjectActions::GoTo5thFloor: + case GameObjectActions::GoTo6thFloor: + case GameObjectActions::GoTo7thFloor: + case GameObjectActions::GoTo8thFloor: + case GameObjectActions::GoTo9thFloor: + case GameObjectActions::GoTo10thFloor: + static_assert(int32(GO_STATE_TRANSPORT_ACTIVE) == int32(GameObjectActions::GoTo1stFloor)); + if (gameObjTarget->GetGoType() == GAMEOBJECT_TYPE_TRANSPORT) + gameObjTarget->SetGoState(GOState(action)); + else + LOG_ERROR("spell", "Spell %d targeted non-transport gameobject for transport only action \"Go to Floor\" %d in effect %d", m_spellInfo->Id, int32(action), int32(effIndex)); + break; + case GameObjectActions::None: + LOG_FATAL("spell", "Spell %d has action type NONE in effect %d", m_spellInfo->Id, int32(effIndex)); + break; + default: + LOG_ERROR("spell", "Spell %d has unhandled action %d in effect %d", m_spellInfo->Id, int32(action), int32(effIndex)); + break; } - } void Spell::EffectApplyGlyph(SpellEffIndex effIndex) @@ -3817,15 +3862,21 @@ void Spell::EffectApplyGlyph(SpellEffIndex effIndex) uint8 minLevel = 0; switch (m_glyphIndex) { - case 0: - case 1: - case 6: minLevel = 25; break; - case 2: - case 3: - case 7: minLevel = 50; break; - case 4: - case 5: - case 8: minLevel = 75; break; + case 0: + case 1: + case 6: + minLevel = 25; + break; + case 2: + case 3: + case 7: + minLevel = 50; + break; + case 4: + case 5: + case 8: + minLevel = 75; + break; } if (minLevel && m_caster->getLevel() < minLevel) @@ -3844,7 +3895,7 @@ void Spell::EffectApplyGlyph(SpellEffIndex effIndex) if (newGlyphProperties->GlyphSlotFlags != newGlyphSlot->Type) { SendCastResult(SPELL_FAILED_INVALID_GLYPH); - return; // glyph slot mismatch + return; // glyph slot mismatch } } @@ -3896,11 +3947,11 @@ void Spell::EffectEnchantHeldItem(SpellEffIndex effIndex) if (m_spellInfo->Effects[effIndex].MiscValue) { uint32 enchant_id = m_spellInfo->Effects[effIndex].MiscValue; - int32 duration = m_spellInfo->GetDuration(); // Try duration index first .. + int32 duration = m_spellInfo->GetDuration(); // Try duration index first .. if (!duration) - duration = damage;//+1; // Base points after .. + duration = damage; //+1; // Base points after .. if (!duration) - duration = 10 * IN_MILLISECONDS; // 10 seconds for enchants which don't have listed duration + duration = 10 * IN_MILLISECONDS; // 10 seconds for enchants which don't have listed duration if (m_spellInfo->Id == 14792) // Venomhide Poison duration = 5 * MINUTE * IN_MILLISECONDS; @@ -3954,7 +4005,7 @@ void Spell::EffectInebriate(SpellEffIndex /*effIndex*/) { currentDrunk = 100; if (rand_chance() < 25.0f) - player->CastSpell(player, 67468, false); // Drunken Vomit + player->CastSpell(player, 67468, false); // Drunken Vomit } else currentDrunk += drunkMod; @@ -4052,9 +4103,9 @@ void Spell::EffectSummonObject(SpellEffIndex effIndex) PhasingHandler::InheritPhaseShift(go, m_caster); - //pGameObj->SetUInt32Value(GAMEOBJECT_LEVEL, m_caster->getLevel()); + // pGameObj->SetUInt32Value(GAMEOBJECT_LEVEL, m_caster->getLevel()); int32 duration = m_spellInfo->GetDuration(); - go->SetRespawnTime(duration > 0 ? duration/IN_MILLISECONDS : 0); + go->SetRespawnTime(duration > 0 ? duration / IN_MILLISECONDS : 0); go->SetSpellId(m_spellInfo->Id); m_caster->AddGameObject(go); @@ -4135,11 +4186,11 @@ void Spell::EffectResurrect(SpellEffIndex effIndex) if (!player || player->IsAlive() || !player->IsInWorld()) return; - if (player->IsResurrectRequested()) // already have one active request + if (player->IsResurrectRequested()) // already have one active request return; uint32 health = player->CountPctFromMaxHealth(damage); - uint32 mana = CalculatePct(player->GetMaxPower(POWER_MANA), damage); + uint32 mana = CalculatePct(player->GetMaxPower(POWER_MANA), damage); // SPELL_AURA_MOD_RESURRECTED_HEALTH_BY_GUILD_MEMBER bonus if (m_caster->IsPlayer() && m_caster->ToPlayer()->GetGuildId() == player->GetGuildId() && !m_caster->IsInCombat()) @@ -4210,7 +4261,7 @@ void Spell::EffectReputation(SpellEffIndex effIndex) Player* player = unitTarget->ToPlayer(); - int32 repChange = damage; + int32 repChange = damage; uint32 factionId = m_spellInfo->Effects[effIndex].MiscValue; @@ -4242,8 +4293,8 @@ void Spell::EffectQuestComplete(SpellEffIndex effIndex) uint16 logSlot = player->FindQuestSlot(questId); if (logSlot < MAX_QUEST_LOG_SIZE) player->AreaExploredOrEventHappens(questId); - else if (quest->HasFlag(QUEST_FLAGS_TRACKING)) // Check if the quest is used as a serverside flag. - player->SetRewardedQuest(questId); // If so, set status to rewarded without broadcasting it to client. + else if (quest->HasFlag(QUEST_FLAGS_TRACKING)) // Check if the quest is used as a serverside flag. + player->SetRewardedQuest(questId); // If so, set status to rewarded without broadcasting it to client. } } @@ -4371,7 +4422,7 @@ void Spell::EffectCharge(SpellEffIndex effIndex) // Spell is not using explicit target - no generated path if (!m_preGeneratedPath) { - //unitTarget->GetContactPoint(m_caster, pos.m_positionX, pos.m_positionY, pos.m_positionZ); + // unitTarget->GetContactPoint(m_caster, pos.m_positionX, pos.m_positionY, pos.m_positionZ); Position pos = unitTarget->GetFirstCollisionPosition(unitTarget->GetCombatReach(), unitTarget->GetRelativeAngle(m_caster)); m_caster->GetMotionMaster()->MoveCharge(pos.m_positionX, pos.m_positionY, pos.m_positionZ, speed); } @@ -4448,7 +4499,7 @@ void Spell::EffectKnockBack(SpellEffIndex effIndex) else return; } - else //if (m_spellInfo->Effects[i].Effect == SPELL_EFFECT_KNOCK_BACK) + else // if (m_spellInfo->Effects[i].Effect == SPELL_EFFECT_KNOCK_BACK) { m_caster->GetPosition(x, y); } @@ -4472,12 +4523,12 @@ void Spell::EffectLeapBack(SpellEffIndex effIndex) { switch (m_spellInfo->SpellIconID) { - case 4329: // Rocket Jump - case 5365: // Thermal Jump - forward = true; - break; - default: - break; + case 4329: // Rocket Jump + case 5365: // Thermal Jump + forward = true; + break; + default: + break; } } unitTarget->JumpTo(speedxy, speedz, forward); @@ -4682,7 +4733,7 @@ void Spell::EffectResurrectPet(SpellEffIndex /*effIndex*/) pet->SetHealth(pet->CountPctFromMaxHealth(damage)); // Reset things for when the AI to takes over - CharmInfo *ci = pet->GetCharmInfo(); + CharmInfo* ci = pet->GetCharmInfo(); if (ci) { // In case the pet was at stay, we don't want it running back @@ -4819,7 +4870,7 @@ void Spell::EffectTransmitted(SpellEffIndex effIndex) if (m_targets.HasDst()) destTarget->GetPosition(fx, fy, fz, fo); - //FIXME: this can be better check for most objects but still hack + // FIXME: this can be better check for most objects but still hack else if (m_spellInfo->Effects[effIndex].HasRadius() && m_spellInfo->Speed == 0) { float dis = m_spellInfo->Effects[effIndex].CalcRadius(m_originalCaster); @@ -4828,7 +4879,7 @@ void Spell::EffectTransmitted(SpellEffIndex effIndex) } else { - //GO is always friendly to it's creator, get range for friends + // GO is always friendly to it's creator, get range for friends float min_dis = m_spellInfo->GetMinRange(true); float max_dis = m_spellInfo->GetMaxRange(true); float dis = (float)rand_norm() * (max_dis - min_dis) + min_dis; @@ -4858,64 +4909,70 @@ void Spell::EffectTransmitted(SpellEffIndex effIndex) switch (goinfo->type) { - case GAMEOBJECT_TYPE_FISHINGNODE: - { - m_caster->SetChannelObjectGuid(pGameObj->GetGUID()); - m_caster->AddGameObject(pGameObj); // will removed at spell cancel - - // end time of range when possible catch fish (FISHING_BOBBER_READY_TIME..GetDuration(m_spellInfo)) - // start time == fish-FISHING_BOBBER_READY_TIME (0..GetDuration(m_spellInfo)-FISHING_BOBBER_READY_TIME) - int32 lastSec = 0; - switch (urand(0, 2)) - { - case 0: lastSec = 3; break; - case 1: lastSec = 7; break; - case 2: lastSec = 13; break; - } + case GAMEOBJECT_TYPE_FISHINGNODE: + { + m_caster->SetChannelObjectGuid(pGameObj->GetGUID()); + m_caster->AddGameObject(pGameObj); // will removed at spell cancel - // Duration of the fishing bobber can't be higher than the Fishing channeling duration - duration = std::min(duration, duration - lastSec*IN_MILLISECONDS + FISHING_BOBBER_READY_TIME*IN_MILLISECONDS); + // end time of range when possible catch fish (FISHING_BOBBER_READY_TIME..GetDuration(m_spellInfo)) + // start time == fish-FISHING_BOBBER_READY_TIME (0..GetDuration(m_spellInfo)-FISHING_BOBBER_READY_TIME) + int32 lastSec = 0; + switch (urand(0, 2)) + { + case 0: + lastSec = 3; + break; + case 1: + lastSec = 7; + break; + case 2: + lastSec = 13; break; } - case GAMEOBJECT_TYPE_SUMMONING_RITUAL: + + // Duration of the fishing bobber can't be higher than the Fishing channeling duration + duration = std::min(duration, duration - lastSec * IN_MILLISECONDS + FISHING_BOBBER_READY_TIME * IN_MILLISECONDS); + break; + } + case GAMEOBJECT_TYPE_SUMMONING_RITUAL: + { + if (m_caster->GetTypeId() == TYPEID_PLAYER) { - if (m_caster->GetTypeId() == TYPEID_PLAYER) - { - pGameObj->AddUniqueUse(m_caster->ToPlayer()); - m_caster->AddGameObject(pGameObj); // will be removed at spell cancel - } - break; + pGameObj->AddUniqueUse(m_caster->ToPlayer()); + m_caster->AddGameObject(pGameObj); // will be removed at spell cancel } - case GAMEOBJECT_TYPE_DUEL_ARBITER: // 52991 - m_caster->AddGameObject(pGameObj); - break; - case GAMEOBJECT_TYPE_SPELLCASTER: - case GAMEOBJECT_TYPE_GUILD_BANK: - if (m_caster->IsPlayer()) + break; + } + case GAMEOBJECT_TYPE_DUEL_ARBITER: // 52991 + m_caster->AddGameObject(pGameObj); + break; + case GAMEOBJECT_TYPE_SPELLCASTER: + case GAMEOBJECT_TYPE_GUILD_BANK: + if (m_caster->IsPlayer()) + { + if (ObjectGuid guildGUID = m_caster->GetGuidValue(OBJECT_FIELD_DATA)) { - if (ObjectGuid guildGUID = m_caster->GetGuidValue(OBJECT_FIELD_DATA)) - { - pGameObj->SetGuidValue(OBJECT_FIELD_DATA, m_caster->GetGuidValue(OBJECT_FIELD_DATA)); - pGameObj->SetUInt16Value(OBJECT_FIELD_TYPE, 1, 1); // Has guild data - } + pGameObj->SetGuidValue(OBJECT_FIELD_DATA, m_caster->GetGuidValue(OBJECT_FIELD_DATA)); + pGameObj->SetUInt16Value(OBJECT_FIELD_TYPE, 1, 1); // Has guild data } - break; - default: - break; + } + break; + default: + break; } - pGameObj->SetRespawnTime(duration > 0 ? duration/IN_MILLISECONDS : 0); + pGameObj->SetRespawnTime(duration > 0 ? duration / IN_MILLISECONDS : 0); pGameObj->SetOwnerGUID(m_caster->GetGUID()); - //pGameObj->SetUInt32Value(GAMEOBJECT_LEVEL, m_caster->getLevel()); + // pGameObj->SetUInt32Value(GAMEOBJECT_LEVEL, m_caster->getLevel()); pGameObj->SetSpellId(m_spellInfo->Id); ExecuteLogEffectSummonObject(effIndex, pGameObj); LOG_DEBUG("spells", "AddObject at SpellEfects.cpp EffectTransmitted"); - //m_caster->AddGameObject(pGameObj); - //m_ObjToDel.push_back(pGameObj); + // m_caster->AddGameObject(pGameObj); + // m_ObjToDel.push_back(pGameObj); cMap->AddToMap(pGameObj); @@ -4923,8 +4980,8 @@ void Spell::EffectTransmitted(SpellEffIndex effIndex) { PhasingHandler::InheritPhaseShift(linkedTrap, m_caster); - linkedTrap->SetRespawnTime(duration > 0 ? duration/IN_MILLISECONDS : 0); - //linkedTrap->SetUInt32Value(GAMEOBJECT_LEVEL, m_caster->getLevel()); + linkedTrap->SetRespawnTime(duration > 0 ? duration / IN_MILLISECONDS : 0); + // linkedTrap->SetUInt32Value(GAMEOBJECT_LEVEL, m_caster->getLevel()); linkedTrap->SetSpellId(m_spellInfo->Id); linkedTrap->SetOwnerGUID(m_caster->GetGUID()); @@ -5006,9 +5063,8 @@ void Spell::EffectSpiritHeal(SpellEffIndex /*effIndex*/) return; //m_spellInfo->Effects[i].BasePoints; == 99 (percent?) - //unitTarget->ToPlayer()->setResurrect(m_caster->GetGUID(), unitTarget->GetPositionX(), unitTarget->GetPositionY(), unitTarget->GetPositionZ(), unitTarget->GetMaxHealth(), unitTarget->GetMaxPower(POWER_MANA)); - unitTarget->ToPlayer()->ResurrectPlayer(1.0f); - unitTarget->ToPlayer()->SpawnCorpseBones(); + //unitTarget->ToPlayer()->setResurrect(m_caster->GetGUID(), unitTarget->GetPositionX(), unitTarget->GetPositionY(), unitTarget->GetPositionZ(), unitTarget->GetMaxHealth(), + unitTarget->GetMaxPower(POWER_MANA)); unitTarget->ToPlayer()->ResurrectPlayer(1.0f); unitTarget->ToPlayer()->SpawnCorpseBones(); */ } @@ -5038,13 +5094,13 @@ void Spell::EffectStealBeneficialBuff(SpellEffIndex effIndex) LOG_DEBUG("spells", "Effect: StealBeneficialBuff"); - if (!unitTarget || unitTarget == m_caster) // can't steal from self + if (!unitTarget || unitTarget == m_caster) // can't steal from self return; DispelChargesList stealList; // Create dispel mask by dispel type - uint32 dispelMask = SpellInfo::GetDispelMask(DispelType(m_spellInfo->Effects[effIndex].MiscValue)); + uint32 dispelMask = SpellInfo::GetDispelMask(DispelType(m_spellInfo->Effects[effIndex].MiscValue)); Unit::AuraMap const& auras = unitTarget->GetOwnedAuras(); for (Unit::AuraMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) { @@ -5106,12 +5162,12 @@ void Spell::EffectStealBeneficialBuff(SpellEffIndex effIndex) if (!failCount) { // Failed to dispell - dataFail << uint64(m_caster->GetGUID()); // Caster GUID - dataFail << uint64(unitTarget->GetGUID()); // Victim GUID - dataFail << uint32(m_spellInfo->Id); // dispel spell id + dataFail << uint64(m_caster->GetGUID()); // Caster GUID + dataFail << uint64(unitTarget->GetGUID()); // Victim GUID + dataFail << uint32(m_spellInfo->Id); // dispel spell id } ++failCount; - dataFail << uint32(itr->GetAura()->GetId()); // Spell Id + dataFail << uint32(itr->GetAura()->GetId()); // Spell Id } ++count; } @@ -5123,15 +5179,15 @@ void Spell::EffectStealBeneficialBuff(SpellEffIndex effIndex) return; WorldPacket dataSuccess(SMSG_SPELLSTEALLOG, 8 + 8 + 4 + 1 + 4 + damage * 5); - dataSuccess << unitTarget->GetPackGUID(); // Victim GUID - dataSuccess << m_caster->GetPackGUID(); // Caster GUID - dataSuccess << uint32(m_spellInfo->Id); // dispel spell id - dataSuccess << uint8(0); // not used - dataSuccess << uint32(successList.size()); // count + dataSuccess << unitTarget->GetPackGUID(); // Victim GUID + dataSuccess << m_caster->GetPackGUID(); // Caster GUID + dataSuccess << uint32(m_spellInfo->Id); // dispel spell id + dataSuccess << uint8(0); // not used + dataSuccess << uint32(successList.size()); // count for (auto itr = successList.begin(); itr != successList.end(); ++itr) { - dataSuccess << uint32(itr->first); // Spell Id - dataSuccess << uint8(0); // 0 - steals !=0 transfers + dataSuccess << uint32(itr->first); // Spell Id + dataSuccess << uint8(0); // 0 - steals !=0 transfers unitTarget->RemoveAurasDueToSpellBySteal(itr->first, itr->second, m_caster); } m_caster->SendMessageToSet(&dataSuccess, true); @@ -5160,7 +5216,7 @@ void Spell::EffectKillCredit(SpellEffIndex effIndex) if (!creatureEntry) { if (m_spellInfo->Id == 42793) // Burn Body - creatureEntry = 24008; // Fallen Combatant + creatureEntry = 24008; // Fallen Combatant } if (creatureEntry) @@ -5355,8 +5411,7 @@ void Spell::EffectRenamePet(SpellEffIndex /*effIndex*/) if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET) return; - if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT || - !unitTarget->IsPet() || ((Pet*)unitTarget)->getPetType() != HUNTER_PET) + if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT || !unitTarget->IsPet() || ((Pet*)unitTarget)->getPetType() != HUNTER_PET) return; unitTarget->SetByteFlag(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PET_FLAGS, UNIT_CAN_BE_RENAMED); @@ -5400,7 +5455,7 @@ void Spell::EffectActivateSpec(SpellEffIndex /*effIndex*/) if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) return; - unitTarget->ToPlayer()->ActivateSpec(damage-1); // damage is 1 or 2, spec is 0 or 1 + unitTarget->ToPlayer()->ActivateSpec(damage - 1); // damage is 1 or 2, spec is 0 or 1 } void Spell::EffectPlaySound(SpellEffIndex effIndex) @@ -5417,11 +5472,11 @@ void Spell::EffectPlaySound(SpellEffIndex effIndex) switch (m_spellInfo->Id) { - case 91604: // Restricted Flight Area - player->GetSession()->SendNotification(LANG_ZONE_NOFLYZONE); - break; - default: - break; + case 91604: // Restricted Flight Area + player->GetSession()->SendNotification(LANG_ZONE_NOFLYZONE); + break; + default: + break; } uint32 soundId = m_spellInfo->Effects[effIndex].MiscValue; @@ -5565,8 +5620,7 @@ void Spell::EffectBind(SpellEffIndex effIndex) player->SetHomebind(homeLoc, areaId); player->SendBindPointUpdate(); - LOG_DEBUG("spells", "EffectBind: New homebind X: %f, Y: %f, Z: %f, MapId: %u, AreaId: %u", - homeLoc.GetPositionX(), homeLoc.GetPositionY(), homeLoc.GetPositionZ(), homeLoc.GetMapId(), areaId); + LOG_DEBUG("spells", "EffectBind: New homebind X: %f, Y: %f, Z: %f, MapId: %u, AreaId: %u", homeLoc.GetPositionX(), homeLoc.GetPositionY(), homeLoc.GetPositionZ(), homeLoc.GetMapId(), areaId); // zone update WorldPacket data(SMSG_PLAYERBOUND, 8 + 4); @@ -5666,11 +5720,11 @@ void Spell::EffectResurrectWithAura(SpellEffIndex effIndex) if (!player || player->IsAlive() || !player->IsInWorld()) return; - if (player->IsResurrectRequested()) // already have one active request + if (player->IsResurrectRequested()) // already have one active request return; uint32 health = player->CountPctFromMaxHealth(damage); - uint32 mana = CalculatePct(player->GetMaxPower(POWER_MANA), damage); + uint32 mana = CalculatePct(player->GetMaxPower(POWER_MANA), damage); uint32 resurrectAura = 0; if (sSpellMgr->GetSpellInfo(GetSpellInfo()->Effects[effIndex].TriggerSpell)) resurrectAura = GetSpellInfo()->Effects[effIndex].TriggerSpell; diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp index d964bdf3..0f5539f8 100644 --- a/src/server/scripts/Commands/cs_misc.cpp +++ b/src/server/scripts/Commands/cs_misc.cpp @@ -15,27 +15,26 @@ * with this program. If not, see . */ -#include "ScriptMgr.h" #include "AccountMgr.h" #include "ArenaTeamMgr.h" #include "CellImpl.h" #include "CharacterCache.h" #include "ChaseMovementGenerator.h" #include "Chat.h" -#include "DatabaseEnv.h" -#include "DBCStores.h" #include "DB2Stores.h" +#include "DBCStores.h" +#include "DatabaseEnv.h" #include "DisableMgr.h" #include "FollowMovementGenerator.h" #include "GridNotifiers.h" #include "Group.h" #include "GroupMgr.h" +#include "IPLocation.h" #include "InstanceSaveMgr.h" #include "IpAddress.h" -#include "IPLocation.h" #include "Item.h" -#include "Language.h" #include "LFG.h" +#include "Language.h" #include "Log.h" #include "MMapFactory.h" #include "MovementGenerator.h" @@ -46,6 +45,7 @@ #include "PhasingHandler.h" #include "Player.h" #include "Realm.h" +#include "ScriptMgr.h" #include "SpellAuras.h" #include "SpellHistory.h" #include "SpellMgr.h" @@ -57,67 +57,68 @@ class misc_commandscript : public CommandScript { -public: - misc_commandscript() : CommandScript("misc_commandscript") { } + public: + misc_commandscript() : CommandScript("misc_commandscript") + { + } std::vector GetCommands() const override { - static std::vector commandTable = - { - { "additem", rbac::RBAC_PERM_COMMAND_ADDITEM, false, &HandleAddItemCommand, "" }, - { "additemset", rbac::RBAC_PERM_COMMAND_ADDITEMSET, false, &HandleAddItemSetCommand, "" }, - { "appear", rbac::RBAC_PERM_COMMAND_APPEAR, false, &HandleAppearCommand, "" }, - { "aura", rbac::RBAC_PERM_COMMAND_AURA, false, &HandleAuraCommand, "" }, - { "bank", rbac::RBAC_PERM_COMMAND_BANK, false, &HandleBankCommand, "" }, - { "bindsight", rbac::RBAC_PERM_COMMAND_BINDSIGHT, false, &HandleBindSightCommand, "" }, - { "combatstop", rbac::RBAC_PERM_COMMAND_COMBATSTOP, true, &HandleCombatStopCommand, "" }, - { "cometome", rbac::RBAC_PERM_COMMAND_COMETOME, false, &HandleComeToMeCommand, "" }, - { "commands", rbac::RBAC_PERM_COMMAND_COMMANDS, true, &HandleCommandsCommand, "" }, - { "cooldown", rbac::RBAC_PERM_COMMAND_COOLDOWN, false, &HandleCooldownCommand, "" }, - { "damage", rbac::RBAC_PERM_COMMAND_DAMAGE, false, &HandleDamageCommand, "" }, - { "dev", rbac::RBAC_PERM_COMMAND_DEV, false, &HandleDevCommand, "" }, - { "die", rbac::RBAC_PERM_COMMAND_DIE, false, &HandleDieCommand, "" }, - { "dismount", rbac::RBAC_PERM_COMMAND_DISMOUNT, false, &HandleDismountCommand, "" }, - { "distance", rbac::RBAC_PERM_COMMAND_DISTANCE, false, &HandleGetDistanceCommand, "" }, - { "freeze", rbac::RBAC_PERM_COMMAND_FREEZE, false, &HandleFreezeCommand, "" }, - { "gps", rbac::RBAC_PERM_COMMAND_GPS, false, &HandleGPSCommand, "" }, - { "guid", rbac::RBAC_PERM_COMMAND_GUID, false, &HandleGUIDCommand, "" }, - { "help", rbac::RBAC_PERM_COMMAND_HELP, true, &HandleHelpCommand, "" }, - { "hidearea", rbac::RBAC_PERM_COMMAND_HIDEAREA, false, &HandleHideAreaCommand, "" }, - { "itemmove", rbac::RBAC_PERM_COMMAND_ITEMMOVE, false, &HandleItemMoveCommand, "" }, - { "kick", rbac::RBAC_PERM_COMMAND_KICK, true, &HandleKickPlayerCommand, "" }, - { "linkgrave", rbac::RBAC_PERM_COMMAND_LINKGRAVE, false, &HandleLinkGraveCommand, "" }, - { "listfreeze", rbac::RBAC_PERM_COMMAND_LISTFREEZE, false, &HandleListFreezeCommand, "" }, - { "movegens", rbac::RBAC_PERM_COMMAND_MOVEGENS, false, &HandleMovegensCommand, "" }, - { "mute", rbac::RBAC_PERM_COMMAND_MUTE, true, &HandleMuteCommand, "" }, - { "mutehistory", rbac::RBAC_PERM_COMMAND_MUTEHISTORY, true, &HandleMuteInfoCommand, "" }, - { "neargrave", rbac::RBAC_PERM_COMMAND_NEARGRAVE, false, &HandleNearGraveCommand, "" }, - { "pinfo", rbac::RBAC_PERM_COMMAND_PINFO, true, &HandlePInfoCommand, "" }, - { "playall", rbac::RBAC_PERM_COMMAND_PLAYALL, false, &HandlePlayAllCommand, "" }, - { "possess", rbac::RBAC_PERM_COMMAND_POSSESS, false, &HandlePossessCommand, "" }, - { "pvpstats", rbac::RBAC_PERM_COMMAND_PVPSTATS, true, &HandlePvPstatsCommand, "" }, - { "recall", rbac::RBAC_PERM_COMMAND_RECALL, false, &HandleRecallCommand, "" }, - { "repairitems", rbac::RBAC_PERM_COMMAND_REPAIRITEMS, true, &HandleRepairitemsCommand, "" }, - { "respawn", rbac::RBAC_PERM_COMMAND_RESPAWN, false, &HandleRespawnCommand, "" }, - { "revive", rbac::RBAC_PERM_COMMAND_REVIVE, true, &HandleReviveCommand, "" }, - { "saveall", rbac::RBAC_PERM_COMMAND_SAVEALL, true, &HandleSaveAllCommand, "" }, - { "save", rbac::RBAC_PERM_COMMAND_SAVE, false, &HandleSaveCommand, "" }, - { "setskill", rbac::RBAC_PERM_COMMAND_SETSKILL, false, &HandleSetSkillCommand, "" }, - { "showarea", rbac::RBAC_PERM_COMMAND_SHOWAREA, false, &HandleShowAreaCommand, "" }, - { "summon", rbac::RBAC_PERM_COMMAND_SUMMON, false, &HandleSummonCommand, "" }, - { "unaura", rbac::RBAC_PERM_COMMAND_UNAURA, false, &HandleUnAuraCommand, "" }, - { "unbindsight", rbac::RBAC_PERM_COMMAND_UNBINDSIGHT, false, HandleUnbindSightCommand, "" }, - { "unfreeze", rbac::RBAC_PERM_COMMAND_UNFREEZE, false, &HandleUnFreezeCommand, "" }, - { "unmute", rbac::RBAC_PERM_COMMAND_UNMUTE, true, &HandleUnmuteCommand, "" }, - { "unpossess", rbac::RBAC_PERM_COMMAND_UNPOSSESS, false, &HandleUnPossessCommand, "" }, - { "unstuck", rbac::RBAC_PERM_COMMAND_UNSTUCK, true, &HandleUnstuckCommand, "" }, - { "wchange", rbac::RBAC_PERM_COMMAND_WCHANGE, false, &HandleChangeWeather, "" }, - { "mailbox", rbac::RBAC_PERM_COMMAND_MAILBOX, false, &HandleMailBoxCommand, "" }, + static std::vector commandTable = { + {"additem", rbac::RBAC_PERM_COMMAND_ADDITEM, false, &HandleAddItemCommand, ""}, + {"additemset", rbac::RBAC_PERM_COMMAND_ADDITEMSET, false, &HandleAddItemSetCommand, ""}, + {"appear", rbac::RBAC_PERM_COMMAND_APPEAR, false, &HandleAppearCommand, ""}, + {"aura", rbac::RBAC_PERM_COMMAND_AURA, false, &HandleAuraCommand, ""}, + {"bank", rbac::RBAC_PERM_COMMAND_BANK, false, &HandleBankCommand, ""}, + {"bindsight", rbac::RBAC_PERM_COMMAND_BINDSIGHT, false, &HandleBindSightCommand, ""}, + {"combatstop", rbac::RBAC_PERM_COMMAND_COMBATSTOP, true, &HandleCombatStopCommand, ""}, + {"cometome", rbac::RBAC_PERM_COMMAND_COMETOME, false, &HandleComeToMeCommand, ""}, + {"commands", rbac::RBAC_PERM_COMMAND_COMMANDS, true, &HandleCommandsCommand, ""}, + {"cooldown", rbac::RBAC_PERM_COMMAND_COOLDOWN, false, &HandleCooldownCommand, ""}, + {"damage", rbac::RBAC_PERM_COMMAND_DAMAGE, false, &HandleDamageCommand, ""}, + {"dev", rbac::RBAC_PERM_COMMAND_DEV, false, &HandleDevCommand, ""}, + {"die", rbac::RBAC_PERM_COMMAND_DIE, false, &HandleDieCommand, ""}, + {"dismount", rbac::RBAC_PERM_COMMAND_DISMOUNT, false, &HandleDismountCommand, ""}, + {"distance", rbac::RBAC_PERM_COMMAND_DISTANCE, false, &HandleGetDistanceCommand, ""}, + {"freeze", rbac::RBAC_PERM_COMMAND_FREEZE, false, &HandleFreezeCommand, ""}, + {"gps", rbac::RBAC_PERM_COMMAND_GPS, false, &HandleGPSCommand, ""}, + {"guid", rbac::RBAC_PERM_COMMAND_GUID, false, &HandleGUIDCommand, ""}, + {"help", rbac::RBAC_PERM_COMMAND_HELP, true, &HandleHelpCommand, ""}, + {"hidearea", rbac::RBAC_PERM_COMMAND_HIDEAREA, false, &HandleHideAreaCommand, ""}, + {"itemmove", rbac::RBAC_PERM_COMMAND_ITEMMOVE, false, &HandleItemMoveCommand, ""}, + {"kick", rbac::RBAC_PERM_COMMAND_KICK, true, &HandleKickPlayerCommand, ""}, + {"linkgrave", rbac::RBAC_PERM_COMMAND_LINKGRAVE, false, &HandleLinkGraveCommand, ""}, + {"listfreeze", rbac::RBAC_PERM_COMMAND_LISTFREEZE, false, &HandleListFreezeCommand, ""}, + {"movegens", rbac::RBAC_PERM_COMMAND_MOVEGENS, false, &HandleMovegensCommand, ""}, + {"mute", rbac::RBAC_PERM_COMMAND_MUTE, true, &HandleMuteCommand, ""}, + {"mutehistory", rbac::RBAC_PERM_COMMAND_MUTEHISTORY, true, &HandleMuteInfoCommand, ""}, + {"neargrave", rbac::RBAC_PERM_COMMAND_NEARGRAVE, false, &HandleNearGraveCommand, ""}, + {"pinfo", rbac::RBAC_PERM_COMMAND_PINFO, true, &HandlePInfoCommand, ""}, + {"playall", rbac::RBAC_PERM_COMMAND_PLAYALL, false, &HandlePlayAllCommand, ""}, + {"possess", rbac::RBAC_PERM_COMMAND_POSSESS, false, &HandlePossessCommand, ""}, + {"pvpstats", rbac::RBAC_PERM_COMMAND_PVPSTATS, true, &HandlePvPstatsCommand, ""}, + {"recall", rbac::RBAC_PERM_COMMAND_RECALL, false, &HandleRecallCommand, ""}, + {"repairitems", rbac::RBAC_PERM_COMMAND_REPAIRITEMS, true, &HandleRepairitemsCommand, ""}, + {"respawn", rbac::RBAC_PERM_COMMAND_RESPAWN, false, &HandleRespawnCommand, ""}, + {"revive", rbac::RBAC_PERM_COMMAND_REVIVE, true, &HandleReviveCommand, ""}, + {"saveall", rbac::RBAC_PERM_COMMAND_SAVEALL, true, &HandleSaveAllCommand, ""}, + {"save", rbac::RBAC_PERM_COMMAND_SAVE, false, &HandleSaveCommand, ""}, + {"setskill", rbac::RBAC_PERM_COMMAND_SETSKILL, false, &HandleSetSkillCommand, ""}, + {"showarea", rbac::RBAC_PERM_COMMAND_SHOWAREA, false, &HandleShowAreaCommand, ""}, + {"summon", rbac::RBAC_PERM_COMMAND_SUMMON, false, &HandleSummonCommand, ""}, + {"unaura", rbac::RBAC_PERM_COMMAND_UNAURA, false, &HandleUnAuraCommand, ""}, + {"unbindsight", rbac::RBAC_PERM_COMMAND_UNBINDSIGHT, false, HandleUnbindSightCommand, ""}, + {"unfreeze", rbac::RBAC_PERM_COMMAND_UNFREEZE, false, &HandleUnFreezeCommand, ""}, + {"unmute", rbac::RBAC_PERM_COMMAND_UNMUTE, true, &HandleUnmuteCommand, ""}, + {"unpossess", rbac::RBAC_PERM_COMMAND_UNPOSSESS, false, &HandleUnPossessCommand, ""}, + {"unstuck", rbac::RBAC_PERM_COMMAND_UNSTUCK, true, &HandleUnstuckCommand, ""}, + {"wchange", rbac::RBAC_PERM_COMMAND_WCHANGE, false, &HandleChangeWeather, ""}, + {"mailbox", rbac::RBAC_PERM_COMMAND_MAILBOX, false, &HandleMailBoxCommand, ""}, }; return commandTable; } - static bool HandlePvPstatsCommand(ChatHandler * handler, char const* /*args*/) + static bool HandlePvPstatsCommand(ChatHandler* handler, char const* /*args*/) { if (sWorld->getBoolConfig(CONFIG_BATTLEGROUND_STORE_STATISTICS_ENABLE)) { @@ -189,38 +190,38 @@ class misc_commandscript : public CommandScript return false; switch (guidHigh) { - case HighGuid::Player: + case HighGuid::Player: + { + object = ObjectAccessor::FindPlayerByLowGUID(guidLow); + if (!object) { - object = ObjectAccessor::FindPlayerByLowGUID(guidLow); - if (!object) - { - handler->SendSysMessage(LANG_PLAYER_NOT_FOUND); - handler->SetSentErrorMessage(true); - } - break; + handler->SendSysMessage(LANG_PLAYER_NOT_FOUND); + handler->SetSentErrorMessage(true); } - case HighGuid::Unit: + break; + } + case HighGuid::Unit: + { + object = handler->GetCreatureFromPlayerMapByDbGuid(guidLow); + if (!object) { - object = handler->GetCreatureFromPlayerMapByDbGuid(guidLow); - if (!object) - { - handler->SendSysMessage(LANG_COMMAND_NOCREATUREFOUND); - handler->SetSentErrorMessage(true); - } - break; + handler->SendSysMessage(LANG_COMMAND_NOCREATUREFOUND); + handler->SetSentErrorMessage(true); } - case HighGuid::GameObject: + break; + } + case HighGuid::GameObject: + { + object = handler->GetObjectFromPlayerMapByDbGuid(guidLow); + if (!object) { - object = handler->GetObjectFromPlayerMapByDbGuid(guidLow); - if (!object) - { - handler->SendSysMessage(LANG_COMMAND_NOGAMEOBJECTFOUND); - handler->SetSentErrorMessage(true); - } - break; + handler->SendSysMessage(LANG_COMMAND_NOGAMEOBJECTFOUND); + handler->SetSentErrorMessage(true); } - default: - return false; + break; + } + default: + return false; } if (!object) return false; @@ -277,23 +278,18 @@ class misc_commandscript : public CommandScript char const* unknown = handler->GetFirelandsString(LANG_UNKNOWN); - handler->PSendSysMessage(LANG_MAP_POSITION, - mapId, (mapEntry ? mapEntry->MapName : unknown), - zoneId, (zoneEntry ? zoneEntry->AreaName : unknown), - areaId, (areaEntry ? areaEntry->AreaName : unknown), - object->GetPositionX(), object->GetPositionY(), object->GetPositionZ(), object->GetOrientation()); + handler->PSendSysMessage(LANG_MAP_POSITION, mapId, (mapEntry ? mapEntry->MapName : unknown), zoneId, (zoneEntry ? zoneEntry->AreaName : unknown), areaId, + (areaEntry ? areaEntry->AreaName : unknown), object->GetPositionX(), object->GetPositionY(), object->GetPositionZ(), object->GetOrientation()); if (Transport* transport = dynamic_cast(object->GetTransport())) { - handler->PSendSysMessage(LANG_TRANSPORT_POSITION, - transport->GetGOInfo()->moTransport.mapID, object->GetTransOffsetX(), object->GetTransOffsetY(), object->GetTransOffsetZ(), object->GetTransOffsetO(), - transport->GetEntry(), transport->GetName().c_str()); + handler->PSendSysMessage(LANG_TRANSPORT_POSITION, transport->GetGOInfo()->moTransport.mapID, object->GetTransOffsetX(), object->GetTransOffsetY(), object->GetTransOffsetZ(), + object->GetTransOffsetO(), transport->GetEntry(), transport->GetName().c_str()); } - handler->PSendSysMessage(LANG_GRID_POSITION, - cell.GridX(), cell.GridY(), cell.CellX(), cell.CellY(), object->GetInstanceId(), - zoneX, zoneY, groundZ, floorZ, haveMap, haveVMap, haveMMap); + handler->PSendSysMessage(LANG_GRID_POSITION, cell.GridX(), cell.GridY(), cell.CellX(), cell.CellY(), object->GetInstanceId(), zoneX, zoneY, groundZ, floorZ, haveMap, haveVMap, haveMMap); LiquidData liquidStatus; - ZLiquidStatus status = map->GetLiquidStatus(object->GetPhaseShift(), object->GetPositionX(), object->GetPositionY(), object->GetPositionZ(), MAP_ALL_LIQUIDS, &liquidStatus, object->GetCollisionHeight()); + ZLiquidStatus status = + map->GetLiquidStatus(object->GetPhaseShift(), object->GetPositionX(), object->GetPositionY(), object->GetPositionZ(), MAP_ALL_LIQUIDS, &liquidStatus, object->GetCollisionHeight()); if (status) handler->PSendSysMessage(LANG_LIQUID_STATUS, liquidStatus.level, liquidStatus.depth_level, liquidStatus.entry, liquidStatus.type_flags, status); @@ -427,7 +423,7 @@ class misc_commandscript : public CommandScript { Group* group = _player->GetGroup(); // if no bind exists, create a solo bind - InstanceGroupBind* gBind = group ? group->GetBoundInstance(target) : nullptr; // if no bind exists, create a solo bind + InstanceGroupBind* gBind = group ? group->GetBoundInstance(target) : nullptr; // if no bind exists, create a solo bind if (!gBind) if (InstanceSave* save = sInstanceSaveMgr->GetInstanceSave(target->GetInstanceId())) _player->BindToInstance(save, !save->CanReset()); @@ -602,13 +598,8 @@ class misc_commandscript : public CommandScript // in point where GM stay CharacterDatabaseTransaction dummy; - Player::SavePositionInDB(WorldLocation(_player->GetMapId(), - _player->GetPositionX(), - _player->GetPositionY(), - _player->GetPositionZ(), - _player->GetOrientation()), - _player->GetZoneId(), - targetGuid, dummy); + Player::SavePositionInDB( + WorldLocation(_player->GetMapId(), _player->GetPositionX(), _player->GetPositionY(), _player->GetPositionZ(), _player->GetOrientation()), _player->GetZoneId(), targetGuid, dummy); } return true; @@ -638,9 +629,9 @@ class misc_commandscript : public CommandScript if (target->IsAlive()) { if (sWorld->getBoolConfig(CONFIG_DIE_COMMAND_MODE)) - handler->GetSession()->GetPlayer()->Kill(target); + Unit::Kill(handler->GetSession()->GetPlayer(), target); else - handler->GetSession()->GetPlayer()->DealDamage(target, target->GetHealth(), nullptr, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, nullptr, false); + Unit::DealDamage(handler->GetSession()->GetPlayer(), target, target->GetHealth(), nullptr, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, nullptr, false); } return true; @@ -813,38 +804,38 @@ class misc_commandscript : public CommandScript return false; switch (guidHigh) { - case HighGuid::Player: + case HighGuid::Player: + { + object = ObjectAccessor::FindPlayerByLowGUID(guidLow); + if (!object) { - object = ObjectAccessor::FindPlayerByLowGUID(guidLow); - if (!object) - { - handler->SendSysMessage(LANG_PLAYER_NOT_FOUND); - handler->SetSentErrorMessage(true); - } - break; + handler->SendSysMessage(LANG_PLAYER_NOT_FOUND); + handler->SetSentErrorMessage(true); } - case HighGuid::Unit: + break; + } + case HighGuid::Unit: + { + object = handler->GetCreatureFromPlayerMapByDbGuid(guidLow); + if (!object) { - object = handler->GetCreatureFromPlayerMapByDbGuid(guidLow); - if (!object) - { - handler->SendSysMessage(LANG_COMMAND_NOCREATUREFOUND); - handler->SetSentErrorMessage(true); - } - break; + handler->SendSysMessage(LANG_COMMAND_NOCREATUREFOUND); + handler->SetSentErrorMessage(true); } - case HighGuid::GameObject: + break; + } + case HighGuid::GameObject: + { + object = handler->GetObjectFromPlayerMapByDbGuid(guidLow); + if (!object) { - object = handler->GetObjectFromPlayerMapByDbGuid(guidLow); - if (!object) - { - handler->SendSysMessage(LANG_COMMAND_NOGAMEOBJECTFOUND); - handler->SetSentErrorMessage(true); - } - break; + handler->SendSysMessage(LANG_COMMAND_NOGAMEOBJECTFOUND); + handler->SetSentErrorMessage(true); } - default: - return false; + break; + } + default: + return false; } if (!object) return false; @@ -860,7 +851,8 @@ class misc_commandscript : public CommandScript } } - handler->PSendSysMessage(LANG_DISTANCE, handler->GetSession()->GetPlayer()->GetDistance(object), handler->GetSession()->GetPlayer()->GetDistance2d(object), handler->GetSession()->GetPlayer()->GetExactDist(object), handler->GetSession()->GetPlayer()->GetExactDist2d(object)); + handler->PSendSysMessage(LANG_DISTANCE, handler->GetSession()->GetPlayer()->GetDistance(object), handler->GetSession()->GetPlayer()->GetDistance2d(object), + handler->GetSession()->GetPlayer()->GetExactDist(object), handler->GetSession()->GetPlayer()->GetExactDist2d(object)); return true; } // Teleport player to last position @@ -1016,9 +1008,8 @@ class misc_commandscript : public CommandScript return true; } - //Not a supported argument + // Not a supported argument return false; - } static bool HandleLinkGraveCommand(ChatHandler* handler, char const* args) @@ -1217,20 +1208,21 @@ class misc_commandscript : public CommandScript uint32 itemId = 0; - if (args[0] == '[') // [name] manual form + if (args[0] == '[') // [name] manual form { char const* itemNameStr = strtok((char*)args, "]"); if (itemNameStr && itemNameStr[0]) { std::string itemName = itemNameStr + 1; - auto itr = std::find_if(sItemSparseStore.begin(), sItemSparseStore.end(), [&itemName](ItemSparseEntry const* sparse) - { - for (uint32 i = 0; i < MAX_LOCALES; ++i) - if (itemName == sparse->Display->Str[i]) - return true; - return false; - }); + auto itr = std::find_if(sItemSparseStore.begin(), sItemSparseStore.end(), + [&itemName](ItemSparseEntry const* sparse) + { + for (uint32 i = 0; i < MAX_LOCALES; ++i) + if (itemName == sparse->Display->Str[i]) + return true; + return false; + }); if (itr == sItemSparseStore.end()) { @@ -1244,7 +1236,7 @@ class misc_commandscript : public CommandScript else return false; } - else // item_id or [name] Shift-click form |color|Hitem:item_id:0:0:0|h[name]|h|r + else // item_id or [name] Shift-click form |color|Hitem:item_id:0:0:0|h[name]|h|r { char const* id = handler->extractKeyFromLink((char*)args, "Hitem"); if (!id) @@ -1291,10 +1283,10 @@ class misc_commandscript : public CommandScript // check space and find places ItemPosCountVec dest; InventoryResult msg = playerTarget->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemId, count, &noSpaceForCount); - if (msg != EQUIP_ERR_OK) // convert to possible store amount + if (msg != EQUIP_ERR_OK) // convert to possible store amount count -= noSpaceForCount; - if (count == 0 || dest.empty()) // can't add any + if (count == 0 || dest.empty()) // can't add any { handler->PSendSysMessage(LANG_ITEM_CANNOT_CREATE, itemId, noSpaceForCount); handler->SetSentErrorMessage(true); @@ -1413,8 +1405,8 @@ class misc_commandscript : public CommandScript if (!px || !py) return false; - uint32 type = uint32(atoi(px)); //0 to 3, 0: fine, 1: rain, 2: snow, 3: sand - float grade = float(atof(py)); //0 to 1, sending -1 is instand good weather + uint32 type = uint32(atoi(px)); // 0 to 3, 0: fine, 1: rain, 2: snow, 3: sand + float grade = float(atof(py)); // 0 to 1, sending -1 is instand good weather Player* player = handler->GetSession()->GetPlayer(); uint32 zoneid = player->GetZoneId(); @@ -1489,22 +1481,22 @@ class misc_commandscript : public CommandScript } /** - * @name Player command: .pinfo - * @date 05/19/2013 - * - * @brief Prints information about a character and it's linked account to the commander - * - * Non-applying information, e.g. a character that is not in gm mode right now or - * that is not banned/muted, is not printed - * - * This can be done either by giving a name or by targeting someone, else, it'll use the commander - * - * @param args name Prints information according to the given name to the commander - * target Prints information on the target to the commander - * none No given args results in printing information on the commander - * - * @return Several pieces of information about the character and the account - **/ + * @name Player command: .pinfo + * @date 05/19/2013 + * + * @brief Prints information about a character and it's linked account to the commander + * + * Non-applying information, e.g. a character that is not in gm mode right now or + * that is not banned/muted, is not printed + * + * This can be done either by giving a name or by targeting someone, else, it'll use the commander + * + * @param args name Prints information according to the given name to the commander + * target Prints information on the target to the commander + * none No given args results in printing information on the commander + * + * @return Several pieces of information about the character and the account + **/ static bool HandlePInfoCommand(ChatHandler* handler, char const* args) { @@ -1560,51 +1552,51 @@ class misc_commandscript : public CommandScript */ // Account data print variables - std::string userName = handler->GetFirelandsString(LANG_ERROR); - uint32 accId = 0; - ObjectGuid::LowType lowguid = targetGuid.GetCounter(); - std::string eMail = handler->GetFirelandsString(LANG_ERROR); - std::string regMail = handler->GetFirelandsString(LANG_ERROR); - uint32 security = 0; - std::string lastIp = handler->GetFirelandsString(LANG_ERROR); - uint8 locked = 0; - std::string lastLogin = handler->GetFirelandsString(LANG_ERROR); - uint32 failedLogins = 0; - uint32 latency = 0; - std::string OS = handler->GetFirelandsString(LANG_UNKNOWN); + std::string userName = handler->GetFirelandsString(LANG_ERROR); + uint32 accId = 0; + ObjectGuid::LowType lowguid = targetGuid.GetCounter(); + std::string eMail = handler->GetFirelandsString(LANG_ERROR); + std::string regMail = handler->GetFirelandsString(LANG_ERROR); + uint32 security = 0; + std::string lastIp = handler->GetFirelandsString(LANG_ERROR); + uint8 locked = 0; + std::string lastLogin = handler->GetFirelandsString(LANG_ERROR); + uint32 failedLogins = 0; + uint32 latency = 0; + std::string OS = handler->GetFirelandsString(LANG_UNKNOWN); // Mute data print variables - int64 muteTime = -1; - std::string muteReason = handler->GetFirelandsString(LANG_NO_REASON); - std::string muteBy = handler->GetFirelandsString(LANG_UNKNOWN); + int64 muteTime = -1; + std::string muteReason = handler->GetFirelandsString(LANG_NO_REASON); + std::string muteBy = handler->GetFirelandsString(LANG_UNKNOWN); // Ban data print variables - int64 banTime = -1; - std::string banType = handler->GetFirelandsString(LANG_UNKNOWN); - std::string banReason = handler->GetFirelandsString(LANG_NO_REASON); - std::string bannedBy = handler->GetFirelandsString(LANG_UNKNOWN); + int64 banTime = -1; + std::string banType = handler->GetFirelandsString(LANG_UNKNOWN); + std::string banReason = handler->GetFirelandsString(LANG_NO_REASON); + std::string bannedBy = handler->GetFirelandsString(LANG_UNKNOWN); // Character data print variables - uint8 raceid, classid = 0; //RACE_NONE, CLASS_NONE - std::string raceStr, classStr = handler->GetFirelandsString(LANG_UNKNOWN); - uint8 gender = 0; - int8 locale = handler->GetSessionDbcLocale(); - uint32 totalPlayerTime = 0; - uint8 level = 0; - std::string alive = handler->GetFirelandsString(LANG_ERROR); - uint64 money = 0; - uint32 xp = 0; - uint32 xptotal = 0; + uint8 raceid, classid = 0; // RACE_NONE, CLASS_NONE + std::string raceStr, classStr = handler->GetFirelandsString(LANG_UNKNOWN); + uint8 gender = 0; + int8 locale = handler->GetSessionDbcLocale(); + uint32 totalPlayerTime = 0; + uint8 level = 0; + std::string alive = handler->GetFirelandsString(LANG_ERROR); + uint64 money = 0; + uint32 xp = 0; + uint32 xptotal = 0; // Position data print uint32 mapId; uint32 areaId; - std::string areaName = handler->GetFirelandsString(LANG_UNKNOWN); - std::string zoneName = handler->GetFirelandsString(LANG_UNKNOWN); + std::string areaName = handler->GetFirelandsString(LANG_UNKNOWN); + std::string zoneName = handler->GetFirelandsString(LANG_UNKNOWN); // Guild data print variables defined so that they exist, but are not necessarily used - uint32 guildId = 0; - uint8 guildRankId = 0; + uint32 guildId = 0; + uint8 guildRankId = 0; std::string guildName; std::string guildRank; std::string note; @@ -1618,18 +1610,18 @@ class misc_commandscript : public CommandScript if (handler->HasLowerSecurity(target, ObjectGuid::Empty)) return false; - accId = target->GetSession()->GetAccountId(); - money = target->GetMoney(); - totalPlayerTime = target->GetTotalPlayedTime(); - level = target->getLevel(); - latency = target->GetSession()->GetLatency(); - raceid = target->getRace(); - classid = target->getClass(); - muteTime = target->GetSession()->m_muteTime; - mapId = target->GetMapId(); - areaId = target->GetAreaId(); - alive = target->IsAlive() ? handler->GetFirelandsString(LANG_YES) : handler->GetFirelandsString(LANG_NO); - gender = target->getGender(); + accId = target->GetSession()->GetAccountId(); + money = target->GetMoney(); + totalPlayerTime = target->GetTotalPlayedTime(); + level = target->getLevel(); + latency = target->GetSession()->GetLatency(); + raceid = target->getRace(); + classid = target->getClass(); + muteTime = target->GetSession()->m_muteTime; + mapId = target->GetMapId(); + areaId = target->GetAreaId(); + alive = target->IsAlive() ? handler->GetFirelandsString(LANG_YES) : handler->GetFirelandsString(LANG_NO); + gender = target->getGender(); } // get additional information from DB else @@ -1646,17 +1638,17 @@ class misc_commandscript : public CommandScript if (!result) return false; - Field* fields = result->Fetch(); - totalPlayerTime = fields[0].GetUInt32(); - level = fields[1].GetUInt8(); - money = fields[2].GetUInt64(); - accId = fields[3].GetUInt32(); - raceid = fields[4].GetUInt8(); - classid = fields[5].GetUInt8(); - mapId = fields[6].GetUInt16(); - areaId = fields[7].GetUInt16(); - gender = fields[8].GetUInt8(); - uint32 health = fields[9].GetUInt32(); + Field* fields = result->Fetch(); + totalPlayerTime = fields[0].GetUInt32(); + level = fields[1].GetUInt8(); + money = fields[2].GetUInt64(); + accId = fields[3].GetUInt32(); + raceid = fields[4].GetUInt8(); + classid = fields[5].GetUInt8(); + mapId = fields[6].GetUInt16(); + areaId = fields[7].GetUInt16(); + gender = fields[8].GetUInt8(); + uint32 health = fields[9].GetUInt32(); uint32 playerFlags = fields[10].GetUInt32(); if (!health || playerFlags & PLAYER_FLAGS_GHOST) @@ -1674,26 +1666,32 @@ class misc_commandscript : public CommandScript if (result) { Field* fields = result->Fetch(); - userName = fields[0].GetString(); - security = fields[1].GetUInt8(); + userName = fields[0].GetString(); + security = fields[1].GetUInt8(); - if(security == 0){ - if(handler->HasPermission(rbac::RBAC_PERM_SEC_ADMINISTRATOR)){ + if (security == 0) + { + if (handler->HasPermission(rbac::RBAC_PERM_SEC_ADMINISTRATOR)) + { security = SEC_ADMINISTRATOR; - } else if (handler->HasPermission(rbac::RBAC_PERM_SEC_GAMEMASTER)){ + } + else if (handler->HasPermission(rbac::RBAC_PERM_SEC_GAMEMASTER)) + { security = SEC_GAMEMASTER; - } else if (handler->HasPermission(rbac::RBAC_PERM_SEC_MODERATOR)){ + } + else if (handler->HasPermission(rbac::RBAC_PERM_SEC_MODERATOR)) + { security = SEC_MODERATOR; } } // Only fetch these fields if commander has sufficient rights) if (handler->HasPermission(rbac::RBAC_PERM_COMMANDS_PINFO_CHECK_PERSONAL_DATA) && // RBAC Perm. 48, Role 39 - (!handler->GetSession() || handler->GetSession()->GetSecurity() >= AccountTypes(security))) + (!handler->GetSession() || handler->GetSession()->GetSecurity() >= AccountTypes(security))) { - eMail = fields[2].GetString(); - regMail = fields[3].GetString(); - lastIp = fields[4].GetString(); + eMail = fields[2].GetString(); + regMail = fields[3].GetString(); + lastIp = fields[4].GetString(); lastLogin = fields[5].GetString(); if (IpLocationRecord const* location = sIPLocation->GetLocationRecord(lastIp)) @@ -1705,17 +1703,17 @@ class misc_commandscript : public CommandScript } else { - eMail = handler->GetFirelandsString(LANG_UNAUTHORIZED); - regMail = handler->GetFirelandsString(LANG_UNAUTHORIZED); - lastIp = handler->GetFirelandsString(LANG_UNAUTHORIZED); + eMail = handler->GetFirelandsString(LANG_UNAUTHORIZED); + regMail = handler->GetFirelandsString(LANG_UNAUTHORIZED); + lastIp = handler->GetFirelandsString(LANG_UNAUTHORIZED); lastLogin = handler->GetFirelandsString(LANG_UNAUTHORIZED); } - muteTime = fields[6].GetUInt64(); - muteReason = fields[7].GetString(); - muteBy = fields[8].GetString(); - failedLogins = fields[9].GetUInt32(); - locked = fields[10].GetUInt8(); - OS = fields[11].GetString(); + muteTime = fields[6].GetUInt64(); + muteReason = fields[7].GetString(); + muteBy = fields[8].GetString(); + failedLogins = fields[9].GetUInt32(); + locked = fields[10].GetUInt8(); + OS = fields[11].GetString(); } // Creates a chat link to the character. Returns nameLink @@ -1736,13 +1734,11 @@ class misc_commandscript : public CommandScript if (result2) { Field* fields = result2->Fetch(); - banTime = int64(fields[1].GetUInt64() ? 0 : fields[0].GetUInt32()); - bannedBy = fields[2].GetString(); - banReason = fields[3].GetString(); + banTime = int64(fields[1].GetUInt64() ? 0 : fields[0].GetUInt32()); + bannedBy = fields[2].GetString(); + banReason = fields[3].GetString(); } - - // Can be used to query data from Characters database stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PINFO_XP); stmt->setUInt32(0, lowguid); @@ -1751,8 +1747,8 @@ class misc_commandscript : public CommandScript if (result4) { Field* fields = result4->Fetch(); - xp = fields[0].GetUInt32(); // Used for "current xp" output and "%u XP Left" calculation - ObjectGuid::LowType gguid = fields[1].GetUInt32(); // We check if have a guild for the person, so we might not require to query it at all + xp = fields[0].GetUInt32(); // Used for "current xp" output and "%u XP Left" calculation + ObjectGuid::LowType gguid = fields[1].GetUInt32(); // We check if have a guild for the person, so we might not require to query it at all xptotal = sObjectMgr->GetXPForLevel(level); if (gguid != 0) @@ -1763,13 +1759,13 @@ class misc_commandscript : public CommandScript PreparedQueryResult result5 = CharacterDatabase.Query(stmt); if (result5) { - Field* fields5 = result5->Fetch(); - guildId = fields5[0].GetUInt32(); - guildName = fields5[1].GetString(); - guildRank = fields5[2].GetString(); - guildRankId = fields5[3].GetUInt8(); - note = fields5[4].GetString(); - officeNote = fields5[5].GetString(); + Field* fields5 = result5->Fetch(); + guildId = fields5[0].GetUInt32(); + guildName = fields5[1].GetString(); + guildRank = fields5[2].GetString(); + guildRankId = fields5[3].GetUInt8(); + note = fields5[4].GetString(); + officeNote = fields5[5].GetString(); } } } @@ -1784,7 +1780,8 @@ class misc_commandscript : public CommandScript // Output III. LANG_PINFO_BANNED if ban exists and is applied if (banTime >= 0) - handler->PSendSysMessage(LANG_PINFO_BANNED, banType.c_str(), banReason.c_str(), banTime > 0 ? secsToTimeString(banTime - GameTime::GetGameTime(), true).c_str() : handler->GetFirelandsString(LANG_PERMANENTLY), bannedBy.c_str()); + handler->PSendSysMessage(LANG_PINFO_BANNED, banType.c_str(), banReason.c_str(), + banTime > 0 ? secsToTimeString(banTime - GameTime::GetGameTime(), true).c_str() : handler->GetFirelandsString(LANG_PERMANENTLY), bannedBy.c_str()); // Output IV. LANG_PINFO_MUTED if mute is applied if (muteTime > 0) @@ -1812,9 +1809,10 @@ class misc_commandscript : public CommandScript handler->PSendSysMessage(LANG_PINFO_CHR_LEVEL_HIGH, level); // Output XI. LANG_PINFO_CHR_RACE - raceStr = DBCManager::GetRaceName(raceid, locale); + raceStr = DBCManager::GetRaceName(raceid, locale); classStr = DBCManager::GetClassName(classid, locale); - handler->PSendSysMessage(LANG_PINFO_CHR_RACE, (gender == 0 ? handler->GetFirelandsString(LANG_CHARACTER_GENDER_MALE) : handler->GetFirelandsString(LANG_CHARACTER_GENDER_FEMALE)), raceStr.c_str(), classStr.c_str()); + handler->PSendSysMessage(LANG_PINFO_CHR_RACE, (gender == 0 ? handler->GetFirelandsString(LANG_CHARACTER_GENDER_MALE) : handler->GetFirelandsString(LANG_CHARACTER_GENDER_FEMALE)), + raceStr.c_str(), classStr.c_str()); // Output XII. LANG_PINFO_CHR_ALIVE handler->PSendSysMessage(LANG_PINFO_CHR_ALIVE, alive.c_str()); @@ -1824,9 +1822,9 @@ class misc_commandscript : public CommandScript PhasingHandler::PrintToChat(handler, target->GetPhaseShift()); // Output XIV. LANG_PINFO_CHR_MONEY - uint32 gold = money / GOLD; - uint32 silv = (money % GOLD) / SILVER; - uint32 copp = (money % GOLD) % SILVER; + uint32 gold = money / GOLD; + uint32 silv = (money % GOLD) / SILVER; + uint32 copp = (money % GOLD) % SILVER; handler->PSendSysMessage(LANG_PINFO_CHR_MONEY, gold, silv, copp); // Position data @@ -1842,8 +1840,7 @@ class misc_commandscript : public CommandScript } if (target) - handler->PSendSysMessage(LANG_PINFO_CHR_MAP, map->MapName, - (!zoneName.empty() ? zoneName.c_str() : handler->GetFirelandsString(LANG_UNKNOWN)), + handler->PSendSysMessage(LANG_PINFO_CHR_MAP, map->MapName, (!zoneName.empty() ? zoneName.c_str() : handler->GetFirelandsString(LANG_UNKNOWN)), (!areaName.empty() ? areaName.c_str() : handler->GetFirelandsString(LANG_UNKNOWN))); // Output XVII. - XVIX. if they are not empty @@ -1867,13 +1864,13 @@ class misc_commandscript : public CommandScript PreparedQueryResult result6 = CharacterDatabase.Query(stmt); if (result6) { - Field* fields = result6->Fetch(); - uint32 readmail = uint32(fields[0].GetDouble()); - uint32 totalmail = uint32(fields[1].GetUInt64()); + Field* fields = result6->Fetch(); + uint32 readmail = uint32(fields[0].GetDouble()); + uint32 totalmail = uint32(fields[1].GetUInt64()); // Output XXI. LANG_INFO_CHR_MAILS if at least one mail is given if (totalmail >= 1) - handler->PSendSysMessage(LANG_PINFO_CHR_MAILS, readmail, totalmail); + handler->PSendSysMessage(LANG_PINFO_CHR_MAILS, readmail, totalmail); } return true; @@ -1948,7 +1945,7 @@ class misc_commandscript : public CommandScript uint32 notSpeakTime = uint32(atoi(delayStr)); // must have strong lesser security level - if (handler->HasLowerSecurity (target, targetGuid, true)) + if (handler->HasLowerSecurity(target, targetGuid, true)) return false; LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_MUTE_TIME); @@ -2015,7 +2012,7 @@ class misc_commandscript : public CommandScript target = session->GetPlayer(); // must have strong lesser security level - if (handler->HasLowerSecurity (target, targetGuid, true)) + if (handler->HasLowerSecurity(target, targetGuid, true)) return false; if (target) @@ -2053,7 +2050,7 @@ class misc_commandscript : public CommandScript if (!*args) return false; - char *nameStr = strtok((char*)args, ""); + char* nameStr = strtok((char*)args, ""); if (!nameStr) return false; @@ -2076,9 +2073,9 @@ class misc_commandscript : public CommandScript } // helper for mutehistory - static bool HandleMuteInfoHelper(uint32 accountId, char const* accountName, ChatHandler *handler) + static bool HandleMuteInfoHelper(uint32 accountId, char const* accountName, ChatHandler* handler) { - LoginDatabasePreparedStatement*stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_MUTE_INFO); + LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_MUTE_INFO); stmt->setUInt32(0, accountId); PreparedQueryResult result = LoginDatabase.Query(stmt); @@ -2100,7 +2097,7 @@ class misc_commandscript : public CommandScript // set it to string localtime_r(&sqlTime, &timeinfo); - strftime(buffer, sizeof(buffer),"%Y-%m-%d %I:%M%p", &timeinfo); + strftime(buffer, sizeof(buffer), "%Y-%m-%d %I:%M%p", &timeinfo); handler->PSendSysMessage(LANG_COMMAND_MUTEHISTORY_OUTPUT, buffer, fields[1].GetUInt32(), fields[2].GetCString(), fields[3].GetCString()); } while (result->NextRow()); @@ -2134,70 +2131,70 @@ class misc_commandscript : public CommandScript switch (movementGenerator->GetMovementGeneratorType()) { - case IDLE_MOTION_TYPE: - handler->SendSysMessage(LANG_MOVEGENS_IDLE); - break; - case RANDOM_MOTION_TYPE: - handler->SendSysMessage(LANG_MOVEGENS_RANDOM); - break; - case WAYPOINT_MOTION_TYPE: - handler->SendSysMessage(LANG_MOVEGENS_WAYPOINT); - break; - case CONFUSED_MOTION_TYPE: - handler->SendSysMessage(LANG_MOVEGENS_CONFUSED); - break; - case CHASE_MOTION_TYPE: - { - Unit const* target = static_cast(movementGenerator)->GetTarget(); + case IDLE_MOTION_TYPE: + handler->SendSysMessage(LANG_MOVEGENS_IDLE); + break; + case RANDOM_MOTION_TYPE: + handler->SendSysMessage(LANG_MOVEGENS_RANDOM); + break; + case WAYPOINT_MOTION_TYPE: + handler->SendSysMessage(LANG_MOVEGENS_WAYPOINT); + break; + case CONFUSED_MOTION_TYPE: + handler->SendSysMessage(LANG_MOVEGENS_CONFUSED); + break; + case CHASE_MOTION_TYPE: + { + Unit const* target = static_cast(movementGenerator)->GetTarget(); - if (!target) - handler->SendSysMessage(LANG_MOVEGENS_CHASE_NULL); - else if (target->GetTypeId() == TYPEID_PLAYER) - handler->PSendSysMessage(LANG_MOVEGENS_CHASE_PLAYER, target->GetName().c_str(), target->GetGUID().GetCounter()); - else - handler->PSendSysMessage(LANG_MOVEGENS_CHASE_CREATURE, target->GetName().c_str(), target->GetGUID().GetCounter()); - break; - } - case FOLLOW_MOTION_TYPE: - { - Unit const* target = static_cast(movementGenerator)->GetTarget(); + if (!target) + handler->SendSysMessage(LANG_MOVEGENS_CHASE_NULL); + else if (target->GetTypeId() == TYPEID_PLAYER) + handler->PSendSysMessage(LANG_MOVEGENS_CHASE_PLAYER, target->GetName().c_str(), target->GetGUID().GetCounter()); + else + handler->PSendSysMessage(LANG_MOVEGENS_CHASE_CREATURE, target->GetName().c_str(), target->GetGUID().GetCounter()); + break; + } + case FOLLOW_MOTION_TYPE: + { + Unit const* target = static_cast(movementGenerator)->GetTarget(); - if (!target) - handler->SendSysMessage(LANG_MOVEGENS_FOLLOW_NULL); - else if (target->GetTypeId() == TYPEID_PLAYER) - handler->PSendSysMessage(LANG_MOVEGENS_FOLLOW_PLAYER, target->GetName().c_str(), target->GetGUID().GetCounter()); - else - handler->PSendSysMessage(LANG_MOVEGENS_FOLLOW_CREATURE, target->GetName().c_str(), target->GetGUID().GetCounter()); - break; - } - case HOME_MOTION_TYPE: - { - if (unit->GetTypeId() == TYPEID_UNIT) - handler->PSendSysMessage(LANG_MOVEGENS_HOME_CREATURE, x, y, z); - else - handler->SendSysMessage(LANG_MOVEGENS_HOME_PLAYER); - break; - } - case FLIGHT_MOTION_TYPE: - handler->SendSysMessage(LANG_MOVEGENS_FLIGHT); - break; - case POINT_MOTION_TYPE: - { - handler->PSendSysMessage(LANG_MOVEGENS_POINT, x, y, z); - break; - } - case FLEEING_MOTION_TYPE: - handler->SendSysMessage(LANG_MOVEGENS_FEAR); - break; - case DISTRACT_MOTION_TYPE: - handler->SendSysMessage(LANG_MOVEGENS_DISTRACT); - break; - case EFFECT_MOTION_TYPE: - handler->SendSysMessage(LANG_MOVEGENS_EFFECT); - break; - default: - handler->PSendSysMessage(LANG_MOVEGENS_UNKNOWN, movementGenerator->GetMovementGeneratorType()); - break; + if (!target) + handler->SendSysMessage(LANG_MOVEGENS_FOLLOW_NULL); + else if (target->GetTypeId() == TYPEID_PLAYER) + handler->PSendSysMessage(LANG_MOVEGENS_FOLLOW_PLAYER, target->GetName().c_str(), target->GetGUID().GetCounter()); + else + handler->PSendSysMessage(LANG_MOVEGENS_FOLLOW_CREATURE, target->GetName().c_str(), target->GetGUID().GetCounter()); + break; + } + case HOME_MOTION_TYPE: + { + if (unit->GetTypeId() == TYPEID_UNIT) + handler->PSendSysMessage(LANG_MOVEGENS_HOME_CREATURE, x, y, z); + else + handler->SendSysMessage(LANG_MOVEGENS_HOME_PLAYER); + break; + } + case FLIGHT_MOTION_TYPE: + handler->SendSysMessage(LANG_MOVEGENS_FLIGHT); + break; + case POINT_MOTION_TYPE: + { + handler->PSendSysMessage(LANG_MOVEGENS_POINT, x, y, z); + break; + } + case FLEEING_MOTION_TYPE: + handler->SendSysMessage(LANG_MOVEGENS_FEAR); + break; + case DISTRACT_MOTION_TYPE: + handler->SendSysMessage(LANG_MOVEGENS_DISTRACT); + break; + case EFFECT_MOTION_TYPE: + handler->SendSysMessage(LANG_MOVEGENS_EFFECT); + break; + default: + handler->PSendSysMessage(LANG_MOVEGENS_UNKNOWN, movementGenerator->GetMovementGeneratorType()); + break; } } return true; @@ -2311,9 +2308,9 @@ class misc_commandscript : public CommandScript // flat melee damage without resistence/etc reduction if (!schoolStr) { - handler->GetSession()->GetPlayer()->DealDamage(target, damage, nullptr, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, nullptr, false); + Unit::DealDamage(handler->GetSession()->GetPlayer(), target, damage, nullptr, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, nullptr, false); if (target != handler->GetSession()->GetPlayer()) - handler->GetSession()->GetPlayer()->SendAttackStateUpdate (HITINFO_AFFECTS_VICTIM, target, 1, SPELL_SCHOOL_MASK_NORMAL, damage, 0, 0, VICTIMSTATE_HIT, 0); + handler->GetSession()->GetPlayer()->SendAttackStateUpdate(HITINFO_AFFECTS_VICTIM, target, 1, SPELL_SCHOOL_MASK_NORMAL, damage, 0, 0, VICTIMSTATE_HIT, 0); return true; } @@ -2324,7 +2321,7 @@ class misc_commandscript : public CommandScript SpellSchoolMask schoolmask = SpellSchoolMask(1 << school); if (Unit::IsDamageReducedByArmor(schoolmask)) - damage = handler->GetSession()->GetPlayer()->CalcArmorReducedDamage(target, damage, nullptr, BASE_ATTACK); + damage = Unit::CalcArmorReducedDamage(handler->GetSession()->GetPlayer(), target, damage, nullptr, BASE_ATTACK); char* spellStr = strtok((char*)nullptr, " "); @@ -2333,7 +2330,7 @@ class misc_commandscript : public CommandScript { Player* attacker = handler->GetSession()->GetPlayer(); DamageInfo dmgInfo(attacker, target, damage, nullptr, schoolmask, SPELL_DIRECT_DAMAGE, BASE_ATTACK); - attacker->CalcAbsorbResist(dmgInfo); + Unit::CalcAbsorbResist(dmgInfo); if (!dmgInfo.GetDamage()) return true; @@ -2342,8 +2339,8 @@ class misc_commandscript : public CommandScript uint32 absorb = dmgInfo.GetAbsorb(); uint32 resist = dmgInfo.GetResist(); - attacker->DealDamageMods(target, damage, &absorb); - attacker->DealDamage(target, damage, nullptr, DIRECT_DAMAGE, schoolmask, nullptr, false); + Unit::DealDamageMods(target, damage, &absorb); + Unit::DealDamage(attacker, target, damage, nullptr, DIRECT_DAMAGE, schoolmask, nullptr, false); attacker->SendAttackStateUpdate(HITINFO_AFFECTS_VICTIM, target, 0, schoolmask, damage, absorb, resist, VICTIMSTATE_HIT, 0); return true; } @@ -2361,7 +2358,7 @@ class misc_commandscript : public CommandScript Player* attacker = handler->GetSession()->GetPlayer(); SpellNonMeleeDamage dmgInfo(attacker, target, spellid, spellInfo->GetSchoolMask()); - attacker->DealDamageMods(dmgInfo.target, dmgInfo.damage, &dmgInfo.absorb); + Unit::DealDamageMods(dmgInfo.target, dmgInfo.damage, &dmgInfo.absorb); attacker->SendSpellNonMeleeDamageLog(&dmgInfo); attacker->DealSpellDamage(&dmgInfo, true); return true; @@ -2419,9 +2416,9 @@ class misc_commandscript : public CommandScript static bool HandleFreezeCommand(ChatHandler* handler, char const* args) { Player* player = handler->getSelectedPlayer(); // Selected player, if any. Might be null. - uint32 freezeDuration = 0; // Freeze Duration (in seconds) - bool canApplyFreeze = false; // Determines if every possible argument is set so Freeze can be applied - bool getDurationFromConfig = false; // If there's no given duration, we'll retrieve the world cfg value later + uint32 freezeDuration = 0; // Freeze Duration (in seconds) + bool canApplyFreeze = false; // Determines if every possible argument is set so Freeze can be applied + bool getDurationFromConfig = false; // If there's no given duration, we'll retrieve the world cfg value later /* Possible Freeze Command Scenarios: @@ -2514,7 +2511,7 @@ class misc_commandscript : public CommandScript return false; } - static bool HandleUnFreezeCommand(ChatHandler* handler, char const*args) + static bool HandleUnFreezeCommand(ChatHandler* handler, char const* args) { std::string name; Player* player; @@ -2602,8 +2599,7 @@ class misc_commandscript : public CommandScript else // show time left (seconds) handler->PSendSysMessage(LANG_COMMAND_TEMP_FROZEN_PLAYER, player.c_str(), remaintime / IN_MILLISECONDS); - } - while (result->NextRow()); + } while (result->NextRow()); return true; } diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_ragnaros.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_ragnaros.cpp index c6be0fd9..1dd58233 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_ragnaros.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_ragnaros.cpp @@ -22,333 +22,338 @@ SDComment: some spells doesnt work correctly SDCategory: Molten Core EndScriptData */ -#include "ScriptMgr.h" #include "InstanceScript.h" -#include "molten_core.h" #include "ObjectAccessor.h" +#include "ScriptMgr.h" #include "ScriptedCreature.h" #include "TemporarySummon.h" +#include "molten_core.h" enum Texts { - SAY_SUMMON_MAJ = 0, - SAY_ARRIVAL1_RAG = 1, - SAY_ARRIVAL2_MAJ = 2, - SAY_ARRIVAL3_RAG = 3, - SAY_ARRIVAL5_RAG = 4, - SAY_REINFORCEMENTS1 = 5, - SAY_REINFORCEMENTS2 = 6, - SAY_HAND = 7, - SAY_WRATH = 8, - SAY_KILL = 9, - SAY_MAGMABURST = 10 + SAY_SUMMON_MAJ = 0, + SAY_ARRIVAL1_RAG = 1, + SAY_ARRIVAL2_MAJ = 2, + SAY_ARRIVAL3_RAG = 3, + SAY_ARRIVAL5_RAG = 4, + SAY_REINFORCEMENTS1 = 5, + SAY_REINFORCEMENTS2 = 6, + SAY_HAND = 7, + SAY_WRATH = 8, + SAY_KILL = 9, + SAY_MAGMABURST = 10 }; enum Spells { - SPELL_HAND_OF_RAGNAROS = 19780, - SPELL_WRATH_OF_RAGNAROS = 20566, - SPELL_LAVA_BURST = 21158, - SPELL_MAGMA_BLAST = 20565, // Ranged attack - SPELL_SONS_OF_FLAME_DUMMY = 21108, // Server side effect - SPELL_RAGSUBMERGE = 21107, // Stealth aura - SPELL_RAGEMERGE = 20568, - SPELL_MELT_WEAPON = 21388, - SPELL_ELEMENTAL_FIRE = 20564, - SPELL_ERRUPTION = 17731 + SPELL_HAND_OF_RAGNAROS = 19780, + SPELL_WRATH_OF_RAGNAROS = 20566, + SPELL_LAVA_BURST = 21158, + SPELL_MAGMA_BLAST = 20565, // Ranged attack + SPELL_SONS_OF_FLAME_DUMMY = 21108, // Server side effect + SPELL_RAGSUBMERGE = 21107, // Stealth aura + SPELL_RAGEMERGE = 20568, + SPELL_MELT_WEAPON = 21388, + SPELL_ELEMENTAL_FIRE = 20564, + SPELL_ERRUPTION = 17731 }; enum Events { - EVENT_ERUPTION = 1, - EVENT_WRATH_OF_RAGNAROS = 2, - EVENT_HAND_OF_RAGNAROS = 3, - EVENT_LAVA_BURST = 4, - EVENT_ELEMENTAL_FIRE = 5, - EVENT_MAGMA_BLAST = 6, - EVENT_SUBMERGE = 7, - - EVENT_INTRO_1 = 8, - EVENT_INTRO_2 = 9, - EVENT_INTRO_3 = 10, - EVENT_INTRO_4 = 11, - EVENT_INTRO_5 = 12 + EVENT_ERUPTION = 1, + EVENT_WRATH_OF_RAGNAROS = 2, + EVENT_HAND_OF_RAGNAROS = 3, + EVENT_LAVA_BURST = 4, + EVENT_ELEMENTAL_FIRE = 5, + EVENT_MAGMA_BLAST = 6, + EVENT_SUBMERGE = 7, + + EVENT_INTRO_1 = 8, + EVENT_INTRO_2 = 9, + EVENT_INTRO_3 = 10, + EVENT_INTRO_4 = 11, + EVENT_INTRO_5 = 12 }; class boss_ragnaros : public CreatureScript { - public: - boss_ragnaros() : CreatureScript("boss_ragnaros") { } - - struct boss_ragnarosAI : public BossAI + public: + boss_ragnaros() : CreatureScript("boss_ragnaros") + { + } + + struct boss_ragnarosAI : public BossAI + { + boss_ragnarosAI(Creature* creature) : BossAI(creature, BOSS_RAGNAROS) { - boss_ragnarosAI(Creature* creature) : BossAI(creature, BOSS_RAGNAROS) - { - Initialize(); - _introState = 0; - me->SetReactState(REACT_PASSIVE); - me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - SetCombatMovement(false); - } + Initialize(); + _introState = 0; + me->SetReactState(REACT_PASSIVE); + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + SetCombatMovement(false); + } - void Initialize() - { - _emergeTimer = 90000; - _hasYelledMagmaBurst = false; - _hasSubmergedOnce = false; - _isBanished = false; - } + void Initialize() + { + _emergeTimer = 90000; + _hasYelledMagmaBurst = false; + _hasSubmergedOnce = false; + _isBanished = false; + } - void Reset() override - { - BossAI::Reset(); - Initialize(); - me->SetUInt32Value(UNIT_NPC_EMOTESTATE, 0); - } + void Reset() override + { + BossAI::Reset(); + Initialize(); + me->SetUInt32Value(UNIT_NPC_EMOTESTATE, 0); + } - void JustEngagedWith(Unit* victim) override - { - BossAI::JustEngagedWith(victim); - events.ScheduleEvent(EVENT_ERUPTION, 15000); - events.ScheduleEvent(EVENT_WRATH_OF_RAGNAROS, 30000); - events.ScheduleEvent(EVENT_HAND_OF_RAGNAROS, 25000); - events.ScheduleEvent(EVENT_LAVA_BURST, 10000); - events.ScheduleEvent(EVENT_ELEMENTAL_FIRE, 3000); - events.ScheduleEvent(EVENT_MAGMA_BLAST, 2000); - events.ScheduleEvent(EVENT_SUBMERGE, 180000); - } + void JustEngagedWith(Unit* victim) override + { + BossAI::JustEngagedWith(victim); + events.ScheduleEvent(EVENT_ERUPTION, 15000); + events.ScheduleEvent(EVENT_WRATH_OF_RAGNAROS, 30000); + events.ScheduleEvent(EVENT_HAND_OF_RAGNAROS, 25000); + events.ScheduleEvent(EVENT_LAVA_BURST, 10000); + events.ScheduleEvent(EVENT_ELEMENTAL_FIRE, 3000); + events.ScheduleEvent(EVENT_MAGMA_BLAST, 2000); + events.ScheduleEvent(EVENT_SUBMERGE, 180000); + } - void KilledUnit(Unit* /*victim*/) override - { - if (urand(0, 99) < 25) - Talk(SAY_KILL); - } + void KilledUnit(Unit* /*victim*/) override + { + if (urand(0, 99) < 25) + Talk(SAY_KILL); + } - void UpdateAI(uint32 diff) override + void UpdateAI(uint32 diff) override + { + if (_introState != 2) { - if (_introState != 2) + if (!_introState) { - if (!_introState) - { - me->HandleEmoteCommand(EMOTE_ONESHOT_EMERGE); - events.ScheduleEvent(EVENT_INTRO_1, 4000); - events.ScheduleEvent(EVENT_INTRO_2, 23000); - events.ScheduleEvent(EVENT_INTRO_3, 42000); - events.ScheduleEvent(EVENT_INTRO_4, 43000); - events.ScheduleEvent(EVENT_INTRO_5, 53000); - _introState = 1; - } + me->HandleEmoteCommand(EMOTE_ONESHOT_EMERGE); + events.ScheduleEvent(EVENT_INTRO_1, 4000); + events.ScheduleEvent(EVENT_INTRO_2, 23000); + events.ScheduleEvent(EVENT_INTRO_3, 42000); + events.ScheduleEvent(EVENT_INTRO_4, 43000); + events.ScheduleEvent(EVENT_INTRO_5, 53000); + _introState = 1; + } - events.Update(diff); + events.Update(diff); - while (uint32 eventId = events.ExecuteEvent()) - { - switch (eventId) - { - case EVENT_INTRO_1: - Talk(SAY_ARRIVAL1_RAG); - break; - case EVENT_INTRO_2: - Talk(SAY_ARRIVAL3_RAG); - break; - case EVENT_INTRO_3: - me->HandleEmoteCommand(EMOTE_ONESHOT_ATTACK1H); - break; - case EVENT_INTRO_4: - Talk(SAY_ARRIVAL5_RAG); - if (Creature* executus = ObjectAccessor::GetCreature(*me, instance->GetGuidData(BOSS_MAJORDOMO_EXECUTUS))) - me->Kill(executus); - break; - case EVENT_INTRO_5: - me->SetReactState(REACT_AGGRESSIVE); - me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - me->SetImmuneToPC(false); - _introState = 2; - break; - default: - break; - } - } - } - else + while (uint32 eventId = events.ExecuteEvent()) { - if (_isBanished && ((_emergeTimer <= diff) || (instance->GetData(DATA_RAGNAROS_ADDS)) > 8)) + switch (eventId) { - //Become unbanished again + case EVENT_INTRO_1: + Talk(SAY_ARRIVAL1_RAG); + break; + case EVENT_INTRO_2: + Talk(SAY_ARRIVAL3_RAG); + break; + case EVENT_INTRO_3: + me->HandleEmoteCommand(EMOTE_ONESHOT_ATTACK1H); + break; + case EVENT_INTRO_4: + Talk(SAY_ARRIVAL5_RAG); + if (Creature* executus = ObjectAccessor::GetCreature(*me, instance->GetGuidData(BOSS_MAJORDOMO_EXECUTUS))) + Unit::Kill(me, executus); + break; + case EVENT_INTRO_5: me->SetReactState(REACT_AGGRESSIVE); - me->SetFaction(FACTION_MONSTER); - me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - me->SetUInt32Value(UNIT_NPC_EMOTESTATE, 0); - me->HandleEmoteCommand(EMOTE_ONESHOT_EMERGE); - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) - AttackStart(target); - instance->SetData(DATA_RAGNAROS_ADDS, 0); - - //DoCast(me, SPELL_RAGEMERGE); //"phase spells" didnt worked correctly so Ive commented them and wrote solution witch doesnt need core support - _isBanished = false; - } - else if (_isBanished) - { - _emergeTimer -= diff; - //Do nothing while banished - return; + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + me->SetImmuneToPC(false); + _introState = 2; + break; + default: + break; } + } + } + else + { + if (_isBanished && ((_emergeTimer <= diff) || (instance->GetData(DATA_RAGNAROS_ADDS)) > 8)) + { + // Become unbanished again + me->SetReactState(REACT_AGGRESSIVE); + me->SetFaction(FACTION_MONSTER); + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + me->SetUInt32Value(UNIT_NPC_EMOTESTATE, 0); + me->HandleEmoteCommand(EMOTE_ONESHOT_EMERGE); + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) + AttackStart(target); + instance->SetData(DATA_RAGNAROS_ADDS, 0); + + // DoCast(me, SPELL_RAGEMERGE); //"phase spells" didnt worked correctly so Ive commented them and wrote solution witch doesnt need core support + _isBanished = false; + } + else if (_isBanished) + { + _emergeTimer -= diff; + // Do nothing while banished + return; + } - //Return since we have no target - if (!UpdateVictim()) - return; + // Return since we have no target + if (!UpdateVictim()) + return; - events.Update(diff); + events.Update(diff); - while (uint32 eventId = events.ExecuteEvent()) + while (uint32 eventId = events.ExecuteEvent()) + { + switch (eventId) { - switch (eventId) + case EVENT_ERUPTION: + DoCastVictim(SPELL_ERRUPTION); + events.ScheduleEvent(EVENT_ERUPTION, urand(20000, 45000)); + break; + case EVENT_WRATH_OF_RAGNAROS: + DoCastVictim(SPELL_WRATH_OF_RAGNAROS); + if (urand(0, 1)) + Talk(SAY_WRATH); + events.ScheduleEvent(EVENT_WRATH_OF_RAGNAROS, 25000); + break; + case EVENT_HAND_OF_RAGNAROS: + DoCast(me, SPELL_HAND_OF_RAGNAROS); + if (urand(0, 1)) + Talk(SAY_HAND); + events.ScheduleEvent(EVENT_HAND_OF_RAGNAROS, 20000); + break; + case EVENT_LAVA_BURST: + DoCastVictim(SPELL_LAVA_BURST); + events.ScheduleEvent(EVENT_LAVA_BURST, 10000); + break; + case EVENT_ELEMENTAL_FIRE: + DoCastVictim(SPELL_ELEMENTAL_FIRE); + events.ScheduleEvent(EVENT_ELEMENTAL_FIRE, urand(10000, 14000)); + break; + case EVENT_MAGMA_BLAST: + if (!me->IsWithinMeleeRange(me->GetVictim())) { - case EVENT_ERUPTION: - DoCastVictim(SPELL_ERRUPTION); - events.ScheduleEvent(EVENT_ERUPTION, urand(20000, 45000)); - break; - case EVENT_WRATH_OF_RAGNAROS: - DoCastVictim(SPELL_WRATH_OF_RAGNAROS); - if (urand(0, 1)) - Talk(SAY_WRATH); - events.ScheduleEvent(EVENT_WRATH_OF_RAGNAROS, 25000); - break; - case EVENT_HAND_OF_RAGNAROS: - DoCast(me, SPELL_HAND_OF_RAGNAROS); - if (urand(0, 1)) - Talk(SAY_HAND); - events.ScheduleEvent(EVENT_HAND_OF_RAGNAROS, 20000); - break; - case EVENT_LAVA_BURST: - DoCastVictim(SPELL_LAVA_BURST); - events.ScheduleEvent(EVENT_LAVA_BURST, 10000); - break; - case EVENT_ELEMENTAL_FIRE: - DoCastVictim(SPELL_ELEMENTAL_FIRE); - events.ScheduleEvent(EVENT_ELEMENTAL_FIRE, urand(10000, 14000)); - break; - case EVENT_MAGMA_BLAST: - if (!me->IsWithinMeleeRange(me->GetVictim())) - { - DoCastVictim(SPELL_MAGMA_BLAST); - if (!_hasYelledMagmaBurst) - { - //Say our dialog - Talk(SAY_MAGMABURST); - _hasYelledMagmaBurst = true; - } - } - events.ScheduleEvent(EVENT_MAGMA_BLAST, 2500); - break; - case EVENT_SUBMERGE: + DoCastVictim(SPELL_MAGMA_BLAST); + if (!_hasYelledMagmaBurst) { - if (!_isBanished) - { - //Creature spawning and ragnaros becomming unattackable - //is not very well supported in the core //no it really isnt - //so added normaly spawning and banish workaround and attack again after 90 secs. - me->AttackStop(); - ResetThreatList(); - me->SetReactState(REACT_PASSIVE); - me->InterruptNonMeleeSpells(false); - //Root self - //DoCast(me, 23973); - me->SetFaction(FACTION_FRIENDLY); - me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_SUBMERGED); - me->HandleEmoteCommand(EMOTE_ONESHOT_SUBMERGE); - instance->SetData(DATA_RAGNAROS_ADDS, 0); - - if (!_hasSubmergedOnce) - { - Talk(SAY_REINFORCEMENTS1); - - // summon 8 elementals - for (uint8 i = 0; i < 8; ++i) - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) - if (Creature* summoned = me->SummonCreature(12143, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0.0f, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 900000)) - summoned->AI()->AttackStart(target); - - _hasSubmergedOnce = true; - _isBanished = true; - //DoCast(me, SPELL_RAGSUBMERGE); - _emergeTimer = 90000; - - } - else - { - Talk(SAY_REINFORCEMENTS2); - - for (uint8 i = 0; i < 8; ++i) - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) - if (Creature* summoned = me->SummonCreature(12143, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0.0f, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 900000)) - summoned->AI()->AttackStart(target); - - _isBanished = true; - //DoCast(me, SPELL_RAGSUBMERGE); - _emergeTimer = 90000; - } - } - events.ScheduleEvent(EVENT_SUBMERGE, 180000); - break; + // Say our dialog + Talk(SAY_MAGMABURST); + _hasYelledMagmaBurst = true; } - default: - break; } - } + events.ScheduleEvent(EVENT_MAGMA_BLAST, 2500); + break; + case EVENT_SUBMERGE: + { + if (!_isBanished) + { + // Creature spawning and ragnaros becomming unattackable + // is not very well supported in the core //no it really isnt + // so added normaly spawning and banish workaround and attack again after 90 secs. + me->AttackStop(); + ResetThreatList(); + me->SetReactState(REACT_PASSIVE); + me->InterruptNonMeleeSpells(false); + // Root self + // DoCast(me, 23973); + me->SetFaction(FACTION_FRIENDLY); + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_SUBMERGED); + me->HandleEmoteCommand(EMOTE_ONESHOT_SUBMERGE); + instance->SetData(DATA_RAGNAROS_ADDS, 0); + + if (!_hasSubmergedOnce) + { + Talk(SAY_REINFORCEMENTS1); + + // summon 8 elementals + for (uint8 i = 0; i < 8; ++i) + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) + if (Creature* summoned = + me->SummonCreature(12143, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0.0f, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 900000)) + summoned->AI()->AttackStart(target); + + _hasSubmergedOnce = true; + _isBanished = true; + // DoCast(me, SPELL_RAGSUBMERGE); + _emergeTimer = 90000; + } + else + { + Talk(SAY_REINFORCEMENTS2); - DoMeleeAttackIfReady(); - } - } + for (uint8 i = 0; i < 8; ++i) + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) + if (Creature* summoned = + me->SummonCreature(12143, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0.0f, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 900000)) + summoned->AI()->AttackStart(target); - private: - uint32 _emergeTimer; - uint8 _introState; - bool _hasYelledMagmaBurst; - bool _hasSubmergedOnce; - bool _isBanished; - }; + _isBanished = true; + // DoCast(me, SPELL_RAGSUBMERGE); + _emergeTimer = 90000; + } + } + events.ScheduleEvent(EVENT_SUBMERGE, 180000); + break; + } + default: + break; + } + } - CreatureAI* GetAI(Creature* creature) const override - { - return GetMoltenCoreAI(creature); + DoMeleeAttackIfReady(); + } } + + private: + uint32 _emergeTimer; + uint8 _introState; + bool _hasYelledMagmaBurst; + bool _hasSubmergedOnce; + bool _isBanished; + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return GetMoltenCoreAI(creature); + } }; class npc_son_of_flame : public CreatureScript { - public: - npc_son_of_flame() : CreatureScript("npc_SonOfFlame") { } - - struct npc_son_of_flameAI : public ScriptedAI //didnt work correctly in EAI for me... + public: + npc_son_of_flame() : CreatureScript("npc_SonOfFlame") + { + } + + struct npc_son_of_flameAI : public ScriptedAI // didnt work correctly in EAI for me... + { + npc_son_of_flameAI(Creature* creature) : ScriptedAI(creature) { - npc_son_of_flameAI(Creature* creature) : ScriptedAI(creature) - { - instance = me->GetInstanceScript(); - } + instance = me->GetInstanceScript(); + } - void JustDied(Unit* /*killer*/) override - { - instance->SetData(DATA_RAGNAROS_ADDS, 1); - } + void JustDied(Unit* /*killer*/) override + { + instance->SetData(DATA_RAGNAROS_ADDS, 1); + } - void UpdateAI(uint32 /*diff*/) override - { - if (!UpdateVictim()) - return; + void UpdateAI(uint32 /*diff*/) override + { + if (!UpdateVictim()) + return; - DoMeleeAttackIfReady(); - } + DoMeleeAttackIfReady(); + } - private: - InstanceScript* instance; - }; + private: + InstanceScript* instance; + }; - CreatureAI* GetAI(Creature* creature) const override - { - return GetMoltenCoreAI(creature); - } + CreatureAI* GetAI(Creature* creature) const override + { + return GetMoltenCoreAI(creature); + } }; void AddSC_boss_ragnaros() diff --git a/src/server/scripts/EasternKingdoms/Karazhan/karazhan.cpp b/src/server/scripts/EasternKingdoms/Karazhan/karazhan.cpp index c3cb89c6..16da27a1 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/karazhan.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/karazhan.cpp @@ -1,4 +1,4 @@ - /* +/* * This file is part of the FirelandsCore Project. See AUTHORS file for Copyright information * * This program is free software; you can redistribute it and/or modify it @@ -27,14 +27,14 @@ npc_barnes npc_image_of_medivh EndContentData */ -#include "ScriptMgr.h" -#include "InstanceScript.h" #include "karazhan.h" +#include "InstanceScript.h" #include "Log.h" #include "Map.h" #include "MotionMaster.h" #include "ObjectAccessor.h" #include "Player.h" +#include "ScriptMgr.h" #include "ScriptedEscortAI.h" #include "ScriptedGossip.h" #include "TemporarySummon.h" @@ -42,43 +42,43 @@ EndContentData */ enum Spells { // Barnes - SPELL_SPOTLIGHT = 25824, - SPELL_TUXEDO = 32616, + SPELL_SPOTLIGHT = 25824, + SPELL_TUXEDO = 32616, // Berthold - SPELL_TELEPORT = 39567, + SPELL_TELEPORT = 39567, // Image of Medivh - SPELL_FIRE_BALL = 30967, - SPELL_UBER_FIREBALL = 30971, - SPELL_CONFLAGRATION_BLAST = 30977, - SPELL_MANA_SHIELD = 31635 + SPELL_FIRE_BALL = 30967, + SPELL_UBER_FIREBALL = 30971, + SPELL_CONFLAGRATION_BLAST = 30977, + SPELL_MANA_SHIELD = 31635 }; enum Creatures { - NPC_ARCANAGOS = 17652, - NPC_SPOTLIGHT = 19525 + NPC_ARCANAGOS = 17652, + NPC_SPOTLIGHT = 19525 }; /*###### # npc_barnesAI ######*/ -#define GOSSIP_READY "I'm not an actor." +#define GOSSIP_READY "I'm not an actor." -#define SAY_READY "Splendid, I'm going to get the audience ready. Break a leg!" -#define SAY_OZ_INTRO1 "Finally, everything is in place. Are you ready for your big stage debut?" -#define OZ_GOSSIP1 "I'm not an actor." -#define SAY_OZ_INTRO2 "Don't worry, you'll be fine. You look like a natural!" -#define OZ_GOSSIP2 "Ok, I'll give it a try, then." +#define SAY_READY "Splendid, I'm going to get the audience ready. Break a leg!" +#define SAY_OZ_INTRO1 "Finally, everything is in place. Are you ready for your big stage debut?" +#define OZ_GOSSIP1 "I'm not an actor." +#define SAY_OZ_INTRO2 "Don't worry, you'll be fine. You look like a natural!" +#define OZ_GOSSIP2 "Ok, I'll give it a try, then." -#define SAY_RAJ_INTRO1 "The romantic plays are really tough, but you'll do better this time. You have TALENT. Ready?" -#define RAJ_GOSSIP1 "I've never been more ready." +#define SAY_RAJ_INTRO1 "The romantic plays are really tough, but you'll do better this time. You have TALENT. Ready?" +#define RAJ_GOSSIP1 "I've never been more ready." -#define OZ_GM_GOSSIP1 "[GM] Change event to EVENT_OZ" -#define OZ_GM_GOSSIP2 "[GM] Change event to EVENT_HOOD" -#define OZ_GM_GOSSIP3 "[GM] Change event to EVENT_RAJ" +#define OZ_GM_GOSSIP1 "[GM] Change event to EVENT_OZ" +#define OZ_GM_GOSSIP2 "[GM] Change event to EVENT_HOOD" +#define OZ_GM_GOSSIP3 "[GM] Change event to EVENT_RAJ" struct Dialogue { @@ -86,49 +86,32 @@ struct Dialogue uint32 timer; }; -static Dialogue OzDialogue[]= -{ - {0, 6000}, - {1, 18000}, - {2, 9000}, - {3, 15000} -}; +static Dialogue OzDialogue[] = {{0, 6000}, {1, 18000}, {2, 9000}, {3, 15000}}; -static Dialogue HoodDialogue[]= -{ - {4, 6000}, - {5, 10000}, - {6, 14000}, - {7, 15000} -}; +static Dialogue HoodDialogue[] = {{4, 6000}, {5, 10000}, {6, 14000}, {7, 15000}}; -static Dialogue RAJDialogue[]= -{ - {8, 5000}, - {9, 7000}, - {10, 14000}, - {11, 14000} -}; +static Dialogue RAJDialogue[] = {{8, 5000}, {9, 7000}, {10, 14000}, {11, 14000}}; // Entries and spawn locations for creatures in Oz event -float Spawns[6][2]= -{ - {17535, -10896}, // Dorothee - {17546, -10891}, // Roar - {17547, -10884}, // Tinhead - {17543, -10902}, // Strawman - {17603, -10892}, // Grandmother - {17534, -10900}, // Julianne +float Spawns[6][2] = { + {17535, -10896}, // Dorothee + {17546, -10891}, // Roar + {17547, -10884}, // Tinhead + {17543, -10902}, // Strawman + {17603, -10892}, // Grandmother + {17534, -10900}, // Julianne }; -#define SPAWN_Z 90.5f -#define SPAWN_Y -1758 -#define SPAWN_O 4.738f +#define SPAWN_Z 90.5f +#define SPAWN_Y -1758 +#define SPAWN_O 4.738f class npc_barnes : public CreatureScript { -public: - npc_barnes() : CreatureScript("npc_barnes") { } + public: + npc_barnes() : CreatureScript("npc_barnes") + { + } struct npc_barnesAI : public EscortAI { @@ -174,44 +157,44 @@ class npc_barnes : public CreatureScript { instance->SetBossState(DATA_OPERA_PERFORMANCE, IN_PROGRESS); - //resets count for this event, in case earlier failed + // resets count for this event, in case earlier failed if (m_uiEventId == EVENT_OZ) instance->SetData(DATA_OPERA_OZ_DEATHCOUNT, IN_PROGRESS); Start(false, false); } - void JustEngagedWith(Unit* /*who*/) override { } + void JustEngagedWith(Unit* /*who*/) override + { + } void WaypointReached(uint32 waypointId, uint32 /*pathId*/) override { switch (waypointId) { - case 0: - DoCast(me, SPELL_TUXEDO, false); - instance->DoUseDoorOrButton(instance->GetGuidData(DATA_GO_STAGEDOORLEFT)); - break; - case 4: - TalkCount = 0; - SetEscortPaused(true); - - if (Creature* spotlight = me->SummonCreature(NPC_SPOTLIGHT, - me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), 0.0f, - TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 60000)) - { - spotlight->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - spotlight->CastSpell(spotlight, SPELL_SPOTLIGHT, false); - m_uiSpotlightGUID = spotlight->GetGUID(); - } - break; - case 8: - instance->DoUseDoorOrButton(instance->GetGuidData(DATA_GO_STAGEDOORLEFT)); - PerformanceReady = true; - break; - case 9: - PrepareEncounter(); - instance->DoUseDoorOrButton(instance->GetGuidData(DATA_GO_CURTAINS)); - break; + case 0: + DoCast(me, SPELL_TUXEDO, false); + instance->DoUseDoorOrButton(instance->GetGuidData(DATA_GO_STAGEDOORLEFT)); + break; + case 4: + TalkCount = 0; + SetEscortPaused(true); + + if (Creature* spotlight = me->SummonCreature(NPC_SPOTLIGHT, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), 0.0f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 60000)) + { + spotlight->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + spotlight->CastSpell(spotlight, SPELL_SPOTLIGHT, false); + m_uiSpotlightGUID = spotlight->GetGUID(); + } + break; + case 8: + instance->DoUseDoorOrButton(instance->GetGuidData(DATA_GO_STAGEDOORLEFT)); + PerformanceReady = true; + break; + case 9: + PrepareEncounter(); + instance->DoUseDoorOrButton(instance->GetGuidData(DATA_GO_CURTAINS)); + break; } } @@ -221,30 +204,30 @@ class npc_barnes : public CreatureScript switch (m_uiEventId) { - case EVENT_OZ: - if (OzDialogue[count].textid) - text = OzDialogue[count].textid; - if (OzDialogue[count].timer) - TalkTimer = OzDialogue[count].timer; - break; - - case EVENT_HOOD: - if (HoodDialogue[count].textid) - text = HoodDialogue[count].textid; - if (HoodDialogue[count].timer) - TalkTimer = HoodDialogue[count].timer; - break; - - case EVENT_RAJ: - if (RAJDialogue[count].textid) - text = RAJDialogue[count].textid; - if (RAJDialogue[count].timer) - TalkTimer = RAJDialogue[count].timer; - break; + case EVENT_OZ: + if (OzDialogue[count].textid) + text = OzDialogue[count].textid; + if (OzDialogue[count].timer) + TalkTimer = OzDialogue[count].timer; + break; + + case EVENT_HOOD: + if (HoodDialogue[count].textid) + text = HoodDialogue[count].textid; + if (HoodDialogue[count].timer) + TalkTimer = HoodDialogue[count].timer; + break; + + case EVENT_RAJ: + if (RAJDialogue[count].textid) + text = RAJDialogue[count].textid; + if (RAJDialogue[count].timer) + TalkTimer = RAJDialogue[count].timer; + break; } if (text) - CreatureAI::Talk(text); + CreatureAI::Talk(text); } void PrepareEncounter() @@ -255,18 +238,18 @@ class npc_barnes : public CreatureScript switch (m_uiEventId) { - case EVENT_OZ: - index = 0; - count = 4; - break; - case EVENT_HOOD: - index = 4; - count = index+1; - break; - case EVENT_RAJ: - index = 5; - count = index+1; - break; + case EVENT_OZ: + index = 0; + count = 4; + break; + case EVENT_HOOD: + index = 4; + count = index + 1; + break; + case EVENT_RAJ: + index = 5; + count = index + 1; + break; } for (; index < count; ++index) @@ -274,7 +257,7 @@ class npc_barnes : public CreatureScript uint32 entry = ((uint32)Spawns[index][0]); float PosX = Spawns[index][1]; - if (Creature* creature = me->SummonCreature(entry, PosX, SPAWN_Y, SPAWN_Z, SPAWN_O, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, HOUR*2*IN_MILLISECONDS)) + if (Creature* creature = me->SummonCreature(entry, PosX, SPAWN_Y, SPAWN_Z, SPAWN_O, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, HOUR * 2 * IN_MILLISECONDS)) { // In case database has bad flags creature->SetUInt32Value(UNIT_FIELD_FLAGS, 0); @@ -304,7 +287,9 @@ class npc_barnes : public CreatureScript Talk(TalkCount); ++TalkCount; - } else TalkTimer -= diff; + } + else + TalkTimer -= diff; } if (PerformanceReady) @@ -335,7 +320,9 @@ class npc_barnes : public CreatureScript } WipeTimer = 15000; - } else WipeTimer -= diff; + } + else + WipeTimer -= diff; } } } @@ -347,30 +334,30 @@ class npc_barnes : public CreatureScript switch (action) { - case GOSSIP_ACTION_INFO_DEF + 1: - AddGossipItemFor(player, GOSSIP_ICON_CHAT, OZ_GOSSIP2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); - SendGossipMenuFor(player, 8971, me->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: - CloseGossipMenuFor(player); - m_uiEventId = urand(EVENT_OZ, EVENT_RAJ); - StartEvent(); - break; - case GOSSIP_ACTION_INFO_DEF + 3: - CloseGossipMenuFor(player); - m_uiEventId = EVENT_OZ; - LOG_DEBUG("scripts", "player (%s) manually set Opera event to EVENT_OZ", player->GetGUID().ToString().c_str()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: - CloseGossipMenuFor(player); - m_uiEventId = EVENT_HOOD; - LOG_DEBUG("scripts", "player (%s) manually set Opera event to EVENT_HOOD", player->GetGUID().ToString().c_str()); - break; - case GOSSIP_ACTION_INFO_DEF + 5: - CloseGossipMenuFor(player); - m_uiEventId = EVENT_RAJ; - LOG_DEBUG("scripts", "player (%s) manually set Opera event to EVENT_RAJ", player->GetGUID().ToString().c_str()); - break; + case GOSSIP_ACTION_INFO_DEF + 1: + AddGossipItemFor(player, GOSSIP_ICON_CHAT, OZ_GOSSIP2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); + SendGossipMenuFor(player, 8971, me->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: + CloseGossipMenuFor(player); + m_uiEventId = urand(EVENT_OZ, EVENT_RAJ); + StartEvent(); + break; + case GOSSIP_ACTION_INFO_DEF + 3: + CloseGossipMenuFor(player); + m_uiEventId = EVENT_OZ; + LOG_DEBUG("scripts", "player (%s) manually set Opera event to EVENT_OZ", player->GetGUID().ToString().c_str()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: + CloseGossipMenuFor(player); + m_uiEventId = EVENT_HOOD; + LOG_DEBUG("scripts", "player (%s) manually set Opera event to EVENT_HOOD", player->GetGUID().ToString().c_str()); + break; + case GOSSIP_ACTION_INFO_DEF + 5: + CloseGossipMenuFor(player); + m_uiEventId = EVENT_RAJ; + LOG_DEBUG("scripts", "player (%s) manually set Opera event to EVENT_RAJ", player->GetGUID().ToString().c_str()); + break; } return true; @@ -416,24 +403,25 @@ class npc_barnes : public CreatureScript # npc_image_of_medivh ####*/ -#define SAY_DIALOG_MEDIVH_1 "You've got my attention, dragon. You'll find I'm not as easily scared as the villagers below." -#define SAY_DIALOG_ARCANAGOS_2 "Your dabbling in the arcane has gone too far, Medivh. You've attracted the attention of powers beyond your understanding. You must leave Karazhan at once!" -#define SAY_DIALOG_MEDIVH_3 "You dare challenge me at my own dwelling? Your arrogance is astounding, even for a dragon!" -#define SAY_DIALOG_ARCANAGOS_4 "A dark power seeks to use you, Medivh! If you stay, dire days will follow. You must hurry, we don't have much time!" -#define SAY_DIALOG_MEDIVH_5 "I do not know what you speak of, dragon... but I will not be bullied by this display of insolence. I'll leave Karazhan when it suits me!" -#define SAY_DIALOG_ARCANAGOS_6 "You leave me no alternative. I will stop you by force if you won't listen to reason!" -#define EMOTE_DIALOG_MEDIVH_7 "begins to cast a spell of great power, weaving his own essence into the magic." -#define SAY_DIALOG_ARCANAGOS_8 "What have you done, wizard? This cannot be! I'm burning from... within!" -#define SAY_DIALOG_MEDIVH_9 "He should not have angered me. I must go... recover my strength now..." - +#define SAY_DIALOG_MEDIVH_1 "You've got my attention, dragon. You'll find I'm not as easily scared as the villagers below." +#define SAY_DIALOG_ARCANAGOS_2 "Your dabbling in the arcane has gone too far, Medivh. You've attracted the attention of powers beyond your understanding. You must leave Karazhan at once!" +#define SAY_DIALOG_MEDIVH_3 "You dare challenge me at my own dwelling? Your arrogance is astounding, even for a dragon!" +#define SAY_DIALOG_ARCANAGOS_4 "A dark power seeks to use you, Medivh! If you stay, dire days will follow. You must hurry, we don't have much time!" +#define SAY_DIALOG_MEDIVH_5 "I do not know what you speak of, dragon... but I will not be bullied by this display of insolence. I'll leave Karazhan when it suits me!" +#define SAY_DIALOG_ARCANAGOS_6 "You leave me no alternative. I will stop you by force if you won't listen to reason!" +#define EMOTE_DIALOG_MEDIVH_7 "begins to cast a spell of great power, weaving his own essence into the magic." +#define SAY_DIALOG_ARCANAGOS_8 "What have you done, wizard? This cannot be! I'm burning from... within!" +#define SAY_DIALOG_MEDIVH_9 "He should not have angered me. I must go... recover my strength now..." static float MedivPos[4] = {-11161.49f, -1902.24f, 91.48f, 1.94f}; static float ArcanagosPos[4] = {-11169.75f, -1881.48f, 95.39f, 4.83f}; class npc_image_of_medivh : public CreatureScript { -public: - npc_image_of_medivh() : CreatureScript("npc_image_of_medivh") { } + public: + npc_image_of_medivh() : CreatureScript("npc_image_of_medivh") + { + } struct npc_image_of_medivhAI : public ScriptedAI { @@ -479,7 +467,9 @@ class npc_image_of_medivh : public CreatureScript me->DespawnOrUnsummon(); } } - void JustEngagedWith(Unit* /*who*/) override { } + void JustEngagedWith(Unit* /*who*/) override + { + } void MovementInform(uint32 type, uint32 id) override { @@ -512,7 +502,8 @@ class npc_image_of_medivh : public CreatureScript { switch (step) { - case 0: return 9999999; + case 0: + return 9999999; case 1: me->Yell(SAY_DIALOG_MEDIVH_1, LANG_UNIVERSAL); return 10000; @@ -583,7 +574,7 @@ class npc_image_of_medivh : public CreatureScript } case 15: if (Creature* arca = ObjectAccessor::GetCreature(*me, ArcanagosGUID)) - arca->DealDamage(arca, arca->GetHealth(), nullptr, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, nullptr, false); + arca->KillSelf(); return 5000; default: return 9999999; @@ -596,7 +587,9 @@ class npc_image_of_medivh : public CreatureScript { if (EventStarted) YellTimer = NextStep(Step++); - } else YellTimer -= diff; + } + else + YellTimer -= diff; if (Step >= 7 && Step <= 12) { @@ -607,14 +600,18 @@ class npc_image_of_medivh : public CreatureScript if (arca) arca->CastSpell(me, SPELL_FIRE_BALL, false); FireArcanagosTimer = 6000; - } else FireArcanagosTimer -= diff; + } + else + FireArcanagosTimer -= diff; if (FireMedivhTimer <= diff) { if (arca) DoCast(arca, SPELL_FIRE_BALL); FireMedivhTimer = 5000; - } else FireMedivhTimer -= diff; + } + else + FireMedivhTimer -= diff; } } }; diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_brutallus.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_brutallus.cpp index 6b4e7f70..c2b2cd2f 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_brutallus.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_brutallus.cpp @@ -21,52 +21,54 @@ SD%Complete: 80 SDComment: Find a way to start the intro, best code for the intro EndScriptData */ -#include "ScriptMgr.h" #include "InstanceScript.h" #include "Log.h" #include "ObjectAccessor.h" +#include "ScriptMgr.h" #include "ScriptedCreature.h" #include "sunwell_plateau.h" enum Quotes { - YELL_INTRO = 0, - YELL_INTRO_BREAK_ICE = 1, - YELL_INTRO_CHARGE = 2, - YELL_INTRO_KILL_MADRIGOSA = 3, - YELL_INTRO_TAUNT = 4, - - YELL_AGGRO = 5, - YELL_KILL = 6, - YELL_LOVE = 7, - YELL_BERSERK = 8, - YELL_DEATH = 9, - - YELL_MADR_ICE_BARRIER = 0, - YELL_MADR_INTRO = 1, - YELL_MADR_ICE_BLOCK = 2, - YELL_MADR_TRAP = 3, - YELL_MADR_DEATH = 4 + YELL_INTRO = 0, + YELL_INTRO_BREAK_ICE = 1, + YELL_INTRO_CHARGE = 2, + YELL_INTRO_KILL_MADRIGOSA = 3, + YELL_INTRO_TAUNT = 4, + + YELL_AGGRO = 5, + YELL_KILL = 6, + YELL_LOVE = 7, + YELL_BERSERK = 8, + YELL_DEATH = 9, + + YELL_MADR_ICE_BARRIER = 0, + YELL_MADR_INTRO = 1, + YELL_MADR_ICE_BLOCK = 2, + YELL_MADR_TRAP = 3, + YELL_MADR_DEATH = 4 }; enum Spells { - SPELL_METEOR_SLASH = 45150, - SPELL_BURN = 46394, - SPELL_STOMP = 45185, - SPELL_BERSERK = 26662, - SPELL_DUAL_WIELD = 42459, - - SPELL_INTRO_FROST_BLAST = 45203, - SPELL_INTRO_FROSTBOLT = 44843, - SPELL_INTRO_ENCAPSULATE = 45665, - SPELL_INTRO_ENCAPSULATE_CHANELLING = 45661 + SPELL_METEOR_SLASH = 45150, + SPELL_BURN = 46394, + SPELL_STOMP = 45185, + SPELL_BERSERK = 26662, + SPELL_DUAL_WIELD = 42459, + + SPELL_INTRO_FROST_BLAST = 45203, + SPELL_INTRO_FROSTBOLT = 44843, + SPELL_INTRO_ENCAPSULATE = 45665, + SPELL_INTRO_ENCAPSULATE_CHANELLING = 45661 }; class boss_brutallus : public CreatureScript { -public: - boss_brutallus() : CreatureScript("boss_brutallus") { } + public: + boss_brutallus() : CreatureScript("boss_brutallus") + { + } struct boss_brutallusAI : public ScriptedAI { @@ -191,73 +193,73 @@ class boss_brutallus : public CreatureScript switch (IntroPhase) { - case 0: - Madrigosa->AI()->Talk(YELL_MADR_ICE_BARRIER); - IntroPhaseTimer = 7000; - ++IntroPhase; - break; - case 1: - me->SetOrientationTowards(Madrigosa); - Madrigosa->SetOrientationTowards(me); - Madrigosa->AI()->Talk(YELL_MADR_INTRO, me); - IntroPhaseTimer = 9000; - ++IntroPhase; - break; - case 2: - Talk(YELL_INTRO, Madrigosa); - IntroPhaseTimer = 13000; - ++IntroPhase; - break; - case 3: - DoCast(me, SPELL_INTRO_FROST_BLAST); - Madrigosa->SetDisableGravity(true); - me->AttackStop(); - Madrigosa->AttackStop(); - IntroFrostBoltTimer = 3000; - IntroPhaseTimer = 28000; - ++IntroPhase; - break; - case 4: - Talk(YELL_INTRO_BREAK_ICE); - IntroPhaseTimer = 6000; - ++IntroPhase; - break; - case 5: - Madrigosa->CastSpell(me, SPELL_INTRO_ENCAPSULATE_CHANELLING, false); - Madrigosa->AI()->Talk(YELL_MADR_TRAP); - DoCast(me, SPELL_INTRO_ENCAPSULATE); - IntroPhaseTimer = 11000; - ++IntroPhase; - break; - case 6: - Talk(YELL_INTRO_CHARGE); - IntroPhaseTimer = 5000; - ++IntroPhase; - break; - case 7: - me->Kill(Madrigosa); - Madrigosa->AI()->Talk(YELL_MADR_DEATH); - me->SetFullHealth(); - me->AttackStop(); - IntroPhaseTimer = 4000; - ++IntroPhase; - break; - case 8: - Talk(YELL_INTRO_KILL_MADRIGOSA); - me->SetOrientation(0.14f); - me->StopMoving(); - Madrigosa->setDeathState(CORPSE); - IntroPhaseTimer = 8000; - ++IntroPhase; - break; - case 9: - Talk(YELL_INTRO_TAUNT); - IntroPhaseTimer = 5000; - ++IntroPhase; - break; - case 10: - EndIntro(); - break; + case 0: + Madrigosa->AI()->Talk(YELL_MADR_ICE_BARRIER); + IntroPhaseTimer = 7000; + ++IntroPhase; + break; + case 1: + me->SetOrientationTowards(Madrigosa); + Madrigosa->SetOrientationTowards(me); + Madrigosa->AI()->Talk(YELL_MADR_INTRO, me); + IntroPhaseTimer = 9000; + ++IntroPhase; + break; + case 2: + Talk(YELL_INTRO, Madrigosa); + IntroPhaseTimer = 13000; + ++IntroPhase; + break; + case 3: + DoCast(me, SPELL_INTRO_FROST_BLAST); + Madrigosa->SetDisableGravity(true); + me->AttackStop(); + Madrigosa->AttackStop(); + IntroFrostBoltTimer = 3000; + IntroPhaseTimer = 28000; + ++IntroPhase; + break; + case 4: + Talk(YELL_INTRO_BREAK_ICE); + IntroPhaseTimer = 6000; + ++IntroPhase; + break; + case 5: + Madrigosa->CastSpell(me, SPELL_INTRO_ENCAPSULATE_CHANELLING, false); + Madrigosa->AI()->Talk(YELL_MADR_TRAP); + DoCast(me, SPELL_INTRO_ENCAPSULATE); + IntroPhaseTimer = 11000; + ++IntroPhase; + break; + case 6: + Talk(YELL_INTRO_CHARGE); + IntroPhaseTimer = 5000; + ++IntroPhase; + break; + case 7: + Unit::Kill(me, Madrigosa); + Madrigosa->AI()->Talk(YELL_MADR_DEATH); + me->SetFullHealth(); + me->AttackStop(); + IntroPhaseTimer = 4000; + ++IntroPhase; + break; + case 8: + Talk(YELL_INTRO_KILL_MADRIGOSA); + me->SetOrientation(0.14f); + me->StopMoving(); + Madrigosa->setDeathState(CORPSE); + IntroPhaseTimer = 8000; + ++IntroPhase; + break; + case 9: + Talk(YELL_INTRO_TAUNT); + IntroPhaseTimer = 5000; + ++IntroPhase; + break; + case 10: + EndIntro(); + break; } } @@ -282,7 +284,8 @@ class boss_brutallus : public CreatureScript { if (IntroPhaseTimer <= diff) DoIntro(); - else IntroPhaseTimer -= diff; + else + IntroPhaseTimer -= diff; if (IntroPhase == 3 + 1) { @@ -311,28 +314,36 @@ class boss_brutallus : public CreatureScript { DoCastVictim(SPELL_METEOR_SLASH); SlashTimer = 11000; - } else SlashTimer -= diff; + } + else + SlashTimer -= diff; if (StompTimer <= diff) { Talk(YELL_LOVE); DoCastVictim(SPELL_STOMP); StompTimer = 30000; - } else StompTimer -= diff; + } + else + StompTimer -= diff; if (BurnTimer <= diff) { if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100.0f, true, true, -SPELL_BURN)) target->CastSpell(target, SPELL_BURN, true); BurnTimer = urand(60000, 180000); - } else BurnTimer -= diff; + } + else + BurnTimer -= diff; if (BerserkTimer < diff && !Enraged) { Talk(YELL_BERSERK); DoCast(me, SPELL_BERSERK); Enraged = true; - } else BerserkTimer -= diff; + } + else + BerserkTimer -= diff; DoMeleeAttackIfReady(); } diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp index faea7919..5984e204 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp @@ -21,69 +21,69 @@ SD%Complete: 0 SDComment: EndScriptData */ -#include "ScriptMgr.h" #include "CellImpl.h" #include "GridNotifiersImpl.h" #include "InstanceScript.h" #include "MotionMaster.h" #include "ObjectAccessor.h" +#include "ScriptMgr.h" #include "ScriptedCreature.h" -#include "sunwell_plateau.h" #include "TemporarySummon.h" +#include "sunwell_plateau.h" enum Yells { - YELL_BIRTH = 0, - YELL_KILL = 1, - YELL_BREATH = 2, - YELL_TAKEOFF = 3, - YELL_BERSERK = 4, - YELL_DEATH = 5, - //YELL_KALECGOS = 6, Not used. After felmyst's death spawned and say this + YELL_BIRTH = 0, + YELL_KILL = 1, + YELL_BREATH = 2, + YELL_TAKEOFF = 3, + YELL_BERSERK = 4, + YELL_DEATH = 5, + // YELL_KALECGOS = 6, Not used. After felmyst's death spawned and say this }; enum Spells { - //Aura - AURA_SUNWELL_RADIANCE = 45769, - AURA_NOXIOUS_FUMES = 47002, - - //Land phase - SPELL_CLEAVE = 19983, - SPELL_CORROSION = 45866, - SPELL_GAS_NOVA = 45855, - SPELL_ENCAPSULATE_CHANNEL = 45661, + // Aura + AURA_SUNWELL_RADIANCE = 45769, + AURA_NOXIOUS_FUMES = 47002, + + // Land phase + SPELL_CLEAVE = 19983, + SPELL_CORROSION = 45866, + SPELL_GAS_NOVA = 45855, + SPELL_ENCAPSULATE_CHANNEL = 45661, // SPELL_ENCAPSULATE_EFFECT = 45665, // SPELL_ENCAPSULATE_AOE = 45662, - //Flight phase - SPELL_VAPOR_SELECT = 45391, // fel to player, force cast 45392, 50000y selete target - SPELL_VAPOR_SUMMON = 45392, // player summon vapor, radius around caster, 5y, - SPELL_VAPOR_FORCE = 45388, // vapor to fel, force cast 45389 - SPELL_VAPOR_CHANNEL = 45389, // fel to vapor, green beam channel - SPELL_VAPOR_TRIGGER = 45411, // linked to 45389, vapor to self, trigger 45410 and 46931 - SPELL_VAPOR_DAMAGE = 46931, // vapor damage, 4000 - SPELL_TRAIL_SUMMON = 45410, // vapor summon trail - SPELL_TRAIL_TRIGGER = 45399, // trail to self, trigger 45402 - SPELL_TRAIL_DAMAGE = 45402, // trail damage, 2000 + 2000 dot - SPELL_DEAD_SUMMON = 45400, // summon blazing dead, 5min - SPELL_DEAD_PASSIVE = 45415, - SPELL_FOG_BREATH = 45495, // fel to self, speed burst - SPELL_FOG_TRIGGER = 45582, // fog to self, trigger 45782 - SPELL_FOG_FORCE = 45782, // fog to player, force cast 45714 - SPELL_FOG_INFORM = 45714, // player let fel cast 45717, script effect - SPELL_FOG_CHARM = 45717, // fel to player - SPELL_FOG_CHARM2 = 45726, // link to 45717 - - SPELL_TRANSFORM_TRIGGER = 44885, // madrigosa to self, trigger 46350 - SPELL_TRANSFORM_VISUAL = 46350, // 46411stun? - SPELL_TRANSFORM_FELMYST = 45068, // become fel - SPELL_FELMYST_SUMMON = 45069, - - //Other - SPELL_BERSERK = 45078, - SPELL_CLOUD_VISUAL = 45212, - SPELL_CLOUD_SUMMON = 45884 + // Flight phase + SPELL_VAPOR_SELECT = 45391, // fel to player, force cast 45392, 50000y selete target + SPELL_VAPOR_SUMMON = 45392, // player summon vapor, radius around caster, 5y, + SPELL_VAPOR_FORCE = 45388, // vapor to fel, force cast 45389 + SPELL_VAPOR_CHANNEL = 45389, // fel to vapor, green beam channel + SPELL_VAPOR_TRIGGER = 45411, // linked to 45389, vapor to self, trigger 45410 and 46931 + SPELL_VAPOR_DAMAGE = 46931, // vapor damage, 4000 + SPELL_TRAIL_SUMMON = 45410, // vapor summon trail + SPELL_TRAIL_TRIGGER = 45399, // trail to self, trigger 45402 + SPELL_TRAIL_DAMAGE = 45402, // trail damage, 2000 + 2000 dot + SPELL_DEAD_SUMMON = 45400, // summon blazing dead, 5min + SPELL_DEAD_PASSIVE = 45415, + SPELL_FOG_BREATH = 45495, // fel to self, speed burst + SPELL_FOG_TRIGGER = 45582, // fog to self, trigger 45782 + SPELL_FOG_FORCE = 45782, // fog to player, force cast 45714 + SPELL_FOG_INFORM = 45714, // player let fel cast 45717, script effect + SPELL_FOG_CHARM = 45717, // fel to player + SPELL_FOG_CHARM2 = 45726, // link to 45717 + + SPELL_TRANSFORM_TRIGGER = 44885, // madrigosa to self, trigger 46350 + SPELL_TRANSFORM_VISUAL = 46350, // 46411stun? + SPELL_TRANSFORM_FELMYST = 45068, // become fel + SPELL_FELMYST_SUMMON = 45069, + + // Other + SPELL_BERSERK = 45078, + SPELL_CLOUD_VISUAL = 45212, + SPELL_CLOUD_SUMMON = 45884 }; enum PhaseFelmyst @@ -111,8 +111,10 @@ enum EventFelmyst class boss_felmyst : public CreatureScript { -public: - boss_felmyst() : CreatureScript("boss_felmyst") { } + public: + boss_felmyst() : CreatureScript("boss_felmyst") + { + } struct boss_felmystAI : public ScriptedAI { @@ -217,7 +219,7 @@ class boss_felmyst : public CreatureScript summon->CastSpell(summon, SPELL_FOG_CHARM, true); summon->CastSpell(summon, SPELL_FOG_CHARM2, true); } - me->DealDamage(caster, caster->GetHealth(), nullptr, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, nullptr, false); + Unit::DealDamage(me, caster, caster->GetHealth(), nullptr, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, nullptr, false); } } @@ -237,7 +239,7 @@ class boss_felmyst : public CreatureScript events.ScheduleEvent(EVENT_FLIGHT_SEQUENCE, 1); } - void DamageTaken(Unit*, uint32 &damage) override + void DamageTaken(Unit*, uint32& damage) override { if (phase != PHASE_GROUND && damage >= me->GetHealth()) damage = 0; @@ -247,26 +249,26 @@ class boss_felmyst : public CreatureScript { switch (NextPhase) { - case PHASE_GROUND: - me->CastStop(SPELL_FOG_BREATH); - me->RemoveAurasDueToSpell(SPELL_FOG_BREATH); - me->StopMoving(); - me->SetSpeedRate(MOVE_RUN, 2.0f); - - events.ScheduleEvent(EVENT_CLEAVE, urand(5000, 10000)); - events.ScheduleEvent(EVENT_CORROSION, urand(10000, 20000)); - events.ScheduleEvent(EVENT_GAS_NOVA, urand(15000, 20000)); - events.ScheduleEvent(EVENT_ENCAPSULATE, urand(20000, 25000)); - events.ScheduleEvent(EVENT_FLIGHT, 60000); - break; - case PHASE_FLIGHT: - me->SetDisableGravity(true); - events.ScheduleEvent(EVENT_FLIGHT_SEQUENCE, 1000); - uiFlightCount = 0; - uiBreathCount = 0; - break; - default: - break; + case PHASE_GROUND: + me->CastStop(SPELL_FOG_BREATH); + me->RemoveAurasDueToSpell(SPELL_FOG_BREATH); + me->StopMoving(); + me->SetSpeedRate(MOVE_RUN, 2.0f); + + events.ScheduleEvent(EVENT_CLEAVE, urand(5000, 10000)); + events.ScheduleEvent(EVENT_CORROSION, urand(10000, 20000)); + events.ScheduleEvent(EVENT_GAS_NOVA, urand(15000, 20000)); + events.ScheduleEvent(EVENT_ENCAPSULATE, urand(20000, 25000)); + events.ScheduleEvent(EVENT_FLIGHT, 60000); + break; + case PHASE_FLIGHT: + me->SetDisableGravity(true); + events.ScheduleEvent(EVENT_FLIGHT_SEQUENCE, 1000); + uiFlightCount = 0; + uiBreathCount = 0; + break; + default: + break; } phase = NextPhase; } @@ -275,130 +277,132 @@ class boss_felmyst : public CreatureScript { switch (uiFlightCount) { - case 0: - //me->AttackStop(); - me->GetMotionMaster()->Clear(false); - me->HandleEmoteCommand(EMOTE_ONESHOT_LIFTOFF); - me->StopMoving(); - Talk(YELL_TAKEOFF); - events.ScheduleEvent(EVENT_FLIGHT_SEQUENCE, 2000); - break; - case 1: - me->GetMotionMaster()->MovePoint(0, me->GetPositionX()+1, me->GetPositionY(), me->GetPositionZ()+10); - break; - case 2: - { - Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 150, true); - if (!target) - target = ObjectAccessor::GetUnit(*me, instance->GetGuidData(DATA_PLAYER_GUID)); - - if (!target) - { - EnterEvadeMode(); - return; - } - - if (Creature* Vapor = me->SummonCreature(NPC_VAPOR, target->GetPositionX() - 5 + rand32() % 10, target->GetPositionY() - 5 + rand32() % 10, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 9000)) - { - Vapor->AI()->AttackStart(target); - me->InterruptNonMeleeSpells(false); - DoCast(Vapor, SPELL_VAPOR_CHANNEL, false); // core bug - Vapor->CastSpell(Vapor, SPELL_VAPOR_TRIGGER, true); - } + case 0: + // me->AttackStop(); + me->GetMotionMaster()->Clear(false); + me->HandleEmoteCommand(EMOTE_ONESHOT_LIFTOFF); + me->StopMoving(); + Talk(YELL_TAKEOFF); + events.ScheduleEvent(EVENT_FLIGHT_SEQUENCE, 2000); + break; + case 1: + me->GetMotionMaster()->MovePoint(0, me->GetPositionX() + 1, me->GetPositionY(), me->GetPositionZ() + 10); + break; + case 2: + { + Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 150, true); + if (!target) + target = ObjectAccessor::GetUnit(*me, instance->GetGuidData(DATA_PLAYER_GUID)); - events.ScheduleEvent(EVENT_FLIGHT_SEQUENCE, 10000); - break; - } - case 3: + if (!target) { - DespawnSummons(NPC_VAPOR_TRAIL); - //DoCast(me, SPELL_VAPOR_SELECT); need core support + EnterEvadeMode(); + return; + } - Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 150, true); - if (!target) - target = ObjectAccessor::GetUnit(*me, instance->GetGuidData(DATA_PLAYER_GUID)); + if (Creature* Vapor = me->SummonCreature( + NPC_VAPOR, target->GetPositionX() - 5 + rand32() % 10, target->GetPositionY() - 5 + rand32() % 10, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 9000)) + { + Vapor->AI()->AttackStart(target); + me->InterruptNonMeleeSpells(false); + DoCast(Vapor, SPELL_VAPOR_CHANNEL, false); // core bug + Vapor->CastSpell(Vapor, SPELL_VAPOR_TRIGGER, true); + } - if (!target) - { - EnterEvadeMode(); - return; - } + events.ScheduleEvent(EVENT_FLIGHT_SEQUENCE, 10000); + break; + } + case 3: + { + DespawnSummons(NPC_VAPOR_TRAIL); + // DoCast(me, SPELL_VAPOR_SELECT); need core support - //target->CastSpell(target, SPELL_VAPOR_SUMMON, true); need core support - if (Creature* pVapor = me->SummonCreature(NPC_VAPOR, target->GetPositionX() - 5 + rand32() % 10, target->GetPositionY() - 5 + rand32() % 10, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 9000)) - { - if (pVapor->AI()) - pVapor->AI()->AttackStart(target); - me->InterruptNonMeleeSpells(false); - DoCast(pVapor, SPELL_VAPOR_CHANNEL, false); // core bug - pVapor->CastSpell(pVapor, SPELL_VAPOR_TRIGGER, true); - } + Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 150, true); + if (!target) + target = ObjectAccessor::GetUnit(*me, instance->GetGuidData(DATA_PLAYER_GUID)); - events.ScheduleEvent(EVENT_FLIGHT_SEQUENCE, 10000); - break; + if (!target) + { + EnterEvadeMode(); + return; } - case 4: - DespawnSummons(NPC_VAPOR_TRAIL); - events.ScheduleEvent(EVENT_FLIGHT_SEQUENCE, 1); - break; - case 5: + + // target->CastSpell(target, SPELL_VAPOR_SUMMON, true); need core support + if (Creature* pVapor = me->SummonCreature( + NPC_VAPOR, target->GetPositionX() - 5 + rand32() % 10, target->GetPositionY() - 5 + rand32() % 10, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 9000)) { - Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 150, true); - if (!target) - target = ObjectAccessor::GetUnit(*me, instance->GetGuidData(DATA_PLAYER_GUID)); + if (pVapor->AI()) + pVapor->AI()->AttackStart(target); + me->InterruptNonMeleeSpells(false); + DoCast(pVapor, SPELL_VAPOR_CHANNEL, false); // core bug + pVapor->CastSpell(pVapor, SPELL_VAPOR_TRIGGER, true); + } - if (!target) - { - EnterEvadeMode(); - return; - } + events.ScheduleEvent(EVENT_FLIGHT_SEQUENCE, 10000); + break; + } + case 4: + DespawnSummons(NPC_VAPOR_TRAIL); + events.ScheduleEvent(EVENT_FLIGHT_SEQUENCE, 1); + break; + case 5: + { + Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 150, true); + if (!target) + target = ObjectAccessor::GetUnit(*me, instance->GetGuidData(DATA_PLAYER_GUID)); - breathX = target->GetPositionX(); - breathY = target->GetPositionY(); - float x, y, z; - target->GetContactPoint(me, x, y, z, 70); - me->GetMotionMaster()->MovePoint(0, x, y, z+10); - break; + if (!target) + { + EnterEvadeMode(); + return; } - case 6: - me->SetFacingTo(me->GetAngle(breathX, breathY)); - //DoTextEmote("takes a deep breath.", nullptr); - events.ScheduleEvent(EVENT_FLIGHT_SEQUENCE, 10000); - break; - case 7: + + breathX = target->GetPositionX(); + breathY = target->GetPositionY(); + float x, y, z; + target->GetContactPoint(me, x, y, z, 70); + me->GetMotionMaster()->MovePoint(0, x, y, z + 10); + break; + } + case 6: + me->SetFacingTo(me->GetAngle(breathX, breathY)); + // DoTextEmote("takes a deep breath.", nullptr); + events.ScheduleEvent(EVENT_FLIGHT_SEQUENCE, 10000); + break; + case 7: + { + DoCast(me, SPELL_FOG_BREATH, true); + float x, y, z; + me->GetPosition(x, y, z); + x = 2 * breathX - x; + y = 2 * breathY - y; + me->GetMotionMaster()->MovePoint(0, x, y, z); + events.ScheduleEvent(EVENT_SUMMON_FOG, 1); + break; + } + case 8: + me->CastStop(SPELL_FOG_BREATH); + me->RemoveAurasDueToSpell(SPELL_FOG_BREATH); + ++uiBreathCount; + events.ScheduleEvent(EVENT_FLIGHT_SEQUENCE, 1); + if (uiBreathCount < 3) + uiFlightCount = 4; + break; + case 9: + if (Unit* target = SelectTarget(SELECT_TARGET_MAXTHREAT)) + DoStartMovement(target); + else { - DoCast(me, SPELL_FOG_BREATH, true); - float x, y, z; - me->GetPosition(x, y, z); - x = 2 * breathX - x; - y = 2 * breathY - y; - me->GetMotionMaster()->MovePoint(0, x, y, z); - events.ScheduleEvent(EVENT_SUMMON_FOG, 1); - break; + EnterEvadeMode(); + return; } - case 8: - me->CastStop(SPELL_FOG_BREATH); - me->RemoveAurasDueToSpell(SPELL_FOG_BREATH); - ++uiBreathCount; - events.ScheduleEvent(EVENT_FLIGHT_SEQUENCE, 1); - if (uiBreathCount < 3) - uiFlightCount = 4; - break; - case 9: - if (Unit* target = SelectTarget(SELECT_TARGET_MAXTHREAT)) - DoStartMovement(target); - else - { - EnterEvadeMode(); - return; - } - break; - case 10: - me->SetDisableGravity(false); - me->HandleEmoteCommand(EMOTE_ONESHOT_LAND); - EnterPhase(PHASE_GROUND); - AttackStart(SelectTarget(SELECT_TARGET_MAXTHREAT)); - break; + break; + case 10: + me->SetDisableGravity(false); + me->HandleEmoteCommand(EMOTE_ONESHOT_LAND); + EnterPhase(PHASE_GROUND); + AttackStart(SelectTarget(SELECT_TARGET_MAXTHREAT)); + break; } ++uiFlightCount; } @@ -421,34 +425,34 @@ class boss_felmyst : public CreatureScript { switch (events.ExecuteEvent()) { - case EVENT_BERSERK: - Talk(YELL_BERSERK); - DoCast(me, SPELL_BERSERK, true); - events.ScheduleEvent(EVENT_BERSERK, 10000); - break; - case EVENT_CLEAVE: - DoCastVictim(SPELL_CLEAVE, false); - events.ScheduleEvent(EVENT_CLEAVE, urand(5000, 10000)); - break; - case EVENT_CORROSION: - DoCastVictim(SPELL_CORROSION, false); - events.ScheduleEvent(EVENT_CORROSION, urand(20000, 30000)); - break; - case EVENT_GAS_NOVA: - DoCast(me, SPELL_GAS_NOVA, false); - events.ScheduleEvent(EVENT_GAS_NOVA, urand(20000, 25000)); - break; - case EVENT_ENCAPSULATE: - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 150, true)) - DoCast(target, SPELL_ENCAPSULATE_CHANNEL, false); - events.ScheduleEvent(EVENT_ENCAPSULATE, urand(25000, 30000)); - break; - case EVENT_FLIGHT: - EnterPhase(PHASE_FLIGHT); - break; - default: - DoMeleeAttackIfReady(); - break; + case EVENT_BERSERK: + Talk(YELL_BERSERK); + DoCast(me, SPELL_BERSERK, true); + events.ScheduleEvent(EVENT_BERSERK, 10000); + break; + case EVENT_CLEAVE: + DoCastVictim(SPELL_CLEAVE, false); + events.ScheduleEvent(EVENT_CLEAVE, urand(5000, 10000)); + break; + case EVENT_CORROSION: + DoCastVictim(SPELL_CORROSION, false); + events.ScheduleEvent(EVENT_CORROSION, urand(20000, 30000)); + break; + case EVENT_GAS_NOVA: + DoCast(me, SPELL_GAS_NOVA, false); + events.ScheduleEvent(EVENT_GAS_NOVA, urand(20000, 25000)); + break; + case EVENT_ENCAPSULATE: + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 150, true)) + DoCast(target, SPELL_ENCAPSULATE_CHANNEL, false); + events.ScheduleEvent(EVENT_ENCAPSULATE, urand(25000, 30000)); + break; + case EVENT_FLIGHT: + EnterPhase(PHASE_FLIGHT); + break; + default: + DoMeleeAttackIfReady(); + break; } } @@ -456,27 +460,27 @@ class boss_felmyst : public CreatureScript { switch (events.ExecuteEvent()) { - case EVENT_BERSERK: - Talk(YELL_BERSERK); - DoCast(me, SPELL_BERSERK, true); - break; - case EVENT_FLIGHT_SEQUENCE: - HandleFlightSequence(); - break; - case EVENT_SUMMON_FOG: - { - float x, y, z; - me->GetPosition(x, y, z); - me->UpdateGroundPositionZ(x, y, z); - if (Creature* Fog = me->SummonCreature(NPC_VAPOR_TRAIL, x, y, z, 0, TEMPSUMMON_TIMED_DESPAWN, 10000)) - { - Fog->RemoveAurasDueToSpell(SPELL_TRAIL_TRIGGER); - Fog->CastSpell(Fog, SPELL_FOG_TRIGGER, true); - me->CastSpell(Fog, SPELL_FOG_FORCE, true); - } - } - events.ScheduleEvent(EVENT_SUMMON_FOG, 1000); - break; + case EVENT_BERSERK: + Talk(YELL_BERSERK); + DoCast(me, SPELL_BERSERK, true); + break; + case EVENT_FLIGHT_SEQUENCE: + HandleFlightSequence(); + break; + case EVENT_SUMMON_FOG: + { + float x, y, z; + me->GetPosition(x, y, z); + me->UpdateGroundPositionZ(x, y, z); + if (Creature* Fog = me->SummonCreature(NPC_VAPOR_TRAIL, x, y, z, 0, TEMPSUMMON_TIMED_DESPAWN, 10000)) + { + Fog->RemoveAurasDueToSpell(SPELL_TRAIL_TRIGGER); + Fog->CastSpell(Fog, SPELL_FOG_TRIGGER, true); + me->CastSpell(Fog, SPELL_FOG_FORCE, true); + } + } + events.ScheduleEvent(EVENT_SUMMON_FOG, 1000); + break; } } } @@ -512,8 +516,10 @@ class boss_felmyst : public CreatureScript class npc_felmyst_vapor : public CreatureScript { -public: - npc_felmyst_vapor() : CreatureScript("npc_felmyst_vapor") { } + public: + npc_felmyst_vapor() : CreatureScript("npc_felmyst_vapor") + { + } struct npc_felmyst_vaporAI : public ScriptedAI { @@ -523,11 +529,13 @@ class npc_felmyst_vapor : public CreatureScript me->SetSpeedRate(MOVE_RUN, 0.8f); } - void Reset() override { } + void Reset() override + { + } void JustEngagedWith(Unit* /*who*/) override { DoZoneInCombat(); - //DoCast(me, SPELL_VAPOR_FORCE, true); core bug + // DoCast(me, SPELL_VAPOR_FORCE, true); core bug } void UpdateAI(uint32 /*diff*/) override @@ -546,8 +554,10 @@ class npc_felmyst_vapor : public CreatureScript class npc_felmyst_trail : public CreatureScript { -public: - npc_felmyst_trail() : CreatureScript("npc_felmyst_trail") { } + public: + npc_felmyst_trail() : CreatureScript("npc_felmyst_trail") + { + } struct npc_felmyst_trailAI : public ScriptedAI { @@ -559,12 +569,22 @@ class npc_felmyst_trail : public CreatureScript me->SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, 0.01f); // core bug } - void Reset() override { } - void JustEngagedWith(Unit* /*who*/) override { } - void AttackStart(Unit* /*who*/) override { } - void MoveInLineOfSight(Unit* /*who*/) override { } + void Reset() override + { + } + void JustEngagedWith(Unit* /*who*/) override + { + } + void AttackStart(Unit* /*who*/) override + { + } + void MoveInLineOfSight(Unit* /*who*/) override + { + } - void UpdateAI(uint32 /*diff*/) override { } + void UpdateAI(uint32 /*diff*/) override + { + } }; CreatureAI* GetAI(Creature* creature) const override diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp index e9033303..147a94b1 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp @@ -15,75 +15,75 @@ * with this program. If not, see . */ -#include "ScriptMgr.h" #include "GameObject.h" #include "GameObjectAI.h" #include "InstanceScript.h" #include "MotionMaster.h" #include "Player.h" +#include "ScriptMgr.h" #include "ScriptedCreature.h" #include "SpellAuraEffects.h" #include "SpellScript.h" -#include "sunwell_plateau.h" #include "TemporarySummon.h" #include "WorldSession.h" +#include "sunwell_plateau.h" enum Yells { - SAY_SATH_AGGRO = 0, - SAY_SATH_SLAY = 1, - SAY_SATH_DEATH = 2, - SAY_SATH_SPELL1 = 3, - SAY_SATH_SPELL2 = 4, - - SAY_EVIL_AGGRO = 0, - SAY_EVIL_SLAY = 1, - SAY_OUTRO_1 = 2, - SAY_OUTRO_2 = 3, - EMOTE_ENRAGE = 4, - SAY_ARCANE_BUFFET = 6, + SAY_SATH_AGGRO = 0, + SAY_SATH_SLAY = 1, + SAY_SATH_DEATH = 2, + SAY_SATH_SPELL1 = 3, + SAY_SATH_SPELL2 = 4, + + SAY_EVIL_AGGRO = 0, + SAY_EVIL_SLAY = 1, + SAY_OUTRO_1 = 2, + SAY_OUTRO_2 = 3, + EMOTE_ENRAGE = 4, + SAY_ARCANE_BUFFET = 6, SAY_GOOD_NEAR_DEATH_0 = 0, SAY_GOOD_NEAR_DEATH_1 = 1, SAY_GOOD_NEAR_DEATH_2 = 2, - SAY_GOOD_DEATH = 3 + SAY_GOOD_DEATH = 3 }; enum Spells { - SPELL_SPECTRAL_BLAST = 44869, - SPELL_ARCANE_BUFFET = 45018, - SPELL_FROST_BREATH = 44799, - SPELL_TAIL_LASH = 45122, - SPELL_WILD_MAGIC_1 = 45001, - SPELL_WILD_MAGIC_2 = 45002, - SPELL_WILD_MAGIC_3 = 45004, - SPELL_WILD_MAGIC_4 = 45006, - SPELL_WILD_MAGIC_5 = 45010, - SPELL_WILD_MAGIC_6 = 44978, - SPELL_BANISH = 44836, - SPELL_ENRAGE = 44807, - SPELL_DEMONIC_VISUAL = 44800, - SPELL_CORRUPTION_STRIKE = 45029, - SPELL_AGONY_CURSE = 45032, - SPELL_SHADOW_BOLT = 45031, - SPELL_TAP_CHECK = 46732, - SPELL_TAP_CHECK_DAMAGE = 46733, - SPELL_AGONY_CURSE_VISUAL_1 = 45083, - SPELL_AGONY_CURSE_VISUAL_2 = 45084, - SPELL_AGONY_CURSE_VISUAL_3 = 45085, - SPELL_AGONY_CURSE_ALLY = 45034, - SPELL_HEROIC_STRIKE = 45026, - SPELL_REVITALIZE = 45027, - SPELL_SPECTRAL_BLAST_EFFECT = 44866, - SPELL_SPECTRAL_BLAST_VISUAL = 46648, - SPELL_SPECTRAL_REALM_TRIGGER = 44811, + SPELL_SPECTRAL_BLAST = 44869, + SPELL_ARCANE_BUFFET = 45018, + SPELL_FROST_BREATH = 44799, + SPELL_TAIL_LASH = 45122, + SPELL_WILD_MAGIC_1 = 45001, + SPELL_WILD_MAGIC_2 = 45002, + SPELL_WILD_MAGIC_3 = 45004, + SPELL_WILD_MAGIC_4 = 45006, + SPELL_WILD_MAGIC_5 = 45010, + SPELL_WILD_MAGIC_6 = 44978, + SPELL_BANISH = 44836, + SPELL_ENRAGE = 44807, + SPELL_DEMONIC_VISUAL = 44800, + SPELL_CORRUPTION_STRIKE = 45029, + SPELL_AGONY_CURSE = 45032, + SPELL_SHADOW_BOLT = 45031, + SPELL_TAP_CHECK = 46732, + SPELL_TAP_CHECK_DAMAGE = 46733, + SPELL_AGONY_CURSE_VISUAL_1 = 45083, + SPELL_AGONY_CURSE_VISUAL_2 = 45084, + SPELL_AGONY_CURSE_VISUAL_3 = 45085, + SPELL_AGONY_CURSE_ALLY = 45034, + SPELL_HEROIC_STRIKE = 45026, + SPELL_REVITALIZE = 45027, + SPELL_SPECTRAL_BLAST_EFFECT = 44866, + SPELL_SPECTRAL_BLAST_VISUAL = 46648, + SPELL_SPECTRAL_REALM_TRIGGER = 44811, SPELL_SPECTRAL_REALM_TELEPORT = 46019, - SPELL_SPECTRAL_REALM_AURA = 46021, - SPELL_SPECTRAL_REALM_2 = 44845, + SPELL_SPECTRAL_REALM_AURA = 46021, + SPELL_SPECTRAL_REALM_2 = 44845, SPELL_SPECTRAL_REALM_REACTION = 44852, - SPELL_SPECTRAL_EXHAUSTION = 44867, - SPELL_TELEPORT_BACK = 46020 + SPELL_SPECTRAL_EXHAUSTION = 44867, + SPELL_TELEPORT_BACK = 46020 }; enum KalecgosEvents @@ -126,26 +126,16 @@ enum KalecgosPoints POINT_OUTRO_2 }; -Position const KalecgosSummonPos = { 1709.094f, 927.5035f, -74.28364f, 2.932153f }; -Position const FlyPos[2] = -{ - { 1704.18f, 927.999f, 57.888f }, - { 1614.355f, 846.9694f, 119.0971f } -}; +Position const KalecgosSummonPos = {1709.094f, 927.5035f, -74.28364f, 2.932153f}; +Position const FlyPos[2] = {{1704.18f, 927.999f, 57.888f}, {1614.355f, 846.9694f, 119.0971f}}; -uint32 const WildMagicSpells[6] = -{ - SPELL_WILD_MAGIC_1, - SPELL_WILD_MAGIC_2, - SPELL_WILD_MAGIC_3, - SPELL_WILD_MAGIC_4, - SPELL_WILD_MAGIC_5, - SPELL_WILD_MAGIC_6 -}; +uint32 const WildMagicSpells[6] = {SPELL_WILD_MAGIC_1, SPELL_WILD_MAGIC_2, SPELL_WILD_MAGIC_3, SPELL_WILD_MAGIC_4, SPELL_WILD_MAGIC_5, SPELL_WILD_MAGIC_6}; struct boss_kalecgos : public BossAI { - boss_kalecgos(Creature* creature) : BossAI(creature, DATA_KALECGOS), _isEnraged(false), _isBanished(false) { } + boss_kalecgos(Creature* creature) : BossAI(creature, DATA_KALECGOS), _isEnraged(false), _isBanished(false) + { + } void Reset() override { @@ -189,20 +179,20 @@ struct boss_kalecgos : public BossAI { switch (action) { - case ACTION_START_OUTRO: - events.ScheduleEvent(EVENT_OUTRO_START, Seconds(1)); - break; - case ACTION_ENRAGE: - _isEnraged = true; - Talk(EMOTE_ENRAGE); - DoCastSelf(SPELL_ENRAGE, true); - break; - default: - break; + case ACTION_START_OUTRO: + events.ScheduleEvent(EVENT_OUTRO_START, Seconds(1)); + break; + case ACTION_ENRAGE: + _isEnraged = true; + Talk(EMOTE_ENRAGE); + DoCastSelf(SPELL_ENRAGE, true); + break; + default: + break; } } - void DamageTaken(Unit* who, uint32 &damage) override + void DamageTaken(Unit* who, uint32& damage) override { if (damage >= me->GetHealth() && who->GetGUID() != me->GetGUID()) damage = 0; @@ -235,17 +225,17 @@ struct boss_kalecgos : public BossAI switch (id) { - case POINT_OUTRO_1: - Talk(SAY_OUTRO_1); - events.ScheduleEvent(EVENT_OUTRO_3, Seconds(9)); - break; - case POINT_OUTRO_2: - me->SetVisible(false); - DespawnPortals(); - me->KillSelf(); - break; - default: - break; + case POINT_OUTRO_1: + Talk(SAY_OUTRO_1); + events.ScheduleEvent(EVENT_OUTRO_3, Seconds(9)); + break; + case POINT_OUTRO_2: + me->SetVisible(false); + DespawnPortals(); + me->KillSelf(); + break; + default: + break; } } @@ -263,78 +253,78 @@ struct boss_kalecgos : public BossAI { switch (eventId) { - case EVENT_ARCANE_BUFFET: - if (roll_chance_i(20)) - Talk(SAY_ARCANE_BUFFET); - DoCastAOE(SPELL_ARCANE_BUFFET); - events.Repeat(Seconds(8)); - break; - case EVENT_FROST_BREATH: - DoCastAOE(SPELL_FROST_BREATH); - events.Repeat(Seconds(15)); - break; - case EVENT_TAIL_LASH: - DoCastAOE(SPELL_TAIL_LASH); - events.Repeat(Seconds(15)); - break; - case EVENT_WILD_MAGIC: - DoCastAOE(WildMagicSpells[urand(0, 5)], true); - events.Repeat(Seconds(20)); - break; - case EVENT_SPECTRAL_BLAST: - DoCastAOE(SPELL_SPECTRAL_BLAST, true); - events.Repeat(Seconds(20), Seconds(25)); - break; - case EVENT_CHECK_TIMER: - if (!_isEnraged && HealthBelowPct(10)) - DoAction(ACTION_ENRAGE); + case EVENT_ARCANE_BUFFET: + if (roll_chance_i(20)) + Talk(SAY_ARCANE_BUFFET); + DoCastAOE(SPELL_ARCANE_BUFFET); + events.Repeat(Seconds(8)); + break; + case EVENT_FROST_BREATH: + DoCastAOE(SPELL_FROST_BREATH); + events.Repeat(Seconds(15)); + break; + case EVENT_TAIL_LASH: + DoCastAOE(SPELL_TAIL_LASH); + events.Repeat(Seconds(15)); + break; + case EVENT_WILD_MAGIC: + DoCastAOE(WildMagicSpells[urand(0, 5)], true); + events.Repeat(Seconds(20)); + break; + case EVENT_SPECTRAL_BLAST: + DoCastAOE(SPELL_SPECTRAL_BLAST, true); + events.Repeat(Seconds(20), Seconds(25)); + break; + case EVENT_CHECK_TIMER: + if (!_isEnraged && HealthBelowPct(10)) + DoAction(ACTION_ENRAGE); - if (HealthBelowPct(1)) + if (HealthBelowPct(1)) + { + if (Creature* sathrovarr = instance->GetCreature(DATA_SATHROVARR)) { - if (Creature* sathrovarr = instance->GetCreature(DATA_SATHROVARR)) + if (sathrovarr->HasAura(SPELL_BANISH)) { - if (sathrovarr->HasAura(SPELL_BANISH)) - { - sathrovarr->CastSpell(sathrovarr, SPELL_TAP_CHECK, true); - break; - } - } - if (_isBanished) + sathrovarr->CastSpell(sathrovarr, SPELL_TAP_CHECK, true); break; - - _isBanished = true; - DoCastSelf(SPELL_BANISH, true); - events.Reset(); + } } - events.Repeat(Seconds(1)); - break; - case EVENT_OUTRO_START: + if (_isBanished) + break; + + _isBanished = true; + DoCastSelf(SPELL_BANISH, true); events.Reset(); - events.SetPhase(PHASE_OUTRO); - me->setRegeneratingHealth(false); - me->SetReactState(REACT_PASSIVE); - me->InterruptNonMeleeSpells(true); - me->RemoveAllAttackers(); - me->AttackStop(); - me->SetFaction(FACTION_FRIENDLY); - me->RemoveAllAuras(); - instance->SendEncounterUnit(ENCOUNTER_FRAME_DISENGAGE, me); - events.ScheduleEvent(EVENT_OUTRO_1, Seconds(3)); - break; - case EVENT_OUTRO_1: - me->SetDisableGravity(true); - me->HandleEmoteCommand(EMOTE_ONESHOT_LIFTOFF); - events.ScheduleEvent(EVENT_OUTRO_2, Seconds(3)); - break; - case EVENT_OUTRO_2: - me->GetMotionMaster()->MovePoint(POINT_OUTRO_1, FlyPos[0]); - break; - case EVENT_OUTRO_3: - Talk(SAY_OUTRO_2); - me->GetMotionMaster()->MovePoint(POINT_OUTRO_2, FlyPos[1], false); - break; - default: - break; + } + events.Repeat(Seconds(1)); + break; + case EVENT_OUTRO_START: + events.Reset(); + events.SetPhase(PHASE_OUTRO); + me->setRegeneratingHealth(false); + me->SetReactState(REACT_PASSIVE); + me->InterruptNonMeleeSpells(true); + me->RemoveAllAttackers(); + me->AttackStop(); + me->SetFaction(FACTION_FRIENDLY); + me->RemoveAllAuras(); + instance->SendEncounterUnit(ENCOUNTER_FRAME_DISENGAGE, me); + events.ScheduleEvent(EVENT_OUTRO_1, Seconds(3)); + break; + case EVENT_OUTRO_1: + me->SetDisableGravity(true); + me->HandleEmoteCommand(EMOTE_ONESHOT_LIFTOFF); + events.ScheduleEvent(EVENT_OUTRO_2, Seconds(3)); + break; + case EVENT_OUTRO_2: + me->GetMotionMaster()->MovePoint(POINT_OUTRO_1, FlyPos[0]); + break; + case EVENT_OUTRO_3: + Talk(SAY_OUTRO_2); + me->GetMotionMaster()->MovePoint(POINT_OUTRO_2, FlyPos[1], false); + break; + default: + break; } if (me->HasUnitState(UNIT_STATE_CASTING)) @@ -344,14 +334,16 @@ struct boss_kalecgos : public BossAI DoMeleeAttackIfReady(); } -private: + private: bool _isEnraged; bool _isBanished; }; struct boss_kalecgos_human : public ScriptedAI { - boss_kalecgos_human(Creature* creature) : ScriptedAI(creature), _instance(creature->GetInstanceScript()) { } + boss_kalecgos_human(Creature* creature) : ScriptedAI(creature), _instance(creature->GetInstanceScript()) + { + } void Reset() override { @@ -370,7 +362,7 @@ struct boss_kalecgos_human : public ScriptedAI Talk(SAY_GOOD_DEATH); } - void DamageTaken(Unit* who, uint32 &damage) override + void DamageTaken(Unit* who, uint32& damage) override { if (who->GetGUID() != _sathGUID) damage = 0; @@ -406,16 +398,16 @@ struct boss_kalecgos_human : public ScriptedAI { switch (eventId) { - case EVENT_REVITALIZE: - DoCastSelf(SPELL_REVITALIZE); - _events.Repeat(Seconds(5)); - break; - case EVENT_HEROIC_STRIKE: - DoCastVictim(SPELL_HEROIC_STRIKE); - _events.Repeat(Seconds(2)); - break; - default: - break; + case EVENT_REVITALIZE: + DoCastSelf(SPELL_REVITALIZE); + _events.Repeat(Seconds(5)); + break; + case EVENT_HEROIC_STRIKE: + DoCastVictim(SPELL_HEROIC_STRIKE); + _events.Repeat(Seconds(2)); + break; + default: + break; } if (me->HasUnitState(UNIT_STATE_CASTING)) @@ -425,7 +417,7 @@ struct boss_kalecgos_human : public ScriptedAI DoMeleeAttackIfReady(); } -private: + private: InstanceScript* _instance; EventMap _events; ObjectGuid _sathGUID; @@ -433,22 +425,25 @@ struct boss_kalecgos_human : public ScriptedAI class CurseAgonySelector : NonTankTargetSelector { -public: - CurseAgonySelector(Unit* source) : NonTankTargetSelector(source, true) { } + public: + CurseAgonySelector(Unit* source) : NonTankTargetSelector(source, true) + { + } bool operator()(WorldObject* target) const { if (Unit* unitTarget = target->ToUnit()) - return !NonTankTargetSelector::operator()(unitTarget) - || unitTarget->HasAura(SPELL_AGONY_CURSE) || unitTarget->HasAura(SPELL_AGONY_CURSE_ALLY) - || !unitTarget->HasAura(SPELL_SPECTRAL_REALM_AURA); + return !NonTankTargetSelector::operator()(unitTarget) || unitTarget->HasAura(SPELL_AGONY_CURSE) || unitTarget->HasAura(SPELL_AGONY_CURSE_ALLY) || + !unitTarget->HasAura(SPELL_SPECTRAL_REALM_AURA); return false; } }; struct boss_sathrovarr : public BossAI { - boss_sathrovarr(Creature* creature) : BossAI(creature, DATA_KALECGOS), _isEnraged(false), _isBanished(false) { } + boss_sathrovarr(Creature* creature) : BossAI(creature, DATA_KALECGOS), _isEnraged(false), _isBanished(false) + { + } void Reset() override { @@ -478,11 +473,11 @@ struct boss_sathrovarr : public BossAI if (spell->Id == SPELL_TAP_CHECK_DAMAGE) { DoCastSelf(SPELL_TELEPORT_BACK, true); - caster->Kill(me); + Unit::Kill(caster, me); } } - void DamageTaken(Unit* who, uint32 &damage) override + void DamageTaken(Unit* who, uint32& damage) override { if (damage >= me->GetHealth() && who->GetGUID() != me->GetGUID()) damage = 0; @@ -512,86 +507,90 @@ struct boss_sathrovarr : public BossAI { switch (eventId) { - case EVENT_SHADOWBOLT: - if (roll_chance_i(20)) - Talk(SAY_SATH_SPELL1); - DoCastAOE(SPELL_SHADOW_BOLT); - events.Repeat(Seconds(7), Seconds(10)); - break; - case EVENT_AGONY_CURSE: + case EVENT_SHADOWBOLT: + if (roll_chance_i(20)) + Talk(SAY_SATH_SPELL1); + DoCastAOE(SPELL_SHADOW_BOLT); + events.Repeat(Seconds(7), Seconds(10)); + break; + case EVENT_AGONY_CURSE: + { + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, CurseAgonySelector(me))) + DoCast(target, SPELL_AGONY_CURSE); + else + DoCastVictim(SPELL_AGONY_CURSE); + events.Repeat(Seconds(20)); + break; + } + case EVENT_CORRUPTION_STRIKE: + if (roll_chance_i(20)) + Talk(SAY_SATH_SPELL2); + DoCastVictim(SPELL_CORRUPTION_STRIKE); + events.Repeat(Seconds(13)); + break; + case EVENT_CHECK_TIMER: + { + if (HealthBelowPct(10) && !_isEnraged) { - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, CurseAgonySelector(me))) - DoCast(target, SPELL_AGONY_CURSE); - else - DoCastVictim(SPELL_AGONY_CURSE); - events.Repeat(Seconds(20)); - break; + _isEnraged = true; + if (Creature* kalecgos = instance->GetCreature(DATA_KALECGOS_DRAGON)) + kalecgos->AI()->DoAction(ACTION_ENRAGE); } - case EVENT_CORRUPTION_STRIKE: - if (roll_chance_i(20)) - Talk(SAY_SATH_SPELL2); - DoCastVictim(SPELL_CORRUPTION_STRIKE); - events.Repeat(Seconds(13)); - break; - case EVENT_CHECK_TIMER: - { - if (HealthBelowPct(10) && !_isEnraged) - { - _isEnraged = true; - if (Creature* kalecgos = instance->GetCreature(DATA_KALECGOS_DRAGON)) - kalecgos->AI()->DoAction(ACTION_ENRAGE); - } - if (HealthBelowPct(1)) + if (HealthBelowPct(1)) + { + if (Creature* kalecgos = instance->GetCreature(DATA_KALECGOS_DRAGON)) { - if (Creature* kalecgos = instance->GetCreature(DATA_KALECGOS_DRAGON)) + if (kalecgos->HasAura(SPELL_BANISH)) { - if (kalecgos->HasAura(SPELL_BANISH)) - { - DoCastSelf(SPELL_TAP_CHECK, true); - break; - } - } - if (_isBanished) + DoCastSelf(SPELL_TAP_CHECK, true); break; - - _isBanished = true; - DoCastSelf(SPELL_BANISH, true); + } } - events.Repeat(Seconds(1)); - break; + if (_isBanished) + break; + + _isBanished = true; + DoCastSelf(SPELL_BANISH, true); } - default: - break; + events.Repeat(Seconds(1)); + break; + } + default: + break; } } -private: + private: bool _isEnraged; bool _isBanished; }; class go_kalecgos_spectral_rift : public GameObjectScript { - public: - go_kalecgos_spectral_rift() : GameObjectScript("go_kalecgos_spectral_rift") { } + public: + go_kalecgos_spectral_rift() : GameObjectScript("go_kalecgos_spectral_rift") + { + } - struct go_kalecgos_spectral_riftAI : public GameObjectAI + struct go_kalecgos_spectral_riftAI : public GameObjectAI + { + go_kalecgos_spectral_riftAI(GameObject* go) : GameObjectAI(go) { - go_kalecgos_spectral_riftAI(GameObject* go) : GameObjectAI(go) { } - - bool GossipHello(Player* player) override - { - if (!player->HasAura(SPELL_SPECTRAL_EXHAUSTION)) - player->CastSpell(player, SPELL_SPECTRAL_REALM_TRIGGER, true); - return true; - } - }; + } - GameObjectAI* GetAI(GameObject* go) const override + bool GossipHello(Player* player) override { - return GetSunwellPlateauAI(go); + if (!player->HasAura(SPELL_SPECTRAL_EXHAUSTION)) + player->CastSpell(player, SPELL_SPECTRAL_REALM_TRIGGER, true); + return true; } + }; + + GameObjectAI* GetAI(GameObject* go) const override + { + return GetSunwellPlateauAI(go); + } }; // 46732 - Tap Check @@ -599,7 +598,7 @@ class spell_kalecgos_tap_check : public SpellScript { bool Validate(SpellInfo const* spellInfo) override { - return ValidateSpellInfo({ uint32(spellInfo->Effects[EFFECT_0].CalcValue()) }); + return ValidateSpellInfo({uint32(spellInfo->Effects[EFFECT_0].CalcValue())}); } void HandleDummy(SpellEffIndex /*effIndex*/) @@ -615,16 +614,17 @@ class spell_kalecgos_tap_check : public SpellScript class SpectralBlastSelector : NonTankTargetSelector { - public: - SpectralBlastSelector(Unit* source) : NonTankTargetSelector(source, true) { } + public: + SpectralBlastSelector(Unit* source) : NonTankTargetSelector(source, true) + { + } - bool operator()(WorldObject* target) const - { - if (Unit* unitTarget = target->ToUnit()) - return !NonTankTargetSelector::operator()(unitTarget) || - unitTarget->HasAura(SPELL_SPECTRAL_EXHAUSTION) || unitTarget->HasAura(SPELL_SPECTRAL_REALM_AURA); - return false; - } + bool operator()(WorldObject* target) const + { + if (Unit* unitTarget = target->ToUnit()) + return !NonTankTargetSelector::operator()(unitTarget) || unitTarget->HasAura(SPELL_SPECTRAL_EXHAUSTION) || unitTarget->HasAura(SPELL_SPECTRAL_REALM_AURA); + return false; + } }; // 44869 - Spectral Blast @@ -632,12 +632,7 @@ class spell_kalecgos_spectral_blast : public SpellScript { bool Validate(SpellInfo const* /*spell*/) override { - return ValidateSpellInfo( - { - SPELL_SPECTRAL_BLAST_EFFECT, - SPELL_SPECTRAL_BLAST_VISUAL, - SPELL_SPECTRAL_REALM_TRIGGER - }); + return ValidateSpellInfo({SPELL_SPECTRAL_BLAST_EFFECT, SPELL_SPECTRAL_BLAST_VISUAL, SPELL_SPECTRAL_REALM_TRIGGER}); } void FilterTargets(std::list& targets) @@ -667,13 +662,7 @@ class spell_kalecgos_spectral_realm_trigger : public SpellScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo( - { - SPELL_SPECTRAL_REALM_TELEPORT, - SPELL_SPECTRAL_REALM_AURA, - SPELL_SPECTRAL_REALM_2, - SPELL_SPECTRAL_REALM_REACTION - }); + return ValidateSpellInfo({SPELL_SPECTRAL_REALM_TELEPORT, SPELL_SPECTRAL_REALM_AURA, SPELL_SPECTRAL_REALM_2, SPELL_SPECTRAL_REALM_REACTION}); } void HandleDummy(SpellEffIndex /*effIndex*/) @@ -696,12 +685,7 @@ class spell_kalecgos_spectral_realm_aura : public AuraScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo( - { - SPELL_SPECTRAL_REALM_REACTION, - SPELL_TELEPORT_BACK, - SPELL_SPECTRAL_EXHAUSTION - }); + return ValidateSpellInfo({SPELL_SPECTRAL_REALM_REACTION, SPELL_TELEPORT_BACK, SPELL_SPECTRAL_EXHAUSTION}); } void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) @@ -723,13 +707,7 @@ class spell_kalecgos_curse_of_boundless_agony : public AuraScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo( - { - SPELL_AGONY_CURSE_VISUAL_1, - SPELL_AGONY_CURSE_VISUAL_2, - SPELL_AGONY_CURSE_VISUAL_3, - SPELL_AGONY_CURSE_ALLY - }); + return ValidateSpellInfo({SPELL_AGONY_CURSE_VISUAL_1, SPELL_AGONY_CURSE_VISUAL_2, SPELL_AGONY_CURSE_VISUAL_3, SPELL_AGONY_CURSE_ALLY}); } void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) diff --git a/src/server/scripts/EasternKingdoms/zone_western_plaguelands.cpp b/src/server/scripts/EasternKingdoms/zone_western_plaguelands.cpp index d5490f82..a96af1d0 100644 --- a/src/server/scripts/EasternKingdoms/zone_western_plaguelands.cpp +++ b/src/server/scripts/EasternKingdoms/zone_western_plaguelands.cpp @@ -27,10 +27,10 @@ npc_the_scourge_cauldron npc_andorhal_tower EndContentData */ +#include "Player.h" #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "ScriptedGossip.h" -#include "Player.h" #include "WorldSession.h" /*###### @@ -39,8 +39,10 @@ EndContentData */ class npc_the_scourge_cauldron : public CreatureScript { -public: - npc_the_scourge_cauldron() : CreatureScript("npc_the_scourge_cauldron") { } + public: + npc_the_scourge_cauldron() : CreatureScript("npc_the_scourge_cauldron") + { + } CreatureAI* GetAI(Creature* creature) const override { @@ -49,17 +51,23 @@ class npc_the_scourge_cauldron : public CreatureScript struct npc_the_scourge_cauldronAI : public ScriptedAI { - npc_the_scourge_cauldronAI(Creature* creature) : ScriptedAI(creature) { } + npc_the_scourge_cauldronAI(Creature* creature) : ScriptedAI(creature) + { + } - void Reset() override { } + void Reset() override + { + } - void JustEngagedWith(Unit* /*who*/) override { } + void JustEngagedWith(Unit* /*who*/) override + { + } void DoDie() { - //summoner dies here - me->DealDamage(me, me->GetHealth(), nullptr, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, nullptr, false); - //override any database `spawntimesecs` to prevent duplicated summons + // summoner dies here + me->KillSelf(); + // override any database `spawntimesecs` to prevent duplicated summons uint32 rTime = me->GetRespawnDelay(); if (rTime < 600) me->SetRespawnDelay(600); @@ -76,38 +84,34 @@ class npc_the_scourge_cauldron : public CreatureScript switch (me->GetAreaId()) { - case 199: //felstone - if (player->GetQuestStatus(5216) == QUEST_STATUS_INCOMPLETE || - player->GetQuestStatus(5229) == QUEST_STATUS_INCOMPLETE) - { - me->SummonCreature(11075, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 600000); - DoDie(); - } - break; - case 200: //dalson - if (player->GetQuestStatus(5219) == QUEST_STATUS_INCOMPLETE || - player->GetQuestStatus(5231) == QUEST_STATUS_INCOMPLETE) - { - me->SummonCreature(11077, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 600000); - DoDie(); - } - break; - case 201: //gahrron - if (player->GetQuestStatus(5225) == QUEST_STATUS_INCOMPLETE || - player->GetQuestStatus(5235) == QUEST_STATUS_INCOMPLETE) - { - me->SummonCreature(11078, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 600000); - DoDie(); - } - break; - case 202: //writhing - if (player->GetQuestStatus(5222) == QUEST_STATUS_INCOMPLETE || - player->GetQuestStatus(5233) == QUEST_STATUS_INCOMPLETE) - { - me->SummonCreature(11076, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 600000); - DoDie(); - } - break; + case 199: // felstone + if (player->GetQuestStatus(5216) == QUEST_STATUS_INCOMPLETE || player->GetQuestStatus(5229) == QUEST_STATUS_INCOMPLETE) + { + me->SummonCreature(11075, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 600000); + DoDie(); + } + break; + case 200: // dalson + if (player->GetQuestStatus(5219) == QUEST_STATUS_INCOMPLETE || player->GetQuestStatus(5231) == QUEST_STATUS_INCOMPLETE) + { + me->SummonCreature(11077, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 600000); + DoDie(); + } + break; + case 201: // gahrron + if (player->GetQuestStatus(5225) == QUEST_STATUS_INCOMPLETE || player->GetQuestStatus(5235) == QUEST_STATUS_INCOMPLETE) + { + me->SummonCreature(11078, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 600000); + DoDie(); + } + break; + case 202: // writhing + if (player->GetQuestStatus(5222) == QUEST_STATUS_INCOMPLETE || player->GetQuestStatus(5233) == QUEST_STATUS_INCOMPLETE) + { + me->SummonCreature(11076, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 600000); + DoDie(); + } + break; } } }; @@ -119,13 +123,15 @@ class npc_the_scourge_cauldron : public CreatureScript enum AndorhalTower { - GO_BEACON_TORCH = 176093 + GO_BEACON_TORCH = 176093 }; class npc_andorhal_tower : public CreatureScript { -public: - npc_andorhal_tower() : CreatureScript("npc_andorhal_tower") { } + public: + npc_andorhal_tower() : CreatureScript("npc_andorhal_tower") + { + } CreatureAI* GetAI(Creature* creature) const override { diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_archimonde.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_archimonde.cpp index 9a88d59c..1fd880f3 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_archimonde.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_archimonde.cpp @@ -22,70 +22,70 @@ SDComment: Doomfires not completely offlike due to core limitations for random m SDCategory: Caverns of Time, Mount Hyjal EndScriptData */ -#include "ScriptMgr.h" -#include "hyjal.h" #include "InstanceScript.h" #include "MotionMaster.h" #include "ObjectAccessor.h" #include "Player.h" +#include "ScriptMgr.h" #include "ScriptedCreature.h" #include "SpellScript.h" +#include "hyjal.h" enum Texts { - SAY_AGGRO = 1, - SAY_DOOMFIRE = 2, - SAY_AIR_BURST = 3, - SAY_SLAY = 4, - SAY_ENRAGE = 5, - SAY_DEATH = 6, + SAY_AGGRO = 1, + SAY_DOOMFIRE = 2, + SAY_AIR_BURST = 3, + SAY_SLAY = 4, + SAY_ENRAGE = 5, + SAY_DEATH = 6, SAY_SOUL_CHARGE = 7, // YELL_ARCHIMONDE_INTRO = 8 }; enum Spells { - SPELL_DENOUEMENT_WISP = 32124, - SPELL_ANCIENT_SPARK = 39349, - SPELL_PROTECTION_OF_ELUNE = 38528, + SPELL_DENOUEMENT_WISP = 32124, + SPELL_ANCIENT_SPARK = 39349, + SPELL_PROTECTION_OF_ELUNE = 38528, - SPELL_DRAIN_WORLD_TREE = 39140, + SPELL_DRAIN_WORLD_TREE = 39140, SPELL_DRAIN_WORLD_TREE_TRIGGERED = 39141, - SPELL_FINGER_OF_DEATH = 31984, - SPELL_HAND_OF_DEATH = 35354, - SPELL_AIR_BURST = 32014, - SPELL_GRIP_OF_THE_LEGION = 31972, - SPELL_DOOMFIRE_STRIKE = 31903, // summons two creatures - SPELL_DOOMFIRE_SPAWN = 32074, - SPELL_DOOMFIRE = 31945, - SPELL_SOUL_CHARGE_YELLOW = 32045, - SPELL_SOUL_CHARGE_GREEN = 32051, - SPELL_SOUL_CHARGE_RED = 32052, - SPELL_UNLEASH_SOUL_YELLOW = 32054, - SPELL_UNLEASH_SOUL_GREEN = 32057, - SPELL_UNLEASH_SOUL_RED = 32053, - SPELL_FEAR = 31970 + SPELL_FINGER_OF_DEATH = 31984, + SPELL_HAND_OF_DEATH = 35354, + SPELL_AIR_BURST = 32014, + SPELL_GRIP_OF_THE_LEGION = 31972, + SPELL_DOOMFIRE_STRIKE = 31903, // summons two creatures + SPELL_DOOMFIRE_SPAWN = 32074, + SPELL_DOOMFIRE = 31945, + SPELL_SOUL_CHARGE_YELLOW = 32045, + SPELL_SOUL_CHARGE_GREEN = 32051, + SPELL_SOUL_CHARGE_RED = 32052, + SPELL_UNLEASH_SOUL_YELLOW = 32054, + SPELL_UNLEASH_SOUL_GREEN = 32057, + SPELL_UNLEASH_SOUL_RED = 32053, + SPELL_FEAR = 31970 }; enum Events { - EVENT_HAND_OF_DEATH = 1, // Raid wiper + EVENT_HAND_OF_DEATH = 1, // Raid wiper EVENT_UNLEASH_SOUL_CHARGE, EVENT_FINGER_OF_DEATH, EVENT_GRIP_OF_THE_LEGION, EVENT_FEAR, EVENT_AIR_BURST, EVENT_DOOMFIRE, - EVENT_DISTANCE_CHECK, // This checks if he's too close to the World Tree (75 yards from a point on the tree), if true then he will enrage + EVENT_DISTANCE_CHECK, // This checks if he's too close to the World Tree (75 yards from a point on the tree), if true then he will enrage EVENT_SUMMON_WHISP }; enum Summons { - NPC_DOOMFIRE = 18095, - NPC_DOOMFIRE_SPIRIT = 18104, - NPC_ANCIENT_WISP = 17946 + NPC_DOOMFIRE = 18095, + NPC_DOOMFIRE_SPIRIT = 18104, + NPC_ANCIENT_WISP = 17946 }; enum Actions @@ -96,8 +96,10 @@ enum Actions class npc_ancient_wisp : public CreatureScript { -public: - npc_ancient_wisp() : CreatureScript("npc_ancient_wisp") { } + public: + npc_ancient_wisp() : CreatureScript("npc_ancient_wisp") + { + } struct npc_ancient_wispAI : public ScriptedAI { @@ -126,9 +128,11 @@ class npc_ancient_wisp : public CreatureScript me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); } - void JustEngagedWith(Unit* /*who*/) override { } + void JustEngagedWith(Unit* /*who*/) override + { + } - void DamageTaken(Unit* /*done_by*/, uint32 &damage) override + void DamageTaken(Unit* /*done_by*/, uint32& damage) override { damage = 0; } @@ -145,7 +149,9 @@ class npc_ancient_wisp : public CreatureScript DoCast(Archimonde, SPELL_ANCIENT_SPARK); } CheckTimer = 1000; - } else CheckTimer -= diff; + } + else + CheckTimer -= diff; } }; @@ -159,20 +165,30 @@ class npc_ancient_wisp : public CreatureScript MoveChase the Doomfire Spirit always, until despawn (AttackStart is called upon it's spawn) */ class npc_doomfire : public CreatureScript { -public: - npc_doomfire() : CreatureScript("npc_doomfire") { } + public: + npc_doomfire() : CreatureScript("npc_doomfire") + { + } struct npc_doomfireAI : public ScriptedAI { - npc_doomfireAI(Creature* creature) : ScriptedAI(creature) { } + npc_doomfireAI(Creature* creature) : ScriptedAI(creature) + { + } - void Reset() override { } + void Reset() override + { + } - void MoveInLineOfSight(Unit* /*who*/) override { } + void MoveInLineOfSight(Unit* /*who*/) override + { + } - void JustEngagedWith(Unit* /*who*/) override { } + void JustEngagedWith(Unit* /*who*/) override + { + } - void DamageTaken(Unit* /*done_by*/, uint32 &damage) override + void DamageTaken(Unit* /*done_by*/, uint32& damage) override { damage = 0; } @@ -188,8 +204,10 @@ class npc_doomfire : public CreatureScript travels in random directions if target cannot be found. */ class npc_doomfire_targetting : public CreatureScript { -public: - npc_doomfire_targetting() : CreatureScript("npc_doomfire_targetting") { } + public: + npc_doomfire_targetting() : CreatureScript("npc_doomfire_targetting") + { + } struct npc_doomfire_targettingAI : public ScriptedAI { @@ -214,15 +232,17 @@ class npc_doomfire_targetting : public CreatureScript void MoveInLineOfSight(Unit* who) override { - //will update once TargetGUID is 0. In case noone actually moves(not likely) and this is 0 - //when UpdateAI needs it, it will be forced to select randomPoint + // will update once TargetGUID is 0. In case noone actually moves(not likely) and this is 0 + // when UpdateAI needs it, it will be forced to select randomPoint if (!TargetGUID && who->GetTypeId() == TYPEID_PLAYER) TargetGUID = who->GetGUID(); } - void JustEngagedWith(Unit* /*who*/) override { } + void JustEngagedWith(Unit* /*who*/) override + { + } - void DamageTaken(Unit* /*done_by*/, uint32 &damage) override + void DamageTaken(Unit* /*done_by*/, uint32& damage) override { damage = 0; } @@ -243,7 +263,9 @@ class npc_doomfire_targetting : public CreatureScript } ChangeTargetTimer = 5000; - } else ChangeTargetTimer -= diff; + } + else + ChangeTargetTimer -= diff; } }; @@ -263,8 +285,10 @@ class npc_doomfire_targetting : public CreatureScript class boss_archimonde : public CreatureScript { -public: - boss_archimonde() : CreatureScript("boss_archimonde") { } + public: + boss_archimonde() : CreatureScript("boss_archimonde") + { + } struct boss_archimondeAI : public BossAI { @@ -278,7 +302,7 @@ class boss_archimonde : public CreatureScript DoomfireSpiritGUID.Clear(); SoulChargeCount = 0; - WispCount = 0; // When ~30 wisps are summoned, Archimonde dies + WispCount = 0; // When ~30 wisps are summoned, Archimonde dies _unleashSpell = 0; _chargeSpell = 0; @@ -296,7 +320,7 @@ class boss_archimonde : public CreatureScript { Initialize(); _Reset(); - me->RemoveAllAuras(); // Reset Soul Charge auras. + me->RemoveAllAuras(); // Reset Soul Charge auras. } void JustEngagedWith(Unit* who) override @@ -317,89 +341,89 @@ class boss_archimonde : public CreatureScript { switch (eventId) { - case EVENT_HAND_OF_DEATH: - DoCastAOE(SPELL_HAND_OF_DEATH); - events.ScheduleEvent(EVENT_HAND_OF_DEATH, 2000); - break; - case EVENT_UNLEASH_SOUL_CHARGE: - _chargeSpell = 0; - _unleashSpell = 0; - me->InterruptNonMeleeSpells(false); - switch (urand(0, 2)) - { - case 0: - _chargeSpell = SPELL_SOUL_CHARGE_RED; - _unleashSpell = SPELL_UNLEASH_SOUL_RED; - break; - case 1: - _chargeSpell = SPELL_SOUL_CHARGE_YELLOW; - _unleashSpell = SPELL_UNLEASH_SOUL_YELLOW; - break; - case 2: - _chargeSpell = SPELL_SOUL_CHARGE_GREEN; - _unleashSpell = SPELL_UNLEASH_SOUL_GREEN; - break; - } - - if (me->HasAura(_chargeSpell)) - { - me->RemoveAuraFromStack(_chargeSpell); - DoCastVictim(_unleashSpell); - SoulChargeCount--; - events.ScheduleEvent(EVENT_UNLEASH_SOUL_CHARGE, urand(2000, 30000)); - } - break; - case EVENT_FINGER_OF_DEATH: - if (!SelectTarget(SELECT_TARGET_RANDOM, 0, 5.0f)) // Checks if there are no targets in melee range - { - DoCast(SelectTarget(SELECT_TARGET_RANDOM, 0), SPELL_FINGER_OF_DEATH); - events.ScheduleEvent(EVENT_FINGER_OF_DEATH, 1000); - } - else - events.ScheduleEvent(EVENT_FINGER_OF_DEATH, 5000); - break; - case EVENT_GRIP_OF_THE_LEGION: - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) - DoCast(target, SPELL_GRIP_OF_THE_LEGION); - events.ScheduleEvent(EVENT_GRIP_OF_THE_LEGION, urand(5000, 25000)); - break; - case EVENT_AIR_BURST: - Talk(SAY_AIR_BURST); - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1)) - DoCast(target, SPELL_AIR_BURST); //not on tank - events.ScheduleEvent(EVENT_AIR_BURST, urand(25000, 40000)); - break; - case EVENT_FEAR: - DoCastAOE(SPELL_FEAR); - events.ScheduleEvent(EVENT_FEAR, 42000); - break; - case EVENT_DOOMFIRE: - Talk(SAY_DOOMFIRE); - if (Unit* temp = SelectTarget(SELECT_TARGET_RANDOM, 1)) - SummonDoomfire(temp); - else - SummonDoomfire(me->GetVictim()); - events.ScheduleEvent(EVENT_DOOMFIRE, 20000); - break; - case EVENT_DISTANCE_CHECK: - if (Creature* channelTrigger = instance->GetCreature(DATA_CHANNEL_TARGET)) - if (me->IsWithinDistInMap(channelTrigger, 75.0f)) - DoAction(ACTION_ENRAGE); - events.ScheduleEvent(EVENT_DISTANCE_CHECK, 5000); + case EVENT_HAND_OF_DEATH: + DoCastAOE(SPELL_HAND_OF_DEATH); + events.ScheduleEvent(EVENT_HAND_OF_DEATH, 2000); + break; + case EVENT_UNLEASH_SOUL_CHARGE: + _chargeSpell = 0; + _unleashSpell = 0; + me->InterruptNonMeleeSpells(false); + switch (urand(0, 2)) + { + case 0: + _chargeSpell = SPELL_SOUL_CHARGE_RED; + _unleashSpell = SPELL_UNLEASH_SOUL_RED; break; - case EVENT_SUMMON_WHISP: - DoSpawnCreature(NPC_ANCIENT_WISP, float(rand32() % 40), float(rand32() % 40), 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); - ++WispCount; - if (WispCount >= 30) - me->DealDamage(me, me->GetHealth(), nullptr, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, nullptr, false); - events.ScheduleEvent(EVENT_SUMMON_WHISP, 1500); + case 1: + _chargeSpell = SPELL_SOUL_CHARGE_YELLOW; + _unleashSpell = SPELL_UNLEASH_SOUL_YELLOW; break; - default: + case 2: + _chargeSpell = SPELL_SOUL_CHARGE_GREEN; + _unleashSpell = SPELL_UNLEASH_SOUL_GREEN; break; + } + + if (me->HasAura(_chargeSpell)) + { + me->RemoveAuraFromStack(_chargeSpell); + DoCastVictim(_unleashSpell); + SoulChargeCount--; + events.ScheduleEvent(EVENT_UNLEASH_SOUL_CHARGE, urand(2000, 30000)); + } + break; + case EVENT_FINGER_OF_DEATH: + if (!SelectTarget(SELECT_TARGET_RANDOM, 0, 5.0f)) // Checks if there are no targets in melee range + { + DoCast(SelectTarget(SELECT_TARGET_RANDOM, 0), SPELL_FINGER_OF_DEATH); + events.ScheduleEvent(EVENT_FINGER_OF_DEATH, 1000); + } + else + events.ScheduleEvent(EVENT_FINGER_OF_DEATH, 5000); + break; + case EVENT_GRIP_OF_THE_LEGION: + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) + DoCast(target, SPELL_GRIP_OF_THE_LEGION); + events.ScheduleEvent(EVENT_GRIP_OF_THE_LEGION, urand(5000, 25000)); + break; + case EVENT_AIR_BURST: + Talk(SAY_AIR_BURST); + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1)) + DoCast(target, SPELL_AIR_BURST); // not on tank + events.ScheduleEvent(EVENT_AIR_BURST, urand(25000, 40000)); + break; + case EVENT_FEAR: + DoCastAOE(SPELL_FEAR); + events.ScheduleEvent(EVENT_FEAR, 42000); + break; + case EVENT_DOOMFIRE: + Talk(SAY_DOOMFIRE); + if (Unit* temp = SelectTarget(SELECT_TARGET_RANDOM, 1)) + SummonDoomfire(temp); + else + SummonDoomfire(me->GetVictim()); + events.ScheduleEvent(EVENT_DOOMFIRE, 20000); + break; + case EVENT_DISTANCE_CHECK: + if (Creature* channelTrigger = instance->GetCreature(DATA_CHANNEL_TARGET)) + if (me->IsWithinDistInMap(channelTrigger, 75.0f)) + DoAction(ACTION_ENRAGE); + events.ScheduleEvent(EVENT_DISTANCE_CHECK, 5000); + break; + case EVENT_SUMMON_WHISP: + DoSpawnCreature(NPC_ANCIENT_WISP, float(rand32() % 40), float(rand32() % 40), 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); + ++WispCount; + if (WispCount >= 30) + me->KillSelf(); + events.ScheduleEvent(EVENT_SUMMON_WHISP, 1500); + break; + default: + break; } } - void DamageTaken(Unit* /*attacker*/, uint32 &damage) override + void DamageTaken(Unit* /*attacker*/, uint32& damage) override { if (me->HealthBelowPctDamaged(10, damage)) { @@ -427,21 +451,21 @@ class boss_archimonde : public CreatureScript { switch (victim->getClass()) { - case CLASS_PRIEST: - case CLASS_PALADIN: - case CLASS_WARLOCK: - victim->CastSpell(me, SPELL_SOUL_CHARGE_RED, true); - break; - case CLASS_MAGE: - case CLASS_ROGUE: - case CLASS_WARRIOR: - victim->CastSpell(me, SPELL_SOUL_CHARGE_YELLOW, true); - break; - case CLASS_DRUID: - case CLASS_SHAMAN: - case CLASS_HUNTER: - victim->CastSpell(me, SPELL_SOUL_CHARGE_GREEN, true); - break; + case CLASS_PRIEST: + case CLASS_PALADIN: + case CLASS_WARLOCK: + victim->CastSpell(me, SPELL_SOUL_CHARGE_RED, true); + break; + case CLASS_MAGE: + case CLASS_ROGUE: + case CLASS_WARRIOR: + victim->CastSpell(me, SPELL_SOUL_CHARGE_YELLOW, true); + break; + case CLASS_DRUID: + case CLASS_SHAMAN: + case CLASS_HUNTER: + victim->CastSpell(me, SPELL_SOUL_CHARGE_GREEN, true); + break; } events.ScheduleEvent(EVENT_UNLEASH_SOUL_CHARGE, urand(2000, 30000)); @@ -466,24 +490,24 @@ class boss_archimonde : public CreatureScript { switch (summoned->GetEntry()) { - case NPC_ANCIENT_WISP: - summoned->AI()->AttackStart(me); - break; - case NPC_DOOMFIRE_SPIRIT: - DoomfireSpiritGUID = summoned->GetGUID(); - break; - case NPC_DOOMFIRE: - summoned->CastSpell(summoned, SPELL_DOOMFIRE_SPAWN, false); - summoned->CastSpell(summoned, SPELL_DOOMFIRE, me->GetGUID()); - - if (Unit* DoomfireSpirit = ObjectAccessor::GetUnit(*me, DoomfireSpiritGUID)) - { - summoned->GetMotionMaster()->MoveFollow(DoomfireSpirit, 0.0f, 0.0f); - DoomfireSpiritGUID.Clear(); - } - break; - default: - break; + case NPC_ANCIENT_WISP: + summoned->AI()->AttackStart(me); + break; + case NPC_DOOMFIRE_SPIRIT: + DoomfireSpiritGUID = summoned->GetGUID(); + break; + case NPC_DOOMFIRE: + summoned->CastSpell(summoned, SPELL_DOOMFIRE_SPAWN, false); + summoned->CastSpell(summoned, SPELL_DOOMFIRE, me->GetGUID()); + + if (Unit* DoomfireSpirit = ObjectAccessor::GetUnit(*me, DoomfireSpiritGUID)) + { + summoned->GetMotionMaster()->MoveFollow(DoomfireSpirit, 0.0f, 0.0f); + DoomfireSpiritGUID.Clear(); + } + break; + default: + break; } } @@ -491,36 +515,32 @@ class boss_archimonde : public CreatureScript { switch (actionId) { - case ACTION_ENRAGE: - me->GetMotionMaster()->Clear(false); - me->GetMotionMaster()->MoveIdle(); - Enraged = true; - Talk(SAY_ENRAGE); - break; - case ACTION_CHANNEL_WORLD_TREE: - DoCastAOE(SPELL_DRAIN_WORLD_TREE, true); - break; - default: - break; + case ACTION_ENRAGE: + me->GetMotionMaster()->Clear(false); + me->GetMotionMaster()->MoveIdle(); + Enraged = true; + Talk(SAY_ENRAGE); + break; + case ACTION_CHANNEL_WORLD_TREE: + DoCastAOE(SPELL_DRAIN_WORLD_TREE, true); + break; + default: + break; } } - //this is code doing close to what the summoning spell would do (spell 31903) + // this is code doing close to what the summoning spell would do (spell 31903) void SummonDoomfire(Unit* target) { if (!target) return; - me->SummonCreature(NPC_DOOMFIRE_SPIRIT, - target->GetPositionX()+15.0f, target->GetPositionY()+15.0f, target->GetPositionZ(), 0, - TEMPSUMMON_TIMED_DESPAWN, 27000); + me->SummonCreature(NPC_DOOMFIRE_SPIRIT, target->GetPositionX() + 15.0f, target->GetPositionY() + 15.0f, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 27000); - me->SummonCreature(NPC_DOOMFIRE, - target->GetPositionX()-15.0f, target->GetPositionY()-15.0f, target->GetPositionZ(), 0, - TEMPSUMMON_TIMED_DESPAWN, 27000); + me->SummonCreature(NPC_DOOMFIRE, target->GetPositionX() - 15.0f, target->GetPositionY() - 15.0f, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 27000); } - private: + private: ObjectGuid DoomfireSpiritGUID; uint8 SoulChargeCount; uint8 WispCount; @@ -539,32 +559,34 @@ class boss_archimonde : public CreatureScript // 39142 - Drain World Tree Dummy class spell_archimonde_drain_world_tree_dummy : public SpellScriptLoader { - public: - spell_archimonde_drain_world_tree_dummy() : SpellScriptLoader("spell_archimonde_drain_world_tree_dummy") { } + public: + spell_archimonde_drain_world_tree_dummy() : SpellScriptLoader("spell_archimonde_drain_world_tree_dummy") + { + } - class spell_archimonde_drain_world_tree_dummy_SpellScript : public SpellScript + class spell_archimonde_drain_world_tree_dummy_SpellScript : public SpellScript + { + bool Validate(SpellInfo const* /*spellInfo*/) override { - bool Validate(SpellInfo const* /*spellInfo*/) override - { - return ValidateSpellInfo({ SPELL_DRAIN_WORLD_TREE_TRIGGERED }); - } - - void HandleScript(SpellEffIndex /*effIndex*/) - { - if (Unit* target = GetHitUnit()) - target->CastSpell(GetCaster(), SPELL_DRAIN_WORLD_TREE_TRIGGERED, true); - } + return ValidateSpellInfo({SPELL_DRAIN_WORLD_TREE_TRIGGERED}); + } - void Register() override - { - OnEffectHitTarget.Register(&spell_archimonde_drain_world_tree_dummy_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_DUMMY); - } - }; + void HandleScript(SpellEffIndex /*effIndex*/) + { + if (Unit* target = GetHitUnit()) + target->CastSpell(GetCaster(), SPELL_DRAIN_WORLD_TREE_TRIGGERED, true); + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_archimonde_drain_world_tree_dummy_SpellScript(); + OnEffectHitTarget.Register(&spell_archimonde_drain_world_tree_dummy_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_DUMMY); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_archimonde_drain_world_tree_dummy_SpellScript(); + } }; void AddSC_boss_archimonde() diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/instance_culling_of_stratholme.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/instance_culling_of_stratholme.cpp index 43ca8383..0afbb83a 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/instance_culling_of_stratholme.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/instance_culling_of_stratholme.cpp @@ -15,7 +15,6 @@ * with this program. If not, see . */ -#include "culling_of_stratholme.h" #include "Creature.h" #include "CreatureAI.h" #include "CreatureTextMgr.h" @@ -23,14 +22,15 @@ #include "GameObject.h" #include "GameTime.h" #include "InstanceScript.h" +#include "Log.h" #include "Map.h" #include "MotionMaster.h" -#include "Log.h" #include "Player.h" #include "ScriptMgr.h" #include "SpellInfo.h" #include "TemporarySummon.h" #include "WorldStatePackets.h" +#include "culling_of_stratholme.h" #include #include #include @@ -56,37 +56,37 @@ enum COSEvents enum COSEntries { - NPC_GENERIC_BUNNY = 28960, - NPC_CRATE_HELPER = 27827, - NPC_CHROMIE = 26527, // first chromie - we don't need the other two for anything - NPC_INFINITE_CORRUPTOR = 32273, - NPC_GUARDIAN_OF_TIME = 32281, - NPC_TIME_RIFT = 28409, - NPC_LORDAERON_CRIER = 27913, - NPC_DEVOURING_GHOUL = 28249, - NPC_ENRAGED_GHOUL = 27729, - NPC_NECROMANCER = 28200, - NPC_CRYPT_FIEND = 27734, - NPC_ACOLYTE = 27731, - NPC_CRYPT_STALKER = 28199, - NPC_ABOMINATION = 27736, - NPC_MEATHOOK = 26529, - NPC_SALRAMM = 26530, - - GO_MALGANIS_GATE_2 = 187723, - GO_EXIT_GATE = 191788, + NPC_GENERIC_BUNNY = 28960, + NPC_CRATE_HELPER = 27827, + NPC_CHROMIE = 26527, // first chromie - we don't need the other two for anything + NPC_INFINITE_CORRUPTOR = 32273, + NPC_GUARDIAN_OF_TIME = 32281, + NPC_TIME_RIFT = 28409, + NPC_LORDAERON_CRIER = 27913, + NPC_DEVOURING_GHOUL = 28249, + NPC_ENRAGED_GHOUL = 27729, + NPC_NECROMANCER = 28200, + NPC_CRYPT_FIEND = 27734, + NPC_ACOLYTE = 27731, + NPC_CRYPT_STALKER = 28199, + NPC_ABOMINATION = 27736, + NPC_MEATHOOK = 26529, + NPC_SALRAMM = 26530, + + GO_MALGANIS_GATE_2 = 187723, + GO_EXIT_GATE = 191788, SPELL_CRATES_KILL_CREDIT = 58109 }; enum COSYells { - CRIER_SAY_CALL_TO_GATES = 0, - CRIER_SAY_KINGS_SQUARE = 1, - CRIER_SAY_MARKET_ROW = 2, - CRIER_SAY_FESTIVAL_LANE = 3, - CRIER_SAY_ELDERS_SQUARE = 4, - CRIER_SAY_TOWN_HALL = 5, + CRIER_SAY_CALL_TO_GATES = 0, + CRIER_SAY_KINGS_SQUARE = 1, + CRIER_SAY_MARKET_ROW = 2, + CRIER_SAY_FESTIVAL_LANE = 3, + CRIER_SAY_ELDERS_SQUARE = 4, + CRIER_SAY_TOWN_HALL = 5, CHROMIE_WHISPER_GUARDIAN_1 = 0, CHROMIE_WHISPER_GUARDIAN_2 = 1, @@ -95,15 +95,15 @@ enum COSYells enum COSWorldStates { - WORLDSTATE_SHOW_CRATES = 3479, - WORLDSTATE_CRATES_REVEALED = 3480, - WORLDSTATE_WAVE_COUNT = 3504, - WORLDSTATE_WAVE_MARKER_ES = 3581, - WORLDSTATE_WAVE_MARKER_FL = 3582, - WORLDSTATE_WAVE_MARKER_KS = 3583, - WORLDSTATE_WAVE_MARKER_MR = 3584, - WORLDSTATE_WAVE_MARKER_TH = 3585, - WORLDSTATE_TIME_GUARDIAN = 3931, + WORLDSTATE_SHOW_CRATES = 3479, + WORLDSTATE_CRATES_REVEALED = 3480, + WORLDSTATE_WAVE_COUNT = 3504, + WORLDSTATE_WAVE_MARKER_ES = 3581, + WORLDSTATE_WAVE_MARKER_FL = 3582, + WORLDSTATE_WAVE_MARKER_KS = 3583, + WORLDSTATE_WAVE_MARKER_MR = 3584, + WORLDSTATE_WAVE_MARKER_TH = 3585, + WORLDSTATE_TIME_GUARDIAN = 3931, WORLDSTATE_TIME_GUARDIAN_SHOW = 3932 }; @@ -117,72 +117,66 @@ enum COSWaveLocations enum COSMisc { - NUM_PLAGUE_CRATES = 5, - NUM_SCOURGE_WAVES = 10, + NUM_PLAGUE_CRATES = 5, + NUM_SCOURGE_WAVES = 10, MAX_SPAWNS_PER_WAVE = 6, - WAVE_MEATHOOK = 5, - WAVE_SALRAMM = 10 + WAVE_MEATHOOK = 5, + WAVE_SALRAMM = 10 }; -DoorData const doorData[] = -{ - { GO_MALGANIS_GATE_2, DATA_MAL_GANIS, DOOR_TYPE_ROOM }, - { GO_EXIT_GATE, DATA_MAL_GANIS, DOOR_TYPE_PASSAGE }, - { 0, 0, DOOR_TYPE_ROOM } // END +DoorData const doorData[] = { + {GO_MALGANIS_GATE_2, DATA_MAL_GANIS, DOOR_TYPE_ROOM}, {GO_EXIT_GATE, DATA_MAL_GANIS, DOOR_TYPE_PASSAGE}, {0, 0, DOOR_TYPE_ROOM} // END }; COSProgressStates GetStableStateFor(COSProgressStates const state) { switch (state) { - case JUST_STARTED: - default: - return JUST_STARTED; - case CRATES_IN_PROGRESS: - return CRATES_IN_PROGRESS; - case CRATES_DONE: - return CRATES_DONE; - case UTHER_TALK: - case PURGE_PENDING: - case PURGE_STARTING: - case WAVES_IN_PROGRESS: - return PURGE_PENDING; - case WAVES_DONE: - case TOWN_HALL_PENDING: - case TOWN_HALL: - return TOWN_HALL_PENDING; - case TOWN_HALL_COMPLETE: - case GAUNTLET_TRANSITION: - case GAUNTLET_PENDING: - case GAUNTLET_IN_PROGRESS: - return GAUNTLET_PENDING; - case GAUNTLET_COMPLETE: - case MALGANIS_IN_PROGRESS: - return GAUNTLET_COMPLETE; - case COMPLETE: - return COMPLETE; + case JUST_STARTED: + default: + return JUST_STARTED; + case CRATES_IN_PROGRESS: + return CRATES_IN_PROGRESS; + case CRATES_DONE: + return CRATES_DONE; + case UTHER_TALK: + case PURGE_PENDING: + case PURGE_STARTING: + case WAVES_IN_PROGRESS: + return PURGE_PENDING; + case WAVES_DONE: + case TOWN_HALL_PENDING: + case TOWN_HALL: + return TOWN_HALL_PENDING; + case TOWN_HALL_COMPLETE: + case GAUNTLET_TRANSITION: + case GAUNTLET_PENDING: + case GAUNTLET_IN_PROGRESS: + return GAUNTLET_PENDING; + case GAUNTLET_COMPLETE: + case MALGANIS_IN_PROGRESS: + return GAUNTLET_COMPLETE; + case COMPLETE: + return COMPLETE; } } -static Position const CorruptorPos = { 2331.642f, 1273.273f, 132.9524f, 3.717551f }; -static Position const GuardianPos = { 2321.489f, 1268.383f, 132.8507f, 0.418879f }; -static Position const CorruptorRiftPos = { 2443.626f, 1280.450f, 133.0066f, 1.727876f }; - -static std::array, NUM_SCOURGE_WAVES> const HeroicWaves = -{ - { - { { NPC_DEVOURING_GHOUL, NPC_DEVOURING_GHOUL, NPC_DEVOURING_GHOUL } }, // wave 1 - { { NPC_DEVOURING_GHOUL, NPC_ENRAGED_GHOUL, NPC_NECROMANCER } }, // wave 2 - { { NPC_DEVOURING_GHOUL, NPC_ENRAGED_GHOUL, NPC_NECROMANCER, NPC_CRYPT_FIEND } }, // wave 3 - { { NPC_NECROMANCER, NPC_CRYPT_FIEND, NPC_ACOLYTE, NPC_ACOLYTE, NPC_ACOLYTE, NPC_ACOLYTE } }, // wave 4 - { { 0 } }, // wave 5, meathook (special) - { { NPC_DEVOURING_GHOUL, NPC_NECROMANCER, NPC_CRYPT_FIEND, NPC_CRYPT_STALKER } }, // wave 6 - { { NPC_DEVOURING_GHOUL, NPC_ENRAGED_GHOUL, NPC_ENRAGED_GHOUL, NPC_ABOMINATION } }, // wave 7 - { { NPC_DEVOURING_GHOUL, NPC_ENRAGED_GHOUL, NPC_NECROMANCER, NPC_ABOMINATION } }, // wave 8 - { { NPC_DEVOURING_GHOUL, NPC_NECROMANCER, NPC_CRYPT_FIEND, NPC_ABOMINATION } }, // wave 9 - { { 0 } } // wave 10, salramm (special) - } -}; +static Position const CorruptorPos = {2331.642f, 1273.273f, 132.9524f, 3.717551f}; +static Position const GuardianPos = {2321.489f, 1268.383f, 132.8507f, 0.418879f}; +static Position const CorruptorRiftPos = {2443.626f, 1280.450f, 133.0066f, 1.727876f}; + +static std::array, NUM_SCOURGE_WAVES> const HeroicWaves = {{ + {{NPC_DEVOURING_GHOUL, NPC_DEVOURING_GHOUL, NPC_DEVOURING_GHOUL}}, // wave 1 + {{NPC_DEVOURING_GHOUL, NPC_ENRAGED_GHOUL, NPC_NECROMANCER}}, // wave 2 + {{NPC_DEVOURING_GHOUL, NPC_ENRAGED_GHOUL, NPC_NECROMANCER, NPC_CRYPT_FIEND}}, // wave 3 + {{NPC_NECROMANCER, NPC_CRYPT_FIEND, NPC_ACOLYTE, NPC_ACOLYTE, NPC_ACOLYTE, NPC_ACOLYTE}}, // wave 4 + {{0}}, // wave 5, meathook (special) + {{NPC_DEVOURING_GHOUL, NPC_NECROMANCER, NPC_CRYPT_FIEND, NPC_CRYPT_STALKER}}, // wave 6 + {{NPC_DEVOURING_GHOUL, NPC_ENRAGED_GHOUL, NPC_ENRAGED_GHOUL, NPC_ABOMINATION}}, // wave 7 + {{NPC_DEVOURING_GHOUL, NPC_ENRAGED_GHOUL, NPC_NECROMANCER, NPC_ABOMINATION}}, // wave 8 + {{NPC_DEVOURING_GHOUL, NPC_NECROMANCER, NPC_CRYPT_FIEND, NPC_ABOMINATION}}, // wave 9 + {{0}} // wave 10, salramm (special) +}}; struct WaveLocation { @@ -190,672 +184,622 @@ struct WaveLocation std::array SpawnPoints; }; -static const std::array WaveLocations = +static const std::array WaveLocations = { + {{// King's Square + WORLDSTATE_WAVE_MARKER_KS, {{{2131.474f, 1352.615f, 131.372f, 6.10960f}, {2131.463f, 1357.127f, 131.587f, 5.95173f}, {2129.795f, 1345.093f, 131.194f, 0.17905f}, + {2136.235f, 1347.894f, 131.628f, 0.20262f}, {2138.219f, 1356.240f, 132.169f, 5.95173f}, {2140.584f, 1351.624f, 132.142f, 6.08525f}}}}, + {// Market Row + WORLDSTATE_WAVE_MARKER_MR, {{{2226.364f, 1331.808f, 127.0193f, 3.298672f}, {2229.934f, 1329.146f, 127.057f, 3.24605f}, {2225.028f, 1327.269f, 127.791f, 3.03792f}, + {2223.844f, 1335.282f, 127.749f, 3.47774f}, {2222.192f, 1330.859f, 127.526f, 3.18793f}, {2225.865f, 1331.029f, 127.007f, 3.18793f}}}}, + {// Festival Lane + WORLDSTATE_WAVE_MARKER_FL, {{{2183.596f, 1238.823f, 136.551f, 2.16377f}, {2181.420f, 1237.357f, 136.565f, 2.16377f}, {2178.692f, 1237.446f, 136.694f, 1.99098f}, + {2184.980f, 1242.458f, 136.772f, 2.59181f}, {2176.873f, 1240.463f, 136.420f, 2.10094f}, {2181.523f, 1244.298f, 136.338f, 2.38997f}}}}, + {// Elders' Square + WORLDSTATE_WAVE_MARKER_ES, {{{2267.003f, 1168.055f, 137.821f, 2.79050f}, {2264.392f, 1162.145f, 137.910f, 2.39937f}, {2262.785f, 1166.648f, 138.053f, 2.71353f}, + {2265.214f, 1170.771f, 137.972f, 2.80385f}, {2259.745f, 1159.360f, 138.198f, 2.34047f}, {2264.222f, 1171.708f, 138.047f, 2.82742f}}}}, + {// Town Hall + WORLDSTATE_WAVE_MARKER_TH, {{{2351.656f, 1218.682f, 130.062f, 4.63383f}, {2354.921f, 1218.425f, 130.280f, 4.63383f}, {2347.516f, 1216.976f, 130.491f, 5.02496f}, + {2356.508f, 1216.656f, 130.445f, 4.29061f}, {2346.674f, 1216.739f, 130.576f, 5.32341f}, {2351.728f, 1214.561f, 130.255f, 4.61891f}}}}}}; + +class instance_culling_of_stratholme : public InstanceMapScript { + public: + instance_culling_of_stratholme() : InstanceMapScript("instance_culling_of_stratholme", 595) { - { // King's Square - WORLDSTATE_WAVE_MARKER_KS, - { - { - { 2131.474f, 1352.615f, 131.372f, 6.10960f }, - { 2131.463f, 1357.127f, 131.587f, 5.95173f }, - { 2129.795f, 1345.093f, 131.194f, 0.17905f }, - { 2136.235f, 1347.894f, 131.628f, 0.20262f }, - { 2138.219f, 1356.240f, 132.169f, 5.95173f }, - { 2140.584f, 1351.624f, 132.142f, 6.08525f } - } - } - }, - { // Market Row - WORLDSTATE_WAVE_MARKER_MR, - { - { - { 2226.364f, 1331.808f, 127.0193f, 3.298672f }, - { 2229.934f, 1329.146f, 127.057f, 3.24605f }, - { 2225.028f, 1327.269f, 127.791f, 3.03792f }, - { 2223.844f, 1335.282f, 127.749f, 3.47774f }, - { 2222.192f, 1330.859f, 127.526f, 3.18793f }, - { 2225.865f, 1331.029f, 127.007f, 3.18793f } - } - } - }, - { // Festival Lane - WORLDSTATE_WAVE_MARKER_FL, - { - { - { 2183.596f, 1238.823f, 136.551f, 2.16377f }, - { 2181.420f, 1237.357f, 136.565f, 2.16377f }, - { 2178.692f, 1237.446f, 136.694f, 1.99098f }, - { 2184.980f, 1242.458f, 136.772f, 2.59181f }, - { 2176.873f, 1240.463f, 136.420f, 2.10094f }, - { 2181.523f, 1244.298f, 136.338f, 2.38997f } - } - } - }, - { // Elders' Square - WORLDSTATE_WAVE_MARKER_ES, - { - { - { 2267.003f, 1168.055f, 137.821f, 2.79050f }, - { 2264.392f, 1162.145f, 137.910f, 2.39937f }, - { 2262.785f, 1166.648f, 138.053f, 2.71353f }, - { 2265.214f, 1170.771f, 137.972f, 2.80385f }, - { 2259.745f, 1159.360f, 138.198f, 2.34047f }, - { 2264.222f, 1171.708f, 138.047f, 2.82742f } - } - } - }, - { // Town Hall - WORLDSTATE_WAVE_MARKER_TH, - { - { - { 2351.656f, 1218.682f, 130.062f, 4.63383f }, - { 2354.921f, 1218.425f, 130.280f, 4.63383f }, - { 2347.516f, 1216.976f, 130.491f, 5.02496f }, - { 2356.508f, 1216.656f, 130.445f, 4.29061f }, - { 2346.674f, 1216.739f, 130.576f, 5.32341f }, - { 2351.728f, 1214.561f, 130.255f, 4.61891f } - } - } - } } -}; -class instance_culling_of_stratholme : public InstanceMapScript -{ - public: - instance_culling_of_stratholme() : InstanceMapScript("instance_culling_of_stratholme", 595) { } + struct instance_culling_of_stratholme_InstanceMapScript : public InstanceScript + { + instance_culling_of_stratholme_InstanceMapScript(InstanceMap* map) : InstanceScript(map), _currentState(JUST_STARTED), _infiniteGuardianTimeout(0), _waveCount(0), _currentSpawnLoc(0) + { + SetHeaders(DataHeader); + SetBossNumber(EncounterCount); + LoadDoorData(doorData); + + _currentWorldStates[WORLDSTATE_SHOW_CRATES] = _currentWorldStates[WORLDSTATE_CRATES_REVEALED] = _currentWorldStates[WORLDSTATE_WAVE_COUNT] = + _currentWorldStates[WORLDSTATE_TIME_GUARDIAN_SHOW] = _currentWorldStates[WORLDSTATE_TIME_GUARDIAN] = 0; + _sentWorldStates = _currentWorldStates; + _plagueCrates.reserve(NUM_PLAGUE_CRATES); + } - struct instance_culling_of_stratholme_InstanceMapScript : public InstanceScript + void FillInitialWorldStates(WorldPackets::WorldState::InitWorldStates& data) override { - instance_culling_of_stratholme_InstanceMapScript(InstanceMap* map) : InstanceScript(map), _currentState(JUST_STARTED), _infiniteGuardianTimeout(0), _waveCount(0), _currentSpawnLoc(0) - { - SetHeaders(DataHeader); - SetBossNumber(EncounterCount); - LoadDoorData(doorData); + for (WorldStateMap::const_iterator itr = _sentWorldStates.begin(); itr != _sentWorldStates.end(); ++itr) + data.Worldstates.emplace_back(uint32(itr->first), uint32(itr->second)); + } - _currentWorldStates[WORLDSTATE_SHOW_CRATES] = _currentWorldStates[WORLDSTATE_CRATES_REVEALED] = _currentWorldStates[WORLDSTATE_WAVE_COUNT] = _currentWorldStates[WORLDSTATE_TIME_GUARDIAN_SHOW] = _currentWorldStates[WORLDSTATE_TIME_GUARDIAN] = 0; - _sentWorldStates = _currentWorldStates; - _plagueCrates.reserve(NUM_PLAGUE_CRATES); - } + void WriteSaveDataMore(std::ostringstream& data) override + { + data << _currentState << ' ' << _infiniteGuardianTimeout; + } - void FillInitialWorldStates(WorldPackets::WorldState::InitWorldStates& data) override - { - for (WorldStateMap::const_iterator itr = _sentWorldStates.begin(); itr != _sentWorldStates.end(); ++itr) - data.Worldstates.emplace_back(uint32(itr->first), uint32(itr->second)); - } + void ReadSaveDataMore(std::istringstream& data) override + { + // read current instance progress from save data, then regress to the previous stable state + uint32 state = JUST_STARTED; + time_t infiniteGuardianTime = 0; + data >> state; + data >> infiniteGuardianTime; // UNIX timestamp - void WriteSaveDataMore(std::ostringstream& data) override - { - data << _currentState << ' ' << _infiniteGuardianTimeout; - } + COSProgressStates loadState = GetStableStateFor(COSProgressStates(state)); + SetInstanceProgress(loadState, true); - void ReadSaveDataMore(std::istringstream& data) override + if (infiniteGuardianTime) { - // read current instance progress from save data, then regress to the previous stable state - uint32 state = JUST_STARTED; - time_t infiniteGuardianTime = 0; - data >> state; - data >> infiniteGuardianTime; // UNIX timestamp - - COSProgressStates loadState = GetStableStateFor(COSProgressStates(state)); - SetInstanceProgress(loadState, true); + _infiniteGuardianTimeout = infiniteGuardianTime; + events.ScheduleEvent(EVENT_GUARDIAN_TICK, 0s); + } - if (infiniteGuardianTime) - { - _infiniteGuardianTimeout = infiniteGuardianTime; - events.ScheduleEvent(EVENT_GUARDIAN_TICK, 0s); - } + time_t timediff = (infiniteGuardianTime - GameTime::GetGameTime()); + if (!infiniteGuardianTime) + timediff = -1; - time_t timediff = (infiniteGuardianTime - GameTime::GetGameTime()); - if (!infiniteGuardianTime) - timediff = -1; + LOG_DEBUG("scripts.cos", "instance_culling_of_stratholme::ReadSaveDataMore: Loaded with state %u and guardian timeout at %zu minutes %zu seconds from now", (uint32)loadState, + timediff / MINUTE, timediff % MINUTE); + } - LOG_DEBUG("scripts.cos", "instance_culling_of_stratholme::ReadSaveDataMore: Loaded with state %u and guardian timeout at %zu minutes %zu seconds from now", (uint32)loadState, timediff / MINUTE, timediff % MINUTE); + void SetData(uint32 type, uint32 data) override + { + switch (type) + { + case DATA_GM_OVERRIDE: + SetInstanceProgress(COSProgressStates(data), true); + break; + case DATA_ARTHAS_DIED: + // Respawn everything, then regress to last stable state + _arthasGUID = ObjectGuid::Empty; + SetInstanceProgress(GetStableStateFor(_currentState), true); + break; + case DATA_CRATES_START: + if (_currentState == JUST_STARTED) + SetInstanceProgress(CRATES_IN_PROGRESS, false); + break; + case DATA_CRATE_REVEALED: + if (uint32 missingCrates = MissingPlagueCrates()) + SetWorldState(WORLDSTATE_CRATES_REVEALED, NUM_PLAGUE_CRATES - missingCrates); + else + SetInstanceProgress(CRATES_DONE, false); + break; + case DATA_UTHER_FINISHED: + if (_currentState == UTHER_TALK) + SetInstanceProgress(PURGE_PENDING, false); + break; + case DATA_SKIP_TO_PURGE: + if (_currentState <= CRATES_DONE) + SetInstanceProgress(PURGE_PENDING, false); + break; + case DATA_START_WAVES: + if (_currentState == PURGE_STARTING) + SetInstanceProgress(WAVES_IN_PROGRESS, false); + break; + case DATA_REACH_TOWN_HALL: + if (_currentState == WAVES_DONE) + SetInstanceProgress(TOWN_HALL_PENDING, false); + break; + case DATA_TOWN_HALL_DONE: + if (_currentState == TOWN_HALL) + SetInstanceProgress(TOWN_HALL_COMPLETE, false); + break; + case DATA_GAUNTLET_REACHED: + if (_currentState == GAUNTLET_TRANSITION) + SetInstanceProgress(GAUNTLET_PENDING, false); + break; + case DATA_GAUNTLET_DONE: + if (_currentState == GAUNTLET_IN_PROGRESS) + SetInstanceProgress(GAUNTLET_COMPLETE, false); + break; + case DATA_MALGANIS_DONE: + if (_currentState == MALGANIS_IN_PROGRESS) + SetInstanceProgress(COMPLETE, false); + break; + default: + break; } + } - void SetData(uint32 type, uint32 data) override + void OnUnitDeath(Unit* unit) override + { + if (_currentState != WAVES_IN_PROGRESS || _waveSpawns.empty()) + return; + + // if this is a wave spawn... + auto it = _waveSpawns.find(unit->GetGUID()); + if (it == _waveSpawns.end()) + return; + + // ... then erase it from our list, then check if there are no more spawns alive... + _waveSpawns.erase(it); + if (!_waveSpawns.empty()) + return; + + // ... and if there are none, the wave is done and we progress + + // clear existing world markers + for (uint32 marker = WAVE_MARKER_MIN; marker <= WAVE_MARKER_MAX; ++marker) + SetWorldState(COSWorldStates(marker), 0, false); + PropagateWorldStateUpdate(); + + // schedule next wave if applicable + if (_waveCount < NUM_SCOURGE_WAVES) + events.ScheduleEvent(EVENT_SCOURGE_WAVE, (_waveCount == WAVE_MEATHOOK) ? 20s : 1s); + else + SetInstanceProgress(WAVES_DONE, false); + } + + void SetGuidData(uint32 type, ObjectGuid guid) override + { + switch (type) + { + case DATA_GM_RECALL: { - switch (type) + Creature* arthas = instance->GetCreature(_arthasGUID); + Position const& target = arthas ? arthas->GetPosition() : GetArthasSnapbackFor(_currentState); + + for (auto itr = instance->GetPlayers().begin(); itr != instance->GetPlayers().end(); ++itr) { - case DATA_GM_OVERRIDE: - SetInstanceProgress(COSProgressStates(data), true); - break; - case DATA_ARTHAS_DIED: - // Respawn everything, then regress to last stable state - _arthasGUID = ObjectGuid::Empty; - SetInstanceProgress(GetStableStateFor(_currentState), true); - break; - case DATA_CRATES_START: - if (_currentState == JUST_STARTED) - SetInstanceProgress(CRATES_IN_PROGRESS, false); - break; - case DATA_CRATE_REVEALED: - if (uint32 missingCrates = MissingPlagueCrates()) - SetWorldState(WORLDSTATE_CRATES_REVEALED, NUM_PLAGUE_CRATES - missingCrates); - else - SetInstanceProgress(CRATES_DONE, false); - break; - case DATA_UTHER_FINISHED: - if (_currentState == UTHER_TALK) - SetInstanceProgress(PURGE_PENDING, false); - break; - case DATA_SKIP_TO_PURGE: - if (_currentState <= CRATES_DONE) - SetInstanceProgress(PURGE_PENDING, false); - break; - case DATA_START_WAVES: - if (_currentState == PURGE_STARTING) - SetInstanceProgress(WAVES_IN_PROGRESS, false); - break; - case DATA_REACH_TOWN_HALL: - if (_currentState == WAVES_DONE) - SetInstanceProgress(TOWN_HALL_PENDING, false); - break; - case DATA_TOWN_HALL_DONE: - if (_currentState == TOWN_HALL) - SetInstanceProgress(TOWN_HALL_COMPLETE, false); - break; - case DATA_GAUNTLET_REACHED: - if (_currentState == GAUNTLET_TRANSITION) - SetInstanceProgress(GAUNTLET_PENDING, false); - break; - case DATA_GAUNTLET_DONE: - if (_currentState == GAUNTLET_IN_PROGRESS) - SetInstanceProgress(GAUNTLET_COMPLETE, false); - break; - case DATA_MALGANIS_DONE: - if (_currentState == MALGANIS_IN_PROGRESS) - SetInstanceProgress(COMPLETE, false); - break; - default: - break; + if (Player* player = itr->GetSource()) + if (player->GetGUID() == guid || !player->IsGameMaster()) + { + player->CombatStop(true); + const float offsetDist = 10; + float myAngle = rand_norm() * 2.0 * M_PI; + Position myTarget(target.GetPositionX() + std::sin(myAngle) * offsetDist, target.GetPositionY() + std::sin(myAngle) * offsetDist, target.GetPositionZ(), myAngle + M_PI); + player->NearTeleportTo(myTarget); + } } + break; } + case DATA_UTHER_START: + if (_currentState == CRATES_DONE) + SetInstanceProgress(UTHER_TALK, false); + break; + case DATA_START_PURGE: + InitiateArthasEvent(PURGE_PENDING, PURGE_STARTING, ACTION_START_RP_EVENT2, guid); + break; + case DATA_START_TOWN_HALL: + InitiateArthasEvent(TOWN_HALL_PENDING, TOWN_HALL, ACTION_START_RP_EVENT3, guid); + break; + case DATA_TO_GAUNTLET: + InitiateArthasEvent(TOWN_HALL_COMPLETE, GAUNTLET_TRANSITION, ACTION_START_RP_EVENT4_1, guid); + break; + case DATA_START_GAUNTLET: + InitiateArthasEvent(GAUNTLET_PENDING, GAUNTLET_IN_PROGRESS, ACTION_START_RP_EVENT4_2, guid); + break; + case DATA_START_MALGANIS: + InitiateArthasEvent(GAUNTLET_COMPLETE, MALGANIS_IN_PROGRESS, ACTION_START_RP_EVENT5, guid); + break; + default: + break; + } + } - void OnUnitDeath(Unit* unit) override - { - if (_currentState != WAVES_IN_PROGRESS || _waveSpawns.empty()) - return; - - // if this is a wave spawn... - auto it = _waveSpawns.find(unit->GetGUID()); - if (it == _waveSpawns.end()) - return; - - // ... then erase it from our list, then check if there are no more spawns alive... - _waveSpawns.erase(it); - if (!_waveSpawns.empty()) - return; + uint32 GetData(uint32 type) const override + { + if (type == DATA_INSTANCE_PROGRESS) + return _currentState; + return 0; + } - // ... and if there are none, the wave is done and we progress + bool SetBossState(uint32 type, EncounterState state) override + { + if (type == DATA_INFINITE_CORRUPTOR && state == DONE) + { + events.CancelEvent(EVENT_GUARDIAN_TICK); + SetWorldState(WORLDSTATE_TIME_GUARDIAN_SHOW, 0, false); + SetWorldState(WORLDSTATE_TIME_GUARDIAN, 0); + } - // clear existing world markers - for (uint32 marker = WAVE_MARKER_MIN; marker <= WAVE_MARKER_MAX; ++marker) - SetWorldState(COSWorldStates(marker), 0, false); - PropagateWorldStateUpdate(); + if (!InstanceScript::SetBossState(type, state)) + return false; - // schedule next wave if applicable - if (_waveCount < NUM_SCOURGE_WAVES) - events.ScheduleEvent(EVENT_SCOURGE_WAVE, (_waveCount == WAVE_MEATHOOK) ? 20s : 1s); - else - SetInstanceProgress(WAVES_DONE, false); - } + return true; + } - void SetGuidData(uint32 type, ObjectGuid guid) override + void Update(uint32 diff) override + { + events.Update(diff); + while (uint32 eventId = events.ExecuteEvent()) { - switch (type) + switch (eventId) { - case DATA_GM_RECALL: + case EVENT_GUARDIAN_TICK: // regular ticks at :00 seconds on the timer, and then at 04:30 remaining for the chromie whisper + { // we do the whisper as a guardian tick because i don't want to duplicate the real-time code + if (instance->GetSpawnMode() != DUNGEON_DIFFICULTY_HEROIC) + return; + + time_t secondsToGuardianDeath = _infiniteGuardianTimeout - GameTime::GetGameTime(); + if (secondsToGuardianDeath <= 0) { - Creature* arthas = instance->GetCreature(_arthasGUID); - Position const& target = arthas ? arthas->GetPosition() : GetArthasSnapbackFor(_currentState); + _infiniteGuardianTimeout = 0; + SetWorldState(WORLDSTATE_TIME_GUARDIAN_SHOW, 0, false); + SetWorldState(WORLDSTATE_TIME_GUARDIAN, 0); - for (auto itr = instance->GetPlayers().begin(); itr != instance->GetPlayers().end(); ++itr) + if (Creature* corruptor = instance->GetCreature(_corruptorGUID)) { - if (Player* player = itr->GetSource()) - if (player->GetGUID() == guid || !player->IsGameMaster()) - { - player->CombatStop(true); - const float offsetDist = 10; - float myAngle = rand_norm() * 2.0 * M_PI; - Position myTarget(target.GetPositionX() + std::sin(myAngle) * offsetDist, target.GetPositionY() + std::sin(myAngle) * offsetDist, target.GetPositionZ(), myAngle + M_PI); - player->NearTeleportTo(myTarget); - } + corruptor->AI()->DoAction(-ACTION_CORRUPTOR_LEAVE); + if (Creature* guardian = instance->GetCreature(_guardianGUID)) + Unit::Kill(corruptor, guardian); // @todo is there some spell for this? } - break; + SetBossState(DATA_INFINITE_CORRUPTOR, FAIL); } - case DATA_UTHER_START: - if (_currentState == CRATES_DONE) - SetInstanceProgress(UTHER_TALK, false); - break; - case DATA_START_PURGE: - InitiateArthasEvent(PURGE_PENDING, PURGE_STARTING, ACTION_START_RP_EVENT2, guid); - break; - case DATA_START_TOWN_HALL: - InitiateArthasEvent(TOWN_HALL_PENDING, TOWN_HALL, ACTION_START_RP_EVENT3, guid); - break; - case DATA_TO_GAUNTLET: - InitiateArthasEvent(TOWN_HALL_COMPLETE, GAUNTLET_TRANSITION, ACTION_START_RP_EVENT4_1, guid); + else + { + time_t minutes = (secondsToGuardianDeath - 1) / MINUTE; + time_t seconds = ((secondsToGuardianDeath - 1) % MINUTE) + 1; + + // chromie whispers - we only ever tick at :00 and :30, but give some leeway in case of slow tick rate + if (minutes == 24 && seconds >= 45) + if (Creature* chromie = instance->GetCreature(_chromieGUID)) + chromie->AI()->Talk(CHROMIE_WHISPER_GUARDIAN_1); + if (minutes == 4 && seconds < 45) + if (Creature* chromie = instance->GetCreature(_chromieGUID)) + chromie->AI()->Talk(CHROMIE_WHISPER_GUARDIAN_2); + if (minutes == 0) + if (Creature* chromie = instance->GetCreature(_chromieGUID)) + chromie->AI()->Talk(CHROMIE_WHISPER_GUARDIAN_3); + + // update the timer state + SetWorldState(WORLDSTATE_TIME_GUARDIAN_SHOW, 1, false); + SetWorldState(WORLDSTATE_TIME_GUARDIAN, minutes + 1); + if (minutes == 4 && seconds > 30) + events.Repeat(Seconds(seconds - 30)); + else + events.Repeat(Seconds(seconds)); + } + break; + } + case EVENT_RESPAWN_ARTHAS: + LOG_DEBUG("scripts.cos", "instance_culling_of_stratholme::Update: Spawning new Arthas for instance..."); + instance->SummonCreature(NPC_ARTHAS, GetArthasSnapbackFor(_currentState)); + events.CancelEvent(EVENT_RESPAWN_ARTHAS); // make sure we don't have two scheduled + break; + case EVENT_CRIER_CALL_TO_GATES: + if (_currentState == CRATES_DONE) + if (Creature* crier = instance->GetCreature(_crierGUID)) + crier->AI()->Talk(CRIER_SAY_CALL_TO_GATES); + break; + case EVENT_SCOURGE_WAVE: + { + if (_currentState != WAVES_IN_PROGRESS) break; - case DATA_START_GAUNTLET: - InitiateArthasEvent(GAUNTLET_PENDING, GAUNTLET_IN_PROGRESS, ACTION_START_RP_EVENT4_2, guid); + + ++_waveCount; + SetWorldState(WORLDSTATE_WAVE_COUNT, _waveCount); + + uint8 spawnLoc = urand(WAVE_LOC_MIN, WAVE_LOC_MAX); + while (spawnLoc == _currentSpawnLoc) // don't allow repeats + spawnLoc = urand(WAVE_LOC_MIN, WAVE_LOC_MAX); + WaveLocation const& spawnLocation = WaveLocations[spawnLoc - WAVE_LOC_MIN]; + + switch (_waveCount) + { + case WAVE_MEATHOOK: + if (Creature* spawn = instance->SummonCreature(NPC_MEATHOOK, spawnLocation.SpawnPoints[0])) + _waveSpawns.insert(spawn->GetGUID()); break; - case DATA_START_MALGANIS: - InitiateArthasEvent(GAUNTLET_COMPLETE, MALGANIS_IN_PROGRESS, ACTION_START_RP_EVENT5, guid); + case WAVE_SALRAMM: + if (Creature* spawn = instance->SummonCreature(NPC_SALRAMM, spawnLocation.SpawnPoints[0])) + _waveSpawns.insert(spawn->GetGUID()); break; default: + if (instance->GetSpawnMode() == DUNGEON_DIFFICULTY_HEROIC) + { + for (uint32 i = 0; i < MAX_SPAWNS_PER_WAVE; ++i) + if (uint32 entry = HeroicWaves[_waveCount - 1][i]) + if (Creature* spawn = instance->SummonCreature(entry, spawnLocation.SpawnPoints[i])) + _waveSpawns.insert(spawn->GetGUID()); + } + else + { + for (uint32 i = 0; i <= 1; ++i) + if (Creature* spawn = instance->SummonCreature(NPC_DEVOURING_GHOUL, spawnLocation.SpawnPoints[i])) + _waveSpawns.insert(spawn->GetGUID()); + } break; + } + + for (uint32 marker = WAVE_MARKER_MIN; marker <= WAVE_MARKER_MAX; ++marker) + SetWorldState(COSWorldStates(marker), 0, false); + SetWorldState(spawnLocation.WorldState, 1); + + events.RescheduleEvent(EVENT_CRIER_ANNOUNCE_WAVE, 2s); + _currentSpawnLoc = spawnLoc; + break; + } + case EVENT_CRIER_ANNOUNCE_WAVE: + if (_currentState == WAVES_IN_PROGRESS) + if (Creature* crier = instance->GetCreature(_crierGUID)) + crier->AI()->Talk(_currentSpawnLoc); + break; + default: + break; } } + } - uint32 GetData(uint32 type) const override + void OnCreatureCreate(Creature* creature) override + { + switch (creature->GetEntry()) { - if (type == DATA_INSTANCE_PROGRESS) - return _currentState; - return 0; + case NPC_CHROMIE: + _chromieGUID = creature->GetGUID(); + creature->setActive(true); + break; + case NPC_INFINITE_CORRUPTOR: + _corruptorGUID = creature->GetGUID(); + creature->setActive(true); + break; + case NPC_GUARDIAN_OF_TIME: + _guardianGUID = creature->GetGUID(); + creature->setActive(true); + break; + case NPC_GENERIC_BUNNY: + _genericBunnyGUID = creature->GetGUID(); + creature->setActive(true); + break; + case NPC_CRATE_HELPER: + _plagueCrates.push_back(creature->GetGUID()); + break; + case NPC_ARTHAS: + LOG_DEBUG("scripts.cos", "instance_culling_of_stratholme::OnCreatureCreate: Arthas spawned at %s", creature->GetPosition().ToString().c_str()); + _arthasGUID = creature->GetGUID(); + creature->setActive(true); + break; + case NPC_LORDAERON_CRIER: + _crierGUID = creature->GetGUID(); + creature->setActive(true); + break; + default: + break; } + } - bool SetBossState(uint32 type, EncounterState state) override + void OnGameObjectCreate(GameObject* object) override + { + switch (object->GetEntry()) { - if (type == DATA_INFINITE_CORRUPTOR && state == DONE) - { - events.CancelEvent(EVENT_GUARDIAN_TICK); - SetWorldState(WORLDSTATE_TIME_GUARDIAN_SHOW, 0, false); - SetWorldState(WORLDSTATE_TIME_GUARDIAN, 0); - } - - if (!InstanceScript::SetBossState(type, state)) - return false; - - return true; + case GO_HIDDEN_PASSAGE: + _passageGUID = object->GetGUID(); + object->setActive(true); + object->SetGoState(_currentState <= GAUNTLET_TRANSITION ? GO_STATE_READY : GO_STATE_ACTIVE); + break; + default: + break; } + } - void Update(uint32 diff) override - { - events.Update(diff); - while (uint32 eventId = events.ExecuteEvent()) + void InitiateArthasEvent(COSProgressStates fromState, COSProgressStates toState, COSInstanceActions startAction, ObjectGuid starterGUID) + { + if (_currentState != fromState) + return; + SetInstanceProgress(toState, false); + if (Creature* arthas = instance->GetCreature(_arthasGUID)) + arthas->AI()->SetGUID(starterGUID, -startAction); + } + + void SetInstanceProgress(COSProgressStates state, bool force) + { + LOG_DEBUG("scripts.cos", "instance_culling_of_stratholme::SetInstanceProgress: Instance progress is now 0x%X", (uint32)state); + _currentState = state; + + /* Spawn group management */ + SetSpawnGroupState(SPAWNGRP_CHROMIE_MID, (state >= CRATES_DONE), force); + SetSpawnGroupState(SPAWNGRP_CRATE_HELPERS, (state == CRATES_IN_PROGRESS || state == CRATES_DONE), true); + SetSpawnGroupState(SPAWNGRP_GAUNTLET_TRASH, (state == WAVES_IN_PROGRESS), force); + SetSpawnGroupState(SPAWNGRP_UNDEAD_TRASH, (state >= WAVES_IN_PROGRESS && state < GAUNTLET_COMPLETE), force); + SetSpawnGroupState(SPAWNGRP_RESIDENTS, (state < WAVES_IN_PROGRESS), true); + + /* Arthas management */ + if (state > CRATES_DONE) + { // there might be an Arthas instance in the dungeon somewhere + // notify him of the change so he can adjust + Creature* arthas = instance->GetCreature(_arthasGUID); + if (arthas) { - switch (eventId) + if (force) { - case EVENT_GUARDIAN_TICK: // regular ticks at :00 seconds on the timer, and then at 04:30 remaining for the chromie whisper - { // we do the whisper as a guardian tick because i don't want to duplicate the real-time code - if (instance->GetSpawnMode() != DUNGEON_DIFFICULTY_HEROIC) - return; - - time_t secondsToGuardianDeath = _infiniteGuardianTimeout - GameTime::GetGameTime(); - if (secondsToGuardianDeath <= 0) - { - _infiniteGuardianTimeout = 0; - SetWorldState(WORLDSTATE_TIME_GUARDIAN_SHOW, 0, false); - SetWorldState(WORLDSTATE_TIME_GUARDIAN, 0); - - if (Creature* corruptor = instance->GetCreature(_corruptorGUID)) - { - corruptor->AI()->DoAction(-ACTION_CORRUPTOR_LEAVE); - if (Creature* guardian = instance->GetCreature(_guardianGUID)) - corruptor->Kill(guardian); // @todo is there some spell for this? - } - SetBossState(DATA_INFINITE_CORRUPTOR, FAIL); - } - else - { - time_t minutes = (secondsToGuardianDeath - 1) / MINUTE; - time_t seconds = ((secondsToGuardianDeath - 1) % MINUTE) + 1; - - // chromie whispers - we only ever tick at :00 and :30, but give some leeway in case of slow tick rate - if (minutes == 24 && seconds >= 45) - if (Creature* chromie = instance->GetCreature(_chromieGUID)) - chromie->AI()->Talk(CHROMIE_WHISPER_GUARDIAN_1); - if (minutes == 4 && seconds < 45) - if (Creature* chromie = instance->GetCreature(_chromieGUID)) - chromie->AI()->Talk(CHROMIE_WHISPER_GUARDIAN_2); - if (minutes == 0) - if (Creature* chromie = instance->GetCreature(_chromieGUID)) - chromie->AI()->Talk(CHROMIE_WHISPER_GUARDIAN_3); - - // update the timer state - SetWorldState(WORLDSTATE_TIME_GUARDIAN_SHOW, 1, false); - SetWorldState(WORLDSTATE_TIME_GUARDIAN, minutes + 1); - if (minutes == 4 && seconds > 30) - events.Repeat(Seconds(seconds - 30)); - else - events.Repeat(Seconds(seconds)); - } - break; - } - case EVENT_RESPAWN_ARTHAS: - LOG_DEBUG("scripts.cos", "instance_culling_of_stratholme::Update: Spawning new Arthas for instance..."); - instance->SummonCreature(NPC_ARTHAS, GetArthasSnapbackFor(_currentState)); - events.CancelEvent(EVENT_RESPAWN_ARTHAS); // make sure we don't have two scheduled - break; - case EVENT_CRIER_CALL_TO_GATES: - if (_currentState == CRATES_DONE) - if (Creature* crier = instance->GetCreature(_crierGUID)) - crier->AI()->Talk(CRIER_SAY_CALL_TO_GATES); - break; - case EVENT_SCOURGE_WAVE: - { - if (_currentState != WAVES_IN_PROGRESS) - break; - - ++_waveCount; - SetWorldState(WORLDSTATE_WAVE_COUNT, _waveCount); - - uint8 spawnLoc = urand(WAVE_LOC_MIN, WAVE_LOC_MAX); - while (spawnLoc == _currentSpawnLoc) // don't allow repeats - spawnLoc = urand(WAVE_LOC_MIN, WAVE_LOC_MAX); - WaveLocation const& spawnLocation = WaveLocations[spawnLoc - WAVE_LOC_MIN]; - - switch (_waveCount) - { - case WAVE_MEATHOOK: - if (Creature* spawn = instance->SummonCreature(NPC_MEATHOOK, spawnLocation.SpawnPoints[0])) - _waveSpawns.insert(spawn->GetGUID()); - break; - case WAVE_SALRAMM: - if (Creature* spawn = instance->SummonCreature(NPC_SALRAMM, spawnLocation.SpawnPoints[0])) - _waveSpawns.insert(spawn->GetGUID()); - break; - default: - if (instance->GetSpawnMode() == DUNGEON_DIFFICULTY_HEROIC) - { - for (uint32 i = 0; i < MAX_SPAWNS_PER_WAVE; ++i) - if (uint32 entry = HeroicWaves[_waveCount - 1][i]) - if (Creature* spawn = instance->SummonCreature(entry, spawnLocation.SpawnPoints[i])) - _waveSpawns.insert(spawn->GetGUID()); - } - else - { - for (uint32 i = 0; i <= 1; ++i) - if (Creature* spawn = instance->SummonCreature(NPC_DEVOURING_GHOUL, spawnLocation.SpawnPoints[i])) - _waveSpawns.insert(spawn->GetGUID()); - } - break; - } - - for (uint32 marker = WAVE_MARKER_MIN; marker <= WAVE_MARKER_MAX; ++marker) - SetWorldState(COSWorldStates(marker), 0, false); - SetWorldState(spawnLocation.WorldState, 1); - - events.RescheduleEvent(EVENT_CRIER_ANNOUNCE_WAVE, 2s); - _currentSpawnLoc = spawnLoc; - break; - } - case EVENT_CRIER_ANNOUNCE_WAVE: - if (_currentState == WAVES_IN_PROGRESS) - if (Creature* crier = instance->GetCreature(_crierGUID)) - crier->AI()->Talk(_currentSpawnLoc); - break; - default: - break; + arthas->DespawnOrUnsummon(); + arthas = nullptr; } + else + arthas->AI()->DoAction(-ACTION_PROGRESS_UPDATE); } + + if (!arthas) // if there is currently no arthas, then we need to spawn one + events.ScheduleEvent(EVENT_RESPAWN_ARTHAS, 1s); } + else if (Creature* arthas = instance->GetCreature(_arthasGUID)) // there shouldn't be any Arthas around + arthas->DespawnOrUnsummon(); - void OnCreatureCreate(Creature* creature) override + /* World state management */ + // Plague crates + if (state == CRATES_IN_PROGRESS) { - switch (creature->GetEntry()) - { - case NPC_CHROMIE: - _chromieGUID = creature->GetGUID(); - creature->setActive(true); - break; - case NPC_INFINITE_CORRUPTOR: - _corruptorGUID = creature->GetGUID(); - creature->setActive(true); - break; - case NPC_GUARDIAN_OF_TIME: - _guardianGUID = creature->GetGUID(); - creature->setActive(true); - break; - case NPC_GENERIC_BUNNY: - _genericBunnyGUID = creature->GetGUID(); - creature->setActive(true); - break; - case NPC_CRATE_HELPER: - _plagueCrates.push_back(creature->GetGUID()); - break; - case NPC_ARTHAS: - LOG_DEBUG("scripts.cos", "instance_culling_of_stratholme::OnCreatureCreate: Arthas spawned at %s", creature->GetPosition().ToString().c_str()); - _arthasGUID = creature->GetGUID(); - creature->setActive(true); - break; - case NPC_LORDAERON_CRIER: - _crierGUID = creature->GetGUID(); - creature->setActive(true); - break; - default: - break; - } + SetWorldState(WORLDSTATE_SHOW_CRATES, 1, false); + SetWorldState(WORLDSTATE_CRATES_REVEALED, 0, false); } - - void OnGameObjectCreate(GameObject* object) override + else if (state == CRATES_DONE) { - switch (object->GetEntry()) - { - case GO_HIDDEN_PASSAGE: - _passageGUID = object->GetGUID(); - object->setActive(true); - object->SetGoState(_currentState <= GAUNTLET_TRANSITION ? GO_STATE_READY : GO_STATE_ACTIVE); - break; - default: - break; - } + SetWorldState(WORLDSTATE_SHOW_CRATES, 1, false); + SetWorldState(WORLDSTATE_CRATES_REVEALED, NUM_PLAGUE_CRATES, false); + } + else + { + SetWorldState(WORLDSTATE_SHOW_CRATES, 0, false); + SetWorldState(WORLDSTATE_CRATES_REVEALED, state == JUST_STARTED ? 0 : NUM_PLAGUE_CRATES, false); } + // Scourge wave counter + if (state == WAVES_DONE) + SetWorldState(WORLDSTATE_WAVE_COUNT, NUM_SCOURGE_WAVES, false); + else + SetWorldState(WORLDSTATE_WAVE_COUNT, 0, false); + + PropagateWorldStateUpdate(); - void InitiateArthasEvent(COSProgressStates fromState, COSProgressStates toState, COSInstanceActions startAction, ObjectGuid starterGUID) + // Hidden Passage status handling + if (GameObject* passage = instance->GetGameObject(_passageGUID)) + passage->SetGoState(state <= GAUNTLET_TRANSITION ? GO_STATE_READY : GO_STATE_ACTIVE); + + switch (state) { - if (_currentState != fromState) - return; - SetInstanceProgress(toState, false); - if (Creature* arthas = instance->GetCreature(_arthasGUID)) - arthas->AI()->SetGUID(starterGUID, -startAction); + case CRATES_DONE: + if (Creature* bunny = instance->GetCreature(_genericBunnyGUID)) + bunny->CastSpell(nullptr, SPELL_CRATES_KILL_CREDIT, TRIGGERED_FULL_MASK); + events.ScheduleEvent(EVENT_CRIER_CALL_TO_GATES, 5s); + break; + case WAVES_IN_PROGRESS: + _waveCount = 0; + _currentSpawnLoc = 0; + _waveSpawns.clear(); + events.ScheduleEvent(EVENT_SCOURGE_WAVE, 1s); + SpawnInfiniteCorruptor(); + break; + default: + break; } - void SetInstanceProgress(COSProgressStates state, bool force) + if (force) { - LOG_DEBUG("scripts.cos", "instance_culling_of_stratholme::SetInstanceProgress: Instance progress is now 0x%X", (uint32)state); - _currentState = state; - - /* Spawn group management */ - SetSpawnGroupState(SPAWNGRP_CHROMIE_MID, (state >= CRATES_DONE), force); - SetSpawnGroupState(SPAWNGRP_CRATE_HELPERS, (state == CRATES_IN_PROGRESS || state == CRATES_DONE), true); - SetSpawnGroupState(SPAWNGRP_GAUNTLET_TRASH, (state == WAVES_IN_PROGRESS), force); - SetSpawnGroupState(SPAWNGRP_UNDEAD_TRASH, (state >= WAVES_IN_PROGRESS && state < GAUNTLET_COMPLETE), force); - SetSpawnGroupState(SPAWNGRP_RESIDENTS, (state < WAVES_IN_PROGRESS), true); - - /* Arthas management */ - if (state > CRATES_DONE) - { // there might be an Arthas instance in the dungeon somewhere - // notify him of the change so he can adjust - Creature* arthas = instance->GetCreature(_arthasGUID); - if (arthas) + // Forced transitions are regressions (event failures) or GM overrides; respawn all dead creatures, and despawn any temporary summons + events.Reset(); + instance->DeleteRespawnTimes(); + + // Reset respawn time on all permanent spawns, despawn all temporary spawns + // @todo dynspawn, this won't work + std::vector toDespawn; + std::unordered_map const& objects = instance->GetObjectsStore().GetElements()._elements._element; + for (std::unordered_map::const_iterator itr = objects.cbegin(); itr != objects.cend(); ++itr) + { + if (itr->second && (itr->second->isDead() || !itr->second->GetSpawnId() || itr->second->GetOriginalEntry() != itr->second->GetEntry())) { - if (force) - { - arthas->DespawnOrUnsummon(); - arthas = nullptr; - } + if (itr->second->getDeathState() == DEAD) // despawned, not corpse + itr->second->SetRespawnTime(1); else - arthas->AI()->DoAction(-ACTION_PROGRESS_UPDATE); + toDespawn.push_back(itr->second); } - - if (!arthas) // if there is currently no arthas, then we need to spawn one - events.ScheduleEvent(EVENT_RESPAWN_ARTHAS, 1s); } - else if (Creature* arthas = instance->GetCreature(_arthasGUID)) // there shouldn't be any Arthas around - arthas->DespawnOrUnsummon(); - /* World state management */ - // Plague crates - if (state == CRATES_IN_PROGRESS) + for (Creature* creature : toDespawn) { - SetWorldState(WORLDSTATE_SHOW_CRATES, 1, false); - SetWorldState(WORLDSTATE_CRATES_REVEALED, 0, false); + if (creature->GetSpawnId()) + creature->SetRespawnTime(1); + creature->DespawnOrUnsummon(0, 1s); } - else if (state == CRATES_DONE) - { - SetWorldState(WORLDSTATE_SHOW_CRATES, 1, false); - SetWorldState(WORLDSTATE_CRATES_REVEALED, NUM_PLAGUE_CRATES, false); - } - else - { - SetWorldState(WORLDSTATE_SHOW_CRATES, 0, false); - SetWorldState(WORLDSTATE_CRATES_REVEALED, state == JUST_STARTED ? 0 : NUM_PLAGUE_CRATES, false); - } - // Scourge wave counter - if (state == WAVES_DONE) - SetWorldState(WORLDSTATE_WAVE_COUNT, NUM_SCOURGE_WAVES, false); - else - SetWorldState(WORLDSTATE_WAVE_COUNT, 0, false); - - PropagateWorldStateUpdate(); - - // Hidden Passage status handling - if (GameObject* passage = instance->GetGameObject(_passageGUID)) - passage->SetGoState(state <= GAUNTLET_TRANSITION ? GO_STATE_READY : GO_STATE_ACTIVE); - - switch (state) - { - case CRATES_DONE: - if (Creature* bunny = instance->GetCreature(_genericBunnyGUID)) - bunny->CastSpell(nullptr, SPELL_CRATES_KILL_CREDIT, TRIGGERED_FULL_MASK); - events.ScheduleEvent(EVENT_CRIER_CALL_TO_GATES, 5s); - break; - case WAVES_IN_PROGRESS: - _waveCount = 0; - _currentSpawnLoc = 0; - _waveSpawns.clear(); - events.ScheduleEvent(EVENT_SCOURGE_WAVE, 1s); - SpawnInfiniteCorruptor(); - break; - default: - break; - } - - if (force) - { - // Forced transitions are regressions (event failures) or GM overrides; respawn all dead creatures, and despawn any temporary summons - events.Reset(); - instance->DeleteRespawnTimes(); - - // Reset respawn time on all permanent spawns, despawn all temporary spawns - // @todo dynspawn, this won't work - std::vector toDespawn; - std::unordered_map const& objects = instance->GetObjectsStore().GetElements()._elements._element; - for (std::unordered_map::const_iterator itr = objects.cbegin(); itr != objects.cend(); ++itr) - { - if (itr->second && (itr->second->isDead() || !itr->second->GetSpawnId() || itr->second->GetOriginalEntry() != itr->second->GetEntry())) - { - if (itr->second->getDeathState() == DEAD) // despawned, not corpse - itr->second->SetRespawnTime(1); - else - toDespawn.push_back(itr->second); - } - } - - for (Creature* creature : toDespawn) - { - if (creature->GetSpawnId()) - creature->SetRespawnTime(1); - creature->DespawnOrUnsummon(0, 1s); - } - SpawnInfiniteCorruptor(); - events.RescheduleEvent(EVENT_RESPAWN_ARTHAS, 1s); - } - - SaveToDB(); + SpawnInfiniteCorruptor(); + events.RescheduleEvent(EVENT_RESPAWN_ARTHAS, 1s); } - private: - typedef std::unordered_map WorldStateMap; + SaveToDB(); + } - uint32 MissingPlagueCrates() const - { - uint32 returnValue = 0; - for (ObjectGuid const& crateHelperGUID : _plagueCrates) - if (Creature* crateHelper = instance->GetCreature(crateHelperGUID)) - if (crateHelper->IsAlive() && !crateHelper->AI()->GetData(DATA_CRATE_REVEALED)) - ++returnValue; - return returnValue; - } + private: + typedef std::unordered_map WorldStateMap; - void SpawnInfiniteCorruptor() - { - if (!_infiniteGuardianTimeout && instance->GetSpawnMode() == DUNGEON_DIFFICULTY_HEROIC && (GetBossState(DATA_INFINITE_CORRUPTOR) != DONE && GetBossState(DATA_INFINITE_CORRUPTOR) != FAIL)) - { - instance->SummonCreature(NPC_TIME_RIFT, CorruptorRiftPos); - instance->SummonCreature(NPC_GUARDIAN_OF_TIME, GuardianPos); - instance->SummonCreature(NPC_INFINITE_CORRUPTOR, CorruptorPos); - _infiniteGuardianTimeout = GameTime::GetGameTime() + 25 * MINUTE; - events.ScheduleEvent(EVENT_GUARDIAN_TICK, 6s); - } - } + uint32 MissingPlagueCrates() const + { + uint32 returnValue = 0; + for (ObjectGuid const& crateHelperGUID : _plagueCrates) + if (Creature* crateHelper = instance->GetCreature(crateHelperGUID)) + if (crateHelper->IsAlive() && !crateHelper->AI()->GetData(DATA_CRATE_REVEALED)) + ++returnValue; + return returnValue; + } - void SetWorldState(COSWorldStates state, uint32 value, bool immediate = true) + void SpawnInfiniteCorruptor() + { + if (!_infiniteGuardianTimeout && instance->GetSpawnMode() == DUNGEON_DIFFICULTY_HEROIC && (GetBossState(DATA_INFINITE_CORRUPTOR) != DONE && GetBossState(DATA_INFINITE_CORRUPTOR) != FAIL)) { - LOG_DEBUG("scripts.cos", "instance_culling_of_stratholme::SetWorldState: %u %u", uint32(state), value); - _currentWorldStates[state] = value; - if (immediate) - PropagateWorldStateUpdate(); + instance->SummonCreature(NPC_TIME_RIFT, CorruptorRiftPos); + instance->SummonCreature(NPC_GUARDIAN_OF_TIME, GuardianPos); + instance->SummonCreature(NPC_INFINITE_CORRUPTOR, CorruptorPos); + _infiniteGuardianTimeout = GameTime::GetGameTime() + 25 * MINUTE; + events.ScheduleEvent(EVENT_GUARDIAN_TICK, 6s); } + } + + void SetWorldState(COSWorldStates state, uint32 value, bool immediate = true) + { + LOG_DEBUG("scripts.cos", "instance_culling_of_stratholme::SetWorldState: %u %u", uint32(state), value); + _currentWorldStates[state] = value; + if (immediate) + PropagateWorldStateUpdate(); + } - void PropagateWorldStateUpdate() + void PropagateWorldStateUpdate() + { + LOG_DEBUG("scripts.cos", "instance_culling_of_stratholme::PropagateWorldStateUpdate: Propagate world states"); + for (WorldStateMap::const_iterator it = _currentWorldStates.begin(); it != _currentWorldStates.end(); ++it) { - LOG_DEBUG("scripts.cos", "instance_culling_of_stratholme::PropagateWorldStateUpdate: Propagate world states"); - for (WorldStateMap::const_iterator it = _currentWorldStates.begin(); it != _currentWorldStates.end(); ++it) + uint32& sent = _sentWorldStates[it->first]; + if (sent != it->second) { - uint32& sent = _sentWorldStates[it->first]; - if (sent != it->second) - { - LOG_DEBUG("scripts.cos", "instance_culling_of_stratholme::PropagateWorldStateUpdate: Sending world state %u (%u)", it->first, it->second); - DoUpdateWorldState(it->first, it->second); - sent = it->second; - } + LOG_DEBUG("scripts.cos", "instance_culling_of_stratholme::PropagateWorldStateUpdate: Sending world state %u (%u)", it->first, it->second); + DoUpdateWorldState(it->first, it->second); + sent = it->second; } } + } - void SetSpawnGroupState(COSInstanceEntries group, bool state, bool force) - { - if (state) - instance->SpawnGroupSpawn(group, true); - else if (force) - instance->SpawnGroupDespawn(group, true); - else - instance->SetSpawnGroupInactive(group); - } + void SetSpawnGroupState(COSInstanceEntries group, bool state, bool force) + { + if (state) + instance->SpawnGroupSpawn(group, true); + else if (force) + instance->SpawnGroupDespawn(group, true); + else + instance->SetSpawnGroupInactive(group); + } - EventMap events; - COSProgressStates _currentState; - WorldStateMap _sentWorldStates; - WorldStateMap _currentWorldStates; - time_t _infiniteGuardianTimeout; + EventMap events; + COSProgressStates _currentState; + WorldStateMap _sentWorldStates; + WorldStateMap _currentWorldStates; + time_t _infiniteGuardianTimeout; - // Generic - ObjectGuid _chromieGUID; - ObjectGuid _corruptorGUID; - ObjectGuid _guardianGUID; - ObjectGuid _genericBunnyGUID; - std::vector _plagueCrates; + // Generic + ObjectGuid _chromieGUID; + ObjectGuid _corruptorGUID; + ObjectGuid _guardianGUID; + ObjectGuid _genericBunnyGUID; + std::vector _plagueCrates; - ObjectGuid _arthasGUID; - ObjectGuid _crierGUID; + ObjectGuid _arthasGUID; + ObjectGuid _crierGUID; - // Scourge Waves - uint32 _waveCount; - uint8 _currentSpawnLoc; - std::unordered_set _waveSpawns; + // Scourge Waves + uint32 _waveCount; + uint8 _currentSpawnLoc; + std::unordered_set _waveSpawns; - // Gauntlet - ObjectGuid _passageGUID; - }; + // Gauntlet + ObjectGuid _passageGUID; + }; - InstanceScript* GetInstanceScript(InstanceMap* map) const override - { - return new instance_culling_of_stratholme_InstanceMapScript(map); - } + InstanceScript* GetInstanceScript(InstanceMap* map) const override + { + return new instance_culling_of_stratholme_InstanceMapScript(map); + } }; void AddSC_instance_culling_of_stratholme() diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/npc_arthas.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/npc_arthas.cpp index 4c046543..8c30aed9 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/npc_arthas.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/npc_arthas.cpp @@ -15,7 +15,6 @@ * with this program. If not, see . */ -#include "culling_of_stratholme.h" #include "GameObject.h" #include "InstanceScript.h" #include "Log.h" @@ -26,83 +25,84 @@ #include "PassiveAI.h" #include "Player.h" #include "Random.h" -#include "ScriptedCreature.h" -#include "ScriptedGossip.h" #include "ScriptMgr.h" #include "ScriptSystem.h" +#include "ScriptedCreature.h" +#include "ScriptedGossip.h" #include "SpellInfo.h" #include "SpellScript.h" #include "SplineChainMovementGenerator.h" #include "TemporarySummon.h" +#include "culling_of_stratholme.h" #include #include #include enum Entries { - NPC_MALGANIS_BUNNY = 20562, - NPC_UTHER = 26528, - NPC_JAINA = 26497, - NPC_CITIZEN = 28167, - NPC_RESIDENT = 28169, - NPC_FOOTMAN = 27745, - NPC_KNIGHT = 27746, - NPC_PRIEST = 27747, - NPC_SORCERESS = 27752, - NPC_RISEN_ZOMBIE = 27737, - NPC_CITIZEN_INFINITE = 28340, - NPC_RESIDENT_INFINITE = 28341, - NPC_TIME_RIFT = 28409, - NPC_TIME_RIFT_LARGE = 28439, - NPC_INFINITE_ADVERSARY = 27742, - NPC_INFINITE_HUNTER = 27743, - NPC_INFINITE_AGENT = 27744, - NPC_EPOCH = 26532, - NPC_MALGANIS = 26533, - NPC_CHROMIE_3 = 30997, - - SPELL_HOLY_LIGHT = 52444, - SPELL_EXORCISM = 52445, - SPELL_DEVOTION_AURA = 52442, - SPELL_CRUSADER_STRIKE = 50773, - SPELL_SHADOWSTEP_VISUAL = 51908, - SPELL_TRANSFORM_VISUAL = 33133, + NPC_MALGANIS_BUNNY = 20562, + NPC_UTHER = 26528, + NPC_JAINA = 26497, + NPC_CITIZEN = 28167, + NPC_RESIDENT = 28169, + NPC_FOOTMAN = 27745, + NPC_KNIGHT = 27746, + NPC_PRIEST = 27747, + NPC_SORCERESS = 27752, + NPC_RISEN_ZOMBIE = 27737, + NPC_CITIZEN_INFINITE = 28340, + NPC_RESIDENT_INFINITE = 28341, + NPC_TIME_RIFT = 28409, + NPC_TIME_RIFT_LARGE = 28439, + NPC_INFINITE_ADVERSARY = 27742, + NPC_INFINITE_HUNTER = 27743, + NPC_INFINITE_AGENT = 27744, + NPC_EPOCH = 26532, + NPC_MALGANIS = 26533, + NPC_CHROMIE_3 = 30997, + + SPELL_HOLY_LIGHT = 52444, + SPELL_EXORCISM = 52445, + SPELL_DEVOTION_AURA = 52442, + SPELL_CRUSADER_STRIKE = 50773, + SPELL_SHADOWSTEP_VISUAL = 51908, + SPELL_TRANSFORM_VISUAL = 33133, SPELL_MALGANIS_QUEST_CREDIT = 58124, - SPELL_MALGANIS_KILL_CREDIT = 58630, - SPELL_CHROMIE_3_TRANSFORM = 58986, - GO_CHEST_NORMAL = 190663, - GO_CHEST_HEROIC = 193597 + SPELL_MALGANIS_KILL_CREDIT = 58630, + SPELL_CHROMIE_3_TRANSFORM = 58986, + GO_CHEST_NORMAL = 190663, + GO_CHEST_HEROIC = 193597 }; enum SplineChains { // RP1: Arthas/Jaina/Uther, outside Stratholme gates - RP1_CHAIN_ARTHAS1 = 1, // Initial movement - RP1_CHAIN_UTHER1 = 1, // Initial movement - RP1_CHAIN_JAINA1 = 1, // Initial movement - RP1_CHAIN_ARTHAS2 = 2, // Arthas moves up the hill to look out over Stratholme - RP1_CHAIN_UTHER2 = 2, // Uther follows - RP1_CHAIN_JAINA2 = 2, // Jaina follows - RP1_CHAIN_UTHER3 = 3, // Uther leaves - RP1_CHAIN_JAINA3 = 3, // Jaina turns to leave, but is stopped by Arthas - RP1_CHAIN_JAINA4 = 4, // Jaina leaves for real - RP1_CHAIN_ARTHAS3 = 3, // Arthas moves down the hill to the bridge - RP1_CHAIN_ARTHAS4 = 4, // Arthas moves to the Stratholme entrance + RP1_CHAIN_ARTHAS1 = 1, // Initial movement + RP1_CHAIN_UTHER1 = 1, // Initial movement + RP1_CHAIN_JAINA1 = 1, // Initial movement + RP1_CHAIN_ARTHAS2 = 2, // Arthas moves up the hill to look out over Stratholme + RP1_CHAIN_UTHER2 = 2, // Uther follows + RP1_CHAIN_JAINA2 = 2, // Jaina follows + RP1_CHAIN_UTHER3 = 3, // Uther leaves + RP1_CHAIN_JAINA3 = 3, // Jaina turns to leave, but is stopped by Arthas + RP1_CHAIN_JAINA4 = 4, // Jaina leaves for real + RP1_CHAIN_ARTHAS3 = 3, // Arthas moves down the hill to the bridge + RP1_CHAIN_ARTHAS4 = 4, // Arthas moves to the Stratholme entrance // RP2: Arthas/Mal'ganis, at Stratholme gates - RP2_CHAIN_ARTHAS1 = 5, // Arthas enters Stratholme proper - RP2_CHAIN_CITIZEN1 = 1, // A Stratholme citizen greets Arthas - RP2_CHAIN_ARTHAS2 = 6, // Arthas advances towards the approaching citizen - RP2_CHAIN_ARTHAS3 = 7, // Arthas moves on to a nearby resident + RP2_CHAIN_ARTHAS1 = 5, // Arthas enters Stratholme proper + RP2_CHAIN_CITIZEN1 = 1, // A Stratholme citizen greets Arthas + RP2_CHAIN_ARTHAS2 = 6, // Arthas advances towards the approaching citizen + RP2_CHAIN_ARTHAS3 = 7, // Arthas moves on to a nearby resident // RP3: Arthas/Infinites, in Stratholme Town Hall - RP3_CHAIN_ARTHAS1 = 91, // Arthas enters Stratholme Town Hall - RP3_CHAIN_ARTHAS2 = 92, // Arthas approaches one of the disguised Infinites - RP3_CHAIN_ARTHAS3 = 95, // Arthas proceeds up the stairs + RP3_CHAIN_ARTHAS1 = 91, // Arthas enters Stratholme Town Hall + RP3_CHAIN_ARTHAS2 = 92, // Arthas approaches one of the disguised Infinites + RP3_CHAIN_ARTHAS3 = 95, // Arthas proceeds up the stairs RP3_CHAIN_ARTHAS3_2 = 96, // Arthas encounters more Infinite resistance - RP3_CHAIN_ARTHAS4 = 97, // Arthas presses onward into a hallway - RP3_CHAIN_ARTHAS5 = 98, // Arthas advances into the boss room - RP3_CHAIN_EPOCH = 1, // Chrono-Lord Epoch advances out of the portal + RP3_CHAIN_ARTHAS4 = 97, // Arthas presses onward into a hallway + RP3_CHAIN_ARTHAS5 = 98, // Arthas advances into the boss room + RP3_CHAIN_EPOCH = 1, // Chrono-Lord Epoch advances out of the portal // Spawn motions (all on 27742, infinite adversary) RP3_CHAIN_SPAWN1_LOC1 = 4, @@ -119,16 +119,16 @@ enum SplineChains RP3_CHAIN_SPAWN3_LOC4 = 12, // RP4: Arthas moving towards Gauntlet - RP4_CHAIN_ARTHAS1 = 101, // Arthas moves up to the bookcase - RP4_CHAIN_ARTHAS2 = 128, // Arthas advances to the start of the Gauntlet section + RP4_CHAIN_ARTHAS1 = 101, // Arthas moves up to the bookcase + RP4_CHAIN_ARTHAS2 = 128, // Arthas advances to the start of the Gauntlet section RP4_CHAIN_GAUNTLET1 = 1024, // Arthas charges to the halfway point of the Gauntlet RP4_CHAIN_GAUNTLET2 = 1025, // Arthas continues to Market Row // RP5: Arthas advances on Crusader Square and faces off against Mal'ganis - RP5_CHAIN_ARTHAS1 = 121, // Arthas moves into Crusader Square - RP5_CHAIN_ARTHAS2 = 124, // After Mal'ganis' defeat, Arthas attempts to chase him down - RP5_CHAIN_ARTHAS3 = 125, // Arthas departs... - RP5_CHAIN_ARTHAS4 = 127 // ...and then finally despawns + RP5_CHAIN_ARTHAS1 = 121, // Arthas moves into Crusader Square + RP5_CHAIN_ARTHAS2 = 124, // After Mal'ganis' defeat, Arthas attempts to chase him down + RP5_CHAIN_ARTHAS3 = 125, // Arthas departs... + RP5_CHAIN_ARTHAS4 = 127 // ...and then finally despawns }; enum PointIDs @@ -313,84 +313,88 @@ enum RPEvents enum RPEventLines1 { - RP1_LINE_ARTHAS1 = 0, // Glad you could make it, Uther. - RP1_LINE_UTHER1 = 0, // Watch your tone with me, boy. You may be the prince, but I'm still your superior as a paladin! - RP1_LINE_ARTHAS2 = 1, // As if I could forget. Listen, Uther, there's something about the plague you should know... - RP1_LINE_ARTHAS3 = 2, // Oh, no. We're too late. These people have all been infected! They may look fine now, but it's just a matter of time before they turn into the undead! - RP1_LINE_UTHER2 = 1, // What? - RP1_LINE_ARTHAS4 = 3, // This entire city must be purged. - RP1_LINE_UTHER3 = 2, // How can you even consider that? There's got to be some other way. - RP1_LINE_ARTHAS5 = 4, // Damn it, Uther! As your future king, I order you to purge this city! - RP1_LINE_UTHER4 = 3, // You are not my king yet, boy! Nor would I obey that command even if you were! - RP1_LINE_ARTHAS6 = 5, // Then I must consider this an act of treason. - RP1_LINE_UTHER5 = 4, // Treason? Have you lost your mind, Arthas? - RP1_LINE_ARTHAS7 = 6, // Have I? Lord Uther, by my right of succession and the sovereignty of my crown, I hereby relieve you of your command and suspend your paladins from service. - RP1_LINE_JAINA1 = 0, // Arthas! You can't just-- - RP1_LINE_ARTHAS8 = 7, // It's done! Those of you who have the will to save this land, follow me! The rest of you... get out of my sight! - RP1_LINE_UTHER6 = 5, // You've just crossed a terrible threshold, Arthas. - RP1_LINE_ARTHAS9 = 8, // Jaina? - RP1_LINE_JAINA2 = 1, // I'm sorry, Arthas. I can't watch you do this. - RP1_LINE_ARTHAS10 = 9, // Take position here, and I will lead a small force inside Stratholme to begin the culling. We must contain and purge the infected for the sake of all of Lordaeron! - RP1_LINE_ARTHAS11 = 40 // All officers should check in with me when their squads are ready. We'll enter Stratholme on my order. + RP1_LINE_ARTHAS1 = 0, // Glad you could make it, Uther. + RP1_LINE_UTHER1 = 0, // Watch your tone with me, boy. You may be the prince, but I'm still your superior as a paladin! + RP1_LINE_ARTHAS2 = 1, // As if I could forget. Listen, Uther, there's something about the plague you should know... + RP1_LINE_ARTHAS3 = 2, // Oh, no. We're too late. These people have all been infected! They may look fine now, but it's just a matter of time before they turn into the undead! + RP1_LINE_UTHER2 = 1, // What? + RP1_LINE_ARTHAS4 = 3, // This entire city must be purged. + RP1_LINE_UTHER3 = 2, // How can you even consider that? There's got to be some other way. + RP1_LINE_ARTHAS5 = 4, // Damn it, Uther! As your future king, I order you to purge this city! + RP1_LINE_UTHER4 = 3, // You are not my king yet, boy! Nor would I obey that command even if you were! + RP1_LINE_ARTHAS6 = 5, // Then I must consider this an act of treason. + RP1_LINE_UTHER5 = 4, // Treason? Have you lost your mind, Arthas? + RP1_LINE_ARTHAS7 = 6, // Have I? Lord Uther, by my right of succession and the sovereignty of my crown, I hereby relieve you of your command and suspend your paladins from service. + RP1_LINE_JAINA1 = 0, // Arthas! You can't just-- + RP1_LINE_ARTHAS8 = 7, // It's done! Those of you who have the will to save this land, follow me! The rest of you... get out of my sight! + RP1_LINE_UTHER6 = 5, // You've just crossed a terrible threshold, Arthas. + RP1_LINE_ARTHAS9 = 8, // Jaina? + RP1_LINE_JAINA2 = 1, // I'm sorry, Arthas. I can't watch you do this. + RP1_LINE_ARTHAS10 = 9, // Take position here, and I will lead a small force inside Stratholme to begin the culling. We must contain and purge the infected for the sake of all of Lordaeron! + RP1_LINE_ARTHAS11 = 40 // All officers should check in with me when their squads are ready. We'll enter Stratholme on my order. }; enum RPEventLines2 { - RP2_LINE_ARTHAS1 = 10, // Everyone looks ready. Remember, these people are all infected with the plague and will die soon. We must purge Stratholme to protect the remainder of Lordaeron from the Scourge. Let's go. - RP2_LINE_CITIZEN1 = 0, // Prince Arthas, may the light be praised! Many people in the town have begun to fall seriously ill, can you help us? - RP2_LINE_ARTHAS2 = 11, // I can only help you with a clean death. - RP2_LINE_CITIZEN2 = 1, // What? This can't be! - RP2_LINE_RESIDENT1 = 0, // Oh, no... - RP2_LINE_ARTHAS3 = 12, // That was just the beginning. - RP2_LINE_MALGANIS1 = 0, // Yes, this is the beginning. I've been waiting for you, young prince. I am Mal'Ganis. - RP2_LINE_MALGANIS2 = 1, // As you can see, your people are now mine. I will now turn this city household by household, until the flame of life has been snuffed out... forever. - RP2_LINE_ARTHAS4 = 13, // I won't allow it, Mal'Ganis! Better that these people die by my hand than serve as your slaves in death! - RP2_LINE_ARTHAS5 = 14 // Mal'Ganis will send out some of his Scourge minions to interfere with us. Those of you with the strongest steel and magic shall go forth and destroy them. I will lead the rest of my forces in purging Stratholme of the infected. + RP2_LINE_ARTHAS1 = 10, // Everyone looks ready. Remember, these people are all infected with the plague and will die soon. We must purge Stratholme to protect the remainder of Lordaeron from the + // Scourge. Let's go. + RP2_LINE_CITIZEN1 = 0, // Prince Arthas, may the light be praised! Many people in the town have begun to fall seriously ill, can you help us? + RP2_LINE_ARTHAS2 = 11, // I can only help you with a clean death. + RP2_LINE_CITIZEN2 = 1, // What? This can't be! + RP2_LINE_RESIDENT1 = 0, // Oh, no... + RP2_LINE_ARTHAS3 = 12, // That was just the beginning. + RP2_LINE_MALGANIS1 = 0, // Yes, this is the beginning. I've been waiting for you, young prince. I am Mal'Ganis. + RP2_LINE_MALGANIS2 = 1, // As you can see, your people are now mine. I will now turn this city household by household, until the flame of life has been snuffed out... forever. + RP2_LINE_ARTHAS4 = 13, // I won't allow it, Mal'Ganis! Better that these people die by my hand than serve as your slaves in death! + RP2_LINE_ARTHAS5 = 14 // Mal'Ganis will send out some of his Scourge minions to interfere with us. Those of you with the strongest steel and magic shall go forth and destroy them. I will lead the + // rest of my forces in purging Stratholme of the infected. }; enum RPEventLines3 { - RP3_LINE_ARTHAS1 = 16, // Follow me, I know the way through. - RP3_LINE_CITIZEN1 = 0, // Ah, you've finally arrived Prince Arthas. You're here just in the nick of time. - RP3_LINE_ARTHAS2 = 17, // Yes, I'm glad I could get to you before the plague. - RP3_LINE_ARTHAS3 = 18, // What is this sorcery? - RP3_LINE_CITIZEN2 = 1, // There's no need for you to understand, Arthas. All you need to do is die. - RP3_LINE_ARTHAS4 = 19, // Mal'Ganis appears to have more than Scourge in his arsenal. We should make haste. - - RP3_LINE_ARTHAS10 = 20, // More vile sorcery! Be ready for anything! - RP3_LINE_ARTHAS11 = 21, // Let's move on. - - RP3_LINE_ARTHAS20 = 22, // Watch your backs: they have us surrounded in this hall. - RP3_LINE_ARTHAS21 = 24, // Mal'ganis is not making this easy. - - RP3_LINE_ARTHAS30 = 25, // They're very persistent. - RP3_LINE_ARTHAS31 = 26, // What else can he put in my way? - RP3_LINE_EPOCH1 = 0, // Prince Arthas Menethil, on this day, a powerful darkness has taken hold of your soul. The death you are destined to visit upon others will this day be your own. - RP3_LINE_ARTHAS32 = 27, // I do what I must for Lordaeron, and neither your words nor your actions will stop me. - RP3_LINE_EPOCH2 = 1 // We'll see about that, young prince. + RP3_LINE_ARTHAS1 = 16, // Follow me, I know the way through. + RP3_LINE_CITIZEN1 = 0, // Ah, you've finally arrived Prince Arthas. You're here just in the nick of time. + RP3_LINE_ARTHAS2 = 17, // Yes, I'm glad I could get to you before the plague. + RP3_LINE_ARTHAS3 = 18, // What is this sorcery? + RP3_LINE_CITIZEN2 = 1, // There's no need for you to understand, Arthas. All you need to do is die. + RP3_LINE_ARTHAS4 = 19, // Mal'Ganis appears to have more than Scourge in his arsenal. We should make haste. + + RP3_LINE_ARTHAS10 = 20, // More vile sorcery! Be ready for anything! + RP3_LINE_ARTHAS11 = 21, // Let's move on. + + RP3_LINE_ARTHAS20 = 22, // Watch your backs: they have us surrounded in this hall. + RP3_LINE_ARTHAS21 = 24, // Mal'ganis is not making this easy. + + RP3_LINE_ARTHAS30 = 25, // They're very persistent. + RP3_LINE_ARTHAS31 = 26, // What else can he put in my way? + RP3_LINE_EPOCH1 = 0, // Prince Arthas Menethil, on this day, a powerful darkness has taken hold of your soul. The death you are destined to visit upon others will this day be your own. + RP3_LINE_ARTHAS32 = 27, // I do what I must for Lordaeron, and neither your words nor your actions will stop me. + RP3_LINE_EPOCH2 = 1 // We'll see about that, young prince. }; enum RPEventLines4 { - RP4_LINE_ARTHAS1 = 28, // The quickest path to Mal'Ganis lies behind that bookshelf ahead. - RP4_LINE_ARTHAS2 = 29, // This will only take a moment. - RP4_LINE_ARTHAS3 = 30, // I'm relieved this secret passage still works. - - RP4_LINE_ARTHAS10 = 31, // Let's move through here as quickly as possible. If the undead don't kill us, the fires might. - RP4_LINE_ARTHAS11 = 32, // Rest a moment and clear your lungs, but we must move again soon. - RP4_LINE_ARTHAS12 = 33, // That's enough; we must move again. Mal'Ganis awaits. - RP4_LINE_ARTHAS13 = 34 // At last some good luck. Market Row has not caught fire yet. Mal'Ganis is supposed to be in Crusaders' Square, which is just ahead. Tell me when you're ready to move forward. + RP4_LINE_ARTHAS1 = 28, // The quickest path to Mal'Ganis lies behind that bookshelf ahead. + RP4_LINE_ARTHAS2 = 29, // This will only take a moment. + RP4_LINE_ARTHAS3 = 30, // I'm relieved this secret passage still works. + + RP4_LINE_ARTHAS10 = 31, // Let's move through here as quickly as possible. If the undead don't kill us, the fires might. + RP4_LINE_ARTHAS11 = 32, // Rest a moment and clear your lungs, but we must move again soon. + RP4_LINE_ARTHAS12 = 33, // That's enough; we must move again. Mal'Ganis awaits. + RP4_LINE_ARTHAS13 = + 34 // At last some good luck. Market Row has not caught fire yet. Mal'Ganis is supposed to be in Crusaders' Square, which is just ahead. Tell me when you're ready to move forward. }; enum RPEventLines5 { - RP5_LINE_ARTHAS1 = 35, // Justice will be done. - RP5_LINE_ARTHAS2 = 36, // We're going to finish this right now, Mal'Ganis. Just you... and me. - RP5_LINE_MALGANIS1 = 2, // This will be a fine test, Prince Arthas. - RP5_LINE_MALGANIS12 = 10, // Your journey has just begun, young prince. Gather your forces and meet me in the arctic land of Northrend. It is there that we shall settle the score between us. It is there that your true destiny will unfold. - RP5_LINE_ARTHAS10 = 37, // I'll hunt you to the ends of the earth if I have to! Do you hear me? To the ends of the earth! - RP5_LINE_ARTHAS11 = 38, // You performed well this day. Anything that Mal'Ganis has left behind is yours. Take it as your reward. I must now begin plans for an expedition to Northrend. - RP5_LINE_CHROMIE0 = 0 // Why, hello again! + RP5_LINE_ARTHAS1 = 35, // Justice will be done. + RP5_LINE_ARTHAS2 = 36, // We're going to finish this right now, Mal'Ganis. Just you... and me. + RP5_LINE_MALGANIS1 = 2, // This will be a fine test, Prince Arthas. + RP5_LINE_MALGANIS12 = 10, // Your journey has just begun, young prince. Gather your forces and meet me in the arctic land of Northrend. It is there that we shall settle the score between us. It is + // there that your true destiny will unfold. + RP5_LINE_ARTHAS10 = 37, // I'll hunt you to the ends of the earth if I have to! Do you hear me? To the ends of the earth! + RP5_LINE_ARTHAS11 = 38, // You performed well this day. Anything that Mal'Ganis has left behind is yours. Take it as your reward. I must now begin plans for an expedition to Northrend. + RP5_LINE_CHROMIE0 = 0 // Why, hello again! }; enum PositionIndices : uint32 @@ -448,66 +452,58 @@ enum PositionIndices : uint32 enum OtherLines { LINE_TOWN_HALL_PENDING = 15, - LINE_SLAY_ZOMBIE = 39 + LINE_SLAY_ZOMBIE = 39 }; // @todo sniff // All kinds of positions Arthas needs for RP events (there are a lot of these) -static std::array const ArthasPositions = -{ - { - { 1983.857f, 1287.043f, 145.5596f, 3.0892330f }, // RP1_ARTHAS_INITIAL - { 1783.843f, 1267.481f, 139.7800f, 0.2698664f }, // RP1_UTHER_SPAWN - { 1876.788f, 1305.723f, 146.2474f, 6.0737460f }, // RP1_JAINA_SPAWN - - { 2047.948f, 1287.598f, 142.8568f, 3.176499f }, // ARTHAS_PURGE_PENDING_POS - { 2091.994f, 1277.257f, 140.4707f, 1.134464f }, // ARTHAS_WAVES_POS // @todo - { 2074.624f, 1282.958f, 141.6344f }, // RP2_PRIEST1_POS - { 2074.805f, 1292.172f, 141.6728f }, // RP2_PRIEST2_POS - { 2077.590f, 1284.609f, 141.5710f }, // RP2_FOOT1_POS - { 2078.365f, 1281.254f, 141.5182f }, // RP2_FOOT2_POS - { 2077.737f, 1290.441f, 141.5698f }, // RP2_FOOT3_POS - { 2078.055f, 1293.624f, 141.5544f }, // RP2_FOOT4_POS - { 2113.454f, 1287.986f, 136.3829f, 3.071779f }, // RP2_MALGANIS_POS - - { 2366.240f, 1195.253f, 132.0441f, 3.159046f }, // ARTHAS_TOWN_HALL_POS - { 2433.154f, 1192.572f, 148.1547f, 5.542059f }, // RP3_SPAWN1_LOC1 - { 2432.990f, 1192.760f, 148.1474f, 1.026526f }, // RP3_SPAWN1_LOC2 - { 2432.824f, 1191.816f, 148.1556f, 4.927707f }, // RP3_SPAWN1_LOC3 - { 2432.711f, 1192.857f, 148.1550f, 6.257423f }, // RP3_SPAWN1_LOC4 - { 2433.357f, 1192.168f, 148.1593f, 3.001966f }, // RP3_SPAWN1_RIFT_SPAWN - { 2414.349f, 1136.075f, 148.1592f, 1.345922f }, // RP3_SPAWN2_LOC1 - { 2403.961f, 1180.299f, 148.1587f, 5.139339f }, // RP3_SPAWN2_LOC2 - { 2414.671f, 1136.262f, 148.1592f, 2.305776f }, // RP3_SPAWN2_LOC3 - { 2403.908f, 1179.994f, 148.1586f, 4.654133f }, // RP3_SPAWN2_LOC4 - { 2404.311f, 1178.306f, 148.1585f, 1.605703f }, // RP3_SPAWN2_RIFT1 - { 2414.041f, 1136.068f, 148.1593f, 2.234021f }, // RP3_SPAWN2_RIFT2 - { 2429.026f, 1102.693f, 148.1499f, 1.952652f }, // RP3_SPAWN3_LOC1 - { 2441.173f, 1115.225f, 148.1264f, 2.302970f }, // RP3_SPAWN3_LOC2 - { 2430.645f, 1104.685f, 148.1306f, 1.135255f }, // RP3_SPAWN3_LOC3 - { 2439.649f, 1113.719f, 148.1298f, 3.111888f }, // RP3_SPAWN3_LOC4 - { 2429.296f, 1102.007f, 148.1593f, 6.213372f }, // RP3_SPAWN3_RIFT1 - { 2440.057f, 1114.226f, 148.1593f, 6.108652f }, // RP3_SPAWN3_RIFT2 - { 2457.008f, 1113.929f, 150.0776f, 3.272437f }, // RP3_EPOCH_SPAWN - { 2456.058f, 1113.838f, 150.0917f, 1.745329f }, // RP3_EPOCH_RIFT - { 2425.898f, 1118.842f, 148.0759f, 6.073746f }, // ARTHAS_TOWN_HALL_END_POS - - { 2534.988f, 1126.163f, 130.8621f, 2.844887f }, // ARTHAS_GAUNTLET_POS - { 2363.440f, 1404.906f, 128.7869f, 2.775074f }, // ARTHAS_GAUNTLET_END_POS - - { 2296.862f, 1501.015f, 128.4456f, 5.131268f }, // RP5_MALGANIS_POS - { 2301.055f, 1478.977f, 128.1299f, 1.758816f }, // ARTHAS_FINAL_POS - { 2319.560f, 1506.408f, 152.0474f }, // RP5_CHROMIE_SPAWN - } -}; +static std::array const ArthasPositions = {{ + {1983.857f, 1287.043f, 145.5596f, 3.0892330f}, // RP1_ARTHAS_INITIAL + {1783.843f, 1267.481f, 139.7800f, 0.2698664f}, // RP1_UTHER_SPAWN + {1876.788f, 1305.723f, 146.2474f, 6.0737460f}, // RP1_JAINA_SPAWN + + {2047.948f, 1287.598f, 142.8568f, 3.176499f}, // ARTHAS_PURGE_PENDING_POS + {2091.994f, 1277.257f, 140.4707f, 1.134464f}, // ARTHAS_WAVES_POS // @todo + {2074.624f, 1282.958f, 141.6344f}, // RP2_PRIEST1_POS + {2074.805f, 1292.172f, 141.6728f}, // RP2_PRIEST2_POS + {2077.590f, 1284.609f, 141.5710f}, // RP2_FOOT1_POS + {2078.365f, 1281.254f, 141.5182f}, // RP2_FOOT2_POS + {2077.737f, 1290.441f, 141.5698f}, // RP2_FOOT3_POS + {2078.055f, 1293.624f, 141.5544f}, // RP2_FOOT4_POS + {2113.454f, 1287.986f, 136.3829f, 3.071779f}, // RP2_MALGANIS_POS + + {2366.240f, 1195.253f, 132.0441f, 3.159046f}, // ARTHAS_TOWN_HALL_POS + {2433.154f, 1192.572f, 148.1547f, 5.542059f}, // RP3_SPAWN1_LOC1 + {2432.990f, 1192.760f, 148.1474f, 1.026526f}, // RP3_SPAWN1_LOC2 + {2432.824f, 1191.816f, 148.1556f, 4.927707f}, // RP3_SPAWN1_LOC3 + {2432.711f, 1192.857f, 148.1550f, 6.257423f}, // RP3_SPAWN1_LOC4 + {2433.357f, 1192.168f, 148.1593f, 3.001966f}, // RP3_SPAWN1_RIFT_SPAWN + {2414.349f, 1136.075f, 148.1592f, 1.345922f}, // RP3_SPAWN2_LOC1 + {2403.961f, 1180.299f, 148.1587f, 5.139339f}, // RP3_SPAWN2_LOC2 + {2414.671f, 1136.262f, 148.1592f, 2.305776f}, // RP3_SPAWN2_LOC3 + {2403.908f, 1179.994f, 148.1586f, 4.654133f}, // RP3_SPAWN2_LOC4 + {2404.311f, 1178.306f, 148.1585f, 1.605703f}, // RP3_SPAWN2_RIFT1 + {2414.041f, 1136.068f, 148.1593f, 2.234021f}, // RP3_SPAWN2_RIFT2 + {2429.026f, 1102.693f, 148.1499f, 1.952652f}, // RP3_SPAWN3_LOC1 + {2441.173f, 1115.225f, 148.1264f, 2.302970f}, // RP3_SPAWN3_LOC2 + {2430.645f, 1104.685f, 148.1306f, 1.135255f}, // RP3_SPAWN3_LOC3 + {2439.649f, 1113.719f, 148.1298f, 3.111888f}, // RP3_SPAWN3_LOC4 + {2429.296f, 1102.007f, 148.1593f, 6.213372f}, // RP3_SPAWN3_RIFT1 + {2440.057f, 1114.226f, 148.1593f, 6.108652f}, // RP3_SPAWN3_RIFT2 + {2457.008f, 1113.929f, 150.0776f, 3.272437f}, // RP3_EPOCH_SPAWN + {2456.058f, 1113.838f, 150.0917f, 1.745329f}, // RP3_EPOCH_RIFT + {2425.898f, 1118.842f, 148.0759f, 6.073746f}, // ARTHAS_TOWN_HALL_END_POS + + {2534.988f, 1126.163f, 130.8621f, 2.844887f}, // ARTHAS_GAUNTLET_POS + {2363.440f, 1404.906f, 128.7869f, 2.775074f}, // ARTHAS_GAUNTLET_END_POS + + {2296.862f, 1501.015f, 128.4456f, 5.131268f}, // RP5_MALGANIS_POS + {2301.055f, 1478.977f, 128.1299f, 1.758816f}, // ARTHAS_FINAL_POS + {2319.560f, 1506.408f, 152.0474f}, // RP5_CHROMIE_SPAWN +}}; uint32 const chromiePathSize = 3; -G3D::Vector3 const ChromieSplinePos[chromiePathSize] = -{ - { 2320.632f, 1507.193f, 152.5081f }, - { 2319.823f, 1506.605f, 152.5081f }, - { 2306.770f, 1496.780f, 128.3620f } -}; +G3D::Vector3 const ChromieSplinePos[chromiePathSize] = {{2320.632f, 1507.193f, 152.5081f}, {2319.823f, 1506.605f, 152.5081f}, {2306.770f, 1496.780f, 128.3620f}}; static float const ArthasSnapbackDistanceThreshold = 5.0f; // how far we can be from where we're supposed at start of phase to be before we snap back @@ -519,35 +515,28 @@ struct SnapbackInfo }; // Positions Arthas should be at when starting a given phase -static std::unordered_map const ArthasSnapbackPositions = -{ - { JUST_STARTED, { REACT_PASSIVE, false, &ArthasPositions[RP1_ARTHAS_INITIAL] } }, - { CRATES_IN_PROGRESS, { REACT_PASSIVE, false, &ArthasPositions[RP1_ARTHAS_INITIAL] } }, - { CRATES_DONE, { REACT_PASSIVE, false, &ArthasPositions[RP1_ARTHAS_INITIAL] } }, - { UTHER_TALK, { REACT_PASSIVE, false, &ArthasPositions[RP1_ARTHAS_INITIAL] } }, - { PURGE_PENDING, { REACT_PASSIVE, true, &ArthasPositions[ARTHAS_PURGE_PENDING_POS] } }, - { PURGE_STARTING, { REACT_PASSIVE, false, &ArthasPositions[ARTHAS_PURGE_PENDING_POS] } }, - { WAVES_IN_PROGRESS, { REACT_AGGRESSIVE, false, &ArthasPositions[ARTHAS_WAVES_POS] } }, - { WAVES_DONE, { REACT_DEFENSIVE, false, &ArthasPositions[ARTHAS_WAVES_POS] } }, - { TOWN_HALL_PENDING, { REACT_DEFENSIVE, true, &ArthasPositions[ARTHAS_TOWN_HALL_POS] } }, - { TOWN_HALL, { REACT_DEFENSIVE, false, &ArthasPositions[ARTHAS_TOWN_HALL_POS] } }, - { TOWN_HALL_COMPLETE, { REACT_PASSIVE, true, &ArthasPositions[ARTHAS_TOWN_HALL_END_POS] } }, - { GAUNTLET_TRANSITION, { REACT_PASSIVE, false, &ArthasPositions[ARTHAS_TOWN_HALL_END_POS] } }, - { GAUNTLET_PENDING, { REACT_PASSIVE, true, &ArthasPositions[ARTHAS_GAUNTLET_POS] } }, - { GAUNTLET_IN_PROGRESS, { REACT_DEFENSIVE, false, &ArthasPositions[ARTHAS_GAUNTLET_POS] } }, - { GAUNTLET_COMPLETE, { REACT_PASSIVE, true, &ArthasPositions[ARTHAS_GAUNTLET_END_POS] } }, - { MALGANIS_IN_PROGRESS, { REACT_DEFENSIVE, false, &ArthasPositions[ARTHAS_GAUNTLET_END_POS] } }, - { COMPLETE, { REACT_PASSIVE, false, &ArthasPositions[ARTHAS_FINAL_POS] } } -}; +static std::unordered_map const ArthasSnapbackPositions = {{JUST_STARTED, {REACT_PASSIVE, false, &ArthasPositions[RP1_ARTHAS_INITIAL]}}, + {CRATES_IN_PROGRESS, {REACT_PASSIVE, false, &ArthasPositions[RP1_ARTHAS_INITIAL]}}, {CRATES_DONE, {REACT_PASSIVE, false, &ArthasPositions[RP1_ARTHAS_INITIAL]}}, + {UTHER_TALK, {REACT_PASSIVE, false, &ArthasPositions[RP1_ARTHAS_INITIAL]}}, {PURGE_PENDING, {REACT_PASSIVE, true, &ArthasPositions[ARTHAS_PURGE_PENDING_POS]}}, + {PURGE_STARTING, {REACT_PASSIVE, false, &ArthasPositions[ARTHAS_PURGE_PENDING_POS]}}, {WAVES_IN_PROGRESS, {REACT_AGGRESSIVE, false, &ArthasPositions[ARTHAS_WAVES_POS]}}, + {WAVES_DONE, {REACT_DEFENSIVE, false, &ArthasPositions[ARTHAS_WAVES_POS]}}, {TOWN_HALL_PENDING, {REACT_DEFENSIVE, true, &ArthasPositions[ARTHAS_TOWN_HALL_POS]}}, + {TOWN_HALL, {REACT_DEFENSIVE, false, &ArthasPositions[ARTHAS_TOWN_HALL_POS]}}, {TOWN_HALL_COMPLETE, {REACT_PASSIVE, true, &ArthasPositions[ARTHAS_TOWN_HALL_END_POS]}}, + {GAUNTLET_TRANSITION, {REACT_PASSIVE, false, &ArthasPositions[ARTHAS_TOWN_HALL_END_POS]}}, {GAUNTLET_PENDING, {REACT_PASSIVE, true, &ArthasPositions[ARTHAS_GAUNTLET_POS]}}, + {GAUNTLET_IN_PROGRESS, {REACT_DEFENSIVE, false, &ArthasPositions[ARTHAS_GAUNTLET_POS]}}, {GAUNTLET_COMPLETE, {REACT_PASSIVE, true, &ArthasPositions[ARTHAS_GAUNTLET_END_POS]}}, + {MALGANIS_IN_PROGRESS, {REACT_DEFENSIVE, false, &ArthasPositions[ARTHAS_GAUNTLET_END_POS]}}, {COMPLETE, {REACT_PASSIVE, false, &ArthasPositions[ARTHAS_FINAL_POS]}}}; class npc_arthas_stratholme : public CreatureScript { -public: - npc_arthas_stratholme() : CreatureScript("npc_arthas_stratholme") { } + public: + npc_arthas_stratholme() : CreatureScript("npc_arthas_stratholme") + { + } struct npc_arthas_stratholmeAI : public ScriptedAI { - npc_arthas_stratholmeAI(Creature* creature) : ScriptedAI(creature), instance(creature->GetInstanceScript()), _exorcismCooldown(urandms(7, 14)), _progressRP(true), _afterCombat(ACTION_NONE) { } + npc_arthas_stratholmeAI(Creature* creature) : ScriptedAI(creature), instance(creature->GetInstanceScript()), _exorcismCooldown(urandms(7, 14)), _progressRP(true), _afterCombat(ACTION_NONE) + { + } inline COSProgressStates GetCurrentProgress() { @@ -589,37 +578,37 @@ class npc_arthas_stratholme : public CreatureScript switch (newState) { - case WAVES_DONE: - events.ScheduleEvent(EVENT_TOWN_HALL_REACHED, 3s); - break; - case UTHER_TALK: - if (Creature* uther = me->SummonCreature(NPC_UTHER, ArthasPositions[RP1_UTHER_SPAWN], TEMPSUMMON_MANUAL_DESPAWN)) - { - uther->setActive(true); - uther->GetMotionMaster()->MoveAlongSplineChain(RP1_POINTID_UTHER1, RP1_CHAIN_UTHER1, false); - } - if (Creature* jaina = me->SummonCreature(NPC_JAINA, ArthasPositions[RP1_JAINA_SPAWN], TEMPSUMMON_MANUAL_DESPAWN)) - { - jaina->setActive(true); - jaina->GetMotionMaster()->MoveAlongSplineChain(0, RP1_CHAIN_JAINA1, true); - } - me->GetMotionMaster()->MoveAlongSplineChain(0, RP1_CHAIN_ARTHAS1, false); - break; - case TOWN_HALL_PENDING: - Talk(LINE_TOWN_HALL_PENDING); - break; - case COMPLETE: - if (events.Empty()) - { - // This must be instance loading into COMPLETE state, spawn chromie - events.ScheduleEvent(RP5_EVENT_CHROMIE_SPAWN, 1s); - events.ScheduleEvent(RP5_EVENT_CHROMIE_LAND, 12s + 668ms); - events.ScheduleEvent(RP5_EVENT_CHROMIE_TRANSFORM, 15s + 491ms); - me->SetVisible(false); - } - break; - default: - break; + case WAVES_DONE: + events.ScheduleEvent(EVENT_TOWN_HALL_REACHED, 3s); + break; + case UTHER_TALK: + if (Creature* uther = me->SummonCreature(NPC_UTHER, ArthasPositions[RP1_UTHER_SPAWN], TEMPSUMMON_MANUAL_DESPAWN)) + { + uther->setActive(true); + uther->GetMotionMaster()->MoveAlongSplineChain(RP1_POINTID_UTHER1, RP1_CHAIN_UTHER1, false); + } + if (Creature* jaina = me->SummonCreature(NPC_JAINA, ArthasPositions[RP1_JAINA_SPAWN], TEMPSUMMON_MANUAL_DESPAWN)) + { + jaina->setActive(true); + jaina->GetMotionMaster()->MoveAlongSplineChain(0, RP1_CHAIN_JAINA1, true); + } + me->GetMotionMaster()->MoveAlongSplineChain(0, RP1_CHAIN_ARTHAS1, false); + break; + case TOWN_HALL_PENDING: + Talk(LINE_TOWN_HALL_PENDING); + break; + case COMPLETE: + if (events.Empty()) + { + // This must be instance loading into COMPLETE state, spawn chromie + events.ScheduleEvent(RP5_EVENT_CHROMIE_SPAWN, 1s); + events.ScheduleEvent(RP5_EVENT_CHROMIE_LAND, 12s + 668ms); + events.ScheduleEvent(RP5_EVENT_CHROMIE_TRANSFORM, 15s + 491ms); + me->SetVisible(false); + } + break; + default: + break; } } @@ -636,38 +625,38 @@ class npc_arthas_stratholme : public CreatureScript { switch (action) { - case -ACTION_PROGRESS_UPDATE: - AdvanceToState(GetCurrentProgress()); - break; - case RP3_ACTION_AFTER_INITIAL: - events.ScheduleEvent(RP3_EVENT_ARTHAS4, 1s); - events.ScheduleEvent(RP3_EVENT_ARTHAS_MOVE_1, 7s); - break; - case RP3_ACTION_AFTER_SPAWN1: - events.ScheduleEvent(RP3_EVENT_ARTHAS11, 1s); - events.ScheduleEvent(RP3_EVENT_ARTHAS_MOVE_2, 3s); - break; - case RP3_ACTION_AFTER_SPAWN2: - events.ScheduleEvent(RP3_EVENT_ARTHAS21, 1s); - events.ScheduleEvent(RP3_EVENT_ARTHAS_MOVE_3, 4s); - break; - case RP3_ACTION_AFTER_SPAWN3: - events.ScheduleEvent(RP3_EVENT_EPOCH_SPAWN, 3s); - events.ScheduleEvent(RP3_EVENT_ARTHAS31, 4s); - events.ScheduleEvent(RP3_EVENT_EPOCH_FACE, 6s); - events.ScheduleEvent(RP3_EVENT_EPOCH1, 9s); - events.ScheduleEvent(RP3_EVENT_ARTHAS32, 22s); - events.ScheduleEvent(RP3_EVENT_ARTHAS32_2, 27s); - events.ScheduleEvent(RP3_EVENT_EPOCH_AGGRO, 30s); - break; - case RP3_ACTION_AFTER_EPOCH: - instance->SetData(DATA_TOWN_HALL_DONE, 1); - break; - case RP5_ACTION_AFTER_MALGANIS: - events.ScheduleEvent(RP5_EVENT_MALGANIS_DONE, 3s); - break; - default: - break; + case -ACTION_PROGRESS_UPDATE: + AdvanceToState(GetCurrentProgress()); + break; + case RP3_ACTION_AFTER_INITIAL: + events.ScheduleEvent(RP3_EVENT_ARTHAS4, 1s); + events.ScheduleEvent(RP3_EVENT_ARTHAS_MOVE_1, 7s); + break; + case RP3_ACTION_AFTER_SPAWN1: + events.ScheduleEvent(RP3_EVENT_ARTHAS11, 1s); + events.ScheduleEvent(RP3_EVENT_ARTHAS_MOVE_2, 3s); + break; + case RP3_ACTION_AFTER_SPAWN2: + events.ScheduleEvent(RP3_EVENT_ARTHAS21, 1s); + events.ScheduleEvent(RP3_EVENT_ARTHAS_MOVE_3, 4s); + break; + case RP3_ACTION_AFTER_SPAWN3: + events.ScheduleEvent(RP3_EVENT_EPOCH_SPAWN, 3s); + events.ScheduleEvent(RP3_EVENT_ARTHAS31, 4s); + events.ScheduleEvent(RP3_EVENT_EPOCH_FACE, 6s); + events.ScheduleEvent(RP3_EVENT_EPOCH1, 9s); + events.ScheduleEvent(RP3_EVENT_ARTHAS32, 22s); + events.ScheduleEvent(RP3_EVENT_ARTHAS32_2, 27s); + events.ScheduleEvent(RP3_EVENT_EPOCH_AGGRO, 30s); + break; + case RP3_ACTION_AFTER_EPOCH: + instance->SetData(DATA_TOWN_HALL_DONE, 1); + break; + case RP5_ACTION_AFTER_MALGANIS: + events.ScheduleEvent(RP5_EVENT_MALGANIS_DONE, 3s); + break; + default: + break; } } @@ -678,29 +667,29 @@ class npc_arthas_stratholme : public CreatureScript Unit* talkTarget = ObjectAccessor::GetUnit(*me, _eventStarterGuid); switch (type) { - case -ACTION_START_RP_EVENT2: - Talk(RP2_LINE_ARTHAS1, talkTarget); - events.ScheduleEvent(RP2_EVENT_ARTHAS_MOVE_1, Seconds(9)); - break; - case -ACTION_START_RP_EVENT3: - Talk(RP3_LINE_ARTHAS1, talkTarget); - me->GetMotionMaster()->MoveAlongSplineChain(RP3_POINTID_ARTHAS1, RP3_CHAIN_ARTHAS1, false); - break; - case -ACTION_START_RP_EVENT4_1: - Talk(RP4_LINE_ARTHAS1, talkTarget); - me->GetMotionMaster()->MoveAlongSplineChain(RP4_POINTID_ARTHAS1, RP4_CHAIN_ARTHAS1, true); - break; - case -ACTION_START_RP_EVENT4_2: - Talk(RP4_LINE_ARTHAS10, talkTarget); - events.ScheduleEvent(RP4_EVENT_ARTHAS_MOVE, Seconds(5)); - break; - case -ACTION_START_RP_EVENT5: - Talk(RP5_LINE_ARTHAS1, talkTarget); - instance->instance->SummonCreature(NPC_MALGANIS, ArthasPositions[RP5_MALGANIS_POS]); - me->GetMotionMaster()->MoveAlongSplineChain(RP5_POINTID_ARTHAS1, RP5_CHAIN_ARTHAS1, false); - break; - default: - break; + case -ACTION_START_RP_EVENT2: + Talk(RP2_LINE_ARTHAS1, talkTarget); + events.ScheduleEvent(RP2_EVENT_ARTHAS_MOVE_1, Seconds(9)); + break; + case -ACTION_START_RP_EVENT3: + Talk(RP3_LINE_ARTHAS1, talkTarget); + me->GetMotionMaster()->MoveAlongSplineChain(RP3_POINTID_ARTHAS1, RP3_CHAIN_ARTHAS1, false); + break; + case -ACTION_START_RP_EVENT4_1: + Talk(RP4_LINE_ARTHAS1, talkTarget); + me->GetMotionMaster()->MoveAlongSplineChain(RP4_POINTID_ARTHAS1, RP4_CHAIN_ARTHAS1, true); + break; + case -ACTION_START_RP_EVENT4_2: + Talk(RP4_LINE_ARTHAS10, talkTarget); + events.ScheduleEvent(RP4_EVENT_ARTHAS_MOVE, Seconds(5)); + break; + case -ACTION_START_RP_EVENT5: + Talk(RP5_LINE_ARTHAS1, talkTarget); + instance->instance->SummonCreature(NPC_MALGANIS, ArthasPositions[RP5_MALGANIS_POS]); + me->GetMotionMaster()->MoveAlongSplineChain(RP5_POINTID_ARTHAS1, RP5_CHAIN_ARTHAS1, false); + break; + default: + break; } } @@ -712,164 +701,164 @@ class npc_arthas_stratholme : public CreatureScript return; switch (id) { - case RP1_POINTID_UTHER1: - events.ScheduleEvent(RP1_EVENT_START1, 0s); - events.ScheduleEvent(RP1_EVENT_START2, 1s); - events.ScheduleEvent(RP1_EVENT_ARTHAS1, 4s); - events.ScheduleEvent(RP1_EVENT_UTHER1, 8s); - events.ScheduleEvent(RP1_EVENT_ARTHAS2, 15s); - break; - case RP1_POINTID_UTHER2: - events.ScheduleEvent(RP1_EVENT_UTHER_FACE, 0s); - break; - case RP1_POINTID_JAINA2: - events.ScheduleEvent(RP1_EVENT_JAINA_FACE, 0s); - break; - case RP1_POINTID_ARTHAS2: - events.ScheduleEvent(RP1_EVENT_ARTHAS3, 1s); - events.ScheduleEvent(RP1_EVENT_UTHER2, 12s); - events.ScheduleEvent(RP1_EVENT_ARTHAS_TURN, 13s); - events.ScheduleEvent(RP1_EVENT_ARTHAS4, 14s); - events.ScheduleEvent(RP1_EVENT_UTHER3, 18s); - events.ScheduleEvent(RP1_EVENT_ARTHAS5, 24s); - events.ScheduleEvent(RP1_EVENT_UTHER4, 30s); - events.ScheduleEvent(RP1_EVENT_ARTHAS6, 36s); - events.ScheduleEvent(RP1_EVENT_UTHER5, 39s); - events.ScheduleEvent(RP1_EVENT_ARTHAS7, 44s); - events.ScheduleEvent(RP1_EVENT_JAINA1, 57s); - events.ScheduleEvent(RP1_EVENT_ARTHAS8, 59s); - events.ScheduleEvent(RP1_EVENT_ARTHAS8_2, 65s); - events.ScheduleEvent(RP1_EVENT_UTHER6, 71s); - events.ScheduleEvent(RP1_EVENT_UTHER_LEAVE, 74s); - events.ScheduleEvent(RP1_EVENT_JAINA_LEAVE, 75s); - events.ScheduleEvent(RP1_EVENT_ARTHAS9, 76s); - events.ScheduleEvent(RP1_EVENT_JAINA2, 78s); - events.ScheduleEvent(RP1_EVENT_JAINA_LEAVE2, 82s); - events.ScheduleEvent(RP1_EVENT_ARTHAS_LEAVE, 88s); - break; - case RP1_POINTID_UTHER3: - if (Creature* uther = me->FindNearestCreature(NPC_UTHER, 500.0f, true)) - uther->DespawnOrUnsummon(); - break; - case RP1_POINTID_JAINA4: - if (Creature* jaina = me->FindNearestCreature(NPC_JAINA, 500.0f, true)) - jaina->DespawnOrUnsummon(); - break; - case RP1_POINTID_ARTHAS3: - events.ScheduleEvent(RP1_EVENT_ARTHAS10, 0s); - events.ScheduleEvent(RP1_EVENT_ARTHAS_LEAVE2, 12s); - break; - case RP1_POINTID_ARTHAS4: - events.ScheduleEvent(RP1_EVENT_FINISHED, 0s); - break; - case RP2_POINTID_ARTHAS1: - if (Creature* citizen = me->FindNearestCreature(NPC_CITIZEN, 100.0f, true)) - citizen->SetFacingToObject(me); - if (Creature* resident = me->FindNearestCreature(NPC_RESIDENT, 100.0f, true)) - resident->SetFacingToObject(me); - events.ScheduleEvent(RP2_EVENT_CITIZEN1, 2s); - events.ScheduleEvent(RP2_EVENT_ARTHAS2, 10s); - events.ScheduleEvent(RP2_EVENT_ARTHAS_MOVE_2, 11s); - break; - case RP2_POINTID_ARTHAS2: - events.ScheduleEvent(RP2_EVENT_CITIZEN2, 0s); - events.ScheduleEvent(RP2_EVENT_KILL1, 1s); - events.ScheduleEvent(RP2_EVENT_ARTHAS_MOVE_3, 3s); - break; - case RP2_POINTID_ARTHAS3: - events.ScheduleEvent(RP2_EVENT_KILL2, 1s); - events.ScheduleEvent(RP2_EVENT_REACT1, 2s); - events.ScheduleEvent(RP2_EVENT_REACT2, 3s); - events.ScheduleEvent(RP2_EVENT_REACT3, 4s); - events.ScheduleEvent(RP2_EVENT_REACT4, 6s); - events.ScheduleEvent(RP2_EVENT_REACT5, 6s); - events.ScheduleEvent(RP2_EVENT_ARTHAS_MOVE_4, 4s); - events.ScheduleEvent(RP2_EVENT_ARTHAS3, 6s); - events.ScheduleEvent(RP2_EVENT_MALGANIS1, 10s); - events.ScheduleEvent(RP2_EVENT_TROOPS_FACE, 11s); - events.ScheduleEvent(RP2_EVENT_ARTHAS_FACE, 13s); - events.ScheduleEvent(RP2_EVENT_MALGANIS2, 22s); - events.ScheduleEvent(RP2_EVENT_MALGANIS_LEAVE1, 34s); - events.ScheduleEvent(RP2_EVENT_MALGANIS_LEAVE2, 35s); - events.ScheduleEvent(RP2_EVENT_ARTHAS4, 35s); - events.ScheduleEvent(RP2_EVENT_ARTHAS4_2, 39s); - events.ScheduleEvent(RP2_EVENT_ARTHAS_MOVE_5, 45s); - events.ScheduleEvent(RP2_EVENT_ARTHAS5, 45s); - events.ScheduleEvent(RP2_EVENT_ARTHAS5_2, 51s); - events.ScheduleEvent(RP2_EVENT_ARTHAS5_3, 57s); - events.ScheduleEvent(RP2_EVENT_WAVE_START, 64s); - break; - case RP3_POINTID_ARTHAS1: - { - std::list infinites; - me->GetCreatureListWithEntryInGrid(infinites, NPC_CITIZEN_INFINITE, 100.0f); - for (Creature* infinite : infinites) - infinite->SetFacingToObject(me); - events.ScheduleEvent(RP3_EVENT_RESIDENT_FACE, 1s); - events.ScheduleEvent(RP3_EVENT_ARTHAS_FACE, 2s); - events.ScheduleEvent(RP3_EVENT_CITIZEN1, 3s); - events.ScheduleEvent(RP3_EVENT_ARTHAS2, 12s); - break; - } - case RP3_POINTID_ARTHAS2: - events.ScheduleEvent(RP3_EVENT_ARTHAS_KILL, 1s); - events.ScheduleEvent(RP3_EVENT_INFINITE_LAUGH, 2s); - events.ScheduleEvent(RP3_EVENT_ARTHAS3, 6s); - events.ScheduleEvent(RP3_EVENT_CITIZEN2, 8s); - events.ScheduleEvent(RP3_EVENT_TRANSFORM1, 10s); - events.ScheduleEvent(RP3_EVENT_TRANSFORM2, 12s); - events.ScheduleEvent(RP3_EVENT_TRANSFORM3, 14s); - events.ScheduleEvent(RP3_EVENT_AGGRO, 15s); - break; - case RP3_POINTID_ARTHAS3: - events.ScheduleEvent(RP3_EVENT_ARTHAS_MOVE_1_2, 1s); - events.ScheduleEvent(RP3_EVENT_SPAWN1, 2s); - events.ScheduleEvent(RP3_EVENT_SPAWN1_FACE, 5s); - events.ScheduleEvent(RP3_EVENT_SPAWN1_AGGRO, 7s); - break; - case RP3_POINTID_ARTHAS4: - events.ScheduleEvent(RP3_EVENT_ARTHAS20, 1s); - events.ScheduleEvent(RP3_EVENT_SPAWN2, 2s); - events.ScheduleEvent(RP3_EVENT_ARTHAS_FACE2, 3s); - events.ScheduleEvent(RP3_EVENT_SPAWN2_FACE, 4s); - events.ScheduleEvent(RP3_EVENT_SPAWN2_AGGRO, 6s); - break; - case RP3_POINTID_ARTHAS5: - events.ScheduleEvent(RP3_EVENT_SPAWN3, 2s); - events.ScheduleEvent(RP3_EVENT_ARTHAS30, 4s); - events.ScheduleEvent(RP3_EVENT_SPAWN3_FACE, 5s); - events.ScheduleEvent(RP3_EVENT_SPAWN3_AGGRO, 6s); - break; - case RP4_POINTID_ARTHAS1: - events.ScheduleEvent(RP4_EVENT_ARTHAS2, 1s); - events.ScheduleEvent(RP4_EVENT_HIDDEN_PASSAGE, 4s); // @todo sniff timer - events.ScheduleEvent(RP4_EVENT_ARTHAS3, 5s); - break; - case RP4_POINTID_ARTHAS2: - events.ScheduleEvent(RP4_EVENT_GAUNTLET_REACHED, 1s); - break; - case RP4_POINTID_GAUNTLET1: - events.ScheduleEvent(RP4_EVENT_ARTHAS11, 1s); - events.ScheduleEvent(RP4_EVENT_ARTHAS_FACE, 5s); - events.ScheduleEvent(RP4_EVENT_ARTHAS12, 21s); - events.ScheduleEvent(RP4_EVENT_GAUNTLET_RESUME, 25s); - break; - case RP4_POINTID_GAUNTLET2: - events.ScheduleEvent(RP4_EVENT_ARTHAS13, 1s); - events.ScheduleEvent(RP4_EVENT_GAUNTLET_DONE, 7s); - break; - case RP5_POINTID_ARTHAS1: - events.ScheduleEvent(RP5_EVENT_ARTHAS2, 1s); - events.ScheduleEvent(RP5_EVENT_MALGANIS1, 6s); - break; - case RP5_POINTID_ARTHAS3: - events.ScheduleEvent(RP5_EVENT_ARTHAS_LEAVE2, 0s); - break; - case RP5_POINTID_ARTHAS4: - me->NearTeleportTo(ArthasPositions[ARTHAS_FINAL_POS]); - break; - default: - break; + case RP1_POINTID_UTHER1: + events.ScheduleEvent(RP1_EVENT_START1, 0s); + events.ScheduleEvent(RP1_EVENT_START2, 1s); + events.ScheduleEvent(RP1_EVENT_ARTHAS1, 4s); + events.ScheduleEvent(RP1_EVENT_UTHER1, 8s); + events.ScheduleEvent(RP1_EVENT_ARTHAS2, 15s); + break; + case RP1_POINTID_UTHER2: + events.ScheduleEvent(RP1_EVENT_UTHER_FACE, 0s); + break; + case RP1_POINTID_JAINA2: + events.ScheduleEvent(RP1_EVENT_JAINA_FACE, 0s); + break; + case RP1_POINTID_ARTHAS2: + events.ScheduleEvent(RP1_EVENT_ARTHAS3, 1s); + events.ScheduleEvent(RP1_EVENT_UTHER2, 12s); + events.ScheduleEvent(RP1_EVENT_ARTHAS_TURN, 13s); + events.ScheduleEvent(RP1_EVENT_ARTHAS4, 14s); + events.ScheduleEvent(RP1_EVENT_UTHER3, 18s); + events.ScheduleEvent(RP1_EVENT_ARTHAS5, 24s); + events.ScheduleEvent(RP1_EVENT_UTHER4, 30s); + events.ScheduleEvent(RP1_EVENT_ARTHAS6, 36s); + events.ScheduleEvent(RP1_EVENT_UTHER5, 39s); + events.ScheduleEvent(RP1_EVENT_ARTHAS7, 44s); + events.ScheduleEvent(RP1_EVENT_JAINA1, 57s); + events.ScheduleEvent(RP1_EVENT_ARTHAS8, 59s); + events.ScheduleEvent(RP1_EVENT_ARTHAS8_2, 65s); + events.ScheduleEvent(RP1_EVENT_UTHER6, 71s); + events.ScheduleEvent(RP1_EVENT_UTHER_LEAVE, 74s); + events.ScheduleEvent(RP1_EVENT_JAINA_LEAVE, 75s); + events.ScheduleEvent(RP1_EVENT_ARTHAS9, 76s); + events.ScheduleEvent(RP1_EVENT_JAINA2, 78s); + events.ScheduleEvent(RP1_EVENT_JAINA_LEAVE2, 82s); + events.ScheduleEvent(RP1_EVENT_ARTHAS_LEAVE, 88s); + break; + case RP1_POINTID_UTHER3: + if (Creature* uther = me->FindNearestCreature(NPC_UTHER, 500.0f, true)) + uther->DespawnOrUnsummon(); + break; + case RP1_POINTID_JAINA4: + if (Creature* jaina = me->FindNearestCreature(NPC_JAINA, 500.0f, true)) + jaina->DespawnOrUnsummon(); + break; + case RP1_POINTID_ARTHAS3: + events.ScheduleEvent(RP1_EVENT_ARTHAS10, 0s); + events.ScheduleEvent(RP1_EVENT_ARTHAS_LEAVE2, 12s); + break; + case RP1_POINTID_ARTHAS4: + events.ScheduleEvent(RP1_EVENT_FINISHED, 0s); + break; + case RP2_POINTID_ARTHAS1: + if (Creature* citizen = me->FindNearestCreature(NPC_CITIZEN, 100.0f, true)) + citizen->SetFacingToObject(me); + if (Creature* resident = me->FindNearestCreature(NPC_RESIDENT, 100.0f, true)) + resident->SetFacingToObject(me); + events.ScheduleEvent(RP2_EVENT_CITIZEN1, 2s); + events.ScheduleEvent(RP2_EVENT_ARTHAS2, 10s); + events.ScheduleEvent(RP2_EVENT_ARTHAS_MOVE_2, 11s); + break; + case RP2_POINTID_ARTHAS2: + events.ScheduleEvent(RP2_EVENT_CITIZEN2, 0s); + events.ScheduleEvent(RP2_EVENT_KILL1, 1s); + events.ScheduleEvent(RP2_EVENT_ARTHAS_MOVE_3, 3s); + break; + case RP2_POINTID_ARTHAS3: + events.ScheduleEvent(RP2_EVENT_KILL2, 1s); + events.ScheduleEvent(RP2_EVENT_REACT1, 2s); + events.ScheduleEvent(RP2_EVENT_REACT2, 3s); + events.ScheduleEvent(RP2_EVENT_REACT3, 4s); + events.ScheduleEvent(RP2_EVENT_REACT4, 6s); + events.ScheduleEvent(RP2_EVENT_REACT5, 6s); + events.ScheduleEvent(RP2_EVENT_ARTHAS_MOVE_4, 4s); + events.ScheduleEvent(RP2_EVENT_ARTHAS3, 6s); + events.ScheduleEvent(RP2_EVENT_MALGANIS1, 10s); + events.ScheduleEvent(RP2_EVENT_TROOPS_FACE, 11s); + events.ScheduleEvent(RP2_EVENT_ARTHAS_FACE, 13s); + events.ScheduleEvent(RP2_EVENT_MALGANIS2, 22s); + events.ScheduleEvent(RP2_EVENT_MALGANIS_LEAVE1, 34s); + events.ScheduleEvent(RP2_EVENT_MALGANIS_LEAVE2, 35s); + events.ScheduleEvent(RP2_EVENT_ARTHAS4, 35s); + events.ScheduleEvent(RP2_EVENT_ARTHAS4_2, 39s); + events.ScheduleEvent(RP2_EVENT_ARTHAS_MOVE_5, 45s); + events.ScheduleEvent(RP2_EVENT_ARTHAS5, 45s); + events.ScheduleEvent(RP2_EVENT_ARTHAS5_2, 51s); + events.ScheduleEvent(RP2_EVENT_ARTHAS5_3, 57s); + events.ScheduleEvent(RP2_EVENT_WAVE_START, 64s); + break; + case RP3_POINTID_ARTHAS1: + { + std::list infinites; + me->GetCreatureListWithEntryInGrid(infinites, NPC_CITIZEN_INFINITE, 100.0f); + for (Creature* infinite : infinites) + infinite->SetFacingToObject(me); + events.ScheduleEvent(RP3_EVENT_RESIDENT_FACE, 1s); + events.ScheduleEvent(RP3_EVENT_ARTHAS_FACE, 2s); + events.ScheduleEvent(RP3_EVENT_CITIZEN1, 3s); + events.ScheduleEvent(RP3_EVENT_ARTHAS2, 12s); + break; + } + case RP3_POINTID_ARTHAS2: + events.ScheduleEvent(RP3_EVENT_ARTHAS_KILL, 1s); + events.ScheduleEvent(RP3_EVENT_INFINITE_LAUGH, 2s); + events.ScheduleEvent(RP3_EVENT_ARTHAS3, 6s); + events.ScheduleEvent(RP3_EVENT_CITIZEN2, 8s); + events.ScheduleEvent(RP3_EVENT_TRANSFORM1, 10s); + events.ScheduleEvent(RP3_EVENT_TRANSFORM2, 12s); + events.ScheduleEvent(RP3_EVENT_TRANSFORM3, 14s); + events.ScheduleEvent(RP3_EVENT_AGGRO, 15s); + break; + case RP3_POINTID_ARTHAS3: + events.ScheduleEvent(RP3_EVENT_ARTHAS_MOVE_1_2, 1s); + events.ScheduleEvent(RP3_EVENT_SPAWN1, 2s); + events.ScheduleEvent(RP3_EVENT_SPAWN1_FACE, 5s); + events.ScheduleEvent(RP3_EVENT_SPAWN1_AGGRO, 7s); + break; + case RP3_POINTID_ARTHAS4: + events.ScheduleEvent(RP3_EVENT_ARTHAS20, 1s); + events.ScheduleEvent(RP3_EVENT_SPAWN2, 2s); + events.ScheduleEvent(RP3_EVENT_ARTHAS_FACE2, 3s); + events.ScheduleEvent(RP3_EVENT_SPAWN2_FACE, 4s); + events.ScheduleEvent(RP3_EVENT_SPAWN2_AGGRO, 6s); + break; + case RP3_POINTID_ARTHAS5: + events.ScheduleEvent(RP3_EVENT_SPAWN3, 2s); + events.ScheduleEvent(RP3_EVENT_ARTHAS30, 4s); + events.ScheduleEvent(RP3_EVENT_SPAWN3_FACE, 5s); + events.ScheduleEvent(RP3_EVENT_SPAWN3_AGGRO, 6s); + break; + case RP4_POINTID_ARTHAS1: + events.ScheduleEvent(RP4_EVENT_ARTHAS2, 1s); + events.ScheduleEvent(RP4_EVENT_HIDDEN_PASSAGE, 4s); // @todo sniff timer + events.ScheduleEvent(RP4_EVENT_ARTHAS3, 5s); + break; + case RP4_POINTID_ARTHAS2: + events.ScheduleEvent(RP4_EVENT_GAUNTLET_REACHED, 1s); + break; + case RP4_POINTID_GAUNTLET1: + events.ScheduleEvent(RP4_EVENT_ARTHAS11, 1s); + events.ScheduleEvent(RP4_EVENT_ARTHAS_FACE, 5s); + events.ScheduleEvent(RP4_EVENT_ARTHAS12, 21s); + events.ScheduleEvent(RP4_EVENT_GAUNTLET_RESUME, 25s); + break; + case RP4_POINTID_GAUNTLET2: + events.ScheduleEvent(RP4_EVENT_ARTHAS13, 1s); + events.ScheduleEvent(RP4_EVENT_GAUNTLET_DONE, 7s); + break; + case RP5_POINTID_ARTHAS1: + events.ScheduleEvent(RP5_EVENT_ARTHAS2, 1s); + events.ScheduleEvent(RP5_EVENT_MALGANIS1, 6s); + break; + case RP5_POINTID_ARTHAS3: + events.ScheduleEvent(RP5_EVENT_ARTHAS_LEAVE2, 0s); + break; + case RP5_POINTID_ARTHAS4: + me->NearTeleportTo(ArthasPositions[ARTHAS_FINAL_POS]); + break; + default: + break; } } @@ -929,579 +918,579 @@ class npc_arthas_stratholme : public CreatureScript uint32 talkerEntry = UINT_MAX, talkerLine = 0; switch (event) { - case RP1_EVENT_START1: - if (Creature* jaina = me->FindNearestCreature(NPC_JAINA, 100.0f, true)) - jaina->SetFacingToObject(me); - break; - case RP1_EVENT_START2: - if (Creature* uther = me->FindNearestCreature(NPC_UTHER, 100.0f, true)) + case RP1_EVENT_START1: + if (Creature* jaina = me->FindNearestCreature(NPC_JAINA, 100.0f, true)) + jaina->SetFacingToObject(me); + break; + case RP1_EVENT_START2: + if (Creature* uther = me->FindNearestCreature(NPC_UTHER, 100.0f, true)) + { + uther->SetFacingToObject(me); + me->SetFacingToObject(uther); + } + break; + case RP1_EVENT_ARTHAS1: + talkerEntry = 0, talkerLine = RP1_LINE_ARTHAS1; + break; + case RP1_EVENT_UTHER1: + talkerEntry = NPC_UTHER, talkerLine = RP1_LINE_UTHER1; + break; + case RP1_EVENT_ARTHAS2: + talkerEntry = 0, talkerLine = RP1_LINE_ARTHAS2; + me->GetMotionMaster()->MoveAlongSplineChain(RP1_POINTID_ARTHAS2, RP1_CHAIN_ARTHAS2, true); + if (Creature* uther = me->FindNearestCreature(NPC_UTHER, 100.0f, true)) + uther->GetMotionMaster()->MoveAlongSplineChain(RP1_POINTID_UTHER2, RP1_CHAIN_UTHER2, true); + if (Creature* jaina = me->FindNearestCreature(NPC_JAINA, 100.0f, true)) + jaina->GetMotionMaster()->MoveAlongSplineChain(RP1_POINTID_JAINA2, RP1_CHAIN_JAINA2, true); + break; + case RP1_EVENT_UTHER_FACE: + if (Creature* uther = me->FindNearestCreature(NPC_UTHER, 100.0f, true)) + uther->SetFacingToObject(me); + break; + case RP1_EVENT_JAINA_FACE: + if (Creature* jaina = me->FindNearestCreature(NPC_JAINA, 100.0f, true)) + jaina->SetFacingToObject(me); + break; + case RP1_EVENT_ARTHAS3: + { + me->SetFacingTo(6.248279f); // @todo migrate + talkerEntry = 0, talkerLine = RP1_LINE_ARTHAS3; + std::list troops; + me->GetCreatureListWithEntryInGrid(troops, NPC_FOOTMAN, 100.0f); + me->GetCreatureListWithEntryInGrid(troops, NPC_SORCERESS, 100.0f); + me->GetCreatureListWithEntryInGrid(troops, NPC_KNIGHT, 100.0f); + me->GetCreatureListWithEntryInGrid(troops, NPC_PRIEST, 100.0f); + for (Creature* unit : troops) + if (unit->IsAlive()) + unit->SetFacingToObject(me); + break; + } + case RP1_EVENT_UTHER2: + talkerEntry = NPC_UTHER, talkerLine = RP1_LINE_UTHER2; + break; + case RP1_EVENT_ARTHAS4: + talkerEntry = 0, talkerLine = RP1_LINE_ARTHAS4; + break; + case RP1_EVENT_UTHER3: + talkerEntry = NPC_UTHER, talkerLine = RP1_LINE_UTHER3; + break; + case RP1_EVENT_ARTHAS_TURN: + if (Creature* uther = me->FindNearestCreature(NPC_UTHER, 100.0f, true)) + me->SetFacingToObject(uther); + break; + case RP1_EVENT_ARTHAS5: + talkerEntry = 0, talkerLine = RP1_LINE_ARTHAS5; + break; + case RP1_EVENT_UTHER4: + talkerEntry = NPC_UTHER, talkerLine = RP1_LINE_UTHER4; + break; + case RP1_EVENT_ARTHAS6: + talkerEntry = 0, talkerLine = RP1_LINE_ARTHAS6; + break; + case RP1_EVENT_UTHER5: + talkerEntry = NPC_UTHER, talkerLine = RP1_LINE_UTHER5; + break; + case RP1_EVENT_ARTHAS7: + talkerEntry = 0, talkerLine = RP1_LINE_ARTHAS7; + break; + case RP1_EVENT_JAINA1: + talkerEntry = NPC_JAINA, talkerLine = RP1_LINE_JAINA1; + break; + case RP1_EVENT_ARTHAS8: + talkerEntry = 0, talkerLine = RP1_LINE_ARTHAS8; + break; + case RP1_EVENT_ARTHAS8_2: + me->HandleEmoteCommand(EMOTE_ONESHOT_EXCLAMATION); + break; + case RP1_EVENT_UTHER6: + talkerEntry = NPC_UTHER, talkerLine = RP1_LINE_UTHER6; + break; + case RP1_EVENT_UTHER_LEAVE: + if (Creature* uther = me->FindNearestCreature(NPC_UTHER, 100.0f, true)) + uther->GetMotionMaster()->MoveAlongSplineChain(RP1_POINTID_UTHER3, RP1_CHAIN_UTHER3, true); + break; + case RP1_EVENT_JAINA_LEAVE: + if (Creature* jaina = me->FindNearestCreature(NPC_JAINA, 100.0f, true)) + jaina->GetMotionMaster()->MoveAlongSplineChain(0, RP1_CHAIN_JAINA3, true); + break; + case RP1_EVENT_ARTHAS9: + talkerEntry = 0, talkerLine = RP1_LINE_ARTHAS9; + if (Creature* jaina = me->FindNearestCreature(NPC_JAINA, 100.0f, true)) + me->SetFacingToObject(jaina); + break; + case RP1_EVENT_JAINA2: + talkerEntry = NPC_JAINA, talkerLine = RP1_LINE_JAINA2; + break; + case RP1_EVENT_JAINA_LEAVE2: + if (Creature* jaina = me->FindNearestCreature(NPC_JAINA, 100.0f, true)) + jaina->GetMotionMaster()->MoveAlongSplineChain(RP1_POINTID_JAINA4, RP1_CHAIN_JAINA4, true); + break; + case RP1_EVENT_ARTHAS_LEAVE: + me->GetMotionMaster()->MoveAlongSplineChain(RP1_POINTID_ARTHAS3, RP1_CHAIN_ARTHAS3, true); + break; + case RP1_EVENT_ARTHAS10: + talkerEntry = 0, talkerLine = RP1_LINE_ARTHAS10; + me->SetFacingTo(3.141593f); // @todo migrate + break; + case RP1_EVENT_ARTHAS_LEAVE2: + me->GetMotionMaster()->MoveAlongSplineChain(RP1_POINTID_ARTHAS4, RP1_CHAIN_ARTHAS4, false); + break; + case RP1_EVENT_FINISHED: + talkerEntry = 0, talkerLine = RP1_LINE_ARTHAS11; + me->SetFacingTo(ArthasPositions[ARTHAS_PURGE_PENDING_POS].GetOrientation()); + instance->SetData(DATA_UTHER_FINISHED, 1); + break; + case RP2_EVENT_ARTHAS_MOVE_1: + me->GetMotionMaster()->MoveAlongSplineChain(RP2_POINTID_ARTHAS1, RP2_CHAIN_ARTHAS1, true); + break; + case RP2_EVENT_CITIZEN1: + if (Creature* citizen = me->FindNearestCreature(NPC_CITIZEN, 100.0f, true)) + { + citizen->GetMotionMaster()->MoveAlongSplineChain(0, RP2_CHAIN_CITIZEN1, true); + citizen->AI()->Talk(RP2_LINE_CITIZEN1, ObjectAccessor::GetUnit(*me, _eventStarterGuid)); + } + break; + case RP2_EVENT_ARTHAS2: + talkerEntry = 0, talkerLine = RP2_LINE_ARTHAS2; + break; + case RP2_EVENT_ARTHAS_MOVE_2: + me->GetMotionMaster()->MoveAlongSplineChain(RP2_POINTID_ARTHAS2, RP2_CHAIN_ARTHAS2, true); + break; + case RP2_EVENT_CITIZEN2: + talkerEntry = NPC_CITIZEN, talkerLine = RP2_LINE_CITIZEN2; + break; + case RP2_EVENT_KILL1: + if (Creature* citizen = me->FindNearestCreature(NPC_CITIZEN, 100.0f, true)) + DoCast(citizen, SPELL_CRUSADER_STRIKE); + if (Creature* resident = me->FindNearestCreature(NPC_RESIDENT, 100.0f, true)) + { + resident->SetFlag(UNIT_NPC_EMOTESTATE, EMOTE_STATE_COWER); + resident->AI()->Talk(RP2_LINE_RESIDENT1, ObjectAccessor::GetUnit(*me, _eventStarterGuid)); + } + break; + case RP2_EVENT_ARTHAS_MOVE_3: + me->GetMotionMaster()->MoveAlongSplineChain(RP2_POINTID_ARTHAS3, RP2_CHAIN_ARTHAS3, true); + break; + case RP2_EVENT_KILL2: + if (Creature* resident = me->FindNearestCreature(NPC_RESIDENT, 100.0f, true)) + DoCast(resident, SPELL_CRUSADER_STRIKE); + break; + case RP2_EVENT_REACT1: + case RP2_EVENT_REACT2: + case RP2_EVENT_REACT3: + case RP2_EVENT_REACT4: + case RP2_EVENT_REACT5: + { + std::list nearbyVictims; + me->GetCreatureListWithEntryInGrid(nearbyVictims, urand(0, 1) ? NPC_CITIZEN : NPC_RESIDENT, 60.0f); + if (!nearbyVictims.empty()) + { + std::list::iterator it = nearbyVictims.begin(); + std::advance(it, urand(0, nearbyVictims.size() - 1)); + Emote emote = EMOTE_ONESHOT_NONE; + switch (urand(0, 3)) { - uther->SetFacingToObject(me); - me->SetFacingToObject(uther); + case 0: + emote = EMOTE_ONESHOT_TALK; + break; + case 1: + emote = EMOTE_ONESHOT_EXCLAMATION; + break; + case 2: + emote = EMOTE_ONESHOT_RUDE; + break; + case 3: + emote = EMOTE_ONESHOT_ROAR; + break; + default: + break; } - break; - case RP1_EVENT_ARTHAS1: - talkerEntry = 0, talkerLine = RP1_LINE_ARTHAS1; - break; - case RP1_EVENT_UTHER1: - talkerEntry = NPC_UTHER, talkerLine = RP1_LINE_UTHER1; - break; - case RP1_EVENT_ARTHAS2: - talkerEntry = 0, talkerLine = RP1_LINE_ARTHAS2; - me->GetMotionMaster()->MoveAlongSplineChain(RP1_POINTID_ARTHAS2, RP1_CHAIN_ARTHAS2, true); - if (Creature* uther = me->FindNearestCreature(NPC_UTHER, 100.0f, true)) - uther->GetMotionMaster()->MoveAlongSplineChain(RP1_POINTID_UTHER2, RP1_CHAIN_UTHER2, true); - if (Creature* jaina = me->FindNearestCreature(NPC_JAINA, 100.0f, true)) - jaina->GetMotionMaster()->MoveAlongSplineChain(RP1_POINTID_JAINA2, RP1_CHAIN_JAINA2, true); - break; - case RP1_EVENT_UTHER_FACE: - if (Creature* uther = me->FindNearestCreature(NPC_UTHER, 100.0f, true)) - uther->SetFacingToObject(me); - break; - case RP1_EVENT_JAINA_FACE: - if (Creature* jaina = me->FindNearestCreature(NPC_JAINA, 100.0f, true)) - jaina->SetFacingToObject(me); - break; - case RP1_EVENT_ARTHAS3: + if ((*it)->IsAlive()) + (*it)->HandleEmoteCommand(emote); + } + break; + } + case RP2_EVENT_ARTHAS_MOVE_4: + me->SetFacingTo(2.234021f); // @todo + break; + case RP2_EVENT_ARTHAS3: + talkerEntry = 0, talkerLine = RP2_LINE_ARTHAS3; + break; + case RP2_EVENT_MALGANIS1: + if (Creature* bunny = me->FindNearestCreature(NPC_MALGANIS_BUNNY, 80.0f, true)) + bunny->CastSpell(bunny, SPELL_SHADOWSTEP_VISUAL); + + if (Creature* malganis = instance->instance->SummonCreature(NPC_MALGANIS, ArthasPositions[RP2_MALGANIS_POS])) + { + malganis->CastSpell(malganis, SPELL_SHADOWSTEP_VISUAL); + malganis->AI()->Talk(RP2_LINE_MALGANIS1); + } + break; + case RP2_EVENT_TROOPS_FACE: + if (Creature* malganis = me->FindNearestCreature(NPC_MALGANIS, 80.0f, true)) { - me->SetFacingTo(6.248279f); // @todo migrate - talkerEntry = 0, talkerLine = RP1_LINE_ARTHAS3; std::list troops; - me->GetCreatureListWithEntryInGrid(troops, NPC_FOOTMAN, 100.0f); - me->GetCreatureListWithEntryInGrid(troops, NPC_SORCERESS, 100.0f); - me->GetCreatureListWithEntryInGrid(troops, NPC_KNIGHT, 100.0f); - me->GetCreatureListWithEntryInGrid(troops, NPC_PRIEST, 100.0f); + me->GetCreatureListWithEntryInGrid(troops, NPC_FOOTMAN, 50.0f); + me->GetCreatureListWithEntryInGrid(troops, NPC_PRIEST, 50.0f); for (Creature* unit : troops) if (unit->IsAlive()) - unit->SetFacingToObject(me); - break; + unit->SetFacingToObject(malganis); } - case RP1_EVENT_UTHER2: - talkerEntry = NPC_UTHER, talkerLine = RP1_LINE_UTHER2; - break; - case RP1_EVENT_ARTHAS4: - talkerEntry = 0, talkerLine = RP1_LINE_ARTHAS4; - break; - case RP1_EVENT_UTHER3: - talkerEntry = NPC_UTHER, talkerLine = RP1_LINE_UTHER3; - break; - case RP1_EVENT_ARTHAS_TURN: - if (Creature* uther = me->FindNearestCreature(NPC_UTHER, 100.0f, true)) - me->SetFacingToObject(uther); - break; - case RP1_EVENT_ARTHAS5: - talkerEntry = 0, talkerLine = RP1_LINE_ARTHAS5; - break; - case RP1_EVENT_UTHER4: - talkerEntry = NPC_UTHER, talkerLine = RP1_LINE_UTHER4; - break; - case RP1_EVENT_ARTHAS6: - talkerEntry = 0, talkerLine = RP1_LINE_ARTHAS6; - break; - case RP1_EVENT_UTHER5: - talkerEntry = NPC_UTHER, talkerLine = RP1_LINE_UTHER5; - break; - case RP1_EVENT_ARTHAS7: - talkerEntry = 0, talkerLine = RP1_LINE_ARTHAS7; - break; - case RP1_EVENT_JAINA1: - talkerEntry = NPC_JAINA, talkerLine = RP1_LINE_JAINA1; - break; - case RP1_EVENT_ARTHAS8: - talkerEntry = 0, talkerLine = RP1_LINE_ARTHAS8; - break; - case RP1_EVENT_ARTHAS8_2: - me->HandleEmoteCommand(EMOTE_ONESHOT_EXCLAMATION); - break; - case RP1_EVENT_UTHER6: - talkerEntry = NPC_UTHER, talkerLine = RP1_LINE_UTHER6; - break; - case RP1_EVENT_UTHER_LEAVE: - if (Creature* uther = me->FindNearestCreature(NPC_UTHER, 100.0f, true)) - uther->GetMotionMaster()->MoveAlongSplineChain(RP1_POINTID_UTHER3, RP1_CHAIN_UTHER3, true); - break; - case RP1_EVENT_JAINA_LEAVE: - if (Creature* jaina = me->FindNearestCreature(NPC_JAINA, 100.0f, true)) - jaina->GetMotionMaster()->MoveAlongSplineChain(0, RP1_CHAIN_JAINA3, true); - break; - case RP1_EVENT_ARTHAS9: - talkerEntry = 0, talkerLine = RP1_LINE_ARTHAS9; - if (Creature* jaina = me->FindNearestCreature(NPC_JAINA, 100.0f, true)) - me->SetFacingToObject(jaina); - break; - case RP1_EVENT_JAINA2: - talkerEntry = NPC_JAINA, talkerLine = RP1_LINE_JAINA2; - break; - case RP1_EVENT_JAINA_LEAVE2: - if (Creature* jaina = me->FindNearestCreature(NPC_JAINA, 100.0f, true)) - jaina->GetMotionMaster()->MoveAlongSplineChain(RP1_POINTID_JAINA4, RP1_CHAIN_JAINA4, true); - break; - case RP1_EVENT_ARTHAS_LEAVE: - me->GetMotionMaster()->MoveAlongSplineChain(RP1_POINTID_ARTHAS3, RP1_CHAIN_ARTHAS3, true); - break; - case RP1_EVENT_ARTHAS10: - talkerEntry = 0, talkerLine = RP1_LINE_ARTHAS10; - me->SetFacingTo(3.141593f); // @todo migrate - break; - case RP1_EVENT_ARTHAS_LEAVE2: - me->GetMotionMaster()->MoveAlongSplineChain(RP1_POINTID_ARTHAS4, RP1_CHAIN_ARTHAS4, false); - break; - case RP1_EVENT_FINISHED: - talkerEntry = 0, talkerLine = RP1_LINE_ARTHAS11; - me->SetFacingTo(ArthasPositions[ARTHAS_PURGE_PENDING_POS].GetOrientation()); - instance->SetData(DATA_UTHER_FINISHED, 1); - break; - case RP2_EVENT_ARTHAS_MOVE_1: - me->GetMotionMaster()->MoveAlongSplineChain(RP2_POINTID_ARTHAS1, RP2_CHAIN_ARTHAS1, true); - break; - case RP2_EVENT_CITIZEN1: - if (Creature* citizen = me->FindNearestCreature(NPC_CITIZEN, 100.0f, true)) - { - citizen->GetMotionMaster()->MoveAlongSplineChain(0, RP2_CHAIN_CITIZEN1, true); - citizen->AI()->Talk(RP2_LINE_CITIZEN1, ObjectAccessor::GetUnit(*me, _eventStarterGuid)); - } - break; - case RP2_EVENT_ARTHAS2: - talkerEntry = 0, talkerLine = RP2_LINE_ARTHAS2; - break; - case RP2_EVENT_ARTHAS_MOVE_2: - me->GetMotionMaster()->MoveAlongSplineChain(RP2_POINTID_ARTHAS2, RP2_CHAIN_ARTHAS2, true); - break; - case RP2_EVENT_CITIZEN2: - talkerEntry = NPC_CITIZEN, talkerLine = RP2_LINE_CITIZEN2; - break; - case RP2_EVENT_KILL1: - if (Creature* citizen = me->FindNearestCreature(NPC_CITIZEN, 100.0f, true)) - DoCast(citizen, SPELL_CRUSADER_STRIKE); - if (Creature* resident = me->FindNearestCreature(NPC_RESIDENT, 100.0f, true)) - { - resident->SetFlag(UNIT_NPC_EMOTESTATE, EMOTE_STATE_COWER); - resident->AI()->Talk(RP2_LINE_RESIDENT1, ObjectAccessor::GetUnit(*me, _eventStarterGuid)); - } - break; - case RP2_EVENT_ARTHAS_MOVE_3: - me->GetMotionMaster()->MoveAlongSplineChain(RP2_POINTID_ARTHAS3, RP2_CHAIN_ARTHAS3, true); - break; - case RP2_EVENT_KILL2: - if (Creature* resident = me->FindNearestCreature(NPC_RESIDENT, 100.0f, true)) - DoCast(resident, SPELL_CRUSADER_STRIKE); - break; - case RP2_EVENT_REACT1: - case RP2_EVENT_REACT2: - case RP2_EVENT_REACT3: - case RP2_EVENT_REACT4: - case RP2_EVENT_REACT5: + break; + case RP2_EVENT_ARTHAS_FACE: + if (Creature* malganis = me->FindNearestCreature(NPC_MALGANIS, 80.0f, true)) + me->SetFacingToObject(malganis); + break; + case RP2_EVENT_MALGANIS2: + talkerEntry = NPC_MALGANIS, talkerLine = RP2_LINE_MALGANIS2; + break; + case RP2_EVENT_MALGANIS_LEAVE1: + if (Creature* malganis = me->FindNearestCreature(NPC_MALGANIS, 80.0f, true)) + malganis->CastSpell(malganis, SPELL_SHADOWSTEP_VISUAL); + break; + case RP2_EVENT_MALGANIS_LEAVE2: + if (Creature* malganis = me->FindNearestCreature(NPC_MALGANIS, 80.0f, true)) + malganis->DespawnOrUnsummon(0); + if (Creature* bunny = me->FindNearestCreature(NPC_MALGANIS_BUNNY, 80.0f, true)) + bunny->CastSpell(bunny, SPELL_SHADOWSTEP_VISUAL); + break; + case RP2_EVENT_ARTHAS4: + talkerEntry = 0, talkerLine = RP2_LINE_ARTHAS4; + break; + case RP2_EVENT_ARTHAS4_2: + me->HandleEmoteCommand(EMOTE_ONESHOT_EXCLAMATION); + break; + case RP2_EVENT_ARTHAS5: + talkerEntry = 0, talkerLine = RP2_LINE_ARTHAS5; + break; + case RP2_EVENT_ARTHAS5_2: + case RP2_EVENT_ARTHAS5_3: + me->HandleEmoteCommand(EMOTE_ONESHOT_TALK); + break; + case RP2_EVENT_WAVE_START: + instance->SetData(DATA_START_WAVES, 1); + break; + case EVENT_TOWN_HALL_REACHED: + me->DespawnOrUnsummon(); + instance->SetData(DATA_REACH_TOWN_HALL, 1); + break; + case RP3_EVENT_RESIDENT_FACE: + if (Creature* infinite = me->FindNearestCreature(NPC_RESIDENT_INFINITE, 100.0f, true)) + infinite->SetFacingToObject(me); + break; + case RP3_EVENT_ARTHAS_FACE: + me->SetFacingTo(0.541052f); // @todo + break; + case RP3_EVENT_CITIZEN1: + talkerEntry = NPC_CITIZEN_INFINITE, talkerLine = RP3_LINE_CITIZEN1; + break; + case RP3_EVENT_ARTHAS2: + talkerEntry = 0, talkerLine = RP3_LINE_ARTHAS2; + me->GetMotionMaster()->MoveAlongSplineChain(RP3_POINTID_ARTHAS2, RP3_CHAIN_ARTHAS2, true); + break; + case RP3_EVENT_ARTHAS_KILL: + if (Creature* citizen = me->FindNearestCreature(NPC_CITIZEN_INFINITE, 100.0f, true)) + DoCast(citizen, SPELL_CRUSADER_STRIKE); + break; + case RP3_EVENT_INFINITE_LAUGH: + if (Creature* citizen = me->FindNearestCreature(NPC_CITIZEN_INFINITE, 100.0f, true)) + citizen->HandleEmoteCommand(EMOTE_ONESHOT_LAUGH); + break; + case RP3_EVENT_ARTHAS3: + talkerEntry = 0, talkerLine = RP3_LINE_ARTHAS3; + break; + case RP3_EVENT_CITIZEN2: + talkerEntry = NPC_CITIZEN_INFINITE, talkerLine = RP3_LINE_CITIZEN2; + break; + case RP3_EVENT_TRANSFORM1: + case RP3_EVENT_TRANSFORM3: + if (Creature* citizen = me->FindNearestCreature(NPC_CITIZEN_INFINITE, 100.0f, true)) { - std::list nearbyVictims; - me->GetCreatureListWithEntryInGrid(nearbyVictims, urand(0, 1) ? NPC_CITIZEN : NPC_RESIDENT, 60.0f); - if (!nearbyVictims.empty()) - { - std::list::iterator it = nearbyVictims.begin(); - std::advance(it, urand(0, nearbyVictims.size()-1)); - Emote emote = EMOTE_ONESHOT_NONE; - switch (urand(0, 3)) - { - case 0: - emote = EMOTE_ONESHOT_TALK; - break; - case 1: - emote = EMOTE_ONESHOT_EXCLAMATION; - break; - case 2: - emote = EMOTE_ONESHOT_RUDE; - break; - case 3: - emote = EMOTE_ONESHOT_ROAR; - break; - default: - break; - } - if ((*it)->IsAlive()) - (*it)->HandleEmoteCommand(emote); - } - break; + citizen->CastSpell(citizen, SPELL_TRANSFORM_VISUAL); + citizen->UpdateEntry(NPC_INFINITE_HUNTER); } - case RP2_EVENT_ARTHAS_MOVE_4: - me->SetFacingTo(2.234021f); // @todo - break; - case RP2_EVENT_ARTHAS3: - talkerEntry = 0, talkerLine = RP2_LINE_ARTHAS3; - break; - case RP2_EVENT_MALGANIS1: - if (Creature* bunny = me->FindNearestCreature(NPC_MALGANIS_BUNNY, 80.0f, true)) - bunny->CastSpell(bunny, SPELL_SHADOWSTEP_VISUAL); - - if (Creature* malganis = instance->instance->SummonCreature(NPC_MALGANIS, ArthasPositions[RP2_MALGANIS_POS])) - { - malganis->CastSpell(malganis, SPELL_SHADOWSTEP_VISUAL); - malganis->AI()->Talk(RP2_LINE_MALGANIS1); - } - break; - case RP2_EVENT_TROOPS_FACE: - if (Creature* malganis = me->FindNearestCreature(NPC_MALGANIS, 80.0f, true)) - { - std::list troops; - me->GetCreatureListWithEntryInGrid(troops, NPC_FOOTMAN, 50.0f); - me->GetCreatureListWithEntryInGrid(troops, NPC_PRIEST, 50.0f); - for (Creature* unit : troops) - if (unit->IsAlive()) - unit->SetFacingToObject(malganis); - } - break; - case RP2_EVENT_ARTHAS_FACE: - if (Creature* malganis = me->FindNearestCreature(NPC_MALGANIS, 80.0f, true)) - me->SetFacingToObject(malganis); - break; - case RP2_EVENT_MALGANIS2: - talkerEntry = NPC_MALGANIS, talkerLine = RP2_LINE_MALGANIS2; - break; - case RP2_EVENT_MALGANIS_LEAVE1: - if (Creature* malganis = me->FindNearestCreature(NPC_MALGANIS, 80.0f, true)) - malganis->CastSpell(malganis, SPELL_SHADOWSTEP_VISUAL); - break; - case RP2_EVENT_MALGANIS_LEAVE2: - if (Creature* malganis = me->FindNearestCreature(NPC_MALGANIS, 80.0f, true)) - malganis->DespawnOrUnsummon(0); - if (Creature* bunny = me->FindNearestCreature(NPC_MALGANIS_BUNNY, 80.0f, true)) - bunny->CastSpell(bunny, SPELL_SHADOWSTEP_VISUAL); - break; - case RP2_EVENT_ARTHAS4: - talkerEntry = 0, talkerLine = RP2_LINE_ARTHAS4; - break; - case RP2_EVENT_ARTHAS4_2: - me->HandleEmoteCommand(EMOTE_ONESHOT_EXCLAMATION); - break; - case RP2_EVENT_ARTHAS5: - talkerEntry = 0, talkerLine = RP2_LINE_ARTHAS5; - break; - case RP2_EVENT_ARTHAS5_2: - case RP2_EVENT_ARTHAS5_3: - me->HandleEmoteCommand(EMOTE_ONESHOT_TALK); - break; - case RP2_EVENT_WAVE_START: - instance->SetData(DATA_START_WAVES, 1); - break; - case EVENT_TOWN_HALL_REACHED: - me->DespawnOrUnsummon(); - instance->SetData(DATA_REACH_TOWN_HALL, 1); - break; - case RP3_EVENT_RESIDENT_FACE: - if (Creature* infinite = me->FindNearestCreature(NPC_RESIDENT_INFINITE, 100.0f, true)) - infinite->SetFacingToObject(me); - break; - case RP3_EVENT_ARTHAS_FACE: - me->SetFacingTo(0.541052f); // @todo - break; - case RP3_EVENT_CITIZEN1: - talkerEntry = NPC_CITIZEN_INFINITE, talkerLine = RP3_LINE_CITIZEN1; - break; - case RP3_EVENT_ARTHAS2: - talkerEntry = 0, talkerLine = RP3_LINE_ARTHAS2; - me->GetMotionMaster()->MoveAlongSplineChain(RP3_POINTID_ARTHAS2, RP3_CHAIN_ARTHAS2, true); - break; - case RP3_EVENT_ARTHAS_KILL: - if (Creature* citizen = me->FindNearestCreature(NPC_CITIZEN_INFINITE, 100.0f, true)) - DoCast(citizen, SPELL_CRUSADER_STRIKE); - break; - case RP3_EVENT_INFINITE_LAUGH: - if (Creature* citizen = me->FindNearestCreature(NPC_CITIZEN_INFINITE, 100.0f, true)) - citizen->HandleEmoteCommand(EMOTE_ONESHOT_LAUGH); - break; - case RP3_EVENT_ARTHAS3: - talkerEntry = 0, talkerLine = RP3_LINE_ARTHAS3; - break; - case RP3_EVENT_CITIZEN2: - talkerEntry = NPC_CITIZEN_INFINITE, talkerLine = RP3_LINE_CITIZEN2; - break; - case RP3_EVENT_TRANSFORM1: - case RP3_EVENT_TRANSFORM3: - if (Creature* citizen = me->FindNearestCreature(NPC_CITIZEN_INFINITE, 100.0f, true)) - { - citizen->CastSpell(citizen, SPELL_TRANSFORM_VISUAL); - citizen->UpdateEntry(NPC_INFINITE_HUNTER); - } - break; - case RP3_EVENT_TRANSFORM2: - if (Creature* resident = me->FindNearestCreature(NPC_RESIDENT_INFINITE, 100.0f, true)) - { - resident->CastSpell(resident, SPELL_TRANSFORM_VISUAL); - resident->UpdateEntry(NPC_INFINITE_AGENT); - } - break; - case RP3_EVENT_AGGRO: - EngageInfinites(); - ScheduleActionOOC(RP3_ACTION_AFTER_INITIAL); - break; - case RP3_EVENT_ARTHAS4: - talkerEntry = 0, talkerLine = RP3_LINE_ARTHAS4; - break; - case RP3_EVENT_ARTHAS_MOVE_1: - me->GetMotionMaster()->MoveAlongSplineChain(RP3_POINTID_ARTHAS3, RP3_CHAIN_ARTHAS3, false); - break; - case RP3_EVENT_ARTHAS_MOVE_1_2: - talkerEntry = 0, talkerLine = RP3_LINE_ARTHAS10; - me->GetMotionMaster()->MoveAlongSplineChain(0, RP3_CHAIN_ARTHAS3_2, true); - break; - case RP3_EVENT_SPAWN1: + break; + case RP3_EVENT_TRANSFORM2: + if (Creature* resident = me->FindNearestCreature(NPC_RESIDENT_INFINITE, 100.0f, true)) { - uint8 extra = urand(0, 2); // 0 = extra adversary, 1 = extra hunter, 2 = extra agent - if (Creature* spawn1 = instance->instance->SummonCreature(NPC_INFINITE_ADVERSARY, ArthasPositions[RP3_SPAWN1_LOC1])) - MoveInfiniteOnSpawn(spawn1, RP3_CHAIN_SPAWN1_LOC1); - if (Creature* spawn2 = instance->instance->SummonCreature(extra ? NPC_INFINITE_HUNTER : NPC_INFINITE_ADVERSARY, ArthasPositions[RP3_SPAWN1_LOC2])) - MoveInfiniteOnSpawn(spawn2, RP3_CHAIN_SPAWN1_LOC2); - if (Creature* spawn3 = instance->instance->SummonCreature(extra < 2 ? NPC_INFINITE_HUNTER : NPC_INFINITE_AGENT, ArthasPositions[RP3_SPAWN1_LOC3])) - MoveInfiniteOnSpawn(spawn3, RP3_CHAIN_SPAWN1_LOC3); - if (Creature* spawn4 = instance->instance->SummonCreature(NPC_INFINITE_AGENT, ArthasPositions[RP3_SPAWN1_LOC4])) - MoveInfiniteOnSpawn(spawn4, RP3_CHAIN_SPAWN1_LOC4); - if (Creature* rift = instance->instance->SummonCreature(NPC_TIME_RIFT, ArthasPositions[RP3_SPAWN1_RIFT])) - rift->DespawnOrUnsummon(Seconds(4)); - break; + resident->CastSpell(resident, SPELL_TRANSFORM_VISUAL); + resident->UpdateEntry(NPC_INFINITE_AGENT); } - case RP3_EVENT_SPAWN1_FACE: - case RP3_EVENT_SPAWN2_FACE: - case RP3_EVENT_SPAWN3_FACE: + break; + case RP3_EVENT_AGGRO: + EngageInfinites(); + ScheduleActionOOC(RP3_ACTION_AFTER_INITIAL); + break; + case RP3_EVENT_ARTHAS4: + talkerEntry = 0, talkerLine = RP3_LINE_ARTHAS4; + break; + case RP3_EVENT_ARTHAS_MOVE_1: + me->GetMotionMaster()->MoveAlongSplineChain(RP3_POINTID_ARTHAS3, RP3_CHAIN_ARTHAS3, false); + break; + case RP3_EVENT_ARTHAS_MOVE_1_2: + talkerEntry = 0, talkerLine = RP3_LINE_ARTHAS10; + me->GetMotionMaster()->MoveAlongSplineChain(0, RP3_CHAIN_ARTHAS3_2, true); + break; + case RP3_EVENT_SPAWN1: + { + uint8 extra = urand(0, 2); // 0 = extra adversary, 1 = extra hunter, 2 = extra agent + if (Creature* spawn1 = instance->instance->SummonCreature(NPC_INFINITE_ADVERSARY, ArthasPositions[RP3_SPAWN1_LOC1])) + MoveInfiniteOnSpawn(spawn1, RP3_CHAIN_SPAWN1_LOC1); + if (Creature* spawn2 = instance->instance->SummonCreature(extra ? NPC_INFINITE_HUNTER : NPC_INFINITE_ADVERSARY, ArthasPositions[RP3_SPAWN1_LOC2])) + MoveInfiniteOnSpawn(spawn2, RP3_CHAIN_SPAWN1_LOC2); + if (Creature* spawn3 = instance->instance->SummonCreature(extra < 2 ? NPC_INFINITE_HUNTER : NPC_INFINITE_AGENT, ArthasPositions[RP3_SPAWN1_LOC3])) + MoveInfiniteOnSpawn(spawn3, RP3_CHAIN_SPAWN1_LOC3); + if (Creature* spawn4 = instance->instance->SummonCreature(NPC_INFINITE_AGENT, ArthasPositions[RP3_SPAWN1_LOC4])) + MoveInfiniteOnSpawn(spawn4, RP3_CHAIN_SPAWN1_LOC4); + if (Creature* rift = instance->instance->SummonCreature(NPC_TIME_RIFT, ArthasPositions[RP3_SPAWN1_RIFT])) + rift->DespawnOrUnsummon(Seconds(4)); + break; + } + case RP3_EVENT_SPAWN1_FACE: + case RP3_EVENT_SPAWN2_FACE: + case RP3_EVENT_SPAWN3_FACE: + { + std::list infinites; + me->GetCreatureListWithEntryInGrid(infinites, NPC_INFINITE_ADVERSARY, 100.0f); + me->GetCreatureListWithEntryInGrid(infinites, NPC_INFINITE_AGENT, 100.0f); + me->GetCreatureListWithEntryInGrid(infinites, NPC_INFINITE_HUNTER, 100.0f); + for (Creature* target : infinites) + if (target->IsAlive()) + target->SetFacingToObject(me); + break; + } + case RP3_EVENT_SPAWN1_AGGRO: + EngageInfinites(); + ScheduleActionOOC(RP3_ACTION_AFTER_SPAWN1); + break; + case RP3_EVENT_ARTHAS11: + talkerEntry = 0, talkerLine = RP3_LINE_ARTHAS11; + break; + case RP3_EVENT_ARTHAS_MOVE_2: + me->GetMotionMaster()->MoveAlongSplineChain(RP3_POINTID_ARTHAS4, RP3_CHAIN_ARTHAS4, false); + break; + case RP3_EVENT_ARTHAS20: + talkerEntry = 0, talkerLine = RP3_LINE_ARTHAS20; + break; + case RP3_EVENT_SPAWN2: + { + uint8 extra = urand(0, 2); // 0 = extra adversary, 1 = extra hunter, 2 = extra agent + if (Creature* SPAWN2 = instance->instance->SummonCreature(NPC_INFINITE_ADVERSARY, ArthasPositions[RP3_SPAWN2_LOC1])) + MoveInfiniteOnSpawn(SPAWN2, RP3_CHAIN_SPAWN2_LOC1); + if (Creature* spawn2 = instance->instance->SummonCreature(extra ? NPC_INFINITE_HUNTER : NPC_INFINITE_ADVERSARY, ArthasPositions[RP3_SPAWN2_LOC2])) + MoveInfiniteOnSpawn(spawn2, RP3_CHAIN_SPAWN2_LOC2); + if (Creature* spawn3 = instance->instance->SummonCreature(extra < 2 ? NPC_INFINITE_HUNTER : NPC_INFINITE_AGENT, ArthasPositions[RP3_SPAWN2_LOC3])) + MoveInfiniteOnSpawn(spawn3, RP3_CHAIN_SPAWN2_LOC3); + if (Creature* spawn4 = instance->instance->SummonCreature(NPC_INFINITE_AGENT, ArthasPositions[RP3_SPAWN2_LOC4])) + MoveInfiniteOnSpawn(spawn4, RP3_CHAIN_SPAWN2_LOC4); + if (Creature* rift1 = instance->instance->SummonCreature(NPC_TIME_RIFT, ArthasPositions[RP3_SPAWN2_RIFT1])) + rift1->DespawnOrUnsummon(Seconds(5)); + if (Creature* rift2 = instance->instance->SummonCreature(NPC_TIME_RIFT, ArthasPositions[RP3_SPAWN2_RIFT2])) + rift2->DespawnOrUnsummon(Seconds(5)); + break; + } + case RP3_EVENT_ARTHAS_FACE2: + me->SetFacingTo(1.762783f); // @todo + break; + case RP3_EVENT_SPAWN2_AGGRO: + EngageInfinites(); + ScheduleActionOOC(RP3_ACTION_AFTER_SPAWN2); + break; + case RP3_EVENT_ARTHAS21: + talkerEntry = 0, talkerLine = RP3_LINE_ARTHAS21; + break; + case RP3_EVENT_ARTHAS_MOVE_3: + me->GetMotionMaster()->MoveAlongSplineChain(RP3_POINTID_ARTHAS5, RP3_CHAIN_ARTHAS5, false); + break; + case RP3_EVENT_SPAWN3: + { + uint8 extra = urand(0, 2); // 0 = extra adversary, 1 = extra hunter, 2 = extra agent + if (Creature* SPAWN3 = instance->instance->SummonCreature(NPC_INFINITE_ADVERSARY, ArthasPositions[RP3_SPAWN3_LOC1])) + MoveInfiniteOnSpawn(SPAWN3, RP3_CHAIN_SPAWN3_LOC1); + if (Creature* SPAWN3 = instance->instance->SummonCreature(extra ? NPC_INFINITE_HUNTER : NPC_INFINITE_ADVERSARY, ArthasPositions[RP3_SPAWN3_LOC2])) + MoveInfiniteOnSpawn(SPAWN3, RP3_CHAIN_SPAWN3_LOC2); + if (Creature* spawn3 = instance->instance->SummonCreature(extra < 2 ? NPC_INFINITE_HUNTER : NPC_INFINITE_AGENT, ArthasPositions[RP3_SPAWN3_LOC3])) + MoveInfiniteOnSpawn(spawn3, RP3_CHAIN_SPAWN3_LOC3); + if (Creature* spawn4 = instance->instance->SummonCreature(NPC_INFINITE_AGENT, ArthasPositions[RP3_SPAWN3_LOC4])) + MoveInfiniteOnSpawn(spawn4, RP3_CHAIN_SPAWN3_LOC4); + if (Creature* rift1 = instance->instance->SummonCreature(NPC_TIME_RIFT, ArthasPositions[RP3_SPAWN3_RIFT1])) + rift1->DespawnOrUnsummon(Seconds(5)); + if (Creature* rift2 = instance->instance->SummonCreature(NPC_TIME_RIFT, ArthasPositions[RP3_SPAWN3_RIFT2])) + rift2->DespawnOrUnsummon(Seconds(5)); + break; + } + case RP3_EVENT_ARTHAS30: + talkerEntry = 0, talkerLine = RP3_LINE_ARTHAS30; + break; + case RP3_EVENT_SPAWN3_AGGRO: + EngageInfinites(); + ScheduleActionOOC(RP3_ACTION_AFTER_SPAWN3); + break; + case RP3_EVENT_EPOCH_SPAWN: + if (Creature* epoch = instance->instance->SummonCreature(NPC_EPOCH, ArthasPositions[RP3_EPOCH_SPAWN])) + epoch->GetMotionMaster()->MoveAlongSplineChain(0, RP3_CHAIN_EPOCH, false); + if (Creature* rift = instance->instance->SummonCreature(NPC_TIME_RIFT_LARGE, ArthasPositions[RP3_EPOCH_RIFT])) + rift->DespawnOrUnsummon(Seconds(27)); + break; + case RP3_EVENT_ARTHAS31: + talkerEntry = 0, talkerLine = RP3_LINE_ARTHAS31; + me->SetFacingTo(6.073746f); // @todo + break; + case RP3_EVENT_EPOCH_FACE: + if (Creature* epoch = me->FindNearestCreature(NPC_EPOCH, 100.0f, true)) + epoch->SetFacingToObject(me); + break; + case RP3_EVENT_EPOCH1: + talkerEntry = NPC_EPOCH, talkerLine = RP3_LINE_EPOCH1; + break; + case RP3_EVENT_ARTHAS32: + talkerEntry = 0, talkerLine = RP3_LINE_ARTHAS32; + break; + case RP3_EVENT_ARTHAS32_2: + me->HandleEmoteCommand(EMOTE_ONESHOT_POINT_NO_SHEATHE); + break; + case RP3_EVENT_EPOCH_AGGRO: + talkerEntry = NPC_EPOCH, talkerLine = RP3_LINE_EPOCH2; + if (Creature* epoch = me->FindNearestCreature(NPC_EPOCH, 100.0f, true)) { - std::list infinites; - me->GetCreatureListWithEntryInGrid(infinites, NPC_INFINITE_ADVERSARY, 100.0f); - me->GetCreatureListWithEntryInGrid(infinites, NPC_INFINITE_AGENT, 100.0f); - me->GetCreatureListWithEntryInGrid(infinites, NPC_INFINITE_HUNTER, 100.0f); - for (Creature* target : infinites) - if (target->IsAlive()) - target->SetFacingToObject(me); - break; + epoch->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC | UNIT_FLAG_IMMUNE_TO_PC); + AttackStart(epoch); + if (epoch->IsAIEnabled()) + epoch->AI()->AttackStart(me); } - case RP3_EVENT_SPAWN1_AGGRO: - EngageInfinites(); - ScheduleActionOOC(RP3_ACTION_AFTER_SPAWN1); - break; - case RP3_EVENT_ARTHAS11: - talkerEntry = 0, talkerLine = RP3_LINE_ARTHAS11; - break; - case RP3_EVENT_ARTHAS_MOVE_2: - me->GetMotionMaster()->MoveAlongSplineChain(RP3_POINTID_ARTHAS4, RP3_CHAIN_ARTHAS4, false); - break; - case RP3_EVENT_ARTHAS20: - talkerEntry = 0, talkerLine = RP3_LINE_ARTHAS20; - break; - case RP3_EVENT_SPAWN2: + ScheduleActionOOC(RP3_ACTION_AFTER_EPOCH); + break; + case RP4_EVENT_ARTHAS2: + me->SetFacingTo(0.226893f); // @todo + talkerEntry = 0, talkerLine = RP4_LINE_ARTHAS2; + break; + case RP4_EVENT_HIDDEN_PASSAGE: + if (GameObject* passage = me->FindNearestGameObject(GO_HIDDEN_PASSAGE, 100.0f)) + passage->SetGoState(GO_STATE_ACTIVE); + break; + case RP4_EVENT_ARTHAS3: + talkerEntry = 0, talkerLine = RP4_LINE_ARTHAS3; + me->GetMotionMaster()->MoveAlongSplineChain(RP4_POINTID_ARTHAS2, RP4_CHAIN_ARTHAS2, false); + break; + case RP4_EVENT_GAUNTLET_REACHED: + me->DespawnOrUnsummon(); + instance->SetData(DATA_GAUNTLET_REACHED, 1); + break; + case RP4_EVENT_ARTHAS_MOVE: + me->GetMotionMaster()->MoveAlongSplineChain(RP4_POINTID_GAUNTLET1, RP4_CHAIN_GAUNTLET1, false); + break; + case RP4_EVENT_ARTHAS11: + talkerEntry = 0, talkerLine = RP4_LINE_ARTHAS11; + break; + case RP4_EVENT_ARTHAS_FACE: + me->SetFacingTo(1.780236f); // @todo + break; + case RP4_EVENT_ARTHAS12: + talkerEntry = 0, talkerLine = RP4_LINE_ARTHAS12; + break; + case RP4_EVENT_GAUNTLET_RESUME: + me->GetMotionMaster()->MoveAlongSplineChain(RP4_POINTID_GAUNTLET2, RP4_CHAIN_GAUNTLET2, false); + break; + case RP4_EVENT_ARTHAS13: + talkerEntry = 0, talkerLine = RP4_LINE_ARTHAS13; + me->SetFacingTo(ArthasPositions[ARTHAS_GAUNTLET_END_POS].GetOrientation()); + break; + case RP4_EVENT_GAUNTLET_DONE: + me->HandleEmoteCommand(EMOTE_ONESHOT_POINT_NO_SHEATHE); + instance->SetData(DATA_GAUNTLET_DONE, 1); + break; + case RP5_EVENT_ARTHAS2: + talkerEntry = 0, talkerLine = RP5_LINE_ARTHAS2; + if (Creature* malganis = me->FindNearestCreature(NPC_MALGANIS, 100.0f, true)) + me->SetFacingToObject(malganis); + break; + case RP5_EVENT_MALGANIS1: + if (Creature* malganis = me->FindNearestCreature(NPC_MALGANIS, 100.0f, true)) { - uint8 extra = urand(0, 2); // 0 = extra adversary, 1 = extra hunter, 2 = extra agent - if (Creature* SPAWN2 = instance->instance->SummonCreature(NPC_INFINITE_ADVERSARY, ArthasPositions[RP3_SPAWN2_LOC1])) - MoveInfiniteOnSpawn(SPAWN2, RP3_CHAIN_SPAWN2_LOC1); - if (Creature* spawn2 = instance->instance->SummonCreature(extra ? NPC_INFINITE_HUNTER : NPC_INFINITE_ADVERSARY, ArthasPositions[RP3_SPAWN2_LOC2])) - MoveInfiniteOnSpawn(spawn2, RP3_CHAIN_SPAWN2_LOC2); - if (Creature* spawn3 = instance->instance->SummonCreature(extra < 2 ? NPC_INFINITE_HUNTER : NPC_INFINITE_AGENT, ArthasPositions[RP3_SPAWN2_LOC3])) - MoveInfiniteOnSpawn(spawn3, RP3_CHAIN_SPAWN2_LOC3); - if (Creature* spawn4 = instance->instance->SummonCreature(NPC_INFINITE_AGENT, ArthasPositions[RP3_SPAWN2_LOC4])) - MoveInfiniteOnSpawn(spawn4, RP3_CHAIN_SPAWN2_LOC4); - if (Creature* rift1 = instance->instance->SummonCreature(NPC_TIME_RIFT, ArthasPositions[RP3_SPAWN2_RIFT1])) - rift1->DespawnOrUnsummon(Seconds(5)); - if (Creature* rift2 = instance->instance->SummonCreature(NPC_TIME_RIFT, ArthasPositions[RP3_SPAWN2_RIFT2])) - rift2->DespawnOrUnsummon(Seconds(5)); - break; + malganis->AI()->Talk(RP5_LINE_MALGANIS1, ObjectAccessor::GetUnit(*malganis, _eventStarterGuid)); + malganis->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC | UNIT_FLAG_IMMUNE_TO_PC); + AttackStart(malganis); + if (malganis->IsAIEnabled()) + malganis->AI()->AttackStart(me); } - case RP3_EVENT_ARTHAS_FACE2: - me->SetFacingTo(1.762783f); // @todo - break; - case RP3_EVENT_SPAWN2_AGGRO: - EngageInfinites(); - ScheduleActionOOC(RP3_ACTION_AFTER_SPAWN2); - break; - case RP3_EVENT_ARTHAS21: - talkerEntry = 0, talkerLine = RP3_LINE_ARTHAS21; - break; - case RP3_EVENT_ARTHAS_MOVE_3: - me->GetMotionMaster()->MoveAlongSplineChain(RP3_POINTID_ARTHAS5, RP3_CHAIN_ARTHAS5, false); - break; - case RP3_EVENT_SPAWN3: + ScheduleActionOOC(RP5_ACTION_AFTER_MALGANIS); + break; + case RP5_EVENT_MALGANIS_DONE: + if (Creature* malganis = me->FindNearestCreature(NPC_MALGANIS, 100.0f, true)) { - uint8 extra = urand(0, 2); // 0 = extra adversary, 1 = extra hunter, 2 = extra agent - if (Creature* SPAWN3 = instance->instance->SummonCreature(NPC_INFINITE_ADVERSARY, ArthasPositions[RP3_SPAWN3_LOC1])) - MoveInfiniteOnSpawn(SPAWN3, RP3_CHAIN_SPAWN3_LOC1); - if (Creature* SPAWN3 = instance->instance->SummonCreature(extra ? NPC_INFINITE_HUNTER : NPC_INFINITE_ADVERSARY, ArthasPositions[RP3_SPAWN3_LOC2])) - MoveInfiniteOnSpawn(SPAWN3, RP3_CHAIN_SPAWN3_LOC2); - if (Creature* spawn3 = instance->instance->SummonCreature(extra < 2 ? NPC_INFINITE_HUNTER : NPC_INFINITE_AGENT, ArthasPositions[RP3_SPAWN3_LOC3])) - MoveInfiniteOnSpawn(spawn3, RP3_CHAIN_SPAWN3_LOC3); - if (Creature* spawn4 = instance->instance->SummonCreature(NPC_INFINITE_AGENT, ArthasPositions[RP3_SPAWN3_LOC4])) - MoveInfiniteOnSpawn(spawn4, RP3_CHAIN_SPAWN3_LOC4); - if (Creature* rift1 = instance->instance->SummonCreature(NPC_TIME_RIFT, ArthasPositions[RP3_SPAWN3_RIFT1])) - rift1->DespawnOrUnsummon(Seconds(5)); - if (Creature* rift2 = instance->instance->SummonCreature(NPC_TIME_RIFT, ArthasPositions[RP3_SPAWN3_RIFT2])) - rift2->DespawnOrUnsummon(Seconds(5)); - break; + malganis->SetFacingToObject(me); + malganis->CastSpell(malganis, SPELL_MALGANIS_QUEST_CREDIT, true); + malganis->CastSpell(malganis, SPELL_MALGANIS_KILL_CREDIT, true); + if (GameObject* chest = malganis->FindNearestGameObject(RAID_MODE(GO_CHEST_NORMAL, GO_CHEST_HEROIC), 100.0f)) + chest->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); } - case RP3_EVENT_ARTHAS30: - talkerEntry = 0, talkerLine = RP3_LINE_ARTHAS30; - break; - case RP3_EVENT_SPAWN3_AGGRO: - EngageInfinites(); - ScheduleActionOOC(RP3_ACTION_AFTER_SPAWN3); - break; - case RP3_EVENT_EPOCH_SPAWN: - if (Creature* epoch = instance->instance->SummonCreature(NPC_EPOCH, ArthasPositions[RP3_EPOCH_SPAWN])) - epoch->GetMotionMaster()->MoveAlongSplineChain(0, RP3_CHAIN_EPOCH, false); - if (Creature* rift = instance->instance->SummonCreature(NPC_TIME_RIFT_LARGE, ArthasPositions[RP3_EPOCH_RIFT])) - rift->DespawnOrUnsummon(Seconds(27)); - break; - case RP3_EVENT_ARTHAS31: - talkerEntry = 0, talkerLine = RP3_LINE_ARTHAS31; - me->SetFacingTo(6.073746f); // @todo - break; - case RP3_EVENT_EPOCH_FACE: - if (Creature* epoch = me->FindNearestCreature(NPC_EPOCH, 100.0f, true)) - epoch->SetFacingToObject(me); - break; - case RP3_EVENT_EPOCH1: - talkerEntry = NPC_EPOCH, talkerLine = RP3_LINE_EPOCH1; - break; - case RP3_EVENT_ARTHAS32: - talkerEntry = 0, talkerLine = RP3_LINE_ARTHAS32; - break; - case RP3_EVENT_ARTHAS32_2: - me->HandleEmoteCommand(EMOTE_ONESHOT_POINT_NO_SHEATHE); - break; - case RP3_EVENT_EPOCH_AGGRO: - talkerEntry = NPC_EPOCH, talkerLine = RP3_LINE_EPOCH2; - if (Creature* epoch = me->FindNearestCreature(NPC_EPOCH, 100.0f, true)) - { - epoch->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC | UNIT_FLAG_IMMUNE_TO_PC); - AttackStart(epoch); - if (epoch->IsAIEnabled()) - epoch->AI()->AttackStart(me); - } - ScheduleActionOOC(RP3_ACTION_AFTER_EPOCH); - break; - case RP4_EVENT_ARTHAS2: - me->SetFacingTo(0.226893f); // @todo - talkerEntry = 0, talkerLine = RP4_LINE_ARTHAS2; - break; - case RP4_EVENT_HIDDEN_PASSAGE: - if (GameObject* passage = me->FindNearestGameObject(GO_HIDDEN_PASSAGE, 100.0f)) - passage->SetGoState(GO_STATE_ACTIVE); - break; - case RP4_EVENT_ARTHAS3: - talkerEntry = 0, talkerLine = RP4_LINE_ARTHAS3; - me->GetMotionMaster()->MoveAlongSplineChain(RP4_POINTID_ARTHAS2, RP4_CHAIN_ARTHAS2, false); - break; - case RP4_EVENT_GAUNTLET_REACHED: - me->DespawnOrUnsummon(); - instance->SetData(DATA_GAUNTLET_REACHED, 1); - break; - case RP4_EVENT_ARTHAS_MOVE: - me->GetMotionMaster()->MoveAlongSplineChain(RP4_POINTID_GAUNTLET1, RP4_CHAIN_GAUNTLET1, false); - break; - case RP4_EVENT_ARTHAS11: - talkerEntry = 0, talkerLine = RP4_LINE_ARTHAS11; - break; - case RP4_EVENT_ARTHAS_FACE: - me->SetFacingTo(1.780236f); // @todo - break; - case RP4_EVENT_ARTHAS12: - talkerEntry = 0, talkerLine = RP4_LINE_ARTHAS12; - break; - case RP4_EVENT_GAUNTLET_RESUME: - me->GetMotionMaster()->MoveAlongSplineChain(RP4_POINTID_GAUNTLET2, RP4_CHAIN_GAUNTLET2, false); - break; - case RP4_EVENT_ARTHAS13: - talkerEntry = 0, talkerLine = RP4_LINE_ARTHAS13; - me->SetFacingTo(ArthasPositions[ARTHAS_GAUNTLET_END_POS].GetOrientation()); - break; - case RP4_EVENT_GAUNTLET_DONE: - me->HandleEmoteCommand(EMOTE_ONESHOT_POINT_NO_SHEATHE); - instance->SetData(DATA_GAUNTLET_DONE, 1); - break; - case RP5_EVENT_ARTHAS2: - talkerEntry = 0, talkerLine = RP5_LINE_ARTHAS2; - if (Creature* malganis = me->FindNearestCreature(NPC_MALGANIS, 100.0f, true)) - me->SetFacingToObject(malganis); - break; - case RP5_EVENT_MALGANIS1: - if (Creature* malganis = me->FindNearestCreature(NPC_MALGANIS, 100.0f, true)) - { - malganis->AI()->Talk(RP5_LINE_MALGANIS1, ObjectAccessor::GetUnit(*malganis, _eventStarterGuid)); - malganis->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC | UNIT_FLAG_IMMUNE_TO_PC); - AttackStart(malganis); - if (malganis->IsAIEnabled()) - malganis->AI()->AttackStart(me); - } - ScheduleActionOOC(RP5_ACTION_AFTER_MALGANIS); - break; - case RP5_EVENT_MALGANIS_DONE: - if (Creature* malganis = me->FindNearestCreature(NPC_MALGANIS, 100.0f, true)) - { - malganis->SetFacingToObject(me); - malganis->CastSpell(malganis, SPELL_MALGANIS_QUEST_CREDIT, true); - malganis->CastSpell(malganis, SPELL_MALGANIS_KILL_CREDIT, true); - if (GameObject* chest = malganis->FindNearestGameObject(RAID_MODE(GO_CHEST_NORMAL, GO_CHEST_HEROIC), 100.0f)) - chest->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); - } - events.ScheduleEvent(RP5_EVENT_MALGANIS12, 3s); - events.ScheduleEvent(RP5_EVENT_MALGANIS_LEAVE, 19s); - events.ScheduleEvent(RP5_EVENT_ARTHAS10, 20s); - events.ScheduleEvent(RP5_EVENT_ARTHAS10_2, 27s); - events.ScheduleEvent(RP5_EVENT_ARTHAS11, 30s); - events.ScheduleEvent(RP5_EVENT_ARTHAS11_2, 35s); - events.ScheduleEvent(RP5_EVENT_ARTHAS_LEAVE, 45s); - events.ScheduleEvent(RP5_EVENT_CHROMIE_SPAWN, 65s); - events.ScheduleEvent(RP5_EVENT_CHROMIE_LAND, 76s + 668ms); - events.ScheduleEvent(RP5_EVENT_CHROMIE_TRANSFORM, 79s + 491ms); - instance->SetBossState(DATA_MAL_GANIS, DONE); - instance->SetData(DATA_MALGANIS_DONE, 1); - break; - case RP5_EVENT_MALGANIS12: - talkerEntry = NPC_MALGANIS, talkerLine = RP5_LINE_MALGANIS12; - break; - case RP5_EVENT_MALGANIS_LEAVE: - if (Creature* malganis = me->FindNearestCreature(NPC_MALGANIS, 100.0f, true)) - malganis->CastSpell(malganis, SPELL_SHADOWSTEP_VISUAL); - break; - case RP5_EVENT_ARTHAS10: - if (Creature* malganis = me->FindNearestCreature(NPC_MALGANIS, 100.0f, true)) - malganis->DespawnOrUnsummon(); - me->GetMotionMaster()->MoveAlongSplineChain(0, RP5_CHAIN_ARTHAS2, false); - talkerEntry = 0, talkerLine = RP5_LINE_ARTHAS10; - break; - case RP5_EVENT_ARTHAS10_2: - me->HandleEmoteCommand(EMOTE_ONESHOT_EXCLAMATION); - break; - case RP5_EVENT_ARTHAS11: - talkerEntry = 0, talkerLine = RP5_LINE_ARTHAS11; - break; - case RP5_EVENT_ARTHAS11_2: - me->HandleEmoteCommand(EMOTE_ONESHOT_TALK); - break; - case RP5_EVENT_ARTHAS_LEAVE: - me->GetMotionMaster()->MoveAlongSplineChain(RP5_POINTID_ARTHAS3, RP5_CHAIN_ARTHAS3, true); - break; - case RP5_EVENT_ARTHAS_LEAVE2: - me->GetMotionMaster()->MoveAlongSplineChain(RP5_POINTID_ARTHAS4, RP5_CHAIN_ARTHAS4, true); - break; - case RP5_EVENT_CHROMIE_SPAWN: - if (Creature* chromie = instance->instance->SummonCreature(NPC_CHROMIE_3, ArthasPositions[RP5_CHROMIE_SPAWN])) - { - chromie->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP | UNIT_NPC_FLAG_QUESTGIVER); - Movement::PointsArray path(ChromieSplinePos, ChromieSplinePos + chromiePathSize); - Movement::MoveSplineInit init(chromie); - init.SetFly(); - init.SetWalk(true); - init.MovebyPath(path, 0); - init.Launch(); - } - break; - case RP5_EVENT_CHROMIE_LAND: - if (Creature* chromie = me->FindNearestCreature(NPC_CHROMIE_3, 100.0f, true)) - chromie->SetByteValue(UNIT_FIELD_BYTES_1, 3, 0); - break; - case RP5_EVENT_CHROMIE_TRANSFORM: - if (Creature* chromie = me->FindNearestCreature(NPC_CHROMIE_3, 100.0f, true)) - { - chromie->CastSpell(chromie, SPELL_CHROMIE_3_TRANSFORM); - chromie->AI()->Talk(RP5_LINE_CHROMIE0); - chromie->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP | UNIT_NPC_FLAG_QUESTGIVER); - } - break; - default: - break; + events.ScheduleEvent(RP5_EVENT_MALGANIS12, 3s); + events.ScheduleEvent(RP5_EVENT_MALGANIS_LEAVE, 19s); + events.ScheduleEvent(RP5_EVENT_ARTHAS10, 20s); + events.ScheduleEvent(RP5_EVENT_ARTHAS10_2, 27s); + events.ScheduleEvent(RP5_EVENT_ARTHAS11, 30s); + events.ScheduleEvent(RP5_EVENT_ARTHAS11_2, 35s); + events.ScheduleEvent(RP5_EVENT_ARTHAS_LEAVE, 45s); + events.ScheduleEvent(RP5_EVENT_CHROMIE_SPAWN, 65s); + events.ScheduleEvent(RP5_EVENT_CHROMIE_LAND, 76s + 668ms); + events.ScheduleEvent(RP5_EVENT_CHROMIE_TRANSFORM, 79s + 491ms); + instance->SetBossState(DATA_MAL_GANIS, DONE); + instance->SetData(DATA_MALGANIS_DONE, 1); + break; + case RP5_EVENT_MALGANIS12: + talkerEntry = NPC_MALGANIS, talkerLine = RP5_LINE_MALGANIS12; + break; + case RP5_EVENT_MALGANIS_LEAVE: + if (Creature* malganis = me->FindNearestCreature(NPC_MALGANIS, 100.0f, true)) + malganis->CastSpell(malganis, SPELL_SHADOWSTEP_VISUAL); + break; + case RP5_EVENT_ARTHAS10: + if (Creature* malganis = me->FindNearestCreature(NPC_MALGANIS, 100.0f, true)) + malganis->DespawnOrUnsummon(); + me->GetMotionMaster()->MoveAlongSplineChain(0, RP5_CHAIN_ARTHAS2, false); + talkerEntry = 0, talkerLine = RP5_LINE_ARTHAS10; + break; + case RP5_EVENT_ARTHAS10_2: + me->HandleEmoteCommand(EMOTE_ONESHOT_EXCLAMATION); + break; + case RP5_EVENT_ARTHAS11: + talkerEntry = 0, talkerLine = RP5_LINE_ARTHAS11; + break; + case RP5_EVENT_ARTHAS11_2: + me->HandleEmoteCommand(EMOTE_ONESHOT_TALK); + break; + case RP5_EVENT_ARTHAS_LEAVE: + me->GetMotionMaster()->MoveAlongSplineChain(RP5_POINTID_ARTHAS3, RP5_CHAIN_ARTHAS3, true); + break; + case RP5_EVENT_ARTHAS_LEAVE2: + me->GetMotionMaster()->MoveAlongSplineChain(RP5_POINTID_ARTHAS4, RP5_CHAIN_ARTHAS4, true); + break; + case RP5_EVENT_CHROMIE_SPAWN: + if (Creature* chromie = instance->instance->SummonCreature(NPC_CHROMIE_3, ArthasPositions[RP5_CHROMIE_SPAWN])) + { + chromie->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP | UNIT_NPC_FLAG_QUESTGIVER); + Movement::PointsArray path(ChromieSplinePos, ChromieSplinePos + chromiePathSize); + Movement::MoveSplineInit init(chromie); + init.SetFly(); + init.SetWalk(true); + init.MovebyPath(path, 0); + init.Launch(); + } + break; + case RP5_EVENT_CHROMIE_LAND: + if (Creature* chromie = me->FindNearestCreature(NPC_CHROMIE_3, 100.0f, true)) + chromie->SetByteValue(UNIT_FIELD_BYTES_1, 3, 0); + break; + case RP5_EVENT_CHROMIE_TRANSFORM: + if (Creature* chromie = me->FindNearestCreature(NPC_CHROMIE_3, 100.0f, true)) + { + chromie->CastSpell(chromie, SPELL_CHROMIE_3_TRANSFORM); + chromie->AI()->Talk(RP5_LINE_CHROMIE0); + chromie->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP | UNIT_NPC_FLAG_QUESTGIVER); + } + break; + default: + break; } if (talkerEntry != UINT_MAX) @@ -1628,15 +1617,15 @@ class npc_arthas_stratholme : public CreatureScript return false; } - private: - InstanceScript* const instance; - EventMap events; - ObjectGuid _eventStarterGuid; - uint32 _exorcismCooldown; // no EventMap entry for this, it's reserved for RP handling + private: + InstanceScript* const instance; + EventMap events; + ObjectGuid _eventStarterGuid; + uint32 _exorcismCooldown; // no EventMap entry for this, it's reserved for RP handling - bool _progressRP; - Actions _afterCombat; - SplineChainResumeInfo _resumeMovement; + bool _progressRP; + Actions _afterCombat; + SplineChainResumeInfo _resumeMovement; }; CreatureAI* GetAI(Creature* creature) const override @@ -1656,7 +1645,9 @@ Position const& GetArthasSnapbackFor(COSProgressStates state) // Arthas' AI is the one controlling everything, all this AI does is report any movementinforms back to Arthas AI struct npc_stratholme_rp_dummy : NullCreatureAI { - npc_stratholme_rp_dummy(Creature* creature) : NullCreatureAI(creature) { } + npc_stratholme_rp_dummy(Creature* creature) : NullCreatureAI(creature) + { + } void MovementInform(uint32 type, uint32 id) override { @@ -1672,7 +1663,7 @@ class spell_stratholme_crusader_strike : public SpellScript { if (Unit* target = GetHitUnit()) if (target->GetEntry() == NPC_CITIZEN || target->GetEntry() == NPC_RESIDENT) - GetCaster()->Kill(target); + Unit::Kill(GetCaster(), target); } void Register() override diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/boss_aeonus.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/boss_aeonus.cpp index 43fd7eaa..dc2f4196 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/boss_aeonus.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/boss_aeonus.cpp @@ -22,44 +22,50 @@ Comment: Some spells not implemented Category: Caverns of Time, The Dark Portal */ -#include "ScriptMgr.h" #include "InstanceScript.h" +#include "ScriptMgr.h" #include "ScriptedCreature.h" #include "the_black_morass.h" enum Enums { - SAY_ENTER = 0, - SAY_AGGRO = 1, - SAY_BANISH = 2, - SAY_SLAY = 3, - SAY_DEATH = 4, - EMOTE_FRENZY = 5, - - SPELL_CLEAVE = 40504, - SPELL_TIME_STOP = 31422, - SPELL_ENRAGE = 37605, - SPELL_SAND_BREATH = 31473, + SAY_ENTER = 0, + SAY_AGGRO = 1, + SAY_BANISH = 2, + SAY_SLAY = 3, + SAY_DEATH = 4, + EMOTE_FRENZY = 5, + + SPELL_CLEAVE = 40504, + SPELL_TIME_STOP = 31422, + SPELL_ENRAGE = 37605, + SPELL_SAND_BREATH = 31473, H_SPELL_SAND_BREATH = 39049 }; enum Events { - EVENT_SANDBREATH = 1, - EVENT_TIMESTOP = 2, - EVENT_FRENZY = 3 + EVENT_SANDBREATH = 1, + EVENT_TIMESTOP = 2, + EVENT_FRENZY = 3 }; class boss_aeonus : public CreatureScript { -public: - boss_aeonus() : CreatureScript("boss_aeonus") { } + public: + boss_aeonus() : CreatureScript("boss_aeonus") + { + } struct boss_aeonusAI : public BossAI { - boss_aeonusAI(Creature* creature) : BossAI(creature, TYPE_AEONUS) { } + boss_aeonusAI(Creature* creature) : BossAI(creature, TYPE_AEONUS) + { + } - void Reset() override { } + void Reset() override + { + } void JustEngagedWith(Unit* /*who*/) override { @@ -73,13 +79,13 @@ class boss_aeonus : public CreatureScript void MoveInLineOfSight(Unit* who) override { - //Despawn Time Keeper + // Despawn Time Keeper if (who->GetTypeId() == TYPEID_UNIT && who->GetEntry() == NPC_TIME_KEEPER) { if (me->IsWithinDistInMap(who, 20.0f)) { Talk(SAY_BANISH); - me->DealDamage(who, who->GetHealth(), nullptr, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, nullptr, false); + Unit::DealDamage(me, who, who->GetHealth(), nullptr, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, nullptr, false); } } @@ -102,7 +108,7 @@ class boss_aeonus : public CreatureScript void UpdateAI(uint32 diff) override { - //Return since we have no target + // Return since we have no target if (!UpdateVictim()) return; @@ -115,21 +121,21 @@ class boss_aeonus : public CreatureScript { switch (eventId) { - case EVENT_SANDBREATH: - DoCastVictim(SPELL_SAND_BREATH); - events.ScheduleEvent(EVENT_SANDBREATH, urand(15000, 25000)); - break; - case EVENT_TIMESTOP: - DoCastVictim(SPELL_TIME_STOP); - events.ScheduleEvent(EVENT_TIMESTOP, urand(20000, 35000)); - break; - case EVENT_FRENZY: - Talk(EMOTE_FRENZY); - DoCast(me, SPELL_ENRAGE); - events.ScheduleEvent(EVENT_FRENZY, urand(20000, 35000)); - break; - default: - break; + case EVENT_SANDBREATH: + DoCastVictim(SPELL_SAND_BREATH); + events.ScheduleEvent(EVENT_SANDBREATH, urand(15000, 25000)); + break; + case EVENT_TIMESTOP: + DoCastVictim(SPELL_TIME_STOP); + events.ScheduleEvent(EVENT_TIMESTOP, urand(20000, 35000)); + break; + case EVENT_FRENZY: + Talk(EMOTE_FRENZY); + DoCast(me, SPELL_ENRAGE); + events.ScheduleEvent(EVENT_FRENZY, urand(20000, 35000)); + break; + default: + break; } if (me->HasUnitState(UNIT_STATE_CASTING)) diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/boss_chrono_lord_deja.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/boss_chrono_lord_deja.cpp index fac28586..96b92c05 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/boss_chrono_lord_deja.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/boss_chrono_lord_deja.cpp @@ -22,45 +22,51 @@ Comment: All abilities not implemented Category: Caverns of Time, The Black Morass */ -#include "ScriptMgr.h" #include "InstanceScript.h" +#include "ScriptMgr.h" #include "ScriptedCreature.h" #include "the_black_morass.h" enum Enums { - SAY_ENTER = 0, - SAY_AGGRO = 1, - SAY_BANISH = 2, - SAY_SLAY = 3, - SAY_DEATH = 4, - - SPELL_ARCANE_BLAST = 31457, - H_SPELL_ARCANE_BLAST = 38538, - SPELL_ARCANE_DISCHARGE = 31472, - H_SPELL_ARCANE_DISCHARGE = 38539, - SPELL_TIME_LAPSE = 31467, - SPELL_ATTRACTION = 38540 //Not Implemented (Heroic mode) + SAY_ENTER = 0, + SAY_AGGRO = 1, + SAY_BANISH = 2, + SAY_SLAY = 3, + SAY_DEATH = 4, + + SPELL_ARCANE_BLAST = 31457, + H_SPELL_ARCANE_BLAST = 38538, + SPELL_ARCANE_DISCHARGE = 31472, + H_SPELL_ARCANE_DISCHARGE = 38539, + SPELL_TIME_LAPSE = 31467, + SPELL_ATTRACTION = 38540 // Not Implemented (Heroic mode) }; enum Events { - EVENT_ARCANE_BLAST = 1, - EVENT_TIME_LAPSE = 2, - EVENT_ARCANE_DISCHARGE = 3, - EVENT_ATTRACTION = 4 + EVENT_ARCANE_BLAST = 1, + EVENT_TIME_LAPSE = 2, + EVENT_ARCANE_DISCHARGE = 3, + EVENT_ATTRACTION = 4 }; class boss_chrono_lord_deja : public CreatureScript { -public: - boss_chrono_lord_deja() : CreatureScript("boss_chrono_lord_deja") { } + public: + boss_chrono_lord_deja() : CreatureScript("boss_chrono_lord_deja") + { + } struct boss_chrono_lord_dejaAI : public BossAI { - boss_chrono_lord_dejaAI(Creature* creature) : BossAI(creature, TYPE_CRONO_LORD_DEJA) { } + boss_chrono_lord_dejaAI(Creature* creature) : BossAI(creature, TYPE_CRONO_LORD_DEJA) + { + } - void Reset() override { } + void Reset() override + { + } void JustEngagedWith(Unit* /*who*/) override { @@ -76,13 +82,13 @@ class boss_chrono_lord_deja : public CreatureScript void MoveInLineOfSight(Unit* who) override { - //Despawn Time Keeper + // Despawn Time Keeper if (who->GetTypeId() == TYPEID_UNIT && who->GetEntry() == NPC_TIME_KEEPER) { if (me->IsWithinDistInMap(who, 20.0f)) { Talk(SAY_BANISH); - me->DealDamage(who, who->GetHealth(), nullptr, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, nullptr, false); + Unit::DealDamage(me, who, who->GetHealth(), nullptr, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, nullptr, false); } } @@ -115,26 +121,26 @@ class boss_chrono_lord_deja : public CreatureScript { switch (eventId) { - case EVENT_ARCANE_BLAST: - DoCastVictim(SPELL_ARCANE_BLAST); - events.ScheduleEvent(EVENT_ARCANE_BLAST, urand(15000, 25000)); - break; - case EVENT_TIME_LAPSE: - Talk(SAY_BANISH); - DoCast(me, SPELL_TIME_LAPSE); - events.ScheduleEvent(EVENT_TIME_LAPSE, urand(15000, 25000)); - break; - case EVENT_ARCANE_DISCHARGE: - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) - DoCast(target, SPELL_ARCANE_DISCHARGE); - events.ScheduleEvent(EVENT_ARCANE_DISCHARGE, urand(20000, 30000)); - break; - case EVENT_ATTRACTION: // Only in Heroic - DoCast(me, SPELL_ATTRACTION); - events.ScheduleEvent(EVENT_ATTRACTION, urand(25000, 35000)); - break; - default: - break; + case EVENT_ARCANE_BLAST: + DoCastVictim(SPELL_ARCANE_BLAST); + events.ScheduleEvent(EVENT_ARCANE_BLAST, urand(15000, 25000)); + break; + case EVENT_TIME_LAPSE: + Talk(SAY_BANISH); + DoCast(me, SPELL_TIME_LAPSE); + events.ScheduleEvent(EVENT_TIME_LAPSE, urand(15000, 25000)); + break; + case EVENT_ARCANE_DISCHARGE: + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) + DoCast(target, SPELL_ARCANE_DISCHARGE); + events.ScheduleEvent(EVENT_ARCANE_DISCHARGE, urand(20000, 30000)); + break; + case EVENT_ATTRACTION: // Only in Heroic + DoCast(me, SPELL_ATTRACTION); + events.ScheduleEvent(EVENT_ATTRACTION, urand(25000, 35000)); + break; + default: + break; } if (me->HasUnitState(UNIT_STATE_CASTING)) diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/boss_temporus.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/boss_temporus.cpp index 9abd9040..8064c223 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/boss_temporus.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/boss_temporus.cpp @@ -22,44 +22,50 @@ Comment: More abilities need to be implemented Category: Caverns of Time, The Black Morass */ -#include "ScriptMgr.h" #include "InstanceScript.h" +#include "ScriptMgr.h" #include "ScriptedCreature.h" #include "the_black_morass.h" enum Enums { - SAY_ENTER = 0, - SAY_AGGRO = 1, - SAY_BANISH = 2, - SAY_SLAY = 3, - SAY_DEATH = 4, - - SPELL_HASTE = 31458, - SPELL_MORTAL_WOUND = 31464, - SPELL_WING_BUFFET = 31475, - H_SPELL_WING_BUFFET = 38593, - SPELL_REFLECT = 38592 //Not Implemented (Heroic mod) + SAY_ENTER = 0, + SAY_AGGRO = 1, + SAY_BANISH = 2, + SAY_SLAY = 3, + SAY_DEATH = 4, + + SPELL_HASTE = 31458, + SPELL_MORTAL_WOUND = 31464, + SPELL_WING_BUFFET = 31475, + H_SPELL_WING_BUFFET = 38593, + SPELL_REFLECT = 38592 // Not Implemented (Heroic mod) }; enum Events { - EVENT_HASTE = 1, - EVENT_MORTAL_WOUND = 2, - EVENT_WING_BUFFET = 3, - EVENT_SPELL_REFLECTION = 4 + EVENT_HASTE = 1, + EVENT_MORTAL_WOUND = 2, + EVENT_WING_BUFFET = 3, + EVENT_SPELL_REFLECTION = 4 }; class boss_temporus : public CreatureScript { -public: - boss_temporus() : CreatureScript("boss_temporus") { } + public: + boss_temporus() : CreatureScript("boss_temporus") + { + } struct boss_temporusAI : public BossAI { - boss_temporusAI(Creature* creature) : BossAI(creature, TYPE_TEMPORUS) { } + boss_temporusAI(Creature* creature) : BossAI(creature, TYPE_TEMPORUS) + { + } - void Reset() override { } + void Reset() override + { + } void JustEngagedWith(Unit* /*who*/) override { @@ -87,14 +93,14 @@ class boss_temporus : public CreatureScript void MoveInLineOfSight(Unit* who) override { - //Despawn Time Keeper + // Despawn Time Keeper if (who->GetTypeId() == TYPEID_UNIT && who->GetEntry() == NPC_TIME_KEEPER) { if (me->IsWithinDistInMap(who, 20.0f)) { Talk(SAY_BANISH); - me->DealDamage(who, who->GetHealth(), nullptr, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, nullptr, false); + Unit::DealDamage(me, who, who->GetHealth(), nullptr, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, nullptr, false); } } @@ -103,7 +109,7 @@ class boss_temporus : public CreatureScript void UpdateAI(uint32 diff) override { - //Return since we have no target + // Return since we have no target if (!UpdateVictim()) return; @@ -116,24 +122,24 @@ class boss_temporus : public CreatureScript { switch (eventId) { - case EVENT_HASTE: - DoCast(me, SPELL_HASTE); - events.ScheduleEvent(EVENT_HASTE, urand(20000, 25000)); - break; - case EVENT_MORTAL_WOUND: - DoCast(me, SPELL_MORTAL_WOUND); - events.ScheduleEvent(EVENT_MORTAL_WOUND, urand(10000, 20000)); - break; - case EVENT_WING_BUFFET: - DoCast(me, SPELL_WING_BUFFET); - events.ScheduleEvent(EVENT_WING_BUFFET, urand(20000, 30000)); - break; - case EVENT_SPELL_REFLECTION: // Only in Heroic - DoCast(me, SPELL_REFLECT); - events.ScheduleEvent(EVENT_SPELL_REFLECTION, urand(25000, 35000)); - break; - default: - break; + case EVENT_HASTE: + DoCast(me, SPELL_HASTE); + events.ScheduleEvent(EVENT_HASTE, urand(20000, 25000)); + break; + case EVENT_MORTAL_WOUND: + DoCast(me, SPELL_MORTAL_WOUND); + events.ScheduleEvent(EVENT_MORTAL_WOUND, urand(10000, 20000)); + break; + case EVENT_WING_BUFFET: + DoCast(me, SPELL_WING_BUFFET); + events.ScheduleEvent(EVENT_WING_BUFFET, urand(20000, 30000)); + break; + case EVENT_SPELL_REFLECTION: // Only in Heroic + DoCast(me, SPELL_REFLECT); + events.ScheduleEvent(EVENT_SPELL_REFLECTION, urand(25000, 35000)); + break; + default: + break; } if (me->HasUnitState(UNIT_STATE_CASTING)) diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/instance_the_black_morass.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/instance_the_black_morass.cpp index bd6279bf..6cba4852 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/instance_the_black_morass.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/instance_the_black_morass.cpp @@ -22,11 +22,11 @@ Comment: Quest support: 9836, 10297. Currently in progress. Category: Caverns of Time, The Black Morass */ -#include "ScriptMgr.h" #include "InstanceScript.h" #include "Log.h" #include "Map.h" #include "Player.h" +#include "ScriptMgr.h" #include "ScriptedCreature.h" #include "SpellInfo.h" #include "TemporarySummon.h" @@ -34,35 +34,24 @@ Category: Caverns of Time, The Black Morass enum Misc { - SPELL_RIFT_CHANNEL = 31387, - RIFT_BOSS = 1 + SPELL_RIFT_CHANNEL = 31387, + RIFT_BOSS = 1 }; -inline uint32 RandRiftBoss() { return ((rand32() % 2) ? NPC_RIFT_KEEPER : NPC_RIFT_LORD); } - -float PortalLocation[4][4]= +inline uint32 RandRiftBoss() { - {-2041.06f, 7042.08f, 29.99f, 1.30f}, - {-1968.18f, 7042.11f, 21.93f, 2.12f}, - {-1885.82f, 7107.36f, 22.32f, 3.07f}, - {-1928.11f, 7175.95f, 22.11f, 3.44f} -}; + return ((rand32() % 2) ? NPC_RIFT_KEEPER : NPC_RIFT_LORD); +} + +float PortalLocation[4][4] = {{-2041.06f, 7042.08f, 29.99f, 1.30f}, {-1968.18f, 7042.11f, 21.93f, 2.12f}, {-1885.82f, 7107.36f, 22.32f, 3.07f}, {-1928.11f, 7175.95f, 22.11f, 3.44f}}; struct Wave { - uint32 PortalBoss; //protector of current portal - uint32 NextPortalTime; //time to next portal, or 0 if portal boss need to be killed + uint32 PortalBoss; // protector of current portal + uint32 NextPortalTime; // time to next portal, or 0 if portal boss need to be killed }; -static Wave RiftWaves[]= -{ - { RIFT_BOSS, 0 }, - { NPC_CRONO_LORD_DEJA, 0 }, - { RIFT_BOSS, 120000 }, - { NPC_TEMPORUS, 140000 }, - { RIFT_BOSS, 120000 }, - { NPC_AEONUS, 0 } -}; +static Wave RiftWaves[] = {{RIFT_BOSS, 0}, {NPC_CRONO_LORD_DEJA, 0}, {RIFT_BOSS, 120000}, {NPC_TEMPORUS, 140000}, {RIFT_BOSS, 120000}, {NPC_AEONUS, 0}}; enum EventIds { @@ -71,8 +60,10 @@ enum EventIds class instance_the_black_morass : public InstanceMapScript { -public: - instance_the_black_morass() : InstanceMapScript(TBMScriptName, 269) { } + public: + instance_the_black_morass() : InstanceMapScript(TBMScriptName, 269) + { + } struct instance_the_black_morass_InstanceMapScript : public InstanceScript { @@ -86,22 +77,22 @@ class instance_the_black_morass : public InstanceMapScript uint32 mRiftPortalCount; uint32 mShieldPercent; - uint8 mRiftWaveCount; - uint8 mRiftWaveId; + uint8 mRiftWaveCount; + uint8 mRiftWaveId; ObjectGuid _medivhGUID; - uint8 _currentRiftId; + uint8 _currentRiftId; void Clear() { memset(&m_auiEncounter, 0, sizeof(m_auiEncounter)); - mRiftPortalCount = 0; - mShieldPercent = 100; - mRiftWaveCount = 0; - mRiftWaveId = 0; + mRiftPortalCount = 0; + mShieldPercent = 100; + mRiftWaveCount = 0; + mRiftWaveId = 0; - _currentRiftId = 0; + _currentRiftId = 0; } void InitWorldState(bool Enable = true) @@ -133,7 +124,7 @@ class instance_the_black_morass : public InstanceMapScript _medivhGUID = creature->GetGUID(); } - //what other conditions to check? + // what other conditions to check? bool CanProgressEvent() { if (instance->GetPlayers().isEmpty()) @@ -176,7 +167,7 @@ class instance_the_black_morass : public InstanceMapScript { if (medivh->IsAlive()) { - medivh->DealDamage(medivh, medivh->GetHealth(), nullptr, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, nullptr, false); + medivh->KillSelf(); m_auiEncounter[0] = FAIL; m_auiEncounter[1] = NOT_STARTED; } @@ -195,7 +186,7 @@ class instance_the_black_morass : public InstanceMapScript if (data == DONE) { - //this may be completed further out in the post-event + // this may be completed further out in the post-event LOG_DEBUG("scripts", "Instance The Black Morass: Event completed."); Map::PlayerList const& players = instance->GetPlayers(); @@ -265,8 +256,9 @@ class instance_the_black_morass : public InstanceMapScript Position pos = me->GetRandomNearPosition(10.0f); - //normalize Z-level if we can, if rift is not at ground level. - pos.m_positionZ = std::max(me->GetMap()->GetHeight(me->GetPhaseShift(), pos.m_positionX, pos.m_positionY, MAX_HEIGHT), me->GetMap()->GetWaterLevel(me->GetPhaseShift(), pos.m_positionX, pos.m_positionY)); + // normalize Z-level if we can, if rift is not at ground level. + pos.m_positionZ = std::max( + me->GetMap()->GetHeight(me->GetPhaseShift(), pos.m_positionX, pos.m_positionY, MAX_HEIGHT), me->GetMap()->GetWaterLevel(me->GetPhaseShift(), pos.m_positionX, pos.m_positionY)); if (Creature* summon = me->SummonCreature(entry, pos, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 600000)) return summon; @@ -288,9 +280,7 @@ class instance_the_black_morass : public InstanceMapScript _currentRiftId = tmp; - Creature* temp = medivh->SummonCreature(NPC_TIME_RIFT, - PortalLocation[tmp][0], PortalLocation[tmp][1], PortalLocation[tmp][2], PortalLocation[tmp][3], - TEMPSUMMON_CORPSE_DESPAWN, 0); + Creature* temp = medivh->SummonCreature(NPC_TIME_RIFT, PortalLocation[tmp][0], PortalLocation[tmp][1], PortalLocation[tmp][2], PortalLocation[tmp][3], TEMPSUMMON_CORPSE_DESPAWN, 0); if (temp) { temp->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); @@ -315,7 +305,7 @@ class instance_the_black_morass : public InstanceMapScript if (m_auiEncounter[1] != IN_PROGRESS) return; - //add delay timer? + // add delay timer? if (!CanProgressEvent()) { Clear(); @@ -339,8 +329,8 @@ class instance_the_black_morass : public InstanceMapScript Events.RescheduleEvent(EVENT_NEXT_PORTAL, nextPortalTime); } - protected: - EventMap Events; + protected: + EventMap Events; }; InstanceScript* GetInstanceScript(InstanceMap* map) const override diff --git a/src/server/scripts/Kalimdor/Firelands/boss_lord_rhyolith.cpp b/src/server/scripts/Kalimdor/Firelands/boss_lord_rhyolith.cpp index c892baa5..dc36aa13 100644 --- a/src/server/scripts/Kalimdor/Firelands/boss_lord_rhyolith.cpp +++ b/src/server/scripts/Kalimdor/Firelands/boss_lord_rhyolith.cpp @@ -1,105 +1,105 @@ /* -* This file is part of the FirelandsCore Project. See AUTHORS file for Copyright information -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU Affero General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at your -* option) any later version. -* -* This program is distributed in the hope that it will be useful, but WITHOUT -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for -* more details. -* -* You should have received a copy of the GNU Affero General Public License along -* with this program. If not, see . -*/ + * This file is part of the FirelandsCore Project. See AUTHORS file for Copyright information + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for + * more details. + * + * You should have received a copy of the GNU Affero General Public License along + * with this program. If not, see . + */ -#include "firelands.h" #include "InstanceScript.h" -#include "PassiveAI.h" -#include "PathGenerator.h" #include "Map.h" #include "MotionMaster.h" #include "MoveSplineInit.h" #include "ObjectAccessor.h" #include "ObjectMgr.h" #include "Optional.h" +#include "PassiveAI.h" +#include "PathGenerator.h" #include "Player.h" -#include "ScriptedCreature.h" #include "ScriptMgr.h" +#include "ScriptedCreature.h" #include "Spell.h" -#include "SpellScript.h" -#include "SpellAuras.h" #include "SpellAuraEffects.h" +#include "SpellAuras.h" +#include "SpellScript.h" +#include "firelands.h" enum Texts { // Lord Rhyolith - SAY_ENGAGE = 0, - SAY_CONCUSSIVE_STOMP = 1, - SAY_ANNOUNCE_DRINK_MAGMA = 2, - SAY_HEATED_VOLCANO = 3, + SAY_ENGAGE = 0, + SAY_CONCUSSIVE_STOMP = 1, + SAY_ANNOUNCE_DRINK_MAGMA = 2, + SAY_HEATED_VOLCANO = 3, SAY_ANNOUNCE_ARMOR_WEAKENED = 4, - SAY_ARMOR_WEAKENED = 5, - SAY_ANNOUNCE_ARMOR_BROKEN = 6, - SAY_ARMOR_BROKEN = 7, - SAY_DEATH = 8, - SAY_SLAY = 9 + SAY_ARMOR_WEAKENED = 5, + SAY_ANNOUNCE_ARMOR_BROKEN = 6, + SAY_ARMOR_BROKEN = 7, + SAY_DEATH = 8, + SAY_SLAY = 9 }; enum Spells { // Lord Rhyolith - SPELL_OBSIDIAN_ARMOR = 98632, - SPELL_BALANCE_BAR = 98226, - SPELL_CONCUSSIVE_STOMP = 97282, - SPELL_HEATED_VOLCANO = 98493, - SPELL_DRINK_MAGMA = 98034, - SPELL_MOLTEN_SPEW = 98043, - SPELL_LAVA_LINE = 100650, - SPELL_SUMMON_TUBE = 98266, // Serverside spell - SPELL_SUMMON_FRAGMENT_OF_RHYOLITH = 98135, - SPELL_SUMMON_SPARK_OF_RHYOLITH = 98553, - SPELL_SUMMON_ROCK_ELEMENTALS = 98146, - SPELL_IMMOLATION_1 = 99846, - SPELL_UNLEASHED_FLAME = 101324, - SPELL_SUMMON_ARMOR_FRAGMENT = 98558, - SPELL_SUPERHEATED = 101304, - SPELL_BURNING_FEET = 98837, + SPELL_OBSIDIAN_ARMOR = 98632, + SPELL_BALANCE_BAR = 98226, + SPELL_CONCUSSIVE_STOMP = 97282, + SPELL_HEATED_VOLCANO = 98493, + SPELL_DRINK_MAGMA = 98034, + SPELL_MOLTEN_SPEW = 98043, + SPELL_LAVA_LINE = 100650, + SPELL_SUMMON_TUBE = 98266, // Serverside spell + SPELL_SUMMON_FRAGMENT_OF_RHYOLITH = 98135, + SPELL_SUMMON_SPARK_OF_RHYOLITH = 98553, + SPELL_SUMMON_ROCK_ELEMENTALS = 98146, + SPELL_IMMOLATION_1 = 99846, + SPELL_UNLEASHED_FLAME = 101324, + SPELL_SUMMON_ARMOR_FRAGMENT = 98558, + SPELL_SUPERHEATED = 101304, + SPELL_BURNING_FEET = 98837, // Feet - SPELL_RIDE_VEHICLE = 98843, - SPELL_START_FIGHT = 103019, // Serverside spell - SPELL_FOOT_DAMAGE_TRACKER = 98192, // Serverside spell + SPELL_RIDE_VEHICLE = 98843, + SPELL_START_FIGHT = 103019, // Serverside spell + SPELL_FOOT_DAMAGE_TRACKER = 98192, // Serverside spell // Volcano - SPELL_VOLCANO_BASE = 98250, - SPELL_ERUPTION = 98264, - SPELL_ERUPTION_AURA = 98492, - SPELL_EXPLOSION = 97719, - SPELL_MAGMA = 98472, - SPELL_MAGMA_FLOW = 97225, - SPELL_MAGMA_FLOW_MISSILE = 97230, - SPELL_MAGMA_FLOW_DAMAGE = 97234, - SPELL_MOLTEN_ARMOR_10N = 98255, // Duplicate enum as NullCreatureAI does not have access to the raid mode macro + SPELL_VOLCANO_BASE = 98250, + SPELL_ERUPTION = 98264, + SPELL_ERUPTION_AURA = 98492, + SPELL_EXPLOSION = 97719, + SPELL_MAGMA = 98472, + SPELL_MAGMA_FLOW = 97225, + SPELL_MAGMA_FLOW_MISSILE = 97230, + SPELL_MAGMA_FLOW_DAMAGE = 97234, + SPELL_MOLTEN_ARMOR_10N = 98255, // Duplicate enum as NullCreatureAI does not have access to the raid mode macro // Pillar - SPELL_LAVA_TUBE = 98265, + SPELL_LAVA_TUBE = 98265, // Fragment of Rhyolith - SPELL_MELTDOWN = 98646, + SPELL_MELTDOWN = 98646, // Spark of Rhyolith - SPELL_IMMOLATION_2 = 98597, - SPELL_INFERNAL_RAGE = 98596, + SPELL_IMMOLATION_2 = 98597, + SPELL_INFERNAL_RAGE = 98596, // Unleashed Flame - SPELL_UNLEASHED_FLAME_AURA = 101313, - SPELL_UNLEASHED_FLAME_CHANNELING = 101314, + SPELL_UNLEASHED_FLAME_AURA = 101313, + SPELL_UNLEASHED_FLAME_CHANNELING = 101314, // Liquid Obsidian - SPELL_FUSE = 99875 + SPELL_FUSE = 99875 }; #define SPELL_MOLTEN_ARMOR RAID_MODE(98255, 101157, 101158, 101159) @@ -146,13 +146,13 @@ enum Actions ACTION_RECALCULATE_DAMAGE_REDUCTION_MOD = 1, // Movement Controller - Lord Rhyolith - ACTION_ENCOUNTER_STARTED = 1, - ACTION_STOP_MOVEMENT_CONTROL = 2, + ACTION_ENCOUNTER_STARTED = 1, + ACTION_STOP_MOVEMENT_CONTROL = 2, // Volcano - ACTION_ACTIVATE_VOLCANO = 1, - ACTION_SCHEDULE_MAGMA_FLOW = 2, - ACTION_DESTROY_VOLCANO = 3 + ACTION_ACTIVATE_VOLCANO = 1, + ACTION_SCHEDULE_MAGMA_FLOW = 2, + ACTION_DESTROY_VOLCANO = 3 }; enum AIAnimKits @@ -171,16 +171,16 @@ enum MovePoints enum Balance : uint32 { - MIN_LEFT_BALANCE = 0, - CENTER_BALANCE = 25, - MAX_RIGHT_BALANCE = 50 + MIN_LEFT_BALANCE = 0, + CENTER_BALANCE = 25, + MAX_RIGHT_BALANCE = 50 }; enum Data { - DATA_CURRENT_BALANCE = 0, - DATA_DAMAGE_PER_SECOND = 0, - DATA_RECENTLY_BROKEN_VOLCANO = 0, + DATA_CURRENT_BALANCE = 0, + DATA_DAMAGE_PER_SECOND = 0, + DATA_RECENTLY_BROKEN_VOLCANO = 0, }; enum WorldStates @@ -188,27 +188,21 @@ enum WorldStates WORLD_STATE_ID_NOT_AN_AMBI_TURNER = 5931 }; -static Position const MovementControllerSummonPosition = { -366.00174f, -349.65277f, 100.378845f, 1.7802358f }; -static Position const PlateauPlatformCenterPosition = { -371.577393f, -318.680725f, 102.f }; -static constexpr float PlateauRadius = 50.f; +static Position const MovementControllerSummonPosition = {-366.00174f, -349.65277f, 100.378845f, 1.7802358f}; +static Position const PlateauPlatformCenterPosition = {-371.577393f, -318.680725f, 102.f}; +static constexpr float PlateauRadius = 50.f; -static std::array TransformationEntries = -{ - NPC_LORD_RHYOLITH_DAMAGED_1, - NPC_LORD_RHYOLITH_DAMAGED_2, - NPC_LORD_RHYOLITH_PHASE_TWO -}; +static std::array TransformationEntries = {NPC_LORD_RHYOLITH_DAMAGED_1, NPC_LORD_RHYOLITH_DAMAGED_2, NPC_LORD_RHYOLITH_PHASE_TWO}; -static std::array BalanceDamageThresholds = -{ - 3000.f, // Hotfix (2011-07-01): Rhyolith is now slightly easier to turn in 10-player mode. - 9000.f -}; +static std::array BalanceDamageThresholds = {3000.f, // Hotfix (2011-07-01): Rhyolith is now slightly easier to turn in 10-player mode. + 9000.f}; struct boss_lord_rhyolith : public BossAI { - boss_lord_rhyolith(Creature* creature) : BossAI(creature, DATA_LORD_RHYOLITH), - _currentBalance(CENTER_BALANCE), _transformationCount(0), _hasBrokenFirstVolcano(false), _achievementFailed(false), _hasBurningFeet(false) { } + boss_lord_rhyolith(Creature* creature) + : BossAI(creature, DATA_LORD_RHYOLITH), _currentBalance(CENTER_BALANCE), _transformationCount(0), _hasBrokenFirstVolcano(false), _achievementFailed(false), _hasBurningFeet(false) + { + } void InitializeAI() override { @@ -221,7 +215,7 @@ struct boss_lord_rhyolith : public BossAI DoCastSelf(SPELL_OBSIDIAN_ARMOR, CastSpellExtraArgs().AddSpellMod(SPELLVALUE_AURA_STACK, 80)); uint8 seatId = 1; - for (uint16 entry : { NPC_LEFT_FOOT, NPC_RIGHT_FOOT }) + for (uint16 entry : {NPC_LEFT_FOOT, NPC_RIGHT_FOOT}) { if (Creature* foot = DoSummon(entry, me->GetPosition(), 0, TEMPSUMMON_MANUAL_DESPAWN)) { @@ -246,7 +240,7 @@ struct boss_lord_rhyolith : public BossAI me->GetMap()->SetWorldState(WORLD_STATE_ID_NOT_AN_AMBI_TURNER, 0); uint8 frameIndex = 2; - for (uint32 type : { DATA_LEFT_FOOT, DATA_RIGHT_FOOT }) + for (uint32 type : {DATA_LEFT_FOOT, DATA_RIGHT_FOOT}) { if (Creature* foot = instance->GetCreature(type)) { @@ -318,52 +312,53 @@ struct boss_lord_rhyolith : public BossAI switch (summon->GetEntry()) { - case NPC_MOVEMENT_CONTROLLER_LORD_RHYOLITH: - summons.Summon(summon); - break; - case NPC_VOLCANO: - summon->CastSpell(nullptr, SPELL_VOLCANO_BASE); - summon->SetDisplayId(summon->GetCreatureTemplate()->Modelid2); - summons.Summon(summon); - break; - case NPC_PILLAR: - summon->CastSpell(nullptr, SPELL_LAVA_TUBE); - summon->GetMotionMaster()->MovePoint(POINT_NONE, summon->GetPositionX(), summon->GetPositionY(), summon->GetPositionZ() + 6.f, false, 2.f); - summon->m_Events.AddEventAtOffset([summon]() + case NPC_MOVEMENT_CONTROLLER_LORD_RHYOLITH: + summons.Summon(summon); + break; + case NPC_VOLCANO: + summon->CastSpell(nullptr, SPELL_VOLCANO_BASE); + summon->SetDisplayId(summon->GetCreatureTemplate()->Modelid2); + summons.Summon(summon); + break; + case NPC_PILLAR: + summon->CastSpell(nullptr, SPELL_LAVA_TUBE); + summon->GetMotionMaster()->MovePoint(POINT_NONE, summon->GetPositionX(), summon->GetPositionY(), summon->GetPositionZ() + 6.f, false, 2.f); + summon->m_Events.AddEventAtOffset( + [summon]() { summon->GetMotionMaster()->MovePoint(POINT_NONE, summon->GetPositionX(), summon->GetPositionY(), summon->GetPositionZ() - 6.f, false, 2.f); summon->DespawnOrUnsummon(4s + 500ms); - }, 11s); - summons.Summon(summon); - break; - case NPC_FRAGMENT_OF_RHYOLITH: - summon->CastSpell(nullptr, SPELL_MELTDOWN); - [[fallthrough]]; - case NPC_SPARK_OF_RHYOLITH: - summon->SetCorpseDelay(3); - summon->SetReactState(REACT_PASSIVE); - summon->m_Events.AddEventAtOffset([summon]() + }, + 11s); + summons.Summon(summon); + break; + case NPC_FRAGMENT_OF_RHYOLITH: + summon->CastSpell(nullptr, SPELL_MELTDOWN); + [[fallthrough]]; + case NPC_SPARK_OF_RHYOLITH: + summon->SetCorpseDelay(3); + summon->SetReactState(REACT_PASSIVE); + summon->m_Events.AddEventAtOffset( + [summon]() { summon->SetReactState(REACT_AGGRESSIVE); summon->SetInCombatWithZone(); if (summon->GetEntry() == NPC_SPARK_OF_RHYOLITH) summon->CastSpell(nullptr, SPELL_IMMOLATION_2); - }, 1s); - summons.Summon(summon); - break; - case NPC_UNLEASHED_FLAME: - summon->CastSpell(nullptr, SPELL_UNLEASHED_FLAME_AURA); - summon->CastSpell(nullptr, SPELL_UNLEASHED_FLAME_CHANNELING); - summon->m_Events.AddEventAtOffset([summon]() - { - summon->GetMotionMaster()->MoveCirclePath(summon->GetPositionX(), summon->GetPositionY(), summon->GetPositionZ(), 10.f, true, 6); - }, 1s); - summons.Summon(summon); - break; - default: - BossAI::JustSummoned(summon); - break; + }, + 1s); + summons.Summon(summon); + break; + case NPC_UNLEASHED_FLAME: + summon->CastSpell(nullptr, SPELL_UNLEASHED_FLAME_AURA); + summon->CastSpell(nullptr, SPELL_UNLEASHED_FLAME_CHANNELING); + summon->m_Events.AddEventAtOffset([summon]() { summon->GetMotionMaster()->MoveCirclePath(summon->GetPositionX(), summon->GetPositionY(), summon->GetPositionZ(), 10.f, true, 6); }, 1s); + summons.Summon(summon); + break; + default: + BossAI::JustSummoned(summon); + break; } } @@ -374,20 +369,19 @@ struct boss_lord_rhyolith : public BossAI switch (pointId) { - case POINT_DRINK_MAGMA: - Talk(SAY_ANNOUNCE_DRINK_MAGMA); - DoCastSelf(SPELL_DRINK_MAGMA); - break; - default: - break; + case POINT_DRINK_MAGMA: + Talk(SAY_ANNOUNCE_DRINK_MAGMA); + DoCastSelf(SPELL_DRINK_MAGMA); + break; + default: + break; } } void DamageTaken(Unit* /*attacker*/, uint32& damage) override { - if ((me->HealthBelowPctDamaged(75, damage) && _transformationCount == 0) - || (me->HealthBelowPctDamaged(50, damage) && _transformationCount == 1) - || (me->HealthBelowPctDamaged(25, damage) && _transformationCount == 2)) + if ((me->HealthBelowPctDamaged(75, damage) && _transformationCount == 0) || (me->HealthBelowPctDamaged(50, damage) && _transformationCount == 1) || + (me->HealthBelowPctDamaged(25, damage) && _transformationCount == 2)) { me->UpdateEntry(TransformationEntries[_transformationCount], nullptr, false); { @@ -404,7 +398,7 @@ struct boss_lord_rhyolith : public BossAI me->GetMotionMaster()->Clear(MOTION_SLOT_ACTIVE); me->StopMoving(); - for (uint32 type : { DATA_LEFT_FOOT, DATA_RIGHT_FOOT }) + for (uint32 type : {DATA_LEFT_FOOT, DATA_RIGHT_FOOT}) { if (Creature* foot = instance->GetCreature(type)) { @@ -449,17 +443,17 @@ struct boss_lord_rhyolith : public BossAI { switch (action) { - case ACTION_DROP_MOLTEN_ARMOR_CHARGE: - if (Aura* armorAura = me->GetAura(SPELL_MOLTEN_ARMOR)) - armorAura->ModStackAmount(-1); - - for (uint32 type : { DATA_LEFT_FOOT, DATA_RIGHT_FOOT }) - if (Creature* foot = instance->GetCreature(type)) - if (Aura* armorAura = foot->GetAura(SPELL_MOLTEN_ARMOR)) - armorAura->ModStackAmount(-1); - break; - default: - break; + case ACTION_DROP_MOLTEN_ARMOR_CHARGE: + if (Aura* armorAura = me->GetAura(SPELL_MOLTEN_ARMOR)) + armorAura->ModStackAmount(-1); + + for (uint32 type : {DATA_LEFT_FOOT, DATA_RIGHT_FOOT}) + if (Creature* foot = instance->GetCreature(type)) + if (Aura* armorAura = foot->GetAura(SPELL_MOLTEN_ARMOR)) + armorAura->ModStackAmount(-1); + break; + default: + break; } } @@ -467,10 +461,10 @@ struct boss_lord_rhyolith : public BossAI { switch (type) { - case DATA_CURRENT_BALANCE: - return _currentBalance; - default: - return 0; + case DATA_CURRENT_BALANCE: + return _currentBalance; + default: + return 0; } return 0; @@ -480,12 +474,12 @@ struct boss_lord_rhyolith : public BossAI { switch (type) { - case DATA_RECENTLY_BROKEN_VOLCANO: - if (_recentlyBrokenVolcanos.empty()) - return ObjectGuid::Empty; - return _recentlyBrokenVolcanos.front(); - default: + case DATA_RECENTLY_BROKEN_VOLCANO: + if (_recentlyBrokenVolcanos.empty()) return ObjectGuid::Empty; + return _recentlyBrokenVolcanos.front(); + default: + return ObjectGuid::Empty; } return ObjectGuid::Empty; @@ -505,186 +499,186 @@ struct boss_lord_rhyolith : public BossAI { switch (eventId) { - case EVENT_CONCUSSIVE_STOMP: - Talk(SAY_CONCUSSIVE_STOMP); - DoCastAOE(SPELL_CONCUSSIVE_STOMP); - events.Repeat(30s); - break; - case EVENT_UPDATE_BALANCE: - { - uint32 damageLeft = 0; - uint32 damageRight = 0; - int16 balanceOffset = 0; + case EVENT_CONCUSSIVE_STOMP: + Talk(SAY_CONCUSSIVE_STOMP); + DoCastAOE(SPELL_CONCUSSIVE_STOMP); + events.Repeat(30s); + break; + case EVENT_UPDATE_BALANCE: + { + uint32 damageLeft = 0; + uint32 damageRight = 0; + int16 balanceOffset = 0; - if (Creature* footLeft = instance->GetCreature(DATA_LEFT_FOOT)) - if (CreatureAI* ai = footLeft->AI()) - damageLeft = ai->GetData(DATA_DAMAGE_PER_SECOND); + if (Creature* footLeft = instance->GetCreature(DATA_LEFT_FOOT)) + if (CreatureAI* ai = footLeft->AI()) + damageLeft = ai->GetData(DATA_DAMAGE_PER_SECOND); - if (Creature* footRight = instance->GetCreature(DATA_RIGHT_FOOT)) - if (CreatureAI* ai = footRight->AI()) - damageRight = ai->GetData(DATA_DAMAGE_PER_SECOND); + if (Creature* footRight = instance->GetCreature(DATA_RIGHT_FOOT)) + if (CreatureAI* ai = footRight->AI()) + damageRight = ai->GetData(DATA_DAMAGE_PER_SECOND); - if (damageLeft != damageRight) - { - uint8 is25ManRaid = Is25ManRaid(); - balanceOffset -= uint8(static_cast(damageLeft) / BalanceDamageThresholds[is25ManRaid]); - balanceOffset += uint8(static_cast(damageRight) / BalanceDamageThresholds[is25ManRaid]); - } + if (damageLeft != damageRight) + { + uint8 is25ManRaid = Is25ManRaid(); + balanceOffset -= uint8(static_cast(damageLeft) / BalanceDamageThresholds[is25ManRaid]); + balanceOffset += uint8(static_cast(damageRight) / BalanceDamageThresholds[is25ManRaid]); + } - _currentBalance = std::clamp(CENTER_BALANCE + balanceOffset, MIN_LEFT_BALANCE, MAX_RIGHT_BALANCE); + _currentBalance = std::clamp(CENTER_BALANCE + balanceOffset, MIN_LEFT_BALANCE, MAX_RIGHT_BALANCE); - if (!_achievementFailed && _currentBalance < CENTER_BALANCE) - { - me->GetMap()->SetWorldState(WORLD_STATE_ID_NOT_AN_AMBI_TURNER, 1); - _achievementFailed = true; - } + if (!_achievementFailed && _currentBalance < CENTER_BALANCE) + { + me->GetMap()->SetWorldState(WORLD_STATE_ID_NOT_AN_AMBI_TURNER, 1); + _achievementFailed = true; + } - // Balance updated, update player power - for (auto const& i : me->GetMap()->GetPlayers()) - if (Player* player = i.GetSource()) - player->SetPower(POWER_ALTERNATE_POWER, _currentBalance); + // Balance updated, update player power + for (auto const& i : me->GetMap()->GetPlayers()) + if (Player* player = i.GetSource()) + player->SetPower(POWER_ALTERNATE_POWER, _currentBalance); - events.Repeat(500ms); // The timer for this event is very inconsistent in sniffs + events.Repeat(500ms); // The timer for this event is very inconsistent in sniffs + break; + } + case EVENT_HEATED_VOLCANO: + Talk(SAY_HEATED_VOLCANO); + DoCastAOE(SPELL_HEATED_VOLCANO, CastSpellExtraArgs().AddSpellMod(SPELLVALUE_MAX_TARGETS, 1)); + events.Repeat(25s); + break; + case EVENT_BALANCE_FEET_HEALTH: + { + Creature* footLeft = instance->GetCreature(DATA_LEFT_FOOT); + Creature* footRight = instance->GetCreature(DATA_RIGHT_FOOT); + + if (!footLeft || !footRight) + { + // One of the feet is missing. Encounter broke. Reset. + EnterEvadeMode(EVADE_REASON_OTHER); break; } - case EVENT_HEATED_VOLCANO: - Talk(SAY_HEATED_VOLCANO); - DoCastAOE(SPELL_HEATED_VOLCANO, CastSpellExtraArgs().AddSpellMod(SPELLVALUE_MAX_TARGETS, 1)); - events.Repeat(25s); - break; - case EVENT_BALANCE_FEET_HEALTH: - { - Creature* footLeft = instance->GetCreature(DATA_LEFT_FOOT); - Creature* footRight = instance->GetCreature(DATA_RIGHT_FOOT); - if (!footLeft || !footRight) - { - // One of the feet is missing. Encounter broke. Reset. - EnterEvadeMode(EVADE_REASON_OTHER); - break; - } + float targetHealthPct = (footLeft->GetHealthPct() + footRight->GetHealthPct()) / 2; + footLeft->SetHealth(CalculatePct(footLeft->GetMaxHealth(), targetHealthPct)); + footRight->SetHealth(CalculatePct(footRight->GetMaxHealth(), targetHealthPct)); - float targetHealthPct = (footLeft->GetHealthPct() + footRight->GetHealthPct()) / 2; - footLeft->SetHealth(CalculatePct(footLeft->GetMaxHealth(), targetHealthPct)); - footRight->SetHealth(CalculatePct(footRight->GetMaxHealth(), targetHealthPct)); - - // Deal damage to trigger the damage taken hook, which manages the model changes and phase switch - if (targetHealthPct < me->GetHealthPct()) - me->DealDamage(me, CalculatePct(me->GetMaxHealth(), me->GetHealthPct() - targetHealthPct)); - events.Repeat(5s); - break; + // Deal damage to trigger the damage taken hook, which manages the model changes and phase switch + if (targetHealthPct < me->GetHealthPct()) + Unit::DealDamage(me, me, CalculatePct(me->GetMaxHealth(), me->GetHealthPct() - targetHealthPct)); + events.Repeat(5s); + break; + } + case EVENT_LAVA_LINE: + if (!_recentlyBrokenVolcanos.empty()) + { + DoCastAOE(SPELL_LAVA_LINE); + _recentlyBrokenVolcanos.pop(); } - case EVENT_LAVA_LINE: - if (!_recentlyBrokenVolcanos.empty()) - { - DoCastAOE(SPELL_LAVA_LINE); - _recentlyBrokenVolcanos.pop(); - } - events.Repeat(10s); - break; - case EVENT_THERMAL_VENT: - DoCastAOE(SPELL_SUMMON_ROCK_ELEMENTALS); - events.Repeat(23s); - break; - case EVENT_STAND_UP: - me->SetAIAnimKitId(0); - events.ScheduleEvent(EVENT_TURN_AGGRESSIVE, 3s + 600ms); - break; - case EVENT_TURN_AGGRESSIVE: - me->SetReactState(REACT_AGGRESSIVE); - break; - case EVENT_UNLEASHED_FLAME: - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 50.f, true)) - DoCast(target, SPELL_UNLEASHED_FLAME); - events.Repeat(6s); - break; - case EVENT_SUPERHEATED: - DoCastSelf(SPELL_SUPERHEATED); - events.Repeat(10s); - break; - case EVENT_SEARCH_FOR_VOLANOS: + events.Repeat(10s); + break; + case EVENT_THERMAL_VENT: + DoCastAOE(SPELL_SUMMON_ROCK_ELEMENTALS); + events.Repeat(23s); + break; + case EVENT_STAND_UP: + me->SetAIAnimKitId(0); + events.ScheduleEvent(EVENT_TURN_AGGRESSIVE, 3s + 600ms); + break; + case EVENT_TURN_AGGRESSIVE: + me->SetReactState(REACT_AGGRESSIVE); + break; + case EVENT_UNLEASHED_FLAME: + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 50.f, true)) + DoCast(target, SPELL_UNLEASHED_FLAME); + events.Repeat(6s); + break; + case EVENT_SUPERHEATED: + DoCastSelf(SPELL_SUPERHEATED); + events.Repeat(10s); + break; + case EVENT_SEARCH_FOR_VOLANOS: + { + // There does not seem to be any serverside spell for searching for volcanos, so we have to do it like this + bool isOnAVolcano = false; + for (ObjectGuid const& summonGuid : summons) { - // There does not seem to be any serverside spell for searching for volcanos, so we have to do it like this - bool isOnAVolcano = false; - for (ObjectGuid const& summonGuid : summons) - { - Creature* summon = ObjectAccessor::GetCreature(*me, summonGuid); - if (!summon || summon->GetOriginalEntry() != NPC_VOLCANO) - continue; + Creature* summon = ObjectAccessor::GetCreature(*me, summonGuid); + if (!summon || summon->GetOriginalEntry() != NPC_VOLCANO) + continue; - if (summon->GetEntry() == NPC_VOLCANO || summon->GetEntry() == NPC_VOLCANO_HEATED || summon->GetEntry() == NPC_VOLCANO_CRATER) + if (summon->GetEntry() == NPC_VOLCANO || summon->GetEntry() == NPC_VOLCANO_HEATED || summon->GetEntry() == NPC_VOLCANO_CRATER) + { + if (me->GetExactDist2d(summon) < 10.f) { - if (me->GetExactDist2d(summon) < 10.f) + if (summon->GetEntry() == NPC_VOLCANO || summon->GetEntry() == NPC_VOLCANO_HEATED) { - if (summon->GetEntry() == NPC_VOLCANO || summon->GetEntry() == NPC_VOLCANO_HEATED) + // Volcano has been heated, the Obsidian Armor is being weakened + if (summon->GetEntry() == NPC_VOLCANO_HEATED) { - // Volcano has been heated, the Obsidian Armor is being weakened - if (summon->GetEntry() == NPC_VOLCANO_HEATED) - { - Talk(SAY_ANNOUNCE_ARMOR_WEAKENED); - Talk(SAY_ARMOR_WEAKENED); - if (Aura* armorAura = me->GetAura(SPELL_OBSIDIAN_ARMOR, me->GetGUID())) - armorAura->ModStackAmount(-16); + Talk(SAY_ANNOUNCE_ARMOR_WEAKENED); + Talk(SAY_ARMOR_WEAKENED); + if (Aura* armorAura = me->GetAura(SPELL_OBSIDIAN_ARMOR, me->GetGUID())) + armorAura->ModStackAmount(-16); - for (uint32 type : { DATA_LEFT_FOOT, DATA_RIGHT_FOOT }) + for (uint32 type : {DATA_LEFT_FOOT, DATA_RIGHT_FOOT}) + { + if (Creature* foot = instance->GetCreature(type)) { - if (Creature* foot = instance->GetCreature(type)) - { - if (Aura* armorAura = foot->GetAura(SPELL_OBSIDIAN_ARMOR)) - armorAura->ModStackAmount(-16); - - if (CreatureAI* ai = foot->AI()) - ai->DoAction(ACTION_RECALCULATE_DAMAGE_REDUCTION_MOD); - } - } + if (Aura* armorAura = foot->GetAura(SPELL_OBSIDIAN_ARMOR)) + armorAura->ModStackAmount(-16); - if (IsHeroic()) - for (uint8 i = 0; i < 5; ++i) - DoCastSelf(SPELL_SUMMON_ARMOR_FRAGMENT); + if (CreatureAI* ai = foot->AI()) + ai->DoAction(ACTION_RECALCULATE_DAMAGE_REDUCTION_MOD); + } } - if (CreatureAI* ai = summon->AI()) + if (IsHeroic()) + for (uint8 i = 0; i < 5; ++i) + DoCastSelf(SPELL_SUMMON_ARMOR_FRAGMENT); + } + + if (CreatureAI* ai = summon->AI()) + { + ai->DoAction(ACTION_DESTROY_VOLCANO); + _recentlyBrokenVolcanos.push(summonGuid); + if (!_hasBrokenFirstVolcano) { - ai->DoAction(ACTION_DESTROY_VOLCANO); - _recentlyBrokenVolcanos.push(summonGuid); - if (!_hasBrokenFirstVolcano) - { - _hasBrokenFirstVolcano = true; - events.ScheduleEvent(EVENT_LAVA_LINE, 11s); - } + _hasBrokenFirstVolcano = true; + events.ScheduleEvent(EVENT_LAVA_LINE, 11s); } } - - isOnAVolcano = true; } + + isOnAVolcano = true; } } + } - if (isOnAVolcano && !_hasBurningFeet) - { - DoCastSelf(SPELL_BURNING_FEET); - - for (uint32 type : { DATA_LEFT_FOOT, DATA_RIGHT_FOOT }) - if (Creature* foot = instance->GetCreature(type)) - foot->CastSpell(nullptr, SPELL_BURNING_FEET); + if (isOnAVolcano && !_hasBurningFeet) + { + DoCastSelf(SPELL_BURNING_FEET); - _hasBurningFeet = true; - } - else if (!isOnAVolcano && _hasBurningFeet) - { - me->RemoveAurasDueToSpell(SPELL_BURNING_FEET); - for (uint32 type : { DATA_LEFT_FOOT, DATA_RIGHT_FOOT }) - if (Creature* foot = instance->GetCreature(type)) - foot->RemoveAurasDueToSpell(SPELL_BURNING_FEET); + for (uint32 type : {DATA_LEFT_FOOT, DATA_RIGHT_FOOT}) + if (Creature* foot = instance->GetCreature(type)) + foot->CastSpell(nullptr, SPELL_BURNING_FEET); - _hasBurningFeet = false; - } + _hasBurningFeet = true; + } + else if (!isOnAVolcano && _hasBurningFeet) + { + me->RemoveAurasDueToSpell(SPELL_BURNING_FEET); + for (uint32 type : {DATA_LEFT_FOOT, DATA_RIGHT_FOOT}) + if (Creature* foot = instance->GetCreature(type)) + foot->RemoveAurasDueToSpell(SPELL_BURNING_FEET); - events.Repeat(500ms); - break; + _hasBurningFeet = false; } - default: - break; + + events.Repeat(500ms); + break; + } + default: + break; } if (me->HasUnitState(UNIT_STATE_CASTING)) @@ -693,12 +687,13 @@ struct boss_lord_rhyolith : public BossAI DoMeleeAttackIfReady(); } -private: + + private: void CleanupEncounter() { instance->SendEncounterUnit(ENCOUNTER_FRAME_DISENGAGE, me); - for (uint32 type : { DATA_LEFT_FOOT, DATA_RIGHT_FOOT }) + for (uint32 type : {DATA_LEFT_FOOT, DATA_RIGHT_FOOT}) { if (Creature* foot = instance->GetCreature(type)) instance->SendEncounterUnit(ENCOUNTER_FRAME_DISENGAGE, foot); @@ -745,7 +740,9 @@ static Optional GetIntersectionPoint(Position const& start, Position c struct npc_rhyolith_movement_controller_lord_rhyolith : public NullCreatureAI { - npc_rhyolith_movement_controller_lord_rhyolith(Creature* creature) : NullCreatureAI(creature), _instance(nullptr) { } + npc_rhyolith_movement_controller_lord_rhyolith(Creature* creature) : NullCreatureAI(creature), _instance(nullptr) + { + } void InitializeAI() override { @@ -756,16 +753,16 @@ struct npc_rhyolith_movement_controller_lord_rhyolith : public NullCreatureAI { switch (action) { - case ACTION_ENCOUNTER_STARTED: - // Launch an initial spline for the boss - _events.ScheduleEvent(EVENT_MOVE_LORD_RHYOLITH, 1ms); - _events.ScheduleEvent(EVENT_TELEPORT, 1s); - break; - case ACTION_STOP_MOVEMENT_CONTROL: - _events.Reset(); - break; - default: - break; + case ACTION_ENCOUNTER_STARTED: + // Launch an initial spline for the boss + _events.ScheduleEvent(EVENT_MOVE_LORD_RHYOLITH, 1ms); + _events.ScheduleEvent(EVENT_TELEPORT, 1s); + break; + case ACTION_STOP_MOVEMENT_CONTROL: + _events.Reset(); + break; + default: + break; } } @@ -777,58 +774,59 @@ struct npc_rhyolith_movement_controller_lord_rhyolith : public NullCreatureAI { switch (eventId) { - case EVENT_TELEPORT: - if (Creature* rhyolith = _instance->GetCreature(DATA_LORD_RHYOLITH)) - { - if (!rhyolith->IsAIEnabled()) - break; + case EVENT_TELEPORT: + if (Creature* rhyolith = _instance->GetCreature(DATA_LORD_RHYOLITH)) + { + if (!rhyolith->IsAIEnabled()) + break; - float angle = rhyolith->GetOrientation(); - uint32 balance = rhyolith->AI()->GetData(DATA_CURRENT_BALANCE); + float angle = rhyolith->GetOrientation(); + uint32 balance = rhyolith->AI()->GetData(DATA_CURRENT_BALANCE); - if (balance < 25) - angle += CalculatePct(float(M_PI_4), uint32(25) - balance); - else if (balance > 25) - angle -= CalculatePct(float(M_PI_4), balance - uint32(25)); + if (balance < 25) + angle += CalculatePct(float(M_PI_4), uint32(25) - balance); + else if (balance > 25) + angle -= CalculatePct(float(M_PI_4), balance - uint32(25)); - Position lineDest = rhyolith->GetPosition(); - lineDest.m_positionX += 1.f * std::cos(angle); - lineDest.m_positionY += 1.f * std::sin(angle); + Position lineDest = rhyolith->GetPosition(); + lineDest.m_positionX += 1.f * std::cos(angle); + lineDest.m_positionY += 1.f * std::sin(angle); - Optional destination = GetIntersectionPoint(rhyolith->GetPosition(), lineDest, PlateauPlatformCenterPosition, PlateauRadius); - if (!destination.has_value()) - { - // No intersections. The boss literally broke. Time for a reset. - if (CreatureAI* ai = rhyolith->AI()) - ai->EnterEvadeMode(); - break; - } + Optional destination = GetIntersectionPoint(rhyolith->GetPosition(), lineDest, PlateauPlatformCenterPosition, PlateauRadius); + if (!destination.has_value()) + { + // No intersections. The boss literally broke. Time for a reset. + if (CreatureAI* ai = rhyolith->AI()) + ai->EnterEvadeMode(); + break; + } - Position previousPosition = me->GetPosition(); + Position previousPosition = me->GetPosition(); - me->NearTeleportTo(*destination); + me->NearTeleportTo(*destination); - if (*destination != previousPosition) - _events.RescheduleEvent(EVENT_MOVE_LORD_RHYOLITH, 400ms); + if (*destination != previousPosition) + _events.RescheduleEvent(EVENT_MOVE_LORD_RHYOLITH, 400ms); - _events.Repeat(1s); - } - break; - case EVENT_MOVE_LORD_RHYOLITH: - if (Creature* rhyolith = _instance->GetCreature(DATA_LORD_RHYOLITH)) - { - if (!rhyolith->IsMovementPreventedByCasting()) - rhyolith->GetMotionMaster()->MovePoint(POINT_DRINK_MAGMA, me->GetPosition()); - else - _events.RescheduleEvent(EVENT_MOVE_LORD_RHYOLITH, 400ms); - } - break; - default: - break; + _events.Repeat(1s); + } + break; + case EVENT_MOVE_LORD_RHYOLITH: + if (Creature* rhyolith = _instance->GetCreature(DATA_LORD_RHYOLITH)) + { + if (!rhyolith->IsMovementPreventedByCasting()) + rhyolith->GetMotionMaster()->MovePoint(POINT_DRINK_MAGMA, me->GetPosition()); + else + _events.RescheduleEvent(EVENT_MOVE_LORD_RHYOLITH, 400ms); + } + break; + default: + break; } } } -private: + + private: EventMap _events; InstanceScript* _instance; }; @@ -837,7 +835,7 @@ struct npc_rhyolith_foot : public NullCreatureAI { npc_rhyolith_foot(Creature* creature) : NullCreatureAI(creature), _damageCleanupTimer(500), _damageReductionModifier(0.f) { - _damagePerSecond = { }; + _damagePerSecond = {}; } void DamageTaken(Unit* /*attacker*/, uint32& damage) override @@ -852,10 +850,10 @@ struct npc_rhyolith_foot : public NullCreatureAI { switch (type) { - case DATA_DAMAGE_PER_SECOND: - return _damagePerSecond[0] + _damagePerSecond[1]; - default: - return 0; + case DATA_DAMAGE_PER_SECOND: + return _damagePerSecond[0] + _damagePerSecond[1]; + default: + return 0; } return 0; @@ -865,14 +863,12 @@ struct npc_rhyolith_foot : public NullCreatureAI { switch (action) { - case ACTION_RECALCULATE_DAMAGE_REDUCTION_MOD: - _damageReductionModifier = 100.f * (1.f - me->GetTotalAuraMultiplier(SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN, [&](AuraEffect const* aurEff) - { - return aurEff->GetSpellInfo()->Id == SPELL_OBSIDIAN_ARMOR; - })); - break; - default: - break; + case ACTION_RECALCULATE_DAMAGE_REDUCTION_MOD: + _damageReductionModifier = + 100.f * (1.f - me->GetTotalAuraMultiplier(SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN, [&](AuraEffect const* aurEff) { return aurEff->GetSpellInfo()->Id == SPELL_OBSIDIAN_ARMOR; })); + break; + default: + break; } } @@ -888,7 +884,7 @@ struct npc_rhyolith_foot : public NullCreatureAI } } -private: + private: int32 _damageCleanupTimer; float _damageReductionModifier; std::array _damagePerSecond; @@ -896,34 +892,36 @@ struct npc_rhyolith_foot : public NullCreatureAI struct npc_rhyolith_volcano : public NullCreatureAI { - npc_rhyolith_volcano(Creature* creature) : NullCreatureAI(creature) { } + npc_rhyolith_volcano(Creature* creature) : NullCreatureAI(creature) + { + } void DoAction(int32 action) override { switch (action) { - case ACTION_ACTIVATE_VOLCANO: - me->UpdateEntry(NPC_VOLCANO_HEATED, nullptr, false); - if (CreatureTemplate const* transformTemplate = sObjectMgr->GetCreatureTemplate(NPC_VOLCANO_HEATED)) - me->SetDisplayId(transformTemplate->Modelid2); - _events.ScheduleEvent(EVENT_ERUPTION, 5s); - break; - case ACTION_SCHEDULE_MAGMA_FLOW: - _events.ScheduleEvent(EVENT_MAGMA_FLOW, 4s); - break; - case ACTION_DESTROY_VOLCANO: - _events.CancelEvent(EVENT_ERUPTION); - me->RemoveAurasDueToSpell(SPELL_VOLCANO_BASE); - me->RemoveAurasDueToSpell(SPELL_ERUPTION); - DoCastSelf(SPELL_EXPLOSION); - DoCastSelf(SPELL_MAGMA); - - me->UpdateEntry(NPC_VOLCANO_CRATER, nullptr, false); - if (CreatureTemplate const* transformTemplate = sObjectMgr->GetCreatureTemplate(NPC_VOLCANO_CRATER)) - me->SetDisplayId(transformTemplate->Modelid2); - break; - default: - break; + case ACTION_ACTIVATE_VOLCANO: + me->UpdateEntry(NPC_VOLCANO_HEATED, nullptr, false); + if (CreatureTemplate const* transformTemplate = sObjectMgr->GetCreatureTemplate(NPC_VOLCANO_HEATED)) + me->SetDisplayId(transformTemplate->Modelid2); + _events.ScheduleEvent(EVENT_ERUPTION, 5s); + break; + case ACTION_SCHEDULE_MAGMA_FLOW: + _events.ScheduleEvent(EVENT_MAGMA_FLOW, 4s); + break; + case ACTION_DESTROY_VOLCANO: + _events.CancelEvent(EVENT_ERUPTION); + me->RemoveAurasDueToSpell(SPELL_VOLCANO_BASE); + me->RemoveAurasDueToSpell(SPELL_ERUPTION); + DoCastSelf(SPELL_EXPLOSION); + DoCastSelf(SPELL_MAGMA); + + me->UpdateEntry(NPC_VOLCANO_CRATER, nullptr, false); + if (CreatureTemplate const* transformTemplate = sObjectMgr->GetCreatureTemplate(NPC_VOLCANO_CRATER)) + me->SetDisplayId(transformTemplate->Modelid2); + break; + default: + break; } } @@ -935,24 +933,27 @@ struct npc_rhyolith_volcano : public NullCreatureAI { switch (eventId) { - case EVENT_ERUPTION: - DoCastSelf(SPELL_ERUPTION); - break; - case EVENT_MAGMA_FLOW: - DoCastSelf(SPELL_MAGMA_FLOW); - break; - default: - break; + case EVENT_ERUPTION: + DoCastSelf(SPELL_ERUPTION); + break; + case EVENT_MAGMA_FLOW: + DoCastSelf(SPELL_MAGMA_FLOW); + break; + default: + break; } } } -private: + + private: EventMap _events; }; struct npc_rhyolith_liquid_obsidian : public PassiveAI { - npc_rhyolith_liquid_obsidian(Creature* creature) : PassiveAI(creature), _instance(nullptr) { } + npc_rhyolith_liquid_obsidian(Creature* creature) : PassiveAI(creature), _instance(nullptr) + { + } void InitializeAI() override { @@ -972,25 +973,25 @@ struct npc_rhyolith_liquid_obsidian : public PassiveAI { switch (eventId) { - case EVENT_FUSE_WITH_LORD_RHYOLITH: - if (Creature* rhyolith = _instance->GetCreature(DATA_LORD_RHYOLITH)) + case EVENT_FUSE_WITH_LORD_RHYOLITH: + if (Creature* rhyolith = _instance->GetCreature(DATA_LORD_RHYOLITH)) + { + if (me->GetExactDist2d(rhyolith) < 10.f) + DoCastSelf(SPELL_FUSE); + else { - if (me->GetExactDist2d(rhyolith) < 10.f) - DoCastSelf(SPELL_FUSE); - else - { - me->GetMotionMaster()->MovePoint(POINT_NONE, rhyolith->GetPosition()); - _events.Repeat(1s); - } + me->GetMotionMaster()->MovePoint(POINT_NONE, rhyolith->GetPosition()); + _events.Repeat(1s); } - break; - default: - break; + } + break; + default: + break; } } } -private: + private: InstanceScript* _instance; EventMap _events; }; @@ -999,7 +1000,7 @@ class spell_rhyolith_drink_magma : public SpellScript { bool Validate(SpellInfo const* /*spell*/) override { - return ValidateSpellInfo({ SPELL_MOLTEN_SPEW }); + return ValidateSpellInfo({SPELL_MOLTEN_SPEW}); } void HandleDummyEffect(SpellEffIndex /*effIndex*/) @@ -1054,7 +1055,8 @@ class spell_rhyolith_concussive_stomp : public SpellScript OnObjectAreaTargetSelect.Register(&spell_rhyolith_concussive_stomp::StoreVolcanoTargets, EFFECT_1, TARGET_UNIT_DEST_AREA_ENEMY); OnEffectHitTarget.Register(&spell_rhyolith_concussive_stomp::HandleDummyEffect, EFFECT_0, SPELL_EFFECT_DUMMY); } -private: + + private: std::vector _volcanoTargetGUIDs; }; @@ -1062,17 +1064,14 @@ class spell_rhyolith_heated_volcano : public SpellScript { bool Validate(SpellInfo const* /*spell*/) override { - return ValidateSpellInfo({ SPELL_ERUPTION }); + return ValidateSpellInfo({SPELL_ERUPTION}); } void FilterTargets(std::list& targets) { // Hotfix (2011-07-06): Lord Rhyolith now prefers to activate volcanoes that are in front of him over volcanoes that are behind him. std::list targetsCopy = targets; - targetsCopy.remove_if([&](WorldObject const* target) - { - return !GetCaster()->isInFront(target); - }); + targetsCopy.remove_if([&](WorldObject const* target) { return !GetCaster()->isInFront(target); }); if (!targetsCopy.empty()) targets = targetsCopy; @@ -1096,7 +1095,7 @@ class spell_rhyolith_lava_strike_visual : public SpellScript { void SetDest(SpellDestination& dest) { - dest.RelocateOffset({ frand(-20.f, 20.f), frand(-20.f, 20.f), frand(25.f, 70.f), 0.f }); + dest.RelocateOffset({frand(-20.f, 20.f), frand(-20.f, 20.f), frand(25.f, 70.f), 0.f}); } void Register() @@ -1105,7 +1104,7 @@ class spell_rhyolith_lava_strike_visual : public SpellScript } }; -class spell_rhyolith_lava_strike: public SpellScript +class spell_rhyolith_lava_strike : public SpellScript { void FilterTargets(std::list& targets) { @@ -1135,7 +1134,7 @@ class spell_rhyolith_lava_line : public SpellScript { bool Validate(SpellInfo const* /*spell*/) override { - return ValidateSpellInfo({ SPELL_SUMMON_TUBE }); + return ValidateSpellInfo({SPELL_SUMMON_TUBE}); } void FilterTargets(std::list& targets) @@ -1148,10 +1147,7 @@ class spell_rhyolith_lava_line : public SpellScript { ObjectGuid volcanoGuid = ai->GetGUID(DATA_RECENTLY_BROKEN_VOLCANO); if (!volcanoGuid.IsEmpty()) - targets.remove_if([volcanoGuid](WorldObject const* target) - { - return target->GetGUID() != volcanoGuid; - }); + targets.remove_if([volcanoGuid](WorldObject const* target) { return target->GetGUID() != volcanoGuid; }); } } @@ -1168,7 +1164,6 @@ class spell_rhyolith_lava_line : public SpellScript Position summonDest = target->GetPosition(); summonDest.m_positionZ -= 6.f; caster->CastSpell(summonDest, SPELL_SUMMON_TUBE); - } void Register() override @@ -1178,7 +1173,7 @@ class spell_rhyolith_lava_line : public SpellScript } }; -static constexpr float Magnitude = 1.f; // Maximum wave outbreak +static constexpr float Magnitude = 1.f; // Maximum wave outbreak static Position GetSineWavePoint(Position const& origin, float angle, uint32 auraTickNumber, float frequency) { @@ -1199,11 +1194,7 @@ class spell_rhyolith_magma_flow : public AuraScript { bool Validate(SpellInfo const* /*spell*/) override { - return ValidateSpellInfo( - { - SPELL_MAGMA_FLOW_DAMAGE, - SPELL_MAGMA_FLOW_MISSILE - }); + return ValidateSpellInfo({SPELL_MAGMA_FLOW_DAMAGE, SPELL_MAGMA_FLOW_MISSILE}); } bool Load() override @@ -1259,7 +1250,8 @@ class spell_rhyolith_magma_flow : public AuraScript OnEffectPeriodic.Register(&spell_rhyolith_magma_flow::HandleEffectPeriodic, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY); AfterEffectRemove.Register(&spell_rhyolith_magma_flow::HandleEffectRemove, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY, AURA_EFFECT_HANDLE_REAL); } -private: + + private: bool _detonated = false; uint8 _lineCount = 0; float _angleOffset = 0.f; @@ -1271,7 +1263,7 @@ class spell_rhyolith_immolation : public AuraScript { bool Validate(SpellInfo const* /*spell*/) override { - return ValidateSpellInfo({ SPELL_INFERNAL_RAGE }); + return ValidateSpellInfo({SPELL_INFERNAL_RAGE}); } void HandleEffectPeriodic(AuraEffect const* aurEff) @@ -1303,7 +1295,6 @@ class spell_rhyolith_meltdown : public SpellScript targets = _storedTargets; } - void CalculateDamage() { Unit* caster = GetCaster(); @@ -1322,7 +1313,8 @@ class spell_rhyolith_meltdown : public SpellScript BeforeCast.Register(&spell_rhyolith_meltdown::CalculateDamage); OnEffectLaunchTarget.Register(&spell_rhyolith_meltdown::ModifyDamage, EFFECT_0, SPELL_EFFECT_SCHOOL_DAMAGE); } -private: + + private: int32 damage = 0; std::list _storedTargets; }; @@ -1362,7 +1354,7 @@ class spell_rhyolith_summon_rock_elementals : public SpellScript AfterCast.Register(&spell_rhyolith_summon_rock_elementals::SummonElementals); } -private: + private: std::vector _elementalTargetGUIDs; uint32 _summonSpellId = 0; }; diff --git a/src/server/scripts/Kalimdor/OnyxiasLair/boss_onyxia.cpp b/src/server/scripts/Kalimdor/OnyxiasLair/boss_onyxia.cpp index eba5c361..51bca874 100644 --- a/src/server/scripts/Kalimdor/OnyxiasLair/boss_onyxia.cpp +++ b/src/server/scripts/Kalimdor/OnyxiasLair/boss_onyxia.cpp @@ -25,69 +25,69 @@ SDComment: SDCategory: Onyxia's Lair EndScriptData */ -#include "ScriptMgr.h" #include "CellImpl.h" #include "GridNotifiersImpl.h" #include "InstanceScript.h" #include "MotionMaster.h" #include "ObjectAccessor.h" -#include "onyxias_lair.h" +#include "ScriptMgr.h" #include "ScriptedCreature.h" #include "TemporarySummon.h" +#include "onyxias_lair.h" enum Yells { // Say - SAY_AGGRO = 0, - SAY_KILL = 1, - SAY_PHASE_2_TRANS = 2, - SAY_PHASE_3_TRANS = 3, + SAY_AGGRO = 0, + SAY_KILL = 1, + SAY_PHASE_2_TRANS = 2, + SAY_PHASE_3_TRANS = 3, // Emote - EMOTE_BREATH = 4 + EMOTE_BREATH = 4 }; enum Spells { // Phase 1 spells - SPELL_WING_BUFFET = 18500, - SPELL_FLAME_BREATH = 18435, - SPELL_CLEAVE = 68868, - SPELL_TAIL_SWEEP = 68867, + SPELL_WING_BUFFET = 18500, + SPELL_FLAME_BREATH = 18435, + SPELL_CLEAVE = 68868, + SPELL_TAIL_SWEEP = 68867, // Phase 2 spells - SPELL_DEEP_BREATH = 23461, - SPELL_FIREBALL = 18392, + SPELL_DEEP_BREATH = 23461, + SPELL_FIREBALL = 18392, - //Not much choise about these. We have to make own defintion on the direction/start-end point - SPELL_BREATH_NORTH_TO_SOUTH = 17086, // 20x in "array" - SPELL_BREATH_SOUTH_TO_NORTH = 18351, // 11x in "array" + // Not much choise about these. We have to make own defintion on the direction/start-end point + SPELL_BREATH_NORTH_TO_SOUTH = 17086, // 20x in "array" + SPELL_BREATH_SOUTH_TO_NORTH = 18351, // 11x in "array" - SPELL_BREATH_EAST_TO_WEST = 18576, // 7x in "array" - SPELL_BREATH_WEST_TO_EAST = 18609, // 7x in "array" + SPELL_BREATH_EAST_TO_WEST = 18576, // 7x in "array" + SPELL_BREATH_WEST_TO_EAST = 18609, // 7x in "array" - SPELL_BREATH_SE_TO_NW = 18564, // 12x in "array" - SPELL_BREATH_NW_TO_SE = 18584, // 12x in "array" - SPELL_BREATH_SW_TO_NE = 18596, // 12x in "array" - SPELL_BREATH_NE_TO_SW = 18617, // 12x in "array" + SPELL_BREATH_SE_TO_NW = 18564, // 12x in "array" + SPELL_BREATH_NW_TO_SE = 18584, // 12x in "array" + SPELL_BREATH_SW_TO_NE = 18596, // 12x in "array" + SPELL_BREATH_NE_TO_SW = 18617, // 12x in "array" - //SPELL_BREATH = 21131, // 8x in "array", different initial cast than the other arrays + // SPELL_BREATH = 21131, // 8x in "array", different initial cast than the other arrays // Phase 3 spells - SPELL_BELLOWING_ROAR = 18431 + SPELL_BELLOWING_ROAR = 18431 }; enum Events { EVENT_BELLOWING_ROAR = 1, - EVENT_FLAME_BREATH = 2, - EVENT_TAIL_SWEEP = 3, - EVENT_CLEAVE = 4, - EVENT_WING_BUFFET = 5, - EVENT_DEEP_BREATH = 6, - EVENT_MOVEMENT = 7, - EVENT_FIREBALL = 8, - EVENT_LAIR_GUARD = 9, - EVENT_WHELP_SPAWN = 10 + EVENT_FLAME_BREATH = 2, + EVENT_TAIL_SWEEP = 3, + EVENT_CLEAVE = 4, + EVENT_WING_BUFFET = 5, + EVENT_DEEP_BREATH = 6, + EVENT_MOVEMENT = 7, + EVENT_FIREBALL = 8, + EVENT_LAIR_GUARD = 9, + EVENT_WHELP_SPAWN = 10 }; struct OnyxMove @@ -98,36 +98,34 @@ struct OnyxMove float fX, fY, fZ; }; -static OnyxMove MoveData[8]= -{ - {0, 1, SPELL_BREATH_WEST_TO_EAST, -33.5561f, -182.682f, -56.9457f}, //west - {1, 0, SPELL_BREATH_EAST_TO_WEST, -31.4963f, -250.123f, -55.1278f}, //east - {2, 4, SPELL_BREATH_NW_TO_SE, 6.8951f, -180.246f, -55.896f}, //north-west - {3, 5, SPELL_BREATH_NE_TO_SW, 10.2191f, -247.912f, -55.896f}, //north-east - {4, 2, SPELL_BREATH_SE_TO_NW, -63.5156f, -240.096f, -55.477f}, //south-east - {5, 3, SPELL_BREATH_SW_TO_NE, -58.2509f, -189.020f, -55.790f}, //south-west - {6, 7, SPELL_BREATH_SOUTH_TO_NORTH, -65.8444f, -213.809f, -55.2985f}, //south - {7, 6, SPELL_BREATH_NORTH_TO_SOUTH, 22.8763f, -217.152f, -55.0548f}, //north +static OnyxMove MoveData[8] = { + {0, 1, SPELL_BREATH_WEST_TO_EAST, -33.5561f, -182.682f, -56.9457f}, // west + {1, 0, SPELL_BREATH_EAST_TO_WEST, -31.4963f, -250.123f, -55.1278f}, // east + {2, 4, SPELL_BREATH_NW_TO_SE, 6.8951f, -180.246f, -55.896f}, // north-west + {3, 5, SPELL_BREATH_NE_TO_SW, 10.2191f, -247.912f, -55.896f}, // north-east + {4, 2, SPELL_BREATH_SE_TO_NW, -63.5156f, -240.096f, -55.477f}, // south-east + {5, 3, SPELL_BREATH_SW_TO_NE, -58.2509f, -189.020f, -55.790f}, // south-west + {6, 7, SPELL_BREATH_SOUTH_TO_NORTH, -65.8444f, -213.809f, -55.2985f}, // south + {7, 6, SPELL_BREATH_NORTH_TO_SOUTH, 22.8763f, -217.152f, -55.0548f}, // north }; Position const MiddleRoomLocation = {-23.6155f, -215.357f, -55.7344f, 0.0f}; Position const Phase2Location = {-80.924f, -214.299f, -82.942f, 0.0f}; -Position const Phase2Floating = { -80.924f, -214.299f, -57.942f, 0.0f }; +Position const Phase2Floating = {-80.924f, -214.299f, -57.942f, 0.0f}; -Position const SpawnLocations[3]= -{ - //Whelps - {-30.127f, -254.463f, -89.440f, 0.0f}, - {-30.817f, -177.106f, -89.258f, 0.0f}, - //Lair Guard - {-145.950f, -212.831f, -68.659f, 0.0f} -}; +Position const SpawnLocations[3] = { + // Whelps + {-30.127f, -254.463f, -89.440f, 0.0f}, {-30.817f, -177.106f, -89.258f, 0.0f}, + // Lair Guard + {-145.950f, -212.831f, -68.659f, 0.0f}}; class boss_onyxia : public CreatureScript { -public: - boss_onyxia() : CreatureScript("boss_onyxia") { } + public: + boss_onyxia() : CreatureScript("boss_onyxia") + { + } struct boss_onyxiaAI : public BossAI { @@ -179,18 +177,17 @@ class boss_onyxia : public CreatureScript switch (summoned->GetEntry()) { - case NPC_WHELP: - ++SummonWhelpCount; - break; - case NPC_LAIRGUARD: - summoned->setActive(true); - summoned->SetFarVisible(true); - break; + case NPC_WHELP: + ++SummonWhelpCount; + break; + case NPC_LAIRGUARD: + summoned->setActive(true); + summoned->SetFarVisible(true); + break; } summons.Summon(summoned); } - void KilledUnit(Unit* /*victim*/) override { Talk(SAY_KILL); @@ -198,12 +195,8 @@ class boss_onyxia : public CreatureScript void SpellHit(Unit* /*pCaster*/, SpellInfo const* Spell) override { - if (Spell->Id == SPELL_BREATH_EAST_TO_WEST || - Spell->Id == SPELL_BREATH_WEST_TO_EAST || - Spell->Id == SPELL_BREATH_SE_TO_NW || - Spell->Id == SPELL_BREATH_NW_TO_SE || - Spell->Id == SPELL_BREATH_SW_TO_NE || - Spell->Id == SPELL_BREATH_NE_TO_SW) + if (Spell->Id == SPELL_BREATH_EAST_TO_WEST || Spell->Id == SPELL_BREATH_WEST_TO_EAST || Spell->Id == SPELL_BREATH_SE_TO_NW || Spell->Id == SPELL_BREATH_NW_TO_SE || + Spell->Id == SPELL_BREATH_SW_TO_NE || Spell->Id == SPELL_BREATH_NE_TO_SW) { PointData = GetMoveData(); MovePoint = PointData->LocIdEnd; @@ -219,73 +212,65 @@ class boss_onyxia : public CreatureScript { switch (id) { - case 8: - PointData = GetMoveData(); - if (PointData) - { - me->SetSpeedRate(MOVE_FLIGHT, 1.0f); - me->GetMotionMaster()->MovePoint(PointData->LocId, PointData->fX, PointData->fY, PointData->fZ); - } - break; - case 9: - me->SetCanFly(false); - me->SetDisableGravity(false); - if (Creature* trigger = ObjectAccessor::GetCreature(*me, triggerGUID)) - me->Kill(trigger); - me->SetReactState(REACT_AGGRESSIVE); - // tank selection based on phase one. If tank is not there i take nearest one - if (Unit* tank = ObjectAccessor::GetUnit(*me, tankGUID)) - me->GetMotionMaster()->MoveChase(tank); - else if (Unit* newtarget = SelectTarget(SELECT_TARGET_MINDISTANCE, 0)) - me->GetMotionMaster()->MoveChase(newtarget); - events.ScheduleEvent(EVENT_BELLOWING_ROAR, 5000); - events.ScheduleEvent(EVENT_FLAME_BREATH, urand(10000, 20000)); - events.ScheduleEvent(EVENT_TAIL_SWEEP, urand(15000, 20000)); - events.ScheduleEvent(EVENT_CLEAVE, urand(2000, 5000)); - events.ScheduleEvent(EVENT_WING_BUFFET, urand(15000, 30000)); - break; - case 10: - me->SetCanFly(true); - me->SetDisableGravity(true); - me->SetFacingTo(me->GetOrientation() + float(M_PI)); - if (Creature * trigger = me->SummonCreature(NPC_TRIGGER, MiddleRoomLocation, TEMPSUMMON_CORPSE_DESPAWN)) - triggerGUID = trigger->GetGUID(); - me->GetMotionMaster()->MoveTakeoff(11, Phase2Floating); + case 8: + PointData = GetMoveData(); + if (PointData) + { me->SetSpeedRate(MOVE_FLIGHT, 1.0f); - Talk(SAY_PHASE_2_TRANS); - instance->SetData(DATA_ONYXIA_PHASE, Phase); - events.ScheduleEvent(EVENT_WHELP_SPAWN, 5000); - events.ScheduleEvent(EVENT_LAIR_GUARD, 15000); - events.ScheduleEvent(EVENT_DEEP_BREATH, 75000); - events.ScheduleEvent(EVENT_MOVEMENT, 10000); - events.ScheduleEvent(EVENT_FIREBALL, 18000); - break; - case 11: - if (PointData) - me->GetMotionMaster()->MovePoint(PointData->LocId, PointData->fX, PointData->fY, PointData->fZ); - me->GetMotionMaster()->MoveIdle(); - break; - default: - IsMoving = false; - break; + me->GetMotionMaster()->MovePoint(PointData->LocId, PointData->fX, PointData->fY, PointData->fZ); + } + break; + case 9: + me->SetCanFly(false); + me->SetDisableGravity(false); + if (Creature* trigger = ObjectAccessor::GetCreature(*me, triggerGUID)) + Unit::Kill(me, trigger); + me->SetReactState(REACT_AGGRESSIVE); + // tank selection based on phase one. If tank is not there i take nearest one + if (Unit* tank = ObjectAccessor::GetUnit(*me, tankGUID)) + me->GetMotionMaster()->MoveChase(tank); + else if (Unit* newtarget = SelectTarget(SELECT_TARGET_MINDISTANCE, 0)) + me->GetMotionMaster()->MoveChase(newtarget); + events.ScheduleEvent(EVENT_BELLOWING_ROAR, 5000); + events.ScheduleEvent(EVENT_FLAME_BREATH, urand(10000, 20000)); + events.ScheduleEvent(EVENT_TAIL_SWEEP, urand(15000, 20000)); + events.ScheduleEvent(EVENT_CLEAVE, urand(2000, 5000)); + events.ScheduleEvent(EVENT_WING_BUFFET, urand(15000, 30000)); + break; + case 10: + me->SetCanFly(true); + me->SetDisableGravity(true); + me->SetFacingTo(me->GetOrientation() + float(M_PI)); + if (Creature* trigger = me->SummonCreature(NPC_TRIGGER, MiddleRoomLocation, TEMPSUMMON_CORPSE_DESPAWN)) + triggerGUID = trigger->GetGUID(); + me->GetMotionMaster()->MoveTakeoff(11, Phase2Floating); + me->SetSpeedRate(MOVE_FLIGHT, 1.0f); + Talk(SAY_PHASE_2_TRANS); + instance->SetData(DATA_ONYXIA_PHASE, Phase); + events.ScheduleEvent(EVENT_WHELP_SPAWN, 5000); + events.ScheduleEvent(EVENT_LAIR_GUARD, 15000); + events.ScheduleEvent(EVENT_DEEP_BREATH, 75000); + events.ScheduleEvent(EVENT_MOVEMENT, 10000); + events.ScheduleEvent(EVENT_FIREBALL, 18000); + break; + case 11: + if (PointData) + me->GetMotionMaster()->MovePoint(PointData->LocId, PointData->fX, PointData->fY, PointData->fZ); + me->GetMotionMaster()->MoveIdle(); + break; + default: + IsMoving = false; + break; } } } void SpellHitTarget(Unit* target, SpellInfo const* Spell) override { - //Workaround - Couldn't find a way to group this spells (All Eruption) - if (((Spell->Id >= 17086 && Spell->Id <= 17095) || - (Spell->Id == 17097) || - (Spell->Id >= 18351 && Spell->Id <= 18361) || - (Spell->Id >= 18564 && Spell->Id <= 18576) || - (Spell->Id >= 18578 && Spell->Id <= 18607) || - (Spell->Id == 18609) || - (Spell->Id >= 18611 && Spell->Id <= 18628) || - (Spell->Id >= 21132 && Spell->Id <= 21133) || - (Spell->Id >= 21135 && Spell->Id <= 21139) || - (Spell->Id >= 22191 && Spell->Id <= 22202) || - (Spell->Id >= 22267 && Spell->Id <= 22268)) && + // Workaround - Couldn't find a way to group this spells (All Eruption) + if (((Spell->Id >= 17086 && Spell->Id <= 17095) || (Spell->Id == 17097) || (Spell->Id >= 18351 && Spell->Id <= 18361) || (Spell->Id >= 18564 && Spell->Id <= 18576) || + (Spell->Id >= 18578 && Spell->Id <= 18607) || (Spell->Id == 18609) || (Spell->Id >= 18611 && Spell->Id <= 18628) || (Spell->Id >= 21132 && Spell->Id <= 21133) || + (Spell->Id >= 21135 && Spell->Id <= 21139) || (Spell->Id >= 22191 && Spell->Id <= 22202) || (Spell->Id >= 22267 && Spell->Id <= 22268)) && (target->GetTypeId() == TYPEID_PLAYER)) { instance->SetData(DATA_SHE_DEEP_BREATH_MORE, FAIL); @@ -322,10 +307,10 @@ class boss_onyxia : public CreatureScript if (!UpdateVictim()) return; - //Common to PHASE_START && PHASE_END + // Common to PHASE_START && PHASE_END if (Phase == PHASE_START || Phase == PHASE_END) { - //Specific to PHASE_START || PHASE_END + // Specific to PHASE_START || PHASE_END if (Phase == PHASE_START) { if (HealthBelowPct(65)) @@ -350,37 +335,37 @@ class boss_onyxia : public CreatureScript { switch (eventId) { - case EVENT_BELLOWING_ROAR: // Phase PHASE_END - { - DoCastVictim(SPELL_BELLOWING_ROAR); - // Eruption - GameObject* Floor = nullptr; - Firelands::GameObjectInRangeCheck check(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), 15); - Firelands::GameObjectLastSearcher searcher(me, Floor, check); - Cell::VisitGridObjects(me, searcher, 30.0f); - if (Floor) - instance->SetGuidData(DATA_FLOOR_ERUPTION_GUID, Floor->GetGUID()); - events.ScheduleEvent(EVENT_BELLOWING_ROAR, 30000); - break; - } - case EVENT_FLAME_BREATH: // Phase PHASE_START and PHASE_END - DoCastVictim(SPELL_FLAME_BREATH); - events.ScheduleEvent(EVENT_FLAME_BREATH, urand(10000, 20000)); - break; - case EVENT_TAIL_SWEEP: // Phase PHASE_START and PHASE_END - DoCastAOE(SPELL_TAIL_SWEEP); - events.ScheduleEvent(EVENT_TAIL_SWEEP, urand(15000, 20000)); - break; - case EVENT_CLEAVE: // Phase PHASE_START and PHASE_END - DoCastVictim(SPELL_CLEAVE); - events.ScheduleEvent(EVENT_CLEAVE, urand(2000, 5000)); - break; - case EVENT_WING_BUFFET: // Phase PHASE_START and PHASE_END - DoCastVictim(SPELL_WING_BUFFET); - events.ScheduleEvent(EVENT_WING_BUFFET, urand(15000, 30000)); - break; - default: - break; + case EVENT_BELLOWING_ROAR: // Phase PHASE_END + { + DoCastVictim(SPELL_BELLOWING_ROAR); + // Eruption + GameObject* Floor = nullptr; + Firelands::GameObjectInRangeCheck check(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), 15); + Firelands::GameObjectLastSearcher searcher(me, Floor, check); + Cell::VisitGridObjects(me, searcher, 30.0f); + if (Floor) + instance->SetGuidData(DATA_FLOOR_ERUPTION_GUID, Floor->GetGUID()); + events.ScheduleEvent(EVENT_BELLOWING_ROAR, 30000); + break; + } + case EVENT_FLAME_BREATH: // Phase PHASE_START and PHASE_END + DoCastVictim(SPELL_FLAME_BREATH); + events.ScheduleEvent(EVENT_FLAME_BREATH, urand(10000, 20000)); + break; + case EVENT_TAIL_SWEEP: // Phase PHASE_START and PHASE_END + DoCastAOE(SPELL_TAIL_SWEEP); + events.ScheduleEvent(EVENT_TAIL_SWEEP, urand(15000, 20000)); + break; + case EVENT_CLEAVE: // Phase PHASE_START and PHASE_END + DoCastVictim(SPELL_CLEAVE); + events.ScheduleEvent(EVENT_CLEAVE, urand(2000, 5000)); + break; + case EVENT_WING_BUFFET: // Phase PHASE_START and PHASE_END + DoCastVictim(SPELL_WING_BUFFET); + events.ScheduleEvent(EVENT_WING_BUFFET, urand(15000, 30000)); + break; + default: + break; } if (me->HasUnitState(UNIT_STATE_CASTING)) @@ -416,63 +401,63 @@ class boss_onyxia : public CreatureScript { switch (eventId) { - case EVENT_DEEP_BREATH: // Phase PHASE_BREATH - if (!IsMoving) - { - if (me->IsNonMeleeSpellCast(false)) - me->InterruptNonMeleeSpells(false); - - Talk(EMOTE_BREATH); - if (PointData) /// @todo: In what cases is this null? What should we do? - DoCast(me, PointData->SpellId); - events.ScheduleEvent(EVENT_DEEP_BREATH, 75000); - } - else - events.ScheduleEvent(EVENT_DEEP_BREATH, 1000); - break; - case EVENT_MOVEMENT: // Phase PHASE_BREATH - if (!IsMoving && !(me->HasUnitState(UNIT_STATE_CASTING))) - { - SetNextRandomPoint(); - PointData = GetMoveData(); - - if (!PointData) - return; - - me->GetMotionMaster()->MovePoint(PointData->LocId, PointData->fX, PointData->fY, PointData->fZ); - IsMoving = true; - events.ScheduleEvent(EVENT_MOVEMENT, 25000); - } - else - events.ScheduleEvent(EVENT_MOVEMENT, 500); - break; - case EVENT_FIREBALL: // Phase PHASE_BREATH - if (!IsMoving) - { - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) - DoCast(target, SPELL_FIREBALL); - events.ScheduleEvent(EVENT_FIREBALL, 8000); - } - else - events.ScheduleEvent(EVENT_FIREBALL, 1000); - break; - case EVENT_LAIR_GUARD: // Phase PHASE_BREATH - me->SummonCreature(NPC_LAIRGUARD, SpawnLocations[2], TEMPSUMMON_CORPSE_DESPAWN); - events.ScheduleEvent(EVENT_LAIR_GUARD, 30000); - break; - case EVENT_WHELP_SPAWN: // Phase PHASE_BREATH - me->SummonCreature(NPC_WHELP, SpawnLocations[0], TEMPSUMMON_CORPSE_DESPAWN); - me->SummonCreature(NPC_WHELP, SpawnLocations[1], TEMPSUMMON_CORPSE_DESPAWN); - if (SummonWhelpCount >= RAID_MODE(20, 40)) - { - SummonWhelpCount = 0; - events.ScheduleEvent(EVENT_WHELP_SPAWN, 90000); - } - else - events.ScheduleEvent(EVENT_WHELP_SPAWN, 500); - break; - default: - break; + case EVENT_DEEP_BREATH: // Phase PHASE_BREATH + if (!IsMoving) + { + if (me->IsNonMeleeSpellCast(false)) + me->InterruptNonMeleeSpells(false); + + Talk(EMOTE_BREATH); + if (PointData) /// @todo: In what cases is this null? What should we do? + DoCast(me, PointData->SpellId); + events.ScheduleEvent(EVENT_DEEP_BREATH, 75000); + } + else + events.ScheduleEvent(EVENT_DEEP_BREATH, 1000); + break; + case EVENT_MOVEMENT: // Phase PHASE_BREATH + if (!IsMoving && !(me->HasUnitState(UNIT_STATE_CASTING))) + { + SetNextRandomPoint(); + PointData = GetMoveData(); + + if (!PointData) + return; + + me->GetMotionMaster()->MovePoint(PointData->LocId, PointData->fX, PointData->fY, PointData->fZ); + IsMoving = true; + events.ScheduleEvent(EVENT_MOVEMENT, 25000); + } + else + events.ScheduleEvent(EVENT_MOVEMENT, 500); + break; + case EVENT_FIREBALL: // Phase PHASE_BREATH + if (!IsMoving) + { + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) + DoCast(target, SPELL_FIREBALL); + events.ScheduleEvent(EVENT_FIREBALL, 8000); + } + else + events.ScheduleEvent(EVENT_FIREBALL, 1000); + break; + case EVENT_LAIR_GUARD: // Phase PHASE_BREATH + me->SummonCreature(NPC_LAIRGUARD, SpawnLocations[2], TEMPSUMMON_CORPSE_DESPAWN); + events.ScheduleEvent(EVENT_LAIR_GUARD, 30000); + break; + case EVENT_WHELP_SPAWN: // Phase PHASE_BREATH + me->SummonCreature(NPC_WHELP, SpawnLocations[0], TEMPSUMMON_CORPSE_DESPAWN); + me->SummonCreature(NPC_WHELP, SpawnLocations[1], TEMPSUMMON_CORPSE_DESPAWN); + if (SummonWhelpCount >= RAID_MODE(20, 40)) + { + SummonWhelpCount = 0; + events.ScheduleEvent(EVENT_WHELP_SPAWN, 90000); + } + else + events.ScheduleEvent(EVENT_WHELP_SPAWN, 500); + break; + default: + break; } if (me->HasUnitState(UNIT_STATE_CASTING)) @@ -481,14 +466,14 @@ class boss_onyxia : public CreatureScript } } - private: - OnyxMove* PointData; - uint8 Phase; - uint8 MovePoint; - uint8 SummonWhelpCount; - ObjectGuid triggerGUID; - ObjectGuid tankGUID; - bool IsMoving; + private: + OnyxMove* PointData; + uint8 Phase; + uint8 MovePoint; + uint8 SummonWhelpCount; + ObjectGuid triggerGUID; + ObjectGuid tankGUID; + bool IsMoving; }; CreatureAI* GetAI(Creature* creature) const override diff --git a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_buru.cpp b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_buru.cpp index 8fc8938b..d91f8753 100644 --- a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_buru.cpp +++ b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_buru.cpp @@ -15,263 +15,271 @@ * with this program. If not, see . */ -#include "ScriptMgr.h" #include "InstanceScript.h" #include "ObjectAccessor.h" -#include "ruins_of_ahnqiraj.h" +#include "ScriptMgr.h" #include "ScriptedCreature.h" #include "SpellScript.h" +#include "ruins_of_ahnqiraj.h" enum Emotes { - EMOTE_TARGET = 0 + EMOTE_TARGET = 0 }; enum Spells { - SPELL_CREEPING_PLAGUE = 20512, - SPELL_DISMEMBER = 96, - SPELL_GATHERING_SPEED = 1834, - SPELL_FULL_SPEED = 1557, - SPELL_THORNS = 25640, - SPELL_BURU_TRANSFORM = 24721, - SPELL_SUMMON_HATCHLING = 1881, - SPELL_EXPLODE = 19593, - SPELL_EXPLODE_2 = 5255, - SPELL_BURU_EGG_TRIGGER = 26646 + SPELL_CREEPING_PLAGUE = 20512, + SPELL_DISMEMBER = 96, + SPELL_GATHERING_SPEED = 1834, + SPELL_FULL_SPEED = 1557, + SPELL_THORNS = 25640, + SPELL_BURU_TRANSFORM = 24721, + SPELL_SUMMON_HATCHLING = 1881, + SPELL_EXPLODE = 19593, + SPELL_EXPLODE_2 = 5255, + SPELL_BURU_EGG_TRIGGER = 26646 }; enum Events { - EVENT_DISMEMBER = 1, - EVENT_GATHERING_SPEED = 2, - EVENT_FULL_SPEED = 3, - EVENT_CREEPING_PLAGUE = 4, - EVENT_RESPAWN_EGG = 5 + EVENT_DISMEMBER = 1, + EVENT_GATHERING_SPEED = 2, + EVENT_FULL_SPEED = 3, + EVENT_CREEPING_PLAGUE = 4, + EVENT_RESPAWN_EGG = 5 }; enum Phases { - PHASE_EGG = 0, - PHASE_TRANSFORM = 1 + PHASE_EGG = 0, + PHASE_TRANSFORM = 1 }; enum Actions { - ACTION_EXPLODE = 0 + ACTION_EXPLODE = 0 }; class boss_buru : public CreatureScript { - public: - boss_buru() : CreatureScript("boss_buru") { } - - struct boss_buruAI : public BossAI + public: + boss_buru() : CreatureScript("boss_buru") + { + } + + struct boss_buruAI : public BossAI + { + boss_buruAI(Creature* creature) : BossAI(creature, DATA_BURU) { - boss_buruAI(Creature* creature) : BossAI(creature, DATA_BURU) - { - _phase = 0; - } - - void EnterEvadeMode(EvadeReason why) override - { - BossAI::EnterEvadeMode(why); + _phase = 0; + } - for (ObjectGuid eggGuid : Eggs) - if (Creature* egg = ObjectAccessor::GetCreature(*me, eggGuid)) - egg->Respawn(); + void EnterEvadeMode(EvadeReason why) override + { + BossAI::EnterEvadeMode(why); - Eggs.clear(); - } + for (ObjectGuid eggGuid : Eggs) + if (Creature* egg = ObjectAccessor::GetCreature(*me, eggGuid)) + egg->Respawn(); - void JustEngagedWith(Unit* who) override - { - BossAI::JustEngagedWith(who); - Talk(EMOTE_TARGET, who); - DoCast(me, SPELL_THORNS); + Eggs.clear(); + } - events.ScheduleEvent(EVENT_DISMEMBER, 5000); - events.ScheduleEvent(EVENT_GATHERING_SPEED, 9000); - events.ScheduleEvent(EVENT_FULL_SPEED, 60000); + void JustEngagedWith(Unit* who) override + { + BossAI::JustEngagedWith(who); + Talk(EMOTE_TARGET, who); + DoCast(me, SPELL_THORNS); - _phase = PHASE_EGG; - } + events.ScheduleEvent(EVENT_DISMEMBER, 5000); + events.ScheduleEvent(EVENT_GATHERING_SPEED, 9000); + events.ScheduleEvent(EVENT_FULL_SPEED, 60000); - void DoAction(int32 action) override - { - if (action == ACTION_EXPLODE) - if (_phase == PHASE_EGG) - me->DealDamage(me, 45000); - } + _phase = PHASE_EGG; + } - void KilledUnit(Unit* victim) override - { - if (victim->GetTypeId() == TYPEID_PLAYER) - ChaseNewVictim(); - } + void DoAction(int32 action) override + { + if (action == ACTION_EXPLODE) + if (_phase == PHASE_EGG) + Unit::DealDamage(me, me, 45000); + } - void ChaseNewVictim() - { - if (_phase != PHASE_EGG) - return; + void KilledUnit(Unit* victim) override + { + if (victim->GetTypeId() == TYPEID_PLAYER) + ChaseNewVictim(); + } - me->RemoveAurasDueToSpell(SPELL_FULL_SPEED); - me->RemoveAurasDueToSpell(SPELL_GATHERING_SPEED); - events.ScheduleEvent(EVENT_GATHERING_SPEED, 9000); - events.ScheduleEvent(EVENT_FULL_SPEED, 60000); + void ChaseNewVictim() + { + if (_phase != PHASE_EGG) + return; - if (Unit* victim = SelectTarget(SELECT_TARGET_RANDOM, 0, 0.0f, true)) - { - ResetThreatList(); - AttackStart(victim); - Talk(EMOTE_TARGET, victim); - } - } + me->RemoveAurasDueToSpell(SPELL_FULL_SPEED); + me->RemoveAurasDueToSpell(SPELL_GATHERING_SPEED); + events.ScheduleEvent(EVENT_GATHERING_SPEED, 9000); + events.ScheduleEvent(EVENT_FULL_SPEED, 60000); - void ManageRespawn(ObjectGuid EggGUID) + if (Unit* victim = SelectTarget(SELECT_TARGET_RANDOM, 0, 0.0f, true)) { - ChaseNewVictim(); - Eggs.push_back(EggGUID); - events.ScheduleEvent(EVENT_RESPAWN_EGG, 100000); + ResetThreatList(); + AttackStart(victim); + Talk(EMOTE_TARGET, victim); } + } - void UpdateAI(uint32 diff) override - { - if (!UpdateVictim()) - return; + void ManageRespawn(ObjectGuid EggGUID) + { + ChaseNewVictim(); + Eggs.push_back(EggGUID); + events.ScheduleEvent(EVENT_RESPAWN_EGG, 100000); + } - events.Update(diff); + void UpdateAI(uint32 diff) override + { + if (!UpdateVictim()) + return; - while (uint32 eventId = events.ExecuteEvent()) + events.Update(diff); + + while (uint32 eventId = events.ExecuteEvent()) + { + switch (eventId) { - switch (eventId) + case EVENT_DISMEMBER: + DoCastVictim(SPELL_DISMEMBER); + events.ScheduleEvent(EVENT_DISMEMBER, 5000); + break; + case EVENT_GATHERING_SPEED: + DoCast(me, SPELL_GATHERING_SPEED); + events.ScheduleEvent(EVENT_GATHERING_SPEED, 9000); + break; + case EVENT_FULL_SPEED: + DoCast(me, SPELL_FULL_SPEED); + break; + case EVENT_CREEPING_PLAGUE: + DoCast(me, SPELL_CREEPING_PLAGUE); + events.ScheduleEvent(EVENT_CREEPING_PLAGUE, 6000); + break; + case EVENT_RESPAWN_EGG: + if (Creature* egg = ObjectAccessor::GetCreature(*me, *Eggs.begin())) { - case EVENT_DISMEMBER: - DoCastVictim(SPELL_DISMEMBER); - events.ScheduleEvent(EVENT_DISMEMBER, 5000); - break; - case EVENT_GATHERING_SPEED: - DoCast(me, SPELL_GATHERING_SPEED); - events.ScheduleEvent(EVENT_GATHERING_SPEED, 9000); - break; - case EVENT_FULL_SPEED: - DoCast(me, SPELL_FULL_SPEED); - break; - case EVENT_CREEPING_PLAGUE: - DoCast(me, SPELL_CREEPING_PLAGUE); - events.ScheduleEvent(EVENT_CREEPING_PLAGUE, 6000); - break; - case EVENT_RESPAWN_EGG: - if (Creature* egg = ObjectAccessor::GetCreature(*me, *Eggs.begin())) - { - egg->Respawn(); - Eggs.pop_front(); - } - break; - default: - break; + egg->Respawn(); + Eggs.pop_front(); } + break; + default: + break; } + } - if (me->GetHealthPct() < 20.0f && _phase == PHASE_EGG) - { - DoCast(me, SPELL_BURU_TRANSFORM); // Enrage - DoCast(me, SPELL_FULL_SPEED, true); - me->RemoveAurasDueToSpell(SPELL_THORNS); - _phase = PHASE_TRANSFORM; - } - - DoMeleeAttackIfReady(); + if (me->GetHealthPct() < 20.0f && _phase == PHASE_EGG) + { + DoCast(me, SPELL_BURU_TRANSFORM); // Enrage + DoCast(me, SPELL_FULL_SPEED, true); + me->RemoveAurasDueToSpell(SPELL_THORNS); + _phase = PHASE_TRANSFORM; } - private: - GuidList Eggs; - uint8 _phase; - }; - CreatureAI* GetAI(Creature* creature) const override - { - return GetAQ20AI(creature); + DoMeleeAttackIfReady(); } + + private: + GuidList Eggs; + uint8 _phase; + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return GetAQ20AI(creature); + } }; class npc_buru_egg : public CreatureScript { - public: - npc_buru_egg() : CreatureScript("npc_buru_egg") { } + public: + npc_buru_egg() : CreatureScript("npc_buru_egg") + { + } + + struct npc_buru_eggAI : public ScriptedAI + { + npc_buru_eggAI(Creature* creature) : ScriptedAI(creature) + { + _instance = me->GetInstanceScript(); + SetCombatMovement(false); + } - struct npc_buru_eggAI : public ScriptedAI + void JustEngagedWith(Unit* attacker) override { - npc_buru_eggAI(Creature* creature) : ScriptedAI(creature) - { - _instance = me->GetInstanceScript(); - SetCombatMovement(false); - } + if (Creature* buru = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_BURU))) + if (!buru->IsInCombat()) + buru->AI()->AttackStart(attacker); + } - void JustEngagedWith(Unit* attacker) override - { + void JustSummoned(Creature* who) override + { + if (who->GetEntry() == NPC_HATCHLING) if (Creature* buru = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_BURU))) - if (!buru->IsInCombat()) - buru->AI()->AttackStart(attacker); - } + if (Unit* target = buru->AI()->SelectTarget(SELECT_TARGET_RANDOM)) + who->AI()->AttackStart(target); + } - void JustSummoned(Creature* who) override - { - if (who->GetEntry() == NPC_HATCHLING) - if (Creature* buru = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_BURU))) - if (Unit* target = buru->AI()->SelectTarget(SELECT_TARGET_RANDOM)) - who->AI()->AttackStart(target); - } + void JustDied(Unit* /*killer*/) override + { + DoCastAOE(SPELL_EXPLODE, true); + DoCastAOE(SPELL_EXPLODE_2, true); // Unknown purpose + DoCast(me, SPELL_SUMMON_HATCHLING, true); - void JustDied(Unit* /*killer*/) override - { - DoCastAOE(SPELL_EXPLODE, true); - DoCastAOE(SPELL_EXPLODE_2, true); // Unknown purpose - DoCast(me, SPELL_SUMMON_HATCHLING, true); + if (Creature* buru = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_BURU))) + if (boss_buru::boss_buruAI* buruAI = dynamic_cast(buru->AI())) + buruAI->ManageRespawn(me->GetGUID()); + } - if (Creature* buru = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_BURU))) - if (boss_buru::boss_buruAI* buruAI = dynamic_cast(buru->AI())) - buruAI->ManageRespawn(me->GetGUID()); - } - private: - InstanceScript* _instance; - }; + private: + InstanceScript* _instance; + }; - CreatureAI* GetAI(Creature* creature) const override - { - return GetAQ20AI(creature); - } + CreatureAI* GetAI(Creature* creature) const override + { + return GetAQ20AI(creature); + } }; class spell_egg_explosion : public SpellScriptLoader { - public: - spell_egg_explosion() : SpellScriptLoader("spell_egg_explosion") { } - - class spell_egg_explosion_SpellScript : public SpellScript + public: + spell_egg_explosion() : SpellScriptLoader("spell_egg_explosion") + { + } + + class spell_egg_explosion_SpellScript : public SpellScript + { + void HandleAfterCast() { - void HandleAfterCast() - { - if (Creature* buru = GetCaster()->FindNearestCreature(NPC_BURU, 5.f)) - buru->AI()->DoAction(ACTION_EXPLODE); - } - - void HandleDummyHitTarget(SpellEffIndex /*effIndex*/) - { - if (Unit* target = GetHitUnit()) - GetCaster()->DealDamage(target, -16 * GetCaster()->GetDistance(target) + 500); - } + if (Creature* buru = GetCaster()->FindNearestCreature(NPC_BURU, 5.f)) + buru->AI()->DoAction(ACTION_EXPLODE); + } - void Register() override - { - AfterCast.Register(&spell_egg_explosion_SpellScript::HandleAfterCast); - OnEffectHitTarget.Register(&spell_egg_explosion_SpellScript::HandleDummyHitTarget, EFFECT_0, SPELL_EFFECT_DUMMY); - } - }; + void HandleDummyHitTarget(SpellEffIndex /*effIndex*/) + { + if (Unit* target = GetHitUnit()) + Unit::DealDamage(GetCaster(), target, -16 * GetCaster()->GetDistance(target) + 500); + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_egg_explosion_SpellScript(); + AfterCast.Register(&spell_egg_explosion_SpellScript::HandleAfterCast); + OnEffectHitTarget.Register(&spell_egg_explosion_SpellScript::HandleDummyHitTarget, EFFECT_0, SPELL_EFFECT_DUMMY); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_egg_explosion_SpellScript(); + } }; void AddSC_boss_buru() diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_viscidus.cpp b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_viscidus.cpp index cb4df7d1..feceb75d 100644 --- a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_viscidus.cpp +++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_viscidus.cpp @@ -15,302 +15,305 @@ * with this program. If not, see . */ -#include "ScriptMgr.h" #include "InstanceScript.h" #include "MotionMaster.h" #include "ObjectAccessor.h" +#include "ScriptMgr.h" #include "ScriptedCreature.h" #include "SpellInfo.h" -#include "temple_of_ahnqiraj.h" #include "TemporarySummon.h" +#include "temple_of_ahnqiraj.h" enum Spells { - SPELL_POISON_SHOCK = 25993, - SPELL_POISONBOLT_VOLLEY = 25991, - SPELL_TOXIN = 26575, - SPELL_VISCIDUS_SLOWED = 26034, - SPELL_VISCIDUS_SLOWED_MORE = 26036, - SPELL_VISCIDUS_FREEZE = 25937, - SPELL_REJOIN_VISCIDUS = 25896, - SPELL_VISCIDUS_EXPLODE = 25938, - SPELL_VISCIDUS_SUICIDE = 26003, - SPELL_VISCIDUS_SHRINKS = 25893, // Removed from client, in world.spell_dbc - - SPELL_MEMBRANE_VISCIDUS = 25994, // damage reduction spell - removed from DBC - SPELL_VISCIDUS_WEAKNESS = 25926, // aura which procs at damage - should trigger the slow spells - removed from DBC - SPELL_VISCIDUS_GROWS = 25897, // removed from DBC - SPELL_SUMMON_GLOBS = 25885, // summons npc 15667 using spells from 25865 to 25884; All spells have target coords - removed from DBC - SPELL_VISCIDUS_TELEPORT = 25904, // removed from DBC + SPELL_POISON_SHOCK = 25993, + SPELL_POISONBOLT_VOLLEY = 25991, + SPELL_TOXIN = 26575, + SPELL_VISCIDUS_SLOWED = 26034, + SPELL_VISCIDUS_SLOWED_MORE = 26036, + SPELL_VISCIDUS_FREEZE = 25937, + SPELL_REJOIN_VISCIDUS = 25896, + SPELL_VISCIDUS_EXPLODE = 25938, + SPELL_VISCIDUS_SUICIDE = 26003, + SPELL_VISCIDUS_SHRINKS = 25893, // Removed from client, in world.spell_dbc + + SPELL_MEMBRANE_VISCIDUS = 25994, // damage reduction spell - removed from DBC + SPELL_VISCIDUS_WEAKNESS = 25926, // aura which procs at damage - should trigger the slow spells - removed from DBC + SPELL_VISCIDUS_GROWS = 25897, // removed from DBC + SPELL_SUMMON_GLOBS = 25885, // summons npc 15667 using spells from 25865 to 25884; All spells have target coords - removed from DBC + SPELL_VISCIDUS_TELEPORT = 25904, // removed from DBC }; enum Events { - EVENT_POISONBOLT_VOLLEY = 1, - EVENT_POISON_SHOCK = 2, - EVENT_RESET_PHASE = 3 + EVENT_POISONBOLT_VOLLEY = 1, + EVENT_POISON_SHOCK = 2, + EVENT_RESET_PHASE = 3 }; enum Phases { - PHASE_FROST = 1, - PHASE_MELEE = 2, - PHASE_GLOB = 3 + PHASE_FROST = 1, + PHASE_MELEE = 2, + PHASE_GLOB = 3 }; enum Emotes { - EMOTE_SLOW = 0, - EMOTE_FREEZE = 1, - EMOTE_FROZEN = 2, + EMOTE_SLOW = 0, + EMOTE_FREEZE = 1, + EMOTE_FROZEN = 2, - EMOTE_CRACK = 3, - EMOTE_SHATTER = 4, - EMOTE_EXPLODE = 5 + EMOTE_CRACK = 3, + EMOTE_SHATTER = 4, + EMOTE_EXPLODE = 5 }; enum HitCounter { - HITCOUNTER_SLOW = 100, - HITCOUNTER_SLOW_MORE = 150, - HITCOUNTER_FREEZE = 200, + HITCOUNTER_SLOW = 100, + HITCOUNTER_SLOW_MORE = 150, + HITCOUNTER_FREEZE = 200, - HITCOUNTER_CRACK = 50, - HITCOUNTER_SHATTER = 100, - HITCOUNTER_EXPLODE = 150, + HITCOUNTER_CRACK = 50, + HITCOUNTER_SHATTER = 100, + HITCOUNTER_EXPLODE = 150, }; enum MovePoints { - ROOM_CENTER = 1 + ROOM_CENTER = 1 }; -Position const ViscidusCoord = { -7992.36f, 908.19f, -52.62f, 1.68f }; /// @todo Visci isn't in room middle -float const RoomRadius = 40.0f; /// @todo Not sure if its correct +Position const ViscidusCoord = {-7992.36f, 908.19f, -52.62f, 1.68f}; /// @todo Visci isn't in room middle +float const RoomRadius = 40.0f; /// @todo Not sure if its correct class boss_viscidus : public CreatureScript { - public: - boss_viscidus() : CreatureScript("boss_viscidus") { } - - struct boss_viscidusAI : public BossAI + public: + boss_viscidus() : CreatureScript("boss_viscidus") + { + } + + struct boss_viscidusAI : public BossAI + { + boss_viscidusAI(Creature* creature) : BossAI(creature, DATA_VISCIDUS) { - boss_viscidusAI(Creature* creature) : BossAI(creature, DATA_VISCIDUS) - { - Initialize(); - } + Initialize(); + } - void Initialize() - { - _hitcounter = 0; - _phase = PHASE_FROST; - } + void Initialize() + { + _hitcounter = 0; + _phase = PHASE_FROST; + } - void Reset() override - { - _Reset(); - Initialize(); - } + void Reset() override + { + _Reset(); + Initialize(); + } - void DamageTaken(Unit* attacker, uint32& /*damage*/) override - { - if (_phase != PHASE_MELEE) - return; + void DamageTaken(Unit* attacker, uint32& /*damage*/) override + { + if (_phase != PHASE_MELEE) + return; - ++_hitcounter; + ++_hitcounter; - if (attacker->HasUnitState(UNIT_STATE_MELEE_ATTACKING) && _hitcounter >= HITCOUNTER_EXPLODE) + if (attacker->HasUnitState(UNIT_STATE_MELEE_ATTACKING) && _hitcounter >= HITCOUNTER_EXPLODE) + { + Talk(EMOTE_EXPLODE); + events.Reset(); + _phase = PHASE_GLOB; + DoCast(me, SPELL_VISCIDUS_EXPLODE); + me->SetVisible(false); + me->RemoveAura(SPELL_TOXIN); + me->RemoveAura(SPELL_VISCIDUS_FREEZE); + + uint8 NumGlobes = me->GetHealthPct() / 5.0f; + for (uint8 i = 0; i < NumGlobes; ++i) { - Talk(EMOTE_EXPLODE); - events.Reset(); - _phase = PHASE_GLOB; - DoCast(me, SPELL_VISCIDUS_EXPLODE); - me->SetVisible(false); - me->RemoveAura(SPELL_TOXIN); - me->RemoveAura(SPELL_VISCIDUS_FREEZE); - - uint8 NumGlobes = me->GetHealthPct() / 5.0f; - for (uint8 i = 0; i < NumGlobes; ++i) + float Angle = i * 2 * float(M_PI) / NumGlobes; + float X = ViscidusCoord.GetPositionX() + std::cos(Angle) * RoomRadius; + float Y = ViscidusCoord.GetPositionY() + std::sin(Angle) * RoomRadius; + float Z = -35.0f; + + if (TempSummon* Glob = me->SummonCreature(NPC_GLOB_OF_VISCIDUS, X, Y, Z)) { - float Angle = i * 2 * float(M_PI) / NumGlobes; - float X = ViscidusCoord.GetPositionX() + std::cos(Angle) * RoomRadius; - float Y = ViscidusCoord.GetPositionY() + std::sin(Angle) * RoomRadius; - float Z = -35.0f; - - if (TempSummon* Glob = me->SummonCreature(NPC_GLOB_OF_VISCIDUS, X, Y, Z)) - { - Glob->UpdateAllowedPositionZ(X, Y, Z); - Glob->NearTeleportTo(X, Y, Z, 0.0f); - Glob->GetMotionMaster()->MovePoint(ROOM_CENTER, ViscidusCoord); - } + Glob->UpdateAllowedPositionZ(X, Y, Z); + Glob->NearTeleportTo(X, Y, Z, 0.0f); + Glob->GetMotionMaster()->MovePoint(ROOM_CENTER, ViscidusCoord); } } - else if (_hitcounter == HITCOUNTER_SHATTER) - Talk(EMOTE_SHATTER); - else if (_hitcounter == HITCOUNTER_CRACK) - Talk(EMOTE_CRACK); } + else if (_hitcounter == HITCOUNTER_SHATTER) + Talk(EMOTE_SHATTER); + else if (_hitcounter == HITCOUNTER_CRACK) + Talk(EMOTE_CRACK); + } - void SpellHit(Unit* /*caster*/, SpellInfo const* spell) override + void SpellHit(Unit* /*caster*/, SpellInfo const* spell) override + { + if ((spell->GetSchoolMask() & SPELL_SCHOOL_MASK_FROST) && _phase == PHASE_FROST && me->GetHealthPct() > 5.0f) { - if ((spell->GetSchoolMask() & SPELL_SCHOOL_MASK_FROST) && _phase == PHASE_FROST && me->GetHealthPct() > 5.0f) - { - ++_hitcounter; + ++_hitcounter; - if (_hitcounter >= HITCOUNTER_FREEZE) - { - _hitcounter = 0; - Talk(EMOTE_FROZEN); - _phase = PHASE_MELEE; - DoCast(me, SPELL_VISCIDUS_FREEZE); - me->RemoveAura(SPELL_VISCIDUS_SLOWED_MORE); - events.ScheduleEvent(EVENT_RESET_PHASE, 15000); - } - else if (_hitcounter >= HITCOUNTER_SLOW_MORE) - { - Talk(EMOTE_FREEZE); - me->RemoveAura(SPELL_VISCIDUS_SLOWED); - DoCast(me, SPELL_VISCIDUS_SLOWED_MORE); - } - else if (_hitcounter >= HITCOUNTER_SLOW) - { - Talk(EMOTE_SLOW); - DoCast(me, SPELL_VISCIDUS_SLOWED); - } + if (_hitcounter >= HITCOUNTER_FREEZE) + { + _hitcounter = 0; + Talk(EMOTE_FROZEN); + _phase = PHASE_MELEE; + DoCast(me, SPELL_VISCIDUS_FREEZE); + me->RemoveAura(SPELL_VISCIDUS_SLOWED_MORE); + events.ScheduleEvent(EVENT_RESET_PHASE, 15000); + } + else if (_hitcounter >= HITCOUNTER_SLOW_MORE) + { + Talk(EMOTE_FREEZE); + me->RemoveAura(SPELL_VISCIDUS_SLOWED); + DoCast(me, SPELL_VISCIDUS_SLOWED_MORE); + } + else if (_hitcounter >= HITCOUNTER_SLOW) + { + Talk(EMOTE_SLOW); + DoCast(me, SPELL_VISCIDUS_SLOWED); } } + } - void JustEngagedWith(Unit* who) override - { - BossAI::JustEngagedWith(who); - events.Reset(); - InitSpells(); - } + void JustEngagedWith(Unit* who) override + { + BossAI::JustEngagedWith(who); + events.Reset(); + InitSpells(); + } - void InitSpells() - { - DoCast(me, SPELL_TOXIN); - events.ScheduleEvent(EVENT_POISONBOLT_VOLLEY, urand(10000, 15000)); - events.ScheduleEvent(EVENT_POISON_SHOCK, urand(7000, 12000)); - } + void InitSpells() + { + DoCast(me, SPELL_TOXIN); + events.ScheduleEvent(EVENT_POISONBOLT_VOLLEY, urand(10000, 15000)); + events.ScheduleEvent(EVENT_POISON_SHOCK, urand(7000, 12000)); + } - void EnterEvadeMode(EvadeReason why) override - { - summons.DespawnAll(); - ScriptedAI::EnterEvadeMode(why); - } + void EnterEvadeMode(EvadeReason why) override + { + summons.DespawnAll(); + ScriptedAI::EnterEvadeMode(why); + } + + void JustDied(Unit* /*killer*/) override + { + DoCast(me, SPELL_VISCIDUS_SUICIDE); + summons.DespawnAll(); + _JustDied(); + } - void JustDied(Unit* /*killer*/) override + void UpdateAI(uint32 diff) override + { + if (!UpdateVictim()) + return; + + if (_phase == PHASE_GLOB && summons.empty()) { - DoCast(me, SPELL_VISCIDUS_SUICIDE); - summons.DespawnAll(); - _JustDied(); + ResetThreatList(); + me->NearTeleportTo(ViscidusCoord.GetPositionX(), ViscidusCoord.GetPositionY(), ViscidusCoord.GetPositionZ(), ViscidusCoord.GetOrientation()); + + _hitcounter = 0; + _phase = PHASE_FROST; + InitSpells(); + me->SetVisible(true); } - void UpdateAI(uint32 diff) override - { - if (!UpdateVictim()) - return; + events.Update(diff); - if (_phase == PHASE_GLOB && summons.empty()) + while (uint32 eventId = events.ExecuteEvent()) + { + switch (eventId) { - ResetThreatList(); - me->NearTeleportTo(ViscidusCoord.GetPositionX(), - ViscidusCoord.GetPositionY(), - ViscidusCoord.GetPositionZ(), - ViscidusCoord.GetOrientation()); - + case EVENT_POISONBOLT_VOLLEY: + DoCast(me, SPELL_POISONBOLT_VOLLEY); + events.ScheduleEvent(EVENT_POISONBOLT_VOLLEY, urand(10000, 15000)); + break; + case EVENT_POISON_SHOCK: + DoCast(me, SPELL_POISON_SHOCK); + events.ScheduleEvent(EVENT_POISON_SHOCK, urand(7000, 12000)); + break; + case EVENT_RESET_PHASE: _hitcounter = 0; _phase = PHASE_FROST; - InitSpells(); - me->SetVisible(true); - } - - events.Update(diff); - - while (uint32 eventId = events.ExecuteEvent()) - { - switch (eventId) - { - case EVENT_POISONBOLT_VOLLEY: - DoCast(me, SPELL_POISONBOLT_VOLLEY); - events.ScheduleEvent(EVENT_POISONBOLT_VOLLEY, urand(10000, 15000)); - break; - case EVENT_POISON_SHOCK: - DoCast(me, SPELL_POISON_SHOCK); - events.ScheduleEvent(EVENT_POISON_SHOCK, urand(7000, 12000)); - break; - case EVENT_RESET_PHASE: - _hitcounter = 0; - _phase = PHASE_FROST; - break; - default: - break; - } + break; + default: + break; } - - if (_phase != PHASE_GLOB) - DoMeleeAttackIfReady(); } - private: - uint8 _hitcounter; - Phases _phase; - }; - - CreatureAI* GetAI(Creature* creature) const override - { - return GetAQ40AI(creature); + if (_phase != PHASE_GLOB) + DoMeleeAttackIfReady(); } + + private: + uint8 _hitcounter; + Phases _phase; + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return GetAQ40AI(creature); + } }; class npc_glob_of_viscidus : public CreatureScript { - public: - npc_glob_of_viscidus() : CreatureScript("boss_glob_of_viscidus") { } + public: + npc_glob_of_viscidus() : CreatureScript("boss_glob_of_viscidus") + { + } + + struct npc_glob_of_viscidusAI : public ScriptedAI + { + npc_glob_of_viscidusAI(Creature* creature) : ScriptedAI(creature) + { + } - struct npc_glob_of_viscidusAI : public ScriptedAI + void JustDied(Unit* /*killer*/) override { - npc_glob_of_viscidusAI(Creature* creature) : ScriptedAI(creature) { } + InstanceScript* Instance = me->GetInstanceScript(); - void JustDied(Unit* /*killer*/) override + if (Creature* Viscidus = ObjectAccessor::GetCreature(*me, Instance->GetGuidData(DATA_VISCIDUS))) { - InstanceScript* Instance = me->GetInstanceScript(); + if (BossAI* ViscidusAI = dynamic_cast(Viscidus->GetAI())) + ViscidusAI->SummonedCreatureDespawn(me); - if (Creature* Viscidus = ObjectAccessor::GetCreature(*me, Instance->GetGuidData(DATA_VISCIDUS))) + if (Viscidus->IsAlive() && Viscidus->GetHealthPct() < 5.0f) { - if (BossAI* ViscidusAI = dynamic_cast(Viscidus->GetAI())) - ViscidusAI->SummonedCreatureDespawn(me); - - if (Viscidus->IsAlive() && Viscidus->GetHealthPct() < 5.0f) - { - Viscidus->SetVisible(true); - if (Viscidus->GetVictim()) - Viscidus->EnsureVictim()->Kill(Viscidus); - } - else - { - Viscidus->SetHealth(Viscidus->GetHealth() - Viscidus->GetMaxHealth() / 20); - Viscidus->CastSpell(Viscidus, SPELL_VISCIDUS_SHRINKS); - } + Viscidus->SetVisible(true); + if (Viscidus->GetVictim()) + Unit::Kill(Viscidus->EnsureVictim(), Viscidus); } - } - - void MovementInform(uint32 /*type*/, uint32 id) override - { - if (id == ROOM_CENTER) + else { - DoCast(me, SPELL_REJOIN_VISCIDUS); - if (TempSummon* summon = me->ToTempSummon()) - summon->UnSummon(); + Viscidus->SetHealth(Viscidus->GetHealth() - Viscidus->GetMaxHealth() / 20); + Viscidus->CastSpell(Viscidus, SPELL_VISCIDUS_SHRINKS); } } - }; + } - CreatureAI* GetAI(Creature* creature) const override + void MovementInform(uint32 /*type*/, uint32 id) override { - return GetAQ40AI(creature); + if (id == ROOM_CENTER) + { + DoCast(me, SPELL_REJOIN_VISCIDUS); + if (TempSummon* summon = me->ToTempSummon()) + summon->UnSummon(); + } } + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return GetAQ40AI(creature); + } }; void AddSC_boss_viscidus() diff --git a/src/server/scripts/Maelstrom/Kezan/kezan.cpp b/src/server/scripts/Maelstrom/Kezan/kezan.cpp index 7e7ea31a..b1ad203e 100644 --- a/src/server/scripts/Maelstrom/Kezan/kezan.cpp +++ b/src/server/scripts/Maelstrom/Kezan/kezan.cpp @@ -36,8 +36,8 @@ # Quest Rolling With My Homies ### */ -std::unordered_map> const seatPerHomie = {{SUMMON_NPC_ACE, {1, SPELL_RESUMMON_ACE}}, - {SUMMON_NPC_GOBBER, {2, SPELL_RESUMMON_GOBBER}}, {SUMMON_NPC_IZZY, {3, SPELL_RESUMMON_IZZY}}}; +std::unordered_map> const seatPerHomie = { + {SUMMON_NPC_ACE, {1, SPELL_RESUMMON_ACE}}, {SUMMON_NPC_GOBBER, {2, SPELL_RESUMMON_GOBBER}}, {SUMMON_NPC_IZZY, {3, SPELL_RESUMMON_IZZY}}}; std::unordered_map> const goalAndSpellPerHomie = { {NPC_ACE, {OBJECTIVE_ACE_PICKED_UP, SPELL_SUMMON_ACE, SPELL_INV_DETECTION_1}}, @@ -45,13 +45,14 @@ std::unordered_map> const goalAndSpel {NPC_IZZY, {OBJECTIVE_IZZY_PICKED_UP, SPELL_SUMMON_IZZY, SPELL_INV_DETECTION_3}}, }; -std::unordered_map objectivesCompleted = { - {OBJECTIVE_IZZY_PICKED_UP, false}, {OBJECTIVE_ACE_PICKED_UP, false}, {OBJECTIVE_GOBBER_PICKED_UP, false}}; +std::unordered_map objectivesCompleted = {{OBJECTIVE_IZZY_PICKED_UP, false}, {OBJECTIVE_ACE_PICKED_UP, false}, {OBJECTIVE_GOBBER_PICKED_UP, false}}; class quest_rolling_with_my_homies : public QuestScript { public: - quest_rolling_with_my_homies() : QuestScript("quest_rolling_with_my_homies") {} + quest_rolling_with_my_homies() : QuestScript("quest_rolling_with_my_homies") + { + } void OnQuestStatusChange(Player* player, Quest const* /*quest*/, QuestStatus /*oldStatus*/, QuestStatus newStatus) override { @@ -64,9 +65,13 @@ class quest_rolling_with_my_homies : public QuestScript struct npc_hot_rod : public ScriptedAI { - npc_hot_rod(Creature* creature) : ScriptedAI(creature) {} + npc_hot_rod(Creature* creature) : ScriptedAI(creature) + { + } - void OnCharmed(bool /*apply*/) override {} + void OnCharmed(bool /*apply*/) override + { + } void PassengerBoarded(Unit* who, int8 /*seatId*/, bool apply) override { @@ -117,7 +122,10 @@ class spell_klaxon : public SpellScript GetCaster()->PlayDirectSound(KLAXON_SOUND, player); } - void Register() override { OnHit.Register(&spell_klaxon::HandleOnHit); } + void Register() override + { + OnHit.Register(&spell_klaxon::HandleOnHit); + } }; class spell_radio : public SpellScript @@ -131,12 +139,17 @@ class spell_radio : public SpellScript GetCaster()->PlayDistanceSound(RADIO_SOUND, caster->ToPlayer()); } - void Register() override { OnHit.Register(&spell_radio::HandleOnHit); } + void Register() override + { + OnHit.Register(&spell_radio::HandleOnHit); + } }; struct npc_homies : public ScriptedAI { - npc_homies(Creature* creature) : ScriptedAI(creature) {} + npc_homies(Creature* creature) : ScriptedAI(creature) + { + } void MoveInLineOfSight(Unit* who) override { @@ -174,7 +187,9 @@ struct npc_homies : public ScriptedAI struct npc_homies_summon : public ScriptedAI { - npc_homies_summon(Creature* creature) : ScriptedAI(creature) {} + npc_homies_summon(Creature* creature) : ScriptedAI(creature) + { + } void Reset() override { @@ -233,7 +248,9 @@ void InitQuestRollingWithMyHomies() class quest_fourth_and_goal : public QuestScript { public: - quest_fourth_and_goal() : QuestScript("quest_fourth_and_goal") {} + quest_fourth_and_goal() : QuestScript("quest_fourth_and_goal") + { + } void OnQuestStatusChange(Player* player, Quest const* /*quest*/, QuestStatus /*oldStatus*/, QuestStatus newStatus) override { @@ -249,11 +266,15 @@ class quest_fourth_and_goal : public QuestScript class npc_coach_crosscheck : public CreatureScript { public: - npc_coach_crosscheck() : CreatureScript("npc_coach_crosscheck") {} + npc_coach_crosscheck() : CreatureScript("npc_coach_crosscheck") + { + } struct npc_coach_crosscheckAI : public ScriptedAI { - npc_coach_crosscheckAI(Creature* creature) : ScriptedAI(creature) {} + npc_coach_crosscheckAI(Creature* creature) : ScriptedAI(creature) + { + } }; bool OnQuestAccept(Player* player, Creature* /*creature*/, Quest const* quest) override @@ -262,8 +283,7 @@ class npc_coach_crosscheck : public CreatureScript if (quest->GetQuestId() == QUEST_NECESSARY_ROUGHNESS) { - player->GetScheduler().Schedule( - 500ms, [player](TaskContext /*ctx*/) { player->CastSpell(player, SPELL_SUMMON_BILGWATER_BUCCANEER, true); }); + player->GetScheduler().Schedule(500ms, [player](TaskContext /*ctx*/) { player->CastSpell(player, SPELL_SUMMON_BILGWATER_BUCCANEER, true); }); } else if (quest->GetQuestId() == QUEST_FOURTH_AND_GOAL) { @@ -274,14 +294,16 @@ class npc_coach_crosscheck : public CreatureScript { player->ExitVehicle(); } - player->GetScheduler().Schedule( - 500ms, [player](TaskContext /*ctx*/) { player->CastSpell(player, SPELL_SUMMON_BILGWATER_BUCCANEER_2, true); }); + player->GetScheduler().Schedule(500ms, [player](TaskContext /*ctx*/) { player->CastSpell(player, SPELL_SUMMON_BILGWATER_BUCCANEER_2, true); }); } return false; } - CreatureAI* GetAI(Creature* creature) const override { return new npc_coach_crosscheckAI(creature); } + CreatureAI* GetAI(Creature* creature) const override + { + return new npc_coach_crosscheckAI(creature); + } }; const Position SharkPos[8] = { @@ -300,7 +322,9 @@ const Position SharkPos[8] = { class npc_bilgewater_bucaneer : public CreatureScript { public: - npc_bilgewater_bucaneer() : CreatureScript("npc_bilgewater_bucaneer") {} + npc_bilgewater_bucaneer() : CreatureScript("npc_bilgewater_bucaneer") + { + } bool OnGossipHello(Player* pPlayer, Creature* pCreature) override { @@ -313,7 +337,9 @@ class npc_bilgewater_bucaneer : public CreatureScript struct npc_bucanneer_gob : public VehicleAI { - npc_bucanneer_gob(Creature* creature) : VehicleAI(creature) {} + npc_bucanneer_gob(Creature* creature) : VehicleAI(creature) + { + } EventMap m_events; ObjectGuid m_playerGUID; @@ -438,13 +464,18 @@ class npc_bilgewater_bucaneer : public CreatureScript } }; - CreatureAI* GetAI(Creature* creature) const override { return new npc_bucanneer_gob(creature); } + CreatureAI* GetAI(Creature* creature) const override + { + return new npc_bucanneer_gob(creature); + } }; // NPC entry 37114 struct npc_shark_gob : public ScriptedAI { - npc_shark_gob(Creature* creature) : ScriptedAI(creature) {} + npc_shark_gob(Creature* creature) : ScriptedAI(creature) + { + } void Reset() override { @@ -452,8 +483,7 @@ struct npc_shark_gob : public ScriptedAI me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); me->SetWalk(true); - me->GetScheduler().Schedule(3s, [this](TaskContext /*context*/) - { me->GetMotionMaster()->MovePoint(1, -8260.0f, me->GetPositionY(), me->GetPositionZ()); }); + me->GetScheduler().Schedule(3s, [this](TaskContext /*context*/) { me->GetMotionMaster()->MovePoint(1, -8260.0f, me->GetPositionY(), me->GetPositionZ()); }); } void SpellHit(Unit* caster, const SpellInfo* spell) override @@ -464,12 +494,13 @@ struct npc_shark_gob : public ScriptedAI if (Unit* passenger = caster->GetVehicleKit()->GetPassenger(0)) if (Player* player = passenger->ToPlayer()) player->KilledMonsterCredit(me->GetEntry(), me->GetGUID()); - - caster->Kill(me); + Unit::Kill(caster, me); } } - void JustReachedHome() override {} + void JustReachedHome() override + { + } }; // Spell Id 70052 @@ -487,13 +518,18 @@ class npc_fourth_and_goal_kick_footbomb : public SpellScript } } - void Register() override { BeforeCast.Register(&npc_fourth_and_goal_kick_footbomb::HandleBeforeCast); } + void Register() override + { + BeforeCast.Register(&npc_fourth_and_goal_kick_footbomb::HandleBeforeCast); + } }; // NPC entry 37203 struct npc_fourth_and_goal_target : public ScriptedAI { - npc_fourth_and_goal_target(Creature* creature) : ScriptedAI(creature) {} + npc_fourth_and_goal_target(Creature* creature) : ScriptedAI(creature) + { + } void Reset() override { @@ -506,11 +542,15 @@ struct npc_fourth_and_goal_target : public ScriptedAI class npc_fourth_and_goal_deathwing : public CreatureScript { public: - npc_fourth_and_goal_deathwing() : CreatureScript("npc_fourth_and_goal_deathwing") {} + npc_fourth_and_goal_deathwing() : CreatureScript("npc_fourth_and_goal_deathwing") + { + } struct npc_fourth_and_goal_deathwingAI : public ScriptedAI { - npc_fourth_and_goal_deathwingAI(Creature* creature) : ScriptedAI(creature) {} + npc_fourth_and_goal_deathwingAI(Creature* creature) : ScriptedAI(creature) + { + } EventMap m_events; ObjectGuid m_playerGUID; @@ -672,8 +712,7 @@ class npc_fourth_and_goal_deathwing : public CreatureScript { if (Player* player = ObjectAccessor::GetPlayer(*me, m_playerGUID)) { - player->CastSpell( - player, SPELL_GROUND_RUMBLE_EARTHQUAKE, true); // This Earthquake is taken drom Duskhaven.. + player->CastSpell(player, SPELL_GROUND_RUMBLE_EARTHQUAKE, true); // This Earthquake is taken drom Duskhaven.. } break; } @@ -682,7 +721,10 @@ class npc_fourth_and_goal_deathwing : public CreatureScript } }; - CreatureAI* GetAI(Creature* creature) const override { return new npc_fourth_and_goal_deathwingAI(creature); } + CreatureAI* GetAI(Creature* creature) const override + { + return new npc_fourth_and_goal_deathwingAI(creature); + } }; // Spell Id 69987 diff --git a/src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/obsidian_sanctum.cpp b/src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/obsidian_sanctum.cpp index 112ecc4a..614326d1 100644 --- a/src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/obsidian_sanctum.cpp +++ b/src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/obsidian_sanctum.cpp @@ -15,148 +15,127 @@ * with this program. If not, see . */ -#include "ScriptMgr.h" +#include "obsidian_sanctum.h" #include "GameObject.h" #include "InstanceScript.h" #include "Map.h" #include "MotionMaster.h" #include "ObjectAccessor.h" -#include "obsidian_sanctum.h" #include "Player.h" +#include "ScriptMgr.h" #include "ScriptedCreature.h" #include "TemporarySummon.h" enum Enums { - //Mini bosses common spells - SPELL_TWILIGHT_RESIDUE = 61885, // makes immune to shadow damage, applied when leave phase - - //Miniboses (Vesperon, Shadron, Tenebron) - SPELL_SHADOW_BREATH = 57570, // Inflicts 6938 to 8062 Fire damage to enemies in a cone in front of the caster. - SPELL_SHADOW_FISSURE = 57579, // Deals 6188 to 8812 Shadow damage to any enemy within the Shadow fissure after 5 sec. - - //Vesperon - //In portal is a disciple, when disciple killed remove Power_of_vesperon, portal open multiple times - NPC_ACOLYTE_OF_VESPERON = 31219, // Acolyte of Vesperon - SPELL_POWER_OF_VESPERON = 61251, // Vesperon's presence decreases the maximum health of all enemies by 25%. - SPELL_TWILIGHT_TORMENT_VESP = 57948, // (Shadow only) trigger 57935 then 57988 - SPELL_TWILIGHT_TORMENT_VESP_ACO = 58853, // (Fire and Shadow) trigger 58835 then 57988 - - //Shadron - //In portal is a disciple, when disciple killed remove Power_of_vesperon, portal open multiple times - NPC_ACOLYTE_OF_SHADRON = 31218, // Acolyte of Shadron - SPELL_POWER_OF_SHADRON = 58105, // Shadron's presence increases Fire damage taken by all enemies by 100%. - SPELL_GIFT_OF_TWILIGTH_SHA = 57835, // TARGET_SCRIPT shadron - SPELL_GIFT_OF_TWILIGTH_SAR = 58766, // TARGET_SCRIPT sartharion - SPELL_VOID_BLAST = 57581, // Twilight Fissure - - //Tenebron - //in the portal spawns 6 eggs, if not killed in time (approx. 20s) they will hatch, whelps can cast 60708 - SPELL_POWER_OF_TENEBRON = 61248, // Tenebron's presence increases Shadow damage taken by all enemies by 100%. - //Tenebron, dummy spell - SPELL_SUMMON_TWILIGHT_WHELP = 58035, // doesn't work, will spawn NPC_TWILIGHT_WHELP - SPELL_SUMMON_SARTHARION_TWILIGHT_WHELP = 58826, // doesn't work, will spawn NPC_SHARTHARION_TWILIGHT_WHELP - SPELL_TWILIGHT_REVENGE = 60639, - SPELL_HATCH_EGGS_H = 59189, - SPELL_HATCH_EGGS = 58542, - SPELL_HATCH_EGGS_EFFECT_H = 59190, - SPELL_HATCH_EGGS_EFFECT = 58685, - NPC_TWILIHT_WHELP = 31214, - NPC_TWILIGHT_EGG = 30882, - NPC_SARTHARION_TWILIGHT_EGG = 31204, - - SPELL_TWILIGHT_SHIFT_ENTER = 57620, // enter phase. Player get this when click GO - SPELL_TWILIGHT_SHIFT = 57874, // Twilight Shift Aura - SPELL_TWILIGHT_SHIFT_REMOVAL = 61187, // leave phase - SPELL_TWILIGHT_SHIFT_REMOVAL_ALL = 61190, // leave phase (probably version to make all leave) - - //Whelps - NPC_TWILIGHT_WHELP = 30890, - NPC_SARTHARION_TWILIGHT_WHELP = 31214, - SPELL_FADE_ARMOR = 60708, // Reduces the armor of an enemy by 1500 for 15s - - //flame tsunami - SPELL_FLAME_TSUNAMI = 57494, // the visual dummy - SPELL_FLAME_TSUNAMI_LEAP = 60241, // SPELL_EFFECT_138 some leap effect, causing caster to move in direction - - SPELL_FLAME_TSUNAMI_DMG_AURA = 57491, // periodic damage, npc has this aura - SPELL_FLAME_TSUNAMI_BUFF = 60430, - NPC_LAVA_BLAZE = 30643, // adds spawning from flame strike - - //using these custom points for dragons start and end - POINT_ID_INIT = 100, - POINT_ID_LAND = 200 + // Mini bosses common spells + SPELL_TWILIGHT_RESIDUE = 61885, // makes immune to shadow damage, applied when leave phase + + // Miniboses (Vesperon, Shadron, Tenebron) + SPELL_SHADOW_BREATH = 57570, // Inflicts 6938 to 8062 Fire damage to enemies in a cone in front of the caster. + SPELL_SHADOW_FISSURE = 57579, // Deals 6188 to 8812 Shadow damage to any enemy within the Shadow fissure after 5 sec. + + // Vesperon + // In portal is a disciple, when disciple killed remove Power_of_vesperon, portal open multiple times + NPC_ACOLYTE_OF_VESPERON = 31219, // Acolyte of Vesperon + SPELL_POWER_OF_VESPERON = 61251, // Vesperon's presence decreases the maximum health of all enemies by 25%. + SPELL_TWILIGHT_TORMENT_VESP = 57948, // (Shadow only) trigger 57935 then 57988 + SPELL_TWILIGHT_TORMENT_VESP_ACO = 58853, // (Fire and Shadow) trigger 58835 then 57988 + + // Shadron + // In portal is a disciple, when disciple killed remove Power_of_vesperon, portal open multiple times + NPC_ACOLYTE_OF_SHADRON = 31218, // Acolyte of Shadron + SPELL_POWER_OF_SHADRON = 58105, // Shadron's presence increases Fire damage taken by all enemies by 100%. + SPELL_GIFT_OF_TWILIGTH_SHA = 57835, // TARGET_SCRIPT shadron + SPELL_GIFT_OF_TWILIGTH_SAR = 58766, // TARGET_SCRIPT sartharion + SPELL_VOID_BLAST = 57581, // Twilight Fissure + + // Tenebron + // in the portal spawns 6 eggs, if not killed in time (approx. 20s) they will hatch, whelps can cast 60708 + SPELL_POWER_OF_TENEBRON = 61248, // Tenebron's presence increases Shadow damage taken by all enemies by 100%. + // Tenebron, dummy spell + SPELL_SUMMON_TWILIGHT_WHELP = 58035, // doesn't work, will spawn NPC_TWILIGHT_WHELP + SPELL_SUMMON_SARTHARION_TWILIGHT_WHELP = 58826, // doesn't work, will spawn NPC_SHARTHARION_TWILIGHT_WHELP + SPELL_TWILIGHT_REVENGE = 60639, + SPELL_HATCH_EGGS_H = 59189, + SPELL_HATCH_EGGS = 58542, + SPELL_HATCH_EGGS_EFFECT_H = 59190, + SPELL_HATCH_EGGS_EFFECT = 58685, + NPC_TWILIHT_WHELP = 31214, + NPC_TWILIGHT_EGG = 30882, + NPC_SARTHARION_TWILIGHT_EGG = 31204, + + SPELL_TWILIGHT_SHIFT_ENTER = 57620, // enter phase. Player get this when click GO + SPELL_TWILIGHT_SHIFT = 57874, // Twilight Shift Aura + SPELL_TWILIGHT_SHIFT_REMOVAL = 61187, // leave phase + SPELL_TWILIGHT_SHIFT_REMOVAL_ALL = 61190, // leave phase (probably version to make all leave) + + // Whelps + NPC_TWILIGHT_WHELP = 30890, + NPC_SARTHARION_TWILIGHT_WHELP = 31214, + SPELL_FADE_ARMOR = 60708, // Reduces the armor of an enemy by 1500 for 15s + + // flame tsunami + SPELL_FLAME_TSUNAMI = 57494, // the visual dummy + SPELL_FLAME_TSUNAMI_LEAP = 60241, // SPELL_EFFECT_138 some leap effect, causing caster to move in direction + + SPELL_FLAME_TSUNAMI_DMG_AURA = 57491, // periodic damage, npc has this aura + SPELL_FLAME_TSUNAMI_BUFF = 60430, + NPC_LAVA_BLAZE = 30643, // adds spawning from flame strike + + // using these custom points for dragons start and end + POINT_ID_INIT = 100, + POINT_ID_LAND = 200 }; enum Misc { - DATA_CAN_LOOT = 0 + DATA_CAN_LOOT = 0 }; #define MAX_WAYPOINT 6 -//points around raid "isle", counter clockwise. should probably be adjusted to be more alike -Position const dragonCommon[MAX_WAYPOINT]= -{ - { 3214.012f, 468.932f, 98.652f, 0.0f }, - { 3244.950f, 468.427f, 98.652f, 0.0f }, - { 3283.520f, 496.869f, 98.652f, 0.0f }, - { 3287.316f, 555.875f, 98.652f, 0.0f }, - { 3250.479f, 585.827f, 98.652f, 0.0f }, - { 3209.969f, 566.523f, 98.652f, 0.0f } -}; +// points around raid "isle", counter clockwise. should probably be adjusted to be more alike +Position const dragonCommon[MAX_WAYPOINT] = {{3214.012f, 468.932f, 98.652f, 0.0f}, {3244.950f, 468.427f, 98.652f, 0.0f}, {3283.520f, 496.869f, 98.652f, 0.0f}, {3287.316f, 555.875f, 98.652f, 0.0f}, + {3250.479f, 585.827f, 98.652f, 0.0f}, {3209.969f, 566.523f, 98.652f, 0.0f}}; -Position const AcolyteofShadron = { 3363.92f, 534.703f, 97.2683f, 0.0f }; -Position const AcolyteofShadron2 = { 3246.57f, 551.263f, 58.6164f, 0.0f }; -Position const AcolyteofVesperon = { 3145.68f, 520.71f, 89.7f, 0.0f }; -Position const AcolyteofVesperon2 = { 3246.57f, 551.263f, 58.6164f, 0.0f }; +Position const AcolyteofShadron = {3363.92f, 534.703f, 97.2683f, 0.0f}; +Position const AcolyteofShadron2 = {3246.57f, 551.263f, 58.6164f, 0.0f}; +Position const AcolyteofVesperon = {3145.68f, 520.71f, 89.7f, 0.0f}; +Position const AcolyteofVesperon2 = {3246.57f, 551.263f, 58.6164f, 0.0f}; -Position const TwilightEggs[] = -{ - { 3219.28f, 669.121f, 88.5549f, 0.0f }, - { 3221.55f, 682.852f, 90.5361f, 0.0f }, - { 3239.77f, 685.94f, 90.3168f, 0.0f }, - { 3250.33f, 669.749f, 88.7637f, 0.0f }, - { 3246.6f, 642.365f, 84.8752f, 0.0f }, - { 3233.68f, 653.117f, 85.7051f, 0.0f } -}; +Position const TwilightEggs[] = {{3219.28f, 669.121f, 88.5549f, 0.0f}, {3221.55f, 682.852f, 90.5361f, 0.0f}, {3239.77f, 685.94f, 90.3168f, 0.0f}, {3250.33f, 669.749f, 88.7637f, 0.0f}, + {3246.6f, 642.365f, 84.8752f, 0.0f}, {3233.68f, 653.117f, 85.7051f, 0.0f}}; -Position const TwilightEggsSarth[] = -{ - { 3252.73f, 515.762f, 58.5501f, 0.0f }, - { 3256.56f, 521.119f, 58.6061f, 0.0f }, - { 3255.63f, 527.513f, 58.7568f, 0.0f }, - { 3264.90f, 525.865f, 58.6436f, 0.0f }, - { 3264.26f, 516.364f, 58.8011f, 0.0f }, - { 3257.54f, 502.285f, 58.2077f, 0.0f } -}; +Position const TwilightEggsSarth[] = {{3252.73f, 515.762f, 58.5501f, 0.0f}, {3256.56f, 521.119f, 58.6061f, 0.0f}, {3255.63f, 527.513f, 58.7568f, 0.0f}, {3264.90f, 525.865f, 58.6436f, 0.0f}, + {3264.26f, 516.364f, 58.8011f, 0.0f}, {3257.54f, 502.285f, 58.2077f, 0.0f}}; enum SharedTextIds { - SAY_AGGRO = 0, - SAY_SLAY = 1, - SAY_DEATH = 2, - SAY_BREATH = 3, - SAY_RESPOND = 4, - SAY_SPECIAL = 5, - WHISPER_OPEN_PORTAL = 6, - WHISPER_OPENED_PORTAL = 7 + SAY_AGGRO = 0, + SAY_SLAY = 1, + SAY_DEATH = 2, + SAY_BREATH = 3, + SAY_RESPOND = 4, + SAY_SPECIAL = 5, + WHISPER_OPEN_PORTAL = 6, + WHISPER_OPENED_PORTAL = 7 }; enum DragonEvents { // Shared Events - EVENT_FREE_MOVEMENT = 1, - EVENT_SHADOW_FISSURE = 2, - EVENT_SHADOW_BREATH = 3, + EVENT_FREE_MOVEMENT = 1, + EVENT_SHADOW_FISSURE = 2, + EVENT_SHADOW_BREATH = 3, // Tenebron - EVENT_HATCH_EGGS = 4, + EVENT_HATCH_EGGS = 4, // Shadron - EVENT_ACOLYTE_SHADRON = 5, + EVENT_ACOLYTE_SHADRON = 5, // Vesperon - EVENT_ACOLYTE_VESPERON = 6 + EVENT_ACOLYTE_VESPERON = 6 }; // to control each dragons common abilities @@ -256,52 +235,52 @@ struct dummy_dragonAI : public ScriptedAI switch (me->GetEntry()) { - case NPC_TENEBRON: + case NPC_TENEBRON: + { + if (instance->GetBossState(DATA_SARTHARION) != IN_PROGRESS) { - if (instance->GetBossState(DATA_SARTHARION) != IN_PROGRESS) - { - for (uint32 i = 0; i < 6; ++i) - me->SummonCreature(NPC_TWILIGHT_EGG, TwilightEggs[i], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 20000); - } - else - { - for (uint32 i = 0; i < 6; ++i) - me->SummonCreature(NPC_SARTHARION_TWILIGHT_EGG, TwilightEggsSarth[i], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 20000); - } - break; + for (uint32 i = 0; i < 6; ++i) + me->SummonCreature(NPC_TWILIGHT_EGG, TwilightEggs[i], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 20000); } - case NPC_SHADRON: + else { - if (instance->GetBossState(DATA_SARTHARION) != IN_PROGRESS) - me->SummonCreature(NPC_ACOLYTE_OF_SHADRON, AcolyteofShadron, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 28000); - else - me->SummonCreature(NPC_ACOLYTE_OF_SHADRON, AcolyteofShadron2, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 28000); - - break; + for (uint32 i = 0; i < 6; ++i) + me->SummonCreature(NPC_SARTHARION_TWILIGHT_EGG, TwilightEggsSarth[i], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 20000); } - case NPC_VESPERON: + break; + } + case NPC_SHADRON: + { + if (instance->GetBossState(DATA_SARTHARION) != IN_PROGRESS) + me->SummonCreature(NPC_ACOLYTE_OF_SHADRON, AcolyteofShadron, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 28000); + else + me->SummonCreature(NPC_ACOLYTE_OF_SHADRON, AcolyteofShadron2, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 28000); + + break; + } + case NPC_VESPERON: + { + if (instance->GetBossState(DATA_SARTHARION) != IN_PROGRESS) { - if (instance->GetBossState(DATA_SARTHARION) != IN_PROGRESS) + if (Creature* acolyte = me->SummonCreature(NPC_ACOLYTE_OF_VESPERON, AcolyteofVesperon, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 20000)) { - if (Creature* acolyte = me->SummonCreature(NPC_ACOLYTE_OF_VESPERON, AcolyteofVesperon, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 20000)) - { - me->InterruptNonMeleeSpells(true); - acolyte->InterruptNonMeleeSpells(true); - me->CastSpell(me, 32747, false); - } + me->InterruptNonMeleeSpells(true); + acolyte->InterruptNonMeleeSpells(true); + me->CastSpell(me, 32747, false); } - else + } + else + { + if (Creature* acolyte = me->SummonCreature(NPC_ACOLYTE_OF_VESPERON, AcolyteofVesperon2, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 20000)) { - if (Creature* acolyte = me->SummonCreature(NPC_ACOLYTE_OF_VESPERON, AcolyteofVesperon2, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 20000)) - { - me->InterruptNonMeleeSpells(true); - acolyte->InterruptNonMeleeSpells(true); - me->CastSpell(me, 32747, false); - } + me->InterruptNonMeleeSpells(true); + acolyte->InterruptNonMeleeSpells(true); + me->CastSpell(me, 32747, false); } - - break; } + + break; + } } Talk(WHISPER_OPEN_PORTAL); @@ -331,25 +310,25 @@ struct dummy_dragonAI : public ScriptedAI switch (me->GetEntry()) { - case NPC_TENEBRON: - spellId = SPELL_POWER_OF_TENEBRON; - if (instance->GetBossState(DATA_SARTHARION) != IN_PROGRESS) - instance->SetBossState(DATA_TENEBRON, DONE); - break; - case NPC_SHADRON: - spellId = SPELL_POWER_OF_SHADRON; - if (instance->GetBossState(DATA_SARTHARION) != IN_PROGRESS) - instance->SetBossState(DATA_SHADRON, DONE); - if (Creature* acolyte = me->FindNearestCreature(NPC_ACOLYTE_OF_SHADRON, 100.0f)) - acolyte->KillSelf(); - break; - case NPC_VESPERON: - spellId = SPELL_POWER_OF_VESPERON; - if (instance->GetBossState(DATA_SARTHARION) != IN_PROGRESS) - instance->SetBossState(DATA_VESPERON, DONE); - if (Creature* acolyte = me->FindNearestCreature(NPC_ACOLYTE_OF_VESPERON, 100.0f)) - acolyte->KillSelf(); - break; + case NPC_TENEBRON: + spellId = SPELL_POWER_OF_TENEBRON; + if (instance->GetBossState(DATA_SARTHARION) != IN_PROGRESS) + instance->SetBossState(DATA_TENEBRON, DONE); + break; + case NPC_SHADRON: + spellId = SPELL_POWER_OF_SHADRON; + if (instance->GetBossState(DATA_SARTHARION) != IN_PROGRESS) + instance->SetBossState(DATA_SHADRON, DONE); + if (Creature* acolyte = me->FindNearestCreature(NPC_ACOLYTE_OF_SHADRON, 100.0f)) + acolyte->KillSelf(); + break; + case NPC_VESPERON: + spellId = SPELL_POWER_OF_VESPERON; + if (instance->GetBossState(DATA_SARTHARION) != IN_PROGRESS) + instance->SetBossState(DATA_VESPERON, DONE); + if (Creature* acolyte = me->FindNearestCreature(NPC_ACOLYTE_OF_VESPERON, 100.0f)) + acolyte->KillSelf(); + break; } Talk(SAY_DEATH); @@ -385,28 +364,28 @@ struct dummy_dragonAI : public ScriptedAI { switch (eventId) { - case EVENT_SHADOW_FISSURE: - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 0.0f, true)) - DoCast(target, SPELL_SHADOW_FISSURE); - events.ScheduleEvent(eventId, urand(15000, 20000)); - break; - case EVENT_SHADOW_BREATH: - Talk(SAY_BREATH); - DoCastVictim(SPELL_SHADOW_BREATH); - events.ScheduleEvent(eventId, urand(20000, 25000)); - break; - default: - break; + case EVENT_SHADOW_FISSURE: + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 0.0f, true)) + DoCast(target, SPELL_SHADOW_FISSURE); + events.ScheduleEvent(eventId, urand(15000, 20000)); + break; + case EVENT_SHADOW_BREATH: + Talk(SAY_BREATH); + DoCastVictim(SPELL_SHADOW_BREATH); + events.ScheduleEvent(eventId, urand(20000, 25000)); + break; + default: + break; } } - protected: - InstanceScript* instance; - EventMap events; - uint32 waypointId; - int32 portalRespawnTime; - bool _canMoveFree; - bool _canLoot; + protected: + InstanceScript* instance; + EventMap events; + uint32 waypointId; + int32 portalRespawnTime; + bool _canMoveFree; + bool _canLoot; }; /*###### @@ -415,12 +394,16 @@ struct dummy_dragonAI : public ScriptedAI class npc_tenebron : public CreatureScript { -public: - npc_tenebron() : CreatureScript("npc_tenebron") { } + public: + npc_tenebron() : CreatureScript("npc_tenebron") + { + } struct npc_tenebronAI : public dummy_dragonAI { - npc_tenebronAI(Creature* creature) : dummy_dragonAI(creature) { } + npc_tenebronAI(Creature* creature) : dummy_dragonAI(creature) + { + } void Reset() override { @@ -449,13 +432,13 @@ class npc_tenebron : public CreatureScript { switch (eventId) { - case EVENT_HATCH_EGGS: - OpenPortal(); - events.ScheduleEvent(EVENT_HATCH_EGGS, 30000); - break; - default: - dummy_dragonAI::ExecuteEvent(eventId); - break; + case EVENT_HATCH_EGGS: + OpenPortal(); + events.ScheduleEvent(EVENT_HATCH_EGGS, 30000); + break; + default: + dummy_dragonAI::ExecuteEvent(eventId); + break; } } @@ -475,12 +458,16 @@ class npc_tenebron : public CreatureScript class npc_shadron : public CreatureScript { -public: - npc_shadron() : CreatureScript("npc_shadron") { } + public: + npc_shadron() : CreatureScript("npc_shadron") + { + } struct npc_shadronAI : public dummy_dragonAI { - npc_shadronAI(Creature* creature) : dummy_dragonAI(creature) { } + npc_shadronAI(Creature* creature) : dummy_dragonAI(creature) + { + } void Reset() override { @@ -517,24 +504,24 @@ class npc_shadron : public CreatureScript { switch (eventId) { - case EVENT_ACOLYTE_SHADRON: - if (instance->GetBossState(DATA_PORTAL_OPEN) == NOT_STARTED) - events.ScheduleEvent(EVENT_ACOLYTE_SHADRON, 10000); - else - { - if (me->HasAura(SPELL_GIFT_OF_TWILIGTH_SHA)) - return; - - OpenPortal(); - - instance->SetBossState(DATA_PORTAL_OPEN, IN_PROGRESS); - - events.ScheduleEvent(EVENT_ACOLYTE_SHADRON, urand(60000, 65000)); - } - break; - default: - dummy_dragonAI::ExecuteEvent(eventId); - break; + case EVENT_ACOLYTE_SHADRON: + if (instance->GetBossState(DATA_PORTAL_OPEN) == NOT_STARTED) + events.ScheduleEvent(EVENT_ACOLYTE_SHADRON, 10000); + else + { + if (me->HasAura(SPELL_GIFT_OF_TWILIGTH_SHA)) + return; + + OpenPortal(); + + instance->SetBossState(DATA_PORTAL_OPEN, IN_PROGRESS); + + events.ScheduleEvent(EVENT_ACOLYTE_SHADRON, urand(60000, 65000)); + } + break; + default: + dummy_dragonAI::ExecuteEvent(eventId); + break; } } @@ -554,12 +541,16 @@ class npc_shadron : public CreatureScript class npc_vesperon : public CreatureScript { -public: - npc_vesperon() : CreatureScript("npc_vesperon") { } + public: + npc_vesperon() : CreatureScript("npc_vesperon") + { + } struct npc_vesperonAI : public dummy_dragonAI { - npc_vesperonAI(Creature* creature) : dummy_dragonAI(creature) { } + npc_vesperonAI(Creature* creature) : dummy_dragonAI(creature) + { + } void Reset() override { @@ -588,19 +579,19 @@ class npc_vesperon : public CreatureScript { switch (eventId) { - case EVENT_ACOLYTE_VESPERON: - if (instance->GetBossState(DATA_PORTAL_OPEN) == IN_PROGRESS) - events.ScheduleEvent(EVENT_ACOLYTE_VESPERON, 10000); - else - { - OpenPortal(); - DoCastVictim(SPELL_TWILIGHT_TORMENT_VESP); - events.ScheduleEvent(EVENT_ACOLYTE_VESPERON, urand(60000, 70000)); - } - break; - default: - dummy_dragonAI::ExecuteEvent(eventId); - break; + case EVENT_ACOLYTE_VESPERON: + if (instance->GetBossState(DATA_PORTAL_OPEN) == IN_PROGRESS) + events.ScheduleEvent(EVENT_ACOLYTE_VESPERON, 10000); + else + { + OpenPortal(); + DoCastVictim(SPELL_TWILIGHT_TORMENT_VESP); + events.ScheduleEvent(EVENT_ACOLYTE_VESPERON, urand(60000, 70000)); + } + break; + default: + dummy_dragonAI::ExecuteEvent(eventId); + break; } } @@ -620,83 +611,85 @@ class npc_vesperon : public CreatureScript class npc_acolyte_of_shadron : public CreatureScript { - public: - npc_acolyte_of_shadron() : CreatureScript("npc_acolyte_of_shadron") { } + public: + npc_acolyte_of_shadron() : CreatureScript("npc_acolyte_of_shadron") + { + } - struct npc_acolyte_of_shadronAI : public ScriptedAI + struct npc_acolyte_of_shadronAI : public ScriptedAI + { + npc_acolyte_of_shadronAI(Creature* creature) : ScriptedAI(creature) { - npc_acolyte_of_shadronAI(Creature* creature) : ScriptedAI(creature) + instance = creature->GetInstanceScript(); + } + + void Reset() override + { + // Despawn the NPC automatically after 28 seconds + me->DespawnOrUnsummon(28000); + + // if not solo fight, buff main boss, else place debuff on mini-boss. both spells TARGET_SCRIPT + if (instance->GetBossState(DATA_SARTHARION) == IN_PROGRESS) { - instance = creature->GetInstanceScript(); + if (Creature* sartharion = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_SARTHARION))) + sartharion->AddAura(SPELL_GIFT_OF_TWILIGTH_SAR, sartharion); } - - void Reset() override + else { - // Despawn the NPC automatically after 28 seconds - me->DespawnOrUnsummon(28000); - - //if not solo fight, buff main boss, else place debuff on mini-boss. both spells TARGET_SCRIPT - if (instance->GetBossState(DATA_SARTHARION) == IN_PROGRESS) - { - if (Creature* sartharion = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_SARTHARION))) - sartharion->AddAura(SPELL_GIFT_OF_TWILIGTH_SAR, sartharion); - } - else - { - if (Creature* shadron = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_SHADRON))) - shadron->AddAura(SPELL_GIFT_OF_TWILIGTH_SHA, shadron); - } - - me->AddAura(SPELL_TWILIGHT_SHIFT_ENTER, me); + if (Creature* shadron = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_SHADRON))) + shadron->AddAura(SPELL_GIFT_OF_TWILIGTH_SHA, shadron); } - void JustDied(Unit* /*killer*/) override - { - if (ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_SHADRON))) - instance->SetBossState(DATA_PORTAL_OPEN, NOT_STARTED); + me->AddAura(SPELL_TWILIGHT_SHIFT_ENTER, me); + } - Map::PlayerList const& PlayerList = me->GetMap()->GetPlayers(); - if (PlayerList.isEmpty()) - return; + void JustDied(Unit* /*killer*/) override + { + if (ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_SHADRON))) + instance->SetBossState(DATA_PORTAL_OPEN, NOT_STARTED); + + Map::PlayerList const& PlayerList = me->GetMap()->GetPlayers(); + if (PlayerList.isEmpty()) + return; - for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) + for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) + { + if (i->GetSource()->IsAlive() && i->GetSource()->HasAura(SPELL_TWILIGHT_SHIFT) && !i->GetSource()->GetVictim()) { - if (i->GetSource()->IsAlive() && i->GetSource()->HasAura(SPELL_TWILIGHT_SHIFT) && !i->GetSource()->GetVictim()) - { - i->GetSource()->CastSpell(i->GetSource(), SPELL_TWILIGHT_SHIFT_REMOVAL_ALL, true); - i->GetSource()->CastSpell(i->GetSource(), SPELL_TWILIGHT_RESIDUE, true); - i->GetSource()->RemoveAurasDueToSpell(SPELL_TWILIGHT_SHIFT); - i->GetSource()->RemoveAurasDueToSpell(SPELL_TWILIGHT_SHIFT_ENTER); - } + i->GetSource()->CastSpell(i->GetSource(), SPELL_TWILIGHT_SHIFT_REMOVAL_ALL, true); + i->GetSource()->CastSpell(i->GetSource(), SPELL_TWILIGHT_RESIDUE, true); + i->GetSource()->RemoveAurasDueToSpell(SPELL_TWILIGHT_SHIFT); + i->GetSource()->RemoveAurasDueToSpell(SPELL_TWILIGHT_SHIFT_ENTER); } - - // not solo fight, so main boss has debuff - if (Creature* debuffTarget = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_SARTHARION))) - if (debuffTarget->IsAlive() && debuffTarget->HasAura(SPELL_GIFT_OF_TWILIGTH_SAR)) - debuffTarget->RemoveAurasDueToSpell(SPELL_GIFT_OF_TWILIGTH_SAR); - - // event not in progress, then solo fight and must remove debuff mini-boss - if (Creature* debuffTarget = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_SHADRON))) - if (debuffTarget->IsAlive() && debuffTarget->HasAura(SPELL_GIFT_OF_TWILIGTH_SHA)) - debuffTarget->RemoveAurasDueToSpell(SPELL_GIFT_OF_TWILIGTH_SHA); } - void UpdateAI(uint32 /*diff*/) override - { - if (!UpdateVictim()) - return; - - DoMeleeAttackIfReady(); - } + // not solo fight, so main boss has debuff + if (Creature* debuffTarget = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_SARTHARION))) + if (debuffTarget->IsAlive() && debuffTarget->HasAura(SPELL_GIFT_OF_TWILIGTH_SAR)) + debuffTarget->RemoveAurasDueToSpell(SPELL_GIFT_OF_TWILIGTH_SAR); - private: - InstanceScript* instance; - }; + // event not in progress, then solo fight and must remove debuff mini-boss + if (Creature* debuffTarget = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_SHADRON))) + if (debuffTarget->IsAlive() && debuffTarget->HasAura(SPELL_GIFT_OF_TWILIGTH_SHA)) + debuffTarget->RemoveAurasDueToSpell(SPELL_GIFT_OF_TWILIGTH_SHA); + } - CreatureAI* GetAI(Creature* creature) const override + void UpdateAI(uint32 /*diff*/) override { - return GetObsidianSanctumAI(creature); + if (!UpdateVictim()) + return; + + DoMeleeAttackIfReady(); } + + private: + InstanceScript* instance; + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return GetObsidianSanctumAI(creature); + } }; /*###### @@ -705,77 +698,79 @@ class npc_acolyte_of_shadron : public CreatureScript class npc_acolyte_of_vesperon : public CreatureScript { - public: - npc_acolyte_of_vesperon() : CreatureScript("npc_acolyte_of_vesperon") { } + public: + npc_acolyte_of_vesperon() : CreatureScript("npc_acolyte_of_vesperon") + { + } - struct npc_acolyte_of_vesperonAI : public ScriptedAI + struct npc_acolyte_of_vesperonAI : public ScriptedAI + { + npc_acolyte_of_vesperonAI(Creature* creature) : ScriptedAI(creature) { - npc_acolyte_of_vesperonAI(Creature* creature) : ScriptedAI(creature) - { - instance = creature->GetInstanceScript(); - } + instance = creature->GetInstanceScript(); + } - void Reset() override - { - // Despawn the NPC automatically after 28 seconds - me->DespawnOrUnsummon(28000); + void Reset() override + { + // Despawn the NPC automatically after 28 seconds + me->DespawnOrUnsummon(28000); + + me->AddAura(SPELL_TWILIGHT_SHIFT_ENTER, me); - me->AddAura(SPELL_TWILIGHT_SHIFT_ENTER, me); + DoCast(me, SPELL_TWILIGHT_TORMENT_VESP_ACO); + } - DoCast(me, SPELL_TWILIGHT_TORMENT_VESP_ACO); - } + void JustDied(Unit* /*killer*/) override + { + me->RemoveAurasDueToSpell(SPELL_TWILIGHT_TORMENT_VESP_ACO); - void JustDied(Unit* /*killer*/) override + // remove twilight torment on Vesperon + if (Creature* vesperon = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_VESPERON))) { - me->RemoveAurasDueToSpell(SPELL_TWILIGHT_TORMENT_VESP_ACO); + instance->SetBossState(DATA_PORTAL_OPEN, NOT_STARTED); - // remove twilight torment on Vesperon - if (Creature* vesperon = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_VESPERON))) - { - instance->SetBossState(DATA_PORTAL_OPEN, NOT_STARTED); - - if (vesperon->IsAlive() && vesperon->HasAura(SPELL_TWILIGHT_TORMENT_VESP)) - vesperon->RemoveAurasDueToSpell(SPELL_TWILIGHT_TORMENT_VESP); - } + if (vesperon->IsAlive() && vesperon->HasAura(SPELL_TWILIGHT_TORMENT_VESP)) + vesperon->RemoveAurasDueToSpell(SPELL_TWILIGHT_TORMENT_VESP); + } - Map::PlayerList const& PlayerList = me->GetMap()->GetPlayers(); - if (PlayerList.isEmpty()) - return; + Map::PlayerList const& PlayerList = me->GetMap()->GetPlayers(); + if (PlayerList.isEmpty()) + return; - for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) + for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) + { + if (i->GetSource()->IsAlive() && i->GetSource()->HasAura(SPELL_TWILIGHT_SHIFT) && !i->GetSource()->GetVictim()) { - if (i->GetSource()->IsAlive() && i->GetSource()->HasAura(SPELL_TWILIGHT_SHIFT) && !i->GetSource()->GetVictim()) - { - i->GetSource()->CastSpell(i->GetSource(), SPELL_TWILIGHT_SHIFT_REMOVAL_ALL, true); - i->GetSource()->CastSpell(i->GetSource(), SPELL_TWILIGHT_RESIDUE, true); - i->GetSource()->RemoveAurasDueToSpell(SPELL_TWILIGHT_SHIFT); - i->GetSource()->RemoveAurasDueToSpell(SPELL_TWILIGHT_SHIFT_ENTER); - } - if (i->GetSource()->IsAlive() && i->GetSource()->HasAura(SPELL_TWILIGHT_TORMENT_VESP) && !i->GetSource()->GetVictim()) - i->GetSource()->RemoveAurasDueToSpell(SPELL_TWILIGHT_TORMENT_VESP); + i->GetSource()->CastSpell(i->GetSource(), SPELL_TWILIGHT_SHIFT_REMOVAL_ALL, true); + i->GetSource()->CastSpell(i->GetSource(), SPELL_TWILIGHT_RESIDUE, true); + i->GetSource()->RemoveAurasDueToSpell(SPELL_TWILIGHT_SHIFT); + i->GetSource()->RemoveAurasDueToSpell(SPELL_TWILIGHT_SHIFT_ENTER); } - - instance->DoRemoveAurasDueToSpellOnPlayers(SPELL_TWILIGHT_TORMENT_VESP_ACO); - instance->DoRemoveAurasDueToSpellOnPlayers(57935); - instance->DoRemoveAurasDueToSpellOnPlayers(58835); // Components of spell Twilight Torment - } - - void UpdateAI(uint32 /*diff*/) override - { - if (!UpdateVictim()) - return; - - DoMeleeAttackIfReady(); + if (i->GetSource()->IsAlive() && i->GetSource()->HasAura(SPELL_TWILIGHT_TORMENT_VESP) && !i->GetSource()->GetVictim()) + i->GetSource()->RemoveAurasDueToSpell(SPELL_TWILIGHT_TORMENT_VESP); } - private: - InstanceScript* instance; - }; + instance->DoRemoveAurasDueToSpellOnPlayers(SPELL_TWILIGHT_TORMENT_VESP_ACO); + instance->DoRemoveAurasDueToSpellOnPlayers(57935); + instance->DoRemoveAurasDueToSpellOnPlayers(58835); // Components of spell Twilight Torment + } - CreatureAI* GetAI(Creature* creature) const override + void UpdateAI(uint32 /*diff*/) override { - return GetObsidianSanctumAI(creature); + if (!UpdateVictim()) + return; + + DoMeleeAttackIfReady(); } + + private: + InstanceScript* instance; + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return GetObsidianSanctumAI(creature); + } }; /*###### @@ -784,13 +779,15 @@ class npc_acolyte_of_vesperon : public CreatureScript enum TwilightEggs { - EVENT_TWILIGHT_EGGS = 11 + EVENT_TWILIGHT_EGGS = 11 }; class npc_twilight_eggs : public CreatureScript { -public: - npc_twilight_eggs() : CreatureScript("npc_twilight_eggs") { } + public: + npc_twilight_eggs() : CreatureScript("npc_twilight_eggs") + { + } struct npc_twilight_eggsAI : public ScriptedAI { @@ -815,7 +812,7 @@ class npc_twilight_eggs : public CreatureScript me->SummonCreature(NPC_TWILIGHT_WHELP, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 60000); else me->SummonCreature(NPC_SARTHARION_TWILIGHT_WHELP, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 60000); - me->DealDamage(me, me->GetHealth()); + me->KillSelf(); } void JustSummoned(Creature* who) override @@ -836,7 +833,7 @@ class npc_twilight_eggs : public CreatureScript } } - private: + private: InstanceScript* instance; EventMap events; }; @@ -853,14 +850,16 @@ class npc_twilight_eggs : public CreatureScript enum FlameTsunami { - EVENT_TSUNAMI_TIMER = 12, - EVENT_TSUNAMI_BUFF = 13 + EVENT_TSUNAMI_TIMER = 12, + EVENT_TSUNAMI_BUFF = 13 }; class npc_flame_tsunami : public CreatureScript { -public: - npc_flame_tsunami() : CreatureScript("npc_flame_tsunami") { } + public: + npc_flame_tsunami() : CreatureScript("npc_flame_tsunami") + { + } struct npc_flame_tsunamiAI : public ScriptedAI { @@ -886,20 +885,20 @@ class npc_flame_tsunami : public CreatureScript { switch (eventId) { - case EVENT_TSUNAMI_TIMER: - DoCast(me, SPELL_FLAME_TSUNAMI_DMG_AURA); - events.ScheduleEvent(EVENT_TSUNAMI_TIMER, 500); - break; - case EVENT_TSUNAMI_BUFF: - if (Unit* lavaBlaze = GetClosestCreatureWithEntry(me, NPC_LAVA_BLAZE, 10.0f, true)) - lavaBlaze->CastSpell(lavaBlaze, SPELL_FLAME_TSUNAMI_BUFF, true); - events.ScheduleEvent(EVENT_TSUNAMI_BUFF, 1000); - break; + case EVENT_TSUNAMI_TIMER: + DoCast(me, SPELL_FLAME_TSUNAMI_DMG_AURA); + events.ScheduleEvent(EVENT_TSUNAMI_TIMER, 500); + break; + case EVENT_TSUNAMI_BUFF: + if (Unit* lavaBlaze = GetClosestCreatureWithEntry(me, NPC_LAVA_BLAZE, 10.0f, true)) + lavaBlaze->CastSpell(lavaBlaze, SPELL_FLAME_TSUNAMI_BUFF, true); + events.ScheduleEvent(EVENT_TSUNAMI_BUFF, 1000); + break; } } } - private: + private: EventMap events; }; @@ -915,13 +914,15 @@ class npc_flame_tsunami : public CreatureScript enum TwilightFissure { - EVENT_VOID_BLAST = 14 + EVENT_VOID_BLAST = 14 }; class npc_twilight_fissure : public CreatureScript { -public: - npc_twilight_fissure() : CreatureScript("npc_twilight_fissure") { } + public: + npc_twilight_fissure() : CreatureScript("npc_twilight_fissure") + { + } struct npc_twilight_fissureAI : public ScriptedAI { @@ -946,14 +947,14 @@ class npc_twilight_fissure : public CreatureScript { DoCastAOE(SPELL_VOID_BLAST); ////twilight realm - //DoCastVictim(57620, true); - //DoCastVictim(57874, true); + // DoCastVictim(57620, true); + // DoCastVictim(57874, true); me->RemoveAllAuras(); me->KillSelf(); } } - private: + private: EventMap events; }; @@ -969,13 +970,15 @@ class npc_twilight_fissure : public CreatureScript enum TwilightWhelps { - EVENT_FADE_ARMOR = 15 + EVENT_FADE_ARMOR = 15 }; class npc_twilight_whelp : public CreatureScript { -public: - npc_twilight_whelp() : CreatureScript("npc_twilight_whelp") { } + public: + npc_twilight_whelp() : CreatureScript("npc_twilight_whelp") + { + } struct npc_twilight_whelpAI : public ScriptedAI { @@ -1007,7 +1010,7 @@ class npc_twilight_whelp : public CreatureScript DoMeleeAttackIfReady(); } - private: + private: EventMap events; }; @@ -1019,35 +1022,41 @@ class npc_twilight_whelp : public CreatureScript class achievement_twilight_assist : public AchievementCriteriaScript { - public: - achievement_twilight_assist() : AchievementCriteriaScript("achievement_twilight_assist") { } + public: + achievement_twilight_assist() : AchievementCriteriaScript("achievement_twilight_assist") + { + } - bool OnCheck(Player* /*player*/, Unit* target) override - { - return target && target->GetAI()->GetData(TWILIGHT_ACHIEVEMENTS) >= 1; - } + bool OnCheck(Player* /*player*/, Unit* target) override + { + return target && target->GetAI()->GetData(TWILIGHT_ACHIEVEMENTS) >= 1; + } }; class achievement_twilight_duo : public AchievementCriteriaScript { - public: - achievement_twilight_duo() : AchievementCriteriaScript("achievement_twilight_duo") { } + public: + achievement_twilight_duo() : AchievementCriteriaScript("achievement_twilight_duo") + { + } - bool OnCheck(Player* /*player*/, Unit* target) override - { - return target && target->GetAI()->GetData(TWILIGHT_ACHIEVEMENTS) >= 2; - } + bool OnCheck(Player* /*player*/, Unit* target) override + { + return target && target->GetAI()->GetData(TWILIGHT_ACHIEVEMENTS) >= 2; + } }; class achievement_twilight_zone : public AchievementCriteriaScript { - public: - achievement_twilight_zone() : AchievementCriteriaScript("achievement_twilight_zone") { } + public: + achievement_twilight_zone() : AchievementCriteriaScript("achievement_twilight_zone") + { + } - bool OnCheck(Player* /*player*/, Unit* target) override - { - return target && target->GetAI()->GetData(TWILIGHT_ACHIEVEMENTS) == 3; - } + bool OnCheck(Player* /*player*/, Unit* target) override + { + return target && target->GetAI()->GetData(TWILIGHT_ACHIEVEMENTS) == 3; + } }; void AddSC_obsidian_sanctum() diff --git a/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_baltharus_the_warborn.cpp b/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_baltharus_the_warborn.cpp index 386d8677..1aebe971 100644 --- a/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_baltharus_the_warborn.cpp +++ b/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_baltharus_the_warborn.cpp @@ -15,38 +15,38 @@ * with this program. If not, see . */ -#include "ScriptMgr.h" #include "InstanceScript.h" -#include "ruby_sanctum.h" +#include "ScriptMgr.h" #include "ScriptedCreature.h" #include "SpellAuras.h" #include "SpellScript.h" +#include "ruby_sanctum.h" enum Texts { - SAY_BALTHARUS_INTRO = 0, // Your power wanes, ancient one.... Soon you will join your friends. - SAY_AGGRO = 1, // Ah, the entertainment has arrived. - SAY_KILL = 2, // Baltharus leaves no survivors! - This world has enough heroes. - SAY_CLONE = 3, // Twice the pain and half the fun. - SAY_DEATH = 4 // I... didn't see that coming.... + SAY_BALTHARUS_INTRO = 0, // Your power wanes, ancient one.... Soon you will join your friends. + SAY_AGGRO = 1, // Ah, the entertainment has arrived. + SAY_KILL = 2, // Baltharus leaves no survivors! - This world has enough heroes. + SAY_CLONE = 3, // Twice the pain and half the fun. + SAY_DEATH = 4 // I... didn't see that coming.... }; enum Spells { - SPELL_BARRIER_CHANNEL = 76221, - SPELL_ENERVATING_BRAND = 74502, - SPELL_SIPHONED_MIGHT = 74507, - SPELL_CLEAVE = 40504, - SPELL_BLADE_TEMPEST = 75125, - SPELL_CLONE = 74511, - SPELL_REPELLING_WAVE = 74509, - SPELL_CLEAR_DEBUFFS = 34098, - SPELL_SPAWN_EFFECT = 64195 + SPELL_BARRIER_CHANNEL = 76221, + SPELL_ENERVATING_BRAND = 74502, + SPELL_SIPHONED_MIGHT = 74507, + SPELL_CLEAVE = 40504, + SPELL_BLADE_TEMPEST = 75125, + SPELL_CLONE = 74511, + SPELL_REPELLING_WAVE = 74509, + SPELL_CLEAR_DEBUFFS = 34098, + SPELL_SPAWN_EFFECT = 64195 }; enum Events { - EVENT_BLADE_TEMPEST = 1, + EVENT_BLADE_TEMPEST = 1, EVENT_CLEAVE, EVENT_ENERVATING_BRAND, EVENT_INTRO_TALK, @@ -56,306 +56,318 @@ enum Events enum Actions { - ACTION_CLONE = 1 + ACTION_CLONE = 1 }; enum Phases { - PHASE_ALL = 0, + PHASE_ALL = 0, PHASE_INTRO, PHASE_COMBAT }; class boss_baltharus_the_warborn : public CreatureScript { - public: - boss_baltharus_the_warborn() : CreatureScript("boss_baltharus_the_warborn") { } + public: + boss_baltharus_the_warborn() : CreatureScript("boss_baltharus_the_warborn") + { + } + + struct boss_baltharus_the_warbornAI : public BossAI + { + boss_baltharus_the_warbornAI(Creature* creature) : BossAI(creature, DATA_BALTHARUS_THE_WARBORN), _cloneCount(0) + { + } - struct boss_baltharus_the_warbornAI : public BossAI + void Reset() override { - boss_baltharus_the_warbornAI(Creature* creature) : BossAI(creature, DATA_BALTHARUS_THE_WARBORN), _cloneCount(0) { } + _Reset(); + events.SetPhase(PHASE_INTRO); + instance->SetData(DATA_BALTHARUS_SHARED_HEALTH, me->GetMaxHealth()); + if (Creature* channelTarget = instance->GetCreature(DATA_CRYSTAL_CHANNEL_TARGET)) + DoCast(channelTarget, SPELL_BARRIER_CHANNEL); + _cloneCount = 0; + } - void Reset() override + void DoAction(int32 action) override + { + switch (action) { - _Reset(); - events.SetPhase(PHASE_INTRO); - instance->SetData(DATA_BALTHARUS_SHARED_HEALTH, me->GetMaxHealth()); - if (Creature* channelTarget = instance->GetCreature(DATA_CRYSTAL_CHANNEL_TARGET)) - DoCast(channelTarget, SPELL_BARRIER_CHANNEL); - _cloneCount = 0; - } - - void DoAction(int32 action) override + case ACTION_INTRO_BALTHARUS: + me->setActive(true); + me->SetFarVisible(true); + events.ScheduleEvent(EVENT_INTRO_TALK, Seconds(7), 0, PHASE_INTRO); + break; + case ACTION_CLONE: { - switch (action) - { - case ACTION_INTRO_BALTHARUS: - me->setActive(true); - me->SetFarVisible(true); - events.ScheduleEvent(EVENT_INTRO_TALK, Seconds(7), 0, PHASE_INTRO); - break; - case ACTION_CLONE: - { - DoCastSelf(SPELL_CLEAR_DEBUFFS, true); - DoCastSelf(SPELL_CLONE, true); - DoCastSelf(SPELL_REPELLING_WAVE); - Talk(SAY_CLONE); - break; - } - default: - break; - } + DoCastSelf(SPELL_CLEAR_DEBUFFS, true); + DoCastSelf(SPELL_CLONE, true); + DoCastSelf(SPELL_REPELLING_WAVE); + Talk(SAY_CLONE); + break; } - - void JustEngagedWith(Unit* who) override - { - me->InterruptNonMeleeSpells(false); - BossAI::JustEngagedWith(who); - events.Reset(); - events.SetPhase(PHASE_COMBAT); - events.ScheduleEvent(EVENT_CLEAVE, Seconds(13), 0, PHASE_COMBAT); - events.ScheduleEvent(EVENT_ENERVATING_BRAND, Seconds(13), 0, PHASE_COMBAT); - events.ScheduleEvent(EVENT_BLADE_TEMPEST, Seconds(18), 0, PHASE_COMBAT); - Talk(SAY_AGGRO); + default: + break; } + } - void JustDied(Unit* /*killer*/) override - { - _JustDied(); - Talk(SAY_DEATH); - if (Creature* xerestrasza = instance->GetCreature(DATA_XERESTRASZA)) - xerestrasza->AI()->DoAction(ACTION_BALTHARUS_DEATH); - } + void JustEngagedWith(Unit* who) override + { + me->InterruptNonMeleeSpells(false); + BossAI::JustEngagedWith(who); + events.Reset(); + events.SetPhase(PHASE_COMBAT); + events.ScheduleEvent(EVENT_CLEAVE, Seconds(13), 0, PHASE_COMBAT); + events.ScheduleEvent(EVENT_ENERVATING_BRAND, Seconds(13), 0, PHASE_COMBAT); + events.ScheduleEvent(EVENT_BLADE_TEMPEST, Seconds(18), 0, PHASE_COMBAT); + Talk(SAY_AGGRO); + } - void KilledUnit(Unit* victim) override - { - if (victim->GetTypeId() == TYPEID_PLAYER) - Talk(SAY_KILL); - } + void JustDied(Unit* /*killer*/) override + { + _JustDied(); + Talk(SAY_DEATH); + if (Creature* xerestrasza = instance->GetCreature(DATA_XERESTRASZA)) + xerestrasza->AI()->DoAction(ACTION_BALTHARUS_DEATH); + } + + void KilledUnit(Unit* victim) override + { + if (victim->GetTypeId() == TYPEID_PLAYER) + Talk(SAY_KILL); + } + + void JustSummoned(Creature* summon) override + { + summons.Summon(summon); + summon->SetHealth(me->GetHealth()); + events.ScheduleEvent(EVENT_SUMMONS_ATTACK, Seconds(2)); + } - void JustSummoned(Creature* summon) override + void DamageTaken(Unit* /*attacker*/, uint32& damage) override + { + if (GetDifficulty() == RAID_DIFFICULTY_10MAN_NORMAL) { - summons.Summon(summon); - summon->SetHealth(me->GetHealth()); - events.ScheduleEvent(EVENT_SUMMONS_ATTACK, Seconds(2)); + if (me->HealthBelowPctDamaged(50, damage) && _cloneCount == 0) + { + ++_cloneCount; + events.ScheduleEvent(EVENT_CLONE, Milliseconds(1)); + } } - - void DamageTaken(Unit* /*attacker*/, uint32& damage) override + else { - if (GetDifficulty() == RAID_DIFFICULTY_10MAN_NORMAL) + if (me->HealthBelowPctDamaged(66, damage) && _cloneCount == 0) { - if (me->HealthBelowPctDamaged(50, damage) && _cloneCount == 0) - { - ++_cloneCount; - events.ScheduleEvent(EVENT_CLONE, Milliseconds(1)); - } + ++_cloneCount; + events.ScheduleEvent(EVENT_CLONE, Milliseconds(1)); } - else + else if (me->HealthBelowPctDamaged(33, damage) && _cloneCount == 1) { - if (me->HealthBelowPctDamaged(66, damage) && _cloneCount == 0) - { - ++_cloneCount; - events.ScheduleEvent(EVENT_CLONE, Milliseconds(1)); - } - else if (me->HealthBelowPctDamaged(33, damage) && _cloneCount == 1) - { - ++_cloneCount; - events.ScheduleEvent(EVENT_CLONE, Milliseconds(1)); - } + ++_cloneCount; + events.ScheduleEvent(EVENT_CLONE, Milliseconds(1)); } - - if (me->GetHealth() > damage) - instance->SetData(DATA_BALTHARUS_SHARED_HEALTH, me->GetHealth() - damage); } - void EnterEvadeMode(EvadeReason /*why*/) override - { - summons.DespawnAll(); - events.Reset(); - _DespawnAtEvade(); - } + if (me->GetHealth() > damage) + instance->SetData(DATA_BALTHARUS_SHARED_HEALTH, me->GetHealth() - damage); + } - void UpdateAI(uint32 diff) override - { + void EnterEvadeMode(EvadeReason /*why*/) override + { + summons.DespawnAll(); + events.Reset(); + _DespawnAtEvade(); + } - if (!events.IsInPhase(PHASE_INTRO) && !UpdateVictim()) - return; + void UpdateAI(uint32 diff) override + { - if (!events.IsInPhase(PHASE_INTRO)) - me->SetHealth(instance->GetData(DATA_BALTHARUS_SHARED_HEALTH)); + if (!events.IsInPhase(PHASE_INTRO) && !UpdateVictim()) + return; - events.Update(diff); + if (!events.IsInPhase(PHASE_INTRO)) + me->SetHealth(instance->GetData(DATA_BALTHARUS_SHARED_HEALTH)); - if (!events.IsInPhase(PHASE_INTRO) && me->HasUnitState(UNIT_STATE_CASTING)) - return; + events.Update(diff); + + if (!events.IsInPhase(PHASE_INTRO) && me->HasUnitState(UNIT_STATE_CASTING)) + return; - while (uint32 eventId = events.ExecuteEvent()) + while (uint32 eventId = events.ExecuteEvent()) + { + switch (eventId) { - switch (eventId) - { - case EVENT_INTRO_TALK: - Talk(SAY_BALTHARUS_INTRO); - break; - case EVENT_CLEAVE: - DoCastVictim(SPELL_CLEAVE); - events.Repeat(Seconds(20), Seconds(24)); - break; - case EVENT_BLADE_TEMPEST: - DoCastSelf(SPELL_BLADE_TEMPEST); - events.Repeat(Seconds(24)); - break; - case EVENT_ENERVATING_BRAND: - for (uint8 i = 0; i < RAID_MODE(4, 8, 8, 10); i++) - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 45.0f, true)) - DoCast(target, SPELL_ENERVATING_BRAND); - events.Repeat(Seconds(26)); - break; - case EVENT_SUMMONS_ATTACK: - summons.DoZoneInCombat(NPC_BALTHARUS_THE_WARBORN_CLONE); - break; - case EVENT_CLONE: - DoAction(ACTION_CLONE); - break; - default: - break; - } - - if (me->HasUnitState(UNIT_STATE_CASTING)) - return; + case EVENT_INTRO_TALK: + Talk(SAY_BALTHARUS_INTRO); + break; + case EVENT_CLEAVE: + DoCastVictim(SPELL_CLEAVE); + events.Repeat(Seconds(20), Seconds(24)); + break; + case EVENT_BLADE_TEMPEST: + DoCastSelf(SPELL_BLADE_TEMPEST); + events.Repeat(Seconds(24)); + break; + case EVENT_ENERVATING_BRAND: + for (uint8 i = 0; i < RAID_MODE(4, 8, 8, 10); i++) + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 45.0f, true)) + DoCast(target, SPELL_ENERVATING_BRAND); + events.Repeat(Seconds(26)); + break; + case EVENT_SUMMONS_ATTACK: + summons.DoZoneInCombat(NPC_BALTHARUS_THE_WARBORN_CLONE); + break; + case EVENT_CLONE: + DoAction(ACTION_CLONE); + break; + default: + break; } - DoMeleeAttackIfReady(); + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; } - private: - uint8 _cloneCount; - }; - - CreatureAI* GetAI(Creature* creature) const override - { - return GetRubySanctumAI(creature); + DoMeleeAttackIfReady(); } + + private: + uint8 _cloneCount; + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return GetRubySanctumAI(creature); + } }; class npc_baltharus_the_warborn_clone : public CreatureScript { - public: - npc_baltharus_the_warborn_clone() : CreatureScript("npc_baltharus_the_warborn_clone") { } - - struct npc_baltharus_the_warborn_cloneAI : public BossAI + public: + npc_baltharus_the_warborn_clone() : CreatureScript("npc_baltharus_the_warborn_clone") + { + } + + struct npc_baltharus_the_warborn_cloneAI : public BossAI + { + npc_baltharus_the_warborn_cloneAI(Creature* creature) : BossAI(creature, DATA_BALTHARUS_CLONE) { - npc_baltharus_the_warborn_cloneAI(Creature* creature) : BossAI(creature, DATA_BALTHARUS_CLONE) { } + } - void Reset() override - { - DoCastSelf(SPELL_SPAWN_EFFECT); - me->SetReactState(REACT_DEFENSIVE); - } + void Reset() override + { + DoCastSelf(SPELL_SPAWN_EFFECT); + me->SetReactState(REACT_DEFENSIVE); + } - void JustEngagedWith(Unit* /*who*/) override - { - DoZoneInCombat(); - events.Reset(); - events.ScheduleEvent(EVENT_CLEAVE, Seconds(11)); - events.ScheduleEvent(EVENT_BLADE_TEMPEST, Seconds(15)); - events.ScheduleEvent(EVENT_ENERVATING_BRAND, Seconds(10)); - } + void JustEngagedWith(Unit* /*who*/) override + { + DoZoneInCombat(); + events.Reset(); + events.ScheduleEvent(EVENT_CLEAVE, Seconds(11)); + events.ScheduleEvent(EVENT_BLADE_TEMPEST, Seconds(15)); + events.ScheduleEvent(EVENT_ENERVATING_BRAND, Seconds(10)); + } - void EnterEvadeMode(EvadeReason /*why*/) override { } + void EnterEvadeMode(EvadeReason /*why*/) override + { + } - void DamageTaken(Unit* /*attacker*/, uint32& damage) override - { - // Setting DATA_BALTHARUS_SHARED_HEALTH to 0 when killed would bug the boss. - if (me->GetHealth() > damage) - instance->SetData(DATA_BALTHARUS_SHARED_HEALTH, me->GetHealth() - damage); - } + void DamageTaken(Unit* /*attacker*/, uint32& damage) override + { + // Setting DATA_BALTHARUS_SHARED_HEALTH to 0 when killed would bug the boss. + if (me->GetHealth() > damage) + instance->SetData(DATA_BALTHARUS_SHARED_HEALTH, me->GetHealth() - damage); + } - void JustDied(Unit* killer) override - { - // This is here because DamageTaken wont trigger if the damage is deadly. - if (Creature* baltharus = instance->GetCreature(DATA_BALTHARUS_THE_WARBORN)) - killer->Kill(baltharus); - } + void JustDied(Unit* killer) override + { + // This is here because DamageTaken wont trigger if the damage is deadly. + if (Creature* baltharus = instance->GetCreature(DATA_BALTHARUS_THE_WARBORN)) + Unit::Kill(killer, baltharus); + } - void UpdateAI(uint32 diff) override - { - if (!UpdateVictim()) - return; + void UpdateAI(uint32 diff) override + { + if (!UpdateVictim()) + return; - me->SetHealth(instance->GetData(DATA_BALTHARUS_SHARED_HEALTH)); + me->SetHealth(instance->GetData(DATA_BALTHARUS_SHARED_HEALTH)); - events.Update(diff); + events.Update(diff); - if (me->HasUnitState(UNIT_STATE_CASTING)) - return; + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; - while (uint32 eventId = events.ExecuteEvent()) + while (uint32 eventId = events.ExecuteEvent()) + { + switch (eventId) { - switch (eventId) - { - case EVENT_CLEAVE: - DoCastVictim(SPELL_CLEAVE); - events.Repeat(Seconds(20), Seconds(24)); - break; - case EVENT_BLADE_TEMPEST: - DoCastVictim(SPELL_BLADE_TEMPEST); - events.Repeat(Seconds(24)); - break; - case EVENT_ENERVATING_BRAND: - for (uint8 i = 0; i < RAID_MODE(4, 8, 8, 10); i++) - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 45.0f, true)) - DoCast(target, SPELL_ENERVATING_BRAND); - events.Repeat(Seconds(26)); - break; - default: - break; - } - - if (me->HasUnitState(UNIT_STATE_CASTING)) - return; + case EVENT_CLEAVE: + DoCastVictim(SPELL_CLEAVE); + events.Repeat(Seconds(20), Seconds(24)); + break; + case EVENT_BLADE_TEMPEST: + DoCastVictim(SPELL_BLADE_TEMPEST); + events.Repeat(Seconds(24)); + break; + case EVENT_ENERVATING_BRAND: + for (uint8 i = 0; i < RAID_MODE(4, 8, 8, 10); i++) + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 45.0f, true)) + DoCast(target, SPELL_ENERVATING_BRAND); + events.Repeat(Seconds(26)); + break; + default: + break; } - DoMeleeAttackIfReady(); + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; } - }; - CreatureAI* GetAI(Creature* creature) const override - { - return GetRubySanctumAI(creature); + DoMeleeAttackIfReady(); } + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return GetRubySanctumAI(creature); + } }; // 74505 - Enervating Brand class spell_baltharus_enervating_brand_trigger : public SpellScriptLoader { - public: - spell_baltharus_enervating_brand_trigger() : SpellScriptLoader("spell_baltharus_enervating_brand_trigger") { } - - class spell_baltharus_enervating_brand_trigger_SpellScript : public SpellScript + public: + spell_baltharus_enervating_brand_trigger() : SpellScriptLoader("spell_baltharus_enervating_brand_trigger") + { + } + + class spell_baltharus_enervating_brand_trigger_SpellScript : public SpellScript + { + bool Validate(SpellInfo const* /*spell*/) override { - bool Validate(SpellInfo const* /*spell*/) override - { - return ValidateSpellInfo({ SPELL_SIPHONED_MIGHT }); - } - - void HandleSiphonedMight() - { - if (SpellInfo const* spellInfo = GetTriggeringSpell()) - if (Aura* triggerAura = GetCaster()->GetAura(spellInfo->Id)) - if (Unit* caster = triggerAura->GetCaster()) - GetHitUnit()->CastSpell(caster, SPELL_SIPHONED_MIGHT, true); - } + return ValidateSpellInfo({SPELL_SIPHONED_MIGHT}); + } - void Register() override - { - OnHit.Register(&spell_baltharus_enervating_brand_trigger_SpellScript::HandleSiphonedMight); - } - }; + void HandleSiphonedMight() + { + if (SpellInfo const* spellInfo = GetTriggeringSpell()) + if (Aura* triggerAura = GetCaster()->GetAura(spellInfo->Id)) + if (Unit* caster = triggerAura->GetCaster()) + GetHitUnit()->CastSpell(caster, SPELL_SIPHONED_MIGHT, true); + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_baltharus_enervating_brand_trigger_SpellScript(); + OnHit.Register(&spell_baltharus_enervating_brand_trigger_SpellScript::HandleSiphonedMight); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_baltharus_enervating_brand_trigger_SpellScript(); + } }; void AddSC_boss_baltharus_the_warborn() diff --git a/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_halion.cpp b/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_halion.cpp index 75bbf85a..a6c1eb42 100644 --- a/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_halion.cpp +++ b/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_halion.cpp @@ -455,7 +455,7 @@ class boss_twilight_halion : public CreatureScript halion->LowerPlayerDamageReq(halion->GetMaxHealth()); if (halion->IsAlive()) - killer->Kill(halion); + Unit::Kill(killer, halion); } if (Creature* controller = instance->GetCreature(DATA_HALION_CONTROLLER)) diff --git a/src/server/scripts/Northrend/Gundrak/boss_drakkari_colossus.cpp b/src/server/scripts/Northrend/Gundrak/boss_drakkari_colossus.cpp index e8f28eb7..d1a5bfc3 100644 --- a/src/server/scripts/Northrend/Gundrak/boss_drakkari_colossus.cpp +++ b/src/server/scripts/Northrend/Gundrak/boss_drakkari_colossus.cpp @@ -19,57 +19,57 @@ * Comment: The event with the Living Mojos is not implemented, just is done that when one of the mojos around the boss take damage will make the boss enter in combat! */ -#include "ScriptMgr.h" -#include "gundrak.h" #include "InstanceScript.h" #include "MotionMaster.h" +#include "ScriptMgr.h" #include "ScriptedCreature.h" #include "SpellInfo.h" +#include "gundrak.h" enum Texts { // Drakkari Elemental - EMOTE_MOJO = 0, - EMOTE_ACTIVATE_ALTAR = 1 + EMOTE_MOJO = 0, + EMOTE_ACTIVATE_ALTAR = 1 }; enum Spells { - SPELL_EMERGE = 54850, - SPELL_ELEMENTAL_SPAWN_EFFECT = 54888, - SPELL_MOJO_VOLLEY = 54849, - SPELL_SURGE_VISUAL = 54827, - SPELL_MERGE = 54878, - SPELL_MIGHTY_BLOW = 54719, - SPELL_SURGE = 54801, - SPELL_FREEZE_ANIM = 16245, - SPELL_MOJO_PUDDLE = 55627, - SPELL_MOJO_WAVE = 55626, + SPELL_EMERGE = 54850, + SPELL_ELEMENTAL_SPAWN_EFFECT = 54888, + SPELL_MOJO_VOLLEY = 54849, + SPELL_SURGE_VISUAL = 54827, + SPELL_MERGE = 54878, + SPELL_MIGHTY_BLOW = 54719, + SPELL_SURGE = 54801, + SPELL_FREEZE_ANIM = 16245, + SPELL_MOJO_PUDDLE = 55627, + SPELL_MOJO_WAVE = 55626, }; enum ColossusEvents { - EVENT_MIGHTY_BLOW = 1, + EVENT_MIGHTY_BLOW = 1, }; enum ColossusActions { - ACTION_SUMMON_ELEMENTAL = 1, - ACTION_FREEZE_COLOSSUS = 2, - ACTION_UNFREEZE_COLOSSUS = 3, + ACTION_SUMMON_ELEMENTAL = 1, + ACTION_FREEZE_COLOSSUS = 2, + ACTION_UNFREEZE_COLOSSUS = 3, }; enum ColossusPhases { - COLOSSUS_PHASE_NORMAL = 1, - COLOSSUS_PHASE_FIRST_ELEMENTAL_SUMMON = 2, - COLOSSUS_PHASE_SECOND_ELEMENTAL_SUMMON = 3 + COLOSSUS_PHASE_NORMAL = 1, + COLOSSUS_PHASE_FIRST_ELEMENTAL_SUMMON = 2, + COLOSSUS_PHASE_SECOND_ELEMENTAL_SUMMON = 3 }; enum ColossusData { DATA_COLOSSUS_PHASE = 1, - DATA_INTRO_DONE = 2 + DATA_INTRO_DONE = 2 }; enum ElementalActions @@ -84,295 +84,300 @@ enum ElementalEvents class boss_drakkari_colossus : public CreatureScript { - public: - boss_drakkari_colossus() : CreatureScript("boss_drakkari_colossus") { } + public: + boss_drakkari_colossus() : CreatureScript("boss_drakkari_colossus") + { + } - struct boss_drakkari_colossusAI : public BossAI + struct boss_drakkari_colossusAI : public BossAI + { + boss_drakkari_colossusAI(Creature* creature) : BossAI(creature, DATA_DRAKKARI_COLOSSUS) { - boss_drakkari_colossusAI(Creature* creature) : BossAI(creature, DATA_DRAKKARI_COLOSSUS) - { - Initialize(); - me->SetReactState(REACT_PASSIVE); - introDone = false; - } + Initialize(); + me->SetReactState(REACT_PASSIVE); + introDone = false; + } + + void Initialize() + { + phase = COLOSSUS_PHASE_NORMAL; + } - void Initialize() + void Reset() override + { + _Reset(); + + if (GetData(DATA_INTRO_DONE)) { - phase = COLOSSUS_PHASE_NORMAL; + me->SetReactState(REACT_AGGRESSIVE); + me->SetImmuneToPC(false); + me->RemoveAura(SPELL_FREEZE_ANIM); } - void Reset() override - { - _Reset(); + events.ScheduleEvent(EVENT_MIGHTY_BLOW, urand(10000, 30000)); - if (GetData(DATA_INTRO_DONE)) - { - me->SetReactState(REACT_AGGRESSIVE); - me->SetImmuneToPC(false); - me->RemoveAura(SPELL_FREEZE_ANIM); - } + Initialize(); + } - events.ScheduleEvent(EVENT_MIGHTY_BLOW, urand(10000, 30000)); + void JustEngagedWith(Unit* who) override + { + BossAI::JustEngagedWith(who); + me->RemoveAura(SPELL_FREEZE_ANIM); + } - Initialize(); - } + void JustDied(Unit* /*killer*/) override + { + _JustDied(); + } - void JustEngagedWith(Unit* who) override + void DoAction(int32 action) override + { + switch (action) { - BossAI::JustEngagedWith(who); - me->RemoveAura(SPELL_FREEZE_ANIM); - } + case ACTION_SUMMON_ELEMENTAL: + DoCast(SPELL_EMERGE); + break; + case ACTION_FREEZE_COLOSSUS: + me->GetMotionMaster()->Clear(); + me->GetMotionMaster()->MoveIdle(); - void JustDied(Unit* /*killer*/) override - { - _JustDied(); - } + me->SetReactState(REACT_PASSIVE); + me->SetImmuneToPC(true); + DoCast(me, SPELL_FREEZE_ANIM); + break; + case ACTION_UNFREEZE_COLOSSUS: - void DoAction(int32 action) override - { - switch (action) - { - case ACTION_SUMMON_ELEMENTAL: - DoCast(SPELL_EMERGE); - break; - case ACTION_FREEZE_COLOSSUS: - me->GetMotionMaster()->Clear(); - me->GetMotionMaster()->MoveIdle(); - - me->SetReactState(REACT_PASSIVE); - me->SetImmuneToPC(true); - DoCast(me, SPELL_FREEZE_ANIM); - break; - case ACTION_UNFREEZE_COLOSSUS: - - if (me->GetReactState() == REACT_AGGRESSIVE) - return; + if (me->GetReactState() == REACT_AGGRESSIVE) + return; - me->SetImmuneToPC(false); - me->SetReactState(REACT_AGGRESSIVE); - me->RemoveAura(SPELL_FREEZE_ANIM); + me->SetImmuneToPC(false); + me->SetReactState(REACT_AGGRESSIVE); + me->RemoveAura(SPELL_FREEZE_ANIM); - me->SetInCombatWithZone(); + me->SetInCombatWithZone(); - break; - } + break; } + } - void DamageTaken(Unit* /*attacker*/, uint32& damage) override - { - if (me->IsImmuneToPC()) - damage = 0; + void DamageTaken(Unit* /*attacker*/, uint32& damage) override + { + if (me->IsImmuneToPC()) + damage = 0; - if (phase == COLOSSUS_PHASE_NORMAL || - phase == COLOSSUS_PHASE_FIRST_ELEMENTAL_SUMMON) + if (phase == COLOSSUS_PHASE_NORMAL || phase == COLOSSUS_PHASE_FIRST_ELEMENTAL_SUMMON) + { + if (HealthBelowPct(phase == COLOSSUS_PHASE_NORMAL ? 50 : 5)) { - if (HealthBelowPct(phase == COLOSSUS_PHASE_NORMAL ? 50 : 5)) - { - damage = 0; - phase = (phase == COLOSSUS_PHASE_NORMAL ? COLOSSUS_PHASE_FIRST_ELEMENTAL_SUMMON : COLOSSUS_PHASE_SECOND_ELEMENTAL_SUMMON); - DoAction(ACTION_FREEZE_COLOSSUS); - DoAction(ACTION_SUMMON_ELEMENTAL); - } + damage = 0; + phase = (phase == COLOSSUS_PHASE_NORMAL ? COLOSSUS_PHASE_FIRST_ELEMENTAL_SUMMON : COLOSSUS_PHASE_SECOND_ELEMENTAL_SUMMON); + DoAction(ACTION_FREEZE_COLOSSUS); + DoAction(ACTION_SUMMON_ELEMENTAL); } } + } - uint32 GetData(uint32 data) const override - { - if (data == DATA_COLOSSUS_PHASE) - return phase; - else if (data == DATA_INTRO_DONE) - return introDone; + uint32 GetData(uint32 data) const override + { + if (data == DATA_COLOSSUS_PHASE) + return phase; + else if (data == DATA_INTRO_DONE) + return introDone; - return 0; - } + return 0; + } - void SetData(uint32 type, uint32 data) override - { - if (type == DATA_INTRO_DONE) - introDone = data != 0; - } + void SetData(uint32 type, uint32 data) override + { + if (type == DATA_INTRO_DONE) + introDone = data != 0; + } - void UpdateAI(uint32 diff) override - { - if (!UpdateVictim()) - return; + void UpdateAI(uint32 diff) override + { + if (!UpdateVictim()) + return; - events.Update(diff); + events.Update(diff); - if (me->HasUnitState(UNIT_STATE_CASTING)) - return; + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; - while (uint32 eventId = events.ExecuteEvent()) + while (uint32 eventId = events.ExecuteEvent()) + { + switch (eventId) { - switch (eventId) - { - case EVENT_MIGHTY_BLOW: - DoCastVictim(SPELL_MIGHTY_BLOW); - events.ScheduleEvent(EVENT_MIGHTY_BLOW, urand(5000, 15000)); - break; - } - - if (me->HasUnitState(UNIT_STATE_CASTING)) - return; + case EVENT_MIGHTY_BLOW: + DoCastVictim(SPELL_MIGHTY_BLOW); + events.ScheduleEvent(EVENT_MIGHTY_BLOW, urand(5000, 15000)); + break; } - if (me->GetReactState() == REACT_AGGRESSIVE) - DoMeleeAttackIfReady(); - } - - void JustSummoned(Creature* summon) override - { - summon->SetInCombatWithZone(); - - if (phase == COLOSSUS_PHASE_SECOND_ELEMENTAL_SUMMON) - summon->SetHealth(summon->GetMaxHealth() / 2); + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; } - private: - uint8 phase; - bool introDone; - }; + if (me->GetReactState() == REACT_AGGRESSIVE) + DoMeleeAttackIfReady(); + } - CreatureAI* GetAI(Creature* creature) const override + void JustSummoned(Creature* summon) override { - return GetGundrakAI(creature); + summon->SetInCombatWithZone(); + + if (phase == COLOSSUS_PHASE_SECOND_ELEMENTAL_SUMMON) + summon->SetHealth(summon->GetMaxHealth() / 2); } + + private: + uint8 phase; + bool introDone; + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return GetGundrakAI(creature); + } }; class boss_drakkari_elemental : public CreatureScript { - public: - boss_drakkari_elemental() : CreatureScript("boss_drakkari_elemental") { } + public: + boss_drakkari_elemental() : CreatureScript("boss_drakkari_elemental") + { + } - struct boss_drakkari_elementalAI : public ScriptedAI + struct boss_drakkari_elementalAI : public ScriptedAI + { + boss_drakkari_elementalAI(Creature* creature) : ScriptedAI(creature) { - boss_drakkari_elementalAI(Creature* creature) : ScriptedAI(creature) - { - DoCast(me, SPELL_ELEMENTAL_SPAWN_EFFECT); - instance = creature->GetInstanceScript(); - } + DoCast(me, SPELL_ELEMENTAL_SPAWN_EFFECT); + instance = creature->GetInstanceScript(); + } - void Reset() override - { - events.Reset(); - events.ScheduleEvent(EVENT_SURGE, urand(5000, 15000)); + void Reset() override + { + events.Reset(); + events.ScheduleEvent(EVENT_SURGE, urand(5000, 15000)); - me->AddAura(SPELL_MOJO_VOLLEY, me); - } + me->AddAura(SPELL_MOJO_VOLLEY, me); + } - void JustDied(Unit* killer) override - { - Talk(EMOTE_ACTIVATE_ALTAR); + void JustDied(Unit* killer) override + { + Talk(EMOTE_ACTIVATE_ALTAR); - if (Creature* colossus = instance->GetCreature(DATA_DRAKKARI_COLOSSUS)) - killer->Kill(colossus); - } + if (Creature* colossus = instance->GetCreature(DATA_DRAKKARI_COLOSSUS)) + Unit::Kill(killer, colossus); + } - void UpdateAI(uint32 diff) override - { - if (!UpdateVictim()) - return; + void UpdateAI(uint32 diff) override + { + if (!UpdateVictim()) + return; - events.Update(diff); + events.Update(diff); - if (me->HasUnitState(UNIT_STATE_CASTING)) - return; + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; - while (uint32 eventId = events.ExecuteEvent()) + while (uint32 eventId = events.ExecuteEvent()) + { + switch (eventId) { - switch (eventId) - { - case EVENT_SURGE: - DoCast(SPELL_SURGE_VISUAL); - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1, 0.0f, true)) - DoCast(target, SPELL_SURGE); - events.ScheduleEvent(EVENT_SURGE, urand(5000, 15000)); - break; - } - - if (me->HasUnitState(UNIT_STATE_CASTING)) - return; + case EVENT_SURGE: + DoCast(SPELL_SURGE_VISUAL); + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1, 0.0f, true)) + DoCast(target, SPELL_SURGE); + events.ScheduleEvent(EVENT_SURGE, urand(5000, 15000)); + break; } - DoMeleeAttackIfReady(); + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; } - void DoAction(int32 action) override + DoMeleeAttackIfReady(); + } + + void DoAction(int32 action) override + { + switch (action) { - switch (action) - { - case ACTION_RETURN_TO_COLOSSUS: - Talk(EMOTE_MOJO); - DoCast(SPELL_SURGE_VISUAL); - if (Creature* colossus = instance->GetCreature(DATA_DRAKKARI_COLOSSUS)) - // what if the elemental is more than 80 yards from drakkari colossus ? - DoCast(colossus, SPELL_MERGE, true); - break; - } - } + case ACTION_RETURN_TO_COLOSSUS: + Talk(EMOTE_MOJO); + DoCast(SPELL_SURGE_VISUAL); + if (Creature* colossus = instance->GetCreature(DATA_DRAKKARI_COLOSSUS)) + // what if the elemental is more than 80 yards from drakkari colossus ? + DoCast(colossus, SPELL_MERGE, true); + break; + } + } - void DamageTaken(Unit* /*attacker*/, uint32& damage) override + void DamageTaken(Unit* /*attacker*/, uint32& damage) override + { + if (HealthBelowPct(50)) { - if (HealthBelowPct(50)) + if (Creature* colossus = instance->GetCreature(DATA_DRAKKARI_COLOSSUS)) { - if (Creature* colossus = instance->GetCreature(DATA_DRAKKARI_COLOSSUS)) + if (colossus->AI()->GetData(DATA_COLOSSUS_PHASE) == COLOSSUS_PHASE_FIRST_ELEMENTAL_SUMMON) { - if (colossus->AI()->GetData(DATA_COLOSSUS_PHASE) == COLOSSUS_PHASE_FIRST_ELEMENTAL_SUMMON) - { - damage = 0; - - // to prevent spell spaming - if (me->HasUnitState(UNIT_STATE_CHARGING)) - return; + damage = 0; - // not sure about this, the idea of this code is to prevent bug the elemental - // if it is not in a acceptable distance to cast the charge spell. - /*if (me->GetDistance(colossus) > 80.0f) - { - if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == POINT_MOTION_TYPE) - return; + // to prevent spell spaming + if (me->HasUnitState(UNIT_STATE_CHARGING)) + return; - me->GetMotionMaster()->MovePoint(0, colossus->GetPositionX(), colossus->GetPositionY(), colossus->GetPositionZ()); + // not sure about this, the idea of this code is to prevent bug the elemental + // if it is not in a acceptable distance to cast the charge spell. + /*if (me->GetDistance(colossus) > 80.0f) + { + if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == POINT_MOTION_TYPE) return; - }*/ - DoAction(ACTION_RETURN_TO_COLOSSUS); - } + + me->GetMotionMaster()->MovePoint(0, colossus->GetPositionX(), colossus->GetPositionY(), colossus->GetPositionZ()); + return; + }*/ + DoAction(ACTION_RETURN_TO_COLOSSUS); } } } + } - void EnterEvadeMode(EvadeReason /*why*/) override - { - me->DespawnOrUnsummon(); - } + void EnterEvadeMode(EvadeReason /*why*/) override + { + me->DespawnOrUnsummon(); + } - void SpellHitTarget(Unit* target, SpellInfo const* spell) override + void SpellHitTarget(Unit* target, SpellInfo const* spell) override + { + if (spell->Id == SPELL_MERGE) { - if (spell->Id == SPELL_MERGE) + if (Creature* colossus = target->ToCreature()) { - if (Creature* colossus = target->ToCreature()) - { - colossus->AI()->DoAction(ACTION_UNFREEZE_COLOSSUS); - me->DespawnOrUnsummon(); - } + colossus->AI()->DoAction(ACTION_UNFREEZE_COLOSSUS); + me->DespawnOrUnsummon(); } } + } - private: - EventMap events; - InstanceScript* instance; - }; + private: + EventMap events; + InstanceScript* instance; + }; - CreatureAI* GetAI(Creature* creature) const override - { - return GetGundrakAI(creature); - } + CreatureAI* GetAI(Creature* creature) const override + { + return GetGundrakAI(creature); + } }; class npc_living_mojo : public CreatureScript { -public: - npc_living_mojo() : CreatureScript("npc_living_mojo") { } + public: + npc_living_mojo() : CreatureScript("npc_living_mojo") + { + } struct npc_living_mojoAI : public ScriptedAI { @@ -449,26 +454,30 @@ class npc_living_mojo : public CreatureScript void UpdateAI(uint32 diff) override { - //Return since we have no target + // Return since we have no target if (!UpdateVictim()) return; if (mojoWaveTimer <= diff) { DoCastVictim(SPELL_MOJO_WAVE); - mojoWaveTimer = 15*IN_MILLISECONDS; - } else mojoWaveTimer -= diff; + mojoWaveTimer = 15 * IN_MILLISECONDS; + } + else + mojoWaveTimer -= diff; if (mojoPuddleTimer <= diff) { DoCastVictim(SPELL_MOJO_PUDDLE); - mojoPuddleTimer = 18*IN_MILLISECONDS; - } else mojoPuddleTimer -= diff; + mojoPuddleTimer = 18 * IN_MILLISECONDS; + } + else + mojoPuddleTimer -= diff; DoMeleeAttackIfReady(); } - private: + private: InstanceScript* instance; uint32 mojoWaveTimer; uint32 mojoPuddleTimer; diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp index 270311a3..c4ac2086 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp @@ -15,117 +15,117 @@ * with this program. If not, see . */ -#include "ScriptMgr.h" -#include "icecrown_citadel.h" #include "InstanceScript.h" #include "Map.h" #include "MotionMaster.h" #include "ObjectAccessor.h" #include "PassiveAI.h" #include "Player.h" +#include "ScriptMgr.h" #include "ScriptedCreature.h" #include "Spell.h" #include "SpellAuraEffects.h" #include "SpellScript.h" #include "TemporarySummon.h" +#include "icecrown_citadel.h" enum Texts { // Blood Queen Lana'Thel - SAY_INTRO_1 = 0, - SAY_INTRO_2 = 1, + SAY_INTRO_1 = 0, + SAY_INTRO_2 = 1, // Prince Keleseth - SAY_KELESETH_INVOCATION = 0, - EMOTE_KELESETH_INVOCATION = 1, - SAY_KELESETH_SPECIAL = 2, - SAY_KELESETH_KILL = 3, - EMOTE_KELESETH_BERSERK = 4, - SAY_KELESETH_DEATH = 5, + SAY_KELESETH_INVOCATION = 0, + EMOTE_KELESETH_INVOCATION = 1, + SAY_KELESETH_SPECIAL = 2, + SAY_KELESETH_KILL = 3, + EMOTE_KELESETH_BERSERK = 4, + SAY_KELESETH_DEATH = 5, // Prince Taldaram - SAY_TALDARAM_INVOCATION = 0, - EMOTE_TALDARAM_INVOCATION = 1, - SAY_TALDARAM_SPECIAL = 2, - EMOTE_TALDARAM_FLAME = 3, - SAY_TALDARAM_KILL = 4, - EMOTE_TALDARAM_BERSERK = 5, - EMOTE_TALDARAM_DEATH = 6, + SAY_TALDARAM_INVOCATION = 0, + EMOTE_TALDARAM_INVOCATION = 1, + SAY_TALDARAM_SPECIAL = 2, + EMOTE_TALDARAM_FLAME = 3, + SAY_TALDARAM_KILL = 4, + EMOTE_TALDARAM_BERSERK = 5, + EMOTE_TALDARAM_DEATH = 6, // Prince Valanar - SAY_VALANAR_INVOCATION = 0, - EMOTE_VALANAR_INVOCATION = 1, - SAY_VALANAR_SPECIAL = 2, - EMOTE_VALANAR_SHOCK_VORTEX = 3, - SAY_VALANAR_KILL = 4, - SAY_VALANAR_BERSERK = 5, - SAY_VALANAR_DEATH = 6 + SAY_VALANAR_INVOCATION = 0, + EMOTE_VALANAR_INVOCATION = 1, + SAY_VALANAR_SPECIAL = 2, + EMOTE_VALANAR_SHOCK_VORTEX = 3, + SAY_VALANAR_KILL = 4, + SAY_VALANAR_BERSERK = 5, + SAY_VALANAR_DEATH = 6 }; enum Spells { - SPELL_FEIGN_DEATH = 71598, - SPELL_OOC_INVOCATION_VISUAL = 70934, - SPELL_INVOCATION_VISUAL_ACTIVE = 71596, + SPELL_FEIGN_DEATH = 71598, + SPELL_OOC_INVOCATION_VISUAL = 70934, + SPELL_INVOCATION_VISUAL_ACTIVE = 71596, // Heroic mode - SPELL_SHADOW_PRISON = 72998, - SPELL_SHADOW_PRISON_DAMAGE = 72999, - SPELL_SHADOW_PRISON_DUMMY = 73001, + SPELL_SHADOW_PRISON = 72998, + SPELL_SHADOW_PRISON_DAMAGE = 72999, + SPELL_SHADOW_PRISON_DUMMY = 73001, // Prince Keleseth - SPELL_INVOCATION_OF_BLOOD_KELESETH = 70981, - SPELL_SHADOW_RESONANCE = 71943, - SPELL_SHADOW_LANCE = 71405, - SPELL_EMPOWERED_SHADOW_LANCE = 71815, + SPELL_INVOCATION_OF_BLOOD_KELESETH = 70981, + SPELL_SHADOW_RESONANCE = 71943, + SPELL_SHADOW_LANCE = 71405, + SPELL_EMPOWERED_SHADOW_LANCE = 71815, // Dark Nucleus - SPELL_SHADOW_RESONANCE_AURA = 72980, - SPELL_SHADOW_RESONANCE_RESIST = 71822, + SPELL_SHADOW_RESONANCE_AURA = 72980, + SPELL_SHADOW_RESONANCE_RESIST = 71822, // Prince Taldaram - SPELL_INVOCATION_OF_BLOOD_TALDARAM = 70982, - SPELL_GLITTERING_SPARKS = 71806, - SPELL_CONJURE_FLAME = 71718, - SPELL_CONJURE_EMPOWERED_FLAME = 72040, + SPELL_INVOCATION_OF_BLOOD_TALDARAM = 70982, + SPELL_GLITTERING_SPARKS = 71806, + SPELL_CONJURE_FLAME = 71718, + SPELL_CONJURE_EMPOWERED_FLAME = 72040, // Ball of Flame - SPELL_FLAME_SPHERE_SPAWN_EFFECT = 55891, // cast from creature_template_addon (needed cast before entering world) - SPELL_BALL_OF_FLAMES_VISUAL = 71706, - SPELL_BALL_OF_FLAMES = 71714, - SPELL_FLAMES = 71393, - SPELL_FLAME_SPHERE_DEATH_EFFECT = 55947, + SPELL_FLAME_SPHERE_SPAWN_EFFECT = 55891, // cast from creature_template_addon (needed cast before entering world) + SPELL_BALL_OF_FLAMES_VISUAL = 71706, + SPELL_BALL_OF_FLAMES = 71714, + SPELL_FLAMES = 71393, + SPELL_FLAME_SPHERE_DEATH_EFFECT = 55947, // Ball of Inferno Flame - SPELL_BALL_OF_FLAMES_PROC = 71756, - SPELL_BALL_OF_FLAMES_PERIODIC = 71709, + SPELL_BALL_OF_FLAMES_PROC = 71756, + SPELL_BALL_OF_FLAMES_PERIODIC = 71709, // Prince Valanar - SPELL_INVOCATION_OF_BLOOD_VALANAR = 70952, - SPELL_KINETIC_BOMB_TARGET = 72053, - SPELL_KINETIC_BOMB = 72080, - SPELL_SHOCK_VORTEX = 72037, - SPELL_EMPOWERED_SHOCK_VORTEX = 72039, + SPELL_INVOCATION_OF_BLOOD_VALANAR = 70952, + SPELL_KINETIC_BOMB_TARGET = 72053, + SPELL_KINETIC_BOMB = 72080, + SPELL_SHOCK_VORTEX = 72037, + SPELL_EMPOWERED_SHOCK_VORTEX = 72039, // Kinetic Bomb - SPELL_UNSTABLE = 72059, - SPELL_KINETIC_BOMB_VISUAL = 72054, - SPELL_KINETIC_BOMB_EXPLOSION = 72052, - SPELL_KINETIC_BOMB_KNOCKBACK = 72087, + SPELL_UNSTABLE = 72059, + SPELL_KINETIC_BOMB_VISUAL = 72054, + SPELL_KINETIC_BOMB_EXPLOSION = 72052, + SPELL_KINETIC_BOMB_KNOCKBACK = 72087, // Shock Vortex - SPELL_SHOCK_VORTEX_PERIODIC = 71945, - SPELL_SHOCK_VORTEX_DUMMY = 72633, + SPELL_SHOCK_VORTEX_PERIODIC = 71945, + SPELL_SHOCK_VORTEX_DUMMY = 72633, // Visual Spells - SPELL_INVOCATION_VISUAL_VALANAR = 71070, - SPELL_INVOCATION_VISUAL_TALDARAM = 71081, - SPELL_INVOCATION_VISUAL_KELESETH = 71080 + SPELL_INVOCATION_VISUAL_VALANAR = 71070, + SPELL_INVOCATION_VISUAL_TALDARAM = 71081, + SPELL_INVOCATION_VISUAL_KELESETH = 71080 }; enum Events { - EVENT_INTRO_1 = 1, + EVENT_INTRO_1 = 1, EVENT_INTRO_2, EVENT_INVOCATION_OF_BLOOD, @@ -148,7 +148,7 @@ enum Events enum Actions { - ACTION_START_INTRO = 1, + ACTION_START_INTRO = 1, ACTION_INTRO_DONE, ACTION_STAND_UP, ACTION_CAST_INVOCATION, @@ -159,282 +159,285 @@ enum Actions enum Points { - POINT_INTRO_DESPAWN = 380040, - POINT_KINETIC_BOMB_IMPACT = 384540 + POINT_INTRO_DESPAWN = 380040, + POINT_KINETIC_BOMB_IMPACT = 384540 }; enum Misc { - DISPLAY_KINETIC_BOMB = 31095, - SUMMON_PRINCES_GROUP = 1, - DATA_INTRO = 2, - DATA_INTRO_DONE = 3, - DATA_PRINCE_EVADE = 4 + DISPLAY_KINETIC_BOMB = 31095, + SUMMON_PRINCES_GROUP = 1, + DATA_INTRO = 2, + DATA_INTRO_DONE = 3, + DATA_PRINCE_EVADE = 4 }; class StandUpEvent : public BasicEvent { - public: - StandUpEvent(Creature* owner) : BasicEvent(), _owner(owner) { } + public: + StandUpEvent(Creature* owner) : BasicEvent(), _owner(owner) + { + } - bool Execute(uint64 /*eventTime*/, uint32 /*diff*/) override - { - _owner->HandleEmoteCommand(EMOTE_ONESHOT_ROAR); - _owner->SetReactState(REACT_AGGRESSIVE); - return true; - } + bool Execute(uint64 /*eventTime*/, uint32 /*diff*/) override + { + _owner->HandleEmoteCommand(EMOTE_ONESHOT_ROAR); + _owner->SetReactState(REACT_AGGRESSIVE); + return true; + } - private: - Creature* _owner; + private: + Creature* _owner; }; class VortexEvent : public BasicEvent { -public: - VortexEvent(Creature* owner) : _owner(owner) { } + public: + VortexEvent(Creature* owner) : _owner(owner) + { + } - bool Execute(uint64 /*eventTime*/, uint32 /*diff*/) override - { - _owner->CastSpell(_owner, SPELL_SHOCK_VORTEX_PERIODIC, true); - return true; - } + bool Execute(uint64 /*eventTime*/, uint32 /*diff*/) override + { + _owner->CastSpell(_owner, SPELL_SHOCK_VORTEX_PERIODIC, true); + return true; + } -private: + private: Creature* _owner; }; Position const introFinalPos = {4660.490f, 2769.200f, 430.0000f, 0.000000f}; -Position const triggerPos = {4680.231f, 2769.134f, 379.9256f, 3.121708f}; +Position const triggerPos = {4680.231f, 2769.134f, 379.9256f, 3.121708f}; Position const triggerEndPos = {4680.180f, 2769.150f, 365.5000f, 3.121708f}; -uint32 const PrincesData[] = -{ - DATA_PRINCE_KELESETH, - DATA_PRINCE_TALDARAM, - DATA_PRINCE_VALANAR -}; +uint32 const PrincesData[] = {DATA_PRINCE_KELESETH, DATA_PRINCE_TALDARAM, DATA_PRINCE_VALANAR}; class boss_blood_council_controller : public CreatureScript { - public: - boss_blood_council_controller() : CreatureScript("boss_blood_council_controller") { } + public: + boss_blood_council_controller() : CreatureScript("boss_blood_council_controller") + { + } - struct boss_blood_council_controllerAI : public BossAI + struct boss_blood_council_controllerAI : public BossAI + { + boss_blood_council_controllerAI(Creature* creature) : BossAI(creature, DATA_BLOOD_PRINCE_COUNCIL) { - boss_blood_council_controllerAI(Creature* creature) : BossAI(creature, DATA_BLOOD_PRINCE_COUNCIL) - { - Initialize(); - SetCombatMovement(false); - } + Initialize(); + SetCombatMovement(false); + } - void Initialize() - { - _invocationStage = 0; - _resetCounter = 0; - } + void Initialize() + { + _invocationStage = 0; + _resetCounter = 0; + } - void Reset() override - { - _Reset(); - Initialize(); - me->SummonCreatureGroup(SUMMON_PRINCES_GROUP); - - if (!instance->GetData(DATA_BLOOD_PRINCE_COUNCIL_INTRO)) - for (uint32 bossData : PrincesData) - if (Creature* prince = ObjectAccessor::GetCreature(*me, instance->GetGuidData(bossData))) - { - prince->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - prince->SetImmuneToPC(false); - if (bossData == DATA_PRINCE_VALANAR) - prince->SetHealth(prince->GetMaxHealth()); - } - } + void Reset() override + { + _Reset(); + Initialize(); + me->SummonCreatureGroup(SUMMON_PRINCES_GROUP); - void EnterEvadeMode(EvadeReason /*why*/) override - { + if (!instance->GetData(DATA_BLOOD_PRINCE_COUNCIL_INTRO)) for (uint32 bossData : PrincesData) if (Creature* prince = ObjectAccessor::GetCreature(*me, instance->GetGuidData(bossData))) - instance->SendEncounterUnit(ENCOUNTER_FRAME_DISENGAGE, prince); + { + prince->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + prince->SetImmuneToPC(false); + if (bossData == DATA_PRINCE_VALANAR) + prince->SetHealth(prince->GetMaxHealth()); + } + } - summons.DespawnAll(); - _DespawnAtEvade(); - } + void EnterEvadeMode(EvadeReason /*why*/) override + { + for (uint32 bossData : PrincesData) + if (Creature* prince = ObjectAccessor::GetCreature(*me, instance->GetGuidData(bossData))) + instance->SendEncounterUnit(ENCOUNTER_FRAME_DISENGAGE, prince); + + summons.DespawnAll(); + _DespawnAtEvade(); + } - void JustEngagedWith(Unit* who) override + void JustEngagedWith(Unit* who) override + { + if (instance->GetBossState(DATA_BLOOD_PRINCE_COUNCIL) == IN_PROGRESS) + return; + + if (!instance->CheckRequiredBosses(DATA_BLOOD_PRINCE_COUNCIL, who->ToPlayer())) { - if (instance->GetBossState(DATA_BLOOD_PRINCE_COUNCIL) == IN_PROGRESS) - return; + EnterEvadeMode(EVADE_REASON_SEQUENCE_BREAK); + instance->DoCastSpellOnPlayers(LIGHT_S_HAMMER_TELEPORT); + return; + } - if (!instance->CheckRequiredBosses(DATA_BLOOD_PRINCE_COUNCIL, who->ToPlayer())) + me->SetCombatPulseDelay(5); + me->setActive(true); + DoZoneInCombat(); + instance->SetBossState(DATA_BLOOD_PRINCE_COUNCIL, IN_PROGRESS); + + DoCastSelf(SPELL_INVOCATION_OF_BLOOD_VALANAR); + + for (uint32 bossData : PrincesData) + if (Creature* prince = ObjectAccessor::GetCreature(*me, instance->GetGuidData(bossData))) { - EnterEvadeMode(EVADE_REASON_SEQUENCE_BREAK); - instance->DoCastSpellOnPlayers(LIGHT_S_HAMMER_TELEPORT); - return; + instance->SendEncounterUnit(ENCOUNTER_FRAME_ENGAGE, prince); + DoZoneInCombat(prince); } - me->SetCombatPulseDelay(5); - me->setActive(true); - DoZoneInCombat(); - instance->SetBossState(DATA_BLOOD_PRINCE_COUNCIL, IN_PROGRESS); + events.ScheduleEvent(EVENT_INVOCATION_OF_BLOOD, Seconds(46) + Milliseconds(500)); - DoCastSelf(SPELL_INVOCATION_OF_BLOOD_VALANAR); + _invocationOrder[0] = InvocationData(instance->GetGuidData(DATA_PRINCE_VALANAR), SPELL_INVOCATION_OF_BLOOD_VALANAR, EMOTE_VALANAR_INVOCATION, SPELL_INVOCATION_VISUAL_VALANAR); + if (roll_chance_i(50)) + { + _invocationOrder[1] = InvocationData(instance->GetGuidData(DATA_PRINCE_TALDARAM), SPELL_INVOCATION_OF_BLOOD_TALDARAM, EMOTE_TALDARAM_INVOCATION, SPELL_INVOCATION_VISUAL_TALDARAM); + _invocationOrder[2] = InvocationData(instance->GetGuidData(DATA_PRINCE_KELESETH), SPELL_INVOCATION_OF_BLOOD_KELESETH, EMOTE_KELESETH_INVOCATION, SPELL_INVOCATION_VISUAL_KELESETH); + } + else + { + _invocationOrder[1] = InvocationData(instance->GetGuidData(DATA_PRINCE_KELESETH), SPELL_INVOCATION_OF_BLOOD_KELESETH, EMOTE_KELESETH_INVOCATION, SPELL_INVOCATION_VISUAL_KELESETH); + _invocationOrder[2] = InvocationData(instance->GetGuidData(DATA_PRINCE_TALDARAM), SPELL_INVOCATION_OF_BLOOD_TALDARAM, EMOTE_TALDARAM_INVOCATION, SPELL_INVOCATION_VISUAL_TALDARAM); + } + } - for (uint32 bossData : PrincesData) - if (Creature* prince = ObjectAccessor::GetCreature(*me, instance->GetGuidData(bossData))) - { - instance->SendEncounterUnit(ENCOUNTER_FRAME_ENGAGE, prince); - DoZoneInCombat(prince); - } + void SetData(uint32 /*type*/, uint32 data) override + { + _resetCounter += uint8(data); + if (_resetCounter == 3) + EnterEvadeMode(EVADE_REASON_OTHER); + } - events.ScheduleEvent(EVENT_INVOCATION_OF_BLOOD, Seconds(46) + Milliseconds(500)); + uint32 GetData(uint32 data) const override + { + if (data == DATA_INTRO && !instance->GetData(DATA_BLOOD_PRINCE_COUNCIL_INTRO)) + return DATA_INTRO_DONE; + return 0; + } - _invocationOrder[0] = InvocationData(instance->GetGuidData(DATA_PRINCE_VALANAR), SPELL_INVOCATION_OF_BLOOD_VALANAR, EMOTE_VALANAR_INVOCATION, SPELL_INVOCATION_VISUAL_VALANAR); - if (roll_chance_i(50)) - { - _invocationOrder[1] = InvocationData(instance->GetGuidData(DATA_PRINCE_TALDARAM), SPELL_INVOCATION_OF_BLOOD_TALDARAM, EMOTE_TALDARAM_INVOCATION, SPELL_INVOCATION_VISUAL_TALDARAM); - _invocationOrder[2] = InvocationData(instance->GetGuidData(DATA_PRINCE_KELESETH), SPELL_INVOCATION_OF_BLOOD_KELESETH, EMOTE_KELESETH_INVOCATION, SPELL_INVOCATION_VISUAL_KELESETH); - } - else + void JustDied(Unit* killer) override + { + events.Reset(); + instance->SetBossState(DATA_BLOOD_PRINCE_COUNCIL, DONE); + // Kill all prices + for (uint8 i = 0; i < 3; ++i) + { + if (++_invocationStage == 3) + _invocationStage = 0; + + if (Creature* prince = ObjectAccessor::GetCreature(*me, _invocationOrder[_invocationStage].guid)) { - _invocationOrder[1] = InvocationData(instance->GetGuidData(DATA_PRINCE_KELESETH), SPELL_INVOCATION_OF_BLOOD_KELESETH, EMOTE_KELESETH_INVOCATION, SPELL_INVOCATION_VISUAL_KELESETH); - _invocationOrder[2] = InvocationData(instance->GetGuidData(DATA_PRINCE_TALDARAM), SPELL_INVOCATION_OF_BLOOD_TALDARAM, EMOTE_TALDARAM_INVOCATION, SPELL_INVOCATION_VISUAL_TALDARAM); + // Make sure looting is allowed + if (me->IsDamageEnoughForLootingAndReward()) + prince->LowerPlayerDamageReq(prince->GetMaxHealth()); + Unit::Kill(killer, prince); } } + } - void SetData(uint32 /*type*/, uint32 data) override + void DoAction(int32 actionId) override + { + if (actionId == ACTION_START_INTRO && instance->GetData(DATA_BLOOD_PRINCE_COUNCIL_INTRO) && instance->GetBossState(DATA_BLOOD_PRINCE_COUNCIL) != DONE) { - _resetCounter += uint8(data); - if (_resetCounter == 3) - EnterEvadeMode(EVADE_REASON_OTHER); + instance->SetData(DATA_BLOOD_PRINCE_COUNCIL_INTRO, 0); + if (Creature* bloodQueen = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_BLOOD_QUEEN_LANA_THEL_COUNCIL))) + bloodQueen->AI()->DoAction(ACTION_START_INTRO); } - - uint32 GetData(uint32 data) const override + else if (actionId == ACTION_INTRO_DONE) { - if (data == DATA_INTRO && !instance->GetData(DATA_BLOOD_PRINCE_COUNCIL_INTRO)) - return DATA_INTRO_DONE; - return 0; + // Remove feigh death from princes + for (uint32 bossData : PrincesData) + if (Creature* prince = ObjectAccessor::GetCreature(*me, instance->GetGuidData(bossData))) + { + prince->AI()->DoAction(ACTION_STAND_UP); + if (bossData == DATA_PRINCE_VALANAR) + prince->SetHealth(prince->GetMaxHealth()); + } } + } + + void UpdateAI(uint32 diff) override + { + if (!UpdateVictim()) + return; + + events.Update(diff); - void JustDied(Unit* killer) override + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; + + while (uint32 eventId = events.ExecuteEvent()) { - events.Reset(); - instance->SetBossState(DATA_BLOOD_PRINCE_COUNCIL, DONE); - // Kill all prices - for (uint8 i = 0; i < 3; ++i) + switch (eventId) + { + case EVENT_INVOCATION_OF_BLOOD: { + Creature* oldPrince = ObjectAccessor::GetCreature(*me, _invocationOrder[_invocationStage].guid); if (++_invocationStage == 3) _invocationStage = 0; - if (Creature* prince = ObjectAccessor::GetCreature(*me, _invocationOrder[_invocationStage].guid)) + Creature* newPrince = ObjectAccessor::GetCreature(*me, _invocationOrder[_invocationStage].guid); + if (oldPrince) { - // Make sure looting is allowed - if (me->IsDamageEnoughForLootingAndReward()) - prince->LowerPlayerDamageReq(prince->GetMaxHealth()); - killer->Kill(prince); + oldPrince->AI()->DoAction(ACTION_REMOVE_INVOCATION); + if (newPrince) + oldPrince->CastSpell(newPrince, _invocationOrder[_invocationStage].visualSpell, true); } - } - } - void DoAction(int32 actionId) override - { - if (actionId == ACTION_START_INTRO && instance->GetData(DATA_BLOOD_PRINCE_COUNCIL_INTRO) && instance->GetBossState(DATA_BLOOD_PRINCE_COUNCIL) != DONE) - { - instance->SetData(DATA_BLOOD_PRINCE_COUNCIL_INTRO, 0); - if (Creature* bloodQueen = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_BLOOD_QUEEN_LANA_THEL_COUNCIL))) - bloodQueen->AI()->DoAction(ACTION_START_INTRO); + if (newPrince) + { + newPrince->SetHealth(me->GetHealth()); + newPrince->AI()->Talk(uint8(_invocationOrder[_invocationStage].textId)); + } + + DoCastSelf(_invocationOrder[_invocationStage].spellId); + events.Repeat(Seconds(46) + Milliseconds(500)); + break; } - else if (actionId == ACTION_INTRO_DONE) - { - // Remove feigh death from princes - for (uint32 bossData : PrincesData) - if (Creature* prince = ObjectAccessor::GetCreature(*me, instance->GetGuidData(bossData))) - { - prince->AI()->DoAction(ACTION_STAND_UP); - if (bossData == DATA_PRINCE_VALANAR) - prince->SetHealth(prince->GetMaxHealth()); - } + default: + break; } - } - - void UpdateAI(uint32 diff) override - { - if (!UpdateVictim()) - return; - - events.Update(diff); if (me->HasUnitState(UNIT_STATE_CASTING)) return; + } + } - while (uint32 eventId = events.ExecuteEvent()) - { - switch (eventId) - { - case EVENT_INVOCATION_OF_BLOOD: - { - Creature* oldPrince = ObjectAccessor::GetCreature(*me, _invocationOrder[_invocationStage].guid); - if (++_invocationStage == 3) - _invocationStage = 0; - - Creature* newPrince = ObjectAccessor::GetCreature(*me, _invocationOrder[_invocationStage].guid); - if (oldPrince) - { - oldPrince->AI()->DoAction(ACTION_REMOVE_INVOCATION); - if (newPrince) - oldPrince->CastSpell(newPrince, _invocationOrder[_invocationStage].visualSpell, true); - } - - if (newPrince) - { - newPrince->SetHealth(me->GetHealth()); - newPrince->AI()->Talk(uint8(_invocationOrder[_invocationStage].textId)); - } - - DoCastSelf(_invocationOrder[_invocationStage].spellId); - events.Repeat(Seconds(46) + Milliseconds(500)); - break; - } - default: - break; - } + private: + struct InvocationData + { + ObjectGuid guid; + uint32 spellId; + uint32 textId; + uint32 visualSpell; - if (me->HasUnitState(UNIT_STATE_CASTING)) - return; - } + InvocationData(ObjectGuid _guid, uint32 _spellId, uint32 _textId, uint32 _visualSpell) + { + guid = _guid; + spellId = _spellId; + textId = _textId; + visualSpell = _visualSpell; } - private: - struct InvocationData + InvocationData() : spellId(0), textId(0), visualSpell(0) { - ObjectGuid guid; - uint32 spellId; - uint32 textId; - uint32 visualSpell; - - InvocationData(ObjectGuid _guid, uint32 _spellId, uint32 _textId, uint32 _visualSpell) - { - guid = _guid; - spellId = _spellId; - textId = _textId; - visualSpell = _visualSpell; - } - - InvocationData() : spellId(0), textId(0), visualSpell(0) { } - } _invocationOrder[3]; + } + } _invocationOrder[3]; - uint32 _invocationStage; - uint32 _resetCounter; - }; + uint32 _invocationStage; + uint32 _resetCounter; + }; - CreatureAI* GetAI(Creature* creature) const override - { - return GetIcecrownCitadelAI(creature); - } + CreatureAI* GetAI(Creature* creature) const override + { + return GetIcecrownCitadelAI(creature); + } }; struct BloodPrincesBossAI : public BossAI { - BloodPrincesBossAI(Creature* creature, uint32 bossId) : BossAI(creature, bossId), _spawnHealth (creature->GetMaxHealth()), _isEmpowered(false) + BloodPrincesBossAI(Creature* creature, uint32 bossId) : BossAI(creature, bossId), _spawnHealth(creature->GetMaxHealth()), _isEmpowered(false) { SetBoundary(instance->GetBossBoundary(DATA_BLOOD_PRINCE_COUNCIL)); } @@ -477,17 +480,17 @@ struct BloodPrincesBossAI : public BossAI switch (me->GetEntry()) { - case NPC_PRINCE_KELESETH: - Talk(SAY_KELESETH_DEATH); - break; - case NPC_PRINCE_TALDARAM: - Talk(EMOTE_TALDARAM_DEATH); - break; - case NPC_PRINCE_VALANAR: - Talk(SAY_VALANAR_DEATH); - break; - default: - break; + case NPC_PRINCE_KELESETH: + Talk(SAY_KELESETH_DEATH); + break; + case NPC_PRINCE_TALDARAM: + Talk(EMOTE_TALDARAM_DEATH); + break; + case NPC_PRINCE_VALANAR: + Talk(SAY_VALANAR_DEATH); + break; + default: + break; } } @@ -514,17 +517,17 @@ struct BloodPrincesBossAI : public BossAI if (victim->GetTypeId() == TYPEID_PLAYER) switch (me->GetEntry()) { - case NPC_PRINCE_KELESETH: - Talk(SAY_KELESETH_KILL); - break; - case NPC_PRINCE_TALDARAM: - Talk(SAY_TALDARAM_KILL); - break; - case NPC_PRINCE_VALANAR: - Talk(SAY_VALANAR_KILL); - break; - default: - break; + case NPC_PRINCE_KELESETH: + Talk(SAY_KELESETH_KILL); + break; + case NPC_PRINCE_TALDARAM: + Talk(SAY_TALDARAM_KILL); + break; + case NPC_PRINCE_VALANAR: + Talk(SAY_VALANAR_KILL); + break; + default: + break; } } @@ -559,28 +562,28 @@ struct BloodPrincesBossAI : public BossAI { switch (action) { - case ACTION_STAND_UP: - me->RemoveAurasDueToSpell(SPELL_FEIGN_DEATH); - me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - me->SetImmuneToPC(false); - me->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_DEAD); - me->RemoveFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FEIGN_DEATH); - me->ForceValuesUpdateAtIndex(UNIT_NPC_FLAGS); // was in sniff. don't ask why - me->m_Events.AddEvent(new StandUpEvent(me), me->m_Events.CalculateTime(1000)); - break; - case ACTION_CAST_INVOCATION: - Talk(SelectInvocationSay()); - DoCastSelf(SPELL_INVOCATION_VISUAL_ACTIVE, true); - _isEmpowered = true; - break; - case ACTION_REMOVE_INVOCATION: - me->SetHealth(_spawnHealth); - me->RemoveAurasDueToSpell(SPELL_INVOCATION_VISUAL_ACTIVE); - me->RemoveAurasDueToSpell(SelectInvocationSpell()); - _isEmpowered = false; - break; - default: - break; + case ACTION_STAND_UP: + me->RemoveAurasDueToSpell(SPELL_FEIGN_DEATH); + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + me->SetImmuneToPC(false); + me->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_DEAD); + me->RemoveFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FEIGN_DEATH); + me->ForceValuesUpdateAtIndex(UNIT_NPC_FLAGS); // was in sniff. don't ask why + me->m_Events.AddEvent(new StandUpEvent(me), me->m_Events.CalculateTime(1000)); + break; + case ACTION_CAST_INVOCATION: + Talk(SelectInvocationSay()); + DoCastSelf(SPELL_INVOCATION_VISUAL_ACTIVE, true); + _isEmpowered = true; + break; + case ACTION_REMOVE_INVOCATION: + me->SetHealth(_spawnHealth); + me->RemoveAurasDueToSpell(SPELL_INVOCATION_VISUAL_ACTIVE); + me->RemoveAurasDueToSpell(SelectInvocationSpell()); + _isEmpowered = false; + break; + default: + break; } } @@ -588,14 +591,14 @@ struct BloodPrincesBossAI : public BossAI { switch (me->GetEntry()) { - case NPC_PRINCE_KELESETH: - return SAY_KELESETH_INVOCATION; - case NPC_PRINCE_TALDARAM: - return SAY_TALDARAM_INVOCATION; - case NPC_PRINCE_VALANAR: - return SAY_KELESETH_INVOCATION; - default: // Should never happen - return 0; + case NPC_PRINCE_KELESETH: + return SAY_KELESETH_INVOCATION; + case NPC_PRINCE_TALDARAM: + return SAY_TALDARAM_INVOCATION; + case NPC_PRINCE_VALANAR: + return SAY_KELESETH_INVOCATION; + default: // Should never happen + return 0; } } @@ -603,529 +606,555 @@ struct BloodPrincesBossAI : public BossAI { switch (me->GetEntry()) { - case NPC_PRINCE_KELESETH: - return SPELL_INVOCATION_OF_BLOOD_KELESETH; - case NPC_PRINCE_TALDARAM: - return SPELL_INVOCATION_OF_BLOOD_TALDARAM; - case NPC_PRINCE_VALANAR: - return SPELL_INVOCATION_OF_BLOOD_VALANAR; - default: // Should never happen - return 0; + case NPC_PRINCE_KELESETH: + return SPELL_INVOCATION_OF_BLOOD_KELESETH; + case NPC_PRINCE_TALDARAM: + return SPELL_INVOCATION_OF_BLOOD_TALDARAM; + case NPC_PRINCE_VALANAR: + return SPELL_INVOCATION_OF_BLOOD_VALANAR; + default: // Should never happen + return 0; } } -protected: + protected: uint32 _spawnHealth; bool _isEmpowered; }; class boss_prince_keleseth_icc : public CreatureScript { - public: - boss_prince_keleseth_icc() : CreatureScript("boss_prince_keleseth_icc") { } + public: + boss_prince_keleseth_icc() : CreatureScript("boss_prince_keleseth_icc") + { + } - struct boss_prince_kelesethAI : public BloodPrincesBossAI + struct boss_prince_kelesethAI : public BloodPrincesBossAI + { + boss_prince_kelesethAI(Creature* creature) : BloodPrincesBossAI(creature, DATA_PRINCE_KELESETH) { - boss_prince_kelesethAI(Creature* creature) : BloodPrincesBossAI(creature, DATA_PRINCE_KELESETH) { } - - void ScheduleEvents() override - { - events.ScheduleEvent(EVENT_BERSERK, Minutes(10)); - events.ScheduleEvent(EVENT_SHADOW_RESONANCE, Seconds(10), Seconds(15)); - events.ScheduleEvent(EVENT_SHADOW_LANCE, Seconds(2)); + } - if (IsHeroic()) - { - DoCastSelf(SPELL_SHADOW_PRISON, true); - DoCastSelf(SPELL_SHADOW_PRISON_DUMMY); - } - } + void ScheduleEvents() override + { + events.ScheduleEvent(EVENT_BERSERK, Minutes(10)); + events.ScheduleEvent(EVENT_SHADOW_RESONANCE, Seconds(10), Seconds(15)); + events.ScheduleEvent(EVENT_SHADOW_LANCE, Seconds(2)); - void JustSummoned(Creature* summon) override + if (IsHeroic()) { - summons.Summon(summon); - Position pos = me->GetPosition(); - float maxRange = me->GetDistance2d(summon); - float angle = me->GetAngle(summon); - me->MovePositionToFirstCollision(pos, maxRange, angle); - summon->NearTeleportTo(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation()); - summon->ToTempSummon()->SetTempSummonType(TEMPSUMMON_CORPSE_DESPAWN); + DoCastSelf(SPELL_SHADOW_PRISON, true); + DoCastSelf(SPELL_SHADOW_PRISON_DUMMY); } + } - void UpdateAI(uint32 diff) override - { - if (!UpdateVictim()) - return; + void JustSummoned(Creature* summon) override + { + summons.Summon(summon); + Position pos = me->GetPosition(); + float maxRange = me->GetDistance2d(summon); + float angle = me->GetAngle(summon); + me->MovePositionToFirstCollision(pos, maxRange, angle); + summon->NearTeleportTo(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation()); + summon->ToTempSummon()->SetTempSummonType(TEMPSUMMON_CORPSE_DESPAWN); + } - events.Update(diff); + void UpdateAI(uint32 diff) override + { + if (!UpdateVictim()) + return; - if (me->HasUnitState(UNIT_STATE_CASTING)) - return; + events.Update(diff); - while (uint32 eventId = events.ExecuteEvent()) - { - switch (eventId) - { - case EVENT_BERSERK: - DoCastSelf(SPELL_BERSERK); - Talk(EMOTE_KELESETH_BERSERK); - break; - case EVENT_SHADOW_RESONANCE: - Talk(SAY_KELESETH_SPECIAL); - DoCastSelf(SPELL_SHADOW_RESONANCE); - events.Repeat(Seconds(10), Seconds(15)); - break; - case EVENT_SHADOW_LANCE: - _isEmpowered ? DoCastVictim(SPELL_EMPOWERED_SHADOW_LANCE) : DoCastVictim(SPELL_SHADOW_LANCE); - events.Repeat(Seconds(2)); - break; - default: - break; - } + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; - if (me->HasUnitState(UNIT_STATE_CASTING)) - return; + while (uint32 eventId = events.ExecuteEvent()) + { + switch (eventId) + { + case EVENT_BERSERK: + DoCastSelf(SPELL_BERSERK); + Talk(EMOTE_KELESETH_BERSERK); + break; + case EVENT_SHADOW_RESONANCE: + Talk(SAY_KELESETH_SPECIAL); + DoCastSelf(SPELL_SHADOW_RESONANCE); + events.Repeat(Seconds(10), Seconds(15)); + break; + case EVENT_SHADOW_LANCE: + _isEmpowered ? DoCastVictim(SPELL_EMPOWERED_SHADOW_LANCE) : DoCastVictim(SPELL_SHADOW_LANCE); + events.Repeat(Seconds(2)); + break; + default: + break; } - // does not melee + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; } - }; - CreatureAI* GetAI(Creature* creature) const override - { - return GetIcecrownCitadelAI(creature); + // does not melee } + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return GetIcecrownCitadelAI(creature); + } }; class boss_prince_taldaram_icc : public CreatureScript { - public: - boss_prince_taldaram_icc() : CreatureScript("boss_prince_taldaram_icc") { } + public: + boss_prince_taldaram_icc() : CreatureScript("boss_prince_taldaram_icc") + { + } - struct boss_prince_taldaramAI : public BloodPrincesBossAI + struct boss_prince_taldaramAI : public BloodPrincesBossAI + { + boss_prince_taldaramAI(Creature* creature) : BloodPrincesBossAI(creature, DATA_PRINCE_TALDARAM) { - boss_prince_taldaramAI(Creature* creature) : BloodPrincesBossAI(creature, DATA_PRINCE_TALDARAM) { } + } - void ScheduleEvents() override - { - events.ScheduleEvent(EVENT_BERSERK, Minutes(10)); - events.ScheduleEvent(EVENT_GLITTERING_SPARKS, Seconds(12), Seconds(15)); - events.ScheduleEvent(EVENT_CONJURE_FLAME, Seconds(20)); - if (IsHeroic()) - DoCastSelf(SPELL_SHADOW_PRISON, true); - } + void ScheduleEvents() override + { + events.ScheduleEvent(EVENT_BERSERK, Minutes(10)); + events.ScheduleEvent(EVENT_GLITTERING_SPARKS, Seconds(12), Seconds(15)); + events.ScheduleEvent(EVENT_CONJURE_FLAME, Seconds(20)); + if (IsHeroic()) + DoCastSelf(SPELL_SHADOW_PRISON, true); + } - void JustSummoned(Creature* summon) override - { - summons.Summon(summon); - Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1, -10.0f, true); // first try at distance - if (!target) - target = SelectTarget(SELECT_TARGET_RANDOM, 0, 0.0f, true); // too bad for you raiders, its going to boom + void JustSummoned(Creature* summon) override + { + summons.Summon(summon); + Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1, -10.0f, true); // first try at distance + if (!target) + target = SelectTarget(SELECT_TARGET_RANDOM, 0, 0.0f, true); // too bad for you raiders, its going to boom - if (summon->GetEntry() == NPC_BALL_OF_INFERNO_FLAME && target) - Talk(EMOTE_TALDARAM_FLAME, target); + if (summon->GetEntry() == NPC_BALL_OF_INFERNO_FLAME && target) + Talk(EMOTE_TALDARAM_FLAME, target); - if (target) - summon->AI()->SetGUID(target->GetGUID()); - } + if (target) + summon->AI()->SetGUID(target->GetGUID()); + } - void UpdateAI(uint32 diff) override - { - if (!UpdateVictim()) - return; + void UpdateAI(uint32 diff) override + { + if (!UpdateVictim()) + return; - events.Update(diff); + events.Update(diff); - if (me->HasUnitState(UNIT_STATE_CASTING)) - return; + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; - while (uint32 eventId = events.ExecuteEvent()) + while (uint32 eventId = events.ExecuteEvent()) + { + switch (eventId) { - switch (eventId) + case EVENT_BERSERK: + DoCastSelf(SPELL_BERSERK); + Talk(EMOTE_TALDARAM_BERSERK); + break; + case EVENT_GLITTERING_SPARKS: + DoCastVictim(SPELL_GLITTERING_SPARKS); + events.Repeat(Seconds(15), Seconds(50)); + break; + case EVENT_CONJURE_FLAME: + if (_isEmpowered) { - case EVENT_BERSERK: - DoCastSelf(SPELL_BERSERK); - Talk(EMOTE_TALDARAM_BERSERK); - break; - case EVENT_GLITTERING_SPARKS: - DoCastVictim(SPELL_GLITTERING_SPARKS); - events.Repeat(Seconds(15), Seconds(50)); - break; - case EVENT_CONJURE_FLAME: - if (_isEmpowered) - { - DoCastSelf(SPELL_CONJURE_EMPOWERED_FLAME); - events.Repeat(Seconds(15), Seconds(25)); - } - else - { - DoCastSelf(SPELL_CONJURE_FLAME); - events.Repeat(Seconds(20), Seconds(30)); - } - Talk(SAY_TALDARAM_SPECIAL); - break; - default: - break; + DoCastSelf(SPELL_CONJURE_EMPOWERED_FLAME); + events.Repeat(Seconds(15), Seconds(25)); } - - if (me->HasUnitState(UNIT_STATE_CASTING)) - return; + else + { + DoCastSelf(SPELL_CONJURE_FLAME); + events.Repeat(Seconds(20), Seconds(30)); + } + Talk(SAY_TALDARAM_SPECIAL); + break; + default: + break; } - DoMeleeAttackIfReady(); + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; } - }; - CreatureAI* GetAI(Creature* creature) const override - { - return GetIcecrownCitadelAI(creature); + DoMeleeAttackIfReady(); } + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return GetIcecrownCitadelAI(creature); + } }; class boss_prince_valanar_icc : public CreatureScript { - public: - boss_prince_valanar_icc() : CreatureScript("boss_prince_valanar_icc") { } + public: + boss_prince_valanar_icc() : CreatureScript("boss_prince_valanar_icc") + { + } - struct boss_prince_valanarAI : public BloodPrincesBossAI + struct boss_prince_valanarAI : public BloodPrincesBossAI + { + boss_prince_valanarAI(Creature* creature) : BloodPrincesBossAI(creature, DATA_PRINCE_VALANAR) { - boss_prince_valanarAI(Creature* creature) : BloodPrincesBossAI(creature, DATA_PRINCE_VALANAR) { } + } - void ScheduleEvents() override - { - events.ScheduleEvent(EVENT_BERSERK, Minutes(10)); - events.ScheduleEvent(EVENT_KINETIC_BOMB, Seconds(18), Seconds(24)); - events.ScheduleEvent(EVENT_SHOCK_VORTEX, Seconds(15), Seconds(20)); - if (IsHeroic()) - DoCastSelf(SPELL_SHADOW_PRISON, true); - } + void ScheduleEvents() override + { + events.ScheduleEvent(EVENT_BERSERK, Minutes(10)); + events.ScheduleEvent(EVENT_KINETIC_BOMB, Seconds(18), Seconds(24)); + events.ScheduleEvent(EVENT_SHOCK_VORTEX, Seconds(15), Seconds(20)); + if (IsHeroic()) + DoCastSelf(SPELL_SHADOW_PRISON, true); + } - void JustSummoned(Creature* summon) override + void JustSummoned(Creature* summon) override + { + switch (summon->GetEntry()) { - switch (summon->GetEntry()) - { - case NPC_KINETIC_BOMB_TARGET: - summon->SetReactState(REACT_PASSIVE); - summon->CastSpell(summon, SPELL_KINETIC_BOMB, me->GetGUID()); - break; - case NPC_KINETIC_BOMB: - { - float x, y, z; - summon->GetPosition(x, y, z); - float ground_Z = summon->GetMap()->GetHeight(summon->GetPhaseShift(), x, y, z, true, 500.0f); - summon->GetMotionMaster()->MovePoint(POINT_KINETIC_BOMB_IMPACT, x, y, ground_Z); - summon->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - break; - } - case NPC_SHOCK_VORTEX: - summon->CastSpell(summon, SPELL_SHOCK_VORTEX_DUMMY, true); - summon->m_Events.AddEvent(new VortexEvent(summon), summon->m_Events.CalculateTime(5000)); - break; - default: - break; - } - - summons.Summon(summon); - if (me->IsInCombat()) - DoZoneInCombat(summon); + case NPC_KINETIC_BOMB_TARGET: + summon->SetReactState(REACT_PASSIVE); + summon->CastSpell(summon, SPELL_KINETIC_BOMB, me->GetGUID()); + break; + case NPC_KINETIC_BOMB: + { + float x, y, z; + summon->GetPosition(x, y, z); + float ground_Z = summon->GetMap()->GetHeight(summon->GetPhaseShift(), x, y, z, true, 500.0f); + summon->GetMotionMaster()->MovePoint(POINT_KINETIC_BOMB_IMPACT, x, y, ground_Z); + summon->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + break; + } + case NPC_SHOCK_VORTEX: + summon->CastSpell(summon, SPELL_SHOCK_VORTEX_DUMMY, true); + summon->m_Events.AddEvent(new VortexEvent(summon), summon->m_Events.CalculateTime(5000)); + break; + default: + break; } - void UpdateAI(uint32 diff) override - { - if (!UpdateVictim()) - return; + summons.Summon(summon); + if (me->IsInCombat()) + DoZoneInCombat(summon); + } - events.Update(diff); + void UpdateAI(uint32 diff) override + { + if (!UpdateVictim()) + return; - if (me->HasUnitState(UNIT_STATE_CASTING)) - return; + events.Update(diff); - while (uint32 eventId = events.ExecuteEvent()) + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; + + while (uint32 eventId = events.ExecuteEvent()) + { + switch (eventId) { - switch (eventId) + case EVENT_BERSERK: + DoCastSelf(SPELL_BERSERK); + Talk(SAY_VALANAR_BERSERK); + break; + case EVENT_KINETIC_BOMB: + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1, 0.0f, true)) { - case EVENT_BERSERK: - DoCastSelf(SPELL_BERSERK); - Talk(SAY_VALANAR_BERSERK); - break; - case EVENT_KINETIC_BOMB: - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1, 0.0f, true)) - { - DoCast(target, SPELL_KINETIC_BOMB_TARGET); - Talk(SAY_VALANAR_SPECIAL); - } - events.Repeat(Seconds(18), Seconds(24)); - break; - case EVENT_SHOCK_VORTEX: - if (_isEmpowered) - { - DoCastSelf(SPELL_EMPOWERED_SHOCK_VORTEX); - Talk(EMOTE_VALANAR_SHOCK_VORTEX); - events.Repeat(Seconds(30)); - } - else - { - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1, 0.0f, true)) - DoCast(target, SPELL_SHOCK_VORTEX); - events.Repeat(Seconds(18), Seconds(23)); - } - break; - default: - break; + DoCast(target, SPELL_KINETIC_BOMB_TARGET); + Talk(SAY_VALANAR_SPECIAL); } - - if (me->HasUnitState(UNIT_STATE_CASTING)) - return; + events.Repeat(Seconds(18), Seconds(24)); + break; + case EVENT_SHOCK_VORTEX: + if (_isEmpowered) + { + DoCastSelf(SPELL_EMPOWERED_SHOCK_VORTEX); + Talk(EMOTE_VALANAR_SHOCK_VORTEX); + events.Repeat(Seconds(30)); + } + else + { + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1, 0.0f, true)) + DoCast(target, SPELL_SHOCK_VORTEX); + events.Repeat(Seconds(18), Seconds(23)); + } + break; + default: + break; } - DoMeleeAttackIfReady(); + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; } - }; - CreatureAI* GetAI(Creature* creature) const override - { - return GetIcecrownCitadelAI(creature); + DoMeleeAttackIfReady(); } + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return GetIcecrownCitadelAI(creature); + } }; class npc_blood_queen_lana_thel : public CreatureScript { - public: - npc_blood_queen_lana_thel() : CreatureScript("npc_blood_queen_lana_thel") { } + public: + npc_blood_queen_lana_thel() : CreatureScript("npc_blood_queen_lana_thel") + { + } - struct npc_blood_queen_lana_thelAI : public PassiveAI + struct npc_blood_queen_lana_thelAI : public PassiveAI + { + npc_blood_queen_lana_thelAI(Creature* creature) : PassiveAI(creature), _instance(creature->GetInstanceScript()) { - npc_blood_queen_lana_thelAI(Creature* creature) : PassiveAI(creature), _instance(creature->GetInstanceScript()) { } + } - void Reset() override - { - _events.Reset(); - me->SetDisableGravity(true); - _instance->GetBossState(DATA_BLOOD_PRINCE_COUNCIL) != DONE ? me->SetVisible(true) : me->SetVisible(false); - } + void Reset() override + { + _events.Reset(); + me->SetDisableGravity(true); + _instance->GetBossState(DATA_BLOOD_PRINCE_COUNCIL) != DONE ? me->SetVisible(true) : me->SetVisible(false); + } - void DoAction(int32 action) override - { - switch (action) + void DoAction(int32 action) override + { + switch (action) + { + case ACTION_START_INTRO: + Talk(SAY_INTRO_1); + _events.SetPhase(1); + _events.ScheduleEvent(EVENT_INTRO_1, Seconds(14)); + // summon a visual trigger + if (Creature* summon = DoSummon(NPC_FLOATING_TRIGGER, triggerPos, 15000, TEMPSUMMON_TIMED_DESPAWN)) { - case ACTION_START_INTRO: - Talk(SAY_INTRO_1); - _events.SetPhase(1); - _events.ScheduleEvent(EVENT_INTRO_1, Seconds(14)); - // summon a visual trigger - if (Creature* summon = DoSummon(NPC_FLOATING_TRIGGER, triggerPos, 15000, TEMPSUMMON_TIMED_DESPAWN)) - { - summon->CastSpell(summon, SPELL_OOC_INVOCATION_VISUAL, true); - summon->SetSpeedRate(MOVE_RUN, 0.14f); - summon->GetMotionMaster()->MovePoint(0, triggerEndPos); - } - break; - default: - break; + summon->CastSpell(summon, SPELL_OOC_INVOCATION_VISUAL, true); + summon->SetSpeedRate(MOVE_RUN, 0.14f); + summon->GetMotionMaster()->MovePoint(0, triggerEndPos); } + break; + default: + break; } + } - void MovementInform(uint32 type, uint32 id) override - { - if (type == POINT_MOTION_TYPE && id == POINT_INTRO_DESPAWN) - me->SetVisible(false); - } + void MovementInform(uint32 type, uint32 id) override + { + if (type == POINT_MOTION_TYPE && id == POINT_INTRO_DESPAWN) + me->SetVisible(false); + } - void UpdateAI(uint32 diff) override - { - if (!_events.GetPhaseMask()) - return; + void UpdateAI(uint32 diff) override + { + if (!_events.GetPhaseMask()) + return; - _events.Update(diff); + _events.Update(diff); - if (_events.ExecuteEvent() == EVENT_INTRO_1) - { - Talk(SAY_INTRO_2); - me->GetMotionMaster()->MovePoint(POINT_INTRO_DESPAWN, introFinalPos); - _events.Reset(); + if (_events.ExecuteEvent() == EVENT_INTRO_1) + { + Talk(SAY_INTRO_2); + me->GetMotionMaster()->MovePoint(POINT_INTRO_DESPAWN, introFinalPos); + _events.Reset(); - if (Creature* controller = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_BLOOD_PRINCES_CONTROL))) - controller->AI()->DoAction(ACTION_INTRO_DONE); - } + if (Creature* controller = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_BLOOD_PRINCES_CONTROL))) + controller->AI()->DoAction(ACTION_INTRO_DONE); } + } - private: - EventMap _events; - InstanceScript* _instance; - }; + private: + EventMap _events; + InstanceScript* _instance; + }; - CreatureAI* GetAI(Creature* creature) const override - { - return GetIcecrownCitadelAI(creature); - } + CreatureAI* GetAI(Creature* creature) const override + { + return GetIcecrownCitadelAI(creature); + } }; class npc_ball_of_flame : public CreatureScript { - public: - npc_ball_of_flame() : CreatureScript("npc_ball_of_flame") { } + public: + npc_ball_of_flame() : CreatureScript("npc_ball_of_flame") + { + } - struct npc_ball_of_flameAI : public ScriptedAI + struct npc_ball_of_flameAI : public ScriptedAI + { + npc_ball_of_flameAI(Creature* creature) : ScriptedAI(creature), _instance(creature->GetInstanceScript()) { - npc_ball_of_flameAI(Creature* creature) : ScriptedAI(creature), _instance(creature->GetInstanceScript()) { } - - void Reset() override - { - DoCastSelf(SPELL_BALL_OF_FLAMES_VISUAL, true); - if (me->GetEntry() == NPC_BALL_OF_INFERNO_FLAME) - { - DoCastSelf(SPELL_BALL_OF_FLAMES_PROC, true); - DoCastSelf(SPELL_BALL_OF_FLAMES_PERIODIC, true); - } - } - - void MovementInform(uint32 type, uint32 id) override - { - if (type == CHASE_MOTION_TYPE && id == _chaseGUID.GetCounter() && _chaseGUID) - { - me->RemoveAurasDueToSpell(SPELL_BALL_OF_FLAMES_PERIODIC); - DoCastSelf(SPELL_FLAMES); - _scheduler.Schedule(Seconds(2), [this](TaskContext /*context*/) - { - DoCastSelf(SPELL_FLAME_SPHERE_DEATH_EFFECT); - }); - _chaseGUID.Clear(); - } - } + } - void SetGUID(ObjectGuid const& guid, int32 /*id*/) override + void Reset() override + { + DoCastSelf(SPELL_BALL_OF_FLAMES_VISUAL, true); + if (me->GetEntry() == NPC_BALL_OF_INFERNO_FLAME) { - _chaseGUID = guid; + DoCastSelf(SPELL_BALL_OF_FLAMES_PROC, true); + DoCastSelf(SPELL_BALL_OF_FLAMES_PERIODIC, true); } + } - void DoAction(int32 action) override + void MovementInform(uint32 type, uint32 id) override + { + if (type == CHASE_MOTION_TYPE && id == _chaseGUID.GetCounter() && _chaseGUID) { - if (action == ACTION_FLAME_BALL_CHASE) - if (Player* target = ObjectAccessor::GetPlayer(*me, _chaseGUID)) - { - // need to clear states now because this call is before AuraEffect is fully removed - me->ClearUnitState(UNIT_STATE_CASTING | UNIT_STATE_STUNNED); - if (me->Attack(target, true)) - me->GetMotionMaster()->MoveChase(target, 1.0f); - } + me->RemoveAurasDueToSpell(SPELL_BALL_OF_FLAMES_PERIODIC); + DoCastSelf(SPELL_FLAMES); + _scheduler.Schedule(Seconds(2), [this](TaskContext /*context*/) { DoCastSelf(SPELL_FLAME_SPHERE_DEATH_EFFECT); }); + _chaseGUID.Clear(); } + } - void DamageDealt(Unit* /*target*/, uint32& damage, DamageEffectType damageType) override - { - if (damageType != SPELL_DIRECT_DAMAGE) - return; + void SetGUID(ObjectGuid const& guid, int32 /*id*/) override + { + _chaseGUID = guid; + } - if (damage > RAID_MODE(23000, 25000, 23000, 25000)) - _instance->SetData(DATA_ORB_WHISPERER_ACHIEVEMENT, uint32(false)); - } + void DoAction(int32 action) override + { + if (action == ACTION_FLAME_BALL_CHASE) + if (Player* target = ObjectAccessor::GetPlayer(*me, _chaseGUID)) + { + // need to clear states now because this call is before AuraEffect is fully removed + me->ClearUnitState(UNIT_STATE_CASTING | UNIT_STATE_STUNNED); + if (me->Attack(target, true)) + me->GetMotionMaster()->MoveChase(target, 1.0f); + } + } - void UpdateAI(uint32 diff) override - { - _scheduler.Update(diff); - } + void DamageDealt(Unit* /*target*/, uint32& damage, DamageEffectType damageType) override + { + if (damageType != SPELL_DIRECT_DAMAGE) + return; - private: - ObjectGuid _chaseGUID; - InstanceScript* _instance; - TaskScheduler _scheduler; - }; + if (damage > RAID_MODE(23000, 25000, 23000, 25000)) + _instance->SetData(DATA_ORB_WHISPERER_ACHIEVEMENT, uint32(false)); + } - CreatureAI* GetAI(Creature* creature) const override + void UpdateAI(uint32 diff) override { - return GetIcecrownCitadelAI(creature); + _scheduler.Update(diff); } + + private: + ObjectGuid _chaseGUID; + InstanceScript* _instance; + TaskScheduler _scheduler; + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return GetIcecrownCitadelAI(creature); + } }; class npc_kinetic_bomb : public CreatureScript { - public: - npc_kinetic_bomb() : CreatureScript("npc_kinetic_bomb") { } + public: + npc_kinetic_bomb() : CreatureScript("npc_kinetic_bomb") + { + } - struct npc_kinetic_bombAI : public ScriptedAI + struct npc_kinetic_bombAI : public ScriptedAI + { + npc_kinetic_bombAI(Creature* creature) : ScriptedAI(creature), _x(0.f), _y(0.f), _groundZ(0.f) { - npc_kinetic_bombAI(Creature* creature) : ScriptedAI(creature), _x(0.f), _y(0.f), _groundZ(0.f) { } + } - void Reset() override - { - _events.Reset(); - me->SetWalk(true); - DoCastSelf(SPELL_UNSTABLE, true); - DoCastSelf(SPELL_KINETIC_BOMB_VISUAL, true); - me->SetReactState(REACT_PASSIVE); - me->GetPosition(_x, _y, _groundZ); - me->DespawnOrUnsummon(60000); - _groundZ = me->GetMap()->GetHeight(me->GetPhaseShift(), _x, _y, _groundZ, true, 500.0f); - } + void Reset() override + { + _events.Reset(); + me->SetWalk(true); + DoCastSelf(SPELL_UNSTABLE, true); + DoCastSelf(SPELL_KINETIC_BOMB_VISUAL, true); + me->SetReactState(REACT_PASSIVE); + me->GetPosition(_x, _y, _groundZ); + me->DespawnOrUnsummon(60000); + _groundZ = me->GetMap()->GetHeight(me->GetPhaseShift(), _x, _y, _groundZ, true, 500.0f); + } - void DoAction(int32 action) override - { - if (action == SPELL_KINETIC_BOMB_EXPLOSION) - _events.ScheduleEvent(EVENT_BOMB_DESPAWN, Seconds(1)); + void DoAction(int32 action) override + { + if (action == SPELL_KINETIC_BOMB_EXPLOSION) + _events.ScheduleEvent(EVENT_BOMB_DESPAWN, Seconds(1)); - else if (action == ACTION_KINETIC_BOMB_JUMP) + else if (action == ACTION_KINETIC_BOMB_JUMP) + { + if (!me->HasAura(SPELL_KINETIC_BOMB_KNOCKBACK)) { - if (!me->HasAura(SPELL_KINETIC_BOMB_KNOCKBACK)) - { - me->GetMotionMaster()->Clear(); - me->GetMotionMaster()->MoveCharge(_x, _y, me->GetPositionZ() + 100.0f, me->GetSpeed(MOVE_RUN), POINT_KINETIC_BOMB_IMPACT); - } - _events.RescheduleEvent(EVENT_CONTINUE_FALLING, Seconds(3)); + me->GetMotionMaster()->Clear(); + me->GetMotionMaster()->MoveCharge(_x, _y, me->GetPositionZ() + 100.0f, me->GetSpeed(MOVE_RUN), POINT_KINETIC_BOMB_IMPACT); } + _events.RescheduleEvent(EVENT_CONTINUE_FALLING, Seconds(3)); } + } - void UpdateAI(uint32 diff) override - { - _events.Update(diff); + void UpdateAI(uint32 diff) override + { + _events.Update(diff); - while (uint32 eventId = _events.ExecuteEvent()) + while (uint32 eventId = _events.ExecuteEvent()) + { + switch (eventId) { - switch (eventId) - { - case EVENT_BOMB_DESPAWN: - me->SetVisible(false); - me->DespawnOrUnsummon(5000); - break; - case EVENT_CONTINUE_FALLING: - me->GetMotionMaster()->Clear(); - me->GetMotionMaster()->MoveCharge(_x, _y, _groundZ, me->GetSpeed(MOVE_RUN), POINT_KINETIC_BOMB_IMPACT); - break; - default: - break; - } + case EVENT_BOMB_DESPAWN: + me->SetVisible(false); + me->DespawnOrUnsummon(5000); + break; + case EVENT_CONTINUE_FALLING: + me->GetMotionMaster()->Clear(); + me->GetMotionMaster()->MoveCharge(_x, _y, _groundZ, me->GetSpeed(MOVE_RUN), POINT_KINETIC_BOMB_IMPACT); + break; + default: + break; } } + } - private: - EventMap _events; - float _x; - float _y; - float _groundZ; - }; + private: + EventMap _events; + float _x; + float _y; + float _groundZ; + }; - CreatureAI* GetAI(Creature* creature) const override - { - return GetIcecrownCitadelAI(creature); - } + CreatureAI* GetAI(Creature* creature) const override + { + return GetIcecrownCitadelAI(creature); + } }; class npc_dark_nucleus : public CreatureScript { - public: - npc_dark_nucleus() : CreatureScript("npc_dark_nucleus") { } + public: + npc_dark_nucleus() : CreatureScript("npc_dark_nucleus") + { + } - struct npc_dark_nucleusAI : public ScriptedAI + struct npc_dark_nucleusAI : public ScriptedAI + { + npc_dark_nucleusAI(Creature* creature) : ScriptedAI(creature) { - npc_dark_nucleusAI(Creature* creature) : ScriptedAI(creature) { } + } - void Reset() override - { - me->SetReactState(REACT_DEFENSIVE); - DoCastSelf(SPELL_SHADOW_RESONANCE_AURA, true); - } + void Reset() override + { + me->SetReactState(REACT_DEFENSIVE); + DoCastSelf(SPELL_SHADOW_RESONANCE_AURA, true); + } - void JustEngagedWith(Unit* who) override - { - _scheduler.Schedule(Seconds(1), [this](TaskContext targetAuraCheck) + void JustEngagedWith(Unit* who) override + { + _scheduler.Schedule(Seconds(1), + [this](TaskContext targetAuraCheck) { if (Unit* victim = me->GetVictim()) { @@ -1137,142 +1166,148 @@ class npc_dark_nucleus : public CreatureScript targetAuraCheck.Repeat(); }); - if (me->GetDistance(who) >= 15.0f) - { - DoStartMovement(who); - return; - } - - DoCast(who, SPELL_SHADOW_RESONANCE_RESIST); - } - - void DamageTaken(Unit* attacker, uint32& /*damage*/) override + if (me->GetDistance(who) >= 15.0f) { - if (attacker == me) - return; - - me->GetThreatManager().ResetAllThreat(); - AddThreat(attacker, 500000000.0f); + DoStartMovement(who); + return; } - void UpdateAI(uint32 diff) override - { - if (!UpdateVictim()) - return; + DoCast(who, SPELL_SHADOW_RESONANCE_RESIST); + } - _scheduler.Update(diff); - } + void DamageTaken(Unit* attacker, uint32& /*damage*/) override + { + if (attacker == me) + return; - private: - TaskScheduler _scheduler; - }; + me->GetThreatManager().ResetAllThreat(); + AddThreat(attacker, 500000000.0f); + } - CreatureAI* GetAI(Creature* creature) const override + void UpdateAI(uint32 diff) override { - return GetIcecrownCitadelAI(creature); + if (!UpdateVictim()) + return; + + _scheduler.Update(diff); } + + private: + TaskScheduler _scheduler; + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return GetIcecrownCitadelAI(creature); + } }; // 71806 - Glittering Sparks class spell_taldaram_glittering_sparks : public SpellScriptLoader { - public: - spell_taldaram_glittering_sparks() : SpellScriptLoader("spell_taldaram_glittering_sparks") { } + public: + spell_taldaram_glittering_sparks() : SpellScriptLoader("spell_taldaram_glittering_sparks") + { + } - class spell_taldaram_glittering_sparks_SpellScript : public SpellScript + class spell_taldaram_glittering_sparks_SpellScript : public SpellScript + { + void HandleScript(SpellEffIndex effIndex) { - void HandleScript(SpellEffIndex effIndex) - { - PreventHitDefaultEffect(effIndex); - GetCaster()->CastSpell(GetCaster(), uint32(GetEffectValue()), true); - } - - void Register() override - { - OnEffectHitTarget.Register(&spell_taldaram_glittering_sparks_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - } - }; + PreventHitDefaultEffect(effIndex); + GetCaster()->CastSpell(GetCaster(), uint32(GetEffectValue()), true); + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_taldaram_glittering_sparks_SpellScript(); + OnEffectHitTarget.Register(&spell_taldaram_glittering_sparks_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_taldaram_glittering_sparks_SpellScript(); + } }; /* 71718 - Conjure Flame 72040 - Conjure Empowered Flame */ class spell_taldaram_summon_flame_ball : public SpellScriptLoader { - public: - spell_taldaram_summon_flame_ball() : SpellScriptLoader("spell_taldaram_summon_flame_ball") { } + public: + spell_taldaram_summon_flame_ball() : SpellScriptLoader("spell_taldaram_summon_flame_ball") + { + } - class spell_taldaram_summon_flame_ball_SpellScript : public SpellScript + class spell_taldaram_summon_flame_ball_SpellScript : public SpellScript + { + void HandleScript(SpellEffIndex effIndex) { - void HandleScript(SpellEffIndex effIndex) - { - PreventHitDefaultEffect(effIndex); - GetCaster()->CastSpell(GetCaster(), uint32(GetEffectValue()), true); - } - - void Register() override - { - OnEffectHitTarget.Register(&spell_taldaram_summon_flame_ball_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_DUMMY); - } - }; + PreventHitDefaultEffect(effIndex); + GetCaster()->CastSpell(GetCaster(), uint32(GetEffectValue()), true); + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_taldaram_summon_flame_ball_SpellScript(); + OnEffectHitTarget.Register(&spell_taldaram_summon_flame_ball_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_DUMMY); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_taldaram_summon_flame_ball_SpellScript(); + } }; /* 55891 - Flame Sphere Spawn Effect 55947 - Flame Sphere Death Effect */ class spell_taldaram_flame_ball_visual : public SpellScriptLoader { - public: - spell_taldaram_flame_ball_visual() : SpellScriptLoader("spell_taldaram_flame_ball_visual") { } + public: + spell_taldaram_flame_ball_visual() : SpellScriptLoader("spell_taldaram_flame_ball_visual") + { + } - class spell_flame_ball_visual_AuraScript : public AuraScript + class spell_flame_ball_visual_AuraScript : public AuraScript + { + bool Load() override { - bool Load() override - { - if (GetCaster()->GetEntry() == NPC_BALL_OF_FLAME || GetCaster()->GetEntry() == NPC_BALL_OF_INFERNO_FLAME) - return true; - return false; - } - - bool Validate(SpellInfo const* /*spell*/) override - { - return ValidateSpellInfo({ SPELL_BALL_OF_FLAMES }); - } + if (GetCaster()->GetEntry() == NPC_BALL_OF_FLAME || GetCaster()->GetEntry() == NPC_BALL_OF_INFERNO_FLAME) + return true; + return false; + } - void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - Creature* target = GetTarget()->ToCreature(); - if (!target) - return; + bool Validate(SpellInfo const* /*spell*/) override + { + return ValidateSpellInfo({SPELL_BALL_OF_FLAMES}); + } - // SPELL_FLAME_SPHERE_SPAWN_EFFECT - if (GetSpellInfo()->Id == SPELL_FLAME_SPHERE_SPAWN_EFFECT) - { - target->CastSpell(target, SPELL_BALL_OF_FLAMES, true); - target->AI()->DoAction(ACTION_FLAME_BALL_CHASE); - } - else // SPELL_FLAME_SPHERE_DEATH_EFFECT - target->DespawnOrUnsummon(); - } + void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + Creature* target = GetTarget()->ToCreature(); + if (!target) + return; - void Register() override + // SPELL_FLAME_SPHERE_SPAWN_EFFECT + if (GetSpellInfo()->Id == SPELL_FLAME_SPHERE_SPAWN_EFFECT) { - AfterEffectRemove.Register(&spell_flame_ball_visual_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_MOD_STUN, AURA_EFFECT_HANDLE_REAL); + target->CastSpell(target, SPELL_BALL_OF_FLAMES, true); + target->AI()->DoAction(ACTION_FLAME_BALL_CHASE); } - }; + else // SPELL_FLAME_SPHERE_DEATH_EFFECT + target->DespawnOrUnsummon(); + } - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_flame_ball_visual_AuraScript(); + AfterEffectRemove.Register(&spell_flame_ball_visual_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_MOD_STUN, AURA_EFFECT_HANDLE_REAL); } + }; + + AuraScript* GetAuraScript() const override + { + return new spell_flame_ball_visual_AuraScript(); + } }; /* 71756 - Ball of Flames Proc @@ -1281,230 +1316,244 @@ class spell_taldaram_flame_ball_visual : public SpellScriptLoader 72784 - Ball of Flames Proc */ class spell_taldaram_ball_of_inferno_flame : public SpellScriptLoader { - public: - spell_taldaram_ball_of_inferno_flame() : SpellScriptLoader("spell_taldaram_ball_of_inferno_flame") { } + public: + spell_taldaram_ball_of_inferno_flame() : SpellScriptLoader("spell_taldaram_ball_of_inferno_flame") + { + } - class spell_taldaram_ball_of_inferno_flame_SpellScript : public SpellScript + class spell_taldaram_ball_of_inferno_flame_SpellScript : public SpellScript + { + void ModAuraStack() { - void ModAuraStack() - { - if (Aura* aur = GetHitAura()) - aur->SetStackAmount(uint8(GetSpellInfo()->StackAmount)); - } - - void Register() override - { - AfterHit.Register(&spell_taldaram_ball_of_inferno_flame_SpellScript::ModAuraStack); - } - }; + if (Aura* aur = GetHitAura()) + aur->SetStackAmount(uint8(GetSpellInfo()->StackAmount)); + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_taldaram_ball_of_inferno_flame_SpellScript(); + AfterHit.Register(&spell_taldaram_ball_of_inferno_flame_SpellScript::ModAuraStack); } + }; - class spell_taldaram_ball_of_inferno_flame_AuraScript : public AuraScript - { - void HandleStackDrop(ProcEventInfo& /*eventInfo*/) - { - ModStackAmount(-1); - } + SpellScript* GetSpellScript() const override + { + return new spell_taldaram_ball_of_inferno_flame_SpellScript(); + } - void Register() override - { - OnProc.Register(&spell_taldaram_ball_of_inferno_flame_AuraScript::HandleStackDrop); - } - }; + class spell_taldaram_ball_of_inferno_flame_AuraScript : public AuraScript + { + void HandleStackDrop(ProcEventInfo& /*eventInfo*/) + { + ModStackAmount(-1); + } - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_taldaram_ball_of_inferno_flame_AuraScript(); + OnProc.Register(&spell_taldaram_ball_of_inferno_flame_AuraScript::HandleStackDrop); } + }; + + AuraScript* GetAuraScript() const override + { + return new spell_taldaram_ball_of_inferno_flame_AuraScript(); + } }; // 72080 - Kinetic Bomb class spell_valanar_kinetic_bomb : public SpellScriptLoader { - public: - spell_valanar_kinetic_bomb() : SpellScriptLoader("spell_valanar_kinetic_bomb") { } + public: + spell_valanar_kinetic_bomb() : SpellScriptLoader("spell_valanar_kinetic_bomb") + { + } - class spell_valanar_kinetic_bomb_SpellScript : public SpellScript + class spell_valanar_kinetic_bomb_SpellScript : public SpellScript + { + void SetDest(SpellDestination& dest) { - void SetDest(SpellDestination& dest) - { - Position const offset = { 0.0f, 0.0f, 20.0f, 0.0f }; - dest.RelocateOffset(offset); - } - - void Register() override - { - OnDestinationTargetSelect.Register(&spell_valanar_kinetic_bomb_SpellScript::SetDest, EFFECT_0, TARGET_DEST_CASTER); - } - }; + Position const offset = {0.0f, 0.0f, 20.0f, 0.0f}; + dest.RelocateOffset(offset); + } - class spell_valanar_kinetic_bomb_AuraScript : public AuraScript + void Register() override { - bool Validate(SpellInfo const* /*spell*/) override - { - return ValidateSpellInfo({ SPELL_KINETIC_BOMB_EXPLOSION, SPELL_KINETIC_BOMB_VISUAL }); - } + OnDestinationTargetSelect.Register(&spell_valanar_kinetic_bomb_SpellScript::SetDest, EFFECT_0, TARGET_DEST_CASTER); + } + }; - void HandleDummyTick(AuraEffect const* /*aurEff*/) - { - Unit* target = GetTarget(); - if (target->GetTypeId() != TYPEID_UNIT) - return; + class spell_valanar_kinetic_bomb_AuraScript : public AuraScript + { + bool Validate(SpellInfo const* /*spell*/) override + { + return ValidateSpellInfo({SPELL_KINETIC_BOMB_EXPLOSION, SPELL_KINETIC_BOMB_VISUAL}); + } - if (Creature* bomb = target->FindNearestCreature(NPC_KINETIC_BOMB, 1.0f, true)) - { - bomb->CastSpell(bomb, SPELL_KINETIC_BOMB_EXPLOSION, true); - bomb->RemoveAurasDueToSpell(SPELL_KINETIC_BOMB_VISUAL); - target->RemoveAura(GetAura()); - bomb->AI()->DoAction(SPELL_KINETIC_BOMB_EXPLOSION); - } - } + void HandleDummyTick(AuraEffect const* /*aurEff*/) + { + Unit* target = GetTarget(); + if (target->GetTypeId() != TYPEID_UNIT) + return; - void Register() override + if (Creature* bomb = target->FindNearestCreature(NPC_KINETIC_BOMB, 1.0f, true)) { - OnEffectPeriodic.Register(&spell_valanar_kinetic_bomb_AuraScript::HandleDummyTick, EFFECT_1, SPELL_AURA_PERIODIC_DUMMY); + bomb->CastSpell(bomb, SPELL_KINETIC_BOMB_EXPLOSION, true); + bomb->RemoveAurasDueToSpell(SPELL_KINETIC_BOMB_VISUAL); + target->RemoveAura(GetAura()); + bomb->AI()->DoAction(SPELL_KINETIC_BOMB_EXPLOSION); } - }; - - SpellScript* GetSpellScript() const override - { - return new spell_valanar_kinetic_bomb_SpellScript(); } - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_valanar_kinetic_bomb_AuraScript(); + OnEffectPeriodic.Register(&spell_valanar_kinetic_bomb_AuraScript::HandleDummyTick, EFFECT_1, SPELL_AURA_PERIODIC_DUMMY); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_valanar_kinetic_bomb_SpellScript(); + } + + AuraScript* GetAuraScript() const override + { + return new spell_valanar_kinetic_bomb_AuraScript(); + } }; // 72087 - Kinetic Bomb Knockback class spell_valanar_kinetic_bomb_knockback : public SpellScriptLoader { - public: - spell_valanar_kinetic_bomb_knockback() : SpellScriptLoader("spell_valanar_kinetic_bomb_knockback") { } + public: + spell_valanar_kinetic_bomb_knockback() : SpellScriptLoader("spell_valanar_kinetic_bomb_knockback") + { + } - class spell_valanar_kinetic_bomb_knockback_SpellScript : public SpellScript + class spell_valanar_kinetic_bomb_knockback_SpellScript : public SpellScript + { + void KnockIntoAir() { - void KnockIntoAir() - { - if (Creature* target = GetHitCreature()) - target->AI()->DoAction(ACTION_KINETIC_BOMB_JUMP); - } - - void Register() override - { - BeforeHit.Register(&spell_valanar_kinetic_bomb_knockback_SpellScript::KnockIntoAir); - } - }; + if (Creature* target = GetHitCreature()) + target->AI()->DoAction(ACTION_KINETIC_BOMB_JUMP); + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_valanar_kinetic_bomb_knockback_SpellScript(); + BeforeHit.Register(&spell_valanar_kinetic_bomb_knockback_SpellScript::KnockIntoAir); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_valanar_kinetic_bomb_knockback_SpellScript(); + } }; // 72054 - Kinetic Bomb Visual class spell_valanar_kinetic_bomb_absorb : public SpellScriptLoader { - public: - spell_valanar_kinetic_bomb_absorb() : SpellScriptLoader("spell_valanar_kinetic_bomb_absorb") { } + public: + spell_valanar_kinetic_bomb_absorb() : SpellScriptLoader("spell_valanar_kinetic_bomb_absorb") + { + } - class spell_valanar_kinetic_bomb_absorb_AuraScript : public AuraScript + class spell_valanar_kinetic_bomb_absorb_AuraScript : public AuraScript + { + void OnAbsorb(AuraEffect* aurEff, DamageInfo& dmgInfo, uint32& absorbAmount) { - void OnAbsorb(AuraEffect* aurEff, DamageInfo& dmgInfo, uint32& absorbAmount) - { - absorbAmount = CalculatePct(dmgInfo.GetDamage(), aurEff->GetAmount()); - RoundToInterval(absorbAmount, 0, dmgInfo.GetDamage()); - dmgInfo.AbsorbDamage(absorbAmount); - } - - void Register() override - { - OnEffectAbsorb.Register(&spell_valanar_kinetic_bomb_absorb_AuraScript::OnAbsorb, EFFECT_0); - } - }; + absorbAmount = CalculatePct(dmgInfo.GetDamage(), aurEff->GetAmount()); + RoundToInterval(absorbAmount, 0, dmgInfo.GetDamage()); + dmgInfo.AbsorbDamage(absorbAmount); + } - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_valanar_kinetic_bomb_absorb_AuraScript(); + OnEffectAbsorb.Register(&spell_valanar_kinetic_bomb_absorb_AuraScript::OnAbsorb, EFFECT_0); } + }; + + AuraScript* GetAuraScript() const override + { + return new spell_valanar_kinetic_bomb_absorb_AuraScript(); + } }; // 73001 - Shadow Prison class spell_blood_council_shadow_prison : public SpellScriptLoader { - public: - spell_blood_council_shadow_prison() : SpellScriptLoader("spell_blood_council_shadow_prison") { } + public: + spell_blood_council_shadow_prison() : SpellScriptLoader("spell_blood_council_shadow_prison") + { + } - class spell_blood_council_shadow_prison_AuraScript : public AuraScript + class spell_blood_council_shadow_prison_AuraScript : public AuraScript + { + bool Validate(SpellInfo const* /*spell*/) override { - bool Validate(SpellInfo const* /*spell*/) override - { - return ValidateSpellInfo({ SPELL_SHADOW_PRISON_DAMAGE }); - } - - void HandleDummyTick(AuraEffect const* aurEff) - { - if (GetTarget()->isMoving()) - GetTarget()->CastSpell(GetTarget(), SPELL_SHADOW_PRISON_DAMAGE, aurEff); - } + return ValidateSpellInfo({SPELL_SHADOW_PRISON_DAMAGE}); + } - void Register() override - { - OnEffectPeriodic.Register(&spell_blood_council_shadow_prison_AuraScript::HandleDummyTick, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY); - } - }; + void HandleDummyTick(AuraEffect const* aurEff) + { + if (GetTarget()->isMoving()) + GetTarget()->CastSpell(GetTarget(), SPELL_SHADOW_PRISON_DAMAGE, aurEff); + } - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_blood_council_shadow_prison_AuraScript(); + OnEffectPeriodic.Register(&spell_blood_council_shadow_prison_AuraScript::HandleDummyTick, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY); } + }; + + AuraScript* GetAuraScript() const override + { + return new spell_blood_council_shadow_prison_AuraScript(); + } }; // 72999 - Shadow Prison class spell_blood_council_shadow_prison_damage : public SpellScriptLoader { - public: - spell_blood_council_shadow_prison_damage() : SpellScriptLoader("spell_blood_council_shadow_prison_damage") { } + public: + spell_blood_council_shadow_prison_damage() : SpellScriptLoader("spell_blood_council_shadow_prison_damage") + { + } - class spell_blood_council_shadow_prison_SpellScript : public SpellScript + class spell_blood_council_shadow_prison_SpellScript : public SpellScript + { + void AddExtraDamage() { - void AddExtraDamage() - { - if (Aura* aur = GetHitUnit()->GetAura(GetSpellInfo()->Id)) - if (AuraEffect const* eff = aur->GetEffect(EFFECT_1)) - SetHitDamage(GetHitDamage() + eff->GetAmount()); - } - - void Register() override - { - OnHit.Register(&spell_blood_council_shadow_prison_SpellScript::AddExtraDamage); - } - }; + if (Aura* aur = GetHitUnit()->GetAura(GetSpellInfo()->Id)) + if (AuraEffect const* eff = aur->GetEffect(EFFECT_1)) + SetHitDamage(GetHitDamage() + eff->GetAmount()); + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_blood_council_shadow_prison_SpellScript(); + OnHit.Register(&spell_blood_council_shadow_prison_SpellScript::AddExtraDamage); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_blood_council_shadow_prison_SpellScript(); + } }; class at_blood_prince_council_start_intro : public AreaTriggerScript { - public: - at_blood_prince_council_start_intro() : AreaTriggerScript("at_blood_prince_council_start_intro") { } + public: + at_blood_prince_council_start_intro() : AreaTriggerScript("at_blood_prince_council_start_intro") + { + } - bool OnTrigger(Player* player, AreaTriggerEntry const* /*areaTrigger*/) override - { - if (InstanceScript* instance = player->GetInstanceScript()) - if (Creature* controller = ObjectAccessor::GetCreature(*player, instance->GetGuidData(DATA_BLOOD_PRINCES_CONTROL))) - controller->AI()->DoAction(ACTION_START_INTRO); + bool OnTrigger(Player* player, AreaTriggerEntry const* /*areaTrigger*/) override + { + if (InstanceScript* instance = player->GetInstanceScript()) + if (Creature* controller = ObjectAccessor::GetCreature(*player, instance->GetGuidData(DATA_BLOOD_PRINCES_CONTROL))) + controller->AI()->DoAction(ACTION_START_INTRO); - return true; - } + return true; + } }; void AddSC_boss_blood_prince_council() diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp index 11691ee9..8e475fc8 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp @@ -15,98 +15,96 @@ * with this program. If not, see . */ -#include "ScriptMgr.h" #include "CellImpl.h" #include "GridNotifiersImpl.h" -#include "icecrown_citadel.h" #include "InstanceScript.h" #include "MotionMaster.h" #include "ObjectAccessor.h" #include "ObjectMgr.h" #include "PhasingHandler.h" +#include "ScriptMgr.h" #include "ScriptedCreature.h" #include "SpellAuraEffects.h" #include "SpellScript.h" +#include "icecrown_citadel.h" enum Texts { // The Lich King - SAY_LICH_KING_INTRO = 0, + SAY_LICH_KING_INTRO = 0, // Valithria Dreamwalker - SAY_VALITHRIA_ENTER_COMBAT = 0, - SAY_VALITHRIA_DREAM_PORTAL = 1, - SAY_VALITHRIA_75_PERCENT = 2, - SAY_VALITHRIA_25_PERCENT = 3, - SAY_VALITHRIA_DEATH = 4, - SAY_VALITHRIA_PLAYER_DEATH = 5, - SAY_VALITHRIA_BERSERK = 6, - SAY_VALITHRIA_SUCCESS = 7, + SAY_VALITHRIA_ENTER_COMBAT = 0, + SAY_VALITHRIA_DREAM_PORTAL = 1, + SAY_VALITHRIA_75_PERCENT = 2, + SAY_VALITHRIA_25_PERCENT = 3, + SAY_VALITHRIA_DEATH = 4, + SAY_VALITHRIA_PLAYER_DEATH = 5, + SAY_VALITHRIA_BERSERK = 6, + SAY_VALITHRIA_SUCCESS = 7, }; enum Spells { // Valithria Dreamwalker - SPELL_COPY_DAMAGE = 71948, - SPELL_DREAM_PORTAL_VISUAL_PRE = 71304, - SPELL_NIGHTMARE_PORTAL_VISUAL_PRE = 71986, - SPELL_NIGHTMARE_CLOUD = 71970, - SPELL_NIGHTMARE_CLOUD_VISUAL = 71939, - SPELL_PRE_SUMMON_DREAM_PORTAL = 72224, - SPELL_PRE_SUMMON_NIGHTMARE_PORTAL = 72480, - SPELL_SUMMON_DREAM_PORTAL = 71305, - SPELL_SUMMON_NIGHTMARE_PORTAL = 71987, - SPELL_DREAMWALKERS_RAGE = 71189, - SPELL_DREAM_SLIP = 71196, - SPELL_ACHIEVEMENT_CHECK = 72706, - SPELL_CLEAR_ALL = 71721, - SPELL_CORRUPTION_VALITHRIA = 70904, - SPELL_MANA_VOID_AURA = 71085, - SPELL_COLUMN_OF_FROST_AURA = 70715, + SPELL_COPY_DAMAGE = 71948, + SPELL_DREAM_PORTAL_VISUAL_PRE = 71304, + SPELL_NIGHTMARE_PORTAL_VISUAL_PRE = 71986, + SPELL_NIGHTMARE_CLOUD = 71970, + SPELL_NIGHTMARE_CLOUD_VISUAL = 71939, + SPELL_PRE_SUMMON_DREAM_PORTAL = 72224, + SPELL_PRE_SUMMON_NIGHTMARE_PORTAL = 72480, + SPELL_SUMMON_DREAM_PORTAL = 71305, + SPELL_SUMMON_NIGHTMARE_PORTAL = 71987, + SPELL_DREAMWALKERS_RAGE = 71189, + SPELL_DREAM_SLIP = 71196, + SPELL_ACHIEVEMENT_CHECK = 72706, + SPELL_CLEAR_ALL = 71721, + SPELL_CORRUPTION_VALITHRIA = 70904, + SPELL_MANA_VOID_AURA = 71085, + SPELL_COLUMN_OF_FROST_AURA = 70715, // The Lich King - SPELL_TIMER_GLUTTONOUS_ABOMINATION = 70915, - SPELL_TIMER_SUPPRESSER = 70912, - SPELL_TIMER_BLISTERING_ZOMBIE = 70914, - SPELL_TIMER_RISEN_ARCHMAGE = 70916, - SPELL_TIMER_BLAZING_SKELETON = 70913, - SPELL_SUMMON_SUPPRESSER = 70936, - SPELL_RECENTLY_SPAWNED = 72954, - SPELL_SPAWN_CHEST = 71207, + SPELL_TIMER_GLUTTONOUS_ABOMINATION = 70915, + SPELL_TIMER_SUPPRESSER = 70912, + SPELL_TIMER_BLISTERING_ZOMBIE = 70914, + SPELL_TIMER_RISEN_ARCHMAGE = 70916, + SPELL_TIMER_BLAZING_SKELETON = 70913, + SPELL_SUMMON_SUPPRESSER = 70936, + SPELL_RECENTLY_SPAWNED = 72954, + SPELL_SPAWN_CHEST = 71207, // Risen Archmage - SPELL_CORRUPTION = 70602, - SPELL_FROSTBOLT_VOLLEY = 70759, - SPELL_MANA_VOID = 71179, - SPELL_COLUMN_OF_FROST = 70704, - SPELL_COLUMN_OF_FROST_DAMAGE = 70702, + SPELL_CORRUPTION = 70602, + SPELL_FROSTBOLT_VOLLEY = 70759, + SPELL_MANA_VOID = 71179, + SPELL_COLUMN_OF_FROST = 70704, + SPELL_COLUMN_OF_FROST_DAMAGE = 70702, // Blazing Skeleton - SPELL_FIREBALL = 70754, - SPELL_LEY_WASTE = 69325, + SPELL_FIREBALL = 70754, + SPELL_LEY_WASTE = 69325, // Suppresser - SPELL_SUPPRESSION = 70588, + SPELL_SUPPRESSION = 70588, // Blistering Zombie - SPELL_ACID_BURST = 70744, + SPELL_ACID_BURST = 70744, // Gluttonous Abomination - SPELL_GUT_SPRAY = 70633, - SPELL_ROT_WORM_SPAWNER = 70675, + SPELL_GUT_SPRAY = 70633, + SPELL_ROT_WORM_SPAWNER = 70675, // Dream Cloud - SPELL_EMERALD_VIGOR = 70873, + SPELL_EMERALD_VIGOR = 70873, // Nightmare Cloud - SPELL_TWISTED_NIGHTMARE = 71941, + SPELL_TWISTED_NIGHTMARE = 71941, }; -#define SUMMON_PORTAL RAID_MODE(SPELL_PRE_SUMMON_DREAM_PORTAL, SPELL_PRE_SUMMON_DREAM_PORTAL, \ - SPELL_PRE_SUMMON_NIGHTMARE_PORTAL, SPELL_PRE_SUMMON_NIGHTMARE_PORTAL) +#define SUMMON_PORTAL RAID_MODE(SPELL_PRE_SUMMON_DREAM_PORTAL, SPELL_PRE_SUMMON_DREAM_PORTAL, SPELL_PRE_SUMMON_NIGHTMARE_PORTAL, SPELL_PRE_SUMMON_NIGHTMARE_PORTAL) -#define EMERALD_VIGOR RAID_MODE(SPELL_EMERALD_VIGOR, SPELL_EMERALD_VIGOR, \ - SPELL_TWISTED_NIGHTMARE, SPELL_TWISTED_NIGHTMARE) +#define EMERALD_VIGOR RAID_MODE(SPELL_EMERALD_VIGOR, SPELL_EMERALD_VIGOR, SPELL_TWISTED_NIGHTMARE, SPELL_TWISTED_NIGHTMARE) enum Events { @@ -146,1308 +144,1349 @@ enum Events enum Misc { - ACTION_ENTER_COMBAT = 1, - MISSED_PORTALS = 2, - ACTION_DEATH = 3, + ACTION_ENTER_COMBAT = 1, + MISSED_PORTALS = 2, + ACTION_DEATH = 3, ACTION_SETUP_ARCHMAGES = 4, DATA_SUPPRESSERS_COUNT = 4, - POINT_VALITHRIA = 42, - SUMMON_GROUP_ALL = 1, - SUMMON_GROUP_10 = 2, - SUMMON_GROUP_25 = 3 + POINT_VALITHRIA = 42, + SUMMON_GROUP_ALL = 1, + SUMMON_GROUP_10 = 2, + SUMMON_GROUP_25 = 3 }; Position const ValithriaSpawnPos = {4210.813f, 2484.443f, 364.9558f, 0.01745329f}; struct ValithriaManaVoidSelector { - explicit ValithriaManaVoidSelector(WorldObject const* source) : _source(source) - { - } + explicit ValithriaManaVoidSelector(WorldObject const* source) : _source(source) + { + } - bool operator()(Unit* unit) const - { - return unit->GetPowerType() == POWER_MANA && _source->GetDistance(unit) > 15.0f; - } + bool operator()(Unit* unit) const + { + return unit->GetPowerType() == POWER_MANA && _source->GetDistance(unit) > 15.0f; + } - WorldObject const* _source; + WorldObject const* _source; }; class ValithriaDelayedCastEvent : public BasicEvent { - public: - ValithriaDelayedCastEvent(Creature* trigger, uint32 spellId, ObjectGuid originalCaster, uint32 despawnTime) : _trigger(trigger), _originalCaster(originalCaster), _spellId(spellId), _despawnTime(despawnTime) - { - } - - bool Execute(uint64 /*time*/, uint32 /*diff*/) override - { - _trigger->CastSpell(_trigger, _spellId, _originalCaster); - if (_despawnTime) - _trigger->DespawnOrUnsummon(_despawnTime); - return true; - } - - private: - Creature* _trigger; - ObjectGuid _originalCaster; - uint32 _spellId; - uint32 _despawnTime; + public: + ValithriaDelayedCastEvent(Creature* trigger, uint32 spellId, ObjectGuid originalCaster, uint32 despawnTime) + : _trigger(trigger), _originalCaster(originalCaster), _spellId(spellId), _despawnTime(despawnTime) + { + } + + bool Execute(uint64 /*time*/, uint32 /*diff*/) override + { + _trigger->CastSpell(_trigger, _spellId, _originalCaster); + if (_despawnTime) + _trigger->DespawnOrUnsummon(_despawnTime); + return true; + } + + private: + Creature* _trigger; + ObjectGuid _originalCaster; + uint32 _spellId; + uint32 _despawnTime; }; class ValithriaAuraRemoveEvent : public BasicEvent { - public: - ValithriaAuraRemoveEvent(Creature* trigger, uint32 spellId) : _trigger(trigger), _spellId(spellId) - { - } + public: + ValithriaAuraRemoveEvent(Creature* trigger, uint32 spellId) : _trigger(trigger), _spellId(spellId) + { + } + + bool Execute(uint64 /*time*/, uint32 /*diff*/) override + { + _trigger->RemoveAurasDueToSpell(_spellId); + return true; + } + + private: + Creature* _trigger; + uint32 _spellId; +}; - bool Execute(uint64 /*time*/, uint32 /*diff*/) override +class ValithriaDespawner : public BasicEvent +{ + public: + explicit ValithriaDespawner(Creature* creature) : _creature(creature) + { + } + + bool Execute(uint64 /*currTime*/, uint32 /*diff*/) override + { + Firelands::CreatureWorker worker(_creature, *this); + Cell::VisitGridObjects(_creature, worker, 333.0f); + return true; + } + + void operator()(Creature* creature) const + { + switch (creature->GetEntry()) { - _trigger->RemoveAurasDueToSpell(_spellId); - return true; + case NPC_VALITHRIA_DREAMWALKER: + if (InstanceScript* instance = creature->GetInstanceScript()) + instance->SendEncounterUnit(ENCOUNTER_FRAME_DISENGAGE, creature); + [[fallthrough]]; + case NPC_BLAZING_SKELETON: + case NPC_SUPPRESSER: + case NPC_BLISTERING_ZOMBIE: + case NPC_GLUTTONOUS_ABOMINATION: + case NPC_MANA_VOID: + case NPC_COLUMN_OF_FROST: + case NPC_ROT_WORM: + case NPC_RISEN_ARCHMAGE: + case NPC_GREEN_DRAGON_COMBAT_TRIGGER: + break; + default: + return; } - private: - Creature* _trigger; - uint32 _spellId; + creature->DespawnOrUnsummon(0, 10s); + } + + private: + Creature* _creature; }; -class ValithriaDespawner : public BasicEvent +class boss_valithria_dreamwalker : public CreatureScript { - public: - explicit ValithriaDespawner(Creature* creature) : _creature(creature) + public: + boss_valithria_dreamwalker() : CreatureScript("boss_valithria_dreamwalker") + { + } + + struct boss_valithria_dreamwalkerAI : public ScriptedAI + { + boss_valithria_dreamwalkerAI(Creature* creature) : ScriptedAI(creature), _instance(creature->GetInstanceScript()), _portalCount(RAID_MODE(3, 8, 3, 8)) { + Initialize(); + _spawnHealth = me->GetHealth(); } - bool Execute(uint64 /*currTime*/, uint32 /*diff*/) override + void Initialize() { - Firelands::CreatureWorker worker(_creature, *this); - Cell::VisitGridObjects(_creature, worker, 333.0f); - return true; + _missedPortals = 0; + _under25PercentTalkDone = false; + _over75PercentTalkDone = false; + _justDied = false; + _done = false; } - void operator()(Creature* creature) const + void InitializeAI() override { - switch (creature->GetEntry()) - { - case NPC_VALITHRIA_DREAMWALKER: - if (InstanceScript* instance = creature->GetInstanceScript()) - instance->SendEncounterUnit(ENCOUNTER_FRAME_DISENGAGE, creature); - [[fallthrough]]; - case NPC_BLAZING_SKELETON: - case NPC_SUPPRESSER: - case NPC_BLISTERING_ZOMBIE: - case NPC_GLUTTONOUS_ABOMINATION: - case NPC_MANA_VOID: - case NPC_COLUMN_OF_FROST: - case NPC_ROT_WORM: - case NPC_RISEN_ARCHMAGE: - case NPC_GREEN_DRAGON_COMBAT_TRIGGER: - break; - default: - return; - } + if (CreatureData const* data = sObjectMgr->GetCreatureData(me->GetSpawnId())) + if (data->curhealth) + _spawnHealth = data->curhealth; - creature->DespawnOrUnsummon(0, 10s); + ScriptedAI::InitializeAI(); } - private: - Creature* _creature; -}; - -class boss_valithria_dreamwalker : public CreatureScript -{ - public: - boss_valithria_dreamwalker() : CreatureScript("boss_valithria_dreamwalker") + void Reset() override { + _events.Reset(); + me->SetHealth(_spawnHealth); + me->SetReactState(REACT_PASSIVE); + me->LoadCreaturesAddon(); + // immune to percent heals + me->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_OBS_MOD_HEALTH, true); + me->ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_HEAL_PCT, true); + // Glyph of Dispel Magic - not a percent heal by effect, its cast with custom basepoints + me->ApplySpellImmune(0, IMMUNITY_ID, 56131, true); + _instance->SendEncounterUnit(ENCOUNTER_FRAME_DISENGAGE, me); + Initialize(); } - struct boss_valithria_dreamwalkerAI : public ScriptedAI + void AttackStart(Unit* /*target*/) override { - boss_valithria_dreamwalkerAI(Creature* creature) : ScriptedAI(creature), _instance(creature->GetInstanceScript()), _portalCount(RAID_MODE(3, 8, 3, 8)) - { - Initialize(); - _spawnHealth = me->GetHealth(); - } + } - void Initialize() - { - _missedPortals = 0; - _under25PercentTalkDone = false; - _over75PercentTalkDone = false; - _justDied = false; - _done = false; - } + void DoAction(int32 action) override + { + if (action != ACTION_ENTER_COMBAT) + return; + + DoCastSelf(SPELL_COPY_DAMAGE); + _instance->SendEncounterUnit(ENCOUNTER_FRAME_ENGAGE, me); + _events.ScheduleEvent(EVENT_INTRO_TALK, 15s); + _events.ScheduleEvent(EVENT_DREAM_PORTAL, 45s, 48s); + if (IsHeroic()) + _events.ScheduleEvent(EVENT_BERSERK, 420000); + } - void InitializeAI() override - { - if (CreatureData const* data = sObjectMgr->GetCreatureData(me->GetSpawnId())) - if (data->curhealth) - _spawnHealth = data->curhealth; + void HealReceived(Unit* healer, uint32& heal) override + { + if (!me->hasLootRecipient()) + me->SetLootRecipient(healer); - ScriptedAI::InitializeAI(); - } + me->LowerPlayerDamageReq(heal); - void Reset() override + // encounter complete + if (me->HealthAbovePctHealed(100, heal) && !_done) { - _events.Reset(); - me->SetHealth(_spawnHealth); - me->SetReactState(REACT_PASSIVE); - me->LoadCreaturesAddon(); - // immune to percent heals - me->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_OBS_MOD_HEALTH, true); - me->ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_HEAL_PCT, true); - // Glyph of Dispel Magic - not a percent heal by effect, its cast with custom basepoints - me->ApplySpellImmune(0, IMMUNITY_ID, 56131, true); + _done = true; + Talk(SAY_VALITHRIA_SUCCESS); _instance->SendEncounterUnit(ENCOUNTER_FRAME_DISENGAGE, me); - Initialize(); + me->RemoveAurasDueToSpell(SPELL_CORRUPTION_VALITHRIA); + DoCastSelf(SPELL_ACHIEVEMENT_CHECK); + DoCastAOE(SPELL_DREAMWALKERS_RAGE); + _events.ScheduleEvent(EVENT_DREAM_SLIP, 3500ms); + if (Creature* lichKing = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_VALITHRIA_LICH_KING))) + lichKing->AI()->EnterEvadeMode(); } - - void AttackStart(Unit* /*target*/) override + else if (!_over75PercentTalkDone && me->HealthAbovePctHealed(75, heal)) { + _over75PercentTalkDone = true; + Talk(SAY_VALITHRIA_75_PERCENT); } - - void DoAction(int32 action) override + else if (_instance->GetBossState(DATA_VALITHRIA_DREAMWALKER) == NOT_STARTED) { - if (action != ACTION_ENTER_COMBAT) - return; - - DoCastSelf(SPELL_COPY_DAMAGE); - _instance->SendEncounterUnit(ENCOUNTER_FRAME_ENGAGE, me); - _events.ScheduleEvent(EVENT_INTRO_TALK, 15s); - _events.ScheduleEvent(EVENT_DREAM_PORTAL, 45s, 48s); - if (IsHeroic()) - _events.ScheduleEvent(EVENT_BERSERK, 420000); + if (Creature* archmage = me->FindNearestCreature(NPC_RISEN_ARCHMAGE, 30.0f)) + DoZoneInCombat(archmage); // on one of them, that will make it all start } + } - void HealReceived(Unit* healer, uint32& heal) override + void DamageTaken(Unit* /*attacker*/, uint32& damage) override + { + if (me->HealthBelowPctDamaged(25, damage)) { - if (!me->hasLootRecipient()) - me->SetLootRecipient(healer); - - me->LowerPlayerDamageReq(heal); - - // encounter complete - if (me->HealthAbovePctHealed(100, heal) && !_done) - { - _done = true; - Talk(SAY_VALITHRIA_SUCCESS); - _instance->SendEncounterUnit(ENCOUNTER_FRAME_DISENGAGE, me); - me->RemoveAurasDueToSpell(SPELL_CORRUPTION_VALITHRIA); - DoCastSelf(SPELL_ACHIEVEMENT_CHECK); - DoCastAOE(SPELL_DREAMWALKERS_RAGE); - _events.ScheduleEvent(EVENT_DREAM_SLIP, 3500ms); - if (Creature* lichKing = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_VALITHRIA_LICH_KING))) - lichKing->AI()->EnterEvadeMode(); - } - else if (!_over75PercentTalkDone && me->HealthAbovePctHealed(75, heal)) - { - _over75PercentTalkDone = true; - Talk(SAY_VALITHRIA_75_PERCENT); - } - else if (_instance->GetBossState(DATA_VALITHRIA_DREAMWALKER) == NOT_STARTED) + if (!_under25PercentTalkDone) { - if (Creature* archmage = me->FindNearestCreature(NPC_RISEN_ARCHMAGE, 30.0f)) - DoZoneInCombat(archmage); // on one of them, that will make it all start + _under25PercentTalkDone = true; + Talk(SAY_VALITHRIA_25_PERCENT); } - } - void DamageTaken(Unit* /*attacker*/, uint32& damage) override - { - if (me->HealthBelowPctDamaged(25, damage)) + if (damage >= me->GetHealth()) { - if (!_under25PercentTalkDone) - { - _under25PercentTalkDone = true; - Talk(SAY_VALITHRIA_25_PERCENT); - } - - if (damage >= me->GetHealth()) + damage = 0; + if (!_justDied) { - damage = 0; - if (!_justDied) - { - _justDied = true; - Talk(SAY_VALITHRIA_DEATH); - _instance->SendEncounterUnit(ENCOUNTER_FRAME_DISENGAGE, me); - if (Creature* trigger = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_VALITHRIA_TRIGGER))) - trigger->AI()->DoAction(ACTION_DEATH); - } + _justDied = true; + Talk(SAY_VALITHRIA_DEATH); + _instance->SendEncounterUnit(ENCOUNTER_FRAME_DISENGAGE, me); + if (Creature* trigger = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_VALITHRIA_TRIGGER))) + trigger->AI()->DoAction(ACTION_DEATH); } } } + } - void SpellHit(Unit* /*caster*/, SpellInfo const* spell) override + void SpellHit(Unit* /*caster*/, SpellInfo const* spell) override + { + if (spell->Id == SPELL_DREAM_SLIP) { - if (spell->Id == SPELL_DREAM_SLIP) - { - DoCastSelf(SPELL_CLEAR_ALL); - DoCastSelf(SPELL_REPUTATION_BOSS_KILL, true); - // this display id was found in sniff instead of the one on aura - me->SetDisplayId(11686); - me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - me->DespawnOrUnsummon(4000); - if (Creature* trigger = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_VALITHRIA_TRIGGER))) - me->Kill(trigger); - - if (Creature* lichKing = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_VALITHRIA_LICH_KING))) - lichKing->CastSpell(lichKing, SPELL_SPAWN_CHEST); - } - } + DoCastSelf(SPELL_CLEAR_ALL); + DoCastSelf(SPELL_REPUTATION_BOSS_KILL, true); + // this display id was found in sniff instead of the one on aura + me->SetDisplayId(11686); + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + me->DespawnOrUnsummon(4000); + if (Creature* trigger = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_VALITHRIA_TRIGGER))) + Unit::Kill(me, trigger); - void JustSummoned(Creature* summon) override - { - if (summon->GetEntry() == NPC_DREAM_PORTAL_PRE_EFFECT) - { - summon->m_Events.AddEvent(new ValithriaDelayedCastEvent(summon, SPELL_SUMMON_DREAM_PORTAL, me->GetGUID(), 6000), summon->m_Events.CalculateTime(15000)); - summon->m_Events.AddEvent(new ValithriaAuraRemoveEvent(summon, SPELL_DREAM_PORTAL_VISUAL_PRE), summon->m_Events.CalculateTime(15000)); - } - else if (summon->GetEntry() == NPC_NIGHTMARE_PORTAL_PRE_EFFECT) - { - summon->m_Events.AddEvent(new ValithriaDelayedCastEvent(summon, SPELL_SUMMON_NIGHTMARE_PORTAL, me->GetGUID(), 6000), summon->m_Events.CalculateTime(15000)); - summon->m_Events.AddEvent(new ValithriaAuraRemoveEvent(summon, SPELL_NIGHTMARE_PORTAL_VISUAL_PRE), summon->m_Events.CalculateTime(15000)); - } + if (Creature* lichKing = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_VALITHRIA_LICH_KING))) + lichKing->CastSpell(lichKing, SPELL_SPAWN_CHEST); } + } - void SummonedCreatureDespawn(Creature* summon) override + void JustSummoned(Creature* summon) override + { + if (summon->GetEntry() == NPC_DREAM_PORTAL_PRE_EFFECT) { - if (summon->GetEntry() == NPC_DREAM_PORTAL || summon->GetEntry() == NPC_NIGHTMARE_PORTAL) - if (summon->AI()->GetData(MISSED_PORTALS)) - ++_missedPortals; + summon->m_Events.AddEvent(new ValithriaDelayedCastEvent(summon, SPELL_SUMMON_DREAM_PORTAL, me->GetGUID(), 6000), summon->m_Events.CalculateTime(15000)); + summon->m_Events.AddEvent(new ValithriaAuraRemoveEvent(summon, SPELL_DREAM_PORTAL_VISUAL_PRE), summon->m_Events.CalculateTime(15000)); } - - void UpdateAI(uint32 diff) override + else if (summon->GetEntry() == NPC_NIGHTMARE_PORTAL_PRE_EFFECT) { - // does not enter combat - if (_instance->GetBossState(DATA_VALITHRIA_DREAMWALKER) != IN_PROGRESS) - return; + summon->m_Events.AddEvent(new ValithriaDelayedCastEvent(summon, SPELL_SUMMON_NIGHTMARE_PORTAL, me->GetGUID(), 6000), summon->m_Events.CalculateTime(15000)); + summon->m_Events.AddEvent(new ValithriaAuraRemoveEvent(summon, SPELL_NIGHTMARE_PORTAL_VISUAL_PRE), summon->m_Events.CalculateTime(15000)); + } + } - _events.Update(diff); + void SummonedCreatureDespawn(Creature* summon) override + { + if (summon->GetEntry() == NPC_DREAM_PORTAL || summon->GetEntry() == NPC_NIGHTMARE_PORTAL) + if (summon->AI()->GetData(MISSED_PORTALS)) + ++_missedPortals; + } - if (me->HasUnitState(UNIT_STATE_CASTING)) - return; + void UpdateAI(uint32 diff) override + { + // does not enter combat + if (_instance->GetBossState(DATA_VALITHRIA_DREAMWALKER) != IN_PROGRESS) + return; - while (uint32 eventId = _events.ExecuteEvent()) - { - switch (eventId) - { - case EVENT_INTRO_TALK: - Talk(SAY_VALITHRIA_ENTER_COMBAT); - break; - case EVENT_BERSERK: - Talk(SAY_VALITHRIA_BERSERK); - break; - case EVENT_DREAM_PORTAL: - if (!IsHeroic()) - Talk(SAY_VALITHRIA_DREAM_PORTAL); - for (uint32 i = 0; i < _portalCount; ++i) - DoCastSelf(SUMMON_PORTAL); - _events.ScheduleEvent(EVENT_DREAM_PORTAL, 45s, 48s); - break; - case EVENT_DREAM_SLIP: - DoCastSelf(SPELL_DREAM_SLIP); - break; - default: - break; - } + _events.Update(diff); - if (me->HasUnitState(UNIT_STATE_CASTING)) - return; - } - } + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; - uint32 GetData(uint32 type) const override + while (uint32 eventId = _events.ExecuteEvent()) { - if (type == MISSED_PORTALS) - return _missedPortals; + switch (eventId) + { + case EVENT_INTRO_TALK: + Talk(SAY_VALITHRIA_ENTER_COMBAT); + break; + case EVENT_BERSERK: + Talk(SAY_VALITHRIA_BERSERK); + break; + case EVENT_DREAM_PORTAL: + if (!IsHeroic()) + Talk(SAY_VALITHRIA_DREAM_PORTAL); + for (uint32 i = 0; i < _portalCount; ++i) + DoCastSelf(SUMMON_PORTAL); + _events.ScheduleEvent(EVENT_DREAM_PORTAL, 45s, 48s); + break; + case EVENT_DREAM_SLIP: + DoCastSelf(SPELL_DREAM_SLIP); + break; + default: + break; + } - return 0; + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; } + } - private: - EventMap _events; - InstanceScript* _instance; - uint32 _spawnHealth; - uint32 const _portalCount; - uint32 _missedPortals; - bool _under25PercentTalkDone; - bool _over75PercentTalkDone; - bool _justDied; - bool _done; - }; - - CreatureAI* GetAI(Creature* creature) const override + uint32 GetData(uint32 type) const override { - return GetIcecrownCitadelAI(creature); + if (type == MISSED_PORTALS) + return _missedPortals; + + return 0; } + + private: + EventMap _events; + InstanceScript* _instance; + uint32 _spawnHealth; + uint32 const _portalCount; + uint32 _missedPortals; + bool _under25PercentTalkDone; + bool _over75PercentTalkDone; + bool _justDied; + bool _done; + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return GetIcecrownCitadelAI(creature); + } }; class npc_green_dragon_combat_trigger : public CreatureScript { - public: - npc_green_dragon_combat_trigger() : CreatureScript("npc_green_dragon_combat_trigger") { } + public: + npc_green_dragon_combat_trigger() : CreatureScript("npc_green_dragon_combat_trigger") + { + } + + struct npc_green_dragon_combat_triggerAI : public BossAI + { + npc_green_dragon_combat_triggerAI(Creature* creature) : BossAI(creature, DATA_VALITHRIA_DREAMWALKER) + { + } - struct npc_green_dragon_combat_triggerAI : public BossAI + void JustAppeared() override { - npc_green_dragon_combat_triggerAI(Creature* creature) : BossAI(creature, DATA_VALITHRIA_DREAMWALKER) - { - } + me->SetReactState(REACT_PASSIVE); + // Setup Archmages + me->SummonCreatureGroup(SUMMON_GROUP_ALL); + if (Is25ManRaid()) + me->SummonCreatureGroup(SUMMON_GROUP_25); + else + me->SummonCreatureGroup(SUMMON_GROUP_10); + + EntryCheckPredicate pred(NPC_RISEN_ARCHMAGE); + summons.DoAction(ACTION_SETUP_ARCHMAGES, pred); + } - void JustAppeared() override - { - me->SetReactState(REACT_PASSIVE); - // Setup Archmages - me->SummonCreatureGroup(SUMMON_GROUP_ALL); - if (Is25ManRaid()) - me->SummonCreatureGroup(SUMMON_GROUP_25); - else - me->SummonCreatureGroup(SUMMON_GROUP_10); - - EntryCheckPredicate pred(NPC_RISEN_ARCHMAGE); - summons.DoAction(ACTION_SETUP_ARCHMAGES, pred); - } + void JustEngagedWith(Unit* /*who*/) override + { + } // JustEnteredCombat is already doing all of this hook's default actions so no need to execute it twice - void JustEngagedWith(Unit* /*who*/) override { } // JustEnteredCombat is already doing all of this hook's default actions so no need to execute it twice + void JustEnteredCombat(Unit* target) override + { + if (IsEngaged()) + return; - void JustEnteredCombat(Unit* target) override + if (!instance->CheckRequiredBosses(DATA_VALITHRIA_DREAMWALKER, target->ToPlayer())) { - if (IsEngaged()) - return; - - if (!instance->CheckRequiredBosses(DATA_VALITHRIA_DREAMWALKER, target->ToPlayer())) - { - EnterEvadeMode(EVADE_REASON_SEQUENCE_BREAK); - instance->DoCastSpellOnPlayers(LIGHT_S_HAMMER_TELEPORT); - return; - } + EnterEvadeMode(EVADE_REASON_SEQUENCE_BREAK); + instance->DoCastSpellOnPlayers(LIGHT_S_HAMMER_TELEPORT); + return; + } - EngagementStart(target); + EngagementStart(target); - me->setActive(true); - me->SetCombatPulseDelay(5); - DoZoneInCombat(); - instance->SetBossState(DATA_VALITHRIA_DREAMWALKER, IN_PROGRESS); - if (Creature* valithria = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_VALITHRIA_DREAMWALKER))) - valithria->AI()->DoAction(ACTION_ENTER_COMBAT); - EntryCheckPredicate pred(NPC_RISEN_ARCHMAGE); - summons.DoAction(ACTION_ENTER_COMBAT, pred); - } + me->setActive(true); + me->SetCombatPulseDelay(5); + DoZoneInCombat(); + instance->SetBossState(DATA_VALITHRIA_DREAMWALKER, IN_PROGRESS); + if (Creature* valithria = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_VALITHRIA_DREAMWALKER))) + valithria->AI()->DoAction(ACTION_ENTER_COMBAT); + EntryCheckPredicate pred(NPC_RISEN_ARCHMAGE); + summons.DoAction(ACTION_ENTER_COMBAT, pred); + } - void JustExitedCombat() override - { - EngagementOver(); + void JustExitedCombat() override + { + EngagementOver(); - me->setActive(false); + me->setActive(false); - // JustExitedCombat is called on death too, so if creature is dead, avoid "respawn" event - if (!me->IsAlive()) - return; - DoAction(ACTION_DEATH); - } + // JustExitedCombat is called on death too, so if creature is dead, avoid "respawn" event + if (!me->IsAlive()) + return; + DoAction(ACTION_DEATH); + } - void DoAction(int32 action) override + void DoAction(int32 action) override + { + if (action == ACTION_DEATH) { - if (action == ACTION_DEATH) - { - instance->SetBossState(DATA_VALITHRIA_DREAMWALKER, NOT_STARTED); - me->m_Events.AddEventAtOffset(new ValithriaDespawner(me), 5s); - if (Creature* lichKing = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_VALITHRIA_LICH_KING))) - lichKing->AI()->EnterEvadeMode(); - } + instance->SetBossState(DATA_VALITHRIA_DREAMWALKER, NOT_STARTED); + me->m_Events.AddEventAtOffset(new ValithriaDespawner(me), 5s); + if (Creature* lichKing = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_VALITHRIA_LICH_KING))) + lichKing->AI()->EnterEvadeMode(); } - }; - - CreatureAI* GetAI(Creature* creature) const override - { - return GetIcecrownCitadelAI(creature); } + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return GetIcecrownCitadelAI(creature); + } }; class npc_the_lich_king_controller : public CreatureScript { - public: - npc_the_lich_king_controller() : CreatureScript("npc_the_lich_king_controller") { } - - struct npc_the_lich_king_controllerAI : public ScriptedAI + public: + npc_the_lich_king_controller() : CreatureScript("npc_the_lich_king_controller") + { + } + + struct npc_the_lich_king_controllerAI : public ScriptedAI + { + npc_the_lich_king_controllerAI(Creature* creature) : ScriptedAI(creature), _instance(creature->GetInstanceScript()) { - npc_the_lich_king_controllerAI(Creature* creature) : ScriptedAI(creature), _instance(creature->GetInstanceScript()) - { - } + } - void Reset() override - { - _events.Reset(); - _events.ScheduleEvent(EVENT_GLUTTONOUS_ABOMINATION_SUMMONER, 5s); - _events.ScheduleEvent(EVENT_SUPPRESSER_SUMMONER, 10s); - _events.ScheduleEvent(EVENT_BLISTERING_ZOMBIE_SUMMONER, 15s); - _events.ScheduleEvent(EVENT_RISEN_ARCHMAGE_SUMMONER, 20s); - _events.ScheduleEvent(EVENT_BLAZING_SKELETON_SUMMONER, 30s); - me->SetReactState(REACT_PASSIVE); - } + void Reset() override + { + _events.Reset(); + _events.ScheduleEvent(EVENT_GLUTTONOUS_ABOMINATION_SUMMONER, 5s); + _events.ScheduleEvent(EVENT_SUPPRESSER_SUMMONER, 10s); + _events.ScheduleEvent(EVENT_BLISTERING_ZOMBIE_SUMMONER, 15s); + _events.ScheduleEvent(EVENT_RISEN_ARCHMAGE_SUMMONER, 20s); + _events.ScheduleEvent(EVENT_BLAZING_SKELETON_SUMMONER, 30s); + me->SetReactState(REACT_PASSIVE); + } - void JustReachedHome() override - { - me->setActive(false); - } + void JustReachedHome() override + { + me->setActive(false); + } - void JustEngagedWith(Unit* /*target*/) override - { - Talk(SAY_LICH_KING_INTRO); - me->setActive(true); - } + void JustEngagedWith(Unit* /*target*/) override + { + Talk(SAY_LICH_KING_INTRO); + me->setActive(true); + } - uint32 GetData(uint32 data) const override - { - if (data == DATA_SUPPRESSERS_COUNT) - return RAID_MODE(4, 6, 4, 6); - else - return 0; - } + uint32 GetData(uint32 data) const override + { + if (data == DATA_SUPPRESSERS_COUNT) + return RAID_MODE(4, 6, 4, 6); + else + return 0; + } - void JustSummoned(Creature* summon) override - { - // must not be in dream phase - PhasingHandler::RemovePhase(summon, 173, true); - DoZoneInCombat(summon); - if (summon->GetEntry() != NPC_SUPPRESSER) - if (Unit* target = me->GetCombatManager().GetAnyTarget()) - summon->AI()->AttackStart(target); - } + void JustSummoned(Creature* summon) override + { + // must not be in dream phase + PhasingHandler::RemovePhase(summon, 173, true); + DoZoneInCombat(summon); + if (summon->GetEntry() != NPC_SUPPRESSER) + if (Unit* target = me->GetCombatManager().GetAnyTarget()) + summon->AI()->AttackStart(target); + } - void UpdateAI(uint32 diff) override - { - if (!UpdateVictim()) - return; + void UpdateAI(uint32 diff) override + { + if (!UpdateVictim()) + return; - _events.Update(diff); + _events.Update(diff); - if (me->HasUnitState(UNIT_STATE_CASTING)) - return; + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; - while (uint32 eventId = _events.ExecuteEvent()) + while (uint32 eventId = _events.ExecuteEvent()) + { + switch (eventId) { - switch (eventId) - { - case EVENT_GLUTTONOUS_ABOMINATION_SUMMONER: - DoCastSelf(SPELL_TIMER_GLUTTONOUS_ABOMINATION); - break; - case EVENT_SUPPRESSER_SUMMONER: - DoCastSelf(SPELL_TIMER_SUPPRESSER); - break; - case EVENT_BLISTERING_ZOMBIE_SUMMONER: - DoCastSelf(SPELL_TIMER_BLISTERING_ZOMBIE); - break; - case EVENT_RISEN_ARCHMAGE_SUMMONER: - DoCastSelf(SPELL_TIMER_RISEN_ARCHMAGE); - break; - case EVENT_BLAZING_SKELETON_SUMMONER: - DoCastSelf(SPELL_TIMER_BLAZING_SKELETON); - break; - default: - break; - } - - if (me->HasUnitState(UNIT_STATE_CASTING)) - return; + case EVENT_GLUTTONOUS_ABOMINATION_SUMMONER: + DoCastSelf(SPELL_TIMER_GLUTTONOUS_ABOMINATION); + break; + case EVENT_SUPPRESSER_SUMMONER: + DoCastSelf(SPELL_TIMER_SUPPRESSER); + break; + case EVENT_BLISTERING_ZOMBIE_SUMMONER: + DoCastSelf(SPELL_TIMER_BLISTERING_ZOMBIE); + break; + case EVENT_RISEN_ARCHMAGE_SUMMONER: + DoCastSelf(SPELL_TIMER_RISEN_ARCHMAGE); + break; + case EVENT_BLAZING_SKELETON_SUMMONER: + DoCastSelf(SPELL_TIMER_BLAZING_SKELETON); + break; + default: + break; } + + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; } + } - private: - EventMap _events; - InstanceScript* _instance; - }; + private: + EventMap _events; + InstanceScript* _instance; + }; - CreatureAI* GetAI(Creature* creature) const override - { - return GetIcecrownCitadelAI(creature); - } + CreatureAI* GetAI(Creature* creature) const override + { + return GetIcecrownCitadelAI(creature); + } }; class npc_risen_archmage : public CreatureScript { - public: - npc_risen_archmage() : CreatureScript("npc_risen_archmage") { } - - struct npc_risen_archmageAI : public ScriptedAI + public: + npc_risen_archmage() : CreatureScript("npc_risen_archmage") + { + } + + struct npc_risen_archmageAI : public ScriptedAI + { + npc_risen_archmageAI(Creature* creature) : ScriptedAI(creature), _instance(creature->GetInstanceScript()) { - npc_risen_archmageAI(Creature* creature) : ScriptedAI(creature), _instance(creature->GetInstanceScript()) - { - Initialize(); - } + Initialize(); + } - void Initialize() - { - _isInitialArchmage = false; - } + void Initialize() + { + _isInitialArchmage = false; + } - bool CanAIAttack(Unit const* target) const override - { - return target->GetEntry() != NPC_VALITHRIA_DREAMWALKER; - } + bool CanAIAttack(Unit const* target) const override + { + return target->GetEntry() != NPC_VALITHRIA_DREAMWALKER; + } - void Reset() override - { - _events.Reset(); - _events.ScheduleEvent(EVENT_FROSTBOLT_VOLLEY, 5s, 15s); - _events.ScheduleEvent(EVENT_MANA_VOID, 20s, 25s); - _events.ScheduleEvent(EVENT_COLUMN_OF_FROST, 10s, 20s); - Initialize(); - } + void Reset() override + { + _events.Reset(); + _events.ScheduleEvent(EVENT_FROSTBOLT_VOLLEY, 5s, 15s); + _events.ScheduleEvent(EVENT_MANA_VOID, 20s, 25s); + _events.ScheduleEvent(EVENT_COLUMN_OF_FROST, 10s, 20s); + Initialize(); + } - void JustEnteredCombat(Unit* who) override - { - if (IsEngaged()) - return; + void JustEnteredCombat(Unit* who) override + { + if (IsEngaged()) + return; - me->InterruptNonMeleeSpells(false); + me->InterruptNonMeleeSpells(false); - EngagementStart(who); + EngagementStart(who); - if (_isInitialArchmage) - { - if (Creature* lichKing = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_VALITHRIA_LICH_KING))) - DoZoneInCombat(lichKing); + if (_isInitialArchmage) + { + if (Creature* lichKing = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_VALITHRIA_LICH_KING))) + DoZoneInCombat(lichKing); - if (Creature* trigger = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_VALITHRIA_TRIGGER))) - DoZoneInCombat(trigger); - } + if (Creature* trigger = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_VALITHRIA_TRIGGER))) + DoZoneInCombat(trigger); } + } + + void DoAction(int32 action) override + { + if (action == ACTION_ENTER_COMBAT) + DoZoneInCombat(); + else if (action == ACTION_SETUP_ARCHMAGES) + _isInitialArchmage = true; + } - void DoAction(int32 action) override + void JustSummoned(Creature* summon) override + { + if (summon->GetEntry() == NPC_COLUMN_OF_FROST) { - if (action == ACTION_ENTER_COMBAT) - DoZoneInCombat(); - else if (action == ACTION_SETUP_ARCHMAGES) - _isInitialArchmage = true; + summon->CastSpell(summon, SPELL_COLUMN_OF_FROST_AURA, true); + summon->m_Events.AddEvent(new ValithriaDelayedCastEvent(summon, SPELL_COLUMN_OF_FROST_DAMAGE, ObjectGuid::Empty, 8000), summon->m_Events.CalculateTime(2000)); } - - void JustSummoned(Creature* summon) override + else if (summon->GetEntry() == NPC_MANA_VOID) { - if (summon->GetEntry() == NPC_COLUMN_OF_FROST) - { - summon->CastSpell(summon, SPELL_COLUMN_OF_FROST_AURA, true); - summon->m_Events.AddEvent(new ValithriaDelayedCastEvent(summon, SPELL_COLUMN_OF_FROST_DAMAGE, ObjectGuid::Empty, 8000), summon->m_Events.CalculateTime(2000)); - } - else if (summon->GetEntry() == NPC_MANA_VOID) - { - summon->CastSpell(summon, SPELL_MANA_VOID_AURA, true); - summon->DespawnOrUnsummon(36000); - } + summon->CastSpell(summon, SPELL_MANA_VOID_AURA, true); + summon->DespawnOrUnsummon(36000); } + } - void UpdateAI(uint32 diff) override - { - if (!me->IsInCombat() && me->IsAlive() && _isInitialArchmage && !me->GetCurrentSpell(CURRENT_CHANNELED_SPELL)) - DoCastSelf(SPELL_CORRUPTION); + void UpdateAI(uint32 diff) override + { + if (!me->IsInCombat() && me->IsAlive() && _isInitialArchmage && !me->GetCurrentSpell(CURRENT_CHANNELED_SPELL)) + DoCastSelf(SPELL_CORRUPTION); - if (!UpdateVictim()) - return; + if (!UpdateVictim()) + return; - _events.Update(diff); + _events.Update(diff); - if (me->HasUnitState(UNIT_STATE_CASTING)) - return; + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; - while (uint32 eventId = _events.ExecuteEvent()) + while (uint32 eventId = _events.ExecuteEvent()) + { + switch (eventId) { - switch (eventId) - { - case EVENT_FROSTBOLT_VOLLEY: - DoCastSelf(SPELL_FROSTBOLT_VOLLEY); - _events.ScheduleEvent(EVENT_FROSTBOLT_VOLLEY, 8s, 15s); - break; - case EVENT_MANA_VOID: - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1, ValithriaManaVoidSelector(me))) - DoCast(target, SPELL_MANA_VOID); - _events.ScheduleEvent(EVENT_MANA_VOID, 20s, 25s); - break; - case EVENT_COLUMN_OF_FROST: - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1, -10.0f, true)) - DoCast(target, SPELL_COLUMN_OF_FROST); - _events.ScheduleEvent(EVENT_COLUMN_OF_FROST, 15s, 25s); - break; - default: - break; - } - - if (me->HasUnitState(UNIT_STATE_CASTING)) - return; + case EVENT_FROSTBOLT_VOLLEY: + DoCastSelf(SPELL_FROSTBOLT_VOLLEY); + _events.ScheduleEvent(EVENT_FROSTBOLT_VOLLEY, 8s, 15s); + break; + case EVENT_MANA_VOID: + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1, ValithriaManaVoidSelector(me))) + DoCast(target, SPELL_MANA_VOID); + _events.ScheduleEvent(EVENT_MANA_VOID, 20s, 25s); + break; + case EVENT_COLUMN_OF_FROST: + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1, -10.0f, true)) + DoCast(target, SPELL_COLUMN_OF_FROST); + _events.ScheduleEvent(EVENT_COLUMN_OF_FROST, 15s, 25s); + break; + default: + break; } - DoMeleeAttackIfReady(); + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; } - private: - EventMap _events; - InstanceScript* _instance; - bool _isInitialArchmage; - }; - - CreatureAI* GetAI(Creature* creature) const override - { - return GetIcecrownCitadelAI(creature); + DoMeleeAttackIfReady(); } + + private: + EventMap _events; + InstanceScript* _instance; + bool _isInitialArchmage; + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return GetIcecrownCitadelAI(creature); + } }; class npc_blazing_skeleton : public CreatureScript { - public: - npc_blazing_skeleton() : CreatureScript("npc_blazing_skeleton") { } - - struct npc_blazing_skeletonAI : public ScriptedAI + public: + npc_blazing_skeleton() : CreatureScript("npc_blazing_skeleton") + { + } + + struct npc_blazing_skeletonAI : public ScriptedAI + { + npc_blazing_skeletonAI(Creature* creature) : ScriptedAI(creature) { - npc_blazing_skeletonAI(Creature* creature) : ScriptedAI(creature) - { - } + } - void Reset() override - { - _events.Reset(); - _events.ScheduleEvent(EVENT_FIREBALL, 2s, 4s); - _events.ScheduleEvent(EVENT_LEY_WASTE, 15s, 20s); - } + void Reset() override + { + _events.Reset(); + _events.ScheduleEvent(EVENT_FIREBALL, 2s, 4s); + _events.ScheduleEvent(EVENT_LEY_WASTE, 15s, 20s); + } - void UpdateAI(uint32 diff) override - { - if (!UpdateVictim()) - return; + void UpdateAI(uint32 diff) override + { + if (!UpdateVictim()) + return; - _events.Update(diff); + _events.Update(diff); - if (me->HasUnitState(UNIT_STATE_CASTING)) - return; + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; - while (uint32 eventId = _events.ExecuteEvent()) + while (uint32 eventId = _events.ExecuteEvent()) + { + switch (eventId) { - switch (eventId) - { - case EVENT_FIREBALL: - if (!me->IsWithinMeleeRange(me->GetVictim())) - DoCastVictim(SPELL_FIREBALL); - _events.ScheduleEvent(EVENT_FIREBALL, 2s, 4s); - break; - case EVENT_LEY_WASTE: - DoCastSelf(SPELL_LEY_WASTE); - _events.ScheduleEvent(EVENT_LEY_WASTE, 15s, 20s); - break; - default: - break; - } - - if (me->HasUnitState(UNIT_STATE_CASTING)) - return; + case EVENT_FIREBALL: + if (!me->IsWithinMeleeRange(me->GetVictim())) + DoCastVictim(SPELL_FIREBALL); + _events.ScheduleEvent(EVENT_FIREBALL, 2s, 4s); + break; + case EVENT_LEY_WASTE: + DoCastSelf(SPELL_LEY_WASTE); + _events.ScheduleEvent(EVENT_LEY_WASTE, 15s, 20s); + break; + default: + break; } - DoMeleeAttackIfReady(); + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; } - private: - EventMap _events; - }; - - CreatureAI* GetAI(Creature* creature) const override - { - return GetIcecrownCitadelAI(creature); + DoMeleeAttackIfReady(); } + + private: + EventMap _events; + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return GetIcecrownCitadelAI(creature); + } }; class npc_suppresser : public CreatureScript { - public: - npc_suppresser() : CreatureScript("npc_suppresser") { } - - struct npc_suppresserAI : public ScriptedAI + public: + npc_suppresser() : CreatureScript("npc_suppresser") + { + } + + struct npc_suppresserAI : public ScriptedAI + { + npc_suppresserAI(Creature* creature) : ScriptedAI(creature), _instance(creature->GetInstanceScript()) { - npc_suppresserAI(Creature* creature) : ScriptedAI(creature), _instance(creature->GetInstanceScript()) - { - } + } - void Reset() override - { - _events.Reset(); - } + void Reset() override + { + _events.Reset(); + } - void IsSummonedBy(Unit* /*summoner*/) override + void IsSummonedBy(Unit* /*summoner*/) override + { + if (Creature* valithria = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_VALITHRIA_DREAMWALKER))) { - if (Creature* valithria = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_VALITHRIA_DREAMWALKER))) - { - me->EngageWithTarget(valithria); - me->GetThreatManager().FixateTarget(valithria); - } - else - me->DespawnOrUnsummon(); + me->EngageWithTarget(valithria); + me->GetThreatManager().FixateTarget(valithria); } + else + me->DespawnOrUnsummon(); + } - void MovementInform(uint32 type, uint32 /*id*/) override - { - if (type == CHASE_MOTION_TYPE) - _events.RescheduleEvent(EVENT_SUPPRESSION, 1); - } + void MovementInform(uint32 type, uint32 /*id*/) override + { + if (type == CHASE_MOTION_TYPE) + _events.RescheduleEvent(EVENT_SUPPRESSION, 1); + } - void UpdateAI(uint32 diff) override - { - if (!UpdateVictim()) - return; + void UpdateAI(uint32 diff) override + { + if (!UpdateVictim()) + return; - _events.Update(diff); + _events.Update(diff); - if (me->HasUnitState(UNIT_STATE_CASTING)) - return; + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; - while (uint32 eventId = _events.ExecuteEvent()) + while (uint32 eventId = _events.ExecuteEvent()) + { + switch (eventId) { - switch (eventId) - { - case EVENT_SUPPRESSION: - DoCastAOE(SPELL_SUPPRESSION); - _events.Repeat(5s); - break; - default: - break; - } + case EVENT_SUPPRESSION: + DoCastAOE(SPELL_SUPPRESSION); + _events.Repeat(5s); + break; + default: + break; } - - DoMeleeAttackIfReady(); } - private: - EventMap _events; - InstanceScript* const _instance; - }; - - CreatureAI* GetAI(Creature* creature) const override - { - return GetIcecrownCitadelAI(creature); + DoMeleeAttackIfReady(); } + + private: + EventMap _events; + InstanceScript* const _instance; + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return GetIcecrownCitadelAI(creature); + } }; class npc_blistering_zombie : public CreatureScript { - public: - npc_blistering_zombie() : CreatureScript("npc_blistering_zombie") { } - - struct npc_blistering_zombieAI : public ScriptedAI + public: + npc_blistering_zombie() : CreatureScript("npc_blistering_zombie") + { + } + + struct npc_blistering_zombieAI : public ScriptedAI + { + npc_blistering_zombieAI(Creature* creature) : ScriptedAI(creature) { - npc_blistering_zombieAI(Creature* creature) : ScriptedAI(creature) - { - } - - void JustDied(Unit* /*killer*/) override - { - DoCastSelf(SPELL_ACID_BURST, true); - } - - void UpdateAI(uint32 /*diff*/) override - { - if (!UpdateVictim()) - return; + } - DoMeleeAttackIfReady(); - } - }; + void JustDied(Unit* /*killer*/) override + { + DoCastSelf(SPELL_ACID_BURST, true); + } - CreatureAI* GetAI(Creature* creature) const override + void UpdateAI(uint32 /*diff*/) override { - return GetIcecrownCitadelAI(creature); + if (!UpdateVictim()) + return; + + DoMeleeAttackIfReady(); } + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return GetIcecrownCitadelAI(creature); + } }; class npc_gluttonous_abomination : public CreatureScript { - public: - npc_gluttonous_abomination() : CreatureScript("npc_gluttonous_abomination") { } - - struct npc_gluttonous_abominationAI : public ScriptedAI + public: + npc_gluttonous_abomination() : CreatureScript("npc_gluttonous_abomination") + { + } + + struct npc_gluttonous_abominationAI : public ScriptedAI + { + npc_gluttonous_abominationAI(Creature* creature) : ScriptedAI(creature) { - npc_gluttonous_abominationAI(Creature* creature) : ScriptedAI(creature) - { - } + } - void Reset() override - { - _events.Reset(); - _events.ScheduleEvent(EVENT_GUT_SPRAY, 10s, 13s); - } + void Reset() override + { + _events.Reset(); + _events.ScheduleEvent(EVENT_GUT_SPRAY, 10s, 13s); + } - void JustDied(Unit* killer) override - { - if (killer && killer->GetEntry() == NPC_VALITHRIA_DREAMWALKER) - return; + void JustDied(Unit* killer) override + { + if (killer && killer->GetEntry() == NPC_VALITHRIA_DREAMWALKER) + return; - DoCastSelf(SPELL_ROT_WORM_SPAWNER, true); - } + DoCastSelf(SPELL_ROT_WORM_SPAWNER, true); + } - void UpdateAI(uint32 diff) override - { - if (!UpdateVictim()) - return; + void UpdateAI(uint32 diff) override + { + if (!UpdateVictim()) + return; - _events.Update(diff); + _events.Update(diff); - if (me->HasUnitState(UNIT_STATE_CASTING)) - return; + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; - while (uint32 eventId = _events.ExecuteEvent()) + while (uint32 eventId = _events.ExecuteEvent()) + { + switch (eventId) { - switch (eventId) - { - case EVENT_GUT_SPRAY: - DoCastSelf(SPELL_GUT_SPRAY); - _events.ScheduleEvent(EVENT_GUT_SPRAY, 10s, 13s); - break; - default: - break; - } + case EVENT_GUT_SPRAY: + DoCastSelf(SPELL_GUT_SPRAY); + _events.ScheduleEvent(EVENT_GUT_SPRAY, 10s, 13s); + break; + default: + break; } - - DoMeleeAttackIfReady(); } - private: - EventMap _events; - }; - - CreatureAI* GetAI(Creature* creature) const override - { - return GetIcecrownCitadelAI(creature); + DoMeleeAttackIfReady(); } + + private: + EventMap _events; + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return GetIcecrownCitadelAI(creature); + } }; class npc_dream_portal : public CreatureScript { - public: - npc_dream_portal() : CreatureScript("npc_dream_portal") { } - - struct npc_dream_portalAI : public CreatureAI + public: + npc_dream_portal() : CreatureScript("npc_dream_portal") + { + } + + struct npc_dream_portalAI : public CreatureAI + { + npc_dream_portalAI(Creature* creature) : CreatureAI(creature), _used(false) { - npc_dream_portalAI(Creature* creature) : CreatureAI(creature), _used(false) - { - } - - void OnSpellClick(Unit* /*clicker*/, bool& spellClickHandled) override - { - if (!spellClickHandled) - return; - - _used = true; - me->DespawnOrUnsummon(); - } + } - uint32 GetData(uint32 type) const override - { - return (type == MISSED_PORTALS && _used) ? 0 : 1; - } + void OnSpellClick(Unit* /*clicker*/, bool& spellClickHandled) override + { + if (!spellClickHandled) + return; - void UpdateAI(uint32 /*diff*/) override - { - UpdateVictim(); - } + _used = true; + me->DespawnOrUnsummon(); + } - private: - bool _used; - }; + uint32 GetData(uint32 type) const override + { + return (type == MISSED_PORTALS && _used) ? 0 : 1; + } - CreatureAI* GetAI(Creature* creature) const override + void UpdateAI(uint32 /*diff*/) override { - return GetIcecrownCitadelAI(creature); + UpdateVictim(); } + + private: + bool _used; + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return GetIcecrownCitadelAI(creature); + } }; class npc_dream_cloud : public CreatureScript { - public: - npc_dream_cloud() : CreatureScript("npc_dream_cloud") { } - - struct npc_dream_cloudAI : public ScriptedAI + public: + npc_dream_cloud() : CreatureScript("npc_dream_cloud") + { + } + + struct npc_dream_cloudAI : public ScriptedAI + { + npc_dream_cloudAI(Creature* creature) : ScriptedAI(creature), _instance(creature->GetInstanceScript()) { - npc_dream_cloudAI(Creature* creature) : ScriptedAI(creature), _instance(creature->GetInstanceScript()) - { - } + } - void Reset() override - { - _events.Reset(); - _events.ScheduleEvent(EVENT_CHECK_PLAYER, 1s); - me->SetCorpseDelay(0); // remove corpse immediately - me->LoadCreaturesAddon(); - } + void Reset() override + { + _events.Reset(); + _events.ScheduleEvent(EVENT_CHECK_PLAYER, 1s); + me->SetCorpseDelay(0); // remove corpse immediately + me->LoadCreaturesAddon(); + } - void UpdateAI(uint32 diff) override - { - // trigger - if (_instance->GetBossState(DATA_VALITHRIA_DREAMWALKER) != IN_PROGRESS) - return; + void UpdateAI(uint32 diff) override + { + // trigger + if (_instance->GetBossState(DATA_VALITHRIA_DREAMWALKER) != IN_PROGRESS) + return; - _events.Update(diff); + _events.Update(diff); - while (uint32 eventId = _events.ExecuteEvent()) + while (uint32 eventId = _events.ExecuteEvent()) + { + switch (eventId) { - switch (eventId) - { - case EVENT_CHECK_PLAYER: - { - Player* player = nullptr; - Firelands::AnyPlayerInObjectRangeCheck check(me, 5.0f); - Firelands::PlayerSearcher searcher(me, player, check); - Cell::VisitWorldObjects(me, searcher, 7.5f); - _events.ScheduleEvent(player ? EVENT_EXPLODE : EVENT_CHECK_PLAYER, 1000); - break; - } - case EVENT_EXPLODE: - me->GetMotionMaster()->MoveIdle(); - // must use originalCaster the same for all clouds to allow stacking - me->CastSpell(me, EMERALD_VIGOR, _instance->GetGuidData(DATA_VALITHRIA_DREAMWALKER)); - me->DespawnOrUnsummon(100); - break; - default: - break; - } + case EVENT_CHECK_PLAYER: + { + Player* player = nullptr; + Firelands::AnyPlayerInObjectRangeCheck check(me, 5.0f); + Firelands::PlayerSearcher searcher(me, player, check); + Cell::VisitWorldObjects(me, searcher, 7.5f); + _events.ScheduleEvent(player ? EVENT_EXPLODE : EVENT_CHECK_PLAYER, 1000); + break; + } + case EVENT_EXPLODE: + me->GetMotionMaster()->MoveIdle(); + // must use originalCaster the same for all clouds to allow stacking + me->CastSpell(me, EMERALD_VIGOR, _instance->GetGuidData(DATA_VALITHRIA_DREAMWALKER)); + me->DespawnOrUnsummon(100); + break; + default: + break; } } + } - private: - EventMap _events; - InstanceScript* _instance; - }; + private: + EventMap _events; + InstanceScript* _instance; + }; - CreatureAI* GetAI(Creature* creature) const override - { - return GetIcecrownCitadelAI(creature); - } + CreatureAI* GetAI(Creature* creature) const override + { + return GetIcecrownCitadelAI(creature); + } }; class spell_dreamwalker_mana_void : public SpellScriptLoader { - public: - spell_dreamwalker_mana_void() : SpellScriptLoader("spell_dreamwalker_mana_void") { } - - class spell_dreamwalker_mana_void_AuraScript : public AuraScript + public: + spell_dreamwalker_mana_void() : SpellScriptLoader("spell_dreamwalker_mana_void") + { + } + + class spell_dreamwalker_mana_void_AuraScript : public AuraScript + { + void PeriodicTick(AuraEffect const* aurEff) { - void PeriodicTick(AuraEffect const* aurEff) - { - // first 3 ticks have amplitude 1 second - // remaining tick every 500ms - if (aurEff->GetTickNumber() <= 5) - if (!(aurEff->GetTickNumber() & 1)) - PreventDefaultAction(); - } - - void Register() override - { - OnEffectPeriodic.Register(&spell_dreamwalker_mana_void_AuraScript::PeriodicTick, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); - } - }; + // first 3 ticks have amplitude 1 second + // remaining tick every 500ms + if (aurEff->GetTickNumber() <= 5) + if (!(aurEff->GetTickNumber() & 1)) + PreventDefaultAction(); + } - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_dreamwalker_mana_void_AuraScript(); + OnEffectPeriodic.Register(&spell_dreamwalker_mana_void_AuraScript::PeriodicTick, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); } + }; + + AuraScript* GetAuraScript() const override + { + return new spell_dreamwalker_mana_void_AuraScript(); + } }; class spell_dreamwalker_decay_periodic_timer : public SpellScriptLoader { - public: - spell_dreamwalker_decay_periodic_timer() : SpellScriptLoader("spell_dreamwalker_decay_periodic_timer") { } - - class spell_dreamwalker_decay_periodic_timer_AuraScript : public AuraScript + public: + spell_dreamwalker_decay_periodic_timer() : SpellScriptLoader("spell_dreamwalker_decay_periodic_timer") + { + } + + class spell_dreamwalker_decay_periodic_timer_AuraScript : public AuraScript + { + bool Load() override { - bool Load() override - { - _decayRate = GetId() != SPELL_TIMER_BLAZING_SKELETON ? 1000 : 5000; - return true; - } - - void DecayPeriodicTimer(AuraEffect* aurEff) - { - int32 timer = aurEff->GetPeriodicTimer(); - if (timer <= 5) - return; - - aurEff->SetPeriodicTimer(timer - _decayRate); - } + _decayRate = GetId() != SPELL_TIMER_BLAZING_SKELETON ? 1000 : 5000; + return true; + } - void Register() override - { - OnEffectUpdatePeriodic.Register(&spell_dreamwalker_decay_periodic_timer_AuraScript::DecayPeriodicTimer, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); - } + void DecayPeriodicTimer(AuraEffect* aurEff) + { + int32 timer = aurEff->GetPeriodicTimer(); + if (timer <= 5) + return; - int32 _decayRate = 0; - }; + aurEff->SetPeriodicTimer(timer - _decayRate); + } - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_dreamwalker_decay_periodic_timer_AuraScript(); + OnEffectUpdatePeriodic.Register(&spell_dreamwalker_decay_periodic_timer_AuraScript::DecayPeriodicTimer, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); } + + int32 _decayRate = 0; + }; + + AuraScript* GetAuraScript() const override + { + return new spell_dreamwalker_decay_periodic_timer_AuraScript(); + } }; class spell_dreamwalker_summoner : public SpellScriptLoader { - public: - spell_dreamwalker_summoner() : SpellScriptLoader("spell_dreamwalker_summoner") { } - - class spell_dreamwalker_summoner_SpellScript : public SpellScript + public: + spell_dreamwalker_summoner() : SpellScriptLoader("spell_dreamwalker_summoner") + { + } + + class spell_dreamwalker_summoner_SpellScript : public SpellScript + { + bool Load() override { - bool Load() override - { - if (!GetCaster()->GetInstanceScript()) - return false; - return true; - } - - void FilterTargets(std::list& targets) - { - targets.remove_if(Firelands::UnitAuraCheck(true, SPELL_RECENTLY_SPAWNED)); - if (targets.empty()) - return; + if (!GetCaster()->GetInstanceScript()) + return false; + return true; + } - WorldObject* target = Firelands::Containers::SelectRandomContainerElement(targets); - targets.clear(); - targets.push_back(target); - } + void FilterTargets(std::list& targets) + { + targets.remove_if(Firelands::UnitAuraCheck(true, SPELL_RECENTLY_SPAWNED)); + if (targets.empty()) + return; - void HandleForceCast(SpellEffIndex effIndex) - { - PreventHitDefaultEffect(effIndex); - if (!GetHitUnit()) - return; + WorldObject* target = Firelands::Containers::SelectRandomContainerElement(targets); + targets.clear(); + targets.push_back(target); + } - GetHitUnit()->CastSpell(GetCaster(), GetSpellInfo()->Effects[effIndex].TriggerSpell, GetCaster()->GetInstanceScript()->GetGuidData(DATA_VALITHRIA_LICH_KING)); - } + void HandleForceCast(SpellEffIndex effIndex) + { + PreventHitDefaultEffect(effIndex); + if (!GetHitUnit()) + return; - void Register() override - { - OnObjectAreaTargetSelect.Register(&spell_dreamwalker_summoner_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENTRY); - OnEffectHitTarget.Register(&spell_dreamwalker_summoner_SpellScript::HandleForceCast, EFFECT_0, SPELL_EFFECT_FORCE_CAST); - } - }; + GetHitUnit()->CastSpell(GetCaster(), GetSpellInfo()->Effects[effIndex].TriggerSpell, GetCaster()->GetInstanceScript()->GetGuidData(DATA_VALITHRIA_LICH_KING)); + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_dreamwalker_summoner_SpellScript(); + OnObjectAreaTargetSelect.Register(&spell_dreamwalker_summoner_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENTRY); + OnEffectHitTarget.Register(&spell_dreamwalker_summoner_SpellScript::HandleForceCast, EFFECT_0, SPELL_EFFECT_FORCE_CAST); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_dreamwalker_summoner_SpellScript(); + } }; class spell_dreamwalker_summon_suppresser : public SpellScriptLoader { - public: - spell_dreamwalker_summon_suppresser() : SpellScriptLoader("spell_dreamwalker_summon_suppresser") { } - - class spell_dreamwalker_summon_suppresser_AuraScript : public AuraScript + public: + spell_dreamwalker_summon_suppresser() : SpellScriptLoader("spell_dreamwalker_summon_suppresser") + { + } + + class spell_dreamwalker_summon_suppresser_AuraScript : public AuraScript + { + bool Validate(SpellInfo const* /*spellInfo*/) override { - bool Validate(SpellInfo const* /*spellInfo*/) override - { - return ValidateSpellInfo({ SPELL_SUMMON_SUPPRESSER }); - } - - void PeriodicTick(AuraEffect const* /*aurEff*/) - { - PreventDefaultAction(); - HandleSummon(GetCaster()); - } + return ValidateSpellInfo({SPELL_SUMMON_SUPPRESSER}); + } - void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - HandleSummon(GetCaster()); - } + void PeriodicTick(AuraEffect const* /*aurEff*/) + { + PreventDefaultAction(); + HandleSummon(GetCaster()); + } - void HandleSummon(Unit* caster) - { - if (!caster || !caster->IsAIEnabled()) - return; + void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + HandleSummon(GetCaster()); + } - std::list summoners; - GetCreatureListWithEntryInGrid(summoners, caster, NPC_WORLD_TRIGGER, 90.0f); - if (summoners.empty()) - return; + void HandleSummon(Unit* caster) + { + if (!caster || !caster->IsAIEnabled()) + return; - uint8 suppresserNumber = caster->GetAI()->GetData(DATA_SUPPRESSERS_COUNT); - for (uint8 i = 0; i < suppresserNumber; ++i) - caster->CastSpell(Firelands::Containers::SelectRandomContainerElement(summoners), SPELL_SUMMON_SUPPRESSER, true); - } + std::list summoners; + GetCreatureListWithEntryInGrid(summoners, caster, NPC_WORLD_TRIGGER, 90.0f); + if (summoners.empty()) + return; - void Register() override - { - OnEffectPeriodic.Register(&spell_dreamwalker_summon_suppresser_AuraScript::PeriodicTick, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); - AfterEffectApply.Register(&spell_dreamwalker_summon_suppresser_AuraScript::OnApply, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL, AURA_EFFECT_HANDLE_REAL); - } - }; + uint8 suppresserNumber = caster->GetAI()->GetData(DATA_SUPPRESSERS_COUNT); + for (uint8 i = 0; i < suppresserNumber; ++i) + caster->CastSpell(Firelands::Containers::SelectRandomContainerElement(summoners), SPELL_SUMMON_SUPPRESSER, true); + } - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_dreamwalker_summon_suppresser_AuraScript(); + OnEffectPeriodic.Register(&spell_dreamwalker_summon_suppresser_AuraScript::PeriodicTick, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); + AfterEffectApply.Register(&spell_dreamwalker_summon_suppresser_AuraScript::OnApply, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL, AURA_EFFECT_HANDLE_REAL); } + }; + + AuraScript* GetAuraScript() const override + { + return new spell_dreamwalker_summon_suppresser_AuraScript(); + } }; class spell_dreamwalker_summon_suppresser_effect : public SpellScriptLoader { - public: - spell_dreamwalker_summon_suppresser_effect() : SpellScriptLoader("spell_dreamwalker_summon_suppresser_effect") { } - - class spell_dreamwalker_summon_suppresser_effect_SpellScript : public SpellScript + public: + spell_dreamwalker_summon_suppresser_effect() : SpellScriptLoader("spell_dreamwalker_summon_suppresser_effect") + { + } + + class spell_dreamwalker_summon_suppresser_effect_SpellScript : public SpellScript + { + bool Load() override { - bool Load() override - { - if (!GetCaster()->GetInstanceScript()) - return false; - return true; - } - - void HandleForceCast(SpellEffIndex effIndex) - { - PreventHitDefaultEffect(effIndex); - if (!GetHitUnit()) - return; + if (!GetCaster()->GetInstanceScript()) + return false; + return true; + } - GetHitUnit()->CastSpell(GetCaster(), GetSpellInfo()->Effects[effIndex].TriggerSpell, GetCaster()->GetInstanceScript()->GetGuidData(DATA_VALITHRIA_LICH_KING)); - } + void HandleForceCast(SpellEffIndex effIndex) + { + PreventHitDefaultEffect(effIndex); + if (!GetHitUnit()) + return; - void Register() override - { - OnEffectHitTarget.Register(&spell_dreamwalker_summon_suppresser_effect_SpellScript::HandleForceCast, EFFECT_0, SPELL_EFFECT_FORCE_CAST); - } - }; + GetHitUnit()->CastSpell(GetCaster(), GetSpellInfo()->Effects[effIndex].TriggerSpell, GetCaster()->GetInstanceScript()->GetGuidData(DATA_VALITHRIA_LICH_KING)); + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_dreamwalker_summon_suppresser_effect_SpellScript(); + OnEffectHitTarget.Register(&spell_dreamwalker_summon_suppresser_effect_SpellScript::HandleForceCast, EFFECT_0, SPELL_EFFECT_FORCE_CAST); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_dreamwalker_summon_suppresser_effect_SpellScript(); + } }; class spell_dreamwalker_summon_dream_portal : public SpellScriptLoader { - public: - spell_dreamwalker_summon_dream_portal() : SpellScriptLoader("spell_dreamwalker_summon_dream_portal") { } - - class spell_dreamwalker_summon_dream_portal_SpellScript : public SpellScript + public: + spell_dreamwalker_summon_dream_portal() : SpellScriptLoader("spell_dreamwalker_summon_dream_portal") + { + } + + class spell_dreamwalker_summon_dream_portal_SpellScript : public SpellScript + { + void HandleScript(SpellEffIndex effIndex) { - void HandleScript(SpellEffIndex effIndex) - { - PreventHitDefaultEffect(effIndex); - if (!GetHitUnit()) - return; - - uint32 spellId = RAND(71301, 72220, 72223, 72225); - GetHitUnit()->CastSpell(GetHitUnit(), spellId, true); - } + PreventHitDefaultEffect(effIndex); + if (!GetHitUnit()) + return; - void Register() override - { - OnEffectHitTarget.Register(&spell_dreamwalker_summon_dream_portal_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - } - }; + uint32 spellId = RAND(71301, 72220, 72223, 72225); + GetHitUnit()->CastSpell(GetHitUnit(), spellId, true); + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_dreamwalker_summon_dream_portal_SpellScript(); + OnEffectHitTarget.Register(&spell_dreamwalker_summon_dream_portal_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_dreamwalker_summon_dream_portal_SpellScript(); + } }; class spell_dreamwalker_summon_nightmare_portal : public SpellScriptLoader { - public: - spell_dreamwalker_summon_nightmare_portal() : SpellScriptLoader("spell_dreamwalker_summon_nightmare_portal") { } - - class spell_dreamwalker_summon_nightmare_portal_SpellScript : public SpellScript + public: + spell_dreamwalker_summon_nightmare_portal() : SpellScriptLoader("spell_dreamwalker_summon_nightmare_portal") + { + } + + class spell_dreamwalker_summon_nightmare_portal_SpellScript : public SpellScript + { + void HandleScript(SpellEffIndex effIndex) { - void HandleScript(SpellEffIndex effIndex) - { - PreventHitDefaultEffect(effIndex); - if (!GetHitUnit()) - return; - - uint32 spellId = RAND(71977, 72481, 72482, 72483); - GetHitUnit()->CastSpell(GetHitUnit(), spellId, true); - } + PreventHitDefaultEffect(effIndex); + if (!GetHitUnit()) + return; - void Register() override - { - OnEffectHitTarget.Register(&spell_dreamwalker_summon_nightmare_portal_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - } - }; + uint32 spellId = RAND(71977, 72481, 72482, 72483); + GetHitUnit()->CastSpell(GetHitUnit(), spellId, true); + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_dreamwalker_summon_nightmare_portal_SpellScript(); + OnEffectHitTarget.Register(&spell_dreamwalker_summon_nightmare_portal_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_dreamwalker_summon_nightmare_portal_SpellScript(); + } }; class spell_dreamwalker_nightmare_cloud : public SpellScriptLoader { - public: - spell_dreamwalker_nightmare_cloud() : SpellScriptLoader("spell_dreamwalker_nightmare_cloud") { } - - class spell_dreamwalker_nightmare_cloud_AuraScript : public AuraScript + public: + spell_dreamwalker_nightmare_cloud() : SpellScriptLoader("spell_dreamwalker_nightmare_cloud") + { + } + + class spell_dreamwalker_nightmare_cloud_AuraScript : public AuraScript + { + public: + spell_dreamwalker_nightmare_cloud_AuraScript() { - public: - spell_dreamwalker_nightmare_cloud_AuraScript() - { - _instance = nullptr; - } - - private: - bool Load() override - { - _instance = GetOwner()->GetInstanceScript(); - return _instance != nullptr; - } - - void PeriodicTick(AuraEffect const* /*aurEff*/) - { - if (_instance->GetBossState(DATA_VALITHRIA_DREAMWALKER) != IN_PROGRESS) - PreventDefaultAction(); - } + _instance = nullptr; + } - void Register() override - { - OnEffectPeriodic.Register(&spell_dreamwalker_nightmare_cloud_AuraScript::PeriodicTick, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); - } + private: + bool Load() override + { + _instance = GetOwner()->GetInstanceScript(); + return _instance != nullptr; + } - InstanceScript* _instance; - }; + void PeriodicTick(AuraEffect const* /*aurEff*/) + { + if (_instance->GetBossState(DATA_VALITHRIA_DREAMWALKER) != IN_PROGRESS) + PreventDefaultAction(); + } - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_dreamwalker_nightmare_cloud_AuraScript(); + OnEffectPeriodic.Register(&spell_dreamwalker_nightmare_cloud_AuraScript::PeriodicTick, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); } + + InstanceScript* _instance; + }; + + AuraScript* GetAuraScript() const override + { + return new spell_dreamwalker_nightmare_cloud_AuraScript(); + } }; class spell_dreamwalker_twisted_nightmares : public SpellScriptLoader { - public: - spell_dreamwalker_twisted_nightmares() : SpellScriptLoader("spell_dreamwalker_twisted_nightmares") { } - - class spell_dreamwalker_twisted_nightmares_SpellScript : public SpellScript + public: + spell_dreamwalker_twisted_nightmares() : SpellScriptLoader("spell_dreamwalker_twisted_nightmares") + { + } + + class spell_dreamwalker_twisted_nightmares_SpellScript : public SpellScript + { + void HandleScript(SpellEffIndex effIndex) { - void HandleScript(SpellEffIndex effIndex) - { - PreventHitDefaultEffect(effIndex); - - if (InstanceScript* instance = GetHitUnit()->GetInstanceScript()) - GetHitUnit()->CastSpell(nullptr, GetSpellInfo()->Effects[effIndex].TriggerSpell, instance->GetGuidData(DATA_VALITHRIA_DREAMWALKER)); - } + PreventHitDefaultEffect(effIndex); - void Register() override - { - OnEffectHitTarget.Register(&spell_dreamwalker_twisted_nightmares_SpellScript::HandleScript, EFFECT_2, SPELL_EFFECT_FORCE_CAST); - } - }; + if (InstanceScript* instance = GetHitUnit()->GetInstanceScript()) + GetHitUnit()->CastSpell(nullptr, GetSpellInfo()->Effects[effIndex].TriggerSpell, instance->GetGuidData(DATA_VALITHRIA_DREAMWALKER)); + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_dreamwalker_twisted_nightmares_SpellScript(); + OnEffectHitTarget.Register(&spell_dreamwalker_twisted_nightmares_SpellScript::HandleScript, EFFECT_2, SPELL_EFFECT_FORCE_CAST); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_dreamwalker_twisted_nightmares_SpellScript(); + } }; class achievement_portal_jockey : public AchievementCriteriaScript { - public: - achievement_portal_jockey() : AchievementCriteriaScript("achievement_portal_jockey") { } - - bool OnCheck(Player* /*source*/, Unit* target) override - { - return target && !target->GetAI()->GetData(MISSED_PORTALS); - } + public: + achievement_portal_jockey() : AchievementCriteriaScript("achievement_portal_jockey") + { + } + + bool OnCheck(Player* /*source*/, Unit* target) override + { + return target && !target->GetAI()->GetData(MISSED_PORTALS); + } }; void AddSC_boss_valithria_dreamwalker() diff --git a/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp b/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp index faeb6c65..6285ab29 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp @@ -771,7 +771,7 @@ class boss_sister_svalna : public CreatureScript switch (spell->Id) { case SPELL_IMPALING_SPEAR_KILL: - me->Kill(target); + Unit::Kill(me, target); break; case SPELL_IMPALING_SPEAR: if (TempSummon* summon = target->SummonCreature(NPC_IMPALING_SPEAR, *target)) diff --git a/src/server/scripts/Northrend/IsleOfConquest/boss_ioc_horde_alliance.cpp b/src/server/scripts/Northrend/IsleOfConquest/boss_ioc_horde_alliance.cpp index f1a92d46..8b3c8824 100644 --- a/src/server/scripts/Northrend/IsleOfConquest/boss_ioc_horde_alliance.cpp +++ b/src/server/scripts/Northrend/IsleOfConquest/boss_ioc_horde_alliance.cpp @@ -15,34 +15,38 @@ * with this program. If not, see . */ +#include "BattlegroundIC.h" #include "ScriptMgr.h" #include "ScriptedCreature.h" -#include "BattlegroundIC.h" enum BossSpells { - SPELL_BRUTAL_STRIKE = 58460, - SPELL_DAGGER_THROW = 67280, - SPELL_CRUSHING_LEAP = 68506, - SPELL_RAGE = 66776 + SPELL_BRUTAL_STRIKE = 58460, + SPELL_DAGGER_THROW = 67280, + SPELL_CRUSHING_LEAP = 68506, + SPELL_RAGE = 66776 }; enum BossEvents { - EVENT_BRUTAL_STRIKE = 1, - EVENT_DAGGER_THROW = 2, - EVENT_CRUSHING_LEAP = 3, - EVENT_CHECK_RANGE = 4 + EVENT_BRUTAL_STRIKE = 1, + EVENT_DAGGER_THROW = 2, + EVENT_CRUSHING_LEAP = 3, + EVENT_CHECK_RANGE = 4 }; class boss_ioc_horde_alliance : public CreatureScript { -public: - boss_ioc_horde_alliance() : CreatureScript("boss_ioc_horde_alliance") { } + public: + boss_ioc_horde_alliance() : CreatureScript("boss_ioc_horde_alliance") + { + } struct boss_ioc_horde_allianceAI : public ScriptedAI { - boss_ioc_horde_allianceAI(Creature* creature) : ScriptedAI(creature) { } + boss_ioc_horde_allianceAI(Creature* creature) : ScriptedAI(creature) + { + } void Reset() override { @@ -63,15 +67,15 @@ class boss_ioc_horde_alliance : public CreatureScript void JustEngagedWith(Unit* /*who*/) override { _events.ScheduleEvent(EVENT_BRUTAL_STRIKE, 5 * IN_MILLISECONDS); - _events.ScheduleEvent(EVENT_DAGGER_THROW, 7 * IN_MILLISECONDS); - _events.ScheduleEvent(EVENT_CHECK_RANGE, 1 * IN_MILLISECONDS); + _events.ScheduleEvent(EVENT_DAGGER_THROW, 7 * IN_MILLISECONDS); + _events.ScheduleEvent(EVENT_CHECK_RANGE, 1 * IN_MILLISECONDS); _events.ScheduleEvent(EVENT_CRUSHING_LEAP, 15 * IN_MILLISECONDS); } void SpellHit(Unit* caster, SpellInfo const* /*spell*/) override { if (caster->IsVehicle()) - me->Kill(caster); + Unit::Kill(me, caster); } void UpdateAI(uint32 diff) override @@ -88,35 +92,35 @@ class boss_ioc_horde_alliance : public CreatureScript { switch (eventId) { - case EVENT_BRUTAL_STRIKE: - DoCastVictim(SPELL_BRUTAL_STRIKE); - _events.ScheduleEvent(EVENT_BRUTAL_STRIKE, 5 * IN_MILLISECONDS); - break; - case EVENT_DAGGER_THROW: - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1)) - DoCast(target, SPELL_DAGGER_THROW); - _events.ScheduleEvent(EVENT_DAGGER_THROW, 7 * IN_MILLISECONDS); - break; - case EVENT_CRUSHING_LEAP: - DoCastVictim(SPELL_CRUSHING_LEAP); - _events.ScheduleEvent(EVENT_CRUSHING_LEAP, 25 * IN_MILLISECONDS); - break; - case EVENT_CHECK_RANGE: - if (me->GetDistance(me->GetHomePosition()) > 25.0f) - DoCast(me, SPELL_RAGE); - else - me->RemoveAurasDueToSpell(SPELL_RAGE); - _events.ScheduleEvent(EVENT_CHECK_RANGE, 1 * IN_MILLISECONDS); - break; - default: - break; + case EVENT_BRUTAL_STRIKE: + DoCastVictim(SPELL_BRUTAL_STRIKE); + _events.ScheduleEvent(EVENT_BRUTAL_STRIKE, 5 * IN_MILLISECONDS); + break; + case EVENT_DAGGER_THROW: + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1)) + DoCast(target, SPELL_DAGGER_THROW); + _events.ScheduleEvent(EVENT_DAGGER_THROW, 7 * IN_MILLISECONDS); + break; + case EVENT_CRUSHING_LEAP: + DoCastVictim(SPELL_CRUSHING_LEAP); + _events.ScheduleEvent(EVENT_CRUSHING_LEAP, 25 * IN_MILLISECONDS); + break; + case EVENT_CHECK_RANGE: + if (me->GetDistance(me->GetHomePosition()) > 25.0f) + DoCast(me, SPELL_RAGE); + else + me->RemoveAurasDueToSpell(SPELL_RAGE); + _events.ScheduleEvent(EVENT_CHECK_RANGE, 1 * IN_MILLISECONDS); + break; + default: + break; } } DoMeleeAttackIfReady(); } - private: + private: EventMap _events; }; diff --git a/src/server/scripts/Northrend/Naxxramas/boss_faerlina.cpp b/src/server/scripts/Northrend/Naxxramas/boss_faerlina.cpp index fbeb016b..38a6e8cb 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_faerlina.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_faerlina.cpp @@ -15,268 +15,277 @@ * with this program. If not, see . */ -#include "ScriptMgr.h" #include "InstanceScript.h" -#include "naxxramas.h" #include "ObjectAccessor.h" #include "Player.h" +#include "ScriptMgr.h" #include "ScriptedCreature.h" #include "SpellAuras.h" #include "SpellInfo.h" +#include "naxxramas.h" enum Yells { - SAY_GREET = 0, - SAY_AGGRO = 1, - SAY_SLAY = 2, - SAY_DEATH = 3, + SAY_GREET = 0, + SAY_AGGRO = 1, + SAY_SLAY = 2, + SAY_DEATH = 3, EMOTE_WIDOW_EMBRACE = 4, - EMOTE_FRENZY = 5 - + EMOTE_FRENZY = 5 }; enum Spells { - SPELL_POISON_BOLT_VOLLEY = 28796, - SPELL_RAIN_OF_FIRE = 28794, - SPELL_FRENZY = 28798, - SPELL_WIDOWS_EMBRACE = 28732, + SPELL_POISON_BOLT_VOLLEY = 28796, + SPELL_RAIN_OF_FIRE = 28794, + SPELL_FRENZY = 28798, + SPELL_WIDOWS_EMBRACE = 28732, - SPELL_ADD_FIREBALL = 54095 // 25-man: 54096 + SPELL_ADD_FIREBALL = 54095 // 25-man: 54096 }; #define SPELL_WIDOWS_EMBRACE_HELPER RAID_MODE(28732, 54097) enum Events { - EVENT_POISON = 1, - EVENT_FIRE = 2, - EVENT_FRENZY = 3 + EVENT_POISON = 1, + EVENT_FIRE = 2, + EVENT_FRENZY = 3 }; enum SummonGroups { - SUMMON_GROUP_WORSHIPPERS = 1, - SUMMON_GROUP_FOLLOWERS = 2 + SUMMON_GROUP_WORSHIPPERS = 1, + SUMMON_GROUP_FOLLOWERS = 2 }; enum Misc { - DATA_FRENZY_DISPELS = 1 + DATA_FRENZY_DISPELS = 1 }; class boss_faerlina : public CreatureScript { - public: - boss_faerlina() : CreatureScript("boss_faerlina") { } - - struct boss_faerlinaAI : public BossAI + public: + boss_faerlina() : CreatureScript("boss_faerlina") + { + } + + struct boss_faerlinaAI : public BossAI + { + boss_faerlinaAI(Creature* creature) : BossAI(creature, BOSS_FAERLINA), _frenzyDispels(0) { - boss_faerlinaAI(Creature* creature) : BossAI(creature, BOSS_FAERLINA), _frenzyDispels(0) { } - - void SummonAdds() - { - me->SummonCreatureGroup(SUMMON_GROUP_WORSHIPPERS); - if (Is25ManRaid()) - me->SummonCreatureGroup(SUMMON_GROUP_FOLLOWERS); - } + } - void InitializeAI() override - { - if (!me->isDead() && instance->GetBossState(BOSS_FAERLINA) != DONE) - { - Reset(); - SummonAdds(); - } - } + void SummonAdds() + { + me->SummonCreatureGroup(SUMMON_GROUP_WORSHIPPERS); + if (Is25ManRaid()) + me->SummonCreatureGroup(SUMMON_GROUP_FOLLOWERS); + } - void JustReachedHome() override + void InitializeAI() override + { + if (!me->isDead() && instance->GetBossState(BOSS_FAERLINA) != DONE) { - _JustReachedHome(); + Reset(); SummonAdds(); } + } - void JustEngagedWith(Unit* who) override - { - BossAI::JustEngagedWith(who); - Talk(SAY_AGGRO); - summons.DoZoneInCombat(); - events.ScheduleEvent(EVENT_POISON, randtime(Seconds(10), Seconds(15))); - events.ScheduleEvent(EVENT_FIRE, randtime(Seconds(6), Seconds(18))); - events.ScheduleEvent(EVENT_FRENZY, Minutes(1)+randtime(0s, Seconds(20))); - } + void JustReachedHome() override + { + _JustReachedHome(); + SummonAdds(); + } - void Reset() override - { - _Reset(); - _frenzyDispels = 0; - } + void JustEngagedWith(Unit* who) override + { + BossAI::JustEngagedWith(who); + Talk(SAY_AGGRO); + summons.DoZoneInCombat(); + events.ScheduleEvent(EVENT_POISON, randtime(Seconds(10), Seconds(15))); + events.ScheduleEvent(EVENT_FIRE, randtime(Seconds(6), Seconds(18))); + events.ScheduleEvent(EVENT_FRENZY, Minutes(1) + randtime(0s, Seconds(20))); + } - void KilledUnit(Unit* victim) override - { - if (victim->GetTypeId() == TYPEID_PLAYER) - Talk(SAY_SLAY); - } + void Reset() override + { + _Reset(); + _frenzyDispels = 0; + } - void JustDied(Unit* /*killer*/) override - { - _JustDied(); - Talk(SAY_DEATH); - } + void KilledUnit(Unit* victim) override + { + if (victim->GetTypeId() == TYPEID_PLAYER) + Talk(SAY_SLAY); + } - void SpellHit(Unit* caster, SpellInfo const* spell) override + void JustDied(Unit* /*killer*/) override + { + _JustDied(); + Talk(SAY_DEATH); + } + + void SpellHit(Unit* caster, SpellInfo const* spell) override + { + if (spell->Id == SPELL_WIDOWS_EMBRACE_HELPER) { - if (spell->Id == SPELL_WIDOWS_EMBRACE_HELPER) - { - ++_frenzyDispels; - Talk(EMOTE_WIDOW_EMBRACE, caster); - me->Kill(caster); - } + ++_frenzyDispels; + Talk(EMOTE_WIDOW_EMBRACE, caster); + Unit::Kill(me, caster); } + } - uint32 GetData(uint32 type) const override - { - if (type == DATA_FRENZY_DISPELS) - return _frenzyDispels; + uint32 GetData(uint32 type) const override + { + if (type == DATA_FRENZY_DISPELS) + return _frenzyDispels; - return 0; - } + return 0; + } - void UpdateAI(uint32 diff) override - { - if (!UpdateVictim()) - return; + void UpdateAI(uint32 diff) override + { + if (!UpdateVictim()) + return; - events.Update(diff); + events.Update(diff); - if (me->HasUnitState(UNIT_STATE_CASTING)) - return; + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; - while (uint32 eventId = events.ExecuteEvent()) + while (uint32 eventId = events.ExecuteEvent()) + { + switch (eventId) { - switch (eventId) + case EVENT_POISON: + if (!me->HasAura(SPELL_WIDOWS_EMBRACE_HELPER)) + DoCastAOE(SPELL_POISON_BOLT_VOLLEY); + events.Repeat(randtime(Seconds(8), Seconds(15))); + break; + case EVENT_FIRE: + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) + DoCast(target, SPELL_RAIN_OF_FIRE); + events.Repeat(randtime(Seconds(6), Seconds(18))); + break; + case EVENT_FRENZY: + if (Aura* widowsEmbrace = me->GetAura(SPELL_WIDOWS_EMBRACE_HELPER)) + events.ScheduleEvent(EVENT_FRENZY, Milliseconds(widowsEmbrace->GetDuration() + 1)); + else { - case EVENT_POISON: - if (!me->HasAura(SPELL_WIDOWS_EMBRACE_HELPER)) - DoCastAOE(SPELL_POISON_BOLT_VOLLEY); - events.Repeat(randtime(Seconds(8), Seconds(15))); - break; - case EVENT_FIRE: - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) - DoCast(target, SPELL_RAIN_OF_FIRE); - events.Repeat(randtime(Seconds(6), Seconds(18))); - break; - case EVENT_FRENZY: - if (Aura* widowsEmbrace = me->GetAura(SPELL_WIDOWS_EMBRACE_HELPER)) - events.ScheduleEvent(EVENT_FRENZY, Milliseconds(widowsEmbrace->GetDuration()+1)); - else - { - DoCast(SPELL_FRENZY); - Talk(EMOTE_FRENZY); - events.Repeat(Minutes(1) + randtime(0s, Seconds(20))); - } - break; + DoCast(SPELL_FRENZY); + Talk(EMOTE_FRENZY); + events.Repeat(Minutes(1) + randtime(0s, Seconds(20))); } - - if (me->HasUnitState(UNIT_STATE_CASTING)) - return; + break; } - DoMeleeAttackIfReady(); + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; } - private: - uint32 _frenzyDispels; - }; - - CreatureAI* GetAI(Creature* creature) const override - { - return GetNaxxramasAI(creature); + DoMeleeAttackIfReady(); } + + private: + uint32 _frenzyDispels; + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return GetNaxxramasAI(creature); + } }; class npc_faerlina_add : public CreatureScript { - public: - npc_faerlina_add() : CreatureScript("npc_faerlina_add") { } + public: + npc_faerlina_add() : CreatureScript("npc_faerlina_add") + { + } + + struct npc_faerlina_addAI : public ScriptedAI + { + npc_faerlina_addAI(Creature* creature) : ScriptedAI(creature), _instance(creature->GetInstanceScript()) + { + } - struct npc_faerlina_addAI : public ScriptedAI + void Reset() override { - npc_faerlina_addAI(Creature* creature) : ScriptedAI(creature), - _instance(creature->GetInstanceScript()) + if (!Is25ManRaid()) { + me->ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_BIND, true); + me->ApplySpellImmune(0, IMMUNITY_MECHANIC, MECHANIC_CHARM, true); } + } - void Reset() override - { - if (!Is25ManRaid()) { - me->ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_BIND, true); - me->ApplySpellImmune(0, IMMUNITY_MECHANIC, MECHANIC_CHARM, true); - } - } + void JustEngagedWith(Unit* /*who*/) override + { + if (Creature* faerlina = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_FAERLINA))) + faerlina->AI()->DoZoneInCombat(); + } - void JustEngagedWith(Unit* /*who*/) override - { + void JustDied(Unit* /*killer*/) override + { + if (!Is25ManRaid()) if (Creature* faerlina = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_FAERLINA))) - faerlina->AI()->DoZoneInCombat(); - } - - void JustDied(Unit* /*killer*/) override - { - if (!Is25ManRaid()) - if (Creature* faerlina = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_FAERLINA))) - DoCast(faerlina, SPELL_WIDOWS_EMBRACE); - } + DoCast(faerlina, SPELL_WIDOWS_EMBRACE); + } - void UpdateAI(uint32 /*diff*/) override - { - if (!UpdateVictim()) - return; - if (me->HasUnitState(UNIT_STATE_CASTING)) - return; + void UpdateAI(uint32 /*diff*/) override + { + if (!UpdateVictim()) + return; + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; - DoCastVictim(SPELL_ADD_FIREBALL); - DoMeleeAttackIfReady(); // this will only happen if the fireball cast fails for some reason - } + DoCastVictim(SPELL_ADD_FIREBALL); + DoMeleeAttackIfReady(); // this will only happen if the fireball cast fails for some reason + } - private: - InstanceScript* const _instance; - }; + private: + InstanceScript* const _instance; + }; - CreatureAI* GetAI(Creature* creature) const override - { - return GetNaxxramasAI(creature); - } + CreatureAI* GetAI(Creature* creature) const override + { + return GetNaxxramasAI(creature); + } }; class achievement_momma_said_knock_you_out : public AchievementCriteriaScript { - public: - achievement_momma_said_knock_you_out() : AchievementCriteriaScript("achievement_momma_said_knock_you_out") { } - - bool OnCheck(Player* /*source*/, Unit* target) override - { - return target && !target->GetAI()->GetData(DATA_FRENZY_DISPELS); - } + public: + achievement_momma_said_knock_you_out() : AchievementCriteriaScript("achievement_momma_said_knock_you_out") + { + } + + bool OnCheck(Player* /*source*/, Unit* target) override + { + return target && !target->GetAI()->GetData(DATA_FRENZY_DISPELS); + } }; class at_faerlina_entrance : public OnlyOnceAreaTriggerScript { - public: - at_faerlina_entrance() : OnlyOnceAreaTriggerScript("at_faerlina_entrance") { } - - bool _OnTrigger(Player* player, AreaTriggerEntry const* /*areaTrigger*/) override - { - InstanceScript* instance = player->GetInstanceScript(); - if (!instance || instance->GetBossState(BOSS_FAERLINA) != NOT_STARTED) - return true; + public: + at_faerlina_entrance() : OnlyOnceAreaTriggerScript("at_faerlina_entrance") + { + } + + bool _OnTrigger(Player* player, AreaTriggerEntry const* /*areaTrigger*/) override + { + InstanceScript* instance = player->GetInstanceScript(); + if (!instance || instance->GetBossState(BOSS_FAERLINA) != NOT_STARTED) + return true; - if (Creature* faerlina = ObjectAccessor::GetCreature(*player, instance->GetGuidData(DATA_FAERLINA))) - faerlina->AI()->Talk(SAY_GREET); + if (Creature* faerlina = ObjectAccessor::GetCreature(*player, instance->GetGuidData(DATA_FAERLINA))) + faerlina->AI()->Talk(SAY_GREET); - return true; - } + return true; + } }; void AddSC_boss_faerlina() diff --git a/src/server/scripts/Northrend/Ulduar/HallsOfStone/halls_of_stone.cpp b/src/server/scripts/Northrend/Ulduar/HallsOfStone/halls_of_stone.cpp index 77141e0f..ec21b19c 100644 --- a/src/server/scripts/Northrend/Ulduar/HallsOfStone/halls_of_stone.cpp +++ b/src/server/scripts/Northrend/Ulduar/HallsOfStone/halls_of_stone.cpp @@ -15,126 +15,126 @@ * with this program. If not, see . */ -#include "ScriptMgr.h" #include "halls_of_stone.h" #include "InstanceScript.h" #include "ObjectAccessor.h" #include "Player.h" +#include "ScriptMgr.h" #include "ScriptedEscortAI.h" #include "ScriptedGossip.h" #include "TemporarySummon.h" enum Texts { - SAY_KILL = 0, - SAY_LOW_HEALTH = 1, - SAY_DEATH = 2, - SAY_PLAYER_DEATH = 3, - SAY_ESCORT_START = 4, - - SAY_SPAWN_DWARF = 5, - SAY_SPAWN_TROGG = 6, - SAY_SPAWN_OOZE = 7, - SAY_SPAWN_EARTHEN = 8, - - SAY_EVENT_INTRO_1 = 9, - SAY_EVENT_INTRO_2 = 10, - SAY_EVENT_A_1 = 11, - SAY_EVENT_A_3 = 12, - SAY_EVENT_B_1 = 13, - SAY_EVENT_B_3 = 14, - SAY_EVENT_C_1 = 15, - SAY_EVENT_C_3 = 16, - SAY_EVENT_D_1 = 17, - SAY_EVENT_D_3 = 18, - - SAY_EVENT_END_01 = 19, - SAY_EVENT_END_02 = 20, - SAY_EVENT_END_04 = 21, - SAY_EVENT_END_06 = 22, - SAY_EVENT_END_08 = 23, - SAY_EVENT_END_10 = 24, - SAY_EVENT_END_12 = 25, - SAY_EVENT_END_14 = 26, - SAY_EVENT_END_16 = 27, - SAY_EVENT_END_18 = 28, - SAY_EVENT_END_20 = 29, - - SAY_VICTORY_SJONNIR_1 = 30, - SAY_VICTORY_SJONNIR_2 = 31, - SAY_ENTRANCE_MEET = 32, - - SAY_EVENT_INTRO_3_ABED = 0, - SAY_EVENT_C_2_ABED = 1, - SAY_EVENT_D_2_ABED = 2, - SAY_EVENT_D_4_ABED = 3, - SAY_EVENT_END_03_ABED = 4, - SAY_EVENT_END_05_ABED = 5, - SAY_EVENT_END_07_ABED = 6, - SAY_EVENT_END_21_ABED = 7, - - SAY_EVENT_A_2_KADD = 0, - SAY_EVENT_END_09_KADD = 1, - SAY_EVENT_END_11_KADD = 2, - SAY_EVENT_END_13_KADD = 3, - - SAY_EVENT_B_2_MARN = 0, - SAY_EVENT_END_15_MARN = 1, - SAY_EVENT_END_17_MARN = 2, - SAY_EVENT_END_19_MARN = 3, - - TEXT_ID_START = 13100, - TEXT_ID_PROGRESS = 13101 + SAY_KILL = 0, + SAY_LOW_HEALTH = 1, + SAY_DEATH = 2, + SAY_PLAYER_DEATH = 3, + SAY_ESCORT_START = 4, + + SAY_SPAWN_DWARF = 5, + SAY_SPAWN_TROGG = 6, + SAY_SPAWN_OOZE = 7, + SAY_SPAWN_EARTHEN = 8, + + SAY_EVENT_INTRO_1 = 9, + SAY_EVENT_INTRO_2 = 10, + SAY_EVENT_A_1 = 11, + SAY_EVENT_A_3 = 12, + SAY_EVENT_B_1 = 13, + SAY_EVENT_B_3 = 14, + SAY_EVENT_C_1 = 15, + SAY_EVENT_C_3 = 16, + SAY_EVENT_D_1 = 17, + SAY_EVENT_D_3 = 18, + + SAY_EVENT_END_01 = 19, + SAY_EVENT_END_02 = 20, + SAY_EVENT_END_04 = 21, + SAY_EVENT_END_06 = 22, + SAY_EVENT_END_08 = 23, + SAY_EVENT_END_10 = 24, + SAY_EVENT_END_12 = 25, + SAY_EVENT_END_14 = 26, + SAY_EVENT_END_16 = 27, + SAY_EVENT_END_18 = 28, + SAY_EVENT_END_20 = 29, + + SAY_VICTORY_SJONNIR_1 = 30, + SAY_VICTORY_SJONNIR_2 = 31, + SAY_ENTRANCE_MEET = 32, + + SAY_EVENT_INTRO_3_ABED = 0, + SAY_EVENT_C_2_ABED = 1, + SAY_EVENT_D_2_ABED = 2, + SAY_EVENT_D_4_ABED = 3, + SAY_EVENT_END_03_ABED = 4, + SAY_EVENT_END_05_ABED = 5, + SAY_EVENT_END_07_ABED = 6, + SAY_EVENT_END_21_ABED = 7, + + SAY_EVENT_A_2_KADD = 0, + SAY_EVENT_END_09_KADD = 1, + SAY_EVENT_END_11_KADD = 2, + SAY_EVENT_END_13_KADD = 3, + + SAY_EVENT_B_2_MARN = 0, + SAY_EVENT_END_15_MARN = 1, + SAY_EVENT_END_17_MARN = 2, + SAY_EVENT_END_19_MARN = 3, + + TEXT_ID_START = 13100, + TEXT_ID_PROGRESS = 13101 }; enum Creatures { - NPC_TRIBUNAL_OF_THE_AGES = 28234, - NPC_BRANN_BRONZEBEARD = 28070, - NPC_DARK_MATTER_TARGET = 28237, - NPC_SEARING_GAZE_TARGET = 28265, - NPC_DARK_RUNE_PROTECTOR = 27983, - NPC_DARK_RUNE_STORMCALLER = 27984, - NPC_IRON_GOLEM_CUSTODIAN = 27985, + NPC_TRIBUNAL_OF_THE_AGES = 28234, + NPC_BRANN_BRONZEBEARD = 28070, + NPC_DARK_MATTER_TARGET = 28237, + NPC_SEARING_GAZE_TARGET = 28265, + NPC_DARK_RUNE_PROTECTOR = 27983, + NPC_DARK_RUNE_STORMCALLER = 27984, + NPC_IRON_GOLEM_CUSTODIAN = 27985, }; enum Spells { - SPELL_STEALTH = 58506, + SPELL_STEALTH = 58506, // Kadrak - SPELL_GLARE_OF_THE_TRIBUNAL = 50988, + SPELL_GLARE_OF_THE_TRIBUNAL = 50988, // Marnak - SPELL_DARK_MATTER = 51012, + SPELL_DARK_MATTER = 51012, // Abedneum - SPELL_SEARING_GAZE = 51136, + SPELL_SEARING_GAZE = 51136, - SPELL_REWARD_ACHIEVEMENT = 59046, + SPELL_REWARD_ACHIEVEMENT = 59046, }; enum Misc { - QUEST_HALLS_OF_STONE = 13207, - - DATA_BRANN_SPARKLIN_NEWS = 1 + QUEST_HALLS_OF_STONE = 13207, + DATA_BRANN_SPARKLIN_NEWS = 1 }; -#define GOSSIP_ITEM_START "Brann, it would be our honor!" -#define GOSSIP_ITEM_PROGRESS "Let's move Brann, enough of the history lessons!" +#define GOSSIP_ITEM_START "Brann, it would be our honor!" +#define GOSSIP_ITEM_PROGRESS "Let's move Brann, enough of the history lessons!" -static Position SpawnLocations[]= -{ +static Position SpawnLocations[] = { {946.992f, 397.016f, 208.374f, 0.0f}, {960.748f, 382.944f, 208.374f, 0.0f}, }; class npc_tribuna_controller : public CreatureScript { -public: - npc_tribuna_controller() : CreatureScript("npc_tribuna_controller") { } + public: + npc_tribuna_controller() : CreatureScript("npc_tribuna_controller") + { + } struct npc_tribuna_controllerAI : public ScriptedAI { @@ -223,7 +223,9 @@ class npc_tribuna_controller : public CreatureScript } } uiKaddrakEncounterTimer = 1500; - } else uiKaddrakEncounterTimer -= diff; + } + else + uiKaddrakEncounterTimer -= diff; } if (bMarnakActivated) { @@ -239,7 +241,9 @@ class npc_tribuna_controller : public CreatureScript } } uiMarnakEncounterTimer = urand(30000, 31000); - } else uiMarnakEncounterTimer -= diff; + } + else + uiMarnakEncounterTimer -= diff; } if (bAbedneumActivated) { @@ -247,7 +251,8 @@ class npc_tribuna_controller : public CreatureScript { if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true)) { - if (Creature* summon = me->SummonCreature(NPC_SEARING_GAZE_TARGET, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0.0f, TEMPSUMMON_TIMED_DESPAWN, 1000)) + if (Creature* summon = + me->SummonCreature(NPC_SEARING_GAZE_TARGET, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0.0f, TEMPSUMMON_TIMED_DESPAWN, 1000)) { summon->SetDisplayId(11686); summon->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); @@ -255,7 +260,9 @@ class npc_tribuna_controller : public CreatureScript } } uiAbedneumEncounterTimer = urand(30000, 31000); - } else uiAbedneumEncounterTimer -= diff; + } + else + uiAbedneumEncounterTimer -= diff; } } }; @@ -268,8 +275,10 @@ class npc_tribuna_controller : public CreatureScript class npc_brann_hos : public CreatureScript { -public: - npc_brann_hos() : CreatureScript("npc_brann_hos") { } + public: + npc_brann_hos() : CreatureScript("npc_brann_hos") + { + } struct npc_brann_hosAI : public EscortAI { @@ -354,56 +363,56 @@ class npc_brann_hos : public CreatureScript { switch (waypointId) { - case 7: - if (Creature* creature = GetClosestCreatureWithEntry(me, NPC_TRIBUNAL_OF_THE_AGES, 100.0f)) - { - if (!creature->IsAlive()) - creature->Respawn(); - ENSURE_AI(npc_tribuna_controller::npc_tribuna_controllerAI, creature->AI())->UpdateFacesList(); - uiControllerGUID = creature->GetGUID(); - } - break; - case 13: - Talk(SAY_EVENT_INTRO_1); - instance->SetBossState(DATA_TRIBUNAL_OF_AGES, IN_PROGRESS); - SetEscortPaused(true); - JumpToNextStep(20000); - // @todo: There should be a pause here and a gossip should start the next step. - break; - case 17: - Talk(SAY_EVENT_INTRO_2); - instance->HandleGameObject(instance->GetGuidData(DATA_GO_TRIBUNAL_CONSOLE), true); - me->SetStandState(UNIT_STAND_STATE_KNEEL); - SetEscortPaused(true); - JumpToNextStep(8500); - break; - case 18: - SetEscortPaused(true); - break; + case 7: + if (Creature* creature = GetClosestCreatureWithEntry(me, NPC_TRIBUNAL_OF_THE_AGES, 100.0f)) + { + if (!creature->IsAlive()) + creature->Respawn(); + ENSURE_AI(npc_tribuna_controller::npc_tribuna_controllerAI, creature->AI())->UpdateFacesList(); + uiControllerGUID = creature->GetGUID(); + } + break; + case 13: + Talk(SAY_EVENT_INTRO_1); + instance->SetBossState(DATA_TRIBUNAL_OF_AGES, IN_PROGRESS); + SetEscortPaused(true); + JumpToNextStep(20000); + // @todo: There should be a pause here and a gossip should start the next step. + break; + case 17: + Talk(SAY_EVENT_INTRO_2); + instance->HandleGameObject(instance->GetGuidData(DATA_GO_TRIBUNAL_CONSOLE), true); + me->SetStandState(UNIT_STAND_STATE_KNEEL); + SetEscortPaused(true); + JumpToNextStep(8500); + break; + case 18: + SetEscortPaused(true); + break; + } + } + + void SpawnDwarf(uint32 uiType) + { + switch (uiType) + { + case 1: + { + uint32 uiSpawnNumber = DUNGEON_MODE(2, 3); + for (uint8 i = 0; i < uiSpawnNumber; ++i) + me->SummonCreature(NPC_DARK_RUNE_PROTECTOR, SpawnLocations[0], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 30000); + me->SummonCreature(NPC_DARK_RUNE_STORMCALLER, SpawnLocations[0], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 30000); + break; } - } - - void SpawnDwarf(uint32 uiType) - { - switch (uiType) - { - case 1: - { - uint32 uiSpawnNumber = DUNGEON_MODE(2, 3); - for (uint8 i = 0; i < uiSpawnNumber; ++i) - me->SummonCreature(NPC_DARK_RUNE_PROTECTOR, SpawnLocations[0], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 30000); - me->SummonCreature(NPC_DARK_RUNE_STORMCALLER, SpawnLocations[0], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 30000); - break; - } - case 2: - for (uint8 i = 0; i < 2; ++i) - me->SummonCreature(NPC_DARK_RUNE_STORMCALLER, SpawnLocations[0], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 30000); - break; - case 3: - me->SummonCreature(NPC_IRON_GOLEM_CUSTODIAN, SpawnLocations[0], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 30000); - break; - } - } + case 2: + for (uint8 i = 0; i < 2; ++i) + me->SummonCreature(NPC_DARK_RUNE_STORMCALLER, SpawnLocations[0], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 30000); + break; + case 3: + me->SummonCreature(NPC_IRON_GOLEM_CUSTODIAN, SpawnLocations[0], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 30000); + break; + } + } void JustSummoned(Creature* summoned) override { @@ -414,8 +423,8 @@ class npc_brann_hos : public CreatureScript void JumpToNextStep(uint32 uiTimer) { - uiPhaseTimer = uiTimer; - ++uiStep; + uiPhaseTimer = uiTimer; + ++uiStep; } void StartWP() @@ -446,254 +455,256 @@ class npc_brann_hos : public CreatureScript { switch (uiStep) { - case 1: - if (instance->GetBossState(DATA_TRIBUNAL_OF_AGES) != NOT_STARTED) - return; - bIsBattle = false; - Talk(SAY_ESCORT_START); - SetRun(true); - JumpToNextStep(0); - break; - case 3: - SetEscortPaused(false); - JumpToNextStep(0); - break; - case 5: - if (Creature* temp = (ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_ABEDNEUM)))) - temp->AI()->Talk(SAY_EVENT_INTRO_3_ABED); - JumpToNextStep(8500); - break; - case 6: - Talk(SAY_EVENT_A_1); - JumpToNextStep(6500); - break; - case 7: - if (Creature* temp = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_KADDRAK))) - temp->AI()->Talk(SAY_EVENT_A_2_KADD); - JumpToNextStep(12500); - break; - case 8: - Talk(SAY_EVENT_A_3); - instance->HandleGameObject(instance->GetGuidData(DATA_GO_KADDRAK), true); - if (Creature* temp = ObjectAccessor::GetCreature(*me, uiControllerGUID)) - ENSURE_AI(npc_tribuna_controller::npc_tribuna_controllerAI, temp->AI())->bKaddrakActivated = true; - JumpToNextStep(5000); - break; - case 9: - me->SetReactState(REACT_PASSIVE); - SpawnDwarf(1); - JumpToNextStep(20000); - break; - case 10: - Talk(SAY_EVENT_B_1); - JumpToNextStep(6000); - break; - case 11: - if (Creature* temp = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_MARNAK))) - temp->AI()->Talk(SAY_EVENT_B_2_MARN); - SpawnDwarf(1); - JumpToNextStep(20000); - break; - case 12: - Talk(SAY_EVENT_B_3); - instance->HandleGameObject(instance->GetGuidData(DATA_GO_MARNAK), true); - if (Creature* temp = ObjectAccessor::GetCreature(*me, uiControllerGUID)) - ENSURE_AI(npc_tribuna_controller::npc_tribuna_controllerAI, temp->AI())->bMarnakActivated = true; - JumpToNextStep(10000); - break; - case 13: - SpawnDwarf(1); - JumpToNextStep(10000); - break; - case 14: - SpawnDwarf(2); - JumpToNextStep(20000); - break; - case 15: - Talk(SAY_EVENT_C_1); - SpawnDwarf(1); - JumpToNextStep(10000); - break; - case 16: - SpawnDwarf(2); - JumpToNextStep(20000); - break; - case 17: - if (Creature* temp = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_ABEDNEUM))) - temp->AI()->Talk(SAY_EVENT_C_2_ABED); - SpawnDwarf(1); - JumpToNextStep(20000); - break; - case 18: - Talk(SAY_EVENT_C_3); - instance->HandleGameObject(instance->GetGuidData(DATA_GO_ABEDNEUM), true); - if (Creature* temp = ObjectAccessor::GetCreature(*me, uiControllerGUID)) - ENSURE_AI(npc_tribuna_controller::npc_tribuna_controllerAI, temp->AI())->bAbedneumActivated = true; - JumpToNextStep(5000); - break; - case 19: - SpawnDwarf(2); - JumpToNextStep(10000); - break; - case 20: - SpawnDwarf(1); - JumpToNextStep(15000); - break; - case 21: - Talk(SAY_EVENT_D_1); - SpawnDwarf(3); - JumpToNextStep(20000); - break; - case 22: - if (Creature* temp = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_ABEDNEUM))) - temp->AI()->Talk(SAY_EVENT_D_2_ABED); - SpawnDwarf(1); - JumpToNextStep(5000); - break; - case 23: - SpawnDwarf(2); - JumpToNextStep(15000); - break; - case 24: - Talk(SAY_EVENT_D_3); - SpawnDwarf(3); - JumpToNextStep(5000); - break; - case 25: - SpawnDwarf(1); - JumpToNextStep(5000); - break; - case 26: - SpawnDwarf(2); - JumpToNextStep(10000); - break; - case 27: - if (Creature* temp = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_ABEDNEUM))) - temp->AI()->Talk(SAY_EVENT_D_4_ABED); - SpawnDwarf(1); - JumpToNextStep(10000); - break; - case 28: - me->SetReactState(REACT_DEFENSIVE); - Talk(SAY_EVENT_END_01); - me->SetStandState(UNIT_STAND_STATE_STAND); - instance->HandleGameObject(instance->GetGuidData(DATA_GO_SKY_FLOOR), true); - if (Creature* temp = ObjectAccessor::GetCreature(*me, uiControllerGUID)) - temp->DealDamage(temp, temp->GetHealth(), nullptr, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, nullptr, false); - bIsBattle = true; - SetEscortPaused(false); - JumpToNextStep(6500); - break; - case 29: - Talk(SAY_EVENT_END_02); - instance->SetBossState(DATA_TRIBUNAL_OF_AGES, DONE); - me->CastSpell(me, SPELL_REWARD_ACHIEVEMENT, true); - JumpToNextStep(5500); - break; - case 30: - if (Creature* temp = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_ABEDNEUM))) - temp->AI()->Talk(SAY_EVENT_END_03_ABED); - JumpToNextStep(8500); - break; - case 31: - Talk(SAY_EVENT_END_04); - JumpToNextStep(11500); - break; - case 32: - if (Creature* temp = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_ABEDNEUM))) - temp->AI()->Talk(SAY_EVENT_END_05_ABED); - JumpToNextStep(11500); - break; - case 33: - Talk(SAY_EVENT_END_06); - JumpToNextStep(4500); - break; - case 34: - if (Creature* temp = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_ABEDNEUM))) - temp->AI()->Talk(SAY_EVENT_END_07_ABED); - JumpToNextStep(22500); - break; - case 35: - Talk(SAY_EVENT_END_08); - JumpToNextStep(7500); - break; - case 36: - if (Creature* temp = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_KADDRAK))) - temp->AI()->Talk(SAY_EVENT_END_09_KADD); - JumpToNextStep(18500); - break; - case 37: - Talk(SAY_EVENT_END_10); - JumpToNextStep(5500); - break; - case 38: - if (Creature* temp = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_KADDRAK))) - temp->AI()->Talk(SAY_EVENT_END_11_KADD); - JumpToNextStep(20500); - break; - case 39: - Talk(SAY_EVENT_END_12); - JumpToNextStep(2500); - break; - case 40: - if (Creature* temp = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_KADDRAK))) - temp->AI()->Talk(SAY_EVENT_END_13_KADD); - JumpToNextStep(19500); - break; - case 41: - Talk(SAY_EVENT_END_14); - JumpToNextStep(10500); - break; - case 42: - if (Creature* temp = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_MARNAK))) - temp->AI()->Talk(SAY_EVENT_END_15_MARN); - JumpToNextStep(6500); - break; - case 43: - Talk(SAY_EVENT_END_16); - JumpToNextStep(6500); - break; - case 44: - if (Creature* temp = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_MARNAK))) - temp->AI()->Talk(SAY_EVENT_END_17_MARN); - JumpToNextStep(25500); - break; - case 45: - Talk(SAY_EVENT_END_18); - JumpToNextStep(23500); - break; - case 46: - if (Creature* temp = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_MARNAK))) - temp->AI()->Talk(SAY_EVENT_END_19_MARN); - JumpToNextStep(3500); - break; - case 47: - Talk(SAY_EVENT_END_20); - JumpToNextStep(8500); - break; - case 48: - if (Creature* temp = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_ABEDNEUM))) - temp->AI()->Talk(SAY_EVENT_END_21_ABED); - JumpToNextStep(5500); - break; - case 49: - { - instance->HandleGameObject(instance->GetGuidData(DATA_GO_KADDRAK), false); - instance->HandleGameObject(instance->GetGuidData(DATA_GO_MARNAK), false); - instance->HandleGameObject(instance->GetGuidData(DATA_GO_ABEDNEUM), false); - instance->HandleGameObject(instance->GetGuidData(DATA_GO_SKY_FLOOR), false); - Player* player = GetPlayerForEscort(); - if (player) - player->GroupEventHappens(QUEST_HALLS_OF_STONE, me); - me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); - JumpToNextStep(180000); - break; - } - case 50: - SetEscortPaused(false); - break; + case 1: + if (instance->GetBossState(DATA_TRIBUNAL_OF_AGES) != NOT_STARTED) + return; + bIsBattle = false; + Talk(SAY_ESCORT_START); + SetRun(true); + JumpToNextStep(0); + break; + case 3: + SetEscortPaused(false); + JumpToNextStep(0); + break; + case 5: + if (Creature* temp = (ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_ABEDNEUM)))) + temp->AI()->Talk(SAY_EVENT_INTRO_3_ABED); + JumpToNextStep(8500); + break; + case 6: + Talk(SAY_EVENT_A_1); + JumpToNextStep(6500); + break; + case 7: + if (Creature* temp = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_KADDRAK))) + temp->AI()->Talk(SAY_EVENT_A_2_KADD); + JumpToNextStep(12500); + break; + case 8: + Talk(SAY_EVENT_A_3); + instance->HandleGameObject(instance->GetGuidData(DATA_GO_KADDRAK), true); + if (Creature* temp = ObjectAccessor::GetCreature(*me, uiControllerGUID)) + ENSURE_AI(npc_tribuna_controller::npc_tribuna_controllerAI, temp->AI())->bKaddrakActivated = true; + JumpToNextStep(5000); + break; + case 9: + me->SetReactState(REACT_PASSIVE); + SpawnDwarf(1); + JumpToNextStep(20000); + break; + case 10: + Talk(SAY_EVENT_B_1); + JumpToNextStep(6000); + break; + case 11: + if (Creature* temp = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_MARNAK))) + temp->AI()->Talk(SAY_EVENT_B_2_MARN); + SpawnDwarf(1); + JumpToNextStep(20000); + break; + case 12: + Talk(SAY_EVENT_B_3); + instance->HandleGameObject(instance->GetGuidData(DATA_GO_MARNAK), true); + if (Creature* temp = ObjectAccessor::GetCreature(*me, uiControllerGUID)) + ENSURE_AI(npc_tribuna_controller::npc_tribuna_controllerAI, temp->AI())->bMarnakActivated = true; + JumpToNextStep(10000); + break; + case 13: + SpawnDwarf(1); + JumpToNextStep(10000); + break; + case 14: + SpawnDwarf(2); + JumpToNextStep(20000); + break; + case 15: + Talk(SAY_EVENT_C_1); + SpawnDwarf(1); + JumpToNextStep(10000); + break; + case 16: + SpawnDwarf(2); + JumpToNextStep(20000); + break; + case 17: + if (Creature* temp = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_ABEDNEUM))) + temp->AI()->Talk(SAY_EVENT_C_2_ABED); + SpawnDwarf(1); + JumpToNextStep(20000); + break; + case 18: + Talk(SAY_EVENT_C_3); + instance->HandleGameObject(instance->GetGuidData(DATA_GO_ABEDNEUM), true); + if (Creature* temp = ObjectAccessor::GetCreature(*me, uiControllerGUID)) + ENSURE_AI(npc_tribuna_controller::npc_tribuna_controllerAI, temp->AI())->bAbedneumActivated = true; + JumpToNextStep(5000); + break; + case 19: + SpawnDwarf(2); + JumpToNextStep(10000); + break; + case 20: + SpawnDwarf(1); + JumpToNextStep(15000); + break; + case 21: + Talk(SAY_EVENT_D_1); + SpawnDwarf(3); + JumpToNextStep(20000); + break; + case 22: + if (Creature* temp = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_ABEDNEUM))) + temp->AI()->Talk(SAY_EVENT_D_2_ABED); + SpawnDwarf(1); + JumpToNextStep(5000); + break; + case 23: + SpawnDwarf(2); + JumpToNextStep(15000); + break; + case 24: + Talk(SAY_EVENT_D_3); + SpawnDwarf(3); + JumpToNextStep(5000); + break; + case 25: + SpawnDwarf(1); + JumpToNextStep(5000); + break; + case 26: + SpawnDwarf(2); + JumpToNextStep(10000); + break; + case 27: + if (Creature* temp = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_ABEDNEUM))) + temp->AI()->Talk(SAY_EVENT_D_4_ABED); + SpawnDwarf(1); + JumpToNextStep(10000); + break; + case 28: + me->SetReactState(REACT_DEFENSIVE); + Talk(SAY_EVENT_END_01); + me->SetStandState(UNIT_STAND_STATE_STAND); + instance->HandleGameObject(instance->GetGuidData(DATA_GO_SKY_FLOOR), true); + if (Creature* temp = ObjectAccessor::GetCreature(*me, uiControllerGUID)) + temp->KillSelf(); + bIsBattle = true; + SetEscortPaused(false); + JumpToNextStep(6500); + break; + case 29: + Talk(SAY_EVENT_END_02); + instance->SetBossState(DATA_TRIBUNAL_OF_AGES, DONE); + me->CastSpell(me, SPELL_REWARD_ACHIEVEMENT, true); + JumpToNextStep(5500); + break; + case 30: + if (Creature* temp = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_ABEDNEUM))) + temp->AI()->Talk(SAY_EVENT_END_03_ABED); + JumpToNextStep(8500); + break; + case 31: + Talk(SAY_EVENT_END_04); + JumpToNextStep(11500); + break; + case 32: + if (Creature* temp = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_ABEDNEUM))) + temp->AI()->Talk(SAY_EVENT_END_05_ABED); + JumpToNextStep(11500); + break; + case 33: + Talk(SAY_EVENT_END_06); + JumpToNextStep(4500); + break; + case 34: + if (Creature* temp = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_ABEDNEUM))) + temp->AI()->Talk(SAY_EVENT_END_07_ABED); + JumpToNextStep(22500); + break; + case 35: + Talk(SAY_EVENT_END_08); + JumpToNextStep(7500); + break; + case 36: + if (Creature* temp = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_KADDRAK))) + temp->AI()->Talk(SAY_EVENT_END_09_KADD); + JumpToNextStep(18500); + break; + case 37: + Talk(SAY_EVENT_END_10); + JumpToNextStep(5500); + break; + case 38: + if (Creature* temp = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_KADDRAK))) + temp->AI()->Talk(SAY_EVENT_END_11_KADD); + JumpToNextStep(20500); + break; + case 39: + Talk(SAY_EVENT_END_12); + JumpToNextStep(2500); + break; + case 40: + if (Creature* temp = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_KADDRAK))) + temp->AI()->Talk(SAY_EVENT_END_13_KADD); + JumpToNextStep(19500); + break; + case 41: + Talk(SAY_EVENT_END_14); + JumpToNextStep(10500); + break; + case 42: + if (Creature* temp = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_MARNAK))) + temp->AI()->Talk(SAY_EVENT_END_15_MARN); + JumpToNextStep(6500); + break; + case 43: + Talk(SAY_EVENT_END_16); + JumpToNextStep(6500); + break; + case 44: + if (Creature* temp = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_MARNAK))) + temp->AI()->Talk(SAY_EVENT_END_17_MARN); + JumpToNextStep(25500); + break; + case 45: + Talk(SAY_EVENT_END_18); + JumpToNextStep(23500); + break; + case 46: + if (Creature* temp = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_MARNAK))) + temp->AI()->Talk(SAY_EVENT_END_19_MARN); + JumpToNextStep(3500); + break; + case 47: + Talk(SAY_EVENT_END_20); + JumpToNextStep(8500); + break; + case 48: + if (Creature* temp = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_ABEDNEUM))) + temp->AI()->Talk(SAY_EVENT_END_21_ABED); + JumpToNextStep(5500); + break; + case 49: + { + instance->HandleGameObject(instance->GetGuidData(DATA_GO_KADDRAK), false); + instance->HandleGameObject(instance->GetGuidData(DATA_GO_MARNAK), false); + instance->HandleGameObject(instance->GetGuidData(DATA_GO_ABEDNEUM), false); + instance->HandleGameObject(instance->GetGuidData(DATA_GO_SKY_FLOOR), false); + Player* player = GetPlayerForEscort(); + if (player) + player->GroupEventHappens(QUEST_HALLS_OF_STONE, me); + me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); + JumpToNextStep(180000); + break; + } + case 50: + SetEscortPaused(false); + break; } - } else uiPhaseTimer -= uiDiff; + } + else + uiPhaseTimer -= uiDiff; if (!bIsLowHP && HealthBelowPct(30)) { @@ -718,20 +729,22 @@ class npc_brann_hos : public CreatureScript class achievement_brann_spankin_new : public AchievementCriteriaScript { - public: - achievement_brann_spankin_new() : AchievementCriteriaScript("achievement_brann_spankin_new") { } + public: + achievement_brann_spankin_new() : AchievementCriteriaScript("achievement_brann_spankin_new") + { + } - bool OnCheck(Player* /*player*/, Unit* target) override - { - if (!target) - return false; + bool OnCheck(Player* /*player*/, Unit* target) override + { + if (!target) + return false; - if (Creature* Brann = target->ToCreature()) - if (Brann->AI()->GetData(DATA_BRANN_SPARKLIN_NEWS)) - return true; + if (Creature* Brann = target->ToCreature()) + if (Brann->AI()->GetData(DATA_BRANN_SPARKLIN_NEWS)) + return true; - return false; - } + return false; + } }; void AddSC_halls_of_stone() diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon_the_observer.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon_the_observer.cpp index d3012c40..b9bf6114 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon_the_observer.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon_the_observer.cpp @@ -15,7 +15,6 @@ * with this program. If not, see . */ -#include "ScriptMgr.h" #include "DBCStores.h" #include "GameObject.h" #include "GameObjectAI.h" @@ -26,6 +25,7 @@ #include "ObjectAccessor.h" #include "PassiveAI.h" #include "Player.h" +#include "ScriptMgr.h" #include "ScriptedCreature.h" #include "Spell.h" #include "SpellInfo.h" @@ -35,75 +35,75 @@ enum Texts { - SAY_BRANN_ALGALON_INTRO_1 = 0, - SAY_BRANN_ALGALON_INTRO_2 = 1, - SAY_BRANN_ALGALON_OUTRO = 2, - - SAY_ALGALON_INTRO_1 = 0, - SAY_ALGALON_INTRO_2 = 1, - SAY_ALGALON_INTRO_3 = 2, - SAY_ALGALON_START_TIMER = 3, - SAY_ALGALON_AGGRO = 4, - SAY_ALGALON_COLLAPSING_STAR = 5, - EMOTE_ALGALON_COLLAPSING_STAR = 6, - SAY_ALGALON_BIG_BANG = 7, - EMOTE_ALGALON_BIG_BANG = 8, - SAY_ALGALON_ASCEND = 9, - EMOTE_ALGALON_COSMIC_SMASH = 10, - SAY_ALGALON_PHASE_TWO = 11, - SAY_ALGALON_OUTRO_1 = 12, - SAY_ALGALON_OUTRO_2 = 13, - SAY_ALGALON_OUTRO_3 = 14, - SAY_ALGALON_OUTRO_4 = 15, - SAY_ALGALON_OUTRO_5 = 16, - SAY_ALGALON_DESPAWN_1 = 17, - SAY_ALGALON_DESPAWN_2 = 18, - SAY_ALGALON_DESPAWN_3 = 19, - SAY_ALGALON_KILL = 20, + SAY_BRANN_ALGALON_INTRO_1 = 0, + SAY_BRANN_ALGALON_INTRO_2 = 1, + SAY_BRANN_ALGALON_OUTRO = 2, + + SAY_ALGALON_INTRO_1 = 0, + SAY_ALGALON_INTRO_2 = 1, + SAY_ALGALON_INTRO_3 = 2, + SAY_ALGALON_START_TIMER = 3, + SAY_ALGALON_AGGRO = 4, + SAY_ALGALON_COLLAPSING_STAR = 5, + EMOTE_ALGALON_COLLAPSING_STAR = 6, + SAY_ALGALON_BIG_BANG = 7, + EMOTE_ALGALON_BIG_BANG = 8, + SAY_ALGALON_ASCEND = 9, + EMOTE_ALGALON_COSMIC_SMASH = 10, + SAY_ALGALON_PHASE_TWO = 11, + SAY_ALGALON_OUTRO_1 = 12, + SAY_ALGALON_OUTRO_2 = 13, + SAY_ALGALON_OUTRO_3 = 14, + SAY_ALGALON_OUTRO_4 = 15, + SAY_ALGALON_OUTRO_5 = 16, + SAY_ALGALON_DESPAWN_1 = 17, + SAY_ALGALON_DESPAWN_2 = 18, + SAY_ALGALON_DESPAWN_3 = 19, + SAY_ALGALON_KILL = 20, }; enum Spells { // Algalon the Observer - SPELL_ARRIVAL = 64997, - SPELL_RIDE_THE_LIGHTNING = 64986, - SPELL_SUMMON_AZEROTH = 64994, - SPELL_REORIGINATION = 64996, - SPELL_SUPERMASSIVE_FAIL = 65311, - SPELL_QUANTUM_STRIKE = 64395, - SPELL_PHASE_PUNCH = 64412, - SPELL_BIG_BANG = 64443, - SPELL_ASCEND_TO_THE_HEAVENS = 64487, - SPELL_COSMIC_SMASH = 62301, - SPELL_COSMIC_SMASH_TRIGGERED = 62304, - SPELL_COSMIC_SMASH_VISUAL_STATE = 62300, - SPELL_SELF_STUN = 65256, - SPELL_KILL_CREDIT = 65184, - SPELL_TELEPORT = 62940, + SPELL_ARRIVAL = 64997, + SPELL_RIDE_THE_LIGHTNING = 64986, + SPELL_SUMMON_AZEROTH = 64994, + SPELL_REORIGINATION = 64996, + SPELL_SUPERMASSIVE_FAIL = 65311, + SPELL_QUANTUM_STRIKE = 64395, + SPELL_PHASE_PUNCH = 64412, + SPELL_BIG_BANG = 64443, + SPELL_ASCEND_TO_THE_HEAVENS = 64487, + SPELL_COSMIC_SMASH = 62301, + SPELL_COSMIC_SMASH_TRIGGERED = 62304, + SPELL_COSMIC_SMASH_VISUAL_STATE = 62300, + SPELL_SELF_STUN = 65256, + SPELL_KILL_CREDIT = 65184, + SPELL_TELEPORT = 62940, // Algalon Stalker - SPELL_TRIGGER_3_ADDS = 62266, // Triggers Living Constellation + SPELL_TRIGGER_3_ADDS = 62266, // Triggers Living Constellation // Living Constellation - SPELL_ARCANE_BARRAGE = 64599, + SPELL_ARCANE_BARRAGE = 64599, // Collapsing Star - SPELL_COLLAPSE = 62018, - SPELL_BLACK_HOLE_SPAWN_VISUAL = 62003, - SPELL_SUMMON_BLACK_HOLE = 62189, + SPELL_COLLAPSE = 62018, + SPELL_BLACK_HOLE_SPAWN_VISUAL = 62003, + SPELL_SUMMON_BLACK_HOLE = 62189, // Black Hole - SPELL_BLACK_HOLE_TRIGGER = 62185, - SPELL_CONSTELLATION_PHASE_TRIGGER = 65508, - SPELL_CONSTELLATION_PHASE_EFFECT = 65509, - SPELL_BLACK_HOLE_EXPLOSION = 64122, - SPELL_SUMMON_VOID_ZONE_VISUAL = 64470, - SPELL_VOID_ZONE_VISUAL = 64469, - SPELL_BLACK_HOLE_CREDIT = 65312, + SPELL_BLACK_HOLE_TRIGGER = 62185, + SPELL_CONSTELLATION_PHASE_TRIGGER = 65508, + SPELL_CONSTELLATION_PHASE_EFFECT = 65509, + SPELL_BLACK_HOLE_EXPLOSION = 64122, + SPELL_SUMMON_VOID_ZONE_VISUAL = 64470, + SPELL_VOID_ZONE_VISUAL = 64469, + SPELL_BLACK_HOLE_CREDIT = 65312, // Worm Hole - SPELL_WORM_HOLE_TRIGGER = 65251, - SPELL_SUMMON_UNLEASHED_DARK_MATTER = 64450, + SPELL_WORM_HOLE_TRIGGER = 65251, + SPELL_SUMMON_UNLEASHED_DARK_MATTER = 64450, }; uint32 const PhasePunchAlphaId[5] = {64435, 64434, 64428, 64421, 64417}; @@ -111,91 +111,89 @@ uint32 const PhasePunchAlphaId[5] = {64435, 64434, 64428, 64421, 64417}; enum Events { // Celestial Planetarium Access - EVENT_DESPAWN_CONSOLE = 1, + EVENT_DESPAWN_CONSOLE = 1, // Brann Bronzebeard - EVENT_BRANN_MOVE_INTRO = 2, - EVENT_SUMMON_ALGALON = 3, - EVENT_BRANN_OUTRO_1 = 4, - EVENT_BRANN_OUTRO_2 = 5, + EVENT_BRANN_MOVE_INTRO = 2, + EVENT_SUMMON_ALGALON = 3, + EVENT_BRANN_OUTRO_1 = 4, + EVENT_BRANN_OUTRO_2 = 5, // Algalon the Observer - EVENT_INTRO_1 = 6, - EVENT_INTRO_2 = 7, - EVENT_INTRO_3 = 8, - EVENT_INTRO_FINISH = 9, - EVENT_START_COMBAT = 10, - EVENT_INTRO_TIMER_DONE = 11, - EVENT_QUANTUM_STRIKE = 12, - EVENT_PHASE_PUNCH = 13, - EVENT_SUMMON_COLLAPSING_STAR = 14, - EVENT_BIG_BANG = 15, - EVENT_RESUME_UPDATING = 16, - EVENT_ASCEND_TO_THE_HEAVENS = 17, - EVENT_EVADE = 18, - EVENT_COSMIC_SMASH = 19, - EVENT_UNLOCK_YELL = 20, - EVENT_OUTRO_START = 21, - EVENT_OUTRO_1 = 22, - EVENT_OUTRO_2 = 23, - EVENT_OUTRO_3 = 24, - EVENT_OUTRO_4 = 25, - EVENT_OUTRO_5 = 26, - EVENT_OUTRO_6 = 27, - EVENT_OUTRO_7 = 28, - EVENT_OUTRO_8 = 29, - EVENT_OUTRO_9 = 30, - EVENT_OUTRO_10 = 31, - EVENT_OUTRO_11 = 32, - EVENT_OUTRO_12 = 33, - EVENT_OUTRO_13 = 34, - EVENT_OUTRO_14 = 35, - EVENT_DESPAWN_ALGALON_1 = 36, - EVENT_DESPAWN_ALGALON_2 = 37, - EVENT_DESPAWN_ALGALON_3 = 38, + EVENT_INTRO_1 = 6, + EVENT_INTRO_2 = 7, + EVENT_INTRO_3 = 8, + EVENT_INTRO_FINISH = 9, + EVENT_START_COMBAT = 10, + EVENT_INTRO_TIMER_DONE = 11, + EVENT_QUANTUM_STRIKE = 12, + EVENT_PHASE_PUNCH = 13, + EVENT_SUMMON_COLLAPSING_STAR = 14, + EVENT_BIG_BANG = 15, + EVENT_RESUME_UPDATING = 16, + EVENT_ASCEND_TO_THE_HEAVENS = 17, + EVENT_EVADE = 18, + EVENT_COSMIC_SMASH = 19, + EVENT_UNLOCK_YELL = 20, + EVENT_OUTRO_START = 21, + EVENT_OUTRO_1 = 22, + EVENT_OUTRO_2 = 23, + EVENT_OUTRO_3 = 24, + EVENT_OUTRO_4 = 25, + EVENT_OUTRO_5 = 26, + EVENT_OUTRO_6 = 27, + EVENT_OUTRO_7 = 28, + EVENT_OUTRO_8 = 29, + EVENT_OUTRO_9 = 30, + EVENT_OUTRO_10 = 31, + EVENT_OUTRO_11 = 32, + EVENT_OUTRO_12 = 33, + EVENT_OUTRO_13 = 34, + EVENT_OUTRO_14 = 35, + EVENT_DESPAWN_ALGALON_1 = 36, + EVENT_DESPAWN_ALGALON_2 = 37, + EVENT_DESPAWN_ALGALON_3 = 38, // Living Constellation - EVENT_ARCANE_BARRAGE = 39, + EVENT_ARCANE_BARRAGE = 39, }; enum Actions { - ACTION_START_INTRO = 0, - ACTION_FINISH_INTRO = 1, - ACTION_ACTIVATE_STAR = 2, - ACTION_BIG_BANG = 3, - ACTION_ASCEND = 4, - ACTION_OUTRO = 5, + ACTION_START_INTRO = 0, + ACTION_FINISH_INTRO = 1, + ACTION_ACTIVATE_STAR = 2, + ACTION_BIG_BANG = 3, + ACTION_ASCEND = 4, + ACTION_OUTRO = 5, }; enum Points { - POINT_BRANN_INTRO = 0, - MAX_BRANN_WAYPOINTS_INTRO = 10, - POINT_BRANN_OUTRO = 10, - POINT_BRANN_OUTRO_END = 11, + POINT_BRANN_INTRO = 0, + MAX_BRANN_WAYPOINTS_INTRO = 10, + POINT_BRANN_OUTRO = 10, + POINT_BRANN_OUTRO_END = 11, - POINT_ALGALON_LAND = 1, - POINT_ALGALON_OUTRO = 2, + POINT_ALGALON_LAND = 1, + POINT_ALGALON_OUTRO = 2, }; enum EncounterPhases { - PHASE_NORMAL = 0, - PHASE_ROLE_PLAY = 1, - PHASE_BIG_BANG = 2 + PHASE_NORMAL = 0, + PHASE_ROLE_PLAY = 1, + PHASE_BIG_BANG = 2 }; enum AchievmentInfo { EVENT_ID_SUPERMASSIVE_START = 21697, - DATA_HAS_FED_ON_TEARS = 30043005, + DATA_HAS_FED_ON_TEARS = 30043005, }; - Position const BrannIntroSpawnPos = {1676.277f, -162.5308f, 427.3326f, 3.235537f}; -Position const BrannIntroWaypoint[MAX_BRANN_WAYPOINTS_INTRO] = -{ +Position const BrannIntroWaypoint[MAX_BRANN_WAYPOINTS_INTRO] = { {1642.482f, -164.0812f, 427.2602f, 0.0f}, {1635.000f, -169.5145f, 427.2523f, 0.0f}, {1632.814f, -173.9334f, 427.2621f, 0.0f}, @@ -208,11 +206,10 @@ Position const BrannIntroWaypoint[MAX_BRANN_WAYPOINTS_INTRO] = {1635.000f, -169.5145f, 427.2523f, 0.0f}, }; Position const AlgalonSummonPos = {1632.531f, -304.8516f, 450.1123f, 1.530165f}; -Position const AlgalonLandPos = {1632.668f, -302.7656f, 417.3211f, 1.530165f}; +Position const AlgalonLandPos = {1632.668f, -302.7656f, 417.3211f, 1.530165f}; #define LIVING_CONSTELLATION_COUNT 11 -Position const ConstellationPos[LIVING_CONSTELLATION_COUNT] = -{ +Position const ConstellationPos[LIVING_CONSTELLATION_COUNT] = { {1625.208f, -267.2771f, 446.4296f, 5.044002f}, {1658.279f, -262.5490f, 441.9073f, 4.188790f}, {1678.677f, -276.3280f, 427.7531f, 3.979351f}, @@ -227,16 +224,14 @@ Position const ConstellationPos[LIVING_CONSTELLATION_COUNT] = }; #define COLLAPSING_STAR_COUNT 4 -Position const CollapsingStarPos[COLLAPSING_STAR_COUNT] = -{ +Position const CollapsingStarPos[COLLAPSING_STAR_COUNT] = { {1649.438f, -319.8127f, 418.3941f, 1.082104f}, {1647.005f, -288.6790f, 417.3955f, 3.490659f}, {1622.451f, -321.1563f, 417.6188f, 4.677482f}, {1615.060f, -291.6816f, 417.7796f, 3.490659f}, }; Position const AlgalonOutroPos = {1633.64f, -317.78f, 417.3211f, 0.0f}; -Position const BrannOutroPos[3] = -{ +Position const BrannOutroPos[3] = { {1632.023f, -243.7434f, 417.9118f, 0.0f}, {1631.986f, -297.7831f, 417.3210f, 0.0f}, {1633.832f, -216.2948f, 417.0463f, 0.0f}, @@ -244,1116 +239,1146 @@ Position const BrannOutroPos[3] = class ActivateLivingConstellation : public BasicEvent { - public: - ActivateLivingConstellation(Unit* owner) : _owner(owner), _instance(owner->GetInstanceScript()) - { - } - - bool Execute(uint64 execTime, uint32 /*diff*/) override - { - if (!_instance || _instance->GetBossState(DATA_ALGALON) != IN_PROGRESS) - return true; // delete event + public: + ActivateLivingConstellation(Unit* owner) : _owner(owner), _instance(owner->GetInstanceScript()) + { + } + + bool Execute(uint64 execTime, uint32 /*diff*/) override + { + if (!_instance || _instance->GetBossState(DATA_ALGALON) != IN_PROGRESS) + return true; // delete event + + _owner->CastSpell((Unit*)nullptr, SPELL_TRIGGER_3_ADDS, TRIGGERED_FULL_MASK); + _owner->m_Events.AddEvent(this, execTime + urand(45000, 50000)); + return false; + } + + private: + Unit* _owner; + InstanceScript* _instance; +}; - _owner->CastSpell((Unit*)nullptr, SPELL_TRIGGER_3_ADDS, TRIGGERED_FULL_MASK); - _owner->m_Events.AddEvent(this, execTime + urand(45000, 50000)); - return false; - } +class CosmicSmashDamageEvent : public BasicEvent +{ + public: + CosmicSmashDamageEvent(Unit* caster) : _caster(caster) + { + } + + bool Execute(uint64 /*execTime*/, uint32 /*diff*/) override + { + _caster->CastSpell((Unit*)nullptr, SPELL_COSMIC_SMASH_TRIGGERED, TRIGGERED_FULL_MASK); + return true; + } + + private: + Unit* _caster; +}; - private: - Unit* _owner; - InstanceScript* _instance; +class SummonUnleashedDarkMatter : public BasicEvent +{ + public: + SummonUnleashedDarkMatter(Unit* caster) : _caster(caster) + { + } + + bool Execute(uint64 execTime, uint32 /*diff*/) override + { + _caster->CastSpell((Unit*)nullptr, SPELL_SUMMON_UNLEASHED_DARK_MATTER, TRIGGERED_FULL_MASK); + _caster->m_Events.AddEvent(this, execTime + 30000); + return false; + } + + private: + Unit* _caster; }; -class CosmicSmashDamageEvent : public BasicEvent +class boss_algalon_the_observer : public CreatureScript { - public: - CosmicSmashDamageEvent(Unit* caster) : _caster(caster) + public: + boss_algalon_the_observer() : CreatureScript("boss_algalon_the_observer") + { + } + + struct boss_algalon_the_observerAI : public BossAI + { + boss_algalon_the_observerAI(Creature* creature) : BossAI(creature, DATA_ALGALON) { + Initialize(); + _firstPull = true; + _fedOnTears = false; } - bool Execute(uint64 /*execTime*/, uint32 /*diff*/) override + void Initialize() { - _caster->CastSpell((Unit*)nullptr, SPELL_COSMIC_SMASH_TRIGGERED, TRIGGERED_FULL_MASK); - return true; + _phaseTwo = false; + _fightWon = false; + _hasYelled = false; } - private: - Unit* _caster; -}; - -class SummonUnleashedDarkMatter : public BasicEvent -{ - public: - SummonUnleashedDarkMatter(Unit* caster) : _caster(caster) + void Reset() override { + _Reset(); + me->SetReactState(REACT_PASSIVE); + Initialize(); } - bool Execute(uint64 execTime, uint32 /*diff*/) override + void KilledUnit(Unit* victim) override { - _caster->CastSpell((Unit*)nullptr, SPELL_SUMMON_UNLEASHED_DARK_MATTER, TRIGGERED_FULL_MASK); - _caster->m_Events.AddEvent(this, execTime + 30000); - return false; + if (victim->GetTypeId() == TYPEID_PLAYER) + { + _fedOnTears = true; + if (!_hasYelled) + { + _hasYelled = true; + events.ScheduleEvent(EVENT_UNLOCK_YELL, 1000); + Talk(SAY_ALGALON_KILL); + } + } } - private: - Unit* _caster; -}; - -class boss_algalon_the_observer : public CreatureScript -{ - public: - boss_algalon_the_observer() : CreatureScript("boss_algalon_the_observer") { } - - struct boss_algalon_the_observerAI : public BossAI + void DoAction(int32 action) override { - boss_algalon_the_observerAI(Creature* creature) : BossAI(creature, DATA_ALGALON) + switch (action) + { + case ACTION_START_INTRO: { - Initialize(); - _firstPull = true; - _fedOnTears = false; + me->SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_INSTANTLY_APPEAR_MODEL); + me->SetDisableGravity(true); + DoCast(me, SPELL_ARRIVAL, true); + DoCast(me, SPELL_RIDE_THE_LIGHTNING, true); + me->SetHomePosition(AlgalonLandPos); + Movement::MoveSplineInit init(me); + init.MoveTo(AlgalonLandPos.GetPositionX(), AlgalonLandPos.GetPositionY(), AlgalonLandPos.GetPositionZ(), false); + init.SetOrientationFixed(true); + me->GetMotionMaster()->LaunchMoveSpline(std::move(init), POINT_ALGALON_LAND, MOTION_SLOT_ACTIVE, POINT_MOTION_TYPE); + + events.Reset(); + events.SetPhase(PHASE_ROLE_PLAY); + events.ScheduleEvent(EVENT_INTRO_1, 5000, 0, PHASE_ROLE_PLAY); + events.ScheduleEvent(EVENT_INTRO_2, 15000, 0, PHASE_ROLE_PLAY); + events.ScheduleEvent(EVENT_INTRO_3, 23000, 0, PHASE_ROLE_PLAY); + events.ScheduleEvent(EVENT_INTRO_FINISH, 36000, 0, PHASE_ROLE_PLAY); + break; + } + case ACTION_ASCEND: + events.SetPhase(PHASE_BIG_BANG); + events.CancelEvent(EVENT_RESUME_UPDATING); + events.ScheduleEvent(EVENT_ASCEND_TO_THE_HEAVENS, 1500); + break; + case EVENT_DESPAWN_ALGALON: + events.Reset(); + events.SetPhase(PHASE_ROLE_PLAY); + if (me->IsInCombat()) + events.ScheduleEvent(EVENT_ASCEND_TO_THE_HEAVENS, 1); + events.ScheduleEvent(EVENT_DESPAWN_ALGALON_1, 5000); + events.ScheduleEvent(EVENT_DESPAWN_ALGALON_2, 17000); + events.ScheduleEvent(EVENT_DESPAWN_ALGALON_3, 26000); + me->DespawnOrUnsummon(34000); + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + me->SetImmuneToNPC(true); + break; + case ACTION_INIT_ALGALON: + _firstPull = false; + me->SetImmuneToPC(false); + break; } + } + + uint32 GetData(uint32 type) const override + { + return type == DATA_HAS_FED_ON_TEARS ? _fedOnTears : 1; + } + + void JustEngagedWith(Unit* who) override + { + uint32 introDelay = 0; + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + me->SetImmuneToNPC(true); + events.Reset(); + events.SetPhase(PHASE_ROLE_PLAY); - void Initialize() + if (!_firstPull) { - _phaseTwo = false; - _fightWon = false; - _hasYelled = false; + Talk(SAY_ALGALON_AGGRO); + _JustEngagedWith(who); + introDelay = 8000; } - - void Reset() override + else { - _Reset(); - me->SetReactState(REACT_PASSIVE); - Initialize(); + _firstPull = false; + Talk(SAY_ALGALON_START_TIMER); + if (Creature* brann = instance->GetCreature(DATA_BRANN_BRONZEBEARD_ALG)) + brann->AI()->DoAction(ACTION_FINISH_INTRO); + + me->setActive(true); + me->SetFarVisible(true); + DoZoneInCombat(); + introDelay = 26000; + summons.DespawnEntry(NPC_AZEROTH); + instance->SetData(EVENT_DESPAWN_ALGALON, 0); + events.ScheduleEvent(EVENT_START_COMBAT, 18000); } - void KilledUnit(Unit* victim) override + events.ScheduleEvent(EVENT_INTRO_TIMER_DONE, introDelay); + events.ScheduleEvent(EVENT_QUANTUM_STRIKE, 3500 + introDelay); + events.ScheduleEvent(EVENT_PHASE_PUNCH, 15500 + introDelay); + events.ScheduleEvent(EVENT_SUMMON_COLLAPSING_STAR, 18000 + introDelay); + events.ScheduleEvent(EVENT_BIG_BANG, 90000 + introDelay); + events.ScheduleEvent(EVENT_ASCEND_TO_THE_HEAVENS, 360000 + introDelay); + events.ScheduleEvent(EVENT_COSMIC_SMASH, 25000 + introDelay); + + std::list stalkers; + me->GetCreatureListWithEntryInGrid(stalkers, NPC_ALGALON_STALKER, 200.0f); + for (std::list::iterator itr = stalkers.begin(); itr != stalkers.end(); ++itr) + (*itr)->m_Events.KillAllEvents(true); + } + + void MovementInform(uint32 movementType, uint32 pointId) override + { + if (movementType != POINT_MOTION_TYPE) + return; + + if (pointId == POINT_ALGALON_LAND) + me->SetDisableGravity(false); + else if (pointId == POINT_ALGALON_OUTRO) { - if (victim->GetTypeId() == TYPEID_PLAYER) - { - _fedOnTears = true; - if (!_hasYelled) - { - _hasYelled = true; - events.ScheduleEvent(EVENT_UNLOCK_YELL, 1000); - Talk(SAY_ALGALON_KILL); - } - } + me->SetFacingTo(1.605703f); + events.ScheduleEvent(EVENT_OUTRO_3, 1200); + events.ScheduleEvent(EVENT_OUTRO_4, 2400); + events.ScheduleEvent(EVENT_OUTRO_5, 8500); + events.ScheduleEvent(EVENT_OUTRO_6, 15500); + events.ScheduleEvent(EVENT_OUTRO_7, 55500); + events.ScheduleEvent(EVENT_OUTRO_8, 73500); + events.ScheduleEvent(EVENT_OUTRO_9, 85500); + events.ScheduleEvent(EVENT_OUTRO_10, 108500); + events.ScheduleEvent(EVENT_OUTRO_11, 123500); } + } - void DoAction(int32 action) override + void JustSummoned(Creature* summon) override + { + summons.Summon(summon); + switch (summon->GetEntry()) { - switch (action) - { - case ACTION_START_INTRO: - { - me->SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_INSTANTLY_APPEAR_MODEL); - me->SetDisableGravity(true); - DoCast(me, SPELL_ARRIVAL, true); - DoCast(me, SPELL_RIDE_THE_LIGHTNING, true); - me->SetHomePosition(AlgalonLandPos); - Movement::MoveSplineInit init(me); - init.MoveTo(AlgalonLandPos.GetPositionX(), AlgalonLandPos.GetPositionY(), AlgalonLandPos.GetPositionZ(), false); - init.SetOrientationFixed(true); - me->GetMotionMaster()->LaunchMoveSpline(std::move(init), POINT_ALGALON_LAND, MOTION_SLOT_ACTIVE, POINT_MOTION_TYPE); - - events.Reset(); - events.SetPhase(PHASE_ROLE_PLAY); - events.ScheduleEvent(EVENT_INTRO_1, 5000, 0, PHASE_ROLE_PLAY); - events.ScheduleEvent(EVENT_INTRO_2, 15000, 0, PHASE_ROLE_PLAY); - events.ScheduleEvent(EVENT_INTRO_3, 23000, 0, PHASE_ROLE_PLAY); - events.ScheduleEvent(EVENT_INTRO_FINISH, 36000, 0, PHASE_ROLE_PLAY); - break; - } - case ACTION_ASCEND: - events.SetPhase(PHASE_BIG_BANG); - events.CancelEvent(EVENT_RESUME_UPDATING); - events.ScheduleEvent(EVENT_ASCEND_TO_THE_HEAVENS, 1500); - break; - case EVENT_DESPAWN_ALGALON: - events.Reset(); - events.SetPhase(PHASE_ROLE_PLAY); - if (me->IsInCombat()) - events.ScheduleEvent(EVENT_ASCEND_TO_THE_HEAVENS, 1); - events.ScheduleEvent(EVENT_DESPAWN_ALGALON_1, 5000); - events.ScheduleEvent(EVENT_DESPAWN_ALGALON_2, 17000); - events.ScheduleEvent(EVENT_DESPAWN_ALGALON_3, 26000); - me->DespawnOrUnsummon(34000); - me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - me->SetImmuneToNPC(true); - break; - case ACTION_INIT_ALGALON: - _firstPull = false; - me->SetImmuneToPC(false); - break; - } + case NPC_AZEROTH: + DoCastAOE(SPELL_REORIGINATION, true); + break; + case NPC_COLLAPSING_STAR: + summon->SetReactState(REACT_PASSIVE); + summon->GetMotionMaster()->MoveRandom(20.0f); + summon->CastSpell(summon, SPELL_COLLAPSE, TRIGGERED_FULL_MASK); + break; + case NPC_BLACK_HOLE: + summon->SetReactState(REACT_PASSIVE); + summon->CastSpell((Unit*)nullptr, SPELL_BLACK_HOLE_TRIGGER, TRIGGERED_FULL_MASK); + summon->CastSpell(summon, SPELL_CONSTELLATION_PHASE_TRIGGER, TRIGGERED_FULL_MASK); + summon->CastSpell((Unit*)nullptr, SPELL_BLACK_HOLE_EXPLOSION); + summon->CastSpell(summon, SPELL_SUMMON_VOID_ZONE_VISUAL, TRIGGERED_FULL_MASK); + break; + case NPC_ALGALON_VOID_ZONE_VISUAL_STALKER: + summon->CastSpell(summon, SPELL_VOID_ZONE_VISUAL, TRIGGERED_FULL_MASK); + break; + case NPC_ALGALON_STALKER_ASTEROID_TARGET_01: + summon->CastSpell(summon, SPELL_COSMIC_SMASH_VISUAL_STATE, TRIGGERED_FULL_MASK); + break; + case NPC_ALGALON_STALKER_ASTEROID_TARGET_02: + summon->m_Events.AddEvent(new CosmicSmashDamageEvent(summon), summon->m_Events.CalculateTime(3250)); + break; + case NPC_WORM_HOLE: + summon->SetReactState(REACT_PASSIVE); + summon->CastSpell(summon, SPELL_WORM_HOLE_TRIGGER, TRIGGERED_FULL_MASK); + summon->CastSpell(summon, SPELL_SUMMON_VOID_ZONE_VISUAL, TRIGGERED_FULL_MASK); + break; + case NPC_UNLEASHED_DARK_MATTER: + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, NonTankTargetSelector(me))) + if (summon->Attack(target, true)) + summon->GetMotionMaster()->MoveChase(target); + break; } + } - uint32 GetData(uint32 type) const override + void EnterEvadeMode(EvadeReason why) override + { + instance->SetBossState(DATA_ALGALON, FAIL); + BossAI::EnterEvadeMode(why); + me->SetImmuneToPC(false); + me->SetSheath(SHEATH_STATE_UNARMED); + } + + void DamageTaken(Unit* /*attacker*/, uint32& damage) override + { + if (_fightWon) { - return type == DATA_HAS_FED_ON_TEARS ? _fedOnTears : 1; + damage = 0; + return; } - void JustEngagedWith(Unit* who) override + if (!_phaseTwo && me->HealthBelowPctDamaged(20, damage)) { - uint32 introDelay = 0; - me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - me->SetImmuneToNPC(true); - events.Reset(); - events.SetPhase(PHASE_ROLE_PLAY); - - if (!_firstPull) - { - Talk(SAY_ALGALON_AGGRO); - _JustEngagedWith(who); - introDelay = 8000; - } - else - { - _firstPull = false; - Talk(SAY_ALGALON_START_TIMER); - if (Creature* brann = instance->GetCreature(DATA_BRANN_BRONZEBEARD_ALG)) - brann->AI()->DoAction(ACTION_FINISH_INTRO); - - me->setActive(true); - me->SetFarVisible(true); - DoZoneInCombat(); - introDelay = 26000; - summons.DespawnEntry(NPC_AZEROTH); - instance->SetData(EVENT_DESPAWN_ALGALON, 0); - events.ScheduleEvent(EVENT_START_COMBAT, 18000); - } - - events.ScheduleEvent(EVENT_INTRO_TIMER_DONE, introDelay); - events.ScheduleEvent(EVENT_QUANTUM_STRIKE, 3500 + introDelay); - events.ScheduleEvent(EVENT_PHASE_PUNCH, 15500 + introDelay); - events.ScheduleEvent(EVENT_SUMMON_COLLAPSING_STAR, 18000 + introDelay); - events.ScheduleEvent(EVENT_BIG_BANG, 90000 + introDelay); - events.ScheduleEvent(EVENT_ASCEND_TO_THE_HEAVENS, 360000 + introDelay); - events.ScheduleEvent(EVENT_COSMIC_SMASH, 25000 + introDelay); - + _phaseTwo = true; + Talk(SAY_ALGALON_PHASE_TWO); + summons.DespawnEntry(NPC_LIVING_CONSTELLATION); + summons.DespawnEntry(NPC_COLLAPSING_STAR); + summons.DespawnEntry(NPC_BLACK_HOLE); + summons.DespawnEntry(NPC_ALGALON_VOID_ZONE_VISUAL_STALKER); + events.CancelEvent(EVENT_SUMMON_COLLAPSING_STAR); std::list stalkers; me->GetCreatureListWithEntryInGrid(stalkers, NPC_ALGALON_STALKER, 200.0f); for (std::list::iterator itr = stalkers.begin(); itr != stalkers.end(); ++itr) (*itr)->m_Events.KillAllEvents(true); + for (uint32 i = 0; i < COLLAPSING_STAR_COUNT; ++i) + if (Creature* wormHole = DoSummon(NPC_WORM_HOLE, CollapsingStarPos[i], TEMPSUMMON_MANUAL_DESPAWN)) + wormHole->m_Events.AddEvent(new SummonUnleashedDarkMatter(wormHole), wormHole->m_Events.CalculateTime(i >= 2 ? 8000 : 6000)); } - - void MovementInform(uint32 movementType, uint32 pointId) override + else if ((int32(me->GetHealth()) - int32(damage)) < CalculatePct(int32(me->GetMaxHealth()), 2.5f) && !_fightWon) { - if (movementType != POINT_MOTION_TYPE) - return; - - if (pointId == POINT_ALGALON_LAND) - me->SetDisableGravity(false); - else if (pointId == POINT_ALGALON_OUTRO) - { - me->SetFacingTo(1.605703f); - events.ScheduleEvent(EVENT_OUTRO_3, 1200); - events.ScheduleEvent(EVENT_OUTRO_4, 2400); - events.ScheduleEvent(EVENT_OUTRO_5, 8500); - events.ScheduleEvent(EVENT_OUTRO_6, 15500); - events.ScheduleEvent(EVENT_OUTRO_7, 55500); - events.ScheduleEvent(EVENT_OUTRO_8, 73500); - events.ScheduleEvent(EVENT_OUTRO_9, 85500); - events.ScheduleEvent(EVENT_OUTRO_10, 108500); - events.ScheduleEvent(EVENT_OUTRO_11, 123500); - } + _fightWon = true; + damage = 0; + me->SetReactState(REACT_PASSIVE); + me->AttackStop(); + me->SetFaction(FACTION_FRIENDLY); + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + DoCast(me, SPELL_SELF_STUN); + events.Reset(); + summons.DespawnAll(); + events.SetPhase(PHASE_ROLE_PLAY); + events.ScheduleEvent(EVENT_OUTRO_START, 1500); + events.ScheduleEvent(EVENT_OUTRO_1, 7200); + events.ScheduleEvent(EVENT_OUTRO_2, 8700); } + } - void JustSummoned(Creature* summon) override - { - summons.Summon(summon); - switch (summon->GetEntry()) - { - case NPC_AZEROTH: - DoCastAOE(SPELL_REORIGINATION, true); - break; - case NPC_COLLAPSING_STAR: - summon->SetReactState(REACT_PASSIVE); - summon->GetMotionMaster()->MoveRandom(20.0f); - summon->CastSpell(summon, SPELL_COLLAPSE, TRIGGERED_FULL_MASK); - break; - case NPC_BLACK_HOLE: - summon->SetReactState(REACT_PASSIVE); - summon->CastSpell((Unit*)nullptr, SPELL_BLACK_HOLE_TRIGGER, TRIGGERED_FULL_MASK); - summon->CastSpell(summon, SPELL_CONSTELLATION_PHASE_TRIGGER, TRIGGERED_FULL_MASK); - summon->CastSpell((Unit*)nullptr, SPELL_BLACK_HOLE_EXPLOSION); - summon->CastSpell(summon, SPELL_SUMMON_VOID_ZONE_VISUAL, TRIGGERED_FULL_MASK); - break; - case NPC_ALGALON_VOID_ZONE_VISUAL_STALKER: - summon->CastSpell(summon, SPELL_VOID_ZONE_VISUAL, TRIGGERED_FULL_MASK); - break; - case NPC_ALGALON_STALKER_ASTEROID_TARGET_01: - summon->CastSpell(summon, SPELL_COSMIC_SMASH_VISUAL_STATE, TRIGGERED_FULL_MASK); - break; - case NPC_ALGALON_STALKER_ASTEROID_TARGET_02: - summon->m_Events.AddEvent(new CosmicSmashDamageEvent(summon), summon->m_Events.CalculateTime(3250)); - break; - case NPC_WORM_HOLE: - summon->SetReactState(REACT_PASSIVE); - summon->CastSpell(summon, SPELL_WORM_HOLE_TRIGGER, TRIGGERED_FULL_MASK); - summon->CastSpell(summon, SPELL_SUMMON_VOID_ZONE_VISUAL, TRIGGERED_FULL_MASK); - break; - case NPC_UNLEASHED_DARK_MATTER: - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, NonTankTargetSelector(me))) - if (summon->Attack(target, true)) - summon->GetMotionMaster()->MoveChase(target); - break; - } - } + void UpdateAI(uint32 diff) override + { + if (!(events.IsInPhase(PHASE_ROLE_PLAY) || events.IsInPhase(PHASE_BIG_BANG)) && !UpdateVictim()) + return; - void EnterEvadeMode(EvadeReason why) override - { - instance->SetBossState(DATA_ALGALON, FAIL); - BossAI::EnterEvadeMode(why); - me->SetImmuneToPC(false); - me->SetSheath(SHEATH_STATE_UNARMED); - } + events.Update(diff); - void DamageTaken(Unit* /*attacker*/, uint32& damage) override - { - if (_fightWon) - { - damage = 0; + if (!events.IsInPhase(PHASE_ROLE_PLAY)) + if (me->HasUnitState(UNIT_STATE_CASTING)) return; - } - if (!_phaseTwo && me->HealthBelowPctDamaged(20, damage)) + while (uint32 eventId = events.ExecuteEvent()) + { + switch (eventId) { - _phaseTwo = true; - Talk(SAY_ALGALON_PHASE_TWO); - summons.DespawnEntry(NPC_LIVING_CONSTELLATION); - summons.DespawnEntry(NPC_COLLAPSING_STAR); - summons.DespawnEntry(NPC_BLACK_HOLE); - summons.DespawnEntry(NPC_ALGALON_VOID_ZONE_VISUAL_STALKER); - events.CancelEvent(EVENT_SUMMON_COLLAPSING_STAR); + case EVENT_INTRO_1: + me->RemoveAurasDueToSpell(SPELL_RIDE_THE_LIGHTNING); + Talk(SAY_ALGALON_INTRO_1); + break; + case EVENT_INTRO_2: + DoCastAOE(SPELL_SUMMON_AZEROTH, true); + Talk(SAY_ALGALON_INTRO_2); + break; + case EVENT_INTRO_3: + Talk(SAY_ALGALON_INTRO_3); + break; + case EVENT_INTRO_FINISH: + events.Reset(); + me->SetImmuneToPC(false); + break; + case EVENT_START_COMBAT: + instance->SetBossState(DATA_ALGALON, IN_PROGRESS); + break; + case EVENT_INTRO_TIMER_DONE: + { + events.SetPhase(PHASE_NORMAL); + me->SetSheath(SHEATH_STATE_MELEE); + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + me->SetImmuneToNPC(false); + me->SetReactState(REACT_DEFENSIVE); + DoCastAOE(SPELL_SUPERMASSIVE_FAIL, true); + //! Workaround for Creature::_IsTargetAcceptable returning false + //! for creatures that start combat in REACT_PASSIVE and UNIT_FLAG_NOT_SELECTABLE + //! causing them to immediately evade + if (!me->GetThreatManager().IsThreatListEmpty()) + AttackStart(me->GetThreatManager().GetCurrentVictim()); + for (uint32 i = 0; i < LIVING_CONSTELLATION_COUNT; ++i) + if (Creature* summon = DoSummon(NPC_LIVING_CONSTELLATION, ConstellationPos[i], 0, TEMPSUMMON_DEAD_DESPAWN)) + summon->SetReactState(REACT_PASSIVE); + std::list stalkers; me->GetCreatureListWithEntryInGrid(stalkers, NPC_ALGALON_STALKER, 200.0f); - for (std::list::iterator itr = stalkers.begin(); itr != stalkers.end(); ++itr) - (*itr)->m_Events.KillAllEvents(true); - for (uint32 i = 0; i < COLLAPSING_STAR_COUNT; ++i) - if (Creature* wormHole = DoSummon(NPC_WORM_HOLE, CollapsingStarPos[i], TEMPSUMMON_MANUAL_DESPAWN)) - wormHole->m_Events.AddEvent(new SummonUnleashedDarkMatter(wormHole), wormHole->m_Events.CalculateTime(i >= 2 ? 8000 : 6000)); + if (!stalkers.empty()) + { + Unit* stalker = Firelands::Containers::SelectRandomContainerElement(stalkers); + stalker->m_Events.AddEvent(new ActivateLivingConstellation(stalker), stalker->m_Events.CalculateTime(urand(45000, 50000))); + } + break; } - else if ((int32(me->GetHealth()) - int32(damage)) < CalculatePct(int32(me->GetMaxHealth()), 2.5f) && !_fightWon) + case EVENT_QUANTUM_STRIKE: + DoCastVictim(SPELL_QUANTUM_STRIKE); + events.ScheduleEvent(EVENT_QUANTUM_STRIKE, urand(3000, 5000)); + break; + case EVENT_PHASE_PUNCH: + DoCastVictim(SPELL_PHASE_PUNCH); + events.ScheduleEvent(EVENT_PHASE_PUNCH, 15500); + break; + case EVENT_SUMMON_COLLAPSING_STAR: + Talk(SAY_ALGALON_COLLAPSING_STAR); + Talk(EMOTE_ALGALON_COLLAPSING_STAR); + for (uint32 i = 0; i < COLLAPSING_STAR_COUNT; ++i) + me->SummonCreature(NPC_COLLAPSING_STAR, CollapsingStarPos[i], TEMPSUMMON_CORPSE_DESPAWN); + events.ScheduleEvent(EVENT_SUMMON_COLLAPSING_STAR, 60000); + break; + case EVENT_BIG_BANG: { - _fightWon = true; - damage = 0; - me->SetReactState(REACT_PASSIVE); - me->AttackStop(); - me->SetFaction(FACTION_FRIENDLY); - me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - DoCast(me, SPELL_SELF_STUN); - events.Reset(); - summons.DespawnAll(); - events.SetPhase(PHASE_ROLE_PLAY); - events.ScheduleEvent(EVENT_OUTRO_START, 1500); - events.ScheduleEvent(EVENT_OUTRO_1, 7200); - events.ScheduleEvent(EVENT_OUTRO_2, 8700); + Talk(SAY_ALGALON_BIG_BANG); + Talk(EMOTE_ALGALON_BIG_BANG); + events.SetPhase(PHASE_BIG_BANG); + std::list constellations; + me->GetCreatureListWithEntryInGrid(constellations, NPC_LIVING_CONSTELLATION, 200.0f); + for (std::list::iterator itr = constellations.begin(); itr != constellations.end(); ++itr) + (*itr)->AI()->DoAction(ACTION_BIG_BANG); + DoCastAOE(SPELL_BIG_BANG); + events.ScheduleEvent(EVENT_BIG_BANG, 90500); + events.ScheduleEvent(EVENT_RESUME_UPDATING, 9500); + break; } - } - - void UpdateAI(uint32 diff) override - { - if (!(events.IsInPhase(PHASE_ROLE_PLAY) || events.IsInPhase(PHASE_BIG_BANG)) && !UpdateVictim()) - return; - - events.Update(diff); - - if (!events.IsInPhase(PHASE_ROLE_PLAY)) - if (me->HasUnitState(UNIT_STATE_CASTING)) - return; - - while (uint32 eventId = events.ExecuteEvent()) - { - switch (eventId) - { - case EVENT_INTRO_1: - me->RemoveAurasDueToSpell(SPELL_RIDE_THE_LIGHTNING); - Talk(SAY_ALGALON_INTRO_1); - break; - case EVENT_INTRO_2: - DoCastAOE(SPELL_SUMMON_AZEROTH, true); - Talk(SAY_ALGALON_INTRO_2); - break; - case EVENT_INTRO_3: - Talk(SAY_ALGALON_INTRO_3); - break; - case EVENT_INTRO_FINISH: - events.Reset(); - me->SetImmuneToPC(false); - break; - case EVENT_START_COMBAT: - instance->SetBossState(DATA_ALGALON, IN_PROGRESS); - break; - case EVENT_INTRO_TIMER_DONE: - { - events.SetPhase(PHASE_NORMAL); - me->SetSheath(SHEATH_STATE_MELEE); - me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - me->SetImmuneToNPC(false); - me->SetReactState(REACT_DEFENSIVE); - DoCastAOE(SPELL_SUPERMASSIVE_FAIL, true); - //! Workaround for Creature::_IsTargetAcceptable returning false - //! for creatures that start combat in REACT_PASSIVE and UNIT_FLAG_NOT_SELECTABLE - //! causing them to immediately evade - if (!me->GetThreatManager().IsThreatListEmpty()) - AttackStart(me->GetThreatManager().GetCurrentVictim()); - for (uint32 i = 0; i < LIVING_CONSTELLATION_COUNT; ++i) - if (Creature* summon = DoSummon(NPC_LIVING_CONSTELLATION, ConstellationPos[i], 0, TEMPSUMMON_DEAD_DESPAWN)) - summon->SetReactState(REACT_PASSIVE); - - std::list stalkers; - me->GetCreatureListWithEntryInGrid(stalkers, NPC_ALGALON_STALKER, 200.0f); - if (!stalkers.empty()) - { - Unit* stalker = Firelands::Containers::SelectRandomContainerElement(stalkers); - stalker->m_Events.AddEvent(new ActivateLivingConstellation(stalker), stalker->m_Events.CalculateTime(urand(45000, 50000))); - } - break; - } - case EVENT_QUANTUM_STRIKE: - DoCastVictim(SPELL_QUANTUM_STRIKE); - events.ScheduleEvent(EVENT_QUANTUM_STRIKE, urand(3000, 5000)); - break; - case EVENT_PHASE_PUNCH: - DoCastVictim(SPELL_PHASE_PUNCH); - events.ScheduleEvent(EVENT_PHASE_PUNCH, 15500); - break; - case EVENT_SUMMON_COLLAPSING_STAR: - Talk(SAY_ALGALON_COLLAPSING_STAR); - Talk(EMOTE_ALGALON_COLLAPSING_STAR); - for (uint32 i = 0; i < COLLAPSING_STAR_COUNT; ++i) - me->SummonCreature(NPC_COLLAPSING_STAR, CollapsingStarPos[i], TEMPSUMMON_CORPSE_DESPAWN); - events.ScheduleEvent(EVENT_SUMMON_COLLAPSING_STAR, 60000); - break; - case EVENT_BIG_BANG: - { - Talk(SAY_ALGALON_BIG_BANG); - Talk(EMOTE_ALGALON_BIG_BANG); - events.SetPhase(PHASE_BIG_BANG); - std::list constellations; - me->GetCreatureListWithEntryInGrid(constellations, NPC_LIVING_CONSTELLATION, 200.0f); - for (std::list::iterator itr = constellations.begin(); itr != constellations.end(); ++itr) - (*itr)->AI()->DoAction(ACTION_BIG_BANG); - DoCastAOE(SPELL_BIG_BANG); - events.ScheduleEvent(EVENT_BIG_BANG, 90500); - events.ScheduleEvent(EVENT_RESUME_UPDATING, 9500); - break; - } - case EVENT_RESUME_UPDATING: - events.SetPhase(0); - break; - case EVENT_ASCEND_TO_THE_HEAVENS: - Talk(SAY_ALGALON_ASCEND); - DoCastAOE(SPELL_ASCEND_TO_THE_HEAVENS); - events.ScheduleEvent(EVENT_EVADE, 2500); - break; - case EVENT_EVADE: - EnterEvadeMode(EVADE_REASON_OTHER); - break; - case EVENT_COSMIC_SMASH: - Talk(EMOTE_ALGALON_COSMIC_SMASH); - DoCastAOE(SPELL_COSMIC_SMASH); - events.ScheduleEvent(EVENT_COSMIC_SMASH, 25500); - break; - case EVENT_UNLOCK_YELL: - _hasYelled = false; - break; - case EVENT_OUTRO_START: - instance->SetBossState(DATA_ALGALON, DONE); - break; - case EVENT_OUTRO_1: - me->RemoveAllAuras(); - me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_RENAME); - break; - case EVENT_OUTRO_2: - _EnterEvadeMode(); - me->GetMotionMaster()->MovePoint(POINT_ALGALON_OUTRO, AlgalonOutroPos); - break; - case EVENT_OUTRO_3: - DoCastAOE(SPELL_KILL_CREDIT); - break; - case EVENT_OUTRO_4: - DoCastAOE(SPELL_SUPERMASSIVE_FAIL); - me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - break; - case EVENT_OUTRO_5: - if (Creature* brann = DoSummon(NPC_BRANN_BRONZBEARD_ALG, BrannOutroPos[0], 131500, TEMPSUMMON_TIMED_DESPAWN)) - brann->AI()->DoAction(ACTION_OUTRO); - break; - case EVENT_OUTRO_6: - Talk(SAY_ALGALON_OUTRO_1); - me->SetStandState(UNIT_STAND_STATE_KNEEL); - break; - case EVENT_OUTRO_7: - Talk(SAY_ALGALON_OUTRO_2); - break; - case EVENT_OUTRO_8: - Talk(SAY_ALGALON_OUTRO_3); - break; - case EVENT_OUTRO_9: - Talk(SAY_ALGALON_OUTRO_4); - break; - case EVENT_OUTRO_10: - Talk(SAY_ALGALON_OUTRO_5); - break; - case EVENT_OUTRO_11: - me->SetStandState(UNIT_STAND_STATE_STAND); - DoCast(me, SPELL_TELEPORT); - me->DespawnOrUnsummon(1500); - break; - } - - if (me->HasUnitState(UNIT_STATE_CASTING) && !events.IsInPhase(PHASE_ROLE_PLAY)) - return; + case EVENT_RESUME_UPDATING: + events.SetPhase(0); + break; + case EVENT_ASCEND_TO_THE_HEAVENS: + Talk(SAY_ALGALON_ASCEND); + DoCastAOE(SPELL_ASCEND_TO_THE_HEAVENS); + events.ScheduleEvent(EVENT_EVADE, 2500); + break; + case EVENT_EVADE: + EnterEvadeMode(EVADE_REASON_OTHER); + break; + case EVENT_COSMIC_SMASH: + Talk(EMOTE_ALGALON_COSMIC_SMASH); + DoCastAOE(SPELL_COSMIC_SMASH); + events.ScheduleEvent(EVENT_COSMIC_SMASH, 25500); + break; + case EVENT_UNLOCK_YELL: + _hasYelled = false; + break; + case EVENT_OUTRO_START: + instance->SetBossState(DATA_ALGALON, DONE); + break; + case EVENT_OUTRO_1: + me->RemoveAllAuras(); + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_RENAME); + break; + case EVENT_OUTRO_2: + _EnterEvadeMode(); + me->GetMotionMaster()->MovePoint(POINT_ALGALON_OUTRO, AlgalonOutroPos); + break; + case EVENT_OUTRO_3: + DoCastAOE(SPELL_KILL_CREDIT); + break; + case EVENT_OUTRO_4: + DoCastAOE(SPELL_SUPERMASSIVE_FAIL); + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + break; + case EVENT_OUTRO_5: + if (Creature* brann = DoSummon(NPC_BRANN_BRONZBEARD_ALG, BrannOutroPos[0], 131500, TEMPSUMMON_TIMED_DESPAWN)) + brann->AI()->DoAction(ACTION_OUTRO); + break; + case EVENT_OUTRO_6: + Talk(SAY_ALGALON_OUTRO_1); + me->SetStandState(UNIT_STAND_STATE_KNEEL); + break; + case EVENT_OUTRO_7: + Talk(SAY_ALGALON_OUTRO_2); + break; + case EVENT_OUTRO_8: + Talk(SAY_ALGALON_OUTRO_3); + break; + case EVENT_OUTRO_9: + Talk(SAY_ALGALON_OUTRO_4); + break; + case EVENT_OUTRO_10: + Talk(SAY_ALGALON_OUTRO_5); + break; + case EVENT_OUTRO_11: + me->SetStandState(UNIT_STAND_STATE_STAND); + DoCast(me, SPELL_TELEPORT); + me->DespawnOrUnsummon(1500); + break; } - DoMeleeAttackIfReady(); + if (me->HasUnitState(UNIT_STATE_CASTING) && !events.IsInPhase(PHASE_ROLE_PLAY)) + return; } - private: - bool _firstPull; - bool _fedOnTears; - bool _phaseTwo; - bool _fightWon; - bool _hasYelled; - }; - - CreatureAI* GetAI(Creature* creature) const override - { - return GetUlduarAI(creature); + DoMeleeAttackIfReady(); } + + private: + bool _firstPull; + bool _fedOnTears; + bool _phaseTwo; + bool _fightWon; + bool _hasYelled; + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return GetUlduarAI(creature); + } }; class npc_living_constellation : public CreatureScript { - public: - npc_living_constellation() : CreatureScript("npc_living_constellation") { } - - struct npc_living_constellationAI : public CreatureAI + public: + npc_living_constellation() : CreatureScript("npc_living_constellation") + { + } + + struct npc_living_constellationAI : public CreatureAI + { + npc_living_constellationAI(Creature* creature) : CreatureAI(creature) { - npc_living_constellationAI(Creature* creature) : CreatureAI(creature) - { - Initialize(); - } + Initialize(); + } - void Initialize() - { - _isActive = false; - } + void Initialize() + { + _isActive = false; + } - void Reset() override - { - _events.Reset(); - _events.ScheduleEvent(EVENT_ARCANE_BARRAGE, 2500); - Initialize(); - } + void Reset() override + { + _events.Reset(); + _events.ScheduleEvent(EVENT_ARCANE_BARRAGE, 2500); + Initialize(); + } - uint32 GetData(uint32 /*type*/) const override - { - return _isActive ? 1 : 0; - } + uint32 GetData(uint32 /*type*/) const override + { + return _isActive ? 1 : 0; + } - void DoAction(int32 action) override + void DoAction(int32 action) override + { + switch (action) { - switch (action) + case ACTION_ACTIVATE_STAR: + if (Creature* algalon = me->FindNearestCreature(NPC_ALGALON, 200.0f)) { - case ACTION_ACTIVATE_STAR: - if (Creature* algalon = me->FindNearestCreature(NPC_ALGALON, 200.0f)) - { - if (Unit* target = algalon->AI()->SelectTarget(SELECT_TARGET_RANDOM, 0, NonTankTargetSelector(algalon))) - { - me->SetReactState(REACT_AGGRESSIVE); - me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - AttackStart(target); - DoZoneInCombat(); - _isActive = true; - } - } - break; - case ACTION_BIG_BANG: - _events.SetPhase(PHASE_BIG_BANG); - _events.DelayEvents(9500); - _events.ScheduleEvent(EVENT_RESUME_UPDATING, 9500); - break; + if (Unit* target = algalon->AI()->SelectTarget(SELECT_TARGET_RANDOM, 0, NonTankTargetSelector(algalon))) + { + me->SetReactState(REACT_AGGRESSIVE); + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + AttackStart(target); + DoZoneInCombat(); + _isActive = true; + } } + break; + case ACTION_BIG_BANG: + _events.SetPhase(PHASE_BIG_BANG); + _events.DelayEvents(9500); + _events.ScheduleEvent(EVENT_RESUME_UPDATING, 9500); + break; } + } - void SpellHit(Unit* caster, SpellInfo const* spell) override - { - if (spell->Id != SPELL_CONSTELLATION_PHASE_EFFECT || caster->GetTypeId() != TYPEID_UNIT) - return; - - me->DespawnOrUnsummon(1); - if (InstanceScript* instance = me->GetInstanceScript()) - instance->DoStartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, EVENT_ID_SUPERMASSIVE_START); - caster->CastSpell((Unit*)nullptr, SPELL_BLACK_HOLE_CREDIT, TRIGGERED_FULL_MASK); - caster->ToCreature()->DespawnOrUnsummon(1); - } + void SpellHit(Unit* caster, SpellInfo const* spell) override + { + if (spell->Id != SPELL_CONSTELLATION_PHASE_EFFECT || caster->GetTypeId() != TYPEID_UNIT) + return; + + me->DespawnOrUnsummon(1); + if (InstanceScript* instance = me->GetInstanceScript()) + instance->DoStartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, EVENT_ID_SUPERMASSIVE_START); + caster->CastSpell((Unit*)nullptr, SPELL_BLACK_HOLE_CREDIT, TRIGGERED_FULL_MASK); + caster->ToCreature()->DespawnOrUnsummon(1); + } - void UpdateAI(uint32 diff) override - { - if (!(_events.IsInPhase(PHASE_ROLE_PLAY) || _events.IsInPhase(PHASE_BIG_BANG)) && !UpdateVictim()) - return; + void UpdateAI(uint32 diff) override + { + if (!(_events.IsInPhase(PHASE_ROLE_PLAY) || _events.IsInPhase(PHASE_BIG_BANG)) && !UpdateVictim()) + return; - _events.Update(diff); + _events.Update(diff); - while (uint32 eventId = _events.ExecuteEvent()) + while (uint32 eventId = _events.ExecuteEvent()) + { + switch (eventId) { - switch (eventId) - { - case EVENT_ARCANE_BARRAGE: - DoCastAOE(SPELL_ARCANE_BARRAGE); - _events.ScheduleEvent(EVENT_ARCANE_BARRAGE, 2500); - break; - case EVENT_RESUME_UPDATING: - _events.SetPhase(0); - break; - } + case EVENT_ARCANE_BARRAGE: + DoCastAOE(SPELL_ARCANE_BARRAGE); + _events.ScheduleEvent(EVENT_ARCANE_BARRAGE, 2500); + break; + case EVENT_RESUME_UPDATING: + _events.SetPhase(0); + break; } } + } - private: - EventMap _events; - bool _isActive; - }; + private: + EventMap _events; + bool _isActive; + }; - CreatureAI* GetAI(Creature* creature) const override - { - return GetUlduarAI(creature); - } + CreatureAI* GetAI(Creature* creature) const override + { + return GetUlduarAI(creature); + } }; class npc_collapsing_star : public CreatureScript { - public: - npc_collapsing_star() : CreatureScript("npc_collapsing_star") { } + public: + npc_collapsing_star() : CreatureScript("npc_collapsing_star") + { + } + + struct npc_collapsing_starAI : public PassiveAI + { + npc_collapsing_starAI(Creature* creature) : PassiveAI(creature) + { + _dying = false; + } - struct npc_collapsing_starAI : public PassiveAI + void JustSummoned(Creature* summon) override { - npc_collapsing_starAI(Creature* creature) : PassiveAI(creature) - { - _dying = false; - } + if (summon->GetEntry() != NPC_BLACK_HOLE) + return; - void JustSummoned(Creature* summon) override - { - if (summon->GetEntry() != NPC_BLACK_HOLE) - return; + if (TempSummon* summ = me->ToTempSummon()) + if (Creature* algalon = ObjectAccessor::GetCreature(*me, summ->GetSummonerGUID())) + algalon->AI()->JustSummoned(summon); - if (TempSummon* summ = me->ToTempSummon()) - if (Creature* algalon = ObjectAccessor::GetCreature(*me, summ->GetSummonerGUID())) - algalon->AI()->JustSummoned(summon); + me->DespawnOrUnsummon(1); + } - me->DespawnOrUnsummon(1); + void DamageTaken(Unit* /*attacker*/, uint32& damage) override + { + if (_dying) + { + damage = 0; + return; } - void DamageTaken(Unit* /*attacker*/, uint32& damage) override + if (damage >= me->GetHealth()) { - if (_dying) - { - damage = 0; - return; - } - - if (damage >= me->GetHealth()) - { - _dying = true; - damage = 0; - DoCast(me, SPELL_BLACK_HOLE_SPAWN_VISUAL, true); - DoCast(me, SPELL_SUMMON_BLACK_HOLE, true); - } + _dying = true; + damage = 0; + DoCast(me, SPELL_BLACK_HOLE_SPAWN_VISUAL, true); + DoCast(me, SPELL_SUMMON_BLACK_HOLE, true); } + } - bool _dying; - }; + bool _dying; + }; - CreatureAI* GetAI(Creature* creature) const override - { - return GetUlduarAI(creature); - } + CreatureAI* GetAI(Creature* creature) const override + { + return GetUlduarAI(creature); + } }; class npc_brann_bronzebeard_algalon : public CreatureScript { - public: - npc_brann_bronzebeard_algalon() : CreatureScript("npc_brann_bronzebeard_algalon") { } + public: + npc_brann_bronzebeard_algalon() : CreatureScript("npc_brann_bronzebeard_algalon") + { + } + + struct npc_brann_bronzebeard_algalonAI : public CreatureAI + { + npc_brann_bronzebeard_algalonAI(Creature* creature) : CreatureAI(creature) + { + _currentPoint = 0; + } - struct npc_brann_bronzebeard_algalonAI : public CreatureAI + void DoAction(int32 action) override { - npc_brann_bronzebeard_algalonAI(Creature* creature) : CreatureAI(creature) + switch (action) { + case ACTION_START_INTRO: _currentPoint = 0; + _events.Reset(); + me->SetWalk(false); + _events.ScheduleEvent(EVENT_BRANN_MOVE_INTRO, 1); + break; + case ACTION_FINISH_INTRO: + Talk(SAY_BRANN_ALGALON_INTRO_2); + _events.ScheduleEvent(EVENT_BRANN_MOVE_INTRO, 1); + break; + case ACTION_OUTRO: + me->GetMotionMaster()->MovePoint(POINT_BRANN_OUTRO, BrannOutroPos[1]); + _events.ScheduleEvent(EVENT_BRANN_OUTRO_1, 89500); + _events.ScheduleEvent(EVENT_BRANN_OUTRO_2, 116500); + break; } + } - void DoAction(int32 action) override - { - switch (action) - { - case ACTION_START_INTRO: - _currentPoint = 0; - _events.Reset(); - me->SetWalk(false); - _events.ScheduleEvent(EVENT_BRANN_MOVE_INTRO, 1); - break; - case ACTION_FINISH_INTRO: - Talk(SAY_BRANN_ALGALON_INTRO_2); - _events.ScheduleEvent(EVENT_BRANN_MOVE_INTRO, 1); - break; - case ACTION_OUTRO: - me->GetMotionMaster()->MovePoint(POINT_BRANN_OUTRO, BrannOutroPos[1]); - _events.ScheduleEvent(EVENT_BRANN_OUTRO_1, 89500); - _events.ScheduleEvent(EVENT_BRANN_OUTRO_2, 116500); - break; - } - } + void MovementInform(uint32 movementType, uint32 pointId) override + { + if (movementType != POINT_MOTION_TYPE) + return; - void MovementInform(uint32 movementType, uint32 pointId) override + uint32 delay = 1; + _currentPoint = pointId + 1; + switch (pointId) { - if (movementType != POINT_MOTION_TYPE) - return; - - uint32 delay = 1; - _currentPoint = pointId + 1; - switch (pointId) - { - case 2: - delay = 8000; - me->SetWalk(true); - break; - case 5: - me->SetWalk(false); - Talk(SAY_BRANN_ALGALON_INTRO_1); - _events.ScheduleEvent(EVENT_SUMMON_ALGALON, 7500); - return; - case 9: - me->DespawnOrUnsummon(1); - return; - case POINT_BRANN_OUTRO: - case POINT_BRANN_OUTRO_END: - return; - } - - _events.ScheduleEvent(EVENT_BRANN_MOVE_INTRO, delay); + case 2: + delay = 8000; + me->SetWalk(true); + break; + case 5: + me->SetWalk(false); + Talk(SAY_BRANN_ALGALON_INTRO_1); + _events.ScheduleEvent(EVENT_SUMMON_ALGALON, 7500); + return; + case 9: + me->DespawnOrUnsummon(1); + return; + case POINT_BRANN_OUTRO: + case POINT_BRANN_OUTRO_END: + return; } - void UpdateAI(uint32 diff) override - { - UpdateVictim(); + _events.ScheduleEvent(EVENT_BRANN_MOVE_INTRO, delay); + } - if (_events.Empty()) - return; + void UpdateAI(uint32 diff) override + { + UpdateVictim(); - _events.Update(diff); + if (_events.Empty()) + return; - while (uint32 eventId = _events.ExecuteEvent()) + _events.Update(diff); + + while (uint32 eventId = _events.ExecuteEvent()) + { + switch (eventId) { - switch (eventId) - { - case EVENT_BRANN_MOVE_INTRO: - if (_currentPoint < MAX_BRANN_WAYPOINTS_INTRO) - me->GetMotionMaster()->MovePoint(_currentPoint, BrannIntroWaypoint[_currentPoint]); - break; - case EVENT_SUMMON_ALGALON: - if (Creature* algalon = me->GetMap()->SummonCreature(NPC_ALGALON, AlgalonSummonPos)) - algalon->AI()->DoAction(ACTION_START_INTRO); - break; - case EVENT_BRANN_OUTRO_1: - Talk(SAY_BRANN_ALGALON_OUTRO); - break; - case EVENT_BRANN_OUTRO_2: - me->GetMotionMaster()->MovePoint(POINT_BRANN_OUTRO_END, BrannOutroPos[2]); - break; - } + case EVENT_BRANN_MOVE_INTRO: + if (_currentPoint < MAX_BRANN_WAYPOINTS_INTRO) + me->GetMotionMaster()->MovePoint(_currentPoint, BrannIntroWaypoint[_currentPoint]); + break; + case EVENT_SUMMON_ALGALON: + if (Creature* algalon = me->GetMap()->SummonCreature(NPC_ALGALON, AlgalonSummonPos)) + algalon->AI()->DoAction(ACTION_START_INTRO); + break; + case EVENT_BRANN_OUTRO_1: + Talk(SAY_BRANN_ALGALON_OUTRO); + break; + case EVENT_BRANN_OUTRO_2: + me->GetMotionMaster()->MovePoint(POINT_BRANN_OUTRO_END, BrannOutroPos[2]); + break; } } + } - private: - EventMap _events; - uint32 _currentPoint; - }; + private: + EventMap _events; + uint32 _currentPoint; + }; - CreatureAI* GetAI(Creature* creature) const override - { - return GetUlduarAI(creature); - } + CreatureAI* GetAI(Creature* creature) const override + { + return GetUlduarAI(creature); + } }; class go_celestial_planetarium_access : public GameObjectScript { - public: - go_celestial_planetarium_access() : GameObjectScript("go_celestial_planetarium_access") { } - - struct go_celestial_planetarium_accessAI : public GameObjectAI + public: + go_celestial_planetarium_access() : GameObjectScript("go_celestial_planetarium_access") + { + } + + struct go_celestial_planetarium_accessAI : public GameObjectAI + { + go_celestial_planetarium_accessAI(GameObject* go) : GameObjectAI(go), instance(go->GetInstanceScript()) { - go_celestial_planetarium_accessAI(GameObject* go) : GameObjectAI(go), instance(go->GetInstanceScript()) { } + } - InstanceScript* instance; + InstanceScript* instance; - bool OnReportUse(Player* player) override - { - if (me->HasFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE)) - return true; + bool OnReportUse(Player* player) override + { + if (me->HasFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE)) + return true; - bool hasKey = true; - if (LockEntry const* lock = sLockStore.LookupEntry(me->GetGOInfo()->goober.lockId)) + bool hasKey = true; + if (LockEntry const* lock = sLockStore.LookupEntry(me->GetGOInfo()->goober.lockId)) + { + hasKey = false; + for (uint32 i = 0; i < MAX_LOCK_CASE; ++i) { - hasKey = false; - for (uint32 i = 0; i < MAX_LOCK_CASE; ++i) + if (!lock->Index[i]) + continue; + + if (player->HasItemCount(lock->Index[i])) { - if (!lock->Index[i]) - continue; - - if (player->HasItemCount(lock->Index[i])) - { - hasKey = true; - break; - } + hasKey = true; + break; } } + } - if (!hasKey) - return false; + if (!hasKey) + return false; - // Start Algalon event - me->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE); - _events.ScheduleEvent(EVENT_DESPAWN_CONSOLE, 5000); - if (Creature* brann = me->SummonCreature(NPC_BRANN_BRONZBEARD_ALG, BrannIntroSpawnPos)) - brann->AI()->DoAction(ACTION_START_INTRO); + // Start Algalon event + me->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE); + _events.ScheduleEvent(EVENT_DESPAWN_CONSOLE, 5000); + if (Creature* brann = me->SummonCreature(NPC_BRANN_BRONZBEARD_ALG, BrannIntroSpawnPos)) + brann->AI()->DoAction(ACTION_START_INTRO); - instance->SetData(DATA_ALGALON_SUMMON_STATE, 1); - if (GameObject* sigil = ObjectAccessor::GetGameObject(*me, instance->GetGuidData(DATA_SIGILDOOR_01))) - sigil->SetGoState(GO_STATE_ACTIVE); + instance->SetData(DATA_ALGALON_SUMMON_STATE, 1); + if (GameObject* sigil = ObjectAccessor::GetGameObject(*me, instance->GetGuidData(DATA_SIGILDOOR_01))) + sigil->SetGoState(GO_STATE_ACTIVE); - if (GameObject* sigil = ObjectAccessor::GetGameObject(*me, instance->GetGuidData(DATA_SIGILDOOR_02))) - sigil->SetGoState(GO_STATE_ACTIVE); + if (GameObject* sigil = ObjectAccessor::GetGameObject(*me, instance->GetGuidData(DATA_SIGILDOOR_02))) + sigil->SetGoState(GO_STATE_ACTIVE); - return false; - } + return false; + } - void UpdateAI(uint32 diff) override - { - if (_events.Empty()) - return; + void UpdateAI(uint32 diff) override + { + if (_events.Empty()) + return; - _events.Update(diff); + _events.Update(diff); - while (uint32 eventId = _events.ExecuteEvent()) + while (uint32 eventId = _events.ExecuteEvent()) + { + switch (eventId) { - switch (eventId) - { - case EVENT_DESPAWN_CONSOLE: - me->Delete(); - break; - } + case EVENT_DESPAWN_CONSOLE: + me->Delete(); + break; } } + } - EventMap _events; - }; + EventMap _events; + }; - GameObjectAI* GetAI(GameObject* go) const override - { - return GetUlduarAI(go); - } + GameObjectAI* GetAI(GameObject* go) const override + { + return GetUlduarAI(go); + } }; class spell_algalon_phase_punch : public SpellScriptLoader { - public: - spell_algalon_phase_punch() : SpellScriptLoader("spell_algalon_phase_punch") { } - - class spell_algalon_phase_punch_AuraScript : public AuraScript - { - void HandlePeriodic(AuraEffect const* /*aurEff*/) - { - PreventDefaultAction(); - if (GetStackAmount() != 1) - GetTarget()->RemoveAurasDueToSpell(PhasePunchAlphaId[GetStackAmount() - 2]); - GetTarget()->CastSpell(GetTarget(), PhasePunchAlphaId[GetStackAmount() - 1], TRIGGERED_FULL_MASK); - if (GetStackAmount() == 5) - Remove(AuraRemoveFlags::ByDefault); - } - - void OnRemove(AuraEffect const*, AuraEffectHandleModes) - { - if (GetStackAmount() != 5) - GetTarget()->RemoveAurasDueToSpell(PhasePunchAlphaId[GetStackAmount() - 1]); - } - - void Register() override - { - OnEffectPeriodic.Register(&spell_algalon_phase_punch_AuraScript::HandlePeriodic, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY); - OnEffectRemove.Register(&spell_algalon_phase_punch_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY, AURA_EFFECT_HANDLE_REAL); - } - }; - - AuraScript* GetAuraScript() const override + public: + spell_algalon_phase_punch() : SpellScriptLoader("spell_algalon_phase_punch") + { + } + + class spell_algalon_phase_punch_AuraScript : public AuraScript + { + void HandlePeriodic(AuraEffect const* /*aurEff*/) { - return new spell_algalon_phase_punch_AuraScript(); + PreventDefaultAction(); + if (GetStackAmount() != 1) + GetTarget()->RemoveAurasDueToSpell(PhasePunchAlphaId[GetStackAmount() - 2]); + GetTarget()->CastSpell(GetTarget(), PhasePunchAlphaId[GetStackAmount() - 1], TRIGGERED_FULL_MASK); + if (GetStackAmount() == 5) + Remove(AuraRemoveFlags::ByDefault); } -}; -class NotVictimFilter -{ - public: - NotVictimFilter(Unit* caster) : _victim(caster->GetVictim()) + void OnRemove(AuraEffect const*, AuraEffectHandleModes) { + if (GetStackAmount() != 5) + GetTarget()->RemoveAurasDueToSpell(PhasePunchAlphaId[GetStackAmount() - 1]); } - bool operator()(WorldObject* target) + void Register() override { - return target != _victim; + OnEffectPeriodic.Register(&spell_algalon_phase_punch_AuraScript::HandlePeriodic, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY); + OnEffectRemove.Register(&spell_algalon_phase_punch_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY, AURA_EFFECT_HANDLE_REAL); } + }; - private: - Unit* _victim; + AuraScript* GetAuraScript() const override + { + return new spell_algalon_phase_punch_AuraScript(); + } }; -class spell_algalon_arcane_barrage : public SpellScriptLoader +class NotVictimFilter { - public: - spell_algalon_arcane_barrage() : SpellScriptLoader("spell_algalon_arcane_barrage") { } + public: + NotVictimFilter(Unit* caster) : _victim(caster->GetVictim()) + { + } + + bool operator()(WorldObject* target) + { + return target != _victim; + } + + private: + Unit* _victim; +}; - class spell_algalon_arcane_barrage_SpellScript : public SpellScript +class spell_algalon_arcane_barrage : public SpellScriptLoader +{ + public: + spell_algalon_arcane_barrage() : SpellScriptLoader("spell_algalon_arcane_barrage") + { + } + + class spell_algalon_arcane_barrage_SpellScript : public SpellScript + { + void SelectTarget(std::list& targets) { - void SelectTarget(std::list& targets) - { - targets.remove_if(NotVictimFilter(GetCaster())); - } - - void Register() override - { - OnObjectAreaTargetSelect.Register(&spell_algalon_arcane_barrage_SpellScript::SelectTarget, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); - } - }; + targets.remove_if(NotVictimFilter(GetCaster())); + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_algalon_arcane_barrage_SpellScript(); + OnObjectAreaTargetSelect.Register(&spell_algalon_arcane_barrage_SpellScript::SelectTarget, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_algalon_arcane_barrage_SpellScript(); + } }; class ActiveConstellationFilter { - public: - bool operator()(WorldObject* target) const - { - return target->ToUnit() && target->ToUnit()->GetAI() && target->ToUnit()->GetAI()->GetData(0); - } + public: + bool operator()(WorldObject* target) const + { + return target->ToUnit() && target->ToUnit()->GetAI() && target->ToUnit()->GetAI()->GetData(0); + } }; class spell_algalon_trigger_3_adds : public SpellScriptLoader { - public: - spell_algalon_trigger_3_adds() : SpellScriptLoader("spell_algalon_trigger_3_adds") { } - - class spell_algalon_trigger_3_adds_SpellScript : public SpellScript + public: + spell_algalon_trigger_3_adds() : SpellScriptLoader("spell_algalon_trigger_3_adds") + { + } + + class spell_algalon_trigger_3_adds_SpellScript : public SpellScript + { + void SelectTarget(std::list& targets) { - void SelectTarget(std::list& targets) - { - targets.remove_if(ActiveConstellationFilter()); - } - - void HandleDummy(SpellEffIndex effIndex) - { - PreventHitDefaultEffect(effIndex); - Creature* target = GetHitCreature(); - if (!target) - return; + targets.remove_if(ActiveConstellationFilter()); + } - target->AI()->DoAction(ACTION_ACTIVATE_STAR); - } + void HandleDummy(SpellEffIndex effIndex) + { + PreventHitDefaultEffect(effIndex); + Creature* target = GetHitCreature(); + if (!target) + return; - void Register() override - { - OnObjectAreaTargetSelect.Register(&spell_algalon_trigger_3_adds_SpellScript::SelectTarget, EFFECT_0, TARGET_UNIT_SRC_AREA_ENTRY); - OnEffectHitTarget.Register(&spell_algalon_trigger_3_adds_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); - } - }; + target->AI()->DoAction(ACTION_ACTIVATE_STAR); + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_algalon_trigger_3_adds_SpellScript(); + OnObjectAreaTargetSelect.Register(&spell_algalon_trigger_3_adds_SpellScript::SelectTarget, EFFECT_0, TARGET_UNIT_SRC_AREA_ENTRY); + OnEffectHitTarget.Register(&spell_algalon_trigger_3_adds_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_algalon_trigger_3_adds_SpellScript(); + } }; class spell_algalon_collapse : public SpellScriptLoader { - public: - spell_algalon_collapse() : SpellScriptLoader("spell_algalon_collapse") { } - - class spell_algalon_collapse_AuraScript : public AuraScript + public: + spell_algalon_collapse() : SpellScriptLoader("spell_algalon_collapse") + { + } + + class spell_algalon_collapse_AuraScript : public AuraScript + { + void HandlePeriodic(AuraEffect const* /*aurEff*/) { - void HandlePeriodic(AuraEffect const* /*aurEff*/) - { - PreventDefaultAction(); - GetTarget()->DealDamage(GetTarget(), GetTarget()->CountPctFromMaxHealth(1), nullptr, NODAMAGE); - } - - void Register() override - { - OnEffectPeriodic.Register(&spell_algalon_collapse_AuraScript::HandlePeriodic, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY); - } - }; + PreventDefaultAction(); + Unit::DealDamage(GetTarget(), GetTarget(), GetTarget()->CountPctFromMaxHealth(1), nullptr, NODAMAGE); + } - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_algalon_collapse_AuraScript(); + OnEffectPeriodic.Register(&spell_algalon_collapse_AuraScript::HandlePeriodic, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY); } + }; + + AuraScript* GetAuraScript() const override + { + return new spell_algalon_collapse_AuraScript(); + } }; class spell_algalon_big_bang : public SpellScriptLoader { - public: - spell_algalon_big_bang() : SpellScriptLoader("spell_algalon_big_bang") { } - - class spell_algalon_big_bang_SpellScript : public SpellScript + public: + spell_algalon_big_bang() : SpellScriptLoader("spell_algalon_big_bang") + { + } + + class spell_algalon_big_bang_SpellScript : public SpellScript + { + public: + spell_algalon_big_bang_SpellScript() { - public: - spell_algalon_big_bang_SpellScript() - { - _targetCount = 0; - } - - private: - bool Load() override - { - return GetCaster()->GetTypeId() == TYPEID_UNIT && GetCaster()->IsAIEnabled(); - } - - void CountTargets(std::list& targets) - { - _targetCount = targets.size(); - } + _targetCount = 0; + } - void CheckTargets() - { - if (!_targetCount) - GetCaster()->GetAI()->DoAction(ACTION_ASCEND); - } + private: + bool Load() override + { + return GetCaster()->GetTypeId() == TYPEID_UNIT && GetCaster()->IsAIEnabled(); + } - void Register() override - { - OnObjectAreaTargetSelect.Register(&spell_algalon_big_bang_SpellScript::CountTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); - AfterCast.Register(&spell_algalon_big_bang_SpellScript::CheckTargets); - } + void CountTargets(std::list& targets) + { + _targetCount = targets.size(); + } - uint32 _targetCount; - }; + void CheckTargets() + { + if (!_targetCount) + GetCaster()->GetAI()->DoAction(ACTION_ASCEND); + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_algalon_big_bang_SpellScript(); + OnObjectAreaTargetSelect.Register(&spell_algalon_big_bang_SpellScript::CountTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); + AfterCast.Register(&spell_algalon_big_bang_SpellScript::CheckTargets); } + + uint32 _targetCount; + }; + + SpellScript* GetSpellScript() const override + { + return new spell_algalon_big_bang_SpellScript(); + } }; class spell_algalon_remove_phase : public SpellScriptLoader { - public: - spell_algalon_remove_phase() : SpellScriptLoader("spell_algalon_remove_phase") { } - - class spell_algalon_remove_phase_AuraScript : public AuraScript + public: + spell_algalon_remove_phase() : SpellScriptLoader("spell_algalon_remove_phase") + { + } + + class spell_algalon_remove_phase_AuraScript : public AuraScript + { + void HandlePeriodic(AuraEffect const* /*aurEff*/) { - void HandlePeriodic(AuraEffect const* /*aurEff*/) - { - PreventDefaultAction(); - GetTarget()->RemoveAurasByType(SPELL_AURA_PHASE); - } - - void Register() override - { - OnEffectPeriodic.Register(&spell_algalon_remove_phase_AuraScript::HandlePeriodic, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); - } - }; + PreventDefaultAction(); + GetTarget()->RemoveAurasByType(SPELL_AURA_PHASE); + } - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_algalon_remove_phase_AuraScript(); + OnEffectPeriodic.Register(&spell_algalon_remove_phase_AuraScript::HandlePeriodic, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); } + }; + + AuraScript* GetAuraScript() const override + { + return new spell_algalon_remove_phase_AuraScript(); + } }; // 62295 - Cosmic Smash class spell_algalon_cosmic_smash : public SpellScriptLoader { - public: - spell_algalon_cosmic_smash() : SpellScriptLoader("spell_algalon_cosmic_smash") { } - - class spell_algalon_cosmic_smash_SpellScript : public SpellScript + public: + spell_algalon_cosmic_smash() : SpellScriptLoader("spell_algalon_cosmic_smash") + { + } + + class spell_algalon_cosmic_smash_SpellScript : public SpellScript + { + void ModDestHeight(SpellDestination& dest) { - void ModDestHeight(SpellDestination& dest) - { - Position const offset = { 0.0f, 0.0f, 65.0f, 0.0f }; - dest.RelocateOffset(offset); - } - - void Register() override - { - OnDestinationTargetSelect.Register(&spell_algalon_cosmic_smash_SpellScript::ModDestHeight, EFFECT_0, TARGET_DEST_CASTER_SUMMON); - } - }; + Position const offset = {0.0f, 0.0f, 65.0f, 0.0f}; + dest.RelocateOffset(offset); + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_algalon_cosmic_smash_SpellScript(); + OnDestinationTargetSelect.Register(&spell_algalon_cosmic_smash_SpellScript::ModDestHeight, EFFECT_0, TARGET_DEST_CASTER_SUMMON); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_algalon_cosmic_smash_SpellScript(); + } }; class spell_algalon_cosmic_smash_damage : public SpellScriptLoader { - public: - spell_algalon_cosmic_smash_damage() : SpellScriptLoader("spell_algalon_cosmic_smash_damage") { } - - class spell_algalon_cosmic_smash_damage_SpellScript : public SpellScript + public: + spell_algalon_cosmic_smash_damage() : SpellScriptLoader("spell_algalon_cosmic_smash_damage") + { + } + + class spell_algalon_cosmic_smash_damage_SpellScript : public SpellScript + { + void RecalculateDamage() { - void RecalculateDamage() - { - if (!GetExplTargetDest() || !GetHitUnit()) - return; - - float distance = GetHitUnit()->GetDistance2d(GetExplTargetDest()->GetPositionX(), GetExplTargetDest()->GetPositionY()); - if (distance > 6.0f) - SetHitDamage(int32(float(GetHitDamage()) / distance) * 2); - } + if (!GetExplTargetDest() || !GetHitUnit()) + return; - void Register() override - { - OnHit.Register(&spell_algalon_cosmic_smash_damage_SpellScript::RecalculateDamage); - } - }; + float distance = GetHitUnit()->GetDistance2d(GetExplTargetDest()->GetPositionX(), GetExplTargetDest()->GetPositionY()); + if (distance > 6.0f) + SetHitDamage(int32(float(GetHitDamage()) / distance) * 2); + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_algalon_cosmic_smash_damage_SpellScript(); + OnHit.Register(&spell_algalon_cosmic_smash_damage_SpellScript::RecalculateDamage); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_algalon_cosmic_smash_damage_SpellScript(); + } }; class spell_algalon_supermassive_fail : public SpellScriptLoader { - public: - spell_algalon_supermassive_fail() : SpellScriptLoader("spell_algalon_supermassive_fail") { } - - class spell_algalon_supermassive_fail_SpellScript : public SpellScript + public: + spell_algalon_supermassive_fail() : SpellScriptLoader("spell_algalon_supermassive_fail") + { + } + + class spell_algalon_supermassive_fail_SpellScript : public SpellScript + { + void RecalculateDamage() { - void RecalculateDamage() - { - if (!GetHitPlayer()) - return; + if (!GetHitPlayer()) + return; - GetHitPlayer()->ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_CONDITION_NO_SPELL_HIT, GetSpellInfo()->Id, true); - } - - void Register() override - { - OnHit.Register(&spell_algalon_supermassive_fail_SpellScript::RecalculateDamage); - } - }; + GetHitPlayer()->ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_CONDITION_NO_SPELL_HIT, GetSpellInfo()->Id, true); + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_algalon_supermassive_fail_SpellScript(); + OnHit.Register(&spell_algalon_supermassive_fail_SpellScript::RecalculateDamage); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_algalon_supermassive_fail_SpellScript(); + } }; void AddSC_boss_algalon_the_observer() diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_mimiron.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_mimiron.cpp index 1caaf3c1..a5d0f2b4 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_mimiron.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_mimiron.cpp @@ -15,169 +15,169 @@ * with this program. If not, see . */ -#include "ScriptMgr.h" #include "GameObject.h" #include "GameObjectAI.h" #include "GridNotifiers.h" #include "InstanceScript.h" #include "MotionMaster.h" #include "ObjectAccessor.h" +#include "ScriptMgr.h" #include "ScriptedCreature.h" #include "SpellAuraEffects.h" #include "SpellScript.h" #include "TemporarySummon.h" -#include "ulduar.h" #include "Vehicle.h" +#include "ulduar.h" enum Yells { - SAY_AGGRO = 0, - SAY_HARDMODE_ON = 1, - SAY_MKII_ACTIVATE = 2, - SAY_MKII_SLAY = 3, - SAY_MKII_DEATH = 4, - SAY_VX001_ACTIVATE = 5, - SAY_VX001_SLAY = 6, - SAY_VX001_DEATH = 7, - SAY_AERIAL_ACTIVATE = 8, - SAY_AERIAL_SLAY = 9, - SAY_AERIAL_DEATH = 10, - SAY_V07TRON_ACTIVATE = 11, - SAY_V07TRON_SLAY = 12, - SAY_V07TRON_DEATH = 13, - SAY_BERSERK = 14 + SAY_AGGRO = 0, + SAY_HARDMODE_ON = 1, + SAY_MKII_ACTIVATE = 2, + SAY_MKII_SLAY = 3, + SAY_MKII_DEATH = 4, + SAY_VX001_ACTIVATE = 5, + SAY_VX001_SLAY = 6, + SAY_VX001_DEATH = 7, + SAY_AERIAL_ACTIVATE = 8, + SAY_AERIAL_SLAY = 9, + SAY_AERIAL_DEATH = 10, + SAY_V07TRON_ACTIVATE = 11, + SAY_V07TRON_SLAY = 12, + SAY_V07TRON_DEATH = 13, + SAY_BERSERK = 14 }; enum ComputerYells { - SAY_SELF_DESTRUCT_INITIATED = 0, - SAY_SELF_DESTRUCT_TERMINATED = 1, - SAY_SELF_DESTRUCT_10 = 2, - SAY_SELF_DESTRUCT_9 = 3, - SAY_SELF_DESTRUCT_8 = 4, - SAY_SELF_DESTRUCT_7 = 5, - SAY_SELF_DESTRUCT_6 = 6, - SAY_SELF_DESTRUCT_5 = 7, - SAY_SELF_DESTRUCT_4 = 8, - SAY_SELF_DESTRUCT_3 = 9, - SAY_SELF_DESTRUCT_2 = 10, - SAY_SELF_DESTRUCT_1 = 11, - SAY_SELF_DESTRUCT_FINALIZED = 12 + SAY_SELF_DESTRUCT_INITIATED = 0, + SAY_SELF_DESTRUCT_TERMINATED = 1, + SAY_SELF_DESTRUCT_10 = 2, + SAY_SELF_DESTRUCT_9 = 3, + SAY_SELF_DESTRUCT_8 = 4, + SAY_SELF_DESTRUCT_7 = 5, + SAY_SELF_DESTRUCT_6 = 6, + SAY_SELF_DESTRUCT_5 = 7, + SAY_SELF_DESTRUCT_4 = 8, + SAY_SELF_DESTRUCT_3 = 9, + SAY_SELF_DESTRUCT_2 = 10, + SAY_SELF_DESTRUCT_1 = 11, + SAY_SELF_DESTRUCT_FINALIZED = 12 }; enum Spells { // Mimiron - SPELL_WELD = 63339, // Idle aura. - SPELL_SEAT_1 = 52391, // Cast on all vehicles, Cycled on MKII - SPELL_SEAT_2 = 63313, // Cast on MKII and VX-001, Cycled on MKII - SPELL_SEAT_3 = 63314, // Cast on MKII, Cycled on MKII - SPELL_SEAT_5 = 63316, // Cast on MKII and VX-001, Cycled on MKII - SPELL_SEAT_6 = 63344, // Cast on MKII - SPELL_SEAT_7 = 63345, // Cast on MKII - SPELL_JETPACK = 63341, - SPELL_DESPAWN_ASSAULT_BOTS = 64463, // only despawns assault bots... no equivalent spell for the other adds... - SPELL_TELEPORT_VISUAL = 41232, - SPELL_SLEEP_VISUAL_1 = 64393, - SPELL_SLEEP_VISUAL_2 = 64394, + SPELL_WELD = 63339, // Idle aura. + SPELL_SEAT_1 = 52391, // Cast on all vehicles, Cycled on MKII + SPELL_SEAT_2 = 63313, // Cast on MKII and VX-001, Cycled on MKII + SPELL_SEAT_3 = 63314, // Cast on MKII, Cycled on MKII + SPELL_SEAT_5 = 63316, // Cast on MKII and VX-001, Cycled on MKII + SPELL_SEAT_6 = 63344, // Cast on MKII + SPELL_SEAT_7 = 63345, // Cast on MKII + SPELL_JETPACK = 63341, + SPELL_DESPAWN_ASSAULT_BOTS = 64463, // only despawns assault bots... no equivalent spell for the other adds... + SPELL_TELEPORT_VISUAL = 41232, + SPELL_SLEEP_VISUAL_1 = 64393, + SPELL_SLEEP_VISUAL_2 = 64394, // Leviathan MK II - SPELL_FLAME_SUPPRESSANT_MK = 64570, - SPELL_NAPALM_SHELL = 63666, - SPELL_FORCE_CAST_NAPALM_SHELL = 64539, - SPELL_PLASMA_BLAST = 62997, - SPELL_SCRIPT_EFFECT_PLASMA_BLAST = 64542, - SPELL_SHOCK_BLAST = 63631, - SPELL_SHOCK_BLAST_AURA = 63632, // Deprecated? It is never cast. + SPELL_FLAME_SUPPRESSANT_MK = 64570, + SPELL_NAPALM_SHELL = 63666, + SPELL_FORCE_CAST_NAPALM_SHELL = 64539, + SPELL_PLASMA_BLAST = 62997, + SPELL_SCRIPT_EFFECT_PLASMA_BLAST = 64542, + SPELL_SHOCK_BLAST = 63631, + SPELL_SHOCK_BLAST_AURA = 63632, // Deprecated? It is never cast. // VX-001 - SPELL_FLAME_SUPPRESSANT_VX = 65192, - SPELL_SPINNING_UP = 63414, - SPELL_HEAT_WAVE_AURA = 63679, - SPELL_HAND_PULSE_LEFT = 64348, - SPELL_HAND_PULSE_RIGHT = 64352, - SPELL_MOUNT_MKII = 64387, - SPELL_TORSO_DISABLED = 64120, + SPELL_FLAME_SUPPRESSANT_VX = 65192, + SPELL_SPINNING_UP = 63414, + SPELL_HEAT_WAVE_AURA = 63679, + SPELL_HAND_PULSE_LEFT = 64348, + SPELL_HAND_PULSE_RIGHT = 64352, + SPELL_MOUNT_MKII = 64387, + SPELL_TORSO_DISABLED = 64120, // Aerial Command Unit - SPELL_PLASMA_BALL_P1 = 63689, - SPELL_PLASMA_BALL_P2 = 65647, - SPELL_MOUNT_VX_001 = 64388, + SPELL_PLASMA_BALL_P1 = 63689, + SPELL_PLASMA_BALL_P2 = 65647, + SPELL_MOUNT_VX_001 = 64388, // Proximity Mines - SPELL_PROXIMITY_MINES = 63027, // Cast by Leviathan MK II - SPELL_PROXIMITY_MINE_EXPLOSION = 66351, - SPELL_PROXIMITY_MINE_TRIGGER = 65346, - SPELL_PROXIMITY_MINE_PERIODIC_TRIGGER = 65345, - SPELL_PERIODIC_PROXIMITY_AURA = 65345, - SPELL_SUMMON_PROXIMITY_MINE = 65347, + SPELL_PROXIMITY_MINES = 63027, // Cast by Leviathan MK II + SPELL_PROXIMITY_MINE_EXPLOSION = 66351, + SPELL_PROXIMITY_MINE_TRIGGER = 65346, + SPELL_PROXIMITY_MINE_PERIODIC_TRIGGER = 65345, + SPELL_PERIODIC_PROXIMITY_AURA = 65345, + SPELL_SUMMON_PROXIMITY_MINE = 65347, // Rapid Burst - SPELL_RAPID_BURST_LEFT = 63387, - SPELL_RAPID_BURST_RIGHT = 64019, - SPELL_RAPID_BURST = 63382, // Cast by VX-001 - SPELL_RAPID_BURST_TARGET_ME = 64841, // Cast by Burst Target - SPELL_SUMMON_BURST_TARGET = 64840, // Cast by VX-001 + SPELL_RAPID_BURST_LEFT = 63387, + SPELL_RAPID_BURST_RIGHT = 64019, + SPELL_RAPID_BURST = 63382, // Cast by VX-001 + SPELL_RAPID_BURST_TARGET_ME = 64841, // Cast by Burst Target + SPELL_SUMMON_BURST_TARGET = 64840, // Cast by VX-001 // Rocket Strike - SPELL_SUMMON_ROCKET_STRIKE = 63036, - SPELL_SCRIPT_EFFECT_ROCKET_STRIKE = 63681, // Cast by Rocket (Mimiron Visual) - SPELL_ROCKET_STRIKE = 64064, // Added in creature_template_addon - SPELL_ROCKET_STRIKE_SINGLE = 64402, // Cast by VX-001 - SPELL_ROCKET_STRIKE_BOTH = 65034, // Cast by VX-001 + SPELL_SUMMON_ROCKET_STRIKE = 63036, + SPELL_SCRIPT_EFFECT_ROCKET_STRIKE = 63681, // Cast by Rocket (Mimiron Visual) + SPELL_ROCKET_STRIKE = 64064, // Added in creature_template_addon + SPELL_ROCKET_STRIKE_SINGLE = 64402, // Cast by VX-001 + SPELL_ROCKET_STRIKE_BOTH = 65034, // Cast by VX-001 // Flames - SPELL_FLAMES_PERIODIC_TRIGGER = 64561, // Added in creature_template_addon - SPELL_SUMMON_FLAMES_SPREAD_TRIGGER = 64562, - SPELL_SUMMON_FLAMES_INITIAL = 64563, - SPELL_SUMMON_FLAMES_SPREAD = 64564, - SPELL_FLAMES = 64566, - SPELL_SCRIPT_EFFECT_SUMMON_FLAMES_INITIAL = 64567, + SPELL_FLAMES_PERIODIC_TRIGGER = 64561, // Added in creature_template_addon + SPELL_SUMMON_FLAMES_SPREAD_TRIGGER = 64562, + SPELL_SUMMON_FLAMES_INITIAL = 64563, + SPELL_SUMMON_FLAMES_SPREAD = 64564, + SPELL_FLAMES = 64566, + SPELL_SCRIPT_EFFECT_SUMMON_FLAMES_INITIAL = 64567, // Frost Bomb - SPELL_SCRIPT_EFFECT_FROST_BOMB = 64623, // Cast by VX-001 - SPELL_FROST_BOMB_LINKED = 64624, // Added in creature_template_addon - SPELL_FROST_BOMB_DUMMY = 64625, - SPELL_SUMMON_FROST_BOMB = 64627, // Cast by VX-001 - SPELL_FROST_BOMB_EXPLOSION = 64626, - SPELL_CLEAR_FIRES = 65354, + SPELL_SCRIPT_EFFECT_FROST_BOMB = 64623, // Cast by VX-001 + SPELL_FROST_BOMB_LINKED = 64624, // Added in creature_template_addon + SPELL_FROST_BOMB_DUMMY = 64625, + SPELL_SUMMON_FROST_BOMB = 64627, // Cast by VX-001 + SPELL_FROST_BOMB_EXPLOSION = 64626, + SPELL_CLEAR_FIRES = 65354, // Bots - SPELL_SUMMON_FIRE_BOT = 64622, - SPELL_SUMMON_FIRE_BOT_DUMMY = 64621, - SPELL_SUMMON_FIRE_BOT_TRIGGER = 64620, // Cast by Areal Command Unit - SPELL_DEAFENING_SIREN = 64616, // Added in creature_template_addon - SPELL_FIRE_SEARCH_AURA = 64617, // Added in creature_template_addon - SPELL_FIRE_SEARCH = 64618, - SPELL_WATER_SPRAY = 64619, - - SPELL_SUMMON_JUNK_BOT = 63819, - SPELL_SUMMON_JUNK_BOT_TRIGGER = 63820, // Cast by Areal Command Unit - SPELL_SUMMON_JUNK_BOT_DUMMY = 64398, - - SPELL_SUMMON_ASSAULT_BOT_TRIGGER = 64425, // Cast by Areal Command Unit - SPELL_SUMMON_ASSAULT_BOT_DUMMY = 64426, - SPELL_SUMMON_ASSAULT_BOT = 64427, - SPELL_MAGNETIC_FIELD = 64668, - - SPELL_SUMMON_BOMB_BOT = 63811, // Cast by Areal Command Unit - SPELL_BOMB_BOT_AURA = 63767, // Added in creature_template_addon + SPELL_SUMMON_FIRE_BOT = 64622, + SPELL_SUMMON_FIRE_BOT_DUMMY = 64621, + SPELL_SUMMON_FIRE_BOT_TRIGGER = 64620, // Cast by Areal Command Unit + SPELL_DEAFENING_SIREN = 64616, // Added in creature_template_addon + SPELL_FIRE_SEARCH_AURA = 64617, // Added in creature_template_addon + SPELL_FIRE_SEARCH = 64618, + SPELL_WATER_SPRAY = 64619, + + SPELL_SUMMON_JUNK_BOT = 63819, + SPELL_SUMMON_JUNK_BOT_TRIGGER = 63820, // Cast by Areal Command Unit + SPELL_SUMMON_JUNK_BOT_DUMMY = 64398, + + SPELL_SUMMON_ASSAULT_BOT_TRIGGER = 64425, // Cast by Areal Command Unit + SPELL_SUMMON_ASSAULT_BOT_DUMMY = 64426, + SPELL_SUMMON_ASSAULT_BOT = 64427, + SPELL_MAGNETIC_FIELD = 64668, + + SPELL_SUMMON_BOMB_BOT = 63811, // Cast by Areal Command Unit + SPELL_BOMB_BOT_AURA = 63767, // Added in creature_template_addon // Miscellaneous - SPELL_SELF_DESTRUCTION_AURA = 64610, - SPELL_SELF_DESTRUCTION_VISUAL = 64613, - SPELL_NOT_SO_FRIENDLY_FIRE = 65040, - SPELL_ELEVATOR_KNOCKBACK = 65096, // Cast by worldtrigger. - SPELL_VEHICLE_DAMAGED = 63415, - SPELL_EMERGENCY_MODE = 64582, // mkii, vx001, aerial, assault, junk - SPELL_EMERGENCY_MODE_TURRET = 65101, // Cast by Leviathan MK II, only hits Leviathan MK II turret - SPELL_SELF_REPAIR = 64383, - SPELL_MAGNETIC_CORE = 64436, - SPELL_MAGNETIC_CORE_VISUAL = 64438, - SPELL_HALF_HEAL = 64188, - SPELL_CLEAR_ALL_DEBUFFS = 34098, /// @todo: make use of this spell... - SPELL_FREEZE_ANIM_STUN = 63354, // used to prevent mkii from doing stuff?.. - SPELL_FREEZE_ANIM = 16245 // Idle aura. Freezes animation. + SPELL_SELF_DESTRUCTION_AURA = 64610, + SPELL_SELF_DESTRUCTION_VISUAL = 64613, + SPELL_NOT_SO_FRIENDLY_FIRE = 65040, + SPELL_ELEVATOR_KNOCKBACK = 65096, // Cast by worldtrigger. + SPELL_VEHICLE_DAMAGED = 63415, + SPELL_EMERGENCY_MODE = 64582, // mkii, vx001, aerial, assault, junk + SPELL_EMERGENCY_MODE_TURRET = 65101, // Cast by Leviathan MK II, only hits Leviathan MK II turret + SPELL_SELF_REPAIR = 64383, + SPELL_MAGNETIC_CORE = 64436, + SPELL_MAGNETIC_CORE_VISUAL = 64438, + SPELL_HALF_HEAL = 64188, + SPELL_CLEAR_ALL_DEBUFFS = 34098, /// @todo: make use of this spell... + SPELL_FREEZE_ANIM_STUN = 63354, // used to prevent mkii from doing stuff?.. + SPELL_FREEZE_ANIM = 16245 // Idle aura. Freezes animation. }; enum Data @@ -329,28 +329,20 @@ enum SeatIds : int8 ROCKET_SEAT_RIGHT = 6 }; -uint32 const RepairSpells[4] = -{ - SPELL_SEAT_1, - SPELL_SEAT_2, - SPELL_SEAT_3, - SPELL_SEAT_5 -}; +uint32 const RepairSpells[4] = {SPELL_SEAT_1, SPELL_SEAT_2, SPELL_SEAT_3, SPELL_SEAT_5}; -Position const VehicleRelocation[] = -{ - { 0.0f, 0.0f, 0.0f}, - { 2792.070f, 2596.320f, 364.3136f }, // WP_MKII_P1_IDLE - { 2765.945f, 2571.095f, 364.0636f }, // WP_MKII_P4_POS_1 - { 2768.195f, 2573.095f, 364.0636f }, // WP_MKII_P4_POS_2 - { 2763.820f, 2568.870f, 364.3136f }, // WP_MKII_P4_POS_3 - { 2761.215f, 2568.875f, 364.0636f }, // WP_MKII_P4_POS_4 - { 2744.610f, 2569.380f, 364.3136f }, // WP_MKII_P4_POS_5 - { 2748.513f, 2569.051f, 364.3136f } // WP_AERIAL_P4_POS +Position const VehicleRelocation[] = { + {0.0f, 0.0f, 0.0f}, {2792.070f, 2596.320f, 364.3136f}, // WP_MKII_P1_IDLE + {2765.945f, 2571.095f, 364.0636f}, // WP_MKII_P4_POS_1 + {2768.195f, 2573.095f, 364.0636f}, // WP_MKII_P4_POS_2 + {2763.820f, 2568.870f, 364.3136f}, // WP_MKII_P4_POS_3 + {2761.215f, 2568.875f, 364.0636f}, // WP_MKII_P4_POS_4 + {2744.610f, 2569.380f, 364.3136f}, // WP_MKII_P4_POS_5 + {2748.513f, 2569.051f, 364.3136f} // WP_AERIAL_P4_POS }; -Position const VX001SummonPos = { 2744.431f, 2569.385f, 364.3968f, 3.141593f }; -Position const ACUSummonPos = { 2744.650f, 2569.460f, 380.0000f, 3.141593f }; +Position const VX001SummonPos = {2744.431f, 2569.385f, 364.3968f, 3.141593f}; +Position const ACUSummonPos = {2744.650f, 2569.460f, 380.0000f, 3.141593f}; static bool IsEncounterFinished(Unit* who) { @@ -362,13 +354,11 @@ static bool IsEncounterFinished(Unit* who) if (!mkii || !vx001 || !aerial) return false; - if (mkii->GetStandState() == UNIT_STAND_STATE_DEAD && - vx001->GetStandState() == UNIT_STAND_STATE_DEAD && - aerial->GetStandState() == UNIT_STAND_STATE_DEAD) + if (mkii->GetStandState() == UNIT_STAND_STATE_DEAD && vx001->GetStandState() == UNIT_STAND_STATE_DEAD && aerial->GetStandState() == UNIT_STAND_STATE_DEAD) { - who->Kill(mkii); - who->Kill(vx001); - who->Kill(aerial); + Unit::Kill(who, mkii); + Unit::Kill(who, vx001); + Unit::Kill(who, aerial); mkii->DespawnOrUnsummon(120000); vx001->DespawnOrUnsummon(120000); aerial->DespawnOrUnsummon(120000); @@ -381,2355 +371,2442 @@ static bool IsEncounterFinished(Unit* who) class boss_mimiron : public CreatureScript { - public: - boss_mimiron() : CreatureScript("boss_mimiron") { } + public: + boss_mimiron() : CreatureScript("boss_mimiron") + { + } - struct boss_mimironAI : public BossAI + struct boss_mimironAI : public BossAI + { + boss_mimironAI(Creature* creature) : BossAI(creature, DATA_MIMIRON) { - boss_mimironAI(Creature* creature) : BossAI(creature, DATA_MIMIRON) - { - me->SetReactState(REACT_PASSIVE); - _fireFighter = false; - } + me->SetReactState(REACT_PASSIVE); + _fireFighter = false; + } - void DoAction(int32 action) override - { - switch (action) - { - case DO_ACTIVATE_VX001: - events.ScheduleEvent(EVENT_VX001_ACTIVATION_1, 1000); - break; - case DO_ACTIVATE_AERIAL: - events.ScheduleEvent(EVENT_AERIAL_ACTIVATION_1, 5000); - break; - case DO_ACTIVATE_V0L7R0N_1: - Talk(SAY_AERIAL_DEATH); - if (Creature* mkii = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_LEVIATHAN_MK_II))) - mkii->GetMotionMaster()->MovePoint(WP_MKII_P4_POS_1, VehicleRelocation[WP_MKII_P4_POS_1]); - break; - case DO_ACTIVATE_V0L7R0N_2: - events.ScheduleEvent(EVENT_VOL7RON_ACTIVATION_1, 1000); - break; - case DO_ACTIVATE_HARD_MODE: - _fireFighter = true; - DoZoneInCombat(me); - break; - default: - break; - } + void DoAction(int32 action) override + { + switch (action) + { + case DO_ACTIVATE_VX001: + events.ScheduleEvent(EVENT_VX001_ACTIVATION_1, 1000); + break; + case DO_ACTIVATE_AERIAL: + events.ScheduleEvent(EVENT_AERIAL_ACTIVATION_1, 5000); + break; + case DO_ACTIVATE_V0L7R0N_1: + Talk(SAY_AERIAL_DEATH); + if (Creature* mkii = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_LEVIATHAN_MK_II))) + mkii->GetMotionMaster()->MovePoint(WP_MKII_P4_POS_1, VehicleRelocation[WP_MKII_P4_POS_1]); + break; + case DO_ACTIVATE_V0L7R0N_2: + events.ScheduleEvent(EVENT_VOL7RON_ACTIVATION_1, 1000); + break; + case DO_ACTIVATE_HARD_MODE: + _fireFighter = true; + DoZoneInCombat(me); + break; + default: + break; } + } - void JustEngagedWith(Unit* who) override - { - if (!me->GetVehicleBase()) - return; + void JustEngagedWith(Unit* who) override + { + if (!me->GetVehicleBase()) + return; - BossAI::JustEngagedWith(who); - me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - me->RemoveAurasDueToSpell(SPELL_WELD); - DoCast(me->GetVehicleBase(), SPELL_SEAT_6); + BossAI::JustEngagedWith(who); + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + me->RemoveAurasDueToSpell(SPELL_WELD); + DoCast(me->GetVehicleBase(), SPELL_SEAT_6); - if (GameObject* button = instance->GetGameObject(DATA_MIMIRON_BUTTON)) - button->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); + if (GameObject* button = instance->GetGameObject(DATA_MIMIRON_BUTTON)) + button->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); - if (_fireFighter) - events.ScheduleEvent(EVENT_SUMMON_FLAMES, 3000); - events.ScheduleEvent(EVENT_INTRO_1, 1500); - } + if (_fireFighter) + events.ScheduleEvent(EVENT_SUMMON_FLAMES, 3000); + events.ScheduleEvent(EVENT_INTRO_1, 1500); + } - void JustDied(Unit* /*killer*/) override - { - instance->SetBossState(DATA_MIMIRON, DONE); - events.Reset(); - me->CombatStop(true); - me->SetDisableGravity(false); - DoCast(me, SPELL_SLEEP_VISUAL_1); - DoCastAOE(SPELL_DESPAWN_ASSAULT_BOTS); - me->ExitVehicle(); - // ExitVehicle() offset position is not implemented, so we make up for that with MoveJump()... - me->GetMotionMaster()->MoveJump(me->GetPositionX() + (10.f * std::cos(me->GetOrientation())), me->GetPositionY() + (10.f * std::sin(me->GetOrientation())), me->GetPositionZ(), me->GetOrientation(), 10.f, 5.f); - events.ScheduleEvent(EVENT_OUTTRO_1, 7000); - } + void JustDied(Unit* /*killer*/) override + { + instance->SetBossState(DATA_MIMIRON, DONE); + events.Reset(); + me->CombatStop(true); + me->SetDisableGravity(false); + DoCast(me, SPELL_SLEEP_VISUAL_1); + DoCastAOE(SPELL_DESPAWN_ASSAULT_BOTS); + me->ExitVehicle(); + // ExitVehicle() offset position is not implemented, so we make up for that with MoveJump()... + me->GetMotionMaster()->MoveJump( + me->GetPositionX() + (10.f * std::cos(me->GetOrientation())), me->GetPositionY() + (10.f * std::sin(me->GetOrientation())), me->GetPositionZ(), me->GetOrientation(), 10.f, 5.f); + events.ScheduleEvent(EVENT_OUTTRO_1, 7000); + } - void Reset() override - { - if (instance->GetBossState(DATA_MIMIRON) == DONE) // Mimiron will attempt to reset because he is not dead and will be set to friendly before despawning. - return; + void Reset() override + { + if (instance->GetBossState(DATA_MIMIRON) == DONE) // Mimiron will attempt to reset because he is not dead and will be set to friendly before despawning. + return; - _Reset(); - me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + _Reset(); + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - if (GameObject* elevator = instance->GetGameObject(DATA_MIMIRON_ELEVATOR)) - elevator->SetGoState(GO_STATE_ACTIVE); + if (GameObject* elevator = instance->GetGameObject(DATA_MIMIRON_ELEVATOR)) + elevator->SetGoState(GO_STATE_ACTIVE); - if (_fireFighter) - if (Creature* computer = instance->GetCreature(DATA_COMPUTER)) - computer->AI()->DoAction(DO_DEACTIVATE_COMPUTER); + if (_fireFighter) + if (Creature* computer = instance->GetCreature(DATA_COMPUTER)) + computer->AI()->DoAction(DO_DEACTIVATE_COMPUTER); - if (GameObject* button = instance->GetGameObject(DATA_MIMIRON_BUTTON)) - { - button->SetGoState(GO_STATE_READY); - button->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); - } + if (GameObject* button = instance->GetGameObject(DATA_MIMIRON_BUTTON)) + { + button->SetGoState(GO_STATE_READY); + button->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); + } - _fireFighter = false; - DoCast(me, SPELL_WELD); + _fireFighter = false; + DoCast(me, SPELL_WELD); - if (Unit* mkii = ObjectAccessor::GetUnit(*me, instance->GetGuidData(DATA_LEVIATHAN_MK_II))) - DoCast(mkii, SPELL_SEAT_3); - } + if (Unit* mkii = ObjectAccessor::GetUnit(*me, instance->GetGuidData(DATA_LEVIATHAN_MK_II))) + DoCast(mkii, SPELL_SEAT_3); + } - void UpdateAI(uint32 diff) override - { - if (!UpdateVictim() && instance->GetBossState(DATA_MIMIRON) != DONE) - return; + void UpdateAI(uint32 diff) override + { + if (!UpdateVictim() && instance->GetBossState(DATA_MIMIRON) != DONE) + return; - events.Update(diff); + events.Update(diff); - if (me->HasUnitState(UNIT_STATE_CASTING)) - return; + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; - while (uint32 eventId = events.ExecuteEvent()) + while (uint32 eventId = events.ExecuteEvent()) + { + switch (eventId) { - switch (eventId) + case EVENT_SUMMON_FLAMES: + if (Creature* worldtrigger = instance->GetCreature(DATA_MIMIRON_WORLD_TRIGGER)) + worldtrigger->CastSpell(nullptr, SPELL_SCRIPT_EFFECT_SUMMON_FLAMES_INITIAL, CastSpellExtraArgs(me->GetGUID()).AddSpellMod(SPELLVALUE_MAX_TARGETS, 3)); + events.RescheduleEvent(EVENT_SUMMON_FLAMES, 28000); + break; + case EVENT_INTRO_1: + Talk(_fireFighter ? SAY_HARDMODE_ON : SAY_MKII_ACTIVATE); + events.ScheduleEvent(EVENT_INTRO_2, 5000); + break; + case EVENT_INTRO_2: + if (Unit* mkii = me->GetVehicleBase()) { - case EVENT_SUMMON_FLAMES: - if (Creature* worldtrigger = instance->GetCreature(DATA_MIMIRON_WORLD_TRIGGER)) - worldtrigger->CastSpell(nullptr, SPELL_SCRIPT_EFFECT_SUMMON_FLAMES_INITIAL, CastSpellExtraArgs(me->GetGUID()).AddSpellMod(SPELLVALUE_MAX_TARGETS, 3)); - events.RescheduleEvent(EVENT_SUMMON_FLAMES, 28000); - break; - case EVENT_INTRO_1: - Talk(_fireFighter ? SAY_HARDMODE_ON : SAY_MKII_ACTIVATE); - events.ScheduleEvent(EVENT_INTRO_2, 5000); - break; - case EVENT_INTRO_2: - if (Unit* mkii = me->GetVehicleBase()) - { - DoCast(mkii, SPELL_SEAT_7); - mkii->RemoveAurasDueToSpell(SPELL_FREEZE_ANIM); - mkii->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); - } - events.ScheduleEvent(EVENT_INTRO_3, 2000); - break; - case EVENT_INTRO_3: - if (Creature* mkii = me->GetVehicleCreatureBase()) - mkii->AI()->DoAction(_fireFighter ? DO_HARDMODE_MKII : DO_START_MKII); - break; - case EVENT_VX001_ACTIVATION_1: - if (Unit* mkii = me->GetVehicleBase()) - mkii->SetFacingTo(3.686f); // fix magic number - events.ScheduleEvent(EVENT_VX001_ACTIVATION_2, 1000); - break; - case EVENT_VX001_ACTIVATION_2: - if (Unit* mkii = me->GetVehicleBase()) - DoCast(mkii, SPELL_SEAT_6); - events.ScheduleEvent(EVENT_VX001_ACTIVATION_3, 1000); - break; - case EVENT_VX001_ACTIVATION_3: - Talk(SAY_MKII_DEATH); - events.ScheduleEvent(EVENT_VX001_ACTIVATION_4, 5000); - break; - case EVENT_VX001_ACTIVATION_4: - if (GameObject* elevator = instance->GetGameObject(DATA_MIMIRON_ELEVATOR)) - elevator->SetGoState(GO_STATE_READY); - if (Creature* worldtrigger = instance->GetCreature(DATA_MIMIRON_WORLD_TRIGGER)) - worldtrigger->CastSpell(worldtrigger, SPELL_ELEVATOR_KNOCKBACK); - events.ScheduleEvent(EVENT_VX001_ACTIVATION_5, 6000); - break; - case EVENT_VX001_ACTIVATION_5: - if (GameObject* elevator = instance->GetGameObject(DATA_MIMIRON_ELEVATOR)) - elevator->SetGoState(GO_STATE_ACTIVE_ALTERNATIVE); - if (Creature* vx001 = me->SummonCreature(NPC_VX_001, VX001SummonPos, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 120000)) - vx001->CastSpell(vx001, SPELL_FREEZE_ANIM); - events.ScheduleEvent(EVENT_VX001_ACTIVATION_6, 19000); - break; - case EVENT_VX001_ACTIVATION_6: - if (Unit* vx001 = ObjectAccessor::GetUnit(*me, instance->GetGuidData(DATA_VX_001))) - DoCast(vx001, SPELL_SEAT_1); - events.ScheduleEvent(EVENT_VX001_ACTIVATION_7, 3500); - break; - case EVENT_VX001_ACTIVATION_7: - Talk(SAY_VX001_ACTIVATE); - events.ScheduleEvent(EVENT_VX001_ACTIVATION_8, 4000); - break; - case EVENT_VX001_ACTIVATION_8: - if (Unit* vx001 = me->GetVehicleBase()) - DoCast(vx001, SPELL_SEAT_2); - events.ScheduleEvent(EVENT_VX001_ACTIVATION_9, 3000); - break; - case EVENT_VX001_ACTIVATION_9: - if (Creature* vx001 = me->GetVehicleCreatureBase()) - vx001->AI()->DoAction(_fireFighter ? DO_HARDMODE_VX001 : DO_START_VX001); - break; - case EVENT_AERIAL_ACTIVATION_1: - if (Unit* mkii = me->GetVehicleBase()) - DoCast(mkii, SPELL_SEAT_5); - events.ScheduleEvent(EVENT_AERIAL_ACTIVATION_2, 2500); - break; - case EVENT_AERIAL_ACTIVATION_2: - Talk(SAY_VX001_DEATH); - events.ScheduleEvent(EVENT_AERIAL_ACTIVATION_3, 5000); - break; - case EVENT_AERIAL_ACTIVATION_3: - me->SummonCreature(NPC_AERIAL_COMMAND_UNIT, ACUSummonPos, TEMPSUMMON_MANUAL_DESPAWN); - events.ScheduleEvent(EVENT_AERIAL_ACTIVATION_4, 5000); - break; - case EVENT_AERIAL_ACTIVATION_4: - if (Unit* aerial = ObjectAccessor::GetUnit(*me, instance->GetGuidData(DATA_AERIAL_COMMAND_UNIT))) - me->CastSpell(aerial, SPELL_SEAT_1); - events.ScheduleEvent(EVENT_AERIAL_ACTIVATION_5, 2000); - break; - case EVENT_AERIAL_ACTIVATION_5: - Talk(SAY_AERIAL_ACTIVATE); - events.ScheduleEvent(EVENT_AERIAL_ACTIVATION_6, 8000); - break; - case EVENT_AERIAL_ACTIVATION_6: - if (Creature* acu = me->GetVehicleCreatureBase()) - acu->AI()->DoAction(_fireFighter? DO_HARDMODE_AERIAL : DO_START_AERIAL); - break; - case EVENT_VOL7RON_ACTIVATION_1: - if (Creature* mkii = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_LEVIATHAN_MK_II))) - mkii->SetFacingTo(float(M_PI)); - events.ScheduleEvent(EVENT_VOL7RON_ACTIVATION_2, 1000); - break; - case EVENT_VOL7RON_ACTIVATION_2: - if (Creature* mkii = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_LEVIATHAN_MK_II))) - { - if (Creature* vx001 = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_VX_001))) - { - vx001->RemoveAurasDueToSpell(SPELL_TORSO_DISABLED); - vx001->CastSpell(mkii, SPELL_MOUNT_MKII); - } - } - events.ScheduleEvent(EVENT_VOL7RON_ACTIVATION_3, 4500); - break; - case EVENT_VOL7RON_ACTIVATION_3: - if (Creature* mkii = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_LEVIATHAN_MK_II))) - mkii->GetMotionMaster()->MovePoint(WP_MKII_P4_POS_4, VehicleRelocation[WP_MKII_P4_POS_4]); - events.ScheduleEvent(EVENT_VOL7RON_ACTIVATION_4, 5000); - break; - case EVENT_VOL7RON_ACTIVATION_4: - if (Creature* vx001 = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_VX_001))) - { - if (Creature* aerial = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_AERIAL_COMMAND_UNIT))) - { - aerial->GetMotionMaster()->MoveLand(0, (aerial->GetPositionX(), aerial->GetPositionY(), aerial->GetPositionZ())); - - aerial->CastSpell(vx001, SPELL_MOUNT_VX_001); - aerial->CastSpell(aerial, SPELL_HALF_HEAL); - } - } - events.ScheduleEvent(EVENT_VOL7RON_ACTIVATION_5, 4000); - break; - case EVENT_VOL7RON_ACTIVATION_5: - Talk(SAY_V07TRON_ACTIVATE); - events.ScheduleEvent(EVENT_VOL7RON_ACTIVATION_6, 3000); - break; - case EVENT_VOL7RON_ACTIVATION_6: - if (Creature* vx001 = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_VX_001))) - DoCast(vx001, SPELL_SEAT_2); - events.ScheduleEvent(EVENT_VOL7RON_ACTIVATION_7, 5000); - break; - case EVENT_VOL7RON_ACTIVATION_7: - for (uint8 data = DATA_LEVIATHAN_MK_II; data <= DATA_AERIAL_COMMAND_UNIT; ++data) - if (Creature* mimironVehicle = ObjectAccessor::GetCreature(*me, instance->GetGuidData(data))) - mimironVehicle->AI()->DoAction(DO_ASSEMBLED_COMBAT); - break; - case EVENT_OUTTRO_1: - me->RemoveAurasDueToSpell(SPELL_SLEEP_VISUAL_1); - DoCast(me, SPELL_SLEEP_VISUAL_2); - me->SetFaction(FACTION_FRIENDLY); - events.ScheduleEvent(EVENT_OUTTRO_2, 3000); - break; - case EVENT_OUTTRO_2: - Talk(SAY_V07TRON_DEATH); - if (_fireFighter) - { - if (Creature* computer = instance->GetCreature(DATA_COMPUTER)) - computer->AI()->DoAction(DO_DEACTIVATE_COMPUTER); - me->SummonGameObject(RAID_MODE(GO_CACHE_OF_INNOVATION_FIREFIGHTER, GO_CACHE_OF_INNOVATION_FIREFIGHTER_HERO), 2744.040f, 2569.352f, 364.3135f, 3.124123f, QuaternionData(0.f, 0.f, 0.9999619f, 0.008734641f), 604800); - } - else - me->SummonGameObject(RAID_MODE(GO_CACHE_OF_INNOVATION, GO_CACHE_OF_INNOVATION_HERO), 2744.040f, 2569.352f, 364.3135f, 3.124123f, QuaternionData(0.f, 0.f, 0.9999619f, 0.008734641f), 604800); - events.ScheduleEvent(EVENT_OUTTRO_3, 11000); - break; - case EVENT_OUTTRO_3: - DoCast(me, SPELL_TELEPORT_VISUAL); - me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - me->DespawnOrUnsummon(1000); // sniffs say 6 sec after, but it doesnt matter. - break; - default: - break; + DoCast(mkii, SPELL_SEAT_7); + mkii->RemoveAurasDueToSpell(SPELL_FREEZE_ANIM); + mkii->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); } + events.ScheduleEvent(EVENT_INTRO_3, 2000); + break; + case EVENT_INTRO_3: + if (Creature* mkii = me->GetVehicleCreatureBase()) + mkii->AI()->DoAction(_fireFighter ? DO_HARDMODE_MKII : DO_START_MKII); + break; + case EVENT_VX001_ACTIVATION_1: + if (Unit* mkii = me->GetVehicleBase()) + mkii->SetFacingTo(3.686f); // fix magic number + events.ScheduleEvent(EVENT_VX001_ACTIVATION_2, 1000); + break; + case EVENT_VX001_ACTIVATION_2: + if (Unit* mkii = me->GetVehicleBase()) + DoCast(mkii, SPELL_SEAT_6); + events.ScheduleEvent(EVENT_VX001_ACTIVATION_3, 1000); + break; + case EVENT_VX001_ACTIVATION_3: + Talk(SAY_MKII_DEATH); + events.ScheduleEvent(EVENT_VX001_ACTIVATION_4, 5000); + break; + case EVENT_VX001_ACTIVATION_4: + if (GameObject* elevator = instance->GetGameObject(DATA_MIMIRON_ELEVATOR)) + elevator->SetGoState(GO_STATE_READY); + if (Creature* worldtrigger = instance->GetCreature(DATA_MIMIRON_WORLD_TRIGGER)) + worldtrigger->CastSpell(worldtrigger, SPELL_ELEVATOR_KNOCKBACK); + events.ScheduleEvent(EVENT_VX001_ACTIVATION_5, 6000); + break; + case EVENT_VX001_ACTIVATION_5: + if (GameObject* elevator = instance->GetGameObject(DATA_MIMIRON_ELEVATOR)) + elevator->SetGoState(GO_STATE_ACTIVE_ALTERNATIVE); + if (Creature* vx001 = me->SummonCreature(NPC_VX_001, VX001SummonPos, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 120000)) + vx001->CastSpell(vx001, SPELL_FREEZE_ANIM); + events.ScheduleEvent(EVENT_VX001_ACTIVATION_6, 19000); + break; + case EVENT_VX001_ACTIVATION_6: + if (Unit* vx001 = ObjectAccessor::GetUnit(*me, instance->GetGuidData(DATA_VX_001))) + DoCast(vx001, SPELL_SEAT_1); + events.ScheduleEvent(EVENT_VX001_ACTIVATION_7, 3500); + break; + case EVENT_VX001_ACTIVATION_7: + Talk(SAY_VX001_ACTIVATE); + events.ScheduleEvent(EVENT_VX001_ACTIVATION_8, 4000); + break; + case EVENT_VX001_ACTIVATION_8: + if (Unit* vx001 = me->GetVehicleBase()) + DoCast(vx001, SPELL_SEAT_2); + events.ScheduleEvent(EVENT_VX001_ACTIVATION_9, 3000); + break; + case EVENT_VX001_ACTIVATION_9: + if (Creature* vx001 = me->GetVehicleCreatureBase()) + vx001->AI()->DoAction(_fireFighter ? DO_HARDMODE_VX001 : DO_START_VX001); + break; + case EVENT_AERIAL_ACTIVATION_1: + if (Unit* mkii = me->GetVehicleBase()) + DoCast(mkii, SPELL_SEAT_5); + events.ScheduleEvent(EVENT_AERIAL_ACTIVATION_2, 2500); + break; + case EVENT_AERIAL_ACTIVATION_2: + Talk(SAY_VX001_DEATH); + events.ScheduleEvent(EVENT_AERIAL_ACTIVATION_3, 5000); + break; + case EVENT_AERIAL_ACTIVATION_3: + me->SummonCreature(NPC_AERIAL_COMMAND_UNIT, ACUSummonPos, TEMPSUMMON_MANUAL_DESPAWN); + events.ScheduleEvent(EVENT_AERIAL_ACTIVATION_4, 5000); + break; + case EVENT_AERIAL_ACTIVATION_4: + if (Unit* aerial = ObjectAccessor::GetUnit(*me, instance->GetGuidData(DATA_AERIAL_COMMAND_UNIT))) + me->CastSpell(aerial, SPELL_SEAT_1); + events.ScheduleEvent(EVENT_AERIAL_ACTIVATION_5, 2000); + break; + case EVENT_AERIAL_ACTIVATION_5: + Talk(SAY_AERIAL_ACTIVATE); + events.ScheduleEvent(EVENT_AERIAL_ACTIVATION_6, 8000); + break; + case EVENT_AERIAL_ACTIVATION_6: + if (Creature* acu = me->GetVehicleCreatureBase()) + acu->AI()->DoAction(_fireFighter ? DO_HARDMODE_AERIAL : DO_START_AERIAL); + break; + case EVENT_VOL7RON_ACTIVATION_1: + if (Creature* mkii = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_LEVIATHAN_MK_II))) + mkii->SetFacingTo(float(M_PI)); + events.ScheduleEvent(EVENT_VOL7RON_ACTIVATION_2, 1000); + break; + case EVENT_VOL7RON_ACTIVATION_2: + if (Creature* mkii = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_LEVIATHAN_MK_II))) + { + if (Creature* vx001 = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_VX_001))) + { + vx001->RemoveAurasDueToSpell(SPELL_TORSO_DISABLED); + vx001->CastSpell(mkii, SPELL_MOUNT_MKII); + } + } + events.ScheduleEvent(EVENT_VOL7RON_ACTIVATION_3, 4500); + break; + case EVENT_VOL7RON_ACTIVATION_3: + if (Creature* mkii = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_LEVIATHAN_MK_II))) + mkii->GetMotionMaster()->MovePoint(WP_MKII_P4_POS_4, VehicleRelocation[WP_MKII_P4_POS_4]); + events.ScheduleEvent(EVENT_VOL7RON_ACTIVATION_4, 5000); + break; + case EVENT_VOL7RON_ACTIVATION_4: + if (Creature* vx001 = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_VX_001))) + { + if (Creature* aerial = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_AERIAL_COMMAND_UNIT))) + { + aerial->GetMotionMaster()->MoveLand(0, (aerial->GetPositionX(), aerial->GetPositionY(), aerial->GetPositionZ())); - if (me->HasUnitState(UNIT_STATE_CASTING)) - return; + aerial->CastSpell(vx001, SPELL_MOUNT_VX_001); + aerial->CastSpell(aerial, SPELL_HALF_HEAL); + } + } + events.ScheduleEvent(EVENT_VOL7RON_ACTIVATION_5, 4000); + break; + case EVENT_VOL7RON_ACTIVATION_5: + Talk(SAY_V07TRON_ACTIVATE); + events.ScheduleEvent(EVENT_VOL7RON_ACTIVATION_6, 3000); + break; + case EVENT_VOL7RON_ACTIVATION_6: + if (Creature* vx001 = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_VX_001))) + DoCast(vx001, SPELL_SEAT_2); + events.ScheduleEvent(EVENT_VOL7RON_ACTIVATION_7, 5000); + break; + case EVENT_VOL7RON_ACTIVATION_7: + for (uint8 data = DATA_LEVIATHAN_MK_II; data <= DATA_AERIAL_COMMAND_UNIT; ++data) + if (Creature* mimironVehicle = ObjectAccessor::GetCreature(*me, instance->GetGuidData(data))) + mimironVehicle->AI()->DoAction(DO_ASSEMBLED_COMBAT); + break; + case EVENT_OUTTRO_1: + me->RemoveAurasDueToSpell(SPELL_SLEEP_VISUAL_1); + DoCast(me, SPELL_SLEEP_VISUAL_2); + me->SetFaction(FACTION_FRIENDLY); + events.ScheduleEvent(EVENT_OUTTRO_2, 3000); + break; + case EVENT_OUTTRO_2: + Talk(SAY_V07TRON_DEATH); + if (_fireFighter) + { + if (Creature* computer = instance->GetCreature(DATA_COMPUTER)) + computer->AI()->DoAction(DO_DEACTIVATE_COMPUTER); + me->SummonGameObject(RAID_MODE(GO_CACHE_OF_INNOVATION_FIREFIGHTER, GO_CACHE_OF_INNOVATION_FIREFIGHTER_HERO), 2744.040f, 2569.352f, 364.3135f, 3.124123f, + QuaternionData(0.f, 0.f, 0.9999619f, 0.008734641f), 604800); + } + else + me->SummonGameObject( + RAID_MODE(GO_CACHE_OF_INNOVATION, GO_CACHE_OF_INNOVATION_HERO), 2744.040f, 2569.352f, 364.3135f, 3.124123f, QuaternionData(0.f, 0.f, 0.9999619f, 0.008734641f), 604800); + events.ScheduleEvent(EVENT_OUTTRO_3, 11000); + break; + case EVENT_OUTTRO_3: + DoCast(me, SPELL_TELEPORT_VISUAL); + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + me->DespawnOrUnsummon(1000); // sniffs say 6 sec after, but it doesnt matter. + break; + default: + break; } + + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; } + } - private: - bool _fireFighter; - }; + private: + bool _fireFighter; + }; - CreatureAI* GetAI(Creature* creature) const override - { - return GetUlduarAI(creature); - } + CreatureAI* GetAI(Creature* creature) const override + { + return GetUlduarAI(creature); + } }; class boss_leviathan_mk_ii : public CreatureScript { - public: - boss_leviathan_mk_ii() : CreatureScript("boss_leviathan_mk_ii") { } + public: + boss_leviathan_mk_ii() : CreatureScript("boss_leviathan_mk_ii") + { + } - struct boss_leviathan_mk_iiAI : public BossAI + struct boss_leviathan_mk_iiAI : public BossAI + { + boss_leviathan_mk_iiAI(Creature* creature) : BossAI(creature, DATA_MIMIRON) { - boss_leviathan_mk_iiAI(Creature* creature) : BossAI(creature, DATA_MIMIRON) - { - _fireFighter = false; - _setupMine = true; - _setupBomb = true; - _setupRocket = true; - } + _fireFighter = false; + _setupMine = true; + _setupBomb = true; + _setupRocket = true; + } - void DamageTaken(Unit* who, uint32 &damage) override + void DamageTaken(Unit* who, uint32& damage) override + { + if (damage >= me->GetHealth()) { - if (damage >= me->GetHealth()) - { - damage = me->GetHealth() - 1; // Let creature fall to 1 hp, but do not let it die or damage itself with SetHealth(). - me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - DoCast(me, SPELL_VEHICLE_DAMAGED, true); - me->AttackStop(); - me->SetReactState(REACT_PASSIVE); - me->RemoveAllAurasExceptType(SPELL_AURA_CONTROL_VEHICLE, SPELL_AURA_MOD_INCREASE_HEALTH_PERCENT); + damage = me->GetHealth() - 1; // Let creature fall to 1 hp, but do not let it die or damage itself with SetHealth(). + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + DoCast(me, SPELL_VEHICLE_DAMAGED, true); + me->AttackStop(); + me->SetReactState(REACT_PASSIVE); + me->RemoveAllAurasExceptType(SPELL_AURA_CONTROL_VEHICLE, SPELL_AURA_MOD_INCREASE_HEALTH_PERCENT); - if (events.IsInPhase(PHASE_LEVIATHAN_MK_II)) - { - me->CastStop(); - if (Unit* turret = me->GetVehicleKit()->GetPassenger(3)) - turret->KillSelf(); + if (events.IsInPhase(PHASE_LEVIATHAN_MK_II)) + { + me->CastStop(); + if (Unit* turret = me->GetVehicleKit()->GetPassenger(3)) + turret->KillSelf(); - me->SetSpeedRate(MOVE_RUN, 1.5f); - me->GetMotionMaster()->MovePoint(WP_MKII_P1_IDLE, VehicleRelocation[WP_MKII_P1_IDLE]); - } - else if (events.IsInPhase(PHASE_VOL7RON)) - { - me->SetStandState(UNIT_STAND_STATE_DEAD); + me->SetSpeedRate(MOVE_RUN, 1.5f); + me->GetMotionMaster()->MovePoint(WP_MKII_P1_IDLE, VehicleRelocation[WP_MKII_P1_IDLE]); + } + else if (events.IsInPhase(PHASE_VOL7RON)) + { + me->SetStandState(UNIT_STAND_STATE_DEAD); - if (IsEncounterFinished(who)) - return; + if (IsEncounterFinished(who)) + return; - me->CastStop(); - DoCast(me, SPELL_SELF_REPAIR); - } - events.Reset(); + me->CastStop(); + DoCast(me, SPELL_SELF_REPAIR); } + events.Reset(); } + } - void DoAction(int32 action) override - { - switch (action) - { - case DO_HARDMODE_MKII: - _fireFighter = true; - DoCast(me, SPELL_EMERGENCY_MODE); - DoCastAOE(SPELL_EMERGENCY_MODE_TURRET); - events.ScheduleEvent(EVENT_FLAME_SUPPRESSANT_MK, 60000, 0, PHASE_LEVIATHAN_MK_II); - [[fallthrough]]; - case DO_START_MKII: - me->SetReactState(REACT_AGGRESSIVE); - events.SetPhase(PHASE_LEVIATHAN_MK_II); - - events.ScheduleEvent(EVENT_NAPALM_SHELL, 3000, 0, PHASE_LEVIATHAN_MK_II); - events.ScheduleEvent(EVENT_PLASMA_BLAST, 15000, 0, PHASE_LEVIATHAN_MK_II); - events.ScheduleEvent(EVENT_PROXIMITY_MINE, 5000); - events.ScheduleEvent(EVENT_SHOCK_BLAST, 18000); - break; - case DO_ASSEMBLED_COMBAT: - me->SetStandState(UNIT_STAND_STATE_STAND); - me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); - me->SetReactState(REACT_AGGRESSIVE); - - events.SetPhase(PHASE_VOL7RON); - events.ScheduleEvent(EVENT_PROXIMITY_MINE, 15000); - events.ScheduleEvent(EVENT_SHOCK_BLAST, 45000); - break; - default: - break; - } + void DoAction(int32 action) override + { + switch (action) + { + case DO_HARDMODE_MKII: + _fireFighter = true; + DoCast(me, SPELL_EMERGENCY_MODE); + DoCastAOE(SPELL_EMERGENCY_MODE_TURRET); + events.ScheduleEvent(EVENT_FLAME_SUPPRESSANT_MK, 60000, 0, PHASE_LEVIATHAN_MK_II); + [[fallthrough]]; + case DO_START_MKII: + me->SetReactState(REACT_AGGRESSIVE); + events.SetPhase(PHASE_LEVIATHAN_MK_II); + + events.ScheduleEvent(EVENT_NAPALM_SHELL, 3000, 0, PHASE_LEVIATHAN_MK_II); + events.ScheduleEvent(EVENT_PLASMA_BLAST, 15000, 0, PHASE_LEVIATHAN_MK_II); + events.ScheduleEvent(EVENT_PROXIMITY_MINE, 5000); + events.ScheduleEvent(EVENT_SHOCK_BLAST, 18000); + break; + case DO_ASSEMBLED_COMBAT: + me->SetStandState(UNIT_STAND_STATE_STAND); + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); + me->SetReactState(REACT_AGGRESSIVE); + + events.SetPhase(PHASE_VOL7RON); + events.ScheduleEvent(EVENT_PROXIMITY_MINE, 15000); + events.ScheduleEvent(EVENT_SHOCK_BLAST, 45000); + break; + default: + break; } + } - uint32 GetData(uint32 type) const override + uint32 GetData(uint32 type) const override + { + switch (type) { - switch (type) - { - case DATA_SETUP_MINE: - return _setupMine; - case DATA_SETUP_BOMB: - return _setupBomb; - case DATA_SETUP_ROCKET: - return _setupRocket; - case DATA_FIREFIGHTER: - return _fireFighter; - default: - return 0; - } + case DATA_SETUP_MINE: + return _setupMine; + case DATA_SETUP_BOMB: + return _setupBomb; + case DATA_SETUP_ROCKET: + return _setupRocket; + case DATA_FIREFIGHTER: + return _fireFighter; + default: + return 0; } + } - void JustSummoned(Creature* summon) override - { - summons.Summon(summon); + void JustSummoned(Creature* summon) override + { + summons.Summon(summon); + } + + void KilledUnit(Unit* victim) override + { + if (victim->GetTypeId() == TYPEID_PLAYER) + if (Creature* mimiron = instance->GetCreature(DATA_MIMIRON)) + mimiron->AI()->Talk(events.IsInPhase(PHASE_LEVIATHAN_MK_II) ? SAY_MKII_SLAY : SAY_V07TRON_SLAY); + } + + void MovementInform(uint32 type, uint32 point) override + { + if (type != POINT_MOTION_TYPE) + return; + + switch (point) + { + case WP_MKII_P1_IDLE: + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + DoCast(me, SPELL_HALF_HEAL); + + if (Creature* mimiron = instance->GetCreature(DATA_MIMIRON)) + mimiron->AI()->DoAction(DO_ACTIVATE_VX001); + break; + case WP_MKII_P4_POS_1: + events.ScheduleEvent(EVENT_MOVE_POINT_2, 1); + break; + case WP_MKII_P4_POS_2: + events.ScheduleEvent(EVENT_MOVE_POINT_3, 1); + break; + case WP_MKII_P4_POS_3: + if (Creature* mimiron = instance->GetCreature(DATA_MIMIRON)) + mimiron->AI()->DoAction(DO_ACTIVATE_V0L7R0N_2); + break; + case WP_MKII_P4_POS_4: + events.ScheduleEvent(EVENT_MOVE_POINT_5, 1); + break; + default: + break; } + } + + void Reset() override + { + _Reset(); + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); + me->SetReactState(REACT_PASSIVE); + _fireFighter = false; + _setupMine = true; + _setupBomb = true; + _setupRocket = true; + DoCast(me, SPELL_FREEZE_ANIM); + } - void KilledUnit(Unit* victim) override + void SetData(uint32 id, uint32 data) override + { + switch (id) { - if (victim->GetTypeId() == TYPEID_PLAYER) - if (Creature* mimiron = instance->GetCreature(DATA_MIMIRON)) - mimiron->AI()->Talk(events.IsInPhase(PHASE_LEVIATHAN_MK_II) ? SAY_MKII_SLAY : SAY_V07TRON_SLAY); + case DATA_SETUP_MINE: + _setupMine = data != 0; + break; + case DATA_SETUP_BOMB: + _setupBomb = data != 0; + break; + case DATA_SETUP_ROCKET: + _setupRocket = data != 0; + break; + default: + break; } + } - void MovementInform(uint32 type, uint32 point) override - { - if (type != POINT_MOTION_TYPE) - return; + void UpdateAI(uint32 diff) override + { + if (!UpdateVictim()) + return; - switch (point) - { - case WP_MKII_P1_IDLE: - me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - DoCast(me, SPELL_HALF_HEAL); - - if (Creature* mimiron = instance->GetCreature(DATA_MIMIRON)) - mimiron->AI()->DoAction(DO_ACTIVATE_VX001); - break; - case WP_MKII_P4_POS_1: - events.ScheduleEvent(EVENT_MOVE_POINT_2, 1); - break; - case WP_MKII_P4_POS_2: - events.ScheduleEvent(EVENT_MOVE_POINT_3, 1); - break; - case WP_MKII_P4_POS_3: - if (Creature* mimiron = instance->GetCreature(DATA_MIMIRON)) - mimiron->AI()->DoAction(DO_ACTIVATE_V0L7R0N_2); - break; - case WP_MKII_P4_POS_4: - events.ScheduleEvent(EVENT_MOVE_POINT_5, 1); - break; - default: - break; - } - } + events.Update(diff); - void Reset() override - { - _Reset(); - me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); - me->SetReactState(REACT_PASSIVE); - _fireFighter = false; - _setupMine = true; - _setupBomb = true; - _setupRocket = true; - DoCast(me, SPELL_FREEZE_ANIM); - } + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; - void SetData(uint32 id, uint32 data) override + while (uint32 eventId = events.ExecuteEvent()) { - switch (id) + switch (eventId) { - case DATA_SETUP_MINE: - _setupMine = data != 0; - break; - case DATA_SETUP_BOMB: - _setupBomb = data != 0; - break; - case DATA_SETUP_ROCKET: - _setupRocket = data != 0; - break; - default: - break; + case EVENT_PROXIMITY_MINE: + DoCastAOE(SPELL_PROXIMITY_MINES); + events.RescheduleEvent(EVENT_PROXIMITY_MINE, 35000); + break; + case EVENT_PLASMA_BLAST: + DoCastVictim(SPELL_SCRIPT_EFFECT_PLASMA_BLAST); + events.RescheduleEvent(EVENT_PLASMA_BLAST, urand(30000, 45000), 0, PHASE_LEVIATHAN_MK_II); + + if (events.GetTimeUntilEvent(EVENT_NAPALM_SHELL) < 9000) + events.RescheduleEvent(EVENT_NAPALM_SHELL, 9000, 0, PHASE_LEVIATHAN_MK_II); // The actual spell is cast by the turret, we should not let it interrupt itself. + break; + case EVENT_SHOCK_BLAST: + DoCastAOE(SPELL_SHOCK_BLAST); + events.RescheduleEvent(EVENT_SHOCK_BLAST, urand(34000, 36000)); + break; + case EVENT_FLAME_SUPPRESSANT_MK: + DoCastAOE(SPELL_FLAME_SUPPRESSANT_MK); + events.RescheduleEvent(EVENT_FLAME_SUPPRESSANT_MK, 60000, 0, PHASE_LEVIATHAN_MK_II); + break; + case EVENT_NAPALM_SHELL: + DoCastAOE(SPELL_FORCE_CAST_NAPALM_SHELL); + events.RescheduleEvent(EVENT_NAPALM_SHELL, urand(6000, 15000), 0, PHASE_LEVIATHAN_MK_II); + + if (events.GetTimeUntilEvent(EVENT_PLASMA_BLAST) < 2000) + events.RescheduleEvent(EVENT_PLASMA_BLAST, 2000, 0, PHASE_LEVIATHAN_MK_II); // The actual spell is cast by the turret, we should not let it interrupt itself. + break; + case EVENT_MOVE_POINT_2: + me->GetMotionMaster()->MovePoint(WP_MKII_P4_POS_2, VehicleRelocation[WP_MKII_P4_POS_2]); + break; + case EVENT_MOVE_POINT_3: + me->GetMotionMaster()->MovePoint(WP_MKII_P4_POS_3, VehicleRelocation[WP_MKII_P4_POS_3]); + break; + case EVENT_MOVE_POINT_5: + me->GetMotionMaster()->MovePoint(WP_MKII_P4_POS_5, VehicleRelocation[WP_MKII_P4_POS_5]); + break; + default: + break; } - } - - void UpdateAI(uint32 diff) override - { - if (!UpdateVictim()) - return; - - events.Update(diff); if (me->HasUnitState(UNIT_STATE_CASTING)) return; - - while (uint32 eventId = events.ExecuteEvent()) - { - switch (eventId) - { - case EVENT_PROXIMITY_MINE: - DoCastAOE(SPELL_PROXIMITY_MINES); - events.RescheduleEvent(EVENT_PROXIMITY_MINE, 35000); - break; - case EVENT_PLASMA_BLAST: - DoCastVictim(SPELL_SCRIPT_EFFECT_PLASMA_BLAST); - events.RescheduleEvent(EVENT_PLASMA_BLAST, urand(30000, 45000), 0, PHASE_LEVIATHAN_MK_II); - - if (events.GetTimeUntilEvent(EVENT_NAPALM_SHELL) < 9000) - events.RescheduleEvent(EVENT_NAPALM_SHELL, 9000, 0, PHASE_LEVIATHAN_MK_II); // The actual spell is cast by the turret, we should not let it interrupt itself. - break; - case EVENT_SHOCK_BLAST: - DoCastAOE(SPELL_SHOCK_BLAST); - events.RescheduleEvent(EVENT_SHOCK_BLAST, urand(34000, 36000)); - break; - case EVENT_FLAME_SUPPRESSANT_MK: - DoCastAOE(SPELL_FLAME_SUPPRESSANT_MK); - events.RescheduleEvent(EVENT_FLAME_SUPPRESSANT_MK, 60000, 0, PHASE_LEVIATHAN_MK_II); - break; - case EVENT_NAPALM_SHELL: - DoCastAOE(SPELL_FORCE_CAST_NAPALM_SHELL); - events.RescheduleEvent(EVENT_NAPALM_SHELL, urand(6000, 15000), 0, PHASE_LEVIATHAN_MK_II); - - if (events.GetTimeUntilEvent(EVENT_PLASMA_BLAST) < 2000) - events.RescheduleEvent(EVENT_PLASMA_BLAST, 2000, 0, PHASE_LEVIATHAN_MK_II); // The actual spell is cast by the turret, we should not let it interrupt itself. - break; - case EVENT_MOVE_POINT_2: - me->GetMotionMaster()->MovePoint(WP_MKII_P4_POS_2, VehicleRelocation[WP_MKII_P4_POS_2]); - break; - case EVENT_MOVE_POINT_3: - me->GetMotionMaster()->MovePoint(WP_MKII_P4_POS_3, VehicleRelocation[WP_MKII_P4_POS_3]); - break; - case EVENT_MOVE_POINT_5: - me->GetMotionMaster()->MovePoint(WP_MKII_P4_POS_5, VehicleRelocation[WP_MKII_P4_POS_5]); - break; - default: - break; - } - - if (me->HasUnitState(UNIT_STATE_CASTING)) - return; - } - DoMeleeAttackIfReady(); } + DoMeleeAttackIfReady(); + } - private: - bool _fireFighter; - bool _setupMine; - bool _setupBomb; - bool _setupRocket; - }; + private: + bool _fireFighter; + bool _setupMine; + bool _setupBomb; + bool _setupRocket; + }; - CreatureAI* GetAI(Creature* creature) const override - { - return GetUlduarAI(creature); - } + CreatureAI* GetAI(Creature* creature) const override + { + return GetUlduarAI(creature); + } }; class boss_vx_001 : public CreatureScript { - public: - boss_vx_001() : CreatureScript("boss_vx_001") { } + public: + boss_vx_001() : CreatureScript("boss_vx_001") + { + } - struct boss_vx_001AI : public BossAI + struct boss_vx_001AI : public BossAI + { + boss_vx_001AI(Creature* creature) : BossAI(creature, DATA_MIMIRON) { - boss_vx_001AI(Creature* creature) : BossAI(creature, DATA_MIMIRON) - { - me->SetDisableGravity(true); // This is the unfold visual state of VX-001, it has to be set on create as it requires an objectupdate if set later. - me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_SPECIAL_UNARMED); // This is a hack to force the yet to be unfolded visual state. - me->SetReactState(REACT_PASSIVE); - _fireFighter = false; - } + me->SetDisableGravity(true); // This is the unfold visual state of VX-001, it has to be set on create as it requires an objectupdate if set later. + me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_SPECIAL_UNARMED); // This is a hack to force the yet to be unfolded visual state. + me->SetReactState(REACT_PASSIVE); + _fireFighter = false; + } - void DamageTaken(Unit* who, uint32 &damage) override + void DamageTaken(Unit* who, uint32& damage) override + { + if (damage >= me->GetHealth()) { - if (damage >= me->GetHealth()) - { - damage = me->GetHealth() - 1; // Let creature fall to 1 hp, but do not let it die or damage itself with SetHealth(). - me->AttackStop(); - DoCast(me, SPELL_VEHICLE_DAMAGED, true); - me->RemoveAllAurasExceptType(SPELL_AURA_CONTROL_VEHICLE, SPELL_AURA_MOD_INCREASE_HEALTH_PERCENT); + damage = me->GetHealth() - 1; // Let creature fall to 1 hp, but do not let it die or damage itself with SetHealth(). + me->AttackStop(); + DoCast(me, SPELL_VEHICLE_DAMAGED, true); + me->RemoveAllAurasExceptType(SPELL_AURA_CONTROL_VEHICLE, SPELL_AURA_MOD_INCREASE_HEALTH_PERCENT); - if (events.IsInPhase(PHASE_VX_001)) - { - me->CastStop(); - me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); // | UNIT_FLAG_NOT_SELECTABLE); - DoCast(me, SPELL_HALF_HEAL); // has no effect, wat - DoCast(me, SPELL_TORSO_DISABLED); - if (Creature* mimiron = instance->GetCreature(DATA_MIMIRON)) - mimiron->AI()->DoAction(DO_ACTIVATE_AERIAL); - } - else if (events.IsInPhase(PHASE_VOL7RON)) - { - me->SetStandState(UNIT_STAND_STATE_DEAD); - me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + if (events.IsInPhase(PHASE_VX_001)) + { + me->CastStop(); + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); // | UNIT_FLAG_NOT_SELECTABLE); + DoCast(me, SPELL_HALF_HEAL); // has no effect, wat + DoCast(me, SPELL_TORSO_DISABLED); + if (Creature* mimiron = instance->GetCreature(DATA_MIMIRON)) + mimiron->AI()->DoAction(DO_ACTIVATE_AERIAL); + } + else if (events.IsInPhase(PHASE_VOL7RON)) + { + me->SetStandState(UNIT_STAND_STATE_DEAD); + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - if (IsEncounterFinished(who)) - return; + if (IsEncounterFinished(who)) + return; - me->CastStop(); - DoCast(me, SPELL_SELF_REPAIR); - } - events.Reset(); + me->CastStop(); + DoCast(me, SPELL_SELF_REPAIR); } + events.Reset(); } + } - void DoAction(int32 action) override - { - switch (action) - { - case DO_HARDMODE_VX001: - _fireFighter = true; - DoCast(me, SPELL_EMERGENCY_MODE); - events.ScheduleEvent(EVENT_FROST_BOMB, 1000); - events.ScheduleEvent(EVENT_FLAME_SUPPRESSANT_VX, 6000); - [[fallthrough]]; - case DO_START_VX001: - me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); - me->SetImmuneToPC(false); - me->RemoveAurasDueToSpell(SPELL_FREEZE_ANIM); - me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_NONE); // Remove emotestate. - //me->SetHover(true); // Blizzard handles hover animation like this it seems. - DoCast(me, SPELL_HEAT_WAVE_AURA); - - events.SetPhase(PHASE_VX_001); - events.ScheduleEvent(EVENT_ROCKET_STRIKE, 20000); - events.ScheduleEvent(EVENT_SPINNING_UP, urand(30000, 35000)); - events.ScheduleEvent(EVENT_RAPID_BURST, 500, 0, PHASE_VX_001); - break; - case DO_ASSEMBLED_COMBAT: - me->SetStandState(UNIT_STAND_STATE_STAND); - me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); - - events.SetPhase(PHASE_VOL7RON); - events.ScheduleEvent(EVENT_ROCKET_STRIKE, 20000); - events.ScheduleEvent(EVENT_SPINNING_UP, urand(30000, 35000)); - events.ScheduleEvent(EVENT_HAND_PULSE, 500, 0, PHASE_VOL7RON); - if (_fireFighter) - events.ScheduleEvent(EVENT_FROST_BOMB, 1000); - break; - default: - break; - } + void DoAction(int32 action) override + { + switch (action) + { + case DO_HARDMODE_VX001: + _fireFighter = true; + DoCast(me, SPELL_EMERGENCY_MODE); + events.ScheduleEvent(EVENT_FROST_BOMB, 1000); + events.ScheduleEvent(EVENT_FLAME_SUPPRESSANT_VX, 6000); + [[fallthrough]]; + case DO_START_VX001: + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); + me->SetImmuneToPC(false); + me->RemoveAurasDueToSpell(SPELL_FREEZE_ANIM); + me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_NONE); // Remove emotestate. + // me->SetHover(true); // Blizzard handles hover animation like this it seems. + DoCast(me, SPELL_HEAT_WAVE_AURA); + + events.SetPhase(PHASE_VX_001); + events.ScheduleEvent(EVENT_ROCKET_STRIKE, 20000); + events.ScheduleEvent(EVENT_SPINNING_UP, urand(30000, 35000)); + events.ScheduleEvent(EVENT_RAPID_BURST, 500, 0, PHASE_VX_001); + break; + case DO_ASSEMBLED_COMBAT: + me->SetStandState(UNIT_STAND_STATE_STAND); + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); + + events.SetPhase(PHASE_VOL7RON); + events.ScheduleEvent(EVENT_ROCKET_STRIKE, 20000); + events.ScheduleEvent(EVENT_SPINNING_UP, urand(30000, 35000)); + events.ScheduleEvent(EVENT_HAND_PULSE, 500, 0, PHASE_VOL7RON); + if (_fireFighter) + events.ScheduleEvent(EVENT_FROST_BOMB, 1000); + break; + default: + break; } + } - void EnterEvadeMode(EvadeReason /*why*/) override - { - summons.DespawnAll(); - } + void EnterEvadeMode(EvadeReason /*why*/) override + { + summons.DespawnAll(); + } - void JustSummoned(Creature* summon) override - { - summons.Summon(summon); - if (summon->GetEntry() == NPC_BURST_TARGET) - summon->CastSpell(me, SPELL_RAPID_BURST_TARGET_ME); - } + void JustSummoned(Creature* summon) override + { + summons.Summon(summon); + if (summon->GetEntry() == NPC_BURST_TARGET) + summon->CastSpell(me, SPELL_RAPID_BURST_TARGET_ME); + } - void KilledUnit(Unit* victim) override - { - if (victim->GetTypeId() == TYPEID_PLAYER) - if (Creature* mimiron = instance->GetCreature(DATA_MIMIRON)) - mimiron->AI()->Talk(events.IsInPhase(PHASE_VX_001) ? SAY_VX001_SLAY : SAY_V07TRON_SLAY); - } + void KilledUnit(Unit* victim) override + { + if (victim->GetTypeId() == TYPEID_PLAYER) + if (Creature* mimiron = instance->GetCreature(DATA_MIMIRON)) + mimiron->AI()->Talk(events.IsInPhase(PHASE_VX_001) ? SAY_VX001_SLAY : SAY_V07TRON_SLAY); + } + + void SpellHit(Unit* caster, SpellInfo const* /*spellProto*/) override + { + if (caster->GetEntry() == NPC_BURST_TARGET && !me->HasUnitState(UNIT_STATE_CASTING)) + DoCast(caster, SPELL_RAPID_BURST); + } + + void UpdateAI(uint32 diff) override + { + if (!UpdateVictim()) + return; + + events.Update(diff); - void SpellHit(Unit* caster, SpellInfo const* /*spellProto*/) override + // Handle rotation during SPELL_SPINNING_UP, SPELL_P3WX2_LASER_BARRAGE, SPELL_RAPID_BURST, and SPELL_HAND_PULSE_LEFT/RIGHT + if (me->HasUnitState(UNIT_STATE_CASTING)) { - if (caster->GetEntry() == NPC_BURST_TARGET && !me->HasUnitState(UNIT_STATE_CASTING)) - DoCast(caster, SPELL_RAPID_BURST); + if (Creature* channelTarget = ObjectAccessor::GetCreature(*me, me->GetChannelObjectGuid())) + me->SetFacingToObject(channelTarget); + return; } - void UpdateAI(uint32 diff) override + while (uint32 eventId = events.ExecuteEvent()) { - if (!UpdateVictim()) - return; - - events.Update(diff); - - // Handle rotation during SPELL_SPINNING_UP, SPELL_P3WX2_LASER_BARRAGE, SPELL_RAPID_BURST, and SPELL_HAND_PULSE_LEFT/RIGHT - if (me->HasUnitState(UNIT_STATE_CASTING)) + switch (eventId) { - if (Creature* channelTarget = ObjectAccessor::GetCreature(*me, me->GetChannelObjectGuid())) - me->SetFacingToObject(channelTarget); - return; + case EVENT_RAPID_BURST: + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 120, true)) + DoCast(target, SPELL_SUMMON_BURST_TARGET); + events.RescheduleEvent(EVENT_RAPID_BURST, 3000, 0, PHASE_VX_001); + break; + case EVENT_ROCKET_STRIKE: + DoCastAOE(events.IsInPhase(PHASE_VX_001) ? SPELL_ROCKET_STRIKE_SINGLE : SPELL_ROCKET_STRIKE_BOTH); + events.ScheduleEvent(EVENT_RELOAD, 10000); + events.RescheduleEvent(EVENT_ROCKET_STRIKE, urand(20000, 25000)); + break; + case EVENT_RELOAD: + for (int8 seat = ROCKET_SEAT_LEFT; seat <= ROCKET_SEAT_RIGHT; ++seat) + if (Unit* rocket = me->GetVehicleKit()->GetPassenger(seat)) + rocket->SetDisplayId(rocket->GetNativeDisplayId()); + break; + case EVENT_HAND_PULSE: + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 120, true)) + DoCast(target, RAND(SPELL_HAND_PULSE_LEFT, SPELL_HAND_PULSE_RIGHT)); + events.RescheduleEvent(EVENT_HAND_PULSE, urand(1500, 3000), 0, PHASE_VOL7RON); + break; + case EVENT_FROST_BOMB: + DoCastAOE(SPELL_SCRIPT_EFFECT_FROST_BOMB); + events.RescheduleEvent(EVENT_FROST_BOMB, 45000); + break; + case EVENT_SPINNING_UP: + DoCastAOE(SPELL_SPINNING_UP); + events.DelayEvents(14000); + events.RescheduleEvent(EVENT_SPINNING_UP, urand(55000, 65000)); + break; + case EVENT_FLAME_SUPPRESSANT_VX: + DoCastAOE(SPELL_FLAME_SUPPRESSANT_VX); + events.RescheduleEvent(EVENT_FLAME_SUPPRESSANT_VX, urand(10000, 12000), 0, PHASE_VX_001); + break; + default: + break; } - while (uint32 eventId = events.ExecuteEvent()) - { - switch (eventId) - { - case EVENT_RAPID_BURST: - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 120, true)) - DoCast(target, SPELL_SUMMON_BURST_TARGET); - events.RescheduleEvent(EVENT_RAPID_BURST, 3000, 0, PHASE_VX_001); - break; - case EVENT_ROCKET_STRIKE: - DoCastAOE(events.IsInPhase(PHASE_VX_001) ? SPELL_ROCKET_STRIKE_SINGLE : SPELL_ROCKET_STRIKE_BOTH); - events.ScheduleEvent(EVENT_RELOAD, 10000); - events.RescheduleEvent(EVENT_ROCKET_STRIKE, urand(20000, 25000)); - break; - case EVENT_RELOAD: - for (int8 seat = ROCKET_SEAT_LEFT; seat <= ROCKET_SEAT_RIGHT; ++seat) - if (Unit* rocket = me->GetVehicleKit()->GetPassenger(seat)) - rocket->SetDisplayId(rocket->GetNativeDisplayId()); - break; - case EVENT_HAND_PULSE: - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 120, true)) - DoCast(target, RAND(SPELL_HAND_PULSE_LEFT, SPELL_HAND_PULSE_RIGHT)); - events.RescheduleEvent(EVENT_HAND_PULSE, urand(1500, 3000), 0, PHASE_VOL7RON); - break; - case EVENT_FROST_BOMB: - DoCastAOE(SPELL_SCRIPT_EFFECT_FROST_BOMB); - events.RescheduleEvent(EVENT_FROST_BOMB, 45000); - break; - case EVENT_SPINNING_UP: - DoCastAOE(SPELL_SPINNING_UP); - events.DelayEvents(14000); - events.RescheduleEvent(EVENT_SPINNING_UP, urand(55000, 65000)); - break; - case EVENT_FLAME_SUPPRESSANT_VX: - DoCastAOE(SPELL_FLAME_SUPPRESSANT_VX); - events.RescheduleEvent(EVENT_FLAME_SUPPRESSANT_VX, urand(10000, 12000), 0, PHASE_VX_001); - break; - default: - break; - } - - if (me->HasUnitState(UNIT_STATE_CASTING)) - return; - } + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; } + } - private: - bool _fireFighter; - }; + private: + bool _fireFighter; + }; - CreatureAI* GetAI(Creature* creature) const override - { - return GetUlduarAI(creature); - } + CreatureAI* GetAI(Creature* creature) const override + { + return GetUlduarAI(creature); + } }; class boss_aerial_command_unit : public CreatureScript { - public: - boss_aerial_command_unit() : CreatureScript("boss_aerial_command_unit") { } + public: + boss_aerial_command_unit() : CreatureScript("boss_aerial_command_unit") + { + } + + struct boss_aerial_command_unitAI : public BossAI + { + boss_aerial_command_unitAI(Creature* creature) : BossAI(creature, DATA_MIMIRON) + { + me->SetReactState(REACT_PASSIVE); + fireFigther = false; + } - struct boss_aerial_command_unitAI : public BossAI + void DamageTaken(Unit* who, uint32& damage) override { - boss_aerial_command_unitAI(Creature* creature) : BossAI(creature, DATA_MIMIRON) + if (damage >= me->GetHealth()) { + damage = me->GetHealth() - 1; // Let creature fall to 1 hp, but do not let it die or damage itself with SetHealth(). + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + me->AttackStop(); me->SetReactState(REACT_PASSIVE); - fireFigther = false; - } + DoCast(me, SPELL_VEHICLE_DAMAGED, true); + me->RemoveAllAurasExceptType(SPELL_AURA_CONTROL_VEHICLE, SPELL_AURA_MOD_INCREASE_HEALTH_PERCENT); - void DamageTaken(Unit* who, uint32 &damage) override - { - if (damage >= me->GetHealth()) + if (events.IsInPhase(PHASE_AERIAL_COMMAND_UNIT)) { - damage = me->GetHealth() - 1; // Let creature fall to 1 hp, but do not let it die or damage itself with SetHealth(). - me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - me->AttackStop(); - me->SetReactState(REACT_PASSIVE); - DoCast(me, SPELL_VEHICLE_DAMAGED, true); - me->RemoveAllAurasExceptType(SPELL_AURA_CONTROL_VEHICLE, SPELL_AURA_MOD_INCREASE_HEALTH_PERCENT); - - if (events.IsInPhase(PHASE_AERIAL_COMMAND_UNIT)) - { - me->GetMotionMaster()->Clear(true); - me->GetMotionMaster()->MovePoint(WP_AERIAL_P4_POS, VehicleRelocation[WP_AERIAL_P4_POS]); - } - else if (events.IsInPhase(PHASE_VOL7RON)) - { - me->SetStandState(UNIT_STAND_STATE_DEAD); + me->GetMotionMaster()->Clear(true); + me->GetMotionMaster()->MovePoint(WP_AERIAL_P4_POS, VehicleRelocation[WP_AERIAL_P4_POS]); + } + else if (events.IsInPhase(PHASE_VOL7RON)) + { + me->SetStandState(UNIT_STAND_STATE_DEAD); - if (IsEncounterFinished(who)) - return; + if (IsEncounterFinished(who)) + return; - me->CastStop(); - DoCast(me, SPELL_SELF_REPAIR); - } - events.Reset(); + me->CastStop(); + DoCast(me, SPELL_SELF_REPAIR); } + events.Reset(); } + } - void DoAction(int32 action) override + void DoAction(int32 action) override + { + switch (action) { - switch (action) - { - case DO_HARDMODE_AERIAL: - fireFigther = true; - DoCast(me, SPELL_EMERGENCY_MODE); - events.ScheduleEvent(EVENT_SUMMON_FIRE_BOTS, 1000, 0, PHASE_AERIAL_COMMAND_UNIT); - [[fallthrough]]; - case DO_START_AERIAL: - me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); - me->SetImmuneToPC(false); - me->SetReactState(REACT_AGGRESSIVE); - me->SetHover(true); - me->SetDisableGravity(false); - - events.SetPhase(PHASE_AERIAL_COMMAND_UNIT); - events.ScheduleEvent(EVENT_SUMMON_JUNK_BOT, 5000, 0, PHASE_AERIAL_COMMAND_UNIT); - events.ScheduleEvent(EVENT_SUMMON_ASSAULT_BOT, 9000, 0, PHASE_AERIAL_COMMAND_UNIT); - events.ScheduleEvent(EVENT_SUMMON_BOMB_BOT, 9000, 0, PHASE_AERIAL_COMMAND_UNIT); - break; - case DO_DISABLE_AERIAL: - me->CastStop(); - me->AttackStop(); - me->SetReactState(REACT_PASSIVE); - me->GetMotionMaster()->MoveFall(); - events.DelayEvents(23000); - break; - case DO_ENABLE_AERIAL: - me->SetReactState(REACT_AGGRESSIVE); - break; - case DO_ASSEMBLED_COMBAT: - me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); - me->SetReactState(REACT_AGGRESSIVE); - me->SetStandState(UNIT_STAND_STATE_STAND); - events.SetPhase(PHASE_VOL7RON); - break; - default: - break; - } - } + case DO_HARDMODE_AERIAL: + fireFigther = true; + DoCast(me, SPELL_EMERGENCY_MODE); + events.ScheduleEvent(EVENT_SUMMON_FIRE_BOTS, 1000, 0, PHASE_AERIAL_COMMAND_UNIT); + [[fallthrough]]; + case DO_START_AERIAL: + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); + me->SetImmuneToPC(false); + me->SetReactState(REACT_AGGRESSIVE); + me->SetHover(true); + me->SetDisableGravity(false); - void EnterEvadeMode(EvadeReason /*why*/) override - { - summons.DespawnAll(); + events.SetPhase(PHASE_AERIAL_COMMAND_UNIT); + events.ScheduleEvent(EVENT_SUMMON_JUNK_BOT, 5000, 0, PHASE_AERIAL_COMMAND_UNIT); + events.ScheduleEvent(EVENT_SUMMON_ASSAULT_BOT, 9000, 0, PHASE_AERIAL_COMMAND_UNIT); + events.ScheduleEvent(EVENT_SUMMON_BOMB_BOT, 9000, 0, PHASE_AERIAL_COMMAND_UNIT); + break; + case DO_DISABLE_AERIAL: + me->CastStop(); + me->AttackStop(); + me->SetReactState(REACT_PASSIVE); + me->GetMotionMaster()->MoveFall(); + events.DelayEvents(23000); + break; + case DO_ENABLE_AERIAL: + me->SetReactState(REACT_AGGRESSIVE); + break; + case DO_ASSEMBLED_COMBAT: + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); + me->SetReactState(REACT_AGGRESSIVE); + me->SetStandState(UNIT_STAND_STATE_STAND); + events.SetPhase(PHASE_VOL7RON); + break; + default: + break; } + } - void JustSummoned(Creature* summon) override - { - if (fireFigther && (summon->GetEntry() == NPC_ASSAULT_BOT || summon->GetEntry() == NPC_JUNK_BOT)) - summon->CastSpell(summon, SPELL_EMERGENCY_MODE); - BossAI::JustSummoned(summon); - } + void EnterEvadeMode(EvadeReason /*why*/) override + { + summons.DespawnAll(); + } - void KilledUnit(Unit* victim) override - { - if (victim->GetTypeId() == TYPEID_PLAYER) - if (Creature* mimiron = instance->GetCreature(DATA_MIMIRON)) - mimiron->AI()->Talk(events.IsInPhase(PHASE_AERIAL_COMMAND_UNIT) ? SAY_AERIAL_SLAY : SAY_V07TRON_SLAY); - } + void JustSummoned(Creature* summon) override + { + if (fireFigther && (summon->GetEntry() == NPC_ASSAULT_BOT || summon->GetEntry() == NPC_JUNK_BOT)) + summon->CastSpell(summon, SPELL_EMERGENCY_MODE); + BossAI::JustSummoned(summon); + } - void MovementInform(uint32 type, uint32 point) override + void KilledUnit(Unit* victim) override + { + if (victim->GetTypeId() == TYPEID_PLAYER) + if (Creature* mimiron = instance->GetCreature(DATA_MIMIRON)) + mimiron->AI()->Talk(events.IsInPhase(PHASE_AERIAL_COMMAND_UNIT) ? SAY_AERIAL_SLAY : SAY_V07TRON_SLAY); + } + + void MovementInform(uint32 type, uint32 point) override + { + if (type == POINT_MOTION_TYPE && point == WP_AERIAL_P4_POS) { - if (type == POINT_MOTION_TYPE && point == WP_AERIAL_P4_POS) - { - me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - if (Creature* mimiron = instance->GetCreature(DATA_MIMIRON)) - mimiron->AI()->DoAction(DO_ACTIVATE_V0L7R0N_1); - } + if (Creature* mimiron = instance->GetCreature(DATA_MIMIRON)) + mimiron->AI()->DoAction(DO_ACTIVATE_V0L7R0N_1); } + } - void UpdateAI(uint32 diff) override - { - if (!UpdateVictim()) - return; + void UpdateAI(uint32 diff) override + { + if (!UpdateVictim()) + return; - events.Update(diff); + events.Update(diff); - if (me->HasUnitState(UNIT_STATE_CASTING)) - return; + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; - while (uint32 eventId = events.ExecuteEvent()) + while (uint32 eventId = events.ExecuteEvent()) + { + switch (eventId) { - switch (eventId) - { - case EVENT_SUMMON_FIRE_BOTS: - DoCastAOE(SPELL_SUMMON_FIRE_BOT_TRIGGER, CastSpellExtraArgs(TRIGGERED_FULL_MASK).AddSpellMod(SPELLVALUE_MAX_TARGETS, 3)); - events.RescheduleEvent(EVENT_SUMMON_FIRE_BOTS, 45000, 0, PHASE_AERIAL_COMMAND_UNIT); - break; - case EVENT_SUMMON_JUNK_BOT: - DoCastAOE(SPELL_SUMMON_JUNK_BOT_TRIGGER, CastSpellExtraArgs(TRIGGERED_FULL_MASK).AddSpellMod(SPELLVALUE_MAX_TARGETS, 1)); - events.RescheduleEvent(EVENT_SUMMON_JUNK_BOT, urand(11000, 12000), 0, PHASE_AERIAL_COMMAND_UNIT); - break; - case EVENT_SUMMON_ASSAULT_BOT: - DoCastAOE(SPELL_SUMMON_ASSAULT_BOT_TRIGGER, CastSpellExtraArgs(TRIGGERED_FULL_MASK).AddSpellMod(SPELLVALUE_MAX_TARGETS, 1)); - events.RescheduleEvent(EVENT_SUMMON_ASSAULT_BOT, 30000, 0, PHASE_AERIAL_COMMAND_UNIT); - break; - case EVENT_SUMMON_BOMB_BOT: - DoCast(me, SPELL_SUMMON_BOMB_BOT); - events.RescheduleEvent(EVENT_SUMMON_BOMB_BOT, urand(15000, 20000), 0, PHASE_AERIAL_COMMAND_UNIT); - break; - default: - break; - } - - if (me->HasUnitState(UNIT_STATE_CASTING)) - return; + case EVENT_SUMMON_FIRE_BOTS: + DoCastAOE(SPELL_SUMMON_FIRE_BOT_TRIGGER, CastSpellExtraArgs(TRIGGERED_FULL_MASK).AddSpellMod(SPELLVALUE_MAX_TARGETS, 3)); + events.RescheduleEvent(EVENT_SUMMON_FIRE_BOTS, 45000, 0, PHASE_AERIAL_COMMAND_UNIT); + break; + case EVENT_SUMMON_JUNK_BOT: + DoCastAOE(SPELL_SUMMON_JUNK_BOT_TRIGGER, CastSpellExtraArgs(TRIGGERED_FULL_MASK).AddSpellMod(SPELLVALUE_MAX_TARGETS, 1)); + events.RescheduleEvent(EVENT_SUMMON_JUNK_BOT, urand(11000, 12000), 0, PHASE_AERIAL_COMMAND_UNIT); + break; + case EVENT_SUMMON_ASSAULT_BOT: + DoCastAOE(SPELL_SUMMON_ASSAULT_BOT_TRIGGER, CastSpellExtraArgs(TRIGGERED_FULL_MASK).AddSpellMod(SPELLVALUE_MAX_TARGETS, 1)); + events.RescheduleEvent(EVENT_SUMMON_ASSAULT_BOT, 30000, 0, PHASE_AERIAL_COMMAND_UNIT); + break; + case EVENT_SUMMON_BOMB_BOT: + DoCast(me, SPELL_SUMMON_BOMB_BOT); + events.RescheduleEvent(EVENT_SUMMON_BOMB_BOT, urand(15000, 20000), 0, PHASE_AERIAL_COMMAND_UNIT); + break; + default: + break; } - DoSpellAttackIfReady(events.IsInPhase(PHASE_AERIAL_COMMAND_UNIT) ? SPELL_PLASMA_BALL_P1 : SPELL_PLASMA_BALL_P2); + + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; } + DoSpellAttackIfReady(events.IsInPhase(PHASE_AERIAL_COMMAND_UNIT) ? SPELL_PLASMA_BALL_P1 : SPELL_PLASMA_BALL_P2); + } - private: - bool fireFigther; - }; + private: + bool fireFigther; + }; - CreatureAI* GetAI(Creature* creature) const override - { - return GetUlduarAI(creature); - } + CreatureAI* GetAI(Creature* creature) const override + { + return GetUlduarAI(creature); + } }; class npc_mimiron_assault_bot : public CreatureScript { - public: - npc_mimiron_assault_bot() : CreatureScript("npc_mimiron_assault_bot") { } + public: + npc_mimiron_assault_bot() : CreatureScript("npc_mimiron_assault_bot") + { + } - struct npc_mimiron_assault_botAI : public ScriptedAI + struct npc_mimiron_assault_botAI : public ScriptedAI + { + npc_mimiron_assault_botAI(Creature* creature) : ScriptedAI(creature) { - npc_mimiron_assault_botAI(Creature* creature) : ScriptedAI(creature) - { - } + } - void JustEngagedWith(Unit* /*who*/) override - { - events.ScheduleEvent(EVENT_MAGNETIC_FIELD, 14000); - } + void JustEngagedWith(Unit* /*who*/) override + { + events.ScheduleEvent(EVENT_MAGNETIC_FIELD, 14000); + } - void UpdateAI(uint32 diff) override - { - if (!UpdateVictim()) - return; + void UpdateAI(uint32 diff) override + { + if (!UpdateVictim()) + return; - events.Update(diff); + events.Update(diff); - if (me->HasUnitState(UNIT_STATE_ROOT)) + if (me->HasUnitState(UNIT_STATE_ROOT)) + { + if (Unit* newTarget = SelectTarget(SELECT_TARGET_MINDISTANCE, 0, 30.0f, true)) { - if (Unit* newTarget = SelectTarget(SELECT_TARGET_MINDISTANCE, 0, 30.0f, true)) - { - me->GetThreatManager().ResetAllThreat(); - AttackStart(newTarget); - } + me->GetThreatManager().ResetAllThreat(); + AttackStart(newTarget); } + } - while (uint32 eventId = events.ExecuteEvent()) + while (uint32 eventId = events.ExecuteEvent()) + { + switch (eventId) { - switch (eventId) - { - case EVENT_MAGNETIC_FIELD: - DoCastVictim(SPELL_MAGNETIC_FIELD); - events.RescheduleEvent(EVENT_MAGNETIC_FIELD, 30000); - break; - default: - break; - } + case EVENT_MAGNETIC_FIELD: + DoCastVictim(SPELL_MAGNETIC_FIELD); + events.RescheduleEvent(EVENT_MAGNETIC_FIELD, 30000); + break; + default: + break; } - - DoMeleeAttackIfReady(); } - private: - EventMap events; - }; - - CreatureAI* GetAI(Creature* creature) const override - { - return GetUlduarAI(creature); + DoMeleeAttackIfReady(); } + + private: + EventMap events; + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return GetUlduarAI(creature); + } }; class npc_mimiron_emergency_fire_bot : public CreatureScript { - public: - npc_mimiron_emergency_fire_bot() : CreatureScript("npc_mimiron_emergency_fire_bot") { } + public: + npc_mimiron_emergency_fire_bot() : CreatureScript("npc_mimiron_emergency_fire_bot") + { + } - struct npc_mimiron_emergency_fire_botAI : public ScriptedAI + struct npc_mimiron_emergency_fire_botAI : public ScriptedAI + { + npc_mimiron_emergency_fire_botAI(Creature* creature) : ScriptedAI(creature) { - npc_mimiron_emergency_fire_botAI(Creature* creature) : ScriptedAI(creature) - { - me->SetReactState(REACT_PASSIVE); - isWaterSprayReady = true; - moveNew = true; - } + me->SetReactState(REACT_PASSIVE); + isWaterSprayReady = true; + moveNew = true; + } - uint32 GetData(uint32 id) const override - { - if (id == DATA_WATERSPRAY) - return isWaterSprayReady; - if (id == DATA_MOVE_NEW) - return moveNew; - return 0; - } + uint32 GetData(uint32 id) const override + { + if (id == DATA_WATERSPRAY) + return isWaterSprayReady; + if (id == DATA_MOVE_NEW) + return moveNew; + return 0; + } - void SetData(uint32 id, uint32 data) override - { - if (id == DATA_WATERSPRAY) - isWaterSprayReady = false; - else if (id == DATA_MOVE_NEW) - moveNew = data ? true : false; - } + void SetData(uint32 id, uint32 data) override + { + if (id == DATA_WATERSPRAY) + isWaterSprayReady = false; + else if (id == DATA_MOVE_NEW) + moveNew = data ? true : false; + } - void Reset() override - { - events.ScheduleEvent(EVENT_WATER_SPRAY, 7000); - isWaterSprayReady = true; - moveNew = true; - } + void Reset() override + { + events.ScheduleEvent(EVENT_WATER_SPRAY, 7000); + isWaterSprayReady = true; + moveNew = true; + } - void UpdateAI(uint32 diff) override - { - if (!isWaterSprayReady) - events.Update(diff); + void UpdateAI(uint32 diff) override + { + if (!isWaterSprayReady) + events.Update(diff); - while (uint32 eventId = events.ExecuteEvent()) + while (uint32 eventId = events.ExecuteEvent()) + { + switch (eventId) { - switch (eventId) - { - case EVENT_WATER_SPRAY: - isWaterSprayReady = true; - events.RescheduleEvent(EVENT_WATER_SPRAY, urand(7000, 9000)); - break; - default: - break; - } + case EVENT_WATER_SPRAY: + isWaterSprayReady = true; + events.RescheduleEvent(EVENT_WATER_SPRAY, urand(7000, 9000)); + break; + default: + break; } } + } - private: - EventMap events; - bool isWaterSprayReady; - bool moveNew; - }; + private: + EventMap events; + bool isWaterSprayReady; + bool moveNew; + }; - CreatureAI* GetAI(Creature* creature) const override - { - return GetUlduarAI(creature); - } + CreatureAI* GetAI(Creature* creature) const override + { + return GetUlduarAI(creature); + } }; class npc_mimiron_computer : public CreatureScript { - public: - npc_mimiron_computer() : CreatureScript("npc_mimiron_computer") { } + public: + npc_mimiron_computer() : CreatureScript("npc_mimiron_computer") + { + } - struct npc_mimiron_computerAI : public ScriptedAI + struct npc_mimiron_computerAI : public ScriptedAI + { + npc_mimiron_computerAI(Creature* creature) : ScriptedAI(creature) { - npc_mimiron_computerAI(Creature* creature) : ScriptedAI(creature) - { - instance = me->GetInstanceScript(); - } + instance = me->GetInstanceScript(); + } - void DoAction(int32 action) override + void DoAction(int32 action) override + { + switch (action) { - switch (action) - { - case DO_ACTIVATE_COMPUTER: - Talk(SAY_SELF_DESTRUCT_INITIATED); - events.ScheduleEvent(EVENT_SELF_DESTRUCT_10, 3000); - break; - case DO_DEACTIVATE_COMPUTER: - Talk(SAY_SELF_DESTRUCT_TERMINATED); - me->RemoveAurasDueToSpell(SPELL_SELF_DESTRUCTION_AURA); - me->RemoveAurasDueToSpell(SPELL_SELF_DESTRUCTION_VISUAL); - events.Reset(); - break; - default: - break; - } + case DO_ACTIVATE_COMPUTER: + Talk(SAY_SELF_DESTRUCT_INITIATED); + events.ScheduleEvent(EVENT_SELF_DESTRUCT_10, 3000); + break; + case DO_DEACTIVATE_COMPUTER: + Talk(SAY_SELF_DESTRUCT_TERMINATED); + me->RemoveAurasDueToSpell(SPELL_SELF_DESTRUCTION_AURA); + me->RemoveAurasDueToSpell(SPELL_SELF_DESTRUCTION_VISUAL); + events.Reset(); + break; + default: + break; } + } - void UpdateAI(uint32 diff) override - { - events.Update(diff); + void UpdateAI(uint32 diff) override + { + events.Update(diff); - while (uint32 eventId = events.ExecuteEvent()) + while (uint32 eventId = events.ExecuteEvent()) + { + switch (eventId) { - switch (eventId) - { - case EVENT_SELF_DESTRUCT_10: - Talk(SAY_SELF_DESTRUCT_10); - if (Creature* mimiron = instance->GetCreature(DATA_MIMIRON)) - mimiron->AI()->DoAction(DO_ACTIVATE_HARD_MODE); - events.ScheduleEvent(EVENT_SELF_DESTRUCT_9, 60000); - break; - case EVENT_SELF_DESTRUCT_9: - Talk(SAY_SELF_DESTRUCT_9); - events.ScheduleEvent(EVENT_SELF_DESTRUCT_8, 60000); - break; - case EVENT_SELF_DESTRUCT_8: - Talk(SAY_SELF_DESTRUCT_8); - events.ScheduleEvent(EVENT_SELF_DESTRUCT_7, 60000); - break; - case EVENT_SELF_DESTRUCT_7: - Talk(SAY_SELF_DESTRUCT_7); - events.ScheduleEvent(EVENT_SELF_DESTRUCT_6, 60000); - break; - case EVENT_SELF_DESTRUCT_6: - Talk(SAY_SELF_DESTRUCT_6); - events.ScheduleEvent(EVENT_SELF_DESTRUCT_5, 60000); - break; - case EVENT_SELF_DESTRUCT_5: - Talk(SAY_SELF_DESTRUCT_5); - events.ScheduleEvent(EVENT_SELF_DESTRUCT_4, 60000); - break; - case EVENT_SELF_DESTRUCT_4: - Talk(SAY_SELF_DESTRUCT_4); - events.ScheduleEvent(EVENT_SELF_DESTRUCT_3, 60000); - break; - case EVENT_SELF_DESTRUCT_3: - Talk(SAY_SELF_DESTRUCT_3); - events.ScheduleEvent(EVENT_SELF_DESTRUCT_2, 60000); - break; - case EVENT_SELF_DESTRUCT_2: - Talk(SAY_SELF_DESTRUCT_2); - events.ScheduleEvent(EVENT_SELF_DESTRUCT_1, 60000); - break; - case EVENT_SELF_DESTRUCT_1: - Talk(SAY_SELF_DESTRUCT_1); - events.ScheduleEvent(EVENT_SELF_DESTRUCT_FINALIZED, 60000); - break; - case EVENT_SELF_DESTRUCT_FINALIZED: - Talk(SAY_SELF_DESTRUCT_FINALIZED); - if (Creature* mimiron = instance->GetCreature(DATA_MIMIRON)) - mimiron->AI()->DoAction(DO_ACTIVATE_SELF_DESTRUCT); - DoCast(me, SPELL_SELF_DESTRUCTION_AURA); - DoCast(me, SPELL_SELF_DESTRUCTION_VISUAL); - break; - default: - break; - } + case EVENT_SELF_DESTRUCT_10: + Talk(SAY_SELF_DESTRUCT_10); + if (Creature* mimiron = instance->GetCreature(DATA_MIMIRON)) + mimiron->AI()->DoAction(DO_ACTIVATE_HARD_MODE); + events.ScheduleEvent(EVENT_SELF_DESTRUCT_9, 60000); + break; + case EVENT_SELF_DESTRUCT_9: + Talk(SAY_SELF_DESTRUCT_9); + events.ScheduleEvent(EVENT_SELF_DESTRUCT_8, 60000); + break; + case EVENT_SELF_DESTRUCT_8: + Talk(SAY_SELF_DESTRUCT_8); + events.ScheduleEvent(EVENT_SELF_DESTRUCT_7, 60000); + break; + case EVENT_SELF_DESTRUCT_7: + Talk(SAY_SELF_DESTRUCT_7); + events.ScheduleEvent(EVENT_SELF_DESTRUCT_6, 60000); + break; + case EVENT_SELF_DESTRUCT_6: + Talk(SAY_SELF_DESTRUCT_6); + events.ScheduleEvent(EVENT_SELF_DESTRUCT_5, 60000); + break; + case EVENT_SELF_DESTRUCT_5: + Talk(SAY_SELF_DESTRUCT_5); + events.ScheduleEvent(EVENT_SELF_DESTRUCT_4, 60000); + break; + case EVENT_SELF_DESTRUCT_4: + Talk(SAY_SELF_DESTRUCT_4); + events.ScheduleEvent(EVENT_SELF_DESTRUCT_3, 60000); + break; + case EVENT_SELF_DESTRUCT_3: + Talk(SAY_SELF_DESTRUCT_3); + events.ScheduleEvent(EVENT_SELF_DESTRUCT_2, 60000); + break; + case EVENT_SELF_DESTRUCT_2: + Talk(SAY_SELF_DESTRUCT_2); + events.ScheduleEvent(EVENT_SELF_DESTRUCT_1, 60000); + break; + case EVENT_SELF_DESTRUCT_1: + Talk(SAY_SELF_DESTRUCT_1); + events.ScheduleEvent(EVENT_SELF_DESTRUCT_FINALIZED, 60000); + break; + case EVENT_SELF_DESTRUCT_FINALIZED: + Talk(SAY_SELF_DESTRUCT_FINALIZED); + if (Creature* mimiron = instance->GetCreature(DATA_MIMIRON)) + mimiron->AI()->DoAction(DO_ACTIVATE_SELF_DESTRUCT); + DoCast(me, SPELL_SELF_DESTRUCTION_AURA); + DoCast(me, SPELL_SELF_DESTRUCTION_VISUAL); + break; + default: + break; } } + } - private: - InstanceScript* instance; - EventMap events; - }; + private: + InstanceScript* instance; + EventMap events; + }; - CreatureAI* GetAI(Creature* creature) const override - { - return GetUlduarAI(creature); - } + CreatureAI* GetAI(Creature* creature) const override + { + return GetUlduarAI(creature); + } }; class npc_mimiron_flames : public CreatureScript { - public: - npc_mimiron_flames() : CreatureScript("npc_mimiron_flames") { } + public: + npc_mimiron_flames() : CreatureScript("npc_mimiron_flames") + { + } - struct npc_mimiron_flamesAI : public ScriptedAI + struct npc_mimiron_flamesAI : public ScriptedAI + { + npc_mimiron_flamesAI(Creature* creature) : ScriptedAI(creature) { - npc_mimiron_flamesAI(Creature* creature) : ScriptedAI(creature) - { - instance = me->GetInstanceScript(); - } + instance = me->GetInstanceScript(); + } - void Reset() override // Reset is possibly more suitable for this case. - { - events.ScheduleEvent(EVENT_SPREAD_FLAMES, 4000); - } + void Reset() override // Reset is possibly more suitable for this case. + { + events.ScheduleEvent(EVENT_SPREAD_FLAMES, 4000); + } - void UpdateAI(uint32 diff) override - { - if (instance->GetBossState(DATA_MIMIRON) != IN_PROGRESS) - me->DespawnOrUnsummon(); + void UpdateAI(uint32 diff) override + { + if (instance->GetBossState(DATA_MIMIRON) != IN_PROGRESS) + me->DespawnOrUnsummon(); - events.Update(diff); + events.Update(diff); - while (uint32 eventId = events.ExecuteEvent()) + while (uint32 eventId = events.ExecuteEvent()) + { + switch (eventId) { - switch (eventId) - { - case EVENT_SPREAD_FLAMES: - DoCastAOE(SPELL_SUMMON_FLAMES_SPREAD_TRIGGER); - break; - default: - break; - } + case EVENT_SPREAD_FLAMES: + DoCastAOE(SPELL_SUMMON_FLAMES_SPREAD_TRIGGER); + break; + default: + break; } } + } - private: - InstanceScript* instance; - EventMap events; - }; + private: + InstanceScript* instance; + EventMap events; + }; - CreatureAI* GetAI(Creature* creature) const override - { - return GetUlduarAI(creature); - } + CreatureAI* GetAI(Creature* creature) const override + { + return GetUlduarAI(creature); + } }; class npc_mimiron_frost_bomb : public CreatureScript { - public: - npc_mimiron_frost_bomb() : CreatureScript("npc_mimiron_frost_bomb") { } + public: + npc_mimiron_frost_bomb() : CreatureScript("npc_mimiron_frost_bomb") + { + } - struct npc_mimiron_frost_bombAI : public ScriptedAI + struct npc_mimiron_frost_bombAI : public ScriptedAI + { + npc_mimiron_frost_bombAI(Creature* creature) : ScriptedAI(creature) { - npc_mimiron_frost_bombAI(Creature* creature) : ScriptedAI(creature) - { - } + } - void Reset() override - { - events.ScheduleEvent(EVENT_FROST_BOMB_EXPLOSION, 10000); - } + void Reset() override + { + events.ScheduleEvent(EVENT_FROST_BOMB_EXPLOSION, 10000); + } - void UpdateAI(uint32 diff) override - { - events.Update(diff); + void UpdateAI(uint32 diff) override + { + events.Update(diff); - while (uint32 eventId = events.ExecuteEvent()) + while (uint32 eventId = events.ExecuteEvent()) + { + switch (eventId) { - switch (eventId) - { - case EVENT_FROST_BOMB_EXPLOSION: - DoCastAOE(SPELL_FROST_BOMB_EXPLOSION); - events.ScheduleEvent(EVENT_FROST_BOMB_CLEAR_FIRES, 3000); - break; - case EVENT_FROST_BOMB_CLEAR_FIRES: - DoCastAOE(SPELL_CLEAR_FIRES); - me->DespawnOrUnsummon(3000); - break; - default: - break; - } + case EVENT_FROST_BOMB_EXPLOSION: + DoCastAOE(SPELL_FROST_BOMB_EXPLOSION); + events.ScheduleEvent(EVENT_FROST_BOMB_CLEAR_FIRES, 3000); + break; + case EVENT_FROST_BOMB_CLEAR_FIRES: + DoCastAOE(SPELL_CLEAR_FIRES); + me->DespawnOrUnsummon(3000); + break; + default: + break; } } + } - private: - EventMap events; - }; + private: + EventMap events; + }; - CreatureAI* GetAI(Creature* creature) const override - { - return GetUlduarAI(creature); - } + CreatureAI* GetAI(Creature* creature) const override + { + return GetUlduarAI(creature); + } }; class npc_mimiron_proximity_mine : public CreatureScript { - public: - npc_mimiron_proximity_mine() : CreatureScript("npc_mimiron_proximity_mine") { } + public: + npc_mimiron_proximity_mine() : CreatureScript("npc_mimiron_proximity_mine") + { + } + + struct npc_mimiron_proximity_mineAI : public ScriptedAI + { + npc_mimiron_proximity_mineAI(Creature* creature) : ScriptedAI(creature) + { + } - struct npc_mimiron_proximity_mineAI : public ScriptedAI + void Reset() override { - npc_mimiron_proximity_mineAI(Creature* creature) : ScriptedAI(creature) - { - } + events.ScheduleEvent(EVENT_PROXIMITY_MINE_ARM, 1500); + } - void Reset() override - { - events.ScheduleEvent(EVENT_PROXIMITY_MINE_ARM, 1500); - } + void UpdateAI(uint32 diff) override + { + events.Update(diff); - void UpdateAI(uint32 diff) override + while (uint32 eventId = events.ExecuteEvent()) { - events.Update(diff); - - while (uint32 eventId = events.ExecuteEvent()) + switch (eventId) { - switch (eventId) - { - case EVENT_PROXIMITY_MINE_ARM: - DoCast(me, SPELL_PROXIMITY_MINE_PERIODIC_TRIGGER); - events.ScheduleEvent(EVENT_PROXIMITY_MINE_DETONATION, 33500); - break; - case EVENT_PROXIMITY_MINE_DETONATION: - if (me->HasAura(SPELL_PROXIMITY_MINE_PERIODIC_TRIGGER)) - DoCastAOE(SPELL_PROXIMITY_MINE_EXPLOSION); - me->DespawnOrUnsummon(1000); - break; - default: - break; - } + case EVENT_PROXIMITY_MINE_ARM: + DoCast(me, SPELL_PROXIMITY_MINE_PERIODIC_TRIGGER); + events.ScheduleEvent(EVENT_PROXIMITY_MINE_DETONATION, 33500); + break; + case EVENT_PROXIMITY_MINE_DETONATION: + if (me->HasAura(SPELL_PROXIMITY_MINE_PERIODIC_TRIGGER)) + DoCastAOE(SPELL_PROXIMITY_MINE_EXPLOSION); + me->DespawnOrUnsummon(1000); + break; + default: + break; } } + } - private: - EventMap events; - }; + private: + EventMap events; + }; - CreatureAI* GetAI(Creature* creature) const override - { - return GetUlduarAI(creature); - } + CreatureAI* GetAI(Creature* creature) const override + { + return GetUlduarAI(creature); + } }; class go_mimiron_hardmode_button : public GameObjectScript { - public: - go_mimiron_hardmode_button() : GameObjectScript("go_mimiron_hardmode_button") { } + public: + go_mimiron_hardmode_button() : GameObjectScript("go_mimiron_hardmode_button") + { + } - struct go_mimiron_hardmode_buttonAI : public GameObjectAI + struct go_mimiron_hardmode_buttonAI : public GameObjectAI + { + go_mimiron_hardmode_buttonAI(GameObject* go) : GameObjectAI(go), instance(go->GetInstanceScript()) { - go_mimiron_hardmode_buttonAI(GameObject* go) : GameObjectAI(go), instance(go->GetInstanceScript()) { } - - InstanceScript* instance; - - bool GossipHello(Player* /*player*/) override - { - if (me->HasFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE)) - return true; + } - if (Creature* computer = instance->GetCreature(DATA_COMPUTER)) - computer->AI()->DoAction(DO_ACTIVATE_COMPUTER); + InstanceScript* instance; - me->SetGoState(GO_STATE_ACTIVE); - me->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); + bool GossipHello(Player* /*player*/) override + { + if (me->HasFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE)) return true; - } - }; - GameObjectAI* GetAI(GameObject* go) const override - { - return GetUlduarAI(go); + if (Creature* computer = instance->GetCreature(DATA_COMPUTER)) + computer->AI()->DoAction(DO_ACTIVATE_COMPUTER); + + me->SetGoState(GO_STATE_ACTIVE); + me->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); + return true; } + }; + + GameObjectAI* GetAI(GameObject* go) const override + { + return GetUlduarAI(go); + } }; // 63801 - Bomb Bot class spell_mimiron_bomb_bot : public SpellScriptLoader { - public: - spell_mimiron_bomb_bot() : SpellScriptLoader("spell_mimiron_bomb_bot") { } + public: + spell_mimiron_bomb_bot() : SpellScriptLoader("spell_mimiron_bomb_bot") + { + } - class spell_mimiron_bomb_bot_SpellScript : public SpellScript + class spell_mimiron_bomb_bot_SpellScript : public SpellScript + { + void HandleScript(SpellEffIndex /*effIndex*/) { - void HandleScript(SpellEffIndex /*effIndex*/) - { - if (GetHitPlayer()) - if (InstanceScript* instance = GetCaster()->GetInstanceScript()) - if (Creature* mkii = ObjectAccessor::GetCreature(*GetCaster(), instance->GetGuidData(DATA_LEVIATHAN_MK_II))) - mkii->AI()->SetData(DATA_SETUP_BOMB, 0); - } - - void HandleDespawn(SpellEffIndex /*effIndex*/) - { - if (Creature* target = GetHitCreature()) - { - target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_PACIFIED); - target->DespawnOrUnsummon(1000); - } - } + if (GetHitPlayer()) + if (InstanceScript* instance = GetCaster()->GetInstanceScript()) + if (Creature* mkii = ObjectAccessor::GetCreature(*GetCaster(), instance->GetGuidData(DATA_LEVIATHAN_MK_II))) + mkii->AI()->SetData(DATA_SETUP_BOMB, 0); + } - void Register() override + void HandleDespawn(SpellEffIndex /*effIndex*/) + { + if (Creature* target = GetHitCreature()) { - OnEffectHitTarget.Register(&spell_mimiron_bomb_bot_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCHOOL_DAMAGE); - OnEffectHitTarget.Register(&spell_mimiron_bomb_bot_SpellScript::HandleDespawn, EFFECT_1, SPELL_EFFECT_APPLY_AURA); + target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_PACIFIED); + target->DespawnOrUnsummon(1000); } - }; + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_mimiron_bomb_bot_SpellScript(); + OnEffectHitTarget.Register(&spell_mimiron_bomb_bot_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCHOOL_DAMAGE); + OnEffectHitTarget.Register(&spell_mimiron_bomb_bot_SpellScript::HandleDespawn, EFFECT_1, SPELL_EFFECT_APPLY_AURA); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_mimiron_bomb_bot_SpellScript(); + } }; // 65192 - Flame Suppressant, 65224 - Clear Fires, 65354 - Clear Fires, 64619 - Water Spray class spell_mimiron_clear_fires : public SpellScriptLoader { - public: - spell_mimiron_clear_fires() : SpellScriptLoader("spell_mimiron_clear_fires") { } + public: + spell_mimiron_clear_fires() : SpellScriptLoader("spell_mimiron_clear_fires") + { + } - class spell_mimiron_clear_fires_SpellScript : public SpellScript + class spell_mimiron_clear_fires_SpellScript : public SpellScript + { + void HandleDummy(SpellEffIndex /*effIndex*/) { - void HandleDummy(SpellEffIndex /*effIndex*/) - { - if (GetHitCreature()) - GetHitCreature()->DespawnOrUnsummon(); - } - - void Register() override - { - OnEffectHitTarget.Register(&spell_mimiron_clear_fires_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); - } - }; + if (GetHitCreature()) + GetHitCreature()->DespawnOrUnsummon(); + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_mimiron_clear_fires_SpellScript(); + OnEffectHitTarget.Register(&spell_mimiron_clear_fires_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_mimiron_clear_fires_SpellScript(); + } }; // 64463 - Despawn Assault Bots class spell_mimiron_despawn_assault_bots : public SpellScriptLoader { - public: - spell_mimiron_despawn_assault_bots() : SpellScriptLoader("spell_mimiron_despawn_assault_bots") { } + public: + spell_mimiron_despawn_assault_bots() : SpellScriptLoader("spell_mimiron_despawn_assault_bots") + { + } - class spell_mimiron_despawn_assault_bots_SpellScript : public SpellScript + class spell_mimiron_despawn_assault_bots_SpellScript : public SpellScript + { + void HandleScript(SpellEffIndex /*effIndex*/) { - void HandleScript(SpellEffIndex /*effIndex*/) - { - if (GetHitCreature()) - GetHitCreature()->DespawnOrUnsummon(); - } - - void Register() override - { - OnEffectHitTarget.Register(&spell_mimiron_despawn_assault_bots_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - } - }; + if (GetHitCreature()) + GetHitCreature()->DespawnOrUnsummon(); + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_mimiron_despawn_assault_bots_SpellScript(); + OnEffectHitTarget.Register(&spell_mimiron_despawn_assault_bots_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_mimiron_despawn_assault_bots_SpellScript(); + } }; // 64618 - Fire Search class spell_mimiron_fire_search : public SpellScriptLoader { - public: - spell_mimiron_fire_search() : SpellScriptLoader("spell_mimiron_fire_search") { } + public: + spell_mimiron_fire_search() : SpellScriptLoader("spell_mimiron_fire_search") + { + } - class spell_mimiron_fire_search_SpellScript : public SpellScript + class spell_mimiron_fire_search_SpellScript : public SpellScript { - public: - spell_mimiron_fire_search_SpellScript() - { - _noTarget = false; - } + public: + spell_mimiron_fire_search_SpellScript() + { + _noTarget = false; + } - private: - bool Validate(SpellInfo const* /*spell*/) override - { - return ValidateSpellInfo({ SPELL_WATER_SPRAY }); - } + private: + bool Validate(SpellInfo const* /*spell*/) override + { + return ValidateSpellInfo({SPELL_WATER_SPRAY}); + } - void FilterTargets(std::list& targets) - { - _noTarget = targets.empty(); - if (_noTarget) - return; + void FilterTargets(std::list& targets) + { + _noTarget = targets.empty(); + if (_noTarget) + return; - WorldObject* target = Firelands::Containers::SelectRandomContainerElement(targets); - targets.clear(); - targets.push_back(target); - } + WorldObject* target = Firelands::Containers::SelectRandomContainerElement(targets); + targets.clear(); + targets.push_back(target); + } - void HandleAftercast() - { - if (_noTarget) - GetCaster()->GetMotionMaster()->MoveRandom(15.0f); - } + void HandleAftercast() + { + if (_noTarget) + GetCaster()->GetMotionMaster()->MoveRandom(15.0f); + } - void HandleScript(SpellEffIndex /*effIndex*/) - { - Unit* caster = GetCaster(); + void HandleScript(SpellEffIndex /*effIndex*/) + { + Unit* caster = GetCaster(); - if (UnitAI* ai = caster->GetAI()) + if (UnitAI* ai = caster->GetAI()) + { + if (caster->GetDistance2d(GetHitUnit()) <= 15.0f && ai->GetData(DATA_WATERSPRAY)) { - if (caster->GetDistance2d(GetHitUnit()) <= 15.0f && ai->GetData(DATA_WATERSPRAY)) - { - caster->CastSpell(GetHitUnit(), SPELL_WATER_SPRAY, true); - ai->SetData(DATA_WATERSPRAY, 0); - ai->SetData(DATA_MOVE_NEW, 1); - } - else if (caster->GetAI()->GetData(DATA_MOVE_NEW)) - { - caster->GetMotionMaster()->MoveChase(GetHitUnit()); - ai->SetData(DATA_MOVE_NEW, 0); - } + caster->CastSpell(GetHitUnit(), SPELL_WATER_SPRAY, true); + ai->SetData(DATA_WATERSPRAY, 0); + ai->SetData(DATA_MOVE_NEW, 1); + } + else if (caster->GetAI()->GetData(DATA_MOVE_NEW)) + { + caster->GetMotionMaster()->MoveChase(GetHitUnit()); + ai->SetData(DATA_MOVE_NEW, 0); } } + } - void Register() override - { - AfterCast.Register(&spell_mimiron_fire_search_SpellScript::HandleAftercast); - OnObjectAreaTargetSelect.Register(&spell_mimiron_fire_search_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENTRY); - OnEffectHitTarget.Register(&spell_mimiron_fire_search_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - } - - private: - bool _noTarget; - }; - - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_mimiron_fire_search_SpellScript(); + AfterCast.Register(&spell_mimiron_fire_search_SpellScript::HandleAftercast); + OnObjectAreaTargetSelect.Register(&spell_mimiron_fire_search_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENTRY); + OnEffectHitTarget.Register(&spell_mimiron_fire_search_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); } + + private: + bool _noTarget; + }; + + SpellScript* GetSpellScript() const override + { + return new spell_mimiron_fire_search_SpellScript(); + } }; // 64436 - Magnetic Core class spell_mimiron_magnetic_core : public SpellScriptLoader { - public: - spell_mimiron_magnetic_core() : SpellScriptLoader("spell_mimiron_magnetic_core") { } + public: + spell_mimiron_magnetic_core() : SpellScriptLoader("spell_mimiron_magnetic_core") + { + } - class spell_mimiron_magnetic_core_SpellScript : public SpellScript + class spell_mimiron_magnetic_core_SpellScript : public SpellScript + { + void FilterTargets(std::list& targets) { - void FilterTargets(std::list& targets) - { - targets.remove_if([](WorldObject* obj) { return obj->ToUnit() && (obj->ToUnit()->GetVehicleBase() || obj->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)); }); - } - - void Register() override - { - OnObjectAreaTargetSelect.Register(&spell_mimiron_magnetic_core_SpellScript::FilterTargets, EFFECT_1, TARGET_UNIT_SRC_AREA_ENTRY); - } - }; + targets.remove_if([](WorldObject* obj) { return obj->ToUnit() && (obj->ToUnit()->GetVehicleBase() || obj->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)); }); + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_mimiron_magnetic_core_SpellScript(); + OnObjectAreaTargetSelect.Register(&spell_mimiron_magnetic_core_SpellScript::FilterTargets, EFFECT_1, TARGET_UNIT_SRC_AREA_ENTRY); } + }; - class spell_mimiron_magnetic_core_AuraScript : public AuraScript - { - bool Validate(SpellInfo const* /*spell*/) override - { - return ValidateSpellInfo({ SPELL_MAGNETIC_CORE_VISUAL }); - } + SpellScript* GetSpellScript() const override + { + return new spell_mimiron_magnetic_core_SpellScript(); + } - void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - if (Creature* target = GetTarget()->ToCreature()) - { - target->AI()->DoAction(DO_DISABLE_AERIAL); - target->CastSpell(target, SPELL_MAGNETIC_CORE_VISUAL, true); - } - } + class spell_mimiron_magnetic_core_AuraScript : public AuraScript + { + bool Validate(SpellInfo const* /*spell*/) override + { + return ValidateSpellInfo({SPELL_MAGNETIC_CORE_VISUAL}); + } - void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + if (Creature* target = GetTarget()->ToCreature()) { - if (Creature* target = GetTarget()->ToCreature()) - { - target->AI()->DoAction(DO_ENABLE_AERIAL); - target->RemoveAurasDueToSpell(SPELL_MAGNETIC_CORE_VISUAL); - } + target->AI()->DoAction(DO_DISABLE_AERIAL); + target->CastSpell(target, SPELL_MAGNETIC_CORE_VISUAL, true); } + } - void OnRemoveSelf(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + if (Creature* target = GetTarget()->ToCreature()) { - if (TempSummon* summ = GetTarget()->ToTempSummon()) - summ->DespawnOrUnsummon(); + target->AI()->DoAction(DO_ENABLE_AERIAL); + target->RemoveAurasDueToSpell(SPELL_MAGNETIC_CORE_VISUAL); } + } - void Register() override - { - AfterEffectApply.Register(&spell_mimiron_magnetic_core_AuraScript::OnApply, EFFECT_1, SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN, AURA_EFFECT_HANDLE_REAL); - AfterEffectRemove.Register(&spell_mimiron_magnetic_core_AuraScript::OnRemove, EFFECT_1, SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN, AURA_EFFECT_HANDLE_REAL); - AfterEffectRemove.Register(&spell_mimiron_magnetic_core_AuraScript::OnRemoveSelf, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); - } - }; + void OnRemoveSelf(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + if (TempSummon* summ = GetTarget()->ToTempSummon()) + summ->DespawnOrUnsummon(); + } - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_mimiron_magnetic_core_AuraScript(); + AfterEffectApply.Register(&spell_mimiron_magnetic_core_AuraScript::OnApply, EFFECT_1, SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN, AURA_EFFECT_HANDLE_REAL); + AfterEffectRemove.Register(&spell_mimiron_magnetic_core_AuraScript::OnRemove, EFFECT_1, SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN, AURA_EFFECT_HANDLE_REAL); + AfterEffectRemove.Register(&spell_mimiron_magnetic_core_AuraScript::OnRemoveSelf, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); } + }; + + AuraScript* GetAuraScript() const override + { + return new spell_mimiron_magnetic_core_AuraScript(); + } }; // 63667 - Napalm Shell class spell_mimiron_napalm_shell : public SpellScriptLoader { - public: - spell_mimiron_napalm_shell() : SpellScriptLoader("spell_mimiron_napalm_shell") { } + public: + spell_mimiron_napalm_shell() : SpellScriptLoader("spell_mimiron_napalm_shell") + { + } - class spell_mimiron_napalm_shell_SpellScript : public SpellScript + class spell_mimiron_napalm_shell_SpellScript : public SpellScript + { + bool Validate(SpellInfo const* /*spell*/) override { - bool Validate(SpellInfo const* /*spell*/) override - { - return ValidateSpellInfo({ SPELL_NAPALM_SHELL }); - } - - void FilterTargets(std::list& targets) - { - if (targets.empty()) - return; + return ValidateSpellInfo({SPELL_NAPALM_SHELL}); + } - WorldObject* target = Firelands::Containers::SelectRandomContainerElement(targets); + void FilterTargets(std::list& targets) + { + if (targets.empty()) + return; - targets.remove_if(Firelands::AllWorldObjectsInRange(GetCaster(), 15.0f)); + WorldObject* target = Firelands::Containers::SelectRandomContainerElement(targets); - if (!targets.empty()) - target = Firelands::Containers::SelectRandomContainerElement(targets); + targets.remove_if(Firelands::AllWorldObjectsInRange(GetCaster(), 15.0f)); - targets.clear(); - targets.push_back(target); - } + if (!targets.empty()) + target = Firelands::Containers::SelectRandomContainerElement(targets); - void HandleScript(SpellEffIndex /*effIndex*/) - { - GetCaster()->CastSpell(GetHitUnit(), SPELL_NAPALM_SHELL); - } + targets.clear(); + targets.push_back(target); + } - void Register() override - { - OnObjectAreaTargetSelect.Register(&spell_mimiron_napalm_shell_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); - OnEffectHitTarget.Register(&spell_mimiron_napalm_shell_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - } - }; + void HandleScript(SpellEffIndex /*effIndex*/) + { + GetCaster()->CastSpell(GetHitUnit(), SPELL_NAPALM_SHELL); + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_mimiron_napalm_shell_SpellScript(); + OnObjectAreaTargetSelect.Register(&spell_mimiron_napalm_shell_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); + OnEffectHitTarget.Register(&spell_mimiron_napalm_shell_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_mimiron_napalm_shell_SpellScript(); + } }; // 63274 - P3Wx2 Laser Barrage -- HACK! Core will currently not set UNIT_FIELD_CHANNEL_OBJECT automatially if the spell targets more than a single target. class spell_mimiron_p3wx2_laser_barrage : public SpellScriptLoader { - public: - spell_mimiron_p3wx2_laser_barrage() : SpellScriptLoader("spell_mimiron_p3wx2_laser_barrage") { } + public: + spell_mimiron_p3wx2_laser_barrage() : SpellScriptLoader("spell_mimiron_p3wx2_laser_barrage") + { + } - class spell_mimiron_p3wx2_laser_barrage_SpellScript : public SpellScript + class spell_mimiron_p3wx2_laser_barrage_SpellScript : public SpellScript + { + void OnHit(SpellEffIndex /*effIndex*/) { - void OnHit(SpellEffIndex /*effIndex*/) - { - GetCaster()->SetChannelObjectGuid(GetHitUnit()->GetGUID()); - } - - void Register() override - { - OnEffectHitTarget.Register(&spell_mimiron_p3wx2_laser_barrage_SpellScript::OnHit, EFFECT_0, SPELL_EFFECT_APPLY_AURA); - } - }; + GetCaster()->SetChannelObjectGuid(GetHitUnit()->GetGUID()); + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_mimiron_p3wx2_laser_barrage_SpellScript(); + OnEffectHitTarget.Register(&spell_mimiron_p3wx2_laser_barrage_SpellScript::OnHit, EFFECT_0, SPELL_EFFECT_APPLY_AURA); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_mimiron_p3wx2_laser_barrage_SpellScript(); + } }; // 64542 - Plasma Blast class spell_mimiron_plasma_blast : public SpellScriptLoader { - public: - spell_mimiron_plasma_blast() : SpellScriptLoader("spell_mimiron_plasma_blast") { } + public: + spell_mimiron_plasma_blast() : SpellScriptLoader("spell_mimiron_plasma_blast") + { + } - class spell_mimiron_plasma_blast_SpellScript : public SpellScript + class spell_mimiron_plasma_blast_SpellScript : public SpellScript + { + bool Validate(SpellInfo const* /*spell*/) override { - bool Validate(SpellInfo const* /*spell*/) override - { - return ValidateSpellInfo({ SPELL_PLASMA_BLAST }); - } - - bool Load() override - { - return GetCaster()->GetVehicleKit() != nullptr; - } + return ValidateSpellInfo({SPELL_PLASMA_BLAST}); + } - void HandleScript(SpellEffIndex /*effIndex*/) - { - if (Unit* caster = GetCaster()->GetVehicleKit()->GetPassenger(3)) - caster->CastSpell(GetHitUnit(), SPELL_PLASMA_BLAST); - } + bool Load() override + { + return GetCaster()->GetVehicleKit() != nullptr; + } - void Register() override - { - OnEffectHitTarget.Register(&spell_mimiron_plasma_blast_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - } - }; + void HandleScript(SpellEffIndex /*effIndex*/) + { + if (Unit* caster = GetCaster()->GetVehicleKit()->GetPassenger(3)) + caster->CastSpell(GetHitUnit(), SPELL_PLASMA_BLAST); + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_mimiron_plasma_blast_SpellScript(); + OnEffectHitTarget.Register(&spell_mimiron_plasma_blast_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_mimiron_plasma_blast_SpellScript(); + } }; // 66351 - Explosion class spell_mimiron_proximity_explosion : public SpellScriptLoader { - public: - spell_mimiron_proximity_explosion() : SpellScriptLoader("spell_mimiron_proximity_explosion") { } + public: + spell_mimiron_proximity_explosion() : SpellScriptLoader("spell_mimiron_proximity_explosion") + { + } - class spell_mimiron_proximity_explosion_SpellScript : public SpellScript + class spell_mimiron_proximity_explosion_SpellScript : public SpellScript + { + void OnHit(SpellEffIndex /*effIndex*/) { - void OnHit(SpellEffIndex /*effIndex*/) - { - if (GetHitPlayer()) - if (InstanceScript* instance = GetCaster()->GetInstanceScript()) - if (Creature* mkII = ObjectAccessor::GetCreature(*GetCaster(), instance->GetGuidData(DATA_LEVIATHAN_MK_II))) - mkII->AI()->SetData(DATA_SETUP_MINE, 0); - } - - void HandleAura(SpellEffIndex /*effIndex*/) - { - GetCaster()->RemoveAurasDueToSpell(SPELL_PROXIMITY_MINE_PERIODIC_TRIGGER); - } + if (GetHitPlayer()) + if (InstanceScript* instance = GetCaster()->GetInstanceScript()) + if (Creature* mkII = ObjectAccessor::GetCreature(*GetCaster(), instance->GetGuidData(DATA_LEVIATHAN_MK_II))) + mkII->AI()->SetData(DATA_SETUP_MINE, 0); + } - void Register() override - { - OnEffectHitTarget.Register(&spell_mimiron_proximity_explosion_SpellScript::OnHit, EFFECT_0, SPELL_EFFECT_SCHOOL_DAMAGE); - OnEffectHitTarget.Register(&spell_mimiron_proximity_explosion_SpellScript::HandleAura, EFFECT_1, SPELL_EFFECT_APPLY_AURA); - } - }; + void HandleAura(SpellEffIndex /*effIndex*/) + { + GetCaster()->RemoveAurasDueToSpell(SPELL_PROXIMITY_MINE_PERIODIC_TRIGGER); + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_mimiron_proximity_explosion_SpellScript(); + OnEffectHitTarget.Register(&spell_mimiron_proximity_explosion_SpellScript::OnHit, EFFECT_0, SPELL_EFFECT_SCHOOL_DAMAGE); + OnEffectHitTarget.Register(&spell_mimiron_proximity_explosion_SpellScript::HandleAura, EFFECT_1, SPELL_EFFECT_APPLY_AURA); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_mimiron_proximity_explosion_SpellScript(); + } }; // 63027 - Proximity Mines class spell_mimiron_proximity_mines : public SpellScriptLoader { - public: - spell_mimiron_proximity_mines() : SpellScriptLoader("spell_mimiron_proximity_mines") { } + public: + spell_mimiron_proximity_mines() : SpellScriptLoader("spell_mimiron_proximity_mines") + { + } - class spell_mimiron_proximity_mines_SpellScript : public SpellScript + class spell_mimiron_proximity_mines_SpellScript : public SpellScript + { + bool Validate(SpellInfo const* /*spell*/) override { - bool Validate(SpellInfo const* /*spell*/) override - { - return ValidateSpellInfo({ SPELL_SUMMON_PROXIMITY_MINE }); - } - - void HandleScript(SpellEffIndex /*effIndex*/) - { - for (uint8 i = 0; i < 10; ++i) - GetCaster()->CastSpell(GetCaster(), SPELL_SUMMON_PROXIMITY_MINE, true); - } + return ValidateSpellInfo({SPELL_SUMMON_PROXIMITY_MINE}); + } - void Register() override - { - OnEffectHitTarget.Register(&spell_mimiron_proximity_mines_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - } - }; + void HandleScript(SpellEffIndex /*effIndex*/) + { + for (uint8 i = 0; i < 10; ++i) + GetCaster()->CastSpell(GetCaster(), SPELL_SUMMON_PROXIMITY_MINE, true); + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_mimiron_proximity_mines_SpellScript(); + OnEffectHitTarget.Register(&spell_mimiron_proximity_mines_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_mimiron_proximity_mines_SpellScript(); + } }; // 65346 - Proximity Mine class spell_mimiron_proximity_trigger : public SpellScriptLoader { - public: - spell_mimiron_proximity_trigger() : SpellScriptLoader("spell_mimiron_proximity_trigger") { } + public: + spell_mimiron_proximity_trigger() : SpellScriptLoader("spell_mimiron_proximity_trigger") + { + } - class spell_mimiron_proximity_trigger_SpellScript : public SpellScript + class spell_mimiron_proximity_trigger_SpellScript : public SpellScript + { + bool Validate(SpellInfo const* /*spell*/) override { - bool Validate(SpellInfo const* /*spell*/) override - { - return ValidateSpellInfo({ SPELL_PROXIMITY_MINE_EXPLOSION }); - } - - void FilterTargets(std::list& targets) - { - targets.remove(GetExplTargetWorldObject()); + return ValidateSpellInfo({SPELL_PROXIMITY_MINE_EXPLOSION}); + } - if (targets.empty()) - FinishCast(SPELL_FAILED_NO_VALID_TARGETS); - } + void FilterTargets(std::list& targets) + { + targets.remove(GetExplTargetWorldObject()); - void HandleDummy(SpellEffIndex /*effIndex*/) - { - GetCaster()->CastSpell((Unit*)nullptr, SPELL_PROXIMITY_MINE_EXPLOSION, true); - } + if (targets.empty()) + FinishCast(SPELL_FAILED_NO_VALID_TARGETS); + } - void Register() override - { - OnObjectAreaTargetSelect.Register(&spell_mimiron_proximity_trigger_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENTRY); - OnEffectHit.Register(&spell_mimiron_proximity_trigger_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); - } - }; + void HandleDummy(SpellEffIndex /*effIndex*/) + { + GetCaster()->CastSpell((Unit*)nullptr, SPELL_PROXIMITY_MINE_EXPLOSION, true); + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_mimiron_proximity_trigger_SpellScript(); + OnObjectAreaTargetSelect.Register(&spell_mimiron_proximity_trigger_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENTRY); + OnEffectHit.Register(&spell_mimiron_proximity_trigger_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_mimiron_proximity_trigger_SpellScript(); + } }; // 63382 - Rapid Burst class spell_mimiron_rapid_burst : public SpellScriptLoader { - public: - spell_mimiron_rapid_burst() : SpellScriptLoader("spell_mimiron_rapid_burst") { } + public: + spell_mimiron_rapid_burst() : SpellScriptLoader("spell_mimiron_rapid_burst") + { + } - class spell_mimiron_rapid_burst_AuraScript : public AuraScript + class spell_mimiron_rapid_burst_AuraScript : public AuraScript + { + bool Validate(SpellInfo const* /*spell*/) override { - bool Validate(SpellInfo const* /*spell*/) override - { - return ValidateSpellInfo({ SPELL_RAPID_BURST_LEFT, SPELL_RAPID_BURST_RIGHT }); - } - - void AfterRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - if (TempSummon* summ = GetTarget()->ToTempSummon()) - summ->DespawnOrUnsummon(); - } + return ValidateSpellInfo({SPELL_RAPID_BURST_LEFT, SPELL_RAPID_BURST_RIGHT}); + } - void HandleDummyTick(AuraEffect const* aurEff) - { - if (GetCaster()) - GetCaster()->CastSpell(GetTarget(), aurEff->GetTickNumber() % 2 == 0 ? SPELL_RAPID_BURST_RIGHT : SPELL_RAPID_BURST_LEFT, aurEff); - } + void AfterRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + if (TempSummon* summ = GetTarget()->ToTempSummon()) + summ->DespawnOrUnsummon(); + } - void Register() override - { - AfterEffectRemove.Register(&spell_mimiron_rapid_burst_AuraScript::AfterRemove, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY, AURA_EFFECT_HANDLE_REAL); - OnEffectPeriodic.Register(&spell_mimiron_rapid_burst_AuraScript::HandleDummyTick, EFFECT_1, SPELL_AURA_PERIODIC_DUMMY); - } - }; + void HandleDummyTick(AuraEffect const* aurEff) + { + if (GetCaster()) + GetCaster()->CastSpell(GetTarget(), aurEff->GetTickNumber() % 2 == 0 ? SPELL_RAPID_BURST_RIGHT : SPELL_RAPID_BURST_LEFT, aurEff); + } - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_mimiron_rapid_burst_AuraScript(); + AfterEffectRemove.Register(&spell_mimiron_rapid_burst_AuraScript::AfterRemove, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY, AURA_EFFECT_HANDLE_REAL); + OnEffectPeriodic.Register(&spell_mimiron_rapid_burst_AuraScript::HandleDummyTick, EFFECT_1, SPELL_AURA_PERIODIC_DUMMY); } + }; + + AuraScript* GetAuraScript() const override + { + return new spell_mimiron_rapid_burst_AuraScript(); + } }; // 64402 - Rocket Strike, 65034 - Rocket Strike class spell_mimiron_rocket_strike : public SpellScriptLoader { - public: - spell_mimiron_rocket_strike() : SpellScriptLoader("spell_mimiron_rocket_strike") { } + public: + spell_mimiron_rocket_strike() : SpellScriptLoader("spell_mimiron_rocket_strike") + { + } - class spell_mimiron_rocket_strike_SpellScript : public SpellScript + class spell_mimiron_rocket_strike_SpellScript : public SpellScript + { + bool Validate(SpellInfo const* /*spell*/) override { - bool Validate(SpellInfo const* /*spell*/) override - { - return ValidateSpellInfo({ SPELL_SCRIPT_EFFECT_ROCKET_STRIKE }); - } - - void FilterTargets(std::list& targets) - { - if (targets.empty()) - return; + return ValidateSpellInfo({SPELL_SCRIPT_EFFECT_ROCKET_STRIKE}); + } - if (m_scriptSpellId == SPELL_ROCKET_STRIKE_SINGLE && GetCaster()->IsVehicle()) - if (WorldObject* target = GetCaster()->GetVehicleKit()->GetPassenger(RAND(ROCKET_SEAT_LEFT, ROCKET_SEAT_RIGHT))) - { - targets.clear(); - targets.push_back(target); - } - } + void FilterTargets(std::list& targets) + { + if (targets.empty()) + return; - void HandleDummy(SpellEffIndex /*effIndex*/) - { - GetHitUnit()->CastSpell(nullptr, SPELL_SCRIPT_EFFECT_ROCKET_STRIKE, GetCaster()->GetGUID()); - } + if (m_scriptSpellId == SPELL_ROCKET_STRIKE_SINGLE && GetCaster()->IsVehicle()) + if (WorldObject* target = GetCaster()->GetVehicleKit()->GetPassenger(RAND(ROCKET_SEAT_LEFT, ROCKET_SEAT_RIGHT))) + { + targets.clear(); + targets.push_back(target); + } + } - void Register() override - { - OnObjectAreaTargetSelect.Register(&spell_mimiron_rocket_strike_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENTRY); - OnEffectHitTarget.Register(&spell_mimiron_rocket_strike_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); - } - }; + void HandleDummy(SpellEffIndex /*effIndex*/) + { + GetHitUnit()->CastSpell(nullptr, SPELL_SCRIPT_EFFECT_ROCKET_STRIKE, GetCaster()->GetGUID()); + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_mimiron_rocket_strike_SpellScript(); + OnObjectAreaTargetSelect.Register(&spell_mimiron_rocket_strike_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENTRY); + OnEffectHitTarget.Register(&spell_mimiron_rocket_strike_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_mimiron_rocket_strike_SpellScript(); + } }; // 63041 - Rocket Strike class spell_mimiron_rocket_strike_damage : public SpellScriptLoader { - public: - spell_mimiron_rocket_strike_damage() : SpellScriptLoader("spell_mimiron_rocket_strike_damage") { } + public: + spell_mimiron_rocket_strike_damage() : SpellScriptLoader("spell_mimiron_rocket_strike_damage") + { + } - class spell_mimiron_rocket_strike_damage_SpellScript : public SpellScript + class spell_mimiron_rocket_strike_damage_SpellScript : public SpellScript + { + bool Validate(SpellInfo const* /*spell*/) override { - bool Validate(SpellInfo const* /*spell*/) override - { - return ValidateSpellInfo({ SPELL_NOT_SO_FRIENDLY_FIRE }); - } - - void HandleAfterCast() - { - if (TempSummon* summ = GetCaster()->ToTempSummon()) - summ->DespawnOrUnsummon(); - } + return ValidateSpellInfo({SPELL_NOT_SO_FRIENDLY_FIRE}); + } - void HandleScript(SpellEffIndex /*effIndex*/) - { - if (GetHitPlayer()) - if (InstanceScript* instance = GetCaster()->GetInstanceScript()) - if (Creature* mkii = ObjectAccessor::GetCreature(*GetCaster(), instance->GetGuidData(DATA_LEVIATHAN_MK_II))) - mkii->AI()->SetData(DATA_SETUP_ROCKET, 0); - } + void HandleAfterCast() + { + if (TempSummon* summ = GetCaster()->ToTempSummon()) + summ->DespawnOrUnsummon(); + } - void HandleFriendlyFire(SpellEffIndex /*effIndex*/) - { - GetHitUnit()->CastSpell((Unit*)nullptr, SPELL_NOT_SO_FRIENDLY_FIRE, true); - } + void HandleScript(SpellEffIndex /*effIndex*/) + { + if (GetHitPlayer()) + if (InstanceScript* instance = GetCaster()->GetInstanceScript()) + if (Creature* mkii = ObjectAccessor::GetCreature(*GetCaster(), instance->GetGuidData(DATA_LEVIATHAN_MK_II))) + mkii->AI()->SetData(DATA_SETUP_ROCKET, 0); + } - void Register() override - { - AfterCast.Register(&spell_mimiron_rocket_strike_damage_SpellScript::HandleAfterCast); - OnEffectHitTarget.Register(&spell_mimiron_rocket_strike_damage_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCHOOL_DAMAGE); - OnEffectHitTarget.Register(&spell_mimiron_rocket_strike_damage_SpellScript::HandleFriendlyFire, EFFECT_1, SPELL_EFFECT_SCHOOL_DAMAGE); - } - }; + void HandleFriendlyFire(SpellEffIndex /*effIndex*/) + { + GetHitUnit()->CastSpell((Unit*)nullptr, SPELL_NOT_SO_FRIENDLY_FIRE, true); + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_mimiron_rocket_strike_damage_SpellScript(); + AfterCast.Register(&spell_mimiron_rocket_strike_damage_SpellScript::HandleAfterCast); + OnEffectHitTarget.Register(&spell_mimiron_rocket_strike_damage_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCHOOL_DAMAGE); + OnEffectHitTarget.Register(&spell_mimiron_rocket_strike_damage_SpellScript::HandleFriendlyFire, EFFECT_1, SPELL_EFFECT_SCHOOL_DAMAGE); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_mimiron_rocket_strike_damage_SpellScript(); + } }; // 63681 - Rocket Strike class spell_mimiron_rocket_strike_target_select : public SpellScriptLoader { - public: - spell_mimiron_rocket_strike_target_select() : SpellScriptLoader("spell_mimiron_rocket_strike_target_select") { } + public: + spell_mimiron_rocket_strike_target_select() : SpellScriptLoader("spell_mimiron_rocket_strike_target_select") + { + } - class spell_mimiron_rocket_strike_target_select_SpellScript : public SpellScript + class spell_mimiron_rocket_strike_target_select_SpellScript : public SpellScript + { + bool Validate(SpellInfo const* /*spell*/) override { - bool Validate(SpellInfo const* /*spell*/) override - { - return ValidateSpellInfo({ SPELL_SUMMON_ROCKET_STRIKE }); - } - - void FilterTargets(std::list& targets) - { - if (targets.empty()) - return; + return ValidateSpellInfo({SPELL_SUMMON_ROCKET_STRIKE}); + } - WorldObject* target = Firelands::Containers::SelectRandomContainerElement(targets); + void FilterTargets(std::list& targets) + { + if (targets.empty()) + return; - targets.remove_if(Firelands::AllWorldObjectsInRange(GetCaster(), 15.0f)); + WorldObject* target = Firelands::Containers::SelectRandomContainerElement(targets); - if (!targets.empty()) - target = Firelands::Containers::SelectRandomContainerElement(targets); + targets.remove_if(Firelands::AllWorldObjectsInRange(GetCaster(), 15.0f)); - targets.clear(); - targets.push_back(target); - } + if (!targets.empty()) + target = Firelands::Containers::SelectRandomContainerElement(targets); - void HandleScript(SpellEffIndex /*effIndex*/) - { - if (InstanceScript* instance = GetCaster()->GetInstanceScript()) - GetCaster()->CastSpell(GetHitUnit(), SPELL_SUMMON_ROCKET_STRIKE, instance->GetGuidData(DATA_VX_001)); - GetCaster()->SetDisplayId(11686); - } + targets.clear(); + targets.push_back(target); + } - void Register() override - { - OnObjectAreaTargetSelect.Register(&spell_mimiron_rocket_strike_target_select_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); - OnEffectHitTarget.Register(&spell_mimiron_rocket_strike_target_select_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - } - }; + void HandleScript(SpellEffIndex /*effIndex*/) + { + if (InstanceScript* instance = GetCaster()->GetInstanceScript()) + GetCaster()->CastSpell(GetHitUnit(), SPELL_SUMMON_ROCKET_STRIKE, instance->GetGuidData(DATA_VX_001)); + GetCaster()->SetDisplayId(11686); + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_mimiron_rocket_strike_target_select_SpellScript(); + OnObjectAreaTargetSelect.Register(&spell_mimiron_rocket_strike_target_select_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); + OnEffectHitTarget.Register(&spell_mimiron_rocket_strike_target_select_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_mimiron_rocket_strike_target_select_SpellScript(); + } }; // 64383 - Self Repair class spell_mimiron_self_repair : public SpellScriptLoader { - public: - spell_mimiron_self_repair() : SpellScriptLoader("spell_mimiron_self_repair") { } + public: + spell_mimiron_self_repair() : SpellScriptLoader("spell_mimiron_self_repair") + { + } - class spell_mimiron_self_repair_SpellScript : public SpellScript + class spell_mimiron_self_repair_SpellScript : public SpellScript + { + void HandleScript() { - void HandleScript() - { - if (GetCaster()->GetAI()) - GetCaster()->GetAI()->DoAction(DO_ASSEMBLED_COMBAT); - } - - void Register() override - { - AfterHit.Register(&spell_mimiron_self_repair_SpellScript::HandleScript); - } - }; + if (GetCaster()->GetAI()) + GetCaster()->GetAI()->DoAction(DO_ASSEMBLED_COMBAT); + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_mimiron_self_repair_SpellScript(); + AfterHit.Register(&spell_mimiron_self_repair_SpellScript::HandleScript); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_mimiron_self_repair_SpellScript(); + } }; // 63414 - Spinning Up -- HACK! Core will currently not set UNIT_FIELD_CHANNEL_OBJECT automatially if the spell targets more than a single target. // eff0 will hit both caster and target due to hack in spellmgr.cpp, it is necessary because caster will interrupt itself if aura is not active on caster. class spell_mimiron_spinning_up : public SpellScriptLoader { - public: - spell_mimiron_spinning_up() : SpellScriptLoader("spell_mimiron_spinning_up") { } + public: + spell_mimiron_spinning_up() : SpellScriptLoader("spell_mimiron_spinning_up") + { + } - class spell_mimiron_spinning_up_SpellScript : public SpellScript + class spell_mimiron_spinning_up_SpellScript : public SpellScript + { + void OnHit(SpellEffIndex /*effIndex*/) { - void OnHit(SpellEffIndex /*effIndex*/) - { - if (GetHitUnit() != GetCaster()) - GetCaster()->SetChannelObjectGuid(GetHitUnit()->GetGUID()); - } - - void Register() override - { - OnEffectHitTarget.Register(&spell_mimiron_spinning_up_SpellScript::OnHit, EFFECT_0, SPELL_EFFECT_APPLY_AURA); - } - }; + if (GetHitUnit() != GetCaster()) + GetCaster()->SetChannelObjectGuid(GetHitUnit()->GetGUID()); + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_mimiron_spinning_up_SpellScript(); + OnEffectHitTarget.Register(&spell_mimiron_spinning_up_SpellScript::OnHit, EFFECT_0, SPELL_EFFECT_APPLY_AURA); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_mimiron_spinning_up_SpellScript(); + } }; // 64426 - Summon Scrap Bot class spell_mimiron_summon_assault_bot : public SpellScriptLoader { - public: - spell_mimiron_summon_assault_bot() : SpellScriptLoader("spell_mimiron_summon_assault_bot") { } + public: + spell_mimiron_summon_assault_bot() : SpellScriptLoader("spell_mimiron_summon_assault_bot") + { + } - class spell_mimiron_summon_assault_bot_AuraScript : public AuraScript + class spell_mimiron_summon_assault_bot_AuraScript : public AuraScript + { + bool Validate(SpellInfo const* /*spell*/) override { - bool Validate(SpellInfo const* /*spell*/) override - { - return ValidateSpellInfo({ SPELL_SUMMON_ASSAULT_BOT }); - } - - void OnRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) - { - if (Unit* caster = GetCaster()) - if (InstanceScript* instance = caster->GetInstanceScript()) - if (instance->GetBossState(DATA_MIMIRON) == IN_PROGRESS) - caster->CastSpell(caster, SPELL_SUMMON_ASSAULT_BOT, CastSpellExtraArgs(aurEff).SetOriginalCaster(instance->GetGuidData(DATA_AERIAL_COMMAND_UNIT))); - } + return ValidateSpellInfo({SPELL_SUMMON_ASSAULT_BOT}); + } - void Register() override - { - OnEffectRemove.Register(&spell_mimiron_summon_assault_bot_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); - } - }; + void OnRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) + { + if (Unit* caster = GetCaster()) + if (InstanceScript* instance = caster->GetInstanceScript()) + if (instance->GetBossState(DATA_MIMIRON) == IN_PROGRESS) + caster->CastSpell(caster, SPELL_SUMMON_ASSAULT_BOT, CastSpellExtraArgs(aurEff).SetOriginalCaster(instance->GetGuidData(DATA_AERIAL_COMMAND_UNIT))); + } - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_mimiron_summon_assault_bot_AuraScript(); + OnEffectRemove.Register(&spell_mimiron_summon_assault_bot_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); } + }; + + AuraScript* GetAuraScript() const override + { + return new spell_mimiron_summon_assault_bot_AuraScript(); + } }; // 64425 - Summon Scrap Bot Trigger class spell_mimiron_summon_assault_bot_target : public SpellScriptLoader { - public: - spell_mimiron_summon_assault_bot_target() : SpellScriptLoader("spell_mimiron_summon_assault_bot_target") { } + public: + spell_mimiron_summon_assault_bot_target() : SpellScriptLoader("spell_mimiron_summon_assault_bot_target") + { + } - class spell_mimiron_summon_assault_bot_target_SpellScript : public SpellScript + class spell_mimiron_summon_assault_bot_target_SpellScript : public SpellScript + { + bool Validate(SpellInfo const* /*spell*/) override { - bool Validate(SpellInfo const* /*spell*/) override - { - return ValidateSpellInfo({ SPELL_SUMMON_ASSAULT_BOT_DUMMY }); - } - - void HandleDummy(SpellEffIndex /*effIndex*/) - { - GetHitUnit()->CastSpell(GetHitUnit(), SPELL_SUMMON_ASSAULT_BOT_DUMMY, true); - } + return ValidateSpellInfo({SPELL_SUMMON_ASSAULT_BOT_DUMMY}); + } - void Register() override - { - OnEffectHitTarget.Register(&spell_mimiron_summon_assault_bot_target_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); - } - }; + void HandleDummy(SpellEffIndex /*effIndex*/) + { + GetHitUnit()->CastSpell(GetHitUnit(), SPELL_SUMMON_ASSAULT_BOT_DUMMY, true); + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_mimiron_summon_assault_bot_target_SpellScript(); + OnEffectHitTarget.Register(&spell_mimiron_summon_assault_bot_target_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_mimiron_summon_assault_bot_target_SpellScript(); + } }; // 64621 - Summon Fire Bot class spell_mimiron_summon_fire_bot : public SpellScriptLoader { - public: - spell_mimiron_summon_fire_bot() : SpellScriptLoader("spell_mimiron_summon_fire_bot") { } + public: + spell_mimiron_summon_fire_bot() : SpellScriptLoader("spell_mimiron_summon_fire_bot") + { + } - class spell_mimiron_summon_fire_bot_AuraScript : public AuraScript + class spell_mimiron_summon_fire_bot_AuraScript : public AuraScript + { + bool Validate(SpellInfo const* /*spell*/) override { - bool Validate(SpellInfo const* /*spell*/) override - { - return ValidateSpellInfo({ SPELL_SUMMON_FIRE_BOT }); - } - - void OnRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) - { - if (Unit* caster = GetCaster()) - if (InstanceScript* instance = caster->GetInstanceScript()) - if (instance->GetBossState(DATA_MIMIRON) == IN_PROGRESS) - caster->CastSpell(caster, SPELL_SUMMON_FIRE_BOT, { aurEff, instance->GetGuidData(DATA_AERIAL_COMMAND_UNIT) }); - } + return ValidateSpellInfo({SPELL_SUMMON_FIRE_BOT}); + } - void Register() override - { - OnEffectRemove.Register(&spell_mimiron_summon_fire_bot_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); - } - }; + void OnRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) + { + if (Unit* caster = GetCaster()) + if (InstanceScript* instance = caster->GetInstanceScript()) + if (instance->GetBossState(DATA_MIMIRON) == IN_PROGRESS) + caster->CastSpell(caster, SPELL_SUMMON_FIRE_BOT, {aurEff, instance->GetGuidData(DATA_AERIAL_COMMAND_UNIT)}); + } - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_mimiron_summon_fire_bot_AuraScript(); + OnEffectRemove.Register(&spell_mimiron_summon_fire_bot_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); } + }; + + AuraScript* GetAuraScript() const override + { + return new spell_mimiron_summon_fire_bot_AuraScript(); + } }; // 64620 - Summon Fire Bot Trigger class spell_mimiron_summon_fire_bot_target : public SpellScriptLoader { - public: - spell_mimiron_summon_fire_bot_target() : SpellScriptLoader("spell_mimiron_summon_fire_bot_target") { } + public: + spell_mimiron_summon_fire_bot_target() : SpellScriptLoader("spell_mimiron_summon_fire_bot_target") + { + } - class spell_mimiron_summon_fire_bot_target_SpellScript : public SpellScript + class spell_mimiron_summon_fire_bot_target_SpellScript : public SpellScript + { + bool Validate(SpellInfo const* /*spell*/) override { - bool Validate(SpellInfo const* /*spell*/) override - { - return ValidateSpellInfo({ SPELL_SUMMON_FIRE_BOT_DUMMY }); - } - - void HandleDummy(SpellEffIndex /*effIndex*/) - { - GetHitUnit()->CastSpell(GetHitUnit(), SPELL_SUMMON_FIRE_BOT_DUMMY, true); - } + return ValidateSpellInfo({SPELL_SUMMON_FIRE_BOT_DUMMY}); + } - void Register() override - { - OnEffectHitTarget.Register(&spell_mimiron_summon_fire_bot_target_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); - } - }; + void HandleDummy(SpellEffIndex /*effIndex*/) + { + GetHitUnit()->CastSpell(GetHitUnit(), SPELL_SUMMON_FIRE_BOT_DUMMY, true); + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_mimiron_summon_fire_bot_target_SpellScript(); + OnEffectHitTarget.Register(&spell_mimiron_summon_fire_bot_target_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_mimiron_summon_fire_bot_target_SpellScript(); + } }; // 64562 - Summon Flames Spread Trigger class spell_mimiron_summon_flames_spread : public SpellScriptLoader { - public: - spell_mimiron_summon_flames_spread() : SpellScriptLoader("spell_mimiron_summon_flames_spread") { } + public: + spell_mimiron_summon_flames_spread() : SpellScriptLoader("spell_mimiron_summon_flames_spread") + { + } - class spell_mimiron_summon_flames_spread_SpellScript : public SpellScript + class spell_mimiron_summon_flames_spread_SpellScript : public SpellScript + { + void FilterTargets(std::list& targets) { - void FilterTargets(std::list& targets) - { - if (targets.empty()) - return; + if (targets.empty()) + return; - // Flames must chase the closest player - WorldObject* target = targets.front(); + // Flames must chase the closest player + WorldObject* target = targets.front(); - for (std::list::const_iterator iter = targets.begin(); iter != targets.end(); ++iter) - if (GetCaster()->GetDistance2d(*iter) < GetCaster()->GetDistance2d(target)) - target = *iter; - - targets.clear(); - targets.push_back(target); - } - - void OnHit(SpellEffIndex /*effIndex*/) - { - GetCaster()->SetOrientationTowards(GetHitUnit()); - } + for (std::list::const_iterator iter = targets.begin(); iter != targets.end(); ++iter) + if (GetCaster()->GetDistance2d(*iter) < GetCaster()->GetDistance2d(target)) + target = *iter; - void Register() override - { - OnObjectAreaTargetSelect.Register(&spell_mimiron_summon_flames_spread_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); - OnEffectHitTarget.Register(&spell_mimiron_summon_flames_spread_SpellScript::OnHit, EFFECT_0, SPELL_EFFECT_APPLY_AURA); - } - }; + targets.clear(); + targets.push_back(target); + } - SpellScript* GetSpellScript() const override + void OnHit(SpellEffIndex /*effIndex*/) { - return new spell_mimiron_summon_flames_spread_SpellScript(); + GetCaster()->SetOrientationTowards(GetHitUnit()); } - class spell_mimiron_summon_flames_spread_AuraScript : public AuraScript + void Register() override { - bool Validate(SpellInfo const* /*spell*/) override - { - return ValidateSpellInfo({ SPELL_SUMMON_FLAMES_SPREAD }); - } + OnObjectAreaTargetSelect.Register(&spell_mimiron_summon_flames_spread_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); + OnEffectHitTarget.Register(&spell_mimiron_summon_flames_spread_SpellScript::OnHit, EFFECT_0, SPELL_EFFECT_APPLY_AURA); + } + }; - void HandleTick(AuraEffect const* /*aurEff*/) - { - PreventDefaultAction(); - if (Unit* caster = GetCaster()) - if (caster->HasAura(SPELL_FLAMES_PERIODIC_TRIGGER)) - caster->CastSpell(GetTarget(), SPELL_SUMMON_FLAMES_SPREAD, true); - } + SpellScript* GetSpellScript() const override + { + return new spell_mimiron_summon_flames_spread_SpellScript(); + } - void Register() override - { - OnEffectPeriodic.Register(&spell_mimiron_summon_flames_spread_AuraScript::HandleTick, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); - } - }; + class spell_mimiron_summon_flames_spread_AuraScript : public AuraScript + { + bool Validate(SpellInfo const* /*spell*/) override + { + return ValidateSpellInfo({SPELL_SUMMON_FLAMES_SPREAD}); + } - AuraScript* GetAuraScript() const override + void HandleTick(AuraEffect const* /*aurEff*/) { - return new spell_mimiron_summon_flames_spread_AuraScript(); + PreventDefaultAction(); + if (Unit* caster = GetCaster()) + if (caster->HasAura(SPELL_FLAMES_PERIODIC_TRIGGER)) + caster->CastSpell(GetTarget(), SPELL_SUMMON_FLAMES_SPREAD, true); } + + void Register() override + { + OnEffectPeriodic.Register(&spell_mimiron_summon_flames_spread_AuraScript::HandleTick, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); + } + }; + + AuraScript* GetAuraScript() const override + { + return new spell_mimiron_summon_flames_spread_AuraScript(); + } }; // 64623 - Frost Bomb class spell_mimiron_summon_frost_bomb_target : public SpellScriptLoader { - public: - spell_mimiron_summon_frost_bomb_target() : SpellScriptLoader("spell_mimiron_summon_frost_bomb_target") { } + public: + spell_mimiron_summon_frost_bomb_target() : SpellScriptLoader("spell_mimiron_summon_frost_bomb_target") + { + } - class spell_mimiron_summon_frost_bomb_target_SpellScript : public SpellScript + class spell_mimiron_summon_frost_bomb_target_SpellScript : public SpellScript + { + bool Validate(SpellInfo const* /*spell*/) override { - bool Validate(SpellInfo const* /*spell*/) override - { - return ValidateSpellInfo({ SPELL_SUMMON_FROST_BOMB }); - } - - void FilterTargets(std::list& targets) - { - if (targets.empty()) - return; + return ValidateSpellInfo({SPELL_SUMMON_FROST_BOMB}); + } - targets.remove_if(Firelands::AllWorldObjectsInRange(GetCaster(), 15.0f)); + void FilterTargets(std::list& targets) + { + if (targets.empty()) + return; - if (targets.empty()) - return; + targets.remove_if(Firelands::AllWorldObjectsInRange(GetCaster(), 15.0f)); - WorldObject* target = Firelands::Containers::SelectRandomContainerElement(targets); + if (targets.empty()) + return; - targets.clear(); - targets.push_back(target); - } + WorldObject* target = Firelands::Containers::SelectRandomContainerElement(targets); - void HandleScript(SpellEffIndex /*effIndex*/) - { - GetCaster()->CastSpell(GetHitUnit(), SPELL_SUMMON_FROST_BOMB, true); - } + targets.clear(); + targets.push_back(target); + } - void Register() override - { - OnObjectAreaTargetSelect.Register(&spell_mimiron_summon_frost_bomb_target_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENTRY); - OnEffectHitTarget.Register(&spell_mimiron_summon_frost_bomb_target_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - } - }; + void HandleScript(SpellEffIndex /*effIndex*/) + { + GetCaster()->CastSpell(GetHitUnit(), SPELL_SUMMON_FROST_BOMB, true); + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_mimiron_summon_frost_bomb_target_SpellScript(); + OnObjectAreaTargetSelect.Register(&spell_mimiron_summon_frost_bomb_target_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENTRY); + OnEffectHitTarget.Register(&spell_mimiron_summon_frost_bomb_target_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_mimiron_summon_frost_bomb_target_SpellScript(); + } }; // 64398 - Summon Scrap Bot class spell_mimiron_summon_junk_bot : public SpellScriptLoader { - public: - spell_mimiron_summon_junk_bot() : SpellScriptLoader("spell_mimiron_summon_junk_bot") { } + public: + spell_mimiron_summon_junk_bot() : SpellScriptLoader("spell_mimiron_summon_junk_bot") + { + } - class spell_mimiron_summon_junk_bot_AuraScript : public AuraScript + class spell_mimiron_summon_junk_bot_AuraScript : public AuraScript + { + bool Validate(SpellInfo const* /*spell*/) override { - bool Validate(SpellInfo const* /*spell*/) override - { - return ValidateSpellInfo({ SPELL_SUMMON_JUNK_BOT }); - } - - void OnRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) - { - if (Unit* caster = GetCaster()) - if (InstanceScript* instance = caster->GetInstanceScript()) - if (instance->GetBossState(DATA_MIMIRON) == IN_PROGRESS) - caster->CastSpell(caster, SPELL_SUMMON_JUNK_BOT, { aurEff, instance->GetGuidData(DATA_AERIAL_COMMAND_UNIT) }); - } + return ValidateSpellInfo({SPELL_SUMMON_JUNK_BOT}); + } - void Register() override - { - OnEffectRemove.Register(&spell_mimiron_summon_junk_bot_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); - } - }; + void OnRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) + { + if (Unit* caster = GetCaster()) + if (InstanceScript* instance = caster->GetInstanceScript()) + if (instance->GetBossState(DATA_MIMIRON) == IN_PROGRESS) + caster->CastSpell(caster, SPELL_SUMMON_JUNK_BOT, {aurEff, instance->GetGuidData(DATA_AERIAL_COMMAND_UNIT)}); + } - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_mimiron_summon_junk_bot_AuraScript(); + OnEffectRemove.Register(&spell_mimiron_summon_junk_bot_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); } + }; + + AuraScript* GetAuraScript() const override + { + return new spell_mimiron_summon_junk_bot_AuraScript(); + } }; // 63820 - Summon Scrap Bot Trigger class spell_mimiron_summon_junk_bot_target : public SpellScriptLoader { - public: - spell_mimiron_summon_junk_bot_target() : SpellScriptLoader("spell_mimiron_summon_junk_bot_target") { } + public: + spell_mimiron_summon_junk_bot_target() : SpellScriptLoader("spell_mimiron_summon_junk_bot_target") + { + } - class spell_mimiron_summon_junk_bot_target_SpellScript : public SpellScript + class spell_mimiron_summon_junk_bot_target_SpellScript : public SpellScript + { + bool Validate(SpellInfo const* /*spell*/) override { - bool Validate(SpellInfo const* /*spell*/) override - { - return ValidateSpellInfo({ SPELL_SUMMON_JUNK_BOT_DUMMY }); - } - - void HandleDummy(SpellEffIndex /*effIndex*/) - { - GetHitUnit()->CastSpell(GetHitUnit(), SPELL_SUMMON_JUNK_BOT_DUMMY, true); - } + return ValidateSpellInfo({SPELL_SUMMON_JUNK_BOT_DUMMY}); + } - void Register() override - { - OnEffectHitTarget.Register(&spell_mimiron_summon_junk_bot_target_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); - } - }; + void HandleDummy(SpellEffIndex /*effIndex*/) + { + GetHitUnit()->CastSpell(GetHitUnit(), SPELL_SUMMON_JUNK_BOT_DUMMY, true); + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_mimiron_summon_junk_bot_target_SpellScript(); + OnEffectHitTarget.Register(&spell_mimiron_summon_junk_bot_target_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_mimiron_summon_junk_bot_target_SpellScript(); + } }; // 63339 - Weld class spell_mimiron_weld : public SpellScriptLoader { - public: - spell_mimiron_weld() : SpellScriptLoader("spell_mimiron_weld") { } + public: + spell_mimiron_weld() : SpellScriptLoader("spell_mimiron_weld") + { + } - class spell_mimiron_weld_AuraScript : public AuraScript + class spell_mimiron_weld_AuraScript : public AuraScript + { + void HandleTick(AuraEffect const* aurEff) { - void HandleTick(AuraEffect const* aurEff) - { - Unit* caster = GetTarget(); - if (Unit* vehicle = caster->GetVehicleBase()) - { - if (aurEff->GetTickNumber() % 5 == 0) - caster->CastSpell(vehicle, RepairSpells[urand(0, 3)]); - caster->SetFacingToObject(vehicle); - } - } - - void Register() override + Unit* caster = GetTarget(); + if (Unit* vehicle = caster->GetVehicleBase()) { - OnEffectPeriodic.Register(&spell_mimiron_weld_AuraScript::HandleTick, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); + if (aurEff->GetTickNumber() % 5 == 0) + caster->CastSpell(vehicle, RepairSpells[urand(0, 3)]); + caster->SetFacingToObject(vehicle); } - }; + } - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_mimiron_weld_AuraScript(); + OnEffectPeriodic.Register(&spell_mimiron_weld_AuraScript::HandleTick, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); } + }; + + AuraScript* GetAuraScript() const override + { + return new spell_mimiron_weld_AuraScript(); + } }; class achievement_setup_boom : public AchievementCriteriaScript { - public: - achievement_setup_boom() : AchievementCriteriaScript("achievement_setup_boom") { } + public: + achievement_setup_boom() : AchievementCriteriaScript("achievement_setup_boom") + { + } - bool OnCheck(Player* /*source*/, Unit* target) override - { - return target && target->GetAI()->GetData(DATA_SETUP_BOMB); - } + bool OnCheck(Player* /*source*/, Unit* target) override + { + return target && target->GetAI()->GetData(DATA_SETUP_BOMB); + } }; class achievement_setup_mine : public AchievementCriteriaScript { - public: - achievement_setup_mine() : AchievementCriteriaScript("achievement_setup_mine") { } + public: + achievement_setup_mine() : AchievementCriteriaScript("achievement_setup_mine") + { + } - bool OnCheck(Player* /*source*/, Unit* target) override - { - return target && target->GetAI()->GetData(DATA_SETUP_MINE); - } + bool OnCheck(Player* /*source*/, Unit* target) override + { + return target && target->GetAI()->GetData(DATA_SETUP_MINE); + } }; class achievement_setup_rocket : public AchievementCriteriaScript { - public: - achievement_setup_rocket() : AchievementCriteriaScript("achievement_setup_rocket") { } + public: + achievement_setup_rocket() : AchievementCriteriaScript("achievement_setup_rocket") + { + } - bool OnCheck(Player* /*source*/, Unit* target) override - { - return target && target->GetAI()->GetData(DATA_SETUP_ROCKET); - } + bool OnCheck(Player* /*source*/, Unit* target) override + { + return target && target->GetAI()->GetData(DATA_SETUP_ROCKET); + } }; class achievement_firefighter : public AchievementCriteriaScript { - public: - achievement_firefighter() : AchievementCriteriaScript("achievement_firefighter") { } + public: + achievement_firefighter() : AchievementCriteriaScript("achievement_firefighter") + { + } - bool OnCheck(Player* /*source*/, Unit* target) override - { - return target && target->GetAI()->GetData(DATA_FIREFIGHTER); - } + bool OnCheck(Player* /*source*/, Unit* target) override + { + return target && target->GetAI()->GetData(DATA_FIREFIGHTER); + } }; void AddSC_boss_mimiron() diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_xt002.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_xt002.cpp index ce2d603c..2ed8bee5 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_xt002.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_xt002.cpp @@ -21,77 +21,77 @@ Codestyle */ -#include "ScriptMgr.h" #include "InstanceScript.h" #include "MotionMaster.h" #include "ObjectAccessor.h" #include "Opcodes.h" #include "PassiveAI.h" #include "Player.h" +#include "ScriptMgr.h" #include "ScriptedCreature.h" #include "SpellAuraEffects.h" #include "SpellScript.h" -#include "ulduar.h" #include "Vehicle.h" #include "WorldPacket.h" +#include "ulduar.h" enum Spells { - SPELL_TYMPANIC_TANTRUM = 62776, - SPELL_SEARING_LIGHT = 63018, + SPELL_TYMPANIC_TANTRUM = 62776, + SPELL_SEARING_LIGHT = 63018, - SPELL_SUMMON_LIFE_SPARK = 64210, - SPELL_SUMMON_VOID_ZONE = 64203, + SPELL_SUMMON_LIFE_SPARK = 64210, + SPELL_SUMMON_VOID_ZONE = 64203, - SPELL_GRAVITY_BOMB = 63024, + SPELL_GRAVITY_BOMB = 63024, - SPELL_HEARTBREAK = 65737, + SPELL_HEARTBREAK = 65737, // Cast by 33337 at Heartbreak: - SPELL_RECHARGE_PUMMELER = 62831, // Summons 33344 - SPELL_RECHARGE_SCRAPBOT = 62828, // Summons 33343 - SPELL_RECHARGE_BOOMBOT = 62835, // Summons 33346 + SPELL_RECHARGE_PUMMELER = 62831, // Summons 33344 + SPELL_RECHARGE_SCRAPBOT = 62828, // Summons 33343 + SPELL_RECHARGE_BOOMBOT = 62835, // Summons 33346 // Cast by 33329 on 33337 (visual?) - SPELL_ENERGY_ORB = 62790, // Triggers 62826 - needs spellscript for periodic tick to cast one of the random spells above + SPELL_ENERGY_ORB = 62790, // Triggers 62826 - needs spellscript for periodic tick to cast one of the random spells above - SPELL_HEART_HEAL_TO_FULL = 17683, - SPELL_HEART_OVERLOAD = 62789, + SPELL_HEART_HEAL_TO_FULL = 17683, + SPELL_HEART_OVERLOAD = 62789, - SPELL_HEART_LIGHTNING_TETHER = 64799, // Cast on self? - SPELL_ENRAGE = 26662, - SPELL_STAND = 37752, - SPELL_SUBMERGE = 37751, + SPELL_HEART_LIGHTNING_TETHER = 64799, // Cast on self? + SPELL_ENRAGE = 26662, + SPELL_STAND = 37752, + SPELL_SUBMERGE = 37751, //------------------VOID ZONE-------------------- - SPELL_VOID_ZONE = 64203, - SPELL_CONSUMPTION = 64208, + SPELL_VOID_ZONE = 64203, + SPELL_CONSUMPTION = 64208, // Life Spark - SPELL_ARCANE_POWER_STATE = 49411, - SPELL_STATIC_CHARGED = 64227, - SPELL_SHOCK = 64230, + SPELL_ARCANE_POWER_STATE = 49411, + SPELL_STATIC_CHARGED = 64227, + SPELL_SHOCK = 64230, //----------------XT-002 HEART------------------- - SPELL_EXPOSED_HEART = 63849, - SPELL_HEART_RIDE_VEHICLE = 63852, - SPELL_RIDE_VEHICLE_EXPOSED = 63313, //Heart Exposed + SPELL_EXPOSED_HEART = 63849, + SPELL_HEART_RIDE_VEHICLE = 63852, + SPELL_RIDE_VEHICLE_EXPOSED = 63313, // Heart Exposed //---------------XM-024 PUMMELLER---------------- - SPELL_ARCING_SMASH = 8374, - SPELL_TRAMPLE = 5568, - SPELL_UPPERCUT = 10966, + SPELL_ARCING_SMASH = 8374, + SPELL_TRAMPLE = 5568, + SPELL_UPPERCUT = 10966, // Scrabot: - SPELL_SCRAPBOT_RIDE_VEHICLE = 47020, - SPELL_SUICIDE = 7, + SPELL_SCRAPBOT_RIDE_VEHICLE = 47020, + SPELL_SUICIDE = 7, //------------------BOOMBOT----------------------- - SPELL_AURA_BOOMBOT = 65032, - SPELL_BOOM = 62834, + SPELL_AURA_BOOMBOT = 65032, + SPELL_BOOM = 62834, // Achievement-related spells - SPELL_ACHIEVEMENT_CREDIT_NERF_SCRAPBOTS = 65037 + SPELL_ACHIEVEMENT_CREDIT_NERF_SCRAPBOTS = 65037 }; enum Events @@ -108,22 +108,22 @@ enum Events enum Timers { - TIMER_TYMPANIC_TANTRUM_MIN = 32000, - TIMER_TYMPANIC_TANTRUM_MAX = 36000, - TIMER_SEARING_LIGHT = 20000, - TIMER_GRAVITY_BOMB = 20000, - TIMER_HEART_PHASE = 30000, - TIMER_ENERGY_ORB_MIN = 9000, - TIMER_ENERGY_ORB_MAX = 10000, - TIMER_ENRAGE = 600000, + TIMER_TYMPANIC_TANTRUM_MIN = 32000, + TIMER_TYMPANIC_TANTRUM_MAX = 36000, + TIMER_SEARING_LIGHT = 20000, + TIMER_GRAVITY_BOMB = 20000, + TIMER_HEART_PHASE = 30000, + TIMER_ENERGY_ORB_MIN = 9000, + TIMER_ENERGY_ORB_MAX = 10000, + TIMER_ENRAGE = 600000, // Pummeller // Timers may be off - TIMER_ARCING_SMASH = 27000, - TIMER_TRAMPLE = 22000, - TIMER_UPPERCUT = 17000, + TIMER_ARCING_SMASH = 27000, + TIMER_TRAMPLE = 22000, + TIMER_UPPERCUT = 17000, - TIMER_SPAWN_ADD = 12000, + TIMER_SPAWN_ADD = 12000, }; enum Actions @@ -141,29 +141,29 @@ enum XT002Data enum Yells { - SAY_AGGRO = 0, - SAY_HEART_OPENED = 1, - SAY_HEART_CLOSED = 2, - SAY_TYMPANIC_TANTRUM = 3, - SAY_SLAY = 4, - SAY_BERSERK = 5, - SAY_DEATH = 6, - SAY_SUMMON = 7, - EMOTE_HEART_OPENED = 8, - EMOTE_HEART_CLOSED = 9, - EMOTE_TYMPANIC_TANTRUM = 10, - EMOTE_SCRAPBOT = 11 + SAY_AGGRO = 0, + SAY_HEART_OPENED = 1, + SAY_HEART_CLOSED = 2, + SAY_TYMPANIC_TANTRUM = 3, + SAY_SLAY = 4, + SAY_BERSERK = 5, + SAY_DEATH = 6, + SAY_SUMMON = 7, + EMOTE_HEART_OPENED = 8, + EMOTE_HEART_CLOSED = 9, + EMOTE_TYMPANIC_TANTRUM = 10, + EMOTE_SCRAPBOT = 11 }; enum AchievementCredits { - ACHIEV_MUST_DECONSTRUCT_FASTER = 21027, + ACHIEV_MUST_DECONSTRUCT_FASTER = 21027, }; enum VehicleSeats { - HEART_VEHICLE_SEAT_NORMAL = 0, - HEART_VEHICLE_SEAT_EXPOSED = 1, + HEART_VEHICLE_SEAT_NORMAL = 0, + HEART_VEHICLE_SEAT_EXPOSED = 1, }; /*------------------------------------------------------- @@ -173,274 +173,275 @@ enum VehicleSeats *///---------------------------------------------------- class boss_xt002 : public CreatureScript { - public: - boss_xt002() : CreatureScript("boss_xt002") { } + public: + boss_xt002() : CreatureScript("boss_xt002") + { + } - struct boss_xt002_AI : public BossAI + struct boss_xt002_AI : public BossAI + { + boss_xt002_AI(Creature* creature) : BossAI(creature, DATA_XT002) { - boss_xt002_AI(Creature* creature) : BossAI(creature, DATA_XT002) - { - Initialize(); - _transferHealth = 0; - } + Initialize(); + _transferHealth = 0; + } - void Initialize() - { - _healthRecovered = false; - _gravityBombCasualty = false; - _hardMode = false; + void Initialize() + { + _healthRecovered = false; + _gravityBombCasualty = false; + _hardMode = false; - _phase = 1; - _heartExposed = 0; - } + _phase = 1; + _heartExposed = 0; + } - void Reset() override - { - _Reset(); + void Reset() override + { + _Reset(); - me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - me->SetReactState(REACT_AGGRESSIVE); - DoCastSelf(SPELL_STAND); + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + me->SetReactState(REACT_AGGRESSIVE); + DoCastSelf(SPELL_STAND); - Initialize(); + Initialize(); - instance->DoStopTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_MUST_DECONSTRUCT_FASTER); - } + instance->DoStopTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_MUST_DECONSTRUCT_FASTER); + } - void EnterEvadeMode(EvadeReason /*why*/) override - { - summons.DespawnAll(); - _DespawnAtEvade(); - } + void EnterEvadeMode(EvadeReason /*why*/) override + { + summons.DespawnAll(); + _DespawnAtEvade(); + } - void JustEngagedWith(Unit* who) override - { - BossAI::JustEngagedWith(who); - Talk(SAY_AGGRO); + void JustEngagedWith(Unit* who) override + { + BossAI::JustEngagedWith(who); + Talk(SAY_AGGRO); - events.ScheduleEvent(EVENT_ENRAGE, TIMER_ENRAGE); - events.ScheduleEvent(EVENT_GRAVITY_BOMB, TIMER_GRAVITY_BOMB); - events.ScheduleEvent(EVENT_SEARING_LIGHT, TIMER_SEARING_LIGHT); - //Tantrum is cast a bit slower the first time. - events.ScheduleEvent(EVENT_TYMPANIC_TANTRUM, urand(TIMER_TYMPANIC_TANTRUM_MIN, TIMER_TYMPANIC_TANTRUM_MAX) * 2); + events.ScheduleEvent(EVENT_ENRAGE, TIMER_ENRAGE); + events.ScheduleEvent(EVENT_GRAVITY_BOMB, TIMER_GRAVITY_BOMB); + events.ScheduleEvent(EVENT_SEARING_LIGHT, TIMER_SEARING_LIGHT); + // Tantrum is cast a bit slower the first time. + events.ScheduleEvent(EVENT_TYMPANIC_TANTRUM, urand(TIMER_TYMPANIC_TANTRUM_MIN, TIMER_TYMPANIC_TANTRUM_MAX) * 2); - instance->DoStartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_MUST_DECONSTRUCT_FASTER); - } + instance->DoStartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_MUST_DECONSTRUCT_FASTER); + } - void DoAction(int32 action) override + void DoAction(int32 action) override + { + switch (action) { - switch (action) - { - case ACTION_ENTER_HARD_MODE: - events.ScheduleEvent(EVENT_ENTER_HARD_MODE, 1); - break; - } + case ACTION_ENTER_HARD_MODE: + events.ScheduleEvent(EVENT_ENTER_HARD_MODE, 1); + break; } + } - void KilledUnit(Unit* who) override - { - if (who->GetTypeId() == TYPEID_PLAYER) - Talk(SAY_SLAY); - } + void KilledUnit(Unit* who) override + { + if (who->GetTypeId() == TYPEID_PLAYER) + Talk(SAY_SLAY); + } - void JustDied(Unit* /*killer*/) override - { - Talk(SAY_DEATH); - _JustDied(); - me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - } + void JustDied(Unit* /*killer*/) override + { + Talk(SAY_DEATH); + _JustDied(); + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + } - void DamageTaken(Unit* /*attacker*/, uint32& /*damage*/) override - { - if (!_hardMode && _phase == 1 && !HealthAbovePct(100 - 25 * (_heartExposed+1))) - ExposeHeart(); - } + void DamageTaken(Unit* /*attacker*/, uint32& /*damage*/) override + { + if (!_hardMode && _phase == 1 && !HealthAbovePct(100 - 25 * (_heartExposed + 1))) + ExposeHeart(); + } - void UpdateAI(uint32 diff) override - { - if (!UpdateVictim()) - return; + void UpdateAI(uint32 diff) override + { + if (!UpdateVictim()) + return; - events.Update(diff); + events.Update(diff); - if (me->HasUnitState(UNIT_STATE_CASTING)) - return; + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; - while (uint32 eventId = events.ExecuteEvent()) + while (uint32 eventId = events.ExecuteEvent()) + { + switch (eventId) { - switch (eventId) - { - case EVENT_SEARING_LIGHT: - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) - DoCast(target, SPELL_SEARING_LIGHT); - - events.ScheduleEvent(EVENT_SEARING_LIGHT, TIMER_SEARING_LIGHT); - break; - case EVENT_GRAVITY_BOMB: - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) - DoCast(target, SPELL_GRAVITY_BOMB); - - events.ScheduleEvent(EVENT_GRAVITY_BOMB, TIMER_GRAVITY_BOMB); - break; - case EVENT_TYMPANIC_TANTRUM: - Talk(SAY_TYMPANIC_TANTRUM); - Talk(EMOTE_TYMPANIC_TANTRUM); - DoCast(SPELL_TYMPANIC_TANTRUM); - events.ScheduleEvent(EVENT_TYMPANIC_TANTRUM, urand(TIMER_TYMPANIC_TANTRUM_MIN, TIMER_TYMPANIC_TANTRUM_MAX)); - break; - case EVENT_DISPOSE_HEART: - SetPhaseOne(); - break; - case EVENT_ENRAGE: - Talk(SAY_BERSERK); - DoCastSelf(SPELL_ENRAGE); - break; - case EVENT_ENTER_HARD_MODE: - me->SetFullHealth(); - DoCastSelf(SPELL_HEARTBREAK, true); - me->AddLootMode(LOOT_MODE_HARD_MODE_1); - _hardMode = true; - SetPhaseOne(); - break; - } - - if (me->HasUnitState(UNIT_STATE_CASTING)) - return; + case EVENT_SEARING_LIGHT: + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) + DoCast(target, SPELL_SEARING_LIGHT); + + events.ScheduleEvent(EVENT_SEARING_LIGHT, TIMER_SEARING_LIGHT); + break; + case EVENT_GRAVITY_BOMB: + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) + DoCast(target, SPELL_GRAVITY_BOMB); + + events.ScheduleEvent(EVENT_GRAVITY_BOMB, TIMER_GRAVITY_BOMB); + break; + case EVENT_TYMPANIC_TANTRUM: + Talk(SAY_TYMPANIC_TANTRUM); + Talk(EMOTE_TYMPANIC_TANTRUM); + DoCast(SPELL_TYMPANIC_TANTRUM); + events.ScheduleEvent(EVENT_TYMPANIC_TANTRUM, urand(TIMER_TYMPANIC_TANTRUM_MIN, TIMER_TYMPANIC_TANTRUM_MAX)); + break; + case EVENT_DISPOSE_HEART: + SetPhaseOne(); + break; + case EVENT_ENRAGE: + Talk(SAY_BERSERK); + DoCastSelf(SPELL_ENRAGE); + break; + case EVENT_ENTER_HARD_MODE: + me->SetFullHealth(); + DoCastSelf(SPELL_HEARTBREAK, true); + me->AddLootMode(LOOT_MODE_HARD_MODE_1); + _hardMode = true; + SetPhaseOne(); + break; } - if (_phase == 1) - DoMeleeAttackIfReady(); + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; } - void PassengerBoarded(Unit* who, int8 seatId, bool apply) override - { - if (apply && who->GetEntry() == NPC_XS013_SCRAPBOT) - { - // Need this so we can properly determine when to expose heart again in damagetaken hook - if (me->GetHealthPct() > (25 * (4 - _heartExposed))) - ++_heartExposed; + if (_phase == 1) + DoMeleeAttackIfReady(); + } - Talk(EMOTE_SCRAPBOT); - _healthRecovered = true; - } + void PassengerBoarded(Unit* who, int8 seatId, bool apply) override + { + if (apply && who->GetEntry() == NPC_XS013_SCRAPBOT) + { + // Need this so we can properly determine when to expose heart again in damagetaken hook + if (me->GetHealthPct() > (25 * (4 - _heartExposed))) + ++_heartExposed; - if (apply && seatId == HEART_VEHICLE_SEAT_EXPOSED) - who->CastSpell(who, SPELL_EXPOSED_HEART); // Channeled + Talk(EMOTE_SCRAPBOT); + _healthRecovered = true; } - uint32 GetData(uint32 type) const override - { - switch (type) - { - case DATA_HARD_MODE: - return _hardMode ? 1 : 0; - case DATA_HEALTH_RECOVERED: - return _healthRecovered ? 1 : 0; - case DATA_GRAVITY_BOMB_CASUALTY: - return _gravityBombCasualty ? 1 : 0; - } + if (apply && seatId == HEART_VEHICLE_SEAT_EXPOSED) + who->CastSpell(who, SPELL_EXPOSED_HEART); // Channeled + } - return 0; + uint32 GetData(uint32 type) const override + { + switch (type) + { + case DATA_HARD_MODE: + return _hardMode ? 1 : 0; + case DATA_HEALTH_RECOVERED: + return _healthRecovered ? 1 : 0; + case DATA_GRAVITY_BOMB_CASUALTY: + return _gravityBombCasualty ? 1 : 0; } - void SetData(uint32 type, uint32 data) override + return 0; + } + + void SetData(uint32 type, uint32 data) override + { + switch (type) { - switch (type) - { - case DATA_TRANSFERED_HEALTH: - _transferHealth = data; - break; - case DATA_GRAVITY_BOMB_CASUALTY: - _gravityBombCasualty = (data > 0) ? true : false; - break; - } + case DATA_TRANSFERED_HEALTH: + _transferHealth = data; + break; + case DATA_GRAVITY_BOMB_CASUALTY: + _gravityBombCasualty = (data > 0) ? true : false; + break; } + } - void ExposeHeart() - { - Talk(SAY_HEART_OPENED); - Talk(EMOTE_HEART_OPENED); + void ExposeHeart() + { + Talk(SAY_HEART_OPENED); + Talk(EMOTE_HEART_OPENED); - DoCastSelf(SPELL_SUBMERGE); // Will make creature untargetable - me->AttackStop(); - me->SetReactState(REACT_PASSIVE); + DoCastSelf(SPELL_SUBMERGE); // Will make creature untargetable + me->AttackStop(); + me->SetReactState(REACT_PASSIVE); - Unit* heart = me->GetVehicleKit() ? me->GetVehicleKit()->GetPassenger(HEART_VEHICLE_SEAT_NORMAL) : nullptr; - if (heart) - { - heart->CastSpell(heart, SPELL_HEART_OVERLOAD); - heart->CastSpell(me, SPELL_HEART_LIGHTNING_TETHER); - heart->CastSpell(heart, SPELL_HEART_HEAL_TO_FULL, true); - heart->CastSpell(me, SPELL_RIDE_VEHICLE_EXPOSED, true); - heart->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - heart->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNK_29); - } - - events.CancelEvent(EVENT_SEARING_LIGHT); - events.CancelEvent(EVENT_GRAVITY_BOMB); - events.CancelEvent(EVENT_TYMPANIC_TANTRUM); - - // Start "end of phase 2 timer" - events.ScheduleEvent(EVENT_DISPOSE_HEART, TIMER_HEART_PHASE); - - // Phase 2 has officially started - _phase = 2; - _heartExposed++; + Unit* heart = me->GetVehicleKit() ? me->GetVehicleKit()->GetPassenger(HEART_VEHICLE_SEAT_NORMAL) : nullptr; + if (heart) + { + heart->CastSpell(heart, SPELL_HEART_OVERLOAD); + heart->CastSpell(me, SPELL_HEART_LIGHTNING_TETHER); + heart->CastSpell(heart, SPELL_HEART_HEAL_TO_FULL, true); + heart->CastSpell(me, SPELL_RIDE_VEHICLE_EXPOSED, true); + heart->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + heart->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNK_29); } - void SetPhaseOne() - { - Talk(SAY_HEART_CLOSED); - Talk(EMOTE_HEART_CLOSED); + events.CancelEvent(EVENT_SEARING_LIGHT); + events.CancelEvent(EVENT_GRAVITY_BOMB); + events.CancelEvent(EVENT_TYMPANIC_TANTRUM); - me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - me->SetReactState(REACT_AGGRESSIVE); - DoCastSelf(SPELL_STAND); + // Start "end of phase 2 timer" + events.ScheduleEvent(EVENT_DISPOSE_HEART, TIMER_HEART_PHASE); - _phase = 1; + // Phase 2 has officially started + _phase = 2; + _heartExposed++; + } - events.RescheduleEvent(EVENT_SEARING_LIGHT, TIMER_SEARING_LIGHT / 2); - events.RescheduleEvent(EVENT_GRAVITY_BOMB, TIMER_GRAVITY_BOMB); - events.RescheduleEvent(EVENT_TYMPANIC_TANTRUM, urand(TIMER_TYMPANIC_TANTRUM_MIN, TIMER_TYMPANIC_TANTRUM_MAX)); + void SetPhaseOne() + { + Talk(SAY_HEART_CLOSED); + Talk(EMOTE_HEART_CLOSED); - Unit* heart = me->GetVehicleKit() ? me->GetVehicleKit()->GetPassenger(HEART_VEHICLE_SEAT_EXPOSED) : nullptr; - if (!heart) - return; + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + me->SetReactState(REACT_AGGRESSIVE); + DoCastSelf(SPELL_STAND); - heart->CastSpell(me, SPELL_HEART_RIDE_VEHICLE, true); - heart->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - heart->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNK_29); - heart->RemoveAurasDueToSpell(SPELL_EXPOSED_HEART); + _phase = 1; - if (!_hardMode) - { - if (!_transferHealth) - _transferHealth = (heart->GetMaxHealth() - heart->GetHealth()); + events.RescheduleEvent(EVENT_SEARING_LIGHT, TIMER_SEARING_LIGHT / 2); + events.RescheduleEvent(EVENT_GRAVITY_BOMB, TIMER_GRAVITY_BOMB); + events.RescheduleEvent(EVENT_TYMPANIC_TANTRUM, urand(TIMER_TYMPANIC_TANTRUM_MIN, TIMER_TYMPANIC_TANTRUM_MAX)); - if (_transferHealth >= me->GetHealth()) - _transferHealth = me->GetHealth() - 1; + Unit* heart = me->GetVehicleKit() ? me->GetVehicleKit()->GetPassenger(HEART_VEHICLE_SEAT_EXPOSED) : nullptr; + if (!heart) + return; - me->ModifyHealth(-((int32)_transferHealth)); - me->LowerPlayerDamageReq(_transferHealth); - } - } + heart->CastSpell(me, SPELL_HEART_RIDE_VEHICLE, true); + heart->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + heart->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNK_29); + heart->RemoveAurasDueToSpell(SPELL_EXPOSED_HEART); - private: - // Achievement related - bool _healthRecovered; // Did a scrapbot recover XT-002's health during the encounter? - bool _hardMode; // Are we in hard mode? Or: was the heart killed during phase 2? - bool _gravityBombCasualty; // Did someone die because of Gravity Bomb damage? + if (!_hardMode) + { + if (!_transferHealth) + _transferHealth = (heart->GetMaxHealth() - heart->GetHealth()); - uint8 _phase; - uint8 _heartExposed; - uint32 _transferHealth; - }; + if (_transferHealth >= me->GetHealth()) + _transferHealth = me->GetHealth() - 1; - CreatureAI* GetAI(Creature* creature) const override - { - return GetUlduarAI(creature); + me->ModifyHealth(-((int32)_transferHealth)); + me->LowerPlayerDamageReq(_transferHealth); + } } + private: + // Achievement related + bool _healthRecovered; // Did a scrapbot recover XT-002's health during the encounter? + bool _hardMode; // Are we in hard mode? Or: was the heart killed during phase 2? + bool _gravityBombCasualty; // Did someone die because of Gravity Bomb damage? + + uint8 _phase; + uint8 _heartExposed; + uint32 _transferHealth; + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return GetUlduarAI(creature); + } }; /*------------------------------------------------------- @@ -451,30 +452,34 @@ class boss_xt002 : public CreatureScript class npc_xt002_heart : public CreatureScript { - public: - npc_xt002_heart() : CreatureScript("npc_xt002_heart") { } + public: + npc_xt002_heart() : CreatureScript("npc_xt002_heart") + { + } - struct npc_xt002_heartAI : public NullCreatureAI + struct npc_xt002_heartAI : public NullCreatureAI + { + npc_xt002_heartAI(Creature* creature) : NullCreatureAI(creature), _instance(creature->GetInstanceScript()) { - npc_xt002_heartAI(Creature* creature) : NullCreatureAI(creature), _instance(creature->GetInstanceScript()) { } + } - void JustDied(Unit* /*killer*/) override + void JustDied(Unit* /*killer*/) override + { + if (Creature* xt002 = _instance->GetCreature(DATA_XT002)) { - if (Creature* xt002 = _instance->GetCreature(DATA_XT002)) - { - xt002->AI()->SetData(DATA_TRANSFERED_HEALTH, me->GetHealth()); - xt002->AI()->DoAction(ACTION_ENTER_HARD_MODE); - } + xt002->AI()->SetData(DATA_TRANSFERED_HEALTH, me->GetHealth()); + xt002->AI()->DoAction(ACTION_ENTER_HARD_MODE); } + } - private: - InstanceScript* _instance; - }; + private: + InstanceScript* _instance; + }; - CreatureAI* GetAI(Creature* creature) const override - { - return GetUlduarAI(creature); - } + CreatureAI* GetAI(Creature* creature) const override + { + return GetUlduarAI(creature); + } }; /*------------------------------------------------------- @@ -484,60 +489,62 @@ class npc_xt002_heart : public CreatureScript *///---------------------------------------------------- class npc_scrapbot : public CreatureScript { - public: - npc_scrapbot() : CreatureScript("npc_scrapbot") { } + public: + npc_scrapbot() : CreatureScript("npc_scrapbot") + { + } - struct npc_scrapbotAI : public ScriptedAI + struct npc_scrapbotAI : public ScriptedAI + { + npc_scrapbotAI(Creature* creature) : ScriptedAI(creature) { - npc_scrapbotAI(Creature* creature) : ScriptedAI(creature) - { - Initialize(); - _instance = me->GetInstanceScript(); - } + Initialize(); + _instance = me->GetInstanceScript(); + } - void Initialize() - { - _rangeCheckTimer = 500; - } + void Initialize() + { + _rangeCheckTimer = 500; + } - void Reset() override - { - me->SetReactState(REACT_PASSIVE); + void Reset() override + { + me->SetReactState(REACT_PASSIVE); - Initialize(); + Initialize(); - if (Creature* xt002 = _instance->GetCreature(DATA_XT002)) - me->GetMotionMaster()->MoveFollow(xt002, 0.0f, 0.0f); - } + if (Creature* xt002 = _instance->GetCreature(DATA_XT002)) + me->GetMotionMaster()->MoveFollow(xt002, 0.0f, 0.0f); + } - void UpdateAI(uint32 diff) override + void UpdateAI(uint32 diff) override + { + if (_rangeCheckTimer <= diff) { - if (_rangeCheckTimer <= diff) + if (Creature* xt002 = _instance->GetCreature(DATA_XT002)) { - if (Creature* xt002 = _instance->GetCreature(DATA_XT002)) + if (me->IsWithinMeleeRange(xt002)) { - if (me->IsWithinMeleeRange(xt002)) - { - DoCast(xt002, SPELL_SCRAPBOT_RIDE_VEHICLE); - // Unapply vehicle aura again - xt002->RemoveAurasDueToSpell(SPELL_SCRAPBOT_RIDE_VEHICLE); - me->DespawnOrUnsummon(); - } + DoCast(xt002, SPELL_SCRAPBOT_RIDE_VEHICLE); + // Unapply vehicle aura again + xt002->RemoveAurasDueToSpell(SPELL_SCRAPBOT_RIDE_VEHICLE); + me->DespawnOrUnsummon(); } } - else - _rangeCheckTimer -= diff; } + else + _rangeCheckTimer -= diff; + } - private: - InstanceScript* _instance; - uint32 _rangeCheckTimer; - }; + private: + InstanceScript* _instance; + uint32 _rangeCheckTimer; + }; - CreatureAI* GetAI(Creature* creature) const override - { - return GetUlduarAI(creature); - } + CreatureAI* GetAI(Creature* creature) const override + { + return GetUlduarAI(creature); + } }; /*------------------------------------------------------- @@ -547,81 +554,83 @@ class npc_scrapbot : public CreatureScript *///---------------------------------------------------- class npc_pummeller : public CreatureScript { - public: - npc_pummeller() : CreatureScript("npc_pummeller") { } + public: + npc_pummeller() : CreatureScript("npc_pummeller") + { + } - struct npc_pummellerAI : public ScriptedAI + struct npc_pummellerAI : public ScriptedAI + { + npc_pummellerAI(Creature* creature) : ScriptedAI(creature) { - npc_pummellerAI(Creature* creature) : ScriptedAI(creature) - { - Initialize(); - _instance = creature->GetInstanceScript(); - } + Initialize(); + _instance = creature->GetInstanceScript(); + } + + void Initialize() + { + _arcingSmashTimer = TIMER_ARCING_SMASH; + _trampleTimer = TIMER_TRAMPLE; + _uppercutTimer = TIMER_UPPERCUT; + } - void Initialize() + void Reset() override + { + Initialize(); + + if (Creature* xt002 = _instance->GetCreature(DATA_XT002)) { - _arcingSmashTimer = TIMER_ARCING_SMASH; - _trampleTimer = TIMER_TRAMPLE; - _uppercutTimer = TIMER_UPPERCUT; + Position pos = xt002->GetPosition(); + me->GetMotionMaster()->MovePoint(0, pos); } + } - void Reset() override - { - Initialize(); + void UpdateAI(uint32 diff) override + { + if (!UpdateVictim()) + return; - if (Creature* xt002 = _instance->GetCreature(DATA_XT002)) + if (me->IsWithinMeleeRange(me->GetVictim())) + { + if (_arcingSmashTimer <= diff) { - Position pos = xt002->GetPosition(); - me->GetMotionMaster()->MovePoint(0, pos); + DoCastVictim(SPELL_ARCING_SMASH); + _arcingSmashTimer = TIMER_ARCING_SMASH; } - } - - void UpdateAI(uint32 diff) override - { - if (!UpdateVictim()) - return; + else + _arcingSmashTimer -= diff; - if (me->IsWithinMeleeRange(me->GetVictim())) + if (_trampleTimer <= diff) { - if (_arcingSmashTimer <= diff) - { - DoCastVictim(SPELL_ARCING_SMASH); - _arcingSmashTimer = TIMER_ARCING_SMASH; - } - else - _arcingSmashTimer -= diff; - - if (_trampleTimer <= diff) - { - DoCastVictim(SPELL_TRAMPLE); - _trampleTimer = TIMER_TRAMPLE; - } - else - _trampleTimer -= diff; - - if (_uppercutTimer <= diff) - { - DoCastVictim(SPELL_UPPERCUT); - _uppercutTimer = TIMER_UPPERCUT; - } - else - _uppercutTimer -= diff; + DoCastVictim(SPELL_TRAMPLE); + _trampleTimer = TIMER_TRAMPLE; } + else + _trampleTimer -= diff; - DoMeleeAttackIfReady(); + if (_uppercutTimer <= diff) + { + DoCastVictim(SPELL_UPPERCUT); + _uppercutTimer = TIMER_UPPERCUT; + } + else + _uppercutTimer -= diff; } - private: - InstanceScript* _instance; - uint32 _arcingSmashTimer; - uint32 _trampleTimer; - uint32 _uppercutTimer; - }; - - CreatureAI* GetAI(Creature* creature) const override - { - return GetUlduarAI(creature); + DoMeleeAttackIfReady(); } + + private: + InstanceScript* _instance; + uint32 _arcingSmashTimer; + uint32 _trampleTimer; + uint32 _uppercutTimer; + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return GetUlduarAI(creature); + } }; /*------------------------------------------------------- @@ -631,172 +640,180 @@ class npc_pummeller : public CreatureScript *///---------------------------------------------------- class BoomEvent : public BasicEvent { - public: - BoomEvent(Creature* me) : _me(me) - { - } - - bool Execute(uint64 /*time*/, uint32 /*diff*/) override - { - // This hack is here because we suspect our implementation of spell effect execution on targets - // is done in the wrong order. We suspect that EFFECT_0 needs to be applied on all targets, - // then EFFECT_1, etc - instead of applying each effect on target1, then target2, etc. - // The above situation causes the visual for this spell to be bugged, so we remove the instakill - // effect and implement a script hack for that. + public: + BoomEvent(Creature* me) : _me(me) + { + } - _me->CastSpell(_me, SPELL_BOOM, false); - return true; - } + bool Execute(uint64 /*time*/, uint32 /*diff*/) override + { + // This hack is here because we suspect our implementation of spell effect execution on targets + // is done in the wrong order. We suspect that EFFECT_0 needs to be applied on all targets, + // then EFFECT_1, etc - instead of applying each effect on target1, then target2, etc. + // The above situation causes the visual for this spell to be bugged, so we remove the instakill + // effect and implement a script hack for that. + + _me->CastSpell(_me, SPELL_BOOM, false); + return true; + } - private: - Creature* _me; + private: + Creature* _me; }; class npc_boombot : public CreatureScript { - public: - npc_boombot() : CreatureScript("npc_boombot") { } + public: + npc_boombot() : CreatureScript("npc_boombot") + { + } - struct npc_boombotAI : public ScriptedAI + struct npc_boombotAI : public ScriptedAI + { + npc_boombotAI(Creature* creature) : ScriptedAI(creature) { - npc_boombotAI(Creature* creature) : ScriptedAI(creature) - { - Initialize(); - _instance = creature->GetInstanceScript(); - } + Initialize(); + _instance = creature->GetInstanceScript(); + } - void Initialize() - { - _boomed = false; - } + void Initialize() + { + _boomed = false; + } - void Reset() override - { - Initialize(); + void Reset() override + { + Initialize(); - DoCast(SPELL_AURA_BOOMBOT); // For achievement + DoCast(SPELL_AURA_BOOMBOT); // For achievement - // HACK/workaround: - // these values aren't confirmed - lack of data - and the values in DB are incorrect - // these values are needed for correct damage of Boom spell - me->SetFloatValue(UNIT_FIELD_MINDAMAGE, 15000.0f); - me->SetFloatValue(UNIT_FIELD_MAXDAMAGE, 18000.0f); + // HACK/workaround: + // these values aren't confirmed - lack of data - and the values in DB are incorrect + // these values are needed for correct damage of Boom spell + me->SetFloatValue(UNIT_FIELD_MINDAMAGE, 15000.0f); + me->SetFloatValue(UNIT_FIELD_MAXDAMAGE, 18000.0f); - /// @todo proper waypoints? - if (Creature* xt002 = _instance->GetCreature(DATA_XT002)) - me->GetMotionMaster()->MoveFollow(xt002, 0.0f, 0.0f); - } + /// @todo proper waypoints? + if (Creature* xt002 = _instance->GetCreature(DATA_XT002)) + me->GetMotionMaster()->MoveFollow(xt002, 0.0f, 0.0f); + } - void DamageTaken(Unit* /*who*/, uint32& damage) override + void DamageTaken(Unit* /*who*/, uint32& damage) override + { + if (damage >= (me->GetHealth() - me->GetMaxHealth() * 0.5f) && !_boomed) { - if (damage >= (me->GetHealth() - me->GetMaxHealth() * 0.5f) && !_boomed) - { - _boomed = true; // Prevent recursive calls + _boomed = true; // Prevent recursive calls - WorldPacket data(SMSG_SPELLINSTAKILLLOG, 8+8+4); - data << uint64(me->GetGUID()); - data << uint64(me->GetGUID()); - data << uint32(SPELL_BOOM); - me->SendMessageToSet(&data, false); + WorldPacket data(SMSG_SPELLINSTAKILLLOG, 8 + 8 + 4); + data << uint64(me->GetGUID()); + data << uint64(me->GetGUID()); + data << uint32(SPELL_BOOM); + me->SendMessageToSet(&data, false); - me->DealDamage(me, me->GetHealth(), nullptr, NODAMAGE, SPELL_SCHOOL_MASK_NORMAL, nullptr, false); + me->KillSelf(); - damage = 0; + damage = 0; - // Visual only seems to work if the instant kill event is delayed or the spell itself is delayed - // Casting done from player and caster source has the same targetinfo flags, - // so that can't be the issue - // See BoomEvent class - // Schedule 1s delayed - me->m_Events.AddEvent(new BoomEvent(me), me->m_Events.CalculateTime(1*IN_MILLISECONDS)); - } + // Visual only seems to work if the instant kill event is delayed or the spell itself is delayed + // Casting done from player and caster source has the same targetinfo flags, + // so that can't be the issue + // See BoomEvent class + // Schedule 1s delayed + me->m_Events.AddEvent(new BoomEvent(me), me->m_Events.CalculateTime(1 * IN_MILLISECONDS)); } + } - void UpdateAI(uint32 /*diff*/) override - { - if (!UpdateVictim()) - return; + void UpdateAI(uint32 /*diff*/) override + { + if (!UpdateVictim()) + return; - // No melee attack - } + // No melee attack + } - private: - InstanceScript* _instance; - bool _boomed; - }; + private: + InstanceScript* _instance; + bool _boomed; + }; - CreatureAI* GetAI(Creature* creature) const override - { - return GetUlduarAI(creature); - } + CreatureAI* GetAI(Creature* creature) const override + { + return GetUlduarAI(creature); + } }; - class npc_life_spark : public CreatureScript { - public: - npc_life_spark() : CreatureScript("npc_life_spark") { } + public: + npc_life_spark() : CreatureScript("npc_life_spark") + { + } + + CreatureAI* GetAI(Creature* creature) const override + { + return GetUlduarAI(creature); + } - CreatureAI* GetAI(Creature* creature) const override + struct npc_life_sparkAI : public ScriptedAI + { + npc_life_sparkAI(Creature* creature) : ScriptedAI(creature) { - return GetUlduarAI(creature); } - struct npc_life_sparkAI : public ScriptedAI + void Reset() override { - npc_life_sparkAI(Creature* creature) : ScriptedAI(creature){ } - - void Reset() override - { - DoCastSelf(SPELL_ARCANE_POWER_STATE); - _scheduler.CancelAll(); - } + DoCastSelf(SPELL_ARCANE_POWER_STATE); + _scheduler.CancelAll(); + } - void JustEngagedWith(Unit* /*who*/) override - { - DoCastSelf(SPELL_STATIC_CHARGED); - _scheduler.Schedule(Seconds(12), [this](TaskContext spellShock) + void JustEngagedWith(Unit* /*who*/) override + { + DoCastSelf(SPELL_STATIC_CHARGED); + _scheduler.Schedule(Seconds(12), + [this](TaskContext spellShock) { DoCastVictim(SPELL_SHOCK); spellShock.Repeat(); }); - } + } - void UpdateAI(uint32 diff) override - { - if (!UpdateVictim()) - return; + void UpdateAI(uint32 diff) override + { + if (!UpdateVictim()) + return; - if (me->HasUnitState(UNIT_STATE_CASTING)) - return; + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; - _scheduler.Update(diff, [this] - { - DoMeleeAttackIfReady(); - }); - } + _scheduler.Update(diff, [this] { DoMeleeAttackIfReady(); }); + } - private: - TaskScheduler _scheduler; - }; + private: + TaskScheduler _scheduler; + }; }; class npc_xt_void_zone : public CreatureScript { -public: - npc_xt_void_zone() : CreatureScript("npc_xt_void_zone") { } + public: + npc_xt_void_zone() : CreatureScript("npc_xt_void_zone") + { + } struct npc_xt_void_zoneAI : public PassiveAI { - npc_xt_void_zoneAI(Creature* creature) : PassiveAI(creature) { } + npc_xt_void_zoneAI(Creature* creature) : PassiveAI(creature) + { + } void Reset() override { - _scheduler.Schedule(Seconds(1), [this](TaskContext consumption) - { - DoCastSelf(SPELL_CONSUMPTION); - consumption.Repeat(); - }); + _scheduler.Schedule(Seconds(1), + [this](TaskContext consumption) + { + DoCastSelf(SPELL_CONSUMPTION); + consumption.Repeat(); + }); } void UpdateAI(uint32 diff) override @@ -804,7 +821,7 @@ class npc_xt_void_zone : public CreatureScript _scheduler.Update(diff); } - private: + private: TaskScheduler _scheduler; }; @@ -812,313 +829,331 @@ class npc_xt_void_zone : public CreatureScript { return GetUlduarAI(creature); } - }; class spell_xt002_searing_light_spawn_life_spark : public SpellScriptLoader { - public: - spell_xt002_searing_light_spawn_life_spark() : SpellScriptLoader("spell_xt002_searing_light_spawn_life_spark") { } + public: + spell_xt002_searing_light_spawn_life_spark() : SpellScriptLoader("spell_xt002_searing_light_spawn_life_spark") + { + } - class spell_xt002_searing_light_spawn_life_spark_AuraScript : public AuraScript + class spell_xt002_searing_light_spawn_life_spark_AuraScript : public AuraScript + { + bool Validate(SpellInfo const* /*spell*/) override { - bool Validate(SpellInfo const* /*spell*/) override - { - return ValidateSpellInfo({ SPELL_SUMMON_LIFE_SPARK }); - } - - void OnRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) - { - if (Player* player = GetOwner()->ToPlayer()) - if (Unit* xt002 = GetCaster()) - if (xt002->HasAura(aurEff->GetAmount())) // Heartbreak aura indicating hard mode - xt002->CastSpell(player, SPELL_SUMMON_LIFE_SPARK, true); - } + return ValidateSpellInfo({SPELL_SUMMON_LIFE_SPARK}); + } - void Register() override - { - AfterEffectRemove.Register(&spell_xt002_searing_light_spawn_life_spark_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL, AURA_EFFECT_HANDLE_REAL); - } - }; + void OnRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) + { + if (Player* player = GetOwner()->ToPlayer()) + if (Unit* xt002 = GetCaster()) + if (xt002->HasAura(aurEff->GetAmount())) // Heartbreak aura indicating hard mode + xt002->CastSpell(player, SPELL_SUMMON_LIFE_SPARK, true); + } - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_xt002_searing_light_spawn_life_spark_AuraScript(); + AfterEffectRemove.Register(&spell_xt002_searing_light_spawn_life_spark_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL, AURA_EFFECT_HANDLE_REAL); } + }; + + AuraScript* GetAuraScript() const override + { + return new spell_xt002_searing_light_spawn_life_spark_AuraScript(); + } }; class spell_xt002_gravity_bomb_aura : public SpellScriptLoader { - public: - spell_xt002_gravity_bomb_aura() : SpellScriptLoader("spell_xt002_gravity_bomb_aura") { } + public: + spell_xt002_gravity_bomb_aura() : SpellScriptLoader("spell_xt002_gravity_bomb_aura") + { + } - class spell_xt002_gravity_bomb_aura_AuraScript : public AuraScript + class spell_xt002_gravity_bomb_aura_AuraScript : public AuraScript + { + bool Validate(SpellInfo const* /*spell*/) override { - bool Validate(SpellInfo const* /*spell*/) override - { - return ValidateSpellInfo({ SPELL_SUMMON_VOID_ZONE }); - } - - void OnRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) - { - if (Player* player = GetOwner()->ToPlayer()) - if (Unit* xt002 = GetCaster()) - if (xt002->HasAura(aurEff->GetAmount())) // Heartbreak aura indicating hard mode - xt002->CastSpell(player, SPELL_SUMMON_VOID_ZONE, true); - } + return ValidateSpellInfo({SPELL_SUMMON_VOID_ZONE}); + } - void OnPeriodic(AuraEffect const* aurEff) - { - Unit* xt002 = GetCaster(); - if (!xt002) - return; + void OnRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) + { + if (Player* player = GetOwner()->ToPlayer()) + if (Unit* xt002 = GetCaster()) + if (xt002->HasAura(aurEff->GetAmount())) // Heartbreak aura indicating hard mode + xt002->CastSpell(player, SPELL_SUMMON_VOID_ZONE, true); + } - Unit* owner = GetOwner()->ToUnit(); - if (!owner) - return; + void OnPeriodic(AuraEffect const* aurEff) + { + Unit* xt002 = GetCaster(); + if (!xt002) + return; - if (aurEff->GetAmount() >= int32(owner->GetHealth())) - if (xt002->GetAI()) - xt002->GetAI()->SetData(DATA_GRAVITY_BOMB_CASUALTY, 1); - } + Unit* owner = GetOwner()->ToUnit(); + if (!owner) + return; - void Register() override - { - OnEffectPeriodic.Register(&spell_xt002_gravity_bomb_aura_AuraScript::OnPeriodic, EFFECT_2, SPELL_AURA_PERIODIC_DAMAGE); - AfterEffectRemove.Register(&spell_xt002_gravity_bomb_aura_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL, AURA_EFFECT_HANDLE_REAL); - } - }; + if (aurEff->GetAmount() >= int32(owner->GetHealth())) + if (xt002->GetAI()) + xt002->GetAI()->SetData(DATA_GRAVITY_BOMB_CASUALTY, 1); + } - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_xt002_gravity_bomb_aura_AuraScript(); + OnEffectPeriodic.Register(&spell_xt002_gravity_bomb_aura_AuraScript::OnPeriodic, EFFECT_2, SPELL_AURA_PERIODIC_DAMAGE); + AfterEffectRemove.Register(&spell_xt002_gravity_bomb_aura_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL, AURA_EFFECT_HANDLE_REAL); } + }; + + AuraScript* GetAuraScript() const override + { + return new spell_xt002_gravity_bomb_aura_AuraScript(); + } }; class spell_xt002_gravity_bomb_damage : public SpellScriptLoader { - public: - spell_xt002_gravity_bomb_damage() : SpellScriptLoader("spell_xt002_gravity_bomb_damage") { } + public: + spell_xt002_gravity_bomb_damage() : SpellScriptLoader("spell_xt002_gravity_bomb_damage") + { + } - class spell_xt002_gravity_bomb_damage_SpellScript : public SpellScript + class spell_xt002_gravity_bomb_damage_SpellScript : public SpellScript + { + void HandleScript(SpellEffIndex /*eff*/) { - void HandleScript(SpellEffIndex /*eff*/) - { - Unit* caster = GetCaster(); - if (!caster) - return; + Unit* caster = GetCaster(); + if (!caster) + return; - if (GetHitDamage() >= int32(GetHitUnit()->GetHealth())) - if (caster->GetAI()) - caster->GetAI()->SetData(DATA_GRAVITY_BOMB_CASUALTY, 1); - } - - void Register() override - { - OnEffectHitTarget.Register(&spell_xt002_gravity_bomb_damage_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCHOOL_DAMAGE); - } - }; + if (GetHitDamage() >= int32(GetHitUnit()->GetHealth())) + if (caster->GetAI()) + caster->GetAI()->SetData(DATA_GRAVITY_BOMB_CASUALTY, 1); + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_xt002_gravity_bomb_damage_SpellScript(); + OnEffectHitTarget.Register(&spell_xt002_gravity_bomb_damage_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCHOOL_DAMAGE); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_xt002_gravity_bomb_damage_SpellScript(); + } }; class spell_xt002_heart_overload_periodic : public SpellScriptLoader { - public: - spell_xt002_heart_overload_periodic() : SpellScriptLoader("spell_xt002_heart_overload_periodic") { } + public: + spell_xt002_heart_overload_periodic() : SpellScriptLoader("spell_xt002_heart_overload_periodic") + { + } - class spell_xt002_heart_overload_periodic_SpellScript : public SpellScript + class spell_xt002_heart_overload_periodic_SpellScript : public SpellScript + { + bool Validate(SpellInfo const* /*spell*/) override { - bool Validate(SpellInfo const* /*spell*/) override - { - return ValidateSpellInfo({ SPELL_ENERGY_ORB, SPELL_RECHARGE_BOOMBOT, SPELL_RECHARGE_PUMMELER, SPELL_RECHARGE_SCRAPBOT }); - } + return ValidateSpellInfo({SPELL_ENERGY_ORB, SPELL_RECHARGE_BOOMBOT, SPELL_RECHARGE_PUMMELER, SPELL_RECHARGE_SCRAPBOT}); + } - void HandleScript(SpellEffIndex /*effIndex*/) + void HandleScript(SpellEffIndex /*effIndex*/) + { + if (Unit* caster = GetCaster()) { - if (Unit* caster = GetCaster()) + if (InstanceScript* instance = caster->GetInstanceScript()) { - if (InstanceScript* instance = caster->GetInstanceScript()) + if (Unit* toyPile = ObjectAccessor::GetUnit(*caster, instance->GetGuidData(DATA_TOY_PILE_0 + urand(0, 3)))) { - if (Unit* toyPile = ObjectAccessor::GetUnit(*caster, instance->GetGuidData(DATA_TOY_PILE_0 + urand(0, 3)))) + caster->CastSpell(toyPile, SPELL_ENERGY_ORB, true); + + // This should probably be incorporated in a dummy effect handler, but I've had trouble getting the correct target + // Weighed randomization (approximation) + uint32 const spells[] = {SPELL_RECHARGE_SCRAPBOT, SPELL_RECHARGE_SCRAPBOT, SPELL_RECHARGE_SCRAPBOT, SPELL_RECHARGE_PUMMELER, SPELL_RECHARGE_BOOMBOT}; + + for (uint8 i = 0; i < 5; ++i) { - caster->CastSpell(toyPile, SPELL_ENERGY_ORB, true); - - // This should probably be incorporated in a dummy effect handler, but I've had trouble getting the correct target - // Weighed randomization (approximation) - uint32 const spells[] = { SPELL_RECHARGE_SCRAPBOT, SPELL_RECHARGE_SCRAPBOT, SPELL_RECHARGE_SCRAPBOT, - SPELL_RECHARGE_PUMMELER, SPELL_RECHARGE_BOOMBOT }; - - for (uint8 i = 0; i < 5; ++i) - { - uint8 a = urand(0, 4); - uint32 spellId = spells[a]; - toyPile->CastSpell(toyPile, spellId, instance->GetGuidData(DATA_XT002)); - } + uint8 a = urand(0, 4); + uint32 spellId = spells[a]; + toyPile->CastSpell(toyPile, spellId, instance->GetGuidData(DATA_XT002)); } } - - if (Creature* base = caster->GetVehicleCreatureBase()) - base->AI()->Talk(SAY_SUMMON); } - } - void Register() override - { - OnEffectHit.Register(&spell_xt002_heart_overload_periodic_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_DUMMY); + if (Creature* base = caster->GetVehicleCreatureBase()) + base->AI()->Talk(SAY_SUMMON); } - }; + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_xt002_heart_overload_periodic_SpellScript(); + OnEffectHit.Register(&spell_xt002_heart_overload_periodic_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_DUMMY); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_xt002_heart_overload_periodic_SpellScript(); + } }; class spell_xt002_tympanic_tantrum : public SpellScriptLoader { - public: - spell_xt002_tympanic_tantrum() : SpellScriptLoader("spell_xt002_tympanic_tantrum") { } + public: + spell_xt002_tympanic_tantrum() : SpellScriptLoader("spell_xt002_tympanic_tantrum") + { + } - class spell_xt002_tympanic_tantrum_SpellScript : public SpellScript + class spell_xt002_tympanic_tantrum_SpellScript : public SpellScript + { + void FilterTargets(std::list& targets) { - void FilterTargets(std::list& targets) - { - targets.remove_if(PlayerOrPetCheck()); - } - - void RecalculateDamage() - { - SetHitDamage(GetHitUnit()->CountPctFromMaxHealth(GetHitDamage())); - } + targets.remove_if(PlayerOrPetCheck()); + } - void Register() override - { - OnObjectAreaTargetSelect.Register(&spell_xt002_tympanic_tantrum_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); - OnObjectAreaTargetSelect.Register(&spell_xt002_tympanic_tantrum_SpellScript::FilterTargets, EFFECT_1, TARGET_UNIT_SRC_AREA_ENEMY); - OnHit.Register(&spell_xt002_tympanic_tantrum_SpellScript::RecalculateDamage); - } - }; + void RecalculateDamage() + { + SetHitDamage(GetHitUnit()->CountPctFromMaxHealth(GetHitDamage())); + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_xt002_tympanic_tantrum_SpellScript(); + OnObjectAreaTargetSelect.Register(&spell_xt002_tympanic_tantrum_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); + OnObjectAreaTargetSelect.Register(&spell_xt002_tympanic_tantrum_SpellScript::FilterTargets, EFFECT_1, TARGET_UNIT_SRC_AREA_ENEMY); + OnHit.Register(&spell_xt002_tympanic_tantrum_SpellScript::RecalculateDamage); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_xt002_tympanic_tantrum_SpellScript(); + } }; class spell_xt002_submerged : public SpellScriptLoader { - public: - spell_xt002_submerged() : SpellScriptLoader("spell_xt002_submerged") { } + public: + spell_xt002_submerged() : SpellScriptLoader("spell_xt002_submerged") + { + } - class spell_xt002_submerged_SpellScript : public SpellScript + class spell_xt002_submerged_SpellScript : public SpellScript + { + void HandleScript(SpellEffIndex /*eff*/) { - void HandleScript(SpellEffIndex /*eff*/) - { - Creature* target = GetHitCreature(); - if (!target) - return; - - target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - target->SetStandState(UNIT_STAND_STATE_SUBMERGED); - } + Creature* target = GetHitCreature(); + if (!target) + return; - void Register() override - { - OnEffectHitTarget.Register(&spell_xt002_submerged_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - } - }; + target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + target->SetStandState(UNIT_STAND_STATE_SUBMERGED); + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_xt002_submerged_SpellScript(); + OnEffectHitTarget.Register(&spell_xt002_submerged_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_xt002_submerged_SpellScript(); + } }; class spell_xt002_321_boombot_aura : public SpellScriptLoader { - public: - spell_xt002_321_boombot_aura() : SpellScriptLoader("spell_xt002_321_boombot_aura") { } + public: + spell_xt002_321_boombot_aura() : SpellScriptLoader("spell_xt002_321_boombot_aura") + { + } - class spell_xt002_321_boombot_aura_AuraScript : public AuraScript + class spell_xt002_321_boombot_aura_AuraScript : public AuraScript + { + bool Validate(SpellInfo const* /*spellInfo*/) override { - bool Validate(SpellInfo const* /*spellInfo*/) override - { - return ValidateSpellInfo({ SPELL_ACHIEVEMENT_CREDIT_NERF_SCRAPBOTS }); - } - - bool CheckProc(ProcEventInfo& eventInfo) - { - if (eventInfo.GetActionTarget()->GetEntry() != NPC_XS013_SCRAPBOT) - return false; - return true; - } + return ValidateSpellInfo({SPELL_ACHIEVEMENT_CREDIT_NERF_SCRAPBOTS}); + } - void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo) - { - InstanceScript* instance = eventInfo.GetActor()->GetInstanceScript(); - if (!instance) - return; + bool CheckProc(ProcEventInfo& eventInfo) + { + if (eventInfo.GetActionTarget()->GetEntry() != NPC_XS013_SCRAPBOT) + return false; + return true; + } - instance->DoCastSpellOnPlayers(SPELL_ACHIEVEMENT_CREDIT_NERF_SCRAPBOTS); - } + void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo) + { + InstanceScript* instance = eventInfo.GetActor()->GetInstanceScript(); + if (!instance) + return; - void Register() override - { - DoCheckProc.Register(&spell_xt002_321_boombot_aura_AuraScript::CheckProc); - OnEffectProc.Register(&spell_xt002_321_boombot_aura_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_DUMMY); - } - }; + instance->DoCastSpellOnPlayers(SPELL_ACHIEVEMENT_CREDIT_NERF_SCRAPBOTS); + } - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_xt002_321_boombot_aura_AuraScript(); + DoCheckProc.Register(&spell_xt002_321_boombot_aura_AuraScript::CheckProc); + OnEffectProc.Register(&spell_xt002_321_boombot_aura_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_DUMMY); } + }; + + AuraScript* GetAuraScript() const override + { + return new spell_xt002_321_boombot_aura_AuraScript(); + } }; class achievement_nerf_engineering : public AchievementCriteriaScript { - public: - achievement_nerf_engineering() : AchievementCriteriaScript("achievement_nerf_engineering") { } + public: + achievement_nerf_engineering() : AchievementCriteriaScript("achievement_nerf_engineering") + { + } - bool OnCheck(Player* /*source*/, Unit* target) override - { - if (!target || !target->GetAI()) - return false; + bool OnCheck(Player* /*source*/, Unit* target) override + { + if (!target || !target->GetAI()) + return false; - return !(target->GetAI()->GetData(DATA_HEALTH_RECOVERED)); - } + return !(target->GetAI()->GetData(DATA_HEALTH_RECOVERED)); + } }; class achievement_heartbreaker : public AchievementCriteriaScript { - public: - achievement_heartbreaker() : AchievementCriteriaScript("achievement_heartbreaker") { } + public: + achievement_heartbreaker() : AchievementCriteriaScript("achievement_heartbreaker") + { + } - bool OnCheck(Player* /*source*/, Unit* target) override - { - if (!target || !target->GetAI()) - return false; + bool OnCheck(Player* /*source*/, Unit* target) override + { + if (!target || !target->GetAI()) + return false; - return target->GetAI()->GetData(DATA_HARD_MODE) != 0; - } + return target->GetAI()->GetData(DATA_HARD_MODE) != 0; + } }; class achievement_nerf_gravity_bombs : public AchievementCriteriaScript { - public: - achievement_nerf_gravity_bombs() : AchievementCriteriaScript("achievement_nerf_gravity_bombs") { } + public: + achievement_nerf_gravity_bombs() : AchievementCriteriaScript("achievement_nerf_gravity_bombs") + { + } - bool OnCheck(Player* /*source*/, Unit* target) override - { - if (!target || !target->GetAI()) - return false; + bool OnCheck(Player* /*source*/, Unit* target) override + { + if (!target || !target->GetAI()) + return false; - return !(target->GetAI()->GetData(DATA_GRAVITY_BOMB_CASUALTY)); - } + return !(target->GetAI()->GetData(DATA_GRAVITY_BOMB_CASUALTY)); + } }; void AddSC_boss_xt002() diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_yogg_saron.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_yogg_saron.cpp index f9ac9a72..fa8a8792 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_yogg_saron.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_yogg_saron.cpp @@ -15,7 +15,6 @@ * with this program. If not, see . */ -#include "ScriptMgr.h" #include "CreatureTextMgr.h" #include "GridNotifiers.h" #include "InstanceScript.h" @@ -25,6 +24,7 @@ #include "ObjectAccessor.h" #include "PassiveAI.h" #include "Player.h" +#include "ScriptMgr.h" #include "ScriptedCreature.h" #include "Spell.h" #include "SpellAuraEffects.h" @@ -36,3050 +36,3190 @@ enum Yells { // Sara - SAY_SARA_ULDUAR_SCREAM_1 = 0, // screams randomly in a whole instance, unused on retail - SAY_SARA_ULDUAR_SCREAM_2 = 1, // screams randomly in a whole instance, unused on retail - SAY_SARA_AGGRO = 2, - SAY_SARA_FERVOR_HIT = 3, - SAY_SARA_BLESSING_HIT = 4, - SAY_SARA_KILL = 5, - SAY_SARA_TRANSFORM_1 = 6, - SAY_SARA_TRANSFORM_2 = 7, - SAY_SARA_TRANSFORM_3 = 8, - SAY_SARA_TRANSFORM_4 = 9, - SAY_SARA_DEATH_RAY = 10, - SAY_SARA_PSYCHOSIS_HIT = 11, + SAY_SARA_ULDUAR_SCREAM_1 = 0, // screams randomly in a whole instance, unused on retail + SAY_SARA_ULDUAR_SCREAM_2 = 1, // screams randomly in a whole instance, unused on retail + SAY_SARA_AGGRO = 2, + SAY_SARA_FERVOR_HIT = 3, + SAY_SARA_BLESSING_HIT = 4, + SAY_SARA_KILL = 5, + SAY_SARA_TRANSFORM_1 = 6, + SAY_SARA_TRANSFORM_2 = 7, + SAY_SARA_TRANSFORM_3 = 8, + SAY_SARA_TRANSFORM_4 = 9, + SAY_SARA_DEATH_RAY = 10, + SAY_SARA_PSYCHOSIS_HIT = 11, // Yogg-Saron - SAY_YOGG_SARON_SPAWN = 0, - SAY_YOGG_SARON_MADNESS = 1, - EMOTE_YOGG_SARON_MADNESS = 2, - SAY_YOGG_SARON_PHASE_3 = 3, - SAY_YOGG_SARON_DEAFENING_ROAR = 4, - EMOTE_YOGG_SARON_DEAFENING_ROAR = 5, - SAY_YOGG_SARON_DEATH = 6, - EMOTE_YOGG_SARON_EMPOWERING_SHADOWS = 7, - EMOTE_YOGG_SARON_EXTINGUISH_ALL_LIFE = 8, + SAY_YOGG_SARON_SPAWN = 0, + SAY_YOGG_SARON_MADNESS = 1, + EMOTE_YOGG_SARON_MADNESS = 2, + SAY_YOGG_SARON_PHASE_3 = 3, + SAY_YOGG_SARON_DEAFENING_ROAR = 4, + EMOTE_YOGG_SARON_DEAFENING_ROAR = 5, + SAY_YOGG_SARON_DEATH = 6, + EMOTE_YOGG_SARON_EMPOWERING_SHADOWS = 7, + EMOTE_YOGG_SARON_EXTINGUISH_ALL_LIFE = 8, // Voice of Yogg-Saron - WHISPER_VOICE_PHASE_1_WIPE = 0, - WHISPER_VOICE_INSANE = 1, + WHISPER_VOICE_PHASE_1_WIPE = 0, + WHISPER_VOICE_INSANE = 1, // Brain of Yogg-Saron - EMOTE_BRAIN_ILLUSION_SHATTERED = 0, + EMOTE_BRAIN_ILLUSION_SHATTERED = 0, // Ominous Cloud - EMOTE_OMINOUS_CLOUD_PLAYER_TOUCH = 0, + EMOTE_OMINOUS_CLOUD_PLAYER_TOUCH = 0, // Keepers - SAY_KEEPER_CHOSEN_1 = 0, - SAY_KEEPER_CHOSEN_2 = 1, + SAY_KEEPER_CHOSEN_1 = 0, + SAY_KEEPER_CHOSEN_2 = 1, // Yogg-Saron illusions - SAY_STORMWIND_ROLEPLAY_4 = 0, - SAY_STORMWIND_ROLEPLAY_7 = 1, - SAY_ICECROWN_ROLEPLAY_5 = 2, - SAY_ICECROWN_ROLEPLAY_6 = 3, - SAY_CHAMBER_ROLEPLAY_5 = 4, + SAY_STORMWIND_ROLEPLAY_4 = 0, + SAY_STORMWIND_ROLEPLAY_7 = 1, + SAY_ICECROWN_ROLEPLAY_5 = 2, + SAY_ICECROWN_ROLEPLAY_6 = 3, + SAY_CHAMBER_ROLEPLAY_5 = 4, // Neltharion - SAY_CHAMBER_ROLEPLAY_1 = 0, - SAY_CHAMBER_ROLEPLAY_3 = 1, + SAY_CHAMBER_ROLEPLAY_1 = 0, + SAY_CHAMBER_ROLEPLAY_3 = 1, // Ysera - SAY_CHAMBER_ROLEPLAY_2 = 0, + SAY_CHAMBER_ROLEPLAY_2 = 0, // Malygos - SAY_CHAMBER_ROLEPLAY_4 = 0, + SAY_CHAMBER_ROLEPLAY_4 = 0, // Immolated Champion - SAY_ICECROWN_ROLEPLAY_1 = 0, - SAY_ICECROWN_ROLEPLAY_3 = 1, + SAY_ICECROWN_ROLEPLAY_1 = 0, + SAY_ICECROWN_ROLEPLAY_3 = 1, // The Lich King - SAY_ICECROWN_ROLEPLAY_2 = 0, - SAY_ICECROWN_ROLEPLAY_4 = 1, + SAY_ICECROWN_ROLEPLAY_2 = 0, + SAY_ICECROWN_ROLEPLAY_4 = 1, // Garona - SAY_STORMWIND_ROLEPLAY_1 = 0, - SAY_STORMWIND_ROLEPLAY_2 = 1, - SAY_STORMWIND_ROLEPLAY_3 = 2, - SAY_STORMWIND_ROLEPLAY_6 = 3, + SAY_STORMWIND_ROLEPLAY_1 = 0, + SAY_STORMWIND_ROLEPLAY_2 = 1, + SAY_STORMWIND_ROLEPLAY_3 = 2, + SAY_STORMWIND_ROLEPLAY_6 = 3, // King Llane - SAY_STORMWIND_ROLEPLAY_5 = 0, + SAY_STORMWIND_ROLEPLAY_5 = 0, }; enum Spells { // Voice of Yogg-Saron - SPELL_SUMMON_GUARDIAN_2 = 62978, - SPELL_SANITY_PERIODIC = 63786, - SPELL_SANITY = 63050, - SPELL_INSANE_PERIODIC = 64554, - SPELL_INSANE = 63120, - //SPELL_CLEAR_INSANE = 63122, // when should it be cast? - SPELL_CONSTRICTOR_TENTACLE = 64132, - SPELL_CRUSHER_TENTACLE_SUMMON = 64139, - SPELL_CORRUPTOR_TENTACLE_SUMMON = 64143, - SPELL_IMMORTAL_GUARDIAN = 64158, + SPELL_SUMMON_GUARDIAN_2 = 62978, + SPELL_SANITY_PERIODIC = 63786, + SPELL_SANITY = 63050, + SPELL_INSANE_PERIODIC = 64554, + SPELL_INSANE = 63120, + // SPELL_CLEAR_INSANE = 63122, // when should it be cast? + SPELL_CONSTRICTOR_TENTACLE = 64132, + SPELL_CRUSHER_TENTACLE_SUMMON = 64139, + SPELL_CORRUPTOR_TENTACLE_SUMMON = 64143, + SPELL_IMMORTAL_GUARDIAN = 64158, // Sara - SPELL_SARAS_FERVOR = 63138, - SPELL_SARAS_FERVOR_TARGET_SELECTOR = 63747, - SPELL_SARAS_BLESSING = 63134, - SPELL_SARAS_BLESSING_TARGET_SELECTOR = 63745, - SPELL_SARAS_ANGER = 63147, - SPELL_SARAS_ANGER_TARGET_SELECTOR = 63744, - SPELL_FULL_HEAL = 43978, - SPELL_PHASE_2_TRANSFORM = 65157, - SPELL_SHADOWY_BARRIER_SARA = 64775, - SPELL_RIDE_YOGG_SARON_VEHICLE = 61791, - SPELL_PSYCHOSIS = 63795, - SPELL_MALADY_OF_THE_MIND = 63830, - SPELL_BRAIN_LINK = 63802, - SPELL_BRAIN_LINK_DAMAGE = 63803, // red beam - SPELL_BRAIN_LINK_NO_DAMAGE = 63804, // yellow beam - SPELL_DEATH_RAY = 63891, + SPELL_SARAS_FERVOR = 63138, + SPELL_SARAS_FERVOR_TARGET_SELECTOR = 63747, + SPELL_SARAS_BLESSING = 63134, + SPELL_SARAS_BLESSING_TARGET_SELECTOR = 63745, + SPELL_SARAS_ANGER = 63147, + SPELL_SARAS_ANGER_TARGET_SELECTOR = 63744, + SPELL_FULL_HEAL = 43978, + SPELL_PHASE_2_TRANSFORM = 65157, + SPELL_SHADOWY_BARRIER_SARA = 64775, + SPELL_RIDE_YOGG_SARON_VEHICLE = 61791, + SPELL_PSYCHOSIS = 63795, + SPELL_MALADY_OF_THE_MIND = 63830, + SPELL_BRAIN_LINK = 63802, + SPELL_BRAIN_LINK_DAMAGE = 63803, // red beam + SPELL_BRAIN_LINK_NO_DAMAGE = 63804, // yellow beam + SPELL_DEATH_RAY = 63891, // Ominous Cloud - SPELL_OMINOUS_CLOUD_VISUAL = 63084, - SPELL_SUMMON_GUARDIAN_1 = 63031, + SPELL_OMINOUS_CLOUD_VISUAL = 63084, + SPELL_SUMMON_GUARDIAN_1 = 63031, // Guardian of Yogg-Saron - SPELL_DARK_VOLLEY = 63038, - SPELL_SHADOW_NOVA = 62714, - SPELL_SHADOW_NOVA_2 = 65719, + SPELL_DARK_VOLLEY = 63038, + SPELL_SHADOW_NOVA = 62714, + SPELL_SHADOW_NOVA_2 = 65719, // Yogg-Saron - SPELL_EXTINGUISH_ALL_LIFE = 64166, - SPELL_SHADOWY_BARRIER_YOGG = 63894, - SPELL_KNOCK_AWAY = 64022, - SPELL_PHASE_3_TRANSFORM = 63895, - SPELL_DEAFENING_ROAR = 64189, - SPELL_LUNATIC_GAZE = 64163, - SPELL_LUNATIC_GAZE_DAMAGE = 64164, - SPELL_SHADOW_BEACON = 64465, + SPELL_EXTINGUISH_ALL_LIFE = 64166, + SPELL_SHADOWY_BARRIER_YOGG = 63894, + SPELL_KNOCK_AWAY = 64022, + SPELL_PHASE_3_TRANSFORM = 63895, + SPELL_DEAFENING_ROAR = 64189, + SPELL_LUNATIC_GAZE = 64163, + SPELL_LUNATIC_GAZE_DAMAGE = 64164, + SPELL_SHADOW_BEACON = 64465, // Brain of Yogg-Saron - SPELL_MATCH_HEALTH = 64066, - SPELL_MATCH_HEALTH_2 = 64069, - SPELL_INDUCE_MADNESS = 64059, - SPELL_BRAIN_HURT_VISUAL = 64361, - SPELL_SHATTERED_ILLUSION = 64173, - SPELL_SHATTERED_ILLUSION_REMOVE = 65238, + SPELL_MATCH_HEALTH = 64066, + SPELL_MATCH_HEALTH_2 = 64069, + SPELL_INDUCE_MADNESS = 64059, + SPELL_BRAIN_HURT_VISUAL = 64361, + SPELL_SHATTERED_ILLUSION = 64173, + SPELL_SHATTERED_ILLUSION_REMOVE = 65238, // Tentacles - SPELL_ERUPT = 64144, - SPELL_TENTACLE_VOID_ZONE = 64017, // used by Corruptor Tentacle and Crusher Tentacle only + SPELL_ERUPT = 64144, + SPELL_TENTACLE_VOID_ZONE = 64017, // used by Corruptor Tentacle and Crusher Tentacle only // Crusher Tentacle - SPELL_DIMINISH_POWER = 64145, - SPELL_DIMINSH_POWER = 64148, - SPELL_FOCUSED_ANGER = 57688, - SPELL_CRUSH = 64146, - //SPELL_CRUSH_2 = 65201, // triggered by SPELL_CRUSH, basepoints of SPELL_MALADY_OF_THE_MIND + SPELL_DIMINISH_POWER = 64145, + SPELL_DIMINSH_POWER = 64148, + SPELL_FOCUSED_ANGER = 57688, + SPELL_CRUSH = 64146, + // SPELL_CRUSH_2 = 65201, // triggered by SPELL_CRUSH, basepoints of SPELL_MALADY_OF_THE_MIND // Constrictor Tentacle - SPELL_TENTACLE_VOID_ZONE_2 = 64384, - SPELL_LUNGE = 64131, + SPELL_TENTACLE_VOID_ZONE_2 = 64384, + SPELL_LUNGE = 64131, // Corruptor Tentacle - SPELL_APATHY = 64156, - SPELL_BLACK_PLAGUE = 64153, - SPELL_CURSE_OF_DOOM = 64157, - SPELL_DRAINING_POISON = 64152, + SPELL_APATHY = 64156, + SPELL_BLACK_PLAGUE = 64153, + SPELL_CURSE_OF_DOOM = 64157, + SPELL_DRAINING_POISON = 64152, // Immortal Guardian - SPELL_EMPOWERING_SHADOWS = 64468, - SPELL_EMPOWERED = 64161, - SPELL_EMPOWERED_BUFF = 65294, - SPELL_WEAKENED = 64162, - SPELL_DRAIN_LIFE = 64159, - SPELL_RECENTLY_SPAWNED = 64497, - SPELL_SIMPLE_TELEPORT = 64195, + SPELL_EMPOWERING_SHADOWS = 64468, + SPELL_EMPOWERED = 64161, + SPELL_EMPOWERED_BUFF = 65294, + SPELL_WEAKENED = 64162, + SPELL_DRAIN_LIFE = 64159, + SPELL_RECENTLY_SPAWNED = 64497, + SPELL_SIMPLE_TELEPORT = 64195, // Keepers at Observation Ring - SPELL_TELEPORT = 62940, + SPELL_TELEPORT = 62940, // Keepers - SPELL_SIMPLE_TELEPORT_KEEPERS = 12980, - SPELL_KEEPER_ACTIVE = 62647, + SPELL_SIMPLE_TELEPORT_KEEPERS = 12980, + SPELL_KEEPER_ACTIVE = 62647, // Mimiron - SPELL_SPEED_OF_INVENTION = 62671, - SPELL_DESTABILIZATION_MATRIX = 65206, + SPELL_SPEED_OF_INVENTION = 62671, + SPELL_DESTABILIZATION_MATRIX = 65206, // Freya - SPELL_RESILIENCE_OF_NATURE = 62670, - SPELL_SANITY_WELL_SUMMON = 64170, + SPELL_RESILIENCE_OF_NATURE = 62670, + SPELL_SANITY_WELL_SUMMON = 64170, // Sanity Well - SPELL_SANITY_WELL_VISUAL = 63288, - SPELL_SANITY_WELL = 64169, + SPELL_SANITY_WELL_VISUAL = 63288, + SPELL_SANITY_WELL = 64169, // Thorim - SPELL_FURY_OF_THE_STORM = 62702, - SPELL_TITANIC_STORM = 64171, + SPELL_FURY_OF_THE_STORM = 62702, + SPELL_TITANIC_STORM = 64171, // Hodir - SPELL_FORTITUDE_OF_FROST = 62650, - SPELL_HODIRS_PROTECTIVE_GAZE = 64174, - SPELL_FLASH_FREEZE_VISUAL = 64176, + SPELL_FORTITUDE_OF_FROST = 62650, + SPELL_HODIRS_PROTECTIVE_GAZE = 64174, + SPELL_FLASH_FREEZE_VISUAL = 64176, // Death Orb - SPELL_DEATH_RAY_ORIGIN_VISUAL = 63893, + SPELL_DEATH_RAY_ORIGIN_VISUAL = 63893, // Death Ray - SPELL_DEATH_RAY_WARNING_VISUAL = 63882, - SPELL_DEATH_RAY_PERIODIC = 63883, - SPELL_DEATH_RAY_DAMAGE_VISUAL = 63886, + SPELL_DEATH_RAY_WARNING_VISUAL = 63882, + SPELL_DEATH_RAY_PERIODIC = 63883, + SPELL_DEATH_RAY_DAMAGE_VISUAL = 63886, // Laughing Skull - SPELL_LUNATIC_GAZE_SKULL = 64167, + SPELL_LUNATIC_GAZE_SKULL = 64167, // Descend Into Madness - SPELL_TELEPORT_PORTAL_VISUAL = 64416, - SPELL_TELEPORT_TO_STORMWIND_ILLUSION = 63989, - SPELL_TELEPORT_TO_CHAMBER_ILLUSION = 63997, - SPELL_TELEPORT_TO_ICECROWN_ILLUSION = 63998, + SPELL_TELEPORT_PORTAL_VISUAL = 64416, + SPELL_TELEPORT_TO_STORMWIND_ILLUSION = 63989, + SPELL_TELEPORT_TO_CHAMBER_ILLUSION = 63997, + SPELL_TELEPORT_TO_ICECROWN_ILLUSION = 63998, // Illusions - SPELL_GRIM_REPRISAL = 63305, - SPELL_GRIM_REPRISAL_DAMAGE = 64039, + SPELL_GRIM_REPRISAL = 63305, + SPELL_GRIM_REPRISAL_DAMAGE = 64039, // Suit of Armor - SPELL_NONDESCRIPT_1 = 64013, + SPELL_NONDESCRIPT_1 = 64013, // Dragon Consorts & Deathsworn Zealot - SPELL_NONDESCRIPT_2 = 64010, + SPELL_NONDESCRIPT_2 = 64010, // Garona - SPELL_ASSASSINATE = 64063, + SPELL_ASSASSINATE = 64063, // King Llane - SPELL_PERMANENT_FEIGN_DEATH = 29266, + SPELL_PERMANENT_FEIGN_DEATH = 29266, // The Lich King - SPELL_DEATHGRASP = 63037, + SPELL_DEATHGRASP = 63037, // Turned Champion - SPELL_VERTEX_COLOR_BLACK = 39662, + SPELL_VERTEX_COLOR_BLACK = 39662, // Player self cast spells - SPELL_MALADY_OF_THE_MIND_JUMP = 63881, - SPELL_ILLUSION_ROOM = 63988, - SPELL_HATE_TO_ZERO = 63984, - SPELL_TELEPORT_BACK_TO_MAIN_ROOM = 63992, - SPELL_INSANE_VISUAL = 64464, - SPELL_CONSTRICTOR_TENTACLE_SUMMON = 64133, - SPELL_SQUEEZE = 64125, - SPELL_FLASH_FREEZE = 64175, - SPELL_LOW_SANITY_SCREEN_EFFECT = 63752, + SPELL_MALADY_OF_THE_MIND_JUMP = 63881, + SPELL_ILLUSION_ROOM = 63988, + SPELL_HATE_TO_ZERO = 63984, + SPELL_TELEPORT_BACK_TO_MAIN_ROOM = 63992, + SPELL_INSANE_VISUAL = 64464, + SPELL_CONSTRICTOR_TENTACLE_SUMMON = 64133, + SPELL_SQUEEZE = 64125, + SPELL_FLASH_FREEZE = 64175, + SPELL_LOW_SANITY_SCREEN_EFFECT = 63752, - SPELL_IN_THE_MAWS_OF_THE_OLD_GOD = 64184, + SPELL_IN_THE_MAWS_OF_THE_OLD_GOD = 64184, }; enum Phases { - PHASE_ONE = 1, - PHASE_TRANSFORM = 2, - PHASE_TWO = 3, - PHASE_THREE = 4, + PHASE_ONE = 1, + PHASE_TRANSFORM = 2, + PHASE_TWO = 3, + PHASE_THREE = 4, }; enum Events { // Voice of Yogg-Saron - EVENT_LOCK_DOOR = 1, - EVENT_SUMMON_GUARDIAN_OF_YOGG_SARON = 2, - EVENT_SUMMON_CORRUPTOR_TENTACLE = 3, - EVENT_SUMMON_CONSTRICTOR_TENTACLE = 4, - EVENT_SUMMON_CRUSHER_TENTACLE = 5, - EVENT_ILLUSION = 6, - EVENT_SUMMON_IMMORTAL_GUARDIAN = 7, - EVENT_EXTINGUISH_ALL_LIFE = 8, // handled by Voice, timer starts at the beginning of the fight (Yogg-Saron is not spawned at this moment) + EVENT_LOCK_DOOR = 1, + EVENT_SUMMON_GUARDIAN_OF_YOGG_SARON = 2, + EVENT_SUMMON_CORRUPTOR_TENTACLE = 3, + EVENT_SUMMON_CONSTRICTOR_TENTACLE = 4, + EVENT_SUMMON_CRUSHER_TENTACLE = 5, + EVENT_ILLUSION = 6, + EVENT_SUMMON_IMMORTAL_GUARDIAN = 7, + EVENT_EXTINGUISH_ALL_LIFE = 8, // handled by Voice, timer starts at the beginning of the fight (Yogg-Saron is not spawned at this moment) // Sara - EVENT_SARAS_FERVOR = 9, - EVENT_SARAS_BLESSING = 10, - EVENT_SARAS_ANGER = 11, - EVENT_TRANSFORM_1 = 12, - EVENT_TRANSFORM_2 = 13, - EVENT_TRANSFORM_3 = 14, - EVENT_TRANSFORM_4 = 15, - EVENT_PSYCHOSIS = 16, - EVENT_MALADY_OF_THE_MIND = 17, - EVENT_BRAIN_LINK = 18, - EVENT_DEATH_RAY = 19, + EVENT_SARAS_FERVOR = 9, + EVENT_SARAS_BLESSING = 10, + EVENT_SARAS_ANGER = 11, + EVENT_TRANSFORM_1 = 12, + EVENT_TRANSFORM_2 = 13, + EVENT_TRANSFORM_3 = 14, + EVENT_TRANSFORM_4 = 15, + EVENT_PSYCHOSIS = 16, + EVENT_MALADY_OF_THE_MIND = 17, + EVENT_BRAIN_LINK = 18, + EVENT_DEATH_RAY = 19, // Tentacles - EVENT_DIMINISH_POWER = 20, - EVENT_CAST_RANDOM_SPELL = 21, + EVENT_DIMINISH_POWER = 20, + EVENT_CAST_RANDOM_SPELL = 21, // Yogg-Saron - EVENT_YELL_BOW_DOWN = 22, - EVENT_SHADOW_BEACON = 23, - EVENT_LUNATIC_GAZE = 24, - EVENT_DEAFENING_ROAR = 25, // only on 25-man with 0-3 keepers active (Hard Mode) + EVENT_YELL_BOW_DOWN = 22, + EVENT_SHADOW_BEACON = 23, + EVENT_LUNATIC_GAZE = 24, + EVENT_DEAFENING_ROAR = 25, // only on 25-man with 0-3 keepers active (Hard Mode) // Guardian of Yogg-Saron - EVENT_DARK_VOLLEY = 26, + EVENT_DARK_VOLLEY = 26, // Immortal Guardian - EVENT_DRAIN_LIFE = 27, + EVENT_DRAIN_LIFE = 27, // Keepers - EVENT_DESTABILIZATION_MATRIX = 28, - EVENT_HODIRS_PROTECTIVE_GAZE = 29, + EVENT_DESTABILIZATION_MATRIX = 28, + EVENT_HODIRS_PROTECTIVE_GAZE = 29, // Chamber Illusion - EVENT_CHAMBER_ROLEPLAY_1 = 30, - EVENT_CHAMBER_ROLEPLAY_2 = 31, - EVENT_CHAMBER_ROLEPLAY_3 = 32, - EVENT_CHAMBER_ROLEPLAY_4 = 33, - EVENT_CHAMBER_ROLEPLAY_5 = 34, + EVENT_CHAMBER_ROLEPLAY_1 = 30, + EVENT_CHAMBER_ROLEPLAY_2 = 31, + EVENT_CHAMBER_ROLEPLAY_3 = 32, + EVENT_CHAMBER_ROLEPLAY_4 = 33, + EVENT_CHAMBER_ROLEPLAY_5 = 34, // Icecrown Illusion - EVENT_ICECROWN_ROLEPLAY_1 = 35, - EVENT_ICECROWN_ROLEPLAY_2 = 36, - EVENT_ICECROWN_ROLEPLAY_3 = 37, - EVENT_ICECROWN_ROLEPLAY_4 = 38, - EVENT_ICECROWN_ROLEPLAY_5 = 39, - EVENT_ICECROWN_ROLEPLAY_6 = 40, + EVENT_ICECROWN_ROLEPLAY_1 = 35, + EVENT_ICECROWN_ROLEPLAY_2 = 36, + EVENT_ICECROWN_ROLEPLAY_3 = 37, + EVENT_ICECROWN_ROLEPLAY_4 = 38, + EVENT_ICECROWN_ROLEPLAY_5 = 39, + EVENT_ICECROWN_ROLEPLAY_6 = 40, // Stormwind Illusion - EVENT_STORMWIND_ROLEPLAY_1 = 41, - EVENT_STORMWIND_ROLEPLAY_2 = 42, - EVENT_STORMWIND_ROLEPLAY_3 = 43, - EVENT_STORMWIND_ROLEPLAY_4 = 44, - EVENT_STORMWIND_ROLEPLAY_5 = 45, - EVENT_STORMWIND_ROLEPLAY_6 = 46, - EVENT_STORMWIND_ROLEPLAY_7 = 47, + EVENT_STORMWIND_ROLEPLAY_1 = 41, + EVENT_STORMWIND_ROLEPLAY_2 = 42, + EVENT_STORMWIND_ROLEPLAY_3 = 43, + EVENT_STORMWIND_ROLEPLAY_4 = 44, + EVENT_STORMWIND_ROLEPLAY_5 = 45, + EVENT_STORMWIND_ROLEPLAY_6 = 46, + EVENT_STORMWIND_ROLEPLAY_7 = 47, }; enum EventGroups { - EVENT_GROUP_SUMMON_TENTACLES = 1, + EVENT_GROUP_SUMMON_TENTACLES = 1, }; enum Actions { - ACTION_PHASE_TRANSFORM = 0, - ACTION_PHASE_TWO = 1, - ACTION_PHASE_THREE = 2, - ACTION_INDUCE_MADNESS = 3, - ACTION_SANITY_WELLS = 4, - ACTION_FLASH_FREEZE = 5, - ACTION_TENTACLE_KILLED = 6, - ACTION_START_ROLEPLAY = 8, - ACTION_TOGGLE_SHATTERED_ILLUSION = 9, + ACTION_PHASE_TRANSFORM = 0, + ACTION_PHASE_TWO = 1, + ACTION_PHASE_THREE = 2, + ACTION_INDUCE_MADNESS = 3, + ACTION_SANITY_WELLS = 4, + ACTION_FLASH_FREEZE = 5, + ACTION_TENTACLE_KILLED = 6, + ACTION_START_ROLEPLAY = 8, + ACTION_TOGGLE_SHATTERED_ILLUSION = 9, }; enum CreatureGroups { - CREATURE_GROUP_CLOUDS = 0, - CREATURE_GROUP_PORTALS_10 = 1, - CREATURE_GROUP_PORTALS_25 = 2, + CREATURE_GROUP_CLOUDS = 0, + CREATURE_GROUP_PORTALS_10 = 1, + CREATURE_GROUP_PORTALS_25 = 2, }; -Position const YoggSaronSpawnPos = {1980.43f, -25.7708f, 324.9724f, 3.141593f}; -Position const ObservationRingKeepersPos[4] = -{ - {1945.682f, 33.34201f, 411.4408f, 5.270895f}, // Freya - {1945.761f, -81.52171f, 411.4407f, 1.029744f}, // Hodir - {2028.822f, -65.73573f, 411.4426f, 2.460914f}, // Thorim - {2028.766f, 17.42014f, 411.4446f, 3.857178f}, // Mimiron +Position const YoggSaronSpawnPos = {1980.43f, -25.7708f, 324.9724f, 3.141593f}; +Position const ObservationRingKeepersPos[4] = { + {1945.682f, 33.34201f, 411.4408f, 5.270895f}, // Freya + {1945.761f, -81.52171f, 411.4407f, 1.029744f}, // Hodir + {2028.822f, -65.73573f, 411.4426f, 2.460914f}, // Thorim + {2028.766f, 17.42014f, 411.4446f, 3.857178f}, // Mimiron }; -Position const YSKeepersPos[4] = -{ - {2036.873f, 25.42513f, 338.4984f, 3.909538f}, // Freya - {1939.045f, -90.87457f, 338.5426f, 0.994837f}, // Hodir - {1939.148f, 42.49035f, 338.5427f, 5.235988f}, // Thorim - {2036.658f, -73.58822f, 338.4985f, 2.460914f}, // Mimiron +Position const YSKeepersPos[4] = { + {2036.873f, 25.42513f, 338.4984f, 3.909538f}, // Freya + {1939.045f, -90.87457f, 338.5426f, 0.994837f}, // Hodir + {1939.148f, 42.49035f, 338.5427f, 5.235988f}, // Thorim + {2036.658f, -73.58822f, 338.4985f, 2.460914f}, // Mimiron }; -Position const IllusionsMiscPos[2] = -{ - {1928.793f, 65.03109f, 242.3763f, 0.0f}, // Garona end position +Position const IllusionsMiscPos[2] = { + {1928.793f, 65.03109f, 242.3763f, 0.0f}, // Garona end position {1912.324f, -155.7967f, 239.9896f, 0.0f}, // Saurfang end position }; enum MiscData { - ACHIEV_TIMED_START_EVENT = 21001, - SOUND_LUNATIC_GAZE = 15757, - MAX_ILLUSION_ROOMS = 3 + ACHIEV_TIMED_START_EVENT = 21001, + SOUND_LUNATIC_GAZE = 15757, + MAX_ILLUSION_ROOMS = 3 }; -uint32 const IllusionSpells[MAX_ILLUSION_ROOMS] -{ - SPELL_TELEPORT_TO_CHAMBER_ILLUSION, - SPELL_TELEPORT_TO_ICECROWN_ILLUSION, - SPELL_TELEPORT_TO_STORMWIND_ILLUSION -}; +uint32 const IllusionSpells[MAX_ILLUSION_ROOMS]{SPELL_TELEPORT_TO_CHAMBER_ILLUSION, SPELL_TELEPORT_TO_ICECROWN_ILLUSION, SPELL_TELEPORT_TO_STORMWIND_ILLUSION}; class StartAttackEvent : public BasicEvent { - public: - StartAttackEvent(Creature* summoner, Creature* owner) - : _summonerGuid(summoner->GetGUID()), _owner(owner) - { - } + public: + StartAttackEvent(Creature* summoner, Creature* owner) : _summonerGuid(summoner->GetGUID()), _owner(owner) + { + } - bool Execute(uint64 /*time*/, uint32 /*diff*/) override - { - _owner->SetReactState(REACT_AGGRESSIVE); - if (Creature* _summoner = ObjectAccessor::GetCreature(*_owner, _summonerGuid)) - if (Unit* target = _summoner->AI()->SelectTarget(SELECT_TARGET_RANDOM, 0, 300.0f)) - _owner->AI()->AttackStart(target); - return true; - } + bool Execute(uint64 /*time*/, uint32 /*diff*/) override + { + _owner->SetReactState(REACT_AGGRESSIVE); + if (Creature* _summoner = ObjectAccessor::GetCreature(*_owner, _summonerGuid)) + if (Unit* target = _summoner->AI()->SelectTarget(SELECT_TARGET_RANDOM, 0, 300.0f)) + _owner->AI()->AttackStart(target); + return true; + } - private: - ObjectGuid _summonerGuid; - Creature* _owner; + private: + ObjectGuid _summonerGuid; + Creature* _owner; }; class boss_voice_of_yogg_saron : public CreatureScript { - public: - boss_voice_of_yogg_saron() : CreatureScript("boss_voice_of_yogg_saron") { } + public: + boss_voice_of_yogg_saron() : CreatureScript("boss_voice_of_yogg_saron") + { + } - struct boss_voice_of_yogg_saronAI : public BossAI + struct boss_voice_of_yogg_saronAI : public BossAI + { + boss_voice_of_yogg_saronAI(Creature* creature) : BossAI(creature, DATA_YOGG_SARON) { - boss_voice_of_yogg_saronAI(Creature* creature) : BossAI(creature, DATA_YOGG_SARON) - { - Initialize(); - SetCombatMovement(false); - } + Initialize(); + SetCombatMovement(false); + } - void Initialize() - { - _guardiansCount = 0; - _guardianTimer = 20000; - _illusionShattered = false; - } + void Initialize() + { + _guardiansCount = 0; + _guardianTimer = 20000; + _illusionShattered = false; + } - void MoveInLineOfSight(Unit* who) override - { - // TODO: MoveInLineOfSight doesn't work for such a big distance - if (who->GetTypeId() == TYPEID_PLAYER && !who->ToPlayer()->IsGameMaster() && me->GetDistance2d(who) < 99.0f && !me->IsInCombat()) - me->SetInCombatWithZone(); - } + void MoveInLineOfSight(Unit* who) override + { + // TODO: MoveInLineOfSight doesn't work for such a big distance + if (who->GetTypeId() == TYPEID_PLAYER && !who->ToPlayer()->IsGameMaster() && me->GetDistance2d(who) < 99.0f && !me->IsInCombat()) + me->SetInCombatWithZone(); + } - void EnterEvadeMode(EvadeReason why) override - { - BossAI::EnterEvadeMode(why); + void EnterEvadeMode(EvadeReason why) override + { + BossAI::EnterEvadeMode(why); - for (uint8 i = DATA_SARA; i <= DATA_MIMIRON_YS; ++i) - if (Creature* creature = ObjectAccessor::GetCreature(*me, instance->GetGuidData(i))) - creature->AI()->EnterEvadeMode(); + for (uint8 i = DATA_SARA; i <= DATA_MIMIRON_YS; ++i) + if (Creature* creature = ObjectAccessor::GetCreature(*me, instance->GetGuidData(i))) + creature->AI()->EnterEvadeMode(); - // not sure, spoken by Sara (sound), regarding to wowwiki Voice whispers it - Map::PlayerList const& players = me->GetMap()->GetPlayers(); - for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr) - if (Player* player = itr->GetSource()) - { - if (events.IsInPhase(PHASE_ONE)) - Talk(WHISPER_VOICE_PHASE_1_WIPE, player); + // not sure, spoken by Sara (sound), regarding to wowwiki Voice whispers it + Map::PlayerList const& players = me->GetMap()->GetPlayers(); + for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr) + if (Player* player = itr->GetSource()) + { + if (events.IsInPhase(PHASE_ONE)) + Talk(WHISPER_VOICE_PHASE_1_WIPE, player); - player->RemoveAurasDueToSpell(SPELL_SANITY); - player->RemoveAurasDueToSpell(SPELL_INSANE); - } - } + player->RemoveAurasDueToSpell(SPELL_SANITY); + player->RemoveAurasDueToSpell(SPELL_INSANE); + } + } - void Reset() override - { - _Reset(); - events.SetPhase(PHASE_ONE); + void Reset() override + { + _Reset(); + events.SetPhase(PHASE_ONE); - instance->SetData(DATA_DRIVE_ME_CRAZY, uint32(true)); - instance->DoStopTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_TIMED_START_EVENT); + instance->SetData(DATA_DRIVE_ME_CRAZY, uint32(true)); + instance->DoStopTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_TIMED_START_EVENT); - Initialize(); + Initialize(); - bool clockwise = false; - std::list clouds; - me->SummonCreatureGroup(CREATURE_GROUP_CLOUDS, &clouds); - clouds.sort(Firelands::ObjectDistanceOrderPred(me, true)); - for (std::list::const_iterator itr = clouds.begin(); itr != clouds.end(); ++itr) - { - (*itr)->AI()->DoAction(int32(clockwise)); - clockwise = !clockwise; - } + bool clockwise = false; + std::list clouds; + me->SummonCreatureGroup(CREATURE_GROUP_CLOUDS, &clouds); + clouds.sort(Firelands::ObjectDistanceOrderPred(me, true)); + for (std::list::const_iterator itr = clouds.begin(); itr != clouds.end(); ++itr) + { + (*itr)->AI()->DoAction(int32(clockwise)); + clockwise = !clockwise; } + } - void JustEngagedWith(Unit* /*who*/) override - { - if (Creature* sara = instance->GetCreature(DATA_SARA)) - sara->SetInCombatWith(me); + void JustEngagedWith(Unit* /*who*/) override + { + if (Creature* sara = instance->GetCreature(DATA_SARA)) + sara->SetInCombatWith(me); - for (uint8 i = DATA_FREYA_YS; i <= DATA_MIMIRON_YS; ++i) - if (Creature* keeper = ObjectAccessor::GetCreature(*me, instance->GetGuidData(i))) - keeper->SetInCombatWith(me); + for (uint8 i = DATA_FREYA_YS; i <= DATA_MIMIRON_YS; ++i) + if (Creature* keeper = ObjectAccessor::GetCreature(*me, instance->GetGuidData(i))) + keeper->SetInCombatWith(me); - instance->DoStartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_TIMED_START_EVENT); + instance->DoStartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_TIMED_START_EVENT); - DoCastAOE(SPELL_SUMMON_GUARDIAN_2, { SPELLVALUE_MAX_TARGETS, 1 }); - DoCast(me, SPELL_SANITY_PERIODIC); + DoCastAOE(SPELL_SUMMON_GUARDIAN_2, {SPELLVALUE_MAX_TARGETS, 1}); + DoCast(me, SPELL_SANITY_PERIODIC); - events.ScheduleEvent(EVENT_LOCK_DOOR, 15000); - events.ScheduleEvent(EVENT_SUMMON_GUARDIAN_OF_YOGG_SARON, _guardianTimer, 0, PHASE_ONE); - events.ScheduleEvent(EVENT_EXTINGUISH_ALL_LIFE, 900000); // 15 minutes - } + events.ScheduleEvent(EVENT_LOCK_DOOR, 15000); + events.ScheduleEvent(EVENT_SUMMON_GUARDIAN_OF_YOGG_SARON, _guardianTimer, 0, PHASE_ONE); + events.ScheduleEvent(EVENT_EXTINGUISH_ALL_LIFE, 900000); // 15 minutes + } - void JustDied(Unit* /*killer*/) override - { - // don't despawn Yogg-Saron's corpse, remove him from SummonList! - if (Creature* yogg = instance->GetCreature(DATA_YOGG_SARON)) - summons.Despawn(yogg); + void JustDied(Unit* /*killer*/) override + { + // don't despawn Yogg-Saron's corpse, remove him from SummonList! + if (Creature* yogg = instance->GetCreature(DATA_YOGG_SARON)) + summons.Despawn(yogg); - _JustDied(); - } + _JustDied(); + } - void UpdateAI(uint32 diff) override - { - if (!UpdateVictim()) - return; + void UpdateAI(uint32 diff) override + { + if (!UpdateVictim()) + return; - events.Update(diff); - // don't summon tentacles when illusion is shattered, delay them - if (_illusionShattered) - events.DelayEvents(diff, EVENT_GROUP_SUMMON_TENTACLES); + events.Update(diff); + // don't summon tentacles when illusion is shattered, delay them + if (_illusionShattered) + events.DelayEvents(diff, EVENT_GROUP_SUMMON_TENTACLES); - while (uint32 eventId = events.ExecuteEvent()) + while (uint32 eventId = events.ExecuteEvent()) + { + switch (eventId) { - switch (eventId) + case EVENT_LOCK_DOOR: + DoCast(me, SPELL_INSANE_PERIODIC); + instance->SetBossState(DATA_YOGG_SARON, IN_PROGRESS); + break; + case EVENT_EXTINGUISH_ALL_LIFE: + if (Creature* yogg = instance->GetCreature(DATA_YOGG_SARON)) { - case EVENT_LOCK_DOOR: - DoCast(me, SPELL_INSANE_PERIODIC); - instance->SetBossState(DATA_YOGG_SARON, IN_PROGRESS); - break; - case EVENT_EXTINGUISH_ALL_LIFE: - if (Creature* yogg = instance->GetCreature(DATA_YOGG_SARON)) - { - yogg->AI()->Talk(EMOTE_YOGG_SARON_EXTINGUISH_ALL_LIFE, me); - yogg->CastSpell((Unit*)nullptr, SPELL_EXTINGUISH_ALL_LIFE, true); - } - events.ScheduleEvent(EVENT_EXTINGUISH_ALL_LIFE, 10000); // cast it again after a short while, players can survive - break; - case EVENT_SUMMON_GUARDIAN_OF_YOGG_SARON: - DoCastAOE(SPELL_SUMMON_GUARDIAN_2, { SPELLVALUE_MAX_TARGETS, 1 }); - ++_guardiansCount; - if (_guardiansCount <= 6 && _guardiansCount % 3 == 0) - _guardianTimer -= 5000; - events.ScheduleEvent(EVENT_SUMMON_GUARDIAN_OF_YOGG_SARON, _guardianTimer, 0, PHASE_ONE); - break; - case EVENT_SUMMON_CORRUPTOR_TENTACLE: - DoCastAOE(SPELL_CORRUPTOR_TENTACLE_SUMMON); - events.ScheduleEvent(EVENT_SUMMON_CORRUPTOR_TENTACLE, 30000, EVENT_GROUP_SUMMON_TENTACLES, PHASE_TWO); - break; - case EVENT_SUMMON_CONSTRICTOR_TENTACLE: - DoCastAOE(SPELL_CONSTRICTOR_TENTACLE, { SPELLVALUE_MAX_TARGETS, 1 }); - events.ScheduleEvent(EVENT_SUMMON_CONSTRICTOR_TENTACLE, 25000, EVENT_GROUP_SUMMON_TENTACLES, PHASE_TWO); - break; - case EVENT_SUMMON_CRUSHER_TENTACLE: - DoCastAOE(SPELL_CRUSHER_TENTACLE_SUMMON); - events.ScheduleEvent(EVENT_SUMMON_CRUSHER_TENTACLE, 60000, EVENT_GROUP_SUMMON_TENTACLES, PHASE_TWO); - break; - case EVENT_ILLUSION: - { - if (Creature* yogg = instance->GetCreature(DATA_YOGG_SARON)) - { - yogg->AI()->Talk(EMOTE_YOGG_SARON_MADNESS); - yogg->AI()->Talk(SAY_YOGG_SARON_MADNESS); - } - - me->SummonCreatureGroup(CREATURE_GROUP_PORTALS_10); - if (me->GetMap()->Is25ManRaid()) - me->SummonCreatureGroup(CREATURE_GROUP_PORTALS_25); - - uint8 illusion = urand(CHAMBER_ILLUSION, STORMWIND_ILLUSION); - instance->SetData(DATA_ILLUSION, illusion); - - if (Creature* brain = instance->GetCreature(DATA_BRAIN_OF_YOGG_SARON)) - brain->AI()->DoAction(ACTION_INDUCE_MADNESS); - events.ScheduleEvent(EVENT_ILLUSION, 80000, 0, PHASE_TWO); // wowwiki says 80 secs, wowhead says something about 90 secs - break; - } - case EVENT_SUMMON_IMMORTAL_GUARDIAN: - DoCastAOE(SPELL_IMMORTAL_GUARDIAN); - events.ScheduleEvent(EVENT_SUMMON_IMMORTAL_GUARDIAN, 15000, 0, PHASE_THREE); - break; - default: - break; + yogg->AI()->Talk(EMOTE_YOGG_SARON_EXTINGUISH_ALL_LIFE, me); + yogg->CastSpell((Unit*)nullptr, SPELL_EXTINGUISH_ALL_LIFE, true); } - } - } - - void DoAction(int32 action) override - { - switch (action) + events.ScheduleEvent(EVENT_EXTINGUISH_ALL_LIFE, 10000); // cast it again after a short while, players can survive + break; + case EVENT_SUMMON_GUARDIAN_OF_YOGG_SARON: + DoCastAOE(SPELL_SUMMON_GUARDIAN_2, {SPELLVALUE_MAX_TARGETS, 1}); + ++_guardiansCount; + if (_guardiansCount <= 6 && _guardiansCount % 3 == 0) + _guardianTimer -= 5000; + events.ScheduleEvent(EVENT_SUMMON_GUARDIAN_OF_YOGG_SARON, _guardianTimer, 0, PHASE_ONE); + break; + case EVENT_SUMMON_CORRUPTOR_TENTACLE: + DoCastAOE(SPELL_CORRUPTOR_TENTACLE_SUMMON); + events.ScheduleEvent(EVENT_SUMMON_CORRUPTOR_TENTACLE, 30000, EVENT_GROUP_SUMMON_TENTACLES, PHASE_TWO); + break; + case EVENT_SUMMON_CONSTRICTOR_TENTACLE: + DoCastAOE(SPELL_CONSTRICTOR_TENTACLE, {SPELLVALUE_MAX_TARGETS, 1}); + events.ScheduleEvent(EVENT_SUMMON_CONSTRICTOR_TENTACLE, 25000, EVENT_GROUP_SUMMON_TENTACLES, PHASE_TWO); + break; + case EVENT_SUMMON_CRUSHER_TENTACLE: + DoCastAOE(SPELL_CRUSHER_TENTACLE_SUMMON); + events.ScheduleEvent(EVENT_SUMMON_CRUSHER_TENTACLE, 60000, EVENT_GROUP_SUMMON_TENTACLES, PHASE_TWO); + break; + case EVENT_ILLUSION: { - case ACTION_PHASE_TRANSFORM: - events.SetPhase(PHASE_TRANSFORM); - summons.DespawnEntry(NPC_OMINOUS_CLOUD); - break; - case ACTION_PHASE_TWO: - events.SetPhase(PHASE_TWO); - me->SummonCreature(NPC_YOGG_SARON, YoggSaronSpawnPos); - if (Creature* brain = instance->GetCreature(DATA_BRAIN_OF_YOGG_SARON)) - brain->SetInCombatWithZone(); - events.ScheduleEvent(EVENT_SUMMON_CORRUPTOR_TENTACLE, 5s, EVENT_GROUP_SUMMON_TENTACLES, PHASE_TWO); - events.ScheduleEvent(EVENT_SUMMON_CONSTRICTOR_TENTACLE, 7s, EVENT_GROUP_SUMMON_TENTACLES, PHASE_TWO); - events.ScheduleEvent(EVENT_SUMMON_CRUSHER_TENTACLE, 5s, EVENT_GROUP_SUMMON_TENTACLES, PHASE_TWO); - events.ScheduleEvent(EVENT_ILLUSION, 60000, 0, PHASE_TWO); - break; - case ACTION_TOGGLE_SHATTERED_ILLUSION: - _illusionShattered = !_illusionShattered; - break; - case ACTION_PHASE_THREE: - events.SetPhase(PHASE_THREE); - events.ScheduleEvent(EVENT_SUMMON_IMMORTAL_GUARDIAN, 1000, 0, PHASE_THREE); - break; - default: - break; - } - } + if (Creature* yogg = instance->GetCreature(DATA_YOGG_SARON)) + { + yogg->AI()->Talk(EMOTE_YOGG_SARON_MADNESS); + yogg->AI()->Talk(SAY_YOGG_SARON_MADNESS); + } - void JustSummoned(Creature* summon) override - { - switch (summon->GetEntry()) - { - case NPC_GUARDIAN_OF_YOGG_SARON: - summon->m_Events.AddEvent(new StartAttackEvent(me, summon), summon->m_Events.CalculateTime(1000)); - break; - case NPC_YOGG_SARON: - summon->HandleEmoteCommand(EMOTE_ONESHOT_EMERGE); - break; - case NPC_CONSTRICTOR_TENTACLE: - summon->CastSpell(summon, SPELL_LUNGE, true); - break; - case NPC_CRUSHER_TENTACLE: - case NPC_CORRUPTOR_TENTACLE: - summon->SetReactState(REACT_PASSIVE); - summon->HandleEmoteCommand(EMOTE_ONESHOT_EMERGE); - summon->m_Events.AddEvent(new StartAttackEvent(me, summon), summon->m_Events.CalculateTime(5000)); - break; - case NPC_DESCEND_INTO_MADNESS: - summon->CastSpell(summon, SPELL_TELEPORT_PORTAL_VISUAL, true); - break; - case NPC_IMMORTAL_GUARDIAN: - summon->CastSpell(summon, SPELL_SIMPLE_TELEPORT, true); - break; - } + me->SummonCreatureGroup(CREATURE_GROUP_PORTALS_10); + if (me->GetMap()->Is25ManRaid()) + me->SummonCreatureGroup(CREATURE_GROUP_PORTALS_25); + + uint8 illusion = urand(CHAMBER_ILLUSION, STORMWIND_ILLUSION); + instance->SetData(DATA_ILLUSION, illusion); - BossAI::JustSummoned(summon); + if (Creature* brain = instance->GetCreature(DATA_BRAIN_OF_YOGG_SARON)) + brain->AI()->DoAction(ACTION_INDUCE_MADNESS); + events.ScheduleEvent(EVENT_ILLUSION, 80000, 0, PHASE_TWO); // wowwiki says 80 secs, wowhead says something about 90 secs + break; + } + case EVENT_SUMMON_IMMORTAL_GUARDIAN: + DoCastAOE(SPELL_IMMORTAL_GUARDIAN); + events.ScheduleEvent(EVENT_SUMMON_IMMORTAL_GUARDIAN, 15000, 0, PHASE_THREE); + break; + default: + break; + } } + } - private: - uint8 _guardiansCount; - uint32 _guardianTimer; - bool _illusionShattered; - }; + void DoAction(int32 action) override + { + switch (action) + { + case ACTION_PHASE_TRANSFORM: + events.SetPhase(PHASE_TRANSFORM); + summons.DespawnEntry(NPC_OMINOUS_CLOUD); + break; + case ACTION_PHASE_TWO: + events.SetPhase(PHASE_TWO); + me->SummonCreature(NPC_YOGG_SARON, YoggSaronSpawnPos); + if (Creature* brain = instance->GetCreature(DATA_BRAIN_OF_YOGG_SARON)) + brain->SetInCombatWithZone(); + events.ScheduleEvent(EVENT_SUMMON_CORRUPTOR_TENTACLE, 5s, EVENT_GROUP_SUMMON_TENTACLES, PHASE_TWO); + events.ScheduleEvent(EVENT_SUMMON_CONSTRICTOR_TENTACLE, 7s, EVENT_GROUP_SUMMON_TENTACLES, PHASE_TWO); + events.ScheduleEvent(EVENT_SUMMON_CRUSHER_TENTACLE, 5s, EVENT_GROUP_SUMMON_TENTACLES, PHASE_TWO); + events.ScheduleEvent(EVENT_ILLUSION, 60000, 0, PHASE_TWO); + break; + case ACTION_TOGGLE_SHATTERED_ILLUSION: + _illusionShattered = !_illusionShattered; + break; + case ACTION_PHASE_THREE: + events.SetPhase(PHASE_THREE); + events.ScheduleEvent(EVENT_SUMMON_IMMORTAL_GUARDIAN, 1000, 0, PHASE_THREE); + break; + default: + break; + } + } - CreatureAI* GetAI(Creature* creature) const override - { - return GetUlduarAI(creature); + void JustSummoned(Creature* summon) override + { + switch (summon->GetEntry()) + { + case NPC_GUARDIAN_OF_YOGG_SARON: + summon->m_Events.AddEvent(new StartAttackEvent(me, summon), summon->m_Events.CalculateTime(1000)); + break; + case NPC_YOGG_SARON: + summon->HandleEmoteCommand(EMOTE_ONESHOT_EMERGE); + break; + case NPC_CONSTRICTOR_TENTACLE: + summon->CastSpell(summon, SPELL_LUNGE, true); + break; + case NPC_CRUSHER_TENTACLE: + case NPC_CORRUPTOR_TENTACLE: + summon->SetReactState(REACT_PASSIVE); + summon->HandleEmoteCommand(EMOTE_ONESHOT_EMERGE); + summon->m_Events.AddEvent(new StartAttackEvent(me, summon), summon->m_Events.CalculateTime(5000)); + break; + case NPC_DESCEND_INTO_MADNESS: + summon->CastSpell(summon, SPELL_TELEPORT_PORTAL_VISUAL, true); + break; + case NPC_IMMORTAL_GUARDIAN: + summon->CastSpell(summon, SPELL_SIMPLE_TELEPORT, true); + break; + } + + BossAI::JustSummoned(summon); } + + private: + uint8 _guardiansCount; + uint32 _guardianTimer; + bool _illusionShattered; + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return GetUlduarAI(creature); + } }; class boss_sara : public CreatureScript { - public: - boss_sara() : CreatureScript("boss_sara") { } + public: + boss_sara() : CreatureScript("boss_sara") + { + } - struct boss_saraAI : public ScriptedAI + struct boss_saraAI : public ScriptedAI + { + boss_saraAI(Creature* creature) : ScriptedAI(creature), _instance(creature->GetInstanceScript()) { - boss_saraAI(Creature* creature) : ScriptedAI(creature), _instance(creature->GetInstanceScript()) { } - - ObjectGuid GetLinkedPlayerGUID(ObjectGuid guid) const - { - std::map::const_iterator itr = _linkData.find(guid); - if (itr != _linkData.end()) - return itr->second; - - return ObjectGuid::Empty; - } + } - void SetLinkBetween(ObjectGuid player1, ObjectGuid player2) - { - _linkData[player1] = player2; - _linkData[player2] = player1; - } + ObjectGuid GetLinkedPlayerGUID(ObjectGuid guid) const + { + std::map::const_iterator itr = _linkData.find(guid); + if (itr != _linkData.end()) + return itr->second; - // called once for each target on aura remove - void RemoveLinkFrom(ObjectGuid player1) - { - _linkData.erase(player1); - } + return ObjectGuid::Empty; + } - void DamageTaken(Unit* /*attacker*/, uint32& damage) override - { - if (damage >= me->GetHealth()) - { - damage = me->GetHealth() - 1; + void SetLinkBetween(ObjectGuid player1, ObjectGuid player2) + { + _linkData[player1] = player2; + _linkData[player2] = player1; + } - if (_events.IsInPhase(PHASE_ONE)) - { - if (Creature* voice = _instance->GetCreature(DATA_VOICE_OF_YOGG_SARON)) - voice->AI()->DoAction(ACTION_PHASE_TRANSFORM); - - Talk(SAY_SARA_TRANSFORM_1); - _events.SetPhase(PHASE_TRANSFORM); - _events.ScheduleEvent(EVENT_TRANSFORM_1, 4700, 0, PHASE_TRANSFORM); - _events.ScheduleEvent(EVENT_TRANSFORM_2, 9500, 0, PHASE_TRANSFORM); - _events.ScheduleEvent(EVENT_TRANSFORM_3, 14300, 0, PHASE_TRANSFORM); - _events.ScheduleEvent(EVENT_TRANSFORM_4, 14500, 0, PHASE_TRANSFORM); - } - } - } + // called once for each target on aura remove + void RemoveLinkFrom(ObjectGuid player1) + { + _linkData.erase(player1); + } - void SpellHitTarget(Unit* /*target*/, SpellInfo const* spell) override + void DamageTaken(Unit* /*attacker*/, uint32& damage) override + { + if (damage >= me->GetHealth()) { - if (!roll_chance_i(30) || _events.IsInPhase(PHASE_TRANSFORM)) - return; + damage = me->GetHealth() - 1; - switch (spell->Id) + if (_events.IsInPhase(PHASE_ONE)) { - case SPELL_SARAS_FERVOR: - Talk(SAY_SARA_FERVOR_HIT); - break; - case SPELL_SARAS_BLESSING: - Talk(SAY_SARA_BLESSING_HIT); - break; - case SPELL_PSYCHOSIS: - Talk(SAY_SARA_PSYCHOSIS_HIT); - break; - default: - break; + if (Creature* voice = _instance->GetCreature(DATA_VOICE_OF_YOGG_SARON)) + voice->AI()->DoAction(ACTION_PHASE_TRANSFORM); + + Talk(SAY_SARA_TRANSFORM_1); + _events.SetPhase(PHASE_TRANSFORM); + _events.ScheduleEvent(EVENT_TRANSFORM_1, 4700, 0, PHASE_TRANSFORM); + _events.ScheduleEvent(EVENT_TRANSFORM_2, 9500, 0, PHASE_TRANSFORM); + _events.ScheduleEvent(EVENT_TRANSFORM_3, 14300, 0, PHASE_TRANSFORM); + _events.ScheduleEvent(EVENT_TRANSFORM_4, 14500, 0, PHASE_TRANSFORM); } } + } - void KilledUnit(Unit* victim) override - { - if (victim->GetTypeId() == TYPEID_PLAYER && !me->IsInEvadeMode()) - Talk(SAY_SARA_KILL); - } + void SpellHitTarget(Unit* /*target*/, SpellInfo const* spell) override + { + if (!roll_chance_i(30) || _events.IsInPhase(PHASE_TRANSFORM)) + return; - void JustEngagedWith(Unit* /*who*/) override + switch (spell->Id) { - Talk(SAY_SARA_AGGRO); - _events.ScheduleEvent(EVENT_SARAS_FERVOR, 5000, 0, PHASE_ONE); - _events.ScheduleEvent(EVENT_SARAS_BLESSING, urand(10000, 30000), 0, PHASE_ONE); - _events.ScheduleEvent(EVENT_SARAS_ANGER, urand(15000, 25000), 0, PHASE_ONE); + case SPELL_SARAS_FERVOR: + Talk(SAY_SARA_FERVOR_HIT); + break; + case SPELL_SARAS_BLESSING: + Talk(SAY_SARA_BLESSING_HIT); + break; + case SPELL_PSYCHOSIS: + Talk(SAY_SARA_PSYCHOSIS_HIT); + break; + default: + break; } + } - void Reset() override - { - me->RemoveAllAuras(); - me->SetReactState(REACT_PASSIVE); - me->SetFaction(FACTION_FRIENDLY); - _events.Reset(); - _events.SetPhase(PHASE_ONE); - } + void KilledUnit(Unit* victim) override + { + if (victim->GetTypeId() == TYPEID_PLAYER && !me->IsInEvadeMode()) + Talk(SAY_SARA_KILL); + } - void UpdateAI(uint32 diff) override - { - if (!me->IsInCombat()) - return; + void JustEngagedWith(Unit* /*who*/) override + { + Talk(SAY_SARA_AGGRO); + _events.ScheduleEvent(EVENT_SARAS_FERVOR, 5000, 0, PHASE_ONE); + _events.ScheduleEvent(EVENT_SARAS_BLESSING, urand(10000, 30000), 0, PHASE_ONE); + _events.ScheduleEvent(EVENT_SARAS_ANGER, urand(15000, 25000), 0, PHASE_ONE); + } + + void Reset() override + { + me->RemoveAllAuras(); + me->SetReactState(REACT_PASSIVE); + me->SetFaction(FACTION_FRIENDLY); + _events.Reset(); + _events.SetPhase(PHASE_ONE); + } - if (me->HasAura(SPELL_SHATTERED_ILLUSION)) - return; + void UpdateAI(uint32 diff) override + { + if (!me->IsInCombat()) + return; - _events.Update(diff); + if (me->HasAura(SPELL_SHATTERED_ILLUSION)) + return; - if (me->HasUnitState(UNIT_STATE_CASTING)) - return; + _events.Update(diff); - while (uint32 eventId = _events.ExecuteEvent()) - { - switch (eventId) - { - case EVENT_SARAS_FERVOR: - DoCastAOE(SPELL_SARAS_FERVOR_TARGET_SELECTOR, { SPELLVALUE_MAX_TARGETS, 1 }); - _events.ScheduleEvent(EVENT_SARAS_FERVOR, 6000, 0, PHASE_ONE); - break; - case EVENT_SARAS_ANGER: - DoCastAOE(SPELL_SARAS_ANGER_TARGET_SELECTOR, { SPELLVALUE_MAX_TARGETS, 1 }); - _events.ScheduleEvent(EVENT_SARAS_ANGER, urand(6000, 8000), 0, PHASE_ONE); - break; - case EVENT_SARAS_BLESSING: - DoCastAOE(SPELL_SARAS_BLESSING_TARGET_SELECTOR, { SPELLVALUE_MAX_TARGETS, 1 }); - _events.ScheduleEvent(EVENT_SARAS_BLESSING, urand(6000, 30000), 0, PHASE_ONE); - break; - case EVENT_TRANSFORM_1: - Talk(SAY_SARA_TRANSFORM_2); - break; - case EVENT_TRANSFORM_2: - Talk(SAY_SARA_TRANSFORM_3); - break; - case EVENT_TRANSFORM_3: - Talk(SAY_SARA_TRANSFORM_4); - DoCast(me, SPELL_FULL_HEAL); - me->SetFaction(FACTION_MONSTER_2); - if (Creature* voice = _instance->GetCreature(DATA_VOICE_OF_YOGG_SARON)) - voice->AI()->DoAction(ACTION_PHASE_TWO); - if (Creature* mimiron = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_MIMIRON_YS))) - mimiron->AI()->DoAction(ACTION_PHASE_TWO); - break; - case EVENT_TRANSFORM_4: - DoCast(me, SPELL_PHASE_2_TRANSFORM); - if (Creature* yogg = _instance->GetCreature(DATA_YOGG_SARON)) - DoCast(yogg, SPELL_RIDE_YOGG_SARON_VEHICLE); - DoCast(me, SPELL_SHADOWY_BARRIER_SARA); - _events.SetPhase(PHASE_TWO); - _events.ScheduleEvent(EVENT_DEATH_RAY, 20000, 0, PHASE_TWO); // almost never cast at scheduled time, why? - _events.ScheduleEvent(EVENT_MALADY_OF_THE_MIND, 18000, 0, PHASE_TWO); - _events.ScheduleEvent(EVENT_PSYCHOSIS, 1, 0, PHASE_TWO); - _events.ScheduleEvent(EVENT_BRAIN_LINK, 23000, 0, PHASE_TWO); - break; - case EVENT_DEATH_RAY: - DoCast(me, SPELL_DEATH_RAY); - _events.ScheduleEvent(EVENT_DEATH_RAY, 21000, 0, PHASE_TWO); - break; - case EVENT_MALADY_OF_THE_MIND: - DoCastAOE(SPELL_MALADY_OF_THE_MIND, { SPELLVALUE_MAX_TARGETS, 1 }); - _events.ScheduleEvent(EVENT_MALADY_OF_THE_MIND, urand(18000, 25000), 0, PHASE_TWO); - break; - case EVENT_PSYCHOSIS: - DoCastAOE(SPELL_PSYCHOSIS, { SPELLVALUE_MAX_TARGETS, 1 }); - _events.ScheduleEvent(EVENT_PSYCHOSIS, 4000, 0, PHASE_TWO); - break; - case EVENT_BRAIN_LINK: - DoCastAOE(SPELL_BRAIN_LINK, { SPELLVALUE_MAX_TARGETS, 2 }); - _events.ScheduleEvent(EVENT_BRAIN_LINK, urand(23000, 26000), 0, PHASE_TWO); - break; - default: - break; - } - } - } + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; - void JustSummoned(Creature* summon) override + while (uint32 eventId = _events.ExecuteEvent()) { - summon->SetReactState(REACT_PASSIVE); - - switch (summon->GetEntry()) + switch (eventId) { - case NPC_DEATH_ORB: - Talk(SAY_SARA_DEATH_RAY); - summon->CastSpell(summon, SPELL_DEATH_RAY_ORIGIN_VISUAL); - for (uint8 i = 0; i < 4; ++i) - { - Position pos; - float radius = frand(25.0f, 50.0f); - float angle = frand(0.0f, 2.0f * float(M_PI)); - pos.m_positionX = YoggSaronSpawnPos.GetPositionX() + radius * cosf(angle); - pos.m_positionY = YoggSaronSpawnPos.GetPositionY() + radius * sinf(angle); - pos.m_positionZ = me->GetMap()->GetHeight(me->GetPhaseShift(), pos.GetPositionX(), pos.GetPositionY(), YoggSaronSpawnPos.GetPositionZ() + 5.0f); - me->SummonCreature(NPC_DEATH_RAY, pos, TEMPSUMMON_TIMED_DESPAWN, 20000); - } - break; - case NPC_DEATH_RAY: - summon->CastSpell(summon, SPELL_DEATH_RAY_WARNING_VISUAL); - break; + case EVENT_SARAS_FERVOR: + DoCastAOE(SPELL_SARAS_FERVOR_TARGET_SELECTOR, {SPELLVALUE_MAX_TARGETS, 1}); + _events.ScheduleEvent(EVENT_SARAS_FERVOR, 6000, 0, PHASE_ONE); + break; + case EVENT_SARAS_ANGER: + DoCastAOE(SPELL_SARAS_ANGER_TARGET_SELECTOR, {SPELLVALUE_MAX_TARGETS, 1}); + _events.ScheduleEvent(EVENT_SARAS_ANGER, urand(6000, 8000), 0, PHASE_ONE); + break; + case EVENT_SARAS_BLESSING: + DoCastAOE(SPELL_SARAS_BLESSING_TARGET_SELECTOR, {SPELLVALUE_MAX_TARGETS, 1}); + _events.ScheduleEvent(EVENT_SARAS_BLESSING, urand(6000, 30000), 0, PHASE_ONE); + break; + case EVENT_TRANSFORM_1: + Talk(SAY_SARA_TRANSFORM_2); + break; + case EVENT_TRANSFORM_2: + Talk(SAY_SARA_TRANSFORM_3); + break; + case EVENT_TRANSFORM_3: + Talk(SAY_SARA_TRANSFORM_4); + DoCast(me, SPELL_FULL_HEAL); + me->SetFaction(FACTION_MONSTER_2); + if (Creature* voice = _instance->GetCreature(DATA_VOICE_OF_YOGG_SARON)) + voice->AI()->DoAction(ACTION_PHASE_TWO); + if (Creature* mimiron = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_MIMIRON_YS))) + mimiron->AI()->DoAction(ACTION_PHASE_TWO); + break; + case EVENT_TRANSFORM_4: + DoCast(me, SPELL_PHASE_2_TRANSFORM); + if (Creature* yogg = _instance->GetCreature(DATA_YOGG_SARON)) + DoCast(yogg, SPELL_RIDE_YOGG_SARON_VEHICLE); + DoCast(me, SPELL_SHADOWY_BARRIER_SARA); + _events.SetPhase(PHASE_TWO); + _events.ScheduleEvent(EVENT_DEATH_RAY, 20000, 0, PHASE_TWO); // almost never cast at scheduled time, why? + _events.ScheduleEvent(EVENT_MALADY_OF_THE_MIND, 18000, 0, PHASE_TWO); + _events.ScheduleEvent(EVENT_PSYCHOSIS, 1, 0, PHASE_TWO); + _events.ScheduleEvent(EVENT_BRAIN_LINK, 23000, 0, PHASE_TWO); + break; + case EVENT_DEATH_RAY: + DoCast(me, SPELL_DEATH_RAY); + _events.ScheduleEvent(EVENT_DEATH_RAY, 21000, 0, PHASE_TWO); + break; + case EVENT_MALADY_OF_THE_MIND: + DoCastAOE(SPELL_MALADY_OF_THE_MIND, {SPELLVALUE_MAX_TARGETS, 1}); + _events.ScheduleEvent(EVENT_MALADY_OF_THE_MIND, urand(18000, 25000), 0, PHASE_TWO); + break; + case EVENT_PSYCHOSIS: + DoCastAOE(SPELL_PSYCHOSIS, {SPELLVALUE_MAX_TARGETS, 1}); + _events.ScheduleEvent(EVENT_PSYCHOSIS, 4000, 0, PHASE_TWO); + break; + case EVENT_BRAIN_LINK: + DoCastAOE(SPELL_BRAIN_LINK, {SPELLVALUE_MAX_TARGETS, 2}); + _events.ScheduleEvent(EVENT_BRAIN_LINK, urand(23000, 26000), 0, PHASE_TWO); + break; + default: + break; } - - if (Creature* voice = _instance->GetCreature(DATA_VOICE_OF_YOGG_SARON)) - voice->AI()->JustSummoned(summon); } + } + + void JustSummoned(Creature* summon) override + { + summon->SetReactState(REACT_PASSIVE); - void DoAction(int32 action) override + switch (summon->GetEntry()) { - switch (action) + case NPC_DEATH_ORB: + Talk(SAY_SARA_DEATH_RAY); + summon->CastSpell(summon, SPELL_DEATH_RAY_ORIGIN_VISUAL); + for (uint8 i = 0; i < 4; ++i) { - case ACTION_PHASE_THREE: // Sara does nothing in phase 3 - _events.SetPhase(PHASE_THREE); - break; - default: - break; + Position pos; + float radius = frand(25.0f, 50.0f); + float angle = frand(0.0f, 2.0f * float(M_PI)); + pos.m_positionX = YoggSaronSpawnPos.GetPositionX() + radius * cosf(angle); + pos.m_positionY = YoggSaronSpawnPos.GetPositionY() + radius * sinf(angle); + pos.m_positionZ = me->GetMap()->GetHeight(me->GetPhaseShift(), pos.GetPositionX(), pos.GetPositionY(), YoggSaronSpawnPos.GetPositionZ() + 5.0f); + me->SummonCreature(NPC_DEATH_RAY, pos, TEMPSUMMON_TIMED_DESPAWN, 20000); } + break; + case NPC_DEATH_RAY: + summon->CastSpell(summon, SPELL_DEATH_RAY_WARNING_VISUAL); + break; } - private: - EventMap _events; - InstanceScript* _instance; - std::map _linkData; - }; + if (Creature* voice = _instance->GetCreature(DATA_VOICE_OF_YOGG_SARON)) + voice->AI()->JustSummoned(summon); + } - CreatureAI* GetAI(Creature* creature) const override + void DoAction(int32 action) override { - return GetUlduarAI(creature); + switch (action) + { + case ACTION_PHASE_THREE: // Sara does nothing in phase 3 + _events.SetPhase(PHASE_THREE); + break; + default: + break; + } } + + private: + EventMap _events; + InstanceScript* _instance; + std::map _linkData; + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return GetUlduarAI(creature); + } }; class boss_yogg_saron : public CreatureScript { - public: - boss_yogg_saron() : CreatureScript("boss_yogg_saron") { } + public: + boss_yogg_saron() : CreatureScript("boss_yogg_saron") + { + } - struct boss_yogg_saronAI : public PassiveAI + struct boss_yogg_saronAI : public PassiveAI + { + boss_yogg_saronAI(Creature* creature) : PassiveAI(creature), _instance(creature->GetInstanceScript()) { - boss_yogg_saronAI(Creature* creature) : PassiveAI(creature), _instance(creature->GetInstanceScript()) { } + } - void Reset() override - { - _events.Reset(); - _events.SetPhase(PHASE_TWO); - _events.ScheduleEvent(EVENT_YELL_BOW_DOWN, 3000, 0, PHASE_TWO); - DoCast(me, SPELL_SHADOWY_BARRIER_YOGG); - DoCast(me, SPELL_KNOCK_AWAY); - - me->ResetLootMode(); - uint32 keepersCount = _instance->GetData(DATA_KEEPERS_COUNT); - if (keepersCount == 0) - me->AddLootMode(LOOT_MODE_HARD_MODE_4); - if (keepersCount <= 1) - me->AddLootMode(LOOT_MODE_HARD_MODE_3); - if (keepersCount <= 2) - me->AddLootMode(LOOT_MODE_HARD_MODE_2); - if (keepersCount <= 3) - me->AddLootMode(LOOT_MODE_HARD_MODE_1); - } + void Reset() override + { + _events.Reset(); + _events.SetPhase(PHASE_TWO); + _events.ScheduleEvent(EVENT_YELL_BOW_DOWN, 3000, 0, PHASE_TWO); + DoCast(me, SPELL_SHADOWY_BARRIER_YOGG); + DoCast(me, SPELL_KNOCK_AWAY); + + me->ResetLootMode(); + uint32 keepersCount = _instance->GetData(DATA_KEEPERS_COUNT); + if (keepersCount == 0) + me->AddLootMode(LOOT_MODE_HARD_MODE_4); + if (keepersCount <= 1) + me->AddLootMode(LOOT_MODE_HARD_MODE_3); + if (keepersCount <= 2) + me->AddLootMode(LOOT_MODE_HARD_MODE_2); + if (keepersCount <= 3) + me->AddLootMode(LOOT_MODE_HARD_MODE_1); + } - void SpellHit(Unit* /*caster*/, SpellInfo const* spell) override - { - // Val'anyr - if (spell->Id == SPELL_IN_THE_MAWS_OF_THE_OLD_GOD) - me->AddLootMode(32); - } + void SpellHit(Unit* /*caster*/, SpellInfo const* spell) override + { + // Val'anyr + if (spell->Id == SPELL_IN_THE_MAWS_OF_THE_OLD_GOD) + me->AddLootMode(32); + } - void JustDied(Unit* /*killer*/) override - { - Talk(SAY_YOGG_SARON_DEATH); + void JustDied(Unit* /*killer*/) override + { + Talk(SAY_YOGG_SARON_DEATH); - if (Creature* creature = _instance->GetCreature(DATA_VOICE_OF_YOGG_SARON)) - me->Kill(creature); + if (Creature* creature = _instance->GetCreature(DATA_VOICE_OF_YOGG_SARON)) + Unit::Kill(me, creature); - for (uint8 i = DATA_SARA; i <= DATA_BRAIN_OF_YOGG_SARON; ++i) - if (Creature* creature = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(i))) - creature->DisappearAndDie(); + for (uint8 i = DATA_SARA; i <= DATA_BRAIN_OF_YOGG_SARON; ++i) + if (Creature* creature = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(i))) + creature->DisappearAndDie(); - for (uint8 i = DATA_FREYA_YS; i <= DATA_MIMIRON_YS; ++i) - if (Creature* creature = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(i))) - creature->AI()->EnterEvadeMode(); + for (uint8 i = DATA_FREYA_YS; i <= DATA_MIMIRON_YS; ++i) + if (Creature* creature = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(i))) + creature->AI()->EnterEvadeMode(); - Map::PlayerList const& players = me->GetMap()->GetPlayers(); - for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr) - if (Player* player = itr->GetSource()) - { - player->RemoveAurasDueToSpell(SPELL_SANITY); - player->RemoveAurasDueToSpell(SPELL_INSANE); - } - } + Map::PlayerList const& players = me->GetMap()->GetPlayers(); + for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr) + if (Player* player = itr->GetSource()) + { + player->RemoveAurasDueToSpell(SPELL_SANITY); + player->RemoveAurasDueToSpell(SPELL_INSANE); + } + } - void UpdateAI(uint32 diff) override - { - _events.Update(diff); + void UpdateAI(uint32 diff) override + { + _events.Update(diff); - if (me->HasUnitState(UNIT_STATE_CASTING)) - return; + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; - while (uint32 eventId = _events.ExecuteEvent()) + while (uint32 eventId = _events.ExecuteEvent()) + { + switch (eventId) { - switch (eventId) - { - case EVENT_YELL_BOW_DOWN: - Talk(SAY_YOGG_SARON_SPAWN); - break; - case EVENT_SHADOW_BEACON: - DoCastAOE(SPELL_SHADOW_BEACON); - Talk(EMOTE_YOGG_SARON_EMPOWERING_SHADOWS); - _events.ScheduleEvent(EVENT_SHADOW_BEACON, 45000, 0, PHASE_THREE); - break; - case EVENT_LUNATIC_GAZE: - DoCast(me, SPELL_LUNATIC_GAZE); - sCreatureTextMgr->SendSound(me, SOUND_LUNATIC_GAZE, CreatureTextSoundType::DirectSound, CHAT_MSG_MONSTER_YELL, 0, TEXT_RANGE_NORMAL, TEAM_OTHER, false); - _events.ScheduleEvent(EVENT_LUNATIC_GAZE, 12000, 0, PHASE_THREE); - break; - case EVENT_DEAFENING_ROAR: - DoCastAOE(SPELL_DEAFENING_ROAR); - Talk(SAY_YOGG_SARON_DEAFENING_ROAR); - Talk(EMOTE_YOGG_SARON_DEAFENING_ROAR); - _events.ScheduleEvent(EVENT_DEAFENING_ROAR, urand(20000, 25000), 0, PHASE_THREE); // timer guessed - break; - default: - break; - } + case EVENT_YELL_BOW_DOWN: + Talk(SAY_YOGG_SARON_SPAWN); + break; + case EVENT_SHADOW_BEACON: + DoCastAOE(SPELL_SHADOW_BEACON); + Talk(EMOTE_YOGG_SARON_EMPOWERING_SHADOWS); + _events.ScheduleEvent(EVENT_SHADOW_BEACON, 45000, 0, PHASE_THREE); + break; + case EVENT_LUNATIC_GAZE: + DoCast(me, SPELL_LUNATIC_GAZE); + sCreatureTextMgr->SendSound(me, SOUND_LUNATIC_GAZE, CreatureTextSoundType::DirectSound, CHAT_MSG_MONSTER_YELL, 0, TEXT_RANGE_NORMAL, TEAM_OTHER, false); + _events.ScheduleEvent(EVENT_LUNATIC_GAZE, 12000, 0, PHASE_THREE); + break; + case EVENT_DEAFENING_ROAR: + DoCastAOE(SPELL_DEAFENING_ROAR); + Talk(SAY_YOGG_SARON_DEAFENING_ROAR); + Talk(EMOTE_YOGG_SARON_DEAFENING_ROAR); + _events.ScheduleEvent(EVENT_DEAFENING_ROAR, urand(20000, 25000), 0, PHASE_THREE); // timer guessed + break; + default: + break; } } + } - void DoAction(int32 action) override + void DoAction(int32 action) override + { + switch (action) { - switch (action) - { - case ACTION_PHASE_THREE: - _events.SetPhase(PHASE_THREE); - _events.ScheduleEvent(EVENT_SHADOW_BEACON, 45000, 0, PHASE_THREE); - _events.ScheduleEvent(EVENT_LUNATIC_GAZE, 12000, 0, PHASE_THREE); - if (me->GetMap()->Is25ManRaid() && _instance->GetData(DATA_KEEPERS_COUNT) < 4) - _events.ScheduleEvent(EVENT_DEAFENING_ROAR, urand(20000, 25000), 0, PHASE_THREE); // timer guessed - Talk(SAY_YOGG_SARON_PHASE_3); - DoCast(me, SPELL_PHASE_3_TRANSFORM); - me->RemoveAurasDueToSpell(SPELL_SHADOWY_BARRIER_YOGG); - me->ResetPlayerDamageReq(); - break; - default: - break; - } + case ACTION_PHASE_THREE: + _events.SetPhase(PHASE_THREE); + _events.ScheduleEvent(EVENT_SHADOW_BEACON, 45000, 0, PHASE_THREE); + _events.ScheduleEvent(EVENT_LUNATIC_GAZE, 12000, 0, PHASE_THREE); + if (me->GetMap()->Is25ManRaid() && _instance->GetData(DATA_KEEPERS_COUNT) < 4) + _events.ScheduleEvent(EVENT_DEAFENING_ROAR, urand(20000, 25000), 0, PHASE_THREE); // timer guessed + Talk(SAY_YOGG_SARON_PHASE_3); + DoCast(me, SPELL_PHASE_3_TRANSFORM); + me->RemoveAurasDueToSpell(SPELL_SHADOWY_BARRIER_YOGG); + me->ResetPlayerDamageReq(); + break; + default: + break; } + } - private: - EventMap _events; - InstanceScript* _instance; - }; + private: + EventMap _events; + InstanceScript* _instance; + }; - CreatureAI* GetAI(Creature* creature) const override - { - return GetUlduarAI(creature); - } + CreatureAI* GetAI(Creature* creature) const override + { + return GetUlduarAI(creature); + } }; class boss_brain_of_yogg_saron : public CreatureScript { - public: - boss_brain_of_yogg_saron() : CreatureScript("boss_brain_of_yogg_saron") { } + public: + boss_brain_of_yogg_saron() : CreatureScript("boss_brain_of_yogg_saron") + { + } - struct boss_brain_of_yogg_saronAI : public PassiveAI + struct boss_brain_of_yogg_saronAI : public PassiveAI + { + boss_brain_of_yogg_saronAI(Creature* creature) : PassiveAI(creature), _instance(creature->GetInstanceScript()), _summons(creature) { - boss_brain_of_yogg_saronAI(Creature* creature) : PassiveAI(creature), _instance(creature->GetInstanceScript()), _summons(creature) - { - _tentaclesKilled = 0; - } + _tentaclesKilled = 0; + } - void Reset() override - { - me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - me->SetImmuneToPC(false); - DoCast(me, SPELL_MATCH_HEALTH); - _summons.DespawnAll(); - } + void Reset() override + { + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + me->SetImmuneToPC(false); + DoCast(me, SPELL_MATCH_HEALTH); + _summons.DespawnAll(); + } - void DamageTaken(Unit* /*attacker*/, uint32& damage) override + void DamageTaken(Unit* /*attacker*/, uint32& damage) override + { + if (me->HealthBelowPctDamaged(30, damage) && !me->HasAura(SPELL_BRAIN_HURT_VISUAL)) { - if (me->HealthBelowPctDamaged(30, damage) && !me->HasAura(SPELL_BRAIN_HURT_VISUAL)) - { - me->RemoveAllAuras(); - me->InterruptNonMeleeSpells(true); - DoCastAOE(SPELL_SHATTERED_ILLUSION_REMOVE, true); - DoCast(me, SPELL_MATCH_HEALTH_2, true); // it doesn't seem to hit Yogg-Saron here - DoCast(me, SPELL_BRAIN_HURT_VISUAL, true); - me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - me->SetImmuneToPC(true); + me->RemoveAllAuras(); + me->InterruptNonMeleeSpells(true); + DoCastAOE(SPELL_SHATTERED_ILLUSION_REMOVE, true); + DoCast(me, SPELL_MATCH_HEALTH_2, true); // it doesn't seem to hit Yogg-Saron here + DoCast(me, SPELL_BRAIN_HURT_VISUAL, true); + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + me->SetImmuneToPC(true); - if (Creature* voice = _instance->GetCreature(DATA_VOICE_OF_YOGG_SARON)) - voice->AI()->DoAction(ACTION_PHASE_THREE); - if (Creature* sara = _instance->GetCreature(DATA_SARA)) - sara->AI()->DoAction(ACTION_PHASE_THREE); - if (Creature* yogg = _instance->GetCreature(DATA_YOGG_SARON)) - yogg->AI()->DoAction(ACTION_PHASE_THREE); + if (Creature* voice = _instance->GetCreature(DATA_VOICE_OF_YOGG_SARON)) + voice->AI()->DoAction(ACTION_PHASE_THREE); + if (Creature* sara = _instance->GetCreature(DATA_SARA)) + sara->AI()->DoAction(ACTION_PHASE_THREE); + if (Creature* yogg = _instance->GetCreature(DATA_YOGG_SARON)) + yogg->AI()->DoAction(ACTION_PHASE_THREE); - for (uint8 i = DATA_THORIM_YS; i <= DATA_MIMIRON_YS; ++i) - if (Creature* keeper = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(i))) - keeper->AI()->DoAction(ACTION_PHASE_THREE); - } + for (uint8 i = DATA_THORIM_YS; i <= DATA_MIMIRON_YS; ++i) + if (Creature* keeper = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(i))) + keeper->AI()->DoAction(ACTION_PHASE_THREE); } + } - void UpdateAI(uint32 /*diff*/) override { } + void UpdateAI(uint32 /*diff*/) override + { + } - void DoAction(int32 action) override + void DoAction(int32 action) override + { + switch (action) { - switch (action) - { - case ACTION_INDUCE_MADNESS: - { - _tentaclesKilled = 0; + case ACTION_INDUCE_MADNESS: + { + _tentaclesKilled = 0; - me->SummonCreatureGroup(_instance->GetData(DATA_ILLUSION)); + me->SummonCreatureGroup(_instance->GetData(DATA_ILLUSION)); - // make sure doors won't be opened - for (uint32 i = GO_BRAIN_ROOM_DOOR_1; i <= GO_BRAIN_ROOM_DOOR_3; ++i) - _instance->HandleGameObject(_instance->GetGuidData(i), false); + // make sure doors won't be opened + for (uint32 i = GO_BRAIN_ROOM_DOOR_1; i <= GO_BRAIN_ROOM_DOOR_3; ++i) + _instance->HandleGameObject(_instance->GetGuidData(i), false); - DoCastAOE(SPELL_INDUCE_MADNESS); - break; - } - case ACTION_TENTACLE_KILLED: - { - uint8 illusion = _instance->GetData(DATA_ILLUSION); - if (++_tentaclesKilled >= (illusion == ICECROWN_ILLUSION ? 9 : 8)) - { - sCreatureTextMgr->SendChat(me, EMOTE_BRAIN_ILLUSION_SHATTERED, nullptr, CHAT_MSG_ADDON, LANG_ADDON, TEXT_RANGE_AREA); - _summons.DespawnAll(); - DoCastAOE(SPELL_SHATTERED_ILLUSION, true); - _instance->HandleGameObject(_instance->GetGuidData(GO_BRAIN_ROOM_DOOR_1 + illusion), true); - - if (Creature* voice = _instance->GetCreature(DATA_VOICE_OF_YOGG_SARON)) - voice->AI()->DoAction(ACTION_TOGGLE_SHATTERED_ILLUSION); - } - break; - } - default: - break; - } + DoCastAOE(SPELL_INDUCE_MADNESS); + break; } - - void JustSummoned(Creature* summon) override + case ACTION_TENTACLE_KILLED: { - _summons.Summon(summon); - } + uint8 illusion = _instance->GetData(DATA_ILLUSION); + if (++_tentaclesKilled >= (illusion == ICECROWN_ILLUSION ? 9 : 8)) + { + sCreatureTextMgr->SendChat(me, EMOTE_BRAIN_ILLUSION_SHATTERED, nullptr, CHAT_MSG_ADDON, LANG_ADDON, TEXT_RANGE_AREA); + _summons.DespawnAll(); + DoCastAOE(SPELL_SHATTERED_ILLUSION, true); + _instance->HandleGameObject(_instance->GetGuidData(GO_BRAIN_ROOM_DOOR_1 + illusion), true); - private: - InstanceScript* _instance; - SummonList _summons; - uint8 _tentaclesKilled; - }; + if (Creature* voice = _instance->GetCreature(DATA_VOICE_OF_YOGG_SARON)) + voice->AI()->DoAction(ACTION_TOGGLE_SHATTERED_ILLUSION); + } + break; + } + default: + break; + } + } - CreatureAI* GetAI(Creature* creature) const override + void JustSummoned(Creature* summon) override { - return GetUlduarAI(creature); + _summons.Summon(summon); } + + private: + InstanceScript* _instance; + SummonList _summons; + uint8 _tentaclesKilled; + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return GetUlduarAI(creature); + } }; class npc_ominous_cloud : public CreatureScript { - public: - npc_ominous_cloud() : CreatureScript("npc_ominous_cloud") { } + public: + npc_ominous_cloud() : CreatureScript("npc_ominous_cloud") + { + } - struct npc_ominous_cloudAI : public PassiveAI + struct npc_ominous_cloudAI : public PassiveAI + { + npc_ominous_cloudAI(Creature* creature) : PassiveAI(creature) { - npc_ominous_cloudAI(Creature* creature) : PassiveAI(creature) { } - - void Reset() override - { - DoCast(me, SPELL_OMINOUS_CLOUD_VISUAL); - } - - void UpdateAI(uint32 /*diff*/) override { } + } - void DoAction(int32 action) override - { - clockwise = bool(action); - me->GetMotionMaster()->MoveCirclePath(YoggSaronSpawnPos.GetPositionX(), YoggSaronSpawnPos.GetPositionY(), me->GetPositionZ() + 5.0f, me->GetDistance2d(YoggSaronSpawnPos.GetPositionX(), YoggSaronSpawnPos.GetPositionY()), clockwise, 16); - } + void Reset() override + { + DoCast(me, SPELL_OMINOUS_CLOUD_VISUAL); + } - bool clockwise = false; - }; + void UpdateAI(uint32 /*diff*/) override + { + } - CreatureAI* GetAI(Creature* creature) const override + void DoAction(int32 action) override { - return GetUlduarAI(creature); + clockwise = bool(action); + me->GetMotionMaster()->MoveCirclePath(YoggSaronSpawnPos.GetPositionX(), YoggSaronSpawnPos.GetPositionY(), me->GetPositionZ() + 5.0f, + me->GetDistance2d(YoggSaronSpawnPos.GetPositionX(), YoggSaronSpawnPos.GetPositionY()), clockwise, 16); } + + bool clockwise = false; + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return GetUlduarAI(creature); + } }; class npc_guardian_of_yogg_saron : public CreatureScript { - public: - npc_guardian_of_yogg_saron() : CreatureScript("npc_guardian_of_yogg_saron") { } + public: + npc_guardian_of_yogg_saron() : CreatureScript("npc_guardian_of_yogg_saron") + { + } - struct npc_guardian_of_yogg_saronAI : public ScriptedAI + struct npc_guardian_of_yogg_saronAI : public ScriptedAI + { + npc_guardian_of_yogg_saronAI(Creature* creature) : ScriptedAI(creature), _instance(creature->GetInstanceScript()) { - npc_guardian_of_yogg_saronAI(Creature* creature) : ScriptedAI(creature), _instance(creature->GetInstanceScript()) { } + } - void JustDied(Unit* /*killer*/) override - { - DoCastAOE(SPELL_SHADOW_NOVA); - DoCastAOE(SPELL_SHADOW_NOVA_2); - } + void JustDied(Unit* /*killer*/) override + { + DoCastAOE(SPELL_SHADOW_NOVA); + DoCastAOE(SPELL_SHADOW_NOVA_2); + } - void Reset() override - { - _events.ScheduleEvent(EVENT_DARK_VOLLEY, urand(10000, 15000)); - } + void Reset() override + { + _events.ScheduleEvent(EVENT_DARK_VOLLEY, urand(10000, 15000)); + } - void UpdateAI(uint32 diff) override - { - if (!UpdateVictim()) - return; + void UpdateAI(uint32 diff) override + { + if (!UpdateVictim()) + return; - _events.Update(diff); + _events.Update(diff); - if (me->HasUnitState(UNIT_STATE_CASTING)) - return; + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; - while (uint32 eventId = _events.ExecuteEvent()) + while (uint32 eventId = _events.ExecuteEvent()) + { + switch (eventId) { - switch (eventId) - { - case EVENT_DARK_VOLLEY: - DoCastAOE(SPELL_DARK_VOLLEY); - _events.ScheduleEvent(EVENT_DARK_VOLLEY, urand(10000, 15000)); - break; - default: - break; - } + case EVENT_DARK_VOLLEY: + DoCastAOE(SPELL_DARK_VOLLEY); + _events.ScheduleEvent(EVENT_DARK_VOLLEY, urand(10000, 15000)); + break; + default: + break; } - - DoMeleeAttackIfReady(); - } - - void IsSummonedBy(Unit* summoner) override - { - if (summoner->GetEntry() != NPC_OMINOUS_CLOUD) - return; - - // Guardian can be summoned both by Voice of Yogg-Saron and by Ominous Cloud - if (Creature* voice = _instance->GetCreature(DATA_VOICE_OF_YOGG_SARON)) - voice->AI()->JustSummoned(me); } - private: - EventMap _events; - InstanceScript* _instance; - }; + DoMeleeAttackIfReady(); + } - CreatureAI* GetAI(Creature* creature) const override + void IsSummonedBy(Unit* summoner) override { - return GetUlduarAI(creature); + if (summoner->GetEntry() != NPC_OMINOUS_CLOUD) + return; + + // Guardian can be summoned both by Voice of Yogg-Saron and by Ominous Cloud + if (Creature* voice = _instance->GetCreature(DATA_VOICE_OF_YOGG_SARON)) + voice->AI()->JustSummoned(me); } + + private: + EventMap _events; + InstanceScript* _instance; + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return GetUlduarAI(creature); + } }; class npc_corruptor_tentacle : public CreatureScript { - public: - npc_corruptor_tentacle() : CreatureScript("npc_corruptor_tentacle") { } + public: + npc_corruptor_tentacle() : CreatureScript("npc_corruptor_tentacle") + { + } - struct npc_corruptor_tentacleAI : public ScriptedAI + struct npc_corruptor_tentacleAI : public ScriptedAI + { + npc_corruptor_tentacleAI(Creature* creature) : ScriptedAI(creature) { - npc_corruptor_tentacleAI(Creature* creature) : ScriptedAI(creature) - { - SetCombatMovement(false); - } + SetCombatMovement(false); + } - void Reset() override - { - DoCast(me, SPELL_TENTACLE_VOID_ZONE); - DoCastAOE(SPELL_ERUPT); - _events.ScheduleEvent(EVENT_CAST_RANDOM_SPELL, 1); - } + void Reset() override + { + DoCast(me, SPELL_TENTACLE_VOID_ZONE); + DoCastAOE(SPELL_ERUPT); + _events.ScheduleEvent(EVENT_CAST_RANDOM_SPELL, 1); + } - void UpdateAI(uint32 diff) override - { - if (!UpdateVictim()) - return; + void UpdateAI(uint32 diff) override + { + if (!UpdateVictim()) + return; - if (me->HasAura(SPELL_SHATTERED_ILLUSION)) - return; + if (me->HasAura(SPELL_SHATTERED_ILLUSION)) + return; - _events.Update(diff); + _events.Update(diff); - if (me->HasUnitState(UNIT_STATE_CASTING)) - return; + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; - while (uint32 eventId = _events.ExecuteEvent()) + while (uint32 eventId = _events.ExecuteEvent()) + { + switch (eventId) { - switch (eventId) - { - case EVENT_CAST_RANDOM_SPELL: - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM)) - DoCast(target, RAND(SPELL_BLACK_PLAGUE, SPELL_CURSE_OF_DOOM, SPELL_APATHY, SPELL_DRAINING_POISON)); - _events.ScheduleEvent(EVENT_CAST_RANDOM_SPELL, 3000); - break; - default: - break; - } + case EVENT_CAST_RANDOM_SPELL: + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM)) + DoCast(target, RAND(SPELL_BLACK_PLAGUE, SPELL_CURSE_OF_DOOM, SPELL_APATHY, SPELL_DRAINING_POISON)); + _events.ScheduleEvent(EVENT_CAST_RANDOM_SPELL, 3000); + break; + default: + break; } } + } - private: - EventMap _events; - }; + private: + EventMap _events; + }; - CreatureAI* GetAI(Creature* creature) const override - { - return GetUlduarAI(creature); - } + CreatureAI* GetAI(Creature* creature) const override + { + return GetUlduarAI(creature); + } }; class npc_constrictor_tentacle : public CreatureScript { - public: - npc_constrictor_tentacle() : CreatureScript("npc_constrictor_tentacle") { } + public: + npc_constrictor_tentacle() : CreatureScript("npc_constrictor_tentacle") + { + } - struct npc_constrictor_tentacleAI : public ScriptedAI + struct npc_constrictor_tentacleAI : public ScriptedAI + { + npc_constrictor_tentacleAI(Creature* creature) : ScriptedAI(creature), _instance(creature->GetInstanceScript()) { - npc_constrictor_tentacleAI(Creature* creature) : ScriptedAI(creature), _instance(creature->GetInstanceScript()) - { - SetCombatMovement(false); - } + SetCombatMovement(false); + } - void Reset() override - { - DoCast(me, SPELL_TENTACLE_VOID_ZONE_2); - DoCastAOE(SPELL_ERUPT); - } - - void PassengerBoarded(Unit* passenger, int8 /*seatId*/, bool apply) override - { - if (!apply) - passenger->RemoveAurasDueToSpell(sSpellMgr->GetSpellIdForDifficulty(SPELL_SQUEEZE, passenger)); - } - - void UpdateAI(uint32 /*diff*/) override - { - UpdateVictim(); - } + void Reset() override + { + DoCast(me, SPELL_TENTACLE_VOID_ZONE_2); + DoCastAOE(SPELL_ERUPT); + } - void IsSummonedBy(Unit* /*summoner*/) override - { - if (Creature* voice = _instance->GetCreature(DATA_VOICE_OF_YOGG_SARON)) - voice->AI()->JustSummoned(me); - } + void PassengerBoarded(Unit* passenger, int8 /*seatId*/, bool apply) override + { + if (!apply) + passenger->RemoveAurasDueToSpell(sSpellMgr->GetSpellIdForDifficulty(SPELL_SQUEEZE, passenger)); + } - private: - InstanceScript* _instance; - }; + void UpdateAI(uint32 /*diff*/) override + { + UpdateVictim(); + } - CreatureAI* GetAI(Creature* creature) const override + void IsSummonedBy(Unit* /*summoner*/) override { - return GetUlduarAI(creature); + if (Creature* voice = _instance->GetCreature(DATA_VOICE_OF_YOGG_SARON)) + voice->AI()->JustSummoned(me); } + + private: + InstanceScript* _instance; + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return GetUlduarAI(creature); + } }; class npc_crusher_tentacle : public CreatureScript { - public: - npc_crusher_tentacle() : CreatureScript("npc_crusher_tentacle") { } + public: + npc_crusher_tentacle() : CreatureScript("npc_crusher_tentacle") + { + } - struct npc_crusher_tentacleAI : public ScriptedAI + struct npc_crusher_tentacleAI : public ScriptedAI + { + npc_crusher_tentacleAI(Creature* creature) : ScriptedAI(creature) { - npc_crusher_tentacleAI(Creature* creature) : ScriptedAI(creature) - { - SetCombatMovement(false); - } + SetCombatMovement(false); + } - void Reset() override - { - DoCast(me, SPELL_CRUSH); - DoCast(me, SPELL_TENTACLE_VOID_ZONE); - DoCast(me, SPELL_DIMINSH_POWER); - DoCast(me, SPELL_FOCUSED_ANGER); - DoCastAOE(SPELL_ERUPT); + void Reset() override + { + DoCast(me, SPELL_CRUSH); + DoCast(me, SPELL_TENTACLE_VOID_ZONE); + DoCast(me, SPELL_DIMINSH_POWER); + DoCast(me, SPELL_FOCUSED_ANGER); + DoCastAOE(SPELL_ERUPT); - _events.ScheduleEvent(EVENT_DIMINISH_POWER, urand(6000, 8000)); - } + _events.ScheduleEvent(EVENT_DIMINISH_POWER, urand(6000, 8000)); + } - void UpdateAI(uint32 diff) override - { - if (!UpdateVictim()) - return; + void UpdateAI(uint32 diff) override + { + if (!UpdateVictim()) + return; - if (me->HasAura(SPELL_SHATTERED_ILLUSION) || me->HasUnitState(UNIT_STATE_CASTING)) - return; + if (me->HasAura(SPELL_SHATTERED_ILLUSION) || me->HasUnitState(UNIT_STATE_CASTING)) + return; - // update timers when the Diminish Power is not being channeled so the next one - // is not cast immediately after interrupt - _events.Update(diff); + // update timers when the Diminish Power is not being channeled so the next one + // is not cast immediately after interrupt + _events.Update(diff); - while (uint32 eventId = _events.ExecuteEvent()) + while (uint32 eventId = _events.ExecuteEvent()) + { + switch (eventId) { - switch (eventId) - { - case EVENT_DIMINISH_POWER: - DoCast(SPELL_DIMINISH_POWER); - _events.ScheduleEvent(EVENT_DIMINISH_POWER, urand(20000, 30000)); - break; - default: - break; - } + case EVENT_DIMINISH_POWER: + DoCast(SPELL_DIMINISH_POWER); + _events.ScheduleEvent(EVENT_DIMINISH_POWER, urand(20000, 30000)); + break; + default: + break; } - - DoMeleeAttackIfReady(); } - private: - EventMap _events; - }; - - CreatureAI* GetAI(Creature* creature) const override - { - return GetUlduarAI(creature); + DoMeleeAttackIfReady(); } + + private: + EventMap _events; + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return GetUlduarAI(creature); + } }; class npc_influence_tentacle : public CreatureScript { - public: - npc_influence_tentacle() : CreatureScript("npc_influence_tentacle") { } + public: + npc_influence_tentacle() : CreatureScript("npc_influence_tentacle") + { + } - struct npc_influence_tentacleAI : public PassiveAI + struct npc_influence_tentacleAI : public PassiveAI + { + npc_influence_tentacleAI(Creature* creature) : PassiveAI(creature), _instance(creature->GetInstanceScript()) { - npc_influence_tentacleAI(Creature* creature) : PassiveAI(creature), _instance(creature->GetInstanceScript()) { } - - void Reset() override - { - DoCast(me, me->GetEntry() == NPC_SUIT_OF_ARMOR ? SPELL_NONDESCRIPT_1 : SPELL_NONDESCRIPT_2); - } - - void JustDied(Unit* /*killer*/) override - { - if (Creature* brain = _instance->GetCreature(DATA_BRAIN_OF_YOGG_SARON)) - brain->AI()->DoAction(ACTION_TENTACLE_KILLED); - } + } - void UpdateAI(uint32 /*diff*/) override { } + void Reset() override + { + DoCast(me, me->GetEntry() == NPC_SUIT_OF_ARMOR ? SPELL_NONDESCRIPT_1 : SPELL_NONDESCRIPT_2); + } - private: - InstanceScript* _instance; - }; + void JustDied(Unit* /*killer*/) override + { + if (Creature* brain = _instance->GetCreature(DATA_BRAIN_OF_YOGG_SARON)) + brain->AI()->DoAction(ACTION_TENTACLE_KILLED); + } - CreatureAI* GetAI(Creature* creature) const override + void UpdateAI(uint32 /*diff*/) override { - return GetUlduarAI(creature); } + + private: + InstanceScript* _instance; + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return GetUlduarAI(creature); + } }; typedef boss_sara::boss_saraAI SaraAI; class npc_descend_into_madness : public CreatureScript { - public: - npc_descend_into_madness() : CreatureScript("npc_descend_into_madness") { } + public: + npc_descend_into_madness() : CreatureScript("npc_descend_into_madness") + { + } - struct npc_descend_into_madnessAI : public PassiveAI + struct npc_descend_into_madnessAI : public PassiveAI + { + npc_descend_into_madnessAI(Creature* creature) : PassiveAI(creature), _instance(creature->GetInstanceScript()) { - npc_descend_into_madnessAI(Creature* creature) : PassiveAI(creature), _instance(creature->GetInstanceScript()) { } - - void OnSpellClick(Unit* clicker, bool& result) override - { - if (!result) - return; - - clicker->RemoveAurasDueToSpell(SPELL_BRAIN_LINK); - uint32 illusion = _instance->GetData(DATA_ILLUSION); - if (illusion < MAX_ILLUSION_ROOMS) - DoCast(clicker, IllusionSpells[illusion], true); - me->DespawnOrUnsummon(); - } + } - void UpdateAI(uint32 /*diff*/) override { } + void OnSpellClick(Unit* clicker, bool& result) override + { + if (!result) + return; - private: - InstanceScript* _instance; - }; + clicker->RemoveAurasDueToSpell(SPELL_BRAIN_LINK); + uint32 illusion = _instance->GetData(DATA_ILLUSION); + if (illusion < MAX_ILLUSION_ROOMS) + DoCast(clicker, IllusionSpells[illusion], true); + me->DespawnOrUnsummon(); + } - CreatureAI* GetAI(Creature* creature) const override + void UpdateAI(uint32 /*diff*/) override { - return GetUlduarAI(creature); } + + private: + InstanceScript* _instance; + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return GetUlduarAI(creature); + } }; class npc_immortal_guardian : public CreatureScript { - public: - npc_immortal_guardian() : CreatureScript("npc_immortal_guardian") { } + public: + npc_immortal_guardian() : CreatureScript("npc_immortal_guardian") + { + } - struct npc_immortal_guardianAI : public ScriptedAI + struct npc_immortal_guardianAI : public ScriptedAI + { + npc_immortal_guardianAI(Creature* creature) : ScriptedAI(creature) { - npc_immortal_guardianAI(Creature* creature) : ScriptedAI(creature) { } + } - void Reset() override - { - DoCast(me, SPELL_EMPOWERED); - DoCast(me, SPELL_RECENTLY_SPAWNED); - _events.ScheduleEvent(EVENT_DRAIN_LIFE, urand(3000, 13000)); - } + void Reset() override + { + DoCast(me, SPELL_EMPOWERED); + DoCast(me, SPELL_RECENTLY_SPAWNED); + _events.ScheduleEvent(EVENT_DRAIN_LIFE, urand(3000, 13000)); + } - void DamageTaken(Unit* /*attacker*/, uint32& damage) override - { - if (me->HealthBelowPctDamaged(1, damage)) - damage = me->GetHealth() - me->CountPctFromMaxHealth(1); // or set immune to damage? should be done here or in SPELL_WEAKENED spell script? - } + void DamageTaken(Unit* /*attacker*/, uint32& damage) override + { + if (me->HealthBelowPctDamaged(1, damage)) + damage = me->GetHealth() - me->CountPctFromMaxHealth(1); // or set immune to damage? should be done here or in SPELL_WEAKENED spell script? + } - void UpdateAI(uint32 diff) override - { - if (!UpdateVictim()) - return; + void UpdateAI(uint32 diff) override + { + if (!UpdateVictim()) + return; - _events.Update(diff); + _events.Update(diff); - if (me->HasUnitState(UNIT_STATE_CASTING)) - return; + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; - while (uint32 eventId = _events.ExecuteEvent()) + while (uint32 eventId = _events.ExecuteEvent()) + { + switch (eventId) { - switch (eventId) - { - case EVENT_DRAIN_LIFE: - DoCast(SPELL_DRAIN_LIFE); - _events.ScheduleEvent(EVENT_DRAIN_LIFE, urand(20000, 30000)); - break; - default: - break; - } + case EVENT_DRAIN_LIFE: + DoCast(SPELL_DRAIN_LIFE); + _events.ScheduleEvent(EVENT_DRAIN_LIFE, urand(20000, 30000)); + break; + default: + break; } - - DoMeleeAttackIfReady(); } - private: - EventMap _events; - }; - - CreatureAI* GetAI(Creature* creature) const override - { - return GetUlduarAI(creature); + DoMeleeAttackIfReady(); } + + private: + EventMap _events; + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return GetUlduarAI(creature); + } }; class npc_observation_ring_keeper : public CreatureScript { - public: - npc_observation_ring_keeper() : CreatureScript("npc_observation_ring_keeper") { } + public: + npc_observation_ring_keeper() : CreatureScript("npc_observation_ring_keeper") + { + } - struct npc_observation_ring_keeperAI : public ScriptedAI + struct npc_observation_ring_keeperAI : public ScriptedAI + { + npc_observation_ring_keeperAI(Creature* creature) : ScriptedAI(creature) { - npc_observation_ring_keeperAI(Creature* creature) : ScriptedAI(creature) { } - - void Reset() override - { - DoCast(SPELL_SIMPLE_TELEPORT_KEEPERS); // not visible here - DoCast(SPELL_KEEPER_ACTIVE); - } - - bool GossipSelect(Player* player, uint32 menuId, uint32 /*gossipListId*/) override - { - if (menuId != 10333) - return true; + } - me->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); - me->DespawnOrUnsummon(2000); - DoCast(SPELL_TELEPORT); - Talk(SAY_KEEPER_CHOSEN_1, player); - Talk(SAY_KEEPER_CHOSEN_2, player); + void Reset() override + { + DoCast(SPELL_SIMPLE_TELEPORT_KEEPERS); // not visible here + DoCast(SPELL_KEEPER_ACTIVE); + } - switch (me->GetEntry()) - { - case NPC_FREYA_OBSERVATION_RING: - me->SummonCreature(NPC_FREYA_YS, YSKeepersPos[0]); - break; - case NPC_HODIR_OBSERVATION_RING: - me->SummonCreature(NPC_HODIR_YS, YSKeepersPos[1]); - break; - case NPC_THORIM_OBSERVATION_RING: - me->SummonCreature(NPC_THORIM_YS, YSKeepersPos[2]); - break; - case NPC_MIMIRON_OBSERVATION_RING: - me->SummonCreature(NPC_MIMIRON_YS, YSKeepersPos[3]); - break; - } - return false; - } + bool GossipSelect(Player* player, uint32 menuId, uint32 /*gossipListId*/) override + { + if (menuId != 10333) + return true; - void UpdateAI(uint32 /*diff*/) override { } - }; + me->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); + me->DespawnOrUnsummon(2000); + DoCast(SPELL_TELEPORT); + Talk(SAY_KEEPER_CHOSEN_1, player); + Talk(SAY_KEEPER_CHOSEN_2, player); + + switch (me->GetEntry()) + { + case NPC_FREYA_OBSERVATION_RING: + me->SummonCreature(NPC_FREYA_YS, YSKeepersPos[0]); + break; + case NPC_HODIR_OBSERVATION_RING: + me->SummonCreature(NPC_HODIR_YS, YSKeepersPos[1]); + break; + case NPC_THORIM_OBSERVATION_RING: + me->SummonCreature(NPC_THORIM_YS, YSKeepersPos[2]); + break; + case NPC_MIMIRON_OBSERVATION_RING: + me->SummonCreature(NPC_MIMIRON_YS, YSKeepersPos[3]); + break; + } + return false; + } - CreatureAI* GetAI(Creature* creature) const override + void UpdateAI(uint32 /*diff*/) override { - return GetUlduarAI(creature); } + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return GetUlduarAI(creature); + } }; class npc_yogg_saron_keeper : public CreatureScript { - public: - npc_yogg_saron_keeper() : CreatureScript("npc_yogg_saron_keeper") { } + public: + npc_yogg_saron_keeper() : CreatureScript("npc_yogg_saron_keeper") + { + } - struct npc_yogg_saron_keeperAI : public ScriptedAI + struct npc_yogg_saron_keeperAI : public ScriptedAI + { + npc_yogg_saron_keeperAI(Creature* creature) : ScriptedAI(creature) { - npc_yogg_saron_keeperAI(Creature* creature) : ScriptedAI(creature) { } + } - void IsSummonedBy(Unit* /*summoner*/) override - { - DoCast(SPELL_SIMPLE_TELEPORT_KEEPERS); - } + void IsSummonedBy(Unit* /*summoner*/) override + { + DoCast(SPELL_SIMPLE_TELEPORT_KEEPERS); + } - void Reset() override - { - _events.Reset(); - _events.SetPhase(PHASE_ONE); - me->SetReactState(REACT_PASSIVE); - me->RemoveAllAuras(); + void Reset() override + { + _events.Reset(); + _events.SetPhase(PHASE_ONE); + me->SetReactState(REACT_PASSIVE); + me->RemoveAllAuras(); - DoCast(SPELL_KEEPER_ACTIVE); // can we skip removing this aura somehow? + DoCast(SPELL_KEEPER_ACTIVE); // can we skip removing this aura somehow? - if (me->GetEntry() == NPC_FREYA_YS) + if (me->GetEntry() == NPC_FREYA_YS) + { + std::list wells; + GetCreatureListWithEntryInGrid(wells, me, NPC_SANITY_WELL, 200.0f); + for (std::list::const_iterator itr = wells.begin(); itr != wells.end(); ++itr) { - std::list wells; - GetCreatureListWithEntryInGrid(wells, me, NPC_SANITY_WELL, 200.0f); - for (std::list::const_iterator itr = wells.begin(); itr != wells.end(); ++itr) - { - (*itr)->RemoveAurasDueToSpell(SPELL_SANITY_WELL); - (*itr)->RemoveAurasDueToSpell(SPELL_SANITY_WELL_VISUAL); - } + (*itr)->RemoveAurasDueToSpell(SPELL_SANITY_WELL); + (*itr)->RemoveAurasDueToSpell(SPELL_SANITY_WELL_VISUAL); } } + } - void JustEngagedWith(Unit* /*who*/) override - { - switch (me->GetEntry()) - { - case NPC_FREYA_YS: - DoCast(SPELL_RESILIENCE_OF_NATURE); - DoCast(SPELL_SANITY_WELL_SUMMON); - break; - case NPC_HODIR_YS: - DoCast(SPELL_FORTITUDE_OF_FROST); - DoCast(SPELL_HODIRS_PROTECTIVE_GAZE); - break; - case NPC_THORIM_YS: - DoCast(SPELL_FURY_OF_THE_STORM); - break; - case NPC_MIMIRON_YS: - DoCast(SPELL_SPEED_OF_INVENTION); - break; - } + void JustEngagedWith(Unit* /*who*/) override + { + switch (me->GetEntry()) + { + case NPC_FREYA_YS: + DoCast(SPELL_RESILIENCE_OF_NATURE); + DoCast(SPELL_SANITY_WELL_SUMMON); + break; + case NPC_HODIR_YS: + DoCast(SPELL_FORTITUDE_OF_FROST); + DoCast(SPELL_HODIRS_PROTECTIVE_GAZE); + break; + case NPC_THORIM_YS: + DoCast(SPELL_FURY_OF_THE_STORM); + break; + case NPC_MIMIRON_YS: + DoCast(SPELL_SPEED_OF_INVENTION); + break; } + } - void UpdateAI(uint32 diff) override - { - if (!me->IsInCombat()) - return; + void UpdateAI(uint32 diff) override + { + if (!me->IsInCombat()) + return; - _events.Update(diff); + _events.Update(diff); - if (me->HasUnitState(UNIT_STATE_CASTING)) - return; + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; - while (uint32 eventId = _events.ExecuteEvent()) + while (uint32 eventId = _events.ExecuteEvent()) + { + switch (eventId) { - switch (eventId) - { - case EVENT_DESTABILIZATION_MATRIX: - DoCastAOE(SPELL_DESTABILIZATION_MATRIX, { SPELLVALUE_MAX_TARGETS, 1 }); - _events.ScheduleEvent(EVENT_DESTABILIZATION_MATRIX, urand(15000, 25000), 0, PHASE_TWO); - break; - case EVENT_HODIRS_PROTECTIVE_GAZE: - DoCast(SPELL_HODIRS_PROTECTIVE_GAZE); - break; - } + case EVENT_DESTABILIZATION_MATRIX: + DoCastAOE(SPELL_DESTABILIZATION_MATRIX, {SPELLVALUE_MAX_TARGETS, 1}); + _events.ScheduleEvent(EVENT_DESTABILIZATION_MATRIX, urand(15000, 25000), 0, PHASE_TWO); + break; + case EVENT_HODIRS_PROTECTIVE_GAZE: + DoCast(SPELL_HODIRS_PROTECTIVE_GAZE); + break; } } + } - void DoAction(int32 action) override + void DoAction(int32 action) override + { + switch (action) { - switch (action) + // setting the phases is only for Thorim and Mimiron + case ACTION_PHASE_TWO: + _events.SetPhase(PHASE_TWO); + _events.ScheduleEvent(EVENT_DESTABILIZATION_MATRIX, urand(5000, 15000), 0, PHASE_TWO); + break; + case ACTION_PHASE_THREE: + _events.SetPhase(PHASE_THREE); + if (me->GetEntry() == NPC_THORIM_YS) + DoCast(SPELL_TITANIC_STORM); + break; + case ACTION_SANITY_WELLS: + { + std::list wells; + GetCreatureListWithEntryInGrid(wells, me, NPC_SANITY_WELL, 200.0f); + for (std::list::const_iterator itr = wells.begin(); itr != wells.end(); ++itr) { - // setting the phases is only for Thorim and Mimiron - case ACTION_PHASE_TWO: - _events.SetPhase(PHASE_TWO); - _events.ScheduleEvent(EVENT_DESTABILIZATION_MATRIX, urand(5000, 15000), 0, PHASE_TWO); - break; - case ACTION_PHASE_THREE: - _events.SetPhase(PHASE_THREE); - if (me->GetEntry() == NPC_THORIM_YS) - DoCast(SPELL_TITANIC_STORM); - break; - case ACTION_SANITY_WELLS: - { - std::list wells; - GetCreatureListWithEntryInGrid(wells, me, NPC_SANITY_WELL, 200.0f); - for (std::list::const_iterator itr = wells.begin(); itr != wells.end(); ++itr) - { - (*itr)->CastSpell(*itr, SPELL_SANITY_WELL); - (*itr)->CastSpell(*itr, SPELL_SANITY_WELL_VISUAL); - } - break; - } - case ACTION_FLASH_FREEZE: - DoCast(SPELL_FLASH_FREEZE_VISUAL); - _events.ScheduleEvent(EVENT_HODIRS_PROTECTIVE_GAZE, urand(25000, 30000)); - break; + (*itr)->CastSpell(*itr, SPELL_SANITY_WELL); + (*itr)->CastSpell(*itr, SPELL_SANITY_WELL_VISUAL); } + break; + } + case ACTION_FLASH_FREEZE: + DoCast(SPELL_FLASH_FREEZE_VISUAL); + _events.ScheduleEvent(EVENT_HODIRS_PROTECTIVE_GAZE, urand(25000, 30000)); + break; } + } - private: - EventMap _events; - }; + private: + EventMap _events; + }; - CreatureAI* GetAI(Creature* creature) const override - { - return GetUlduarAI(creature); - } + CreatureAI* GetAI(Creature* creature) const override + { + return GetUlduarAI(creature); + } }; class npc_yogg_saron_illusions : public CreatureScript { - public: - npc_yogg_saron_illusions() : CreatureScript("npc_yogg_saron_illusions") { } + public: + npc_yogg_saron_illusions() : CreatureScript("npc_yogg_saron_illusions") + { + } - struct npc_yogg_saron_illusionsAI : public ScriptedAI + struct npc_yogg_saron_illusionsAI : public ScriptedAI + { + npc_yogg_saron_illusionsAI(Creature* creature) : ScriptedAI(creature), _instance(creature->GetInstanceScript()) { - npc_yogg_saron_illusionsAI(Creature* creature) : ScriptedAI(creature), _instance(creature->GetInstanceScript()) { } + } - void IsSummonedBy(Unit* /*summoner*/) override - { - switch (_instance->GetData(DATA_ILLUSION)) - { - case CHAMBER_ILLUSION: - // i think the first Talk should be delayed as in this moment - // players are too far away to be able to see it - if (Creature* neltharion = me->FindNearestCreature(NPC_NELTHARION, 50.0f)) - neltharion->AI()->Talk(SAY_CHAMBER_ROLEPLAY_1); - - _events.ScheduleEvent(EVENT_CHAMBER_ROLEPLAY_1, 16000); - _events.ScheduleEvent(EVENT_CHAMBER_ROLEPLAY_2, 22000); - _events.ScheduleEvent(EVENT_CHAMBER_ROLEPLAY_3, 28000); - _events.ScheduleEvent(EVENT_CHAMBER_ROLEPLAY_4, 36000); - break; - case ICECROWN_ILLUSION: - // same here - _events.ScheduleEvent(EVENT_ICECROWN_ROLEPLAY_1, 1000); - _events.ScheduleEvent(EVENT_ICECROWN_ROLEPLAY_2, 7500); - _events.ScheduleEvent(EVENT_ICECROWN_ROLEPLAY_3, 19500); - _events.ScheduleEvent(EVENT_ICECROWN_ROLEPLAY_4, 25500); - _events.ScheduleEvent(EVENT_ICECROWN_ROLEPLAY_5, 33000); - _events.ScheduleEvent(EVENT_ICECROWN_ROLEPLAY_6, 41300); - break; - case STORMWIND_ILLUSION: - _events.ScheduleEvent(EVENT_STORMWIND_ROLEPLAY_4, 33800); // "A thousand deaths..." - _events.ScheduleEvent(EVENT_STORMWIND_ROLEPLAY_5, 38850); - _events.ScheduleEvent(EVENT_STORMWIND_ROLEPLAY_7, 58750); - // TODO: use "or one murder." sound and split the text in DB - break; - } + void IsSummonedBy(Unit* /*summoner*/) override + { + switch (_instance->GetData(DATA_ILLUSION)) + { + case CHAMBER_ILLUSION: + // i think the first Talk should be delayed as in this moment + // players are too far away to be able to see it + if (Creature* neltharion = me->FindNearestCreature(NPC_NELTHARION, 50.0f)) + neltharion->AI()->Talk(SAY_CHAMBER_ROLEPLAY_1); + + _events.ScheduleEvent(EVENT_CHAMBER_ROLEPLAY_1, 16000); + _events.ScheduleEvent(EVENT_CHAMBER_ROLEPLAY_2, 22000); + _events.ScheduleEvent(EVENT_CHAMBER_ROLEPLAY_3, 28000); + _events.ScheduleEvent(EVENT_CHAMBER_ROLEPLAY_4, 36000); + break; + case ICECROWN_ILLUSION: + // same here + _events.ScheduleEvent(EVENT_ICECROWN_ROLEPLAY_1, 1000); + _events.ScheduleEvent(EVENT_ICECROWN_ROLEPLAY_2, 7500); + _events.ScheduleEvent(EVENT_ICECROWN_ROLEPLAY_3, 19500); + _events.ScheduleEvent(EVENT_ICECROWN_ROLEPLAY_4, 25500); + _events.ScheduleEvent(EVENT_ICECROWN_ROLEPLAY_5, 33000); + _events.ScheduleEvent(EVENT_ICECROWN_ROLEPLAY_6, 41300); + break; + case STORMWIND_ILLUSION: + _events.ScheduleEvent(EVENT_STORMWIND_ROLEPLAY_4, 33800); // "A thousand deaths..." + _events.ScheduleEvent(EVENT_STORMWIND_ROLEPLAY_5, 38850); + _events.ScheduleEvent(EVENT_STORMWIND_ROLEPLAY_7, 58750); + // TODO: use "or one murder." sound and split the text in DB + break; } + } - void UpdateAI(uint32 diff) override - { - _events.Update(diff); + void UpdateAI(uint32 diff) override + { + _events.Update(diff); - while (uint32 eventId = _events.ExecuteEvent()) + while (uint32 eventId = _events.ExecuteEvent()) + { + switch (eventId) { - switch (eventId) + case EVENT_CHAMBER_ROLEPLAY_1: + if (Creature* ysera = me->FindNearestCreature(NPC_YSERA, 50.0f)) + ysera->AI()->Talk(SAY_CHAMBER_ROLEPLAY_2); + break; + case EVENT_CHAMBER_ROLEPLAY_2: + if (Creature* neltharion = me->FindNearestCreature(NPC_NELTHARION, 50.0f)) + neltharion->AI()->Talk(SAY_CHAMBER_ROLEPLAY_3); + break; + case EVENT_CHAMBER_ROLEPLAY_3: + if (Creature* malygos = me->FindNearestCreature(NPC_MALYGOS, 50.0f)) + malygos->AI()->Talk(SAY_CHAMBER_ROLEPLAY_4); + break; + case EVENT_CHAMBER_ROLEPLAY_4: + Talk(SAY_CHAMBER_ROLEPLAY_5); + break; + case EVENT_ICECROWN_ROLEPLAY_1: + if (Creature* bolvar = me->FindNearestCreature(NPC_IMMOLATED_CHAMPION, 50.0f)) { - case EVENT_CHAMBER_ROLEPLAY_1: - if (Creature* ysera = me->FindNearestCreature(NPC_YSERA, 50.0f)) - ysera->AI()->Talk(SAY_CHAMBER_ROLEPLAY_2); - break; - case EVENT_CHAMBER_ROLEPLAY_2: - if (Creature* neltharion = me->FindNearestCreature(NPC_NELTHARION, 50.0f)) - neltharion->AI()->Talk(SAY_CHAMBER_ROLEPLAY_3); - break; - case EVENT_CHAMBER_ROLEPLAY_3: - if (Creature* malygos = me->FindNearestCreature(NPC_MALYGOS, 50.0f)) - malygos->AI()->Talk(SAY_CHAMBER_ROLEPLAY_4); - break; - case EVENT_CHAMBER_ROLEPLAY_4: - Talk(SAY_CHAMBER_ROLEPLAY_5); - break; - case EVENT_ICECROWN_ROLEPLAY_1: - if (Creature* bolvar = me->FindNearestCreature(NPC_IMMOLATED_CHAMPION, 50.0f)) - { - bolvar->AI()->Talk(SAY_ICECROWN_ROLEPLAY_1); - - if (Creature* lichKing = me->FindNearestCreature(NPC_THE_LICH_KING, 50.0f)) - lichKing->CastSpell(bolvar, SPELL_DEATHGRASP); - } - break; - case EVENT_ICECROWN_ROLEPLAY_2: - if (Creature* lichKing = me->FindNearestCreature(NPC_THE_LICH_KING, 50.0f)) - lichKing->AI()->Talk(SAY_ICECROWN_ROLEPLAY_2); - break; - case EVENT_ICECROWN_ROLEPLAY_3: - if (Creature* bolvar = me->FindNearestCreature(NPC_IMMOLATED_CHAMPION, 50.0f)) - bolvar->AI()->Talk(SAY_ICECROWN_ROLEPLAY_3); - if (Creature* saurfang = me->FindNearestCreature(NPC_TURNED_CHAMPION, 50.0f)) - saurfang->AI()->DoAction(ACTION_START_ROLEPLAY); - break; - case EVENT_ICECROWN_ROLEPLAY_4: - if (Creature* lichKing = me->FindNearestCreature(NPC_THE_LICH_KING, 50.0f)) - lichKing->AI()->Talk(SAY_ICECROWN_ROLEPLAY_4); - break; - case EVENT_ICECROWN_ROLEPLAY_5: - Talk(SAY_ICECROWN_ROLEPLAY_5); - break; - case EVENT_ICECROWN_ROLEPLAY_6: - Talk(SAY_ICECROWN_ROLEPLAY_6); - break; - case EVENT_STORMWIND_ROLEPLAY_4: - Talk(SAY_STORMWIND_ROLEPLAY_4); - break; - case EVENT_STORMWIND_ROLEPLAY_5: - if (Creature* llane = me->FindNearestCreature(NPC_KING_LLANE, 50.0f)) - llane->AI()->Talk(SAY_STORMWIND_ROLEPLAY_5); - break; - case EVENT_STORMWIND_ROLEPLAY_7: - Talk(SAY_STORMWIND_ROLEPLAY_7); - break; - default: - break; + bolvar->AI()->Talk(SAY_ICECROWN_ROLEPLAY_1); + + if (Creature* lichKing = me->FindNearestCreature(NPC_THE_LICH_KING, 50.0f)) + lichKing->CastSpell(bolvar, SPELL_DEATHGRASP); } + break; + case EVENT_ICECROWN_ROLEPLAY_2: + if (Creature* lichKing = me->FindNearestCreature(NPC_THE_LICH_KING, 50.0f)) + lichKing->AI()->Talk(SAY_ICECROWN_ROLEPLAY_2); + break; + case EVENT_ICECROWN_ROLEPLAY_3: + if (Creature* bolvar = me->FindNearestCreature(NPC_IMMOLATED_CHAMPION, 50.0f)) + bolvar->AI()->Talk(SAY_ICECROWN_ROLEPLAY_3); + if (Creature* saurfang = me->FindNearestCreature(NPC_TURNED_CHAMPION, 50.0f)) + saurfang->AI()->DoAction(ACTION_START_ROLEPLAY); + break; + case EVENT_ICECROWN_ROLEPLAY_4: + if (Creature* lichKing = me->FindNearestCreature(NPC_THE_LICH_KING, 50.0f)) + lichKing->AI()->Talk(SAY_ICECROWN_ROLEPLAY_4); + break; + case EVENT_ICECROWN_ROLEPLAY_5: + Talk(SAY_ICECROWN_ROLEPLAY_5); + break; + case EVENT_ICECROWN_ROLEPLAY_6: + Talk(SAY_ICECROWN_ROLEPLAY_6); + break; + case EVENT_STORMWIND_ROLEPLAY_4: + Talk(SAY_STORMWIND_ROLEPLAY_4); + break; + case EVENT_STORMWIND_ROLEPLAY_5: + if (Creature* llane = me->FindNearestCreature(NPC_KING_LLANE, 50.0f)) + llane->AI()->Talk(SAY_STORMWIND_ROLEPLAY_5); + break; + case EVENT_STORMWIND_ROLEPLAY_7: + Talk(SAY_STORMWIND_ROLEPLAY_7); + break; + default: + break; } } + } - private: - EventMap _events; - InstanceScript* _instance; - }; + private: + EventMap _events; + InstanceScript* _instance; + }; - CreatureAI* GetAI(Creature* creature) const override - { - return GetUlduarAI(creature); - } + CreatureAI* GetAI(Creature* creature) const override + { + return GetUlduarAI(creature); + } }; class npc_garona : public CreatureScript { - public: - npc_garona() : CreatureScript("npc_garona") { } + public: + npc_garona() : CreatureScript("npc_garona") + { + } - struct npc_garonaAI : public ScriptedAI + struct npc_garonaAI : public ScriptedAI + { + npc_garonaAI(Creature* creature) : ScriptedAI(creature) { - npc_garonaAI(Creature* creature) : ScriptedAI(creature) { } + } - void Reset() override - { - _events.Reset(); + void Reset() override + { + _events.Reset(); - me->SetWalk(true); - me->GetMotionMaster()->MovePoint(0, IllusionsMiscPos[0]); + me->SetWalk(true); + me->GetMotionMaster()->MovePoint(0, IllusionsMiscPos[0]); - _events.ScheduleEvent(EVENT_STORMWIND_ROLEPLAY_1, 9250); - _events.ScheduleEvent(EVENT_STORMWIND_ROLEPLAY_2, 16700); - _events.ScheduleEvent(EVENT_STORMWIND_ROLEPLAY_3, 24150); - _events.ScheduleEvent(EVENT_STORMWIND_ROLEPLAY_6, 52700); - } + _events.ScheduleEvent(EVENT_STORMWIND_ROLEPLAY_1, 9250); + _events.ScheduleEvent(EVENT_STORMWIND_ROLEPLAY_2, 16700); + _events.ScheduleEvent(EVENT_STORMWIND_ROLEPLAY_3, 24150); + _events.ScheduleEvent(EVENT_STORMWIND_ROLEPLAY_6, 52700); + } - void UpdateAI(uint32 diff) override - { - _events.Update(diff); + void UpdateAI(uint32 diff) override + { + _events.Update(diff); - while (uint32 eventId = _events.ExecuteEvent()) + while (uint32 eventId = _events.ExecuteEvent()) + { + switch (eventId) { - switch (eventId) + case EVENT_STORMWIND_ROLEPLAY_1: + Talk(SAY_STORMWIND_ROLEPLAY_1); + break; + case EVENT_STORMWIND_ROLEPLAY_2: + Talk(SAY_STORMWIND_ROLEPLAY_2); + break; + case EVENT_STORMWIND_ROLEPLAY_3: + Talk(SAY_STORMWIND_ROLEPLAY_3); + break; + case EVENT_STORMWIND_ROLEPLAY_6: + Talk(SAY_STORMWIND_ROLEPLAY_6); + if (Creature* llane = me->FindNearestCreature(NPC_KING_LLANE, 50.0f)) { - case EVENT_STORMWIND_ROLEPLAY_1: - Talk(SAY_STORMWIND_ROLEPLAY_1); - break; - case EVENT_STORMWIND_ROLEPLAY_2: - Talk(SAY_STORMWIND_ROLEPLAY_2); - break; - case EVENT_STORMWIND_ROLEPLAY_3: - Talk(SAY_STORMWIND_ROLEPLAY_3); - break; - case EVENT_STORMWIND_ROLEPLAY_6: - Talk(SAY_STORMWIND_ROLEPLAY_6); - if (Creature* llane = me->FindNearestCreature(NPC_KING_LLANE, 50.0f)) - { - DoCast(SPELL_ASSASSINATE); - llane->CastSpell(llane, SPELL_PERMANENT_FEIGN_DEATH); - } - break; - default: - break; + DoCast(SPELL_ASSASSINATE); + llane->CastSpell(llane, SPELL_PERMANENT_FEIGN_DEATH); } + break; + default: + break; } } + } - private: - EventMap _events; - }; + private: + EventMap _events; + }; - CreatureAI* GetAI(Creature* creature) const override - { - return GetUlduarAI(creature); - } + CreatureAI* GetAI(Creature* creature) const override + { + return GetUlduarAI(creature); + } }; class npc_turned_champion : public CreatureScript { - public: - npc_turned_champion() : CreatureScript("npc_turned_champion") { } + public: + npc_turned_champion() : CreatureScript("npc_turned_champion") + { + } - struct npc_turned_championAI : public ScriptedAI + struct npc_turned_championAI : public ScriptedAI + { + npc_turned_championAI(Creature* creature) : ScriptedAI(creature) { - npc_turned_championAI(Creature* creature) : ScriptedAI(creature) { } - - void Reset() override - { - DoCast(SPELL_VERTEX_COLOR_BLACK); - } - - void MovementInform(uint32 type, uint32 pointId) override - { - if (type != POINT_MOTION_TYPE || pointId != 0) - return; + } - me->HandleEmoteCommand(EMOTE_ONESHOT_SALUTE); - } + void Reset() override + { + DoCast(SPELL_VERTEX_COLOR_BLACK); + } - void DoAction(int32 action) override - { - if (action != ACTION_START_ROLEPLAY) - return; + void MovementInform(uint32 type, uint32 pointId) override + { + if (type != POINT_MOTION_TYPE || pointId != 0) + return; - me->SetWalk(true); - me->GetMotionMaster()->MovePoint(0, IllusionsMiscPos[1]); - } - }; + me->HandleEmoteCommand(EMOTE_ONESHOT_SALUTE); + } - CreatureAI* GetAI(Creature* creature) const override + void DoAction(int32 action) override { - return GetUlduarAI(creature); + if (action != ACTION_START_ROLEPLAY) + return; + + me->SetWalk(true); + me->GetMotionMaster()->MovePoint(0, IllusionsMiscPos[1]); } + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return GetUlduarAI(creature); + } }; class npc_laughing_skull : public CreatureScript { - public: - npc_laughing_skull() : CreatureScript("npc_laughing_skull") { } + public: + npc_laughing_skull() : CreatureScript("npc_laughing_skull") + { + } - struct npc_laughing_skullAI : public ScriptedAI + struct npc_laughing_skullAI : public ScriptedAI + { + npc_laughing_skullAI(Creature* creature) : ScriptedAI(creature) { - npc_laughing_skullAI(Creature* creature) : ScriptedAI(creature) { } - - void Reset() override - { - me->SetReactState(REACT_PASSIVE); - DoCast(me, SPELL_LUNATIC_GAZE_SKULL); - } + } - // don't evade, otherwise the Lunatic Gaze aura is removed - void UpdateAI(uint32 /*diff*/) override { } - }; + void Reset() override + { + me->SetReactState(REACT_PASSIVE); + DoCast(me, SPELL_LUNATIC_GAZE_SKULL); + } - CreatureAI* GetAI(Creature* creature) const override + // don't evade, otherwise the Lunatic Gaze aura is removed + void UpdateAI(uint32 /*diff*/) override { - return GetUlduarAI(creature); } + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return GetUlduarAI(creature); + } }; -class spell_yogg_saron_target_selectors : public SpellScriptLoader // 63744, 63745, 63747, 65206 +class spell_yogg_saron_target_selectors : public SpellScriptLoader // 63744, 63745, 63747, 65206 { - public: - spell_yogg_saron_target_selectors() : SpellScriptLoader("spell_yogg_saron_target_selectors") { } + public: + spell_yogg_saron_target_selectors() : SpellScriptLoader("spell_yogg_saron_target_selectors") + { + } - class spell_yogg_saron_target_selectors_SpellScript : public SpellScript + class spell_yogg_saron_target_selectors_SpellScript : public SpellScript + { + void HandleScript(SpellEffIndex /*effIndex*/) { - void HandleScript(SpellEffIndex /*effIndex*/) - { - if (Unit* target = GetHitUnit()) - GetCaster()->CastSpell(target, uint32(GetEffectValue())); - } - - void Register() override - { - OnEffectHitTarget.Register(&spell_yogg_saron_target_selectors_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_DUMMY); - } - }; + if (Unit* target = GetHitUnit()) + GetCaster()->CastSpell(target, uint32(GetEffectValue())); + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_yogg_saron_target_selectors_SpellScript(); + OnEffectHitTarget.Register(&spell_yogg_saron_target_selectors_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_DUMMY); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_yogg_saron_target_selectors_SpellScript(); + } }; class SanityReduction : public SpellScript { - public: - SanityReduction() : SpellScript(), _stacks(0) { } - SanityReduction(uint8 stacks) : SpellScript(), _stacks(stacks) { } + public: + SanityReduction() : SpellScript(), _stacks(0) + { + } + SanityReduction(uint8 stacks) : SpellScript(), _stacks(stacks) + { + } - void RemoveSanity(SpellEffIndex /*effIndex*/) - { - if (Unit* target = GetHitUnit()) - if (Aura* sanity = target->GetAura(SPELL_SANITY)) - sanity->ModStackAmount(-int32(_stacks), AuraRemoveFlags::ByEnemySpell); - } + void RemoveSanity(SpellEffIndex /*effIndex*/) + { + if (Unit* target = GetHitUnit()) + if (Aura* sanity = target->GetAura(SPELL_SANITY)) + sanity->ModStackAmount(-int32(_stacks), AuraRemoveFlags::ByEnemySpell); + } - protected: - uint8 _stacks; + protected: + uint8 _stacks; }; class HighSanityTargetSelector { - public: - HighSanityTargetSelector() { } + public: + HighSanityTargetSelector() + { + } - bool operator()(WorldObject* object) - { - if (Unit* unit = object->ToUnit()) - if (Aura* sanity = unit->GetAura(SPELL_SANITY)) - return sanity->GetStackAmount() <= 40; - return true; - } + bool operator()(WorldObject* object) + { + if (Unit* unit = object->ToUnit()) + if (Aura* sanity = unit->GetAura(SPELL_SANITY)) + return sanity->GetStackAmount() <= 40; + return true; + } }; -class spell_yogg_saron_psychosis : public SpellScriptLoader // 63795, 65301 +class spell_yogg_saron_psychosis : public SpellScriptLoader // 63795, 65301 { - public: - spell_yogg_saron_psychosis() : SpellScriptLoader("spell_yogg_saron_psychosis") { } + public: + spell_yogg_saron_psychosis() : SpellScriptLoader("spell_yogg_saron_psychosis") + { + } - class spell_yogg_saron_psychosis_SpellScript : public SanityReduction + class spell_yogg_saron_psychosis_SpellScript : public SanityReduction + { + bool Load() override { - bool Load() override - { - _stacks = GetSpellInfo()->Id == SPELL_PSYCHOSIS ? 9 : 12; - return true; - } - - void FilterTargets(std::list& targets) - { - targets.remove_if(HighSanityTargetSelector()); - targets.remove_if(Firelands::UnitAuraCheck(true, SPELL_ILLUSION_ROOM)); - } + _stacks = GetSpellInfo()->Id == SPELL_PSYCHOSIS ? 9 : 12; + return true; + } - void Register() override - { - OnObjectAreaTargetSelect.Register(&spell_yogg_saron_psychosis_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); - OnObjectAreaTargetSelect.Register(&spell_yogg_saron_psychosis_SpellScript::FilterTargets, EFFECT_1, TARGET_UNIT_SRC_AREA_ENEMY); - OnEffectHitTarget.Register(&SanityReduction::RemoveSanity, EFFECT_1, SPELL_EFFECT_SCRIPT_EFFECT); - } - }; + void FilterTargets(std::list& targets) + { + targets.remove_if(HighSanityTargetSelector()); + targets.remove_if(Firelands::UnitAuraCheck(true, SPELL_ILLUSION_ROOM)); + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_yogg_saron_psychosis_SpellScript(); + OnObjectAreaTargetSelect.Register(&spell_yogg_saron_psychosis_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); + OnObjectAreaTargetSelect.Register(&spell_yogg_saron_psychosis_SpellScript::FilterTargets, EFFECT_1, TARGET_UNIT_SRC_AREA_ENEMY); + OnEffectHitTarget.Register(&SanityReduction::RemoveSanity, EFFECT_1, SPELL_EFFECT_SCRIPT_EFFECT); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_yogg_saron_psychosis_SpellScript(); + } }; -class spell_yogg_saron_malady_of_the_mind : public SpellScriptLoader // 63830, 63881 +class spell_yogg_saron_malady_of_the_mind : public SpellScriptLoader // 63830, 63881 { - public: - spell_yogg_saron_malady_of_the_mind() : SpellScriptLoader("spell_yogg_saron_malady_of_the_mind") { } + public: + spell_yogg_saron_malady_of_the_mind() : SpellScriptLoader("spell_yogg_saron_malady_of_the_mind") + { + } - struct spell_yogg_saron_malady_of_the_mind_SpellScript : public SanityReduction + struct spell_yogg_saron_malady_of_the_mind_SpellScript : public SanityReduction + { + spell_yogg_saron_malady_of_the_mind_SpellScript() : SanityReduction(3) { - spell_yogg_saron_malady_of_the_mind_SpellScript() : SanityReduction(3) { } - - void FilterTargets(std::list& targets) - { - targets.remove_if(HighSanityTargetSelector()); - targets.remove_if(Firelands::UnitAuraCheck(true, SPELL_ILLUSION_ROOM)); - } - - void Register() override - { - if (m_scriptSpellId == SPELL_MALADY_OF_THE_MIND) - { - OnObjectAreaTargetSelect.Register(&spell_yogg_saron_malady_of_the_mind_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); - OnObjectAreaTargetSelect.Register(&spell_yogg_saron_malady_of_the_mind_SpellScript::FilterTargets, EFFECT_1, TARGET_UNIT_SRC_AREA_ENEMY); - OnObjectAreaTargetSelect.Register(&spell_yogg_saron_malady_of_the_mind_SpellScript::FilterTargets, EFFECT_2, TARGET_UNIT_SRC_AREA_ENEMY); - } + } - OnEffectHitTarget.Register(&SanityReduction::RemoveSanity, EFFECT_2, SPELL_EFFECT_SCRIPT_EFFECT); - } - }; + void FilterTargets(std::list& targets) + { + targets.remove_if(HighSanityTargetSelector()); + targets.remove_if(Firelands::UnitAuraCheck(true, SPELL_ILLUSION_ROOM)); + } - class spell_yogg_saron_malady_of_the_mind_AuraScript : public AuraScript + void Register() override { - bool Validate(SpellInfo const* /*spell*/) override + if (m_scriptSpellId == SPELL_MALADY_OF_THE_MIND) { - return ValidateSpellInfo({ SPELL_MALADY_OF_THE_MIND_JUMP }); + OnObjectAreaTargetSelect.Register(&spell_yogg_saron_malady_of_the_mind_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); + OnObjectAreaTargetSelect.Register(&spell_yogg_saron_malady_of_the_mind_SpellScript::FilterTargets, EFFECT_1, TARGET_UNIT_SRC_AREA_ENEMY); + OnObjectAreaTargetSelect.Register(&spell_yogg_saron_malady_of_the_mind_SpellScript::FilterTargets, EFFECT_2, TARGET_UNIT_SRC_AREA_ENEMY); } - void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - if (!GetTargetApplication()->GetRemoveMode().HasFlag(AuraRemoveFlags::ByEnemySpell | AuraRemoveFlags::Expired | AuraRemoveFlags::ByDeath)) - return; - - GetTarget()->CastSpell(GetTarget(), SPELL_MALADY_OF_THE_MIND_JUMP); - } + OnEffectHitTarget.Register(&SanityReduction::RemoveSanity, EFFECT_2, SPELL_EFFECT_SCRIPT_EFFECT); + } + }; - void Register() override - { - AfterEffectRemove.Register(&spell_yogg_saron_malady_of_the_mind_AuraScript::OnRemove, EFFECT_1, SPELL_AURA_MOD_FEAR, AURA_EFFECT_HANDLE_REAL); - } - }; + class spell_yogg_saron_malady_of_the_mind_AuraScript : public AuraScript + { + bool Validate(SpellInfo const* /*spell*/) override + { + return ValidateSpellInfo({SPELL_MALADY_OF_THE_MIND_JUMP}); + } - SpellScript* GetSpellScript() const override + void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { - return new spell_yogg_saron_malady_of_the_mind_SpellScript(); + if (!GetTargetApplication()->GetRemoveMode().HasFlag(AuraRemoveFlags::ByEnemySpell | AuraRemoveFlags::Expired | AuraRemoveFlags::ByDeath)) + return; + + GetTarget()->CastSpell(GetTarget(), SPELL_MALADY_OF_THE_MIND_JUMP); } - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_yogg_saron_malady_of_the_mind_AuraScript(); + AfterEffectRemove.Register(&spell_yogg_saron_malady_of_the_mind_AuraScript::OnRemove, EFFECT_1, SPELL_AURA_MOD_FEAR, AURA_EFFECT_HANDLE_REAL); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_yogg_saron_malady_of_the_mind_SpellScript(); + } + + AuraScript* GetAuraScript() const override + { + return new spell_yogg_saron_malady_of_the_mind_AuraScript(); + } }; -class spell_yogg_saron_brain_link : public SpellScriptLoader // 63802 +class spell_yogg_saron_brain_link : public SpellScriptLoader // 63802 { - public: - spell_yogg_saron_brain_link() : SpellScriptLoader("spell_yogg_saron_brain_link") { } + public: + spell_yogg_saron_brain_link() : SpellScriptLoader("spell_yogg_saron_brain_link") + { + } - class spell_yogg_saron_brain_link_SpellScript : public SpellScript + class spell_yogg_saron_brain_link_SpellScript : public SpellScript + { + void FilterTargets(std::list& targets) { - void FilterTargets(std::list& targets) + targets.remove_if(Firelands::UnitAuraCheck(true, SPELL_ILLUSION_ROOM)); + + if (targets.size() != 2) { - targets.remove_if(Firelands::UnitAuraCheck(true, SPELL_ILLUSION_ROOM)); + targets.clear(); + return; + } - if (targets.size() != 2) - { - targets.clear(); - return; - } + if (SaraAI* ai = CAST_AI(SaraAI, GetCaster()->GetAI())) + ai->SetLinkBetween(targets.front()->GetGUID(), targets.back()->GetGUID()); + } - if (SaraAI* ai = CAST_AI(SaraAI, GetCaster()->GetAI())) - ai->SetLinkBetween(targets.front()->GetGUID(), targets.back()->GetGUID()); - } + void Register() override + { + OnObjectAreaTargetSelect.Register(&spell_yogg_saron_brain_link_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); + } + }; - void Register() override - { - OnObjectAreaTargetSelect.Register(&spell_yogg_saron_brain_link_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); - } - }; + class spell_yogg_saron_brain_link_AuraScript : public AuraScript + { + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo({SPELL_BRAIN_LINK_DAMAGE, SPELL_BRAIN_LINK_NO_DAMAGE}); + } - class spell_yogg_saron_brain_link_AuraScript : public AuraScript + void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { - bool Validate(SpellInfo const* /*spellInfo*/) override - { - return ValidateSpellInfo({ SPELL_BRAIN_LINK_DAMAGE, SPELL_BRAIN_LINK_NO_DAMAGE }); - } + Unit* caster = GetCaster(); + if (!caster) + return; - void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + if (SaraAI* ai = CAST_AI(SaraAI, caster->GetAI())) { - Unit* caster = GetCaster(); - if (!caster) - return; - - if (SaraAI* ai = CAST_AI(SaraAI, caster->GetAI())) + if (GetTargetApplication()->GetRemoveMode().HasFlag(AuraRemoveFlags::Expired)) + ai->RemoveLinkFrom(GetTarget()->GetGUID()); + else { - if (GetTargetApplication()->GetRemoveMode().HasFlag(AuraRemoveFlags::Expired)) - ai->RemoveLinkFrom(GetTarget()->GetGUID()); - else + if (Player* player = ObjectAccessor::GetPlayer(*GetTarget(), ai->GetLinkedPlayerGUID(GetTarget()->GetGUID()))) { - if (Player* player = ObjectAccessor::GetPlayer(*GetTarget(), ai->GetLinkedPlayerGUID(GetTarget()->GetGUID()))) - { - ai->RemoveLinkFrom(GetTarget()->GetGUID()); - player->RemoveAurasDueToSpell(SPELL_BRAIN_LINK); - } + ai->RemoveLinkFrom(GetTarget()->GetGUID()); + player->RemoveAurasDueToSpell(SPELL_BRAIN_LINK); } } } + } - void DummyTick(AuraEffect const* aurEff) - { - Unit* caster = GetCaster(); - if (!caster) - return; - - SaraAI* ai = CAST_AI(SaraAI, caster->GetAI()); - if (!ai) - return; + void DummyTick(AuraEffect const* aurEff) + { + Unit* caster = GetCaster(); + if (!caster) + return; - Player* linked = ObjectAccessor::GetPlayer(*GetTarget(), ai->GetLinkedPlayerGUID(GetTarget()->GetGUID())); - if (!linked) - return; + SaraAI* ai = CAST_AI(SaraAI, caster->GetAI()); + if (!ai) + return; - GetTarget()->CastSpell(linked, (GetTarget()->GetDistance(linked) > (float)aurEff->GetAmount()) ? SPELL_BRAIN_LINK_DAMAGE : SPELL_BRAIN_LINK_NO_DAMAGE, true); - } + Player* linked = ObjectAccessor::GetPlayer(*GetTarget(), ai->GetLinkedPlayerGUID(GetTarget()->GetGUID())); + if (!linked) + return; - void Register() override - { - OnEffectPeriodic.Register(&spell_yogg_saron_brain_link_AuraScript::DummyTick, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY); - OnEffectRemove.Register(&spell_yogg_saron_brain_link_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY, AURA_EFFECT_HANDLE_REAL); - } - }; + GetTarget()->CastSpell(linked, (GetTarget()->GetDistance(linked) > (float)aurEff->GetAmount()) ? SPELL_BRAIN_LINK_DAMAGE : SPELL_BRAIN_LINK_NO_DAMAGE, true); + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_yogg_saron_brain_link_SpellScript(); + OnEffectPeriodic.Register(&spell_yogg_saron_brain_link_AuraScript::DummyTick, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY); + OnEffectRemove.Register(&spell_yogg_saron_brain_link_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY, AURA_EFFECT_HANDLE_REAL); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_yogg_saron_brain_link_SpellScript(); + } + + AuraScript* GetAuraScript() const override + { + return new spell_yogg_saron_brain_link_AuraScript(); + } +}; - AuraScript* GetAuraScript() const override +class spell_yogg_saron_brain_link_damage : public SpellScriptLoader // 63803 +{ + public: + spell_yogg_saron_brain_link_damage() : SpellScriptLoader("spell_yogg_saron_brain_link_damage") + { + } + + class spell_yogg_saron_brain_link_damage_SpellScript : public SanityReduction + { + public: + spell_yogg_saron_brain_link_damage_SpellScript() : SanityReduction(2) + { + } + void Register() override { - return new spell_yogg_saron_brain_link_AuraScript(); + OnEffectHitTarget.Register(&SanityReduction::RemoveSanity, EFFECT_1, SPELL_EFFECT_SCRIPT_EFFECT); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_yogg_saron_brain_link_damage_SpellScript(); + } }; -class spell_yogg_saron_brain_link_damage : public SpellScriptLoader // 63803 +class spell_yogg_saron_boil_ominously : public SpellScriptLoader // 63030 { - public: - spell_yogg_saron_brain_link_damage() : SpellScriptLoader("spell_yogg_saron_brain_link_damage") { } + public: + spell_yogg_saron_boil_ominously() : SpellScriptLoader("spell_yogg_saron_boil_ominously") + { + } + + class spell_yogg_saron_boil_ominously_SpellScript : public SpellScript + { + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo({SPELL_SUMMON_GUARDIAN_1}); + } - class spell_yogg_saron_brain_link_damage_SpellScript : public SanityReduction + void HandleDummy(SpellEffIndex /*effIndex*/) { - public: - spell_yogg_saron_brain_link_damage_SpellScript() : SanityReduction(2) { } - void Register() override + if (Unit* target = GetHitUnit()) + if (!target->HasAura(SPELL_FLASH_FREEZE) && !GetCaster()->HasAura(SPELL_SUMMON_GUARDIAN_1) && !GetCaster()->HasAura(SPELL_SUMMON_GUARDIAN_2)) { - OnEffectHitTarget.Register(&SanityReduction::RemoveSanity, EFFECT_1, SPELL_EFFECT_SCRIPT_EFFECT); + if (Creature* caster = GetCaster()->ToCreature()) + caster->AI()->Talk(EMOTE_OMINOUS_CLOUD_PLAYER_TOUCH, target); + + GetCaster()->CastSpell(GetCaster(), SPELL_SUMMON_GUARDIAN_1, true); } - }; + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_yogg_saron_brain_link_damage_SpellScript(); + OnEffectHitTarget.Register(&spell_yogg_saron_boil_ominously_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_yogg_saron_boil_ominously_SpellScript(); + } }; -class spell_yogg_saron_boil_ominously : public SpellScriptLoader // 63030 +class spell_yogg_saron_shadow_beacon : public SpellScriptLoader // 64465 { - public: - spell_yogg_saron_boil_ominously() : SpellScriptLoader("spell_yogg_saron_boil_ominously") { } + public: + spell_yogg_saron_shadow_beacon() : SpellScriptLoader("spell_yogg_saron_shadow_beacon") + { + } - class spell_yogg_saron_boil_ominously_SpellScript : public SpellScript + class spell_yogg_saron_shadow_beacon_AuraScript : public AuraScript + { + void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { - bool Validate(SpellInfo const* /*spellInfo*/) override - { - return ValidateSpellInfo({ SPELL_SUMMON_GUARDIAN_1 }); - } - - void HandleDummy(SpellEffIndex /*effIndex*/) - { - if (Unit* target = GetHitUnit()) - if (!target->HasAura(SPELL_FLASH_FREEZE) && !GetCaster()->HasAura(SPELL_SUMMON_GUARDIAN_1) && !GetCaster()->HasAura(SPELL_SUMMON_GUARDIAN_2)) - { - if (Creature* caster = GetCaster()->ToCreature()) - caster->AI()->Talk(EMOTE_OMINOUS_CLOUD_PLAYER_TOUCH, target); - - GetCaster()->CastSpell(GetCaster(), SPELL_SUMMON_GUARDIAN_1, true); - } - } - - void Register() override - { - OnEffectHitTarget.Register(&spell_yogg_saron_boil_ominously_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); - } - }; - - SpellScript* GetSpellScript() const override - { - return new spell_yogg_saron_boil_ominously_SpellScript(); + if (Creature* target = GetTarget()->ToCreature()) + target->SetEntry(NPC_MARKED_IMMORTAL_GUARDIAN); } -}; -class spell_yogg_saron_shadow_beacon : public SpellScriptLoader // 64465 -{ - public: - spell_yogg_saron_shadow_beacon() : SpellScriptLoader("spell_yogg_saron_shadow_beacon") { } - - class spell_yogg_saron_shadow_beacon_AuraScript : public AuraScript + void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { - void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - if (Creature* target = GetTarget()->ToCreature()) - target->SetEntry(NPC_MARKED_IMMORTAL_GUARDIAN); - } - - void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - if (Creature* target = GetTarget()->ToCreature()) - target->SetEntry(NPC_IMMORTAL_GUARDIAN); - } - - void Register() override - { - AfterEffectApply.Register(&spell_yogg_saron_shadow_beacon_AuraScript::OnApply, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL, AURA_EFFECT_HANDLE_REAL); - AfterEffectRemove.Register(&spell_yogg_saron_shadow_beacon_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL, AURA_EFFECT_HANDLE_REAL); - } - }; + if (Creature* target = GetTarget()->ToCreature()) + target->SetEntry(NPC_IMMORTAL_GUARDIAN); + } - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_yogg_saron_shadow_beacon_AuraScript(); + AfterEffectApply.Register(&spell_yogg_saron_shadow_beacon_AuraScript::OnApply, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL, AURA_EFFECT_HANDLE_REAL); + AfterEffectRemove.Register(&spell_yogg_saron_shadow_beacon_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL, AURA_EFFECT_HANDLE_REAL); } + }; + + AuraScript* GetAuraScript() const override + { + return new spell_yogg_saron_shadow_beacon_AuraScript(); + } }; -class spell_yogg_saron_empowering_shadows_range_check : public SpellScriptLoader // 64466 +class spell_yogg_saron_empowering_shadows_range_check : public SpellScriptLoader // 64466 { - public: - spell_yogg_saron_empowering_shadows_range_check() : SpellScriptLoader("spell_yogg_saron_empowering_shadows_range_check") { } + public: + spell_yogg_saron_empowering_shadows_range_check() : SpellScriptLoader("spell_yogg_saron_empowering_shadows_range_check") + { + } - class spell_yogg_saron_empowering_shadows_range_check_SpellScript : public SpellScript + class spell_yogg_saron_empowering_shadows_range_check_SpellScript : public SpellScript + { + void HandleScript(SpellEffIndex /*effIndex*/) { - void HandleScript(SpellEffIndex /*effIndex*/) - { - if (Unit* target = GetHitUnit()) - target->CastSpell(GetCaster(), uint32(GetEffectValue()), true); - } - - void Register() override - { - OnEffectHitTarget.Register(&spell_yogg_saron_empowering_shadows_range_check_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - } - }; + if (Unit* target = GetHitUnit()) + target->CastSpell(GetCaster(), uint32(GetEffectValue()), true); + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_yogg_saron_empowering_shadows_range_check_SpellScript(); + OnEffectHitTarget.Register(&spell_yogg_saron_empowering_shadows_range_check_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_yogg_saron_empowering_shadows_range_check_SpellScript(); + } }; -class spell_yogg_saron_empowering_shadows_missile : public SpellScriptLoader // 64467 +class spell_yogg_saron_empowering_shadows_missile : public SpellScriptLoader // 64467 { - public: - spell_yogg_saron_empowering_shadows_missile() : SpellScriptLoader("spell_yogg_saron_empowering_shadows_missile") { } + public: + spell_yogg_saron_empowering_shadows_missile() : SpellScriptLoader("spell_yogg_saron_empowering_shadows_missile") + { + } - class spell_yogg_saron_empowering_shadows_missile_SpellScript : public SpellScript + class spell_yogg_saron_empowering_shadows_missile_SpellScript : public SpellScript + { + bool Validate(SpellInfo const* /*spellInfo*/) override { - bool Validate(SpellInfo const* /*spellInfo*/) override - { - return ValidateSpellInfo({ SPELL_EMPOWERING_SHADOWS }); - } - - void HandleScript(SpellEffIndex /*effIndex*/) - { - if (Unit* target = GetHitUnit()) - target->CastSpell((Unit*)nullptr, SPELL_EMPOWERING_SHADOWS, true); - } + return ValidateSpellInfo({SPELL_EMPOWERING_SHADOWS}); + } - void Register() override - { - OnEffectHitTarget.Register(&spell_yogg_saron_empowering_shadows_missile_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - } - }; + void HandleScript(SpellEffIndex /*effIndex*/) + { + if (Unit* target = GetHitUnit()) + target->CastSpell((Unit*)nullptr, SPELL_EMPOWERING_SHADOWS, true); + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_yogg_saron_empowering_shadows_missile_SpellScript(); + OnEffectHitTarget.Register(&spell_yogg_saron_empowering_shadows_missile_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_yogg_saron_empowering_shadows_missile_SpellScript(); + } }; // it works, but is it scripted correctly? why is it aura with 2500ms duration? -class spell_yogg_saron_constrictor_tentacle : public SpellScriptLoader // 64132 +class spell_yogg_saron_constrictor_tentacle : public SpellScriptLoader // 64132 { - public: - spell_yogg_saron_constrictor_tentacle() : SpellScriptLoader("spell_yogg_saron_constrictor_tentacle") { } + public: + spell_yogg_saron_constrictor_tentacle() : SpellScriptLoader("spell_yogg_saron_constrictor_tentacle") + { + } - class spell_yogg_saron_constrictor_tentacle_AuraScript : public AuraScript + class spell_yogg_saron_constrictor_tentacle_AuraScript : public AuraScript + { + bool Validate(SpellInfo const* /*spellInfo*/) override { - bool Validate(SpellInfo const* /*spellInfo*/) override - { - return ValidateSpellInfo({ SPELL_CONSTRICTOR_TENTACLE_SUMMON }); - } - - void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - GetTarget()->CastSpell(GetTarget(), SPELL_CONSTRICTOR_TENTACLE_SUMMON); - } + return ValidateSpellInfo({SPELL_CONSTRICTOR_TENTACLE_SUMMON}); + } - void Register() override - { - AfterEffectApply.Register(&spell_yogg_saron_constrictor_tentacle_AuraScript::OnApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); - } - }; + void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + GetTarget()->CastSpell(GetTarget(), SPELL_CONSTRICTOR_TENTACLE_SUMMON); + } - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_yogg_saron_constrictor_tentacle_AuraScript(); + AfterEffectApply.Register(&spell_yogg_saron_constrictor_tentacle_AuraScript::OnApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); } + }; + + AuraScript* GetAuraScript() const override + { + return new spell_yogg_saron_constrictor_tentacle_AuraScript(); + } }; -class spell_yogg_saron_lunge : public SpellScriptLoader // 64131 +class spell_yogg_saron_lunge : public SpellScriptLoader // 64131 { - public: - spell_yogg_saron_lunge() : SpellScriptLoader("spell_yogg_saron_lunge") { } + public: + spell_yogg_saron_lunge() : SpellScriptLoader("spell_yogg_saron_lunge") + { + } - class spell_yogg_saron_lunge_SpellScript : public SpellScript + class spell_yogg_saron_lunge_SpellScript : public SpellScript + { + bool Validate(SpellInfo const* /*spellInfo*/) override { - bool Validate(SpellInfo const* /*spellInfo*/) override - { - return ValidateSpellInfo({ SPELL_SQUEEZE }); - } - - void HandleScript(SpellEffIndex /*effIndex*/) - { - if (Unit* target = GetHitUnit()) - { - target->CastSpell(target, SPELL_SQUEEZE, true); - target->CastSpell(GetCaster(), uint32(GetEffectValue()), true); - } - } + return ValidateSpellInfo({SPELL_SQUEEZE}); + } - void Register() override + void HandleScript(SpellEffIndex /*effIndex*/) + { + if (Unit* target = GetHitUnit()) { - OnEffectHitTarget.Register(&spell_yogg_saron_lunge_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); + target->CastSpell(target, SPELL_SQUEEZE, true); + target->CastSpell(GetCaster(), uint32(GetEffectValue()), true); } - }; + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_yogg_saron_lunge_SpellScript(); + OnEffectHitTarget.Register(&spell_yogg_saron_lunge_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_yogg_saron_lunge_SpellScript(); + } }; -class spell_yogg_saron_squeeze : public SpellScriptLoader // 64125, 64126 +class spell_yogg_saron_squeeze : public SpellScriptLoader // 64125, 64126 { - public: - spell_yogg_saron_squeeze() : SpellScriptLoader("spell_yogg_saron_squeeze") { } + public: + spell_yogg_saron_squeeze() : SpellScriptLoader("spell_yogg_saron_squeeze") + { + } - class spell_yogg_saron_squeeze_AuraScript : public AuraScript + class spell_yogg_saron_squeeze_AuraScript : public AuraScript + { + void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { - void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - if (Unit* vehicle = GetTarget()->GetVehicleBase()) - if (vehicle->IsAlive()) - vehicle->KillSelf(); // should tentacle die or just release its target? - } - - void Register() override - { - AfterEffectRemove.Register(&spell_yogg_saron_squeeze_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_PERIODIC_DAMAGE, AURA_EFFECT_HANDLE_REAL); - } - }; + if (Unit* vehicle = GetTarget()->GetVehicleBase()) + if (vehicle->IsAlive()) + vehicle->KillSelf(); // should tentacle die or just release its target? + } - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_yogg_saron_squeeze_AuraScript(); + AfterEffectRemove.Register(&spell_yogg_saron_squeeze_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_PERIODIC_DAMAGE, AURA_EFFECT_HANDLE_REAL); } + }; + + AuraScript* GetAuraScript() const override + { + return new spell_yogg_saron_squeeze_AuraScript(); + } }; -class spell_yogg_saron_diminsh_power : public SpellScriptLoader // 64148 +class spell_yogg_saron_diminsh_power : public SpellScriptLoader // 64148 { - public: - spell_yogg_saron_diminsh_power() : SpellScriptLoader("spell_yogg_saron_diminsh_power") { } + public: + spell_yogg_saron_diminsh_power() : SpellScriptLoader("spell_yogg_saron_diminsh_power") + { + } - class spell_yogg_saron_diminsh_power_AuraScript : public AuraScript + class spell_yogg_saron_diminsh_power_AuraScript : public AuraScript + { + void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& /*eventInfo*/) { - void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& /*eventInfo*/) - { - PreventDefaultAction(); - if (Spell* spell = GetTarget()->GetCurrentSpell(CURRENT_CHANNELED_SPELL)) - if (spell->getState() == SPELL_STATE_CASTING) - GetTarget()->InterruptSpell(CURRENT_CHANNELED_SPELL); - } - - void Register() override - { - OnEffectProc.Register(&spell_yogg_saron_diminsh_power_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_PROC_TRIGGER_SPELL); - } - }; + PreventDefaultAction(); + if (Spell* spell = GetTarget()->GetCurrentSpell(CURRENT_CHANNELED_SPELL)) + if (spell->getState() == SPELL_STATE_CASTING) + GetTarget()->InterruptSpell(CURRENT_CHANNELED_SPELL); + } - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_yogg_saron_diminsh_power_AuraScript(); + OnEffectProc.Register(&spell_yogg_saron_diminsh_power_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_PROC_TRIGGER_SPELL); } + }; + + AuraScript* GetAuraScript() const override + { + return new spell_yogg_saron_diminsh_power_AuraScript(); + } }; // not sure about SPELL_WEAKENED part, where should it be handled? -class spell_yogg_saron_empowered : public SpellScriptLoader // 64161 +class spell_yogg_saron_empowered : public SpellScriptLoader // 64161 { - public: - spell_yogg_saron_empowered() : SpellScriptLoader("spell_yogg_saron_empowered") { } + public: + spell_yogg_saron_empowered() : SpellScriptLoader("spell_yogg_saron_empowered") + { + } - class spell_yogg_saron_empowered_AuraScript : public AuraScript + class spell_yogg_saron_empowered_AuraScript : public AuraScript + { + bool Validate(SpellInfo const* /*spellInfo*/) override { - bool Validate(SpellInfo const* /*spellInfo*/) override - { - return ValidateSpellInfo({ SPELL_EMPOWERED_BUFF, SPELL_WEAKENED }); - } - - void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - GetTarget()->CastSpell(GetTarget(), SPELL_EMPOWERED_BUFF, CastSpellExtraArgs(true).AddSpellMod(SPELLVALUE_AURA_STACK, 9)); - } + return ValidateSpellInfo({SPELL_EMPOWERED_BUFF, SPELL_WEAKENED}); + } - void OnPeriodic(AuraEffect const* /*aurEff*/) - { - Unit* target = GetTarget(); - float stack = std::ceil((target->GetHealthPct() / 10) - 1); - target->RemoveAurasDueToSpell(SPELL_EMPOWERED_BUFF); + void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + GetTarget()->CastSpell(GetTarget(), SPELL_EMPOWERED_BUFF, CastSpellExtraArgs(true).AddSpellMod(SPELLVALUE_AURA_STACK, 9)); + } - if (stack) - { - target->RemoveAurasDueToSpell(SPELL_WEAKENED); - target->CastSpell(target, SPELL_EMPOWERED_BUFF, CastSpellExtraArgs(true).AddSpellMod(SPELLVALUE_AURA_STACK, stack)); - } - else if (!target->HealthAbovePct(1) && !target->HasAura(SPELL_WEAKENED)) - target->CastSpell(target, SPELL_WEAKENED, true); - } + void OnPeriodic(AuraEffect const* /*aurEff*/) + { + Unit* target = GetTarget(); + float stack = std::ceil((target->GetHealthPct() / 10) - 1); + target->RemoveAurasDueToSpell(SPELL_EMPOWERED_BUFF); - void Register() override + if (stack) { - AfterEffectApply.Register(&spell_yogg_saron_empowered_AuraScript::OnApply, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY, AURA_EFFECT_HANDLE_REAL); - OnEffectPeriodic.Register(&spell_yogg_saron_empowered_AuraScript::OnPeriodic, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY); + target->RemoveAurasDueToSpell(SPELL_WEAKENED); + target->CastSpell(target, SPELL_EMPOWERED_BUFF, CastSpellExtraArgs(true).AddSpellMod(SPELLVALUE_AURA_STACK, stack)); } - }; + else if (!target->HealthAbovePct(1) && !target->HasAura(SPELL_WEAKENED)) + target->CastSpell(target, SPELL_WEAKENED, true); + } - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_yogg_saron_empowered_AuraScript(); + AfterEffectApply.Register(&spell_yogg_saron_empowered_AuraScript::OnApply, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY, AURA_EFFECT_HANDLE_REAL); + OnEffectPeriodic.Register(&spell_yogg_saron_empowered_AuraScript::OnPeriodic, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY); } + }; + + AuraScript* GetAuraScript() const override + { + return new spell_yogg_saron_empowered_AuraScript(); + } }; -class spell_yogg_saron_match_health : public SpellScriptLoader // 64069 +class spell_yogg_saron_match_health : public SpellScriptLoader // 64069 { - public: - spell_yogg_saron_match_health() : SpellScriptLoader("spell_yogg_saron_match_health") { } + public: + spell_yogg_saron_match_health() : SpellScriptLoader("spell_yogg_saron_match_health") + { + } - class spell_yogg_saron_match_health_SpellScript : public SpellScript + class spell_yogg_saron_match_health_SpellScript : public SpellScript + { + void HandleScript(SpellEffIndex /*effIndex*/) { - void HandleScript(SpellEffIndex /*effIndex*/) - { - if (Unit* target = GetHitUnit()) - target->SetHealth(target->CountPctFromMaxHealth((int32)GetCaster()->GetHealthPct())); - } - - void Register() override - { - OnEffectHitTarget.Register(&spell_yogg_saron_match_health_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - } - }; + if (Unit* target = GetHitUnit()) + target->SetHealth(target->CountPctFromMaxHealth((int32)GetCaster()->GetHealthPct())); + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_yogg_saron_match_health_SpellScript(); + OnEffectHitTarget.Register(&spell_yogg_saron_match_health_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_yogg_saron_match_health_SpellScript(); + } }; -class spell_yogg_saron_shattered_illusion : public SpellScriptLoader // 65238 +class spell_yogg_saron_shattered_illusion : public SpellScriptLoader // 65238 { - public: - spell_yogg_saron_shattered_illusion() : SpellScriptLoader("spell_yogg_saron_shattered_illusion") { } + public: + spell_yogg_saron_shattered_illusion() : SpellScriptLoader("spell_yogg_saron_shattered_illusion") + { + } - class spell_yogg_saron_shattered_illusion_SpellScript : public SpellScript + class spell_yogg_saron_shattered_illusion_SpellScript : public SpellScript + { + void HandleScript(SpellEffIndex /*effIndex*/) { - void HandleScript(SpellEffIndex /*effIndex*/) - { - if (Unit* target = GetHitUnit()) - target->RemoveAurasDueToSpell(uint32(GetEffectValue())); - } - - void Register() override - { - OnEffectHitTarget.Register(&spell_yogg_saron_shattered_illusion_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - } - }; + if (Unit* target = GetHitUnit()) + target->RemoveAurasDueToSpell(uint32(GetEffectValue())); + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_yogg_saron_shattered_illusion_SpellScript(); + OnEffectHitTarget.Register(&spell_yogg_saron_shattered_illusion_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_yogg_saron_shattered_illusion_SpellScript(); + } }; -class spell_yogg_saron_death_ray_warning_visual : public SpellScriptLoader // 63882 +class spell_yogg_saron_death_ray_warning_visual : public SpellScriptLoader // 63882 { - public: - spell_yogg_saron_death_ray_warning_visual() : SpellScriptLoader("spell_yogg_saron_death_ray_warning_visual") { } + public: + spell_yogg_saron_death_ray_warning_visual() : SpellScriptLoader("spell_yogg_saron_death_ray_warning_visual") + { + } - class spell_yogg_saron_death_ray_warning_visual_AuraScript : public AuraScript + class spell_yogg_saron_death_ray_warning_visual_AuraScript : public AuraScript + { + bool Validate(SpellInfo const* /*spellInfo*/) override { - bool Validate(SpellInfo const* /*spellInfo*/) override - { - return ValidateSpellInfo({ SPELL_DEATH_RAY_PERIODIC, SPELL_DEATH_RAY_DAMAGE_VISUAL }); - } - - void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - if (Unit* caster = GetCaster()) - { - caster->CastSpell(caster, SPELL_DEATH_RAY_PERIODIC, true); - caster->CastSpell((Unit*)nullptr, SPELL_DEATH_RAY_DAMAGE_VISUAL, true); - // TODO: set better movement - caster->GetMotionMaster()->MoveConfused(); - } - } + return ValidateSpellInfo({SPELL_DEATH_RAY_PERIODIC, SPELL_DEATH_RAY_DAMAGE_VISUAL}); + } - void Register() override + void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + if (Unit* caster = GetCaster()) { - AfterEffectRemove.Register(&spell_yogg_saron_death_ray_warning_visual_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); + caster->CastSpell(caster, SPELL_DEATH_RAY_PERIODIC, true); + caster->CastSpell((Unit*)nullptr, SPELL_DEATH_RAY_DAMAGE_VISUAL, true); + // TODO: set better movement + caster->GetMotionMaster()->MoveConfused(); } - }; + } - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_yogg_saron_death_ray_warning_visual_AuraScript(); + AfterEffectRemove.Register(&spell_yogg_saron_death_ray_warning_visual_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); } + }; + + AuraScript* GetAuraScript() const override + { + return new spell_yogg_saron_death_ray_warning_visual_AuraScript(); + } }; -class spell_yogg_saron_cancel_illusion_room_aura : public SpellScriptLoader // 63993 +class spell_yogg_saron_cancel_illusion_room_aura : public SpellScriptLoader // 63993 { - public: - spell_yogg_saron_cancel_illusion_room_aura() : SpellScriptLoader("spell_yogg_saron_cancel_illusion_room_aura") { } + public: + spell_yogg_saron_cancel_illusion_room_aura() : SpellScriptLoader("spell_yogg_saron_cancel_illusion_room_aura") + { + } - class spell_yogg_saron_cancel_illusion_room_aura_SpellScript : public SpellScript + class spell_yogg_saron_cancel_illusion_room_aura_SpellScript : public SpellScript + { + bool Validate(SpellInfo const* /*spellInfo*/) override { - bool Validate(SpellInfo const* /*spellInfo*/) override - { - return ValidateSpellInfo({ SPELL_TELEPORT_BACK_TO_MAIN_ROOM }); - } - - void HandleScript(SpellEffIndex /*effIndex*/) - { - if (Unit* target = GetHitUnit()) - { - target->CastSpell(target, SPELL_TELEPORT_BACK_TO_MAIN_ROOM); - target->RemoveAurasDueToSpell(uint32(GetEffectValue())); - } - } + return ValidateSpellInfo({SPELL_TELEPORT_BACK_TO_MAIN_ROOM}); + } - void Register() override + void HandleScript(SpellEffIndex /*effIndex*/) + { + if (Unit* target = GetHitUnit()) { - OnEffectHitTarget.Register(&spell_yogg_saron_cancel_illusion_room_aura_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); + target->CastSpell(target, SPELL_TELEPORT_BACK_TO_MAIN_ROOM); + target->RemoveAurasDueToSpell(uint32(GetEffectValue())); } - }; + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_yogg_saron_cancel_illusion_room_aura_SpellScript(); + OnEffectHitTarget.Register(&spell_yogg_saron_cancel_illusion_room_aura_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_yogg_saron_cancel_illusion_room_aura_SpellScript(); + } }; -class spell_yogg_saron_nondescript : public SpellScriptLoader // 64010, 64013 +class spell_yogg_saron_nondescript : public SpellScriptLoader // 64010, 64013 { - public: - spell_yogg_saron_nondescript() : SpellScriptLoader("spell_yogg_saron_nondescript") { } + public: + spell_yogg_saron_nondescript() : SpellScriptLoader("spell_yogg_saron_nondescript") + { + } - class spell_yogg_saron_nondescript_AuraScript : public AuraScript + class spell_yogg_saron_nondescript_AuraScript : public AuraScript + { + void OnRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) { - void OnRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) - { - GetTarget()->CastSpell(GetTarget(), uint32(aurEff->GetAmount()), true); - } - - void Register() override - { - AfterEffectRemove.Register(&spell_yogg_saron_nondescript_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_MOD_STUN, AURA_EFFECT_HANDLE_REAL); - } - }; + GetTarget()->CastSpell(GetTarget(), uint32(aurEff->GetAmount()), true); + } - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_yogg_saron_nondescript_AuraScript(); + AfterEffectRemove.Register(&spell_yogg_saron_nondescript_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_MOD_STUN, AURA_EFFECT_HANDLE_REAL); } + }; + + AuraScript* GetAuraScript() const override + { + return new spell_yogg_saron_nondescript_AuraScript(); + } }; -class spell_yogg_saron_revealed_tentacle : public SpellScriptLoader // 64012 +class spell_yogg_saron_revealed_tentacle : public SpellScriptLoader // 64012 { - public: - spell_yogg_saron_revealed_tentacle() : SpellScriptLoader("spell_yogg_saron_revealed_tentacle") { } + public: + spell_yogg_saron_revealed_tentacle() : SpellScriptLoader("spell_yogg_saron_revealed_tentacle") + { + } - class spell_yogg_saron_revealed_tentacle_SpellScript : public SpellScript + class spell_yogg_saron_revealed_tentacle_SpellScript : public SpellScript + { + bool Validate(SpellInfo const* /*spellInfo*/) override { - bool Validate(SpellInfo const* /*spellInfo*/) override - { - return ValidateSpellInfo({ SPELL_TENTACLE_VOID_ZONE, SPELL_GRIM_REPRISAL }); - } - - void HandleScript(SpellEffIndex /*effIndex*/) - { - if (Creature* caster = GetCaster()->ToCreature()) - { - caster->CastSpell(caster, SPELL_TENTACLE_VOID_ZONE, true); - caster->CastSpell(caster, SPELL_GRIM_REPRISAL, true); - caster->UpdateEntry(NPC_INFLUENCE_TENTACLE, caster->GetCreatureData()); - } - } + return ValidateSpellInfo({SPELL_TENTACLE_VOID_ZONE, SPELL_GRIM_REPRISAL}); + } - void Register() override + void HandleScript(SpellEffIndex /*effIndex*/) + { + if (Creature* caster = GetCaster()->ToCreature()) { - OnEffectHitTarget.Register(&spell_yogg_saron_revealed_tentacle_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_DUMMY); + caster->CastSpell(caster, SPELL_TENTACLE_VOID_ZONE, true); + caster->CastSpell(caster, SPELL_GRIM_REPRISAL, true); + caster->UpdateEntry(NPC_INFLUENCE_TENTACLE, caster->GetCreatureData()); } - }; + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_yogg_saron_revealed_tentacle_SpellScript(); + OnEffectHitTarget.Register(&spell_yogg_saron_revealed_tentacle_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_DUMMY); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_yogg_saron_revealed_tentacle_SpellScript(); + } }; -class spell_yogg_saron_grim_reprisal : public SpellScriptLoader // 63305 +class spell_yogg_saron_grim_reprisal : public SpellScriptLoader // 63305 { - public: - spell_yogg_saron_grim_reprisal() : SpellScriptLoader("spell_yogg_saron_grim_reprisal") { } + public: + spell_yogg_saron_grim_reprisal() : SpellScriptLoader("spell_yogg_saron_grim_reprisal") + { + } - class spell_yogg_saron_grim_reprisal_AuraScript : public AuraScript + class spell_yogg_saron_grim_reprisal_AuraScript : public AuraScript + { + bool Validate(SpellInfo const* /*spellInfo*/) override { - bool Validate(SpellInfo const* /*spellInfo*/) override - { - return ValidateSpellInfo({ SPELL_GRIM_REPRISAL_DAMAGE }); - } - - void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo) - { - PreventDefaultAction(); - DamageInfo* damageInfo = eventInfo.GetDamageInfo(); - if (!damageInfo || !damageInfo->GetDamage()) - return; + return ValidateSpellInfo({SPELL_GRIM_REPRISAL_DAMAGE}); + } - int32 damage = CalculatePct(static_cast(damageInfo->GetDamage()), 60); - GetTarget()->CastSpell(damageInfo->GetAttacker(), SPELL_GRIM_REPRISAL_DAMAGE, CastSpellExtraArgs(aurEff).AddSpellBP0(damage)); - } + void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo) + { + PreventDefaultAction(); + DamageInfo* damageInfo = eventInfo.GetDamageInfo(); + if (!damageInfo || !damageInfo->GetDamage()) + return; - void Register() override - { - OnEffectProc.Register(&spell_yogg_saron_grim_reprisal_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_DUMMY); - } - }; + int32 damage = CalculatePct(static_cast(damageInfo->GetDamage()), 60); + GetTarget()->CastSpell(damageInfo->GetAttacker(), SPELL_GRIM_REPRISAL_DAMAGE, CastSpellExtraArgs(aurEff).AddSpellBP0(damage)); + } - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_yogg_saron_grim_reprisal_AuraScript(); + OnEffectProc.Register(&spell_yogg_saron_grim_reprisal_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_DUMMY); } + }; + + AuraScript* GetAuraScript() const override + { + return new spell_yogg_saron_grim_reprisal_AuraScript(); + } }; -class spell_yogg_saron_induce_madness : public SpellScriptLoader // 64059 +class spell_yogg_saron_induce_madness : public SpellScriptLoader // 64059 { - public: - spell_yogg_saron_induce_madness() : SpellScriptLoader("spell_yogg_saron_induce_madness") { } + public: + spell_yogg_saron_induce_madness() : SpellScriptLoader("spell_yogg_saron_induce_madness") + { + } - class spell_yogg_saron_induce_madness_SpellScript : public SpellScript + class spell_yogg_saron_induce_madness_SpellScript : public SpellScript + { + bool Validate(SpellInfo const* /*spellInfo*/) override { - bool Validate(SpellInfo const* /*spellInfo*/) override - { - return ValidateSpellInfo({ SPELL_TELEPORT_BACK_TO_MAIN_ROOM, SPELL_SHATTERED_ILLUSION_REMOVE }); - } + return ValidateSpellInfo({SPELL_TELEPORT_BACK_TO_MAIN_ROOM, SPELL_SHATTERED_ILLUSION_REMOVE}); + } - void HandleScript(SpellEffIndex /*effIndex*/) + void HandleScript(SpellEffIndex /*effIndex*/) + { + if (Unit* target = GetHitUnit()) { - if (Unit* target = GetHitUnit()) - { - target->CastSpell(target, SPELL_TELEPORT_BACK_TO_MAIN_ROOM); - target->RemoveAurasDueToSpell(SPELL_SANITY, ObjectGuid::Empty, 0, AuraRemoveFlags::ByEnemySpell); - target->RemoveAurasDueToSpell(uint32(GetEffectValue())); - } + target->CastSpell(target, SPELL_TELEPORT_BACK_TO_MAIN_ROOM); + target->RemoveAurasDueToSpell(SPELL_SANITY, ObjectGuid::Empty, 0, AuraRemoveFlags::ByEnemySpell); + target->RemoveAurasDueToSpell(uint32(GetEffectValue())); } + } - void ClearShatteredIllusion() - { - GetCaster()->CastSpell((Unit*)nullptr, SPELL_SHATTERED_ILLUSION_REMOVE); - - if (InstanceScript* instance = GetCaster()->GetInstanceScript()) - if (Creature* voice = instance->GetCreature(DATA_VOICE_OF_YOGG_SARON)) - voice->AI()->DoAction(ACTION_TOGGLE_SHATTERED_ILLUSION); - } + void ClearShatteredIllusion() + { + GetCaster()->CastSpell((Unit*)nullptr, SPELL_SHATTERED_ILLUSION_REMOVE); - void Register() override - { - OnEffectHitTarget.Register(&spell_yogg_saron_induce_madness_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - AfterCast.Register(&spell_yogg_saron_induce_madness_SpellScript::ClearShatteredIllusion); - } - }; + if (InstanceScript* instance = GetCaster()->GetInstanceScript()) + if (Creature* voice = instance->GetCreature(DATA_VOICE_OF_YOGG_SARON)) + voice->AI()->DoAction(ACTION_TOGGLE_SHATTERED_ILLUSION); + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_yogg_saron_induce_madness_SpellScript(); + OnEffectHitTarget.Register(&spell_yogg_saron_induce_madness_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); + AfterCast.Register(&spell_yogg_saron_induce_madness_SpellScript::ClearShatteredIllusion); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_yogg_saron_induce_madness_SpellScript(); + } }; -class spell_yogg_saron_sanity : public SpellScriptLoader // 63050 +class spell_yogg_saron_sanity : public SpellScriptLoader // 63050 { - public: - spell_yogg_saron_sanity() : SpellScriptLoader("spell_yogg_saron_sanity") { } + public: + spell_yogg_saron_sanity() : SpellScriptLoader("spell_yogg_saron_sanity") + { + } - class spell_yogg_saron_sanity_SpellScript : public SpellScript - { // don't target players outside of room or handle it in SPELL_INSANE_PERIODIC? + class spell_yogg_saron_sanity_SpellScript : public SpellScript + { // don't target players outside of room or handle it in SPELL_INSANE_PERIODIC? - void ModSanityStacks() - { - GetSpell()->SetSpellValue(SPELLVALUE_AURA_STACK, 100); - } - - void Register() override - { - BeforeCast.Register(&spell_yogg_saron_sanity_SpellScript::ModSanityStacks); - } - }; - - class spell_yogg_saron_sanity_AuraScript : public AuraScript + void ModSanityStacks() { - bool Validate(SpellInfo const* /*spellInfo*/) override - { - return ValidateSpellInfo({ SPELL_LOW_SANITY_SCREEN_EFFECT, SPELL_INSANE }); - } + GetSpell()->SetSpellValue(SPELLVALUE_AURA_STACK, 100); + } - void DummyTick(AuraEffect const* /*aurEff*/) - { - if (GetTarget()->HasAura(SPELL_SANITY_WELL)) - ModStackAmount(20); + void Register() override + { + BeforeCast.Register(&spell_yogg_saron_sanity_SpellScript::ModSanityStacks); + } + }; - if (GetStackAmount() <= 40 && !GetTarget()->HasAura(SPELL_LOW_SANITY_SCREEN_EFFECT)) - GetTarget()->CastSpell(GetTarget(), SPELL_LOW_SANITY_SCREEN_EFFECT, true); - } + class spell_yogg_saron_sanity_AuraScript : public AuraScript + { + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo({SPELL_LOW_SANITY_SCREEN_EFFECT, SPELL_INSANE}); + } - void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - if (!GetTargetApplication()->GetRemoveMode().HasFlag(AuraRemoveFlags::ByEnemySpell)) - return; + void DummyTick(AuraEffect const* /*aurEff*/) + { + if (GetTarget()->HasAura(SPELL_SANITY_WELL)) + ModStackAmount(20); - if (InstanceScript* instance = GetTarget()->GetInstanceScript()) - instance->SetData(DATA_DRIVE_ME_CRAZY, uint32(false)); + if (GetStackAmount() <= 40 && !GetTarget()->HasAura(SPELL_LOW_SANITY_SCREEN_EFFECT)) + GetTarget()->CastSpell(GetTarget(), SPELL_LOW_SANITY_SCREEN_EFFECT, true); + } - GetTarget()->RemoveAurasDueToSpell(SPELL_BRAIN_LINK); + void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + if (!GetTargetApplication()->GetRemoveMode().HasFlag(AuraRemoveFlags::ByEnemySpell)) + return; - if (Unit* caster = GetCaster()) - caster->CastSpell(GetTarget(), SPELL_INSANE, true); - } + if (InstanceScript* instance = GetTarget()->GetInstanceScript()) + instance->SetData(DATA_DRIVE_ME_CRAZY, uint32(false)); - void Register() override - { - OnEffectPeriodic.Register(&spell_yogg_saron_sanity_AuraScript::DummyTick, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY); - AfterEffectRemove.Register(&spell_yogg_saron_sanity_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY, AURA_EFFECT_HANDLE_REAL); - } - }; + GetTarget()->RemoveAurasDueToSpell(SPELL_BRAIN_LINK); - SpellScript* GetSpellScript() const override - { - return new spell_yogg_saron_sanity_SpellScript(); + if (Unit* caster = GetCaster()) + caster->CastSpell(GetTarget(), SPELL_INSANE, true); } - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_yogg_saron_sanity_AuraScript(); + OnEffectPeriodic.Register(&spell_yogg_saron_sanity_AuraScript::DummyTick, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY); + AfterEffectRemove.Register(&spell_yogg_saron_sanity_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY, AURA_EFFECT_HANDLE_REAL); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_yogg_saron_sanity_SpellScript(); + } + + AuraScript* GetAuraScript() const override + { + return new spell_yogg_saron_sanity_AuraScript(); + } }; -class spell_yogg_saron_insane : public SpellScriptLoader // 63120 +class spell_yogg_saron_insane : public SpellScriptLoader // 63120 { - public: - spell_yogg_saron_insane() : SpellScriptLoader("spell_yogg_saron_insane") { } + public: + spell_yogg_saron_insane() : SpellScriptLoader("spell_yogg_saron_insane") + { + } - class spell_yogg_saron_insane_AuraScript : public AuraScript + class spell_yogg_saron_insane_AuraScript : public AuraScript + { + bool Validate(SpellInfo const* /*spellInfo*/) override { - bool Validate(SpellInfo const* /*spellInfo*/) override - { - return ValidateSpellInfo({ SPELL_INSANE_VISUAL }); - } - - void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - if (Unit* caster = GetCaster()) - if (Creature* yogg = caster->ToCreature()) - yogg->AI()->Talk(WHISPER_VOICE_INSANE, GetTarget()); + return ValidateSpellInfo({SPELL_INSANE_VISUAL}); + } - GetTarget()->CastSpell(GetTarget(), SPELL_INSANE_VISUAL, true); - } + void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + if (Unit* caster = GetCaster()) + if (Creature* yogg = caster->ToCreature()) + yogg->AI()->Talk(WHISPER_VOICE_INSANE, GetTarget()); - void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - if (GetTarget()->IsAlive()) - GetTarget()->KillSelf(); - } + GetTarget()->CastSpell(GetTarget(), SPELL_INSANE_VISUAL, true); + } - void Register() override - { - AfterEffectApply.Register(&spell_yogg_saron_insane_AuraScript::OnApply, EFFECT_0, SPELL_AURA_AOE_CHARM, AURA_EFFECT_HANDLE_REAL); - AfterEffectRemove.Register(&spell_yogg_saron_insane_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_AOE_CHARM, AURA_EFFECT_HANDLE_REAL); - } - }; + void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + if (GetTarget()->IsAlive()) + GetTarget()->KillSelf(); + } - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_yogg_saron_insane_AuraScript(); + AfterEffectApply.Register(&spell_yogg_saron_insane_AuraScript::OnApply, EFFECT_0, SPELL_AURA_AOE_CHARM, AURA_EFFECT_HANDLE_REAL); + AfterEffectRemove.Register(&spell_yogg_saron_insane_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_AOE_CHARM, AURA_EFFECT_HANDLE_REAL); } + }; + + AuraScript* GetAuraScript() const override + { + return new spell_yogg_saron_insane_AuraScript(); + } }; -class spell_yogg_saron_insane_periodic : public SpellScriptLoader // 64555 +class spell_yogg_saron_insane_periodic : public SpellScriptLoader // 64555 { - public: - spell_yogg_saron_insane_periodic() : SpellScriptLoader("spell_yogg_saron_insane_periodic") { } + public: + spell_yogg_saron_insane_periodic() : SpellScriptLoader("spell_yogg_saron_insane_periodic") + { + } - class spell_yogg_saron_insane_periodic_SpellScript : public SpellScript + class spell_yogg_saron_insane_periodic_SpellScript : public SpellScript + { + void HandleScript(SpellEffIndex /*effIndex*/) { - void HandleScript(SpellEffIndex /*effIndex*/) - { - if (Unit* target = GetHitUnit()) - GetCaster()->CastSpell(target, uint32(GetEffectValue()), true); - } - - void Register() override - { - OnEffectHitTarget.Register(&spell_yogg_saron_insane_periodic_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_DUMMY); - } - }; + if (Unit* target = GetHitUnit()) + GetCaster()->CastSpell(target, uint32(GetEffectValue()), true); + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_yogg_saron_insane_periodic_SpellScript(); + OnEffectHitTarget.Register(&spell_yogg_saron_insane_periodic_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_DUMMY); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_yogg_saron_insane_periodic_SpellScript(); + } }; class LunaticGazeTargetSelector { - public: - LunaticGazeTargetSelector(Unit* caster) : _caster(caster) { } + public: + LunaticGazeTargetSelector(Unit* caster) : _caster(caster) + { + } - bool operator()(WorldObject* object) - { - return !object->HasInArc(static_cast(M_PI), _caster); - } + bool operator()(WorldObject* object) + { + return !object->HasInArc(static_cast(M_PI), _caster); + } - private: - Unit* _caster; + private: + Unit* _caster; }; -class spell_yogg_saron_lunatic_gaze : public SpellScriptLoader // 64164, 64168 +class spell_yogg_saron_lunatic_gaze : public SpellScriptLoader // 64164, 64168 { - public: - spell_yogg_saron_lunatic_gaze() : SpellScriptLoader("spell_yogg_saron_lunatic_gaze") { } + public: + spell_yogg_saron_lunatic_gaze() : SpellScriptLoader("spell_yogg_saron_lunatic_gaze") + { + } - class spell_yogg_saron_lunatic_gaze_SpellScript : public SanityReduction + class spell_yogg_saron_lunatic_gaze_SpellScript : public SanityReduction + { + bool Load() override { - bool Load() override - { - _stacks = GetSpellInfo()->Id == SPELL_LUNATIC_GAZE_DAMAGE ? 4 : 2; - return true; - } - - void FilterTargets(std::list& targets) - { - targets.remove_if(LunaticGazeTargetSelector(GetCaster())); - } + _stacks = GetSpellInfo()->Id == SPELL_LUNATIC_GAZE_DAMAGE ? 4 : 2; + return true; + } - void Register() override - { - OnObjectAreaTargetSelect.Register(&spell_yogg_saron_lunatic_gaze_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); - OnObjectAreaTargetSelect.Register(&spell_yogg_saron_lunatic_gaze_SpellScript::FilterTargets, EFFECT_1, TARGET_UNIT_SRC_AREA_ENEMY); - OnEffectHitTarget.Register(&SanityReduction::RemoveSanity, EFFECT_1, SPELL_EFFECT_SCRIPT_EFFECT); - } - }; + void FilterTargets(std::list& targets) + { + targets.remove_if(LunaticGazeTargetSelector(GetCaster())); + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_yogg_saron_lunatic_gaze_SpellScript(); + OnObjectAreaTargetSelect.Register(&spell_yogg_saron_lunatic_gaze_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); + OnObjectAreaTargetSelect.Register(&spell_yogg_saron_lunatic_gaze_SpellScript::FilterTargets, EFFECT_1, TARGET_UNIT_SRC_AREA_ENEMY); + OnEffectHitTarget.Register(&SanityReduction::RemoveSanity, EFFECT_1, SPELL_EFFECT_SCRIPT_EFFECT); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_yogg_saron_lunatic_gaze_SpellScript(); + } }; -class spell_yogg_saron_keeper_aura : public SpellScriptLoader // 62650, 62670, 62671, 62702 +class spell_yogg_saron_keeper_aura : public SpellScriptLoader // 62650, 62670, 62671, 62702 { - public: - spell_yogg_saron_keeper_aura() : SpellScriptLoader("spell_yogg_saron_keeper_aura") { } + public: + spell_yogg_saron_keeper_aura() : SpellScriptLoader("spell_yogg_saron_keeper_aura") + { + } - class spell_yogg_saron_keeper_aura_AuraScript : public AuraScript + class spell_yogg_saron_keeper_aura_AuraScript : public AuraScript + { + bool CanApply(Unit* target) { - bool CanApply(Unit* target) - { - if (target->GetTypeId() != TYPEID_PLAYER && target != GetCaster()) - return false; - return true; - } - - void Register() override - { - DoCheckAreaTarget.Register(&spell_yogg_saron_keeper_aura_AuraScript::CanApply); - } - }; + if (target->GetTypeId() != TYPEID_PLAYER && target != GetCaster()) + return false; + return true; + } - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_yogg_saron_keeper_aura_AuraScript(); + DoCheckAreaTarget.Register(&spell_yogg_saron_keeper_aura_AuraScript::CanApply); } + }; + + AuraScript* GetAuraScript() const override + { + return new spell_yogg_saron_keeper_aura_AuraScript(); + } }; -class spell_yogg_saron_hate_to_zero : public SpellScriptLoader // 63984 +class spell_yogg_saron_hate_to_zero : public SpellScriptLoader // 63984 { - public: - spell_yogg_saron_hate_to_zero() : SpellScriptLoader("spell_yogg_saron_hate_to_zero") { } + public: + spell_yogg_saron_hate_to_zero() : SpellScriptLoader("spell_yogg_saron_hate_to_zero") + { + } - class spell_yogg_saron_hate_to_zero_SpellScript : public SpellScript + class spell_yogg_saron_hate_to_zero_SpellScript : public SpellScript + { + void HandleScript(SpellEffIndex /*effIndex*/) { - void HandleScript(SpellEffIndex /*effIndex*/) - { - if (Unit* target = GetHitUnit()) - if (target->CanHaveThreatList()) - target->GetThreatManager().ModifyThreatByPercent(GetCaster(), -100); - } - - void Register() override - { - OnEffectHitTarget.Register(&spell_yogg_saron_hate_to_zero_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_DUMMY); - } - }; + if (Unit* target = GetHitUnit()) + if (target->CanHaveThreatList()) + target->GetThreatManager().ModifyThreatByPercent(GetCaster(), -100); + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_yogg_saron_hate_to_zero_SpellScript(); + OnEffectHitTarget.Register(&spell_yogg_saron_hate_to_zero_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_DUMMY); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_yogg_saron_hate_to_zero_SpellScript(); + } }; -class spell_yogg_saron_in_the_maws_of_the_old_god : public SpellScriptLoader // 64184 +class spell_yogg_saron_in_the_maws_of_the_old_god : public SpellScriptLoader // 64184 { - public: - spell_yogg_saron_in_the_maws_of_the_old_god() : SpellScriptLoader("spell_yogg_saron_in_the_maws_of_the_old_god") { } + public: + spell_yogg_saron_in_the_maws_of_the_old_god() : SpellScriptLoader("spell_yogg_saron_in_the_maws_of_the_old_god") + { + } - class spell_yogg_saron_in_the_maws_of_the_old_god_SpellScript : public SpellScript + class spell_yogg_saron_in_the_maws_of_the_old_god_SpellScript : public SpellScript + { + SpellCastResult CheckRequirement() { - SpellCastResult CheckRequirement() + if (InstanceScript* instance = GetCaster()->GetInstanceScript()) { - if (InstanceScript* instance = GetCaster()->GetInstanceScript()) + if (Creature* yogg = instance->GetCreature(DATA_YOGG_SARON)) { - if (Creature* yogg = instance->GetCreature(DATA_YOGG_SARON)) + if (yogg->FindCurrentSpellBySpellId(SPELL_DEAFENING_ROAR)) { - if (yogg->FindCurrentSpellBySpellId(SPELL_DEAFENING_ROAR)) - { - if (GetCaster()->GetDistance(yogg) > 20.0f) - return SPELL_FAILED_OUT_OF_RANGE; - else - return SPELL_CAST_OK; - } + if (GetCaster()->GetDistance(yogg) > 20.0f) + return SPELL_FAILED_OUT_OF_RANGE; + else + return SPELL_CAST_OK; } } - - return SPELL_FAILED_CANT_DO_THAT_RIGHT_NOW; } - void Register() override - { - OnCheckCast.Register(&spell_yogg_saron_in_the_maws_of_the_old_god_SpellScript::CheckRequirement); - } - }; + return SPELL_FAILED_CANT_DO_THAT_RIGHT_NOW; + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_yogg_saron_in_the_maws_of_the_old_god_SpellScript(); + OnCheckCast.Register(&spell_yogg_saron_in_the_maws_of_the_old_god_SpellScript::CheckRequirement); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_yogg_saron_in_the_maws_of_the_old_god_SpellScript(); + } }; -class spell_yogg_saron_titanic_storm : public SpellScriptLoader // 64172 +class spell_yogg_saron_titanic_storm : public SpellScriptLoader // 64172 { - public: - spell_yogg_saron_titanic_storm() : SpellScriptLoader("spell_yogg_saron_titanic_storm") { } + public: + spell_yogg_saron_titanic_storm() : SpellScriptLoader("spell_yogg_saron_titanic_storm") + { + } - class spell_yogg_saron_titanic_storm_SpellScript : public SpellScript + class spell_yogg_saron_titanic_storm_SpellScript : public SpellScript + { + void HandleScript(SpellEffIndex /*effIndex*/) { - void HandleScript(SpellEffIndex /*effIndex*/) - { - if (Unit* target = GetHitUnit()) - GetCaster()->Kill(target); - } - - void Register() override - { - OnEffectHitTarget.Register(&spell_yogg_saron_titanic_storm_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_DUMMY); - } - }; + if (Unit* target = GetHitUnit()) + Unit::Kill(GetCaster(), target); + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_yogg_saron_titanic_storm_SpellScript(); + OnEffectHitTarget.Register(&spell_yogg_saron_titanic_storm_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_DUMMY); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_yogg_saron_titanic_storm_SpellScript(); + } }; -class spell_yogg_saron_hodirs_protective_gaze : public SpellScriptLoader // 64174 +class spell_yogg_saron_hodirs_protective_gaze : public SpellScriptLoader // 64174 { - public: - spell_yogg_saron_hodirs_protective_gaze() : SpellScriptLoader("spell_yogg_saron_hodirs_protective_gaze") { } + public: + spell_yogg_saron_hodirs_protective_gaze() : SpellScriptLoader("spell_yogg_saron_hodirs_protective_gaze") + { + } - class spell_yogg_saron_hodirs_protective_gaze_AuraScript : public AuraScript + class spell_yogg_saron_hodirs_protective_gaze_AuraScript : public AuraScript + { + bool Validate(SpellInfo const* /*spellInfo*/) override { - bool Validate(SpellInfo const* /*spellInfo*/) override - { - return ValidateSpellInfo({ SPELL_FLASH_FREEZE }); - } - - bool CanApply(Unit* target) - { - if (target->GetTypeId() != TYPEID_PLAYER && target != GetCaster()) - return false; - return true; - } + return ValidateSpellInfo({SPELL_FLASH_FREEZE}); + } - void OnAbsorb(AuraEffect* /*aurEff*/, DamageInfo& dmgInfo, uint32& absorbAmount) - { - if (dmgInfo.GetDamage() >= GetTarget()->GetHealth()) - { - absorbAmount = dmgInfo.GetDamage(); - // or absorbAmount = dmgInfo.GetDamage() - GetTarget()->GetHealth() + 1 - GetTarget()->CastSpell(GetTarget(), SPELL_FLASH_FREEZE, true); - } - else - PreventDefaultAction(); - } + bool CanApply(Unit* target) + { + if (target->GetTypeId() != TYPEID_PLAYER && target != GetCaster()) + return false; + return true; + } - void Register() override + void OnAbsorb(AuraEffect* /*aurEff*/, DamageInfo& dmgInfo, uint32& absorbAmount) + { + if (dmgInfo.GetDamage() >= GetTarget()->GetHealth()) { - DoCheckAreaTarget.Register(&spell_yogg_saron_hodirs_protective_gaze_AuraScript::CanApply); - OnEffectAbsorb.Register(&spell_yogg_saron_hodirs_protective_gaze_AuraScript::OnAbsorb, EFFECT_0); + absorbAmount = dmgInfo.GetDamage(); + // or absorbAmount = dmgInfo.GetDamage() - GetTarget()->GetHealth() + 1 + GetTarget()->CastSpell(GetTarget(), SPELL_FLASH_FREEZE, true); } - }; + else + PreventDefaultAction(); + } - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_yogg_saron_hodirs_protective_gaze_AuraScript(); + DoCheckAreaTarget.Register(&spell_yogg_saron_hodirs_protective_gaze_AuraScript::CanApply); + OnEffectAbsorb.Register(&spell_yogg_saron_hodirs_protective_gaze_AuraScript::OnAbsorb, EFFECT_0); } + }; + + AuraScript* GetAuraScript() const override + { + return new spell_yogg_saron_hodirs_protective_gaze_AuraScript(); + } }; void AddSC_boss_yogg_saron() diff --git a/src/server/scripts/Northrend/zone_borean_tundra.cpp b/src/server/scripts/Northrend/zone_borean_tundra.cpp index 5b02f3db..8175a95c 100644 --- a/src/server/scripts/Northrend/zone_borean_tundra.cpp +++ b/src/server/scripts/Northrend/zone_borean_tundra.cpp @@ -32,13 +32,13 @@ npc_nesingwary_trapper npc_lurgglbr EndContentData */ -#include "ScriptMgr.h" #include "GameObject.h" #include "MotionMaster.h" #include "ObjectAccessor.h" #include "ObjectMgr.h" #include "PhasingHandler.h" #include "Player.h" +#include "ScriptMgr.h" #include "ScriptedEscortAI.h" #include "ScriptedFollowerAI.h" #include "ScriptedGossip.h" @@ -54,19 +54,21 @@ EndContentData */ enum Sinkhole { - GO_EXPLOSIVES_CART = 188160, - NPC_SCOURGED_BURROWER = 26250, - QUEST_PLUG_THE_SINKHOLES = 11897, - SPELL_SET_CART = 46797, - SPELL_EXPLODE_CART = 46799, - SPELL_SUMMON_CART = 46798, - SPELL_SUMMON_WORM = 46800, + GO_EXPLOSIVES_CART = 188160, + NPC_SCOURGED_BURROWER = 26250, + QUEST_PLUG_THE_SINKHOLES = 11897, + SPELL_SET_CART = 46797, + SPELL_EXPLODE_CART = 46799, + SPELL_SUMMON_CART = 46798, + SPELL_SUMMON_WORM = 46800, }; class npc_sinkhole_kill_credit : public CreatureScript { -public: - npc_sinkhole_kill_credit() : CreatureScript("npc_sinkhole_kill_credit") { } + public: + npc_sinkhole_kill_credit() : CreatureScript("npc_sinkhole_kill_credit") + { + } struct npc_sinkhole_kill_creditAI : public ScriptedAI { @@ -83,7 +85,7 @@ class npc_sinkhole_kill_credit : public CreatureScript } uint32 phaseTimer; - uint8 phase; + uint8 phase; ObjectGuid casterGuid; void Reset() override @@ -104,7 +106,9 @@ class npc_sinkhole_kill_credit : public CreatureScript } } - void JustEngagedWith(Unit* /*who*/) override { } + void JustEngagedWith(Unit* /*who*/) override + { + } void UpdateAI(uint32 diff) override { @@ -115,61 +119,61 @@ class npc_sinkhole_kill_credit : public CreatureScript { switch (phase) { - case 1: - DoCast(me, SPELL_EXPLODE_CART, true); - DoCast(me, SPELL_SUMMON_CART, true); - if (GameObject* cart = me->FindNearestGameObject(GO_EXPLOSIVES_CART, 3.0f)) - cart->SetFaction(FACTION_MONSTER); - phaseTimer = 3000; - phase = 2; - break; - case 2: - if (GameObject* cart = me->FindNearestGameObject(GO_EXPLOSIVES_CART, 3.0f)) - cart->UseDoorOrButton(); - DoCast(me, SPELL_EXPLODE_CART, true); - phaseTimer = 3000; - phase = 3; - break; - case 3: - DoCast(me, SPELL_EXPLODE_CART, true); - phaseTimer = 2000; - phase = 5; // @fixme: phase 4 is missing... - break; - case 5: - DoCast(me, SPELL_SUMMON_WORM, true); - if (Unit* worm = me->FindNearestCreature(NPC_SCOURGED_BURROWER, 3.0f)) - { - worm->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - worm->HandleEmoteCommand(EMOTE_ONESHOT_EMERGE); - } - phaseTimer = 1000; - phase = 6; - break; - case 6: - DoCast(me, SPELL_EXPLODE_CART, true); - if (Unit* worm = me->FindNearestCreature(NPC_SCOURGED_BURROWER, 3.0f)) - { - me->Kill(worm); - worm->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE); - } - phaseTimer = 2000; - phase = 7; - break; - case 7: - DoCast(me, SPELL_EXPLODE_CART, true); - if (Player* caster = ObjectAccessor::GetPlayer(*me, casterGuid)) - caster->KilledMonster(me->GetCreatureTemplate(), me->GetGUID()); - phaseTimer = 5000; - phase = 8; - break; - case 8: - EnterEvadeMode(); - break; + case 1: + DoCast(me, SPELL_EXPLODE_CART, true); + DoCast(me, SPELL_SUMMON_CART, true); + if (GameObject* cart = me->FindNearestGameObject(GO_EXPLOSIVES_CART, 3.0f)) + cart->SetFaction(FACTION_MONSTER); + phaseTimer = 3000; + phase = 2; + break; + case 2: + if (GameObject* cart = me->FindNearestGameObject(GO_EXPLOSIVES_CART, 3.0f)) + cart->UseDoorOrButton(); + DoCast(me, SPELL_EXPLODE_CART, true); + phaseTimer = 3000; + phase = 3; + break; + case 3: + DoCast(me, SPELL_EXPLODE_CART, true); + phaseTimer = 2000; + phase = 5; // @fixme: phase 4 is missing... + break; + case 5: + DoCast(me, SPELL_SUMMON_WORM, true); + if (Unit* worm = me->FindNearestCreature(NPC_SCOURGED_BURROWER, 3.0f)) + { + worm->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + worm->HandleEmoteCommand(EMOTE_ONESHOT_EMERGE); + } + phaseTimer = 1000; + phase = 6; + break; + case 6: + DoCast(me, SPELL_EXPLODE_CART, true); + if (Unit* worm = me->FindNearestCreature(NPC_SCOURGED_BURROWER, 3.0f)) + { + Unit::Kill(me, worm); + worm->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE); + } + phaseTimer = 2000; + phase = 7; + break; + case 7: + DoCast(me, SPELL_EXPLODE_CART, true); + if (Player* caster = ObjectAccessor::GetPlayer(*me, casterGuid)) + caster->KilledMonster(me->GetCreatureTemplate(), me->GetGUID()); + phaseTimer = 5000; + phase = 8; + break; + case 8: + EnterEvadeMode(); + break; } - } else phaseTimer -= diff; - + } + else + phaseTimer -= diff; } - }; CreatureAI* GetAI(Creature* creature) const override @@ -184,18 +188,22 @@ class npc_sinkhole_kill_credit : public CreatureScript enum Khunok { - NPC_ORPHANED_MAMMOTH_CALF = 25861, + NPC_ORPHANED_MAMMOTH_CALF = 25861, SPELL_MAMMOTH_CALF_ESCORT_CREDIT = 46231 }; class npc_khunok_the_behemoth : public CreatureScript { -public: - npc_khunok_the_behemoth() : CreatureScript("npc_khunok_the_behemoth") { } + public: + npc_khunok_the_behemoth() : CreatureScript("npc_khunok_the_behemoth") + { + } struct npc_khunok_the_behemothAI : public ScriptedAI { - npc_khunok_the_behemothAI(Creature* creature) : ScriptedAI(creature) { } + npc_khunok_the_behemothAI(Creature* creature) : ScriptedAI(creature) + { + } void MoveInLineOfSight(Unit* who) override @@ -233,28 +241,32 @@ class npc_khunok_the_behemoth : public CreatureScript enum Corastrasza { - SPELL_SUMMON_WYRMREST_SKYTALON = 61240, - SPELL_WYRMREST_SKYTALON_RIDE_PERIODIC = 61244, + SPELL_SUMMON_WYRMREST_SKYTALON = 61240, + SPELL_WYRMREST_SKYTALON_RIDE_PERIODIC = 61244, - QUEST_ACES_HIGH_DAILY = 13414, - QUEST_ACES_HIGH = 13413 + QUEST_ACES_HIGH_DAILY = 13414, + QUEST_ACES_HIGH = 13413 }; class npc_corastrasza : public CreatureScript { -public: - npc_corastrasza() : CreatureScript("npc_corastrasza") { } + public: + npc_corastrasza() : CreatureScript("npc_corastrasza") + { + } struct npc_corastraszaAI : public ScriptedAI { - npc_corastraszaAI(Creature* creature) : ScriptedAI(creature) { } + npc_corastraszaAI(Creature* creature) : ScriptedAI(creature) + { + } bool GossipHello(Player* player) override { if (me->IsQuestGiver()) player->PrepareQuestMenu(me->GetGUID()); - if (player->GetQuestStatus(QUEST_ACES_HIGH) == QUEST_STATUS_INCOMPLETE || player->GetQuestStatus(QUEST_ACES_HIGH_DAILY) == QUEST_STATUS_INCOMPLETE) //It's the same dragon for both quests. + if (player->GetQuestStatus(QUEST_ACES_HIGH) == QUEST_STATUS_INCOMPLETE || player->GetQuestStatus(QUEST_ACES_HIGH_DAILY) == QUEST_STATUS_INCOMPLETE) // It's the same dragon for both quests. AddGossipItemFor(player, GOSSIP_ICON_CHAT, GOSSIP_ITEM_C_1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); SendGossipMenuFor(player, player->GetGossipTextId(me), me->GetGUID()); @@ -286,53 +298,56 @@ class npc_corastrasza : public CreatureScript ## npc_iruk ######*/ -#define GOSSIP_ITEM_I "" +#define GOSSIP_ITEM_I "" enum Iruk { - QUEST_SPIRITS_WATCH_OVER_US = 11961, - SPELL_CREATURE_TOTEM_OF_ISSLIRUK = 46816, - GOSSIP_TEXT_I = 12585 + QUEST_SPIRITS_WATCH_OVER_US = 11961, + SPELL_CREATURE_TOTEM_OF_ISSLIRUK = 46816, + GOSSIP_TEXT_I = 12585 }; class npc_iruk : public CreatureScript { - public: - npc_iruk() : CreatureScript("npc_iruk") { } + public: + npc_iruk() : CreatureScript("npc_iruk") + { + } - struct npc_irukAI : public ScriptedAI + struct npc_irukAI : public ScriptedAI + { + npc_irukAI(Creature* creature) : ScriptedAI(creature) { - npc_irukAI(Creature* creature) : ScriptedAI(creature) { } + } - bool GossipHello(Player* player) override - { - if (player->GetQuestStatus(QUEST_SPIRITS_WATCH_OVER_US) == QUEST_STATUS_INCOMPLETE) - AddGossipItemFor(player, GOSSIP_ICON_CHAT, GOSSIP_ITEM_I, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + bool GossipHello(Player* player) override + { + if (player->GetQuestStatus(QUEST_SPIRITS_WATCH_OVER_US) == QUEST_STATUS_INCOMPLETE) + AddGossipItemFor(player, GOSSIP_ICON_CHAT, GOSSIP_ITEM_I, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->PlayerTalkClass->SendGossipMenu(GOSSIP_TEXT_I, me->GetGUID()); - return true; - } + player->PlayerTalkClass->SendGossipMenu(GOSSIP_TEXT_I, me->GetGUID()); + return true; + } - bool GossipSelect(Player* player, uint32 /*menuId*/, uint32 gossipListId) override + bool GossipSelect(Player* player, uint32 /*menuId*/, uint32 gossipListId) override + { + uint32 const action = player->PlayerTalkClass->GetGossipOptionAction(gossipListId); + ClearGossipMenuFor(player); + switch (action) { - uint32 const action = player->PlayerTalkClass->GetGossipOptionAction(gossipListId); - ClearGossipMenuFor(player); - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: - player->CastSpell(player, SPELL_CREATURE_TOTEM_OF_ISSLIRUK, true); - CloseGossipMenuFor(player); - break; - - } - return true; + case GOSSIP_ACTION_INFO_DEF + 1: + player->CastSpell(player, SPELL_CREATURE_TOTEM_OF_ISSLIRUK, true); + CloseGossipMenuFor(player); + break; } - }; - - CreatureAI* GetAI(Creature* creature) const override - { - return new npc_irukAI(creature); + return true; } + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return new npc_irukAI(creature); + } }; /*###### @@ -341,32 +356,38 @@ class npc_iruk : public CreatureScript enum Nerubar { - NPC_WARSONG_PEON = 25270, - QUEST_TAKEN_BY_THE_SCOURGE = 11611, - SPELL_FREED_WARSONG_MAGE = 45526, - SPELL_FREED_WARSONG_SHAMAN = 45527, - SPELL_FREED_WARSONG_WARRIOR = 45514, - SPELL_FREED_WARSONG_PEON = 45532 + NPC_WARSONG_PEON = 25270, + QUEST_TAKEN_BY_THE_SCOURGE = 11611, + SPELL_FREED_WARSONG_MAGE = 45526, + SPELL_FREED_WARSONG_SHAMAN = 45527, + SPELL_FREED_WARSONG_WARRIOR = 45514, + SPELL_FREED_WARSONG_PEON = 45532 }; -const uint32 nerubarVictims[3] = -{ - SPELL_FREED_WARSONG_MAGE, SPELL_FREED_WARSONG_SHAMAN, SPELL_FREED_WARSONG_WARRIOR -}; +const uint32 nerubarVictims[3] = {SPELL_FREED_WARSONG_MAGE, SPELL_FREED_WARSONG_SHAMAN, SPELL_FREED_WARSONG_WARRIOR}; class npc_nerubar_victim : public CreatureScript { -public: - npc_nerubar_victim() : CreatureScript("npc_nerubar_victim") { } + public: + npc_nerubar_victim() : CreatureScript("npc_nerubar_victim") + { + } struct npc_nerubar_victimAI : public ScriptedAI { - npc_nerubar_victimAI(Creature* creature) : ScriptedAI(creature) { } - - void Reset() override { } - void JustEngagedWith(Unit* /*who*/) override { } - void MoveInLineOfSight(Unit* /*who*/) override { } + npc_nerubar_victimAI(Creature* creature) : ScriptedAI(creature) + { + } + void Reset() override + { + } + void JustEngagedWith(Unit* /*who*/) override + { + } + void MoveInLineOfSight(Unit* /*who*/) override + { + } void JustDied(Unit* killer) override { @@ -403,40 +424,53 @@ enum NesingwaryTrapper { GO_HIGH_QUALITY_FUR = 187983, - GO_CARIBOU_TRAP_1 = 187982, - GO_CARIBOU_TRAP_2 = 187995, - GO_CARIBOU_TRAP_3 = 187996, - GO_CARIBOU_TRAP_4 = 187997, - GO_CARIBOU_TRAP_5 = 187998, - GO_CARIBOU_TRAP_6 = 187999, - GO_CARIBOU_TRAP_7 = 188000, - GO_CARIBOU_TRAP_8 = 188001, - GO_CARIBOU_TRAP_9 = 188002, - GO_CARIBOU_TRAP_10 = 188003, - GO_CARIBOU_TRAP_11 = 188004, - GO_CARIBOU_TRAP_12 = 188005, - GO_CARIBOU_TRAP_13 = 188006, - GO_CARIBOU_TRAP_14 = 188007, - GO_CARIBOU_TRAP_15 = 188008, - - SPELL_TRAPPED = 46104, + GO_CARIBOU_TRAP_1 = 187982, + GO_CARIBOU_TRAP_2 = 187995, + GO_CARIBOU_TRAP_3 = 187996, + GO_CARIBOU_TRAP_4 = 187997, + GO_CARIBOU_TRAP_5 = 187998, + GO_CARIBOU_TRAP_6 = 187999, + GO_CARIBOU_TRAP_7 = 188000, + GO_CARIBOU_TRAP_8 = 188001, + GO_CARIBOU_TRAP_9 = 188002, + GO_CARIBOU_TRAP_10 = 188003, + GO_CARIBOU_TRAP_11 = 188004, + GO_CARIBOU_TRAP_12 = 188005, + GO_CARIBOU_TRAP_13 = 188006, + GO_CARIBOU_TRAP_14 = 188007, + GO_CARIBOU_TRAP_15 = 188008, + + SPELL_TRAPPED = 46104, // Texts - SAY_NESINGWARY_1 = 0 + SAY_NESINGWARY_1 = 0 }; #define CaribouTrapsNum 15 -const uint32 CaribouTraps[CaribouTrapsNum] = -{ - GO_CARIBOU_TRAP_1, GO_CARIBOU_TRAP_2, GO_CARIBOU_TRAP_3, GO_CARIBOU_TRAP_4, GO_CARIBOU_TRAP_5, - GO_CARIBOU_TRAP_6, GO_CARIBOU_TRAP_7, GO_CARIBOU_TRAP_8, GO_CARIBOU_TRAP_9, GO_CARIBOU_TRAP_10, - GO_CARIBOU_TRAP_11, GO_CARIBOU_TRAP_12, GO_CARIBOU_TRAP_13, GO_CARIBOU_TRAP_14, GO_CARIBOU_TRAP_15, +const uint32 CaribouTraps[CaribouTrapsNum] = { + GO_CARIBOU_TRAP_1, + GO_CARIBOU_TRAP_2, + GO_CARIBOU_TRAP_3, + GO_CARIBOU_TRAP_4, + GO_CARIBOU_TRAP_5, + GO_CARIBOU_TRAP_6, + GO_CARIBOU_TRAP_7, + GO_CARIBOU_TRAP_8, + GO_CARIBOU_TRAP_9, + GO_CARIBOU_TRAP_10, + GO_CARIBOU_TRAP_11, + GO_CARIBOU_TRAP_12, + GO_CARIBOU_TRAP_13, + GO_CARIBOU_TRAP_14, + GO_CARIBOU_TRAP_15, }; class npc_nesingwary_trapper : public CreatureScript { -public: - npc_nesingwary_trapper() : CreatureScript("npc_nesingwary_trapper") { } + public: + npc_nesingwary_trapper() : CreatureScript("npc_nesingwary_trapper") + { + } struct npc_nesingwary_trapperAI : public ScriptedAI { @@ -454,7 +488,7 @@ class npc_nesingwary_trapper : public CreatureScript } ObjectGuid go_caribouGUID; - uint8 phase; + uint8 phase; uint32 phaseTimer; void Reset() override @@ -462,9 +496,12 @@ class npc_nesingwary_trapper : public CreatureScript Initialize(); } - void JustEngagedWith(Unit* /*who*/) override { } - void MoveInLineOfSight(Unit* /*who*/) override { } - + void JustEngagedWith(Unit* /*who*/) override + { + } + void MoveInLineOfSight(Unit* /*who*/) override + { + } void JustDied(Unit* /*killer*/) override { @@ -487,61 +524,63 @@ class npc_nesingwary_trapper : public CreatureScript { switch (phase) { - case 1: - me->SetVisible(true); - phaseTimer = 2000; - phase = 2; - break; - case 2: - if (GameObject* go_fur = me->FindNearestGameObject(GO_HIGH_QUALITY_FUR, 11.0f)) - me->GetMotionMaster()->MovePoint(0, go_fur->GetPositionX(), go_fur->GetPositionY(), go_fur->GetPositionZ()); - phaseTimer = 1500; - phase = 3; - break; - case 3: - Talk(SAY_NESINGWARY_1); - phaseTimer = 2000; - phase = 4; - break; - case 4: - me->HandleEmoteCommand(EMOTE_ONESHOT_LOOT); - phaseTimer = 1000; - phase = 5; - break; - case 5: - me->HandleEmoteCommand(EMOTE_ONESHOT_NONE); - phaseTimer = 500; - phase = 6; - break; - case 6: - if (GameObject* go_fur = me->FindNearestGameObject(GO_HIGH_QUALITY_FUR, 11.0f)) - go_fur->Delete(); - phaseTimer = 500; - phase = 7; - break; - case 7: + case 1: + me->SetVisible(true); + phaseTimer = 2000; + phase = 2; + break; + case 2: + if (GameObject* go_fur = me->FindNearestGameObject(GO_HIGH_QUALITY_FUR, 11.0f)) + me->GetMotionMaster()->MovePoint(0, go_fur->GetPositionX(), go_fur->GetPositionY(), go_fur->GetPositionZ()); + phaseTimer = 1500; + phase = 3; + break; + case 3: + Talk(SAY_NESINGWARY_1); + phaseTimer = 2000; + phase = 4; + break; + case 4: + me->HandleEmoteCommand(EMOTE_ONESHOT_LOOT); + phaseTimer = 1000; + phase = 5; + break; + case 5: + me->HandleEmoteCommand(EMOTE_ONESHOT_NONE); + phaseTimer = 500; + phase = 6; + break; + case 6: + if (GameObject* go_fur = me->FindNearestGameObject(GO_HIGH_QUALITY_FUR, 11.0f)) + go_fur->Delete(); + phaseTimer = 500; + phase = 7; + break; + case 7: + { + GameObject* go_caribou = nullptr; + for (uint8 i = 0; i < CaribouTrapsNum; ++i) { - GameObject* go_caribou = nullptr; - for (uint8 i = 0; i < CaribouTrapsNum; ++i) + go_caribou = me->FindNearestGameObject(CaribouTraps[i], 5.0f); + if (go_caribou) { - go_caribou = me->FindNearestGameObject(CaribouTraps[i], 5.0f); - if (go_caribou) - { - go_caribou->SetGoState(GO_STATE_ACTIVE); - go_caribouGUID = go_caribou->GetGUID(); - break; - } + go_caribou->SetGoState(GO_STATE_ACTIVE); + go_caribouGUID = go_caribou->GetGUID(); + break; } - phase = 8; - phaseTimer = 1000; } + phase = 8; + phaseTimer = 1000; + } + break; + case 8: + DoCast(me, SPELL_TRAPPED, true); + phase = 0; break; - case 8: - DoCast(me, SPELL_TRAPPED, true); - phase = 0; - break; } - } else phaseTimer -= diff; + } + else + phaseTimer -= diff; } }; @@ -557,144 +596,148 @@ class npc_nesingwary_trapper : public CreatureScript enum Lurgglbr { - QUEST_ESCAPE_WINTERFIN_CAVERNS = 11570, + QUEST_ESCAPE_WINTERFIN_CAVERNS = 11570, - GO_CAGE = 187369, + GO_CAGE = 187369, - SAY_START_1 = 0, - SAY_START_2 = 1, - SAY_END_1 = 2, - SAY_END_2 = 3 + SAY_START_1 = 0, + SAY_START_2 = 1, + SAY_END_1 = 2, + SAY_END_2 = 3 }; class npc_lurgglbr : public CreatureScript { - public: - npc_lurgglbr() : CreatureScript("npc_lurgglbr") { } + public: + npc_lurgglbr() : CreatureScript("npc_lurgglbr") + { + } - struct npc_lurgglbrAI : public EscortAI + struct npc_lurgglbrAI : public EscortAI + { + npc_lurgglbrAI(Creature* creature) : EscortAI(creature) { - npc_lurgglbrAI(Creature* creature) : EscortAI(creature) - { - Initialize(); - } + Initialize(); + } - void Initialize() - { - IntroTimer = 0; - IntroPhase = 0; - } + void Initialize() + { + IntroTimer = 0; + IntroPhase = 0; + } + + uint32 IntroTimer; + uint32 IntroPhase; - uint32 IntroTimer; - uint32 IntroPhase; + void Reset() override + { + if (!HasEscortState(STATE_ESCORT_ESCORTING)) + Initialize(); + } - void Reset() override + void WaypointReached(uint32 waypointId, uint32 /*pathId*/) override + { + switch (waypointId) { - if (!HasEscortState(STATE_ESCORT_ESCORTING)) - Initialize(); + case 0: + IntroPhase = 1; + IntroTimer = 2000; + break; + case 41: + SetEscortPaused(true); + IntroPhase = 4; + IntroTimer = 2000; + break; } + } - void WaypointReached(uint32 waypointId, uint32 /*pathId*/) override + void UpdateAI(uint32 diff) override + { + if (IntroPhase) { - switch (waypointId) + if (IntroTimer <= diff) { - case 0: - IntroPhase = 1; - IntroTimer = 2000; + switch (IntroPhase) + { + case 1: + if (Player* player = GetPlayerForEscort()) + Talk(SAY_START_1, player); + IntroPhase = 2; + IntroTimer = 7500; + break; + case 2: + Talk(SAY_START_2); + IntroPhase = 3; + IntroTimer = 7500; + break; + case 3: + me->SetReactState(REACT_DEFENSIVE); + IntroPhase = 0; + IntroTimer = 0; + break; + case 4: + Talk(SAY_END_1); + IntroPhase = 5; + IntroTimer = 8000; + break; + case 5: + if (Player* player = GetPlayerForEscort()) + Talk(SAY_END_2, player); + IntroPhase = 6; + IntroTimer = 2500; break; - case 41: - SetEscortPaused(true); - IntroPhase = 4; - IntroTimer = 2000; + case 6: + if (Player* player = GetPlayerForEscort()) + player->AreaExploredOrEventHappens(QUEST_ESCAPE_WINTERFIN_CAVERNS); + IntroPhase = 7; + IntroTimer = 2500; break; + case 7: + me->DespawnOrUnsummon(); + IntroPhase = 0; + IntroTimer = 0; + break; + } } + else + IntroTimer -= diff; } + EscortAI::UpdateAI(diff); - void UpdateAI(uint32 diff) override + if (!UpdateVictim()) + return; + } + + void QuestAccept(Player* player, Quest const* quest) override + { + if (quest->GetQuestId() == QUEST_ESCAPE_WINTERFIN_CAVERNS) { - if (IntroPhase) + if (GameObject* go = me->FindNearestGameObject(GO_CAGE, 5.0f)) { - if (IntroTimer <= diff) - { - switch (IntroPhase) - { - case 1: - if (Player* player = GetPlayerForEscort()) - Talk(SAY_START_1, player); - IntroPhase = 2; - IntroTimer = 7500; - break; - case 2: - Talk(SAY_START_2); - IntroPhase = 3; - IntroTimer = 7500; - break; - case 3: - me->SetReactState(REACT_DEFENSIVE); - IntroPhase = 0; - IntroTimer = 0; - break; - case 4: - Talk(SAY_END_1); - IntroPhase = 5; - IntroTimer = 8000; - break; - case 5: - if (Player* player = GetPlayerForEscort()) - Talk(SAY_END_2, player); - IntroPhase = 6; - IntroTimer = 2500; - break; - case 6: - if (Player* player = GetPlayerForEscort()) - player->AreaExploredOrEventHappens(QUEST_ESCAPE_WINTERFIN_CAVERNS); - IntroPhase = 7; - IntroTimer = 2500; - break; - case 7: - me->DespawnOrUnsummon(); - IntroPhase = 0; - IntroTimer = 0; - break; - } - } else IntroTimer -= diff; + go->SetRespawnTime(0); + go->UseDoorOrButton(20000); } - EscortAI::UpdateAI(diff); - if (!UpdateVictim()) - return; - } + Start(true, false, player->GetGUID()); - void QuestAccept(Player* player, Quest const* quest) override - { - if (quest->GetQuestId() == QUEST_ESCAPE_WINTERFIN_CAVERNS) + switch (player->GetTeam()) { - if (GameObject* go = me->FindNearestGameObject(GO_CAGE, 5.0f)) - { - go->SetRespawnTime(0); - go->UseDoorOrButton(20000); - } - - Start(true, false, player->GetGUID()); - - switch (player->GetTeam()) - { - case ALLIANCE: - me->SetFaction(FACTION_ESCORTEE_A_PASSIVE); - break; - default: - case HORDE: - me->SetFaction(FACTION_ESCORTEE_H_PASSIVE); - break; - } + case ALLIANCE: + me->SetFaction(FACTION_ESCORTEE_A_PASSIVE); + break; + default: + case HORDE: + me->SetFaction(FACTION_ESCORTEE_H_PASSIVE); + break; } } - }; - - CreatureAI* GetAI(Creature* creature) const override - { - return new npc_lurgglbrAI(creature); } + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return new npc_lurgglbrAI(creature); + } }; enum red_dragonblood @@ -705,8 +748,10 @@ enum red_dragonblood class spell_red_dragonblood : public SpellScriptLoader { -public: - spell_red_dragonblood() : SpellScriptLoader("spell_red_dragonblood") { } + public: + spell_red_dragonblood() : SpellScriptLoader("spell_red_dragonblood") + { + } class spell_red_dragonblood_AuraScript : public AuraScript { @@ -724,7 +769,7 @@ class spell_red_dragonblood : public SpellScriptLoader GetCaster()->CastSpell(GetCaster(), SPELL_DRAKE_HATCHLING_SUBDUED, true); owner->SetFaction(35); owner->SetImmuneToAll(true); - owner->DespawnOrUnsummon(3 * MINUTE*IN_MILLISECONDS); + owner->DespawnOrUnsummon(3 * MINUTE * IN_MILLISECONDS); } void Register() @@ -745,50 +790,52 @@ class spell_red_dragonblood : public SpellScriptLoader enum Thassarian { - QUEST_LAST_RITES = 12019, + QUEST_LAST_RITES = 12019, SPELL_TRANSFORM_VALANAR = 46753, - SPELL_STUN = 46957, - SPELL_SHADOW_BOLT = 15537, - - NPC_IMAGE_LICH_KING = 26203, - NPC_COUNSELOR_TALBOT = 25301, - NPC_PRINCE_VALANAR = 28189, - NPC_GENERAL_ARLOS = 25250, - NPC_LERYSSA = 25251, - - SAY_THASSARIAN_1 = 0, - SAY_THASSARIAN_2 = 1, - SAY_THASSARIAN_3 = 2, - SAY_THASSARIAN_4 = 3, - SAY_THASSARIAN_5 = 4, - SAY_THASSARIAN_6 = 5, - SAY_THASSARIAN_7 = 6, - - SAY_TALBOT_1 = 0, - SAY_TALBOT_2 = 1, - SAY_TALBOT_3 = 2, - SAY_TALBOT_4 = 3, - - SAY_LICH_1 = 0, - SAY_LICH_2 = 1, - SAY_LICH_3 = 2, - - SAY_ARLOS_1 = 0, - SAY_ARLOS_2 = 1, - - SAY_LERYSSA_1 = 0, - SAY_LERYSSA_2 = 1, - SAY_LERYSSA_3 = 2, - SAY_LERYSSA_4 = 3 + SPELL_STUN = 46957, + SPELL_SHADOW_BOLT = 15537, + + NPC_IMAGE_LICH_KING = 26203, + NPC_COUNSELOR_TALBOT = 25301, + NPC_PRINCE_VALANAR = 28189, + NPC_GENERAL_ARLOS = 25250, + NPC_LERYSSA = 25251, + + SAY_THASSARIAN_1 = 0, + SAY_THASSARIAN_2 = 1, + SAY_THASSARIAN_3 = 2, + SAY_THASSARIAN_4 = 3, + SAY_THASSARIAN_5 = 4, + SAY_THASSARIAN_6 = 5, + SAY_THASSARIAN_7 = 6, + + SAY_TALBOT_1 = 0, + SAY_TALBOT_2 = 1, + SAY_TALBOT_3 = 2, + SAY_TALBOT_4 = 3, + + SAY_LICH_1 = 0, + SAY_LICH_2 = 1, + SAY_LICH_3 = 2, + + SAY_ARLOS_1 = 0, + SAY_ARLOS_2 = 1, + + SAY_LERYSSA_1 = 0, + SAY_LERYSSA_2 = 1, + SAY_LERYSSA_3 = 2, + SAY_LERYSSA_4 = 3 }; -#define GOSSIP_ITEM_T "Let's do this, Thassarian. It's now or never." +#define GOSSIP_ITEM_T "Let's do this, Thassarian. It's now or never." class npc_thassarian : public CreatureScript { -public: - npc_thassarian() : CreatureScript("npc_thassarian") { } + public: + npc_thassarian() : CreatureScript("npc_thassarian") + { + } struct npc_thassarianAI : public EscortAI { @@ -842,28 +889,28 @@ class npc_thassarian : public CreatureScript switch (waypointId) { - case 3: - SetEscortPaused(true); - if (Creature* arthas = me->SummonCreature(NPC_IMAGE_LICH_KING, 3730.313f, 3518.689f, 473.324f, 1.562f, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 120000)) - { - arthasGUID = arthas->GetGUID(); - arthas->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - arthas->SetReactState(REACT_PASSIVE); - arthas->SetWalk(true); - arthas->GetMotionMaster()->MovePoint(0, 3737.374756f, 3564.841309f, 477.433014f); - } - if (Creature* talbot = me->SummonCreature(NPC_COUNSELOR_TALBOT, 3747.23f, 3614.936f, 473.321f, 4.462012f, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 120000)) - { - talbotGUID = talbot->GetGUID(); - talbot->SetWalk(true); - talbot->GetMotionMaster()->MovePoint(0, 3738.000977f, 3568.882080f, 477.433014f); - } - me->SetWalk(false); - break; - case 4: - SetEscortPaused(true); - phase = 7; - break; + case 3: + SetEscortPaused(true); + if (Creature* arthas = me->SummonCreature(NPC_IMAGE_LICH_KING, 3730.313f, 3518.689f, 473.324f, 1.562f, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 120000)) + { + arthasGUID = arthas->GetGUID(); + arthas->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + arthas->SetReactState(REACT_PASSIVE); + arthas->SetWalk(true); + arthas->GetMotionMaster()->MovePoint(0, 3737.374756f, 3564.841309f, 477.433014f); + } + if (Creature* talbot = me->SummonCreature(NPC_COUNSELOR_TALBOT, 3747.23f, 3614.936f, 473.321f, 4.462012f, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 120000)) + { + talbotGUID = talbot->GetGUID(); + talbot->SetWalk(true); + talbot->GetMotionMaster()->MovePoint(0, 3738.000977f, 3568.882080f, 477.433014f); + } + me->SetWalk(false); + break; + case 4: + SetEscortPaused(true); + phase = 7; + break; } } @@ -880,7 +927,7 @@ class npc_thassarian : public CreatureScript if (arlosInPosition && leryssaInPosition) { - arlosInPosition = false; + arlosInPosition = false; leryssaInPosition = false; Talk(SAY_THASSARIAN_1); SetEscortPaused(false); @@ -892,152 +939,154 @@ class npc_thassarian : public CreatureScript Creature* arthas = ObjectAccessor::GetCreature(*me, arthasGUID); switch (phase) { - case 1: - if (talbot) - talbot->SetStandState(UNIT_STAND_STATE_KNEEL); - phaseTimer = 3000; - ++phase; - break; + case 1: + if (talbot) + talbot->SetStandState(UNIT_STAND_STATE_KNEEL); + phaseTimer = 3000; + ++phase; + break; - case 2: - if (talbot) - { - talbot->UpdateEntry(NPC_PRINCE_VALANAR); - talbot->SetFaction(14); - talbot->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - talbot->SetReactState(REACT_PASSIVE); - } - phaseTimer = 5000; - ++phase; - break; + case 2: + if (talbot) + { + talbot->UpdateEntry(NPC_PRINCE_VALANAR); + talbot->SetFaction(14); + talbot->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + talbot->SetReactState(REACT_PASSIVE); + } + phaseTimer = 5000; + ++phase; + break; - case 3: - if (talbot) - talbot->AI()->Talk(SAY_TALBOT_1); - phaseTimer = 5000; - ++phase; - break; + case 3: + if (talbot) + talbot->AI()->Talk(SAY_TALBOT_1); + phaseTimer = 5000; + ++phase; + break; - case 4: - if (arthas) - arthas->AI()->Talk(SAY_LICH_1); - phaseTimer = 5000; - ++phase; - break; + case 4: + if (arthas) + arthas->AI()->Talk(SAY_LICH_1); + phaseTimer = 5000; + ++phase; + break; - case 5: - if (talbot) - talbot->AI()->Talk(SAY_TALBOT_2); - phaseTimer = 5000; - ++phase; - break; + case 5: + if (talbot) + talbot->AI()->Talk(SAY_TALBOT_2); + phaseTimer = 5000; + ++phase; + break; - case 6: - if (Creature* arlos = me->SummonCreature(NPC_GENERAL_ARLOS, 3745.527100f, 3615.655029f, 473.321533f, 4.447805f, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 120000)) - { - arlosGUID = arlos->GetGUID(); - arlos->SetWalk(true); - arlos->GetMotionMaster()->MovePoint(0, 3735.570068f, 3572.419922f, 477.441010f); - } - if (Creature* leryssa = me->SummonCreature(NPC_LERYSSA, 3749.654541f, 3614.959717f, 473.323486f, 4.524959f, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 120000)) - { - leryssaGUID = leryssa->GetGUID(); - leryssa->SetWalk(false); - leryssa->SetReactState(REACT_PASSIVE); - leryssa->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - leryssa->GetMotionMaster()->MovePoint(0, 3741.969971f, 3571.439941f, 477.441010f); - } - phaseTimer = 2000; - phase = 0; - break; + case 6: + if (Creature* arlos = me->SummonCreature(NPC_GENERAL_ARLOS, 3745.527100f, 3615.655029f, 473.321533f, 4.447805f, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 120000)) + { + arlosGUID = arlos->GetGUID(); + arlos->SetWalk(true); + arlos->GetMotionMaster()->MovePoint(0, 3735.570068f, 3572.419922f, 477.441010f); + } + if (Creature* leryssa = me->SummonCreature(NPC_LERYSSA, 3749.654541f, 3614.959717f, 473.323486f, 4.524959f, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 120000)) + { + leryssaGUID = leryssa->GetGUID(); + leryssa->SetWalk(false); + leryssa->SetReactState(REACT_PASSIVE); + leryssa->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + leryssa->GetMotionMaster()->MovePoint(0, 3741.969971f, 3571.439941f, 477.441010f); + } + phaseTimer = 2000; + phase = 0; + break; - case 7: - Talk(SAY_THASSARIAN_2); - phaseTimer = 5000; - ++phase; - break; + case 7: + Talk(SAY_THASSARIAN_2); + phaseTimer = 5000; + ++phase; + break; - case 8: - if (arthas && talbot) - { - arthas->SetOrientationTowards(me); //The client doesen't update with the new orientation :l - talbot->SetStandState(UNIT_STAND_STATE_STAND); - arthas->AI()->Talk(SAY_LICH_2); - } - phaseTimer = 5000; - phase = 9; - break; + case 8: + if (arthas && talbot) + { + arthas->SetOrientationTowards(me); // The client doesen't update with the new orientation :l + talbot->SetStandState(UNIT_STAND_STATE_STAND); + arthas->AI()->Talk(SAY_LICH_2); + } + phaseTimer = 5000; + phase = 9; + break; - case 9: - Talk(SAY_THASSARIAN_3); - phaseTimer = 5000; - phase = 10; - break; + case 9: + Talk(SAY_THASSARIAN_3); + phaseTimer = 5000; + phase = 10; + break; - case 10: - if (talbot) - talbot->AI()->Talk(SAY_TALBOT_3); - phaseTimer = 5000; - phase = 11; - break; + case 10: + if (talbot) + talbot->AI()->Talk(SAY_TALBOT_3); + phaseTimer = 5000; + phase = 11; + break; - case 11: - if (arthas) - arthas->AI()->Talk(SAY_LICH_3); - phaseTimer = 5000; - phase = 12; - break; + case 11: + if (arthas) + arthas->AI()->Talk(SAY_LICH_3); + phaseTimer = 5000; + phase = 12; + break; - case 12: - if (talbot) - talbot->AI()->Talk(SAY_TALBOT_4); - phaseTimer = 2000; - phase = 13; - break; + case 12: + if (talbot) + talbot->AI()->Talk(SAY_TALBOT_4); + phaseTimer = 2000; + phase = 13; + break; - case 13: - if (arthas) - arthas->RemoveFromWorld(); - ++phase; - break; + case 13: + if (arthas) + arthas->RemoveFromWorld(); + ++phase; + break; - case 14: - me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - if (talbot) - { - talbot->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - talbot->SetReactState(REACT_AGGRESSIVE); - talbot->CastSpell(me, SPELL_SHADOW_BOLT, false); - } - phaseTimer = 1500; - ++phase; - break; + case 14: + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + if (talbot) + { + talbot->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + talbot->SetReactState(REACT_AGGRESSIVE); + talbot->CastSpell(me, SPELL_SHADOW_BOLT, false); + } + phaseTimer = 1500; + ++phase; + break; - case 15: - me->SetReactState(REACT_AGGRESSIVE); - AttackStart(talbot); - phase = 0; - break; + case 15: + me->SetReactState(REACT_AGGRESSIVE); + AttackStart(talbot); + phase = 0; + break; - case 16: - me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER); - phaseTimer = 20000; - ++phase; - break; + case 16: + me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER); + phaseTimer = 20000; + ++phase; + break; - case 17: - if (Creature* leryssa = ObjectAccessor::GetCreature(*me, leryssaGUID)) - leryssa->RemoveFromWorld(); - if (Creature* arlos= ObjectAccessor::GetCreature(*me, arlosGUID)) - arlos->RemoveFromWorld(); - if (talbot) - talbot->RemoveFromWorld(); - me->RemoveStandFlags(UNIT_STAND_STATE_SIT); - SetEscortPaused(false); - phaseTimer = 0; - phase = 0; + case 17: + if (Creature* leryssa = ObjectAccessor::GetCreature(*me, leryssaGUID)) + leryssa->RemoveFromWorld(); + if (Creature* arlos = ObjectAccessor::GetCreature(*me, arlosGUID)) + arlos->RemoveFromWorld(); + if (talbot) + talbot->RemoveFromWorld(); + me->RemoveStandFlags(UNIT_STAND_STATE_SIT); + SetEscortPaused(false); + phaseTimer = 0; + phase = 0; } - } else phaseTimer -= diff; + } + else + phaseTimer -= diff; if (!UpdateVictim()) return; @@ -1079,10 +1128,10 @@ class npc_thassarian : public CreatureScript ClearGossipMenuFor(player); switch (action) { - case GOSSIP_ACTION_INFO_DEF + 1: - Start(true, false, player->GetGUID()); - SetMaxPlayerDistance(200.0f); - break; + case GOSSIP_ACTION_INFO_DEF + 1: + Start(true, false, player->GetGUID()); + SetMaxPlayerDistance(200.0f); + break; } return true; } @@ -1100,12 +1149,16 @@ class npc_thassarian : public CreatureScript class npc_image_lich_king : public CreatureScript { -public: - npc_image_lich_king() : CreatureScript("npc_image_lich_king") { } + public: + npc_image_lich_king() : CreatureScript("npc_image_lich_king") + { + } struct npc_image_lich_kingAI : public ScriptedAI { - npc_image_lich_kingAI(Creature* creature) : ScriptedAI(creature) { } + npc_image_lich_kingAI(Creature* creature) : ScriptedAI(creature) + { + } void Reset() override { @@ -1135,12 +1188,16 @@ class npc_image_lich_king : public CreatureScript class npc_general_arlos : public CreatureScript { -public: - npc_general_arlos() : CreatureScript("npc_general_arlos") { } + public: + npc_general_arlos() : CreatureScript("npc_general_arlos") + { + } struct npc_general_arlosAI : public ScriptedAI { - npc_general_arlosAI(Creature* creature) : ScriptedAI(creature) { } + npc_general_arlosAI(Creature* creature) : ScriptedAI(creature) + { + } void MovementInform(uint32 uiType, uint32 /*uiId*/) override { @@ -1167,14 +1224,16 @@ class npc_general_arlos : public CreatureScript enum CounselorTalbot { - SPELL_DEFLECTION = 51009, - SPELL_SOUL_BLAST = 50992, + SPELL_DEFLECTION = 51009, + SPELL_SOUL_BLAST = 50992, }; class npc_counselor_talbot : public CreatureScript { -public: - npc_counselor_talbot() : CreatureScript("npc_counselor_talbot") { } + public: + npc_counselor_talbot() : CreatureScript("npc_counselor_talbot") + { + } struct npc_counselor_talbotAI : public ScriptedAI { @@ -1237,21 +1296,24 @@ class npc_counselor_talbot : public CreatureScript DoCastVictim(SPELL_SHADOW_BOLT); shadowBoltTimer = urand(5000, 12000); } - else shadowBoltTimer -= diff; + else + shadowBoltTimer -= diff; if (deflectionTimer <= diff) { DoCastVictim(SPELL_DEFLECTION); deflectionTimer = urand(20000, 25000); } - else deflectionTimer -= diff; + else + deflectionTimer -= diff; if (soulBlastTimer <= diff) { DoCastVictim(SPELL_SOUL_BLAST); - soulBlastTimer = urand(12000, 18000); + soulBlastTimer = urand(12000, 18000); } - else soulBlastTimer -= diff; + else + soulBlastTimer -= diff; } DoMeleeAttackIfReady(); @@ -1293,8 +1355,10 @@ class npc_counselor_talbot : public CreatureScript class npc_leryssa : public CreatureScript { -public: - npc_leryssa() : CreatureScript("npc_leryssa") { } + public: + npc_leryssa() : CreatureScript("npc_leryssa") + { + } struct npc_leryssaAI : public ScriptedAI { @@ -1335,7 +1399,7 @@ class npc_leryssa : public CreatureScript me->SetStandState(UNIT_STAND_STATE_SIT); if (me->IsSummon()) if (Unit* summoner = me->ToTempSummon()->GetSummoner()) - summoner->SetStandState(UNIT_STAND_STATE_SIT); + summoner->SetStandState(UNIT_STAND_STATE_SIT); phaseTimer = 1500; phase = 1; } @@ -1349,59 +1413,61 @@ class npc_leryssa : public CreatureScript { switch (phase) { - case 1: - if (me->IsSummon()) - if (Unit* summoner = me->ToTempSummon()->GetSummoner()) - if (Creature* thassarian = summoner->ToCreature()) - thassarian->AI()->Talk(SAY_THASSARIAN_4); - phaseTimer = 5000; - ++phase; - break; - case 2: - Talk(SAY_LERYSSA_2); - phaseTimer = 5000; - ++phase; - break; - case 3: - if (me->IsSummon()) - if (Unit* summoner = me->ToTempSummon()->GetSummoner()) - if (Creature* thassarian = summoner->ToCreature()) - thassarian->AI()->Talk(SAY_THASSARIAN_5); - phaseTimer = 5000; - ++phase; - break; - case 4: - Talk(SAY_LERYSSA_3); - phaseTimer = 5000; - ++phase; - break; - case 5: - if (me->IsSummon()) - if (Unit* summoner = me->ToTempSummon()->GetSummoner()) - if (Creature* thassarian = summoner->ToCreature()) - thassarian->AI()->Talk(SAY_THASSARIAN_6); - phaseTimer = 5000; - ++phase; - break; + case 1: + if (me->IsSummon()) + if (Unit* summoner = me->ToTempSummon()->GetSummoner()) + if (Creature* thassarian = summoner->ToCreature()) + thassarian->AI()->Talk(SAY_THASSARIAN_4); + phaseTimer = 5000; + ++phase; + break; + case 2: + Talk(SAY_LERYSSA_2); + phaseTimer = 5000; + ++phase; + break; + case 3: + if (me->IsSummon()) + if (Unit* summoner = me->ToTempSummon()->GetSummoner()) + if (Creature* thassarian = summoner->ToCreature()) + thassarian->AI()->Talk(SAY_THASSARIAN_5); + phaseTimer = 5000; + ++phase; + break; + case 4: + Talk(SAY_LERYSSA_3); + phaseTimer = 5000; + ++phase; + break; + case 5: + if (me->IsSummon()) + if (Unit* summoner = me->ToTempSummon()->GetSummoner()) + if (Creature* thassarian = summoner->ToCreature()) + thassarian->AI()->Talk(SAY_THASSARIAN_6); + phaseTimer = 5000; + ++phase; + break; - case 6: - Talk(SAY_LERYSSA_4); - phaseTimer = 5000; - ++phase; - break; - case 7: - if (me->IsSummon()) - if (Unit* summoner = me->ToTempSummon()->GetSummoner()) - if (Creature* thassarian = summoner->ToCreature()) - { - thassarian->AI()->Talk(SAY_THASSARIAN_7); - ENSURE_AI(npc_thassarian::npc_thassarianAI, thassarian->GetAI())->phase = 16; - } - phaseTimer = 5000; - phase = 0; - break; + case 6: + Talk(SAY_LERYSSA_4); + phaseTimer = 5000; + ++phase; + break; + case 7: + if (me->IsSummon()) + if (Unit* summoner = me->ToTempSummon()->GetSummoner()) + if (Creature* thassarian = summoner->ToCreature()) + { + thassarian->AI()->Talk(SAY_THASSARIAN_7); + ENSURE_AI(npc_thassarian::npc_thassarianAI, thassarian->GetAI())->phase = 16; + } + phaseTimer = 5000; + phase = 0; + break; } - } else phaseTimer -= diff; + } + else + phaseTimer -= diff; if (!UpdateVictim()) return; @@ -1422,18 +1488,20 @@ class npc_leryssa : public CreatureScript enum BerylSorcerer { - NPC_CAPTURED_BERLY_SORCERER = 25474, - NPC_LIBRARIAN_DONATHAN = 25262, + NPC_CAPTURED_BERLY_SORCERER = 25474, + NPC_LIBRARIAN_DONATHAN = 25262, - SPELL_ARCANE_CHAINS = 45611, - SPELL_COSMETIC_CHAINS = 54324, - SPELL_COSMETIC_ENSLAVE_CHAINS_SELF = 45631 + SPELL_ARCANE_CHAINS = 45611, + SPELL_COSMETIC_CHAINS = 54324, + SPELL_COSMETIC_ENSLAVE_CHAINS_SELF = 45631 }; // To-do: this entire thing is a hack clusterfuck. Rewrite recommended struct npc_beryl_sorcerer : public FollowerAI { - npc_beryl_sorcerer(Creature* creature) : FollowerAI(creature), _enslaved(false) { } + npc_beryl_sorcerer(Creature* creature) : FollowerAI(creature), _enslaved(false) + { + } void Reset() override { @@ -1480,7 +1548,8 @@ struct npc_beryl_sorcerer : public FollowerAI DoMeleeAttackIfReady(); } -private: + + private: bool _enslaved; }; @@ -1489,23 +1558,25 @@ struct npc_beryl_sorcerer : public FollowerAI ######*/ enum ImprisionedBerylSorcerer { - SPELL_NEURAL_NEEDLE = 45634, + SPELL_NEURAL_NEEDLE = 45634, - NPC_IMPRISONED_BERYL_SORCERER = 25478, + NPC_IMPRISONED_BERYL_SORCERER = 25478, - SAY_IMPRISIONED_BERYL_1 = 0, - SAY_IMPRISIONED_BERYL_2 = 1, - SAY_IMPRISIONED_BERYL_3 = 2, - SAY_IMPRISIONED_BERYL_4 = 3, - SAY_IMPRISIONED_BERYL_5 = 4, - SAY_IMPRISIONED_BERYL_6 = 5, - SAY_IMPRISIONED_BERYL_7 = 6 + SAY_IMPRISIONED_BERYL_1 = 0, + SAY_IMPRISIONED_BERYL_2 = 1, + SAY_IMPRISIONED_BERYL_3 = 2, + SAY_IMPRISIONED_BERYL_4 = 3, + SAY_IMPRISIONED_BERYL_5 = 4, + SAY_IMPRISIONED_BERYL_6 = 5, + SAY_IMPRISIONED_BERYL_7 = 6 }; class npc_imprisoned_beryl_sorcerer : public CreatureScript { -public: - npc_imprisoned_beryl_sorcerer() : CreatureScript("npc_imprisoned_beryl_sorcerer") { } + public: + npc_imprisoned_beryl_sorcerer() : CreatureScript("npc_imprisoned_beryl_sorcerer") + { + } struct npc_imprisoned_beryl_sorcererAI : public ScriptedAI { @@ -1565,28 +1636,28 @@ class npc_imprisoned_beryl_sorcerer : public CreatureScript uint32 step = caster->GetAuraCount(SPELL_NEURAL_NEEDLE) + 1; switch (step) { - case 1: - Talk(SAY_IMPRISIONED_BERYL_1); - break; - case 2: - Talk(SAY_IMPRISIONED_BERYL_2, caster); - break; - case 3: - Talk(SAY_IMPRISIONED_BERYL_3); - break; - case 4: - Talk(SAY_IMPRISIONED_BERYL_4); - break; - case 5: - Talk(SAY_IMPRISIONED_BERYL_5); - caster->KilledMonsterCredit(NPC_IMPRISONED_BERYL_SORCERER); - break; - case 6: - Talk(SAY_IMPRISIONED_BERYL_6, caster); - break; - case 7: - Talk(SAY_IMPRISIONED_BERYL_7); - break; + case 1: + Talk(SAY_IMPRISIONED_BERYL_1); + break; + case 2: + Talk(SAY_IMPRISIONED_BERYL_2, caster); + break; + case 3: + Talk(SAY_IMPRISIONED_BERYL_3); + break; + case 4: + Talk(SAY_IMPRISIONED_BERYL_4); + break; + case 5: + Talk(SAY_IMPRISIONED_BERYL_5); + caster->KilledMonsterCredit(NPC_IMPRISONED_BERYL_SORCERER); + break; + case 6: + Talk(SAY_IMPRISIONED_BERYL_6, caster); + break; + case 7: + Talk(SAY_IMPRISIONED_BERYL_7); + break; } } } @@ -1603,24 +1674,28 @@ class npc_imprisoned_beryl_sorcerer : public CreatureScript ######*/ enum MootooTheYounger { - SAY_1 = 0, - SAY_2 = 1, - SAY_3 = 2, - SAY_4 = 3, - SAY_5 = 4, - - NPC_MOOTOO_THE_YOUNGER = 25504, - QUEST_ESCAPING_THE_MIST = 11664 + SAY_1 = 0, + SAY_2 = 1, + SAY_3 = 2, + SAY_4 = 3, + SAY_5 = 4, + + NPC_MOOTOO_THE_YOUNGER = 25504, + QUEST_ESCAPING_THE_MIST = 11664 }; class npc_mootoo_the_younger : public CreatureScript { -public: - npc_mootoo_the_younger() : CreatureScript("npc_mootoo_the_younger") { } + public: + npc_mootoo_the_younger() : CreatureScript("npc_mootoo_the_younger") + { + } struct npc_mootoo_the_youngerAI : public EscortAI { - npc_mootoo_the_youngerAI(Creature* creature) : EscortAI(creature) { } + npc_mootoo_the_youngerAI(Creature* creature) : EscortAI(creature) + { + } void QuestAccept(Player* player, Quest const* quest) override { @@ -1628,12 +1703,12 @@ class npc_mootoo_the_younger : public CreatureScript { switch (player->GetTeam()) { - case ALLIANCE: - me->SetFaction(FACTION_ESCORTEE_A_PASSIVE); - break; - case HORDE: - me->SetFaction(FACTION_ESCORTEE_H_PASSIVE); - break; + case ALLIANCE: + me->SetFaction(FACTION_ESCORTEE_A_PASSIVE); + break; + case HORDE: + me->SetFaction(FACTION_ESCORTEE_H_PASSIVE); + break; } me->SetStandState(UNIT_STAND_STATE_STAND); Talk(SAY_1, player); @@ -1648,7 +1723,7 @@ class npc_mootoo_the_younger : public CreatureScript void JustDied(Unit* /*killer*/) override { - if (Player* player=GetPlayerForEscort()) + if (Player* player = GetPlayerForEscort()) player->FailQuest(QUEST_ESCAPING_THE_MIST); } @@ -1660,25 +1735,25 @@ class npc_mootoo_the_younger : public CreatureScript switch (waypointId) { - case 10: - me->HandleEmoteCommand(EMOTE_ONESHOT_EXCLAMATION); - Talk(SAY_2); - break; - case 12: - Talk(SAY_3); - me->HandleEmoteCommand(EMOTE_ONESHOT_LOOT); - break; - case 16: - Talk(SAY_4); - me->HandleEmoteCommand(EMOTE_ONESHOT_EXCLAMATION); - break; - case 20: - PhasingHandler::RemovePhase(me, 170, true); - Talk(SAY_5); - me->HandleEmoteCommand(EMOTE_ONESHOT_EXCLAMATION); - player->GroupEventHappens(QUEST_ESCAPING_THE_MIST, me); - SetRun(true); - break; + case 10: + me->HandleEmoteCommand(EMOTE_ONESHOT_EXCLAMATION); + Talk(SAY_2); + break; + case 12: + Talk(SAY_3); + me->HandleEmoteCommand(EMOTE_ONESHOT_LOOT); + break; + case 16: + Talk(SAY_4); + me->HandleEmoteCommand(EMOTE_ONESHOT_EXCLAMATION); + break; + case 20: + PhasingHandler::RemovePhase(me, 170, true); + Talk(SAY_5); + me->HandleEmoteCommand(EMOTE_ONESHOT_EXCLAMATION); + player->GroupEventHappens(QUEST_ESCAPING_THE_MIST, me); + SetRun(true); + break; } } }; @@ -1695,17 +1770,19 @@ class npc_mootoo_the_younger : public CreatureScript enum BonkerTogglevolt { - NPC_BONKER_TOGGLEVOLT = 25589, - QUEST_GET_ME_OUTA_HERE = 11673, + NPC_BONKER_TOGGLEVOLT = 25589, + QUEST_GET_ME_OUTA_HERE = 11673, - SAY_BONKER_1 = 0, - SAY_BONKER_2 = 1 + SAY_BONKER_1 = 0, + SAY_BONKER_2 = 1 }; class npc_bonker_togglevolt : public CreatureScript { -public: - npc_bonker_togglevolt() : CreatureScript("npc_bonker_togglevolt") { } + public: + npc_bonker_togglevolt() : CreatureScript("npc_bonker_togglevolt") + { + } struct npc_bonker_togglevoltAI : public EscortAI { @@ -1754,7 +1831,8 @@ class npc_bonker_togglevolt : public CreatureScript } DoMeleeAttackIfReady(); } - else Bonker_agro=0; + else + Bonker_agro = 0; } void WaypointReached(uint32 waypointId, uint32 /*pathId*/) override @@ -1765,9 +1843,9 @@ class npc_bonker_togglevolt : public CreatureScript switch (waypointId) { - case 29: - player->GroupEventHappens(QUEST_GET_ME_OUTA_HERE, me); - break; + case 29: + player->GroupEventHappens(QUEST_GET_ME_OUTA_HERE, me); + break; } } }; @@ -1784,45 +1862,42 @@ class npc_bonker_togglevolt : public CreatureScript enum HelpThemselves { - QUEST_CANNOT_HELP_THEMSELVES = 11876, - GO_MAMMOTH_TRAP_1 = 188022, - GO_MAMMOTH_TRAP_2 = 188024, - GO_MAMMOTH_TRAP_3 = 188025, - GO_MAMMOTH_TRAP_4 = 188026, - GO_MAMMOTH_TRAP_5 = 188027, - GO_MAMMOTH_TRAP_6 = 188028, - GO_MAMMOTH_TRAP_7 = 188029, - GO_MAMMOTH_TRAP_8 = 188030, - GO_MAMMOTH_TRAP_9 = 188031, - GO_MAMMOTH_TRAP_10 = 188032, - GO_MAMMOTH_TRAP_11 = 188033, - GO_MAMMOTH_TRAP_12 = 188034, - GO_MAMMOTH_TRAP_13 = 188035, - GO_MAMMOTH_TRAP_14 = 188036, - GO_MAMMOTH_TRAP_15 = 188037, - GO_MAMMOTH_TRAP_16 = 188038, - GO_MAMMOTH_TRAP_17 = 188039, - GO_MAMMOTH_TRAP_18 = 188040, - GO_MAMMOTH_TRAP_19 = 188041, - GO_MAMMOTH_TRAP_20 = 188042, - GO_MAMMOTH_TRAP_21 = 188043, - GO_MAMMOTH_TRAP_22 = 188044, + QUEST_CANNOT_HELP_THEMSELVES = 11876, + GO_MAMMOTH_TRAP_1 = 188022, + GO_MAMMOTH_TRAP_2 = 188024, + GO_MAMMOTH_TRAP_3 = 188025, + GO_MAMMOTH_TRAP_4 = 188026, + GO_MAMMOTH_TRAP_5 = 188027, + GO_MAMMOTH_TRAP_6 = 188028, + GO_MAMMOTH_TRAP_7 = 188029, + GO_MAMMOTH_TRAP_8 = 188030, + GO_MAMMOTH_TRAP_9 = 188031, + GO_MAMMOTH_TRAP_10 = 188032, + GO_MAMMOTH_TRAP_11 = 188033, + GO_MAMMOTH_TRAP_12 = 188034, + GO_MAMMOTH_TRAP_13 = 188035, + GO_MAMMOTH_TRAP_14 = 188036, + GO_MAMMOTH_TRAP_15 = 188037, + GO_MAMMOTH_TRAP_16 = 188038, + GO_MAMMOTH_TRAP_17 = 188039, + GO_MAMMOTH_TRAP_18 = 188040, + GO_MAMMOTH_TRAP_19 = 188041, + GO_MAMMOTH_TRAP_20 = 188042, + GO_MAMMOTH_TRAP_21 = 188043, + GO_MAMMOTH_TRAP_22 = 188044, }; #define MammothTrapsNum 22 -const uint32 MammothTraps[MammothTrapsNum] = -{ - GO_MAMMOTH_TRAP_1, GO_MAMMOTH_TRAP_2, GO_MAMMOTH_TRAP_3, GO_MAMMOTH_TRAP_4, GO_MAMMOTH_TRAP_5, - GO_MAMMOTH_TRAP_6, GO_MAMMOTH_TRAP_7, GO_MAMMOTH_TRAP_8, GO_MAMMOTH_TRAP_9, GO_MAMMOTH_TRAP_10, - GO_MAMMOTH_TRAP_11, GO_MAMMOTH_TRAP_12, GO_MAMMOTH_TRAP_13, GO_MAMMOTH_TRAP_14, GO_MAMMOTH_TRAP_15, - GO_MAMMOTH_TRAP_16, GO_MAMMOTH_TRAP_17, GO_MAMMOTH_TRAP_18, GO_MAMMOTH_TRAP_19, GO_MAMMOTH_TRAP_20, - GO_MAMMOTH_TRAP_21, GO_MAMMOTH_TRAP_22 -}; +const uint32 MammothTraps[MammothTrapsNum] = {GO_MAMMOTH_TRAP_1, GO_MAMMOTH_TRAP_2, GO_MAMMOTH_TRAP_3, GO_MAMMOTH_TRAP_4, GO_MAMMOTH_TRAP_5, GO_MAMMOTH_TRAP_6, GO_MAMMOTH_TRAP_7, GO_MAMMOTH_TRAP_8, + GO_MAMMOTH_TRAP_9, GO_MAMMOTH_TRAP_10, GO_MAMMOTH_TRAP_11, GO_MAMMOTH_TRAP_12, GO_MAMMOTH_TRAP_13, GO_MAMMOTH_TRAP_14, GO_MAMMOTH_TRAP_15, GO_MAMMOTH_TRAP_16, GO_MAMMOTH_TRAP_17, + GO_MAMMOTH_TRAP_18, GO_MAMMOTH_TRAP_19, GO_MAMMOTH_TRAP_20, GO_MAMMOTH_TRAP_21, GO_MAMMOTH_TRAP_22}; class npc_trapped_mammoth_calf : public CreatureScript { -public: - npc_trapped_mammoth_calf() : CreatureScript("npc_trapped_mammoth_calf") { } + public: + npc_trapped_mammoth_calf() : CreatureScript("npc_trapped_mammoth_calf") + { + } struct npc_trapped_mammoth_calfAI : public ScriptedAI { @@ -1866,7 +1941,8 @@ class npc_trapped_mammoth_calf : public CreatureScript me->GetMotionMaster()->MovePoint(0, pos); bStarted = false; } - else uiTimer -= diff; + else + uiTimer -= diff; } } @@ -1908,21 +1984,25 @@ class npc_trapped_mammoth_calf : public CreatureScript enum NotSoBig { - QUEST_YOU_RE_NOT_SO_BIG_NOW = 11653, - SPELL_AURA_NOTSOBIG_1 = 45672, - SPELL_AURA_NOTSOBIG_2 = 45673, - SPELL_AURA_NOTSOBIG_3 = 45677, - SPELL_AURA_NOTSOBIG_4 = 45681 + QUEST_YOU_RE_NOT_SO_BIG_NOW = 11653, + SPELL_AURA_NOTSOBIG_1 = 45672, + SPELL_AURA_NOTSOBIG_2 = 45673, + SPELL_AURA_NOTSOBIG_3 = 45677, + SPELL_AURA_NOTSOBIG_4 = 45681 }; class npc_magmoth_crusher : public CreatureScript { -public: - npc_magmoth_crusher() : CreatureScript("npc_magmoth_crusher") { } + public: + npc_magmoth_crusher() : CreatureScript("npc_magmoth_crusher") + { + } struct npc_magmoth_crusherAI : public ScriptedAI { - npc_magmoth_crusherAI(Creature* creature) : ScriptedAI(creature) { } + npc_magmoth_crusherAI(Creature* creature) : ScriptedAI(creature) + { + } void JustDied(Unit* killer) override { @@ -1932,8 +2012,7 @@ class npc_magmoth_crusher : public CreatureScript Player* player = killer->ToPlayer(); if (player->GetQuestStatus(QUEST_YOU_RE_NOT_SO_BIG_NOW) == QUEST_STATUS_INCOMPLETE && - (me->HasAura(SPELL_AURA_NOTSOBIG_1) || me->HasAura(SPELL_AURA_NOTSOBIG_2) || - me->HasAura(SPELL_AURA_NOTSOBIG_3) || me->HasAura(SPELL_AURA_NOTSOBIG_4))) + (me->HasAura(SPELL_AURA_NOTSOBIG_1) || me->HasAura(SPELL_AURA_NOTSOBIG_2) || me->HasAura(SPELL_AURA_NOTSOBIG_3) || me->HasAura(SPELL_AURA_NOTSOBIG_4))) { Quest const* qInfo = sObjectMgr->GetQuestTemplate(QUEST_YOU_RE_NOT_SO_BIG_NOW); if (qInfo) @@ -1954,14 +2033,16 @@ class npc_magmoth_crusher : public CreatureScript enum Valiancekeepcannons { - GO_VALIANCE_KEEP_CANNON_1 = 187560, - GO_VALIANCE_KEEP_CANNON_2 = 188692 + GO_VALIANCE_KEEP_CANNON_1 = 187560, + GO_VALIANCE_KEEP_CANNON_2 = 188692 }; class npc_valiance_keep_cannoneer : public CreatureScript { -public: - npc_valiance_keep_cannoneer() : CreatureScript("npc_valiance_keep_cannoneer") { } + public: + npc_valiance_keep_cannoneer() : CreatureScript("npc_valiance_keep_cannoneer") + { + } struct npc_valiance_keep_cannoneerAI : public ScriptedAI { @@ -1994,7 +2075,8 @@ class npc_valiance_keep_cannoneer : public CreatureScript pCannon->Use(me); uiTimer = urand(13000, 18000); } - else uiTimer -= diff; + else + uiTimer -= diff; if (!UpdateVictim()) return; @@ -2018,16 +2100,18 @@ enum Spells enum NPCs { - NPC_TRANSITUS_SHIELD_DUMMY = 27306, - NPC_WARMAGE_HOLLISTER = 27906, - NPC_WARMAGE_CALANDRA = 27173, - NPC_WARMAGE_WATKINS = 27904 + NPC_TRANSITUS_SHIELD_DUMMY = 27306, + NPC_WARMAGE_HOLLISTER = 27906, + NPC_WARMAGE_CALANDRA = 27173, + NPC_WARMAGE_WATKINS = 27904 }; class npc_warmage_coldarra : public CreatureScript { -public: - npc_warmage_coldarra() : CreatureScript("npc_warmage_coldarra") { } + public: + npc_warmage_coldarra() : CreatureScript("npc_warmage_coldarra") + { + } struct npc_warmage_coldarraAI : public ScriptedAI { @@ -2041,16 +2125,20 @@ class npc_warmage_coldarra : public CreatureScript m_uiTimer = 0; } - uint32 m_uiTimer; //Timer until recast + uint32 m_uiTimer; // Timer until recast void Reset() override { Initialize(); } - void JustEngagedWith(Unit* /*who*/) override { } + void JustEngagedWith(Unit* /*who*/) override + { + } - void AttackStart(Unit* /*who*/) override { } + void AttackStart(Unit* /*who*/) override + { + } void UpdateAI(uint32 uiDiff) override { @@ -2061,51 +2149,52 @@ class npc_warmage_coldarra : public CreatureScript switch (me->GetEntry()) { - case NPC_WARMAGE_HOLLISTER: + case NPC_WARMAGE_HOLLISTER: + { + if (!orbList.empty()) { - if (!orbList.empty()) + for (std::list::const_iterator itr = orbList.begin(); itr != orbList.end(); ++itr) { - for (std::list::const_iterator itr = orbList.begin(); itr != orbList.end(); ++itr) - { - if (Creature* pOrb = *itr) - if (pOrb->GetPositionY() > 6680) - DoCast(pOrb, SPELL_TRANSITUS_SHIELD_BEAM); - } + if (Creature* pOrb = *itr) + if (pOrb->GetPositionY() > 6680) + DoCast(pOrb, SPELL_TRANSITUS_SHIELD_BEAM); } - m_uiTimer = urand(90000, 120000); } - break; - case NPC_WARMAGE_CALANDRA: + m_uiTimer = urand(90000, 120000); + } + break; + case NPC_WARMAGE_CALANDRA: + { + if (!orbList.empty()) { - if (!orbList.empty()) + for (std::list::const_iterator itr = orbList.begin(); itr != orbList.end(); ++itr) { - for (std::list::const_iterator itr = orbList.begin(); itr != orbList.end(); ++itr) - { - if (Creature* pOrb = *itr) - if ((pOrb->GetPositionY() < 6680) && (pOrb->GetPositionY() > 6630)) - DoCast(pOrb, SPELL_TRANSITUS_SHIELD_BEAM); - } + if (Creature* pOrb = *itr) + if ((pOrb->GetPositionY() < 6680) && (pOrb->GetPositionY() > 6630)) + DoCast(pOrb, SPELL_TRANSITUS_SHIELD_BEAM); } - m_uiTimer = urand(90000, 120000); } - break; - case NPC_WARMAGE_WATKINS: + m_uiTimer = urand(90000, 120000); + } + break; + case NPC_WARMAGE_WATKINS: + { + if (!orbList.empty()) { - if (!orbList.empty()) + for (std::list::const_iterator itr = orbList.begin(); itr != orbList.end(); ++itr) { - for (std::list::const_iterator itr = orbList.begin(); itr != orbList.end(); ++itr) - { - if (Creature* pOrb = *itr) - if (pOrb->GetPositionY() < 6630) - DoCast(pOrb, SPELL_TRANSITUS_SHIELD_BEAM); - } + if (Creature* pOrb = *itr) + if (pOrb->GetPositionY() < 6630) + DoCast(pOrb, SPELL_TRANSITUS_SHIELD_BEAM); } - m_uiTimer = urand(90000, 120000); } - break; + m_uiTimer = urand(90000, 120000); + } + break; } } - else m_uiTimer -= uiDiff; + else + m_uiTimer -= uiDiff; ScriptedAI::UpdateAI(uiDiff); @@ -2126,23 +2215,23 @@ class npc_warmage_coldarra : public CreatureScript enum HiddenCultist { - SPELL_SHROUD_OF_THE_DEATH_CULTIST = 46077, //not working - SPELL_RIGHTEOUS_VISION = 46078, //player aura + SPELL_SHROUD_OF_THE_DEATH_CULTIST = 46077, // not working + SPELL_RIGHTEOUS_VISION = 46078, // player aura - QUEST_THE_HUNT_IS_ON = 11794, + QUEST_THE_HUNT_IS_ON = 11794, - GOSSIP_TEXT_SALTY_JOHN_THORPE = 12529, - GOSSIP_TEXT_GUARD_MITCHELSS = 12530, - GOSSIP_TEXT_TOM_HEGGER = 12528, + GOSSIP_TEXT_SALTY_JOHN_THORPE = 12529, + GOSSIP_TEXT_GUARD_MITCHELSS = 12530, + GOSSIP_TEXT_TOM_HEGGER = 12528, - NPC_TOM_HEGGER = 25827, - NPC_SALTY_JOHN_THORPE = 25248, - NPC_GUARD_MITCHELLS = 25828, + NPC_TOM_HEGGER = 25827, + NPC_SALTY_JOHN_THORPE = 25248, + NPC_GUARD_MITCHELLS = 25828, - SAY_HIDDEN_CULTIST_1 = 0, - SAY_HIDDEN_CULTIST_2 = 1, - SAY_HIDDEN_CULTIST_3 = 2, - SAY_HIDDEN_CULTIST_4 = 3 + SAY_HIDDEN_CULTIST_1 = 0, + SAY_HIDDEN_CULTIST_2 = 1, + SAY_HIDDEN_CULTIST_3 = 2, + SAY_HIDDEN_CULTIST_4 = 3 }; char const* GOSSIP_ITEM_TOM_HEGGER = "What do you know about the Cult of the Damned?"; @@ -2151,8 +2240,10 @@ char const* GOSSIP_ITEM_SALTY_JOHN_THORPE = "I have a reason to believe you're i class npc_hidden_cultist : public CreatureScript { -public: - npc_hidden_cultist() : CreatureScript("npc_hidden_cultist") { } + public: + npc_hidden_cultist() : CreatureScript("npc_hidden_cultist") + { + } struct npc_hidden_cultistAI : public ScriptedAI { @@ -2223,53 +2314,55 @@ class npc_hidden_cultist : public CreatureScript { switch (uiEventPhase) { - case 1: - switch (me->GetEntry()) - { - case NPC_SALTY_JOHN_THORPE: - Talk(SAY_HIDDEN_CULTIST_1); - uiEventTimer = 5000; - uiEventPhase = 2; - break; - case NPC_GUARD_MITCHELLS: - Talk(SAY_HIDDEN_CULTIST_2); - uiEventTimer = 5000; - uiEventPhase = 2; - break; - case NPC_TOM_HEGGER: - if (Player* player = ObjectAccessor::GetPlayer(*me, uiPlayerGUID)) - Talk(SAY_HIDDEN_CULTIST_3, player); - uiEventTimer = 5000; - uiEventPhase = 2; - break; - } + case 1: + switch (me->GetEntry()) + { + case NPC_SALTY_JOHN_THORPE: + Talk(SAY_HIDDEN_CULTIST_1); + uiEventTimer = 5000; + uiEventPhase = 2; break; - case 2: - switch (me->GetEntry()) - { - case NPC_SALTY_JOHN_THORPE: - Talk(SAY_HIDDEN_CULTIST_4); - if (Player* player = ObjectAccessor::GetPlayer(*me, uiPlayerGUID)) - me->SetFacingToObject(player); - uiEventTimer = 3000; - uiEventPhase = 3; - break; - case NPC_GUARD_MITCHELLS: - case NPC_TOM_HEGGER: - AttackPlayer(); - uiEventPhase = 0; - break; - } + case NPC_GUARD_MITCHELLS: + Talk(SAY_HIDDEN_CULTIST_2); + uiEventTimer = 5000; + uiEventPhase = 2; break; - case 3: - if (me->GetEntry() == NPC_SALTY_JOHN_THORPE) - { - AttackPlayer(); - uiEventPhase = 0; - } + case NPC_TOM_HEGGER: + if (Player* player = ObjectAccessor::GetPlayer(*me, uiPlayerGUID)) + Talk(SAY_HIDDEN_CULTIST_3, player); + uiEventTimer = 5000; + uiEventPhase = 2; + break; + } + break; + case 2: + switch (me->GetEntry()) + { + case NPC_SALTY_JOHN_THORPE: + Talk(SAY_HIDDEN_CULTIST_4); + if (Player* player = ObjectAccessor::GetPlayer(*me, uiPlayerGUID)) + me->SetFacingToObject(player); + uiEventTimer = 3000; + uiEventPhase = 3; + break; + case NPC_GUARD_MITCHELLS: + case NPC_TOM_HEGGER: + AttackPlayer(); + uiEventPhase = 0; break; + } + break; + case 3: + if (me->GetEntry() == NPC_SALTY_JOHN_THORPE) + { + AttackPlayer(); + uiEventPhase = 0; + } + break; } - }else uiEventTimer -= uiDiff; + } + else + uiEventTimer -= uiDiff; if (!UpdateVictim()) return; @@ -2284,21 +2377,21 @@ class npc_hidden_cultist : public CreatureScript switch (me->GetEntry()) { - case NPC_TOM_HEGGER: - uiGossipText = GOSSIP_TEXT_TOM_HEGGER; - charGossipItem = GOSSIP_ITEM_TOM_HEGGER; - break; - case NPC_SALTY_JOHN_THORPE: - uiGossipText = GOSSIP_TEXT_SALTY_JOHN_THORPE; - charGossipItem = GOSSIP_ITEM_SALTY_JOHN_THORPE; - break; - case NPC_GUARD_MITCHELLS: - uiGossipText = GOSSIP_TEXT_GUARD_MITCHELSS; - charGossipItem = GOSSIP_ITEM_GUARD_MITCHELLS; - break; - default: - charGossipItem = ""; - return false; + case NPC_TOM_HEGGER: + uiGossipText = GOSSIP_TEXT_TOM_HEGGER; + charGossipItem = GOSSIP_ITEM_TOM_HEGGER; + break; + case NPC_SALTY_JOHN_THORPE: + uiGossipText = GOSSIP_TEXT_SALTY_JOHN_THORPE; + charGossipItem = GOSSIP_ITEM_SALTY_JOHN_THORPE; + break; + case NPC_GUARD_MITCHELLS: + uiGossipText = GOSSIP_TEXT_GUARD_MITCHELSS; + charGossipItem = GOSSIP_ITEM_GUARD_MITCHELLS; + break; + default: + charGossipItem = ""; + return false; } if (player->HasAura(SPELL_RIGHTEOUS_VISION) && player->GetQuestStatus(QUEST_THE_HUNT_IS_ON) == QUEST_STATUS_INCOMPLETE) @@ -2344,8 +2437,10 @@ enum WindsoulTotemAura class spell_windsoul_totem_aura : public SpellScriptLoader { -public: - spell_windsoul_totem_aura() : SpellScriptLoader("spell_windsoul_totem_aura") { } + public: + spell_windsoul_totem_aura() : SpellScriptLoader("spell_windsoul_totem_aura") + { + } class spell_windsoul_totem_aura_AuraScript : public AuraScript { @@ -2370,16 +2465,18 @@ class spell_windsoul_totem_aura : public SpellScriptLoader enum BloodsporeRuination { - NPC_BLOODMAGE_LAURITH = 25381, - SAY_BLOODMAGE_LAURITH = 0, - EVENT_TALK = 1, + NPC_BLOODMAGE_LAURITH = 25381, + SAY_BLOODMAGE_LAURITH = 0, + EVENT_TALK = 1, EVENT_RESET_ORIENTATION }; class spell_q11719_bloodspore_ruination_45997 : public SpellScriptLoader { -public: - spell_q11719_bloodspore_ruination_45997() : SpellScriptLoader("spell_q11719_bloodspore_ruination_45997") { } + public: + spell_q11719_bloodspore_ruination_45997() : SpellScriptLoader("spell_q11719_bloodspore_ruination_45997") + { + } class spell_q11719_bloodspore_ruination_45997_SpellScript : public SpellScript { @@ -2404,12 +2501,16 @@ class spell_q11719_bloodspore_ruination_45997 : public SpellScriptLoader class npc_bloodmage_laurith : public CreatureScript { -public: - npc_bloodmage_laurith() : CreatureScript("npc_bloodmage_laurith") { } + public: + npc_bloodmage_laurith() : CreatureScript("npc_bloodmage_laurith") + { + } struct npc_bloodmage_laurithAI : public ScriptedAI { - npc_bloodmage_laurithAI(Creature* creature) : ScriptedAI(creature) { } + npc_bloodmage_laurithAI(Creature* creature) : ScriptedAI(creature) + { + } void Reset() override { @@ -2444,22 +2545,22 @@ class npc_bloodmage_laurith : public CreatureScript { switch (eventId) { - case EVENT_TALK: - if (Player* player = ObjectAccessor::GetPlayer(*me, _playerGUID)) - Talk(SAY_BLOODMAGE_LAURITH, player); - _playerGUID.Clear(); - _events.ScheduleEvent(EVENT_RESET_ORIENTATION, Seconds(5)); - break; - case EVENT_RESET_ORIENTATION: - me->SetFacingTo(me->GetHomePosition().GetOrientation()); - break; + case EVENT_TALK: + if (Player* player = ObjectAccessor::GetPlayer(*me, _playerGUID)) + Talk(SAY_BLOODMAGE_LAURITH, player); + _playerGUID.Clear(); + _events.ScheduleEvent(EVENT_RESET_ORIENTATION, Seconds(5)); + break; + case EVENT_RESET_ORIENTATION: + me->SetFacingTo(me->GetHomePosition().GetOrientation()); + break; } } } - private: - EventMap _events; - ObjectGuid _playerGUID; + private: + EventMap _events; + ObjectGuid _playerGUID; }; CreatureAI* GetAI(Creature* creature) const override diff --git a/src/server/scripts/Northrend/zone_grizzly_hills.cpp b/src/server/scripts/Northrend/zone_grizzly_hills.cpp index f625cf1e..2fb7007e 100644 --- a/src/server/scripts/Northrend/zone_grizzly_hills.cpp +++ b/src/server/scripts/Northrend/zone_grizzly_hills.cpp @@ -15,11 +15,11 @@ * with this program. If not, see . */ -#include "ScriptMgr.h" #include "CombatAI.h" #include "MotionMaster.h" #include "ObjectAccessor.h" #include "Player.h" +#include "ScriptMgr.h" #include "ScriptedEscortAI.h" #include "SpellInfo.h" #include "SpellScript.h" @@ -32,39 +32,43 @@ enum Floppy { // Creature - NPC_MRFLOPPY = 26589, - NPC_HUNGRY_WORG = 26586, - NPC_RAVENOUS_WORG = 26590, // RWORG - NPC_EMILY = 26588, + NPC_MRFLOPPY = 26589, + NPC_HUNGRY_WORG = 26586, + NPC_RAVENOUS_WORG = 26590, // RWORG + NPC_EMILY = 26588, // Quest - QUEST_PERILOUS_ADVENTURE = 12027, + QUEST_PERILOUS_ADVENTURE = 12027, // Spell - SPELL_MRFLOPPY = 47184, // vehicle aura + SPELL_MRFLOPPY = 47184, // vehicle aura // Text - SAY_WORGHAGGRO1 = 0, // Um... I think one of those wolves is back... - SAY_WORGHAGGRO2 = 1, // He's going for Mr. Floppy! - SAY_WORGRAGGRO3 = 2, // Oh, no! Look, it's another wolf, and it's a biiiiiig one! - SAY_WORGRAGGRO4 = 3, // He's gonna eat Mr. Floppy! You gotta help Mr. Floppy! You just gotta! - SAY_RANDOMAGGRO = 4, // There's a big meanie attacking Mr. Floppy! Help! - SAY_VICTORY1 = 5, // Let's get out of here before more wolves find us! - SAY_VICTORY2 = 6, // Don't go toward the light, Mr. Floppy! - SAY_VICTORY3 = 7, // Mr. Floppy, you're ok! Thank you so much for saving Mr. Floppy! - SAY_VICTORY4 = 8, // I think I see the camp! We're almost home, Mr. Floppy! Let's go! - TEXT_EMOTE_WP1 = 9, // Mr. Floppy revives - TEXT_EMOTE_AGGRO = 10, // The Ravenous Worg chomps down on Mr. Floppy - SAY_QUEST_ACCEPT = 11, // Are you ready, Mr. Floppy? Stay close to me and watch out for those wolves! - SAY_QUEST_COMPLETE = 12 // Thank you for helping me get back to the camp. Go tell Walter that I'm safe now! + SAY_WORGHAGGRO1 = 0, // Um... I think one of those wolves is back... + SAY_WORGHAGGRO2 = 1, // He's going for Mr. Floppy! + SAY_WORGRAGGRO3 = 2, // Oh, no! Look, it's another wolf, and it's a biiiiiig one! + SAY_WORGRAGGRO4 = 3, // He's gonna eat Mr. Floppy! You gotta help Mr. Floppy! You just gotta! + SAY_RANDOMAGGRO = 4, // There's a big meanie attacking Mr. Floppy! Help! + SAY_VICTORY1 = 5, // Let's get out of here before more wolves find us! + SAY_VICTORY2 = 6, // Don't go toward the light, Mr. Floppy! + SAY_VICTORY3 = 7, // Mr. Floppy, you're ok! Thank you so much for saving Mr. Floppy! + SAY_VICTORY4 = 8, // I think I see the camp! We're almost home, Mr. Floppy! Let's go! + TEXT_EMOTE_WP1 = 9, // Mr. Floppy revives + TEXT_EMOTE_AGGRO = 10, // The Ravenous Worg chomps down on Mr. Floppy + SAY_QUEST_ACCEPT = 11, // Are you ready, Mr. Floppy? Stay close to me and watch out for those wolves! + SAY_QUEST_COMPLETE = 12 // Thank you for helping me get back to the camp. Go tell Walter that I'm safe now! }; // emily class npc_emily : public CreatureScript { -public: - npc_emily() : CreatureScript("npc_emily") { } + public: + npc_emily() : CreatureScript("npc_emily") + { + } struct npc_emilyAI : public EscortAI { - npc_emilyAI(Creature* creature) : EscortAI(creature) { } + npc_emilyAI(Creature* creature) : EscortAI(creature) + { + } void JustSummoned(Creature* summoned) override { @@ -82,93 +86,93 @@ class npc_emily : public CreatureScript switch (waypointId) { - case 9: - if (Creature* Mrfloppy = GetClosestCreatureWithEntry(me, NPC_MRFLOPPY, 100.0f)) - _mrfloppyGUID = Mrfloppy->GetGUID(); - break; - case 10: - if (ObjectAccessor::GetCreature(*me, _mrfloppyGUID)) - { - Talk(SAY_WORGHAGGRO1); - me->SummonCreature(NPC_HUNGRY_WORG, me->GetPositionX()+5, me->GetPositionY()+2, me->GetPositionZ()+1, 3.229f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 120000); - } - break; - case 11: - if (Creature* Mrfloppy = ObjectAccessor::GetCreature(*me, _mrfloppyGUID)) - Mrfloppy->FollowTarget(me); - break; - case 17: - if (Creature* Mrfloppy = ObjectAccessor::GetCreature(*me, _mrfloppyGUID)) - Mrfloppy->GetMotionMaster()->MovePoint(0, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ()); - Talk(SAY_WORGRAGGRO3); - if (Creature* RWORG = me->SummonCreature(NPC_RAVENOUS_WORG, me->GetPositionX()+10, me->GetPositionY()+8, me->GetPositionZ()+2, 3.229f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 120000)) - { - RWORG->SetFaction(FACTION_FRIENDLY); - _RavenousworgGUID = RWORG->GetGUID(); - } - break; - case 18: - if (Creature* Mrfloppy = ObjectAccessor::GetCreature(*me, _mrfloppyGUID)) + case 9: + if (Creature* Mrfloppy = GetClosestCreatureWithEntry(me, NPC_MRFLOPPY, 100.0f)) + _mrfloppyGUID = Mrfloppy->GetGUID(); + break; + case 10: + if (ObjectAccessor::GetCreature(*me, _mrfloppyGUID)) + { + Talk(SAY_WORGHAGGRO1); + me->SummonCreature(NPC_HUNGRY_WORG, me->GetPositionX() + 5, me->GetPositionY() + 2, me->GetPositionZ() + 1, 3.229f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 120000); + } + break; + case 11: + if (Creature* Mrfloppy = ObjectAccessor::GetCreature(*me, _mrfloppyGUID)) + Mrfloppy->FollowTarget(me); + break; + case 17: + if (Creature* Mrfloppy = ObjectAccessor::GetCreature(*me, _mrfloppyGUID)) + Mrfloppy->GetMotionMaster()->MovePoint(0, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ()); + Talk(SAY_WORGRAGGRO3); + if (Creature* RWORG = me->SummonCreature(NPC_RAVENOUS_WORG, me->GetPositionX() + 10, me->GetPositionY() + 8, me->GetPositionZ() + 2, 3.229f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 120000)) + { + RWORG->SetFaction(FACTION_FRIENDLY); + _RavenousworgGUID = RWORG->GetGUID(); + } + break; + case 18: + if (Creature* Mrfloppy = ObjectAccessor::GetCreature(*me, _mrfloppyGUID)) + { + if (Creature* RWORG = ObjectAccessor::GetCreature(*me, _RavenousworgGUID)) + RWORG->GetMotionMaster()->MovePoint(0, Mrfloppy->GetPositionX(), Mrfloppy->GetPositionY(), Mrfloppy->GetPositionZ()); + DoCast(Mrfloppy, SPELL_MRFLOPPY); + } + break; + case 19: + if (Creature* Mrfloppy = ObjectAccessor::GetCreature(*me, _mrfloppyGUID)) + { + if (Mrfloppy->HasAura(SPELL_MRFLOPPY)) { if (Creature* RWORG = ObjectAccessor::GetCreature(*me, _RavenousworgGUID)) - RWORG->GetMotionMaster()->MovePoint(0, Mrfloppy->GetPositionX(), Mrfloppy->GetPositionY(), Mrfloppy->GetPositionZ()); - DoCast(Mrfloppy, SPELL_MRFLOPPY); - } - break; - case 19: - if (Creature* Mrfloppy = ObjectAccessor::GetCreature(*me, _mrfloppyGUID)) - { - if (Mrfloppy->HasAura(SPELL_MRFLOPPY)) - { - if (Creature* RWORG = ObjectAccessor::GetCreature(*me, _RavenousworgGUID)) - Mrfloppy->EnterVehicle(RWORG); - } + Mrfloppy->EnterVehicle(RWORG); } - break; - case 20: + } + break; + case 20: + if (Creature* RWORG = ObjectAccessor::GetCreature(*me, _RavenousworgGUID)) + RWORG->HandleEmoteCommand(34); + break; + case 21: + if (Creature* Mrfloppy = ObjectAccessor::GetCreature(*me, _mrfloppyGUID)) + { if (Creature* RWORG = ObjectAccessor::GetCreature(*me, _RavenousworgGUID)) - RWORG->HandleEmoteCommand(34); - break; - case 21: - if (Creature* Mrfloppy = ObjectAccessor::GetCreature(*me, _mrfloppyGUID)) { - if (Creature* RWORG = ObjectAccessor::GetCreature(*me, _RavenousworgGUID)) - { - RWORG->Kill(Mrfloppy); - Mrfloppy->ExitVehicle(); - RWORG->SetFaction(FACTION_MONSTER); - RWORG->GetMotionMaster()->MovePoint(0, RWORG->GetPositionX()+10, RWORG->GetPositionY()+80, RWORG->GetPositionZ()); - Talk(SAY_VICTORY2); - } + Unit::Kill(RWORG, Mrfloppy); + Mrfloppy->ExitVehicle(); + RWORG->SetFaction(FACTION_MONSTER); + RWORG->GetMotionMaster()->MovePoint(0, RWORG->GetPositionX() + 10, RWORG->GetPositionY() + 80, RWORG->GetPositionZ()); + Talk(SAY_VICTORY2); } - break; - case 22: - if (Creature* Mrfloppy = ObjectAccessor::GetCreature(*me, _mrfloppyGUID)) + } + break; + case 22: + if (Creature* Mrfloppy = ObjectAccessor::GetCreature(*me, _mrfloppyGUID)) + { + if (Mrfloppy->isDead()) { - if (Mrfloppy->isDead()) - { - if (Creature* RWORG = ObjectAccessor::GetCreature(*me, _RavenousworgGUID)) - RWORG->DisappearAndDie(); - me->GetMotionMaster()->MovePoint(0, Mrfloppy->GetPositionX(), Mrfloppy->GetPositionY(), Mrfloppy->GetPositionZ()); - Mrfloppy->setDeathState(ALIVE); - Mrfloppy->FollowTarget(me); - Talk(SAY_VICTORY3); - } + if (Creature* RWORG = ObjectAccessor::GetCreature(*me, _RavenousworgGUID)) + RWORG->DisappearAndDie(); + me->GetMotionMaster()->MovePoint(0, Mrfloppy->GetPositionX(), Mrfloppy->GetPositionY(), Mrfloppy->GetPositionZ()); + Mrfloppy->setDeathState(ALIVE); + Mrfloppy->FollowTarget(me); + Talk(SAY_VICTORY3); } - break; - case 24: - player->GroupEventHappens(QUEST_PERILOUS_ADVENTURE, me); - Talk(SAY_QUEST_COMPLETE, player); - me->SetWalk(false); - break; - case 25: - Talk(SAY_VICTORY4); - break; - case 27: - me->DisappearAndDie(); - if (Creature* Mrfloppy = ObjectAccessor::GetCreature(*me, _mrfloppyGUID)) - Mrfloppy->DisappearAndDie(); - break; + } + break; + case 24: + player->GroupEventHappens(QUEST_PERILOUS_ADVENTURE, me); + Talk(SAY_QUEST_COMPLETE, player); + me->SetWalk(false); + break; + case 25: + Talk(SAY_VICTORY4); + break; + case 27: + me->DisappearAndDie(); + if (Creature* Mrfloppy = ObjectAccessor::GetCreature(*me, _mrfloppyGUID)) + Mrfloppy->DisappearAndDie(); + break; } } @@ -195,9 +199,9 @@ class npc_emily : public CreatureScript } } - private: - ObjectGuid _RavenousworgGUID; - ObjectGuid _mrfloppyGUID; + private: + ObjectGuid _RavenousworgGUID; + ObjectGuid _mrfloppyGUID; }; CreatureAI* GetAI(Creature* creature) const override @@ -209,14 +213,20 @@ class npc_emily : public CreatureScript // mrfloppy class npc_mrfloppy : public CreatureScript { -public: - npc_mrfloppy() : CreatureScript("npc_mrfloppy") { } + public: + npc_mrfloppy() : CreatureScript("npc_mrfloppy") + { + } struct npc_mrfloppyAI : public ScriptedAI { - npc_mrfloppyAI(Creature* creature) : ScriptedAI(creature) { } + npc_mrfloppyAI(Creature* creature) : ScriptedAI(creature) + { + } - void Reset() override { } + void Reset() override + { + } void JustEngagedWith(Unit* Who) override { @@ -224,22 +234,25 @@ class npc_mrfloppy : public CreatureScript { switch (Who->GetEntry()) { - case NPC_HUNGRY_WORG: - Emily->AI()->Talk(SAY_WORGHAGGRO2); - break; - case NPC_RAVENOUS_WORG: - Emily->AI()->Talk(SAY_WORGRAGGRO4); - break; - default: - Emily->AI()->Talk(SAY_RANDOMAGGRO); + case NPC_HUNGRY_WORG: + Emily->AI()->Talk(SAY_WORGHAGGRO2); + break; + case NPC_RAVENOUS_WORG: + Emily->AI()->Talk(SAY_WORGRAGGRO4); + break; + default: + Emily->AI()->Talk(SAY_RANDOMAGGRO); } } } - void EnterEvadeMode(EvadeReason /*why*/) override { } - - void MoveInLineOfSight(Unit* /*who*/) override { } + void EnterEvadeMode(EvadeReason /*why*/) override + { + } + void MoveInLineOfSight(Unit* /*who*/) override + { + } void UpdateAI(uint32 /*diff*/) override { @@ -261,18 +274,20 @@ class npc_mrfloppy : public CreatureScript enum Outhouse { // Sound - SOUND_FEMALE = 12671, - SOUND_MALE = 12670, + SOUND_FEMALE = 12671, + SOUND_MALE = 12670, // Spell - SPELL_OUTHOUSE_GROANS = 48382, - SPELL_CAMERA_SHAKE = 47533, - SPELL_DUST_FIELD = 48329 + SPELL_OUTHOUSE_GROANS = 48382, + SPELL_CAMERA_SHAKE = 47533, + SPELL_DUST_FIELD = 48329 }; class npc_outhouse_bunny : public CreatureScript { -public: - npc_outhouse_bunny() : CreatureScript("npc_outhouse_bunny") { } + public: + npc_outhouse_bunny() : CreatureScript("npc_outhouse_bunny") + { + } struct npc_outhouse_bunnyAI : public ScriptedAI { @@ -300,8 +315,8 @@ class npc_outhouse_bunny : public CreatureScript void SpellHit(Unit* Caster, SpellInfo const* Spell) override { - if (Spell->Id == SPELL_OUTHOUSE_GROANS) - { + if (Spell->Id == SPELL_OUTHOUSE_GROANS) + { ++_counter; if (_counter < 5) DoCast(Caster, SPELL_CAMERA_SHAKE, true); @@ -310,19 +325,20 @@ class npc_outhouse_bunny : public CreatureScript DoCast(me, SPELL_DUST_FIELD, true); switch (_gender) { - case GENDER_FEMALE: - DoPlaySoundToSet(me, SOUND_FEMALE); - break; + case GENDER_FEMALE: + DoPlaySoundToSet(me, SOUND_FEMALE); + break; - case GENDER_MALE: - DoPlaySoundToSet(me, SOUND_MALE); - break; + case GENDER_MALE: + DoPlaySoundToSet(me, SOUND_MALE); + break; } } } - private: - uint8 _counter; - uint8 _gender; + + private: + uint8 _counter; + uint8 _gender; }; CreatureAI* GetAI(Creature* creature) const override @@ -335,14 +351,16 @@ class npc_outhouse_bunny : public CreatureScript enum TallhornStage { - //Gameobject - OBJECT_HAUNCH = 188665 + // Gameobject + OBJECT_HAUNCH = 188665 }; class npc_tallhorn_stag : public CreatureScript { -public: - npc_tallhorn_stag() : CreatureScript("npc_tallhorn_stag") { } + public: + npc_tallhorn_stag() : CreatureScript("npc_tallhorn_stag") + { + } struct npc_tallhorn_stagAI : public ScriptedAI { @@ -375,8 +393,9 @@ class npc_tallhorn_stag : public CreatureScript } DoMeleeAttackIfReady(); } - private: - uint8 _phase; + + private: + uint8 _phase; }; CreatureAI* GetAI(Creature* creature) const override @@ -390,23 +409,27 @@ class npc_tallhorn_stag : public CreatureScript enum AmberpineWoodsman { // Creature - NPC_TALLHORN_STAG = 26363 + NPC_TALLHORN_STAG = 26363 }; enum AmberpineWoodsmanEvents { - EVENT_WOODSMAN_1 = 1, - EVENT_WOODSMAN_2 = 2 + EVENT_WOODSMAN_1 = 1, + EVENT_WOODSMAN_2 = 2 }; class npc_amberpine_woodsman : public CreatureScript { -public: - npc_amberpine_woodsman() : CreatureScript("npc_amberpine_woodsman") { } + public: + npc_amberpine_woodsman() : CreatureScript("npc_amberpine_woodsman") + { + } struct npc_amberpine_woodsmanAI : public ScriptedAI { - npc_amberpine_woodsmanAI(Creature* creature) : ScriptedAI(creature) { } + npc_amberpine_woodsmanAI(Creature* creature) : ScriptedAI(creature) + { + } void Reset() override { @@ -426,22 +449,23 @@ class npc_amberpine_woodsman : public CreatureScript { switch (eventId) { - case EVENT_WOODSMAN_1: - me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_LOOT); - _events.ScheduleEvent(EVENT_WOODSMAN_2, 3000); - break; - case EVENT_WOODSMAN_2: - me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_ATTACK1H); - _events.ScheduleEvent(EVENT_WOODSMAN_1, 4000); - break; - default: - break; + case EVENT_WOODSMAN_1: + me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_LOOT); + _events.ScheduleEvent(EVENT_WOODSMAN_2, 3000); + break; + case EVENT_WOODSMAN_2: + me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_ATTACK1H); + _events.ScheduleEvent(EVENT_WOODSMAN_1, 4000); + break; + default: + break; } } UpdateVictim(); } - private: - EventMap _events; + + private: + EventMap _events; }; CreatureAI* GetAI(Creature* creature) const override @@ -457,18 +481,20 @@ class npc_amberpine_woodsman : public CreatureScript enum Skirmisher { // Quest - QUEST_OVERWHELMED = 12288, + QUEST_OVERWHELMED = 12288, // Spell - SPELL_RENEW_SKIRMISHER = 48812, - SPELL_KILL_CREDIT = 48813, + SPELL_RENEW_SKIRMISHER = 48812, + SPELL_KILL_CREDIT = 48813, // Text - SAY_RANDOM = 0 + SAY_RANDOM = 0 }; class npc_wounded_skirmisher : public CreatureScript { -public: - npc_wounded_skirmisher() : CreatureScript("npc_wounded_skirmisher") { } + public: + npc_wounded_skirmisher() : CreatureScript("npc_wounded_skirmisher") + { + } struct npc_wounded_skirmisherAI : public ScriptedAI { @@ -495,13 +521,12 @@ class npc_wounded_skirmisher : public CreatureScript void SpellHit(Unit* caster, SpellInfo const* spell) override { - if (spell->Id == SPELL_RENEW_SKIRMISHER && caster->GetTypeId() == TYPEID_PLAYER - && caster->ToPlayer()->GetQuestStatus(QUEST_OVERWHELMED) == QUEST_STATUS_INCOMPLETE) + if (spell->Id == SPELL_RENEW_SKIRMISHER && caster->GetTypeId() == TYPEID_PLAYER && caster->ToPlayer()->GetQuestStatus(QUEST_OVERWHELMED) == QUEST_STATUS_INCOMPLETE) { DoCast(caster, SPELL_KILL_CREDIT); Talk(SAY_RANDOM); if (me->IsStandState()) - me->GetMotionMaster()->MovePoint(1, me->GetPositionX()+7, me->GetPositionY()+7, me->GetPositionZ()); + me->GetMotionMaster()->MovePoint(1, me->GetPositionX() + 7, me->GetPositionY() + 7, me->GetPositionZ()); else { me->SetStandState(UNIT_STAND_STATE_STAND); @@ -517,8 +542,9 @@ class npc_wounded_skirmisher : public CreatureScript DoMeleeAttackIfReady(); } - private: - uint32 _despawnTimer; + + private: + uint32 _despawnTimer; }; CreatureAI* GetAI(Creature* creature) const override @@ -531,33 +557,37 @@ class npc_wounded_skirmisher : public CreatureScript enum SmokeEmOut { // Quest - QUEST_SMOKE_EM_OUT_A = 12323, - QUEST_SMOKE_EM_OUT_H = 12324, + QUEST_SMOKE_EM_OUT_A = 12323, + QUEST_SMOKE_EM_OUT_H = 12324, // Spell - SPELL_SMOKE_BOMB = 49075, - SPELL_CHOP = 43410, - SPELL_VENTURE_STRAGGLER_CREDIT = 49093, + SPELL_SMOKE_BOMB = 49075, + SPELL_CHOP = 43410, + SPELL_VENTURE_STRAGGLER_CREDIT = 49093, // Text - SAY_SEO = 0 + SAY_SEO = 0 }; enum StragglerEvents { - EVENT_STRAGGLER_1 = 1, - EVENT_STRAGGLER_2 = 2, - EVENT_STRAGGLER_3 = 3, - EVENT_STRAGGLER_4 = 4, - EVENT_CHOP = 5 + EVENT_STRAGGLER_1 = 1, + EVENT_STRAGGLER_2 = 2, + EVENT_STRAGGLER_3 = 3, + EVENT_STRAGGLER_4 = 4, + EVENT_CHOP = 5 }; class npc_venture_co_straggler : public CreatureScript { -public: - npc_venture_co_straggler() : CreatureScript("npc_venture_co_straggler") { } + public: + npc_venture_co_straggler() : CreatureScript("npc_venture_co_straggler") + { + } struct npc_venture_co_stragglerAI : public ScriptedAI { - npc_venture_co_stragglerAI(Creature* creature) : ScriptedAI(creature) { } + npc_venture_co_stragglerAI(Creature* creature) : ScriptedAI(creature) + { + } void JustEngagedWith(Unit* /*who*/) override { @@ -581,31 +611,31 @@ class npc_venture_co_straggler : public CreatureScript { switch (eventId) { - case EVENT_STRAGGLER_1: - if (Player* player = ObjectAccessor::GetPlayer(*me, _playerGUID)) - DoCast(player, SPELL_VENTURE_STRAGGLER_CREDIT); - me->GetMotionMaster()->MovePoint(0, me->GetPositionX()-7, me->GetPositionY()+7, me->GetPositionZ()); - _events.ScheduleEvent(EVENT_STRAGGLER_2, 2500); - break; - case EVENT_STRAGGLER_2: - Talk(SAY_SEO); - me->GetMotionMaster()->MovePoint(0, me->GetPositionX()-7, me->GetPositionY()-5, me->GetPositionZ()); - _events.ScheduleEvent(EVENT_STRAGGLER_3, 2500); - break; - case EVENT_STRAGGLER_3: - me->GetMotionMaster()->MovePoint(0, me->GetPositionX()-5, me->GetPositionY()-5, me->GetPositionZ()); - _events.ScheduleEvent(EVENT_STRAGGLER_4, 2500); - break; - case EVENT_STRAGGLER_4: - me->DisappearAndDie(); - break; - case EVENT_CHOP: - if (UpdateVictim()) - DoCastVictim(SPELL_CHOP); - _events.Repeat(Seconds(10), Seconds(12)); - break; - default: - break; + case EVENT_STRAGGLER_1: + if (Player* player = ObjectAccessor::GetPlayer(*me, _playerGUID)) + DoCast(player, SPELL_VENTURE_STRAGGLER_CREDIT); + me->GetMotionMaster()->MovePoint(0, me->GetPositionX() - 7, me->GetPositionY() + 7, me->GetPositionZ()); + _events.ScheduleEvent(EVENT_STRAGGLER_2, 2500); + break; + case EVENT_STRAGGLER_2: + Talk(SAY_SEO); + me->GetMotionMaster()->MovePoint(0, me->GetPositionX() - 7, me->GetPositionY() - 5, me->GetPositionZ()); + _events.ScheduleEvent(EVENT_STRAGGLER_3, 2500); + break; + case EVENT_STRAGGLER_3: + me->GetMotionMaster()->MovePoint(0, me->GetPositionX() - 5, me->GetPositionY() - 5, me->GetPositionZ()); + _events.ScheduleEvent(EVENT_STRAGGLER_4, 2500); + break; + case EVENT_STRAGGLER_4: + me->DisappearAndDie(); + break; + case EVENT_CHOP: + if (UpdateVictim()) + DoCastVictim(SPELL_CHOP); + _events.Repeat(Seconds(10), Seconds(12)); + break; + default: + break; } } @@ -627,15 +657,15 @@ class npc_venture_co_straggler : public CreatureScript } } - private: - EventMap _events; - ObjectGuid _playerGUID; - }; + private: + EventMap _events; + ObjectGuid _playerGUID; + }; - CreatureAI* GetAI(Creature* creature) const override - { - return new npc_venture_co_stragglerAI(creature); - } + CreatureAI* GetAI(Creature* creature) const override + { + return new npc_venture_co_stragglerAI(creature); + } }; /*###### @@ -645,213 +675,219 @@ class npc_venture_co_straggler : public CreatureScript enum LakeFrog { // Creature - NPC_LAKE_FROG = 33211, - NPC_LAKE_FROG_QUEST = 33224, - NPC_MAIDEN_OF_ASHWOOD_LAKE = 33220, + NPC_LAKE_FROG = 33211, + NPC_LAKE_FROG_QUEST = 33224, + NPC_MAIDEN_OF_ASHWOOD_LAKE = 33220, // Items - ITEM_WARTS_B_GONE_LIP_BALM = 44986, + ITEM_WARTS_B_GONE_LIP_BALM = 44986, // Spells - SPELL_WARTSBGONE_LIP_BALM = 62574, - SPELL_FROG_LOVE = 62537, // for 1 minute ! - SPELL_WARTS = 62581, + SPELL_WARTSBGONE_LIP_BALM = 62574, + SPELL_FROG_LOVE = 62537, // for 1 minute ! + SPELL_WARTS = 62581, SPELL_MAIDEN_OF_ASHWOOD_LAKE_TRANSFORM = 62550, - SPELL_SUMMON_ASHWOOD_BRAND = 62554, - SPELL_FROG_KISS = 62536, + SPELL_SUMMON_ASHWOOD_BRAND = 62554, + SPELL_FROG_KISS = 62536, // Text - SAY_MAIDEN_0 = 0, - SAY_MAIDEN_1 = 1 + SAY_MAIDEN_0 = 0, + SAY_MAIDEN_1 = 1 }; enum LakeFrogEvents { - EVENT_LAKEFROG_1 = 1, - EVENT_LAKEFROG_2 = 2, - EVENT_LAKEFROG_3 = 3, - EVENT_LAKEFROG_4 = 4, - EVENT_LAKEFROG_5 = 5 + EVENT_LAKEFROG_1 = 1, + EVENT_LAKEFROG_2 = 2, + EVENT_LAKEFROG_3 = 3, + EVENT_LAKEFROG_4 = 4, + EVENT_LAKEFROG_5 = 5 }; class npc_lake_frog : public CreatureScript { -public: - npc_lake_frog() : CreatureScript("npc_lake_frog") { } + public: + npc_lake_frog() : CreatureScript("npc_lake_frog") + { + } - struct npc_lake_frogAI : public ScriptedAI + struct npc_lake_frogAI : public ScriptedAI + { + npc_lake_frogAI(Creature* creature) : ScriptedAI(creature) { - npc_lake_frogAI(Creature* creature) : ScriptedAI(creature) - { - Initialize(); - } + Initialize(); + } - void Initialize() - { - _following = false; - _runningScript = false; - } + void Initialize() + { + _following = false; + _runningScript = false; + } - void Reset() override - { - Initialize(); - if (me->GetEntry() == NPC_LAKE_FROG_QUEST) - me->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); - } + void Reset() override + { + Initialize(); + if (me->GetEntry() == NPC_LAKE_FROG_QUEST) + me->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); + } - void UpdateAI(uint32 diff) override - { - if (_following) - if (!me->HasAura(SPELL_FROG_LOVE)) - me->DespawnOrUnsummon(1000); + void UpdateAI(uint32 diff) override + { + if (_following) + if (!me->HasAura(SPELL_FROG_LOVE)) + me->DespawnOrUnsummon(1000); - _events.Update(diff); + _events.Update(diff); - while (uint32 eventId = _events.ExecuteEvent()) + while (uint32 eventId = _events.ExecuteEvent()) + { + switch (eventId) { - switch (eventId) - { - case EVENT_LAKEFROG_1: - DoCast(me, SPELL_MAIDEN_OF_ASHWOOD_LAKE_TRANSFORM); - me->SetEntry(NPC_MAIDEN_OF_ASHWOOD_LAKE); - _events.ScheduleEvent(EVENT_LAKEFROG_2, 2000); - break; - case EVENT_LAKEFROG_2: - Talk(SAY_MAIDEN_0); - _events.ScheduleEvent(EVENT_LAKEFROG_3, 3000); - break; - case EVENT_LAKEFROG_3: - me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); - _events.ScheduleEvent(EVENT_LAKEFROG_4, 25000); - break; - case EVENT_LAKEFROG_4: - me->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); - _events.ScheduleEvent(EVENT_LAKEFROG_5, 2000); - break; - case EVENT_LAKEFROG_5: - Talk(SAY_MAIDEN_1); - me->DespawnOrUnsummon(4000); - break; - default: - break; - } + case EVENT_LAKEFROG_1: + DoCast(me, SPELL_MAIDEN_OF_ASHWOOD_LAKE_TRANSFORM); + me->SetEntry(NPC_MAIDEN_OF_ASHWOOD_LAKE); + _events.ScheduleEvent(EVENT_LAKEFROG_2, 2000); + break; + case EVENT_LAKEFROG_2: + Talk(SAY_MAIDEN_0); + _events.ScheduleEvent(EVENT_LAKEFROG_3, 3000); + break; + case EVENT_LAKEFROG_3: + me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); + _events.ScheduleEvent(EVENT_LAKEFROG_4, 25000); + break; + case EVENT_LAKEFROG_4: + me->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); + _events.ScheduleEvent(EVENT_LAKEFROG_5, 2000); + break; + case EVENT_LAKEFROG_5: + Talk(SAY_MAIDEN_1); + me->DespawnOrUnsummon(4000); + break; + default: + break; } } + } - void ReceiveEmote(Player* player, uint32 emote) override - { - if (_following || _runningScript) - return; + void ReceiveEmote(Player* player, uint32 emote) override + { + if (_following || _runningScript) + return; - if (emote == TEXT_EMOTE_KISS && me->IsWithinDistInMap(player, 30.0f) && player->HasItemCount(ITEM_WARTS_B_GONE_LIP_BALM, 1, false)) + if (emote == TEXT_EMOTE_KISS && me->IsWithinDistInMap(player, 30.0f) && player->HasItemCount(ITEM_WARTS_B_GONE_LIP_BALM, 1, false)) + { + if (!player->HasAura(SPELL_WARTSBGONE_LIP_BALM)) + player->AddAura(SPELL_WARTS, player); + else { - if (!player->HasAura(SPELL_WARTSBGONE_LIP_BALM)) - player->AddAura(SPELL_WARTS, player); - else + DoCast(player, SPELL_FROG_KISS); // Removes SPELL_WARTSBGONE_LIP_BALM + + if (me->GetEntry() == NPC_LAKE_FROG) { - DoCast(player, SPELL_FROG_KISS); // Removes SPELL_WARTSBGONE_LIP_BALM - - if (me->GetEntry() == NPC_LAKE_FROG) - { - me->AddAura(SPELL_FROG_LOVE, me); - me->GetMotionMaster()->MoveFollow(player, 0.3f, frand(float(M_PI) / 2, float(M_PI) + (float(M_PI) / 2))); - _following = true; - } - else if (me->GetEntry() == NPC_LAKE_FROG_QUEST) - { - me->GetMotionMaster()->MoveIdle(); - me->SetFacingToObject(player); - _runningScript = true; - _events.ScheduleEvent(EVENT_LAKEFROG_1, 2000); - } + me->AddAura(SPELL_FROG_LOVE, me); + me->GetMotionMaster()->MoveFollow(player, 0.3f, frand(float(M_PI) / 2, float(M_PI) + (float(M_PI) / 2))); + _following = true; + } + else if (me->GetEntry() == NPC_LAKE_FROG_QUEST) + { + me->GetMotionMaster()->MoveIdle(); + me->SetFacingToObject(player); + _runningScript = true; + _events.ScheduleEvent(EVENT_LAKEFROG_1, 2000); } } } + } - bool GossipSelect(Player* player, uint32 /*menuId*/, uint32 /*gossipListId*/) override - { - DoCast(player, SPELL_SUMMON_ASHWOOD_BRAND); - return false; - } - - private: - EventMap _events; - bool _following; - bool _runningScript; - }; - - CreatureAI* GetAI(Creature* creature) const override + bool GossipSelect(Player* player, uint32 /*menuId*/, uint32 /*gossipListId*/) override { - return new npc_lake_frogAI(creature); + DoCast(player, SPELL_SUMMON_ASHWOOD_BRAND); + return false; } + + private: + EventMap _events; + bool _following; + bool _runningScript; + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return new npc_lake_frogAI(creature); + } }; enum ShredderDelivery { - NPC_BROKEN_DOWN_SHREDDER = 27354 + NPC_BROKEN_DOWN_SHREDDER = 27354 }; class spell_shredder_delivery : public SpellScriptLoader { - public: - spell_shredder_delivery() : SpellScriptLoader("spell_shredder_delivery") { } + public: + spell_shredder_delivery() : SpellScriptLoader("spell_shredder_delivery") + { + } - class spell_shredder_delivery_SpellScript : public SpellScript + class spell_shredder_delivery_SpellScript : public SpellScript + { + bool Load() override { - bool Load() override - { - return GetCaster()->GetTypeId() == TYPEID_UNIT; - } - - void HandleScript(SpellEffIndex /*effIndex*/) - { - if (GetCaster()->ToCreature()->GetEntry() == NPC_BROKEN_DOWN_SHREDDER) - GetCaster()->ToCreature()->DespawnOrUnsummon(); - } + return GetCaster()->GetTypeId() == TYPEID_UNIT; + } - void Register() override - { - OnEffectHitTarget.Register(&spell_shredder_delivery_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - } - }; + void HandleScript(SpellEffIndex /*effIndex*/) + { + if (GetCaster()->ToCreature()->GetEntry() == NPC_BROKEN_DOWN_SHREDDER) + GetCaster()->ToCreature()->DespawnOrUnsummon(); + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_shredder_delivery_SpellScript(); + OnEffectHitTarget.Register(&spell_shredder_delivery_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_shredder_delivery_SpellScript(); + } }; enum InfectedWorgenBite { SPELL_INFECTED_WORGEN_BITE = 53094, - SPELL_WORGENS_CALL = 53095 + SPELL_WORGENS_CALL = 53095 }; class spell_infected_worgen_bite : public SpellScriptLoader { - public: - spell_infected_worgen_bite() : SpellScriptLoader("spell_infected_worgen_bite") { } + public: + spell_infected_worgen_bite() : SpellScriptLoader("spell_infected_worgen_bite") + { + } - class spell_infected_worgen_bite_AuraScript : public AuraScript + class spell_infected_worgen_bite_AuraScript : public AuraScript + { + void HandleAfterEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { - void HandleAfterEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - Unit* target = GetTarget(); - if (target->GetTypeId() == TYPEID_PLAYER) - if (GetStackAmount() == GetSpellInfo()->StackAmount) - { - Remove(); - target->CastSpell(target, SPELL_WORGENS_CALL, true); - } - } - - void Register() override - { - AfterEffectApply.Register(&spell_infected_worgen_bite_AuraScript::HandleAfterEffectApply, EFFECT_1, SPELL_AURA_PERIODIC_DAMAGE, AURA_EFFECT_HANDLE_REAPPLY); - } - }; + Unit* target = GetTarget(); + if (target->GetTypeId() == TYPEID_PLAYER) + if (GetStackAmount() == GetSpellInfo()->StackAmount) + { + Remove(); + target->CastSpell(target, SPELL_WORGENS_CALL, true); + } + } - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_infected_worgen_bite_AuraScript(); + AfterEffectApply.Register(&spell_infected_worgen_bite_AuraScript::HandleAfterEffectApply, EFFECT_1, SPELL_AURA_PERIODIC_DAMAGE, AURA_EFFECT_HANDLE_REAPPLY); } + }; + + AuraScript* GetAuraScript() const override + { + return new spell_infected_worgen_bite_AuraScript(); + } }; /*###### @@ -860,18 +896,20 @@ class spell_infected_worgen_bite : public SpellScriptLoader enum RedRocket { - SPELL_VEHICLE_WARHEAD_FUSE = 49107, - SPELL_ALLIANCE_KILL_CREDIT_TORPEDO = 49510, - SPELL_HORDE_KILL_CREDIT_TORPEDO = 49340, - NPC_HORDE_LUMBERBOAT = 27702, - NPC_ALLIANCE_LUMBERBOAT = 27688, - SPELL_DETONATE = 49250 + SPELL_VEHICLE_WARHEAD_FUSE = 49107, + SPELL_ALLIANCE_KILL_CREDIT_TORPEDO = 49510, + SPELL_HORDE_KILL_CREDIT_TORPEDO = 49340, + NPC_HORDE_LUMBERBOAT = 27702, + NPC_ALLIANCE_LUMBERBOAT = 27688, + SPELL_DETONATE = 49250 }; class npc_rocket_propelled_warhead : public CreatureScript { -public: - npc_rocket_propelled_warhead() : CreatureScript("npc_rocket_propelled_warhead") { } + public: + npc_rocket_propelled_warhead() : CreatureScript("npc_rocket_propelled_warhead") + { + } struct npc_rocket_propelled_warheadAI : public VehicleAI { @@ -924,7 +962,7 @@ class npc_rocket_propelled_warhead : public CreatureScript me->GetMotionMaster()->MoveTargetedHome(); } - private: + private: uint32 _faction; bool _finished; }; @@ -937,21 +975,23 @@ class npc_rocket_propelled_warhead : public CreatureScript enum WarheadSpells { - SPELL_WARHEAD_Z_CHECK = 61678, - SPELL_WARHEAD_SEEKING_LUMBERSHIP = 49331, - SPELL_WARHEAD_FUSE = 49181 + SPELL_WARHEAD_Z_CHECK = 61678, + SPELL_WARHEAD_SEEKING_LUMBERSHIP = 49331, + SPELL_WARHEAD_FUSE = 49181 }; // 49107 - Vehicle: Warhead Fuse class spell_vehicle_warhead_fuse : public SpellScriptLoader { -public: - spell_vehicle_warhead_fuse() : SpellScriptLoader("spell_vehicle_warhead_fuse") { } + public: + spell_vehicle_warhead_fuse() : SpellScriptLoader("spell_vehicle_warhead_fuse") + { + } class spell_vehicle_warhead_fuse_SpellScript : public SpellScript { - bool Validate(SpellInfo const* /*spellInfo*/) override + bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo({ SPELL_WARHEAD_Z_CHECK, SPELL_WARHEAD_SEEKING_LUMBERSHIP, SPELL_WARHEAD_FUSE }); + return ValidateSpellInfo({SPELL_WARHEAD_Z_CHECK, SPELL_WARHEAD_SEEKING_LUMBERSHIP, SPELL_WARHEAD_FUSE}); } void HandleDummy(SpellEffIndex /*effIndex*/) @@ -977,21 +1017,23 @@ class spell_vehicle_warhead_fuse : public SpellScriptLoader enum WarheadDenonate { - SPELL_PARACHUTE = 66154, - SPELL_TORPEDO_EXPLOSION = 49290, - NPC_ALLIANCE_LUMBERBOAT_EXPLOSIONS = 27689 + SPELL_PARACHUTE = 66154, + SPELL_TORPEDO_EXPLOSION = 49290, + NPC_ALLIANCE_LUMBERBOAT_EXPLOSIONS = 27689 }; // 49250 - Detonate class spell_warhead_detonate : public SpellScriptLoader { -public: - spell_warhead_detonate() : SpellScriptLoader("spell_warhead_detonate") { } + public: + spell_warhead_detonate() : SpellScriptLoader("spell_warhead_detonate") + { + } class spell_warhead_detonate_SpellScript : public SpellScript { - bool Validate(SpellInfo const* /*spellInfo*/) override + bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo({ SPELL_PARACHUTE, SPELL_TORPEDO_EXPLOSION }); + return ValidateSpellInfo({SPELL_PARACHUTE, SPELL_TORPEDO_EXPLOSION}); } void HandleDummy(SpellEffIndex /*effIndex*/) @@ -1028,8 +1070,10 @@ class spell_warhead_detonate : public SpellScriptLoader // 61678 - Z Check class spell_z_check : public SpellScriptLoader { -public: - spell_z_check() : SpellScriptLoader("spell_z_check") { } + public: + spell_z_check() : SpellScriptLoader("spell_z_check") + { + } class spell_z_check_AuraScript : public AuraScript { @@ -1065,8 +1109,10 @@ class spell_z_check : public SpellScriptLoader // 49181 - Warhead Fuse class spell_warhead_fuse : public SpellScriptLoader { -public: - spell_warhead_fuse() : SpellScriptLoader("spell_warhead_fuse") { } + public: + spell_warhead_fuse() : SpellScriptLoader("spell_warhead_fuse") + { + } class spell_warhead_fuse_AuraScript : public AuraScript { diff --git a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_fathomlord_karathress.cpp b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_fathomlord_karathress.cpp index 8cbe25aa..c561d27d 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_fathomlord_karathress.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_fathomlord_karathress.cpp @@ -22,87 +22,89 @@ SDComment: Cyclone workaround SDCategory: Coilfang Resevoir, Serpent Shrine Cavern EndScriptData */ -#include "ScriptMgr.h" #include "InstanceScript.h" #include "MotionMaster.h" #include "ObjectAccessor.h" +#include "ScriptMgr.h" #include "ScriptedEscortAI.h" -#include "serpent_shrine.h" #include "TemporarySummon.h" +#include "serpent_shrine.h" enum FathomlordKarathress { - SAY_AGGRO = 0, - SAY_GAIN_BLESSING = 1, - SAY_GAIN_ABILITY1 = 2, - SAY_GAIN_ABILITY2 = 3, - SAY_GAIN_ABILITY3 = 4, - SAY_SLAY = 5, - SAY_DEATH = 6, - - //Karathress spells - SPELL_CATACLYSMIC_BOLT = 38441, - SPELL_POWER_OF_SHARKKIS = 38455, - SPELL_POWER_OF_TIDALVESS = 38452, - SPELL_POWER_OF_CARIBDIS = 38451, - SPELL_ENRAGE = 24318, - SPELL_SEAR_NOVA = 38445, - SPELL_BLESSING_OF_THE_TIDES = 38449, - - //Sharkkis spells - SPELL_LEECHING_THROW = 29436, - SPELL_THE_BEAST_WITHIN = 38373, - SPELL_MULTISHOT = 38366, - SPELL_SUMMON_FATHOM_LURKER = 38433, - SPELL_SUMMON_FATHOM_SPOREBAT = 38431, - SPELL_PET_ENRAGE = 19574, - - //Tidalvess spells - SPELL_FROST_SHOCK = 38234, - SPELL_SPITFIRE_TOTEM = 38236, - SPELL_POISON_CLEANSING_TOTEM = 38306, + SAY_AGGRO = 0, + SAY_GAIN_BLESSING = 1, + SAY_GAIN_ABILITY1 = 2, + SAY_GAIN_ABILITY2 = 3, + SAY_GAIN_ABILITY3 = 4, + SAY_SLAY = 5, + SAY_DEATH = 6, + + // Karathress spells + SPELL_CATACLYSMIC_BOLT = 38441, + SPELL_POWER_OF_SHARKKIS = 38455, + SPELL_POWER_OF_TIDALVESS = 38452, + SPELL_POWER_OF_CARIBDIS = 38451, + SPELL_ENRAGE = 24318, + SPELL_SEAR_NOVA = 38445, + SPELL_BLESSING_OF_THE_TIDES = 38449, + + // Sharkkis spells + SPELL_LEECHING_THROW = 29436, + SPELL_THE_BEAST_WITHIN = 38373, + SPELL_MULTISHOT = 38366, + SPELL_SUMMON_FATHOM_LURKER = 38433, + SPELL_SUMMON_FATHOM_SPOREBAT = 38431, + SPELL_PET_ENRAGE = 19574, + + // Tidalvess spells + SPELL_FROST_SHOCK = 38234, + SPELL_SPITFIRE_TOTEM = 38236, + SPELL_POISON_CLEANSING_TOTEM = 38306, // Spell obsolete - SPELL_EARTHBIND_TOTEM = 38304, - SPELL_EARTHBIND_TOTEM_EFFECT = 6474, - SPELL_WINDFURY_WEAPON = 38184, - - //Caribdis Spells - SPELL_WATER_BOLT_VOLLEY = 38335, - SPELL_TIDAL_SURGE = 38358, - SPELL_TIDAL_SURGE_FREEZE = 38357, - SPELL_HEAL = 38330, - SPELL_SUMMON_CYCLONE = 38337, - SPELL_CYCLONE_CYCLONE = 29538, - - //Yells and Quotes - SOUND_GAIN_BLESSING_OF_TIDES = 11278, - SOUND_MISC = 11283, - - //Summoned Unit GUIDs - CREATURE_CYCLONE = 22104, - CREATURE_FATHOM_SPOREBAT = 22120, - CREATURE_FATHOM_LURKER = 22119, - CREATURE_SPITFIRE_TOTEM = 22091, - CREATURE_EARTHBIND_TOTEM = 22486, + SPELL_EARTHBIND_TOTEM = 38304, + SPELL_EARTHBIND_TOTEM_EFFECT = 6474, + SPELL_WINDFURY_WEAPON = 38184, + + // Caribdis Spells + SPELL_WATER_BOLT_VOLLEY = 38335, + SPELL_TIDAL_SURGE = 38358, + SPELL_TIDAL_SURGE_FREEZE = 38357, + SPELL_HEAL = 38330, + SPELL_SUMMON_CYCLONE = 38337, + SPELL_CYCLONE_CYCLONE = 29538, + + // Yells and Quotes + SOUND_GAIN_BLESSING_OF_TIDES = 11278, + SOUND_MISC = 11283, + + // Summoned Unit GUIDs + CREATURE_CYCLONE = 22104, + CREATURE_FATHOM_SPOREBAT = 22120, + CREATURE_FATHOM_LURKER = 22119, + CREATURE_SPITFIRE_TOTEM = 22091, + CREATURE_EARTHBIND_TOTEM = 22486, CREATURE_POISON_CLEANSING_TOTEM = 22487, }; -//entry and position for Seer Olum -#define SEER_OLUM 22820 -#define OLUM_X 446.78f -#define OLUM_Y -542.76f -#define OLUM_Z -7.54773f -#define OLUM_O 0.401581f +// entry and position for Seer Olum +#define SEER_OLUM 22820 +#define OLUM_X 446.78f +#define OLUM_Y -542.76f +#define OLUM_Z -7.54773f +#define OLUM_O 0.401581f -#define SAY_GAIN_BLESSING_OF_TIDES "Your overconfidence will be your undoing! Guards, lend me your strength!" -#define SAY_MISC "Alana be'lendor!" //don't know what use this +#define SAY_GAIN_BLESSING_OF_TIDES "Your overconfidence will be your undoing! Guards, lend me your strength!" +#define SAY_MISC "Alana be'lendor!" // don't know what use this #define MAX_ADVISORS 3 -//Fathom-Lord Karathress AI +// Fathom-Lord Karathress AI class boss_fathomlord_karathress : public CreatureScript { -public: - boss_fathomlord_karathress() : CreatureScript("boss_fathomlord_karathress") { } + public: + boss_fathomlord_karathress() : CreatureScript("boss_fathomlord_karathress") + { + } CreatureAI* GetAI(Creature* creature) const override { @@ -120,7 +122,7 @@ class boss_fathomlord_karathress : public CreatureScript void Initialize() { CataclysmicBolt_Timer = 10000; - Enrage_Timer = 600000; //10 minutes + Enrage_Timer = 600000; // 10 minutes SearNova_Timer = 20000 + rand32() % 40000; // 20 - 60 seconds BlessingOfTides = false; @@ -207,7 +209,7 @@ class boss_fathomlord_karathress : public CreatureScript instance->SetData(DATA_FATHOMLORDKARATHRESSEVENT, DONE); - //support for quest 10944 + // support for quest 10944 me->SummonCreature(SEER_OLUM, OLUM_X, OLUM_Y, OLUM_Z, OLUM_O, TEMPSUMMON_TIMED_DESPAWN, 3600000); } @@ -218,7 +220,7 @@ class boss_fathomlord_karathress : public CreatureScript void UpdateAI(uint32 diff) override { - //Only if not incombat check if the event is started + // Only if not incombat check if the event is started if (!me->IsInCombat() && instance->GetData(DATA_KARATHRESSEVENT)) { if (Unit* target = ObjectAccessor::GetUnit(*me, instance->GetGuidData(DATA_KARATHRESSEVENT_STARTER))) @@ -228,47 +230,53 @@ class boss_fathomlord_karathress : public CreatureScript } } - //Return since we have no target + // Return since we have no target if (!UpdateVictim()) return; - //someone evaded! + // someone evaded! if (!instance->GetData(DATA_KARATHRESSEVENT)) { EnterEvadeMode(); return; } - //CataclysmicBolt_Timer + // CataclysmicBolt_Timer if (CataclysmicBolt_Timer <= diff) { - //select a random unit other than the main tank + // select a random unit other than the main tank Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1); - //if there aren't other units, cast on the tank + // if there aren't other units, cast on the tank if (!target) target = me->GetVictim(); if (target) DoCast(target, SPELL_CATACLYSMIC_BOLT); CataclysmicBolt_Timer = 10000; - } else CataclysmicBolt_Timer -= diff; + } + else + CataclysmicBolt_Timer -= diff; - //SearNova_Timer + // SearNova_Timer if (SearNova_Timer <= diff) { DoCastVictim(SPELL_SEAR_NOVA); SearNova_Timer = 20000 + rand32() % 40000; - } else SearNova_Timer -= diff; + } + else + SearNova_Timer -= diff; - //Enrage_Timer + // Enrage_Timer if (Enrage_Timer <= diff) { DoCast(me, SPELL_ENRAGE); Enrage_Timer = 90000; - } else Enrage_Timer -= diff; + } + else + Enrage_Timer -= diff; - //Blessing of Tides Trigger + // Blessing of Tides Trigger if (!HealthAbovePct(75) && !BlessingOfTides) { BlessingOfTides = true; @@ -294,14 +302,15 @@ class boss_fathomlord_karathress : public CreatureScript DoMeleeAttackIfReady(); } }; - }; -//Fathom-Guard Sharkkis AI +// Fathom-Guard Sharkkis AI class boss_fathomguard_sharkkis : public CreatureScript { -public: - boss_fathomguard_sharkkis() : CreatureScript("boss_fathomguard_sharkkis") { } + public: + boss_fathomguard_sharkkis() : CreatureScript("boss_fathomguard_sharkkis") + { + } CreatureAI* GetAI(Creature* creature) const override { @@ -343,7 +352,7 @@ class boss_fathomguard_sharkkis : public CreatureScript Creature* Pet = ObjectAccessor::GetCreature(*me, SummonedPet); if (Pet && Pet->IsAlive()) - Pet->DealDamage(Pet, Pet->GetHealth(), nullptr, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, nullptr, false); + Pet->KillSelf(); SummonedPet.Clear(); @@ -364,39 +373,43 @@ class boss_fathomguard_sharkkis : public CreatureScript void UpdateAI(uint32 diff) override { - //Only if not incombat check if the event is started + // Only if not incombat check if the event is started if (!me->IsInCombat() && instance->GetData(DATA_KARATHRESSEVENT)) { if (Unit* target = ObjectAccessor::GetUnit(*me, instance->GetGuidData(DATA_KARATHRESSEVENT_STARTER))) AttackStart(target); } - //Return since we have no target + // Return since we have no target if (!UpdateVictim()) return; - //someone evaded! + // someone evaded! if (!instance->GetData(DATA_KARATHRESSEVENT)) { EnterEvadeMode(); return; } - //LeechingThrow_Timer + // LeechingThrow_Timer if (LeechingThrow_Timer <= diff) { DoCastVictim(SPELL_LEECHING_THROW); LeechingThrow_Timer = 20000; - } else LeechingThrow_Timer -= diff; + } + else + LeechingThrow_Timer -= diff; - //Multishot_Timer + // Multishot_Timer if (Multishot_Timer <= diff) { DoCastVictim(SPELL_MULTISHOT); Multishot_Timer = 20000; - } else Multishot_Timer -= diff; + } + else + Multishot_Timer -= diff; - //TheBeastWithin_Timer + // TheBeastWithin_Timer if (TheBeastWithin_Timer <= diff) { DoCast(me, SPELL_THE_BEAST_WITHIN); @@ -406,25 +419,27 @@ class boss_fathomguard_sharkkis : public CreatureScript Pet->CastSpell(Pet, SPELL_PET_ENRAGE, true); TheBeastWithin_Timer = 30000; - } else TheBeastWithin_Timer -= diff; + } + else + TheBeastWithin_Timer -= diff; - //Pet_Timer + // Pet_Timer if (Pet_Timer < diff && pet == false) { pet = true; - //uint32 spell_id; + // uint32 spell_id; uint32 pet_id; if (!urand(0, 1)) { - //spell_id = SPELL_SUMMON_FATHOM_LURKER; + // spell_id = SPELL_SUMMON_FATHOM_LURKER; pet_id = CREATURE_FATHOM_LURKER; } else { - //spell_id = SPELL_SUMMON_FATHOM_SPOREBAT; + // spell_id = SPELL_SUMMON_FATHOM_SPOREBAT; pet_id = CREATURE_FATHOM_SPOREBAT; } - //DoCast(me, spell_id, true); + // DoCast(me, spell_id, true); if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) { if (Creature* Pet = DoSpawnCreature(pet_id, 0, 0, 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000)) @@ -433,19 +448,22 @@ class boss_fathomguard_sharkkis : public CreatureScript SummonedPet = Pet->GetGUID(); } } - } else Pet_Timer -= diff; + } + else + Pet_Timer -= diff; DoMeleeAttackIfReady(); } }; - }; -//Fathom-Guard Tidalvess AI +// Fathom-Guard Tidalvess AI class boss_fathomguard_tidalvess : public CreatureScript { -public: - boss_fathomguard_tidalvess() : CreatureScript("boss_fathomguard_tidalvess") { } + public: + boss_fathomguard_tidalvess() : CreatureScript("boss_fathomguard_tidalvess") + { + } CreatureAI* GetAI(Creature* creature) const override { @@ -497,18 +515,18 @@ class boss_fathomguard_tidalvess : public CreatureScript void UpdateAI(uint32 diff) override { - //Only if not incombat check if the event is started + // Only if not incombat check if the event is started if (!me->IsInCombat() && instance->GetData(DATA_KARATHRESSEVENT)) { if (Unit* target = ObjectAccessor::GetUnit(*me, instance->GetGuidData(DATA_KARATHRESSEVENT_STARTER))) AttackStart(target); } - //Return since we have no target + // Return since we have no target if (!UpdateVictim()) return; - //someone evaded! + // someone evaded! if (!instance->GetData(DATA_KARATHRESSEVENT)) { EnterEvadeMode(); @@ -520,14 +538,16 @@ class boss_fathomguard_tidalvess : public CreatureScript DoCast(me, SPELL_WINDFURY_WEAPON); } - //FrostShock_Timer + // FrostShock_Timer if (FrostShock_Timer <= diff) { DoCastVictim(SPELL_FROST_SHOCK); FrostShock_Timer = 25000 + rand32() % 5000; - } else FrostShock_Timer -= diff; + } + else + FrostShock_Timer -= diff; - //Spitfire_Timer + // Spitfire_Timer if (Spitfire_Timer <= diff) { DoCast(me, SPELL_SPITFIRE_TOTEM); @@ -539,7 +559,7 @@ class boss_fathomguard_tidalvess : public CreatureScript else Spitfire_Timer -= diff; - //PoisonCleansing_Timer + // PoisonCleansing_Timer if (PoisonCleansing_Timer <= diff) { DoCast(me, SPELL_POISON_CLEANSING_TOTEM); @@ -548,7 +568,7 @@ class boss_fathomguard_tidalvess : public CreatureScript else PoisonCleansing_Timer -= diff; - //Earthbind_Timer + // Earthbind_Timer if (Earthbind_Timer <= diff) { DoCast(me, SPELL_EARTHBIND_TOTEM); @@ -560,14 +580,15 @@ class boss_fathomguard_tidalvess : public CreatureScript DoMeleeAttackIfReady(); } }; - }; -//Fathom-Guard Caribdis AI +// Fathom-Guard Caribdis AI class boss_fathomguard_caribdis : public CreatureScript { -public: - boss_fathomguard_caribdis() : CreatureScript("boss_fathomguard_caribdis") { } + public: + boss_fathomguard_caribdis() : CreatureScript("boss_fathomguard_caribdis") + { + } CreatureAI* GetAI(Creature* creature) const override { @@ -618,32 +639,34 @@ class boss_fathomguard_caribdis : public CreatureScript void UpdateAI(uint32 diff) override { - //Only if not incombat check if the event is started + // Only if not incombat check if the event is started if (!me->IsInCombat() && instance->GetData(DATA_KARATHRESSEVENT)) { if (Unit* target = ObjectAccessor::GetUnit(*me, instance->GetGuidData(DATA_KARATHRESSEVENT_STARTER))) AttackStart(target); } - //Return since we have no target + // Return since we have no target if (!UpdateVictim()) return; - //someone evaded! + // someone evaded! if (!instance->GetData(DATA_KARATHRESSEVENT)) { EnterEvadeMode(); return; } - //WaterBoltVolley_Timer + // WaterBoltVolley_Timer if (WaterBoltVolley_Timer <= diff) { DoCastVictim(SPELL_WATER_BOLT_VOLLEY); WaterBoltVolley_Timer = 30000; - } else WaterBoltVolley_Timer -= diff; + } + else + WaterBoltVolley_Timer -= diff; - //TidalSurge_Timer + // TidalSurge_Timer if (TidalSurge_Timer <= diff) { DoCastVictim(SPELL_TIDAL_SURGE); @@ -651,12 +674,14 @@ class boss_fathomguard_caribdis : public CreatureScript if (me->GetVictim()) me->EnsureVictim()->CastSpell(me->GetVictim(), SPELL_TIDAL_SURGE_FREEZE, true); TidalSurge_Timer = 15000 + rand32() % 5000; - } else TidalSurge_Timer -= diff; + } + else + TidalSurge_Timer -= diff; - //Cyclone_Timer + // Cyclone_Timer if (Cyclone_Timer <= diff) { - //DoCast(me, SPELL_SUMMON_CYCLONE); // Doesn't work + // DoCast(me, SPELL_SUMMON_CYCLONE); // Doesn't work Cyclone_Timer = 30000 + rand32() % 10000; if (Creature* Cyclone = me->SummonCreature(CREATURE_CYCLONE, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), float(rand32() % 5), TEMPSUMMON_TIMED_DESPAWN, 15000)) @@ -672,7 +697,7 @@ class boss_fathomguard_caribdis : public CreatureScript else Cyclone_Timer -= diff; - //Heal_Timer + // Heal_Timer if (Heal_Timer <= diff) { // It can be cast on any of the mobs diff --git a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp index 486d4e65..18516bc9 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp @@ -22,61 +22,63 @@ SDComment: Possesion Support SDCategory: Coilfang Resevoir, Serpent Shrine Cavern EndScriptData */ -#include "ScriptMgr.h" #include "InstanceScript.h" #include "Map.h" #include "MotionMaster.h" #include "ObjectAccessor.h" #include "Player.h" +#include "ScriptMgr.h" #include "ScriptedCreature.h" -#include "serpent_shrine.h" #include "TemporarySummon.h" +#include "serpent_shrine.h" enum LeotherasTheBlind { // Spells used by Leotheras The Blind - SPELL_WHIRLWIND = 37640, - SPELL_CHAOS_BLAST = 37674, - SPELL_BERSERK = 26662, + SPELL_WHIRLWIND = 37640, + SPELL_CHAOS_BLAST = 37674, + SPELL_BERSERK = 26662, SPELL_INSIDIOUS_WHISPER = 37676, - SPELL_DUAL_WIELD = 42459, + SPELL_DUAL_WIELD = 42459, // Spells used in banish phase - BANISH_BEAM = 38909, - AURA_BANISH = 37833, + BANISH_BEAM = 38909, + AURA_BANISH = 37833, // Spells used by Greyheart Spellbinders - SPELL_EARTHSHOCK = 39076, - SPELL_MINDBLAST = 37531, + SPELL_EARTHSHOCK = 39076, + SPELL_MINDBLAST = 37531, // Spells used by Inner Demons and Creature ID - INNER_DEMON_ID = 21857, - AURA_DEMONIC_ALIGNMENT = 37713, - SPELL_SHADOWBOLT = 39309, - SPELL_SOUL_LINK = 38007, + INNER_DEMON_ID = 21857, + AURA_DEMONIC_ALIGNMENT = 37713, + SPELL_SHADOWBOLT = 39309, + SPELL_SOUL_LINK = 38007, SPELL_CONSUMING_MADNESS = 37749, - //Misc. - MODEL_DEMON = 20125, - MODEL_NIGHTELF = 20514, - DEMON_FORM = 21875, - NPC_SPELLBINDER = 21806, - INNER_DEMON_VICTIM = 1, - - SAY_AGGRO = 0, - SAY_SWITCH_TO_DEMON = 1, - SAY_INNER_DEMONS = 2, - SAY_DEMON_SLAY = 3, - SAY_NIGHTELF_SLAY = 4, - SAY_FINAL_FORM = 5, - SAY_FREE = 6, - SAY_DEATH = 7 + // Misc. + MODEL_DEMON = 20125, + MODEL_NIGHTELF = 20514, + DEMON_FORM = 21875, + NPC_SPELLBINDER = 21806, + INNER_DEMON_VICTIM = 1, + + SAY_AGGRO = 0, + SAY_SWITCH_TO_DEMON = 1, + SAY_INNER_DEMONS = 2, + SAY_DEMON_SLAY = 3, + SAY_NIGHTELF_SLAY = 4, + SAY_FINAL_FORM = 5, + SAY_FREE = 6, + SAY_DEATH = 7 }; class npc_inner_demon : public CreatureScript { -public: - npc_inner_demon() : CreatureScript("npc_inner_demon") { } + public: + npc_inner_demon() : CreatureScript("npc_inner_demon") + { + } CreatureAI* GetAI(Creature* creature) const override { @@ -112,7 +114,7 @@ class npc_inner_demon : public CreatureScript victimGUID = guid; } - ObjectGuid GetGUID(int32 id/* = 0 */) const override + ObjectGuid GetGUID(int32 id /* = 0 */) const override { if (id == INNER_DEMON_VICTIM) return victimGUID; @@ -126,7 +128,7 @@ class npc_inner_demon : public CreatureScript unit->RemoveAurasDueToSpell(SPELL_INSIDIOUS_WHISPER); } - void DamageTaken(Unit* done_by, uint32 &damage) override + void DamageTaken(Unit* done_by, uint32& damage) override { if (done_by->GetGUID() != victimGUID && done_by->GetGUID() != me->GetGUID()) { @@ -143,7 +145,7 @@ class npc_inner_demon : public CreatureScript void UpdateAI(uint32 diff) override { - //Return since we have no target + // Return since we have no target if (!UpdateVictim() || !me->GetVictim()) return; @@ -155,9 +157,10 @@ class npc_inner_demon : public CreatureScript { AddThreat(owner, 999999); AttackStart(owner); - } else if (owner && owner->isDead()) + } + else if (owner && owner->isDead()) { - me->DealDamage(me, me->GetHealth(), nullptr, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, nullptr, false); + me->KillSelf(); return; } } @@ -166,7 +169,9 @@ class npc_inner_demon : public CreatureScript { DoCastVictim(SPELL_SOUL_LINK, true); Link_Timer = 1000; - } else Link_Timer -= diff; + } + else + Link_Timer -= diff; if (!me->HasAura(AURA_DEMONIC_ALIGNMENT)) DoCast(me, AURA_DEMONIC_ALIGNMENT, true); @@ -175,18 +180,22 @@ class npc_inner_demon : public CreatureScript { DoCastVictim(SPELL_SHADOWBOLT, false); ShadowBolt_Timer = 10000; - } else ShadowBolt_Timer -= diff; + } + else + ShadowBolt_Timer -= diff; - DoMeleeAttackIfReady(); + DoMeleeAttackIfReady(); } }; }; -//Original Leotheras the Blind AI +// Original Leotheras the Blind AI class boss_leotheras_the_blind : public CreatureScript { -public: - boss_leotheras_the_blind() : CreatureScript("boss_leotheras_the_blind") { } + public: + boss_leotheras_the_blind() : CreatureScript("boss_leotheras_the_blind") + { + } CreatureAI* GetAI(Creature* creature) const override { @@ -250,10 +259,10 @@ class boss_leotheras_the_blind : public CreatureScript me->SetCanDualWield(true); me->SetSpeedRate(MOVE_RUN, 2.0f); me->SetDisplayId(MODEL_NIGHTELF); - me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID , 0); - me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID+1, 0); + me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID, 0); + me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 1, 0); DoCast(me, SPELL_DUAL_WIELD, true); - me->SetCorpseDelay(1000*60*60); + me->SetCorpseDelay(1000 * 60 * 60); instance->SetData(DATA_LEOTHERASTHEBLINDEVENT, NOT_STARTED); } @@ -267,9 +276,24 @@ class boss_leotheras_the_blind : public CreatureScript float nx = x; float ny = y; float o = 2.4f; - if (i == 0) {nx += 10; ny -= 5; o=2.5f;} - if (i == 1) {nx -= 8; ny -= 7; o=0.9f;} - if (i == 2) {nx -= 3; ny += 9; o=5.0f;} + if (i == 0) + { + nx += 10; + ny -= 5; + o = 2.5f; + } + if (i == 1) + { + nx -= 8; + ny -= 7; + o = 0.9f; + } + if (i == 2) + { + nx -= 3; + ny += 9; + o = 5.0f; + } Creature* binder = me->SummonCreature(NPC_SPELLBINDER, nx, ny, z, o, TEMPSUMMON_DEAD_DESPAWN, 0); if (binder) SpellBinderGUID[i] = binder->GetGUID(); @@ -347,19 +371,19 @@ class boss_leotheras_the_blind : public CreatureScript me->SetDisplayId(MODEL_DEMON); // and removing weapons - me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID , 0); - me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID+1, 0); + me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID, 0); + me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 1, 0); } } - //Despawn all Inner Demon summoned + // Despawn all Inner Demon summoned void DespawnDemon() { - for (uint8 i=0; i<5; ++i) + for (uint8 i = 0; i < 5; ++i) { if (InnderDemon[i]) { - //delete creature + // delete creature Creature* creature = ObjectAccessor::GetCreature((*me), InnderDemon[i]); if (creature && creature->IsAlive()) creature->DespawnOrUnsummon(); @@ -371,7 +395,7 @@ class boss_leotheras_the_blind : public CreatureScript InnerDemon_Count = 0; } - void CastConsumingMadness() //remove this once SPELL_INSIDIOUS_WHISPER is supported by core + void CastConsumingMadness() // remove this once SPELL_INSIDIOUS_WHISPER is supported by core { for (uint8 i = 0; i < 5; ++i) { @@ -403,7 +427,7 @@ class boss_leotheras_the_blind : public CreatureScript { Talk(SAY_DEATH); - //despawn copy + // despawn copy if (Demon) { if (Creature* pDemon = ObjectAccessor::GetCreature(*me, Demon)) @@ -415,21 +439,23 @@ class boss_leotheras_the_blind : public CreatureScript void JustEngagedWith(Unit* /*who*/) override { if (me->HasAura(AURA_BANISH)) - return; + return; me->LoadEquipment(); } void UpdateAI(uint32 diff) override { - //Return since we have no target + // Return since we have no target if (me->HasAura(AURA_BANISH) || !UpdateVictim()) { if (BanishTimer <= diff) { - CheckBanish();//no need to check every update tick + CheckBanish(); // no need to check every update tick BanishTimer = 1000; - } else BanishTimer -= diff; + } + else + BanishTimer -= diff; return; } if (me->HasAura(SPELL_WHIRLWIND)) @@ -444,7 +470,9 @@ class boss_leotheras_the_blind : public CreatureScript me->GetMotionMaster()->MovePoint(0, newTarget->GetPositionX(), newTarget->GetPositionY(), newTarget->GetPositionZ()); } Whirlwind_Timer = 2000; - } else Whirlwind_Timer -= diff; + } + else + Whirlwind_Timer -= diff; } // reseting after changing forms and after ending whirlwind @@ -454,7 +482,7 @@ class boss_leotheras_the_blind : public CreatureScript if (DemonForm) InnerDemons_Timer = 30000; else - Whirlwind_Timer = 15000; + Whirlwind_Timer = 15000; NeedThreatReset = false; ResetThreatList(); @@ -462,17 +490,19 @@ class boss_leotheras_the_blind : public CreatureScript me->GetMotionMaster()->MoveChase(me->GetVictim()); } - //Enrage_Timer (10 min) + // Enrage_Timer (10 min) if (Berserk_Timer < diff && !EnrageUsed) { me->InterruptNonMeleeSpells(false); DoCast(me, SPELL_BERSERK); EnrageUsed = true; - } else Berserk_Timer -= diff; + } + else + Berserk_Timer -= diff; if (!DemonForm) { - //Whirldind Timer + // Whirldind Timer if (!me->HasAura(SPELL_WHIRLWIND)) { if (Whirlwind_Timer <= diff) @@ -481,30 +511,34 @@ class boss_leotheras_the_blind : public CreatureScript // while whirlwinding this variable is used to countdown target's change Whirlwind_Timer = 2000; NeedThreatReset = true; - } else Whirlwind_Timer -= diff; + } + else + Whirlwind_Timer -= diff; } - //Switch_Timer + // Switch_Timer if (!IsFinalForm) { if (SwitchToDemon_Timer <= diff) { - //switch to demon form + // switch to demon form me->RemoveAurasDueToSpell(SPELL_WHIRLWIND); me->SetDisplayId(MODEL_DEMON); Talk(SAY_SWITCH_TO_DEMON); - me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID , 0); - me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID+1, 0); + me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID, 0); + me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 1, 0); DemonForm = true; NeedThreatReset = true; SwitchToDemon_Timer = 45000; - } else SwitchToDemon_Timer -= diff; + } + else + SwitchToDemon_Timer -= diff; } DoMeleeAttackIfReady(); } else { - //ChaosBlast_Timer + // ChaosBlast_Timer if (!me->GetVictim()) return; if (me->IsWithinDist(me->GetVictim(), 30)) @@ -514,13 +548,15 @@ class boss_leotheras_the_blind : public CreatureScript // will cast only when in range of spell if (me->IsWithinDist(me->GetVictim(), 30)) { - //DoCastVictim(SPELL_CHAOS_BLAST, true); + // DoCastVictim(SPELL_CHAOS_BLAST, true); int damage = 100; DoCast(me->GetVictim(), SPELL_CHAOS_BLAST, CastSpellExtraArgs(damage).SetOriginalCaster(me->GetGUID())); } ChaosBlast_Timer = 3000; - } else ChaosBlast_Timer -= diff; - //Summon Inner Demon + } + else + ChaosBlast_Timer -= diff; + // Summon Inner Demon if (InnerDemons_Timer <= diff) { ThreatManager const& mgr = me->GetThreatManager(); @@ -532,12 +568,13 @@ class boss_leotheras_the_blind : public CreatureScript if (tempTarget != currentVictim && TargetList.size() < 5) TargetList.push_back(tempTarget); } - //SpellInfo* spell = GET_SPELL(SPELL_INSIDIOUS_WHISPER); + // SpellInfo* spell = GET_SPELL(SPELL_INSIDIOUS_WHISPER); for (auto itr = TargetList.begin(), end = TargetList.end(); itr != end; ++itr) { if ((*itr) && (*itr)->IsAlive()) { - Creature* demon = me->SummonCreature(INNER_DEMON_ID, (*itr)->GetPositionX()+10, (*itr)->GetPositionY()+10, (*itr)->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); + Creature* demon = + me->SummonCreature(INNER_DEMON_ID, (*itr)->GetPositionX() + 10, (*itr)->GetPositionY() + 10, (*itr)->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); if (demon) { demon->AI()->AttackStart((*itr)); @@ -548,10 +585,10 @@ class boss_leotheras_the_blind : public CreatureScript if (InnerDemon_Count > 4) InnerDemon_Count = 0; - //Safe storing of creatures + // Safe storing of creatures InnderDemon[InnerDemon_Count] = demon->GetGUID(); - //Update demon count + // Update demon count ++InnerDemon_Count; } } @@ -559,12 +596,14 @@ class boss_leotheras_the_blind : public CreatureScript Talk(SAY_INNER_DEMONS); InnerDemons_Timer = 999999; - } else InnerDemons_Timer -= diff; + } + else + InnerDemons_Timer -= diff; - //Switch_Timer + // Switch_Timer if (SwitchToHuman_Timer <= diff) { - //switch to nightelf form + // switch to nightelf form me->SetDisplayId(MODEL_NIGHTELF); me->LoadEquipment(); @@ -575,12 +614,14 @@ class boss_leotheras_the_blind : public CreatureScript NeedThreatReset = true; SwitchToHuman_Timer = 60000; - } else SwitchToHuman_Timer -= diff; + } + else + SwitchToHuman_Timer -= diff; } if (!IsFinalForm && HealthBelowPct(15)) { - //at this point he divides himself in two parts + // at this point he divides himself in two parts CastConsumingMadness(); DespawnDemon(); if (Creature* Copy = DoSpawnCreature(DEMON_FORM, 0, 0, 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 6000)) @@ -589,7 +630,7 @@ class boss_leotheras_the_blind : public CreatureScript if (me->GetVictim()) Copy->AI()->AttackStart(me->GetVictim()); } - //set nightelf final form + // set nightelf final form IsFinalForm = true; DemonForm = false; @@ -601,11 +642,13 @@ class boss_leotheras_the_blind : public CreatureScript }; }; -//Leotheras the Blind Demon Form AI +// Leotheras the Blind Demon Form AI class boss_leotheras_the_blind_demonform : public CreatureScript { -public: - boss_leotheras_the_blind_demonform() : CreatureScript("boss_leotheras_the_blind_demonform") { } + public: + boss_leotheras_the_blind_demonform() : CreatureScript("boss_leotheras_the_blind_demonform") + { + } CreatureAI* GetAI(Creature* creature) const override { @@ -648,7 +691,7 @@ class boss_leotheras_the_blind_demonform : public CreatureScript void JustDied(Unit* /*killer*/) override { - //invisibility (blizzlike, at the end of the fight he doesn't die, he disappears) + // invisibility (blizzlike, at the end of the fight he doesn't die, he disappears) DoCast(me, 8149, true); } @@ -659,34 +702,38 @@ class boss_leotheras_the_blind_demonform : public CreatureScript void UpdateAI(uint32 diff) override { - //Return since we have no target + // Return since we have no target if (!UpdateVictim()) return; - //ChaosBlast_Timer + // ChaosBlast_Timer if (me->IsWithinDist(me->GetVictim(), 30)) me->StopMoving(); if (ChaosBlast_Timer <= diff) - { + { // will cast only when in range od spell if (me->IsWithinDist(me->GetVictim(), 30)) { - //DoCastVictim(SPELL_CHAOS_BLAST, true); + // DoCastVictim(SPELL_CHAOS_BLAST, true); int damage = 100; DoCast(me->GetVictim(), SPELL_CHAOS_BLAST, CastSpellExtraArgs(damage).SetOriginalCaster(me->GetGUID())); ChaosBlast_Timer = 3000; } - } else ChaosBlast_Timer -= diff; + } + else + ChaosBlast_Timer -= diff; - //Do NOT deal any melee damage to the target. + // Do NOT deal any melee damage to the target. } }; }; class npc_greyheart_spellbinder : public CreatureScript { -public: - npc_greyheart_spellbinder() : CreatureScript("npc_greyheart_spellbinder") { } + public: + npc_greyheart_spellbinder() : CreatureScript("npc_greyheart_spellbinder") + { + } CreatureAI* GetAI(Creature* creature) const override { @@ -781,7 +828,9 @@ class npc_greyheart_spellbinder : public CreatureScript DoCast(target, SPELL_MINDBLAST); Mindblast_Timer = urand(10000, 15000); - } else Mindblast_Timer -= diff; + } + else + Mindblast_Timer -= diff; if (Earthshock_Timer <= diff) { @@ -803,11 +852,15 @@ class npc_greyheart_spellbinder : public CreatureScript } } Earthshock_Timer = urand(8000, 15000); - } else Earthshock_Timer -= diff; + } + else + Earthshock_Timer -= diff; DoMeleeAttackIfReady(); } - void JustDied(Unit* /*killer*/) override { } + void JustDied(Unit* /*killer*/) override + { + } }; }; diff --git a/src/server/scripts/Outland/CoilfangReservoir/TheSlavePens/boss_ahune.cpp b/src/server/scripts/Outland/CoilfangReservoir/TheSlavePens/boss_ahune.cpp index 554f73f8..b394e3aa 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/TheSlavePens/boss_ahune.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/TheSlavePens/boss_ahune.cpp @@ -15,7 +15,6 @@ * with this program. If not, see . */ -#include "ScriptMgr.h" #include "CreatureTextMgr.h" #include "GameObject.h" #include "GameObjectAI.h" @@ -26,6 +25,7 @@ #include "MotionMaster.h" #include "ObjectAccessor.h" #include "Player.h" +#include "ScriptMgr.h" #include "ScriptedCreature.h" #include "ScriptedGossip.h" #include "SpellAuraEffects.h" @@ -36,107 +36,107 @@ enum Spells { // Ahune - SPELL_SYNCH_HEALTH = 46430, - SPELL_AHUNES_SHIELD = 45954, - SPELL_STAY_SUBMERGED = 46981, - SPELL_AHUNE_SELF_STUN = 46416, - SPELL_AHUNE_ACHIEVEMENT = 62043, - SPELL_AHUNE_SPANKY_HANDS = 46146, - SPELL_COLD_SLAP = 46145, - SPELL_RESURFACE = 46402, - SPELL_SUBMERGED = 37751, - SPELL_STAND = 37752, - - //Earther Ring Flamecaller - SPELL_FIND_OPENING_VISUAL = 45964, - SPELL_FIND_OPENING_BEAM_END = 46333, - SPELL_FIND_OPENING_TRIGGER = 46341, - SPELL_FIND_OPENING_CHANNEL = 46345, - SPELL_BONFIRE_VISUAL = 46339, - SPELL_FOUND_OPENING = 46421, - - //Ahune Bunny - SPELL_SUMMON_COLDWEAVE = 46143, - SPELL_SUMMON_FROSTWIND = 46382, - SPELL_SUMMON_HAILSTONE = 46176, - SPELL_SUMMONING_VISUAL_1 = 45937, - SPELL_SUMMONING_RHYME_AURA = 45926, - SPELL_SUMMONING_RHYME_BONFIRE = 45930, - SPELL_FORCE_WHISP_FLIGHT = 46603, - SPELL_SHAMANS_LOOK_FOR_OPENING = 46422, - SPELL_CLOSE_OPENING_VISUAL = 46236, - SPELL_ICE_BOMBARD = 46397, - SPELL_ICE_BOMBARDMENT_DEST_PICKER = 46398, - SPELL_ICE_BOMBARDMENT = 46396, + SPELL_SYNCH_HEALTH = 46430, + SPELL_AHUNES_SHIELD = 45954, + SPELL_STAY_SUBMERGED = 46981, + SPELL_AHUNE_SELF_STUN = 46416, + SPELL_AHUNE_ACHIEVEMENT = 62043, + SPELL_AHUNE_SPANKY_HANDS = 46146, + SPELL_COLD_SLAP = 46145, + SPELL_RESURFACE = 46402, + SPELL_SUBMERGED = 37751, + SPELL_STAND = 37752, + + // Earther Ring Flamecaller + SPELL_FIND_OPENING_VISUAL = 45964, + SPELL_FIND_OPENING_BEAM_END = 46333, + SPELL_FIND_OPENING_TRIGGER = 46341, + SPELL_FIND_OPENING_CHANNEL = 46345, + SPELL_BONFIRE_VISUAL = 46339, + SPELL_FOUND_OPENING = 46421, + + // Ahune Bunny + SPELL_SUMMON_COLDWEAVE = 46143, + SPELL_SUMMON_FROSTWIND = 46382, + SPELL_SUMMON_HAILSTONE = 46176, + SPELL_SUMMONING_VISUAL_1 = 45937, + SPELL_SUMMONING_RHYME_AURA = 45926, + SPELL_SUMMONING_RHYME_BONFIRE = 45930, + SPELL_FORCE_WHISP_FLIGHT = 46603, + SPELL_SHAMANS_LOOK_FOR_OPENING = 46422, + SPELL_CLOSE_OPENING_VISUAL = 46236, + SPELL_ICE_BOMBARD = 46397, + SPELL_ICE_BOMBARDMENT_DEST_PICKER = 46398, + SPELL_ICE_BOMBARDMENT = 46396, // Ice Spear - SPELL_SUMMON_ICE_SPEAR_BUNNY = 46359, - SPELL_ICE_SPEAR_KNOCKBACK = 46360, - SPELL_SUMMON_ICE_SPEAR_GO = 46369, - SPELL_ICE_SPEAR_AURA = 46371, - SPELL_ICE_SPEAR_TARGET_PICKER = 46372, - SPELL_ICE_SPEAR_DELAY = 46878, - SPELL_ICE_SPEAR_VISUAL = 75498, + SPELL_SUMMON_ICE_SPEAR_BUNNY = 46359, + SPELL_ICE_SPEAR_KNOCKBACK = 46360, + SPELL_SUMMON_ICE_SPEAR_GO = 46369, + SPELL_ICE_SPEAR_AURA = 46371, + SPELL_ICE_SPEAR_TARGET_PICKER = 46372, + SPELL_ICE_SPEAR_DELAY = 46878, + SPELL_ICE_SPEAR_VISUAL = 75498, // Slippery Floor - SPELL_SLIPPERY_FLOOR_AMBIENT = 46314, - SPELL_SLIPPERY_FLOOR_PERIODIC = 46320, - SPELL_SLIPPERY_FLOOR_SLIP = 45947, - SPELL_SLIPPERY_FLOOR_YOU_SLIPPED = 45946, + SPELL_SLIPPERY_FLOOR_AMBIENT = 46314, + SPELL_SLIPPERY_FLOOR_PERIODIC = 46320, + SPELL_SLIPPERY_FLOOR_SLIP = 45947, + SPELL_SLIPPERY_FLOOR_YOU_SLIPPED = 45946, // Frozen Core - SPELL_SUICIDE = 45254, - SPELL_SUMMON_LOOT_MISSILE = 45941, - SPELL_FROZEN_CORE_GETS_HIT = 46810, - SPELL_MINION_DESPAWNER = 46843, - SPELL_GHOST_DISGUISE = 46786 + SPELL_SUICIDE = 45254, + SPELL_SUMMON_LOOT_MISSILE = 45941, + SPELL_FROZEN_CORE_GETS_HIT = 46810, + SPELL_MINION_DESPAWNER = 46843, + SPELL_GHOST_DISGUISE = 46786 }; enum Emotes { - EMOTE_EARTHEN_ASSAULT = 0, - EMOTE_RETREAT = 0, - EMOTE_RESURFACE = 1 + EMOTE_EARTHEN_ASSAULT = 0, + EMOTE_RETREAT = 0, + EMOTE_RESURFACE = 1 }; enum Says { - SAY_PLAYER_TEXT_1 = 0, - SAY_PLAYER_TEXT_2 = 1, - SAY_PLAYER_TEXT_3 = 2 + SAY_PLAYER_TEXT_1 = 0, + SAY_PLAYER_TEXT_2 = 1, + SAY_PLAYER_TEXT_3 = 2 }; enum Events { - EVENT_EMERGE = 1, - EVENT_INITIAL_EMERGE = 2, - EVENT_SYNCH_HEALTH = 3, - EVENT_LOOKFOROPENING_0 = 4, - EVENT_LOOKFOROPENING_1 = 5, - EVENT_LOOKFOROPENING_2 = 6, - EVENT_SUMMON_HAILSTONE = 7, - EVENT_SUMMON_COLDWEAVE = 8, - EVENT_SUMMON_FROSTWIND = 9, - EVENT_SUMMON_AHUNE = 10, - EVENT_CLOSE_OPENING = 11, - EVENT_AHUNE_PHASE_ONE = 12, - EVENT_AHUNE_PHASE_TWO = 13, - EVENT_START_LOOKING_FOR_OPENING = 14, - EVENT_STOP_LOOKING_FOR_OPENING = 15 + EVENT_EMERGE = 1, + EVENT_INITIAL_EMERGE = 2, + EVENT_SYNCH_HEALTH = 3, + EVENT_LOOKFOROPENING_0 = 4, + EVENT_LOOKFOROPENING_1 = 5, + EVENT_LOOKFOROPENING_2 = 6, + EVENT_SUMMON_HAILSTONE = 7, + EVENT_SUMMON_COLDWEAVE = 8, + EVENT_SUMMON_FROSTWIND = 9, + EVENT_SUMMON_AHUNE = 10, + EVENT_CLOSE_OPENING = 11, + EVENT_AHUNE_PHASE_ONE = 12, + EVENT_AHUNE_PHASE_TWO = 13, + EVENT_START_LOOKING_FOR_OPENING = 14, + EVENT_STOP_LOOKING_FOR_OPENING = 15 }; enum Actions { - ACTION_START_EVENT = -2574500, - ACTION_AHUNE_RETREAT = -2586500, - ACTION_AHUNE_RESURFACE = -2586501, - ACTION_EMOTE_RESURFACE = -2575400 + ACTION_START_EVENT = -2574500, + ACTION_AHUNE_RETREAT = -2586500, + ACTION_AHUNE_RESURFACE = -2586501, + ACTION_EMOTE_RESURFACE = -2575400 }; enum Phases { - PHASE_ONE = 0, - PHASE_TWO = 1 + PHASE_ONE = 0, + PHASE_TWO = 1 }; enum Points @@ -148,31 +148,27 @@ enum Points enum Misc { - MAX_FLAMECALLERS = 3 + MAX_FLAMECALLERS = 3 }; -Position const SummonPositions[] = -{ - { -99.1021f, -233.7526f, -1.22307f, 1.588250f }, // Ahune - { -98.0151f, -230.4555f, -1.21089f, 1.797689f }, // Frozen Core - { -143.172f, -147.6801f, -3.16113f, 4.852015f }, // Bonfire Bunny 000 - { -134.304f, -145.7803f, -1.70332f, 4.677482f }, // Bonfire Bunny 001 - { -125.036f, -144.2065f, -1.91660f, 4.991642f }, // Bonfire Bunny 002 - { -69.8121f, -162.4954f, -2.30451f, 1.710423f }, // Wisp Source Bunny - { -98.1029f, -230.7864f, -10.8085f, 1.448623f } // Wisp Dest Bunny +Position const SummonPositions[] = { + {-99.1021f, -233.7526f, -1.22307f, 1.588250f}, // Ahune + {-98.0151f, -230.4555f, -1.21089f, 1.797689f}, // Frozen Core + {-143.172f, -147.6801f, -3.16113f, 4.852015f}, // Bonfire Bunny 000 + {-134.304f, -145.7803f, -1.70332f, 4.677482f}, // Bonfire Bunny 001 + {-125.036f, -144.2065f, -1.91660f, 4.991642f}, // Bonfire Bunny 002 + {-69.8121f, -162.4954f, -2.30451f, 1.710423f}, // Wisp Source Bunny + {-98.1029f, -230.7864f, -10.8085f, 1.448623f} // Wisp Dest Bunny }; -Position const FlameCallerSpots[] = -{ - { -145.2233f, -137.5543f, -1.59056f, 5.427049f }, - { -137.4383f, -136.4050f, -1.72384f, 5.336747f }, - { -129.0413f, -132.1494f, -2.09285f, 5.460842f } -}; +Position const FlameCallerSpots[] = {{-145.2233f, -137.5543f, -1.59056f, 5.427049f}, {-137.4383f, -136.4050f, -1.72384f, 5.336747f}, {-129.0413f, -132.1494f, -2.09285f, 5.460842f}}; class boss_ahune : public CreatureScript { -public: - boss_ahune() : CreatureScript("boss_ahune") { } + public: + boss_ahune() : CreatureScript("boss_ahune") + { + } struct boss_ahuneAI : public BossAI { @@ -201,9 +197,9 @@ class boss_ahune : public CreatureScript instance->DoCastSpellOnPlayers(SPELL_AHUNE_ACHIEVEMENT); if (Creature* ahuneBunny = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_AHUNE_BUNNY))) - me->Kill(ahuneBunny); + Unit::Kill(me, ahuneBunny); if (Creature* frozenCore = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_FROZEN_CORE))) - me->Kill(frozenCore); + Unit::Kill(me, frozenCore); Map::PlayerList const& players = me->GetMap()->GetPlayers(); if (!players.isEmpty()) @@ -236,23 +232,23 @@ class boss_ahune : public CreatureScript { switch (eventId) { - case EVENT_INITIAL_EMERGE: - DoCast(me, SPELL_STAND); - DoCast(me, SPELL_AHUNE_SPANKY_HANDS); - DoCast(me, SPELL_AHUNES_SHIELD); - break; - case EVENT_EMERGE: - Emerge(); - break; - case EVENT_SYNCH_HEALTH: - if (Creature* frozenCore = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_FROZEN_CORE))) - DoCast(frozenCore, SPELL_SYNCH_HEALTH, true); - else - DoCast(me, SPELL_SUICIDE); - events.Repeat(Seconds(3)); - break; - default: - break; + case EVENT_INITIAL_EMERGE: + DoCast(me, SPELL_STAND); + DoCast(me, SPELL_AHUNE_SPANKY_HANDS); + DoCast(me, SPELL_AHUNES_SHIELD); + break; + case EVENT_EMERGE: + Emerge(); + break; + case EVENT_SYNCH_HEALTH: + if (Creature* frozenCore = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_FROZEN_CORE))) + DoCast(frozenCore, SPELL_SYNCH_HEALTH, true); + else + DoCast(me, SPELL_SUICIDE); + events.Repeat(Seconds(3)); + break; + default: + break; } } DoMeleeAttackIfReady(); @@ -293,8 +289,10 @@ class boss_ahune : public CreatureScript class npc_frozen_core : public CreatureScript { -public: - npc_frozen_core() : CreatureScript("npc_frozen_core") { } + public: + npc_frozen_core() : CreatureScript("npc_frozen_core") + { + } struct npc_frozen_coreAI : public ScriptedAI { @@ -315,7 +313,7 @@ class npc_frozen_core : public CreatureScript void JustDied(Unit* /*killer*/) override { if (Creature* ahune = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_AHUNE))) - me->Kill(ahune); + Unit::Kill(me, ahune); DoCast(SPELL_SUMMON_LOOT_MISSILE); DoCast(SPELL_MINION_DESPAWNER); @@ -347,20 +345,20 @@ class npc_frozen_core : public CreatureScript { switch (eventId) { - case EVENT_SYNCH_HEALTH: - if (Creature* ahune = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_AHUNE))) - DoCast(ahune, SPELL_SYNCH_HEALTH, true); - else - DoCast(me, SPELL_SUICIDE); - _events.Repeat(Seconds(3)); - break; - default: - break; + case EVENT_SYNCH_HEALTH: + if (Creature* ahune = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_AHUNE))) + DoCast(ahune, SPELL_SYNCH_HEALTH, true); + else + DoCast(me, SPELL_SUICIDE); + _events.Repeat(Seconds(3)); + break; + default: + break; } } } - private: + private: InstanceScript* _instance; EventMap _events; }; @@ -373,8 +371,10 @@ class npc_frozen_core : public CreatureScript class npc_ahune_bunny : public CreatureScript { -public: - npc_ahune_bunny() : CreatureScript("npc_ahune_bunny") { } + public: + npc_ahune_bunny() : CreatureScript("npc_ahune_bunny") + { + } struct npc_ahune_bunnyAI : public ScriptedAI { @@ -445,60 +445,60 @@ class npc_ahune_bunny : public CreatureScript { switch (eventId) { - case EVENT_START_LOOKING_FOR_OPENING: - Talk(EMOTE_EARTHEN_ASSAULT); - for (uint8 counter = 0; counter < MAX_FLAMECALLERS; ++counter) - if (Creature* flamecaller = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_FLAMECALLER_000 + counter))) - DoCast(flamecaller, SPELL_SHAMANS_LOOK_FOR_OPENING, true); - break; - case EVENT_SUMMON_HAILSTONE: - DoCast(SPELL_SUMMON_HAILSTONE); - break; - case EVENT_SUMMON_COLDWEAVE: - DoCast(SPELL_SUMMON_COLDWEAVE); - DoCast(SPELL_SUMMON_COLDWEAVE); - _events.Repeat(Seconds(8)); - if (_submerged) - _events.ScheduleEvent(EVENT_SUMMON_FROSTWIND, Seconds(4), 0, PHASE_ONE); - break; - case EVENT_SUMMON_FROSTWIND: - DoCast(SPELL_SUMMON_FROSTWIND); - break; - case EVENT_SUMMON_AHUNE: - if (TempSummon* ahune = me->SummonCreature(NPC_AHUNE, SummonPositions[0], TEMPSUMMON_DEAD_DESPAWN)) - { - ahune->SummonCreature(NPC_FROZEN_CORE, SummonPositions[1], TEMPSUMMON_CORPSE_DESPAWN); - ahune->SetInCombatWithZone(); - DoCast(ahune, SPELL_RESURFACE); - } - break; - case EVENT_CLOSE_OPENING: - if (Creature* flamecaller = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_FLAMECALLER_000))) - flamecaller->AI()->DoAction(ACTION_EMOTE_RESURFACE); - DoCast(SPELL_CLOSE_OPENING_VISUAL); - DoCast(me, SPELL_ICE_BOMBARD); - break; - case EVENT_AHUNE_PHASE_TWO: - if (Creature* flamecaller = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_FLAMECALLER_000))) - DoCast(flamecaller, SPELL_FOUND_OPENING); - if (Creature* ahune = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_AHUNE))) - ahune->AI()->DoAction(ACTION_AHUNE_RETREAT); - _events.Reset(); - _events.SetPhase(PHASE_TWO); - _events.ScheduleEvent(EVENT_CLOSE_OPENING, Seconds(25), 0, PHASE_TWO); - _events.ScheduleEvent(EVENT_AHUNE_PHASE_ONE, Seconds(35), 0, PHASE_TWO); - break; - case EVENT_AHUNE_PHASE_ONE: - _submerged = true; - _events.Reset(); - _events.SetPhase(PHASE_ONE); - _events.ScheduleEvent(EVENT_SUMMON_COLDWEAVE, Seconds(8), 0, PHASE_ONE); - _events.ScheduleEvent(EVENT_SUMMON_HAILSTONE, Seconds(5), 0, PHASE_ONE); - _events.ScheduleEvent(EVENT_START_LOOKING_FOR_OPENING, Seconds(5), 0, PHASE_ONE); - _events.ScheduleEvent(EVENT_AHUNE_PHASE_TWO, Seconds(100), 0, PHASE_ONE); - break; - default: - break; + case EVENT_START_LOOKING_FOR_OPENING: + Talk(EMOTE_EARTHEN_ASSAULT); + for (uint8 counter = 0; counter < MAX_FLAMECALLERS; ++counter) + if (Creature* flamecaller = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_FLAMECALLER_000 + counter))) + DoCast(flamecaller, SPELL_SHAMANS_LOOK_FOR_OPENING, true); + break; + case EVENT_SUMMON_HAILSTONE: + DoCast(SPELL_SUMMON_HAILSTONE); + break; + case EVENT_SUMMON_COLDWEAVE: + DoCast(SPELL_SUMMON_COLDWEAVE); + DoCast(SPELL_SUMMON_COLDWEAVE); + _events.Repeat(Seconds(8)); + if (_submerged) + _events.ScheduleEvent(EVENT_SUMMON_FROSTWIND, Seconds(4), 0, PHASE_ONE); + break; + case EVENT_SUMMON_FROSTWIND: + DoCast(SPELL_SUMMON_FROSTWIND); + break; + case EVENT_SUMMON_AHUNE: + if (TempSummon* ahune = me->SummonCreature(NPC_AHUNE, SummonPositions[0], TEMPSUMMON_DEAD_DESPAWN)) + { + ahune->SummonCreature(NPC_FROZEN_CORE, SummonPositions[1], TEMPSUMMON_CORPSE_DESPAWN); + ahune->SetInCombatWithZone(); + DoCast(ahune, SPELL_RESURFACE); + } + break; + case EVENT_CLOSE_OPENING: + if (Creature* flamecaller = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_FLAMECALLER_000))) + flamecaller->AI()->DoAction(ACTION_EMOTE_RESURFACE); + DoCast(SPELL_CLOSE_OPENING_VISUAL); + DoCast(me, SPELL_ICE_BOMBARD); + break; + case EVENT_AHUNE_PHASE_TWO: + if (Creature* flamecaller = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_FLAMECALLER_000))) + DoCast(flamecaller, SPELL_FOUND_OPENING); + if (Creature* ahune = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_AHUNE))) + ahune->AI()->DoAction(ACTION_AHUNE_RETREAT); + _events.Reset(); + _events.SetPhase(PHASE_TWO); + _events.ScheduleEvent(EVENT_CLOSE_OPENING, Seconds(25), 0, PHASE_TWO); + _events.ScheduleEvent(EVENT_AHUNE_PHASE_ONE, Seconds(35), 0, PHASE_TWO); + break; + case EVENT_AHUNE_PHASE_ONE: + _submerged = true; + _events.Reset(); + _events.SetPhase(PHASE_ONE); + _events.ScheduleEvent(EVENT_SUMMON_COLDWEAVE, Seconds(8), 0, PHASE_ONE); + _events.ScheduleEvent(EVENT_SUMMON_HAILSTONE, Seconds(5), 0, PHASE_ONE); + _events.ScheduleEvent(EVENT_START_LOOKING_FOR_OPENING, Seconds(5), 0, PHASE_ONE); + _events.ScheduleEvent(EVENT_AHUNE_PHASE_TWO, Seconds(100), 0, PHASE_ONE); + break; + default: + break; } } } @@ -510,11 +510,11 @@ class npc_ahune_bunny : public CreatureScript flamecaller->AI()->EnterEvadeMode(); } - private: - InstanceScript* _instance; - EventMap _events; - SummonList _summons; - bool _submerged; + private: + InstanceScript* _instance; + EventMap _events; + SummonList _summons; + bool _submerged; }; CreatureAI* GetAI(Creature* creature) const override @@ -525,8 +525,10 @@ class npc_ahune_bunny : public CreatureScript class npc_earthen_ring_flamecaller : public CreatureScript { -public: - npc_earthen_ring_flamecaller() : CreatureScript("npc_earthen_ring_flamecaller") { } + public: + npc_earthen_ring_flamecaller() : CreatureScript("npc_earthen_ring_flamecaller") + { + } struct npc_earthen_ring_flamecallerAI : public ScriptedAI { @@ -548,20 +550,20 @@ class npc_earthen_ring_flamecaller : public CreatureScript switch (pointId) { - case POINT_FLAMECALLER_000: - _mySpot = POINT_FLAMECALLER_000; - me->SetOrientation(FlameCallerSpots[_mySpot].GetOrientation()); - break; - case POINT_FLAMECALLER_001: - _mySpot = POINT_FLAMECALLER_001; - me->SetOrientation(FlameCallerSpots[_mySpot].GetOrientation()); - break; - case POINT_FLAMECALLER_002: - _mySpot = POINT_FLAMECALLER_002; - me->SetOrientation(FlameCallerSpots[_mySpot].GetOrientation()); - break; - default: - break; + case POINT_FLAMECALLER_000: + _mySpot = POINT_FLAMECALLER_000; + me->SetOrientation(FlameCallerSpots[_mySpot].GetOrientation()); + break; + case POINT_FLAMECALLER_001: + _mySpot = POINT_FLAMECALLER_001; + me->SetOrientation(FlameCallerSpots[_mySpot].GetOrientation()); + break; + case POINT_FLAMECALLER_002: + _mySpot = POINT_FLAMECALLER_002; + me->SetOrientation(FlameCallerSpots[_mySpot].GetOrientation()); + break; + default: + break; } DoCast(me, SPELL_FIND_OPENING_CHANNEL); @@ -571,14 +573,14 @@ class npc_earthen_ring_flamecaller : public CreatureScript { switch (spellInfo->Id) { - case SPELL_SHAMANS_LOOK_FOR_OPENING: - _events.ScheduleEvent(EVENT_LOOKFOROPENING_0, Seconds(17)); - break; - case SPELL_FOUND_OPENING: - Talk(EMOTE_RETREAT); - break; - default: - break; + case SPELL_SHAMANS_LOOK_FOR_OPENING: + _events.ScheduleEvent(EVENT_LOOKFOROPENING_0, Seconds(17)); + break; + case SPELL_FOUND_OPENING: + Talk(EMOTE_RETREAT); + break; + default: + break; } } @@ -596,23 +598,23 @@ class npc_earthen_ring_flamecaller : public CreatureScript { switch (eventId) { - case EVENT_LOOKFOROPENING_0: - LookOpening(true, 0); - _events.ScheduleEvent(EVENT_LOOKFOROPENING_1, Seconds(26)); - break; - case EVENT_LOOKFOROPENING_1: - LookOpening(true, 1); - _events.ScheduleEvent(EVENT_LOOKFOROPENING_2, Seconds(25)); - break; - case EVENT_LOOKFOROPENING_2: - LookOpening(true, 2); - _events.ScheduleEvent(EVENT_STOP_LOOKING_FOR_OPENING, Seconds(27)); - break; - case EVENT_STOP_LOOKING_FOR_OPENING: - LookOpening(false, _mySpot); - break; - default: - break; + case EVENT_LOOKFOROPENING_0: + LookOpening(true, 0); + _events.ScheduleEvent(EVENT_LOOKFOROPENING_1, Seconds(26)); + break; + case EVENT_LOOKFOROPENING_1: + LookOpening(true, 1); + _events.ScheduleEvent(EVENT_LOOKFOROPENING_2, Seconds(25)); + break; + case EVENT_LOOKFOROPENING_2: + LookOpening(true, 2); + _events.ScheduleEvent(EVENT_STOP_LOOKING_FOR_OPENING, Seconds(27)); + break; + case EVENT_STOP_LOOKING_FOR_OPENING: + LookOpening(false, _mySpot); + break; + default: + break; } } } @@ -639,7 +641,7 @@ class npc_earthen_ring_flamecaller : public CreatureScript } } - private: + private: EventMap _events; InstanceScript* _instance; uint8 _mySpot; @@ -653,12 +655,16 @@ class npc_earthen_ring_flamecaller : public CreatureScript class go_ahune_ice_stone : public GameObjectScript { -public: - go_ahune_ice_stone() : GameObjectScript("go_ahune_ice_stone") { } + public: + go_ahune_ice_stone() : GameObjectScript("go_ahune_ice_stone") + { + } struct go_ahune_ice_stoneAI : public GameObjectAI { - go_ahune_ice_stoneAI(GameObject* go) : GameObjectAI(go), instance(go->GetInstanceScript()) { } + go_ahune_ice_stoneAI(GameObject* go) : GameObjectAI(go), instance(go->GetInstanceScript()) + { + } InstanceScript* instance; @@ -688,14 +694,16 @@ class go_ahune_ice_stone : public GameObjectScript // 46430 - Synch Health class spell_ahune_synch_health : public SpellScriptLoader { -public: - spell_ahune_synch_health() : SpellScriptLoader("spell_ahune_synch_health") { } + public: + spell_ahune_synch_health() : SpellScriptLoader("spell_ahune_synch_health") + { + } class spell_ahune_synch_health_SpellScript : public SpellScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo({ SPELL_SYNCH_HEALTH }); + return ValidateSpellInfo({SPELL_SYNCH_HEALTH}); } void HandleScript(SpellEffIndex /*effIndex*/) @@ -720,14 +728,16 @@ class spell_ahune_synch_health : public SpellScriptLoader // 45926 - Summoning Rhyme Aura class spell_summoning_rhyme_aura : public SpellScriptLoader { -public: - spell_summoning_rhyme_aura() : SpellScriptLoader("spell_summoning_rhyme_aura") { } + public: + spell_summoning_rhyme_aura() : SpellScriptLoader("spell_summoning_rhyme_aura") + { + } class spell_summoning_rhyme_aura_AuraScript : public AuraScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo({ SPELL_FORCE_WHISP_FLIGHT, SPELL_SUMMONING_RHYME_BONFIRE }); + return ValidateSpellInfo({SPELL_FORCE_WHISP_FLIGHT, SPELL_SUMMONING_RHYME_BONFIRE}); } void PeriodicTick(AuraEffect const* aurEff) @@ -745,17 +755,17 @@ class spell_summoning_rhyme_aura : public SpellScriptLoader switch (aurEff->GetTickNumber()) { - case 1: - sCreatureTextMgr->SendChat(caster, SAY_PLAYER_TEXT_1, nullptr, CHAT_MSG_SAY, LANG_UNIVERSAL, TEXT_RANGE_NORMAL, 0, TEAM_OTHER, false, player); - player->CastSpell(player, SPELL_SUMMONING_RHYME_BONFIRE, true); - break; - case 2: - sCreatureTextMgr->SendChat(caster, SAY_PLAYER_TEXT_2, nullptr, CHAT_MSG_SAY, LANG_UNIVERSAL, TEXT_RANGE_NORMAL, 0, TEAM_OTHER, false, player); - break; - case 3: - sCreatureTextMgr->SendChat(caster, SAY_PLAYER_TEXT_3, nullptr, CHAT_MSG_SAY, LANG_UNIVERSAL, TEXT_RANGE_NORMAL, 0, TEAM_OTHER, false, player); - Remove(); - break; + case 1: + sCreatureTextMgr->SendChat(caster, SAY_PLAYER_TEXT_1, nullptr, CHAT_MSG_SAY, LANG_UNIVERSAL, TEXT_RANGE_NORMAL, 0, TEAM_OTHER, false, player); + player->CastSpell(player, SPELL_SUMMONING_RHYME_BONFIRE, true); + break; + case 2: + sCreatureTextMgr->SendChat(caster, SAY_PLAYER_TEXT_2, nullptr, CHAT_MSG_SAY, LANG_UNIVERSAL, TEXT_RANGE_NORMAL, 0, TEAM_OTHER, false, player); + break; + case 3: + sCreatureTextMgr->SendChat(caster, SAY_PLAYER_TEXT_3, nullptr, CHAT_MSG_SAY, LANG_UNIVERSAL, TEXT_RANGE_NORMAL, 0, TEAM_OTHER, false, player); + Remove(); + break; } } @@ -774,14 +784,16 @@ class spell_summoning_rhyme_aura : public SpellScriptLoader // 46878 - Summon Ice Spear Delayer class spell_summon_ice_spear_delayer : public SpellScriptLoader { -public: - spell_summon_ice_spear_delayer() : SpellScriptLoader("spell_summon_ice_spear_delayer") { } + public: + spell_summon_ice_spear_delayer() : SpellScriptLoader("spell_summon_ice_spear_delayer") + { + } class spell_summon_ice_spear_delayer_AuraScript : public AuraScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo({ SPELL_SUMMON_ICE_SPEAR_GO, SPELL_ICE_SPEAR_KNOCKBACK }); + return ValidateSpellInfo({SPELL_SUMMON_ICE_SPEAR_GO, SPELL_ICE_SPEAR_KNOCKBACK}); } void PeriodicTick(AuraEffect const* aurEff) @@ -790,21 +802,21 @@ class spell_summon_ice_spear_delayer : public SpellScriptLoader if (Creature* caster = tmpCaster->ToCreature()) switch (aurEff->GetTickNumber()) { - case 1: - caster->CastSpell(caster, SPELL_SUMMON_ICE_SPEAR_GO); - break; - case 3: - if (GameObject* spike = caster->FindNearestGameObject(GO_ICE_SPEAR, 3.0f)) - spike->UseDoorOrButton(); - caster->AI()->DoCastAOE(SPELL_ICE_SPEAR_KNOCKBACK, true); - break; - case 5: - if (GameObject* spike = caster->FindNearestGameObject(GO_ICE_SPEAR, 3.0f)) - spike->Delete(); - caster->DespawnOrUnsummon(); - break; - default: - break; + case 1: + caster->CastSpell(caster, SPELL_SUMMON_ICE_SPEAR_GO); + break; + case 3: + if (GameObject* spike = caster->FindNearestGameObject(GO_ICE_SPEAR, 3.0f)) + spike->UseDoorOrButton(); + caster->AI()->DoCastAOE(SPELL_ICE_SPEAR_KNOCKBACK, true); + break; + case 5: + if (GameObject* spike = caster->FindNearestGameObject(GO_ICE_SPEAR, 3.0f)) + spike->Delete(); + caster->DespawnOrUnsummon(); + break; + default: + break; } } @@ -823,14 +835,16 @@ class spell_summon_ice_spear_delayer : public SpellScriptLoader // 46371 - Ice Spear Control Aura class spell_ice_spear_control_aura : public SpellScriptLoader { -public: - spell_ice_spear_control_aura() : SpellScriptLoader("spell_ice_spear_control_aura") { } + public: + spell_ice_spear_control_aura() : SpellScriptLoader("spell_ice_spear_control_aura") + { + } class spell_ice_spear_control_aura_AuraScript : public AuraScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo({ SPELL_ICE_SPEAR_TARGET_PICKER }); + return ValidateSpellInfo({SPELL_ICE_SPEAR_TARGET_PICKER}); } void PeriodicTick(AuraEffect const* /*aurEff*/) @@ -854,14 +868,16 @@ class spell_ice_spear_control_aura : public SpellScriptLoader // 46372 - Ice Spear Target Picker class spell_ice_spear_target_picker : public SpellScriptLoader { -public: - spell_ice_spear_target_picker() : SpellScriptLoader("spell_ice_spear_target_picker") { } + public: + spell_ice_spear_target_picker() : SpellScriptLoader("spell_ice_spear_target_picker") + { + } class spell_ice_spear_target_picker_SpellScript : public SpellScript { - bool Validate(SpellInfo const* /*spellInfo*/) override + bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo({ SPELL_SUMMON_ICE_SPEAR_BUNNY }); + return ValidateSpellInfo({SPELL_SUMMON_ICE_SPEAR_BUNNY}); } void FilterTargets(std::list& targets) @@ -895,14 +911,16 @@ class spell_ice_spear_target_picker : public SpellScriptLoader // 46320 - Spell Slippery Floor Periodic class spell_slippery_floor_periodic : public SpellScriptLoader { -public: - spell_slippery_floor_periodic() : SpellScriptLoader("spell_slippery_floor_periodic") { } + public: + spell_slippery_floor_periodic() : SpellScriptLoader("spell_slippery_floor_periodic") + { + } class spell_slippery_floor_periodic_SpellScript : public SpellScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo({ SPELL_SLIPPERY_FLOOR_SLIP }); + return ValidateSpellInfo({SPELL_SLIPPERY_FLOOR_SLIP}); } void HandleScriptEffect(SpellEffIndex /*effIndex*/) @@ -930,14 +948,16 @@ class spell_slippery_floor_periodic : public SpellScriptLoader // 46146 - Ahune Spanky Hands class spell_ahune_spanky_hands : public SpellScriptLoader { -public: - spell_ahune_spanky_hands() : SpellScriptLoader("spell_ahune_spanky_hands") { } + public: + spell_ahune_spanky_hands() : SpellScriptLoader("spell_ahune_spanky_hands") + { + } class spell_ahune_spanky_hands_AuraScript : public AuraScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo({ SPELL_COLD_SLAP }); + return ValidateSpellInfo({SPELL_COLD_SLAP}); } void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo) @@ -960,8 +980,10 @@ class spell_ahune_spanky_hands : public SpellScriptLoader class spell_ahune_minion_despawner : public SpellScriptLoader { -public: - spell_ahune_minion_despawner() : SpellScriptLoader("spell_ahune_minion_despawner") { } + public: + spell_ahune_minion_despawner() : SpellScriptLoader("spell_ahune_minion_despawner") + { + } class spell_ahune_minion_despawner_SpellScript : public SpellScript { @@ -986,19 +1008,21 @@ class spell_ahune_minion_despawner : public SpellScriptLoader // 46398 - Spell Ice Bombardment Dest Picker class spell_ice_bombardment_dest_picker : public SpellScriptLoader { -public: - spell_ice_bombardment_dest_picker() : SpellScriptLoader("spell_ice_bombardment_dest_picker") { } + public: + spell_ice_bombardment_dest_picker() : SpellScriptLoader("spell_ice_bombardment_dest_picker") + { + } class spell_ice_bombardment_dest_picker_SpellScript : public SpellScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo({ SPELL_ICE_BOMBARDMENT }); + return ValidateSpellInfo({SPELL_ICE_BOMBARDMENT}); } void HandleScriptEffect(SpellEffIndex /*effIndex*/) { - GetCaster()->CastSpell({ GetHitDest()->GetPositionX(), GetHitDest()->GetPositionY(), GetHitDest()->GetPositionZ() }, SPELL_ICE_BOMBARDMENT, true); + GetCaster()->CastSpell({GetHitDest()->GetPositionX(), GetHitDest()->GetPositionY(), GetHitDest()->GetPositionZ()}, SPELL_ICE_BOMBARDMENT, true); } void Register() override diff --git a/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/shattered_halls.cpp b/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/shattered_halls.cpp index b8345ac4..0f0f8626 100644 --- a/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/shattered_halls.cpp +++ b/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/shattered_halls.cpp @@ -15,47 +15,47 @@ * with this program. If not, see . */ -#include "ScriptMgr.h" +#include "shattered_halls.h" #include "InstanceScript.h" #include "Map.h" #include "ObjectAccessor.h" #include "Player.h" +#include "ScriptMgr.h" #include "ScriptedCreature.h" -#include "shattered_halls.h" #include "SpellScript.h" #include "TemporarySummon.h" class at_nethekurse_exit : public AreaTriggerScript { - public: - at_nethekurse_exit() : AreaTriggerScript("at_nethekurse_exit") { }; + public: + at_nethekurse_exit() : AreaTriggerScript("at_nethekurse_exit"){}; - bool OnTrigger(Player* player, AreaTriggerEntry const*) override + bool OnTrigger(Player* player, AreaTriggerEntry const*) override + { + if (InstanceScript* is = player->GetInstanceScript()) { - if (InstanceScript* is = player->GetInstanceScript()) + if (is->instance->IsHeroic()) { - if (is->instance->IsHeroic()) - { - Creature* executioner = nullptr; + Creature* executioner = nullptr; - is->instance->LoadGrid(Executioner.GetPositionX(), Executioner.GetPositionY()); - if (Creature* kargath = ObjectAccessor::GetCreature(*player, is->GetGuidData(NPC_KARGATH_BLADEFIST))) + is->instance->LoadGrid(Executioner.GetPositionX(), Executioner.GetPositionY()); + if (Creature* kargath = ObjectAccessor::GetCreature(*player, is->GetGuidData(NPC_KARGATH_BLADEFIST))) + { + if (is->GetGuidData(NPC_SHATTERED_EXECUTIONER).IsEmpty()) { - if (is->GetGuidData(NPC_SHATTERED_EXECUTIONER).IsEmpty()) - { - executioner = kargath->SummonCreature(NPC_SHATTERED_EXECUTIONER, Executioner); - kargath->AI()->DoAction(ACTION_EXECUTIONER_TAUNT); - } + executioner = kargath->SummonCreature(NPC_SHATTERED_EXECUTIONER, Executioner); + kargath->AI()->DoAction(ACTION_EXECUTIONER_TAUNT); } - - if (executioner) - for (uint8 i = 0; i < VictimCount; ++i) - executioner->SummonCreature(executionerVictims[i](is->GetData(DATA_TEAM_IN_INSTANCE)), executionerVictims[i].GetPos()); } - } - return false; + if (executioner) + for (uint8 i = 0; i < VictimCount; ++i) + executioner->SummonCreature(executionerVictims[i](is->GetData(DATA_TEAM_IN_INSTANCE)), executionerVictims[i].GetPos()); + } } + + return false; + } }; enum Spells @@ -65,185 +65,194 @@ enum Spells class boss_shattered_executioner : public CreatureScript { - public: - boss_shattered_executioner() : CreatureScript("boss_shattered_executioner") { } - - struct boss_shattered_executionerAI : public BossAI + public: + boss_shattered_executioner() : CreatureScript("boss_shattered_executioner") + { + } + + struct boss_shattered_executionerAI : public BossAI + { + boss_shattered_executionerAI(Creature* creature) : BossAI(creature, DATA_SHATTERED_EXECUTIONER) { - boss_shattered_executionerAI(Creature* creature) : BossAI(creature, DATA_SHATTERED_EXECUTIONER) - { - Initialize(); - }; + Initialize(); + }; - void Initialize() - { - cleaveTimer = 500; - } + void Initialize() + { + cleaveTimer = 500; + } - void Reset() override - { - _Reset(); - - // _Reset() resets the loot mode, so we add them again, if any - uint32 prisonersExecuted = instance->GetData(DATA_PRISONERS_EXECUTED); - if (prisonersExecuted == 0) - me->AddLootMode(LOOT_MODE_HARD_MODE_3); - if (prisonersExecuted <= 1) - me->AddLootMode(LOOT_MODE_HARD_MODE_2); - if (prisonersExecuted <= 2) - me->AddLootMode(LOOT_MODE_HARD_MODE_1); - - if (instance->GetBossState(DATA_KARGATH) == DONE) - me->SetImmuneToPC(false); - else - me->SetImmuneToPC(true); - - Initialize(); - } + void Reset() override + { + _Reset(); + + // _Reset() resets the loot mode, so we add them again, if any + uint32 prisonersExecuted = instance->GetData(DATA_PRISONERS_EXECUTED); + if (prisonersExecuted == 0) + me->AddLootMode(LOOT_MODE_HARD_MODE_3); + if (prisonersExecuted <= 1) + me->AddLootMode(LOOT_MODE_HARD_MODE_2); + if (prisonersExecuted <= 2) + me->AddLootMode(LOOT_MODE_HARD_MODE_1); + + if (instance->GetBossState(DATA_KARGATH) == DONE) + me->SetImmuneToPC(false); + else + me->SetImmuneToPC(true); + + Initialize(); + } - void JustSummoned(Creature*) override { } // avoid despawn of prisoners on death/reset + void JustSummoned(Creature*) override + { + } // avoid despawn of prisoners on death/reset - void JustDied(Unit* /*killer*/) override - { - _JustDied(); + void JustDied(Unit* /*killer*/) override + { + _JustDied(); - if (instance->GetData(DATA_PRISONERS_EXECUTED) > 0) - return; + if (instance->GetData(DATA_PRISONERS_EXECUTED) > 0) + return; - Map::PlayerList const& players = instance->instance->GetPlayers(); - for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr) - { - Player* pl = itr->GetSource(); - uint32 qId = pl->GetTeam() == ALLIANCE ? QUEST_IMPRISONED_A : QUEST_IMPRISONED_H; - if (pl->GetQuestStatus(qId) == QUEST_STATUS_INCOMPLETE) - pl->CompleteQuest(qId); - } + Map::PlayerList const& players = instance->instance->GetPlayers(); + for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr) + { + Player* pl = itr->GetSource(); + uint32 qId = pl->GetTeam() == ALLIANCE ? QUEST_IMPRISONED_A : QUEST_IMPRISONED_H; + if (pl->GetQuestStatus(qId) == QUEST_STATUS_INCOMPLETE) + pl->CompleteQuest(qId); } + } - void SetData(uint32 type, uint32 data) override + void SetData(uint32 type, uint32 data) override + { + if (type == DATA_PRISONERS_EXECUTED && data <= 3) { - if (type == DATA_PRISONERS_EXECUTED && data <= 3) - { - if (Creature* victim = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_FIRST_PRISONER + data - 1))) - me->Kill(victim); + if (Creature* victim = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_FIRST_PRISONER + data - 1))) + Unit::Kill(me, victim); - if (data == 1) - { - Map::PlayerList const& players = instance->instance->GetPlayers(); - for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr) - { - Player* pl = itr->GetSource(); - uint32 qId = pl->GetTeam() == ALLIANCE ? QUEST_IMPRISONED_A : QUEST_IMPRISONED_H; - if (pl->GetQuestStatus(qId) == QUEST_STATUS_INCOMPLETE) - pl->FailQuest(qId); - } - } - - switch (data) + if (data == 1) + { + Map::PlayerList const& players = instance->instance->GetPlayers(); + for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr) { - case 3: - me->RemoveLootMode(LOOT_MODE_HARD_MODE_1); - [[fallthrough]]; - case 2: - me->RemoveLootMode(LOOT_MODE_HARD_MODE_2); - [[fallthrough]]; - case 1: - me->RemoveLootMode(LOOT_MODE_HARD_MODE_3); - break; - default: - break; + Player* pl = itr->GetSource(); + uint32 qId = pl->GetTeam() == ALLIANCE ? QUEST_IMPRISONED_A : QUEST_IMPRISONED_H; + if (pl->GetQuestStatus(qId) == QUEST_STATUS_INCOMPLETE) + pl->FailQuest(qId); } } - } - - void UpdateAI(uint32 diff) override - { - if (!UpdateVictim()) - return; - if (cleaveTimer <= diff) + switch (data) { - DoCast(SPELL_CLEAVE); - cleaveTimer = urand(5000, 7000); + case 3: + me->RemoveLootMode(LOOT_MODE_HARD_MODE_1); + [[fallthrough]]; + case 2: + me->RemoveLootMode(LOOT_MODE_HARD_MODE_2); + [[fallthrough]]; + case 1: + me->RemoveLootMode(LOOT_MODE_HARD_MODE_3); + break; + default: + break; } - else - cleaveTimer -= diff; - - DoMeleeAttackIfReady(); } - private: - uint32 cleaveTimer; - }; + } - CreatureAI* GetAI(Creature* creature) const override + void UpdateAI(uint32 diff) override { - return GetShatteredHallsAI(creature); + if (!UpdateVictim()) + return; + + if (cleaveTimer <= diff) + { + DoCast(SPELL_CLEAVE); + cleaveTimer = urand(5000, 7000); + } + else + cleaveTimer -= diff; + + DoMeleeAttackIfReady(); } + + private: + uint32 cleaveTimer; + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return GetShatteredHallsAI(creature); + } }; class spell_kargath_executioner : public SpellScriptLoader { - public: - spell_kargath_executioner() : SpellScriptLoader("spell_kargath_executioner") { } - - class spell_kargath_executioner_AuraScript : public AuraScript + public: + spell_kargath_executioner() : SpellScriptLoader("spell_kargath_executioner") + { + } + + class spell_kargath_executioner_AuraScript : public AuraScript + { + bool AreaCheck(Unit* target) { - bool AreaCheck(Unit* target) - { - if (target->GetMap()->GetId() != 540) - return false; - - return true; - } + if (target->GetMap()->GetId() != 540) + return false; - bool Load() override - { - return GetCaster()->GetTypeId() == TYPEID_PLAYER; - } + return true; + } - void Register() override - { - DoCheckAreaTarget.Register(&spell_kargath_executioner_AuraScript::AreaCheck); - } - }; + bool Load() override + { + return GetCaster()->GetTypeId() == TYPEID_PLAYER; + } - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_kargath_executioner_AuraScript(); + DoCheckAreaTarget.Register(&spell_kargath_executioner_AuraScript::AreaCheck); } + }; + + AuraScript* GetAuraScript() const override + { + return new spell_kargath_executioner_AuraScript(); + } }; class spell_remove_kargath_executioner : public SpellScriptLoader { - public: - spell_remove_kargath_executioner() : SpellScriptLoader("spell_remove_kargath_executioner") { } - - class spell_remove_kargath_executioner_SpellScript : public SpellScript + public: + spell_remove_kargath_executioner() : SpellScriptLoader("spell_remove_kargath_executioner") + { + } + + class spell_remove_kargath_executioner_SpellScript : public SpellScript + { + void HandleScript(SpellEffIndex /*effIndex*/) { - void HandleScript(SpellEffIndex /*effIndex*/) - { - Unit* target = GetCaster(); - - target->RemoveAurasDueToSpell(SPELL_KARGATH_EXECUTIONER_1); - target->RemoveAurasDueToSpell(SPELL_KARGATH_EXECUTIONER_2); - target->RemoveAurasDueToSpell(SPELL_KARGATH_EXECUTIONER_3); - } + Unit* target = GetCaster(); - bool Load() override - { - return GetCaster()->GetTypeId() == TYPEID_PLAYER; - } + target->RemoveAurasDueToSpell(SPELL_KARGATH_EXECUTIONER_1); + target->RemoveAurasDueToSpell(SPELL_KARGATH_EXECUTIONER_2); + target->RemoveAurasDueToSpell(SPELL_KARGATH_EXECUTIONER_3); + } - void Register() override - { - OnEffectHitTarget.Register(&spell_remove_kargath_executioner_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - } - }; + bool Load() override + { + return GetCaster()->GetTypeId() == TYPEID_PLAYER; + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_remove_kargath_executioner_SpellScript(); + OnEffectHitTarget.Register(&spell_remove_kargath_executioner_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_remove_kargath_executioner_SpellScript(); + } }; void AddSC_shattered_halls() diff --git a/src/server/scripts/Outland/TempestKeep/Eye/boss_alar.cpp b/src/server/scripts/Outland/TempestKeep/Eye/boss_alar.cpp index ddc81b6e..bfd15a42 100644 --- a/src/server/scripts/Outland/TempestKeep/Eye/boss_alar.cpp +++ b/src/server/scripts/Outland/TempestKeep/Eye/boss_alar.cpp @@ -22,10 +22,10 @@ SD%Complete: 95 SDCategory: Tempest Keep, The Eye EndScriptData */ -#include "ScriptMgr.h" #include "InstanceScript.h" -#include "ObjectAccessor.h" #include "MotionMaster.h" +#include "ObjectAccessor.h" +#include "ScriptMgr.h" #include "ScriptedCreature.h" #include "SpellInfo.h" #include "TemporarySummon.h" @@ -33,529 +33,539 @@ EndScriptData */ enum Spells { - SPELL_FLAME_BUFFET = 34121, // Flame Buffet - every 1, 5 secs in phase 1 if there is no victim in melee range and after Dive Bomb in phase 2 with same conditions - SPELL_FLAME_QUILLS = 34229, // Randomly after changing position in phase after watching tons of movies, set probability 20% - SPELL_REBIRTH = 34342, // Rebirth - beginning of second phase(after losing all health in phase 1) - SPELL_REBIRTH_2 = 35369, // Rebirth(another, without healing to full HP) - after Dive Bomb in phase 2 - SPELL_MELT_ARMOR = 35410, // Melt Armor - every 60 sec in phase 2 - SPELL_CHARGE = 35412, // Charge - 30 sec cooldown - SPELL_DIVE_BOMB_VISUAL = 35367, // Bosskillers says 30 sec cooldown, wowwiki says 30 sec colldown, DBM and BigWigs addons says ~47 sec - SPELL_DIVE_BOMB = 35181, // after watching tonns of movies, set cooldown to 40+rand()%5. - SPELL_BERSERK = 45078, // 10 minutes after phase 2 starts(id is wrong, but proper id is unknown) - - CREATURE_EMBER_OF_ALAR = 19551, // Al'ar summons one Ember of Al'ar every position change in phase 1 and two after Dive Bomb. Also in phase 2 when Ember of Al'ar dies, boss loses 3% health. - SPELL_EMBER_BLAST = 34133, // When Ember of Al'ar dies, it casts Ember Blast - - CREATURE_FLAME_PATCH_ALAR = 20602, // Flame Patch - every 30 sec in phase 2 - SPELL_FLAME_PATCH = 35380, // + SPELL_FLAME_BUFFET = 34121, // Flame Buffet - every 1, 5 secs in phase 1 if there is no victim in melee range and after Dive Bomb in phase 2 with same conditions + SPELL_FLAME_QUILLS = 34229, // Randomly after changing position in phase after watching tons of movies, set probability 20% + SPELL_REBIRTH = 34342, // Rebirth - beginning of second phase(after losing all health in phase 1) + SPELL_REBIRTH_2 = 35369, // Rebirth(another, without healing to full HP) - after Dive Bomb in phase 2 + SPELL_MELT_ARMOR = 35410, // Melt Armor - every 60 sec in phase 2 + SPELL_CHARGE = 35412, // Charge - 30 sec cooldown + SPELL_DIVE_BOMB_VISUAL = 35367, // Bosskillers says 30 sec cooldown, wowwiki says 30 sec colldown, DBM and BigWigs addons says ~47 sec + SPELL_DIVE_BOMB = 35181, // after watching tonns of movies, set cooldown to 40+rand()%5. + SPELL_BERSERK = 45078, // 10 minutes after phase 2 starts(id is wrong, but proper id is unknown) + + CREATURE_EMBER_OF_ALAR = 19551, // Al'ar summons one Ember of Al'ar every position change in phase 1 and two after Dive Bomb. Also in phase 2 when Ember of Al'ar dies, boss loses 3% health. + SPELL_EMBER_BLAST = 34133, // When Ember of Al'ar dies, it casts Ember Blast + + CREATURE_FLAME_PATCH_ALAR = 20602, // Flame Patch - every 30 sec in phase 2 + SPELL_FLAME_PATCH = 35380, // }; -static float waypoint[6][3] = -{ - {340.15f, 58.65f, 17.71f}, - {388.09f, 31.54f, 20.18f}, - {388.18f, -32.85f, 20.18f}, - {340.29f, -60.19f, 17.72f}, - {332.0f, 0.01f, 39.0f}, // better not use the same xy coord - {331.0f, 0.01f, -2.39f} -}; +static float waypoint[6][3] = {{340.15f, 58.65f, 17.71f}, {388.09f, 31.54f, 20.18f}, {388.18f, -32.85f, 20.18f}, {340.29f, -60.19f, 17.72f}, {332.0f, 0.01f, 39.0f}, // better not use the same xy coord + {331.0f, 0.01f, -2.39f}}; enum WaitEventType { - WE_NONE = 0, - WE_DUMMY = 1, + WE_NONE = 0, + WE_DUMMY = 1, WE_PLATFORM = 2, - WE_QUILL = 3, - WE_DIE = 4, - WE_REVIVE = 5, - WE_CHARGE = 6, - WE_METEOR = 7, - WE_DIVE = 8, - WE_LAND = 9, - WE_SUMMON = 10 + WE_QUILL = 3, + WE_DIE = 4, + WE_REVIVE = 5, + WE_CHARGE = 6, + WE_METEOR = 7, + WE_DIVE = 8, + WE_LAND = 9, + WE_SUMMON = 10 }; class boss_alar : public CreatureScript { - public: - boss_alar() : CreatureScript("boss_alar") { } - - struct boss_alarAI : public BossAI + public: + boss_alar() : CreatureScript("boss_alar") + { + } + + struct boss_alarAI : public BossAI + { + boss_alarAI(Creature* creature) : BossAI(creature, DATA_ALAR) { - boss_alarAI(Creature* creature) : BossAI(creature, DATA_ALAR) - { - Initialize(); - DefaultMoveSpeedRate = creature->GetSpeedRate(MOVE_RUN); - DiveBomb_Timer = 0; - MeltArmor_Timer = 0; - Charge_Timer = 0; - FlamePatch_Timer = 0; - } - - void Initialize() - { - Berserk_Timer = 1200000; - Platforms_Move_Timer = 0; + Initialize(); + DefaultMoveSpeedRate = creature->GetSpeedRate(MOVE_RUN); + DiveBomb_Timer = 0; + MeltArmor_Timer = 0; + Charge_Timer = 0; + FlamePatch_Timer = 0; + } - Phase1 = true; - WaitEvent = WE_NONE; - WaitTimer = 0; - AfterMoving = false; - ForceMove = false; - ForceTimer = 5000; + void Initialize() + { + Berserk_Timer = 1200000; + Platforms_Move_Timer = 0; - cur_wp = 4; - } + Phase1 = true; + WaitEvent = WE_NONE; + WaitTimer = 0; + AfterMoving = false; + ForceMove = false; + ForceTimer = 5000; - WaitEventType WaitEvent; - uint32 WaitTimer; + cur_wp = 4; + } - bool AfterMoving; + WaitEventType WaitEvent; + uint32 WaitTimer; - uint32 Platforms_Move_Timer; - uint32 DiveBomb_Timer; - uint32 MeltArmor_Timer; - uint32 Charge_Timer; - uint32 FlamePatch_Timer; - uint32 Berserk_Timer; + bool AfterMoving; - float DefaultMoveSpeedRate; + uint32 Platforms_Move_Timer; + uint32 DiveBomb_Timer; + uint32 MeltArmor_Timer; + uint32 Charge_Timer; + uint32 FlamePatch_Timer; + uint32 Berserk_Timer; - bool Phase1; - bool ForceMove; - uint32 ForceTimer; + float DefaultMoveSpeedRate; - int8 cur_wp; + bool Phase1; + bool ForceMove; + uint32 ForceTimer; - void Reset() override - { - Initialize(); - _Reset(); + int8 cur_wp; - me->SetDisplayId(me->GetNativeDisplayId()); - me->SetSpeedRate(MOVE_RUN, DefaultMoveSpeedRate); - //me->SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, 10); - //me->SetFloatValue(UNIT_FIELD_COMBATREACH, 10); - me->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FIRE, true); - me->SetDisableGravity(true); - me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - me->setActive(false); - } + void Reset() override + { + Initialize(); + _Reset(); + + me->SetDisplayId(me->GetNativeDisplayId()); + me->SetSpeedRate(MOVE_RUN, DefaultMoveSpeedRate); + // me->SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, 10); + // me->SetFloatValue(UNIT_FIELD_COMBATREACH, 10); + me->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FIRE, true); + me->SetDisableGravity(true); + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + me->setActive(false); + } - void JustEngagedWith(Unit* who) override - { - BossAI::JustEngagedWith(who); - me->SetDisableGravity(true); // after enterevademode will be set walk movement - me->setActive(true); - } + void JustEngagedWith(Unit* who) override + { + BossAI::JustEngagedWith(who); + me->SetDisableGravity(true); // after enterevademode will be set walk movement + me->setActive(true); + } - void JustSummoned(Creature* summon) override - { - if (summon->GetEntry() == CREATURE_EMBER_OF_ALAR) - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) - summon->AI()->AttackStart(target); - } + void JustSummoned(Creature* summon) override + { + if (summon->GetEntry() == CREATURE_EMBER_OF_ALAR) + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) + summon->AI()->AttackStart(target); + } - void MoveInLineOfSight(Unit* /*who*/) override { } + void MoveInLineOfSight(Unit* /*who*/) override + { + } - void AttackStart(Unit* who) override - { - if (Phase1) - AttackStartNoMove(who); - else - ScriptedAI::AttackStart(who); - } + void AttackStart(Unit* who) override + { + if (Phase1) + AttackStartNoMove(who); + else + ScriptedAI::AttackStart(who); + } - void DamageTaken(Unit* /*killer*/, uint32 &damage) override + void DamageTaken(Unit* /*killer*/, uint32& damage) override + { + if (damage >= me->GetHealth() && Phase1) { - if (damage >= me->GetHealth() && Phase1) + damage = 0; + if (!WaitEvent) { - damage = 0; - if (!WaitEvent) - { - WaitEvent = WE_DIE; - WaitTimer = 0; - me->SetHealth(0); - me->InterruptNonMeleeSpells(true); - me->RemoveAllAuras(); - me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - me->AttackStop(); - me->SetTarget(ObjectGuid::Empty); - me->SetSpeedRate(MOVE_RUN, 5.0f); - me->GetMotionMaster()->Clear(); - me->GetMotionMaster()->MovePoint(0, waypoint[5][0], waypoint[5][1], waypoint[5][2]); - } + WaitEvent = WE_DIE; + WaitTimer = 0; + me->SetHealth(0); + me->InterruptNonMeleeSpells(true); + me->RemoveAllAuras(); + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + me->AttackStop(); + me->SetTarget(ObjectGuid::Empty); + me->SetSpeedRate(MOVE_RUN, 5.0f); + me->GetMotionMaster()->Clear(); + me->GetMotionMaster()->MovePoint(0, waypoint[5][0], waypoint[5][1], waypoint[5][2]); } } + } - void SpellHit(Unit*, SpellInfo const* spell) override + void SpellHit(Unit*, SpellInfo const* spell) override + { + if (spell->Id == SPELL_DIVE_BOMB_VISUAL) { - if (spell->Id == SPELL_DIVE_BOMB_VISUAL) - { - me->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FIRE, true); - me->SetDisplayId(11686); - //me->SendUpdateObjectToAllExcept(nullptr); - } + me->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FIRE, true); + me->SetDisplayId(11686); + // me->SendUpdateObjectToAllExcept(nullptr); } + } - void MovementInform(uint32 type, uint32 /*id*/) override + void MovementInform(uint32 type, uint32 /*id*/) override + { + if (type == POINT_MOTION_TYPE) { - if (type == POINT_MOTION_TYPE) - { - WaitTimer = 1; - AfterMoving = true; - ForceMove = false; - } + WaitTimer = 1; + AfterMoving = true; + ForceMove = false; } + } + + void UpdateAI(uint32 diff) override + { + if (!me->IsEngaged()) + return; - void UpdateAI(uint32 diff) override + if (Berserk_Timer <= diff) { - if (!me->IsEngaged()) - return; + DoCast(me, SPELL_BERSERK, true); + Berserk_Timer = 60000; + } + else + Berserk_Timer -= diff; - if (Berserk_Timer <= diff) + if (ForceMove) + { + if (ForceTimer <= diff) { - DoCast(me, SPELL_BERSERK, true); - Berserk_Timer = 60000; + me->GetMotionMaster()->MovePoint(0, waypoint[cur_wp][0], waypoint[cur_wp][1], waypoint[cur_wp][2]); + ForceTimer = 5000; } else - Berserk_Timer -= diff; - - if (ForceMove) + ForceTimer -= diff; + } + if (WaitEvent) + { + if (WaitTimer) { - if (ForceTimer <= diff) + if (WaitTimer <= diff) { - me->GetMotionMaster()->MovePoint(0, waypoint[cur_wp][0], waypoint[cur_wp][1], waypoint[cur_wp][2]); - ForceTimer = 5000; - } - else - ForceTimer -= diff; + if (AfterMoving) + { + me->GetMotionMaster()->MoveIdle(); + AfterMoving = false; + } - } - if (WaitEvent) - { - if (WaitTimer) - { - if (WaitTimer <= diff) + switch (WaitEvent) { - if (AfterMoving) + case WE_PLATFORM: + Platforms_Move_Timer = 30000 + rand32() % 5000; + break; + case WE_QUILL: + DoCast(me, SPELL_FLAME_QUILLS, true); + Platforms_Move_Timer = 1; + WaitTimer = 10000; + WaitEvent = WE_DUMMY; + return; + case WE_DIE: + ForceMove = false; + me->SetStandState(UNIT_STAND_STATE_DEAD); + WaitTimer = 5000; + WaitEvent = WE_REVIVE; + return; + case WE_REVIVE: + me->SetStandState(UNIT_STAND_STATE_STAND); + me->SetFullHealth(); + me->SetSpeedRate(MOVE_RUN, DefaultMoveSpeedRate); + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + DoZoneInCombat(); + DoCast(me, SPELL_REBIRTH, true); + MeltArmor_Timer = 60000; + Charge_Timer = 7000; + DiveBomb_Timer = 40000 + rand32() % 5000; + FlamePatch_Timer = 30000; + Phase1 = false; + break; + case WE_METEOR: + me->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FIRE, false); + DoCast(me, SPELL_DIVE_BOMB_VISUAL, false); + WaitEvent = WE_DIVE; + WaitTimer = 4000; + return; + case WE_DIVE: + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) { - me->GetMotionMaster()->MoveIdle(); - AfterMoving = false; + me->RemoveAurasDueToSpell(SPELL_DIVE_BOMB_VISUAL); + DoCast(target, SPELL_DIVE_BOMB, true); + float dist = 3.0f; + if (me->IsWithinDist3d(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 5.0f)) + dist = 5.0f; + WaitTimer = 1000 + uint32(floor(dist / 80 * 1000.0f)); + me->SetPosition(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0.0f); + me->StopMoving(); + WaitEvent = WE_LAND; + return; } - - switch (WaitEvent) + else { - case WE_PLATFORM: - Platforms_Move_Timer = 30000 + rand32() % 5000; - break; - case WE_QUILL: - DoCast(me, SPELL_FLAME_QUILLS, true); - Platforms_Move_Timer = 1; - WaitTimer = 10000; - WaitEvent = WE_DUMMY; - return; - case WE_DIE: - ForceMove = false; - me->SetStandState(UNIT_STAND_STATE_DEAD); - WaitTimer = 5000; - WaitEvent = WE_REVIVE; + EnterEvadeMode(); return; - case WE_REVIVE: - me->SetStandState(UNIT_STAND_STATE_STAND); - me->SetFullHealth(); - me->SetSpeedRate(MOVE_RUN, DefaultMoveSpeedRate); - me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - DoZoneInCombat(); - DoCast(me, SPELL_REBIRTH, true); - MeltArmor_Timer = 60000; - Charge_Timer = 7000; - DiveBomb_Timer = 40000 + rand32() % 5000; - FlamePatch_Timer = 30000; - Phase1 = false; - break; - case WE_METEOR: - me->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FIRE, false); - DoCast(me, SPELL_DIVE_BOMB_VISUAL, false); - WaitEvent = WE_DIVE; - WaitTimer = 4000; - return; - case WE_DIVE: - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) - { - me->RemoveAurasDueToSpell(SPELL_DIVE_BOMB_VISUAL); - DoCast(target, SPELL_DIVE_BOMB, true); - float dist = 3.0f; - if (me->IsWithinDist3d(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 5.0f)) - dist = 5.0f; - WaitTimer = 1000 + uint32(floor(dist / 80 * 1000.0f)); - me->SetPosition(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0.0f); - me->StopMoving(); - WaitEvent = WE_LAND; - return; - } - else - { - EnterEvadeMode(); - return; - } - case WE_LAND: - WaitEvent = WE_SUMMON; - WaitTimer = 2000; - return; - case WE_SUMMON: - for (uint8 i = 0; i < 2; ++i) - DoSpawnCreature(CREATURE_EMBER_OF_ALAR, 0, 0, 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); - me->SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, 10); - me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - me->SetDisplayId(me->GetNativeDisplayId()); - DoCast(me, SPELL_REBIRTH_2, true); - break; - case WE_DUMMY: - default: - break; } - - WaitEvent = WE_NONE; - WaitTimer = 0; + case WE_LAND: + WaitEvent = WE_SUMMON; + WaitTimer = 2000; + return; + case WE_SUMMON: + for (uint8 i = 0; i < 2; ++i) + DoSpawnCreature(CREATURE_EMBER_OF_ALAR, 0, 0, 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); + me->SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, 10); + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + me->SetDisplayId(me->GetNativeDisplayId()); + DoCast(me, SPELL_REBIRTH_2, true); + break; + case WE_DUMMY: + default: + break; } - else - WaitTimer -= diff; + + WaitEvent = WE_NONE; + WaitTimer = 0; } + else + WaitTimer -= diff; + } + return; + } + + if (Phase1) + { + if (!me->IsThreatened()) + { + EnterEvadeMode(); return; } - if (Phase1) + if (Platforms_Move_Timer <= diff) { - if (!me->IsThreatened()) + if (cur_wp == 4) { - EnterEvadeMode(); - return; + cur_wp = 0; + WaitEvent = WE_PLATFORM; } - - if (Platforms_Move_Timer <= diff) + else { - if (cur_wp == 4) + if (urand(0, 4)) // next platform { - cur_wp = 0; + DoSpawnCreature(CREATURE_EMBER_OF_ALAR, 0, 0, 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); + if (cur_wp == 3) + cur_wp = 0; + else + ++cur_wp; WaitEvent = WE_PLATFORM; } - else + else // flame quill { - if (urand(0, 4)) // next platform - { - DoSpawnCreature(CREATURE_EMBER_OF_ALAR, 0, 0, 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); - if (cur_wp == 3) - cur_wp = 0; - else - ++cur_wp; - WaitEvent = WE_PLATFORM; - } - else // flame quill - { - cur_wp = 4; - WaitEvent = WE_QUILL; - } + cur_wp = 4; + WaitEvent = WE_QUILL; } - ForceMove = true; - ForceTimer = 5000; - me->GetMotionMaster()->MovePoint(0, waypoint[cur_wp][0], waypoint[cur_wp][1], waypoint[cur_wp][2]); - WaitTimer = 0; - return; } - else - Platforms_Move_Timer -= diff; + ForceMove = true; + ForceTimer = 5000; + me->GetMotionMaster()->MovePoint(0, waypoint[cur_wp][0], waypoint[cur_wp][1], waypoint[cur_wp][2]); + WaitTimer = 0; + return; } else + Platforms_Move_Timer -= diff; + } + else + { + if (Charge_Timer <= diff) { - if (Charge_Timer <= diff) - { - Unit* target= SelectTarget(SELECT_TARGET_RANDOM, 1, 100, true); - if (target) - DoCast(target, SPELL_CHARGE); - Charge_Timer = 30000; - } - else - Charge_Timer -= diff; + Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1, 100, true); + if (target) + DoCast(target, SPELL_CHARGE); + Charge_Timer = 30000; + } + else + Charge_Timer -= diff; - if (MeltArmor_Timer <= diff) - { - DoCastVictim(SPELL_MELT_ARMOR); - MeltArmor_Timer = 60000; - } - else - MeltArmor_Timer -= diff; + if (MeltArmor_Timer <= diff) + { + DoCastVictim(SPELL_MELT_ARMOR); + MeltArmor_Timer = 60000; + } + else + MeltArmor_Timer -= diff; - if (DiveBomb_Timer <= diff) - { - me->AttackStop(); - me->GetMotionMaster()->MovePoint(6, waypoint[4][0], waypoint[4][1], waypoint[4][2]); - me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - me->SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, 50); - WaitEvent = WE_METEOR; - WaitTimer = 0; - DiveBomb_Timer = 40000 + rand32() % 5000; - return; - } - else - DiveBomb_Timer -= diff; + if (DiveBomb_Timer <= diff) + { + me->AttackStop(); + me->GetMotionMaster()->MovePoint(6, waypoint[4][0], waypoint[4][1], waypoint[4][2]); + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + me->SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, 50); + WaitEvent = WE_METEOR; + WaitTimer = 0; + DiveBomb_Timer = 40000 + rand32() % 5000; + return; + } + else + DiveBomb_Timer -= diff; - if (FlamePatch_Timer <= diff) + if (FlamePatch_Timer <= diff) + { + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) { - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) + Creature* Summoned = me->SummonCreature(CREATURE_FLAME_PATCH_ALAR, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 120000); + if (Summoned) { - Creature* Summoned = me->SummonCreature(CREATURE_FLAME_PATCH_ALAR, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 120000); - if (Summoned) - { - Summoned->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - Summoned->SetObjectScale(Summoned->GetObjectScale() * 2.5f); - Summoned->SetDisplayId(11686); - Summoned->SetFaction(me->GetFaction()); - Summoned->SetLevel(me->getLevel()); - Summoned->CastSpell(Summoned, SPELL_FLAME_PATCH, false); - } + Summoned->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + Summoned->SetObjectScale(Summoned->GetObjectScale() * 2.5f); + Summoned->SetDisplayId(11686); + Summoned->SetFaction(me->GetFaction()); + Summoned->SetLevel(me->getLevel()); + Summoned->CastSpell(Summoned, SPELL_FLAME_PATCH, false); } - FlamePatch_Timer = 30000; } - else - FlamePatch_Timer -= diff; + FlamePatch_Timer = 30000; } - - DoMeleeAttackIfReady(); + else + FlamePatch_Timer -= diff; } - void DoMeleeAttackIfReady() + DoMeleeAttackIfReady(); + } + + void DoMeleeAttackIfReady() + { + if (me->isAttackReady() && !me->IsNonMeleeSpellCast(false)) { - if (me->isAttackReady() && !me->IsNonMeleeSpellCast(false)) + if (me->IsWithinMeleeRange(me->GetVictim())) { - if (me->IsWithinMeleeRange(me->GetVictim())) - { - me->AttackerStateUpdate(me->GetVictim()); - me->resetAttackTimer(); - } + me->AttackerStateUpdate(me->GetVictim()); + me->resetAttackTimer(); + } + else + { + if (Unit* target = me->SelectNearestTargetInAttackDistance(5)) + AttackStart(target); else { - if (Unit* target = me->SelectNearestTargetInAttackDistance(5)) - AttackStart(target); - else - { - DoCast(me, SPELL_FLAME_BUFFET, true); - me->setAttackTimer(BASE_ATTACK, 1500); - } + DoCast(me, SPELL_FLAME_BUFFET, true); + me->setAttackTimer(BASE_ATTACK, 1500); } } } - }; - - CreatureAI* GetAI(Creature* creature) const override - { - return GetTheEyeAI(creature); } + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return GetTheEyeAI(creature); + } }; class npc_ember_of_alar : public CreatureScript { - public: - npc_ember_of_alar() : CreatureScript("npc_ember_of_alar") { } - - struct npc_ember_of_alarAI : public ScriptedAI + public: + npc_ember_of_alar() : CreatureScript("npc_ember_of_alar") + { + } + + struct npc_ember_of_alarAI : public ScriptedAI + { + npc_ember_of_alarAI(Creature* creature) : ScriptedAI(creature) { - npc_ember_of_alarAI(Creature* creature) : ScriptedAI(creature) - { - Initialize(); - instance = creature->GetInstanceScript(); - creature->SetDisableGravity(true); - creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FIRE, true); - } + Initialize(); + instance = creature->GetInstanceScript(); + creature->SetDisableGravity(true); + creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FIRE, true); + } - void Initialize() - { - toDie = false; - } + void Initialize() + { + toDie = false; + } - InstanceScript* instance; - bool toDie; + InstanceScript* instance; + bool toDie; - void Reset() override - { - Initialize(); - } + void Reset() override + { + Initialize(); + } - void JustEngagedWith(Unit* /*who*/) override - { - DoZoneInCombat(); - } + void JustEngagedWith(Unit* /*who*/) override + { + DoZoneInCombat(); + } - void EnterEvadeMode(EvadeReason /*why*/) override - { - me->setDeathState(JUST_DIED); - } + void EnterEvadeMode(EvadeReason /*why*/) override + { + me->setDeathState(JUST_DIED); + } - void DamageTaken(Unit* killer, uint32& damage) override + void DamageTaken(Unit* killer, uint32& damage) override + { + if (damage >= me->GetHealth() && killer != me && !toDie) { - if (damage >= me->GetHealth() && killer != me && !toDie) + damage = 0; + DoCast(me, SPELL_EMBER_BLAST, true); + me->SetDisplayId(11686); + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + if (instance->GetBossState(DATA_ALAR) == IN_PROGRESS) { - damage = 0; - DoCast(me, SPELL_EMBER_BLAST, true); - me->SetDisplayId(11686); - me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - if (instance->GetBossState(DATA_ALAR) == IN_PROGRESS) + if (Unit* Alar = ObjectAccessor::GetUnit(*me, instance->GetGuidData(DATA_ALAR))) { - if (Unit* Alar = ObjectAccessor::GetUnit(*me, instance->GetGuidData(DATA_ALAR))) - { - int32 AlarHealth = int32(Alar->GetHealth()) - int32(Alar->CountPctFromMaxHealth(3)); - if (AlarHealth > 0) - Alar->SetHealth(AlarHealth); - else - Alar->SetHealth(1); - } + int32 AlarHealth = int32(Alar->GetHealth()) - int32(Alar->CountPctFromMaxHealth(3)); + if (AlarHealth > 0) + Alar->SetHealth(AlarHealth); + else + Alar->SetHealth(1); } - toDie = true; } + toDie = true; } + } - void UpdateAI(uint32 /*diff*/) override - { - if (!UpdateVictim()) - return; - - if (toDie) - { - me->DealDamage(me, me->GetHealth(), nullptr, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, nullptr, false); - //me->SetVisibility(VISIBILITY_OFF); - } + void UpdateAI(uint32 /*diff*/) override + { + if (!UpdateVictim()) + return; - DoMeleeAttackIfReady(); + if (toDie) + { + me->KillSelf(); } - }; - - CreatureAI* GetAI(Creature* creature) const override - { - return GetTheEyeAI(creature); + DoMeleeAttackIfReady(); } + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return GetTheEyeAI(creature); + } }; class npc_flame_patch_alar : public CreatureScript { - public: - npc_flame_patch_alar() : CreatureScript("npc_flame_patch_alar") { } - - struct npc_flame_patch_alarAI : public ScriptedAI + public: + npc_flame_patch_alar() : CreatureScript("npc_flame_patch_alar") + { + } + + struct npc_flame_patch_alarAI : public ScriptedAI + { + npc_flame_patch_alarAI(Creature* creature) : ScriptedAI(creature) { - npc_flame_patch_alarAI(Creature* creature) : ScriptedAI(creature) { } - void Reset() override { } - void JustEngagedWith(Unit* /*who*/) override { } - void AttackStart(Unit* /*who*/) override { } - void MoveInLineOfSight(Unit* /*who*/) override { } - - void UpdateAI(uint32 /*diff*/) override { } - }; + } + void Reset() override + { + } + void JustEngagedWith(Unit* /*who*/) override + { + } + void AttackStart(Unit* /*who*/) override + { + } + void MoveInLineOfSight(Unit* /*who*/) override + { + } - CreatureAI* GetAI(Creature* creature) const override + void UpdateAI(uint32 /*diff*/) override { - return GetTheEyeAI(creature); } + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return GetTheEyeAI(creature); + } }; void AddSC_boss_alar() diff --git a/src/server/scripts/Outland/TempestKeep/botanica/boss_warp_splinter.cpp b/src/server/scripts/Outland/TempestKeep/botanica/boss_warp_splinter.cpp index f590b136..6e45b997 100644 --- a/src/server/scripts/Outland/TempestKeep/botanica/boss_warp_splinter.cpp +++ b/src/server/scripts/Outland/TempestKeep/botanica/boss_warp_splinter.cpp @@ -22,112 +22,107 @@ SDComment: Includes Sapling (need some better control with these). SDCategory: Tempest Keep, The Botanica EndScriptData */ -#include "ScriptMgr.h" #include "MotionMaster.h" #include "ObjectAccessor.h" +#include "ScriptMgr.h" #include "ScriptedCreature.h" #include "TemporarySummon.h" #include "the_botanica.h" enum Says { - SAY_AGGRO = 0, - SAY_SLAY = 1, - SAY_SUMMON = 2, - SAY_DEATH = 3 + SAY_AGGRO = 0, + SAY_SLAY = 1, + SAY_SUMMON = 2, + SAY_DEATH = 3 }; enum Spells { - WAR_STOMP = 34716, - SUMMON_TREANTS = 34727, // DBC: 34727, 34731, 34733, 34734, 34736, 34739, 34741 (with Ancestral Life spell 34742) // won't work (guardian summon) - ARCANE_VOLLEY = 36705, - SPELL_HEAL_FATHER = 6262 + WAR_STOMP = 34716, + SUMMON_TREANTS = 34727, // DBC: 34727, 34731, 34733, 34734, 34736, 34739, 34741 (with Ancestral Life spell 34742) // won't work (guardian summon) + ARCANE_VOLLEY = 36705, + SPELL_HEAL_FATHER = 6262 }; enum Misc { - CREATURE_TREANT = 19949, - TREANT_SPAWN_DIST = 50 //50 yards from Warp Splinter's spawn point + CREATURE_TREANT = 19949, + TREANT_SPAWN_DIST = 50 // 50 yards from Warp Splinter's spawn point }; -float treant_pos[6][3] = -{ - {24.301233f, 427.221100f, -27.060635f}, - {16.795492f, 359.678802f, -27.355425f}, - {53.493484f, 345.381470f, -26.196192f}, - {61.867096f, 439.362732f, -25.921030f}, - {109.861877f, 423.201630f, -27.356019f}, - {106.780159f, 355.582581f, -27.593357f} -}; +float treant_pos[6][3] = {{24.301233f, 427.221100f, -27.060635f}, {16.795492f, 359.678802f, -27.355425f}, {53.493484f, 345.381470f, -26.196192f}, {61.867096f, 439.362732f, -25.921030f}, + {109.861877f, 423.201630f, -27.356019f}, {106.780159f, 355.582581f, -27.593357f}}; /*##### # npc_treant (Sapling) #####*/ class npc_warp_splinter_treant : public CreatureScript { - public: - - npc_warp_splinter_treant() - : CreatureScript("npc_warp_splinter_treant") + public: + npc_warp_splinter_treant() : CreatureScript("npc_warp_splinter_treant") + { + } + struct npc_warp_splinter_treantAI : public ScriptedAI + { + npc_warp_splinter_treantAI(Creature* creature) : ScriptedAI(creature) { + Initialize(); } - struct npc_warp_splinter_treantAI : public ScriptedAI - { - npc_warp_splinter_treantAI(Creature* creature) : ScriptedAI(creature) - { - Initialize(); - } - void Initialize() - { - check_Timer = 0; - } + void Initialize() + { + check_Timer = 0; + } - ObjectGuid WarpGuid; - uint32 check_Timer; + ObjectGuid WarpGuid; + uint32 check_Timer; - void Reset() override - { - Initialize(); - } + void Reset() override + { + Initialize(); + } - void JustEngagedWith(Unit* /*who*/) override { } + void JustEngagedWith(Unit* /*who*/) override + { + } - void MoveInLineOfSight(Unit* /*who*/) override { } + void MoveInLineOfSight(Unit* /*who*/) override + { + } - void UpdateAI(uint32 diff) override + void UpdateAI(uint32 diff) override + { + if (!UpdateVictim() || !me->GetVictim()) { - if (!UpdateVictim() || !me->GetVictim()) + if (WarpGuid && check_Timer <= diff) { - if (WarpGuid && check_Timer <= diff) + if (Unit* Warp = ObjectAccessor::GetUnit(*me, WarpGuid)) { - if (Unit* Warp = ObjectAccessor::GetUnit(*me, WarpGuid)) + if (me->IsWithinMeleeRange(Warp)) { - if (me->IsWithinMeleeRange(Warp)) - { - int32 CurrentHP_Treant = (int32)me->GetHealth(); - Warp->CastSpell(Warp, SPELL_HEAL_FATHER, CastSpellExtraArgs(me->GetGUID()).AddSpellBP0(CurrentHP_Treant)); - me->DealDamage(me, me->GetHealth(), nullptr, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, nullptr, false); - return; - } - me->GetMotionMaster()->MoveFollow(Warp, 0, 0); + int32 CurrentHP_Treant = (int32)me->GetHealth(); + Warp->CastSpell(Warp, SPELL_HEAL_FATHER, CastSpellExtraArgs(me->GetGUID()).AddSpellBP0(CurrentHP_Treant)); + me->KillSelf(); + return; } - check_Timer = 1000; + me->GetMotionMaster()->MoveFollow(Warp, 0, 0); } - else - check_Timer -= diff; - return; + check_Timer = 1000; } - - if (me->EnsureVictim()->GetGUID() != WarpGuid) - DoMeleeAttackIfReady(); + else + check_Timer -= diff; + return; } - }; - CreatureAI* GetAI(Creature* creature) const override - { - return GetBotanicaAI(creature); + + if (me->EnsureVictim()->GetGUID() != WarpGuid) + DoMeleeAttackIfReady(); } + }; + CreatureAI* GetAI(Creature* creature) const override + { + return GetBotanicaAI(creature); + } }; /*##### @@ -135,113 +130,111 @@ class npc_warp_splinter_treant : public CreatureScript #####*/ class boss_warp_splinter : public CreatureScript { - public: + public: + boss_warp_splinter() : CreatureScript("boss_warp_splinter") + { + } + struct boss_warp_splinterAI : public BossAI + { + boss_warp_splinterAI(Creature* creature) : BossAI(creature, DATA_WARP_SPLINTER) + { + Initialize(); + Treant_Spawn_Pos_X = creature->GetPositionX(); + Treant_Spawn_Pos_Y = creature->GetPositionY(); + } - boss_warp_splinter() - : CreatureScript("boss_warp_splinter") + void Initialize() { + War_Stomp_Timer = urand(25000, 40000); + Summon_Treants_Timer = 45000; + Arcane_Volley_Timer = urand(8000, 20000); } - struct boss_warp_splinterAI : public BossAI + + uint32 War_Stomp_Timer; + uint32 Summon_Treants_Timer; + uint32 Arcane_Volley_Timer; + + float Treant_Spawn_Pos_X; + float Treant_Spawn_Pos_Y; + + void Reset() override { - boss_warp_splinterAI(Creature* creature) : BossAI(creature, DATA_WARP_SPLINTER) - { - Initialize(); - Treant_Spawn_Pos_X = creature->GetPositionX(); - Treant_Spawn_Pos_Y = creature->GetPositionY(); - } + Initialize(); - void Initialize() - { - War_Stomp_Timer = urand(25000, 40000); - Summon_Treants_Timer = 45000; - Arcane_Volley_Timer = urand(8000, 20000); - } + me->SetSpeedRate(MOVE_RUN, 0.7f); + } - uint32 War_Stomp_Timer; - uint32 Summon_Treants_Timer; - uint32 Arcane_Volley_Timer; + void JustEngagedWith(Unit* /*who*/) override + { + Talk(SAY_AGGRO); + } + + void KilledUnit(Unit* /*victim*/) override + { + Talk(SAY_SLAY); + } - float Treant_Spawn_Pos_X; - float Treant_Spawn_Pos_Y; + void JustDied(Unit* /*killer*/) override + { + Talk(SAY_DEATH); + } - void Reset() override + void SummonTreants() + { + for (uint8 i = 0; i < 6; ++i) { - Initialize(); + float angle = (float(M_PI) / 3) * i; - me->SetSpeedRate(MOVE_RUN, 0.7f); - } + float X = Treant_Spawn_Pos_X + TREANT_SPAWN_DIST * std::cos(angle); + float Y = Treant_Spawn_Pos_Y + TREANT_SPAWN_DIST * std::sin(angle); + float O = -me->GetAngle(X, Y); - void JustEngagedWith(Unit* /*who*/) override - { - Talk(SAY_AGGRO); + if (Creature* pTreant = me->SummonCreature(CREATURE_TREANT, treant_pos[i][0], treant_pos[i][1], treant_pos[i][2], O, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 25000)) + ENSURE_AI(npc_warp_splinter_treant::npc_warp_splinter_treantAI, pTreant->AI())->WarpGuid = me->GetGUID(); } + Talk(SAY_SUMMON); + } - void KilledUnit(Unit* /*victim*/) override - { - Talk(SAY_SLAY); - } + void UpdateAI(uint32 diff) override + { + if (!UpdateVictim()) + return; - void JustDied(Unit* /*killer*/) override + // Check for War Stomp + if (War_Stomp_Timer <= diff) { - Talk(SAY_DEATH); + DoCastVictim(WAR_STOMP); + War_Stomp_Timer = urand(25000, 40000); } + else + War_Stomp_Timer -= diff; - void SummonTreants() + // Check for Arcane Volley + if (Arcane_Volley_Timer <= diff) { - for (uint8 i = 0; i < 6; ++i) - { - float angle = (float(M_PI) / 3) * i; - - float X = Treant_Spawn_Pos_X + TREANT_SPAWN_DIST * std::cos(angle); - float Y = Treant_Spawn_Pos_Y + TREANT_SPAWN_DIST * std::sin(angle); - float O = - me->GetAngle(X, Y); - - if (Creature* pTreant = me->SummonCreature(CREATURE_TREANT, treant_pos[i][0], treant_pos[i][1], treant_pos[i][2], O, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 25000)) - ENSURE_AI(npc_warp_splinter_treant::npc_warp_splinter_treantAI, pTreant->AI())->WarpGuid = me->GetGUID(); - } - Talk(SAY_SUMMON); + DoCastVictim(ARCANE_VOLLEY); + Arcane_Volley_Timer = urand(20000, 35000); } + else + Arcane_Volley_Timer -= diff; - void UpdateAI(uint32 diff) override + // Check for Summon Treants + if (Summon_Treants_Timer <= diff) { - if (!UpdateVictim()) - return; - - //Check for War Stomp - if (War_Stomp_Timer <= diff) - { - DoCastVictim(WAR_STOMP); - War_Stomp_Timer = urand(25000, 40000); - } - else - War_Stomp_Timer -= diff; - - //Check for Arcane Volley - if (Arcane_Volley_Timer <= diff) - { - DoCastVictim(ARCANE_VOLLEY); - Arcane_Volley_Timer = urand(20000, 35000); - } - else - Arcane_Volley_Timer -= diff; - - //Check for Summon Treants - if (Summon_Treants_Timer <= diff) - { - SummonTreants(); - Summon_Treants_Timer = 45000; - } - else - Summon_Treants_Timer -= diff; - - DoMeleeAttackIfReady(); + SummonTreants(); + Summon_Treants_Timer = 45000; } - }; + else + Summon_Treants_Timer -= diff; - CreatureAI* GetAI(Creature* creature) const override - { - return GetBotanicaAI(creature); + DoMeleeAttackIfReady(); } + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return GetBotanicaAI(creature); + } }; void AddSC_boss_warp_splinter() diff --git a/src/server/scripts/Outland/zone_shadowmoon_valley.cpp b/src/server/scripts/Outland/zone_shadowmoon_valley.cpp index e121f4bf..c9b3847e 100644 --- a/src/server/scripts/Outland/zone_shadowmoon_valley.cpp +++ b/src/server/scripts/Outland/zone_shadowmoon_valley.cpp @@ -35,7 +35,6 @@ go_crystal_prison npc_enraged_spirit EndContentData */ -#include "ScriptMgr.h" #include "GameObject.h" #include "GameObjectAI.h" #include "Group.h" @@ -43,6 +42,7 @@ EndContentData */ #include "MotionMaster.h" #include "ObjectAccessor.h" #include "Player.h" +#include "ScriptMgr.h" #include "ScriptedEscortAI.h" #include "ScriptedGossip.h" #include "SpellInfo.h" @@ -56,18 +56,20 @@ EndContentData */ enum InvisInfernalCaster { EVENT_CAST_SUMMON_INFERNAL = 1, - NPC_INFERNAL_ATTACKER = 21419, - MODEL_INVISIBLE = 20577, - MODEL_INFERNAL = 17312, - SPELL_SUMMON_INFERNAL = 37277, - TYPE_INFERNAL = 1, - DATA_DIED = 1 + NPC_INFERNAL_ATTACKER = 21419, + MODEL_INVISIBLE = 20577, + MODEL_INFERNAL = 17312, + SPELL_SUMMON_INFERNAL = 37277, + TYPE_INFERNAL = 1, + DATA_DIED = 1 }; class npc_invis_infernal_caster : public CreatureScript { -public: - npc_invis_infernal_caster() : CreatureScript("npc_invis_infernal_caster") { } + public: + npc_invis_infernal_caster() : CreatureScript("npc_invis_infernal_caster") + { + } struct npc_invis_infernal_casterAI : public ScriptedAI { @@ -119,7 +121,7 @@ class npc_invis_infernal_caster : public CreatureScript } } - private: + private: EventMap events; ObjectGuid infernalGUID; float ground; @@ -137,12 +139,16 @@ class npc_invis_infernal_caster : public CreatureScript class npc_infernal_attacker : public CreatureScript { -public: - npc_infernal_attacker() : CreatureScript("npc_infernal_attacker") { } + public: + npc_infernal_attacker() : CreatureScript("npc_infernal_attacker") + { + } struct npc_infernal_attackerAI : public ScriptedAI { - npc_infernal_attackerAI(Creature* creature) : ScriptedAI(creature) { } + npc_infernal_attackerAI(Creature* creature) : ScriptedAI(creature) + { + } void Reset() override { @@ -153,7 +159,8 @@ class npc_infernal_attacker : public CreatureScript void IsSummonedBy(Unit* summoner) override { if (summoner->ToCreature()) - casterGUID = summoner->ToCreature()->GetGUID();; + casterGUID = summoner->ToCreature()->GetGUID(); + ; } void JustDied(Unit* /*killer*/) override @@ -180,7 +187,7 @@ class npc_infernal_attacker : public CreatureScript DoMeleeAttackIfReady(); } - private: + private: ObjectGuid casterGUID; }; @@ -196,23 +203,25 @@ class npc_infernal_attacker : public CreatureScript enum MatureNetherwing { - SAY_JUST_EATEN = 0, + SAY_JUST_EATEN = 0, - SPELL_PLACE_CARCASS = 38439, - SPELL_JUST_EATEN = 38502, - SPELL_NETHER_BREATH = 38467, - POINT_ID = 1, + SPELL_PLACE_CARCASS = 38439, + SPELL_JUST_EATEN = 38502, + SPELL_NETHER_BREATH = 38467, + POINT_ID = 1, - GO_CARCASS = 185155, + GO_CARCASS = 185155, - QUEST_KINDNESS = 10804, - NPC_EVENT_PINGER = 22131 + QUEST_KINDNESS = 10804, + NPC_EVENT_PINGER = 22131 }; class npc_mature_netherwing_drake : public CreatureScript { -public: - npc_mature_netherwing_drake() : CreatureScript("npc_mature_netherwing_drake") { } + public: + npc_mature_netherwing_drake() : CreatureScript("npc_mature_netherwing_drake") + { + } CreatureAI* GetAI(Creature* creature) const override { @@ -318,7 +327,7 @@ class npc_mature_netherwing_drake : public CreatureScript else EatTimer -= diff; - return; + return; } if (!UpdateVictim()) @@ -328,7 +337,9 @@ class npc_mature_netherwing_drake : public CreatureScript { DoCastVictim(SPELL_NETHER_BREATH); CastTimer = 5000; - } else CastTimer -= diff; + } + else + CastTimer -= diff; DoMeleeAttackIfReady(); } @@ -342,19 +353,20 @@ class npc_mature_netherwing_drake : public CreatureScript enum EnshlavedNetherwingDrake { // Spells - SPELL_HIT_FORCE_OF_NELTHARAKU = 38762, - SPELL_FORCE_OF_NELTHARAKU = 38775, + SPELL_HIT_FORCE_OF_NELTHARAKU = 38762, + SPELL_FORCE_OF_NELTHARAKU = 38775, // Creatures - NPC_DRAGONMAW_SUBJUGATOR = 21718, - NPC_ESCAPE_DUMMY = 22317 - + NPC_DRAGONMAW_SUBJUGATOR = 21718, + NPC_ESCAPE_DUMMY = 22317 }; class npc_enslaved_netherwing_drake : public CreatureScript { -public: - npc_enslaved_netherwing_drake() : CreatureScript("npc_enslaved_netherwing_drake") { } + public: + npc_enslaved_netherwing_drake() : CreatureScript("npc_enslaved_netherwing_drake") + { + } CreatureAI* GetAI(Creature* creature) const override { @@ -461,7 +473,9 @@ class npc_enslaved_netherwing_drake : public CreatureScript me->GetMotionMaster()->MovePoint(1, pos); } } - } else FlyTimer -= diff; + } + else + FlyTimer -= diff; } return; } @@ -477,8 +491,10 @@ class npc_enslaved_netherwing_drake : public CreatureScript class npc_dragonmaw_peon : public CreatureScript { -public: - npc_dragonmaw_peon() : CreatureScript("npc_dragonmaw_peon") { } + public: + npc_dragonmaw_peon() : CreatureScript("npc_dragonmaw_peon") + { + } CreatureAI* GetAI(Creature* creature) const override { @@ -551,8 +567,10 @@ class npc_dragonmaw_peon : public CreatureScript player->KilledMonsterCredit(23209); } PoisonTimer = 0; - me->DealDamage(me, me->GetHealth(), nullptr, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, nullptr, false); - } else PoisonTimer -= diff; + me->KillSelf(); + } + else + PoisonTimer -= diff; } if (!UpdateVictim()) return; @@ -568,27 +586,29 @@ class npc_dragonmaw_peon : public CreatureScript enum Earthmender { - SAY_WIL_START = 0, - SAY_WIL_AGGRO = 1, - SAY_WIL_PROGRESS1 = 2, - SAY_WIL_PROGRESS2 = 3, - SAY_WIL_FIND_EXIT = 4, - SAY_WIL_JUST_AHEAD = 5, - SAY_WIL_END = 6, - - SPELL_CHAIN_LIGHTNING = 16006, - SPELL_EARTHBING_TOTEM = 15786, - SPELL_FROST_SHOCK = 12548, - SPELL_HEALING_WAVE = 12491, - - QUEST_ESCAPE_COILSCAR = 10451, - NPC_COILSKAR_ASSASSIN = 21044 + SAY_WIL_START = 0, + SAY_WIL_AGGRO = 1, + SAY_WIL_PROGRESS1 = 2, + SAY_WIL_PROGRESS2 = 3, + SAY_WIL_FIND_EXIT = 4, + SAY_WIL_JUST_AHEAD = 5, + SAY_WIL_END = 6, + + SPELL_CHAIN_LIGHTNING = 16006, + SPELL_EARTHBING_TOTEM = 15786, + SPELL_FROST_SHOCK = 12548, + SPELL_HEALING_WAVE = 12491, + + QUEST_ESCAPE_COILSCAR = 10451, + NPC_COILSKAR_ASSASSIN = 21044 }; class npc_earthmender_wilda : public CreatureScript { -public: - npc_earthmender_wilda() : CreatureScript("npc_earthmender_wilda") { } + public: + npc_earthmender_wilda() : CreatureScript("npc_earthmender_wilda") + { + } CreatureAI* GetAI(Creature* creature) const override { @@ -632,53 +652,53 @@ class npc_earthmender_wilda : public CreatureScript switch (waypointId) { - case 13: - Talk(SAY_WIL_PROGRESS1, player); - DoSpawnAssassin(); - break; - case 14: - DoSpawnAssassin(); - break; - case 15: - Talk(SAY_WIL_FIND_EXIT, player); - break; - case 19: - DoRandomSay(); - break; - case 20: - DoSpawnAssassin(); - break; - case 26: - DoRandomSay(); - break; - case 27: - DoSpawnAssassin(); - break; - case 33: - DoRandomSay(); - break; - case 34: - DoSpawnAssassin(); - break; - case 37: - DoRandomSay(); - break; - case 38: - DoSpawnAssassin(); - break; - case 39: - Talk(SAY_WIL_JUST_AHEAD, player); - break; - case 43: - DoRandomSay(); - break; - case 44: - DoSpawnAssassin(); - break; - case 50: - Talk(SAY_WIL_END, player); - player->GroupEventHappens(QUEST_ESCAPE_COILSCAR, me); - break; + case 13: + Talk(SAY_WIL_PROGRESS1, player); + DoSpawnAssassin(); + break; + case 14: + DoSpawnAssassin(); + break; + case 15: + Talk(SAY_WIL_FIND_EXIT, player); + break; + case 19: + DoRandomSay(); + break; + case 20: + DoSpawnAssassin(); + break; + case 26: + DoRandomSay(); + break; + case 27: + DoSpawnAssassin(); + break; + case 33: + DoRandomSay(); + break; + case 34: + DoSpawnAssassin(); + break; + case 37: + DoRandomSay(); + break; + case 38: + DoSpawnAssassin(); + break; + case 39: + Talk(SAY_WIL_JUST_AHEAD, player); + break; + case 43: + DoRandomSay(); + break; + case 44: + DoSpawnAssassin(); + break; + case 50: + Talk(SAY_WIL_END, player); + player->GroupEventHappens(QUEST_ESCAPE_COILSCAR, me); + break; } } @@ -688,7 +708,7 @@ class npc_earthmender_wilda : public CreatureScript summoned->AI()->AttackStart(me); } - //this is very unclear, random say without no real relevance to script/event + // this is very unclear, random say without no real relevance to script/event void DoRandomSay() { Talk(SAY_WIL_PROGRESS2); @@ -696,20 +716,20 @@ class npc_earthmender_wilda : public CreatureScript void DoSpawnAssassin() { - //unknown where they actually appear + // unknown where they actually appear DoSummon(NPC_COILSKAR_ASSASSIN, me, 15.0f, 5000, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT); } void JustEngagedWith(Unit* who) override { - //don't always use + // don't always use if (rand32() % 5) return; - //only aggro text if not player + // only aggro text if not player if (who->GetTypeId() != TYPEID_PLAYER) { - //appears to be random + // appears to be random if (urand(0, 1)) Talk(SAY_WIL_AGGRO); } @@ -750,8 +770,8 @@ go_crystal_prison : GameObject that begins the event and hands out quest EndContentData */ #define QUEST_BATTLE_OF_THE_CRIMSON_WATCH 10781 -#define EVENT_AREA_RADIUS 65 //65yds -#define EVENT_COOLDOWN 30000 //in ms. appear after event completed or failed (should be = Adds despawn time) +#define EVENT_AREA_RADIUS 65 // 65yds +#define EVENT_COOLDOWN 30000 // in ms. appear after event completed or failed (should be = Adds despawn time) struct TorlothCinematic { @@ -759,37 +779,28 @@ struct TorlothCinematic }; // Creature 0 - Torloth, 1 - Illidan -static TorlothCinematic TorlothAnim[]= -{ - {0, 2000}, - {1, 7000}, - {0, 3000}, - {0, 2000}, // Torloth stand - {0, 1000}, - {0, 3000}, - {0, 0} -}; - -//Cordinates for Spawns -static Position SpawnLocation[]= -{ - //Cords used for: - {-4615.8556f, 1342.2532f, 139.9f, 1.612f}, //Illidari Soldier - {-4598.9365f, 1377.3182f, 139.9f, 3.917f}, //Illidari Soldier - {-4598.4697f, 1360.8999f, 139.9f, 2.427f}, //Illidari Soldier - {-4589.3599f, 1369.1061f, 139.9f, 3.165f}, //Illidari Soldier - {-4608.3477f, 1386.0076f, 139.9f, 4.108f}, //Illidari Soldier - {-4633.1889f, 1359.8033f, 139.9f, 0.949f}, //Illidari Soldier - {-4623.5791f, 1351.4574f, 139.9f, 0.971f}, //Illidari Soldier - {-4607.2988f, 1351.6099f, 139.9f, 2.416f}, //Illidari Soldier - {-4633.7764f, 1376.0417f, 139.9f, 5.608f}, //Illidari Soldier - {-4600.2461f, 1369.1240f, 139.9f, 3.056f}, //Illidari Mind Breaker - {-4631.7808f, 1367.9459f, 139.9f, 0.020f}, //Illidari Mind Breaker - {-4600.2461f, 1369.1240f, 139.9f, 3.056f}, //Illidari Highlord - {-4631.7808f, 1367.9459f, 139.9f, 0.020f}, //Illidari Highlord - {-4615.5586f, 1353.0031f, 139.9f, 1.540f}, //Illidari Highlord - {-4616.4736f, 1384.2170f, 139.9f, 4.971f}, //Illidari Highlord - {-4627.1240f, 1378.8752f, 139.9f, 2.544f} //Torloth The Magnificent +static TorlothCinematic TorlothAnim[] = {{0, 2000}, {1, 7000}, {0, 3000}, {0, 2000}, // Torloth stand + {0, 1000}, {0, 3000}, {0, 0}}; + +// Cordinates for Spawns +static Position SpawnLocation[] = { + // Cords used for: + {-4615.8556f, 1342.2532f, 139.9f, 1.612f}, // Illidari Soldier + {-4598.9365f, 1377.3182f, 139.9f, 3.917f}, // Illidari Soldier + {-4598.4697f, 1360.8999f, 139.9f, 2.427f}, // Illidari Soldier + {-4589.3599f, 1369.1061f, 139.9f, 3.165f}, // Illidari Soldier + {-4608.3477f, 1386.0076f, 139.9f, 4.108f}, // Illidari Soldier + {-4633.1889f, 1359.8033f, 139.9f, 0.949f}, // Illidari Soldier + {-4623.5791f, 1351.4574f, 139.9f, 0.971f}, // Illidari Soldier + {-4607.2988f, 1351.6099f, 139.9f, 2.416f}, // Illidari Soldier + {-4633.7764f, 1376.0417f, 139.9f, 5.608f}, // Illidari Soldier + {-4600.2461f, 1369.1240f, 139.9f, 3.056f}, // Illidari Mind Breaker + {-4631.7808f, 1367.9459f, 139.9f, 0.020f}, // Illidari Mind Breaker + {-4600.2461f, 1369.1240f, 139.9f, 3.056f}, // Illidari Highlord + {-4631.7808f, 1367.9459f, 139.9f, 0.020f}, // Illidari Highlord + {-4615.5586f, 1353.0031f, 139.9f, 1.540f}, // Illidari Highlord + {-4616.4736f, 1384.2170f, 139.9f, 4.971f}, // Illidari Highlord + {-4627.1240f, 1378.8752f, 139.9f, 2.544f} // Torloth The Magnificent }; struct WaveData @@ -798,30 +809,28 @@ struct WaveData uint32 CreatureId, SpawnTimer, YellTimer; }; -static WaveData WavesInfo[]= -{ - {9, 0, 22075, 10000, 7000}, //Illidari Soldier - {2, 9, 22074, 10000, 7000}, //Illidari Mind Breaker - {4, 11, 19797, 10000, 7000}, //Illidari Highlord - {1, 15, 22076, 10000, 7000} //Torloth The Magnificent +static WaveData WavesInfo[] = { + {9, 0, 22075, 10000, 7000}, // Illidari Soldier + {2, 9, 22074, 10000, 7000}, // Illidari Mind Breaker + {4, 11, 19797, 10000, 7000}, // Illidari Highlord + {1, 15, 22076, 10000, 7000} // Torloth The Magnificent }; struct SpawnSpells { - uint32 Timer1, Timer2, SpellId; + uint32 Timer1, Timer2, SpellId; }; -static SpawnSpells SpawnCast[]= -{ - {10000, 15000, 35871}, // Illidari Soldier Cast - Spellbreaker - {10000, 10000, 38985}, // Illidari Mind Breake Cast - Focused Bursts - {35000, 35000, 22884}, // Illidari Mind Breake Cast - Psychic Scream - {20000, 20000, 17194}, // Illidari Mind Breake Cast - Mind Blast - {8000, 15000, 38010}, // Illidari Highlord Cast - Curse of Flames - {12000, 20000, 16102}, // Illidari Highlord Cast - Flamestrike - {10000, 15000, 15284}, // Torloth the Magnificent Cast - Cleave - {18000, 20000, 39082}, // Torloth the Magnificent Cast - Shadowfury - {25000, 28000, 33961} // Torloth the Magnificent Cast - Spell Reflection +static SpawnSpells SpawnCast[] = { + {10000, 15000, 35871}, // Illidari Soldier Cast - Spellbreaker + {10000, 10000, 38985}, // Illidari Mind Breake Cast - Focused Bursts + {35000, 35000, 22884}, // Illidari Mind Breake Cast - Psychic Scream + {20000, 20000, 17194}, // Illidari Mind Breake Cast - Mind Blast + {8000, 15000, 38010}, // Illidari Highlord Cast - Curse of Flames + {12000, 20000, 16102}, // Illidari Highlord Cast - Flamestrike + {10000, 15000, 15284}, // Torloth the Magnificent Cast - Cleave + {18000, 20000, 39082}, // Torloth the Magnificent Cast - Shadowfury + {25000, 28000, 33961} // Torloth the Magnificent Cast - Spell Reflection }; /*###### @@ -830,8 +839,10 @@ static SpawnSpells SpawnCast[]= class npc_torloth_the_magnificent : public CreatureScript { -public: - npc_torloth_the_magnificent() : CreatureScript("npc_torloth_the_magnificent") { } + public: + npc_torloth_the_magnificent() : CreatureScript("npc_torloth_the_magnificent") + { + } CreatureAI* GetAI(Creature* c) const override { @@ -875,7 +886,9 @@ class npc_torloth_the_magnificent : public CreatureScript me->SetTarget(ObjectGuid::Empty); } - void JustEngagedWith(Unit* /*who*/) override { } + void JustEngagedWith(Unit* /*who*/) override + { + } void HandleAnimation() { @@ -929,13 +942,16 @@ class npc_torloth_the_magnificent : public CreatureScript if (AnimationTimer <= diff) { HandleAnimation(); - } else AnimationTimer -= diff; + } + else + AnimationTimer -= diff; } if (AnimationCount < 6) { me->CombatStop(); - } else if (!Timers) + } + else if (!Timers) { SpellTimer1 = SpawnCast[6].Timer1; SpellTimer2 = SpawnCast[7].Timer1; @@ -947,21 +963,27 @@ class npc_torloth_the_magnificent : public CreatureScript { if (SpellTimer1 <= diff) { - DoCastVictim(SpawnCast[6].SpellId);//Cleave + DoCastVictim(SpawnCast[6].SpellId); // Cleave SpellTimer1 = SpawnCast[6].Timer2 + (rand32() % 10 * 1000); - } else SpellTimer1 -= diff; + } + else + SpellTimer1 -= diff; if (SpellTimer2 <= diff) { - DoCastVictim(SpawnCast[7].SpellId);//Shadowfury + DoCastVictim(SpawnCast[7].SpellId); // Shadowfury SpellTimer2 = SpawnCast[7].Timer2 + (rand32() % 5 * 1000); - } else SpellTimer2 -= diff; + } + else + SpellTimer2 -= diff; if (SpellTimer3 <= diff) { DoCast(me, SpawnCast[8].SpellId); - SpellTimer3 = SpawnCast[8].Timer2 + (rand32() % 7 * 1000);//Spell Reflection - } else SpellTimer3 -= diff; + SpellTimer3 = SpawnCast[8].Timer2 + (rand32() % 7 * 1000); // Spell Reflection + } + else + SpellTimer3 -= diff; } DoMeleeAttackIfReady(); @@ -974,17 +996,17 @@ class npc_torloth_the_magnificent : public CreatureScript switch (killer->GetTypeId()) { - case TYPEID_UNIT: - if (Unit* owner = killer->GetOwner()) - if (Player* player = owner->ToPlayer()) - player->GroupEventHappens(QUEST_BATTLE_OF_THE_CRIMSON_WATCH, me); - break; - case TYPEID_PLAYER: - if (Player* player = killer->ToPlayer()) + case TYPEID_UNIT: + if (Unit* owner = killer->GetOwner()) + if (Player* player = owner->ToPlayer()) player->GroupEventHappens(QUEST_BATTLE_OF_THE_CRIMSON_WATCH, me); - break; - default: - break; + break; + case TYPEID_PLAYER: + if (Player* player = killer->ToPlayer()) + player->GroupEventHappens(QUEST_BATTLE_OF_THE_CRIMSON_WATCH, me); + break; + default: + break; } if (Creature* LordIllidan = (ObjectAccessor::GetCreature(*me, LordIllidanGUID))) @@ -999,8 +1021,10 @@ class npc_torloth_the_magnificent : public CreatureScript class npc_lord_illidan_stormrage : public CreatureScript { -public: - npc_lord_illidan_stormrage() : CreatureScript("npc_lord_illidan_stormrage") { } + public: + npc_lord_illidan_stormrage() : CreatureScript("npc_lord_illidan_stormrage") + { + } CreatureAI* GetAI(Creature* c) const override { @@ -1047,10 +1071,16 @@ class npc_lord_illidan_stormrage : public CreatureScript me->SetVisible(false); } - void JustEngagedWith(Unit* /*who*/) override { } - void MoveInLineOfSight(Unit* /*who*/) override { } + void JustEngagedWith(Unit* /*who*/) override + { + } + void MoveInLineOfSight(Unit* /*who*/) override + { + } - void AttackStart(Unit* /*who*/) override { } + void AttackStart(Unit* /*who*/) override + { + } void SummonNextWave(); @@ -1069,7 +1099,7 @@ class npc_lord_illidan_stormrage : public CreatureScript Group::MemberSlotList const& members = EventGroup->GetMemberSlots(); - for (Group::member_citerator itr = members.begin(); itr!= members.end(); ++itr) + for (Group::member_citerator itr = members.begin(); itr != members.end(); ++itr) { Player* GroupMember = ObjectAccessor::GetPlayer(*me, itr->guid); if (!GroupMember) @@ -1092,7 +1122,7 @@ class npc_lord_illidan_stormrage : public CreatureScript if (GroupMemberCount == DeadMemberCount) { - for (Group::member_citerator itr = members.begin(); itr!= members.end(); ++itr) + for (Group::member_citerator itr = members.begin(); itr != members.end(); ++itr) { if (Player* groupMember = ObjectAccessor::GetPlayer(*me, itr->guid)) if (groupMember->GetQuestStatus(QUEST_BATTLE_OF_THE_CRIMSON_WATCH) == QUEST_STATUS_INCOMPLETE) @@ -1100,7 +1130,8 @@ class npc_lord_illidan_stormrage : public CreatureScript } Failed = true; } - } else if (player->isDead() || !player->IsWithinDistInMap(me, EVENT_AREA_RADIUS)) + } + else if (player->isDead() || !player->IsWithinDistInMap(me, EVENT_AREA_RADIUS)) { player->FailQuest(QUEST_BATTLE_OF_THE_CRIMSON_WATCH); Failed = true; @@ -1149,8 +1180,10 @@ class npc_lord_illidan_stormrage : public CreatureScript class npc_illidari_spawn : public CreatureScript { -public: - npc_illidari_spawn() : CreatureScript("npc_illidari_spawn") { } + public: + npc_illidari_spawn() : CreatureScript("npc_illidari_spawn") + { + } CreatureAI* GetAI(Creature* c) const override { @@ -1182,7 +1215,9 @@ class npc_illidari_spawn : public CreatureScript Initialize(); } - void JustEngagedWith(Unit* /*who*/) override { } + void JustEngagedWith(Unit* /*who*/) override + { + } void JustDied(Unit* /*killer*/) override { @@ -1198,33 +1233,35 @@ class npc_illidari_spawn : public CreatureScript if (!Timers) { - if (me->GetEntry() == 22075)//Illidari Soldier + if (me->GetEntry() == 22075) // Illidari Soldier { SpellTimer1 = SpawnCast[0].Timer1 + (rand32() % 4 * 1000); } - if (me->GetEntry() == 22074)//Illidari Mind Breaker + if (me->GetEntry() == 22074) // Illidari Mind Breaker { SpellTimer1 = SpawnCast[1].Timer1 + (rand32() % 10 * 1000); SpellTimer2 = SpawnCast[2].Timer1 + (rand32() % 4 * 1000); SpellTimer3 = SpawnCast[3].Timer1 + (rand32() % 4 * 1000); } - if (me->GetEntry() == 19797)// Illidari Highlord + if (me->GetEntry() == 19797) // Illidari Highlord { SpellTimer1 = SpawnCast[4].Timer1 + (rand32() % 4 * 1000); SpellTimer2 = SpawnCast[5].Timer1 + (rand32() % 4 * 1000); } Timers = true; } - //Illidari Soldier + // Illidari Soldier if (me->GetEntry() == 22075) { if (SpellTimer1 <= diff) { - DoCastVictim(SpawnCast[0].SpellId);//Spellbreaker + DoCastVictim(SpawnCast[0].SpellId); // Spellbreaker SpellTimer1 = SpawnCast[0].Timer2 + (rand32() % 5 * 1000); - } else SpellTimer1 -= diff; + } + else + SpellTimer1 -= diff; } - //Illidari Mind Breaker + // Illidari Mind Breaker if (me->GetEntry() == 22074) { if (SpellTimer1 <= diff) @@ -1233,38 +1270,50 @@ class npc_illidari_spawn : public CreatureScript { if (target->GetTypeId() == TYPEID_PLAYER) { - DoCast(target, SpawnCast[1].SpellId); //Focused Bursts + DoCast(target, SpawnCast[1].SpellId); // Focused Bursts SpellTimer1 = SpawnCast[1].Timer2 + (rand32() % 5 * 1000); - } else SpellTimer1 = 2000; + } + else + SpellTimer1 = 2000; } - } else SpellTimer1 -= diff; + } + else + SpellTimer1 -= diff; if (SpellTimer2 <= diff) { - DoCastVictim(SpawnCast[2].SpellId);//Psychic Scream + DoCastVictim(SpawnCast[2].SpellId); // Psychic Scream SpellTimer2 = SpawnCast[2].Timer2 + (rand32() % 13 * 1000); - } else SpellTimer2 -= diff; + } + else + SpellTimer2 -= diff; if (SpellTimer3 <= diff) { - DoCastVictim(SpawnCast[3].SpellId);//Mind Blast + DoCastVictim(SpawnCast[3].SpellId); // Mind Blast SpellTimer3 = SpawnCast[3].Timer2 + (rand32() % 8 * 1000); - } else SpellTimer3 -= diff; + } + else + SpellTimer3 -= diff; } - //Illidari Highlord + // Illidari Highlord if (me->GetEntry() == 19797) { if (SpellTimer1 <= diff) { - DoCastVictim(SpawnCast[4].SpellId);//Curse Of Flames + DoCastVictim(SpawnCast[4].SpellId); // Curse Of Flames SpellTimer1 = SpawnCast[4].Timer2 + (rand32() % 10 * 1000); - } else SpellTimer1 -= diff; + } + else + SpellTimer1 -= diff; if (SpellTimer2 <= diff) { - DoCastVictim(SpawnCast[5].SpellId);//Flamestrike + DoCastVictim(SpawnCast[5].SpellId); // Flamestrike SpellTimer2 = SpawnCast[5].Timer2 + (rand32() % 7 * 13000); - } else SpellTimer2 -= diff; + } + else + SpellTimer2 -= diff; } DoMeleeAttackIfReady(); @@ -1288,9 +1337,9 @@ void npc_lord_illidan_stormrage::npc_lord_illidan_stormrageAI::SummonNextWave() { Spawn->LoadCreaturesAddon(); - if (WaveCount == 0)//1 Wave + if (WaveCount == 0) // 1 Wave { - if (rand32() % 3 == 1 && FelguardCount<2) + if (rand32() % 3 == 1 && FelguardCount < 2) { Spawn->SetDisplayId(18654); ++FelguardCount; @@ -1300,14 +1349,14 @@ void npc_lord_illidan_stormrage::npc_lord_illidan_stormrageAI::SummonNextWave() Spawn->SetDisplayId(19991); ++DreadlordCount; } - else if (FelguardCount<2) + else if (FelguardCount < 2) { Spawn->SetDisplayId(18654); ++FelguardCount; } } - if (WaveCount < 3)//1-3 Wave + if (WaveCount < 3) // 1-3 Wave { if (PlayerGUID) { @@ -1340,33 +1389,37 @@ void npc_lord_illidan_stormrage::npc_lord_illidan_stormrageAI::SummonNextWave() class go_crystal_prison : public GameObjectScript { - public: - go_crystal_prison() : GameObjectScript("go_crystal_prison") { } + public: + go_crystal_prison() : GameObjectScript("go_crystal_prison") + { + } - struct go_crystal_prisonAI : public GameObjectAI + struct go_crystal_prisonAI : public GameObjectAI + { + go_crystal_prisonAI(GameObject* go) : GameObjectAI(go) { - go_crystal_prisonAI(GameObject* go) : GameObjectAI(go) { } + } - void QuestAccept(Player* player, Quest const* quest) override + void QuestAccept(Player* player, Quest const* quest) override + { + if (quest->GetQuestId() == QUEST_BATTLE_OF_THE_CRIMSON_WATCH) { - if (quest->GetQuestId() == QUEST_BATTLE_OF_THE_CRIMSON_WATCH) - { - Creature* Illidan = player->FindNearestCreature(22083, 50); + Creature* Illidan = player->FindNearestCreature(22083, 50); - if (Illidan && !ENSURE_AI(npc_lord_illidan_stormrage::npc_lord_illidan_stormrageAI, Illidan->AI())->EventStarted) - { - ENSURE_AI(npc_lord_illidan_stormrage::npc_lord_illidan_stormrageAI, Illidan->AI())->PlayerGUID = player->GetGUID(); - ENSURE_AI(npc_lord_illidan_stormrage::npc_lord_illidan_stormrageAI, Illidan->AI())->LiveCount = 0; - ENSURE_AI(npc_lord_illidan_stormrage::npc_lord_illidan_stormrageAI, Illidan->AI())->EventStarted = true; - } + if (Illidan && !ENSURE_AI(npc_lord_illidan_stormrage::npc_lord_illidan_stormrageAI, Illidan->AI())->EventStarted) + { + ENSURE_AI(npc_lord_illidan_stormrage::npc_lord_illidan_stormrageAI, Illidan->AI())->PlayerGUID = player->GetGUID(); + ENSURE_AI(npc_lord_illidan_stormrage::npc_lord_illidan_stormrageAI, Illidan->AI())->LiveCount = 0; + ENSURE_AI(npc_lord_illidan_stormrage::npc_lord_illidan_stormrageAI, Illidan->AI())->EventStarted = true; } } - }; - - GameObjectAI* GetAI(GameObject* go) const override - { - return new go_crystal_prisonAI(go); } + }; + + GameObjectAI* GetAI(GameObject* go) const override + { + return new go_crystal_prisonAI(go); + } }; /*#### @@ -1376,71 +1429,73 @@ class go_crystal_prison : public GameObjectScript enum Enraged_Dpirits { // QUESTS - QUEST_ENRAGED_SPIRITS_FIRE_EARTH = 10458, - QUEST_ENRAGED_SPIRITS_AIR = 10481, - QUEST_ENRAGED_SPIRITS_WATER = 10480, + QUEST_ENRAGED_SPIRITS_FIRE_EARTH = 10458, + QUEST_ENRAGED_SPIRITS_AIR = 10481, + QUEST_ENRAGED_SPIRITS_WATER = 10480, // Totem - ENTRY_TOTEM_OF_SPIRITS = 21071, - RADIUS_TOTEM_OF_SPIRITS = 15, + ENTRY_TOTEM_OF_SPIRITS = 21071, + RADIUS_TOTEM_OF_SPIRITS = 15, // SPIRITS - NPC_ENRAGED_EARTH_SPIRIT = 21050, - NPC_ENRAGED_FIRE_SPIRIT = 21061, - NPC_ENRAGED_AIR_SPIRIT = 21060, - NPC_ENRAGED_WATER_SPIRIT = 21059, + NPC_ENRAGED_EARTH_SPIRIT = 21050, + NPC_ENRAGED_FIRE_SPIRIT = 21061, + NPC_ENRAGED_AIR_SPIRIT = 21060, + NPC_ENRAGED_WATER_SPIRIT = 21059, // ENRAGED WATER SPIRIT SPELLS - SPELL_STORMBOLT = 38032, + SPELL_STORMBOLT = 38032, // ENRAGED AIR SPIRIT SPELLS - SPELL_AIR_SPIRIT_CHAIN_LIGHTNING = 12058, - SPELL_HURRICANE = 32717, - SPELL_ENRAGE = 8599, + SPELL_AIR_SPIRIT_CHAIN_LIGHTNING = 12058, + SPELL_HURRICANE = 32717, + SPELL_ENRAGE = 8599, // ENRAGED FIRE SPIRIT SPELLS - Will be using the enrage spell from Air Spirit - SPELL_FEL_FIREBALL = 36247, - SPELL_FEL_FIRE_AURA = 36006, // Earth spirit uses this one + SPELL_FEL_FIREBALL = 36247, + SPELL_FEL_FIRE_AURA = 36006, // Earth spirit uses this one // ENRAGED EARTH SPIRIT SPELLS - SPELL_FIERY_BOULDER = 38498, - SPELL_SUMMON_ENRAGED_EARTH_SHARD = 38365, + SPELL_FIERY_BOULDER = 38498, + SPELL_SUMMON_ENRAGED_EARTH_SHARD = 38365, // SOULS - NPC_EARTHEN_SOUL = 21073, - NPC_FIERY_SOUL = 21097, - NPC_ENRAGED_AIRY_SOUL = 21116, - NPC_ENRAGED_WATERY_SOUL = 21109, // wrong model + NPC_EARTHEN_SOUL = 21073, + NPC_FIERY_SOUL = 21097, + NPC_ENRAGED_AIRY_SOUL = 21116, + NPC_ENRAGED_WATERY_SOUL = 21109, // wrong model // SPELL KILLCREDIT - not working!?! - using KilledMonsterCredit - SPELL_EARTHEN_SOUL_CAPTURED_CREDIT = 36108, - SPELL_FIERY_SOUL_CAPTURED_CREDIT = 36117, - SPELL_AIRY_SOUL_CAPTURED_CREDIT = 36182, - SPELL_WATERY_SOUL_CAPTURED_CREDIT = 36171, + SPELL_EARTHEN_SOUL_CAPTURED_CREDIT = 36108, + SPELL_FIERY_SOUL_CAPTURED_CREDIT = 36117, + SPELL_AIRY_SOUL_CAPTURED_CREDIT = 36182, + SPELL_WATERY_SOUL_CAPTURED_CREDIT = 36171, // KilledMonsterCredit Workaround - NPC_CREDIT_FIRE = 21094, - NPC_CREDIT_WATER = 21095, - NPC_CREDIT_AIR = 21096, - NPC_CREDIT_EARTH = 21092, + NPC_CREDIT_FIRE = 21094, + NPC_CREDIT_WATER = 21095, + NPC_CREDIT_AIR = 21096, + NPC_CREDIT_EARTH = 21092, // Captured Spell / Buff - SPELL_SOUL_CAPTURED = 36115 + SPELL_SOUL_CAPTURED = 36115 }; enum Enraged_Spirits_Events { - EVENT_ENRAGED_WATER_SPIRIT = 1, - EVENT_ENRAGED_FIRE_SPIRIT = 2, - EVENT_ENRAGED_EARTH_SPIRIT = 3, - EVENT_ENRAGED_AIR_SPIRIT_CHAIN_LIGHTNING = 4, - EVENT_ENRAGED_AIR_SPIRIT_HURRICANE = 5 + EVENT_ENRAGED_WATER_SPIRIT = 1, + EVENT_ENRAGED_FIRE_SPIRIT = 2, + EVENT_ENRAGED_EARTH_SPIRIT = 3, + EVENT_ENRAGED_AIR_SPIRIT_CHAIN_LIGHTNING = 4, + EVENT_ENRAGED_AIR_SPIRIT_HURRICANE = 5 }; class npc_enraged_spirit : public CreatureScript { -public: - npc_enraged_spirit() : CreatureScript("npc_enraged_spirit") { } + public: + npc_enraged_spirit() : CreatureScript("npc_enraged_spirit") + { + } CreatureAI* GetAI(Creature* creature) const override { @@ -1449,32 +1504,36 @@ class npc_enraged_spirit : public CreatureScript struct npc_enraged_spiritAI : public ScriptedAI { - npc_enraged_spiritAI(Creature* creature) : ScriptedAI(creature) { } + npc_enraged_spiritAI(Creature* creature) : ScriptedAI(creature) + { + } - void Reset() override { } + void Reset() override + { + } void JustEngagedWith(Unit* /*who*/) override { switch (me->GetEntry()) { - case NPC_ENRAGED_WATER_SPIRIT: - _events.ScheduleEvent(EVENT_ENRAGED_WATER_SPIRIT, 0s, Seconds(1)); - break; - case NPC_ENRAGED_FIRE_SPIRIT: - if (!me->GetAura(SPELL_FEL_FIRE_AURA)) - DoCastSelf(SPELL_FEL_FIRE_AURA); - _events.ScheduleEvent(EVENT_ENRAGED_FIRE_SPIRIT, Seconds(2), Seconds(10)); - break; - case NPC_ENRAGED_EARTH_SPIRIT: - if (!me->GetAura(SPELL_FEL_FIRE_AURA)) - DoCastSelf(SPELL_FEL_FIRE_AURA); - _events.ScheduleEvent(EVENT_ENRAGED_EARTH_SPIRIT, Seconds(3), Seconds(4)); - break; - case NPC_ENRAGED_AIR_SPIRIT: - _events.ScheduleEvent(EVENT_ENRAGED_AIR_SPIRIT_CHAIN_LIGHTNING, Seconds(10)); - break; - default: - break; + case NPC_ENRAGED_WATER_SPIRIT: + _events.ScheduleEvent(EVENT_ENRAGED_WATER_SPIRIT, 0s, Seconds(1)); + break; + case NPC_ENRAGED_FIRE_SPIRIT: + if (!me->GetAura(SPELL_FEL_FIRE_AURA)) + DoCastSelf(SPELL_FEL_FIRE_AURA); + _events.ScheduleEvent(EVENT_ENRAGED_FIRE_SPIRIT, Seconds(2), Seconds(10)); + break; + case NPC_ENRAGED_EARTH_SPIRIT: + if (!me->GetAura(SPELL_FEL_FIRE_AURA)) + DoCastSelf(SPELL_FEL_FIRE_AURA); + _events.ScheduleEvent(EVENT_ENRAGED_EARTH_SPIRIT, Seconds(3), Seconds(4)); + break; + case NPC_ENRAGED_AIR_SPIRIT: + _events.ScheduleEvent(EVENT_ENRAGED_AIR_SPIRIT_CHAIN_LIGHTNING, Seconds(10)); + break; + default: + break; } } @@ -1488,41 +1547,41 @@ class npc_enraged_spirit : public CreatureScript { switch (eventId) { - case EVENT_ENRAGED_WATER_SPIRIT: - if (UpdateVictim()) - DoCastVictim(SPELL_STORMBOLT); - _events.Repeat(Seconds(17), Seconds(23)); - break; - case EVENT_ENRAGED_FIRE_SPIRIT: - if (UpdateVictim()) - DoCastVictim(SPELL_FEL_FIREBALL); - _events.Repeat(Seconds(6), Seconds(12)); - break; - case EVENT_ENRAGED_EARTH_SPIRIT: - if (UpdateVictim()) - DoCastVictim(SPELL_FIERY_BOULDER); - _events.Repeat(Seconds(6), Seconds(9)); - break; - case EVENT_ENRAGED_AIR_SPIRIT_CHAIN_LIGHTNING: - if (UpdateVictim()) - DoCastVictim(SPELL_CHAIN_LIGHTNING); - _events.ScheduleEvent(EVENT_ENRAGED_AIR_SPIRIT_HURRICANE, Seconds(3), Seconds(5)); - break; - case EVENT_ENRAGED_AIR_SPIRIT_HURRICANE: - if (UpdateVictim()) - DoCastVictim(SPELL_HURRICANE); - _events.ScheduleEvent(EVENT_ENRAGED_AIR_SPIRIT_CHAIN_LIGHTNING, Seconds(15), Seconds(20)); - break; - default: - break; + case EVENT_ENRAGED_WATER_SPIRIT: + if (UpdateVictim()) + DoCastVictim(SPELL_STORMBOLT); + _events.Repeat(Seconds(17), Seconds(23)); + break; + case EVENT_ENRAGED_FIRE_SPIRIT: + if (UpdateVictim()) + DoCastVictim(SPELL_FEL_FIREBALL); + _events.Repeat(Seconds(6), Seconds(12)); + break; + case EVENT_ENRAGED_EARTH_SPIRIT: + if (UpdateVictim()) + DoCastVictim(SPELL_FIERY_BOULDER); + _events.Repeat(Seconds(6), Seconds(9)); + break; + case EVENT_ENRAGED_AIR_SPIRIT_CHAIN_LIGHTNING: + if (UpdateVictim()) + DoCastVictim(SPELL_CHAIN_LIGHTNING); + _events.ScheduleEvent(EVENT_ENRAGED_AIR_SPIRIT_HURRICANE, Seconds(3), Seconds(5)); + break; + case EVENT_ENRAGED_AIR_SPIRIT_HURRICANE: + if (UpdateVictim()) + DoCastVictim(SPELL_HURRICANE); + _events.ScheduleEvent(EVENT_ENRAGED_AIR_SPIRIT_CHAIN_LIGHTNING, Seconds(15), Seconds(20)); + break; + default: + break; } } - if (me->GetEntry() == NPC_ENRAGED_FIRE_SPIRIT || me->GetEntry() == NPC_ENRAGED_AIR_SPIRIT) - if (HealthBelowPct(35) && !me->GetAura(SPELL_ENRAGE)) - DoCastSelf(SPELL_ENRAGE); + if (me->GetEntry() == NPC_ENRAGED_FIRE_SPIRIT || me->GetEntry() == NPC_ENRAGED_AIR_SPIRIT) + if (HealthBelowPct(35) && !me->GetAura(SPELL_ENRAGE)) + DoCastSelf(SPELL_ENRAGE); - DoMeleeAttackIfReady(); + DoMeleeAttackIfReady(); } void JustDied(Unit* /*killer*/) override @@ -1535,29 +1594,29 @@ class npc_enraged_spirit : public CreatureScript switch (me->GetEntry()) { - case NPC_ENRAGED_FIRE_SPIRIT: - entry = NPC_FIERY_SOUL; - //credit = SPELL_FIERY_SOUL_CAPTURED_CREDIT; - credit = NPC_CREDIT_FIRE; - break; - case NPC_ENRAGED_EARTH_SPIRIT: - entry = NPC_EARTHEN_SOUL; - //credit = SPELL_EARTHEN_SOUL_CAPTURED_CREDIT; - credit = NPC_CREDIT_EARTH; - DoCastSelf(SPELL_SUMMON_ENRAGED_EARTH_SHARD); - break; - case NPC_ENRAGED_AIR_SPIRIT: - entry = NPC_ENRAGED_AIRY_SOUL; - //credit = SPELL_AIRY_SOUL_CAPTURED_CREDIT; - credit = NPC_CREDIT_AIR; - break; - case NPC_ENRAGED_WATER_SPIRIT: - entry = NPC_ENRAGED_WATERY_SOUL; - //credit = SPELL_WATERY_SOUL_CAPTURED_CREDIT; - credit = NPC_CREDIT_WATER; - break; - default: - break; + case NPC_ENRAGED_FIRE_SPIRIT: + entry = NPC_FIERY_SOUL; + // credit = SPELL_FIERY_SOUL_CAPTURED_CREDIT; + credit = NPC_CREDIT_FIRE; + break; + case NPC_ENRAGED_EARTH_SPIRIT: + entry = NPC_EARTHEN_SOUL; + // credit = SPELL_EARTHEN_SOUL_CAPTURED_CREDIT; + credit = NPC_CREDIT_EARTH; + DoCastSelf(SPELL_SUMMON_ENRAGED_EARTH_SHARD); + break; + case NPC_ENRAGED_AIR_SPIRIT: + entry = NPC_ENRAGED_AIRY_SOUL; + // credit = SPELL_AIRY_SOUL_CAPTURED_CREDIT; + credit = NPC_CREDIT_AIR; + break; + case NPC_ENRAGED_WATER_SPIRIT: + entry = NPC_ENRAGED_WATERY_SOUL; + // credit = SPELL_WATERY_SOUL_CAPTURED_CREDIT; + credit = NPC_CREDIT_WATER; + break; + default: + break; } // Spawn Soul on Kill ALWAYS! @@ -1570,77 +1629,83 @@ class npc_enraged_spirit : public CreatureScript // FIND TOTEM, PROCESS QUEST if (Summoned) { - totemOspirits = me->FindNearestCreature(ENTRY_TOTEM_OF_SPIRITS, RADIUS_TOTEM_OF_SPIRITS); - if (totemOspirits) - { - Summoned->SetFaction(FACTION_FRIENDLY); - Summoned->GetMotionMaster()->MovePoint(0, totemOspirits->GetPositionX(), totemOspirits->GetPositionY(), Summoned->GetPositionZ()); - - if (Unit* owner = totemOspirits->GetOwner()) - if (Player* player = owner->ToPlayer()) - player->KilledMonsterCredit(credit); - DoCast(totemOspirits, SPELL_SOUL_CAPTURED); - } + totemOspirits = me->FindNearestCreature(ENTRY_TOTEM_OF_SPIRITS, RADIUS_TOTEM_OF_SPIRITS); + if (totemOspirits) + { + Summoned->SetFaction(FACTION_FRIENDLY); + Summoned->GetMotionMaster()->MovePoint(0, totemOspirits->GetPositionX(), totemOspirits->GetPositionY(), Summoned->GetPositionZ()); + + if (Unit* owner = totemOspirits->GetOwner()) + if (Player* player = owner->ToPlayer()) + player->KilledMonsterCredit(credit); + DoCast(totemOspirits, SPELL_SOUL_CAPTURED); + } } } - private: + private: EventMap _events; }; }; enum ZuluhedChains { - NPC_KARYNAKU = 22112, + NPC_KARYNAKU = 22112, }; class spell_unlocking_zuluheds_chains : public SpellScriptLoader { - public: - spell_unlocking_zuluheds_chains() : SpellScriptLoader("spell_unlocking_zuluheds_chains") { } + public: + spell_unlocking_zuluheds_chains() : SpellScriptLoader("spell_unlocking_zuluheds_chains") + { + } - class spell_unlocking_zuluheds_chains_SpellScript : public SpellScript + class spell_unlocking_zuluheds_chains_SpellScript : public SpellScript + { + void HandleAfterHit() { - void HandleAfterHit() - { - if (Player* caster = GetCaster()->ToPlayer()) - if (Creature* karynaku = caster->FindNearestCreature(NPC_KARYNAKU, 15.0f)) - caster->KilledMonsterCredit(NPC_KARYNAKU, karynaku->GetGUID()); - } - - void Register() override - { - AfterHit.Register(&spell_unlocking_zuluheds_chains_SpellScript::HandleAfterHit); - } - }; + if (Player* caster = GetCaster()->ToPlayer()) + if (Creature* karynaku = caster->FindNearestCreature(NPC_KARYNAKU, 15.0f)) + caster->KilledMonsterCredit(NPC_KARYNAKU, karynaku->GetGUID()); + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_unlocking_zuluheds_chains_SpellScript(); + AfterHit.Register(&spell_unlocking_zuluheds_chains_SpellScript::HandleAfterHit); } + }; + + SpellScript* GetSpellScript() const override + { + return new spell_unlocking_zuluheds_chains_SpellScript(); + } }; enum ShadowMoonTuberEnum { - SPELL_WHISTLE = 36652, - SPELL_SHADOWMOON_TUBER = 36462, + SPELL_WHISTLE = 36652, + SPELL_SHADOWMOON_TUBER = 36462, - NPC_BOAR_ENTRY = 21195, - GO_SHADOWMOON_TUBER_MOUND = 184701, + NPC_BOAR_ENTRY = 21195, + GO_SHADOWMOON_TUBER_MOUND = 184701, - POINT_TUBER = 1, - TYPE_BOAR = 1, - DATA_BOAR = 1 + POINT_TUBER = 1, + TYPE_BOAR = 1, + DATA_BOAR = 1 }; class npc_shadowmoon_tuber_node : public CreatureScript { -public: - npc_shadowmoon_tuber_node() : CreatureScript("npc_shadowmoon_tuber_node") { } + public: + npc_shadowmoon_tuber_node() : CreatureScript("npc_shadowmoon_tuber_node") + { + } struct npc_shadowmoon_tuber_nodeAI : public ScriptedAI { - npc_shadowmoon_tuber_nodeAI(Creature* creature) : ScriptedAI(creature) { } + npc_shadowmoon_tuber_nodeAI(Creature* creature) : ScriptedAI(creature) + { + } void SetData(uint32 id, uint32 data) override { diff --git a/src/server/scripts/Spells/spell_dk.cpp b/src/server/scripts/Spells/spell_dk.cpp index ab9a0a11..9a2cac3e 100644 --- a/src/server/scripts/Spells/spell_dk.cpp +++ b/src/server/scripts/Spells/spell_dk.cpp @@ -15,18 +15,18 @@ * with this program. If not, see . */ - /* - * Scripts for spells with SPELLFAMILY_DEATHKNIGHT and SPELLFAMILY_GENERIC spells used by deathknight players. - * Ordered alphabetically using scriptname. - * Scriptnames of files in this file should be prefixed with "spell_dk_". - */ +/* + * Scripts for spells with SPELLFAMILY_DEATHKNIGHT and SPELLFAMILY_GENERIC spells used by deathknight players. + * Ordered alphabetically using scriptname. + * Scriptnames of files in this file should be prefixed with "spell_dk_". + */ -#include "ScriptMgr.h" #include "Containers.h" #include "Creature.h" #include "GridNotifiers.h" #include "Pet.h" #include "Player.h" +#include "ScriptMgr.h" #include "Spell.h" #include "SpellAuraEffects.h" #include "SpellHistory.h" @@ -35,78 +35,78 @@ enum DeathKnightSpells { - SPELL_DK_ANTI_MAGIC_SHELL_TALENT = 51052, - SPELL_DK_BLOOD_BOIL_TRIGGERED = 65658, - SPELL_DK_BLOOD_BURST = 81280, - SPELL_DK_BLOOD_PLAGUE = 55078, - SPELL_DK_BLOOD_PRESENCE = 48263, - SPELL_DK_BLOOD_PRESENCE_TRIGGERED = 61261, - SPELL_DK_BLOOD_SHIELD_ABSORB = 77535, - SPELL_DK_BLOOD_STRIKE = 45902, - SPELL_DK_BLOOD_STRIKE_OFFHAND = 66215, - SPELL_DK_BLOOD_TAP = 45529, - SPELL_DK_BUTCHERY = 50163, - SPELL_DK_CORPSE_EXPLOSION_TRIGGERED = 43999, - SPELL_DK_DANCING_RUNE_WEAPON_PARRY_BONUS = 81256, - SPELL_DK_DARK_TRANSFORMATION = 63560, - SPELL_DK_DARK_TRANSFORMATION_DUMMY = 93426, - SPELL_DK_DEATH_AND_DECAY_DAMAGE = 52212, - SPELL_DK_DEATH_COIL = 47541, - SPELL_DK_DEATH_COIL_DAMAGE = 47632, - SPELL_DK_DEATH_COIL_HEAL = 47633, - SPELL_DK_DEATH_EATER = 90507, - SPELL_DK_DEATH_GRIP = 49560, - SPELL_DK_DEATH_GRIP_INITIAL = 49576, - SPELL_DK_DEATH_STRIKE = 49998, - SPELL_DK_DEATH_STRIKE_OFFHAND = 66188, - SPELL_DK_DEATH_STRIKE_HEAL = 45470, - SPELL_DK_DEATH_STRIKE_ENABLER = 89832, - SPELL_DK_EBON_PLAGUE = 65142, - SPELL_DK_FLAMING_RUNE_WEAPON = 101162, - SPELL_DK_FLAMING_TORRENT = 99000, - SPELL_DK_FROST_FEVER = 55095, - SPELL_DK_FROST_PRESENCE = 48266, - SPELL_DK_FROST_STRIKE = 49143, - SPELL_DK_FROST_STRIKE_OFFHAND = 66196, - SPELL_DK_GHOUL_EXPLODE = 47496, - SPELL_DK_GLYPH_OF_ICEBOUND_FORTITUDE = 58625, - SPELL_DK_IMPROVED_BLOOD_PRESENCE_R1 = 50365, - SPELL_DK_IMPROVED_BLOOD_PRESENCE = 63611, - SPELL_DK_IMPROVED_DEATH_STRIKE = 62905, - SPELL_DK_IMPROVED_FROST_PRESENCE = 63621, - SPELL_DK_IMPROVED_UNHOLY_PRESENCE = 63622, - SPELL_DK_ITEM_SIGIL_VENGEFUL_HEART = 64962, - SPELL_DK_ITEM_T8_MELEE_4P_BONUS = 64736, - SPELL_DK_ITEM_T11_DPS_4P_BONUS = 90459, - SPELL_DK_ITEM_T12_BLOOD_4P_BONUS = 98966, - SPELL_DK_MASTER_OF_GHOULS = 52143, - SPELL_DK_OBLITERATE = 49020, - SPELL_DK_OBLITERATE_OFFHAND = 66198, - SPELL_DK_PLAGUE_STRIKE = 45462, - SPELL_DK_PLAGUE_STRIKE_OFFHAND = 66216, - SPELL_DK_RESILIENT_INFECTION = 90721, - SPELL_DK_RUNIC_CORRUPTION_TRIGGERED = 51460, - SPELL_DK_RUNE_STRIKE = 56815, - SPELL_DK_RUNE_STRIKE_OFFHAND = 66217, - SPELL_DK_RUNE_TAP = 48982, - SPELL_DK_SCENT_OF_BLOOD = 50422, - SPELL_DK_SCOURGE_STRIKE_TRIGGERED = 70890, - SPELL_DK_SHADOW_INFUSION = 91342, - SPELL_DK_SMOLDERING_RUNE_ENERGIZE = 99055, - SPELL_DK_UNHOLY_BLIGHT_PERIODIC = 50536, - SPELL_DK_UNHOLY_PRESENCE = 48265, - SPELL_DK_PESTILENCE_REDUCED_DOTS = 76243, - SPELL_DK_PESTILENCE_VISUAL = 91939, - SPELL_DK_WILL_OF_THE_NECROPOLIS = 96171 + SPELL_DK_ANTI_MAGIC_SHELL_TALENT = 51052, + SPELL_DK_BLOOD_BOIL_TRIGGERED = 65658, + SPELL_DK_BLOOD_BURST = 81280, + SPELL_DK_BLOOD_PLAGUE = 55078, + SPELL_DK_BLOOD_PRESENCE = 48263, + SPELL_DK_BLOOD_PRESENCE_TRIGGERED = 61261, + SPELL_DK_BLOOD_SHIELD_ABSORB = 77535, + SPELL_DK_BLOOD_STRIKE = 45902, + SPELL_DK_BLOOD_STRIKE_OFFHAND = 66215, + SPELL_DK_BLOOD_TAP = 45529, + SPELL_DK_BUTCHERY = 50163, + SPELL_DK_CORPSE_EXPLOSION_TRIGGERED = 43999, + SPELL_DK_DANCING_RUNE_WEAPON_PARRY_BONUS = 81256, + SPELL_DK_DARK_TRANSFORMATION = 63560, + SPELL_DK_DARK_TRANSFORMATION_DUMMY = 93426, + SPELL_DK_DEATH_AND_DECAY_DAMAGE = 52212, + SPELL_DK_DEATH_COIL = 47541, + SPELL_DK_DEATH_COIL_DAMAGE = 47632, + SPELL_DK_DEATH_COIL_HEAL = 47633, + SPELL_DK_DEATH_EATER = 90507, + SPELL_DK_DEATH_GRIP = 49560, + SPELL_DK_DEATH_GRIP_INITIAL = 49576, + SPELL_DK_DEATH_STRIKE = 49998, + SPELL_DK_DEATH_STRIKE_OFFHAND = 66188, + SPELL_DK_DEATH_STRIKE_HEAL = 45470, + SPELL_DK_DEATH_STRIKE_ENABLER = 89832, + SPELL_DK_EBON_PLAGUE = 65142, + SPELL_DK_FLAMING_RUNE_WEAPON = 101162, + SPELL_DK_FLAMING_TORRENT = 99000, + SPELL_DK_FROST_FEVER = 55095, + SPELL_DK_FROST_PRESENCE = 48266, + SPELL_DK_FROST_STRIKE = 49143, + SPELL_DK_FROST_STRIKE_OFFHAND = 66196, + SPELL_DK_GHOUL_EXPLODE = 47496, + SPELL_DK_GLYPH_OF_ICEBOUND_FORTITUDE = 58625, + SPELL_DK_IMPROVED_BLOOD_PRESENCE_R1 = 50365, + SPELL_DK_IMPROVED_BLOOD_PRESENCE = 63611, + SPELL_DK_IMPROVED_DEATH_STRIKE = 62905, + SPELL_DK_IMPROVED_FROST_PRESENCE = 63621, + SPELL_DK_IMPROVED_UNHOLY_PRESENCE = 63622, + SPELL_DK_ITEM_SIGIL_VENGEFUL_HEART = 64962, + SPELL_DK_ITEM_T8_MELEE_4P_BONUS = 64736, + SPELL_DK_ITEM_T11_DPS_4P_BONUS = 90459, + SPELL_DK_ITEM_T12_BLOOD_4P_BONUS = 98966, + SPELL_DK_MASTER_OF_GHOULS = 52143, + SPELL_DK_OBLITERATE = 49020, + SPELL_DK_OBLITERATE_OFFHAND = 66198, + SPELL_DK_PLAGUE_STRIKE = 45462, + SPELL_DK_PLAGUE_STRIKE_OFFHAND = 66216, + SPELL_DK_RESILIENT_INFECTION = 90721, + SPELL_DK_RUNIC_CORRUPTION_TRIGGERED = 51460, + SPELL_DK_RUNE_STRIKE = 56815, + SPELL_DK_RUNE_STRIKE_OFFHAND = 66217, + SPELL_DK_RUNE_TAP = 48982, + SPELL_DK_SCENT_OF_BLOOD = 50422, + SPELL_DK_SCOURGE_STRIKE_TRIGGERED = 70890, + SPELL_DK_SHADOW_INFUSION = 91342, + SPELL_DK_SMOLDERING_RUNE_ENERGIZE = 99055, + SPELL_DK_UNHOLY_BLIGHT_PERIODIC = 50536, + SPELL_DK_UNHOLY_PRESENCE = 48265, + SPELL_DK_PESTILENCE_REDUCED_DOTS = 76243, + SPELL_DK_PESTILENCE_VISUAL = 91939, + SPELL_DK_WILL_OF_THE_NECROPOLIS = 96171 }; enum DKSpellIcons { - DK_ICON_ID_RUNIC_CORRUPTION = 4068, - DK_ICON_ID_RESILIENT_INFECTION = 1910, - DK_ICON_ID_IMPROVED_UNHOLY_PRESENCE = 2633, - DK_ICON_ID_IMPROVED_FROST_PRESENCE = 2632, - DK_ICON_ID_BLOOD_SHIELD_MASTERY = 2624 + DK_ICON_ID_RUNIC_CORRUPTION = 4068, + DK_ICON_ID_RESILIENT_INFECTION = 1910, + DK_ICON_ID_IMPROVED_UNHOLY_PRESENCE = 2633, + DK_ICON_ID_IMPROVED_FROST_PRESENCE = 2632, + DK_ICON_ID_BLOOD_SHIELD_MASTERY = 2624 }; // 48707 - Anti-Magic Shell (on self) @@ -119,12 +119,12 @@ class spell_dk_anti_magic_shell : public AuraScript return true; } - void CalculateAmount(AuraEffect const* /*aurEff*/, int32 & amount, bool & /*canBeRecalculated*/) + void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/) { amount = GetCaster()->CountPctFromMaxHealth(healthPct); } - void Absorb(AuraEffect* /*aurEff*/, DamageInfo & dmgInfo, uint32 & absorbAmount) + void Absorb(AuraEffect* /*aurEff*/, DamageInfo& dmgInfo, uint32& absorbAmount) { absorbAmount = std::min(CalculatePct(dmgInfo.GetDamage(), absorbPct), GetTarget()->CountPctFromMaxHealth(healthPct)); } @@ -134,7 +134,8 @@ class spell_dk_anti_magic_shell : public AuraScript DoEffectCalcAmount.Register(&spell_dk_anti_magic_shell::CalculateAmount, EFFECT_0, SPELL_AURA_SCHOOL_ABSORB); OnEffectAbsorb.Register(&spell_dk_anti_magic_shell::Absorb, EFFECT_0); } -private: + + private: int32 absorbPct; int32 healthPct; }; @@ -150,10 +151,10 @@ class spell_dk_anti_magic_zone : public AuraScript bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo({ SPELL_DK_ANTI_MAGIC_SHELL_TALENT }); + return ValidateSpellInfo({SPELL_DK_ANTI_MAGIC_SHELL_TALENT}); } - void CalculateAmount(AuraEffect const* /*aurEff*/, int32 & amount, bool & /*canBeRecalculated*/) + void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/) { SpellInfo const* talentSpell = sSpellMgr->AssertSpellInfo(SPELL_DK_ANTI_MAGIC_SHELL_TALENT); amount = talentSpell->Effects[EFFECT_0].CalcValue(GetCaster()); @@ -161,7 +162,7 @@ class spell_dk_anti_magic_zone : public AuraScript amount += int32(2 * player->GetTotalAttackPowerValue(BASE_ATTACK)); } - void Absorb(AuraEffect* /*aurEff*/, DamageInfo & dmgInfo, uint32 & absorbAmount) + void Absorb(AuraEffect* /*aurEff*/, DamageInfo& dmgInfo, uint32& absorbAmount) { absorbAmount = CalculatePct(dmgInfo.GetDamage(), absorbPct); } @@ -171,7 +172,8 @@ class spell_dk_anti_magic_zone : public AuraScript DoEffectCalcAmount.Register(&spell_dk_anti_magic_zone::CalculateAmount, EFFECT_0, SPELL_AURA_SCHOOL_ABSORB); OnEffectAbsorb.Register(&spell_dk_anti_magic_zone::Absorb, EFFECT_0); } -private: + + private: uint32 absorbPct = 0; }; @@ -180,7 +182,7 @@ class spell_dk_blood_boil : public SpellScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo({ SPELL_DK_BLOOD_BOIL_TRIGGERED }); + return ValidateSpellInfo({SPELL_DK_BLOOD_BOIL_TRIGGERED}); } bool Load() override @@ -203,7 +205,7 @@ class spell_dk_blood_boil : public SpellScript AfterHit.Register(&spell_dk_blood_boil::HandleAfterHit); } -private: + private: bool _executed; }; @@ -212,7 +214,7 @@ class spell_dk_blood_gorged : public AuraScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo({ SPELL_DK_BLOOD_BURST }); + return ValidateSpellInfo({SPELL_DK_BLOOD_BURST}); } void HandleBloodBurst(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) @@ -237,7 +239,7 @@ class spell_dk_butchery : public AuraScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo({ SPELL_DK_BUTCHERY }); + return ValidateSpellInfo({SPELL_DK_BUTCHERY}); } void HandleProc(AuraEffect const* aurEff, ProcEventInfo& /*eventInfo*/) @@ -256,13 +258,13 @@ class spell_dk_death_and_decay : public AuraScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo({ SPELL_DK_DEATH_AND_DECAY_DAMAGE }); + return ValidateSpellInfo({SPELL_DK_DEATH_AND_DECAY_DAMAGE}); } void HandleDummyTick(AuraEffect const* aurEff) { if (DynamicObject* dyn = GetTarget()->GetDynObject(aurEff->GetId())) - GetTarget()->CastSpell({ dyn->GetPositionX(), dyn->GetPositionY(), dyn->GetPositionZ() }, SPELL_DK_DEATH_AND_DECAY_DAMAGE, aurEff); + GetTarget()->CastSpell({dyn->GetPositionX(), dyn->GetPositionY(), dyn->GetPositionZ()}, SPELL_DK_DEATH_AND_DECAY_DAMAGE, aurEff); } void Register() override @@ -281,17 +283,13 @@ class spell_dk_death_coil : public SpellScript bool Validate(SpellInfo const* /*spell*/) override { - return ValidateSpellInfo( - { - SPELL_DK_DEATH_COIL_DAMAGE, - SPELL_DK_DEATH_COIL_HEAL - }); + return ValidateSpellInfo({SPELL_DK_DEATH_COIL_DAMAGE, SPELL_DK_DEATH_COIL_HEAL}); } SpellCastResult CheckCast() { Unit* caster = GetCaster(); - if (Unit * target = GetExplTargetUnit()) + if (Unit* target = GetExplTargetUnit()) { if (!caster->IsFriendlyTo(target) && !caster->isInFront(target)) return SPELL_FAILED_UNIT_NOT_INFRONT; @@ -377,7 +375,7 @@ class spell_dk_death_grip : public SpellScript if (Unit* target = GetHitUnit()) { if (!target->HasAuraType(SPELL_AURA_DEFLECT_SPELLS)) // Deterrence - target->CastSpell({ pos->GetPositionX(), pos->GetPositionY(), pos->GetPositionZ() }, damage, true); + target->CastSpell({pos->GetPositionX(), pos->GetPositionY(), pos->GetPositionZ()}, damage, true); } } @@ -385,7 +383,6 @@ class spell_dk_death_grip : public SpellScript { OnEffectHitTarget.Register(&spell_dk_death_grip::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); } - }; // 48743 - Death Pact @@ -397,9 +394,7 @@ class spell_dk_death_pact : public SpellScript if (Player* player = GetCaster()->ToPlayer()) for (Unit::ControlList::const_iterator itr = player->m_Controlled.begin(); itr != player->m_Controlled.end(); ++itr) if (Creature* undeadPet = (*itr)->ToCreature()) - if (undeadPet->IsAlive() && - undeadPet->GetOwnerOrCreatorGUID() == player->GetGUID() && - undeadPet->GetCreatureType() == CREATURE_TYPE_UNDEAD && + if (undeadPet->IsAlive() && undeadPet->GetOwnerOrCreatorGUID() == player->GetGUID() && undeadPet->GetCreatureType() == CREATURE_TYPE_UNDEAD && undeadPet->IsWithinDist(player, 100.0f, false)) return SPELL_CAST_OK; @@ -438,12 +433,7 @@ class spell_dk_death_strike : public SpellScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo( - { - SPELL_DK_DEATH_STRIKE_ENABLER, - SPELL_DK_DEATH_STRIKE_HEAL, - SPELL_DK_BLOOD_SHIELD_ABSORB - }); + return ValidateSpellInfo({SPELL_DK_DEATH_STRIKE_ENABLER, SPELL_DK_DEATH_STRIKE_HEAL, SPELL_DK_BLOOD_SHIELD_ABSORB}); } void HandleDummy(SpellEffIndex /*effIndex*/) @@ -528,7 +518,8 @@ class spell_dk_death_strike_enabler : public AuraScript OnEffectUpdatePeriodic.Register(&spell_dk_death_strike_enabler::Update, EFFECT_0, SPELL_AURA_DUMMY); DoEffectCalcAmount.Register(&spell_dk_death_strike_enabler::HandleCalcAmount, EFFECT_0, SPELL_AURA_DUMMY); } -private: + + private: uint32 _damagePerSecond[5]; }; @@ -537,11 +528,7 @@ class spell_dk_death_strike_heal : public SpellScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo( - { - SPELL_DK_BLOOD_PRESENCE, - SPELL_DK_BLOOD_SHIELD_ABSORB - }); + return ValidateSpellInfo({SPELL_DK_BLOOD_PRESENCE, SPELL_DK_BLOOD_SHIELD_ABSORB}); } void HandleBloodShield() @@ -571,7 +558,7 @@ class spell_dk_ghoul_explode : public SpellScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo({ SPELL_DK_CORPSE_EXPLOSION_TRIGGERED }); + return ValidateSpellInfo({SPELL_DK_CORPSE_EXPLOSION_TRIGGERED}); } void Suicide(SpellEffIndex /*effIndex*/) @@ -628,7 +615,7 @@ class spell_dk_icebound_fortitude : public AuraScript // 73975 - Necrotic Strike class spell_dk_necrotic_strike : public AuraScript { - void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool & /*canBeRecalculated*/) + void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/) { if (Unit* caster = GetCaster()) amount = int32(caster->GetTotalAttackPowerValue(BASE_ATTACK) * 0.7f); @@ -645,13 +632,7 @@ class spell_dk_pestilence : public SpellScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo( - { - SPELL_DK_PESTILENCE_REDUCED_DOTS, - SPELL_DK_PESTILENCE_VISUAL, - SPELL_DK_BLOOD_PLAGUE, - SPELL_DK_FROST_FEVER - }); + return ValidateSpellInfo({SPELL_DK_PESTILENCE_REDUCED_DOTS, SPELL_DK_PESTILENCE_VISUAL, SPELL_DK_BLOOD_PLAGUE, SPELL_DK_FROST_FEVER}); } bool Load() override @@ -678,18 +659,21 @@ class spell_dk_pestilence : public SpellScript { if (Aura* aurOld = victim->GetAura(SPELL_DK_BLOOD_PLAGUE, caster->GetGUID())) // Check Blood Plague application on victim. { + float donePct = aurOld->GetDonePct(); + float critChance = aurOld->GetCritChance(); + if (AuraEffect* aurEffOld = aurOld->GetEffect(EFFECT_0)) { - float donePct = aurEffOld->GetDonePct(); - caster->CastSpell(hitUnit, SPELL_DK_BLOOD_PLAGUE, true); // Spread the disease to hitUnit. if (Aura* aurNew = hitUnit->GetAura(SPELL_DK_BLOOD_PLAGUE, caster->GetGUID())) // Check Blood Plague application on hitUnit. { if (AuraEffect* aurEffNew = aurNew->GetEffect(EFFECT_0)) { - aurEffNew->SetDonePct(donePct); - aurEffNew->SetBonusAmount(caster->SpellDamageBonusDone(hitUnit, aurEffNew->GetSpellInfo(), 0, DOT, aurEffNew->GetEffIndex())); + aurNew->SetCritChance(critChance); // Blood Plague can crit if caster has T9. + aurNew->SetDonePct(donePct); + if (AuraEffect* aurEffNew = aurNew->GetEffect(EFFECT_0)) + aurEffNew->ChangeAmount(aurEffNew->CalculateAmount(aurEffNew->GetCaster()), false); } } } @@ -697,19 +681,17 @@ class spell_dk_pestilence : public SpellScript if (Aura* aurOld = victim->GetAura(SPELL_DK_FROST_FEVER, caster->GetGUID())) // Check Frost Fever application on victim. { + float donePct = aurOld->GetDonePct(); + if (AuraEffect* aurEffOld = aurOld->GetEffect(EFFECT_0)) { - float donePct = aurEffOld->GetDonePct(); - caster->CastSpell(hitUnit, SPELL_DK_FROST_FEVER, true); // Spread the disease to hitUnit. if (Aura* aurNew = hitUnit->GetAura(SPELL_DK_FROST_FEVER, caster->GetGUID())) // Check Frost Fever application on hitUnit. { + aurNew->SetDonePct(donePct); if (AuraEffect* aurEffNew = aurNew->GetEffect(EFFECT_0)) - { - aurEffNew->SetDonePct(donePct); - aurEffNew->SetBonusAmount(caster->SpellDamageBonusDone(hitUnit, aurEffNew->GetSpellInfo(), 0, DOT, aurEffNew->GetEffIndex())); - } + aurEffNew->ChangeAmount(aurEffNew->CalculateAmount(aurEffNew->GetCaster()), false); } } } @@ -734,8 +716,8 @@ class spell_dk_pestilence : public SpellScript AfterCast.Register(&spell_dk_pestilence::HandleAuraRemoval); } -private: - Unit * _prevTarget; + private: + Unit* _prevTarget; }; // 48266 - Frost Presence @@ -745,17 +727,8 @@ class spell_dk_presence : public AuraScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo( - { - SPELL_DK_UNHOLY_PRESENCE, - SPELL_DK_FROST_PRESENCE, - SPELL_DK_BLOOD_PRESENCE, - SPELL_DK_BLOOD_PRESENCE_TRIGGERED, - SPELL_DK_IMPROVED_UNHOLY_PRESENCE, - SPELL_DK_IMPROVED_FROST_PRESENCE, - SPELL_DK_IMPROVED_BLOOD_PRESENCE, - SPELL_DK_IMPROVED_BLOOD_PRESENCE_R1 - }); + return ValidateSpellInfo({SPELL_DK_UNHOLY_PRESENCE, SPELL_DK_FROST_PRESENCE, SPELL_DK_BLOOD_PRESENCE, SPELL_DK_BLOOD_PRESENCE_TRIGGERED, SPELL_DK_IMPROVED_UNHOLY_PRESENCE, + SPELL_DK_IMPROVED_FROST_PRESENCE, SPELL_DK_IMPROVED_BLOOD_PRESENCE, SPELL_DK_IMPROVED_BLOOD_PRESENCE_R1}); } void HandlePresenceEffects(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) @@ -829,14 +802,7 @@ class spell_dk_improved_presence : public AuraScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo( - { - SPELL_DK_BLOOD_PRESENCE, - SPELL_DK_BLOOD_PRESENCE_TRIGGERED, - SPELL_DK_IMPROVED_UNHOLY_PRESENCE, - SPELL_DK_IMPROVED_FROST_PRESENCE, - SPELL_DK_IMPROVED_BLOOD_PRESENCE - }); + return ValidateSpellInfo({SPELL_DK_BLOOD_PRESENCE, SPELL_DK_BLOOD_PRESENCE_TRIGGERED, SPELL_DK_IMPROVED_UNHOLY_PRESENCE, SPELL_DK_IMPROVED_FROST_PRESENCE, SPELL_DK_IMPROVED_BLOOD_PRESENCE}); } void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { @@ -861,12 +827,7 @@ class spell_dk_raise_dead : public SpellScript { bool Validate(SpellInfo const* spellInfo) override { - return ValidateSpellInfo( - { - uint32(spellInfo->Effects[EFFECT_0].CalcValue()), - uint32(spellInfo->Effects[EFFECT_1].CalcValue()), - SPELL_DK_MASTER_OF_GHOULS - }); + return ValidateSpellInfo({uint32(spellInfo->Effects[EFFECT_0].CalcValue()), uint32(spellInfo->Effects[EFFECT_1].CalcValue()), SPELL_DK_MASTER_OF_GHOULS}); } bool Load() override @@ -915,7 +876,7 @@ class spell_dk_scent_of_blood : public AuraScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo({ SPELL_DK_SCENT_OF_BLOOD }); + return ValidateSpellInfo({SPELL_DK_SCENT_OF_BLOOD}); } void OnProc(AuraEffect const* aurEff, ProcEventInfo& /*eventInfo*/) @@ -936,11 +897,7 @@ class spell_dk_scourge_strike : public SpellScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo( - { - SPELL_DK_SCOURGE_STRIKE_TRIGGERED, - SPELL_DK_ITEM_T8_MELEE_4P_BONUS - }); + return ValidateSpellInfo({SPELL_DK_SCOURGE_STRIKE_TRIGGERED, SPELL_DK_ITEM_T8_MELEE_4P_BONUS}); } void HandleAfterHit() @@ -964,7 +921,8 @@ class spell_dk_scourge_strike : public SpellScript { AfterHit.Register(&spell_dk_scourge_strike::HandleAfterHit); } -private: + + private: float multiplier = 1.0f; }; @@ -988,11 +946,7 @@ class spell_dk_will_of_the_necropolis : public AuraScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo( - { - SPELL_DK_WILL_OF_THE_NECROPOLIS, - SPELL_DK_RUNE_TAP - }); + return ValidateSpellInfo({SPELL_DK_WILL_OF_THE_NECROPOLIS, SPELL_DK_RUNE_TAP}); } bool CheckProc(ProcEventInfo& eventInfo) @@ -1051,12 +1005,7 @@ class spell_dk_shadow_infusion : public AuraScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo( - { - SPELL_DK_SHADOW_INFUSION, - SPELL_DK_DARK_TRANSFORMATION_DUMMY, - SPELL_DK_DEATH_COIL - }); + return ValidateSpellInfo({SPELL_DK_SHADOW_INFUSION, SPELL_DK_DARK_TRANSFORMATION_DUMMY, SPELL_DK_DEATH_COIL}); } bool CheckProc(ProcEventInfo& eventInfo) @@ -1096,11 +1045,7 @@ class spell_dk_dark_transformation : public SpellScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo( - { - SPELL_DK_SHADOW_INFUSION, - SPELL_DK_DARK_TRANSFORMATION_DUMMY - }); + return ValidateSpellInfo({SPELL_DK_SHADOW_INFUSION, SPELL_DK_DARK_TRANSFORMATION_DUMMY}); } void HandleLaunch(SpellEffIndex /*effIndex*/) @@ -1125,7 +1070,7 @@ class spell_dk_dark_transformation_aura : public AuraScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo({ SPELL_DK_SHADOW_INFUSION }); + return ValidateSpellInfo({SPELL_DK_SHADOW_INFUSION}); } void HandlePeriodic(AuraEffect const* aurEff) @@ -1149,7 +1094,7 @@ class spell_dk_runic_empowerment : public AuraScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo({ SPELL_DK_RUNIC_CORRUPTION_TRIGGERED }); + return ValidateSpellInfo({SPELL_DK_RUNIC_CORRUPTION_TRIGGERED}); } void HandleProc(AuraEffect const* aurEff, ProcEventInfo& /*eventInfo*/) @@ -1189,7 +1134,7 @@ class spell_dk_runic_empowerment : public AuraScript OnEffectProc.Register(&spell_dk_runic_empowerment::HandleProc, EFFECT_0, SPELL_AURA_DUMMY); } -private: + private: // Sniffs do not show any spell cast to activate runes. We just copy the code part from Spell::EffectActivateRune in this case with some small tweaks void ActivateRune(Player* player, uint8 runeIndex) { @@ -1220,21 +1165,8 @@ class spell_dk_threat_of_thassarian : public AuraScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo( - { - SPELL_DK_OBLITERATE, - SPELL_DK_OBLITERATE_OFFHAND, - SPELL_DK_FROST_STRIKE, - SPELL_DK_FROST_STRIKE_OFFHAND, - SPELL_DK_PLAGUE_STRIKE, - SPELL_DK_PLAGUE_STRIKE_OFFHAND, - SPELL_DK_DEATH_STRIKE, - SPELL_DK_DEATH_STRIKE_OFFHAND, - SPELL_DK_RUNE_STRIKE, - SPELL_DK_RUNE_STRIKE_OFFHAND, - SPELL_DK_BLOOD_STRIKE, - SPELL_DK_BLOOD_STRIKE_OFFHAND - }); + return ValidateSpellInfo({SPELL_DK_OBLITERATE, SPELL_DK_OBLITERATE_OFFHAND, SPELL_DK_FROST_STRIKE, SPELL_DK_FROST_STRIKE_OFFHAND, SPELL_DK_PLAGUE_STRIKE, SPELL_DK_PLAGUE_STRIKE_OFFHAND, + SPELL_DK_DEATH_STRIKE, SPELL_DK_DEATH_STRIKE_OFFHAND, SPELL_DK_RUNE_STRIKE, SPELL_DK_RUNE_STRIKE_OFFHAND, SPELL_DK_BLOOD_STRIKE, SPELL_DK_BLOOD_STRIKE_OFFHAND}); } void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo) @@ -1252,26 +1184,26 @@ class spell_dk_threat_of_thassarian : public AuraScript uint32 offhandSpellId = 0; switch (spell->Id) { - case SPELL_DK_OBLITERATE: - offhandSpellId = SPELL_DK_OBLITERATE_OFFHAND; - break; - case SPELL_DK_FROST_STRIKE: - offhandSpellId = SPELL_DK_FROST_STRIKE_OFFHAND; - break; - case SPELL_DK_PLAGUE_STRIKE: - offhandSpellId = SPELL_DK_PLAGUE_STRIKE_OFFHAND; - break; - case SPELL_DK_DEATH_STRIKE: - offhandSpellId = SPELL_DK_DEATH_STRIKE_OFFHAND; - break; - case SPELL_DK_RUNE_STRIKE: - offhandSpellId = SPELL_DK_RUNE_STRIKE_OFFHAND; - break; - case SPELL_DK_BLOOD_STRIKE: - offhandSpellId = SPELL_DK_BLOOD_STRIKE_OFFHAND; - break; - default: - break; + case SPELL_DK_OBLITERATE: + offhandSpellId = SPELL_DK_OBLITERATE_OFFHAND; + break; + case SPELL_DK_FROST_STRIKE: + offhandSpellId = SPELL_DK_FROST_STRIKE_OFFHAND; + break; + case SPELL_DK_PLAGUE_STRIKE: + offhandSpellId = SPELL_DK_PLAGUE_STRIKE_OFFHAND; + break; + case SPELL_DK_DEATH_STRIKE: + offhandSpellId = SPELL_DK_DEATH_STRIKE_OFFHAND; + break; + case SPELL_DK_RUNE_STRIKE: + offhandSpellId = SPELL_DK_RUNE_STRIKE_OFFHAND; + break; + case SPELL_DK_BLOOD_STRIKE: + offhandSpellId = SPELL_DK_BLOOD_STRIKE_OFFHAND; + break; + default: + break; } if (offhandSpellId && eventInfo.GetProcTarget()) @@ -1295,11 +1227,7 @@ class spell_dk_reaping : public AuraScript bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo( - { - SPELL_DK_ITEM_T11_DPS_4P_BONUS, - SPELL_DK_DEATH_EATER - }); + return ValidateSpellInfo({SPELL_DK_ITEM_T11_DPS_4P_BONUS, SPELL_DK_DEATH_EATER}); } void HandleProc(AuraEffect const* aurEff, ProcEventInfo& /*eventInfo*/) @@ -1359,7 +1287,7 @@ class spell_dk_crimson_scourge : public AuraScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo({ SPELL_DK_BLOOD_PLAGUE }); + return ValidateSpellInfo({SPELL_DK_BLOOD_PLAGUE}); } bool CheckProc(ProcEventInfo& eventInfo) @@ -1379,7 +1307,7 @@ class spell_dk_crimson_scourge : public AuraScript class spell_dk_army_of_the_dead : public AuraScript { - void CalculateAmount(AuraEffect const* /*aurEff*/, int32 & amount, bool & /*canBeRecalculated*/) + void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/) { amount = 0; if (Player* player = GetUnitOwner()->ToPlayer()) @@ -1401,7 +1329,7 @@ class spell_dk_unholy_command : public AuraScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo({ SPELL_DK_DEATH_GRIP_INITIAL }); + return ValidateSpellInfo({SPELL_DK_DEATH_GRIP_INITIAL}); } void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& /*eventInfo*/) @@ -1421,15 +1349,10 @@ class spell_dk_disease : public AuraScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo( - { - SPELL_DK_RESILIENT_INFECTION, - SPELL_DK_BLOOD_PLAGUE, - SPELL_DK_FROST_FEVER - }); + return ValidateSpellInfo({SPELL_DK_RESILIENT_INFECTION, SPELL_DK_BLOOD_PLAGUE, SPELL_DK_FROST_FEVER}); } - void CalculateAmount(AuraEffect const* /*aurEff*/, int32 &amount, bool & /*canBeRecalculated*/) + void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/) { Unit* caster = GetCaster(); Unit* target = GetUnitOwner(); @@ -1550,7 +1473,7 @@ class spell_dk_ebon_plaguebringer : public AuraScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo({ SPELL_DK_EBON_PLAGUE }); + return ValidateSpellInfo({SPELL_DK_EBON_PLAGUE}); } void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo) @@ -1594,7 +1517,7 @@ class spell_dk_unoly_blight : public AuraScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo({ SPELL_DK_UNHOLY_BLIGHT_PERIODIC }); + return ValidateSpellInfo({SPELL_DK_UNHOLY_BLIGHT_PERIODIC}); } void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo) @@ -1615,11 +1538,7 @@ class spell_dk_festering_strike : public SpellScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo( - { - SPELL_DK_FROST_FEVER, - SPELL_DK_BLOOD_PLAGUE - }); + return ValidateSpellInfo({SPELL_DK_FROST_FEVER, SPELL_DK_BLOOD_PLAGUE}); } void HandleScriptEffect(SpellEffIndex effIndex) @@ -1631,8 +1550,7 @@ class spell_dk_festering_strike : public SpellScript uint32 durationBonus = GetSpellInfo()->Effects[effIndex].CalcValue(caster) * IN_MILLISECONDS; for (AuraEffect* disease : GetHitUnit()->GetAuraEffectsByType(SPELL_AURA_PERIODIC_DAMAGE)) { - if ((disease->GetSpellInfo()->Id == SPELL_DK_FROST_FEVER || disease->GetSpellInfo()->Id == SPELL_DK_BLOOD_PLAGUE) - && disease->GetCasterGUID() == caster->GetGUID()) + if ((disease->GetSpellInfo()->Id == SPELL_DK_FROST_FEVER || disease->GetSpellInfo()->Id == SPELL_DK_BLOOD_PLAGUE) && disease->GetCasterGUID() == caster->GetGUID()) { uint32 maxDuration = disease->GetBase()->GetMaxDuration(); disease->GetBase()->SetDuration(std::min(maxDuration, disease->GetBase()->GetDuration() + durationBonus)); @@ -1642,7 +1560,7 @@ class spell_dk_festering_strike : public SpellScript for (AuraEffect* snare : GetHitUnit()->GetAuraEffectsByType(SPELL_AURA_MOD_DECREASE_SPEED)) { SpellInfo const* spellInfo = snare->GetSpellInfo(); - if (spellInfo->SpellFamilyName == SPELLFAMILY_DEATHKNIGHT && spellInfo->SpellFamilyFlags[0] == 0x00000004 && snare->GetCasterGUID() == caster->GetGUID()) + if (spellInfo->SpellFamilyName == SPELLFAMILY_DEATHKNIGHT && spellInfo->SpellFamilyFlags[0] == 0x00000004 && snare->GetCasterGUID() == caster->GetGUID()) { uint32 maxDuration = snare->GetBase()->GetMaxDuration(); snare->GetBase()->SetDuration(std::min(maxDuration, snare->GetBase()->GetDuration() + durationBonus)); @@ -1661,11 +1579,7 @@ class spell_dk_killing_machine : public SpellScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo( - { - SPELL_DK_ITEM_T11_DPS_4P_BONUS, - SPELL_DK_DEATH_EATER - }); + return ValidateSpellInfo({SPELL_DK_ITEM_T11_DPS_4P_BONUS, SPELL_DK_DEATH_EATER}); } void HandleT11Bonus(SpellEffIndex /*effIndex*/) @@ -1686,7 +1600,7 @@ class spell_dk_item_death_knight_t12_dps_4p_bonus : public AuraScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo({ SPELL_DK_FLAMING_TORRENT }); + return ValidateSpellInfo({SPELL_DK_FLAMING_TORRENT}); } bool CheckProc(ProcEventInfo& eventInfo) @@ -1713,7 +1627,7 @@ class spell_dk_smoldering_rune : public AuraScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo({ SPELL_DK_SMOLDERING_RUNE_ENERGIZE }); + return ValidateSpellInfo({SPELL_DK_SMOLDERING_RUNE_ENERGIZE}); } void HandleDummyTick(AuraEffect const* aurEff) @@ -1732,12 +1646,7 @@ class spell_dk_dancing_rune_weapon : public AuraScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo( - { - SPELL_DK_ITEM_T12_BLOOD_4P_BONUS, - SPELL_DK_FLAMING_RUNE_WEAPON, - SPELL_DK_DANCING_RUNE_WEAPON_PARRY_BONUS - }); + return ValidateSpellInfo({SPELL_DK_ITEM_T12_BLOOD_4P_BONUS, SPELL_DK_FLAMING_RUNE_WEAPON, SPELL_DK_DANCING_RUNE_WEAPON_PARRY_BONUS}); } void HandleApply(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) diff --git a/src/server/scripts/Spells/spell_druid.cpp b/src/server/scripts/Spells/spell_druid.cpp index c6fdaa49..e7ab7a31 100644 --- a/src/server/scripts/Spells/spell_druid.cpp +++ b/src/server/scripts/Spells/spell_druid.cpp @@ -21,123 +21,123 @@ * Scriptnames of files in this file should be prefixed with "spell_dru_". */ -#include "ScriptMgr.h" #include "Containers.h" +#include "Creature.h" +#include "DynamicObject.h" #include "Player.h" +#include "ScriptMgr.h" #include "Spell.h" #include "SpellAuraEffects.h" #include "SpellHistory.h" #include "SpellMgr.h" #include "SpellScript.h" -#include "DynamicObject.h" -#include "Creature.h" #include "TemporarySummon.h" enum DruidSpells { - SPELL_DRUID_ASTRAL_ALIGNMENT = 90164, - SPELL_DRUID_BLOOD_IN_THE_WATER_SCRIPT = 80863, - SPELL_DRUID_BLOOM = 90159, - SPELL_DRUID_BRUTAL_IMPACT_R1 = 16940, - SPELL_DRUID_WRATH = 5176, - SPELL_DRUID_STARFIRE = 2912, - SPELL_DRUID_STARSURGE = 78674, - SPELL_DRUID_ECLIPSE_GENERAL_ENERGIZE = 89265, - SPELL_DRUID_STARSURGE_ENERGIZE = 86605, - SPELL_DRUID_LUNAR_ECLIPSE_MARKER = 67484, // Will make the yellow arrow on eclipse bar point to the blue side (lunar) - SPELL_DRUID_SOLAR_ECLIPSE_MARKER = 67483, // Will make the yellow arrow on eclipse bar point to the yellow side (solar) - SPELL_DRUID_SOLAR_ECLIPSE = 48517, - SPELL_DRUID_LUNAR_ECLIPSE = 48518, - SPELL_DRUID_SOLAR_ECLIPSE_SUNFIRE = 94338, - SPELL_DRUID_HARMONY = 100977, - SPELL_DRUID_EFFLORESCENCE_AOE = 81262, - SPELL_DRUID_EFFLORESCENCE_HEAL = 81269, - SPELL_DRUID_ENRAGE_MOD_DAMAGE = 51185, - SPELL_DRUID_ENRAGED_DEFENSE = 70725, - SPELL_DRUID_EUPHORIA = 81061, - SPELL_DRUID_EUPHORIA_MANA_ENERGIZE = 81070, - SPELL_DRUID_EUPHORIA_ENERGIZE = 81069, - SPELL_DRUID_FERAL_CHARGE_BEAR = 16979, - SPELL_DRUID_FERAL_CHARGE_CAT = 49376, - SPELL_DRUID_FERAL_SWIFTNESS = 17002, - SPELL_DRUID_FERAL_SWIFTNESS_CLEAR_ROAR = 97993, - SPELL_DRUID_FERAL_SWIFTNESS_CLEAR_CAT = 97985, - SPELL_DRUID_FUNGAL_GROWTH_R1 = 78788, - SPELL_DRUID_FUNGAL_GROWTH_R2 = 78789, - SPELL_DRUID_FUNGAL_GROWTH_SUMMON_R1 = 81291, - SPELL_DRUID_FUNGAL_GROWTH_SUMMON_R2 = 81283, - SPELL_DRUID_FRENZIED_REGENERATION_HEAL = 22845, - SPELL_DRUID_EMPOWERED_TOUCH_SCRIPT = 88433, - SPELL_DRUID_FURY_OF_STORMRAGE = 81093, - SPELL_DRUID_GLYPH_OF_INNERVATE = 54833, - SPELL_DRUID_GLYPH_OF_STARFIRE = 54846, - SPELL_DRUID_GLYPH_OF_TYPHOON = 62135, - SPELL_DRUID_GLYPH_OF_FEROCIOUS_BITE = 101024, - SPELL_DRUID_IDOL_OF_FERAL_SHADOWS = 34241, - SPELL_DRUID_IDOL_OF_WORSHIP = 60774, + SPELL_DRUID_ASTRAL_ALIGNMENT = 90164, + SPELL_DRUID_BLOOD_IN_THE_WATER_SCRIPT = 80863, + SPELL_DRUID_BLOOM = 90159, + SPELL_DRUID_BRUTAL_IMPACT_R1 = 16940, + SPELL_DRUID_WRATH = 5176, + SPELL_DRUID_STARFIRE = 2912, + SPELL_DRUID_STARSURGE = 78674, + SPELL_DRUID_ECLIPSE_GENERAL_ENERGIZE = 89265, + SPELL_DRUID_STARSURGE_ENERGIZE = 86605, + SPELL_DRUID_LUNAR_ECLIPSE_MARKER = 67484, // Will make the yellow arrow on eclipse bar point to the blue side (lunar) + SPELL_DRUID_SOLAR_ECLIPSE_MARKER = 67483, // Will make the yellow arrow on eclipse bar point to the yellow side (solar) + SPELL_DRUID_SOLAR_ECLIPSE = 48517, + SPELL_DRUID_LUNAR_ECLIPSE = 48518, + SPELL_DRUID_SOLAR_ECLIPSE_SUNFIRE = 94338, + SPELL_DRUID_HARMONY = 100977, + SPELL_DRUID_EFFLORESCENCE_AOE = 81262, + SPELL_DRUID_EFFLORESCENCE_HEAL = 81269, + SPELL_DRUID_ENRAGE_MOD_DAMAGE = 51185, + SPELL_DRUID_ENRAGED_DEFENSE = 70725, + SPELL_DRUID_EUPHORIA = 81061, + SPELL_DRUID_EUPHORIA_MANA_ENERGIZE = 81070, + SPELL_DRUID_EUPHORIA_ENERGIZE = 81069, + SPELL_DRUID_FERAL_CHARGE_BEAR = 16979, + SPELL_DRUID_FERAL_CHARGE_CAT = 49376, + SPELL_DRUID_FERAL_SWIFTNESS = 17002, + SPELL_DRUID_FERAL_SWIFTNESS_CLEAR_ROAR = 97993, + SPELL_DRUID_FERAL_SWIFTNESS_CLEAR_CAT = 97985, + SPELL_DRUID_FUNGAL_GROWTH_R1 = 78788, + SPELL_DRUID_FUNGAL_GROWTH_R2 = 78789, + SPELL_DRUID_FUNGAL_GROWTH_SUMMON_R1 = 81291, + SPELL_DRUID_FUNGAL_GROWTH_SUMMON_R2 = 81283, + SPELL_DRUID_FRENZIED_REGENERATION_HEAL = 22845, + SPELL_DRUID_EMPOWERED_TOUCH_SCRIPT = 88433, + SPELL_DRUID_FURY_OF_STORMRAGE = 81093, + SPELL_DRUID_GLYPH_OF_INNERVATE = 54833, + SPELL_DRUID_GLYPH_OF_STARFIRE = 54846, + SPELL_DRUID_GLYPH_OF_TYPHOON = 62135, + SPELL_DRUID_GLYPH_OF_FEROCIOUS_BITE = 101024, + SPELL_DRUID_IDOL_OF_FERAL_SHADOWS = 34241, + SPELL_DRUID_IDOL_OF_WORSHIP = 60774, SPELL_DRUID_INCREASED_MOONFIRE_DURATION = 38414, - SPELL_DRUID_INNERVATE_TRIGGERED = 54833, - SPELL_DRUID_ITEM_T8_BALANCE_RELIC = 64950, - SPELL_DRUID_ITEM_T10_FERAL_4P_BONUS = 70726, - SPELL_DRUID_ITEM_T11_BALANCE_4P_BONUS = 90163, - SPELL_DRUID_KING_OF_THE_JUNGLE = 48492, - SPELL_DRUID_LACERATE = 33745, - SPELL_DRUID_LEADER_OF_THE_PACK_HEAL = 34299, + SPELL_DRUID_INNERVATE_TRIGGERED = 54833, + SPELL_DRUID_ITEM_T8_BALANCE_RELIC = 64950, + SPELL_DRUID_ITEM_T10_FERAL_4P_BONUS = 70726, + SPELL_DRUID_ITEM_T11_BALANCE_4P_BONUS = 90163, + SPELL_DRUID_KING_OF_THE_JUNGLE = 48492, + SPELL_DRUID_LACERATE = 33745, + SPELL_DRUID_LEADER_OF_THE_PACK_HEAL = 34299, SPELL_DRUID_LEADER_OF_THE_PACK_ENERGIZE = 68285, - SPELL_DRUID_LIFEBLOOM = 33763, - SPELL_DRUID_LIFEBLOOM_ENERGIZE = 64372, - SPELL_DRUID_LIFEBLOOM_FINAL_HEAL = 33778, - SPELL_DRUID_LIVING_SEED_HEAL = 48503, - SPELL_DRUID_LIVING_SEED_PROC = 48504, - SPELL_DRUID_LUNAR_SHOWER = 33603, - SPELL_DRUID_MOONFIRE = 8921, - SPELL_DRUID_NATURES_BOUNTY = 96206, - SPELL_DRUID_NATURES_GRACE = 16880, - SPELL_DRUID_PULVERIZE_TRIGGERED = 80951, - SPELL_DRUID_RIP = 1079, - SPELL_DRUID_SURVIVAL_INSTINCTS = 50322, - SPELL_DRUID_SAVAGE_ROAR = 62071, - SPELL_DRUID_SKULL_BASH_CHARGE = 93983, - SPELL_DRUID_SKULL_BASH_INTERRUPT = 93985, + SPELL_DRUID_LIFEBLOOM = 33763, + SPELL_DRUID_LIFEBLOOM_ENERGIZE = 64372, + SPELL_DRUID_LIFEBLOOM_FINAL_HEAL = 33778, + SPELL_DRUID_LIVING_SEED_HEAL = 48503, + SPELL_DRUID_LIVING_SEED_PROC = 48504, + SPELL_DRUID_LUNAR_SHOWER = 33603, + SPELL_DRUID_MOONFIRE = 8921, + SPELL_DRUID_NATURES_BOUNTY = 96206, + SPELL_DRUID_NATURES_GRACE = 16880, + SPELL_DRUID_PULVERIZE_TRIGGERED = 80951, + SPELL_DRUID_RIP = 1079, + SPELL_DRUID_SURVIVAL_INSTINCTS = 50322, + SPELL_DRUID_SAVAGE_ROAR = 62071, + SPELL_DRUID_SKULL_BASH_CHARGE = 93983, + SPELL_DRUID_SKULL_BASH_INTERRUPT = 93985, SPELL_DRUID_SKULL_BASH_COST_INCREASE_R1 = 82364, SPELL_DRUID_SKULL_BASH_COST_INCREASE_R2 = 82365, - SPELL_DRUID_STAMPEDE_BAER_RANK_1 = 81016, - SPELL_DRUID_STAMPEDE_CAT_RANK_1 = 81021, - SPELL_DRUID_STAMPEDE_CAT_STATE = 109881, - SPELL_DRUID_SOLAR_BEAM_SILENCE = 81261, - SPELL_DRUID_STRENGTH_OF_THE_PANTHER = 90166, - SPELL_DRUID_SUNFIRE = 93402, - SPELL_DRUID_REJUVENATION_DIRECT_HEAL = 64801, - SPELL_DRUID_TIGER_S_FURY_ENERGIZE = 51178, - SPELL_DRUID_TREE_OF_LIFE = 33891, - SPELL_DRUID_TREE_OF_LIFE_PASSIVE_1 = 5420, - SPELL_DRUID_TREE_OF_LIFE_PASSIVE_2 = 81097, - SPELL_DRUID_TREE_OF_LIFE_PASSIVE_3 = 81098, - SPELL_DRUID_T13_FERAL_2P_BONUS = 105725, - SPELL_DRUID_WILD_MUSHROOM = 88747, - SPELL_DRUID_WILD_MUSHROOM_DAMAGE = 78777, - SPELL_DRUID_WILD_MUSHROOM_SUICIDE = 92853, - SPELL_DRUID_WILD_MUSHROOM_VISUAL = 92701, - SPELL_DRUID_FIREBLOOM = 99017 + SPELL_DRUID_STAMPEDE_BAER_RANK_1 = 81016, + SPELL_DRUID_STAMPEDE_CAT_RANK_1 = 81021, + SPELL_DRUID_STAMPEDE_CAT_STATE = 109881, + SPELL_DRUID_SOLAR_BEAM_SILENCE = 81261, + SPELL_DRUID_STRENGTH_OF_THE_PANTHER = 90166, + SPELL_DRUID_SUNFIRE = 93402, + SPELL_DRUID_REJUVENATION_DIRECT_HEAL = 64801, + SPELL_DRUID_TIGER_S_FURY_ENERGIZE = 51178, + SPELL_DRUID_TREE_OF_LIFE = 33891, + SPELL_DRUID_TREE_OF_LIFE_PASSIVE_1 = 5420, + SPELL_DRUID_TREE_OF_LIFE_PASSIVE_2 = 81097, + SPELL_DRUID_TREE_OF_LIFE_PASSIVE_3 = 81098, + SPELL_DRUID_T13_FERAL_2P_BONUS = 105725, + SPELL_DRUID_WILD_MUSHROOM = 88747, + SPELL_DRUID_WILD_MUSHROOM_DAMAGE = 78777, + SPELL_DRUID_WILD_MUSHROOM_SUICIDE = 92853, + SPELL_DRUID_WILD_MUSHROOM_VISUAL = 92701, + SPELL_DRUID_FIREBLOOM = 99017 }; enum DruidSpellIconIds { - SPELL_ICON_ID_NATURES_BOUNTY = 197, - SPELL_ICON_ID_DREAMSTATE = 2255, - SPELL_ICON_ID_GLYPH_OF_INNERVATE = 62, - SPELL_ICON_ID_EUPHORIA = 4431, - SPELL_ICON_ID_SAVAGE_DEFENDER = 146, - SPELL_ICON_ID_SUNFIRE = 3262, - SPELL_ICON_ID_GLYPH_OF_FEROCIOUS_BITE = 1680, - SPELL_ICON_ID_GLYPH_OF_FRENZIED_REGENERATION = 50, - SPELL_ICON_ID_GIFT_OF_THE_EARTHMOTHER = 3186 + SPELL_ICON_ID_NATURES_BOUNTY = 197, + SPELL_ICON_ID_DREAMSTATE = 2255, + SPELL_ICON_ID_GLYPH_OF_INNERVATE = 62, + SPELL_ICON_ID_EUPHORIA = 4431, + SPELL_ICON_ID_SAVAGE_DEFENDER = 146, + SPELL_ICON_ID_SUNFIRE = 3262, + SPELL_ICON_ID_GLYPH_OF_FEROCIOUS_BITE = 1680, + SPELL_ICON_ID_GLYPH_OF_FRENZIED_REGENERATION = 50, + SPELL_ICON_ID_GIFT_OF_THE_EARTHMOTHER = 3186 }; enum MiscSpells { - SPELL_CATEGORY_MANGLE_BEAR = 971, - SPELL_RACIAL_SHADOWMELD = 58984 + SPELL_CATEGORY_MANGLE_BEAR = 971, + SPELL_RACIAL_SHADOWMELD = 58984 }; // 50334 - Berserk @@ -146,11 +146,13 @@ class spell_dru_berserk : public AuraScript void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { // Remove cooldown on Mangle (bear) - GetTarget()->GetSpellHistory()->ResetCooldowns([](SpellHistory::CooldownStorageType::iterator itr) -> bool - { - SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(itr->first); - return spellInfo && spellInfo->GetCategory() == SPELL_CATEGORY_MANGLE_BEAR; - }, true); + GetTarget()->GetSpellHistory()->ResetCooldowns( + [](SpellHistory::CooldownStorageType::iterator itr) -> bool + { + SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(itr->first); + return spellInfo && spellInfo->GetCategory() == SPELL_CATEGORY_MANGLE_BEAR; + }, + true); } void Register() override @@ -164,11 +166,7 @@ class spell_dru_dash : public SpellScript { bool Validate(SpellInfo const* /*spell*/) override { - return ValidateSpellInfo( - { - SPELL_DRUID_FERAL_SWIFTNESS, - SPELL_DRUID_FERAL_SWIFTNESS_CLEAR_CAT - }); + return ValidateSpellInfo({SPELL_DRUID_FERAL_SWIFTNESS, SPELL_DRUID_FERAL_SWIFTNESS_CLEAR_CAT}); } void HandleFeralSwiftness(SpellEffIndex /*effIndex*/) @@ -205,12 +203,7 @@ class spell_dru_eclipse : public AuraScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo( - { - SPELL_DRUID_SOLAR_ECLIPSE, - SPELL_DRUID_SUNFIRE, - SPELL_DRUID_SOLAR_ECLIPSE_SUNFIRE - }); + return ValidateSpellInfo({SPELL_DRUID_SOLAR_ECLIPSE, SPELL_DRUID_SUNFIRE, SPELL_DRUID_SOLAR_ECLIPSE_SUNFIRE}); } void ApplyEffect(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) @@ -242,19 +235,8 @@ class spell_dru_eclipse_mastery_driver_passive : public AuraScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo( - { - SPELL_DRUID_LUNAR_ECLIPSE, - SPELL_DRUID_LUNAR_ECLIPSE_MARKER, - SPELL_DRUID_SOLAR_ECLIPSE, - SPELL_DRUID_SOLAR_ECLIPSE_MARKER, - SPELL_DRUID_EUPHORIA_ENERGIZE, - SPELL_DRUID_EUPHORIA_MANA_ENERGIZE, - SPELL_DRUID_STARSURGE_ENERGIZE, - SPELL_DRUID_ECLIPSE_GENERAL_ENERGIZE, - SPELL_DRUID_NATURES_GRACE, - SPELL_DRUID_ITEM_T11_BALANCE_4P_BONUS - }); + return ValidateSpellInfo({SPELL_DRUID_LUNAR_ECLIPSE, SPELL_DRUID_LUNAR_ECLIPSE_MARKER, SPELL_DRUID_SOLAR_ECLIPSE, SPELL_DRUID_SOLAR_ECLIPSE_MARKER, SPELL_DRUID_EUPHORIA_ENERGIZE, + SPELL_DRUID_EUPHORIA_MANA_ENERGIZE, SPELL_DRUID_STARSURGE_ENERGIZE, SPELL_DRUID_ECLIPSE_GENERAL_ENERGIZE, SPELL_DRUID_NATURES_GRACE, SPELL_DRUID_ITEM_T11_BALANCE_4P_BONUS}); } bool CheckProc(ProcEventInfo& eventInfo) @@ -319,8 +301,7 @@ class spell_dru_eclipse_mastery_driver_passive : public AuraScript newMarkerSpellId = SPELL_DRUID_LUNAR_ECLIPSE_MARKER; } - if ((eclipse->GetId() == SPELL_DRUID_LUNAR_ECLIPSE && target->GetPower(POWER_ECLIPSE) >= 0) || - ((eclipse->GetId() == SPELL_DRUID_SOLAR_ECLIPSE && target->GetPower(POWER_ECLIPSE) <= 0))) + if ((eclipse->GetId() == SPELL_DRUID_LUNAR_ECLIPSE && target->GetPower(POWER_ECLIPSE) >= 0) || ((eclipse->GetId() == SPELL_DRUID_SOLAR_ECLIPSE && target->GetPower(POWER_ECLIPSE) <= 0))) if (Aura* aura = eclipse->GetBase()) aura->Remove(); } @@ -356,7 +337,8 @@ class spell_dru_eclipse_mastery_driver_passive : public AuraScript AfterEffectProc.Register(&spell_dru_eclipse_mastery_driver_passive::HandleEclipseProc, EFFECT_0, SPELL_AURA_PROC_ON_POWER_AMOUNT); AfterEffectProc.Register(&spell_dru_eclipse_mastery_driver_passive::HandleEclipseProc, EFFECT_1, SPELL_AURA_PROC_ON_POWER_AMOUNT); } -private: + + private: int32 GetEnergyGainFromSpellInfo(SpellInfo const* spell) { Unit* target = GetTarget(); @@ -415,13 +397,7 @@ class spell_dru_enrage : public AuraScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo( - { - SPELL_DRUID_KING_OF_THE_JUNGLE, - SPELL_DRUID_ENRAGE_MOD_DAMAGE, - SPELL_DRUID_ENRAGED_DEFENSE, - SPELL_DRUID_ITEM_T10_FERAL_4P_BONUS - }); + return ValidateSpellInfo({SPELL_DRUID_KING_OF_THE_JUNGLE, SPELL_DRUID_ENRAGE_MOD_DAMAGE, SPELL_DRUID_ENRAGED_DEFENSE, SPELL_DRUID_ITEM_T10_FERAL_4P_BONUS}); } void RecalculateBaseArmor() @@ -472,7 +448,7 @@ class spell_dru_glyph_of_starfire : public SpellScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo({ SPELL_DRUID_INCREASED_MOONFIRE_DURATION }); + return ValidateSpellInfo({SPELL_DRUID_INCREASED_MOONFIRE_DURATION}); } void HandleScriptEffect(SpellEffIndex /*effIndex*/) @@ -509,7 +485,7 @@ class spell_dru_glyph_of_starfire_proc : public AuraScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo({ SPELL_DRUID_GLYPH_OF_STARFIRE }); + return ValidateSpellInfo({SPELL_DRUID_GLYPH_OF_STARFIRE}); } bool CheckProc(ProcEventInfo& eventInfo) @@ -536,7 +512,8 @@ class spell_dru_glyph_of_starfire_proc : public AuraScript DoCheckProc.Register(&spell_dru_glyph_of_starfire_proc::CheckProc); OnEffectProc.Register(&spell_dru_glyph_of_starfire_proc::HandleEffectProc, EFFECT_0, SPELL_AURA_DUMMY); } -private: + + private: ObjectGuid _lastMoonFireTargetGuid; }; @@ -610,7 +587,7 @@ class spell_dru_innervate : public AuraScript // 5570 - Insect Swarm class spell_dru_insect_swarm : public AuraScript { - void CalculateAmount(AuraEffect const* aurEff, int32 & amount, bool & /*canBeRecalculated*/) + void CalculateAmount(AuraEffect const* aurEff, int32& amount, bool& /*canBeRecalculated*/) { if (Unit* caster = GetCaster()) if (AuraEffect const* relicAurEff = caster->GetAuraEffect(SPELL_DRUID_ITEM_T8_BALANCE_RELIC, EFFECT_0)) @@ -629,11 +606,7 @@ class spell_dru_lifebloom : public AuraScript { bool Validate(SpellInfo const* /*spell*/) override { - return ValidateSpellInfo( - { - SPELL_DRUID_LIFEBLOOM_FINAL_HEAL, - SPELL_DRUID_LIFEBLOOM_ENERGIZE - }); + return ValidateSpellInfo({SPELL_DRUID_LIFEBLOOM_FINAL_HEAL, SPELL_DRUID_LIFEBLOOM_ENERGIZE}); } void AfterRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) @@ -698,7 +671,7 @@ class spell_dru_living_seed : public AuraScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo({ SPELL_DRUID_LIVING_SEED_PROC }); + return ValidateSpellInfo({SPELL_DRUID_LIVING_SEED_PROC}); } void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo) @@ -720,7 +693,7 @@ class spell_dru_living_seed_proc : public AuraScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo({ SPELL_DRUID_LIVING_SEED_HEAL }); + return ValidateSpellInfo({SPELL_DRUID_LIVING_SEED_HEAL}); } void HandleProc(AuraEffect const* aurEff, ProcEventInfo& /*eventInfo*/) @@ -818,13 +791,13 @@ class spell_dru_savage_roar_AuraScript : public AuraScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo({ SPELL_DRUID_SAVAGE_ROAR }); + return ValidateSpellInfo({SPELL_DRUID_SAVAGE_ROAR}); } void AfterApply(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) { Unit* target = GetTarget(); - target->CastSpell(target, SPELL_DRUID_SAVAGE_ROAR, { aurEff, GetCasterGUID() }); + target->CastSpell(target, SPELL_DRUID_SAVAGE_ROAR, {aurEff, GetCasterGUID()}); } void AfterRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) @@ -877,14 +850,7 @@ class spell_dru_stampede : public AuraScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo( - { - SPELL_DRUID_STAMPEDE_BAER_RANK_1, - SPELL_DRUID_STAMPEDE_CAT_RANK_1, - SPELL_DRUID_STAMPEDE_CAT_STATE, - SPELL_DRUID_FERAL_CHARGE_CAT, - SPELL_DRUID_FERAL_CHARGE_BEAR - }); + return ValidateSpellInfo({SPELL_DRUID_STAMPEDE_BAER_RANK_1, SPELL_DRUID_STAMPEDE_CAT_RANK_1, SPELL_DRUID_STAMPEDE_CAT_STATE, SPELL_DRUID_FERAL_CHARGE_CAT, SPELL_DRUID_FERAL_CHARGE_BEAR}); } void HandleEffectCatProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo) @@ -935,7 +901,7 @@ class spell_dru_survival_instincts_AuraScript : public AuraScript { bool Validate(SpellInfo const* /*spell*/) override { - return ValidateSpellInfo({ SPELL_DRUID_SURVIVAL_INSTINCTS }); + return ValidateSpellInfo({SPELL_DRUID_SURVIVAL_INSTINCTS}); } void AfterApply(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) @@ -963,7 +929,7 @@ class spell_dru_swift_flight_passive : public AuraScript return GetCaster()->GetTypeId() == TYPEID_PLAYER; } - void CalculateAmount(AuraEffect const* /*aurEff*/, int32 & amount, bool & /*canBeRecalculated*/) + void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/) { if (Player* caster = GetCaster()->ToPlayer()) if (caster->GetSkillValue(SKILL_RIDING) >= 375) @@ -1095,19 +1061,21 @@ class spell_dru_t10_restoration_4p_bonus : public SpellScript class RaidCheck { - public: - explicit RaidCheck(Unit const* caster) : _caster(caster) { } + public: + explicit RaidCheck(Unit const* caster) : _caster(caster) + { + } - bool operator()(WorldObject* obj) const - { - if (Unit* target = obj->ToUnit()) - return !_caster->IsInRaidWith(target); + bool operator()(WorldObject* obj) const + { + if (Unit* target = obj->ToUnit()) + return !_caster->IsInRaidWith(target); - return true; - } + return true; + } - private: - Unit const* _caster; + private: + Unit const* _caster; }; // 48438 - Wild Growth @@ -1115,7 +1083,7 @@ class spell_dru_wild_growth : public SpellScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo({ SPELL_DRUID_TREE_OF_LIFE }); + return ValidateSpellInfo({SPELL_DRUID_TREE_OF_LIFE}); } void FilterTargets(std::list& targets) @@ -1148,7 +1116,7 @@ class spell_dru_wild_growth : public SpellScript OnObjectAreaTargetSelect.Register(&spell_dru_wild_growth::SetTargets, EFFECT_1, TARGET_UNIT_DEST_AREA_ALLY); } -private: + private: std::list _targets; }; @@ -1157,13 +1125,13 @@ class spell_dru_solar_beam : public AuraScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo({ SPELL_DRUID_SOLAR_BEAM_SILENCE }); + return ValidateSpellInfo({SPELL_DRUID_SOLAR_BEAM_SILENCE}); } void HandleEffectPeriodic(AuraEffect const* aurEff) { if (DynamicObject* dyn = GetTarget()->GetDynObject(aurEff->GetId())) - GetTarget()->CastSpell({ dyn->GetPositionX(), dyn->GetPositionY(), dyn->GetPositionZ() }, SPELL_DRUID_SOLAR_BEAM_SILENCE, true); + GetTarget()->CastSpell({dyn->GetPositionX(), dyn->GetPositionY(), dyn->GetPositionZ()}, SPELL_DRUID_SOLAR_BEAM_SILENCE, true); } void Register() override @@ -1198,14 +1166,14 @@ class spell_dru_effloresence_aoe : public AuraScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo({ SPELL_DRUID_EFFLORESCENCE_HEAL }); + return ValidateSpellInfo({SPELL_DRUID_EFFLORESCENCE_HEAL}); } void HandleEffectPeriodic(AuraEffect const* aurEff) { if (Unit* caster = GetCaster()) if (DynamicObject* dyn = caster->GetDynObject(aurEff->GetId())) - caster->CastSpell({ dyn->GetPositionX(), dyn->GetPositionY(), dyn->GetPositionZ() }, SPELL_DRUID_EFFLORESCENCE_HEAL, { aurEff, caster->GetGUID() }); + caster->CastSpell({dyn->GetPositionX(), dyn->GetPositionY(), dyn->GetPositionZ()}, SPELL_DRUID_EFFLORESCENCE_HEAL, {aurEff, caster->GetGUID()}); } void Register() override @@ -1219,7 +1187,7 @@ class spell_dru_effloresence_heal : public SpellScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo({ SPELL_DRUID_EFFLORESCENCE_AOE }); + return ValidateSpellInfo({SPELL_DRUID_EFFLORESCENCE_AOE}); } void FilterTargets(std::list& targets) @@ -1252,28 +1220,7 @@ class spell_dru_rejuvenation : public AuraScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo( - { - SPELL_DRUID_NATURES_BOUNTY, - SPELL_DRUID_REJUVENATION_DIRECT_HEAL - }); - } - - void AfterApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - if (Unit* caster = GetCaster()) - { - if (AuraEffect* naturesBountyAurEff = caster->GetAuraEffect(SPELL_AURA_ADD_FLAT_MODIFIER, SPELLFAMILY_DRUID, SPELL_ICON_ID_NATURES_BOUNTY, EFFECT_0)) - { - // a bit cheaty here but as long as we don't have a unit internal aura count... - naturesBountyAurEff->SetBonusAmount(naturesBountyAurEff->GetBonusAmount() + 1); - if (naturesBountyAurEff->GetBonusAmount() >= 3) - { - int32 bp0 = -naturesBountyAurEff->GetSpellInfo()->Effects[EFFECT_1].BasePoints; - caster->CastSpell(caster, SPELL_DRUID_NATURES_BOUNTY, CastSpellExtraArgs(true).AddSpellBP0(bp0)); - } - } - } + return ValidateSpellInfo({SPELL_DRUID_NATURES_BOUNTY, SPELL_DRUID_REJUVENATION_DIRECT_HEAL}); } void HandleGiftOfTheEarthmother(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) @@ -1288,24 +1235,9 @@ class spell_dru_rejuvenation : public AuraScript } } - void AfterRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - if (Unit* caster = GetCaster()) - { - if (AuraEffect* naturesBountyAurEff = caster->GetAuraEffect(SPELL_AURA_ADD_FLAT_MODIFIER, SPELLFAMILY_DRUID, SPELL_ICON_ID_NATURES_BOUNTY, EFFECT_0)) - { - naturesBountyAurEff->SetBonusAmount(naturesBountyAurEff->GetBonusAmount() > 0 ? naturesBountyAurEff->GetBonusAmount() - 1 : 0); - if (naturesBountyAurEff->GetBonusAmount() < 3 && caster->HasAura(SPELL_DRUID_NATURES_BOUNTY)) - caster->RemoveAurasDueToSpell(SPELL_DRUID_NATURES_BOUNTY); - } - } - } - void Register() override { - AfterEffectApply.Register(&spell_dru_rejuvenation::AfterApply, EFFECT_0, SPELL_AURA_PERIODIC_HEAL, AURA_EFFECT_HANDLE_REAL); AfterEffectApply.Register(&spell_dru_rejuvenation::HandleGiftOfTheEarthmother, EFFECT_0, SPELL_AURA_PERIODIC_HEAL, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK); - AfterEffectRemove.Register(&spell_dru_rejuvenation::AfterRemove, EFFECT_0, SPELL_AURA_PERIODIC_HEAL, AURA_EFFECT_HANDLE_REAL); } }; @@ -1314,12 +1246,7 @@ class spell_dru_tree_of_life : public AuraScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo( - { - SPELL_DRUID_TREE_OF_LIFE_PASSIVE_1, - SPELL_DRUID_TREE_OF_LIFE_PASSIVE_2, - SPELL_DRUID_TREE_OF_LIFE_PASSIVE_3 - }); + return ValidateSpellInfo({SPELL_DRUID_TREE_OF_LIFE_PASSIVE_1, SPELL_DRUID_TREE_OF_LIFE_PASSIVE_2, SPELL_DRUID_TREE_OF_LIFE_PASSIVE_3}); } void AfterApply(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) @@ -1329,7 +1256,6 @@ class spell_dru_tree_of_life : public AuraScript target->CastSpell(target, SPELL_DRUID_TREE_OF_LIFE_PASSIVE_1, aurEff); target->CastSpell(target, SPELL_DRUID_TREE_OF_LIFE_PASSIVE_2, aurEff); target->CastSpell(target, SPELL_DRUID_TREE_OF_LIFE_PASSIVE_3, aurEff); - } } @@ -1355,7 +1281,7 @@ class spell_dru_harmony : public AuraScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo({ SPELL_DRUID_HARMONY }); + return ValidateSpellInfo({SPELL_DRUID_HARMONY}); } void HandleProc(AuraEffect const* aurEff, ProcEventInfo& /*eventInfo*/) @@ -1376,11 +1302,7 @@ class spell_dru_leader_of_the_pack : public AuraScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo( - { - SPELL_DRUID_LEADER_OF_THE_PACK_HEAL, - SPELL_DRUID_LEADER_OF_THE_PACK_ENERGIZE - }); + return ValidateSpellInfo({SPELL_DRUID_LEADER_OF_THE_PACK_HEAL, SPELL_DRUID_LEADER_OF_THE_PACK_ENERGIZE}); } bool CheckProc(ProcEventInfo& /*eventInfo*/) @@ -1463,17 +1385,8 @@ class spell_dru_wild_mushroom_detonate : public SpellScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo( - { - SPELL_DRUID_WILD_MUSHROOM, - SPELL_DRUID_WILD_MUSHROOM_DAMAGE, - SPELL_DRUID_WILD_MUSHROOM_SUICIDE, - SPELL_DRUID_WILD_MUSHROOM_VISUAL, - SPELL_DRUID_FUNGAL_GROWTH_R1, - SPELL_DRUID_FUNGAL_GROWTH_R2, - SPELL_DRUID_FUNGAL_GROWTH_SUMMON_R1, - SPELL_DRUID_FUNGAL_GROWTH_SUMMON_R2 - }); + return ValidateSpellInfo({SPELL_DRUID_WILD_MUSHROOM, SPELL_DRUID_WILD_MUSHROOM_DAMAGE, SPELL_DRUID_WILD_MUSHROOM_SUICIDE, SPELL_DRUID_WILD_MUSHROOM_VISUAL, SPELL_DRUID_FUNGAL_GROWTH_R1, + SPELL_DRUID_FUNGAL_GROWTH_R2, SPELL_DRUID_FUNGAL_GROWTH_SUMMON_R1, SPELL_DRUID_FUNGAL_GROWTH_SUMMON_R2}); } void HandleDummy(SpellEffIndex /*effIndex*/) @@ -1519,14 +1432,7 @@ class spell_dru_moonfire : public AuraScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo( - { - SPELL_DRUID_LUNAR_ECLIPSE_MARKER, - SPELL_DRUID_SOLAR_ECLIPSE_MARKER, - SPELL_DRUID_SOLAR_ECLIPSE, - SPELL_DRUID_LUNAR_ECLIPSE, - SPELL_DRUID_SOLAR_ECLIPSE_SUNFIRE - }); + return ValidateSpellInfo({SPELL_DRUID_LUNAR_ECLIPSE_MARKER, SPELL_DRUID_SOLAR_ECLIPSE_MARKER, SPELL_DRUID_SOLAR_ECLIPSE, SPELL_DRUID_LUNAR_ECLIPSE, SPELL_DRUID_SOLAR_ECLIPSE_SUNFIRE}); } void RemoveEffect(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) @@ -1554,7 +1460,7 @@ class spell_dru_ferocious_bite : public SpellScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo({ SPELL_DRUID_GLYPH_OF_FEROCIOUS_BITE }); + return ValidateSpellInfo({SPELL_DRUID_GLYPH_OF_FEROCIOUS_BITE}); } bool Load() override @@ -1591,7 +1497,6 @@ class spell_dru_ferocious_bite : public SpellScript int32 bp = aurEff->GetAmount() * totalEnergySpentMultiplier; caster->CastSpell(caster, SPELL_DRUID_GLYPH_OF_FEROCIOUS_BITE, CastSpellExtraArgs(true).AddSpellBP0(bp)); } - } } @@ -1606,7 +1511,7 @@ class spell_dru_empowered_touch : public AuraScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo({ SPELL_DRUID_EMPOWERED_TOUCH_SCRIPT }); + return ValidateSpellInfo({SPELL_DRUID_EMPOWERED_TOUCH_SCRIPT}); } bool CheckProc(ProcEventInfo& /*eventInfo*/) @@ -1633,7 +1538,7 @@ class spell_dru_empowered_touch_script : public SpellScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo({ SPELL_DRUID_LIFEBLOOM }); + return ValidateSpellInfo({SPELL_DRUID_LIFEBLOOM}); } void HandleScriptEffect(SpellEffIndex /*effIndex*/) @@ -1654,7 +1559,7 @@ class spell_dru_shooting_stars : public SpellScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo({ SPELL_DRUID_STARSURGE }); + return ValidateSpellInfo({SPELL_DRUID_STARSURGE}); } void HandleCooldownReset(SpellEffIndex /*effIndex*/) @@ -1673,11 +1578,7 @@ class spell_dru_pulverize : public SpellScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo( - { - SPELL_DRUID_PULVERIZE_TRIGGERED, - SPELL_DRUID_LACERATE - }); + return ValidateSpellInfo({SPELL_DRUID_PULVERIZE_TRIGGERED, SPELL_DRUID_LACERATE}); } void ChangeDamage(SpellEffIndex /*effIndex*/) @@ -1715,7 +1616,7 @@ class spell_dru_frenzied_regeneration : public AuraScript { bool Validate(SpellInfo const* /*spell*/) override { - return ValidateSpellInfo({ SPELL_DRUID_FRENZIED_REGENERATION_HEAL }); + return ValidateSpellInfo({SPELL_DRUID_FRENZIED_REGENERATION_HEAL}); } void HandleHealthAfterApply(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) @@ -1747,7 +1648,6 @@ class spell_dru_frenzied_regeneration : public AuraScript { OnEffectPeriodic.Register(&spell_dru_frenzied_regeneration::HandleRegeneration, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY); AfterEffectApply.Register(&spell_dru_frenzied_regeneration::HandleHealthAfterApply, EFFECT_1, SPELL_AURA_MOD_INCREASE_HEALTH_2, AURA_EFFECT_HANDLE_REAL); - } }; @@ -1755,11 +1655,7 @@ class spell_dru_stampeding_roar : public SpellScript { bool Validate(SpellInfo const* /*spell*/) override { - return ValidateSpellInfo( - { - SPELL_DRUID_FERAL_SWIFTNESS, - SPELL_DRUID_FERAL_SWIFTNESS_CLEAR_ROAR - }); + return ValidateSpellInfo({SPELL_DRUID_FERAL_SWIFTNESS, SPELL_DRUID_FERAL_SWIFTNESS_CLEAR_ROAR}); } void HandleFeralSwiftness(SpellEffIndex /*effIndex*/) @@ -1783,12 +1679,13 @@ class spell_dru_feral_swiftness_clear : public SpellScript { void HandleScriptEffect(SpellEffIndex /*effIndex*/) { - GetHitUnit()->RemoveAppliedAuras([](AuraApplication const* aurApp)->bool - { - SpellInfo const* auraSpellInfo = aurApp->GetBase()->GetSpellInfo(); - uint32 mechanicMask = auraSpellInfo->GetSpellMechanicMaskByEffectMask(EFFECT_ALL); - return (mechanicMask & (1 << MECHANIC_ROOT)) || (mechanicMask & (1 << MECHANIC_SNARE)); - }); + GetHitUnit()->RemoveAppliedAuras( + [](AuraApplication const* aurApp) -> bool + { + SpellInfo const* auraSpellInfo = aurApp->GetBase()->GetSpellInfo(); + uint32 mechanicMask = auraSpellInfo->GetSpellMechanicMaskByEffectMask(EFFECT_ALL); + return (mechanicMask & (1 << MECHANIC_ROOT)) || (mechanicMask & (1 << MECHANIC_SNARE)); + }); } void Register() override @@ -1802,11 +1699,7 @@ class spell_dru_blood_in_the_water : public AuraScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo( - { - SPELL_DRUID_BLOOD_IN_THE_WATER_SCRIPT, - SPELL_DRUID_T13_FERAL_2P_BONUS - }); + return ValidateSpellInfo({SPELL_DRUID_BLOOD_IN_THE_WATER_SCRIPT, SPELL_DRUID_T13_FERAL_2P_BONUS}); } bool CheckProc(ProcEventInfo& eventInfo) @@ -1841,7 +1734,7 @@ class spell_dru_blood_in_the_water_script : public SpellScript { bool Validate(SpellInfo const* /*spell*/) override { - return ValidateSpellInfo({ SPELL_DRUID_RIP }); + return ValidateSpellInfo({SPELL_DRUID_RIP}); } void HandleScriptEffect(SpellEffIndex /*effIndex*/) @@ -1860,7 +1753,7 @@ class spell_dru_blood_in_the_water_script : public SpellScript // 90164 - Astral Alignment class spell_dru_astral_alignment : public AuraScript { - void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& /*eventInfo*/) + void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& /*eventInfo*/) { PreventDefaultAction(); GetAura()->ModStackAmount(-1); @@ -1877,7 +1770,7 @@ class spell_dru_harmony_triggered : public AuraScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo({ SPELL_DRUID_BLOOM }); + return ValidateSpellInfo({SPELL_DRUID_BLOOM}); } void RemoveEffect(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) @@ -1896,7 +1789,7 @@ class spell_dru_item_t11_feral_4p_bonus : public AuraScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo({ SPELL_DRUID_STRENGTH_OF_THE_PANTHER }); + return ValidateSpellInfo({SPELL_DRUID_STRENGTH_OF_THE_PANTHER}); } void HandleProc(AuraEffect const* aurEff, ProcEventInfo& /*eventInfo*/) @@ -1918,13 +1811,7 @@ class spell_dru_skull_bash : public SpellScript bool Validate(SpellInfo const* /*spellInfo*/) override { return ValidateSpellInfo( - { - SPELL_DRUID_SKULL_BASH_CHARGE, - SPELL_DRUID_SKULL_BASH_INTERRUPT, - SPELL_DRUID_SKULL_BASH_COST_INCREASE_R1, - SPELL_DRUID_SKULL_BASH_COST_INCREASE_R2, - SPELL_DRUID_BRUTAL_IMPACT_R1 - }); + {SPELL_DRUID_SKULL_BASH_CHARGE, SPELL_DRUID_SKULL_BASH_INTERRUPT, SPELL_DRUID_SKULL_BASH_COST_INCREASE_R1, SPELL_DRUID_SKULL_BASH_COST_INCREASE_R2, SPELL_DRUID_BRUTAL_IMPACT_R1}); } void HandleDummyEffect(SpellEffIndex /*effIndex*/) @@ -1957,12 +1844,12 @@ class spell_dru_nourish : public SpellScript return; auto periodicHealEffects = GetHitUnit()->GetAuraEffectsByType(SPELL_AURA_PERIODIC_HEAL); - if (std::any_of(periodicHealEffects.begin(), periodicHealEffects.end(), [caster](AuraEffect const* aurEff) - { - return (aurEff->GetCasterGUID() == caster->GetGUID() - && aurEff->GetSpellInfo()->SpellFamilyName == SPELLFAMILY_DRUID - && !aurEff->GetSpellInfo()->SpellFamilyFlags.HasFlag(0x10 | 0x40, 0x10 | 0x4000000, 0)); - })) + if (std::any_of(periodicHealEffects.begin(), periodicHealEffects.end(), + [caster](AuraEffect const* aurEff) + { + return (aurEff->GetCasterGUID() == caster->GetGUID() && aurEff->GetSpellInfo()->SpellFamilyName == SPELLFAMILY_DRUID && + !aurEff->GetSpellInfo()->SpellFamilyFlags.HasFlag(0x10 | 0x40, 0x10 | 0x4000000, 0)); + })) SetHitHeal(GetHitHeal() * 1.2f); } @@ -2026,7 +1913,7 @@ class spell_dru_t12_restoration_4p_bonus : public AuraScript { bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo({ SPELL_DRUID_FIREBLOOM }); + return ValidateSpellInfo({SPELL_DRUID_FIREBLOOM}); } void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)