aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/server/game/AI/PlayerAI/PlayerAI.cpp36
-rw-r--r--src/server/game/AI/PlayerAI/PlayerAI.h25
-rw-r--r--src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/boss_pyroguard_emberseer.cpp9
-rw-r--r--src/server/scripts/Kalimdor/zone_ashenvale.cpp5
-rw-r--r--src/server/scripts/Northrend/zone_grizzly_hills.cpp9
-rw-r--r--src/server/scripts/Outland/zone_shadowmoon_valley.cpp12
-rw-r--r--src/server/scripts/Spells/spell_dk.cpp7
-rw-r--r--src/server/scripts/Spells/spell_holiday.cpp11
-rw-r--r--src/server/scripts/Spells/spell_item.cpp12
-rw-r--r--src/server/scripts/Spells/spell_mage.cpp11
-rw-r--r--src/server/scripts/Spells/spell_monk.cpp2
-rw-r--r--src/server/scripts/Spells/spell_pet.cpp7
-rw-r--r--src/server/scripts/Spells/spell_quest.cpp2
-rw-r--r--src/server/scripts/Spells/spell_rogue.cpp1
-rw-r--r--src/server/scripts/Spells/spell_shaman.cpp1
-rw-r--r--src/server/scripts/Spells/spell_warlock.cpp11
-rw-r--r--src/server/scripts/World/chat_log.cpp3
17 files changed, 104 insertions, 60 deletions
diff --git a/src/server/game/AI/PlayerAI/PlayerAI.cpp b/src/server/game/AI/PlayerAI/PlayerAI.cpp
index 2a660fc31d7..d670df82528 100644
--- a/src/server/game/AI/PlayerAI/PlayerAI.cpp
+++ b/src/server/game/AI/PlayerAI/PlayerAI.cpp
@@ -16,6 +16,10 @@
*/
#include "PlayerAI.h"
+#include "Creature.h"
+#include "ObjectAccessor.h"
+#include "Player.h"
+#include "Spell.h"
#include "SpellAuras.h"
#include "SpellAuraEffects.h"
@@ -383,6 +387,25 @@ enum Spells
SPELL_LIFEBLOOM = 48451
};
+PlayerAI::PlayerAI(Player* player) : UnitAI(player), me(player),
+ _selfSpec(player->GetUInt32Value(PLAYER_FIELD_CURRENT_SPEC_ID)),
+ _isSelfHealer(PlayerAI::IsPlayerHealer(player)),
+ _isSelfRangedAttacker(PlayerAI::IsPlayerRangedAttacker(player))
+{
+}
+
+Creature* PlayerAI::GetCharmer() const
+{
+ if (me->GetCharmerGUID().IsCreature())
+ return ObjectAccessor::GetCreature(*me, me->GetCharmerGUID());
+ return nullptr;
+}
+
+uint16 PlayerAI::GetSpec(Player const* who /*= nullptr*/) const
+{
+ return (!who || who == me) ? _selfSpec : who->GetUInt32Value(PLAYER_FIELD_CURRENT_SPEC_ID);
+}
+
bool PlayerAI::IsPlayerHealer(Player const* who)
{
if (!who)
@@ -543,6 +566,13 @@ PlayerAI::TargetedSpell PlayerAI::SelectSpellCast(PossibleSpellVector& spells)
return selected;
}
+void PlayerAI::DoCastAtTarget(TargetedSpell spell)
+{
+ SpellCastTargets targets;
+ targets.SetUnitTarget(spell.second);
+ spell.first->prepare(&targets);
+}
+
void PlayerAI::DoRangedAttackIfReady()
{
if (me->HasUnitState(UNIT_STATE_CASTING))
@@ -614,6 +644,11 @@ void PlayerAI::CancelAllShapeshifts()
me->RemoveOwnedAura(aura, AURA_REMOVE_BY_CANCEL);
}
+Unit* PlayerAI::SelectAttackTarget() const
+{
+ return me->GetCharmer() ? me->GetCharmer()->GetVictim() : nullptr;
+}
+
struct UncontrolledTargetSelectPredicate : public std::unary_function<Unit*, bool>
{
bool operator()(Unit const* target) const
@@ -621,6 +656,7 @@ struct UncontrolledTargetSelectPredicate : public std::unary_function<Unit*, boo
return !target->HasBreakableByDamageCrowdControlAura();
}
};
+
Unit* SimpleCharmedPlayerAI::SelectAttackTarget() const
{
if (Unit* charmer = me->GetCharmer())
diff --git a/src/server/game/AI/PlayerAI/PlayerAI.h b/src/server/game/AI/PlayerAI/PlayerAI.h
index 78c8c3c27b5..a89e262a10d 100644
--- a/src/server/game/AI/PlayerAI/PlayerAI.h
+++ b/src/server/game/AI/PlayerAI/PlayerAI.h
@@ -19,25 +19,19 @@
#define TRINITY_PLAYERAI_H
#include "UnitAI.h"
-#include "Player.h"
-#include "Spell.h"
-#include "Creature.h"
+
+class Spell;
class TC_GAME_API PlayerAI : public UnitAI
{
public:
- explicit PlayerAI(Player* player) : UnitAI(player), me(player), _selfSpec(player->GetUInt32Value(PLAYER_FIELD_CURRENT_SPEC_ID)), _isSelfHealer(PlayerAI::IsPlayerHealer(player)), _isSelfRangedAttacker(PlayerAI::IsPlayerRangedAttacker(player)) { }
+ explicit PlayerAI(Player* player);
void OnCharmed(bool /*apply*/) override { } // charm AI application for players is handled by Unit::SetCharmedBy / Unit::RemoveCharmedBy
- Creature* GetCharmer() const
- {
- if (me->GetCharmerGUID().IsCreature())
- return ObjectAccessor::GetCreature(*me, me->GetCharmerGUID());
- return nullptr;
- }
+ Creature* GetCharmer() const;
// helper functions to determine player info
- uint16 GetSpec(Player const* who = nullptr) const { return (!who || who == me) ? _selfSpec : who->GetUInt32Value(PLAYER_FIELD_CURRENT_SPEC_ID); }
+ uint16 GetSpec(Player const* who = nullptr) const;
static bool IsPlayerHealer(Player const* who);
bool IsHealer(Player const* who = nullptr) const { return (!who || who == me) ? _isSelfHealer : IsPlayerHealer(who); }
static bool IsPlayerRangedAttacker(Player const* who);
@@ -81,14 +75,9 @@ class TC_GAME_API PlayerAI : public UnitAI
This invalidates the vector, and empties it to prevent accidental misuse. */
TargetedSpell SelectSpellCast(PossibleSpellVector& spells);
/* Helper method - casts the included spell at the included target */
- inline void DoCastAtTarget(TargetedSpell spell)
- {
- SpellCastTargets targets;
- targets.SetUnitTarget(spell.second);
- spell.first->prepare(&targets);
- }
+ void DoCastAtTarget(TargetedSpell spell);
- virtual Unit* SelectAttackTarget() const { return me->GetCharmer() ? me->GetCharmer()->GetVictim() : nullptr; }
+ virtual Unit* SelectAttackTarget() const;
void DoRangedAttackIfReady();
void DoAutoAttackIfReady();
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 9dcaf290cb8..b70e7a00ec7 100644
--- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/boss_pyroguard_emberseer.cpp
+++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/boss_pyroguard_emberseer.cpp
@@ -15,12 +15,13 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "ObjectMgr.h"
#include "ScriptMgr.h"
-#include "ScriptedCreature.h"
-#include "Player.h"
-#include "Spell.h"
#include "blackrock_spire.h"
+#include "InstanceScript.h"
+#include "ObjectMgr.h"
+#include "Player.h"
+#include "ScriptedCreature.h"
+#include "SpellInfo.h"
enum Text
{
diff --git a/src/server/scripts/Kalimdor/zone_ashenvale.cpp b/src/server/scripts/Kalimdor/zone_ashenvale.cpp
index 3074ccc936d..b6767768340 100644
--- a/src/server/scripts/Kalimdor/zone_ashenvale.cpp
+++ b/src/server/scripts/Kalimdor/zone_ashenvale.cpp
@@ -28,9 +28,10 @@ npc_ruul_snowhoof
EndContentData */
#include "ScriptMgr.h"
-#include "ScriptedCreature.h"
-#include "ScriptedEscortAI.h"
+#include "GameObject.h"
#include "Player.h"
+#include "ScriptedEscortAI.h"
+#include "SpellInfo.h"
#include "SpellScript.h"
/*####
diff --git a/src/server/scripts/Northrend/zone_grizzly_hills.cpp b/src/server/scripts/Northrend/zone_grizzly_hills.cpp
index 3e3215129d3..cdc0fa36714 100644
--- a/src/server/scripts/Northrend/zone_grizzly_hills.cpp
+++ b/src/server/scripts/Northrend/zone_grizzly_hills.cpp
@@ -17,12 +17,13 @@
*/
#include "ScriptMgr.h"
-#include "ScriptedCreature.h"
-#include "ScriptedEscortAI.h"
+#include "CombatAI.h"
+#include "ObjectAccessor.h"
#include "Player.h"
+#include "ScriptedEscortAI.h"
+#include "SpellInfo.h"
#include "SpellScript.h"
-#include "CreatureTextMgr.h"
-#include "CombatAI.h"
+#include "TemporarySummon.h"
/*######
## Quest 12027: Mr. Floppy's Perilous Adventure
diff --git a/src/server/scripts/Outland/zone_shadowmoon_valley.cpp b/src/server/scripts/Outland/zone_shadowmoon_valley.cpp
index 9b16713bb27..82ba849bbbe 100644
--- a/src/server/scripts/Outland/zone_shadowmoon_valley.cpp
+++ b/src/server/scripts/Outland/zone_shadowmoon_valley.cpp
@@ -37,13 +37,15 @@ npc_enraged_spirit
EndContentData */
#include "ScriptMgr.h"
-#include "ScriptedCreature.h"
-#include "ScriptedGossip.h"
-#include "ScriptedEscortAI.h"
+#include "GameObject.h"
#include "Group.h"
-#include "SpellScript.h"
+#include "ObjectAccessor.h"
#include "Player.h"
-#include "WorldSession.h"
+#include "ScriptedEscortAI.h"
+#include "ScriptedGossip.h"
+#include "SpellInfo.h"
+#include "SpellScript.h"
+#include "TemporarySummon.h"
/*#####
# npc_invis_infernal_caster
diff --git a/src/server/scripts/Spells/spell_dk.cpp b/src/server/scripts/Spells/spell_dk.cpp
index 595b3c22c7a..0bed78d7b07 100644
--- a/src/server/scripts/Spells/spell_dk.cpp
+++ b/src/server/scripts/Spells/spell_dk.cpp
@@ -21,12 +21,13 @@
* Scriptnames of files in this file should be prefixed with "spell_dk_".
*/
-#include "Player.h"
#include "ScriptMgr.h"
-#include "SpellScript.h"
+#include "Containers.h"
+#include "ObjectMgr.h"
+#include "Player.h"
#include "SpellAuraEffects.h"
#include "SpellHistory.h"
-#include "Containers.h"
+#include "SpellScript.h"
enum DeathKnightSpells
{
diff --git a/src/server/scripts/Spells/spell_holiday.cpp b/src/server/scripts/Spells/spell_holiday.cpp
index 9ce05057f37..1f60cd7fb93 100644
--- a/src/server/scripts/Spells/spell_holiday.cpp
+++ b/src/server/scripts/Spells/spell_holiday.cpp
@@ -21,15 +21,16 @@
* Scriptnames in this file should be prefixed with "spell_#holidayname_".
*/
-#include "Player.h"
#include "ScriptMgr.h"
+#include "CellImpl.h"
+#include "CreatureAIImpl.h"
+#include "GridNotifiersImpl.h"
+#include "Player.h"
#include "ScriptedCreature.h"
-#include "SpellScript.h"
#include "SpellAuraEffects.h"
-#include "GridNotifiers.h"
-#include "GridNotifiersImpl.h"
-#include "CellImpl.h"
+#include "SpellScript.h"
#include "Vehicle.h"
+#include "World.h"
// 45102 Romantic Picnic
enum SpellsPicnic
diff --git a/src/server/scripts/Spells/spell_item.cpp b/src/server/scripts/Spells/spell_item.cpp
index f36a3ff38d8..e5d313236d9 100644
--- a/src/server/scripts/Spells/spell_item.cpp
+++ b/src/server/scripts/Spells/spell_item.cpp
@@ -21,15 +21,17 @@
* Scriptnames of files in this file should be prefixed with "spell_item_".
*/
-#include "Player.h"
#include "ScriptMgr.h"
+#include "Battleground.h"
+#include "CreatureAIImpl.h"
+#include "Log.h"
+#include "ObjectMgr.h"
+#include "Player.h"
#include "ScriptedCreature.h"
-#include "SpellScript.h"
+#include "SkillDiscovery.h"
#include "SpellAuraEffects.h"
#include "SpellHistory.h"
-#include "SkillDiscovery.h"
-#include "Battleground.h"
-#include "Log.h"
+#include "SpellScript.h"
// Generic script for handling item dummy effects which trigger another spell.
class spell_item_trigger_spell : public SpellScriptLoader
diff --git a/src/server/scripts/Spells/spell_mage.cpp b/src/server/scripts/Spells/spell_mage.cpp
index 474ec9371ee..9b75fb508eb 100644
--- a/src/server/scripts/Spells/spell_mage.cpp
+++ b/src/server/scripts/Spells/spell_mage.cpp
@@ -21,13 +21,14 @@
* Scriptnames of files in this file should be prefixed with "spell_mage_".
*/
-#include "Player.h"
#include "ScriptMgr.h"
-#include "SpellScript.h"
-#include "SpellHistory.h"
-#include "SpellAuraEffects.h"
-#include "Pet.h"
#include "GridNotifiers.h"
+#include "ObjectAccessor.h"
+#include "Pet.h"
+#include "Player.h"
+#include "SpellAuraEffects.h"
+#include "SpellHistory.h"
+#include "SpellScript.h"
enum MageSpells
{
diff --git a/src/server/scripts/Spells/spell_monk.cpp b/src/server/scripts/Spells/spell_monk.cpp
index 0d9e6ad3f3d..6e86295e322 100644
--- a/src/server/scripts/Spells/spell_monk.cpp
+++ b/src/server/scripts/Spells/spell_monk.cpp
@@ -21,7 +21,9 @@
*/
#include "ScriptMgr.h"
+#include "Spell.h"
#include "SpellAuraEffects.h"
+#include "SpellInfo.h"
#include "SpellMgr.h"
#include "SpellScript.h"
#include "Unit.h"
diff --git a/src/server/scripts/Spells/spell_pet.cpp b/src/server/scripts/Spells/spell_pet.cpp
index 0915feb6100..32d5a81f238 100644
--- a/src/server/scripts/Spells/spell_pet.cpp
+++ b/src/server/scripts/Spells/spell_pet.cpp
@@ -22,11 +22,12 @@
*/
#include "ScriptMgr.h"
-#include "SpellScript.h"
+#include "ObjectMgr.h"
+#include "Pet.h"
+#include "Player.h"
#include "SpellAuraEffects.h"
+#include "SpellScript.h"
#include "Unit.h"
-#include "Player.h"
-#include "Pet.h"
enum HunterPetCalculate
{
diff --git a/src/server/scripts/Spells/spell_quest.cpp b/src/server/scripts/Spells/spell_quest.cpp
index 2959e50992e..72eec36d0e5 100644
--- a/src/server/scripts/Spells/spell_quest.cpp
+++ b/src/server/scripts/Spells/spell_quest.cpp
@@ -22,8 +22,8 @@
*/
#include "CellImpl.h"
+#include "CreatureAIImpl.h"
#include "CreatureTextMgr.h"
-#include "GridNotifiers.h"
#include "GridNotifiersImpl.h"
#include "Player.h"
#include "ScriptMgr.h"
diff --git a/src/server/scripts/Spells/spell_rogue.cpp b/src/server/scripts/Spells/spell_rogue.cpp
index af4283b0e94..894f17e6a05 100644
--- a/src/server/scripts/Spells/spell_rogue.cpp
+++ b/src/server/scripts/Spells/spell_rogue.cpp
@@ -24,6 +24,7 @@
#include "ScriptMgr.h"
#include "Containers.h"
#include "Log.h"
+#include "ObjectAccessor.h"
#include "Player.h"
#include "SpellAuraEffects.h"
#include "SpellHistory.h"
diff --git a/src/server/scripts/Spells/spell_shaman.cpp b/src/server/scripts/Spells/spell_shaman.cpp
index 24b7cccace9..2667f83b42d 100644
--- a/src/server/scripts/Spells/spell_shaman.cpp
+++ b/src/server/scripts/Spells/spell_shaman.cpp
@@ -25,6 +25,7 @@
#include "CellImpl.h"
#include "CreatureAIImpl.h" // for RAND()
#include "GridNotifiersImpl.h"
+#include "ObjectAccessor.h"
#include "Player.h"
#include "SpellScript.h"
#include "SpellHistory.h"
diff --git a/src/server/scripts/Spells/spell_warlock.cpp b/src/server/scripts/Spells/spell_warlock.cpp
index aa4f3cc5086..8ab6dd5be3e 100644
--- a/src/server/scripts/Spells/spell_warlock.cpp
+++ b/src/server/scripts/Spells/spell_warlock.cpp
@@ -21,13 +21,16 @@
* Scriptnames of files in this file should be prefixed with "spell_warl_".
*/
-#include "Player.h"
#include "ScriptMgr.h"
-#include "SpellScript.h"
-#include "SpellAuraEffects.h"
-#include "SpellAuras.h"
#include "AreaTrigger.h"
#include "AreaTriggerTemplate.h"
+#include "Creature.h"
+#include "GameObject.h"
+#include "ObjectAccessor.h"
+#include "Player.h"
+#include "SpellAuraEffects.h"
+#include "SpellAuras.h"
+#include "SpellScript.h"
enum WarlockSpells
{
diff --git a/src/server/scripts/World/chat_log.cpp b/src/server/scripts/World/chat_log.cpp
index 7366b12e8ea..34a232b76eb 100644
--- a/src/server/scripts/World/chat_log.cpp
+++ b/src/server/scripts/World/chat_log.cpp
@@ -17,9 +17,10 @@
#include "ScriptMgr.h"
#include "Channel.h"
-#include "Guild.h"
#include "Group.h"
+#include "Guild.h"
#include "Log.h"
+#include "Player.h"
class ChatLogScript : public PlayerScript
{