aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDDuarte <dnpd.dd@gmail.com>2014-01-10 18:32:05 +0000
committerDDuarte <dnpd.dd@gmail.com>2014-01-10 18:32:05 +0000
commit33c2bd5ce1f4f8d20981e9f7aea90e37de0abbda (patch)
tree823ad5570f27e923c77203660ee7cc12e26182ec /src
parent352a2682b1d531c83bd2b80704233677448e99de (diff)
parenta63780fd90701ed81a0a5f2030e82ab1f6927ab4 (diff)
Merge branch 'master' into 4.3.4
Conflicts: src/server/game/Entities/Creature/Creature.cpp src/server/game/Entities/Creature/Creature.h src/server/game/Entities/Creature/GossipDef.cpp src/server/game/Entities/Player/Player.cpp src/server/game/Entities/Transport/Transport.cpp src/server/game/Entities/Unit/Unit.cpp src/server/game/Globals/ObjectMgr.cpp src/server/game/Globals/ObjectMgr.h src/server/game/Handlers/QuestHandler.cpp src/server/game/Handlers/SpellHandler.cpp src/server/game/Handlers/TradeHandler.cpp src/server/game/Quests/QuestDef.h src/server/game/Spells/Auras/SpellAuraEffects.cpp src/server/scripts/EasternKingdoms/ZulAman/boss_akilzon.cpp src/server/scripts/EasternKingdoms/ZulAman/boss_halazzi.cpp src/server/scripts/EasternKingdoms/ZulAman/boss_hexlord.cpp src/server/scripts/EasternKingdoms/ZulAman/boss_janalai.cpp src/server/scripts/EasternKingdoms/ZulAman/boss_nalorakk.cpp src/server/scripts/EasternKingdoms/ZulAman/boss_zuljin.cpp src/server/scripts/EasternKingdoms/ZulAman/zulaman.cpp src/server/scripts/EasternKingdoms/ZulGurub/boss_arlokk.cpp src/server/scripts/EasternKingdoms/ZulGurub/boss_hakkar.cpp src/server/scripts/EasternKingdoms/ZulGurub/boss_jeklik.cpp src/server/scripts/EasternKingdoms/ZulGurub/boss_jindo.cpp src/server/scripts/EasternKingdoms/ZulGurub/boss_mandokir.cpp src/server/scripts/EasternKingdoms/ZulGurub/boss_thekal.cpp src/server/scripts/EasternKingdoms/zone_arathi_highlands.cpp src/server/scripts/EasternKingdoms/zone_burning_steppes.cpp src/server/scripts/EasternKingdoms/zone_ghostlands.cpp src/server/scripts/EasternKingdoms/zone_hinterlands.cpp src/server/scripts/EasternKingdoms/zone_redridge_mountains.cpp src/server/scripts/EasternKingdoms/zone_swamp_of_sorrows.cpp src/server/scripts/Kalimdor/zone_azshara.cpp src/server/scripts/Kalimdor/zone_darkshore.cpp src/server/scripts/Kalimdor/zone_desolace.cpp src/server/scripts/Northrend/zone_dalaran.cpp src/tools/CMakeLists.txt
Diffstat (limited to 'src')
-rw-r--r--src/server/authserver/Main.cpp2
-rw-r--r--src/server/collision/Management/MMapFactory.cpp18
-rw-r--r--src/server/collision/Management/MMapFactory.h8
-rw-r--r--src/server/collision/Management/MMapManager.cpp175
-rw-r--r--src/server/collision/Management/MMapManager.h29
-rw-r--r--src/server/game/AI/CoreAI/GameObjectAI.h3
-rw-r--r--src/server/game/AI/CoreAI/PetAI.cpp2
-rw-r--r--src/server/game/AI/CoreAI/TotemAI.cpp2
-rw-r--r--src/server/game/AI/ScriptedAI/ScriptedCreature.cpp2
-rw-r--r--src/server/game/AI/SmartScripts/SmartAI.cpp5
-rw-r--r--src/server/game/AI/SmartScripts/SmartScript.cpp44
-rw-r--r--src/server/game/Achievements/AchievementMgr.cpp2
-rw-r--r--src/server/game/Battlefield/Zones/BattlefieldWG.cpp2
-rw-r--r--src/server/game/Battlegrounds/Zones/BattlegroundDS.h2
-rw-r--r--src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp6
-rw-r--r--src/server/game/Chat/Channels/Channel.cpp14
-rw-r--r--src/server/game/DataStores/DBCEnums.h2
-rw-r--r--src/server/game/Entities/Creature/Creature.cpp16
-rw-r--r--src/server/game/Entities/Creature/Creature.h11
-rw-r--r--src/server/game/Entities/Creature/GossipDef.cpp6
-rw-r--r--src/server/game/Entities/Creature/GossipDef.h2
-rw-r--r--src/server/game/Entities/GameObject/GameObject.cpp4
-rw-r--r--src/server/game/Entities/Item/Item.cpp2
-rw-r--r--src/server/game/Entities/Object/Object.cpp4
-rw-r--r--src/server/game/Entities/Player/Player.cpp20
-rw-r--r--src/server/game/Entities/Player/Player.h2
-rw-r--r--src/server/game/Entities/Transport/Transport.cpp86
-rw-r--r--src/server/game/Entities/Transport/Transport.h2
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp42
-rw-r--r--src/server/game/Entities/Unit/Unit.h12
-rw-r--r--src/server/game/Globals/ObjectMgr.cpp23
-rw-r--r--src/server/game/Globals/ObjectMgr.h2
-rw-r--r--src/server/game/Handlers/ChatHandler.cpp8
-rw-r--r--src/server/game/Handlers/LootHandler.cpp2
-rw-r--r--src/server/game/Handlers/QuestHandler.cpp44
-rw-r--r--src/server/game/Handlers/SpellHandler.cpp12
-rw-r--r--src/server/game/Handlers/TradeHandler.cpp4
-rw-r--r--src/server/game/Instances/InstanceScript.h12
-rw-r--r--src/server/game/Maps/Map.cpp68
-rw-r--r--src/server/game/Maps/MapInstanced.cpp2
-rw-r--r--src/server/game/Maps/TransportMgr.cpp139
-rw-r--r--src/server/game/Maps/TransportMgr.h3
-rw-r--r--src/server/game/Miscellaneous/SharedDefines.h4
-rwxr-xr-xsrc/server/game/Movement/MovementGenerators/ConfusedMovementGenerator.cpp1
-rw-r--r--src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.cpp1
-rw-r--r--src/server/game/Movement/MovementGenerators/HomeMovementGenerator.cpp2
-rw-r--r--src/server/game/Movement/PathGenerator.cpp835
-rw-r--r--src/server/game/Movement/PathGenerator.h65
-rw-r--r--src/server/game/Movement/Spline/Spline.cpp2
-rw-r--r--src/server/game/Movement/Spline/Spline.h2
-rw-r--r--src/server/game/Quests/QuestDef.h3
-rw-r--r--src/server/game/Scripting/MapScripts.cpp4
-rw-r--r--src/server/game/Scripting/ScriptMgr.cpp6
-rw-r--r--src/server/game/Scripting/ScriptMgr.h5
-rw-r--r--src/server/game/Server/WorldSession.h2
-rw-r--r--src/server/game/Spells/Auras/SpellAuraEffects.cpp4
-rw-r--r--src/server/game/Spells/Auras/SpellAuras.cpp14
-rw-r--r--src/server/game/Spells/Auras/SpellAuras.h2
-rw-r--r--src/server/game/Spells/Spell.cpp73
-rw-r--r--src/server/game/Spells/Spell.h2
-rw-r--r--src/server/game/Spells/SpellEffects.cpp9
-rw-r--r--src/server/game/Spells/SpellInfo.cpp8
-rw-r--r--src/server/game/Spells/SpellMgr.cpp6
-rw-r--r--src/server/game/Spells/SpellScript.h6
-rw-r--r--src/server/game/World/World.cpp2
-rw-r--r--src/server/scripts/Commands/cs_debug.cpp3
-rw-r--r--src/server/scripts/Commands/cs_go.cpp2
-rw-r--r--src/server/scripts/Commands/cs_gobject.cpp2
-rw-r--r--src/server/scripts/Commands/cs_misc.cpp4
-rw-r--r--src/server/scripts/Commands/cs_mmaps.cpp213
-rw-r--r--src/server/scripts/Commands/cs_npc.cpp6
-rw-r--r--src/server/scripts/Commands/cs_quest.cpp2
-rw-r--r--src/server/scripts/EasternKingdoms/BaradinHold/boss_alizabal.cpp2
-rw-r--r--src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/blackrock_depths.cpp22
-rw-r--r--src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_emperor_dagran_thaurissan.cpp4
-rw-r--r--src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_tomb_of_seven.cpp19
-rw-r--r--src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/boss_gyth.cpp2
-rw-r--r--src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/boss_lord_valthalak.cpp5
-rw-r--r--src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/boss_pyroguard_emberseer.cpp81
-rw-r--r--src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/boss_rend_blackhand.cpp2
-rw-r--r--src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/boss_warmaster_voone.cpp15
-rw-r--r--src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_broodlord_lashlayer.cpp2
-rw-r--r--src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_chromaggus.cpp2
-rw-r--r--src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_ebonroc.cpp2
-rw-r--r--src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_firemaw.cpp2
-rw-r--r--src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_flamegor.cpp2
-rw-r--r--src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_nefarian.cpp10
-rw-r--r--src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_razorgore.cpp8
-rw-r--r--src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_golemagg.cpp2
-rw-r--r--src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_majordomo_executus.cpp5
-rw-r--r--src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_ragnaros.cpp53
-rw-r--r--src/server/scripts/EasternKingdoms/Deadmines/boss_mr_smite.cpp13
-rw-r--r--src/server/scripts/EasternKingdoms/Gnomeregan/gnomeregan.cpp31
-rw-r--r--src/server/scripts/EasternKingdoms/Karazhan/boss_midnight.cpp1
-rw-r--r--src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp32
-rw-r--r--src/server/scripts/EasternKingdoms/Karazhan/boss_netherspite.cpp8
-rw-r--r--src/server/scripts/EasternKingdoms/Karazhan/boss_nightbane.cpp26
-rw-r--r--src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp13
-rw-r--r--src/server/scripts/EasternKingdoms/Karazhan/boss_shade_of_aran.cpp38
-rw-r--r--src/server/scripts/EasternKingdoms/Karazhan/boss_terestian_illhoof.cpp30
-rw-r--r--src/server/scripts/EasternKingdoms/Karazhan/bosses_opera.cpp80
-rw-r--r--src/server/scripts/EasternKingdoms/Karazhan/karazhan.cpp15
-rw-r--r--src/server/scripts/EasternKingdoms/MagistersTerrace/boss_felblood_kaelthas.cpp16
-rw-r--r--src/server/scripts/EasternKingdoms/MagistersTerrace/boss_priestess_delrissa.cpp63
-rw-r--r--src/server/scripts/EasternKingdoms/MagistersTerrace/boss_selin_fireheart.cpp50
-rw-r--r--src/server/scripts/EasternKingdoms/MagistersTerrace/boss_vexallus.cpp11
-rw-r--r--src/server/scripts/EasternKingdoms/ScarletMonastery/boss_arcanist_doan.cpp2
-rw-r--r--src/server/scripts/EasternKingdoms/ScarletMonastery/boss_azshir_the_sleepless.cpp2
-rw-r--r--src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp17
-rw-r--r--src/server/scripts/EasternKingdoms/ScarletMonastery/boss_herod.cpp2
-rw-r--r--src/server/scripts/EasternKingdoms/ScarletMonastery/boss_high_inquisitor_fairbanks.cpp2
-rw-r--r--src/server/scripts/EasternKingdoms/ScarletMonastery/boss_interrogator_vishas.cpp7
-rw-r--r--src/server/scripts/EasternKingdoms/ScarletMonastery/boss_mograine_and_whitemane.cpp42
-rw-r--r--src/server/scripts/EasternKingdoms/Scholomance/boss_darkmaster_gandling.cpp2
-rw-r--r--src/server/scripts/EasternKingdoms/Scholomance/boss_instructor_malicia.cpp4
-rw-r--r--src/server/scripts/EasternKingdoms/Scholomance/boss_jandice_barov.cpp2
-rw-r--r--src/server/scripts/EasternKingdoms/Scholomance/boss_kirtonos_the_herald.cpp2
-rw-r--r--src/server/scripts/EasternKingdoms/Scholomance/boss_lord_alexei_barov.cpp9
-rw-r--r--src/server/scripts/EasternKingdoms/ShadowfangKeep/shadowfang_keep.cpp10
-rw-r--r--src/server/scripts/EasternKingdoms/Stratholme/boss_baron_rivendare.cpp15
-rw-r--r--src/server/scripts/EasternKingdoms/Stratholme/boss_baroness_anastari.cpp11
-rw-r--r--src/server/scripts/EasternKingdoms/Stratholme/boss_dathrohan_balnazzar.cpp2
-rw-r--r--src/server/scripts/EasternKingdoms/Stratholme/boss_maleki_the_pallid.cpp5
-rw-r--r--src/server/scripts/EasternKingdoms/Stratholme/boss_nerubenkan.cpp5
-rw-r--r--src/server/scripts/EasternKingdoms/Stratholme/boss_order_of_silver_hand.cpp40
-rw-r--r--src/server/scripts/EasternKingdoms/Stratholme/boss_ramstein_the_gorger.cpp5
-rw-r--r--src/server/scripts/EasternKingdoms/SunwellPlateau/boss_eredar_twins.cpp22
-rw-r--r--src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp2
-rw-r--r--src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp17
-rw-r--r--src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kiljaeden.cpp27
-rw-r--r--src/server/scripts/EasternKingdoms/SunwellPlateau/boss_muru.cpp10
-rw-r--r--src/server/scripts/EasternKingdoms/Uldaman/boss_archaedas.cpp21
-rw-r--r--src/server/scripts/EasternKingdoms/Uldaman/boss_ironaya.cpp16
-rw-r--r--src/server/scripts/EasternKingdoms/ZulAman/boss_akilzon.cpp8
-rw-r--r--src/server/scripts/EasternKingdoms/ZulAman/boss_hexlord.cpp2
-rw-r--r--src/server/scripts/EasternKingdoms/ZulAman/boss_janalai.cpp2
-rw-r--r--src/server/scripts/EasternKingdoms/ZulAman/boss_nalorakk.cpp2
-rw-r--r--src/server/scripts/EasternKingdoms/ZulAman/zulaman.cpp3
-rw-r--r--src/server/scripts/EasternKingdoms/zone_arathi_highlands.cpp62
-rw-r--r--src/server/scripts/EasternKingdoms/zone_blasted_lands.cpp85
-rw-r--r--src/server/scripts/EasternKingdoms/zone_burning_steppes.cpp32
-rw-r--r--src/server/scripts/EasternKingdoms/zone_duskwood.cpp132
-rw-r--r--src/server/scripts/EasternKingdoms/zone_ghostlands.cpp54
-rw-r--r--src/server/scripts/EasternKingdoms/zone_hinterlands.cpp79
-rw-r--r--src/server/scripts/Examples/example_spell.cpp2
-rw-r--r--src/server/scripts/Kalimdor/BlackfathomDeeps/blackfathom_deeps.cpp5
-rw-r--r--src/server/scripts/Kalimdor/BlackfathomDeeps/boss_gelihast.cpp11
-rw-r--r--src/server/scripts/Kalimdor/BlackfathomDeeps/boss_kelris.cpp11
-rw-r--r--src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_anetheron.cpp36
-rw-r--r--src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_archimonde.cpp37
-rw-r--r--src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_azgalor.cpp31
-rw-r--r--src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_kazrogal.cpp25
-rw-r--r--src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_rage_winterchill.cpp25
-rw-r--r--src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal.cpp9
-rw-r--r--src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp107
-rw-r--r--src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal_trash.cpp246
-rw-r--r--src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_chrono_lord_epoch.cpp11
-rw-r--r--src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_infinite_corruptor.cpp11
-rw-r--r--src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_mal_ganis.cpp22
-rw-r--r--src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_meathook.cpp14
-rw-r--r--src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_salramm_the_fleshcrafter.cpp14
-rw-r--r--src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/culling_of_stratholme.cpp159
-rw-r--r--src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/boss_captain_skarloc.cpp2
-rw-r--r--src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/boss_epoch_hunter.cpp4
-rw-r--r--src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/old_hillsbrad.cpp10
-rw-r--r--src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/boss_aeonus.cpp14
-rw-r--r--src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/boss_chrono_lord_deja.cpp5
-rw-r--r--src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/boss_temporus.cpp5
-rw-r--r--src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/the_black_morass.cpp22
-rw-r--r--src/server/scripts/Kalimdor/OnyxiasLair/boss_onyxia.cpp32
-rw-r--r--src/server/scripts/Kalimdor/RazorfenDowns/boss_amnennar_the_coldbringer.cpp5
-rw-r--r--src/server/scripts/Kalimdor/RazorfenDowns/razorfen_downs.cpp12
-rw-r--r--src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_ayamiss.cpp4
-rw-r--r--src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_buru.cpp2
-rw-r--r--src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_kurinnaxx.cpp2
-rw-r--r--src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_ossirian.cpp33
-rw-r--r--src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_bug_trio.cpp76
-rw-r--r--src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp36
-rw-r--r--src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_sartura.cpp2
-rw-r--r--src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_twinemperors.cpp24
-rw-r--r--src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_viscidus.cpp7
-rw-r--r--src/server/scripts/Kalimdor/WailingCaverns/wailing_caverns.cpp18
-rw-r--r--src/server/scripts/Kalimdor/ZulFarrak/boss_zum_rah.cpp5
-rw-r--r--src/server/scripts/Kalimdor/ZulFarrak/zulfarrak.cpp44
-rw-r--r--src/server/scripts/Kalimdor/zone_ashenvale.cpp431
-rw-r--r--src/server/scripts/Kalimdor/zone_azuremyst_isle.cpp138
-rw-r--r--src/server/scripts/Kalimdor/zone_bloodmyst_isle.cpp86
-rw-r--r--src/server/scripts/Kalimdor/zone_desolace.cpp27
-rw-r--r--src/server/scripts/Kalimdor/zone_the_barrens.cpp5
-rw-r--r--src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_herald_volazj.cpp26
-rw-r--r--src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_jedoga_shadowseeker.cpp60
-rw-r--r--src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_anubarak.cpp18
-rw-r--r--src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_hadronox.cpp8
-rw-r--r--src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_krikthir_the_gatewatcher.cpp11
-rw-r--r--src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/boss_sartharion.cpp191
-rw-r--r--src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/obsidian_sanctum.cpp460
-rw-r--r--src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/obsidian_sanctum.h12
-rw-r--r--src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_argent_challenge.cpp15
-rw-r--r--src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_black_knight.cpp5
-rw-r--r--src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_grand_champions.cpp42
-rw-r--r--src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/trial_of_the_champion.cpp26
-rw-r--r--src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp20
-rw-r--r--src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_faction_champions.cpp68
-rw-r--r--src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_lord_jaraxxus.cpp14
-rw-r--r--src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_northrend_beasts.cpp81
-rw-r--r--src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_twin_valkyr.cpp53
-rw-r--r--src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/trial_of_the_crusader.cpp10
-rw-r--r--src/server/scripts/Northrend/DraktharonKeep/boss_king_dred.cpp2
-rw-r--r--src/server/scripts/Northrend/DraktharonKeep/boss_tharon_ja.cpp2
-rw-r--r--src/server/scripts/Northrend/DraktharonKeep/instance_drak_tharon_keep.cpp2
-rw-r--r--src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_bronjahm.cpp21
-rw-r--r--src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_devourer_of_souls.cpp6
-rw-r--r--src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/forge_of_souls.cpp10
-rw-r--r--src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/boss_falric.cpp11
-rw-r--r--src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/boss_marwyn.cpp11
-rw-r--r--src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/halls_of_reflection.cpp20
-rw-r--r--src/server/scripts/Northrend/Gundrak/boss_drakkari_colossus.cpp22
-rw-r--r--src/server/scripts/Northrend/Gundrak/boss_eck.cpp22
-rw-r--r--src/server/scripts/Northrend/Gundrak/boss_gal_darah.cpp11
-rw-r--r--src/server/scripts/Northrend/Gundrak/boss_moorabi.cpp11
-rw-r--r--src/server/scripts/Northrend/Gundrak/boss_slad_ran.cpp16
-rw-r--r--src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp2
-rw-r--r--src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp2
-rw-r--r--src/server/scripts/Northrend/Naxxramas/boss_anubrekhan.cpp5
-rw-r--r--src/server/scripts/Northrend/Naxxramas/boss_faerlina.cpp2
-rw-r--r--src/server/scripts/Northrend/Naxxramas/boss_four_horsemen.cpp13
-rw-r--r--src/server/scripts/Northrend/Naxxramas/boss_gothik.cpp17
-rw-r--r--src/server/scripts/Northrend/Naxxramas/boss_heigan.cpp2
-rw-r--r--src/server/scripts/Northrend/Naxxramas/boss_kelthuzad.cpp7
-rw-r--r--src/server/scripts/Northrend/Naxxramas/boss_noth.cpp68
-rw-r--r--src/server/scripts/Northrend/Naxxramas/boss_patchwerk.cpp8
-rw-r--r--src/server/scripts/Northrend/Naxxramas/boss_sapphiron.cpp2
-rw-r--r--src/server/scripts/Northrend/Naxxramas/boss_thaddius.cpp44
-rw-r--r--src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp49
-rw-r--r--src/server/scripts/Northrend/Nexus/Nexus/boss_anomalus.cpp13
-rw-r--r--src/server/scripts/Northrend/Nexus/Nexus/boss_keristrasza.cpp19
-rw-r--r--src/server/scripts/Northrend/Nexus/Nexus/boss_magus_telestra.cpp16
-rw-r--r--src/server/scripts/Northrend/Nexus/Nexus/boss_ormorok.cpp25
-rw-r--r--src/server/scripts/Northrend/Nexus/Oculus/boss_eregos.cpp7
-rw-r--r--src/server/scripts/Northrend/Nexus/Oculus/boss_urom.cpp2
-rw-r--r--src/server/scripts/Northrend/Nexus/Oculus/boss_varos.cpp17
-rw-r--r--src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_bjarngrim.cpp33
-rw-r--r--src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_ionar.cpp45
-rw-r--r--src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_loken.cpp28
-rw-r--r--src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_volkhan.cpp20
-rw-r--r--src/server/scripts/Northrend/Ulduar/HallsOfStone/boss_krystallus.cpp9
-rw-r--r--src/server/scripts/Northrend/Ulduar/HallsOfStone/boss_maiden_of_grief.cpp17
-rw-r--r--src/server/scripts/Northrend/Ulduar/HallsOfStone/halls_of_stone.cpp152
-rw-r--r--src/server/scripts/Northrend/Ulduar/Ulduar/boss_auriaya.cpp6
-rw-r--r--src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp6
-rw-r--r--src/server/scripts/Northrend/Ulduar/Ulduar/boss_freya.cpp10
-rw-r--r--src/server/scripts/Northrend/Ulduar/Ulduar/boss_general_vezax.cpp4
-rw-r--r--src/server/scripts/Northrend/Ulduar/Ulduar/boss_hodir.cpp4
-rw-r--r--src/server/scripts/Northrend/Ulduar/Ulduar/boss_razorscale.cpp4
-rw-r--r--src/server/scripts/Northrend/Ulduar/Ulduar/boss_xt002.cpp16
-rw-r--r--src/server/scripts/Northrend/Ulduar/Ulduar/boss_yogg_saron.cpp4
-rw-r--r--src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_keleseth.cpp2
-rw-r--r--src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_skarvald_dalronn.cpp6
-rw-r--r--src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_palehoof.cpp18
-rw-r--r--src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_skadi.cpp34
-rw-r--r--src/server/scripts/Northrend/VaultOfArchavon/boss_emalon.cpp2
-rw-r--r--src/server/scripts/Northrend/VaultOfArchavon/boss_toravon.cpp2
-rw-r--r--src/server/scripts/Northrend/VioletHold/boss_cyanigosa.cpp11
-rw-r--r--src/server/scripts/Northrend/VioletHold/boss_erekem.cpp57
-rw-r--r--src/server/scripts/Northrend/VioletHold/boss_ichoron.cpp70
-rw-r--r--src/server/scripts/Northrend/VioletHold/boss_lavanthor.cpp35
-rw-r--r--src/server/scripts/Northrend/VioletHold/boss_moragg.cpp55
-rw-r--r--src/server/scripts/Northrend/VioletHold/boss_xevozz.cpp72
-rw-r--r--src/server/scripts/Northrend/VioletHold/boss_zuramat.cpp55
-rw-r--r--src/server/scripts/Northrend/VioletHold/instance_violet_hold.cpp4
-rw-r--r--src/server/scripts/Northrend/VioletHold/violet_hold.cpp48
-rw-r--r--src/server/scripts/Northrend/zone_borean_tundra.cpp81
-rw-r--r--src/server/scripts/Northrend/zone_crystalsong_forest.cpp18
-rw-r--r--src/server/scripts/Northrend/zone_dalaran.cpp14
-rw-r--r--src/server/scripts/Northrend/zone_dragonblight.cpp2
-rw-r--r--src/server/scripts/Outland/Auchindoun/AuchenaiCrypts/boss_exarch_maladaar.cpp4
-rw-r--r--src/server/scripts/Outland/Auchindoun/ManaTombs/boss_nexusprince_shaffar.cpp8
-rw-r--r--src/server/scripts/Outland/Auchindoun/ManaTombs/boss_pandemonius.cpp2
-rw-r--r--src/server/scripts/Outland/Auchindoun/SethekkHalls/boss_darkweaver_syth.cpp2
-rw-r--r--src/server/scripts/Outland/Auchindoun/SethekkHalls/boss_tailonking_ikiss.cpp2
-rw-r--r--src/server/scripts/Outland/BlackTemple/black_temple.cpp2
-rw-r--r--src/server/scripts/Outland/BlackTemple/boss_bloodboil.cpp11
-rw-r--r--src/server/scripts/Outland/BlackTemple/boss_illidan.cpp72
-rw-r--r--src/server/scripts/Outland/BlackTemple/boss_mother_shahraz.cpp11
-rw-r--r--src/server/scripts/Outland/BlackTemple/boss_reliquary_of_souls.cpp11
-rw-r--r--src/server/scripts/Outland/BlackTemple/boss_shade_of_akama.cpp39
-rw-r--r--src/server/scripts/Outland/BlackTemple/boss_supremus.cpp15
-rw-r--r--src/server/scripts/Outland/BlackTemple/boss_teron_gorefiend.cpp11
-rw-r--r--src/server/scripts/Outland/BlackTemple/boss_warlord_najentus.cpp11
-rw-r--r--src/server/scripts/Outland/BlackTemple/illidari_council.cpp52
-rw-r--r--src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_fathomlord_karathress.cpp137
-rw-r--r--src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_hydross_the_unstable.cpp11
-rw-r--r--src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lady_vashj.cpp75
-rw-r--r--src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp46
-rw-r--r--src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lurker_below.cpp19
-rw-r--r--src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_morogrim_tidewalker.cpp11
-rw-r--r--src/server/scripts/Outland/CoilfangReservoir/SteamVault/boss_hydromancer_thespia.cpp11
-rw-r--r--src/server/scripts/Outland/CoilfangReservoir/SteamVault/boss_mekgineer_steamrigger.cpp13
-rw-r--r--src/server/scripts/Outland/CoilfangReservoir/SteamVault/boss_warlord_kalithresh.cpp33
-rw-r--r--src/server/scripts/Outland/HellfireCitadel/BloodFurnace/boss_broggok.cpp11
-rw-r--r--src/server/scripts/Outland/HellfireCitadel/BloodFurnace/boss_kelidan_the_breaker.cpp25
-rw-r--r--src/server/scripts/Outland/HellfireCitadel/BloodFurnace/boss_the_maker.cpp11
-rw-r--r--src/server/scripts/Outland/HellfireCitadel/HellfireRamparts/boss_omor_the_unscarred.cpp2
-rw-r--r--src/server/scripts/Outland/HellfireCitadel/MagtheridonsLair/boss_magtheridon.cpp35
-rw-r--r--src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/boss_nethekurse.cpp31
-rw-r--r--src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/boss_warbringer_omrogg.cpp13
-rw-r--r--src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/boss_warchief_kargath_bladefist.cpp5
-rw-r--r--src/server/scripts/Outland/TempestKeep/Eye/boss_alar.cpp15
-rw-r--r--src/server/scripts/Outland/TempestKeep/Eye/boss_astromancer.cpp16
-rw-r--r--src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp45
-rw-r--r--src/server/scripts/Outland/TempestKeep/Eye/boss_void_reaver.cpp8
-rw-r--r--src/server/scripts/Outland/TempestKeep/Mechanar/boss_nethermancer_sepethrea.cpp13
-rw-r--r--src/server/scripts/Outland/TempestKeep/arcatraz/arcatraz.cpp9
-rw-r--r--src/server/scripts/Outland/TempestKeep/arcatraz/arcatraz.h10
-rw-r--r--src/server/scripts/Outland/TempestKeep/arcatraz/boss_harbinger_skyriss.cpp8
-rw-r--r--src/server/scripts/Outland/TempestKeep/botanica/boss_high_botanist_freywinn.cpp2
-rw-r--r--src/server/scripts/Outland/zone_blades_edge_mountains.cpp98
-rw-r--r--src/server/scripts/Outland/zone_hellfire_peninsula.cpp363
-rw-r--r--src/server/scripts/Pet/pet_dk.cpp7
-rw-r--r--src/server/scripts/Pet/pet_mage.cpp2
-rw-r--r--src/server/scripts/Spells/spell_generic.cpp28
-rw-r--r--src/server/scripts/Spells/spell_quest.cpp2
-rw-r--r--src/server/scripts/World/guards.cpp4
-rw-r--r--src/server/scripts/World/mob_generic_creature.cpp4
-rw-r--r--src/server/shared/Database/Field.cpp2
-rw-r--r--src/server/worldserver/Master.cpp2
-rw-r--r--src/tools/CMakeLists.txt3
-rw-r--r--src/tools/mesh_extractor/ADT.cpp7
-rw-r--r--src/tools/mesh_extractor/CMakeLists.txt2
-rw-r--r--src/tools/mesh_extractor/Cache.h20
-rw-r--r--src/tools/mesh_extractor/Chunk.cpp16
-rw-r--r--src/tools/mesh_extractor/Chunk.h8
-rw-r--r--src/tools/mesh_extractor/ChunkedData.cpp40
-rw-r--r--src/tools/mesh_extractor/ChunkedData.h7
-rw-r--r--src/tools/mesh_extractor/Constants.h2
-rw-r--r--src/tools/mesh_extractor/ContinentBuilder.cpp140
-rw-r--r--src/tools/mesh_extractor/ContinentBuilder.h65
-rw-r--r--src/tools/mesh_extractor/DBC.cpp43
-rw-r--r--src/tools/mesh_extractor/DBC.h14
-rw-r--r--src/tools/mesh_extractor/DoodadHandler.cpp44
-rw-r--r--src/tools/mesh_extractor/DoodadHandler.h21
-rw-r--r--src/tools/mesh_extractor/Geometry.cpp14
-rw-r--r--src/tools/mesh_extractor/Geometry.h2
-rw-r--r--src/tools/mesh_extractor/LiquidHandler.cpp75
-rw-r--r--src/tools/mesh_extractor/LiquidHandler.h4
-rw-r--r--src/tools/mesh_extractor/MPQ.cpp14
-rw-r--r--src/tools/mesh_extractor/MPQ.h17
-rw-r--r--src/tools/mesh_extractor/MPQManager.cpp95
-rw-r--r--src/tools/mesh_extractor/MPQManager.h13
-rw-r--r--src/tools/mesh_extractor/MapChunk.cpp18
-rw-r--r--src/tools/mesh_extractor/MapChunk.h2
-rw-r--r--src/tools/mesh_extractor/MeshExtractor.cpp96
-rw-r--r--src/tools/mesh_extractor/Model.cpp31
-rw-r--r--src/tools/mesh_extractor/Model.h3
-rw-r--r--src/tools/mesh_extractor/ObjectDataHandler.h1
-rw-r--r--src/tools/mesh_extractor/Stream.cpp47
-rw-r--r--src/tools/mesh_extractor/Stream.h59
-rw-r--r--src/tools/mesh_extractor/TileBuilder.cpp49
-rw-r--r--src/tools/mesh_extractor/TileBuilder.h6
-rw-r--r--src/tools/mesh_extractor/Utils.cpp496
-rw-r--r--src/tools/mesh_extractor/Utils.h81
-rw-r--r--src/tools/mesh_extractor/WDT.cpp21
-rw-r--r--src/tools/mesh_extractor/WDT.h4
-rw-r--r--src/tools/mesh_extractor/WorldModelGroup.cpp72
-rw-r--r--src/tools/mesh_extractor/WorldModelGroup.h4
-rw-r--r--src/tools/mesh_extractor/WorldModelHandler.cpp80
-rw-r--r--src/tools/mesh_extractor/WorldModelHandler.h6
-rw-r--r--src/tools/mesh_extractor/WorldModelRoot.cpp28
-rw-r--r--src/tools/mesh_extractor/WorldModelRoot.h2
369 files changed, 4808 insertions, 6287 deletions
diff --git a/src/server/authserver/Main.cpp b/src/server/authserver/Main.cpp
index 80a810e4ce1..c4a130e7aa1 100644
--- a/src/server/authserver/Main.cpp
+++ b/src/server/authserver/Main.cpp
@@ -229,7 +229,7 @@ extern int main(int argc, char** argv)
{
CPU_ZERO(&mask);
sched_getaffinity(0, sizeof(mask), &mask);
- TC_LOG_INFO("server.authserver", "Using processors (bitmask, hex): %x", *(uint32*)(&mask));
+ TC_LOG_INFO("server.authserver", "Using processors (bitmask, hex): %lx", *(__cpu_mask*)(&mask));
}
}
diff --git a/src/server/collision/Management/MMapFactory.cpp b/src/server/collision/Management/MMapFactory.cpp
index 6aa71d77ed8..28a1caf14ba 100644
--- a/src/server/collision/Management/MMapFactory.cpp
+++ b/src/server/collision/Management/MMapFactory.cpp
@@ -25,14 +25,14 @@ namespace MMAP
{
// ######################## MMapFactory ########################
// our global singleton copy
- MMapManager* g_MMapManager = NULL;
+ MMapManager* _manager = NULL;
- MMapManager* MMapFactory::createOrGetMMapManager()
+ MMapManager* MMapFactory::CreateOrGetMMapManager()
{
- if (g_MMapManager == NULL)
- g_MMapManager = new MMapManager();
+ if (_manager == NULL)
+ _manager = new MMapManager();
- return g_MMapManager;
+ return _manager;
}
bool MMapFactory::IsPathfindingEnabled(uint32 mapId)
@@ -41,12 +41,12 @@ namespace MMAP
&& !DisableMgr::IsDisabledFor(DISABLE_TYPE_MMAP, mapId, NULL, MMAP_DISABLE_PATHFINDING);
}
- void MMapFactory::clear()
+ void MMapFactory::Clear()
{
- if (g_MMapManager)
+ if (_manager)
{
- delete g_MMapManager;
- g_MMapManager = NULL;
+ delete _manager;
+ _manager = NULL;
}
}
} \ No newline at end of file
diff --git a/src/server/collision/Management/MMapFactory.h b/src/server/collision/Management/MMapFactory.h
index 038d44a941c..c7e3283d22d 100644
--- a/src/server/collision/Management/MMapFactory.h
+++ b/src/server/collision/Management/MMapFactory.h
@@ -20,10 +20,6 @@
#define _MMAP_FACTORY_H
#include "MMapManager.h"
-#include "UnorderedMap.h"
-#include "DetourAlloc.h"
-#include "DetourNavMesh.h"
-#include "DetourNavMeshQuery.h"
namespace MMAP
{
@@ -40,8 +36,8 @@ namespace MMAP
class MMapFactory
{
public:
- static MMapManager* createOrGetMMapManager();
- static void clear();
+ static MMapManager* CreateOrGetMMapManager();
+ static void Clear();
static bool IsPathfindingEnabled(uint32 mapId);
};
}
diff --git a/src/server/collision/Management/MMapManager.cpp b/src/server/collision/Management/MMapManager.cpp
index 4e6b3bb6d10..c29d6fa4b56 100644
--- a/src/server/collision/Management/MMapManager.cpp
+++ b/src/server/collision/Management/MMapManager.cpp
@@ -22,32 +22,29 @@
namespace MMAP
{
- // ######################## MMapManager ########################
MMapManager::~MMapManager()
{
- for (MMapDataSet::iterator i = loadedMMaps.begin(); i != loadedMMaps.end(); ++i)
+ for (MMapDataSet::iterator i = _loadedMaps.begin(); i != _loadedMaps.end(); ++i)
delete i->second;
-
- // by now we should not have maps loaded
- // if we had, tiles in MMapData->mmapLoadedTiles, their actual data is lost!
}
- bool MMapManager::loadMapData(uint32 mapId)
+ bool MMapManager::LoadMap(uint32 mapId)
{
- // we already have this map loaded?
- if (loadedMMaps.find(mapId) != loadedMMaps.end())
+ // Do not load a map twice.
+ if (_loadedMaps.find(mapId) != _loadedMaps.end())
return true;
// load and init dtNavMesh - read parameters from file
- uint32 pathLen = sWorld->GetDataPath().length() + strlen("mmaps/%03i.mmap")+1;
- char *fileName = new char[pathLen];
- snprintf(fileName, pathLen, (sWorld->GetDataPath()+"mmaps/%03i.mmap").c_str(), mapId);
+ std::string basePath = sWorld->GetDataPath();
+ uint32 pathLen = basePath.length() + strlen("mmaps/%03i.mmap") + 1;
+ char* fileName = new char[pathLen];
+ snprintf(fileName, pathLen, (basePath + "mmaps/%03i.mmap").c_str(), mapId);
FILE* file = fopen(fileName, "rb");
if (!file)
{
- TC_LOG_DEBUG("maps", "MMAP:loadMapData: Error: Could not open mmap file '%s'", fileName);
- delete [] fileName;
+ TC_LOG_DEBUG("maps", "MMAP::LoadMap: Error: Could not open mmap file '%s'", fileName);
+ delete[] fileName;
return false;
}
@@ -56,80 +53,75 @@ namespace MMAP
fclose(file);
if (count != 1)
{
- TC_LOG_DEBUG("maps", "MMAP:loadMapData: Error: Could not read params from file '%s'", fileName);
- delete [] fileName;
+ TC_LOG_DEBUG("maps", "MMAP::LoadMap: Error: Could not read params from file '%s'", fileName);
+ delete[] fileName;
return false;
}
dtNavMesh* mesh = dtAllocNavMesh();
- ASSERT(mesh);
if (dtStatusFailed(mesh->init(&params)))
{
dtFreeNavMesh(mesh);
- TC_LOG_ERROR("maps", "MMAP:loadMapData: Failed to initialize dtNavMesh for mmap %03u from file %s", mapId, fileName);
- delete [] fileName;
+ TC_LOG_ERROR("maps", "MMAP::LoadMap: Failed to initialize dtNavMesh for mmap %03u from file %s", mapId, fileName);
+ delete[] fileName;
return false;
}
- delete [] fileName;
+ delete[] fileName;
- TC_LOG_INFO("maps", "MMAP:loadMapData: Loaded %03i.mmap", mapId);
+ TC_LOG_INFO("maps", "MMAP::LoadMap: Loaded %03i.mmap", mapId);
// store inside our map list
- MMapData* mmap_data = new MMapData(mesh);
- mmap_data->mmapLoadedTiles.clear();
+ MMapData* mmapData = new MMapData(mesh);
+ mmapData->_loadedTiles.clear();
- loadedMMaps.insert(std::pair<uint32, MMapData*>(mapId, mmap_data));
+ _loadedMaps.insert(std::pair<uint32, MMapData*>(mapId, mmapData));
return true;
}
- uint32 MMapManager::packTileID(int32 x, int32 y)
- {
- return uint32(x << 16 | y);
- }
-
- bool MMapManager::loadMap(const std::string& /*basePath*/, uint32 mapId, int32 x, int32 y)
+ bool MMapManager::LoadMapTile(uint32 mapId, int32 x, int32 y)
{
// make sure the mmap is loaded and ready to load tiles
- if (!loadMapData(mapId))
+ if (!LoadMap(mapId))
return false;
// get this mmap data
- MMapData* mmap = loadedMMaps[mapId];
+ MMapData* mmap = _loadedMaps[mapId];
ASSERT(mmap->navMesh);
- // check if we already have this tile loaded
- uint32 packedGridPos = packTileID(x, y);
- if (mmap->mmapLoadedTiles.find(packedGridPos) != mmap->mmapLoadedTiles.end())
+ // Check if we already have this tile loaded
+ uint32 pos = PackTileId(x, y);
+ if (mmap->_loadedTiles.find(pos) != mmap->_loadedTiles.end())
return false;
- // load this tile :: mmaps/MMMXXYY.mmtile
- uint32 pathLen = sWorld->GetDataPath().length() + strlen("mmaps/%03i%02i%02i.mmtile")+1;
- char *fileName = new char[pathLen];
+ std::string basePath = sWorld->GetDataPath();
+ uint32 pathLen = basePath.length() + strlen("mmaps/%03i%02i%02i.mmtile") + 1;
+ char* fileName = new char[pathLen];
- snprintf(fileName, pathLen, (sWorld->GetDataPath()+"mmaps/%03i%02i%02i.mmtile").c_str(), mapId, x, y);
+ snprintf(fileName, pathLen, (basePath + "mmaps/%03i%02i%02i.mmtile").c_str(), mapId, x, y);
FILE* file = fopen(fileName, "rb");
if (!file)
{
- TC_LOG_DEBUG("maps", "MMAP:loadMap: Could not open mmtile file '%s'", fileName);
- delete [] fileName;
+ TC_LOG_DEBUG("maps", "MMAP::LoadMapTile: Could not open mmtile file '%s'", fileName);
+ delete[] fileName;
return false;
}
- delete [] fileName;
+
+ delete[] fileName;
// read header
MmapTileHeader fileHeader;
if (fread(&fileHeader, sizeof(MmapTileHeader), 1, file) != 1 || fileHeader.mmapMagic != MMAP_MAGIC)
{
- TC_LOG_ERROR("maps", "MMAP:loadMap: Bad header in mmap %03u%02i%02i.mmtile", mapId, x, y);
+ TC_LOG_ERROR("maps", "MMAP::LoadMapTile: Bad header in mmap %03u%02i%02i.mmtile", mapId, x, y);
fclose(file);
return false;
}
if (fileHeader.mmapVersion != MMAP_VERSION)
{
- TC_LOG_ERROR("maps", "MMAP:loadMap: %03u%02i%02i.mmtile was built with generator v%i, expected v%i",
+ TC_LOG_ERROR("maps", "MMAP::LoadMapTile: %03u%02i%02i.mmtile was built with generator v%i, expected v%i",
mapId, x, y, fileHeader.mmapVersion, MMAP_VERSION);
fclose(file);
return false;
@@ -139,9 +131,9 @@ namespace MMAP
ASSERT(data);
size_t result = fread(data, fileHeader.size, 1, file);
- if (!result)
+ if (result != 1)
{
- TC_LOG_ERROR("maps", "MMAP:loadMap: Bad header or data in mmap %03u%02i%02i.mmtile", mapId, x, y);
+ TC_LOG_ERROR("maps", "MMAP::LoadMapTile: Bad header or data in mmap %03u%02i%02i.mmtile", mapId, x, y);
fclose(file);
return false;
}
@@ -154,14 +146,14 @@ namespace MMAP
// memory allocated for data is now managed by detour, and will be deallocated when the tile is removed
if (dtStatusSucceed(mmap->navMesh->addTile(data, fileHeader.size, DT_TILE_FREE_DATA, 0, &tileRef)))
{
- mmap->mmapLoadedTiles.insert(std::pair<uint32, dtTileRef>(packedGridPos, tileRef));
- ++loadedTiles;
- TC_LOG_INFO("maps", "MMAP:loadMap: Loaded mmtile %03i[%02i, %02i] into %03i[%02i, %02i]", mapId, x, y, mapId, header->x, header->y);
+ mmap->_loadedTiles.insert(std::pair<uint32, dtTileRef>(pos, tileRef));
+ ++_loadedTiles;
+ TC_LOG_INFO("maps", "MMAP::LoadMapTile: Loaded mmtile %03i[%02i, %02i] into %03i[%02i, %02i]", mapId, x, y, mapId, header->x, header->y);
return true;
}
else
{
- TC_LOG_ERROR("maps", "MMAP:loadMap: Could not load %03u%02i%02i.mmtile into navmesh", mapId, x, y);
+ TC_LOG_ERROR("maps", "MMAP::LoadMapTile: Could not load %03u%02i%02i.mmtile into navmesh", mapId, x, y);
dtFree(data);
return false;
}
@@ -169,28 +161,26 @@ namespace MMAP
return false;
}
- bool MMapManager::unloadMap(uint32 mapId, int32 x, int32 y)
+ bool MMapManager::UnloadMapTile(uint32 mapId, int32 x, int32 y)
{
- // check if we have this map loaded
- if (loadedMMaps.find(mapId) == loadedMMaps.end())
+ // Do not attempt to remove tiles from a not-loaded map
+ if (_loadedMaps.find(mapId) == _loadedMaps.end())
{
- // file may not exist, therefore not loaded
- TC_LOG_DEBUG("maps", "MMAP:unloadMap: Asked to unload not loaded navmesh map. %03u%02i%02i.mmtile", mapId, x, y);
+ TC_LOG_DEBUG("maps", "MMAP::UnloadMapTile: Asked to unload not loaded navmesh map. %03u%02i%02i.mmtile", mapId, x, y);
return false;
}
- MMapData* mmap = loadedMMaps[mapId];
+ MMapData* mmap = _loadedMaps[mapId];
// check if we have this tile loaded
- uint32 packedGridPos = packTileID(x, y);
- if (mmap->mmapLoadedTiles.find(packedGridPos) == mmap->mmapLoadedTiles.end())
+ uint32 pos = PackTileId(x, y);
+ if (mmap->_loadedTiles.find(pos) == mmap->_loadedTiles.end())
{
- // file may not exist, therefore not loaded
- TC_LOG_DEBUG("maps", "MMAP:unloadMap: Asked to unload not loaded navmesh tile. %03u%02i%02i.mmtile", mapId, x, y);
+ TC_LOG_DEBUG("maps", "MMAP::UnloadMapTile: Asked to unload not loaded navmesh tile. %03u%02i%02i.mmtile", mapId, x, y);
return false;
}
- dtTileRef tileRef = mmap->mmapLoadedTiles[packedGridPos];
+ dtTileRef tileRef = mmap->_loadedTiles[pos];
// unload, and mark as non loaded
if (dtStatusFailed(mmap->navMesh->removeTile(tileRef, NULL, NULL)))
@@ -198,107 +188,106 @@ namespace MMAP
// this is technically a memory leak
// if the grid is later reloaded, dtNavMesh::addTile will return error but no extra memory is used
// we cannot recover from this error - assert out
- TC_LOG_ERROR("maps", "MMAP:unloadMap: Could not unload %03u%02i%02i.mmtile from navmesh", mapId, x, y);
+ TC_LOG_ERROR("maps", "MMAP::UnloadMapTile: Could not unload %03u%02i%02i.mmtile from navmesh", mapId, x, y);
ASSERT(false);
}
else
{
- mmap->mmapLoadedTiles.erase(packedGridPos);
- --loadedTiles;
- TC_LOG_INFO("maps", "MMAP:unloadMap: Unloaded mmtile %03i[%02i, %02i] from %03i", mapId, x, y, mapId);
+ mmap->_loadedTiles.erase(pos);
+ --_loadedTiles;
+ TC_LOG_INFO("maps", "MMAP::UnloadMapTile: Unloaded mmtile [%02i, %02i] from %03i", x, y, mapId);
return true;
}
return false;
}
- bool MMapManager::unloadMap(uint32 mapId)
+ bool MMapManager::UnloadMap(uint32 mapId)
{
- if (loadedMMaps.find(mapId) == loadedMMaps.end())
+ if (_loadedMaps.find(mapId) == _loadedMaps.end())
{
// file may not exist, therefore not loaded
- TC_LOG_DEBUG("maps", "MMAP:unloadMap: Asked to unload not loaded navmesh map %03u", mapId);
+ TC_LOG_DEBUG("maps", "MMAP::UnloadMap: Asked to unload not loaded navmesh map %03u", mapId);
return false;
}
// unload all tiles from given map
- MMapData* mmap = loadedMMaps[mapId];
- for (MMapTileSet::iterator i = mmap->mmapLoadedTiles.begin(); i != mmap->mmapLoadedTiles.end(); ++i)
+ MMapData* mmap = _loadedMaps[mapId];
+ for (MMapTileSet::iterator i = mmap->_loadedTiles.begin(); i != mmap->_loadedTiles.end(); ++i)
{
uint32 x = (i->first >> 16);
uint32 y = (i->first & 0x0000FFFF);
if (dtStatusFailed(mmap->navMesh->removeTile(i->second, NULL, NULL)))
- TC_LOG_ERROR("maps", "MMAP:unloadMap: Could not unload %03u%02i%02i.mmtile from navmesh", mapId, x, y);
+ TC_LOG_ERROR("maps", "MMAP::UnloadMap: Could not unload %03u%02u%02u.mmtile from navmesh", mapId, x, y);
else
{
- --loadedTiles;
- TC_LOG_INFO("maps", "MMAP:unloadMap: Unloaded mmtile %03i[%02i, %02i] from %03i", mapId, x, y, mapId);
+ --_loadedTiles;
+ TC_LOG_INFO("maps", "MMAP::UnloadMap: Unloaded mmtile [%02u, %02u] from %03u", x, y, mapId);
}
}
delete mmap;
- loadedMMaps.erase(mapId);
- TC_LOG_INFO("maps", "MMAP:unloadMap: Unloaded %03i.mmap", mapId);
+ _loadedMaps.erase(mapId);
+ TC_LOG_INFO("maps", "MMAP::UnloadMap: Unloaded %03u.mmap", mapId);
return true;
}
- bool MMapManager::unloadMapInstance(uint32 mapId, uint32 instanceId)
+ bool MMapManager::UnloadMapInstance(uint32 mapId, uint32 instanceId)
{
// check if we have this map loaded
- if (loadedMMaps.find(mapId) == loadedMMaps.end())
+ if (_loadedMaps.find(mapId) == _loadedMaps.end())
{
// file may not exist, therefore not loaded
- TC_LOG_DEBUG("maps", "MMAP:unloadMapInstance: Asked to unload not loaded navmesh map %03u", mapId);
+ TC_LOG_DEBUG("maps", "MMAP::UnloadMapInstance: Asked to unload not loaded navmesh map %03u", mapId);
return false;
}
- MMapData* mmap = loadedMMaps[mapId];
- if (mmap->navMeshQueries.find(instanceId) == mmap->navMeshQueries.end())
+ MMapData* mmap = _loadedMaps[mapId];
+ if (mmap->_navMeshQueries.find(instanceId) == mmap->_navMeshQueries.end())
{
- TC_LOG_DEBUG("maps", "MMAP:unloadMapInstance: Asked to unload not loaded dtNavMeshQuery mapId %03u instanceId %u", mapId, instanceId);
+ TC_LOG_DEBUG("maps", "MMAP::UnloadMapInstance: Asked to unload not loaded dtNavMeshQuery mapId %03u instanceId %u", mapId, instanceId);
return false;
}
- dtNavMeshQuery* query = mmap->navMeshQueries[instanceId];
+ dtNavMeshQuery* query = mmap->_navMeshQueries[instanceId];
dtFreeNavMeshQuery(query);
- mmap->navMeshQueries.erase(instanceId);
- TC_LOG_INFO("maps", "MMAP:unloadMapInstance: Unloaded mapId %03u instanceId %u", mapId, instanceId);
+ mmap->_navMeshQueries.erase(instanceId);
+ TC_LOG_INFO("maps", "MMAP::UnloadMapInstance: Unloaded mapId %03u instanceId %u", mapId, instanceId);
return true;
}
dtNavMesh const* MMapManager::GetNavMesh(uint32 mapId)
{
- if (loadedMMaps.find(mapId) == loadedMMaps.end())
+ if (_loadedMaps.find(mapId) == _loadedMaps.end())
return NULL;
- return loadedMMaps[mapId]->navMesh;
+ return _loadedMaps[mapId]->navMesh;
}
dtNavMeshQuery const* MMapManager::GetNavMeshQuery(uint32 mapId, uint32 instanceId)
{
- if (loadedMMaps.find(mapId) == loadedMMaps.end())
+ if (_loadedMaps.find(mapId) == _loadedMaps.end())
return NULL;
- MMapData* mmap = loadedMMaps[mapId];
- if (mmap->navMeshQueries.find(instanceId) == mmap->navMeshQueries.end())
+ MMapData* mmap = _loadedMaps[mapId];
+ if (mmap->_navMeshQueries.find(instanceId) == mmap->_navMeshQueries.end())
{
// allocate mesh query
dtNavMeshQuery* query = dtAllocNavMeshQuery();
- ASSERT(query);
- if (dtStatusFailed(query->init(mmap->navMesh, 1024)))
+ if (dtStatusFailed(query->init(mmap->navMesh, 2048)))
{
dtFreeNavMeshQuery(query);
- TC_LOG_ERROR("maps", "MMAP:GetNavMeshQuery: Failed to initialize dtNavMeshQuery for mapId %03u instanceId %u", mapId, instanceId);
+ TC_LOG_ERROR("maps", "MMAP::GetNavMeshQuery: Failed to initialize dtNavMeshQuery for mapId %03u instanceId %u", mapId, instanceId);
return NULL;
}
TC_LOG_INFO("maps", "MMAP:GetNavMeshQuery: created dtNavMeshQuery for mapId %03u instanceId %u", mapId, instanceId);
- mmap->navMeshQueries.insert(std::pair<uint32, dtNavMeshQuery*>(instanceId, query));
+ mmap->_navMeshQueries.insert(std::pair<uint32, dtNavMeshQuery*>(instanceId, query));
}
- return mmap->navMeshQueries[instanceId];
+ return mmap->_navMeshQueries[instanceId];
}
}
diff --git a/src/server/collision/Management/MMapManager.h b/src/server/collision/Management/MMapManager.h
index 9a04d638805..9d90d1bb2af 100644
--- a/src/server/collision/Management/MMapManager.h
+++ b/src/server/collision/Management/MMapManager.h
@@ -36,7 +36,7 @@ namespace MMAP
MMapData(dtNavMesh* mesh) : navMesh(mesh) { }
~MMapData()
{
- for (NavMeshQuerySet::iterator i = navMeshQueries.begin(); i != navMeshQueries.end(); ++i)
+ for (NavMeshQuerySet::iterator i = _navMeshQueries.begin(); i != _navMeshQueries.end(); ++i)
dtFreeNavMeshQuery(i->second);
if (navMesh)
@@ -46,8 +46,8 @@ namespace MMAP
dtNavMesh* navMesh;
// we have to use single dtNavMeshQuery for every instance, since those are not thread safe
- NavMeshQuerySet navMeshQueries; // instanceId to query
- MMapTileSet mmapLoadedTiles; // maps [map grid coords] to [dtTile]
+ NavMeshQuerySet _navMeshQueries; // instanceId to query
+ MMapTileSet _loadedTiles; // maps [map grid coords] to [dtTile]
};
@@ -58,26 +58,27 @@ namespace MMAP
class MMapManager
{
public:
- MMapManager() : loadedTiles(0) { }
+ MMapManager() : _loadedTiles(0) {}
+
~MMapManager();
- bool loadMap(const std::string& basePath, uint32 mapId, int32 x, int32 y);
- bool unloadMap(uint32 mapId, int32 x, int32 y);
- bool unloadMap(uint32 mapId);
- bool unloadMapInstance(uint32 mapId, uint32 instanceId);
+ bool LoadMapTile(uint32 mapId, int32 x, int32 y);
+ bool UnloadMapTile(uint32 mapId, int32 x, int32 y);
+ bool UnloadMap(uint32 mapId);
+ bool UnloadMapInstance(uint32 mapId, uint32 instanceId);
// the returned [dtNavMeshQuery const*] is NOT threadsafe
dtNavMeshQuery const* GetNavMeshQuery(uint32 mapId, uint32 instanceId);
dtNavMesh const* GetNavMesh(uint32 mapId);
- uint32 getLoadedTilesCount() const { return loadedTiles; }
- uint32 getLoadedMapsCount() const { return loadedMMaps.size(); }
+ uint32 GetLoadedTilesCount() const { return _loadedTiles; }
+ uint32 GetLoadedMapsCount() const { return _loadedMaps.size(); }
private:
- bool loadMapData(uint32 mapId);
- uint32 packTileID(int32 x, int32 y);
+ bool LoadMap(uint32 mapId);
+ uint32 PackTileId(int32 x, int32 y) { return uint32(x << 16 | y); }
- MMapDataSet loadedMMaps;
- uint32 loadedTiles;
+ MMapDataSet _loadedMaps;
+ uint32 _loadedTiles;
};
}
diff --git a/src/server/game/AI/CoreAI/GameObjectAI.h b/src/server/game/AI/CoreAI/GameObjectAI.h
index 0d5af4f8802..7c0e04aa957 100644
--- a/src/server/game/AI/CoreAI/GameObjectAI.h
+++ b/src/server/game/AI/CoreAI/GameObjectAI.h
@@ -22,6 +22,7 @@
#include "Define.h"
#include <list>
#include "Object.h"
+#include "QuestDef.h"
#include "GameObject.h"
#include "CreatureAI.h"
@@ -51,7 +52,7 @@ class GameObjectAI
virtual bool GossipSelectCode(Player* /*player*/, uint32 /*sender*/, uint32 /*action*/, char const* /*code*/) { return false; }
virtual bool QuestAccept(Player* /*player*/, Quest const* /*quest*/) { return false; }
virtual bool QuestReward(Player* /*player*/, Quest const* /*quest*/, uint32 /*opt*/) { return false; }
- virtual uint32 GetDialogStatus(Player* /*player*/) { return 100; }
+ virtual uint32 GetDialogStatus(Player* /*player*/) { return DIALOG_STATUS_SCRIPTED_NO_STATUS; }
virtual void Destroyed(Player* /*player*/, uint32 /*eventId*/) { }
virtual uint32 GetData(uint32 /*id*/) const { return 0; }
virtual void SetData64(uint32 /*id*/, uint64 /*value*/) { }
diff --git a/src/server/game/AI/CoreAI/PetAI.cpp b/src/server/game/AI/CoreAI/PetAI.cpp
index 18daf1ef8de..bc131724484 100644
--- a/src/server/game/AI/CoreAI/PetAI.cpp
+++ b/src/server/game/AI/CoreAI/PetAI.cpp
@@ -131,7 +131,7 @@ void PetAI::UpdateAI(uint32 diff)
HandleReturnMovement();
}
- // Autocast (casted only in combat or persistent spells in any state)
+ // Autocast (cast only in combat or persistent spells in any state)
if (!me->HasUnitState(UNIT_STATE_CASTING))
{
typedef std::vector<std::pair<Unit*, Spell*> > TargetSpellList;
diff --git a/src/server/game/AI/CoreAI/TotemAI.cpp b/src/server/game/AI/CoreAI/TotemAI.cpp
index 464021e1e53..9d751976f84 100644
--- a/src/server/game/AI/CoreAI/TotemAI.cpp
+++ b/src/server/game/AI/CoreAI/TotemAI.cpp
@@ -52,7 +52,7 @@ void TotemAI::UpdateAI(uint32 /*diff*/)
if (me->ToTotem()->GetTotemType() != TOTEM_ACTIVE)
return;
- if (!me->IsAlive() || me->IsNonMeleeSpellCasted(false))
+ if (!me->IsAlive() || me->IsNonMeleeSpellCast(false))
return;
// Search spell
diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp
index c70fc45be33..6d5ddfcae2b 100644
--- a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp
+++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp
@@ -156,7 +156,7 @@ void ScriptedAI::DoStopAttack()
void ScriptedAI::DoCastSpell(Unit* target, SpellInfo const* spellInfo, bool triggered)
{
- if (!target || me->IsNonMeleeSpellCasted(false))
+ if (!target || me->IsNonMeleeSpellCast(false))
return;
me->StopMoving();
diff --git a/src/server/game/AI/SmartScripts/SmartAI.cpp b/src/server/game/AI/SmartScripts/SmartAI.cpp
index 1ced9e79672..8b914d7ca20 100644
--- a/src/server/game/AI/SmartScripts/SmartAI.cpp
+++ b/src/server/game/AI/SmartScripts/SmartAI.cpp
@@ -905,7 +905,10 @@ bool SmartGameObjectAI::QuestReward(Player* player, Quest const* quest, uint32 o
}
// Called when the dialog status between a player and the gameobject is requested.
-uint32 SmartGameObjectAI::GetDialogStatus(Player* /*player*/) { return 100; }
+uint32 SmartGameObjectAI::GetDialogStatus(Player* /*player*/)
+{
+ return DIALOG_STATUS_SCRIPTED_NO_STATUS;
+}
// Called when the gameobject is destroyed (destructible buildings only).
void SmartGameObjectAI::Destroyed(Player* player, uint32 eventId)
diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp
index a45e45e58c2..b90ca2ed8cc 100644
--- a/src/server/game/AI/SmartScripts/SmartScript.cpp
+++ b/src/server/game/AI/SmartScripts/SmartScript.cpp
@@ -17,6 +17,7 @@
#include "Cell.h"
#include "CellImpl.h"
+#include "Chat.h"
#include "CreatureTextMgr.h"
#include "DatabaseEnv.h"
#include "GossipDef.h"
@@ -40,41 +41,22 @@
class TrinityStringTextBuilder
{
public:
- TrinityStringTextBuilder(WorldObject* obj, ChatMsg msgtype, int32 id, uint32 language, uint64 targetGUID)
- : _source(obj), _msgType(msgtype), _textId(id), _language(language), _targetGUID(targetGUID)
+ TrinityStringTextBuilder(WorldObject* obj, ChatMsg msgtype, int32 id, uint32 language, WorldObject* target)
+ : _source(obj), _msgType(msgtype), _textId(id), _language(language), _target(target)
{
}
size_t operator()(WorldPacket* data, LocaleConstant locale) const
{
std::string text = sObjectMgr->GetTrinityString(_textId, locale);
- std::string localizedName = _source->GetNameForLocaleIdx(locale);
-
- *data << uint8(_msgType);
- *data << uint32(_language);
- *data << uint64(_source->GetGUID());
- *data << uint32(1); // 2.1.0
- *data << uint32(localizedName.size() + 1);
- *data << localizedName;
- size_t whisperGUIDpos = data->wpos();
- *data << uint64(_targetGUID); // Unit Target
- if (_targetGUID && !IS_PLAYER_GUID(_targetGUID))
- {
- *data << uint32(1); // target name length
- *data << uint8(0); // target name
- }
- *data << uint32(text.length() + 1);
- *data << text;
- *data << uint8(0); // ChatTag
-
- return whisperGUIDpos;
+ return ChatHandler::BuildChatPacket(*data, _msgType, Language(_language), _source, _target, text, 0, "", locale);
}
WorldObject* _source;
ChatMsg _msgType;
int32 _textId;
uint32 _language;
- uint64 _targetGUID;
+ WorldObject* _target;
};
SmartScript::SmartScript()
@@ -547,7 +529,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
me->GetGUIDLow(), e.action.cast.spell, (*itr)->GetGUIDLow(), e.action.cast.flags);
}
else
- TC_LOG_DEBUG("scripts.ai", "Spell %u not casted because it has flag SMARTCAST_AURA_NOT_PRESENT and the target (Guid: " UI64FMTD " Entry: %u Type: %u) already has the aura", e.action.cast.spell, (*itr)->GetGUID(), (*itr)->GetEntry(), uint32((*itr)->GetTypeId()));
+ TC_LOG_DEBUG("scripts.ai", "Spell %u not cast because it has flag SMARTCAST_AURA_NOT_PRESENT and the target (Guid: " UI64FMTD " Entry: %u Type: %u) already has the aura", e.action.cast.spell, (*itr)->GetGUID(), (*itr)->GetEntry(), uint32((*itr)->GetTypeId()));
}
delete targets;
@@ -578,7 +560,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
tempLastInvoker->GetGUIDLow(), e.action.cast.spell, (*itr)->GetGUIDLow(), e.action.cast.flags);
}
else
- TC_LOG_DEBUG("scripts.ai", "Spell %u not casted because it has flag SMARTCAST_AURA_NOT_PRESENT and the target (Guid: " UI64FMTD " Entry: %u Type: %u) already has the aura", e.action.cast.spell, (*itr)->GetGUID(), (*itr)->GetEntry(), uint32((*itr)->GetTypeId()));
+ TC_LOG_DEBUG("scripts.ai", "Spell %u not cast because it has flag SMARTCAST_AURA_NOT_PRESENT and the target (Guid: " UI64FMTD " Entry: %u Type: %u) already has the aura", e.action.cast.spell, (*itr)->GetGUID(), (*itr)->GetEntry(), uint32((*itr)->GetTypeId()));
}
delete targets;
@@ -777,7 +759,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
me->DoFleeToGetAssistance();
if (e.action.flee.withEmote)
{
- TrinityStringTextBuilder builder(me, CHAT_MSG_MONSTER_EMOTE, LANG_FLEE, LANG_UNIVERSAL, 0);
+ TrinityStringTextBuilder builder(me, CHAT_MSG_MONSTER_EMOTE, LANG_FLEE, LANG_UNIVERSAL, NULL);
sCreatureTextMgr->SendChatPacket(me, builder, CHAT_MSG_MONSTER_EMOTE);
}
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_FLEE_FOR_ASSIST: Creature %u DoFleeToGetAssistance", me->GetGUIDLow());
@@ -1020,7 +1002,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
me->CallForHelp((float)e.action.callHelp.range);
if (e.action.callHelp.withEmote)
{
- TrinityStringTextBuilder builder(me, CHAT_MSG_MONSTER_EMOTE, LANG_CALL_FOR_HELP, LANG_UNIVERSAL, 0);
+ TrinityStringTextBuilder builder(me, CHAT_MSG_MONSTER_EMOTE, LANG_CALL_FOR_HELP, LANG_UNIVERSAL, NULL);
sCreatureTextMgr->SendChatPacket(me, builder, CHAT_MSG_MONSTER_EMOTE);
}
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction: SMART_ACTION_CALL_FOR_HELP: Creature %u", me->GetGUIDLow());
@@ -1747,7 +1729,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
unit->CastSpell((*it)->ToUnit(), e.action.cast.spell, (e.action.cast.flags & SMARTCAST_TRIGGERED));
}
else
- TC_LOG_DEBUG("scripts.ai", "Spell %u not casted because it has flag SMARTCAST_AURA_NOT_PRESENT and the target (Guid: " UI64FMTD " Entry: %u Type: %u) already has the aura", e.action.cast.spell, (*it)->GetGUID(), (*it)->GetEntry(), uint32((*it)->GetTypeId()));
+ TC_LOG_DEBUG("scripts.ai", "Spell %u not cast because it has flag SMARTCAST_AURA_NOT_PRESENT and the target (Guid: " UI64FMTD " Entry: %u Type: %u) already has the aura", e.action.cast.spell, (*it)->GetGUID(), (*it)->GetEntry(), uint32((*it)->GetTypeId()));
}
}
@@ -2748,7 +2730,7 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui
Unit* victim = me->GetVictim();
- if (!victim || !victim->IsNonMeleeSpellCasted(false, false, true))
+ if (!victim || !victim->IsNonMeleeSpellCast(false, false, true))
return;
if (e.event.targetCasting.spellId > 0)
@@ -3174,12 +3156,12 @@ void SmartScript::UpdateTimer(SmartScriptHolder& e, uint32 const diff)
if (e.GetEventType() == SMART_EVENT_UPDATE_IC && (!me || !me->IsInCombat()))
return;
- if (e.GetEventType() == SMART_EVENT_UPDATE_OOC && (me && me->IsInCombat()))//can be used with me=NULL (go script)
+ if (e.GetEventType() == SMART_EVENT_UPDATE_OOC && (me && me->IsInCombat())) //can be used with me=NULL (go script)
return;
if (e.timer < diff)
{
- // delay spell cast event if another spell is being casted
+ // delay spell cast event if another spell is being cast
if (e.GetActionType() == SMART_ACTION_CAST)
{
if (!(e.action.cast.flags & SMARTCAST_INTERRUPT_PREVIOUS))
diff --git a/src/server/game/Achievements/AchievementMgr.cpp b/src/server/game/Achievements/AchievementMgr.cpp
index 03aabefcd88..e97fcfaa1ad 100644
--- a/src/server/game/Achievements/AchievementMgr.cpp
+++ b/src/server/game/Achievements/AchievementMgr.cpp
@@ -1149,7 +1149,7 @@ void AchievementMgr<T>::UpdateAchievementCriteria(AchievementCriteriaTypes type,
case ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_SOLD: /* FIXME: for online player only currently */
case ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HIT_DEALT:
case ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HIT_RECEIVED:
- case ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HEAL_CASTED:
+ case ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HEAL_CAST:
case ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HEALING_RECEIVED:
SetCriteriaProgress(achievementCriteria, miscValue1, referencePlayer, PROGRESS_HIGHEST);
break;
diff --git a/src/server/game/Battlefield/Zones/BattlefieldWG.cpp b/src/server/game/Battlefield/Zones/BattlefieldWG.cpp
index a5602a1b415..67288e0fadb 100644
--- a/src/server/game/Battlefield/Zones/BattlefieldWG.cpp
+++ b/src/server/game/Battlefield/Zones/BattlefieldWG.cpp
@@ -804,7 +804,7 @@ uint32 BattlefieldWG::GetData(uint32 data) const
{
switch (data)
{
- // Used to determine when the phasing spells must be casted
+ // Used to determine when the phasing spells must be cast
// See: SpellArea::IsFitToRequirements
case AREA_THE_SUNKEN_RING:
case AREA_THE_BROKEN_TEMPLATE:
diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundDS.h b/src/server/game/Battlegrounds/Zones/BattlegroundDS.h
index cdfbbc480bb..74c5e70a633 100644
--- a/src/server/game/Battlegrounds/Zones/BattlegroundDS.h
+++ b/src/server/game/Battlegrounds/Zones/BattlegroundDS.h
@@ -58,7 +58,7 @@ enum BattlegroundDSCreatures
enum BattlegroundDSSpells
{
BG_DS_SPELL_FLUSH = 57405, // Visual and target selector for the starting knockback from the pipe
- BG_DS_SPELL_FLUSH_KNOCKBACK = 61698, // Knockback effect for previous spell (triggered, not need to be casted)
+ BG_DS_SPELL_FLUSH_KNOCKBACK = 61698, // Knockback effect for previous spell (triggered, not needed to be cast)
BG_DS_SPELL_WATER_SPOUT = 58873 // Knockback effect of the central waterfall
};
diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp
index aa3568a62d5..5ebef030518 100644
--- a/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp
+++ b/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp
@@ -397,10 +397,8 @@ bool BattlegroundIC::SetupBattleground()
return false;
}
- //Send transport init packet to all player in map
- for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
- if (Player* player = ObjectAccessor::FindPlayer(itr->first))
- GetBgMap()->SendInitTransports(player);
+ gunshipHorde->EnableMovement(false);
+ gunshipAlliance->EnableMovement(false);
// setting correct factions for Keep Cannons
for (uint8 i = BG_IC_NPC_KEEP_CANNON_1; i < BG_IC_NPC_KEEP_CANNON_12; ++i)
diff --git a/src/server/game/Chat/Channels/Channel.cpp b/src/server/game/Chat/Channels/Channel.cpp
index c65d76cecd0..1faa168b3a8 100644
--- a/src/server/game/Chat/Channels/Channel.cpp
+++ b/src/server/game/Chat/Channels/Channel.cpp
@@ -600,14 +600,6 @@ void Channel::Say(uint64 guid, std::string const& what, uint32 lang)
if (what.empty())
return;
- uint8 chatTag = 0;
- bool isGM = false;
- if (Player* player = ObjectAccessor::FindPlayer(guid))
- {
- chatTag = player->GetChatTag();
- isGM = player->GetSession()->HasPermission(rbac::RBAC_PERM_COMMAND_GM_CHAT);
- }
-
// TODO: Add proper RBAC check
if (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL))
lang = LANG_UNIVERSAL;
@@ -629,7 +621,11 @@ void Channel::Say(uint64 guid, std::string const& what, uint32 lang)
}
WorldPacket data;
- ChatHandler::BuildChatPacket(data, CHAT_MSG_CHANNEL, Language(lang), guid, guid, what, chatTag, "", "", 0, isGM, _name);
+ if (Player* player = ObjectAccessor::FindPlayer(guid))
+ ChatHandler::BuildChatPacket(data, CHAT_MSG_CHANNEL, Language(lang), player, player, what, 0, _name);
+ else
+ ChatHandler::BuildChatPacket(data, CHAT_MSG_CHANNEL, Language(lang), guid, guid, what, 0, "", "", 0, false, _name);
+
SendToAll(&data, !playersStore[guid].IsModerator() ? guid : false);
}
diff --git a/src/server/game/DataStores/DBCEnums.h b/src/server/game/DataStores/DBCEnums.h
index 0d7d520b4fa..215ce1c594a 100644
--- a/src/server/game/DataStores/DBCEnums.h
+++ b/src/server/game/DataStores/DBCEnums.h
@@ -258,7 +258,7 @@ enum AchievementCriteriaTypes
ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HIT_DEALT = 101,
ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HIT_RECEIVED = 102,
ACHIEVEMENT_CRITERIA_TYPE_TOTAL_DAMAGE_RECEIVED = 103,
- ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HEAL_CASTED = 104,
+ ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HEAL_CAST = 104,
ACHIEVEMENT_CRITERIA_TYPE_TOTAL_HEALING_RECEIVED = 105,
ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HEALING_RECEIVED = 106,
ACHIEVEMENT_CRITERIA_TYPE_QUEST_ABANDONED = 107,
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp
index e416500f77f..949ca6324e9 100644
--- a/src/server/game/Entities/Creature/Creature.cpp
+++ b/src/server/game/Entities/Creature/Creature.cpp
@@ -1081,15 +1081,17 @@ void Creature::SelectLevel(const CreatureTemplate* cinfo)
SetModifierValue(UNIT_MOD_MANA, BASE_VALUE, (float)mana);
//damage
- //float damagemod = _GetDamageMod(rank); // Set during loading templates into dmg_multiplier field
- SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, cinfo->mindmg);
- SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, cinfo->maxdmg);
+ float basedamage = stats->GenerateBaseDamage(cinfo);
- SetFloatValue(UNIT_FIELD_MINRANGEDDAMAGE, cinfo->minrangedmg);
- SetFloatValue(UNIT_FIELD_MAXRANGEDDAMAGE, cinfo->maxrangedmg);
+ SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, ((basedamage + (stats->AttackPower / 14)) * cinfo->dmg_multiplier) * (cinfo->baseattacktime / 1000));
+ SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, (((basedamage * 1.5) + (stats->AttackPower / 14)) * cinfo->dmg_multiplier) * (cinfo->baseattacktime / 1000));
+ SetBaseWeaponDamage(RANGED_ATTACK, MINDAMAGE, (basedamage + (stats->RangedAttackPower / 14)) * (cinfo->rangeattacktime / 1000));
+ SetBaseWeaponDamage(RANGED_ATTACK, MAXDAMAGE, ((basedamage * 1.5) + (stats->RangedAttackPower / 14)) * (cinfo->rangeattacktime / 1000));
- SetModifierValue(UNIT_MOD_ATTACK_POWER, BASE_VALUE, cinfo->attackpower);
+ float damagemod = 1.0f;//_GetDamageMod(rank);
+
+ SetModifierValue(UNIT_MOD_ATTACK_POWER, BASE_VALUE, stats->AttackPower * damagemod);
}
@@ -1484,7 +1486,7 @@ void Creature::setDeathState(DeathState s)
CreatureTemplate const* cinfo = GetCreatureTemplate();
SetUInt32Value(UNIT_NPC_FLAGS, cinfo->npcflag);
- ClearUnitState(uint32(UNIT_STATE_ALL_STATE));
+ ClearUnitState(uint32(UNIT_STATE_ALL_STATE & ~UNIT_STATE_IGNORE_PATHFINDING));
SetMeleeDamageSchool(SpellSchools(cinfo->dmgschool));
LoadCreaturesAddon(true);
Motion_Initialize();
diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h
index d54a1a61258..6599bab80c7 100644
--- a/src/server/game/Entities/Creature/Creature.h
+++ b/src/server/game/Entities/Creature/Creature.h
@@ -175,6 +175,7 @@ struct CreatureTemplate
// Benchmarked: Faster than std::map (insert/find)
typedef UNORDERED_MAP<uint32, CreatureTemplate> CreatureTemplateContainer;
+#define MAX_CREATURE_BASE_DAMAGE 3
// GCC have alternative #pragma pack(N) syntax and old gcc version not support pack(push, N), also any gcc version not support it at some platform
#if defined(__GNUC__)
#pragma pack(1)
@@ -182,12 +183,15 @@ typedef UNORDERED_MAP<uint32, CreatureTemplate> CreatureTemplateContainer;
#pragma pack(push, 1)
#endif
-// Defines base stats for creatures (used to calculate HP/mana/armor).
+// Defines base stats for creatures (used to calculate HP/mana/armor/attackpower/rangedattackpower/all damage).
struct CreatureBaseStats
{
uint32 BaseHealth[MAX_CREATURE_BASE_HP];
uint32 BaseMana;
uint32 BaseArmor;
+ uint32 AttackPower;
+ uint32 RangedAttackPower;
+ float BaseDamage[MAX_CREATURE_BASE_DAMAGE];
// Helpers
@@ -210,6 +214,11 @@ struct CreatureBaseStats
return uint32(ceil(BaseArmor * info->ModArmor));
}
+ float GenerateBaseDamage(CreatureTemplate const* info) const
+ {
+ return BaseDamage[info->expansion];
+ }
+
static CreatureBaseStats const* GetBaseStats(uint8 level, uint8 unitClass);
};
diff --git a/src/server/game/Entities/Creature/GossipDef.cpp b/src/server/game/Entities/Creature/GossipDef.cpp
index 1af9b7fa73a..5b9f92103e3 100644
--- a/src/server/game/Entities/Creature/GossipDef.cpp
+++ b/src/server/game/Entities/Creature/GossipDef.cpp
@@ -297,7 +297,7 @@ void QuestMenu::ClearMenu()
_questMenuItems.clear();
}
-void PlayerMenu::SendQuestGiverQuestList(QEmote eEmote, const std::string& Title, uint64 npcGUID)
+void PlayerMenu::SendQuestGiverQuestList(QEmote const& eEmote, const std::string& Title, uint64 npcGUID)
{
WorldPacket data(SMSG_QUESTGIVER_QUEST_LIST, 100); // guess size
data << uint64(npcGUID);
@@ -480,8 +480,8 @@ void PlayerMenu::SendQuestQueryResponse(Quest const* quest) const
data << uint32(quest->GetRewOrReqMoney()); // reward money (below max lvl)
data << uint32(quest->GetRewMoneyMaxLevel()); // used in XP calculation at client
- data << uint32(quest->GetRewSpell()); // reward spell, this spell will display (icon) (casted if RewSpellCast == 0)
- data << int32(quest->GetRewSpellCast()); // casted spell
+ data << uint32(quest->GetRewSpell()); // reward spell, this spell will display (icon) (cast if RewSpellCast == 0)
+ data << int32(quest->GetRewSpellCast()); // cast spell
// rewarded honor points
data << uint32(quest->GetRewHonorAddition());
diff --git a/src/server/game/Entities/Creature/GossipDef.h b/src/server/game/Entities/Creature/GossipDef.h
index c76febc0165..8c720c5f550 100644
--- a/src/server/game/Entities/Creature/GossipDef.h
+++ b/src/server/game/Entities/Creature/GossipDef.h
@@ -273,7 +273,7 @@ class PlayerMenu
/*********************************************************/
void SendQuestGiverStatus(uint32 questStatus, uint64 npcGUID) const;
- void SendQuestGiverQuestList(QEmote eEmote, const std::string& Title, uint64 npcGUID);
+ void SendQuestGiverQuestList(QEmote const& eEmote, const std::string& Title, uint64 npcGUID);
void SendQuestQueryResponse(Quest const* quest) const;
void SendQuestGiverQuestDetails(Quest const* quest, uint64 npcGUID, bool activateAccept) const;
diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp
index 97287aabe3c..d36a1bad93e 100644
--- a/src/server/game/Entities/GameObject/GameObject.cpp
+++ b/src/server/game/Entities/GameObject/GameObject.cpp
@@ -652,7 +652,7 @@ void GameObject::Update(uint32 diff)
void GameObject::Refresh()
{
- // not refresh despawned not casted GO (despawned casted GO destroyed in all cases anyway)
+ // Do not refresh despawned GO from spellcast (GO's from spellcast are destroyed after despawn)
if (m_respawnTime > 0 && m_spawnedByDefault)
return;
@@ -1486,7 +1486,7 @@ void GameObject::Use(Unit* user)
if (spellId == 62330) // GO store nonexistent spell, replace by expected
{
// spell have reagent and mana cost but it not expected use its
- // it triggered spell in fact casted at currently channeled GO
+ // it triggered spell in fact cast at currently channeled GO
spellId = 61993;
triggered = true;
}
diff --git a/src/server/game/Entities/Item/Item.cpp b/src/server/game/Entities/Item/Item.cpp
index 01dfd92e34c..98eaec87817 100644
--- a/src/server/game/Entities/Item/Item.cpp
+++ b/src/server/game/Entities/Item/Item.cpp
@@ -103,7 +103,7 @@ void AddItemsSetItem(Player* player, Item* item)
break;
}
- // spell casted only if fit form requirement, in other case will casted at form change
+ // spell cast only if fit form requirement, in other case will cast at form change
player->ApplyEquipSpell(spellInfo, NULL, true);
eff->spells[y] = spellInfo;
break;
diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp
index 149560fd891..74d05ca58ea 100644
--- a/src/server/game/Entities/Object/Object.cpp
+++ b/src/server/game/Entities/Object/Object.cpp
@@ -1738,6 +1738,10 @@ void WorldObject::UpdateGroundPositionZ(float x, float y, float &z) const
void WorldObject::UpdateAllowedPositionZ(float x, float y, float &z) const
{
+ // TODO: Allow transports to be part of dynamic vmap tree
+ if (GetTransport())
+ return;
+
switch (GetTypeId())
{
case TYPEID_UNIT:
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 45381864aac..f9d96225e3f 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -2198,7 +2198,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
SetSemaphoreTeleportFar(false);
//setup delayed teleport flag
SetDelayedTeleportFlag(IsCanDelayTeleport());
- //if teleport spell is casted in Unit::Update() func
+ //if teleport spell is cast in Unit::Update() func
//then we need to delay it until update process will be finished
if (IsHasDelayedTeleport())
{
@@ -2261,7 +2261,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
SetSemaphoreTeleportNear(false);
//setup delayed teleport flag
SetDelayedTeleportFlag(IsCanDelayTeleport());
- //if teleport spell is casted in Unit::Update() func
+ //if teleport spell is cast in Unit::Update() func
//then we need to delay it until update process will be finished
if (IsHasDelayedTeleport())
{
@@ -2307,7 +2307,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
// stop spellcasting
// not attempt interrupt teleportation spell at caster teleport
if (!(options & TELE_TO_SPELL))
- if (IsNonMeleeSpellCasted(true))
+ if (IsNonMeleeSpellCast(true))
InterruptNonMeleeSpells(true);
//remove auras before removing from map...
@@ -8713,7 +8713,7 @@ void Player::CastItemCombatSpell(Unit* target, WeaponAttackType attType, uint32
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(pEnchant->spellid[s]);
if (!spellInfo)
{
- TC_LOG_ERROR("entities.player.items", "Player::CastItemCombatSpell(GUID: %u, name: %s, enchant: %i): unknown spell %i is casted, ignoring...",
+ TC_LOG_ERROR("entities.player.items", "Player::CastItemCombatSpell(GUID: %u, name: %s, enchant: %i): unknown spell %i is cast, ignoring...",
GetGUIDLow(), GetName().c_str(), pEnchant->ID, pEnchant->spellid[s]);
continue;
}
@@ -8774,7 +8774,7 @@ void Player::CastItemUseSpell(Item* item, SpellCastTargets const& targets, uint8
// use triggered flag only for items with many spell casts and for not first cast
uint8 count = 0;
- // item spells casted at use
+ // item spells cast at use
for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
{
_Spell const& spellData = proto->Spells[i];
@@ -8803,7 +8803,7 @@ void Player::CastItemUseSpell(Item* item, SpellCastTargets const& targets, uint8
++count;
}
- // Item enchantments spells casted at use
+ // Item enchantments spells cast at use
for (uint8 e_slot = 0; e_slot < MAX_ENCHANTMENT_SLOT; ++e_slot)
{
if (e_slot > PRISMATIC_ENCHANTMENT_SLOT && e_slot < PROP_ENCHANTMENT_SLOT_0) // not holding enchantment id
@@ -11464,7 +11464,7 @@ InventoryResult Player::CanEquipItem(uint8 slot, uint16 &dest, Item* pItem, bool
if (IsInCombat()&& (pProto->Class == ITEM_CLASS_WEAPON || pProto->InventoryType == INVTYPE_RELIC) && m_weaponChangeTimer != 0)
return EQUIP_ERR_CLIENT_LOCKED_OUT; // maybe exist better err
- if (IsNonMeleeSpellCasted(false))
+ if (IsNonMeleeSpellCast(false))
return EQUIP_ERR_CLIENT_LOCKED_OUT;
}
@@ -21395,7 +21395,7 @@ bool Player::ActivateTaxiPathTo(std::vector<uint32> const& nodes, Creature* npc
}
// not let cheating with start flight in time of logout process || if casting not finished || while in combat || if not use Spell's with EffectSendTaxi
- if (IsNonMeleeSpellCasted(false))
+ if (IsNonMeleeSpellCast(false))
{
GetSession()->SendActivateTaxiReply(ERR_TAXIPLAYERBUSY);
return false;
@@ -24149,7 +24149,7 @@ void Player::RemoveItemDependentAurasAndCasts(Item* pItem)
RemoveOwnedAura(itr);
}
- // currently casted spells can be dependent from item
+ // currently cast spells can be dependent from item
for (uint32 i = 0; i < CURRENT_MAX_SPELL; ++i)
if (Spell* spell = GetCurrentSpell(CurrentSpellTypes(i)))
if (spell->getState() != SPELL_STATE_DELAYED && !HasItemFitToSpellRequirements(spell->m_spellInfo, pItem))
@@ -26514,7 +26514,7 @@ void Player::ActivateSpec(uint8 spec)
if (spec > GetSpecsCount())
return;
- if (IsNonMeleeSpellCasted(false))
+ if (IsNonMeleeSpellCast(false))
InterruptNonMeleeSpells(false);
SQLTransaction trans = CharacterDatabase.BeginTransaction();
diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h
index 17deabeba70..bec86f9ce90 100644
--- a/src/server/game/Entities/Player/Player.h
+++ b/src/server/game/Entities/Player/Player.h
@@ -1120,7 +1120,7 @@ class TradeData
uint64 m_money; // m_player place money to trade
uint32 m_spell; // m_player apply spell to non-traded slot item
- uint64 m_spellCastItem; // applied spell casted by item use
+ uint64 m_spellCastItem; // applied spell cast by item use
uint64 m_items[TRADE_SLOT_COUNT]; // traded items from m_player side including non-traded slot
};
diff --git a/src/server/game/Entities/Transport/Transport.cpp b/src/server/game/Entities/Transport/Transport.cpp
index 9026f4c0e46..b1d8c02f41d 100644
--- a/src/server/game/Entities/Transport/Transport.cpp
+++ b/src/server/game/Entities/Transport/Transport.cpp
@@ -90,8 +90,7 @@ bool Transport::Create(uint32 guidlow, uint32 entry, uint32 mapid, float x, floa
SetPeriod(tInfo->pathTime);
SetEntry(goinfo->entry);
SetDisplayId(goinfo->displayId);
- SetGoState(GO_STATE_READY);
- _pendingStop = goinfo->moTransport.canBeStopped != 0;
+ SetGoState(!goinfo->moTransport.canBeStopped ? GO_STATE_READY : GO_STATE_ACTIVE);
SetGoType(GAMEOBJECT_TYPE_MO_TRANSPORT);
SetGoAnimProgress(animprogress);
SetName(goinfo->name);
@@ -111,7 +110,8 @@ void Transport::Update(uint32 diff)
if (GetKeyFrames().size() <= 1)
return;
- m_goValue.Transport.PathProgress += diff;
+ if (IsMoving() || !_pendingStop)
+ m_goValue.Transport.PathProgress += diff;
uint32 timer = m_goValue.Transport.PathProgress % GetPeriod();
@@ -132,31 +132,23 @@ void Transport::Update(uint32 diff)
if (timer < _currentFrame->DepartureTime)
{
SetMoving(false);
- if (_pendingStop)
+ if (_pendingStop && GetGoState() != GO_STATE_READY)
+ {
SetGoState(GO_STATE_READY);
+ m_goValue.Transport.PathProgress = (m_goValue.Transport.PathProgress / GetPeriod());
+ m_goValue.Transport.PathProgress *= GetPeriod();
+ m_goValue.Transport.PathProgress += _currentFrame->ArriveTime;
+ }
break; // its a stop frame and we are waiting
}
}
- if (_pendingStop && timer >= _currentFrame->DepartureTime && GetGoState() == GO_STATE_READY)
- {
- m_goValue.Transport.PathProgress = (m_goValue.Transport.PathProgress / GetPeriod());
- m_goValue.Transport.PathProgress *= GetPeriod();
- m_goValue.Transport.PathProgress += _currentFrame->ArriveTime;
- break;
- }
-
if (timer >= _currentFrame->DepartureTime && !_triggeredDepartureEvent)
{
DoEventIfAny(*_currentFrame, true); // departure event
_triggeredDepartureEvent = true;
}
- if (timer >= _currentFrame->DepartureTime && timer < _currentFrame->NextArriveTime)
- break; // found current waypoint
-
- MoveToNextWaypoint();
-
// not waiting anymore
SetMoving(true);
@@ -164,13 +156,18 @@ void Transport::Update(uint32 diff)
if (GetGOInfo()->moTransport.canBeStopped)
SetGoState(GO_STATE_ACTIVE);
+ if (timer >= _currentFrame->DepartureTime && timer < _currentFrame->NextArriveTime)
+ break; // found current waypoint
+
+ MoveToNextWaypoint();
+
sScriptMgr->OnRelocate(this, _currentFrame->Node->index, _currentFrame->Node->mapid, _currentFrame->Node->x, _currentFrame->Node->y, _currentFrame->Node->z);
TC_LOG_DEBUG("entities.transport", "Transport %u (%s) moved to node %u %u %f %f %f", GetEntry(), GetName().c_str(), _currentFrame->Node->index, _currentFrame->Node->mapid, _currentFrame->Node->x, _currentFrame->Node->y, _currentFrame->Node->z);
// Departure event
if (_currentFrame->IsTeleportFrame())
- if (TeleportTransport(_nextFrame->Node->mapid, _nextFrame->Node->x, _nextFrame->Node->y, _nextFrame->Node->z))
+ if (TeleportTransport(_nextFrame->Node->mapid, _nextFrame->Node->x, _nextFrame->Node->y, _nextFrame->Node->z, _nextFrame->InitialOrientation))
return; // Update more in new map thread
}
@@ -185,7 +182,18 @@ void Transport::Update(uint32 diff)
G3D::Vector3 pos, dir;
_currentFrame->Spline->evaluate_percent(_currentFrame->Index, t, pos);
_currentFrame->Spline->evaluate_derivative(_currentFrame->Index, t, dir);
- UpdatePosition(pos.x, pos.y, pos.z, atan2(dir.x, dir.y));
+ UpdatePosition(pos.x, pos.y, pos.z, atan2(dir.y, dir.x) + M_PI);
+ }
+ else
+ {
+ /* There are four possible scenarios that trigger loading/unloading passengers:
+ 1. transport moves from inactive to active grid
+ 2. the grid that transport is currently in becomes active
+ 3. transport moves from active to inactive grid
+ 4. the grid that transport is currently in unloads
+ */
+ if (_staticPassengers.empty() && GetMap()->IsGridLoaded(GetPositionX(), GetPositionY())) // 2.
+ LoadStaticPassengers();
}
}
@@ -313,7 +321,7 @@ void Transport::UpdatePosition(float x, float y, float z, float o)
3. transport moves from active to inactive grid
4. the grid that transport is currently in unloads
*/
- if (_staticPassengers.empty() && newActive) // 1. and 2.
+ if (_staticPassengers.empty() && newActive) // 1.
LoadStaticPassengers();
else if (!_staticPassengers.empty() && !newActive && Cell(x, y).DiffGrid(Cell(GetPositionX(), GetPositionY()))) // 3.
UnloadStaticPassengers();
@@ -403,52 +411,24 @@ float Transport::CalculateSegmentPos(float now)
return segmentPos / frame.NextDistFromPrev;
}
-bool Transport::TeleportTransport(uint32 newMapid, float x, float y, float z)
+bool Transport::TeleportTransport(uint32 newMapid, float x, float y, float z, float o)
{
Map const* oldMap = GetMap();
if (oldMap->GetId() != newMapid)
{
Map* newMap = sMapMgr->CreateBaseMap(newMapid);
- Map::PlayerList const& oldPlayers = GetMap()->GetPlayers();
- if (!oldPlayers.isEmpty())
- {
- UpdateData data(GetMapId());
- BuildOutOfRangeUpdateBlock(&data);
- WorldPacket packet;
- data.BuildPacket(&packet);
- for (Map::PlayerList::const_iterator itr = oldPlayers.begin(); itr != oldPlayers.end(); ++itr)
- if (itr->GetSource()->GetTransport() != this)
- itr->GetSource()->SendDirectMessage(&packet);
- }
-
UnloadStaticPassengers();
GetMap()->RemoveFromMap<Transport>(this, false);
SetMap(newMap);
- Map::PlayerList const& newPlayers = GetMap()->GetPlayers();
- if (!newPlayers.isEmpty())
- {
- for (Map::PlayerList::const_iterator itr = newPlayers.begin(); itr != newPlayers.end(); ++itr)
- {
- if (itr->GetSource()->GetTransport() != this)
- {
- UpdateData data(newMapid);
- BuildCreateUpdateBlockForPlayer(&data, itr->GetSource());
- WorldPacket packet;
- data.BuildPacket(&packet);
- itr->GetSource()->SendDirectMessage(&packet);
- }
- }
- }
-
for (std::set<WorldObject*>::iterator itr = _passengers.begin(); itr != _passengers.end();)
{
WorldObject* obj = (*itr++);
float destX, destY, destZ, destO;
obj->m_movementInfo.transport.pos.GetPosition(destX, destY, destZ, destO);
- TransportBase::CalculatePassengerPosition(destX, destY, destZ, &destO, x, y, z, GetOrientation());
+ TransportBase::CalculatePassengerPosition(destX, destY, destZ, &destO, x, y, z, o);
switch (obj->GetTypeId())
{
@@ -474,7 +454,7 @@ bool Transport::TeleportTransport(uint32 newMapid, float x, float y, float z)
}
}
- Relocate(x, y, z, GetOrientation());
+ Relocate(x, y, z, o);
GetMap()->AddToMap<Transport>(this);
return true;
}
@@ -487,13 +467,13 @@ bool Transport::TeleportTransport(uint32 newMapid, float x, float y, float z)
{
float destX, destY, destZ, destO;
(*itr)->m_movementInfo.transport.pos.GetPosition(destX, destY, destZ, destO);
- TransportBase::CalculatePassengerPosition(destX, destY, destZ, &destO, x, y, z, GetOrientation());
+ TransportBase::CalculatePassengerPosition(destX, destY, destZ, &destO, x, y, z, o);
(*itr)->ToUnit()->NearTeleportTo(destX, destY, destZ, destO);
}
}
- UpdatePosition(x, y, z, GetOrientation());
+ UpdatePosition(x, y, z, o);
return false;
}
}
diff --git a/src/server/game/Entities/Transport/Transport.h b/src/server/game/Entities/Transport/Transport.h
index e290a5d5e00..b0e80ea27b3 100644
--- a/src/server/game/Entities/Transport/Transport.h
+++ b/src/server/game/Entities/Transport/Transport.h
@@ -78,7 +78,7 @@ class Transport : public GameObject, public TransportBase
private:
void MoveToNextWaypoint();
float CalculateSegmentPos(float perc);
- bool TeleportTransport(uint32 newMapid, float x, float y, float z);
+ bool TeleportTransport(uint32 newMapid, float x, float y, float z, float o);
void UpdatePassengerPositions(std::set<WorldObject*>& passengers);
void DoEventIfAny(KeyFrame const& node, bool departure);
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index 02bdc5f3a8c..0f2104bd8c2 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -1834,7 +1834,7 @@ void Unit::AttackerStateUpdate (Unit* victim, WeaponAttackType attType, bool ext
if (attType != BASE_ATTACK && attType != OFF_ATTACK)
return; // ignore ranged case
- // melee attack spell casted at main hand attack only - no normal melee dmg dealt
+ // melee attack spell cast at main hand attack only - no normal melee dmg dealt
if (attType == BASE_ATTACK && m_currentSpells[CURRENT_MELEE_SPELL] && !extra)
m_currentSpells[CURRENT_MELEE_SPELL]->cast();
else
@@ -2496,7 +2496,7 @@ uint32 Unit::GetUnitMeleeSkill(Unit const* target) const
float Unit::GetUnitDodgeChance() const
{
- if (IsNonMeleeSpellCasted(false) || HasUnitState(UNIT_STATE_CONTROLLED))
+ if (IsNonMeleeSpellCast(false) || HasUnitState(UNIT_STATE_CONTROLLED))
return 0.0f;
if (GetTypeId() == TYPEID_PLAYER)
@@ -2516,7 +2516,7 @@ float Unit::GetUnitDodgeChance() const
float Unit::GetUnitParryChance() const
{
- if (IsNonMeleeSpellCasted(false) || HasUnitState(UNIT_STATE_CONTROLLED))
+ if (IsNonMeleeSpellCast(false) || HasUnitState(UNIT_STATE_CONTROLLED))
return 0.0f;
float chance = 0.0f;
@@ -2559,7 +2559,7 @@ float Unit::GetUnitMissChance(WeaponAttackType attType) const
float Unit::GetUnitBlockChance() const
{
- if (IsNonMeleeSpellCasted(false) || HasUnitState(UNIT_STATE_CONTROLLED))
+ if (IsNonMeleeSpellCast(false) || HasUnitState(UNIT_STATE_CONTROLLED))
return 0.0f;
if (Player const* player = ToPlayer())
@@ -2698,7 +2698,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()) || IsNonMeleeSpellCasted(false, false, true, m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_spellInfo->Id == 75)) &&
+ if (((GetTypeId() == TYPEID_PLAYER && ToPlayer()->isMoving()) || IsNonMeleeSpellCast(false, false, true, m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_spellInfo->Id == 75)) &&
!HasAuraTypeWithAffectMask(SPELL_AURA_CAST_WHILE_WALKING, m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_spellInfo))
{
// cancel wand shoot
@@ -2732,7 +2732,7 @@ void Unit::_UpdateAutoRepeatSpell()
}
}
-void Unit::SetCurrentCastedSpell(Spell* pSpell)
+void Unit::SetCurrentCastSpell(Spell* pSpell)
{
ASSERT(pSpell); // NULL may be never passed here, use InterruptSpell or InterruptNonMeleeSpells
@@ -2845,16 +2845,16 @@ void Unit::FinishSpell(CurrentSpellTypes spellType, bool ok /*= true*/)
spell->finish(ok);
}
-bool Unit::IsNonMeleeSpellCasted(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.
- // if skipInstant then instant spells shouldn't count as being casted
+ // if skipInstant then instant spells shouldn't count as being cast
if (skipInstant && m_currentSpells[CURRENT_GENERIC_SPELL] && !m_currentSpells[CURRENT_GENERIC_SPELL]->GetCastTime())
return false;
- // generic spells are casted when they are not finished and not delayed
+ // generic spells are cast when they are not finished and not delayed
if (m_currentSpells[CURRENT_GENERIC_SPELL] &&
(m_currentSpells[CURRENT_GENERIC_SPELL]->getState() != SPELL_STATE_FINISHED) &&
(withDelayed || m_currentSpells[CURRENT_GENERIC_SPELL]->getState() != SPELL_STATE_DELAYED))
@@ -2862,14 +2862,14 @@ bool Unit::IsNonMeleeSpellCasted(bool withDelayed, bool skipChanneled, bool skip
if (!isAutoshoot || !(m_currentSpells[CURRENT_GENERIC_SPELL]->m_spellInfo->AttributesEx2 & SPELL_ATTR2_NOT_RESET_AUTO_ACTIONS))
return true;
}
- // channeled spells may be delayed, but they are still considered casted
+ // channeled spells may be delayed, but they are still considered cast
else 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->AttributesEx2 & SPELL_ATTR2_NOT_RESET_AUTO_ACTIONS))
return true;
}
- // autorepeat spells may be finished or delayed, but they are still considered casted
+ // autorepeat spells may be finished or delayed, but they are still considered cast
else if (!skipAutorepeat && m_currentSpells[CURRENT_AUTOREPEAT_SPELL])
return true;
@@ -6334,7 +6334,7 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere
// Runic Power Back on Snare/Root
if (dummySpell->Id == 61257)
{
- // only for spells and hit/crit (trigger start always) and not start from self casted spells
+ // only for spells and hit/crit (trigger start always) and not start from self cast spells
if (procSpell == 0 || !(procEx & (PROC_EX_NORMAL_HIT|PROC_EX_CRITICAL_HIT)) || this == victim)
return false;
// Need snare or root mechanic
@@ -7585,7 +7585,7 @@ bool Unit::AttackStop()
void Unit::CombatStop(bool includingCast)
{
- if (includingCast && IsNonMeleeSpellCasted(false))
+ if (includingCast && IsNonMeleeSpellCast(false))
InterruptNonMeleeSpells(false);
AttackStop();
@@ -8134,7 +8134,7 @@ int32 Unit::DealHeal(Unit* victim, uint32 addhealth)
if (gain)
player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HEALING_DONE, gain, 0, 0, victim);
- player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HEAL_CASTED, addhealth);
+ player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HEAL_CAST, addhealth);
}
if (Player* player = victim->ToPlayer())
@@ -10651,7 +10651,7 @@ void Unit::setDeathState(DeathState s)
getHostileRefManager().deleteReferences();
ClearComboPointHolders(); // any combo points pointed to unit lost at it death
- if (IsNonMeleeSpellCasted(false))
+ if (IsNonMeleeSpellCast(false))
InterruptNonMeleeSpells(false);
ExitVehicle(); // Exit vehicle before calling RemoveAllControlled
@@ -11070,7 +11070,7 @@ int32 Unit::ModSpellDuration(SpellInfo const* spellProto, Unit const* target, in
}
}
- // Glyphs which increase duration of selfcasted buffs
+ // Glyphs which increase duration of selfcast buffs
if (target == this)
{
switch (spellProto->SpellFamilyName)
@@ -11117,7 +11117,7 @@ DiminishingLevels Unit::GetDiminishing(DiminishingGroup group)
if (!i->hitTime)
return DIMINISHING_LEVEL_1;
- // If last spell was casted more than 15 seconds ago - reset the count.
+ // If last spell was cast more than 15 seconds ago - reset the count.
if (i->stack == 0 && getMSTimeDiff(i->hitTime, getMSTime()) > 15000)
{
i->hitCount = DIMINISHING_LEVEL_1;
@@ -11775,7 +11775,7 @@ void Unit::CleanupBeforeRemoveFromMap(bool finalCleanup)
if (finalCleanup)
m_cleanupDone = true;
- m_Events.KillAllEvents(false); // non-delatable (currently casted spells) will not deleted now but it will deleted at call in Map::RemoveAllObjectsInRemoveList
+ m_Events.KillAllEvents(false); // non-delatable (currently cast spells) will not deleted now but it will deleted at call in Map::RemoveAllObjectsInRemoveList
CombatStop();
ClearComboPointHolders();
DeleteThreatList();
@@ -12947,7 +12947,7 @@ void Unit::ApplyCastTimePercentMod(float val, bool apply)
uint32 Unit::GetCastingTimeForBonus(SpellInfo const* spellProto, DamageEffectType damagetype, uint32 CastingTime) const
{
- // Not apply this to creature casted spells with casttime == 0
+ // Not apply this to creature cast spells with casttime == 0
if (CastingTime == 0 && GetTypeId() == TYPEID_UNIT && !ToCreature()->IsPet())
return 3500;
@@ -15804,7 +15804,7 @@ void Unit::StopAttackFaction(uint32 faction_id)
if (victim->GetFactionTemplateEntry()->faction == faction_id)
{
AttackStop();
- if (IsNonMeleeSpellCasted(false))
+ if (IsNonMeleeSpellCast(false))
InterruptNonMeleeSpells(false);
// melee and ranged forced attack cancel
@@ -15835,7 +15835,7 @@ void Unit::OutDebugInfo() const
{
TC_LOG_ERROR("entities.unit", "Unit::OutDebugInfo");
TC_LOG_INFO("entities.unit", "GUID " UI64FMTD ", entry %u, type %u, name %s", GetGUID(), GetEntry(), (uint32)GetTypeId(), GetName().c_str());
- TC_LOG_INFO("entities.unit", "OwnerGUID " UI64FMTD ", MinionGUID " UI64FMTD ", CharmerGUID " UI64FMTD ", CharmedGUID "UI64FMTD, GetOwnerGUID(), GetMinionGUID(), GetCharmerGUID(), GetCharmGUID());
+ TC_LOG_INFO("entities.unit", "OwnerGUID " UI64FMTD ", MinionGUID " UI64FMTD ", CharmerGUID " UI64FMTD ", CharmedGUID " UI64FMTD, GetOwnerGUID(), GetMinionGUID(), GetCharmerGUID(), GetCharmGUID());
TC_LOG_INFO("entities.unit", "In world %u, unit type mask %u", (uint32)(IsInWorld() ? 1 : 0), m_unitTypeMask);
if (IsInWorld())
TC_LOG_INFO("entities.unit", "Mapid %u", GetMapId());
diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h
index 8411b282402..22a48d791e1 100644
--- a/src/server/game/Entities/Unit/Unit.h
+++ b/src/server/game/Entities/Unit/Unit.h
@@ -1828,15 +1828,15 @@ class Unit : public WorldObject
float GetNegStat(Stats stat) const { return GetFloatValue(UNIT_FIELD_NEGSTAT0+stat); }
float GetCreateStat(Stats stat) const { return m_createStats[stat]; }
- void SetCurrentCastedSpell(Spell* pSpell);
+ void SetCurrentCastSpell(Spell* pSpell);
virtual void ProhibitSpellSchool(SpellSchoolMask /*idSchoolMask*/, uint32 /*unTimeMs*/) { }
void InterruptSpell(CurrentSpellTypes spellType, bool withDelayed = true, bool withInstant = true);
void FinishSpell(CurrentSpellTypes spellType, bool ok = true);
- // set withDelayed to true to account delayed spells as casted
- // delayed+channeled spells are always accounted as casted
+ // 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 IsNonMeleeSpellCasted(bool withDelayed, bool skipChanneled = false, bool skipAutorepeat = false, bool isAutoshoot = false, bool skipInstant = true) const;
+ 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
@@ -2180,8 +2180,8 @@ class Unit : public WorldObject
uint32 m_removedAurasCount;
AuraEffectList m_modAuras[TOTAL_AURAS];
- AuraList m_scAuras; // casted singlecast auras
- AuraApplicationList m_interruptableAuras; // auras which have interrupt mask applied on unit
+ AuraList m_scAuras; // cast singlecast 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
uint32 m_interruptMask;
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp
index 4877d904f72..c4963f6372c 100644
--- a/src/server/game/Globals/ObjectMgr.cpp
+++ b/src/server/game/Globals/ObjectMgr.cpp
@@ -1627,7 +1627,8 @@ void ObjectMgr::LoadCreatures()
continue;
}
- if (data.spawnMask & ~spawnMasks[data.mapid])
+ // Skip spawnMask check for transport maps
+ if (!_transportMaps.count(data.mapid) && data.spawnMask & ~spawnMasks[data.mapid])
TC_LOG_ERROR("sql.sql", "Table `creature` have creature (GUID: %u) that have wrong spawn mask %u including not supported difficulty modes for map (Id: %u) spawnMasks[data.mapid]: %u.", guid, data.spawnMask, data.mapid, spawnMasks[data.mapid]);
bool ok = true;
@@ -1962,7 +1963,7 @@ void ObjectMgr::LoadGameobjects()
data.spawnMask = fields[14].GetUInt8();
- if (data.spawnMask & ~spawnMasks[data.mapid])
+ if (!_transportMaps.count(data.mapid) && data.spawnMask & ~spawnMasks[data.mapid])
TC_LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: %u Entry: %u) that has wrong spawn mask %u including not supported difficulty modes for map (Id: %u), skip", guid, data.id, data.spawnMask, data.mapid);
data.phaseMask = fields[15].GetUInt32();
@@ -4071,21 +4072,21 @@ void ObjectMgr::LoadQuests()
{
TC_LOG_ERROR("sql.sql", "Quest %u has `RewardSpellCast` = %u but spell %u does not exist, quest will not have a spell reward.",
qinfo->GetQuestId(), qinfo->RewardSpellCast, qinfo->RewardSpellCast);
- qinfo->RewardSpellCast = 0; // no spell will be casted on player
+ qinfo->RewardSpellCast = 0; // no spell will be cast on player
}
else if (!SpellMgr::IsSpellValid(spellInfo))
{
TC_LOG_ERROR("sql.sql", "Quest %u has `RewardSpellCast` = %u but spell %u is broken, quest will not have a spell reward.",
qinfo->GetQuestId(), qinfo->RewardSpellCast, qinfo->RewardSpellCast);
- qinfo->RewardSpellCast = 0; // no spell will be casted on player
+ qinfo->RewardSpellCast = 0; // no spell will be cast on player
}
else if (GetTalentSpellCost(qinfo->RewardSpellCast))
{
TC_LOG_ERROR("sql.sql", "Quest %u has `RewardSpell` = %u but spell %u is talent, quest will not have a spell reward.",
qinfo->GetQuestId(), qinfo->RewardSpellCast, qinfo->RewardSpellCast);
- qinfo->RewardSpellCast = 0; // no spell will be casted on player
+ qinfo->RewardSpellCast = 0; // no spell will be cast on player
}
}
@@ -6471,6 +6472,8 @@ void ObjectMgr::LoadGameObjectTemplate()
TC_LOG_ERROR("sql.sql", "GameObject (Entry: %u GoType: %u) have data0=%u but TaxiPath (Id: %u) not exist.",
entry, got.type, got.moTransport.taxiPathId, got.moTransport.taxiPathId);
}
+ if (uint32 transportMap = got.moTransport.mapID)
+ _transportMaps.insert(transportMap);
break;
}
case GAMEOBJECT_TYPE_SUMMONING_RITUAL: //18
@@ -8545,8 +8548,8 @@ CreatureBaseStats const* ObjectMgr::GetCreatureBaseStats(uint8 level, uint8 unit
void ObjectMgr::LoadCreatureClassLevelStats()
{
uint32 oldMSTime = getMSTime();
- // 0 1 2 3 4 5 6 7
- QueryResult result = WorldDatabase.Query("SELECT level, class, basehp0, basehp1, basehp2, basehp3, basemana, basearmor FROM creature_classlevelstats");
+ // 0 1 2 3 4 5 6 7 8 9 10 11 12
+ QueryResult result = WorldDatabase.Query("SELECT level, class, basehp0, basehp1, basehp2, basehp3, basemana, basearmor, attackpower, rangedattackpower, damage_base, damage_exp1, damage_exp2 FROM creature_classlevelstats");
if (!result)
{
@@ -8570,6 +8573,12 @@ void ObjectMgr::LoadCreatureClassLevelStats()
stats.BaseMana = fields[6].GetUInt32();
stats.BaseArmor = fields[7].GetUInt32();
+ stats.AttackPower = fields[8].GetInt16();
+ stats.RangedAttackPower = fields[9].GetInt16();
+
+ for (uint8 i = 0; i < MAX_CREATURE_BASE_DAMAGE; ++i)
+ stats.BaseDamage[i] = fields[i + 10].GetFloat();
+
if (!Class || ((1 << (Class - 1)) & CLASSMASK_ALL_CREATURES) == 0)
TC_LOG_ERROR("sql.sql", "Creature base stats for level %u has invalid class %u", Level, Class);
diff --git a/src/server/game/Globals/ObjectMgr.h b/src/server/game/Globals/ObjectMgr.h
index fb106884bba..dfd0192dfed 100644
--- a/src/server/game/Globals/ObjectMgr.h
+++ b/src/server/game/Globals/ObjectMgr.h
@@ -1408,7 +1408,9 @@ class ObjectMgr
GO_TO_GO,
GO_TO_CREATURE // GO is dependant on creature
};
+
HotfixData _hotfixData;
+ std::set<uint32> _transportMaps; // Helper container storing map ids that are for transports only, loaded from gameobject_template
};
#define sObjectMgr ACE_Singleton<ObjectMgr, ACE_Null_Mutex>::instance()
diff --git a/src/server/game/Handlers/ChatHandler.cpp b/src/server/game/Handlers/ChatHandler.cpp
index e33e8f73cd6..73c46cc0372 100644
--- a/src/server/game/Handlers/ChatHandler.cpp
+++ b/src/server/game/Handlers/ChatHandler.cpp
@@ -415,7 +415,7 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData)
sScriptMgr->OnPlayerChat(GetPlayer(), type, lang, msg, group);
WorldPacket data;
- ChatHandler::BuildChatPacket(data, uint8(type), Language(lang), _player, NULL, msg);
+ ChatHandler::BuildChatPacket(data, type, Language(lang), _player, NULL, msg);
group->BroadcastPacket(&data, false);
} break;
case CHAT_MSG_RAID_WARNING:
@@ -445,7 +445,7 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData)
sScriptMgr->OnPlayerChat(GetPlayer(), type, lang, msg, group);
WorldPacket data;
- ChatHandler::BuildChatPacket(data, uint8(type), Language(lang), _player, NULL, msg);;
+ ChatHandler::BuildChatPacket(data, type, Language(lang), _player, NULL, msg);;
group->BroadcastPacket(&data, false);
} break;
case CHAT_MSG_CHANNEL:
@@ -614,7 +614,7 @@ void WorldSession::HandleAddonMessagechatOpcode(WorldPacket& recvData)
return;
WorldPacket data;
- ChatHandler::BuildChatPacket(data, type, uint32(LANG_ADDON), this, this, message, 0, "", DEFAULT_LOCALE, prefix.c_str());
+ ChatHandler::BuildChatPacket(data, type, LANG_ADDON, this, this, message, 0, "", DEFAULT_LOCALE, prefix.c_str());
group->BroadcastAddonMessagePacket(&data, prefix, false);
break;
}
@@ -647,7 +647,7 @@ void WorldSession::HandleAddonMessagechatOpcode(WorldPacket& recvData)
break;
WorldPacket data;
- ChatHandler::BuildChatPacket(data, type, uint32(LANG_ADDON), this, this, message, 0, "", DEFAULT_LOCALE, prefix.c_str());
+ ChatHandler::BuildChatPacket(data, type, LANG_ADDON, this, this, message, 0, "", DEFAULT_LOCALE, prefix.c_str());
group->BroadcastAddonMessagePacket(&data, prefix, true, -1, group->GetMemberGroup(sender->GetGUID()));
break;
}
diff --git a/src/server/game/Handlers/LootHandler.cpp b/src/server/game/Handlers/LootHandler.cpp
index 9a32df7d4af..7b1e2474c8d 100644
--- a/src/server/game/Handlers/LootHandler.cpp
+++ b/src/server/game/Handlers/LootHandler.cpp
@@ -238,7 +238,7 @@ void WorldSession::HandleLootOpcode(WorldPacket& recvData)
GetPlayer()->SendLoot(guid, LOOT_CORPSE);
// interrupt cast
- if (GetPlayer()->IsNonMeleeSpellCasted(false))
+ if (GetPlayer()->IsNonMeleeSpellCast(false))
GetPlayer()->InterruptNonMeleeSpells(false);
}
diff --git a/src/server/game/Handlers/QuestHandler.cpp b/src/server/game/Handlers/QuestHandler.cpp
index a1ece86de09..0cb1a51329f 100644
--- a/src/server/game/Handlers/QuestHandler.cpp
+++ b/src/server/game/Handlers/QuestHandler.cpp
@@ -37,7 +37,6 @@ void WorldSession::HandleQuestgiverStatusQueryOpcode(WorldPacket& recvData)
uint64 guid;
recvData >> guid;
uint32 questStatus = DIALOG_STATUS_NONE;
- uint32 defstatus = DIALOG_STATUS_NONE;
Object* questgiver = ObjectAccessor::GetObjectByTypeMask(*_player, guid, TYPEMASK_UNIT|TYPEMASK_GAMEOBJECT);
if (!questgiver)
@@ -50,23 +49,23 @@ void WorldSession::HandleQuestgiverStatusQueryOpcode(WorldPacket& recvData)
{
case TYPEID_UNIT:
{
- TC_LOG_DEBUG("network", "WORLD: Received CMSG_QUESTGIVER_STATUS_QUERY for npc, guid = %u", uint32(GUID_LOPART(guid)));
- Creature* cr_questgiver=questgiver->ToCreature();
+ TC_LOG_DEBUG("network", "WORLD: Received CMSG_QUESTGIVER_STATUS_QUERY for npc, guid = %u", questgiver->GetGUIDLow());
+ Creature* cr_questgiver = questgiver->ToCreature();
if (!cr_questgiver->IsHostileTo(_player)) // do not show quest status to enemies
{
questStatus = sScriptMgr->GetDialogStatus(_player, cr_questgiver);
- if (questStatus > 6)
- questStatus = getDialogStatus(_player, cr_questgiver, defstatus);
+ if (questStatus == DIALOG_STATUS_SCRIPTED_NO_STATUS)
+ questStatus = getDialogStatus(_player, cr_questgiver);
}
break;
}
case TYPEID_GAMEOBJECT:
{
- TC_LOG_DEBUG("network", "WORLD: Received CMSG_QUESTGIVER_STATUS_QUERY for GameObject guid = %u", uint32(GUID_LOPART(guid)));
- GameObject* go_questgiver=(GameObject*)questgiver;
+ TC_LOG_DEBUG("network", "WORLD: Received CMSG_QUESTGIVER_STATUS_QUERY for GameObject guid = %u", questgiver->GetGUIDLow());
+ GameObject* go_questgiver = questgiver->ToGameObject();
questStatus = sScriptMgr->GetDialogStatus(_player, go_questgiver);
- if (questStatus > 6)
- questStatus = getDialogStatus(_player, go_questgiver, defstatus);
+ if (questStatus == DIALOG_STATUS_SCRIPTED_NO_STATUS)
+ questStatus = getDialogStatus(_player, go_questgiver);
break;
}
default:
@@ -75,7 +74,7 @@ void WorldSession::HandleQuestgiverStatusQueryOpcode(WorldPacket& recvData)
}
//inform client about status of quest
- _player->PlayerTalkClass->SendQuestGiverStatus(questStatus, guid);
+ _player->PlayerTalkClass->SendQuestGiverStatus(uint8(questStatus), guid);
}
void WorldSession::HandleQuestgiverHelloOpcode(WorldPacket& recvData)
@@ -665,9 +664,9 @@ void WorldSession::HandleQuestPushResult(WorldPacket& recvPacket)
}
}
-uint32 WorldSession::getDialogStatus(Player* player, Object* questgiver, uint32 defstatus)
+uint32 WorldSession::getDialogStatus(Player* player, Object* questgiver)
{
- uint32 result = defstatus;
+ uint32 result = DIALOG_STATUS_NONE;
QuestRelationBounds qr;
QuestRelationBounds qir;
@@ -708,7 +707,7 @@ uint32 WorldSession::getDialogStatus(Player* player, Object* questgiver, uint32
if ((status == QUEST_STATUS_COMPLETE && !player->GetQuestRewardStatus(quest_id)) ||
(quest->IsAutoComplete() && player->CanTakeQuest(quest, false)))
{
- if (quest->IsAutoComplete() && quest->IsRepeatable())
+ if (quest->IsAutoComplete() && quest->IsRepeatable() && !quest->IsDailyOrWeekly())
result2 = DIALOG_STATUS_REWARD_REP;
else
result2 = DIALOG_STATUS_REWARD;
@@ -739,11 +738,11 @@ uint32 WorldSession::getDialogStatus(Player* player, Object* questgiver, uint32
{
if (player->SatisfyQuestLevel(quest, false))
{
- if (quest->IsAutoComplete() || (quest->IsRepeatable() && player->IsQuestRewarded(quest_id)))
+ if (quest->IsAutoComplete())
result2 = DIALOG_STATUS_REWARD_REP;
else if (player->getLevel() <= ((player->GetQuestLevel(quest) == -1) ? player->getLevel() : player->GetQuestLevel(quest) + sWorld->getIntConfig(CONFIG_QUEST_LOW_LEVEL_HIDE_DIFF)))
{
- if (quest->HasFlag(QUEST_FLAGS_DAILY) || quest->HasFlag(QUEST_FLAGS_WEEKLY))
+ if (quest->IsDaily())
result2 = DIALOG_STATUS_AVAILABLE_REP;
else
result2 = DIALOG_STATUS_AVAILABLE;
@@ -775,7 +774,6 @@ void WorldSession::HandleQuestgiverStatusMultipleQuery(WorldPacket& /*recvPacket
for (Player::ClientGUIDs::const_iterator itr = _player->m_clientGUIDs.begin(); itr != _player->m_clientGUIDs.end(); ++itr)
{
uint32 questStatus = DIALOG_STATUS_NONE;
- uint32 defstatus = DIALOG_STATUS_NONE;
if (IS_CRE_OR_VEH_OR_PET_GUID(*itr))
{
@@ -785,9 +783,10 @@ void WorldSession::HandleQuestgiverStatusMultipleQuery(WorldPacket& /*recvPacket
continue;
if (!questgiver->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER))
continue;
+
questStatus = sScriptMgr->GetDialogStatus(_player, questgiver);
- if (questStatus > 6)
- questStatus = getDialogStatus(_player, questgiver, defstatus);
+ if (questStatus == DIALOG_STATUS_SCRIPTED_NO_STATUS)
+ questStatus = getDialogStatus(_player, questgiver);
data << uint64(questgiver->GetGUID());
data << uint32(questStatus);
@@ -796,13 +795,12 @@ void WorldSession::HandleQuestgiverStatusMultipleQuery(WorldPacket& /*recvPacket
else if (IS_GAMEOBJECT_GUID(*itr))
{
GameObject* questgiver = GetPlayer()->GetMap()->GetGameObject(*itr);
- if (!questgiver)
- continue;
- if (questgiver->GetGoType() != GAMEOBJECT_TYPE_QUESTGIVER)
+ if (!questgiver || questgiver->GetGoType() != GAMEOBJECT_TYPE_QUESTGIVER)
continue;
+
questStatus = sScriptMgr->GetDialogStatus(_player, questgiver);
- if (questStatus > 6)
- questStatus = getDialogStatus(_player, questgiver, defstatus);
+ if (questStatus == DIALOG_STATUS_SCRIPTED_NO_STATUS)
+ questStatus = getDialogStatus(_player, questgiver);
data << uint64(questgiver->GetGUID());
data << uint32(questStatus);
diff --git a/src/server/game/Handlers/SpellHandler.cpp b/src/server/game/Handlers/SpellHandler.cpp
index 9324f52be3e..5da2512b873 100644
--- a/src/server/game/Handlers/SpellHandler.cpp
+++ b/src/server/game/Handlers/SpellHandler.cpp
@@ -86,10 +86,10 @@ void WorldSession::HandleUseItemOpcode(WorldPacket& recvPacket)
return;
uint8 bagIndex, slot, castFlags;
- uint8 castCount; // next cast if exists (single or not)
+ uint8 castCount; // next cast if exists (single or not)
uint64 itemGUID;
uint32 glyphIndex; // something to do with glyphs?
- uint32 spellId; // casted spell id
+ uint32 spellId; // cast spell id
recvPacket >> bagIndex >> slot >> castCount >> spellId >> itemGUID >> glyphIndex >> castFlags;
@@ -401,7 +401,7 @@ void WorldSession::HandleCastSpellOpcode(WorldPacket& recvPacket)
}
}
- // Client is resending autoshot cast opcode when other spell is casted during shoot rotation
+ // Client is resending autoshot cast opcode when other spell is cast during shoot rotation
// Skip it to prevent "interrupt" message
if (spellInfo->IsAutoRepeatRangedSpell() && caster->GetCurrentSpell(CURRENT_AUTOREPEAT_SPELL)
&& caster->GetCurrentSpell(CURRENT_AUTOREPEAT_SPELL)->m_spellInfo == spellInfo)
@@ -427,7 +427,7 @@ void WorldSession::HandleCastSpellOpcode(WorldPacket& recvPacket)
{
SpellInfo const* actualSpellInfo = spellInfo->GetAuraRankForLevel(targets.GetUnitTarget()->getLevel());
- // if rank not found then function return NULL but in explicit cast case original spell can be casted and later failed with appropriate error message
+ // if rank not found then function return NULL but in explicit cast case original spell can be cast and later failed with appropriate error message
if (actualSpellInfo)
spellInfo = actualSpellInfo;
}
@@ -445,7 +445,7 @@ void WorldSession::HandleCancelCastOpcode(WorldPacket& recvPacket)
recvPacket.read_skip<uint8>(); // counter, increments with every CANCEL packet, don't use for now
recvPacket >> spellId;
- if (_player->IsNonMeleeSpellCasted(false))
+ if (_player->IsNonMeleeSpellCast(false))
_player->InterruptNonMeleeSpells(false, spellId, false);
}
@@ -462,7 +462,7 @@ void WorldSession::HandleCancelAuraOpcode(WorldPacket& recvPacket)
if (spellInfo->Attributes & SPELL_ATTR0_CANT_CANCEL)
return;
- // channeled spell case (it currently casted then)
+ // channeled spell case (it currently cast then)
if (spellInfo->IsChanneled())
{
if (Spell* curSpell = _player->GetCurrentSpell(CURRENT_CHANNELED_SPELL))
diff --git a/src/server/game/Handlers/TradeHandler.cpp b/src/server/game/Handlers/TradeHandler.cpp
index 44e590cb795..650301575c2 100644
--- a/src/server/game/Handlers/TradeHandler.cpp
+++ b/src/server/game/Handlers/TradeHandler.cpp
@@ -412,7 +412,7 @@ void WorldSession::HandleAcceptTradeOpcode(WorldPacket& /*recvPacket*/)
Spell* his_spell = NULL;
SpellCastTargets his_targets;
- // not accept if spell can't be casted now (cheating)
+ // not accept if spell can't be cast now (cheating)
if (uint32 my_spell_id = my_trade->GetSpell())
{
SpellInfo const* spellEntry = sSpellMgr->GetSpellInfo(my_spell_id);
@@ -447,7 +447,7 @@ void WorldSession::HandleAcceptTradeOpcode(WorldPacket& /*recvPacket*/)
}
}
- // not accept if spell can't be casted now (cheating)
+ // not accept if spell can't be cast now (cheating)
if (uint32 his_spell_id = his_trade->GetSpell())
{
SpellInfo const* spellEntry = sSpellMgr->GetSpellInfo(his_spell_id);
diff --git a/src/server/game/Instances/InstanceScript.h b/src/server/game/Instances/InstanceScript.h
index 2d7dbad2541..9ccc3a839be 100644
--- a/src/server/game/Instances/InstanceScript.h
+++ b/src/server/game/Instances/InstanceScript.h
@@ -249,6 +249,16 @@ AI* GetInstanceAI(T* obj, char const* scriptName)
return new AI(obj);
return NULL;
-}
+};
+
+template<class AI, class T>
+AI* GetInstanceAI(T* obj)
+{
+ if (InstanceMap* instance = obj->GetMap()->ToInstanceMap())
+ if (instance->GetInstanceScript())
+ return new AI(obj);
+
+ return NULL;
+};
#endif // TRINITY_INSTANCE_DATA_H
diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp
index 4f3640fe73b..bc478f260ca 100644
--- a/src/server/game/Maps/Map.cpp
+++ b/src/server/game/Maps/Map.cpp
@@ -63,19 +63,12 @@ Map::~Map()
obj->ResetMap();
}
- for (TransportsContainer::iterator itr = _transports.begin(); itr != _transports.end();)
- {
- Transport* transport = *itr;
- ++itr;
-
- transport->RemoveFromWorld();
- delete transport;
- }
-
if (!m_scriptSchedule.empty())
sScriptMgr->DecreaseScheduledScriptCount(m_scriptSchedule.size());
- MMAP::MMapFactory::createOrGetMMapManager()->unloadMapInstance(GetId(), i_InstanceId);
+ MMAP::MMapManager* manager = MMAP::MMapFactory::CreateOrGetMMapManager();
+ manager->UnloadMapInstance(GetId(), i_InstanceId); // Delete the dtNavMeshQuery
+ manager->UnloadMap(GetId()); // Unload the loaded tiles and delete the dtNavMesh
}
bool Map::ExistMap(uint32 mapid, int gx, int gy)
@@ -128,12 +121,16 @@ bool Map::ExistVMap(uint32 mapid, int gx, int gy)
void Map::LoadMMap(int gx, int gy)
{
- bool mmapLoadResult = MMAP::MMapFactory::createOrGetMMapManager()->loadMap((sWorld->GetDataPath() + "mmaps").c_str(), GetId(), gx, gy);
+ bool mmapLoadResult = false;
+ if (GetEntry()->Instanceable())
+ mmapLoadResult = MMAP::MMapFactory::CreateOrGetMMapManager()->LoadMapTile(GetId(), 0, 0); // Ignore the tile entry for instances, as they only have 1 tile.
+ else
+ mmapLoadResult = MMAP::MMapFactory::CreateOrGetMMapManager()->LoadMapTile(GetId(), gx, gy);
if (mmapLoadResult)
- TC_LOG_INFO("maps", "MMAP loaded name:%s, id:%d, x:%d, y:%d (mmap rep.: x:%d, y:%d)", GetMapName(), GetId(), gx, gy, gx, gy);
+ TC_LOG_INFO("maps", "MMAP loaded name: %s, id: %d, x: %d, y: %d", GetMapName(), GetId(), gx, gy);
else
- TC_LOG_INFO("maps", "Could not load MMAP name:%s, id:%d, x:%d, y:%d (mmap rep.: x:%d, y:%d)", GetMapName(), GetId(), gx, gy, gx, gy);
+ TC_LOG_INFO("maps", "Could not load MMAP name: %s, id: %d, x: %d, y: %d", GetMapName(), GetId(), gx, gy);
}
void Map::LoadVMap(int gx, int gy)
@@ -235,9 +232,9 @@ i_gridExpiry(expiry),
i_scriptLock(false)
{
m_parentMap = (_parent ? _parent : this);
- for (unsigned int idx=0; idx < MAX_NUMBER_OF_GRIDS; ++idx)
+ for (unsigned int idx = 0; idx < MAX_NUMBER_OF_GRIDS; ++idx)
{
- for (unsigned int j=0; j < MAX_NUMBER_OF_GRIDS; ++j)
+ for (unsigned int j = 0; j < MAX_NUMBER_OF_GRIDS; ++j)
{
//z code
GridMaps[idx][j] =NULL;
@@ -562,6 +559,22 @@ bool Map::AddToMap(Transport* obj)
obj->AddToWorld();
_transports.insert(obj);
+ // Broadcast creation to players
+ if (!GetPlayers().isEmpty())
+ {
+ for (Map::PlayerList::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
+ {
+ if (itr->GetSource()->GetTransport() != obj)
+ {
+ UpdateData data;
+ obj->BuildCreateUpdateBlockForPlayer(&data, itr->GetSource());
+ WorldPacket packet;
+ data.BuildPacket(&packet);
+ itr->GetSource()->SendDirectMessage(&packet);
+ }
+ }
+ }
+
return true;
}
@@ -810,6 +823,18 @@ void Map::RemoveFromMap(Transport* obj, bool remove)
{
obj->RemoveFromWorld();
+ Map::PlayerList const& players = GetPlayers();
+ if (!players.isEmpty())
+ {
+ UpdateData data;
+ obj->BuildOutOfRangeUpdateBlock(&data);
+ WorldPacket packet;
+ data.BuildPacket(&packet);
+ for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
+ if (itr->GetSource()->GetTransport() != obj)
+ itr->GetSource()->SendDirectMessage(&packet);
+ }
+
if (_transportsUpdateIter != _transports.end())
{
TransportsContainer::iterator itr = _transports.find(obj);
@@ -1317,7 +1342,7 @@ bool Map::UnloadGrid(NGridType& ngrid, bool unloadAll)
delete GridMaps[gx][gy];
}
VMAP::VMapFactory::createOrGetVMapManager()->unloadMap(GetId(), gx, gy);
- MMAP::MMapFactory::createOrGetMMapManager()->unloadMap(GetId(), gx, gy);
+ MMAP::MMapFactory::CreateOrGetMMapManager()->UnloadMapTile(GetId(), gx, gy);
}
else
((MapInstanced*)m_parentMap)->RemoveGridMapReference(GridCoord(gx, gy));
@@ -1357,6 +1382,17 @@ void Map::UnloadAll()
++i;
UnloadGrid(grid, true); // deletes the grid and removes it from the GridRefManager
}
+
+ for (TransportsContainer::iterator itr = _transports.begin(); itr != _transports.end();)
+ {
+ Transport* transport = *itr;
+ ++itr;
+
+ transport->RemoveFromWorld();
+ delete transport;
+ }
+
+ _transports.clear();
}
// *****************************
diff --git a/src/server/game/Maps/MapInstanced.cpp b/src/server/game/Maps/MapInstanced.cpp
index 667f94fb53a..d191293ecaf 100644
--- a/src/server/game/Maps/MapInstanced.cpp
+++ b/src/server/game/Maps/MapInstanced.cpp
@@ -260,7 +260,7 @@ bool MapInstanced::DestroyInstance(InstancedMaps::iterator &itr)
if (m_InstancedMaps.size() <= 1 && sWorld->getBoolConfig(CONFIG_GRID_UNLOAD))
{
VMAP::VMapFactory::createOrGetVMapManager()->unloadMap(itr->second->GetId());
- MMAP::MMapFactory::createOrGetMMapManager()->unloadMap(itr->second->GetId());
+ MMAP::MMapFactory::CreateOrGetMMapManager()->UnloadMap(itr->second->GetId());
// in that case, unload grids of the base map, too
// so in the next map creation, (EnsureGridCreated actually) VMaps will be reloaded
Map::UnloadAll();
diff --git a/src/server/game/Maps/TransportMgr.cpp b/src/server/game/Maps/TransportMgr.cpp
index 11798201397..328342ab303 100644
--- a/src/server/game/Maps/TransportMgr.cpp
+++ b/src/server/game/Maps/TransportMgr.cpp
@@ -87,28 +87,60 @@ void TransportMgr::LoadTransportTemplates()
TC_LOG_INFO("server.loading", ">> Loaded %u transport templates in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
}
+class SplineRawInitializer
+{
+public:
+ SplineRawInitializer(Movement::PointsArray& points) : _points(points) { }
+
+ void operator()(uint8& mode, bool& cyclic, Movement::PointsArray& points, int& lo, int& hi) const
+ {
+ mode = Movement::SplineBase::ModeCatmullrom;
+ cyclic = false;
+ points.assign(_points.begin(), _points.end());
+ lo = 1;
+ hi = points.size() - 2;
+ }
+
+ Movement::PointsArray& _points;
+};
+
void TransportMgr::GeneratePath(GameObjectTemplate const* goInfo, TransportTemplate* transport)
{
uint32 pathId = goInfo->moTransport.taxiPathId;
TaxiPathNodeList const& path = sTaxiPathNodesByPath[pathId];
std::vector<KeyFrame>& keyFrames = transport->keyFrames;
- Movement::PointsArray splinePath;
+ Movement::PointsArray splinePath, allPoints;
bool mapChange = false;
- bool cyclic = true;
+ for (size_t i = 0; i < path.size(); ++i)
+ allPoints.push_back(G3D::Vector3(path[i].x, path[i].y, path[i].z));
+
+ // Add extra points to allow derivative calculations for all path nodes
+ allPoints.insert(allPoints.begin(), allPoints.front().lerp(allPoints[1], -0.2f));
+ allPoints.push_back(allPoints.back().lerp(allPoints[allPoints.size() - 2], -0.2f));
+ allPoints.push_back(allPoints.back().lerp(allPoints[allPoints.size() - 2], -1.0f));
+
+ SplineRawInitializer initer(allPoints);
+ TransportSpline orientationSpline;
+ orientationSpline.init_spline_custom(initer);
+ orientationSpline.initLengths();
+
for (size_t i = 0; i < path.size(); ++i)
{
if (!mapChange)
{
TaxiPathNodeEntry const& node_i = path[i];
- if (i != path.size() - 1 && (node_i.actionFlag == 1 || node_i.mapid != path[i + 1].mapid))
+ if (i != path.size() - 1 && (node_i.actionFlag & 1 || node_i.mapid != path[i + 1].mapid))
{
- cyclic = false;
keyFrames.back().Teleport = true;
mapChange = true;
}
else
{
KeyFrame k(node_i);
+ G3D::Vector3 h;
+ orientationSpline.evaluate_derivative(i + 1, 0.0f, h);
+ k.InitialOrientation = Position::NormalizeOrientation(atan2(h.y, h.x) + M_PI);
+
keyFrames.push_back(k);
splinePath.push_back(G3D::Vector3(node_i.x, node_i.y, node_i.z));
transport->mapsUsed.insert(k.Node->mapid);
@@ -118,16 +150,15 @@ void TransportMgr::GeneratePath(GameObjectTemplate const* goInfo, TransportTempl
mapChange = false;
}
- // Not sure if data8 means the transport can be stopped or that its path in dbc does not contain extra spline points
- if (!goInfo->moTransport.canBeStopped && splinePath.size() >= 2)
+ if (splinePath.size() >= 2)
{
// Remove special catmull-rom spline points
- splinePath.erase(splinePath.begin());
- keyFrames.erase(keyFrames.begin());
- splinePath.pop_back();
- keyFrames.pop_back();
- // Cyclic spline has one more extra point
- if (cyclic && !splinePath.empty())
+ if (!keyFrames.front().IsStopFrame() && !keyFrames.front().Node->arrivalEventID && !keyFrames.front().Node->departureEventID)
+ {
+ splinePath.erase(splinePath.begin());
+ keyFrames.erase(keyFrames.begin());
+ }
+ if (!keyFrames.back().IsStopFrame() && !keyFrames.back().Node->arrivalEventID && !keyFrames.back().Node->departureEventID)
{
splinePath.pop_back();
keyFrames.pop_back();
@@ -170,67 +201,41 @@ void TransportMgr::GeneratePath(GameObjectTemplate const* goInfo, TransportTempl
// find the rest of the distances between key points
// Every path segment has its own spline
- if (cyclic)
- {
- TransportSpline* spline = new TransportSpline();
- spline->init_cyclic_spline(&splinePath[0], splinePath.size(), Movement::SplineBase::ModeCatmullrom, 0);
- spline->initLengths();
- keyFrames[0].DistFromPrev = spline->length(spline->last() - 2, spline->last() - 1);
- keyFrames[0].Spline = spline;
- for (size_t i = 0; i < keyFrames.size(); ++i)
- {
- keyFrames[i].Index = i + 1;
- keyFrames[i].DistFromPrev = spline->length(i, i + 1);
- if (i > 0)
- keyFrames[i - 1].NextDistFromPrev = keyFrames[i].DistFromPrev;
- keyFrames[i].Spline = spline;
- if (keyFrames[i].IsStopFrame())
- {
- // remember first stop frame
- if (firstStop == -1)
- firstStop = i;
- lastStop = i;
- }
- }
- }
- else
+ size_t start = 0;
+ for (size_t i = 1; i < keyFrames.size(); ++i)
{
- size_t start = 0;
- for (size_t i = 1; i < keyFrames.size(); ++i)
+ if (keyFrames[i - 1].Teleport || i + 1 == keyFrames.size())
{
- if (keyFrames[i - 1].Teleport || i + 1 == keyFrames.size())
+ size_t extra = !keyFrames[i - 1].Teleport ? 1 : 0;
+ TransportSpline* spline = new TransportSpline();
+ spline->init_spline(&splinePath[start], i - start + extra, Movement::SplineBase::ModeCatmullrom);
+ spline->initLengths();
+ for (size_t j = start; j < i + extra; ++j)
{
- size_t extra = !keyFrames[i - 1].Teleport ? 1 : 0;
- TransportSpline* spline = new TransportSpline();
- spline->init_spline(&splinePath[start], i - start + extra, Movement::SplineBase::ModeCatmullrom);
- spline->initLengths();
- for (size_t j = start; j < i + extra; ++j)
- {
- keyFrames[j].Index = j - start + 1;
- keyFrames[j].DistFromPrev = spline->length(j - start, j + 1 - start);
- if (j > 0)
- keyFrames[j - 1].NextDistFromPrev = keyFrames[j].DistFromPrev;
- keyFrames[j].Spline = spline;
- }
-
- if (keyFrames[i - 1].Teleport)
- {
- keyFrames[i].Index = i - start + 1;
- keyFrames[i].DistFromPrev = 0.0f;
- keyFrames[i - 1].NextDistFromPrev = 0.0f;
- keyFrames[i].Spline = spline;
- }
-
- start = i;
+ keyFrames[j].Index = j - start + 1;
+ keyFrames[j].DistFromPrev = spline->length(j - start, j + 1 - start);
+ if (j > 0)
+ keyFrames[j - 1].NextDistFromPrev = keyFrames[j].DistFromPrev;
+ keyFrames[j].Spline = spline;
}
- if (keyFrames[i].IsStopFrame())
+ if (keyFrames[i - 1].Teleport)
{
- // remember first stop frame
- if (firstStop == -1)
- firstStop = i;
- lastStop = i;
+ keyFrames[i].Index = i - start + 1;
+ keyFrames[i].DistFromPrev = 0.0f;
+ keyFrames[i - 1].NextDistFromPrev = 0.0f;
+ keyFrames[i].Spline = spline;
}
+
+ start = i;
+ }
+
+ if (keyFrames[i].IsStopFrame())
+ {
+ // remember first stop frame
+ if (firstStop == -1)
+ firstStop = i;
+ lastStop = i;
}
}
@@ -373,7 +378,7 @@ Transport* TransportMgr::CreateTransport(uint32 entry, uint32 guid /*= 0*/, Map*
float x = startNode->x;
float y = startNode->y;
float z = startNode->z;
- float o = 0.0f;
+ float o = tInfo->keyFrames.begin()->InitialOrientation;
// initialize the gameobject base
uint32 guidLow = guid ? guid : sObjectMgr->GenerateLowGuid(HIGHGUID_MO_TRANSPORT);
diff --git a/src/server/game/Maps/TransportMgr.h b/src/server/game/Maps/TransportMgr.h
index 205a614eabb..c2f82069b30 100644
--- a/src/server/game/Maps/TransportMgr.h
+++ b/src/server/game/Maps/TransportMgr.h
@@ -38,7 +38,7 @@ typedef UNORDERED_MAP<uint32, std::set<uint32> > TransportInstanceMap;
struct KeyFrame
{
- explicit KeyFrame(TaxiPathNodeEntry const& _node) : Index(0), Node(&_node),
+ explicit KeyFrame(TaxiPathNodeEntry const& _node) : Index(0), Node(&_node), InitialOrientation(0.0f),
DistSinceStop(-1.0f), DistUntilStop(-1.0f), DistFromPrev(-1.0f), TimeFrom(0.0f), TimeTo(0.0f),
Teleport(false), ArriveTime(0), DepartureTime(0), Spline(NULL), NextDistFromPrev(0.0f), NextArriveTime(0)
{
@@ -46,6 +46,7 @@ struct KeyFrame
uint32 Index;
TaxiPathNodeEntry const* Node;
+ float InitialOrientation;
float DistSinceStop;
float DistUntilStop;
float DistFromPrev;
diff --git a/src/server/game/Miscellaneous/SharedDefines.h b/src/server/game/Miscellaneous/SharedDefines.h
index ddca3a92fd8..03c44cc3a75 100644
--- a/src/server/game/Miscellaneous/SharedDefines.h
+++ b/src/server/game/Miscellaneous/SharedDefines.h
@@ -396,7 +396,7 @@ enum SpellAttr3
SPELL_ATTR3_ONLY_TARGET_PLAYERS = 0x00000100, // 8 can only target players
SPELL_ATTR3_TRIGGERED_CAN_TRIGGER_PROC_2 = 0x00000200, // 9 triggered from effect?
SPELL_ATTR3_MAIN_HAND = 0x00000400, // 10 Main hand weapon required
- SPELL_ATTR3_BATTLEGROUND = 0x00000800, // 11 Can casted only on battleground
+ SPELL_ATTR3_BATTLEGROUND = 0x00000800, // 11 Can only be cast in battleground
SPELL_ATTR3_ONLY_TARGET_GHOSTS = 0x00001000, // 12
SPELL_ATTR3_UNK13 = 0x00002000, // 13
SPELL_ATTR3_IS_HONORLESS_TARGET = 0x00004000, // 14 "Honorless Target" only this spells have this flag
@@ -4049,7 +4049,7 @@ enum PartyResult
};
const uint32 MMAP_MAGIC = 0x4d4d4150; // 'MMAP'
-#define MMAP_VERSION 4
+#define MMAP_VERSION 5
struct MmapTileHeader
{
diff --git a/src/server/game/Movement/MovementGenerators/ConfusedMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/ConfusedMovementGenerator.cpp
index ef24b112253..63b1cf283a4 100755
--- a/src/server/game/Movement/MovementGenerators/ConfusedMovementGenerator.cpp
+++ b/src/server/game/Movement/MovementGenerators/ConfusedMovementGenerator.cpp
@@ -86,7 +86,6 @@ bool ConfusedMovementGenerator<T>::DoUpdate(T* unit, uint32 diff)
unit->MovePositionToFirstCollision(pos, dest, 0.0f);
PathGenerator path(unit);
- path.SetPathLengthLimit(30.0f);
bool result = path.CalculatePath(pos.m_positionX, pos.m_positionY, pos.m_positionZ);
if (!result || (path.GetPathType() & PATHFIND_NOPATH))
{
diff --git a/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.cpp
index f78411fc547..1c65499fe50 100644
--- a/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.cpp
+++ b/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.cpp
@@ -44,7 +44,6 @@ void FleeingMovementGenerator<T>::_setTargetLocation(T* owner)
_getPoint(owner, x, y, z);
PathGenerator path(owner);
- path.SetPathLengthLimit(30.0f);
bool result = path.CalculatePath(x, y, z);
if (!result || (path.GetPathType() & PATHFIND_NOPATH))
{
diff --git a/src/server/game/Movement/MovementGenerators/HomeMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/HomeMovementGenerator.cpp
index 2d9fe4dd27f..ecf9e0c9ede 100644
--- a/src/server/game/Movement/MovementGenerators/HomeMovementGenerator.cpp
+++ b/src/server/game/Movement/MovementGenerators/HomeMovementGenerator.cpp
@@ -60,7 +60,7 @@ void HomeMovementGenerator<Creature>::_setTargetLocation(Creature* owner)
arrived = false;
- owner->ClearUnitState(uint32(UNIT_STATE_ALL_STATE & ~UNIT_STATE_EVADE));
+ owner->ClearUnitState(uint32(UNIT_STATE_ALL_STATE & ~(UNIT_STATE_EVADE | UNIT_STATE_IGNORE_PATHFINDING)));
}
bool HomeMovementGenerator<Creature>::DoUpdate(Creature* owner, const uint32 /*time_diff*/)
diff --git a/src/server/game/Movement/PathGenerator.cpp b/src/server/game/Movement/PathGenerator.cpp
index 91ad6d2b676..19295f63712 100644
--- a/src/server/game/Movement/PathGenerator.cpp
+++ b/src/server/game/Movement/PathGenerator.cpp
@@ -1,4 +1,5 @@
/*
+ * Copyright (C) 2008-2013 TrinityCore <http://www.trinitycore.org/>
* Copyright (C) 2005-2011 MaNGOS <http://getmangos.com/>
*
* This program is free software; you can redistribute it and/or modify
@@ -26,21 +27,19 @@
#include "DetourCommon.h"
#include "DetourNavMeshQuery.h"
+float PathGenerator::MinWallDistance = 2.5f;
+
////////////////// PathGenerator //////////////////
PathGenerator::PathGenerator(const Unit* owner) :
- _polyLength(0), _type(PATHFIND_BLANK), _useStraightPath(false),
- _forceDestination(false), _pointPathLimit(MAX_POINT_PATH_LENGTH),
- _endPosition(G3D::Vector3::zero()), _sourceUnit(owner), _navMesh(NULL),
- _navMeshQuery(NULL)
+ _type(PATHFIND_BLANK), _endPosition(G3D::Vector3::zero()),
+ _sourceUnit(owner), _navMesh(NULL), _navMeshQuery(NULL)
{
- memset(_pathPolyRefs, 0, sizeof(_pathPolyRefs));
-
- TC_LOG_DEBUG("maps", "++ PathGenerator::PathGenerator for %u \n", _sourceUnit->GetGUIDLow());
+ TC_LOG_DEBUG("maps", "PathGenerator::PathGenerator for %u \n", _sourceUnit->GetGUIDLow());
uint32 mapId = _sourceUnit->GetMapId();
if (MMAP::MMapFactory::IsPathfindingEnabled(mapId))
{
- MMAP::MMapManager* mmap = MMAP::MMapFactory::createOrGetMMapManager();
+ MMAP::MMapManager* mmap = MMAP::MMapFactory::CreateOrGetMMapManager();
_navMesh = mmap->GetNavMesh(mapId);
_navMeshQuery = mmap->GetNavMeshQuery(mapId, _sourceUnit->GetInstanceId());
}
@@ -50,16 +49,23 @@ PathGenerator::PathGenerator(const Unit* owner) :
PathGenerator::~PathGenerator()
{
- TC_LOG_DEBUG("maps", "++ PathGenerator::~PathGenerator() for %u \n", _sourceUnit->GetGUIDLow());
+ TC_LOG_DEBUG("maps", "PathGenerator::~PathGenerator() for %u \n", _sourceUnit->GetGUIDLow());
}
bool PathGenerator::CalculatePath(float destX, float destY, float destZ, bool forceDest)
{
+ // Clear the previous path, just in case that the same PathGenerator instance is being used
+ _pathPoints.clear();
+
float x, y, z;
_sourceUnit->GetPosition(x, y, z);
if (!Trinity::IsValidMapCoord(destX, destY, destZ) || !Trinity::IsValidMapCoord(x, y, z))
+ {
+ TC_LOG_DEBUG("maps", "PathGenerator::CalculatePath() called with invalid map coords, destX: %f destY: %f destZ: %f x: %f y: %f z: %f for creature %u", destX, destY, destZ, x, y, z, _sourceUnit->GetGUIDLow());
+ _type = PATHFIND_NOPATH;
return false;
+ }
G3D::Vector3 dest(destX, destY, destZ);
SetEndPosition(dest);
@@ -67,463 +73,103 @@ bool PathGenerator::CalculatePath(float destX, float destY, float destZ, bool fo
G3D::Vector3 start(x, y, z);
SetStartPosition(start);
- _forceDestination = forceDest;
-
- TC_LOG_DEBUG("maps", "++ PathGenerator::CalculatePath() for %u \n", _sourceUnit->GetGUIDLow());
+ TC_LOG_DEBUG("maps", "PathGenerator::CalculatePath() for %u \n", _sourceUnit->GetGUIDLow());
// make sure navMesh works - we can run on map w/o mmap
// check if the start and end point have a .mmtile loaded (can we pass via not loaded tile on the way?)
- if (!_navMesh || !_navMeshQuery || _sourceUnit->HasUnitState(UNIT_STATE_IGNORE_PATHFINDING) ||
- !HaveTile(start) || !HaveTile(dest))
+ if (!_navMesh || !_navMeshQuery || _sourceUnit->HasUnitState(UNIT_STATE_IGNORE_PATHFINDING))
{
- BuildShortcut();
+ TC_LOG_DEBUG("maps", "PathGenerator::CalculatePath() navmesh is not initialized for %u \n", _sourceUnit->GetGUIDLow());
_type = PathType(PATHFIND_NORMAL | PATHFIND_NOT_USING_PATH);
+ _pathPoints.push_back(start);
+ _pathPoints.push_back(dest);
return true;
}
UpdateFilter();
- BuildPolyPath(start, dest);
- return true;
-}
-
-dtPolyRef PathGenerator::GetPathPolyByPosition(dtPolyRef const* polyPath, uint32 polyPathSize, float const* point, float* distance) const
-{
- if (!polyPath || !polyPathSize)
- return INVALID_POLYREF;
-
- dtPolyRef nearestPoly = INVALID_POLYREF;
- float minDist2d = FLT_MAX;
- float minDist3d = 0.0f;
-
- for (uint32 i = 0; i < polyPathSize; ++i)
- {
- float closestPoint[VERTEX_SIZE];
- if (dtStatusFailed(_navMeshQuery->closestPointOnPoly(polyPath[i], point, closestPoint)))
- continue;
-
- float d = dtVdist2DSqr(point, closestPoint);
- if (d < minDist2d)
- {
- minDist2d = d;
- nearestPoly = polyPath[i];
- minDist3d = dtVdistSqr(point, closestPoint);
- }
-
- if (minDist2d < 1.0f) // shortcut out - close enough for us
- break;
- }
-
- if (distance)
- *distance = dtSqrt(minDist3d);
-
- return (minDist2d < 3.0f) ? nearestPoly : INVALID_POLYREF;
-}
-
-dtPolyRef PathGenerator::GetPolyByLocation(float const* point, float* distance) const
-{
- // first we check the current path
- // if the current path doesn't contain the current poly,
- // we need to use the expensive navMesh.findNearestPoly
- dtPolyRef polyRef = GetPathPolyByPosition(_pathPolyRefs, _polyLength, point, distance);
- if (polyRef != INVALID_POLYREF)
- return polyRef;
-
- // we don't have it in our old path
- // try to get it by findNearestPoly()
- // first try with low search box
- float extents[VERTEX_SIZE] = {3.0f, 5.0f, 3.0f}; // bounds of poly search area
- float closestPoint[VERTEX_SIZE] = {0.0f, 0.0f, 0.0f};
- if (dtStatusSucceed(_navMeshQuery->findNearestPoly(point, extents, &_filter, &polyRef, closestPoint)) && polyRef != INVALID_POLYREF)
- {
- *distance = dtVdist(closestPoint, point);
- return polyRef;
- }
-
- // still nothing ..
- // try with bigger search box
- // Note that the extent should not overlap more than 128 polygons in the navmesh (see dtNavMeshQuery::findNearestPoly)
- extents[1] = 50.0f;
+ float startPos[3];
+ startPos[0] = -y;
+ startPos[1] = z;
+ startPos[2] = -x;
- if (dtStatusSucceed(_navMeshQuery->findNearestPoly(point, extents, &_filter, &polyRef, closestPoint)) && polyRef != INVALID_POLYREF)
- {
- *distance = dtVdist(closestPoint, point);
- return polyRef;
- }
+ float endPos[3];
+ endPos[0] = -destY;
+ endPos[1] = destZ;
+ endPos[2] = -destX;
- return INVALID_POLYREF;
-}
+ float polyPickExt[3];
+ polyPickExt[0] = 2.5f;
+ polyPickExt[1] = 2.5f;
+ polyPickExt[2] = 2.5f;
-void PathGenerator::BuildPolyPath(G3D::Vector3 const& startPos, G3D::Vector3 const& endPos)
-{
- // *** getting start/end poly logic ***
+ //
+ dtPolyRef startRef;
+ dtPolyRef endRef;
- float distToStartPoly, distToEndPoly;
- float startPoint[VERTEX_SIZE] = {startPos.y, startPos.z, startPos.x};
- float endPoint[VERTEX_SIZE] = {endPos.y, endPos.z, endPos.x};
+ float nearestPt[3];
- dtPolyRef startPoly = GetPolyByLocation(startPoint, &distToStartPoly);
- dtPolyRef endPoly = GetPolyByLocation(endPoint, &distToEndPoly);
+ _navMeshQuery->findNearestPoly(startPos, polyPickExt, &_filter, &startRef, nearestPt);
+ _navMeshQuery->findNearestPoly(endPos, polyPickExt, &_filter, &endRef, nearestPt);
- // we have a hole in our mesh
- // make shortcut path and mark it as NOPATH ( with flying and swimming exception )
- // its up to caller how he will use this info
- if (startPoly == INVALID_POLYREF || endPoly == INVALID_POLYREF)
+ if (!startRef || !endRef)
{
- TC_LOG_DEBUG("maps", "++ BuildPolyPath :: (startPoly == 0 || endPoly == 0)\n");
- BuildShortcut();
- bool path = _sourceUnit->GetTypeId() == TYPEID_UNIT && _sourceUnit->ToCreature()->CanFly();
-
- bool waterPath = _sourceUnit->GetTypeId() == TYPEID_UNIT && _sourceUnit->ToCreature()->CanSwim();
- if (waterPath)
- {
- // Check both start and end points, if they're both in water, then we can *safely* let the creature move
- for (uint32 i = 0; i < _pathPoints.size(); ++i)
- {
- ZLiquidStatus status = _sourceUnit->GetBaseMap()->getLiquidStatus(_pathPoints[i].x, _pathPoints[i].y, _pathPoints[i].z, MAP_ALL_LIQUIDS, NULL);
- // One of the points is not in the water, cancel movement.
- if (status == LIQUID_MAP_NO_WATER)
- {
- waterPath = false;
- break;
- }
- }
- }
-
- _type = (path || waterPath) ? PathType(PATHFIND_NORMAL | PATHFIND_NOT_USING_PATH) : PATHFIND_NOPATH;
- return;
- }
-
- // we may need a better number here
- bool farFromPoly = (distToStartPoly > 7.0f || distToEndPoly > 7.0f);
- if (farFromPoly)
- {
- TC_LOG_DEBUG("maps", "++ BuildPolyPath :: farFromPoly distToStartPoly=%.3f distToEndPoly=%.3f\n", distToStartPoly, distToEndPoly);
-
- bool buildShotrcut = false;
- if (_sourceUnit->GetTypeId() == TYPEID_UNIT)
- {
- Creature* owner = (Creature*)_sourceUnit;
-
- G3D::Vector3 const& p = (distToStartPoly > 7.0f) ? startPos : endPos;
- if (_sourceUnit->GetBaseMap()->IsUnderWater(p.x, p.y, p.z))
- {
- TC_LOG_DEBUG("maps", "++ BuildPolyPath :: underWater case\n");
- if (owner->CanSwim())
- buildShotrcut = true;
- }
- else
- {
- TC_LOG_DEBUG("maps", "++ BuildPolyPath :: flying case\n");
- if (owner->CanFly())
- buildShotrcut = true;
- }
- }
-
- if (buildShotrcut)
- {
- BuildShortcut();
- _type = PathType(PATHFIND_NORMAL | PATHFIND_NOT_USING_PATH);
- return;
- }
- else
- {
- float closestPoint[VERTEX_SIZE];
- // we may want to use closestPointOnPolyBoundary instead
- if (dtStatusSucceed(_navMeshQuery->closestPointOnPoly(endPoly, endPoint, closestPoint)))
- {
- dtVcopy(endPoint, closestPoint);
- SetActualEndPosition(G3D::Vector3(endPoint[2], endPoint[0], endPoint[1]));
- }
-
- _type = PATHFIND_INCOMPLETE;
- }
- }
-
- // *** poly path generating logic ***
-
- // start and end are on same polygon
- // just need to move in straight line
- if (startPoly == endPoly)
- {
- TC_LOG_DEBUG("maps", "++ BuildPolyPath :: (startPoly == endPoly)\n");
-
- BuildShortcut();
-
- _pathPolyRefs[0] = startPoly;
- _polyLength = 1;
-
- _type = farFromPoly ? PATHFIND_INCOMPLETE : PATHFIND_NORMAL;
- TC_LOG_DEBUG("maps", "++ BuildPolyPath :: path type %d\n", _type);
- return;
- }
-
- // look for startPoly/endPoly in current path
- /// @todo we can merge it with getPathPolyByPosition() loop
- bool startPolyFound = false;
- bool endPolyFound = false;
- uint32 pathStartIndex = 0;
- uint32 pathEndIndex = 0;
-
- if (_polyLength)
- {
- for (; pathStartIndex < _polyLength; ++pathStartIndex)
- {
- // here to carch few bugs
- ASSERT(_pathPolyRefs[pathStartIndex] != INVALID_POLYREF);
-
- if (_pathPolyRefs[pathStartIndex] == startPoly)
- {
- startPolyFound = true;
- break;
- }
- }
-
- for (pathEndIndex = _polyLength-1; pathEndIndex > pathStartIndex; --pathEndIndex)
- if (_pathPolyRefs[pathEndIndex] == endPoly)
- {
- endPolyFound = true;
- break;
- }
- }
-
- if (startPolyFound && endPolyFound)
- {
- TC_LOG_DEBUG("maps", "++ BuildPolyPath :: (startPolyFound && endPolyFound)\n");
-
- // we moved along the path and the target did not move out of our old poly-path
- // our path is a simple subpath case, we have all the data we need
- // just "cut" it out
-
- _polyLength = pathEndIndex - pathStartIndex + 1;
- memmove(_pathPolyRefs, _pathPolyRefs + pathStartIndex, _polyLength * sizeof(dtPolyRef));
+ TC_LOG_DEBUG("maps", "PathGenerator::CalculatePath() for %u no polygons found for start and end locations\n", _sourceUnit->GetGUIDLow());
+ _type = PathType(PATHFIND_NORMAL | PATHFIND_NOT_USING_PATH);
+ _pathPoints.push_back(start);
+ _pathPoints.push_back(dest);
+ return false;
}
- else if (startPolyFound && !endPolyFound)
- {
- TC_LOG_DEBUG("maps", "++ BuildPolyPath :: (startPolyFound && !endPolyFound)\n");
-
- // we are moving on the old path but target moved out
- // so we have atleast part of poly-path ready
-
- _polyLength -= pathStartIndex;
-
- // try to adjust the suffix of the path instead of recalculating entire length
- // at given interval the target cannot get too far from its last location
- // thus we have less poly to cover
- // sub-path of optimal path is optimal
-
- // take ~80% of the original length
- /// @todo play with the values here
- uint32 prefixPolyLength = uint32(_polyLength * 0.8f + 0.5f);
- memmove(_pathPolyRefs, _pathPolyRefs+pathStartIndex, prefixPolyLength * sizeof(dtPolyRef));
-
- dtPolyRef suffixStartPoly = _pathPolyRefs[prefixPolyLength-1];
-
- // we need any point on our suffix start poly to generate poly-path, so we need last poly in prefix data
- float suffixEndPoint[VERTEX_SIZE];
- if (dtStatusFailed(_navMeshQuery->closestPointOnPoly(suffixStartPoly, endPoint, suffixEndPoint)))
- {
- // we can hit offmesh connection as last poly - closestPointOnPoly() don't like that
- // try to recover by using prev polyref
- --prefixPolyLength;
- suffixStartPoly = _pathPolyRefs[prefixPolyLength-1];
- if (dtStatusFailed(_navMeshQuery->closestPointOnPoly(suffixStartPoly, endPoint, suffixEndPoint)))
- {
- // suffixStartPoly is still invalid, error state
- BuildShortcut();
- _type = PATHFIND_NOPATH;
- return;
- }
- }
-
- // generate suffix
- uint32 suffixPolyLength = 0;
- dtStatus dtResult = _navMeshQuery->findPath(
- suffixStartPoly, // start polygon
- endPoly, // end polygon
- suffixEndPoint, // start position
- endPoint, // end position
- &_filter, // polygon search filter
- _pathPolyRefs + prefixPolyLength - 1, // [out] path
- (int*)&suffixPolyLength,
- MAX_PATH_LENGTH-prefixPolyLength); // max number of polygons in output path
-
- if (!suffixPolyLength || dtStatusFailed(dtResult))
- {
- // this is probably an error state, but we'll leave it
- // and hopefully recover on the next Update
- // we still need to copy our preffix
- TC_LOG_ERROR("maps", "%u's Path Build failed: 0 length path", _sourceUnit->GetGUIDLow());
- }
- TC_LOG_DEBUG("maps", "++ m_polyLength=%u prefixPolyLength=%u suffixPolyLength=%u \n", _polyLength, prefixPolyLength, suffixPolyLength);
+ int hops;
+ dtPolyRef* hopBuffer = new dtPolyRef[8192];
+ dtStatus status = _navMeshQuery->findPath(startRef, endRef, startPos, endPos, &_filter, hopBuffer, &hops, 8192);
- // new path = prefix + suffix - overlap
- _polyLength = prefixPolyLength + suffixPolyLength - 1;
- }
- else
+ if (!dtStatusSucceed(status))
{
- TC_LOG_DEBUG("maps", "++ BuildPolyPath :: (!startPolyFound && !endPolyFound)\n");
-
- // either we have no path at all -> first run
- // or something went really wrong -> we aren't moving along the path to the target
- // just generate new path
-
- // free and invalidate old path data
- Clear();
-
- dtStatus dtResult = _navMeshQuery->findPath(
- startPoly, // start polygon
- endPoly, // end polygon
- startPoint, // start position
- endPoint, // end position
- &_filter, // polygon search filter
- _pathPolyRefs, // [out] path
- (int*)&_polyLength,
- MAX_PATH_LENGTH); // max number of polygons in output path
-
- if (!_polyLength || dtStatusFailed(dtResult))
- {
- // only happens if we passed bad data to findPath(), or navmesh is messed up
- TC_LOG_ERROR("maps", "%u's Path Build failed: 0 length path", _sourceUnit->GetGUIDLow());
- BuildShortcut();
- _type = PATHFIND_NOPATH;
- return;
- }
+ TC_LOG_DEBUG("maps", "PathGenerator::CalculatePath() for %u no path found for start and end locations\n", _sourceUnit->GetGUIDLow());
+ _type = PathType(PATHFIND_NORMAL | PATHFIND_NOT_USING_PATH);
+ _pathPoints.push_back(start);
+ _pathPoints.push_back(dest);
+ return false;
}
- // by now we know what type of path we can get
- if (_pathPolyRefs[_polyLength - 1] == endPoly && !(_type & PATHFIND_INCOMPLETE))
- _type = PATHFIND_NORMAL;
- else
- _type = PATHFIND_INCOMPLETE;
-
- // generate the point-path out of our up-to-date poly-path
- BuildPointPath(startPoint, endPoint);
-}
-
-void PathGenerator::BuildPointPath(const float *startPoint, const float *endPoint)
-{
- float pathPoints[MAX_POINT_PATH_LENGTH*VERTEX_SIZE];
- uint32 pointCount = 0;
- dtStatus dtResult = DT_FAILURE;
- if (_useStraightPath)
- {
- dtResult = _navMeshQuery->findStraightPath(
- startPoint, // start position
- endPoint, // end position
- _pathPolyRefs, // current path
- _polyLength, // lenth of current path
- pathPoints, // [out] path corner points
- NULL, // [out] flags
- NULL, // [out] shortened path
- (int*)&pointCount,
- _pointPathLimit); // maximum number of points/polygons to use
- }
- else
- {
- dtResult = FindSmoothPath(
- startPoint, // start position
- endPoint, // end position
- _pathPolyRefs, // current path
- _polyLength, // length of current path
- pathPoints, // [out] path corner points
- (int*)&pointCount,
- _pointPathLimit); // maximum number of points
- }
+ int resultHopCount;
+ float* straightPath = new float[2048 * 3];
+ unsigned char* pathFlags = new unsigned char[2048];
+ dtPolyRef* pathRefs = new dtPolyRef[2048];
- if (pointCount < 2 || dtStatusFailed(dtResult))
+ status = _navMeshQuery->findStraightPath(startPos, endPos, hopBuffer, hops, straightPath, pathFlags, pathRefs, &resultHopCount, 2048);
+ if (!dtStatusSucceed(status))
{
- // only happens if pass bad data to findStraightPath or navmesh is broken
- // single point paths can be generated here
- /// @todo check the exact cases
- TC_LOG_DEBUG("maps", "++ PathGenerator::BuildPointPath FAILED! path sized %d returned\n", pointCount);
- BuildShortcut();
- _type = PATHFIND_NOPATH;
- return;
- }
- else if (pointCount == _pointPathLimit)
- {
- TC_LOG_DEBUG("maps", "++ PathGenerator::BuildPointPath FAILED! path sized %d returned, lower than limit set to %d\n", pointCount, _pointPathLimit);
- BuildShortcut();
- _type = PATHFIND_SHORT;
- return;
+ TC_LOG_DEBUG("maps", "PathGenerator::CalculatePath() for %u no straight path found for start and end locations\n", _sourceUnit->GetGUIDLow());
+ _type = PathType(PATHFIND_NORMAL | PATHFIND_NOT_USING_PATH);
+ _pathPoints.push_back(start);
+ _pathPoints.push_back(dest);
+ return false;
}
- _pathPoints.resize(pointCount);
- for (uint32 i = 0; i < pointCount; ++i)
- _pathPoints[i] = G3D::Vector3(pathPoints[i*VERTEX_SIZE+2], pathPoints[i*VERTEX_SIZE], pathPoints[i*VERTEX_SIZE+1]);
-
- NormalizePath();
+ SmoothPath(polyPickExt, resultHopCount, straightPath); // Separate the path from the walls
- // first point is always our current location - we need the next one
- SetActualEndPosition(_pathPoints[pointCount-1]);
-
- // force the given destination, if needed
- if (_forceDestination &&
- (!(_type & PATHFIND_NORMAL) || !InRange(GetEndPosition(), GetActualEndPosition(), 1.0f, 1.0f)))
+ for (uint32 i = 0; i < resultHopCount; ++i)
{
- // we may want to keep partial subpath
- if (Dist3DSqr(GetActualEndPosition(), GetEndPosition()) < 0.3f * Dist3DSqr(GetStartPosition(), GetEndPosition()))
- {
- SetActualEndPosition(GetEndPosition());
- _pathPoints[_pathPoints.size()-1] = GetEndPosition();
- }
- else
- {
- SetActualEndPosition(GetEndPosition());
- BuildShortcut();
- }
-
- _type = PathType(PATHFIND_NORMAL | PATHFIND_NOT_USING_PATH);
+ _pathPoints.push_back(G3D::Vector3(-straightPath[i * 3 + 2], -straightPath[i * 3 + 0], straightPath[i * 3 + 1]));
+ TC_LOG_DEBUG("maps", "PathGenerator::CalculatePath() for %u path point %u: (%f, %f, %f)", _sourceUnit->GetGUIDLow(), i, _pathPoints[i].x, _pathPoints[i].y, _pathPoints[i].z);
}
- TC_LOG_DEBUG("maps", "++ PathGenerator::BuildPointPath path type %d size %d poly-size %d\n", _type, pointCount, _polyLength);
-}
-
-void PathGenerator::NormalizePath()
-{
- for (uint32 i = 0; i < _pathPoints.size(); ++i)
- _sourceUnit->UpdateAllowedPositionZ(_pathPoints[i].x, _pathPoints[i].y, _pathPoints[i].z);
-}
-
-void PathGenerator::BuildShortcut()
-{
- TC_LOG_DEBUG("maps", "++ BuildShortcut :: making shortcut\n");
-
- Clear();
-
- // make two point path, our curr pos is the start, and dest is the end
- _pathPoints.resize(2);
-
- // set start and a default next position
- _pathPoints[0] = GetStartPosition();
- _pathPoints[1] = GetActualEndPosition();
-
- NormalizePath();
-
- _type = PATHFIND_SHORTCUT;
+ _type = PATHFIND_NORMAL;
+ return true;
}
void PathGenerator::CreateFilter()
{
- uint16 includeFlags = 0;
+ uint16 includeFlags = POLY_FLAG_WALK | POLY_FLAG_SWIM;
uint16 excludeFlags = 0;
- if (_sourceUnit->GetTypeId() == TYPEID_UNIT)
+ if (_sourceUnit->GetTypeId() == TYPEID_UNIT && !_sourceUnit->ToCreature()->CanSwim())
{
- Creature* creature = (Creature*)_sourceUnit;
- if (creature->CanWalk())
- includeFlags |= NAV_GROUND; // walk
-
- // creatures don't take environmental damage
- if (creature->CanSwim())
- includeFlags |= (NAV_WATER | NAV_MAGMA | NAV_SLIME); // swim
- }
- else // assume Player
- {
- // perfect support not possible, just stay 'safe'
- includeFlags |= (NAV_GROUND | NAV_WATER | NAV_MAGMA | NAV_SLIME);
+ includeFlags = POLY_FLAG_WALK;
+ excludeFlags = POLY_FLAG_SWIM;
}
_filter.setIncludeFlags(includeFlags);
@@ -534,275 +180,130 @@ void PathGenerator::CreateFilter()
void PathGenerator::UpdateFilter()
{
- // allow creatures to cheat and use different movement types if they are moved
- // forcefully into terrain they can't normally move in
- if (_sourceUnit->IsInWater() || _sourceUnit->IsUnderWater())
- {
- uint16 includedFlags = _filter.getIncludeFlags();
- includedFlags |= GetNavTerrain(_sourceUnit->GetPositionX(),
- _sourceUnit->GetPositionY(),
- _sourceUnit->GetPositionZ());
- _filter.setIncludeFlags(includedFlags);
- }
}
-NavTerrain PathGenerator::GetNavTerrain(float x, float y, float z)
+float PathGenerator::GetTriangleArea(float* verts, int nv)
{
- LiquidData data;
- ZLiquidStatus liquidStatus = _sourceUnit->GetBaseMap()->getLiquidStatus(x, y, z, MAP_ALL_LIQUIDS, &data);
- if (liquidStatus == LIQUID_MAP_NO_WATER)
- return NAV_GROUND;
-
- switch (data.type_flags)
- {
- case MAP_LIQUID_TYPE_WATER:
- case MAP_LIQUID_TYPE_OCEAN:
- return NAV_WATER;
- case MAP_LIQUID_TYPE_MAGMA:
- return NAV_MAGMA;
- case MAP_LIQUID_TYPE_SLIME:
- return NAV_SLIME;
- default:
- return NAV_GROUND;
- }
+ float area = 0;
+ for (int i = 0; i < nv - 1; i++)
+ area += verts[i * 3] * verts[i * 3 + 5] - verts[i * 3 + 3] * verts[i * 3 + 2];
+ area += verts[(nv - 1) * 3] * verts[2] - verts[0] * verts[(nv - 1) * 3 + 2];
+ return area * 0.5f;
}
-bool PathGenerator::HaveTile(const G3D::Vector3& p) const
+bool PathGenerator::PointInPoly(float* pos, float* verts, int nv, float err)
{
- int tx = -1, ty = -1;
- float point[VERTEX_SIZE] = {p.y, p.z, p.x};
-
- _navMesh->calcTileLoc(point, &tx, &ty);
-
- /// Workaround
- /// For some reason, often the tx and ty variables wont get a valid value
- /// Use this check to prevent getting negative tile coords and crashing on getTileAt
- if (tx < 0 || ty < 0)
- return false;
-
- return (_navMesh->getTileAt(tx, ty, 0) != NULL);
-}
-
-uint32 PathGenerator::FixupCorridor(dtPolyRef* path, uint32 npath, uint32 maxPath, dtPolyRef const* visited, uint32 nvisited)
-{
- int32 furthestPath = -1;
- int32 furthestVisited = -1;
-
- // Find furthest common polygon.
- for (int32 i = npath-1; i >= 0; --i)
+ // Poly area
+ float area = abs(PathGenerator::GetTriangleArea(verts, nv));
+
+ // Calculate each area of the triangles
+ float testTri[9];
+ memcpy(testTri, pos, sizeof(float) * 3);
+ float area1 = 0;
+ for(int i = 0; i < nv - 1; ++i)
{
- bool found = false;
- for (int32 j = nvisited-1; j >= 0; --j)
- {
- if (path[i] == visited[j])
- {
- furthestPath = i;
- furthestVisited = j;
- found = true;
- }
- }
- if (found)
- break;
+ memcpy(&testTri[3], &verts[i * 3], sizeof(float) * 3);
+ memcpy(&testTri[6], &verts[i * 3 + 3], sizeof(float) * 3);
+ area1 += abs(PathGenerator::GetTriangleArea(testTri, 3));
+ if (area1 - err > area)
+ return false;
}
- // If no intersection found just return current path.
- if (furthestPath == -1 || furthestVisited == -1)
- return npath;
+ // Last one
+ memcpy(&testTri[3], verts, sizeof(float) * 3);
+ memcpy(&testTri[6], &verts[nv * 3 - 3] , sizeof(float) * 3);
+ area1 += abs(PathGenerator::GetTriangleArea(testTri, 3));
- // Concatenate paths.
+ return abs(area1 - area) < err;
+}
- // Adjust beginning of the buffer to include the visited.
- uint32 req = nvisited - furthestVisited;
- uint32 orig = uint32(furthestPath + 1) < npath ? furthestPath + 1 : npath;
- uint32 size = npath > orig ? npath - orig : 0;
- if (req + size > maxPath)
- size = maxPath-req;
+float PathGenerator::DistanceToWall(float* polyPickExt, float* pos, float* hitPos, float* hitNormal)
+{
+ float distanceToWall = 0;
+ dtPolyRef ref;
- if (size)
- memmove(path + req, path + orig, size * sizeof(dtPolyRef));
+ dtStatus status = _navMeshQuery->findNearestPoly(pos, polyPickExt, &_filter, &ref, 0);
- // Store visited
- for (uint32 i = 0; i < req; ++i)
- path[i] = visited[(nvisited - 1) - i];
+ if (!dtStatusSucceed(status) || ref == 0)
+ return -1;
- return req+size;
-}
+ const dtMeshTile* tile = 0;
+ const dtPoly* poly = 0;
+ if (dtStatusFailed(_navMesh->getTileAndPolyByRef(ref, &tile, &poly)))
+ return -1;
-bool PathGenerator::GetSteerTarget(float const* startPos, float const* endPos,
- float minTargetDist, dtPolyRef const* path, uint32 pathSize,
- float* steerPos, unsigned char& steerPosFlag, dtPolyRef& steerPosRef)
-{
- // Find steer target.
- static const uint32 MAX_STEER_POINTS = 3;
- float steerPath[MAX_STEER_POINTS*VERTEX_SIZE];
- unsigned char steerPathFlags[MAX_STEER_POINTS];
- dtPolyRef steerPathPolys[MAX_STEER_POINTS];
- uint32 nsteerPath = 0;
- dtStatus dtResult = _navMeshQuery->findStraightPath(startPos, endPos, path, pathSize,
- steerPath, steerPathFlags, steerPathPolys, (int*)&nsteerPath, MAX_STEER_POINTS);
- if (!nsteerPath || dtStatusFailed(dtResult))
- return false;
-
- // Find vertex far enough to steer to.
- uint32 ns = 0;
- while (ns < nsteerPath)
+ // Collect vertices.
+ float verts[DT_VERTS_PER_POLYGON * 3];
+ int nv = 0;
+ for (unsigned char i = 0; i < poly->vertCount; ++i)
{
- // Stop at Off-Mesh link or when point is further than slop away.
- if ((steerPathFlags[ns] & DT_STRAIGHTPATH_OFFMESH_CONNECTION) ||
- !InRangeYZX(&steerPath[ns*VERTEX_SIZE], startPos, minTargetDist, 1000.0f))
- break;
- ns++;
+ dtVcopy(&verts[nv * 3], &tile->verts[poly->verts[i] * 3]);
+ nv++;
}
- // Failed to find good point to steer to.
- if (ns >= nsteerPath)
- return false;
- dtVcopy(steerPos, &steerPath[ns*VERTEX_SIZE]);
- steerPos[1] = startPos[1]; // keep Z value
- steerPosFlag = steerPathFlags[ns];
- steerPosRef = steerPathPolys[ns];
+ bool inside = PathGenerator::PointInPoly(pos, verts, nv, 0.05f);
+ if (!inside)
+ return -1;
- return true;
+ if (!dtStatusSucceed(_navMeshQuery->findDistanceToWall(ref, pos, 100.0f, &_filter, &distanceToWall, hitPos, hitNormal)))
+ return -1;
+
+ return distanceToWall;
}
-dtStatus PathGenerator::FindSmoothPath(float const* startPos, float const* endPos,
- dtPolyRef const* polyPath, uint32 polyPathSize,
- float* smoothPath, int* smoothPathSize, uint32 maxSmoothPathSize)
+void PathGenerator::SmoothPath(float* polyPickExt, int pathLength, float*& straightPath)
{
- *smoothPathSize = 0;
- uint32 nsmoothPath = 0;
-
- dtPolyRef polys[MAX_PATH_LENGTH];
- memcpy(polys, polyPath, sizeof(dtPolyRef)*polyPathSize);
- uint32 npolys = polyPathSize;
-
- float iterPos[VERTEX_SIZE], targetPos[VERTEX_SIZE];
- if (dtStatusFailed(_navMeshQuery->closestPointOnPolyBoundary(polys[0], startPos, iterPos)))
- return DT_FAILURE;
-
- if (dtStatusFailed(_navMeshQuery->closestPointOnPolyBoundary(polys[npolys-1], endPos, targetPos)))
- return DT_FAILURE;
-
- dtVcopy(&smoothPath[nsmoothPath*VERTEX_SIZE], iterPos);
- nsmoothPath++;
-
- // Move towards target a small advancement at a time until target reached or
- // when ran out of memory to store the path.
- while (npolys && nsmoothPath < maxSmoothPathSize)
+ float hitPos[3];
+ float hitNormal[3];
+ float testPos[3];
+ float distanceToWall = 0;
+ float up[]= { 0, 1, 0 };
+ float origDis = 0;
+
+ for (int i = 1; i < pathLength - 1; ++i)
{
- // Find location to steer towards.
- float steerPos[VERTEX_SIZE];
- unsigned char steerPosFlag;
- dtPolyRef steerPosRef = INVALID_POLYREF;
-
- if (!GetSteerTarget(iterPos, targetPos, SMOOTH_PATH_SLOP, polys, npolys, steerPos, steerPosFlag, steerPosRef))
- break;
-
- bool endOfPath = (steerPosFlag & DT_STRAIGHTPATH_END);
- bool offMeshConnection = (steerPosFlag & DT_STRAIGHTPATH_OFFMESH_CONNECTION);
-
- // Find movement delta.
- float delta[VERTEX_SIZE];
- dtVsub(delta, steerPos, iterPos);
- float len = dtSqrt(dtVdot(delta, delta));
- // If the steer target is end of path or off-mesh link, do not move past the location.
- if ((endOfPath || offMeshConnection) && len < SMOOTH_PATH_STEP_SIZE)
- len = 1.0f;
- else
- len = SMOOTH_PATH_STEP_SIZE / len;
-
- float moveTgt[VERTEX_SIZE];
- dtVmad(moveTgt, iterPos, delta, len);
-
- // Move
- float result[VERTEX_SIZE];
- const static uint32 MAX_VISIT_POLY = 16;
- dtPolyRef visited[MAX_VISIT_POLY];
-
- uint32 nvisited = 0;
- _navMeshQuery->moveAlongSurface(polys[0], iterPos, moveTgt, &_filter, result, visited, (int*)&nvisited, MAX_VISIT_POLY);
- npolys = FixupCorridor(polys, npolys, MAX_PATH_LENGTH, visited, nvisited);
-
- _navMeshQuery->getPolyHeight(polys[0], result, &result[1]);
- result[1] += 0.5f;
- dtVcopy(iterPos, result);
-
- // Handle end of path and off-mesh links when close enough.
- if (endOfPath && InRangeYZX(iterPos, steerPos, SMOOTH_PATH_SLOP, 1.0f))
- {
- // Reached end of path.
- dtVcopy(iterPos, targetPos);
- if (nsmoothPath < maxSmoothPathSize)
- {
- dtVcopy(&smoothPath[nsmoothPath*VERTEX_SIZE], iterPos);
- nsmoothPath++;
- }
- break;
- }
- else if (offMeshConnection && InRangeYZX(iterPos, steerPos, SMOOTH_PATH_SLOP, 1.0f))
- {
- // Advance the path up to and over the off-mesh connection.
- dtPolyRef prevRef = INVALID_POLYREF;
- dtPolyRef polyRef = polys[0];
- uint32 npos = 0;
- while (npos < npolys && polyRef != steerPosRef)
- {
- prevRef = polyRef;
- polyRef = polys[npos];
- npos++;
- }
-
- for (uint32 i = npos; i < npolys; ++i)
- polys[i-npos] = polys[i];
-
- npolys -= npos;
+ dtPolyRef pt;
+ float* curPoi = &straightPath[i * 3];
+ distanceToWall = DistanceToWall(polyPickExt, curPoi, hitPos, hitNormal);
- // Handle the connection.
- float startPos[VERTEX_SIZE], endPos[VERTEX_SIZE];
- if (dtStatusSucceed(_navMesh->getOffMeshConnectionPolyEndPoints(prevRef, polyRef, startPos, endPos)))
+ if (distanceToWall < PathGenerator::MinWallDistance && distanceToWall >= 0)
+ {
+ float vec[3];
+ dtVsub(vec, &straightPath[i * 3 - 3], &straightPath[i * 3]);
+ // If distanceToWall is 0 means the point is in the edge, so we can't get the hitpos.
+ if (distanceToWall == 0)
{
- if (nsmoothPath < maxSmoothPathSize)
+ // Test the left side
+ dtVcross(testPos, vec, up);
+ dtVadd(testPos, testPos, curPoi);
+ float ft = PathGenerator::MinWallDistance / dtVdist(testPos, curPoi);
+ dtVlerp(testPos, curPoi, testPos, ft);
+ distanceToWall = DistanceToWall(polyPickExt, testPos, hitPos, hitNormal);
+ if (abs(PathGenerator::MinWallDistance - distanceToWall) > 0.1f)
{
- dtVcopy(&smoothPath[nsmoothPath*VERTEX_SIZE], startPos);
- nsmoothPath++;
+ // Test the right side
+ dtVcross(testPos, up, vec);
+ dtVadd(testPos, testPos, curPoi);
+ ft = PathGenerator::MinWallDistance / dtVdist(testPos, curPoi);
+ dtVlerp(testPos, curPoi, testPos, ft);
+ distanceToWall = DistanceToWall(polyPickExt, testPos, hitPos, hitNormal);
}
- // Move position at the other side of the off-mesh link.
- dtVcopy(iterPos, endPos);
- _navMeshQuery->getPolyHeight(polys[0], iterPos, &iterPos[1]);
- iterPos[1] += 0.5f;
+
+ // If the test point is better than the orig point, replace it.
+ if (abs(distanceToWall - PathGenerator::MinWallDistance) < 0.1f)
+ dtVcopy(curPoi, testPos);
}
- }
+ else
+ {
+ // We get the hitpos with a ray
+ float ft = PathGenerator::MinWallDistance / distanceToWall;
+ dtVlerp(testPos, hitPos, curPoi, ft);
+ distanceToWall = DistanceToWall(polyPickExt, testPos, hitPos, hitNormal);
- // Store results.
- if (nsmoothPath < maxSmoothPathSize)
- {
- dtVcopy(&smoothPath[nsmoothPath*VERTEX_SIZE], iterPos);
- nsmoothPath++;
+ if (abs(distanceToWall - PathGenerator::MinWallDistance) < 0.1f)
+ dtVcopy(curPoi, testPos);
+ }
}
}
-
- *smoothPathSize = nsmoothPath;
-
- // this is most likely a loop
- return nsmoothPath < MAX_POINT_PATH_LENGTH ? DT_SUCCESS : DT_FAILURE;
-}
-
-bool PathGenerator::InRangeYZX(const float* v1, const float* v2, float r, float h) const
-{
- const float dx = v2[0] - v1[0];
- const float dy = v2[1] - v1[1]; // elevation
- const float dz = v2[2] - v1[2];
- return (dx * dx + dz * dz) < r * r && fabsf(dy) < h;
-}
-
-bool PathGenerator::InRange(G3D::Vector3 const& p1, G3D::Vector3 const& p2, float r, float h) const
-{
- G3D::Vector3 d = p1 - p2;
- return (d.x * d.x + d.y * d.y) < r * r && fabsf(d.z) < h;
-}
-
-float PathGenerator::Dist3DSqr(G3D::Vector3 const& p1, G3D::Vector3 const& p2) const
-{
- return (p1 - p2).squaredLength();
}
diff --git a/src/server/game/Movement/PathGenerator.h b/src/server/game/Movement/PathGenerator.h
index ac66b7cec57..075d6dabc9f 100644
--- a/src/server/game/Movement/PathGenerator.h
+++ b/src/server/game/Movement/PathGenerator.h
@@ -26,18 +26,6 @@
class Unit;
-// 74*4.0f=296y number_of_points*interval = max_path_len
-// this is way more than actual evade range
-// I think we can safely cut those down even more
-#define MAX_PATH_LENGTH 74
-#define MAX_POINT_PATH_LENGTH 74
-
-#define SMOOTH_PATH_STEP_SIZE 4.0f
-#define SMOOTH_PATH_SLOP 0.3f
-
-#define VERTEX_SIZE 3
-#define INVALID_POLYREF 0
-
enum PathType
{
PATHFIND_BLANK = 0x00, // path not built yet
@@ -49,6 +37,12 @@ enum PathType
PATHFIND_SHORT = 0x20, // path is longer or equal to its limited path length
};
+enum PolyFlag
+{
+ POLY_FLAG_WALK = 1,
+ POLY_FLAG_SWIM = 2
+};
+
class PathGenerator
{
public:
@@ -59,10 +53,6 @@ class PathGenerator
// return: true if new path was calculated, false otherwise (no change needed)
bool CalculatePath(float destX, float destY, float destZ, bool forceDest = false);
- // option setters - use optional
- void SetUseStraightPath(bool useStraightPath) { _useStraightPath = useStraightPath; }
- void SetPathLengthLimit(float distance) { _pointPathLimit = std::min<uint32>(uint32(distance/SMOOTH_PATH_STEP_SIZE), MAX_POINT_PATH_LENGTH); }
-
// result getters
G3D::Vector3 const& GetStartPosition() const { return _startPosition; }
G3D::Vector3 const& GetEndPosition() const { return _endPosition; }
@@ -71,19 +61,13 @@ class PathGenerator
Movement::PointsArray const& GetPath() const { return _pathPoints; }
PathType GetPathType() const { return _type; }
+
+ static float MinWallDistance;
private:
-
- dtPolyRef _pathPolyRefs[MAX_PATH_LENGTH]; // array of detour polygon references
- uint32 _polyLength; // number of polygons in the path
-
Movement::PointsArray _pathPoints; // our actual (x,y,z) path to the target
PathType _type; // tells what kind of path this is
- bool _useStraightPath; // type of path will be generated
- bool _forceDestination; // when set, we will always arrive at given point
- uint32 _pointPathLimit; // limit point path size; min(this, MAX_POINT_PATH_LENGTH)
-
G3D::Vector3 _startPosition; // {x, y, z} of current location
G3D::Vector3 _endPosition; // {x, y, z} of the destination
G3D::Vector3 _actualEndPosition; // {x, y, z} of the closest possible point to given destination
@@ -97,37 +81,16 @@ class PathGenerator
void SetStartPosition(G3D::Vector3 const& point) { _startPosition = point; }
void SetEndPosition(G3D::Vector3 const& point) { _actualEndPosition = point; _endPosition = point; }
void SetActualEndPosition(G3D::Vector3 const& point) { _actualEndPosition = point; }
- void NormalizePath();
-
- void Clear()
- {
- _polyLength = 0;
- _pathPoints.clear();
- }
- bool InRange(G3D::Vector3 const& p1, G3D::Vector3 const& p2, float r, float h) const;
- float Dist3DSqr(G3D::Vector3 const& p1, G3D::Vector3 const& p2) const;
- bool InRangeYZX(float const* v1, float const* v2, float r, float h) const;
+ // Path smoothing
+ void SmoothPath(float* polyPickExt, int pathLength, float*& straightPath);
+ float DistanceToWall(float* polyPickExt, float* pos, float* hitPos, float* hitNormal);
+ // dtPointInPolygon will return false when the point is too close to the edge, so we rewrite the test function.
+ static bool PointInPoly(float* pos, float* verts, int nv, float err);
+ static float GetTriangleArea(float* verts, int nv);
- dtPolyRef GetPathPolyByPosition(dtPolyRef const* polyPath, uint32 polyPathSize, float const* Point, float* Distance = NULL) const;
- dtPolyRef GetPolyByLocation(float const* Point, float* Distance) const;
- bool HaveTile(G3D::Vector3 const& p) const;
-
- void BuildPolyPath(G3D::Vector3 const& startPos, G3D::Vector3 const& endPos);
- void BuildPointPath(float const* startPoint, float const* endPoint);
- void BuildShortcut();
-
- NavTerrain GetNavTerrain(float x, float y, float z);
void CreateFilter();
void UpdateFilter();
-
- // smooth path aux functions
- uint32 FixupCorridor(dtPolyRef* path, uint32 npath, uint32 maxPath, dtPolyRef const* visited, uint32 nvisited);
- bool GetSteerTarget(float const* startPos, float const* endPos, float minTargetDist, dtPolyRef const* path, uint32 pathSize, float* steerPos,
- unsigned char& steerPosFlag, dtPolyRef& steerPosRef);
- dtStatus FindSmoothPath(float const* startPos, float const* endPos,
- dtPolyRef const* polyPath, uint32 polyPathSize,
- float* smoothPath, int* smoothPathSize, uint32 smoothPathMaxSize);
};
#endif
diff --git a/src/server/game/Movement/Spline/Spline.cpp b/src/server/game/Movement/Spline/Spline.cpp
index 887541e2289..6424afc5d6e 100644
--- a/src/server/game/Movement/Spline/Spline.cpp
+++ b/src/server/game/Movement/Spline/Spline.cpp
@@ -156,7 +156,7 @@ float SplineBase::SegLengthLinear(index_type index) const
return (points[index] - points[index+1]).length();
}
-float SplineBase::SegLengthCatmullRom( index_type index ) const
+float SplineBase::SegLengthCatmullRom(index_type index) const
{
ASSERT(index >= index_lo && index < index_hi);
diff --git a/src/server/game/Movement/Spline/Spline.h b/src/server/game/Movement/Spline/Spline.h
index dab31e957f1..1444b2872d1 100644
--- a/src/server/game/Movement/Spline/Spline.h
+++ b/src/server/game/Movement/Spline/Spline.h
@@ -118,7 +118,7 @@ public:
/** As i can see there are a lot of ways how spline can be initialized
would be no harm to have some custom initializers. */
- template<class Init> inline void init_spline(Init& initializer)
+ template<class Init> inline void init_spline_custom(Init& initializer)
{
initializer(m_mode, cyclic, points, index_lo, index_hi);
}
diff --git a/src/server/game/Quests/QuestDef.h b/src/server/game/Quests/QuestDef.h
index 599780d5cbe..2464b99c0ab 100644
--- a/src/server/game/Quests/QuestDef.h
+++ b/src/server/game/Quests/QuestDef.h
@@ -123,6 +123,9 @@ enum QuestGiverStatus
DIALOG_STATUS_AVAILABLE = 0x100,
DIALOG_STATUS_REWARD2 = 0x200, // no yellow dot on minimap
DIALOG_STATUS_REWARD = 0x400 // yellow dot on minimap
+
+ // Custom value meaning that script call did not return any valid quest status
+ DIALOG_STATUS_SCRIPTED_NO_STATUS = 0x1000,
};
enum QuestFlags
diff --git a/src/server/game/Scripting/MapScripts.cpp b/src/server/game/Scripting/MapScripts.cpp
index 7f2e1f095e4..b9765bbbdc2 100644
--- a/src/server/game/Scripting/MapScripts.cpp
+++ b/src/server/game/Scripting/MapScripts.cpp
@@ -166,7 +166,7 @@ inline Unit* Map::_GetScriptUnit(Object* obj, bool isSource, const ScriptInfo* s
{
unit = obj->ToUnit();
if (!unit)
- TC_LOG_ERROR("scripts", "%s %s object could not be casted to unit.",
+ TC_LOG_ERROR("scripts", "%s %s object could not be cast to unit.",
scriptInfo->GetDebugInfo().c_str(), isSource ? "source" : "target");
}
return unit;
@@ -242,7 +242,7 @@ inline void Map::_ScriptProcessDoor(Object* source, Object* target, const Script
{
WorldObject* wSource = dynamic_cast <WorldObject*> (source);
if (!wSource)
- TC_LOG_ERROR("scripts", "%s source object could not be casted to world object (TypeId: %u, Entry: %u, GUID: %u), skipping.",
+ TC_LOG_ERROR("scripts", "%s source object could not be cast to world object (TypeId: %u, Entry: %u, GUID: %u), skipping.",
scriptInfo->GetDebugInfo().c_str(), source->GetTypeId(), source->GetEntry(), source->GetGUIDLow());
else
{
diff --git a/src/server/game/Scripting/ScriptMgr.cpp b/src/server/game/Scripting/ScriptMgr.cpp
index ddf6fe3a093..20b40051c19 100644
--- a/src/server/game/Scripting/ScriptMgr.cpp
+++ b/src/server/game/Scripting/ScriptMgr.cpp
@@ -778,8 +778,7 @@ uint32 ScriptMgr::GetDialogStatus(Player* player, Creature* creature)
ASSERT(player);
ASSERT(creature);
- /// @todo 100 is a funny magic number to have hanging around here...
- GET_SCRIPT_RET(CreatureScript, creature->GetScriptId(), tmpscript, 100);
+ GET_SCRIPT_RET(CreatureScript, creature->GetScriptId(), tmpscript, DIALOG_STATUS_SCRIPTED_NO_STATUS);
player->PlayerTalkClass->ClearMenus();
return tmpscript->GetDialogStatus(player, creature);
}
@@ -864,8 +863,7 @@ uint32 ScriptMgr::GetDialogStatus(Player* player, GameObject* go)
ASSERT(player);
ASSERT(go);
- /// @todo 100 is a funny magic number to have hanging around here...
- GET_SCRIPT_RET(GameObjectScript, go->GetScriptId(), tmpscript, 100);
+ GET_SCRIPT_RET(GameObjectScript, go->GetScriptId(), tmpscript, DIALOG_STATUS_SCRIPTED_NO_STATUS);
player->PlayerTalkClass->ClearMenus();
return tmpscript->GetDialogStatus(player, go);
}
diff --git a/src/server/game/Scripting/ScriptMgr.h b/src/server/game/Scripting/ScriptMgr.h
index 86ddc377bc2..a10707924e4 100644
--- a/src/server/game/Scripting/ScriptMgr.h
+++ b/src/server/game/Scripting/ScriptMgr.h
@@ -24,6 +24,7 @@
#include <ace/Atomic_Op.h>
#include "DBCStores.h"
+#include "QuestDef.h"
#include "SharedDefines.h"
#include "World.h"
#include "Weather.h"
@@ -446,7 +447,7 @@ class CreatureScript : public UnitScript, public UpdatableScript<Creature>
virtual bool OnQuestReward(Player* /*player*/, Creature* /*creature*/, Quest const* /*quest*/, uint32 /*opt*/) { return false; }
// Called when the dialog status between a player and the creature is requested.
- virtual uint32 GetDialogStatus(Player* /*player*/, Creature* /*creature*/) { return 100; }
+ virtual uint32 GetDialogStatus(Player* /*player*/, Creature* /*creature*/) { return DIALOG_STATUS_SCRIPTED_NO_STATUS; }
// Called when a CreatureAI object is needed for the creature.
virtual CreatureAI* GetAI(Creature* /*creature*/) const { return NULL; }
@@ -481,7 +482,7 @@ class GameObjectScript : public ScriptObject, public UpdatableScript<GameObject>
virtual bool OnQuestReward(Player* /*player*/, GameObject* /*go*/, Quest const* /*quest*/, uint32 /*opt*/) { return false; }
// Called when the dialog status between a player and the gameobject is requested.
- virtual uint32 GetDialogStatus(Player* /*player*/, GameObject* /*go*/) { return 100; }
+ virtual uint32 GetDialogStatus(Player* /*player*/, GameObject* /*go*/) { return DIALOG_STATUS_SCRIPTED_NO_STATUS; }
// Called when the game object is destroyed (destructible buildings only).
virtual void OnDestroyed(GameObject* /*go*/, Player* /*player*/) { }
diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h
index 4954d099dab..7227254b9f7 100644
--- a/src/server/game/Server/WorldSession.h
+++ b/src/server/game/Server/WorldSession.h
@@ -363,7 +363,7 @@ class WorldSession
uint32 GetLatency() const { return m_latency; }
void SetLatency(uint32 latency) { m_latency = latency; }
void ResetClientTimeDelay() { m_clientTimeDelay = 0; }
- uint32 getDialogStatus(Player* player, Object* questgiver, uint32 defstatus);
+ uint32 getDialogStatus(Player* player, Object* questgiver);
ACE_Atomic_Op<ACE_Thread_Mutex, time_t> m_timeOutTime;
void UpdateTimeOutTime(uint32 diff)
diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
index 4a9854333a5..53350f8328a 100644
--- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp
+++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
@@ -804,7 +804,7 @@ void AuraEffect::ApplySpellMod(Unit* target, bool apply)
{
Aura* aura = iter->second->GetBase();
// only passive and permament auras-active auras should have amount set on spellcast and not be affected
- // if aura is casted by others, it will not be affected
+ // if aura is cast by others, it will not be affected
if ((aura->IsPassive() || aura->IsPermanent()) && aura->GetCasterGUID() == guid && aura->GetSpellInfo()->IsAffectedBySpellMod(m_spellmod))
{
if (GetMiscValue() == SPELLMOD_ALL_EFFECTS)
@@ -4704,7 +4704,7 @@ void AuraEffect::HandleAuraDummy(AuraApplication const* aurApp, uint8 mode, bool
case 42783: // Wrath of the Astromancer
target->CastSpell(target, GetAmount(), true, NULL, this);
break;
- case 46308: // Burning Winds casted only at creatures at spawn
+ case 46308: // Burning Winds cast only at creatures at spawn
target->CastSpell(target, 47287, true, NULL, this);
break;
case 52172: // Coyote Spirit Despawn Aura
diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp
index a984ee7b035..4a1eeed46b1 100644
--- a/src/server/game/Spells/Auras/SpellAuras.cpp
+++ b/src/server/game/Spells/Auras/SpellAuras.cpp
@@ -114,12 +114,12 @@ void AuraApplication::_Remove()
void AuraApplication::_InitFlags(Unit* caster, uint8 effMask)
{
- // mark as selfcasted if needed
+ // mark as selfcast if needed
_flags |= (GetBase()->GetCasterGUID() == GetTarget()->GetGUID()) ? AFLAG_CASTER : AFLAG_NONE;
- // aura is casted by self or an enemy
+ // aura is cast by self or an enemy
// one negative effect and we know aura is negative
- if (IsSelfcasted() || !caster || !caster->IsFriendlyTo(GetTarget()))
+ if (IsSelfcast() || !caster || !caster->IsFriendlyTo(GetTarget()))
{
bool negativeFound = false;
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
@@ -132,7 +132,7 @@ void AuraApplication::_InitFlags(Unit* caster, uint8 effMask)
}
_flags |= negativeFound ? AFLAG_NEGATIVE : AFLAG_POSITIVE;
}
- // aura is casted by friend
+ // aura is cast by friend
// one positive effect and we know aura is positive
else
{
@@ -315,7 +315,7 @@ Aura* Aura::Create(SpellInfo const* spellproto, uint8 effMask, WorldObject* owne
// check if aura can be owned by owner
if (owner->isType(TYPEMASK_UNIT))
if (!owner->IsInWorld() || ((Unit*)owner)->IsDuringRemoveFromWorld())
- // owner not in world so don't allow to own not self casted single target auras
+ // owner not in world so don't allow to own not self cast single target auras
if (casterGUID != owner->GetGUID() && spellproto->IsSingleTarget())
return NULL;
@@ -1284,7 +1284,7 @@ void Aura::HandleAuraSpecificMods(AuraApplication const* aurApp, Unit* caster, b
}
break;
case SPELLFAMILY_ROGUE:
- // Sprint (skip non player casted spells by category)
+ // 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
@@ -1500,7 +1500,7 @@ bool Aura::CanBeAppliedOn(Unit* target)
// area auras mustn't be applied
if (GetOwner() != target)
return false;
- // not selfcasted single target auras mustn't be applied
+ // do not apply non-selfcast single target auras
if (GetCasterGUID() != GetOwner()->GetGUID() && GetSpellInfo()->IsSingleTarget())
return false;
return true;
diff --git a/src/server/game/Spells/Auras/SpellAuras.h b/src/server/game/Spells/Auras/SpellAuras.h
index 9e7d0cce82c..123ad9d5a8a 100644
--- a/src/server/game/Spells/Auras/SpellAuras.h
+++ b/src/server/game/Spells/Auras/SpellAuras.h
@@ -69,7 +69,7 @@ class AuraApplication
uint8 GetEffectMask() const { return _flags & (AFLAG_EFF_INDEX_0 | AFLAG_EFF_INDEX_1 | AFLAG_EFF_INDEX_2); }
bool HasEffect(uint8 effect) const { ASSERT(effect < MAX_SPELL_EFFECTS); return _flags & (1<<effect); }
bool IsPositive() const { return _flags & AFLAG_POSITIVE; }
- bool IsSelfcasted() const { return _flags & AFLAG_CASTER; }
+ bool IsSelfcast() const { return _flags & AFLAG_CASTER; }
uint8 GetEffectsToApply() const { return _effectsToApply; }
void SetRemoveMode(AuraRemoveMode mode) { _removeMode = mode; }
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index 08d500ec666..a46f5cdaa9a 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -2409,7 +2409,7 @@ void Spell::DoAllEffectOnTarget(TargetInfo* target)
m_spellAura = NULL; // Set aura to null for every target-make sure that pointer is not used for unit without aura applied
- //Spells with this flag cannot trigger if effect is casted on self
+ //Spells with this flag cannot trigger if effect is cast on self
bool canEffectTrigger = !(m_spellInfo->AttributesEx3 & SPELL_ATTR3_CANT_TRIGGER_PROC) && unitTarget->CanProc() && CanExecuteTriggersOnHit(mask);
Unit* spellHitTarget = NULL;
@@ -3000,7 +3000,7 @@ void Spell::prepare(SpellCastTargets const* targets, AuraEffect const* triggered
m_caster->m_Events.AddEvent(Event, m_caster->m_Events.CalculateTime(1));
//Prevent casting at cast another spell (ServerSide check)
- if (!(_triggeredCastFlags & TRIGGERED_IGNORE_CAST_IN_PROGRESS) && m_caster->IsNonMeleeSpellCasted(false, true, true) && m_cast_count)
+ if (!(_triggeredCastFlags & TRIGGERED_IGNORE_CAST_IN_PROGRESS) && m_caster->IsNonMeleeSpellCast(false, true, true) && m_cast_count)
{
SendCastResult(SPELL_FAILED_SPELL_IN_PROGRESS);
finish(false);
@@ -3067,7 +3067,7 @@ void Spell::prepare(SpellCastTargets const* targets, AuraEffect const* triggered
else
m_casttime = m_spellInfo->CalcCastTime(m_caster->getLevel(), this);
- // don't allow channeled spells / spells with cast time to be casted while moving
+ // don't allow channeled spells / spells with cast time to be cast while moving
// (even if they are interrupted on moving, spells with almost immediate effect get to have their effect processed before movement interrupter kicks in)
// don't cancel spells which are affected by a SPELL_AURA_CAST_WHILE_WALKING effect
if (((m_spellInfo->IsChanneled() || m_casttime) && m_caster->GetTypeId() == TYPEID_PLAYER && m_caster->isMoving() &&
@@ -3084,7 +3084,7 @@ void Spell::prepare(SpellCastTargets const* targets, AuraEffect const* triggered
TC_LOG_DEBUG("spells", "Spell::prepare: spell id %u source %u caster %d customCastFlags %u mask %u", m_spellInfo->Id, m_caster->GetEntry(), m_originalCaster ? m_originalCaster->GetEntry() : -1, _triggeredCastFlags, m_targets.GetTargetMask());
//Containers for channeled spells have to be set
- /// @todoApply this to all casted spells if needed
+ /// @todoApply this to all cast spells if needed
// Why check duration? 29350: channelled triggers channelled
if ((_triggeredCastFlags & TRIGGERED_CAST_DIRECTLY) && (!m_spellInfo->IsChanneled() || !m_spellInfo->GetMaxDuration()))
cast(true);
@@ -3103,7 +3103,7 @@ void Spell::prepare(SpellCastTargets const* targets, AuraEffect const* triggered
}
}
- m_caster->SetCurrentCastedSpell(this);
+ m_caster->SetCurrentCastSpell(this);
SendSpellStart();
// set target for proper facing
@@ -3213,7 +3213,7 @@ void Spell::cast(bool skipCheck)
if (m_caster->GetTypeId() == TYPEID_PLAYER)
{
// Set spell which will drop charges for triggered cast spells
- // if not successfully casted, will be remove in finish(false)
+ // if not successfully cast, will be remove in finish(false)
m_caster->ToPlayer()->SetSpellModTakingSpell(this, true);
}
@@ -3250,7 +3250,7 @@ void Spell::cast(bool skipCheck)
{
if (!my_trade->IsInAcceptProcess())
{
- // Spell will be casted at completing the trade. Silently ignore at this place
+ // Spell will be cast after completing the trade. Silently ignore at this place
my_trade->SetSpell(m_spellInfo->Id, m_CastItem);
SendCastResult(SPELL_FAILED_DONT_REPORT);
SendInterrupted(0);
@@ -3340,7 +3340,7 @@ void Spell::cast(bool skipCheck)
m_spellState = SPELL_STATE_DELAYED;
SetDelayStart(0);
- if (m_caster->HasUnitState(UNIT_STATE_CASTING) && !m_caster->IsNonMeleeSpellCasted(false, false, true))
+ if (m_caster->HasUnitState(UNIT_STATE_CASTING) && !m_caster->IsNonMeleeSpellCast(false, false, true))
m_caster->ClearUnitState(UNIT_STATE_CASTING);
}
else
@@ -3667,7 +3667,7 @@ void Spell::finish(bool ok)
if (m_spellInfo->IsChanneled())
m_caster->UpdateInterruptMask();
- if (m_caster->HasUnitState(UNIT_STATE_CASTING) && !m_caster->IsNonMeleeSpellCasted(false, false, true))
+ if (m_caster->HasUnitState(UNIT_STATE_CASTING) && !m_caster->IsNonMeleeSpellCast(false, false, true))
m_caster->ClearUnitState(UNIT_STATE_CASTING);
// Unsummon summon as possessed creatures on spell cancel
@@ -4029,7 +4029,7 @@ void Spell::SendSpellGo()
if (castFlags & CAST_FLAG_RUNE_LIST) // rune cooldowns list
{
- /// @todo There is a crash caused by a spell with CAST_FLAG_RUNE_LIST casted by a creature
+ /// @todo There is a crash caused by a spell with CAST_FLAG_RUNE_LIST cast by a creature
//The creature is the mover of a player, so HandleCastSpellOpcode uses it as the caster
if (Player* player = m_caster->ToPlayer())
{
@@ -4975,7 +4975,7 @@ SpellCastResult Spell::CheckCast(bool strict)
if ((m_spellInfo->AttributesCu & SPELL_ATTR0_CU_REQ_TARGET_FACING_CASTER) && !target->HasInArc(static_cast<float>(M_PI), m_caster))
return SPELL_FAILED_NOT_INFRONT;
- if (m_caster->GetEntry() != WORLD_TRIGGER) // Ignore LOS for gameobjects casts (wrongly casted by a trigger)
+ if (m_caster->GetEntry() != WORLD_TRIGGER) // Ignore LOS for gameobjects casts (wrongly cast by a trigger)
if (!(m_spellInfo->AttributesEx2 & SPELL_ATTR2_CAN_TARGET_NOT_IN_LOS) && !DisableMgr::IsDisabledFor(DISABLE_TYPE_SPELL, m_spellInfo->Id, NULL, SPELL_DISABLE_LOS) && !m_caster->IsWithinLOSInMap(target))
return SPELL_FAILED_LINE_OF_SIGHT;
}
@@ -5007,7 +5007,7 @@ SpellCastResult Spell::CheckCast(bool strict)
}
}
- // Spell casted only on battleground
+ // Spell cast only in battleground
if ((m_spellInfo->AttributesEx3 & SPELL_ATTR3_BATTLEGROUND) && m_caster->GetTypeId() == TYPEID_PLAYER)
if (!m_caster->ToPlayer()->InBattleground())
return SPELL_FAILED_ONLY_BATTLEGROUNDS;
@@ -5230,7 +5230,6 @@ SpellCastResult Spell::CheckCast(bool strict)
target->GetContactPoint(m_caster, pos.m_positionX, pos.m_positionY, pos.m_positionZ);
target->GetFirstCollisionPosition(pos, CONTACT_DISTANCE, target->GetRelativeAngle(m_caster));
- m_preGeneratedPath.SetPathLengthLimit(m_spellInfo->GetMaxRange(true) * 1.5f);
bool result = m_preGeneratedPath.CalculatePath(pos.m_positionX, pos.m_positionY, pos.m_positionZ + target->GetObjectSize());
if (m_preGeneratedPath.GetPathType() & PATHFIND_SHORT)
return SPELL_FAILED_OUT_OF_RANGE;
@@ -5554,7 +5553,7 @@ SpellCastResult Spell::CheckCast(bool strict)
if (!m_targets.GetUnitTarget())
return SPELL_FAILED_BAD_IMPLICIT_TARGETS;
- // can be casted at non-friendly unit or own pet/charm
+ // can be cast at non-friendly unit or own pet/charm
if (m_caster->IsFriendlyTo(m_targets.GetUnitTarget()))
return SPELL_FAILED_TARGET_FRIENDLY;
@@ -5783,7 +5782,7 @@ SpellCastResult Spell::CheckCasterAuras() const
}
}
}
- // You are prevented from casting and the spell casted does not grant immunity. Return a failed error.
+ // You are prevented from casting and the spell cast does not grant immunity. Return a failed error.
else
return prevented_reason;
}
@@ -6190,19 +6189,39 @@ SpellCastResult Spell::CheckItems()
}
}
- SpellItemEnchantmentEntry const* pEnchant = sSpellItemEnchantmentStore.LookupEntry(m_spellInfo->Effects[i].MiscValue);
+ SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(m_spellInfo->Effects[i].MiscValue);
// do not allow adding usable enchantments to items that have use effect already
- if (pEnchant && isItemUsable)
+ if (enchantEntry)
+ {
for (uint8 s = 0; s < MAX_ITEM_ENCHANTMENT_EFFECTS; ++s)
- if (pEnchant->type[s] == ITEM_ENCHANTMENT_TYPE_USE_SPELL)
- return SPELL_FAILED_ON_USE_ENCHANT;
+ {
+ switch (enchantEntry->type[s])
+ {
+ case ITEM_ENCHANTMENT_TYPE_USE_SPELL:
+ if (isItemUsable)
+ return SPELL_FAILED_ON_USE_ENCHANT;
+ break;
+ case ITEM_ENCHANTMENT_TYPE_PRISMATIC_SOCKET:
+ {
+ uint32 numSockets = 0;
+ for (uint32 socket = 0; socket < MAX_ITEM_PROTO_SOCKETS; ++socket)
+ if (targetItem->GetTemplate()->Socket[socket].Color)
+ ++numSockets;
+
+ if (numSockets == MAX_ITEM_PROTO_SOCKETS || targetItem->GetEnchantmentId(PRISMATIC_ENCHANTMENT_SLOT))
+ return SPELL_FAILED_MAX_SOCKETS;
+ break;
+ }
+ }
+ }
+ }
// Not allow enchant in trade slot for some enchant type
if (targetItem->GetOwner() != m_caster)
{
- if (!pEnchant)
+ if (!enchantEntry)
return SPELL_FAILED_ERROR;
- if (pEnchant->slot & ENCHANTMENT_CAN_SOULBOUND)
+ if (enchantEntry->slot & ENCHANTMENT_CAN_SOULBOUND)
return SPELL_FAILED_NOT_TRADEABLE;
}
break;
@@ -6671,11 +6690,11 @@ bool SpellEvent::Execute(uint64 e_time, uint32 p_time)
/*
if (m_Spell->m_spellInfo->IsChanneled())
{
- // evented channeled spell is processed separately, casted once after delay, and not destroyed till finish
+ // evented channeled spell is processed separately, cast once after delay, and not destroyed till finish
// check, if we have casting anything else except this channeled spell and autorepeat
- if (m_Spell->GetCaster()->IsNonMeleeSpellCasted(false, true, true))
+ if (m_Spell->GetCaster()->IsNonMeleeSpellCast(false, true, true))
{
- // another non-melee non-delayed spell is casted now, abort
+ // another non-melee non-delayed spell is cast now, abort
m_Spell->cancel();
}
else
@@ -6898,7 +6917,7 @@ SpellCastResult Spell::CanOpenLock(uint32 effIndex, uint32 lockId, SkillType& sk
0 : m_caster->ToPlayer()->GetSkillValue(skillId);
// skill bonus provided by casting spell (mostly item spells)
- // add the effect base points modifier from the spell casted (cheat lock / skeleton key etc.)
+ // add the effect base points modifier from the spell cast (cheat lock / skeleton key etc.)
if (m_spellInfo->Effects[effIndex].TargetA.GetTarget() == TARGET_GAMEOBJECT_ITEM_TARGET || m_spellInfo->Effects[effIndex].TargetB.GetTarget() == TARGET_GAMEOBJECT_ITEM_TARGET)
skillValue += m_spellInfo->Effects[effIndex].CalcValue();
@@ -7199,7 +7218,7 @@ bool Spell::CheckScriptEffectImplicitTargets(uint32 effIndex, uint32 effIndexToC
bool Spell::CanExecuteTriggersOnHit(uint8 effMask, SpellInfo const* triggeredByAura) const
{
bool only_on_caster = (triggeredByAura && (triggeredByAura->AttributesEx4 & SPELL_ATTR4_PROC_ONLY_ON_CASTER));
- // If triggeredByAura has SPELL_ATTR4_PROC_ONLY_ON_CASTER then it can only proc on a casted spell with TARGET_UNIT_CASTER
+ // If triggeredByAura has SPELL_ATTR4_PROC_ONLY_ON_CASTER then it can only proc on a cast spell with TARGET_UNIT_CASTER
for (uint8 i = 0;i < MAX_SPELL_EFFECTS; ++i)
{
if ((effMask & (1 << i)) && (!only_on_caster || (m_spellInfo->Effects[i].TargetA.GetTarget() == TARGET_UNIT_CASTER)))
@@ -7289,7 +7308,7 @@ void Spell::TriggerGlobalCooldown()
return;
// Global cooldown can't leave range 1..1.5 secs
- // There are some spells (mostly not casted directly by player) that have < 1 sec and > 1.5 sec global cooldowns
+ // There are some spells (mostly not cast directly by player) that have < 1 sec and > 1.5 sec global cooldowns
// but as tests show are not affected by any spell mods.
if (m_spellInfo->StartRecoveryTime >= MIN_GCD && m_spellInfo->StartRecoveryTime <= MAX_GCD)
{
diff --git a/src/server/game/Spells/Spell.h b/src/server/game/Spells/Spell.h
index 37316e1d6bb..b6cf0a1f9b7 100644
--- a/src/server/game/Spells/Spell.h
+++ b/src/server/game/Spells/Spell.h
@@ -209,7 +209,7 @@ enum SpellEffectHandleMode
class Spell
{
- friend void Unit::SetCurrentCastedSpell(Spell* pSpell);
+ friend void Unit::SetCurrentCastSpell(Spell* pSpell);
friend class SpellScript;
public:
diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp
index a22e32abf82..922074970b2 100644
--- a/src/server/game/Spells/SpellEffects.cpp
+++ b/src/server/game/Spells/SpellEffects.cpp
@@ -4614,8 +4614,8 @@ void Spell::EffectKnockBack(SpellEffIndex effIndex)
if (unitTarget->HasUnitState(UNIT_STATE_ROOT | UNIT_STATE_STUNNED))
return;
- // Instantly interrupt non melee spells being casted
- if (unitTarget->IsNonMeleeSpellCasted(true))
+ // Instantly interrupt non melee spells being cast
+ if (unitTarget->IsNonMeleeSpellCast(true))
unitTarget->InterruptNonMeleeSpells(true);
float ratio = 0.1f;
@@ -4716,8 +4716,6 @@ void Spell::EffectPullTowards(SpellEffIndex effIndex)
if (!unitTarget)
return;
- float speedZ = (float)(m_spellInfo->Effects[effIndex].CalcValue() / 10);
- float speedXY = (float)(m_spellInfo->Effects[effIndex].MiscValue/10);
Position pos;
if (m_spellInfo->Effects[effIndex].Effect == SPELL_EFFECT_PULL_TOWARDS_DEST)
{
@@ -4731,6 +4729,9 @@ void Spell::EffectPullTowards(SpellEffIndex effIndex)
pos.Relocate(m_caster);
}
+ float speedXY = float(m_spellInfo->Effects[effIndex].MiscValue) * 0.1f;
+ float speedZ = unitTarget->GetDistance(pos) / speedXY * 0.5f * Movement::gravity;
+
unitTarget->GetMotionMaster()->MoveJump(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), speedXY, speedZ);
}
diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp
index 79a8c54cdbb..9bf2059b618 100644
--- a/src/server/game/Spells/SpellInfo.cpp
+++ b/src/server/game/Spells/SpellInfo.cpp
@@ -1478,10 +1478,10 @@ SpellCastResult SpellInfo::CheckShapeshift(uint32 form) const
uint32 stanceMask = (form ? 1 << (form - 1) : 0);
- if (stanceMask & StancesNot) // can explicitly not be casted in this stance
+ if (stanceMask & StancesNot) // can explicitly not be cast in this stance
return SPELL_FAILED_NOT_SHAPESHIFT;
- if (stanceMask & Stances) // can explicitly be casted in this stance
+ if (stanceMask & Stances) // can explicitly be cast in this stance
return SPELL_CAST_OK;
bool actAsShifted = false;
@@ -2711,12 +2711,12 @@ bool SpellInfo::_IsPositiveEffect(uint8 effIndex, bool deep) const
case SPELL_AURA_PREVENT_RESURRECTION:
return false;
case SPELL_AURA_PERIODIC_DAMAGE: // used in positive spells also.
- // part of negative spell if casted at self (prevent cancel)
+ // part of negative spell if cast at self (prevent cancel)
if (Effects[effIndex].TargetA.GetTarget() == TARGET_UNIT_CASTER)
return false;
break;
case SPELL_AURA_MOD_DECREASE_SPEED: // used in positive spells also
- // part of positive spell if casted at self
+ // part of positive spell if cast at self
if (Effects[effIndex].TargetA.GetTarget() != TARGET_UNIT_CASTER)
return false;
// but not this if this first effect (didn't find better check)
diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp
index 6d58da9095b..945f907f548 100644
--- a/src/server/game/Spells/SpellMgr.cpp
+++ b/src/server/game/Spells/SpellMgr.cpp
@@ -1528,8 +1528,8 @@ void SpellMgr::LoadSpellLearnSpells()
if (!GetSpellInfo(dbc_node.spell))
continue;
- // talent or passive spells or skill-step spells auto-casted and not need dependent learning,
- // pet teaching spells must not be dependent learning (casted)
+ // talent or passive spells or skill-step spells auto-cast and not need dependent learning,
+ // pet teaching spells must not be dependent learning (cast)
// other required explicit dependent learning
dbc_node.autoLearned = entry->Effects[i].TargetA.GetTarget() == TARGET_UNIT_PET || GetTalentSpellCost(spell) > 0 || entry->IsPassive() || entry->HasEffect(SPELL_EFFECT_SKILL_STEP);
@@ -3725,7 +3725,7 @@ void SpellMgr::LoadSpellInfoCorrections()
break;
// This would never crit on retail and it has attribute for SPELL_ATTR3_NO_DONE_BONUS because is handled from player,
// until someone figures how to make scions not critting without hack and without making them main casters this should stay here.
- case 63934: // Arcane Barrage (casted by players and NONMELEEDAMAGELOG with caster Scion of Eternity (original caster)).
+ case 63934: // Arcane Barrage (cast by players and NONMELEEDAMAGELOG with caster Scion of Eternity (original caster)).
spellInfo->AttributesEx2 |= SPELL_ATTR2_CANT_CRIT;
break;
// ENDOF EYE OF ETERNITY SPELLS
diff --git a/src/server/game/Spells/SpellScript.h b/src/server/game/Spells/SpellScript.h
index 0d5643bc50c..4c25adb0476 100644
--- a/src/server/game/Spells/SpellScript.h
+++ b/src/server/game/Spells/SpellScript.h
@@ -775,11 +775,11 @@ class AuraScript : public _SpellScript
// returns spellid of the spell
uint32 GetId() const;
- // returns guid of object which casted the aura (m_originalCaster of the Spell class)
+ // returns guid of object which cast the aura (m_originalCaster of the Spell class)
uint64 GetCasterGUID() const;
- // returns unit which casted the aura or NULL if not avalible (caster logged out for example)
+ // returns unit which cast the aura or NULL if not avalible (caster logged out for example)
Unit* GetCaster() const;
- // returns object on which aura was casted, target for non-area auras, area aura source for area auras
+ // returns object on which aura was cast, target for non-area auras, area aura source for area auras
WorldObject* GetOwner() const;
// returns owner if it's unit or unit derived object, NULL otherwise (only for persistent area auras NULL is returned)
Unit* GetUnitOwner() const;
diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp
index 8c3d92dcbfe..91606b7214a 100644
--- a/src/server/game/World/World.cpp
+++ b/src/server/game/World/World.cpp
@@ -152,7 +152,7 @@ World::~World()
delete command;
VMAP::VMapFactory::clear();
- MMAP::MMapFactory::clear();
+ MMAP::MMapFactory::Clear();
/// @todo free addSessQueue
}
diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp
index b3f2cadf3a9..31c3c5a9051 100644
--- a/src/server/scripts/Commands/cs_debug.cpp
+++ b/src/server/scripts/Commands/cs_debug.cpp
@@ -1376,7 +1376,10 @@ public:
}
else
{
+ Position pos;
+ transport->GetPosition(&pos);
handler->PSendSysMessage("Transport %s is %s", transport->GetName().c_str(), transport->GetGoState() == GO_STATE_READY ? "stopped" : "moving");
+ handler->PSendSysMessage("Transport position: %s", pos.ToString().c_str());
return true;
}
diff --git a/src/server/scripts/Commands/cs_go.cpp b/src/server/scripts/Commands/cs_go.cpp
index 54ea09c3996..af2b6cd89b0 100644
--- a/src/server/scripts/Commands/cs_go.cpp
+++ b/src/server/scripts/Commands/cs_go.cpp
@@ -112,7 +112,7 @@ public:
{
std::string name = param1;
WorldDatabase.EscapeString(name);
- whereClause << ", creature_template WHERE creature.id = creature_template.entry AND creature_template.name "_LIKE_" '" << name << '\'';
+ whereClause << ", creature_template WHERE creature.id = creature_template.entry AND creature_template.name " _LIKE_" '" << name << '\'';
}
else
whereClause << "WHERE guid = '" << guid << '\'';
diff --git a/src/server/scripts/Commands/cs_gobject.cpp b/src/server/scripts/Commands/cs_gobject.cpp
index a49926678ba..14e072b9dea 100644
--- a/src/server/scripts/Commands/cs_gobject.cpp
+++ b/src/server/scripts/Commands/cs_gobject.cpp
@@ -238,7 +238,7 @@ public:
WorldDatabase.EscapeString(name);
result = WorldDatabase.PQuery(
"SELECT guid, id, position_x, position_y, position_z, orientation, map, phaseMask, (POW(position_x - %f, 2) + POW(position_y - %f, 2) + POW(position_z - %f, 2)) AS order_ "
- "FROM gameobject, gameobject_template WHERE gameobject_template.entry = gameobject.id AND map = %i AND name "_LIKE_" "_CONCAT3_("'%%'", "'%s'", "'%%'")" ORDER BY order_ ASC LIMIT 1",
+ "FROM gameobject, gameobject_template WHERE gameobject_template.entry = gameobject.id AND map = %i AND name " _LIKE_" " _CONCAT3_("'%%'", "'%s'", "'%%'")" ORDER BY order_ ASC LIMIT 1",
player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetMapId(), name.c_str());
}
}
diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp
index 406fac9cd67..0ebc90c53f3 100644
--- a/src/server/scripts/Commands/cs_misc.cpp
+++ b/src/server/scripts/Commands/cs_misc.cpp
@@ -186,7 +186,7 @@ public:
uint32 haveMap = Map::ExistMap(mapId, gridX, gridY) ? 1 : 0;
uint32 haveVMap = Map::ExistVMap(mapId, gridX, gridY) ? 1 : 0;
- uint32 haveMMap = (MMAP::MMapFactory::IsPathfindingEnabled(mapId) && MMAP::MMapFactory::createOrGetMMapManager()->GetNavMesh(handler->GetSession()->GetPlayer()->GetMapId())) ? 1 : 0;
+ uint32 haveMMap = (MMAP::MMapFactory::IsPathfindingEnabled(mapId) && MMAP::MMapFactory::CreateOrGetMMapManager()->GetNavMesh(handler->GetSession()->GetPlayer()->GetMapId())) ? 1 : 0;
if (haveVMap)
{
@@ -2273,7 +2273,7 @@ public:
// stop combat + make player unattackable + duel stop + stop some spells
player->setFaction(35);
player->CombatStop();
- if (player->IsNonMeleeSpellCasted(true))
+ if (player->IsNonMeleeSpellCast(true))
player->InterruptNonMeleeSpells(true);
player->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
diff --git a/src/server/scripts/Commands/cs_mmaps.cpp b/src/server/scripts/Commands/cs_mmaps.cpp
index 690988ebac1..88e364878cc 100644
--- a/src/server/scripts/Commands/cs_mmaps.cpp
+++ b/src/server/scripts/Commands/cs_mmaps.cpp
@@ -30,11 +30,13 @@
#include "PointMovementGenerator.h"
#include "PathGenerator.h"
#include "MMapFactory.h"
+#include "DetourCommon.h"
#include "Map.h"
#include "TargetedMovementGenerator.h"
#include "GridNotifiers.h"
#include "GridNotifiersImpl.h"
#include "CellImpl.h"
+#include "MMapManager.h"
class mmaps_commandscript : public CommandScript
{
@@ -61,9 +63,137 @@ public:
return commandTable;
}
+ static float Fix_GetXZArea(float* verts, int nv)
+ {
+ float area = 0;
+ for(int i=0; i<nv-1; i++)
+ area+=(verts[i*3]*verts[i*3+5]-verts[i*3+3]*verts[i*3+2]);
+ area += (verts[(nv-1)*3]*verts[2] - verts[0]*verts[(nv-1)*3+2]);
+ return area*0.5f;
+ }
+
+
+ //dtPointInPolygon will return false when the point is too close to the edge,so we rewite the test function.
+ static bool Fix_PointIsInPoly(float* pos,float* verts,int nv,float err)
+ {
+ //poly area
+ float area = abs(Fix_GetXZArea(verts,nv));
+
+ //calculate each area of triangles
+ float TestTri[9];
+ memcpy(TestTri,pos,sizeof(float)*3);
+ float area1 = 0;
+ for(int i=0;i<nv-1;++i)
+ {
+ memcpy(&TestTri[3],&verts[i*3],sizeof(float)*3);
+ memcpy(&TestTri[6],&verts[i*3+3],sizeof(float)*3);
+ area1+= abs(Fix_GetXZArea(TestTri,3));
+ if(area1-err>area)
+ return false;
+ }
+
+ //last one
+ memcpy(&TestTri[3],verts,sizeof(float)*3);
+ memcpy(&TestTri[6],&verts[nv*3-3],sizeof(float)*3);
+ area1+= abs(Fix_GetXZArea(TestTri,3));
+
+ return abs(area1-area)<err;
+ }
+
+
+ static float DistanceToWall(dtNavMeshQuery* navQuery, dtNavMesh* navMesh, float* polyPickExt, dtQueryFilter& filter, float* pos,float* hitPos,float* hitNormal)
+ {
+ float distanceToWall=0;
+ dtPolyRef ref;
+ if(dtStatusSucceed(navQuery->findNearestPoly(pos, polyPickExt, &filter, &ref, 0))==false || ref ==0)
+ return -1;
+
+ const dtMeshTile* tile = 0;
+ const dtPoly* poly = 0;
+ if (dtStatusFailed(navMesh->getTileAndPolyByRef(ref, &tile, &poly)))
+ return -1;
+
+ // Collect vertices.
+ float verts[DT_VERTS_PER_POLYGON*3];
+ int nv = 0;
+ for (int i = 0; i < (int)poly->vertCount; ++i)
+ {
+ dtVcopy(&verts[nv*3], &tile->verts[poly->verts[i]*3]);
+ nv++;
+ }
+
+ bool inside = Fix_PointIsInPoly(pos, verts, nv,0.05f);
+ if(inside == false)
+ return -1;
+
+ if(dtStatusSucceed(navQuery->findDistanceToWall(ref, pos, 100.0f, &filter, &distanceToWall, hitPos, hitNormal))==false)
+ return -1;
+
+ return distanceToWall;
+ }
+
+ #define MIN_WALL_DISTANCE 1.5f //set this value bigger to make the path point far way from wall
+
+ //Try to fix the path,
+ static void FixPath(dtNavMesh* navMesh, dtNavMeshQuery* navQuery, float* polyPickExt, dtQueryFilter& filter, int pathLength, float*& straightPath)
+ {
+ float hitPos[3];
+ float hitNormal[3];
+ float TestPos[3];
+ float distanceToWall=0;
+ float up[3]={0,1,0};
+ float origDis = 0;
+
+ for(int i=1;i<pathLength-1;++i)
+ {
+ dtPolyRef pt;
+ float* pCurPoi=&straightPath[i*3];
+ distanceToWall = DistanceToWall(navQuery, navMesh, polyPickExt, filter, pCurPoi,hitPos,hitNormal);
+
+ if(distanceToWall<MIN_WALL_DISTANCE && distanceToWall>=0)
+ {
+ float vec[3];
+ dtVsub(vec,&straightPath[i*3-3],&straightPath[i*3]);
+ //distanceToWall is 0 means the point is in the edge.so we can't get the hitpos.
+ if(distanceToWall == 0)
+ {
+ //test left side
+ dtVcross(TestPos,vec,up);
+ dtVadd(TestPos,TestPos,pCurPoi);
+ float ft = MIN_WALL_DISTANCE/dtVdist(TestPos,pCurPoi);
+ dtVlerp(TestPos,pCurPoi,TestPos,ft);
+ distanceToWall = DistanceToWall(navQuery, navMesh, polyPickExt, filter,TestPos,hitPos,hitNormal);
+ if(abs(MIN_WALL_DISTANCE - distanceToWall)>0.1f)
+ {
+ //test right side
+ dtVcross(TestPos,up,vec);
+ dtVadd(TestPos,TestPos,pCurPoi);
+ ft = MIN_WALL_DISTANCE/dtVdist(TestPos,pCurPoi);
+ dtVlerp(TestPos,pCurPoi,TestPos,ft);
+ distanceToWall = DistanceToWall(navQuery, navMesh, polyPickExt, filter,TestPos,hitPos,hitNormal);
+ }
+
+ //if test point is better than the orig point,replace it.
+ if(abs(distanceToWall-MIN_WALL_DISTANCE)<0.1f)
+ dtVcopy(pCurPoi,TestPos);
+ }
+ else
+ {
+ //ok,we get the hitpos,just make a ray
+ float ft = MIN_WALL_DISTANCE/distanceToWall;
+ dtVlerp(TestPos,hitPos,pCurPoi,ft);
+ distanceToWall = DistanceToWall(navQuery, navMesh, polyPickExt, filter, TestPos,hitPos,hitNormal);
+
+ if(abs(distanceToWall-MIN_WALL_DISTANCE)<0.1f)
+ dtVcopy(pCurPoi,TestPos);
+ }
+ }
+ }
+ }
+
static bool HandleMmapPathCommand(ChatHandler* handler, char const* args)
{
- if (!MMAP::MMapFactory::createOrGetMMapManager()->GetNavMesh(handler->GetSession()->GetPlayer()->GetMapId()))
+ if (!MMAP::MMapFactory::CreateOrGetMMapManager()->GetNavMesh(handler->GetSession()->GetPlayer()->GetMapId()))
{
handler->PSendSysMessage("NavMesh not loaded for current map.");
return true;
@@ -91,10 +221,10 @@ public:
player->GetPosition(x, y, z);
// path
- PathGenerator path(target);
+ /*PathGenerator path(target);
path.SetUseStraightPath(useStraightPath);
bool result = path.CalculatePath(x, y, z);
-
+
Movement::PointsArray const& pointPath = path.GetPath();
handler->PSendSysMessage("%s's path to %s:", target->GetName().c_str(), player->GetName().c_str());
handler->PSendSysMessage("Building: %s", useStraightPath ? "StraightPath" : "SmoothPath");
@@ -107,13 +237,64 @@ public:
handler->PSendSysMessage("StartPosition (%.3f, %.3f, %.3f)", start.x, start.y, start.z);
handler->PSendSysMessage("EndPosition (%.3f, %.3f, %.3f)", end.x, end.y, end.z);
handler->PSendSysMessage("ActualEndPosition (%.3f, %.3f, %.3f)", actualEnd.x, actualEnd.y, actualEnd.z);
+ */
+ float m_spos[3];
+ m_spos[0] = -y;
+ m_spos[1] = z;
+ m_spos[2] = -x;
+
+ //
+ float m_epos[3];
+ m_epos[0] = -target->GetPositionY();
+ m_epos[1] = target->GetPositionZ();
+ m_epos[2] = -target->GetPositionX();
+
+ //
+ dtQueryFilter m_filter;
+ m_filter.setIncludeFlags(3);
+ m_filter.setExcludeFlags(2);
+
+ //
+ float m_polyPickExt[3];
+ m_polyPickExt[0] = 2.5f;
+ m_polyPickExt[1] = 2.5f;
+ m_polyPickExt[2] = 2.5f;
+
+ //
+ dtPolyRef m_startRef;
+ dtPolyRef m_endRef;
+
+ const dtNavMesh* navMesh = MMAP::MMapFactory::CreateOrGetMMapManager()->GetNavMesh(player->GetMapId());
+ const dtNavMeshQuery* navMeshQuery = MMAP::MMapFactory::CreateOrGetMMapManager()->GetNavMeshQuery(player->GetMapId(), handler->GetSession()->GetPlayer()->GetInstanceId());
+
+ float nearestPt[3];
+
+ navMeshQuery->findNearestPoly(m_spos, m_polyPickExt, &m_filter, &m_startRef, nearestPt);
+ navMeshQuery->findNearestPoly(m_epos, m_polyPickExt, &m_filter, &m_endRef, nearestPt);
+
+ if ( !m_startRef || !m_endRef )
+ {
+ std::cerr << "Could not find any nearby poly's (" << m_startRef << "," << m_endRef << ")" << std::endl;
+ return 0;
+ }
+
+ int hops;
+ dtPolyRef* hopBuffer = new dtPolyRef[8192];
+ dtStatus status = navMeshQuery->findPath(m_startRef, m_endRef, m_spos, m_epos, &m_filter, hopBuffer, &hops, 8192);
+
+ int resultHopCount;
+ float* straightPath = new float[2048*3];
+ unsigned char* pathFlags = new unsigned char[2048];
+ dtPolyRef* pathRefs = new dtPolyRef[2048];
+
+ status = navMeshQuery->findStraightPath(m_spos, m_epos, hopBuffer, hops, straightPath, pathFlags, pathRefs, &resultHopCount, 2048);
+ FixPath(const_cast<dtNavMesh*>(navMesh), const_cast<dtNavMeshQuery*>(navMeshQuery), m_polyPickExt, m_filter, resultHopCount, straightPath);
+ for (uint32 i = 0; i < resultHopCount; ++i)
+ player->SummonCreature(VISUAL_WAYPOINT, -straightPath[i * 3 + 2], -straightPath[i * 3 + 0], straightPath[i * 3 + 1], 0, TEMPSUMMON_TIMED_DESPAWN, 9000);
if (!player->IsGameMaster())
handler->PSendSysMessage("Enable GM mode to see the path points.");
- for (uint32 i = 0; i < pointPath.size(); ++i)
- player->SummonCreature(VISUAL_WAYPOINT, pointPath[i].x, pointPath[i].y, pointPath[i].z, 0, TEMPSUMMON_TIMED_DESPAWN, 9000);
-
return true;
}
@@ -131,8 +312,8 @@ public:
handler->PSendSysMessage("gridloc [%i, %i]", gx, gy);
// calculate navmesh tile location
- dtNavMesh const* navmesh = MMAP::MMapFactory::createOrGetMMapManager()->GetNavMesh(handler->GetSession()->GetPlayer()->GetMapId());
- dtNavMeshQuery const* navmeshquery = MMAP::MMapFactory::createOrGetMMapManager()->GetNavMeshQuery(handler->GetSession()->GetPlayer()->GetMapId(), player->GetInstanceId());
+ dtNavMesh const* navmesh = MMAP::MMapFactory::CreateOrGetMMapManager()->GetNavMesh(handler->GetSession()->GetPlayer()->GetMapId());
+ dtNavMeshQuery const* navmeshquery = MMAP::MMapFactory::CreateOrGetMMapManager()->GetNavMeshQuery(handler->GetSession()->GetPlayer()->GetMapId(), player->GetInstanceId());
if (!navmesh || !navmeshquery)
{
handler->PSendSysMessage("NavMesh not loaded for current map.");
@@ -142,8 +323,8 @@ public:
float const* min = navmesh->getParams()->orig;
float x, y, z;
player->GetPosition(x, y, z);
- float location[VERTEX_SIZE] = {y, z, x};
- float extents[VERTEX_SIZE] = {3.0f, 5.0f, 3.0f};
+ float location[] = {y, z, x};
+ float extents[] = {3.0f, 5.0f, 3.0f};
int32 tilex = int32((y - min[0]) / SIZE_OF_GRIDS);
int32 tiley = int32((x - min[2]) / SIZE_OF_GRIDS);
@@ -152,14 +333,14 @@ public:
// navmesh poly -> navmesh tile location
dtQueryFilter filter = dtQueryFilter();
- dtPolyRef polyRef = INVALID_POLYREF;
+ dtPolyRef polyRef = 0;
if (dtStatusFailed(navmeshquery->findNearestPoly(location, extents, &filter, &polyRef, NULL)))
{
handler->PSendSysMessage("Dt [??,??] (invalid poly, probably no tile loaded)");
return true;
}
- if (polyRef == INVALID_POLYREF)
+ if (polyRef == 0)
handler->PSendSysMessage("Dt [??, ??] (invalid poly, probably no tile loaded)");
else
{
@@ -183,8 +364,8 @@ public:
static bool HandleMmapLoadedTilesCommand(ChatHandler* handler, char const* /*args*/)
{
uint32 mapid = handler->GetSession()->GetPlayer()->GetMapId();
- dtNavMesh const* navmesh = MMAP::MMapFactory::createOrGetMMapManager()->GetNavMesh(mapid);
- dtNavMeshQuery const* navmeshquery = MMAP::MMapFactory::createOrGetMMapManager()->GetNavMeshQuery(mapid, handler->GetSession()->GetPlayer()->GetInstanceId());
+ dtNavMesh const* navmesh = MMAP::MMapFactory::CreateOrGetMMapManager()->GetNavMesh(mapid);
+ dtNavMeshQuery const* navmeshquery = MMAP::MMapFactory::CreateOrGetMMapManager()->GetNavMeshQuery(mapid, handler->GetSession()->GetPlayer()->GetInstanceId());
if (!navmesh || !navmeshquery)
{
handler->PSendSysMessage("NavMesh not loaded for current map.");
@@ -211,8 +392,8 @@ public:
handler->PSendSysMessage("mmap stats:");
handler->PSendSysMessage(" global mmap pathfinding is %sabled", MMAP::MMapFactory::IsPathfindingEnabled(mapId) ? "en" : "dis");
- MMAP::MMapManager* manager = MMAP::MMapFactory::createOrGetMMapManager();
- handler->PSendSysMessage(" %u maps loaded with %u tiles overall", manager->getLoadedMapsCount(), manager->getLoadedTilesCount());
+ MMAP::MMapManager* manager = MMAP::MMapFactory::CreateOrGetMMapManager();
+ handler->PSendSysMessage(" %u maps loaded with %u tiles overall", manager->GetLoadedMapsCount(), manager->GetLoadedTilesCount());
dtNavMesh const* navmesh = manager->GetNavMesh(handler->GetSession()->GetPlayer()->GetMapId());
if (!navmesh)
diff --git a/src/server/scripts/Commands/cs_npc.cpp b/src/server/scripts/Commands/cs_npc.cpp
index 19693d86708..135606b947c 100644
--- a/src/server/scripts/Commands/cs_npc.cpp
+++ b/src/server/scripts/Commands/cs_npc.cpp
@@ -276,7 +276,11 @@ public:
uint32 db_guid = creature->GetDBTableGUIDLow();
- // To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells();
+ // To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells()
+ // current "creature" variable is deleted and created fresh new, otherwise old values might trigger asserts or cause undefined behavior
+ creature->CleanupsBeforeDelete();
+ delete creature;
+ creature = new Creature();
if (!creature->LoadCreatureFromDB(db_guid, map))
{
delete creature;
diff --git a/src/server/scripts/Commands/cs_quest.cpp b/src/server/scripts/Commands/cs_quest.cpp
index 83e65d2f01f..cdae7a88387 100644
--- a/src/server/scripts/Commands/cs_quest.cpp
+++ b/src/server/scripts/Commands/cs_quest.cpp
@@ -201,7 +201,7 @@ public:
}
}
- // All creature/GO slain/casted (not required, but otherwise it will display "Creature slain 0/10")
+ // All creature/GO slain/cast (not required, but otherwise it will display "Creature slain 0/10")
for (uint8 i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
{
int32 creature = quest->RequiredNpcOrGo[i];
diff --git a/src/server/scripts/EasternKingdoms/BaradinHold/boss_alizabal.cpp b/src/server/scripts/EasternKingdoms/BaradinHold/boss_alizabal.cpp
index 34fc09fe809..7a054d68da8 100644
--- a/src/server/scripts/EasternKingdoms/BaradinHold/boss_alizabal.cpp
+++ b/src/server/scripts/EasternKingdoms/BaradinHold/boss_alizabal.cpp
@@ -208,7 +208,7 @@ class boss_alizabal : public CreatureScript
{
DoCast(target, SPELL_SKEWER, true);
Talk(SAY_SKEWER);
- Talk(SAY_SKEWER_ANNOUNCE, target->GetGUID());
+ Talk(SAY_SKEWER_ANNOUNCE, target);
}
_skewer = true;
events.ScheduleEvent(EVENT_RANDOM_CAST, urand(7000, 10000));
diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/blackrock_depths.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/blackrock_depths.cpp
index ee8f22ca66c..e2a4359f6a8 100644
--- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/blackrock_depths.cpp
+++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/blackrock_depths.cpp
@@ -117,7 +117,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_grimstoneAI(creature);
+ return GetInstanceAI<npc_grimstoneAI>(creature);
}
struct npc_grimstoneAI : public npc_escortAI
@@ -207,12 +207,9 @@ public:
Event_Timer = 5000;
break;
case 5:
- if (instance)
- {
- instance->UpdateEncounterState(ENCOUNTER_CREDIT_KILL_CREATURE, NPC_GRIMSTONE, me);
- instance->SetData(TYPE_RING_OF_LAW, DONE);
- TC_LOG_DEBUG("scripts", "npc_grimstone: event reached end and set complete.");
- }
+ instance->UpdateEncounterState(ENCOUNTER_CREDIT_KILL_CREATURE, NPC_GRIMSTONE, me);
+ instance->SetData(TYPE_RING_OF_LAW, DONE);
+ TC_LOG_DEBUG("scripts", "npc_grimstone: event reached end and set complete.");
break;
}
}
@@ -224,9 +221,6 @@ public:
void UpdateAI(uint32 diff) OVERRIDE
{
- if (!instance)
- return;
-
if (MobDeath_Timer)
{
if (MobDeath_Timer <= diff)
@@ -1237,7 +1231,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_rocknotAI(creature);
+ return GetInstanceAI<npc_rocknotAI>(creature);
}
struct npc_rocknotAI : public npc_escortAI
@@ -1269,9 +1263,6 @@ public:
void WaypointReached(uint32 waypointId) OVERRIDE
{
- if (!instance)
- return;
-
switch (waypointId)
{
case 1:
@@ -1295,9 +1286,6 @@ public:
void UpdateAI(uint32 diff) OVERRIDE
{
- if (!instance)
- return;
-
if (BreakKeg_Timer)
{
if (BreakKeg_Timer <= diff)
diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_emperor_dagran_thaurissan.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_emperor_dagran_thaurissan.cpp
index 25f93a2b6b7..ecdfafea641 100644
--- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_emperor_dagran_thaurissan.cpp
+++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_emperor_dagran_thaurissan.cpp
@@ -39,7 +39,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_draganthaurissanAI(creature);
+ return GetInstanceAI<boss_draganthaurissanAI>(creature);
}
struct boss_draganthaurissanAI : public ScriptedAI
@@ -92,7 +92,7 @@ public:
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
DoCast(target, SPELL_HANDOFTHAURISSAN);
- //3 Hands of Thaurissan will be casted
+ //3 Hands of Thaurissan will be cast
//if (Counter < 3)
//{
// HandOfThaurissan_Timer = 1000;
diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_tomb_of_seven.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_tomb_of_seven.cpp
index 55e6862bda7..2353f8bc4d6 100644
--- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_tomb_of_seven.cpp
+++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_tomb_of_seven.cpp
@@ -140,7 +140,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_doomrelAI(creature);
+ return GetInstanceAI<boss_doomrelAI>(creature);
}
struct boss_doomrelAI : public ScriptedAI
@@ -170,13 +170,10 @@ public:
// was set before event start, so set again
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC);
- if (instance)
- {
- if (instance->GetData(DATA_GHOSTKILL) >= 7)
- me->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE);
- else
- me->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
- }
+ if (instance->GetData(DATA_GHOSTKILL) >= 7)
+ me->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE);
+ else
+ me->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
}
void EnterCombat(Unit* /*who*/) OVERRIDE
@@ -192,14 +189,12 @@ public:
if (me->IsAlive())
me->GetMotionMaster()->MoveTargetedHome();
me->SetLootRecipient(NULL);
- if (instance)
- instance->SetData64(DATA_EVENSTARTER, 0);
+ instance->SetData64(DATA_EVENSTARTER, 0);
}
void JustDied(Unit* /*killer*/) OVERRIDE
{
- if (instance)
- instance->SetData(DATA_GHOSTKILL, 1);
+ instance->SetData(DATA_GHOSTKILL, 1);
}
void UpdateAI(uint32 diff) OVERRIDE
diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/boss_gyth.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/boss_gyth.cpp
index dbc3056b1ff..b2d496501ff 100644
--- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/boss_gyth.cpp
+++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/boss_gyth.cpp
@@ -162,7 +162,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_gythAI(creature);
+ return GetInstanceAI<boss_gythAI>(creature);
}
};
diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/boss_lord_valthalak.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/boss_lord_valthalak.cpp
index 26540eb38a6..11f421ac19e 100644
--- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/boss_lord_valthalak.cpp
+++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/boss_lord_valthalak.cpp
@@ -64,8 +64,7 @@ public:
void JustDied(Unit* /*killer*/) OVERRIDE
{
- if (instance)
- instance->SetData(DATA_LORD_VALTHALAK, DONE);
+ instance->SetData(DATA_LORD_VALTHALAK, DONE);
}
void UpdateAI(uint32 diff) OVERRIDE
@@ -128,7 +127,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_lord_valthalakAI(creature);
+ return GetInstanceAI<boss_lord_valthalakAI>(creature);
}
};
diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/boss_pyroguard_emberseer.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/boss_pyroguard_emberseer.cpp
index 1c40385c0fd..65cddb55b8c 100644
--- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/boss_pyroguard_emberseer.cpp
+++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/boss_pyroguard_emberseer.cpp
@@ -79,23 +79,20 @@ public:
void Reset() OVERRIDE
{
- if (instance)
- {
- me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_NOT_SELECTABLE);
- events.Reset();
- // Apply auras on spawn and reset
- // DoCast(me, SPELL_FIRE_SHIELD_TRIGGER); // Need to find this in old DBC if possible
- me->RemoveAura(SPELL_EMBERSEER_FULL_STRENGTH);
- me->RemoveAura(SPELL_EMBERSEER_GROWING);
- me->RemoveAura(SPELL_EMBERSEER_GROWING_TRIGGER);
- events.ScheduleEvent(EVENT_RESPAWN, 5000);
- // Hack for missing trigger spell
- events.ScheduleEvent(EVENT_FIRE_SHIELD, 3000);
-
- // Open doors on reset
- if (instance->GetBossState(DATA_PYROGAURD_EMBERSEER) == IN_PROGRESS)
- OpenDoors(false); // Opens 2 entrance doors
- }
+ me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_NOT_SELECTABLE);
+ events.Reset();
+ // Apply auras on spawn and reset
+ // DoCast(me, SPELL_FIRE_SHIELD_TRIGGER); // Need to find this in old DBC if possible
+ me->RemoveAura(SPELL_EMBERSEER_FULL_STRENGTH);
+ me->RemoveAura(SPELL_EMBERSEER_GROWING);
+ me->RemoveAura(SPELL_EMBERSEER_GROWING_TRIGGER);
+ events.ScheduleEvent(EVENT_RESPAWN, 5000);
+ // Hack for missing trigger spell
+ events.ScheduleEvent(EVENT_FIRE_SHIELD, 3000);
+
+ // Open doors on reset
+ if (instance->GetBossState(DATA_PYROGAURD_EMBERSEER) == IN_PROGRESS)
+ OpenDoors(false); // Opens 2 entrance doors
}
void SetData(uint32 /*type*/, uint32 data) OVERRIDE
@@ -132,15 +129,12 @@ public:
void JustDied(Unit* /*killer*/) OVERRIDE
{
- if (instance)
- {
- // Activate all the runes
- UpdateRunes(GO_STATE_READY);
- // Opens all 3 doors
- OpenDoors(true);
- // Complete encounter
- instance->SetBossState(DATA_PYROGAURD_EMBERSEER, DONE);
- }
+ // Activate all the runes
+ UpdateRunes(GO_STATE_READY);
+ // Opens all 3 doors
+ OpenDoors(true);
+ // Complete encounter
+ instance->SetBossState(DATA_PYROGAURD_EMBERSEER, DONE);
}
void SpellHit(Unit* /*caster*/, SpellInfo const* spell) OVERRIDE
@@ -185,24 +179,21 @@ public:
void UpdateRunes(GOState state)
{
- if (instance)
- {
- // update all runes
- if (GameObject* rune1 = me->GetMap()->GetGameObject(instance->GetData64(GO_EMBERSEER_RUNE_1)))
- rune1->SetGoState(state);
- if (GameObject* rune2 = me->GetMap()->GetGameObject(instance->GetData64(GO_EMBERSEER_RUNE_2)))
- rune2->SetGoState(state);
- if (GameObject* rune3 = me->GetMap()->GetGameObject(instance->GetData64(GO_EMBERSEER_RUNE_3)))
- rune3->SetGoState(state);
- if (GameObject* rune4 = me->GetMap()->GetGameObject(instance->GetData64(GO_EMBERSEER_RUNE_4)))
- rune4->SetGoState(state);
- if (GameObject* rune5 = me->GetMap()->GetGameObject(instance->GetData64(GO_EMBERSEER_RUNE_5)))
- rune5->SetGoState(state);
- if (GameObject* rune6 = me->GetMap()->GetGameObject(instance->GetData64(GO_EMBERSEER_RUNE_6)))
- rune6->SetGoState(state);
- if (GameObject* rune7 = me->GetMap()->GetGameObject(instance->GetData64(GO_EMBERSEER_RUNE_7)))
- rune7->SetGoState(state);
- }
+ // update all runes
+ if (GameObject* rune1 = me->GetMap()->GetGameObject(instance->GetData64(GO_EMBERSEER_RUNE_1)))
+ rune1->SetGoState(state);
+ if (GameObject* rune2 = me->GetMap()->GetGameObject(instance->GetData64(GO_EMBERSEER_RUNE_2)))
+ rune2->SetGoState(state);
+ if (GameObject* rune3 = me->GetMap()->GetGameObject(instance->GetData64(GO_EMBERSEER_RUNE_3)))
+ rune3->SetGoState(state);
+ if (GameObject* rune4 = me->GetMap()->GetGameObject(instance->GetData64(GO_EMBERSEER_RUNE_4)))
+ rune4->SetGoState(state);
+ if (GameObject* rune5 = me->GetMap()->GetGameObject(instance->GetData64(GO_EMBERSEER_RUNE_5)))
+ rune5->SetGoState(state);
+ if (GameObject* rune6 = me->GetMap()->GetGameObject(instance->GetData64(GO_EMBERSEER_RUNE_6)))
+ rune6->SetGoState(state);
+ if (GameObject* rune7 = me->GetMap()->GetGameObject(instance->GetData64(GO_EMBERSEER_RUNE_7)))
+ rune7->SetGoState(state);
}
void UpdateAI(uint32 diff) OVERRIDE
@@ -316,7 +307,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_pyroguard_emberseerAI(creature);
+ return GetInstanceAI<boss_pyroguard_emberseerAI>(creature);
}
};
diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/boss_rend_blackhand.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/boss_rend_blackhand.cpp
index ff839e3cacb..efe53d0825a 100644
--- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/boss_rend_blackhand.cpp
+++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/boss_rend_blackhand.cpp
@@ -438,7 +438,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_rend_blackhandAI(creature);
+ return GetInstanceAI<boss_rend_blackhandAI>(creature);
}
};
diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/boss_warmaster_voone.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/boss_warmaster_voone.cpp
index ccd74b204ce..5849ab1442c 100644
--- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/boss_warmaster_voone.cpp
+++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/boss_warmaster_voone.cpp
@@ -23,11 +23,11 @@
enum Spells
{
SPELL_SNAPKICK = 15618,
- SPELL_CLEAVE = 15579,
+ SPELL_CLEAVE = 15284,
SPELL_UPPERCUT = 10966,
SPELL_MORTALSTRIKE = 16856,
SPELL_PUMMEL = 15615,
- SPELL_THROWAXE = 16075,
+ SPELL_THROWAXE = 16075
};
enum Events
@@ -37,7 +37,7 @@ enum Events
EVENT_UPPERCUT = 3,
EVENT_MORTAL_STRIKE = 4,
EVENT_PUMMEL = 5,
- EVENT_THROW_AXE = 6,
+ EVENT_THROW_AXE = 6
};
class boss_warmaster_voone : public CreatureScript
@@ -45,11 +45,6 @@ class boss_warmaster_voone : public CreatureScript
public:
boss_warmaster_voone() : CreatureScript("boss_warmaster_voone") { }
- CreatureAI* GetAI(Creature* creature) const OVERRIDE
- {
- return new boss_warmastervooneAI(creature);
- }
-
struct boss_warmastervooneAI : public BossAI
{
boss_warmastervooneAI(Creature* creature) : BossAI(creature, DATA_WARMASTER_VOONE) { }
@@ -119,6 +114,10 @@ public:
}
};
+ CreatureAI* GetAI(Creature* creature) const OVERRIDE
+ {
+ return new boss_warmastervooneAI(creature);
+ }
};
void AddSC_boss_warmastervoone()
diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_broodlord_lashlayer.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_broodlord_lashlayer.cpp
index c9dc3d8f134..77afea4b656 100644
--- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_broodlord_lashlayer.cpp
+++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_broodlord_lashlayer.cpp
@@ -116,7 +116,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_broodlordAI(creature);
+ return GetInstanceAI<boss_broodlordAI>(creature);
}
};
diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_chromaggus.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_chromaggus.cpp
index 05effabe557..9878720b1dd 100644
--- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_chromaggus.cpp
+++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_chromaggus.cpp
@@ -282,7 +282,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_chromaggusAI(creature);
+ return GetInstanceAI<boss_chromaggusAI>(creature);
}
};
diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_ebonroc.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_ebonroc.cpp
index 0d79f3faeee..222bd6f80ea 100644
--- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_ebonroc.cpp
+++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_ebonroc.cpp
@@ -92,7 +92,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_ebonrocAI(creature);
+ return GetInstanceAI<boss_ebonrocAI>(creature);
}
};
diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_firemaw.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_firemaw.cpp
index 369e4e02f5a..983fe60a2d0 100644
--- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_firemaw.cpp
+++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_firemaw.cpp
@@ -94,7 +94,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_firemawAI(creature);
+ return GetInstanceAI<boss_firemawAI>(creature);
}
};
diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_flamegor.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_flamegor.cpp
index 060bfeb60b3..63b43d81ae4 100644
--- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_flamegor.cpp
+++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_flamegor.cpp
@@ -100,7 +100,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_flamegorAI(creature);
+ return GetInstanceAI<boss_flamegorAI>(creature);
}
};
diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_nefarian.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_nefarian.cpp
index 9d34cb680e1..7c368fae96a 100644
--- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_nefarian.cpp
+++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_nefarian.cpp
@@ -170,11 +170,12 @@ public:
void Reset() OVERRIDE
{
+ SpawnedAdds = 0;
+
if (me->GetMapId() == 469)
{
if (!me->FindNearestCreature(NPC_NEFARIAN, 1000.0f, true))
_Reset();
- SpawnedAdds = 0;
me->SetVisible(true);
me->SetPhaseMask(1, true);
@@ -376,7 +377,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_victor_nefariusAI(creature);
+ return GetInstanceAI<boss_victor_nefariusAI>(creature);
}
};
@@ -443,8 +444,7 @@ public:
{
if (canDespawn && DespawnTimer <= diff)
{
- if (instance)
- instance->SetBossState(BOSS_NEFARIAN, FAIL);
+ instance->SetBossState(BOSS_NEFARIAN, FAIL);
std::list<Creature*> constructList;
me->GetCreatureListWithEntryInGrid(constructList, NPC_BONE_CONSTRUCT, 500.0f);
@@ -572,7 +572,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_nefarianAI(creature);
+ return GetInstanceAI<boss_nefarianAI>(creature);
}
};
diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_razorgore.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_razorgore.cpp
index caf2719eff9..6b24cd0b74b 100644
--- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_razorgore.cpp
+++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_razorgore.cpp
@@ -75,8 +75,7 @@ public:
_Reset();
secondPhase = false;
- if (instance)
- instance->SetData(DATA_EGG_EVENT, NOT_STARTED);
+ instance->SetData(DATA_EGG_EVENT, NOT_STARTED);
}
void JustDied(Unit* /*killer*/) OVERRIDE
@@ -84,8 +83,7 @@ public:
_JustDied();
Talk(SAY_DEATH);
- if (instance)
- instance->SetData(DATA_EGG_EVENT, NOT_STARTED);
+ instance->SetData(DATA_EGG_EVENT, NOT_STARTED);
}
void DoChangePhase()
@@ -156,7 +154,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_razorgoreAI(creature);
+ return GetInstanceAI<boss_razorgoreAI>(creature);
}
};
diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_golemagg.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_golemagg.cpp
index 0fdb88923b3..bc94f1b0267 100644
--- a/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_golemagg.cpp
+++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_golemagg.cpp
@@ -179,7 +179,7 @@ class npc_core_rager : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_core_ragerAI(creature);
+ return GetInstanceAI<npc_core_ragerAI>(creature);
}
};
diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_majordomo_executus.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_majordomo_executus.cpp
index 1001516d42e..19b4bea8858 100644
--- a/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_majordomo_executus.cpp
+++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_majordomo_executus.cpp
@@ -161,8 +161,7 @@ class boss_majordomo : public CreatureScript
me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
break;
case EVENT_OUTRO_2:
- if (instance)
- instance->instance->SummonCreature(NPC_RAGNAROS, RagnarosSummonPos);
+ instance->instance->SummonCreature(NPC_RAGNAROS, RagnarosSummonPos);
break;
case EVENT_OUTRO_3:
Talk(SAY_ARRIVAL2_MAJ);
@@ -207,7 +206,7 @@ class boss_majordomo : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_majordomoAI(creature);
+ return GetInstanceAI<boss_majordomoAI>(creature);
}
};
diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_ragnaros.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_ragnaros.cpp
index d03f756f366..364d171ed35 100644
--- a/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_ragnaros.cpp
+++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_ragnaros.cpp
@@ -147,9 +147,8 @@ class boss_ragnaros : public CreatureScript
break;
case EVENT_INTRO_4:
Talk(SAY_ARRIVAL5_RAG);
- if (instance)
- if (Creature* executus = Unit::GetCreature(*me, instance->GetData64(BOSS_MAJORDOMO_EXECUTUS)))
- me->Kill(executus);
+ if (Creature* executus = Unit::GetCreature(*me, instance->GetData64(BOSS_MAJORDOMO_EXECUTUS)))
+ me->Kill(executus);
break;
case EVENT_INTRO_5:
me->SetReactState(REACT_AGGRESSIVE);
@@ -163,29 +162,26 @@ class boss_ragnaros : public CreatureScript
}
else
{
- if (instance)
+ if (_isBanished && ((_emergeTimer <= diff) || (instance->GetData(DATA_RAGNAROS_ADDS)) > 8))
{
- if (_isBanished && ((_emergeTimer <= diff) || (instance->GetData(DATA_RAGNAROS_ADDS)) > 8))
- {
- //Become unbanished again
- me->SetReactState(REACT_AGGRESSIVE);
- me->setFaction(14);
- 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;
- }
+ //Become unbanished again
+ me->SetReactState(REACT_AGGRESSIVE);
+ me->setFaction(14);
+ 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
@@ -306,7 +302,7 @@ class boss_ragnaros : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_ragnarosAI(creature);
+ return GetInstanceAI<boss_ragnarosAI>(creature);
}
};
@@ -324,8 +320,7 @@ class npc_son_of_flame : public CreatureScript
void JustDied(Unit* /*killer*/) OVERRIDE
{
- if (instance)
- instance->SetData(DATA_RAGNAROS_ADDS, 1);
+ instance->SetData(DATA_RAGNAROS_ADDS, 1);
}
void UpdateAI(uint32 /*diff*/) OVERRIDE
@@ -342,7 +337,7 @@ class npc_son_of_flame : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_son_of_flameAI(creature);
+ return GetInstanceAI<npc_son_of_flameAI>(creature);
}
};
diff --git a/src/server/scripts/EasternKingdoms/Deadmines/boss_mr_smite.cpp b/src/server/scripts/EasternKingdoms/Deadmines/boss_mr_smite.cpp
index 8a7836b310e..57879c812e9 100644
--- a/src/server/scripts/EasternKingdoms/Deadmines/boss_mr_smite.cpp
+++ b/src/server/scripts/EasternKingdoms/Deadmines/boss_mr_smite.cpp
@@ -45,7 +45,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_mr_smiteAI(creature);
+ return GetInstanceAI<boss_mr_smiteAI>(creature);
}
struct boss_mr_smiteAI : public ScriptedAI
@@ -127,12 +127,11 @@ public:
++uiHealth;
DoCastAOE(SPELL_SMITE_STOMP, false);
SetCombatMovement(false);
- if (instance)
- if (GameObject* go = GameObject::GetGameObject(*me, instance->GetData64(DATA_SMITE_CHEST)))
- {
- me->GetMotionMaster()->Clear();
- me->GetMotionMaster()->MovePoint(1, go->GetPositionX() - 3.0f, go->GetPositionY(), go->GetPositionZ());
- }
+ if (GameObject* go = GameObject::GetGameObject(*me, instance->GetData64(DATA_SMITE_CHEST)))
+ {
+ me->GetMotionMaster()->Clear();
+ me->GetMotionMaster()->MovePoint(1, go->GetPositionX() - 3.0f, go->GetPositionY(), go->GetPositionZ());
+ }
}
if (uiPhase)
diff --git a/src/server/scripts/EasternKingdoms/Gnomeregan/gnomeregan.cpp b/src/server/scripts/EasternKingdoms/Gnomeregan/gnomeregan.cpp
index 46683442a60..325e39e638c 100644
--- a/src/server/scripts/EasternKingdoms/Gnomeregan/gnomeregan.cpp
+++ b/src/server/scripts/EasternKingdoms/Gnomeregan/gnomeregan.cpp
@@ -90,7 +90,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_blastmaster_emi_shortfuseAI(creature);
+ return GetInstanceAI<npc_blastmaster_emi_shortfuseAI>(creature);
}
bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action) OVERRIDE
@@ -186,20 +186,15 @@ public:
if (bBool)
{
- if (instance)
- if (GameObject* go = GameObject::GetGameObject(*me, instance->GetData64(DATA_GO_CAVE_IN_RIGHT)))
- instance->HandleGameObject(0, false, go);
+ if (GameObject* go = GameObject::GetGameObject(*me, instance->GetData64(DATA_GO_CAVE_IN_RIGHT)))
+ instance->HandleGameObject(0, false, go);
}else
- if (instance)
- if (GameObject* go = GameObject::GetGameObject(*me, instance->GetData64(DATA_GO_CAVE_IN_LEFT)))
- instance->HandleGameObject(0, false, go);
+ if (GameObject* go = GameObject::GetGameObject(*me, instance->GetData64(DATA_GO_CAVE_IN_LEFT)))
+ instance->HandleGameObject(0, false, go);
}
void SetInFace(bool bBool)
{
- if (!instance)
- return;
-
if (bBool)
{
if (GameObject* go = GameObject::GetGameObject(*me, instance->GetData64(DATA_GO_CAVE_IN_RIGHT)))
@@ -211,9 +206,6 @@ public:
void RestoreAll()
{
- if (!instance)
- return;
-
if (GameObject* go = GameObject::GetGameObject(*me, instance->GetData64(DATA_GO_CAVE_IN_RIGHT)))
instance->HandleGameObject(0, false, go);
@@ -318,9 +310,6 @@ public:
NextStep(2000, true);
break;
case 2:
- if (!instance)
- return;
-
switch (uiValue)
{
case 1:
@@ -441,9 +430,8 @@ public:
SetInFace(true);
Talk(SAY_BLASTMASTER_5);
Summon(1);
- if (instance)
- if (GameObject* go = GameObject::GetGameObject(*me, instance->GetData64(DATA_GO_CAVE_IN_RIGHT)))
- instance->HandleGameObject(0, true, go);
+ if (GameObject* go = GameObject::GetGameObject(*me, instance->GetData64(DATA_GO_CAVE_IN_RIGHT)))
+ instance->HandleGameObject(0, true, go);
NextStep(3000, true);
break;
case 7:
@@ -488,9 +476,8 @@ public:
case 16:
Talk(SAY_BLASTMASTER_14);
SetInFace(false);
- if (instance)
- if (GameObject* go = GameObject::GetGameObject(*me, instance->GetData64(DATA_GO_CAVE_IN_LEFT)))
- instance->HandleGameObject(0, true, go);
+ if (GameObject* go = GameObject::GetGameObject(*me, instance->GetData64(DATA_GO_CAVE_IN_LEFT)))
+ instance->HandleGameObject(0, true, go);
NextStep(2000, true);
break;
case 17:
diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_midnight.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_midnight.cpp
index 30416aca1b5..129a9af823c 100644
--- a/src/server/scripts/EasternKingdoms/Karazhan/boss_midnight.cpp
+++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_midnight.cpp
@@ -82,6 +82,7 @@ public:
void Reset() OVERRIDE
{
ResetTimer = 0;
+ Midnight = 0;
}
void EnterEvadeMode() OVERRIDE
diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp
index fc37c42be85..06e5745c87e 100644
--- a/src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp
+++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp
@@ -98,7 +98,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_moroesAI(creature);
+ return GetInstanceAI<boss_moroesAI>(creature);
}
struct boss_moroesAI : public ScriptedAI
@@ -138,14 +138,12 @@ public:
if (me->IsAlive())
SpawnAdds();
- if (instance)
- instance->SetData(TYPE_MOROES, NOT_STARTED);
+ instance->SetData(TYPE_MOROES, NOT_STARTED);
}
void StartEvent()
{
- if (instance)
- instance->SetData(TYPE_MOROES, IN_PROGRESS);
+ instance->SetData(TYPE_MOROES, IN_PROGRESS);
DoZoneInCombat();
}
@@ -168,14 +166,12 @@ public:
{
Talk(SAY_DEATH);
- if (instance)
- instance->SetData(TYPE_MOROES, DONE);
+ instance->SetData(TYPE_MOROES, DONE);
DeSpawnAdds();
//remove aura from spell Garrote when Moroes dies
- if (instance)
- instance->DoRemoveAurasDueToSpellOnPlayers(SPELL_GARROTE);
+ instance->DoRemoveAurasDueToSpellOnPlayers(SPELL_GARROTE);
}
void SpawnAdds()
@@ -349,15 +345,11 @@ struct boss_moroes_guestAI : public ScriptedAI
void Reset() OVERRIDE
{
- if (instance)
- instance->SetData(TYPE_MOROES, NOT_STARTED);
+ instance->SetData(TYPE_MOROES, NOT_STARTED);
}
void AcquireGUID()
{
- if (!instance)
- return;
-
if (Creature* Moroes = Unit::GetCreature(*me, instance->GetData64(DATA_MOROES)))
for (uint8 i = 0; i < 4; ++i)
if (uint64 GUID = CAST_AI(boss_moroes::boss_moroesAI, Moroes->AI())->AddGUID[i])
@@ -393,7 +385,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_baroness_dorothea_millstipeAI(creature);
+ return GetInstanceAI<boss_baroness_dorothea_millstipeAI>(creature);
}
struct boss_baroness_dorothea_millstipeAI : public boss_moroes_guestAI
@@ -456,7 +448,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_baron_rafe_dreugerAI(creature);
+ return GetInstanceAI<boss_baron_rafe_dreugerAI>(creature);
}
struct boss_baron_rafe_dreugerAI : public boss_moroes_guestAI
@@ -513,7 +505,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_lady_catriona_von_indiAI(creature);
+ return GetInstanceAI<boss_lady_catriona_von_indiAI>(creature);
}
struct boss_lady_catriona_von_indiAI : public boss_moroes_guestAI
@@ -583,7 +575,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_lady_keira_berrybuckAI(creature);
+ return GetInstanceAI<boss_lady_keira_berrybuckAI>(creature);
}
struct boss_lady_keira_berrybuckAI : public boss_moroes_guestAI
@@ -657,7 +649,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_lord_robin_darisAI(creature);
+ return GetInstanceAI<boss_lord_robin_darisAI>(creature);
}
struct boss_lord_robin_darisAI : public boss_moroes_guestAI
@@ -713,7 +705,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_lord_crispin_ferenceAI(creature);
+ return GetInstanceAI<boss_lord_crispin_ferenceAI>(creature);
}
struct boss_lord_crispin_ferenceAI : public boss_moroes_guestAI
diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_netherspite.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_netherspite.cpp
index f80ff5b6028..52bec6dbf27 100644
--- a/src/server/scripts/EasternKingdoms/Karazhan/boss_netherspite.cpp
+++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_netherspite.cpp
@@ -71,7 +71,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_netherspiteAI(creature);
+ return GetInstanceAI<boss_netherspiteAI>(creature);
}
struct boss_netherspiteAI : public ScriptedAI
@@ -172,7 +172,7 @@ public:
for (int j=0; j<3; ++j) // j = color
if (Creature* portal = Unit::GetCreature(*me, PortalGUID[j]))
{
- // the one who's been casted upon before
+ // the one who's been cast upon before
Unit* current = Unit::GetUnit(*portal, BeamTarget[j]);
// temporary store for the best suitable beam reciever
Unit* target = me;
@@ -308,7 +308,7 @@ public:
if (PhaseTimer <= diff)
{
- if (!me->IsNonMeleeSpellCasted(false))
+ if (!me->IsNonMeleeSpellCast(false))
{
SwitchToBanishPhase();
return;
@@ -327,7 +327,7 @@ public:
if (PhaseTimer <= diff)
{
- if (!me->IsNonMeleeSpellCasted(false))
+ if (!me->IsNonMeleeSpellCast(false))
{
SwitchToPortalPhase();
return;
diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_nightbane.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_nightbane.cpp
index 984ef902f05..b4cfd339909 100644
--- a/src/server/scripts/EasternKingdoms/Karazhan/boss_nightbane.cpp
+++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_nightbane.cpp
@@ -71,7 +71,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_nightbaneAI(creature);
+ return GetInstanceAI<boss_nightbaneAI>(creature);
}
struct boss_nightbaneAI : public ScriptedAI
@@ -131,13 +131,10 @@ public:
me->SetWalk(false);
me->setActive(true);
- if (instance)
- {
- if (instance->GetData(TYPE_NIGHTBANE) == DONE || instance->GetData(TYPE_NIGHTBANE) == IN_PROGRESS)
- me->DisappearAndDie();
- else
- instance->SetData(TYPE_NIGHTBANE, NOT_STARTED);
- }
+ if (instance->GetData(TYPE_NIGHTBANE) == DONE || instance->GetData(TYPE_NIGHTBANE) == IN_PROGRESS)
+ me->DisappearAndDie();
+ else
+ instance->SetData(TYPE_NIGHTBANE, NOT_STARTED);
HandleTerraceDoors(true);
@@ -153,17 +150,13 @@ public:
void HandleTerraceDoors(bool open)
{
- if (instance)
- {
- instance->HandleGameObject(instance->GetData64(DATA_MASTERS_TERRACE_DOOR_1), open);
- instance->HandleGameObject(instance->GetData64(DATA_MASTERS_TERRACE_DOOR_2), open);
- }
+ instance->HandleGameObject(instance->GetData64(DATA_MASTERS_TERRACE_DOOR_1), open);
+ instance->HandleGameObject(instance->GetData64(DATA_MASTERS_TERRACE_DOOR_2), open);
}
void EnterCombat(Unit* /*who*/) OVERRIDE
{
- if (instance)
- instance->SetData(TYPE_NIGHTBANE, IN_PROGRESS);
+ instance->SetData(TYPE_NIGHTBANE, IN_PROGRESS);
HandleTerraceDoors(false);
Talk(YELL_AGGRO);
@@ -177,8 +170,7 @@ public:
void JustDied(Unit* /*killer*/) OVERRIDE
{
- if (instance)
- instance->SetData(TYPE_NIGHTBANE, DONE);
+ instance->SetData(TYPE_NIGHTBANE, DONE);
HandleTerraceDoors(true);
}
diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp
index 7c6cdd4cb3e..6ceceb5ab6c 100644
--- a/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp
+++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp
@@ -179,7 +179,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_malchezaarAI(creature);
+ return GetInstanceAI<boss_malchezaarAI>(creature);
}
struct boss_malchezaarAI : public ScriptedAI
@@ -239,8 +239,7 @@ public:
SunderArmorTimer = urand(5000, 10000);
phase = 1;
- if (instance)
- instance->HandleGameObject(instance->GetData64(DATA_GO_NETHER_DOOR), true);
+ instance->HandleGameObject(instance->GetData64(DATA_GO_NETHER_DOOR), true);
}
void KilledUnit(Unit* /*victim*/) OVERRIDE
@@ -260,16 +259,14 @@ public:
for (uint8 i = 0; i < TOTAL_INFERNAL_POINTS; ++i)
positions.push_back(&InfernalPoints[i]);
- if (instance)
- instance->HandleGameObject(instance->GetData64(DATA_GO_NETHER_DOOR), true);
+ instance->HandleGameObject(instance->GetData64(DATA_GO_NETHER_DOOR), true);
}
void EnterCombat(Unit* /*who*/) OVERRIDE
{
Talk(SAY_AGGRO);
- if (instance)
- instance->HandleGameObject(instance->GetData64(DATA_GO_NETHER_DOOR), false); // Open the door leading further in
+ instance->HandleGameObject(instance->GetData64(DATA_GO_NETHER_DOOR), false); // Open the door leading further in
}
void InfernalCleanup()
@@ -569,7 +566,7 @@ public:
void DoMeleeAttacksIfReady()
{
- if (me->IsWithinMeleeRange(me->GetVictim()) && !me->IsNonMeleeSpellCasted(false))
+ if (me->IsWithinMeleeRange(me->GetVictim()) && !me->IsNonMeleeSpellCast(false))
{
//Check for base attack
if (me->isAttackReady() && me->GetVictim())
diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_shade_of_aran.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_shade_of_aran.cpp
index 2d3fabb810b..3d7ee24a64f 100644
--- a/src/server/scripts/EasternKingdoms/Karazhan/boss_shade_of_aran.cpp
+++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_shade_of_aran.cpp
@@ -86,7 +86,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_aranAI(creature);
+ return GetInstanceAI<boss_aranAI>(creature);
}
struct boss_aranAI : public ScriptedAI
@@ -147,12 +147,9 @@ public:
Drinking = false;
DrinkInturrupted = false;
- if (instance)
- {
- // Not in progress
- instance->SetData(TYPE_ARAN, NOT_STARTED);
- instance->HandleGameObject(instance->GetData64(DATA_GO_LIBRARY_DOOR), true);
- }
+ // Not in progress
+ instance->SetData(TYPE_ARAN, NOT_STARTED);
+ instance->HandleGameObject(instance->GetData64(DATA_GO_LIBRARY_DOOR), true);
}
void KilledUnit(Unit* /*victim*/) OVERRIDE
@@ -164,22 +161,16 @@ public:
{
Talk(SAY_DEATH);
- if (instance)
- {
- instance->SetData(TYPE_ARAN, DONE);
- instance->HandleGameObject(instance->GetData64(DATA_GO_LIBRARY_DOOR), true);
- }
+ instance->SetData(TYPE_ARAN, DONE);
+ instance->HandleGameObject(instance->GetData64(DATA_GO_LIBRARY_DOOR), true);
}
void EnterCombat(Unit* /*who*/) OVERRIDE
{
Talk(SAY_AGGRO);
- if (instance)
- {
- instance->SetData(TYPE_ARAN, IN_PROGRESS);
- instance->HandleGameObject(instance->GetData64(DATA_GO_LIBRARY_DOOR), false);
- }
+ instance->SetData(TYPE_ARAN, IN_PROGRESS);
+ instance->HandleGameObject(instance->GetData64(DATA_GO_LIBRARY_DOOR), false);
}
void FlameWreathEffect()
@@ -226,11 +217,8 @@ public:
{
if (CloseDoorTimer <= diff)
{
- if (instance)
- {
- instance->HandleGameObject(instance->GetData64(DATA_GO_LIBRARY_DOOR), false);
- CloseDoorTimer = 0;
- }
+ instance->HandleGameObject(instance->GetData64(DATA_GO_LIBRARY_DOOR), false);
+ CloseDoorTimer = 0;
} else CloseDoorTimer -= diff;
}
@@ -305,7 +293,7 @@ public:
//Normal casts
if (NormalCastTimer <= diff)
{
- if (!me->IsNonMeleeSpellCasted(false))
+ if (!me->IsNonMeleeSpellCast(false))
{
Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true);
if (!target)
@@ -486,10 +474,10 @@ public:
void SpellHit(Unit* /*pAttacker*/, const SpellInfo* Spell) OVERRIDE
{
- //We only care about interrupt effects and only if they are durring a spell currently being casted
+ //We only care about interrupt effects and only if they are durring a spell currently being cast
if ((Spell->Effects[0].Effect != SPELL_EFFECT_INTERRUPT_CAST &&
Spell->Effects[1].Effect != SPELL_EFFECT_INTERRUPT_CAST &&
- Spell->Effects[2].Effect != SPELL_EFFECT_INTERRUPT_CAST) || !me->IsNonMeleeSpellCasted(false))
+ Spell->Effects[2].Effect != SPELL_EFFECT_INTERRUPT_CAST) || !me->IsNonMeleeSpellCast(false))
return;
//Interrupt effect
diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_terestian_illhoof.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_terestian_illhoof.cpp
index 6355fe33724..c20d424cb9c 100644
--- a/src/server/scripts/EasternKingdoms/Karazhan/boss_terestian_illhoof.cpp
+++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_terestian_illhoof.cpp
@@ -71,7 +71,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_kilrekAI(creature);
+ return GetInstanceAI<npc_kilrekAI>(creature);
}
struct npc_kilrekAI : public ScriptedAI
@@ -95,25 +95,17 @@ public:
void EnterCombat(Unit* /*who*/) OVERRIDE
{
- if (!instance)
- {
- ERROR_INST_DATA(me);
- return;
- }
}
void JustDied(Unit* /*killer*/) OVERRIDE
{
- if (instance)
+ uint64 TerestianGUID = instance->GetData64(DATA_TERESTIAN);
+ if (TerestianGUID)
{
- uint64 TerestianGUID = instance->GetData64(DATA_TERESTIAN);
- if (TerestianGUID)
- {
- Unit* Terestian = Unit::GetUnit(*me, TerestianGUID);
- if (Terestian && Terestian->IsAlive())
- DoCast(Terestian, SPELL_BROKEN_PACT, true);
- }
- } else ERROR_INST_DATA(me);
+ Unit* Terestian = Unit::GetUnit(*me, TerestianGUID);
+ if (Terestian && Terestian->IsAlive())
+ DoCast(Terestian, SPELL_BROKEN_PACT, true);
+ }
}
void UpdateAI(uint32 diff) OVERRIDE
@@ -256,7 +248,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_terestianAI(creature);
+ return GetInstanceAI<boss_terestianAI>(creature);
}
struct boss_terestianAI : public ScriptedAI
@@ -306,8 +298,7 @@ public:
SummonedPortals = false;
Berserk = false;
- if (instance)
- instance->SetData(TYPE_TERESTIAN, NOT_STARTED);
+ instance->SetData(TYPE_TERESTIAN, NOT_STARTED);
me->RemoveAurasDueToSpell(SPELL_BROKEN_PACT);
@@ -362,8 +353,7 @@ public:
Talk(SAY_DEATH);
- if (instance)
- instance->SetData(TYPE_TERESTIAN, DONE);
+ instance->SetData(TYPE_TERESTIAN, DONE);
}
void UpdateAI(uint32 diff) OVERRIDE
diff --git a/src/server/scripts/EasternKingdoms/Karazhan/bosses_opera.cpp b/src/server/scripts/EasternKingdoms/Karazhan/bosses_opera.cpp
index da14ab8646e..e3a97ae72d9 100644
--- a/src/server/scripts/EasternKingdoms/Karazhan/bosses_opera.cpp
+++ b/src/server/scripts/EasternKingdoms/Karazhan/bosses_opera.cpp
@@ -118,7 +118,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_dorotheeAI(creature);
+ return GetInstanceAI<boss_dorotheeAI>(creature);
}
struct boss_dorotheeAI : public ScriptedAI
@@ -167,8 +167,7 @@ public:
{
Talk(SAY_DOROTHEE_DEATH);
- if (instance)
- SummonCroneIfReady(instance, me);
+ SummonCroneIfReady(instance, me);
}
void AttackStart(Unit* who) OVERRIDE
@@ -299,7 +298,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_strawmanAI(creature);
+ return GetInstanceAI<boss_strawmanAI>(creature);
}
struct boss_strawmanAI : public ScriptedAI
@@ -366,8 +365,7 @@ public:
{
Talk(SAY_STRAWMAN_DEATH);
- if (instance)
- SummonCroneIfReady(instance, me);
+ SummonCroneIfReady(instance, me);
}
void KilledUnit(Unit* /*victim*/) OVERRIDE
@@ -414,7 +412,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_tinheadAI(creature);
+ return GetInstanceAI<boss_tinheadAI>(creature);
}
struct boss_tinheadAI : public ScriptedAI
@@ -472,8 +470,7 @@ public:
{
Talk(SAY_TINHEAD_DEATH);
- if (instance)
- SummonCroneIfReady(instance, me);
+ SummonCroneIfReady(instance, me);
}
void KilledUnit(Unit* /*victim*/) OVERRIDE
@@ -524,7 +521,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_roarAI(creature);
+ return GetInstanceAI<boss_roarAI>(creature);
}
struct boss_roarAI : public ScriptedAI
@@ -580,8 +577,7 @@ public:
{
Talk(SAY_ROAR_DEATH);
- if (instance)
- SummonCroneIfReady(instance, me);
+ SummonCroneIfReady(instance, me);
}
void KilledUnit(Unit* /*victim*/) OVERRIDE
@@ -633,7 +629,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_croneAI(creature);
+ return GetInstanceAI<boss_croneAI>(creature);
}
struct boss_croneAI : public ScriptedAI
@@ -675,15 +671,12 @@ public:
{
Talk(SAY_CRONE_DEATH);
- if (instance)
- {
- instance->SetData(TYPE_OPERA, DONE);
- instance->HandleGameObject(instance->GetData64(DATA_GO_STAGEDOORLEFT), true);
- instance->HandleGameObject(instance->GetData64(DATA_GO_STAGEDOORRIGHT), true);
+ instance->SetData(TYPE_OPERA, DONE);
+ instance->HandleGameObject(instance->GetData64(DATA_GO_STAGEDOORLEFT), true);
+ instance->HandleGameObject(instance->GetData64(DATA_GO_STAGEDOORRIGHT), true);
- if (GameObject* pSideEntrance = instance->instance->GetGameObject(instance->GetData64(DATA_GO_SIDE_ENTRANCE_DOOR)))
- pSideEntrance->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_LOCKED);
- }
+ if (GameObject* pSideEntrance = instance->instance->GetGameObject(instance->GetData64(DATA_GO_SIDE_ENTRANCE_DOOR)))
+ pSideEntrance->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_LOCKED);
}
void UpdateAI(uint32 diff) OVERRIDE
@@ -813,7 +806,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_bigbadwolfAI(creature);
+ return GetInstanceAI<boss_bigbadwolfAI>(creature);
}
struct boss_bigbadwolfAI : public ScriptedAI
@@ -865,15 +858,12 @@ public:
{
DoPlaySoundToSet(me, SOUND_WOLF_DEATH);
- if (instance)
- {
- instance->SetData(TYPE_OPERA, DONE);
- instance->HandleGameObject(instance->GetData64(DATA_GO_STAGEDOORLEFT), true);
- instance->HandleGameObject(instance->GetData64(DATA_GO_STAGEDOORRIGHT), true);
+ instance->SetData(TYPE_OPERA, DONE);
+ instance->HandleGameObject(instance->GetData64(DATA_GO_STAGEDOORLEFT), true);
+ instance->HandleGameObject(instance->GetData64(DATA_GO_STAGEDOORRIGHT), true);
- if (GameObject* pSideEntrance = instance->instance->GetGameObject(instance->GetData64(DATA_GO_SIDE_ENTRANCE_DOOR)))
- pSideEntrance->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_LOCKED);
- }
+ if (GameObject* pSideEntrance = instance->instance->GetGameObject(instance->GetData64(DATA_GO_SIDE_ENTRANCE_DOOR)))
+ pSideEntrance->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_LOCKED);
}
void UpdateAI(uint32 diff) OVERRIDE
@@ -1015,7 +1005,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_julianneAI(creature);
+ return GetInstanceAI<boss_julianneAI>(creature);
}
struct boss_julianneAI : public ScriptedAI
@@ -1112,14 +1102,11 @@ public:
{
Talk(SAY_JULIANNE_DEATH02);
- if (instance)
- {
- instance->SetData(TYPE_OPERA, DONE);
- instance->HandleGameObject(instance->GetData64(DATA_GO_STAGEDOORLEFT), true);
- instance->HandleGameObject(instance->GetData64(DATA_GO_STAGEDOORRIGHT), true);
- if (GameObject* pSideEntrance = instance->instance->GetGameObject(instance->GetData64(DATA_GO_SIDE_ENTRANCE_DOOR)))
- pSideEntrance->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_LOCKED);
- }
+ instance->SetData(TYPE_OPERA, DONE);
+ instance->HandleGameObject(instance->GetData64(DATA_GO_STAGEDOORLEFT), true);
+ instance->HandleGameObject(instance->GetData64(DATA_GO_STAGEDOORRIGHT), true);
+ if (GameObject* pSideEntrance = instance->instance->GetGameObject(instance->GetData64(DATA_GO_SIDE_ENTRANCE_DOOR)))
+ pSideEntrance->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_LOCKED);
}
void KilledUnit(Unit* /*victim*/) OVERRIDE
@@ -1138,7 +1125,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_romuloAI(creature);
+ return GetInstanceAI<boss_romuloAI>(creature);
}
struct boss_romuloAI : public ScriptedAI
@@ -1267,15 +1254,12 @@ public:
{
Talk(SAY_ROMULO_DEATH);
- if (instance)
- {
- instance->SetData(TYPE_OPERA, DONE);
- instance->HandleGameObject(instance->GetData64(DATA_GO_STAGEDOORLEFT), true);
- instance->HandleGameObject(instance->GetData64(DATA_GO_STAGEDOORRIGHT), true);
+ instance->SetData(TYPE_OPERA, DONE);
+ instance->HandleGameObject(instance->GetData64(DATA_GO_STAGEDOORLEFT), true);
+ instance->HandleGameObject(instance->GetData64(DATA_GO_STAGEDOORRIGHT), true);
- if (GameObject* pSideEntrance = instance->instance->GetGameObject(instance->GetData64(DATA_GO_SIDE_ENTRANCE_DOOR)))
- pSideEntrance->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_LOCKED);
- }
+ if (GameObject* pSideEntrance = instance->instance->GetGameObject(instance->GetData64(DATA_GO_SIDE_ENTRANCE_DOOR)))
+ pSideEntrance->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_LOCKED);
}
void KilledUnit(Unit* /*victim*/) OVERRIDE
diff --git a/src/server/scripts/EasternKingdoms/Karazhan/karazhan.cpp b/src/server/scripts/EasternKingdoms/Karazhan/karazhan.cpp
index e59889d24aa..ae08d580e57 100644
--- a/src/server/scripts/EasternKingdoms/Karazhan/karazhan.cpp
+++ b/src/server/scripts/EasternKingdoms/Karazhan/karazhan.cpp
@@ -158,15 +158,11 @@ public:
PerformanceReady = false;
- if (instance)
- m_uiEventId = instance->GetData(DATA_OPERA_PERFORMANCE);
+ m_uiEventId = instance->GetData(DATA_OPERA_PERFORMANCE);
}
void StartEvent()
{
- if (!instance)
- return;
-
instance->SetData(TYPE_OPERA, IN_PROGRESS);
//resets count for this event, in case earlier failed
@@ -180,9 +176,6 @@ public:
void WaypointReached(uint32 waypointId) OVERRIDE
{
- if (!instance)
- return;
-
switch (waypointId)
{
case 0:
@@ -412,7 +405,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_barnesAI(creature);
+ return GetInstanceAI<npc_barnesAI>(creature);
}
};
@@ -476,7 +469,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_image_of_medivhAI(creature);
+ return GetInstanceAI<npc_image_of_medivhAI>(creature);
}
struct npc_image_of_medivhAI : public ScriptedAI
@@ -500,6 +493,8 @@ public:
void Reset() OVERRIDE
{
ArcanagosGUID = 0;
+ EventStarted = false;
+ YellTimer = 0;
if (instance && instance->GetData64(DATA_IMAGE_OF_MEDIVH) == 0)
{
diff --git a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_felblood_kaelthas.cpp b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_felblood_kaelthas.cpp
index 074ad3f1b96..ddc8ceb0aa1 100644
--- a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_felblood_kaelthas.cpp
+++ b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_felblood_kaelthas.cpp
@@ -96,7 +96,7 @@ public:
CreatureAI* GetAI(Creature* c) const OVERRIDE
{
- return new boss_felblood_kaelthasAI(c);
+ return GetInstanceAI<boss_felblood_kaelthasAI>(c);
}
struct boss_felblood_kaelthasAI : public ScriptedAI
@@ -150,17 +150,13 @@ public:
Phase = 0;
- if (instance)
- instance->SetData(DATA_KAELTHAS_EVENT, NOT_STARTED);
+ instance->SetData(DATA_KAELTHAS_EVENT, NOT_STARTED);
}
void JustDied(Unit* /*killer*/) OVERRIDE
{
Talk(SAY_DEATH);
- if (!instance)
- return;
-
instance->SetData(DATA_KAELTHAS_EVENT, DONE);
// Enable the Translocation Orb Exit
@@ -176,9 +172,6 @@ public:
void EnterCombat(Unit* /*who*/) OVERRIDE
{
- if (!instance)
- return;
-
instance->SetData(DATA_KAELTHAS_EVENT, IN_PROGRESS);
}
@@ -371,8 +364,7 @@ public:
Talk(SAY_GRAVITY_LAPSE);
FirstGravityLapse = false;
- if (instance)
- instance->SetData(DATA_KAELTHAS_STATUES, 1);
+ instance->SetData(DATA_KAELTHAS_STATUES, 1);
}
else
Talk(SAY_RECAST_GRAVITY);
@@ -482,7 +474,7 @@ public:
CreatureAI* GetAI(Creature* c) const OVERRIDE
{
- return new npc_felkael_phoenixAI(c);
+ return GetInstanceAI<npc_felkael_phoenixAI>(c);
}
struct npc_felkael_phoenixAI : public ScriptedAI
diff --git a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_priestess_delrissa.cpp b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_priestess_delrissa.cpp
index c8ab4a147ff..1571c94dc33 100644
--- a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_priestess_delrissa.cpp
+++ b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_priestess_delrissa.cpp
@@ -110,7 +110,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_priestess_delrissaAI(creature);
+ return GetInstanceAI<boss_priestess_delrissaAI>(creature);
}
struct boss_priestess_delrissaAI : public ScriptedAI
@@ -153,8 +153,7 @@ public:
//this mean she at some point evaded
void JustReachedHome() OVERRIDE
{
- if (instance)
- instance->SetData(DATA_DELRISSA_EVENT, FAIL);
+ instance->SetData(DATA_DELRISSA_EVENT, FAIL);
}
void EnterCombat(Unit* who) OVERRIDE
@@ -173,8 +172,7 @@ public:
}
}
- if (instance)
- instance->SetData(DATA_DELRISSA_EVENT, IN_PROGRESS);
+ instance->SetData(DATA_DELRISSA_EVENT, IN_PROGRESS);
}
void InitializeLackeys()
@@ -241,9 +239,6 @@ public:
{
Talk(SAY_DEATH);
- if (!instance)
- return;
-
if (instance->GetData(DATA_DELRISSA_DEATH_COUNT) == MAX_ACTIVE_LACKEY)
instance->SetData(DATA_DELRISSA_EVENT, DONE);
else
@@ -393,36 +388,30 @@ struct boss_priestess_lackey_commonAI : public ScriptedAI
if (!who)
return;
- if (instance)
+ for (uint8 i = 0; i < MAX_ACTIVE_LACKEY; ++i)
{
- for (uint8 i = 0; i < MAX_ACTIVE_LACKEY; ++i)
+ if (Unit* pAdd = Unit::GetUnit(*me, m_auiLackeyGUIDs[i]))
{
- if (Unit* pAdd = Unit::GetUnit(*me, m_auiLackeyGUIDs[i]))
+ if (!pAdd->GetVictim() && pAdd != me)
{
- if (!pAdd->GetVictim() && pAdd != me)
- {
- who->SetInCombatWith(pAdd);
- pAdd->AddThreat(who, 0.0f);
- }
+ who->SetInCombatWith(pAdd);
+ pAdd->AddThreat(who, 0.0f);
}
}
+ }
- if (Creature* pDelrissa = Unit::GetCreature(*me, instance->GetData64(DATA_DELRISSA)))
+ if (Creature* pDelrissa = Unit::GetCreature(*me, instance->GetData64(DATA_DELRISSA)))
+ {
+ if (pDelrissa->IsAlive() && !pDelrissa->GetVictim())
{
- if (pDelrissa->IsAlive() && !pDelrissa->GetVictim())
- {
- who->SetInCombatWith(pDelrissa);
- pDelrissa->AddThreat(who, 0.0f);
- }
+ who->SetInCombatWith(pDelrissa);
+ pDelrissa->AddThreat(who, 0.0f);
}
}
}
void JustDied(Unit* /*killer*/) OVERRIDE
{
- if (!instance)
- return;
-
Creature* pDelrissa = Unit::GetCreature(*me, instance->GetData64(DATA_DELRISSA));
uint32 uiLackeyDeathCount = instance->GetData(DATA_DELRISSA_DEATH_COUNT);
@@ -452,18 +441,12 @@ struct boss_priestess_lackey_commonAI : public ScriptedAI
void KilledUnit(Unit* victim) OVERRIDE
{
- if (!instance)
- return;
-
if (Creature* Delrissa = Unit::GetCreature(*me, instance->GetData64(DATA_DELRISSA)))
Delrissa->AI()->KilledUnit(victim);
}
void AcquireGUIDs()
{
- if (!instance)
- return;
-
if (Creature* Delrissa = (Unit::GetCreature(*me, instance->GetData64(DATA_DELRISSA))))
{
for (uint8 i = 0; i < MAX_ACTIVE_LACKEY; ++i)
@@ -504,7 +487,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_kagani_nightstrikeAI(creature);
+ return GetInstanceAI<boss_kagani_nightstrikeAI>(creature);
}
struct boss_kagani_nightstrikeAI : public boss_priestess_lackey_commonAI
@@ -608,7 +591,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_ellris_duskhallowAI(creature);
+ return GetInstanceAI<boss_ellris_duskhallowAI>(creature);
}
struct boss_ellris_duskhallowAI : public boss_priestess_lackey_commonAI
@@ -699,7 +682,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_eramas_brightblazeAI(creature);
+ return GetInstanceAI<boss_eramas_brightblazeAI>(creature);
}
struct boss_eramas_brightblazeAI : public boss_priestess_lackey_commonAI
@@ -760,7 +743,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_yazzaiAI(creature);
+ return GetInstanceAI<boss_yazzaiAI>(creature);
}
struct boss_yazzaiAI : public boss_priestess_lackey_commonAI
@@ -890,7 +873,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_warlord_salarisAI(creature);
+ return GetInstanceAI<boss_warlord_salarisAI>(creature);
}
struct boss_warlord_salarisAI : public boss_priestess_lackey_commonAI
@@ -1010,7 +993,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_garaxxasAI(creature);
+ return GetInstanceAI<boss_garaxxasAI>(creature);
}
struct boss_garaxxasAI : public boss_priestess_lackey_commonAI
@@ -1068,7 +1051,7 @@ public:
if (Freezing_Trap_Timer <= diff)
{
- //attempt find go summoned from spell (casted by me)
+ //attempt find go summoned from spell (cast by me)
GameObject* go = me->GetGameObject(SPELL_FREEZING_TRAP);
//if we have a go, we need to wait (only one trap at a time)
@@ -1121,7 +1104,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_apokoAI(creature);
+ return GetInstanceAI<boss_apokoAI>(creature);
}
struct boss_apokoAI : public boss_priestess_lackey_commonAI
@@ -1219,7 +1202,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_zelfanAI(creature);
+ return GetInstanceAI<boss_zelfanAI>(creature);
}
struct boss_zelfanAI : public boss_priestess_lackey_commonAI
diff --git a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_selin_fireheart.cpp b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_selin_fireheart.cpp
index 849713d72bf..936f30c4135 100644
--- a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_selin_fireheart.cpp
+++ b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_selin_fireheart.cpp
@@ -66,7 +66,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_selin_fireheartAI(creature);
+ return GetInstanceAI<boss_selin_fireheartAI>(creature);
};
struct boss_selin_fireheartAI : public ScriptedAI
@@ -77,16 +77,13 @@ public:
Crystals.clear();
//GUIDs per instance is static, so we only need to load them once.
- if (instance)
+ uint32 size = instance->GetData(DATA_FEL_CRYSTAL_SIZE);
+ for (uint8 i = 0; i < size; ++i)
{
- uint32 size = instance->GetData(DATA_FEL_CRYSTAL_SIZE);
- for (uint8 i = 0; i < size; ++i)
- {
- instance->SetData64(DATA_FEL_CRYSTAL, i);
- uint64 guid = instance->GetData64(DATA_FEL_CRYSTAL);
- TC_LOG_DEBUG("scripts", "Selin: Adding Fel Crystal " UI64FMTD " to list", guid);
- Crystals.push_back(guid);
- }
+ instance->SetData64(DATA_FEL_CRYSTAL, i);
+ uint64 guid = instance->GetData64(DATA_FEL_CRYSTAL);
+ TC_LOG_DEBUG("scripts", "Selin: Adding Fel Crystal " UI64FMTD " to list", guid);
+ Crystals.push_back(guid);
}
}
@@ -107,25 +104,22 @@ public:
void Reset() OVERRIDE
{
- if (instance)
+ //for (uint8 i = 0; i < CRYSTALS_NUMBER; ++i)
+ for (std::list<uint64>::const_iterator itr = Crystals.begin(); itr != Crystals.end(); ++itr)
{
- //for (uint8 i = 0; i < CRYSTALS_NUMBER; ++i)
- for (std::list<uint64>::const_iterator itr = Crystals.begin(); itr != Crystals.end(); ++itr)
+ //Unit* unit = Unit::GetUnit(*me, FelCrystals[i]);
+ if (Creature* creature = Unit::GetCreature(*me, *itr))
{
- //Unit* unit = Unit::GetUnit(*me, FelCrystals[i]);
- if (Creature* creature = Unit::GetCreature(*me, *itr))
- {
- if (!creature->IsAlive())
- creature->Respawn(); // Let the core handle setting death state, etc.
+ if (!creature->IsAlive())
+ creature->Respawn(); // Let the core handle setting death state, etc.
- // Only need to set unselectable flag. You can't attack unselectable units so non_attackable flag is not necessary here.
- creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
- }
+ // Only need to set unselectable flag. You can't attack unselectable units so non_attackable flag is not necessary here.
+ creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
}
+ }
- // Set Inst data for encounter
- instance->SetData(DATA_SELIN_EVENT, NOT_STARTED);
- } else TC_LOG_ERROR("scripts", ERROR_INST_DATA);
+ // Set Inst data for encounter
+ instance->SetData(DATA_SELIN_EVENT, NOT_STARTED);
DrainLifeTimer = urand(3000, 7000);
DrainManaTimer = DrainLifeTimer + 5000;
@@ -200,8 +194,7 @@ public:
void EnterCombat(Unit* /*who*/) OVERRIDE
{
Talk(SAY_AGGRO);
- if (instance)
- instance->SetData(DATA_SELIN_EVENT, IN_PROGRESS);
+ instance->SetData(DATA_SELIN_EVENT, IN_PROGRESS);
}
void KilledUnit(Unit* /*victim*/) OVERRIDE
@@ -235,9 +228,6 @@ public:
{
Talk(SAY_DEATH);
- if (!instance)
- return;
-
instance->SetData(DATA_SELIN_EVENT, DONE); // Encounter complete!
ShatterRemainingCrystals();
}
@@ -271,7 +261,7 @@ public:
if (FelExplosionTimer <= diff)
{
- if (!me->IsNonMeleeSpellCasted(false))
+ if (!me->IsNonMeleeSpellCast(false))
{
DoCast(me, SPELL_FEL_EXPLOSION);
FelExplosionTimer = 2000;
diff --git a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_vexallus.cpp b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_vexallus.cpp
index 24b48112bb6..290c4830251 100644
--- a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_vexallus.cpp
+++ b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_vexallus.cpp
@@ -76,7 +76,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_vexallusAI(creature);
+ return GetInstanceAI<boss_vexallusAI>(creature);
};
struct boss_vexallusAI : public BossAI
@@ -103,8 +103,7 @@ public:
IntervalHealthAmount = 1;
Enraged = false;
- if (instance)
- instance->SetData(DATA_VEXALLUS_EVENT, NOT_STARTED);
+ instance->SetData(DATA_VEXALLUS_EVENT, NOT_STARTED);
}
void KilledUnit(Unit* /*victim*/) OVERRIDE
@@ -115,16 +114,14 @@ public:
void JustDied(Unit* /*killer*/) OVERRIDE
{
summons.DespawnAll();
- if (instance)
- instance->SetData(DATA_VEXALLUS_EVENT, DONE);
+ instance->SetData(DATA_VEXALLUS_EVENT, DONE);
}
void EnterCombat(Unit* /*who*/) OVERRIDE
{
Talk(SAY_AGGRO);
- if (instance)
- instance->SetData(DATA_VEXALLUS_EVENT, IN_PROGRESS);
+ instance->SetData(DATA_VEXALLUS_EVENT, IN_PROGRESS);
}
void JustSummoned(Creature* summoned) OVERRIDE
diff --git a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_arcanist_doan.cpp b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_arcanist_doan.cpp
index 694fdf9d84e..7389d9afbff 100644
--- a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_arcanist_doan.cpp
+++ b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_arcanist_doan.cpp
@@ -93,7 +93,7 @@ public:
if (!bShielded && !HealthAbovePct(50))
{
//wait if we already casting
- if (me->IsNonMeleeSpellCasted(false))
+ if (me->IsNonMeleeSpellCast(false))
return;
Talk(SAY_SPECIALAE);
diff --git a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_azshir_the_sleepless.cpp b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_azshir_the_sleepless.cpp
index 6f028e33726..274be80b7b0 100644
--- a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_azshir_the_sleepless.cpp
+++ b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_azshir_the_sleepless.cpp
@@ -66,7 +66,7 @@ public:
return;
//If we are <50% hp cast Soul Siphon rank 1
- if (!HealthAbovePct(50) && !me->IsNonMeleeSpellCasted(false))
+ if (!HealthAbovePct(50) && !me->IsNonMeleeSpellCast(false))
{
//SoulSiphon_Timer
if (SoulSiphon_Timer <= diff)
diff --git a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp
index 442dcf91f32..f67d85469e3 100644
--- a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp
+++ b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp
@@ -374,7 +374,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_headless_horsemanAI(creature);
+ return GetInstanceAI<boss_headless_horsemanAI>(creature);
}
struct boss_headless_horsemanAI : public ScriptedAI
@@ -382,6 +382,7 @@ public:
boss_headless_horsemanAI(Creature* creature) : ScriptedAI(creature)
{
instance = creature->GetInstanceScript();
+ headGUID = 0;
}
InstanceScript* instance;
@@ -434,8 +435,7 @@ public:
}
me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC);
- //if (instance)
- // instance->SetData(DATA_HORSEMAN_EVENT, NOT_STARTED);
+ //instance->SetData(DATA_HORSEMAN_EVENT, NOT_STARTED);
}
void FlyMode()
@@ -471,8 +471,7 @@ public:
break;
}
case 6:
- if (instance)
- instance->SetData(GAMEOBJECT_PUMPKIN_SHRINE, 0); //hide gameobject
+ instance->SetData(GAMEOBJECT_PUMPKIN_SHRINE, 0); //hide gameobject
break;
case 19:
me->SetDisableGravity(false);
@@ -494,8 +493,7 @@ public:
void EnterCombat(Unit* /*who*/) OVERRIDE
{
- if (instance)
- instance->SetData(DATA_HORSEMAN_EVENT, IN_PROGRESS);
+ instance->SetData(DATA_HORSEMAN_EVENT, IN_PROGRESS);
DoZoneInCombat();
}
@@ -569,8 +567,7 @@ public:
flame->CastSpell(flame, SPELL_BODY_FLAME, false);
if (Creature* wisp = DoSpawnCreature(WISP_INVIS, 0, 0, 0, 0, TEMPSUMMON_TIMED_DESPAWN, 60000))
CAST_AI(npc_wisp_invis::npc_wisp_invisAI, wisp->AI())->SetType(4);
- if (instance)
- instance->SetData(DATA_HORSEMAN_EVENT, DONE);
+ instance->SetData(DATA_HORSEMAN_EVENT, DONE);
Map::PlayerList const& players = me->GetMap()->GetPlayers();
if (!players.isEmpty())
@@ -800,8 +797,8 @@ public:
float x, y, z;
me->GetPosition(x, y, z); //this visual aura some under ground
me->SetPosition(x, y, z + 0.35f, 0.0f);
- Despawn();
debuffGUID = 0;
+ Despawn();
Creature* debuff = DoSpawnCreature(HELPER, 0, 0, 0, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 14500);
if (debuff)
{
diff --git a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_herod.cpp b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_herod.cpp
index 40fe93155a5..e4974ef7eb0 100644
--- a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_herod.cpp
+++ b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_herod.cpp
@@ -99,7 +99,7 @@ public:
return;
//If we are <30% hp goes Enraged
- if (!Enrage && !HealthAbovePct(30) && !me->IsNonMeleeSpellCasted(false))
+ if (!Enrage && !HealthAbovePct(30) && !me->IsNonMeleeSpellCast(false))
{
Talk(EMOTE_ENRAGE);
Talk(SAY_ENRAGE);
diff --git a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_high_inquisitor_fairbanks.cpp b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_high_inquisitor_fairbanks.cpp
index 46680730f7e..ea624576dbc 100644
--- a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_high_inquisitor_fairbanks.cpp
+++ b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_high_inquisitor_fairbanks.cpp
@@ -83,7 +83,7 @@ public:
return;
//If we are <25% hp cast Heal
- if (!HealthAbovePct(25) && !me->IsNonMeleeSpellCasted(false) && Heal_Timer <= diff)
+ if (!HealthAbovePct(25) && !me->IsNonMeleeSpellCast(false) && Heal_Timer <= diff)
{
DoCast(me, SPELL_HEAL);
Heal_Timer = 30000;
diff --git a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_interrogator_vishas.cpp b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_interrogator_vishas.cpp
index a57c237c21a..db10c319121 100644
--- a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_interrogator_vishas.cpp
+++ b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_interrogator_vishas.cpp
@@ -48,7 +48,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_interrogator_vishasAI(creature);
+ return GetInstanceAI<boss_interrogator_vishasAI>(creature);
}
struct boss_interrogator_vishasAI : public ScriptedAI
@@ -67,6 +67,8 @@ public:
void Reset() OVERRIDE
{
ShadowWordPain_Timer = 5000;
+ Yell60 = false;
+ Yell30 = false;
}
void EnterCombat(Unit* /*who*/) OVERRIDE
@@ -81,9 +83,6 @@ public:
void JustDied(Unit* /*killer*/) OVERRIDE
{
- if (!instance)
- return;
-
//Any other Actions to do with vorrel? setStandState?
if (Creature* vorrel = Creature::GetCreature(*me, instance->GetData64(DATA_VORREL)))
vorrel->AI()->Talk(SAY_TRIGGER_VORREL);
diff --git a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_mograine_and_whitemane.cpp b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_mograine_and_whitemane.cpp
index 403416bb202..6490ee38ab6 100644
--- a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_mograine_and_whitemane.cpp
+++ b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_mograine_and_whitemane.cpp
@@ -65,7 +65,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_scarlet_commander_mograineAI(creature);
+ return GetInstanceAI<boss_scarlet_commander_mograineAI>(creature);
}
struct boss_scarlet_commander_mograineAI : public ScriptedAI
@@ -94,9 +94,8 @@ public:
me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
me->SetStandState(UNIT_STAND_STATE_STAND);
- if (instance)
- if (me->IsAlive())
- instance->SetData(TYPE_MOGRAINE_AND_WHITE_EVENT, NOT_STARTED);
+ if (me->IsAlive())
+ instance->SetData(TYPE_MOGRAINE_AND_WHITE_EVENT, NOT_STARTED);
_bHasDied = false;
_bHeal = false;
@@ -105,11 +104,8 @@ public:
void JustReachedHome() OVERRIDE
{
- if (instance)
- {
- if (instance->GetData(TYPE_MOGRAINE_AND_WHITE_EVENT) != NOT_STARTED)
- instance->SetData(TYPE_MOGRAINE_AND_WHITE_EVENT, FAIL);
- }
+ if (instance->GetData(TYPE_MOGRAINE_AND_WHITE_EVENT) != NOT_STARTED)
+ instance->SetData(TYPE_MOGRAINE_AND_WHITE_EVENT, FAIL);
}
void EnterCombat(Unit* /*who*/) OVERRIDE
@@ -130,9 +126,6 @@ public:
if (damage < me->GetHealth() || _bHasDied || _bFakeDeath)
return;
- if (!instance)
- return;
-
//On first death, fake death and open door, as well as initiate whitemane if exist
if (Unit* Whitemane = Unit::GetUnit(*me, instance->GetData64(DATA_WHITEMANE)))
{
@@ -145,7 +138,7 @@ public:
me->SetHealth(0);
- if (me->IsNonMeleeSpellCasted(false))
+ if (me->IsNonMeleeSpellCast(false))
me->InterruptNonMeleeSpells(false);
me->ClearComboPointHolders();
@@ -170,8 +163,7 @@ public:
Talk(SAY_MO_RESSURECTED);
_bFakeDeath = false;
- if (instance)
- instance->SetData(TYPE_MOGRAINE_AND_WHITE_EVENT, SPECIAL);
+ instance->SetData(TYPE_MOGRAINE_AND_WHITE_EVENT, SPECIAL);
}
}
@@ -231,7 +223,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_high_inquisitor_whitemaneAI(creature);
+ return GetInstanceAI<boss_high_inquisitor_whitemaneAI>(creature);
}
struct boss_high_inquisitor_whitemaneAI : public ScriptedAI
@@ -261,9 +253,8 @@ public:
_bCanResurrectCheck = false;
_bCanResurrect = false;
- if (instance)
- if (me->IsAlive())
- instance->SetData(TYPE_MOGRAINE_AND_WHITE_EVENT, NOT_STARTED);
+ if (me->IsAlive())
+ instance->SetData(TYPE_MOGRAINE_AND_WHITE_EVENT, NOT_STARTED);
}
void AttackStart(Unit* who) OVERRIDE
@@ -313,7 +304,7 @@ public:
//Cast Deep sleep when health is less than 50%
if (!_bCanResurrectCheck && !HealthAbovePct(50))
{
- if (me->IsNonMeleeSpellCasted(false))
+ if (me->IsNonMeleeSpellCast(false))
me->InterruptNonMeleeSpells(false);
DoCastVictim(SPELL_DEEPSLEEP);
@@ -334,14 +325,11 @@ public:
if (!HealthAbovePct(75))
target = me;
- if (instance)
+ if (Creature* mograine = Unit::GetCreature((*me), instance->GetData64(DATA_MOGRAINE)))
{
- if (Creature* mograine = Unit::GetCreature((*me), instance->GetData64(DATA_MOGRAINE)))
- {
- // checking _bCanResurrectCheck prevents her healing Mograine while he is "faking death"
- if (_bCanResurrectCheck && mograine->IsAlive() && !mograine->HealthAbovePct(75))
- target = mograine;
- }
+ // checking _bCanResurrectCheck prevents her healing Mograine while he is "faking death"
+ if (_bCanResurrectCheck && mograine->IsAlive() && !mograine->HealthAbovePct(75))
+ target = mograine;
}
if (target)
diff --git a/src/server/scripts/EasternKingdoms/Scholomance/boss_darkmaster_gandling.cpp b/src/server/scripts/EasternKingdoms/Scholomance/boss_darkmaster_gandling.cpp
index 2277c53ae6b..558dc030eaf 100644
--- a/src/server/scripts/EasternKingdoms/Scholomance/boss_darkmaster_gandling.cpp
+++ b/src/server/scripts/EasternKingdoms/Scholomance/boss_darkmaster_gandling.cpp
@@ -128,7 +128,7 @@ class boss_darkmaster_gandling : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_darkmaster_gandlingAI(creature);
+ return GetInstanceAI<boss_darkmaster_gandlingAI>(creature);
}
};
diff --git a/src/server/scripts/EasternKingdoms/Scholomance/boss_instructor_malicia.cpp b/src/server/scripts/EasternKingdoms/Scholomance/boss_instructor_malicia.cpp
index 88f95df69c4..0f3929bda36 100644
--- a/src/server/scripts/EasternKingdoms/Scholomance/boss_instructor_malicia.cpp
+++ b/src/server/scripts/EasternKingdoms/Scholomance/boss_instructor_malicia.cpp
@@ -99,7 +99,7 @@ class boss_instructor_malicia : public CreatureScript
events.ScheduleEvent(EVENT_RENEW, 10000);
break;
case EVENT_FLASHHEAL:
- //5 Flashheals will be casted
+ //5 Flashheals will be cast
DoCast(me, SPELL_FLASHHEAL);
if (FlashCounter < 2)
{
@@ -113,7 +113,7 @@ class boss_instructor_malicia : public CreatureScript
}
break;
case EVENT_HEALINGTOUCH:
- //3 Healing Touch will be casted
+ //3 Healing Touch will be cast
DoCast(me, SPELL_HEALINGTOUCH);
if (TouchCounter < 2)
{
diff --git a/src/server/scripts/EasternKingdoms/Scholomance/boss_jandice_barov.cpp b/src/server/scripts/EasternKingdoms/Scholomance/boss_jandice_barov.cpp
index 2663146317a..cbd996d04fc 100644
--- a/src/server/scripts/EasternKingdoms/Scholomance/boss_jandice_barov.cpp
+++ b/src/server/scripts/EasternKingdoms/Scholomance/boss_jandice_barov.cpp
@@ -32,7 +32,7 @@ enum Spells
//SPELL_ILLUSION = 17773,
// Spells of Illusion of Jandice Barov
- SPELL_CLEAVE = 15584
+ SPELL_CLEAVE = 15284
};
class boss_jandice_barov : public CreatureScript
diff --git a/src/server/scripts/EasternKingdoms/Scholomance/boss_kirtonos_the_herald.cpp b/src/server/scripts/EasternKingdoms/Scholomance/boss_kirtonos_the_herald.cpp
index 2433390f8f5..e485db94e42 100644
--- a/src/server/scripts/EasternKingdoms/Scholomance/boss_kirtonos_the_herald.cpp
+++ b/src/server/scripts/EasternKingdoms/Scholomance/boss_kirtonos_the_herald.cpp
@@ -253,7 +253,7 @@ class boss_kirtonos_the_herald : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_kirtonos_the_heraldAI(creature);
+ return GetInstanceAI<boss_kirtonos_the_heraldAI>(creature);
}
};
diff --git a/src/server/scripts/EasternKingdoms/Scholomance/boss_lord_alexei_barov.cpp b/src/server/scripts/EasternKingdoms/Scholomance/boss_lord_alexei_barov.cpp
index e06c0d6bfbb..17524ddf2b2 100644
--- a/src/server/scripts/EasternKingdoms/Scholomance/boss_lord_alexei_barov.cpp
+++ b/src/server/scripts/EasternKingdoms/Scholomance/boss_lord_alexei_barov.cpp
@@ -28,8 +28,9 @@ EndScriptData */
enum Spells
{
- SPELL_IMMOLATE = 20294, // Old ID was 15570
- SPELL_VEILOFSHADOW = 17820
+ SPELL_IMMOLATE = 20294,
+ SPELL_VEILOFSHADOW = 17820,
+ SPELL_UNHOLY_AURA = 17467
};
enum Events
@@ -49,7 +50,9 @@ class boss_lord_alexei_barov : public CreatureScript
void Reset() OVERRIDE
{
_Reset();
- me->LoadCreaturesAddon();
+
+ if (!me->HasAura(SPELL_UNHOLY_AURA))
+ DoCast(me, SPELL_UNHOLY_AURA);
}
void EnterCombat(Unit* /*who*/) OVERRIDE
diff --git a/src/server/scripts/EasternKingdoms/ShadowfangKeep/shadowfang_keep.cpp b/src/server/scripts/EasternKingdoms/ShadowfangKeep/shadowfang_keep.cpp
index 8d89592090e..b7ce218008c 100644
--- a/src/server/scripts/EasternKingdoms/ShadowfangKeep/shadowfang_keep.cpp
+++ b/src/server/scripts/EasternKingdoms/ShadowfangKeep/shadowfang_keep.cpp
@@ -72,7 +72,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_shadowfang_prisonerAI(creature);
+ return GetInstanceAI<npc_shadowfang_prisonerAI>(creature);
}
bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action) OVERRIDE
@@ -135,8 +135,7 @@ public:
else
Talk(SAY_POST1_DOOR_AD);
- if (instance)
- instance->SetData(TYPE_FREE_NPC, DONE);
+ instance->SetData(TYPE_FREE_NPC, DONE);
break;
case 13:
if (me->GetEntry() != NPC_ASH)
@@ -158,7 +157,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_arugal_voidwalkerAI(creature);
+ return GetInstanceAI<npc_arugal_voidwalkerAI>(creature);
}
struct npc_arugal_voidwalkerAI : public ScriptedAI
@@ -196,8 +195,7 @@ public:
void JustDied(Unit* /*killer*/) OVERRIDE
{
- if (instance)
- instance->SetData(TYPE_FENRUS, instance->GetData(TYPE_FENRUS) + 1);
+ instance->SetData(TYPE_FENRUS, instance->GetData(TYPE_FENRUS) + 1);
}
};
diff --git a/src/server/scripts/EasternKingdoms/Stratholme/boss_baron_rivendare.cpp b/src/server/scripts/EasternKingdoms/Stratholme/boss_baron_rivendare.cpp
index 16ec442d963..b6e7f850a0c 100644
--- a/src/server/scripts/EasternKingdoms/Stratholme/boss_baron_rivendare.cpp
+++ b/src/server/scripts/EasternKingdoms/Stratholme/boss_baron_rivendare.cpp
@@ -68,7 +68,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_baron_rivendareAI(creature);
+ return GetInstanceAI<boss_baron_rivendareAI>(creature);
}
struct boss_baron_rivendareAI : public ScriptedAI
@@ -99,8 +99,8 @@ public:
void AttackStart(Unit* who) OVERRIDE
{
- if (instance)//can't use entercombat(), boss' dmg aura sets near players in combat, before entering the room's door
- instance->SetData(TYPE_BARON, IN_PROGRESS);
+ //can't use entercombat(), boss' dmg aura sets near players in combat, before entering the room's door
+ instance->SetData(TYPE_BARON, IN_PROGRESS);
ScriptedAI::AttackStart(who);
}
@@ -110,11 +110,10 @@ public:
summoned->AI()->AttackStart(target);
}
- void JustDied(Unit* /*killer*/) OVERRIDE
- {
- if (instance)
- instance->SetData(TYPE_BARON, DONE);
- }
+ void JustDied(Unit* /*killer*/) OVERRIDE
+ {
+ instance->SetData(TYPE_BARON, DONE);
+ }
void UpdateAI(uint32 diff) OVERRIDE
{
diff --git a/src/server/scripts/EasternKingdoms/Stratholme/boss_baroness_anastari.cpp b/src/server/scripts/EasternKingdoms/Stratholme/boss_baroness_anastari.cpp
index 1812e2efd8d..5cfa3766e1c 100644
--- a/src/server/scripts/EasternKingdoms/Stratholme/boss_baroness_anastari.cpp
+++ b/src/server/scripts/EasternKingdoms/Stratholme/boss_baroness_anastari.cpp
@@ -42,7 +42,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_baroness_anastariAI(creature);
+ return GetInstanceAI<boss_baroness_anastariAI>(creature);
}
struct boss_baroness_anastariAI : public ScriptedAI
@@ -71,11 +71,10 @@ public:
{
}
- void JustDied(Unit* /*killer*/) OVERRIDE
- {
- if (instance)
- instance->SetData(TYPE_BARONESS, IN_PROGRESS);
- }
+ void JustDied(Unit* /*killer*/) OVERRIDE
+ {
+ instance->SetData(TYPE_BARONESS, IN_PROGRESS);
+ }
void UpdateAI(uint32 diff) OVERRIDE
{
diff --git a/src/server/scripts/EasternKingdoms/Stratholme/boss_dathrohan_balnazzar.cpp b/src/server/scripts/EasternKingdoms/Stratholme/boss_dathrohan_balnazzar.cpp
index 5847f7b132b..951cb8e2659 100644
--- a/src/server/scripts/EasternKingdoms/Stratholme/boss_dathrohan_balnazzar.cpp
+++ b/src/server/scripts/EasternKingdoms/Stratholme/boss_dathrohan_balnazzar.cpp
@@ -162,7 +162,7 @@ public:
//BalnazzarTransform
if (HealthBelowPct(40))
{
- if (me->IsNonMeleeSpellCasted(false))
+ if (me->IsNonMeleeSpellCast(false))
me->InterruptNonMeleeSpells(false);
//restore hp, mana and stun
diff --git a/src/server/scripts/EasternKingdoms/Stratholme/boss_maleki_the_pallid.cpp b/src/server/scripts/EasternKingdoms/Stratholme/boss_maleki_the_pallid.cpp
index 0f8340891a8..daa5e754d17 100644
--- a/src/server/scripts/EasternKingdoms/Stratholme/boss_maleki_the_pallid.cpp
+++ b/src/server/scripts/EasternKingdoms/Stratholme/boss_maleki_the_pallid.cpp
@@ -43,7 +43,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_maleki_the_pallidAI(creature);
+ return GetInstanceAI<boss_maleki_the_pallidAI>(creature);
}
struct boss_maleki_the_pallidAI : public ScriptedAI
@@ -72,8 +72,7 @@ public:
void JustDied(Unit* /*killer*/) OVERRIDE
{
- if (instance)
- instance->SetData(TYPE_PALLID, IN_PROGRESS);
+ instance->SetData(TYPE_PALLID, IN_PROGRESS);
}
void UpdateAI(uint32 diff) OVERRIDE
diff --git a/src/server/scripts/EasternKingdoms/Stratholme/boss_nerubenkan.cpp b/src/server/scripts/EasternKingdoms/Stratholme/boss_nerubenkan.cpp
index 2cacf80e27c..0a73e0ea47a 100644
--- a/src/server/scripts/EasternKingdoms/Stratholme/boss_nerubenkan.cpp
+++ b/src/server/scripts/EasternKingdoms/Stratholme/boss_nerubenkan.cpp
@@ -42,7 +42,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_nerubenkanAI(creature);
+ return GetInstanceAI<boss_nerubenkanAI>(creature);
}
struct boss_nerubenkanAI : public ScriptedAI
@@ -73,8 +73,7 @@ public:
void JustDied(Unit* /*killer*/) OVERRIDE
{
- if (instance)
- instance->SetData(TYPE_NERUB, IN_PROGRESS);
+ instance->SetData(TYPE_NERUB, IN_PROGRESS);
}
void RaiseUndeadScarab(Unit* victim)
diff --git a/src/server/scripts/EasternKingdoms/Stratholme/boss_order_of_silver_hand.cpp b/src/server/scripts/EasternKingdoms/Stratholme/boss_order_of_silver_hand.cpp
index 706c2e7b6fb..7a3200bd168 100644
--- a/src/server/scripts/EasternKingdoms/Stratholme/boss_order_of_silver_hand.cpp
+++ b/src/server/scripts/EasternKingdoms/Stratholme/boss_order_of_silver_hand.cpp
@@ -58,7 +58,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_silver_hand_bossesAI(creature);
+ return GetInstanceAI<boss_silver_hand_bossesAI>(creature);
}
struct boss_silver_hand_bossesAI : public ScriptedAI
@@ -78,26 +78,23 @@ public:
HolyLight_Timer = 20000;
DivineShield_Timer = 20000;
- if (instance)
+ switch (me->GetEntry())
{
- switch (me->GetEntry())
- {
- case SH_AELMAR:
- instance->SetData(TYPE_SH_AELMAR, 0);
- break;
- case SH_CATHELA:
- instance->SetData(TYPE_SH_CATHELA, 0);
- break;
- case SH_GREGOR:
- instance->SetData(TYPE_SH_GREGOR, 0);
- break;
- case SH_NEMAS:
- instance->SetData(TYPE_SH_NEMAS, 0);
- break;
- case SH_VICAR:
- instance->SetData(TYPE_SH_VICAR, 0);
- break;
- }
+ case SH_AELMAR:
+ instance->SetData(TYPE_SH_AELMAR, 0);
+ break;
+ case SH_CATHELA:
+ instance->SetData(TYPE_SH_CATHELA, 0);
+ break;
+ case SH_GREGOR:
+ instance->SetData(TYPE_SH_GREGOR, 0);
+ break;
+ case SH_NEMAS:
+ instance->SetData(TYPE_SH_NEMAS, 0);
+ break;
+ case SH_VICAR:
+ instance->SetData(TYPE_SH_VICAR, 0);
+ break;
}
}
@@ -107,9 +104,6 @@ public:
void JustDied(Unit* killer) OVERRIDE
{
- if (!instance)
- return;
-
switch (me->GetEntry())
{
case SH_AELMAR:
diff --git a/src/server/scripts/EasternKingdoms/Stratholme/boss_ramstein_the_gorger.cpp b/src/server/scripts/EasternKingdoms/Stratholme/boss_ramstein_the_gorger.cpp
index 79b8dd7dfe2..91e7ed222c7 100644
--- a/src/server/scripts/EasternKingdoms/Stratholme/boss_ramstein_the_gorger.cpp
+++ b/src/server/scripts/EasternKingdoms/Stratholme/boss_ramstein_the_gorger.cpp
@@ -45,7 +45,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_ramstein_the_gorgerAI(creature);
+ return GetInstanceAI<boss_ramstein_the_gorgerAI>(creature);
}
struct boss_ramstein_the_gorgerAI : public ScriptedAI
@@ -78,8 +78,7 @@ public:
mob->AI()->AttackStart(me->SelectNearestTarget(100.0f));
}
- if (instance)
- instance->SetData(TYPE_RAMSTEIN, DONE);
+ instance->SetData(TYPE_RAMSTEIN, DONE);
}
void UpdateAI(uint32 diff) OVERRIDE
diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_eredar_twins.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_eredar_twins.cpp
index 37dda5a969a..d80196f79ee 100644
--- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_eredar_twins.cpp
+++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_eredar_twins.cpp
@@ -217,7 +217,7 @@ public:
{
if (ConflagrationTimer <= diff)
{
- if (!me->IsNonMeleeSpellCasted(false))
+ if (!me->IsNonMeleeSpellCast(false))
{
me->InterruptSpell(CURRENT_GENERIC_SPELL);
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
@@ -230,7 +230,7 @@ public:
{
if (ShadownovaTimer <= diff)
{
- if (!me->IsNonMeleeSpellCasted(false))
+ if (!me->IsNonMeleeSpellCast(false))
{
Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0);
if (target)
@@ -249,7 +249,7 @@ public:
if (ConfoundingblowTimer <= diff)
{
- if (!me->IsNonMeleeSpellCasted(false))
+ if (!me->IsNonMeleeSpellCast(false))
{
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
DoCast(target, SPELL_CONFOUNDING_BLOW);
@@ -276,7 +276,7 @@ public:
if (ShadowbladesTimer <= diff)
{
- if (!me->IsNonMeleeSpellCasted(false))
+ if (!me->IsNonMeleeSpellCast(false))
{
DoCast(me, SPELL_SHADOW_BLADES);
ShadowbladesTimer = 10000;
@@ -291,7 +291,7 @@ public:
Enraged = true;
} else EnrageTimer -= diff;
- if (me->isAttackReady() && !me->IsNonMeleeSpellCasted(false))
+ if (me->isAttackReady() && !me->IsNonMeleeSpellCast(false))
{
//If we are within range melee the target
if (me->IsWithinMeleeRange(me->GetVictim()))
@@ -548,7 +548,7 @@ public:
{
if (ShadownovaTimer <= diff)
{
- if (!me->IsNonMeleeSpellCasted(false))
+ if (!me->IsNonMeleeSpellCast(false))
{
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
DoCast(target, SPELL_SHADOW_NOVA);
@@ -560,7 +560,7 @@ public:
{
if (ConflagrationTimer <= diff)
{
- if (!me->IsNonMeleeSpellCasted(false))
+ if (!me->IsNonMeleeSpellCast(false))
{
me->InterruptSpell(CURRENT_GENERIC_SPELL);
Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0);
@@ -582,7 +582,7 @@ public:
if (FlamesearTimer <= diff)
{
- if (!me->IsNonMeleeSpellCasted(false))
+ if (!me->IsNonMeleeSpellCast(false))
{
DoCast(me, SPELL_FLAME_SEAR);
FlamesearTimer = 15000;
@@ -591,7 +591,7 @@ public:
if (PyrogenicsTimer <= diff)
{
- if (!me->IsNonMeleeSpellCasted(false))
+ if (!me->IsNonMeleeSpellCast(false))
{
DoCast(me, SPELL_PYROGENICS, true);
PyrogenicsTimer = 15000;
@@ -600,7 +600,7 @@ public:
if (BlazeTimer <= diff)
{
- if (!me->IsNonMeleeSpellCasted(false))
+ if (!me->IsNonMeleeSpellCast(false))
{
DoCastVictim(SPELL_BLAZE);
BlazeTimer = 3800;
@@ -691,7 +691,7 @@ public:
if (DarkstrikeTimer <= diff)
{
- if (!me->IsNonMeleeSpellCasted(false))
+ if (!me->IsNonMeleeSpellCast(false))
{
//If we are within range melee the target
if (me->IsWithinMeleeRange(me->GetVictim()))
diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp
index 80b4b98b0a4..a52c008a16c 100644
--- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp
+++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp
@@ -404,7 +404,7 @@ public:
events.Update(diff);
- if (me->IsNonMeleeSpellCasted(false))
+ if (me->IsNonMeleeSpellCast(false))
return;
if (phase == PHASE_GROUND)
diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp
index 28f4bae9f0f..70331a87ab0 100644
--- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp
+++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp
@@ -441,7 +441,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_kalecAI(creature);
+ return GetInstanceAI<boss_kalecAI>(creature);
}
struct boss_kalecAI : public ScriptedAI
@@ -464,8 +464,7 @@ public:
void Reset() OVERRIDE
{
- if (instance)
- SathGUID = instance->GetData64(DATA_SATHROVARR);
+ SathGUID = instance->GetData64(DATA_SATHROVARR);
RevitalizeTimer = 5000;
HeroicStrikeTimer = 3000;
@@ -575,7 +574,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_sathrovarrAI(creature);
+ return GetInstanceAI<boss_sathrovarrAI>(creature);
}
struct boss_sathrovarrAI : public ScriptedAI
@@ -605,11 +604,8 @@ public:
{
me->SetFullHealth();//dunno why it does not resets health at evade..
me->setActive(true);
- if (instance)
- {
- KalecgosGUID = instance->GetData64(DATA_KALECGOS_DRAGON);
- instance->SetBossState(DATA_KALECGOS, NOT_STARTED);
- }
+ KalecgosGUID = instance->GetData64(DATA_KALECGOS_DRAGON);
+ instance->SetBossState(DATA_KALECGOS, NOT_STARTED);
if (KalecGUID)
{
if (Creature* Kalec = ObjectAccessor::GetCreature(*me, KalecGUID))
@@ -674,8 +670,7 @@ public:
CAST_AI(boss_kalecgos::boss_kalecgosAI, Kalecgos->AI())->isFriendly = true;
}
- if (instance)
- instance->SetBossState(DATA_KALECGOS, DONE);
+ instance->SetBossState(DATA_KALECGOS, DONE);
}
void TeleportAllPlayersBack()
diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kiljaeden.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kiljaeden.cpp
index b3982200a10..c949e4d103d 100644
--- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kiljaeden.cpp
+++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kiljaeden.cpp
@@ -236,7 +236,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_kalecgos_kjAI(creature);
+ return GetInstanceAI<boss_kalecgos_kjAI>(creature);
}
struct boss_kalecgos_kjAI : public ScriptedAI
@@ -265,9 +265,6 @@ public:
GameObject* GetOrb(int32 index)
{
- if (!instance)
- return NULL;
-
switch (index)
{
case 0:
@@ -389,7 +386,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_kiljaeden_controllerAI(creature);
+ return GetInstanceAI<npc_kiljaeden_controllerAI>(creature);
}
struct npc_kiljaeden_controllerAI : public ScriptedAI
@@ -424,9 +421,8 @@ public:
{
phase = PHASE_DECEIVERS;
- if (instance)
- if (Creature* pKalecKJ = ObjectAccessor::GetCreature((*me), instance->GetData64(DATA_KALECGOS_KJ)))
- CAST_AI(boss_kalecgos_kj::boss_kalecgos_kjAI, pKalecKJ->AI())->ResetOrbs();
+ if (Creature* pKalecKJ = ObjectAccessor::GetCreature((*me), instance->GetData64(DATA_KALECGOS_KJ)))
+ CAST_AI(boss_kalecgos_kj::boss_kalecgos_kjAI, pKalecKJ->AI())->ResetOrbs();
deceiverDeathCount = 0;
bSummonedDeceivers = false;
bKiljaedenDeath = false;
@@ -710,7 +706,7 @@ public:
SpeechTimer += diff;
break;
case TIMER_SOUL_FLAY:
- if (!me->IsNonMeleeSpellCasted(false))
+ if (!me->IsNonMeleeSpellCast(false))
{
DoCastVictim(SPELL_SOUL_FLAY_SLOW, false);
DoCastVictim(SPELL_SOUL_FLAY, false);
@@ -718,7 +714,7 @@ public:
}
break;
case TIMER_LEGION_LIGHTNING:
- if (!me->IsNonMeleeSpellCasted(false))
+ if (!me->IsNonMeleeSpellCast(false))
{
Unit* pRandomPlayer = NULL;
@@ -740,7 +736,7 @@ public:
}
break;
case TIMER_FIRE_BLOOM:
- if (!me->IsNonMeleeSpellCasted(false))
+ if (!me->IsNonMeleeSpellCast(false))
{
me->RemoveAurasDueToSpell(SPELL_SOUL_FLAY);
DoCastAOE(SPELL_FIRE_BLOOM, false);
@@ -760,7 +756,7 @@ public:
Timer[TIMER_SOUL_FLAY] = 2000;
break;
case TIMER_SHADOW_SPIKE: //Phase 3
- if (!me->IsNonMeleeSpellCasted(false))
+ if (!me->IsNonMeleeSpellCast(false))
{
CastSinisterReflection();
DoCastAOE(SPELL_SHADOW_SPIKE, false);
@@ -774,7 +770,7 @@ public:
Timer[TIMER_FLAME_DART] = 3000; /// @todo Timer
break;
case TIMER_DARKNESS: //Phase 3
- if (!me->IsNonMeleeSpellCasted(false))
+ if (!me->IsNonMeleeSpellCast(false))
{
// Begins to channel for 8 seconds, then deals 50'000 damage to all raid members.
if (!IsInDarkness)
@@ -927,9 +923,6 @@ public:
void JustDied(Unit* /*killer*/) OVERRIDE
{
- if (!instance)
- return;
-
if (Creature* pControl = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_KILJAEDEN_CONTROLLER)))
++(CAST_AI(npc_kiljaeden_controller::npc_kiljaeden_controllerAI, pControl->AI())->deceiverDeathCount);
}
@@ -1150,7 +1143,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_shield_orbAI(creature);
+ return GetInstanceAI<npc_shield_orbAI>(creature);
}
struct npc_shield_orbAI : public ScriptedAI
diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_muru.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_muru.cpp
index 8da162bae14..5d525103d5c 100644
--- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_muru.cpp
+++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_muru.cpp
@@ -371,7 +371,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_muru_portalAI(creature);
+ return GetInstanceAI<npc_muru_portalAI>(creature);
}
struct npc_muru_portalAI : public ScriptedAI
@@ -405,9 +405,8 @@ public:
void JustSummoned(Creature* summoned) OVERRIDE
{
- if (instance)
- if (Player* Target = ObjectAccessor::GetPlayer(*me, instance->GetData64(DATA_PLAYER_GUID)))
- summoned->AI()->AttackStart(Target);
+ if (Player* Target = ObjectAccessor::GetPlayer(*me, instance->GetData64(DATA_PLAYER_GUID)))
+ summoned->AI()->AttackStart(Target);
Summons.Summon(summoned);
}
@@ -571,7 +570,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_blackholeAI(creature);
+ return GetInstanceAI<npc_blackholeAI>(creature);
}
struct npc_blackholeAI : public ScriptedAI
@@ -593,6 +592,7 @@ public:
DespawnTimer = 15000;
SpellTimer = 5000;
Phase = 0;
+ NeedForAHack = 0;
me->AddUnitState(UNIT_STATE_STUNNED);
DoCastAOE(SPELL_BLACKHOLE_SPAWN, true);
diff --git a/src/server/scripts/EasternKingdoms/Uldaman/boss_archaedas.cpp b/src/server/scripts/EasternKingdoms/Uldaman/boss_archaedas.cpp
index 69ee53f0762..726b9ea31a2 100644
--- a/src/server/scripts/EasternKingdoms/Uldaman/boss_archaedas.cpp
+++ b/src/server/scripts/EasternKingdoms/Uldaman/boss_archaedas.cpp
@@ -86,8 +86,7 @@ class boss_archaedas : public CreatureScript
bGuardiansAwake = false;
bVaultWalkersAwake = false;
- if (instance)
- instance->SetData(0, 5); // respawn any dead minions
+ instance->SetData(0, 5); // respawn any dead minions
me->setFaction(35);
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE);
@@ -132,8 +131,6 @@ class boss_archaedas : public CreatureScript
void UpdateAI(uint32 uiDiff) OVERRIDE
{
- if (!instance)
- return;
// we're still doing awaken animation
if (bWakingUp && iAwakenTimer >= 0)
{
@@ -196,17 +193,14 @@ class boss_archaedas : public CreatureScript
void JustDied (Unit* /*killer*/)
{
- if (instance)
- {
- instance->SetData(DATA_ANCIENT_DOOR, DONE); // open the vault door
- instance->SetData(DATA_MINIONS, SPECIAL); // deactivate his minions
- }
+ instance->SetData(DATA_ANCIENT_DOOR, DONE); // open the vault door
+ instance->SetData(DATA_MINIONS, SPECIAL); // deactivate his minions
}
};
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_archaedasAI(creature);
+ return GetInstanceAI<boss_archaedasAI>(creature);
}
};
@@ -305,7 +299,7 @@ class npc_archaedas_minions : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_archaedas_minionsAI(creature);
+ return GetInstanceAI<npc_archaedas_minionsAI>(creature);
}
};
@@ -361,14 +355,13 @@ class npc_stonekeepers : public CreatureScript
void JustDied(Unit* /*attacker*/) OVERRIDE
{
DoCast (me, SPELL_SELF_DESTRUCT, true);
- if (instance)
- instance->SetData(DATA_STONE_KEEPERS, IN_PROGRESS); // activate next stonekeeper
+ instance->SetData(DATA_STONE_KEEPERS, IN_PROGRESS); // activate next stonekeeper
}
};
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_stonekeepersAI(creature);
+ return GetInstanceAI<npc_stonekeepersAI>(creature);
}
};
diff --git a/src/server/scripts/EasternKingdoms/Uldaman/boss_ironaya.cpp b/src/server/scripts/EasternKingdoms/Uldaman/boss_ironaya.cpp
index 830942ae2c3..8ab31cc08fa 100644
--- a/src/server/scripts/EasternKingdoms/Uldaman/boss_ironaya.cpp
+++ b/src/server/scripts/EasternKingdoms/Uldaman/boss_ironaya.cpp
@@ -48,14 +48,14 @@ class boss_ironaya : public CreatureScript
boss_ironayaAI(Creature* creature) : ScriptedAI(creature) { }
uint32 uiArcingTimer;
- bool bHasCastedWstomp;
- bool bHasCastedKnockaway;
+ bool bHasCastWstomp;
+ bool bHasCastKnockaway;
void Reset() OVERRIDE
{
uiArcingTimer = 3000;
- bHasCastedKnockaway = false;
- bHasCastedWstomp = false;
+ bHasCastKnockaway = false;
+ bHasCastWstomp = false;
}
void EnterCombat(Unit* /*who*/) OVERRIDE
@@ -70,7 +70,7 @@ class boss_ironaya : public CreatureScript
return;
//If we are <50% hp do knockaway ONCE
- if (!bHasCastedKnockaway && HealthBelowPct(50))
+ if (!bHasCastKnockaway && HealthBelowPct(50))
{
DoCastVictim(SPELL_KNOCKAWAY, true);
@@ -84,7 +84,7 @@ class boss_ironaya : public CreatureScript
me->TauntApply(target);
//Shouldn't cast this agian
- bHasCastedKnockaway = true;
+ bHasCastKnockaway = true;
}
//uiArcingTimer
@@ -94,10 +94,10 @@ class boss_ironaya : public CreatureScript
uiArcingTimer = 13000;
} else uiArcingTimer -= uiDiff;
- if (!bHasCastedWstomp && HealthBelowPct(25))
+ if (!bHasCastWstomp && HealthBelowPct(25))
{
DoCast(me, SPELL_WSTOMP);
- bHasCastedWstomp = true;
+ bHasCastWstomp = true;
}
DoMeleeAttackIfReady();
diff --git a/src/server/scripts/EasternKingdoms/ZulAman/boss_akilzon.cpp b/src/server/scripts/EasternKingdoms/ZulAman/boss_akilzon.cpp
index 386b8818d5f..415b04f34c6 100644
--- a/src/server/scripts/EasternKingdoms/ZulAman/boss_akilzon.cpp
+++ b/src/server/scripts/EasternKingdoms/ZulAman/boss_akilzon.cpp
@@ -56,10 +56,10 @@ class boss_akilzon : public CreatureScript
_JustDied();
}
- void KilledUnit(Unit* victim) OVERRIDE
+ void KilledUnit(Unit* who) OVERRIDE
{
- if (victim->GetTypeId() == TYPEID_PLAYER)
- Talk(SAY_PLAYER_KILL);
+ if (who->GetTypeId() == TYPEID_PLAYER)
+ Talk(SAY_KILL);
}
void UpdateAI(uint32 diff) OVERRIDE
@@ -88,7 +88,7 @@ class boss_akilzon : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return GetZulAmanAI<boss_akilzonAI>(creature);
+ return GetInstanceAI<boss_akilzonAI>(creature);
}
};
diff --git a/src/server/scripts/EasternKingdoms/ZulAman/boss_hexlord.cpp b/src/server/scripts/EasternKingdoms/ZulAman/boss_hexlord.cpp
index 8d9d1b5d5aa..d9f05d929ed 100644
--- a/src/server/scripts/EasternKingdoms/ZulAman/boss_hexlord.cpp
+++ b/src/server/scripts/EasternKingdoms/ZulAman/boss_hexlord.cpp
@@ -100,7 +100,7 @@ class boss_hexlord_malacrass : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return GetZulAmanAI<boss_hex_lord_malacrassAI>(creature);
+ return GetInstanceAI<boss_hex_lord_malacrassAI>(creature);
}
};
diff --git a/src/server/scripts/EasternKingdoms/ZulAman/boss_janalai.cpp b/src/server/scripts/EasternKingdoms/ZulAman/boss_janalai.cpp
index 861c2921cd3..b233e8ae542 100644
--- a/src/server/scripts/EasternKingdoms/ZulAman/boss_janalai.cpp
+++ b/src/server/scripts/EasternKingdoms/ZulAman/boss_janalai.cpp
@@ -97,7 +97,7 @@ class boss_janalai : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return GetZulAmanAI<boss_janalaiAI>(creature);
+ return GetInstanceAI<boss_janalaiAI>(creature);
}
};
diff --git a/src/server/scripts/EasternKingdoms/ZulAman/boss_nalorakk.cpp b/src/server/scripts/EasternKingdoms/ZulAman/boss_nalorakk.cpp
index fe7f99cebe9..59809c13a71 100644
--- a/src/server/scripts/EasternKingdoms/ZulAman/boss_nalorakk.cpp
+++ b/src/server/scripts/EasternKingdoms/ZulAman/boss_nalorakk.cpp
@@ -102,7 +102,7 @@ class boss_nalorakk : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_nalorakkAI(creature);
+ return GetInstanceAI<boss_nalorakkAI>(creature);
}
};
diff --git a/src/server/scripts/EasternKingdoms/ZulAman/zulaman.cpp b/src/server/scripts/EasternKingdoms/ZulAman/zulaman.cpp
index 26cd58ab296..5f2729e9c4d 100644
--- a/src/server/scripts/EasternKingdoms/ZulAman/zulaman.cpp
+++ b/src/server/scripts/EasternKingdoms/ZulAman/zulaman.cpp
@@ -126,7 +126,6 @@ class npc_voljin_zulaman : public CreatureScript
void UpdateAI(uint32 diff) OVERRIDE
{
_events.Update(diff);
-
while (uint32 eventId = _events.ExecuteEvent())
{
switch (eventId)
@@ -214,7 +213,7 @@ class npc_voljin_zulaman : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return GetZulAmanAI<npc_voljin_zulamanAI>(creature);
+ return GetInstanceAI<npc_voljin_zulamanAI>(creature);
}
};
diff --git a/src/server/scripts/EasternKingdoms/zone_arathi_highlands.cpp b/src/server/scripts/EasternKingdoms/zone_arathi_highlands.cpp
index d7d9934d69e..f12ac196aca 100644
--- a/src/server/scripts/EasternKingdoms/zone_arathi_highlands.cpp
+++ b/src/server/scripts/EasternKingdoms/zone_arathi_highlands.cpp
@@ -39,17 +39,16 @@ EndContentData */
enum ProfessorPhizzlethorpe
{
// Yells
- SAY_PROGRESS_1 = 0,
- SAY_PROGRESS_2 = 1,
- SAY_PROGRESS_3 = 2,
- EMOTE_PROGRESS_4 = 3,
- SAY_AGGRO = 4,
- SAY_PROGRESS_5 = 5,
- SAY_PROGRESS_6 = 6,
- SAY_PROGRESS_7 = 7,
- EMOTE_PROGRESS_8 = 8,
- SAY_PROGRESS_9 = 9,
-
+ SAY_PROGRESS_1 = 0,
+ SAY_PROGRESS_2 = 1,
+ SAY_PROGRESS_3 = 2,
+ EMOTE_PROGRESS_4 = 3,
+ SAY_AGGRO = 4,
+ SAY_PROGRESS_5 = 5,
+ SAY_PROGRESS_6 = 6,
+ SAY_PROGRESS_7 = 7,
+ EMOTE_PROGRESS_8 = 8,
+ SAY_PROGRESS_9 = 9,
EVENT_SAY_3 = 1,
EVENT_SAY_6 = 2,
EVENT_SAY_8 = 3,
@@ -57,19 +56,15 @@ enum ProfessorPhizzlethorpe
// Quests
QUEST_SUNKEN_TREASURE = 665,
QUEST_GOGGLE_BOGGLE = 26050,
-
// Creatures
- NPC_VENGEFUL_SURGE = 2776
+ NPC_VENGEFUL_SURGE = 2776,
+ FACTION_SUNKEN_TREASURE = 113
};
class npc_professor_phizzlethorpe : public CreatureScript
{
public:
-
- npc_professor_phizzlethorpe()
- : CreatureScript("npc_professor_phizzlethorpe")
- {
- }
+ npc_professor_phizzlethorpe() : CreatureScript("npc_professor_phizzlethorpe") { }
struct npc_professor_phizzlethorpeAI : public npc_escortAI
{
@@ -113,6 +108,16 @@ class npc_professor_phizzlethorpe : public CreatureScript
Talk(SAY_AGGRO);
}
+ void sQuestAccept(Player* player, Quest const* quest)
+ {
+ if (quest->GetQuestId() == QUEST_SUNKEN_TREASURE)
+ {
+ Talk(SAY_PROGRESS_1, player);
+ npc_escortAI::Start(false, false, player->GetGUID(), quest);
+ me->setFaction(FACTION_SUNKEN_TREASURE);
+ }
+ }
+
void UpdateAI(uint32 diff) OVERRIDE
{
Player* player = GetPlayerForEscort();
@@ -145,23 +150,10 @@ class npc_professor_phizzlethorpe : public CreatureScript
EventMap events;
};
- CreatureAI* GetAI(Creature* creature) const OVERRIDE
- {
- return new npc_professor_phizzlethorpeAI(creature);
- }
-
- bool OnQuestAccept(Player* player, Creature* creature, Quest const* quest) OVERRIDE
- {
- if (quest->GetQuestId() == QUEST_GOGGLE_BOGGLE)
- {
- creature->AI()->Talk(SAY_PROGRESS_1, player);
- if (npc_escortAI* pEscortAI = CAST_AI(npc_professor_phizzlethorpeAI, (creature->AI())))
- pEscortAI->Start(false, false, player->GetGUID(), quest);
-
- creature->setFaction(42);
- }
- return true;
- }
+ CreatureAI* GetAI(Creature* creature) const OVERRIDE
+ {
+ return new npc_professor_phizzlethorpeAI(creature);
+ }
};
void AddSC_arathi_highlands()
diff --git a/src/server/scripts/EasternKingdoms/zone_blasted_lands.cpp b/src/server/scripts/EasternKingdoms/zone_blasted_lands.cpp
index b102873e940..c212592d49b 100644
--- a/src/server/scripts/EasternKingdoms/zone_blasted_lands.cpp
+++ b/src/server/scripts/EasternKingdoms/zone_blasted_lands.cpp
@@ -1,6 +1,5 @@
/*
* Copyright (C) 2008-2013 TrinityCore <http://www.trinitycore.org/>
- * Copyright (C) 2006-2009 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
@@ -16,28 +15,26 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/* ScriptData
-SDName: Blasted_Lands
-SD%Complete: 90
-SDComment: Quest support: 3628. Teleporter to Rise of the Defiler missing group support.
-SDCategory: Blasted Lands
-EndScriptData */
+/*
+Blasted_Lands
+Quest support: 3628. Teleporter to Rise of the Defiler.
+*/
-/* ContentData
+/*
npc_deathly_usher
-EndContentData */
+*/
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "ScriptedGossip.h"
+#include "SpellScript.h"
#include "Player.h"
+#include "Group.h"
/*######
## npc_deathly_usher
######*/
-#define GOSSIP_ITEM_USHER "I wish to to visit the Rise of the Defiler."
-
enum DeathlyUsher
{
SPELL_TELEPORT_SINGLE = 12885,
@@ -50,30 +47,72 @@ class npc_deathly_usher : public CreatureScript
public:
npc_deathly_usher() : CreatureScript("npc_deathly_usher") { }
- bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action) OVERRIDE
+ struct npc_deathly_usherAI : public ScriptedAI
{
- player->PlayerTalkClass->ClearMenus();
- if (action == GOSSIP_ACTION_INFO_DEF)
+ npc_deathly_usherAI(Creature* creature) : ScriptedAI(creature) { }
+
+ void sGossipSelect(Player* player, uint32 /*sender*/, uint32 /*action*/) OVERRIDE
{
player->CLOSE_GOSSIP_MENU();
- creature->CastSpell(player, SPELL_TELEPORT_SINGLE, true);
+ me->CastSpell(player, SPELL_TELEPORT_GROUP, true);
}
+ };
- return true;
+ CreatureAI* GetAI(Creature* creature) const OVERRIDE
+ {
+ return new npc_deathly_usherAI(creature);
}
+};
- bool OnGossipHello(Player* player, Creature* creature) OVERRIDE
- {
- if (player->GetQuestStatus(3628) == QUEST_STATUS_INCOMPLETE && player->HasItemCount(10757))
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_USHER, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF);
+/*#####
+# spell_razelikh_teleport_group
+#####*/
+
+class spell_razelikh_teleport_group : public SpellScriptLoader
+{
+ public: spell_razelikh_teleport_group() : SpellScriptLoader("spell_razelikh_teleport_group") { }
+
+ class spell_razelikh_teleport_group_SpellScript : public SpellScript
+ {
+ PrepareSpellScript(spell_razelikh_teleport_group_SpellScript);
- player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID());
+ bool Validate(SpellInfo const* /*spell*/) OVERRIDE
+ {
+ if (!sSpellMgr->GetSpellInfo(SPELL_TELEPORT_SINGLE) && !sSpellMgr->GetSpellInfo(SPELL_TELEPORT_SINGLE_IN_GROUP))
+ return false;
+ return true;
+ }
- return true;
- }
+ void HandleScriptEffect(SpellEffIndex /* effIndex */)
+ {
+ if (Player* player = GetHitPlayer())
+ {
+ if (Group* group = player->GetGroup())
+ {
+ for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
+ if (Player* member = itr->GetSource())
+ if (member->IsWithinDistInMap(player, 20.0f) && !member->isDead())
+ member->CastSpell(member, SPELL_TELEPORT_SINGLE_IN_GROUP, true);
+ }
+ else
+ player->CastSpell(player, SPELL_TELEPORT_SINGLE, true);
+ }
+ }
+
+ void Register() OVERRIDE
+ {
+ OnEffectHitTarget += SpellEffectFn(spell_razelikh_teleport_group_SpellScript::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
+ }
+ };
+
+ SpellScript* GetSpellScript() const OVERRIDE
+ {
+ return new spell_razelikh_teleport_group_SpellScript();
+ }
};
void AddSC_blasted_lands()
{
new npc_deathly_usher();
+ new spell_razelikh_teleport_group();
}
diff --git a/src/server/scripts/EasternKingdoms/zone_burning_steppes.cpp b/src/server/scripts/EasternKingdoms/zone_burning_steppes.cpp
index e575965987c..fbb8db41fa5 100644
--- a/src/server/scripts/EasternKingdoms/zone_burning_steppes.cpp
+++ b/src/server/scripts/EasternKingdoms/zone_burning_steppes.cpp
@@ -23,6 +23,38 @@ SDComment:
SDCategory: Burning Steppes
EndScriptData */
+enum RaggedJohn
+{
+ QUEST_THE_TRUE_MASTERS = 4224,
+ QUEST_MOTHERS_MILK = 4866,
+ SPELL_MOTHERS_MILK = 16468,
+ SPELL_WICKED_MILKING = 16472
+};
+
+ struct npc_ragged_johnAI : public ScriptedAI
+ {
+ npc_ragged_johnAI(Creature* creature) : ScriptedAI(creature) { }
+
+ void Reset() OVERRIDE { }
+
+ void MoveInLineOfSight(Unit* who) OVERRIDE
+ {
+ if (who->HasAura(SPELL_MOTHERS_MILK))
+ {
+ if (who->GetTypeId() == TYPEID_PLAYER && me->IsWithinDistInMap(who, 15) && who->isInAccessiblePlaceFor(me))
+ {
+ DoCast(who, SPELL_WICKED_MILKING);
+ if (Player* player = who->ToPlayer())
+ player->AreaExploredOrEventHappens(QUEST_MOTHERS_MILK);
+ }
+ }
+
+ ScriptedAI::MoveInLineOfSight(who);
+ }
+
+ void EnterCombat(Unit* /*who*/) OVERRIDE { }
+ };
+
void AddSC_burning_steppes()
{
diff --git a/src/server/scripts/EasternKingdoms/zone_duskwood.cpp b/src/server/scripts/EasternKingdoms/zone_duskwood.cpp
index a7fa73fa4a5..7c9e33c98b7 100644
--- a/src/server/scripts/EasternKingdoms/zone_duskwood.cpp
+++ b/src/server/scripts/EasternKingdoms/zone_duskwood.cpp
@@ -27,81 +27,45 @@ EndScriptData */
#include "ScriptedCreature.h"
#include "Player.h"
-enum Yells
-{
- YELL_TWILIGHTCORRUPTOR_RESPAWN = 0,
- YELL_TWILIGHTCORRUPTOR_AGGRO = 1,
- YELL_TWILIGHTCORRUPTOR_KILL = 2,
-};
-
-
-/*######
-# at_twilight_grove
-######*/
-
-class at_twilight_grove : public AreaTriggerScript
+enum TwilightCorrupter
{
-public:
- at_twilight_grove() : AreaTriggerScript("at_twilight_grove") { }
+ ITEM_FRAGMENT = 21149,
+ NPC_TWILIGHT_CORRUPTER = 15625,
+ YELL_TWILIGHTCORRUPTOR_RESPAWN = 0,
+ YELL_TWILIGHTCORRUPTOR_AGGRO = 1,
+ YELL_TWILIGHTCORRUPTOR_KILL = 2,
+ SPELL_SOUL_CORRUPTION = 25805,
+ SPELL_CREATURE_OF_NIGHTMARE = 25806,
+ SPELL_LEVEL_UP = 24312,
- bool OnTrigger(Player* player, const AreaTriggerEntry* /*at*/) OVERRIDE
- {
- if (player->HasQuestForItem(21149))
- {
- if (Unit* TCorrupter = player->SummonCreature(15625, -10328.16f, -489.57f, 49.95f, 0, TEMPSUMMON_MANUAL_DESPAWN, 60000))
- {
- TCorrupter->setFaction(14);
- TCorrupter->SetMaxHealth(832750);
- }
- if (Creature* CorrupterSpeaker = player->SummonCreature(1, player->GetPositionX(), player->GetPositionY(), player->GetPositionZ()-1, 0, TEMPSUMMON_TIMED_DESPAWN, 15000))
- {
- CorrupterSpeaker->SetName("Twilight Corrupter");
- CorrupterSpeaker->SetVisible(true);
- CorrupterSpeaker->AI()->Talk(YELL_TWILIGHTCORRUPTOR_RESPAWN, player);
- }
- }
- return false;
- };
+ EVENT_SOUL_CORRUPTION = 1,
+ EVENT_CREATURE_OF_NIGHTMARE = 2,
+ FACTION_HOSTILE = 14
};
/*######
# boss_twilight_corrupter
######*/
-enum TwilightCorrupter
-{
- SPELL_SOUL_CORRUPTION = 25805,
- SPELL_CREATURE_OF_NIGHTMARE = 25806,
- SPELL_LEVEL_UP = 24312
-};
-
class boss_twilight_corrupter : public CreatureScript
{
public:
boss_twilight_corrupter() : CreatureScript("boss_twilight_corrupter") { }
- CreatureAI* GetAI(Creature* creature) const OVERRIDE
- {
- return new boss_twilight_corrupterAI(creature);
- }
-
struct boss_twilight_corrupterAI : public ScriptedAI
{
boss_twilight_corrupterAI(Creature* creature) : ScriptedAI(creature) { }
- uint32 SoulCorruption_Timer;
- uint32 CreatureOfNightmare_Timer;
- uint8 KillCount;
-
void Reset() OVERRIDE
{
- SoulCorruption_Timer = 15000;
- CreatureOfNightmare_Timer = 30000;
- KillCount = 0;
+ KillCount = 0;
}
+
void EnterCombat(Unit* /*who*/) OVERRIDE
{
Talk(YELL_TWILIGHTCORRUPTOR_AGGRO);
+ _events.ScheduleEvent(EVENT_SOUL_CORRUPTION, 15000);
+ _events.ScheduleEvent(EVENT_CREATURE_OF_NIGHTMARE, 30000);
}
void KilledUnit(Unit* victim) OVERRIDE
@@ -123,19 +87,63 @@ public:
{
if (!UpdateVictim())
return;
- if (SoulCorruption_Timer <= diff)
- {
- DoCastVictim(SPELL_SOUL_CORRUPTION);
- SoulCorruption_Timer = rand()%4000+15000; //gotta confirm Timers
- } else SoulCorruption_Timer-=diff;
- if (CreatureOfNightmare_Timer <= diff)
+ _events.Update(diff);
+
+ while (uint32 eventId = _events.ExecuteEvent())
{
- DoCastVictim(SPELL_CREATURE_OF_NIGHTMARE);
- CreatureOfNightmare_Timer = 45000; //gotta confirm Timers
- } else CreatureOfNightmare_Timer-=diff;
+ switch (eventId)
+ {
+ case EVENT_SOUL_CORRUPTION:
+ DoCastVictim(SPELL_SOUL_CORRUPTION);
+ _events.ScheduleEvent(EVENT_SOUL_CORRUPTION, rand()%4000+15000);
+ break;
+ case EVENT_CREATURE_OF_NIGHTMARE:
+ DoCastVictim(SPELL_CREATURE_OF_NIGHTMARE);
+ _events.ScheduleEvent(EVENT_CREATURE_OF_NIGHTMARE, 45000);
+ break;
+ default:
+ break;
+ }
+ }
DoMeleeAttackIfReady();
- };
+ }
+
+ private:
+ EventMap _events;
+ uint8 KillCount;
+ };
+
+ CreatureAI* GetAI(Creature* creature) const OVERRIDE
+ {
+ return new boss_twilight_corrupterAI(creature);
+ }
+};
+
+/*######
+# at_twilight_grove
+######*/
+
+class at_twilight_grove : public AreaTriggerScript
+{
+public:
+ at_twilight_grove() : AreaTriggerScript("at_twilight_grove") { }
+
+ bool OnTrigger(Player* player, const AreaTriggerEntry* /*at*/) OVERRIDE
+ {
+ if (player->HasQuestForItem(ITEM_FRAGMENT))
+ {
+ if (Unit* corrupter = player->SummonCreature(NPC_TWILIGHT_CORRUPTER, -10328.16f, -489.57f, 49.95f, 0, TEMPSUMMON_MANUAL_DESPAWN, 60000))
+ corrupter->setFaction(FACTION_HOSTILE);
+
+ if (Creature* CorrupterSpeaker = player->SummonCreature(1, player->GetPositionX(), player->GetPositionY(), player->GetPositionZ()-1, 0, TEMPSUMMON_TIMED_DESPAWN, 15000))
+ {
+ CorrupterSpeaker->SetName("Twilight Corrupter");
+ CorrupterSpeaker->SetVisible(true);
+ CorrupterSpeaker->AI()->Talk(YELL_TWILIGHTCORRUPTOR_RESPAWN, player);
+ }
+ }
+ return false;
};
};
diff --git a/src/server/scripts/EasternKingdoms/zone_ghostlands.cpp b/src/server/scripts/EasternKingdoms/zone_ghostlands.cpp
index bb7cab832df..450445fc9fc 100644
--- a/src/server/scripts/EasternKingdoms/zone_ghostlands.cpp
+++ b/src/server/scripts/EasternKingdoms/zone_ghostlands.cpp
@@ -24,7 +24,6 @@ SDCategory: Ghostlands
EndScriptData */
/* ContentData
-npc_rathis_tomber
npc_ranger_lilatha
EndContentData */
@@ -36,46 +35,12 @@ EndContentData */
#include "WorldSession.h"
/*######
-## npc_rathis_tomber
-######*/
-
-class npc_rathis_tomber : public CreatureScript
-{
-public:
- npc_rathis_tomber() : CreatureScript("npc_rathis_tomber") { }
-
- bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action) OVERRIDE
- {
- player->PlayerTalkClass->ClearMenus();
- if (action == GOSSIP_ACTION_TRADE)
- player->GetSession()->SendListInventory(creature->GetGUID());
- return true;
- }
-
- bool OnGossipHello(Player* player, Creature* creature) OVERRIDE
- {
- if (creature->IsQuestGiver())
- player->PrepareQuestMenu(creature->GetGUID());
-
- if (creature->IsVendor() && player->GetQuestRewardStatus(9152))
- {
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE);
- player->SEND_GOSSIP_MENU(8432, creature->GetGUID());
- }
- else
- player->SEND_GOSSIP_MENU(8431, creature->GetGUID());
-
- return true;
- }
-};
-/*######
## npc_ranger_lilatha
######*/
enum RangerLilatha
{
- // Yells
SAY_START = 0,
SAY_PROGRESS1 = 1,
SAY_PROGRESS2 = 2,
@@ -83,18 +48,12 @@ enum RangerLilatha
SAY_END1 = 4,
SAY_END2 = 5,
SAY_CAPTAIN_ANSWER = 0,
-
- // Quests
QUEST_ESCAPE_FROM_THE_CATACOMBS = 9212,
-
- // Gameobjects
GO_CAGE = 181152,
-
- // Creature
NPC_CAPTAIN_HELIOS = 16220,
-
- // Factions
- FACTION_SMOON_E = 1603
+ NPC_MUMMIFIED_HEADHUNTER = 16342,
+ NPC_SHADOWPINE_ORACLE = 16343,
+ FACTION_QUEST_ESCAPE = 113
};
class npc_ranger_lilatha : public CreatureScript
@@ -130,8 +89,8 @@ public:
case 18:
{
Talk(SAY_PROGRESS3, player);
- Creature* Summ1 = me->SummonCreature(16342, 7627.083984f, -7532.538086f, 152.128616f, 1.082733f, TEMPSUMMON_DEAD_DESPAWN, 0);
- Creature* Summ2 = me->SummonCreature(16343, 7620.432129f, -7532.550293f, 152.454865f, 0.827478f, TEMPSUMMON_DEAD_DESPAWN, 0);
+ Creature* Summ1 = me->SummonCreature(NPC_MUMMIFIED_HEADHUNTER, 7627.083984f, -7532.538086f, 152.128616f, 1.082733f, TEMPSUMMON_DEAD_DESPAWN, 0);
+ Creature* Summ2 = me->SummonCreature(NPC_SHADOWPINE_ORACLE, 7620.432129f, -7532.550293f, 152.454865f, 0.827478f, TEMPSUMMON_DEAD_DESPAWN, 0);
if (Summ1 && Summ2)
{
Summ1->Attack(me, true);
@@ -174,7 +133,7 @@ public:
{
if (quest->GetQuestId() == QUEST_ESCAPE_FROM_THE_CATACOMBS)
{
- creature->setFaction(113);
+ creature->setFaction(FACTION_QUEST_ESCAPE);
if (npc_escortAI* pEscortAI = CAST_AI(npc_ranger_lilatha::npc_ranger_lilathaAI, creature->AI()))
pEscortAI->Start(true, false, player->GetGUID());
@@ -191,6 +150,5 @@ public:
void AddSC_ghostlands()
{
- new npc_rathis_tomber();
new npc_ranger_lilatha();
}
diff --git a/src/server/scripts/EasternKingdoms/zone_hinterlands.cpp b/src/server/scripts/EasternKingdoms/zone_hinterlands.cpp
index d833ebc5820..c3512ed7f76 100644
--- a/src/server/scripts/EasternKingdoms/zone_hinterlands.cpp
+++ b/src/server/scripts/EasternKingdoms/zone_hinterlands.cpp
@@ -24,7 +24,7 @@ SDCategory: The Hinterlands
EndScriptData */
/* ContentData
-npc_00x09hl
+npc_oox09hl
EndContentData */
#include "ScriptMgr.h"
@@ -33,7 +33,7 @@ EndContentData */
#include "Player.h"
/*######
-## npc_00x09hl
+## npc_oox09hl
######*/
enum eOOX
@@ -43,50 +43,47 @@ enum eOOX
SAY_OOX_AMBUSH = 2,
SAY_OOX_AMBUSH_REPLY = 3,
SAY_OOX_END = 4,
-
QUEST_RESQUE_OOX_09 = 836,
-
NPC_MARAUDING_OWL = 7808,
NPC_VILE_AMBUSHER = 7809,
-
FACTION_ESCORTEE_A = 774,
FACTION_ESCORTEE_H = 775
};
-class npc_00x09hl : public CreatureScript
+class npc_oox09hl : public CreatureScript
{
public:
- npc_00x09hl() : CreatureScript("npc_00x09hl") { }
+ npc_oox09hl() : CreatureScript("npc_oox09hl") { }
- bool OnQuestAccept(Player* player, Creature* creature, const Quest* quest)
+ struct npc_oox09hlAI : public npc_escortAI
{
- if (quest->GetQuestId() == QUEST_RESQUE_OOX_09)
- {
- creature->SetStandState(UNIT_STAND_STATE_STAND);
+ npc_oox09hlAI(Creature* creature) : npc_escortAI(creature) { }
- if (player->GetTeam() == ALLIANCE)
- creature->setFaction(FACTION_ESCORTEE_A);
- else if (player->GetTeam() == HORDE)
- creature->setFaction(FACTION_ESCORTEE_H);
+ void Reset() OVERRIDE { }
- creature->AI()->Talk(SAY_OOX_START, player);
+ void EnterCombat(Unit* who) OVERRIDE
+ {
+ if (who->GetEntry() == NPC_MARAUDING_OWL || who->GetEntry() == NPC_VILE_AMBUSHER)
+ return;
- if (npc_00x09hlAI* pEscortAI = CAST_AI(npc_00x09hl::npc_00x09hlAI, creature->AI()))
- pEscortAI->Start(false, false, player->GetGUID(), quest);
+ Talk(SAY_OOX_AGGRO);
}
- return true;
- }
- CreatureAI* GetAI(Creature* creature) const OVERRIDE
- {
- return new npc_00x09hlAI(creature);
- }
-
- struct npc_00x09hlAI : public npc_escortAI
- {
- npc_00x09hlAI(Creature* creature) : npc_escortAI(creature) { }
+ void JustSummoned(Creature* summoned) OVERRIDE
+ {
+ summoned->GetMotionMaster()->MovePoint(0, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ());
+ }
- void Reset() OVERRIDE { }
+ void sQuestAccept(Player* player, Quest const* quest)
+ {
+ if (quest->GetQuestId() == QUEST_RESQUE_OOX_09)
+ {
+ me->SetStandState(UNIT_STAND_STATE_STAND);
+ me->setFaction(player->GetTeam() == ALLIANCE ? FACTION_ESCORTEE_A : FACTION_ESCORTEE_H);
+ Talk(SAY_OOX_START, player);
+ npc_escortAI::Start(false, false, player->GetGUID(), quest);
+ }
+ }
void WaypointReached(uint32 waypointId)
{
@@ -106,9 +103,9 @@ public:
}
}
- void WaypointStart(uint32 uiPointId)
+ void WaypointStart(uint32 pointId) OVERRIDE
{
- switch (uiPointId)
+ switch (pointId)
{
case 27:
for (uint8 i = 0; i < 3; ++i)
@@ -130,23 +127,15 @@ public:
break;
}
}
-
- void EnterCombat(Unit* who)
- {
- if (who->GetEntry() == NPC_MARAUDING_OWL || who->GetEntry() == NPC_VILE_AMBUSHER)
- return;
-
- Talk(SAY_OOX_AGGRO);
- }
-
- void JustSummoned(Creature* summoned) OVERRIDE
- {
- summoned->GetMotionMaster()->MovePoint(0, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ());
- }
};
+
+ CreatureAI* GetAI(Creature* creature) const OVERRIDE
+ {
+ return new npc_oox09hlAI(creature);
+ }
};
void AddSC_hinterlands()
{
- new npc_00x09hl();
+ new npc_oox09hl();
}
diff --git a/src/server/scripts/Examples/example_spell.cpp b/src/server/scripts/Examples/example_spell.cpp
index 2c76d9a40b0..af028d539f0 100644
--- a/src/server/scripts/Examples/example_spell.cpp
+++ b/src/server/scripts/Examples/example_spell.cpp
@@ -220,7 +220,7 @@ class spell_ex_66244 : public SpellScriptLoader
// we initialize local variables if needed
bool Load() OVERRIDE
{
- // do not load script if aura is casted by player or caster not avalible
+ // do not load script if aura is cast by player or caster not avalible
if (Unit* caster = GetCaster())
if (caster->GetTypeId() == TYPEID_PLAYER)
return true;
diff --git a/src/server/scripts/Kalimdor/BlackfathomDeeps/blackfathom_deeps.cpp b/src/server/scripts/Kalimdor/BlackfathomDeeps/blackfathom_deeps.cpp
index e74ed93bc66..ac1403a26ec 100644
--- a/src/server/scripts/Kalimdor/BlackfathomDeeps/blackfathom_deeps.cpp
+++ b/src/server/scripts/Kalimdor/BlackfathomDeeps/blackfathom_deeps.cpp
@@ -73,7 +73,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_blackfathom_deeps_eventAI(creature);
+ return GetInstanceAI<npc_blackfathom_deeps_eventAI>(creature);
}
struct npc_blackfathom_deeps_eventAI : public ScriptedAI
@@ -182,8 +182,7 @@ public:
void JustDied(Unit* /*killer*/) OVERRIDE
{
if (me->IsSummon()) //we are not a normal spawn.
- if (instance)
- instance->SetData(DATA_EVENT, instance->GetData(DATA_EVENT) + 1);
+ instance->SetData(DATA_EVENT, instance->GetData(DATA_EVENT) + 1);
}
};
};
diff --git a/src/server/scripts/Kalimdor/BlackfathomDeeps/boss_gelihast.cpp b/src/server/scripts/Kalimdor/BlackfathomDeeps/boss_gelihast.cpp
index 139eed963c1..55e28e3f19e 100644
--- a/src/server/scripts/Kalimdor/BlackfathomDeeps/boss_gelihast.cpp
+++ b/src/server/scripts/Kalimdor/BlackfathomDeeps/boss_gelihast.cpp
@@ -31,7 +31,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_gelihastAI(creature);
+ return GetInstanceAI<boss_gelihastAI>(creature);
}
struct boss_gelihastAI : public ScriptedAI
@@ -48,20 +48,17 @@ public:
void Reset() OVERRIDE
{
netTimer = urand(2000, 4000);
- if (instance)
- instance->SetData(TYPE_GELIHAST, NOT_STARTED);
+ instance->SetData(TYPE_GELIHAST, NOT_STARTED);
}
void EnterCombat(Unit* /*who*/) OVERRIDE
{
- if (instance)
- instance->SetData(TYPE_GELIHAST, IN_PROGRESS);
+ instance->SetData(TYPE_GELIHAST, IN_PROGRESS);
}
void JustDied(Unit* /*killer*/) OVERRIDE
{
- if (instance)
- instance->SetData(TYPE_GELIHAST, DONE);
+ instance->SetData(TYPE_GELIHAST, DONE);
}
void UpdateAI(uint32 diff) OVERRIDE
diff --git a/src/server/scripts/Kalimdor/BlackfathomDeeps/boss_kelris.cpp b/src/server/scripts/Kalimdor/BlackfathomDeeps/boss_kelris.cpp
index 8eeedb6e15f..e43ac0d4e7c 100644
--- a/src/server/scripts/Kalimdor/BlackfathomDeeps/boss_kelris.cpp
+++ b/src/server/scripts/Kalimdor/BlackfathomDeeps/boss_kelris.cpp
@@ -36,7 +36,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_kelrisAI(creature);
+ return GetInstanceAI<boss_kelrisAI>(creature);
}
struct boss_kelrisAI : public ScriptedAI
@@ -55,22 +55,19 @@ public:
{
mindBlastTimer = urand(2000, 5000);
sleepTimer = urand(9000, 12000);
- if (instance)
- instance->SetData(TYPE_KELRIS, NOT_STARTED);
+ instance->SetData(TYPE_KELRIS, NOT_STARTED);
}
void EnterCombat(Unit* /*who*/) OVERRIDE
{
Talk(SAY_AGGRO);
- if (instance)
- instance->SetData(TYPE_KELRIS, IN_PROGRESS);
+ instance->SetData(TYPE_KELRIS, IN_PROGRESS);
}
void JustDied(Unit* /*killer*/) OVERRIDE
{
Talk(SAY_DEATH);
- if (instance)
- instance->SetData(TYPE_KELRIS, DONE);
+ instance->SetData(TYPE_KELRIS, DONE);
}
void UpdateAI(uint32 diff) OVERRIDE
diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_anetheron.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_anetheron.cpp
index 52f706d5626..fa31628268b 100644
--- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_anetheron.cpp
+++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_anetheron.cpp
@@ -47,7 +47,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_anetheronAI(creature);
+ return GetInstanceAI<boss_anetheronAI>(creature);
}
struct boss_anetheronAI : public hyjal_trashAI
@@ -83,9 +83,10 @@ public:
Talk(SAY_ONAGGRO);
}
- void KilledUnit(Unit* /*victim*/) OVERRIDE
+ void KilledUnit(Unit* who) OVERRIDE
{
- Talk(SAY_ONSLAY);
+ if (who->GetTypeId() == TYPEID_PLAYER)
+ Talk(SAY_ONSLAY);
}
void WaypointReached(uint32 waypointId) OVERRIDE
@@ -115,19 +116,16 @@ public:
if (!go)
{
go = true;
- if (instance)
- {
- AddWaypoint(0, 4896.08f, -1576.35f, 1333.65f);
- AddWaypoint(1, 4898.68f, -1615.02f, 1329.48f);
- AddWaypoint(2, 4907.12f, -1667.08f, 1321.00f);
- AddWaypoint(3, 4963.18f, -1699.35f, 1340.51f);
- AddWaypoint(4, 4989.16f, -1716.67f, 1335.74f);
- AddWaypoint(5, 5026.27f, -1736.89f, 1323.02f);
- AddWaypoint(6, 5037.77f, -1770.56f, 1324.36f);
- AddWaypoint(7, 5067.23f, -1789.95f, 1321.17f);
- Start(false, true);
- SetDespawnAtEnd(false);
- }
+ AddWaypoint(0, 4896.08f, -1576.35f, 1333.65f);
+ AddWaypoint(1, 4898.68f, -1615.02f, 1329.48f);
+ AddWaypoint(2, 4907.12f, -1667.08f, 1321.00f);
+ AddWaypoint(3, 4963.18f, -1699.35f, 1340.51f);
+ AddWaypoint(4, 4989.16f, -1716.67f, 1335.74f);
+ AddWaypoint(5, 5026.27f, -1736.89f, 1323.02f);
+ AddWaypoint(6, 5037.77f, -1770.56f, 1324.36f);
+ AddWaypoint(7, 5067.23f, -1789.95f, 1321.17f);
+ Start(false, true);
+ SetDespawnAtEnd(false);
}
}
@@ -179,17 +177,15 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_towering_infernalAI(creature);
+ return GetInstanceAI<npc_towering_infernalAI>(creature);
}
struct npc_towering_infernalAI : public ScriptedAI
{
npc_towering_infernalAI(Creature* creature) : ScriptedAI(creature)
{
- AnetheronGUID = 0;
instance = creature->GetInstanceScript();
- if (instance)
- AnetheronGUID = instance->GetData64(DATA_ANETHERON);
+ AnetheronGUID = instance->GetData64(DATA_ANETHERON);
}
uint32 ImmolationTimer;
diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_archimonde.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_archimonde.cpp
index 41cc1d0241d..2708b39e8a8 100644
--- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_archimonde.cpp
+++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_archimonde.cpp
@@ -83,7 +83,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_ancient_wispAI(creature);
+ return GetInstanceAI<npc_ancient_wispAI>(creature);
}
struct npc_ancient_wispAI : public ScriptedAI
@@ -102,8 +102,7 @@ public:
{
CheckTimer = 1000;
- if (instance)
- ArchimondeGUID = instance->GetData64(DATA_ARCHIMONDE);
+ ArchimondeGUID = instance->GetData64(DATA_ARCHIMONDE);
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
}
@@ -239,7 +238,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_archimondeAI(creature);
+ return GetInstanceAI<boss_archimondeAI>(creature);
}
struct boss_archimondeAI : public hyjal_trashAI
@@ -275,8 +274,7 @@ public:
void Reset() OVERRIDE
{
- if (instance)
- instance->SetData(DATA_ARCHIMONDEEVENT, NOT_STARTED);
+ instance->SetData(DATA_ARCHIMONDEEVENT, NOT_STARTED);
DoomfireSpiritGUID = 0;
damageTaken = 0;
@@ -308,8 +306,7 @@ public:
Talk(SAY_AGGRO);
DoZoneInCombat();
- if (instance)
- instance->SetData(DATA_ARCHIMONDEEVENT, IN_PROGRESS);
+ instance->SetData(DATA_ARCHIMONDEEVENT, IN_PROGRESS);
}
void KilledUnit(Unit* victim) OVERRIDE
@@ -350,8 +347,7 @@ public:
hyjal_trashAI::JustDied(killer);
Talk(SAY_DEATH);
- if (instance)
- instance->SetData(DATA_ARCHIMONDEEVENT, DONE);
+ instance->SetData(DATA_ARCHIMONDEEVENT, DONE);
}
bool CanUseFingerOfDeath()
@@ -471,19 +467,16 @@ public:
{
if (!me->IsInCombat())
{
- if (instance)
+ // Do not let the raid skip straight to Archimonde. Visible and hostile ONLY if Azagalor is finished.
+ if ((instance->GetData(DATA_AZGALOREVENT) < DONE) && (me->IsVisible() || (me->getFaction() != 35)))
{
- // Do not let the raid skip straight to Archimonde. Visible and hostile ONLY if Azagalor is finished.
- if ((instance->GetData(DATA_AZGALOREVENT) < DONE) && (me->IsVisible() || (me->getFaction() != 35)))
- {
- me->SetVisible(false);
- me->setFaction(35);
- }
- else if ((instance->GetData(DATA_AZGALOREVENT) >= DONE) && (!me->IsVisible() || (me->getFaction() == 35)))
- {
- me->setFaction(1720);
- me->SetVisible(true);
- }
+ me->SetVisible(false);
+ me->setFaction(35);
+ }
+ else if ((instance->GetData(DATA_AZGALOREVENT) >= DONE) && (!me->IsVisible() || (me->getFaction() == 35)))
+ {
+ me->setFaction(1720);
+ me->SetVisible(true);
}
if (DrainNordrassilTimer <= diff)
diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_azgalor.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_azgalor.cpp
index dd486df16ed..c4d68f76df4 100644
--- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_azgalor.cpp
+++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_azgalor.cpp
@@ -48,7 +48,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_azgalorAI(creature);
+ return GetInstanceAI<boss_azgalorAI>(creature);
}
struct boss_azgalorAI : public hyjal_trashAI
@@ -121,19 +121,16 @@ public:
if (!go)
{
go = true;
- if (instance)
- {
- AddWaypoint(0, 5492.91f, -2404.61f, 1462.63f);
- AddWaypoint(1, 5531.76f, -2460.87f, 1469.55f);
- AddWaypoint(2, 5554.58f, -2514.66f, 1476.12f);
- AddWaypoint(3, 5554.16f, -2567.23f, 1479.90f);
- AddWaypoint(4, 5540.67f, -2625.99f, 1480.89f);
- AddWaypoint(5, 5508.16f, -2659.2f, 1480.15f);
- AddWaypoint(6, 5489.62f, -2704.05f, 1482.18f);
- AddWaypoint(7, 5457.04f, -2726.26f, 1485.10f);
- Start(false, true);
- SetDespawnAtEnd(false);
- }
+ AddWaypoint(0, 5492.91f, -2404.61f, 1462.63f);
+ AddWaypoint(1, 5531.76f, -2460.87f, 1469.55f);
+ AddWaypoint(2, 5554.58f, -2514.66f, 1476.12f);
+ AddWaypoint(3, 5554.16f, -2567.23f, 1479.90f);
+ AddWaypoint(4, 5540.67f, -2625.99f, 1480.89f);
+ AddWaypoint(5, 5508.16f, -2659.2f, 1480.15f);
+ AddWaypoint(6, 5489.62f, -2704.05f, 1482.18f);
+ AddWaypoint(7, 5457.04f, -2726.26f, 1485.10f);
+ Start(false, true);
+ SetDespawnAtEnd(false);
}
}
@@ -186,17 +183,15 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_lesser_doomguardAI(creature);
+ return GetInstanceAI<npc_lesser_doomguardAI>(creature);
}
struct npc_lesser_doomguardAI : public hyjal_trashAI
{
npc_lesser_doomguardAI(Creature* creature) : hyjal_trashAI(creature)
{
- AzgalorGUID = 0;
instance = creature->GetInstanceScript();
- if (instance)
- AzgalorGUID = instance->GetData64(DATA_AZGALOR);
+ AzgalorGUID = instance->GetData64(DATA_AZGALOR);
}
uint32 CrippleTimer;
diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_kazrogal.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_kazrogal.cpp
index 0c918f0b0ca..eb4ef16889f 100644
--- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_kazrogal.cpp
+++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_kazrogal.cpp
@@ -49,7 +49,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_kazrogalAI(creature);
+ return GetInstanceAI<boss_kazrogalAI>(creature);
}
struct boss_kazrogalAI : public hyjal_trashAI
@@ -117,19 +117,16 @@ public:
if (!go)
{
go = true;
- if (instance)
- {
- AddWaypoint(0, 5492.91f, -2404.61f, 1462.63f);
- AddWaypoint(1, 5531.76f, -2460.87f, 1469.55f);
- AddWaypoint(2, 5554.58f, -2514.66f, 1476.12f);
- AddWaypoint(3, 5554.16f, -2567.23f, 1479.90f);
- AddWaypoint(4, 5540.67f, -2625.99f, 1480.89f);
- AddWaypoint(5, 5508.16f, -2659.2f, 1480.15f);
- AddWaypoint(6, 5489.62f, -2704.05f, 1482.18f);
- AddWaypoint(7, 5457.04f, -2726.26f, 1485.10f);
- Start(false, true);
- SetDespawnAtEnd(false);
- }
+ AddWaypoint(0, 5492.91f, -2404.61f, 1462.63f);
+ AddWaypoint(1, 5531.76f, -2460.87f, 1469.55f);
+ AddWaypoint(2, 5554.58f, -2514.66f, 1476.12f);
+ AddWaypoint(3, 5554.16f, -2567.23f, 1479.90f);
+ AddWaypoint(4, 5540.67f, -2625.99f, 1480.89f);
+ AddWaypoint(5, 5508.16f, -2659.2f, 1480.15f);
+ AddWaypoint(6, 5489.62f, -2704.05f, 1482.18f);
+ AddWaypoint(7, 5457.04f, -2726.26f, 1485.10f);
+ Start(false, true);
+ SetDespawnAtEnd(false);
}
}
diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_rage_winterchill.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_rage_winterchill.cpp
index c163e7c0f1f..00c82b11171 100644
--- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_rage_winterchill.cpp
+++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_rage_winterchill.cpp
@@ -44,7 +44,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_rage_winterchillAI(creature);
+ return GetInstanceAI<boss_rage_winterchillAI>(creature);
}
struct boss_rage_winterchillAI : public hyjal_trashAI
@@ -112,19 +112,16 @@ public:
if (!go)
{
go = true;
- if (instance)
- {
- AddWaypoint(0, 4896.08f, -1576.35f, 1333.65f);
- AddWaypoint(1, 4898.68f, -1615.02f, 1329.48f);
- AddWaypoint(2, 4907.12f, -1667.08f, 1321.00f);
- AddWaypoint(3, 4963.18f, -1699.35f, 1340.51f);
- AddWaypoint(4, 4989.16f, -1716.67f, 1335.74f);
- AddWaypoint(5, 5026.27f, -1736.89f, 1323.02f);
- AddWaypoint(6, 5037.77f, -1770.56f, 1324.36f);
- AddWaypoint(7, 5067.23f, -1789.95f, 1321.17f);
- Start(false, true);
- SetDespawnAtEnd(false);
- }
+ AddWaypoint(0, 4896.08f, -1576.35f, 1333.65f);
+ AddWaypoint(1, 4898.68f, -1615.02f, 1329.48f);
+ AddWaypoint(2, 4907.12f, -1667.08f, 1321.00f);
+ AddWaypoint(3, 4963.18f, -1699.35f, 1340.51f);
+ AddWaypoint(4, 4989.16f, -1716.67f, 1335.74f);
+ AddWaypoint(5, 5026.27f, -1736.89f, 1323.02f);
+ AddWaypoint(6, 5037.77f, -1770.56f, 1324.36f);
+ AddWaypoint(7, 5067.23f, -1789.95f, 1321.17f);
+ Start(false, true);
+ SetDespawnAtEnd(false);
}
}
diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal.cpp
index f4d3f559585..a352c3493ee 100644
--- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal.cpp
+++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal.cpp
@@ -102,6 +102,9 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
+ if (!creature->GetInstanceScript())
+ return NULL;
+
hyjalAI* ai = new hyjalAI(creature);
ai->Reset();
@@ -184,6 +187,9 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
+ if (!creature->GetInstanceScript())
+ return NULL;
+
hyjalAI* ai = new hyjalAI(creature);
ai->Reset();
@@ -209,6 +215,9 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
+ if (!creature->GetInstanceScript())
+ return NULL;
+
hyjalAI* ai = new hyjalAI(creature);
ai->Reset();
ai->EnterEvadeMode();
diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp
index 6d73485d98b..70b0489447f 100644
--- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp
+++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp
@@ -397,17 +397,14 @@ void hyjalAI::Reset()
memset(Spells, 0, sizeof(Spell) * HYJAL_AI_MAX_SPELLS);
//Reset Instance Data for trash count
- if (instance)
+ if ((!instance->GetData(DATA_ALLIANCE_RETREAT) && me->GetEntry() == JAINA) || (instance->GetData(DATA_ALLIANCE_RETREAT) && me->GetEntry() == THRALL))
{
- if ((!instance->GetData(DATA_ALLIANCE_RETREAT) && me->GetEntry() == JAINA) || (instance->GetData(DATA_ALLIANCE_RETREAT) && me->GetEntry() == THRALL))
- {
- //Reset World States
- instance->DoUpdateWorldState(WORLD_STATE_WAVES, 0);
- instance->DoUpdateWorldState(WORLD_STATE_ENEMY, 0);
- instance->DoUpdateWorldState(WORLD_STATE_ENEMYCOUNT, 0);
- instance->SetData(DATA_RESET_TRASH_COUNT, 0);
- }
- } else TC_LOG_ERROR("scripts", ERROR_INST_DATA);
+ //Reset World States
+ instance->DoUpdateWorldState(WORLD_STATE_WAVES, 0);
+ instance->DoUpdateWorldState(WORLD_STATE_ENEMY, 0);
+ instance->DoUpdateWorldState(WORLD_STATE_ENEMYCOUNT, 0);
+ instance->SetData(DATA_RESET_TRASH_COUNT, 0);
+ }
//Visibility
DoHide = true;
@@ -517,11 +514,8 @@ void hyjalAI::SummonCreature(uint32 entry, float Base[4][3])
CAST_AI(hyjal_trashAI, creature->AI())->IsEvent = true;
break;
}
- if (instance)
- {
- if (instance->GetData(DATA_RAIDDAMAGE) < MINRAIDDAMAGE)
- creature->SetDisableReputationGain(true);//no repu for solo farming
- }
+ if (instance->GetData(DATA_RAIDDAMAGE) < MINRAIDDAMAGE)
+ creature->SetDisableReputationGain(true);//no repu for solo farming
// Check if Creature is a boss.
if (creature->isWorldBoss())
{
@@ -538,11 +532,6 @@ void hyjalAI::SummonNextWave(const Wave wave[18], uint32 Count, float Base[4][3]
if (rand()%4 == 0)
Talk(RALLY);
- if (!instance)
- {
- TC_LOG_ERROR("scripts", ERROR_INST_DATA);
- return;
- }
InfernalCount = 0;//reset infernal count every new wave
EnemyCount = instance->GetData(DATA_TRASH);
@@ -612,41 +601,34 @@ void hyjalAI::StartEvent(Player* player)
uint32 hyjalAI::GetInstanceData(uint32 Event)
{
- if (instance)
- return instance->GetData(Event);
- else TC_LOG_ERROR("scripts", ERROR_INST_DATA);
-
- return 0;
+ return instance->GetData(Event);
}
void hyjalAI::Retreat()
{
- if (instance)
- {
- instance->SetData(TYPE_RETREAT, SPECIAL);
+ instance->SetData(TYPE_RETREAT, SPECIAL);
- if (Faction == 0)
- {
- instance->SetData(DATA_ALLIANCE_RETREAT, 1);
- AddWaypoint(0, JainaWPs[0][0], JainaWPs[0][1], JainaWPs[0][2]);
- AddWaypoint(1, JainaWPs[1][0], JainaWPs[1][1], JainaWPs[1][2]);
- Start(false, false);
- SetDespawnAtEnd(false);//move to center of alliance base
- }
- if (Faction == 1)
+ if (Faction == 0)
+ {
+ instance->SetData(DATA_ALLIANCE_RETREAT, 1);
+ AddWaypoint(0, JainaWPs[0][0], JainaWPs[0][1], JainaWPs[0][2]);
+ AddWaypoint(1, JainaWPs[1][0], JainaWPs[1][1], JainaWPs[1][2]);
+ Start(false, false);
+ SetDespawnAtEnd(false);//move to center of alliance base
+ }
+ if (Faction == 1)
+ {
+ instance->SetData(DATA_HORDE_RETREAT, 1);
+ Creature* JainaDummy = me->SummonCreature(JAINA, JainaDummySpawn[0][0], JainaDummySpawn[0][1], JainaDummySpawn[0][2], JainaDummySpawn[0][3], TEMPSUMMON_TIMED_DESPAWN, 60000);
+ if (JainaDummy)
{
- instance->SetData(DATA_HORDE_RETREAT, 1);
- Creature* JainaDummy = me->SummonCreature(JAINA, JainaDummySpawn[0][0], JainaDummySpawn[0][1], JainaDummySpawn[0][2], JainaDummySpawn[0][3], TEMPSUMMON_TIMED_DESPAWN, 60000);
- if (JainaDummy)
- {
- JainaDummy->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
- CAST_AI(hyjalAI, JainaDummy->AI())->IsDummy = true;
- DummyGuid = JainaDummy->GetGUID();
- }
- AddWaypoint(0, JainaDummySpawn[1][0], JainaDummySpawn[1][1], JainaDummySpawn[1][2]);
- Start(false, false);
- SetDespawnAtEnd(false);//move to center of alliance base
+ JainaDummy->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
+ CAST_AI(hyjalAI, JainaDummy->AI())->IsDummy = true;
+ DummyGuid = JainaDummy->GetGUID();
}
+ AddWaypoint(0, JainaDummySpawn[1][0], JainaDummySpawn[1][1], JainaDummySpawn[1][2]);
+ Start(false, false);
+ SetDespawnAtEnd(false);//move to center of alliance base
}
SpawnVeins();
Overrun = true;
@@ -681,8 +663,6 @@ void hyjalAI::SpawnVeins()
void hyjalAI::DeSpawnVeins()
{
- if (!instance)
- return;
if (Faction == 1)
{
Creature* unit=Unit::GetCreature((*me), instance->GetData64(DATA_JAINAPROUDMOORE));
@@ -841,8 +821,7 @@ void hyjalAI::UpdateAI(uint32 diff)
CheckTimer = 0;
me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
BossGUID[i] = 0;
- if (instance)
- instance->DoUpdateWorldState(WORLD_STATE_ENEMY, 0); // Reset world state for enemies to disable it
+ instance->DoUpdateWorldState(WORLD_STATE_ENEMY, 0); // Reset world state for enemies to disable it
}
}
}
@@ -858,7 +837,7 @@ void hyjalAI::UpdateAI(uint32 diff)
{
if (SpellTimer[i] <= diff)
{
- if (me->IsNonMeleeSpellCasted(false))
+ if (me->IsNonMeleeSpellCast(false))
me->InterruptNonMeleeSpells(false);
Unit* target = NULL;
@@ -899,18 +878,16 @@ void hyjalAI::JustDied(Unit* /*killer*/)
RespawnTimer = 120000;
Talk(DEATH);
Summons.DespawnAll();//despawn all wave's summons
- if (instance)
- {//reset encounter if boss is despawned (ex: thrall is killed, boss despawns, event stucks at inprogress)
- if (instance->GetData(DATA_RAGEWINTERCHILLEVENT) == IN_PROGRESS)
- instance->SetData(DATA_RAGEWINTERCHILLEVENT, NOT_STARTED);
- if (instance->GetData(DATA_ANETHERONEVENT) == IN_PROGRESS)
- instance->SetData(DATA_ANETHERONEVENT, NOT_STARTED);
- if (instance->GetData(DATA_KAZROGALEVENT) == IN_PROGRESS)
- instance->SetData(DATA_KAZROGALEVENT, NOT_STARTED);
- if (instance->GetData(DATA_AZGALOREVENT) == IN_PROGRESS)
- instance->SetData(DATA_AZGALOREVENT, NOT_STARTED);
- instance->SetData(DATA_RESET_RAIDDAMAGE, 0);//reset damage on die
- }
+ //reset encounter if boss is despawned (ex: thrall is killed, boss despawns, event stucks at inprogress)
+ if (instance->GetData(DATA_RAGEWINTERCHILLEVENT) == IN_PROGRESS)
+ instance->SetData(DATA_RAGEWINTERCHILLEVENT, NOT_STARTED);
+ if (instance->GetData(DATA_ANETHERONEVENT) == IN_PROGRESS)
+ instance->SetData(DATA_ANETHERONEVENT, NOT_STARTED);
+ if (instance->GetData(DATA_KAZROGALEVENT) == IN_PROGRESS)
+ instance->SetData(DATA_KAZROGALEVENT, NOT_STARTED);
+ if (instance->GetData(DATA_AZGALOREVENT) == IN_PROGRESS)
+ instance->SetData(DATA_AZGALOREVENT, NOT_STARTED);
+ instance->SetData(DATA_RESET_RAIDDAMAGE, 0);//reset damage on die
}
void hyjalAI::HideNearPos(float x, float y)
diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal_trash.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal_trash.cpp
index 9245a0c648f..0a369154ad4 100644
--- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal_trash.cpp
+++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal_trash.cpp
@@ -195,8 +195,7 @@ void hyjal_trashAI::DamageTaken(Unit* done_by, uint32 &damage)
if (done_by->GetTypeId() == TYPEID_PLAYER || done_by->IsPet())
{
damageTaken += damage;
- if (instance)
- instance->SetData(DATA_RAIDDAMAGE, damage);//store raid's damage
+ instance->SetData(DATA_RAIDDAMAGE, damage);//store raid's damage
}
}
@@ -399,9 +398,6 @@ void hyjal_trashAI::UpdateAI(uint32 /*diff*/)
void hyjal_trashAI::JustDied(Unit* /*killer*/)
{
- if (!instance)
- return;
-
if (IsEvent && !me->isWorldBoss())
instance->SetData(DATA_TRASH, 0);//signal trash is dead
@@ -488,16 +484,13 @@ public:
me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
me->SetDisplayId(me->GetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID));
CanMove = true;
- if (instance)
+ if (instance->GetData(DATA_ALLIANCE_RETREAT) && !instance->GetData(DATA_HORDE_RETREAT))
{
- if (instance->GetData(DATA_ALLIANCE_RETREAT) && !instance->GetData(DATA_HORDE_RETREAT))
- {
- Unit* target = Unit::GetUnit(*me, instance->GetData64(DATA_THRALL));
- if (target && target->IsAlive())
- me->AddThreat(target, 0.0f);
- } else if (instance->GetData(DATA_ALLIANCE_RETREAT) && instance->GetData(DATA_HORDE_RETREAT)){
- //do overrun
- }
+ Unit* target = Unit::GetUnit(*me, instance->GetData64(DATA_THRALL));
+ if (target && target->IsAlive())
+ me->AddThreat(target, 0.0f);
+ } else if (instance->GetData(DATA_ALLIANCE_RETREAT) && instance->GetData(DATA_HORDE_RETREAT)){
+ //do overrun
}
} else spawnTimer -= diff;
}
@@ -510,12 +503,9 @@ public:
if (!go)
{
go = true;
- if (instance)
- {
- AddWaypoint(0, HordeWPs[7][0]+irand(-3, 3), HordeWPs[7][1]+irand(-3, 3), HordeWPs[7][2]);//HordeWPs[7] infront of thrall
- Start(true, true);
- SetDespawnAtEnd(false);
- }
+ AddWaypoint(0, HordeWPs[7][0]+irand(-3, 3), HordeWPs[7][1]+irand(-3, 3), HordeWPs[7][2]);//HordeWPs[7] infront of thrall
+ Start(true, true);
+ SetDespawnAtEnd(false);
}
}
@@ -537,7 +527,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_giant_infernalAI(creature);
+ return GetInstanceAI<npc_giant_infernalAI>(creature);
}
};
@@ -548,7 +538,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_abominationAI(creature);
+ return GetInstanceAI<npc_abominationAI>(creature);
}
struct npc_abominationAI : public hyjal_trashAI
@@ -606,21 +596,18 @@ public:
if (!go)
{
go = true;
- if (instance)
+ if (instance->GetData(DATA_ALLIANCE_RETREAT))//2.alliance boss down, use horde WPs
+ {
+ for (uint8 i = 0; i < 8; ++i)
+ AddWaypoint(i, HordeWPs[i][0]+irand(-3, 3), HordeWPs[i][1]+irand(-3, 3), HordeWPs[i][2]);
+ Start(false, true);
+ SetDespawnAtEnd(false);
+ }else//use alliance WPs
{
- if (instance->GetData(DATA_ALLIANCE_RETREAT))//2.alliance boss down, use horde WPs
- {
- for (uint8 i = 0; i < 8; ++i)
- AddWaypoint(i, HordeWPs[i][0]+irand(-3, 3), HordeWPs[i][1]+irand(-3, 3), HordeWPs[i][2]);
- Start(false, true);
- SetDespawnAtEnd(false);
- }else//use alliance WPs
- {
- for (uint8 i = 0; i < 8; ++i)
- AddWaypoint(i, AllianceWPs[i][0]+irand(-3, 3), AllianceWPs[i][1]+irand(-3, 3), AllianceWPs[i][2]);
- Start(false, true);
- SetDespawnAtEnd(false);
- }
+ for (uint8 i = 0; i < 8; ++i)
+ AddWaypoint(i, AllianceWPs[i][0]+irand(-3, 3), AllianceWPs[i][1]+irand(-3, 3), AllianceWPs[i][2]);
+ Start(false, true);
+ SetDespawnAtEnd(false);
}
}
}
@@ -646,7 +633,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_ghoulAI(creature);
+ return GetInstanceAI<npc_ghoulAI>(creature);
}
struct npc_ghoulAI : public hyjal_trashAI
@@ -709,21 +696,18 @@ public:
if (!go)
{
go = true;
- if (instance)
+ if (instance->GetData(DATA_ALLIANCE_RETREAT))//2.alliance boss down, use horde WPs
{
- if (instance->GetData(DATA_ALLIANCE_RETREAT))//2.alliance boss down, use horde WPs
- {
- for (uint8 i = 0; i < 8; ++i)
- AddWaypoint(i, HordeWPs[i][0]+irand(-3, 3), HordeWPs[i][1]+irand(-3, 3), HordeWPs[i][2]);
- Start(false, true);
- SetDespawnAtEnd(false);
- }else//use alliance WPs
- {
- for (uint8 i = 0; i < 8; ++i)
- AddWaypoint(i, AllianceWPs[i][0]+irand(-3, 3), AllianceWPs[i][1]+irand(-3, 3), AllianceWPs[i][2]);
- Start(false, true);
- SetDespawnAtEnd(false);
- }
+ for (uint8 i = 0; i < 8; ++i)
+ AddWaypoint(i, HordeWPs[i][0]+irand(-3, 3), HordeWPs[i][1]+irand(-3, 3), HordeWPs[i][2]);
+ Start(false, true);
+ SetDespawnAtEnd(false);
+ }else//use alliance WPs
+ {
+ for (uint8 i = 0; i < 8; ++i)
+ AddWaypoint(i, AllianceWPs[i][0]+irand(-3, 3), AllianceWPs[i][1]+irand(-3, 3), AllianceWPs[i][2]);
+ Start(false, true);
+ SetDespawnAtEnd(false);
}
}
}
@@ -748,7 +732,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_necromancerAI(creature);
+ return GetInstanceAI<npc_necromancerAI>(creature);
}
struct npc_necromancerAI : public hyjal_trashAI
@@ -834,21 +818,18 @@ public:
if (!go)
{
go = true;
- if (instance)
+ if (instance->GetData(DATA_ALLIANCE_RETREAT))//2.alliance boss down, use horde WPs
+ {
+ for (uint8 i = 0; i < 8; ++i)
+ AddWaypoint(i, HordeWPs[i][0]+irand(-3, 3), HordeWPs[i][1]+irand(-3, 3), HordeWPs[i][2]);
+ Start(true, true);
+ SetDespawnAtEnd(false);
+ }else//use alliance WPs
{
- if (instance->GetData(DATA_ALLIANCE_RETREAT))//2.alliance boss down, use horde WPs
- {
- for (uint8 i = 0; i < 8; ++i)
- AddWaypoint(i, HordeWPs[i][0]+irand(-3, 3), HordeWPs[i][1]+irand(-3, 3), HordeWPs[i][2]);
- Start(true, true);
- SetDespawnAtEnd(false);
- }else//use alliance WPs
- {
- for (uint8 i = 0; i < 8; ++i)
- AddWaypoint(i, AllianceWPs[i][0]+irand(-3, 3), AllianceWPs[i][1]+irand(-3, 3), AllianceWPs[i][2]);
- Start(true, true);
- SetDespawnAtEnd(false);
- }
+ for (uint8 i = 0; i < 8; ++i)
+ AddWaypoint(i, AllianceWPs[i][0]+irand(-3, 3), AllianceWPs[i][1]+irand(-3, 3), AllianceWPs[i][2]);
+ Start(true, true);
+ SetDespawnAtEnd(false);
}
}
}
@@ -875,7 +856,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_bansheeAI(creature);
+ return GetInstanceAI<npc_bansheeAI>(creature);
}
struct npc_bansheeAI : public hyjal_trashAI
@@ -930,21 +911,18 @@ public:
if (!go)
{
go = true;
- if (instance)
+ if (instance->GetData(DATA_ALLIANCE_RETREAT))//2.alliance boss down, use horde WPs
{
- if (instance->GetData(DATA_ALLIANCE_RETREAT))//2.alliance boss down, use horde WPs
- {
- for (uint8 i = 0; i < 8; ++i)
- AddWaypoint(i, HordeWPs[i][0]+irand(-3, 3), HordeWPs[i][1]+irand(-3, 3), HordeWPs[i][2]);
- Start(false, true);
- SetDespawnAtEnd(false);
- }else//use alliance WPs
- {
- for (uint8 i = 0; i < 8; ++i)
- AddWaypoint(i, AllianceWPs[i][0]+irand(-3, 3), AllianceWPs[i][1]+irand(-3, 3), AllianceWPs[i][2]);
- Start(false, true);
- SetDespawnAtEnd(false);
- }
+ for (uint8 i = 0; i < 8; ++i)
+ AddWaypoint(i, HordeWPs[i][0]+irand(-3, 3), HordeWPs[i][1]+irand(-3, 3), HordeWPs[i][2]);
+ Start(false, true);
+ SetDespawnAtEnd(false);
+ }else//use alliance WPs
+ {
+ for (uint8 i = 0; i < 8; ++i)
+ AddWaypoint(i, AllianceWPs[i][0]+irand(-3, 3), AllianceWPs[i][1]+irand(-3, 3), AllianceWPs[i][2]);
+ Start(false, true);
+ SetDespawnAtEnd(false);
}
}
}
@@ -978,7 +956,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_crypt_fiendAI(creature);
+ return GetInstanceAI<npc_crypt_fiendAI>(creature);
}
struct npc_crypt_fiendAI : public hyjal_trashAI
@@ -1029,22 +1007,18 @@ public:
if (!go)
{
go = true;
- if (instance)
+ if (instance->GetData(DATA_ALLIANCE_RETREAT))//2.alliance boss down, use horde WPs
{
- if (instance->GetData(DATA_ALLIANCE_RETREAT))//2.alliance boss down, use horde WPs
- {
- for (uint8 i = 0; i < 8; ++i)
- AddWaypoint(i, HordeWPs[i][0]+irand(-3, 3), HordeWPs[i][1]+irand(-3, 3), HordeWPs[i][2]);
- Start(false, true);
- SetDespawnAtEnd(false);
- }else//use alliance WPs
- {
- for (uint8 i = 0; i < 8; ++i)
- AddWaypoint(i, AllianceWPs[i][0]+irand(-3, 3), AllianceWPs[i][1]+irand(-3, 3), AllianceWPs[i][2]);
- Start(false, true);
- SetDespawnAtEnd(false);
- }
-
+ for (uint8 i = 0; i < 8; ++i)
+ AddWaypoint(i, HordeWPs[i][0]+irand(-3, 3), HordeWPs[i][1]+irand(-3, 3), HordeWPs[i][2]);
+ Start(false, true);
+ SetDespawnAtEnd(false);
+ }else//use alliance WPs
+ {
+ for (uint8 i = 0; i < 8; ++i)
+ AddWaypoint(i, AllianceWPs[i][0]+irand(-3, 3), AllianceWPs[i][1]+irand(-3, 3), AllianceWPs[i][2]);
+ Start(false, true);
+ SetDespawnAtEnd(false);
}
}
}
@@ -1068,7 +1042,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_fel_stalkerAI(creature);
+ return GetInstanceAI<npc_fel_stalkerAI>(creature);
}
struct npc_fel_stalkerAI : public hyjal_trashAI
@@ -1119,22 +1093,18 @@ public:
if (!go)
{
go = true;
- if (instance)
+ if (instance->GetData(DATA_ALLIANCE_RETREAT))//2.alliance boss down, use horde WPs
{
- if (instance->GetData(DATA_ALLIANCE_RETREAT))//2.alliance boss down, use horde WPs
- {
- for (uint8 i = 0; i < 8; ++i)
- AddWaypoint(i, HordeWPs[i][0]+irand(-3, 3), HordeWPs[i][1]+irand(-3, 3), HordeWPs[i][2]);
- Start(false, true);
- SetDespawnAtEnd(false);
- }else//use alliance WPs
- {
- for (uint8 i = 0; i < 8; ++i)
- AddWaypoint(i, AllianceWPs[i][0]+irand(-3, 3), AllianceWPs[i][1]+irand(-3, 3), AllianceWPs[i][2]);
- Start(false, true);
- SetDespawnAtEnd(false);
- }
-
+ for (uint8 i = 0; i < 8; ++i)
+ AddWaypoint(i, HordeWPs[i][0]+irand(-3, 3), HordeWPs[i][1]+irand(-3, 3), HordeWPs[i][2]);
+ Start(false, true);
+ SetDespawnAtEnd(false);
+ }else//use alliance WPs
+ {
+ for (uint8 i = 0; i < 8; ++i)
+ AddWaypoint(i, AllianceWPs[i][0]+irand(-3, 3), AllianceWPs[i][1]+irand(-3, 3), AllianceWPs[i][2]);
+ Start(false, true);
+ SetDespawnAtEnd(false);
}
}
}
@@ -1158,7 +1128,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_frost_wyrmAI(creature);
+ return GetInstanceAI<npc_frost_wyrmAI>(creature);
}
struct npc_frost_wyrmAI : public hyjal_trashAI
@@ -1221,20 +1191,17 @@ public:
if (!go)
{
go = true;
- if (instance)
+ if (!useFlyPath)
{
- if (!useFlyPath)
- {
- for (uint8 i = 0; i < 3; ++i)
- AddWaypoint(i, FrostWyrmWPs[i][0], FrostWyrmWPs[i][1], FrostWyrmWPs[i][2]);
- Start(false, true);
- SetDespawnAtEnd(false);
- }else{//fly path FlyPathWPs
- for (uint8 i = 0; i < 3; ++i)
- AddWaypoint(i, FlyPathWPs[i][0]+irand(-10, 10), FlyPathWPs[i][1]+irand(-10, 10), FlyPathWPs[i][2]);
- Start(false, true);
- SetDespawnAtEnd(false);
- }
+ for (uint8 i = 0; i < 3; ++i)
+ AddWaypoint(i, FrostWyrmWPs[i][0], FrostWyrmWPs[i][1], FrostWyrmWPs[i][2]);
+ Start(false, true);
+ SetDespawnAtEnd(false);
+ }else{//fly path FlyPathWPs
+ for (uint8 i = 0; i < 3; ++i)
+ AddWaypoint(i, FlyPathWPs[i][0]+irand(-10, 10), FlyPathWPs[i][1]+irand(-10, 10), FlyPathWPs[i][2]);
+ Start(false, true);
+ SetDespawnAtEnd(false);
}
}
}
@@ -1270,7 +1237,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_gargoyleAI(creature);
+ return GetInstanceAI<npc_gargoyleAI>(creature);
}
struct npc_gargoyleAI : public hyjal_trashAI
@@ -1334,20 +1301,17 @@ public:
if (!go)
{
go = true;
- if (instance)
+ if (!useFlyPath)
{
- if (!useFlyPath)
- {
- for (uint8 i = 0; i < 3; ++i)
- AddWaypoint(i, GargoyleWPs[i][0]+irand(-10, 10), GargoyleWPs[i][1]+irand(-10, 10), GargoyleWPs[i][2]);
- Start(false, true);
- SetDespawnAtEnd(false);
- }else{//fly path FlyPathWPs
- for (uint8 i = 0; i < 3; ++i)
- AddWaypoint(i, FlyPathWPs[i][0]+irand(-10, 10), FlyPathWPs[i][1]+irand(-10, 10), FlyPathWPs[i][2]);
- Start(false, true);
- SetDespawnAtEnd(false);
- }
+ for (uint8 i = 0; i < 3; ++i)
+ AddWaypoint(i, GargoyleWPs[i][0]+irand(-10, 10), GargoyleWPs[i][1]+irand(-10, 10), GargoyleWPs[i][2]);
+ Start(false, true);
+ SetDespawnAtEnd(false);
+ }else{//fly path FlyPathWPs
+ for (uint8 i = 0; i < 3; ++i)
+ AddWaypoint(i, FlyPathWPs[i][0]+irand(-10, 10), FlyPathWPs[i][1]+irand(-10, 10), FlyPathWPs[i][2]);
+ Start(false, true);
+ SetDespawnAtEnd(false);
}
}
}
diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_chrono_lord_epoch.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_chrono_lord_epoch.cpp
index c049be0309b..07bfdae208f 100644
--- a/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_chrono_lord_epoch.cpp
+++ b/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_chrono_lord_epoch.cpp
@@ -52,7 +52,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_epochAI(creature);
+ return GetInstanceAI<boss_epochAI>(creature);
}
struct boss_epochAI : public ScriptedAI
@@ -81,16 +81,14 @@ public:
uiTimeStopTimer = 21300;
uiWoundingStrikeTimer = 5300;
- if (instance)
- instance->SetData(DATA_EPOCH_EVENT, NOT_STARTED);
+ instance->SetData(DATA_EPOCH_EVENT, NOT_STARTED);
}
void EnterCombat(Unit* /*who*/) OVERRIDE
{
Talk(SAY_AGGRO);
- if (instance)
- instance->SetData(DATA_EPOCH_EVENT, IN_PROGRESS);
+ instance->SetData(DATA_EPOCH_EVENT, IN_PROGRESS);
}
void UpdateAI(uint32 diff) OVERRIDE
@@ -132,8 +130,7 @@ public:
{
Talk(SAY_DEATH);
- if (instance)
- instance->SetData(DATA_EPOCH_EVENT, DONE);
+ instance->SetData(DATA_EPOCH_EVENT, DONE);
}
void KilledUnit(Unit* victim) OVERRIDE
diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_infinite_corruptor.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_infinite_corruptor.cpp
index 54438e3b8a9..f9ea0f482f0 100644
--- a/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_infinite_corruptor.cpp
+++ b/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_infinite_corruptor.cpp
@@ -39,7 +39,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_infinite_corruptorAI(creature);
+ return GetInstanceAI<boss_infinite_corruptorAI>(creature);
}
struct boss_infinite_corruptorAI : public ScriptedAI
@@ -53,15 +53,13 @@ public:
void Reset() OVERRIDE
{
- if (instance)
- instance->SetData(DATA_INFINITE_EVENT, NOT_STARTED);
+ instance->SetData(DATA_INFINITE_EVENT, NOT_STARTED);
}
void EnterCombat(Unit* /*who*/) OVERRIDE
{
Talk(SAY_AGGRO);
- if (instance)
- instance->SetData(DATA_INFINITE_EVENT, IN_PROGRESS);
+ instance->SetData(DATA_INFINITE_EVENT, IN_PROGRESS);
}
void UpdateAI(uint32 /*diff*/) OVERRIDE
@@ -76,8 +74,7 @@ public:
void JustDied(Unit* /*killer*/) OVERRIDE
{
Talk(SAY_DEATH);
- if (instance)
- instance->SetData(DATA_INFINITE_EVENT, DONE);
+ instance->SetData(DATA_INFINITE_EVENT, DONE);
}
};
diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_mal_ganis.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_mal_ganis.cpp
index e16ed882171..0e1d6e966c5 100644
--- a/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_mal_ganis.cpp
+++ b/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_mal_ganis.cpp
@@ -66,7 +66,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_mal_ganisAI(creature);
+ return GetInstanceAI<boss_mal_ganisAI>(creature);
}
struct boss_mal_ganisAI : public ScriptedAI
@@ -102,15 +102,13 @@ public:
uiSleepTimer = urand(15000, 20000);
uiOutroTimer = 1000;
- if (instance)
- instance->SetData(DATA_MAL_GANIS_EVENT, NOT_STARTED);
+ instance->SetData(DATA_MAL_GANIS_EVENT, NOT_STARTED);
}
void EnterCombat(Unit* /*who*/) OVERRIDE
{
Talk(SAY_AGGRO);
- if (instance)
- instance->SetData(DATA_MAL_GANIS_EVENT, IN_PROGRESS);
+ instance->SetData(DATA_MAL_GANIS_EVENT, IN_PROGRESS);
}
void DamageTaken(Unit* done_by, uint32 &damage) OVERRIDE
@@ -154,8 +152,7 @@ public:
{
EnterEvadeMode();
me->DisappearAndDie();
- if (instance)
- instance->SetData(DATA_MAL_GANIS_EVENT, FAIL);
+ instance->SetData(DATA_MAL_GANIS_EVENT, FAIL);
}
if (uiCarrionSwarmTimer < diff)
@@ -228,13 +225,10 @@ public:
void JustDied(Unit* /*killer*/) OVERRIDE
{
- if (instance)
- {
- instance->SetData(DATA_MAL_GANIS_EVENT, DONE);
- DoCastAOE(SPELL_MAL_GANIS_KILL_CREDIT);
- // give achievement credit and LFG rewards to players. criteria use spell 58630 which doesn't exist, but it was created in spell_dbc
- DoCastAOE(SPELL_KILL_CREDIT);
- }
+ instance->SetData(DATA_MAL_GANIS_EVENT, DONE);
+ DoCastAOE(SPELL_MAL_GANIS_KILL_CREDIT);
+ // give achievement credit and LFG rewards to players. criteria use spell 58630 which doesn't exist, but it was created in spell_dbc
+ DoCastAOE(SPELL_KILL_CREDIT);
}
void KilledUnit(Unit* victim) OVERRIDE
diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_meathook.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_meathook.cpp
index aff076f4763..5b8ba2ad18c 100644
--- a/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_meathook.cpp
+++ b/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_meathook.cpp
@@ -51,7 +51,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_meathookAI(creature);
+ return GetInstanceAI<boss_meathookAI>(creature);
}
struct boss_meathookAI : public ScriptedAI
@@ -59,8 +59,7 @@ public:
boss_meathookAI(Creature* creature) : ScriptedAI(creature)
{
instance = creature->GetInstanceScript();
- if (instance)
- Talk(SAY_SPAWN);
+ Talk(SAY_SPAWN);
}
uint32 uiChainTimer;
@@ -75,16 +74,14 @@ public:
uiDiseaseTimer = urand(2000, 4000); //approx 3s
uiFrenzyTimer = urand(21000, 26000); //made it up
- if (instance)
- instance->SetData(DATA_MEATHOOK_EVENT, NOT_STARTED);
+ instance->SetData(DATA_MEATHOOK_EVENT, NOT_STARTED);
}
void EnterCombat(Unit* /*who*/) OVERRIDE
{
Talk(SAY_AGGRO);
- if (instance)
- instance->SetData(DATA_MEATHOOK_EVENT, IN_PROGRESS);
+ instance->SetData(DATA_MEATHOOK_EVENT, IN_PROGRESS);
}
void UpdateAI(uint32 diff) OVERRIDE
@@ -119,8 +116,7 @@ public:
{
Talk(SAY_DEATH);
- if (instance)
- instance->SetData(DATA_MEATHOOK_EVENT, DONE);
+ instance->SetData(DATA_MEATHOOK_EVENT, DONE);
}
void KilledUnit(Unit* victim) OVERRIDE
diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_salramm_the_fleshcrafter.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_salramm_the_fleshcrafter.cpp
index fc5b3c4a8b0..0716f71574c 100644
--- a/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_salramm_the_fleshcrafter.cpp
+++ b/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_salramm_the_fleshcrafter.cpp
@@ -56,7 +56,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_salrammAI(creature);
+ return GetInstanceAI<boss_salrammAI>(creature);
}
struct boss_salrammAI : public ScriptedAI
@@ -64,8 +64,7 @@ public:
boss_salrammAI(Creature* creature) : ScriptedAI(creature)
{
instance = creature->GetInstanceScript();
- if (instance)
- Talk(SAY_SPAWN);
+ Talk(SAY_SPAWN);
}
uint32 uiCurseFleshTimer;
@@ -84,16 +83,14 @@ public:
uiStealFleshTimer = 12345;
uiSummonGhoulsTimer = urand(19000, 24000); //on a video approx 24s after aggro
- if (instance)
- instance->SetData(DATA_SALRAMM_EVENT, NOT_STARTED);
+ instance->SetData(DATA_SALRAMM_EVENT, NOT_STARTED);
}
void EnterCombat(Unit* /*who*/) OVERRIDE
{
Talk(SAY_AGGRO);
- if (instance)
- instance->SetData(DATA_SALRAMM_EVENT, IN_PROGRESS);
+ instance->SetData(DATA_SALRAMM_EVENT, IN_PROGRESS);
}
void UpdateAI(uint32 diff) OVERRIDE
@@ -142,8 +139,7 @@ public:
{
Talk(SAY_DEATH);
- if (instance)
- instance->SetData(DATA_SALRAMM_EVENT, DONE);
+ instance->SetData(DATA_SALRAMM_EVENT, DONE);
}
void KilledUnit(Unit* victim) OVERRIDE
diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/culling_of_stratholme.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/culling_of_stratholme.cpp
index dbead663cff..e8f776d8a75 100644
--- a/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/culling_of_stratholme.cpp
+++ b/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/culling_of_stratholme.cpp
@@ -344,7 +344,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_arthasAI(creature);
+ return GetInstanceAI<npc_arthasAI>(creature);
}
struct npc_arthasAI : public npc_escortAI
@@ -399,22 +399,20 @@ public:
malganisGUID = 0;
infiniteGUID = 0;
- if (instance) {
- instance->SetData(DATA_ARTHAS_EVENT, NOT_STARTED);
- switch (instance->GetData(DATA_ARTHAS_EVENT))
- {
- case NOT_STARTED:
- bStepping = true;
- step = 0;
- me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
- bossEvent = DATA_MEATHOOK_EVENT;
- gossipStep = 0;
- break;
- }
- phaseTimer = 1000;
- exorcismTimer = 7300;
- wave = 0;
+ instance->SetData(DATA_ARTHAS_EVENT, NOT_STARTED);
+ switch (instance->GetData(DATA_ARTHAS_EVENT))
+ {
+ case NOT_STARTED:
+ bStepping = true;
+ step = 0;
+ me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
+ bossEvent = DATA_MEATHOOK_EVENT;
+ gossipStep = 0;
+ break;
}
+ phaseTimer = 1000;
+ exorcismTimer = 7300;
+ wave = 0;
}
void EnterCombat(Unit* /*who*/) OVERRIDE
@@ -424,8 +422,7 @@ public:
void JustDied(Unit* /*killer*/) OVERRIDE
{
- if (instance)
- instance->SetData(DATA_ARTHAS_EVENT, FAIL);
+ instance->SetData(DATA_ARTHAS_EVENT, FAIL);
}
void SpawnTimeRift(uint32 timeRiftID, uint64* guidVector)
@@ -559,9 +556,8 @@ public:
Talk(SAY_PHASE403);
break;
case 36:
- if (instance)
- if (GameObject* pGate = instance->instance->GetGameObject(instance->GetData64(DATA_SHKAF_GATE)))
- pGate->SetGoState(GO_STATE_ACTIVE);
+ if (GameObject* pGate = instance->instance->GetGameObject(instance->GetData64(DATA_SHKAF_GATE)))
+ pGate->SetGoState(GO_STATE_ACTIVE);
break;
case 45:
SetRun(true);
@@ -888,8 +884,7 @@ public:
Talk(SAY_PHASE209);
bossEvent = DATA_MEATHOOK_EVENT;
- if (instance)
- instance->SetData(DATA_ARTHAS_EVENT, IN_PROGRESS);
+ instance->SetData(DATA_ARTHAS_EVENT, IN_PROGRESS);
me->SetReactState(REACT_DEFENSIVE);
SetDespawnAtFar(false);
@@ -961,25 +956,22 @@ public:
break;
case 50: //Wait Boss death
case 60:
- if (instance)
+ if (instance->GetData(bossEvent) == DONE)
{
- if (instance->GetData(bossEvent) == DONE)
+ JumpToNextStep(1000);
+ if (bossEvent == DATA_MEATHOOK_EVENT)
+ bossEvent = DATA_SALRAMM_EVENT;
+ else if (bossEvent == DATA_SALRAMM_EVENT)
{
- JumpToNextStep(1000);
- if (bossEvent == DATA_MEATHOOK_EVENT)
- bossEvent = DATA_SALRAMM_EVENT;
- else if (bossEvent == DATA_SALRAMM_EVENT)
- {
- SetHoldState(false);
- bStepping = false;
- bossEvent = DATA_EPOCH_EVENT;
- }
+ SetHoldState(false);
+ bStepping = false;
+ bossEvent = DATA_EPOCH_EVENT;
}
- else if (instance->GetData(bossEvent) == FAIL)
- npc_escortAI::EnterEvadeMode();
- else
- phaseTimer = 10000;
}
+ else if (instance->GetData(bossEvent) == FAIL)
+ npc_escortAI::EnterEvadeMode();
+ else
+ phaseTimer = 10000;
break;
//After Gossip 2 (waypoint 22)
case 61:
@@ -1096,53 +1088,47 @@ public:
JumpToNextStep(1000);
break;
case 80:
- if (instance)
- if (instance->GetData(DATA_EPOCH_EVENT) != DONE)
- {
- SpawnTimeRift(17, &epochGUID);
- if (Creature* epoch = Unit::GetCreature(*me, epochGUID))
- epoch->AI()->Talk(SAY_PHASE314);
- me->SetTarget(epochGUID);
- }
+ if (instance->GetData(DATA_EPOCH_EVENT) != DONE)
+ {
+ SpawnTimeRift(17, &epochGUID);
+ if (Creature* epoch = Unit::GetCreature(*me, epochGUID))
+ epoch->AI()->Talk(SAY_PHASE314);
+ me->SetTarget(epochGUID);
+ }
JumpToNextStep(18000);
break;
case 81:
- if (instance)
- if (instance->GetData(DATA_EPOCH_EVENT) != DONE)
- Talk(SAY_PHASE315);
+ if (instance->GetData(DATA_EPOCH_EVENT) != DONE)
+ Talk(SAY_PHASE315);
JumpToNextStep(6000);
break;
case 82:
- if (instance)
- if (instance->GetData(DATA_EPOCH_EVENT) != DONE)
+ if (instance->GetData(DATA_EPOCH_EVENT) != DONE)
+ {
+ if (Creature* epoch = Unit::GetCreature(*me, epochGUID))
{
- if (Creature* epoch = Unit::GetCreature(*me, epochGUID))
- {
- //Make Epoch attackable
- epoch->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
- epoch->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
- epoch->SetReactState(REACT_AGGRESSIVE);
- }
-
+ //Make Epoch attackable
+ epoch->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
+ epoch->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
+ epoch->SetReactState(REACT_AGGRESSIVE);
}
+
+ }
JumpToNextStep(1000);
break;
case 83:
- if (instance)
+ if (instance->GetData(DATA_EPOCH_EVENT) == DONE)
{
- if (instance->GetData(DATA_EPOCH_EVENT) == DONE)
- {
- gossipStep = 3;
- me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
- bStepping = false;
- bossEvent = DATA_MAL_GANIS_EVENT;
- JumpToNextStep(15000);
- }
- else if (instance->GetData(DATA_EPOCH_EVENT) == FAIL)
- npc_escortAI::EnterEvadeMode();
- else
- phaseTimer = 10000;
+ gossipStep = 3;
+ me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
+ bStepping = false;
+ bossEvent = DATA_MAL_GANIS_EVENT;
+ JumpToNextStep(15000);
}
+ else if (instance->GetData(DATA_EPOCH_EVENT) == FAIL)
+ npc_escortAI::EnterEvadeMode();
+ else
+ phaseTimer = 10000;
break;
//After Gossip 4
case 84:
@@ -1158,9 +1144,8 @@ public:
malganisGUID = malganis->GetGUID();
malganis->SetReactState(REACT_PASSIVE);
}
- if (instance)
- if (GameObject* pGate = instance->instance->GetGameObject(instance->GetData64(DATA_MAL_GANIS_GATE_1)))
- pGate->SetGoState(GO_STATE_ACTIVE);
+ if (GameObject* pGate = instance->instance->GetGameObject(instance->GetData64(DATA_MAL_GANIS_GATE_1)))
+ pGate->SetGoState(GO_STATE_ACTIVE);
SetHoldState(false);
bStepping = false;
JumpToNextStep(0);
@@ -1180,18 +1165,15 @@ public:
JumpToNextStep(1000);
break;
case 88:
- if (instance)
+ if (instance->GetData(DATA_MAL_GANIS_EVENT) == DONE)
{
- if (instance->GetData(DATA_MAL_GANIS_EVENT) == DONE)
- {
- SetHoldState(false);
- JumpToNextStep(1000);
- }
- else if (instance->GetData(DATA_MAL_GANIS_EVENT) == FAIL)
- npc_escortAI::EnterEvadeMode();
- else
- phaseTimer = 10000;
+ SetHoldState(false);
+ JumpToNextStep(1000);
}
+ else if (instance->GetData(DATA_MAL_GANIS_EVENT) == FAIL)
+ npc_escortAI::EnterEvadeMode();
+ else
+ phaseTimer = 10000;
break;
//After waypoint 56
case 89:
@@ -1201,11 +1183,8 @@ public:
JumpToNextStep(7000);
break;
case 90:
- if (instance)
- {
- instance->SetData(DATA_ARTHAS_EVENT, DONE); //Rewards: Achiev & Chest ;D
- me->SetTarget(instance->GetData64(DATA_MAL_GANIS_GATE_2)); //Look behind
- }
+ instance->SetData(DATA_ARTHAS_EVENT, DONE); //Rewards: Achiev & Chest ;D
+ me->SetTarget(instance->GetData64(DATA_MAL_GANIS_GATE_2)); //Look behind
Talk(SAY_PHASE504);
bStepping = false;
break;
diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/boss_captain_skarloc.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/boss_captain_skarloc.cpp
index 3b51f6d0f8f..d69137060e0 100644
--- a/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/boss_captain_skarloc.cpp
+++ b/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/boss_captain_skarloc.cpp
@@ -54,7 +54,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_captain_skarlocAI(creature);
+ return GetInstanceAI<boss_captain_skarlocAI>(creature);
}
struct boss_captain_skarlocAI : public ScriptedAI
diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/boss_epoch_hunter.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/boss_epoch_hunter.cpp
index 3e650bf4fe9..0c20669775c 100644
--- a/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/boss_epoch_hunter.cpp
+++ b/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/boss_epoch_hunter.cpp
@@ -52,7 +52,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_epoch_hunterAI(creature);
+ return GetInstanceAI<boss_epoch_hunterAI>(creature);
}
struct boss_epoch_hunterAI : public ScriptedAI
@@ -104,7 +104,7 @@ public:
//Sand Breath
if (SandBreath_Timer <= diff)
{
- if (me->IsNonMeleeSpellCasted(false))
+ if (me->IsNonMeleeSpellCast(false))
me->InterruptNonMeleeSpells(false);
DoCastVictim(SPELL_SAND_BREATH);
diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/old_hillsbrad.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/old_hillsbrad.cpp
index bdf7d71a497..f4da323a746 100644
--- a/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/old_hillsbrad.cpp
+++ b/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/old_hillsbrad.cpp
@@ -188,7 +188,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_thrall_old_hillsbradAI(creature);
+ return GetInstanceAI<npc_thrall_old_hillsbradAI>(creature);
}
bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action) OVERRIDE
@@ -291,9 +291,6 @@ public:
void WaypointReached(uint32 waypointId) OVERRIDE
{
- if (!instance)
- return;
-
switch (waypointId)
{
case 8:
@@ -526,8 +523,7 @@ public:
}
void JustDied(Unit* slayer) OVERRIDE
{
- if (instance)
- instance->SetData(TYPE_THRALL_EVENT, FAIL);
+ instance->SetData(TYPE_THRALL_EVENT, FAIL);
// Don't do a yell if he kills self (if player goes too far or at the end).
if (slayer == me)
@@ -573,7 +569,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_tarethaAI(creature);
+ return GetInstanceAI<npc_tarethaAI>(creature);
}
bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action) OVERRIDE
diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/boss_aeonus.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/boss_aeonus.cpp
index c929a1b6a55..850dd3a10d7 100644
--- a/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/boss_aeonus.cpp
+++ b/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/boss_aeonus.cpp
@@ -90,16 +90,14 @@ public:
{
Talk(SAY_DEATH);
- if (instance)
- {
- instance->SetData(TYPE_RIFT, DONE);
- instance->SetData(TYPE_MEDIVH, DONE); // FIXME: later should be removed
- }
+ instance->SetData(TYPE_RIFT, DONE);
+ instance->SetData(TYPE_MEDIVH, DONE); // FIXME: later should be removed
}
- void KilledUnit(Unit* /*victim*/) OVERRIDE
+ void KilledUnit(Unit* who) OVERRIDE
{
- Talk(SAY_SLAY);
+ if (who->GetTypeId() == TYPEID_PLAYER)
+ Talk(SAY_SLAY);
}
void UpdateAI(uint32 diff) OVERRIDE
@@ -140,7 +138,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_aeonusAI(creature);
+ return GetInstanceAI<boss_aeonusAI>(creature);
}
};
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 fe91f3ab712..8910631dc5d 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
@@ -98,8 +98,7 @@ public:
{
Talk(SAY_DEATH);
- if (instance)
- instance->SetData(TYPE_RIFT, SPECIAL);
+ instance->SetData(TYPE_RIFT, SPECIAL);
}
void UpdateAI(uint32 diff) OVERRIDE
@@ -145,7 +144,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_chrono_lord_dejaAI(creature);
+ return GetInstanceAI<boss_chrono_lord_dejaAI>(creature);
}
};
diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/boss_temporus.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/boss_temporus.cpp
index 4d94edf7339..35ddfc2df3d 100644
--- a/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/boss_temporus.cpp
+++ b/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/boss_temporus.cpp
@@ -81,8 +81,7 @@ public:
{
Talk(SAY_DEATH);
- if (instance)
- instance->SetData(TYPE_RIFT, SPECIAL);
+ instance->SetData(TYPE_RIFT, SPECIAL);
}
void MoveInLineOfSight(Unit* who) OVERRIDE
@@ -143,7 +142,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_temporusAI(creature);
+ return GetInstanceAI<boss_temporusAI>(creature);
}
};
diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/the_black_morass.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/the_black_morass.cpp
index cc3cf8192dc..90e746367c2 100644
--- a/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/the_black_morass.cpp
+++ b/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/the_black_morass.cpp
@@ -70,7 +70,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_medivh_bmAI(creature);
+ return GetInstanceAI<npc_medivh_bmAI>(creature);
}
struct npc_medivh_bmAI : public ScriptedAI
@@ -97,9 +97,6 @@ public:
Life50 = true;
Life25 = true;
- if (!instance)
- return;
-
if (instance->GetData(TYPE_MEDIVH) == IN_PROGRESS)
DoCast(me, SPELL_CHANNEL, true);
else if (me->HasAura(SPELL_CHANNEL))
@@ -109,11 +106,7 @@ public:
}
void MoveInLineOfSight(Unit* who) OVERRIDE
-
{
- if (!instance)
- return;
-
if (who->GetTypeId() == TYPEID_PLAYER && me->IsWithinDistInMap(who, 10.0f))
{
if (instance->GetData(TYPE_MEDIVH) == IN_PROGRESS || instance->GetData(TYPE_MEDIVH) == DONE)
@@ -175,9 +168,6 @@ public:
void UpdateAI(uint32 diff) OVERRIDE
{
- if (!instance)
- return;
-
if (SpellCorrupt_Timer)
{
if (SpellCorrupt_Timer <= diff)
@@ -268,7 +258,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_time_riftAI(creature);
+ return GetInstanceAI<npc_time_riftAI>(creature);
}
struct npc_time_riftAI : public ScriptedAI
@@ -291,9 +281,6 @@ public:
TimeRiftWave_Timer = 15000;
mRiftWaveCount = 0;
- if (!instance)
- return;
-
mPortalCount = instance->GetData(DATA_PORTAL_COUNT);
if (mPortalCount < 6)
@@ -349,16 +336,13 @@ public:
void UpdateAI(uint32 diff) OVERRIDE
{
- if (!instance)
- return;
-
if (TimeRiftWave_Timer <= diff)
{
DoSelectSummon();
TimeRiftWave_Timer = 15000;
} else TimeRiftWave_Timer -= diff;
- if (me->IsNonMeleeSpellCasted(false))
+ if (me->IsNonMeleeSpellCast(false))
return;
TC_LOG_DEBUG("scripts", "npc_time_rift: not casting anylonger, i need to die.");
diff --git a/src/server/scripts/Kalimdor/OnyxiasLair/boss_onyxia.cpp b/src/server/scripts/Kalimdor/OnyxiasLair/boss_onyxia.cpp
index 79421ffe37e..aef232ab3f3 100644
--- a/src/server/scripts/Kalimdor/OnyxiasLair/boss_onyxia.cpp
+++ b/src/server/scripts/Kalimdor/OnyxiasLair/boss_onyxia.cpp
@@ -145,12 +145,9 @@ public:
SummonWhelpCount = 0;
IsMoving = false;
- if (instance)
- {
- instance->SetBossState(DATA_ONYXIA, NOT_STARTED);
- instance->SetData(DATA_ONYXIA_PHASE, Phase);
- instance->DoStopTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_TIMED_START_EVENT);
- }
+ instance->SetBossState(DATA_ONYXIA, NOT_STARTED);
+ instance->SetData(DATA_ONYXIA_PHASE, Phase);
+ instance->DoStopTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_TIMED_START_EVENT);
}
void EnterCombat(Unit* /*who*/) OVERRIDE
@@ -163,17 +160,13 @@ public:
events.ScheduleEvent(EVENT_CLEAVE, urand (2000, 5000));
events.ScheduleEvent(EVENT_WING_BUFFET, urand (10000, 20000));
- if (instance)
- {
- instance->SetBossState(DATA_ONYXIA, IN_PROGRESS);
- instance->DoStartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_TIMED_START_EVENT);
- }
+ instance->SetBossState(DATA_ONYXIA, IN_PROGRESS);
+ instance->DoStartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_TIMED_START_EVENT);
}
void JustDied(Unit* /*killer*/) OVERRIDE
{
- if (instance)
- instance->SetBossState(DATA_ONYXIA, DONE);
+ instance->SetBossState(DATA_ONYXIA, DONE);
Summons.DespawnAll();
}
@@ -246,8 +239,7 @@ public:
me->GetMotionMaster()->MovePoint(11, Phase2Location.GetPositionX(), Phase2Location.GetPositionY(), Phase2Location.GetPositionZ()+25);
me->SetSpeed(MOVE_FLIGHT, 1.0f);
Talk(SAY_PHASE_2_TRANS);
- if (instance)
- instance->SetData(DATA_ONYXIA_PHASE, Phase);
+ instance->SetData(DATA_ONYXIA_PHASE, Phase);
events.ScheduleEvent(EVENT_WHELP_SPAWN, 5000);
events.ScheduleEvent(EVENT_LAIR_GUARD, 15000);
break;
@@ -280,10 +272,7 @@ public:
(Spell->Id >= 22267 && Spell->Id <= 22268)) &&
(target->GetTypeId() == TYPEID_PLAYER))
{
- if (instance)
- {
instance->SetData(DATA_SHE_DEEP_BREATH_MORE, FAIL);
- }
}
}
@@ -383,8 +372,7 @@ public:
if (HealthBelowPct(40))
{
Phase = PHASE_END;
- if (instance)
- instance->SetData(DATA_ONYXIA_PHASE, PHASE_END);
+ instance->SetData(DATA_ONYXIA_PHASE, PHASE_END);
Talk(SAY_PHASE_3_TRANS);
SetCombatMovement(true);
@@ -404,7 +392,7 @@ public:
case EVENT_DEEP_BREATH: // Phase PHASE_BREATH
if (!IsMoving)
{
- if (me->IsNonMeleeSpellCasted(false))
+ if (me->IsNonMeleeSpellCast(false))
me->InterruptNonMeleeSpells(false);
Talk(EMOTE_BREATH);
@@ -469,7 +457,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_onyxiaAI(creature);
+ return GetInstanceAI<boss_onyxiaAI>(creature);
}
};
diff --git a/src/server/scripts/Kalimdor/RazorfenDowns/boss_amnennar_the_coldbringer.cpp b/src/server/scripts/Kalimdor/RazorfenDowns/boss_amnennar_the_coldbringer.cpp
index 323fd92a8f6..952ed5679f9 100644
--- a/src/server/scripts/Kalimdor/RazorfenDowns/boss_amnennar_the_coldbringer.cpp
+++ b/src/server/scripts/Kalimdor/RazorfenDowns/boss_amnennar_the_coldbringer.cpp
@@ -69,9 +69,10 @@ public:
Talk(SAY_AGGRO);
}
- void KilledUnit(Unit* /*victim*/) OVERRIDE
+ void KilledUnit(Unit* who) OVERRIDE
{
- Talk(SAY_KILL);
+ if (who->GetTypeId() == TYPEID_PLAYER)
+ Talk(SAY_KILL);
}
void JustDied(Unit* /*killer*/) OVERRIDE
diff --git a/src/server/scripts/Kalimdor/RazorfenDowns/razorfen_downs.cpp b/src/server/scripts/Kalimdor/RazorfenDowns/razorfen_downs.cpp
index abd76ebe508..6c4db288a0f 100644
--- a/src/server/scripts/Kalimdor/RazorfenDowns/razorfen_downs.cpp
+++ b/src/server/scripts/Kalimdor/RazorfenDowns/razorfen_downs.cpp
@@ -321,7 +321,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_belnistraszAI(creature);
+ return GetInstanceAI<npc_belnistraszAI>(creature);
}
};
@@ -341,9 +341,6 @@ public:
void SetData(uint32 /*type*/, uint32 data) OVERRIDE
{
- if (!instance)
- return;
-
if (data < 7)
{
me->SummonCreature(NPC_WITHERED_BATTLE_BOAR, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), me->GetOrientation());
@@ -362,7 +359,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_idol_room_spawnerAI(creature);
+ return GetInstanceAI<npc_idol_room_spawnerAI>(creature);
}
};
@@ -397,8 +394,7 @@ public:
void JustDied(Unit* /*killer*/) OVERRIDE
{
- if (instance)
- instance->SetData(DATA_WAVE, me->GetEntry());
+ instance->SetData(DATA_WAVE, me->GetEntry());
}
void EnterCombat(Unit* /*who*/) OVERRIDE
@@ -433,7 +429,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_tomb_creatureAI(creature);
+ return GetInstanceAI<npc_tomb_creatureAI>(creature);
}
};
diff --git a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_ayamiss.cpp b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_ayamiss.cpp
index 327fe0d1358..1cdcfae1139 100644
--- a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_ayamiss.cpp
+++ b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_ayamiss.cpp
@@ -232,7 +232,7 @@ class boss_ayamiss : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_ayamissAI(creature);
+ return GetInstanceAI<boss_ayamissAI>(creature);
}
};
@@ -286,7 +286,7 @@ class npc_hive_zara_larva : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_hive_zara_larvaAI(creature);
+ return GetInstanceAI<npc_hive_zara_larvaAI>(creature);
}
};
diff --git a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_buru.cpp b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_buru.cpp
index 0890a9804f9..ae4b42a4221 100644
--- a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_buru.cpp
+++ b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_buru.cpp
@@ -236,7 +236,7 @@ class npc_buru_egg : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_buru_eggAI(creature);
+ return GetInstanceAI<npc_buru_eggAI>(creature);
}
};
diff --git a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_kurinnaxx.cpp b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_kurinnaxx.cpp
index 0b58ded0b1c..09c4734dc49 100644
--- a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_kurinnaxx.cpp
+++ b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_kurinnaxx.cpp
@@ -127,7 +127,7 @@ class boss_kurinnaxx : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_kurinnaxxAI(creature);
+ return GetInstanceAI<boss_kurinnaxxAI>(creature);
}
};
diff --git a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_ossirian.cpp b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_ossirian.cpp
index 366f74f469e..06d193ee5b0 100644
--- a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_ossirian.cpp
+++ b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_ossirian.cpp
@@ -136,26 +136,23 @@ class boss_ossirian : public CreatureScript
DoCast(me, SPELL_SUPREME);
Talk(SAY_AGGRO);
- if (instance)
- {
- Map* map = me->GetMap();
- if (!map->IsDungeon())
- return;
+ Map* map = me->GetMap();
+ if (!map->IsDungeon())
+ return;
- WorldPacket data(SMSG_WEATHER, (4+4+4));
- data << uint32(WEATHER_STATE_HEAVY_SANDSTORM) << float(1) << uint8(0);
- map->SendToPlayers(&data);
+ WorldPacket data(SMSG_WEATHER, (4+4+4));
+ data << uint32(WEATHER_STATE_HEAVY_SANDSTORM) << float(1) << uint8(0);
+ map->SendToPlayers(&data);
- for (uint8 i = 0; i < NUM_TORNADOS; ++i)
- {
- Position Point;
- me->GetRandomPoint(RoomCenter, RoomRadius, Point);
- if (Creature* Tornado = me->GetMap()->SummonCreature(NPC_SAND_VORTEX, Point))
- Tornado->CastSpell(Tornado, SPELL_SAND_STORM, true);
- }
-
- SpawnNextCrystal();
+ for (uint8 i = 0; i < NUM_TORNADOS; ++i)
+ {
+ Position Point;
+ me->GetRandomPoint(RoomCenter, RoomRadius, Point);
+ if (Creature* Tornado = me->GetMap()->SummonCreature(NPC_SAND_VORTEX, Point))
+ Tornado->CastSpell(Tornado, SPELL_SAND_STORM, true);
}
+
+ SpawnNextCrystal();
}
void KilledUnit(Unit* /*victim*/) OVERRIDE
@@ -273,7 +270,7 @@ class boss_ossirian : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_ossirianAI(creature);
+ return GetInstanceAI<boss_ossirianAI>(creature);
}
};
diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_bug_trio.cpp b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_bug_trio.cpp
index 8dd009cdb32..5f0481431a8 100644
--- a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_bug_trio.cpp
+++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_bug_trio.cpp
@@ -32,7 +32,7 @@ enum Spells
SPELL_CLEAVE = 26350,
SPELL_TOXIC_VOLLEY = 25812,
SPELL_POISON_CLOUD = 38718, //Only Spell with right dmg.
- SPELL_ENRAGE = 34624, //Changed cause 25790 is casted on gamers too. Same prob with old explosion of twin emperors.
+ SPELL_ENRAGE = 34624, //Changed cause 25790 is cast on gamers too. Same prob with old explosion of twin emperors.
SPELL_CHARGE = 26561,
SPELL_KNOCKBACK = 26027,
@@ -48,7 +48,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_kriAI(creature);
+ return GetInstanceAI<boss_kriAI>(creature);
}
struct boss_kriAI : public ScriptedAI
@@ -83,14 +83,10 @@ public:
void JustDied(Unit* /*killer*/) OVERRIDE
{
- if (instance)
- {
- if (instance->GetData(DATA_BUG_TRIO_DEATH) < 2)
- // Unlootable if death
- me->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
+ if (instance->GetData(DATA_BUG_TRIO_DEATH) < 2)// Unlootable if death
+ me->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
- instance->SetData(DATA_BUG_TRIO_DEATH, 1);
- }
+ instance->SetData(DATA_BUG_TRIO_DEATH, 1);
}
void UpdateAI(uint32 diff) OVERRIDE
{
@@ -145,7 +141,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_vemAI(creature);
+ return GetInstanceAI<boss_vemAI>(creature);
}
struct boss_vemAI : public ScriptedAI
@@ -174,14 +170,10 @@ public:
void JustDied(Unit* /*killer*/) OVERRIDE
{
- if (instance)
- {
- instance->SetData(DATA_VEM_DEATH, 0);
- if (instance->GetData(DATA_BUG_TRIO_DEATH) < 2)
- // Unlootable if death
- me->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
- instance->SetData(DATA_BUG_TRIO_DEATH, 1);
- }
+ instance->SetData(DATA_VEM_DEATH, 0);
+ if (instance->GetData(DATA_BUG_TRIO_DEATH) < 2)// Unlootable if death
+ me->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
+ instance->SetData(DATA_BUG_TRIO_DEATH, 1);
}
void EnterCombat(Unit* /*who*/) OVERRIDE
@@ -238,7 +230,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_yaujAI(creature);
+ return GetInstanceAI<boss_yaujAI>(creature);
}
struct boss_yaujAI : public ScriptedAI
@@ -267,13 +259,9 @@ public:
void JustDied(Unit* /*killer*/) OVERRIDE
{
- if (instance)
- {
- if (instance->GetData(DATA_BUG_TRIO_DEATH) < 2)
- // Unlootable if death
- me->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
- instance->SetData(DATA_BUG_TRIO_DEATH, 1);
- }
+ if (instance->GetData(DATA_BUG_TRIO_DEATH) < 2)// Unlootable if death
+ me->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
+ instance->SetData(DATA_BUG_TRIO_DEATH, 1);
for (uint8 i = 0; i < 10; ++i)
{
@@ -306,22 +294,19 @@ public:
//Casting Heal to other twins or herself.
if (Heal_Timer <= diff)
{
- if (instance)
+ switch (urand(0, 2))
{
- switch (urand(0, 2))
- {
- case 0:
- if (Creature* kri = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_KRI)))
- DoCast(kri, SPELL_HEAL);
- break;
- case 1:
- if (Creature* vem = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_VEM)))
- DoCast(vem, SPELL_HEAL);
- break;
- case 2:
- DoCast(me, SPELL_HEAL);
- break;
- }
+ case 0:
+ if (Creature* kri = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_KRI)))
+ DoCast(kri, SPELL_HEAL);
+ break;
+ case 1:
+ if (Creature* vem = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_VEM)))
+ DoCast(vem, SPELL_HEAL);
+ break;
+ case 2:
+ DoCast(me, SPELL_HEAL);
+ break;
}
Heal_Timer = 15000+rand()%15000;
@@ -332,13 +317,10 @@ public:
{
if (!VemDead)
{
- if (instance)
+ if (instance->GetData(DATA_VEMISDEAD))
{
- if (instance->GetData(DATA_VEMISDEAD))
- {
- DoCast(me, SPELL_ENRAGE);
- VemDead = true;
- }
+ DoCast(me, SPELL_ENRAGE);
+ VemDead = true;
}
}
Check_Timer = 2000;
diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp
index d2b5b5eaf8c..67b093a2c38 100644
--- a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp
+++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp
@@ -153,7 +153,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new eye_of_cthunAI(creature);
+ return GetInstanceAI<eye_of_cthunAI>(creature);
}
struct eye_of_cthunAI : public ScriptedAI
@@ -161,8 +161,6 @@ public:
eye_of_cthunAI(Creature* creature) : ScriptedAI(creature)
{
instance = creature->GetInstanceScript();
- if (!instance)
- TC_LOG_ERROR("scripts", "No Instance eye_of_cthunAI");
SetCombatMovement(false);
}
@@ -206,8 +204,7 @@ public:
me->SetVisible(true);
//Reset Phase
- if (instance)
- instance->SetData(DATA_CTHUN_PHASE, PHASE_NOT_STARTED);
+ instance->SetData(DATA_CTHUN_PHASE, PHASE_NOT_STARTED);
//to avoid having a following void zone
Creature* pPortal= me->FindNearestCreature(NPC_CTHUN_PORTAL, 10);
@@ -218,8 +215,7 @@ public:
void EnterCombat(Unit* /*who*/) OVERRIDE
{
DoZoneInCombat();
- if (instance)
- instance->SetData(DATA_CTHUN_PHASE, PHASE_EYE_GREEN_BEAM);
+ instance->SetData(DATA_CTHUN_PHASE, PHASE_EYE_GREEN_BEAM);
}
void SpawnEyeTentacle(float x, float y)
@@ -236,10 +232,6 @@ public:
if (!UpdateVictim())
return;
- //No instance
- if (!instance)
- return;
-
uint32 currentPhase = instance->GetData(DATA_CTHUN_PHASE);
if (currentPhase == PHASE_EYE_GREEN_BEAM || currentPhase == PHASE_EYE_RED_BEAM)
{
@@ -404,10 +396,6 @@ public:
void DamageTaken(Unit* /*done_by*/, uint32 &damage) OVERRIDE
{
- //No instance
- if (!instance)
- return;
-
switch (instance->GetData(DATA_CTHUN_PHASE))
{
case PHASE_EYE_GREEN_BEAM:
@@ -459,7 +447,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new cthunAI(creature);
+ return GetInstanceAI<cthunAI>(creature);
}
struct cthunAI : public ScriptedAI
@@ -469,8 +457,6 @@ public:
SetCombatMovement(false);
instance = creature->GetInstanceScript();
- if (!instance)
- TC_LOG_ERROR("scripts", "No Instance eye_of_cthunAI");
}
InstanceScript* instance;
@@ -528,8 +514,7 @@ public:
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_NON_ATTACKABLE);
me->SetVisible(false);
- if (instance)
- instance->SetData(DATA_CTHUN_PHASE, PHASE_NOT_STARTED);
+ instance->SetData(DATA_CTHUN_PHASE, PHASE_NOT_STARTED);
}
void EnterCombat(Unit* /*who*/) OVERRIDE
@@ -615,10 +600,6 @@ public:
me->SetTarget(0);
- //No instance
- if (!instance)
- return;
-
uint32 currentPhase = instance->GetData(DATA_CTHUN_PHASE);
if (currentPhase == PHASE_CTHUN_STOMACH || currentPhase == PHASE_CTHUN_WEAK)
{
@@ -861,16 +842,11 @@ public:
void JustDied(Unit* /*killer*/) OVERRIDE
{
- if (instance)
- instance->SetData(DATA_CTHUN_PHASE, PHASE_CTHUN_DONE);
+ instance->SetData(DATA_CTHUN_PHASE, PHASE_CTHUN_DONE);
}
void DamageTaken(Unit* /*done_by*/, uint32 &damage) OVERRIDE
{
- //No instance
- if (!instance)
- return;
-
switch (instance->GetData(DATA_CTHUN_PHASE))
{
case PHASE_CTHUN_STOMACH:
diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_sartura.cpp b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_sartura.cpp
index a3edd9ad83d..f640173efb2 100644
--- a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_sartura.cpp
+++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_sartura.cpp
@@ -160,7 +160,7 @@ public:
//If she is 20% enrage
if (!Enraged)
{
- if (!HealthAbovePct(20) && !me->IsNonMeleeSpellCasted(false))
+ if (!HealthAbovePct(20) && !me->IsNonMeleeSpellCast(false))
{
DoCast(me, SPELL_ENRAGE);
Enraged = true;
diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_twinemperors.cpp b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_twinemperors.cpp
index 1d888f3ce8b..90207746838 100644
--- a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_twinemperors.cpp
+++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_twinemperors.cpp
@@ -80,7 +80,7 @@ struct boss_twinemperorsAI : public ScriptedAI
uint32 AfterTeleportTimer;
bool DontYellWhenDead;
uint32 Abuse_Bug_Timer, BugsTimer;
- bool tspellcasted;
+ bool tspellcast;
uint32 EnrageTimer;
virtual bool IAmVeklor() = 0;
@@ -92,7 +92,7 @@ struct boss_twinemperorsAI : public ScriptedAI
Heal_Timer = 0; // first heal immediately when they get close together
Teleport_Timer = TELEPORTTIME;
AfterTeleport = false;
- tspellcasted = false;
+ tspellcast = false;
AfterTeleportTimer = 0;
Abuse_Bug_Timer = urand(10000, 17000);
BugsTimer = 2000;
@@ -103,10 +103,7 @@ struct boss_twinemperorsAI : public ScriptedAI
Creature* GetOtherBoss()
{
- if (instance)
- return Unit::GetCreature(*me, instance->GetData64(IAmVeklor() ? DATA_VEKNILASH : DATA_VEKLOR));
- else
- return NULL;
+ return Unit::GetCreature(*me, instance->GetData64(IAmVeklor() ? DATA_VEKNILASH : DATA_VEKLOR));
}
void DamageTaken(Unit* /*done_by*/, uint32 &damage) OVERRIDE
@@ -210,9 +207,6 @@ struct boss_twinemperorsAI : public ScriptedAI
void TeleportToMyBrother()
{
- if (!instance)
- return;
-
Teleport_Timer = TELEPORTTIME;
if (IAmVeklor())
@@ -243,21 +237,21 @@ struct boss_twinemperorsAI : public ScriptedAI
me->AddUnitState(UNIT_STATE_STUNNED);
AfterTeleport = true;
AfterTeleportTimer = 2000;
- tspellcasted = false;
+ tspellcast = false;
}
bool TryActivateAfterTTelep(uint32 diff)
{
if (AfterTeleport)
{
- if (!tspellcasted)
+ if (!tspellcast)
{
me->ClearUnitState(UNIT_STATE_STUNNED);
DoCast(me, SPELL_TWIN_TELEPORT);
me->AddUnitState(UNIT_STATE_STUNNED);
}
- tspellcasted = true;
+ tspellcast = true;
if (AfterTeleportTimer <= diff)
{
@@ -378,7 +372,7 @@ struct boss_twinemperorsAI : public ScriptedAI
{
if (EnrageTimer <= diff)
{
- if (!me->IsNonMeleeSpellCasted(true))
+ if (!me->IsNonMeleeSpellCast(true))
{
DoCast(me, SPELL_BERSERK);
EnrageTimer = 60*60000;
@@ -394,7 +388,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_veknilashAI(creature);
+ return GetInstanceAI<boss_veknilashAI>(creature);
}
struct boss_veknilashAI : public boss_twinemperorsAI
@@ -480,7 +474,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_veklorAI(creature);
+ return GetInstanceAI<boss_veklorAI>(creature);
}
struct boss_veklorAI : public boss_twinemperorsAI
diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_viscidus.cpp b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_viscidus.cpp
index 115d9d0d12c..18dcc718848 100644
--- a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_viscidus.cpp
+++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_viscidus.cpp
@@ -263,8 +263,6 @@ class npc_glob_of_viscidus : public CreatureScript
void JustDied(Unit* /*killer*/) OVERRIDE
{
InstanceScript* Instance = me->GetInstanceScript();
- if (!Instance)
- return;
if (Creature* Viscidus = me->GetMap()->GetCreature(Instance->GetData64(DATA_VISCIDUS)))
{
@@ -289,14 +287,15 @@ class npc_glob_of_viscidus : public CreatureScript
if (id == ROOM_CENTER)
{
DoCast(me, SPELL_REJOIN_VISCIDUS);
- ((TempSummon*)me)->UnSummon();
+ if (TempSummon* summon = me->ToTempSummon())
+ summon->UnSummon();
}
}
};
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_glob_of_viscidusAI(creature);
+ return GetInstanceAI<npc_glob_of_viscidusAI>(creature);
}
};
diff --git a/src/server/scripts/Kalimdor/WailingCaverns/wailing_caverns.cpp b/src/server/scripts/Kalimdor/WailingCaverns/wailing_caverns.cpp
index a985f353976..9d4a6f54c31 100644
--- a/src/server/scripts/Kalimdor/WailingCaverns/wailing_caverns.cpp
+++ b/src/server/scripts/Kalimdor/WailingCaverns/wailing_caverns.cpp
@@ -81,7 +81,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_disciple_of_naralexAI(creature);
+ return GetInstanceAI<npc_disciple_of_naralexAI>(creature);
}
bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action) OVERRIDE
@@ -152,9 +152,6 @@ public:
void WaypointReached(uint32 waypointId) OVERRIDE
{
- if (!instance)
- return;
-
switch (waypointId)
{
case 4:
@@ -194,13 +191,10 @@ public:
void JustDied(Unit* /*slayer*/) OVERRIDE
{
- if (instance)
- {
- instance->SetData(TYPE_NARALEX_EVENT, FAIL);
- instance->SetData(TYPE_NARALEX_PART1, FAIL);
- instance->SetData(TYPE_NARALEX_PART2, FAIL);
- instance->SetData(TYPE_NARALEX_PART3, FAIL);
- }
+ instance->SetData(TYPE_NARALEX_EVENT, FAIL);
+ instance->SetData(TYPE_NARALEX_PART1, FAIL);
+ instance->SetData(TYPE_NARALEX_PART2, FAIL);
+ instance->SetData(TYPE_NARALEX_PART3, FAIL);
}
void JustSummoned(Creature* summoned) OVERRIDE
@@ -213,8 +207,6 @@ public:
if (currentEvent != TYPE_NARALEX_PART3)
npc_escortAI::UpdateAI(diff);
- if (!instance)
- return;
if (eventTimer <= diff)
{
eventTimer = 0;
diff --git a/src/server/scripts/Kalimdor/ZulFarrak/boss_zum_rah.cpp b/src/server/scripts/Kalimdor/ZulFarrak/boss_zum_rah.cpp
index bc31fd118be..23cf3f56c35 100644
--- a/src/server/scripts/Kalimdor/ZulFarrak/boss_zum_rah.cpp
+++ b/src/server/scripts/Kalimdor/ZulFarrak/boss_zum_rah.cpp
@@ -78,8 +78,7 @@ public:
void JustDied(Unit* /*killer*/) OVERRIDE
{
- if (instance)
- instance->SetData(DATA_ZUM_RAH, DONE);
+ instance->SetData(DATA_ZUM_RAH, DONE);
}
void KilledUnit(Unit* /*victim*/) OVERRIDE
@@ -150,7 +149,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_zum_rahAI(creature);
+ return GetInstanceAI<boss_zum_rahAI>(creature);
}
};
diff --git a/src/server/scripts/Kalimdor/ZulFarrak/zulfarrak.cpp b/src/server/scripts/Kalimdor/ZulFarrak/zulfarrak.cpp
index a2f98b21589..2fe443fd0a3 100644
--- a/src/server/scripts/Kalimdor/ZulFarrak/zulfarrak.cpp
+++ b/src/server/scripts/Kalimdor/ZulFarrak/zulfarrak.cpp
@@ -97,7 +97,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_sergeant_blyAI(creature);
+ return GetInstanceAI<npc_sergeant_blyAI>(creature);
}
struct npc_sergeant_blyAI : public ScriptedAI
@@ -148,12 +148,9 @@ public:
if (Player* target = ObjectAccessor::GetPlayer(*me, PlayerGUID))
AttackStart(target);
- if (instance)
- {
- switchFactionIfAlive(instance, ENTRY_RAVEN);
- switchFactionIfAlive(instance, ENTRY_ORO);
- switchFactionIfAlive(instance, ENTRY_MURTA);
- }
+ switchFactionIfAlive(instance, ENTRY_RAVEN);
+ switchFactionIfAlive(instance, ENTRY_ORO);
+ switchFactionIfAlive(instance, ENTRY_MURTA);
}
postGossipStep++;
}
@@ -296,7 +293,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_weegli_blastfuseAI(creature);
+ return GetInstanceAI<npc_weegli_blastfuseAI>(creature);
}
struct npc_weegli_blastfuseAI : public ScriptedAI
@@ -316,8 +313,7 @@ public:
void Reset() OVERRIDE
{
- /*if (instance)
- instance->SetData(0, NOT_STARTED);*/
+ /*instance->SetData(0, NOT_STARTED);*/
}
void AttackStart(Unit* victim) OVERRIDE
@@ -327,8 +323,7 @@ public:
void JustDied(Unit* /*killer*/) OVERRIDE
{
- /*if (instance)
- instance->SetData(0, DONE);*/
+ /*instance->SetData(0, DONE);*/
}
void UpdateAI(uint32 diff) OVERRIDE
@@ -358,22 +353,19 @@ public:
void MovementInform(uint32 /*type*/, uint32 /*id*/) OVERRIDE
{
- if (instance)
+ if (instance->GetData(EVENT_PYRAMID) == PYRAMID_CAGES_OPEN)
{
- if (instance->GetData(EVENT_PYRAMID) == PYRAMID_CAGES_OPEN)
- {
- instance->SetData(EVENT_PYRAMID, PYRAMID_ARRIVED_AT_STAIR);
- Talk(SAY_WEEGLI_OHNO);
- me->SetHomePosition(1882.69f, 1272.28f, 41.87f, 0);
- }
- else
- if (destroyingDoor)
- {
- instance->DoUseDoorOrButton(instance->GetData64(GO_END_DOOR));
- /// @todo leave the area...
- me->DespawnOrUnsummon();
- };
+ instance->SetData(EVENT_PYRAMID, PYRAMID_ARRIVED_AT_STAIR);
+ Talk(SAY_WEEGLI_OHNO);
+ me->SetHomePosition(1882.69f, 1272.28f, 41.87f, 0);
}
+ else
+ if (destroyingDoor)
+ {
+ instance->DoUseDoorOrButton(instance->GetData64(GO_END_DOOR));
+ /// @todo leave the area...
+ me->DespawnOrUnsummon();
+ };
}
void DoAction(int32 /*param*/) OVERRIDE
diff --git a/src/server/scripts/Kalimdor/zone_ashenvale.cpp b/src/server/scripts/Kalimdor/zone_ashenvale.cpp
index b4aeced5e9b..8304f5ba9e4 100644
--- a/src/server/scripts/Kalimdor/zone_ashenvale.cpp
+++ b/src/server/scripts/Kalimdor/zone_ashenvale.cpp
@@ -37,133 +37,118 @@ EndContentData */
# npc_torek
####*/
-enum TorekSays
+enum Torek
{
SAY_READY = 0,
SAY_MOVE = 1,
SAY_PREPARE = 2,
SAY_WIN = 3,
SAY_END = 4,
+ SPELL_REND = 11977,
+ SPELL_THUNDERCLAP = 8078,
+ QUEST_TOREK_ASSULT = 6544,
+ NPC_SPLINTERTREE_RAIDER = 12859,
+ NPC_DURIEL = 12860,
+ NPC_SILVERWING_SENTINEL = 12896,
+ NPC_SILVERWING_WARRIOR = 12897,
+ FACTION_QUEST = 113
};
-enum TorekSpells
+class npc_torek : public CreatureScript
{
- SPELL_REND = 11977,
- SPELL_THUNDERCLAP = 8078,
-};
+public:
+ npc_torek() : CreatureScript("npc_torek") { }
-enum TorekMisc
-{
- QUEST_TOREK_ASSULT = 6544,
+ struct npc_torekAI : public npc_escortAI
+ {
+ npc_torekAI(Creature* creature) : npc_escortAI(creature) { }
- ENTRY_SPLINTERTREE_RAIDER = 12859,
- ENTRY_DURIEL = 12860,
- ENTRY_SILVERWING_SENTINEL = 12896,
- ENTRY_SILVERWING_WARRIOR = 12897,
-};
+ void Reset() OVERRIDE
+ {
+ rend_Timer = 5000;
+ thunderclap_Timer = 8000;
+ _completed = false;
+ }
-class npc_torek : public CreatureScript
-{
- public:
+ void EnterCombat(Unit* /*who*/) OVERRIDE { }
- npc_torek() : CreatureScript("npc_torek")
+ void JustSummoned(Creature* summoned) OVERRIDE
{
+ summoned->AI()->AttackStart(me);
}
- struct npc_torekAI : public npc_escortAI
+ void sQuestAccept(Player* player, Quest const* quest)
{
- npc_torekAI(Creature* creature) : npc_escortAI(creature) { }
-
- uint32 Rend_Timer;
- uint32 Thunderclap_Timer;
- bool Completed;
+ if (quest->GetQuestId() == QUEST_TOREK_ASSULT)
+ {
+ /// @todo find companions, make them follow Torek, at any time (possibly done by core/database in future?)
+ Talk(SAY_READY, player);
+ me->setFaction(FACTION_QUEST);
+ npc_escortAI::Start(true, true, player->GetGUID());
+ }
+ }
- void WaypointReached(uint32 waypointId) OVERRIDE
+ void WaypointReached(uint32 waypointId) OVERRIDE
+ {
+ if (Player* player = GetPlayerForEscort())
{
- if (Player* player = GetPlayerForEscort())
+ switch (waypointId)
{
- switch (waypointId)
- {
- case 1:
- Talk(SAY_MOVE, player);
- break;
- case 8:
- Talk(SAY_PREPARE, player);
- break;
- case 19:
- /// @todo verify location and creatures amount.
- me->SummonCreature(ENTRY_DURIEL, 1776.73f, -2049.06f, 109.83f, 1.54f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 25000);
- me->SummonCreature(ENTRY_SILVERWING_SENTINEL, 1774.64f, -2049.41f, 109.83f, 1.40f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 25000);
- me->SummonCreature(ENTRY_SILVERWING_WARRIOR, 1778.73f, -2049.50f, 109.83f, 1.67f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 25000);
- break;
- case 20:
- Talk(SAY_WIN, player);
- Completed = true;
- player->GroupEventHappens(QUEST_TOREK_ASSULT, me);
- break;
- case 21:
- Talk(SAY_END, player);
- break;
- }
+ case 1:
+ Talk(SAY_MOVE, player);
+ break;
+ case 8:
+ Talk(SAY_PREPARE, player);
+ break;
+ case 19:
+ /// @todo verify location and creatures amount.
+ me->SummonCreature(NPC_DURIEL, 1776.73f, -2049.06f, 109.83f, 1.54f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 25000);
+ me->SummonCreature(NPC_SILVERWING_SENTINEL, 1774.64f, -2049.41f, 109.83f, 1.40f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 25000);
+ me->SummonCreature(NPC_SILVERWING_WARRIOR, 1778.73f, -2049.50f, 109.83f, 1.67f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 25000);
+ break;
+ case 20:
+ Talk(SAY_WIN, player);
+ _completed = true;
+ player->GroupEventHappens(QUEST_TOREK_ASSULT, me);
+ break;
+ case 21:
+ Talk(SAY_END, player);
+ break;
}
}
+ }
- void Reset() OVERRIDE
- {
- Rend_Timer = 5000;
- Thunderclap_Timer = 8000;
- Completed = false;
- }
+ void UpdateAI(uint32 diff) OVERRIDE
+ {
+ npc_escortAI::UpdateAI(diff);
- void EnterCombat(Unit* /*who*/) OVERRIDE
- {
- }
+ if (!UpdateVictim())
+ return;
- void JustSummoned(Creature* summoned) OVERRIDE
+ if (rend_Timer <= diff)
{
- summoned->AI()->AttackStart(me);
- }
+ DoCastVictim(SPELL_REND);
+ rend_Timer = 20000;
+ } else rend_Timer -= diff;
- void UpdateAI(uint32 diff) OVERRIDE
+ if (thunderclap_Timer <= diff)
{
- npc_escortAI::UpdateAI(diff);
-
- if (!UpdateVictim())
- return;
-
- if (Rend_Timer <= diff)
- {
- DoCastVictim(SPELL_REND);
- Rend_Timer = 20000;
- } else Rend_Timer -= diff;
-
- if (Thunderclap_Timer <= diff)
- {
- DoCast(me, SPELL_THUNDERCLAP);
- Thunderclap_Timer = 30000;
- } else Thunderclap_Timer -= diff;
- }
- };
-
- CreatureAI* GetAI(Creature* creature) const OVERRIDE
- {
- return new npc_torekAI(creature);
+ DoCast(me, SPELL_THUNDERCLAP);
+ thunderclap_Timer = 30000;
+ } else thunderclap_Timer -= diff;
}
- bool OnQuestAccept(Player* player, Creature* creature, Quest const* quest) OVERRIDE
- {
- if (quest->GetQuestId() == QUEST_TOREK_ASSULT)
- {
- /// @todo find companions, make them follow Torek, at any time (possibly done by core/database in future?)
- creature->AI()->Talk(SAY_READY, player);
- creature->setFaction(113);
+ private:
+ uint32 rend_Timer;
+ uint32 thunderclap_Timer;
+ bool _completed;
- if (npc_escortAI* pEscortAI = CAST_AI(npc_torekAI, creature->AI()))
- pEscortAI->Start(true, true, player->GetGUID());
- }
+ };
- return true;
- }
+ CreatureAI* GetAI(Creature* creature) const OVERRIDE
+ {
+ return new npc_torekAI(creature);
+ }
};
/*####
@@ -175,96 +160,90 @@ enum RuulSnowhoof
NPC_THISTLEFUR_URSA = 3921,
NPC_THISTLEFUR_TOTEMIC = 3922,
NPC_THISTLEFUR_PATHFINDER = 3926,
-
QUEST_FREEDOM_TO_RUUL = 6482,
-
GO_CAGE = 178147
};
Position const RuulSnowhoofSummonsCoord[6] =
{
- {3449.218018f, -587.825073f, 174.978867f, 4.714445f},
- {3446.384521f, -587.830872f, 175.186279f, 4.714445f},
- {3444.218994f, -587.835327f, 175.380600f, 4.714445f},
- {3508.344482f, -492.024261f, 186.929031f, 4.145029f},
- {3506.265625f, -490.531006f, 186.740128f, 4.239277f},
- {3503.682373f, -489.393799f, 186.629684f, 4.349232f}
+ { 3449.218018f, -587.825073f, 174.978867f, 4.714445f },
+ { 3446.384521f, -587.830872f, 175.186279f, 4.714445f },
+ { 3444.218994f, -587.835327f, 175.380600f, 4.714445f },
+ { 3508.344482f, -492.024261f, 186.929031f, 4.145029f },
+ { 3506.265625f, -490.531006f, 186.740128f, 4.239277f },
+ { 3503.682373f, -489.393799f, 186.629684f, 4.349232f }
};
class npc_ruul_snowhoof : public CreatureScript
{
- public:
- npc_ruul_snowhoof() : CreatureScript("npc_ruul_snowhoof") { }
+public:
+ npc_ruul_snowhoof() : CreatureScript("npc_ruul_snowhoof") { }
- struct npc_ruul_snowhoofAI : public npc_escortAI
- {
- npc_ruul_snowhoofAI(Creature* creature) : npc_escortAI(creature) { }
+ struct npc_ruul_snowhoofAI : public npc_escortAI
+ {
+ npc_ruul_snowhoofAI(Creature* creature) : npc_escortAI(creature) { }
- void WaypointReached(uint32 waypointId) OVERRIDE
- {
- Player* player = GetPlayerForEscort();
- if (!player)
- return;
+ void Reset() OVERRIDE
+ {
+ if (GameObject* Cage = me->FindNearestGameObject(GO_CAGE, 20))
+ Cage->SetGoState(GO_STATE_READY);
+ }
- switch (waypointId)
- {
- case 0:
- me->SetUInt32Value(UNIT_FIELD_BYTES_1, 0);
- if (GameObject* Cage = me->FindNearestGameObject(GO_CAGE, 20))
- Cage->SetGoState(GO_STATE_ACTIVE);
- break;
- case 13:
- me->SummonCreature(NPC_THISTLEFUR_TOTEMIC, RuulSnowhoofSummonsCoord[0], TEMPSUMMON_DEAD_DESPAWN, 60000);
- me->SummonCreature(NPC_THISTLEFUR_URSA, RuulSnowhoofSummonsCoord[1], TEMPSUMMON_DEAD_DESPAWN, 60000);
- me->SummonCreature(NPC_THISTLEFUR_PATHFINDER, RuulSnowhoofSummonsCoord[2], TEMPSUMMON_DEAD_DESPAWN, 60000);
- break;
- case 19:
- me->SummonCreature(NPC_THISTLEFUR_TOTEMIC, RuulSnowhoofSummonsCoord[3], TEMPSUMMON_DEAD_DESPAWN, 60000);
- me->SummonCreature(NPC_THISTLEFUR_URSA, RuulSnowhoofSummonsCoord[4], TEMPSUMMON_DEAD_DESPAWN, 60000);
- me->SummonCreature(NPC_THISTLEFUR_PATHFINDER, RuulSnowhoofSummonsCoord[5], TEMPSUMMON_DEAD_DESPAWN, 60000);
- break;
- case 21:
- player->GroupEventHappens(QUEST_FREEDOM_TO_RUUL, me);
- break;
- }
- }
+ void EnterCombat(Unit* /*who*/) OVERRIDE { }
- void EnterCombat(Unit* /*who*/) OVERRIDE { }
+ void JustSummoned(Creature* summoned) OVERRIDE
+ {
+ summoned->AI()->AttackStart(me);
+ }
- void Reset() OVERRIDE
+ void sQuestAccept(Player* player, Quest const* quest)
+ {
+ if (quest->GetQuestId() == QUEST_TOREK_ASSULT)
{
- if (GameObject* Cage = me->FindNearestGameObject(GO_CAGE, 20))
- Cage->SetGoState(GO_STATE_READY);
+ me->setFaction(FACTION_QUEST);
+ npc_escortAI::Start(true, false, player->GetGUID());
}
+ }
- void JustSummoned(Creature* summoned) OVERRIDE
- {
- summoned->AI()->AttackStart(me);
- }
+ void WaypointReached(uint32 waypointId) OVERRIDE
+ {
+ Player* player = GetPlayerForEscort();
+ if (!player)
+ return;
- void UpdateAI(uint32 diff) OVERRIDE
+ switch (waypointId)
{
- npc_escortAI::UpdateAI(diff);
+ case 0:
+ me->SetUInt32Value(UNIT_FIELD_BYTES_1, 0);
+ if (GameObject* Cage = me->FindNearestGameObject(GO_CAGE, 20))
+ Cage->SetGoState(GO_STATE_ACTIVE);
+ break;
+ case 13:
+ me->SummonCreature(NPC_THISTLEFUR_TOTEMIC, RuulSnowhoofSummonsCoord[0], TEMPSUMMON_DEAD_DESPAWN, 60000);
+ me->SummonCreature(NPC_THISTLEFUR_URSA, RuulSnowhoofSummonsCoord[1], TEMPSUMMON_DEAD_DESPAWN, 60000);
+ me->SummonCreature(NPC_THISTLEFUR_PATHFINDER, RuulSnowhoofSummonsCoord[2], TEMPSUMMON_DEAD_DESPAWN, 60000);
+ break;
+ case 19:
+ me->SummonCreature(NPC_THISTLEFUR_TOTEMIC, RuulSnowhoofSummonsCoord[3], TEMPSUMMON_DEAD_DESPAWN, 60000);
+ me->SummonCreature(NPC_THISTLEFUR_URSA, RuulSnowhoofSummonsCoord[4], TEMPSUMMON_DEAD_DESPAWN, 60000);
+ me->SummonCreature(NPC_THISTLEFUR_PATHFINDER, RuulSnowhoofSummonsCoord[5], TEMPSUMMON_DEAD_DESPAWN, 60000);
+ break;
+ case 21:
+ player->GroupEventHappens(QUEST_FREEDOM_TO_RUUL, me);
+ break;
}
- };
-
- CreatureAI* GetAI(Creature* creature) const OVERRIDE
- {
- return new npc_ruul_snowhoofAI(creature);
}
- bool OnQuestAccept(Player* player, Creature* creature, Quest const* quest) OVERRIDE
+ void UpdateAI(uint32 diff) OVERRIDE
{
- if (quest->GetQuestId() == QUEST_FREEDOM_TO_RUUL)
- {
- creature->setFaction(113);
-
- if (npc_escortAI* pEscortAI = CAST_AI(npc_ruul_snowhoofAI, (creature->AI())))
- pEscortAI->Start(true, false, player->GetGUID());
- }
-
- return true;
+ npc_escortAI::UpdateAI(diff);
}
+ };
+
+ CreatureAI* GetAI(Creature* creature) const OVERRIDE
+ {
+ return new npc_ruul_snowhoofAI(creature);
+ }
};
enum Muglash
@@ -298,37 +277,68 @@ enum Muglash
Position const FirstNagaCoord[3] =
{
- {3603.504150f, 1122.631104f, 1.635f, 0.0f}, // rider
- {3589.293945f, 1148.664063f, 5.565f, 0.0f}, // sorceress
- {3609.925537f, 1168.759521f, -1.168f, 0.0f} // razortail
+ { 3603.504150f, 1122.631104f, 1.635f, 0.0f }, // rider
+ { 3589.293945f, 1148.664063f, 5.565f, 0.0f }, // sorceress
+ { 3609.925537f, 1168.759521f, -1.168f, 0.0f } // razortail
};
Position const SecondNagaCoord[3] =
{
- {3609.925537f, 1168.759521f, -1.168f, 0.0f}, // witch
- {3645.652100f, 1139.425415f, 1.322f, 0.0f}, // priest
- {3583.602051f, 1128.405762f, 2.347f, 0.0f} // myrmidon
+ { 3609.925537f, 1168.759521f, -1.168f, 0.0f }, // witch
+ { 3645.652100f, 1139.425415f, 1.322f, 0.0f }, // priest
+ { 3583.602051f, 1128.405762f, 2.347f, 0.0f } // myrmidon
};
Position const VorshaCoord = {3633.056885f, 1172.924072f, -5.388f, 0.0f};
class npc_muglash : public CreatureScript
{
- public:
- npc_muglash() : CreatureScript("npc_muglash") { }
+public:
+ npc_muglash() : CreatureScript("npc_muglash") { }
+
+ struct npc_muglashAI : public npc_escortAI
+ {
+ npc_muglashAI(Creature* creature) : npc_escortAI(creature) { }
+
+ void Reset() OVERRIDE
+ {
+ eventTimer = 10000;
+ waveId = 0;
+ _isBrazierExtinguished = false;
+ }
+
+ void EnterCombat(Unit* /*who*/) OVERRIDE
+ {
+ if (Player* player = GetPlayerForEscort())
+ if (HasEscortState(STATE_ESCORT_PAUSED))
+ {
+ if (urand(0, 1))
+ Talk(SAY_MUG_ON_GUARD, player);
+ return;
+ }
+ }
- struct npc_muglashAI : public npc_escortAI
+ void JustDied(Unit* /*killer*/) OVERRIDE
{
- npc_muglashAI(Creature* creature) : npc_escortAI(creature) { }
+ if (HasEscortState(STATE_ESCORT_ESCORTING))
+ if (Player* player = GetPlayerForEscort())
+ player->FailQuest(QUEST_VORSHA);
+ }
- uint8 WaveId;
- uint32 EventTimer;
- bool IsBrazierExtinguished;
+ void JustSummoned(Creature* summoned) OVERRIDE
+ {
+ summoned->AI()->AttackStart(me);
+ }
- void JustSummoned(Creature* summoned) OVERRIDE
+ void sQuestAccept(Player* player, Quest const* quest)
+ {
+ if (quest->GetQuestId() == QUEST_VORSHA)
{
- summoned->AI()->AttackStart(me);
+ Talk(SAY_MUG_START1);
+ me->setFaction(FACTION_QUEST);
+ npc_escortAI::Start(true, false, player->GetGUID());
}
+ }
void WaypointReached(uint32 waypointId) OVERRIDE
{
@@ -362,34 +372,9 @@ class npc_muglash : public CreatureScript
}
}
- void EnterCombat(Unit* /*who*/) OVERRIDE
- {
- if (Player* player = GetPlayerForEscort())
- if (HasEscortState(STATE_ESCORT_PAUSED))
- {
- if (urand(0, 1))
- Talk(SAY_MUG_ON_GUARD, player);
- return;
- }
- }
-
- void Reset() OVERRIDE
- {
- EventTimer = 10000;
- WaveId = 0;
- IsBrazierExtinguished = false;
- }
-
- void JustDied(Unit* /*killer*/) OVERRIDE
- {
- if (HasEscortState(STATE_ESCORT_ESCORTING))
- if (Player* player = GetPlayerForEscort())
- player->FailQuest(QUEST_VORSHA);
- }
-
void DoWaveSummon()
{
- switch (WaveId)
+ switch (waveId)
{
case 1:
me->SummonCreature(NPC_WRATH_RIDER, FirstNagaCoord[0], TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000);
@@ -411,48 +396,40 @@ class npc_muglash : public CreatureScript
}
}
- void UpdateAI(uint32 uiDiff) OVERRIDE
+ void UpdateAI(uint32 diff) OVERRIDE
{
- npc_escortAI::UpdateAI(uiDiff);
+ npc_escortAI::UpdateAI(diff);
if (!me->GetVictim())
{
- if (HasEscortState(STATE_ESCORT_PAUSED) && IsBrazierExtinguished)
+ if (HasEscortState(STATE_ESCORT_PAUSED) && _isBrazierExtinguished)
{
- if (EventTimer < uiDiff)
+ if (eventTimer < diff)
{
- ++WaveId;
+ ++waveId;
DoWaveSummon();
- EventTimer = 10000;
+ eventTimer = 10000;
}
else
- EventTimer -= uiDiff;
+ eventTimer -= diff;
}
return;
}
DoMeleeAttackIfReady();
}
- };
- CreatureAI* GetAI(Creature* creature) const OVERRIDE
- {
- return new npc_muglashAI(creature);
- }
+ private:
+ uint32 eventTimer;
+ uint8 waveId;
+ public:
+ bool _isBrazierExtinguished;
- bool OnQuestAccept(Player* player, Creature* creature, Quest const* quest) OVERRIDE
- {
- if (quest->GetQuestId() == QUEST_VORSHA)
- {
- if (npc_muglashAI* pEscortAI = CAST_AI(npc_muglashAI, creature->AI()))
- {
- creature->AI()->Talk(SAY_MUG_START1);
- creature->setFaction(113);
+ };
- pEscortAI->Start(true, false, player->GetGUID());
- }
- }
- return true;
- }
+ CreatureAI* GetAI(Creature* creature) const OVERRIDE
+ {
+ return new npc_muglashAI(creature);
+ }
};
class go_naga_brazier : public GameObjectScript
@@ -468,7 +445,7 @@ class go_naga_brazier : public GameObjectScript
{
creature->AI()->Talk(SAY_MUG_BRAZIER_WAIT);
- pEscortAI->IsBrazierExtinguished = true;
+ pEscortAI->_isBrazierExtinguished = true;
return false;
}
}
diff --git a/src/server/scripts/Kalimdor/zone_azuremyst_isle.cpp b/src/server/scripts/Kalimdor/zone_azuremyst_isle.cpp
index c2ae69373a0..c225c3a8576 100644
--- a/src/server/scripts/Kalimdor/zone_azuremyst_isle.cpp
+++ b/src/server/scripts/Kalimdor/zone_azuremyst_isle.cpp
@@ -48,9 +48,7 @@ EndContentData */
enum draeneiSurvivor
{
SAY_HEAL = 0,
-
SAY_HELP = 1,
-
SPELL_IRRIDATION = 35046,
SPELL_STUNNED = 28630
};
@@ -60,11 +58,6 @@ class npc_draenei_survivor : public CreatureScript
public:
npc_draenei_survivor() : CreatureScript("npc_draenei_survivor") { }
- CreatureAI* GetAI(Creature* creature) const OVERRIDE
- {
- return new npc_draenei_survivorAI(creature);
- }
-
struct npc_draenei_survivorAI : public ScriptedAI
{
npc_draenei_survivorAI(Creature* creature) : ScriptedAI(creature) { }
@@ -167,6 +160,10 @@ public:
}
};
+ CreatureAI* GetAI(Creature* creature) const OVERRIDE
+ {
+ return new npc_draenei_survivorAI(creature);
+ }
};
/*######
@@ -186,39 +183,11 @@ enum Overgrind
SPELL_DYNAMITE = 7978
};
-#define GOSSIP_FIGHT "Traitor! You will be brought to justice!"
-
class npc_engineer_spark_overgrind : public CreatureScript
{
public:
npc_engineer_spark_overgrind() : CreatureScript("npc_engineer_spark_overgrind") { }
- bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action) OVERRIDE
- {
- player->PlayerTalkClass->ClearMenus();
- if (action == GOSSIP_ACTION_INFO_DEF)
- {
- player->CLOSE_GOSSIP_MENU();
- creature->setFaction(FACTION_HOSTILE);
- CAST_AI(npc_engineer_spark_overgrind::npc_engineer_spark_overgrindAI, creature->AI())->AttackStart(player);
- }
- return true;
- }
-
- bool OnGossipHello(Player* player, Creature* creature) OVERRIDE
- {
- if (player->GetQuestStatus(QUEST_GNOMERCY) == QUEST_STATUS_INCOMPLETE)
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_FIGHT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF);
-
- player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID());
- return true;
- }
-
- CreatureAI* GetAI(Creature* creature) const OVERRIDE
- {
- return new npc_engineer_spark_overgrindAI(creature);
- }
-
struct npc_engineer_spark_overgrindAI : public ScriptedAI
{
npc_engineer_spark_overgrindAI(Creature* creature) : ScriptedAI(creature)
@@ -230,14 +199,6 @@ public:
IsTreeEvent = true;
}
- uint32 NormFaction;
- uint32 NpcFlags;
-
- uint32 DynamiteTimer;
- uint32 EmoteTimer;
-
- bool IsTreeEvent;
-
void Reset() OVERRIDE
{
DynamiteTimer = 8000;
@@ -254,6 +215,13 @@ public:
Talk(ATTACK_YELL, who);
}
+ void sGossipSelect(Player* player, uint32 /*sender*/, uint32 /*action*/) OVERRIDE
+ {
+ player->CLOSE_GOSSIP_MENU();
+ me->setFaction(FACTION_HOSTILE);
+ me->Attack(player, true);
+ }
+
void UpdateAI(uint32 diff) OVERRIDE
{
if (!me->IsInCombat() && !IsTreeEvent)
@@ -279,8 +247,19 @@ public:
DoMeleeAttackIfReady();
}
+
+ private:
+ uint32 NormFaction;
+ uint32 NpcFlags;
+ uint32 DynamiteTimer;
+ uint32 EmoteTimer;
+ bool IsTreeEvent;
};
+ CreatureAI* GetAI(Creature* creature) const OVERRIDE
+ {
+ return new npc_engineer_spark_overgrindAI(creature);
+ }
};
/*######
@@ -292,11 +271,6 @@ class npc_injured_draenei : public CreatureScript
public:
npc_injured_draenei() : CreatureScript("npc_injured_draenei") { }
- CreatureAI* GetAI(Creature* creature) const OVERRIDE
- {
- return new npc_injured_draeneiAI(creature);
- }
-
struct npc_injured_draeneiAI : public ScriptedAI
{
npc_injured_draeneiAI(Creature* creature) : ScriptedAI(creature) { }
@@ -321,10 +295,13 @@ public:
void MoveInLineOfSight(Unit* /*who*/) OVERRIDE { }
-
void UpdateAI(uint32 /*diff*/) OVERRIDE { }
};
+ CreatureAI* GetAI(Creature* creature) const OVERRIDE
+ {
+ return new npc_injured_draeneiAI(creature);
+ }
};
/*######
@@ -339,8 +316,8 @@ enum Magwin
SAY_END1 = 3,
SAY_END2 = 4,
EMOTE_HUG = 5,
-
- QUEST_A_CRY_FOR_SAY_HELP = 9528
+ QUEST_A_CRY_FOR_SAY_HELP = 9528,
+ FACTION_QUEST = 113
};
class npc_magwin : public CreatureScript
@@ -348,25 +325,25 @@ class npc_magwin : public CreatureScript
public:
npc_magwin() : CreatureScript("npc_magwin") { }
- bool OnQuestAccept(Player* player, Creature* creature, Quest const* quest) OVERRIDE
+ struct npc_magwinAI : public npc_escortAI
{
- if (quest->GetQuestId() == QUEST_A_CRY_FOR_SAY_HELP)
+ npc_magwinAI(Creature* creature) : npc_escortAI(creature) { }
+
+ void Reset() OVERRIDE { }
+
+ void EnterCombat(Unit* who) OVERRIDE
{
- creature->setFaction(113);
- if (npc_escortAI* pEscortAI = CAST_AI(npc_escortAI, creature->AI()))
- pEscortAI->Start(true, false, player->GetGUID());
+ Talk(SAY_AGGRO, who);
}
- return true;
- }
- CreatureAI* GetAI(Creature* creature) const OVERRIDE
- {
- return new npc_magwinAI(creature);
- }
-
- struct npc_magwinAI : public npc_escortAI
- {
- npc_magwinAI(Creature* creature) : npc_escortAI(creature) { }
+ void sQuestAccept(Player* player, Quest const* quest)
+ {
+ if (quest->GetQuestId() == QUEST_A_CRY_FOR_SAY_HELP)
+ {
+ me->setFaction(FACTION_QUEST);
+ npc_escortAI::Start(true, false, player->GetGUID());
+ }
+ }
void WaypointReached(uint32 waypointId) OVERRIDE
{
@@ -391,15 +368,12 @@ public:
}
}
}
-
- void EnterCombat(Unit* who) OVERRIDE
- {
- Talk(SAY_AGGRO, who);
- }
-
- void Reset() OVERRIDE { }
};
+ CreatureAI* GetAI(Creature* creature) const OVERRIDE
+ {
+ return new npc_magwinAI(creature);
+ }
};
/*######
@@ -433,11 +407,6 @@ class npc_geezle : public CreatureScript
public:
npc_geezle() : CreatureScript("npc_geezle") { }
- CreatureAI* GetAI(Creature* creature) const OVERRIDE
- {
- return new npc_geezleAI(creature);
- }
-
struct npc_geezleAI : public ScriptedAI
{
npc_geezleAI(Creature* creature) : ScriptedAI(creature) { }
@@ -568,6 +537,10 @@ public:
}
};
+ CreatureAI* GetAI(Creature* creature) const OVERRIDE
+ {
+ return new npc_geezleAI(creature);
+ }
};
enum RavegerCage
@@ -606,11 +579,6 @@ class npc_death_ravager : public CreatureScript
public:
npc_death_ravager() : CreatureScript("npc_death_ravager") { }
- CreatureAI* GetAI(Creature* creature) const OVERRIDE
- {
- return new npc_death_ravagerAI(creature);
- }
-
struct npc_death_ravagerAI : public ScriptedAI
{
npc_death_ravagerAI(Creature* creature) : ScriptedAI(creature){ }
@@ -650,6 +618,10 @@ public:
}
};
+ CreatureAI* GetAI(Creature* creature) const OVERRIDE
+ {
+ return new npc_death_ravagerAI(creature);
+ }
};
/*########
diff --git a/src/server/scripts/Kalimdor/zone_bloodmyst_isle.cpp b/src/server/scripts/Kalimdor/zone_bloodmyst_isle.cpp
index 694d63d5295..f71c07b5c7d 100644
--- a/src/server/scripts/Kalimdor/zone_bloodmyst_isle.cpp
+++ b/src/server/scripts/Kalimdor/zone_bloodmyst_isle.cpp
@@ -19,18 +19,18 @@
/* ScriptData
SDName: Bloodmyst_Isle
SD%Complete: 80
-SDComment: Quest support: 9670, 9756(gossip items text needed).
+SDComment: Quest support: 9670, 9667
SDCategory: Bloodmyst Isle
EndScriptData */
/* ContentData
npc_webbed_creature
-npc_captured_sunhawk_agent
+npc_princess_stillpine
+go_princess_stillpines_cage
EndContentData */
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
-#include "ScriptedGossip.h"
#include "Player.h"
/*######
@@ -40,16 +40,16 @@ EndContentData */
//possible creatures to be spawned
uint32 const possibleSpawns[32] = {17322, 17661, 17496, 17522, 17340, 17352, 17333, 17524, 17654, 17348, 17339, 17345, 17359, 17353, 17336, 17550, 17330, 17701, 17321, 17680, 17325, 17320, 17683, 17342, 17715, 17334, 17341, 17338, 17337, 17346, 17344, 17327};
+enum WebbedCreature
+{
+ NPC_EXPEDITION_RESEARCHER = 17681
+};
+
class npc_webbed_creature : public CreatureScript
{
public:
npc_webbed_creature() : CreatureScript("npc_webbed_creature") { }
- CreatureAI* GetAI(Creature* creature) const OVERRIDE
- {
- return new npc_webbed_creatureAI(creature);
- }
-
struct npc_webbed_creatureAI : public ScriptedAI
{
npc_webbed_creatureAI(Creature* creature) : ScriptedAI(creature) { }
@@ -65,9 +65,8 @@ public:
switch (urand(0, 2))
{
case 0:
- spawnCreatureID = 17681;
if (Player* player = killer->ToPlayer())
- player->KilledMonsterCredit(spawnCreatureID, 0);
+ player->KilledMonsterCredit(NPC_EXPEDITION_RESEARCHER, 0);
break;
case 1:
case 2:
@@ -80,72 +79,10 @@ public:
}
};
-};
-
-/*######
-## npc_captured_sunhawk_agent
-######*/
-
-#define C_SUNHAWK_TRIGGER 17974
-
-#define GOSSIP_HELLO_CSA "[PH] "
-#define GOSSIP_SELECT_CSA1 "[PH] "
-#define GOSSIP_SELECT_CSA2 "[PH] "
-#define GOSSIP_SELECT_CSA3 "[PH] "
-#define GOSSIP_SELECT_CSA4 "[PH] "
-#define GOSSIP_SELECT_CSA5 "[PH] "
-
-class npc_captured_sunhawk_agent : public CreatureScript
-{
-public:
- npc_captured_sunhawk_agent() : CreatureScript("npc_captured_sunhawk_agent") { }
-
- bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action) OVERRIDE
- {
- player->PlayerTalkClass->ClearMenus();
- switch (action)
- {
- case GOSSIP_ACTION_INFO_DEF+1:
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_SELECT_CSA1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2);
- player->SEND_GOSSIP_MENU(9137, creature->GetGUID());
- break;
- case GOSSIP_ACTION_INFO_DEF+2:
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_SELECT_CSA2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3);
- player->SEND_GOSSIP_MENU(9138, creature->GetGUID());
- break;
- case GOSSIP_ACTION_INFO_DEF+3:
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_SELECT_CSA3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+4);
- player->SEND_GOSSIP_MENU(9139, creature->GetGUID());
- break;
- case GOSSIP_ACTION_INFO_DEF+4:
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_SELECT_CSA4, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+5);
- player->SEND_GOSSIP_MENU(9140, creature->GetGUID());
- break;
- case GOSSIP_ACTION_INFO_DEF+5:
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_SELECT_CSA5, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+6);
- player->SEND_GOSSIP_MENU(9141, creature->GetGUID());
- break;
- case GOSSIP_ACTION_INFO_DEF+6:
- player->CLOSE_GOSSIP_MENU();
- player->TalkedToCreature(C_SUNHAWK_TRIGGER, creature->GetGUID());
- break;
- }
- return true;
- }
-
- bool OnGossipHello(Player* player, Creature* creature) OVERRIDE
+ CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- if (player->HasAura(31609) && player->GetQuestStatus(9756) == QUEST_STATUS_INCOMPLETE)
- {
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HELLO_CSA, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
- player->SEND_GOSSIP_MENU(9136, creature->GetGUID());
- }
- else
- player->SEND_GOSSIP_MENU(9134, creature->GetGUID());
-
- return true;
+ return new npc_webbed_creatureAI(creature);
}
-
};
/*######
@@ -206,7 +143,6 @@ public:
void AddSC_bloodmyst_isle()
{
new npc_webbed_creature();
- new npc_captured_sunhawk_agent();
new npc_princess_stillpine();
new go_princess_stillpines_cage();
}
diff --git a/src/server/scripts/Kalimdor/zone_desolace.cpp b/src/server/scripts/Kalimdor/zone_desolace.cpp
index 4590b21f132..4f11a2ee169 100644
--- a/src/server/scripts/Kalimdor/zone_desolace.cpp
+++ b/src/server/scripts/Kalimdor/zone_desolace.cpp
@@ -59,18 +59,6 @@ class npc_aged_dying_ancient_kodo : public CreatureScript
public:
npc_aged_dying_ancient_kodo() : CreatureScript("npc_aged_dying_ancient_kodo") { }
- bool OnGossipHello(Player* player, Creature* creature)
- {
- if (player->HasAura(SPELL_KODO_KOMBO_PLAYER_BUFF) && creature->HasAura(SPELL_KODO_KOMBO_DESPAWN_BUFF))
- {
- player->TalkedToCreature(creature->GetEntry(), 0);
- player->RemoveAurasDueToSpell(SPELL_KODO_KOMBO_PLAYER_BUFF);
- }
-
- player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID());
- return true;
- }
-
struct npc_aged_dying_ancient_kodoAI : public ScriptedAI
{
npc_aged_dying_ancient_kodoAI(Creature* creature) : ScriptedAI(creature) { }
@@ -108,6 +96,18 @@ public:
}
};
+ bool OnGossipHello(Player* player, Creature* creature) OVERRIDE
+ {
+ if (player->HasAura(SPELL_KODO_KOMBO_PLAYER_BUFF) && creature->HasAura(SPELL_KODO_KOMBO_DESPAWN_BUFF))
+ {
+ player->TalkedToCreature(creature->GetEntry(), 0);
+ player->RemoveAurasDueToSpell(SPELL_KODO_KOMBO_PLAYER_BUFF);
+ }
+
+ player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID());
+ return true;
+ }
+
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
return new npc_aged_dying_ancient_kodoAI(creature);
@@ -122,8 +122,7 @@ public:
enum DemonPortal
{
NPC_DEMON_GUARDIAN = 11937,
-
- QUEST_PORTAL_OF_THE_LEGION = 5581,
+ QUEST_PORTAL_OF_THE_LEGION = 5581
};
class go_demon_portal : public GameObjectScript
diff --git a/src/server/scripts/Kalimdor/zone_the_barrens.cpp b/src/server/scripts/Kalimdor/zone_the_barrens.cpp
index 49b557e9fab..849f72d2fc8 100644
--- a/src/server/scripts/Kalimdor/zone_the_barrens.cpp
+++ b/src/server/scripts/Kalimdor/zone_the_barrens.cpp
@@ -340,10 +340,7 @@ public:
BigWill = 0;
}
- void EnterCombat(Unit* /*who*/) OVERRIDE { }
-
void MoveInLineOfSight(Unit* who) OVERRIDE
-
{
if (!who || !who->IsAlive() || EventInProgress)
return;
@@ -357,8 +354,6 @@ public:
}
}
- void KilledUnit(Unit* /*victim*/) OVERRIDE { }
-
void UpdateAI(uint32 diff) OVERRIDE
{
if (EventInProgress)
diff --git a/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_herald_volazj.cpp b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_herald_volazj.cpp
index 5bb68a4c886..51b234846ad 100644
--- a/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_herald_volazj.cpp
+++ b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_herald_volazj.cpp
@@ -33,7 +33,7 @@ enum Spells
SPELL_MIND_FLAY = 57941,
SPELL_SHADOW_BOLT_VOLLEY = 57942,
SPELL_SHIVER = 57949,
- SPELL_CLONE_PLAYER = 57507, //casted on player during insanity
+ SPELL_CLONE_PLAYER = 57507, //cast on player during insanity
SPELL_INSANITY_PHASING_1 = 57508,
SPELL_INSANITY_PHASING_2 = 57509,
SPELL_INSANITY_PHASING_3 = 57510,
@@ -149,11 +149,8 @@ public:
uiShadowBoltVolleyTimer = 5*IN_MILLISECONDS;
uiShiverTimer = 15*IN_MILLISECONDS;
- if (instance)
- {
- instance->SetBossState(DATA_HERALD_VOLAZJ, NOT_STARTED);
- instance->DoStopTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_QUICK_DEMISE_START_EVENT);
- }
+ instance->SetBossState(DATA_HERALD_VOLAZJ, NOT_STARTED);
+ instance->DoStopTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_QUICK_DEMISE_START_EVENT);
// Visible for all players in insanity
me->SetPhaseMask((1|16|32|64|128|256), true);
@@ -172,11 +169,8 @@ public:
{
Talk(SAY_AGGRO);
- if (instance)
- {
- instance->SetBossState(DATA_HERALD_VOLAZJ, IN_PROGRESS);
- instance->DoStartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_QUICK_DEMISE_START_EVENT);
- }
+ instance->SetBossState(DATA_HERALD_VOLAZJ, IN_PROGRESS);
+ instance->DoStartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_QUICK_DEMISE_START_EVENT);
}
void JustSummoned(Creature* summon) OVERRIDE
@@ -295,22 +289,22 @@ public:
{
Talk(SAY_DEATH);
- if (instance)
- instance->SetBossState(DATA_HERALD_VOLAZJ, DONE);
+ instance->SetBossState(DATA_HERALD_VOLAZJ, DONE);
Summons.DespawnAll();
ResetPlayersPhaseMask();
}
- void KilledUnit(Unit* /*victim*/) OVERRIDE
+ void KilledUnit(Unit* who) OVERRIDE
{
- Talk(SAY_SLAY);
+ if (who->GetTypeId() == TYPEID_PLAYER)
+ Talk(SAY_SLAY);
}
};
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_volazjAI(creature);
+ return GetInstanceAI<boss_volazjAI>(creature);
}
};
diff --git a/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_jedoga_shadowseeker.cpp b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_jedoga_shadowseeker.cpp
index a68a122bc31..5cf57c18bcf 100644
--- a/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_jedoga_shadowseeker.cpp
+++ b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_jedoga_shadowseeker.cpp
@@ -101,15 +101,12 @@ public:
bCanDown = false;
volunteerWork = true;
- if (instance)
- {
- if (!bFirstTime)
- instance->SetBossState(DATA_JEDOGA_SHADOWSEEKER, FAIL);
+ if (!bFirstTime)
+ instance->SetBossState(DATA_JEDOGA_SHADOWSEEKER, FAIL);
- instance->SetData64(DATA_PL_JEDOGA_TARGET, 0);
- instance->SetData64(DATA_ADD_JEDOGA_OPFER, 0);
- instance->SetData(DATA_JEDOGA_RESET_INITIANDS, 0);
- }
+ instance->SetData64(DATA_PL_JEDOGA_TARGET, 0);
+ instance->SetData64(DATA_ADD_JEDOGA_OPFER, 0);
+ instance->SetData(DATA_JEDOGA_RESET_INITIANDS, 0);
MoveUp();
bFirstTime = false;
@@ -144,8 +141,7 @@ public:
void JustDied(Unit* /*killer*/) OVERRIDE
{
Talk(TEXT_DEATH);
- if (instance)
- instance->SetBossState(DATA_JEDOGA_SHADOWSEEKER, DONE);
+ instance->SetBossState(DATA_JEDOGA_SHADOWSEEKER, DONE);
}
void DoAction(int32 action) OVERRIDE
@@ -197,9 +193,6 @@ public:
void MoveDown()
{
- if (!instance)
- return;
-
bOpFerokFail = false;
instance->SetData(DATA_JEDOGA_TRIGGER_SWITCH, 0);
@@ -233,9 +226,6 @@ public:
void MoveUp()
{
- if (!instance)
- return;
-
me->ApplySpellImmune(0, IMMUNITY_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, true);
me->ApplySpellImmune(0, IMMUNITY_DAMAGE, SPELL_SCHOOL_MASK_MAGIC, true);
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE + UNIT_FLAG_NON_ATTACKABLE);
@@ -255,9 +245,6 @@ public:
void OpferRufen()
{
- if (!instance)
- return;
-
uint64 opfer = instance->GetData64(DATA_ADD_JEDOGA_INITIAND);
if (opfer)
@@ -281,9 +268,6 @@ public:
void UpdateAI(uint32 diff) OVERRIDE
{
- if (!instance)
- return;
-
if (instance->GetBossState(DATA_JEDOGA_SHADOWSEEKER) != IN_PROGRESS && instance->GetData(DATA_ALL_INITIAND_DEAD))
MoveDown();
@@ -337,7 +321,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_jedoga_shadowseekerAI(creature);
+ return GetInstanceAI<boss_jedoga_shadowseekerAI>(creature);
}
};
@@ -361,9 +345,6 @@ public:
void Reset() OVERRIDE
{
- if (!instance)
- return;
-
bWalking = false;
bCheckTimer = 2*IN_MILLISECONDS;
@@ -503,7 +484,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_jedoga_initiandAI(creature);
+ return GetInstanceAI<npc_jedoga_initiandAI>(creature);
}
};
@@ -528,8 +509,8 @@ public:
instance = creature->GetInstanceScript();
bRemoved = false;
bRemoved2 = false;
- bCasted = false;
- bCasted2 = false;
+ bCast = false;
+ bCast2 = false;
SetCombatMovement(false);
}
@@ -538,8 +519,8 @@ public:
bool bRemoved;
bool bRemoved2;
- bool bCasted;
- bool bCasted2;
+ bool bCast;
+ bool bCast2;
void Reset() OVERRIDE { }
void EnterCombat(Unit* /*who*/) OVERRIDE { }
@@ -549,9 +530,6 @@ public:
void UpdateAI(uint32 /*diff*/) OVERRIDE
{
- if (!instance)
- return;
-
if (!bRemoved && me->GetPositionX() > 440.0f)
{
if (instance->GetBossState(DATA_PRINCE_TALDARAM) == DONE)
@@ -560,23 +538,23 @@ public:
bRemoved = true;
return;
}
- if (!bCasted)
+ if (!bCast)
{
DoCast(me, SPELL_BEAM_VISUAL_JEDOGAS_AUFSEHER_1, false);
- bCasted = true;
+ bCast = true;
}
}
if (!bRemoved2 && me->GetPositionX() < 440.0f)
{
- if (!bCasted2 && instance->GetData(DATA_JEDOGA_TRIGGER_SWITCH))
+ if (!bCast2 && instance->GetData(DATA_JEDOGA_TRIGGER_SWITCH))
{
DoCast(me, SPELL_BEAM_VISUAL_JEDOGAS_AUFSEHER_2, false);
- bCasted2 = true;
+ bCast2 = true;
}
- if (bCasted2 && !instance->GetData(DATA_JEDOGA_TRIGGER_SWITCH))
+ if (bCast2 && !instance->GetData(DATA_JEDOGA_TRIGGER_SWITCH))
{
me->InterruptNonMeleeSpells(true);
- bCasted2 = false;
+ bCast2 = false;
}
if (!bRemoved2 && instance->GetBossState(DATA_JEDOGA_SHADOWSEEKER) == DONE)
{
@@ -589,7 +567,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_jedogas_aufseher_triggerAI(creature);
+ return GetInstanceAI<npc_jedogas_aufseher_triggerAI>(creature);
}
};
diff --git a/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_anubarak.cpp b/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_anubarak.cpp
index 81530265617..8315f099198 100644
--- a/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_anubarak.cpp
+++ b/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_anubarak.cpp
@@ -130,11 +130,8 @@ public:
Summons.DespawnAll();
- if (instance)
- {
- instance->SetBossState(DATA_ANUBARAK, NOT_STARTED);
- instance->DoStopTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_TIMED_START_EVENT);
- }
+ instance->SetBossState(DATA_ANUBARAK, NOT_STARTED);
+ instance->DoStopTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_TIMED_START_EVENT);
}
Creature* DoSummonImpaleTarget(Unit* target)
@@ -158,14 +155,12 @@ public:
{
Talk(SAY_AGGRO);
DelayTimer = 0;
- if (instance)
- instance->DoStartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_TIMED_START_EVENT);
+ instance->DoStartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_TIMED_START_EVENT);
}
void DelayEventStart()
{
- if (instance)
- instance->SetBossState(DATA_ANUBARAK, IN_PROGRESS);
+ instance->SetBossState(DATA_ANUBARAK, IN_PROGRESS);
}
void UpdateAI(uint32 diff) OVERRIDE
@@ -335,8 +330,7 @@ public:
{
Talk(SAY_DEATH);
Summons.DespawnAll();
- if (instance)
- instance->SetBossState(DATA_ANUBARAK, DONE);
+ instance->SetBossState(DATA_ANUBARAK, DONE);
}
void KilledUnit(Unit* victim) OVERRIDE
@@ -355,7 +349,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_anub_arakAI(creature);
+ return GetInstanceAI<boss_anub_arakAI>(creature);
}
};
diff --git a/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_hadronox.cpp b/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_hadronox.cpp
index 1664a1375ae..a3227b02f10 100644
--- a/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_hadronox.cpp
+++ b/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_hadronox.cpp
@@ -102,14 +102,12 @@ public:
void JustDied(Unit* /*killer*/) OVERRIDE
{
- if (instance)
- instance->SetBossState(DATA_HADRONOX, DONE);
+ instance->SetBossState(DATA_HADRONOX, DONE);
}
void EnterCombat(Unit* /*who*/) OVERRIDE
{
- if (instance)
- instance->SetBossState(DATA_HADRONOX, IN_PROGRESS);
+ instance->SetBossState(DATA_HADRONOX, IN_PROGRESS);
me->SetInCombatWithZone();
}
@@ -192,7 +190,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_hadronoxAI(creature);
+ return GetInstanceAI<boss_hadronoxAI>(creature);
}
};
diff --git a/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_krikthir_the_gatewatcher.cpp b/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_krikthir_the_gatewatcher.cpp
index 143ccc29e0d..527b5d76973 100644
--- a/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_krikthir_the_gatewatcher.cpp
+++ b/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_krikthir_the_gatewatcher.cpp
@@ -104,8 +104,7 @@ public:
uiMindFlayTimer = 15*IN_MILLISECONDS;
uiCurseFatigueTimer = 12*IN_MILLISECONDS;
- if (instance)
- instance->SetBossState(DATA_KRIKTHIR_THE_GATEWATCHER, NOT_STARTED);
+ instance->SetBossState(DATA_KRIKTHIR_THE_GATEWATCHER, NOT_STARTED);
}
void EnterCombat(Unit* /*who*/) OVERRIDE
@@ -114,8 +113,7 @@ public:
Summon();
uiSummonTimer = 15*IN_MILLISECONDS;
- if (instance)
- instance->SetBossState(DATA_KRIKTHIR_THE_GATEWATCHER, IN_PROGRESS);
+ instance->SetBossState(DATA_KRIKTHIR_THE_GATEWATCHER, IN_PROGRESS);
}
void Summon()
@@ -175,8 +173,7 @@ public:
{
Talk(SAY_DEATH);
- if (instance)
- instance->SetBossState(DATA_KRIKTHIR_THE_GATEWATCHER, DONE);
+ instance->SetBossState(DATA_KRIKTHIR_THE_GATEWATCHER, DONE);
}
void KilledUnit(Unit* victim) OVERRIDE
@@ -195,7 +192,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_krik_thirAI(creature);
+ return GetInstanceAI<boss_krik_thirAI>(creature);
}
};
diff --git a/src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/boss_sartharion.cpp b/src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/boss_sartharion.cpp
index 8c470f73e04..534d942b9ef 100644
--- a/src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/boss_sartharion.cpp
+++ b/src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/boss_sartharion.cpp
@@ -45,7 +45,7 @@ enum Enums
SPELL_TAIL_LASH = 56910, // A sweeping tail strike hits all enemies behind the caster, inflicting 3063 to 3937 damage and stunning them for 2 sec.
SPELL_TAIL_LASH_H = 58957, // A sweeping tail strike hits all enemies behind the caster, inflicting 4375 to 5625 damage and stunning them for 2 sec.
SPELL_WILL_OF_SARTHARION = 61254, // Sartharion's presence bolsters the resolve of the Twilight Drakes, increasing their total health by 25%. This effect also increases Sartharion's health by 25%.
- SPELL_LAVA_STRIKE = 57571, // (Real spell casted should be 57578) 57571 then trigger visual missile, then summon Lava Blaze on impact(spell 57572)
+ SPELL_LAVA_STRIKE = 57571, // (Real spell cast should be 57578) 57571 then trigger visual missile, then summon Lava Blaze on impact(spell 57572)
SPELL_TWILIGHT_REVENGE = 60639,
NPC_FIRE_CYCLONE = 30648,
@@ -78,44 +78,34 @@ enum Misc
DATA_CAN_LOOT = 0
};
-struct Location
-{
- float x, y, z;
-};
-
-static Location FlameRight1Spawn = { 3200.00f, 573.211f, 57.1551f };
-static Location FlameRight1Direction = { 3289.28f, 573.211f, 57.1551f };
-static Location FlameRight2Spawn = { 3200.00f, 532.211f, 57.1551f };
-static Location FlameRight2Direction = { 3289.28f, 532.211f, 57.1551f };
-static Location FlameRight3Spawn = { 3200.00f, 491.211f, 57.1551f };
-static Location FlameRight3Direction = { 3289.28f, 491.211f, 57.1551f };
-static Location FlameLeft1Spawn = { 3289.28f, 511.711f, 57.1551f };
-static Location FlameLeft1Direction = { 3200.00f, 511.711f, 57.1551f };
-static Location FlameLeft2Spawn = { 3289.28f, 552.711f, 57.1551f };
-static Location FlameLeft2Direction = { 3200.00f, 552.711f, 57.1551f };
-
-struct Waypoint
-{
- float m_fX, m_fY, m_fZ;
-};
+Position const FlameRight1Spawn = { 3200.00f, 573.211f, 57.1551f, 0.0f };
+Position const FlameRight1Direction = { 3289.28f, 573.211f, 57.1551f, 0.0f };
+Position const FlameRight2Spawn = { 3200.00f, 532.211f, 57.1551f, 0.0f };
+Position const FlameRight2Direction = { 3289.28f, 532.211f, 57.1551f, 0.0f };
+Position const FlameRight3Spawn = { 3200.00f, 491.211f, 57.1551f, 0.0f };
+Position const FlameRight3Direction = { 3289.28f, 491.211f, 57.1551f, 0.0f };
+Position const FlameLeft1Spawn = { 3289.28f, 511.711f, 57.1551f, 0.0f };
+Position const FlameLeft1Direction = { 3200.00f, 511.711f, 57.1551f, 0.0f };
+Position const FlameLeft2Spawn = { 3289.28f, 552.711f, 57.1551f, 0.0f };
+Position const FlameLeft2Direction = { 3200.00f, 552.711f, 57.1551f, 0.0f };
//each dragons special points. First where fly to before connect to connon, second where land point is.
-Waypoint m_aTene[]=
+Position const TenebronPositions[] =
{
- {3212.854f, 575.597f, 109.856f}, // init
- {3246.425f, 565.367f, 61.249f} // end
+ { 3212.854f, 575.597f, 109.856f, 0.0f }, // init
+ { 3246.425f, 565.367f, 61.249f, 0.0f } // end
};
-Waypoint m_aShad[]=
+Position const ShadronPositions[] =
{
- {3293.238f, 472.223f, 106.968f},
- {3271.669f, 526.907f, 61.931f}
+ { 3293.238f, 472.223f, 106.968f, 0.0f },
+ { 3271.669f, 526.907f, 61.931f, 0.0f }
};
-Waypoint m_aVesp[]=
+Position const VesperonPositions[] =
{
- {3193.310f, 472.861f, 102.697f},
- {3227.268f, 533.238f, 59.995f}
+ { 3193.310f, 472.861f, 102.697f, 0.0f },
+ { 3227.268f, 533.238f, 59.995f, 0.0f }
};
enum SartharionEvents
@@ -156,11 +146,8 @@ public:
me->SetHomePosition(3246.57f, 551.263f, 58.6164f, 4.66003f);
- if (instance)
- {
- DrakeRespawn();
- instance->SetBossState(DATA_PORTAL_OPEN, NOT_STARTED);
- }
+ DrakeRespawn();
+ instance->SetBossState(DATA_PORTAL_OPEN, NOT_STARTED);
}
void JustReachedHome() OVERRIDE
@@ -174,8 +161,7 @@ public:
_EnterCombat();
DoZoneInCombat();
- if (instance)
- FetchDragons();
+ FetchDragons();
events.ScheduleEvent(EVENT_LAVA_STRIKE, 5000);
events.ScheduleEvent(EVENT_CLEAVE_ATTACK, 7000);
@@ -192,25 +178,23 @@ public:
Talk(SAY_SARTHARION_DEATH);
_JustDied();
- if (instance)
- {
- if (Creature* tenebron = Unit::GetCreature(*me, instance->GetData64(DATA_TENEBRON)))
- if (tenebron->IsAlive())
- tenebron->DisappearAndDie();
+ if (Creature* tenebron = Unit::GetCreature(*me, instance->GetData64(DATA_TENEBRON)))
+ if (tenebron->IsAlive())
+ tenebron->DisappearAndDie();
- if (Creature* shadron = Unit::GetCreature(*me, instance->GetData64(DATA_SHADRON)))
- if (shadron->IsAlive())
- shadron->DisappearAndDie();
+ if (Creature* shadron = Unit::GetCreature(*me, instance->GetData64(DATA_SHADRON)))
+ if (shadron->IsAlive())
+ shadron->DisappearAndDie();
- if (Creature* vesperon = Unit::GetCreature(*me, instance->GetData64(DATA_VESPERON)))
- if (vesperon->IsAlive())
- vesperon->DisappearAndDie();
- }
+ if (Creature* vesperon = Unit::GetCreature(*me, instance->GetData64(DATA_VESPERON)))
+ if (vesperon->IsAlive())
+ vesperon->DisappearAndDie();
}
- void KilledUnit(Unit* /*victim*/) OVERRIDE
+ void KilledUnit(Unit* who) OVERRIDE
{
- Talk(SAY_SARTHARION_SLAY);
+ if (who->GetTypeId() == TYPEID_PLAYER)
+ Talk(SAY_SARTHARION_SLAY);
}
// me->ResetLootMode() is called from Reset()
@@ -307,7 +291,7 @@ public:
AddDrakeLootMode();
++drakeCount;
}
- fetchTene->GetMotionMaster()->MovePoint(POINT_ID_INIT, m_aTene[0].m_fX, m_aTene[0].m_fY, m_aTene[0].m_fZ);
+ fetchTene->GetMotionMaster()->MovePoint(POINT_ID_INIT, TenebronPositions[0]);
if (!fetchTene->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE))
fetchTene->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
@@ -325,7 +309,7 @@ public:
AddDrakeLootMode();
++drakeCount;
}
- fetchShad->GetMotionMaster()->MovePoint(POINT_ID_INIT, m_aShad[0].m_fX, m_aShad[0].m_fY, m_aShad[0].m_fZ);
+ fetchShad->GetMotionMaster()->MovePoint(POINT_ID_INIT, ShadronPositions[0]);
if (!fetchShad->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE))
fetchShad->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
@@ -343,7 +327,7 @@ public:
AddDrakeLootMode();
++drakeCount;
}
- fetchVesp->GetMotionMaster()->MovePoint(POINT_ID_INIT, m_aVesp[0].m_fX, m_aVesp[0].m_fY, m_aVesp[0].m_fZ);
+ fetchVesp->GetMotionMaster()->MovePoint(POINT_ID_INIT, VesperonPositions[0]);
if (!fetchVesp->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE))
fetchVesp->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
@@ -356,40 +340,37 @@ public:
void CallDragon(uint32 dataId)
{
- if (instance)
+ if (Creature* temp = Unit::GetCreature(*me, instance->GetData64(dataId)))
{
- if (Creature* temp = Unit::GetCreature(*me, instance->GetData64(dataId)))
+ if (temp->IsAlive() && !temp->GetVictim())
{
- if (temp->IsAlive() && !temp->GetVictim())
- {
- temp->SetWalk(false);
+ temp->SetWalk(false);
- if (temp->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE))
- temp->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
+ if (temp->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE))
+ temp->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
- int32 textId = 0;
+ uint8 textId = 0;
- switch (temp->GetEntry())
- {
- case NPC_TENEBRON:
- textId = SAY_SARTHARION_CALL_TENEBRON;
- temp->AddAura(SPELL_POWER_OF_TENEBRON, temp);
- temp->GetMotionMaster()->MovePoint(POINT_ID_LAND, m_aTene[1].m_fX, m_aTene[1].m_fY, m_aTene[1].m_fZ);
- break;
- case NPC_SHADRON:
- textId = SAY_SARTHARION_CALL_SHADRON;
- temp->AddAura(SPELL_POWER_OF_SHADRON, temp);
- temp->GetMotionMaster()->MovePoint(POINT_ID_LAND, m_aShad[1].m_fX, m_aShad[1].m_fY, m_aShad[1].m_fZ);
- break;
- case NPC_VESPERON:
- textId = SAY_SARTHARION_CALL_VESPERON;
- temp->AddAura(SPELL_POWER_OF_VESPERON, temp);
- temp->GetMotionMaster()->MovePoint(POINT_ID_LAND, m_aVesp[1].m_fX, m_aVesp[1].m_fY, m_aVesp[1].m_fZ);
- break;
- }
-
- Talk(textId);
+ switch (temp->GetEntry())
+ {
+ case NPC_TENEBRON:
+ textId = SAY_SARTHARION_CALL_TENEBRON;
+ temp->AddAura(SPELL_POWER_OF_TENEBRON, temp);
+ temp->GetMotionMaster()->MovePoint(POINT_ID_LAND, TenebronPositions[1]);
+ break;
+ case NPC_SHADRON:
+ textId = SAY_SARTHARION_CALL_SHADRON;
+ temp->AddAura(SPELL_POWER_OF_SHADRON, temp);
+ temp->GetMotionMaster()->MovePoint(POINT_ID_LAND, ShadronPositions[1]);
+ break;
+ case NPC_VESPERON:
+ textId = SAY_SARTHARION_CALL_VESPERON;
+ temp->AddAura(SPELL_POWER_OF_VESPERON, temp);
+ temp->GetMotionMaster()->MovePoint(POINT_ID_LAND, VesperonPositions[1]);
+ break;
}
+
+ Talk(textId);
}
}
}
@@ -402,20 +383,6 @@ public:
return 0;
}
- void SendFlameTsunami()
- {
- if (Map* map = me->GetMap())
- if (map->IsDungeon())
- {
- Map::PlayerList const &PlayerList = map->GetPlayers();
-
- if (!PlayerList.isEmpty())
- for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
- if (i->GetSource() && i->GetSource()->IsAlive())
- Talk(WHISPER_LAVA_CHURN, i->GetSource());
- }
- }
-
// Selects a random Fire Cyclone and makes it cast Lava Strike.
// FIXME: Frequency of the casts reduced to compensate 100% chance of spawning a Lava Blaze add
void CastLavaStrikeOnTarget(Unit* target)
@@ -428,13 +395,7 @@ public:
if (fireCyclonesList.empty())
return;
- std::list<Creature*>::iterator itr = fireCyclonesList.begin();
- uint32 rnd = rand()%fireCyclonesList.size();
-
- for (uint32 i = 0; i < rnd; ++i)
- ++itr;
-
- (*itr)->CastSpell(target, SPELL_LAVA_STRIKE, true);
+ Trinity::Containers::SelectRandomContainerElement(fireCyclonesList)->CastSpell(target, SPELL_LAVA_STRIKE, true);
}
void UpdateAI(uint32 diff) OVERRIDE
@@ -456,25 +417,25 @@ public:
}
break;
case EVENT_FLAME_TSUNAMI:
- SendFlameTsunami();
+ Talk(WHISPER_LAVA_CHURN);
switch (urand(0, 1))
{
case 0:
{
- if (Creature* right1 = me->SummonCreature(NPC_FLAME_TSUNAMI, FlameRight1Spawn.x, FlameRight1Spawn.y, FlameRight1Spawn.z, 0, TEMPSUMMON_TIMED_DESPAWN, 12000))
- right1->GetMotionMaster()->MovePoint(0, FlameRight1Direction.x, FlameRight1Direction.y, FlameRight1Direction.z);
- if (Creature* right2 = me->SummonCreature(NPC_FLAME_TSUNAMI, FlameRight2Spawn.x, FlameRight2Spawn.y, FlameRight2Spawn.z, 0, TEMPSUMMON_TIMED_DESPAWN, 12000))
- right2->GetMotionMaster()->MovePoint(0, FlameRight2Direction.x, FlameRight2Direction.y, FlameRight2Direction.z);
- if (Creature* right3 = me->SummonCreature(NPC_FLAME_TSUNAMI, FlameRight3Spawn.x, FlameRight3Spawn.y, FlameRight3Spawn.z, 0, TEMPSUMMON_TIMED_DESPAWN, 12000))
- right3->GetMotionMaster()->MovePoint(0, FlameRight3Direction.x, FlameRight3Direction.y, FlameRight3Direction.z);
+ if (Creature* right1 = me->SummonCreature(NPC_FLAME_TSUNAMI, FlameRight1Spawn, TEMPSUMMON_TIMED_DESPAWN, 12000))
+ right1->GetMotionMaster()->MovePoint(0, FlameRight1Direction);
+ if (Creature* right2 = me->SummonCreature(NPC_FLAME_TSUNAMI, FlameRight2Spawn, TEMPSUMMON_TIMED_DESPAWN, 12000))
+ right2->GetMotionMaster()->MovePoint(0, FlameRight2Direction);
+ if (Creature* right3 = me->SummonCreature(NPC_FLAME_TSUNAMI, FlameRight3Spawn, TEMPSUMMON_TIMED_DESPAWN, 12000))
+ right3->GetMotionMaster()->MovePoint(0, FlameRight3Direction);
break;
}
case 1:
{
- if (Creature* left1 = me->SummonCreature(NPC_FLAME_TSUNAMI, FlameLeft1Spawn.x, FlameLeft1Spawn.y, FlameLeft1Spawn.z, 0, TEMPSUMMON_TIMED_DESPAWN, 12000))
- left1->GetMotionMaster()->MovePoint(0, FlameLeft1Direction.x, FlameLeft1Direction.y, FlameLeft1Direction.z);
- if (Creature* left2 = me->SummonCreature(NPC_FLAME_TSUNAMI, FlameLeft2Spawn.x, FlameLeft2Spawn.y, FlameLeft2Spawn.z, 0, TEMPSUMMON_TIMED_DESPAWN, 12000))
- left2->GetMotionMaster()->MovePoint(0, FlameLeft2Direction.x, FlameLeft2Direction.y, FlameLeft2Direction.z);
+ if (Creature* left1 = me->SummonCreature(NPC_FLAME_TSUNAMI, FlameLeft1Spawn, TEMPSUMMON_TIMED_DESPAWN, 12000))
+ left1->GetMotionMaster()->MovePoint(0, FlameLeft1Direction);
+ if (Creature* left2 = me->SummonCreature(NPC_FLAME_TSUNAMI, FlameLeft2Spawn, TEMPSUMMON_TIMED_DESPAWN, 12000))
+ left2->GetMotionMaster()->MovePoint(0, FlameLeft2Direction);
break;
}
}
@@ -547,7 +508,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_sartharionAI(creature);
+ return GetObsidianSanctumAI<boss_sartharionAI>(creature);
}
};
diff --git a/src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/obsidian_sanctum.cpp b/src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/obsidian_sanctum.cpp
index 6aa1eb74706..2891834c6e0 100644
--- a/src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/obsidian_sanctum.cpp
+++ b/src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/obsidian_sanctum.cpp
@@ -94,58 +94,44 @@ enum Misc
DATA_CAN_LOOT = 0
};
-struct Location
-{
- float x, y, z;
-};
-
-struct Locations
-{
- float x, y, z;
-};
-
-struct Waypoint
-{
- float m_fX, m_fY, m_fZ;
-};
-
#define MAX_WAYPOINT 6
//points around raid "isle", counter clockwise. should probably be adjusted to be more alike
-Waypoint dragonCommon[MAX_WAYPOINT]=
+Position const dragonCommon[MAX_WAYPOINT]=
{
- {3214.012f, 468.932f, 98.652f},
- {3244.950f, 468.427f, 98.652f},
- {3283.520f, 496.869f, 98.652f},
- {3287.316f, 555.875f, 98.652f},
- {3250.479f, 585.827f, 98.652f},
- {3209.969f, 566.523f, 98.652f}
+ { 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 }
};
-static Location AcolyteofShadron = { 3363.92f, 534.703f, 97.2683f };
-static Location AcolyteofShadron2 = { 3246.57f, 551.263f, 58.6164f };
-static Location AcolyteofVesperon = { 3145.68f, 520.71f, 89.7f };
-static Location AcolyteofVesperon2 = { 3246.57f, 551.263f, 58.6164f };
+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 };
-Locations TwilightEggs[] =
+Position const TwilightEggs[] =
{
- {3219.28f, 669.121f, 88.5549f},
- {3221.55f, 682.852f, 90.5361f},
- {3239.77f, 685.94f, 90.3168f},
- {3250.33f, 669.749f, 88.7637f},
- {3246.6f, 642.365f, 84.8752f},
- {3233.68f, 653.117f, 85.7051f}
+ { 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 }
};
-Locations TwilightEggsSarth[] =
+
+Position const TwilightEggsSarth[] =
{
- {3252.73f, 515.762f, 58.5501f},
- {3256.56f, 521.119f, 58.6061f},
- {3255.63f, 527.513f, 58.7568f},
- {3264.90f, 525.865f, 58.6436f},
- {3264.26f, 516.364f, 58.8011f},
- {3257.54f, 502.285f, 58.2077f}
+ { 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
+enum SharedTextIds
{
SAY_AGGRO = 0,
SAY_SLAY = 1,
@@ -157,12 +143,24 @@ enum SharedTextIDs
WHISPER_OPENED_PORTAL = 7
};
-enum DummyDragonEvents
+enum DragonEvents
{
- EVENT_FREE_MOVEMENT = 1
+ // Shared Events
+ EVENT_FREE_MOVEMENT = 1,
+ EVENT_SHADOW_FISSURE = 2,
+ EVENT_SHADOW_BREATH = 3,
+
+ // Tenebron
+ EVENT_HATCH_EGGS = 4,
+
+ // Shadron
+ EVENT_ACOLYTE_SHADRON = 5,
+
+ // Vesperon
+ EVENT_ACOLYTE_VESPERON = 6
};
-//to control each dragons common abilities
+// to control each dragons common abilities
struct dummy_dragonAI : public ScriptedAI
{
dummy_dragonAI(Creature* creature) : ScriptedAI(creature)
@@ -175,12 +173,22 @@ struct dummy_dragonAI : public ScriptedAI
if (me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE))
me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
+ events.Reset();
waypointId = 0;
portalRespawnTime = 30000;
_canMoveFree = false;
_canLoot = true;
}
+ void EnterCombat(Unit* /*who*/) OVERRIDE
+ {
+ Talk(SAY_AGGRO);
+ DoZoneInCombat();
+
+ events.ScheduleEvent(EVENT_SHADOW_FISSURE, 5000);
+ events.ScheduleEvent(EVENT_SHADOW_BREATH, 20000);
+ }
+
void SetData(uint32 type, uint32 value) OVERRIDE
{
if (type == DATA_CAN_LOOT)
@@ -217,14 +225,11 @@ struct dummy_dragonAI : public ScriptedAI
return;
}
- // get amount of common points
- uint32 commonWPCount = sizeof(dragonCommon)/sizeof(Waypoint);
-
// increase
- waypointId = pointId+1;
+ waypointId = pointId + 1;
// if we have reached a point bigger or equal to count, it mean we must reset to point 0
- if (waypointId >= commonWPCount)
+ if (waypointId >= MAX_WAYPOINT)
{
if (!_canMoveFree)
_canMoveFree = true;
@@ -235,23 +240,6 @@ struct dummy_dragonAI : public ScriptedAI
events.ScheduleEvent(EVENT_FREE_MOVEMENT, 500);
}
- // used when open portal and spawn mobs in phase
- void DoRaidWhisper(int32 iTextId)
- {
- Map* map = me->GetMap();
-
- if (map && map->IsDungeon())
- {
- Map::PlayerList const &PlayerList = map->GetPlayers();
-
- if (!PlayerList.isEmpty())
- {
- for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
- Talk(iTextId, i->GetSource());
- }
- }
- }
-
// "opens" the portal and does the "opening" whisper
void OpenPortal()
{
@@ -268,21 +256,21 @@ struct dummy_dragonAI : public ScriptedAI
if (instance && !instance->GetBossState(DATA_SARTHARION) == IN_PROGRESS)
{
for (uint32 i = 0; i < 6; ++i)
- me->SummonCreature(NPC_TWILIGHT_EGG, TwilightEggs[i].x, TwilightEggs[i].y, TwilightEggs[i].z, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 20000);
+ 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].x, TwilightEggsSarth[i].y, TwilightEggsSarth[i].z, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 20000);
+ me->SummonCreature(NPC_SARTHARION_TWILIGHT_EGG, TwilightEggsSarth[i], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 20000);
}
break;
}
case NPC_SHADRON:
{
if (instance && !instance->GetBossState(DATA_SARTHARION) == IN_PROGRESS)
- me->SummonCreature(NPC_ACOLYTE_OF_SHADRON, AcolyteofShadron.x, AcolyteofShadron.y, AcolyteofShadron.z, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 28000);
+ me->SummonCreature(NPC_ACOLYTE_OF_SHADRON, AcolyteofShadron, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 28000);
else
- me->SummonCreature(NPC_ACOLYTE_OF_SHADRON, AcolyteofShadron2.x, AcolyteofShadron2.y, AcolyteofShadron2.z, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 28000);
+ me->SummonCreature(NPC_ACOLYTE_OF_SHADRON, AcolyteofShadron2, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 28000);
break;
}
@@ -290,7 +278,7 @@ struct dummy_dragonAI : public ScriptedAI
{
if (instance && !instance->GetBossState(DATA_SARTHARION) == IN_PROGRESS)
{
- if (Creature* acolyte = me->SummonCreature(NPC_ACOLYTE_OF_VESPERON, AcolyteofVesperon.x, AcolyteofVesperon.y, AcolyteofVesperon.z, 0, 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);
@@ -299,7 +287,7 @@ struct dummy_dragonAI : public ScriptedAI
}
else
{
- if (Creature* acolyte = me->SummonCreature(NPC_ACOLYTE_OF_VESPERON, AcolyteofVesperon2.x, AcolyteofVesperon2.y, AcolyteofVesperon2.z, 0, 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);
@@ -307,12 +295,12 @@ struct dummy_dragonAI : public ScriptedAI
}
}
- break;
+ break;
}
}
- DoRaidWhisper(WHISPER_OPEN_PORTAL);
- DoRaidWhisper(WHISPER_OPENED_PORTAL);
+ Talk(WHISPER_OPEN_PORTAL);
+ Talk(WHISPER_OPENED_PORTAL);
// By using SetRespawnTime() we will actually "spawn" the object with our defined time.
// Once time is up, portal will disappear again.
@@ -323,6 +311,12 @@ struct dummy_dragonAI : public ScriptedAI
// Refresh respawnTime so time again are set to 30secs?
}
+ void KilledUnit(Unit* who) OVERRIDE
+ {
+ if (who->GetTypeId() == TYPEID_PLAYER)
+ Talk(SAY_SLAY);
+ }
+
void JustDied(Unit* /*killer*/) OVERRIDE
{
if (!_canLoot)
@@ -356,22 +350,19 @@ struct dummy_dragonAI : public ScriptedAI
Talk(SAY_DEATH);
me->RemoveAurasDueToSpell(spellId);
- if (instance)
- {
- instance->DoRemoveAurasDueToSpellOnPlayers(spellId);
+ instance->DoRemoveAurasDueToSpellOnPlayers(spellId);
- // not if solo mini-boss fight
- if (instance->GetBossState(DATA_SARTHARION) != IN_PROGRESS)
- return;
+ // not if solo mini-boss fight
+ if (instance->GetBossState(DATA_SARTHARION) != IN_PROGRESS)
+ return;
- // Twilight Revenge to main boss
- if (Unit* sartharion = Unit::GetUnit(*me, instance->GetData64(DATA_SARTHARION)))
- if (sartharion->IsAlive())
- {
- sartharion->RemoveAurasDueToSpell(spellId);
- DoCast(sartharion, SPELL_TWILIGHT_REVENGE, true);
- }
- }
+ // Twilight Revenge to main boss
+ if (Unit* sartharion = ObjectAccessor::GetUnit(*me, instance->GetData64(DATA_SARTHARION)))
+ if (sartharion->IsAlive())
+ {
+ sartharion->RemoveAurasDueToSpell(spellId);
+ DoCast(sartharion, SPELL_TWILIGHT_REVENGE, true);
+ }
}
void UpdateAI(uint32 diff) OVERRIDE
@@ -381,11 +372,30 @@ struct dummy_dragonAI : public ScriptedAI
if (events.ExecuteEvent() == EVENT_FREE_MOVEMENT)
{
if (_canMoveFree && waypointId < MAX_WAYPOINT)
- me->GetMotionMaster()->MovePoint(waypointId, dragonCommon[waypointId].m_fX, dragonCommon[waypointId].m_fY, dragonCommon[waypointId].m_fZ);
+ me->GetMotionMaster()->MovePoint(waypointId, dragonCommon[waypointId]);
}
}
- private:
+ void ExecuteEvent(uint32 eventId)
+ {
+ switch (eventId)
+ {
+ case EVENT_SHADOW_FISSURE:
+ if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 0.0f, true))
+ DoCast(target, RAID_MODE(SPELL_SHADOW_FISSURE, SPELL_SHADOW_FISSURE));
+ events.ScheduleEvent(eventId, urand(15000, 20000));
+ break;
+ case EVENT_SHADOW_BREATH:
+ Talk(SAY_BREATH);
+ DoCastVictim(RAID_MODE(SPELL_SHADOW_BREATH, SPELL_SHADOW_BREATH_H));
+ events.ScheduleEvent(eventId, urand(20000, 25000));
+ break;
+ default:
+ break;
+ }
+ }
+
+ protected:
InstanceScript* instance;
EventMap events;
uint32 waypointId;
@@ -398,13 +408,6 @@ struct dummy_dragonAI : public ScriptedAI
## Tenebron
######*/
-enum TenebronEvents
-{
- EVENT_SHADOW_FISSURE_TENEBRON = 2,
- EVENT_HATCH_EGGS = 3,
- EVENT_SHADOW_BREATH_TENEBRON = 4
-};
-
class npc_tenebron : public CreatureScript
{
public:
@@ -419,23 +422,16 @@ public:
dummy_dragonAI::Reset();
}
- void EnterCombat(Unit* /*who*/) OVERRIDE
+ void EnterCombat(Unit* who) OVERRIDE
{
- Talk(SAY_AGGRO);
- DoZoneInCombat();
- events.ScheduleEvent(EVENT_SHADOW_FISSURE_TENEBRON, 5000);
- events.ScheduleEvent(EVENT_HATCH_EGGS, 30000);
- events.ScheduleEvent(EVENT_SHADOW_BREATH_TENEBRON, 20000);
- }
+ dummy_dragonAI::EnterCombat(who);
- void KilledUnit(Unit* /*victim*/) OVERRIDE
- {
- Talk(SAY_SLAY);
+ events.ScheduleEvent(EVENT_HATCH_EGGS, 30000);
}
void UpdateAI(uint32 diff) OVERRIDE
{
- //if no target, update dummy and return
+ // if no target, update dummy and return
if (!UpdateVictim())
{
dummy_dragonAI::UpdateAI(diff);
@@ -448,32 +444,23 @@ public:
{
switch (eventId)
{
- case EVENT_SHADOW_FISSURE_TENEBRON:
- if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
- DoCast(target, RAID_MODE(SPELL_SHADOW_FISSURE, SPELL_SHADOW_FISSURE));
- events.ScheduleEvent(EVENT_SHADOW_FISSURE_TENEBRON, urand(15000, 20000));
- break;
case EVENT_HATCH_EGGS:
OpenPortal();
events.ScheduleEvent(EVENT_HATCH_EGGS, 30000);
break;
- case EVENT_SHADOW_BREATH_TENEBRON:
- Talk(SAY_BREATH);
- DoCastVictim(RAID_MODE(SPELL_SHADOW_BREATH, SPELL_SHADOW_BREATH_H));
- events.ScheduleEvent(EVENT_SHADOW_BREATH_TENEBRON, urand(20000, 25000));
+ default:
+ dummy_dragonAI::ExecuteEvent(eventId);
break;
}
}
+
DoMeleeAttackIfReady();
}
-
- private:
- EventMap events;
};
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_tenebronAI(creature);
+ return GetObsidianSanctumAI<npc_tenebronAI>(creature);
}
};
@@ -481,13 +468,6 @@ public:
## Shadron
######*/
-enum ShadronEvents
-{
- EVENT_SHADOW_FISSURE_SHADRON = 5,
- EVENT_ACOLYTE_SHADRON = 6,
- EVENT_SHADOW_BREATH_SHADRON = 7
-};
-
class npc_shadron : public CreatureScript
{
public:
@@ -495,10 +475,7 @@ public:
struct npc_shadronAI : public dummy_dragonAI
{
- npc_shadronAI(Creature* creature) : dummy_dragonAI(creature)
- {
- instance = creature->GetInstanceScript();
- }
+ npc_shadronAI(Creature* creature) : dummy_dragonAI(creature) { }
void Reset() OVERRIDE
{
@@ -510,27 +487,19 @@ public:
if (me->HasAura(SPELL_GIFT_OF_TWILIGTH_SHA))
me->RemoveAurasDueToSpell(SPELL_GIFT_OF_TWILIGTH_SHA);
- if (instance)
- instance->SetBossState(DATA_PORTAL_OPEN, NOT_STARTED);
+ instance->SetBossState(DATA_PORTAL_OPEN, NOT_STARTED);
}
- void EnterCombat(Unit* /*who*/) OVERRIDE
+ void EnterCombat(Unit* who) OVERRIDE
{
- Talk(SAY_AGGRO);
- DoZoneInCombat();
- events.ScheduleEvent(EVENT_SHADOW_FISSURE_SHADRON, 5000);
- events.ScheduleEvent(EVENT_ACOLYTE_SHADRON, 60000);
- events.ScheduleEvent(EVENT_SHADOW_BREATH_SHADRON, 20000);
- }
+ dummy_dragonAI::EnterCombat(who);
- void KilledUnit(Unit* /*victim*/) OVERRIDE
- {
- Talk(SAY_SLAY);
+ events.ScheduleEvent(EVENT_ACOLYTE_SHADRON, 60000);
}
void UpdateAI(uint32 diff) OVERRIDE
{
- //if no target, update dummy and return
+ // if no target, update dummy and return
if (!UpdateVictim())
{
dummy_dragonAI::UpdateAI(diff);
@@ -543,11 +512,6 @@ public:
{
switch (eventId)
{
- case EVENT_SHADOW_FISSURE_SHADRON:
- if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
- DoCast(target, RAID_MODE(SPELL_SHADOW_FISSURE, SPELL_SHADOW_FISSURE_H));
- events.ScheduleEvent(EVENT_SHADOW_FISSURE_SHADRON, urand(15000, 20000));
- break;
case EVENT_ACOLYTE_SHADRON:
if (instance->GetBossState(DATA_PORTAL_OPEN) == NOT_STARTED)
events.ScheduleEvent(EVENT_ACOLYTE_SHADRON, 10000);
@@ -558,30 +522,24 @@ public:
OpenPortal();
- if (instance)
- instance->SetBossState(DATA_PORTAL_OPEN, IN_PROGRESS);
+ instance->SetBossState(DATA_PORTAL_OPEN, IN_PROGRESS);
events.ScheduleEvent(EVENT_ACOLYTE_SHADRON, urand(60000, 65000));
}
break;
- case EVENT_SHADOW_BREATH_SHADRON:
- Talk(SAY_BREATH);
- DoCastVictim(RAID_MODE(SPELL_SHADOW_BREATH, SPELL_SHADOW_BREATH_H));
- events.ScheduleEvent(EVENT_SHADOW_BREATH_SHADRON, urand(20000, 25000));
+ default:
+ dummy_dragonAI::ExecuteEvent(eventId);
break;
}
}
+
DoMeleeAttackIfReady();
}
-
- private:
- InstanceScript* instance;
- EventMap events;
};
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_shadronAI(creature);
+ return GetObsidianSanctumAI<npc_shadronAI>(creature);
}
};
@@ -589,13 +547,6 @@ public:
## Vesperon
######*/
-enum VesperonEvents
-{
- EVENT_SHADOW_FISSURE_VESPERON = 8,
- EVENT_ACOLYTE_VESPERON = 9,
- EVENT_SHADOW_BREATH_VESPERON = 10
-};
-
class npc_vesperon : public CreatureScript
{
public:
@@ -603,33 +554,23 @@ public:
struct npc_vesperonAI : public dummy_dragonAI
{
- npc_vesperonAI(Creature* creature) : dummy_dragonAI(creature)
- {
- instance = creature->GetInstanceScript();
- }
+ npc_vesperonAI(Creature* creature) : dummy_dragonAI(creature) { }
void Reset() OVERRIDE
{
dummy_dragonAI::Reset();
}
- void EnterCombat(Unit* /*who*/) OVERRIDE
+ void EnterCombat(Unit* who) OVERRIDE
{
- Talk(SAY_AGGRO);
- DoZoneInCombat();
- events.ScheduleEvent(EVENT_SHADOW_FISSURE_VESPERON, 5000);
- events.ScheduleEvent(EVENT_ACOLYTE_VESPERON, 60000);
- events.ScheduleEvent(EVENT_SHADOW_BREATH_VESPERON, 20000);
- }
+ dummy_dragonAI::EnterCombat(who);
- void KilledUnit(Unit* /*victim*/) OVERRIDE
- {
- Talk(SAY_SLAY);
+ events.ScheduleEvent(EVENT_ACOLYTE_VESPERON, 60000);
}
void UpdateAI(uint32 diff) OVERRIDE
{
- //if no target, update dummy and return
+ // if no target, update dummy and return
if (!UpdateVictim())
{
dummy_dragonAI::UpdateAI(diff);
@@ -642,11 +583,6 @@ public:
{
switch (eventId)
{
- case EVENT_SHADOW_FISSURE_VESPERON:
- if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
- DoCast(target, RAID_MODE(SPELL_SHADOW_FISSURE, SPELL_SHADOW_FISSURE_H));
- events.ScheduleEvent(EVENT_SHADOW_FISSURE_VESPERON, urand(15000, 20000));
- break;
case EVENT_ACOLYTE_VESPERON:
if (instance->GetBossState(DATA_PORTAL_OPEN) == IN_PROGRESS)
events.ScheduleEvent(EVENT_ACOLYTE_VESPERON, 10000);
@@ -657,24 +593,19 @@ public:
events.ScheduleEvent(EVENT_ACOLYTE_VESPERON, urand(60000, 70000));
}
break;
- case EVENT_SHADOW_BREATH_VESPERON:
- Talk(SAY_BREATH);
- DoCastVictim(RAID_MODE(SPELL_SHADOW_BREATH, SPELL_SHADOW_BREATH_H));
- events.ScheduleEvent(EVENT_SHADOW_BREATH_VESPERON, urand(20000, 25000));
+ default:
+ dummy_dragonAI::ExecuteEvent(eventId);
break;
}
}
+
DoMeleeAttackIfReady();
}
-
- private:
- InstanceScript* instance;
- EventMap events;
};
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_vesperonAI(creature);
+ return GetObsidianSanctumAI<npc_vesperonAI>(creature);
}
};
@@ -684,23 +615,21 @@ public:
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
- {
- npc_acolyte_of_shadronAI(Creature* creature) : ScriptedAI(creature)
+ struct npc_acolyte_of_shadronAI : public ScriptedAI
{
- instance = creature->GetInstanceScript();
- }
-
- void Reset() OVERRIDE
- {
- // Despawn the NPC automatically after 28 seconds
- me->DespawnOrUnsummon(28000);
+ npc_acolyte_of_shadronAI(Creature* creature) : ScriptedAI(creature)
+ {
+ instance = creature->GetInstanceScript();
+ }
- if (instance)
+ 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)
{
@@ -712,14 +641,11 @@ public:
if (Creature* shadron = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_SHADRON)))
shadron->AddAura(SPELL_GIFT_OF_TWILIGTH_SHA, shadron);
}
- }
- me->AddAura(SPELL_TWILIGHT_SHIFT_ENTER, me);
- }
+ me->AddAura(SPELL_TWILIGHT_SHIFT_ENTER, me);
+ }
- void JustDied(Unit* /*killer*/) OVERRIDE
- {
- if (instance)
+ void JustDied(Unit* /*killer*/) OVERRIDE
{
if (ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_SHADRON)))
instance->SetBossState(DATA_PORTAL_OPEN, NOT_STARTED);
@@ -727,7 +653,7 @@ public:
Map* map = me->GetMap();
if (map->IsDungeon())
{
- Map::PlayerList const &PlayerList = map->GetPlayers();
+ Map::PlayerList const& PlayerList = map->GetPlayers();
if (PlayerList.isEmpty())
return;
@@ -741,7 +667,7 @@ public:
i->GetSource()->RemoveAurasDueToSpell(SPELL_TWILIGHT_SHIFT);
i->GetSource()->RemoveAurasDueToSpell(SPELL_TWILIGHT_SHIFT_ENTER);
}
- }
+ }
}
// not solo fight, so main boss has debuff
@@ -754,24 +680,23 @@ public:
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;
+ void UpdateAI(uint32 /*diff*/) OVERRIDE
+ {
+ if (!UpdateVictim())
+ return;
- DoMeleeAttackIfReady();
- }
+ DoMeleeAttackIfReady();
+ }
- private:
- InstanceScript* instance;
- };
+ private:
+ InstanceScript* instance;
+ };
- CreatureAI* GetAI(Creature* creature) const OVERRIDE
- {
- return new npc_acolyte_of_shadronAI(creature);
- }
+ CreatureAI* GetAI(Creature* creature) const OVERRIDE
+ {
+ return GetObsidianSanctumAI<npc_acolyte_of_shadronAI>(creature);
+ }
};
/*######
@@ -780,34 +705,31 @@ public:
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
- {
- npc_acolyte_of_vesperonAI(Creature* creature) : ScriptedAI(creature)
+ struct npc_acolyte_of_vesperonAI : public ScriptedAI
{
- instance = creature->GetInstanceScript();
- }
+ npc_acolyte_of_vesperonAI(Creature* creature) : ScriptedAI(creature)
+ {
+ 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);
- if (instance)
me->AddAura(SPELL_TWILIGHT_SHIFT_ENTER, me);
- DoCast(me, SPELL_TWILIGHT_TORMENT_VESP_ACO);
- }
-
- void JustDied(Unit* /*killer*/) OVERRIDE
- {
- me->RemoveAurasDueToSpell(SPELL_TWILIGHT_TORMENT_VESP_ACO);
+ DoCast(me, SPELL_TWILIGHT_TORMENT_VESP_ACO);
+ }
- // remove twilight torment on Vesperon
- if (instance)
+ void JustDied(Unit* /*killer*/) OVERRIDE
{
+ me->RemoveAurasDueToSpell(SPELL_TWILIGHT_TORMENT_VESP_ACO);
+
+ // remove twilight torment on Vesperon
if (Creature* vesperon = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_VESPERON)))
{
instance->SetBossState(DATA_PORTAL_OPEN, NOT_STARTED);
@@ -842,24 +764,23 @@ public:
instance->DoRemoveAurasDueToSpellOnPlayers(57935);
instance->DoRemoveAurasDueToSpellOnPlayers(58835); // Components of spell Twilight Torment
}
- }
- 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 new npc_acolyte_of_vesperonAI(creature);
- }
+ CreatureAI* GetAI(Creature* creature) const OVERRIDE
+ {
+ return GetObsidianSanctumAI<npc_acolyte_of_vesperonAI>(creature);
+ }
};
/*######
@@ -886,8 +807,7 @@ public:
void Reset() OVERRIDE
{
- if (instance)
- me->AddAura(SPELL_TWILIGHT_SHIFT_ENTER, me);
+ me->AddAura(SPELL_TWILIGHT_SHIFT_ENTER, me);
events.ScheduleEvent(EVENT_TWILIGHT_EGGS, 20000);
}
@@ -928,7 +848,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_twilight_eggsAI(creature);
+ return GetObsidianSanctumAI<npc_twilight_eggsAI>(creature);
}
};
diff --git a/src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/obsidian_sanctum.h b/src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/obsidian_sanctum.h
index 8cfb3931372..d8f49a06578 100644
--- a/src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/obsidian_sanctum.h
+++ b/src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/obsidian_sanctum.h
@@ -15,8 +15,8 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef DEF_OBSIDIAN_SANCTUM_H
-#define DEF_OBSIDIAN_SANCTUM_H
+#ifndef OBSIDIAN_SANCTUM_H_
+#define OBSIDIAN_SANCTUM_H_
#define OSScriptName "instance_obsidian_sanctum"
@@ -45,4 +45,10 @@ enum GameObjectIds
GO_TWILIGHT_PORTAL = 193988
};
-#endif
+template<class AI>
+AI* GetObsidianSanctumAI(Creature* creature)
+{
+ return GetInstanceAI<AI>(creature, OSScriptName);
+}
+
+#endif // OBSIDIAN_SANCTUM_H_
diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_argent_challenge.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_argent_challenge.cpp
index f6fd1c14a9b..7839ad3dde8 100644
--- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_argent_challenge.cpp
+++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_argent_challenge.cpp
@@ -196,8 +196,7 @@ public:
if (MovementType != POINT_MOTION_TYPE)
return;
- if (instance)
- instance->SetData(BOSS_ARGENT_CHALLENGE_E, DONE);
+ instance->SetData(BOSS_ARGENT_CHALLENGE_E, DONE);
me->DisappearAndDie();
}
@@ -248,7 +247,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_eadricAI(creature);
+ return GetInstanceAI<boss_eadricAI>(creature);
}
};
@@ -320,8 +319,7 @@ public:
if (MovementType != POINT_MOTION_TYPE || Point != 0)
return;
- if (instance)
- instance->SetData(BOSS_ARGENT_CHALLENGE_P, DONE);
+ instance->SetData(BOSS_ARGENT_CHALLENGE_P, DONE);
me->DisappearAndDie();
}
@@ -406,7 +404,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_paletressAI(creature);
+ return GetInstanceAI<boss_paletressAI>(creature);
}
};
@@ -582,14 +580,13 @@ public:
void JustDied(Unit* /*killer*/) OVERRIDE
{
- if (instance)
- instance->SetData(DATA_ARGENT_SOLDIER_DEFEATED, instance->GetData(DATA_ARGENT_SOLDIER_DEFEATED) + 1);
+ instance->SetData(DATA_ARGENT_SOLDIER_DEFEATED, instance->GetData(DATA_ARGENT_SOLDIER_DEFEATED) + 1);
}
};
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_argent_soldierAI(creature);
+ return GetInstanceAI<npc_argent_soldierAI>(creature);
}
};
diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_black_knight.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_black_knight.cpp
index 1922ad26060..29aac1cd40e 100644
--- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_black_knight.cpp
+++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_black_knight.cpp
@@ -293,14 +293,13 @@ public:
{
DoCast(me, SPELL_KILL_CREDIT);
- if (instance)
- instance->SetData(BOSS_BLACK_KNIGHT, DONE);
+ instance->SetData(BOSS_BLACK_KNIGHT, DONE);
}
};
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_black_knightAI(creature);
+ return GetInstanceAI<boss_black_knightAI>(creature);
}
};
diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_grand_champions.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_grand_champions.cpp
index 07ecaadef77..b3d756dd29f 100644
--- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_grand_champions.cpp
+++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_grand_champions.cpp
@@ -207,9 +207,6 @@ public:
void WaypointReached(uint32 waypointId) OVERRIDE
{
- if (!instance)
- return;
-
switch (waypointId)
{
case 2:
@@ -300,7 +297,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new generic_vehicleAI_toc5AI(creature);
+ return GetInstanceAI<generic_vehicleAI_toc5AI>(creature);
}
};
@@ -426,14 +423,13 @@ public:
void JustDied(Unit* /*killer*/) OVERRIDE
{
- if (instance)
- instance->SetData(BOSS_GRAND_CHAMPIONS, DONE);
+ instance->SetData(BOSS_GRAND_CHAMPIONS, DONE);
}
};
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_warrior_toc5AI(creature);
+ return GetInstanceAI<boss_warrior_toc5AI>(creature);
}
};
@@ -507,8 +503,7 @@ public:
else if (instance && me->GetGUID() == instance->GetData64(DATA_GRAND_CHAMPION_3))
me->SetHomePosition(754.34f, 660.70f, 412.39f, 4.79f);
- if (instance)
- instance->SetData(BOSS_GRAND_CHAMPIONS, IN_PROGRESS);
+ instance->SetData(BOSS_GRAND_CHAMPIONS, IN_PROGRESS);
EnterEvadeMode();
bHome = true;
@@ -565,14 +560,13 @@ public:
void JustDied(Unit* /*killer*/) OVERRIDE
{
- if (instance)
- instance->SetData(BOSS_GRAND_CHAMPIONS, DONE);
+ instance->SetData(BOSS_GRAND_CHAMPIONS, DONE);
}
};
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_mage_toc5AI(creature);
+ return GetInstanceAI<boss_mage_toc5AI>(creature);
}
};
@@ -652,8 +646,7 @@ public:
else if (instance && me->GetGUID() == instance->GetData64(DATA_GRAND_CHAMPION_3))
me->SetHomePosition(754.34f, 660.70f, 412.39f, 4.79f);
- if (instance)
- instance->SetData(BOSS_GRAND_CHAMPIONS, IN_PROGRESS);
+ instance->SetData(BOSS_GRAND_CHAMPIONS, IN_PROGRESS);
EnterEvadeMode();
bHome = true;
@@ -712,14 +705,13 @@ public:
void JustDied(Unit* /*killer*/) OVERRIDE
{
- if (instance)
- instance->SetData(BOSS_GRAND_CHAMPIONS, DONE);
+ instance->SetData(BOSS_GRAND_CHAMPIONS, DONE);
}
};
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_shaman_toc5AI(creature);
+ return GetInstanceAI<boss_shaman_toc5AI>(creature);
}
};
@@ -798,8 +790,7 @@ public:
else if (instance && me->GetGUID() == instance->GetData64(DATA_GRAND_CHAMPION_3))
me->SetHomePosition(754.34f, 660.70f, 412.39f, 4.79f);
- if (instance)
- instance->SetData(BOSS_GRAND_CHAMPIONS, IN_PROGRESS);
+ instance->SetData(BOSS_GRAND_CHAMPIONS, IN_PROGRESS);
EnterEvadeMode();
bHome = true;
@@ -868,14 +859,13 @@ public:
void JustDied(Unit* /*killer*/) OVERRIDE
{
- if (instance)
- instance->SetData(BOSS_GRAND_CHAMPIONS, DONE);
+ instance->SetData(BOSS_GRAND_CHAMPIONS, DONE);
}
};
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_hunter_toc5AI(creature);
+ return GetInstanceAI<boss_hunter_toc5AI>(creature);
}
};
@@ -946,8 +936,7 @@ public:
else if (instance && me->GetGUID() == instance->GetData64(DATA_GRAND_CHAMPION_3))
me->SetHomePosition(754.34f, 660.70f, 412.39f, 4.79f);
- if (instance)
- instance->SetData(BOSS_GRAND_CHAMPIONS, IN_PROGRESS);
+ instance->SetData(BOSS_GRAND_CHAMPIONS, IN_PROGRESS);
EnterEvadeMode();
bHome = true;
@@ -989,14 +978,13 @@ public:
void JustDied(Unit* /*killer*/) OVERRIDE
{
- if (instance)
- instance->SetData(BOSS_GRAND_CHAMPIONS, DONE);
+ instance->SetData(BOSS_GRAND_CHAMPIONS, DONE);
}
};
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_rouge_toc5AI(creature);
+ return GetInstanceAI<boss_rouge_toc5AI>(creature);
}
};
diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/trial_of_the_champion.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/trial_of_the_champion.cpp
index 00b312aa407..3f01e055141 100644
--- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/trial_of_the_champion.cpp
+++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/trial_of_the_champion.cpp
@@ -236,11 +236,8 @@ public:
if (Vehicle* pVehicle = pBoss->GetVehicleKit())
if (Unit* unit = pVehicle->GetPassenger(0))
uiGrandChampionBoss1 = unit->GetGUID();
- if (instance)
- {
- instance->SetData64(DATA_GRAND_CHAMPION_VEHICLE_1, uiVehicle1GUID);
- instance->SetData64(DATA_GRAND_CHAMPION_1, uiGrandChampionBoss1);
- }
+ instance->SetData64(DATA_GRAND_CHAMPION_VEHICLE_1, uiVehicle1GUID);
+ instance->SetData64(DATA_GRAND_CHAMPION_1, uiGrandChampionBoss1);
pBoss->AI()->SetData(1, 0);
break;
}
@@ -251,11 +248,8 @@ public:
if (Vehicle* pVehicle = pBoss->GetVehicleKit())
if (Unit* unit = pVehicle->GetPassenger(0))
uiGrandChampionBoss2 = unit->GetGUID();
- if (instance)
- {
- instance->SetData64(DATA_GRAND_CHAMPION_VEHICLE_2, uiVehicle2GUID);
- instance->SetData64(DATA_GRAND_CHAMPION_2, uiGrandChampionBoss2);
- }
+ instance->SetData64(DATA_GRAND_CHAMPION_VEHICLE_2, uiVehicle2GUID);
+ instance->SetData64(DATA_GRAND_CHAMPION_2, uiGrandChampionBoss2);
pBoss->AI()->SetData(2, 0);
break;
}
@@ -266,11 +260,8 @@ public:
if (Vehicle* pVehicle = pBoss->GetVehicleKit())
if (Unit* unit = pVehicle->GetPassenger(0))
uiGrandChampionBoss3 = unit->GetGUID();
- if (instance)
- {
- instance->SetData64(DATA_GRAND_CHAMPION_VEHICLE_3, uiVehicle3GUID);
- instance->SetData64(DATA_GRAND_CHAMPION_3, uiGrandChampionBoss3);
- }
+ instance->SetData64(DATA_GRAND_CHAMPION_VEHICLE_3, uiVehicle3GUID);
+ instance->SetData64(DATA_GRAND_CHAMPION_3, uiGrandChampionBoss3);
pBoss->AI()->SetData(3, 0);
break;
}
@@ -359,9 +350,6 @@ public:
void StartEncounter()
{
- if (!instance)
- return;
-
me->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
if (instance->GetData(BOSS_BLACK_KNIGHT) == NOT_STARTED)
@@ -472,7 +460,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_announcer_toc5AI(creature);
+ return GetInstanceAI<npc_announcer_toc5AI>(creature);
}
bool OnGossipHello(Player* player, Creature* creature) OVERRIDE
diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp
index 32a8a2fe379..1f1b7f3ff3b 100644
--- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp
+++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp
@@ -201,8 +201,7 @@ class boss_anubarak_trial : public CreatureScript
if (who->GetTypeId() == TYPEID_PLAYER)
{
Talk(SAY_KILL_PLAYER);
- if (instance)
- instance->SetData(DATA_TRIBUTE_TO_IMMORTALITY_ELIGIBLE, 0);
+ instance->SetData(DATA_TRIBUTE_TO_IMMORTALITY_ELIGIBLE, 0);
}
}
@@ -218,8 +217,7 @@ class boss_anubarak_trial : public CreatureScript
void JustReachedHome() OVERRIDE
{
- if (instance)
- instance->SetBossState(BOSS_ANUBARAK, FAIL);
+ instance->SetBossState(BOSS_ANUBARAK, FAIL);
//Summon Scarab Swarms neutral at random places
for (int i = 0; i < 10; i++)
if (Creature* temp = me->SummonCreature(NPC_SCARAB, AnubarakLoc[1].GetPositionX()+urand(0, 50)-25, AnubarakLoc[1].GetPositionY()+urand(0, 50)-25, AnubarakLoc[1].GetPositionZ()))
@@ -245,7 +243,6 @@ class boss_anubarak_trial : public CreatureScript
void JustSummoned(Creature* summoned) OVERRIDE
{
- Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 0.0f, true);
switch (summoned->GetEntry())
{
case NPC_BURROW:
@@ -255,9 +252,12 @@ class boss_anubarak_trial : public CreatureScript
summoned->SetDisplayId(summoned->GetCreatureTemplate()->Modelid2);
break;
case NPC_SPIKE:
- summoned->CombatStart(target);
summoned->SetDisplayId(summoned->GetCreatureTemplate()->Modelid1);
- Talk(EMOTE_SPIKE, target);
+ if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 0.0f, true))
+ {
+ summoned->CombatStart(target);
+ Talk(EMOTE_SPIKE, target);
+ }
break;
default:
break;
@@ -423,7 +423,7 @@ class boss_anubarak_trial : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_anubarak_trialAI(creature);
+ return GetInstanceAI<boss_anubarak_trialAI>(creature);
};
};
@@ -495,7 +495,7 @@ class npc_swarm_scarab : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_swarm_scarabAI(creature);
+ return GetInstanceAI<npc_swarm_scarabAI>(creature);
};
};
@@ -583,7 +583,7 @@ class npc_nerubian_burrower : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_nerubian_burrowerAI(creature);
+ return GetInstanceAI<npc_nerubian_burrowerAI>(creature);
};
};
diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_faction_champions.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_faction_champions.cpp
index 4c73d1a5f55..f510e2be99f 100644
--- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_faction_champions.cpp
+++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_faction_champions.cpp
@@ -539,7 +539,7 @@ class boss_toc_champion_controller : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_toc_champion_controllerAI(creature);
+ return GetInstanceAI<boss_toc_champion_controllerAI>(creature);
}
};
@@ -559,9 +559,8 @@ struct boss_faction_championsAI : public BossAI
void JustReachedHome() OVERRIDE
{
- if (instance)
- if (Creature* pChampionController = Unit::GetCreature((*me), instance->GetData64(NPC_CHAMPIONS_CONTROLLER)))
- pChampionController->AI()->SetData(2, FAIL);
+ if (Creature* pChampionController = Unit::GetCreature((*me), instance->GetData64(NPC_CHAMPIONS_CONTROLLER)))
+ pChampionController->AI()->SetData(2, FAIL);
me->DespawnOrUnsummon();
}
@@ -610,18 +609,16 @@ struct boss_faction_championsAI : public BossAI
void JustDied(Unit* /*killer*/) OVERRIDE
{
if (_aiType != AI_PET)
- if (instance)
- if (Creature* pChampionController = Unit::GetCreature((*me), instance->GetData64(NPC_CHAMPIONS_CONTROLLER)))
- pChampionController->AI()->SetData(2, DONE);
+ if (Creature* pChampionController = Unit::GetCreature((*me), instance->GetData64(NPC_CHAMPIONS_CONTROLLER)))
+ pChampionController->AI()->SetData(2, DONE);
}
void EnterCombat(Unit* /*who*/) OVERRIDE
{
DoCast(me, SPELL_ANTI_AOE, true);
_EnterCombat();
- if (instance)
- if (Creature* pChampionController = Unit::GetCreature((*me), instance->GetData64(NPC_CHAMPIONS_CONTROLLER)))
- pChampionController->AI()->SetData(2, IN_PROGRESS);
+ if (Creature* pChampionController = Unit::GetCreature((*me), instance->GetData64(NPC_CHAMPIONS_CONTROLLER)))
+ pChampionController->AI()->SetData(2, IN_PROGRESS);
}
void KilledUnit(Unit* who) OVERRIDE
@@ -635,20 +632,17 @@ struct boss_faction_championsAI : public BossAI
if (Player* player = players.begin()->GetSource())
TeamInInstance = player->GetTeam();
- if (instance)
+ if (TeamInInstance == ALLIANCE)
{
- if (TeamInInstance == ALLIANCE)
- {
- if (Creature* temp = Unit::GetCreature(*me, instance->GetData64(NPC_VARIAN)))
- temp->AI()->Talk(SAY_KILL_PLAYER);
- }
- else
- if (Creature* temp = Unit::GetCreature(*me, instance->GetData64(NPC_GARROSH)))
- temp->AI()->Talk(SAY_KILL_PLAYER);
+ if (Creature* temp = Unit::GetCreature(*me, instance->GetData64(NPC_VARIAN)))
+ temp->AI()->Talk(SAY_KILL_PLAYER);
+ }
+ else
+ if (Creature* temp = Unit::GetCreature(*me, instance->GetData64(NPC_GARROSH)))
+ temp->AI()->Talk(SAY_KILL_PLAYER);
- instance->SetData(DATA_TRIBUTE_TO_IMMORTALITY_ELIGIBLE, 0);
- }
+ instance->SetData(DATA_TRIBUTE_TO_IMMORTALITY_ELIGIBLE, 0);
}
}
@@ -839,7 +833,7 @@ class npc_toc_druid : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_toc_druidAI(creature);
+ return GetInstanceAI<npc_toc_druidAI>(creature);
}
};
@@ -932,7 +926,7 @@ class npc_toc_shaman : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_toc_shamanAI(creature);
+ return GetInstanceAI<npc_toc_shamanAI>(creature);
}
};
@@ -1036,7 +1030,7 @@ class npc_toc_paladin : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_toc_paladinAI(creature);
+ return GetInstanceAI<npc_toc_paladinAI>(creature);
}
};
@@ -1121,7 +1115,7 @@ class npc_toc_priest : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_toc_priestAI(creature);
+ return GetInstanceAI<npc_toc_priestAI>(creature);
}
};
@@ -1219,7 +1213,7 @@ class npc_toc_shadow_priest : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_toc_shadow_priestAI(creature);
+ return GetInstanceAI<npc_toc_shadow_priestAI>(creature);
}
};
@@ -1310,7 +1304,7 @@ class npc_toc_warlock : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_toc_warlockAI(creature);
+ return GetInstanceAI<npc_toc_warlockAI>(creature);
}
};
@@ -1404,7 +1398,7 @@ class npc_toc_mage : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_toc_mageAI(creature);
+ return GetInstanceAI<npc_toc_mageAI>(creature);
}
};
@@ -1506,7 +1500,7 @@ class npc_toc_hunter : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_toc_hunterAI(creature);
+ return GetInstanceAI<npc_toc_hunterAI>(creature);
}
};
@@ -1598,7 +1592,7 @@ class npc_toc_boomkin : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_toc_boomkinAI(creature);
+ return GetInstanceAI<npc_toc_boomkinAI>(creature);
}
};
@@ -1702,7 +1696,7 @@ class npc_toc_warrior : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_toc_warriorAI(creature);
+ return GetInstanceAI<npc_toc_warriorAI>(creature);
}
};
@@ -1798,7 +1792,7 @@ class npc_toc_dk : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_toc_dkAI(creature);
+ return GetInstanceAI<npc_toc_dkAI>(creature);
}
};
@@ -1903,7 +1897,7 @@ class npc_toc_rogue : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_toc_rogueAI(creature);
+ return GetInstanceAI<npc_toc_rogueAI>(creature);
}
};
@@ -2029,7 +2023,7 @@ class npc_toc_enh_shaman : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_toc_enh_shamanAI(creature);
+ return GetInstanceAI<npc_toc_enh_shamanAI>(creature);
}
};
@@ -2135,7 +2129,7 @@ class npc_toc_retro_paladin : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_toc_retro_paladinAI(creature);
+ return GetInstanceAI<npc_toc_retro_paladinAI>(creature);
}
};
@@ -2187,7 +2181,7 @@ class npc_toc_pet_warlock : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_toc_pet_warlockAI(creature);
+ return GetInstanceAI<npc_toc_pet_warlockAI>(creature);
}
};
@@ -2227,7 +2221,7 @@ class npc_toc_pet_hunter : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_toc_pet_hunterAI(creature);
+ return GetInstanceAI<npc_toc_pet_hunterAI>(creature);
}
};
diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_lord_jaraxxus.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_lord_jaraxxus.cpp
index 3fa9ac7387f..7fbdc30c0e5 100644
--- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_lord_jaraxxus.cpp
+++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_lord_jaraxxus.cpp
@@ -116,8 +116,7 @@ class boss_jaraxxus : public CreatureScript
void JustReachedHome() OVERRIDE
{
_JustReachedHome();
- if (instance)
- instance->SetBossState(BOSS_JARAXXUS, FAIL);
+ instance->SetBossState(BOSS_JARAXXUS, FAIL);
DoCast(me, SPELL_JARAXXUS_CHAINS);
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
}
@@ -127,8 +126,7 @@ class boss_jaraxxus : public CreatureScript
if (who->GetTypeId() == TYPEID_PLAYER)
{
Talk(SAY_KILL_PLAYER);
- if (instance)
- instance->SetData(DATA_TRIBUTE_TO_IMMORTALITY_ELIGIBLE, 0);
+ instance->SetData(DATA_TRIBUTE_TO_IMMORTALITY_ELIGIBLE, 0);
}
}
@@ -214,7 +212,7 @@ class boss_jaraxxus : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_jaraxxusAI(creature);
+ return GetInstanceAI<boss_jaraxxusAI>(creature);
}
};
@@ -250,7 +248,7 @@ class npc_legion_flame : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_legion_flameAI(creature);
+ return GetInstanceAI<npc_legion_flameAI>(creature);
}
};
@@ -355,7 +353,7 @@ class npc_fel_infernal : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_fel_infernalAI(creature);
+ return GetInstanceAI<npc_fel_infernalAI>(creature);
}
};
@@ -488,7 +486,7 @@ class npc_mistress_of_pain : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_mistress_of_painAI(creature);
+ return GetInstanceAI<npc_mistress_of_painAI>(creature);
}
};
diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_northrend_beasts.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_northrend_beasts.cpp
index 7843808a6a3..0209c1d9ac8 100644
--- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_northrend_beasts.cpp
+++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_northrend_beasts.cpp
@@ -195,17 +195,14 @@ class boss_gormok : public CreatureScript
void JustDied(Unit* /*killer*/) OVERRIDE
{
- if (instance)
- instance->SetData(TYPE_NORTHREND_BEASTS, GORMOK_DONE);
+ instance->SetData(TYPE_NORTHREND_BEASTS, GORMOK_DONE);
}
void JustReachedHome() OVERRIDE
{
- if (instance)
- {
- instance->DoUseDoorOrButton(instance->GetData64(GO_MAIN_GATE_DOOR));
- instance->SetData(TYPE_NORTHREND_BEASTS, FAIL);
- }
+ instance->DoUseDoorOrButton(instance->GetData64(GO_MAIN_GATE_DOOR));
+ instance->SetData(TYPE_NORTHREND_BEASTS, FAIL);
+
me->DespawnOrUnsummon();
}
@@ -284,7 +281,7 @@ class boss_gormok : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_gormokAI(creature);
+ return GetInstanceAI<boss_gormokAI>(creature);
}
};
@@ -454,7 +451,7 @@ class npc_snobold_vassal : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_snobold_vassalAI(creature);
+ return GetInstanceAI<npc_snobold_vassalAI>(creature);
}
};
@@ -490,7 +487,7 @@ class npc_firebomb : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_firebombAI(creature);
+ return GetInstanceAI<npc_firebombAI>(creature);
}
};
@@ -514,20 +511,17 @@ struct boss_jormungarAI : public BossAI
void JustDied(Unit* /*killer*/) OVERRIDE
{
- if (instance)
+ if (Creature* otherWorm = Unit::GetCreature(*me, instance->GetData64(OtherWormEntry)))
{
- if (Creature* otherWorm = Unit::GetCreature(*me, instance->GetData64(OtherWormEntry)))
+ if (!otherWorm->IsAlive())
{
- if (!otherWorm->IsAlive())
- {
- instance->SetData(TYPE_NORTHREND_BEASTS, SNAKES_DONE);
+ instance->SetData(TYPE_NORTHREND_BEASTS, SNAKES_DONE);
- me->DespawnOrUnsummon();
- otherWorm->DespawnOrUnsummon();
- }
- else
- instance->SetData(TYPE_NORTHREND_BEASTS, SNAKES_SPECIAL);
+ me->DespawnOrUnsummon();
+ otherWorm->DespawnOrUnsummon();
}
+ else
+ instance->SetData(TYPE_NORTHREND_BEASTS, SNAKES_SPECIAL);
}
}
@@ -543,16 +537,14 @@ struct boss_jormungarAI : public BossAI
void KilledUnit(Unit* who) OVERRIDE
{
if (who->GetTypeId() == TYPEID_PLAYER)
- if (instance)
- instance->SetData(DATA_TRIBUTE_TO_IMMORTALITY_ELIGIBLE, 0);
+ instance->SetData(DATA_TRIBUTE_TO_IMMORTALITY_ELIGIBLE, 0);
}
void EnterCombat(Unit* /*who*/) OVERRIDE
{
_EnterCombat();
me->SetInCombatWithZone();
- if (instance)
- instance->SetData(TYPE_NORTHREND_BEASTS, SNAKES_IN_PROGRESS);
+ instance->SetData(TYPE_NORTHREND_BEASTS, SNAKES_IN_PROGRESS);
}
void UpdateAI(uint32 diff) OVERRIDE
@@ -712,7 +704,7 @@ class boss_acidmaw : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_acidmawAI(creature);
+ return GetInstanceAI<boss_acidmawAI>(creature);
}
};
@@ -770,8 +762,7 @@ class boss_dreadscale : public CreatureScript
void JustReachedHome() OVERRIDE
{
- if (instance)
- instance->DoUseDoorOrButton(instance->GetData64(GO_MAIN_GATE_DOOR));
+ instance->DoUseDoorOrButton(instance->GetData64(GO_MAIN_GATE_DOOR));
boss_jormungarAI::JustReachedHome();
}
@@ -779,7 +770,7 @@ class boss_dreadscale : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_dreadscaleAI(creature);
+ return GetInstanceAI<boss_dreadscaleAI>(creature);
}
};
@@ -820,7 +811,7 @@ class npc_slime_pool : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_slime_poolAI(creature);
+ return GetInstanceAI<npc_slime_poolAI>(creature);
}
};
@@ -873,7 +864,7 @@ class boss_icehowl : public CreatureScript
events.ScheduleEvent(EVENT_MASSIVE_CRASH, 30*IN_MILLISECONDS);
_movementStarted = false;
_movementFinish = false;
- _trampleCasted = false;
+ _trampleCast = false;
_trampleTargetGUID = 0;
_trampleTargetX = 0;
_trampleTargetY = 0;
@@ -884,8 +875,7 @@ class boss_icehowl : public CreatureScript
void JustDied(Unit* /*killer*/) OVERRIDE
{
_JustDied();
- if (instance)
- instance->SetData(TYPE_NORTHREND_BEASTS, ICEHOWL_DONE);
+ instance->SetData(TYPE_NORTHREND_BEASTS, ICEHOWL_DONE);
}
void MovementInform(uint32 type, uint32 pointId) OVERRIDE
@@ -933,11 +923,8 @@ class boss_icehowl : public CreatureScript
void JustReachedHome() OVERRIDE
{
- if (instance)
- {
- instance->DoUseDoorOrButton(instance->GetData64(GO_MAIN_GATE_DOOR));
- instance->SetData(TYPE_NORTHREND_BEASTS, FAIL);
- }
+ instance->DoUseDoorOrButton(instance->GetData64(GO_MAIN_GATE_DOOR));
+ instance->SetData(TYPE_NORTHREND_BEASTS, FAIL);
me->DespawnOrUnsummon();
}
@@ -945,26 +932,24 @@ class boss_icehowl : public CreatureScript
{
if (who->GetTypeId() == TYPEID_PLAYER)
{
- if (instance)
- instance->SetData(DATA_TRIBUTE_TO_IMMORTALITY_ELIGIBLE, 0);
+ instance->SetData(DATA_TRIBUTE_TO_IMMORTALITY_ELIGIBLE, 0);
}
}
void EnterCombat(Unit* /*who*/) OVERRIDE
{
_EnterCombat();
- if (instance)
- instance->SetData(TYPE_NORTHREND_BEASTS, ICEHOWL_IN_PROGRESS);
+ instance->SetData(TYPE_NORTHREND_BEASTS, ICEHOWL_IN_PROGRESS);
}
void SpellHitTarget(Unit* target, SpellInfo const* spell) OVERRIDE
{
if (spell->Id == SPELL_TRAMPLE && target->GetTypeId() == TYPEID_PLAYER)
{
- if (!_trampleCasted)
+ if (!_trampleCast)
{
DoCast(me, SPELL_FROTHING_RAGE, true);
- _trampleCasted = true;
+ _trampleCast = true;
}
}
}
@@ -1025,7 +1010,7 @@ class boss_icehowl : public CreatureScript
me->AttackStop();
_trampleTargetGUID = target->GetGUID();
me->SetTarget(_trampleTargetGUID);
- _trampleCasted = false;
+ _trampleCast = false;
SetCombatMovement(false);
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_DISABLE_MOVE);
me->GetMotionMaster()->Clear();
@@ -1047,7 +1032,7 @@ class boss_icehowl : public CreatureScript
{
me->StopMoving();
me->AttackStop();
- _trampleCasted = false;
+ _trampleCast = false;
_movementStarted = true;
_trampleTargetX = target->GetPositionX();
_trampleTargetY = target->GetPositionY();
@@ -1100,7 +1085,7 @@ class boss_icehowl : public CreatureScript
}
break;
case 6:
- if (!_trampleCasted)
+ if (!_trampleCast)
{
DoCast(me, SPELL_STAGGERED_DAZE);
Talk(EMOTE_TRAMPLE_CRASH);
@@ -1131,13 +1116,13 @@ class boss_icehowl : public CreatureScript
uint64 _trampleTargetGUID;
bool _movementStarted;
bool _movementFinish;
- bool _trampleCasted;
+ bool _trampleCast;
uint8 _stage;
};
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_icehowlAI(creature);
+ return GetInstanceAI<boss_icehowlAI>(creature);
}
};
diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_twin_valkyr.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_twin_valkyr.cpp
index 0674696a033..e81cfee1b98 100644
--- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_twin_valkyr.cpp
+++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_twin_valkyr.cpp
@@ -165,8 +165,7 @@ struct boss_twin_baseAI : public BossAI
void JustReachedHome() OVERRIDE
{
- if (instance)
- instance->SetBossState(BOSS_VALKIRIES, FAIL);
+ instance->SetBossState(BOSS_VALKIRIES, FAIL);
summons.DespawnAll();
me->DespawnOrUnsummon();
@@ -193,8 +192,7 @@ struct boss_twin_baseAI : public BossAI
if (who->GetTypeId() == TYPEID_PLAYER)
{
Talk(SAY_KILL_PLAYER);
- if (instance)
- instance->SetData(DATA_TRIBUTE_TO_IMMORTALITY_ELIGIBLE, 0);
+ instance->SetData(DATA_TRIBUTE_TO_IMMORTALITY_ELIGIBLE, 0);
}
}
@@ -227,21 +225,18 @@ struct boss_twin_baseAI : public BossAI
void JustDied(Unit* /*killer*/) OVERRIDE
{
Talk(SAY_DEATH);
- if (instance)
+ if (Creature* pSister = GetSister())
{
- if (Creature* pSister = GetSister())
+ if (!pSister->IsAlive())
{
- if (!pSister->IsAlive())
- {
- me->SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
- pSister->SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
- _JustDied();
- }
- else
- {
- me->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
- instance->SetBossState(BOSS_VALKIRIES, SPECIAL);
- }
+ me->SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
+ pSister->SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
+ _JustDied();
+ }
+ else
+ {
+ me->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
+ instance->SetBossState(BOSS_VALKIRIES, SPECIAL);
}
}
summons.DespawnAll();
@@ -256,15 +251,12 @@ struct boss_twin_baseAI : public BossAI
void EnterCombat(Unit* /*who*/) OVERRIDE
{
me->SetInCombatWithZone();
- if (instance)
+ if (Creature* pSister = GetSister())
{
- if (Creature* pSister = GetSister())
- {
- me->AddAura(MyEmphatySpellId, pSister);
- pSister->SetInCombatWithZone();
- }
- instance->SetBossState(BOSS_VALKIRIES, IN_PROGRESS);
+ me->AddAura(MyEmphatySpellId, pSister);
+ pSister->SetInCombatWithZone();
}
+ instance->SetBossState(BOSS_VALKIRIES, IN_PROGRESS);
Talk(SAY_AGGRO);
DoCast(me, SurgeSpellId);
@@ -420,15 +412,13 @@ class boss_fjola : public CreatureScript
TouchSpellId = SPELL_LIGHT_TOUCH;
SpikeSpellId = SPELL_LIGHT_TWIN_SPIKE;
- if (instance)
- instance->DoStopTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, EVENT_START_TWINS_FIGHT);
+ instance->DoStopTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, EVENT_START_TWINS_FIGHT);
boss_twin_baseAI::Reset();
}
void EnterCombat(Unit* who) OVERRIDE
{
- if (instance)
- instance->DoStartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, EVENT_START_TWINS_FIGHT);
+ instance->DoStartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, EVENT_START_TWINS_FIGHT);
me->SummonCreature(NPC_BULLET_CONTROLLER, ToCCommonLoc[1].GetPositionX(), ToCCommonLoc[1].GetPositionY(), ToCCommonLoc[1].GetPositionZ(), 0.0f, TEMPSUMMON_MANUAL_DESPAWN);
boss_twin_baseAI::EnterCombat(who);
@@ -442,8 +432,7 @@ class boss_fjola : public CreatureScript
void JustReachedHome() OVERRIDE
{
- if (instance)
- instance->DoUseDoorOrButton(instance->GetData64(GO_MAIN_GATE_DOOR));
+ instance->DoUseDoorOrButton(instance->GetData64(GO_MAIN_GATE_DOOR));
boss_twin_baseAI::JustReachedHome();
}
@@ -451,7 +440,7 @@ class boss_fjola : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_fjolaAI(creature);
+ return GetInstanceAI<boss_fjolaAI>(creature);
}
};
@@ -486,7 +475,7 @@ class boss_eydis : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_eydisAI(creature);
+ return GetInstanceAI<boss_eydisAI>(creature);
}
};
diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/trial_of_the_crusader.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/trial_of_the_crusader.cpp
index 36cf9432d96..cd3a4e26924 100644
--- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/trial_of_the_crusader.cpp
+++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/trial_of_the_crusader.cpp
@@ -357,7 +357,7 @@ class boss_lich_king_toc : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_lich_king_tocAI(creature);
+ return GetInstanceAI<boss_lich_king_tocAI>(creature);
}
};
@@ -531,7 +531,7 @@ class npc_fizzlebang_toc : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_fizzlebang_tocAI(creature);
+ return GetInstanceAI<npc_fizzlebang_tocAI>(creature);
}
};
@@ -819,7 +819,7 @@ class npc_tirion_toc : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_tirion_tocAI(creature);
+ return GetInstanceAI<npc_tirion_tocAI>(creature);
}
};
@@ -903,7 +903,7 @@ class npc_garrosh_toc : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_garrosh_tocAI(creature);
+ return GetInstanceAI<npc_garrosh_tocAI>(creature);
}
};
@@ -987,7 +987,7 @@ class npc_varian_toc : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_varian_tocAI(creature);
+ return GetInstanceAI<npc_varian_tocAI>(creature);
}
};
diff --git a/src/server/scripts/Northrend/DraktharonKeep/boss_king_dred.cpp b/src/server/scripts/Northrend/DraktharonKeep/boss_king_dred.cpp
index f8f0752184e..42f408861e1 100644
--- a/src/server/scripts/Northrend/DraktharonKeep/boss_king_dred.cpp
+++ b/src/server/scripts/Northrend/DraktharonKeep/boss_king_dred.cpp
@@ -27,7 +27,7 @@ enum Spells
{
SPELL_BELLOWING_ROAR = 22686, // fears the group, can be resisted/dispelled
SPELL_GRIEVOUS_BITE = 48920,
- SPELL_MANGLING_SLASH = 48873, // casted on the current tank, adds debuf
+ SPELL_MANGLING_SLASH = 48873, // cast on the current tank, adds debuf
SPELL_FEARSOME_ROAR = 48849,
SPELL_PIERCING_SLASH = 48878, // debuff --> Armor reduced by 75%
SPELL_RAPTOR_CALL = 59416, // dummy
diff --git a/src/server/scripts/Northrend/DraktharonKeep/boss_tharon_ja.cpp b/src/server/scripts/Northrend/DraktharonKeep/boss_tharon_ja.cpp
index efca060b67c..78399749fe6 100644
--- a/src/server/scripts/Northrend/DraktharonKeep/boss_tharon_ja.cpp
+++ b/src/server/scripts/Northrend/DraktharonKeep/boss_tharon_ja.cpp
@@ -32,7 +32,7 @@ enum Spells
SPELL_CURSE_OF_LIFE = 49527,
SPELL_RAIN_OF_FIRE = 49518,
SPELL_SHADOW_VOLLEY = 49528,
- SPELL_DECAY_FLESH = 49356, // casted at end of phase 1, starts phase 2
+ SPELL_DECAY_FLESH = 49356, // cast at end of phase 1, starts phase 2
// Flesh Spells (phase 2)
SPELL_GIFT_OF_THARON_JA = 52509,
SPELL_CLEAR_GIFT_OF_THARON_JA = 53242,
diff --git a/src/server/scripts/Northrend/DraktharonKeep/instance_drak_tharon_keep.cpp b/src/server/scripts/Northrend/DraktharonKeep/instance_drak_tharon_keep.cpp
index d9e34ee2af3..445e3fa5f68 100644
--- a/src/server/scripts/Northrend/DraktharonKeep/instance_drak_tharon_keep.cpp
+++ b/src/server/scripts/Northrend/DraktharonKeep/instance_drak_tharon_keep.cpp
@@ -170,7 +170,7 @@ class instance_drak_tharon_keep : public InstanceMapScript
return saveStream.str();
}
- void Load(char const* str) OVERRIDE OVERRIDE
+ void Load(char const* str) OVERRIDE
{
if (!str)
{
diff --git a/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_bronjahm.cpp b/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_bronjahm.cpp
index 2dedc986b0c..5ef97aa87cf 100644
--- a/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_bronjahm.cpp
+++ b/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_bronjahm.cpp
@@ -188,7 +188,7 @@ class boss_bronjahm : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_bronjahmAI(creature);
+ return GetInstanceAI<boss_bronjahmAI>(creature);
}
};
@@ -209,19 +209,16 @@ class npc_corrupted_soul_fragment : public CreatureScript
if (type != CHASE_MOTION_TYPE)
return;
- if (instance)
+ if (TempSummon* summ = me->ToTempSummon())
{
- if (TempSummon* summ = me->ToTempSummon())
- {
- uint64 BronjahmGUID = instance->GetData64(DATA_BRONJAHM);
- if (GUID_LOPART(BronjahmGUID) != id)
- return;
+ uint64 BronjahmGUID = instance->GetData64(DATA_BRONJAHM);
+ if (GUID_LOPART(BronjahmGUID) != id)
+ return;
- if (Creature* bronjahm = ObjectAccessor::GetCreature(*me, BronjahmGUID))
- me->CastSpell(bronjahm, SPELL_CONSUME_SOUL, true);
+ if (Creature* bronjahm = ObjectAccessor::GetCreature(*me, BronjahmGUID))
+ me->CastSpell(bronjahm, SPELL_CONSUME_SOUL, true);
- summ->UnSummon();
- }
+ summ->UnSummon();
}
}
@@ -231,7 +228,7 @@ class npc_corrupted_soul_fragment : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_corrupted_soul_fragmentAI(creature);
+ return GetInstanceAI<npc_corrupted_soul_fragmentAI>(creature);
}
};
diff --git a/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_devourer_of_souls.cpp b/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_devourer_of_souls.cpp
index 7d923e7686f..52ab910fb9e 100644
--- a/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_devourer_of_souls.cpp
+++ b/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_devourer_of_souls.cpp
@@ -345,7 +345,7 @@ class boss_devourer_of_souls : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_devourer_of_soulsAI(creature);
+ return GetInstanceAI<boss_devourer_of_soulsAI>(creature);
}
};
@@ -480,9 +480,7 @@ class spell_devourer_of_souls_mirrored_soul_target_selector : public SpellScript
class achievement_three_faced : public AchievementCriteriaScript
{
public:
- achievement_three_faced() : AchievementCriteriaScript("achievement_three_faced")
- {
- }
+ achievement_three_faced() : AchievementCriteriaScript("achievement_three_faced") { }
bool OnCheck(Player* /*player*/, Unit* target) OVERRIDE
{
diff --git a/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/forge_of_souls.cpp b/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/forge_of_souls.cpp
index cfa149c134f..4d2a87a3850 100644
--- a/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/forge_of_souls.cpp
+++ b/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/forge_of_souls.cpp
@@ -113,9 +113,6 @@ public:
{
if (phase == PHASE_INTRO)
{
- if (!instance)
- return;
-
events.Update(diff);
switch (events.ExecuteEvent())
{
@@ -193,7 +190,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_sylvanas_fosAI(creature);
+ return GetInstanceAI<npc_sylvanas_fosAI>(creature);
}
};
@@ -239,9 +236,6 @@ public:
{
if (phase == PHASE_INTRO)
{
- if (!instance)
- return;
-
events.Update(diff);
switch (events.ExecuteEvent())
{
@@ -330,7 +324,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_jaina_fosAI(creature);
+ return GetInstanceAI<npc_jaina_fosAI>(creature);
}
};
diff --git a/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/boss_falric.cpp b/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/boss_falric.cpp
index e2d285f7306..a7111a1d07f 100644
--- a/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/boss_falric.cpp
+++ b/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/boss_falric.cpp
@@ -52,7 +52,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_falricAI(creature);
+ return GetInstanceAI<boss_falricAI>(creature);
}
struct boss_falricAI : public boss_horAI
@@ -67,15 +67,13 @@ public:
uiHopelessnessCount = 0;
- if (instance)
- instance->SetBossState(DATA_FALRIC_EVENT, NOT_STARTED);
+ instance->SetBossState(DATA_FALRIC_EVENT, NOT_STARTED);
}
void EnterCombat(Unit* /*who*/) OVERRIDE
{
Talk(SAY_AGGRO);
- if (instance)
- instance->SetBossState(DATA_FALRIC_EVENT, IN_PROGRESS);
+ instance->SetBossState(DATA_FALRIC_EVENT, IN_PROGRESS);
events.ScheduleEvent(EVENT_QUIVERING_STRIKE, 23000);
events.ScheduleEvent(EVENT_IMPENDING_DESPAIR, 9000);
@@ -86,8 +84,7 @@ public:
{
Talk(SAY_DEATH);
- if (instance)
- instance->SetBossState(DATA_FALRIC_EVENT, DONE);
+ instance->SetBossState(DATA_FALRIC_EVENT, DONE);
}
void KilledUnit(Unit* /*victim*/) OVERRIDE
diff --git a/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/boss_marwyn.cpp b/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/boss_marwyn.cpp
index a87b7b6d93d..ae448bdc65c 100644
--- a/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/boss_marwyn.cpp
+++ b/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/boss_marwyn.cpp
@@ -51,7 +51,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_marwynAI(creature);
+ return GetInstanceAI<boss_marwynAI>(creature);
}
struct boss_marwynAI : public boss_horAI
@@ -62,15 +62,13 @@ public:
{
boss_horAI::Reset();
- if (instance)
- instance->SetBossState(DATA_MARWYN_EVENT, NOT_STARTED);
+ instance->SetBossState(DATA_MARWYN_EVENT, NOT_STARTED);
}
void EnterCombat(Unit* /*who*/) OVERRIDE
{
Talk(SAY_AGGRO);
- if (instance)
- instance->SetBossState(DATA_MARWYN_EVENT, IN_PROGRESS);
+ instance->SetBossState(DATA_MARWYN_EVENT, IN_PROGRESS);
events.ScheduleEvent(EVENT_OBLITERATE, 30000); /// @todo Check timer
events.ScheduleEvent(EVENT_WELL_OF_CORRUPTION, 13000);
@@ -82,8 +80,7 @@ public:
{
Talk(SAY_DEATH);
- if (instance)
- instance->SetBossState(DATA_MARWYN_EVENT, DONE);
+ instance->SetBossState(DATA_MARWYN_EVENT, DONE);
}
void KilledUnit(Unit* /*victim*/) OVERRIDE
diff --git a/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/halls_of_reflection.cpp b/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/halls_of_reflection.cpp
index 96b772df5a9..9e4fe02a361 100644
--- a/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/halls_of_reflection.cpp
+++ b/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/halls_of_reflection.cpp
@@ -1283,7 +1283,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_ghostly_priestAI(creature);
+ return GetInstanceAI<npc_ghostly_priestAI>(creature);
}
};
@@ -1355,7 +1355,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_phantom_mageAI(creature);
+ return GetInstanceAI<npc_phantom_mageAI>(creature);
}
};
@@ -1377,7 +1377,7 @@ public:
void EnterEvadeMode() OVERRIDE
{
- if (!me->GetOwner()->HasAura(AURA_HALLUCINATION))
+ if (me->GetOwner() && !me->GetOwner()->HasAura(AURA_HALLUCINATION))
npc_phantom_mage::npc_phantom_mageAI::EnterEvadeMode();
}
@@ -1447,7 +1447,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_shadowy_mercenaryAI(creature);
+ return GetInstanceAI<npc_shadowy_mercenaryAI>(creature);
}
};
@@ -1499,7 +1499,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_spectral_footmanAI(creature);
+ return GetInstanceAI<npc_spectral_footmanAI>(creature);
}
};
@@ -1558,7 +1558,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_tortured_riflemanAI(creature);
+ return GetInstanceAI<npc_tortured_riflemanAI>(creature);
}
};
@@ -1674,7 +1674,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_frostworn_generalAI(creature);
+ return GetInstanceAI<npc_frostworn_generalAI>(creature);
}
};
@@ -1901,7 +1901,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_raging_ghoulAI(creature);
+ return GetInstanceAI<npc_raging_ghoulAI>(creature);
}
};
@@ -2021,7 +2021,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_risen_witch_doctorAI(creature);
+ return GetInstanceAI<npc_risen_witch_doctorAI>(creature);
}
};
@@ -2111,7 +2111,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_lumbering_abominationAI(creature);
+ return GetInstanceAI<npc_lumbering_abominationAI>(creature);
}
};
diff --git a/src/server/scripts/Northrend/Gundrak/boss_drakkari_colossus.cpp b/src/server/scripts/Northrend/Gundrak/boss_drakkari_colossus.cpp
index 93030492caf..c8e58ca700c 100644
--- a/src/server/scripts/Northrend/Gundrak/boss_drakkari_colossus.cpp
+++ b/src/server/scripts/Northrend/Gundrak/boss_drakkari_colossus.cpp
@@ -248,7 +248,7 @@ class boss_drakkari_colossus : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_drakkari_colossusAI(creature);
+ return GetInstanceAI<boss_drakkari_colossusAI>(creature);
}
};
@@ -278,11 +278,8 @@ class boss_drakkari_elemental : public CreatureScript
if (killer == me)
return;
- if (instance)
- {
- if (Creature* colossus = Unit::GetCreature(*me, instance->GetData64(DATA_DRAKKARI_COLOSSUS)))
- killer->Kill(colossus);
- }
+ if (Creature* colossus = Unit::GetCreature(*me, instance->GetData64(DATA_DRAKKARI_COLOSSUS)))
+ killer->Kill(colossus);
}
void UpdateAI(uint32 diff) OVERRIDE
@@ -317,12 +314,9 @@ class boss_drakkari_elemental : public CreatureScript
{
case ACTION_RETURN_TO_COLOSSUS:
DoCast(SPELL_SURGE_VISUAL);
- if (instance)
- {
- if (Creature* colossus = Unit::GetCreature(*me, instance->GetData64(DATA_DRAKKARI_COLOSSUS)))
- // what if the elemental is more than 80 yards from drakkari colossus ?
- DoCast(colossus, SPELL_MERGE, true);
- }
+ if (Creature* colossus = Unit::GetCreature(*me, instance->GetData64(DATA_DRAKKARI_COLOSSUS)))
+ // what if the elemental is more than 80 yards from drakkari colossus ?
+ DoCast(colossus, SPELL_MERGE, true);
break;
}
}
@@ -381,7 +375,7 @@ class boss_drakkari_elemental : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_drakkari_elementalAI(creature);
+ return GetInstanceAI<boss_drakkari_elementalAI>(creature);
}
};
@@ -392,7 +386,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_living_mojoAI(creature);
+ return GetInstanceAI<npc_living_mojoAI>(creature);
}
struct npc_living_mojoAI : public ScriptedAI
diff --git a/src/server/scripts/Northrend/Gundrak/boss_eck.cpp b/src/server/scripts/Northrend/Gundrak/boss_eck.cpp
index c11db7146d1..71d1748a3ea 100644
--- a/src/server/scripts/Northrend/Gundrak/boss_eck.cpp
+++ b/src/server/scripts/Northrend/Gundrak/boss_eck.cpp
@@ -37,7 +37,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_eckAI(creature);
+ return GetInstanceAI<boss_eckAI>(creature);
}
struct boss_eckAI : public ScriptedAI
@@ -65,14 +65,12 @@ public:
bBerserk = false;
- if (instance)
- instance->SetData(DATA_ECK_THE_FEROCIOUS_EVENT, NOT_STARTED);
+ instance->SetData(DATA_ECK_THE_FEROCIOUS_EVENT, NOT_STARTED);
}
void EnterCombat(Unit* /*who*/) OVERRIDE
{
- if (instance)
- instance->SetData(DATA_ECK_THE_FEROCIOUS_EVENT, IN_PROGRESS);
+ instance->SetData(DATA_ECK_THE_FEROCIOUS_EVENT, IN_PROGRESS);
}
void UpdateAI(uint32 diff) OVERRIDE
@@ -127,8 +125,7 @@ public:
void JustDied(Unit* /*killer*/) OVERRIDE
{
- if (instance)
- instance->SetData(DATA_ECK_THE_FEROCIOUS_EVENT, DONE);
+ instance->SetData(DATA_ECK_THE_FEROCIOUS_EVENT, DONE);
}
};
@@ -141,7 +138,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_ruins_dwellerAI(creature);
+ return GetInstanceAI<npc_ruins_dwellerAI>(creature);
}
struct npc_ruins_dwellerAI : public ScriptedAI
@@ -155,12 +152,9 @@ public:
void JustDied(Unit* /*killer*/) OVERRIDE
{
- if (instance)
- {
- instance->SetData64(DATA_RUIN_DWELLER_DIED, me->GetGUID());
- if (instance->GetData(DATA_ALIVE_RUIN_DWELLERS) == 0)
- me->SummonCreature(CREATURE_ECK, EckSpawnPoint, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 300*IN_MILLISECONDS);
- }
+ instance->SetData64(DATA_RUIN_DWELLER_DIED, me->GetGUID());
+ if (instance->GetData(DATA_ALIVE_RUIN_DWELLERS) == 0)
+ me->SummonCreature(CREATURE_ECK, EckSpawnPoint, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 300*IN_MILLISECONDS);
}
};
diff --git a/src/server/scripts/Northrend/Gundrak/boss_gal_darah.cpp b/src/server/scripts/Northrend/Gundrak/boss_gal_darah.cpp
index 7a5520ab145..5a3c4b8c694 100644
--- a/src/server/scripts/Northrend/Gundrak/boss_gal_darah.cpp
+++ b/src/server/scripts/Northrend/Gundrak/boss_gal_darah.cpp
@@ -70,7 +70,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_gal_darahAI(creature);
+ return GetInstanceAI<boss_gal_darahAI>(creature);
}
struct boss_gal_darahAI : public ScriptedAI
@@ -118,16 +118,14 @@ public:
me->SetDisplayId(DISPLAY_TROLL);
- if (instance)
- instance->SetData(DATA_GAL_DARAH_EVENT, NOT_STARTED);
+ instance->SetData(DATA_GAL_DARAH_EVENT, NOT_STARTED);
}
void EnterCombat(Unit* /*who*/) OVERRIDE
{
Talk(SAY_AGGRO);
- if (instance)
- instance->SetData(DATA_GAL_DARAH_EVENT, IN_PROGRESS);
+ instance->SetData(DATA_GAL_DARAH_EVENT, IN_PROGRESS);
}
void UpdateAI(uint32 diff) OVERRIDE
@@ -269,8 +267,7 @@ public:
{
Talk(SAY_DEATH);
- if (instance)
- instance->SetData(DATA_GAL_DARAH_EVENT, DONE);
+ instance->SetData(DATA_GAL_DARAH_EVENT, DONE);
}
void KilledUnit(Unit* victim) OVERRIDE
diff --git a/src/server/scripts/Northrend/Gundrak/boss_moorabi.cpp b/src/server/scripts/Northrend/Gundrak/boss_moorabi.cpp
index 0ccaea316ef..a69e236c6e9 100644
--- a/src/server/scripts/Northrend/Gundrak/boss_moorabi.cpp
+++ b/src/server/scripts/Northrend/Gundrak/boss_moorabi.cpp
@@ -54,7 +54,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_moorabiAI(creature);
+ return GetInstanceAI<boss_moorabiAI>(creature);
}
struct boss_moorabiAI : public ScriptedAI
@@ -81,8 +81,7 @@ public:
uiTransformationTImer = 12*IN_MILLISECONDS;
bPhase = false;
- if (instance)
- instance->SetData(DATA_MOORABI_EVENT, NOT_STARTED);
+ instance->SetData(DATA_MOORABI_EVENT, NOT_STARTED);
}
void EnterCombat(Unit* /*who*/) OVERRIDE
@@ -90,8 +89,7 @@ public:
Talk(SAY_AGGRO);
DoCast(me, SPELL_MOJO_FRENZY, true);
- if (instance)
- instance->SetData(DATA_MOORABI_EVENT, IN_PROGRESS);
+ instance->SetData(DATA_MOORABI_EVENT, IN_PROGRESS);
}
void UpdateAI(uint32 uiDiff) OVERRIDE
@@ -157,8 +155,7 @@ public:
{
Talk(SAY_DEATH);
- if (instance)
- instance->SetData(DATA_MOORABI_EVENT, DONE);
+ instance->SetData(DATA_MOORABI_EVENT, DONE);
}
void KilledUnit(Unit* victim) OVERRIDE
diff --git a/src/server/scripts/Northrend/Gundrak/boss_slad_ran.cpp b/src/server/scripts/Northrend/Gundrak/boss_slad_ran.cpp
index 441149c6dd8..25989ca9652 100644
--- a/src/server/scripts/Northrend/Gundrak/boss_slad_ran.cpp
+++ b/src/server/scripts/Northrend/Gundrak/boss_slad_ran.cpp
@@ -76,7 +76,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_slad_ranAI(creature);
+ return GetInstanceAI<boss_slad_ranAI>(creature);
}
struct boss_slad_ranAI : public ScriptedAI
@@ -109,16 +109,14 @@ public:
lSummons.DespawnAll();
- if (instance)
- instance->SetData(DATA_SLAD_RAN_EVENT, NOT_STARTED);
+ instance->SetData(DATA_SLAD_RAN_EVENT, NOT_STARTED);
}
void EnterCombat(Unit* /*who*/) OVERRIDE
{
Talk(SAY_AGGRO);
- if (instance)
- instance->SetData(DATA_SLAD_RAN_EVENT, IN_PROGRESS);
+ instance->SetData(DATA_SLAD_RAN_EVENT, IN_PROGRESS);
}
void UpdateAI(uint32 diff) OVERRIDE
@@ -180,13 +178,13 @@ public:
Talk(SAY_DEATH);
lSummons.DespawnAll();
- if (instance)
- instance->SetData(DATA_SLAD_RAN_EVENT, DONE);
+ instance->SetData(DATA_SLAD_RAN_EVENT, DONE);
}
- void KilledUnit(Unit* /*victim*/) OVERRIDE
+ void KilledUnit(Unit* who) OVERRIDE
{
- Talk(SAY_SLAY);
+ if (who->GetTypeId() == TYPEID_PLAYER)
+ Talk(SAY_SLAY);
}
void JustSummoned(Creature* summoned) OVERRIDE
diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp
index cdcd8ed796a..92c97ce6abf 100644
--- a/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp
+++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp
@@ -739,7 +739,7 @@ class npc_putricide_oozeAI : public ScriptedAI
if (!UpdateVictim() && !_newTargetSelectTimer)
return;
- if (!_newTargetSelectTimer && !me->IsNonMeleeSpellCasted(false, false, true, false, true))
+ if (!_newTargetSelectTimer && !me->IsNonMeleeSpellCast(false, false, true, false, true))
_newTargetSelectTimer = 1000;
DoMeleeAttackIfReady();
diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp
index bbd700b7edd..9684c7d9cdf 100644
--- a/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp
+++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp
@@ -666,7 +666,7 @@ class npc_the_lich_king_controller : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_the_lich_king_controllerAI(creature);
+ return GetInstanceAI<npc_the_lich_king_controllerAI>(creature);
}
};
diff --git a/src/server/scripts/Northrend/Naxxramas/boss_anubrekhan.cpp b/src/server/scripts/Northrend/Naxxramas/boss_anubrekhan.cpp
index b873b3ee15c..da2dc8583a8 100644
--- a/src/server/scripts/Northrend/Naxxramas/boss_anubrekhan.cpp
+++ b/src/server/scripts/Northrend/Naxxramas/boss_anubrekhan.cpp
@@ -59,7 +59,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_anubrekhanAI(creature);
+ return GetInstanceAI<boss_anubrekhanAI>(creature);
}
struct boss_anubrekhanAI : public BossAI
@@ -105,8 +105,7 @@ public:
_JustDied();
// start achievement timer (kill Maexna within 20 min)
- if (instance)
- instance->DoStartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_TIMED_START_EVENT);
+ instance->DoStartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_TIMED_START_EVENT);
}
void EnterCombat(Unit* /*who*/) OVERRIDE
{
diff --git a/src/server/scripts/Northrend/Naxxramas/boss_faerlina.cpp b/src/server/scripts/Northrend/Naxxramas/boss_faerlina.cpp
index b723c2f4139..2d216c78ea8 100644
--- a/src/server/scripts/Northrend/Naxxramas/boss_faerlina.cpp
+++ b/src/server/scripts/Northrend/Naxxramas/boss_faerlina.cpp
@@ -216,7 +216,7 @@ class npc_faerlina_add : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_faerlina_addAI(creature);
+ return GetInstanceAI<npc_faerlina_addAI>(creature);
}
};
diff --git a/src/server/scripts/Northrend/Naxxramas/boss_four_horsemen.cpp b/src/server/scripts/Northrend/Naxxramas/boss_four_horsemen.cpp
index 9b336a77e26..b57cb3af190 100644
--- a/src/server/scripts/Northrend/Naxxramas/boss_four_horsemen.cpp
+++ b/src/server/scripts/Northrend/Naxxramas/boss_four_horsemen.cpp
@@ -89,7 +89,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_four_horsemenAI(creature);
+ return GetInstanceAI<boss_four_horsemenAI>(creature);
}
struct boss_four_horsemenAI : public BossAI
@@ -121,8 +121,7 @@ public:
if (!encounterActionReset)
DoEncounteraction(NULL, false, true, false);
- if (instance)
- instance->SetData(DATA_HORSEMEN0 + id, NOT_STARTED);
+ instance->SetData(DATA_HORSEMEN0 + id, NOT_STARTED);
me->SetReactState(REACT_AGGRESSIVE);
uiEventStarterGUID = 0;
@@ -139,9 +138,6 @@ public:
bool DoEncounteraction(Unit* who, bool attack, bool reset, bool checkAllDead)
{
- if (!instance)
- return false;
-
Creature* Thane = Unit::GetCreature(*me, instance->GetData64(DATA_THANE));
Creature* Lady = Unit::GetCreature(*me, instance->GetData64(DATA_LADY));
Creature* Baron = Unit::GetCreature(*me, instance->GetData64(DATA_BARON));
@@ -301,10 +297,9 @@ public:
events.Reset();
summons.DespawnAll();
- if (instance)
- instance->SetData(DATA_HORSEMEN0 + id, DONE);
+ instance->SetData(DATA_HORSEMEN0 + id, DONE);
- if (instance && DoEncounteraction(NULL, false, false, true))
+ if (DoEncounteraction(NULL, false, false, true))
{
instance->SetBossState(BOSS_HORSEMEN, DONE);
instance->SaveToDB();
diff --git a/src/server/scripts/Northrend/Naxxramas/boss_gothik.cpp b/src/server/scripts/Northrend/Naxxramas/boss_gothik.cpp
index f76c46d96ff..9e5dac9c50b 100644
--- a/src/server/scripts/Northrend/Naxxramas/boss_gothik.cpp
+++ b/src/server/scripts/Northrend/Naxxramas/boss_gothik.cpp
@@ -181,8 +181,7 @@ class boss_gothik : public CreatureScript
DeadTriggerGUID.clear();
me->SetReactState(REACT_PASSIVE);
- if (instance)
- instance->SetData(DATA_GOTHIK_GATE, GO_STATE_ACTIVE);
+ instance->SetData(DATA_GOTHIK_GATE, GO_STATE_ACTIVE);
_Reset();
mergedSides = false;
phaseTwo = false;
@@ -210,8 +209,7 @@ class boss_gothik : public CreatureScript
events.ScheduleEvent(EVENT_SUMMON, 30000);
DoTeleportTo(PosPlatform);
Talk(SAY_SPEECH);
- if (instance)
- instance->SetData(DATA_GOTHIK_GATE, GO_STATE_READY);
+ instance->SetData(DATA_GOTHIK_GATE, GO_STATE_READY);
}
void JustSummoned(Creature* summon) OVERRIDE
@@ -248,8 +246,7 @@ class boss_gothik : public CreatureScript
DeadTriggerGUID.clear();
_JustDied();
Talk(SAY_DEATH);
- if (instance)
- instance->SetData(DATA_GOTHIK_GATE, GO_STATE_ACTIVE);
+ instance->SetData(DATA_GOTHIK_GATE, GO_STATE_ACTIVE);
}
void DoGothikSummon(uint32 entry)
@@ -403,8 +400,7 @@ class boss_gothik : public CreatureScript
if (!thirtyPercentReached && HealthBelowPct(30) && phaseTwo)
{
thirtyPercentReached = true;
- if (instance)
- instance->SetData(DATA_GOTHIK_GATE, GO_STATE_ACTIVE);
+ instance->SetData(DATA_GOTHIK_GATE, GO_STATE_ACTIVE);
}
if (me->HasUnitState(UNIT_STATE_CASTING))
@@ -429,8 +425,7 @@ class boss_gothik : public CreatureScript
{
if (!CheckGroupSplitted())
{
- if (instance)
- instance->SetData(DATA_GOTHIK_GATE, GO_STATE_ACTIVE);
+ instance->SetData(DATA_GOTHIK_GATE, GO_STATE_ACTIVE);
DummyEntryCheckPredicate pred;
summons.DoAction(0, pred); //! Magic numbers fail
summons.DoZoneInCombat();
@@ -500,7 +495,7 @@ class boss_gothik : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_gothikAI(creature);
+ return GetInstanceAI<boss_gothikAI>(creature);
}
};
diff --git a/src/server/scripts/Northrend/Naxxramas/boss_heigan.cpp b/src/server/scripts/Northrend/Naxxramas/boss_heigan.cpp
index a8e2783602f..3dad2798d2f 100644
--- a/src/server/scripts/Northrend/Naxxramas/boss_heigan.cpp
+++ b/src/server/scripts/Northrend/Naxxramas/boss_heigan.cpp
@@ -61,7 +61,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_heiganAI(creature);
+ return GetInstanceAI<boss_heiganAI>(creature);
}
struct boss_heiganAI : public BossAI
diff --git a/src/server/scripts/Northrend/Naxxramas/boss_kelthuzad.cpp b/src/server/scripts/Northrend/Naxxramas/boss_kelthuzad.cpp
index f9efdfce28b..169c3241a73 100644
--- a/src/server/scripts/Northrend/Naxxramas/boss_kelthuzad.cpp
+++ b/src/server/scripts/Northrend/Naxxramas/boss_kelthuzad.cpp
@@ -310,8 +310,7 @@ public:
FindGameObjects();
- if (instance)
- instance->SetData(DATA_ABOMINATION_KILLED, 0);
+ instance->SetData(DATA_ABOMINATION_KILLED, 0);
if (GameObject* pKTTrigger = me->GetMap()->GetGameObject(KTTriggerGUID))
{
@@ -649,7 +648,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_kelthuzadAI(creature);
+ return GetInstanceAI<boss_kelthuzadAI>(creature);
}
};
@@ -769,7 +768,7 @@ class npc_kelthuzad_abomination : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_kelthuzad_abominationAI(creature);
+ return GetInstanceAI<npc_kelthuzad_abominationAI>(creature);
}
};
diff --git a/src/server/scripts/Northrend/Naxxramas/boss_noth.cpp b/src/server/scripts/Northrend/Naxxramas/boss_noth.cpp
index d90db5e077e..d653be216dc 100644
--- a/src/server/scripts/Northrend/Naxxramas/boss_noth.cpp
+++ b/src/server/scripts/Northrend/Naxxramas/boss_noth.cpp
@@ -37,23 +37,20 @@ enum Noth
NPC_GUARDIAN = 16981
};
-#define SPELL_BLINK RAND(29208, 29209, 29210, 29211)
+#define SPELL_BLINK RAND(29208, 29209, 29210, 29211)
// Teleport position of Noth on his balcony
-#define TELE_X 2631.370f
-#define TELE_Y -3529.680f
-#define TELE_Z 274.040f
-#define TELE_O 6.277f
+Position const Teleport = { 2631.370f, -3529.680f, 274.040f, 6.277f };
#define MAX_SUMMON_POS 5
-const float SummonPos[MAX_SUMMON_POS][4] =
+Position const SummonPos[MAX_SUMMON_POS] =
{
- {2728.12f, -3544.43f, 261.91f, 6.04f},
- {2729.05f, -3544.47f, 261.91f, 5.58f},
- {2728.24f, -3465.08f, 264.20f, 3.56f},
- {2704.11f, -3456.81f, 265.53f, 4.51f},
- {2663.56f, -3464.43f, 262.66f, 5.20f},
+ { 2728.12f, -3544.43f, 261.91f, 6.04f },
+ { 2729.05f, -3544.47f, 261.91f, 5.58f },
+ { 2728.24f, -3465.08f, 264.20f, 3.56f },
+ { 2704.11f, -3456.81f, 265.53f, 4.51f },
+ { 2663.56f, -3464.43f, 262.66f, 5.20f }
};
enum Events
@@ -65,7 +62,7 @@ enum Events
EVENT_WARRIOR,
EVENT_BALCONY,
EVENT_WAVE,
- EVENT_GROUND,
+ EVENT_GROUND
};
class boss_noth : public CreatureScript
@@ -73,17 +70,10 @@ class boss_noth : public CreatureScript
public:
boss_noth() : CreatureScript("boss_noth") { }
- CreatureAI* GetAI(Creature* creature) const OVERRIDE
- {
- return new boss_nothAI(creature);
- }
-
struct boss_nothAI : public BossAI
{
boss_nothAI(Creature* creature) : BossAI(creature, BOSS_NOTH) { }
- uint32 waveCount, balconyCount;
-
void Reset() OVERRIDE
{
me->SetReactState(REACT_AGGRESSIVE);
@@ -104,6 +94,7 @@ public:
me->SetReactState(REACT_AGGRESSIVE);
me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
DoZoneInCombat();
+
if (me->getThreatManager().isThreatListEmpty())
EnterEvadeMode();
else
@@ -138,11 +129,7 @@ public:
void SummonUndead(uint32 entry, uint32 num)
{
for (uint32 i = 0; i < num; ++i)
- {
- uint32 pos = rand()%MAX_SUMMON_POS;
- me->SummonCreature(entry, SummonPos[pos][0], SummonPos[pos][1], SummonPos[pos][2],
- SummonPos[pos][3], TEMPSUMMON_CORPSE_DESPAWN, 60000);
- }
+ me->SummonCreature(entry, SummonPos[rand()%MAX_SUMMON_POS], TEMPSUMMON_CORPSE_DESPAWN, 60000);
}
void UpdateAI(uint32 diff) OVERRIDE
@@ -152,6 +139,9 @@ public:
events.Update(diff);
+ if (me->HasUnitState(UNIT_STATE_CASTING))
+ return;
+
while (uint32 eventId = events.ExecuteEvent())
{
switch (eventId)
@@ -176,7 +166,7 @@ public:
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
me->AttackStop();
me->RemoveAllAuras();
- me->NearTeleportTo(TELE_X, TELE_Y, TELE_Z, TELE_O);
+ me->NearTeleportTo(Teleport.GetPositionX(), Teleport.GetPositionY(), Teleport.GetPositionZ(), Teleport.GetOrientation());
events.Reset();
events.ScheduleEvent(EVENT_WAVE, urand(2000, 5000));
waveCount = 0;
@@ -185,12 +175,20 @@ public:
Talk(SAY_SUMMON);
switch (balconyCount)
{
- case 0: SummonUndead(NPC_CHAMPION, RAID_MODE(2, 4)); break;
- case 1: SummonUndead(NPC_CHAMPION, RAID_MODE(1, 2));
- SummonUndead(NPC_GUARDIAN, RAID_MODE(1, 2)); break;
- case 2: SummonUndead(NPC_GUARDIAN, RAID_MODE(2, 4)); break;
- default:SummonUndead(NPC_CHAMPION, RAID_MODE(5, 10));
- SummonUndead(NPC_GUARDIAN, RAID_MODE(5, 10));break;
+ case 0:
+ SummonUndead(NPC_CHAMPION, RAID_MODE(2, 4));
+ break;
+ case 1:
+ SummonUndead(NPC_CHAMPION, RAID_MODE(1, 2));
+ SummonUndead(NPC_GUARDIAN, RAID_MODE(1, 2));
+ break;
+ case 2:
+ SummonUndead(NPC_GUARDIAN, RAID_MODE(2, 4));
+ break;
+ default:
+ SummonUndead(NPC_CHAMPION, RAID_MODE(5, 10));
+ SummonUndead(NPC_GUARDIAN, RAID_MODE(5, 10));
+ break;
}
++waveCount;
events.ScheduleEvent(waveCount < 2 ? EVENT_WAVE : EVENT_GROUND, urand(30000, 45000));
@@ -211,8 +209,16 @@ public:
if (me->HasReactState(REACT_AGGRESSIVE))
DoMeleeAttackIfReady();
}
+
+ private:
+ uint32 waveCount;
+ uint32 balconyCount;
};
+ CreatureAI* GetAI(Creature* creature) const OVERRIDE
+ {
+ return GetInstanceAI<boss_nothAI>(creature);
+ }
};
void AddSC_boss_noth()
diff --git a/src/server/scripts/Northrend/Naxxramas/boss_patchwerk.cpp b/src/server/scripts/Northrend/Naxxramas/boss_patchwerk.cpp
index 96f2d743cac..e414bdaaa33 100644
--- a/src/server/scripts/Northrend/Naxxramas/boss_patchwerk.cpp
+++ b/src/server/scripts/Northrend/Naxxramas/boss_patchwerk.cpp
@@ -57,7 +57,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_patchwerkAI(creature);
+ return GetInstanceAI<boss_patchwerkAI>(creature);
}
struct boss_patchwerkAI : public BossAI
@@ -70,8 +70,7 @@ public:
{
_Reset();
- if (instance)
- instance->DoStopTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_MAKE_QUICK_WERK_OF_HIM_STARTING_EVENT);
+ instance->DoStopTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_MAKE_QUICK_WERK_OF_HIM_STARTING_EVENT);
}
void KilledUnit(Unit* /*Victim*/) OVERRIDE
@@ -94,8 +93,7 @@ public:
events.ScheduleEvent(EVENT_HATEFUL, 1000);
events.ScheduleEvent(EVENT_BERSERK, 360000);
- if (instance)
- instance->DoStartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_MAKE_QUICK_WERK_OF_HIM_STARTING_EVENT);
+ instance->DoStartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_MAKE_QUICK_WERK_OF_HIM_STARTING_EVENT);
}
void UpdateAI(uint32 diff) OVERRIDE
diff --git a/src/server/scripts/Northrend/Naxxramas/boss_sapphiron.cpp b/src/server/scripts/Northrend/Naxxramas/boss_sapphiron.cpp
index 60620804db8..761529ab0f2 100644
--- a/src/server/scripts/Northrend/Naxxramas/boss_sapphiron.cpp
+++ b/src/server/scripts/Northrend/Naxxramas/boss_sapphiron.cpp
@@ -96,6 +96,8 @@ class boss_sapphiron : public CreatureScript
void InitializeAI() OVERRIDE
{
+ _canTheHundredClub = true;
+
float x, y, z;
me->GetPosition(x, y, z);
me->SummonGameObject(GO_BIRTH, x, y, z, 0, 0, 0, 0, 0, 0);
diff --git a/src/server/scripts/Northrend/Naxxramas/boss_thaddius.cpp b/src/server/scripts/Northrend/Naxxramas/boss_thaddius.cpp
index 3d121887471..1ef81faa57e 100644
--- a/src/server/scripts/Northrend/Naxxramas/boss_thaddius.cpp
+++ b/src/server/scripts/Northrend/Naxxramas/boss_thaddius.cpp
@@ -110,7 +110,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_thaddiusAI(creature);
+ return GetInstanceAI<boss_thaddiusAI>(creature);
}
struct boss_thaddiusAI : public BossAI
@@ -230,15 +230,13 @@ public:
{
if (!checkStalaggAlive)
{
- if (instance)
- if (Creature* pStalagg = me->GetCreature(*me, instance->GetData64(DATA_STALAGG)))
- pStalagg->Respawn();
+ if (Creature* pStalagg = me->GetCreature(*me, instance->GetData64(DATA_STALAGG)))
+ pStalagg->Respawn();
}
else
{
- if (instance)
- if (Creature* pFeugen = me->GetCreature(*me, instance->GetData64(DATA_FEUGEN)))
- pFeugen->Respawn();
+ if (Creature* pFeugen = me->GetCreature(*me, instance->GetData64(DATA_FEUGEN)))
+ pFeugen->Respawn();
}
}
}
@@ -285,7 +283,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_stalaggAI(creature);
+ return GetInstanceAI<npc_stalaggAI>(creature);
}
struct npc_stalaggAI : public ScriptedAI
@@ -302,10 +300,9 @@ public:
void Reset() OVERRIDE
{
- if (instance)
- if (Creature* pThaddius = me->GetCreature(*me, instance->GetData64(DATA_THADDIUS)))
- if (pThaddius->AI())
- pThaddius->AI()->DoAction(ACTION_STALAGG_RESET);
+ if (Creature* pThaddius = me->GetCreature(*me, instance->GetData64(DATA_THADDIUS)))
+ if (pThaddius->AI())
+ pThaddius->AI()->DoAction(ACTION_STALAGG_RESET);
powerSurgeTimer = urand(20000, 25000);
magneticPullTimer = 20000;
}
@@ -325,10 +322,9 @@ public:
void JustDied(Unit* /*killer*/) OVERRIDE
{
Talk(SAY_STAL_DEATH);
- if (instance)
- if (Creature* pThaddius = me->GetCreature(*me, instance->GetData64(DATA_THADDIUS)))
- if (pThaddius->AI())
- pThaddius->AI()->DoAction(ACTION_STALAGG_DIED);
+ if (Creature* pThaddius = me->GetCreature(*me, instance->GetData64(DATA_THADDIUS)))
+ if (pThaddius->AI())
+ pThaddius->AI()->DoAction(ACTION_STALAGG_DIED);
}
void UpdateAI(uint32 uiDiff) OVERRIDE
@@ -379,7 +375,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_feugenAI(creature);
+ return GetInstanceAI<npc_feugenAI>(creature);
}
struct npc_feugenAI : public ScriptedAI
@@ -395,10 +391,9 @@ public:
void Reset() OVERRIDE
{
- if (instance)
- if (Creature* pThaddius = me->GetCreature(*me, instance->GetData64(DATA_THADDIUS)))
- if (pThaddius->AI())
- pThaddius->AI()->DoAction(ACTION_FEUGEN_RESET);
+ if (Creature* pThaddius = me->GetCreature(*me, instance->GetData64(DATA_THADDIUS)))
+ if (pThaddius->AI())
+ pThaddius->AI()->DoAction(ACTION_FEUGEN_RESET);
staticFieldTimer = 5000;
}
@@ -417,10 +412,9 @@ public:
void JustDied(Unit* /*killer*/) OVERRIDE
{
Talk(SAY_FEUG_DEATH);
- if (instance)
- if (Creature* pThaddius = me->GetCreature(*me, instance->GetData64(DATA_THADDIUS)))
- if (pThaddius->AI())
- pThaddius->AI()->DoAction(ACTION_FEUGEN_DIED);
+ if (Creature* pThaddius = me->GetCreature(*me, instance->GetData64(DATA_THADDIUS)))
+ if (pThaddius->AI())
+ pThaddius->AI()->DoAction(ACTION_FEUGEN_DIED);
}
void UpdateAI(uint32 uiDiff) OVERRIDE
diff --git a/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp b/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp
index c813577dd53..589b9a30d9b 100644
--- a/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp
+++ b/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp
@@ -106,8 +106,8 @@ enum Spells
SPELL_ARCANE_STORM_P_I = 61693,
SPELL_VORTEX_1 = 56237, // seems that frezze object animation
SPELL_VORTEX_2 = 55873, // visual effect
- SPELL_VORTEX_3 = 56105, // this spell must handle all the script - casted by the boss and to himself
- SPELL_VORTEX_6 = 73040, // teleport - (casted to all raid), caster vortex bunnies, targets players.
+ SPELL_VORTEX_3 = 56105, // this spell must handle all the script - cast by the boss and to himself
+ SPELL_VORTEX_6 = 73040, // teleport - (cast to all raid), caster vortex bunnies, targets players.
// Phase II
SPELL_TELEPORT_VISUAL_ONLY = 41232, // Light blue animation cast by arcane NPCs when spawned on Hover Disks
@@ -117,7 +117,7 @@ enum Spells
SPELL_SUMMON_ARCANE_BOMB = 56429,
SPELL_ARCANE_BOMB_TRIGGER = 56430,
SPELL_ARCANE_BOMB_KNOCKBACK_DAMAGE = 56431,
- SPELL_ARCANE_OVERLOAD_1 = 56432, // casted by npc Arcane Overload ID: 30282
+ SPELL_ARCANE_OVERLOAD_1 = 56432, // cast by npc Arcane Overload ID: 30282
// SPELL_ARCANE_OVERLOAD_2 = 56435, // Triggered by 56432 - resizing target
// SPELL_ARCANE_OVERLOAD_3 = 56438, // Triggered by 56432 - damage reduction
SPELL_SURGE_OF_POWER_P_II = 56505,
@@ -376,8 +376,7 @@ public:
SetPhase(PHASE_NOT_STARTED, true);
me->SetReactState(REACT_PASSIVE);
- if (instance)
- instance->DoStopTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_TIMED_START_EVENT);
+ instance->DoStopTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_TIMED_START_EVENT);
}
uint32 GetData(uint32 data) const OVERRIDE
@@ -568,27 +567,22 @@ public:
// We can't call full function here since it includes DoZoneInCombat(),
// if someone does it will be returned with a warning.
me->setActive(true);
- if (instance)
+ if (!instance->CheckRequiredBosses(DATA_MALYGOS_EVENT))
{
- if (!instance->CheckRequiredBosses(DATA_MALYGOS_EVENT))
- {
- EnterEvadeMode();
- return;
- }
-
- instance->SetBossState(DATA_MALYGOS_EVENT, IN_PROGRESS);
+ EnterEvadeMode();
+ return;
}
+ instance->SetBossState(DATA_MALYGOS_EVENT, IN_PROGRESS);
+
Talk(SAY_START_P_ONE);
DoCast(SPELL_BERSERK); // periodic aura, first tick in 10 minutes
- if (instance)
- instance->DoStartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_TIMED_START_EVENT);
+ instance->DoStartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_TIMED_START_EVENT);
}
void EnterEvadeMode() OVERRIDE
{
- if (instance)
- instance->SetBossState(DATA_MALYGOS_EVENT, FAIL);
+ instance->SetBossState(DATA_MALYGOS_EVENT, FAIL);
SendLightOverride(LIGHT_GET_DEFAULT_FOR_MAP, 1*IN_MILLISECONDS);
@@ -628,8 +622,7 @@ public:
summons.DespawnAll();
}
- if (instance)
- instance->SetBossState(DATA_MALYGOS_EVENT, NOT_STARTED);
+ instance->SetBossState(DATA_MALYGOS_EVENT, NOT_STARTED);
}
void KilledUnit(Unit* victim) OVERRIDE
@@ -1074,7 +1067,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_malygosAI(creature);
+ return GetInstanceAI<boss_malygosAI>(creature);
}
};
@@ -1127,7 +1120,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_portal_eoeAI(creature);
+ return GetInstanceAI<npc_portal_eoeAI>(creature);
}
};
@@ -1190,7 +1183,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_power_sparkAI(creature);
+ return GetInstanceAI<npc_power_sparkAI>(creature);
}
};
@@ -1292,7 +1285,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_melee_hover_diskAI(creature);
+ return GetInstanceAI<npc_melee_hover_diskAI>(creature);
}
};
@@ -1374,7 +1367,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_caster_hover_diskAI(creature);
+ return GetInstanceAI<npc_caster_hover_diskAI>(creature);
}
};
@@ -1450,7 +1443,7 @@ class npc_nexus_lord : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_nexus_lordAI(creature);
+ return GetInstanceAI<npc_nexus_lordAI>(creature);
}
};
@@ -1517,7 +1510,7 @@ class npc_scion_of_eternity : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_scion_of_eternityAI(creature);
+ return GetInstanceAI<npc_scion_of_eternityAI>(creature);
}
};
@@ -1575,7 +1568,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_arcane_overloadAI(creature);
+ return GetInstanceAI<npc_arcane_overloadAI>(creature);
}
};
@@ -1907,7 +1900,7 @@ class spell_malygos_vortex_visual : public SpellScriptLoader
if (InstanceScript* instance = caster->GetInstanceScript())
{
- // Teleport spell - I'm not sure but might be it must be casted by each vehicle when it's passenger leaves it.
+ // Teleport spell - I'm not sure but might be it must be cast by each vehicle when it's passenger leaves it.
if (Creature* trigger = caster->GetMap()->GetCreature(instance->GetData64(DATA_TRIGGER)))
trigger->CastSpell(targetPlayer, SPELL_VORTEX_6, true);
}
diff --git a/src/server/scripts/Northrend/Nexus/Nexus/boss_anomalus.cpp b/src/server/scripts/Northrend/Nexus/Nexus/boss_anomalus.cpp
index f05d065ab34..bffae212eec 100644
--- a/src/server/scripts/Northrend/Nexus/Nexus/boss_anomalus.cpp
+++ b/src/server/scripts/Northrend/Nexus/Nexus/boss_anomalus.cpp
@@ -95,24 +95,21 @@ class boss_anomalus : public CreatureScript
uiChaoticRiftGUID = 0;
chaosTheory = true;
- if (instance)
- instance->SetData(DATA_ANOMALUS_EVENT, NOT_STARTED);
+ instance->SetData(DATA_ANOMALUS_EVENT, NOT_STARTED);
}
void EnterCombat(Unit* /*who*/) OVERRIDE
{
Talk(SAY_AGGRO);
- if (instance)
- instance->SetData(DATA_ANOMALUS_EVENT, IN_PROGRESS);
+ instance->SetData(DATA_ANOMALUS_EVENT, IN_PROGRESS);
}
void JustDied(Unit* /*killer*/) OVERRIDE
{
Talk(SAY_DEATH);
- if (instance)
- instance->SetData(DATA_ANOMALUS_EVENT, DONE);
+ instance->SetData(DATA_ANOMALUS_EVENT, DONE);
}
uint32 GetData(uint32 type) const OVERRIDE
@@ -187,7 +184,7 @@ class boss_anomalus : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_anomalusAI(creature);
+ return GetInstanceAI<boss_anomalusAI>(creature);
}
};
@@ -255,7 +252,7 @@ class npc_chaotic_rift : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_chaotic_riftAI(creature);
+ return GetInstanceAI<npc_chaotic_riftAI>(creature);
}
};
diff --git a/src/server/scripts/Northrend/Nexus/Nexus/boss_keristrasza.cpp b/src/server/scripts/Northrend/Nexus/Nexus/boss_keristrasza.cpp
index 455653a136e..b0d2334790b 100644
--- a/src/server/scripts/Northrend/Nexus/Nexus/boss_keristrasza.cpp
+++ b/src/server/scripts/Northrend/Nexus/Nexus/boss_keristrasza.cpp
@@ -61,7 +61,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_keristraszaAI(creature);
+ return GetInstanceAI<boss_keristraszaAI>(creature);
}
struct boss_keristraszaAI : public ScriptedAI
@@ -95,8 +95,7 @@ public:
RemovePrison(CheckContainmentSpheres());
- if (instance)
- instance->SetData(DATA_KERISTRASZA_EVENT, NOT_STARTED);
+ instance->SetData(DATA_KERISTRASZA_EVENT, NOT_STARTED);
}
void EnterCombat(Unit* /*who*/) OVERRIDE
@@ -104,28 +103,24 @@ public:
Talk(SAY_AGGRO);
DoCastAOE(SPELL_INTENSE_COLD);
- if (instance)
- instance->SetData(DATA_KERISTRASZA_EVENT, IN_PROGRESS);
+ instance->SetData(DATA_KERISTRASZA_EVENT, IN_PROGRESS);
}
void JustDied(Unit* /*killer*/) OVERRIDE
{
Talk(SAY_DEATH);
- if (instance)
- instance->SetData(DATA_KERISTRASZA_EVENT, DONE);
+ instance->SetData(DATA_KERISTRASZA_EVENT, DONE);
}
- void KilledUnit(Unit* /*victim*/) OVERRIDE
+ void KilledUnit(Unit* who) OVERRIDE
{
- Talk(SAY_SLAY);
+ if (who->GetTypeId() == TYPEID_PLAYER)
+ Talk(SAY_SLAY);
}
bool CheckContainmentSpheres(bool remove_prison = false)
{
- if (!instance)
- return false;
-
auiContainmentSphereGUIDs[0] = instance->GetData64(ANOMALUS_CONTAINMET_SPHERE);
auiContainmentSphereGUIDs[1] = instance->GetData64(ORMOROKS_CONTAINMET_SPHERE);
auiContainmentSphereGUIDs[2] = instance->GetData64(TELESTRAS_CONTAINMET_SPHERE);
diff --git a/src/server/scripts/Northrend/Nexus/Nexus/boss_magus_telestra.cpp b/src/server/scripts/Northrend/Nexus/Nexus/boss_magus_telestra.cpp
index 8a01c40186e..e528b9e1634 100644
--- a/src/server/scripts/Northrend/Nexus/Nexus/boss_magus_telestra.cpp
+++ b/src/server/scripts/Northrend/Nexus/Nexus/boss_magus_telestra.cpp
@@ -65,7 +65,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_magus_telestraAI(creature);
+ return GetInstanceAI<boss_magus_telestraAI>(creature);
}
struct boss_magus_telestraAI : public ScriptedAI
@@ -118,29 +118,27 @@ public:
me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
me->SetVisible(true);
- if (instance)
- instance->SetData(DATA_MAGUS_TELESTRA_EVENT, NOT_STARTED);
+ instance->SetData(DATA_MAGUS_TELESTRA_EVENT, NOT_STARTED);
}
void EnterCombat(Unit* /*who*/) OVERRIDE
{
Talk(SAY_AGGRO);
- if (instance)
- instance->SetData(DATA_MAGUS_TELESTRA_EVENT, IN_PROGRESS);
+ instance->SetData(DATA_MAGUS_TELESTRA_EVENT, IN_PROGRESS);
}
void JustDied(Unit* /*killer*/) OVERRIDE
{
Talk(SAY_DEATH);
- if (instance)
- instance->SetData(DATA_MAGUS_TELESTRA_EVENT, DONE);
+ instance->SetData(DATA_MAGUS_TELESTRA_EVENT, DONE);
}
- void KilledUnit(Unit* /*victim*/) OVERRIDE
+ void KilledUnit(Unit* who) OVERRIDE
{
- Talk(SAY_KILL);
+ if (who->GetTypeId() == TYPEID_PLAYER)
+ Talk(SAY_KILL);
}
void DoAction(int32 action) OVERRIDE
diff --git a/src/server/scripts/Northrend/Nexus/Nexus/boss_ormorok.cpp b/src/server/scripts/Northrend/Nexus/Nexus/boss_ormorok.cpp
index e2789995ec7..ddaf9f7e94b 100644
--- a/src/server/scripts/Northrend/Nexus/Nexus/boss_ormorok.cpp
+++ b/src/server/scripts/Northrend/Nexus/Nexus/boss_ormorok.cpp
@@ -70,6 +70,12 @@ public:
{
boss_ormorokAI(Creature* creature) : BossAI(creature, DATA_ORMOROK_EVENT) { }
+ void Reset()
+ {
+ BossAI::Reset();
+ frenzy = false;
+ }
+
void EnterCombat(Unit* /*who*/) OVERRIDE
{
_EnterCombat();
@@ -82,8 +88,7 @@ public:
Talk(SAY_AGGRO);
- if (instance)
- instance->SetData(DATA_ORMOROK_EVENT, IN_PROGRESS);
+ instance->SetData(DATA_ORMOROK_EVENT, IN_PROGRESS);
}
void DamageTaken(Unit* /*attacker*/, uint32& /*damage*/) OVERRIDE
@@ -102,13 +107,13 @@ public:
Talk(SAY_DEATH);
- if (instance)
- instance->SetData(DATA_ORMOROK_EVENT, DONE);
+ instance->SetData(DATA_ORMOROK_EVENT, DONE);
}
- void KilledUnit(Unit* /*victim*/) OVERRIDE
+ void KilledUnit(Unit* who) OVERRIDE
{
- Talk(SAY_KILL);
+ if (who->GetTypeId() == TYPEID_PLAYER)
+ Talk(SAY_KILL);
}
void UpdateAI(uint32 diff) OVERRIDE
@@ -159,7 +164,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_ormorokAI(creature);
+ return GetInstanceAI<boss_ormorokAI>(creature);
}
};
@@ -190,7 +195,11 @@ public:
struct npc_crystal_spike_triggerAI : public ScriptedAI
{
- npc_crystal_spike_triggerAI(Creature* creature) : ScriptedAI(creature) { }
+ npc_crystal_spike_triggerAI(Creature* creature) : ScriptedAI(creature)
+ {
+ _count = 0;
+ _despawntimer = 0;
+ }
void IsSummonedBy(Unit* owner) OVERRIDE
{
diff --git a/src/server/scripts/Northrend/Nexus/Oculus/boss_eregos.cpp b/src/server/scripts/Northrend/Nexus/Oculus/boss_eregos.cpp
index ca6f580633c..1f7d47ccc31 100644
--- a/src/server/scripts/Northrend/Nexus/Oculus/boss_eregos.cpp
+++ b/src/server/scripts/Northrend/Nexus/Oculus/boss_eregos.cpp
@@ -99,9 +99,10 @@ class boss_eregos : public CreatureScript
DoAction(ACTION_SET_NORMAL_EVENTS);
}
- void KilledUnit(Unit* /*victim*/) OVERRIDE
+ void KilledUnit(Unit* who) OVERRIDE
{
- Talk(SAY_KILL);
+ if (who->GetTypeId() == TYPEID_PLAYER)
+ Talk(SAY_KILL);
}
void EnterCombat(Unit* /*who*/) OVERRIDE
@@ -165,7 +166,7 @@ class boss_eregos : public CreatureScript
if (summon->GetEntry() != NPC_PLANAR_ANOMALY)
return;
- /// @todo: See why the spell is not casted
+ /// @todo: See why the spell is not cast
summon->CastSpell(summon, SPELL_PLANAR_BLAST, true);
}
diff --git a/src/server/scripts/Northrend/Nexus/Oculus/boss_urom.cpp b/src/server/scripts/Northrend/Nexus/Oculus/boss_urom.cpp
index f7c558879d1..db1bb342286 100644
--- a/src/server/scripts/Northrend/Nexus/Oculus/boss_urom.cpp
+++ b/src/server/scripts/Northrend/Nexus/Oculus/boss_urom.cpp
@@ -248,7 +248,7 @@ class boss_urom : public CreatureScript
arcaneExplosionTimer -= diff;
}
- if (!me->IsNonMeleeSpellCasted(false, true, true))
+ if (!me->IsNonMeleeSpellCast(false, true, true))
{
if (frostBombTimer <= diff)
{
diff --git a/src/server/scripts/Northrend/Nexus/Oculus/boss_varos.cpp b/src/server/scripts/Northrend/Nexus/Oculus/boss_varos.cpp
index 385f80ae37d..074f3b9a135 100644
--- a/src/server/scripts/Northrend/Nexus/Oculus/boss_varos.cpp
+++ b/src/server/scripts/Northrend/Nexus/Oculus/boss_varos.cpp
@@ -217,17 +217,14 @@ class npc_azure_ring_captain : public CreatureScript
switch (action)
{
case ACTION_CALL_DRAGON_EVENT:
- if (instance)
+ if (Creature* varos = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_VAROS)))
{
- if (Creature* varos = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_VAROS)))
+ if (Unit* victim = varos->AI()->SelectTarget(SELECT_TARGET_RANDOM, 0))
{
- if (Unit* victim = varos->AI()->SelectTarget(SELECT_TARGET_RANDOM, 0))
- {
- me->SetReactState(REACT_PASSIVE);
- me->SetWalk(false);
- me->GetMotionMaster()->MovePoint(ACTION_CALL_DRAGON_EVENT, victim->GetPositionX(), victim->GetPositionY(), victim->GetPositionZ() + 20.0f);
- targetGUID = victim->GetGUID();
- }
+ me->SetReactState(REACT_PASSIVE);
+ me->SetWalk(false);
+ me->GetMotionMaster()->MovePoint(ACTION_CALL_DRAGON_EVENT, victim->GetPositionX(), victim->GetPositionY(), victim->GetPositionZ() + 20.0f);
+ targetGUID = victim->GetGUID();
}
}
break;
@@ -241,7 +238,7 @@ class npc_azure_ring_captain : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_azure_ring_captainAI(creature);
+ return GetInstanceAI<npc_azure_ring_captainAI>(creature);
}
};
diff --git a/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_bjarngrim.cpp b/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_bjarngrim.cpp
index 944eacda34e..b61d12df484 100644
--- a/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_bjarngrim.cpp
+++ b/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_bjarngrim.cpp
@@ -99,7 +99,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_bjarngrimAI(creature);
+ return GetInstanceAI<boss_bjarngrimAI>(creature);
}
struct boss_bjarngrimAI : public ScriptedAI
@@ -180,8 +180,7 @@ public:
SetEquipmentSlots(false, EQUIP_SWORD, EQUIP_SHIELD, EQUIP_NO_CHANGE);
- if (instance)
- instance->SetBossState(DATA_BJARNGRIM, NOT_STARTED);
+ instance->SetBossState(DATA_BJARNGRIM, NOT_STARTED);
}
void EnterEvadeMode() OVERRIDE
@@ -201,8 +200,7 @@ public:
//must get both lieutenants here and make sure they are with him
me->CallForHelp(30.0f);
- if (instance)
- instance->SetBossState(DATA_BJARNGRIM, IN_PROGRESS);
+ instance->SetBossState(DATA_BJARNGRIM, IN_PROGRESS);
}
void KilledUnit(Unit* /*victim*/) OVERRIDE
@@ -214,8 +212,7 @@ public:
{
Talk(SAY_DEATH);
- if (instance)
- instance->SetBossState(DATA_BJARNGRIM, DONE);
+ instance->SetBossState(DATA_BJARNGRIM, DONE);
}
/// @todo remove when removal is done by the core
@@ -245,7 +242,7 @@ public:
if (m_uiChangeStance_Timer <= uiDiff)
{
//wait for current spell to finish before change stance
- if (me->IsNonMeleeSpellCasted(false))
+ if (me->IsNonMeleeSpellCast(false))
return;
DoRemoveStanceAura(m_uiStance);
@@ -391,7 +388,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_stormforged_lieutenantAI(creature);
+ return GetInstanceAI<npc_stormforged_lieutenantAI>(creature);
}
struct npc_stormforged_lieutenantAI : public ScriptedAI
@@ -414,13 +411,10 @@ public:
void EnterCombat(Unit* who) OVERRIDE
{
- if (instance)
+ if (Creature* pBjarngrim = instance->instance->GetCreature(instance->GetData64(DATA_BJARNGRIM)))
{
- if (Creature* pBjarngrim = instance->instance->GetCreature(instance->GetData64(DATA_BJARNGRIM)))
- {
- if (pBjarngrim->IsAlive() && !pBjarngrim->GetVictim())
- pBjarngrim->AI()->AttackStart(who);
- }
+ if (pBjarngrim->IsAlive() && !pBjarngrim->GetVictim())
+ pBjarngrim->AI()->AttackStart(who);
}
}
@@ -440,13 +434,10 @@ public:
if (m_uiRenewSteel_Timer <= uiDiff)
{
- if (instance)
+ if (Creature* pBjarngrim = instance->instance->GetCreature(instance->GetData64(DATA_BJARNGRIM)))
{
- if (Creature* pBjarngrim = instance->instance->GetCreature(instance->GetData64(DATA_BJARNGRIM)))
- {
- if (pBjarngrim->IsAlive())
- DoCast(pBjarngrim, SPELL_RENEW_STEEL_N);
- }
+ if (pBjarngrim->IsAlive())
+ DoCast(pBjarngrim, SPELL_RENEW_STEEL_N);
}
m_uiRenewSteel_Timer = urand(10000, 14000);
}
diff --git a/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_ionar.cpp b/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_ionar.cpp
index af6beca608d..3e35ae3fae7 100644
--- a/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_ionar.cpp
+++ b/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_ionar.cpp
@@ -72,7 +72,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_ionarAI(creature);
+ return GetInstanceAI<boss_ionarAI>(creature);
}
struct boss_ionarAI : public ScriptedAI
@@ -115,16 +115,14 @@ public:
if (!me->IsVisible())
me->SetVisible(true);
- if (instance)
- instance->SetBossState(DATA_IONAR, NOT_STARTED);
+ instance->SetBossState(DATA_IONAR, NOT_STARTED);
}
void EnterCombat(Unit* /*who*/) OVERRIDE
{
Talk(SAY_AGGRO);
- if (instance)
- instance->SetBossState(DATA_IONAR, IN_PROGRESS);
+ instance->SetBossState(DATA_IONAR, IN_PROGRESS);
}
void JustDied(Unit* /*killer*/) OVERRIDE
@@ -133,13 +131,13 @@ public:
lSparkList.DespawnAll();
- if (instance)
- instance->SetBossState(DATA_IONAR, DONE);
+ instance->SetBossState(DATA_IONAR, DONE);
}
- void KilledUnit(Unit* /*victim*/) OVERRIDE
+ void KilledUnit(Unit* who) OVERRIDE
{
- Talk(SAY_SLAY);
+ if (who->GetTypeId() == TYPEID_PLAYER)
+ Talk(SAY_SLAY);
}
void SpellHit(Unit* /*caster*/, const SpellInfo* spell) OVERRIDE
@@ -278,7 +276,7 @@ public:
Talk(SAY_SPLIT);
- if (me->IsNonMeleeSpellCasted(false))
+ if (me->IsNonMeleeSpellCast(false))
me->InterruptNonMeleeSpells(false);
DoCast(me, SPELL_DISPERSE, false);
@@ -301,7 +299,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_spark_of_ionarAI(creature);
+ return GetInstanceAI<npc_spark_of_ionarAI>(creature);
}
struct npc_spark_of_ionarAI : public ScriptedAI
@@ -347,24 +345,21 @@ public:
// Prevent them to follow players through the whole instance
if (uiCheckTimer <= uiDiff)
{
- if (instance)
+ Creature* pIonar = instance->instance->GetCreature(instance->GetData64(DATA_IONAR));
+ if (pIonar && pIonar->IsAlive())
{
- Creature* pIonar = instance->instance->GetCreature(instance->GetData64(DATA_IONAR));
- if (pIonar && pIonar->IsAlive())
+ if (me->GetDistance(pIonar) > DATA_MAX_SPARK_DISTANCE)
{
- if (me->GetDistance(pIonar) > DATA_MAX_SPARK_DISTANCE)
- {
- Position pos;
- pIonar->GetPosition(&pos);
-
- me->SetSpeed(MOVE_RUN, 2.0f);
- me->GetMotionMaster()->Clear();
- me->GetMotionMaster()->MovePoint(DATA_POINT_CALLBACK, pos);
- }
+ Position pos;
+ pIonar->GetPosition(&pos);
+
+ me->SetSpeed(MOVE_RUN, 2.0f);
+ me->GetMotionMaster()->Clear();
+ me->GetMotionMaster()->MovePoint(DATA_POINT_CALLBACK, pos);
}
- else
- me->DespawnOrUnsummon();
}
+ else
+ me->DespawnOrUnsummon();
uiCheckTimer = 2*IN_MILLISECONDS;
}
else
diff --git a/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_loken.cpp b/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_loken.cpp
index 61687de1b58..cb997ebe0ec 100644
--- a/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_loken.cpp
+++ b/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_loken.cpp
@@ -69,7 +69,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_lokenAI(creature);
+ return GetInstanceAI<boss_lokenAI>(creature);
}
struct boss_lokenAI : public ScriptedAI
@@ -95,38 +95,30 @@ public:
m_uiHealthAmountModifier = 1;
- if (instance)
- {
- instance->SetBossState(DATA_LOKEN, NOT_STARTED);
- instance->DoStopTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_TIMELY_DEATH_START_EVENT);
- }
+ instance->SetBossState(DATA_LOKEN, NOT_STARTED);
+ instance->DoStopTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_TIMELY_DEATH_START_EVENT);
}
void EnterCombat(Unit* /*who*/) OVERRIDE
{
Talk(SAY_AGGRO);
- if (instance)
- {
- instance->SetBossState(DATA_LOKEN, IN_PROGRESS);
- instance->DoStartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_TIMELY_DEATH_START_EVENT);
- }
+ instance->SetBossState(DATA_LOKEN, IN_PROGRESS);
+ instance->DoStartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_TIMELY_DEATH_START_EVENT);
}
void JustDied(Unit* /*killer*/) OVERRIDE
{
Talk(SAY_DEATH);
- if (instance)
- {
- instance->SetBossState(DATA_LOKEN, DONE);
- instance->DoRemoveAurasDueToSpellOnPlayers(SPELL_PULSING_SHOCKWAVE_AURA);
- }
+ instance->SetBossState(DATA_LOKEN, DONE);
+ instance->DoRemoveAurasDueToSpellOnPlayers(SPELL_PULSING_SHOCKWAVE_AURA);
}
- void KilledUnit(Unit* /*victim*/) OVERRIDE
+ void KilledUnit(Unit* who) OVERRIDE
{
- Talk(SAY_SLAY);
+ if (who->GetTypeId() == TYPEID_PLAYER)
+ Talk(SAY_SLAY);
}
void UpdateAI(uint32 uiDiff) OVERRIDE
diff --git a/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_volkhan.cpp b/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_volkhan.cpp
index b6790a088ad..b756a9a3dc6 100644
--- a/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_volkhan.cpp
+++ b/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_volkhan.cpp
@@ -75,7 +75,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_volkhanAI(creature);
+ return GetInstanceAI<boss_volkhanAI>(creature);
}
struct boss_volkhanAI : public ScriptedAI
@@ -120,16 +120,14 @@ public:
DespawnGolem();
m_lGolemGUIDList.clear();
- if (instance)
- instance->SetBossState(DATA_VOLKHAN, NOT_STARTED);
+ instance->SetBossState(DATA_VOLKHAN, NOT_STARTED);
}
void EnterCombat(Unit* /*who*/) OVERRIDE
{
Talk(SAY_AGGRO);
- if (instance)
- instance->SetBossState(DATA_VOLKHAN, IN_PROGRESS);
+ instance->SetBossState(DATA_VOLKHAN, IN_PROGRESS);
}
void AttackStart(Unit* who) OVERRIDE
@@ -150,13 +148,13 @@ public:
Talk(SAY_DEATH);
DespawnGolem();
- if (instance)
- instance->SetBossState(DATA_VOLKHAN, DONE);
+ instance->SetBossState(DATA_VOLKHAN, DONE);
}
- void KilledUnit(Unit* /*victim*/) OVERRIDE
+ void KilledUnit(Unit* who) OVERRIDE
{
- Talk(SAY_SLAY);
+ if (who->GetTypeId() == TYPEID_PLAYER)
+ Talk(SAY_SLAY);
}
void DespawnGolem()
@@ -286,7 +284,7 @@ public:
{
++m_uiHealthAmountModifier;
- if (me->IsNonMeleeSpellCasted(false))
+ if (me->IsNonMeleeSpellCast(false))
me->InterruptNonMeleeSpells(false);
Talk(SAY_FORGE);
@@ -411,7 +409,7 @@ public:
me->AttackStop();
// me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED); //Set in DB
// me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); //Set in DB
- if (me->IsNonMeleeSpellCasted(false))
+ if (me->IsNonMeleeSpellCast(false))
me->InterruptNonMeleeSpells(false);
if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == CHASE_MOTION_TYPE)
me->GetMotionMaster()->MovementExpired();
diff --git a/src/server/scripts/Northrend/Ulduar/HallsOfStone/boss_krystallus.cpp b/src/server/scripts/Northrend/Ulduar/HallsOfStone/boss_krystallus.cpp
index b6a4375d0eb..d445dc08ce1 100644
--- a/src/server/scripts/Northrend/Ulduar/HallsOfStone/boss_krystallus.cpp
+++ b/src/server/scripts/Northrend/Ulduar/HallsOfStone/boss_krystallus.cpp
@@ -83,15 +83,13 @@ public:
uiStompTimer = urand(20000, 29000);
uiShatterTimer = 0;
- if (instance)
- instance->SetBossState(DATA_KRYSTALLUS, NOT_STARTED);
+ instance->SetBossState(DATA_KRYSTALLUS, NOT_STARTED);
}
void EnterCombat(Unit* /*who*/) OVERRIDE
{
Talk(SAY_AGGRO);
- if (instance)
- instance->SetBossState(DATA_KRYSTALLUS, IN_PROGRESS);
+ instance->SetBossState(DATA_KRYSTALLUS, IN_PROGRESS);
}
void UpdateAI(uint32 diff) OVERRIDE
@@ -143,8 +141,7 @@ public:
{
Talk(SAY_DEATH);
- if (instance)
- instance->SetBossState(DATA_KRYSTALLUS, DONE);
+ instance->SetBossState(DATA_KRYSTALLUS, DONE);
}
void KilledUnit(Unit* victim) OVERRIDE
diff --git a/src/server/scripts/Northrend/Ulduar/HallsOfStone/boss_maiden_of_grief.cpp b/src/server/scripts/Northrend/Ulduar/HallsOfStone/boss_maiden_of_grief.cpp
index f4ea3ff556c..d2e85438bc1 100644
--- a/src/server/scripts/Northrend/Ulduar/HallsOfStone/boss_maiden_of_grief.cpp
+++ b/src/server/scripts/Northrend/Ulduar/HallsOfStone/boss_maiden_of_grief.cpp
@@ -77,22 +77,16 @@ public:
ShockOfSorrowTimer = 20000+rand()%5000;
PillarOfWoeTimer = urand(5000, 15000);
- if (instance)
- {
- instance->SetBossState(DATA_MAIDEN_OF_GRIEF, NOT_STARTED);
- instance->DoStopTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_GOOD_GRIEF_START_EVENT);
- }
+ instance->SetBossState(DATA_MAIDEN_OF_GRIEF, NOT_STARTED);
+ instance->DoStopTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_GOOD_GRIEF_START_EVENT);
}
void EnterCombat(Unit* /*who*/) OVERRIDE
{
Talk(SAY_AGGRO);
- if (instance)
- {
- instance->SetBossState(DATA_MAIDEN_OF_GRIEF, IN_PROGRESS);
- instance->DoStartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_GOOD_GRIEF_START_EVENT);
- }
+ instance->SetBossState(DATA_MAIDEN_OF_GRIEF, IN_PROGRESS);
+ instance->DoStartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_GOOD_GRIEF_START_EVENT);
}
void UpdateAI(uint32 diff) OVERRIDE
@@ -145,8 +139,7 @@ public:
{
Talk(SAY_DEATH);
- if (instance)
- instance->SetBossState(DATA_MAIDEN_OF_GRIEF, DONE);
+ instance->SetBossState(DATA_MAIDEN_OF_GRIEF, DONE);
}
void KilledUnit(Unit* victim) OVERRIDE
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 ff4a5d1b43a..5fff9889fac 100644
--- a/src/server/scripts/Northrend/Ulduar/HallsOfStone/halls_of_stone.cpp
+++ b/src/server/scripts/Northrend/Ulduar/HallsOfStone/halls_of_stone.cpp
@@ -167,13 +167,10 @@ public:
bMarnakActivated = false;
bAbedneumActivated = false;
- if (instance)
- {
- instance->HandleGameObject(instance->GetData64(DATA_GO_KADDRAK), false);
- instance->HandleGameObject(instance->GetData64(DATA_GO_MARNAK), false);
- instance->HandleGameObject(instance->GetData64(DATA_GO_ABEDNEUM), false);
- instance->HandleGameObject(instance->GetData64(DATA_GO_SKY_FLOOR), false);
- }
+ instance->HandleGameObject(instance->GetData64(DATA_GO_KADDRAK), false);
+ instance->HandleGameObject(instance->GetData64(DATA_GO_MARNAK), false);
+ instance->HandleGameObject(instance->GetData64(DATA_GO_ABEDNEUM), false);
+ instance->HandleGameObject(instance->GetData64(DATA_GO_SKY_FLOOR), false);
KaddrakGUIDList.clear();
}
@@ -324,8 +321,7 @@ public:
DespawnDwarf();
- if (instance)
- instance->SetBossState(DATA_BRANN_EVENT, NOT_STARTED);
+ instance->SetBossState(DATA_BRANN_EVENT, NOT_STARTED);
}
}
@@ -362,8 +358,7 @@ public:
break;
case 17:
Talk(SAY_EVENT_INTRO_2);
- if (instance)
- instance->HandleGameObject(instance->GetData64(DATA_GO_TRIBUNAL_CONSOLE), true);
+ instance->HandleGameObject(instance->GetData64(DATA_GO_TRIBUNAL_CONSOLE), true);
me->SetStandState(UNIT_STAND_STATE_KNEEL);
SetEscortPaused(true);
JumpToNextStep(8500);
@@ -438,12 +433,9 @@ public:
switch (uiStep)
{
case 1:
- if (instance)
- {
- if (instance->GetBossState(DATA_BRANN_EVENT) != NOT_STARTED)
- return;
- instance->SetBossState(DATA_BRANN_EVENT, IN_PROGRESS);
- }
+ if (instance->GetBossState(DATA_BRANN_EVENT) != NOT_STARTED)
+ return;
+ instance->SetBossState(DATA_BRANN_EVENT, IN_PROGRESS);
bIsBattle = false;
Talk(SAY_ESCORT_START);
SetRun(true);
@@ -454,25 +446,22 @@ public:
JumpToNextStep(0);
break;
case 5:
- if (instance)
- if (Creature* temp = (Unit::GetCreature(*me, instance->GetData64(DATA_ABEDNEUM))))
- temp->AI()->Talk(SAY_EVENT_INTRO_3_ABED);
- JumpToNextStep(8500);
+ if (Creature* temp = (Unit::GetCreature(*me, instance->GetData64(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 (instance)
- if (Creature* temp = Unit::GetCreature(*me, instance->GetData64(DATA_KADDRAK)))
- temp->AI()->Talk(SAY_EVENT_A_2_KADD);
- JumpToNextStep(12500);
+ if (Creature* temp = Unit::GetCreature(*me, instance->GetData64(DATA_KADDRAK)))
+ temp->AI()->Talk(SAY_EVENT_A_2_KADD);
+ JumpToNextStep(12500);
break;
case 8:
Talk(SAY_EVENT_A_3);
- if (instance)
- instance->HandleGameObject(instance->GetData64(DATA_GO_KADDRAK), true);
+ instance->HandleGameObject(instance->GetData64(DATA_GO_KADDRAK), true);
if (Creature* temp = Unit::GetCreature(*me, uiControllerGUID))
CAST_AI(npc_tribuna_controller::npc_tribuna_controllerAI, temp->AI())->bKaddrakActivated = true;
JumpToNextStep(5000);
@@ -487,16 +476,14 @@ public:
JumpToNextStep(6000);
break;
case 11:
- if (instance)
- if (Creature* temp = Unit::GetCreature(*me, instance->GetData64(DATA_MARNAK)))
- temp->AI()->Talk(SAY_EVENT_B_2_MARN);
+ if (Creature* temp = Unit::GetCreature(*me, instance->GetData64(DATA_MARNAK)))
+ temp->AI()->Talk(SAY_EVENT_B_2_MARN);
SpawnDwarf(1);
JumpToNextStep(20000);
break;
case 12:
Talk(SAY_EVENT_B_3);
- if (instance)
- instance->HandleGameObject(instance->GetData64(DATA_GO_MARNAK), true);
+ instance->HandleGameObject(instance->GetData64(DATA_GO_MARNAK), true);
if (Creature* temp = Unit::GetCreature(*me, uiControllerGUID))
CAST_AI(npc_tribuna_controller::npc_tribuna_controllerAI, temp->AI())->bMarnakActivated = true;
JumpToNextStep(10000);
@@ -519,16 +506,14 @@ public:
JumpToNextStep(20000);
break;
case 17:
- if (instance)
- if (Creature* temp = Unit::GetCreature(*me, instance->GetData64(DATA_ABEDNEUM)))
- temp->AI()->Talk(SAY_EVENT_C_2_ABED);
- SpawnDwarf(1);
+ if (Creature* temp = Unit::GetCreature(*me, instance->GetData64(DATA_ABEDNEUM)))
+ temp->AI()->Talk(SAY_EVENT_C_2_ABED);
+ SpawnDwarf(1);
JumpToNextStep(20000);
break;
case 18:
Talk(SAY_EVENT_C_3);
- if (instance)
- instance->HandleGameObject(instance->GetData64(DATA_GO_ABEDNEUM), true);
+ instance->HandleGameObject(instance->GetData64(DATA_GO_ABEDNEUM), true);
if (Creature* temp = Unit::GetCreature(*me, uiControllerGUID))
CAST_AI(npc_tribuna_controller::npc_tribuna_controllerAI, temp->AI())->bAbedneumActivated = true;
JumpToNextStep(5000);
@@ -547,9 +532,8 @@ public:
JumpToNextStep(20000);
break;
case 22:
- if (instance)
- if (Creature* temp = Unit::GetCreature(*me, instance->GetData64(DATA_ABEDNEUM)))
- temp->AI()->Talk(SAY_EVENT_D_2_ABED);
+ if (Creature* temp = Unit::GetCreature(*me, instance->GetData64(DATA_ABEDNEUM)))
+ temp->AI()->Talk(SAY_EVENT_D_2_ABED);
SpawnDwarf(1);
JumpToNextStep(5000);
break;
@@ -571,9 +555,8 @@ public:
JumpToNextStep(10000);
break;
case 27:
- if (instance)
- if (Creature* temp = Unit::GetCreature(*me, instance->GetData64(DATA_ABEDNEUM)))
- temp->AI()->Talk(SAY_EVENT_D_4_ABED);
+ if (Creature* temp = Unit::GetCreature(*me, instance->GetData64(DATA_ABEDNEUM)))
+ temp->AI()->Talk(SAY_EVENT_D_4_ABED);
SpawnDwarf(1);
JumpToNextStep(10000);
break;
@@ -581,8 +564,7 @@ public:
me->SetReactState(REACT_DEFENSIVE);
Talk(SAY_EVENT_END_01);
me->SetStandState(UNIT_STAND_STATE_STAND);
- if (instance)
- instance->HandleGameObject(instance->GetData64(DATA_GO_SKY_FLOOR), true);
+ instance->HandleGameObject(instance->GetData64(DATA_GO_SKY_FLOOR), true);
if (Creature* temp = Unit::GetCreature(*me, uiControllerGUID))
temp->DealDamage(temp, temp->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
bIsBattle = true;
@@ -591,15 +573,13 @@ public:
break;
case 29:
Talk(SAY_EVENT_END_02);
- if (instance)
- instance->SetBossState(DATA_BRANN_EVENT, DONE);
+ instance->SetBossState(DATA_BRANN_EVENT, DONE);
me->CastSpell(me, SPELL_REWARD_ACHIEVEMENT, true);
JumpToNextStep(5500);
break;
case 30:
- if (instance)
- if (Creature* temp = Unit::GetCreature(*me, instance->GetData64(DATA_ABEDNEUM)))
- temp->AI()->Talk(SAY_EVENT_END_03_ABED);
+ if (Creature* temp = Unit::GetCreature(*me, instance->GetData64(DATA_ABEDNEUM)))
+ temp->AI()->Talk(SAY_EVENT_END_03_ABED);
JumpToNextStep(8500);
break;
case 31:
@@ -607,29 +587,26 @@ public:
JumpToNextStep(11500);
break;
case 32:
- if (instance)
- if (Creature* temp = Unit::GetCreature(*me, instance->GetData64(DATA_ABEDNEUM)))
- temp->AI()->Talk(SAY_EVENT_END_05_ABED);
- JumpToNextStep(11500);
+ if (Creature* temp = Unit::GetCreature(*me, instance->GetData64(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 (instance)
- if (Creature* temp = Unit::GetCreature(*me, instance->GetData64(DATA_ABEDNEUM)))
- temp->AI()->Talk(SAY_EVENT_END_07_ABED);
- JumpToNextStep(22500);
+ if (Creature* temp = Unit::GetCreature(*me, instance->GetData64(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 (instance)
- if (Creature* temp = Unit::GetCreature(*me, instance->GetData64(DATA_KADDRAK)))
- temp->AI()->Talk(SAY_EVENT_END_09_KADD);
+ if (Creature* temp = Unit::GetCreature(*me, instance->GetData64(DATA_KADDRAK)))
+ temp->AI()->Talk(SAY_EVENT_END_09_KADD);
JumpToNextStep(18500);
break;
case 37:
@@ -637,19 +614,17 @@ public:
JumpToNextStep(5500);
break;
case 38:
- if (instance)
- if (Creature* temp = Unit::GetCreature(*me, instance->GetData64(DATA_KADDRAK)))
- temp->AI()->Talk(SAY_EVENT_END_11_KADD);
- JumpToNextStep(20500);
+ if (Creature* temp = Unit::GetCreature(*me, instance->GetData64(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 (instance)
- if (Creature* temp = Unit::GetCreature(*me, instance->GetData64(DATA_KADDRAK)))
- temp->AI()->Talk(SAY_EVENT_END_13_KADD);
+ if (Creature* temp = Unit::GetCreature(*me, instance->GetData64(DATA_KADDRAK)))
+ temp->AI()->Talk(SAY_EVENT_END_13_KADD);
JumpToNextStep(19500);
break;
case 41:
@@ -657,50 +632,43 @@ public:
JumpToNextStep(10500);
break;
case 42:
- if (instance)
- if (Creature* temp = Unit::GetCreature(*me, instance->GetData64(DATA_MARNAK)))
- temp->AI()->Talk(SAY_EVENT_END_15_MARN);
- JumpToNextStep(6500);
+ if (Creature* temp = Unit::GetCreature(*me, instance->GetData64(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 (instance)
- if (Creature* temp = Unit::GetCreature(*me, instance->GetData64(DATA_MARNAK)))
- temp->AI()->Talk(SAY_EVENT_END_17_MARN);
- JumpToNextStep(25500);
+ if (Creature* temp = Unit::GetCreature(*me, instance->GetData64(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 (instance)
- if (Creature* temp = Unit::GetCreature(*me, instance->GetData64(DATA_MARNAK)))
- temp->AI()->Talk(SAY_EVENT_END_19_MARN);
- JumpToNextStep(3500);
+ if (Creature* temp = Unit::GetCreature(*me, instance->GetData64(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 (instance)
- if (Creature* temp = Unit::GetCreature(*me, instance->GetData64(DATA_ABEDNEUM)))
- temp->AI()->Talk(SAY_EVENT_END_21_ABED);
- JumpToNextStep(5500);
+ if (Creature* temp = Unit::GetCreature(*me, instance->GetData64(DATA_ABEDNEUM)))
+ temp->AI()->Talk(SAY_EVENT_END_21_ABED);
+ JumpToNextStep(5500);
break;
case 49:
{
- if (instance)
- {
- instance->HandleGameObject(instance->GetData64(DATA_GO_KADDRAK), false);
- instance->HandleGameObject(instance->GetData64(DATA_GO_MARNAK), false);
- instance->HandleGameObject(instance->GetData64(DATA_GO_ABEDNEUM), false);
- instance->HandleGameObject(instance->GetData64(DATA_GO_SKY_FLOOR), false);
- }
+ instance->HandleGameObject(instance->GetData64(DATA_GO_KADDRAK), false);
+ instance->HandleGameObject(instance->GetData64(DATA_GO_MARNAK), false);
+ instance->HandleGameObject(instance->GetData64(DATA_GO_ABEDNEUM), false);
+ instance->HandleGameObject(instance->GetData64(DATA_GO_SKY_FLOOR), false);
Player* player = GetPlayerForEscort();
if (player)
player->GroupEventHappens(QUEST_HALLS_OF_STONE, me);
diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_auriaya.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_auriaya.cpp
index 2905a714062..4e1f701a0be 100644
--- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_auriaya.cpp
+++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_auriaya.cpp
@@ -315,7 +315,7 @@ class npc_auriaya_seeping_trigger : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_auriaya_seeping_triggerAI(creature);
+ return GetInstanceAI<npc_auriaya_seeping_triggerAI>(creature);
}
};
@@ -390,7 +390,7 @@ class npc_sanctum_sentry : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_sanctum_sentryAI(creature);
+ return GetInstanceAI<npc_sanctum_sentryAI>(creature);
}
};
@@ -466,7 +466,7 @@ class npc_feral_defender : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_feral_defenderAI(creature);
+ return GetInstanceAI<npc_feral_defenderAI>(creature);
}
};
diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp
index 4bcbe855c2f..eed34f0229d 100644
--- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp
+++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp
@@ -619,7 +619,7 @@ class boss_flame_leviathan_seat : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_flame_leviathan_seatAI(creature);
+ return GetInstanceAI<boss_flame_leviathan_seatAI>(creature);
}
};
@@ -898,7 +898,7 @@ class npc_colossus : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_colossusAI(creature);
+ return GetInstanceAI<npc_colossusAI>(creature);
}
};
@@ -1179,7 +1179,7 @@ class npc_lorekeeper : public CreatureScript
if (Creature* Branz = creature->FindNearestCreature(NPC_BRANZ_BRONZBEARD, 1000, true))
{
Delorah->GetMotionMaster()->MovePoint(0, Branz->GetPositionX()-4, Branz->GetPositionY(), Branz->GetPositionZ());
- /// @todo Delorah->AI()->Talk(xxxx, Branz->GetGUID()); when reached at branz
+ /// @todo Delorah->AI()->Talk(xxxx, Branz); when reached at branz
}
}
}
diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_freya.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_freya.cpp
index 549d496f19d..19f22947b7c 100644
--- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_freya.cpp
+++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_freya.cpp
@@ -433,7 +433,7 @@ class boss_freya : public CreatureScript
case EVENT_STRENGTHENED_IRON_ROOTS:
Talk(EMOTE_IRON_ROOTS);
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100.0f, true, -SPELL_ROOTS_FREYA))
- target->CastSpell(target, SPELL_ROOTS_FREYA, true); // This must be casted by Target self
+ target->CastSpell(target, SPELL_ROOTS_FREYA, true); // This must be cast by Target self
events.ScheduleEvent(EVENT_STRENGTHENED_IRON_ROOTS, urand(12000, 20000));
break;
case EVENT_GROUND_TREMOR:
@@ -1146,7 +1146,7 @@ class npc_ancient_water_spirit : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_ancient_water_spiritAI(creature);
+ return GetInstanceAI<npc_ancient_water_spiritAI>(creature);
}
};
@@ -1213,7 +1213,7 @@ class npc_storm_lasher : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_storm_lasherAI(creature);
+ return GetInstanceAI<npc_storm_lasherAI>(creature);
}
};
@@ -1258,7 +1258,7 @@ class npc_snaplasher : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_snaplasherAI(creature);
+ return GetInstanceAI<npc_snaplasherAI>(creature);
}
};
@@ -1522,7 +1522,7 @@ class npc_unstable_sun_beam : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_unstable_sun_beamAI(creature);
+ return GetInstanceAI<npc_unstable_sun_beamAI>(creature);
}
};
diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_general_vezax.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_general_vezax.cpp
index 46776ae9b96..d4ef496dba0 100644
--- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_general_vezax.cpp
+++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_general_vezax.cpp
@@ -369,7 +369,7 @@ class boss_saronite_animus : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_saronite_animusAI(creature);
+ return GetInstanceAI<boss_saronite_animusAI>(creature);
}
};
@@ -439,7 +439,7 @@ class npc_saronite_vapors : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_saronite_vaporsAI(creature);
+ return GetInstanceAI<npc_saronite_vaporsAI>(creature);
}
};
diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_hodir.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_hodir.cpp
index 2fb165b935e..344fd7d3e85 100644
--- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_hodir.cpp
+++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_hodir.cpp
@@ -235,7 +235,7 @@ class npc_flash_freeze : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_flash_freezeAI(creature);
+ return GetInstanceAI<npc_flash_freezeAI>(creature);
}
};
@@ -296,7 +296,7 @@ class npc_ice_block : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_ice_blockAI(creature);
+ return GetInstanceAI<npc_ice_blockAI>(creature);
}
};
diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_razorscale.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_razorscale.cpp
index 31c635c7de5..30b0e41f52a 100644
--- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_razorscale.cpp
+++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_razorscale.cpp
@@ -300,7 +300,7 @@ class boss_razorscale_controller : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_razorscale_controllerAI(creature);
+ return GetInstanceAI<boss_razorscale_controllerAI>(creature);
}
};
@@ -735,7 +735,7 @@ class npc_expedition_commander : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_expedition_commanderAI(creature);
+ return GetInstanceAI<npc_expedition_commanderAI>(creature);
}
};
diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_xt002.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_xt002.cpp
index 12925f1c6e1..74fc83653d4 100644
--- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_xt002.cpp
+++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_xt002.cpp
@@ -218,9 +218,6 @@ class boss_xt002 : public CreatureScript
_phase = 1;
_heartExposed = 0;
- if (!instance)
- return;
-
instance->DoStopTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_MUST_DECONSTRUCT_FASTER);
}
@@ -232,12 +229,9 @@ class boss_xt002 : public CreatureScript
events.ScheduleEvent(EVENT_ENRAGE, TIMER_ENRAGE);
events.ScheduleEvent(EVENT_GRAVITY_BOMB, TIMER_GRAVITY_BOMB);
events.ScheduleEvent(EVENT_SEARING_LIGHT, TIMER_SEARING_LIGHT);
- //Tantrum is casted a bit slower the first time.
+ //Tantrum is cast a bit slower the first time.
events.ScheduleEvent(EVENT_TYMPANIC_TANTRUM, urand(TIMER_TYMPANIC_TANTRUM_MIN, TIMER_TYMPANIC_TANTRUM_MAX) * 2);
- if (!instance)
- return;
-
instance->DoStartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_MUST_DECONSTRUCT_FASTER);
}
@@ -477,7 +471,7 @@ class npc_xt002_heart : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_xt002_heartAI(creature);
+ return GetInstanceAI<npc_xt002_heartAI>(creature);
}
};
@@ -493,7 +487,7 @@ class npc_scrapbot : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_scrapbotAI(creature);
+ return GetInstanceAI<npc_scrapbotAI>(creature);
}
struct npc_scrapbotAI : public ScriptedAI
@@ -550,7 +544,7 @@ class npc_pummeller : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_pummellerAI(creature);
+ return GetInstanceAI<npc_pummellerAI>(creature);
}
struct npc_pummellerAI : public ScriptedAI
@@ -652,7 +646,7 @@ class npc_boombot : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_boombotAI(creature);
+ return GetInstanceAI<npc_boombotAI>(creature);
}
struct npc_boombotAI : public ScriptedAI
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 575ab574140..96a2a52714a 100644
--- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_yogg_saron.cpp
+++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_yogg_saron.cpp
@@ -108,7 +108,7 @@ enum Spells
SPELL_SANITY = 63050,
SPELL_INSANE_PERIODIC = 64554,
SPELL_INSANE = 63120,
- //SPELL_CLEAR_INSANE = 63122, // when it should be casted?
+ //SPELL_CLEAR_INSANE = 63122, // when should it be cast?
SPELL_CONSTRICTOR_TENTACLE = 64132,
SPELL_CRUSHER_TENTACLE_SUMMON = 64139,
SPELL_CORRUPTOR_TENTACLE_SUMMON = 64143,
@@ -799,7 +799,7 @@ class boss_sara : public CreatureScript
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 casted at scheduled time, why?
+ _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);
diff --git a/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_keleseth.cpp b/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_keleseth.cpp
index 126185215e9..d21b597eb2b 100644
--- a/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_keleseth.cpp
+++ b/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_keleseth.cpp
@@ -212,7 +212,7 @@ class boss_keleseth : public CreatureScript
void SummonSkeletons()
{
- // I could not found any spell casted for this
+ // I could not found any spell cast for this
for (uint8 i = 0; i < 4; ++i)
me->SummonCreature(NPC_SKELETON, SkeletonSpawnPoint[0][0], SkeletonSpawnPoint[0][1], SKELETONSPAWN_Z, 0);
}
diff --git a/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_skarvald_dalronn.cpp b/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_skarvald_dalronn.cpp
index 5247f9019da..42fa0242df2 100644
--- a/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_skarvald_dalronn.cpp
+++ b/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_skarvald_dalronn.cpp
@@ -358,7 +358,7 @@ class boss_dalronn_the_controller : public CreatureScript
if (ShadowBolt_Timer <= diff)
{
- if (!me->IsNonMeleeSpellCasted(false))
+ if (!me->IsNonMeleeSpellCast(false))
{
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 0.0f, true))
DoCast(target, SPELL_SHADOW_BOLT);
@@ -370,7 +370,7 @@ class boss_dalronn_the_controller : public CreatureScript
if (Debilitate_Timer <= diff)
{
- if (!me->IsNonMeleeSpellCasted(false))
+ if (!me->IsNonMeleeSpellCast(false))
{
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 0.0f, true))
DoCast(target, SPELL_DEBILITATE);
@@ -384,7 +384,7 @@ class boss_dalronn_the_controller : public CreatureScript
{
if (Summon_Timer <= diff)
{
- if (!me->IsNonMeleeSpellCasted(false))
+ if (!me->IsNonMeleeSpellCast(false))
{
DoCast(me, H_SPELL_SUMMON_SKELETONS);
Summon_Timer = (rand()%10000) + 20000;
diff --git a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_palehoof.cpp b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_palehoof.cpp
index 77c19422da0..e02ceb4866a 100644
--- a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_palehoof.cpp
+++ b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_palehoof.cpp
@@ -193,9 +193,10 @@ public:
//Talk(SAY_DEATH);
}
- void KilledUnit(Unit* /*victim*/) OVERRIDE
+ void KilledUnit(Unit* who) OVERRIDE
{
- Talk(SAY_SLAY);
+ if (who->GetTypeId() == TYPEID_PLAYER)
+ Talk(SAY_SLAY);
}
void DoAction(int32 actionId) OVERRIDE
@@ -255,7 +256,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_ravenous_furbolgAI(creature);
+ return GetInstanceAI<npc_ravenous_furbolgAI>(creature);
}
struct npc_ravenous_furbolgAI : public ScriptedAI
@@ -363,7 +364,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_frenzied_worgenAI(creature);
+ return GetInstanceAI<npc_frenzied_worgenAI>(creature);
}
struct npc_frenzied_worgenAI : public ScriptedAI
@@ -437,8 +438,7 @@ public:
who->SetInCombatWith(me);
DoStartMovement(who);
}
- if (instance)
- instance->SetBossState(DATA_GORTOK_PALEHOOF, IN_PROGRESS);
+ instance->SetBossState(DATA_GORTOK_PALEHOOF, IN_PROGRESS);
}
void JustDied(Unit* /*killer*/) OVERRIDE
@@ -474,7 +474,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_ferocious_rhinoAI(creature);
+ return GetInstanceAI<npc_ferocious_rhinoAI>(creature);
}
struct npc_ferocious_rhinoAI : public ScriptedAI
@@ -589,7 +589,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_massive_jormungarAI(creature);
+ return GetInstanceAI<npc_massive_jormungarAI>(creature);
}
struct npc_massive_jormungarAI : public ScriptedAI
@@ -690,7 +690,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_palehoof_orbAI(creature);
+ return GetInstanceAI<npc_palehoof_orbAI>(creature);
}
struct npc_palehoof_orbAI : public ScriptedAI
diff --git a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_skadi.cpp b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_skadi.cpp
index 01fcd9a665d..aa955f6957a 100644
--- a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_skadi.cpp
+++ b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_skadi.cpp
@@ -133,7 +133,7 @@ enum Spells
{
// Skadi Spells
SPELL_CRUSH = 50234,
- SPELL_POISONED_SPEAR = 50225, //isn't being casted =/
+ SPELL_POISONED_SPEAR = 50225, //isn't being cast
SPELL_WHIRLWIND = 50228, //random target, but not the tank approx. every 20s
SPELL_RAPID_FIRE = 56570,
SPELL_HARPOON_DAMAGE = 56578,
@@ -162,7 +162,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_skadiAI(creature);
+ return GetInstanceAI<boss_skadiAI>(creature);
}
struct boss_skadiAI : public ScriptedAI
@@ -208,11 +208,8 @@ public:
me->SetSpeed(MOVE_FLIGHT, 3.0f);
if ((Unit::GetCreature(*me, m_uiGraufGUID) == NULL) && !me->IsMounted())
me->SummonCreature(NPC_GRAUF, Location[0].GetPositionX(), Location[0].GetPositionY(), Location[0].GetPositionZ(), 3.0f);
- if (instance)
- {
- instance->SetBossState(DATA_SKADI_THE_RUTHLESS, NOT_STARTED);
- instance->DoStopTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_TIMED_START_EVENT);
- }
+ instance->SetBossState(DATA_SKADI_THE_RUTHLESS, NOT_STARTED);
+ instance->DoStopTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_TIMED_START_EVENT);
}
void JustReachedHome() OVERRIDE
@@ -235,15 +232,12 @@ public:
m_uiMovementTimer = 1000;
m_uiSummonTimer = 10000;
me->SetInCombatWithZone();
- if (instance)
- {
- instance->SetBossState(DATA_SKADI_THE_RUTHLESS, IN_PROGRESS);
- instance->DoStartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_TIMED_START_EVENT);
- me->GetMotionMaster()->MoveJump(Location[0].GetPositionX(), Location[0].GetPositionY(), Location[0].GetPositionZ(), 5.0f, 10.0f);
- me->SetWalk(false);
- m_uiMountTimer = 1000;
- Summons.DespawnEntry(NPC_GRAUF);
- }
+ instance->SetBossState(DATA_SKADI_THE_RUTHLESS, IN_PROGRESS);
+ instance->DoStartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_TIMED_START_EVENT);
+ me->GetMotionMaster()->MoveJump(Location[0].GetPositionX(), Location[0].GetPositionY(), Location[0].GetPositionZ(), 5.0f, 10.0f);
+ me->SetWalk(false);
+ m_uiMountTimer = 1000;
+ Summons.DespawnEntry(NPC_GRAUF);
}
void JustSummoned(Creature* summoned) OVERRIDE
@@ -411,13 +405,13 @@ public:
{
Talk(SAY_DEATH);
Summons.DespawnAll();
- if (instance)
- instance->SetBossState(DATA_SKADI_THE_RUTHLESS, DONE);
+ instance->SetBossState(DATA_SKADI_THE_RUTHLESS, DONE);
}
- void KilledUnit(Unit* /*victim*/) OVERRIDE
+ void KilledUnit(Unit* who) OVERRIDE
{
- Talk(SAY_KILL);
+ if (who->GetTypeId() == TYPEID_PLAYER)
+ Talk(SAY_KILL);
}
void SpawnMobs()
diff --git a/src/server/scripts/Northrend/VaultOfArchavon/boss_emalon.cpp b/src/server/scripts/Northrend/VaultOfArchavon/boss_emalon.cpp
index 1ceddd4bd66..6fc0ffa2d45 100644
--- a/src/server/scripts/Northrend/VaultOfArchavon/boss_emalon.cpp
+++ b/src/server/scripts/Northrend/VaultOfArchavon/boss_emalon.cpp
@@ -268,7 +268,7 @@ class npc_tempest_minion : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_tempest_minionAI(creature);
+ return GetInstanceAI<npc_tempest_minionAI>(creature);
}
};
diff --git a/src/server/scripts/Northrend/VaultOfArchavon/boss_toravon.cpp b/src/server/scripts/Northrend/VaultOfArchavon/boss_toravon.cpp
index e8e54184cb3..7a42983d4e8 100644
--- a/src/server/scripts/Northrend/VaultOfArchavon/boss_toravon.cpp
+++ b/src/server/scripts/Northrend/VaultOfArchavon/boss_toravon.cpp
@@ -277,7 +277,7 @@ class npc_frozen_orb_stalker : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_frozen_orb_stalkerAI(creature);
+ return GetInstanceAI<npc_frozen_orb_stalkerAI>(creature);
}
};
diff --git a/src/server/scripts/Northrend/VioletHold/boss_cyanigosa.cpp b/src/server/scripts/Northrend/VioletHold/boss_cyanigosa.cpp
index 80ebc01debc..524ca946e25 100644
--- a/src/server/scripts/Northrend/VioletHold/boss_cyanigosa.cpp
+++ b/src/server/scripts/Northrend/VioletHold/boss_cyanigosa.cpp
@@ -50,7 +50,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_cyanigosaAI(creature);
+ return GetInstanceAI<boss_cyanigosaAI>(creature);
}
struct boss_cyanigosaAI : public ScriptedAI
@@ -75,16 +75,14 @@ public:
uiManaDestructionTimer = 30000;
uiTailSweepTimer = 20000;
uiUncontrollableEnergyTimer = 25000;
- if (instance)
- instance->SetData(DATA_CYANIGOSA_EVENT, NOT_STARTED);
+ instance->SetData(DATA_CYANIGOSA_EVENT, NOT_STARTED);
}
void EnterCombat(Unit* /*who*/) OVERRIDE
{
Talk(SAY_AGGRO);
- if (instance)
- instance->SetData(DATA_CYANIGOSA_EVENT, IN_PROGRESS);
+ instance->SetData(DATA_CYANIGOSA_EVENT, IN_PROGRESS);
}
void MoveInLineOfSight(Unit* /*who*/) OVERRIDE { }
@@ -144,8 +142,7 @@ public:
{
Talk(SAY_DEATH);
- if (instance)
- instance->SetData(DATA_CYANIGOSA_EVENT, DONE);
+ instance->SetData(DATA_CYANIGOSA_EVENT, DONE);
}
void KilledUnit(Unit* victim) OVERRIDE
diff --git a/src/server/scripts/Northrend/VioletHold/boss_erekem.cpp b/src/server/scripts/Northrend/VioletHold/boss_erekem.cpp
index 883ea8fa0c0..fb6ca01a3d7 100644
--- a/src/server/scripts/Northrend/VioletHold/boss_erekem.cpp
+++ b/src/server/scripts/Northrend/VioletHold/boss_erekem.cpp
@@ -49,7 +49,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_erekemAI(creature);
+ return GetInstanceAI<boss_erekemAI>(creature);
}
struct boss_erekemAI : public ScriptedAI
@@ -74,13 +74,10 @@ public:
uiEarthShockTimer = urand(2000, 8000);
uiLightningBoltTimer = urand(5000, 10000);
uiEarthShieldTimer = 20000;
- if (instance)
- {
- if (instance->GetData(DATA_WAVE_COUNT) == 6)
- instance->SetData(DATA_1ST_BOSS_EVENT, NOT_STARTED);
- else if (instance->GetData(DATA_WAVE_COUNT) == 12)
- instance->SetData(DATA_2ND_BOSS_EVENT, NOT_STARTED);
- }
+ if (instance->GetData(DATA_WAVE_COUNT) == 6)
+ instance->SetData(DATA_1ST_BOSS_EVENT, NOT_STARTED);
+ else if (instance->GetData(DATA_WAVE_COUNT) == 12)
+ instance->SetData(DATA_2ND_BOSS_EVENT, NOT_STARTED);
if (Creature* pGuard1 = Unit::GetCreature(*me, instance ? instance->GetData64(DATA_EREKEM_GUARD_1) : 0))
{
@@ -126,20 +123,17 @@ public:
Talk(SAY_AGGRO);
DoCast(me, SPELL_EARTH_SHIELD);
- if (instance)
- {
- if (GameObject* pDoor = instance->instance->GetGameObject(instance->GetData64(DATA_EREKEM_CELL)))
- if (pDoor->GetGoState() == GO_STATE_READY)
- {
- EnterEvadeMode();
- return;
- }
+ if (GameObject* pDoor = instance->instance->GetGameObject(instance->GetData64(DATA_EREKEM_CELL)))
+ if (pDoor->GetGoState() == GO_STATE_READY)
+ {
+ EnterEvadeMode();
+ return;
+ }
- if (instance->GetData(DATA_WAVE_COUNT) == 6)
- instance->SetData(DATA_1ST_BOSS_EVENT, IN_PROGRESS);
- else if (instance->GetData(DATA_WAVE_COUNT) == 12)
- instance->SetData(DATA_2ND_BOSS_EVENT, IN_PROGRESS);
- }
+ if (instance->GetData(DATA_WAVE_COUNT) == 6)
+ instance->SetData(DATA_1ST_BOSS_EVENT, IN_PROGRESS);
+ else if (instance->GetData(DATA_WAVE_COUNT) == 12)
+ instance->SetData(DATA_2ND_BOSS_EVENT, IN_PROGRESS);
}
void MoveInLineOfSight(Unit* /*who*/) OVERRIDE { }
@@ -210,18 +204,15 @@ public:
{
Talk(SAY_DEATH);
- if (instance)
+ if (instance->GetData(DATA_WAVE_COUNT) == 6)
{
- if (instance->GetData(DATA_WAVE_COUNT) == 6)
- {
- instance->SetData(DATA_1ST_BOSS_EVENT, DONE);
- instance->SetData(DATA_WAVE_COUNT, 7);
- }
- else if (instance->GetData(DATA_WAVE_COUNT) == 12)
- {
- instance->SetData(DATA_2ND_BOSS_EVENT, DONE);
- instance->SetData(DATA_WAVE_COUNT, 13);
- }
+ instance->SetData(DATA_1ST_BOSS_EVENT, DONE);
+ instance->SetData(DATA_WAVE_COUNT, 7);
+ }
+ else if (instance->GetData(DATA_WAVE_COUNT) == 12)
+ {
+ instance->SetData(DATA_2ND_BOSS_EVENT, DONE);
+ instance->SetData(DATA_WAVE_COUNT, 13);
}
}
@@ -266,7 +257,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_erekem_guardAI(creature);
+ return GetInstanceAI<npc_erekem_guardAI>(creature);
}
struct npc_erekem_guardAI : public ScriptedAI
diff --git a/src/server/scripts/Northrend/VioletHold/boss_ichoron.cpp b/src/server/scripts/Northrend/VioletHold/boss_ichoron.cpp
index 4852b6cea07..d6a434669ce 100644
--- a/src/server/scripts/Northrend/VioletHold/boss_ichoron.cpp
+++ b/src/server/scripts/Northrend/VioletHold/boss_ichoron.cpp
@@ -78,7 +78,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_ichoronAI(creature);
+ return GetInstanceAI<boss_ichoronAI>(creature);
}
struct boss_ichoronAI : public ScriptedAI
@@ -110,13 +110,10 @@ public:
me->SetVisible(true);
DespawnWaterElements();
- if (instance)
- {
- if (instance->GetData(DATA_WAVE_COUNT) == 6)
- instance->SetData(DATA_1ST_BOSS_EVENT, NOT_STARTED);
- else if (instance->GetData(DATA_WAVE_COUNT) == 12)
- instance->SetData(DATA_2ND_BOSS_EVENT, NOT_STARTED);
- }
+ if (instance->GetData(DATA_WAVE_COUNT) == 6)
+ instance->SetData(DATA_1ST_BOSS_EVENT, NOT_STARTED);
+ else if (instance->GetData(DATA_WAVE_COUNT) == 12)
+ instance->SetData(DATA_2ND_BOSS_EVENT, NOT_STARTED);
}
void EnterCombat(Unit* /*who*/) OVERRIDE
@@ -125,19 +122,16 @@ public:
DoCast(me, SPELL_PROTECTIVE_BUBBLE);
- if (instance)
- {
- if (GameObject* pDoor = instance->instance->GetGameObject(instance->GetData64(DATA_ICHORON_CELL)))
- if (pDoor->GetGoState() == GO_STATE_READY)
- {
- EnterEvadeMode();
- return;
- }
- if (instance->GetData(DATA_WAVE_COUNT) == 6)
- instance->SetData(DATA_1ST_BOSS_EVENT, IN_PROGRESS);
- else if (instance->GetData(DATA_WAVE_COUNT) == 12)
- instance->SetData(DATA_2ND_BOSS_EVENT, IN_PROGRESS);
- }
+ if (GameObject* pDoor = instance->instance->GetGameObject(instance->GetData64(DATA_ICHORON_CELL)))
+ if (pDoor->GetGoState() == GO_STATE_READY)
+ {
+ EnterEvadeMode();
+ return;
+ }
+ if (instance->GetData(DATA_WAVE_COUNT) == 6)
+ instance->SetData(DATA_1ST_BOSS_EVENT, IN_PROGRESS);
+ else if (instance->GetData(DATA_WAVE_COUNT) == 12)
+ instance->SetData(DATA_2ND_BOSS_EVENT, IN_PROGRESS);
}
void AttackStart(Unit* who) OVERRIDE
@@ -289,18 +283,15 @@ public:
DespawnWaterElements();
- if (instance)
+ if (instance->GetData(DATA_WAVE_COUNT) == 6)
{
- if (instance->GetData(DATA_WAVE_COUNT) == 6)
- {
- instance->SetData(DATA_1ST_BOSS_EVENT, DONE);
- instance->SetData(DATA_WAVE_COUNT, 7);
- }
- else if (instance->GetData(DATA_WAVE_COUNT) == 12)
- {
- instance->SetData(DATA_2ND_BOSS_EVENT, DONE);
- instance->SetData(DATA_WAVE_COUNT, 13);
- }
+ instance->SetData(DATA_1ST_BOSS_EVENT, DONE);
+ instance->SetData(DATA_WAVE_COUNT, 7);
+ }
+ else if (instance->GetData(DATA_WAVE_COUNT) == 12)
+ {
+ instance->SetData(DATA_2ND_BOSS_EVENT, DONE);
+ instance->SetData(DATA_WAVE_COUNT, 13);
}
}
@@ -342,7 +333,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_ichor_globuleAI(creature);
+ return GetInstanceAI<npc_ichor_globuleAI>(creature);
}
struct npc_ichor_globuleAI : public ScriptedAI
@@ -371,16 +362,13 @@ public:
{
if (uiRangeCheck_Timer < uiDiff)
{
- if (instance)
+ if (Creature* pIchoron = Unit::GetCreature(*me, instance->GetData64(DATA_ICHORON)))
{
- if (Creature* pIchoron = Unit::GetCreature(*me, instance->GetData64(DATA_ICHORON)))
+ if (me->IsWithinDist(pIchoron, 2.0f, false))
{
- if (me->IsWithinDist(pIchoron, 2.0f, false))
- {
- if (pIchoron->AI())
- pIchoron->AI()->DoAction(ACTION_WATER_ELEMENT_HIT);
- me->DespawnOrUnsummon();
- }
+ if (pIchoron->AI())
+ pIchoron->AI()->DoAction(ACTION_WATER_ELEMENT_HIT);
+ me->DespawnOrUnsummon();
}
}
uiRangeCheck_Timer = 1000;
diff --git a/src/server/scripts/Northrend/VioletHold/boss_lavanthor.cpp b/src/server/scripts/Northrend/VioletHold/boss_lavanthor.cpp
index 964f6b75e72..c4985962bd4 100644
--- a/src/server/scripts/Northrend/VioletHold/boss_lavanthor.cpp
+++ b/src/server/scripts/Northrend/VioletHold/boss_lavanthor.cpp
@@ -37,7 +37,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_lavanthorAI(creature);
+ return GetInstanceAI<boss_lavanthorAI>(creature);
}
struct boss_lavanthorAI : public ScriptedAI
@@ -60,19 +60,14 @@ public:
uiFlameBreathTimer = 5000;
uiLavaBurnTimer = 10000;
uiCauterizingFlamesTimer = 3000;
- if (instance)
- {
- if (instance->GetData(DATA_WAVE_COUNT) == 6)
- instance->SetData(DATA_1ST_BOSS_EVENT, NOT_STARTED);
- else if (instance->GetData(DATA_WAVE_COUNT) == 12)
- instance->SetData(DATA_2ND_BOSS_EVENT, NOT_STARTED);
- }
+ if (instance->GetData(DATA_WAVE_COUNT) == 6)
+ instance->SetData(DATA_1ST_BOSS_EVENT, NOT_STARTED);
+ else if (instance->GetData(DATA_WAVE_COUNT) == 12)
+ instance->SetData(DATA_2ND_BOSS_EVENT, NOT_STARTED);
}
void EnterCombat(Unit* /*who*/) OVERRIDE
{
- if (instance)
- {
if (GameObject* pDoor = instance->instance->GetGameObject(instance->GetData64(DATA_LAVANTHOR_CELL)))
if (pDoor->GetGoState() == GO_STATE_READY)
{
@@ -83,7 +78,6 @@ public:
instance->SetData(DATA_1ST_BOSS_EVENT, IN_PROGRESS);
else if (instance->GetData(DATA_WAVE_COUNT) == 12)
instance->SetData(DATA_2ND_BOSS_EVENT, IN_PROGRESS);
- }
}
void AttackStart(Unit* who) OVERRIDE
@@ -141,18 +135,15 @@ public:
void JustDied(Unit* /*killer*/) OVERRIDE
{
- if (instance)
+ if (instance->GetData(DATA_WAVE_COUNT) == 6)
{
- if (instance->GetData(DATA_WAVE_COUNT) == 6)
- {
- instance->SetData(DATA_1ST_BOSS_EVENT, DONE);
- instance->SetData(DATA_WAVE_COUNT, 7);
- }
- else if (instance->GetData(DATA_WAVE_COUNT) == 12)
- {
- instance->SetData(DATA_2ND_BOSS_EVENT, DONE);
- instance->SetData(DATA_WAVE_COUNT, 13);
- }
+ instance->SetData(DATA_1ST_BOSS_EVENT, DONE);
+ instance->SetData(DATA_WAVE_COUNT, 7);
+ }
+ else if (instance->GetData(DATA_WAVE_COUNT) == 12)
+ {
+ instance->SetData(DATA_2ND_BOSS_EVENT, DONE);
+ instance->SetData(DATA_WAVE_COUNT, 13);
}
}
};
diff --git a/src/server/scripts/Northrend/VioletHold/boss_moragg.cpp b/src/server/scripts/Northrend/VioletHold/boss_moragg.cpp
index d5dd41e7a90..0807fb826f2 100644
--- a/src/server/scripts/Northrend/VioletHold/boss_moragg.cpp
+++ b/src/server/scripts/Northrend/VioletHold/boss_moragg.cpp
@@ -33,7 +33,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_moraggAI(creature);
+ return GetInstanceAI<boss_moraggAI>(creature);
}
struct boss_moraggAI : public ScriptedAI
@@ -53,30 +53,24 @@ public:
uiOpticLinkTimer = 10000;
uiCorrosiveSalivaTimer = 5000;
- if (instance)
- {
- if (instance->GetData(DATA_WAVE_COUNT) == 6)
- instance->SetData(DATA_1ST_BOSS_EVENT, NOT_STARTED);
- else if (instance->GetData(DATA_WAVE_COUNT) == 12)
- instance->SetData(DATA_2ND_BOSS_EVENT, NOT_STARTED);
- }
+ if (instance->GetData(DATA_WAVE_COUNT) == 6)
+ instance->SetData(DATA_1ST_BOSS_EVENT, NOT_STARTED);
+ else if (instance->GetData(DATA_WAVE_COUNT) == 12)
+ instance->SetData(DATA_2ND_BOSS_EVENT, NOT_STARTED);
}
void EnterCombat(Unit* /*who*/) OVERRIDE
{
- if (instance)
- {
- if (GameObject* pDoor = instance->instance->GetGameObject(instance->GetData64(DATA_MORAGG_CELL)))
- if (pDoor->GetGoState() == GO_STATE_READY)
- {
- EnterEvadeMode();
- return;
- }
- if (instance->GetData(DATA_WAVE_COUNT) == 6)
- instance->SetData(DATA_1ST_BOSS_EVENT, IN_PROGRESS);
- else if (instance->GetData(DATA_WAVE_COUNT) == 12)
- instance->SetData(DATA_2ND_BOSS_EVENT, IN_PROGRESS);
- }
+ if (GameObject* pDoor = instance->instance->GetGameObject(instance->GetData64(DATA_MORAGG_CELL)))
+ if (pDoor->GetGoState() == GO_STATE_READY)
+ {
+ EnterEvadeMode();
+ return;
+ }
+ if (instance->GetData(DATA_WAVE_COUNT) == 6)
+ instance->SetData(DATA_1ST_BOSS_EVENT, IN_PROGRESS);
+ else if (instance->GetData(DATA_WAVE_COUNT) == 12)
+ instance->SetData(DATA_2ND_BOSS_EVENT, IN_PROGRESS);
}
void AttackStart(Unit* who) OVERRIDE
@@ -119,18 +113,15 @@ public:
}
void JustDied(Unit* /*killer*/) OVERRIDE
{
- if (instance)
+ if (instance->GetData(DATA_WAVE_COUNT) == 6)
{
- if (instance->GetData(DATA_WAVE_COUNT) == 6)
- {
- instance->SetData(DATA_1ST_BOSS_EVENT, DONE);
- instance->SetData(DATA_WAVE_COUNT, 7);
- }
- else if (instance->GetData(DATA_WAVE_COUNT) == 12)
- {
- instance->SetData(DATA_2ND_BOSS_EVENT, DONE);
- instance->SetData(DATA_WAVE_COUNT, 13);
- }
+ instance->SetData(DATA_1ST_BOSS_EVENT, DONE);
+ instance->SetData(DATA_WAVE_COUNT, 7);
+ }
+ else if (instance->GetData(DATA_WAVE_COUNT) == 12)
+ {
+ instance->SetData(DATA_2ND_BOSS_EVENT, DONE);
+ instance->SetData(DATA_WAVE_COUNT, 13);
}
}
};
diff --git a/src/server/scripts/Northrend/VioletHold/boss_xevozz.cpp b/src/server/scripts/Northrend/VioletHold/boss_xevozz.cpp
index 8b39c48fb92..40dcac41692 100644
--- a/src/server/scripts/Northrend/VioletHold/boss_xevozz.cpp
+++ b/src/server/scripts/Northrend/VioletHold/boss_xevozz.cpp
@@ -63,7 +63,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_xevozzAI(creature);
+ return GetInstanceAI<boss_xevozzAI>(creature);
}
struct boss_xevozzAI : public ScriptedAI
@@ -81,13 +81,10 @@ public:
void Reset() OVERRIDE
{
- if (instance)
- {
- if (instance->GetData(DATA_WAVE_COUNT) == 6)
- instance->SetData(DATA_1ST_BOSS_EVENT, NOT_STARTED);
- else if (instance->GetData(DATA_WAVE_COUNT) == 12)
- instance->SetData(DATA_2ND_BOSS_EVENT, NOT_STARTED);
- }
+ if (instance->GetData(DATA_WAVE_COUNT) == 6)
+ instance->SetData(DATA_1ST_BOSS_EVENT, NOT_STARTED);
+ else if (instance->GetData(DATA_WAVE_COUNT) == 12)
+ instance->SetData(DATA_2ND_BOSS_EVENT, NOT_STARTED);
uiSummonEtherealSphere_Timer = urand(10000, 12000);
uiArcaneBarrageVolley_Timer = urand(20000, 22000);
@@ -137,19 +134,16 @@ public:
void EnterCombat(Unit* /*who*/) OVERRIDE
{
Talk(SAY_AGGRO);
- if (instance)
- {
- if (GameObject* pDoor = instance->instance->GetGameObject(instance->GetData64(DATA_XEVOZZ_CELL)))
- if (pDoor->GetGoState() == GO_STATE_READY)
- {
- EnterEvadeMode();
- return;
- }
- if (instance->GetData(DATA_WAVE_COUNT) == 6)
- instance->SetData(DATA_1ST_BOSS_EVENT, IN_PROGRESS);
- else if (instance->GetData(DATA_WAVE_COUNT) == 12)
- instance->SetData(DATA_2ND_BOSS_EVENT, IN_PROGRESS);
- }
+ if (GameObject* pDoor = instance->instance->GetGameObject(instance->GetData64(DATA_XEVOZZ_CELL)))
+ if (pDoor->GetGoState() == GO_STATE_READY)
+ {
+ EnterEvadeMode();
+ return;
+ }
+ if (instance->GetData(DATA_WAVE_COUNT) == 6)
+ instance->SetData(DATA_1ST_BOSS_EVENT, IN_PROGRESS);
+ else if (instance->GetData(DATA_WAVE_COUNT) == 12)
+ instance->SetData(DATA_2ND_BOSS_EVENT, IN_PROGRESS);
}
void MoveInLineOfSight(Unit* /*who*/) OVERRIDE { }
@@ -199,18 +193,15 @@ public:
DespawnSphere();
- if (instance)
+ if (instance->GetData(DATA_WAVE_COUNT) == 6)
{
- if (instance->GetData(DATA_WAVE_COUNT) == 6)
- {
- instance->SetData(DATA_1ST_BOSS_EVENT, DONE);
- instance->SetData(DATA_WAVE_COUNT, 7);
- }
- else if (instance->GetData(DATA_WAVE_COUNT) == 12)
- {
- instance->SetData(DATA_2ND_BOSS_EVENT, NOT_STARTED);
- instance->SetData(DATA_WAVE_COUNT, 13);
- }
+ instance->SetData(DATA_1ST_BOSS_EVENT, DONE);
+ instance->SetData(DATA_WAVE_COUNT, 7);
+ }
+ else if (instance->GetData(DATA_WAVE_COUNT) == 12)
+ {
+ instance->SetData(DATA_2ND_BOSS_EVENT, NOT_STARTED);
+ instance->SetData(DATA_WAVE_COUNT, 13);
}
}
void KilledUnit(Unit* victim) OVERRIDE
@@ -231,7 +222,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_ethereal_sphereAI(creature);
+ return GetInstanceAI<npc_ethereal_sphereAI>(creature);
}
struct npc_ethereal_sphereAI : public ScriptedAI
@@ -263,16 +254,13 @@ public:
if (uiRangeCheck_Timer < uiDiff)
{
- if (instance)
+ if (Creature* pXevozz = Unit::GetCreature(*me, instance->GetData64(DATA_XEVOZZ)))
{
- if (Creature* pXevozz = Unit::GetCreature(*me, instance->GetData64(DATA_XEVOZZ)))
- {
- float fDistance = me->GetDistance2d(pXevozz);
- if (fDistance <= 3)
- DoCast(pXevozz, SPELL_ARCANE_POWER);
- else
- DoCast(me, 35845); //Is it blizzlike?
- }
+ float fDistance = me->GetDistance2d(pXevozz);
+ if (fDistance <= 3)
+ DoCast(pXevozz, SPELL_ARCANE_POWER);
+ else
+ DoCast(me, 35845); //Is it blizzlike?
}
uiRangeCheck_Timer = 1000;
}
diff --git a/src/server/scripts/Northrend/VioletHold/boss_zuramat.cpp b/src/server/scripts/Northrend/VioletHold/boss_zuramat.cpp
index 3db389ac703..420f3d2836b 100644
--- a/src/server/scripts/Northrend/VioletHold/boss_zuramat.cpp
+++ b/src/server/scripts/Northrend/VioletHold/boss_zuramat.cpp
@@ -58,7 +58,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_zuramatAI(creature);
+ return GetInstanceAI<boss_zuramatAI>(creature);
}
struct boss_zuramatAI : public ScriptedAI
@@ -77,13 +77,10 @@ public:
void Reset() OVERRIDE
{
- if (instance)
- {
- if (instance->GetData(DATA_WAVE_COUNT) == 6)
- instance->SetData(DATA_1ST_BOSS_EVENT, NOT_STARTED);
- else if (instance->GetData(DATA_WAVE_COUNT) == 12)
- instance->SetData(DATA_2ND_BOSS_EVENT, NOT_STARTED);
- }
+ if (instance->GetData(DATA_WAVE_COUNT) == 6)
+ instance->SetData(DATA_1ST_BOSS_EVENT, NOT_STARTED);
+ else if (instance->GetData(DATA_WAVE_COUNT) == 12)
+ instance->SetData(DATA_2ND_BOSS_EVENT, NOT_STARTED);
SpellShroudOfDarknessTimer = 22000;
SpellVoidShiftTimer = 15000;
@@ -108,19 +105,16 @@ public:
void EnterCombat(Unit* /*who*/) OVERRIDE
{
Talk(SAY_AGGRO);
- if (instance)
- {
- if (GameObject* pDoor = instance->instance->GetGameObject(instance->GetData64(DATA_ZURAMAT_CELL)))
- if (pDoor->GetGoState() == GO_STATE_READY)
- {
- EnterEvadeMode();
- return;
- }
- if (instance->GetData(DATA_WAVE_COUNT) == 6)
- instance->SetData(DATA_1ST_BOSS_EVENT, IN_PROGRESS);
- else if (instance->GetData(DATA_WAVE_COUNT) == 12)
- instance->SetData(DATA_2ND_BOSS_EVENT, IN_PROGRESS);
- }
+ if (GameObject* pDoor = instance->instance->GetGameObject(instance->GetData64(DATA_ZURAMAT_CELL)))
+ if (pDoor->GetGoState() == GO_STATE_READY)
+ {
+ EnterEvadeMode();
+ return;
+ }
+ if (instance->GetData(DATA_WAVE_COUNT) == 6)
+ instance->SetData(DATA_1ST_BOSS_EVENT, IN_PROGRESS);
+ else if (instance->GetData(DATA_WAVE_COUNT) == 12)
+ instance->SetData(DATA_2ND_BOSS_EVENT, IN_PROGRESS);
}
void MoveInLineOfSight(Unit* /*who*/) OVERRIDE { }
@@ -172,18 +166,15 @@ public:
{
Talk(SAY_DEATH);
- if (instance)
+ if (instance->GetData(DATA_WAVE_COUNT) == 6)
{
- if (instance->GetData(DATA_WAVE_COUNT) == 6)
- {
- instance->SetData(DATA_1ST_BOSS_EVENT, DONE);
- instance->SetData(DATA_WAVE_COUNT, 7);
- }
- else if (instance->GetData(DATA_WAVE_COUNT) == 12)
- {
- instance->SetData(DATA_2ND_BOSS_EVENT, DONE);
- instance->SetData(DATA_WAVE_COUNT, 13);
- }
+ instance->SetData(DATA_1ST_BOSS_EVENT, DONE);
+ instance->SetData(DATA_WAVE_COUNT, 7);
+ }
+ else if (instance->GetData(DATA_WAVE_COUNT) == 12)
+ {
+ instance->SetData(DATA_2ND_BOSS_EVENT, DONE);
+ instance->SetData(DATA_WAVE_COUNT, 13);
}
}
diff --git a/src/server/scripts/Northrend/VioletHold/instance_violet_hold.cpp b/src/server/scripts/Northrend/VioletHold/instance_violet_hold.cpp
index 4ff0f2d36e9..3e16f38001b 100644
--- a/src/server/scripts/Northrend/VioletHold/instance_violet_hold.cpp
+++ b/src/server/scripts/Northrend/VioletHold/instance_violet_hold.cpp
@@ -160,7 +160,7 @@ public:
bool bActive;
bool bWiped;
- bool bIsDoorSpellCasted;
+ bool bIsDoorSpellCast;
bool bCrystalActivated;
bool defenseless;
@@ -210,7 +210,7 @@ public:
uiCyanigosaEventTimer = 3*IN_MILLISECONDS;
bActive = false;
- bIsDoorSpellCasted = false;
+ bIsDoorSpellCast = false;
bCrystalActivated = false;
defenseless = true;
uiMainEventPhase = NOT_STARTED;
diff --git a/src/server/scripts/Northrend/VioletHold/violet_hold.cpp b/src/server/scripts/Northrend/VioletHold/violet_hold.cpp
index c78a1ee1740..af833f3d4c5 100644
--- a/src/server/scripts/Northrend/VioletHold/violet_hold.cpp
+++ b/src/server/scripts/Northrend/VioletHold/violet_hold.cpp
@@ -307,7 +307,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_sinclariAI(creature);
+ return GetInstanceAI<npc_sinclariAI>(creature);
}
struct npc_sinclariAI : public ScriptedAI
@@ -401,8 +401,7 @@ public:
uiPhase = 5;
break;
case 5:
- if (instance)
- instance->SetData(DATA_MAIN_EVENT_PHASE, IN_PROGRESS);
+ instance->SetData(DATA_MAIN_EVENT_PHASE, IN_PROGRESS);
me->SetReactState(REACT_PASSIVE);
uiTimer = 0;
uiPhase = 0;
@@ -428,7 +427,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_azure_saboteurAI(creature);
+ return GetInstanceAI<npc_azure_saboteurAI>(creature);
}
struct npc_azure_saboteurAI : public npc_escortAI
@@ -552,7 +551,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_teleportation_portalAI(creature);
+ return GetInstanceAI<npc_teleportation_portalAI>(creature);
}
struct npc_teleportation_portalAI : public ScriptedAI
@@ -585,9 +584,6 @@ public:
void UpdateAI(uint32 diff) OVERRIDE
{
- if (!instance) //Massive usage of instance, global check
- return;
-
if (instance->GetData(DATA_REMOVE_NPC) == 1)
{
me->DespawnOrUnsummon();
@@ -649,7 +645,7 @@ public:
uiSpawnTimer = SPAWN_TIME;
} else uiSpawnTimer -= diff;
- if (bPortalGuardianOrKeeperOrEliteSpawn && !me->IsNonMeleeSpellCasted(false))
+ if (bPortalGuardianOrKeeperOrEliteSpawn && !me->IsNonMeleeSpellCast(false))
{
me->Kill(me, false);
me->RemoveCorpse();
@@ -660,22 +656,19 @@ public:
void JustDied(Unit* /*killer*/) OVERRIDE
{
- if (instance)
- instance->SetData(DATA_WAVE_COUNT, instance->GetData(DATA_WAVE_COUNT)+1);
+ instance->SetData(DATA_WAVE_COUNT, instance->GetData(DATA_WAVE_COUNT)+1);
}
void JustSummoned(Creature* summoned) OVERRIDE
{
listOfMobs.Summon(summoned);
- if (instance)
- instance->SetData64(DATA_ADD_TRASH_MOB, summoned->GetGUID());
+ instance->SetData64(DATA_ADD_TRASH_MOB, summoned->GetGUID());
}
void SummonedCreatureDies(Creature* summoned, Unit* /*killer*/) OVERRIDE
{
listOfMobs.Despawn(summoned);
- if (instance)
- instance->SetData64(DATA_DEL_TRASH_MOB, summoned->GetGUID());
+ instance->SetData64(DATA_DEL_TRASH_MOB, summoned->GetGUID());
}
};
@@ -687,8 +680,7 @@ struct violet_hold_trashAI : public npc_escortAI
{
instance = creature->GetInstanceScript();
bHasGotMovingPoints = false;
- if (instance)
- portalLocationID = instance->GetData(DATA_PORTAL_LOCATION);
+ portalLocationID = instance->GetData(DATA_PORTAL_LOCATION);
Reset();
}
@@ -788,16 +780,14 @@ struct violet_hold_trashAI : public npc_escortAI
void JustDied(Unit* /*killer*/) OVERRIDE
{
- if (instance)
- instance->SetData(DATA_NPC_PRESENCE_AT_DOOR_REMOVE, 1);
+ instance->SetData(DATA_NPC_PRESENCE_AT_DOOR_REMOVE, 1);
}
void CreatureStartAttackDoor()
{
me->SetReactState(REACT_PASSIVE);
DoCast(SPELL_DESTROY_DOOR_SEAL);
- if (instance)
- instance->SetData(DATA_NPC_PRESENCE_AT_DOOR_ADD, 1);
+ instance->SetData(DATA_NPC_PRESENCE_AT_DOOR_ADD, 1);
}
};
@@ -809,7 +799,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_azure_invaderAI(creature);
+ return GetInstanceAI<npc_azure_invaderAI>(creature);
}
struct npc_azure_invaderAI : public violet_hold_trashAI
@@ -887,7 +877,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_azure_binderAI(creature);
+ return GetInstanceAI<npc_azure_binderAI>(creature);
}
struct npc_azure_binderAI : public violet_hold_trashAI
@@ -965,7 +955,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_azure_mage_slayerAI(creature);
+ return GetInstanceAI<npc_azure_mage_slayerAI>(creature);
}
struct npc_azure_mage_slayerAI : public violet_hold_trashAI
@@ -1025,7 +1015,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_azure_raiderAI(creature);
+ return GetInstanceAI<npc_azure_raiderAI>(creature);
}
struct npc_azure_raiderAI : public violet_hold_trashAI
@@ -1131,7 +1121,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_azure_stalkerAI(creature);
+ return GetInstanceAI<npc_azure_stalkerAI>(creature);
}
};
@@ -1210,7 +1200,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_azure_spellbreakerAI(creature);
+ return GetInstanceAI<npc_azure_spellbreakerAI>(creature);
}
};
@@ -1221,7 +1211,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_azure_captainAI(creature);
+ return GetInstanceAI<npc_azure_captainAI>(creature);
}
struct npc_azure_captainAI : public violet_hold_trashAI
@@ -1273,7 +1263,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_azure_sorcerorAI(creature);
+ return GetInstanceAI<npc_azure_sorcerorAI>(creature);
}
struct npc_azure_sorcerorAI : public violet_hold_trashAI
diff --git a/src/server/scripts/Northrend/zone_borean_tundra.cpp b/src/server/scripts/Northrend/zone_borean_tundra.cpp
index ccb18df7f0d..420b01d3564 100644
--- a/src/server/scripts/Northrend/zone_borean_tundra.cpp
+++ b/src/server/scripts/Northrend/zone_borean_tundra.cpp
@@ -51,6 +51,9 @@ 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,
@@ -83,7 +86,7 @@ public:
return;
Player* player = caster->ToPlayer();
- if (player && player->GetQuestStatus(11897) == QUEST_STATUS_INCOMPLETE)
+ if (player && player->GetQuestStatus(QUEST_PLUG_THE_SINKHOLES) == QUEST_STATUS_INCOMPLETE)
{
phase = 1;
casterGuid = caster->GetGUID();
@@ -104,13 +107,13 @@ public:
case 1:
DoCast(me, SPELL_EXPLODE_CART, true);
DoCast(me, SPELL_SUMMON_CART, true);
- if (GameObject* cart = me->FindNearestGameObject(188160, 3))
+ if (GameObject* cart = me->FindNearestGameObject(GO_EXPLOSIVES_CART, 3.0f))
cart->SetUInt32Value(GAMEOBJECT_FACTION, 14);
phaseTimer = 3000;
phase = 2;
break;
case 2:
- if (GameObject* cart = me->FindNearestGameObject(188160, 3))
+ if (GameObject* cart = me->FindNearestGameObject(GO_EXPLOSIVES_CART, 3.0f))
cart->UseDoorOrButton();
DoCast(me, SPELL_EXPLODE_CART, true);
phaseTimer = 3000;
@@ -123,7 +126,7 @@ public:
break;
case 5:
DoCast(me, SPELL_SUMMON_WORM, true);
- if (Unit* worm = me->FindNearestCreature(26250, 3))
+ if (Unit* worm = me->FindNearestCreature(NPC_SCOURGED_BURROWER, 3.0f))
{
worm->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
worm->HandleEmoteCommand(EMOTE_ONESHOT_EMERGE);
@@ -133,7 +136,7 @@ public:
break;
case 6:
DoCast(me, SPELL_EXPLODE_CART, true);
- if (Unit* worm = me->FindNearestCreature(26250, 3))
+ if (Unit* worm = me->FindNearestCreature(NPC_SCOURGED_BURROWER, 3.0f))
{
me->Kill(worm);
worm->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
@@ -168,6 +171,12 @@ public:
## npc_khunok_the_behemoth
######*/
+enum Khunok
+{
+ NPC_ORPHANED_MAMMOTH_CALF = 25861,
+ SPELL_MAMMOTH_CALF_ESCORT_CREDIT = 46231
+};
+
class npc_khunok_the_behemoth : public CreatureScript
{
public:
@@ -185,13 +194,13 @@ public:
if (who->GetTypeId() != TYPEID_UNIT)
return;
- if (who->GetEntry() == 25861 && me->IsWithinDistInMap(who, 10.0f))
+ if (who->GetEntry() == NPC_ORPHANED_MAMMOTH_CALF && me->IsWithinDistInMap(who, 10.0f))
{
if (Unit* owner = who->GetOwner())
{
if (owner->GetTypeId() == TYPEID_PLAYER)
{
- owner->CastSpell(owner, 46231, true);
+ owner->CastSpell(owner, SPELL_MAMMOTH_CALF_ESCORT_CREDIT, true);
who->ToCreature()->DespawnOrUnsummon();
}
}
@@ -341,11 +350,19 @@ public:
## npc_nerubar_victim
######*/
-#define WARSONG_PEON 25270
+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
+};
const uint32 nerubarVictims[3] =
{
- 45526, 45527, 45514
+ SPELL_FREED_WARSONG_MAGE, SPELL_FREED_WARSONG_SHAMAN, SPELL_FREED_WARSONG_WARRIOR
};
class npc_nerubar_victim : public CreatureScript
@@ -368,13 +385,13 @@ public:
if (!player)
return;
- if (player->GetQuestStatus(11611) == QUEST_STATUS_INCOMPLETE)
+ if (player->GetQuestStatus(QUEST_TAKEN_BY_THE_SCOURGE) == QUEST_STATUS_INCOMPLETE)
{
uint8 uiRand = urand(0, 99);
if (uiRand < 25)
{
- player->CastSpell(me, 45532, true);
- player->KilledMonsterCredit(WARSONG_PEON, 0);
+ player->CastSpell(me, SPELL_FREED_WARSONG_PEON, true);
+ player->KilledMonsterCredit(NPC_WARSONG_PEON, 0);
}
else if (uiRand < 75)
player->CastSpell(me, nerubarVictims[urand(0, 2)], true);
@@ -411,7 +428,10 @@ public:
struct npc_jennyAI : public ScriptedAI
{
- npc_jennyAI(Creature* creature) : ScriptedAI(creature) { }
+ npc_jennyAI(Creature* creature) : ScriptedAI(creature)
+ {
+ setCrateNumber = false;
+ }
bool setCrateNumber;
@@ -422,6 +442,9 @@ public:
me->SetReactState(REACT_PASSIVE);
+ if (!me->GetOwner())
+ return;
+
switch (me->GetOwner()->ToPlayer()->GetTeamId())
{
case TEAM_ALLIANCE:
@@ -1026,9 +1049,9 @@ public:
}
}
- void UpdateAI(uint32 uiDiff) OVERRIDE
+ void UpdateAI(uint32 diff) OVERRIDE
{
- npc_escortAI::UpdateAI(uiDiff);
+ npc_escortAI::UpdateAI(diff);
if (arthasInPosition && talbotInPosition)
{
@@ -1045,7 +1068,7 @@ public:
SetEscortPaused(false);
}
- if (phaseTimer <= uiDiff)
+ if (phaseTimer <= diff)
{
Creature* talbot = me->GetCreature(*me, talbotGUID);
Creature* arthas = me->GetCreature(*me, arthasGUID);
@@ -1196,7 +1219,7 @@ public:
phaseTimer = 0;
phase = 0;
}
- } else phaseTimer -= uiDiff;
+ } else phaseTimer -= diff;
if (!UpdateVictim())
return;
@@ -1369,7 +1392,7 @@ public:
CAST_AI(npc_thassarian::npc_thassarianAI, summoner->ToCreature()->AI())->talbotInPosition = true;
}
- void UpdateAI(uint32 uiDiff) OVERRIDE
+ void UpdateAI(uint32 diff) OVERRIDE
{
if (bCheck)
{
@@ -1385,23 +1408,23 @@ public:
if (me->GetAreaId() == 4125)
{
- if (shadowBoltTimer <= uiDiff)
+ if (shadowBoltTimer <= diff)
{
DoCastVictim(SPELL_SHADOW_BOLT);
shadowBoltTimer = urand(5000, 12000);
- } else shadowBoltTimer -= uiDiff;
+ } else shadowBoltTimer -= diff;
- if (deflectionTimer <= uiDiff)
+ if (deflectionTimer <= diff)
{
DoCastVictim(SPELL_DEFLECTION);
deflectionTimer = urand(20000, 25000);
- } else deflectionTimer -= uiDiff;
+ } else deflectionTimer -= diff;
- if (soulBlastTimer <= uiDiff)
+ if (soulBlastTimer <= diff)
{
DoCastVictim(SPELL_SOUL_BLAST);
soulBlastTimer = urand(12000, 18000);
- } else soulBlastTimer -= uiDiff;
+ } else soulBlastTimer -= diff;
}
DoMeleeAttackIfReady();
@@ -1491,11 +1514,11 @@ public:
}
}
- void UpdateAI(uint32 uiDiff) OVERRIDE
+ void UpdateAI(uint32 diff) OVERRIDE
{
- ScriptedAI::UpdateAI(uiDiff);
+ ScriptedAI::UpdateAI(diff);
- if (phaseTimer <= uiDiff)
+ if (phaseTimer <= diff)
{
switch (phase)
{
@@ -1551,7 +1574,7 @@ public:
phase = 0;
break;
}
- } else phaseTimer -= uiDiff;
+ } else phaseTimer -= diff;
if (!UpdateVictim())
return;
@@ -1632,7 +1655,7 @@ public:
}
}
- void UpdateAI(uint32 /*uiDiff*/) OVERRIDE
+ void UpdateAI(uint32 /*diff*/) OVERRIDE
{
if (!UpdateVictim())
return;
diff --git a/src/server/scripts/Northrend/zone_crystalsong_forest.cpp b/src/server/scripts/Northrend/zone_crystalsong_forest.cpp
index 34a217b6418..4c45bed1af8 100644
--- a/src/server/scripts/Northrend/zone_crystalsong_forest.cpp
+++ b/src/server/scripts/Northrend/zone_crystalsong_forest.cpp
@@ -56,21 +56,21 @@ public:
SetCombatMovement(false);
}
- uint64 uiTargetGUID;
+ uint64 targetGUID;
void Reset() OVERRIDE
{
- uiTargetGUID = 0;
+ targetGUID = 0;
}
- void UpdateAI(uint32 /*uiDiff*/) OVERRIDE
+ void UpdateAI(uint32 /*diff*/) OVERRIDE
{
- if (me->IsNonMeleeSpellCasted(false))
+ if (me->IsNonMeleeSpellCast(false))
return;
if (me->GetEntry() == NPC_WARMAGE_SARINA)
{
- if (!uiTargetGUID)
+ if (!targetGUID)
{
std::list<Creature*> orbList;
GetCreatureListWithEntryInGrid(orbList, me, NPC_TRANSITUS_SHIELD_DUMMY, 32.0f);
@@ -82,7 +82,7 @@ public:
{
if (pOrb->GetPositionY() < 1000)
{
- uiTargetGUID = pOrb->GetGUID();
+ targetGUID = pOrb->GetGUID();
break;
}
}
@@ -91,13 +91,13 @@ public:
}
}else
{
- if (!uiTargetGUID)
+ if (!targetGUID)
if (Creature* pOrb = GetClosestCreatureWithEntry(me, NPC_TRANSITUS_SHIELD_DUMMY, 32.0f))
- uiTargetGUID = pOrb->GetGUID();
+ targetGUID = pOrb->GetGUID();
}
- if (Creature* pOrb = me->GetCreature(*me, uiTargetGUID))
+ if (Creature* pOrb = me->GetCreature(*me, targetGUID))
DoCast(pOrb, SPELL_TRANSITUS_SHIELD_BEAM);
}
diff --git a/src/server/scripts/Northrend/zone_dalaran.cpp b/src/server/scripts/Northrend/zone_dalaran.cpp
index 3a0984e4c44..146276e757b 100644
--- a/src/server/scripts/Northrend/zone_dalaran.cpp
+++ b/src/server/scripts/Northrend/zone_dalaran.cpp
@@ -35,8 +35,8 @@ Script Data End */
enum Spells
{
- SPELL_TRESPASSER_A = 54028,
- SPELL_TRESPASSER_H = 54029,
+ SPELL_TRESPASSER_A = 54028,
+ SPELL_TRESPASSER_H = 54029,
SPELL_SUNREAVER_DISGUISE_FEMALE = 70973,
SPELL_SUNREAVER_DISGUISE_MALE = 70974,
@@ -46,8 +46,10 @@ enum Spells
enum NPCs // All outdoor guards are within 35.0f of these NPCs
{
- NPC_APPLEBOUGH_A = 29547,
- NPC_SWEETBERRY_H = 29715,
+ NPC_APPLEBOUGH_A = 29547,
+ NPC_SWEETBERRY_H = 29715,
+ NPC_SILVER_COVENANT_GUARDIAN_MAGE = 29254,
+ NPC_SUNREAVER_GUARDIAN_MAGE = 29255,
};
class npc_mageguard_dalaran : public CreatureScript
@@ -89,7 +91,7 @@ public:
switch (me->GetEntry())
{
- case 29254:
+ case NPC_SILVER_COVENANT_GUARDIAN_MAGE:
if (player->GetTeam() == HORDE) // Horde unit found in Alliance area
{
if (GetClosestCreatureWithEntry(me, NPC_APPLEBOUGH_A, 32.0f))
@@ -101,7 +103,7 @@ public:
DoCast(who, SPELL_TRESPASSER_A); // Teleport the Horde unit out
}
break;
- case 29255:
+ case NPC_SUNREAVER_GUARDIAN_MAGE:
if (player->GetTeam() == ALLIANCE) // Alliance unit found in Horde area
{
if (GetClosestCreatureWithEntry(me, NPC_SWEETBERRY_H, 32.0f))
diff --git a/src/server/scripts/Northrend/zone_dragonblight.cpp b/src/server/scripts/Northrend/zone_dragonblight.cpp
index 5f3442c1ba9..9673fef0a1e 100644
--- a/src/server/scripts/Northrend/zone_dragonblight.cpp
+++ b/src/server/scripts/Northrend/zone_dragonblight.cpp
@@ -517,7 +517,7 @@ enum WyrmDefenderEnum
// Spells data
SPELL_CHARACTER_SCRIPT = 49213,
SPELL_DEFENDER_ON_LOW_HEALTH_EMOTE = 52421, // ID - 52421 Wyrmrest Defender: On Low Health Boss Emote to Controller - Random /self/
- SPELL_RENEW = 49263, // casted to heal drakes
+ SPELL_RENEW = 49263, // cast to heal drakes
SPELL_WYRMREST_DEFENDER_MOUNT = 49256,
// Texts data
diff --git a/src/server/scripts/Outland/Auchindoun/AuchenaiCrypts/boss_exarch_maladaar.cpp b/src/server/scripts/Outland/Auchindoun/AuchenaiCrypts/boss_exarch_maladaar.cpp
index 783e7b9f09b..9b96255fde0 100644
--- a/src/server/scripts/Outland/Auchindoun/AuchenaiCrypts/boss_exarch_maladaar.cpp
+++ b/src/server/scripts/Outland/Auchindoun/AuchenaiCrypts/boss_exarch_maladaar.cpp
@@ -250,7 +250,7 @@ public:
if (!Avatar_summoned && HealthBelowPct(25))
{
- if (me->IsNonMeleeSpellCasted(false))
+ if (me->IsNonMeleeSpellCast(false))
me->InterruptNonMeleeSpells(true);
Talk(SAY_SUMMON);
@@ -266,7 +266,7 @@ public:
{
if (target->GetTypeId() == TYPEID_PLAYER)
{
- if (me->IsNonMeleeSpellCasted(false))
+ if (me->IsNonMeleeSpellCast(false))
me->InterruptNonMeleeSpells(true);
Talk(SAY_ROAR);
diff --git a/src/server/scripts/Outland/Auchindoun/ManaTombs/boss_nexusprince_shaffar.cpp b/src/server/scripts/Outland/Auchindoun/ManaTombs/boss_nexusprince_shaffar.cpp
index 862fe76decd..db69ca6c892 100644
--- a/src/server/scripts/Outland/Auchindoun/ManaTombs/boss_nexusprince_shaffar.cpp
+++ b/src/server/scripts/Outland/Auchindoun/ManaTombs/boss_nexusprince_shaffar.cpp
@@ -170,7 +170,7 @@ public:
if (FrostNova_Timer <= diff)
{
- if (me->IsNonMeleeSpellCasted(false))
+ if (me->IsNonMeleeSpellCast(false))
me->InterruptNonMeleeSpells(true);
DoCast(me, SPELL_FROSTNOVA);
@@ -194,7 +194,7 @@ public:
{
if (Blink_Timer <= diff)
{
- if (me->IsNonMeleeSpellCasted(false))
+ if (me->IsNonMeleeSpellCast(false))
me->InterruptNonMeleeSpells(true);
//expire movement, will prevent from running right back to victim after cast
@@ -210,7 +210,7 @@ public:
if (Beacon_Timer <= diff)
{
- if (me->IsNonMeleeSpellCasted(false))
+ if (me->IsNonMeleeSpellCast(false))
me->InterruptNonMeleeSpells(true);
if (!urand(0, 3))
@@ -301,7 +301,7 @@ public:
if (Apprentice_Timer <= diff)
{
- if (me->IsNonMeleeSpellCasted(false))
+ if (me->IsNonMeleeSpellCast(false))
me->InterruptNonMeleeSpells(true);
DoCast(me, SPELL_ETHEREAL_APPRENTICE, true);
diff --git a/src/server/scripts/Outland/Auchindoun/ManaTombs/boss_pandemonius.cpp b/src/server/scripts/Outland/Auchindoun/ManaTombs/boss_pandemonius.cpp
index 9b959a7fdd8..e04ef216d92 100644
--- a/src/server/scripts/Outland/Auchindoun/ManaTombs/boss_pandemonius.cpp
+++ b/src/server/scripts/Outland/Auchindoun/ManaTombs/boss_pandemonius.cpp
@@ -106,7 +106,7 @@ public:
{
if (DarkShell_Timer <= diff)
{
- if (me->IsNonMeleeSpellCasted(false))
+ if (me->IsNonMeleeSpellCast(false))
me->InterruptNonMeleeSpells(true);
Talk(EMOTE_DARK_SHELL);
diff --git a/src/server/scripts/Outland/Auchindoun/SethekkHalls/boss_darkweaver_syth.cpp b/src/server/scripts/Outland/Auchindoun/SethekkHalls/boss_darkweaver_syth.cpp
index c077cec3c04..6adfdf7c885 100644
--- a/src/server/scripts/Outland/Auchindoun/SethekkHalls/boss_darkweaver_syth.cpp
+++ b/src/server/scripts/Outland/Auchindoun/SethekkHalls/boss_darkweaver_syth.cpp
@@ -115,7 +115,7 @@ public:
{
Talk(SAY_SUMMON);
- if (me->IsNonMeleeSpellCasted(false))
+ if (me->IsNonMeleeSpellCast(false))
me->InterruptNonMeleeSpells(false);
DoCast(me, SPELL_SUMMON_SYTH_ARCANE, true); //front
diff --git a/src/server/scripts/Outland/Auchindoun/SethekkHalls/boss_tailonking_ikiss.cpp b/src/server/scripts/Outland/Auchindoun/SethekkHalls/boss_tailonking_ikiss.cpp
index 022ac3e9e4d..217eb2ea004 100644
--- a/src/server/scripts/Outland/Auchindoun/SethekkHalls/boss_tailonking_ikiss.cpp
+++ b/src/server/scripts/Outland/Auchindoun/SethekkHalls/boss_tailonking_ikiss.cpp
@@ -167,7 +167,7 @@ public:
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
{
- if (me->IsNonMeleeSpellCasted(false))
+ if (me->IsNonMeleeSpellCast(false))
me->InterruptNonMeleeSpells(false);
//Spell doesn't work, but we use for visual effect at least
diff --git a/src/server/scripts/Outland/BlackTemple/black_temple.cpp b/src/server/scripts/Outland/BlackTemple/black_temple.cpp
index 57c494756e5..0f13a03f568 100644
--- a/src/server/scripts/Outland/BlackTemple/black_temple.cpp
+++ b/src/server/scripts/Outland/BlackTemple/black_temple.cpp
@@ -207,7 +207,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_wrathbone_flayerAI(creature);
+ return GetInstanceAI<npc_wrathbone_flayerAI>(creature);
}
};
diff --git a/src/server/scripts/Outland/BlackTemple/boss_bloodboil.cpp b/src/server/scripts/Outland/BlackTemple/boss_bloodboil.cpp
index 3a33885144d..080960c27c3 100644
--- a/src/server/scripts/Outland/BlackTemple/boss_bloodboil.cpp
+++ b/src/server/scripts/Outland/BlackTemple/boss_bloodboil.cpp
@@ -64,7 +64,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_gurtogg_bloodboilAI(creature);
+ return GetInstanceAI<boss_gurtogg_bloodboilAI>(creature);
}
struct boss_gurtogg_bloodboilAI : public ScriptedAI
@@ -95,8 +95,7 @@ public:
void Reset() OVERRIDE
{
- if (instance)
- instance->SetBossState(DATA_GURTOGG_BLOODBOIL, NOT_STARTED);
+ instance->SetBossState(DATA_GURTOGG_BLOODBOIL, NOT_STARTED);
TargetGUID = 0;
@@ -123,8 +122,7 @@ public:
{
DoZoneInCombat();
Talk(SAY_AGGRO);
- if (instance)
- instance->SetBossState(DATA_GURTOGG_BLOODBOIL, IN_PROGRESS);
+ instance->SetBossState(DATA_GURTOGG_BLOODBOIL, IN_PROGRESS);
}
void KilledUnit(Unit* /*victim*/) OVERRIDE
@@ -134,8 +132,7 @@ public:
void JustDied(Unit* /*killer*/) OVERRIDE
{
- if (instance)
- instance->SetBossState(DATA_GURTOGG_BLOODBOIL, DONE);
+ instance->SetBossState(DATA_GURTOGG_BLOODBOIL, DONE);
Talk(SAY_DEATH);
}
diff --git a/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp b/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp
index c9ccbb79ad0..88a549e124b 100644
--- a/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp
+++ b/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp
@@ -541,9 +541,6 @@ public:
{
me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
- if (!instance)
- return;
-
instance->SetBossState(DATA_ILLIDAN_STORMRAGE, DONE);
for (uint8 i = DATA_GO_ILLIDAN_DOOR_R; i < DATA_GO_ILLIDAN_DOOR_L + 1; ++i)
@@ -974,7 +971,7 @@ public:
break;
}
- if (me->IsNonMeleeSpellCasted(false))
+ if (me->IsNonMeleeSpellCast(false))
return;
if (Phase == PHASE_NORMAL || Phase == PHASE_NORMAL_2 || (Phase == PHASE_NORMAL_MAIEV && !me->HasAura(SPELL_CAGED)))
@@ -1126,7 +1123,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_illidan_stormrageAI(creature);
+ return GetInstanceAI<boss_illidan_stormrageAI>(creature);
}
};
@@ -1368,37 +1365,27 @@ public:
void Reset() OVERRIDE
{
WalkCount = 0;
- if (instance)
- {
- instance->SetBossState(DATA_ILLIDAN_STORMRAGE, NOT_STARTED);
+ instance->SetBossState(DATA_ILLIDAN_STORMRAGE, NOT_STARTED);
- IllidanGUID = instance->GetData64(DATA_ILLIDAN_STORMRAGE);
- GateGUID = instance->GetData64(DATA_GO_ILLIDAN_GATE);
- DoorGUID[0] = instance->GetData64(DATA_GO_ILLIDAN_DOOR_R);
- DoorGUID[1] = instance->GetData64(DATA_GO_ILLIDAN_DOOR_L);
-
- if (JustCreated) // close all doors at create
- {
- instance->HandleGameObject(GateGUID, false);
+ IllidanGUID = instance->GetData64(DATA_ILLIDAN_STORMRAGE);
+ GateGUID = instance->GetData64(DATA_GO_ILLIDAN_GATE);
+ DoorGUID[0] = instance->GetData64(DATA_GO_ILLIDAN_DOOR_R);
+ DoorGUID[1] = instance->GetData64(DATA_GO_ILLIDAN_DOOR_L);
- for (uint8 i = 0; i < 2; ++i)
- instance->HandleGameObject(DoorGUID[i], false);
- }
- else // open all doors, raid wiped
- {
- instance->HandleGameObject(GateGUID, true);
- WalkCount = 1; // skip first wp
+ if (JustCreated) // close all doors at create
+ {
+ instance->HandleGameObject(GateGUID, false);
- for (uint8 i = 0; i < 2; ++i)
- instance->HandleGameObject(DoorGUID[i], true);
- }
+ for (uint8 i = 0; i < 2; ++i)
+ instance->HandleGameObject(DoorGUID[i], false);
}
- else
+ else // open all doors, raid wiped
{
- IllidanGUID = 0;
- GateGUID = 0;
- DoorGUID[0] = 0;
- DoorGUID[1] = 0;
+ instance->HandleGameObject(GateGUID, true);
+ WalkCount = 1; // skip first wp
+
+ for (uint8 i = 0; i < 2; ++i)
+ instance->HandleGameObject(DoorGUID[i], true);
}
ChannelGUID = 0;
@@ -1461,9 +1448,6 @@ public:
void BeginTalk()
{
- if (!instance)
- return;
-
instance->SetBossState(DATA_ILLIDAN_STORMRAGE, IN_PROGRESS);
for (uint8 i = 0; i < 2; ++i)
instance->HandleGameObject(DoorGUID[i], false);
@@ -1515,8 +1499,6 @@ public:
void EnterPhase(PhaseAkama NextPhase)
{
- if (!instance)
- return;
switch (NextPhase)
{
case PHASE_CHANNEL:
@@ -1634,8 +1616,7 @@ public:
me->InterruptNonMeleeSpells(true);
Spirit[0]->InterruptNonMeleeSpells(true);
Spirit[1]->InterruptNonMeleeSpells(true);
- if (instance)
- instance->HandleGameObject(GateGUID, true);
+ instance->HandleGameObject(GateGUID, true);
Timer = 2000;
break;
case 4:
@@ -1664,8 +1645,7 @@ public:
{
case 6:
for (uint8 i = 0; i < 2; ++i)
- if (instance)
- instance->HandleGameObject(DoorGUID[i], true);
+ instance->HandleGameObject(DoorGUID[i], true);
break;
case 8:
if (Phase == PHASE_WALK)
@@ -1794,14 +1774,13 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_akama_illidanAI(creature);
+ return GetInstanceAI<npc_akama_illidanAI>(creature);
}
};
void boss_illidan_stormrage::boss_illidan_stormrageAI::Reset()
{
- if (instance)
- instance->SetBossState(DATA_ILLIDAN_STORMRAGE, NOT_STARTED);
+ instance->SetBossState(DATA_ILLIDAN_STORMRAGE, NOT_STARTED);
if (Creature* akama = ObjectAccessor::GetCreature(*me, AkamaGUID))
{
@@ -2160,10 +2139,7 @@ public:
void Reset() OVERRIDE
{
- if (instance)
- IllidanGUID = instance->GetData64(DATA_ILLIDAN_STORMRAGE);
- else
- IllidanGUID = 0;
+ IllidanGUID = instance->GetData64(DATA_ILLIDAN_STORMRAGE);
CheckTimer = 5000;
DoCast(me, SPELL_SHADOWFIEND_PASSIVE, true);
@@ -2228,7 +2204,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_parasitic_shadowfiendAI(creature);
+ return GetInstanceAI<npc_parasitic_shadowfiendAI>(creature);
}
};
diff --git a/src/server/scripts/Outland/BlackTemple/boss_mother_shahraz.cpp b/src/server/scripts/Outland/BlackTemple/boss_mother_shahraz.cpp
index aafe5f365b2..f33c316d278 100644
--- a/src/server/scripts/Outland/BlackTemple/boss_mother_shahraz.cpp
+++ b/src/server/scripts/Outland/BlackTemple/boss_mother_shahraz.cpp
@@ -84,7 +84,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_shahrazAI(creature);
+ return GetInstanceAI<boss_shahrazAI>(creature);
}
struct boss_shahrazAI : public ScriptedAI
@@ -113,8 +113,7 @@ public:
void Reset() OVERRIDE
{
- if (instance)
- instance->SetBossState(DATA_MOTHER_SHAHRAZ, NOT_STARTED);
+ instance->SetBossState(DATA_MOTHER_SHAHRAZ, NOT_STARTED);
for (uint8 i = 0; i<3; ++i)
TargetGUID[i] = 0;
@@ -136,8 +135,7 @@ public:
void EnterCombat(Unit* /*who*/) OVERRIDE
{
- if (instance)
- instance->SetBossState(DATA_MOTHER_SHAHRAZ, IN_PROGRESS);
+ instance->SetBossState(DATA_MOTHER_SHAHRAZ, IN_PROGRESS);
DoZoneInCombat();
Talk(SAY_AGGRO);
@@ -150,8 +148,7 @@ public:
void JustDied(Unit* /*killer*/) OVERRIDE
{
- if (instance)
- instance->SetBossState(DATA_MOTHER_SHAHRAZ, DONE);
+ instance->SetBossState(DATA_MOTHER_SHAHRAZ, DONE);
Talk(SAY_DEATH);
}
diff --git a/src/server/scripts/Outland/BlackTemple/boss_reliquary_of_souls.cpp b/src/server/scripts/Outland/BlackTemple/boss_reliquary_of_souls.cpp
index ad913a45071..da238c3ec4e 100644
--- a/src/server/scripts/Outland/BlackTemple/boss_reliquary_of_souls.cpp
+++ b/src/server/scripts/Outland/BlackTemple/boss_reliquary_of_souls.cpp
@@ -134,7 +134,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_reliquary_of_soulsAI(creature);
+ return GetInstanceAI<boss_reliquary_of_soulsAI>(creature);
}
struct boss_reliquary_of_soulsAI : public ScriptedAI
@@ -158,8 +158,7 @@ public:
void Reset() OVERRIDE
{
- if (instance)
- instance->SetBossState(DATA_RELIQUARY_OF_SOULS, NOT_STARTED);
+ instance->SetBossState(DATA_RELIQUARY_OF_SOULS, NOT_STARTED);
if (EssenceGUID)
{
@@ -197,8 +196,7 @@ public:
{
me->AddThreat(who, 10000.0f);
DoZoneInCombat();
- if (instance)
- instance->SetBossState(DATA_RELIQUARY_OF_SOULS, IN_PROGRESS);
+ instance->SetBossState(DATA_RELIQUARY_OF_SOULS, IN_PROGRESS);
Phase = 1;
Counter = 0;
@@ -243,8 +241,7 @@ public:
void JustDied(Unit* /*killer*/) OVERRIDE
{
- if (instance)
- instance->SetBossState(DATA_RELIQUARY_OF_SOULS, DONE);
+ instance->SetBossState(DATA_RELIQUARY_OF_SOULS, DONE);
}
void UpdateAI(uint32 diff) OVERRIDE
diff --git a/src/server/scripts/Outland/BlackTemple/boss_shade_of_akama.cpp b/src/server/scripts/Outland/BlackTemple/boss_shade_of_akama.cpp
index 1a2a55e6d00..be3c5b35ea6 100644
--- a/src/server/scripts/Outland/BlackTemple/boss_shade_of_akama.cpp
+++ b/src/server/scripts/Outland/BlackTemple/boss_shade_of_akama.cpp
@@ -198,8 +198,7 @@ public:
void JustDied(Unit* /*killer*/) OVERRIDE
{
- if (instance)
- instance->SetBossState(DATA_SHADE_OF_AKAMA, DONE);
+ instance->SetBossState(DATA_SHADE_OF_AKAMA, DONE);
}
void EnterCombat(Unit* /*who*/) OVERRIDE { }
@@ -405,7 +404,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_shade_of_akamaAI(creature);
+ return GetInstanceAI<boss_shade_of_akamaAI>(creature);
}
};
@@ -475,16 +474,13 @@ public:
switch (eventId)
{
case EVENT_SHADE_START:
- if (instance)
- {
- instance->SetBossState(DATA_SHADE_OF_AKAMA, IN_PROGRESS);
- me->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
- me->RemoveAura(SPELL_STEALTH);
- me->SetWalk(true);
- me->GetMotionMaster()->MovePoint(0, AkamaWP[0].x, AkamaWP[0].y, AkamaWP[0].z, false);
- events.ScheduleEvent(EVENT_SHADE_CHANNEL, 10000);
- break;
- }
+ instance->SetBossState(DATA_SHADE_OF_AKAMA, IN_PROGRESS);
+ me->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
+ me->RemoveAura(SPELL_STEALTH);
+ me->SetWalk(true);
+ me->GetMotionMaster()->MovePoint(0, AkamaWP[0].x, AkamaWP[0].y, AkamaWP[0].z, false);
+ events.ScheduleEvent(EVENT_SHADE_CHANNEL, 10000);
+ break;
case EVENT_SHADE_CHANNEL:
me->AddUnitState(UNIT_STATE_ROOT);
me->SetFacingTo(3.118662f);
@@ -550,7 +546,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_akamaAI(creature);
+ return GetInstanceAI<npc_akamaAI>(creature);
}
};
@@ -622,7 +618,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_ashtongue_channelerAI(creature);
+ return GetInstanceAI<npc_ashtongue_channelerAI>(creature);
}
};
@@ -730,7 +726,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_creature_generator_akamaAI(creature);
+ return GetInstanceAI<npc_creature_generator_akamaAI>(creature);
}
};
@@ -748,6 +744,7 @@ public:
npc_ashtongue_sorcererAI(Creature* creature) : ScriptedAI(creature)
{
instance = creature->GetInstanceScript();
+ startedBanishing = false;
}
void Reset() OVERRIDE
@@ -851,7 +848,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_ashtongue_sorcererAI(creature);
+ return GetInstanceAI<npc_ashtongue_sorcererAI>(creature);
}
};
@@ -941,7 +938,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_ashtongue_defenderAI(creature);
+ return GetInstanceAI<npc_ashtongue_defenderAI>(creature);
}
};
@@ -1021,7 +1018,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_ashtongue_rogueAI(creature);
+ return GetInstanceAI<npc_ashtongue_rogueAI>(creature);
}
};
@@ -1101,7 +1098,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_ashtongue_elementalistAI(creature);
+ return GetInstanceAI<npc_ashtongue_elementalistAI>(creature);
}
};
@@ -1198,7 +1195,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_ashtongue_spiritbinderAI(creature);
+ return GetInstanceAI<npc_ashtongue_spiritbinderAI>(creature);
}
};
diff --git a/src/server/scripts/Outland/BlackTemple/boss_supremus.cpp b/src/server/scripts/Outland/BlackTemple/boss_supremus.cpp
index b62e7b35a3c..7c9d88e8db2 100644
--- a/src/server/scripts/Outland/BlackTemple/boss_supremus.cpp
+++ b/src/server/scripts/Outland/BlackTemple/boss_supremus.cpp
@@ -90,7 +90,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_supremusAI(creature);
+ return GetInstanceAI<boss_supremusAI>(creature);
}
struct boss_supremusAI : public ScriptedAI
@@ -107,11 +107,8 @@ public:
void Reset() OVERRIDE
{
- if (instance)
- {
- if (me->IsAlive())
- instance->SetBossState(DATA_SUPREMUS, NOT_STARTED);
- }
+ if (me->IsAlive())
+ instance->SetBossState(DATA_SUPREMUS, NOT_STARTED);
phase = 0;
@@ -121,8 +118,7 @@ public:
void EnterCombat(Unit* /*who*/) OVERRIDE
{
- if (instance)
- instance->SetBossState(DATA_SUPREMUS, IN_PROGRESS);
+ instance->SetBossState(DATA_SUPREMUS, IN_PROGRESS);
ChangePhase();
events.ScheduleEvent(EVENT_BERSERK, 900000, GCD_CAST);
@@ -158,8 +154,7 @@ public:
void JustDied(Unit* /*killer*/) OVERRIDE
{
- if (instance)
- instance->SetBossState(DATA_SUPREMUS, DONE);
+ instance->SetBossState(DATA_SUPREMUS, DONE);
summons.DespawnAll();
}
diff --git a/src/server/scripts/Outland/BlackTemple/boss_teron_gorefiend.cpp b/src/server/scripts/Outland/BlackTemple/boss_teron_gorefiend.cpp
index 7d445e23053..acdc6819ef6 100644
--- a/src/server/scripts/Outland/BlackTemple/boss_teron_gorefiend.cpp
+++ b/src/server/scripts/Outland/BlackTemple/boss_teron_gorefiend.cpp
@@ -217,7 +217,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_teron_gorefiendAI(creature);
+ return GetInstanceAI<boss_teron_gorefiendAI>(creature);
}
struct boss_teron_gorefiendAI : public ScriptedAI
@@ -246,8 +246,7 @@ public:
void Reset() OVERRIDE
{
- if (instance)
- instance->SetBossState(DATA_TERON_GOREFIEND, NOT_STARTED);
+ instance->SetBossState(DATA_TERON_GOREFIEND, NOT_STARTED);
IncinerateTimer = urand(20000, 31000);
SummonDoomBlossomTimer = 12000;
@@ -275,8 +274,7 @@ public:
{
if (me->IsWithinDistInMap(who, VISIBLE_RANGE) && me->IsWithinLOSInMap(who))
{
- if (instance)
- instance->SetBossState(DATA_TERON_GOREFIEND, IN_PROGRESS);
+ instance->SetBossState(DATA_TERON_GOREFIEND, IN_PROGRESS);
me->GetMotionMaster()->Clear(false);
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
@@ -297,8 +295,7 @@ public:
void JustDied(Unit* /*killer*/) OVERRIDE
{
- if (instance)
- instance->SetBossState(DATA_TERON_GOREFIEND, DONE);
+ instance->SetBossState(DATA_TERON_GOREFIEND, DONE);
Talk(SAY_DEATH);
}
diff --git a/src/server/scripts/Outland/BlackTemple/boss_warlord_najentus.cpp b/src/server/scripts/Outland/BlackTemple/boss_warlord_najentus.cpp
index 1f4a36afad6..882c334cb6e 100644
--- a/src/server/scripts/Outland/BlackTemple/boss_warlord_najentus.cpp
+++ b/src/server/scripts/Outland/BlackTemple/boss_warlord_najentus.cpp
@@ -78,7 +78,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_najentusAI(creature);
+ return GetInstanceAI<boss_najentusAI>(creature);
}
struct boss_najentusAI : public ScriptedAI
@@ -99,8 +99,7 @@ public:
SpineTargetGUID = 0;
- if (instance)
- instance->SetBossState(DATA_HIGH_WARLORD_NAJENTUS, NOT_STARTED);
+ instance->SetBossState(DATA_HIGH_WARLORD_NAJENTUS, NOT_STARTED);
}
void KilledUnit(Unit* /*victim*/) OVERRIDE
@@ -111,8 +110,7 @@ public:
void JustDied(Unit* /*killer*/) OVERRIDE
{
- if (instance)
- instance->SetBossState(DATA_HIGH_WARLORD_NAJENTUS, DONE);
+ instance->SetBossState(DATA_HIGH_WARLORD_NAJENTUS, DONE);
Talk(SAY_DEATH);
}
@@ -129,8 +127,7 @@ public:
void EnterCombat(Unit* /*who*/) OVERRIDE
{
- if (instance)
- instance->SetBossState(DATA_HIGH_WARLORD_NAJENTUS, IN_PROGRESS);
+ instance->SetBossState(DATA_HIGH_WARLORD_NAJENTUS, IN_PROGRESS);
Talk(SAY_AGGRO);
DoZoneInCombat();
diff --git a/src/server/scripts/Outland/BlackTemple/illidari_council.cpp b/src/server/scripts/Outland/BlackTemple/illidari_council.cpp
index 057bb725c32..bb77e10d727 100644
--- a/src/server/scripts/Outland/BlackTemple/illidari_council.cpp
+++ b/src/server/scripts/Outland/BlackTemple/illidari_council.cpp
@@ -218,7 +218,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_illidari_councilAI(creature);
+ return GetInstanceAI<npc_illidari_councilAI>(creature);
}
struct npc_illidari_councilAI : public ScriptedAI
@@ -263,12 +263,9 @@ public:
pMember->AI()->EnterEvadeMode();
}
- if (instance)
- {
- instance->SetBossState(DATA_ILLIDARI_COUNCIL, NOT_STARTED);
- if (Creature* VoiceTrigger = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_BLOOD_ELF_COUNCIL_VOICE)))
- VoiceTrigger->AI()->EnterEvadeMode();
- }
+ instance->SetBossState(DATA_ILLIDARI_COUNCIL, NOT_STARTED);
+ if (Creature* VoiceTrigger = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_BLOOD_ELF_COUNCIL_VOICE)))
+ VoiceTrigger->AI()->EnterEvadeMode();
EventBegun = false;
@@ -284,9 +281,6 @@ public:
void StartEvent(Unit* target)
{
- if (!instance)
- return;
-
if (target && target->IsAlive())
{
Council[0] = instance->GetData64(DATA_GATHIOS_THE_SHATTERER);
@@ -328,13 +322,10 @@ public:
{
if (DeathCount > 3)
{
- if (instance)
- {
- if (Creature* VoiceTrigger = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_BLOOD_ELF_COUNCIL_VOICE)))
- VoiceTrigger->DealDamage(VoiceTrigger, VoiceTrigger->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
- instance->SetBossState(DATA_ILLIDARI_COUNCIL, DONE);
- //me->SummonCreature(AKAMAID, 746.466980f, 304.394989f, 311.90208f, 6.272870f, TEMPSUMMON_DEAD_DESPAWN, 0);
- }
+ if (Creature* VoiceTrigger = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_BLOOD_ELF_COUNCIL_VOICE)))
+ VoiceTrigger->DealDamage(VoiceTrigger, VoiceTrigger->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
+ instance->SetBossState(DATA_ILLIDARI_COUNCIL, DONE);
+ //me->SummonCreature(AKAMAID, 746.466980f, 304.394989f, 311.90208f, 6.272870f, TEMPSUMMON_DEAD_DESPAWN, 0);
me->DealDamage(me, me->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
return;
}
@@ -401,17 +392,8 @@ struct boss_illidari_councilAI : public ScriptedAI
void EnterCombat(Unit* who) OVERRIDE
{
- if (instance)
- {
- if (Creature* controller = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_ILLIDARI_COUNCIL)))
- CAST_AI(npc_illidari_council::npc_illidari_councilAI, controller->AI())->StartEvent(who);
- }
- else
- {
- TC_LOG_ERROR("scripts", ERROR_INST_DATA);
- EnterEvadeMode();
- return;
- }
+ if (Creature* controller = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_ILLIDARI_COUNCIL)))
+ CAST_AI(npc_illidari_council::npc_illidari_councilAI, controller->AI())->StartEvent(who);
DoZoneInCombat();
// Load GUIDs on first aggro because the Creature guids are only set as the creatures are created in world-
// this means that for each creature, it will attempt to LoadGUIDs even though some of the other creatures are
@@ -454,12 +436,6 @@ struct boss_illidari_councilAI : public ScriptedAI
void LoadGUIDs()
{
- if (!instance)
- {
- TC_LOG_ERROR("scripts", ERROR_INST_DATA);
- return;
- }
-
Council[0] = instance->GetData64(DATA_LADY_MALANDE);
Council[1] = instance->GetData64(DATA_HIGH_NETHERMANCER_ZEREVOR);
Council[2] = instance->GetData64(DATA_GATHIOS_THE_SHATTERER);
@@ -476,7 +452,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_gathios_the_shattererAI(creature);
+ return GetInstanceAI<boss_gathios_the_shattererAI>(creature);
}
struct boss_gathios_the_shattererAI : public boss_illidari_councilAI
@@ -608,7 +584,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_high_nethermancer_zerevorAI(creature);
+ return GetInstanceAI<boss_high_nethermancer_zerevorAI>(creature);
}
struct boss_high_nethermancer_zerevorAI : public boss_illidari_councilAI
@@ -712,7 +688,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_lady_malandeAI(creature);
+ return GetInstanceAI<boss_lady_malandeAI>(creature);
}
struct boss_lady_malandeAI : public boss_illidari_councilAI
@@ -790,7 +766,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_veras_darkshadowAI(creature);
+ return GetInstanceAI<boss_veras_darkshadowAI>(creature);
}
struct boss_veras_darkshadowAI : public boss_illidari_councilAI
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 6ccf69ae39b..1552c4ffe46 100644
--- a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_fathomlord_karathress.cpp
+++ b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_fathomlord_karathress.cpp
@@ -104,7 +104,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_fathomlord_karathressAI(creature);
+ return GetInstanceAI<boss_fathomlord_karathressAI>(creature);
}
struct boss_fathomlord_karathressAI : public ScriptedAI
@@ -135,27 +135,24 @@ public:
BlessingOfTides = false;
- if (instance)
- {
- uint64 RAdvisors[MAX_ADVISORS];
- RAdvisors[0] = instance->GetData64(DATA_SHARKKIS);
- RAdvisors[1] = instance->GetData64(DATA_TIDALVESS);
- RAdvisors[2] = instance->GetData64(DATA_CARIBDIS);
- //Respawn of the 3 Advisors
- Creature* pAdvisor = NULL;
- for (int i=0; i<MAX_ADVISORS; ++i)
- if (RAdvisors[i])
+ uint64 RAdvisors[MAX_ADVISORS];
+ RAdvisors[0] = instance->GetData64(DATA_SHARKKIS);
+ RAdvisors[1] = instance->GetData64(DATA_TIDALVESS);
+ RAdvisors[2] = instance->GetData64(DATA_CARIBDIS);
+ //Respawn of the 3 Advisors
+ Creature* pAdvisor = NULL;
+ for (int i=0; i<MAX_ADVISORS; ++i)
+ if (RAdvisors[i])
+ {
+ pAdvisor = (Unit::GetCreature((*me), RAdvisors[i]));
+ if (pAdvisor && !pAdvisor->IsAlive())
{
- pAdvisor = (Unit::GetCreature((*me), RAdvisors[i]));
- if (pAdvisor && !pAdvisor->IsAlive())
- {
- pAdvisor->Respawn();
- pAdvisor->AI()->EnterEvadeMode();
- pAdvisor->GetMotionMaster()->MoveTargetedHome();
- }
+ pAdvisor->Respawn();
+ pAdvisor->AI()->EnterEvadeMode();
+ pAdvisor->GetMotionMaster()->MoveTargetedHome();
}
- instance->SetData(DATA_KARATHRESSEVENT, NOT_STARTED);
- }
+ }
+ instance->SetData(DATA_KARATHRESSEVENT, NOT_STARTED);
}
@@ -179,9 +176,6 @@ public:
void GetAdvisors()
{
- if (!instance)
- return;
-
Advisors[0] = instance->GetData64(DATA_SHARKKIS);
Advisors[1] = instance->GetData64(DATA_TIDALVESS);
Advisors[2] = instance->GetData64(DATA_CARIBDIS);
@@ -189,9 +183,6 @@ public:
void StartEvent(Unit* who)
{
- if (!instance)
- return;
-
GetAdvisors();
Talk(SAY_AGGRO);
@@ -210,8 +201,7 @@ public:
{
Talk(SAY_DEATH);
- if (instance)
- instance->SetData(DATA_FATHOMLORDKARATHRESSEVENT, DONE);
+ instance->SetData(DATA_FATHOMLORDKARATHRESSEVENT, DONE);
//support for quest 10944
me->SummonCreature(SEER_OLUM, OLUM_X, OLUM_Y, OLUM_Z, OLUM_O, TEMPSUMMON_TIMED_DESPAWN, 3600000);
@@ -312,7 +302,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_fathomguard_sharkkisAI(creature);
+ return GetInstanceAI<boss_fathomguard_sharkkisAI>(creature);
}
struct boss_fathomguard_sharkkisAI : public ScriptedAI
@@ -320,6 +310,7 @@ public:
boss_fathomguard_sharkkisAI(Creature* creature) : ScriptedAI(creature)
{
instance = creature->GetInstanceScript();
+ SummonedPet = 0;
}
InstanceScript* instance;
@@ -350,26 +341,19 @@ public:
SummonedPet = 0;
- if (instance)
- instance->SetData(DATA_KARATHRESSEVENT, NOT_STARTED);
+ instance->SetData(DATA_KARATHRESSEVENT, NOT_STARTED);
}
void JustDied(Unit* /*killer*/) OVERRIDE
{
- if (instance)
- {
- if (Creature* Karathress = (Unit::GetCreature((*me), instance->GetData64(DATA_KARATHRESS))))
- CAST_AI(boss_fathomlord_karathress::boss_fathomlord_karathressAI, Karathress->AI())->EventSharkkisDeath();
- }
+ if (Creature* Karathress = (Unit::GetCreature((*me), instance->GetData64(DATA_KARATHRESS))))
+ CAST_AI(boss_fathomlord_karathress::boss_fathomlord_karathressAI, Karathress->AI())->EventSharkkisDeath();
}
void EnterCombat(Unit* who) OVERRIDE
{
- if (instance)
- {
- instance->SetData64(DATA_KARATHRESSEVENT_STARTER, who->GetGUID());
- instance->SetData(DATA_KARATHRESSEVENT, IN_PROGRESS);
- }
+ instance->SetData64(DATA_KARATHRESSEVENT_STARTER, who->GetGUID());
+ instance->SetData(DATA_KARATHRESSEVENT, IN_PROGRESS);
}
void UpdateAI(uint32 diff) OVERRIDE
@@ -459,7 +443,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_fathomguard_tidalvessAI(creature);
+ return GetInstanceAI<boss_fathomguard_tidalvessAI>(creature);
}
struct boss_fathomguard_tidalvessAI : public ScriptedAI
@@ -483,26 +467,19 @@ public:
PoisonCleansing_Timer = 30000;
Earthbind_Timer = 45000;
- if (instance)
- instance->SetData(DATA_KARATHRESSEVENT, NOT_STARTED);
+ instance->SetData(DATA_KARATHRESSEVENT, NOT_STARTED);
}
void JustDied(Unit* /*killer*/) OVERRIDE
{
- if (instance)
- {
- if (Creature* Karathress = Unit::GetCreature((*me), instance->GetData64(DATA_KARATHRESS)))
- CAST_AI(boss_fathomlord_karathress::boss_fathomlord_karathressAI, Karathress->AI())->EventTidalvessDeath();
- }
+ if (Creature* Karathress = Unit::GetCreature((*me), instance->GetData64(DATA_KARATHRESS)))
+ CAST_AI(boss_fathomlord_karathress::boss_fathomlord_karathressAI, Karathress->AI())->EventTidalvessDeath();
}
void EnterCombat(Unit* who) OVERRIDE
{
- if (instance)
- {
- instance->SetData64(DATA_KARATHRESSEVENT_STARTER, who->GetGUID());
- instance->SetData(DATA_KARATHRESSEVENT, IN_PROGRESS);
- }
+ instance->SetData64(DATA_KARATHRESSEVENT_STARTER, who->GetGUID());
+ instance->SetData(DATA_KARATHRESSEVENT, IN_PROGRESS);
DoCast(me, SPELL_WINDFURY_WEAPON);
}
@@ -582,7 +559,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_fathomguard_caribdisAI(creature);
+ return GetInstanceAI<boss_fathomguard_caribdisAI>(creature);
}
struct boss_fathomguard_caribdisAI : public ScriptedAI
@@ -606,26 +583,19 @@ public:
Heal_Timer = 55000;
Cyclone_Timer = 30000+rand()%10000;
- if (instance)
- instance->SetData(DATA_KARATHRESSEVENT, NOT_STARTED);
+ instance->SetData(DATA_KARATHRESSEVENT, NOT_STARTED);
}
void JustDied(Unit* /*killer*/) OVERRIDE
{
- if (instance)
- {
- if (Creature* Karathress = Unit::GetCreature((*me), instance->GetData64(DATA_KARATHRESS)))
- CAST_AI(boss_fathomlord_karathress::boss_fathomlord_karathressAI, Karathress->AI())->EventCaribdisDeath();
- }
+ if (Creature* Karathress = Unit::GetCreature((*me), instance->GetData64(DATA_KARATHRESS)))
+ CAST_AI(boss_fathomlord_karathress::boss_fathomlord_karathressAI, Karathress->AI())->EventCaribdisDeath();
}
void EnterCombat(Unit* who) OVERRIDE
{
- if (instance)
- {
- instance->SetData64(DATA_KARATHRESSEVENT_STARTER, who->GetGUID());
- instance->SetData(DATA_KARATHRESSEVENT, IN_PROGRESS);
- }
+ instance->SetData64(DATA_KARATHRESSEVENT_STARTER, who->GetGUID());
+ instance->SetData(DATA_KARATHRESSEVENT, IN_PROGRESS);
}
void UpdateAI(uint32 diff) OVERRIDE
@@ -705,24 +675,21 @@ public:
Unit* selectAdvisorUnit()
{
Unit* unit = NULL;
- if (instance)
- {
- switch (rand()%4)
- {
- case 0:
- unit = Unit::GetUnit(*me, instance->GetData64(DATA_KARATHRESS));
- break;
- case 1:
- unit = Unit::GetUnit(*me, instance->GetData64(DATA_SHARKKIS));
- break;
- case 2:
- unit = Unit::GetUnit(*me, instance->GetData64(DATA_TIDALVESS));
- break;
- case 3:
- unit = me;
- break;
- }
- } else unit = me;
+ switch (rand()%4)
+ {
+ case 0:
+ unit = Unit::GetUnit(*me, instance->GetData64(DATA_KARATHRESS));
+ break;
+ case 1:
+ unit = Unit::GetUnit(*me, instance->GetData64(DATA_SHARKKIS));
+ break;
+ case 2:
+ unit = Unit::GetUnit(*me, instance->GetData64(DATA_TIDALVESS));
+ break;
+ case 3:
+ unit = me;
+ break;
+ }
return unit;
}
};
diff --git a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_hydross_the_unstable.cpp b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_hydross_the_unstable.cpp
index d6205cb3ec7..e3b9006527c 100644
--- a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_hydross_the_unstable.cpp
+++ b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_hydross_the_unstable.cpp
@@ -86,7 +86,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_hydross_the_unstableAI(creature);
+ return GetInstanceAI<boss_hydross_the_unstableAI>(creature);
}
struct boss_hydross_the_unstableAI : public ScriptedAI
@@ -134,8 +134,7 @@ public:
me->SetDisplayId(MODEL_CLEAN);
- if (instance)
- instance->SetData(DATA_HYDROSSTHEUNSTABLEEVENT, NOT_STARTED);
+ instance->SetData(DATA_HYDROSSTHEUNSTABLEEVENT, NOT_STARTED);
beam = false;
Summons.DespawnAll();
}
@@ -174,8 +173,7 @@ public:
{
Talk(SAY_AGGRO);
- if (instance)
- instance->SetData(DATA_HYDROSSTHEUNSTABLEEVENT, IN_PROGRESS);
+ instance->SetData(DATA_HYDROSSTHEUNSTABLEEVENT, IN_PROGRESS);
}
void KilledUnit(Unit* /*victim*/) OVERRIDE
@@ -208,8 +206,7 @@ public:
{
Talk(CorruptedForm ? SAY_CORRUPT_DEATH : SAY_CLEAN_DEATH);
- if (instance)
- instance->SetData(DATA_HYDROSSTHEUNSTABLEEVENT, DONE);
+ instance->SetData(DATA_HYDROSSTHEUNSTABLEEVENT, DONE);
Summons.DespawnAll();
}
diff --git a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lady_vashj.cpp b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lady_vashj.cpp
index 1d233aa6da4..f13c64235c4 100644
--- a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lady_vashj.cpp
+++ b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lady_vashj.cpp
@@ -140,7 +140,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_lady_vashjAI(creature);
+ return GetInstanceAI<boss_lady_vashjAI>(creature);
}
struct boss_lady_vashjAI : public ScriptedAI
@@ -215,8 +215,7 @@ public:
}
}
- if (instance)
- instance->SetData(DATA_LADYVASHJEVENT, NOT_STARTED);
+ instance->SetData(DATA_LADYVASHJEVENT, NOT_STARTED);
me->SetCorpseDelay(1000*60*60);
}
@@ -237,8 +236,7 @@ public:
{
Talk(SAY_DEATH);
- if (instance)
- instance->SetData(DATA_LADYVASHJEVENT, DONE);
+ instance->SetData(DATA_LADYVASHJEVENT, DONE);
}
void StartEvent()
@@ -247,21 +245,17 @@ public:
Phase = 1;
- if (instance)
- instance->SetData(DATA_LADYVASHJEVENT, IN_PROGRESS);
+ instance->SetData(DATA_LADYVASHJEVENT, IN_PROGRESS);
}
void EnterCombat(Unit* who) OVERRIDE
{
- if (instance)
- {
- // remove old tainted cores to prevent cheating in phase 2
- Map* map = me->GetMap();
- Map::PlayerList const &PlayerList = map->GetPlayers();
- for (Map::PlayerList::const_iterator itr = PlayerList.begin(); itr != PlayerList.end(); ++itr)
- if (Player* player = itr->GetSource())
- player->DestroyItemCount(31088, 1, true);
- }
+ // remove old tainted cores to prevent cheating in phase 2
+ Map* map = me->GetMap();
+ Map::PlayerList const &PlayerList = map->GetPlayers();
+ for (Map::PlayerList::const_iterator itr = PlayerList.begin(); itr != PlayerList.end(); ++itr)
+ if (Player* player = itr->GetSource())
+ player->DestroyItemCount(31088, 1, true);
StartEvent(); // this is EnterCombat(), so were are 100% in combat, start the event
if (Phase != 2)
@@ -556,7 +550,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_enchanted_elementalAI(creature);
+ return GetInstanceAI<npc_enchanted_elementalAI>(creature);
}
struct npc_enchanted_elementalAI : public ScriptedAI
@@ -580,8 +574,6 @@ public:
Move = 0;
Phase = 1;
- VashjGUID = 0;
-
X = ElementWPPos[0][0];
Y = ElementWPPos[0][1];
Z = ElementWPPos[0][2];
@@ -597,8 +589,7 @@ public:
}
}
- if (instance)
- VashjGUID = instance->GetData64(DATA_LADYVASHJ);
+ VashjGUID = instance->GetData64(DATA_LADYVASHJ);
}
void EnterCombat(Unit* /*who*/) OVERRIDE { }
@@ -608,9 +599,6 @@ public:
void UpdateAI(uint32 diff) OVERRIDE
{
- if (!instance)
- return;
-
if (!VashjGUID)
return;
@@ -651,7 +639,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_tainted_elementalAI(creature);
+ return GetInstanceAI<npc_tainted_elementalAI>(creature);
}
struct npc_tainted_elementalAI : public ScriptedAI
@@ -674,9 +662,8 @@ public:
void JustDied(Unit* /*killer*/) OVERRIDE
{
- if (instance)
- if (Creature* vashj = Unit::GetCreature((*me), instance->GetData64(DATA_LADYVASHJ)))
- CAST_AI(boss_lady_vashj::boss_lady_vashjAI, vashj->AI())->EventTaintedElementalDeath();
+ if (Creature* vashj = Unit::GetCreature((*me), instance->GetData64(DATA_LADYVASHJ)))
+ CAST_AI(boss_lady_vashj::boss_lady_vashjAI, vashj->AI())->EventTaintedElementalDeath();
}
void EnterCombat(Unit* who) OVERRIDE
@@ -720,7 +707,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_toxic_sporebatAI(creature);
+ return GetInstanceAI<npc_toxic_sporebatAI>(creature);
}
struct npc_toxic_sporebatAI : public ScriptedAI
@@ -790,17 +777,14 @@ public:
// CheckTimer
if (CheckTimer <= diff)
{
- if (instance)
+ // check if vashj is death
+ Unit* Vashj = Unit::GetUnit(*me, instance->GetData64(DATA_LADYVASHJ));
+ if (!Vashj || !Vashj->IsAlive() || CAST_AI(boss_lady_vashj::boss_lady_vashjAI, Vashj->ToCreature()->AI())->Phase != 3)
{
- // check if vashj is death
- Unit* Vashj = Unit::GetUnit(*me, instance->GetData64(DATA_LADYVASHJ));
- if (!Vashj || !Vashj->IsAlive() || CAST_AI(boss_lady_vashj::boss_lady_vashjAI, Vashj->ToCreature()->AI())->Phase != 3)
- {
- // remove
- me->setDeathState(DEAD);
- me->RemoveCorpse();
- me->setFaction(35);
- }
+ // remove
+ me->setDeathState(DEAD);
+ me->RemoveCorpse();
+ me->setFaction(35);
}
CheckTimer = 1000;
@@ -819,7 +803,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_shield_generator_channelAI(creature);
+ return GetInstanceAI<npc_shield_generator_channelAI>(creature);
}
struct npc_shield_generator_channelAI : public ScriptedAI
@@ -831,12 +815,12 @@ public:
InstanceScript* instance;
uint32 CheckTimer;
- bool Casted;
+ bool Cast;
void Reset() OVERRIDE
{
CheckTimer = 0;
- Casted = false;
+ Cast = false;
me->SetDisplayId(11686); // invisible
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
@@ -847,9 +831,6 @@ public:
void UpdateAI(uint32 diff) OVERRIDE
{
- if (!instance)
- return;
-
if (CheckTimer <= diff)
{
Unit* vashj = Unit::GetUnit(*me, instance->GetData64(DATA_LADYVASHJ));
@@ -857,10 +838,10 @@ public:
if (vashj && vashj->IsAlive())
{
// start visual channel
- if (!Casted || !vashj->HasAura(SPELL_MAGIC_BARRIER))
+ if (!Cast || !vashj->HasAura(SPELL_MAGIC_BARRIER))
{
DoCast(vashj, SPELL_MAGIC_BARRIER, true);
- Casted = true;
+ Cast = true;
}
}
CheckTimer = 1000;
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 83ec5e053c0..069b4a45933 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
@@ -181,7 +181,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_leotheras_the_blindAI(creature);
+ return GetInstanceAI<boss_leotheras_the_blindAI>(creature);
}
struct boss_leotheras_the_blindAI : public ScriptedAI
@@ -242,8 +242,7 @@ public:
me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID+1, 0);
DoCast(me, SPELL_DUAL_WIELD, true);
me->SetCorpseDelay(1000*60*60);
- if (instance)
- instance->SetData(DATA_LEOTHERASTHEBLINDEVENT, NOT_STARTED);
+ instance->SetData(DATA_LEOTHERASTHEBLINDEVENT, NOT_STARTED);
}
void CheckChannelers(/*bool DoEvade = true*/)
@@ -290,8 +289,7 @@ public:
void StartEvent()
{
Talk(SAY_AGGRO);
- if (instance)
- instance->SetData(DATA_LEOTHERASTHEBLINDEVENT, IN_PROGRESS);
+ instance->SetData(DATA_LEOTHERASTHEBLINDEVENT, IN_PROGRESS);
}
void CheckBanish()
@@ -402,8 +400,7 @@ public:
if (Creature* pDemon = Unit::GetCreature(*me, Demon))
pDemon->DespawnOrUnsummon();
}
- if (instance)
- instance->SetData(DATA_LEOTHERASTHEBLINDEVENT, DONE);
+ instance->SetData(DATA_LEOTHERASTHEBLINDEVENT, DONE);
}
void EnterCombat(Unit* /*who*/) OVERRIDE
@@ -677,7 +674,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_greyheart_spellbinderAI(creature);
+ return GetInstanceAI<npc_greyheart_spellbinderAI>(creature);
}
struct npc_greyheart_spellbinderAI : public ScriptedAI
@@ -703,20 +700,16 @@ public:
Mindblast_Timer = urand(3000, 8000);
Earthshock_Timer = urand(5000, 10000);
- if (instance)
- {
- instance->SetData64(DATA_LEOTHERAS_EVENT_STARTER, 0);
- Creature* leotheras = Unit::GetCreature(*me, leotherasGUID);
- if (leotheras && leotheras->IsAlive())
- CAST_AI(boss_leotheras_the_blind::boss_leotheras_the_blindAI, leotheras->AI())->CheckChannelers(/*false*/);
- }
+ instance->SetData64(DATA_LEOTHERAS_EVENT_STARTER, 0);
+ Creature* leotheras = Unit::GetCreature(*me, leotherasGUID);
+ if (leotheras && leotheras->IsAlive())
+ CAST_AI(boss_leotheras_the_blind::boss_leotheras_the_blindAI, leotheras->AI())->CheckChannelers(/*false*/);
}
void EnterCombat(Unit* who) OVERRIDE
{
me->InterruptNonMeleeSpells(false);
- if (instance)
- instance->SetData64(DATA_LEOTHERAS_EVENT_STARTER, who->GetGUID());
+ instance->SetData64(DATA_LEOTHERAS_EVENT_STARTER, who->GetGUID());
}
void JustRespawned() OVERRIDE
@@ -740,18 +733,15 @@ public:
void UpdateAI(uint32 diff) OVERRIDE
{
- if (instance)
- {
- if (!leotherasGUID)
- leotherasGUID = instance->GetData64(DATA_LEOTHERAS);
+ if (!leotherasGUID)
+ leotherasGUID = instance->GetData64(DATA_LEOTHERAS);
- if (!me->IsInCombat() && instance->GetData64(DATA_LEOTHERAS_EVENT_STARTER))
- {
- Unit* victim = NULL;
- victim = Unit::GetUnit(*me, instance->GetData64(DATA_LEOTHERAS_EVENT_STARTER));
- if (victim)
- AttackStart(victim);
- }
+ if (!me->IsInCombat() && instance->GetData64(DATA_LEOTHERAS_EVENT_STARTER))
+ {
+ Unit* victim = NULL;
+ victim = Unit::GetUnit(*me, instance->GetData64(DATA_LEOTHERAS_EVENT_STARTER));
+ if (victim)
+ AttackStart(victim);
}
if (!UpdateVictim())
diff --git a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lurker_below.cpp b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lurker_below.cpp
index c4a55065f27..8ea9337537a 100644
--- a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lurker_below.cpp
+++ b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lurker_below.cpp
@@ -81,7 +81,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_the_lurker_belowAI(creature);
+ return GetInstanceAI<boss_the_lurker_belowAI>(creature);
}
struct boss_the_lurker_belowAI : public ScriptedAI
@@ -138,11 +138,8 @@ public:
Summons.DespawnAll();
- if (instance)
- {
- instance->SetData(DATA_THELURKERBELOWEVENT, NOT_STARTED);
- instance->SetData(DATA_STRANGE_POOL, NOT_STARTED);
- }
+ instance->SetData(DATA_THELURKERBELOWEVENT, NOT_STARTED);
+ instance->SetData(DATA_STRANGE_POOL, NOT_STARTED);
DoCast(me, SPELL_SUBMERGE); // submerge anim
me->SetVisible(false); // we start invis under water, submerged
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
@@ -151,19 +148,15 @@ public:
void JustDied(Unit* /*killer*/) OVERRIDE
{
- if (instance)
- {
- instance->SetData(DATA_THELURKERBELOWEVENT, DONE);
- instance->SetData(DATA_STRANGE_POOL, IN_PROGRESS);
- }
+ instance->SetData(DATA_THELURKERBELOWEVENT, DONE);
+ instance->SetData(DATA_STRANGE_POOL, IN_PROGRESS);
Summons.DespawnAll();
}
void EnterCombat(Unit* /*who*/) OVERRIDE
{
- if (instance)
- instance->SetData(DATA_THELURKERBELOWEVENT, IN_PROGRESS);
+ instance->SetData(DATA_THELURKERBELOWEVENT, IN_PROGRESS);
}
void MoveInLineOfSight(Unit* who) OVERRIDE
diff --git a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_morogrim_tidewalker.cpp b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_morogrim_tidewalker.cpp
index 48a4a1e5ecd..1a0b06d25dc 100644
--- a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_morogrim_tidewalker.cpp
+++ b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_morogrim_tidewalker.cpp
@@ -91,7 +91,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_morogrim_tidewalkerAI(creature);
+ return GetInstanceAI<boss_morogrim_tidewalkerAI>(creature);
}
struct boss_morogrim_tidewalkerAI : public ScriptedAI
@@ -130,16 +130,14 @@ public:
Earthquake = false;
Phase2 = false;
- if (instance)
- instance->SetData(DATA_MOROGRIMTIDEWALKEREVENT, NOT_STARTED);
+ instance->SetData(DATA_MOROGRIMTIDEWALKEREVENT, NOT_STARTED);
}
void StartEvent()
{
Talk(SAY_AGGRO);
- if (instance)
- instance->SetData(DATA_MOROGRIMTIDEWALKEREVENT, IN_PROGRESS);
+ instance->SetData(DATA_MOROGRIMTIDEWALKEREVENT, IN_PROGRESS);
}
void KilledUnit(Unit* /*victim*/) OVERRIDE
@@ -151,8 +149,7 @@ public:
{
Talk(SAY_DEATH);
- if (instance)
- instance->SetData(DATA_MOROGRIMTIDEWALKEREVENT, DONE);
+ instance->SetData(DATA_MOROGRIMTIDEWALKEREVENT, DONE);
}
void EnterCombat(Unit* /*who*/) OVERRIDE
diff --git a/src/server/scripts/Outland/CoilfangReservoir/SteamVault/boss_hydromancer_thespia.cpp b/src/server/scripts/Outland/CoilfangReservoir/SteamVault/boss_hydromancer_thespia.cpp
index d6162fd1ea4..0dd83a1adf6 100644
--- a/src/server/scripts/Outland/CoilfangReservoir/SteamVault/boss_hydromancer_thespia.cpp
+++ b/src/server/scripts/Outland/CoilfangReservoir/SteamVault/boss_hydromancer_thespia.cpp
@@ -41,7 +41,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_thespiaAI(creature);
+ return GetInstanceAI<boss_thespiaAI>(creature);
}
struct boss_thespiaAI : public ScriptedAI
@@ -63,16 +63,14 @@ public:
LungBurst_Timer = 7000;
EnvelopingWinds_Timer = 9000;
- if (instance)
- instance->SetBossState(DATA_HYDROMANCER_THESPIA, NOT_STARTED);
+ instance->SetBossState(DATA_HYDROMANCER_THESPIA, NOT_STARTED);
}
void JustDied(Unit* /*killer*/) OVERRIDE
{
Talk(SAY_DEAD);
- if (instance)
- instance->SetBossState(DATA_HYDROMANCER_THESPIA, DONE);
+ instance->SetBossState(DATA_HYDROMANCER_THESPIA, DONE);
}
void KilledUnit(Unit* /*victim*/) OVERRIDE
@@ -84,8 +82,7 @@ public:
{
Talk(SAY_AGGRO);
- if (instance)
- instance->SetBossState(DATA_HYDROMANCER_THESPIA, IN_PROGRESS);
+ instance->SetBossState(DATA_HYDROMANCER_THESPIA, IN_PROGRESS);
}
void UpdateAI(uint32 diff) OVERRIDE
diff --git a/src/server/scripts/Outland/CoilfangReservoir/SteamVault/boss_mekgineer_steamrigger.cpp b/src/server/scripts/Outland/CoilfangReservoir/SteamVault/boss_mekgineer_steamrigger.cpp
index 241d0f8fec2..2cc3d45ccff 100644
--- a/src/server/scripts/Outland/CoilfangReservoir/SteamVault/boss_mekgineer_steamrigger.cpp
+++ b/src/server/scripts/Outland/CoilfangReservoir/SteamVault/boss_mekgineer_steamrigger.cpp
@@ -57,7 +57,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_mekgineer_steamriggerAI(creature);
+ return GetInstanceAI<boss_mekgineer_steamriggerAI>(creature);
}
struct boss_mekgineer_steamriggerAI : public ScriptedAI
@@ -86,16 +86,14 @@ public:
Summon50 = false;
Summon25 = false;
- if (instance)
- instance->SetBossState(DATA_MEKGINEER_STEAMRIGGER, NOT_STARTED);
+ instance->SetBossState(DATA_MEKGINEER_STEAMRIGGER, NOT_STARTED);
}
void JustDied(Unit* /*killer*/) OVERRIDE
{
Talk(SAY_DEATH);
- if (instance)
- instance->SetBossState(DATA_MEKGINEER_STEAMRIGGER, DONE);
+ instance->SetBossState(DATA_MEKGINEER_STEAMRIGGER, DONE);
}
void KilledUnit(Unit* /*victim*/) OVERRIDE
@@ -107,8 +105,7 @@ public:
{
Talk(SAY_AGGRO);
- if (instance)
- instance->SetBossState(DATA_MEKGINEER_STEAMRIGGER, IN_PROGRESS);
+ instance->SetBossState(DATA_MEKGINEER_STEAMRIGGER, IN_PROGRESS);
}
//no known summon spells exist
@@ -197,7 +194,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_steamrigger_mechanicAI(creature);
+ return GetInstanceAI<npc_steamrigger_mechanicAI>(creature);
}
struct npc_steamrigger_mechanicAI : public ScriptedAI
diff --git a/src/server/scripts/Outland/CoilfangReservoir/SteamVault/boss_warlord_kalithresh.cpp b/src/server/scripts/Outland/CoilfangReservoir/SteamVault/boss_warlord_kalithresh.cpp
index 887d51a43bf..1b496c086bd 100644
--- a/src/server/scripts/Outland/CoilfangReservoir/SteamVault/boss_warlord_kalithresh.cpp
+++ b/src/server/scripts/Outland/CoilfangReservoir/SteamVault/boss_warlord_kalithresh.cpp
@@ -50,7 +50,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_naga_distillerAI(creature);
+ return GetInstanceAI<npc_naga_distillerAI>(creature);
}
struct npc_naga_distillerAI : public ScriptedAI
@@ -68,13 +68,10 @@ public:
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
//hack, due to really weird spell behaviour :(
- if (instance)
+ if (instance->GetData(DATA_DISTILLER) == IN_PROGRESS)
{
- if (instance->GetData(DATA_DISTILLER) == IN_PROGRESS)
- {
- me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
- me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
- }
+ me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
+ me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
}
}
@@ -87,15 +84,13 @@ public:
DoCast(me, SPELL_WARLORDS_RAGE_NAGA, true);
- if (instance)
- instance->SetData(DATA_DISTILLER, IN_PROGRESS);
+ instance->SetData(DATA_DISTILLER, IN_PROGRESS);
}
void DamageTaken(Unit* /*done_by*/, uint32 &damage) OVERRIDE
{
if (me->GetHealth() <= damage)
- if (instance)
- instance->SetData(DATA_DISTILLER, DONE);
+ instance->SetData(DATA_DISTILLER, DONE);
}
};
@@ -108,7 +103,7 @@ public:
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_warlord_kalithreshAI(creature);
+ return GetInstanceAI<boss_warlord_kalithreshAI>(creature);
}
struct boss_warlord_kalithreshAI : public ScriptedAI
@@ -132,16 +127,14 @@ public:
Rage_Timer = 45000;
CanRage = false;
- if (instance)
- instance->SetBossState(DATA_WARLORD_KALITHRESH, NOT_STARTED);
+ instance->SetBossState(DATA_WARLORD_KALITHRESH, NOT_STARTED);
}
void EnterCombat(Unit* /*who*/) OVERRIDE
{
Talk(SAY_AGGRO);
- if (instance)
- instance->SetBossState(DATA_WARLORD_KALITHRESH, IN_PROGRESS);
+ instance->SetBossState(DATA_WARLORD_KALITHRESH, IN_PROGRESS);
}
void KilledUnit(Unit* /*victim*/) OVERRIDE
@@ -153,17 +146,15 @@ public:
{
//hack :(
if (spell->Id == SPELL_WARLORDS_RAGE_PROC)
- if (instance)
- if (instance->GetData(DATA_DISTILLER) == DONE)
- me->RemoveAurasDueToSpell(SPELL_WARLORDS_RAGE_PROC);
+ if (instance->GetData(DATA_DISTILLER) == DONE)
+ me->RemoveAurasDueToSpell(SPELL_WARLORDS_RAGE_PROC);
}
void JustDied(Unit* /*killer*/) OVERRIDE
{
Talk(SAY_DEATH);
- if (instance)
- instance->SetBossState(DATA_WARLORD_KALITHRESH, DONE);
+ instance->SetBossState(DATA_WARLORD_KALITHRESH, DONE);
}
void UpdateAI(uint32 diff) OVERRIDE
diff --git a/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/boss_broggok.cpp b/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/boss_broggok.cpp
index be4cac80adb..0788fdb3796 100644
--- a/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/boss_broggok.cpp
+++ b/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/boss_broggok.cpp
@@ -122,12 +122,9 @@ class boss_broggok : public CreatureScript
void JustDied(Unit* /*killer*/) OVERRIDE
{
- if (instance)
- {
- instance->HandleGameObject(instance->GetData64(DATA_DOOR4), true);
- instance->HandleGameObject(instance->GetData64(DATA_DOOR5), true);
- instance->SetData(TYPE_BROGGOK_EVENT, DONE);
- }
+ instance->HandleGameObject(instance->GetData64(DATA_DOOR4), true);
+ instance->HandleGameObject(instance->GetData64(DATA_DOOR5), true);
+ instance->SetData(TYPE_BROGGOK_EVENT, DONE);
}
void DoAction(int32 action) OVERRIDE
@@ -154,7 +151,7 @@ class boss_broggok : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_broggokAI(creature);
+ return GetInstanceAI<boss_broggokAI>(creature);
}
};
diff --git a/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/boss_kelidan_the_breaker.cpp b/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/boss_kelidan_the_breaker.cpp
index f6bceb78a14..f4bc5a99a01 100644
--- a/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/boss_kelidan_the_breaker.cpp
+++ b/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/boss_kelidan_the_breaker.cpp
@@ -108,18 +108,16 @@ class boss_kelidan_the_breaker : public CreatureScript
SummonChannelers();
me->SetReactState(REACT_PASSIVE);
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC | UNIT_FLAG_NON_ATTACKABLE);
- if (instance)
- instance->SetData(TYPE_KELIDAN_THE_BREAKER_EVENT, NOT_STARTED);
+ instance->SetData(TYPE_KELIDAN_THE_BREAKER_EVENT, NOT_STARTED);
}
void EnterCombat(Unit* who) OVERRIDE
{
Talk(SAY_WAKE);
- if (me->IsNonMeleeSpellCasted(false))
+ if (me->IsNonMeleeSpellCast(false))
me->InterruptNonMeleeSpells(true);
DoStartMovement(who);
- if (instance)
- instance->SetData(TYPE_KELIDAN_THE_BREAKER_EVENT, IN_PROGRESS);
+ instance->SetData(TYPE_KELIDAN_THE_BREAKER_EVENT, IN_PROGRESS);
}
void KilledUnit(Unit* /*victim*/) OVERRIDE
@@ -193,9 +191,6 @@ class boss_kelidan_the_breaker : public CreatureScript
{
Talk(SAY_DIE);
- if (!instance)
- return;
-
instance->SetData(TYPE_KELIDAN_THE_BREAKER_EVENT, DONE);
instance->HandleGameObject(instance->GetData64(DATA_DOOR1), true);
instance->HandleGameObject(instance->GetData64(DATA_DOOR6), true);
@@ -207,7 +202,7 @@ class boss_kelidan_the_breaker : public CreatureScript
{
if (check_Timer <= diff)
{
- if (!me->IsNonMeleeSpellCasted(false))
+ if (!me->IsNonMeleeSpellCast(false))
DoCast(me, SPELL_EVOCATION);
check_Timer = 5000;
}
@@ -248,7 +243,7 @@ class boss_kelidan_the_breaker : public CreatureScript
if (BurningNova_Timer <= diff)
{
- if (me->IsNonMeleeSpellCasted(false))
+ if (me->IsNonMeleeSpellCast(false))
me->InterruptNonMeleeSpells(true);
Talk(SAY_NOVA);
@@ -275,7 +270,7 @@ class boss_kelidan_the_breaker : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_kelidan_the_breakerAI(creature);
+ return GetInstanceAI<boss_kelidan_the_breakerAI>(creature);
}
};
@@ -311,7 +306,7 @@ class npc_shadowmoon_channeler : public CreatureScript
ShadowBolt_Timer = 1000+rand()%1000;
MarkOfShadow_Timer = 5000+rand()%2000;
check_Timer = 0;
- if (me->IsNonMeleeSpellCasted(false))
+ if (me->IsNonMeleeSpellCast(false))
me->InterruptNonMeleeSpells(true);
}
@@ -319,7 +314,7 @@ class npc_shadowmoon_channeler : public CreatureScript
{
if (Creature* Kelidan = me->FindNearestCreature(ENTRY_KELIDAN, 100))
CAST_AI(boss_kelidan_the_breaker::boss_kelidan_the_breakerAI, Kelidan->AI())->ChannelerEngaged(who);
- if (me->IsNonMeleeSpellCasted(false))
+ if (me->IsNonMeleeSpellCast(false))
me->InterruptNonMeleeSpells(true);
DoStartMovement(who);
}
@@ -336,7 +331,7 @@ class npc_shadowmoon_channeler : public CreatureScript
{
if (check_Timer <= diff)
{
- if (!me->IsNonMeleeSpellCasted(false))
+ if (!me->IsNonMeleeSpellCast(false))
if (Creature* Kelidan = me->FindNearestCreature(ENTRY_KELIDAN, 100))
{
uint64 channeler = CAST_AI(boss_kelidan_the_breaker::boss_kelidan_the_breakerAI, Kelidan->AI())->GetChanneled(me);
@@ -373,7 +368,7 @@ class npc_shadowmoon_channeler : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_shadowmoon_channelerAI(creature);
+ return GetInstanceAI<npc_shadowmoon_channelerAI>(creature);
}
};
diff --git a/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/boss_the_maker.cpp b/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/boss_the_maker.cpp
index 33e23c12d14..fb5cfa272aa 100644
--- a/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/boss_the_maker.cpp
+++ b/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/boss_the_maker.cpp
@@ -72,9 +72,6 @@ class boss_the_maker : public CreatureScript
Domination_Timer = 120000;
Knockdown_Timer = 10000;
- if (!instance)
- return;
-
instance->SetData(TYPE_THE_MAKER_EVENT, NOT_STARTED);
instance->HandleGameObject(instance->GetData64(DATA_DOOR2), true);
}
@@ -83,9 +80,6 @@ class boss_the_maker : public CreatureScript
{
Talk(SAY_AGGRO);
- if (!instance)
- return;
-
instance->SetData(TYPE_THE_MAKER_EVENT, IN_PROGRESS);
instance->HandleGameObject(instance->GetData64(DATA_DOOR2), false);
}
@@ -99,9 +93,6 @@ class boss_the_maker : public CreatureScript
{
Talk(SAY_DIE);
- if (!instance)
- return;
-
instance->SetData(TYPE_THE_MAKER_EVENT, DONE);
instance->HandleGameObject(instance->GetData64(DATA_DOOR2), true);
instance->HandleGameObject(instance->GetData64(DATA_DOOR3), true);
@@ -156,7 +147,7 @@ class boss_the_maker : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_the_makerAI(creature);
+ return GetInstanceAI<boss_the_makerAI>(creature);
}
};
diff --git a/src/server/scripts/Outland/HellfireCitadel/HellfireRamparts/boss_omor_the_unscarred.cpp b/src/server/scripts/Outland/HellfireCitadel/HellfireRamparts/boss_omor_the_unscarred.cpp
index 7e80182f1e8..6f8eac88c66 100644
--- a/src/server/scripts/Outland/HellfireCitadel/HellfireRamparts/boss_omor_the_unscarred.cpp
+++ b/src/server/scripts/Outland/HellfireCitadel/HellfireRamparts/boss_omor_the_unscarred.cpp
@@ -224,7 +224,7 @@ class boss_omor_the_unscarred : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_omor_the_unscarredAI(creature);
+ return GetInstanceAI<boss_omor_the_unscarredAI>(creature);
}
};
diff --git a/src/server/scripts/Outland/HellfireCitadel/MagtheridonsLair/boss_magtheridon.cpp b/src/server/scripts/Outland/HellfireCitadel/MagtheridonsLair/boss_magtheridon.cpp
index f4ee716dc67..f52ae3a8948 100644
--- a/src/server/scripts/Outland/HellfireCitadel/MagtheridonsLair/boss_magtheridon.cpp
+++ b/src/server/scripts/Outland/HellfireCitadel/MagtheridonsLair/boss_magtheridon.cpp
@@ -71,7 +71,7 @@ enum Spells
SPELL_SHADOW_CAGE = 30168,
SPELL_SHADOW_GRASP = 30410,
SPELL_SHADOW_GRASP_VISUAL = 30166,
- SPELL_MIND_EXHAUSTION = 44032, //Casted by the cubes when channeling ends
+ SPELL_MIND_EXHAUSTION = 44032, //Cast by the cubes when channeling ends
SPELL_SHADOW_CAGE_C = 30205,
SPELL_SHADOW_GRASP_C = 30207,
SPELL_SHADOW_BOLT_VOLLEY = 30510,
@@ -249,11 +249,8 @@ class boss_magtheridon : public CreatureScript
void JustReachedHome() OVERRIDE
{
- if (instance)
- {
- instance->SetData(DATA_MAGTHERIDON_EVENT, NOT_STARTED);
- instance->SetData(DATA_COLLAPSE, false);
- }
+ instance->SetData(DATA_MAGTHERIDON_EVENT, NOT_STARTED);
+ instance->SetData(DATA_COLLAPSE, false);
}
void SetClicker(uint64 cubeGUID, uint64 clickerGUID)
@@ -314,8 +311,7 @@ class boss_magtheridon : public CreatureScript
void JustDied(Unit* /*killer*/) OVERRIDE
{
- if (instance)
- instance->SetData(DATA_MAGTHERIDON_EVENT, DONE);
+ instance->SetData(DATA_MAGTHERIDON_EVENT, DONE);
Talk(SAY_DEATH);
}
@@ -331,8 +327,7 @@ class boss_magtheridon : public CreatureScript
void EnterCombat(Unit* /*who*/) OVERRIDE
{
- if (instance)
- instance->SetData(DATA_MAGTHERIDON_EVENT, IN_PROGRESS);
+ instance->SetData(DATA_MAGTHERIDON_EVENT, IN_PROGRESS);
DoZoneInCombat();
me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
@@ -392,7 +387,7 @@ class boss_magtheridon : public CreatureScript
if (Quake_Timer <= diff)
{
// to avoid blastnova interruption
- if (!me->IsNonMeleeSpellCasted(false))
+ if (!me->IsNonMeleeSpellCast(false))
{
DoCast(me, SPELL_QUAKE_TRIGGER, true);
Quake_Timer = 50000;
@@ -421,7 +416,7 @@ class boss_magtheridon : public CreatureScript
Blaze_Timer -= diff;
if (!Phase3 && HealthBelowPct(30)
- && !me->IsNonMeleeSpellCasted(false) // blast nova
+ && !me->IsNonMeleeSpellCast(false) // blast nova
&& !me->HasUnitState(UNIT_STATE_STUNNED)) // shadow cage and earthquake
{
Phase3 = true;
@@ -429,8 +424,7 @@ class boss_magtheridon : public CreatureScript
DoCast(me, SPELL_CAMERA_SHAKE, true);
DoCast(me, SPELL_DEBRIS_KNOCKDOWN, true);
- if (instance)
- instance->SetData(DATA_COLLAPSE, true);
+ instance->SetData(DATA_COLLAPSE, true);
}
if (Phase3)
@@ -457,7 +451,7 @@ class boss_magtheridon : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_magtheridonAI(creature);
+ return GetInstanceAI<boss_magtheridonAI>(creature);
}
};
@@ -498,8 +492,7 @@ class npc_hellfire_channeler : public CreatureScript
void EnterCombat(Unit* /*who*/) OVERRIDE
{
- if (instance)
- instance->SetData(DATA_CHANNELER_EVENT, IN_PROGRESS);
+ instance->SetData(DATA_CHANNELER_EVENT, IN_PROGRESS);
me->InterruptNonMeleeSpells(false);
DoZoneInCombat();
@@ -507,8 +500,7 @@ class npc_hellfire_channeler : public CreatureScript
void JustReachedHome() OVERRIDE
{
- if (instance)
- instance->SetData(DATA_CHANNELER_EVENT, NOT_STARTED);
+ instance->SetData(DATA_CHANNELER_EVENT, NOT_STARTED);
DoCast(me, SPELL_SHADOW_GRASP_C, false);
}
@@ -526,8 +518,7 @@ class npc_hellfire_channeler : public CreatureScript
void JustDied(Unit* /*killer*/) OVERRIDE
{
- if (instance)
- instance->SetData(DATA_CHANNELER_EVENT, DONE);
+ instance->SetData(DATA_CHANNELER_EVENT, DONE);
}
void UpdateAI(uint32 diff) OVERRIDE
@@ -576,7 +567,7 @@ class npc_hellfire_channeler : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_hellfire_channelerAI(creature);
+ return GetInstanceAI<npc_hellfire_channelerAI>(creature);
}
};
diff --git a/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/boss_nethekurse.cpp b/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/boss_nethekurse.cpp
index 981774a677b..404680a9097 100644
--- a/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/boss_nethekurse.cpp
+++ b/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/boss_nethekurse.cpp
@@ -109,8 +109,7 @@ class boss_grand_warlock_nethekurse : public CreatureScript
{
Talk(SAY_DIE);
- if (instance)
- instance->SetBossState(DATA_NETHEKURSE, DONE);
+ instance->SetBossState(DATA_NETHEKURSE, DONE);
}
void SetData(uint32 data, uint32 value) OVERRIDE
@@ -184,8 +183,7 @@ class boss_grand_warlock_nethekurse : public CreatureScript
IntroOnce = true;
IsIntroEvent = true;
- if (instance)
- instance->SetBossState(DATA_NETHEKURSE, IN_PROGRESS);
+ instance->SetBossState(DATA_NETHEKURSE, IN_PROGRESS);
}
if (IsIntroEvent || !IsMainEvent)
@@ -219,9 +217,6 @@ class boss_grand_warlock_nethekurse : public CreatureScript
{
if (IsIntroEvent)
{
- if (!instance)
- return;
-
if (instance->GetBossState(DATA_NETHEKURSE) == IN_PROGRESS)
{
if (IntroEvent_Timer <= diff)
@@ -297,7 +292,7 @@ class boss_grand_warlock_nethekurse : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_grand_warlock_nethekurseAI(creature);
+ return GetInstanceAI<boss_grand_warlock_nethekurseAI>(creature);
}
};
@@ -328,22 +323,18 @@ class npc_fel_orc_convert : public CreatureScript
{
events.ScheduleEvent(EVENT_HEMORRHAGE, 3000);
- if (instance)
- if (Creature* Kurse = Unit::GetCreature(*me, instance->GetData64(NPC_GRAND_WARLOCK_NETHEKURSE)))
- if (Kurse && me->IsWithinDist(Kurse, 45.0f))
- Kurse->AI()->SetData(SETDATA_DATA, SETDATA_PEON_AGGRO);
+ if (Creature* Kurse = Unit::GetCreature(*me, instance->GetData64(NPC_GRAND_WARLOCK_NETHEKURSE)))
+ if (me->IsWithinDist(Kurse, 45.0f))
+ Kurse->AI()->SetData(SETDATA_DATA, SETDATA_PEON_AGGRO);
}
void JustDied(Unit* /*killer*/) OVERRIDE
{
- if (instance)
- {
- if (instance->GetBossState(DATA_NETHEKURSE) != IN_PROGRESS)
- return;
+ if (instance->GetBossState(DATA_NETHEKURSE) != IN_PROGRESS)
+ return;
- if (Creature* Kurse = Unit::GetCreature(*me, instance->GetData64(NPC_GRAND_WARLOCK_NETHEKURSE)))
- Kurse->AI()->SetData(SETDATA_DATA, SETDATA_PEON_DEATH);
- }
+ if (Creature* Kurse = Unit::GetCreature(*me, instance->GetData64(NPC_GRAND_WARLOCK_NETHEKURSE)))
+ Kurse->AI()->SetData(SETDATA_DATA, SETDATA_PEON_DEATH);
}
void UpdateAI(uint32 diff) OVERRIDE
@@ -369,7 +360,7 @@ class npc_fel_orc_convert : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_fel_orc_convertAI(creature);
+ return GetInstanceAI<npc_fel_orc_convertAI>(creature);
}
};
diff --git a/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/boss_warbringer_omrogg.cpp b/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/boss_warbringer_omrogg.cpp
index 9c4be7c0b1b..e647947c133 100644
--- a/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/boss_warbringer_omrogg.cpp
+++ b/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/boss_warbringer_omrogg.cpp
@@ -167,8 +167,7 @@ class boss_warbringer_omrogg : public CreatureScript
ThunderClap_Timer = 15000;
ResetThreat_Timer = 30000;
- if (instance)
- instance->SetData(DATA_OMROGG, NOT_STARTED); //End boss can use this later. O'mrogg must be defeated(DONE) or he will come to aid.
+ instance->SetData(DATA_OMROGG, NOT_STARTED); //End boss can use this later. O'mrogg must be defeated(DONE) or he will come to aid.
}
void DoYellForThreat()
@@ -204,8 +203,7 @@ class boss_warbringer_omrogg : public CreatureScript
AggroYell = true;
}
- if (instance)
- instance->SetBossState(DATA_OMROGG, IN_PROGRESS);
+ instance->SetBossState(DATA_OMROGG, IN_PROGRESS);
}
void JustSummoned(Creature* summoned) OVERRIDE
@@ -259,8 +257,7 @@ class boss_warbringer_omrogg : public CreatureScript
RightHead->AI()->SetData(SETDATA_DATA, SETDATA_YELL);
- if (instance)
- instance->SetBossState(DATA_OMROGG, DONE);
+ instance->SetBossState(DATA_OMROGG, DONE);
}
void UpdateAI(uint32 diff) OVERRIDE
@@ -388,7 +385,7 @@ class boss_warbringer_omrogg : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_warbringer_omroggAI(creature);
+ return GetInstanceAI<boss_warbringer_omroggAI>(creature);
}
};
@@ -438,7 +435,7 @@ class npc_omrogg_heads : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_omrogg_headsAI(creature);
+ return GetInstanceAI<npc_omrogg_headsAI>(creature);
}
};
diff --git a/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/boss_warchief_kargath_bladefist.cpp b/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/boss_warchief_kargath_bladefist.cpp
index f9ec3edb362..553c1cbdb33 100644
--- a/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/boss_warchief_kargath_bladefist.cpp
+++ b/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/boss_warchief_kargath_bladefist.cpp
@@ -90,8 +90,7 @@ class boss_warchief_kargath_bladefist : public CreatureScript
Talk(SAY_DEATH);
removeAdds();
- if (instance)
- instance->SetBossState(DATA_KARGATH, DONE);
+ instance->SetBossState(DATA_KARGATH, DONE);
}
void EnterCombat(Unit* /*who*/) OVERRIDE
@@ -311,7 +310,7 @@ class boss_warchief_kargath_bladefist : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_warchief_kargath_bladefistAI(creature);
+ return GetInstanceAI<boss_warchief_kargath_bladefistAI>(creature);
}
};
diff --git a/src/server/scripts/Outland/TempestKeep/Eye/boss_alar.cpp b/src/server/scripts/Outland/TempestKeep/Eye/boss_alar.cpp
index 5d789359864..ef01fd3a2ea 100644
--- a/src/server/scripts/Outland/TempestKeep/Eye/boss_alar.cpp
+++ b/src/server/scripts/Outland/TempestKeep/Eye/boss_alar.cpp
@@ -109,8 +109,7 @@ class boss_alar : public CreatureScript
void Reset() OVERRIDE
{
- if (instance)
- instance->SetData(DATA_ALAREVENT, NOT_STARTED);
+ instance->SetData(DATA_ALAREVENT, NOT_STARTED);
Berserk_Timer = 1200000;
Platforms_Move_Timer = 0;
@@ -136,8 +135,7 @@ class boss_alar : public CreatureScript
void EnterCombat(Unit* /*who*/) OVERRIDE
{
- if (instance)
- instance->SetData(DATA_ALAREVENT, IN_PROGRESS);
+ instance->SetData(DATA_ALAREVENT, IN_PROGRESS);
me->SetDisableGravity(true); // after enterevademode will be set walk movement
DoZoneInCombat();
@@ -146,8 +144,7 @@ class boss_alar : public CreatureScript
void JustDied(Unit* /*killer*/) OVERRIDE
{
- if (instance)
- instance->SetData(DATA_ALAREVENT, DONE);
+ instance->SetData(DATA_ALAREVENT, DONE);
}
void JustSummoned(Creature* summon) OVERRIDE
@@ -426,7 +423,7 @@ class boss_alar : public CreatureScript
void DoMeleeAttackIfReady()
{
- if (me->isAttackReady() && !me->IsNonMeleeSpellCasted(false))
+ if (me->isAttackReady() && !me->IsNonMeleeSpellCast(false))
{
if (me->IsWithinMeleeRange(me->GetVictim()))
{
@@ -451,7 +448,7 @@ class boss_alar : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_alarAI(creature);
+ return GetInstanceAI<boss_alarAI>(creature);
}
};
@@ -528,7 +525,7 @@ class npc_ember_of_alar : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_ember_of_alarAI(creature);
+ return GetInstanceAI<npc_ember_of_alarAI>(creature);
}
};
diff --git a/src/server/scripts/Outland/TempestKeep/Eye/boss_astromancer.cpp b/src/server/scripts/Outland/TempestKeep/Eye/boss_astromancer.cpp
index c5c3f6deb12..241438d611b 100644
--- a/src/server/scripts/Outland/TempestKeep/Eye/boss_astromancer.cpp
+++ b/src/server/scripts/Outland/TempestKeep/Eye/boss_astromancer.cpp
@@ -146,8 +146,7 @@ class boss_high_astromancer_solarian : public CreatureScript
Wrath_Timer = 20000+rand()%5000;//twice in phase one
Phase = 1;
- if (instance)
- instance->SetData(DATA_HIGHASTROMANCERSOLARIANEVENT, NOT_STARTED);
+ instance->SetData(DATA_HIGHASTROMANCERSOLARIANEVENT, NOT_STARTED);
me->SetArmor(defaultarmor);
me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
@@ -168,8 +167,7 @@ class boss_high_astromancer_solarian : public CreatureScript
me->SetObjectScale(defaultsize);
me->SetDisplayId(MODEL_HUMAN);
Talk(SAY_DEATH);
- if (instance)
- instance->SetData(DATA_HIGHASTROMANCERSOLARIANEVENT, DONE);
+ instance->SetData(DATA_HIGHASTROMANCERSOLARIANEVENT, DONE);
}
void EnterCombat(Unit* /*who*/) OVERRIDE
@@ -177,8 +175,7 @@ class boss_high_astromancer_solarian : public CreatureScript
Talk(SAY_AGGRO);
DoZoneInCombat();
- if (instance)
- instance->SetData(DATA_HIGHASTROMANCERSOLARIANEVENT, IN_PROGRESS);
+ instance->SetData(DATA_HIGHASTROMANCERSOLARIANEVENT, IN_PROGRESS);
}
void SummonMinion(uint32 entry, float x, float y, float z)
@@ -419,7 +416,7 @@ class boss_high_astromancer_solarian : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_high_astromancer_solarianAI(creature);
+ return GetInstanceAI<boss_high_astromancer_solarianAI>(creature);
}
};
@@ -467,8 +464,7 @@ class npc_solarium_priest : public CreatureScript
switch (urand(0, 1))
{
case 0:
- if (instance)
- target = Unit::GetUnit(*me, instance->GetData64(DATA_ASTROMANCER));
+ target = Unit::GetUnit(*me, instance->GetData64(DATA_ASTROMANCER));
break;
case 1:
target = me;
@@ -506,7 +502,7 @@ class npc_solarium_priest : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_solarium_priestAI(creature);
+ return GetInstanceAI<npc_solarium_priestAI>(creature);
}
};
diff --git a/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp b/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp
index e85c8781dd9..11b4ad1398d 100644
--- a/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp
+++ b/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp
@@ -308,7 +308,7 @@ class boss_kaelthas : public CreatureScript
uint32 Phase;
uint32 PhaseSubphase; //generic
uint32 Phase_Timer; //generic timer
- uint32 PyrosCasted;
+ uint32 PyrosCast;
bool InGravityLapse;
bool IsCastingFireball;
@@ -330,7 +330,7 @@ class boss_kaelthas : public CreatureScript
GravityLapse_Phase = 0;
NetherBeam_Timer = 8000;
NetherVapor_Timer = 10000;
- PyrosCasted = 0;
+ PyrosCast = 0;
Phase = 0;
InGravityLapse = false;
IsCastingFireball = false;
@@ -344,8 +344,7 @@ class boss_kaelthas : public CreatureScript
me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
- if (instance)
- instance->SetData(DATA_KAELTHASEVENT, 0);
+ instance->SetData(DATA_KAELTHASEVENT, 0);
}
void PrepareAdvisors()
@@ -364,9 +363,6 @@ class boss_kaelthas : public CreatureScript
void StartEvent()
{
- if (!instance)
- return;
-
m_auiAdvisorGuid[0] = instance->GetData64(DATA_THALADREDTHEDARKENER);
m_auiAdvisorGuid[1] = instance->GetData64(DATA_LORDSANGUINAR);
m_auiAdvisorGuid[2] = instance->GetData64(DATA_GRANDASTROMANCERCAPERNIAN);
@@ -468,8 +464,7 @@ class boss_kaelthas : public CreatureScript
summons.DespawnAll();
- if (instance)
- instance->SetData(DATA_KAELTHASEVENT, 0);
+ instance->SetData(DATA_KAELTHASEVENT, 0);
for (uint8 i = 0; i < MAX_ADVISORS; ++i)
{
@@ -633,8 +628,7 @@ class boss_kaelthas : public CreatureScript
if (Advisor && (Advisor->getStandState() == UNIT_STAND_STATE_DEAD))
{
Phase = 2;
- if (instance)
- instance->SetData(DATA_KAELTHASEVENT, 2);
+ instance->SetData(DATA_KAELTHASEVENT, 2);
Talk(SAY_PHASE2_WEAPON);
@@ -678,8 +672,7 @@ class boss_kaelthas : public CreatureScript
if (Phase_Timer <= diff)
{
Talk(SAY_PHASE3_ADVANCE);
- if (instance)
- instance->SetData(DATA_KAELTHASEVENT, 3);
+ instance->SetData(DATA_KAELTHASEVENT, 3);
Phase = 3;
PhaseSubphase = 0;
}
@@ -716,8 +709,7 @@ class boss_kaelthas : public CreatureScript
Talk(SAY_PHASE4_INTRO2);
Phase = 4;
- if (instance)
- instance->SetData(DATA_KAELTHASEVENT, 4);
+ instance->SetData(DATA_KAELTHASEVENT, 4);
// Sometimes people can collect Aggro in Phase 1-3. Reset threat before releasing Kael.
DoResetThreat();
@@ -750,7 +742,7 @@ class boss_kaelthas : public CreatureScript
{
if (!IsCastingFireball)
{
- if (!me->IsNonMeleeSpellCasted(false))
+ if (!me->IsNonMeleeSpellCast(false))
{
//interruptable
me->ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_INTERRUPT_CAST, false);
@@ -821,8 +813,7 @@ class boss_kaelthas : public CreatureScript
{
if (HealthBelowPct(50))
{
- if (instance)
- instance->SetData(DATA_KAELTHASEVENT, 4);
+ instance->SetData(DATA_KAELTHASEVENT, 4);
Phase = 5;
Phase_Timer = 10000;
@@ -844,19 +835,19 @@ class boss_kaelthas : public CreatureScript
{
DoCast(me, SPELL_SHOCK_BARRIER);
ChainPyros = true;
- PyrosCasted = 0;
+ PyrosCast = 0;
ShockBarrier_Timer = 60000;
}
else
ShockBarrier_Timer -= diff;
//Chain Pyros (3 of them max)
- if (ChainPyros && !me->IsNonMeleeSpellCasted(false))
+ if (ChainPyros && !me->IsNonMeleeSpellCast(false))
{
- if (PyrosCasted < 3)
+ if (PyrosCast < 3)
{
DoCastVictim(SPELL_PYROBLAST);
- ++PyrosCasted;
+ ++PyrosCast;
}
else
{
@@ -1011,7 +1002,7 @@ class boss_kaelthas : public CreatureScript
};
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_kaelthasAI(creature);
+ return GetInstanceAI<boss_kaelthasAI>(creature);
}
};
@@ -1109,7 +1100,7 @@ class boss_thaladred_the_darkener : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_thaladred_the_darkenerAI(creature);
+ return GetInstanceAI<boss_thaladred_the_darkenerAI>(creature);
}
};
@@ -1177,7 +1168,7 @@ class boss_lord_sanguinar : public CreatureScript
};
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_lord_sanguinarAI(creature);
+ return GetInstanceAI<boss_lord_sanguinarAI>(creature);
}
};
//Grand Astromancer Capernian AI
@@ -1321,7 +1312,7 @@ class boss_grand_astromancer_capernian : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_grand_astromancer_capernianAI(creature);
+ return GetInstanceAI<boss_grand_astromancer_capernianAI>(creature);
}
};
@@ -1404,7 +1395,7 @@ class boss_master_engineer_telonicus : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_master_engineer_telonicusAI(creature);
+ return GetInstanceAI<boss_master_engineer_telonicusAI>(creature);
}
};
diff --git a/src/server/scripts/Outland/TempestKeep/Eye/boss_void_reaver.cpp b/src/server/scripts/Outland/TempestKeep/Eye/boss_void_reaver.cpp
index f842ed19f3c..db6bd772a83 100644
--- a/src/server/scripts/Outland/TempestKeep/Eye/boss_void_reaver.cpp
+++ b/src/server/scripts/Outland/TempestKeep/Eye/boss_void_reaver.cpp
@@ -91,16 +91,14 @@ class boss_void_reaver : public CreatureScript
Talk(SAY_DEATH);
DoZoneInCombat();
- if (instance)
- instance->SetData(DATA_VOIDREAVEREVENT, DONE);
+ instance->SetData(DATA_VOIDREAVEREVENT, DONE);
}
void EnterCombat(Unit* /*who*/) OVERRIDE
{
Talk(SAY_AGGRO);
- if (instance)
- instance->SetData(DATA_VOIDREAVEREVENT, IN_PROGRESS);
+ instance->SetData(DATA_VOIDREAVEREVENT, IN_PROGRESS);
}
void UpdateAI(uint32 diff) OVERRIDE
@@ -172,7 +170,7 @@ class boss_void_reaver : public CreatureScript
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new boss_void_reaverAI(creature);
+ return GetInstanceAI<boss_void_reaverAI>(creature);
}
};
diff --git a/src/server/scripts/Outland/TempestKeep/Mechanar/boss_nethermancer_sepethrea.cpp b/src/server/scripts/Outland/TempestKeep/Mechanar/boss_nethermancer_sepethrea.cpp
index b5172245b49..37a6886cda5 100644
--- a/src/server/scripts/Outland/TempestKeep/Mechanar/boss_nethermancer_sepethrea.cpp
+++ b/src/server/scripts/Outland/TempestKeep/Mechanar/boss_nethermancer_sepethrea.cpp
@@ -182,14 +182,11 @@ class npc_ragin_flames : public CreatureScript
//Check_Timer
if (Check_Timer <= diff)
{
- if (instance)
+ if (instance->GetData(DATA_NETHERMANCER_SEPRETHREA) != IN_PROGRESS)
{
- if (instance->GetData(DATA_NETHERMANCER_SEPRETHREA) != IN_PROGRESS)
- {
- //remove
- me->setDeathState(JUST_DIED);
- me->RemoveCorpse();
- }
+ //remove
+ me->setDeathState(JUST_DIED);
+ me->RemoveCorpse();
}
Check_Timer = 1000;
} else Check_Timer -= diff;
@@ -223,7 +220,7 @@ class npc_ragin_flames : public CreatureScript
};
CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- return new npc_ragin_flamesAI(creature);
+ return GetInstanceAI<npc_ragin_flamesAI>(creature);
}
};
diff --git a/src/server/scripts/Outland/TempestKeep/arcatraz/arcatraz.cpp b/src/server/scripts/Outland/TempestKeep/arcatraz/arcatraz.cpp
index ff3145c5c78..741b1378e4a 100644
--- a/src/server/scripts/Outland/TempestKeep/arcatraz/arcatraz.cpp
+++ b/src/server/scripts/Outland/TempestKeep/arcatraz/arcatraz.cpp
@@ -116,11 +116,10 @@ class npc_millhouse_manastorm : public CreatureScript
}
}
- void EnterCombat(Unit* /*who*/) OVERRIDE { }
-
- void KilledUnit(Unit* /*victim*/) OVERRIDE
+ void KilledUnit(Unit* who) OVERRIDE
{
- Talk(SAY_KILL);
+ if (who->GetTypeId() == TYPEID_PLAYER)
+ Talk(SAY_KILL);
}
void JustDied(Unit* /*killer*/) OVERRIDE
@@ -191,7 +190,7 @@ class npc_millhouse_manastorm : public CreatureScript
if (Pyroblast_Timer <= diff)
{
- if (me->IsNonMeleeSpellCasted(false))
+ if (me->IsNonMeleeSpellCast(false))
return;
Talk(SAY_PYRO);
diff --git a/src/server/scripts/Outland/TempestKeep/arcatraz/arcatraz.h b/src/server/scripts/Outland/TempestKeep/arcatraz/arcatraz.h
index 1ebfad4dfeb..c3b7d754a0d 100644
--- a/src/server/scripts/Outland/TempestKeep/arcatraz/arcatraz.h
+++ b/src/server/scripts/Outland/TempestKeep/arcatraz/arcatraz.h
@@ -32,11 +32,11 @@ enum DataTypes
// Additional Data
DATA_CONVERSATION = 4,
- DATA_WARDEN_1 = 5, // used by EventAI
- DATA_WARDEN_2 = 6, // used by EventAI
- DATA_WARDEN_3 = 7, // used by EventAI
- DATA_WARDEN_4 = 8, // used by EventAI
- DATA_WARDEN_5 = 9, // used by EventAI
+ DATA_WARDEN_1 = 5, // used by SmartAI
+ DATA_WARDEN_2 = 6, // used by SmartAI
+ DATA_WARDEN_3 = 7, // used by SmartAI
+ DATA_WARDEN_4 = 8, // used by SmartAI
+ DATA_WARDEN_5 = 9, // used by SmartAI
DATA_MELLICHAR = 10,
DATA_WARDENS_SHIELD = 11
};
diff --git a/src/server/scripts/Outland/TempestKeep/arcatraz/boss_harbinger_skyriss.cpp b/src/server/scripts/Outland/TempestKeep/arcatraz/boss_harbinger_skyriss.cpp
index 48d955acbc3..d590093de56 100644
--- a/src/server/scripts/Outland/TempestKeep/arcatraz/boss_harbinger_skyriss.cpp
+++ b/src/server/scripts/Outland/TempestKeep/arcatraz/boss_harbinger_skyriss.cpp
@@ -137,7 +137,7 @@ class boss_harbinger_skyriss : public CreatureScript
void DoSplit(uint32 val)
{
- if (me->IsNonMeleeSpellCasted(false))
+ if (me->IsNonMeleeSpellCast(false))
me->InterruptNonMeleeSpells(false);
Talk(SAY_IMAGE);
@@ -211,7 +211,7 @@ class boss_harbinger_skyriss : public CreatureScript
if (Fear_Timer <= diff)
{
- if (me->IsNonMeleeSpellCasted(false))
+ if (me->IsNonMeleeSpellCast(false))
return;
Talk(SAY_FEAR);
@@ -228,7 +228,7 @@ class boss_harbinger_skyriss : public CreatureScript
if (Domination_Timer <= diff)
{
- if (me->IsNonMeleeSpellCasted(false))
+ if (me->IsNonMeleeSpellCast(false))
return;
Talk(SAY_MIND);
@@ -247,7 +247,7 @@ class boss_harbinger_skyriss : public CreatureScript
{
if (ManaBurn_Timer <= diff)
{
- if (me->IsNonMeleeSpellCasted(false))
+ if (me->IsNonMeleeSpellCast(false))
return;
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1))
diff --git a/src/server/scripts/Outland/TempestKeep/botanica/boss_high_botanist_freywinn.cpp b/src/server/scripts/Outland/TempestKeep/botanica/boss_high_botanist_freywinn.cpp
index 1b362fe8a5a..fe072b437eb 100644
--- a/src/server/scripts/Outland/TempestKeep/botanica/boss_high_botanist_freywinn.cpp
+++ b/src/server/scripts/Outland/TempestKeep/botanica/boss_high_botanist_freywinn.cpp
@@ -126,7 +126,7 @@ class boss_high_botanist_freywinn : public CreatureScript
{
Talk(SAY_TREE);
- if (me->IsNonMeleeSpellCasted(false))
+ if (me->IsNonMeleeSpellCast(false))
me->InterruptNonMeleeSpells(true);
me->RemoveAllAuras();
diff --git a/src/server/scripts/Outland/zone_blades_edge_mountains.cpp b/src/server/scripts/Outland/zone_blades_edge_mountains.cpp
index dcb9f71615d..39a97bd4d8a 100644
--- a/src/server/scripts/Outland/zone_blades_edge_mountains.cpp
+++ b/src/server/scripts/Outland/zone_blades_edge_mountains.cpp
@@ -19,7 +19,7 @@
/* ScriptData
SDName: Blades_Edge_Mountains
SD%Complete: 90
-SDComment: Quest support: 10503, 10504, 10556, 10594, 10609, 10682, 10821, 10980. Ogri'la->Skettis Flight. (npc_daranelle needs bit more work before consider complete)
+SDComment: Quest support: 10503, 10504, 10556, 10594, 10609, 10821. Ogri'la->Skettis Flight. (npc_daranelle needs bit more work before consider complete)
SDCategory: Blade's Edge Mountains
EndScriptData */
@@ -28,8 +28,6 @@ npc_bloodmaul_brutebane
npc_bloodmaul_brute
npc_nether_drake
npc_daranelle
-npc_overseer_nuaar
-npc_saikkal_the_elder
go_legion_obelisk
go_thunderspike
EndContentData */
@@ -134,8 +132,9 @@ public:
void JustDied(Unit* killer) OVERRIDE
{
- if (killer->ToPlayer()->GetQuestRewardStatus(QUEST_INTO_THE_SOULGRINDER))
- Talk(SAY_DEATH);
+ if (killer->GetTypeId() == TYPEID_PLAYER)
+ if (killer->ToPlayer()->GetQuestRewardStatus(QUEST_INTO_THE_SOULGRINDER))
+ Talk(SAY_DEATH);
}
void MoveInLineOfSight(Unit* who) OVERRIDE
@@ -401,8 +400,9 @@ public:
enum Daranelle
{
- SAY_SPELL_INFLUENCE = 0,
- SPELL_LASHHAN_CHANNEL = 36904
+ SAY_SPELL_INFLUENCE = 0,
+ SPELL_LASHHAN_CHANNEL = 36904,
+ SPELL_DISPELLING_ANALYSIS = 37028
};
class npc_daranelle : public CreatureScript
@@ -427,7 +427,7 @@ public:
{
Talk(SAY_SPELL_INFLUENCE, who);
/// @todo Move the below to updateAI and run if this statement == true
- DoCast(who, 37028, true);
+ DoCast(who, SPELL_DISPELLING_ANALYSIS, true);
}
}
@@ -441,79 +441,6 @@ public:
}
};
-/*######
-## npc_overseer_nuaar
-######*/
-
-#define GOSSIP_HELLO_ON "Overseer, I am here to negotiate on behalf of the Cenarion Expedition."
-
-class npc_overseer_nuaar : public CreatureScript
-{
-public:
- npc_overseer_nuaar() : CreatureScript("npc_overseer_nuaar") { }
-
- bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action) OVERRIDE
- {
- player->PlayerTalkClass->ClearMenus();
- if (action == GOSSIP_ACTION_INFO_DEF+1)
- {
- player->SEND_GOSSIP_MENU(10533, creature->GetGUID());
- player->AreaExploredOrEventHappens(10682);
- }
- return true;
- }
-
- bool OnGossipHello(Player* player, Creature* creature) OVERRIDE
- {
- if (player->GetQuestStatus(10682) == QUEST_STATUS_INCOMPLETE)
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HELLO_ON, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
-
- player->SEND_GOSSIP_MENU(10532, creature->GetGUID());
-
- return true;
- }
-};
-
-/*######
-## npc_saikkal_the_elder
-######*/
-
-#define GOSSIP_HELLO_STE "Yes... yes, it's me."
-#define GOSSIP_SELECT_STE "Yes elder. Tell me more of the book."
-
-class npc_saikkal_the_elder : public CreatureScript
-{
-public:
- npc_saikkal_the_elder() : CreatureScript("npc_saikkal_the_elder") { }
-
- bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action) OVERRIDE
- {
- player->PlayerTalkClass->ClearMenus();
- switch (action)
- {
- case GOSSIP_ACTION_INFO_DEF+1:
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_SELECT_STE, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2);
- player->SEND_GOSSIP_MENU(10795, creature->GetGUID());
- break;
- case GOSSIP_ACTION_INFO_DEF+2:
- player->TalkedToCreature(creature->GetEntry(), creature->GetGUID());
- player->SEND_GOSSIP_MENU(10796, creature->GetGUID());
- break;
- }
- return true;
- }
-
- bool OnGossipHello(Player* player, Creature* creature) OVERRIDE
- {
- if (player->GetQuestStatus(10980) == QUEST_STATUS_INCOMPLETE)
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HELLO_STE, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
-
- player->SEND_GOSSIP_MENU(10794, creature->GetGUID());
-
- return true;
- }
-};
-
//Support for quest: You're Fired! (10821)
bool obelisk_one, obelisk_two, obelisk_three, obelisk_four, obelisk_five;
@@ -955,7 +882,7 @@ class npc_simon_bunny : public CreatureScript
/*
Called when AI is playing the sequence for player. We cast the visual spell and then remove the
- casted color from the casting sequence.
+ cast color from the casting sequence.
*/
void PlayNextColor()
{
@@ -1198,7 +1125,10 @@ public:
struct npc_oscillating_frequency_scanner_master_bunnyAI : public ScriptedAI
{
- npc_oscillating_frequency_scanner_master_bunnyAI(Creature* creature) : ScriptedAI(creature) { }
+ npc_oscillating_frequency_scanner_master_bunnyAI(Creature* creature) : ScriptedAI(creature)
+ {
+ playerGuid = 0;
+ }
void Reset() OVERRIDE
{
@@ -1279,8 +1209,6 @@ void AddSC_blades_edge_mountains()
new npc_bloodmaul_brute();
new npc_nether_drake();
new npc_daranelle();
- new npc_overseer_nuaar();
- new npc_saikkal_the_elder();
new go_legion_obelisk();
new go_thunderspike();
new npc_simon_bunny();
diff --git a/src/server/scripts/Outland/zone_hellfire_peninsula.cpp b/src/server/scripts/Outland/zone_hellfire_peninsula.cpp
index 672cf51bdb7..5e70b7f9fc4 100644
--- a/src/server/scripts/Outland/zone_hellfire_peninsula.cpp
+++ b/src/server/scripts/Outland/zone_hellfire_peninsula.cpp
@@ -19,18 +19,15 @@
/* ScriptData
SDName: Hellfire_Peninsula
SD%Complete: 100
-SDComment: Quest support: 9375, 9410, 9418, 10129, 10146, 10162, 10163, 10340, 10346, 10347, 10382 (Special flight paths)
+SDComment: Quest support: 9375, 9410, 9418, 10129, 10146, 10162, 10163, 10340, 10346, 10347, 10382 (Special flight paths) "Needs update"
SDCategory: Hellfire Peninsula
EndScriptData */
/* ContentData
npc_aeranas
npc_ancestral_wolf
-go_haaleshi_altar
-npc_naladu
-npc_tracy_proudwell
-npc_trollbane
npc_wounded_blood_elf
+npc_fel_guard_hound
EndContentData */
#include "ScriptMgr.h"
@@ -46,14 +43,12 @@ EndContentData */
enum Aeranas
{
- SAY_SUMMON = 0,
- SAY_FREE = 1,
-
- FACTION_HOSTILE = 16,
- FACTION_FRIENDLY = 35,
-
- SPELL_ENVELOPING_WINDS = 15535,
- SPELL_SHOCK = 12553
+ SAY_SUMMON = 0,
+ SAY_FREE = 1,
+ FACTION_HOSTILE = 16,
+ FACTION_FRIENDLY = 35,
+ SPELL_ENVELOPING_WINDS = 15535,
+ SPELL_SHOCK = 12553
};
class npc_aeranas : public CreatureScript
@@ -61,24 +56,15 @@ class npc_aeranas : public CreatureScript
public:
npc_aeranas() : CreatureScript("npc_aeranas") { }
- CreatureAI* GetAI(Creature* creature) const OVERRIDE
- {
- return new npc_aeranasAI(creature);
- }
-
struct npc_aeranasAI : public ScriptedAI
{
npc_aeranasAI(Creature* creature) : ScriptedAI(creature) { }
- uint32 Faction_Timer;
- uint32 EnvelopingWinds_Timer;
- uint32 Shock_Timer;
-
void Reset() OVERRIDE
{
- Faction_Timer = 8000;
- EnvelopingWinds_Timer = 9000;
- Shock_Timer = 5000;
+ faction_Timer = 8000;
+ envelopingWinds_Timer = 9000;
+ shock_Timer = 5000;
me->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER);
me->setFaction(FACTION_FRIENDLY);
@@ -88,13 +74,13 @@ public:
void UpdateAI(uint32 diff) OVERRIDE
{
- if (Faction_Timer)
+ if (faction_Timer)
{
- if (Faction_Timer <= diff)
+ if (faction_Timer <= diff)
{
me->setFaction(FACTION_HOSTILE);
- Faction_Timer = 0;
- } else Faction_Timer -= diff;
+ faction_Timer = 0;
+ } else faction_Timer -= diff;
}
if (!UpdateVictim())
@@ -111,21 +97,31 @@ public:
return;
}
- if (Shock_Timer <= diff)
+ if (shock_Timer <= diff)
{
DoCastVictim(SPELL_SHOCK);
- Shock_Timer = 10000;
- } else Shock_Timer -= diff;
+ shock_Timer = 10000;
+ } else shock_Timer -= diff;
- if (EnvelopingWinds_Timer <= diff)
+ if (envelopingWinds_Timer <= diff)
{
DoCastVictim(SPELL_ENVELOPING_WINDS);
- EnvelopingWinds_Timer = 25000;
- } else EnvelopingWinds_Timer -= diff;
+ envelopingWinds_Timer = 25000;
+ } else envelopingWinds_Timer -= diff;
DoMeleeAttackIfReady();
}
+
+ private:
+ uint32 faction_Timer;
+ uint32 envelopingWinds_Timer;
+ uint32 shock_Timer;
};
+
+ CreatureAI* GetAI(Creature* creature) const OVERRIDE
+ {
+ return new npc_aeranasAI(creature);
+ }
};
/*######
@@ -134,13 +130,11 @@ public:
enum AncestralWolf
{
- EMOTE_WOLF_LIFT_HEAD = 0,
- EMOTE_WOLF_HOWL = 1,
- SAY_WOLF_WELCOME = 2,
-
- SPELL_ANCESTRAL_WOLF_BUFF = 29981,
-
- NPC_RYGA = 17123
+ EMOTE_WOLF_LIFT_HEAD = 0,
+ EMOTE_WOLF_HOWL = 1,
+ SAY_WOLF_WELCOME = 2,
+ SPELL_ANCESTRAL_WOLF_BUFF = 29981,
+ NPC_RYGA = 17123
};
class npc_ancestral_wolf : public CreatureScript
@@ -148,11 +142,6 @@ class npc_ancestral_wolf : public CreatureScript
public:
npc_ancestral_wolf() : CreatureScript("npc_ancestral_wolf") { }
- CreatureAI* GetAI(Creature* creature) const OVERRIDE
- {
- return new npc_ancestral_wolfAI(creature);
- }
-
struct npc_ancestral_wolfAI : public npc_escortAI
{
npc_ancestral_wolfAI(Creature* creature) : npc_escortAI(creature)
@@ -166,20 +155,18 @@ public:
Reset();
}
- Creature* pRyga;
-
void Reset() OVERRIDE
{
- pRyga = NULL;
+ ryga = NULL;
DoCast(me, SPELL_ANCESTRAL_WOLF_BUFF, true);
}
void MoveInLineOfSight(Unit* who) OVERRIDE
{
- if (!pRyga && who->GetEntry() == NPC_RYGA && me->IsWithinDistInMap(who, 15.0f))
+ if (!ryga && who->GetEntry() == NPC_RYGA && me->IsWithinDistInMap(who, 15.0f))
if (Creature* temp = who->ToCreature())
- pRyga = temp;
+ ryga = temp;
npc_escortAI::MoveInLineOfSight(who);
}
@@ -195,154 +182,19 @@ public:
Talk(EMOTE_WOLF_HOWL);
break;
case 50:
- if (pRyga && pRyga->IsAlive() && !pRyga->IsInCombat())
- pRyga->AI()->Talk(SAY_WOLF_WELCOME);
+ if (ryga && ryga->IsAlive() && !ryga->IsInCombat())
+ ryga->AI()->Talk(SAY_WOLF_WELCOME);
break;
}
}
- };
-};
-
-/*######
-## npc_naladu
-######*/
-
-#define GOSSIP_NALADU_ITEM1 "Why don't you escape?"
-
-enum Naladu
-{
- GOSSIP_TEXTID_NALADU1 = 9788
-};
-
-class npc_naladu : public CreatureScript
-{
-public:
- npc_naladu() : CreatureScript("npc_naladu") { }
-
- bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action) OVERRIDE
- {
- player->PlayerTalkClass->ClearMenus();
- if (action == GOSSIP_ACTION_INFO_DEF+1)
- player->SEND_GOSSIP_MENU(GOSSIP_TEXTID_NALADU1, creature->GetGUID());
-
- return true;
- }
-
- bool OnGossipHello(Player* player, Creature* creature) OVERRIDE
- {
- if (creature->IsQuestGiver())
- player->PrepareQuestMenu(creature->GetGUID());
-
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_NALADU_ITEM1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
- player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID());
- return true;
- }
-};
-
-/*######
-## npc_tracy_proudwell
-######*/
-
-#define GOSSIP_TEXT_REDEEM_MARKS "I have marks to redeem!"
-#define GOSSIP_TRACY_PROUDWELL_ITEM1 "I heard that your dog Fei Fei took Klatu's prayer beads..."
-#define GOSSIP_TRACY_PROUDWELL_ITEM2 "<back>"
-
-enum Tracy
-{
- GOSSIP_TEXTID_TRACY_PROUDWELL1 = 10689,
- QUEST_DIGGING_FOR_PRAYER_BEADS = 10916
-};
-
-class npc_tracy_proudwell : public CreatureScript
-{
-public:
- npc_tracy_proudwell() : CreatureScript("npc_tracy_proudwell") { }
-
- bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action) OVERRIDE
- {
- player->PlayerTalkClass->ClearMenus();
- switch (action)
- {
- case GOSSIP_ACTION_INFO_DEF+1:
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TRACY_PROUDWELL_ITEM2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2);
- player->SEND_GOSSIP_MENU(GOSSIP_TEXTID_TRACY_PROUDWELL1, creature->GetGUID());
- break;
- case GOSSIP_ACTION_INFO_DEF+2:
- player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID());
- break;
- case GOSSIP_ACTION_TRADE:
- player->GetSession()->SendListInventory(creature->GetGUID());
- break;
- }
-
- return true;
- }
-
- bool OnGossipHello(Player* player, Creature* creature) OVERRIDE
- {
- if (creature->IsQuestGiver())
- player->PrepareQuestMenu(creature->GetGUID());
-
- if (creature->IsVendor())
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, GOSSIP_TEXT_REDEEM_MARKS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE);
-
- if (player->GetQuestStatus(QUEST_DIGGING_FOR_PRAYER_BEADS) == QUEST_STATUS_INCOMPLETE)
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TRACY_PROUDWELL_ITEM1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
-
- player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID());
- return true;
- }
-};
-
-/*######
-## npc_trollbane
-######*/
-
-#define GOSSIP_TROLLBANE_ITEM1 "Tell me of the Sons of Lothar."
-#define GOSSIP_TROLLBANE_ITEM2 "<more>"
-#define GOSSIP_TROLLBANE_ITEM3 "Tell me of your homeland."
-
-enum Trollbane
-{
- GOSSIP_TEXTID_TROLLBANE1 = 9932,
- GOSSIP_TEXTID_TROLLBANE2 = 9933,
- GOSSIP_TEXTID_TROLLBANE3 = 8772
-};
-class npc_trollbane : public CreatureScript
-{
-public:
- npc_trollbane() : CreatureScript("npc_trollbane") { }
-
- bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action) OVERRIDE
- {
- player->PlayerTalkClass->ClearMenus();
- switch (action)
- {
- case GOSSIP_ACTION_INFO_DEF+1:
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TROLLBANE_ITEM2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2);
- player->SEND_GOSSIP_MENU(GOSSIP_TEXTID_TROLLBANE1, creature->GetGUID());
- break;
- case GOSSIP_ACTION_INFO_DEF+2:
- player->SEND_GOSSIP_MENU(GOSSIP_TEXTID_TROLLBANE2, creature->GetGUID());
- break;
- case GOSSIP_ACTION_INFO_DEF+3:
- player->SEND_GOSSIP_MENU(GOSSIP_TEXTID_TROLLBANE3, creature->GetGUID());
- break;
- }
-
- return true;
- }
+ private:
+ Creature* ryga;
+ };
- bool OnGossipHello(Player* player, Creature* creature) OVERRIDE
+ CreatureAI* GetAI(Creature* creature) const OVERRIDE
{
- if (creature->IsQuestGiver())
- player->PrepareQuestMenu(creature->GetGUID());
-
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TROLLBANE_ITEM1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TROLLBANE_ITEM3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3);
- player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID());
- return true;
+ return new npc_ancestral_wolfAI(creature);
}
};
@@ -358,8 +210,10 @@ enum WoundedBloodElf
SAY_ELF_SUMMON2 = 3,
SAY_ELF_COMPLETE = 4,
SAY_ELF_AGGRO = 5,
-
- QUEST_ROAD_TO_FALCON_WATCH = 9375
+ QUEST_ROAD_TO_FALCON_WATCH = 9375,
+ NPC_HAALESHI_WINDWALKER = 16966,
+ NPC_HAALESHI_TALONGUARD = 16967,
+ FACTION_FALCON_WATCH_QUEST = 775
};
class npc_wounded_blood_elf : public CreatureScript
@@ -367,28 +221,31 @@ class npc_wounded_blood_elf : public CreatureScript
public:
npc_wounded_blood_elf() : CreatureScript("npc_wounded_blood_elf") { }
- bool OnQuestAccept(Player* player, Creature* creature, Quest const* quest) OVERRIDE
+ struct npc_wounded_blood_elfAI : public npc_escortAI
{
- if (quest->GetQuestId() == QUEST_ROAD_TO_FALCON_WATCH)
- {
- if (npc_escortAI* pEscortAI = CAST_AI(npc_wounded_blood_elf::npc_wounded_blood_elfAI, creature->AI()))
- pEscortAI->Start(true, false, player->GetGUID());
+ npc_wounded_blood_elfAI(Creature* creature) : npc_escortAI(creature) { }
- // Change faction so mobs attack
- creature->setFaction(775);
- }
+ void Reset() OVERRIDE { }
- return true;
- }
+ void EnterCombat(Unit* /*who*/) OVERRIDE
+ {
+ if (HasEscortState(STATE_ESCORT_ESCORTING))
+ Talk(SAY_ELF_AGGRO);
+ }
- CreatureAI* GetAI(Creature* creature) const OVERRIDE
- {
- return new npc_wounded_blood_elfAI(creature);
- }
+ void JustSummoned(Creature* summoned) OVERRIDE
+ {
+ summoned->AI()->AttackStart(me);
+ }
- struct npc_wounded_blood_elfAI : public npc_escortAI
- {
- npc_wounded_blood_elfAI(Creature* creature) : npc_escortAI(creature) { }
+ void sQuestAccept(Player* player, Quest const* quest)
+ {
+ if (quest->GetQuestId() == QUEST_ROAD_TO_FALCON_WATCH)
+ {
+ me->setFaction(FACTION_FALCON_WATCH_QUEST);
+ npc_escortAI::Start(true, false, player->GetGUID());
+ }
+ }
void WaypointReached(uint32 waypointId) OVERRIDE
{
@@ -404,8 +261,8 @@ public:
case 9:
Talk(SAY_ELF_SUMMON1, player);
// Spawn two Haal'eshi Talonguard
- DoSpawnCreature(16967, -15, -15, 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
- DoSpawnCreature(16967, -17, -17, 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
+ DoSpawnCreature(NPC_HAALESHI_TALONGUARD, -15, -15, 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
+ DoSpawnCreature(NPC_HAALESHI_TALONGUARD, -17, -17, 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
break;
case 13:
Talk(SAY_ELF_RESTING, player);
@@ -413,8 +270,8 @@ public:
case 14:
Talk(SAY_ELF_SUMMON2, player);
// Spawn two Haal'eshi Windwalker
- DoSpawnCreature(16966, -15, -15, 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
- DoSpawnCreature(16966, -17, -17, 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
+ DoSpawnCreature(NPC_HAALESHI_WINDWALKER, -15, -15, 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
+ DoSpawnCreature(NPC_HAALESHI_WINDWALKER, -17, -17, 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
break;
case 27:
Talk(SAY_ELF_COMPLETE, player);
@@ -423,20 +280,12 @@ public:
break;
}
}
-
- void Reset() OVERRIDE { }
-
- void EnterCombat(Unit* /*who*/) OVERRIDE
- {
- if (HasEscortState(STATE_ESCORT_ESCORTING))
- Talk(SAY_ELF_AGGRO);
- }
-
- void JustSummoned(Creature* summoned) OVERRIDE
- {
- summoned->AI()->AttackStart(me);
- }
};
+
+ CreatureAI* GetAI(Creature* creature) const OVERRIDE
+ {
+ return new npc_wounded_blood_elfAI(creature);
+ }
};
/*######
@@ -445,9 +294,8 @@ public:
enum FelGuard
{
- SPELL_SUMMON_POO = 37688,
-
- NPC_DERANGED_HELBOAR = 16863
+ SPELL_SUMMON_POO = 37688,
+ NPC_DERANGED_HELBOAR = 16863
};
class npc_fel_guard_hound : public CreatureScript
@@ -455,32 +303,24 @@ class npc_fel_guard_hound : public CreatureScript
public:
npc_fel_guard_hound() : CreatureScript("npc_fel_guard_hound") { }
- CreatureAI* GetAI(Creature* creature) const OVERRIDE
- {
- return new npc_fel_guard_houndAI(creature);
- }
-
struct npc_fel_guard_houndAI : public ScriptedAI
{
npc_fel_guard_houndAI(Creature* creature) : ScriptedAI(creature) { }
- uint32 uiCheckTimer;
- uint64 uiHelboarGUID;
-
void Reset() OVERRIDE
{
- uiCheckTimer = 5000; //check for creature every 5 sec
- uiHelboarGUID = 0;
+ checkTimer = 5000; //check for creature every 5 sec
+ helboarGUID = 0;
}
- void MovementInform(uint32 uiType, uint32 uiId) OVERRIDE
+ void MovementInform(uint32 type, uint32 id) OVERRIDE
{
- if (uiType != POINT_MOTION_TYPE || uiId != 1)
+ if (type != POINT_MOTION_TYPE || id != 1)
return;
- if (Creature* pHelboar = me->GetCreature(*me, uiHelboarGUID))
+ if (Creature* helboar = me->GetCreature(*me, helboarGUID))
{
- pHelboar->RemoveCorpse();
+ helboar->RemoveCorpse();
DoCast(SPELL_SUMMON_POO);
if (Player* owner = me->GetCharmerOrOwnerPlayerOrPlayerItself())
@@ -488,36 +328,43 @@ public:
}
}
- void UpdateAI(uint32 uiDiff) OVERRIDE
+ void UpdateAI(uint32 diff) OVERRIDE
{
- if (uiCheckTimer <= uiDiff)
+ if (checkTimer <= diff)
{
- if (Creature* pHelboar = me->FindNearestCreature(NPC_DERANGED_HELBOAR, 10.0f, false))
+ if (Creature* helboar = me->FindNearestCreature(NPC_DERANGED_HELBOAR, 10.0f, false))
{
- if (pHelboar->GetGUID() != uiHelboarGUID && me->GetMotionMaster()->GetCurrentMovementGeneratorType() != POINT_MOTION_TYPE && !me->FindCurrentSpellBySpellId(SPELL_SUMMON_POO))
+ if (helboar->GetGUID() != helboarGUID && me->GetMotionMaster()->GetCurrentMovementGeneratorType() != POINT_MOTION_TYPE && !me->FindCurrentSpellBySpellId(SPELL_SUMMON_POO))
{
- uiHelboarGUID = pHelboar->GetGUID();
- me->GetMotionMaster()->MovePoint(1, pHelboar->GetPositionX(), pHelboar->GetPositionY(), pHelboar->GetPositionZ());
+ helboarGUID = helboar->GetGUID();
+ me->GetMotionMaster()->MovePoint(1, helboar->GetPositionX(), helboar->GetPositionY(), helboar->GetPositionZ());
}
}
- uiCheckTimer = 5000;
- }else uiCheckTimer -= uiDiff;
+ checkTimer = 5000;
+ }
+ else checkTimer -= diff;
if (!UpdateVictim())
return;
DoMeleeAttackIfReady();
}
+
+ private:
+ uint32 checkTimer;
+ uint64 helboarGUID;
};
+
+ CreatureAI* GetAI(Creature* creature) const OVERRIDE
+ {
+ return new npc_fel_guard_houndAI(creature);
+ }
};
void AddSC_hellfire_peninsula()
{
new npc_aeranas();
new npc_ancestral_wolf();
- new npc_naladu();
- new npc_tracy_proudwell();
- new npc_trollbane();
new npc_wounded_blood_elf();
new npc_fel_guard_hound();
}
diff --git a/src/server/scripts/Pet/pet_dk.cpp b/src/server/scripts/Pet/pet_dk.cpp
index 31a6af2fc1c..799aaf5d0a2 100644
--- a/src/server/scripts/Pet/pet_dk.cpp
+++ b/src/server/scripts/Pet/pet_dk.cpp
@@ -47,13 +47,14 @@ class npc_pet_dk_ebon_gargoyle : public CreatureScript
void InitializeAI() OVERRIDE
{
+ // Not needed to be despawned now
+ _despawnTimer = 0;
+
CasterAI::InitializeAI();
uint64 ownerGuid = me->GetOwnerGUID();
if (!ownerGuid)
return;
-
- // Not needed to be despawned now
- _despawnTimer = 0;
+
// Find victim of Summon Gargoyle spell
std::list<Unit*> targets;
Trinity::AnyUnfriendlyUnitInObjectRangeCheck u_check(me, me, 30.0f);
diff --git a/src/server/scripts/Pet/pet_mage.cpp b/src/server/scripts/Pet/pet_mage.cpp
index 85247b29f84..7ac50f4313c 100644
--- a/src/server/scripts/Pet/pet_mage.cpp
+++ b/src/server/scripts/Pet/pet_mage.cpp
@@ -49,7 +49,7 @@ class npc_pet_mage_mirror_image : public CreatureScript
// Inherit Master's Threat List (not yet implemented)
owner->CastSpell((Unit*)NULL, SPELL_MAGE_MASTERS_THREAT_LIST, true);
// here mirror image casts on summoner spell (not present in client dbc) 49866
- // here should be auras (not present in client dbc): 35657, 35658, 35659, 35660 selfcasted by mirror images (stats related?)
+ // here should be auras (not present in client dbc): 35657, 35658, 35659, 35660 selfcast by mirror images (stats related?)
// Clone Me!
owner->CastSpell(me, SPELL_MAGE_CLONE_ME, false);
}
diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp
index 14746fbcb6c..f418e98048b 100644
--- a/src/server/scripts/Spells/spell_generic.cpp
+++ b/src/server/scripts/Spells/spell_generic.cpp
@@ -536,20 +536,20 @@ class spell_gen_bonked : public SpellScriptLoader
+ EFFECT_0: SCRIPT_EFFECT
+ EFFECT_1: NONE
+ EFFECT_2: NONE
- - Spells casted by players triggered by script:
+ - Spells cast by players triggered by script:
+ EFFECT_0: SCHOOL_DAMAGE
+ EFFECT_1: SCRIPT_EFFECT
+ EFFECT_2: FORCE_CAST
- - Spells casted by NPCs on players:
+ - Spells cast by NPCs on players:
+ EFFECT_0: SCHOOL_DAMAGE
+ EFFECT_1: SCRIPT_EFFECT
+ EFFECT_2: NONE
In the following script we handle the SCRIPT_EFFECT for effIndex EFFECT_0 and EFFECT_1.
- When handling EFFECT_0 we're in the "Spells on vehicle bar used by players" case
- and we'll trigger "Spells casted by players triggered by script"
- - When handling EFFECT_1 we're in the "Spells casted by players triggered by script"
- or "Spells casted by NPCs on players" so we'll search for the first defend layer and drop it.
+ and we'll trigger "Spells cast by players triggered by script"
+ - When handling EFFECT_1 we're in the "Spells cast by players triggered by script"
+ or "Spells cast by NPCs on players" so we'll search for the first defend layer and drop it.
*/
enum BreakShieldSpells
@@ -1210,7 +1210,7 @@ class spell_gen_defend : public SpellScriptLoader
{
SpellInfo const* spell = sSpellMgr->GetSpellInfo(m_scriptSpellId);
- // Defend spells casted by NPCs (add visuals)
+ // Defend spells cast by NPCs (add visuals)
if (spell->Effects[EFFECT_0].ApplyAuraName == SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN)
{
AfterEffectApply += AuraEffectApplyFn(spell_gen_defend_AuraScript::RefreshVisualShields, EFFECT_0, SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK);
@@ -1221,7 +1221,7 @@ class spell_gen_defend : public SpellScriptLoader
if (spell->Effects[EFFECT_2].ApplyAuraName == SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN)
OnEffectRemove += AuraEffectRemoveFn(spell_gen_defend_AuraScript::RemoveDummyFromDriver, EFFECT_2, SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN, AURA_EFFECT_HANDLE_REAL);
- // Defend spells casted by players (add/remove visuals)
+ // Defend spells cast by players (add/remove visuals)
if (spell->Effects[EFFECT_1].ApplyAuraName == SPELL_AURA_DUMMY)
{
AfterEffectApply += AuraEffectApplyFn(spell_gen_defend_AuraScript::RefreshVisualShields, EFFECT_1, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK);
@@ -1872,15 +1872,15 @@ class spell_gen_lifebloom : public SpellScriptLoader
+ EFFECT_0: SCRIPT_EFFECT
+ EFFECT_1: TRIGGER_SPELL
+ EFFECT_2: NONE
- - Spells casted by player's mounts triggered by script:
+ - Spells cast by player's mounts triggered by script:
+ EFFECT_0: CHARGE
+ EFFECT_1: TRIGGER_SPELL
+ EFFECT_2: APPLY_AURA
- - Spells casted by players on the target triggered by script:
+ - Spells cast by players on the target triggered by script:
+ EFFECT_0: SCHOOL_DAMAGE
+ EFFECT_1: SCRIPT_EFFECT
+ EFFECT_2: NONE
- - Spells casted by NPCs on players:
+ - Spells cast by NPCs on players:
+ EFFECT_0: SCHOOL_DAMAGE
+ EFFECT_1: CHARGE
+ EFFECT_2: SCRIPT_EFFECT
@@ -1888,12 +1888,12 @@ class spell_gen_lifebloom : public SpellScriptLoader
In the following script we handle the SCRIPT_EFFECT and CHARGE
- When handling SCRIPT_EFFECT:
+ EFFECT_0: Corresponds to "Spells on vehicle bar used by players" and we make player's mount cast
- the charge effect on the current target ("Spells casted by player's mounts triggered by script").
- + EFFECT_1 and EFFECT_2: Triggered when "Spells casted by player's mounts triggered by script" hits target,
- corresponding to "Spells casted by players on the target triggered by script" and "Spells casted by
+ the charge effect on the current target ("Spells cast by player's mounts triggered by script").
+ + EFFECT_1 and EFFECT_2: Triggered when "Spells cast by player's mounts triggered by script" hits target,
+ corresponding to "Spells cast by players on the target triggered by script" and "Spells cast by
NPCs on players" and we check Defend layers and drop a charge of the first found.
- When handling CHARGE:
- + Only launched for "Spells casted by player's mounts triggered by script", makes the player cast the
+ + Only launched for "Spells cast by player's mounts triggered by script", makes the player cast the
damaging spell on target with a small chance of failing it.
*/
diff --git a/src/server/scripts/Spells/spell_quest.cpp b/src/server/scripts/Spells/spell_quest.cpp
index 92a18a654d5..cfb43e8a3f8 100644
--- a/src/server/scripts/Spells/spell_quest.cpp
+++ b/src/server/scripts/Spells/spell_quest.cpp
@@ -1367,7 +1367,7 @@ class spell_q12372_destabilize_azure_dragonshrine_dummy : public SpellScriptLoad
}
};
-// ID - 50287 Azure Dragon: On Death Force Cast Wyrmrest Defender to Whisper to Controller - Random (casted from Azure Dragons and Azure Drakes on death)
+// ID - 50287 Azure Dragon: On Death Force Cast Wyrmrest Defender to Whisper to Controller - Random (cast from Azure Dragons and Azure Drakes on death)
class spell_q12372_azure_on_death_force_whisper : public SpellScriptLoader
{
public:
diff --git a/src/server/scripts/World/guards.cpp b/src/server/scripts/World/guards.cpp
index 5ba95dca199..b629fd06b32 100644
--- a/src/server/scripts/World/guards.cpp
+++ b/src/server/scripts/World/guards.cpp
@@ -106,7 +106,7 @@ public:
return;
// Make sure our attack is ready and we arn't currently casting
- if (me->isAttackReady() && !me->IsNonMeleeSpellCasted(false))
+ if (me->isAttackReady() && !me->IsNonMeleeSpellCast(false))
{
//If we are within range melee the target
if (me->IsWithinMeleeRange(me->GetVictim()))
@@ -145,7 +145,7 @@ public:
else
{
//Only run this code if we arn't already casting
- if (!me->IsNonMeleeSpellCasted(false))
+ if (!me->IsNonMeleeSpellCast(false))
{
bool healing = false;
SpellInfo const* info = NULL;
diff --git a/src/server/scripts/World/mob_generic_creature.cpp b/src/server/scripts/World/mob_generic_creature.cpp
index ed086712ca2..5cc9e68eb9b 100644
--- a/src/server/scripts/World/mob_generic_creature.cpp
+++ b/src/server/scripts/World/mob_generic_creature.cpp
@@ -93,7 +93,7 @@ public:
if (me->IsWithinMeleeRange(me->GetVictim()))
{
//Make sure our attack is ready and we arn't currently casting
- if (me->isAttackReady() && !me->IsNonMeleeSpellCasted(false))
+ if (me->isAttackReady() && !me->IsNonMeleeSpellCast(false))
{
bool Healing = false;
SpellInfo const* info = NULL;
@@ -124,7 +124,7 @@ public:
else
{
//Only run this code if we arn't already casting
- if (!me->IsNonMeleeSpellCasted(false))
+ if (!me->IsNonMeleeSpellCast(false))
{
bool Healing = false;
SpellInfo const* info = NULL;
diff --git a/src/server/shared/Database/Field.cpp b/src/server/shared/Database/Field.cpp
index 51d918e716e..87151f7a9be 100644
--- a/src/server/shared/Database/Field.cpp
+++ b/src/server/shared/Database/Field.cpp
@@ -35,7 +35,7 @@ void Field::SetByteValue(const void* newValue, const size_t newSize, enum_field_
if (data.value)
CleanUp();
- // This value stores raw bytes that have to be explicitly casted later
+ // This value stores raw bytes that have to be explicitly cast later
if (newValue)
{
data.value = new char[newSize];
diff --git a/src/server/worldserver/Master.cpp b/src/server/worldserver/Master.cpp
index 3fcd4c28f0f..eebf46f3831 100644
--- a/src/server/worldserver/Master.cpp
+++ b/src/server/worldserver/Master.cpp
@@ -251,7 +251,7 @@ int Master::Run()
{
CPU_ZERO(&mask);
sched_getaffinity(0, sizeof(mask), &mask);
- TC_LOG_INFO("server.worldserver", "Using processors (bitmask, hex): %x", *(uint32*)(&mask));
+ TC_LOG_INFO("server.worldserver", "Using processors (bitmask, hex): %lx", *(__cpu_mask*)(&mask));
}
}
diff --git a/src/tools/CMakeLists.txt b/src/tools/CMakeLists.txt
index 09f23b844cf..db338711d08 100644
--- a/src/tools/CMakeLists.txt
+++ b/src/tools/CMakeLists.txt
@@ -11,7 +11,8 @@
add_subdirectory(map_extractor)
add_subdirectory(vmap4_assembler)
add_subdirectory(vmap4_extractor)
-add_subdirectory(mmaps_generator)
#if (WITH_MESHEXTRACTOR)
# add_subdirectory(mesh_extractor)
+#else()
+# add_subdirectory(mmaps_generator)
#endif()
diff --git a/src/tools/mesh_extractor/ADT.cpp b/src/tools/mesh_extractor/ADT.cpp
index a32276f9856..ee7e1b12b44 100644
--- a/src/tools/mesh_extractor/ADT.cpp
+++ b/src/tools/mesh_extractor/ADT.cpp
@@ -25,7 +25,7 @@ ADT::ADT( std::string file, int x, int y ) : ObjectData(NULL), Data(NULL), HasOb
{
Data = new ChunkedData(file);
ObjectData = new ChunkedData(file);
- if (ObjectData->Stream)
+ if (ObjectData->_Stream)
HasObjectData = true;
else
ObjectData = NULL;
@@ -33,6 +33,11 @@ ADT::ADT( std::string file, int x, int y ) : ObjectData(NULL), Data(NULL), HasOb
ADT::~ADT()
{
+ // Temporarily delete the underlying streams, they are guaranteed to be different
+ // @TODO: Remove this code once the ChunkedData destructor properly releases _Stream
+ delete ObjectData->_Stream;
+ delete Data->_Stream;
+
delete ObjectData;
delete Data;
diff --git a/src/tools/mesh_extractor/CMakeLists.txt b/src/tools/mesh_extractor/CMakeLists.txt
index 9ed8472051d..f5dbb0fd7ff 100644
--- a/src/tools/mesh_extractor/CMakeLists.txt
+++ b/src/tools/mesh_extractor/CMakeLists.txt
@@ -47,4 +47,4 @@ if( UNIX )
install(TARGETS MeshExtractor DESTINATION bin)
elseif( WIN32 )
install(TARGETS MeshExtractor DESTINATION "${CMAKE_INSTALL_PREFIX}")
-endif()
+endif() \ No newline at end of file
diff --git a/src/tools/mesh_extractor/Cache.h b/src/tools/mesh_extractor/Cache.h
index 017b4c53f72..75496b5364d 100644
--- a/src/tools/mesh_extractor/Cache.h
+++ b/src/tools/mesh_extractor/Cache.h
@@ -31,24 +31,18 @@ class GenericCache
public:
GenericCache() {}
- static const uint32 FlushLimit = 300; // We can't get too close to filling up all the memory, and we have to be wary of the maximum number of open streams.
-
- void Insert(K key, T* val)
- {
- ACE_GUARD(ACE_Thread_Mutex, g, mutex);
-
- if (_items.size() > FlushLimit)
- Clear();
- _items[key] = val;
- }
-
- T* Get(K key)
+ T const* Get(K key)
{
ACE_GUARD_RETURN(ACE_Thread_Mutex, g, mutex, NULL);
typename std::map<K, T*>::iterator itr = _items.find(key);
if (itr != _items.end())
return itr->second;
- return NULL;
+ else
+ {
+ T* t = new T(key); // Create the object
+ _items[key] = t;
+ return t;
+ }
}
void Clear()
diff --git a/src/tools/mesh_extractor/Chunk.cpp b/src/tools/mesh_extractor/Chunk.cpp
index 42eb9e14881..bc6d9b66b96 100644
--- a/src/tools/mesh_extractor/Chunk.cpp
+++ b/src/tools/mesh_extractor/Chunk.cpp
@@ -25,24 +25,24 @@ int32 Chunk::FindSubChunkOffset(std::string name)
if (name.size() != 4)
return -1;
- FILE* stream = GetStream();
+ Stream* stream = GetStream();
uint32 matched = 0;
- while (uint32(ftell(stream)) < Utils::Size(stream))
+ while (stream->GetPos() < stream->GetSize())
{
- char b = 0;
- if (fread(&b, sizeof(char), 1, stream) != 1 || b != name[matched])
+ char b = stream->Read<char>();
+ if (b != name[matched])
matched = 0;
else
++matched;
if (matched == 4)
- return ftell(stream) - 4;
+ return stream->GetPos() - 4;
}
return -1;
}
-FILE* Chunk::GetStream()
+Stream* Chunk::GetStream()
{
- fseek(Stream, Offset, SEEK_SET);
- return Stream;
+ _Stream->Seek(Offset, SEEK_SET);
+ return _Stream;
}
diff --git a/src/tools/mesh_extractor/Chunk.h b/src/tools/mesh_extractor/Chunk.h
index 0641eb1dc3c..95d06efe206 100644
--- a/src/tools/mesh_extractor/Chunk.h
+++ b/src/tools/mesh_extractor/Chunk.h
@@ -19,19 +19,21 @@
#define CHUNK_H
#include "Define.h"
#include <string>
+#include "Stream.h"
+
class ChunkedData;
class Chunk
{
public:
- Chunk(const char* name, uint32 length, uint32 offset, FILE* stream) : Name(name), Length(length), Offset(offset), Stream(stream) {}
+ Chunk(const char* name, uint32 length, uint32 offset, Stream* stream) : Name(name), Length(length), Offset(offset), _Stream(stream) {}
int32 FindSubChunkOffset(std::string name);
- FILE* GetStream();
+ Stream* GetStream();
std::string Name;
uint32 Length;
uint32 Offset;
- FILE* Stream;
+ Stream* _Stream;
};
#endif \ No newline at end of file
diff --git a/src/tools/mesh_extractor/ChunkedData.cpp b/src/tools/mesh_extractor/ChunkedData.cpp
index 1330e4b47f9..b288b5712cd 100644
--- a/src/tools/mesh_extractor/ChunkedData.cpp
+++ b/src/tools/mesh_extractor/ChunkedData.cpp
@@ -21,18 +21,18 @@
#include <string>
-ChunkedData::ChunkedData( FILE* stream, uint32 maxLength, uint32 chunksHint /*= 300*/ ) :
-Stream(stream)
+ChunkedData::ChunkedData(Stream* stream, uint32 maxLength, uint32 chunksHint /*= 300*/ ) :
+_Stream(stream)
{
- if (!Stream)
+ if (!_Stream)
return;
Load(maxLength, chunksHint);
}
ChunkedData::ChunkedData( const std::string& file, uint32 chunksHint /*= 300*/ )
{
- Stream = MPQHandler->GetFile(file);
- if (!Stream)
+ _Stream = MPQHandler->GetFile(file);
+ if (!_Stream)
return;
Load(0, chunksHint);
}
@@ -40,31 +40,30 @@ ChunkedData::ChunkedData( const std::string& file, uint32 chunksHint /*= 300*/ )
void ChunkedData::Load( uint32 maxLength, uint32 chunksHint )
{
if (!maxLength)
- maxLength = Utils::Size(Stream);
+ maxLength = _Stream->GetSize();
Chunks.reserve(chunksHint);
- uint32 baseOffset = ftell(Stream);
+ uint32 baseOffset = _Stream->GetPos();
uint32 calcOffset = 0;
- while ((calcOffset + baseOffset) < Utils::Size(Stream) && (calcOffset < maxLength))
+ while ((calcOffset + baseOffset) < _Stream->GetSize() && (calcOffset < maxLength))
{
char nameBytes[5];
- uint32 read = fread(&nameBytes, sizeof(char), 4, Stream);
- nameBytes[read] = '\0';
+ _Stream->Read(nameBytes, sizeof(char) * 4);
+ nameBytes[4] = '\0';
std::string name = std::string(nameBytes);
- // Utils::Reverse(nameBytes);
name = std::string(name.rbegin(), name.rend());
- uint32 length;
- if (fread(&length, sizeof(uint32), 1, Stream) != 1)
- continue;
+
+ uint32 length = _Stream->Read<uint32>();
calcOffset += 8;
- Chunks.push_back(new Chunk(name.c_str(), length, calcOffset + baseOffset, Stream));
+
+ Chunks.push_back(new Chunk(name.c_str(), length, calcOffset + baseOffset, _Stream));
calcOffset += length;
// save an extra seek at the end
- if ((calcOffset + baseOffset) < Utils::Size(Stream) && calcOffset < maxLength)
- fseek(Stream, length, SEEK_CUR);
+ if ((calcOffset + baseOffset) < _Stream->GetSize() && calcOffset < maxLength)
+ _Stream->Seek(length, SEEK_CUR);
}
}
-int ChunkedData::GetFirstIndex( const std::string& name )
+int ChunkedData::GetFirstIndex( const std::string& name ) const
{
for (uint32 i = 0; i < Chunks.size(); ++i)
if (Chunks[i]->Name == name)
@@ -86,6 +85,7 @@ ChunkedData::~ChunkedData()
delete *itr;
Chunks.clear();
- if (Stream)
- fclose(Stream);
+ /* WorldModelGroup Data and SubData share the same _Stream so it's deleted twice and it crashes
+ if (_Stream)
+ delete _Stream;*/
}
diff --git a/src/tools/mesh_extractor/ChunkedData.h b/src/tools/mesh_extractor/ChunkedData.h
index 5befdf30dd1..112bdb47199 100644
--- a/src/tools/mesh_extractor/ChunkedData.h
+++ b/src/tools/mesh_extractor/ChunkedData.h
@@ -20,19 +20,20 @@
#include <vector>
#include "Chunk.h"
+#include "Stream.h"
class ChunkedData
{
public:
- ChunkedData(FILE* stream, uint32 maxLength, uint32 chunksHint = 300);
+ ChunkedData(Stream* stream, uint32 maxLength, uint32 chunksHint = 300);
ChunkedData(const std::string &file, uint32 chunksHint = 300);
~ChunkedData();
- int GetFirstIndex(const std::string& name);
+ int GetFirstIndex(const std::string& name) const;
Chunk* GetChunkByName(const std::string& name);
void Load(uint32 maxLength, uint32 chunksHint);
std::vector<Chunk*> Chunks;
- FILE* Stream;
+ Stream* _Stream;
};
#endif \ No newline at end of file
diff --git a/src/tools/mesh_extractor/Constants.h b/src/tools/mesh_extractor/Constants.h
index 5a89be9fe9c..7d9d6f92b92 100644
--- a/src/tools/mesh_extractor/Constants.h
+++ b/src/tools/mesh_extractor/Constants.h
@@ -26,6 +26,8 @@ public:
TRIANGLE_TYPE_UNKNOWN,
TRIANGLE_TYPE_TERRAIN,
TRIANGLE_TYPE_WATER,
+ TRIANGLE_TYPE_MAGMA,
+ TRIANGLE_TYPE_SLIME,
TRIANGLE_TYPE_DOODAD,
TRIANGLE_TYPE_WMO
};
diff --git a/src/tools/mesh_extractor/ContinentBuilder.cpp b/src/tools/mesh_extractor/ContinentBuilder.cpp
index 841d7a608e4..9e64e7a1b05 100644
--- a/src/tools/mesh_extractor/ContinentBuilder.cpp
+++ b/src/tools/mesh_extractor/ContinentBuilder.cpp
@@ -16,80 +16,21 @@
*/
#include "ContinentBuilder.h"
-#include "TileBuilder.h"
#include "WDT.h"
#include "Utils.h"
#include "DetourNavMesh.h"
#include "Cache.h"
-#include "ace/Task.h"
#include "Recast.h"
#include "DetourCommon.h"
-class BuilderThread : public ACE_Task_Base
-{
-private:
- int X, Y, MapId;
- std::string Continent;
- dtNavMeshParams Params;
- ContinentBuilder* cBuilder;
-public:
- BuilderThread(ContinentBuilder* _cBuilder, dtNavMeshParams& params) : Params(params), cBuilder(_cBuilder), Free(true) {}
-
- void SetData(int x, int y, int map, const std::string& cont)
- {
- X = x;
- Y = y;
- MapId = map;
- Continent = cont;
- }
-
- int svc()
- {
- Free = false;
- printf("[%02i,%02i] Building tile\n", X, Y);
- TileBuilder builder(cBuilder, Continent, X, Y, MapId);
- char buff[100];
- sprintf(buff, "mmaps/%03u%02i%02i.mmtile", MapId, Y, X);
- FILE* f = fopen(buff, "r");
- if (f) // Check if file already exists.
- {
- printf("[%02i,%02i] Tile skipped, file already exists\n", X, Y);
- fclose(f);
- Free = true;
- return 0;
- }
- uint8* nav = builder.BuildTiled(Params);
- if (nav)
- {
- f = fopen(buff, "wb");
- if (!f)
- {
- printf("Could not create file %s. Check that you have write permissions to the destination folder and try again\n", buff);
- return 0;
- }
- MmapTileHeader header;
- header.size = builder.DataSize;
- fwrite(&header, sizeof(MmapTileHeader), 1, f);
- fwrite(nav, sizeof(unsigned char), builder.DataSize, f);
- fclose(f);
- }
- dtFree(nav);
- printf("[%02i,%02i] Tile Built!\n", X, Y);
- Free = true;
- return 0;
- }
-
- bool Free;
-};
-
-void ContinentBuilder::getTileBounds(uint32 tileX, uint32 tileY, float* verts, int vertCount, float* bmin, float* bmax)
+void ContinentBuilder::getTileBounds(uint32 tileX, uint32 tileY, float* verts, int vertCount, float* bmin, float* bmax) const
{
// this is for elevation
if (verts && vertCount)
rcCalcBounds(verts, vertCount, bmin, bmax);
else
{
- bmin[1] = FLT_MIN;
+ bmin[1] = -FLT_MAX;
bmax[1] = FLT_MAX;
}
@@ -128,8 +69,6 @@ void ContinentBuilder::Build()
dtNavMeshParams params;
- std::vector<BuilderThread*> Threads;
-
if (TileMap->IsGlobalModel)
{
printf("Map %s ( %u ) is a WMO. Building with 1 thread.\n", Continent.c_str(), MapId);
@@ -159,6 +98,7 @@ void ContinentBuilder::Build()
}
MmapTileHeader mheader;
+ Utils::InitializeMmapTileHeader(mheader);
mheader.size = builder->DataSize;
fwrite(&mheader, sizeof(MmapTileHeader), 1, f);
fwrite(nav, sizeof(unsigned char), builder->DataSize, f);
@@ -170,44 +110,70 @@ void ContinentBuilder::Build()
}
else
{
- params.maxPolys = 32768;
- params.maxTiles = 4096;
+ params.maxPolys = 1024;
+ params.maxTiles = TileMap->TileTable.size();
rcVcopy(params.orig, Constants::Origin);
params.tileHeight = Constants::TileSize;
params.tileWidth = Constants::TileSize;
fwrite(&params, sizeof(dtNavMeshParams), 1, mmap);
fclose(mmap);
- for (uint32 i = 0; i < NumberOfThreads; ++i)
- Threads.push_back(new BuilderThread(this, params));
+ std::vector<BuilderThread*> _threads;
+ BuilderThreadPool* pool = NumberOfThreads > 0 ? new BuilderThreadPool() : NULL;
+
printf("Map %s ( %u ) has %u tiles. Building them with %u threads\n", Continent.c_str(), MapId, uint32(TileMap->TileTable.size()), NumberOfThreads);
+
for (std::vector<TilePos>::iterator itr = TileMap->TileTable.begin(); itr != TileMap->TileTable.end(); ++itr)
+ pool->Enqueue(new TileBuildRequest(this, Continent, itr->X, itr->Y, MapId, params));
+
+ for (uint32 i = 0; i < NumberOfThreads; ++i)
+ _threads.push_back(new BuilderThread(this, pool->Queue()));
+
+ // Free memory
+ for (std::vector<BuilderThread*>::iterator _th = _threads.begin(); _th != _threads.end(); ++_th)
{
- bool next = false;
- while (!next)
- {
- for (std::vector<BuilderThread*>::iterator _th = Threads.begin(); _th != Threads.end(); ++_th)
- {
- if ((*_th)->Free)
- {
- (*_th)->SetData(itr->X, itr->Y, MapId, Continent);
- (*_th)->activate();
- next = true;
- break;
- }
- }
- // Wait for 20 seconds
- ACE_OS::sleep(ACE_Time_Value (0, 20000));
- }
+ (*_th)->wait();
+ delete *_th;
}
+
+ delete pool;
}
Cache->Clear();
+}
- // Free memory
- for (std::vector<BuilderThread*>::iterator _th = Threads.begin(); _th != Threads.end(); ++_th)
+int TileBuildRequest::call()
+{
+ printf("[%02i,%02i] Building tile\n", X, Y);
+ // Build the tile and return negative on error
+ TileBuilder tile(_builder, _continent, X, Y, _mapId);
+ char buff[100];
+ sprintf(buff, "mmaps/%03u%02i%02i.mmtile", _mapId, Y, X);
+ FILE* f = fopen(buff, "r");
+ if (f) // Check if file already exists.
{
- (*_th)->wait();
- delete *_th;
+ printf("[%02i,%02i] Tile skipped, file already exists\n", X, Y);
+ fclose(f);
+ return 0;
+ }
+ uint8* nav = tile.BuildTiled(_params);
+ if (nav)
+ {
+ f = fopen(buff, "wb");
+ if (!f)
+ {
+ printf("Could not create file %s. Check that you have write permissions to the destination folder and try again\n", buff);
+ dtFree(nav);
+ return -1;
+ }
+ MmapTileHeader header;
+ Utils::InitializeMmapTileHeader(header);
+ header.size = tile.DataSize;
+ fwrite(&header, sizeof(MmapTileHeader), 1, f);
+ fwrite(nav, sizeof(unsigned char), tile.DataSize, f);
+ fclose(f);
}
+ dtFree(nav);
+ printf("[%02i,%02i] Tile Built!\n", X, Y);
+ return 0;
}
diff --git a/src/tools/mesh_extractor/ContinentBuilder.h b/src/tools/mesh_extractor/ContinentBuilder.h
index 5349b8e1ba5..249fad05eb1 100644
--- a/src/tools/mesh_extractor/ContinentBuilder.h
+++ b/src/tools/mesh_extractor/ContinentBuilder.h
@@ -17,9 +17,15 @@
#ifndef CONT_BUILDER_H
#define CONT_BUILDER_H
+
#include <string>
#include "WDT.h"
#include "Define.h"
+#include "TileBuilder.h"
+
+#include <ace/Task.h>
+#include <ace/Activation_Queue.h>
+#include <ace/Method_Request.h>
class ContinentBuilder
{
@@ -30,7 +36,7 @@ public:
{}
void Build();
- void getTileBounds(uint32 tileX, uint32 tileY, float* verts, int vertCount, float* bmin, float* bmax);
+ void getTileBounds(uint32 tileX, uint32 tileY, float* verts, int vertCount, float* bmin, float* bmax) const;
void CalculateTileBounds();
float bmin[3];
float bmax[3];
@@ -44,4 +50,61 @@ private:
int tileXMax;
int tileYMax;
};
+
+class TileBuildRequest : public ACE_Method_Request
+{
+public:
+ TileBuildRequest(ContinentBuilder* builder, std::string& continent, uint32 x, uint32 y, uint32 mapId, dtNavMeshParams& params) : _mapId(mapId), _builder(builder), _continent(continent), X(x), Y(y), _params(params) { }
+
+ virtual int call();
+
+private:
+ uint32 _mapId;
+ ContinentBuilder* _builder;
+ std::string& _continent;
+ uint32 X;
+ uint32 Y;
+ dtNavMeshParams& _params;
+};
+
+class BuilderThreadPool
+{
+public:
+ BuilderThreadPool() : _queue(new ACE_Activation_Queue()) {}
+ ~BuilderThreadPool() { _queue->queue()->close(); delete _queue; }
+
+ void Enqueue(TileBuildRequest* request)
+ {
+ _queue->enqueue(request);
+ }
+
+ ACE_Activation_Queue* Queue() { return _queue; }
+
+private:
+ ACE_Activation_Queue* _queue;
+};
+
+class BuilderThread : public ACE_Task_Base
+{
+private:
+ ContinentBuilder* _builder;
+ ACE_Activation_Queue* _queue;
+public:
+ BuilderThread(ContinentBuilder* builder, ACE_Activation_Queue* queue) : _builder(builder), _queue(queue) { activate(); }
+
+ int svc()
+ {
+ /// @ Set a timeout for dequeue attempts (only used when the queue is empty) as it will never get populated after thread starts
+ ACE_Time_Value timeout(5);
+ ACE_Method_Request* request = NULL;
+ while ((request = _queue->dequeue(&timeout)) != NULL)
+ {
+ request->call();
+ delete request;
+ request = NULL;
+ }
+ return 0;
+ }
+};
+
#endif
diff --git a/src/tools/mesh_extractor/DBC.cpp b/src/tools/mesh_extractor/DBC.cpp
index 9249e320563..5bebc34a389 100644
--- a/src/tools/mesh_extractor/DBC.cpp
+++ b/src/tools/mesh_extractor/DBC.cpp
@@ -19,19 +19,15 @@
#include "DBC.h"
#include "Define.h"
-DBC::DBC( FILE* stream ) : StringBlock(NULL), StringBlockSize(0), IsFaulty(true)
+DBC::DBC(Stream* stream) : StringBlock(NULL), StringBlockSize(0), IsFaulty(true)
{
- char magic[5];
- uint32 count = 0;
- count += fread(&magic, sizeof(char), 4, stream);
- magic[4] = '\0';
- count += fread(&RecordCount, sizeof(uint32), 1, stream);
+ delete[] stream->Read(4); // Read the magic "WDBC"
+
+ RecordCount = stream->Read<int>();
Records.reserve(RecordCount);
- count += fread(&Fields, sizeof(uint32), 1, stream);
- count += fread(&RecordSize, sizeof(uint32), 1, stream);
- count += fread(&StringBlockSize, sizeof(uint32), 1, stream);
- if (count != 8)
- printf("DBC::DBC: Failed to read some data expected 8, read %u\n", count);
+ Fields = stream->Read<int>();
+ RecordSize = stream->Read<int>();
+ StringBlockSize = stream->Read<uint32>();
for (int i = 0; i < RecordCount; i++)
{
@@ -45,20 +41,21 @@ DBC::DBC( FILE* stream ) : StringBlock(NULL), StringBlockSize(0), IsFaulty(true)
IsFaulty = true;
break;
}
- uint32 tmp;
- if (fread(&tmp, sizeof(uint32), 1, stream) != 1)
- printf("DBC::DBC: Failed to read some data expected 1, read 0\n");
- rec->Values.push_back(tmp);
+ rec->Values.push_back(stream->Read<uint32>());
size += 4;
}
}
- StringBlock = new uint8[StringBlockSize];
- count = fread(StringBlock, sizeof(uint8), StringBlockSize, stream);
- if (count != StringBlockSize)
- printf("DBC::DBC: Failed to read some data expected %u, read %u\n", StringBlockSize, count);
+ StringBlock = (uint8*)stream->Read(StringBlockSize);
+}
+
+DBC::~DBC()
+{
+ delete[] StringBlock;
+ for (std::vector<Record*>::iterator itr = Records.begin(); itr != Records.end(); ++itr)
+ delete *itr;
}
-std::string DBC::GetStringByOffset( int offset )
+std::string DBC::GetStringByOffset( int offset ) const
{
int len = 0;
for (uint32 i = offset; i < StringBlockSize; i++)
@@ -73,14 +70,14 @@ std::string DBC::GetStringByOffset( int offset )
strcpy(d, (const char*)(StringBlock + offset));
d[len] = '\0';
std::string val = std::string(d);
- delete [] d;
+ delete[] d;
return val;
}
-Record* DBC::GetRecordById( int id )
+Record const* DBC::GetRecordById( int id ) const
{
// we assume Id is index 0
- for (std::vector<Record*>::iterator itr = Records.begin(); itr != Records.end(); ++itr)
+ for (std::vector<Record*>::const_iterator itr = Records.begin(); itr != Records.end(); ++itr)
if ((*itr)->Values[0] == id)
return *itr;
return NULL;
diff --git a/src/tools/mesh_extractor/DBC.h b/src/tools/mesh_extractor/DBC.h
index 0d3b85d8c78..33f5437ebe2 100644
--- a/src/tools/mesh_extractor/DBC.h
+++ b/src/tools/mesh_extractor/DBC.h
@@ -20,17 +20,19 @@
#include <vector>
#include <string>
#include "Define.h"
+#include "Stream.h"
class Record;
class DBC
{
public:
- DBC(FILE* stream);
+ DBC(Stream* stream);
+ ~DBC();
- std::string GetStringByOffset(int offset);
+ std::string GetStringByOffset(int offset) const;
- Record* GetRecordById(int id);
+ Record const* GetRecordById(int id) const;
std::string Name;
std::vector<Record*> Records;
@@ -50,18 +52,18 @@ public:
DBC* Source;
std::vector<int> Values;
- int operator[](int index)
+ int operator[](int index) const
{
return Values[index];
}
template <typename T>
- T GetValue(int index)
+ T GetValue(int index) const
{
return *(T*)(&Values[index]);
}
- std::string GetString(int index)
+ const std::string GetString(int index) const
{
return Source->GetStringByOffset(Values[index]);
}
diff --git a/src/tools/mesh_extractor/DoodadHandler.cpp b/src/tools/mesh_extractor/DoodadHandler.cpp
index 2e0743134d4..5363855740e 100644
--- a/src/tools/mesh_extractor/DoodadHandler.cpp
+++ b/src/tools/mesh_extractor/DoodadHandler.cpp
@@ -34,20 +34,18 @@ DoodadHandler::DoodadHandler( ADT* adt ) :
ReadDoodadPaths(mmid, mmdx);
}
-void DoodadHandler::ProcessInternal( MapChunk* mcnk )
+void DoodadHandler::ProcessInternal(MapChunk* mcnk)
{
if (!IsSane())
return;
uint32 refCount = mcnk->Header.DoodadRefs;
- FILE* stream = mcnk->Source->GetStream();
- fseek(stream, mcnk->Source->Offset + mcnk->Header.OffsetMCRF, SEEK_SET);
+ Stream* stream = mcnk->Source->GetStream();
+ stream->Seek(mcnk->Source->Offset + mcnk->Header.OffsetMCRF, SEEK_SET);
+
for (uint32 i = 0; i < refCount; i++)
{
- int32 index;
- int32 count;
- if ((count = fread(&index, sizeof(int32), 1, stream)) != 1)
- printf("DoodadHandler::ProcessInternal: Failed to read some data expected 1, read %d\n", count);
+ int32 index = stream->Read<int32>();
if (index < 0 || uint32(index) >= _definitions->size())
continue;
DoodadDefinition doodad = (*_definitions)[index];
@@ -58,12 +56,7 @@ void DoodadHandler::ProcessInternal( MapChunk* mcnk )
continue;
std::string path = (*_paths)[doodad.MmidIndex];
- Model* model = Cache->ModelCache.Get(path);
- if (!model)
- {
- model = new Model(path);
- Cache->ModelCache.Insert(path, model);
- }
+ Model const* model = Cache->ModelCache.Get(path);
if (!model->IsCollidable)
continue;
@@ -73,7 +66,7 @@ void DoodadHandler::ProcessInternal( MapChunk* mcnk )
InsertModelGeometry(doodad, model);
}
// Restore the stream position
- fseek(stream, mcnk->Source->Offset, SEEK_SET);
+ stream->Seek(mcnk->Source->Offset, SEEK_SET);
}
void DoodadHandler::ReadDoodadDefinitions( Chunk* chunk )
@@ -81,7 +74,7 @@ void DoodadHandler::ReadDoodadDefinitions( Chunk* chunk )
int32 count = chunk->Length / 36;
_definitions = new std::vector<DoodadDefinition>;
_definitions->reserve(count);
- FILE* stream = chunk->GetStream();
+ Stream* stream = chunk->GetStream();
for (int i = 0; i < count; i++)
{
DoodadDefinition def;
@@ -97,25 +90,24 @@ void DoodadHandler::ReadDoodadPaths( Chunk* id, Chunk* data )
_paths->reserve(paths);
for (int i = 0; i < paths; i++)
{
- FILE* idStream = id->GetStream();
- fseek(idStream, i * 4, SEEK_CUR);
- uint32 offset;
- if (fread(&offset, sizeof(uint32), 1, idStream) != 1)
- printf("DoodadHandler::ReadDoodadPaths: Failed to read some data expected 1, read 0\n");
- FILE* dataStream = data->GetStream();
- fseek(dataStream, offset + data->Offset, SEEK_SET);
- _paths->push_back(Utils::ReadString(dataStream));
+ Stream* idStream = id->GetStream();
+ idStream->Seek(i * 4, SEEK_CUR);
+ uint32 offset = idStream->Read<uint32>();
+
+ Stream* dataStream = data->GetStream();
+ dataStream->Seek(offset + data->Offset, SEEK_SET);
+ _paths->push_back(dataStream->ReadString());
}
}
-void DoodadHandler::InsertModelGeometry(const DoodadDefinition& def, Model* model)
+void DoodadHandler::InsertModelGeometry(const DoodadDefinition& def, Model const* model)
{
uint32 vertOffset = Vertices.size();
- for (std::vector<Vector3>::iterator itr = model->Vertices.begin(); itr != model->Vertices.end(); ++itr)
+ for (std::vector<Vector3>::const_iterator itr = model->Vertices.begin(); itr != model->Vertices.end(); ++itr)
Vertices.push_back(Utils::TransformDoodadVertex(def, *itr)); // Vertices have to be converted based on the information from the DoodadDefinition struct
- for (std::vector<Triangle<uint16> >::iterator itr = model->Triangles.begin(); itr != model->Triangles.end(); ++itr)
+ for (std::vector<Triangle<uint16> >::const_iterator itr = model->Triangles.begin(); itr != model->Triangles.end(); ++itr)
Triangles.push_back(Triangle<uint32>(Constants::TRIANGLE_TYPE_DOODAD, itr->V0 + vertOffset, itr->V1 + vertOffset, itr->V2 + vertOffset));
}
diff --git a/src/tools/mesh_extractor/DoodadHandler.h b/src/tools/mesh_extractor/DoodadHandler.h
index c3a8d645016..d7d3e0917b5 100644
--- a/src/tools/mesh_extractor/DoodadHandler.h
+++ b/src/tools/mesh_extractor/DoodadHandler.h
@@ -21,6 +21,7 @@
#include "Utils.h"
#include "Chunk.h"
#include "Model.h"
+#include "Stream.h"
#include <set>
#include <vector>
@@ -39,18 +40,14 @@ public:
return Vector3(vec.z, vec.x, vec.y);
}
- void Read(FILE* stream)
+ void Read(Stream* stream)
{
- int count = 0;
-
- count += fread(&MmidIndex, sizeof(uint32), 1, stream);
- count += fread(&UniqueId, sizeof(uint32), 1, stream);
- Position = (Vector3::Read(stream));
+ MmidIndex = stream->Read<uint32>();
+ UniqueId = stream->Read<uint32>();
+ Position = Vector3::Read(stream);
Rotation = Vector3::Read(stream);
- count += fread(&DecimalScale, sizeof(uint16), 1, stream);
- count += fread(&Flags, sizeof(uint16), 1, stream);
- if (count != 4)
- printf("DoodadDefinition::Read: Failed to read some data expected 4, read %d\n", count);
+ DecimalScale = stream->Read<uint16>();
+ Flags = stream->Read<uint16>();
}
};
@@ -62,7 +59,7 @@ public:
std::vector<Vector3> Vertices;
std::vector<Triangle<uint32> > Triangles;
- bool IsSane() { return _definitions && _paths; }
+ bool IsSane() const { return _definitions && _paths; }
protected:
@@ -71,7 +68,7 @@ protected:
private:
void ReadDoodadDefinitions(Chunk* chunk);
void ReadDoodadPaths(Chunk* id, Chunk* data);
- void InsertModelGeometry(const DoodadDefinition& def, Model* model);
+ void InsertModelGeometry(const DoodadDefinition& def, Model const* model);
std::set<uint32> _drawn;
std::vector<DoodadDefinition>* _definitions;
std::vector<std::string>* _paths;
diff --git a/src/tools/mesh_extractor/Geometry.cpp b/src/tools/mesh_extractor/Geometry.cpp
index 0c7b7a492c5..2ae05c0b736 100644
--- a/src/tools/mesh_extractor/Geometry.cpp
+++ b/src/tools/mesh_extractor/Geometry.cpp
@@ -20,6 +20,7 @@
#include "ADT.h"
#include "WorldModelHandler.h"
#include "DoodadHandler.h"
+#include "LiquidHandler.h"
#include <limits.h>
Geometry::Geometry() : Transform(false)
@@ -34,7 +35,7 @@ void Geometry::CalculateBoundingBox( float*& min, float*& max )
max = new float[3];
for (int i = 0; i < 3; ++i)
{
- max[i] = std::numeric_limits<float>::lowest();
+ max[i] = -FLT_MAX;
min[i] = std::numeric_limits<float>::max();
}
@@ -60,7 +61,7 @@ void Geometry::CalculateBoundingBox( float*& min, float*& max )
void Geometry::CalculateMinMaxHeight( float& min, float& max )
{
min = std::numeric_limits<float>::max();
- max = std::numeric_limits<float>::lowest();
+ max = -FLT_MAX;
for (std::vector<Vector3>::iterator itr = Vertices.begin(); itr != Vertices.end(); ++itr)
{
@@ -91,12 +92,12 @@ void Geometry::AddData( std::vector<Vector3>& verts, std::vector<Triangle<uint32
Triangles.push_back(Triangle<uint32>(itr->Type, itr->V0 + vertOffset, itr->V1 + vertOffset, itr->V2 + vertOffset));
}
-void Geometry::GetRawData( float*& verts, int*& tris, uint8*& areas )
+void Geometry::GetRawData( float*& verts, int*& tris, uint8*& areas ) const
{
verts = new float[Vertices.size() * 3];
for (uint32 i = 0; i < Vertices.size(); ++i)
{
- Vector3& vert = Vertices[i];
+ const Vector3& vert = Vertices[i];
verts[(i * 3) + 0] = vert.x;
verts[(i * 3) + 1] = vert.y;
verts[(i * 3) + 2] = vert.z;
@@ -105,7 +106,7 @@ void Geometry::GetRawData( float*& verts, int*& tris, uint8*& areas )
tris = new int[Triangles.size() * 3];
for (uint32 i = 0; i < Triangles.size(); ++i)
{
- Triangle<uint32>& tri = Triangles[i];
+ const Triangle<uint32>& tri = Triangles[i];
tris[(i * 3) + 0] = (int)tri.V0;
tris[(i * 3) + 1] = (int)tri.V1;
tris[(i * 3) + 2] = (int)tri.V2;
@@ -142,5 +143,8 @@ void Geometry::AddAdt( ADT* adt )
if (!adt->_WorldModelHandler->Triangles.empty())
AddData(adt->_WorldModelHandler->Vertices, adt->_WorldModelHandler->Triangles);
+
+ if (!adt->_LiquidHandler->Triangles.empty())
+ AddData(adt->_LiquidHandler->Vertices, adt->_LiquidHandler->Triangles);
}
diff --git a/src/tools/mesh_extractor/Geometry.h b/src/tools/mesh_extractor/Geometry.h
index f2ea43e381e..cd71ac5a828 100644
--- a/src/tools/mesh_extractor/Geometry.h
+++ b/src/tools/mesh_extractor/Geometry.h
@@ -31,7 +31,7 @@ public:
void CalculateMinMaxHeight(float& min, float& max);
void AddData(std::vector<Vector3>& verts, std::vector<Triangle<uint32> >& tris);
void AddAdt(ADT* adt);
- void GetRawData(float*& verts, int*& tris, uint8*& areas);
+ void GetRawData(float*& verts, int*& tris, uint8*& areas) const;
std::vector<Vector3> Vertices;
std::vector<Triangle<uint32> > Triangles;
diff --git a/src/tools/mesh_extractor/LiquidHandler.cpp b/src/tools/mesh_extractor/LiquidHandler.cpp
index eef36d8ea92..1b6f5ce944e 100644
--- a/src/tools/mesh_extractor/LiquidHandler.cpp
+++ b/src/tools/mesh_extractor/LiquidHandler.cpp
@@ -17,10 +17,20 @@
#include "LiquidHandler.h"
#include "Utils.h"
+#include "DBC.h"
+#include "MPQManager.h"
LiquidHandler::LiquidHandler( ADT* adt ) : Source(adt)
{
HandleNewLiquid();
+ HandleOldLiquid();
+}
+
+LiquidHandler::~LiquidHandler()
+{
+ for (std::vector<MCNKLiquidData*>::iterator itr = MCNKData.begin(); itr != MCNKData.end(); ++itr)
+ delete *itr;
+ MCNKData.clear();
}
void LiquidHandler::HandleNewLiquid()
@@ -32,7 +42,7 @@ void LiquidHandler::HandleNewLiquid()
Vertices.reserve(1000);
Triangles.reserve(1000);
- FILE* stream = chunk->GetStream();
+ Stream* stream = chunk->GetStream();
H2OHeader header[256];
MCNKData.reserve(256);
for (int i = 0; i < 256; i++)
@@ -44,40 +54,44 @@ void LiquidHandler::HandleNewLiquid()
if (h.LayerCount == 0)
{
// Need to fill in missing data with dummies.
- MCNKData.push_back(MCNKLiquidData(NULL, H2ORenderMask()));
+ MCNKData.push_back(new MCNKLiquidData(NULL, H2ORenderMask()));
continue;
}
- fseek(stream, chunk->Offset + h.OffsetInformation, SEEK_SET);
+ stream->Seek(chunk->Offset + h.OffsetInformation, SEEK_SET);
H2OInformation information = H2OInformation::Read(stream);
+ // Load the LiquidTypes DBC
+ DBC const* liquidTypes = MPQHandler->GetDBC("LiquidTypes");
+ Record const* liquid = liquidTypes->GetRecordById(information.LiquidType);
+ ASSERT(liquid);
+
+ // This pointer will be passed to the MCNKLiquidData constructor, from that point on, it is the job of MCNKLiquidData's destructor to release it.
float** heights = new float*[9];
for (int j = 0; j < 9; ++j)
{
heights[j] = new float[9];
memset(heights[j], 0, sizeof(float) * 9);
}
-
+
H2ORenderMask renderMask;
- if (information.LiquidType != 2)
+ if (liquid->GetValue<uint32>(3) != 1) // Read the liquid type and skip Ocean, Slow Ocean and Fast Ocean
{
- fseek(stream, chunk->Offset + h.OffsetRender, SEEK_SET);
+ stream->Seek(chunk->Offset + h.OffsetRender, SEEK_SET);
renderMask = H2ORenderMask::Read(stream);
if ((Utils::IsAllZero(renderMask.Mask, 8) || (information.Width == 8 && information.Height == 8)) && information.OffsetMask2)
{
- fseek(stream, chunk->Offset + information.OffsetMask2, SEEK_SET);
+ stream->Seek(chunk->Offset + information.OffsetMask2, SEEK_SET);
uint32 size = ceil(information.Width * information.Height / 8.0f);
- uint8* altMask = new uint8[size];
- if (fread(altMask, sizeof(uint8), size, stream) == size)
- for (uint32 mi = 0; mi < size; mi++)
- renderMask.Mask[mi + information.OffsetY] |= altMask[mi];
+ uint8* altMask = (uint8*)stream->Read(size);
+ for (uint32 mi = 0; mi < size; mi++)
+ renderMask.Mask[mi + information.OffsetY] |= altMask[mi];
delete[] altMask;
}
- fseek(stream, chunk->Offset + information.OffsetHeightmap, SEEK_SET);
+ stream->Seek(chunk->Offset + information.OffsetHeightmap, SEEK_SET);
for (int y = information.OffsetY; y < (information.OffsetY + information.Height); y++)
for (int x = information.OffsetX; x < (information.OffsetX + information.Width); x++)
- if (fread(&heights[x][y], sizeof(float), 1, stream) != 1)
- return;
+ heights[x][y] = stream->Read<float>();
}
else
{
@@ -90,7 +104,7 @@ void LiquidHandler::HandleNewLiquid()
heights[x][y] = information.HeightLevel1;
}
- MCNKData.push_back(MCNKLiquidData(heights, renderMask));
+ MCNKData.push_back(new MCNKLiquidData(heights, renderMask));
for (int y = information.OffsetY; y < (information.OffsetY + information.Height); y++)
{
@@ -110,10 +124,37 @@ void LiquidHandler::HandleNewLiquid()
Vertices.push_back(Vector3(location.x - Constants::UnitSize, location.y, location.z));
Vertices.push_back(Vector3(location.x, location.y - Constants::UnitSize, location.z));
Vertices.push_back(Vector3(location.x - Constants::UnitSize, location.y - Constants::UnitSize, location.z));
+
+ // Define the liquid type
+ Constants::TriangleType type = Constants::TRIANGLE_TYPE_UNKNOWN;
+ switch (liquid->GetValue<uint32>(3))
+ {
+ case 0: // Water
+ case 1: // Ocean
+ type = Constants::TRIANGLE_TYPE_WATER;
+ break;
+ case 2: // Magma
+ type = Constants::TRIANGLE_TYPE_MAGMA;
+ break;
+ case 3: // Slime
+ type = Constants::TRIANGLE_TYPE_SLIME;
+ break;
+ }
- Triangles.push_back(Triangle<uint32>(Constants::TRIANGLE_TYPE_WATER, vertOffset, vertOffset+2, vertOffset + 1));
- Triangles.push_back(Triangle<uint32>(Constants::TRIANGLE_TYPE_WATER, vertOffset + 2, vertOffset + 3, vertOffset + 1));
+ Triangles.push_back(Triangle<uint32>(type, vertOffset, vertOffset+2, vertOffset + 1));
+ Triangles.push_back(Triangle<uint32>(type, vertOffset + 2, vertOffset + 3, vertOffset + 1));
}
}
}
}
+
+void LiquidHandler::HandleOldLiquid()
+{
+ for (uint32 i = 0; i < 256; ++i)
+ {
+ MapChunk* mapChunk = Source->MapChunks[i];
+ if (!mapChunk->Header.OffsetMCLQ || mapChunk->Header.SizeMCLQ <= 8)
+ continue;
+ printf("Found old liquid");
+ }
+}
diff --git a/src/tools/mesh_extractor/LiquidHandler.h b/src/tools/mesh_extractor/LiquidHandler.h
index c053b621088..d7f493e2719 100644
--- a/src/tools/mesh_extractor/LiquidHandler.h
+++ b/src/tools/mesh_extractor/LiquidHandler.h
@@ -27,12 +27,14 @@ class LiquidHandler
{
public:
LiquidHandler(ADT* adt);
+ ~LiquidHandler();
ADT* Source;
std::vector<Vector3> Vertices;
std::vector<Triangle<uint32> > Triangles;
- std::vector<MCNKLiquidData> MCNKData;
+ std::vector<MCNKLiquidData*> MCNKData;
private:
void HandleNewLiquid();
+ void HandleOldLiquid();
};
#endif \ No newline at end of file
diff --git a/src/tools/mesh_extractor/MPQ.cpp b/src/tools/mesh_extractor/MPQ.cpp
index 5a2957cac0b..4a86ab0b4de 100644
--- a/src/tools/mesh_extractor/MPQ.cpp
+++ b/src/tools/mesh_extractor/MPQ.cpp
@@ -17,6 +17,7 @@
#include "MPQ.h"
#include "MPQManager.h"
+#include "Stream.h"
#include <deque>
#include <cstdio>
@@ -125,15 +126,8 @@ void MPQFile::close()
eof = true;
}
-FILE* MPQFile::GetFileStream()
+Stream* MPQFile::GetFileStream()
{
- FILE* file = tmpfile();
- if (!file)
- {
- printf("Could not create temporary file. Please run as Administrator or root\n");
- exit(1);
- }
- fwrite(buffer, sizeof(char), size, file);
- fseek(file, 0, SEEK_SET);
- return file;
+ Stream* stream = new Stream(buffer, size);
+ return stream;
}
diff --git a/src/tools/mesh_extractor/MPQ.h b/src/tools/mesh_extractor/MPQ.h
index 17dbe74dcaa..df39e901d5d 100644
--- a/src/tools/mesh_extractor/MPQ.h
+++ b/src/tools/mesh_extractor/MPQ.h
@@ -20,6 +20,7 @@
#include "libmpq/mpq.h"
#include "Define.h"
+#include "Stream.h"
#include <string>
#include <ctype.h>
#include <vector>
@@ -30,7 +31,7 @@ class MPQArchive
{
public:
- mpq_archive_s *mpq_a;
+ mpq_archive_s* mpq_a;
std::vector<std::string> Files;
@@ -70,8 +71,8 @@ class MPQFile
{
//MPQHANDLE handle;
bool eof;
- char *buffer;
- libmpq__off_t pointer,size;
+ char* buffer;
+ libmpq__off_t pointer, size;
// disable copying
MPQFile(const MPQFile& /*f*/) {}
@@ -81,18 +82,18 @@ public:
MPQFile(const char* filename); // filenames are not case sensitive
~MPQFile() { close(); }
size_t Read(void* dest, size_t bytes);
- FILE* GetFileStream();
- size_t getSize() { return size; }
- size_t getPos() { return pointer; }
+ Stream* GetFileStream();
+ size_t getSize() const { return size; }
+ size_t getPos() const { return pointer; }
char* getBuffer() { return buffer; }
char* getPointer() { return buffer + pointer; }
- bool isEof() { return eof; }
+ bool isEof() const { return eof; }
void seek(int offset);
void seekRelative(int offset);
void close();
};
-inline void flipcc(char *fcc)
+inline void flipcc(char* fcc)
{
char t;
t=fcc[0];
diff --git a/src/tools/mesh_extractor/MPQManager.cpp b/src/tools/mesh_extractor/MPQManager.cpp
index 8954da6c154..4834ca368c0 100644
--- a/src/tools/mesh_extractor/MPQManager.cpp
+++ b/src/tools/mesh_extractor/MPQManager.cpp
@@ -19,6 +19,7 @@
#include "MPQ.h"
#include "DBC.h"
#include "Utils.h"
+#include "Stream.h"
#include <ace/Guard_T.h>
char const* MPQManager::Files[] = {
@@ -31,6 +32,12 @@ char const* MPQManager::Files[] = {
"patch-3.MPQ"
};
+char const* MPQManager::LocalePatchFiles[] = {
+ "Data/%s/patch-%s.MPQ",
+ "Data/%s/patch-%s-2.MPQ",
+ "Data/%s/patch-%s-3.MPQ"
+};
+
char const* MPQManager::Languages[] = { "enGB", "enUS", "deDE", "esES", "frFR", "koKR", "zhCN", "zhTW", "enCN", "enTW", "esMX", "ruRU" };
void MPQManager::Initialize()
@@ -48,9 +55,7 @@ void MPQManager::Initialize()
void MPQManager::InitializeDBC()
{
BaseLocale = -1;
- std::string fileName;
uint32 size = sizeof(Languages) / sizeof(char*);
- MPQArchive* _baseLocale = NULL;
for (uint32 i = 0; i < size; ++i)
{
std::string _fileName = "Data/" + std::string(Languages[i]) + "/locale-" + std::string(Languages[i]) + ".MPQ";
@@ -58,20 +63,34 @@ void MPQManager::InitializeDBC()
if (file)
{
if (BaseLocale == -1)
- {
BaseLocale = i;
- _baseLocale = new MPQArchive(_fileName.c_str());
- fileName = _fileName;
- LocaleFiles[i] = _baseLocale;
+
+ // Load the base locale file
+ MPQArchive* arch = new MPQArchive(_fileName.c_str());
+ LocaleFiles[i].push_front(arch);
+
+ Archives.push_front(arch); // For lookup in GetFile
+
+ // Load the locale patches
+ for (uint32 j = 0; j < sizeof(LocalePatchFiles) / sizeof(char*); ++j)
+ {
+ char patchName[100];
+ sprintf(patchName, LocalePatchFiles[j], Languages[i], Languages[i]);
+ FILE* patch = fopen(patchName, "rb");
+ if (file)
+ {
+ MPQArchive* archP = new MPQArchive(patchName);
+ LocaleFiles[i].push_front(archP);
+ Archives.push_front(archP); // For lookup in GetFile
+ fclose(patch);
+ }
}
- else
- LocaleFiles[i] = new MPQArchive(_fileName.c_str());
AvailableLocales.insert(i);
printf("Detected locale: %s\n", Languages[i]);
}
}
- Archives.push_front(_baseLocale);
+
if (BaseLocale == -1)
{
printf("No locale data detected. Please make sure that the executable is in the same folder as your WoW installation.\n");
@@ -81,7 +100,7 @@ void MPQManager::InitializeDBC()
printf("Using default locale: %s\n", Languages[BaseLocale]);
}
-FILE* MPQManager::GetFile(const std::string& path )
+Stream* MPQManager::GetFile(const std::string& path )
{
ACE_GUARD_RETURN(ACE_Thread_Mutex, g, mutex, NULL);
MPQFile file(path.c_str());
@@ -90,13 +109,54 @@ FILE* MPQManager::GetFile(const std::string& path )
return file.GetFileStream();
}
-DBC* MPQManager::GetDBC(const std::string& name )
+DBC const* MPQManager::GetDBC(const std::string& name )
{
+ std::map<std::string, DBC*>::const_iterator itr = LoadedDBCs.find(name);
+ if (itr != LoadedDBCs.end())
+ return itr->second;
+
std::string path = "DBFilesClient\\" + name + ".dbc";
- return new DBC(GetFile(path));
+ DBC* dbc = new DBC(GetFile(path));
+
+ LoadedDBCs[name] = dbc;
+
+ return dbc;
}
-FILE* MPQManager::GetFileFrom(const std::string& path, MPQArchive* file )
+Stream* MPQManager::GetFileFromLocale( const std::string& path, uint32 locale )
+{
+ ACE_GUARD_RETURN(ACE_Thread_Mutex, g, mutex, NULL);
+ std::deque<MPQArchive*> files = LocaleFiles[locale];
+ Stream* ret = NULL;
+ for (std::deque<MPQArchive*>::iterator itr = files.begin(); itr != files.end(); ++itr)
+ {
+ mpq_archive* mpq_a = (*itr)->mpq_a;
+
+ uint32_t filenum;
+ if(libmpq__file_number(mpq_a, path.c_str(), &filenum))
+ continue;
+ libmpq__off_t transferred;
+ libmpq__off_t size = 0;
+ libmpq__file_unpacked_size(mpq_a, filenum, &size);
+
+ // HACK: in patch.mpq some files don't want to open and give 1 for filesize
+ if (size <= 1)
+ continue;
+
+ char* buffer = new char[size];
+
+ //libmpq_file_getdata
+ libmpq__file_read(mpq_a, filenum, (unsigned char*)buffer, size, &transferred);
+
+ ret = new Stream(buffer, size);
+
+ delete[] buffer;
+ break;
+ }
+ return ret;
+}
+
+Stream* MPQManager::GetFileFrom(const std::string& path, MPQArchive* file )
{
ACE_GUARD_RETURN(ACE_Thread_Mutex, g, mutex, NULL);
mpq_archive* mpq_a = file->mpq_a;
@@ -119,14 +179,7 @@ FILE* MPQManager::GetFileFrom(const std::string& path, MPQArchive* file )
libmpq__file_read(mpq_a, filenum, (unsigned char*)buffer, size, &transferred);
// Pack the return into a FILE stream
- FILE* ret = tmpfile();
- if (!ret)
- {
- printf("Could not create temporary file. Please run as Administrator or root\n");
- exit(1);
- }
- fwrite(buffer, sizeof(uint8), size, ret);
- fseek(ret, 0, SEEK_SET);
+ Stream* ret = new Stream((char*)buffer, size);
delete[] buffer;
return ret;
}
diff --git a/src/tools/mesh_extractor/MPQManager.h b/src/tools/mesh_extractor/MPQManager.h
index 6172237df49..d44030319cf 100644
--- a/src/tools/mesh_extractor/MPQManager.h
+++ b/src/tools/mesh_extractor/MPQManager.h
@@ -19,6 +19,7 @@
#define MPQ_MANAGER_H
#include "MPQ.h"
+#include "Stream.h"
#include <ace/Synch.h>
#include <set>
#include <map>
@@ -31,22 +32,26 @@ public:
~MPQManager() {}
void Initialize();
- FILE* GetFile(const std::string& path);
- FILE* GetFileFrom(const std::string& path, MPQArchive* file);
- DBC* GetDBC(const std::string& name);
+ Stream* GetFile(const std::string& path);
+ Stream* GetFileFrom(const std::string& path, MPQArchive* file);
+ Stream* GetFileFromLocale(const std::string& path, uint32 locale);
+
+ DBC const* GetDBC(const std::string& name);
std::vector<std::string> GetAllFiles(std::string extension);
std::deque<MPQArchive*> Archives;
int32 BaseLocale;
std::set<uint32> AvailableLocales;
- std::map<uint32, MPQArchive*> LocaleFiles;
+ std::map<uint32, std::deque<MPQArchive*> > LocaleFiles;
static char const* Files[];
+ static char const* LocalePatchFiles[];
static char const* Languages[];
protected:
void InitializeDBC();
private:
ACE_Thread_Mutex mutex;
+ std::map<std::string, DBC*> LoadedDBCs;
};
extern MPQManager* MPQHandler;
diff --git a/src/tools/mesh_extractor/MapChunk.cpp b/src/tools/mesh_extractor/MapChunk.cpp
index 4cd5afad3f1..ee6b4584396 100644
--- a/src/tools/mesh_extractor/MapChunk.cpp
+++ b/src/tools/mesh_extractor/MapChunk.cpp
@@ -21,9 +21,9 @@
MapChunk::MapChunk( ADT* _adt, Chunk* chunk ) : Adt(_adt), Source(chunk)
{
- FILE* stream = chunk->GetStream();
+ Stream* stream = chunk->GetStream();
Header.Read(stream);
- fseek(stream, chunk->Offset, SEEK_SET);
+ stream->Seek(chunk->Offset, SEEK_SET);
Index = Header.IndexX + Header.IndexY * 16;
GenerateVertices(stream);
}
@@ -47,12 +47,12 @@ void MapChunk::GenerateTriangles()
Constants::TriangleType triangleType = Constants::TRIANGLE_TYPE_TERRAIN;
if (Adt->_LiquidHandler && !Adt->_LiquidHandler->MCNKData.empty())
{
- MCNKLiquidData& data = Adt->_LiquidHandler->MCNKData[Index];
+ MCNKLiquidData* data = Adt->_LiquidHandler->MCNKData[Index];
float maxHeight = std::max(
std::max(
std::max(std::max(Vertices[topLeft].z, Vertices[topRight].z), Vertices[bottomLeft].z),
Vertices[bottomRight].z), Vertices[center].z);
- if (data.IsWater(x, y, maxHeight))
+ if (data->IsWater(x, y, maxHeight))
triangleType = Constants::TRIANGLE_TYPE_WATER;
}
@@ -64,9 +64,9 @@ void MapChunk::GenerateTriangles()
}
}
-void MapChunk::GenerateVertices( FILE* stream )
+void MapChunk::GenerateVertices(Stream* stream)
{
- fseek(stream, Header.OffsetMCVT, SEEK_CUR);
+ stream->Seek(Header.OffsetMCVT, SEEK_CUR);
Vertices.reserve(125);
for (int j = 0; j < 17; j++)
@@ -74,9 +74,7 @@ void MapChunk::GenerateVertices( FILE* stream )
int values = j % 2 ? 8 : 9;
for (int i = 0; i < values; i++)
{
- float tmp;
- if (fread(&tmp, sizeof(float), 1, stream) != 1)
- printf("MapChunk::GenerateVertices: Failed to read some data expected 1, read 0\n");
+ float tmp = stream->Read<float>();
Vector3 vert(Header.Position.x - (j * (Constants::UnitSize * 0.5f)), Header.Position.y - (i * Constants::UnitSize), Header.Position.z + tmp);
if (values == 8)
vert.y -= Constants::UnitSize * 0.5f;
@@ -84,7 +82,7 @@ void MapChunk::GenerateVertices( FILE* stream )
}
}
// Restore stream position.
- fseek(stream, Source->Offset, SEEK_SET);
+ stream->Seek(Source->Offset, SEEK_SET);
}
bool MapChunk::HasHole( uint32 map, int x, int y )
diff --git a/src/tools/mesh_extractor/MapChunk.h b/src/tools/mesh_extractor/MapChunk.h
index 95bce9ffcd6..c5127b08002 100644
--- a/src/tools/mesh_extractor/MapChunk.h
+++ b/src/tools/mesh_extractor/MapChunk.h
@@ -29,7 +29,7 @@ public:
MapChunk(ADT* _adt, Chunk* chunk);
void GenerateTriangles();
- void GenerateVertices(FILE* stream);
+ void GenerateVertices(Stream* stream);
static bool HasHole(uint32 map, int x, int y);
ADT* Adt;
Chunk* Source;
diff --git a/src/tools/mesh_extractor/MeshExtractor.cpp b/src/tools/mesh_extractor/MeshExtractor.cpp
index e60e11b1db8..de791b04d36 100644
--- a/src/tools/mesh_extractor/MeshExtractor.cpp
+++ b/src/tools/mesh_extractor/MeshExtractor.cpp
@@ -34,16 +34,41 @@
MPQManager* MPQHandler;
CacheClass* Cache;
+bool IgnoreMap(uint32 id)
+{
+ switch (id)
+ {
+ case 13: // test.wdt
+ case 25: // ScottTest.wdt
+ case 29: // Test.wdt
+ case 42: // Colin.wdt
+ case 169: // EmeraldDream.wdt (unused, and very large)
+ case 451: // development.wdt
+ case 573: // ExteriorTest.wdt
+ case 597: // CraigTest.wdt
+ case 605: // development_nonweighted.wdt
+ case 606: // QA_DVD.wdt
+ return true;
+ default:
+ break;
+ }
+
+ return false;
+}
+
void ExtractMMaps(std::set<uint32>& mapIds, uint32 threads)
{
- DBC* dbc = MPQHandler->GetDBC("Map");
- printf("Map.dbc contains %u rows.\n", dbc->Records.size());
- for (std::vector<Record*>::iterator itr = dbc->Records.begin(); itr != dbc->Records.end(); ++itr)
+ std::string basePath = "mmaps/";
+ Utils::CreateDir(basePath);
+
+ DBC const* dbc = MPQHandler->GetDBC("Map");
+ printf("Map.dbc contains " SIZEFMTD " rows.\n", dbc->Records.size());
+ for (std::vector<Record*>::const_iterator itr = dbc->Records.begin(); itr != dbc->Records.end(); ++itr)
{
uint32 mapId = (*itr)->Values[0];
- // Skip this map if a list of specific maps was provided and this one is not contained in it.
- if (!mapIds.empty() && mapIds.find(mapId) == mapIds.end())
+ // Skip this map if a list of specific maps was provided and this one is not contained in it, or if the map is in the ignore list.
+ if ((!mapIds.empty() && mapIds.find(mapId) == mapIds.end()) || IgnoreMap(mapId))
{
if (Constants::Debug)
printf("Map %u will not be built.\n", mapId);
@@ -75,9 +100,12 @@ void ExtractDBCs()
// Populate list of DBC files
// We get the DBC names by going over the (guaranteed to exist) default locale files
// Then we look in other locale files in case that they are available.
- for (std::vector<std::string>::iterator itr = MPQHandler->LocaleFiles[MPQHandler->BaseLocale]->Files.begin(); itr != MPQHandler->LocaleFiles[MPQHandler->BaseLocale]->Files.end(); ++itr)
- if (itr->rfind(".dbc") == itr->length() - extLen) // Check if the extension is ".dbc"
- DBCFiles.insert(*itr);
+ for (std::map<uint32, std::deque<MPQArchive*> >::iterator itr = MPQHandler->LocaleFiles.begin(); itr != MPQHandler->LocaleFiles.end(); ++itr)
+ for (std::deque<MPQArchive*>::iterator itr2 = itr->second.begin(); itr2 != itr->second.end(); ++itr2)
+ for (std::vector<std::string>::iterator itr3 = (*itr2)->Files.begin(); itr3 != (*itr2)->Files.end(); ++itr3)
+ if (itr3->rfind(".dbc") == itr3->length() - extLen) // Check if the extension is ".dbc"
+ if (DBCFiles.find(*itr3) == DBCFiles.end())
+ DBCFiles.insert(*itr3);
const size_t folderLen = strlen("DBFilesClient\\");
// Iterate over all available locales
@@ -93,10 +121,10 @@ void ExtractDBCs()
std::string component = "component.wow-" + std::string(MPQManager::Languages[*itr]) + ".txt";
// Extract the component file
- Utils::SaveToDisk(MPQHandler->GetFileFrom(component, MPQHandler->LocaleFiles[*itr]), path + component);
+ Utils::SaveToDisk(MPQHandler->GetFileFromLocale(component, *itr), path + component);
// Extract the DBC files for the given locale
for (std::set<std::string>::iterator itr2 = DBCFiles.begin(); itr2 != DBCFiles.end(); ++itr2)
- Utils::SaveToDisk(MPQHandler->GetFileFrom(*itr2, MPQHandler->LocaleFiles[*itr]), path + (itr2->c_str() + folderLen));
+ Utils::SaveToDisk(MPQHandler->GetFileFromLocale(*itr2, *itr), path + (itr2->c_str() + folderLen));
}
printf("DBC extraction finished!\n");
}
@@ -118,8 +146,8 @@ void ExtractGameobjectModels()
return;
}
- DBC* dbc = MPQHandler->GetDBC("GameObjectDisplayInfo");
- for (std::vector<Record*>::iterator itr = dbc->Records.begin(); itr != dbc->Records.end(); ++itr)
+ DBC const* dbc = MPQHandler->GetDBC("GameObjectDisplayInfo");
+ for (std::vector<Record*>::const_iterator itr = dbc->Records.begin(); itr != dbc->Records.end(); ++itr)
{
std::string path = (*itr)->GetString(1);
std::string fileName = Utils::GetPlainName(path.c_str());
@@ -225,8 +253,9 @@ void ExtractGameobjectModels()
fwrite(&model.Header.WmoId, sizeof(uint32), 1, output);
const char grp[] = { 'G' , 'R' , 'P', ' ' };
- for (std::vector<WorldModelGroup>::iterator itr2 = model.Groups.begin(); itr2 != model.Groups.end(); ++itr2)
+ for (std::vector<WorldModelGroup*>::iterator groupItr = model.Groups.begin(); groupItr != model.Groups.end(); ++groupItr)
{
+ WorldModelGroup* itr2 = *groupItr;
const WMOGroupHeader& header = itr2->Header;
fwrite(&header.Flags, sizeof(uint32), 1, output);
fwrite(&header.WmoId, sizeof(uint32), 1, output);
@@ -363,7 +392,6 @@ void LoadTile(dtNavMesh*& navMesh, const char* tile)
int main(int argc, char* argv[])
{
- _setmaxstdio(2048);
uint32 threads = 4, extractFlags = 0;
std::set<uint32> mapIds;
@@ -395,8 +423,8 @@ int main(int argc, char* argv[])
if (extractFlags & Constants::EXTRACT_FLAG_TEST)
{
- float start[] = { 16226.200195f, 16257.000000f, 13.202200f };
- float end[] = { 16245.725586f, 16382.465820f, 47.384956f };
+ float start[] = { -45.4745407f, -29.5000954f, -21.4456501f };
+ float end[] = { -107.686218f, -32.3544769f, -30.3459435f };
//
float m_spos[3];
@@ -425,7 +453,7 @@ int main(int argc, char* argv[])
dtPolyRef m_startRef;
dtPolyRef m_endRef;
- FILE* mmap = fopen("mmaps/001.mmap", "rb");
+ FILE* mmap = fopen("mmaps/631.mmap", "rb");
dtNavMeshParams params;
int count = fread(&params, sizeof(dtNavMeshParams), 1, mmap);
fclose(mmap);
@@ -444,7 +472,7 @@ int main(int argc, char* argv[])
for (int j = 0; j <= 32; ++j)
{
char buff[100];
- sprintf(buff, "mmaps/001%02i%02i.mmtile", i, j);
+ sprintf(buff, "mmaps/631%02i%02i.mmtile", i, j);
LoadTile(navMesh, buff);
}
}
@@ -462,24 +490,38 @@ int main(int argc, char* argv[])
return 0;
}
- int hops;
- dtPolyRef* hopBuffer = new dtPolyRef[8192];
- dtStatus status = navMeshQuery->findPath(m_startRef, m_endRef, m_spos, m_epos, &m_filter, hopBuffer, &hops, 8192);
+ dtStatus status;
+ status = navMeshQuery->initSlicedFindPath(m_startRef, m_endRef, m_spos, m_epos, &m_filter);
+ while (status != DT_SUCCESS)
+ status = navMeshQuery->updateSlicedFindPath(1, 0);
- int resultHopCount;
- float* straightPath = new float[2048*3];
- unsigned char* pathFlags = new unsigned char[2048];
dtPolyRef* pathRefs = new dtPolyRef[2048];
+ int pcount = 0;
+ int resultHopCount = 0;
+ float* straightPath = new float[2048 * 3];
+ unsigned char* pathFlags = new unsigned char[2048];
+ dtPolyRef* hopBuffer = new dtPolyRef[8192];
- status = navMeshQuery->findStraightPath(m_spos, m_epos, hopBuffer, hops, straightPath, pathFlags, pathRefs, &resultHopCount, 2048);
+ navMeshQuery->finalizeSlicedFindPath(pathRefs, &pcount, 200);
std::vector<Vector3> FinalPath;
+
+ for (int i = 0; i < pcount; ++i)
+ {
+ navMeshQuery->findStraightPath(m_spos, m_epos, &pathRefs[i], 1,
+ straightPath, pathFlags,
+ hopBuffer, &resultHopCount, 200);
+ Vector3 finalV = Utils::ToWoWCoords(Vector3(straightPath[0 * 3 + 0], straightPath[0 * 3 + 1], straightPath[0 * 3 + 2]));
+ FinalPath.push_back(finalV);
+ printf("Point %f %f %f\n", finalV.x, finalV.y, finalV.z);
+ }
+ /*
FinalPath.reserve(resultHopCount);
- for (uint32 i = 0; i < resultHopCount; ++i)
+ for (int i = 0; i < resultHopCount; ++i)
{
Vector3 finalV = Utils::ToWoWCoords(Vector3(straightPath[i * 3 + 0], straightPath[i * 3 + 1], straightPath[i * 3 + 2]));
FinalPath.push_back(finalV);
printf("Point %f %f %f\n", finalV.x, finalV.y, finalV.z);
- }
+ }*/
}
return 0;
diff --git a/src/tools/mesh_extractor/Model.cpp b/src/tools/mesh_extractor/Model.cpp
index 2a1a80f41eb..f88f620720c 100644
--- a/src/tools/mesh_extractor/Model.cpp
+++ b/src/tools/mesh_extractor/Model.cpp
@@ -19,15 +19,15 @@
#include "MPQManager.h"
#include "Utils.h"
-Model::Model( std::string path ) : IsCollidable(false), IsBad(false)
+Model::Model(std::string path) : IsCollidable(false), IsBad(false)
{
- Stream = MPQHandler->GetFile(Utils::FixModelPath(path));
- if (!Stream)
+ _Stream = MPQHandler->GetFile(Utils::FixModelPath(path));
+ if (!_Stream)
{
IsBad = true;
return;
}
- Header.Read(Stream);
+ Header.Read(_Stream);
if (Header.OffsetBoundingNormals > 0 && Header.OffsetBoundingVertices > 0 &&
Header.OffsetBoundingTriangles > 0 && Header.BoundingRadius > 0.0f)
{
@@ -40,17 +40,17 @@ Model::Model( std::string path ) : IsCollidable(false), IsBad(false)
Model::~Model()
{
- if (Stream)
- fclose(Stream);
+ if (_Stream)
+ delete _Stream;
}
void Model::ReadVertices()
{
- fseek(Stream, Header.OffsetBoundingVertices, SEEK_SET);
+ _Stream->Seek(Header.OffsetBoundingVertices, SEEK_SET);
Vertices.reserve(Header.CountBoundingVertices);
for (uint32 i = 0; i < Header.CountBoundingVertices; ++i)
{
- Vertices.push_back(Vector3::Read(Stream));
+ Vertices.push_back(Vector3::Read(_Stream));
if (Constants::ToWoWCoords)
Vertices[i] = Utils::ToWoWCoords(Vertices[i]);
}
@@ -58,27 +58,24 @@ void Model::ReadVertices()
void Model::ReadBoundingTriangles()
{
- fseek(Stream, Header.OffsetBoundingTriangles, SEEK_SET);
+ _Stream->Seek(Header.OffsetBoundingTriangles, SEEK_SET);
Triangles.reserve(Header.CountBoundingTriangles / 3);
for (uint32 i = 0; i < Header.CountBoundingTriangles / 3; i++)
{
Triangle<uint16> tri;
tri.Type = Constants::TRIANGLE_TYPE_DOODAD;
- int count = 0;
- count += fread(&tri.V0, sizeof(uint16), 1, Stream);
- count += fread(&tri.V1, sizeof(uint16), 1, Stream);
- count += fread(&tri.V2, sizeof(uint16), 1, Stream);
- if (count != 3)
- printf("Model::ReadBoundingTriangles: Error reading data, expected 3, read %d\n", count);
+ tri.V0 = _Stream->Read<uint16>();
+ tri.V1 = _Stream->Read<uint16>();
+ tri.V2 = _Stream->Read<uint16>();
Triangles.push_back(tri);
}
}
void Model::ReadBoundingNormals()
{
- fseek(Stream, Header.OffsetBoundingNormals, SEEK_SET);
+ _Stream->Seek(Header.OffsetBoundingNormals, SEEK_SET);
Normals.reserve(Header.CountBoundingNormals);
for (uint32 i = 0; i < Header.CountBoundingNormals; i++)
- Normals.push_back(Vector3::Read(Stream));
+ Normals.push_back(Vector3::Read(_Stream));
}
diff --git a/src/tools/mesh_extractor/Model.h b/src/tools/mesh_extractor/Model.h
index a1f224729dd..9b460b1e2b6 100644
--- a/src/tools/mesh_extractor/Model.h
+++ b/src/tools/mesh_extractor/Model.h
@@ -19,6 +19,7 @@
#define MODEL_H
#include <vector>
#include "Utils.h"
+#include "Stream.h"
class Model
{
@@ -34,7 +35,7 @@ public:
std::vector<Vector3> Normals;
std::vector<Triangle<uint16> > Triangles;
bool IsCollidable;
- FILE* Stream;
+ Stream* _Stream;
bool IsBad;
};
#endif \ No newline at end of file
diff --git a/src/tools/mesh_extractor/ObjectDataHandler.h b/src/tools/mesh_extractor/ObjectDataHandler.h
index 3b18427db47..346241f9ae0 100644
--- a/src/tools/mesh_extractor/ObjectDataHandler.h
+++ b/src/tools/mesh_extractor/ObjectDataHandler.h
@@ -24,6 +24,7 @@ class ObjectDataHandler
{
public:
ObjectDataHandler(ADT* _adt) : Source(_adt) {}
+ virtual ~ObjectDataHandler() {}
void ProcessMapChunk(MapChunk* chunk);
virtual void ProcessInternal(MapChunk* data) = 0;
diff --git a/src/tools/mesh_extractor/Stream.cpp b/src/tools/mesh_extractor/Stream.cpp
new file mode 100644
index 00000000000..f775d97d114
--- /dev/null
+++ b/src/tools/mesh_extractor/Stream.cpp
@@ -0,0 +1,47 @@
+#include "Stream.h"
+#include <iostream>
+
+Stream::Stream(char* buffer, uint32 size) : _size(size), _position(0)
+{
+ _buffer = new char[size];
+ memcpy(_buffer, buffer, size); // Initialize the buffer
+}
+
+Stream::~Stream()
+{
+ delete[] _buffer;
+}
+
+char* Stream::Read(uint32 size)
+{
+ char* buff = new char[size];
+ memcpy(buff, &_buffer[_position], size);
+ _position += size;
+ return buff;
+}
+
+void Stream::Seek(uint32 position, uint32 type)
+{
+ switch (type)
+ {
+ case SEEK_SET:
+ _position = position;
+ break;
+ case SEEK_CUR:
+ _position += position;
+ break;
+ }
+}
+
+std::string Stream::ReadString()
+{
+ std::string str;
+ while (true)
+ {
+ char b = Read<char>();
+ if (b == 0)
+ break;
+ str.push_back(b);
+ }
+ return str;
+} \ No newline at end of file
diff --git a/src/tools/mesh_extractor/Stream.h b/src/tools/mesh_extractor/Stream.h
new file mode 100644
index 00000000000..647ff9d5357
--- /dev/null
+++ b/src/tools/mesh_extractor/Stream.h
@@ -0,0 +1,59 @@
+#ifndef STREAM_H
+#define STREAM_H
+
+#include "Define.h"
+#include <iostream>
+
+class Stream
+{
+public:
+ Stream(char* buffer, uint32 size);
+ ~Stream();
+
+ template<typename T>
+ T Read()
+ {
+ T ret = *((T*)(&_buffer[_position]));
+ _position += sizeof(T);
+ return ret;
+ }
+
+ template<typename T>
+ void Read(T* dest, uint32 size)
+ {
+ memcpy(dest, &_buffer[_position], size);
+ _position += size;
+ }
+
+ template<typename T>
+ void Skip()
+ {
+ _position += sizeof(T);
+ }
+
+ char* Read(uint32 size);
+ std::string ReadString();
+
+ void Reset()
+ {
+ _position = 0;
+ }
+
+ void Seek(uint32 position, uint32 type);
+
+ uint32 GetSize() const
+ {
+ return _size;
+ }
+
+ uint32 GetPos() const
+ {
+ return _position;
+ }
+
+private:
+ char* _buffer;
+ uint32 _size;
+ uint32 _position;
+};
+#endif \ No newline at end of file
diff --git a/src/tools/mesh_extractor/TileBuilder.cpp b/src/tools/mesh_extractor/TileBuilder.cpp
index 7b70ccca44c..faee5b767cd 100644
--- a/src/tools/mesh_extractor/TileBuilder.cpp
+++ b/src/tools/mesh_extractor/TileBuilder.cpp
@@ -43,8 +43,8 @@ TileBuilder::TileBuilder(ContinentBuilder* _cBuilder, std::string world, int x,
Config.detailSampleDist = 3.0f;
Config.detailSampleMaxError = 1.25f;
Config.walkableClimb = 1.0f / Config.ch;
- Config.walkableHeight = 2.1 / Config.ch;
- Config.walkableRadius = 0.6f / Config.cs;
+ Config.walkableHeight = 2.1;
+ Config.walkableRadius = 0.6f;
Config.maxEdgeLen = Config.walkableRadius * 8;
Config.borderSize = Config.walkableRadius + 8;
Config.tileSize = 1800;
@@ -59,19 +59,19 @@ TileBuilder::TileBuilder(ContinentBuilder* _cBuilder, std::string world, int x,
InstanceConfig.mergeRegionArea = 100;
InstanceConfig.walkableSlopeAngle = 50.0f;
InstanceConfig.detailSampleDist = 3.0f;
- InstanceConfig.detailSampleMaxError = 1.5f;
+ InstanceConfig.detailSampleMaxError = 1.25f;
InstanceConfig.walkableClimb = 1.0f / InstanceConfig.ch;
- InstanceConfig.walkableHeight = 2.1f / InstanceConfig.ch;
- InstanceConfig.walkableRadius = 0.6f / InstanceConfig.cs;
+ InstanceConfig.walkableHeight = 2.1f;
+ InstanceConfig.walkableRadius = 0.6f;
InstanceConfig.maxEdgeLen = 8 * InstanceConfig.walkableRadius;
InstanceConfig.maxVertsPerPoly = 6;
- InstanceConfig.maxSimplificationError = 1.25f;
+ InstanceConfig.maxSimplificationError = 1.3f;
InstanceConfig.borderSize = 0;
Context = new rcContext;
}
-void TileBuilder::CalculateTileBounds( float*& bmin, float*& bmax, dtNavMeshParams& /*navMeshParams*/ )
+void TileBuilder::CalculateTileBounds( float*& bmin, float*& bmax, dtNavMeshParams& /*navMeshParams*/ ) const
{
bmin = new float[3];
bmax = new float[3];
@@ -81,7 +81,7 @@ void TileBuilder::CalculateTileBounds( float*& bmin, float*& bmax, dtNavMeshPara
bmax[2] = Constants::Origin[2] /*navMeshParams.orig[2]*/ + (Constants::TileSize * (Y + 1));
}
-void TileBuilder::AddGeometry(WorldModelRoot* root, const WorldModelDefinition& def)
+void TileBuilder::AddGeometry(WorldModelRoot const* root, const WorldModelDefinition& def)
{
_Geometry = new Geometry();
_Geometry->Transform = true;
@@ -91,7 +91,7 @@ void TileBuilder::AddGeometry(WorldModelRoot* root, const WorldModelDefinition&
OutputDebugVertices();
}
-uint8* TileBuilder::BuildInstance( dtNavMeshParams& navMeshParams )
+uint8* TileBuilder::BuildInstance( dtNavMeshParams& /*navMeshParams*/ )
{
float* bmin = NULL, *bmax = NULL;
@@ -183,11 +183,11 @@ uint8* TileBuilder::BuildInstance( dtNavMeshParams& navMeshParams )
rcFreeHeightField(hf);
rcFreeCompactHeightfield(chf);
rcFreeContourSet(contours);
- delete vertices;
- delete triangles;
- delete areas;
- delete bmin;
- delete bmax;
+ delete[] vertices;
+ delete[] triangles;
+ delete[] areas;
+ delete[] bmin;
+ delete[] bmax;
if (!params.polyCount || !params.polys || Constants::TilesPerMap * Constants::TilesPerMap == params.polyCount)
{
@@ -226,7 +226,7 @@ uint8* TileBuilder::BuildTiled(dtNavMeshParams& navMeshParams)
adt->Read();
_Geometry->AddAdt(adt);
delete adt;
-
+
if (_Geometry->Vertices.empty() && _Geometry->Triangles.empty())
return NULL;
@@ -234,7 +234,8 @@ uint8* TileBuilder::BuildTiled(dtNavMeshParams& navMeshParams)
CalculateTileBounds(bmin, bmax, navMeshParams);
_Geometry->CalculateMinMaxHeight(bmin[1], bmax[1]);
- // again, we load everything - wasteful but who cares
+ // This is commented out to reduce the size of the resulting files (and the time it takes to generate them), we shouldn't need to load 4 more ADTs each time.
+ /*// again, we load everything - wasteful but who cares
for (int ty = Y - 1; ty <= Y + 1; ty++)
{
for (int tx = X - 1; tx <= X + 1; tx++)
@@ -245,7 +246,7 @@ uint8* TileBuilder::BuildTiled(dtNavMeshParams& navMeshParams)
ADT* _adt = new ADT(Utils::GetAdtPath(World, tx, ty), tx, ty);
// If this condition is met, it means that this WDT does not contain the ADT
- if (!_adt->Data->Stream)
+ if (!_adt->Data->_Stream)
{
delete _adt;
continue;
@@ -254,7 +255,7 @@ uint8* TileBuilder::BuildTiled(dtNavMeshParams& navMeshParams)
_Geometry->AddAdt(_adt);
delete _adt;
}
- }
+ }*/
OutputDebugVertices();
@@ -351,11 +352,11 @@ uint8* TileBuilder::BuildTiled(dtNavMeshParams& navMeshParams)
rcFreeHeightField(hf);
rcFreeCompactHeightfield(chf);
rcFreeContourSet(contours);
- delete vertices;
- delete triangles;
- delete areas;
- delete bmin;
- delete bmax;
+ delete[] vertices;
+ delete[] triangles;
+ delete[] areas;
+ delete[] bmin;
+ delete[] bmax;
if (!params.polyCount || !params.polys || Constants::TilesPerMap * Constants::TilesPerMap == params.polyCount)
{
@@ -386,7 +387,7 @@ uint8* TileBuilder::BuildTiled(dtNavMeshParams& navMeshParams)
return NULL;
}
-void TileBuilder::OutputDebugVertices()
+void TileBuilder::OutputDebugVertices() const
{
if (Constants::Debug)
{
diff --git a/src/tools/mesh_extractor/TileBuilder.h b/src/tools/mesh_extractor/TileBuilder.h
index fb8950c552b..6171d407212 100644
--- a/src/tools/mesh_extractor/TileBuilder.h
+++ b/src/tools/mesh_extractor/TileBuilder.h
@@ -32,11 +32,11 @@ public:
TileBuilder(ContinentBuilder* _cBuilder, std::string world, int x, int y, uint32 mapId);
~TileBuilder();
- void CalculateTileBounds(float*& bmin, float*& bmax, dtNavMeshParams& navMeshParams);
+ void CalculateTileBounds(float*& bmin, float*& bmax, dtNavMeshParams& navMeshParams) const;
uint8* BuildTiled(dtNavMeshParams& navMeshParams);
uint8* BuildInstance(dtNavMeshParams& navMeshParams);
- void AddGeometry(WorldModelRoot* root, const WorldModelDefinition& def);
- void OutputDebugVertices();
+ void AddGeometry(WorldModelRoot const* root, const WorldModelDefinition& def);
+ void OutputDebugVertices() const;
std::string World;
int X;
int Y;
diff --git a/src/tools/mesh_extractor/Utils.cpp b/src/tools/mesh_extractor/Utils.cpp
index f82eb6ed1c8..b8ebc0b8fd3 100644
--- a/src/tools/mesh_extractor/Utils.cpp
+++ b/src/tools/mesh_extractor/Utils.cpp
@@ -18,6 +18,7 @@
#include "Utils.h"
#include "WorldModelHandler.h"
#include "Constants.h"
+#include "Stream.h"
#include <cstring>
#include "G3D/Matrix4.h"
#include "G3D/Quat.h"
@@ -53,40 +54,9 @@ void Utils::CreateDir( const std::string& Path )
#endif
}
-void Utils::Reverse(char word[])
+void Utils::Reverse(std::string& str)
{
- int len = strlen(word);
- for (int i = 0;i < len / 2; i++)
- {
- word[i] ^= word[len-i-1];
- word[len-i-1] ^= word[i];
- word[i] ^= word[len-i-1];
- }
-}
-
-std::string Utils::ReadString( FILE* file )
-{
- std::string ret;
- while (true)
- {
- char b;
- if (fread(&b, sizeof(char), 1, file) != 1 || b == 0)
- break;
- ret.push_back(b);
- }
- return ret;
-}
-
-uint32 Utils::Size( FILE* file )
-{
- // store the old position
- uint32 offset = ftell(file);
- // Get file size
- fseek(file, 0, SEEK_END);
- uint32 size = ftell(file);
- // reset back to the old position
- fseek(file, offset, SEEK_SET);
- return size;
+ std::reverse(str.begin(), str.end());
}
Vector3 Utils::ToRecast(const Vector3& val )
@@ -104,7 +74,7 @@ std::string Utils::FixModelPath(const std::string& path )
return Utils::GetPathBase(path) + ".M2";
}
-Vector3 Utils::TransformDoodadVertex(const IDefinition& def, Vector3& vec, bool translate)
+Vector3 Utils::TransformDoodadVertex(const IDefinition& def, Vector3 vec, bool translate)
{
// Sources of information:
/// http://www.pxr.dk/wowdev/wiki/index.php?title=ADT/v18&oldid=3715
@@ -122,7 +92,7 @@ Vector3 Utils::TransformDoodadVertex(const IDefinition& def, Vector3& vec, bool
return ret;
}
-Vector3 Utils::TransformWmoDoodad(const DoodadInstance& inst, const WorldModelDefinition& root, Vector3& vec, bool translate )
+Vector3 Utils::TransformWmoDoodad(const DoodadInstance& inst, const WorldModelDefinition& /*root*/, const Vector3& vec, bool translate)
{
G3D::Quat quat = G3D::Quat(-inst.QuatY, inst.QuatZ, -inst.QuatX, inst.QuatW);
@@ -153,12 +123,9 @@ std::string Utils::GetPathBase(const std::string& path )
return path;
}
-Vector3 Vector3::Read( FILE* file )
+Vector3 Vector3::Read(Stream* file)
{
- Vector3 ret;
- if (fread(&ret, sizeof(Vector3), 1, file) != 1)
- printf("Vector3::Read: Failed to read some data expected 1, read 0\n");
- return ret;
+ return file->Read<Vector3>();
}
Vector3 Utils::GetLiquidVert(const IDefinition& def, Vector3 basePosition, float height, int x, int y, bool translate)
@@ -184,41 +151,36 @@ std::string Utils::Replace( std::string str, const std::string& oldStr, const st
return str;
}
-void Utils::SaveToDisk( FILE* stream, const std::string& path )
+void Utils::SaveToDisk(Stream* stream, const std::string& path)
{
FILE* disk = fopen(path.c_str(), "wb");
if (!disk)
{
printf("SaveToDisk: Could not save file %s to disk, please verify that you have write permissions on that directory\n", path.c_str());
- fclose(stream);
+ delete stream;
return;
}
- uint32 size = Utils::Size(stream);
- uint8* data = new uint8[size];
- // Read the data to an array
- size_t read = fread(data, size, 1, stream);
- if (read != 1)
- {
- printf("SaveToDisk: Error reading from Stream while trying to save file %s to disk.\n", path.c_str());
- fclose(disk);
- fclose(stream);
- return;
- }
+ uint32 size = stream->GetSize();
+ stream->Reset(); // Reset the stream just in case
+ // Read the data to an array
+ char* data = stream->Read(size);
+
// And write it in the file
size_t wrote = fwrite(data, size, 1, disk);
if (wrote != 1)
{
printf("SaveToDisk: Error writing to the file while trying to save %s to disk.\n", path.c_str());
- fclose(stream);
+ delete[] data;
+ delete stream;
fclose(disk);
return;
}
// Close the filestream
fclose(disk);
- fclose(stream);
+ delete stream;
// Free the used memory
delete[] data;
@@ -239,249 +201,193 @@ std::string Utils::GetExtension( std::string path )
return extension;
}
-void MapChunkHeader::Read(FILE* stream)
-{
- int count = 0;
-
- count += fread(&Flags, sizeof(uint32), 1, stream);
- count += fread(&IndexX, sizeof(uint32), 1, stream);
- count += fread(&IndexY, sizeof(uint32), 1, stream);
- count += fread(&Layers, sizeof(uint32), 1, stream);
- count += fread(&DoodadRefs, sizeof(uint32), 1, stream);
- count += fread(&OffsetMCVT, sizeof(uint32), 1, stream);
- count += fread(&OffsetMCNR, sizeof(uint32), 1, stream);
- count += fread(&OffsetMCLY, sizeof(uint32), 1, stream);
- count += fread(&OffsetMCRF, sizeof(uint32), 1, stream);
- count += fread(&OffsetMCAL, sizeof(uint32), 1, stream);
- count += fread(&SizeMCAL, sizeof(uint32), 1, stream);
- count += fread(&OffsetMCSH, sizeof(uint32), 1, stream);
- count += fread(&SizeMCSH, sizeof(uint32), 1, stream);
- count += fread(&AreaId, sizeof(uint32), 1, stream);
- count += fread(&MapObjectRefs, sizeof(uint32), 1, stream);
- count += fread(&Holes, sizeof(uint32), 1, stream);
- LowQualityTextureMap = new uint32[4];
- count += fread(LowQualityTextureMap, sizeof(uint32), 4, stream);
- count += fread(&PredTex, sizeof(uint32), 1, stream);
- count += fread(&NumberEffectDoodad, sizeof(uint32), 1, stream);
- count += fread(&OffsetMCSE, sizeof(uint32), 1, stream);
- count += fread(&SoundEmitters, sizeof(uint32), 1, stream);
- count += fread(&OffsetMCLQ, sizeof(uint32), 1, stream);
- count += fread(&SizeMCLQ, sizeof(uint32), 1, stream);
+void MapChunkHeader::Read(Stream* stream)
+{
+ Flags = stream->Read<uint32>();
+ IndexX = stream->Read<uint32>();
+ IndexY = stream->Read<uint32>();
+ Layers = stream->Read<uint32>();
+ DoodadRefs = stream->Read<uint32>();
+ OffsetMCVT = stream->Read<uint32>();
+ OffsetMCNR = stream->Read<uint32>();
+ OffsetMCLY = stream->Read<uint32>();
+ OffsetMCRF = stream->Read<uint32>();
+ OffsetMCAL = stream->Read<uint32>();
+ SizeMCAL = stream->Read<uint32>();
+ OffsetMCSH = stream->Read<uint32>();
+ SizeMCSH = stream->Read<uint32>();
+ AreaId = stream->Read<uint32>();
+ MapObjectRefs = stream->Read<uint32>();
+ Holes = stream->Read<uint32>();
+ stream->Read(LowQualityTextureMap, sizeof(uint32) * 4);
+ PredTex = stream->Read<uint32>();
+ NumberEffectDoodad = stream->Read<uint32>();
+ OffsetMCSE = stream->Read<uint32>();
+ SoundEmitters = stream->Read<uint32>();
+ OffsetMCLQ = stream->Read<uint32>();
+ SizeMCLQ = stream->Read<uint32>();
Position = Vector3::Read(stream);
- count += fread(&OffsetMCCV, sizeof(uint32), 1, stream);
-
- if (count != 27)
- printf("MapChunkHeader::Read: Failed to read some data expected 27, read %d\n", count);
+ OffsetMCCV = stream->Read<uint32>();
}
-void MHDR::Read(FILE* stream)
+void MHDR::Read(Stream* stream)
{
- int count = 0;
-
- count += fread(&Flags, sizeof(uint32), 1, stream);
- count += fread(&OffsetMCIN, sizeof(uint32), 1, stream);
- count += fread(&OffsetMTEX, sizeof(uint32), 1, stream);
- count += fread(&OffsetMMDX, sizeof(uint32), 1, stream);
- count += fread(&OffsetMMID, sizeof(uint32), 1, stream);
- count += fread(&OffsetMWMO, sizeof(uint32), 1, stream);
- count += fread(&OffsetMWID, sizeof(uint32), 1, stream);
- count += fread(&OffsetMDDF, sizeof(uint32), 1, stream);
- count += fread(&OffsetMODF, sizeof(uint32), 1, stream);
- count += fread(&OffsetMFBO, sizeof(uint32), 1, stream);
- count += fread(&OffsetMH2O, sizeof(uint32), 1, stream);
- count += fread(&OffsetMTFX, sizeof(uint32), 1, stream);
-
- if (count != 12)
- printf("MHDR::Read: Failed to read some data expected 12, read %d\n", count);
+ Flags = stream->Read<uint32>();
+ OffsetMCIN = stream->Read<uint32>();
+ OffsetMTEX = stream->Read<uint32>();
+ OffsetMMDX = stream->Read<uint32>();
+ OffsetMMID = stream->Read<uint32>();
+ OffsetMWMO = stream->Read<uint32>();
+ OffsetMWID = stream->Read<uint32>();
+ OffsetMDDF = stream->Read<uint32>();
+ OffsetMODF = stream->Read<uint32>();
+ OffsetMFBO = stream->Read<uint32>();
+ OffsetMH2O = stream->Read<uint32>();
+ OffsetMTFX = stream->Read<uint32>();
}
-void ModelHeader::Read(FILE* stream)
+void ModelHeader::Read(Stream* stream)
{
- int count = 0;
-
- count += fread(&Magic, sizeof(char), 4, stream);
+ stream->Read(Magic, 4);
Magic[4] = '\0'; // null-terminate it.
- count += fread(&Version, sizeof(uint32), 1, stream);
- count += fread(&LengthModelName, sizeof(uint32), 1, stream);
- count += fread(&OffsetName, sizeof(uint32), 1, stream);
- count += fread(&ModelFlags, sizeof(uint32), 1, stream);
- count += fread(&CountGlobalSequences, sizeof(uint32), 1, stream);
- count += fread(&OffsetGlobalSequences, sizeof(uint32), 1, stream);
- count += fread(&CountAnimations, sizeof(uint32), 1, stream);
- count += fread(&OffsetAnimations, sizeof(uint32), 1, stream);
- count += fread(&CountAnimationLookup, sizeof(uint32), 1, stream);
- count += fread(&OffsetAnimationLookup, sizeof(uint32), 1, stream);
- count += fread(&CountBones, sizeof(uint32), 1, stream);
- count += fread(&OffsetBones, sizeof(uint32), 1, stream);
- count += fread(&CountKeyBoneLookup, sizeof(uint32), 1, stream);
- count += fread(&OffsetKeyBoneLookup, sizeof(uint32), 1, stream);
- count += fread(&CountVertices, sizeof(uint32), 1, stream);
- count += fread(&OffsetVertices, sizeof(uint32), 1, stream);
- count += fread(&CountViews, sizeof(uint32), 1, stream);
- count += fread(&CountColors, sizeof(uint32), 1, stream);
- count += fread(&OffsetColors, sizeof(uint32), 1, stream);
- count += fread(&CountTextures, sizeof(uint32), 1, stream);
- count += fread(&OffsetTextures, sizeof(uint32), 1, stream);
- count += fread(&CountTransparency, sizeof(uint32), 1, stream);
- count += fread(&OffsetTransparency, sizeof(uint32), 1, stream);
- count += fread(&CountUvAnimation, sizeof(uint32), 1, stream);
- count += fread(&OffsetUvAnimation, sizeof(uint32), 1, stream);
- count += fread(&CountTexReplace, sizeof(uint32), 1, stream);
- count += fread(&OffsetTexReplace, sizeof(uint32), 1, stream);
- count += fread(&CountRenderFlags, sizeof(uint32), 1, stream);
- count += fread(&OffsetRenderFlags, sizeof(uint32), 1, stream);
- count += fread(&CountBoneLookup, sizeof(uint32), 1, stream);
- count += fread(&OffsetBoneLookup, sizeof(uint32), 1, stream);
- count += fread(&CountTexLookup, sizeof(uint32), 1, stream);
- count += fread(&OffsetTexLookup, sizeof(uint32), 1, stream);
- count += fread(&CountTexUnits, sizeof(uint32), 1, stream);
- count += fread(&OffsetTexUnits, sizeof(uint32), 1, stream);
- count += fread(&CountTransLookup, sizeof(uint32), 1, stream);
- count += fread(&OffsetTransLookup, sizeof(uint32), 1, stream);
- count += fread(&CountUvAnimLookup, sizeof(uint32), 1, stream);
- count += fread(&OffsetUvAnimLookup, sizeof(uint32), 1, stream);
+ Version = stream->Read<uint32>();
+ LengthModelName = stream->Read<uint32>();
+ OffsetName = stream->Read<uint32>();
+ ModelFlags = stream->Read<uint32>();
+ CountGlobalSequences = stream->Read<uint32>();
+ OffsetGlobalSequences = stream->Read<uint32>();
+ CountAnimations = stream->Read<uint32>();
+ OffsetAnimations = stream->Read<uint32>();
+ CountAnimationLookup = stream->Read<uint32>();
+ OffsetAnimationLookup = stream->Read<uint32>();
+ CountBones = stream->Read<uint32>();
+ OffsetBones = stream->Read<uint32>();
+ CountKeyBoneLookup = stream->Read<uint32>();
+ OffsetKeyBoneLookup = stream->Read<uint32>();
+ CountVertices = stream->Read<uint32>();
+ OffsetVertices = stream->Read<uint32>();
+ CountViews = stream->Read<uint32>();
+ CountColors = stream->Read<uint32>();
+ OffsetColors = stream->Read<uint32>();
+ CountTextures = stream->Read<uint32>();
+ OffsetTextures = stream->Read<uint32>();
+ CountTransparency = stream->Read<uint32>();
+ OffsetTransparency = stream->Read<uint32>();
+ CountUvAnimation = stream->Read<uint32>();
+ OffsetUvAnimation = stream->Read<uint32>();
+ CountTexReplace = stream->Read<uint32>();
+ OffsetTexReplace = stream->Read<uint32>();
+ CountRenderFlags = stream->Read<uint32>();
+ OffsetRenderFlags = stream->Read<uint32>();
+ CountBoneLookup = stream->Read<uint32>();
+ OffsetBoneLookup = stream->Read<uint32>();
+ CountTexLookup = stream->Read<uint32>();
+ OffsetTexLookup = stream->Read<uint32>();
+ CountTexUnits = stream->Read<uint32>();
+ OffsetTexUnits = stream->Read<uint32>();
+ CountTransLookup = stream->Read<uint32>();
+ OffsetTransLookup = stream->Read<uint32>();
+ CountUvAnimLookup = stream->Read<uint32>();
+ OffsetUvAnimLookup = stream->Read<uint32>();
VertexBox[0] = Vector3::Read(stream);
VertexBox[1] = Vector3::Read(stream);
- count += fread(&VertexRadius, sizeof(float), 1, stream);
+ VertexRadius = stream->Read<float>();
BoundingBox[0] = Vector3::Read(stream);
BoundingBox[1] = Vector3::Read(stream);
- count += fread(&BoundingRadius, sizeof(float), 1, stream);
- count += fread(&CountBoundingTriangles, sizeof(uint32), 1, stream);
- count += fread(&OffsetBoundingTriangles, sizeof(uint32), 1, stream);
- count += fread(&CountBoundingVertices, sizeof(uint32), 1, stream);
- count += fread(&OffsetBoundingVertices, sizeof(uint32), 1, stream);
- count += fread(&CountBoundingNormals, sizeof(uint32), 1, stream);
- count += fread(&OffsetBoundingNormals, sizeof(uint32), 1, stream);
-
- if (count != 51)
- printf("ModelHeader::Read: Failed to read some data expected 51, read %d\n", count);
-
-}
-
-WorldModelHeader WorldModelHeader::Read(FILE* stream)
-{
- WorldModelHeader ret;
- int count = 0;
-
- count += fread(&ret.CountMaterials, sizeof(uint32), 1, stream);
- count += fread(&ret.CountGroups, sizeof(uint32), 1, stream);
- count += fread(&ret.CountPortals, sizeof(uint32), 1, stream);
- count += fread(&ret.CountLights, sizeof(uint32), 1, stream);
- count += fread(&ret.CountModels, sizeof(uint32), 1, stream);
- count += fread(&ret.CountDoodads, sizeof(uint32), 1, stream);
- count += fread(&ret.CountSets, sizeof(uint32), 1, stream);
- count += fread(&ret.AmbientColorUnk, sizeof(uint32), 1, stream);
- count += fread(&ret.WmoId, sizeof(uint32), 1, stream);
- ret.BoundingBox[0] = Vector3::Read(stream);
- ret.BoundingBox[1] = Vector3::Read(stream);
- count += fread(&ret.LiquidTypeRelated, sizeof(uint32), 1, stream);
-
- if (count != 10)
- printf("WorldModelHeader::Read: Failed to read some data expected 10, read %d\n", count);
-
- return ret;
+ BoundingRadius = stream->Read<float>();
+ CountBoundingTriangles = stream->Read<uint32>();
+ OffsetBoundingTriangles = stream->Read<uint32>();
+ CountBoundingVertices = stream->Read<uint32>();
+ OffsetBoundingVertices = stream->Read<uint32>();
+ CountBoundingNormals = stream->Read<uint32>();
+ OffsetBoundingNormals = stream->Read<uint32>();
+}
+
+void WorldModelHeader::Read(Stream* stream)
+{
+ CountMaterials = stream->Read<uint32>();
+ CountGroups = stream->Read<uint32>();
+ CountPortals = stream->Read<uint32>();
+ CountLights = stream->Read<uint32>();
+ CountModels = stream->Read<uint32>();
+ CountDoodads = stream->Read<uint32>();
+ CountSets = stream->Read<uint32>();
+ AmbientColorUnk = stream->Read<uint32>();
+ WmoId = stream->Read<uint32>();
+ BoundingBox[0] = Vector3::Read(stream);
+ BoundingBox[1] = Vector3::Read(stream);
+ LiquidTypeRelated = stream->Read<uint32>();
}
-DoodadInstance DoodadInstance::Read(FILE* stream)
+DoodadInstance DoodadInstance::Read(Stream* stream)
{
DoodadInstance ret;
- int count = 0;
- count += fread(&ret.FileOffset, sizeof(uint32), 1, stream);
+ ret.FileOffset = stream->Read<uint32>();
ret.Position = Vector3::Read(stream);
- count += fread(&ret.QuatW, sizeof(float), 1, stream);
- count += fread(&ret.QuatX, sizeof(float), 1, stream);
- count += fread(&ret.QuatY, sizeof(float), 1, stream);
- count += fread(&ret.QuatZ, sizeof(float), 1, stream);
- count += fread(&ret.Scale, sizeof(float), 1, stream);
- count += fread(&ret.LightColor, sizeof(uint32), 1, stream);
-
- if (count != 7)
- printf("DoodadInstance::Read: Failed to read some data expected 7, read %d\n", count);
-
+ ret.QuatW = stream->Read<float>();
+ ret.QuatX = stream->Read<float>();
+ ret.QuatY = stream->Read<float>();
+ ret.QuatZ = stream->Read<float>();
+ ret.Scale = stream->Read<float>();
+ ret.LightColor = stream->Read<uint32>();
return ret;
}
-DoodadSet DoodadSet::Read(FILE* stream)
+DoodadSet DoodadSet::Read(Stream* stream)
{
DoodadSet ret;
- char name[21];
- int count = 0;
-
- count += fread(&name, sizeof(char), 20, stream);
- name[20] = '\0';
- ret.Name = name;
- count += fread(&ret.FirstInstanceIndex, sizeof(uint32), 1, stream);
- count += fread(&ret.CountInstances, sizeof(uint32), 1, stream);
- count += fread(&ret.UnknownZero, sizeof(uint32), 1, stream);
-
- if (count != 23)
- printf("DoodadSet::Read: Failed to read some data expected 23, read %d\n", count);
-
+ char* name = stream->Read(20);
+ ret.Name = std::string(name, 20);
+ delete[] name;
+ ret.FirstInstanceIndex = stream->Read<uint32>();
+ ret.CountInstances = stream->Read<uint32>();
+ ret.UnknownZero = stream->Read<uint32>();
+
return ret;
}
-LiquidHeader LiquidHeader::Read(FILE* stream)
+void LiquidHeader::Read(Stream* stream)
{
- LiquidHeader ret;
- int count = 0;
- count += fread(&ret.CountXVertices, sizeof(uint32), 1, stream);
- count += fread(&ret.CountYVertices, sizeof(uint32), 1, stream);
- count += fread(&ret.Width, sizeof(uint32), 1, stream);
- count += fread(&ret.Height, sizeof(uint32), 1, stream);
- ret.BaseLocation = Vector3::Read(stream);
- count += fread(&ret.MaterialId, sizeof(uint16), 1, stream);
-
- if (count != 5)
- printf("LiquidHeader::Read: Failed to read some data expected 5, read %d\n", count);
-
- return ret;
+ CountXVertices = stream->Read<uint32>();
+ CountYVertices = stream->Read<uint32>();
+ Width = stream->Read<uint32>();
+ Height = stream->Read<uint32>();
+ BaseLocation = Vector3::Read(stream);
+ MaterialId = stream->Read<uint16>();
}
-LiquidData LiquidData::Read(FILE* stream, LiquidHeader& header)
+void LiquidData::Read(Stream* stream, LiquidHeader& header)
{
- LiquidData ret;
- ret.HeightMap = new float*[header.CountXVertices];
+ CountXVertices = header.CountXVertices;
+ Width = header.Width;
+
+ HeightMap = new float*[header.CountXVertices];
for (uint32 i = 0; i < header.CountXVertices; ++i)
- ret.HeightMap[i] = new float[header.CountYVertices];
+ HeightMap[i] = new float[header.CountYVertices];
- ret.RenderFlags = new uint8*[header.Width];
+ RenderFlags = new uint8*[header.Width];
for (uint32 i = 0; i < header.Width; ++i)
- ret.RenderFlags[i] = new uint8[header.Height];
+ RenderFlags[i] = new uint8[header.Height];
for (uint32 y = 0; y < header.CountYVertices; y++)
{
for (uint32 x = 0; x < header.CountXVertices; x++)
{
- uint32 discard;
- float tmp;
- if (fread(&discard, sizeof(uint32), 1, stream) == 1 &&
- fread(&tmp, sizeof(float), 1, stream) == 1)
- {
- ret.HeightMap[x][y] = tmp;
- }
+ stream->Skip<uint32>();
+ HeightMap[x][y] = stream->Read<float>();
}
}
for (uint32 y = 0; y < header.Height; y++)
- {
for (uint32 x = 0; x < header.Width; x++)
- {
- uint8 tmp = 0;
- if (fread(&tmp, sizeof(uint8), 1, stream) == 1)
- ret.RenderFlags[x][y] = tmp;
- }
- }
-
- return ret;
+ RenderFlags[x][y] = stream->Read<uint8>();
}
-H2ORenderMask H2ORenderMask::Read(FILE* stream)
+H2ORenderMask H2ORenderMask::Read(Stream* stream)
{
H2ORenderMask ret;
- int32 count;
- if ((count = fread(&ret.Mask, sizeof(uint8), 8, stream)) != 8)
- printf("H2OHeader::Read: Failed to read some data expected 8, read %d\n", count);
+ stream->Read(ret.Mask, sizeof(uint8) * 8);
return ret;
}
@@ -497,38 +403,42 @@ bool MCNKLiquidData::IsWater(int x, int y, float height)
return false;
}
-H2OHeader H2OHeader::Read(FILE* stream)
+MCNKLiquidData::~MCNKLiquidData()
{
- H2OHeader ret;
- int count = 0;
- count += fread(&ret.OffsetInformation, sizeof(uint32), 1, stream);
- count += fread(&ret.LayerCount, sizeof(uint32), 1, stream);
- count += fread(&ret.OffsetRender, sizeof(uint32), 1, stream);
+ if (!Heights)
+ return;
- if (count != 3)
- printf("H2OHeader::Read: Failed to read some data expected 3, read %d\n", count);
+ for (uint32 i = 0; i < 9; ++i)
+ delete[] Heights[i];
+ delete[] Heights;
+ Heights = NULL;
+}
+H2OHeader H2OHeader::Read(Stream* stream)
+{
+ H2OHeader ret;
+
+ ret.OffsetInformation = stream->Read<uint32>();
+ ret.LayerCount = stream->Read<uint32>();
+ ret.OffsetRender = stream->Read<uint32>();
+
return ret;
}
-H2OInformation H2OInformation::Read(FILE* stream)
+H2OInformation H2OInformation::Read(Stream* stream)
{
H2OInformation ret;
- int count = 0;
- count += fread(&ret.LiquidType, sizeof(uint16), 1, stream);
- count += fread(&ret.Flags, sizeof(uint16), 1, stream);
- count += fread(&ret.HeightLevel1, sizeof(float), 1, stream);
- count += fread(&ret.HeightLevel2, sizeof(float), 1, stream);
- count += fread(&ret.OffsetX, sizeof(uint8), 1, stream);
- count += fread(&ret.OffsetY, sizeof(uint8), 1, stream);
- count += fread(&ret.Width, sizeof(uint8), 1, stream);
- count += fread(&ret.Height, sizeof(uint8), 1, stream);
- count += fread(&ret.OffsetMask2, sizeof(uint32), 1, stream);
- count += fread(&ret.OffsetHeightmap, sizeof(uint32), 1, stream);
-
- if (count != 10)
- printf("H2OInformation::Read: Failed to read some data expected 10, read %d\n", count);
-
+ ret.LiquidType = stream->Read<uint16>();
+ ret.Flags = stream->Read<uint16>();
+ ret.HeightLevel1 = stream->Read<float>();
+ ret.HeightLevel2 = stream->Read<float>();
+ ret.OffsetX = stream->Read<uint8>();
+ ret.OffsetY = stream->Read<uint8>();
+ ret.Width = stream->Read<uint8>();
+ ret.Height = stream->Read<uint8>();
+ ret.OffsetMask2 = stream->Read<uint32>();
+ ret.OffsetHeightmap = stream->Read<uint32>();
+
return ret;
}
@@ -541,24 +451,30 @@ char* Utils::GetPlainName(const char* FileName)
return (char*)FileName;
}
-WMOGroupHeader WMOGroupHeader::Read( FILE* stream )
+WMOGroupHeader WMOGroupHeader::Read(Stream* stream)
{
WMOGroupHeader ret;
- int count = 0;
- count += fread(&ret.OffsetGroupName, sizeof(uint32), 1, stream);
- count += fread(&ret.OffsetDescriptiveName, sizeof(uint32), 1, stream);
- count += fread(&ret.Flags, sizeof(uint32), 1, stream);
+ ret.OffsetGroupName = stream->Read<uint32>();
+ ret.OffsetDescriptiveName = stream->Read<uint32>();
+ ret.Flags = stream->Read<uint32>();
ret.BoundingBox[0] = Vector3::Read(stream);
ret.BoundingBox[1] = Vector3::Read(stream);
- count += fread(&ret.OffsetPortals, sizeof(uint32), 1, stream);
- count += fread(&ret.CountPortals, sizeof(uint32), 1, stream);
- count += fread(&ret.CountBatches, sizeof(uint16), 4, stream);
- count += fread(&ret.Fogs, sizeof(uint8), 4, stream);
- count += fread(&ret.LiquidTypeRelated, sizeof(uint32), 1, stream);
- count += fread(&ret.WmoId, sizeof(uint32), 1, stream);
-
- if (count != 15)
- printf("WMOGroupHeader::Read: Failed to read some data expected 15, read %d\n", count);
-
+ ret.OffsetPortals = stream->Read<uint32>();
+ ret.CountPortals = stream->Read<uint32>();
+ stream->Read(ret.CountBatches, sizeof(uint16) * 4);
+ stream->Read(ret.Fogs, sizeof(uint8) * 4);
+ ret.LiquidTypeRelated = stream->Read<uint32>();
+ ret.WmoId = stream->Read<uint32>();
+
return ret;
}
+
+void Utils::InitializeMmapTileHeader(MmapTileHeader& header)
+{
+ memset(&header, 0, sizeof(MmapTileHeader));
+ header.mmapMagic = MMAP_MAGIC;
+ header.dtVersion = DT_NAVMESH_VERSION;
+ header.mmapVersion = MMAP_VERSION;
+ header.size = 0;
+ header.usesLiquids = true;
+}
diff --git a/src/tools/mesh_extractor/Utils.h b/src/tools/mesh_extractor/Utils.h
index 612282f3e8f..8424d92baa9 100644
--- a/src/tools/mesh_extractor/Utils.h
+++ b/src/tools/mesh_extractor/Utils.h
@@ -27,6 +27,8 @@
#include "Define.h"
#include "Constants.h"
+#include "Stream.h"
+
#include <ace/Stack_Trace.h>
struct WorldModelDefinition;
@@ -59,7 +61,7 @@ struct Vector3
return Vector3(x * s, y * s, z * s);
}
- static Vector3 Read(FILE* file);
+ static Vector3 Read(Stream* file);
};
struct TilePos
@@ -100,7 +102,7 @@ public:
uint32 AreaId;
uint32 MapObjectRefs;
uint32 Holes;
- uint32* LowQualityTextureMap;
+ uint32 LowQualityTextureMap[4];
uint32 PredTex;
uint32 NumberEffectDoodad;
uint32 OffsetMCSE;
@@ -110,7 +112,7 @@ public:
Vector3 Position;
uint32 OffsetMCCV;
- void Read(FILE* stream);
+ void Read(Stream* stream);
};
class MHDR
@@ -130,7 +132,7 @@ public:
uint32 OffsetMH2O;
uint32 OffsetMTFX;
- void Read(FILE* stream);
+ void Read(Stream* stream);
};
class ModelHeader
@@ -187,7 +189,7 @@ public:
uint32 CountBoundingNormals;
uint32 OffsetBoundingNormals;
- void Read(FILE* stream);
+ void Read(Stream* stream);
};
class WorldModelHeader
@@ -206,7 +208,7 @@ public:
Vector3 BoundingBox[2];
uint32 LiquidTypeRelated;
- static WorldModelHeader Read(FILE* stream);
+ void Read(Stream* stream);
};
class DoodadInstance
@@ -223,7 +225,7 @@ public:
float Scale;
uint32 LightColor;
- static DoodadInstance Read(FILE* stream);
+ static DoodadInstance Read(Stream* stream);
};
class DoodadSet
@@ -235,13 +237,13 @@ public:
uint32 CountInstances;
uint32 UnknownZero;
- static DoodadSet Read(FILE* stream);
+ static DoodadSet Read(Stream* stream);
};
class LiquidHeader
{
public:
- LiquidHeader() {}
+ LiquidHeader() : CountXVertices(0), CountYVertices(0), Width(0), Height(0), BaseLocation(0,0,0), MaterialId(0) {}
uint32 CountXVertices;
uint32 CountYVertices;
uint32 Width;
@@ -249,22 +251,36 @@ public:
Vector3 BaseLocation;
uint16 MaterialId;
- static LiquidHeader Read(FILE* stream);
+ void Read(Stream* stream);
};
class LiquidData
{
public:
- LiquidData() {}
+ LiquidData() : HeightMap(NULL), RenderFlags(NULL), CountXVertices(0), Width(0) {}
+
+ ~LiquidData()
+ {
+ for (uint32 i = 0; i < CountXVertices; ++i)
+ delete[] HeightMap[i];
+ delete[] HeightMap;
+
+ for (uint32 i = 0; i < Width; ++i)
+ delete[] RenderFlags[i];
+ delete[] RenderFlags;
+ }
+
float** HeightMap;
uint8** RenderFlags;
+ uint32 CountXVertices;
+ uint32 Width;
- bool ShouldRender(int x, int y)
+ bool ShouldRender(int x, int y) const
{
return RenderFlags[x][y] != 0x0F;
}
- static LiquidData Read(FILE* stream, LiquidHeader& header);
+ void Read(Stream* stream, LiquidHeader& header);
};
class H2ORenderMask
@@ -278,14 +294,15 @@ public:
return (Mask[y] >> x & 1) != 0;
}
- static H2ORenderMask Read(FILE* stream);
+ static H2ORenderMask Read(Stream* stream);
};
class MCNKLiquidData
{
public:
- MCNKLiquidData() {}
+ MCNKLiquidData() : Heights(NULL) {}
MCNKLiquidData(float** heights, H2ORenderMask mask) : Heights(heights), Mask(mask) {}
+ ~MCNKLiquidData();
float** Heights;
H2ORenderMask Mask;
@@ -301,7 +318,7 @@ public:
uint32 LayerCount;
uint32 OffsetRender;
- static H2OHeader Read(FILE* stream);
+ static H2OHeader Read(Stream* stream);
};
class H2OInformation
@@ -319,7 +336,7 @@ public:
uint32 OffsetMask2;
uint32 OffsetHeightmap;
- static H2OInformation Read(FILE* stream);
+ static H2OInformation Read(Stream* stream);
};
class WMOGroupHeader
@@ -338,7 +355,7 @@ public:
uint32 LiquidTypeRelated;
uint32 WmoId;
- static WMOGroupHeader Read(FILE* stream);
+ static WMOGroupHeader Read(Stream* stream);
};
// Dummy class to act as an interface.
@@ -351,7 +368,7 @@ public:
};
#define MMAP_MAGIC 0x4d4d4150 // 'MMAP'
-#define MMAP_VERSION 3
+#define MMAP_VERSION 5
struct MmapTileHeader
{
@@ -359,18 +376,13 @@ struct MmapTileHeader
uint32 dtVersion;
uint32 mmapVersion;
uint32 size;
- bool usesLiquids;
-
- MmapTileHeader() : mmapMagic(MMAP_MAGIC), dtVersion(DT_NAVMESH_VERSION),
- mmapVersion(MMAP_VERSION), size(0), usesLiquids(true) {}
+ bool usesLiquids : 1;
};
class Utils
{
public:
- static void Reverse(char word[]);
- static std::string ReadString(FILE* file);
- static uint32 Size(FILE* file);
+ static void Reverse(std::string& str);
static Vector3 ToRecast(const Vector3& val );
static std::string GetAdtPath(const std::string& world, int x, int y);
static std::string FixModelPath(const std::string& path);
@@ -394,14 +406,15 @@ public:
return false;
return true;
}
- static std::string Replace( std::string str, const std::string& oldStr, const std::string& newStr );
- static void CreateDir( const std::string& Path );
- static void SaveToDisk(FILE* stream, const std::string& path);
- static Vector3 ToWoWCoords(const Vector3& vec );
- static std::string GetExtension( std::string path );
+ static std::string Replace(std::string str, const std::string& oldStr, const std::string& newStr);
+ static void CreateDir(const std::string& Path);
+ static void SaveToDisk(Stream* stream, const std::string& path);
+ static Vector3 ToWoWCoords(const Vector3& vec);
+ static std::string GetExtension( std::string path);
static char* GetPlainName(const char* FileName);
- static Vector3 TransformDoodadVertex(const IDefinition& def, Vector3& vec, bool translate = true);
- static Vector3 VectorTransform(const Vector3& vec, const G3D::Matrix4& matrix, bool normal = false );
- static Vector3 TransformWmoDoodad(const DoodadInstance& inst, const WorldModelDefinition& root, Vector3& vec, bool translate = true );
+ static Vector3 TransformDoodadVertex(const IDefinition& def, Vector3 vec, bool translate = true);
+ static Vector3 VectorTransform(const Vector3& vec, const G3D::Matrix4& matrix, bool normal = false);
+ static Vector3 TransformWmoDoodad(const DoodadInstance& inst, const WorldModelDefinition& root, const Vector3& vec, bool translate = true);
+ static void InitializeMmapTileHeader(MmapTileHeader& header);
};
#endif
diff --git a/src/tools/mesh_extractor/WDT.cpp b/src/tools/mesh_extractor/WDT.cpp
index 07aec95365e..c4afec32a63 100644
--- a/src/tools/mesh_extractor/WDT.cpp
+++ b/src/tools/mesh_extractor/WDT.cpp
@@ -20,6 +20,7 @@
#include "ChunkedData.h"
#include "Utils.h"
#include "WorldModelHandler.h"
+#include "Cache.h"
WDT::WDT(std::string file) : IsGlobalModel(false), IsValid(false), Model(NULL)
{
@@ -37,8 +38,8 @@ void WDT::ReadGlobalModel()
IsGlobalModel = true;
ModelDefinition = WorldModelDefinition::Read(defChunk->GetStream());
- ModelFile = Utils::ReadString(fileChunk->GetStream());
- Model = new WorldModelRoot(ModelFile);
+ ModelFile = fileChunk->GetStream()->ReadString();
+ Model = Cache->WorldModelCache.Get(ModelFile);
}
void WDT::ReadTileTable()
@@ -47,20 +48,14 @@ void WDT::ReadTileTable()
if (!chunk)
return;
IsValid = true;
- FILE* stream = chunk->GetStream();
+ Stream* stream = chunk->GetStream();
for (int y = 0; y < 64; ++y)
{
for (int x = 0; x < 64; ++x)
{
const uint32 hasTileFlag = 0x1;
- uint32 flags;
- uint32 discard;
- int count = 0;
- count += fread(&flags, sizeof(uint32), 1, stream);
- count += fread(&discard, sizeof(uint32), 1, stream);
-
- if (count != 2)
- printf("WDT::ReadTileTable: Failed to read some data expected 2, read %d\n", count);
+ uint32 flags = stream->Read<uint32>();
+ stream->Skip<uint32>();
if (flags & hasTileFlag)
TileTable.push_back(TilePos(x, y));
@@ -69,9 +64,9 @@ void WDT::ReadTileTable()
}
}
-bool WDT::HasTile( int x, int y )
+bool WDT::HasTile( int x, int y ) const
{
- for (std::vector<TilePos>::iterator itr = TileTable.begin(); itr != TileTable.end(); ++itr)
+ for (std::vector<TilePos>::const_iterator itr = TileTable.begin(); itr != TileTable.end(); ++itr)
if (itr->X == x && itr->Y == y)
return true;
return false;
diff --git a/src/tools/mesh_extractor/WDT.h b/src/tools/mesh_extractor/WDT.h
index d1e8e30918d..0deb5830e75 100644
--- a/src/tools/mesh_extractor/WDT.h
+++ b/src/tools/mesh_extractor/WDT.h
@@ -36,8 +36,8 @@ public:
bool IsValid;
std::string ModelFile;
WorldModelDefinition ModelDefinition;
- WorldModelRoot* Model;
- bool HasTile(int x, int y);
+ WorldModelRoot const* Model;
+ bool HasTile(int x, int y) const;
private:
void ReadGlobalModel();
void ReadTileTable();
diff --git a/src/tools/mesh_extractor/WorldModelGroup.cpp b/src/tools/mesh_extractor/WorldModelGroup.cpp
index 6ea72d6edbe..3e16894ced6 100644
--- a/src/tools/mesh_extractor/WorldModelGroup.cpp
+++ b/src/tools/mesh_extractor/WorldModelGroup.cpp
@@ -20,14 +20,37 @@
#include "Chunk.h"
#include "Utils.h"
-WorldModelGroup::WorldModelGroup( std::string path, int groupIndex ) : GroupIndex(groupIndex), MOBA(NULL), IsBad(false), HasLiquidData(false)
+WorldModelGroup::WorldModelGroup(std::string path, int groupIndex) : SubData(NULL), GroupIndex(groupIndex), MOBA(NULL), MOBALength(0), HasLiquidData(false), IsBad(false)
{
Data = new ChunkedData(path);
- if (!Data->Stream)
+ if (!Data->_Stream)
{
IsBad = true;
return;
}
+ Load(path);
+}
+
+WorldModelGroup::WorldModelGroup(Stream* stream, std::string path, int groupIndex) : SubData(NULL), GroupIndex(groupIndex), MOBA(NULL), MOBALength(0), HasLiquidData(false), IsBad(false)
+{
+ Data = new ChunkedData(stream, stream->GetSize());
+ Load(path);
+}
+
+WorldModelGroup::~WorldModelGroup()
+{
+ // Temporarily delete the underlying stream, it is the same pointer for both Data and SubData.
+ // @TODO: Remove this code once the ChunkedData destructor properly releases _Stream
+ delete Data->_Stream;
+
+ delete Data;
+ delete SubData;
+ delete[] MOBA;
+
+}
+
+void WorldModelGroup::Load(std::string& path)
+{
Chunk* mainChunk = Data->GetChunkByName("MOGP");
int32 firstSub = mainChunk->FindSubChunkOffset("MOPY");
if (firstSub == -1)
@@ -35,8 +58,8 @@ WorldModelGroup::WorldModelGroup( std::string path, int groupIndex ) : GroupInde
Name = Utils::GetPlainName(path.c_str());
- FILE* stream = mainChunk->GetStream();
- fseek(stream, firstSub, SEEK_SET);
+ Stream* stream = mainChunk->GetStream();
+ stream->Seek(firstSub, SEEK_SET);
SubData = new ChunkedData(stream, mainChunk->Length - firstSub);
ReadHeader();
@@ -57,7 +80,7 @@ void WorldModelGroup::ReadNormals()
uint32 normalCount = chunk->Length / 12;
ASSERT(normalCount == Vertices.size() && "normalCount is different than the Vertices count");
Normals.reserve(normalCount);
- FILE* stream = chunk->GetStream();
+ Stream* stream = chunk->GetStream();
for (uint32 i = 0; i < normalCount; i++)
Normals.push_back(Vector3::Read(stream));
}
@@ -69,9 +92,9 @@ void WorldModelGroup::ReadLiquid()
return;
HasLiquidData = true;
- FILE* stream = chunk->GetStream();
- LiquidDataHeader = LiquidHeader::Read(stream);
- LiquidDataGeometry = LiquidData::Read(stream, LiquidDataHeader);
+ Stream* stream = chunk->GetStream();
+ LiquidDataHeader.Read(stream);
+ LiquidDataGeometry.Read(stream, LiquidDataHeader);
}
void WorldModelGroup::ReadVertices()
@@ -82,7 +105,7 @@ void WorldModelGroup::ReadVertices()
uint32 verticeCount = chunk->Length / 12;
Vertices.reserve(verticeCount);
- FILE* stream = chunk->GetStream();
+ Stream* stream = chunk->GetStream();
for (uint32 i = 0; i < verticeCount; i++)
Vertices.push_back(Vector3::Read(stream));
}
@@ -95,19 +118,13 @@ void WorldModelGroup::ReadTriangles()
uint32 triangleCount = chunk->Length / 6;
ASSERT(triangleCount == TriangleFlags.size() && "triangleCount != TriangleFlags.size()");
- FILE* stream = chunk->GetStream();
+ Stream* stream = chunk->GetStream();
Triangles.reserve(triangleCount);
for (uint32 i = 0; i < triangleCount; i++)
{
- uint16 v0;
- uint16 v1;
- uint16 v2;
- int count = 0;
- count += fread(&v0, sizeof(uint16), 1, stream);
- count += fread(&v1, sizeof(uint16), 1, stream);
- count += fread(&v2, sizeof(uint16), 1, stream);
- if (count != 3)
- printf("WorldModelGroup::ReadMaterials: Error reading data, expected 3, read %d\n", count);
+ uint16 v0 = stream->Read<uint16>();
+ uint16 v1 = stream->Read<uint16>();
+ uint16 v2 = stream->Read<uint16>();
Triangles.push_back(Triangle<uint16>(Constants::TRIANGLE_TYPE_WMO, v0, v1, v2));
}
@@ -119,20 +136,15 @@ void WorldModelGroup::ReadMaterials()
if (!chunk)
return;
- FILE* stream = chunk->GetStream();
+ Stream* stream = chunk->GetStream();
uint32 triangleCount = chunk->Length / 2;
TriangleFlags.reserve(triangleCount);
TriangleMaterials.reserve(triangleCount);
for (uint32 i = 0; i < triangleCount; i++)
{
- uint8 tmp;
- if (fread(&tmp, sizeof(uint8), 1, stream) != 1)
- printf("WorldModelGroup::ReadMaterials: Error reading data, expected 1, read 0\n");
- TriangleFlags.push_back(tmp);
+ TriangleFlags.push_back(stream->Read<uint8>());
// Read again for material.
- if (fread(&tmp, sizeof(uint8), 1, stream) != 1)
- printf("WorldModelGroup::ReadMaterials: Error reading data, expected 1, read 0\n");
- TriangleMaterials.push_back(tmp);
+ TriangleMaterials.push_back(stream->Read<uint8>());
}
}
@@ -142,7 +154,7 @@ void WorldModelGroup::ReadHeader()
if (!chunk)
return;
- FILE* stream = chunk->GetStream();
+ Stream* stream = chunk->GetStream();
Header = WMOGroupHeader::Read(stream);
}
@@ -154,7 +166,5 @@ void WorldModelGroup::ReadBatches()
MOBALength = chunk->Length / 2;
MOBA = new uint16[MOBALength];
- uint32 count = (uint32)fread(MOBA, sizeof(uint16), MOBALength, chunk->GetStream());
- if (count != MOBALength)
- printf("WorldModelGroup::ReadBatches: Error reading data, expected %u, read %u\n", MOBALength, count);
+ chunk->GetStream()->Read(MOBA, sizeof(uint16) * MOBALength);
}
diff --git a/src/tools/mesh_extractor/WorldModelGroup.h b/src/tools/mesh_extractor/WorldModelGroup.h
index b3c2c2bd940..20d453ee028 100644
--- a/src/tools/mesh_extractor/WorldModelGroup.h
+++ b/src/tools/mesh_extractor/WorldModelGroup.h
@@ -24,6 +24,10 @@ class WorldModelGroup
{
public:
WorldModelGroup(std::string path, int groupIndex);
+ WorldModelGroup(Stream* stream, std::string path, int groupIndex);
+ ~WorldModelGroup();
+ void Load(std::string& path);
+
ChunkedData* Data;
ChunkedData* SubData;
int GroupIndex;
diff --git a/src/tools/mesh_extractor/WorldModelHandler.cpp b/src/tools/mesh_extractor/WorldModelHandler.cpp
index 7c0acbc38e4..18a90365c5b 100644
--- a/src/tools/mesh_extractor/WorldModelHandler.cpp
+++ b/src/tools/mesh_extractor/WorldModelHandler.cpp
@@ -21,27 +21,24 @@
#include "Cache.h"
#include "Model.h"
#include "Define.h"
+#include "Stream.h"
#include "G3D/Matrix4.h"
#include "G3D/Quat.h"
#include <cstdio>
-WorldModelDefinition WorldModelDefinition::Read( FILE* file )
+WorldModelDefinition WorldModelDefinition::Read(Stream* file)
{
WorldModelDefinition ret;
- int count = 0;
- count += fread(&ret.MwidIndex, sizeof(uint32), 1, file);
- count += fread(&ret.UniqueId, sizeof(uint32), 1, file);
+ ret.MwidIndex = file->Read<uint32>();
+ ret.UniqueId = file->Read<uint32>();
ret.Position = Vector3::Read(file);
ret.Rotation = Vector3::Read(file);
ret.UpperExtents = Vector3::Read(file);
ret.LowerExtents = Vector3::Read(file);
- count += fread(&ret.Flags, sizeof(uint16), 1, file);
- count += fread(&ret.DoodadSet, sizeof(uint16), 1, file);
- uint32 discard;
- count += fread(&discard, sizeof(uint32), 1, file);
-
- if (count != 5)
- printf("WorldModelDefinition::Read: Error reading data, expected 5, read %d\n", count);
+ ret.Flags = file->Read<uint16>();
+ ret.DoodadSet = file->Read<uint16>();
+ file->Read<uint32>(); // Discarded
+
return ret;
}
@@ -58,14 +55,12 @@ void WorldModelHandler::ProcessInternal( MapChunk* mcnk )
return;
uint32 refCount = mcnk->Header.MapObjectRefs;
- FILE* stream = mcnk->Source->GetStream();
- fseek(stream, mcnk->Source->Offset + mcnk->Header.OffsetMCRF, SEEK_SET);
+ Stream* stream = mcnk->Source->GetStream();
+ stream->Seek(mcnk->Source->Offset + mcnk->Header.OffsetMCRF, SEEK_SET);
// Start looping at the last Doodad Ref index
for (uint32 i = mcnk->Header.DoodadRefs; i < refCount; i++)
{
- int32 index;
- if (fread(&index, sizeof(int32), 1, stream) != 1)
- printf("WorldModelDefinition::Read: Error reading data, expected 1, read 0\n");
+ int32 index = stream->Read<int32>();
if (index < 0 || uint32(index) >= _definitions->size())
continue;
@@ -80,12 +75,7 @@ void WorldModelHandler::ProcessInternal( MapChunk* mcnk )
continue;
std::string path = (*_paths)[wmo.MwidIndex];
- WorldModelRoot* model = Cache->WorldModelCache.Get(path);
- if (!model)
- {
- model = new WorldModelRoot(path);
- Cache->WorldModelCache.Insert(path, model);
- }
+ WorldModelRoot const* model = Cache->WorldModelCache.Get(path);
Vertices.reserve(1000);
Triangles.reserve(1000);
@@ -93,15 +83,16 @@ void WorldModelHandler::ProcessInternal( MapChunk* mcnk )
InsertModelGeometry(Vertices, Triangles, wmo, model);
}
// Restore the stream position
- fseek(stream, mcnk->Source->Offset, SEEK_SET);
+ stream->Seek(mcnk->Source->Offset, SEEK_SET);
}
-void WorldModelHandler::InsertModelGeometry( std::vector<Vector3>& verts, std::vector<Triangle<uint32> >& tris, const WorldModelDefinition& def, WorldModelRoot* root, bool translate )
+void WorldModelHandler::InsertModelGeometry( std::vector<Vector3>& verts, std::vector<Triangle<uint32> >& tris, const WorldModelDefinition& def, WorldModelRoot const* root, bool translate )
{
- for (std::vector<WorldModelGroup>::iterator group = root->Groups.begin(); group != root->Groups.end(); ++group)
+ for (std::vector<WorldModelGroup*>::const_iterator groupItr = root->Groups.begin(); groupItr != root->Groups.end(); ++groupItr)
{
+ WorldModelGroup const* group = *groupItr;
uint32 vertOffset = verts.size();
- for (std::vector<Vector3>::iterator itr2 = group->Vertices.begin(); itr2 != group->Vertices.end(); ++itr2)
+ for (std::vector<Vector3>::const_iterator itr2 = group->Vertices.begin(); itr2 != group->Vertices.end(); ++itr2)
{
Vector3 v = Utils::TransformDoodadVertex(def, *itr2, translate);
// If translate is false, then we were called directly from the TileBuilder to add data to it's _Geometry member, hence, we have to manually convert the vertices to Recast format.
@@ -111,8 +102,9 @@ void WorldModelHandler::InsertModelGeometry( std::vector<Vector3>& verts, std::v
for (uint32 i = 0; i < group->Triangles.size(); ++i)
{
// only include colliding tris
- if ((group->TriangleFlags[i] & 0x04) != 0 && group->TriangleMaterials[i] != 0xFF)
+ if ((group->TriangleFlags[i] & 0x04) != 0 || group->TriangleMaterials[i] == 0xFF)
continue;
+
Triangle<uint16> tri = group->Triangles[i];
tris.push_back(Triangle<uint32>(Constants::TRIANGLE_TYPE_WMO, tri.V0 + vertOffset, tri.V1 + vertOffset, tri.V2 + vertOffset));
}
@@ -132,38 +124,33 @@ void WorldModelHandler::InsertModelGeometry( std::vector<Vector3>& verts, std::v
for (std::vector<DoodadInstance>::iterator instance = instances.begin(); instance != instances.end(); ++instance)
{
- Model* model = Cache->ModelCache.Get(instance->File);
- if (!model)
- {
- model = new Model(instance->File);
- Cache->ModelCache.Insert(instance->File, model);
- }
+ Model const* model = Cache->ModelCache.Get(instance->File);
if (!model->IsCollidable)
continue;
int vertOffset = verts.size();
- for (std::vector<Vector3>::iterator itr2 = model->Vertices.begin(); itr2 != model->Vertices.end(); ++itr2)
+ for (std::vector<Vector3>::const_iterator itr2 = model->Vertices.begin(); itr2 != model->Vertices.end(); ++itr2)
{
Vector3 v = Utils::TransformDoodadVertex(def, Utils::TransformWmoDoodad(*instance, def, *itr2, false), translate);
verts.push_back(translate ? v : Utils::ToRecast(v));
}
- for (std::vector<Triangle<uint16> >::iterator itr2 = model->Triangles.begin(); itr2 != model->Triangles.end(); ++itr2)
+ for (std::vector<Triangle<uint16> >::const_iterator itr2 = model->Triangles.begin(); itr2 != model->Triangles.end(); ++itr2)
tris.push_back(Triangle<uint32>(Constants::TRIANGLE_TYPE_WMO, itr2->V0 + vertOffset, itr2->V1 + vertOffset, itr2->V2 + vertOffset));
}
- for (std::vector<WorldModelGroup>::iterator group = root->Groups.begin(); group != root->Groups.end(); ++group)
+ for (std::vector<WorldModelGroup*>::const_iterator groupItr = root->Groups.begin(); groupItr != root->Groups.end(); ++groupItr)
{
+ WorldModelGroup const* group = *groupItr;
if (!group->HasLiquidData)
continue;
const LiquidHeader& liquidHeader = group->LiquidDataHeader;
- LiquidData& liquidDataGeometry = group->LiquidDataGeometry;
+ const LiquidData& liquidDataGeometry = group->LiquidDataGeometry;
for (uint32 y = 0; y < liquidHeader.Height; y++)
{
for (uint32 x = 0; x < liquidHeader.Width; x++)
{
-
if (!liquidDataGeometry.ShouldRender(x, y))
continue;
@@ -202,7 +189,7 @@ void WorldModelHandler::ReadDefinitions()
uint32 definitionCount = chunk->Length / definitionSize;
_definitions = new std::vector<WorldModelDefinition>;
_definitions->reserve(definitionCount);
- FILE* stream = chunk->GetStream();
+ Stream* stream = chunk->GetStream();
for (uint32 i = 0; i < definitionCount; i++)
_definitions->push_back(WorldModelDefinition::Read(stream));
}
@@ -219,14 +206,13 @@ void WorldModelHandler::ReadModelPaths()
_paths->reserve(paths);
for (uint32 i = 0; i < paths; i++)
{
- FILE* stream = mwid->GetStream();
- fseek(stream, i * 4, SEEK_CUR);
- uint32 offset;
- if (fread(&offset, sizeof(uint32), 1, stream) != 1)
- printf("WorldModelDefinition::Read: Error reading data, expected 1, read 0\n");
- FILE* dataStream = mwmo->GetStream();
- fseek(dataStream, offset + mwmo->Offset, SEEK_SET);
- _paths->push_back(Utils::ReadString(dataStream));
+ Stream* stream = mwid->GetStream();
+ stream->Seek(i * 4, SEEK_CUR);
+ uint32 offset = stream->Read<uint32>();
+
+ Stream* dataStream = mwmo->GetStream();
+ dataStream->Seek(offset + mwmo->Offset, SEEK_SET);
+ _paths->push_back(dataStream->ReadString());
}
}
diff --git a/src/tools/mesh_extractor/WorldModelHandler.h b/src/tools/mesh_extractor/WorldModelHandler.h
index dd030e4521f..ddc6f589147 100644
--- a/src/tools/mesh_extractor/WorldModelHandler.h
+++ b/src/tools/mesh_extractor/WorldModelHandler.h
@@ -39,7 +39,7 @@ public:
uint16 Flags;
uint16 DoodadSet;
- static WorldModelDefinition Read(FILE* file);
+ static WorldModelDefinition Read(Stream* file);
};
class WorldModelHandler : public ObjectDataHandler
@@ -50,8 +50,8 @@ public:
std::vector<Vector3> Vertices;
std::vector<Triangle<uint32> > Triangles;
- bool IsSane() { return _definitions && _paths; }
- static void InsertModelGeometry(std::vector<Vector3>& verts, std::vector<Triangle<uint32> >& tris, const WorldModelDefinition& def, WorldModelRoot* root, bool translate = true);
+ bool IsSane() const { return _definitions && _paths; }
+ static void InsertModelGeometry(std::vector<Vector3>& verts, std::vector<Triangle<uint32> >& tris, const WorldModelDefinition& def, WorldModelRoot const* root, bool translate = true);
protected:
void ProcessInternal(MapChunk* data);
private:
diff --git a/src/tools/mesh_extractor/WorldModelRoot.cpp b/src/tools/mesh_extractor/WorldModelRoot.cpp
index 4b6e4e189a4..cdeeec5ad26 100644
--- a/src/tools/mesh_extractor/WorldModelRoot.cpp
+++ b/src/tools/mesh_extractor/WorldModelRoot.cpp
@@ -18,6 +18,7 @@
#include "WorldModelRoot.h"
#include "ChunkedData.h"
#include "Utils.h"
+#include "MPQManager.h"
WorldModelRoot::WorldModelRoot( std::string path )
{
@@ -32,6 +33,10 @@ WorldModelRoot::WorldModelRoot( std::string path )
WorldModelRoot::~WorldModelRoot()
{
delete Data;
+ for (std::vector<WorldModelGroup*>::iterator group = Groups.begin(); group != Groups.end(); ++group)
+ delete *group;
+
+ Groups.clear();
}
void WorldModelRoot::ReadGroups()
@@ -42,9 +47,10 @@ void WorldModelRoot::ReadGroups()
{
char name[200];
sprintf(name, "%s_%03u.wmo", pathBase.c_str(), i);
- WorldModelGroup group(name, i);
- if (!group.IsBad)
- Groups.push_back(group);
+ Stream* stream = MPQHandler->GetFile(name);
+ if (!stream)
+ continue;
+ Groups.push_back(new WorldModelGroup(stream, name, i));
}
}
@@ -54,7 +60,7 @@ void WorldModelRoot::ReadDoodadSets()
if (!chunk)
return;
- FILE* stream = chunk->GetStream();
+ Stream* stream = chunk->GetStream();
ASSERT(chunk->Length / 32 == Header.CountSets && "chunk.Length / 32 == Header.CountSets");
DoodadSets.reserve(Header.CountSets);
for (uint32 i = 0; i < Header.CountSets; i++)
@@ -73,14 +79,14 @@ void WorldModelRoot::ReadDoodadInstances()
DoodadInstances.reserve(countInstances);
for (uint32 i = 0; i < countInstances; i++)
{
- FILE* stream = chunk->GetStream();
- fseek(stream, instanceSize * i, SEEK_CUR);
+ Stream* stream = chunk->GetStream();
+ stream->Seek(instanceSize * i, SEEK_CUR);
DoodadInstance instance = DoodadInstance::Read(stream);
- FILE* nameStream = nameChunk->GetStream();
+ Stream* nameStream = nameChunk->GetStream();
if (instance.FileOffset >= nameChunk->Length)
continue;
- fseek(nameStream, instance.FileOffset, SEEK_CUR);
- instance.File = Utils::ReadString(nameStream);
+ nameStream->Seek(instance.FileOffset, SEEK_CUR);
+ instance.File = nameStream->ReadString();
DoodadInstances.push_back(instance);
}
}
@@ -91,6 +97,6 @@ void WorldModelRoot::ReadHeader()
if (!chunk)
return;
- FILE* stream = chunk->GetStream();
- Header = WorldModelHeader::Read(stream);
+ Stream* stream = chunk->GetStream();
+ Header.Read(stream);
}
diff --git a/src/tools/mesh_extractor/WorldModelRoot.h b/src/tools/mesh_extractor/WorldModelRoot.h
index c2303ceafe4..7b1248246ca 100644
--- a/src/tools/mesh_extractor/WorldModelRoot.h
+++ b/src/tools/mesh_extractor/WorldModelRoot.h
@@ -34,7 +34,7 @@ public:
WorldModelHeader Header;
std::vector<DoodadInstance> DoodadInstances;
std::vector<DoodadSet> DoodadSets;
- std::vector<WorldModelGroup> Groups;
+ std::vector<WorldModelGroup*> Groups;
private:
void ReadGroups();
void ReadDoodadSets();