aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/Common.h1
-rw-r--r--src/common/Metric/Metric.cpp2
-rw-r--r--src/common/Metric/Metric.h8
-rw-r--r--src/common/Utilities/Util.h32
-rw-r--r--src/server/authserver/Server/AuthSession.cpp73
-rw-r--r--src/server/authserver/Server/AuthSession.h10
-rw-r--r--src/server/database/Database/Implementation/CharacterDatabase.cpp6
-rw-r--r--src/server/game/AI/CoreAI/UnitAI.cpp13
-rw-r--r--src/server/game/AI/ScriptedAI/ScriptedCreature.cpp28
-rw-r--r--src/server/game/AI/ScriptedAI/ScriptedCreature.h32
-rw-r--r--src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp8
-rw-r--r--src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp12
-rw-r--r--src/server/game/AI/SmartScripts/SmartAI.cpp12
-rw-r--r--src/server/game/AI/SmartScripts/SmartScript.cpp25
-rw-r--r--src/server/game/AI/SmartScripts/SmartScript.h11
-rw-r--r--src/server/game/AuctionHouse/AuctionHouseMgr.cpp13
-rw-r--r--src/server/game/AuctionHouseBot/AuctionHouseBot.cpp67
-rw-r--r--src/server/game/AuctionHouseBot/AuctionHouseBot.h5
-rw-r--r--src/server/game/AuctionHouseBot/AuctionHouseBotBuyer.cpp12
-rw-r--r--src/server/game/AuctionHouseBot/AuctionHouseBotSeller.cpp6
-rw-r--r--src/server/game/Battlefield/Zones/BattlefieldWG.cpp216
-rw-r--r--src/server/game/Battlefield/Zones/BattlefieldWG.h33
-rw-r--r--src/server/game/Battlegrounds/ArenaTeam.cpp12
-rw-r--r--src/server/game/Battlegrounds/ArenaTeam.h2
-rw-r--r--src/server/game/Battlegrounds/ArenaTeamMgr.cpp5
-rw-r--r--src/server/game/Battlegrounds/BattlegroundMgr.cpp2
-rw-r--r--src/server/game/Chat/Channels/Channel.cpp782
-rw-r--r--src/server/game/Chat/Channels/Channel.h95
-rw-r--r--src/server/game/Chat/Channels/ChannelAppenders.h476
-rw-r--r--src/server/game/Chat/Channels/ChannelMgr.cpp162
-rw-r--r--src/server/game/Chat/Channels/ChannelMgr.h27
-rw-r--r--src/server/game/Combat/HostileRefManager.cpp8
-rw-r--r--src/server/game/Combat/HostileRefManager.h11
-rw-r--r--src/server/game/Combat/ThreatManager.cpp27
-rw-r--r--src/server/game/Combat/ThreatManager.h37
-rw-r--r--src/server/game/Combat/UnitEvents.h39
-rw-r--r--src/server/game/Conditions/ConditionMgr.cpp1
-rw-r--r--src/server/game/Conditions/ConditionMgr.h2
-rw-r--r--src/server/game/DataStores/DBCEnums.h1
-rw-r--r--src/server/game/DataStores/DBCStructure.h12
-rw-r--r--src/server/game/Entities/Creature/Creature.cpp27
-rw-r--r--src/server/game/Entities/Creature/Creature.h3
-rw-r--r--src/server/game/Entities/GameObject/GameObject.cpp61
-rw-r--r--src/server/game/Entities/GameObject/GameObject.h7
-rw-r--r--src/server/game/Entities/Item/Item.cpp48
-rw-r--r--src/server/game/Entities/Item/Item.h14
-rw-r--r--src/server/game/Entities/Item/ItemTemplate.h195
-rw-r--r--src/server/game/Entities/Object/Object.cpp114
-rw-r--r--src/server/game/Entities/Object/Object.h11
-rw-r--r--src/server/game/Entities/Player/Player.cpp402
-rw-r--r--src/server/game/Entities/Player/Player.h13
-rw-r--r--src/server/game/Entities/Transport/Transport.cpp6
-rw-r--r--src/server/game/Entities/Unit/StatSystem.cpp25
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp1008
-rw-r--r--src/server/game/Entities/Unit/Unit.h107
-rw-r--r--src/server/game/Globals/ObjectMgr.cpp23
-rw-r--r--src/server/game/Globals/ObjectMgr.h2
-rw-r--r--src/server/game/Grids/GridRefManager.h2
-rw-r--r--src/server/game/Grids/Notifiers/GridNotifiers.h416
-rw-r--r--src/server/game/Grids/Notifiers/GridNotifiersImpl.h20
-rw-r--r--src/server/game/Groups/Group.cpp2
-rw-r--r--src/server/game/Guilds/Guild.cpp285
-rw-r--r--src/server/game/Guilds/Guild.h1138
-rw-r--r--src/server/game/Handlers/AuctionHouseHandler.cpp2
-rw-r--r--src/server/game/Handlers/ChannelHandler.cpp132
-rw-r--r--src/server/game/Handlers/CharacterHandler.cpp7
-rw-r--r--src/server/game/Handlers/ChatHandler.cpp10
-rw-r--r--src/server/game/Handlers/ItemHandler.cpp12
-rw-r--r--src/server/game/Handlers/LootHandler.cpp4
-rw-r--r--src/server/game/Handlers/MailHandler.cpp6
-rw-r--r--src/server/game/Handlers/PetitionsHandler.cpp16
-rw-r--r--src/server/game/Handlers/SpellHandler.cpp8
-rw-r--r--src/server/game/Handlers/TradeHandler.cpp6
-rw-r--r--src/server/game/Loot/LootMgr.cpp153
-rw-r--r--src/server/game/Loot/LootMgr.h49
-rw-r--r--src/server/game/Maps/MapRefManager.h15
-rw-r--r--src/server/game/Miscellaneous/SharedDefines.h17
-rw-r--r--src/server/game/Movement/MovementGenerators/HomeMovementGenerator.cpp2
-rw-r--r--src/server/game/Scripting/ScriptMgr.cpp21
-rw-r--r--src/server/game/Scripting/ScriptMgr.h5
-rw-r--r--src/server/game/Spells/Auras/SpellAuraEffects.cpp649
-rw-r--r--src/server/game/Spells/Auras/SpellAuraEffects.h2
-rw-r--r--src/server/game/Spells/Auras/SpellAuras.cpp281
-rw-r--r--src/server/game/Spells/Auras/SpellAuras.h14
-rw-r--r--src/server/game/Spells/Spell.cpp781
-rw-r--r--src/server/game/Spells/Spell.h45
-rw-r--r--src/server/game/Spells/SpellEffects.cpp137
-rw-r--r--src/server/game/Spells/SpellInfo.cpp1266
-rw-r--r--src/server/game/Spells/SpellInfo.h440
-rw-r--r--src/server/game/Spells/SpellMgr.cpp595
-rw-r--r--src/server/game/Spells/SpellMgr.h27
-rw-r--r--src/server/game/Spells/SpellScript.cpp68
-rw-r--r--src/server/game/Spells/SpellScript.h8
-rw-r--r--src/server/game/World/World.cpp9
-rw-r--r--src/server/scripts/Commands/cs_cast.cpp15
-rw-r--r--src/server/scripts/Commands/cs_guild.cpp9
-rw-r--r--src/server/scripts/Commands/cs_message.cpp43
-rw-r--r--src/server/scripts/Commands/cs_misc.cpp35
-rw-r--r--src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/blackrock_spire.h6
-rw-r--r--src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/instance_blackrock_spire.cpp30
-rw-r--r--src/server/scripts/EasternKingdoms/ShadowfangKeep/shadowfang_keep.cpp119
-rw-r--r--src/server/scripts/EasternKingdoms/ShadowfangKeep/shadowfang_keep.h4
-rw-r--r--src/server/scripts/EasternKingdoms/eastern_kingdoms_script_loader.cpp4
-rw-r--r--src/server/scripts/EasternKingdoms/zone_eastern_plaguelands.cpp140
-rw-r--r--src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_anetheron.cpp4
-rw-r--r--src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/the_black_morass.cpp62
-rw-r--r--src/server/scripts/Kalimdor/zone_stonetalon_mountains.cpp68
-rw-r--r--src/server/scripts/Northrend/AzjolNerub/AzjolNerub/azjol_nerub.h3
-rw-r--r--src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_anubarak.cpp6
-rw-r--r--src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_hadronox.cpp2
-rw-r--r--src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_krikthir_the_gatewatcher.cpp25
-rw-r--r--src/server/scripts/Northrend/AzjolNerub/AzjolNerub/instance_azjol_nerub.cpp14
-rw-r--r--src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_northrend_beasts.cpp423
-rw-r--r--src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_devourer_of_souls.cpp6
-rw-r--r--src/server/scripts/Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp8
-rw-r--r--src/server/scripts/Northrend/IcecrownCitadel/boss_lady_deathwhisper.cpp818
-rw-r--r--src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp2
-rw-r--r--src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp6
-rw-r--r--src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp8
-rw-r--r--src/server/scripts/Northrend/Nexus/Oculus/oculus.cpp5
-rw-r--r--src/server/scripts/Northrend/Ulduar/Ulduar/boss_yogg_saron.cpp8
-rw-r--r--src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/utgarde_keep.cpp4
-rw-r--r--src/server/scripts/Northrend/zone_dragonblight.cpp26
-rw-r--r--src/server/scripts/Northrend/zone_storm_peaks.cpp1
-rw-r--r--src/server/scripts/Northrend/zone_wintergrasp.cpp308
-rw-r--r--src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/shadow_labyrinth.cpp2
-rw-r--r--src/server/scripts/Outland/BlackTemple/black_temple.h18
-rw-r--r--src/server/scripts/Outland/BlackTemple/boss_illidan.cpp24
-rw-r--r--src/server/scripts/Outland/BlackTemple/boss_shade_of_akama.cpp93
-rw-r--r--src/server/scripts/Outland/BlackTemple/instance_black_temple.cpp189
-rw-r--r--src/server/scripts/Outland/boss_doomlord_kazzak.cpp4
-rw-r--r--src/server/scripts/Outland/zone_hellfire_peninsula.cpp184
-rw-r--r--src/server/scripts/Pet/pet_hunter.cpp60
-rw-r--r--src/server/scripts/Spells/spell_dk.cpp91
-rw-r--r--src/server/scripts/Spells/spell_druid.cpp177
-rw-r--r--src/server/scripts/Spells/spell_generic.cpp20
-rw-r--r--src/server/scripts/Spells/spell_hunter.cpp213
-rw-r--r--src/server/scripts/Spells/spell_item.cpp225
-rw-r--r--src/server/scripts/Spells/spell_mage.cpp44
-rw-r--r--src/server/scripts/Spells/spell_paladin.cpp78
-rw-r--r--src/server/scripts/Spells/spell_priest.cpp59
-rw-r--r--src/server/scripts/Spells/spell_quest.cpp144
-rw-r--r--src/server/scripts/Spells/spell_rogue.cpp16
-rw-r--r--src/server/scripts/Spells/spell_shaman.cpp146
-rw-r--r--src/server/scripts/Spells/spell_warlock.cpp135
-rw-r--r--src/server/scripts/Spells/spell_warrior.cpp55
-rw-r--r--src/server/scripts/World/go_scripts.cpp182
-rw-r--r--src/server/shared/Dynamic/LinkedList.h56
-rw-r--r--src/server/shared/Dynamic/LinkedReference/RefManager.h30
-rw-r--r--src/server/shared/Dynamic/LinkedReference/Reference.h7
-rw-r--r--src/server/worldserver/worldserver.conf.dist9
-rw-r--r--src/tools/vmap4_extractor/mpq_libmpq.cpp6
-rw-r--r--src/tools/vmap4_extractor/mpq_libmpq04.h12
153 files changed, 8693 insertions, 6840 deletions
diff --git a/src/common/Common.h b/src/common/Common.h
index aa04abacd30..af9b9b17321 100644
--- a/src/common/Common.h
+++ b/src/common/Common.h
@@ -35,6 +35,7 @@
#include <unordered_map>
#include <unordered_set>
#include <vector>
+#include <numeric>
#include <cmath>
#include <cstdio>
diff --git a/src/common/Metric/Metric.cpp b/src/common/Metric/Metric.cpp
index 9484cebcc72..cb6b3b1217b 100644
--- a/src/common/Metric/Metric.cpp
+++ b/src/common/Metric/Metric.cpp
@@ -22,7 +22,7 @@
void Metric::Initialize(std::string const& realmName, boost::asio::io_service& ioService, std::function<void()> overallStatusLogger)
{
- _realmName = realmName;
+ _realmName = FormatInfluxDBTagValue(realmName);
_batchTimer = Trinity::make_unique<boost::asio::deadline_timer>(ioService);
_overallStatusTimer = Trinity::make_unique<boost::asio::deadline_timer>(ioService);
_overallStatusLogger = overallStatusLogger;
diff --git a/src/common/Metric/Metric.h b/src/common/Metric/Metric.h
index 1855e1d0098..9230983da4d 100644
--- a/src/common/Metric/Metric.h
+++ b/src/common/Metric/Metric.h
@@ -79,6 +79,14 @@ private:
static std::string FormatInfluxDBValue(double value) { return std::to_string(value); }
static std::string FormatInfluxDBValue(float value) { return FormatInfluxDBValue(double(value)); }
+ static std::string FormatInfluxDBTagValue(std::string const& value)
+ {
+ // ToDo: should handle '=' and ',' characters too
+ return boost::replace_all_copy(value, " ", "\\ ");
+ }
+
+ // ToDo: should format TagKey and FieldKey too in the same way as TagValue
+
public:
static Metric* instance();
diff --git a/src/common/Utilities/Util.h b/src/common/Utilities/Util.h
index fc322a89583..88708a79cd6 100644
--- a/src/common/Utilities/Util.h
+++ b/src/common/Utilities/Util.h
@@ -327,33 +327,35 @@ TC_COMMON_API bool StringToBool(std::string const& str);
// simple class for not-modifyable list
template <typename T>
-class HookList
+class HookList final
{
- typedef typename std::list<T>::iterator ListIterator;
private:
- typename std::list<T> m_list;
+ typedef std::vector<T> ContainerType;
+
+ ContainerType _container;
+
public:
- HookList<T> & operator+=(T t)
- {
- m_list.push_back(t);
- return *this;
- }
- HookList<T> & operator-=(T t)
+ typedef typename ContainerType::iterator iterator;
+
+ HookList<T>& operator+=(T t)
{
- m_list.remove(t);
+ _container.push_back(t);
return *this;
}
+
size_t size()
{
- return m_list.size();
+ return _container.size();
}
- ListIterator begin()
+
+ iterator begin()
{
- return m_list.begin();
+ return _container.begin();
}
- ListIterator end()
+
+ iterator end()
{
- return m_list.end();
+ return _container.end();
}
};
diff --git a/src/server/authserver/Server/AuthSession.cpp b/src/server/authserver/Server/AuthSession.cpp
index 45c2b61436f..b139d50ef8a 100644
--- a/src/server/authserver/Server/AuthSession.cpp
+++ b/src/server/authserver/Server/AuthSession.cpp
@@ -118,10 +118,10 @@ std::unordered_map<uint8, AuthHandler> AuthSession::InitHandlers()
{
std::unordered_map<uint8, AuthHandler> handlers;
- handlers[AUTH_LOGON_CHALLENGE] = { STATUS_CONNECTED, AUTH_LOGON_CHALLENGE_INITIAL_SIZE, &AuthSession::HandleLogonChallenge };
- handlers[AUTH_LOGON_PROOF] = { STATUS_CONNECTED, sizeof(AUTH_LOGON_PROOF_C), &AuthSession::HandleLogonProof };
- handlers[AUTH_RECONNECT_CHALLENGE] = { STATUS_CONNECTED, AUTH_LOGON_CHALLENGE_INITIAL_SIZE, &AuthSession::HandleReconnectChallenge };
- handlers[AUTH_RECONNECT_PROOF] = { STATUS_CONNECTED, sizeof(AUTH_RECONNECT_PROOF_C), &AuthSession::HandleReconnectProof };
+ handlers[AUTH_LOGON_CHALLENGE] = { STATUS_CHALLENGE, AUTH_LOGON_CHALLENGE_INITIAL_SIZE, &AuthSession::HandleLogonChallenge };
+ handlers[AUTH_LOGON_PROOF] = { STATUS_LOGON_PROOF, sizeof(AUTH_LOGON_PROOF_C), &AuthSession::HandleLogonProof };
+ handlers[AUTH_RECONNECT_CHALLENGE] = { STATUS_CHALLENGE, AUTH_LOGON_CHALLENGE_INITIAL_SIZE, &AuthSession::HandleReconnectChallenge };
+ handlers[AUTH_RECONNECT_PROOF] = { STATUS_RECONNECT_PROOF, sizeof(AUTH_RECONNECT_PROOF_C), &AuthSession::HandleReconnectProof };
handlers[REALM_LIST] = { STATUS_AUTHED, REALM_LIST_PACKET_SIZE, &AuthSession::HandleRealmList };
return handlers;
@@ -154,8 +154,7 @@ void AccountInfo::LoadResult(Field* fields)
}
AuthSession::AuthSession(tcp::socket&& socket) : Socket(std::move(socket)),
-_sentChallenge(false), _sentProof(false),
-_status(STATUS_CONNECTED), _build(0), _expversion(0)
+_status(STATUS_CHALLENGE), _build(0), _expversion(0)
{
N.SetHexStr("894B645E89E1535BBDAD5B8B290650530801B18EBFBF5E8FAB3C82872A3E9BB7");
g.SetDword(7);
@@ -285,10 +284,7 @@ void AuthSession::SendPacket(ByteBuffer& packet)
bool AuthSession::HandleLogonChallenge()
{
- if (_sentChallenge)
- return false;
-
- _sentChallenge = true;
+ _status = STATUS_CLOSED;
sAuthLogonChallenge_C* challenge = reinterpret_cast<sAuthLogonChallenge_C*>(GetReadBuffer().GetReadPointer());
if (challenge->size - (sizeof(sAuthLogonChallenge_C) - AUTH_LOGON_CHALLENGE_INITIAL_SIZE - 1) != challenge->I_len)
@@ -428,7 +424,10 @@ void AuthSession::LogonChallengeCallback(PreparedQueryResult result)
// Fill the response packet with the result
if (AuthHelper::IsAcceptedClientBuild(_build))
+ {
pkt << uint8(WOW_SUCCESS);
+ _status = STATUS_LOGON_PROOF;
+ }
else
pkt << uint8(WOW_FAIL_VERSION_INVALID);
@@ -477,10 +476,7 @@ void AuthSession::LogonChallengeCallback(PreparedQueryResult result)
bool AuthSession::HandleLogonProof()
{
TC_LOG_DEBUG("server.authserver", "Entering _HandleLogonProof");
- if (_sentProof)
- return false;
-
- _sentProof = true;
+ _status = STATUS_CLOSED;
// Read the packet
sAuthLogonProof_C *logonProof = reinterpret_cast<sAuthLogonProof_C*>(GetReadBuffer().GetReadPointer());
@@ -500,9 +496,7 @@ bool AuthSession::HandleLogonProof()
// SRP safeguard: abort if A == 0
if (A.IsZero())
- {
return false;
- }
SHA1Hash sha;
sha.UpdateBigNumbers(&A, &B, NULL);
@@ -571,24 +565,6 @@ bool AuthSession::HandleLogonProof()
// Check if SRP6 results match (password is correct), else send an error
if (!memcmp(M.AsByteArray(sha.GetLength()).get(), logonProof->M1, 20))
{
- TC_LOG_DEBUG("server.authserver", "'%s:%d' User '%s' successfully authenticated", GetRemoteIpAddress().to_string().c_str(), GetRemotePort(), _accountInfo.Login.c_str());
-
- // Update the sessionkey, last_ip, last login time and reset number of failed logins in the account table for this account
- // No SQL injection (escaped user name) and IP address as received by socket
-
- PreparedStatement *stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_LOGONPROOF);
- stmt->setString(0, K.AsHexStr());
- stmt->setString(1, GetRemoteIpAddress().to_string().c_str());
- stmt->setUInt32(2, GetLocaleByName(_localizationName));
- stmt->setString(3, _os);
- stmt->setString(4, _accountInfo.Login);
- LoginDatabase.DirectExecute(stmt);
-
- // Finish SRP6 and send the final result to the client
- sha.Initialize();
- sha.UpdateBigNumbers(&A, &M, &K, NULL);
- sha.Finalize();
-
// Check auth token
if ((logonProof->securityFlags & 0x04) || !_tokenKey.empty())
{
@@ -610,6 +586,24 @@ bool AuthSession::HandleLogonProof()
}
}
+ TC_LOG_DEBUG("server.authserver", "'%s:%d' User '%s' successfully authenticated", GetRemoteIpAddress().to_string().c_str(), GetRemotePort(), _accountInfo.Login.c_str());
+
+ // Update the sessionkey, last_ip, last login time and reset number of failed logins in the account table for this account
+ // No SQL injection (escaped user name) and IP address as received by socket
+
+ PreparedStatement *stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_LOGONPROOF);
+ stmt->setString(0, K.AsHexStr());
+ stmt->setString(1, GetRemoteIpAddress().to_string().c_str());
+ stmt->setUInt32(2, GetLocaleByName(_localizationName));
+ stmt->setString(3, _os);
+ stmt->setString(4, _accountInfo.Login);
+ LoginDatabase.DirectExecute(stmt);
+
+ // Finish SRP6 and send the final result to the client
+ sha.Initialize();
+ sha.UpdateBigNumbers(&A, &M, &K, NULL);
+ sha.Finalize();
+
ByteBuffer packet;
if (_expversion & POST_BC_EXP_FLAG) // 2.x and 3.x clients
{
@@ -705,10 +699,7 @@ bool AuthSession::HandleLogonProof()
bool AuthSession::HandleReconnectChallenge()
{
- if (_sentChallenge)
- return false;
-
- _sentChallenge = true;
+ _status = STATUS_CLOSED;
sAuthLogonChallenge_C* challenge = reinterpret_cast<sAuthLogonChallenge_C*>(GetReadBuffer().GetReadPointer());
if (challenge->size - (sizeof(sAuthLogonChallenge_C) - AUTH_LOGON_CHALLENGE_INITIAL_SIZE - 1) != challenge->I_len)
@@ -768,6 +759,7 @@ void AuthSession::ReconnectChallengeCallback(PreparedQueryResult result)
_accountInfo.LoadResult(fields);
K.SetHexStr(fields[9].GetCString());
_reconnectProof.SetRand(16 * 8);
+ _status = STATUS_RECONNECT_PROOF;
pkt << uint8(WOW_SUCCESS);
pkt.append(_reconnectProof.AsByteArray(16).get(), 16); // 16 bytes random
@@ -779,10 +771,7 @@ void AuthSession::ReconnectChallengeCallback(PreparedQueryResult result)
bool AuthSession::HandleReconnectProof()
{
TC_LOG_DEBUG("server.authserver", "Entering _HandleReconnectProof");
- if (_sentProof)
- return false;
-
- _sentProof = true;
+ _status = STATUS_CLOSED;
sAuthReconnectProof_C *reconnectProof = reinterpret_cast<sAuthReconnectProof_C*>(GetReadBuffer().GetReadPointer());
diff --git a/src/server/authserver/Server/AuthSession.h b/src/server/authserver/Server/AuthSession.h
index 027011629eb..98d2cb9fcdb 100644
--- a/src/server/authserver/Server/AuthSession.h
+++ b/src/server/authserver/Server/AuthSession.h
@@ -34,8 +34,11 @@ struct AuthHandler;
enum AuthStatus
{
- STATUS_CONNECTED = 0,
- STATUS_AUTHED
+ STATUS_CHALLENGE = 0,
+ STATUS_LOGON_PROOF,
+ STATUS_RECONNECT_PROOF,
+ STATUS_AUTHED,
+ STATUS_CLOSED
};
struct AccountInfo
@@ -90,9 +93,6 @@ private:
BigNumber K;
BigNumber _reconnectProof;
- bool _sentChallenge;
- bool _sentProof;
-
AuthStatus _status;
AccountInfo _accountInfo;
std::string _tokenKey;
diff --git a/src/server/database/Database/Implementation/CharacterDatabase.cpp b/src/server/database/Database/Implementation/CharacterDatabase.cpp
index 658827662ec..6122e5aca7b 100644
--- a/src/server/database/Database/Implementation/CharacterDatabase.cpp
+++ b/src/server/database/Database/Implementation/CharacterDatabase.cpp
@@ -226,7 +226,7 @@ void CharacterDatabaseConnection::DoPrepareStatements()
PrepareStatement(CHAR_SEL_CHAR_DATA_FOR_GUILD, "SELECT name, level, class, zone, account FROM characters WHERE guid = ?", CONNECTION_SYNCH);
// Chat channel handling
- PrepareStatement(CHAR_SEL_CHANNEL, "SELECT announce, ownership, password, bannedList FROM channels WHERE name = ? AND team = ?", CONNECTION_SYNCH);
+ PrepareStatement(CHAR_SEL_CHANNEL, "SELECT name, announce, ownership, password, bannedList FROM channels WHERE name = ? AND team = ?", CONNECTION_SYNCH);
PrepareStatement(CHAR_INS_CHANNEL, "INSERT INTO channels(name, team, lastUsed) VALUES (?, ?, UNIX_TIMESTAMP())", CONNECTION_ASYNC);
PrepareStatement(CHAR_UPD_CHANNEL, "UPDATE channels SET announce = ?, ownership = ?, password = ?, bannedList = ?, lastUsed = UNIX_TIMESTAMP() WHERE name = ? AND team = ?", CONNECTION_ASYNC);
PrepareStatement(CHAR_UPD_CHANNEL_USAGE, "UPDATE channels SET lastUsed = UNIX_TIMESTAMP() WHERE name = ? AND team = ?", CONNECTION_ASYNC);
@@ -243,8 +243,8 @@ void CharacterDatabaseConnection::DoPrepareStatements()
PrepareStatement(CHAR_DEL_EQUIP_SET, "DELETE FROM character_equipmentsets WHERE setguid=?", CONNECTION_ASYNC);
// Auras
- PrepareStatement(CHAR_INS_AURA, "INSERT INTO character_aura (guid, casterGuid, itemGuid, spell, effectMask, recalculateMask, stackCount, amount0, amount1, amount2, base_amount0, base_amount1, base_amount2, maxDuration, remainTime, remainCharges) "
- "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC);
+ PrepareStatement(CHAR_INS_AURA, "INSERT INTO character_aura (guid, casterGuid, spell, effectMask, recalculateMask, stackCount, amount0, amount1, amount2, base_amount0, base_amount1, base_amount2, maxDuration, remainTime, remainCharges) "
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC);
// Account data
PrepareStatement(CHAR_SEL_ACCOUNT_DATA, "SELECT type, time, data FROM account_data WHERE accountId = ?", CONNECTION_ASYNC);
diff --git a/src/server/game/AI/CoreAI/UnitAI.cpp b/src/server/game/AI/CoreAI/UnitAI.cpp
index fbb79426bb8..a2967dc7391 100644
--- a/src/server/game/AI/CoreAI/UnitAI.cpp
+++ b/src/server/game/AI/CoreAI/UnitAI.cpp
@@ -56,16 +56,25 @@ void UnitAI::DoMeleeAttackIfReady()
if (!me->IsWithinMeleeRange(victim))
return;
+ bool sparAttack = me->GetFactionTemplateEntry()->ShouldSparAttack() && victim->GetFactionTemplateEntry()->ShouldSparAttack();
//Make sure our attack is ready and we aren't currently casting before checking distance
if (me->isAttackReady())
{
- me->AttackerStateUpdate(victim);
+ if (sparAttack)
+ me->FakeAttackerStateUpdate(victim);
+ else
+ me->AttackerStateUpdate(victim);
+
me->resetAttackTimer();
}
if (me->haveOffhandWeapon() && me->isAttackReady(OFF_ATTACK))
{
- me->AttackerStateUpdate(victim, OFF_ATTACK);
+ if (sparAttack)
+ me->FakeAttackerStateUpdate(victim, OFF_ATTACK);
+ else
+ me->AttackerStateUpdate(victim, OFF_ATTACK);
+
me->resetAttackTimer(OFF_ATTACK);
}
}
diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp
index 241441db958..b6635db5daf 100644
--- a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp
+++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp
@@ -569,7 +569,7 @@ void BossAI::_DespawnAtEvade(uint32 delayToRespawn, Creature* who)
return;
}
- me->DespawnOrUnsummon(0, Seconds(delayToRespawn));
+ who->DespawnOrUnsummon(0, Seconds(delayToRespawn));
if (instance && who == me)
instance->SetBossState(_bossId, FAIL);
@@ -635,29 +635,3 @@ void WorldBossAI::UpdateAI(uint32 diff)
DoMeleeAttackIfReady();
}
-
-// SD2 grid searchers.
-Creature* GetClosestCreatureWithEntry(WorldObject* source, uint32 entry, float maxSearchRange, bool alive /*= true*/)
-{
- return source->FindNearestCreature(entry, maxSearchRange, alive);
-}
-
-GameObject* GetClosestGameObjectWithEntry(WorldObject* source, uint32 entry, float maxSearchRange)
-{
- return source->FindNearestGameObject(entry, maxSearchRange);
-}
-
-void GetCreatureListWithEntryInGrid(std::list<Creature*>& list, WorldObject* source, uint32 entry, float maxSearchRange)
-{
- source->GetCreatureListWithEntryInGrid(list, entry, maxSearchRange);
-}
-
-void GetGameObjectListWithEntryInGrid(std::list<GameObject*>& list, WorldObject* source, uint32 entry, float maxSearchRange)
-{
- source->GetGameObjectListWithEntryInGrid(list, entry, maxSearchRange);
-}
-
-void GetPlayerListInGrid(std::list<Player*>& list, WorldObject* source, float maxSearchRange)
-{
- source->GetPlayerListInGrid(list, maxSearchRange);
-}
diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.h b/src/server/game/AI/ScriptedAI/ScriptedCreature.h
index 08cc4fa3960..37a7020752b 100644
--- a/src/server/game/AI/ScriptedAI/ScriptedCreature.h
+++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.h
@@ -417,10 +417,32 @@ class TC_GAME_API WorldBossAI : public ScriptedAI
};
// SD2 grid searchers.
-TC_GAME_API Creature* GetClosestCreatureWithEntry(WorldObject* source, uint32 entry, float maxSearchRange, bool alive = true);
-TC_GAME_API GameObject* GetClosestGameObjectWithEntry(WorldObject* source, uint32 entry, float maxSearchRange);
-TC_GAME_API void GetCreatureListWithEntryInGrid(std::list<Creature*>& list, WorldObject* source, uint32 entry, float maxSearchRange);
-TC_GAME_API void GetGameObjectListWithEntryInGrid(std::list<GameObject*>& list, WorldObject* source, uint32 entry, float maxSearchRange);
-TC_GAME_API void GetPlayerListInGrid(std::list<Player*>& list, WorldObject* source, float maxSearchRange);
+inline Creature* GetClosestCreatureWithEntry(WorldObject* source, uint32 entry, float maxSearchRange, bool alive = true)
+{
+ return source->FindNearestCreature(entry, maxSearchRange, alive);
+}
+
+inline GameObject* GetClosestGameObjectWithEntry(WorldObject* source, uint32 entry, float maxSearchRange)
+{
+ return source->FindNearestGameObject(entry, maxSearchRange);
+}
+
+template <typename Container>
+inline void GetCreatureListWithEntryInGrid(Container& container, WorldObject* source, uint32 entry, float maxSearchRange)
+{
+ source->GetCreatureListWithEntryInGrid(container, entry, maxSearchRange);
+}
+
+template <typename Container>
+inline void GetGameObjectListWithEntryInGrid(Container& container, WorldObject* source, uint32 entry, float maxSearchRange)
+{
+ source->GetGameObjectListWithEntryInGrid(container, entry, maxSearchRange);
+}
+
+template <typename Container>
+inline void GetPlayerListInGrid(Container& container, WorldObject* source, float maxSearchRange)
+{
+ source->GetPlayerListInGrid(container, maxSearchRange);
+}
#endif // SCRIPTEDCREATURE_H_
diff --git a/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp b/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp
index 89ad726b253..9e55b9d8187 100644
--- a/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp
+++ b/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp
@@ -150,14 +150,10 @@ void npc_escortAI::JustDied(Unit* /*killer*/)
{
for (GroupReference* groupRef = group->GetFirstMember(); groupRef != NULL; groupRef = groupRef->next())
if (Player* member = groupRef->GetSource())
- if (member->GetQuestStatus(m_pQuestForEscort->GetQuestId()) == QUEST_STATUS_INCOMPLETE)
- member->FailQuest(m_pQuestForEscort->GetQuestId());
+ member->FailQuest(m_pQuestForEscort->GetQuestId());
}
else
- {
- if (player->GetQuestStatus(m_pQuestForEscort->GetQuestId()) == QUEST_STATUS_INCOMPLETE)
- player->FailQuest(m_pQuestForEscort->GetQuestId());
- }
+ player->FailQuest(m_pQuestForEscort->GetQuestId());
}
}
diff --git a/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp b/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp
index 24de7344f99..9730370a77c 100644
--- a/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp
+++ b/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp
@@ -147,19 +147,11 @@ void FollowerAI::JustDied(Unit* /*killer*/)
if (Group* group = player->GetGroup())
{
for (GroupReference* groupRef = group->GetFirstMember(); groupRef != NULL; groupRef = groupRef->next())
- {
if (Player* member = groupRef->GetSource())
- {
- if (member->GetQuestStatus(m_pQuestForFollow->GetQuestId()) == QUEST_STATUS_INCOMPLETE)
- member->FailQuest(m_pQuestForFollow->GetQuestId());
- }
- }
+ member->FailQuest(m_pQuestForFollow->GetQuestId());
}
else
- {
- if (player->GetQuestStatus(m_pQuestForFollow->GetQuestId()) == QUEST_STATUS_INCOMPLETE)
- player->FailQuest(m_pQuestForFollow->GetQuestId());
- }
+ player->FailQuest(m_pQuestForFollow->GetQuestId());
}
}
diff --git a/src/server/game/AI/SmartScripts/SmartAI.cpp b/src/server/game/AI/SmartScripts/SmartAI.cpp
index b57717fa53d..97bbbfe2b72 100644
--- a/src/server/game/AI/SmartScripts/SmartAI.cpp
+++ b/src/server/game/AI/SmartScripts/SmartAI.cpp
@@ -73,11 +73,7 @@ SmartAI::SmartAI(Creature* c) : CreatureAI(c)
bool SmartAI::IsAIControlled() const
{
- if (me->IsControlledByPlayer())
- return false;
- if (mIsCharmed)
- return false;
- return true;
+ return !mIsCharmed;
}
void SmartAI::UpdateDespawn(const uint32 diff)
@@ -225,7 +221,7 @@ void SmartAI::EndPath(bool fail)
if (!fail && player->IsAtGroupRewardDistance(me) && !player->HasCorpse())
player->GroupEventHappens(mEscortQuestID, me);
- if (fail && player->GetQuestStatus(mEscortQuestID) == QUEST_STATUS_INCOMPLETE)
+ if (fail)
player->FailQuest(mEscortQuestID);
if (Group* group = player->GetGroup())
@@ -236,7 +232,7 @@ void SmartAI::EndPath(bool fail)
if (!fail && groupGuy->IsAtGroupRewardDistance(me) && !groupGuy->HasCorpse())
groupGuy->AreaExploredOrEventHappens(mEscortQuestID);
- if (fail && groupGuy->GetQuestStatus(mEscortQuestID) == QUEST_STATUS_INCOMPLETE)
+ else if (fail)
groupGuy->FailQuest(mEscortQuestID);
}
}
@@ -250,7 +246,7 @@ void SmartAI::EndPath(bool fail)
Player* player = (*iter)->ToPlayer();
if (!fail && player->IsAtGroupRewardDistance(me) && !player->HasCorpse())
player->AreaExploredOrEventHappens(mEscortQuestID);
- if (fail && player->GetQuestStatus(mEscortQuestID) == QUEST_STATUS_INCOMPLETE)
+ else if (fail)
player->FailQuest(mEscortQuestID);
}
}
diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp
index 56e943a64c9..48315eb44ed 100644
--- a/src/server/game/AI/SmartScripts/SmartScript.cpp
+++ b/src/server/game/AI/SmartScripts/SmartScript.cpp
@@ -65,7 +65,6 @@ SmartScript::~SmartScript()
void SmartScript::OnReset()
{
- SetPhase(0);
ResetBaseObject();
for (SmartAIEventList::iterator i = mEvents.begin(); i != mEvents.end(); ++i)
{
@@ -99,8 +98,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
//calc random
if (e.GetEventType() != SMART_EVENT_LINK && e.event.event_chance < 100 && e.event.event_chance)
{
- uint32 rnd = urand(1, 100);
- if (e.event.event_chance <= rnd)
+ if (!roll_chance_i(e.event.event_chance))
return;
}
e.runOnce = true;//used for repeat check
@@ -1069,20 +1067,10 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
break;
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
- {
if (Creature* target = (*itr)->ToCreature())
- {
- if (target->IsAlive() && IsSmart(target))
- {
- ENSURE_AI(SmartAI, target->AI())->SetDespawnTime(e.action.forceDespawn.delay + 1); // Next tick
- ENSURE_AI(SmartAI, target->AI())->StartDespawn();
- }
- else
- target->DespawnOrUnsummon(e.action.forceDespawn.delay);
- }
+ target->DespawnOrUnsummon(e.action.forceDespawn.delay);
else if (GameObject* goTarget = (*itr)->ToGameObject())
goTarget->SetRespawnTime(e.action.forceDespawn.delay + 1);
- }
delete targets;
break;
@@ -1176,7 +1164,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
if (!IsCreature(*itr))
continue;
- if (!(e.event.event_flags & SMART_EVENT_FLAG_WHILE_CHARMED) && !IsCreatureInControlOfSelf(*itr))
+ if (!(e.event.event_flags & SMART_EVENT_FLAG_WHILE_CHARMED) && IsCharmedCreature(*itr))
continue;
Position pos = (*itr)->GetPosition();
@@ -1683,6 +1671,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
ResetBaseObject();
break;
case SMART_ACTION_CALL_SCRIPT_RESET:
+ SetPhase(0);
OnReset();
break;
case SMART_ACTION_SET_RANGED_MOVEMENT:
@@ -2854,7 +2843,7 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui
if ((e.event.event_phase_mask && !IsInPhase(e.event.event_phase_mask)) || ((e.event.event_flags & SMART_EVENT_FLAG_NOT_REPEATABLE) && e.runOnce))
return;
- if (!(e.event.event_flags & SMART_EVENT_FLAG_WHILE_CHARMED) && IsCreature(me) && !IsCreatureInControlOfSelf(me))
+ if (!(e.event.event_flags & SMART_EVENT_FLAG_WHILE_CHARMED) && IsCharmedCreature(me))
return;
switch (e.GetEventType())
@@ -3599,10 +3588,6 @@ void SmartScript::FillScript(SmartAIEventList e, WorldObject* obj, AreaTriggerEn
}
mEvents.push_back((*i));//NOTE: 'world(0)' events still get processed in ANY instance mode
}
- if (mEvents.empty() && obj)
- TC_LOG_ERROR("sql.sql", "SmartScript: Entry %u has events but no events added to list because of instance flags.", obj->GetEntry());
- if (mEvents.empty() && at)
- TC_LOG_ERROR("sql.sql", "SmartScript: AreaTrigger %u has events but no events added to list because of instance flags. NOTE: triggers can not handle any instance flags.", at->id);
}
void SmartScript::GetScript()
diff --git a/src/server/game/AI/SmartScripts/SmartScript.h b/src/server/game/AI/SmartScripts/SmartScript.h
index 8ac5b494911..3cb66faa033 100644
--- a/src/server/game/AI/SmartScripts/SmartScript.h
+++ b/src/server/game/AI/SmartScripts/SmartScript.h
@@ -78,12 +78,15 @@ class TC_GAME_API SmartScript
return obj && obj->GetTypeId() == TYPEID_UNIT;
}
- static bool IsCreatureInControlOfSelf(WorldObject* obj)
+ static bool IsCharmedCreature(WorldObject* obj)
{
- if (Creature* creatureObj = obj ? obj->ToCreature() : nullptr)
- return !creatureObj->IsCharmed() && !creatureObj->IsControlledByPlayer();
- else
+ if (!obj)
return false;
+
+ if (Creature* creatureObj = obj->ToCreature())
+ return creatureObj->IsCharmed();
+
+ return false;
}
static bool IsGameObject(WorldObject* obj)
diff --git a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp
index d9f5388e3ce..43bd28c7863 100644
--- a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp
+++ b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp
@@ -27,6 +27,7 @@
#include "ScriptMgr.h"
#include "AccountMgr.h"
#include "AuctionHouseMgr.h"
+#include "AuctionHouseBot.h"
#include "Item.h"
#include "Language.h"
#include "Log.h"
@@ -156,7 +157,7 @@ void AuctionHouseMgr::SendAuctionWonMail(AuctionEntry* auction, SQLTransaction&
}
// receiver exist
- if (bidder || bidderAccId)
+ if ((bidder || bidderAccId) && !sAuctionBotConfig->IsBotChar(auction->bidder))
{
// set owner to bidder (to prevent delete item with sender char deleting)
// owner in `data` will set at mail receive and item extracting
@@ -189,7 +190,7 @@ void AuctionHouseMgr::SendAuctionSalePendingMail(AuctionEntry* auction, SQLTrans
Player* owner = ObjectAccessor::FindConnectedPlayer(owner_guid);
uint32 owner_accId = sObjectMgr->GetPlayerAccountIdByGUID(owner_guid);
// owner exist (online or offline)
- if (owner || owner_accId)
+ if ((owner || owner_accId) && !sAuctionBotConfig->IsBotChar(auction->owner))
MailDraft(auction->BuildAuctionMailSubject(AUCTION_SALE_PENDING), AuctionEntry::BuildAuctionMailBody(auction->bidder, auction->bid, auction->buyout, auction->deposit, auction->GetAuctionCut()))
.SendMailTo(trans, MailReceiver(owner, auction->owner), auction, MAIL_CHECK_MASK_COPIED);
}
@@ -201,7 +202,7 @@ void AuctionHouseMgr::SendAuctionSuccessfulMail(AuctionEntry* auction, SQLTransa
Player* owner = ObjectAccessor::FindConnectedPlayer(owner_guid);
uint32 owner_accId = sObjectMgr->GetPlayerAccountIdByGUID(owner_guid);
// owner exist
- if (owner || owner_accId)
+ if ((owner || owner_accId) && !sAuctionBotConfig->IsBotChar(auction->owner))
{
uint32 profit = auction->bid + auction->deposit - auction->GetAuctionCut();
@@ -232,7 +233,7 @@ void AuctionHouseMgr::SendAuctionExpiredMail(AuctionEntry* auction, SQLTransacti
Player* owner = ObjectAccessor::FindConnectedPlayer(owner_guid);
uint32 owner_accId = sObjectMgr->GetPlayerAccountIdByGUID(owner_guid);
// owner exist
- if (owner || owner_accId)
+ if ((owner || owner_accId) && !sAuctionBotConfig->IsBotChar(auction->owner))
{
if (owner)
owner->GetSession()->SendAuctionOwnerNotification(auction);
@@ -259,7 +260,7 @@ void AuctionHouseMgr::SendAuctionOutbiddedMail(AuctionEntry* auction, uint32 new
oldBidder_accId = sObjectMgr->GetPlayerAccountIdByGUID(oldBidder_guid);
// old bidder exist
- if (oldBidder || oldBidder_accId)
+ if ((oldBidder || oldBidder_accId) && !sAuctionBotConfig->IsBotChar(auction->bidder))
{
if (oldBidder && newBidder)
oldBidder->GetSession()->SendAuctionBidderNotification(auction->GetHouseId(), auction->Id, newBidder->GetGUID(), newPrice, auction->GetAuctionOutBid(), auction->itemEntry);
@@ -281,7 +282,7 @@ void AuctionHouseMgr::SendAuctionCancelledToBidderMail(AuctionEntry* auction, SQ
bidder_accId = sObjectMgr->GetPlayerAccountIdByGUID(bidder_guid);
// bidder exist
- if (bidder || bidder_accId)
+ if ((bidder || bidder_accId) && !sAuctionBotConfig->IsBotChar(auction->bidder))
MailDraft(auction->BuildAuctionMailSubject(AUCTION_CANCELLED_TO_BIDDER), AuctionEntry::BuildAuctionMailBody(auction->owner, auction->bid, auction->buyout, auction->deposit, 0))
.AddMoney(auction->bid)
.SendMailTo(trans, MailReceiver(bidder, auction->bidder), auction, MAIL_CHECK_MASK_COPIED);
diff --git a/src/server/game/AuctionHouseBot/AuctionHouseBot.cpp b/src/server/game/AuctionHouseBot/AuctionHouseBot.cpp
index 74f0aaf428a..4601495a70b 100644
--- a/src/server/game/AuctionHouseBot/AuctionHouseBot.cpp
+++ b/src/server/game/AuctionHouseBot/AuctionHouseBot.cpp
@@ -15,10 +15,12 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "Containers.h"
#include "Log.h"
#include "Item.h"
#include "World.h"
#include "Config.h"
+#include "AccountMgr.h"
#include "AuctionHouseMgr.h"
#include "AuctionHouseBot.h"
#include "AuctionHouseBotBuyer.h"
@@ -56,6 +58,31 @@ bool AuctionBotConfig::Initialize()
_itemsPerCycleBoost = GetConfig(CONFIG_AHBOT_ITEMS_PER_CYCLE_BOOST);
_itemsPerCycleNormal = GetConfig(CONFIG_AHBOT_ITEMS_PER_CYCLE_NORMAL);
+ if (uint32 ahBotAccId = GetConfig(CONFIG_AHBOT_ACCOUNT_ID))
+ {
+ // check character count
+ if (AccountMgr::GetCharactersCount(GetConfig(CONFIG_AHBOT_ACCOUNT_ID)))
+ {
+ // find account guids associated with ahbot account
+ uint32 count = 0;
+ PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARS_BY_ACCOUNT_ID);
+ stmt->setUInt32(0, ahBotAccId);
+ if (PreparedQueryResult result = CharacterDatabase.Query(stmt))
+ {
+ do
+ {
+ Field* fields = result->Fetch();
+ _AHBotCharacters.push_back(fields[0].GetUInt32());
+ ++count;
+ } while (result->NextRow());
+ }
+
+ TC_LOG_DEBUG("ahbot", "AuctionHouseBot found %u characters", count);
+ }
+ else
+ TC_LOG_WARN("ahbot", "AuctionHouseBot Account ID %u has no associated characters.", ahBotAccId);
+ }
+
return true;
}
@@ -111,6 +138,8 @@ void AuctionBotConfig::SetConfig(AuctionBotConfigFloatValues index, char const*
//Get AuctionHousebot configuration file
void AuctionBotConfig::GetConfigFromFile()
{
+ SetConfig(CONFIG_AHBOT_ACCOUNT_ID, "AuctionHouseBot.Account", 0);
+
SetConfigMax(CONFIG_AHBOT_ALLIANCE_ITEM_AMOUNT_RATIO, "AuctionHouseBot.Alliance.Items.Amount.Ratio", 100, 10000);
SetConfigMax(CONFIG_AHBOT_HORDE_ITEM_AMOUNT_RATIO, "AuctionHouseBot.Horde.Items.Amount.Ratio", 100, 10000);
SetConfigMax(CONFIG_AHBOT_NEUTRAL_ITEM_AMOUNT_RATIO, "AuctionHouseBot.Neutral.Items.Amount.Ratio", 100, 10000);
@@ -272,6 +301,40 @@ char const* AuctionBotConfig::GetHouseTypeName(AuctionHouseType houseType)
return names[houseType];
}
+// Picks a random character from the list of AHBot chars
+uint32 AuctionBotConfig::GetRandChar() const
+{
+ if (_AHBotCharacters.empty())
+ return 0;
+
+ return Trinity::Containers::SelectRandomContainerElement(_AHBotCharacters);
+}
+
+// Picks a random AHBot character, but excludes a specific one. This is used
+// to have another character than the auction owner place bids
+uint32 AuctionBotConfig::GetRandCharExclude(uint32 exclude) const
+{
+ if (_AHBotCharacters.empty())
+ return 0;
+
+ std::vector<uint32> filteredCharacters;
+ filteredCharacters.reserve(_AHBotCharacters.size() - 1);
+
+ for (uint32 charId : _AHBotCharacters)
+ if (charId != exclude)
+ filteredCharacters.push_back(charId);
+
+ if (filteredCharacters.empty())
+ return 0;
+
+ return Trinity::Containers::SelectRandomContainerElement(filteredCharacters);
+}
+
+bool AuctionBotConfig::IsBotChar(uint32 characterID) const
+{
+ return !characterID || std::find(_AHBotCharacters.begin(), _AHBotCharacters.end(), characterID) != _AHBotCharacters.end();
+}
+
uint32 AuctionBotConfig::GetConfigItemAmountRatio(AuctionHouseType houseType) const
{
switch (houseType)
@@ -408,7 +471,7 @@ void AuctionHouseBot::PrepareStatusInfos(AuctionHouseBotStatusInfo& statusInfo)
if (Item* item = sAuctionMgr->GetAItem(auctionEntry->itemGUIDLow))
{
ItemTemplate const* prototype = item->GetTemplate();
- if (!auctionEntry->owner) // Add only ahbot items
+ if (!auctionEntry->owner || sAuctionBotConfig->IsBotChar(auctionEntry->owner)) // Add only ahbot items
{
if (prototype->Quality < MAX_AUCTION_QUALITY)
++statusInfo[i].QualityInfo[prototype->Quality];
@@ -426,7 +489,7 @@ void AuctionHouseBot::Rebuild(bool all)
{
AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(AuctionHouseType(i));
for (AuctionHouseObject::AuctionEntryMap::const_iterator itr = auctionHouse->GetAuctionsBegin(); itr != auctionHouse->GetAuctionsEnd(); ++itr)
- if (!itr->second->owner) // ahbot auction
+ if (!itr->second->owner || sAuctionBotConfig->IsBotChar(itr->second->owner)) // ahbot auction
if (all || itr->second->bid == 0) // expire now auction if no bid or forced
itr->second->expire_time = sWorld->GetGameTime();
}
diff --git a/src/server/game/AuctionHouseBot/AuctionHouseBot.h b/src/server/game/AuctionHouseBot/AuctionHouseBot.h
index 1a438e01cdb..4f68a172255 100644
--- a/src/server/game/AuctionHouseBot/AuctionHouseBot.h
+++ b/src/server/game/AuctionHouseBot/AuctionHouseBot.h
@@ -152,6 +152,7 @@ enum AuctionBotConfigUInt32Values
CONFIG_AHBOT_CLASS_RANDOMSTACKRATIO_KEY,
CONFIG_AHBOT_CLASS_RANDOMSTACKRATIO_MISC,
CONFIG_AHBOT_CLASS_RANDOMSTACKRATIO_GLYPH,
+ CONFIG_AHBOT_ACCOUNT_ID,
CONFIG_UINT32_AHBOT_UINT32_COUNT
};
@@ -224,6 +225,9 @@ public:
uint32 GetItemPerCycleBoost() const { return _itemsPerCycleBoost; }
uint32 GetItemPerCycleNormal() const { return _itemsPerCycleNormal; }
+ uint32 GetRandChar() const;
+ uint32 GetRandCharExclude(uint32 exclude) const;
+ bool IsBotChar(uint32 characterID) const;
void Reload() { GetConfigFromFile(); }
static char const* GetHouseTypeName(AuctionHouseType houseType);
@@ -231,6 +235,7 @@ public:
private:
std::string _AHBotIncludes;
std::string _AHBotExcludes;
+ std::vector<uint32> _AHBotCharacters;
uint32 _itemsPerCycleBoost;
uint32 _itemsPerCycleNormal;
diff --git a/src/server/game/AuctionHouseBot/AuctionHouseBotBuyer.cpp b/src/server/game/AuctionHouseBot/AuctionHouseBotBuyer.cpp
index 6b1dcb85bec..0e6b3402db0 100644
--- a/src/server/game/AuctionHouseBot/AuctionHouseBotBuyer.cpp
+++ b/src/server/game/AuctionHouseBot/AuctionHouseBotBuyer.cpp
@@ -103,7 +103,7 @@ uint32 AuctionBotBuyer::GetItemInformation(BuyerConfiguration& config)
{
AuctionEntry* entry = itr->second;
- if (!entry->owner)
+ if (!entry->owner || sAuctionBotConfig->IsBotChar(entry->owner))
continue; // Skip auctions owned by AHBot
Item* item = sAuctionMgr->GetAItem(entry->itemGUIDLow);
@@ -218,7 +218,7 @@ bool AuctionBotBuyer::RollBidChance(const BuyerItemInfo* ahInfo, const Item* ite
}
// If a player has bidded on item, have fifth of normal chance
- if (auction->bidder)
+ if (auction->bidder && !sAuctionBotConfig->IsBotChar(auction->bidder))
chance = chance / 5.f;
// Add config weigh in for quality
@@ -391,11 +391,11 @@ void AuctionBotBuyer::BuyEntry(AuctionEntry* auction, AuctionHouseObject* auctio
SQLTransaction trans = CharacterDatabase.BeginTransaction();
// Send mail to previous bidder if any
- if (auction->bidder)
+ if (auction->bidder && !sAuctionBotConfig->IsBotChar(auction->bidder))
sAuctionMgr->SendAuctionOutbiddedMail(auction, auction->buyout, NULL, trans);
// Set bot as bidder and set new bid amount
- auction->bidder = 0;
+ auction->bidder = sAuctionBotConfig->GetRandCharExclude(auction->owner);
auction->bid = auction->buyout;
// Mails must be under transaction control too to prevent data loss
@@ -422,11 +422,11 @@ void AuctionBotBuyer::PlaceBidToEntry(AuctionEntry* auction, uint32 bidPrice)
SQLTransaction trans = CharacterDatabase.BeginTransaction();
// Send mail to previous bidder if any
- if (auction->bidder)
+ if (auction->bidder && !sAuctionBotConfig->IsBotChar(auction->bidder))
sAuctionMgr->SendAuctionOutbiddedMail(auction, bidPrice, NULL, trans);
// Set bot as bidder and set new bid amount
- auction->bidder = 0;
+ auction->bidder = sAuctionBotConfig->GetRandCharExclude(auction->owner);
auction->bid = bidPrice;
// Update auction to DB
diff --git a/src/server/game/AuctionHouseBot/AuctionHouseBotSeller.cpp b/src/server/game/AuctionHouseBot/AuctionHouseBotSeller.cpp
index 17b104eb388..34127f0c59f 100644
--- a/src/server/game/AuctionHouseBot/AuctionHouseBotSeller.cpp
+++ b/src/server/game/AuctionHouseBot/AuctionHouseBotSeller.cpp
@@ -320,7 +320,7 @@ bool AuctionBotSeller::Initialize()
continue;
}
- if (prototype->Flags & ITEM_FLAG_UNLOCKED)
+ if (prototype->Flags & ITEM_FLAG_HAS_LOOT)
{
// skip any not locked lootable items (mostly quest specific or reward cases)
if (!prototype->LockID)
@@ -640,7 +640,7 @@ uint32 AuctionBotSeller::SetStat(SellerConfiguration& config)
{
ItemTemplate const* prototype = item->GetTemplate();
if (prototype)
- if (!auctionEntry->owner) // Add only ahbot items
+ if (!auctionEntry->owner || sAuctionBotConfig->IsBotChar(auctionEntry->owner)) // Add only ahbot items
++itemsSaved[prototype->Quality][prototype->Class];
}
}
@@ -1019,7 +1019,7 @@ void AuctionBotSeller::AddNewAuctions(SellerConfiguration& config)
AuctionEntry* auctionEntry = new AuctionEntry();
auctionEntry->Id = sObjectMgr->GenerateAuctionID();
- auctionEntry->owner = 0;
+ auctionEntry->owner = sAuctionBotConfig->GetRandChar();
auctionEntry->itemGUIDLow = item->GetGUID().GetCounter();
auctionEntry->itemEntry = item->GetEntry();
auctionEntry->startbid = bidPrice;
diff --git a/src/server/game/Battlefield/Zones/BattlefieldWG.cpp b/src/server/game/Battlefield/Zones/BattlefieldWG.cpp
index b82d5ed5837..8df95619ae5 100644
--- a/src/server/game/Battlefield/Zones/BattlefieldWG.cpp
+++ b/src/server/game/Battlefield/Zones/BattlefieldWG.cpp
@@ -61,9 +61,6 @@ G3D::Quat const WintergraspRelicRot = { 0.f, 0.f, -0.7933531f, 0.6087617f };
uint8 const WG_MAX_OBJ = 32;
uint8 const WG_MAX_TURRET = 15;
-uint8 const WG_MAX_KEEP_NPC = 39;
-uint8 const WG_MAX_OUTSIDE_NPC = 14;
-uint8 const WG_OUTSIDE_ALLIANCE_NPC = 7;
uint8 const WG_MAX_TELEPORTER = 12;
uint8 const WG_MAX_WORKSHOP = 6;
uint8 const WG_MAX_TOWER = 7;
@@ -177,76 +174,6 @@ struct WintergraspObjectPositionData
uint32 AllianceEntry;
};
-// Here there is all npc keeper spawn point
-WintergraspObjectPositionData const WGKeepNPC[WG_MAX_KEEP_NPC] =
-{
- // X Y Z O horde alliance
- // North East
- { { 5326.203125f, 2660.026367f, 409.100891f, 2.543383f }, BATTLEFIELD_WG_NPC_GUARD_H, BATTLEFIELD_WG_NPC_GUARD_A }, // Roaming Guard
- { { 5298.430176f, 2738.760010f, 409.316010f, 3.971740f }, BATTLEFIELD_WG_NPC_VIERON_BLAZEFEATHER, BATTLEFIELD_WG_NPC_BOWYER_RANDOLPH }, // Vieron Blazefeather
- { { 5335.310059f, 2764.110107f, 409.274994f, 4.834560f }, BATTLEFIELD_WG_NPC_GUARD_H, BATTLEFIELD_WG_NPC_GUARD_A }, // Standing Guard
- { { 5349.810059f, 2763.629883f, 409.333008f, 4.660030f }, BATTLEFIELD_WG_NPC_GUARD_H, BATTLEFIELD_WG_NPC_GUARD_A }, // Standing Guard
- // North
- { { 5373.470215f, 2789.060059f, 409.322998f, 2.600540f }, BATTLEFIELD_WG_NPC_STONE_GUARD_MUKAR, BATTLEFIELD_WG_NPC_KNIGHT_DAMERON }, // Stone Guard Mukar
- { { 5296.560059f, 2789.870117f, 409.274994f, 0.733038f }, BATTLEFIELD_WG_NPC_HOODOO_MASTER_FU_JIN, BATTLEFIELD_WG_NPC_SORCERESS_KAYLANA }, // Voodoo Master Fu'jin
- { { 5372.670000f, 2786.740000f, 409.442000f, 2.809980f }, BATTLEFIELD_WG_NPC_CHAMPION_ROS_SLAI, BATTLEFIELD_WG_NPC_MARSHAL_MAGRUDER }, // Wintergrasp Quartermaster
- { { 5368.709961f, 2856.360107f, 409.322998f, 2.949610f }, BATTLEFIELD_WG_NPC_GUARD_H, BATTLEFIELD_WG_NPC_GUARD_A }, // Standing Guard
- { { 5367.910156f, 2826.520020f, 409.322998f, 3.333580f }, BATTLEFIELD_WG_NPC_GUARD_H, BATTLEFIELD_WG_NPC_GUARD_A }, // Standing Guard
- { { 5389.270020f, 2847.370117f, 418.759003f, 3.106690f }, BATTLEFIELD_WG_NPC_GUARD_H, BATTLEFIELD_WG_NPC_GUARD_A }, // Standing Guard
- { { 5388.560059f, 2834.770020f, 418.759003f, 3.071780f }, BATTLEFIELD_WG_NPC_GUARD_H, BATTLEFIELD_WG_NPC_GUARD_A }, // Standing Guard
- { { 5359.129883f, 2837.989990f, 409.364014f, 4.698930f }, BATTLEFIELD_WG_NPC_COMMANDER_DARDOSH, BATTLEFIELD_WG_NPC_COMMANDER_ZANNETH }, // Commander Dardosh
- { { 5366.129883f, 2833.399902f, 409.322998f, 3.141590f }, BATTLEFIELD_WG_NPC_TACTICAL_OFFICER_KILRATH, BATTLEFIELD_WG_NPC_TACTICAL_OFFICER_AHBRAMIS }, // Tactical Officer Kilrath
- // X Y Z O horde alliance
- // North West
- { { 5350.680176f, 2917.010010f, 409.274994f, 1.466080f }, BATTLEFIELD_WG_NPC_GUARD_H, BATTLEFIELD_WG_NPC_GUARD_A }, // Standing Guard
- { { 5335.120117f, 2916.800049f, 409.444000f, 1.500980f }, BATTLEFIELD_WG_NPC_GUARD_H, BATTLEFIELD_WG_NPC_GUARD_A }, // Standing Guard
- { { 5295.560059f, 2926.669922f, 409.274994f, 0.872665f }, BATTLEFIELD_WG_NPC_SIEGESMITH_STRONGHOOF, BATTLEFIELD_WG_NPC_SIEGE_MASTER_STOUTHANDLE }, // Stronghoof
- { { 5371.399902f, 3026.510010f, 409.205994f, 3.250030f }, BATTLEFIELD_WG_NPC_PRIMALIST_MULFORT, BATTLEFIELD_WG_NPC_ANCHORITE_TESSA }, // Primalist Mulfort
- { { 5392.123535f, 3031.110352f, 409.187683f, 3.677212f }, BATTLEFIELD_WG_NPC_GUARD_H, BATTLEFIELD_WG_NPC_GUARD_A }, // Roaming Guard
- // South
- { { 5270.060059f, 2847.550049f, 409.274994f, 3.071780f }, BATTLEFIELD_WG_NPC_GUARD_H, BATTLEFIELD_WG_NPC_GUARD_A }, // Standing Guard
- { { 5270.160156f, 2833.479980f, 409.274994f, 3.124140f }, BATTLEFIELD_WG_NPC_GUARD_H, BATTLEFIELD_WG_NPC_GUARD_A }, // Standing Guard
- { { 5179.109863f, 2837.129883f, 409.274994f, 3.211410f }, BATTLEFIELD_WG_NPC_GUARD_H, BATTLEFIELD_WG_NPC_GUARD_A }, // Standing Guard
- { { 5179.669922f, 2846.600098f, 409.274994f, 3.089230f }, BATTLEFIELD_WG_NPC_GUARD_H, BATTLEFIELD_WG_NPC_GUARD_A }, // Standing Guard
- { { 5234.970215f, 2883.399902f, 409.274994f, 4.293510f }, BATTLEFIELD_WG_NPC_LIEUTENANT_MURP, BATTLEFIELD_WG_NPC_SENIOR_DEMOLITIONIST_LEGOSO }, // Lieutenant Murp
- // X Y Z O horde alliance
- // Portal guards (from around the fortress)
- { { 5319.209473f, 3055.947754f, 409.176636f, 1.020201f }, BATTLEFIELD_WG_NPC_GUARD_H, BATTLEFIELD_WG_NPC_GUARD_A }, // Standing Guard
- { { 5311.612305f, 3061.207275f, 408.734161f, 0.965223f }, BATTLEFIELD_WG_NPC_GUARD_H, BATTLEFIELD_WG_NPC_GUARD_A }, // Standing Guard
- { { 5264.713379f, 3017.283447f, 408.479706f, 3.482424f }, BATTLEFIELD_WG_NPC_GUARD_H, BATTLEFIELD_WG_NPC_GUARD_A }, // Standing Guard
- { { 5269.096191f, 3008.315918f, 408.826294f, 3.843706f }, BATTLEFIELD_WG_NPC_GUARD_H, BATTLEFIELD_WG_NPC_GUARD_A }, // Standing Guard
- { { 5201.414551f, 2945.096924f, 409.190735f, 0.945592f }, BATTLEFIELD_WG_NPC_GUARD_H, BATTLEFIELD_WG_NPC_GUARD_A }, // Standing Guard
- { { 5193.386230f, 2949.617188f, 409.190735f, 1.145859f }, BATTLEFIELD_WG_NPC_GUARD_H, BATTLEFIELD_WG_NPC_GUARD_A }, // Standing Guard
- { { 5148.116211f, 2904.761963f, 409.193756f, 3.368532f }, BATTLEFIELD_WG_NPC_GUARD_H, BATTLEFIELD_WG_NPC_GUARD_A }, // Standing Guard
- { { 5153.355957f, 2895.501465f, 409.199310f, 3.549174f }, BATTLEFIELD_WG_NPC_GUARD_H, BATTLEFIELD_WG_NPC_GUARD_A }, // Standing Guard
- { { 5154.353027f, 2787.349365f, 409.250183f, 2.555644f }, BATTLEFIELD_WG_NPC_GUARD_H, BATTLEFIELD_WG_NPC_GUARD_A }, // Standing Guard
- { { 5150.066406f, 2777.876953f, 409.343903f, 2.708797f }, BATTLEFIELD_WG_NPC_GUARD_H, BATTLEFIELD_WG_NPC_GUARD_A }, // Standing Guard
- { { 5193.706543f, 2732.882812f, 409.189514f, 4.845073f }, BATTLEFIELD_WG_NPC_GUARD_H, BATTLEFIELD_WG_NPC_GUARD_A }, // Standing Guard
- { { 5202.126953f, 2737.570557f, 409.189514f, 5.375215f }, BATTLEFIELD_WG_NPC_GUARD_H, BATTLEFIELD_WG_NPC_GUARD_A }, // Standing Guard
- { { 5269.181152f, 2671.174072f, 409.098999f, 2.457459f }, BATTLEFIELD_WG_NPC_GUARD_H, BATTLEFIELD_WG_NPC_GUARD_A }, // Standing Guard
- { { 5264.960938f, 2662.332520f, 409.098999f, 2.598828f }, BATTLEFIELD_WG_NPC_GUARD_H, BATTLEFIELD_WG_NPC_GUARD_A }, // Standing Guard
- { { 5307.111816f, 2616.006836f, 409.095734f, 5.355575f }, BATTLEFIELD_WG_NPC_GUARD_H, BATTLEFIELD_WG_NPC_GUARD_A }, // Standing Guard
- { { 5316.770996f, 2619.430176f, 409.027740f, 5.363431f }, BATTLEFIELD_WG_NPC_GUARD_H, BATTLEFIELD_WG_NPC_GUARD_A } // Standing Guard
-};
-
-WintergraspObjectPositionData const WGOutsideNPC[WG_MAX_OUTSIDE_NPC] =
-{
- { { 5032.04f, 3681.79f, 362.980f, 4.210f }, BATTLEFIELD_WG_NPC_VIERON_BLAZEFEATHER, 0 },
- { { 5020.71f, 3626.19f, 360.150f, 4.640f }, BATTLEFIELD_WG_NPC_HOODOO_MASTER_FU_JIN, 0 },
- { { 4994.85f, 3660.51f, 359.150f, 2.260f }, BATTLEFIELD_WG_NPC_COMMANDER_DARDOSH, 0 },
- { { 5015.46f, 3677.11f, 362.970f, 6.009f }, BATTLEFIELD_WG_NPC_TACTICAL_OFFICER_KILRATH, 0 },
- { { 5031.12f, 3663.77f, 363.500f, 3.110f }, BATTLEFIELD_WG_NPC_SIEGESMITH_STRONGHOOF, 0 },
- { { 5042.74f, 3675.82f, 363.060f, 3.358f }, BATTLEFIELD_WG_NPC_PRIMALIST_MULFORT, 0 },
- { { 5014.45f, 3640.87f, 361.390f, 3.280f }, BATTLEFIELD_WG_NPC_LIEUTENANT_MURP, 0 },
- { { 5100.07f, 2168.89f, 365.779f, 1.972f }, 0, BATTLEFIELD_WG_NPC_BOWYER_RANDOLPH },
- { { 5081.70f, 2173.73f, 365.878f, 0.855f }, 0, BATTLEFIELD_WG_NPC_SORCERESS_KAYLANA },
- { { 5078.28f, 2183.70f, 365.029f, 1.466f }, 0, BATTLEFIELD_WG_NPC_COMMANDER_ZANNETH },
- { { 5088.49f, 2188.18f, 365.647f, 5.253f }, 0, BATTLEFIELD_WG_NPC_TACTICAL_OFFICER_AHBRAMIS },
- { { 5095.67f, 2193.28f, 365.924f, 4.939f }, 0, BATTLEFIELD_WG_NPC_SIEGE_MASTER_STOUTHANDLE },
- { { 5088.61f, 2167.66f, 365.689f, 0.680f }, 0, BATTLEFIELD_WG_NPC_ANCHORITE_TESSA },
- { { 5080.40f, 2199.00f, 359.489f, 2.967f }, 0, BATTLEFIELD_WG_NPC_SENIOR_DEMOLITIONIST_LEGOSO },
-};
-
struct WintergraspGameObjectData
{
Position Pos;
@@ -492,6 +419,7 @@ bool BattlefieldWG::SetupBattlefield()
m_StartGroupingTimer = 15 * MINUTE * IN_MILLISECONDS;
m_StartGrouping = false;
+ m_tenacityTeam = TEAM_NEUTRAL;
m_tenacityStack = 0;
KickPosition.Relocate(5728.117f, 2714.346f, 697.733f, 0);
@@ -550,7 +478,7 @@ bool BattlefieldWG::SetupBattlefield()
for (uint8 i = 0; i < WG_MAX_WORKSHOP; i++)
{
WintergraspWorkshop* workshop = new WintergraspWorkshop(this, i);
- if (i < BATTLEFIELD_WG_WORKSHOP_KEEP_WEST)
+ if (i < BATTLEFIELD_WG_WORKSHOP_NE)
workshop->GiveControlTo(GetAttackerTeam(), true);
else
workshop->GiveControlTo(GetDefenderTeam(), true);
@@ -559,38 +487,6 @@ bool BattlefieldWG::SetupBattlefield()
Workshops[i] = workshop;
}
- // Spawn NPCs in the defender's keep, both Horde and Alliance
- for (uint8 i = 0; i < WG_MAX_KEEP_NPC; ++i)
- {
- // Horde npc
- if (Creature* creature = SpawnCreature(WGKeepNPC[i].HordeEntry, WGKeepNPC[i].Pos))
- KeepCreature[TEAM_HORDE].push_back(creature->GetGUID());
-
- // Alliance npc
- if (Creature* creature = SpawnCreature(WGKeepNPC[i].AllianceEntry, WGKeepNPC[i].Pos))
- KeepCreature[TEAM_ALLIANCE].push_back(creature->GetGUID());
- }
-
- // Hide NPCs from the Attacker's team in the keep
- for (auto itr = KeepCreature[GetAttackerTeam()].begin(); itr != KeepCreature[GetAttackerTeam()].end(); ++itr)
- if (Creature* creature = GetCreature(*itr))
- HideNpc(creature);
-
- // Spawn Horde NPCs outside the keep
- for (uint8 i = 0; i < WG_OUTSIDE_ALLIANCE_NPC; ++i)
- if (Creature* creature = SpawnCreature(WGOutsideNPC[i].HordeEntry, WGOutsideNPC[i].Pos))
- OutsideCreature[TEAM_HORDE].push_back(creature->GetGUID());
-
- // Spawn Alliance NPCs outside the keep
- for (uint8 i = WG_OUTSIDE_ALLIANCE_NPC; i < WG_MAX_OUTSIDE_NPC; ++i)
- if (Creature* creature = SpawnCreature(WGOutsideNPC[i].AllianceEntry, WGOutsideNPC[i].Pos))
- OutsideCreature[TEAM_ALLIANCE].push_back(creature->GetGUID());
-
- // Hide units outside the keep that are defenders
- for (auto itr = OutsideCreature[GetDefenderTeam()].begin(); itr != OutsideCreature[GetDefenderTeam()].end(); ++itr)
- if (Creature* creature = GetCreature(*itr))
- HideNpc(creature);
-
// Spawn turrets and hide them per default
for (uint8 i = 0; i < WG_MAX_TURRET; i++)
{
@@ -768,27 +664,6 @@ void BattlefieldWG::OnBattleEnd(bool endByTimer)
}
}
- if (!endByTimer) // One player triggered the relic
- {
- // Change all npc in keep
- for (auto itr = KeepCreature[GetAttackerTeam()].begin(); itr != KeepCreature[GetAttackerTeam()].end(); ++itr)
- if (Creature* creature = GetCreature(*itr))
- HideNpc(creature);
-
- for (auto itr = KeepCreature[GetDefenderTeam()].begin(); itr != KeepCreature[GetDefenderTeam()].end(); ++itr)
- if (Creature* creature = GetCreature(*itr))
- ShowNpc(creature, true);
-
- // Change all npc out of keep
- for (auto itr = OutsideCreature[GetDefenderTeam()].begin(); itr != OutsideCreature[GetDefenderTeam()].end(); ++itr)
- if (Creature* creature = GetCreature(*itr))
- HideNpc(creature);
-
- for (auto itr = OutsideCreature[GetAttackerTeam()].begin(); itr != OutsideCreature[GetAttackerTeam()].end(); ++itr)
- if (Creature* creature = GetCreature(*itr))
- ShowNpc(creature, true);
- }
-
// Update all graveyard, control is to defender when no wartime
for (uint8 i = 0; i < BATTLEFIELD_WG_GY_HORDE; i++)
if (BfGraveyard* graveyard = GetGraveyardById(i))
@@ -1073,33 +948,9 @@ void BattlefieldWG::HandleKill(Player* killer, Unit* victim)
if (killer == victim)
return;
- bool again = false;
- TeamId killerTeam = killer->GetTeamId();
-
if (victim->GetTypeId() == TYPEID_PLAYER)
- {
- for (auto itr = m_PlayersInWar[killerTeam].begin(); itr != m_PlayersInWar[killerTeam].end(); ++itr)
- if (Player* player = ObjectAccessor::FindPlayer(*itr))
- if (player->GetDistance2d(killer) < 40)
- PromotePlayer(player);
- return;
- }
+ HandlePromotion(killer, victim);
- for (auto itr = KeepCreature[GetOtherTeam(killerTeam)].begin();
- itr != KeepCreature[GetOtherTeam(killerTeam)].end(); ++itr)
- {
- if (Creature* creature = GetCreature(*itr))
- {
- if (victim->GetEntry() == creature->GetEntry() && !again)
- {
- again = true;
- for (auto iter = m_PlayersInWar[killerTeam].begin(); iter != m_PlayersInWar[killerTeam].end(); ++iter)
- if (Player* player = ObjectAccessor::FindPlayer(*iter))
- if (player->GetDistance2d(killer) < 40.0f)
- PromotePlayer(player);
- }
- }
- }
/// @todoRecent PvP activity worldstate
}
@@ -1131,6 +982,16 @@ void BattlefieldWG::OnUnitDeath(Unit* unit)
UpdateVehicleCountWG();
}
+void BattlefieldWG::HandlePromotion(Player* playerKiller, Unit* unitKilled)
+{
+ uint32 teamId = playerKiller->GetTeamId();
+
+ for (auto iter = m_PlayersInWar[teamId].begin(); iter != m_PlayersInWar[teamId].end(); ++iter)
+ if (Player* player = ObjectAccessor::FindPlayer(*iter))
+ if (player->GetDistance2d(unitKilled) < 40.0f)
+ PromotePlayer(player);
+}
+
// Update rank for player
void BattlefieldWG::PromotePlayer(Player* killer)
{
@@ -1224,6 +1085,7 @@ void BattlefieldWG::OnPlayerLeaveWar(Player* player)
player->RemoveAurasDueToSpell(SPELL_ALLIANCE_CONTROLS_FACTORY_PHASE_SHIFT);
player->RemoveAurasDueToSpell(SPELL_HORDE_CONTROL_PHASE_SHIFT);
player->RemoveAurasDueToSpell(SPELL_ALLIANCE_CONTROL_PHASE_SHIFT);
+ UpdateTenacity();
}
void BattlefieldWG::OnPlayerLeaveZone(Player* player)
@@ -1317,25 +1179,17 @@ void BattlefieldWG::SendInitWorldStatesToAll()
SendInitWorldStatesTo(player);
}
-void BattlefieldWG::BrokenWallOrTower(TeamId /*team*/)
-{
-/*
-uint32 const WGQuest[2][6] =
+void BattlefieldWG::BrokenWallOrTower(TeamId team, BfWGGameObjectBuilding* building)
{
- { 13186, 13181, 13222, 13538, 13177, 13179 },
- { 13185, 13183, 13223, 13539, 13178, 13180 },
-};
-*/
-
-// might be some use for this in the future. old code commented out below. KL
-/* if (team == GetDefenderTeam())
+ if (team == GetDefenderTeam())
{
- for (GuidSet::const_iterator itr = m_PlayersInWar[GetAttackerTeam()].begin(); itr != m_PlayersInWar[GetAttackerTeam()].end(); ++itr)
+ for (auto itr = m_PlayersInWar[GetAttackerTeam()].begin(); itr != m_PlayersInWar[GetAttackerTeam()].end(); ++itr)
{
if (Player* player = ObjectAccessor::FindPlayer(*itr))
- IncrementQuest(player, WGQuest[player->GetTeamId()][2], true);
+ if (player->GetDistance2d(GetGameObject(building->GetGUID())) < 50.0f)
+ player->KilledMonsterCredit(QUEST_CREDIT_DEFEND_SIEGE);
}
- }*/
+ }
}
// Called when a tower is broke
@@ -1437,7 +1291,6 @@ void BattlefieldWG::UpdateVehicleCountWG()
void BattlefieldWG::UpdateTenacity()
{
- TeamId team = TEAM_NEUTRAL;
uint32 alliancePlayers = m_PlayersInWar[TEAM_ALLIANCE].size();
uint32 hordePlayers = m_PlayersInWar[TEAM_HORDE].size();
int32 newStack = 0;
@@ -1453,21 +1306,16 @@ void BattlefieldWG::UpdateTenacity()
if (newStack == int32(m_tenacityStack))
return;
- if (m_tenacityStack > 0 && newStack <= 0) // old buff was on alliance
- team = TEAM_ALLIANCE;
- else if (newStack >= 0) // old buff was on horde
- team = TEAM_HORDE;
-
m_tenacityStack = newStack;
// Remove old buff
- if (team != TEAM_NEUTRAL)
+ if (m_tenacityTeam != TEAM_NEUTRAL)
{
- for (auto itr = m_players[team].begin(); itr != m_players[team].end(); ++itr)
+ for (auto itr = m_players[m_tenacityTeam].begin(); itr != m_players[m_tenacityTeam].end(); ++itr)
if (Player* player = ObjectAccessor::FindPlayer(*itr))
if (player->getLevel() >= m_MinLevel)
player->RemoveAurasDueToSpell(SPELL_TENACITY);
- for (auto itr = m_vehicles[team].begin(); itr != m_vehicles[team].end(); ++itr)
+ for (auto itr = m_vehicles[m_tenacityTeam].begin(); itr != m_vehicles[m_tenacityTeam].end(); ++itr)
if (Creature* creature = GetCreature(*itr))
creature->RemoveAurasDueToSpell(SPELL_TENACITY_VEHICLE);
}
@@ -1475,7 +1323,7 @@ void BattlefieldWG::UpdateTenacity()
// Apply new buff
if (newStack)
{
- team = newStack > 0 ? TEAM_ALLIANCE : TEAM_HORDE;
+ m_tenacityTeam = newStack > 0 ? TEAM_ALLIANCE : TEAM_HORDE;
if (newStack < 0)
newStack = -newStack;
@@ -1490,25 +1338,27 @@ void BattlefieldWG::UpdateTenacity()
if (newStack < 5)
buff_honor = 0;
- for (auto itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr)
+ for (auto itr = m_PlayersInWar[m_tenacityTeam].begin(); itr != m_PlayersInWar[m_tenacityTeam].end(); ++itr)
if (Player* player = ObjectAccessor::FindPlayer(*itr))
player->SetAuraStack(SPELL_TENACITY, player, newStack);
- for (auto itr = m_vehicles[team].begin(); itr != m_vehicles[team].end(); ++itr)
+ for (auto itr = m_vehicles[m_tenacityTeam].begin(); itr != m_vehicles[m_tenacityTeam].end(); ++itr)
if (Creature* creature = GetCreature(*itr))
creature->SetAuraStack(SPELL_TENACITY_VEHICLE, creature, newStack);
if (buff_honor != 0)
{
- for (auto itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr)
+ for (auto itr = m_PlayersInWar[m_tenacityTeam].begin(); itr != m_PlayersInWar[m_tenacityTeam].end(); ++itr)
if (Player* player = ObjectAccessor::FindPlayer(*itr))
player->CastSpell(player, buff_honor, true);
- for (auto itr = m_vehicles[team].begin(); itr != m_vehicles[team].end(); ++itr)
+ for (auto itr = m_vehicles[m_tenacityTeam].begin(); itr != m_vehicles[m_tenacityTeam].end(); ++itr)
if (Creature* creature = GetCreature(*itr))
creature->CastSpell(creature, buff_honor, true);
}
}
+ else
+ m_tenacityTeam = TEAM_NEUTRAL;
}
WintergraspCapturePoint::WintergraspCapturePoint(BattlefieldWG* battlefield, TeamId teamInControl) : BfCapturePoint(battlefield)
@@ -1634,7 +1484,7 @@ void BfWGGameObjectBuilding::Destroyed()
break;
}
- _wg->BrokenWallOrTower(_teamControl);
+ _wg->BrokenWallOrTower(_teamControl, this);
}
void BfWGGameObjectBuilding::Init(GameObject* go)
@@ -1958,8 +1808,8 @@ void WintergraspWorkshop::GiveControlTo(TeamId teamId, bool init /*= false*/)
void WintergraspWorkshop::UpdateGraveyardAndWorkshop()
{
- if (_staticInfo->WorkshopId < BATTLEFIELD_WG_WORKSHOP_KEEP_WEST)
- _wg->GetGraveyardById(_staticInfo->WorkshopId)->GiveControlTo(_teamControl);
+ if (_staticInfo->WorkshopId < BATTLEFIELD_WG_WORKSHOP_NE)
+ GiveControlTo(_wg->GetAttackerTeam(), true);
else
GiveControlTo(_wg->GetDefenderTeam(), true);
}
diff --git a/src/server/game/Battlefield/Zones/BattlefieldWG.h b/src/server/game/Battlefield/Zones/BattlefieldWG.h
index 8fa72bea8fd..3bd719c1a60 100644
--- a/src/server/game/Battlefield/Zones/BattlefieldWG.h
+++ b/src/server/game/Battlefield/Zones/BattlefieldWG.h
@@ -154,7 +154,8 @@ enum WintergraspQuests
{
QUEST_VICTORY_WINTERGRASP_A = 13181,
QUEST_VICTORY_WINTERGRASP_H = 13183,
- QUEST_CREDIT_TOWERS_DESTROYED = 35074
+ QUEST_CREDIT_TOWERS_DESTROYED = 35074,
+ QUEST_CREDIT_DEFEND_SIEGE = 31284
};
/*#########################
@@ -202,26 +203,6 @@ enum WintergraspNpcs
BATTLEFIELD_WG_NPC_GUARD_A = 30740,
BATTLEFIELD_WG_NPC_STALKER = 15214,
- BATTLEFIELD_WG_NPC_VIERON_BLAZEFEATHER = 31102,
- BATTLEFIELD_WG_NPC_STONE_GUARD_MUKAR = 32296, // <WINTERGRASP QUARTERMASTER>
- BATTLEFIELD_WG_NPC_HOODOO_MASTER_FU_JIN = 31101, // <MASTER HEXXER>
- BATTLEFIELD_WG_NPC_CHAMPION_ROS_SLAI = 39173, // <WINTERGRASP QUARTERMASTER>
- BATTLEFIELD_WG_NPC_COMMANDER_DARDOSH = 31091,
- BATTLEFIELD_WG_NPC_TACTICAL_OFFICER_KILRATH = 31151,
- BATTLEFIELD_WG_NPC_SIEGESMITH_STRONGHOOF = 31106,
- BATTLEFIELD_WG_NPC_PRIMALIST_MULFORT = 31053,
- BATTLEFIELD_WG_NPC_LIEUTENANT_MURP = 31107,
-
- BATTLEFIELD_WG_NPC_BOWYER_RANDOLPH = 31052,
- BATTLEFIELD_WG_NPC_KNIGHT_DAMERON = 32294, // <WINTERGRASP QUARTERMASTER>
- BATTLEFIELD_WG_NPC_SORCERESS_KAYLANA = 31051, // <ENCHANTRESS>
- BATTLEFIELD_WG_NPC_MARSHAL_MAGRUDER = 39172, // <WINTERGRASP QUARTERMASTER>
- BATTLEFIELD_WG_NPC_COMMANDER_ZANNETH = 31036,
- BATTLEFIELD_WG_NPC_TACTICAL_OFFICER_AHBRAMIS = 31153,
- BATTLEFIELD_WG_NPC_SIEGE_MASTER_STOUTHANDLE = 31108,
- BATTLEFIELD_WG_NPC_ANCHORITE_TESSA = 31054,
- BATTLEFIELD_WG_NPC_SENIOR_DEMOLITIONIST_LEGOSO = 31109,
-
NPC_TAUNKA_SPIRIT_GUIDE = 31841, // Horde spirit guide for Wintergrasp
NPC_DWARVEN_SPIRIT_GUIDE = 31842, // Alliance spirit guide for Wintergrasp
@@ -343,7 +324,7 @@ class TC_GAME_API BattlefieldWG : public Battlefield
* \brief Called when a wall/tower is broken
* - Update quest
*/
- void BrokenWallOrTower(TeamId team);
+ void BrokenWallOrTower(TeamId team, BfWGGameObjectBuilding* building);
/**
* \brief Called when a tower is damaged
@@ -388,6 +369,7 @@ class TC_GAME_API BattlefieldWG : public Battlefield
void HandleKill(Player* killer, Unit* victim) override;
void OnUnitDeath(Unit* unit) override;
+ void HandlePromotion(Player* killer, Unit* killed);
void PromotePlayer(Player* killer);
void UpdateTenacity();
@@ -410,9 +392,8 @@ class TC_GAME_API BattlefieldWG : public Battlefield
GuidUnorderedSet m_vehicles[BG_TEAMS_COUNT];
GuidVector CanonList;
- GuidVector KeepCreature[BG_TEAMS_COUNT];
- GuidVector OutsideCreature[BG_TEAMS_COUNT];
+ TeamId m_tenacityTeam;
uint32 m_tenacityStack;
uint32 m_saveTimer;
@@ -456,10 +437,10 @@ enum WintergraspTowerIds
enum WintergraspWorkshopIds
{
- BATTLEFIELD_WG_WORKSHOP_NE,
- BATTLEFIELD_WG_WORKSHOP_NW,
BATTLEFIELD_WG_WORKSHOP_SE,
BATTLEFIELD_WG_WORKSHOP_SW,
+ BATTLEFIELD_WG_WORKSHOP_NE,
+ BATTLEFIELD_WG_WORKSHOP_NW,
BATTLEFIELD_WG_WORKSHOP_KEEP_WEST,
BATTLEFIELD_WG_WORKSHOP_KEEP_EAST
};
diff --git a/src/server/game/Battlegrounds/ArenaTeam.cpp b/src/server/game/Battlegrounds/ArenaTeam.cpp
index ec007df6b6c..f1747bc0d00 100644
--- a/src/server/game/Battlegrounds/ArenaTeam.cpp
+++ b/src/server/game/Battlegrounds/ArenaTeam.cpp
@@ -899,6 +899,10 @@ void ArenaTeam::SaveToDB()
for (MemberList::const_iterator itr = Members.begin(); itr != Members.end(); ++itr)
{
+ // Save the effort and go
+ if (itr->WeekGames == 0)
+ continue;
+
stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ARENA_TEAM_MEMBER);
stmt->setUInt16(0, itr->PersonalRating);
stmt->setUInt16(1, itr->WeekGames);
@@ -919,8 +923,12 @@ void ArenaTeam::SaveToDB()
CharacterDatabase.CommitTransaction(trans);
}
-void ArenaTeam::FinishWeek()
+bool ArenaTeam::FinishWeek()
{
+ // No need to go further than this
+ if (Stats.WeekGames == 0)
+ return false;
+
// Reset team stats
Stats.WeekGames = 0;
Stats.WeekWins = 0;
@@ -931,6 +939,8 @@ void ArenaTeam::FinishWeek()
itr->WeekGames = 0;
itr->WeekWins = 0;
}
+
+ return true;
}
bool ArenaTeam::IsFighting() const
diff --git a/src/server/game/Battlegrounds/ArenaTeam.h b/src/server/game/Battlegrounds/ArenaTeam.h
index 7e9f490bff9..e283197346c 100644
--- a/src/server/game/Battlegrounds/ArenaTeam.h
+++ b/src/server/game/Battlegrounds/ArenaTeam.h
@@ -180,7 +180,7 @@ class TC_GAME_API ArenaTeam
void UpdateArenaPointsHelper(std::map<uint32, uint32> & PlayerPoints);
- void FinishWeek();
+ bool FinishWeek(); // returns true if arena team played this week
void FinishGame(int32 mod);
protected:
diff --git a/src/server/game/Battlegrounds/ArenaTeamMgr.cpp b/src/server/game/Battlegrounds/ArenaTeamMgr.cpp
index 37e26d7e448..6fe11e3bd8c 100644
--- a/src/server/game/Battlegrounds/ArenaTeamMgr.cpp
+++ b/src/server/game/Battlegrounds/ArenaTeamMgr.cpp
@@ -186,8 +186,9 @@ void ArenaTeamMgr::DistributeArenaPoints()
{
if (ArenaTeam* at = titr->second)
{
- at->FinishWeek();
- at->SaveToDB();
+ if (at->FinishWeek())
+ at->SaveToDB();
+
at->NotifyStatsChanged();
}
}
diff --git a/src/server/game/Battlegrounds/BattlegroundMgr.cpp b/src/server/game/Battlegrounds/BattlegroundMgr.cpp
index 753d0f92ef3..1ae610ecf68 100644
--- a/src/server/game/Battlegrounds/BattlegroundMgr.cpp
+++ b/src/server/game/Battlegrounds/BattlegroundMgr.cpp
@@ -843,7 +843,7 @@ void BattlegroundMgr::ScheduleQueueUpdate(uint32 arenaMatchmakerRating, uint8 ar
{
//This method must be atomic, @todo add mutex
//we will use only 1 number created of bgTypeId and bracket_id
- uint64 const scheduleId = ((uint64)arenaMatchmakerRating << 32) | (uint32(arenaType) << 24) | (bgQueueTypeId << 16) | (bgTypeId << 8) | bracket_id;
+ uint64 const scheduleId = ((uint64)arenaMatchmakerRating << 32) | ((uint64)arenaType << 24) | ((uint64)bgQueueTypeId << 16) | ((uint64)bgTypeId << 8) | (uint64)bracket_id;
if (std::find(m_QueueUpdateScheduler.begin(), m_QueueUpdateScheduler.end(), scheduleId) == m_QueueUpdateScheduler.end())
m_QueueUpdateScheduler.push_back(scheduleId);
}
diff --git a/src/server/game/Chat/Channels/Channel.cpp b/src/server/game/Chat/Channels/Channel.cpp
index 22601b711d1..afaa0063a45 100644
--- a/src/server/game/Chat/Channels/Channel.cpp
+++ b/src/server/game/Chat/Channels/Channel.cpp
@@ -17,93 +17,124 @@
*/
#include "Channel.h"
+#include "ChannelAppenders.h"
#include "Chat.h"
+#include "GridNotifiers.h"
+#include "GridNotifiersImpl.h"
#include "ObjectMgr.h"
+#include "Language.h"
#include "SocialMgr.h"
#include "World.h"
#include "DatabaseEnv.h"
#include "AccountMgr.h"
#include "Player.h"
-Channel::Channel(std::string const& name, uint32 channelId, uint32 team /*= 0*/):
- _announceEnabled(true),
- _ownershipEnabled(true),
+Channel::Channel(uint32 channelId, uint32 team /*= 0*/, AreaTableEntry const* zoneEntry /*= nullptr*/) :
+ _announceEnabled(false), // no join/leave announces
+ _ownershipEnabled(false), // no ownership handout
_persistentChannel(false),
_isOwnerInvisible(false),
- _channelFlags(0),
+ _channelFlags(CHANNEL_FLAG_GENERAL), // for all built-in channels
_channelId(channelId),
_channelTeam(team),
_ownerGuid(),
- _channelName(name),
- _channelPassword()
+ _channelName(),
+ _channelPassword(),
+ _zoneEntry(zoneEntry)
{
- // set special flags if built-in channel
- if (ChatChannelsEntry const* ch = sChatChannelsStore.LookupEntry(channelId)) // check whether it's a built-in channel
- {
- _announceEnabled = false; // no join/leave announces
- _ownershipEnabled = false; // no ownership handout
+ ChatChannelsEntry const* channelEntry = sChatChannelsStore.AssertEntry(channelId);
+ if (channelEntry->flags & CHANNEL_DBC_FLAG_TRADE) // for trade channel
+ _channelFlags |= CHANNEL_FLAG_TRADE;
- _channelFlags |= CHANNEL_FLAG_GENERAL; // for all built-in channels
+ if (channelEntry->flags & CHANNEL_DBC_FLAG_CITY_ONLY2) // for city only channels
+ _channelFlags |= CHANNEL_FLAG_CITY;
- if (ch->flags & CHANNEL_DBC_FLAG_TRADE) // for trade channel
- _channelFlags |= CHANNEL_FLAG_TRADE;
-
- if (ch->flags & CHANNEL_DBC_FLAG_CITY_ONLY2) // for city only channels
- _channelFlags |= CHANNEL_FLAG_CITY;
+ if (channelEntry->flags & CHANNEL_DBC_FLAG_LFG) // for LFG channel
+ _channelFlags |= CHANNEL_FLAG_LFG;
+ else // for all other channels
+ _channelFlags |= CHANNEL_FLAG_NOT_LFG;
+}
- if (ch->flags & CHANNEL_DBC_FLAG_LFG) // for LFG channel
- _channelFlags |= CHANNEL_FLAG_LFG;
- else // for all other channels
- _channelFlags |= CHANNEL_FLAG_NOT_LFG;
- }
- else // it's custom channel
+Channel::Channel(std::string const& name, uint32 team /*= 0*/) :
+ _announceEnabled(true),
+ _ownershipEnabled(true),
+ _persistentChannel(false),
+ _isOwnerInvisible(false),
+ _channelFlags(CHANNEL_FLAG_CUSTOM),
+ _channelId(0),
+ _channelTeam(team),
+ _ownerGuid(),
+ _channelName(name),
+ _channelPassword(),
+ _zoneEntry(nullptr)
+{
+ // If storing custom channels in the db is enabled either load or save the channel
+ if (sWorld->getBoolConfig(CONFIG_PRESERVE_CUSTOM_CHANNELS))
{
- _channelFlags |= CHANNEL_FLAG_CUSTOM;
-
- // If storing custom channels in the db is enabled either load or save the channel
- if (sWorld->getBoolConfig(CONFIG_PRESERVE_CUSTOM_CHANNELS))
+ PreparedStatement *stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHANNEL);
+ stmt->setString(0, name);
+ stmt->setUInt32(1, _channelTeam);
+ if (PreparedQueryResult result = CharacterDatabase.Query(stmt)) // load
{
- PreparedStatement *stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHANNEL);
- stmt->setString(0, name);
- stmt->setUInt32(1, _channelTeam);
- PreparedQueryResult result = CharacterDatabase.Query(stmt);
-
- if (result) //load
+ Field* fields = result->Fetch();
+ _channelName = fields[0].GetString(); // re-get channel name. MySQL table collation is case insensitive
+ _announceEnabled = fields[1].GetBool();
+ _ownershipEnabled = fields[2].GetBool();
+ _channelPassword = fields[3].GetString();
+ std::string db_BannedList = fields[4].GetString();
+
+ if (!db_BannedList.empty())
{
- Field* fields = result->Fetch();
- _announceEnabled = fields[0].GetBool();
- _ownershipEnabled = fields[1].GetBool();
- _channelPassword = fields[2].GetString();
- char const* db_BannedList = fields[3].GetCString();
-
- if (db_BannedList)
+ Tokenizer tokens(db_BannedList, ' ');
+ for (auto const& token : tokens)
{
- Tokenizer tokens(db_BannedList, ' ');
- for (Tokenizer::const_iterator i = tokens.begin(); i != tokens.end(); ++i)
+ ObjectGuid banned_guid(uint64(atoull(token)));
+ if (banned_guid)
{
- ObjectGuid banned_guid(uint64(atoull(*i)));
- if (banned_guid)
- {
- TC_LOG_DEBUG("chat.system", "Channel(%s) loaded bannedStore %s", name.c_str(), banned_guid.ToString().c_str());
- _bannedStore.insert(banned_guid);
- }
+ TC_LOG_DEBUG("chat.system", "Channel(%s) loaded player %s into bannedStore", name.c_str(), banned_guid.ToString().c_str());
+ _bannedStore.insert(banned_guid);
}
}
}
- else // save
- {
- stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHANNEL);
- stmt->setString(0, name);
- stmt->setUInt32(1, _channelTeam);
- CharacterDatabase.Execute(stmt);
- TC_LOG_DEBUG("chat.system", "Channel(%s) saved in database", name.c_str());
- }
+ }
+ else // save
+ {
+ stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHANNEL);
+ stmt->setString(0, name);
+ stmt->setUInt32(1, _channelTeam);
+ CharacterDatabase.Execute(stmt);
+ TC_LOG_DEBUG("chat.system", "Channel(%s) saved in database", name.c_str());
+ }
- _persistentChannel = true;
+ _persistentChannel = true;
+ }
+}
+
+void Channel::GetChannelName(std::string& channelName, uint32 channelId, LocaleConstant locale, AreaTableEntry const* zoneEntry)
+{
+ if (channelId)
+ {
+ ChatChannelsEntry const* channelEntry = sChatChannelsStore.AssertEntry(channelId);
+ if (!(channelEntry->flags & CHANNEL_DBC_FLAG_GLOBAL))
+ {
+ if (channelEntry->flags & CHANNEL_DBC_FLAG_CITY_ONLY)
+ channelName = Trinity::StringFormat(channelEntry->pattern[locale], sObjectMgr->GetTrinityString(LANG_CHANNEL_CITY, locale));
+ else
+ channelName = Trinity::StringFormat(channelEntry->pattern[locale], ASSERT_NOTNULL(zoneEntry)->area_name[locale]);
}
+ else
+ channelName = channelEntry->pattern[locale];
}
}
+std::string Channel::GetName(LocaleConstant locale /*= DEFAULT_LOCALE*/) const
+{
+ std::string result = _channelName;
+ Channel::GetChannelName(result, _channelId, locale, _zoneEntry);
+
+ return result;
+}
+
void Channel::UpdateChannelInDB() const
{
if (_persistentChannel)
@@ -155,26 +186,26 @@ void Channel::JoinChannel(Player* player, std::string const& pass)
// Do not send error message for built-in channels
if (!IsConstant())
{
- WorldPacket data;
- MakePlayerAlreadyMember(&data, guid);
- SendToOne(&data, guid);
+ PlayerAlreadyMemberAppend appender(guid);
+ ChannelNameBuilder<PlayerAlreadyMemberAppend> builder(this, appender);
+ SendToOne(builder, guid);
}
return;
}
if (IsBanned(guid))
{
- WorldPacket data;
- MakeBanned(&data);
- SendToOne(&data, guid);
+ BannedAppend appender;
+ ChannelNameBuilder<BannedAppend> builder(this, appender);
+ SendToOne(builder, guid);
return;
}
if (!_channelPassword.empty() && pass != _channelPassword)
{
- WorldPacket data;
- MakeWrongPassword(&data);
- SendToOne(&data, guid);
+ WrongPasswordAppend appender;
+ ChannelNameBuilder<WrongPasswordAppend> builder(this, appender);
+ SendToOne(builder, guid);
return;
}
@@ -183,9 +214,9 @@ void Channel::JoinChannel(Player* player, std::string const& pass)
AccountMgr::IsPlayerAccount(player->GetSession()->GetSecurity()) && //FIXME: Move to RBAC
player->GetGroup())
{
- WorldPacket data;
- MakeNotInLfg(&data);
- SendToOne(&data, guid);
+ NotInLFGAppend appender;
+ ChannelNameBuilder<NotInLFGAppend> builder(this, appender);
+ SendToOne(builder, guid);
return;
}
@@ -193,9 +224,9 @@ void Channel::JoinChannel(Player* player, std::string const& pass)
if (_announceEnabled && !player->GetSession()->HasPermission(rbac::RBAC_PERM_SILENTLY_JOIN_CHANNEL))
{
- WorldPacket data;
- MakeJoined(&data, guid);
- SendToAll(&data);
+ JoinedAppend appender(guid);
+ ChannelNameBuilder<JoinedAppend> builder(this, appender);
+ SendToAll(builder);
}
bool newChannel = _playersStore.empty();
@@ -204,9 +235,9 @@ void Channel::JoinChannel(Player* player, std::string const& pass)
pinfo.flags = MEMBER_FLAG_NONE;
pinfo.invisible = !player->isGMVisible();
- WorldPacket data;
- MakeYouJoined(&data);
- SendToOne(&data, guid);
+ YouJoinedAppend appender(this);
+ ChannelNameBuilder<YouJoinedAppend> builder(this, appender);
+ SendToOne(builder, guid);
JoinNotify(guid);
@@ -236,20 +267,20 @@ void Channel::LeaveChannel(Player* player, bool send)
{
if (send)
{
- WorldPacket data;
- MakeNotMember(&data);
- SendToOne(&data, guid);
+ NotMemberAppend appender;
+ ChannelNameBuilder<NotMemberAppend> builder(this, appender);
+ SendToOne(builder, guid);
}
return;
}
if (send)
{
- WorldPacket data;
- MakeYouLeft(&data);
- SendToOne(&data, guid);
+ YouLeftAppend appender(this);
+ ChannelNameBuilder<YouLeftAppend> builder(this, appender);
+ SendToOne(builder, guid);
+
player->LeftChannel(this);
- data.clear();
}
PlayerInfo& info = _playersStore.at(guid);
@@ -258,9 +289,9 @@ void Channel::LeaveChannel(Player* player, bool send)
if (_announceEnabled && !player->GetSession()->HasPermission(rbac::RBAC_PERM_SILENTLY_JOIN_CHANNEL))
{
- WorldPacket data;
- MakeLeft(&data, guid);
- SendToAll(&data);
+ LeftAppend appender(guid);
+ ChannelNameBuilder<LeftAppend> builder(this, appender);
+ SendToAll(builder);
}
LeaveNotify(guid);
@@ -302,18 +333,18 @@ void Channel::KickOrBan(Player const* player, std::string const& badname, bool b
if (!IsOn(good))
{
- WorldPacket data;
- MakeNotMember(&data);
- SendToOne(&data, good);
+ NotMemberAppend appender;
+ ChannelNameBuilder<NotMemberAppend> builder(this, appender);
+ SendToOne(builder, good);
return;
}
PlayerInfo& info = _playersStore.at(good);
if (!info.IsModerator() && !player->GetSession()->HasPermission(rbac::RBAC_PERM_CHANGE_CHANNEL_NOT_MODERATOR))
{
- WorldPacket data;
- MakeNotModerator(&data);
- SendToOne(&data, good);
+ NotModeratorAppend appender;
+ ChannelNameBuilder<NotModeratorAppend> builder(this, appender);
+ SendToOne(builder, good);
return;
}
@@ -321,9 +352,9 @@ void Channel::KickOrBan(Player const* player, std::string const& badname, bool b
ObjectGuid victim = bad ? bad->GetGUID() : ObjectGuid::Empty;
if (!victim || !IsOn(victim))
{
- WorldPacket data;
- MakePlayerNotFound(&data, badname);
- SendToOne(&data, good);
+ PlayerNotFoundAppend appender(badname);
+ ChannelNameBuilder<PlayerNotFoundAppend> builder(this, appender);
+ SendToOne(builder, good);
return;
}
@@ -331,9 +362,9 @@ void Channel::KickOrBan(Player const* player, std::string const& badname, bool b
if (!player->GetSession()->HasPermission(rbac::RBAC_PERM_CHANGE_CHANNEL_NOT_MODERATOR) && changeowner && good != _ownerGuid)
{
- WorldPacket data;
- MakeNotOwner(&data);
- SendToOne(&data, good);
+ NotOwnerAppend appender;
+ ChannelNameBuilder<NotOwnerAppend> builder(this, appender);
+ SendToOne(builder, good);
return;
}
@@ -344,16 +375,16 @@ void Channel::KickOrBan(Player const* player, std::string const& badname, bool b
if (!player->GetSession()->HasPermission(rbac::RBAC_PERM_SILENTLY_JOIN_CHANNEL))
{
- WorldPacket data;
- MakePlayerBanned(&data, victim, good);
- SendToAll(&data);
+ PlayerBannedAppend appender(good, victim);
+ ChannelNameBuilder<PlayerBannedAppend> builder(this, appender);
+ SendToAll(builder);
}
}
else if (!player->GetSession()->HasPermission(rbac::RBAC_PERM_SILENTLY_JOIN_CHANNEL))
{
- WorldPacket data;
- MakePlayerKicked(&data, victim, good);
- SendToAll(&data);
+ PlayerKickedAppend appender(good, victim);
+ ChannelNameBuilder<PlayerKickedAppend> builder(this, appender);
+ SendToAll(builder);
}
_playersStore.erase(victim);
@@ -373,18 +404,18 @@ void Channel::UnBan(Player const* player, std::string const& badname)
if (!IsOn(good))
{
- WorldPacket data;
- MakeNotMember(&data);
- SendToOne(&data, good);
+ NotMemberAppend appender;
+ ChannelNameBuilder<NotMemberAppend> builder(this, appender);
+ SendToOne(builder, good);
return;
}
PlayerInfo& info = _playersStore.at(good);
if (!info.IsModerator() && !player->GetSession()->HasPermission(rbac::RBAC_PERM_CHANGE_CHANNEL_NOT_MODERATOR))
{
- WorldPacket data;
- MakeNotModerator(&data);
- SendToOne(&data, good);
+ NotModeratorAppend appender;
+ ChannelNameBuilder<NotModeratorAppend> builder(this, appender);
+ SendToOne(builder, good);
return;
}
@@ -393,17 +424,17 @@ void Channel::UnBan(Player const* player, std::string const& badname)
if (!victim || !IsBanned(victim))
{
- WorldPacket data;
- MakePlayerNotFound(&data, badname);
- SendToOne(&data, good);
+ PlayerNotFoundAppend appender(badname);
+ ChannelNameBuilder<PlayerNotFoundAppend> builder(this, appender);
+ SendToOne(builder, good);
return;
}
_bannedStore.erase(victim);
- WorldPacket data;
- MakePlayerUnbanned(&data, victim, good);
- SendToAll(&data);
+ PlayerUnbannedAppend appender(good, victim);
+ ChannelNameBuilder<PlayerUnbannedAppend> builder(this, appender);
+ SendToAll(builder);
UpdateChannelInDB();
}
@@ -415,26 +446,26 @@ void Channel::Password(Player const* player, std::string const& pass)
ChatHandler chat(player->GetSession());
if (!IsOn(guid))
{
- WorldPacket data;
- MakeNotMember(&data);
- SendToOne(&data, guid);
+ NotMemberAppend appender;
+ ChannelNameBuilder<NotMemberAppend> builder(this, appender);
+ SendToOne(builder, guid);
return;
}
PlayerInfo& info = _playersStore.at(guid);
if (!info.IsModerator() && !player->GetSession()->HasPermission(rbac::RBAC_PERM_CHANGE_CHANNEL_NOT_MODERATOR))
{
- WorldPacket data;
- MakeNotModerator(&data);
- SendToOne(&data, guid);
+ NotModeratorAppend appender;
+ ChannelNameBuilder<NotModeratorAppend> builder(this, appender);
+ SendToOne(builder, guid);
return;
}
_channelPassword = pass;
- WorldPacket data;
- MakePasswordChanged(&data, guid);
- SendToAll(&data);
+ PasswordChangedAppend appender(guid);
+ ChannelNameBuilder<PasswordChangedAppend> builder(this, appender);
+ SendToAll(builder);
UpdateChannelInDB();
}
@@ -445,18 +476,18 @@ void Channel::SetMode(Player const* player, std::string const& p2n, bool mod, bo
if (!IsOn(guid))
{
- WorldPacket data;
- MakeNotMember(&data);
- SendToOne(&data, guid);
+ NotMemberAppend appender;
+ ChannelNameBuilder<NotMemberAppend> builder(this, appender);
+ SendToOne(builder, guid);
return;
}
PlayerInfo& info = _playersStore.at(guid);
if (!info.IsModerator() && !player->GetSession()->HasPermission(rbac::RBAC_PERM_CHANGE_CHANNEL_NOT_MODERATOR))
{
- WorldPacket data;
- MakeNotModerator(&data);
- SendToOne(&data, guid);
+ NotModeratorAppend appender;
+ ChannelNameBuilder<NotModeratorAppend> builder(this, appender);
+ SendToOne(builder, guid);
return;
}
@@ -471,17 +502,17 @@ void Channel::SetMode(Player const* player, std::string const& p2n, bool mod, bo
(!player->GetSession()->HasPermission(rbac::RBAC_PERM_TWO_SIDE_INTERACTION_CHANNEL) ||
!newp->GetSession()->HasPermission(rbac::RBAC_PERM_TWO_SIDE_INTERACTION_CHANNEL))))
{
- WorldPacket data;
- MakePlayerNotFound(&data, p2n);
- SendToOne(&data, guid);
+ PlayerNotFoundAppend appender(p2n);
+ ChannelNameBuilder<PlayerNotFoundAppend> builder(this, appender);
+ SendToOne(builder, guid);
return;
}
if (_ownerGuid == victim && _ownerGuid != guid)
{
- WorldPacket data;
- MakeNotOwner(&data);
- SendToOne(&data, guid);
+ NotOwnerAppend appender;
+ ChannelNameBuilder<NotOwnerAppend> builder(this, appender);
+ SendToOne(builder, guid);
return;
}
@@ -504,23 +535,57 @@ void Channel::SetInvisible(Player const* player, bool on)
_isOwnerInvisible = on;
}
+void Channel::SetModerator(ObjectGuid guid, bool set)
+{
+ if (!IsOn(guid))
+ return;
+
+ PlayerInfo& playerInfo = _playersStore.at(guid);
+ if (playerInfo.IsModerator() != set)
+ {
+ uint8 oldFlag = GetPlayerFlags(guid);
+ playerInfo.SetModerator(set);
+
+ ModeChangeAppend appender(guid, oldFlag, GetPlayerFlags(guid));
+ ChannelNameBuilder<ModeChangeAppend> builder(this, appender);
+ SendToAll(builder);
+ }
+}
+
+void Channel::SetMute(ObjectGuid guid, bool set)
+{
+ if (!IsOn(guid))
+ return;
+
+ PlayerInfo& playerInfo = _playersStore.at(guid);
+ if (playerInfo.IsMuted() != set)
+ {
+ uint8 oldFlag = GetPlayerFlags(guid);
+ playerInfo.SetMuted(set);
+
+ ModeChangeAppend appender(guid, oldFlag, GetPlayerFlags(guid));
+ ChannelNameBuilder<ModeChangeAppend> builder(this, appender);
+ SendToAll(builder);
+ }
+}
+
void Channel::SetOwner(Player const* player, std::string const& newname)
{
ObjectGuid guid = player->GetGUID();
if (!IsOn(guid))
{
- WorldPacket data;
- MakeNotMember(&data);
- SendToOne(&data, guid);
+ NotMemberAppend appender;
+ ChannelNameBuilder<NotMemberAppend> builder(this, appender);
+ SendToOne(builder, guid);
return;
}
if (!player->GetSession()->HasPermission(rbac::RBAC_PERM_CHANGE_CHANNEL_NOT_MODERATOR) && guid != _ownerGuid)
{
- WorldPacket data;
- MakeNotOwner(&data);
- SendToOne(&data, guid);
+ NotOwnerAppend appender;
+ ChannelNameBuilder<NotOwnerAppend> builder(this, appender);
+ SendToOne(builder, guid);
return;
}
@@ -532,9 +597,9 @@ void Channel::SetOwner(Player const* player, std::string const& newname)
(!player->GetSession()->HasPermission(rbac::RBAC_PERM_TWO_SIDE_INTERACTION_CHANNEL) ||
!newp->GetSession()->HasPermission(rbac::RBAC_PERM_TWO_SIDE_INTERACTION_CHANNEL))))
{
- WorldPacket data;
- MakePlayerNotFound(&data, newname);
- SendToOne(&data, guid);
+ PlayerNotFoundAppend appender(newname);
+ ChannelNameBuilder<PlayerNotFoundAppend> builder(this, appender);
+ SendToOne(builder, guid);
return;
}
@@ -545,12 +610,18 @@ void Channel::SetOwner(Player const* player, std::string const& newname)
void Channel::SendWhoOwner(ObjectGuid guid)
{
- WorldPacket data;
if (IsOn(guid))
- MakeChannelOwner(&data);
+ {
+ ChannelOwnerAppend appender(this, _ownerGuid);
+ ChannelNameBuilder<ChannelOwnerAppend> builder(this, appender);
+ SendToOne(builder, guid);
+ }
else
- MakeNotMember(&data);
- SendToOne(&data, guid);
+ {
+ NotMemberAppend appender;
+ ChannelNameBuilder<NotMemberAppend> builder(this, appender);
+ SendToOne(builder, guid);
+ }
}
void Channel::List(Player const* player) const
@@ -559,18 +630,19 @@ void Channel::List(Player const* player) const
if (!IsOn(guid))
{
- WorldPacket data;
- MakeNotMember(&data);
- SendToOne(&data, guid);
+ NotMemberAppend appender;
+ ChannelNameBuilder<NotMemberAppend> builder(this, appender);
+ SendToOne(builder, guid);
return;
}
+ std::string channelName = GetName(player->GetSession()->GetSessionDbcLocale());
TC_LOG_DEBUG("chat.system", "SMSG_CHANNEL_LIST %s Channel: %s",
- player->GetSession()->GetPlayerInfo().c_str(), GetName().c_str());
+ player->GetSession()->GetPlayerInfo().c_str(), channelName.c_str());
- WorldPacket data(SMSG_CHANNEL_LIST, 1+(GetName().size()+1)+1+4+_playersStore.size()*(8+1));
+ WorldPacket data(SMSG_CHANNEL_LIST, 1 + (channelName.size() + 1) + 1 + 4 + _playersStore.size() * (8 + 1));
data << uint8(1); // channel type?
- data << GetName(); // channel name
+ data << channelName; // channel name
data << uint8(GetFlags()); // channel flags?
size_t pos = data.wpos();
@@ -597,8 +669,7 @@ void Channel::List(Player const* player) const
}
data.put<uint32>(pos, count);
-
- SendToOne(&data, guid);
+ player->SendDirectMessage(&data);
}
void Channel::Announce(Player const* player)
@@ -607,29 +678,35 @@ void Channel::Announce(Player const* player)
if (!IsOn(guid))
{
- WorldPacket data;
- MakeNotMember(&data);
- SendToOne(&data, guid);
+ NotMemberAppend appender;
+ ChannelNameBuilder<NotMemberAppend> builder(this, appender);
+ SendToOne(builder, guid);
return;
}
PlayerInfo& info = _playersStore.at(guid);
if (!info.IsModerator() && !player->GetSession()->HasPermission(rbac::RBAC_PERM_CHANGE_CHANNEL_NOT_MODERATOR))
{
- WorldPacket data;
- MakeNotModerator(&data);
- SendToOne(&data, guid);
+ NotModeratorAppend appender;
+ ChannelNameBuilder<NotModeratorAppend> builder(this, appender);
+ SendToOne(builder, guid);
return;
}
_announceEnabled = !_announceEnabled;
- WorldPacket data;
if (_announceEnabled)
- MakeAnnouncementsOn(&data, guid);
+ {
+ AnnouncementsOnAppend appender(guid);
+ ChannelNameBuilder<AnnouncementsOnAppend> builder(this, appender);
+ SendToAll(builder);
+ }
else
- MakeAnnouncementsOff(&data, guid);
- SendToAll(&data);
+ {
+ AnnouncementsOffAppend appender(guid);
+ ChannelNameBuilder<AnnouncementsOffAppend> builder(this, appender);
+ SendToAll(builder);
+ }
UpdateChannelInDB();
}
@@ -645,28 +722,32 @@ void Channel::Say(ObjectGuid guid, std::string const& what, uint32 lang) const
if (!IsOn(guid))
{
- WorldPacket data;
- MakeNotMember(&data);
- SendToOne(&data, guid);
+ NotMemberAppend appender;
+ ChannelNameBuilder<NotMemberAppend> builder(this, appender);
+ SendToOne(builder, guid);
return;
}
PlayerInfo const& info = _playersStore.at(guid);
if (info.IsMuted())
{
- WorldPacket data;
- MakeMuted(&data);
- SendToOne(&data, guid);
+ MutedAppend appender;
+ ChannelNameBuilder<MutedAppend> builder(this, appender);
+ SendToOne(builder, guid);
return;
}
- WorldPacket data;
- if (Player* player = ObjectAccessor::FindConnectedPlayer(guid))
- ChatHandler::BuildChatPacket(data, CHAT_MSG_CHANNEL, Language(lang), player, player, what, 0, _channelName);
- else
- ChatHandler::BuildChatPacket(data, CHAT_MSG_CHANNEL, Language(lang), guid, guid, what, 0, "", "", 0, false, _channelName);
+ auto builder = [&](WorldPacket& data, LocaleConstant locale)
+ {
+ LocaleConstant localeIdx = sWorld->GetAvailableDbcLocale(locale);
+
+ if (Player* player = ObjectAccessor::FindConnectedPlayer(guid))
+ ChatHandler::BuildChatPacket(data, CHAT_MSG_CHANNEL, Language(lang), player, player, what, 0, GetName(localeIdx));
+ else
+ ChatHandler::BuildChatPacket(data, CHAT_MSG_CHANNEL, Language(lang), guid, guid, what, 0, "", "", 0, false, GetName(localeIdx));
+ };
- SendToAll(&data, !info.IsModerator() ? guid : ObjectGuid::Empty);
+ SendToAll(builder, !info.IsModerator() ? guid : ObjectGuid::Empty);
}
void Channel::Invite(Player const* player, std::string const& newname)
@@ -675,26 +756,26 @@ void Channel::Invite(Player const* player, std::string const& newname)
if (!IsOn(guid))
{
- WorldPacket data;
- MakeNotMember(&data);
- SendToOne(&data, guid);
+ NotMemberAppend appender;
+ ChannelNameBuilder<NotMemberAppend> builder(this, appender);
+ SendToOne(builder, guid);
return;
}
Player* newp = ObjectAccessor::FindConnectedPlayerByName(newname);
if (!newp || !newp->isGMVisible())
{
- WorldPacket data;
- MakePlayerNotFound(&data, newname);
- SendToOne(&data, guid);
+ PlayerNotFoundAppend appender(newname);
+ ChannelNameBuilder<PlayerNotFoundAppend> builder(this, appender);
+ SendToOne(builder, guid);
return;
}
if (IsBanned(newp->GetGUID()))
{
- WorldPacket data;
- MakePlayerInviteBanned(&data, newname);
- SendToOne(&data, guid);
+ PlayerInviteBannedAppend appender(newname);
+ ChannelNameBuilder<PlayerInviteBannedAppend> builder(this, appender);
+ SendToOne(builder, guid);
return;
}
@@ -702,31 +783,30 @@ void Channel::Invite(Player const* player, std::string const& newname)
(!player->GetSession()->HasPermission(rbac::RBAC_PERM_TWO_SIDE_INTERACTION_CHANNEL) ||
!newp->GetSession()->HasPermission(rbac::RBAC_PERM_TWO_SIDE_INTERACTION_CHANNEL)))
{
- WorldPacket data;
- MakeInviteWrongFaction(&data);
- SendToOne(&data, guid);
+ InviteWrongFactionAppend appender;
+ ChannelNameBuilder<InviteWrongFactionAppend> builder(this, appender);
+ SendToOne(builder, guid);
return;
}
if (IsOn(newp->GetGUID()))
{
- WorldPacket data;
- MakePlayerAlreadyMember(&data, newp->GetGUID());
- SendToOne(&data, guid);
+ PlayerAlreadyMemberAppend appender(newp->GetGUID());
+ ChannelNameBuilder<PlayerAlreadyMemberAppend> builder(this, appender);
+ SendToOne(builder, guid);
return;
}
if (!newp->GetSocial()->HasIgnore(guid.GetCounter()))
{
- WorldPacket data;
- MakeInvite(&data, guid);
- SendToOne(&data, newp->GetGUID());
- data.clear();
+ InviteAppend appender(guid);
+ ChannelNameBuilder<InviteAppend> builder(this, appender);
+ SendToOne(builder, newp->GetGUID());
}
- WorldPacket data;
- MakePlayerInvited(&data, newp->GetName());
- SendToOne(&data, guid);
+ PlayerInvitedAppend appender(newp->GetName());
+ ChannelNameBuilder<PlayerInvitedAppend> builder(this, appender);
+ SendToOne(builder, guid);
}
void Channel::SetOwner(ObjectGuid guid, bool exclaim)
@@ -749,42 +829,21 @@ void Channel::SetOwner(ObjectGuid guid, bool exclaim)
itr->second.SetModerator(true);
itr->second.SetOwner(true);
- WorldPacket data;
- MakeModeChange(&data, _ownerGuid, oldFlag);
- SendToAll(&data);
+ ModeChangeAppend appender(_ownerGuid, oldFlag, GetPlayerFlags(_ownerGuid));
+ ChannelNameBuilder<ModeChangeAppend> builder(this, appender);
+ SendToAll(builder);
if (exclaim)
{
- MakeOwnerChanged(&data, _ownerGuid);
- SendToAll(&data);
+ OwnerChangedAppend appender(_ownerGuid);
+ ChannelNameBuilder<OwnerChangedAppend> builder(this, appender);
+ SendToAll(builder);
}
UpdateChannelInDB();
}
}
-void Channel::SendToAll(WorldPacket* data, ObjectGuid guid) const
-{
- for (PlayerContainer::const_iterator i = _playersStore.begin(); i != _playersStore.end(); ++i)
- if (Player* player = ObjectAccessor::FindConnectedPlayer(i->first))
- if (!guid || !player->GetSocial()->HasIgnore(guid.GetCounter()))
- player->GetSession()->SendPacket(data);
-}
-
-void Channel::SendToAllButOne(WorldPacket* data, ObjectGuid who) const
-{
- for (PlayerContainer::const_iterator i = _playersStore.begin(); i != _playersStore.end(); ++i)
- if (i->first != who)
- if (Player* player = ObjectAccessor::FindConnectedPlayer(i->first))
- player->GetSession()->SendPacket(data);
-}
-
-void Channel::SendToOne(WorldPacket* data, ObjectGuid who) const
-{
- if (Player* player = ObjectAccessor::FindConnectedPlayer(who))
- player->GetSession()->SendPacket(data);
-}
-
void Channel::Voice(ObjectGuid /*guid1*/, ObjectGuid /*guid2*/) const
{
@@ -795,245 +854,72 @@ void Channel::DeVoice(ObjectGuid /*guid1*/, ObjectGuid /*guid2*/) const
}
-void Channel::MakeNotifyPacket(WorldPacket* data, uint8 notify_type) const
-{
- data->Initialize(SMSG_CHANNEL_NOTIFY, 1 + _channelName.size());
- *data << uint8(notify_type);
- *data << _channelName;
-}
-
-void Channel::MakeJoined(WorldPacket* data, ObjectGuid guid) const
-{
- MakeNotifyPacket(data, CHAT_JOINED_NOTICE);
- *data << uint64(guid);
-}
-
-void Channel::MakeLeft(WorldPacket* data, ObjectGuid guid) const
-{
- MakeNotifyPacket(data, CHAT_LEFT_NOTICE);
- *data << uint64(guid);
-}
-
-void Channel::MakeYouJoined(WorldPacket* data) const
-{
- MakeNotifyPacket(data, CHAT_YOU_JOINED_NOTICE);
- *data << uint8(GetFlags());
- *data << uint32(GetChannelId());
- *data << uint32(0);
-}
-
-void Channel::MakeYouLeft(WorldPacket* data) const
-{
- MakeNotifyPacket(data, CHAT_YOU_LEFT_NOTICE);
- *data << uint32(GetChannelId());
- *data << uint8(IsConstant());
-}
-
-void Channel::MakeWrongPassword(WorldPacket* data) const
-{
- MakeNotifyPacket(data, CHAT_WRONG_PASSWORD_NOTICE);
-}
-
-void Channel::MakeNotMember(WorldPacket* data) const
-{
- MakeNotifyPacket(data, CHAT_NOT_MEMBER_NOTICE);
-}
-
-void Channel::MakeNotModerator(WorldPacket* data) const
-{
- MakeNotifyPacket(data, CHAT_NOT_MODERATOR_NOTICE);
-}
-
-void Channel::MakePasswordChanged(WorldPacket* data, ObjectGuid guid) const
-{
- MakeNotifyPacket(data, CHAT_PASSWORD_CHANGED_NOTICE);
- *data << uint64(guid);
-}
-
-void Channel::MakeOwnerChanged(WorldPacket* data, ObjectGuid guid) const
-{
- MakeNotifyPacket(data, CHAT_OWNER_CHANGED_NOTICE);
- *data << uint64(guid);
-}
-
-void Channel::MakePlayerNotFound(WorldPacket* data, std::string const& name) const
-{
- MakeNotifyPacket(data, CHAT_PLAYER_NOT_FOUND_NOTICE);
- *data << name;
-}
-
-void Channel::MakeNotOwner(WorldPacket* data) const
+void Channel::JoinNotify(ObjectGuid guid) const
{
- MakeNotifyPacket(data, CHAT_NOT_OWNER_NOTICE);
-}
+ auto builder = [&](WorldPacket& data, LocaleConstant locale)
+ {
+ LocaleConstant localeIdx = sWorld->GetAvailableDbcLocale(locale);
-void Channel::MakeChannelOwner(WorldPacket* data) const
-{
- std::string name;
+ data.Initialize(IsConstant() ? SMSG_USERLIST_ADD : SMSG_USERLIST_UPDATE, 8 + 1 + 1 + 4 + 30 /*channelName buffer*/);
+ data << uint64(guid);
+ data << uint8(GetPlayerFlags(guid));
+ data << uint8(GetFlags());
+ data << uint32(GetNumPlayers());
+ data << GetName(localeIdx);
+ };
- CharacterInfo const* cInfo = sWorld->GetCharacterInfo(_ownerGuid);
- if (!cInfo || cInfo->Name.empty())
- name = "PLAYER_NOT_FOUND";
+ if (IsConstant())
+ SendToAllButOne(builder, guid);
else
- name = cInfo->Name;
-
- MakeNotifyPacket(data, CHAT_CHANNEL_OWNER_NOTICE);
- *data << ((IsConstant() || !_ownerGuid) ? "Nobody" : name);
-}
-
-void Channel::MakeModeChange(WorldPacket* data, ObjectGuid guid, uint8 oldflags) const
-{
- MakeNotifyPacket(data, CHAT_MODE_CHANGE_NOTICE);
- *data << uint64(guid);
- *data << uint8(oldflags);
- *data << uint8(GetPlayerFlags(guid));
-}
-
-void Channel::MakeAnnouncementsOn(WorldPacket* data, ObjectGuid guid) const
-{
- MakeNotifyPacket(data, CHAT_ANNOUNCEMENTS_ON_NOTICE);
- *data << uint64(guid);
-}
-
-void Channel::MakeAnnouncementsOff(WorldPacket* data, ObjectGuid guid) const
-{
- MakeNotifyPacket(data, CHAT_ANNOUNCEMENTS_OFF_NOTICE);
- *data << uint64(guid);
-}
-
-void Channel::MakeMuted(WorldPacket* data) const
-{
- MakeNotifyPacket(data, CHAT_MUTED_NOTICE);
-}
-
-void Channel::MakePlayerKicked(WorldPacket* data, ObjectGuid bad, ObjectGuid good) const
-{
- MakeNotifyPacket(data, CHAT_PLAYER_KICKED_NOTICE);
- *data << uint64(bad);
- *data << uint64(good);
-}
-
-void Channel::MakeBanned(WorldPacket* data) const
-{
- MakeNotifyPacket(data, CHAT_BANNED_NOTICE);
-}
-
-void Channel::MakePlayerBanned(WorldPacket* data, ObjectGuid bad, ObjectGuid good) const
-{
- MakeNotifyPacket(data, CHAT_PLAYER_BANNED_NOTICE);
- *data << uint64(bad);
- *data << uint64(good);
-}
-
-void Channel::MakePlayerUnbanned(WorldPacket* data, ObjectGuid bad, ObjectGuid good) const
-{
- MakeNotifyPacket(data, CHAT_PLAYER_UNBANNED_NOTICE);
- *data << uint64(bad);
- *data << uint64(good);
-}
-
-void Channel::MakePlayerNotBanned(WorldPacket* data, const std::string &name) const
-{
- MakeNotifyPacket(data, CHAT_PLAYER_NOT_BANNED_NOTICE);
- *data << name;
+ SendToAll(builder);
}
-void Channel::MakePlayerAlreadyMember(WorldPacket* data, ObjectGuid guid) const
-{
- MakeNotifyPacket(data, CHAT_PLAYER_ALREADY_MEMBER_NOTICE);
- *data << uint64(guid);
-}
-
-void Channel::MakeInvite(WorldPacket* data, ObjectGuid guid) const
-{
- MakeNotifyPacket(data, CHAT_INVITE_NOTICE);
- *data << uint64(guid);
-}
-
-void Channel::MakeInviteWrongFaction(WorldPacket* data) const
-{
- MakeNotifyPacket(data, CHAT_INVITE_WRONG_FACTION_NOTICE);
-}
-
-void Channel::MakeWrongFaction(WorldPacket* data) const
-{
- MakeNotifyPacket(data, CHAT_WRONG_FACTION_NOTICE);
-}
-
-void Channel::MakeInvalidName(WorldPacket* data) const
-{
- MakeNotifyPacket(data, CHAT_INVALID_NAME_NOTICE);
-}
-
-void Channel::MakeNotModerated(WorldPacket* data) const
-{
- MakeNotifyPacket(data, CHAT_NOT_MODERATED_NOTICE);
-}
-
-void Channel::MakePlayerInvited(WorldPacket* data, std::string const& name) const
-{
- MakeNotifyPacket(data, CHAT_PLAYER_INVITED_NOTICE);
- *data << name;
-}
-
-void Channel::MakePlayerInviteBanned(WorldPacket* data, std::string const& name) const
-{
- MakeNotifyPacket(data, CHAT_PLAYER_INVITE_BANNED_NOTICE);
- *data << name;
-}
-
-void Channel::MakeThrottled(WorldPacket* data) const
+void Channel::LeaveNotify(ObjectGuid guid) const
{
- MakeNotifyPacket(data, CHAT_THROTTLED_NOTICE);
-}
+ auto builder = [&](WorldPacket& data, LocaleConstant locale)
+ {
+ LocaleConstant localeIdx = sWorld->GetAvailableDbcLocale(locale);
-void Channel::MakeNotInArea(WorldPacket* data) const
-{
- MakeNotifyPacket(data, CHAT_NOT_IN_AREA_NOTICE);
-}
+ data.Initialize(SMSG_USERLIST_REMOVE, 8 + 1 + 4 + 30 /*channelName buffer*/);
+ data << uint64(guid);
+ data << uint8(GetFlags());
+ data << uint32(GetNumPlayers());
+ data << GetName(localeIdx);
+ };
-void Channel::MakeNotInLfg(WorldPacket* data) const
-{
- MakeNotifyPacket(data, CHAT_NOT_IN_LFG_NOTICE);
+ if (IsConstant())
+ SendToAllButOne(builder, guid);
+ else
+ SendToAll(builder);
}
-void Channel::MakeVoiceOn(WorldPacket* data, ObjectGuid guid) const
+template<class Builder>
+void Channel::SendToAll(Builder& builder, ObjectGuid guid /*= ObjectGuid::Empty*/) const
{
- MakeNotifyPacket(data, CHAT_VOICE_ON_NOTICE);
- *data << uint64(guid);
-}
+ Trinity::LocalizedPacketDo<Builder> localizer(builder);
-void Channel::MakeVoiceOff(WorldPacket* data, ObjectGuid guid) const
-{
- MakeNotifyPacket(data, CHAT_VOICE_OFF_NOTICE);
- *data << uint64(guid);
+ for (PlayerContainer::const_iterator i = _playersStore.begin(); i != _playersStore.end(); ++i)
+ if (Player* player = ObjectAccessor::FindConnectedPlayer(i->first))
+ if (!guid || !player->GetSocial()->HasIgnore(guid.GetCounter()))
+ localizer(player);
}
-void Channel::JoinNotify(ObjectGuid guid) const
+template<class Builder>
+void Channel::SendToAllButOne(Builder& builder, ObjectGuid who) const
{
- WorldPacket data(IsConstant() ? SMSG_USERLIST_ADD : SMSG_USERLIST_UPDATE, 8 + 1 + 1 + 4 + GetName().size());
- data << uint64(guid);
- data << uint8(GetPlayerFlags(guid));
- data << uint8(GetFlags());
- data << uint32(GetNumPlayers());
- data << GetName();
+ Trinity::LocalizedPacketDo<Builder> localizer(builder);
- if (IsConstant())
- SendToAllButOne(&data, guid);
- else
- SendToAll(&data);
+ for (PlayerContainer::const_iterator i = _playersStore.begin(); i != _playersStore.end(); ++i)
+ if (i->first != who)
+ if (Player* player = ObjectAccessor::FindConnectedPlayer(i->first))
+ localizer(player);
}
-void Channel::LeaveNotify(ObjectGuid guid) const
+template<class Builder>
+void Channel::SendToOne(Builder& builder, ObjectGuid who) const
{
- WorldPacket data(SMSG_USERLIST_REMOVE, 8 + 1 + 4 + GetName().size());
- data << uint64(guid);
- data << uint8(GetFlags());
- data << uint32(GetNumPlayers());
- data << GetName();
+ Trinity::LocalizedPacketDo<Builder> localizer(builder);
- if (IsConstant())
- SendToAllButOne(&data, guid);
- else
- SendToAll(&data);
+ if (Player* player = ObjectAccessor::FindConnectedPlayer(who))
+ localizer(player);
}
diff --git a/src/server/game/Chat/Channels/Channel.h b/src/server/game/Chat/Channels/Channel.h
index 4859a984967..8c01a474854 100644
--- a/src/server/game/Chat/Channels/Channel.h
+++ b/src/server/game/Chat/Channels/Channel.h
@@ -150,9 +150,11 @@ class TC_GAME_API Channel
};
public:
- Channel(std::string const& name, uint32 channel_id, uint32 team = 0);
+ Channel(uint32 channelId, uint32 team = 0, AreaTableEntry const* zoneEntry = nullptr); // built-in channel ctor
+ Channel(std::string const& name, uint32 team = 0); // custom player channel ctor
- std::string const& GetName() const { return _channelName; }
+ static void GetChannelName(std::string& channelName, uint32 channelId, LocaleConstant locale, AreaTableEntry const* zoneEntry);
+ std::string GetName(LocaleConstant locale = DEFAULT_LOCALE) const;
uint32 GetChannelId() const { return _channelId; }
bool IsConstant() const { return _channelId != 0; }
@@ -169,6 +171,8 @@ class TC_GAME_API Channel
uint8 GetFlags() const { return _channelFlags; }
bool HasFlag(uint8 flag) const { return (_channelFlags & flag) != 0; }
+ AreaTableEntry const* GetZoneEntry() const { return _zoneEntry; }
+
void JoinChannel(Player* player, std::string const& pass);
void LeaveChannel(Player* player, bool send = true);
@@ -203,47 +207,15 @@ class TC_GAME_API Channel
static void CleanOldChannelsInDB();
private:
- // initial packet data (notify type and channel name)
- void MakeNotifyPacket(WorldPacket* data, uint8 notify_type) const;
- // type specific packet data
- void MakeJoined(WorldPacket* data, ObjectGuid guid) const; //+ 0x00
- void MakeLeft(WorldPacket* data, ObjectGuid guid) const; //+ 0x01
- void MakeYouJoined(WorldPacket* data) const; //+ 0x02
- void MakeYouLeft(WorldPacket* data) const; //+ 0x03
- void MakeWrongPassword(WorldPacket* data) const; //? 0x04
- void MakeNotMember(WorldPacket* data) const; //? 0x05
- void MakeNotModerator(WorldPacket* data) const; //? 0x06
- void MakePasswordChanged(WorldPacket* data, ObjectGuid guid) const; //+ 0x07
- void MakeOwnerChanged(WorldPacket* data, ObjectGuid guid) const; //? 0x08
- void MakePlayerNotFound(WorldPacket* data, std::string const& name) const; //+ 0x09
- void MakeNotOwner(WorldPacket* data) const; //? 0x0A
- void MakeChannelOwner(WorldPacket* data) const; //? 0x0B
- void MakeModeChange(WorldPacket* data, ObjectGuid guid, uint8 oldflags) const; //+ 0x0C
- void MakeAnnouncementsOn(WorldPacket* data, ObjectGuid guid) const; //+ 0x0D
- void MakeAnnouncementsOff(WorldPacket* data, ObjectGuid guid) const; //+ 0x0E
- void MakeMuted(WorldPacket* data) const; //? 0x11
- void MakePlayerKicked(WorldPacket* data, ObjectGuid bad, ObjectGuid good) const; //? 0x12
- void MakeBanned(WorldPacket* data) const; //? 0x13
- void MakePlayerBanned(WorldPacket* data, ObjectGuid bad, ObjectGuid good) const; //? 0x14
- void MakePlayerUnbanned(WorldPacket* data, ObjectGuid bad, ObjectGuid good) const; //? 0x15
- void MakePlayerNotBanned(WorldPacket* data, std::string const& name) const; //? 0x16
- void MakePlayerAlreadyMember(WorldPacket* data, ObjectGuid guid) const; //+ 0x17
- void MakeInvite(WorldPacket* data, ObjectGuid guid) const; //? 0x18
- void MakeInviteWrongFaction(WorldPacket* data) const; //? 0x19
- void MakeWrongFaction(WorldPacket* data) const; //? 0x1A
- void MakeInvalidName(WorldPacket* data) const; //? 0x1B
- void MakeNotModerated(WorldPacket* data) const; //? 0x1C
- void MakePlayerInvited(WorldPacket* data, std::string const& name) const; //+ 0x1D
- void MakePlayerInviteBanned(WorldPacket* data, std::string const& name) const; //? 0x1E
- void MakeThrottled(WorldPacket* data) const; //? 0x1F
- void MakeNotInArea(WorldPacket* data) const; //? 0x20
- void MakeNotInLfg(WorldPacket* data) const; //? 0x21
- void MakeVoiceOn(WorldPacket* data, ObjectGuid guid) const; //+ 0x22
- void MakeVoiceOff(WorldPacket* data, ObjectGuid guid) const; //+ 0x23
-
- void SendToAll(WorldPacket* data, ObjectGuid guid = ObjectGuid::Empty) const;
- void SendToAllButOne(WorldPacket* data, ObjectGuid who) const;
- void SendToOne(WorldPacket* data, ObjectGuid who) const;
+
+ template<class Builder>
+ void SendToAll(Builder&, ObjectGuid guid = ObjectGuid::Empty) const;
+
+ template<class Builder>
+ void SendToAllButOne(Builder& builder, ObjectGuid who) const;
+
+ template<class Builder>
+ void SendToOne(Builder& builder, ObjectGuid who) const;
bool IsOn(ObjectGuid who) const { return _playersStore.count(who) != 0; }
bool IsBanned(ObjectGuid guid) const { return _bannedStore.count(guid) != 0; }
@@ -257,39 +229,8 @@ class TC_GAME_API Channel
return itr != _playersStore.end() ? itr->second.flags : 0;
}
- void SetModerator(ObjectGuid guid, bool set)
- {
- if (!IsOn(guid))
- return;
-
- PlayerInfo& playerInfo = _playersStore.at(guid);
- if (playerInfo.IsModerator() != set)
- {
- uint8 oldFlag = GetPlayerFlags(guid);
- playerInfo.SetModerator(set);
-
- WorldPacket data;
- MakeModeChange(&data, guid, oldFlag);
- SendToAll(&data);
- }
- }
-
- void SetMute(ObjectGuid guid, bool set)
- {
- if (!IsOn(guid))
- return;
-
- PlayerInfo& playerInfo = _playersStore.at(guid);
- if (playerInfo.IsMuted() != set)
- {
- uint8 oldFlag = GetPlayerFlags(guid);
- playerInfo.SetMuted(set);
-
- WorldPacket data;
- MakeModeChange(&data, guid, oldFlag);
- SendToAll(&data);
- }
- }
+ void SetModerator(ObjectGuid guid, bool set);
+ void SetMute(ObjectGuid guid, bool set);
typedef std::map<ObjectGuid, PlayerInfo> PlayerContainer;
typedef GuidUnorderedSet BannedContainer;
@@ -307,6 +248,8 @@ class TC_GAME_API Channel
std::string _channelPassword;
PlayerContainer _playersStore;
BannedContainer _bannedStore;
+
+ AreaTableEntry const* _zoneEntry;
};
#endif
diff --git a/src/server/game/Chat/Channels/ChannelAppenders.h b/src/server/game/Chat/Channels/ChannelAppenders.h
new file mode 100644
index 00000000000..3dfdc3f32cf
--- /dev/null
+++ b/src/server/game/Chat/Channels/ChannelAppenders.h
@@ -0,0 +1,476 @@
+/*
+ * Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
+ *
+ * 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
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _CHANNELAPPENDERS_H
+#define _CHANNELAPPENDERS_H
+
+#include "Channel.h"
+
+// initial packet data (notify type and channel name)
+template<class PacketModifier>
+class ChannelNameBuilder
+{
+ public:
+ ChannelNameBuilder(Channel const* source, PacketModifier const& modifier)
+ : _source(source), _modifier(modifier){ }
+
+ void operator()(WorldPacket& data, LocaleConstant locale) const
+ {
+ // LocalizedPacketDo sends client DBC locale, we need to get available to server locale
+ LocaleConstant localeIdx = sWorld->GetAvailableDbcLocale(locale);
+
+ data.Initialize(SMSG_CHANNEL_NOTIFY, 60); // guess size
+ data << uint8(_modifier.NotificationType);
+ data << _source->GetName(localeIdx);
+ _modifier.Append(data);
+ }
+
+ private:
+ Channel const* _source;
+ PacketModifier _modifier;
+};
+
+struct JoinedAppend
+{
+ explicit JoinedAppend(ObjectGuid const& guid) : _guid(guid) { }
+
+ static uint8 const NotificationType = CHAT_JOINED_NOTICE;
+
+ void Append(WorldPacket& data) const
+ {
+ data << uint64(_guid);
+ }
+
+private:
+ ObjectGuid _guid;
+};
+
+struct LeftAppend
+{
+ explicit LeftAppend(ObjectGuid const& guid) : _guid(guid) { }
+
+ static uint8 const NotificationType = CHAT_LEFT_NOTICE;
+
+ void Append(WorldPacket& data) const
+ {
+ data << uint64(_guid);
+ }
+
+private:
+ ObjectGuid _guid;
+};
+
+struct YouJoinedAppend
+{
+ explicit YouJoinedAppend(Channel const* channel) : _channel(channel) { }
+
+ static uint8 const NotificationType = CHAT_YOU_JOINED_NOTICE;
+
+ void Append(WorldPacket& data) const
+ {
+ data << uint8(_channel->GetFlags());
+ data << uint32(_channel->GetChannelId());
+ data << uint32(0);
+ }
+
+private:
+ Channel const* _channel;
+};
+
+struct YouLeftAppend
+{
+ explicit YouLeftAppend(Channel const* channel) : _channel(channel) { }
+
+ static uint8 const NotificationType = CHAT_YOU_LEFT_NOTICE;
+
+ void Append(WorldPacket& data) const
+ {
+ data << uint32(_channel->GetChannelId());
+ data << uint8(_channel->IsConstant());
+ }
+
+private:
+ Channel const* _channel;
+};
+
+struct WrongPasswordAppend
+{
+ static uint8 const NotificationType = CHAT_WRONG_PASSWORD_NOTICE;
+
+ void Append(WorldPacket& /*data*/) const { }
+};
+
+struct NotMemberAppend
+{
+ static uint8 const NotificationType = CHAT_NOT_MEMBER_NOTICE;
+
+ void Append(WorldPacket& /*data*/) const { }
+};
+
+struct NotModeratorAppend
+{
+ static uint8 const NotificationType = CHAT_NOT_MODERATOR_NOTICE;
+
+ void Append(WorldPacket& /*data*/) const { }
+};
+
+struct PasswordChangedAppend
+{
+ explicit PasswordChangedAppend(ObjectGuid const& guid) : _guid(guid) { }
+
+ static uint8 const NotificationType = CHAT_PASSWORD_CHANGED_NOTICE;
+
+ void Append(WorldPacket& data) const
+ {
+ data << uint64(_guid);
+ }
+
+private:
+ ObjectGuid _guid;
+};
+
+struct OwnerChangedAppend
+{
+ explicit OwnerChangedAppend(ObjectGuid const& guid) : _guid(guid) { }
+
+ static uint8 const NotificationType = CHAT_OWNER_CHANGED_NOTICE;
+
+ void Append(WorldPacket& data) const
+ {
+ data << uint64(_guid);
+ }
+
+private:
+ ObjectGuid _guid;
+};
+
+struct PlayerNotFoundAppend
+{
+ explicit PlayerNotFoundAppend(std::string const& playerName) : _playerName(playerName) { }
+
+ static uint8 const NotificationType = CHAT_PLAYER_NOT_FOUND_NOTICE;
+
+ void Append(WorldPacket& data) const
+ {
+ data << _playerName;
+ }
+
+private:
+ std::string _playerName;
+};
+
+struct NotOwnerAppend
+{
+ static uint8 const NotificationType = CHAT_NOT_OWNER_NOTICE;
+
+ void Append(WorldPacket& /*data*/) const { }
+};
+
+struct ChannelOwnerAppend
+{
+ explicit ChannelOwnerAppend(Channel const* channel, ObjectGuid const& ownerGuid) : _channel(channel), _ownerGuid(ownerGuid)
+ {
+ CharacterInfo const* cInfo = sWorld->GetCharacterInfo(_ownerGuid);
+ if (!cInfo || cInfo->Name.empty())
+ _ownerName = "PLAYER_NOT_FOUND";
+ else
+ _ownerName = cInfo->Name;
+ }
+
+ static uint8 const NotificationType = CHAT_CHANNEL_OWNER_NOTICE;
+
+ void Append(WorldPacket& data) const
+ {
+ data << ((_channel->IsConstant() || !_ownerGuid) ? "Nobody" : _ownerName);
+ }
+
+private:
+ Channel const* _channel;
+ ObjectGuid _ownerGuid;
+
+ std::string _ownerName;
+};
+
+struct ModeChangeAppend
+{
+ explicit ModeChangeAppend(ObjectGuid const& guid, uint8 oldFlags, uint8 newFlags) : _guid(guid), _oldFlags(oldFlags), _newFlags(newFlags) { }
+
+ static uint8 const NotificationType = CHAT_MODE_CHANGE_NOTICE;
+
+ void Append(WorldPacket& data) const
+ {
+ data << uint64(_guid);
+ data << uint8(_oldFlags);
+ data << uint8(_newFlags);
+ }
+
+private:
+ ObjectGuid _guid;
+ uint8 _oldFlags;
+ uint8 _newFlags;
+};
+
+struct AnnouncementsOnAppend
+{
+ explicit AnnouncementsOnAppend(ObjectGuid const& guid) : _guid(guid) { }
+
+ static uint8 const NotificationType = CHAT_ANNOUNCEMENTS_ON_NOTICE;
+
+ void Append(WorldPacket& data) const
+ {
+ data << uint64(_guid);
+ }
+
+private:
+ ObjectGuid _guid;
+};
+
+struct AnnouncementsOffAppend
+{
+ explicit AnnouncementsOffAppend(ObjectGuid const& guid) : _guid(guid) { }
+
+ static uint8 const NotificationType = CHAT_ANNOUNCEMENTS_OFF_NOTICE;
+
+ void Append(WorldPacket& data) const
+ {
+ data << uint64(_guid);
+ }
+
+private:
+ ObjectGuid _guid;
+};
+
+struct MutedAppend
+{
+ static uint8 const NotificationType = CHAT_MUTED_NOTICE;
+
+ void Append(WorldPacket& /*data*/) const { }
+};
+
+struct PlayerKickedAppend
+{
+ explicit PlayerKickedAppend(ObjectGuid const& kicker, ObjectGuid const& kickee) : _kicker(kicker), _kickee(kickee) { }
+
+ static uint8 const NotificationType = CHAT_PLAYER_KICKED_NOTICE;
+
+ void Append(WorldPacket& data) const
+ {
+ data << uint64(_kickee);
+ data << uint64(_kicker);
+ }
+
+private:
+ ObjectGuid _kicker;
+ ObjectGuid _kickee;
+};
+
+struct BannedAppend
+{
+ static uint8 const NotificationType = CHAT_BANNED_NOTICE;
+
+ void Append(WorldPacket& /*data*/) const { }
+};
+
+struct PlayerBannedAppend
+{
+ explicit PlayerBannedAppend(ObjectGuid const& moderator, ObjectGuid const& banned) : _moderator(moderator), _banned(banned) { }
+
+ static uint8 const NotificationType = CHAT_PLAYER_BANNED_NOTICE;
+
+ void Append(WorldPacket& data) const
+ {
+ data << uint64(_banned);
+ data << uint64(_moderator);
+ }
+
+private:
+ ObjectGuid _moderator;
+ ObjectGuid _banned;
+};
+
+struct PlayerUnbannedAppend
+{
+ explicit PlayerUnbannedAppend(ObjectGuid const& moderator, ObjectGuid const& unbanned) : _moderator(moderator), _unbanned(unbanned) { }
+
+ static uint8 const NotificationType = CHAT_PLAYER_UNBANNED_NOTICE;
+
+ void Append(WorldPacket& data) const
+ {
+ data << uint64(_unbanned);
+ data << uint64(_moderator);
+ }
+
+private:
+ ObjectGuid _moderator;
+ ObjectGuid _unbanned;
+};
+
+struct PlayerNotBannedAppend
+{
+ explicit PlayerNotBannedAppend(std::string const& playerName) : _playerName(playerName) { }
+
+ static uint8 const NotificationType = CHAT_PLAYER_NOT_BANNED_NOTICE;
+
+ void Append(WorldPacket& data) const
+ {
+ data << _playerName;
+ }
+
+private:
+ std::string _playerName;
+};
+
+struct PlayerAlreadyMemberAppend
+{
+ explicit PlayerAlreadyMemberAppend(ObjectGuid const& guid) : _guid(guid) { }
+
+ static uint8 const NotificationType = CHAT_PLAYER_ALREADY_MEMBER_NOTICE;
+
+ void Append(WorldPacket& data) const
+ {
+ data << uint64(_guid);
+ }
+
+private:
+ ObjectGuid _guid;
+};
+
+struct InviteAppend
+{
+ explicit InviteAppend(ObjectGuid const& guid) : _guid(guid) { }
+
+ static uint8 const NotificationType = CHAT_INVITE_NOTICE;
+
+ void Append(WorldPacket& data) const
+ {
+ data << uint64(_guid);
+ }
+
+private:
+ ObjectGuid _guid;
+};
+
+struct InviteWrongFactionAppend
+{
+ static uint8 const NotificationType = CHAT_INVITE_WRONG_FACTION_NOTICE;
+
+ void Append(WorldPacket& /*data*/) const { }
+};
+
+struct WrongFactionAppend
+{
+ static uint8 const NotificationType = CHAT_WRONG_FACTION_NOTICE;
+
+ void Append(WorldPacket& /*data*/) const { }
+};
+
+struct InvalidNameAppend
+{
+ static uint8 const NotificationType = CHAT_INVALID_NAME_NOTICE;
+
+ void Append(WorldPacket& /*data*/) const { }
+};
+
+struct NotModeratedAppend
+{
+ static uint8 const NotificationType = CHAT_NOT_MODERATED_NOTICE;
+
+ void Append(WorldPacket& /*data*/) const { }
+};
+
+struct PlayerInvitedAppend
+{
+ explicit PlayerInvitedAppend(std::string const& playerName) : _playerName(playerName) { }
+
+ static uint8 const NotificationType = CHAT_PLAYER_INVITED_NOTICE;
+
+ void Append(WorldPacket& data) const
+ {
+ data << _playerName;
+ }
+
+private:
+ std::string _playerName;
+};
+
+struct PlayerInviteBannedAppend
+{
+ explicit PlayerInviteBannedAppend(std::string const& playerName) : _playerName(playerName) { }
+
+ static uint8 const NotificationType = CHAT_PLAYER_INVITE_BANNED_NOTICE;
+
+ void Append(WorldPacket& data) const
+ {
+ data << _playerName;
+ }
+
+private:
+ std::string _playerName;
+};
+
+struct ThrottledAppend
+{
+ static uint8 const NotificationType = CHAT_THROTTLED_NOTICE;
+
+ void Append(WorldPacket& /*data*/) const { }
+};
+
+struct NotInAreaAppend
+{
+ static uint8 const NotificationType = CHAT_NOT_IN_AREA_NOTICE;
+
+ void Append(WorldPacket& /*data*/) const { }
+};
+
+struct NotInLFGAppend
+{
+ static uint8 const NotificationType = CHAT_NOT_IN_LFG_NOTICE;
+
+ void Append(WorldPacket& /*data*/) const { }
+};
+
+struct VoiceOnAppend
+{
+ explicit VoiceOnAppend(ObjectGuid const& guid) : _guid(guid) { }
+
+ static uint8 const NotificationType = CHAT_VOICE_ON_NOTICE;
+
+ void Append(WorldPacket& data) const
+ {
+ data << uint64(_guid);
+ }
+
+private:
+ ObjectGuid _guid;
+};
+
+struct VoiceOffAppend
+{
+ explicit VoiceOffAppend(ObjectGuid const& guid) : _guid(guid) { }
+
+ static uint8 const NotificationType = CHAT_VOICE_OFF_NOTICE;
+
+ void Append(WorldPacket& data) const
+ {
+ data << uint64(_guid);
+ }
+
+private:
+ ObjectGuid _guid;
+};
+
+#endif // _CHANNELAPPENDERS_H
diff --git a/src/server/game/Chat/Channels/ChannelMgr.cpp b/src/server/game/Chat/Channels/ChannelMgr.cpp
index 043d4bdc2bc..ee1f463aae2 100644
--- a/src/server/game/Chat/Channels/ChannelMgr.cpp
+++ b/src/server/game/Chat/Channels/ChannelMgr.cpp
@@ -16,20 +16,25 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "Channel.h"
#include "ChannelMgr.h"
#include "Player.h"
#include "World.h"
ChannelMgr::~ChannelMgr()
{
- for (ChannelMap::iterator itr = channels.begin(); itr != channels.end(); ++itr)
+ for (auto itr = _channels.begin(); itr != _channels.end(); ++itr)
+ delete itr->second;
+
+ for (auto itr = _customChannels.begin(); itr != _customChannels.end(); ++itr)
delete itr->second;
}
ChannelMgr* ChannelMgr::forTeam(uint32 team)
{
- static ChannelMgr allianceChannelMgr;
- static ChannelMgr hordeChannelMgr;
+ static ChannelMgr allianceChannelMgr(ALLIANCE);
+ static ChannelMgr hordeChannelMgr(HORDE);
+
if (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL))
return &allianceChannelMgr; // cross-faction
@@ -42,69 +47,148 @@ ChannelMgr* ChannelMgr::forTeam(uint32 team)
return nullptr;
}
-Channel* ChannelMgr::GetJoinChannel(std::string const& name, uint32 channelId)
+Channel* ChannelMgr::GetChannelForPlayerByNamePart(std::string const& namePart, Player* playerSearcher)
{
- std::wstring wname;
- if (!Utf8toWStr(name, wname))
+ std::wstring channelNamePart;
+ if (!Utf8toWStr(namePart, channelNamePart))
return nullptr;
- wstrToLower(wname);
+ wstrToLower(channelNamePart);
+ for (Channel* channel : playerSearcher->GetJoinedChannels())
+ {
+ std::string chanName = channel->GetName(playerSearcher->GetSession()->GetSessionDbcLocale());
- ChannelMap::const_iterator i = channels.find(wname);
+ std::wstring channelNameW;
+ if (!Utf8toWStr(chanName, channelNameW))
+ continue;
- if (i == channels.end())
- {
- Channel* nchan = new Channel(name, channelId, team);
- channels[wname] = nchan;
- return nchan;
+ wstrToLower(channelNameW);
+ if (!channelNameW.compare(0, channelNamePart.size(), channelNamePart))
+ return channel;
}
- return i->second;
+ return nullptr;
}
-Channel* ChannelMgr::GetChannel(std::string const& name, Player* player, bool pkt)
+Channel* ChannelMgr::GetJoinChannel(uint32 channelId, std::string const& name, AreaTableEntry const* zoneEntry /*= nullptr*/)
{
- std::wstring wname;
- if (!Utf8toWStr(name, wname))
- return nullptr;
+ if (channelId) // builtin
+ {
+ ChatChannelsEntry const* channelEntry = sChatChannelsStore.AssertEntry(channelId);
+ uint32 zoneId = zoneEntry ? zoneEntry->ID : 0;
+ if (channelEntry->flags & (CHANNEL_DBC_FLAG_GLOBAL | CHANNEL_DBC_FLAG_CITY_ONLY))
+ zoneId = 0;
- wstrToLower(wname);
+ std::pair<uint32, uint32> key = std::make_pair(channelId, zoneId);
- ChannelMap::const_iterator i = channels.find(wname);
+ auto itr = _channels.find(key);
+ if (itr != _channels.end())
+ return itr->second;
- if (i == channels.end())
+ Channel* newChannel = new Channel(channelId, _team, zoneEntry);
+ _channels[key] = newChannel;
+ return newChannel;
+ }
+ else // custom
{
- if (pkt)
- {
- WorldPacket data;
- MakeNotOnPacket(&data, name);
- player->GetSession()->SendPacket(&data);
- }
+ std::wstring channelName;
+ if (!Utf8toWStr(name, channelName))
+ return nullptr;
+
+ wstrToLower(channelName);
+ auto itr = _customChannels.find(channelName);
+ if (itr != _customChannels.end())
+ return itr->second;
+
+ Channel* newChannel = new Channel(name, _team);
+ _customChannels[channelName] = newChannel;
+ return newChannel;
+ }
+}
- return nullptr;
+Channel* ChannelMgr::GetChannel(uint32 channelId, std::string const& name, Player* player, bool pkt /*= true*/, AreaTableEntry const* zoneEntry /*= nullptr*/) const
+{
+ Channel* ret = nullptr;
+ bool send = false;
+
+ if (channelId) // builtin
+ {
+ ChatChannelsEntry const* channelEntry = sChatChannelsStore.AssertEntry(channelId);
+ uint32 zoneId = zoneEntry ? zoneEntry->ID : 0;
+ if (channelEntry->flags & (CHANNEL_DBC_FLAG_GLOBAL | CHANNEL_DBC_FLAG_CITY_ONLY))
+ zoneId = 0;
+
+ std::pair<uint32, uint32> key = std::make_pair(channelId, zoneId);
+
+ auto itr = _channels.find(key);
+ if (itr != _channels.end())
+ ret = itr->second;
+ else
+ send = true;
}
+ else // custom
+ {
+ std::wstring channelName;
+ if (!Utf8toWStr(name, channelName))
+ return nullptr;
+
+ wstrToLower(channelName);
+ auto itr = _customChannels.find(channelName);
+ if (itr != _customChannels.end())
+ ret = itr->second;
+ else
+ send = true;
+ }
+
+ if (send && pkt)
+ {
+ std::string channelName = name;
+ Channel::GetChannelName(channelName, channelId, player->GetSession()->GetSessionDbcLocale(), zoneEntry);
- return i->second;
+ WorldPacket data;
+ ChannelMgr::MakeNotOnPacket(&data, channelName);
+ player->SendDirectMessage(&data);
+ }
+
+ return ret;
}
void ChannelMgr::LeftChannel(std::string const& name)
{
- std::wstring wname;
- if (!Utf8toWStr(name, wname))
+ std::wstring channelName;
+ if (!Utf8toWStr(name, channelName))
return;
- wstrToLower(wname);
+ wstrToLower(channelName);
+ auto itr = _customChannels.find(channelName);
+ if (itr == _customChannels.end())
+ return;
- ChannelMap::const_iterator i = channels.find(wname);
+ Channel* channel = itr->second;
+ if (!channel->GetNumPlayers())
+ {
+ _customChannels.erase(itr);
+ delete channel;
+ }
+}
- if (i == channels.end())
- return;
+void ChannelMgr::LeftChannel(uint32 channelId, AreaTableEntry const* zoneEntry)
+{
+ ChatChannelsEntry const* channelEntry = sChatChannelsStore.AssertEntry(channelId);
+ uint32 zoneId = zoneEntry ? zoneEntry->ID : 0;
+ if (channelEntry->flags & (CHANNEL_DBC_FLAG_GLOBAL | CHANNEL_DBC_FLAG_CITY_ONLY))
+ zoneId = 0;
+
+ std::pair<uint32, uint32> key = std::make_pair(channelId, zoneId);
- Channel* channel = i->second;
+ auto itr = _channels.find(key);
+ if (itr == _channels.end())
+ return;
- if (!channel->GetNumPlayers() && !channel->IsConstant())
+ Channel* channel = itr->second;
+ if (!channel->GetNumPlayers())
{
- channels.erase(wname);
+ _channels.erase(itr);
delete channel;
}
}
@@ -112,5 +196,5 @@ void ChannelMgr::LeftChannel(std::string const& name)
void ChannelMgr::MakeNotOnPacket(WorldPacket* data, std::string const& name)
{
data->Initialize(SMSG_CHANNEL_NOTIFY, 1 + name.size());
- (*data) << uint8(5) << name;
+ (*data) << uint8(CHAT_NOT_MEMBER_NOTICE) << name;
}
diff --git a/src/server/game/Chat/Channels/ChannelMgr.h b/src/server/game/Chat/Channels/ChannelMgr.h
index abe45690997..5f6fa55516a 100644
--- a/src/server/game/Chat/Channels/ChannelMgr.h
+++ b/src/server/game/Chat/Channels/ChannelMgr.h
@@ -19,36 +19,33 @@
#define __TRINITY_CHANNELMGR_H
#include "Common.h"
-#include "Channel.h"
-#include <map>
-#include <string>
-
-#include "World.h"
-
-#define MAX_CHANNEL_PASS_STR 31
+class Channel;
class TC_GAME_API ChannelMgr
{
- typedef std::map<std::wstring, Channel*> ChannelMap;
+ typedef std::unordered_map<std::wstring, Channel*> CustomChannelContainer; // custom channels only differ in name
+ typedef std::unordered_map<std::pair<uint32 /*channelId*/, uint32 /*zoneId*/>, Channel*> BuiltinChannelContainer; //identify builtin (DBC) channels by zoneId instead, since name changes by client locale
protected:
- ChannelMgr() : team(0) { }
+ explicit ChannelMgr(uint32 team) : _team(team) { }
~ChannelMgr();
public:
static ChannelMgr* forTeam(uint32 team);
- void setTeam(uint32 newTeam) { team = newTeam; }
+ static Channel* GetChannelForPlayerByNamePart(std::string const& namePart, Player* playerSearcher);
- Channel* GetJoinChannel(std::string const& name, uint32 channel_id);
- Channel* GetChannel(std::string const& name, Player* p, bool pkt = true);
+ Channel* GetJoinChannel(uint32 channelId, std::string const& name, AreaTableEntry const* zoneEntry = nullptr);
+ Channel* GetChannel(uint32 channelId, std::string const& name, Player* player, bool pkt = true, AreaTableEntry const* zoneEntry = nullptr) const;
void LeftChannel(std::string const& name);
+ void LeftChannel(uint32 channelId, AreaTableEntry const* zoneEntry);
private:
- ChannelMap channels;
- uint32 team;
+ CustomChannelContainer _customChannels;
+ BuiltinChannelContainer _channels;
+ uint32 const _team;
- void MakeNotOnPacket(WorldPacket* data, std::string const& name);
+ static void MakeNotOnPacket(WorldPacket* data, std::string const& name);
};
#endif
diff --git a/src/server/game/Combat/HostileRefManager.cpp b/src/server/game/Combat/HostileRefManager.cpp
index 397fd59b7d1..965b910c3f4 100644
--- a/src/server/game/Combat/HostileRefManager.cpp
+++ b/src/server/game/Combat/HostileRefManager.cpp
@@ -28,8 +28,8 @@ HostileRefManager::~HostileRefManager()
}
//=================================================
-// send threat to all my hateres for the victim
-// The victim is hated than by them as well
+// send threat to all my haters for the victim
+// The victim is then hated by them as well
// use for buffs and healing threat functionality
void HostileRefManager::threatAssist(Unit* victim, float baseThreat, SpellInfo const* threatSpell)
@@ -37,9 +37,10 @@ void HostileRefManager::threatAssist(Unit* victim, float baseThreat, SpellInfo c
if (getSize() == 0)
return;
- HostileReference* ref = getFirst();
float threat = ThreatCalcHelper::calcThreat(victim, iOwner, baseThreat, (threatSpell ? threatSpell->GetSchoolMask() : SPELL_SCHOOL_MASK_NORMAL), threatSpell);
threat /= getSize();
+
+ HostileReference* ref = getFirst();
while (ref)
{
if (ThreatCalcHelper::isValidProcess(victim, ref->GetSource()->GetOwner(), threatSpell))
@@ -54,7 +55,6 @@ void HostileRefManager::threatAssist(Unit* victim, float baseThreat, SpellInfo c
void HostileRefManager::addTempThreat(float threat, bool apply)
{
HostileReference* ref = getFirst();
-
while (ref)
{
if (apply)
diff --git a/src/server/game/Combat/HostileRefManager.h b/src/server/game/Combat/HostileRefManager.h
index 855f9e3d272..859bee3caf7 100644
--- a/src/server/game/Combat/HostileRefManager.h
+++ b/src/server/game/Combat/HostileRefManager.h
@@ -31,18 +31,16 @@ class SpellInfo;
class TC_GAME_API HostileRefManager : public RefManager<Unit, ThreatManager>
{
- private:
- Unit* iOwner;
public:
- explicit HostileRefManager(Unit* owner) { iOwner = owner; }
+ explicit HostileRefManager(Unit* owner) : iOwner(owner) { }
~HostileRefManager();
- Unit* GetOwner() { return iOwner; }
+ Unit* GetOwner() const { return iOwner; }
// send threat to all my hateres for the victim
// The victim is hated than by them as well
// use for buffs and healing threat functionality
- void threatAssist(Unit* victim, float baseThreat, SpellInfo const* threatSpell = NULL);
+ void threatAssist(Unit* victim, float baseThreat, SpellInfo const* threatSpell = nullptr);
void addTempThreat(float threat, bool apply);
@@ -68,6 +66,9 @@ class TC_GAME_API HostileRefManager : public RefManager<Unit, ThreatManager>
void deleteReference(Unit* creature);
void UpdateVisibility();
+
+ private:
+ Unit* iOwner;
};
//=================================================
#endif
diff --git a/src/server/game/Combat/ThreatManager.cpp b/src/server/game/Combat/ThreatManager.cpp
index e04e1485d64..fec4ec300cc 100644
--- a/src/server/game/Combat/ThreatManager.cpp
+++ b/src/server/game/Combat/ThreatManager.cpp
@@ -30,7 +30,7 @@
//==============================================================
// The hatingUnit is not used yet
-float ThreatCalcHelper::calcThreat(Unit* hatedUnit, Unit* /*hatingUnit*/, float threat, SpellSchoolMask schoolMask, SpellInfo const* threatSpell)
+float ThreatCalcHelper::calcThreat(Unit* hatedUnit, Unit* /*hatingUnit*/, float threat, SpellSchoolMask schoolMask, SpellInfo const* threatSpell /*= nullptr*/)
{
if (threatSpell)
{
@@ -39,7 +39,7 @@ float ThreatCalcHelper::calcThreat(Unit* hatedUnit, Unit* /*hatingUnit*/, float
threat *= threatEntry->pctMod;
// Energize is not affected by Mods
- for (uint8 i = 0; i < MAX_SPELL_EFFECTS; i++)
+ for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
if (threatSpell->Effects[i].Effect == SPELL_EFFECT_ENERGIZE || threatSpell->Effects[i].ApplyAuraName == SPELL_AURA_PERIODIC_ENERGIZE)
return threat;
@@ -50,7 +50,7 @@ float ThreatCalcHelper::calcThreat(Unit* hatedUnit, Unit* /*hatingUnit*/, float
return hatedUnit->ApplyTotalThreatModifier(threat, schoolMask);
}
-bool ThreatCalcHelper::isValidProcess(Unit* hatedUnit, Unit* hatingUnit, SpellInfo const* threatSpell)
+bool ThreatCalcHelper::isValidProcess(Unit* hatedUnit, Unit* hatingUnit, SpellInfo const* threatSpell /*= nullptr*/)
{
//function deals with adding threat and adding players and pets into ThreatList
//mobs, NPCs, guards have ThreatList and HateOfflineList
@@ -134,18 +134,20 @@ void HostileReference::fireStatusChanged(ThreatRefStatusChangeEvent& threatRefSt
void HostileReference::addThreat(float modThreat)
{
+ if (!modThreat)
+ return;
+
iThreat += modThreat;
+
// the threat is changed. Source and target unit have to be available
// if the link was cut before relink it again
if (!isOnline())
updateOnlineStatus();
- if (modThreat != 0.0f)
- {
- ThreatRefStatusChangeEvent event(UEV_THREAT_REF_THREAT_CHANGE, this, modThreat);
- fireStatusChanged(event);
- }
- if (isValid() && modThreat >= 0.0f)
+ ThreatRefStatusChangeEvent event(UEV_THREAT_REF_THREAT_CHANGE, this, modThreat);
+ fireStatusChanged(event);
+
+ if (isValid() && modThreat > 0.0f)
{
Unit* victimOwner = getTarget()->GetCharmerOrOwner();
if (victimOwner && victimOwner->IsAlive())
@@ -155,9 +157,7 @@ void HostileReference::addThreat(float modThreat)
void HostileReference::addThreatPercent(int32 percent)
{
- float tmpThreat = iThreat;
- AddPct(tmpThreat, percent);
- addThreat(tmpThreat - iThreat);
+ addThreat(CalculatePct(iThreat, percent));
}
//============================================================
@@ -193,6 +193,7 @@ void HostileReference::updateOnlineStatus()
else
accessible = true;
}
+
setAccessibleState(accessible);
setOnlineOfflineState(online);
}
@@ -221,7 +222,7 @@ void HostileReference::setAccessibleState(bool isAccessible)
{
iAccessible = isAccessible;
- ThreatRefStatusChangeEvent event(UEV_THREAT_REF_ASSECCIBLE_STATUS, this);
+ ThreatRefStatusChangeEvent event(UEV_THREAT_REF_ACCESSIBLE_STATUS, this);
fireStatusChanged(event);
}
}
diff --git a/src/server/game/Combat/ThreatManager.h b/src/server/game/Combat/ThreatManager.h
index a68d803304d..cad62659317 100644
--- a/src/server/game/Combat/ThreatManager.h
+++ b/src/server/game/Combat/ThreatManager.h
@@ -41,8 +41,8 @@ class SpellInfo;
struct TC_GAME_API ThreatCalcHelper
{
- static float calcThreat(Unit* hatedUnit, Unit* hatingUnit, float threat, SpellSchoolMask schoolMask = SPELL_SCHOOL_MASK_NORMAL, SpellInfo const* threatSpell = NULL);
- static bool isValidProcess(Unit* hatedUnit, Unit* hatingUnit, SpellInfo const* threatSpell = NULL);
+ static float calcThreat(Unit* hatedUnit, Unit* hatingUnit, float threat, SpellSchoolMask schoolMask = SPELL_SCHOOL_MASK_NORMAL, SpellInfo const* threatSpell = nullptr);
+ static bool isValidProcess(Unit* hatedUnit, Unit* hatingUnit, SpellInfo const* threatSpell = nullptr);
};
//==============================================================
@@ -54,11 +54,11 @@ class TC_GAME_API HostileReference : public Reference<Unit, ThreatManager>
//=================================================
void addThreat(float modThreat);
- void setThreat(float threat) { addThreat(threat - getThreat()); }
+ void setThreat(float threat) { addThreat(threat - iThreat); }
void addThreatPercent(int32 percent);
- float getThreat() const { return iThreat; }
+ float getThreat() const { return iThreat + iTempThreatModifier; }
bool isOnline() const { return iOnline; }
@@ -66,27 +66,27 @@ class TC_GAME_API HostileReference : public Reference<Unit, ThreatManager>
// in this case online = true, but accessible = false
bool isAccessible() const { return iAccessible; }
- // used for temporary setting a threat and reducting it later again.
+ // used for temporary setting a threat and reducing it later again.
// the threat modification is stored
void setTempThreat(float threat)
{
- addTempThreat(threat - getThreat());
+ addTempThreat(threat - iTempThreatModifier);
}
void addTempThreat(float threat)
{
- iTempThreatModifier = threat;
- if (iTempThreatModifier != 0.0f)
- addThreat(iTempThreatModifier);
+ if (!threat)
+ return;
+
+ iTempThreatModifier += threat;
+
+ ThreatRefStatusChangeEvent event(UEV_THREAT_REF_THREAT_CHANGE, this, threat);
+ fireStatusChanged(event);
}
void resetTempThreat()
{
- if (iTempThreatModifier != 0.0f)
- {
- addThreat(-iTempThreatModifier);
- iTempThreatModifier = 0.0f;
- }
+ addTempThreat(-iTempThreatModifier);
}
float getTempThreatModifier() { return iTempThreatModifier; }
@@ -100,7 +100,7 @@ class TC_GAME_API HostileReference : public Reference<Unit, ThreatManager>
void setAccessibleState(bool isAccessible);
//=================================================
- bool operator == (const HostileReference& hostileRef) const { return hostileRef.getUnitGuid() == getUnitGuid(); }
+ bool operator==(HostileReference const& hostileRef) const { return hostileRef.getUnitGuid() == getUnitGuid(); }
//=================================================
@@ -113,7 +113,7 @@ class TC_GAME_API HostileReference : public Reference<Unit, ThreatManager>
//=================================================
- HostileReference* next() { return ((HostileReference*) Reference<Unit, ThreatManager>::next()); }
+ HostileReference* next() { return static_cast<HostileReference*>(Reference<Unit, ThreatManager>::next()); }
//=================================================
@@ -125,14 +125,17 @@ class TC_GAME_API HostileReference : public Reference<Unit, ThreatManager>
// Tell our refFrom (source) object, that the link is cut (Target destroyed)
void sourceObjectDestroyLink() override;
+
private:
// Inform the source, that the status of that reference was changed
void fireStatusChanged(ThreatRefStatusChangeEvent& threatRefStatusChangeEvent);
Unit* GetSourceUnit();
+
private:
float iThreat;
- float iTempThreatModifier; // used for taunt
+ float iTempThreatModifier; // used for SPELL_AURA_MOD_TOTAL_THREAT
+
ObjectGuid iUnitGuid;
bool iOnline;
bool iAccessible;
diff --git a/src/server/game/Combat/UnitEvents.h b/src/server/game/Combat/UnitEvents.h
index f50edcf3c7d..ee1a960c524 100644
--- a/src/server/game/Combat/UnitEvents.h
+++ b/src/server/game/Combat/UnitEvents.h
@@ -40,7 +40,7 @@ enum UNIT_EVENT_TYPE
UEV_THREAT_REF_REMOVE_FROM_LIST = 1<<2,
// Player/Pet entered/left water or some other place where it is/was not accessible for the creature
- UEV_THREAT_REF_ASSECCIBLE_STATUS = 1<<3,
+ UEV_THREAT_REF_ACCESSIBLE_STATUS = 1<<3,
// Threat list is going to be sorted (if dirty flag is set)
UEV_THREAT_SORT_LIST = 1<<4,
@@ -58,7 +58,7 @@ enum UNIT_EVENT_TYPE
//UEV_UNIT_HEALTH_CHANGE = 1<<8,
};
-#define UEV_THREAT_REF_EVENT_MASK (UEV_THREAT_REF_ONLINE_STATUS | UEV_THREAT_REF_THREAT_CHANGE | UEV_THREAT_REF_REMOVE_FROM_LIST | UEV_THREAT_REF_ASSECCIBLE_STATUS)
+#define UEV_THREAT_REF_EVENT_MASK (UEV_THREAT_REF_ONLINE_STATUS | UEV_THREAT_REF_THREAT_CHANGE | UEV_THREAT_REF_REMOVE_FROM_LIST | UEV_THREAT_REF_ACCESSIBLE_STATUS)
#define UEV_THREAT_MANAGER_EVENT_MASK (UEV_THREAT_SORT_LIST | UEV_THREAT_SET_NEXT_TARGET | UEV_THREAT_VICTIM_CHANGED)
#define UEV_ALL_EVENT_MASK (0xffffffff)
@@ -69,14 +69,16 @@ enum UNIT_EVENT_TYPE
class UnitBaseEvent
{
- private:
- uint32 iType;
public:
- UnitBaseEvent(uint32 pType) { iType = pType; }
+ explicit UnitBaseEvent(uint32 pType) { iType = pType; }
uint32 getType() const { return iType; }
bool matchesTypeMask(uint32 pMask) const { return (iType & pMask) != 0; }
- void setType(uint32 pType) { iType = pType; }
+ private:
+ uint32 iType;
+
+ protected:
+ ~UnitBaseEvent() { }
};
//==============================================================
@@ -92,14 +94,15 @@ class TC_GAME_API ThreatRefStatusChangeEvent : public UnitBaseEvent
bool iBValue;
};
ThreatManager* iThreatManager;
+
public:
- ThreatRefStatusChangeEvent(uint32 pType) : UnitBaseEvent(pType), iThreatManager(NULL) { iHostileReference = NULL; }
+ explicit ThreatRefStatusChangeEvent(uint32 pType) : UnitBaseEvent(pType), iHostileReference(nullptr), iThreatManager(nullptr) { }
- ThreatRefStatusChangeEvent(uint32 pType, HostileReference* pHostileReference) : UnitBaseEvent(pType), iThreatManager(NULL) { iHostileReference = pHostileReference; }
+ ThreatRefStatusChangeEvent(uint32 pType, HostileReference* pHostileReference) : UnitBaseEvent(pType), iHostileReference(pHostileReference), iThreatManager(nullptr) { }
- ThreatRefStatusChangeEvent(uint32 pType, HostileReference* pHostileReference, float pValue) : UnitBaseEvent(pType), iThreatManager(NULL) { iHostileReference = pHostileReference; iFValue = pValue; }
+ ThreatRefStatusChangeEvent(uint32 pType, HostileReference* pHostileReference, float pValue) : UnitBaseEvent(pType), iHostileReference(pHostileReference), iFValue(pValue), iThreatManager(nullptr) { }
- ThreatRefStatusChangeEvent(uint32 pType, HostileReference* pHostileReference, bool pValue) : UnitBaseEvent(pType), iThreatManager(NULL) { iHostileReference = pHostileReference; iBValue = pValue; }
+ ThreatRefStatusChangeEvent(uint32 pType, HostileReference* pHostileReference, bool pValue) : UnitBaseEvent(pType), iHostileReference(pHostileReference), iBValue(pValue), iThreatManager(nullptr) { }
int32 getIValue() const { return iIValue; }
@@ -116,20 +119,4 @@ class TC_GAME_API ThreatRefStatusChangeEvent : public UnitBaseEvent
ThreatManager* getThreatManager() const { return iThreatManager; }
};
-//==============================================================
-
-class ThreatManagerEvent : public ThreatRefStatusChangeEvent
-{
- private:
- ThreatContainer* iThreatContainer;
- public:
- ThreatManagerEvent(uint32 pType) : ThreatRefStatusChangeEvent(pType), iThreatContainer(NULL) { }
- ThreatManagerEvent(uint32 pType, HostileReference* pHostileReference) : ThreatRefStatusChangeEvent(pType, pHostileReference), iThreatContainer(NULL) { }
-
- void setThreatContainer(ThreatContainer* pThreatContainer) { iThreatContainer = pThreatContainer; }
-
- ThreatContainer* getThreatContainer() const { return iThreatContainer; }
-};
-
-//==============================================================
#endif
diff --git a/src/server/game/Conditions/ConditionMgr.cpp b/src/server/game/Conditions/ConditionMgr.cpp
index c859031b573..7ee775ec676 100644
--- a/src/server/game/Conditions/ConditionMgr.cpp
+++ b/src/server/game/Conditions/ConditionMgr.cpp
@@ -1671,7 +1671,6 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond) const
break;
}
case CONDITION_SOURCE_TYPE_QUEST_ACCEPT:
- case CONDITION_SOURCE_TYPE_QUEST_SHOW_MARK:
if (!sObjectMgr->GetQuestTemplate(cond->SourceEntry))
{
TC_LOG_ERROR("sql.sql", "%s SourceEntry specifies non-existing quest, skipped.", cond->ToString().c_str());
diff --git a/src/server/game/Conditions/ConditionMgr.h b/src/server/game/Conditions/ConditionMgr.h
index 7bda1376a0d..4d32c3f36dc 100644
--- a/src/server/game/Conditions/ConditionMgr.h
+++ b/src/server/game/Conditions/ConditionMgr.h
@@ -130,7 +130,7 @@ enum ConditionSourceType
CONDITION_SOURCE_TYPE_SPELL = 17,
CONDITION_SOURCE_TYPE_SPELL_CLICK_EVENT = 18,
CONDITION_SOURCE_TYPE_QUEST_ACCEPT = 19,
- CONDITION_SOURCE_TYPE_QUEST_SHOW_MARK = 20,
+ // Condition source type 20 unused
CONDITION_SOURCE_TYPE_VEHICLE_SPELL = 21,
CONDITION_SOURCE_TYPE_SMART_EVENT = 22,
CONDITION_SOURCE_TYPE_NPC_VENDOR = 23,
diff --git a/src/server/game/DataStores/DBCEnums.h b/src/server/game/DataStores/DBCEnums.h
index cb2f26e567f..99d7b49f82f 100644
--- a/src/server/game/DataStores/DBCEnums.h
+++ b/src/server/game/DataStores/DBCEnums.h
@@ -312,6 +312,7 @@ enum SpawnMask
enum FactionTemplateFlags
{
+ FACTION_TEMPLATE_ENEMY_SPAR = 0x00000020, // guessed, sparring with enemies?
FACTION_TEMPLATE_FLAG_PVP = 0x00000800, // flagged for PvP
FACTION_TEMPLATE_FLAG_CONTESTED_GUARD = 0x00001000, // faction will attack players that were involved in PvP combats
FACTION_TEMPLATE_FLAG_HOSTILE_BY_DEFAULT= 0x00002000
diff --git a/src/server/game/DataStores/DBCStructure.h b/src/server/game/DataStores/DBCStructure.h
index c85344b9bd1..8431f369b69 100644
--- a/src/server/game/DataStores/DBCStructure.h
+++ b/src/server/game/DataStores/DBCStructure.h
@@ -192,6 +192,17 @@ struct AreaTableEntry
return true;
return (flags & AREA_FLAG_SANCTUARY) != 0;
}
+
+ bool IsFlyable() const
+ {
+ if (flags & AREA_FLAG_OUTLAND)
+ {
+ if (!(flags & AREA_FLAG_NO_FLY_ZONE))
+ return true;
+ }
+
+ return false;
+ }
};
#define MAX_GROUP_AREA_IDS 6
@@ -673,6 +684,7 @@ struct FactionTemplateEntry
return hostileMask == 0 && friendlyMask == 0;
}
bool IsContestedGuardFaction() const { return (factionFlags & FACTION_TEMPLATE_FLAG_CONTESTED_GUARD) != 0; }
+ bool ShouldSparAttack() const { return (factionFlags & FACTION_TEMPLATE_ENEMY_SPAR) != 0; }
};
struct GameObjectDisplayInfoEntry
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp
index fa603b9509e..9df9d2ad53c 100644
--- a/src/server/game/Entities/Creature/Creature.cpp
+++ b/src/server/game/Entities/Creature/Creature.cpp
@@ -1450,23 +1450,21 @@ void Creature::LoadEquipment(int8 id, bool force /*= true*/)
void Creature::SetSpawnHealth()
{
+ if (!m_creatureData)
+ return;
+
uint32 curhealth;
if (!m_regenHealth)
{
- if (m_creatureData)
+ curhealth = m_creatureData->curhealth;
+ if (curhealth)
{
- curhealth = m_creatureData->curhealth;
- if (curhealth)
- {
- curhealth = uint32(curhealth*_GetHealthMod(GetCreatureTemplate()->rank));
- if (curhealth < 1)
- curhealth = 1;
- }
- SetPower(POWER_MANA, m_creatureData->curmana);
+ curhealth = uint32(curhealth*_GetHealthMod(GetCreatureTemplate()->rank));
+ if (curhealth < 1)
+ curhealth = 1;
}
- else
- curhealth = GetHealth();
+ SetPower(POWER_MANA, m_creatureData->curmana);
}
else
{
@@ -1663,6 +1661,7 @@ void Creature::setDeathState(DeathState s)
SaveRespawnTime();
ReleaseFocus(nullptr, false); // remove spellcast focus
+ DoNotReacquireTarget(); // cancel delayed re-target
SetTarget(ObjectGuid::Empty); // drop target - dead mobs shouldn't ever target things
SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE);
@@ -1696,6 +1695,7 @@ void Creature::setDeathState(DeathState s)
SetLootRecipient(nullptr);
ResetPlayerDamageReq();
+ SetCannotReachTarget(false);
UpdateMovementFlags();
ClearUnitState(uint32(UNIT_STATE_ALL_STATE & ~UNIT_STATE_IGNORE_PATHFINDING));
@@ -1767,6 +1767,8 @@ void Creature::Respawn(bool force)
}
GetMotionMaster()->InitDefault();
+ //Re-initialize reactstate that could be altered by movementgenerators
+ InitializeReactState();
//Call AI respawn virtual function
if (IsAIEnabled)
@@ -1779,9 +1781,6 @@ void Creature::Respawn(bool force)
uint32 poolid = GetSpawnId() ? sPoolMgr->IsPartOfAPool<Creature>(GetSpawnId()) : 0;
if (poolid)
sPoolMgr->UpdatePool<Creature>(poolid, GetSpawnId());
-
- //Re-initialize reactstate that could be altered by movementgenerators
- InitializeReactState();
}
UpdateObjectVisibility();
diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h
index bb85fa9fc5b..d79e55b623e 100644
--- a/src/server/game/Entities/Creature/Creature.h
+++ b/src/server/game/Entities/Creature/Creature.h
@@ -339,7 +339,7 @@ struct VendorItem
uint32 ExtendedCost;
//helpers
- bool IsGoldRequired(ItemTemplate const* pProto) const { return pProto->Flags2 & ITEM_FLAGS_EXTRA_EXT_COST_REQUIRES_GOLD || !ExtendedCost; }
+ bool IsGoldRequired(ItemTemplate const* pProto) const { return (pProto->Flags2 & ITEM_FLAG2_DONT_IGNORE_BUY_PRICE) || !ExtendedCost; }
};
typedef std::vector<VendorItem*> VendorItemList;
@@ -691,6 +691,7 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma
// Handling caster facing during spellcast
void SetTarget(ObjectGuid guid) override;
void MustReacquireTarget() { m_shouldReacquireTarget = true; } // flags the Creature for forced (client displayed) target reacquisition in the next ::Update call
+ void DoNotReacquireTarget() { m_shouldReacquireTarget = false; m_suppressedTarget = ObjectGuid::Empty; m_suppressedOrientation = 0.0f; }
void FocusTarget(Spell const* focusSpell, WorldObject const* target);
bool IsFocusing(Spell const* focusSpell = nullptr, bool withDelay = false);
void ReleaseFocus(Spell const* focusSpell = nullptr, bool withDelay = true);
diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp
index 8c43d287c91..f1365ac3150 100644
--- a/src/server/game/Entities/GameObject/GameObject.cpp
+++ b/src/server/game/Entities/GameObject/GameObject.cpp
@@ -310,6 +310,18 @@ bool GameObject::Create(ObjectGuid::LowType guidlow, uint32 name_id, Map* map, u
if (map->Is25ManRaid())
loot.maxDuplicates = 3;
+ if (uint32 linkedEntry = GetGOInfo()->GetLinkedGameObjectEntry())
+ {
+ GameObject* linkedGO = new GameObject();
+ if (linkedGO->Create(map->GenerateLowGuid<HighGuid::GameObject>(), linkedEntry, map, phaseMask, pos, rotation, 255, GO_STATE_READY))
+ {
+ SetLinkedTrap(linkedGO);
+ map->AddToMap(linkedGO);
+ }
+ else
+ delete linkedGO;
+ }
+
return true;
}
@@ -428,6 +440,10 @@ void GameObject::Update(uint32 diff)
m_SkillupList.clear();
m_usetimes = 0;
+ // If nearby linked trap exists, respawn it
+ if (GameObject* linkedTrap = GetLinkedTrap())
+ linkedTrap->SetLootState(GO_READY);
+
switch (GetGoType())
{
case GAMEOBJECT_TYPE_FISHINGNODE: // can't fish now
@@ -511,11 +527,9 @@ void GameObject::Update(uint32 diff)
if (Unit* owner = GetOwner())
{
// Hunter trap: Search units which are unfriendly to the trap's owner
- Trinity::AnyUnfriendlyNoTotemUnitInObjectRangeCheck checker(this, owner, radius);
- Trinity::UnitSearcher<Trinity::AnyUnfriendlyNoTotemUnitInObjectRangeCheck> searcher(this, target, checker);
- VisitNearbyGridObject(radius, searcher);
- if (!target)
- VisitNearbyWorldObject(radius, searcher);
+ Trinity::NearestAttackableNoTotemUnitInObjectRangeCheck checker(this, owner, radius);
+ Trinity::UnitLastSearcher<Trinity::NearestAttackableNoTotemUnitInObjectRangeCheck> searcher(this, target, checker);
+ VisitNearbyObject(radius, searcher);
}
else
{
@@ -613,6 +627,10 @@ void GameObject::Update(uint32 diff)
}
case GO_JUST_DEACTIVATED:
{
+ // If nearby linked trap exists, despawn it
+ if (GameObject* linkedTrap = GetLinkedTrap())
+ linkedTrap->SetLootState(GO_JUST_DEACTIVATED);
+
//if Gameobject should cast spell, then this, but some GOs (type = 10) should be destroyed
if (GetGoType() == GAMEOBJECT_TYPE_GOOBER)
{
@@ -1092,25 +1110,8 @@ void GameObject::TriggeringLinkedGameObject(uint32 trapEntry, Unit* target)
if (!trapSpell) // checked at load already
return;
- float range = float(target->GetSpellMaxRangeForTarget(GetOwner(), trapSpell));
-
- // search nearest linked GO
- GameObject* trapGO = nullptr;
- {
- // using original GO distance
- CellCoord p(Trinity::ComputeCellCoord(GetPositionX(), GetPositionY()));
- Cell cell(p);
-
- Trinity::NearestGameObjectEntryInObjectRangeCheck go_check(*target, trapEntry, range);
- Trinity::GameObjectLastSearcher<Trinity::NearestGameObjectEntryInObjectRangeCheck> checker(this, trapGO, go_check);
-
- TypeContainerVisitor<Trinity::GameObjectLastSearcher<Trinity::NearestGameObjectEntryInObjectRangeCheck>, GridTypeMapContainer > object_checker(checker);
- cell.Visit(p, object_checker, *GetMap(), *target, range);
- }
-
- // found correct GO
- if (trapGO)
- trapGO->CastSpell(target, trapInfo->trap.spellId);
+ if (GameObject* trapGO = GetLinkedTrap())
+ trapGO->CastSpell(target, trapSpell->Id);
}
GameObject* GameObject::LookupFishingHoleAround(float range)
@@ -1828,18 +1829,23 @@ void GameObject::CastSpell(Unit* target, uint32 spellId, TriggerCastFlags trigge
if (!trigger)
return;
+ // remove immunity flags, to allow spell to target anything
+ trigger->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC | UNIT_FLAG_IMMUNE_TO_PC);
+
if (Unit* owner = GetOwner())
{
trigger->setFaction(owner->getFaction());
if (owner->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE))
trigger->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE);
+ // copy pvp state flags from owner
+ trigger->SetByteValue(UNIT_FIELD_BYTES_2, 1, owner->GetByteValue(UNIT_FIELD_BYTES_2, 1));
// needed for GO casts for proper target validation checks
trigger->SetOwnerGUID(owner->GetGUID());
trigger->CastSpell(target ? target : trigger, spellInfo, triggered, nullptr, nullptr, owner->GetGUID());
}
else
{
- trigger->setFaction(14);
+ trigger->setFaction(spellInfo->IsPositive() ? 35 : 14);
// Set owner guid for target if no owner available - needed by trigger auras
// - trigger gets despawned and there's no caster avalible (see AuraEffect::TriggerSpell())
trigger->CastSpell(target ? target : trigger, spellInfo, triggered, nullptr, nullptr, target ? target->GetGUID() : ObjectGuid::Empty);
@@ -2231,6 +2237,11 @@ bool GameObject::IsLootAllowedFor(Player const* player) const
return true;
}
+GameObject* GameObject::GetLinkedTrap()
+{
+ return ObjectAccessor::GetGameObject(*this, m_linkedTrap);
+}
+
void GameObject::BuildValuesUpdate(uint8 updateType, ByteBuffer* data, Player* target) const
{
if (!target)
diff --git a/src/server/game/Entities/GameObject/GameObject.h b/src/server/game/Entities/GameObject/GameObject.h
index 85b37abaf3c..dc7d99bb622 100644
--- a/src/server/game/Entities/GameObject/GameObject.h
+++ b/src/server/game/Entities/GameObject/GameObject.h
@@ -495,6 +495,7 @@ struct GameObjectTemplate
{
switch (type)
{
+ case GAMEOBJECT_TYPE_BUTTON: return button.linkedTrap;
case GAMEOBJECT_TYPE_CHEST: return chest.linkedTrapId;
case GAMEOBJECT_TYPE_SPELL_FOCUS: return spellFocus.linkedTrapId;
case GAMEOBJECT_TYPE_GOOBER: return goober.linkedTrapId;
@@ -818,6 +819,9 @@ class TC_GAME_API GameObject : public WorldObject, public GridObject<GameObject>
uint32 m_groupLootTimer; // (msecs)timer used for group loot
ObjectGuid::LowType lootingGroupLowGUID; // used to find group which is looting
+ GameObject* GetLinkedTrap();
+ void SetLinkedTrap(GameObject* linkedTrap) { m_linkedTrap = linkedTrap->GetGUID(); }
+
bool hasQuest(uint32 quest_id) const override;
bool hasInvolvedQuest(uint32 quest_id) const override;
bool ActivateToQuest(Player* target) const;
@@ -925,6 +929,9 @@ class TC_GAME_API GameObject : public WorldObject, public GridObject<GameObject>
ObjectGuid m_lootRecipient;
uint32 m_lootRecipientGroup;
uint16 m_LootMode; // bitmask, default LOOT_MODE_DEFAULT, determines what loot will be lootable
+
+ ObjectGuid m_linkedTrap;
+
private:
void RemoveFromOwner();
void SwitchDoorOrButton(bool activate, bool alternative = false);
diff --git a/src/server/game/Entities/Item/Item.cpp b/src/server/game/Entities/Item/Item.cpp
index a8dad0b2fbc..1173831be0b 100644
--- a/src/server/game/Entities/Item/Item.cpp
+++ b/src/server/game/Entities/Item/Item.cpp
@@ -256,11 +256,11 @@ Item::Item()
m_paidExtendedCost = 0;
}
-bool Item::Create(ObjectGuid::LowType guidlow, uint32 itemid, Player const* owner)
+bool Item::Create(ObjectGuid::LowType guidlow, uint32 itemId, Player const* owner)
{
Object::_Create(guidlow, 0, HighGuid::Item);
- SetEntry(itemid);
+ SetEntry(itemId);
SetObjectScale(1.0f);
if (owner)
@@ -269,7 +269,7 @@ bool Item::Create(ObjectGuid::LowType guidlow, uint32 itemid, Player const* owne
SetGuidValue(ITEM_FIELD_CONTAINED, owner->GetGUID());
}
- ItemTemplate const* itemProto = sObjectMgr->GetItemTemplate(itemid);
+ ItemTemplate const* itemProto = sObjectMgr->GetItemTemplate(itemId);
if (!itemProto)
return false;
@@ -357,7 +357,7 @@ void Item::SaveToDB(SQLTransaction& trans)
trans->Append(stmt);
- if ((uState == ITEM_CHANGED) && HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_WRAPPED))
+ if ((uState == ITEM_CHANGED) && HasFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_WRAPPED))
{
stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GIFT_OWNER);
stmt->setUInt32(0, GetOwnerGUID().GetCounter());
@@ -372,7 +372,7 @@ void Item::SaveToDB(SQLTransaction& trans)
stmt->setUInt32(0, guid);
trans->Append(stmt);
- if (HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_WRAPPED))
+ if (HasFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_WRAPPED))
{
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GIFT);
stmt->setUInt32(0, guid);
@@ -443,7 +443,7 @@ bool Item::LoadFromDB(ObjectGuid::LowType guid, ObjectGuid owner_guid, Field* fi
// Remove bind flag for items vs NO_BIND set
if (IsSoulBound() && proto->Bonding == NO_BIND)
{
- ApplyModFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_SOULBOUND, false);
+ ApplyModFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_SOULBOUND, false);
need_save = true;
}
@@ -746,7 +746,7 @@ bool Item::CanBeTraded(bool mail, bool trade) const
if (m_lootGenerated)
return false;
- if ((!mail || !IsBoundAccountWide()) && (IsSoulBound() && (!HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_BOP_TRADEABLE) || !trade)))
+ if ((!mail || !IsBoundAccountWide()) && (IsSoulBound() && (!HasFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_BOP_TRADEABLE) || !trade)))
return false;
if (IsBag() && (Player::IsBagPos(GetPos()) || !((Bag const*)this)->IsEmpty()))
@@ -824,13 +824,13 @@ bool Item::IsFitToSpellRequirements(SpellInfo const* spellInfo) const
{
ItemTemplate const* proto = GetTemplate();
+ bool const isEnchantSpell = spellInfo->HasEffect(SPELL_EFFECT_ENCHANT_ITEM) || spellInfo->HasEffect(SPELL_EFFECT_ENCHANT_ITEM_TEMPORARY) || spellInfo->HasEffect(SPELL_EFFECT_ENCHANT_ITEM_PRISMATIC);
if (spellInfo->EquippedItemClass != -1) // -1 == any item class
{
// Special case - accept vellum for armor/weapon requirements
- if ((spellInfo->EquippedItemClass == ITEM_CLASS_ARMOR && proto->IsArmorVellum())
- ||(spellInfo->EquippedItemClass == ITEM_CLASS_WEAPON && proto->IsWeaponVellum()))
- if (spellInfo->IsAbilityOfSkillType(SKILL_ENCHANTING)) // only for enchanting spells
- return true;
+ if (isEnchantSpell && ((spellInfo->EquippedItemClass == ITEM_CLASS_ARMOR && proto->IsArmorVellum())
+ || (spellInfo->EquippedItemClass == ITEM_CLASS_WEAPON && proto->IsWeaponVellum())))
+ return true;
if (spellInfo->EquippedItemClass != int32(proto->Class))
return false; // wrong item class
@@ -842,7 +842,7 @@ bool Item::IsFitToSpellRequirements(SpellInfo const* spellInfo) const
}
}
- if (spellInfo->EquippedItemInventoryTypeMask != 0) // 0 == any inventory type
+ if (isEnchantSpell && spellInfo->EquippedItemInventoryTypeMask != 0) // 0 == any inventory type
{
// Special case - accept weapon type for main and offhand requirements
if (proto->InventoryType == INVTYPE_WEAPON &&
@@ -1017,10 +1017,10 @@ void Item::SendTimeUpdate(Player* owner)
owner->GetSession()->SendPacket(&data);
}
-Item* Item::CreateItem(uint32 itemEntry, uint32 count, Player const* player)
+Item* Item::CreateItem(uint32 itemEntry, uint32 count, Player const* player /*= nullptr*/)
{
if (count < 1)
- return NULL; //don't create item at zero count
+ return nullptr; //don't create item at zero count
ItemTemplate const* proto = sObjectMgr->GetItemTemplate(itemEntry);
if (proto)
@@ -1041,18 +1041,18 @@ Item* Item::CreateItem(uint32 itemEntry, uint32 count, Player const* player)
}
else
ABORT();
- return NULL;
+ return nullptr;
}
-Item* Item::CloneItem(uint32 count, Player const* player) const
+Item* Item::CloneItem(uint32 count, Player const* player /*= nullptr*/) const
{
Item* newItem = CreateItem(GetEntry(), count, player);
if (!newItem)
- return NULL;
+ return nullptr;
newItem->SetGuidValue(ITEM_FIELD_CREATOR, GetGuidValue(ITEM_FIELD_CREATOR));
newItem->SetGuidValue(ITEM_FIELD_GIFTCREATOR, GetGuidValue(ITEM_FIELD_GIFTCREATOR));
- newItem->SetUInt32Value(ITEM_FIELD_FLAGS, GetUInt32Value(ITEM_FIELD_FLAGS) & ~(ITEM_FLAG_REFUNDABLE | ITEM_FLAG_BOP_TRADEABLE));
+ newItem->SetUInt32Value(ITEM_FIELD_FLAGS, GetUInt32Value(ITEM_FIELD_FLAGS) & ~(ITEM_FIELD_FLAG_REFUNDABLE | ITEM_FIELD_FLAG_BOP_TRADEABLE));
newItem->SetUInt32Value(ITEM_FIELD_DURATION, GetUInt32Value(ITEM_FIELD_DURATION));
// player CAN be NULL in which case we must not update random properties because that accesses player's item update queue
if (player)
@@ -1070,7 +1070,7 @@ bool Item::IsBindedNotWith(Player const* player) const
if (GetOwnerGUID() == player->GetGUID())
return false;
- if (HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_BOP_TRADEABLE))
+ if (HasFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_BOP_TRADEABLE))
if (allowedGUIDs.find(player->GetGUID().GetCounter()) != allowedGUIDs.end())
return false;
@@ -1131,10 +1131,10 @@ void Item::DeleteRefundDataFromDB(SQLTransaction* trans)
void Item::SetNotRefundable(Player* owner, bool changestate /*=true*/, SQLTransaction* trans /*=NULL*/)
{
- if (!HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_REFUNDABLE))
+ if (!HasFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_REFUNDABLE))
return;
- RemoveFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_REFUNDABLE);
+ RemoveFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_REFUNDABLE);
// Following is not applicable in the trading procedure
if (changestate)
SetState(ITEM_CHANGED, owner);
@@ -1189,13 +1189,13 @@ bool Item::IsRefundExpired()
void Item::SetSoulboundTradeable(AllowedLooterSet const& allowedLooters)
{
- SetFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_BOP_TRADEABLE);
+ SetFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_BOP_TRADEABLE);
allowedGUIDs = allowedLooters;
}
void Item::ClearSoulboundTradeable(Player* currentOwner)
{
- RemoveFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_BOP_TRADEABLE);
+ RemoveFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_BOP_TRADEABLE);
if (allowedGUIDs.empty())
return;
@@ -1346,7 +1346,7 @@ bool Item::ItemContainerLoadLootFromDB()
// If container item is in a bag, add that player as an allowed looter
if (GetBagSlot())
- loot_item.allowedGUIDs.insert(GetOwner()->GetGUID().GetCounter());
+ loot_item.AddAllowedLooter(GetOwner());
// Finally add the LootItem to the container
loot.items.push_back(loot_item);
diff --git a/src/server/game/Entities/Item/Item.h b/src/server/game/Entities/Item/Item.h
index 5e00a816cab..edc7001e1c4 100644
--- a/src/server/game/Entities/Item/Item.h
+++ b/src/server/game/Entities/Item/Item.h
@@ -206,12 +206,12 @@ bool ItemCanGoIntoBag(ItemTemplate const* proto, ItemTemplate const* pBagProto);
class TC_GAME_API Item : public Object
{
public:
- static Item* CreateItem(uint32 itemEntry, uint32 count, Player const* player = NULL);
- Item* CloneItem(uint32 count, Player const* player = NULL) const;
+ static Item* CreateItem(uint32 itemEntry, uint32 count, Player const* player = nullptr);
+ Item* CloneItem(uint32 count, Player const* player = nullptr) const;
Item();
- virtual bool Create(ObjectGuid::LowType guidlow, ObjectGuid::LowType itemid, Player const* owner);
+ virtual bool Create(ObjectGuid::LowType guidlow, uint32 itemId, Player const* owner);
ItemTemplate const* GetTemplate() const;
@@ -219,9 +219,9 @@ class TC_GAME_API Item : public Object
void SetOwnerGUID(ObjectGuid guid) { SetGuidValue(ITEM_FIELD_OWNER, guid); }
Player* GetOwner()const;
- void SetBinding(bool val) { ApplyModFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_SOULBOUND, val); }
- bool IsSoulBound() const { return HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_SOULBOUND); }
- bool IsBoundAccountWide() const { return (GetTemplate()->Flags & ITEM_PROTO_FLAG_BIND_TO_ACCOUNT) != 0; }
+ void SetBinding(bool val) { ApplyModFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_SOULBOUND, val); }
+ bool IsSoulBound() const { return HasFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_SOULBOUND); }
+ bool IsBoundAccountWide() const { return (GetTemplate()->Flags & ITEM_FLAG_IS_BOUND_TO_ACCOUNT) != 0; }
bool IsBindedNotWith(Player const* player) const;
bool IsBoundByEnchant() const;
virtual void SaveToDB(SQLTransaction& trans);
@@ -245,7 +245,7 @@ class TC_GAME_API Item : public Object
Bag* ToBag() { if (IsBag()) return reinterpret_cast<Bag*>(this); else return NULL; }
const Bag* ToBag() const { if (IsBag()) return reinterpret_cast<const Bag*>(this); else return NULL; }
- bool IsLocked() const { return !HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_UNLOCKED); }
+ bool IsLocked() const { return !HasFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_UNLOCKED); }
bool IsBag() const { return GetTemplate()->InventoryType == INVTYPE_BAG; }
bool IsCurrencyToken() const { return GetTemplate()->IsCurrencyToken(); }
bool IsNotEmptyBag() const;
diff --git a/src/server/game/Entities/Item/ItemTemplate.h b/src/server/game/Entities/Item/ItemTemplate.h
index 0ff3f00a08b..8cc408b47fb 100644
--- a/src/server/game/Entities/Item/ItemTemplate.h
+++ b/src/server/game/Entities/Item/ItemTemplate.h
@@ -103,88 +103,117 @@ enum ItemBondingType
#define MAX_BIND_TYPE 6
/* /// @todo: Requiring actual cases in which using (an) item isn't allowed while shapeshifted. Else, this flag would need an implementation.
- ITEM_PROTO_FLAG_USABLE_WHEN_SHAPESHIFTED = 0x00800000, // Item can be used in shapeshift forms */
-
-enum ItemProtoFlags
-{
- ITEM_PROTO_FLAG_NO_PICKUP = 0x00000001, // ?
- ITEM_PROTO_FLAG_CONJURED = 0x00000002, // Conjured item
- ITEM_PROTO_FLAG_HAS_LOOT = 0x00000004, // Item can be right clicked to open for loot
- ITEM_PROTO_FLAG_HEROIC = 0x00000008, // Makes green "Heroic" text appear on item
- ITEM_PROTO_FLAG_DEPRECATED = 0x00000010, // Cannot equip or use
- ITEM_PROTO_FLAG_INDESTRUCTIBLE = 0x00000020, // Item can not be destroyed, except by using spell (item can be reagent for spell)
- ITEM_PROTO_FLAG_PLAYER_CAST = 0x00000040, // Item's spells are castable by players
- ITEM_PROTO_FLAG_NO_EQUIP_COOLDOWN = 0x00000080, // No default 30 seconds cooldown when equipped
- ITEM_PROTO_FLAG_INT_BONUS_INSTEAD = 0x00000100, // ?
- ITEM_PROTO_FLAG_IS_WRAPPER = 0x00000200, // Item can wrap other items
- ITEM_PROTO_FLAG_USES_RESOURCES = 0x00000400, // ?
- ITEM_PROTO_FLAG_MULTI_DROP = 0x00000800, // Looting this item does not remove it from available loot
- ITEM_PROTO_FLAG_REFUNDABLE = 0x00001000, // Item can be returned to vendor for its original cost (extended cost)
- ITEM_PROTO_FLAG_PETITION = 0x00002000, // Item is guild or arena charter
- ITEM_PROTO_FLAG_UNK5 = 0x00004000, // Only readable items have this (but not all)
- ITEM_PROTO_FLAG_UNK6 = 0x00008000, // ?
- ITEM_PROTO_FLAG_UNK7 = 0x00010000, // ?
- ITEM_PROTO_FLAG_UNK8 = 0x00020000, // ?
- ITEM_PROTO_FLAG_PROSPECTABLE = 0x00040000, // Item can be prospected
- ITEM_PROTO_FLAG_UNIQUE_EQUIPPED = 0x00080000, // You can only equip one of these
- ITEM_PROTO_FLAG_UNK9 = 0x00100000, // ?
- ITEM_PROTO_FLAG_USEABLE_IN_ARENA = 0x00200000, // Item can be used during arena match
- ITEM_PROTO_FLAG_THROWABLE = 0x00400000, // Some Thrown weapons have it (and only Thrown) but not all
- ITEM_PROTO_FLAG_USABLE_WHEN_SHAPESHIFTED = 0x00800000, // Item can be used in shapeshift forms
- ITEM_PROTO_FLAG_UNK10 = 0x01000000, // ?
- ITEM_PROTO_FLAG_SMART_LOOT = 0x02000000, // Profession recipes: can only be looted if you meet requirements and don't already know it
- ITEM_PROTO_FLAG_NOT_USEABLE_IN_ARENA = 0x04000000, // Item cannot be used in arena
- ITEM_PROTO_FLAG_BIND_TO_ACCOUNT = 0x08000000, // Item binds to account and can be sent only to your own characters
- ITEM_PROTO_FLAG_TRIGGERED_CAST = 0x10000000, // Spell is cast with triggered flag
- ITEM_PROTO_FLAG_MILLABLE = 0x20000000, // Item can be milled
- ITEM_PROTO_FLAG_UNK11 = 0x40000000, // ?
- ITEM_PROTO_FLAG_UNK12 = 0x80000000 // ?
-};
-
-enum ItemFieldFlags
-{
- ITEM_FLAG_SOULBOUND = 0x00000001, // Item is soulbound and cannot be traded <<--
- ITEM_FLAG_UNK1 = 0x00000002, // ?
- ITEM_FLAG_UNLOCKED = 0x00000004, // Item had lock but can be opened now
- ITEM_FLAG_WRAPPED = 0x00000008, // Item is wrapped and contains another item
- ITEM_FLAG_UNK2 = 0x00000010, // ?
- ITEM_FLAG_UNK3 = 0x00000020, // ?
- ITEM_FLAG_UNK4 = 0x00000040, // ?
- ITEM_FLAG_UNK5 = 0x00000080, // ?
- ITEM_FLAG_BOP_TRADEABLE = 0x00000100, // Allows trading soulbound items
- ITEM_FLAG_READABLE = 0x00000200, // Opens text page when right clicked
- ITEM_FLAG_UNK6 = 0x00000400, // ?
- ITEM_FLAG_UNK7 = 0x00000800, // ?
- ITEM_FLAG_REFUNDABLE = 0x00001000, // Item can be returned to vendor for its original cost (extended cost)
- ITEM_FLAG_UNK8 = 0x00002000, // ?
- ITEM_FLAG_UNK9 = 0x00004000, // ?
- ITEM_FLAG_UNK10 = 0x00008000, // ?
- ITEM_FLAG_UNK11 = 0x00010000, // ?
- ITEM_FLAG_UNK12 = 0x00020000, // ?
- ITEM_FLAG_UNK13 = 0x00040000, // ?
- ITEM_FLAG_UNK14 = 0x00080000, // ?
- ITEM_FLAG_UNK15 = 0x00100000, // ?
- ITEM_FLAG_UNK16 = 0x00200000, // ?
- ITEM_FLAG_UNK17 = 0x00400000, // ?
- ITEM_FLAG_UNK18 = 0x00800000, // ?
- ITEM_FLAG_UNK19 = 0x01000000, // ?
- ITEM_FLAG_UNK20 = 0x02000000, // ?
- ITEM_FLAG_UNK21 = 0x04000000, // ?
- ITEM_FLAG_UNK22 = 0x08000000, // ?
- ITEM_FLAG_UNK23 = 0x10000000, // ?
- ITEM_FLAG_UNK24 = 0x20000000, // ?
- ITEM_FLAG_UNK25 = 0x40000000, // ?
- ITEM_FLAG_UNK26 = 0x80000000, // ?
-
- ITEM_FLAG_MAIL_TEXT_MASK = ITEM_FLAG_READABLE | ITEM_FLAG_UNK13 | ITEM_FLAG_UNK14
-};
-
-enum ItemFlagsExtra
-{
- ITEM_FLAGS_EXTRA_HORDE_ONLY = 0x00000001,
- ITEM_FLAGS_EXTRA_ALLIANCE_ONLY = 0x00000002,
- ITEM_FLAGS_EXTRA_EXT_COST_REQUIRES_GOLD = 0x00000004, // when item uses extended cost, gold is also required
- ITEM_FLAGS_EXTRA_NEED_ROLL_DISABLED = 0x00000100
+ ITEM_FLAG_USE_WHEN_SHAPESHIFTED = 0x00800000, // Item can be used in shapeshift forms */
+
+// ITEM_FIELD_FLAGS
+enum ItemFieldFlags : uint32
+{
+ ITEM_FIELD_FLAG_SOULBOUND = 0x00000001, // Item is soulbound and cannot be traded <<--
+ ITEM_FIELD_FLAG_UNK1 = 0x00000002, // ?
+ ITEM_FIELD_FLAG_UNLOCKED = 0x00000004, // Item had lock but can be opened now
+ ITEM_FIELD_FLAG_WRAPPED = 0x00000008, // Item is wrapped and contains another item
+ ITEM_FIELD_FLAG_UNK2 = 0x00000010, // ?
+ ITEM_FIELD_FLAG_UNK3 = 0x00000020, // ?
+ ITEM_FIELD_FLAG_UNK4 = 0x00000040, // ?
+ ITEM_FIELD_FLAG_UNK5 = 0x00000080, // ?
+ ITEM_FIELD_FLAG_BOP_TRADEABLE = 0x00000100, // Allows trading soulbound items
+ ITEM_FIELD_FLAG_READABLE = 0x00000200, // Opens text page when right clicked
+ ITEM_FIELD_FLAG_UNK6 = 0x00000400, // ?
+ ITEM_FIELD_FLAG_UNK7 = 0x00000800, // ?
+ ITEM_FIELD_FLAG_REFUNDABLE = 0x00001000, // Item can be returned to vendor for its original cost (extended cost)
+ ITEM_FIELD_FLAG_UNK8 = 0x00002000, // ?
+ ITEM_FIELD_FLAG_UNK9 = 0x00004000, // ?
+ ITEM_FIELD_FLAG_UNK10 = 0x00008000, // ?
+ ITEM_FIELD_FLAG_UNK11 = 0x00010000, // ?
+ ITEM_FIELD_FLAG_UNK12 = 0x00020000, // ?
+ ITEM_FIELD_FLAG_UNK13 = 0x00040000, // ?
+ ITEM_FIELD_FLAG_UNK14 = 0x00080000, // ?
+ ITEM_FIELD_FLAG_UNK15 = 0x00100000, // ?
+ ITEM_FIELD_FLAG_UNK16 = 0x00200000, // ?
+ ITEM_FIELD_FLAG_UNK17 = 0x00400000, // ?
+ ITEM_FIELD_FLAG_UNK18 = 0x00800000, // ?
+ ITEM_FIELD_FLAG_UNK19 = 0x01000000, // ?
+ ITEM_FIELD_FLAG_UNK20 = 0x02000000, // ?
+ ITEM_FIELD_FLAG_UNK21 = 0x04000000, // ?
+ ITEM_FIELD_FLAG_UNK22 = 0x08000000, // ?
+ ITEM_FIELD_FLAG_UNK23 = 0x10000000, // ?
+ ITEM_FIELD_FLAG_UNK24 = 0x20000000, // ?
+ ITEM_FIELD_FLAG_UNK25 = 0x40000000, // ?
+ ITEM_FIELD_FLAG_UNK26 = 0x80000000, // ?
+
+ ITEM_FLAG_MAIL_TEXT_MASK = ITEM_FIELD_FLAG_READABLE | ITEM_FIELD_FLAG_UNK13 | ITEM_FIELD_FLAG_UNK14
+};
+
+enum ItemFlags : uint32
+{
+ ITEM_FLAG_NO_PICKUP = 0x00000001,
+ ITEM_FLAG_CONJURED = 0x00000002, // Conjured item
+ ITEM_FLAG_HAS_LOOT = 0x00000004, // Item can be right clicked to open for loot
+ ITEM_FLAG_HEROIC_TOOLTIP = 0x00000008, // Makes green "Heroic" text appear on item
+ ITEM_FLAG_DEPRECATED = 0x00000010, // Cannot equip or use
+ ITEM_FLAG_NO_USER_DESTROY = 0x00000020, // Item can not be destroyed, except by using spell (item can be reagent for spell)
+ ITEM_FLAG_PLAYERCAST = 0x00000040, // Item's spells are castable by players
+ ITEM_FLAG_NO_EQUIP_COOLDOWN = 0x00000080, // No default 30 seconds cooldown when equipped
+ ITEM_FLAG_MULTI_LOOT_QUEST = 0x00000100,
+ ITEM_FLAG_IS_WRAPPER = 0x00000200, // Item can wrap other items
+ ITEM_FLAG_USES_RESOURCES = 0x00000400,
+ ITEM_FLAG_MULTI_DROP = 0x00000800, // Looting this item does not remove it from available loot
+ ITEM_FLAG_ITEM_PURCHASE_RECORD = 0x00001000, // Item can be returned to vendor for its original cost (extended cost)
+ ITEM_FLAG_PETITION = 0x00002000, // Item is guild or arena charter
+ ITEM_FLAG_HAS_TEXT = 0x00004000, // Only readable items have this (but not all)
+ ITEM_FLAG_NO_DISENCHANT = 0x00008000,
+ ITEM_FLAG_REAL_DURATION = 0x00010000,
+ ITEM_FLAG_NO_CREATOR = 0x00020000,
+ ITEM_FLAG_IS_PROSPECTABLE = 0x00040000, // Item can be prospected
+ ITEM_FLAG_UNIQUE_EQUIPPABLE = 0x00080000, // You can only equip one of these
+ ITEM_FLAG_IGNORE_FOR_AURAS = 0x00100000,
+ ITEM_FLAG_IGNORE_DEFAULT_ARENA_RESTRICTIONS = 0x00200000, // Item can be used during arena match
+ ITEM_FLAG_NO_DURABILITY_LOSS = 0x00400000, // Some Thrown weapons have it (and only Thrown) but not all
+ ITEM_FLAG_USE_WHEN_SHAPESHIFTED = 0x00800000, // Item can be used in shapeshift forms
+ ITEM_FLAG_HAS_QUEST_GLOW = 0x01000000,
+ ITEM_FLAG_HIDE_UNUSABLE_RECIPE = 0x02000000, // Profession recipes: can only be looted if you meet requirements and don't already know it
+ ITEM_FLAG_NOT_USEABLE_IN_ARENA = 0x04000000, // Item cannot be used in arena
+ ITEM_FLAG_IS_BOUND_TO_ACCOUNT = 0x08000000, // Item binds to account and can be sent only to your own characters
+ ITEM_FLAG_NO_REAGENT_COST = 0x10000000, // Spell is cast ignoring reagents
+ ITEM_FLAG_IS_MILLABLE = 0x20000000, // Item can be milled
+ ITEM_FLAG_REPORT_TO_GUILD_CHAT = 0x40000000,
+ ITEM_FLAG_NO_PROGRESSIVE_LOOT = 0x80000000
+};
+
+enum ItemFlags2 : uint32
+{
+ ITEM_FLAG2_FACTION_HORDE = 0x00000001,
+ ITEM_FLAG2_FACTION_ALLIANCE = 0x00000002,
+ ITEM_FLAG2_DONT_IGNORE_BUY_PRICE = 0x00000004, // when item uses extended cost, gold is also required
+ ITEM_FLAG2_CLASSIFY_AS_CASTER = 0x00000008,
+ ITEM_FLAG2_CLASSIFY_AS_PHYSICAL = 0x00000010,
+ ITEM_FLAG2_EVERYONE_CAN_ROLL_NEED = 0x00000020,
+ ITEM_FLAG2_NO_TRADE_BIND_ON_ACQUIRE = 0x00000040,
+ ITEM_FLAG2_CAN_TRADE_BIND_ON_ACQUIRE = 0x00000080,
+ ITEM_FLAG2_CAN_ONLY_ROLL_GREED = 0x00000100,
+ ITEM_FLAG2_CASTER_WEAPON = 0x00000200,
+ ITEM_FLAG2_DELETE_ON_LOGIN = 0x00000400,
+ ITEM_FLAG2_INTERNAL_ITEM = 0x00000800,
+ ITEM_FLAG2_NO_VENDOR_VALUE = 0x00001000,
+ ITEM_FLAG2_SHOW_BEFORE_DISCOVERED = 0x00002000,
+ ITEM_FLAG2_OVERRIDE_GOLD_COST = 0x00004000,
+ ITEM_FLAG2_IGNORE_DEFAULT_RATED_BG_RESTRICTIONS = 0x00008000,
+ ITEM_FLAG2_NOT_USABLE_IN_RATED_BG = 0x00010000,
+ ITEM_FLAG2_BNET_ACCOUNT_TRADE_OK = 0x00020000,
+ ITEM_FLAG2_CONFIRM_BEFORE_USE = 0x00040000,
+ ITEM_FLAG2_REEVALUATE_BONDING_ON_TRANSFORM = 0x00080000,
+ ITEM_FLAG2_NO_TRANSFORM_ON_CHARGE_DEPLETION = 0x00100000,
+ ITEM_FLAG2_NO_ALTER_ITEM_VISUAL = 0x00200000,
+ ITEM_FLAG2_NO_SOURCE_FOR_ITEM_VISUAL = 0x00400000,
+ ITEM_FLAG2_IGNORE_QUALITY_FOR_ITEM_VISUAL_SOURCE = 0x00800000,
+ ITEM_FLAG2_NO_DURABILITY = 0x01000000,
+ ITEM_FLAG2_ROLE_TANK = 0x02000000,
+ ITEM_FLAG2_ROLE_HEALER = 0x04000000,
+ ITEM_FLAG2_ROLE_DAMAGE = 0x08000000,
+ ITEM_FLAG2_CAN_DROP_IN_CHALLENGE_MODE = 0x10000000,
+ ITEM_FLAG2_NEVER_STACK_IN_LOOT_UI = 0x20000000,
+ ITEM_FLAG2_DISENCHANT_TO_LOOT_TABLE = 0x40000000,
+ ITEM_FLAG2_USED_IN_A_TRADESKILL = 0x80000000
};
enum ItemFlagsCustom
@@ -674,7 +703,7 @@ struct ItemTemplate
bool IsPotion() const { return Class == ITEM_CLASS_CONSUMABLE && SubClass == ITEM_SUBCLASS_POTION; }
bool IsWeaponVellum() const { return Class == ITEM_CLASS_TRADE_GOODS && SubClass == ITEM_SUBCLASS_WEAPON_ENCHANTMENT; }
bool IsArmorVellum() const { return Class == ITEM_CLASS_TRADE_GOODS && SubClass == ITEM_SUBCLASS_ARMOR_ENCHANTMENT; }
- bool IsConjuredConsumable() const { return Class == ITEM_CLASS_CONSUMABLE && (Flags & ITEM_PROTO_FLAG_CONJURED); }
+ bool IsConjuredConsumable() const { return Class == ITEM_CLASS_CONSUMABLE && (Flags & ITEM_FLAG_CONJURED); }
};
// Benchmarked: Faster than std::map (insert/find)
diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp
index aea923f6eac..a5f5aa18b1d 100644
--- a/src/server/game/Entities/Object/Object.cpp
+++ b/src/server/game/Entities/Object/Object.cpp
@@ -173,7 +173,7 @@ void Object::BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) c
if (flags & UPDATEFLAG_STATIONARY_POSITION)
{
// UPDATETYPE_CREATE_OBJECT2 dynamic objects, corpses...
- if (isType(TYPEMASK_DYNAMICOBJECT) || isType(TYPEMASK_CORPSE) || isType(TYPEMASK_PLAYER))
+ if (isType(TYPEMASK_DYNAMICOBJECT | TYPEMASK_CORPSE | TYPEMASK_PLAYER))
updateType = UPDATETYPE_CREATE_OBJECT2;
// UPDATETYPE_CREATE_OBJECT2 for pets...
@@ -2116,114 +2116,42 @@ GameObject* WorldObject::FindNearestGameObjectOfType(GameobjectTypes type, float
return go;
}
-void WorldObject::GetGameObjectListWithEntryInGrid(std::list<GameObject*>& gameobjectList, uint32 entry, float maxSearchRange) const
+template <typename Container>
+void WorldObject::GetGameObjectListWithEntryInGrid(Container& gameObjectContainer, uint32 entry, float maxSearchRange /*= 250.0f*/) const
{
- CellCoord pair(Trinity::ComputeCellCoord(this->GetPositionX(), this->GetPositionY()));
+ CellCoord pair(Trinity::ComputeCellCoord(GetPositionX(), GetPositionY()));
Cell cell(pair);
cell.SetNoCreate();
Trinity::AllGameObjectsWithEntryInRange check(this, entry, maxSearchRange);
- Trinity::GameObjectListSearcher<Trinity::AllGameObjectsWithEntryInRange> searcher(this, gameobjectList, check);
+ Trinity::GameObjectListSearcher<Trinity::AllGameObjectsWithEntryInRange> searcher(this, gameObjectContainer, check);
TypeContainerVisitor<Trinity::GameObjectListSearcher<Trinity::AllGameObjectsWithEntryInRange>, GridTypeMapContainer> visitor(searcher);
- cell.Visit(pair, visitor, *(this->GetMap()), *this, maxSearchRange);
+ cell.Visit(pair, visitor, *GetMap(), *this, maxSearchRange);
}
-void WorldObject::GetCreatureListWithEntryInGrid(std::list<Creature*>& creatureList, uint32 entry, float maxSearchRange) const
+template <typename Container>
+void WorldObject::GetCreatureListWithEntryInGrid(Container& creatureContainer, uint32 entry, float maxSearchRange /*= 250.0f*/) const
{
- CellCoord pair(Trinity::ComputeCellCoord(this->GetPositionX(), this->GetPositionY()));
+ CellCoord pair(Trinity::ComputeCellCoord(GetPositionX(), GetPositionY()));
Cell cell(pair);
cell.SetNoCreate();
Trinity::AllCreaturesOfEntryInRange check(this, entry, maxSearchRange);
- Trinity::CreatureListSearcher<Trinity::AllCreaturesOfEntryInRange> searcher(this, creatureList, check);
+ Trinity::CreatureListSearcher<Trinity::AllCreaturesOfEntryInRange> searcher(this, creatureContainer, check);
TypeContainerVisitor<Trinity::CreatureListSearcher<Trinity::AllCreaturesOfEntryInRange>, GridTypeMapContainer> visitor(searcher);
- cell.Visit(pair, visitor, *(this->GetMap()), *this, maxSearchRange);
+ cell.Visit(pair, visitor, *GetMap(), *this, maxSearchRange);
}
-void WorldObject::GetPlayerListInGrid(std::list<Player*>& playerList, float maxSearchRange) const
+template <typename Container>
+void WorldObject::GetPlayerListInGrid(Container& playerContainer, float maxSearchRange) const
{
Trinity::AnyPlayerInObjectRangeCheck checker(this, maxSearchRange);
- Trinity::PlayerListSearcher<Trinity::AnyPlayerInObjectRangeCheck> searcher(this, playerList, checker);
- this->VisitNearbyWorldObject(maxSearchRange, searcher);
+ Trinity::PlayerListSearcher<Trinity::AnyPlayerInObjectRangeCheck> searcher(this, playerContainer, checker);
+ VisitNearbyWorldObject(maxSearchRange, searcher);
}
-/*
-namespace Trinity
-{
- class NearUsedPosDo
- {
- public:
- NearUsedPosDo(WorldObject const& obj, WorldObject const* searcher, float angle, ObjectPosSelector& selector)
- : i_object(obj), i_searcher(searcher), i_angle(angle), i_selector(selector) { }
-
- void operator()(Corpse*) const { }
- void operator()(DynamicObject*) const { }
-
- void operator()(Creature* c) const
- {
- // skip self or target
- if (c == i_searcher || c == &i_object)
- return;
-
- float x, y, z;
-
- if (!c->IsAlive() || c->HasUnitState(UNIT_STATE_ROOT | UNIT_STATE_STUNNED | UNIT_STATE_DISTRACTED) ||
- !c->GetMotionMaster()->GetDestination(x, y, z))
- {
- x = c->GetPositionX();
- y = c->GetPositionY();
- }
-
- add(c, x, y);
- }
-
- template<class T>
- void operator()(T* u) const
- {
- // skip self or target
- if (u == i_searcher || u == &i_object)
- return;
-
- float x, y;
-
- x = u->GetPositionX();
- y = u->GetPositionY();
-
- add(u, x, y);
- }
-
- // we must add used pos that can fill places around center
- void add(WorldObject* u, float x, float y) const
- {
- // u is too nearest/far away to i_object
- if (!i_object.IsInRange2d(x, y, i_selector.m_dist - i_selector.m_size, i_selector.m_dist + i_selector.m_size))
- return;
-
- float angle = i_object.GetAngle(u)-i_angle;
-
- // move angle to range -pi ... +pi
- while (angle > M_PI)
- angle -= 2.0f * M_PI;
- while (angle < -M_PI)
- angle += 2.0f * M_PI;
-
- // dist include size of u
- float dist2d = i_object.GetDistance2d(x, y);
- i_selector.AddUsedPos(u->GetObjectSize(), angle, dist2d + i_object.GetObjectSize());
- }
- private:
- WorldObject const& i_object;
- WorldObject const* i_searcher;
- float i_angle;
- ObjectPosSelector& i_selector;
- };
-} // namespace Trinity
-*/
-
-//===================================================================================================
-
void WorldObject::GetNearPoint2D(float &x, float &y, float distance2d, float absAngle) const
{
x = GetPositionX() + (GetObjectSize() + distance2d) * std::cos(absAngle);
@@ -2623,3 +2551,15 @@ ObjectGuid WorldObject::GetTransGUID() const
return GetTransport()->GetGUID();
return ObjectGuid::Empty;
}
+
+template TC_GAME_API void WorldObject::GetGameObjectListWithEntryInGrid(std::list<GameObject*>&, uint32, float) const;
+template TC_GAME_API void WorldObject::GetGameObjectListWithEntryInGrid(std::deque<GameObject*>&, uint32, float) const;
+template TC_GAME_API void WorldObject::GetGameObjectListWithEntryInGrid(std::vector<GameObject*>&, uint32, float) const;
+
+template TC_GAME_API void WorldObject::GetCreatureListWithEntryInGrid(std::list<Creature*>&, uint32, float) const;
+template TC_GAME_API void WorldObject::GetCreatureListWithEntryInGrid(std::deque<Creature*>&, uint32, float) const;
+template TC_GAME_API void WorldObject::GetCreatureListWithEntryInGrid(std::vector<Creature*>&, uint32, float) const;
+
+template TC_GAME_API void WorldObject::GetPlayerListInGrid(std::list<Player*>&, float) const;
+template TC_GAME_API void WorldObject::GetPlayerListInGrid(std::deque<Player*>&, float) const;
+template TC_GAME_API void WorldObject::GetPlayerListInGrid(std::vector<Player*>&, float) const;
diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h
index 2fdb9433356..e107a5f6bfd 100644
--- a/src/server/game/Entities/Object/Object.h
+++ b/src/server/game/Entities/Object/Object.h
@@ -558,9 +558,14 @@ class TC_GAME_API WorldObject : public Object, public WorldLocation
GameObject* FindNearestGameObject(uint32 entry, float range) const;
GameObject* FindNearestGameObjectOfType(GameobjectTypes type, float range) const;
- void GetGameObjectListWithEntryInGrid(std::list<GameObject*>& lList, uint32 uiEntry = 0, float fMaxSearchRange = 250.0f) const;
- void GetCreatureListWithEntryInGrid(std::list<Creature*>& lList, uint32 uiEntry = 0, float fMaxSearchRange = 250.0f) const;
- void GetPlayerListInGrid(std::list<Player*>& lList, float fMaxSearchRange) const;
+ template <typename Container>
+ void GetGameObjectListWithEntryInGrid(Container& gameObjectContainer, uint32 entry, float maxSearchRange = 250.0f) const;
+
+ template <typename Container>
+ void GetCreatureListWithEntryInGrid(Container& creatureContainer, uint32 entry, float maxSearchRange = 250.0f) const;
+
+ template <typename Container>
+ void GetPlayerListInGrid(Container& playerContainer, float maxSearchRange) const;
void DestroyForNearbyPlayers();
virtual void UpdateObjectVisibility(bool forced = true);
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index dff6f8c0478..3e0f9078c2c 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -939,12 +939,21 @@ uint32 Player::EnvironmentalDamage(EnviromentalDamage type, uint32 damage)
// Absorb, resist some environmental damage type
uint32 absorb = 0;
uint32 resist = 0;
- if (type == DAMAGE_LAVA)
- CalcAbsorbResist(this, SPELL_SCHOOL_MASK_FIRE, DIRECT_DAMAGE, damage, &absorb, &resist);
- else if (type == DAMAGE_SLIME)
- CalcAbsorbResist(this, SPELL_SCHOOL_MASK_NATURE, DIRECT_DAMAGE, damage, &absorb, &resist);
-
- damage -= absorb + resist;
+ switch (type)
+ {
+ case DAMAGE_LAVA:
+ case DAMAGE_SLIME:
+ {
+ DamageInfo dmgInfo(this, this, damage, nullptr, type == DAMAGE_LAVA ? SPELL_SCHOOL_MASK_FIRE : SPELL_SCHOOL_MASK_NATURE, DIRECT_DAMAGE, BASE_ATTACK);
+ CalcAbsorbResist(dmgInfo);
+ absorb = dmgInfo.GetAbsorb();
+ resist = dmgInfo.GetResist();
+ damage = dmgInfo.GetDamage();
+ break;
+ }
+ default:
+ break;
+ }
DealDamageMods(this, damage, &absorb);
@@ -3314,7 +3323,7 @@ bool Player::AddSpell(uint32 spellId, bool active, bool learning, bool dependent
if (active)
{
if (spellInfo->IsPassive() && IsNeedCastPassiveSpellAtLearn(spellInfo))
- CastSpell (this, spellId, true);
+ CastSpell(this, spellId, true);
}
else if (IsInWorld())
{
@@ -3588,6 +3597,15 @@ bool Player::IsNeedCastPassiveSpellAtLearn(SpellInfo const* spellInfo) const
bool need_cast = (!spellInfo->Stances || (form && (spellInfo->Stances & (UI64LIT(1) << (form - 1)))) ||
(!form && spellInfo->HasAttribute(SPELL_ATTR2_NOT_NEED_SHAPESHIFT)));
+ // Check EquippedItemClass
+ // passive spells which apply aura and have an item requirement are to be added in Player::ApplyItemDependentAuras
+ if (spellInfo->IsPassive() && spellInfo->EquippedItemClass >= 0)
+ {
+ for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
+ if (spellInfo->Effects[i].IsAura())
+ return false;
+ }
+
//Check CasterAuraStates
return need_cast && (!spellInfo->CasterAuraState || HasAuraState(AuraStateType(spellInfo->CasterAuraState)));
}
@@ -4216,9 +4234,10 @@ void Player::DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRe
charDelete_method = CHAR_DELETE_REMOVE;
}
+ SQLTransaction trans = CharacterDatabase.BeginTransaction();
if (ObjectGuid::LowType guildId = GetGuildIdFromDB(playerguid))
if (Guild* guild = sGuildMgr->GetGuildById(guildId))
- guild->DeleteMember(playerguid, false, false, true);
+ guild->DeleteMember(trans, playerguid, false, false, true);
// close player ticket if any
GmTicket* ticket = sTicketMgr->GetTicketByPlayer(playerguid);
@@ -4245,8 +4264,6 @@ void Player::DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRe
// Completely remove from the database
case CHAR_DELETE_REMOVE:
{
- SQLTransaction trans = CharacterDatabase.BeginTransaction();
-
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_COD_ITEM_MAIL);
stmt->setUInt32(0, guid);
PreparedQueryResult resultMail = CharacterDatabase.Query(stmt);
@@ -4535,26 +4552,27 @@ void Player::DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRe
trans->Append(stmt);
Corpse::DeleteFromDB(playerguid, trans);
-
- CharacterDatabase.CommitTransaction(trans);
break;
}
// The character gets unlinked from the account, the name gets freed up and appears as deleted ingame
case CHAR_DELETE_UNLINK:
{
stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_DELETE_INFO);
-
stmt->setUInt32(0, guid);
-
- CharacterDatabase.Execute(stmt);
+ trans->Append(stmt);
break;
}
default:
TC_LOG_ERROR("entities.player.cheat", "Player::DeleteFromDB: Tried to delete player (%s) with unsupported delete method (%u).",
playerguid.ToString().c_str(), charDelete_method);
+
+ if (trans->GetSize() > 0)
+ CharacterDatabase.CommitTransaction(trans);
return;
}
+ CharacterDatabase.CommitTransaction(trans);
+
if (updateRealmChars)
sWorld->UpdateRealmCharCount(accountId);
@@ -5172,8 +5190,15 @@ void Player::CleanupChannels()
Channel* ch = *m_channels.begin();
m_channels.erase(m_channels.begin()); // remove from player's channel list
ch->LeaveChannel(this, false); // not send to client, not remove from player's channel list
+
+ // delete channel if empty
if (ChannelMgr* cMgr = ChannelMgr::forTeam(GetTeam()))
- cMgr->LeftChannel(ch->GetName()); // deleted channel if empty
+ {
+ if (ch->IsConstant())
+ cMgr->LeftChannel(ch->GetChannelId(), ch->GetZoneEntry());
+ else
+ cMgr->LeftChannel(ch->GetName());
+ }
}
TC_LOG_DEBUG("chat.system", "Player::CleanupChannels: Channels of player '%s' (%s) cleaned up.", GetName().c_str(), GetGUID().ToString().c_str());
}
@@ -5191,7 +5216,6 @@ void Player::UpdateLocalChannels(uint32 newZone)
if (!cMgr)
return;
- std::string current_zone_name = current_zone->area_name[GetSession()->GetSessionDbcLocale()];
for (uint32 i = 0; i < sChatChannelsStore.GetNumRows(); ++i)
{
ChatChannelsEntry const* channelEntry = sChatChannelsStore.LookupEntry(i);
@@ -5219,14 +5243,7 @@ void Player::UpdateLocalChannels(uint32 newZone)
if (channelEntry->flags & CHANNEL_DBC_FLAG_CITY_ONLY && usedChannel)
continue; // Already on the channel, as city channel names are not changing
- std::string currentNameExt;
- if (channelEntry->flags & CHANNEL_DBC_FLAG_CITY_ONLY)
- currentNameExt = sObjectMgr->GetTrinityStringForDBCLocale(LANG_CHANNEL_CITY);
- else
- currentNameExt = current_zone_name;
-
- std::string newChannelName = Trinity::StringFormat(channelEntry->pattern[m_session->GetSessionDbcLocale()], currentNameExt.c_str());
- joinChannel = cMgr->GetJoinChannel(newChannelName, channelEntry->ChannelID);
+ joinChannel = cMgr->GetJoinChannel(channelEntry->ChannelID, std::string(), current_zone);
if (usedChannel)
{
if (joinChannel != usedChannel)
@@ -5239,7 +5256,7 @@ void Player::UpdateLocalChannels(uint32 newZone)
}
}
else
- joinChannel = cMgr->GetJoinChannel(channelEntry->pattern[m_session->GetSessionDbcLocale()], channelEntry->ChannelID);
+ joinChannel = cMgr->GetJoinChannel(channelEntry->ChannelID, std::string());
}
else
removeChannel = usedChannel;
@@ -5249,10 +5266,10 @@ void Player::UpdateLocalChannels(uint32 newZone)
if (removeChannel)
{
- removeChannel->LeaveChannel(this, sendRemove); // Leave old channel
- std::string name = removeChannel->GetName(); // Store name, (*i)erase in LeftChannel
- LeftChannel(removeChannel); // Remove from player's channel list
- cMgr->LeftChannel(name); // Delete if empty
+ removeChannel->LeaveChannel(this, sendRemove); // Leave old channel
+
+ LeftChannel(removeChannel); // Remove from player's channel list
+ cMgr->LeftChannel(removeChannel->GetChannelId(), removeChannel->GetZoneEntry()); // Delete if empty
}
}
}
@@ -7378,20 +7395,16 @@ void Player::_ApplyItemMods(Item* item, uint8 slot, bool apply)
TC_LOG_DEBUG("entities.player.items", "Player::_ApplyItemMods: Applying mods for item %s", item->GetGUID().ToString().c_str());
- uint8 attacktype = Player::GetAttackBySlot(slot);
-
if (proto->Socket[0].Color) //only (un)equipping of items with sockets can influence metagems, so no need to waste time with normal items
CorrectMetaGemEnchants(slot, apply);
- if (attacktype < MAX_ATTACK)
- _ApplyWeaponDependentAuraMods(item, WeaponAttackType(attacktype), apply);
-
_ApplyItemBonuses(proto, slot, apply);
if (slot == EQUIPMENT_SLOT_RANGED)
_ApplyAmmoBonuses();
ApplyItemEquipSpell(item, apply);
+ ApplyItemDependentAuras(item, apply);
ApplyEnchantment(item, apply);
TC_LOG_DEBUG("entities.player.items", "Player::_ApplyItemMods: completed");
@@ -7745,86 +7758,26 @@ void Player::_ApplyWeaponDamage(uint8 slot, ItemTemplate const* proto, ScalingSt
UpdateDamagePhysical(attType);
}
-void Player::_ApplyWeaponDependentAuraMods(Item* item, WeaponAttackType attackType, bool apply)
-{
- AuraEffectList const& auraCritList = GetAuraEffectsByType(SPELL_AURA_MOD_WEAPON_CRIT_PERCENT);
- for (AuraEffectList::const_iterator itr = auraCritList.begin(); itr != auraCritList.end(); ++itr)
- _ApplyWeaponDependentAuraCritMod(item, attackType, *itr, apply);
-
- AuraEffectList const& auraDamageFlatList = GetAuraEffectsByType(SPELL_AURA_MOD_DAMAGE_DONE);
- for (AuraEffectList::const_iterator itr = auraDamageFlatList.begin(); itr != auraDamageFlatList.end(); ++itr)
- _ApplyWeaponDependentAuraDamageMod(item, attackType, *itr, apply);
-
- AuraEffectList const& auraDamagePctList = GetAuraEffectsByType(SPELL_AURA_MOD_DAMAGE_PERCENT_DONE);
- for (AuraEffectList::const_iterator itr = auraDamagePctList.begin(); itr != auraDamagePctList.end(); ++itr)
- _ApplyWeaponDependentAuraDamageMod(item, attackType, *itr, apply);
-}
-
-void Player::_ApplyWeaponDependentAuraCritMod(Item* item, WeaponAttackType attackType, AuraEffect const* aura, bool apply)
+void Player::ApplyItemDependentAuras(Item* item, bool apply)
{
- // don't apply mod if item is broken or cannot be used
- if (item->IsBroken() || !CanUseAttackType(attackType))
- return;
-
- // generic not weapon specific case processes in aura code
- if (aura->GetSpellInfo()->EquippedItemClass == -1)
- return;
-
- BaseModGroup mod;
- switch (attackType)
- {
- case BASE_ATTACK: mod = CRIT_PERCENTAGE; break;
- case OFF_ATTACK: mod = OFFHAND_CRIT_PERCENTAGE;break;
- case RANGED_ATTACK: mod = RANGED_CRIT_PERCENTAGE; break;
- default: return;
- }
-
- if (item->IsFitToSpellRequirements(aura->GetSpellInfo()))
- HandleBaseModValue(mod, FLAT_MOD, float (aura->GetAmount()), apply);
-}
-
-void Player::_ApplyWeaponDependentAuraDamageMod(Item* item, WeaponAttackType attackType, AuraEffect const* aura, bool apply)
-{
- // don't apply mod if item is broken or cannot be used
- if (item->IsBroken() || !CanUseAttackType(attackType))
- return;
-
- // ignore spell mods for not wands
- if ((aura->GetMiscValue() & SPELL_SCHOOL_MASK_NORMAL) == 0 && (getClassMask() & CLASSMASK_WAND_USERS) == 0)
- return;
-
- // generic not weapon specific case processes in aura code
- if (aura->GetSpellInfo()->EquippedItemClass == -1)
- return;
-
- UnitMods unitMod;
- switch (attackType)
+ if (apply)
{
- case BASE_ATTACK: unitMod = UNIT_MOD_DAMAGE_MAINHAND; break;
- case OFF_ATTACK: unitMod = UNIT_MOD_DAMAGE_OFFHAND; break;
- case RANGED_ATTACK: unitMod = UNIT_MOD_DAMAGE_RANGED; break;
- default: return;
- }
+ PlayerSpellMap const& spells = GetSpellMap();
+ for (auto itr = spells.begin(); itr != spells.end(); ++itr)
+ {
+ if (itr->second->state == PLAYERSPELL_REMOVED || itr->second->disabled)
+ continue;
- UnitModifierType unitModType;
- switch (aura->GetAuraType())
- {
- case SPELL_AURA_MOD_DAMAGE_DONE: unitModType = TOTAL_VALUE; break;
- case SPELL_AURA_MOD_DAMAGE_PERCENT_DONE: unitModType = TOTAL_PCT; break;
- default: return;
- }
+ SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(itr->first);
+ if (!spellInfo || !spellInfo->IsPassive() || spellInfo->EquippedItemClass < 0)
+ continue;
- if (item->IsFitToSpellRequirements(aura->GetSpellInfo()))
- {
- HandleStatModifier(unitMod, unitModType, float(aura->GetAmount()), apply);
- if (unitModType == TOTAL_VALUE)
- {
- if (aura->GetAmount() > 0)
- ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS, aura->GetAmount(), apply);
- else
- ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG, aura->GetAmount(), apply);
+ if (!HasAura(itr->first) && HasItemFitToSpellRequirements(spellInfo))
+ AddAura(itr->first, this); // no SMSG_SPELL_GO in sniff found
}
}
+ else
+ RemoveItemDependentAurasAndCasts(item);
}
void Player::ApplyItemEquipSpell(Item* item, bool apply, bool form_change)
@@ -8002,7 +7955,7 @@ void Player::CastItemCombatSpell(DamageInfo const& damageInfo, Item* item, ItemT
}
// not allow proc extra attack spell at extra attack
- if (HasExtraAttacksPending() && spellInfo->HasEffect(SPELL_EFFECT_ADD_EXTRA_ATTACKS))
+ if (m_extraAttacks && spellInfo->HasEffect(SPELL_EFFECT_ADD_EXTRA_ATTACKS))
return;
float chance = (float)spellInfo->ProcChance;
@@ -8199,10 +8152,7 @@ void Player::_RemoveAllItemMods()
if (!proto)
continue;
- uint32 attacktype = Player::GetAttackBySlot(i);
- if (attacktype < MAX_ATTACK)
- _ApplyWeaponDependentAuraMods(m_items[i], WeaponAttackType(attacktype), false);
-
+ ApplyItemDependentAuras(m_items[i], false);
_ApplyItemBonuses(proto, i, false);
if (i == EQUIPMENT_SLOT_RANGED)
@@ -8228,10 +8178,7 @@ void Player::_ApplyAllItemMods()
if (!proto)
continue;
- uint32 attacktype = Player::GetAttackBySlot(i);
- if (attacktype < MAX_ATTACK)
- _ApplyWeaponDependentAuraMods(m_items[i], WeaponAttackType(attacktype), true);
-
+ ApplyItemDependentAuras(m_items[i], true);
_ApplyItemBonuses(proto, i, true);
if (i == EQUIPMENT_SLOT_RANGED)
@@ -9387,7 +9334,7 @@ void Player::SendBattlefieldWorldStates() const
/// Send misc stuff that needs to be sent on every login, like the battle timers.
if (sWorld->getBoolConfig(CONFIG_WINTERGRASP_ENABLE))
{
- if (BattlefieldWG* wg = (BattlefieldWG*)sBattlefieldMgr->GetBattlefieldByBattleId(BATTLEFIELD_BATTLEID_WG))
+ if (BattlefieldWG* wg = static_cast<BattlefieldWG*>(sBattlefieldMgr->GetBattlefieldByBattleId(BATTLEFIELD_BATTLEID_WG)))
{
SendUpdateWorldState(BATTLEFIELD_WG_WORLD_STATE_ACTIVE, wg->IsWarTime() ? 0 : 1);
uint32 timer = wg->IsWarTime() ? 0 : (wg->GetTimer() / 1000); // 0 - Time to next battle
@@ -10141,7 +10088,7 @@ bool Player::HasItemOrGemWithIdEquipped(uint32 item, uint32 count, uint8 except_
return false;
}
-bool Player::HasItemOrGemWithLimitCategoryEquipped(uint32 limitCategory, uint32 count, uint8 except_slot) const
+bool Player::HasItemWithLimitCategoryEquipped(uint32 limitCategory, uint32 count, uint8 except_slot) const
{
uint32 tempcount = 0;
for (uint8 i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; ++i)
@@ -10163,6 +10110,26 @@ bool Player::HasItemOrGemWithLimitCategoryEquipped(uint32 limitCategory, uint32
if (tempcount >= count)
return true;
}
+ }
+
+ return false;
+}
+
+bool Player::HasGemWithLimitCategoryEquipped(uint32 limitCategory, uint32 count, uint8 except_slot) const
+{
+ uint32 tempcount = 0;
+ for (uint8 i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; ++i)
+ {
+ if (i == except_slot)
+ continue;
+
+ Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i);
+ if (!pItem)
+ continue;
+
+ ItemTemplate const* pProto = pItem->GetTemplate();
+ if (!pProto)
+ continue;
if (pProto->Socket[0].Color || pItem->GetEnchantmentId(PRISMATIC_ENCHANTMENT_SLOT))
{
@@ -11628,10 +11595,8 @@ InventoryResult Player::CanUseItem(ItemTemplate const* proto) const
if (!proto)
return EQUIP_ERR_ITEM_NOT_FOUND;
- if ((proto->Flags2 & ITEM_FLAGS_EXTRA_HORDE_ONLY) && GetTeam() != HORDE)
- return EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM;
-
- if ((proto->Flags2 & ITEM_FLAGS_EXTRA_ALLIANCE_ONLY) && GetTeam() != ALLIANCE)
+ if (((proto->Flags2 & ITEM_FLAG2_FACTION_HORDE) && GetTeam() != HORDE) ||
+ (((proto->Flags2 & ITEM_FLAG2_FACTION_ALLIANCE) && GetTeam() != ALLIANCE)))
return EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM;
if ((proto->AllowableClass & getClassMask()) == 0 || (proto->AllowableRace & getRaceMask()) == 0)
@@ -12204,9 +12169,6 @@ void Player::RemoveItem(uint8 bag, uint8 slot, bool update)
// remove item dependent auras and casts (only weapon and armor slots)
if (slot < EQUIPMENT_SLOT_END)
{
- if (update)
- RemoveItemDependentAurasAndCasts(pItem);
-
// remove held enchantments, update expertise
if (slot == EQUIPMENT_SLOT_MAINHAND)
{
@@ -12297,7 +12259,7 @@ void Player::MoveItemToInventory(ItemPosCountVec const& dest, Item* pItem, bool
// in case trade we already have item in other player inventory
pLastItem->SetState(in_characterInventoryDB ? ITEM_CHANGED : ITEM_NEW, this);
- if (pLastItem->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_BOP_TRADEABLE))
+ if (pLastItem->HasFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_BOP_TRADEABLE))
AddTradeableItem(pLastItem);
}
}
@@ -12315,7 +12277,7 @@ void Player::DestroyItem(uint8 bag, uint8 slot, bool update)
for (uint8 i = 0; i < MAX_BAG_SIZE; ++i)
DestroyItem(slot, i, update);
- if (pItem->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_WRAPPED))
+ if (pItem->HasFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_WRAPPED))
{
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GIFT);
@@ -12357,9 +12319,6 @@ void Player::DestroyItem(uint8 bag, uint8 slot, bool update)
if (slot < EQUIPMENT_SLOT_END)
{
- // remove item dependent auras and casts (only weapon and armor slots)
- RemoveItemDependentAurasAndCasts(pItem);
-
// update expertise and armor penetration - passive auras may need it
switch (slot)
{
@@ -12388,7 +12347,7 @@ void Player::DestroyItem(uint8 bag, uint8 slot, bool update)
// Delete rolled money / loot from db.
// MUST be done before RemoveFromWorld() or GetTemplate() fails
if (ItemTemplate const* pTmp = pItem->GetTemplate())
- if (pTmp->Flags & ITEM_PROTO_FLAG_HAS_LOOT)
+ if (pTmp->Flags & ITEM_FLAG_HAS_LOOT)
pItem->ItemContainerDeleteLootMoneyAndLootItemsFromDB();
if (IsInWorld() && update)
@@ -14826,7 +14785,9 @@ bool Player::CanRewardQuest(Quest const* quest, uint32 reward, bool msg)
InventoryResult res = CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, quest->RewardChoiceItemId[reward], quest->RewardChoiceItemCount[reward]);
if (res != EQUIP_ERR_OK)
{
- SendEquipError(res, nullptr, nullptr, quest->RewardChoiceItemId[reward]);
+ if (msg)
+ SendQuestFailed(quest->GetQuestId(), res);
+
return false;
}
}
@@ -14841,7 +14802,9 @@ bool Player::CanRewardQuest(Quest const* quest, uint32 reward, bool msg)
InventoryResult res = CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, quest->RewardItemId[i], quest->RewardItemIdCount[i]);
if (res != EQUIP_ERR_OK)
{
- SendEquipError(res, nullptr, nullptr, quest->RewardItemId[i]);
+ if (msg)
+ SendQuestFailed(quest->GetQuestId(), res);
+
return false;
}
}
@@ -14990,20 +14953,20 @@ void Player::RewardQuest(Quest const* quest, uint32 reward, Object* questGiver,
{
if (ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(quest->RequiredItemId[i]))
{
- if (quest->RequiredItemCount[i] > 0 && (itemTemplate->Bonding == BIND_QUEST_ITEM || itemTemplate->Bonding == BIND_QUEST_ITEM1))
- DestroyItemCount(quest->RequiredItemId[i], 9999, true, true);
+ if (quest->RequiredItemCount[i] > 0 && itemTemplate->Bonding == BIND_QUEST_ITEM && !quest->IsRepeatable() && !HasQuestForItem(quest->RequiredItemId[i], quest_id, true))
+ DestroyItemCount(quest->RequiredItemId[i], 9999, true);
else
- DestroyItemCount(quest->RequiredItemId[i], quest->RequiredItemCount[i], true, true);
+ DestroyItemCount(quest->RequiredItemId[i], quest->RequiredItemCount[i], true);
}
}
for (uint8 i = 0; i < QUEST_SOURCE_ITEM_IDS_COUNT; ++i)
{
if (ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(quest->ItemDrop[i]))
{
- if (quest->ItemDropQuantity[i] > 0 && (itemTemplate->Bonding == BIND_QUEST_ITEM || itemTemplate->Bonding == BIND_QUEST_ITEM1))
- DestroyItemCount(quest->ItemDrop[i], 9999, true, true);
+ if (quest->ItemDropQuantity[i] > 0 && itemTemplate->Bonding == BIND_QUEST_ITEM && !quest->IsRepeatable() && !HasQuestForItem(quest->ItemDrop[i], quest_id))
+ DestroyItemCount(quest->ItemDrop[i], 9999, true);
else
- DestroyItemCount(quest->ItemDrop[i], quest->ItemDropQuantity[i], true, true);
+ DestroyItemCount(quest->ItemDrop[i], quest->ItemDropQuantity[i], true);
}
}
@@ -15188,13 +15151,16 @@ void Player::SetRewardedQuest(uint32 quest_id)
void Player::FailQuest(uint32 questId)
{
-
if (Quest const* quest = sObjectMgr->GetQuestTemplate(questId))
{
// Already complete quests shouldn't turn failed.
if (GetQuestStatus(questId) == QUEST_STATUS_COMPLETE && !quest->HasSpecialFlag(QUEST_SPECIAL_FLAGS_TIMED))
return;
+ // You can't fail a quest if you don't have it, or if it's already rewarded.
+ if (GetQuestStatus(questId) == QUEST_STATUS_NONE || GetQuestStatus(questId) == QUEST_STATUS_REWARDED)
+ return;
+
SetQuestStatus(questId, QUEST_STATUS_FAILED);
uint16 log_slot = FindQuestSlot(questId);
@@ -15220,13 +15186,13 @@ void Player::FailQuest(uint32 questId)
// Destroy quest items on quest failure.
for (uint8 i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i)
if (ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(quest->RequiredItemId[i]))
- if (quest->RequiredItemCount[i] > 0 && (itemTemplate->Bonding == BIND_QUEST_ITEM || itemTemplate->Bonding == BIND_QUEST_ITEM1))
- DestroyItemCount(quest->RequiredItemId[i], 9999, true, true);
+ if (quest->RequiredItemCount[i] > 0 && itemTemplate->Bonding == BIND_QUEST_ITEM)
+ DestroyItemCount(quest->RequiredItemId[i], 9999, true);
for (uint8 i = 0; i < QUEST_SOURCE_ITEM_IDS_COUNT; ++i)
if (ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(quest->ItemDrop[i]))
- if (quest->ItemDropQuantity[i] > 0 && (itemTemplate->Bonding == BIND_QUEST_ITEM || itemTemplate->Bonding == BIND_QUEST_ITEM1))
- DestroyItemCount(quest->ItemDrop[i], 9999, true, true);
+ if (quest->ItemDropQuantity[i] > 0 && itemTemplate->Bonding == BIND_QUEST_ITEM)
+ DestroyItemCount(quest->ItemDrop[i], 9999, true);
}
}
@@ -15237,13 +15203,13 @@ void Player::AbandonQuest(uint32 questId)
// Destroy quest items on quest abandon.
for (uint8 i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i)
if (ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(quest->RequiredItemId[i]))
- if (quest->RequiredItemCount[i] > 0 && (itemTemplate->Bonding == BIND_QUEST_ITEM || itemTemplate->Bonding == BIND_QUEST_ITEM1))
- DestroyItemCount(quest->RequiredItemId[i], 9999, true, true);
+ if (quest->RequiredItemCount[i] > 0 && itemTemplate->Bonding == BIND_QUEST_ITEM)
+ DestroyItemCount(quest->RequiredItemId[i], 9999, true);
for (uint8 i = 0; i < QUEST_SOURCE_ITEM_IDS_COUNT; ++i)
if (ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(quest->ItemDrop[i]))
- if (quest->ItemDropQuantity[i] > 0 && (itemTemplate->Bonding == BIND_QUEST_ITEM || itemTemplate->Bonding == BIND_QUEST_ITEM1))
- DestroyItemCount(quest->ItemDrop[i], 9999, true, true);
+ if (quest->ItemDropQuantity[i] > 0 && itemTemplate->Bonding == BIND_QUEST_ITEM)
+ DestroyItemCount(quest->ItemDrop[i], 9999, true);
}
}
@@ -15947,21 +15913,18 @@ QuestGiverStatus Player::GetQuestDialogStatus(Object* questgiver)
if (!quest)
continue;
- if (!sConditionMgr->IsObjectMeetingNotGroupedConditions(CONDITION_SOURCE_TYPE_QUEST_SHOW_MARK, quest->GetQuestId(), this))
+ if (!sConditionMgr->IsObjectMeetingNotGroupedConditions(CONDITION_SOURCE_TYPE_QUEST_ACCEPT, quest->GetQuestId(), this))
continue;
QuestStatus status = GetQuestStatus(questId);
- if ((status == QUEST_STATUS_COMPLETE && !GetQuestRewardStatus(questId)) ||
- (quest->IsAutoComplete() && CanTakeQuest(quest, false)))
- {
- if (quest->IsAutoComplete() && quest->IsRepeatable() && !quest->IsDailyOrWeekly())
- result2 = DIALOG_STATUS_REWARD_REP;
- else
- result2 = DIALOG_STATUS_REWARD;
- }
+ if (status == QUEST_STATUS_COMPLETE && !GetQuestRewardStatus(questId))
+ result2 = DIALOG_STATUS_REWARD;
else if (status == QUEST_STATUS_INCOMPLETE)
result2 = DIALOG_STATUS_INCOMPLETE;
+ if (quest->IsAutoComplete() && CanTakeQuest(quest, false) && quest->IsRepeatable() && !quest->IsDailyOrWeekly())
+ result2 = DIALOG_STATUS_REWARD_REP;
+
if (result2 > result)
result = result2;
}
@@ -15974,7 +15937,7 @@ QuestGiverStatus Player::GetQuestDialogStatus(Object* questgiver)
if (!quest)
continue;
- if (!sConditionMgr->IsObjectMeetingNotGroupedConditions(CONDITION_SOURCE_TYPE_QUEST_SHOW_MARK, quest->GetQuestId(), this))
+ if (!sConditionMgr->IsObjectMeetingNotGroupedConditions(CONDITION_SOURCE_TYPE_QUEST_ACCEPT, quest->GetQuestId(), this))
continue;
QuestStatus status = GetQuestStatus(questId);
@@ -15984,9 +15947,7 @@ QuestGiverStatus Player::GetQuestDialogStatus(Object* questgiver)
{
if (SatisfyQuestLevel(quest, false))
{
- if (quest->IsAutoComplete())
- result2 = DIALOG_STATUS_REWARD_REP;
- else if (getLevel() <= (GetQuestLevel(quest) + sWorld->getIntConfig(CONFIG_QUEST_LOW_LEVEL_HIDE_DIFF)))
+ if (getLevel() <= (GetQuestLevel(quest) + sWorld->getIntConfig(CONFIG_QUEST_LOW_LEVEL_HIDE_DIFF)))
{
if (quest->IsDaily())
result2 = DIALOG_STATUS_AVAILABLE_REP;
@@ -16547,12 +16508,12 @@ void Player::ReputationChanged2(FactionEntry const* factionEntry)
}
}
-bool Player::HasQuestForItem(uint32 itemid) const
+bool Player::HasQuestForItem(uint32 itemid, uint32 excludeQuestId /* 0 */, bool turnIn /* false */) const
{
for (uint8 i = 0; i < MAX_QUEST_LOG_SIZE; ++i)
{
uint32 questid = GetQuestSlotQuestId(i);
- if (questid == 0)
+ if (questid == 0 || questid == excludeQuestId)
continue;
QuestStatusMap::const_iterator qs_itr = m_QuestStatus.find(questid);
@@ -16561,7 +16522,7 @@ bool Player::HasQuestForItem(uint32 itemid) const
QuestStatusData const& q_status = qs_itr->second;
- if (q_status.Status == QUEST_STATUS_INCOMPLETE)
+ if ((q_status.Status == QUEST_STATUS_INCOMPLETE) || (turnIn && q_status.Status == QUEST_STATUS_COMPLETE))
{
Quest const* qinfo = sObjectMgr->GetQuestTemplate(questid);
if (!qinfo)
@@ -16576,7 +16537,7 @@ bool Player::HasQuestForItem(uint32 itemid) const
// This part for ReqItem drop
for (uint8 j = 0; j < QUEST_ITEM_OBJECTIVES_COUNT; ++j)
{
- if (itemid == qinfo->RequiredItemId[j] && q_status.ItemCount[j] < qinfo->RequiredItemCount[j])
+ if ((itemid == qinfo->RequiredItemId[j] && q_status.ItemCount[j] < qinfo->RequiredItemCount[j]) || (turnIn && q_status.ItemCount[j] >= qinfo->RequiredItemCount[j]))
return true;
}
// This part - for ReqSource
@@ -16586,17 +16547,17 @@ bool Player::HasQuestForItem(uint32 itemid) const
if (qinfo->ItemDrop[j] == itemid)
{
ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(itemid);
-
+ uint32 ownedCount = GetItemCount(itemid, true);
// 'unique' item
- if (pProto->MaxCount && int32(GetItemCount(itemid, true)) < pProto->MaxCount)
+ if ((pProto->MaxCount && int32(ownedCount) < pProto->MaxCount) || (turnIn && int32(ownedCount) >= pProto->MaxCount))
return true;
// allows custom amount drop when not 0
if (qinfo->ItemDropQuantity[j])
{
- if (GetItemCount(itemid, true) < qinfo->ItemDropQuantity[j])
+ if ((ownedCount < qinfo->ItemDropQuantity[j]) || (turnIn && ownedCount >= qinfo->ItemDropQuantity[j]))
return true;
- } else if (GetItemCount(itemid, true) < pProto->GetMaxStackSize())
+ } else if (ownedCount < pProto->GetMaxStackSize())
return true;
}
}
@@ -18080,13 +18041,13 @@ Item* Player::_LoadItem(SQLTransaction& trans, uint32 zoneId, uint32 timeDiff, F
remove = true;
}
// "Conjured items disappear if you are logged out for more than 15 minutes"
- else if (timeDiff > 15 * MINUTE && proto->Flags & ITEM_PROTO_FLAG_CONJURED)
+ else if (timeDiff > 15 * MINUTE && proto->Flags & ITEM_FLAG_CONJURED)
{
TC_LOG_DEBUG("entities.player.loading", "Player::_LoadInventory: player (GUID: %u, name: '%s', diff: %u) has conjured item (GUID: %u, entry: %u) with expired lifetime (15 minutes). Deleting item.",
GetGUID().GetCounter(), GetName().c_str(), timeDiff, item->GetGUID().GetCounter(), item->GetEntry());
remove = true;
}
- else if (item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_REFUNDABLE))
+ else if (item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_REFUNDABLE))
{
if (item->GetPlayedTime() > (2 * HOUR))
{
@@ -18097,7 +18058,7 @@ Item* Player::_LoadItem(SQLTransaction& trans, uint32 zoneId, uint32 timeDiff, F
stmt->setUInt32(0, item->GetGUID().GetCounter());
trans->Append(stmt);
- item->RemoveFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_REFUNDABLE);
+ item->RemoveFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_REFUNDABLE);
}
else
{
@@ -18115,11 +18076,11 @@ Item* Player::_LoadItem(SQLTransaction& trans, uint32 zoneId, uint32 timeDiff, F
{
TC_LOG_DEBUG("entities.player.loading", "Player::_LoadInventory: player (GUID: %u, name: '%s') has item (GUID: %u, entry: %u) with refundable flags, but without data in item_refund_instance. Removing flag.",
GetGUID().GetCounter(), GetName().c_str(), item->GetGUID().GetCounter(), item->GetEntry());
- item->RemoveFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_REFUNDABLE);
+ item->RemoveFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_REFUNDABLE);
}
}
}
- else if (item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_BOP_TRADEABLE))
+ else if (item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_BOP_TRADEABLE))
{
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_ITEM_BOP_TRADE);
stmt->setUInt32(0, item->GetGUID().GetCounter());
@@ -18143,7 +18104,7 @@ Item* Player::_LoadItem(SQLTransaction& trans, uint32 zoneId, uint32 timeDiff, F
{
TC_LOG_DEBUG("entities.player.loading", "Player::_LoadInventory: player (GUID: %u, name: '%s') has item (GUID: %u, entry: %u) with ITEM_FLAG_BOP_TRADEABLE flag, but without data in item_soulbound_trade_data. Removing flag.",
GetGUID().GetCounter(), GetName().c_str(), item->GetGUID().GetCounter(), item->GetEntry());
- item->RemoveFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_BOP_TRADEABLE);
+ item->RemoveFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_BOP_TRADEABLE);
}
}
else if (proto->HolidayId)
@@ -19539,7 +19500,6 @@ void Player::_SaveAuras(SQLTransaction& trans)
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_AURA);
stmt->setUInt32(index++, GetGUID().GetCounter());
stmt->setUInt64(index++, itr->second->GetCasterGUID().GetRawValue());
- stmt->setUInt64(index++, itr->second->GetCastItemGUID().GetRawValue());
stmt->setUInt32(index++, itr->second->GetId());
stmt->setUInt8(index++, effMask);
stmt->setUInt8(index++, recalculateMask);
@@ -20854,29 +20814,30 @@ void Player::AddSpellMod(SpellModifier* mod, bool apply)
TC_LOG_DEBUG("spells", "Player::AddSpellMod: Player '%s' (%s), SpellID: %d", GetName().c_str(), GetGUID().ToString().c_str(), mod->spellId);
uint16 Opcode = (mod->type == SPELLMOD_FLAT) ? SMSG_SET_FLAT_SPELL_MODIFIER : SMSG_SET_PCT_SPELL_MODIFIER;
- int i = 0;
- flag96 _mask = 0;
- for (int32 eff = 0; eff < 96; ++eff)
+ flag96 modMask;
+ for (uint8 i = 0; i < 3; ++i)
{
- if (eff != 0 && eff % 32 == 0)
- _mask[i++] = 0;
-
- _mask[i] = uint32(1) << (eff - (32 * i));
- if ((mod->mask & _mask))
+ for (uint32 eff = 0; eff < 32; ++eff)
{
- int32 val = 0;
- for (SpellModifier* spellMod : m_spellMods[mod->op])
+ modMask[i] = uint32(1) << eff;
+ if ((mod->mask & modMask))
{
- if (spellMod->type == mod->type && (spellMod->mask & _mask))
- val += spellMod->value;
+ int32 val = 0;
+ for (SpellModifier* spellMod : m_spellMods[mod->op])
+ {
+ if (spellMod->type == mod->type && (spellMod->mask & modMask))
+ val += spellMod->value;
+ }
+ val += apply ? mod->value : -(mod->value);
+ WorldPacket data(Opcode, (1 + 1 + 4));
+ data << uint8(eff + 32 * i);
+ data << uint8(mod->op);
+ data << int32(val);
+ SendDirectMessage(&data);
}
- val += apply ? mod->value : -(mod->value);
- WorldPacket data(Opcode, (1 + 1 + 4));
- data << uint8(eff);
- data << uint8(mod->op);
- data << int32(val);
- SendDirectMessage(&data);
}
+
+ modMask[i] = 0;
}
if (apply)
@@ -21483,9 +21444,9 @@ inline bool Player::_StoreOrEquipNewItem(uint32 vendorslot, uint32 item, uint8 c
if (!bStore)
AutoUnequipOffhandIfNeed();
- if (pProto->Flags & ITEM_PROTO_FLAG_REFUNDABLE && crItem->ExtendedCost && pProto->GetMaxStackSize() == 1)
+ if (pProto->Flags & ITEM_FLAG_ITEM_PURCHASE_RECORD && crItem->ExtendedCost && pProto->GetMaxStackSize() == 1)
{
- it->SetFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_REFUNDABLE);
+ it->SetFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_REFUNDABLE);
it->SetRefundRecipient(GetGUID().GetCounter());
it->SetPaidMoney(price);
it->SetPaidExtendedCost(crItem->ExtendedCost);
@@ -21522,7 +21483,7 @@ bool Player::BuyItemFromVendorSlot(ObjectGuid vendorguid, uint32 vendorslot, uin
return false;
}
- if (!IsGameMaster() && ((pProto->Flags2 & ITEM_FLAGS_EXTRA_HORDE_ONLY && GetTeam() == ALLIANCE) || (pProto->Flags2 == ITEM_FLAGS_EXTRA_ALLIANCE_ONLY && GetTeam() == HORDE)))
+ if (!IsGameMaster() && ((pProto->Flags2 & ITEM_FLAG2_FACTION_HORDE && GetTeam() == ALLIANCE) || (pProto->Flags2 == ITEM_FLAG2_FACTION_ALLIANCE && GetTeam() == HORDE)))
return false;
Creature* creature = GetNPCIfCanInteractWith(vendorguid, UNIT_NPC_FLAG_VENDOR);
@@ -22710,7 +22671,7 @@ void Player::SendInstanceResetWarning(uint32 mapid, Difficulty difficulty, uint3
void Player::ApplyEquipCooldown(Item* pItem)
{
- if (pItem->HasFlag(ITEM_FIELD_FLAGS, ITEM_PROTO_FLAG_NO_EQUIP_COOLDOWN))
+ if (pItem->GetTemplate()->Flags & ITEM_FLAG_NO_EQUIP_COOLDOWN)
return;
std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now();
@@ -23563,9 +23524,9 @@ void Player::RemoveItemDependentAurasAndCasts(Item* pItem)
{
Aura* aura = itr->second;
- // skip passive (passive item dependent spells work in another way) and not self applied auras
+ // skip not self applied auras
SpellInfo const* spellInfo = aura->GetSpellInfo();
- if (aura->IsPassive() || aura->GetCasterGUID() != GetGUID())
+ if (aura->GetCasterGUID() != GetGUID())
{
++itr;
continue;
@@ -24610,9 +24571,9 @@ void Player::AutoStoreLoot(uint8 bag, uint8 slot, uint32 loot_id, LootStore cons
void Player::StoreLootItem(uint8 lootSlot, Loot* loot)
{
- QuestItem* qitem = nullptr;
- QuestItem* ffaitem = nullptr;
- QuestItem* conditem = nullptr;
+ NotNormalLootItem* qitem = nullptr;
+ NotNormalLootItem* ffaitem = nullptr;
+ NotNormalLootItem* conditem = nullptr;
LootItem* item = loot->LootItemInSlot(lootSlot, this, &qitem, &ffaitem, &conditem);
@@ -24878,7 +24839,7 @@ InventoryResult Player::CanEquipUniqueItem(Item* pItem, uint8 eslot, uint32 limi
InventoryResult Player::CanEquipUniqueItem(ItemTemplate const* itemProto, uint8 except_slot, uint32 limit_count) const
{
// check unique-equipped on item
- if (itemProto->Flags & ITEM_PROTO_FLAG_UNIQUE_EQUIPPED)
+ if (itemProto->Flags & ITEM_FLAG_UNIQUE_EQUIPPABLE)
{
// there is an equip limit on this item
if (HasItemOrGemWithIdEquipped(itemProto->ItemId, 1, except_slot))
@@ -24898,7 +24859,9 @@ InventoryResult Player::CanEquipUniqueItem(ItemTemplate const* itemProto, uint8
return EQUIP_ERR_ITEM_MAX_LIMIT_CATEGORY_EQUIPPED_EXCEEDED;
// there is an equip limit on this item
- if (HasItemOrGemWithLimitCategoryEquipped(itemProto->ItemLimitCategory, limitEntry->maxCount - limit_count + 1, except_slot))
+ if (HasItemWithLimitCategoryEquipped(itemProto->ItemLimitCategory, limitEntry->maxCount - limit_count + 1, except_slot))
+ return EQUIP_ERR_ITEM_MAX_LIMIT_CATEGORY_EQUIPPED_EXCEEDED;
+ else if (HasGemWithLimitCategoryEquipped(itemProto->ItemLimitCategory, limitEntry->maxCount - limit_count + 1, except_slot))
return EQUIP_ERR_ITEM_MAX_COUNT_EQUIPPED_SOCKETED;
}
@@ -25862,6 +25825,20 @@ void Player::ActivateSpec(uint8 spec)
UnsummonAllTotems();
ExitVehicle();
RemoveAllControlled();
+
+ // remove single target auras at other targets
+ AuraList& scAuras = GetSingleCastAuras();
+ for (AuraList::iterator iter = scAuras.begin(); iter != scAuras.end();)
+ {
+ Aura* aura = *iter;
+ if (aura->GetUnitOwner() != this)
+ {
+ aura->Remove();
+ iter = scAuras.begin();
+ }
+ else
+ ++iter;
+ }
/*RemoveAllAurasOnDeath();
if (GetPet())
GetPet()->RemoveAllAurasOnDeath();*/
@@ -25979,6 +25956,13 @@ void Player::ActivateSpec(uint8 spec)
SetPower(POWER_MANA, 0); // Mana must be 0 even if it isn't the active power type.
SetPower(pw, 0);
+
+ Unit::AuraEffectList const& shapeshiftAuras = GetAuraEffectsByType(SPELL_AURA_MOD_SHAPESHIFT);
+ for (AuraEffect* aurEff : shapeshiftAuras)
+ {
+ aurEff->HandleShapeshiftBoosts(this, false);
+ aurEff->HandleShapeshiftBoosts(this, true);
+ }
}
void Player::ResetTimeSync()
@@ -26038,7 +26022,7 @@ void Player::SendRefundInfo(Item* item)
// This function call unsets ITEM_FLAGS_REFUNDABLE if played time is over 2 hours.
item->UpdatePlayedTime(this);
- if (!item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_REFUNDABLE))
+ if (!item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_REFUNDABLE))
{
TC_LOG_DEBUG("entities.player.items", "Item refund: item not refundable!");
return;
@@ -26098,7 +26082,7 @@ bool Player::AddItem(uint32 itemId, uint32 count)
void Player::RefundItem(Item* item)
{
- if (!item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_REFUNDABLE))
+ if (!item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_REFUNDABLE))
{
TC_LOG_DEBUG("entities.player.items", "Item refund: item not refundable!");
return;
diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h
index 2f580908e2b..ed5dc7e954f 100644
--- a/src/server/game/Entities/Player/Player.h
+++ b/src/server/game/Entities/Player/Player.h
@@ -1199,7 +1199,8 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
bool HasItemFitToSpellRequirements(SpellInfo const* spellInfo, Item const* ignoreItem = nullptr) const;
bool CanNoReagentCast(SpellInfo const* spellInfo) const;
bool HasItemOrGemWithIdEquipped(uint32 item, uint32 count, uint8 except_slot = NULL_SLOT) const;
- bool HasItemOrGemWithLimitCategoryEquipped(uint32 limitCategory, uint32 count, uint8 except_slot = NULL_SLOT) const;
+ bool HasItemWithLimitCategoryEquipped(uint32 limitCategory, uint32 count, uint8 except_slot = NULL_SLOT) const;
+ bool HasGemWithLimitCategoryEquipped(uint32 limitCategory, uint32 count, uint8 except_slot = NULL_SLOT) const;
InventoryResult CanTakeMoreSimilarItems(Item* pItem, uint32* itemLimitCategory = NULL) const { return CanTakeMoreSimilarItems(pItem->GetEntry(), pItem->GetCount(), pItem, NULL, itemLimitCategory); }
InventoryResult CanTakeMoreSimilarItems(uint32 entry, uint32 count, uint32* itemLimitCategory = NULL) const { return CanTakeMoreSimilarItems(entry, count, NULL, NULL, itemLimitCategory); }
InventoryResult CanStoreNewItem(uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 item, uint32 count, uint32* no_space_count = nullptr) const;
@@ -1405,7 +1406,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
void MoneyChanged(uint32 value);
void ReputationChanged(FactionEntry const* factionEntry);
void ReputationChanged2(FactionEntry const* factionEntry);
- bool HasQuestForItem(uint32 itemId) const;
+ bool HasQuestForItem(uint32 itemId, uint32 excludeQuestId = 0, bool turnIn = false) const;
bool HasQuestForGO(int32 goId) const;
void UpdateForQuestWorldObjects();
bool CanShareQuest(uint32 questId) const;
@@ -1847,6 +1848,9 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
void UpdateLocalChannels(uint32 newZone);
void LeaveLFGChannel();
+ typedef std::list<Channel*> JoinedChannelsList;
+ JoinedChannelsList const& GetJoinedChannels() const { return m_channels; }
+
void UpdateDefense();
void UpdateWeaponSkill (WeaponAttackType attType);
void UpdateCombatSkills(Unit* victim, WeaponAttackType attType, bool defense);
@@ -1954,9 +1958,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
void ResetAllPowers();
- void _ApplyWeaponDependentAuraMods(Item* item, WeaponAttackType attackType, bool apply);
- void _ApplyWeaponDependentAuraCritMod(Item* item, WeaponAttackType attackType, AuraEffect const* aura, bool apply);
- void _ApplyWeaponDependentAuraDamageMod(Item* item, WeaponAttackType attackType, AuraEffect const* aura, bool apply);
+ void ApplyItemDependentAuras(Item* item, bool apply);
void _ApplyItemMods(Item* item, uint8 slot, bool apply);
void _RemoveAllItemMods();
@@ -2454,7 +2456,6 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
WorldSession* m_session;
- typedef std::list<Channel*> JoinedChannelsList;
JoinedChannelsList m_channels;
uint8 m_cinematic;
diff --git a/src/server/game/Entities/Transport/Transport.cpp b/src/server/game/Entities/Transport/Transport.cpp
index fad197949a8..cdb4b931a07 100644
--- a/src/server/game/Entities/Transport/Transport.cpp
+++ b/src/server/game/Entities/Transport/Transport.cpp
@@ -131,6 +131,7 @@ void Transport::Update(uint32 diff)
m_goValue.Transport.PathProgress += diff;
uint32 timer = m_goValue.Transport.PathProgress % GetTransportPeriod();
+ bool justStopped = false;
// Set current waypoint
// Desired outcome: _currentFrame->DepartureTime < timer < _nextFrame->ArriveTime
@@ -149,6 +150,7 @@ void Transport::Update(uint32 diff)
if (timer < _currentFrame->DepartureTime)
{
SetMoving(false);
+ justStopped = true;
if (_pendingStop && GetGoState() != GO_STATE_READY)
{
SetGoState(GO_STATE_READY);
@@ -203,12 +205,14 @@ void Transport::Update(uint32 diff)
_positionChangeTimer.Reset(positionUpdateDelay);
if (IsMoving())
{
- float t = CalculateSegmentPos(float(timer) * 0.001f);
+ float t = !justStopped ? CalculateSegmentPos(float(timer) * 0.001f) : 1.0f;
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, std::atan2(dir.y, dir.x) + float(M_PI));
}
+ else if (justStopped)
+ UpdatePosition(_currentFrame->Node->LocX, _currentFrame->Node->LocY, _currentFrame->Node->LocZ, _currentFrame->InitialOrientation);
else
{
/* There are four possible scenarios that trigger loading/unloading passengers:
diff --git a/src/server/game/Entities/Unit/StatSystem.cpp b/src/server/game/Entities/Unit/StatSystem.cpp
index 699709fabb1..0cad0b2cb05 100644
--- a/src/server/game/Entities/Unit/StatSystem.cpp
+++ b/src/server/game/Entities/Unit/StatSystem.cpp
@@ -184,8 +184,17 @@ void Player::UpdateSpellDamageAndHealingBonus()
// Get healing bonus for all schools
SetStatInt32Value(PLAYER_FIELD_MOD_HEALING_DONE_POS, SpellBaseHealingBonusDone(SPELL_SCHOOL_MASK_ALL));
// Get damage bonus for all schools
- for (int i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i)
- SetStatInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS+i, SpellBaseDamageBonusDone(SpellSchoolMask(1 << i)));
+ Unit::AuraEffectList const& modDamageAuras = GetAuraEffectsByType(SPELL_AURA_MOD_DAMAGE_DONE);
+ for (uint16 i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i)
+ {
+ SetInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG + i, std::accumulate(modDamageAuras.begin(), modDamageAuras.end(), 0, [i](int32 negativeMod, AuraEffect const* aurEff)
+ {
+ if (aurEff->GetAmount() < 0 && aurEff->GetMiscValue() & (1 << i))
+ negativeMod += aurEff->GetAmount();
+ return negativeMod;
+ }));
+ SetStatInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + i, SpellBaseDamageBonusDone(SpellSchoolMask(1 << i)) - GetInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG + i));
+ }
}
bool Player::UpdateAllStats()
@@ -530,9 +539,9 @@ void Player::CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, bo
break;
}
- float attackSpeedMod = GetAPMultiplier(attType, normalized);
+ float const attackPowerMod = std::max(GetAPMultiplier(attType, normalized), 0.25f);
- float baseValue = GetModifierValue(unitMod, BASE_VALUE) + GetTotalAttackPowerValue(attType) / 14.0f * attackSpeedMod;
+ float baseValue = GetModifierValue(unitMod, BASE_VALUE) + GetTotalAttackPowerValue(attType) / 14.0f * attackPowerMod;
float basePct = GetModifierValue(unitMod, BASE_PCT);
float totalValue = GetModifierValue(unitMod, TOTAL_VALUE);
float totalPct = addTotalPct ? GetModifierValue(unitMod, TOTAL_PCT) : 1.0f;
@@ -546,8 +555,8 @@ void Player::CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, bo
if (lvl > 60)
lvl = 60;
- weaponMinDamage = lvl * 0.85f * attackSpeedMod;
- weaponMaxDamage = lvl * 1.25f * attackSpeedMod;
+ weaponMinDamage = lvl * 0.85f * attackPowerMod;
+ weaponMaxDamage = lvl * 1.25f * attackPowerMod;
}
else if (!CanUseAttackType(attType)) // check if player not in form but still can't use (disarm case)
{
@@ -563,8 +572,8 @@ void Player::CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, bo
}
else if (attType == RANGED_ATTACK) // add ammo DPS to ranged damage
{
- weaponMinDamage += GetAmmoDPS() * attackSpeedMod;
- weaponMaxDamage += GetAmmoDPS() * attackSpeedMod;
+ weaponMinDamage += GetAmmoDPS() * attackPowerMod;
+ weaponMaxDamage += GetAmmoDPS() * attackPowerMod;
}
minDamage = ((weaponMinDamage + baseValue) * basePct + totalValue) * totalPct;
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index 4dcb9a505ea..7ff01efa363 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -112,7 +112,7 @@ DamageInfo::DamageInfo(CalcDamageInfo const& dmgInfo)
break;
}
- if (m_absorb)
+ if (dmgInfo.HitInfo & (HITINFO_PARTIAL_ABSORB | HITINFO_FULL_ABSORB))
m_hitMask |= PROC_HIT_ABSORB;
if (dmgInfo.HitInfo & HITINFO_FULL_RESIST)
@@ -121,6 +121,8 @@ DamageInfo::DamageInfo(CalcDamageInfo const& dmgInfo)
if (m_block)
m_hitMask |= PROC_HIT_BLOCK;
+ bool const damageNullified = (dmgInfo.HitInfo & (HITINFO_FULL_ABSORB | HITINFO_FULL_RESIST)) != 0 ||
+ (m_hitMask & (PROC_HIT_IMMUNE | PROC_HIT_FULL_BLOCK)) != 0;
switch (dmgInfo.hitOutCome)
{
case MELEE_HIT_MISS:
@@ -138,10 +140,12 @@ DamageInfo::DamageInfo(CalcDamageInfo const& dmgInfo)
case MELEE_HIT_CRUSHING:
case MELEE_HIT_GLANCING:
case MELEE_HIT_NORMAL:
- m_hitMask |= PROC_HIT_NORMAL;
+ if (!damageNullified)
+ m_hitMask |= PROC_HIT_NORMAL;
break;
case MELEE_HIT_CRIT:
- m_hitMask |= PROC_HIT_CRITICAL;
+ if (!damageNullified)
+ m_hitMask |= PROC_HIT_CRITICAL;
break;
default:
break;
@@ -161,7 +165,7 @@ DamageInfo::DamageInfo(SpellNonMeleeDamage const& spellNonMeleeDamage, DamageEff
void DamageInfo::ModifyDamage(int32 amount)
{
- amount = std::min(amount, int32(GetDamage()));
+ amount = std::max(amount, -static_cast<int32>(GetDamage()));
m_damage += amount;
}
@@ -179,7 +183,10 @@ void DamageInfo::ResistDamage(uint32 amount)
m_resist += amount;
m_damage -= amount;
if (!m_damage)
+ {
m_hitMask |= PROC_HIT_FULL_RESIST;
+ m_hitMask &= ~(PROC_HIT_NORMAL | PROC_HIT_CRITICAL);
+ }
}
void DamageInfo::BlockDamage(uint32 amount)
@@ -189,7 +196,10 @@ void DamageInfo::BlockDamage(uint32 amount)
m_damage -= amount;
m_hitMask |= PROC_HIT_BLOCK;
if (!m_damage)
+ {
m_hitMask |= PROC_HIT_FULL_BLOCK;
+ m_hitMask &= ~(PROC_HIT_NORMAL | PROC_HIT_CRITICAL);
+ }
}
uint32 DamageInfo::GetHitMask() const
@@ -294,9 +304,6 @@ Unit::Unit(bool isWorldObject) :
m_transform = 0;
m_canModifyStats = false;
- for (uint8 i = 0; i < MAX_SPELL_IMMUNITY; ++i)
- m_spellImmune[i].clear();
-
for (uint8 i = 0; i < UNIT_MOD_END; ++i)
{
m_auraModifiersGroup[i][BASE_VALUE] = 0.0f;
@@ -646,7 +653,7 @@ bool Unit::HasBreakableByDamageCrowdControlAura(Unit* excludeCasterChannel) cons
|| HasBreakableByDamageAuraType(SPELL_AURA_TRANSFORM, excludeAura));
}
-void Unit::DealDamageMods(Unit* victim, uint32 &damage, uint32* absorb)
+void Unit::DealDamageMods(Unit const* victim, uint32 &damage, uint32* absorb) const
{
if (!victim || !victim->IsAlive() || victim->HasUnitState(UNIT_STATE_IN_FLIGHT) || (victim->GetTypeId() == TYPEID_UNIT && victim->ToCreature()->IsEvadingAttacks()))
{
@@ -967,7 +974,7 @@ void Unit::CastSpell(Unit* victim, uint32 spellId, bool triggered, Item* castIte
CastSpell(victim, spellId, triggered ? TRIGGERED_FULL_MASK : TRIGGERED_NONE, castItem, triggeredByAura, originalCaster);
}
-void Unit::CastSpell(Unit* victim, uint32 spellId, TriggerCastFlags triggerFlags /*= TRIGGER_NONE*/, Item* castItem /*= NULL*/, AuraEffect const* triggeredByAura /*= NULL*/, ObjectGuid originalCaster /*= ObjectGuid::Empty*/)
+void Unit::CastSpell(Unit* victim, uint32 spellId, TriggerCastFlags triggerFlags /*= TRIGGER_NONE*/, Item* castItem /*= nullptr*/, AuraEffect const* triggeredByAura /*= nullptr*/, ObjectGuid originalCaster /*= ObjectGuid::Empty*/)
{
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
if (!spellInfo)
@@ -979,7 +986,7 @@ void Unit::CastSpell(Unit* victim, uint32 spellId, TriggerCastFlags triggerFlags
CastSpell(victim, spellInfo, triggerFlags, castItem, triggeredByAura, originalCaster);
}
-void Unit::CastSpell(Unit* victim, SpellInfo const* spellInfo, bool triggered, Item* castItem/*= NULL*/, AuraEffect const* triggeredByAura /*= NULL*/, ObjectGuid originalCaster /*= ObjectGuid::Empty*/)
+void Unit::CastSpell(Unit* victim, SpellInfo const* spellInfo, bool triggered, Item* castItem/*= nullptr*/, AuraEffect const* triggeredByAura /*= nullptr*/, ObjectGuid originalCaster /*= ObjectGuid::Empty*/)
{
CastSpell(victim, spellInfo, triggered ? TRIGGERED_FULL_MASK : TRIGGERED_NONE, castItem, triggeredByAura, originalCaster);
}
@@ -988,7 +995,7 @@ void Unit::CastSpell(Unit* victim, SpellInfo const* spellInfo, TriggerCastFlags
{
SpellCastTargets targets;
targets.SetUnitTarget(victim);
- CastSpell(targets, spellInfo, NULL, triggerFlags, castItem, triggeredByAura, originalCaster);
+ CastSpell(targets, spellInfo, nullptr, triggerFlags, castItem, triggeredByAura, originalCaster);
}
void Unit::CastCustomSpell(Unit* target, uint32 spellId, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item* castItem, AuraEffect const* triggeredByAura, ObjectGuid originalCaster)
@@ -1042,10 +1049,10 @@ void Unit::CastSpell(float x, float y, float z, uint32 spellId, bool triggered,
SpellCastTargets targets;
targets.SetDst(x, y, z, GetOrientation());
- CastSpell(targets, spellInfo, NULL, triggered ? TRIGGERED_FULL_MASK : TRIGGERED_NONE, castItem, triggeredByAura, originalCaster);
+ CastSpell(targets, spellInfo, nullptr, triggered ? TRIGGERED_FULL_MASK : TRIGGERED_NONE, castItem, triggeredByAura, originalCaster);
}
-void Unit::CastSpell(GameObject* go, uint32 spellId, bool triggered, Item* castItem, AuraEffect* triggeredByAura, ObjectGuid originalCaster)
+void Unit::CastSpell(float x, float y, float z, uint32 spellId, TriggerCastFlags triggerFlags, Item* castItem, AuraEffect const* triggeredByAura, ObjectGuid originalCaster)
{
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
if (!spellInfo)
@@ -1054,26 +1061,23 @@ void Unit::CastSpell(GameObject* go, uint32 spellId, bool triggered, Item* castI
return;
}
SpellCastTargets targets;
- targets.SetGOTarget(go);
+ targets.SetDst(x, y, z, GetOrientation());
- CastSpell(targets, spellInfo, NULL, triggered ? TRIGGERED_FULL_MASK : TRIGGERED_NONE, castItem, triggeredByAura, originalCaster);
+ CastSpell(targets, spellInfo, nullptr, triggerFlags, castItem, triggeredByAura, originalCaster);
}
-// Obsolete func need remove, here only for comotability vs another patches
-uint32 Unit::SpellNonMeleeDamageLog(Unit* victim, uint32 spellID, uint32 damage)
+void Unit::CastSpell(GameObject* go, uint32 spellId, bool triggered, Item* castItem, AuraEffect* triggeredByAura, ObjectGuid originalCaster)
{
- SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellID);
+ SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
if (!spellInfo)
- return 0;
- SpellNonMeleeDamage damageInfo(this, victim, spellInfo->Id, spellInfo->SchoolMask);
- damage = SpellDamageBonusDone(victim, spellInfo, damage, SPELL_DIRECT_DAMAGE);
- damage = victim->SpellDamageBonusTaken(this, spellInfo, damage, SPELL_DIRECT_DAMAGE);
+ {
+ TC_LOG_ERROR("entities.unit", "CastSpell: unknown spell id %u by caster: %s %u)", spellId, (GetTypeId() == TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"), (GetTypeId() == TYPEID_PLAYER ? GetGUID().GetCounter() : GetEntry()));
+ return;
+ }
+ SpellCastTargets targets;
+ targets.SetGOTarget(go);
- CalculateSpellDamageTaken(&damageInfo, damage, spellInfo);
- DealDamageMods(damageInfo.target, damageInfo.damage, &damageInfo.absorb);
- SendSpellNonMeleeDamageLog(&damageInfo);
- DealSpellDamage(&damageInfo, true);
- return damageInfo.damage;
+ CastSpell(targets, spellInfo, nullptr, triggered ? TRIGGERED_FULL_MASK : TRIGGERED_NONE, castItem, triggeredByAura, originalCaster);
}
void Unit::CalculateSpellDamageTaken(SpellNonMeleeDamage* damageInfo, int32 damage, SpellInfo const* spellInfo, WeaponAttackType attackType, bool crit)
@@ -1144,8 +1148,11 @@ void Unit::CalculateSpellDamageTaken(SpellNonMeleeDamage* damageInfo, int32 dama
// double blocked amount if block is critical
if (victim->isBlockCritical())
damageInfo->blocked += damageInfo->blocked;
- if (damage < int32(damageInfo->blocked))
+ if (damage <= int32(damageInfo->blocked))
+ {
damageInfo->blocked = uint32(damage);
+ damageInfo->fullBlock = true;
+ }
damage -= damageInfo->blocked;
}
@@ -1155,7 +1162,7 @@ void Unit::CalculateSpellDamageTaken(SpellNonMeleeDamage* damageInfo, int32 dama
ApplyResilience(victim, nullptr, &damage, crit, CR_CRIT_TAKEN_RANGED);
break;
}
- // Magical Attacks
+ // Magical Attacks
case SPELL_DAMAGE_CLASS_NONE:
case SPELL_DAMAGE_CLASS_MAGIC:
{
@@ -1178,24 +1185,30 @@ void Unit::CalculateSpellDamageTaken(SpellNonMeleeDamage* damageInfo, int32 dama
sScriptMgr->ModifySpellDamageTaken(damageInfo->target, damageInfo->attacker, damage);
// Calculate absorb resist
- if (damage > 0)
- {
- CalcAbsorbResist(victim, damageSchoolMask, SPELL_DIRECT_DAMAGE, damage, &damageInfo->absorb, &damageInfo->resist, spellInfo);
- damage -= damageInfo->absorb + damageInfo->resist;
- }
- else
+ if (damage < 0)
damage = 0;
damageInfo->damage = damage;
+ DamageInfo dmgInfo(*damageInfo, SPELL_DIRECT_DAMAGE, BASE_ATTACK, PROC_HIT_NONE);
+ CalcAbsorbResist(dmgInfo);
+ damageInfo->absorb = dmgInfo.GetAbsorb();
+ damageInfo->resist = dmgInfo.GetResist();
+
+ if (damageInfo->absorb)
+ damageInfo->HitInfo |= (damageInfo->damage - damageInfo->absorb == 0 ? HITINFO_FULL_ABSORB : HITINFO_PARTIAL_ABSORB);
+
+ if (damageInfo->resist)
+ damageInfo->HitInfo |= (damageInfo->damage - damageInfo->resist == 0 ? HITINFO_FULL_RESIST : HITINFO_PARTIAL_RESIST);
+
+ damageInfo->damage = dmgInfo.GetDamage();
}
void Unit::DealSpellDamage(SpellNonMeleeDamage* damageInfo, bool durabilityLoss)
{
- if (damageInfo == 0)
+ if (!damageInfo)
return;
Unit* victim = damageInfo->target;
-
if (!victim)
return;
@@ -1396,7 +1409,10 @@ void Unit::CalculateMeleeDamage(Unit* victim, uint32 damage, CalcDamageInfo* dam
{
damageInfo->procVictim |= PROC_FLAG_TAKEN_DAMAGE;
// Calculate absorb & resists
- CalcAbsorbResist(damageInfo->target, SpellSchoolMask(damageInfo->damageSchoolMask), DIRECT_DAMAGE, damageInfo->damage, &damageInfo->absorb, &damageInfo->resist);
+ DamageInfo dmgInfo(*damageInfo);
+ CalcAbsorbResist(dmgInfo);
+ damageInfo->absorb = dmgInfo.GetAbsorb();
+ damageInfo->resist = dmgInfo.GetResist();
if (damageInfo->absorb)
damageInfo->HitInfo |= (damageInfo->damage - damageInfo->absorb == 0 ? HITINFO_FULL_ABSORB : HITINFO_PARTIAL_ABSORB);
@@ -1404,7 +1420,7 @@ void Unit::CalculateMeleeDamage(Unit* victim, uint32 damage, CalcDamageInfo* dam
if (damageInfo->resist)
damageInfo->HitInfo |= (damageInfo->damage - damageInfo->resist == 0 ? HITINFO_FULL_RESIST : HITINFO_PARTIAL_RESIST);
- damageInfo->damage -= damageInfo->absorb + damageInfo->resist;
+ damageInfo->damage = dmgInfo.GetDamage();
}
else // Impossible get negative result but....
damageInfo->damage = 0;
@@ -1500,46 +1516,47 @@ void Unit::DealMeleeDamage(CalcDamageInfo* damageInfo, bool durabilityLoss)
// We're going to call functions which can modify content of the list during iteration over it's elements
// Let's copy the list so we can prevent iterator invalidation
AuraEffectList vDamageShieldsCopy(victim->GetAuraEffectsByType(SPELL_AURA_DAMAGE_SHIELD));
- for (AuraEffectList::const_iterator dmgShieldItr = vDamageShieldsCopy.begin(); dmgShieldItr != vDamageShieldsCopy.end(); ++dmgShieldItr)
+ for (AuraEffect const* aurEff : vDamageShieldsCopy)
{
- SpellInfo const* i_spellProto = (*dmgShieldItr)->GetSpellInfo();
+ SpellInfo const* spellInfo = aurEff->GetSpellInfo();
+
// Damage shield can be resisted...
- if (SpellMissInfo missInfo = victim->SpellHitResult(this, i_spellProto, false))
+ SpellMissInfo missInfo = victim->SpellHitResult(this, spellInfo, false);
+ if (missInfo != SPELL_MISS_NONE)
{
- victim->SendSpellMiss(this, i_spellProto->Id, missInfo);
+ victim->SendSpellMiss(this, spellInfo->Id, missInfo);
continue;
}
// ...or immuned
- if (IsImmunedToDamage(i_spellProto))
+ if (IsImmunedToDamage(spellInfo))
{
- victim->SendSpellDamageImmune(this, i_spellProto->Id);
+ victim->SendSpellDamageImmune(this, spellInfo->Id);
continue;
}
- uint32 damage = (*dmgShieldItr)->GetAmount();
-
- if (Unit* caster = (*dmgShieldItr)->GetCaster())
+ uint32 damage = aurEff->GetAmount();
+ if (Unit* caster = aurEff->GetCaster())
{
- damage = caster->SpellDamageBonusDone(this, i_spellProto, damage, SPELL_DIRECT_DAMAGE);
- damage = this->SpellDamageBonusTaken(caster, i_spellProto, damage, SPELL_DIRECT_DAMAGE);
+ damage = caster->SpellDamageBonusDone(this, spellInfo, damage, SPELL_DIRECT_DAMAGE);
+ damage = SpellDamageBonusTaken(caster, spellInfo, damage, SPELL_DIRECT_DAMAGE);
}
// No Unit::CalcAbsorbResist here - opcode doesn't send that data - this damage is probably not affected by that
- victim->DealDamageMods(this, damage, NULL);
+ victim->DealDamageMods(this, damage, nullptr);
/// @todo Move this to a packet handler
WorldPacket data(SMSG_SPELLDAMAGESHIELD, 8 + 8 + 4 + 4 + 4 + 4 + 4);
data << uint64(victim->GetGUID());
data << uint64(GetGUID());
- data << uint32(i_spellProto->Id);
+ data << uint32(spellInfo->Id);
data << uint32(damage); // Damage
- int32 overkill = int32(damage) - int32(GetHealth());
- data << uint32(overkill > 0 ? overkill : 0); // Overkill
- data << uint32(i_spellProto->SchoolMask);
+ int32 const overkill = int32(damage) - int32(GetHealth());
+ data << uint32(std::max(overkill, 0)); // Overkill
+ data << uint32(spellInfo->SchoolMask);
victim->SendMessageToSet(&data, true);
- victim->DealDamage(this, damage, 0, SPELL_DIRECT_DAMAGE, i_spellProto->GetSchoolMask(), i_spellProto, true);
+ victim->DealDamage(this, damage, nullptr, SPELL_DIRECT_DAMAGE, spellInfo->GetSchoolMask(), spellInfo, true);
}
}
}
@@ -1731,57 +1748,49 @@ uint32 Unit::CalcSpellResistance(Unit* victim, SpellSchoolMask schoolMask, Spell
return resistance * 10;
}
-void Unit::CalcAbsorbResist(Unit* victim, SpellSchoolMask schoolMask, DamageEffectType damagetype, uint32 const damage, uint32* absorb, uint32* resist, SpellInfo const* spellInfo /*= NULL*/)
+void Unit::CalcAbsorbResist(DamageInfo& damageInfo)
{
- if (!victim || !victim->IsAlive() || !damage)
+ if (!damageInfo.GetVictim() || !damageInfo.GetVictim()->IsAlive() || !damageInfo.GetDamage())
return;
- DamageInfo dmgInfo = DamageInfo(this, victim, damage, spellInfo, schoolMask, damagetype, BASE_ATTACK);
-
- uint32 spellResistance = CalcSpellResistance(victim, schoolMask, spellInfo);
- dmgInfo.ResistDamage(CalculatePct(damage, spellResistance));
+ uint32 spellResistance = CalcSpellResistance(damageInfo.GetVictim(), damageInfo.GetSchoolMask(), damageInfo.GetSpellInfo());
+ damageInfo.ResistDamage(CalculatePct(damageInfo.GetDamage(), spellResistance));
// Ignore Absorption Auras
- float auraAbsorbMod = 0;
- AuraEffectList const& AbsIgnoreAurasA = GetAuraEffectsByType(SPELL_AURA_MOD_TARGET_ABSORB_SCHOOL);
- for (AuraEffectList::const_iterator itr = AbsIgnoreAurasA.begin(); itr != AbsIgnoreAurasA.end(); ++itr)
+ float auraAbsorbMod(GetMaxPositiveAuraModifierByMiscMask(SPELL_AURA_MOD_TARGET_ABSORB_SCHOOL, damageInfo.GetSchoolMask()));
+
+ AuraEffectList const& abilityAbsorbAuras = GetAuraEffectsByType(SPELL_AURA_MOD_TARGET_ABILITY_ABSORB_SCHOOL);
+ for (AuraEffect const* aurEff : abilityAbsorbAuras)
{
- if (!((*itr)->GetMiscValue() & schoolMask))
+ if (!(aurEff->GetMiscValue() & damageInfo.GetSchoolMask()))
continue;
- if ((*itr)->GetAmount() > auraAbsorbMod)
- auraAbsorbMod = float((*itr)->GetAmount());
- }
-
- AuraEffectList const& AbsIgnoreAurasB = GetAuraEffectsByType(SPELL_AURA_MOD_TARGET_ABILITY_ABSORB_SCHOOL);
- for (AuraEffectList::const_iterator itr = AbsIgnoreAurasB.begin(); itr != AbsIgnoreAurasB.end(); ++itr)
- {
- if (!((*itr)->GetMiscValue() & schoolMask))
+ if (!aurEff->IsAffectedOnSpell(damageInfo.GetSpellInfo()))
continue;
- if (((*itr)->GetAmount() > auraAbsorbMod) && (*itr)->IsAffectedOnSpell(spellInfo))
- auraAbsorbMod = float((*itr)->GetAmount());
+ if ((aurEff->GetAmount() > auraAbsorbMod))
+ auraAbsorbMod = float(aurEff->GetAmount());
}
RoundToInterval(auraAbsorbMod, 0.0f, 100.0f);
- int32 absorbIgnoringDamage = CalculatePct(dmgInfo.GetDamage(), auraAbsorbMod);
- dmgInfo.ModifyDamage(-absorbIgnoringDamage);
+ int32 absorbIgnoringDamage = CalculatePct(damageInfo.GetDamage(), auraAbsorbMod);
+ damageInfo.ModifyDamage(-absorbIgnoringDamage);
// We're going to call functions which can modify content of the list during iteration over it's elements
// Let's copy the list so we can prevent iterator invalidation
- AuraEffectList vSchoolAbsorbCopy(victim->GetAuraEffectsByType(SPELL_AURA_SCHOOL_ABSORB));
+ AuraEffectList vSchoolAbsorbCopy(damageInfo.GetVictim()->GetAuraEffectsByType(SPELL_AURA_SCHOOL_ABSORB));
vSchoolAbsorbCopy.sort(Trinity::AbsorbAuraOrderPred());
// absorb without mana cost
- for (AuraEffectList::iterator itr = vSchoolAbsorbCopy.begin(); (itr != vSchoolAbsorbCopy.end()) && (dmgInfo.GetDamage() > 0); ++itr)
+ for (AuraEffectList::iterator itr = vSchoolAbsorbCopy.begin(); (itr != vSchoolAbsorbCopy.end()) && (damageInfo.GetDamage() > 0); ++itr)
{
AuraEffect* absorbAurEff = *itr;
// Check if aura was removed during iteration - we don't need to work on such auras
- AuraApplication const* aurApp = absorbAurEff->GetBase()->GetApplicationOfTarget(victim->GetGUID());
+ AuraApplication const* aurApp = absorbAurEff->GetBase()->GetApplicationOfTarget(damageInfo.GetVictim()->GetGUID());
if (!aurApp)
continue;
- if (!(absorbAurEff->GetMiscValue() & schoolMask))
+ if (!(absorbAurEff->GetMiscValue() & damageInfo.GetSchoolMask()))
continue;
// get amount which can be still absorbed by the aura
@@ -1794,19 +1803,19 @@ void Unit::CalcAbsorbResist(Unit* victim, SpellSchoolMask schoolMask, DamageEffe
bool defaultPrevented = false;
- absorbAurEff->GetBase()->CallScriptEffectAbsorbHandlers(absorbAurEff, aurApp, dmgInfo, tempAbsorb, defaultPrevented);
+ absorbAurEff->GetBase()->CallScriptEffectAbsorbHandlers(absorbAurEff, aurApp, damageInfo, tempAbsorb, defaultPrevented);
currentAbsorb = tempAbsorb;
if (defaultPrevented)
continue;
// absorb must be smaller than the damage itself
- currentAbsorb = RoundToInterval(currentAbsorb, 0, int32(dmgInfo.GetDamage()));
+ currentAbsorb = RoundToInterval(currentAbsorb, 0, int32(damageInfo.GetDamage()));
- dmgInfo.AbsorbDamage(currentAbsorb);
+ damageInfo.AbsorbDamage(currentAbsorb);
tempAbsorb = currentAbsorb;
- absorbAurEff->GetBase()->CallScriptEffectAfterAbsorbHandlers(absorbAurEff, aurApp, dmgInfo, tempAbsorb);
+ absorbAurEff->GetBase()->CallScriptEffectAfterAbsorbHandlers(absorbAurEff, aurApp, damageInfo, tempAbsorb);
// Check if our aura is using amount to count damage
if (absorbAurEff->GetAmount() >= 0)
@@ -1820,16 +1829,16 @@ void Unit::CalcAbsorbResist(Unit* victim, SpellSchoolMask schoolMask, DamageEffe
}
// absorb by mana cost
- AuraEffectList vManaShieldCopy(victim->GetAuraEffectsByType(SPELL_AURA_MANA_SHIELD));
- for (AuraEffectList::const_iterator itr = vManaShieldCopy.begin(); (itr != vManaShieldCopy.end()) && (dmgInfo.GetDamage() > 0); ++itr)
+ AuraEffectList vManaShieldCopy(damageInfo.GetVictim()->GetAuraEffectsByType(SPELL_AURA_MANA_SHIELD));
+ for (AuraEffectList::const_iterator itr = vManaShieldCopy.begin(); (itr != vManaShieldCopy.end()) && (damageInfo.GetDamage() > 0); ++itr)
{
AuraEffect* absorbAurEff = *itr;
// Check if aura was removed during iteration - we don't need to work on such auras
- AuraApplication const* aurApp = absorbAurEff->GetBase()->GetApplicationOfTarget(victim->GetGUID());
+ AuraApplication const* aurApp = absorbAurEff->GetBase()->GetApplicationOfTarget(damageInfo.GetVictim()->GetGUID());
if (!aurApp)
continue;
// check damage school mask
- if (!(absorbAurEff->GetMiscValue() & schoolMask))
+ if (!(absorbAurEff->GetMiscValue() & damageInfo.GetSchoolMask()))
continue;
// get amount which can be still absorbed by the aura
@@ -1842,14 +1851,14 @@ void Unit::CalcAbsorbResist(Unit* victim, SpellSchoolMask schoolMask, DamageEffe
bool defaultPrevented = false;
- absorbAurEff->GetBase()->CallScriptEffectManaShieldHandlers(absorbAurEff, aurApp, dmgInfo, tempAbsorb, defaultPrevented);
+ absorbAurEff->GetBase()->CallScriptEffectManaShieldHandlers(absorbAurEff, aurApp, damageInfo, tempAbsorb, defaultPrevented);
currentAbsorb = tempAbsorb;
if (defaultPrevented)
continue;
// absorb must be smaller than the damage itself
- currentAbsorb = RoundToInterval(currentAbsorb, 0, int32(dmgInfo.GetDamage()));
+ currentAbsorb = RoundToInterval(currentAbsorb, 0, int32(damageInfo.GetDamage()));
int32 manaReduction = currentAbsorb;
@@ -1857,15 +1866,15 @@ void Unit::CalcAbsorbResist(Unit* victim, SpellSchoolMask schoolMask, DamageEffe
if (float manaMultiplier = absorbAurEff->GetSpellInfo()->Effects[absorbAurEff->GetEffIndex()].CalcValueMultiplier(absorbAurEff->GetCaster()))
manaReduction = int32(float(manaReduction) * manaMultiplier);
- int32 manaTaken = -victim->ModifyPower(POWER_MANA, -manaReduction);
+ int32 manaTaken = -damageInfo.GetVictim()->ModifyPower(POWER_MANA, -manaReduction);
// take case when mana has ended up into account
currentAbsorb = currentAbsorb ? int32(float(currentAbsorb) * (float(manaTaken) / float(manaReduction))) : 0;
- dmgInfo.AbsorbDamage(currentAbsorb);
+ damageInfo.AbsorbDamage(currentAbsorb);
tempAbsorb = currentAbsorb;
- absorbAurEff->GetBase()->CallScriptEffectAfterManaShieldHandlers(absorbAurEff, aurApp, dmgInfo, tempAbsorb);
+ absorbAurEff->GetBase()->CallScriptEffectAfterManaShieldHandlers(absorbAurEff, aurApp, damageInfo, tempAbsorb);
// Check if our aura is using amount to count damage
if (absorbAurEff->GetAmount() >= 0)
@@ -1876,39 +1885,39 @@ void Unit::CalcAbsorbResist(Unit* victim, SpellSchoolMask schoolMask, DamageEffe
}
}
- dmgInfo.ModifyDamage(absorbIgnoringDamage);
+ damageInfo.ModifyDamage(absorbIgnoringDamage);
// split damage auras - only when not damaging self
- if (victim != this)
+ if (damageInfo.GetVictim() != this)
{
// We're going to call functions which can modify content of the list during iteration over it's elements
// Let's copy the list so we can prevent iterator invalidation
- AuraEffectList vSplitDamageFlatCopy(victim->GetAuraEffectsByType(SPELL_AURA_SPLIT_DAMAGE_FLAT));
- for (AuraEffectList::iterator itr = vSplitDamageFlatCopy.begin(); (itr != vSplitDamageFlatCopy.end()) && (dmgInfo.GetDamage() > 0); ++itr)
+ AuraEffectList vSplitDamageFlatCopy(damageInfo.GetVictim()->GetAuraEffectsByType(SPELL_AURA_SPLIT_DAMAGE_FLAT));
+ for (AuraEffectList::iterator itr = vSplitDamageFlatCopy.begin(); (itr != vSplitDamageFlatCopy.end()) && (damageInfo.GetDamage() > 0); ++itr)
{
// Check if aura was removed during iteration - we don't need to work on such auras
- if (!((*itr)->GetBase()->IsAppliedOnTarget(victim->GetGUID())))
+ if (!((*itr)->GetBase()->IsAppliedOnTarget(damageInfo.GetVictim()->GetGUID())))
continue;
// check damage school mask
- if (!((*itr)->GetMiscValue() & schoolMask))
+ if (!((*itr)->GetMiscValue() & damageInfo.GetSchoolMask()))
continue;
// Damage can be splitted only if aura has an alive caster
Unit* caster = (*itr)->GetCaster();
- if (!caster || (caster == victim) || !caster->IsInWorld() || !caster->IsAlive())
+ if (!caster || (caster == damageInfo.GetVictim()) || !caster->IsInWorld() || !caster->IsAlive())
continue;
int32 splitDamage = (*itr)->GetAmount();
// absorb must be smaller than the damage itself
- splitDamage = RoundToInterval(splitDamage, 0, int32(dmgInfo.GetDamage()));
+ splitDamage = RoundToInterval(splitDamage, 0, int32(damageInfo.GetDamage()));
- dmgInfo.AbsorbDamage(splitDamage);
+ damageInfo.AbsorbDamage(splitDamage);
// check if caster is immune to damage
- if (caster->IsImmunedToDamage(schoolMask))
+ if (caster->IsImmunedToDamage(damageInfo.GetSchoolMask()))
{
- victim->SendSpellMiss(caster, (*itr)->GetSpellInfo()->Id, SPELL_MISS_IMMUNE);
+ damageInfo.GetVictim()->SendSpellMiss(caster, (*itr)->GetSpellInfo()->Id, SPELL_MISS_IMMUNE);
continue;
}
@@ -1916,66 +1925,62 @@ void Unit::CalcAbsorbResist(Unit* victim, SpellSchoolMask schoolMask, DamageEffe
uint32 splitted_absorb = 0;
DealDamageMods(caster, splitted, &splitted_absorb);
- SendSpellNonMeleeDamageLog(caster, (*itr)->GetSpellInfo()->Id, splitted, schoolMask, splitted_absorb, 0, false, 0, false);
+ SendSpellNonMeleeDamageLog(caster, (*itr)->GetSpellInfo()->Id, splitted, damageInfo.GetSchoolMask(), splitted_absorb, 0, false, 0, false);
CleanDamage cleanDamage = CleanDamage(splitted, 0, BASE_ATTACK, MELEE_HIT_NORMAL);
- DealDamage(caster, splitted, &cleanDamage, DIRECT_DAMAGE, schoolMask, (*itr)->GetSpellInfo(), false);
+ DealDamage(caster, splitted, &cleanDamage, DIRECT_DAMAGE, damageInfo.GetSchoolMask(), (*itr)->GetSpellInfo(), false);
}
// We're going to call functions which can modify content of the list during iteration over it's elements
// Let's copy the list so we can prevent iterator invalidation
- AuraEffectList vSplitDamagePctCopy(victim->GetAuraEffectsByType(SPELL_AURA_SPLIT_DAMAGE_PCT));
- for (AuraEffectList::iterator itr = vSplitDamagePctCopy.begin(); itr != vSplitDamagePctCopy.end() && dmgInfo.GetDamage() > 0; ++itr)
+ AuraEffectList vSplitDamagePctCopy(damageInfo.GetVictim()->GetAuraEffectsByType(SPELL_AURA_SPLIT_DAMAGE_PCT));
+ for (AuraEffectList::iterator itr = vSplitDamagePctCopy.begin(); itr != vSplitDamagePctCopy.end() && damageInfo.GetDamage() > 0; ++itr)
{
// Check if aura was removed during iteration - we don't need to work on such auras
- AuraApplication const* aurApp = (*itr)->GetBase()->GetApplicationOfTarget(victim->GetGUID());
+ AuraApplication const* aurApp = (*itr)->GetBase()->GetApplicationOfTarget(damageInfo.GetVictim()->GetGUID());
if (!aurApp)
continue;
// check damage school mask
- if (!((*itr)->GetMiscValue() & schoolMask))
+ if (!((*itr)->GetMiscValue() & damageInfo.GetSchoolMask()))
continue;
// Damage can be splitted only if aura has an alive caster
Unit* caster = (*itr)->GetCaster();
- if (!caster || (caster == victim) || !caster->IsInWorld() || !caster->IsAlive())
+ if (!caster || (caster == damageInfo.GetVictim()) || !caster->IsInWorld() || !caster->IsAlive())
continue;
- uint32 splitDamage = CalculatePct(dmgInfo.GetDamage(), (*itr)->GetAmount());
+ uint32 splitDamage = CalculatePct(damageInfo.GetDamage(), (*itr)->GetAmount());
- (*itr)->GetBase()->CallScriptEffectSplitHandlers((*itr), aurApp, dmgInfo, splitDamage);
+ (*itr)->GetBase()->CallScriptEffectSplitHandlers((*itr), aurApp, damageInfo, splitDamage);
// absorb must be smaller than the damage itself
- splitDamage = RoundToInterval(splitDamage, uint32(0), uint32(dmgInfo.GetDamage()));
+ splitDamage = RoundToInterval(splitDamage, uint32(0), uint32(damageInfo.GetDamage()));
- dmgInfo.AbsorbDamage(splitDamage);
+ damageInfo.AbsorbDamage(splitDamage);
// check if caster is immune to damage
- if (caster->IsImmunedToDamage(schoolMask))
+ if (caster->IsImmunedToDamage(damageInfo.GetSchoolMask()))
{
- victim->SendSpellMiss(caster, (*itr)->GetSpellInfo()->Id, SPELL_MISS_IMMUNE);
+ damageInfo.GetVictim()->SendSpellMiss(caster, (*itr)->GetSpellInfo()->Id, SPELL_MISS_IMMUNE);
continue;
}
uint32 split_absorb = 0;
DealDamageMods(caster, splitDamage, &split_absorb);
- SendSpellNonMeleeDamageLog(caster, (*itr)->GetSpellInfo()->Id, splitDamage, schoolMask, split_absorb, 0, false, 0, false);
+ SendSpellNonMeleeDamageLog(caster, (*itr)->GetSpellInfo()->Id, splitDamage, damageInfo.GetSchoolMask(), split_absorb, 0, false, 0, false);
CleanDamage cleanDamage = CleanDamage(splitDamage, 0, BASE_ATTACK, MELEE_HIT_NORMAL);
- DealDamage(caster, splitDamage, &cleanDamage, DIRECT_DAMAGE, schoolMask, (*itr)->GetSpellInfo(), false);
+ DealDamage(caster, splitDamage, &cleanDamage, DIRECT_DAMAGE, damageInfo.GetSchoolMask(), (*itr)->GetSpellInfo(), false);
// break 'Fear' and similar auras
- DamageInfo damageInfo(caster, this, splitDamage, (*itr)->GetSpellInfo(), schoolMask, DIRECT_DAMAGE, BASE_ATTACK);
ProcSkillsAndAuras(caster, PROC_FLAG_NONE, PROC_FLAG_TAKEN_SPELL_MAGIC_DMG_CLASS_NEG, PROC_SPELL_TYPE_DAMAGE, PROC_SPELL_PHASE_HIT, PROC_HIT_NONE, nullptr, &damageInfo, nullptr);
}
}
-
- *resist = dmgInfo.GetResist();
- *absorb = dmgInfo.GetAbsorb();
}
-void Unit::CalcHealAbsorb(HealInfo& healInfo)
+void Unit::CalcHealAbsorb(HealInfo& healInfo) const
{
if (!healInfo.GetHeal())
return;
@@ -2086,15 +2091,56 @@ void Unit::AttackerStateUpdate(Unit* victim, WeaponAttackType attType, bool extr
}
}
+void Unit::FakeAttackerStateUpdate(Unit* victim, WeaponAttackType attType /*= BASE_ATTACK*/)
+{
+ if (HasUnitState(UNIT_STATE_CANNOT_AUTOATTACK) || HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED))
+ return;
+
+ if (!victim->IsAlive())
+ return;
+
+ if ((attType == BASE_ATTACK || attType == OFF_ATTACK) && !IsWithinLOSInMap(victim))
+ return;
+
+ CombatStart(victim);
+ RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_MELEE_ATTACK);
+
+ if (attType != BASE_ATTACK && attType != OFF_ATTACK)
+ return; // ignore ranged case
+
+ if (GetTypeId() == TYPEID_UNIT && !HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED))
+ SetFacingToObject(victim); // update client side facing to face the target (prevents visual glitches when casting untargeted spells)
+
+ CalcDamageInfo damageInfo;
+ damageInfo.attacker = this;
+ damageInfo.target = victim;
+ damageInfo.damageSchoolMask = GetMeleeDamageSchoolMask();
+ damageInfo.attackType = attType;
+ damageInfo.damage = 0;
+ damageInfo.cleanDamage = 0;
+ damageInfo.absorb = 0;
+ damageInfo.resist = 0;
+ damageInfo.blocked_amount = 0;
+
+ damageInfo.TargetState = VICTIMSTATE_HIT;
+ damageInfo.HitInfo = HITINFO_AFFECTS_VICTIM | HITINFO_NORMALSWING | HITINFO_FAKE_DAMAGE;
+ if (attType == OFF_ATTACK)
+ damageInfo.HitInfo |= HITINFO_OFFHAND;
+
+ damageInfo.procAttacker = PROC_FLAG_NONE;
+ damageInfo.procVictim = PROC_FLAG_NONE;
+ damageInfo.hitOutCome = MELEE_HIT_NORMAL;
+
+ SendAttackStateUpdate(&damageInfo);
+}
+
void Unit::HandleProcExtraAttackFor(Unit* victim)
{
- while (m_extraAttacks > 0)
+ while (m_extraAttacks)
{
AttackerStateUpdate(victim, BASE_ATTACK, true);
--m_extraAttacks;
}
-
- m_extraAttacks = 0;
}
MeleeHitOutcome Unit::RollMeleeOutcomeAgainst(Unit const* victim, WeaponAttackType attType) const
@@ -2323,7 +2369,7 @@ void Unit::SendMeleeAttackStop(Unit* victim)
bool Unit::isSpellBlocked(Unit* victim, SpellInfo const* spellProto, WeaponAttackType attackType)
{
// These spells can't be blocked
- if (spellProto && spellProto->HasAttribute(SPELL_ATTR0_IMPOSSIBLE_DODGE_PARRY_BLOCK))
+ if (spellProto && (spellProto->HasAttribute(SPELL_ATTR0_IMPOSSIBLE_DODGE_PARRY_BLOCK) || spellProto->HasAttribute(SPELL_ATTR3_IGNORE_HIT_RESULT)))
return false;
// Can't block when casting/controlled
@@ -2332,13 +2378,8 @@ bool Unit::isSpellBlocked(Unit* victim, SpellInfo const* spellProto, WeaponAttac
if (victim->HasAuraType(SPELL_AURA_IGNORE_HIT_DIRECTION) || victim->HasInArc(float(M_PI), this))
{
- // Check creatures flags_extra for disable block
- if (victim->GetTypeId() == TYPEID_UNIT &&
- victim->ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_NO_BLOCK)
- return false;
-
float blockChance = GetUnitBlockChance(attackType, victim);
- if (roll_chance_f(blockChance))
+ if (blockChance && roll_chance_f(blockChance))
return true;
}
@@ -2393,11 +2434,6 @@ bool Unit::CanUseAttackType(uint8 attacktype) const
// Melee based spells hit result calculations
SpellMissInfo Unit::MeleeSpellHitResult(Unit* victim, SpellInfo const* spellInfo) const
{
- // Spells with SPELL_ATTR3_IGNORE_HIT_RESULT will additionally fully ignore
- // resist and deflect chances
- if (spellInfo->HasAttribute(SPELL_ATTR3_IGNORE_HIT_RESULT))
- return SPELL_MISS_NONE;
-
WeaponAttackType attType = BASE_ATTACK;
// Check damage class instead of attack type to correctly handle judgements
@@ -2451,7 +2487,7 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit* victim, SpellInfo const* spellInfo
canDodge = false;
// only if in front
- if (victim->HasInArc(float(M_PI), this) || victim->HasAuraType(SPELL_AURA_IGNORE_HIT_DIRECTION))
+ if (!victim->HasUnitState(UNIT_STATE_CONTROLLED) && (victim->HasInArc(float(M_PI), this) || victim->HasAuraType(SPELL_AURA_IGNORE_HIT_DIRECTION)))
{
int32 deflect_chance = victim->GetTotalAuraModifier(SPELL_AURA_DEFLECT_SPELLS) * 100;
tmp += deflect_chance;
@@ -2545,7 +2581,7 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit* victim, SpellInfo const* spellInfo
SpellMissInfo Unit::MagicSpellHitResult(Unit* victim, SpellInfo const* spellInfo) const
{
// Can`t miss on dead target (on skinning for example)
- if ((!victim->IsAlive() && victim->GetTypeId() != TYPEID_PLAYER) || spellInfo->HasAttribute(SPELL_ATTR3_IGNORE_HIT_RESULT))
+ if ((!victim->IsAlive() && victim->GetTypeId() != TYPEID_PLAYER))
return SPELL_MISS_NONE;
SpellSchoolMask schoolMask = spellInfo->GetSchoolMask();
@@ -2588,8 +2624,7 @@ SpellMissInfo Unit::MagicSpellHitResult(Unit* victim, SpellInfo const* spellInfo
int32 tmp = 10000 - HitChance;
- int32 rand = irand(0, 10000);
-
+ int32 rand = irand(0, 9999);
if (rand < tmp)
return SPELL_MISS_MISS;
@@ -2611,10 +2646,7 @@ SpellMissInfo Unit::MagicSpellHitResult(Unit* victim, SpellInfo const* spellInfo
}
if (hasAura)
- {
- tmp += victim->GetMaxPositiveAuraModifierByMiscValue(SPELL_AURA_MOD_DEBUFF_RESISTANCE, int32(spellInfo->Dispel)) * 100;
- tmp += victim->GetMaxNegativeAuraModifierByMiscValue(SPELL_AURA_MOD_DEBUFF_RESISTANCE, int32(spellInfo->Dispel)) * 100;
- }
+ tmp += victim->GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_DEBUFF_RESISTANCE, static_cast<int32>(spellInfo->Dispel)) * 100;
}
// Roll chance
@@ -2643,19 +2675,23 @@ SpellMissInfo Unit::MagicSpellHitResult(Unit* victim, SpellInfo const* spellInfo
// Resist
SpellMissInfo Unit::SpellHitResult(Unit* victim, SpellInfo const* spellInfo, bool CanReflect)
{
+ if (spellInfo->HasAttribute(SPELL_ATTR3_IGNORE_HIT_RESULT))
+ return SPELL_MISS_NONE;
+
// Check for immune
if (victim->IsImmunedToSpell(spellInfo))
return SPELL_MISS_IMMUNE;
+ // Damage immunity is only checked if the spell has damage effects, this immunity must not prevent aura apply
+ // returns SPELL_MISS_IMMUNE in that case, for other spells, the SMSG_SPELL_GO must show hit
+ if (spellInfo->HasOnlyDamageEffects() && victim->IsImmunedToDamage(spellInfo))
+ return SPELL_MISS_IMMUNE;
+
// All positive spells can`t miss
/// @todo client not show miss log for this spells - so need find info for this in dbc and use it!
if (spellInfo->IsPositive() && !IsHostileTo(victim)) // prevent from affecting enemy by "positive" spell
return SPELL_MISS_NONE;
- // Check for immune
- if (victim->IsImmunedToDamage(spellInfo))
- return SPELL_MISS_IMMUNE;
-
if (this == victim)
return SPELL_MISS_NONE;
@@ -2789,9 +2825,9 @@ float Unit::GetUnitParryChance(WeaponAttackType attType, Unit const* victim) con
skillBonus = 0.04f * skillDiff;
}
}
- else if (victim->GetTypeId() == TYPEID_UNIT && !(victim->ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_NO_PARRY))
+ else
{
- if (victim->GetCreatureType() == CREATURE_TYPE_HUMANOID)
+ if (!victim->IsTotem() && !(victim->ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_NO_PARRY))
{
chance = 5.0f;
chance += victim->GetTotalAuraModifier(SPELL_AURA_MOD_PARRY_PERCENT);
@@ -2869,8 +2905,8 @@ float Unit::GetUnitBlockChance(WeaponAttackType attType, Unit const* victim) con
float Unit::GetUnitCriticalChance(WeaponAttackType attackType, Unit const* victim) const
{
int32 const attackerWeaponSkill = GetWeaponSkillValue(attackType, victim);
- int32 const victimMaxSkillValueForLevel = victim->GetMaxSkillValueForLevel(this);
- int32 const skillDiff = victimMaxSkillValueForLevel - attackerWeaponSkill;
+ int32 const victimDefenseSkill = victim->GetDefenseSkillValue(this);
+ int32 const skillDiff = victimDefenseSkill - attackerWeaponSkill;
float chance = 0.0f;
float skillBonus = 0.0f;
@@ -3264,10 +3300,13 @@ int32 Unit::GetCurrentSpellCastTime(uint32 spell_id) const
bool Unit::CanMoveDuringChannel() const
{
if (Spell* spell = m_currentSpells[CURRENT_CHANNELED_SPELL])
- if (spell->getState() != SPELL_STATE_FINISHED)
- return spell->GetSpellInfo()->HasAttribute(SPELL_ATTR5_CAN_CHANNEL_WHEN_MOVING) && spell->IsChannelActive();
+ {
+ if (spell->getState() != SPELL_STATE_FINISHED && spell->IsChannelActive())
+ if (!spell->GetSpellInfo()->IsMoveAllowedChannel())
+ return false;
+ }
- return false;
+ return true;
}
bool Unit::isInFrontInMap(Unit const* target, float distance, float arc) const
@@ -5210,10 +5249,10 @@ void Unit::SendSpellNonMeleeDamageLog(Unit* target, uint32 SpellID, uint32 Damag
void Unit::ProcSkillsAndAuras(Unit* actionTarget, uint32 typeMaskActor, uint32 typeMaskActionTarget, uint32 spellTypeMask, uint32 spellPhaseMask, uint32 hitMask, Spell* spell, DamageInfo* damageInfo, HealInfo* healInfo)
{
WeaponAttackType attType = damageInfo ? damageInfo->GetAttackType() : BASE_ATTACK;
- if (typeMaskActor && CanProc())
+ if (typeMaskActor)
ProcSkillsAndReactives(false, actionTarget, typeMaskActor, hitMask, attType);
- if (typeMaskActionTarget && actionTarget && actionTarget->CanProc())
+ if (typeMaskActionTarget && actionTarget)
actionTarget->ProcSkillsAndReactives(true, this, typeMaskActionTarget, hitMask, attType);
TriggerAurasProcOnEvent(actionTarget, typeMaskActor, typeMaskActionTarget, spellTypeMask, spellPhaseMask, hitMask, spell, damageInfo, healInfo);
@@ -5303,8 +5342,8 @@ void Unit::SendAttackStateUpdate(CalcDamageInfo* damageInfo)
{
TC_LOG_DEBUG("entities.unit", "WORLD: Sending SMSG_ATTACKERSTATEUPDATE");
- uint32 count = 1;
- size_t maxsize = 4+5+5+4+4+1+4+4+4+4+4+1+4+4+4+4+4*12;
+ uint32 const count = 1;
+ size_t const maxsize = 4+5+5+4+4+1+4+4+4+4+4+1+4+4+4+4+4*12;
WorldPacket data(SMSG_ATTACKERSTATEUPDATE, maxsize); // we guess size
data << uint32(damageInfo->HitInfo);
data << damageInfo->attacker->GetPackGUID();
@@ -5439,6 +5478,8 @@ FactionTemplateEntry const* Unit::GetFactionTemplateEntry() const
TC_LOG_ERROR("entities.unit", "Creature (template id: %u) has invalid faction (faction template id) #%u", creature->GetCreatureTemplate()->Entry, getFaction());
else
TC_LOG_ERROR("entities.unit", "Unit (name=%s, type=%u) has invalid faction (faction template id) #%u", GetName().c_str(), uint32(GetTypeId()), getFaction());
+
+ ABORT();
}
return entry;
}
@@ -5494,8 +5535,7 @@ ReputationRank Unit::GetReactionTo(Unit const* target) const
}
// check FFA_PVP
- if (GetByteValue(UNIT_FIELD_BYTES_2, 1) & UNIT_BYTE2_FLAG_FFA_PVP
- && target->GetByteValue(UNIT_FIELD_BYTES_2, 1) & UNIT_BYTE2_FLAG_FFA_PVP)
+ if (IsFFAPvP() && target->IsFFAPvP())
return REP_HOSTILE;
if (selfPlayerOwner)
@@ -5873,17 +5913,14 @@ void Unit::ModifyAuraState(AuraStateType flag, bool apply)
{
RemoveFlag(UNIT_FIELD_AURASTATE, 1<<(flag-1));
- if (flag != AURA_STATE_ENRAGE) // enrage aura state triggering continues auras
+ Unit::AuraApplicationMap& tAuras = GetAppliedAuras();
+ for (Unit::AuraApplicationMap::iterator itr = tAuras.begin(); itr != tAuras.end();)
{
- Unit::AuraApplicationMap& tAuras = GetAppliedAuras();
- for (Unit::AuraApplicationMap::iterator itr = tAuras.begin(); itr != tAuras.end();)
- {
- SpellInfo const* spellProto = (*itr).second->GetBase()->GetSpellInfo();
- if (spellProto->CasterAuraState == uint32(flag))
- RemoveAura(itr);
- else
- ++itr;
- }
+ SpellInfo const* spellProto = itr->second->GetBase()->GetSpellInfo();
+ if (itr->second->GetBase()->GetCasterGUID() == GetGUID() && spellProto->CasterAuraState == uint32(flag) && (spellProto->IsPassive() || flag != AURA_STATE_ENRAGE))
+ RemoveAura(itr);
+ else
+ ++itr;
}
}
}
@@ -6558,7 +6595,7 @@ void Unit::SendHealSpellLog(HealInfo& healInfo, bool critical /*= false*/)
// we guess size
WorldPacket data(SMSG_SPELLHEALLOG, 8 + 8 + 4 + 4 + 4 + 4 + 1 + 1);
data << healInfo.GetTarget()->GetPackGUID();
- data << GetPackGUID();
+ data << healInfo.GetHealer()->GetPackGUID();
data << uint32(healInfo.GetSpellInfo()->Id);
data << uint32(healInfo.GetHeal());
data << uint32(healInfo.GetHeal() - healInfo.GetEffectiveHeal());
@@ -6648,11 +6685,12 @@ uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, uin
// Impurity (dummy effect)
if (GetTypeId() == TYPEID_PLAYER)
{
- PlayerSpellMap playerSpells = ToPlayer()->GetSpellMap();
- for (PlayerSpellMap::const_iterator itr = playerSpells.begin(); itr != playerSpells.end(); ++itr)
+ PlayerSpellMap const& playerSpells = ToPlayer()->GetSpellMap();
+ for (auto itr = playerSpells.begin(); itr != playerSpells.end(); ++itr)
{
if (itr->second->state == PLAYERSPELL_REMOVED || itr->second->disabled)
continue;
+
switch (itr->first)
{
case 49220:
@@ -6661,7 +6699,7 @@ uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, uin
case 49636:
case 49638:
if (SpellInfo const* proto = sSpellMgr->GetSpellInfo(itr->first))
- AddPct(ApCoeffMod, proto->Effects[0].CalcValue());
+ AddPct(ApCoeffMod, proto->Effects[EFFECT_0].CalcValue());
break;
}
}
@@ -6677,33 +6715,28 @@ uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, uin
DoneAdvertisedBenefit += ((Guardian*)this)->GetBonusDamage();
// Check for table values
- float coeff = 0;
+ float coeff = 0.0f;
SpellBonusEntry const* bonus = sSpellMgr->GetSpellBonusData(spellProto->Id);
if (bonus)
{
+ WeaponAttackType attType = (spellProto->IsRangedWeaponSpell() && spellProto->DmgClass != SPELL_DAMAGE_CLASS_MELEE) ? RANGED_ATTACK : BASE_ATTACK;
+ float APbonus = float(victim->GetTotalAuraModifier(attType == BASE_ATTACK ? SPELL_AURA_MELEE_ATTACK_POWER_ATTACKER_BONUS : SPELL_AURA_RANGED_ATTACK_POWER_ATTACKER_BONUS));
+ APbonus += GetTotalAttackPowerValue(attType);
+
if (damagetype == DOT)
{
coeff = bonus->dot_damage;
if (bonus->ap_dot_bonus > 0)
- {
- WeaponAttackType attType = (spellProto->IsRangedWeaponSpell() && spellProto->DmgClass != SPELL_DAMAGE_CLASS_MELEE) ? RANGED_ATTACK : BASE_ATTACK;
- float APbonus = float(victim->GetTotalAuraModifier(attType == BASE_ATTACK ? SPELL_AURA_MELEE_ATTACK_POWER_ATTACKER_BONUS : SPELL_AURA_RANGED_ATTACK_POWER_ATTACKER_BONUS));
- APbonus += GetTotalAttackPowerValue(attType);
DoneTotal += int32(bonus->ap_dot_bonus * stack * ApCoeffMod * APbonus);
- }
}
else
{
coeff = bonus->direct_damage;
if (bonus->ap_bonus > 0)
- {
- WeaponAttackType attType = (spellProto->IsRangedWeaponSpell() && spellProto->DmgClass != SPELL_DAMAGE_CLASS_MELEE) ? RANGED_ATTACK : BASE_ATTACK;
- float APbonus = float(victim->GetTotalAuraModifier(attType == BASE_ATTACK ? SPELL_AURA_MELEE_ATTACK_POWER_ATTACKER_BONUS : SPELL_AURA_RANGED_ATTACK_POWER_ATTACKER_BONUS));
- APbonus += GetTotalAttackPowerValue(attType);
DoneTotal += int32(bonus->ap_bonus * stack * ApCoeffMod * APbonus);
- }
}
}
+
// Default calculation
if (DoneAdvertisedBenefit)
{
@@ -6721,14 +6754,16 @@ uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, uin
DoneTotal += int32(DoneAdvertisedBenefit * coeff * factorMod);
}
+ float tmpDamage = (int32(pdamage) + DoneTotal);
+
+ // DOTs calculated in AuraEffect::PeriodicDamageAurasTick
// Done Percentage for DOT is already calculated, no need to do it again. The percentage mod is applied in Aura::HandleAuraSpecificMods.
- float tmpDamage = (int32(pdamage) + DoneTotal) * (damagetype == DOT ? 1.0f : SpellDamagePctDone(victim, spellProto, damagetype));
- // apply spellmod to Done damage (flat and pct)
- if (Player* modOwner = GetSpellModOwner())
+ if (damagetype != DOT)
{
- if (damagetype == DOT)
- modOwner->ApplySpellMod<SPELLMOD_DOT>(spellProto->Id, tmpDamage);
- else
+ tmpDamage *= SpellDamagePctDone(victim, spellProto, damagetype);
+
+ // apply spellmod to Done damage (flat and pct)
+ if (Player* modOwner = GetSpellModOwner())
modOwner->ApplySpellMod<SPELLMOD_DAMAGE>(spellProto->Id, tmpDamage);
}
@@ -6755,22 +6790,17 @@ float Unit::SpellDamagePctDone(Unit* victim, SpellInfo const* spellProto, Damage
if (GetTypeId() == TYPEID_UNIT && !IsPet())
DoneTotalMod *= ToCreature()->GetSpellDamageMod(ToCreature()->GetCreatureTemplate()->rank);
- AuraEffectList const& mModDamagePercentDone = GetAuraEffectsByType(SPELL_AURA_MOD_DAMAGE_PERCENT_DONE);
- for (AuraEffectList::const_iterator i = mModDamagePercentDone.begin(); i != mModDamagePercentDone.end(); ++i)
+ float maxModDamagePercentSchool = 0.0f;
+ if (GetTypeId() == TYPEID_PLAYER)
{
- if (spellProto->EquippedItemClass == -1 && (*i)->GetSpellInfo()->EquippedItemClass != -1) //prevent apply mods from weapon specific case to non weapon specific spells (Example: thunder clap and two-handed weapon specialization)
- continue;
-
- if ((*i)->GetMiscValue() & spellProto->GetSchoolMask())
- {
- if ((*i)->GetSpellInfo()->EquippedItemClass == -1)
- AddPct(DoneTotalMod, (*i)->GetAmount());
- else if (!(*i)->GetSpellInfo()->HasAttribute(SPELL_ATTR5_SPECIAL_ITEM_CLASS_CHECK) && ((*i)->GetSpellInfo()->EquippedItemSubClassMask == 0))
- AddPct(DoneTotalMod, (*i)->GetAmount());
- else if (ToPlayer() && ToPlayer()->HasItemFitToSpellRequirements((*i)->GetSpellInfo()))
- AddPct(DoneTotalMod, (*i)->GetAmount());
- }
+ for (uint32 i = 0; i < MAX_SPELL_SCHOOL; ++i)
+ if (spellProto->GetSchoolMask() & (1 << i))
+ maxModDamagePercentSchool = std::max(maxModDamagePercentSchool, GetFloatValue(PLAYER_FIELD_MOD_DAMAGE_DONE_PCT + i));
}
+ else
+ maxModDamagePercentSchool = GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_DAMAGE_PERCENT_DONE, spellProto->GetSchoolMask());
+
+ DoneTotalMod *= maxModDamagePercentSchool;
uint32 creatureTypeMask = victim->GetCreatureTypeMask();
@@ -7151,13 +7181,9 @@ int32 Unit::SpellBaseDamageBonusDone(SpellSchoolMask schoolMask) const
int32 DoneAdvertisedBenefit = 0;
AuraEffectList const& mDamageDone = GetAuraEffectsByType(SPELL_AURA_MOD_DAMAGE_DONE);
- for (AuraEffectList::const_iterator i = mDamageDone.begin(); i != mDamageDone.end(); ++i)
- if (((*i)->GetMiscValue() & schoolMask) != 0 &&
- (*i)->GetSpellInfo()->EquippedItemClass == -1 &&
- // -1 == any item class (not wand then)
- (*i)->GetSpellInfo()->EquippedItemInventoryTypeMask == 0)
- // 0 == any inventory type (not wand then)
- DoneAdvertisedBenefit += (*i)->GetAmount();
+ for (AuraEffect const* aurEff : mDamageDone)
+ if (aurEff->GetMiscValue() & schoolMask)
+ DoneAdvertisedBenefit += aurEff->GetAmount();
if (GetTypeId() == TYPEID_PLAYER)
{
@@ -7166,22 +7192,20 @@ int32 Unit::SpellBaseDamageBonusDone(SpellSchoolMask schoolMask) const
// Damage bonus from stats
AuraEffectList const& mDamageDoneOfStatPercent = GetAuraEffectsByType(SPELL_AURA_MOD_SPELL_DAMAGE_OF_STAT_PERCENT);
- for (AuraEffectList::const_iterator i = mDamageDoneOfStatPercent.begin(); i != mDamageDoneOfStatPercent.end(); ++i)
+ for (AuraEffect const* aurEff : mDamageDoneOfStatPercent)
{
- if ((*i)->GetMiscValue() & schoolMask)
+ if ((aurEff->GetMiscValue() & schoolMask) != 0)
{
// stat used stored in miscValueB for this aura
- Stats usedStat = Stats((*i)->GetMiscValueB());
- DoneAdvertisedBenefit += int32(CalculatePct(GetStat(usedStat), (*i)->GetAmount()));
+ Stats const usedStat = static_cast<Stats>(aurEff->GetMiscValueB());
+ DoneAdvertisedBenefit += static_cast<int32>(CalculatePct(GetStat(usedStat), aurEff->GetAmount()));
}
}
- // ... and attack power
- AuraEffectList const& mDamageDonebyAP = GetAuraEffectsByType(SPELL_AURA_MOD_SPELL_DAMAGE_OF_ATTACK_POWER);
- for (AuraEffectList::const_iterator i =mDamageDonebyAP.begin(); i != mDamageDonebyAP.end(); ++i)
- if ((*i)->GetMiscValue() & schoolMask)
- DoneAdvertisedBenefit += int32(CalculatePct(GetTotalAttackPowerValue(BASE_ATTACK), (*i)->GetAmount()));
+ // ... and attack power
+ DoneAdvertisedBenefit += static_cast<int32>(CalculatePct(GetTotalAttackPowerValue(BASE_ATTACK), GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_SPELL_DAMAGE_OF_ATTACK_POWER, schoolMask)));
}
+
return DoneAdvertisedBenefit;
}
@@ -7502,6 +7526,7 @@ uint32 Unit::SpellHealingBonusDone(Unit* victim, SpellInfo const* spellProto, ui
if (spellProto->SpellFamilyName == SPELLFAMILY_POTION)
return healamount;
+ float ApCoeffMod = 1.0f;
int32 DoneTotal = 0;
// done scripted mod (take it from owner)
@@ -7523,6 +7548,35 @@ uint32 Unit::SpellHealingBonusDone(Unit* victim, SpellInfo const* spellProto, ui
}
}
+ // Custom scripted damage
+ switch (spellProto->SpellFamilyName)
+ {
+ case SPELLFAMILY_DEATHKNIGHT:
+ // Impurity (dummy effect)
+ if (GetTypeId() == TYPEID_PLAYER)
+ {
+ PlayerSpellMap const& playerSpells = ToPlayer()->GetSpellMap();
+ for (auto itr = playerSpells.begin(); itr != playerSpells.end(); ++itr)
+ {
+ if (itr->second->state == PLAYERSPELL_REMOVED || itr->second->disabled)
+ continue;
+
+ switch (itr->first)
+ {
+ case 49220:
+ case 49633:
+ case 49635:
+ case 49636:
+ case 49638:
+ if (SpellInfo const* proto = sSpellMgr->GetSpellInfo(itr->first))
+ AddPct(ApCoeffMod, proto->Effects[EFFECT_0].CalcValue());
+ break;
+ }
+ }
+ }
+ break;
+ }
+
// Done fixed damage bonus auras
int32 DoneAdvertisedBenefit = SpellBaseHealingBonusDone(spellProto->GetSchoolMask());
@@ -7536,15 +7590,15 @@ uint32 Unit::SpellHealingBonusDone(Unit* victim, SpellInfo const* spellProto, ui
{
coeff = bonus->dot_damage;
if (bonus->ap_dot_bonus > 0)
- DoneTotal += int32(bonus->ap_dot_bonus * stack * GetTotalAttackPowerValue(
- (spellProto->IsRangedWeaponSpell() && spellProto->DmgClass !=SPELL_DAMAGE_CLASS_MELEE) ? RANGED_ATTACK : BASE_ATTACK));
+ DoneTotal += int32(bonus->ap_dot_bonus * ApCoeffMod * stack * GetTotalAttackPowerValue(
+ (spellProto->IsRangedWeaponSpell() && spellProto->DmgClass != SPELL_DAMAGE_CLASS_MELEE) ? RANGED_ATTACK : BASE_ATTACK));
}
else
{
coeff = bonus->direct_damage;
if (bonus->ap_bonus > 0)
- DoneTotal += int32(bonus->ap_bonus * stack * GetTotalAttackPowerValue(
- (spellProto->IsRangedWeaponSpell() && spellProto->DmgClass !=SPELL_DAMAGE_CLASS_MELEE) ? RANGED_ATTACK : BASE_ATTACK));
+ DoneTotal += int32(bonus->ap_bonus * ApCoeffMod * stack * GetTotalAttackPowerValue(
+ (spellProto->IsRangedWeaponSpell() && spellProto->DmgClass != SPELL_DAMAGE_CLASS_MELEE) ? RANGED_ATTACK : BASE_ATTACK));
}
}
else
@@ -7590,14 +7644,16 @@ uint32 Unit::SpellHealingBonusDone(Unit* victim, SpellInfo const* spellProto, ui
DoneTotal = 0;
}
+ float heal = float(int32(healamount) + DoneTotal);
+
+ // DOTs calculated in AuraEffect::HandlePeriodicHealAurasTick
// Done Percentage for DOT is already calculated, no need to do it again. The percentage mod is applied in Aura::HandleAuraSpecificMods.
- float heal = float(int32(healamount) + DoneTotal) * (damagetype == DOT ? 1.0f : SpellHealingPctDone(victim, spellProto));
- // apply spellmod to Done amount
- if (Player* modOwner = GetSpellModOwner())
+ if (damagetype != DOT)
{
- if (damagetype == DOT)
- modOwner->ApplySpellMod<SPELLMOD_DOT>(spellProto->Id, heal);
- else
+ heal *= SpellHealingPctDone(victim, spellProto);
+
+ // apply spellmod to Done amount
+ if (Player* modOwner = GetSpellModOwner())
modOwner->ApplySpellMod<SPELLMOD_DAMAGE>(spellProto->Id, heal);
}
@@ -7825,18 +7881,18 @@ int32 Unit::SpellBaseHealingBonusTaken(SpellSchoolMask schoolMask) const
return advertisedBenefit;
}
-bool Unit::IsImmunedToDamage(SpellSchoolMask shoolMask) const
+bool Unit::IsImmunedToDamage(SpellSchoolMask schoolMask) const
{
// If m_immuneToSchool type contain this school type, IMMUNE damage.
- SpellImmuneList const& schoolList = m_spellImmune[IMMUNITY_SCHOOL];
- for (SpellImmuneList::const_iterator itr = schoolList.begin(); itr != schoolList.end(); ++itr)
- if (itr->type & shoolMask)
+ SpellImmuneContainer const& schoolList = m_spellImmune[IMMUNITY_SCHOOL];
+ for (auto itr = schoolList.begin(); itr != schoolList.end(); ++itr)
+ if ((itr->first & schoolMask) != 0)
return true;
// If m_immuneToDamage type contain magic, IMMUNE damage.
- SpellImmuneList const& damageList = m_spellImmune[IMMUNITY_DAMAGE];
- for (SpellImmuneList::const_iterator itr = damageList.begin(); itr != damageList.end(); ++itr)
- if (itr->type & shoolMask)
+ SpellImmuneContainer const& damageList = m_spellImmune[IMMUNITY_DAMAGE];
+ for (auto itr = damageList.begin(); itr != damageList.end(); ++itr)
+ if ((itr->first & schoolMask) != 0)
return true;
return false;
@@ -7844,23 +7900,27 @@ bool Unit::IsImmunedToDamage(SpellSchoolMask shoolMask) const
bool Unit::IsImmunedToDamage(SpellInfo const* spellInfo) const
{
- if (spellInfo->HasAttribute(SPELL_ATTR0_UNAFFECTED_BY_INVULNERABILITY))
+ if (!spellInfo)
return false;
- uint32 shoolMask = spellInfo->GetSchoolMask();
- if (spellInfo->Id != 42292 && spellInfo->Id != 59752)
- {
- // If m_immuneToSchool type contain this school type, IMMUNE damage.
- SpellImmuneList const& schoolList = m_spellImmune[IMMUNITY_SCHOOL];
- for (SpellImmuneList::const_iterator itr = schoolList.begin(); itr != schoolList.end(); ++itr)
- if (itr->type & shoolMask && !spellInfo->CanPierceImmuneAura(sSpellMgr->GetSpellInfo(itr->spellId)))
- return true;
- }
+ // for example 40175
+ if (spellInfo->HasAttribute(SPELL_ATTR0_UNAFFECTED_BY_INVULNERABILITY) && spellInfo->HasAttribute(SPELL_ATTR3_IGNORE_HIT_RESULT))
+ return false;
+
+ if (spellInfo->HasAttribute(SPELL_ATTR1_UNAFFECTED_BY_SCHOOL_IMMUNE) || spellInfo->HasAttribute(SPELL_ATTR2_UNAFFECTED_BY_AURA_SCHOOL_IMMUNE))
+ return false;
+
+ uint32 schoolMask = spellInfo->GetSchoolMask();
+ // If m_immuneToSchool type contain this school type, IMMUNE damage.
+ SpellImmuneContainer const& schoolList = m_spellImmune[IMMUNITY_SCHOOL];
+ for (auto itr = schoolList.begin(); itr != schoolList.end(); ++itr)
+ if ((itr->first & schoolMask) && !spellInfo->CanPierceImmuneAura(sSpellMgr->GetSpellInfo(itr->second)))
+ return true;
// If m_immuneToDamage type contain magic, IMMUNE damage.
- SpellImmuneList const& damageList = m_spellImmune[IMMUNITY_DAMAGE];
- for (SpellImmuneList::const_iterator itr = damageList.begin(); itr != damageList.end(); ++itr)
- if (itr->type & shoolMask)
+ SpellImmuneContainer const& damageList = m_spellImmune[IMMUNITY_DAMAGE];
+ for (auto itr = damageList.begin(); itr != damageList.end(); ++itr)
+ if ((itr->first & schoolMask) != 0)
return true;
return false;
@@ -7872,29 +7932,26 @@ bool Unit::IsImmunedToSpell(SpellInfo const* spellInfo) const
return false;
// Single spell immunity.
- SpellImmuneList const& idList = m_spellImmune[IMMUNITY_ID];
- for (SpellImmuneList::const_iterator itr = idList.begin(); itr != idList.end(); ++itr)
- if (itr->type == spellInfo->Id)
- return true;
+ SpellImmuneContainer const& idList = m_spellImmune[IMMUNITY_ID];
+ if (idList.count(spellInfo->Id) > 0)
+ return true;
if (spellInfo->HasAttribute(SPELL_ATTR0_UNAFFECTED_BY_INVULNERABILITY))
return false;
- if (spellInfo->Dispel)
+ if (uint32 dispel = spellInfo->Dispel)
{
- SpellImmuneList const& dispelList = m_spellImmune[IMMUNITY_DISPEL];
- for (SpellImmuneList::const_iterator itr = dispelList.begin(); itr != dispelList.end(); ++itr)
- if (itr->type == spellInfo->Dispel)
- return true;
+ SpellImmuneContainer const& dispelList = m_spellImmune[IMMUNITY_DISPEL];
+ if (dispelList.count(dispel) > 0)
+ return true;
}
// Spells that don't have effectMechanics.
- if (spellInfo->Mechanic)
+ if (uint32 mechanic = spellInfo->Mechanic)
{
- SpellImmuneList const& mechanicList = m_spellImmune[IMMUNITY_MECHANIC];
- for (SpellImmuneList::const_iterator itr = mechanicList.begin(); itr != mechanicList.end(); ++itr)
- if (itr->type == spellInfo->Mechanic)
- return true;
+ SpellImmuneContainer const& mechanicList = m_spellImmune[IMMUNITY_MECHANIC];
+ if (mechanicList.count(mechanic) > 0)
+ return true;
}
bool immuneToAllEffects = true;
@@ -7902,8 +7959,6 @@ bool Unit::IsImmunedToSpell(SpellInfo const* spellInfo) const
{
// State/effect immunities applied by aura expect full spell immunity
// Ignore effects with mechanic, they are supposed to be checked separately
- if (!spellInfo->Effects[i].IsEffect())
- continue;
if (!IsImmunedToSpellEffect(spellInfo, i))
{
immuneToAllEffects = false;
@@ -7914,13 +7969,13 @@ bool Unit::IsImmunedToSpell(SpellInfo const* spellInfo) const
if (immuneToAllEffects) //Return immune only if the target is immune to all spell effects.
return true;
- if (spellInfo->Id != 42292 && spellInfo->Id != 59752)
+ if (!spellInfo->HasAttribute(SPELL_ATTR1_UNAFFECTED_BY_SCHOOL_IMMUNE) && !spellInfo->HasAttribute(SPELL_ATTR2_UNAFFECTED_BY_AURA_SCHOOL_IMMUNE))
{
- SpellImmuneList const& schoolList = m_spellImmune[IMMUNITY_SCHOOL];
- for (SpellImmuneList::const_iterator itr = schoolList.begin(); itr != schoolList.end(); ++itr)
+ SpellImmuneContainer const& schoolList = m_spellImmune[IMMUNITY_SCHOOL];
+ for (auto itr = schoolList.begin(); itr != schoolList.end(); ++itr)
{
- SpellInfo const* immuneSpellInfo = sSpellMgr->GetSpellInfo(itr->spellId);
- if ((itr->type & spellInfo->GetSchoolMask())
+ SpellInfo const* immuneSpellInfo = sSpellMgr->GetSpellInfo(itr->second);
+ if ((itr->first & spellInfo->GetSchoolMask())
&& !(immuneSpellInfo && immuneSpellInfo->IsPositive() && spellInfo->IsPositive())
&& !spellInfo->CanPierceImmuneAura(immuneSpellInfo))
return true;
@@ -7933,9 +7988,9 @@ bool Unit::IsImmunedToSpell(SpellInfo const* spellInfo) const
uint32 Unit::GetSchoolImmunityMask() const
{
uint32 mask = 0;
- SpellImmuneList const& mechanicList = m_spellImmune[IMMUNITY_SCHOOL];
- for (SpellImmuneList::const_iterator itr = mechanicList.begin(); itr != mechanicList.end(); ++itr)
- mask |= itr->type;
+ SpellImmuneContainer const& mechanicList = m_spellImmune[IMMUNITY_SCHOOL];
+ for (auto itr = mechanicList.begin(); itr != mechanicList.end(); ++itr)
+ mask |= itr->first;
return mask;
}
@@ -7943,9 +7998,9 @@ uint32 Unit::GetSchoolImmunityMask() const
uint32 Unit::GetMechanicImmunityMask() const
{
uint32 mask = 0;
- SpellImmuneList const& mechanicList = m_spellImmune[IMMUNITY_MECHANIC];
- for (SpellImmuneList::const_iterator itr = mechanicList.begin(); itr != mechanicList.end(); ++itr)
- mask |= (1 << itr->type);
+ SpellImmuneContainer const& mechanicList = m_spellImmune[IMMUNITY_MECHANIC];
+ for (auto itr = mechanicList.begin(); itr != mechanicList.end(); ++itr)
+ mask |= (1 << itr->first);
return mask;
}
@@ -7960,33 +8015,35 @@ bool Unit::IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) cons
// If m_immuneToEffect type contain this effect type, IMMUNE effect.
uint32 effect = spellInfo->Effects[index].Effect;
- SpellImmuneList const& effectList = m_spellImmune[IMMUNITY_EFFECT];
- for (SpellImmuneList::const_iterator itr = effectList.begin(); itr != effectList.end(); ++itr)
- if (itr->type == effect)
- return true;
+ auto const& effectList = m_spellImmune[IMMUNITY_EFFECT];
+ if (effectList.count(effect) > 0)
+ return true;
if (uint32 mechanic = spellInfo->Effects[index].Mechanic)
{
- SpellImmuneList const& mechanicList = m_spellImmune[IMMUNITY_MECHANIC];
- for (SpellImmuneList::const_iterator itr = mechanicList.begin(); itr != mechanicList.end(); ++itr)
- if (itr->type == mechanic)
- return true;
+ auto const& mechanicList = m_spellImmune[IMMUNITY_MECHANIC];
+ if (mechanicList.count(mechanic) > 0)
+ return true;
}
- if (uint32 aura = spellInfo->Effects[index].ApplyAuraName)
+ if (!spellInfo->HasAttribute(SPELL_ATTR3_IGNORE_HIT_RESULT))
{
- SpellImmuneList const& list = m_spellImmune[IMMUNITY_STATE];
- for (SpellImmuneList::const_iterator itr = list.begin(); itr != list.end(); ++itr)
- if (itr->type == aura)
- if (!spellInfo->HasAttribute(SPELL_ATTR3_IGNORE_HIT_RESULT))
- return true;
-
- // Check for immune to application of harmful magical effects
- AuraEffectList const& immuneAuraApply = GetAuraEffectsByType(SPELL_AURA_MOD_IMMUNE_AURA_APPLY_SCHOOL);
- for (AuraEffectList::const_iterator iter = immuneAuraApply.begin(); iter != immuneAuraApply.end(); ++iter)
- if (((*iter)->GetMiscValue() & spellInfo->GetSchoolMask()) && // Check school
- !spellInfo->IsPositiveEffect(index)) // Harmful
+ if (uint32 aura = spellInfo->Effects[index].ApplyAuraName)
+ {
+ SpellImmuneContainer const& list = m_spellImmune[IMMUNITY_STATE];
+ if (list.count(aura) > 0)
return true;
+
+ if (!spellInfo->HasAttribute(SPELL_ATTR2_UNAFFECTED_BY_AURA_SCHOOL_IMMUNE))
+ {
+ // Check for immune to application of harmful magical effects
+ AuraEffectList const& immuneAuraApply = GetAuraEffectsByType(SPELL_AURA_MOD_IMMUNE_AURA_APPLY_SCHOOL);
+ for (AuraEffectList::const_iterator iter = immuneAuraApply.begin(); iter != immuneAuraApply.end(); ++iter)
+ if (((*iter)->GetMiscValue() & spellInfo->GetSchoolMask()) && // Check school
+ !spellInfo->IsPositiveEffect(index)) // Harmful
+ return true;
+ }
+ }
}
return false;
@@ -8037,15 +8094,8 @@ uint32 Unit::MeleeDamageBonusDone(Unit* victim, uint32 pdamage, WeaponAttackType
if (APbonus != 0) // Can be negative
{
- bool normalized = false;
- if (spellProto)
- for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
- if (spellProto->Effects[i].Effect == SPELL_EFFECT_NORMALIZED_WEAPON_DMG)
- {
- normalized = true;
- break;
- }
- DoneFlatBenefit += int32(APbonus/14.0f * GetAPMultiplier(attType, normalized));
+ bool const normalized = spellProto && spellProto->HasEffect(SPELL_EFFECT_NORMALIZED_WEAPON_DMG);
+ DoneFlatBenefit += int32(APbonus / 14.0f * GetAPMultiplier(attType, normalized));
}
// Done total percent damage auras
@@ -8053,22 +8103,23 @@ uint32 Unit::MeleeDamageBonusDone(Unit* victim, uint32 pdamage, WeaponAttackType
// Some spells don't benefit from pct done mods
if (spellProto)
- if (!spellProto->HasAttribute(SPELL_ATTR6_NO_DONE_PCT_DAMAGE_MODS))
+ {
+ // mods for SPELL_SCHOOL_MASK_NORMAL are already factored in base melee damage calculation
+ if (!spellProto->HasAttribute(SPELL_ATTR6_NO_DONE_PCT_DAMAGE_MODS) && !(spellProto->GetSchoolMask() & SPELL_SCHOOL_MASK_NORMAL))
{
- AuraEffectList const& mModDamagePercentDone = GetAuraEffectsByType(SPELL_AURA_MOD_DAMAGE_PERCENT_DONE);
- for (AuraEffectList::const_iterator i = mModDamagePercentDone.begin(); i != mModDamagePercentDone.end(); ++i)
+ float maxModDamagePercentSchool = 0.0f;
+ if (GetTypeId() == TYPEID_PLAYER)
{
- if ((*i)->GetMiscValue() & spellProto->GetSchoolMask() && !(spellProto->GetSchoolMask() & SPELL_SCHOOL_MASK_NORMAL))
- {
- if ((*i)->GetSpellInfo()->EquippedItemClass == -1)
- AddPct(DoneTotalMod, (*i)->GetAmount());
- else if (!(*i)->GetSpellInfo()->HasAttribute(SPELL_ATTR5_SPECIAL_ITEM_CLASS_CHECK) && ((*i)->GetSpellInfo()->EquippedItemSubClassMask == 0))
- AddPct(DoneTotalMod, (*i)->GetAmount());
- else if (ToPlayer() && ToPlayer()->HasItemFitToSpellRequirements((*i)->GetSpellInfo()))
- AddPct(DoneTotalMod, (*i)->GetAmount());
- }
+ for (uint32 i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i)
+ if (spellProto->GetSchoolMask() & (1 << i))
+ maxModDamagePercentSchool = std::max(maxModDamagePercentSchool, GetFloatValue(PLAYER_FIELD_MOD_DAMAGE_DONE_PCT + i));
}
+ else
+ maxModDamagePercentSchool = GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_DAMAGE_PERCENT_DONE, spellProto->GetSchoolMask());
+
+ DoneTotalMod *= maxModDamagePercentSchool;
}
+ }
AuraEffectList const& mDamageDoneVersus = GetAuraEffectsByType(SPELL_AURA_MOD_DAMAGE_DONE_VERSUS);
for (AuraEffectList::const_iterator i = mDamageDoneVersus.begin(); i != mDamageDoneVersus.end(); ++i)
@@ -8292,52 +8343,14 @@ uint32 Unit::MeleeDamageBonusTaken(Unit* attacker, uint32 pdamage, WeaponAttackT
void Unit::ApplySpellImmune(uint32 spellId, uint32 op, uint32 type, bool apply)
{
if (apply)
- {
- for (SpellImmuneList::iterator itr = m_spellImmune[op].begin(), next; itr != m_spellImmune[op].end(); itr = next)
- {
- next = itr; ++next;
- if (itr->type == type)
- {
- m_spellImmune[op].erase(itr);
- next = m_spellImmune[op].begin();
- }
- }
- SpellImmune Immune;
- Immune.spellId = spellId;
- Immune.type = type;
- m_spellImmune[op].push_back(Immune);
- }
+ m_spellImmune[op].emplace(type, spellId);
else
{
- for (SpellImmuneList::iterator itr = m_spellImmune[op].begin(); itr != m_spellImmune[op].end(); ++itr)
+ auto bounds = m_spellImmune[op].equal_range(type);
+ for (auto itr = bounds.first; itr != bounds.second;)
{
- if (itr->spellId == spellId && itr->type == type)
- {
- m_spellImmune[op].erase(itr);
- break;
- }
- }
- }
-}
-
-void Unit::ApplySpellDispelImmunity(const SpellInfo* spellProto, DispelType type, bool apply)
-{
- ApplySpellImmune(spellProto->Id, IMMUNITY_DISPEL, type, apply);
-
- if (apply && spellProto->HasAttribute(SPELL_ATTR1_DISPEL_AURAS_ON_IMMUNITY))
- {
- // Create dispel mask by dispel type
- uint32 dispelMask = SpellInfo::GetDispelMask(type);
- // Dispel all existing auras vs current dispel type
- AuraApplicationMap& auras = GetAppliedAuras();
- for (AuraApplicationMap::iterator itr = auras.begin(); itr != auras.end();)
- {
- SpellInfo const* spell = itr->second->GetBase()->GetSpellInfo();
- if (spell->GetDispelMask() & dispelMask)
- {
- // Dispel aura
- RemoveAura(itr);
- }
+ if (itr->second == spellId)
+ itr = m_spellImmune[op].erase(itr);
else
++itr;
}
@@ -8655,14 +8668,26 @@ bool Unit::_IsValidAttackTarget(Unit const* target, SpellInfo const* bySpell, Wo
|| (target->GetTypeId() == TYPEID_PLAYER && target->ToPlayer()->IsGameMaster()))
return false;
- // can't attack own vehicle or passenger
- if (m_vehicle)
- if (IsOnVehicle(target) || m_vehicle->GetBase()->IsOnVehicle(target))
- return false;
+ // visibility checks
+ // skip visibility check for GO casts, needs removal when go cast is implemented. Also ignore for gameobject and dynauras
+ if (GetEntry() != WORLD_TRIGGER && (!obj || !obj->isType(TYPEMASK_GAMEOBJECT | TYPEMASK_DYNAMICOBJECT)))
+ {
+ // can't attack invisible
+ if (!bySpell || !bySpell->HasAttribute(SPELL_ATTR6_CAN_TARGET_INVISIBLE))
+ {
+ if (obj && !obj->CanSeeOrDetect(target, bySpell && bySpell->IsAffectingArea()))
+ return false;
+ else if (!obj)
+ {
+ // ignore stealth for aoe spells. Ignore stealth if target is player and unit in combat with same player
+ bool const ignoreStealthCheck = (bySpell && bySpell->IsAffectingArea()) ||
+ (target->GetTypeId() == TYPEID_PLAYER && target->HasStealthAura() && target->IsInCombat() && IsInCombatWith(target));
- // can't attack invisible (ignore stealth for aoe spells) also if the area being looked at is from a spell use the dynamic object created instead of the casting unit. Ignore stealth if target is player and unit in combat with same player
- if ((!bySpell || !bySpell->HasAttribute(SPELL_ATTR6_CAN_TARGET_INVISIBLE)) && (obj ? !obj->CanSeeOrDetect(target, bySpell && bySpell->IsAffectingArea()) : !CanSeeOrDetect(target, (bySpell && bySpell->IsAffectingArea()) || (target->GetTypeId() == TYPEID_PLAYER && target->HasStealthAura() && target->IsInCombat() && IsInCombatWith(target)))))
- return false;
+ if (!CanSeeOrDetect(target, ignoreStealthCheck))
+ return false;
+ }
+ }
+ }
// can't attack dead
if ((!bySpell || !bySpell->IsAllowingDeadTarget()) && !target->IsAlive())
@@ -8693,7 +8718,7 @@ bool Unit::_IsValidAttackTarget(Unit const* target, SpellInfo const* bySpell, Wo
// PvP, PvC, CvP case
// can't attack friendly targets
- if ( GetReactionTo(target) > REP_NEUTRAL
+ if (GetReactionTo(target) > REP_NEUTRAL
|| target->GetReactionTo(this) > REP_NEUTRAL)
return false;
@@ -8701,10 +8726,8 @@ bool Unit::_IsValidAttackTarget(Unit const* target, SpellInfo const* bySpell, Wo
Player const* playerAffectingTarget = target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE) ? target->GetAffectingPlayer() : nullptr;
// Not all neutral creatures can be attacked (even some unfriendly faction does not react aggresive to you, like Sporaggar)
- if (
- (playerAffectingAttacker && !playerAffectingTarget) ||
- (!playerAffectingAttacker && playerAffectingTarget)
- )
+ if ((playerAffectingAttacker && !playerAffectingTarget) ||
+ (!playerAffectingAttacker && playerAffectingTarget))
{
Player const* player = playerAffectingAttacker ? playerAffectingAttacker : playerAffectingTarget;
Unit const* creature = playerAffectingAttacker ? target : this;
@@ -8738,15 +8761,14 @@ bool Unit::_IsValidAttackTarget(Unit const* target, SpellInfo const* bySpell, Wo
// additional checks - only PvP case
if (playerAffectingAttacker && playerAffectingTarget)
{
- if (target->GetByteValue(UNIT_FIELD_BYTES_2, 1) & UNIT_BYTE2_FLAG_PVP)
+ if (target->IsPvP())
return true;
- if (GetByteValue(UNIT_FIELD_BYTES_2, 1) & UNIT_BYTE2_FLAG_FFA_PVP
- && target->GetByteValue(UNIT_FIELD_BYTES_2, 1) & UNIT_BYTE2_FLAG_FFA_PVP)
+ if (IsFFAPvP() && target->IsFFAPvP())
return true;
- return (GetByteValue(UNIT_FIELD_BYTES_2, 1) & UNIT_BYTE2_FLAG_UNK1)
- || (target->GetByteValue(UNIT_FIELD_BYTES_2, 1) & UNIT_BYTE2_FLAG_UNK1);
+ return HasByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_UNK1)
+ || target->HasByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_UNK1);
}
return true;
}
@@ -9729,63 +9751,53 @@ void Unit::ModSpellDurationTime(SpellInfo const* spellInfo, int32 & duration, Sp
DiminishingLevels Unit::GetDiminishing(DiminishingGroup group)
{
- for (Diminishing::iterator i = m_Diminishing.begin(); i != m_Diminishing.end(); ++i)
- {
- if (i->DRGroup != group)
- continue;
-
- if (!i->hitCount)
- return DIMINISHING_LEVEL_1;
-
- if (!i->hitTime)
- return DIMINISHING_LEVEL_1;
+ DiminishingReturn& diminish = m_Diminishing[group];
+ if (!diminish.hitCount)
+ return DIMINISHING_LEVEL_1;
- // 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;
- return DIMINISHING_LEVEL_1;
- }
- // or else increase the count.
- else
- return DiminishingLevels(i->hitCount);
+ // If last spell was cast more than 15 seconds ago - reset the count.
+ if (!diminish.stack && GetMSTimeDiffToNow(diminish.hitTime) > 15000)
+ {
+ diminish.hitCount = DIMINISHING_LEVEL_1;
+ return DIMINISHING_LEVEL_1;
}
- return DIMINISHING_LEVEL_1;
+
+ return DiminishingLevels(diminish.hitCount);
}
-void Unit::IncrDiminishing(DiminishingGroup group)
+void Unit::IncrDiminishing(SpellInfo const* auraSpellInfo, bool triggered)
{
+ DiminishingGroup const group = auraSpellInfo->GetDiminishingReturnsGroupForSpell(triggered);
+ DiminishingLevels const maxLevel = auraSpellInfo->GetDiminishingReturnsMaxLevel(triggered);
+
// Checking for existing in the table
- for (Diminishing::iterator i = m_Diminishing.begin(); i != m_Diminishing.end(); ++i)
- {
- if (i->DRGroup != group)
- continue;
- if (int32(i->hitCount) < GetDiminishingReturnsMaxLevel(group))
- i->hitCount += 1;
- return;
- }
- m_Diminishing.push_back(DiminishingReturn(group, getMSTime(), DIMINISHING_LEVEL_2));
+ DiminishingReturn& diminish = m_Diminishing[group];
+ if (static_cast<int32>(diminish.hitCount) < maxLevel)
+ ++diminish.hitCount;
}
-float Unit::ApplyDiminishingToDuration(DiminishingGroup group, int32 &duration, Unit* caster, DiminishingLevels Level, int32 limitduration)
+float Unit::ApplyDiminishingToDuration(SpellInfo const* auraSpellInfo, bool triggered, int32& duration, Unit* caster, DiminishingLevels previousLevel)
{
+ DiminishingGroup const group = auraSpellInfo->GetDiminishingReturnsGroupForSpell(triggered);
if (duration == -1 || group == DIMINISHING_NONE)
return 1.0f;
+ int32 const limitDuration = auraSpellInfo->GetDiminishingReturnsLimitDuration(triggered);
+
// test pet/charm masters instead pets/charmeds
- Unit const* tarGetOwner = GetCharmerOrOwner();
+ Unit const* targetOwner = GetCharmerOrOwner();
Unit const* casterOwner = caster->GetCharmerOrOwner();
// Duration of crowd control abilities on pvp target is limited by 10 sec. (2.2.0)
- if (limitduration > 0 && duration > limitduration)
+ if (limitDuration > 0 && duration > limitDuration)
{
- Unit const* target = tarGetOwner ? tarGetOwner : this;
+ Unit const* target = targetOwner ? targetOwner : this;
Unit const* source = casterOwner ? casterOwner : caster;
if ((target->GetTypeId() == TYPEID_PLAYER
|| target->ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_ALL_DIMINISH)
&& source->GetTypeId() == TYPEID_PLAYER)
- duration = limitduration;
+ duration = limitDuration;
}
float mod = 1.0f;
@@ -9794,7 +9806,7 @@ float Unit::ApplyDiminishingToDuration(DiminishingGroup group, int32 &duration,
{
if (GetTypeId() == TYPEID_UNIT && (ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_TAUNT_DIMINISH))
{
- DiminishingLevels diminish = Level;
+ DiminishingLevels diminish = previousLevel;
switch (diminish)
{
case DIMINISHING_LEVEL_1: break;
@@ -9807,12 +9819,12 @@ float Unit::ApplyDiminishingToDuration(DiminishingGroup group, int32 &duration,
}
}
// Some diminishings applies to mobs too (for example, Stun)
- else if ((GetDiminishingReturnsGroupType(group) == DRTYPE_PLAYER
- && ((tarGetOwner ? (tarGetOwner->GetTypeId() == TYPEID_PLAYER) : (GetTypeId() == TYPEID_PLAYER))
+ else if ((auraSpellInfo->GetDiminishingReturnsGroupType(triggered) == DRTYPE_PLAYER
+ && ((targetOwner ? (targetOwner->GetTypeId() == TYPEID_PLAYER) : (GetTypeId() == TYPEID_PLAYER))
|| (GetTypeId() == TYPEID_UNIT && ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_ALL_DIMINISH)))
- || GetDiminishingReturnsGroupType(group) == DRTYPE_ALL)
+ || auraSpellInfo->GetDiminishingReturnsGroupType(triggered) == DRTYPE_ALL)
{
- DiminishingLevels diminish = Level;
+ DiminishingLevels diminish = previousLevel;
switch (diminish)
{
case DIMINISHING_LEVEL_1: break;
@@ -9830,24 +9842,26 @@ float Unit::ApplyDiminishingToDuration(DiminishingGroup group, int32 &duration,
void Unit::ApplyDiminishingAura(DiminishingGroup group, bool apply)
{
// Checking for existing in the table
- for (Diminishing::iterator i = m_Diminishing.begin(); i != m_Diminishing.end(); ++i)
+ DiminishingReturn& diminish = m_Diminishing[group];
+
+ if (apply)
+ ++diminish.stack;
+ else if (diminish.stack)
{
- if (i->DRGroup != group)
- continue;
+ --diminish.stack;
- if (apply)
- i->stack += 1;
- else if (i->stack)
- {
- i->stack -= 1;
- // Remember time after last aura from group removed
- if (i->stack == 0)
- i->hitTime = getMSTime();
- }
- break;
+ // Remember time after last aura from group removed
+ if (!diminish.stack)
+ diminish.hitTime = getMSTime();
}
}
+void Unit::ClearDiminishings()
+{
+ for (uint32 i = 0; i < DIMINISHING_MAX; ++i)
+ m_Diminishing[i].Clear();
+}
+
float Unit::GetSpellMaxRangeForTarget(Unit const* target, SpellInfo const* spellInfo) const
{
if (!spellInfo->RangeEntry)
@@ -10777,14 +10791,13 @@ uint32 createProcHitMask(SpellNonMeleeDamage* damageInfo, SpellMissInfo missCond
hitMask |= PROC_HIT_PARRY;
break;
case SPELL_MISS_BLOCK:
- hitMask |= PROC_HIT_BLOCK;
+ // spells can't be partially blocked (it's damage can though)
+ hitMask |= PROC_HIT_BLOCK | PROC_HIT_FULL_BLOCK;
break;
case SPELL_MISS_EVADE:
hitMask |= PROC_HIT_EVADE;
break;
case SPELL_MISS_IMMUNE:
- hitMask |= PROC_HIT_IMMUNE;
- break;
case SPELL_MISS_IMMUNE2:
hitMask |= PROC_HIT_IMMUNE;
break;
@@ -10797,6 +10810,9 @@ uint32 createProcHitMask(SpellNonMeleeDamage* damageInfo, SpellMissInfo missCond
case SPELL_MISS_REFLECT:
hitMask |= PROC_HIT_REFLECT;
break;
+ case SPELL_MISS_RESIST:
+ hitMask |= PROC_HIT_FULL_RESIST;
+ break;
default:
break;
}
@@ -10805,15 +10821,27 @@ uint32 createProcHitMask(SpellNonMeleeDamage* damageInfo, SpellMissInfo missCond
{
// On block
if (damageInfo->blocked)
+ {
hitMask |= PROC_HIT_BLOCK;
+ if (damageInfo->fullBlock)
+ hitMask |= PROC_HIT_FULL_BLOCK;
+ }
// On absorb
if (damageInfo->absorb)
hitMask |= PROC_HIT_ABSORB;
- // On crit
- if (damageInfo->HitInfo & SPELL_HIT_TYPE_CRIT)
- hitMask |= PROC_HIT_CRITICAL;
- else
- hitMask |= PROC_HIT_NORMAL;
+
+ // Don't set hit/crit hitMask if damage is nullified
+ bool const damageNullified = (damageInfo->HitInfo & (HITINFO_FULL_ABSORB | HITINFO_FULL_RESIST)) != 0 || (hitMask & PROC_HIT_FULL_BLOCK) != 0;
+ if (!damageNullified)
+ {
+ // On crit
+ if (damageInfo->HitInfo & SPELL_HIT_TYPE_CRIT)
+ hitMask |= PROC_HIT_CRITICAL;
+ else
+ hitMask |= PROC_HIT_NORMAL;
+ }
+ else if ((damageInfo->HitInfo & HITINFO_FULL_RESIST) != 0)
+ hitMask |= PROC_HIT_FULL_RESIST;
}
return hitMask;
@@ -10902,10 +10930,10 @@ void Unit::GetProcAurasTriggeredOnEvent(AuraApplicationProcContainer& aurasTrigg
for (AuraApplication* aurApp : *procAuras)
{
ASSERT(aurApp->GetTarget() == this);
- if (uint8 procEffectMask = aurApp->GetBase()->IsProcTriggeredOnEvent(aurApp, eventInfo, now))
+ if (uint8 procEffectMask = aurApp->GetBase()->GetProcEffectMask(aurApp, eventInfo, now))
{
aurApp->GetBase()->PrepareProcToTrigger(aurApp, eventInfo, now);
- aurasTriggeringProc.emplace_back(std::make_pair(procEffectMask, aurApp));
+ aurasTriggeringProc.emplace_back(procEffectMask, aurApp);
}
}
}
@@ -10914,10 +10942,10 @@ void Unit::GetProcAurasTriggeredOnEvent(AuraApplicationProcContainer& aurasTrigg
{
for (AuraApplicationMap::iterator itr = GetAppliedAuras().begin(); itr != GetAppliedAuras().end(); ++itr)
{
- if (uint8 procEffectMask = itr->second->GetBase()->IsProcTriggeredOnEvent(itr->second, eventInfo, now))
+ if (uint8 procEffectMask = itr->second->GetBase()->GetProcEffectMask(itr->second, eventInfo, now))
{
itr->second->GetBase()->PrepareProcToTrigger(itr->second, eventInfo, now);
- aurasTriggeringProc.emplace_back(std::make_pair(procEffectMask, itr->second));
+ aurasTriggeringProc.emplace_back(procEffectMask, itr->second);
}
}
}
@@ -10933,16 +10961,31 @@ void Unit::TriggerAurasProcOnEvent(Unit* actionTarget, uint32 typeMaskActor, uin
{
// prepare data for self trigger
ProcEventInfo myProcEventInfo(this, actionTarget, actionTarget, typeMaskActor, spellTypeMask, spellPhaseMask, hitMask, spell, damageInfo, healInfo);
- if (typeMaskActor && CanProc())
+ if (typeMaskActor)
{
AuraApplicationProcContainer myAurasTriggeringProc;
GetProcAurasTriggeredOnEvent(myAurasTriggeringProc, nullptr, myProcEventInfo);
+
+ // needed for example for Cobra Strikes, pet does the attack, but aura is on owner
+ if (Player* modOwner = GetSpellModOwner())
+ {
+ if (modOwner != this && spell)
+ {
+ AuraApplicationList modAuras;
+ for (auto itr = modOwner->GetAppliedAuras().begin(); itr != modOwner->GetAppliedAuras().end(); ++itr)
+ {
+ if (spell->m_appliedMods.count(itr->second->GetBase()) != 0)
+ modAuras.push_back(itr->second);
+ }
+ modOwner->GetProcAurasTriggeredOnEvent(myAurasTriggeringProc, &modAuras, myProcEventInfo);
+ }
+ }
TriggerAurasProcOnEvent(myProcEventInfo, myAurasTriggeringProc);
}
// prepare data for target trigger
ProcEventInfo targetProcEventInfo(this, actionTarget, this, typeMaskActionTarget, spellTypeMask, spellPhaseMask, hitMask, spell, damageInfo, healInfo);
- if (typeMaskActionTarget && actionTarget && actionTarget->CanProc())
+ if (typeMaskActionTarget && actionTarget)
{
AuraApplicationProcContainer targetAurasTriggeringProc;
actionTarget->GetProcAurasTriggeredOnEvent(targetAurasTriggeringProc, nullptr, targetProcEventInfo);
@@ -10952,6 +10995,11 @@ void Unit::TriggerAurasProcOnEvent(Unit* actionTarget, uint32 typeMaskActor, uin
void Unit::TriggerAurasProcOnEvent(ProcEventInfo& eventInfo, AuraApplicationProcContainer& aurasTriggeringProc)
{
+ Spell const* triggeringSpell = eventInfo.GetProcSpell();
+ bool const disableProcs = triggeringSpell && triggeringSpell->IsProcDisabled();
+ if (disableProcs)
+ SetCantProc(true);
+
for (auto const& aurAppProc : aurasTriggeringProc)
{
AuraApplication* aurApp;
@@ -10970,6 +11018,9 @@ void Unit::TriggerAurasProcOnEvent(ProcEventInfo& eventInfo, AuraApplicationProc
if (spellInfo->HasAttribute(SPELL_ATTR3_DISABLE_PROC))
SetCantProc(false);
}
+
+ if (disableProcs)
+ SetCantProc(false);
}
SpellSchoolMask Unit::GetMeleeDamageSchoolMask() const
@@ -11419,26 +11470,41 @@ float Unit::CalculateDefaultCoefficient(SpellInfo const* spellInfo, DamageEffect
float Unit::GetAPMultiplier(WeaponAttackType attType, bool normalized)
{
- if (!normalized || GetTypeId() != TYPEID_PLAYER)
- return float(GetAttackTime(attType)) / 1000.0f;
+ if (GetTypeId() != TYPEID_PLAYER)
+ return GetAttackTime(attType) / 1000.0f;
+
+ Item* weapon = ToPlayer()->GetWeaponForAttack(attType, true);
+ if (!weapon)
+ return BASE_ATTACK_TIME / 1000.0f;
- Item* Weapon = ToPlayer()->GetWeaponForAttack(attType, true);
- if (!Weapon)
- return 2.4f; // fist attack
+ if (!normalized)
+ return weapon->GetTemplate()->Delay / 1000.0f;
- switch (Weapon->GetTemplate()->InventoryType)
+ switch (weapon->GetTemplate()->SubClass)
{
- case INVTYPE_2HWEAPON:
+ case ITEM_SUBCLASS_WEAPON_AXE2:
+ case ITEM_SUBCLASS_WEAPON_MACE2:
+ case ITEM_SUBCLASS_WEAPON_POLEARM:
+ case ITEM_SUBCLASS_WEAPON_SWORD2:
+ case ITEM_SUBCLASS_WEAPON_STAFF:
+ case ITEM_SUBCLASS_WEAPON_FISHING_POLE:
return 3.3f;
- case INVTYPE_RANGED:
- case INVTYPE_RANGEDRIGHT:
- case INVTYPE_THROWN:
+ case ITEM_SUBCLASS_WEAPON_BOW:
+ case ITEM_SUBCLASS_WEAPON_GUN:
+ case ITEM_SUBCLASS_WEAPON_CROSSBOW:
+ case ITEM_SUBCLASS_WEAPON_THROWN:
return 2.8f;
- case INVTYPE_WEAPON:
- case INVTYPE_WEAPONMAINHAND:
- case INVTYPE_WEAPONOFFHAND:
+ case ITEM_SUBCLASS_WEAPON_AXE:
+ case ITEM_SUBCLASS_WEAPON_MACE:
+ case ITEM_SUBCLASS_WEAPON_SWORD:
+ case ITEM_SUBCLASS_WEAPON_EXOTIC:
+ case ITEM_SUBCLASS_WEAPON_EXOTIC2:
+ case ITEM_SUBCLASS_WEAPON_FIST:
+ return 2.4f;
+ case ITEM_SUBCLASS_WEAPON_DAGGER:
+ return 1.7f;
default:
- return Weapon->GetTemplate()->SubClass == ITEM_SUBCLASS_WEAPON_DAGGER ? 1.7f : 2.4f;
+ return weapon->GetTemplate()->Delay / 1000.0f;
}
}
@@ -12466,8 +12532,9 @@ bool Unit::IsInPartyWith(Unit const* unit) const
else if ((u2->GetTypeId() == TYPEID_PLAYER && u1->GetTypeId() == TYPEID_UNIT && u1->ToCreature()->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_TREAT_AS_RAID_UNIT) ||
(u1->GetTypeId() == TYPEID_PLAYER && u2->GetTypeId() == TYPEID_UNIT && u2->ToCreature()->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_TREAT_AS_RAID_UNIT))
return true;
- else
- return false;
+
+ // else u1->GetTypeId() == u2->GetTypeId() == TYPEID_UNIT
+ return u1->getFaction() == u2->getFaction();
}
bool Unit::IsInRaidWith(Unit const* unit) const
@@ -12485,8 +12552,9 @@ bool Unit::IsInRaidWith(Unit const* unit) const
else if ((u2->GetTypeId() == TYPEID_PLAYER && u1->GetTypeId() == TYPEID_UNIT && u1->ToCreature()->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_TREAT_AS_RAID_UNIT) ||
(u1->GetTypeId() == TYPEID_PLAYER && u2->GetTypeId() == TYPEID_UNIT && u2->ToCreature()->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_TREAT_AS_RAID_UNIT))
return true;
- else
- return false;
+
+ // else u1->GetTypeId() == u2->GetTypeId() == TYPEID_UNIT
+ return u1->getFaction() == u2->getFaction();
}
void Unit::GetPartyMembers(std::list<Unit*> &TagUnitMap)
diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h
index aee3d783868..917e5d24c79 100644
--- a/src/server/game/Entities/Unit/Unit.h
+++ b/src/server/game/Entities/Unit/Unit.h
@@ -324,20 +324,21 @@ enum HitInfo
HITINFO_FULL_RESIST = 0x00000080,
HITINFO_PARTIAL_RESIST = 0x00000100,
HITINFO_CRITICALHIT = 0x00000200, // critical hit
- // 0x00000400
- // 0x00000800
- // 0x00001000
+ HITINFO_UNK10 = 0x00000400,
+ HITINFO_UNK11 = 0x00000800,
+ HITINFO_UNK12 = 0x00001000,
HITINFO_BLOCK = 0x00002000, // blocked damage
- // 0x00004000 // Hides worldtext for 0 damage
- // 0x00008000 // Related to blood visual
+ HITINFO_UNK14 = 0x00004000, // set only if meleespellid is present// no world text when victim is hit for 0 dmg(HideWorldTextForNoDamage?)
+ HITINFO_UNK15 = 0x00008000, // player victim?// something related to blod sprut visual (BloodSpurtInBack?)
HITINFO_GLANCING = 0x00010000,
HITINFO_CRUSHING = 0x00020000,
HITINFO_NO_ANIMATION = 0x00040000,
- // 0x00080000
- // 0x00100000
+ HITINFO_UNK19 = 0x00080000,
+ HITINFO_UNK20 = 0x00100000,
HITINFO_SWINGNOHITSOUND = 0x00200000, // unused?
- // 0x00400000
- HITINFO_RAGE_GAIN = 0x00800000
+ HITINFO_UNK22 = 0x00400000,
+ HITINFO_RAGE_GAIN = 0x00800000,
+ HITINFO_FAKE_DAMAGE = 0x01000000 // enables damage animation even if no damage done, set only if no damage
};
//i would like to remove this: (it is defined in item.h
@@ -376,13 +377,7 @@ class SpellCastTargets;
typedef std::list<Unit*> UnitList;
typedef std::list<std::pair<Aura*, uint8>> DispelChargesList;
-struct SpellImmune
-{
- uint32 type;
- uint32 spellId;
-};
-
-typedef std::list<SpellImmune> SpellImmuneList;
+typedef std::unordered_multimap<uint32 /*type*/, uint32 /*spellId*/> SpellImmuneContainer;
enum UnitModifierType
{
@@ -424,12 +419,18 @@ enum TriggerCastFlags
TRIGGERED_IGNORE_SET_FACING = 0x00000200, //! Will not adjust facing to target (if any)
TRIGGERED_IGNORE_SHAPESHIFT = 0x00000400, //! Will ignore shapeshift checks
TRIGGERED_IGNORE_CASTER_AURASTATE = 0x00000800, //! Will ignore caster aura states including combat requirements and death state
+ TRIGGERED_DISALLOW_PROC_EVENTS = 0x00001000, //! Disallows proc events from triggered spell (default)
TRIGGERED_IGNORE_CASTER_MOUNTED_OR_ON_VEHICLE = 0x00002000, //! Will ignore mounted/on vehicle restrictions
+ // reuse = 0x00004000,
+ // reuse = 0x00008000,
TRIGGERED_IGNORE_CASTER_AURAS = 0x00010000, //! Will ignore caster aura restrictions or requirements
TRIGGERED_DONT_RESET_PERIODIC_TIMER = 0x00020000, //! Will allow periodic aura timers to keep ticking (instead of resetting)
TRIGGERED_DONT_REPORT_CAST_ERROR = 0x00040000, //! Will return SPELL_FAILED_DONT_REPORT in CheckCast functions
+ TRIGGERED_FULL_MASK = 0x0007FFFF, //! Used when doing CastSpell with triggered == true
+
+ // debug flags (used with .cast triggered commands)
TRIGGERED_IGNORE_EQUIPPED_ITEM_REQUIREMENT = 0x00080000, //! Will ignore equipped item requirements
- TRIGGERED_FULL_MASK = 0xFFFFFFFF
+ TRIGGERED_FULL_DEBUG_MASK = 0xFFFFFFFF
};
enum UnitMods
@@ -801,11 +802,15 @@ namespace Movement{
struct DiminishingReturn
{
- DiminishingReturn(DiminishingGroup group, uint32 t, uint32 count)
- : DRGroup(group), stack(0), hitTime(t), hitCount(count)
- { }
+ DiminishingReturn() : stack(0), hitTime(0), hitCount(DIMINISHING_LEVEL_1) { }
+
+ void Clear()
+ {
+ stack = 0;
+ hitTime = 0;
+ hitCount = DIMINISHING_LEVEL_1;
+ }
- DiminishingGroup DRGroup;
uint16 stack;
uint32 hitTime;
uint32 hitCount;
@@ -978,7 +983,7 @@ struct TC_GAME_API SpellNonMeleeDamage
{
SpellNonMeleeDamage(Unit* _attacker, Unit* _target, uint32 _SpellID, uint32 _schoolMask)
: target(_target), attacker(_attacker), SpellID(_SpellID), damage(0), overkill(0), schoolMask(_schoolMask),
- absorb(0), resist(0), physicalLog(false), unused(false), blocked(0), HitInfo(0), cleanDamage(0)
+ absorb(0), resist(0), physicalLog(false), unused(false), blocked(0), HitInfo(0), cleanDamage(0), fullBlock(false)
{ }
Unit *target;
@@ -995,6 +1000,7 @@ struct TC_GAME_API SpellNonMeleeDamage
uint32 HitInfo;
// Used for help
uint32 cleanDamage;
+ bool fullBlock;
};
struct SpellPeriodicAuraLogInfo
@@ -1255,9 +1261,9 @@ class TC_GAME_API Unit : public WorldObject
typedef std::list<AuraEffect*> AuraEffectList;
typedef std::list<Aura*> AuraList;
typedef std::list<AuraApplication *> AuraApplicationList;
- typedef std::list<DiminishingReturn> Diminishing;
+ typedef std::array<DiminishingReturn, DIMINISHING_MAX> Diminishing;
- typedef std::deque<std::pair<uint8 /*procEffectMask*/, AuraApplication*>> AuraApplicationProcContainer;
+ typedef std::vector<std::pair<uint8 /*procEffectMask*/, AuraApplication*>> AuraApplicationProcContainer;
typedef std::map<uint8, AuraApplication*> VisibleAuraMap;
@@ -1272,11 +1278,11 @@ class TC_GAME_API Unit : public WorldObject
void CleanupBeforeRemoveFromMap(bool finalCleanup);
void CleanupsBeforeDelete(bool finalCleanup = true) override; // used in ~Creature/~Player (or before mass creature delete to remove cross-references to already deleted units)
- DiminishingLevels GetDiminishing(DiminishingGroup group);
- void IncrDiminishing(DiminishingGroup group);
- float ApplyDiminishingToDuration(DiminishingGroup group, int32 &duration, Unit* caster, DiminishingLevels Level, int32 limitduration);
- void ApplyDiminishingAura(DiminishingGroup group, bool apply);
- void ClearDiminishings() { m_Diminishing.clear(); }
+ DiminishingLevels GetDiminishing(DiminishingGroup group);
+ void IncrDiminishing(SpellInfo const* auraSpellInfo, bool triggered);
+ float ApplyDiminishingToDuration(SpellInfo const* auraSpellInfo, bool triggered, int32& duration, Unit* caster, DiminishingLevels previousLevel);
+ void ApplyDiminishingAura(DiminishingGroup group, bool apply);
+ void ClearDiminishings();
// target dependent range checks
float GetSpellMaxRangeForTarget(Unit const* target, SpellInfo const* spellInfo) const;
@@ -1296,10 +1302,7 @@ class TC_GAME_API Unit : public WorldObject
bool IsWithinMeleeRange(Unit const* obj) const;
float GetMeleeRange(Unit const* target) const;
void GetRandomContactPoint(const Unit* target, float &x, float &y, float &z, float distance2dMin, float distance2dMax) const;
-
- bool HasExtraAttacksPending() const { return m_extraAttacks > 0; }
- void SetExtraAttacks(uint32 val) { m_extraAttacks = static_cast<int32>(val); }
-
+ uint32 m_extraAttacks;
bool m_canDualWield;
void _addAttacker(Unit* pAttacker); // must be called only from Unit::Attack(Unit*)
@@ -1431,7 +1434,7 @@ class TC_GAME_API Unit : public WorldObject
void Dismount();
uint16 GetMaxSkillValueForLevel(Unit const* target = NULL) const { return (target ? getLevelForTarget(target) : getLevel()) * 5; }
- void DealDamageMods(Unit* victim, uint32 &damage, uint32* absorb);
+ void DealDamageMods(Unit const* victim, uint32 &damage, uint32* absorb) const;
uint32 DealDamage(Unit* victim, uint32 damage, CleanDamage const* cleanDamage = NULL, DamageEffectType damagetype = DIRECT_DAMAGE, SpellSchoolMask damageSchoolMask = SPELL_SCHOOL_MASK_NORMAL, SpellInfo const* spellProto = NULL, bool durabilityLoss = true);
void Kill(Unit* victim, bool durabilityLoss = true);
void KillSelf(bool durabilityLoss = true) { Kill(this, durabilityLoss); }
@@ -1450,6 +1453,7 @@ class TC_GAME_API Unit : public WorldObject
void HandleEmoteCommand(uint32 anim_id);
void AttackerStateUpdate (Unit* victim, WeaponAttackType attType = BASE_ATTACK, bool extra = false);
+ void FakeAttackerStateUpdate(Unit* victim, WeaponAttackType attType = BASE_ATTACK);
void CalculateMeleeDamage(Unit* victim, uint32 damage, CalcDamageInfo* damageInfo, WeaponAttackType attackType = BASE_ATTACK);
void DealMeleeDamage(CalcDamageInfo* damageInfo, bool durabilityLoss);
@@ -1557,19 +1561,19 @@ class TC_GAME_API Unit : public WorldObject
int32 HealBySpell(HealInfo& healInfo, bool critical = false);
void SendEnergizeSpellLog(Unit* victim, uint32 spellID, int32 damage, Powers powerType);
void EnergizeBySpell(Unit* victim, uint32 SpellID, int32 Damage, Powers powertype);
- uint32 SpellNonMeleeDamageLog(Unit* victim, uint32 spellID, uint32 damage);
-
- void CastSpell(SpellCastTargets const& targets, SpellInfo const* spellInfo, CustomSpellValues const* value, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem = NULL, AuraEffect const* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid::Empty);
- void CastSpell(Unit* victim, uint32 spellId, bool triggered, Item* castItem = NULL, AuraEffect const* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid::Empty);
- void CastSpell(Unit* victim, uint32 spellId, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem = NULL, AuraEffect const* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid::Empty);
- void CastSpell(Unit* victim, SpellInfo const* spellInfo, bool triggered, Item* castItem = NULL, AuraEffect const* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid::Empty);
- void CastSpell(Unit* victim, SpellInfo const* spellInfo, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem = NULL, AuraEffect const* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid::Empty);
- void CastSpell(float x, float y, float z, uint32 spellId, bool triggered, Item* castItem = NULL, AuraEffect const* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid::Empty);
- void CastSpell(GameObject* go, uint32 spellId, bool triggered, Item* castItem = NULL, AuraEffect* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid::Empty);
- void CastCustomSpell(Unit* victim, uint32 spellId, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item* castItem = NULL, AuraEffect const* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid::Empty);
- void CastCustomSpell(uint32 spellId, SpellValueMod mod, int32 value, Unit* victim, bool triggered, Item* castItem = NULL, AuraEffect const* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid::Empty);
- void CastCustomSpell(uint32 spellId, SpellValueMod mod, int32 value, Unit* victim = NULL, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem = NULL, AuraEffect const* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid::Empty);
- void CastCustomSpell(uint32 spellId, CustomSpellValues const &value, Unit* victim = NULL, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem = NULL, AuraEffect const* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid::Empty);
+
+ void CastSpell(SpellCastTargets const& targets, SpellInfo const* spellInfo, CustomSpellValues const* value, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, ObjectGuid originalCaster = ObjectGuid::Empty);
+ void CastSpell(Unit* victim, uint32 spellId, bool triggered, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, ObjectGuid originalCaster = ObjectGuid::Empty);
+ void CastSpell(Unit* victim, uint32 spellId, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, ObjectGuid originalCaster = ObjectGuid::Empty);
+ void CastSpell(Unit* victim, SpellInfo const* spellInfo, bool triggered, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, ObjectGuid originalCaster = ObjectGuid::Empty);
+ void CastSpell(Unit* victim, SpellInfo const* spellInfo, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, ObjectGuid originalCaster = ObjectGuid::Empty);
+ void CastSpell(float x, float y, float z, uint32 spellId, bool triggered, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, ObjectGuid originalCaster = ObjectGuid::Empty);
+ void CastSpell(float x, float y, float z, uint32 spellId, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, ObjectGuid originalCaster = ObjectGuid::Empty);
+ void CastSpell(GameObject* go, uint32 spellId, bool triggered, Item* castItem = nullptr, AuraEffect* triggeredByAura = nullptr, ObjectGuid originalCaster = ObjectGuid::Empty);
+ void CastCustomSpell(Unit* victim, uint32 spellId, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, ObjectGuid originalCaster = ObjectGuid::Empty);
+ void CastCustomSpell(uint32 spellId, SpellValueMod mod, int32 value, Unit* victim, bool triggered, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, ObjectGuid originalCaster = ObjectGuid::Empty);
+ void CastCustomSpell(uint32 spellId, SpellValueMod mod, int32 value, Unit* victim = nullptr, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, ObjectGuid originalCaster = ObjectGuid::Empty);
+ void CastCustomSpell(uint32 spellId, CustomSpellValues const &value, Unit* victim = nullptr, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, ObjectGuid originalCaster = ObjectGuid::Empty);
Aura* AddAura(uint32 spellId, Unit* target);
Aura* AddAura(SpellInfo const* spellInfo, uint8 effMask, Unit* target);
void SetAuraStack(uint32 spellId, Unit* target, uint32 stack);
@@ -1933,7 +1937,7 @@ class TC_GAME_API Unit : public WorldObject
void SetPhaseMask(uint32 newPhaseMask, bool update) override;// overwrite WorldObject::SetPhaseMask
void UpdateObjectVisibility(bool forced = true) override;
- SpellImmuneList m_spellImmune[MAX_SPELL_IMMUNITY];
+ SpellImmuneContainer m_spellImmune[MAX_SPELL_IMMUNITY];
uint32 m_lastSanctuaryTime;
// Threat related methods
@@ -2018,7 +2022,6 @@ class TC_GAME_API Unit : public WorldObject
uint32 GetRemainingPeriodicAmount(ObjectGuid caster, uint32 spellId, AuraType auraType, uint8 effectIndex = 0) const;
void ApplySpellImmune(uint32 spellId, uint32 op, uint32 type, bool apply);
- void ApplySpellDispelImmunity(const SpellInfo* spellProto, DispelType type, bool apply);
virtual bool IsImmunedToSpell(SpellInfo const* spellInfo) const; // redefined in Creature
uint32 GetSchoolImmunityMask() const;
uint32 GetMechanicImmunityMask() const;
@@ -2030,8 +2033,8 @@ class TC_GAME_API Unit : public WorldObject
static bool IsDamageReducedByArmor(SpellSchoolMask damageSchoolMask, SpellInfo const* spellInfo = NULL, uint8 effIndex = MAX_SPELL_EFFECTS);
uint32 CalcArmorReducedDamage(Unit* victim, const uint32 damage, SpellInfo const* spellInfo, WeaponAttackType attackType = MAX_ATTACK);
uint32 CalcSpellResistance(Unit* victim, SpellSchoolMask schoolMask, SpellInfo const* spellInfo) const;
- void CalcAbsorbResist(Unit* victim, SpellSchoolMask schoolMask, DamageEffectType damagetype, uint32 const damage, uint32* absorb, uint32* resist, SpellInfo const* spellInfo = NULL);
- void CalcHealAbsorb(HealInfo& healInfo);
+ void CalcAbsorbResist(DamageInfo& damageInfo);
+ void CalcHealAbsorb(HealInfo& healInfo) const;
void UpdateSpeed(UnitMoveType mtype);
float GetSpeed(UnitMoveType mtype) const;
@@ -2288,8 +2291,6 @@ class TC_GAME_API Unit : public WorldObject
uint32 m_lastManaUse; // msecs
TimeTrackerSmall m_movesplineTimer;
- int32 m_extraAttacks;
-
Diminishing m_Diminishing;
// Manage all Units that are threatened by us
HostileRefManager m_HostileRefManager;
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp
index 781d30f148d..e594cf7f289 100644
--- a/src/server/game/Globals/ObjectMgr.cpp
+++ b/src/server/game/Globals/ObjectMgr.cpp
@@ -804,7 +804,10 @@ void ObjectMgr::CheckCreatureTemplate(CreatureTemplate const* cInfo)
FactionTemplateEntry const* factionTemplate = sFactionTemplateStore.LookupEntry(cInfo->faction);
if (!factionTemplate)
- TC_LOG_ERROR("sql.sql", "Creature (Entry: %u) has non-existing faction template (%u).", cInfo->Entry, cInfo->faction);
+ {
+ TC_LOG_FATAL("sql.sql", "Creature (Entry: %u) has non-existing faction template (%u). This can lead to crashes, aborting.", cInfo->Entry, cInfo->faction);
+ ABORT();
+ }
// used later for scale
CreatureDisplayInfoEntry const* displayScaleEntry = nullptr;
@@ -2545,23 +2548,23 @@ void ObjectMgr::LoadItemTemplates()
itemTemplate.Quality = ITEM_QUALITY_NORMAL;
}
- if (itemTemplate.Flags2 & ITEM_FLAGS_EXTRA_HORDE_ONLY)
+ if (itemTemplate.Flags2 & ITEM_FLAG2_FACTION_HORDE)
{
if (FactionEntry const* faction = sFactionStore.LookupEntry(HORDE))
if ((itemTemplate.AllowableRace & faction->BaseRepRaceMask[0]) == 0)
- TC_LOG_ERROR("sql.sql", "Item (Entry: %u) has value (%u) in `AllowableRace` races, not compatible with ITEM_FLAGS_EXTRA_HORDE_ONLY (%u) in Flags field, item cannot be equipped or used by these races.",
- entry, itemTemplate.AllowableRace, ITEM_FLAGS_EXTRA_HORDE_ONLY);
+ TC_LOG_ERROR("sql.sql", "Item (Entry: %u) has value (%u) in `AllowableRace` races, not compatible with ITEM_FLAG2_FACTION_HORDE (%u) in Flags field, item cannot be equipped or used by these races.",
+ entry, itemTemplate.AllowableRace, ITEM_FLAG2_FACTION_HORDE);
- if (itemTemplate.Flags2 & ITEM_FLAGS_EXTRA_ALLIANCE_ONLY)
- TC_LOG_ERROR("sql.sql", "Item (Entry: %u) has value (%u) in `Flags2` flags (ITEM_FLAGS_EXTRA_ALLIANCE_ONLY) and ITEM_FLAGS_EXTRA_HORDE_ONLY (%u) in Flags field, this is a wrong combination.",
- entry, ITEM_FLAGS_EXTRA_ALLIANCE_ONLY, ITEM_FLAGS_EXTRA_HORDE_ONLY);
+ if (itemTemplate.Flags2 & ITEM_FLAG2_FACTION_ALLIANCE)
+ TC_LOG_ERROR("sql.sql", "Item (Entry: %u) has value (%u) in `Flags2` flags (ITEM_FLAG2_FACTION_ALLIANCE) and ITEM_FLAG2_FACTION_HORDE (%u) in Flags field, this is a wrong combination.",
+ entry, ITEM_FLAG2_FACTION_ALLIANCE, ITEM_FLAG2_FACTION_HORDE);
}
- else if (itemTemplate.Flags2 & ITEM_FLAGS_EXTRA_ALLIANCE_ONLY)
+ else if (itemTemplate.Flags2 & ITEM_FLAG2_FACTION_ALLIANCE)
{
if (FactionEntry const* faction = sFactionStore.LookupEntry(ALLIANCE))
if ((itemTemplate.AllowableRace & faction->BaseRepRaceMask[0]) == 0)
- TC_LOG_ERROR("sql.sql", "Item (Entry: %u) has value (%u) in `AllowableRace` races, not compatible with ITEM_FLAGS_EXTRA_ALLIANCE_ONLY (%u) in Flags field, item cannot be equipped or used by these races.",
- entry, itemTemplate.AllowableRace, ITEM_FLAGS_EXTRA_ALLIANCE_ONLY);
+ TC_LOG_ERROR("sql.sql", "Item (Entry: %u) has value (%u) in `AllowableRace` races, not compatible with ITEM_FLAG2_FACTION_ALLIANCE (%u) in Flags field, item cannot be equipped or used by these races.",
+ entry, itemTemplate.AllowableRace, ITEM_FLAG2_FACTION_ALLIANCE);
}
if (itemTemplate.BuyCount <= 0)
diff --git a/src/server/game/Globals/ObjectMgr.h b/src/server/game/Globals/ObjectMgr.h
index ea0a4da8d62..a30d92ad68a 100644
--- a/src/server/game/Globals/ObjectMgr.h
+++ b/src/server/game/Globals/ObjectMgr.h
@@ -428,7 +428,7 @@ struct BroadcastText
std::string const& GetText(LocaleConstant locale = DEFAULT_LOCALE, uint8 gender = GENDER_MALE, bool forceGender = false) const
{
- if (gender == GENDER_FEMALE && (forceGender || !FemaleText[DEFAULT_LOCALE].empty()))
+ if ((gender == GENDER_FEMALE || gender == GENDER_NONE) && (forceGender || !FemaleText[DEFAULT_LOCALE].empty()))
{
if (FemaleText.size() > size_t(locale) && !FemaleText[locale].empty())
return FemaleText[locale];
diff --git a/src/server/game/Grids/GridRefManager.h b/src/server/game/Grids/GridRefManager.h
index 755417d873d..ceaf632aa63 100644
--- a/src/server/game/Grids/GridRefManager.h
+++ b/src/server/game/Grids/GridRefManager.h
@@ -35,8 +35,6 @@ class GridRefManager : public RefManager<GridRefManager<OBJECT>, OBJECT>
iterator begin() { return iterator(getFirst()); }
iterator end() { return iterator(NULL); }
- iterator rbegin() { return iterator(getLast()); }
- iterator rend() { return iterator(NULL); }
};
#endif
diff --git a/src/server/game/Grids/Notifiers/GridNotifiers.h b/src/server/game/Grids/Notifiers/GridNotifiers.h
index 8304054c663..ac153f31b8e 100644
--- a/src/server/game/Grids/Notifiers/GridNotifiers.h
+++ b/src/server/game/Grids/Notifiers/GridNotifiers.h
@@ -170,6 +170,31 @@ namespace Trinity
// WorldObject searchers & workers
+ // Generic base class to insert elements into arbitrary containers using push_back
+ template<typename Type>
+ class ContainerInserter {
+ using InserterType = void(*)(void*, Type&&);
+
+ void* ref;
+ InserterType inserter;
+
+ // MSVC workaround
+ template<typename T>
+ static void InserterOf(void* ref, Type&& type)
+ {
+ static_cast<T*>(ref)->push_back(std::move(type));
+ }
+
+ protected:
+ template<typename T>
+ ContainerInserter(T& ref_) : ref(&ref_), inserter(&InserterOf<T>) { }
+
+ void Insert(Type type)
+ {
+ inserter(ref, std::move(type));
+ }
+ };
+
template<class Check>
struct WorldObjectSearcher
{
@@ -211,15 +236,16 @@ namespace Trinity
};
template<class Check>
- struct WorldObjectListSearcher
+ struct WorldObjectListSearcher : ContainerInserter<WorldObject*>
{
uint32 i_mapTypeMask;
uint32 i_phaseMask;
- std::list<WorldObject*> &i_objects;
Check& i_check;
- WorldObjectListSearcher(WorldObject const* searcher, std::list<WorldObject*> &objects, Check & check, uint32 mapTypeMask = GRID_MAP_TYPE_MASK_ALL)
- : i_mapTypeMask(mapTypeMask), i_phaseMask(searcher->GetPhaseMask()), i_objects(objects), i_check(check) { }
+ template<typename Container>
+ WorldObjectListSearcher(WorldObject const* searcher, Container& container, Check & check, uint32 mapTypeMask = GRID_MAP_TYPE_MASK_ALL)
+ : ContainerInserter<WorldObject*>(container),
+ i_mapTypeMask(mapTypeMask), i_phaseMask(searcher->GetPhaseMask()), i_check(check) { }
void Visit(PlayerMapType &m);
void Visit(CreatureMapType &m);
@@ -321,14 +347,15 @@ namespace Trinity
};
template<class Check>
- struct GameObjectListSearcher
+ struct GameObjectListSearcher : ContainerInserter<GameObject*>
{
uint32 i_phaseMask;
- std::list<GameObject*> &i_objects;
Check& i_check;
- GameObjectListSearcher(WorldObject const* searcher, std::list<GameObject*> &objects, Check & check)
- : i_phaseMask(searcher->GetPhaseMask()), i_objects(objects), i_check(check) { }
+ template<typename Container>
+ GameObjectListSearcher(WorldObject const* searcher, Container& container, Check & check)
+ : ContainerInserter<GameObject*>(container),
+ i_phaseMask(searcher->GetPhaseMask()), i_check(check) { }
void Visit(GameObjectMapType &m);
@@ -393,14 +420,15 @@ namespace Trinity
// All accepted by Check units if any
template<class Check>
- struct UnitListSearcher
+ struct UnitListSearcher : ContainerInserter<Unit*>
{
uint32 i_phaseMask;
- std::list<Unit*> &i_objects;
Check& i_check;
- UnitListSearcher(WorldObject const* searcher, std::list<Unit*> &objects, Check & check)
- : i_phaseMask(searcher->GetPhaseMask()), i_objects(objects), i_check(check) { }
+ template<typename Container>
+ UnitListSearcher(WorldObject const* searcher, Container& container, Check& check)
+ : ContainerInserter<Unit*>(container),
+ i_phaseMask(searcher->GetPhaseMask()), i_check(check) { }
void Visit(PlayerMapType &m);
void Visit(CreatureMapType &m);
@@ -442,14 +470,15 @@ namespace Trinity
};
template<class Check>
- struct CreatureListSearcher
+ struct CreatureListSearcher : ContainerInserter<Creature*>
{
uint32 i_phaseMask;
- std::list<Creature*> &i_objects;
Check& i_check;
- CreatureListSearcher(WorldObject const* searcher, std::list<Creature*> &objects, Check & check)
- : i_phaseMask(searcher->GetPhaseMask()), i_objects(objects), i_check(check) { }
+ template<typename Container>
+ CreatureListSearcher(WorldObject const* searcher, Container& container, Check & check)
+ : ContainerInserter<Creature*>(container),
+ i_phaseMask(searcher->GetPhaseMask()), i_check(check) { }
void Visit(CreatureMapType &m);
@@ -493,14 +522,15 @@ namespace Trinity
};
template<class Check>
- struct PlayerListSearcher
+ struct PlayerListSearcher : ContainerInserter<Player*>
{
uint32 i_phaseMask;
- std::list<Player*> &i_objects;
Check& i_check;
- PlayerListSearcher(WorldObject const* searcher, std::list<Player*> &objects, Check & check)
- : i_phaseMask(searcher->GetPhaseMask()), i_objects(objects), i_check(check) { }
+ template<typename Container>
+ PlayerListSearcher(WorldObject const* searcher, Container& container, Check & check)
+ : ContainerInserter<Player*>(container),
+ i_phaseMask(searcher->GetPhaseMask()), i_check(check) { }
void Visit(PlayerMapType &m);
@@ -612,6 +642,7 @@ namespace Trinity
{
public:
GameObjectFocusCheck(Unit const* unit, uint32 focusId) : i_unit(unit), i_focusId(focusId) { }
+
bool operator()(GameObject* go) const
{
if (go->GetGOInfo()->type != GAMEOBJECT_TYPE_SPELL_FOCUS)
@@ -627,6 +658,7 @@ namespace Trinity
return go->IsWithinDistInMap(i_unit, dist);
}
+
private:
Unit const* i_unit;
uint32 i_focusId;
@@ -637,6 +669,7 @@ namespace Trinity
{
public:
NearestGameObjectFishingHole(WorldObject const& obj, float range) : i_obj(obj), i_range(range) { }
+
bool operator()(GameObject* go)
{
if (go->GetGOInfo()->type == GAMEOBJECT_TYPE_FISHINGHOLE && go->isSpawned() && i_obj.IsWithinDistInMap(go, i_range) && i_obj.IsWithinDistInMap(go, (float)go->GetGOInfo()->fishinghole.radius))
@@ -646,19 +679,20 @@ namespace Trinity
}
return false;
}
- float GetLastRange() const { return i_range; }
+
private:
WorldObject const& i_obj;
- float i_range;
+ float i_range;
// prevent clone
- NearestGameObjectFishingHole(NearestGameObjectFishingHole const&);
+ NearestGameObjectFishingHole(NearestGameObjectFishingHole const&) = delete;
};
class NearestGameObjectCheck
{
public:
- NearestGameObjectCheck(WorldObject const& obj) : i_obj(obj), i_range(999) { }
+ NearestGameObjectCheck(WorldObject const& obj) : i_obj(obj), i_range(999.f) { }
+
bool operator()(GameObject* go)
{
if (i_obj.IsWithinDistInMap(go, i_range))
@@ -668,13 +702,13 @@ namespace Trinity
}
return false;
}
- float GetLastRange() const { return i_range; }
+
private:
WorldObject const& i_obj;
float i_range;
// prevent clone this object
- NearestGameObjectCheck(NearestGameObjectCheck const&);
+ NearestGameObjectCheck(NearestGameObjectCheck const&) = delete;
};
// Success at unit in range, range update for next check (this can be use with GameobjectLastSearcher to find nearest GO)
@@ -682,6 +716,7 @@ namespace Trinity
{
public:
NearestGameObjectEntryInObjectRangeCheck(WorldObject const& obj, uint32 entry, float range) : i_obj(obj), i_entry(entry), i_range(range) { }
+
bool operator()(GameObject* go)
{
if (go->GetEntry() == i_entry && i_obj.IsWithinDistInMap(go, i_range))
@@ -691,38 +726,39 @@ namespace Trinity
}
return false;
}
- float GetLastRange() const { return i_range; }
+
private:
WorldObject const& i_obj;
uint32 i_entry;
float i_range;
// prevent clone this object
- NearestGameObjectEntryInObjectRangeCheck(NearestGameObjectEntryInObjectRangeCheck const&);
+ NearestGameObjectEntryInObjectRangeCheck(NearestGameObjectEntryInObjectRangeCheck const&) = delete;
};
// Success at unit in range, range update for next check (this can be use with GameobjectLastSearcher to find nearest GO with a certain type)
class NearestGameObjectTypeInObjectRangeCheck
{
- public:
- NearestGameObjectTypeInObjectRangeCheck(WorldObject const& obj, GameobjectTypes type, float range) : i_obj(obj), i_type(type), i_range(range) { }
- bool operator()(GameObject* go)
- {
- if (go->GetGoType() == i_type && i_obj.IsWithinDistInMap(go, i_range))
+ public:
+ NearestGameObjectTypeInObjectRangeCheck(WorldObject const& obj, GameobjectTypes type, float range) : i_obj(obj), i_type(type), i_range(range) { }
+
+ bool operator()(GameObject* go)
{
- i_range = i_obj.GetDistance(go); // use found GO range as new range limit for next check
- return true;
+ if (go->GetGoType() == i_type && i_obj.IsWithinDistInMap(go, i_range))
+ {
+ i_range = i_obj.GetDistance(go); // use found GO range as new range limit for next check
+ return true;
+ }
+ return false;
}
- return false;
- }
- float GetLastRange() const { return i_range; }
- private:
- WorldObject const& i_obj;
- GameobjectTypes i_type;
- float i_range;
- // prevent clone this object
- NearestGameObjectTypeInObjectRangeCheck(NearestGameObjectTypeInObjectRangeCheck const&);
+ private:
+ WorldObject const& i_obj;
+ GameobjectTypes i_type;
+ float i_range;
+
+ // prevent clone this object
+ NearestGameObjectTypeInObjectRangeCheck(NearestGameObjectTypeInObjectRangeCheck const&) = delete;
};
// Unit checks
@@ -731,6 +767,7 @@ namespace Trinity
{
public:
MostHPMissingInRange(Unit const* obj, float range, uint32 hp) : i_obj(obj), i_range(range), i_hp(hp) { }
+
bool operator()(Unit* u)
{
if (u->IsAlive() && u->IsInCombat() && !i_obj->IsHostileTo(u) && i_obj->IsWithinDistInMap(u, i_range) && u->GetMaxHealth() - u->GetHealth() > i_hp)
@@ -740,6 +777,7 @@ namespace Trinity
}
return false;
}
+
private:
Unit const* i_obj;
float i_range;
@@ -750,7 +788,8 @@ namespace Trinity
{
public:
FriendlyCCedInRange(Unit const* obj, float range) : i_obj(obj), i_range(range) { }
- bool operator()(Unit* u)
+
+ bool operator()(Unit* u) const
{
if (u->IsAlive() && u->IsInCombat() && !i_obj->IsHostileTo(u) && i_obj->IsWithinDistInMap(u, i_range) &&
(u->isFeared() || u->IsCharmed() || u->isFrozen() || u->HasUnitState(UNIT_STATE_STUNNED) || u->HasUnitState(UNIT_STATE_CONFUSED)))
@@ -759,6 +798,7 @@ namespace Trinity
}
return false;
}
+
private:
Unit const* i_obj;
float i_range;
@@ -768,15 +808,15 @@ namespace Trinity
{
public:
FriendlyMissingBuffInRange(Unit const* obj, float range, uint32 spellid) : i_obj(obj), i_range(range), i_spell(spellid) { }
- bool operator()(Unit* u)
+
+ bool operator()(Unit* u) const
{
- if (u->IsAlive() && u->IsInCombat() && !i_obj->IsHostileTo(u) && i_obj->IsWithinDistInMap(u, i_range) &&
- !(u->HasAura(i_spell)))
- {
+ if (u->IsAlive() && u->IsInCombat() && !i_obj->IsHostileTo(u) && i_obj->IsWithinDistInMap(u, i_range) && !u->HasAura(i_spell))
return true;
- }
+
return false;
}
+
private:
Unit const* i_obj;
float i_range;
@@ -787,23 +827,26 @@ namespace Trinity
{
public:
AnyUnfriendlyUnitInObjectRangeCheck(WorldObject const* obj, Unit const* funit, float range) : i_obj(obj), i_funit(funit), i_range(range) { }
- bool operator()(Unit* u)
+
+ bool operator()(Unit* u) const
{
if (u->IsAlive() && i_obj->IsWithinDistInMap(u, i_range) && !i_funit->IsFriendlyTo(u))
return true;
- else
- return false;
+
+ return false;
}
+
private:
WorldObject const* i_obj;
Unit const* i_funit;
float i_range;
};
- class AnyUnfriendlyNoTotemUnitInObjectRangeCheck
+ class NearestAttackableNoTotemUnitInObjectRangeCheck
{
public:
- AnyUnfriendlyNoTotemUnitInObjectRangeCheck(WorldObject const* obj, Unit const* funit, float range) : i_obj(obj), i_funit(funit), i_range(range) { }
+ NearestAttackableNoTotemUnitInObjectRangeCheck(WorldObject const* obj, Unit const* funit, float range) : i_obj(obj), i_funit(funit), i_range(range) { }
+
bool operator()(Unit* u)
{
if (!u->IsAlive())
@@ -812,14 +855,19 @@ namespace Trinity
if (u->GetCreatureType() == CREATURE_TYPE_NON_COMBAT_PET)
return false;
- if (u->GetTypeId() == TYPEID_UNIT && ((Creature*)u)->IsTotem())
+ if (u->GetTypeId() == TYPEID_UNIT && u->ToCreature()->IsTotem())
return false;
if (!u->isTargetableForAttack(false))
return false;
- return i_obj->IsWithinDistInMap(u, i_range) && !i_funit->IsFriendlyTo(u);
+ if (!i_obj->IsWithinDistInMap(u, i_range) || !i_funit->_IsValidAttackTarget(u, nullptr, i_obj))
+ return false;
+
+ i_range = i_obj->GetDistance(*u);
+ return true;
}
+
private:
WorldObject const* i_obj;
Unit const* i_funit;
@@ -830,13 +878,15 @@ namespace Trinity
{
public:
AnyFriendlyUnitInObjectRangeCheck(WorldObject const* obj, Unit const* funit, float range, bool playerOnly = false) : i_obj(obj), i_funit(funit), i_range(range), i_playerOnly(playerOnly) { }
- bool operator()(Unit* u)
+
+ bool operator()(Unit* u) const
{
if (u->IsAlive() && i_obj->IsWithinDistInMap(u, i_range) && i_funit->IsFriendlyTo(u) && (!i_playerOnly || u->GetTypeId() == TYPEID_PLAYER))
return true;
else
return false;
}
+
private:
WorldObject const* i_obj;
Unit const* i_funit;
@@ -847,10 +897,14 @@ namespace Trinity
class AnyGroupedUnitInObjectRangeCheck
{
public:
- AnyGroupedUnitInObjectRangeCheck(WorldObject const* obj, Unit const* funit, float range, bool raid) : _source(obj), _refUnit(funit), _range(range), _raid(raid) { }
- bool operator()(Unit* u)
+ AnyGroupedUnitInObjectRangeCheck(WorldObject const* obj, Unit const* funit, float range, bool raid, bool playerOnly = false) : _source(obj), _refUnit(funit), _range(range), _raid(raid), _playerOnly(playerOnly) { }
+
+ bool operator()(Unit* u) const
{
- if (G3D::fuzzyEq(_range, 0))
+ if (G3D::fuzzyEq(_range, 0.0f))
+ return false;
+
+ if (_playerOnly && u->GetTypeId() != TYPEID_PLAYER)
return false;
if (_raid)
@@ -869,19 +923,22 @@ namespace Trinity
Unit const* _refUnit;
float _range;
bool _raid;
+ bool _playerOnly;
};
class AnyUnitInObjectRangeCheck
{
public:
AnyUnitInObjectRangeCheck(WorldObject const* obj, float range) : i_obj(obj), i_range(range) { }
- bool operator()(Unit* u)
+
+ bool operator()(Unit* u) const
{
if (u->IsAlive() && i_obj->IsWithinDistInMap(u, i_range))
return true;
return false;
}
+
private:
WorldObject const* i_obj;
float i_range;
@@ -892,6 +949,7 @@ namespace Trinity
{
public:
NearestAttackableUnitInObjectRangeCheck(WorldObject const* obj, Unit const* funit, float range) : i_obj(obj), i_funit(funit), i_range(range) { }
+
bool operator()(Unit* u)
{
if (u->isTargetableForAttack() && i_obj->IsWithinDistInMap(u, i_range) &&
@@ -903,42 +961,40 @@ namespace Trinity
return false;
}
+
private:
WorldObject const* i_obj;
Unit const* i_funit;
float i_range;
// prevent clone this object
- NearestAttackableUnitInObjectRangeCheck(NearestAttackableUnitInObjectRangeCheck const&);
+ NearestAttackableUnitInObjectRangeCheck(NearestAttackableUnitInObjectRangeCheck const&) = delete;
};
class AnyAoETargetUnitInObjectRangeCheck
{
public:
- AnyAoETargetUnitInObjectRangeCheck(WorldObject const* obj, Unit const* funit, float range)
- : i_obj(obj), i_funit(funit), _spellInfo(NULL), i_range(range)
+ AnyAoETargetUnitInObjectRangeCheck(WorldObject const* obj, Unit const* funit, float range, SpellInfo const* spellInfo = nullptr)
+ : i_obj(obj), i_funit(funit), _spellInfo(spellInfo), i_range(range)
{
- Unit const* check = i_funit;
- Unit const* owner = i_funit->GetOwner();
- if (owner)
- check = owner;
- i_targetForPlayer = (check->GetTypeId() == TYPEID_PLAYER);
- if (DynamicObject const* dynObj = i_obj->ToDynObject())
- _spellInfo = sSpellMgr->GetSpellInfo(dynObj->GetSpellId());
+ if (!_spellInfo)
+ if (DynamicObject const* dynObj = i_obj->ToDynObject())
+ _spellInfo = sSpellMgr->GetSpellInfo(dynObj->GetSpellId());
}
- bool operator()(Unit* u)
+
+ bool operator()(Unit* u) const
{
// Check contains checks for: live, non-selectable, non-attackable flags, flight check and GM check, ignore totems
if (u->GetTypeId() == TYPEID_UNIT && u->IsTotem())
return false;
- if (i_funit->_IsValidAttackTarget(u, _spellInfo, i_obj->GetTypeId() == TYPEID_DYNAMICOBJECT ? i_obj : NULL) && i_obj->IsWithinDistInMap(u, i_range))
- return true;
+ if (_spellInfo && _spellInfo->HasAttribute(SPELL_ATTR3_ONLY_TARGET_PLAYERS) && u->GetTypeId() != TYPEID_PLAYER)
+ return false;
- return false;
+ return i_funit->_IsValidAttackTarget(u, _spellInfo, i_obj->GetTypeId() == TYPEID_DYNAMICOBJECT ? i_obj : nullptr) && i_obj->IsWithinDistInMap(u, i_range);
}
+
private:
- bool i_targetForPlayer;
WorldObject const* i_obj;
Unit const* i_funit;
SpellInfo const* _spellInfo;
@@ -950,9 +1006,9 @@ namespace Trinity
{
public:
CallOfHelpCreatureInRangeDo(Unit* funit, Unit* enemy, float range)
- : i_funit(funit), i_enemy(enemy), i_range(range)
- { }
- void operator()(Creature* u)
+ : i_funit(funit), i_enemy(enemy), i_range(range) { }
+
+ void operator()(Creature* u) const
{
if (u == i_funit)
return;
@@ -977,27 +1033,16 @@ namespace Trinity
float i_range;
};
- struct AnyDeadUnitCheck
- {
- bool operator()(Unit* u) { return !u->IsAlive(); }
- };
-
- /*
- struct AnyStealthedCheck
- {
- bool operator()(Unit* u) { return u->GetVisibility() == VISIBILITY_GROUP_STEALTH; }
- };
- */
-
// Creature checks
class NearestHostileUnitCheck
{
public:
- explicit NearestHostileUnitCheck(Creature const* creature, float dist = 0, bool playerOnly = false) : me(creature), i_playerOnly(playerOnly)
+ explicit NearestHostileUnitCheck(Creature const* creature, float dist = 0.f, bool playerOnly = false) : me(creature), i_playerOnly(playerOnly)
{
- m_range = (dist == 0 ? 9999 : dist);
+ m_range = (dist == 0.f ? 9999.f : dist);
}
+
bool operator()(Unit* u)
{
if (!me->IsWithinDistInMap(u, m_range))
@@ -1013,21 +1058,22 @@ namespace Trinity
return true;
}
- private:
+ private:
Creature const* me;
float m_range;
bool i_playerOnly;
- NearestHostileUnitCheck(NearestHostileUnitCheck const&);
+ NearestHostileUnitCheck(NearestHostileUnitCheck const&) = delete;
};
class NearestHostileUnitInAttackDistanceCheck
{
public:
- explicit NearestHostileUnitInAttackDistanceCheck(Creature const* creature, float dist = 0) : me(creature)
+ explicit NearestHostileUnitInAttackDistanceCheck(Creature const* creature, float dist = 0.f) : me(creature)
{
- m_range = (dist == 0 ? 9999 : dist);
- m_force = (dist == 0 ? false : true);
+ m_range = (dist == 0.f ? 9999.f : dist);
+ m_force = (dist == 0.f ? false : true);
}
+
bool operator()(Unit* u)
{
if (!me->IsWithinDistInMap(u, m_range))
@@ -1047,21 +1093,20 @@ namespace Trinity
m_range = me->GetDistance(u); // use found unit range as new range limit for next check
return true;
}
- float GetLastRange() const { return m_range; }
+
private:
Creature const* me;
float m_range;
bool m_force;
- NearestHostileUnitInAttackDistanceCheck(NearestHostileUnitInAttackDistanceCheck const&);
+ NearestHostileUnitInAttackDistanceCheck(NearestHostileUnitInAttackDistanceCheck const&) = delete;
};
class NearestHostileUnitInAggroRangeCheck
{
public:
- explicit NearestHostileUnitInAggroRangeCheck(Creature const* creature, bool useLOS = false) : _me(creature), _useLOS(useLOS)
- {
- }
- bool operator()(Unit* u)
+ explicit NearestHostileUnitInAggroRangeCheck(Creature const* creature, bool useLOS = false) : _me(creature), _useLOS(useLOS) { }
+
+ bool operator()(Unit* u) const
{
if (!u->IsHostileTo(_me))
return false;
@@ -1078,20 +1123,19 @@ namespace Trinity
return true;
}
- private:
+ private:
Creature const* _me;
bool _useLOS;
- NearestHostileUnitInAggroRangeCheck(NearestHostileUnitInAggroRangeCheck const&);
+ NearestHostileUnitInAggroRangeCheck(NearestHostileUnitInAggroRangeCheck const&) = delete;
};
class AnyAssistCreatureInRangeCheck
{
public:
AnyAssistCreatureInRangeCheck(Unit* funit, Unit* enemy, float range)
- : i_funit(funit), i_enemy(enemy), i_range(range)
- {
- }
- bool operator()(Creature* u)
+ : i_funit(funit), i_enemy(enemy), i_range(range) { }
+
+ bool operator()(Creature* u) const
{
if (u == i_funit)
return false;
@@ -1109,6 +1153,7 @@ namespace Trinity
return true;
}
+
private:
Unit* const i_funit;
Unit* const i_enemy;
@@ -1137,14 +1182,14 @@ namespace Trinity
i_range = i_obj->GetDistance(u); // use found unit range as new range limit for next check
return true;
}
- float GetLastRange() const { return i_range; }
+
private:
Creature* const i_obj;
Unit* const i_enemy;
float i_range;
// prevent clone this object
- NearestAssistCreatureInCreatureRangeCheck(NearestAssistCreatureInCreatureRangeCheck const&);
+ NearestAssistCreatureInCreatureRangeCheck(NearestAssistCreatureInCreatureRangeCheck const&) = delete;
};
// Success at unit in range, range update for next check (this can be use with CreatureLastSearcher to find nearest creature)
@@ -1163,7 +1208,7 @@ namespace Trinity
}
return false;
}
- float GetLastRange() const { return i_range; }
+
private:
WorldObject const& i_obj;
uint32 i_entry;
@@ -1171,14 +1216,15 @@ namespace Trinity
float i_range;
// prevent clone this object
- NearestCreatureEntryWithLiveStateInObjectRangeCheck(NearestCreatureEntryWithLiveStateInObjectRangeCheck const&);
+ NearestCreatureEntryWithLiveStateInObjectRangeCheck(NearestCreatureEntryWithLiveStateInObjectRangeCheck const&) = delete;
};
class AnyPlayerInObjectRangeCheck
{
public:
AnyPlayerInObjectRangeCheck(WorldObject const* obj, float range, bool reqAlive = true) : _obj(obj), _range(range), _reqAlive(reqAlive) { }
- bool operator()(Player* u)
+
+ bool operator()(Player* u) const
{
if (_reqAlive && !u->IsAlive())
return false;
@@ -1198,9 +1244,7 @@ namespace Trinity
class NearestPlayerInObjectRangeCheck
{
public:
- NearestPlayerInObjectRangeCheck(WorldObject const* obj, float range) : i_obj(obj), i_range(range)
- {
- }
+ NearestPlayerInObjectRangeCheck(WorldObject const* obj, float range) : i_obj(obj), i_range(range) { }
bool operator()(Player* u)
{
@@ -1216,46 +1260,51 @@ namespace Trinity
WorldObject const* i_obj;
float i_range;
- NearestPlayerInObjectRangeCheck(NearestPlayerInObjectRangeCheck const&);
+ NearestPlayerInObjectRangeCheck(NearestPlayerInObjectRangeCheck const&) = delete;
};
class AllFriendlyCreaturesInGrid
{
- public:
- AllFriendlyCreaturesInGrid(Unit const* obj) : unit(obj) { }
- bool operator() (Unit* u)
- {
- if (u->IsAlive() && u->IsVisible() && u->IsFriendlyTo(unit))
- return true;
+ public:
+ AllFriendlyCreaturesInGrid(Unit const* obj) : unit(obj) { }
- return false;
- }
- private:
- Unit const* unit;
+ bool operator()(Unit* u) const
+ {
+ if (u->IsAlive() && u->IsVisible() && u->IsFriendlyTo(unit))
+ return true;
+
+ return false;
+ }
+
+ private:
+ Unit const* unit;
};
class AllGameObjectsWithEntryInRange
{
- public:
- AllGameObjectsWithEntryInRange(const WorldObject* object, uint32 entry, float maxRange) : m_pObject(object), m_uiEntry(entry), m_fRange(maxRange) { }
- bool operator() (GameObject* go)
- {
- if ((!m_uiEntry || go->GetEntry() == m_uiEntry) && m_pObject->IsWithinDist(go, m_fRange, false))
- return true;
+ public:
+ AllGameObjectsWithEntryInRange(const WorldObject* object, uint32 entry, float maxRange) : m_pObject(object), m_uiEntry(entry), m_fRange(maxRange) { }
- return false;
- }
- private:
- const WorldObject* m_pObject;
- uint32 m_uiEntry;
- float m_fRange;
+ bool operator()(GameObject* go) const
+ {
+ if ((!m_uiEntry || go->GetEntry() == m_uiEntry) && m_pObject->IsWithinDist(go, m_fRange, false))
+ return true;
+
+ return false;
+ }
+
+ private:
+ WorldObject const* m_pObject;
+ uint32 m_uiEntry;
+ float m_fRange;
};
class AllCreaturesOfEntryInRange
{
public:
AllCreaturesOfEntryInRange(const WorldObject* object, uint32 entry, float maxRange) : m_pObject(object), m_uiEntry(entry), m_fRange(maxRange) { }
- bool operator() (Unit* unit)
+
+ bool operator()(Unit* unit) const
{
if ((!m_uiEntry || unit->GetEntry() == m_uiEntry) && m_pObject->IsWithinDist(unit, m_fRange, false))
return true;
@@ -1264,63 +1313,69 @@ namespace Trinity
}
private:
- const WorldObject* m_pObject;
+ WorldObject const* m_pObject;
uint32 m_uiEntry;
float m_fRange;
};
class PlayerAtMinimumRangeAway
{
- public:
- PlayerAtMinimumRangeAway(Unit const* unit, float fMinRange) : unit(unit), fRange(fMinRange) { }
- bool operator() (Player* player)
- {
- //No threat list check, must be done explicit if expected to be in combat with creature
- if (!player->IsGameMaster() && player->IsAlive() && !unit->IsWithinDist(player, fRange, false))
- return true;
+ public:
+ PlayerAtMinimumRangeAway(Unit const* unit, float fMinRange) : unit(unit), fRange(fMinRange) { }
- return false;
- }
+ bool operator()(Player* player) const
+ {
+ //No threat list check, must be done explicit if expected to be in combat with creature
+ if (!player->IsGameMaster() && player->IsAlive() && !unit->IsWithinDist(player, fRange, false))
+ return true;
- private:
- Unit const* unit;
- float fRange;
+ return false;
+ }
+
+ private:
+ Unit const* unit;
+ float fRange;
};
class GameObjectInRangeCheck
{
- public:
- GameObjectInRangeCheck(float _x, float _y, float _z, float _range, uint32 _entry = 0) :
- x(_x), y(_y), z(_z), range(_range), entry(_entry) { }
- bool operator() (GameObject* go)
- {
- if (!entry || (go->GetGOInfo() && go->GetGOInfo()->entry == entry))
- return go->IsInRange(x, y, z, range);
- else return false;
- }
- private:
- float x, y, z, range;
- uint32 entry;
+ public:
+ GameObjectInRangeCheck(float _x, float _y, float _z, float _range, uint32 _entry = 0) :
+ x(_x), y(_y), z(_z), range(_range), entry(_entry) { }
+
+ bool operator()(GameObject* go) const
+ {
+ if (!entry || (go->GetGOInfo() && go->GetGOInfo()->entry == entry))
+ return go->IsInRange(x, y, z, range);
+ else return false;
+ }
+
+ private:
+ float x, y, z, range;
+ uint32 entry;
};
class AllWorldObjectsInRange
{
- public:
- AllWorldObjectsInRange(const WorldObject* object, float maxRange) : m_pObject(object), m_fRange(maxRange) { }
- bool operator() (WorldObject* go)
- {
- return m_pObject->IsWithinDist(go, m_fRange, false) && m_pObject->InSamePhase(go);
- }
- private:
- const WorldObject* m_pObject;
- float m_fRange;
+ public:
+ AllWorldObjectsInRange(const WorldObject* object, float maxRange) : m_pObject(object), m_fRange(maxRange) { }
+
+ bool operator()(WorldObject* go) const
+ {
+ return m_pObject->IsWithinDist(go, m_fRange, false) && m_pObject->InSamePhase(go);
+ }
+
+ private:
+ WorldObject const* m_pObject;
+ float m_fRange;
};
class ObjectTypeIdCheck
{
public:
ObjectTypeIdCheck(TypeID typeId, bool equals) : _typeId(typeId), _equals(equals) { }
- bool operator()(WorldObject* object)
+
+ bool operator()(WorldObject* object) const
{
return (object->GetTypeId() == _typeId) == _equals;
}
@@ -1334,7 +1389,8 @@ namespace Trinity
{
public:
ObjectGUIDCheck(ObjectGuid GUID) : _GUID(GUID) { }
- bool operator()(WorldObject* object)
+
+ bool operator()(WorldObject* object) const
{
return object->GetGUID() == _GUID;
}
@@ -1347,6 +1403,7 @@ namespace Trinity
{
public:
UnitAuraCheck(bool present, uint32 spellId, ObjectGuid casterGUID = ObjectGuid::Empty) : _present(present), _spellId(spellId), _casterGUID(casterGUID) { }
+
bool operator()(Unit* unit) const
{
return unit->HasAura(_spellId, _casterGUID) == _present;
@@ -1377,6 +1434,7 @@ namespace Trinity
for (size_t i = 0; i < i_data_cache.size(); ++i)
delete i_data_cache[i];
}
+
void operator()(Player* p);
private:
diff --git a/src/server/game/Grids/Notifiers/GridNotifiersImpl.h b/src/server/game/Grids/Notifiers/GridNotifiersImpl.h
index 340531c5883..5a3f41e5351 100644
--- a/src/server/game/Grids/Notifiers/GridNotifiersImpl.h
+++ b/src/server/game/Grids/Notifiers/GridNotifiersImpl.h
@@ -246,7 +246,7 @@ void Trinity::WorldObjectListSearcher<Check>::Visit(PlayerMapType &m)
for (PlayerMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
if (i_check(itr->GetSource()))
- i_objects.push_back(itr->GetSource());
+ Insert(itr->GetSource());
}
template<class Check>
@@ -257,7 +257,7 @@ void Trinity::WorldObjectListSearcher<Check>::Visit(CreatureMapType &m)
for (CreatureMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
if (i_check(itr->GetSource()))
- i_objects.push_back(itr->GetSource());
+ Insert(itr->GetSource());
}
template<class Check>
@@ -268,7 +268,7 @@ void Trinity::WorldObjectListSearcher<Check>::Visit(CorpseMapType &m)
for (CorpseMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
if (i_check(itr->GetSource()))
- i_objects.push_back(itr->GetSource());
+ Insert(itr->GetSource());
}
template<class Check>
@@ -279,7 +279,7 @@ void Trinity::WorldObjectListSearcher<Check>::Visit(GameObjectMapType &m)
for (GameObjectMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
if (i_check(itr->GetSource()))
- i_objects.push_back(itr->GetSource());
+ Insert(itr->GetSource());
}
template<class Check>
@@ -290,7 +290,7 @@ void Trinity::WorldObjectListSearcher<Check>::Visit(DynamicObjectMapType &m)
for (DynamicObjectMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
if (i_check(itr->GetSource()))
- i_objects.push_back(itr->GetSource());
+ Insert(itr->GetSource());
}
// Gameobject searchers
@@ -334,7 +334,7 @@ void Trinity::GameObjectListSearcher<Check>::Visit(GameObjectMapType &m)
for (GameObjectMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
if (itr->GetSource()->InSamePhase(i_phaseMask))
if (i_check(itr->GetSource()))
- i_objects.push_back(itr->GetSource());
+ Insert(itr->GetSource());
}
// Unit searchers
@@ -411,7 +411,7 @@ void Trinity::UnitListSearcher<Check>::Visit(PlayerMapType &m)
for (PlayerMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
if (itr->GetSource()->InSamePhase(i_phaseMask))
if (i_check(itr->GetSource()))
- i_objects.push_back(itr->GetSource());
+ Insert(itr->GetSource());
}
template<class Check>
@@ -420,7 +420,7 @@ void Trinity::UnitListSearcher<Check>::Visit(CreatureMapType &m)
for (CreatureMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
if (itr->GetSource()->InSamePhase(i_phaseMask))
if (i_check(itr->GetSource()))
- i_objects.push_back(itr->GetSource());
+ Insert(itr->GetSource());
}
// Creature searchers
@@ -464,7 +464,7 @@ void Trinity::CreatureListSearcher<Check>::Visit(CreatureMapType &m)
for (CreatureMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
if (itr->GetSource()->InSamePhase(i_phaseMask))
if (i_check(itr->GetSource()))
- i_objects.push_back(itr->GetSource());
+ Insert(itr->GetSource());
}
template<class Check>
@@ -473,7 +473,7 @@ void Trinity::PlayerListSearcher<Check>::Visit(PlayerMapType &m)
for (PlayerMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
if (itr->GetSource()->InSamePhase(i_phaseMask))
if (i_check(itr->GetSource()))
- i_objects.push_back(itr->GetSource());
+ Insert(itr->GetSource());
}
template<class Check>
diff --git a/src/server/game/Groups/Group.cpp b/src/server/game/Groups/Group.cpp
index ccfd4845dc3..e99ee78991d 100644
--- a/src/server/game/Groups/Group.cpp
+++ b/src/server/game/Groups/Group.cpp
@@ -1154,7 +1154,7 @@ void Group::NeedBeforeGreed(Loot* loot, WorldObject* lootedObject)
if (item->DisenchantID && m_maxEnchantingLevel >= item->RequiredDisenchantSkill)
r->rollVoteMask |= ROLL_FLAG_TYPE_DISENCHANT;
- if (item->Flags2 & ITEM_FLAGS_EXTRA_NEED_ROLL_DISABLED)
+ if (item->Flags2 & ITEM_FLAG2_CAN_ONLY_ROLL_GREED)
r->rollVoteMask &= ~ROLL_FLAG_TYPE_NEED;
loot->items[itemSlot].is_blocked = true;
diff --git a/src/server/game/Guilds/Guild.cpp b/src/server/game/Guilds/Guild.cpp
index b95d2ed1981..84b2da9b2ea 100644
--- a/src/server/game/Guilds/Guild.cpp
+++ b/src/server/game/Guilds/Guild.cpp
@@ -29,10 +29,13 @@
#include "SocialMgr.h"
#include "Opcodes.h"
-#define MAX_GUILD_BANK_TAB_TEXT_LEN 500
-#define EMBLEM_PRICE 10 * GOLD
-std::string _GetGuildEventString(GuildEvents event)
+size_t const MAX_GUILD_BANK_TAB_TEXT_LEN = 500;
+
+uint32 const EMBLEM_PRICE = 10 * GOLD;
+
+// only used in logs
+char const* GetGuildEventString(GuildEvents event)
{
switch (event)
{
@@ -82,18 +85,13 @@ std::string _GetGuildEventString(GuildEvents event)
return "<None>";
}
-inline uint32 _GetGuildBankTabPrice(uint8 tabId)
+inline uint32 GetGuildBankTabPrice(uint8 tabId)
{
- switch (tabId)
- {
- case 0: return 100;
- case 1: return 250;
- case 2: return 500;
- case 3: return 1000;
- case 4: return 2500;
- case 5: return 5000;
- default: return 0;
- }
+ // these prices are in gold units, not copper
+ static uint32 const tabPrices[GUILD_BANK_MAX_TABS] = { 100, 250, 500, 1000, 2500, 5000 };
+ ASSERT(tabId < GUILD_BANK_MAX_TABS);
+
+ return tabPrices[tabId];
}
void Guild::SendCommandResult(WorldSession* session, GuildCommandType type, GuildCommandError errCode, std::string const& param)
@@ -121,7 +119,7 @@ void Guild::SendSaveEmblemResult(WorldSession* session, GuildEmblemError errCode
Guild::LogHolder::~LogHolder()
{
// Cleanup
- for (GuildLog::iterator itr = m_log.begin(); itr != m_log.end(); ++itr)
+ for (auto itr = m_log.begin(); itr != m_log.end(); ++itr)
delete (*itr);
}
@@ -154,7 +152,7 @@ inline void Guild::LogHolder::AddEvent(SQLTransaction& trans, LogEntry* entry)
inline void Guild::LogHolder::WritePacket(WorldPacket& data) const
{
data << uint8(m_log.size());
- for (GuildLog::const_iterator itr = m_log.begin(); itr != m_log.end(); ++itr)
+ for (auto itr = m_log.begin(); itr != m_log.end(); ++itr)
(*itr)->WritePacket(data);
}
@@ -175,7 +173,7 @@ void Guild::EventLogEntry::SaveToDB(SQLTransaction& trans) const
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_EVENTLOG);
stmt->setUInt32(0, m_guildId);
stmt->setUInt32(1, m_guid);
- CharacterDatabase.ExecuteOrAppend(trans, stmt);
+ trans->Append(stmt);
uint8 index = 0;
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_GUILD_EVENTLOG);
@@ -186,7 +184,7 @@ void Guild::EventLogEntry::SaveToDB(SQLTransaction& trans) const
stmt->setUInt32(++index, m_playerGuid2);
stmt->setUInt8 (++index, m_newRank);
stmt->setUInt64(++index, m_timestamp);
- CharacterDatabase.ExecuteOrAppend(trans, stmt);
+ trans->Append(stmt);
}
void Guild::EventLogEntry::WritePacket(WorldPacket& data) const
@@ -202,7 +200,7 @@ void Guild::EventLogEntry::WritePacket(WorldPacket& data) const
if (m_eventType == GUILD_EVENT_LOG_PROMOTE_PLAYER || m_eventType == GUILD_EVENT_LOG_DEMOTE_PLAYER)
data << uint8(m_newRank);
// Event timestamp
- data << uint32(::time(NULL) - m_timestamp);
+ data << uint32(::time(nullptr) - m_timestamp);
}
// BankEventLogEntry
@@ -214,7 +212,7 @@ void Guild::BankEventLogEntry::SaveToDB(SQLTransaction& trans) const
stmt->setUInt32( index, m_guildId);
stmt->setUInt32(++index, m_guid);
stmt->setUInt8 (++index, m_bankTabId);
- CharacterDatabase.ExecuteOrAppend(trans, stmt);
+ trans->Append(stmt);
index = 0;
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_GUILD_BANK_EVENTLOG);
@@ -227,7 +225,7 @@ void Guild::BankEventLogEntry::SaveToDB(SQLTransaction& trans) const
stmt->setUInt16(++index, m_itemStackCount);
stmt->setUInt8 (++index, m_destTabId);
stmt->setUInt64(++index, m_timestamp);
- CharacterDatabase.ExecuteOrAppend(trans, stmt);
+ trans->Append(stmt);
}
void Guild::BankEventLogEntry::WritePacket(WorldPacket& data) const
@@ -252,7 +250,7 @@ void Guild::BankEventLogEntry::WritePacket(WorldPacket& data) const
data << uint32(m_itemOrMoney);
}
- data << uint32(time(NULL) - m_timestamp);
+ data << uint32(time(nullptr) - m_timestamp);
}
// RankInfo
@@ -434,14 +432,16 @@ bool Guild::BankTab::LoadItemFromDB(Field* fields)
void Guild::BankTab::Delete(SQLTransaction& trans, bool removeItemsFromDB)
{
for (uint8 slotId = 0; slotId < GUILD_BANK_MAX_SLOTS; ++slotId)
+ {
if (Item* pItem = m_items[slotId])
{
pItem->RemoveFromWorld();
if (removeItemsFromDB)
pItem->DeleteFromDB(trans);
delete pItem;
- pItem = NULL;
+ pItem = nullptr;
}
+ }
}
inline void Guild::BankTab::WritePacket(WorldPacket& data) const
@@ -491,12 +491,14 @@ bool Guild::BankTab::WriteSlotPacket(WorldPacket& data, uint8 slotId, bool ignor
data << uint8(enchCount); // Number of enchantments
for (uint32 i = PERM_ENCHANTMENT_SLOT; i < MAX_ENCHANTMENT_SLOT; ++i)
+ {
if (uint32 enchId = pItem->GetEnchantmentId(EnchantmentSlot(i)))
{
data << uint8(i);
data << uint32(enchId);
++enchCount;
}
+ }
data.put<uint8>(enchCountPos, enchCount);
}
return true;
@@ -534,7 +536,7 @@ void Guild::BankTab::SetText(std::string const& text)
}
// Sets/removes contents of specified slot.
-// If pItem == NULL contents are removed.
+// If pItem == nullptr contents are removed.
bool Guild::BankTab::SetItem(SQLTransaction& trans, uint8 slotId, Item* item)
{
if (slotId >= GUILD_BANK_MAX_SLOTS)
@@ -546,7 +548,7 @@ bool Guild::BankTab::SetItem(SQLTransaction& trans, uint8 slotId, Item* item)
stmt->setUInt32(0, m_guildId);
stmt->setUInt8 (1, m_tabId);
stmt->setUInt8 (2, slotId);
- CharacterDatabase.ExecuteOrAppend(trans, stmt);
+ trans->Append(stmt);
if (item)
{
@@ -555,13 +557,14 @@ bool Guild::BankTab::SetItem(SQLTransaction& trans, uint8 slotId, Item* item)
stmt->setUInt8 (1, m_tabId);
stmt->setUInt8 (2, slotId);
stmt->setUInt32(3, item->GetGUID().GetCounter());
- CharacterDatabase.ExecuteOrAppend(trans, stmt);
+ trans->Append(stmt);
item->SetGuidValue(ITEM_FIELD_CONTAINED, ObjectGuid::Empty);
item->SetGuidValue(ITEM_FIELD_OWNER, ObjectGuid::Empty);
item->FSetState(ITEM_NEW);
item->SaveToDB(trans); // Not in inventory and can be saved standalone
}
+
return true;
}
@@ -629,7 +632,7 @@ void Guild::Member::SetOfficerNote(std::string const& officerNote)
CharacterDatabase.Execute(stmt);
}
-void Guild::Member::ChangeRank(uint8 newRank)
+void Guild::Member::ChangeRank(SQLTransaction& trans, uint8 newRank)
{
m_rankId = newRank;
@@ -640,7 +643,7 @@ void Guild::Member::ChangeRank(uint8 newRank)
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GUILD_MEMBER_RANK);
stmt->setUInt8 (0, newRank);
stmt->setUInt32(1, m_guid.GetCounter());
- CharacterDatabase.Execute(stmt);
+ CharacterDatabase.ExecuteOrAppend(trans, stmt);
}
void Guild::Member::SaveToDB(SQLTransaction& trans) const
@@ -714,7 +717,7 @@ void Guild::Member::WritePacket(WorldPacket& data, bool sendOfficerNote) const
<< uint32(m_zoneId);
if (!m_flags)
- data << float(float(::time(NULL) - m_logoutTime) / DAY);
+ data << float(float(::time(nullptr) - m_logoutTime) / DAY);
data << m_publicNote;
@@ -839,7 +842,7 @@ void Guild::MoveItemData::LogAction(MoveItemData* pFrom) const
inline void Guild::MoveItemData::CopySlots(SlotIds& ids) const
{
- for (ItemPosCountVec::const_iterator itr = m_vec.begin(); itr != m_vec.end(); ++itr)
+ for (auto itr = m_vec.begin(); itr != m_vec.end(); ++itr)
ids.insert(uint8(itr->pos));
}
@@ -853,16 +856,16 @@ bool Guild::PlayerMoveItemData::InitItem()
if (m_pItem->IsNotEmptyBag())
{
m_pPlayer->SendEquipError(EQUIP_ERR_CAN_ONLY_DO_WITH_EMPTY_BAGS, m_pItem);
- m_pItem = NULL;
+ m_pItem = nullptr;
}
// Bound items cannot be put into bank.
else if (!m_pItem->CanBeTraded())
{
m_pPlayer->SendEquipError(EQUIP_ERR_ITEMS_CANT_BE_SWAPPED, m_pItem);
- m_pItem = NULL;
+ m_pItem = nullptr;
}
}
- return (m_pItem != NULL);
+ return (m_pItem != nullptr);
}
void Guild::PlayerMoveItemData::RemoveItem(SQLTransaction& trans, MoveItemData* /*pOther*/, uint32 splitedAmount)
@@ -877,7 +880,7 @@ void Guild::PlayerMoveItemData::RemoveItem(SQLTransaction& trans, MoveItemData*
{
m_pPlayer->MoveItemFromInventory(m_container, m_slotId, true);
m_pItem->DeleteFromInventoryDB(trans);
- m_pItem = NULL;
+ m_pItem = nullptr;
}
}
@@ -906,7 +909,7 @@ inline InventoryResult Guild::PlayerMoveItemData::CanStore(Item* pItem, bool swa
bool Guild::BankMoveItemData::InitItem()
{
m_pItem = m_pGuild->_GetItem(m_container, m_slotId);
- return (m_pItem != NULL);
+ return (m_pItem != nullptr);
}
bool Guild::BankMoveItemData::HasStoreRights(MoveItemData* pOther) const
@@ -944,7 +947,7 @@ void Guild::BankMoveItemData::RemoveItem(SQLTransaction& trans, MoveItemData* pO
else
{
m_pGuild->_RemoveItem(trans, m_container, m_slotId);
- m_pItem = NULL;
+ m_pItem = nullptr;
}
// Decrease amount of player's remaining items (if item is moved to different tab or to player)
if (!pOther->IsBank() || pOther->GetContainer() != m_container)
@@ -954,14 +957,14 @@ void Guild::BankMoveItemData::RemoveItem(SQLTransaction& trans, MoveItemData* pO
Item* Guild::BankMoveItemData::StoreItem(SQLTransaction& trans, Item* pItem)
{
if (!pItem)
- return NULL;
+ return nullptr;
BankTab* pTab = m_pGuild->GetBankTab(m_container);
if (!pTab)
- return NULL;
+ return nullptr;
Item* pLastItem = pItem;
- for (ItemPosCountVec::const_iterator itr = m_vec.begin(); itr != m_vec.end(); )
+ for (auto itr = m_vec.begin(); itr != m_vec.end(); )
{
ItemPosCount pos(*itr);
++itr;
@@ -1025,7 +1028,7 @@ Item* Guild::BankMoveItemData::_StoreItem(SQLTransaction& trans, BankTab* pTab,
if (pItem && pTab->SetItem(trans, slotId, pItem))
return pItem;
- return NULL;
+ return nullptr;
}
// Tries to reserve space for source item.
@@ -1065,10 +1068,10 @@ void Guild::BankMoveItemData::CanStoreItemInTab(Item* pItem, uint8 skipSlotId, b
Item* pItemDest = m_pGuild->_GetItem(m_container, slotId);
if (pItemDest == pItem)
- pItemDest = NULL;
+ pItemDest = nullptr;
// If merge skip empty, if not merge skip non-empty
- if ((pItemDest != NULL) != merge)
+ if ((pItemDest != nullptr) != merge)
continue;
_ReserveSpace(slotId, pItem, pItemDest, count);
@@ -1095,7 +1098,7 @@ InventoryResult Guild::BankMoveItemData::CanStore(Item* pItem, bool swap)
Item* pItemDest = m_pGuild->_GetItem(m_container, m_slotId);
// Ignore swapped item (this slot will be empty after move)
if ((pItemDest == pItem) || swap)
- pItemDest = NULL;
+ pItemDest = nullptr;
if (!_ReserveSpace(m_slotId, pItem, pItemDest, count))
return EQUIP_ERR_ITEM_CANT_STACK;
@@ -1128,30 +1131,30 @@ Guild::Guild():
m_createdDate(0),
m_accountsNumber(0),
m_bankMoney(0),
- m_eventLog(NULL)
+ m_eventLog(nullptr)
{
memset(&m_bankEventLog, 0, (GUILD_BANK_MAX_TABS + 1) * sizeof(LogHolder*));
}
Guild::~Guild()
{
- SQLTransaction temp(NULL);
+ SQLTransaction temp(nullptr);
_DeleteBankItems(temp);
// Cleanup
delete m_eventLog;
- m_eventLog = NULL;
+ m_eventLog = nullptr;
for (uint8 tabId = 0; tabId <= GUILD_BANK_MAX_TABS; ++tabId)
{
delete m_bankEventLog[tabId];
- m_bankEventLog[tabId] = NULL;
+ m_bankEventLog[tabId] = nullptr;
}
- for (Members::iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
+ for (auto itr = m_members.begin(); itr != m_members.end(); ++itr)
{
delete itr->second;
- itr->second = NULL;
+ itr->second = nullptr;
}
}
@@ -1172,7 +1175,7 @@ bool Guild::Create(Player* pLeader, std::string const& name)
m_info = "";
m_motd = "No message set.";
m_bankMoney = 0;
- m_createdDate = ::time(NULL);
+ m_createdDate = ::time(nullptr);
_CreateLogHolders();
TC_LOG_DEBUG("guild", "GUILD: creating guild [%s] for leader %s (%u)",
@@ -1200,9 +1203,10 @@ bool Guild::Create(Player* pLeader, std::string const& name)
stmt->setUInt64(++index, m_bankMoney);
trans->Append(stmt);
+ _CreateDefaultGuildRanks(trans, pLeaderSession->GetSessionDbLocaleIndex()); // Create default ranks
+ bool ret = AddMember(trans, m_leaderGuid, GR_GUILDMASTER); // Add guildmaster
+
CharacterDatabase.CommitTransaction(trans);
- _CreateDefaultGuildRanks(pLeaderSession->GetSessionDbLocaleIndex()); // Create default ranks
- bool ret = AddMember(m_leaderGuid, GR_GUILDMASTER); // Add guildmaster
if (ret)
sScriptMgr->OnGuildCreate(this, pLeader, name);
@@ -1217,15 +1221,15 @@ void Guild::Disband()
sScriptMgr->OnGuildDisband(this);
_BroadcastEvent(GE_DISBANDED, ObjectGuid::Empty);
+
+ SQLTransaction trans = CharacterDatabase.BeginTransaction();
// Remove all members
while (!m_members.empty())
{
- Members::const_iterator itr = m_members.begin();
- DeleteMember(itr->second->GetGUID(), true);
+ auto itr = m_members.begin();
+ DeleteMember(trans, itr->second->GetGUID(), true);
}
- SQLTransaction trans = CharacterDatabase.BeginTransaction();
-
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD);
stmt->setUInt32(0, m_id);
trans->Append(stmt);
@@ -1313,10 +1317,10 @@ void Guild::HandleRoster(WorldSession* session)
data << m_info;
data << uint32(_GetRanksSize());
- for (Ranks::const_iterator ritr = m_ranks.begin(); ritr != m_ranks.end(); ++ritr)
+ for (auto ritr = m_ranks.begin(); ritr != m_ranks.end(); ++ritr)
ritr->WritePacket(data);
- for (Members::const_iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
+ for (auto itr = m_members.begin(); itr != m_members.end(); ++itr)
itr->second->WritePacket(data, _HasRankRight(session->GetPlayer(), GR_RIGHT_VIEWOFFNOTE));
TC_LOG_DEBUG("guild", "SMSG_GUILD_ROSTER [%s]", session->GetPlayerInfo().c_str());
@@ -1420,7 +1424,9 @@ void Guild::HandleSetLeader(WorldSession* session, std::string const& name)
if (Member* pNewLeader = GetMember(name))
{
_SetLeaderGUID(pNewLeader);
- pOldLeader->ChangeRank(GR_OFFICER);
+
+ SQLTransaction trans(nullptr);
+ pOldLeader->ChangeRank(trans, GR_OFFICER);
_BroadcastEvent(GE_LEADER_CHANGED, ObjectGuid::Empty, player->GetName().c_str(), name.c_str());
}
}
@@ -1436,11 +1442,8 @@ void Guild::HandleSetBankTabInfo(WorldSession* session, uint8 tabId, std::string
return;
}
- char aux[2];
- sprintf(aux, "%u", tabId);
-
tab->SetInfo(name, icon);
- _BroadcastEvent(GE_BANK_TAB_UPDATED, ObjectGuid::Empty, aux, name.c_str(), icon.c_str());
+ _BroadcastEvent(GE_BANK_TAB_UPDATED, ObjectGuid::Empty, std::to_string(tabId).c_str(), name.c_str(), icon.c_str());
}
void Guild::HandleSetMemberNote(WorldSession* session, std::string const& name, std::string const& note, bool officer)
@@ -1472,12 +1475,10 @@ void Guild::HandleSetRankInfo(WorldSession* session, uint8 rankId, std::string c
rankInfo->SetRights(rights);
_SetRankBankMoneyPerDay(rankId, moneyPerDay);
- for (GuildBankRightsAndSlotsVec::const_iterator itr = rightsAndSlots.begin(); itr != rightsAndSlots.end(); ++itr)
+ for (auto itr = rightsAndSlots.begin(); itr != rightsAndSlots.end(); ++itr)
_SetRankBankTabRightsAndSlots(rankId, *itr);
- char aux[2];
- sprintf(aux, "%u", rankId);
- _BroadcastEvent(GE_RANK_UPDATED, ObjectGuid::Empty, aux, name.c_str());
+ _BroadcastEvent(GE_RANK_UPDATED, ObjectGuid::Empty, std::to_string(rankId).c_str(), name.c_str());
}
}
@@ -1497,10 +1498,10 @@ void Guild::HandleBuyBankTab(WorldSession* session, uint8 tabId)
if (tabId != _GetPurchasedTabsSize())
return;
- uint32 tabCost = _GetGuildBankTabPrice(tabId) * GOLD;
- if (!tabCost)
+ if (tabId >= GUILD_BANK_MAX_TABS)
return;
+ uint32 tabCost = GetGuildBankTabPrice(tabId) * GOLD;
if (!player->HasEnoughMoney(tabCost)) // Should not happen, this is checked by client
return;
@@ -1570,7 +1571,8 @@ void Guild::HandleAcceptMember(WorldSession* session)
player->GetTeam() != sObjectMgr->GetPlayerTeamByGUID(GetLeaderGUID()))
return;
- AddMember(player->GetGUID());
+ SQLTransaction trans(nullptr);
+ AddMember(trans, player->GetGUID());
}
void Guild::HandleLeaveMember(WorldSession* session)
@@ -1593,7 +1595,8 @@ void Guild::HandleLeaveMember(WorldSession* session)
}
else
{
- DeleteMember(player->GetGUID(), false, false);
+ SQLTransaction trans(nullptr);
+ DeleteMember(trans, player->GetGUID(), false, false);
_LogEvent(GUILD_EVENT_LOG_LEAVE_GUILD, player->GetGUID().GetCounter());
_BroadcastEvent(GE_LEFT, player->GetGUID(), player->GetName().c_str());
@@ -1627,8 +1630,10 @@ void Guild::HandleRemoveMember(WorldSession* session, std::string const& name)
else
{
ObjectGuid guid = member->GetGUID();
+
// After call to DeleteMember pointer to member becomes invalid
- DeleteMember(guid, false, true);
+ SQLTransaction trans(nullptr);
+ DeleteMember(trans, guid, false, true);
_LogEvent(GUILD_EVENT_LOG_UNINVITE_PLAYER, player->GetGUID().GetCounter(), guid.GetCounter());
_BroadcastEvent(GE_REMOVED, ObjectGuid::Empty, name.c_str(), player->GetName().c_str());
}
@@ -1682,7 +1687,8 @@ void Guild::HandleUpdateMemberRank(WorldSession* session, std::string const& nam
}
uint32 newRankId = member->GetRankId() + (demote ? 1 : -1);
- member->ChangeRank(newRankId);
+ SQLTransaction trans(nullptr);
+ member->ChangeRank(trans, newRankId);
_LogEvent(demote ? GUILD_EVENT_LOG_DEMOTE_PLAYER : GUILD_EVENT_LOG_PROMOTE_PLAYER, player->GetGUID().GetCounter(), member->GetGUID().GetCounter(), newRankId);
_BroadcastEvent(demote ? GE_DEMOTION : GE_PROMOTION, ObjectGuid::Empty, player->GetName().c_str(), name.c_str(), _GetRankName(newRankId).c_str());
}
@@ -1696,12 +1702,11 @@ void Guild::HandleAddNewRank(WorldSession* session, std::string const& name)
// Only leader can add new rank
if (_IsLeader(session->GetPlayer()))
- if (_CreateRank(name, GR_RIGHT_GCHATLISTEN | GR_RIGHT_GCHATSPEAK))
- {
- char aux[2];
- sprintf(aux, "%u", size);
- _BroadcastEvent(GE_RANK_UPDATED, ObjectGuid::Empty, aux, name.c_str());
- }
+ {
+ SQLTransaction trans(nullptr);
+ if (_CreateRank(trans, name, GR_RIGHT_GCHATLISTEN | GR_RIGHT_GCHATSPEAK))
+ _BroadcastEvent(GE_RANK_UPDATED, ObjectGuid::Empty, std::to_string(size).c_str(), name.c_str());
+ }
}
void Guild::HandleRemoveLowestRank(WorldSession* session)
@@ -1973,10 +1978,11 @@ void Guild::LoadRankFromDB(Field* fields)
bool Guild::LoadMemberFromDB(Field* fields)
{
ObjectGuid::LowType lowguid = fields[1].GetUInt32();
- Member *member = new Member(m_id, ObjectGuid(HighGuid::Player, lowguid), fields[2].GetUInt8());
+ Member* member = new Member(m_id, ObjectGuid(HighGuid::Player, lowguid), fields[2].GetUInt8());
if (!member->LoadFromDB(fields))
{
- _DeleteMemberFromDB(lowguid);
+ SQLTransaction trans(nullptr);
+ _DeleteMemberFromDB(trans, lowguid);
delete member;
return false;
}
@@ -2080,6 +2086,8 @@ bool Guild::Validate()
// Min ranks count is 5 and max is 10.
bool broken_ranks = false;
uint8 ranks = _GetRanksSize();
+
+ SQLTransaction trans = CharacterDatabase.BeginTransaction();
if (ranks < GUILD_RANKS_MIN_COUNT || ranks > GUILD_RANKS_MAX_COUNT)
{
TC_LOG_ERROR("guild", "Guild %u has invalid number of ranks, creating new...", m_id);
@@ -2096,24 +2104,20 @@ bool Guild::Validate()
broken_ranks = true;
}
else
- {
- SQLTransaction trans = CharacterDatabase.BeginTransaction();
rankInfo->CreateMissingTabsIfNeeded(_GetPurchasedTabsSize(), trans, true);
- CharacterDatabase.CommitTransaction(trans);
- }
}
}
if (broken_ranks)
{
m_ranks.clear();
- _CreateDefaultGuildRanks(DEFAULT_LOCALE);
+ _CreateDefaultGuildRanks(trans, DEFAULT_LOCALE);
}
// Validate members' data
- for (Members::iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
+ for (auto itr = m_members.begin(); itr != m_members.end(); ++itr)
if (itr->second->GetRankId() > _GetRanksSize())
- itr->second->ChangeRank(_GetLowestRankId());
+ itr->second->ChangeRank(trans, _GetLowestRankId());
// Repair the structure of the guild.
// If the guildmaster doesn't exist or isn't member of the guild
@@ -2121,7 +2125,8 @@ bool Guild::Validate()
Member* pLeader = GetMember(m_leaderGuid);
if (!pLeader)
{
- DeleteMember(m_leaderGuid);
+ SQLTransaction trans(nullptr);
+ DeleteMember(trans, m_leaderGuid);
// If no more members left, disband guild
if (m_members.empty())
{
@@ -2134,10 +2139,12 @@ bool Guild::Validate()
// Check config if multiple guildmasters are allowed
if (!sConfigMgr->GetBoolDefault("Guild.AllowMultipleGuildMaster", 0))
- for (Members::iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
+ for (auto itr = m_members.begin(); itr != m_members.end(); ++itr)
if (itr->second->GetRankId() == GR_GUILDMASTER && !itr->second->IsSamePlayer(m_leaderGuid))
- itr->second->ChangeRank(GR_OFFICER);
+ itr->second->ChangeRank(trans, GR_OFFICER);
+ if (trans->GetSize() > 0)
+ CharacterDatabase.CommitTransaction(trans);
_UpdateAccountsNumber();
return true;
}
@@ -2148,8 +2155,8 @@ void Guild::BroadcastToGuild(WorldSession* session, bool officerOnly, std::strin
if (session && session->GetPlayer() && _HasRankRight(session->GetPlayer(), officerOnly ? GR_RIGHT_OFFCHATSPEAK : GR_RIGHT_GCHATSPEAK))
{
WorldPacket data;
- ChatHandler::BuildChatPacket(data, officerOnly ? CHAT_MSG_OFFICER : CHAT_MSG_GUILD, Language(language), session->GetPlayer(), NULL, msg);
- for (Members::const_iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
+ ChatHandler::BuildChatPacket(data, officerOnly ? CHAT_MSG_OFFICER : CHAT_MSG_GUILD, Language(language), session->GetPlayer(), nullptr, msg);
+ for (auto itr = m_members.begin(); itr != m_members.end(); ++itr)
if (Player* player = itr->second->FindConnectedPlayer())
if (player->GetSession() && _HasRankRight(player, officerOnly ? GR_RIGHT_OFFCHATLISTEN : GR_RIGHT_GCHATLISTEN) &&
!player->GetSocial()->HasIgnore(session->GetPlayer()->GetGUID().GetCounter()))
@@ -2159,7 +2166,7 @@ void Guild::BroadcastToGuild(WorldSession* session, bool officerOnly, std::strin
void Guild::BroadcastPacketToRank(WorldPacket* packet, uint8 rankId) const
{
- for (Members::const_iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
+ for (auto itr = m_members.begin(); itr != m_members.end(); ++itr)
if (itr->second->IsRank(rankId))
if (Player* player = itr->second->FindConnectedPlayer())
player->GetSession()->SendPacket(packet);
@@ -2167,7 +2174,7 @@ void Guild::BroadcastPacketToRank(WorldPacket* packet, uint8 rankId) const
void Guild::BroadcastPacket(WorldPacket* packet) const
{
- for (Members::const_iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
+ for (auto itr = m_members.begin(); itr != m_members.end(); ++itr)
if (Player* player = itr->second->FindPlayer())
player->GetSession()->SendPacket(packet);
}
@@ -2179,7 +2186,7 @@ void Guild::MassInviteToEvent(WorldSession* session, uint32 minLevel, uint32 max
WorldPacket data(SMSG_CALENDAR_FILTER_GUILD);
data << uint32(count); // count placeholder
- for (Members::const_iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
+ for (auto itr = m_members.begin(); itr != m_members.end(); ++itr)
{
// not sure if needed, maybe client checks it as well
if (count >= CALENDAR_MAX_INVITES)
@@ -2206,7 +2213,7 @@ void Guild::MassInviteToEvent(WorldSession* session, uint32 minLevel, uint32 max
}
// Members handling
-bool Guild::AddMember(ObjectGuid guid, uint8 rankId)
+bool Guild::AddMember(SQLTransaction& trans, ObjectGuid guid, uint8 rankId)
{
Player* player = ObjectAccessor::FindConnectedPlayer(guid);
// Player cannot be in guild
@@ -2269,7 +2276,6 @@ bool Guild::AddMember(ObjectGuid guid, uint8 rankId)
m_members[lowguid] = member;
}
- SQLTransaction trans(NULL);
member->SaveToDB(trans);
_UpdateAccountsNumber();
@@ -2282,7 +2288,7 @@ bool Guild::AddMember(ObjectGuid guid, uint8 rankId)
return true;
}
-void Guild::DeleteMember(ObjectGuid guid, bool isDisbanding, bool isKicked, bool canDeleteGuild)
+void Guild::DeleteMember(SQLTransaction& trans, ObjectGuid guid, bool isDisbanding, bool isKicked, bool canDeleteGuild)
{
ObjectGuid::LowType lowguid = guid.GetCounter();
Player* player = ObjectAccessor::FindConnectedPlayer(guid);
@@ -2291,9 +2297,9 @@ void Guild::DeleteMember(ObjectGuid guid, bool isDisbanding, bool isKicked, bool
// or when he is removed from guild by gm command
if (m_leaderGuid == guid && !isDisbanding)
{
- Member* oldLeader = NULL;
- Member* newLeader = NULL;
- for (Guild::Members::iterator i = m_members.begin(); i != m_members.end(); ++i)
+ Member* oldLeader = nullptr;
+ Member* newLeader = nullptr;
+ for (auto i = m_members.begin(); i != m_members.end(); ++i)
{
if (i->first == lowguid)
oldLeader = i->second;
@@ -2336,19 +2342,22 @@ void Guild::DeleteMember(ObjectGuid guid, bool isDisbanding, bool isKicked, bool
player->SetRank(0);
}
- _DeleteMemberFromDB(lowguid);
+ _DeleteMemberFromDB(trans, lowguid);
if (!isDisbanding)
_UpdateAccountsNumber();
}
-bool Guild::ChangeMemberRank(ObjectGuid guid, uint8 newRank)
+bool Guild::ChangeMemberRank(SQLTransaction& trans, ObjectGuid guid, uint8 newRank)
{
if (newRank <= _GetLowestRankId()) // Validate rank (allow only existing ranks)
+ {
if (Member* member = GetMember(guid))
{
- member->ChangeRank(newRank);
+ member->ChangeRank(trans, newRank);
return true;
}
+ }
+
return false;
}
@@ -2386,7 +2395,7 @@ void Guild::SetBankTabText(uint8 tabId, std::string const& text)
if (BankTab* pTab = GetBankTab(tabId))
{
pTab->SetText(text);
- pTab->SendText(this, NULL);
+ pTab->SendText(this, nullptr);
}
}
@@ -2416,30 +2425,32 @@ void Guild::_CreateNewBankTab()
trans->Append(stmt);
++tabId;
- for (Ranks::iterator itr = m_ranks.begin(); itr != m_ranks.end(); ++itr)
+ for (auto itr = m_ranks.begin(); itr != m_ranks.end(); ++itr)
(*itr).CreateMissingTabsIfNeeded(tabId, trans, false);
CharacterDatabase.CommitTransaction(trans);
}
-void Guild::_CreateDefaultGuildRanks(LocaleConstant loc)
+void Guild::_CreateDefaultGuildRanks(SQLTransaction& trans, LocaleConstant loc)
{
+ ASSERT(trans);
+
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_RANKS);
stmt->setUInt32(0, m_id);
- CharacterDatabase.Execute(stmt);
+ trans->Append(stmt);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_BANK_RIGHTS);
stmt->setUInt32(0, m_id);
- CharacterDatabase.Execute(stmt);
+ trans->Append(stmt);
- _CreateRank(sObjectMgr->GetTrinityString(LANG_GUILD_MASTER, loc), GR_RIGHT_ALL);
- _CreateRank(sObjectMgr->GetTrinityString(LANG_GUILD_OFFICER, loc), GR_RIGHT_ALL);
- _CreateRank(sObjectMgr->GetTrinityString(LANG_GUILD_VETERAN, loc), GR_RIGHT_GCHATLISTEN | GR_RIGHT_GCHATSPEAK);
- _CreateRank(sObjectMgr->GetTrinityString(LANG_GUILD_MEMBER, loc), GR_RIGHT_GCHATLISTEN | GR_RIGHT_GCHATSPEAK);
- _CreateRank(sObjectMgr->GetTrinityString(LANG_GUILD_INITIATE, loc), GR_RIGHT_GCHATLISTEN | GR_RIGHT_GCHATSPEAK);
+ _CreateRank(trans, sObjectMgr->GetTrinityString(LANG_GUILD_MASTER, loc), GR_RIGHT_ALL);
+ _CreateRank(trans, sObjectMgr->GetTrinityString(LANG_GUILD_OFFICER, loc), GR_RIGHT_ALL);
+ _CreateRank(trans, sObjectMgr->GetTrinityString(LANG_GUILD_VETERAN, loc), GR_RIGHT_GCHATLISTEN | GR_RIGHT_GCHATSPEAK);
+ _CreateRank(trans, sObjectMgr->GetTrinityString(LANG_GUILD_MEMBER, loc), GR_RIGHT_GCHATLISTEN | GR_RIGHT_GCHATSPEAK);
+ _CreateRank(trans, sObjectMgr->GetTrinityString(LANG_GUILD_INITIATE, loc), GR_RIGHT_GCHATLISTEN | GR_RIGHT_GCHATSPEAK);
}
-bool Guild::_CreateRank(std::string const& name, uint32 rights)
+bool Guild::_CreateRank(SQLTransaction& trans, std::string const& name, uint32 rights)
{
uint8 newRankId = _GetRanksSize();
if (newRankId >= GUILD_RANKS_MAX_COUNT)
@@ -2449,10 +2460,15 @@ bool Guild::_CreateRank(std::string const& name, uint32 rights)
RankInfo info(m_id, newRankId, name, rights, 0);
m_ranks.push_back(info);
- SQLTransaction trans = CharacterDatabase.BeginTransaction();
+ bool const isInTransaction = bool(trans);
+ if (!isInTransaction)
+ trans = CharacterDatabase.BeginTransaction();
+
info.CreateMissingTabsIfNeeded(_GetPurchasedTabsSize(), trans);
info.SaveToDB(trans);
- CharacterDatabase.CommitTransaction(trans);
+
+ if (!isInTransaction)
+ CharacterDatabase.CommitTransaction(trans);
return true;
}
@@ -2463,7 +2479,7 @@ void Guild::_UpdateAccountsNumber()
{
// We use a set to be sure each element will be unique
std::set<uint32> accountsIdSet;
- for (Members::const_iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
+ for (auto itr = m_members.begin(); itr != m_members.end(); ++itr)
accountsIdSet.insert(itr->second->GetAccountId());
m_accountsNumber = accountsIdSet.size();
@@ -2487,7 +2503,7 @@ void Guild::_DeleteBankItems(SQLTransaction& trans, bool removeItemsFromDB)
{
m_bankTabs[tabId]->Delete(trans, removeItemsFromDB);
delete m_bankTabs[tabId];
- m_bankTabs[tabId] = NULL;
+ m_bankTabs[tabId] = nullptr;
}
m_bankTabs.clear();
}
@@ -2516,13 +2532,16 @@ void Guild::_SetLeaderGUID(Member* pLeader)
if (!pLeader)
return;
+ SQLTransaction trans = CharacterDatabase.BeginTransaction();
m_leaderGuid = pLeader->GetGUID();
- pLeader->ChangeRank(GR_GUILDMASTER);
+ pLeader->ChangeRank(trans, GR_GUILDMASTER);
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GUILD_LEADER);
stmt->setUInt32(0, m_leaderGuid.GetCounter());
stmt->setUInt32(1, m_id);
- CharacterDatabase.Execute(stmt);
+ trans->Append(stmt);
+
+ CharacterDatabase.CommitTransaction(trans);
}
void Guild::_SetRankBankMoneyPerDay(uint8 rankId, uint32 moneyPerDay)
@@ -2670,13 +2689,13 @@ inline Item* Guild::_GetItem(uint8 tabId, uint8 slotId) const
{
if (const BankTab* tab = GetBankTab(tabId))
return tab->GetItem(slotId);
- return NULL;
+ return nullptr;
}
inline void Guild::_RemoveItem(SQLTransaction& trans, uint8 tabId, uint8 slotId)
{
if (BankTab* pTab = GetBankTab(tabId))
- pTab->SetItem(trans, slotId, NULL);
+ pTab->SetItem(trans, slotId, nullptr);
}
void Guild::_MoveItems(MoveItemData* pSrc, MoveItemData* pDest, uint32 splitedAmount)
@@ -2717,7 +2736,7 @@ void Guild::_MoveItems(MoveItemData* pSrc, MoveItemData* pDest, uint32 splitedAm
}
else // 6. No split
{
- // 6.1. Try to merge items in destination (pDest->GetItem() == NULL)
+ // 6.1. Try to merge items in destination (pDest->GetItem() == nullptr)
if (!_DoItemsMove(pSrc, pDest, false)) // Item could not be merged
{
// 6.2. Try to swap items
@@ -2732,7 +2751,7 @@ void Guild::_MoveItems(MoveItemData* pSrc, MoveItemData* pDest, uint32 splitedAm
if (!pDest->HasWithdrawRights(pSrc))
return; // Player has no rights to withdraw item from destination (opposite direction)
- // 6.2.3. Swap items (pDest->GetItem() != NULL)
+ // 6.2.3. Swap items (pDest->GetItem() != nullptr)
_DoItemsMove(pSrc, pDest, true);
}
}
@@ -2743,7 +2762,7 @@ void Guild::_MoveItems(MoveItemData* pSrc, MoveItemData* pDest, uint32 splitedAm
bool Guild::_DoItemsMove(MoveItemData* pSrc, MoveItemData* pDest, bool sendError, uint32 splitedAmount)
{
Item* pDestItem = pDest->GetItem();
- bool swap = (pDestItem != NULL);
+ bool swap = (pDestItem != nullptr);
Item* pSrcItem = pSrc->GetItem(splitedAmount != 0);
// 1. Can store source item in destination
@@ -2832,7 +2851,7 @@ void Guild::_SendBankContentUpdate(MoveItemData* pSrc, MoveItemData* pDest) cons
void Guild::_SendBankContentUpdate(uint8 tabId, SlotIds slots) const
{
- _SendBankList(NULL, tabId, false, &slots);
+ _SendBankList(nullptr, tabId, false, &slots);
}
void Guild::_BroadcastEvent(GuildEvents guildEvent, ObjectGuid guid, const char* param1, const char* param2, const char* param3) const
@@ -2855,10 +2874,10 @@ void Guild::_BroadcastEvent(GuildEvents guildEvent, ObjectGuid guid, const char*
BroadcastPacket(&data);
- TC_LOG_DEBUG("guild", "SMSG_GUILD_EVENT [Broadcast] Event: %s (%u)", _GetGuildEventString(guildEvent).c_str(), guildEvent);
+ TC_LOG_DEBUG("guild", "SMSG_GUILD_EVENT [Broadcast] Event: %s (%u)", GetGuildEventString(guildEvent), guildEvent);
}
-void Guild::_SendBankList(WorldSession* session /* = NULL*/, uint8 tabId /*= 0*/, bool sendAllSlots /*= false*/, SlotIds *slots /*= NULL*/) const
+void Guild::_SendBankList(WorldSession* session /* = nullptr*/, uint8 tabId /*= 0*/, bool sendAllSlots /*= false*/, SlotIds *slots /*= nullptr*/) const
{
WorldPacket data(SMSG_GUILD_BANK_LIST, 500);
data << uint64(m_bankMoney);
@@ -2882,7 +2901,7 @@ void Guild::_SendBankList(WorldSession* session /* = NULL*/, uint8 tabId /*= 0*/
else if (slots && !slots->empty())
{
data << uint8(slots->size());
- for (SlotIds::const_iterator itr = slots->begin(); itr != slots->end(); ++itr)
+ for (auto itr = slots->begin(); itr != slots->end(); ++itr)
tab->WriteSlotPacket(data, *itr, false);
}
else
@@ -2900,7 +2919,7 @@ void Guild::_SendBankList(WorldSession* session /* = NULL*/, uint8 tabId /*= 0*/
}
else /// @todo - Probably this is just sent to session + those that have sent CMSG_GUILD_BANKER_ACTIVATE
{
- for (Members::const_iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
+ for (auto itr = m_members.begin(); itr != m_members.end(); ++itr)
{
if (!_MemberHasTabRights(itr->second->GetGUID(), tabId, GUILD_BANK_RIGHT_VIEW_TAB))
continue;
@@ -2919,7 +2938,7 @@ void Guild::_SendBankList(WorldSession* session /* = NULL*/, uint8 tabId /*= 0*/
void Guild::ResetTimes()
{
- for (Members::const_iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
+ for (auto itr = m_members.begin(); itr != m_members.end(); ++itr)
itr->second->ResetValues();
_BroadcastEvent(GE_BANK_TAB_AND_MONEY_UPDATED, ObjectGuid::Empty);
diff --git a/src/server/game/Guilds/Guild.h b/src/server/game/Guilds/Guild.h
index e25a3201957..742923f51a1 100644
--- a/src/server/game/Guilds/Guild.h
+++ b/src/server/game/Guilds/Guild.h
@@ -225,54 +225,54 @@ enum GuildMemberFlags
// Emblem info
class TC_GAME_API EmblemInfo
{
-public:
- EmblemInfo() : m_style(0), m_color(0), m_borderStyle(0), m_borderColor(0), m_backgroundColor(0) { }
-
- void LoadFromDB(Field* fields);
- void SaveToDB(ObjectGuid::LowType guildId) const;
- void ReadPacket(WorldPacket& recv);
- void WritePacket(WorldPacket& data) const;
-
- uint32 GetStyle() const { return m_style; }
- uint32 GetColor() const { return m_color; }
- uint32 GetBorderStyle() const { return m_borderStyle; }
- uint32 GetBorderColor() const { return m_borderColor; }
- uint32 GetBackgroundColor() const { return m_backgroundColor; }
-
-private:
- uint32 m_style;
- uint32 m_color;
- uint32 m_borderStyle;
- uint32 m_borderColor;
- uint32 m_backgroundColor;
+ public:
+ EmblemInfo() : m_style(0), m_color(0), m_borderStyle(0), m_borderColor(0), m_backgroundColor(0) { }
+
+ void LoadFromDB(Field* fields);
+ void SaveToDB(ObjectGuid::LowType guildId) const;
+ void ReadPacket(WorldPacket& recv);
+ void WritePacket(WorldPacket& data) const;
+
+ uint32 GetStyle() const { return m_style; }
+ uint32 GetColor() const { return m_color; }
+ uint32 GetBorderStyle() const { return m_borderStyle; }
+ uint32 GetBorderColor() const { return m_borderColor; }
+ uint32 GetBackgroundColor() const { return m_backgroundColor; }
+
+ private:
+ uint32 m_style;
+ uint32 m_color;
+ uint32 m_borderStyle;
+ uint32 m_borderColor;
+ uint32 m_backgroundColor;
};
// Structure for storing guild bank rights and remaining slots together.
class GuildBankRightsAndSlots
{
-public:
- GuildBankRightsAndSlots() : tabId(TAB_UNDEFINED), rights(0), slots(0) { }
- GuildBankRightsAndSlots(uint8 _tabId) : tabId(_tabId), rights(0), slots(0) { }
- GuildBankRightsAndSlots(uint8 _tabId, uint8 _rights, uint32 _slots) : tabId(_tabId), rights(_rights), slots(_slots) { }
-
- void SetGuildMasterValues()
- {
- rights = GUILD_BANK_RIGHT_FULL;
- slots = uint32(GUILD_WITHDRAW_SLOT_UNLIMITED);
- }
-
- void SetTabId(uint8 _tabId) { tabId = _tabId; }
- void SetSlots(uint32 _slots) { slots = _slots; }
- void SetRights(uint8 _rights) { rights = _rights; }
-
- int8 GetTabId() const { return tabId; }
- int32 GetSlots() const { return slots; }
- int8 GetRights() const { return rights; }
-
-private:
- uint8 tabId;
- uint8 rights;
- uint32 slots;
+ public:
+ GuildBankRightsAndSlots() : tabId(TAB_UNDEFINED), rights(0), slots(0) { }
+ GuildBankRightsAndSlots(uint8 _tabId) : tabId(_tabId), rights(0), slots(0) { }
+ GuildBankRightsAndSlots(uint8 _tabId, uint8 _rights, uint32 _slots) : tabId(_tabId), rights(_rights), slots(_slots) { }
+
+ void SetGuildMasterValues()
+ {
+ rights = GUILD_BANK_RIGHT_FULL;
+ slots = uint32(GUILD_WITHDRAW_SLOT_UNLIMITED);
+ }
+
+ void SetTabId(uint8 _tabId) { tabId = _tabId; }
+ void SetSlots(uint32 _slots) { slots = _slots; }
+ void SetRights(uint8 _rights) { rights = _rights; }
+
+ int8 GetTabId() const { return tabId; }
+ int32 GetSlots() const { return slots; }
+ int8 GetRights() const { return rights; }
+
+ private:
+ uint8 tabId;
+ uint8 rights;
+ uint32 slots;
};
typedef std::vector <GuildBankRightsAndSlots> GuildBankRightsAndSlotsVec;
@@ -281,577 +281,577 @@ typedef std::set <uint8> SlotIds;
class TC_GAME_API Guild
{
-private:
- // Class representing guild member
- class Member
- {
- public:
- Member(ObjectGuid::LowType guildId, ObjectGuid guid, uint8 rankId) :
- m_guildId(guildId),
- m_guid(guid),
- m_zoneId(0),
- m_level(0),
- m_class(0),
- m_flags(GUILDMEMBER_STATUS_NONE),
- m_logoutTime(::time(NULL)),
- m_accountId(0),
- m_rankId(rankId)
+ private:
+ // Class representing guild member
+ class Member
{
- memset(m_bankWithdraw, 0, (GUILD_BANK_MAX_TABS + 1) * sizeof(int32));
- }
-
- void SetStats(Player* player);
- void SetStats(std::string const& name, uint8 level, uint8 _class, uint32 zoneId, uint32 accountId);
- bool CheckStats() const;
+ public:
+ Member(ObjectGuid::LowType guildId, ObjectGuid guid, uint8 rankId) :
+ m_guildId(guildId),
+ m_guid(guid),
+ m_zoneId(0),
+ m_level(0),
+ m_class(0),
+ m_flags(GUILDMEMBER_STATUS_NONE),
+ m_logoutTime(::time(nullptr)),
+ m_accountId(0),
+ m_rankId(rankId)
+ {
+ memset(m_bankWithdraw, 0, (GUILD_BANK_MAX_TABS + 1) * sizeof(int32));
+ }
+
+ void SetStats(Player* player);
+ void SetStats(std::string const& name, uint8 level, uint8 _class, uint32 zoneId, uint32 accountId);
+ bool CheckStats() const;
+
+ void SetPublicNote(std::string const& publicNote);
+ void SetOfficerNote(std::string const& officerNote);
+ void SetZoneID(uint32 id) { m_zoneId = id; }
+ void SetLevel(uint8 var) { m_level = var; }
+
+ void AddFlag(uint8 var) { m_flags |= var; }
+ void RemFlag(uint8 var) { m_flags &= ~var; }
+ void ResetFlags() { m_flags = GUILDMEMBER_STATUS_NONE; }
+
+ bool LoadFromDB(Field* fields);
+ void SaveToDB(SQLTransaction& trans) const;
+ void WritePacket(WorldPacket& data, bool sendOfficerNote) const;
+
+ ObjectGuid GetGUID() const { return m_guid; }
+ std::string const& GetName() const { return m_name; }
+ uint32 GetAccountId() const { return m_accountId; }
+ uint8 GetRankId() const { return m_rankId; }
+ uint64 GetLogoutTime() const { return m_logoutTime; }
+ std::string GetPublicNote() const { return m_publicNote; }
+ std::string GetOfficerNote() const { return m_officerNote; }
+ uint8 GetClass() const { return m_class; }
+ uint8 GetLevel() const { return m_level; }
+ uint8 GetFlags() const { return m_flags; }
+ uint32 GetZoneId() const { return m_zoneId; }
+ bool IsOnline() const { return (m_flags & GUILDMEMBER_STATUS_ONLINE); }
+
+ void ChangeRank(SQLTransaction& trans, uint8 newRank);
+
+ inline void UpdateLogoutTime() { m_logoutTime = ::time(nullptr); }
+ inline bool IsRank(uint8 rankId) const { return m_rankId == rankId; }
+ inline bool IsRankNotLower(uint8 rankId) const { return m_rankId <= rankId; }
+ inline bool IsSamePlayer(ObjectGuid guid) const { return m_guid == guid; }
+
+ void UpdateBankWithdrawValue(SQLTransaction& trans, uint8 tabId, uint32 amount);
+ int32 GetBankWithdrawValue(uint8 tabId) const;
+ void ResetValues();
+
+ inline Player* FindPlayer() const { return ObjectAccessor::FindPlayer(m_guid); }
+ inline Player* FindConnectedPlayer() const { return ObjectAccessor::FindConnectedPlayer(m_guid); }
+
+ private:
+ ObjectGuid::LowType m_guildId;
+ // Fields from characters table
+ ObjectGuid m_guid;
+ std::string m_name;
+ uint32 m_zoneId;
+ uint8 m_level;
+ uint8 m_class;
+ uint8 m_flags;
+ uint64 m_logoutTime;
+ uint32 m_accountId;
+ // Fields from guild_member table
+ uint8 m_rankId;
+ std::string m_publicNote;
+ std::string m_officerNote;
+
+ int32 m_bankWithdraw[GUILD_BANK_MAX_TABS + 1];
+ };
+
+ // Base class for event entries
+ class LogEntry
+ {
+ public:
+ LogEntry(ObjectGuid::LowType guildId, uint32 guid) : m_guildId(guildId), m_guid(guid), m_timestamp(::time(nullptr)) { }
+ LogEntry(ObjectGuid::LowType guildId, uint32 guid, time_t timestamp) : m_guildId(guildId), m_guid(guid), m_timestamp(timestamp) { }
+ virtual ~LogEntry() { }
- void SetPublicNote(std::string const& publicNote);
- void SetOfficerNote(std::string const& officerNote);
- void SetZoneID(uint32 id) { m_zoneId = id; }
- void SetLevel(uint8 var) { m_level = var; }
+ uint32 GetGUID() const { return m_guid; }
+ uint64 GetTimestamp() const { return m_timestamp; }
- void AddFlag(uint8 var) { m_flags |= var; }
- void RemFlag(uint8 var) { m_flags &= ~var; }
- void ResetFlags() { m_flags = GUILDMEMBER_STATUS_NONE; }
+ virtual void SaveToDB(SQLTransaction& trans) const = 0;
+ virtual void WritePacket(WorldPacket& data) const = 0;
- bool LoadFromDB(Field* fields);
- void SaveToDB(SQLTransaction& trans) const;
- void WritePacket(WorldPacket& data, bool sendOfficerNote) const;
+ protected:
+ ObjectGuid::LowType m_guildId;
+ uint32 m_guid;
+ uint64 m_timestamp;
+ };
- ObjectGuid GetGUID() const { return m_guid; }
- std::string const& GetName() const { return m_name; }
- uint32 GetAccountId() const { return m_accountId; }
- uint8 GetRankId() const { return m_rankId; }
- uint64 GetLogoutTime() const { return m_logoutTime; }
- std::string GetPublicNote() const { return m_publicNote; }
- std::string GetOfficerNote() const { return m_officerNote; }
- uint8 GetClass() const { return m_class; }
- uint8 GetLevel() const { return m_level; }
- uint8 GetFlags() const { return m_flags; }
- uint32 GetZoneId() const { return m_zoneId; }
- bool IsOnline() const { return (m_flags & GUILDMEMBER_STATUS_ONLINE); }
-
- void ChangeRank(uint8 newRank);
-
- inline void UpdateLogoutTime() { m_logoutTime = ::time(NULL); }
- inline bool IsRank(uint8 rankId) const { return m_rankId == rankId; }
- inline bool IsRankNotLower(uint8 rankId) const { return m_rankId <= rankId; }
- inline bool IsSamePlayer(ObjectGuid guid) const { return m_guid == guid; }
-
- void UpdateBankWithdrawValue(SQLTransaction& trans, uint8 tabId, uint32 amount);
- int32 GetBankWithdrawValue(uint8 tabId) const;
- void ResetValues();
-
- inline Player* FindPlayer() const { return ObjectAccessor::FindPlayer(m_guid); }
- inline Player* FindConnectedPlayer() const { return ObjectAccessor::FindConnectedPlayer(m_guid); }
+ // Event log entry
+ class EventLogEntry : public LogEntry
+ {
+ public:
+ EventLogEntry(ObjectGuid::LowType guildId, uint32 guid, GuildEventLogTypes eventType, ObjectGuid::LowType playerGuid1, ObjectGuid::LowType playerGuid2, uint8 newRank) :
+ LogEntry(guildId, guid), m_eventType(eventType), m_playerGuid1(playerGuid1), m_playerGuid2(playerGuid2), m_newRank(newRank) { }
- private:
- ObjectGuid::LowType m_guildId;
- // Fields from characters table
- ObjectGuid m_guid;
- std::string m_name;
- uint32 m_zoneId;
- uint8 m_level;
- uint8 m_class;
- uint8 m_flags;
- uint64 m_logoutTime;
- uint32 m_accountId;
- // Fields from guild_member table
- uint8 m_rankId;
- std::string m_publicNote;
- std::string m_officerNote;
-
- int32 m_bankWithdraw[GUILD_BANK_MAX_TABS + 1];
- };
-
- // Base class for event entries
- class LogEntry
- {
- public:
- LogEntry(ObjectGuid::LowType guildId, uint32 guid) : m_guildId(guildId), m_guid(guid), m_timestamp(::time(NULL)) { }
- LogEntry(ObjectGuid::LowType guildId, uint32 guid, time_t timestamp) : m_guildId(guildId), m_guid(guid), m_timestamp(timestamp) { }
- virtual ~LogEntry() { }
+ EventLogEntry(ObjectGuid::LowType guildId, uint32 guid, time_t timestamp, GuildEventLogTypes eventType, ObjectGuid::LowType playerGuid1, ObjectGuid::LowType playerGuid2, uint8 newRank) :
+ LogEntry(guildId, guid, timestamp), m_eventType(eventType), m_playerGuid1(playerGuid1), m_playerGuid2(playerGuid2), m_newRank(newRank) { }
- uint32 GetGUID() const { return m_guid; }
- uint64 GetTimestamp() const { return m_timestamp; }
+ ~EventLogEntry() { }
- virtual void SaveToDB(SQLTransaction& trans) const = 0;
- virtual void WritePacket(WorldPacket& data) const = 0;
+ void SaveToDB(SQLTransaction& trans) const override;
+ void WritePacket(WorldPacket& data) const override;
- protected:
- ObjectGuid::LowType m_guildId;
- uint32 m_guid;
- uint64 m_timestamp;
- };
-
- // Event log entry
- class EventLogEntry : public LogEntry
- {
- public:
- EventLogEntry(ObjectGuid::LowType guildId, uint32 guid, GuildEventLogTypes eventType, ObjectGuid::LowType playerGuid1, ObjectGuid::LowType playerGuid2, uint8 newRank) :
- LogEntry(guildId, guid), m_eventType(eventType), m_playerGuid1(playerGuid1), m_playerGuid2(playerGuid2), m_newRank(newRank) { }
+ private:
+ GuildEventLogTypes m_eventType;
+ ObjectGuid::LowType m_playerGuid1;
+ ObjectGuid::LowType m_playerGuid2;
+ uint8 m_newRank;
+ };
- EventLogEntry(ObjectGuid::LowType guildId, uint32 guid, time_t timestamp, GuildEventLogTypes eventType, ObjectGuid::LowType playerGuid1, ObjectGuid::LowType playerGuid2, uint8 newRank) :
- LogEntry(guildId, guid, timestamp), m_eventType(eventType), m_playerGuid1(playerGuid1), m_playerGuid2(playerGuid2), m_newRank(newRank) { }
+ // Bank event log entry
+ class BankEventLogEntry : public LogEntry
+ {
+ public:
+ static bool IsMoneyEvent(GuildBankEventLogTypes eventType)
+ {
+ return
+ eventType == GUILD_BANK_LOG_DEPOSIT_MONEY ||
+ eventType == GUILD_BANK_LOG_WITHDRAW_MONEY ||
+ eventType == GUILD_BANK_LOG_REPAIR_MONEY;
+ }
+
+ BankEventLogEntry(ObjectGuid::LowType guildId, uint32 guid, GuildBankEventLogTypes eventType, uint8 tabId, ObjectGuid::LowType playerGuid, uint32 itemOrMoney, uint16 itemStackCount, uint8 destTabId) :
+ LogEntry(guildId, guid), m_eventType(eventType), m_bankTabId(tabId), m_playerGuid(playerGuid),
+ m_itemOrMoney(itemOrMoney), m_itemStackCount(itemStackCount), m_destTabId(destTabId) { }
+
+ BankEventLogEntry(ObjectGuid::LowType guildId, uint32 guid, time_t timestamp, uint8 tabId, GuildBankEventLogTypes eventType, ObjectGuid::LowType playerGuid, uint32 itemOrMoney, uint16 itemStackCount, uint8 destTabId) :
+ LogEntry(guildId, guid, timestamp), m_eventType(eventType), m_bankTabId(tabId), m_playerGuid(playerGuid),
+ m_itemOrMoney(itemOrMoney), m_itemStackCount(itemStackCount), m_destTabId(destTabId) { }
+
+ ~BankEventLogEntry() { }
+
+ void SaveToDB(SQLTransaction& trans) const override;
+ void WritePacket(WorldPacket& data) const override;
+
+ private:
+ GuildBankEventLogTypes m_eventType;
+ uint8 m_bankTabId;
+ ObjectGuid::LowType m_playerGuid;
+ uint32 m_itemOrMoney;
+ uint16 m_itemStackCount;
+ uint8 m_destTabId;
+ };
+
+ // Class encapsulating work with events collection
+ typedef std::list<LogEntry*> GuildLog;
+
+ class LogHolder
+ {
+ public:
+ LogHolder(uint32 maxRecords) : m_maxRecords(maxRecords), m_nextGUID(uint32(GUILD_EVENT_LOG_GUID_UNDEFINED)) { }
+ ~LogHolder();
+
+ uint8 GetSize() const { return uint8(m_log.size()); }
+ // Checks if new log entry can be added to holder when loading from DB
+ inline bool CanInsert() const { return m_log.size() < m_maxRecords; }
+ // Adds event from DB to collection
+ void LoadEvent(LogEntry* entry);
+ // Adds new event to collection and saves it to DB
+ void AddEvent(SQLTransaction& trans, LogEntry* entry);
+ // Writes information about all events to packet
+ void WritePacket(WorldPacket& data) const;
+ uint32 GetNextGUID();
+
+ private:
+ GuildLog m_log;
+ uint32 m_maxRecords;
+ uint32 m_nextGUID;
+ };
+
+ // Class encapsulating guild rank data
+ class RankInfo
+ {
+ public:
+ RankInfo(): m_guildId(0), m_rankId(GUILD_RANK_NONE), m_rights(GR_RIGHT_EMPTY), m_bankMoneyPerDay(0) { }
+ RankInfo(ObjectGuid::LowType guildId) : m_guildId(guildId), m_rankId(GUILD_RANK_NONE), m_rights(GR_RIGHT_EMPTY), m_bankMoneyPerDay(0) { }
+ RankInfo(ObjectGuid::LowType guildId, uint8 rankId, std::string const& name, uint32 rights, uint32 money) :
+ m_guildId(guildId), m_rankId(rankId), m_name(name), m_rights(rights),
+ m_bankMoneyPerDay(rankId != GR_GUILDMASTER ? money : GUILD_WITHDRAW_MONEY_UNLIMITED) { }
- ~EventLogEntry() { }
+ void LoadFromDB(Field* fields);
+ void SaveToDB(SQLTransaction& trans) const;
+ void WritePacket(WorldPacket& data) const;
- void SaveToDB(SQLTransaction& trans) const override;
- void WritePacket(WorldPacket& data) const override;
+ uint8 GetId() const { return m_rankId; }
- private:
- GuildEventLogTypes m_eventType;
- ObjectGuid::LowType m_playerGuid1;
- ObjectGuid::LowType m_playerGuid2;
- uint8 m_newRank;
- };
-
- // Bank event log entry
- class BankEventLogEntry : public LogEntry
- {
- public:
- static bool IsMoneyEvent(GuildBankEventLogTypes eventType)
- {
- return
- eventType == GUILD_BANK_LOG_DEPOSIT_MONEY ||
- eventType == GUILD_BANK_LOG_WITHDRAW_MONEY ||
- eventType == GUILD_BANK_LOG_REPAIR_MONEY;
- }
+ std::string const& GetName() const { return m_name; }
+ void SetName(std::string const& name);
- BankEventLogEntry(ObjectGuid::LowType guildId, uint32 guid, GuildBankEventLogTypes eventType, uint8 tabId, ObjectGuid::LowType playerGuid, uint32 itemOrMoney, uint16 itemStackCount, uint8 destTabId) :
- LogEntry(guildId, guid), m_eventType(eventType), m_bankTabId(tabId), m_playerGuid(playerGuid),
- m_itemOrMoney(itemOrMoney), m_itemStackCount(itemStackCount), m_destTabId(destTabId) { }
+ uint32 GetRights() const { return m_rights; }
+ void SetRights(uint32 rights);
- BankEventLogEntry(ObjectGuid::LowType guildId, uint32 guid, time_t timestamp, uint8 tabId, GuildBankEventLogTypes eventType, ObjectGuid::LowType playerGuid, uint32 itemOrMoney, uint16 itemStackCount, uint8 destTabId) :
- LogEntry(guildId, guid, timestamp), m_eventType(eventType), m_bankTabId(tabId), m_playerGuid(playerGuid),
- m_itemOrMoney(itemOrMoney), m_itemStackCount(itemStackCount), m_destTabId(destTabId) { }
+ int32 GetBankMoneyPerDay() const { return m_bankMoneyPerDay; }
- ~BankEventLogEntry() { }
+ void SetBankMoneyPerDay(uint32 money);
- void SaveToDB(SQLTransaction& trans) const override;
- void WritePacket(WorldPacket& data) const override;
+ inline int8 GetBankTabRights(uint8 tabId) const
+ {
+ return tabId < GUILD_BANK_MAX_TABS ? m_bankTabRightsAndSlots[tabId].GetRights() : 0;
+ }
- private:
- GuildBankEventLogTypes m_eventType;
- uint8 m_bankTabId;
- ObjectGuid::LowType m_playerGuid;
- uint32 m_itemOrMoney;
- uint16 m_itemStackCount;
- uint8 m_destTabId;
- };
-
- // Class encapsulating work with events collection
- typedef std::list<LogEntry*> GuildLog;
-
- class LogHolder
- {
- public:
- LogHolder(uint32 maxRecords) : m_maxRecords(maxRecords), m_nextGUID(uint32(GUILD_EVENT_LOG_GUID_UNDEFINED)) { }
- ~LogHolder();
-
- uint8 GetSize() const { return uint8(m_log.size()); }
- // Checks if new log entry can be added to holder when loading from DB
- inline bool CanInsert() const { return m_log.size() < m_maxRecords; }
- // Adds event from DB to collection
- void LoadEvent(LogEntry* entry);
- // Adds new event to collection and saves it to DB
- void AddEvent(SQLTransaction& trans, LogEntry* entry);
- // Writes information about all events to packet
- void WritePacket(WorldPacket& data) const;
- uint32 GetNextGUID();
+ inline int32 GetBankTabSlotsPerDay(uint8 tabId) const
+ {
+ return tabId < GUILD_BANK_MAX_TABS ? m_bankTabRightsAndSlots[tabId].GetSlots() : 0;
+ }
- private:
- GuildLog m_log;
- uint32 m_maxRecords;
- uint32 m_nextGUID;
- };
-
- // Class encapsulating guild rank data
- class RankInfo
- {
- public:
- RankInfo(): m_guildId(0), m_rankId(GUILD_RANK_NONE), m_rights(GR_RIGHT_EMPTY), m_bankMoneyPerDay(0) { }
- RankInfo(ObjectGuid::LowType guildId) : m_guildId(guildId), m_rankId(GUILD_RANK_NONE), m_rights(GR_RIGHT_EMPTY), m_bankMoneyPerDay(0) { }
- RankInfo(ObjectGuid::LowType guildId, uint8 rankId, std::string const& name, uint32 rights, uint32 money) :
- m_guildId(guildId), m_rankId(rankId), m_name(name), m_rights(rights),
- m_bankMoneyPerDay(rankId != GR_GUILDMASTER ? money : GUILD_WITHDRAW_MONEY_UNLIMITED) { }
+ void SetBankTabSlotsAndRights(GuildBankRightsAndSlots rightsAndSlots, bool saveToDB);
+ void CreateMissingTabsIfNeeded(uint8 ranks, SQLTransaction& trans, bool logOnCreate = false);
- void LoadFromDB(Field* fields);
- void SaveToDB(SQLTransaction& trans) const;
- void WritePacket(WorldPacket& data) const;
+ private:
+ ObjectGuid::LowType m_guildId;
- uint8 GetId() const { return m_rankId; }
+ uint8 m_rankId;
+ std::string m_name;
+ uint32 m_rights;
+ uint32 m_bankMoneyPerDay;
+ GuildBankRightsAndSlots m_bankTabRightsAndSlots[GUILD_BANK_MAX_TABS];
+ };
- std::string const& GetName() const { return m_name; }
- void SetName(std::string const& name);
+ class BankTab
+ {
+ public:
+ BankTab(ObjectGuid::LowType guildId, uint8 tabId) : m_guildId(guildId), m_tabId(tabId)
+ {
+ memset(m_items, 0, GUILD_BANK_MAX_SLOTS * sizeof(Item*));
+ }
+
+ void LoadFromDB(Field* fields);
+ bool LoadItemFromDB(Field* fields);
+ void Delete(SQLTransaction& trans, bool removeItemsFromDB = false);
+
+ void WritePacket(WorldPacket& data) const;
+ bool WriteSlotPacket(WorldPacket& data, uint8 slotId, bool ignoreEmpty = true) const;
+ void WriteInfoPacket(WorldPacket& data) const
+ {
+ data << m_name;
+ data << m_icon;
+ }
+
+ void SetInfo(std::string const& name, std::string const& icon);
+ void SetText(std::string const& text);
+ void SendText(const Guild* guild, WorldSession* session) const;
+
+ inline Item* GetItem(uint8 slotId) const { return slotId < GUILD_BANK_MAX_SLOTS ? m_items[slotId] : NULL; }
+ bool SetItem(SQLTransaction& trans, uint8 slotId, Item* pItem);
+
+ private:
+ ObjectGuid::LowType m_guildId;
+ uint8 m_tabId;
+
+ Item* m_items[GUILD_BANK_MAX_SLOTS];
+ std::string m_name;
+ std::string m_icon;
+ std::string m_text;
+ };
+
+ // Movement data
+ class MoveItemData
+ {
+ public:
+ MoveItemData(Guild* guild, Player* player, uint8 container, uint8 slotId) : m_pGuild(guild), m_pPlayer(player),
+ m_container(container), m_slotId(slotId), m_pItem(NULL), m_pClonedItem(NULL) { }
+ virtual ~MoveItemData() { }
+
+ virtual bool IsBank() const = 0;
+ // Initializes item pointer. Returns true, if item exists, false otherwise.
+ virtual bool InitItem() = 0;
+ // Checks splited amount against item. Splited amount cannot be more that number of items in stack.
+ virtual bool CheckItem(uint32& splitedAmount);
+ // Defines if player has rights to save item in container
+ virtual bool HasStoreRights(MoveItemData* /*pOther*/) const { return true; }
+ // Defines if player has rights to withdraw item from container
+ virtual bool HasWithdrawRights(MoveItemData* /*pOther*/) const { return true; }
+ // Checks if container can store specified item
+ bool CanStore(Item* pItem, bool swap, bool sendError);
+ // Clones stored item
+ bool CloneItem(uint32 count);
+ // Remove item from container (if splited update items fields)
+ virtual void RemoveItem(SQLTransaction& trans, MoveItemData* pOther, uint32 splitedAmount = 0) = 0;
+ // Saves item to container
+ virtual Item* StoreItem(SQLTransaction& trans, Item* pItem) = 0;
+ // Log bank event
+ virtual void LogBankEvent(SQLTransaction& trans, MoveItemData* pFrom, uint32 count) const = 0;
+ // Log GM action
+ virtual void LogAction(MoveItemData* pFrom) const;
+ // Copy slots id from position vector
+ void CopySlots(SlotIds& ids) const;
+
+ Item* GetItem(bool isCloned = false) const { return isCloned ? m_pClonedItem : m_pItem; }
+ uint8 GetContainer() const { return m_container; }
+ uint8 GetSlotId() const { return m_slotId; }
+
+ protected:
+ virtual InventoryResult CanStore(Item* pItem, bool swap) = 0;
+
+ Guild* m_pGuild;
+ Player* m_pPlayer;
+ uint8 m_container;
+ uint8 m_slotId;
+ Item* m_pItem;
+ Item* m_pClonedItem;
+ ItemPosCountVec m_vec;
+ };
+
+ class PlayerMoveItemData : public MoveItemData
+ {
+ public:
+ PlayerMoveItemData(Guild* guild, Player* player, uint8 container, uint8 slotId) :
+ MoveItemData(guild, player, container, slotId) { }
+
+ bool IsBank() const override { return false; }
+ bool InitItem() override;
+ void RemoveItem(SQLTransaction& trans, MoveItemData* pOther, uint32 splitedAmount = 0) override;
+ Item* StoreItem(SQLTransaction& trans, Item* pItem) override;
+ void LogBankEvent(SQLTransaction& trans, MoveItemData* pFrom, uint32 count) const override;
+ protected:
+ InventoryResult CanStore(Item* pItem, bool swap) override;
+ };
+
+ class BankMoveItemData : public MoveItemData
+ {
+ public:
+ BankMoveItemData(Guild* guild, Player* player, uint8 container, uint8 slotId) :
+ MoveItemData(guild, player, container, slotId) { }
+
+ bool IsBank() const override { return true; }
+ bool InitItem() override;
+ bool HasStoreRights(MoveItemData* pOther) const override;
+ bool HasWithdrawRights(MoveItemData* pOther) const override;
+ void RemoveItem(SQLTransaction& trans, MoveItemData* pOther, uint32 splitedAmount) override;
+ Item* StoreItem(SQLTransaction& trans, Item* pItem) override;
+ void LogBankEvent(SQLTransaction& trans, MoveItemData* pFrom, uint32 count) const override;
+ void LogAction(MoveItemData* pFrom) const override;
+
+ protected:
+ InventoryResult CanStore(Item* pItem, bool swap) override;
+
+ private:
+ Item* _StoreItem(SQLTransaction& trans, BankTab* pTab, Item* pItem, ItemPosCount& pos, bool clone) const;
+ bool _ReserveSpace(uint8 slotId, Item* pItem, Item* pItemDest, uint32& count);
+ void CanStoreItemInTab(Item* pItem, uint8 skipSlotId, bool merge, uint32& count);
+ };
+
+ typedef std::unordered_map<uint32, Member*> Members;
+ typedef std::vector<RankInfo> Ranks;
+ typedef std::vector<BankTab*> BankTabs;
- uint32 GetRights() const { return m_rights; }
- void SetRights(uint32 rights);
+ public:
+ static void SendCommandResult(WorldSession* session, GuildCommandType type, GuildCommandError errCode, std::string const& param = "");
+ static void SendSaveEmblemResult(WorldSession* session, GuildEmblemError errCode);
- int32 GetBankMoneyPerDay() const { return m_bankMoneyPerDay; }
+ Guild();
+ ~Guild();
- void SetBankMoneyPerDay(uint32 money);
+ bool Create(Player* pLeader, std::string const& name);
+ void Disband();
- inline int8 GetBankTabRights(uint8 tabId) const
+ // Getters
+ ObjectGuid::LowType GetId() const { return m_id; }
+ ObjectGuid GetLeaderGUID() const { return m_leaderGuid; }
+ std::string const& GetName() const { return m_name; }
+ std::string const& GetMOTD() const { return m_motd; }
+ std::string const& GetInfo() const { return m_info; }
+ uint32 GetMemberCount() const { return m_members.size(); }
+ time_t GetCreatedDate() const { return m_createdDate; }
+ uint64 GetBankMoney() const { return m_bankMoney; }
+
+ bool SetName(std::string const& name);
+
+ // Handle client commands
+ void HandleRoster(WorldSession* session);
+ void HandleQuery(WorldSession* session);
+ void HandleSetMOTD(WorldSession* session, std::string const& motd);
+ void HandleSetInfo(WorldSession* session, std::string const& info);
+ void HandleSetEmblem(WorldSession* session, const EmblemInfo& emblemInfo);
+ void HandleSetLeader(WorldSession* session, std::string const& name);
+ void HandleSetBankTabInfo(WorldSession* session, uint8 tabId, std::string const& name, std::string const& icon);
+ void HandleSetMemberNote(WorldSession* session, std::string const& name, std::string const& note, bool officer);
+ void HandleSetRankInfo(WorldSession* session, uint8 rankId, std::string const& name, uint32 rights, uint32 moneyPerDay, const GuildBankRightsAndSlotsVec& rightsAndSlots);
+ void HandleBuyBankTab(WorldSession* session, uint8 tabId);
+ void HandleInviteMember(WorldSession* session, std::string const& name);
+ void HandleAcceptMember(WorldSession* session);
+ void HandleLeaveMember(WorldSession* session);
+ void HandleRemoveMember(WorldSession* session, std::string const& name);
+ void HandleUpdateMemberRank(WorldSession* session, std::string const& name, bool demote);
+ void HandleAddNewRank(WorldSession* session, std::string const& name);
+ void HandleRemoveRank(WorldSession* session, uint8 rankId);
+ void HandleRemoveLowestRank(WorldSession* session);
+ void HandleMemberDepositMoney(WorldSession* session, uint32 amount);
+ bool HandleMemberWithdrawMoney(WorldSession* session, uint32 amount, bool repair = false);
+ void HandleMemberLogout(WorldSession* session);
+ void HandleDisband(WorldSession* session);
+
+ void UpdateMemberData(Player* player, uint8 dataid, uint32 value);
+ void OnPlayerStatusChange(Player* player, uint32 flag, bool state);
+
+ // Send info to client
+ void SendInfo(WorldSession* session) const;
+ void SendEventLog(WorldSession* session) const;
+ void SendBankLog(WorldSession* session, uint8 tabId) const;
+ void SendBankTabsInfo(WorldSession* session, bool showTabs = false) const;
+ void SendBankTabData(WorldSession* session, uint8 tabId) const;
+ void SendBankTabText(WorldSession* session, uint8 tabId) const;
+ void SendPermissions(WorldSession* session) const;
+ void SendMoneyInfo(WorldSession* session) const;
+ void SendLoginInfo(WorldSession* session);
+
+ // Load from DB
+ bool LoadFromDB(Field* fields);
+ void LoadRankFromDB(Field* fields);
+ bool LoadMemberFromDB(Field* fields);
+ bool LoadEventLogFromDB(Field* fields);
+ void LoadBankRightFromDB(Field* fields);
+ void LoadBankTabFromDB(Field* fields);
+ bool LoadBankEventLogFromDB(Field* fields);
+ bool LoadBankItemFromDB(Field* fields);
+ bool Validate();
+
+ // Broadcasts
+ void BroadcastToGuild(WorldSession* session, bool officerOnly, std::string const& msg, uint32 language = LANG_UNIVERSAL) const;
+ void BroadcastPacketToRank(WorldPacket* packet, uint8 rankId) const;
+ void BroadcastPacket(WorldPacket* packet) const;
+
+ void MassInviteToEvent(WorldSession* session, uint32 minLevel, uint32 maxLevel, uint32 minRank);
+
+ template<class Do>
+ void BroadcastWorker(Do& _do, Player* except = nullptr)
{
- return tabId < GUILD_BANK_MAX_TABS ? m_bankTabRightsAndSlots[tabId].GetRights() : 0;
+ for (auto itr = m_members.begin(); itr != m_members.end(); ++itr)
+ if (Player* player = itr->second->FindConnectedPlayer())
+ if (player != except)
+ _do(player);
}
- inline int32 GetBankTabSlotsPerDay(uint8 tabId) const
- {
- return tabId < GUILD_BANK_MAX_TABS ? m_bankTabRightsAndSlots[tabId].GetSlots() : 0;
- }
+ // Members
+ // Adds member to guild. If rankId == GUILD_RANK_NONE, lowest rank is assigned.
+ bool AddMember(SQLTransaction& trans, ObjectGuid guid, uint8 rankId = GUILD_RANK_NONE);
+ void DeleteMember(SQLTransaction& trans, ObjectGuid guid, bool isDisbanding = false, bool isKicked = false, bool canDeleteGuild = false);
+ bool ChangeMemberRank(SQLTransaction& trans, ObjectGuid guid, uint8 newRank);
- void SetBankTabSlotsAndRights(GuildBankRightsAndSlots rightsAndSlots, bool saveToDB);
- void CreateMissingTabsIfNeeded(uint8 ranks, SQLTransaction& trans, bool logOnCreate = false);
+ // Bank
+ void SwapItems(Player* player, uint8 tabId, uint8 slotId, uint8 destTabId, uint8 destSlotId, uint32 splitedAmount);
+ void SwapItemsWithInventory(Player* player, bool toChar, uint8 tabId, uint8 slotId, uint8 playerBag, uint8 playerSlotId, uint32 splitedAmount);
- private:
- ObjectGuid::LowType m_guildId;
+ // Bank tabs
+ void SetBankTabText(uint8 tabId, std::string const& text);
- uint8 m_rankId;
+ void ResetTimes();
+
+ protected:
+ ObjectGuid::LowType m_id;
std::string m_name;
- uint32 m_rights;
- uint32 m_bankMoneyPerDay;
- GuildBankRightsAndSlots m_bankTabRightsAndSlots[GUILD_BANK_MAX_TABS];
- };
+ ObjectGuid m_leaderGuid;
+ std::string m_motd;
+ std::string m_info;
+ time_t m_createdDate;
- class BankTab
- {
- public:
- BankTab(ObjectGuid::LowType guildId, uint8 tabId) : m_guildId(guildId), m_tabId(tabId)
- {
- memset(m_items, 0, GUILD_BANK_MAX_SLOTS * sizeof(Item*));
- }
+ EmblemInfo m_emblemInfo;
+ uint32 m_accountsNumber;
+ uint64 m_bankMoney;
- void LoadFromDB(Field* fields);
- bool LoadItemFromDB(Field* fields);
- void Delete(SQLTransaction& trans, bool removeItemsFromDB = false);
+ Ranks m_ranks;
+ Members m_members;
+ BankTabs m_bankTabs;
- void WritePacket(WorldPacket& data) const;
- bool WriteSlotPacket(WorldPacket& data, uint8 slotId, bool ignoreEmpty = true) const;
- void WriteInfoPacket(WorldPacket& data) const
+ // These are actually ordered lists. The first element is the oldest entry.
+ LogHolder* m_eventLog;
+ LogHolder* m_bankEventLog[GUILD_BANK_MAX_TABS + 1];
+
+ private:
+ inline uint8 _GetRanksSize() const { return uint8(m_ranks.size()); }
+ inline RankInfo const* GetRankInfo(uint8 rankId) const { return rankId < _GetRanksSize() ? &m_ranks[rankId] : nullptr; }
+ inline RankInfo* GetRankInfo(uint8 rankId) { return rankId < _GetRanksSize() ? &m_ranks[rankId] : nullptr; }
+ inline bool _HasRankRight(Player* player, uint32 right) const
{
- data << m_name;
- data << m_icon;
+ if (player)
+ if (Member const* member = GetMember(player->GetGUID()))
+ return (_GetRankRights(member->GetRankId()) & right) != GR_RIGHT_EMPTY;
+ return false;
}
- void SetInfo(std::string const& name, std::string const& icon);
- void SetText(std::string const& text);
- void SendText(const Guild* guild, WorldSession* session) const;
+ inline uint8 _GetLowestRankId() const { return uint8(m_ranks.size() - 1); }
- inline Item* GetItem(uint8 slotId) const { return slotId < GUILD_BANK_MAX_SLOTS ? m_items[slotId] : NULL; }
- bool SetItem(SQLTransaction& trans, uint8 slotId, Item* pItem);
+ inline uint8 _GetPurchasedTabsSize() const { return uint8(m_bankTabs.size()); }
+ inline BankTab* GetBankTab(uint8 tabId) { return tabId < m_bankTabs.size() ? m_bankTabs[tabId] : nullptr; }
+ inline BankTab const* GetBankTab(uint8 tabId) const { return tabId < m_bankTabs.size() ? m_bankTabs[tabId] : nullptr; }
- private:
- ObjectGuid::LowType m_guildId;
- uint8 m_tabId;
-
- Item* m_items[GUILD_BANK_MAX_SLOTS];
- std::string m_name;
- std::string m_icon;
- std::string m_text;
- };
+ inline Member const* GetMember(ObjectGuid guid) const
+ {
+ auto itr = m_members.find(guid.GetCounter());
+ return itr != m_members.end() ? itr->second : nullptr;
+ }
- // Movement data
- class MoveItemData
- {
- public:
- MoveItemData(Guild* guild, Player* player, uint8 container, uint8 slotId) : m_pGuild(guild), m_pPlayer(player),
- m_container(container), m_slotId(slotId), m_pItem(NULL), m_pClonedItem(NULL) { }
- virtual ~MoveItemData() { }
-
- virtual bool IsBank() const = 0;
- // Initializes item pointer. Returns true, if item exists, false otherwise.
- virtual bool InitItem() = 0;
- // Checks splited amount against item. Splited amount cannot be more that number of items in stack.
- virtual bool CheckItem(uint32& splitedAmount);
- // Defines if player has rights to save item in container
- virtual bool HasStoreRights(MoveItemData* /*pOther*/) const { return true; }
- // Defines if player has rights to withdraw item from container
- virtual bool HasWithdrawRights(MoveItemData* /*pOther*/) const { return true; }
- // Checks if container can store specified item
- bool CanStore(Item* pItem, bool swap, bool sendError);
- // Clones stored item
- bool CloneItem(uint32 count);
- // Remove item from container (if splited update items fields)
- virtual void RemoveItem(SQLTransaction& trans, MoveItemData* pOther, uint32 splitedAmount = 0) = 0;
- // Saves item to container
- virtual Item* StoreItem(SQLTransaction& trans, Item* pItem) = 0;
- // Log bank event
- virtual void LogBankEvent(SQLTransaction& trans, MoveItemData* pFrom, uint32 count) const = 0;
- // Log GM action
- virtual void LogAction(MoveItemData* pFrom) const;
- // Copy slots id from position vector
- void CopySlots(SlotIds& ids) const;
-
- Item* GetItem(bool isCloned = false) const { return isCloned ? m_pClonedItem : m_pItem; }
- uint8 GetContainer() const { return m_container; }
- uint8 GetSlotId() const { return m_slotId; }
+ inline Member* GetMember(ObjectGuid guid)
+ {
+ auto itr = m_members.find(guid.GetCounter());
+ return itr != m_members.end() ? itr->second : nullptr;
+ }
- protected:
- virtual InventoryResult CanStore(Item* pItem, bool swap) = 0;
-
- Guild* m_pGuild;
- Player* m_pPlayer;
- uint8 m_container;
- uint8 m_slotId;
- Item* m_pItem;
- Item* m_pClonedItem;
- ItemPosCountVec m_vec;
- };
-
- class PlayerMoveItemData : public MoveItemData
- {
- public:
- PlayerMoveItemData(Guild* guild, Player* player, uint8 container, uint8 slotId) :
- MoveItemData(guild, player, container, slotId) { }
-
- bool IsBank() const override { return false; }
- bool InitItem() override;
- void RemoveItem(SQLTransaction& trans, MoveItemData* pOther, uint32 splitedAmount = 0) override;
- Item* StoreItem(SQLTransaction& trans, Item* pItem) override;
- void LogBankEvent(SQLTransaction& trans, MoveItemData* pFrom, uint32 count) const override;
- protected:
- InventoryResult CanStore(Item* pItem, bool swap) override;
- };
+ inline Member* GetMember(std::string const& name)
+ {
+ for (auto itr = m_members.begin(); itr != m_members.end(); ++itr)
+ if (itr->second->GetName() == name)
+ return itr->second;
- class BankMoveItemData : public MoveItemData
- {
- public:
- BankMoveItemData(Guild* guild, Player* player, uint8 container, uint8 slotId) :
- MoveItemData(guild, player, container, slotId) { }
-
- bool IsBank() const override { return true; }
- bool InitItem() override;
- bool HasStoreRights(MoveItemData* pOther) const override;
- bool HasWithdrawRights(MoveItemData* pOther) const override;
- void RemoveItem(SQLTransaction& trans, MoveItemData* pOther, uint32 splitedAmount) override;
- Item* StoreItem(SQLTransaction& trans, Item* pItem) override;
- void LogBankEvent(SQLTransaction& trans, MoveItemData* pFrom, uint32 count) const override;
- void LogAction(MoveItemData* pFrom) const override;
+ return nullptr;
+ }
- protected:
- InventoryResult CanStore(Item* pItem, bool swap) override;
+ inline void _DeleteMemberFromDB(SQLTransaction& trans, ObjectGuid::LowType lowguid) const
+ {
+ PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_MEMBER);
+ stmt->setUInt32(0, lowguid);
+ CharacterDatabase.ExecuteOrAppend(trans, stmt);
+ }
- private:
- Item* _StoreItem(SQLTransaction& trans, BankTab* pTab, Item* pItem, ItemPosCount& pos, bool clone) const;
- bool _ReserveSpace(uint8 slotId, Item* pItem, Item* pItemDest, uint32& count);
- void CanStoreItemInTab(Item* pItem, uint8 skipSlotId, bool merge, uint32& count);
- };
-
- typedef std::unordered_map<uint32, Member*> Members;
- typedef std::vector<RankInfo> Ranks;
- typedef std::vector<BankTab*> BankTabs;
-
-public:
- static void SendCommandResult(WorldSession* session, GuildCommandType type, GuildCommandError errCode, std::string const& param = "");
- static void SendSaveEmblemResult(WorldSession* session, GuildEmblemError errCode);
-
- Guild();
- ~Guild();
-
- bool Create(Player* pLeader, std::string const& name);
- void Disband();
-
- // Getters
- ObjectGuid::LowType GetId() const { return m_id; }
- ObjectGuid GetLeaderGUID() const { return m_leaderGuid; }
- std::string const& GetName() const { return m_name; }
- std::string const& GetMOTD() const { return m_motd; }
- std::string const& GetInfo() const { return m_info; }
- uint32 GetMemberCount() const { return m_members.size(); }
- time_t GetCreatedDate() const { return m_createdDate; }
- uint64 GetBankMoney() const { return m_bankMoney; }
-
- bool SetName(std::string const& name);
-
- // Handle client commands
- void HandleRoster(WorldSession* session);
- void HandleQuery(WorldSession* session);
- void HandleSetMOTD(WorldSession* session, std::string const& motd);
- void HandleSetInfo(WorldSession* session, std::string const& info);
- void HandleSetEmblem(WorldSession* session, const EmblemInfo& emblemInfo);
- void HandleSetLeader(WorldSession* session, std::string const& name);
- void HandleSetBankTabInfo(WorldSession* session, uint8 tabId, std::string const& name, std::string const& icon);
- void HandleSetMemberNote(WorldSession* session, std::string const& name, std::string const& note, bool officer);
- void HandleSetRankInfo(WorldSession* session, uint8 rankId, std::string const& name, uint32 rights, uint32 moneyPerDay, const GuildBankRightsAndSlotsVec& rightsAndSlots);
- void HandleBuyBankTab(WorldSession* session, uint8 tabId);
- void HandleInviteMember(WorldSession* session, std::string const& name);
- void HandleAcceptMember(WorldSession* session);
- void HandleLeaveMember(WorldSession* session);
- void HandleRemoveMember(WorldSession* session, std::string const& name);
- void HandleUpdateMemberRank(WorldSession* session, std::string const& name, bool demote);
- void HandleAddNewRank(WorldSession* session, std::string const& name);
- void HandleRemoveRank(WorldSession* session, uint8 rankId);
- void HandleRemoveLowestRank(WorldSession* session);
- void HandleMemberDepositMoney(WorldSession* session, uint32 amount);
- bool HandleMemberWithdrawMoney(WorldSession* session, uint32 amount, bool repair = false);
- void HandleMemberLogout(WorldSession* session);
- void HandleDisband(WorldSession* session);
-
- void UpdateMemberData(Player* player, uint8 dataid, uint32 value);
- void OnPlayerStatusChange(Player* player, uint32 flag, bool state);
-
- // Send info to client
- void SendInfo(WorldSession* session) const;
- void SendEventLog(WorldSession* session) const;
- void SendBankLog(WorldSession* session, uint8 tabId) const;
- void SendBankTabsInfo(WorldSession* session, bool showTabs = false) const;
- void SendBankTabData(WorldSession* session, uint8 tabId) const;
- void SendBankTabText(WorldSession* session, uint8 tabId) const;
- void SendPermissions(WorldSession* session) const;
- void SendMoneyInfo(WorldSession* session) const;
- void SendLoginInfo(WorldSession* session);
-
- // Load from DB
- bool LoadFromDB(Field* fields);
- void LoadRankFromDB(Field* fields);
- bool LoadMemberFromDB(Field* fields);
- bool LoadEventLogFromDB(Field* fields);
- void LoadBankRightFromDB(Field* fields);
- void LoadBankTabFromDB(Field* fields);
- bool LoadBankEventLogFromDB(Field* fields);
- bool LoadBankItemFromDB(Field* fields);
- bool Validate();
-
- // Broadcasts
- void BroadcastToGuild(WorldSession* session, bool officerOnly, std::string const& msg, uint32 language = LANG_UNIVERSAL) const;
- void BroadcastPacketToRank(WorldPacket* packet, uint8 rankId) const;
- void BroadcastPacket(WorldPacket* packet) const;
-
- void MassInviteToEvent(WorldSession* session, uint32 minLevel, uint32 maxLevel, uint32 minRank);
-
- template<class Do>
- void BroadcastWorker(Do& _do, Player* except = NULL)
- {
- for (Members::iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
- if (Player* player = itr->second->FindConnectedPlayer())
- if (player != except)
- _do(player);
- }
-
- // Members
- // Adds member to guild. If rankId == GUILD_RANK_NONE, lowest rank is assigned.
- bool AddMember(ObjectGuid guid, uint8 rankId = GUILD_RANK_NONE);
- void DeleteMember(ObjectGuid guid, bool isDisbanding = false, bool isKicked = false, bool canDeleteGuild = false);
- bool ChangeMemberRank(ObjectGuid guid, uint8 newRank);
-
- // Bank
- void SwapItems(Player* player, uint8 tabId, uint8 slotId, uint8 destTabId, uint8 destSlotId, uint32 splitedAmount);
- void SwapItemsWithInventory(Player* player, bool toChar, uint8 tabId, uint8 slotId, uint8 playerBag, uint8 playerSlotId, uint32 splitedAmount);
-
- // Bank tabs
- void SetBankTabText(uint8 tabId, std::string const& text);
-
- void ResetTimes();
-
-protected:
- ObjectGuid::LowType m_id;
- std::string m_name;
- ObjectGuid m_leaderGuid;
- std::string m_motd;
- std::string m_info;
- time_t m_createdDate;
-
- EmblemInfo m_emblemInfo;
- uint32 m_accountsNumber;
- uint64 m_bankMoney;
-
- Ranks m_ranks;
- Members m_members;
- BankTabs m_bankTabs;
-
- // These are actually ordered lists. The first element is the oldest entry.
- LogHolder* m_eventLog;
- LogHolder* m_bankEventLog[GUILD_BANK_MAX_TABS + 1];
-
-private:
- inline uint8 _GetRanksSize() const { return uint8(m_ranks.size()); }
- inline const RankInfo* GetRankInfo(uint8 rankId) const { return rankId < _GetRanksSize() ? &m_ranks[rankId] : NULL; }
- inline RankInfo* GetRankInfo(uint8 rankId) { return rankId < _GetRanksSize() ? &m_ranks[rankId] : NULL; }
- inline bool _HasRankRight(Player* player, uint32 right) const
- {
- if (player)
- if (Member const* member = GetMember(player->GetGUID()))
- return (_GetRankRights(member->GetRankId()) & right) != GR_RIGHT_EMPTY;
- return false;
- }
-
- inline uint8 _GetLowestRankId() const { return uint8(m_ranks.size() - 1); }
-
- inline uint8 _GetPurchasedTabsSize() const { return uint8(m_bankTabs.size()); }
- inline BankTab* GetBankTab(uint8 tabId) { return tabId < m_bankTabs.size() ? m_bankTabs[tabId] : NULL; }
- inline const BankTab* GetBankTab(uint8 tabId) const { return tabId < m_bankTabs.size() ? m_bankTabs[tabId] : NULL; }
-
- inline const Member* GetMember(ObjectGuid guid) const
- {
- Members::const_iterator itr = m_members.find(guid.GetCounter());
- return itr != m_members.end() ? itr->second : NULL;
- }
-
- inline Member* GetMember(ObjectGuid guid)
- {
- Members::iterator itr = m_members.find(guid.GetCounter());
- return itr != m_members.end() ? itr->second : NULL;
- }
-
- inline Member* GetMember(std::string const& name)
- {
- for (Members::iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
- if (itr->second->GetName() == name)
- return itr->second;
-
- return NULL;
- }
-
- inline void _DeleteMemberFromDB(ObjectGuid::LowType lowguid) const
- {
- PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_MEMBER);
- stmt->setUInt32(0, lowguid);
- CharacterDatabase.Execute(stmt);
- }
-
- // Creates log holders (either when loading or when creating guild)
- void _CreateLogHolders();
- // Tries to create new bank tab
- void _CreateNewBankTab();
- // Creates default guild ranks with names in given locale
- void _CreateDefaultGuildRanks(LocaleConstant loc);
- // Creates new rank
- bool _CreateRank(std::string const& name, uint32 rights);
- // Update account number when member added/removed from guild
- void _UpdateAccountsNumber();
- bool _IsLeader(Player* player) const;
- void _DeleteBankItems(SQLTransaction& trans, bool removeItemsFromDB = false);
- bool _ModifyBankMoney(SQLTransaction& trans, uint64 amount, bool add);
- void _SetLeaderGUID(Member* pLeader);
-
- void _SetRankBankMoneyPerDay(uint8 rankId, uint32 moneyPerDay);
- void _SetRankBankTabRightsAndSlots(uint8 rankId, GuildBankRightsAndSlots rightsAndSlots, bool saveToDB = true);
- int8 _GetRankBankTabRights(uint8 rankId, uint8 tabId) const;
- uint32 _GetRankRights(uint8 rankId) const;
- int32 _GetRankBankMoneyPerDay(uint8 rankId) const;
- int32 _GetRankBankTabSlotsPerDay(uint8 rankId, uint8 tabId) const;
- std::string _GetRankName(uint8 rankId) const;
-
- int32 _GetMemberRemainingSlots(Member const* member, uint8 tabId) const;
- int32 _GetMemberRemainingMoney(Member const* member) const;
- void _UpdateMemberWithdrawSlots(SQLTransaction& trans, ObjectGuid guid, uint8 tabId);
- bool _MemberHasTabRights(ObjectGuid guid, uint8 tabId, uint32 rights) const;
-
- void _LogEvent(GuildEventLogTypes eventType, ObjectGuid::LowType playerGuid1, ObjectGuid::LowType playerGuid2 = 0, uint8 newRank = 0);
- void _LogBankEvent(SQLTransaction& trans, GuildBankEventLogTypes eventType, uint8 tabId, ObjectGuid::LowType playerGuid, uint32 itemOrMoney, uint16 itemStackCount = 0, uint8 destTabId = 0);
-
- Item* _GetItem(uint8 tabId, uint8 slotId) const;
- void _RemoveItem(SQLTransaction& trans, uint8 tabId, uint8 slotId);
- void _MoveItems(MoveItemData* pSrc, MoveItemData* pDest, uint32 splitedAmount);
- bool _DoItemsMove(MoveItemData* pSrc, MoveItemData* pDest, bool sendError, uint32 splitedAmount = 0);
-
- void _SendBankContent(WorldSession* session, uint8 tabId) const;
- void _SendBankMoneyUpdate(WorldSession* session) const;
- void _SendBankContentUpdate(MoveItemData* pSrc, MoveItemData* pDest) const;
- void _SendBankContentUpdate(uint8 tabId, SlotIds slots) const;
- void _SendBankList(WorldSession* session = NULL, uint8 tabId = 0, bool sendFullSlots = false, SlotIds *slots = NULL) const;
-
- void _BroadcastEvent(GuildEvents guildEvent, ObjectGuid guid, const char* param1 = NULL, const char* param2 = NULL, const char* param3 = NULL) const;
+ // Creates log holders (either when loading or when creating guild)
+ void _CreateLogHolders();
+ // Tries to create new bank tab
+ void _CreateNewBankTab();
+ // Creates default guild ranks with names in given locale
+ void _CreateDefaultGuildRanks(SQLTransaction& trans, LocaleConstant loc);
+ // Creates new rank
+ bool _CreateRank(SQLTransaction& trans, std::string const& name, uint32 rights);
+ // Update account number when member added/removed from guild
+ void _UpdateAccountsNumber();
+ bool _IsLeader(Player* player) const;
+ void _DeleteBankItems(SQLTransaction& trans, bool removeItemsFromDB = false);
+ bool _ModifyBankMoney(SQLTransaction& trans, uint64 amount, bool add);
+ void _SetLeaderGUID(Member* pLeader);
+
+ void _SetRankBankMoneyPerDay(uint8 rankId, uint32 moneyPerDay);
+ void _SetRankBankTabRightsAndSlots(uint8 rankId, GuildBankRightsAndSlots rightsAndSlots, bool saveToDB = true);
+ int8 _GetRankBankTabRights(uint8 rankId, uint8 tabId) const;
+ uint32 _GetRankRights(uint8 rankId) const;
+ int32 _GetRankBankMoneyPerDay(uint8 rankId) const;
+ int32 _GetRankBankTabSlotsPerDay(uint8 rankId, uint8 tabId) const;
+ std::string _GetRankName(uint8 rankId) const;
+
+ int32 _GetMemberRemainingSlots(Member const* member, uint8 tabId) const;
+ int32 _GetMemberRemainingMoney(Member const* member) const;
+ void _UpdateMemberWithdrawSlots(SQLTransaction& trans, ObjectGuid guid, uint8 tabId);
+ bool _MemberHasTabRights(ObjectGuid guid, uint8 tabId, uint32 rights) const;
+
+ void _LogEvent(GuildEventLogTypes eventType, ObjectGuid::LowType playerGuid1, ObjectGuid::LowType playerGuid2 = 0, uint8 newRank = 0);
+ void _LogBankEvent(SQLTransaction& trans, GuildBankEventLogTypes eventType, uint8 tabId, ObjectGuid::LowType playerGuid, uint32 itemOrMoney, uint16 itemStackCount = 0, uint8 destTabId = 0);
+
+ Item* _GetItem(uint8 tabId, uint8 slotId) const;
+ void _RemoveItem(SQLTransaction& trans, uint8 tabId, uint8 slotId);
+ void _MoveItems(MoveItemData* pSrc, MoveItemData* pDest, uint32 splitedAmount);
+ bool _DoItemsMove(MoveItemData* pSrc, MoveItemData* pDest, bool sendError, uint32 splitedAmount = 0);
+
+ void _SendBankContent(WorldSession* session, uint8 tabId) const;
+ void _SendBankMoneyUpdate(WorldSession* session) const;
+ void _SendBankContentUpdate(MoveItemData* pSrc, MoveItemData* pDest) const;
+ void _SendBankContentUpdate(uint8 tabId, SlotIds slots) const;
+ void _SendBankList(WorldSession* session = NULL, uint8 tabId = 0, bool sendFullSlots = false, SlotIds *slots = NULL) const;
+
+ void _BroadcastEvent(GuildEvents guildEvent, ObjectGuid guid, const char* param1 = NULL, const char* param2 = NULL, const char* param3 = NULL) const;
};
#endif
diff --git a/src/server/game/Handlers/AuctionHouseHandler.cpp b/src/server/game/Handlers/AuctionHouseHandler.cpp
index 71242d57f33..2c5eddcefdc 100644
--- a/src/server/game/Handlers/AuctionHouseHandler.cpp
+++ b/src/server/game/Handlers/AuctionHouseHandler.cpp
@@ -202,7 +202,7 @@ void WorldSession::HandleAuctionSellItem(WorldPacket& recvData)
itemEntry = item->GetTemplate()->ItemId;
if (sAuctionMgr->GetAItem(item->GetGUID().GetCounter()) || !item->CanBeTraded() || item->IsNotEmptyBag() ||
- item->GetTemplate()->Flags & ITEM_PROTO_FLAG_CONJURED || item->GetUInt32Value(ITEM_FIELD_DURATION) ||
+ (item->GetTemplate()->Flags & ITEM_FLAG_CONJURED) || item->GetUInt32Value(ITEM_FIELD_DURATION) ||
item->GetCount() < count[i] || itemEntry != item->GetTemplate()->ItemId)
{
SendAuctionCommandResult(0, AUCTION_SELL_ITEM, ERR_AUCTION_DATABASE_ERROR);
diff --git a/src/server/game/Handlers/ChannelHandler.cpp b/src/server/game/Handlers/ChannelHandler.cpp
index 9285f4247b2..71cdddcebf5 100644
--- a/src/server/game/Handlers/ChannelHandler.cpp
+++ b/src/server/game/Handlers/ChannelHandler.cpp
@@ -17,11 +17,15 @@
*/
#include "ObjectMgr.h" // for normalizePlayerName
+#include "Channel.h"
#include "ChannelMgr.h"
#include "Player.h"
+#include "WorldSession.h"
#include <cctype>
+static size_t const MAX_CHANNEL_PASS_STR = 31;
+
void WorldSession::HandleJoinChannel(WorldPacket& recvPacket)
{
uint32 channelId;
@@ -33,13 +37,13 @@ void WorldSession::HandleJoinChannel(WorldPacket& recvPacket)
TC_LOG_DEBUG("chat.system", "CMSG_JOIN_CHANNEL %s Channel: %u, unk1: %u, unk2: %u, channel: %s, password: %s",
GetPlayerInfo().c_str(), channelId, unknown1, unknown2, channelName.c_str(), password.c_str());
+ AreaTableEntry const* zone = sAreaTableStore.LookupEntry(GetPlayer()->GetZoneId());
if (channelId)
{
ChatChannelsEntry const* channel = sChatChannelsStore.LookupEntry(channelId);
if (!channel)
return;
- AreaTableEntry const* zone = sAreaTableStore.LookupEntry(GetPlayer()->GetZoneId());
if (!zone || !GetPlayer()->CanJoinConstantChannelInZone(channel, zone))
return;
}
@@ -51,30 +55,42 @@ void WorldSession::HandleJoinChannel(WorldPacket& recvPacket)
return;
if (ChannelMgr* cMgr = ChannelMgr::forTeam(GetPlayer()->GetTeam()))
- {
- cMgr->setTeam(GetPlayer()->GetTeam());
- if (Channel* channel = cMgr->GetJoinChannel(channelName, channelId))
+ if (Channel* channel = cMgr->GetJoinChannel(channelId, channelName, zone))
channel->JoinChannel(GetPlayer(), password);
- }
}
void WorldSession::HandleLeaveChannel(WorldPacket& recvPacket)
{
- uint32 unk;
+ uint32 channelId;
std::string channelName;
- recvPacket >> unk >> channelName;
+ recvPacket >> channelId >> channelName;
- TC_LOG_DEBUG("chat.system", "CMSG_LEAVE_CHANNEL %s Channel: %s, unk1: %u",
- GetPlayerInfo().c_str(), channelName.c_str(), unk);
+ TC_LOG_DEBUG("chat.system", "CMSG_LEAVE_CHANNEL %s Channel: %s, channelId: %u",
+ GetPlayerInfo().c_str(), channelName.c_str(), channelId);
- if (channelName.empty())
+ if (channelName.empty() && !channelId)
return;
+ AreaTableEntry const* zone = sAreaTableStore.LookupEntry(GetPlayer()->GetZoneId());
+ if (channelId)
+ {
+ ChatChannelsEntry const* channel = sChatChannelsStore.LookupEntry(channelId);
+ if (!channel)
+ return;
+
+ if (!zone || !GetPlayer()->CanJoinConstantChannelInZone(channel, zone))
+ return;
+ }
+
if (ChannelMgr* cMgr = ChannelMgr::forTeam(GetPlayer()->GetTeam()))
{
- if (Channel* channel = cMgr->GetChannel(channelName, GetPlayer()))
+ if (Channel* channel = cMgr->GetChannel(channelId, channelName, GetPlayer(), true, zone))
channel->LeaveChannel(GetPlayer(), true);
- cMgr->LeftChannel(channelName);
+
+ if (channelId)
+ cMgr->LeftChannel(channelId, zone);
+ else
+ cMgr->LeftChannel(channelName);
}
}
@@ -87,9 +103,8 @@ void WorldSession::HandleChannelList(WorldPacket& recvPacket)
recvPacket.GetOpcode() == CMSG_CHANNEL_DISPLAY_LIST ? "CMSG_CHANNEL_DISPLAY_LIST" : "CMSG_CHANNEL_LIST",
GetPlayerInfo().c_str(), channelName.c_str());
- if (ChannelMgr* cMgr = ChannelMgr::forTeam(GetPlayer()->GetTeam()))
- if (Channel* channel = cMgr->GetChannel(channelName, GetPlayer()))
- channel->List(GetPlayer());
+ if (Channel* channel = ChannelMgr::GetChannelForPlayerByNamePart(channelName, GetPlayer()))
+ channel->List(GetPlayer());
}
void WorldSession::HandleChannelPassword(WorldPacket& recvPacket)
@@ -103,9 +118,8 @@ void WorldSession::HandleChannelPassword(WorldPacket& recvPacket)
if (password.length() > MAX_CHANNEL_PASS_STR)
return;
- if (ChannelMgr* cMgr = ChannelMgr::forTeam(GetPlayer()->GetTeam()))
- if (Channel* channel = cMgr->GetChannel(channelName, GetPlayer()))
- channel->Password(GetPlayer(), password);
+ if (Channel* channel = ChannelMgr::GetChannelForPlayerByNamePart(channelName, GetPlayer()))
+ channel->Password(GetPlayer(), password);
}
void WorldSession::HandleChannelSetOwner(WorldPacket& recvPacket)
@@ -119,9 +133,8 @@ void WorldSession::HandleChannelSetOwner(WorldPacket& recvPacket)
if (!normalizePlayerName(targetName))
return;
- if (ChannelMgr* cMgr = ChannelMgr::forTeam(GetPlayer()->GetTeam()))
- if (Channel* channel = cMgr->GetChannel(channelName, GetPlayer()))
- channel->SetOwner(GetPlayer(), targetName);
+ if (Channel* channel = ChannelMgr::GetChannelForPlayerByNamePart(channelName, GetPlayer()))
+ channel->SetOwner(GetPlayer(), targetName);
}
void WorldSession::HandleChannelOwner(WorldPacket& recvPacket)
@@ -132,9 +145,8 @@ void WorldSession::HandleChannelOwner(WorldPacket& recvPacket)
TC_LOG_DEBUG("chat.system", "CMSG_CHANNEL_OWNER %s Channel: %s",
GetPlayerInfo().c_str(), channelName.c_str());
- if (ChannelMgr* cMgr = ChannelMgr::forTeam(GetPlayer()->GetTeam()))
- if (Channel* channel = cMgr->GetChannel(channelName, GetPlayer()))
- channel->SendWhoOwner(GetPlayer()->GetGUID());
+ if (Channel* channel = ChannelMgr::GetChannelForPlayerByNamePart(channelName, GetPlayer()))
+ channel->SendWhoOwner(GetPlayer()->GetGUID());
}
void WorldSession::HandleChannelModerator(WorldPacket& recvPacket)
@@ -148,9 +160,8 @@ void WorldSession::HandleChannelModerator(WorldPacket& recvPacket)
if (!normalizePlayerName(targetName))
return;
- if (ChannelMgr* cMgr = ChannelMgr::forTeam(GetPlayer()->GetTeam()))
- if (Channel* channel = cMgr->GetChannel(channelName, GetPlayer()))
- channel->SetModerator(GetPlayer(), targetName);
+ if (Channel* channel = ChannelMgr::GetChannelForPlayerByNamePart(channelName, GetPlayer()))
+ channel->SetModerator(GetPlayer(), targetName);
}
void WorldSession::HandleChannelUnmoderator(WorldPacket& recvPacket)
@@ -164,9 +175,8 @@ void WorldSession::HandleChannelUnmoderator(WorldPacket& recvPacket)
if (!normalizePlayerName(targetName))
return;
- if (ChannelMgr* cMgr = ChannelMgr::forTeam(GetPlayer()->GetTeam()))
- if (Channel* channel = cMgr->GetChannel(channelName, GetPlayer()))
- channel->UnsetModerator(GetPlayer(), targetName);
+ if (Channel* channel = ChannelMgr::GetChannelForPlayerByNamePart(channelName, GetPlayer()))
+ channel->UnsetModerator(GetPlayer(), targetName);
}
void WorldSession::HandleChannelMute(WorldPacket& recvPacket)
@@ -180,9 +190,8 @@ void WorldSession::HandleChannelMute(WorldPacket& recvPacket)
if (!normalizePlayerName(targetName))
return;
- if (ChannelMgr* cMgr = ChannelMgr::forTeam(GetPlayer()->GetTeam()))
- if (Channel* channel = cMgr->GetChannel(channelName, GetPlayer()))
- channel->SetMute(GetPlayer(), targetName);
+ if (Channel* channel = ChannelMgr::GetChannelForPlayerByNamePart(channelName, GetPlayer()))
+ channel->SetMute(GetPlayer(), targetName);
}
void WorldSession::HandleChannelUnmute(WorldPacket& recvPacket)
@@ -196,9 +205,8 @@ void WorldSession::HandleChannelUnmute(WorldPacket& recvPacket)
if (!normalizePlayerName(targetName))
return;
- if (ChannelMgr* cMgr = ChannelMgr::forTeam(GetPlayer()->GetTeam()))
- if (Channel* channel = cMgr->GetChannel(channelName, GetPlayer()))
- channel->UnsetMute(GetPlayer(), targetName);
+ if (Channel* channel = ChannelMgr::GetChannelForPlayerByNamePart(channelName, GetPlayer()))
+ channel->UnsetMute(GetPlayer(), targetName);
}
void WorldSession::HandleChannelInvite(WorldPacket& recvPacket)
@@ -212,9 +220,8 @@ void WorldSession::HandleChannelInvite(WorldPacket& recvPacket)
if (!normalizePlayerName(targetName))
return;
- if (ChannelMgr* cMgr = ChannelMgr::forTeam(GetPlayer()->GetTeam()))
- if (Channel* channel = cMgr->GetChannel(channelName, GetPlayer()))
- channel->Invite(GetPlayer(), targetName);
+ if (Channel* channel = ChannelMgr::GetChannelForPlayerByNamePart(channelName, GetPlayer()))
+ channel->Invite(GetPlayer(), targetName);
}
void WorldSession::HandleChannelKick(WorldPacket& recvPacket)
@@ -228,9 +235,8 @@ void WorldSession::HandleChannelKick(WorldPacket& recvPacket)
if (!normalizePlayerName(targetName))
return;
- if (ChannelMgr* cMgr = ChannelMgr::forTeam(GetPlayer()->GetTeam()))
- if (Channel* channel = cMgr->GetChannel(channelName, GetPlayer()))
- channel->Kick(GetPlayer(), targetName);
+ if (Channel* channel = ChannelMgr::GetChannelForPlayerByNamePart(channelName, GetPlayer()))
+ channel->Kick(GetPlayer(), targetName);
}
void WorldSession::HandleChannelBan(WorldPacket& recvPacket)
@@ -244,9 +250,8 @@ void WorldSession::HandleChannelBan(WorldPacket& recvPacket)
if (!normalizePlayerName(targetName))
return;
- if (ChannelMgr* cMgr = ChannelMgr::forTeam(GetPlayer()->GetTeam()))
- if (Channel* channel = cMgr->GetChannel(channelName, GetPlayer()))
- channel->Ban(GetPlayer(), targetName);
+ if (Channel* channel = ChannelMgr::GetChannelForPlayerByNamePart(channelName, GetPlayer()))
+ channel->Ban(GetPlayer(), targetName);
}
void WorldSession::HandleChannelUnban(WorldPacket& recvPacket)
@@ -260,9 +265,8 @@ void WorldSession::HandleChannelUnban(WorldPacket& recvPacket)
if (!normalizePlayerName(targetName))
return;
- if (ChannelMgr* cMgr = ChannelMgr::forTeam(GetPlayer()->GetTeam()))
- if (Channel* channel = cMgr->GetChannel(channelName, GetPlayer()))
- channel->UnBan(GetPlayer(), targetName);
+ if (Channel* channel = ChannelMgr::GetChannelForPlayerByNamePart(channelName, GetPlayer()))
+ channel->UnBan(GetPlayer(), targetName);
}
void WorldSession::HandleChannelAnnouncements(WorldPacket& recvPacket)
@@ -273,9 +277,8 @@ void WorldSession::HandleChannelAnnouncements(WorldPacket& recvPacket)
TC_LOG_DEBUG("chat.system", "CMSG_CHANNEL_ANNOUNCEMENTS %s Channel: %s",
GetPlayerInfo().c_str(), channelName.c_str());
- if (ChannelMgr* cMgr = ChannelMgr::forTeam(GetPlayer()->GetTeam()))
- if (Channel* channel = cMgr->GetChannel(channelName, GetPlayer()))
- channel->Announce(GetPlayer());
+ if (Channel* channel = ChannelMgr::GetChannelForPlayerByNamePart(channelName, GetPlayer()))
+ channel->Announce(GetPlayer());
}
void WorldSession::HandleChannelDisplayListQuery(WorldPacket &recvPacket)
@@ -292,19 +295,17 @@ void WorldSession::HandleGetChannelMemberCount(WorldPacket &recvPacket)
TC_LOG_DEBUG("chat.system", "CMSG_GET_CHANNEL_MEMBER_COUNT %s Channel: %s",
GetPlayerInfo().c_str(), channelName.c_str());
- if (ChannelMgr* cMgr = ChannelMgr::forTeam(GetPlayer()->GetTeam()))
+ if (Channel* channel = ChannelMgr::GetChannelForPlayerByNamePart(channelName, GetPlayer()))
{
- if (Channel* channel = cMgr->GetChannel(channelName, GetPlayer()))
- {
- TC_LOG_DEBUG("chat.system", "SMSG_CHANNEL_MEMBER_COUNT %s Channel: %s Count: %u",
- GetPlayerInfo().c_str(), channelName.c_str(), channel->GetNumPlayers());
-
- WorldPacket data(SMSG_CHANNEL_MEMBER_COUNT, channel->GetName().size() + 1 + 4);
- data << channel->GetName();
- data << uint8(channel->GetFlags());
- data << uint32(channel->GetNumPlayers());
- SendPacket(&data);
- }
+ TC_LOG_DEBUG("chat.system", "SMSG_CHANNEL_MEMBER_COUNT %s Channel: %s Count: %u",
+ GetPlayerInfo().c_str(), channelName.c_str(), channel->GetNumPlayers());
+
+ std::string name = channel->GetName(GetSessionDbcLocale());
+ WorldPacket data(SMSG_CHANNEL_MEMBER_COUNT, name.size() + 1 + 4);
+ data << name;
+ data << uint8(channel->GetFlags());
+ data << uint32(channel->GetNumPlayers());
+ SendPacket(&data);
}
}
@@ -317,8 +318,7 @@ void WorldSession::HandleSetChannelWatch(WorldPacket &recvPacket)
GetPlayerInfo().c_str(), channelName.c_str());
/*
- if (ChannelMgr* cMgr = channelMgr(GetPlayer()->GetTeam()))
- if (Channel* channel = cMgr->GetChannel(channelName, GetPlayer()))
- channel->JoinNotify(GetPlayer());
+ if (Channel* channel = ChannelMgr::GetChannelForPlayerByNamePart(channelName, GetPlayer()))
+ channel->JoinNotify(GetPlayer());
*/
}
diff --git a/src/server/game/Handlers/CharacterHandler.cpp b/src/server/game/Handlers/CharacterHandler.cpp
index 53c62858c04..157511afd96 100644
--- a/src/server/game/Handlers/CharacterHandler.cpp
+++ b/src/server/game/Handlers/CharacterHandler.cpp
@@ -1843,13 +1843,10 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recvData)
{
// Reset guild
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GUILD_MEMBER);
-
stmt->setUInt32(0, lowGuid);
-
- PreparedQueryResult result = CharacterDatabase.Query(stmt);
- if (result)
+ if (PreparedQueryResult result = CharacterDatabase.Query(stmt))
if (Guild* guild = sGuildMgr->GetGuildById((result->Fetch()[0]).GetUInt32()))
- guild->DeleteMember(factionChangeInfo.Guid, false, false, true);
+ guild->DeleteMember(trans, factionChangeInfo.Guid, false, false, true);
Player::LeaveAllArenaTeams(factionChangeInfo.Guid);
}
diff --git a/src/server/game/Handlers/ChatHandler.cpp b/src/server/game/Handlers/ChatHandler.cpp
index 2b1660fef2b..ba5164f9be5 100644
--- a/src/server/game/Handlers/ChatHandler.cpp
+++ b/src/server/game/Handlers/ChatHandler.cpp
@@ -26,6 +26,7 @@
#include "DatabaseEnv.h"
#include "CellImpl.h"
#include "Chat.h"
+#include "Channel.h"
#include "ChannelMgr.h"
#include "GridNotifiersImpl.h"
#include "Group.h"
@@ -461,13 +462,10 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData)
}
}
- if (ChannelMgr* cMgr = ChannelMgr::forTeam(sender->GetTeam()))
+ if (Channel* chn = ChannelMgr::GetChannelForPlayerByNamePart(channel, sender))
{
- if (Channel* chn = cMgr->GetChannel(channel, sender))
- {
- sScriptMgr->OnPlayerChat(sender, type, lang, msg, chn);
- chn->Say(sender->GetGUID(), msg.c_str(), lang);
- }
+ sScriptMgr->OnPlayerChat(sender, type, lang, msg, chn);
+ chn->Say(sender->GetGUID(), msg.c_str(), lang);
}
break;
}
diff --git a/src/server/game/Handlers/ItemHandler.cpp b/src/server/game/Handlers/ItemHandler.cpp
index bb188b08fbc..8f9a3ba6ffc 100644
--- a/src/server/game/Handlers/ItemHandler.cpp
+++ b/src/server/game/Handlers/ItemHandler.cpp
@@ -284,7 +284,7 @@ void WorldSession::HandleDestroyItemOpcode(WorldPacket& recvData)
return;
}
- if (pItem->GetTemplate()->Flags & ITEM_PROTO_FLAG_INDESTRUCTIBLE)
+ if (pItem->GetTemplate()->Flags & ITEM_FLAG_NO_USER_DESTROY)
{
_player->SendEquipError(EQUIP_ERR_CANT_DROP_SOULBOUND, NULL, NULL);
return;
@@ -542,7 +542,7 @@ void WorldSession::HandleSellItemOpcode(WorldPacket& recvData)
// prevent selling item for sellprice when the item is still refundable
// this probably happens when right clicking a refundable item, the client sends both
// CMSG_SELL_ITEM and CMSG_REFUND_ITEM (unverified)
- if (pItem->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_REFUNDABLE))
+ if (pItem->HasFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_REFUNDABLE))
return; // Therefore, no feedback to client
// special case at auto sell (sell all)
@@ -776,7 +776,7 @@ void WorldSession::SendListInventory(ObjectGuid vendorGuid)
continue;
// Only display items in vendor lists for the team the
// player is on. If GM on, display all items.
- if (!_player->IsGameMaster() && ((itemTemplate->Flags2 & ITEM_FLAGS_EXTRA_HORDE_ONLY && _player->GetTeam() == ALLIANCE) || (itemTemplate->Flags2 == ITEM_FLAGS_EXTRA_ALLIANCE_ONLY && _player->GetTeam() == HORDE)))
+ if (!_player->IsGameMaster() && ((itemTemplate->Flags2 & ITEM_FLAG2_FACTION_HORDE && _player->GetTeam() == ALLIANCE) || (itemTemplate->Flags2 == ITEM_FLAG2_FACTION_ALLIANCE && _player->GetTeam() == HORDE)))
continue;
// Items sold out are not displayed in list
@@ -1093,7 +1093,7 @@ void WorldSession::HandleWrapItemOpcode(WorldPacket& recvData)
return;
}
- if (!(gift->GetTemplate()->Flags & ITEM_PROTO_FLAG_IS_WRAPPER)) // cheating: non-wrapper wrapper
+ if (!(gift->GetTemplate()->Flags & ITEM_FLAG_IS_WRAPPER)) // cheating: non-wrapper wrapper
{
_player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, gift, NULL);
return;
@@ -1171,7 +1171,7 @@ void WorldSession::HandleWrapItemOpcode(WorldPacket& recvData)
case 21830: item->SetEntry(21831); break;
}
item->SetGuidValue(ITEM_FIELD_GIFTCREATOR, _player->GetGUID());
- item->SetUInt32Value(ITEM_FIELD_FLAGS, ITEM_FLAG_WRAPPED);
+ item->SetUInt32Value(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_WRAPPED);
item->SetState(ITEM_CHANGED, _player);
if (item->GetState() == ITEM_NEW) // save new item, to have alway for `character_gifts` record in `item_instance`
@@ -1272,7 +1272,7 @@ void WorldSession::HandleSocketOpcode(WorldPacket& recvData)
ItemTemplate const* iGemProto = Gems[i]->GetTemplate();
// unique item (for new and already placed bit removed enchantments
- if (iGemProto->Flags & ITEM_PROTO_FLAG_UNIQUE_EQUIPPED)
+ if (iGemProto->Flags & ITEM_FLAG_UNIQUE_EQUIPPABLE)
{
for (int j = 0; j < MAX_GEM_SOCKETS; ++j)
{
diff --git a/src/server/game/Handlers/LootHandler.cpp b/src/server/game/Handlers/LootHandler.cpp
index d91dd6f495f..94e271465cd 100644
--- a/src/server/game/Handlers/LootHandler.cpp
+++ b/src/server/game/Handlers/LootHandler.cpp
@@ -322,7 +322,7 @@ void WorldSession::DoLootRelease(ObjectGuid lguid)
ItemTemplate const* proto = pItem->GetTemplate();
// destroy only 5 items from stack in case prospecting and milling
- if (proto->Flags & (ITEM_PROTO_FLAG_PROSPECTABLE | ITEM_PROTO_FLAG_MILLABLE))
+ if (proto->Flags & (ITEM_FLAG_IS_PROSPECTABLE | ITEM_FLAG_IS_MILLABLE))
{
pItem->m_lootGenerated = false;
pItem->loot.clear();
@@ -338,7 +338,7 @@ void WorldSession::DoLootRelease(ObjectGuid lguid)
else
{
// Only delete item if no loot or money (unlooted loot is saved to db) or if it isn't an openable item
- if (pItem->loot.isLooted() || !(proto->Flags & ITEM_PROTO_FLAG_HAS_LOOT))
+ if (pItem->loot.isLooted() || !(proto->Flags & ITEM_FLAG_HAS_LOOT))
player->DestroyItem(pItem->GetBagSlot(), pItem->GetSlot(), true);
}
return; // item can be looted only single player
diff --git a/src/server/game/Handlers/MailHandler.cpp b/src/server/game/Handlers/MailHandler.cpp
index 36df5b64f1b..a4dcd22c1f2 100644
--- a/src/server/game/Handlers/MailHandler.cpp
+++ b/src/server/game/Handlers/MailHandler.cpp
@@ -199,7 +199,7 @@ void WorldSession::HandleSendMail(WorldPacket& recvData)
if (Item* item = player->GetItemByGuid(itemGUIDs[i]))
{
ItemTemplate const* itemProto = item->GetTemplate();
- if (!itemProto || !(itemProto->Flags & ITEM_PROTO_FLAG_BIND_TO_ACCOUNT))
+ if (!itemProto || !(itemProto->Flags & ITEM_FLAG_IS_BOUND_TO_ACCOUNT))
{
accountBound = false;
break;
@@ -250,13 +250,13 @@ void WorldSession::HandleSendMail(WorldPacket& recvData)
return;
}
- if (item->GetTemplate()->Flags & ITEM_PROTO_FLAG_CONJURED || item->GetUInt32Value(ITEM_FIELD_DURATION))
+ if ((item->GetTemplate()->Flags & ITEM_FLAG_CONJURED) || item->GetUInt32Value(ITEM_FIELD_DURATION))
{
player->SendMailResult(0, MAIL_SEND, MAIL_ERR_EQUIP_ERROR, EQUIP_ERR_MAIL_BOUND_ITEM);
return;
}
- if (COD && item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_WRAPPED))
+ if (COD && item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_WRAPPED))
{
player->SendMailResult(0, MAIL_SEND, MAIL_ERR_CANT_SEND_WRAPPED_COD);
return;
diff --git a/src/server/game/Handlers/PetitionsHandler.cpp b/src/server/game/Handlers/PetitionsHandler.cpp
index c0b5db65d90..a4d41bbff1f 100644
--- a/src/server/game/Handlers/PetitionsHandler.cpp
+++ b/src/server/game/Handlers/PetitionsHandler.cpp
@@ -849,12 +849,18 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket& recvData)
Guild::SendCommandResult(this, GUILD_COMMAND_CREATE, ERR_GUILD_COMMAND_SUCCESS, name);
- // Add members from signatures
- for (uint8 i = 0; i < signatures; ++i)
{
- Field* fields = result->Fetch();
- guild->AddMember(ObjectGuid(HighGuid::Player, fields[0].GetUInt32()));
- result->NextRow();
+ SQLTransaction trans = CharacterDatabase.BeginTransaction();
+
+ // Add members from signatures
+ for (uint8 i = 0; i < signatures; ++i)
+ {
+ Field* fields = result->Fetch();
+ guild->AddMember(trans, ObjectGuid(HighGuid::Player, fields[0].GetUInt32()));
+ result->NextRow();
+ }
+
+ CharacterDatabase.CommitTransaction(trans);
}
}
else
diff --git a/src/server/game/Handlers/SpellHandler.cpp b/src/server/game/Handlers/SpellHandler.cpp
index cbc9be3b140..728fda8d184 100644
--- a/src/server/game/Handlers/SpellHandler.cpp
+++ b/src/server/game/Handlers/SpellHandler.cpp
@@ -115,14 +115,14 @@ void WorldSession::HandleUseItemOpcode(WorldPacket& recvPacket)
}
// only allow conjured consumable, bandage, poisons (all should have the 2^21 item flag set in DB)
- if (proto->Class == ITEM_CLASS_CONSUMABLE && !(proto->Flags & ITEM_PROTO_FLAG_USEABLE_IN_ARENA) && pUser->InArena())
+ if (proto->Class == ITEM_CLASS_CONSUMABLE && !(proto->Flags & ITEM_FLAG_IGNORE_DEFAULT_ARENA_RESTRICTIONS) && pUser->InArena())
{
pUser->SendEquipError(EQUIP_ERR_NOT_DURING_ARENA_MATCH, pItem, NULL);
return;
}
// don't allow items banned in arena
- if (proto->Flags & ITEM_PROTO_FLAG_NOT_USEABLE_IN_ARENA && pUser->InArena())
+ if ((proto->Flags & ITEM_FLAG_NOT_USEABLE_IN_ARENA) && pUser->InArena())
{
pUser->SendEquipError(EQUIP_ERR_NOT_DURING_ARENA_MATCH, pItem, NULL);
return;
@@ -196,7 +196,7 @@ void WorldSession::HandleOpenItemOpcode(WorldPacket& recvPacket)
}
// Verify that the bag is an actual bag or wrapped item that can be used "normally"
- if (!(proto->Flags & ITEM_PROTO_FLAG_HAS_LOOT) && !item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_WRAPPED))
+ if (!(proto->Flags & ITEM_FLAG_HAS_LOOT) && !item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_WRAPPED))
{
pUser->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW, item, NULL);
TC_LOG_ERROR("entities.player.cheat", "Possible hacking attempt: Player %s [guid: %u] tried to open item [guid: %u, entry: %u] which is not openable!",
@@ -225,7 +225,7 @@ void WorldSession::HandleOpenItemOpcode(WorldPacket& recvPacket)
}
}
- if (item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_WRAPPED))// wrapped?
+ if (item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_WRAPPED))// wrapped?
{
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_GIFT_BY_ITEM);
diff --git a/src/server/game/Handlers/TradeHandler.cpp b/src/server/game/Handlers/TradeHandler.cpp
index e2743f8f456..6b4d16111ed 100644
--- a/src/server/game/Handlers/TradeHandler.cpp
+++ b/src/server/game/Handlers/TradeHandler.cpp
@@ -93,7 +93,7 @@ void WorldSession::SendUpdateTrade(bool trader_data /*= true*/)
data << uint32(item->GetTemplate()->DisplayInfoID);// display id
data << uint32(item->GetCount()); // stack count
// wrapped: hide stats but show giftcreator name
- data << uint32(item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_WRAPPED) ? 1 : 0);
+ data << uint32(item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_WRAPPED) ? 1 : 0);
data << uint64(item->GetGuidValue(ITEM_FIELD_GIFTCREATOR));
// perm. enchantment and gems
data << uint32(item->GetEnchantmentId(PERM_ENCHANTMENT_SLOT));
@@ -152,7 +152,7 @@ void WorldSession::moveItems(Item* myItems[], Item* hisItems[])
}
// adjust time (depends on /played)
- if (myItems[i]->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_BOP_TRADEABLE))
+ if (myItems[i]->HasFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_BOP_TRADEABLE))
myItems[i]->SetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME, trader->GetTotalPlayedTime()-(_player->GetTotalPlayedTime()-myItems[i]->GetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME)));
// store
trader->MoveItemToInventory(traderDst, myItems[i], true, true);
@@ -170,7 +170,7 @@ void WorldSession::moveItems(Item* myItems[], Item* hisItems[])
}
// adjust time (depends on /played)
- if (hisItems[i]->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_BOP_TRADEABLE))
+ if (hisItems[i]->HasFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_BOP_TRADEABLE))
hisItems[i]->SetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME, _player->GetTotalPlayedTime()-(trader->GetTotalPlayedTime()-hisItems[i]->GetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME)));
// store
_player->MoveItemToInventory(playerDst, hisItems[i], true, true);
diff --git a/src/server/game/Loot/LootMgr.cpp b/src/server/game/Loot/LootMgr.cpp
index da50b818341..b69bb41d3ad 100644
--- a/src/server/game/Loot/LootMgr.cpp
+++ b/src/server/game/Loot/LootMgr.cpp
@@ -353,7 +353,7 @@ LootItem::LootItem(LootStoreItem const& li)
conditions = li.conditions;
ItemTemplate const* proto = sObjectMgr->GetItemTemplate(itemid);
- freeforall = proto && (proto->Flags & ITEM_PROTO_FLAG_MULTI_DROP);
+ freeforall = proto && (proto->Flags & ITEM_FLAG_MULTI_DROP);
follow_loot_rules = proto && (proto->FlagsCu & ITEM_FLAGS_CU_FOLLOW_LOOT_RULES);
needs_quest = li.needs_quest;
@@ -380,24 +380,20 @@ bool LootItem::AllowedForPlayer(Player const* player) const
return false;
// not show loot for players without profession or those who already know the recipe
- if ((pProto->Flags & ITEM_PROTO_FLAG_SMART_LOOT) && (!player->HasSkill(pProto->RequiredSkill) || player->HasSpell(pProto->Spells[1].SpellId)))
+ if ((pProto->Flags & ITEM_FLAG_HIDE_UNUSABLE_RECIPE) && (!player->HasSkill(pProto->RequiredSkill) || player->HasSpell(pProto->Spells[1].SpellId)))
return false;
// not show loot for not own team
- if ((pProto->Flags2 & ITEM_FLAGS_EXTRA_HORDE_ONLY) && player->GetTeam() != HORDE)
+ if ((pProto->Flags2 & ITEM_FLAG2_FACTION_HORDE) && player->GetTeam() != HORDE)
return false;
- if ((pProto->Flags2 & ITEM_FLAGS_EXTRA_ALLIANCE_ONLY) && player->GetTeam() != ALLIANCE)
+ if ((pProto->Flags2 & ITEM_FLAG2_FACTION_ALLIANCE) && player->GetTeam() != ALLIANCE)
return false;
// check quest requirements
if (!(pProto->FlagsCu & ITEM_FLAGS_CU_IGNORE_QUEST_STATUS) && ((needs_quest || (pProto->StartQuest && player->GetQuestStatus(pProto->StartQuest) != QUEST_STATUS_NONE)) && !player->HasQuestForItem(itemid)))
return false;
- // Don't show bind-when-picked-up unique items if player already has the maximum allowed quantity.
- if (pProto->Bonding == BIND_WHEN_PICKED_UP && pProto->MaxCount && int32(player->GetItemCount(itemid, true)) >= pProto->MaxCount)
- return false;
-
return true;
}
@@ -433,7 +429,7 @@ void Loot::AddItem(LootStoreItem const& item)
// non-conditional one-player only items are counted here,
// free for all items are counted in FillFFALoot(),
// non-ffa conditionals are counted in FillNonQuestNonFFAConditionalLoot()
- if (!item.needs_quest && item.conditions.empty() && !(proto->Flags & ITEM_PROTO_FLAG_MULTI_DROP))
+ if (!item.needs_quest && item.conditions.empty() && !(proto->Flags & ITEM_FLAG_MULTI_DROP))
++unlootedCount;
}
}
@@ -487,7 +483,7 @@ void Loot::FillNotNormalLootFor(Player* player, bool presentAtLooting)
{
ObjectGuid::LowType plguid = player->GetGUID().GetCounter();
- QuestItemMap::const_iterator qmapitr = PlayerQuestItems.find(plguid);
+ NotNormalLootItemMap::const_iterator qmapitr = PlayerQuestItems.find(plguid);
if (qmapitr == PlayerQuestItems.end())
FillQuestLoot(player);
@@ -521,16 +517,16 @@ void Loot::FillNotNormalLootFor(Player* player, bool presentAtLooting)
}
}
-QuestItemList* Loot::FillFFALoot(Player* player)
+NotNormalLootItemList* Loot::FillFFALoot(Player* player)
{
- QuestItemList* ql = new QuestItemList();
+ NotNormalLootItemList* ql = new NotNormalLootItemList();
for (uint8 i = 0; i < items.size(); ++i)
{
LootItem &item = items[i];
if (!item.is_looted && item.freeforall && item.AllowedForPlayer(player))
{
- ql->push_back(QuestItem(i));
+ ql->push_back(NotNormalLootItem(i));
++unlootedCount;
}
}
@@ -544,12 +540,12 @@ QuestItemList* Loot::FillFFALoot(Player* player)
return ql;
}
-QuestItemList* Loot::FillQuestLoot(Player* player)
+NotNormalLootItemList* Loot::FillQuestLoot(Player* player)
{
if (items.size() == MAX_NR_LOOT_ITEMS)
return NULL;
- QuestItemList* ql = new QuestItemList();
+ NotNormalLootItemList* ql = new NotNormalLootItemList();
for (uint8 i = 0; i < quest_items.size(); ++i)
{
@@ -557,7 +553,7 @@ QuestItemList* Loot::FillQuestLoot(Player* player)
if (!item.is_looted && (item.AllowedForPlayer(player) || (item.follow_loot_rules && player->GetGroup() && ((player->GetGroup()->GetLootMethod() == MASTER_LOOT && player->GetGroup()->GetMasterLooterGuid() == player->GetGUID()) || player->GetGroup()->GetLootMethod() != MASTER_LOOT))))
{
- ql->push_back(QuestItem(i));
+ ql->push_back(NotNormalLootItem(i));
// quest items get blocked when they first appear in a
// player's quest vector
@@ -582,20 +578,20 @@ QuestItemList* Loot::FillQuestLoot(Player* player)
return ql;
}
-QuestItemList* Loot::FillNonQuestNonFFAConditionalLoot(Player* player, bool presentAtLooting)
+NotNormalLootItemList* Loot::FillNonQuestNonFFAConditionalLoot(Player* player, bool presentAtLooting)
{
- QuestItemList* ql = new QuestItemList();
+ NotNormalLootItemList* ql = new NotNormalLootItemList();
for (uint8 i = 0; i < items.size(); ++i)
{
LootItem &item = items[i];
- if (!item.is_looted && !item.freeforall && (item.AllowedForPlayer(player) || (item.follow_loot_rules && player->GetGroup() && ((player->GetGroup()->GetLootMethod() == MASTER_LOOT && player->GetGroup()->GetMasterLooterGuid() == player->GetGUID()) || player->GetGroup()->GetLootMethod() != MASTER_LOOT))))
+ if (!item.is_looted && !item.freeforall && (item.AllowedForPlayer(player)))
{
if (presentAtLooting)
item.AddAllowedLooter(player);
if (!item.conditions.empty())
{
- ql->push_back(QuestItem(i));
+ ql->push_back(NotNormalLootItem(i));
if (!item.is_counted)
{
++unlootedCount;
@@ -661,11 +657,11 @@ void Loot::NotifyQuestItemRemoved(uint8 questIndex)
++i_next;
if (Player* player = ObjectAccessor::FindPlayer(*i))
{
- QuestItemMap::const_iterator pq = PlayerQuestItems.find(player->GetGUID().GetCounter());
+ NotNormalLootItemMap::const_iterator pq = PlayerQuestItems.find(player->GetGUID().GetCounter());
if (pq != PlayerQuestItems.end() && pq->second)
{
// find where/if the player has the given item in it's vector
- QuestItemList& pql = *pq->second;
+ NotNormalLootItemList& pql = *pq->second;
uint8 j;
for (j = 0; j < pql.size(); ++j)
@@ -721,17 +717,17 @@ void Loot::DeleteLootMoneyFromContainerItemDB()
CharacterDatabase.Execute(stmt);
}
-LootItem* Loot::LootItemInSlot(uint32 lootSlot, Player* player, QuestItem* *qitem, QuestItem* *ffaitem, QuestItem* *conditem)
+LootItem* Loot::LootItemInSlot(uint32 lootSlot, Player* player, NotNormalLootItem* *qitem, NotNormalLootItem* *ffaitem, NotNormalLootItem* *conditem)
{
LootItem* item = NULL;
bool is_looted = true;
if (lootSlot >= items.size())
{
uint32 questSlot = lootSlot - items.size();
- QuestItemMap::const_iterator itr = PlayerQuestItems.find(player->GetGUID().GetCounter());
+ NotNormalLootItemMap::const_iterator itr = PlayerQuestItems.find(player->GetGUID().GetCounter());
if (itr != PlayerQuestItems.end() && questSlot < itr->second->size())
{
- QuestItem* qitem2 = &itr->second->at(questSlot);
+ NotNormalLootItem* qitem2 = &itr->second->at(questSlot);
if (qitem)
*qitem = qitem2;
item = &quest_items[qitem2->index];
@@ -744,13 +740,13 @@ LootItem* Loot::LootItemInSlot(uint32 lootSlot, Player* player, QuestItem* *qite
is_looted = item->is_looted;
if (item->freeforall)
{
- QuestItemMap::const_iterator itr = PlayerFFAItems.find(player->GetGUID().GetCounter());
+ NotNormalLootItemMap::const_iterator itr = PlayerFFAItems.find(player->GetGUID().GetCounter());
if (itr != PlayerFFAItems.end())
{
- for (QuestItemList::const_iterator iter=itr->second->begin(); iter!= itr->second->end(); ++iter)
+ for (NotNormalLootItemList::const_iterator iter=itr->second->begin(); iter!= itr->second->end(); ++iter)
if (iter->index == lootSlot)
{
- QuestItem* ffaitem2 = (QuestItem*)&(*iter);
+ NotNormalLootItem* ffaitem2 = (NotNormalLootItem*)&(*iter);
if (ffaitem)
*ffaitem = ffaitem2;
is_looted = ffaitem2->is_looted;
@@ -760,14 +756,14 @@ LootItem* Loot::LootItemInSlot(uint32 lootSlot, Player* player, QuestItem* *qite
}
else if (!item->conditions.empty())
{
- QuestItemMap::const_iterator itr = PlayerNonQuestNonFFAConditionalItems.find(player->GetGUID().GetCounter());
+ NotNormalLootItemMap::const_iterator itr = PlayerNonQuestNonFFAConditionalItems.find(player->GetGUID().GetCounter());
if (itr != PlayerNonQuestNonFFAConditionalItems.end())
{
- for (QuestItemList::const_iterator iter=itr->second->begin(); iter!= itr->second->end(); ++iter)
+ for (NotNormalLootItemList::const_iterator iter=itr->second->begin(); iter!= itr->second->end(); ++iter)
{
if (iter->index == lootSlot)
{
- QuestItem* conditem2 = (QuestItem*)&(*iter);
+ NotNormalLootItem* conditem2 = (NotNormalLootItem*)&(*iter);
if (conditem)
*conditem = conditem2;
is_looted = conditem2->is_looted;
@@ -786,7 +782,7 @@ LootItem* Loot::LootItemInSlot(uint32 lootSlot, Player* player, QuestItem* *qite
uint32 Loot::GetMaxSlotInLootFor(Player* player) const
{
- QuestItemMap::const_iterator itr = PlayerQuestItems.find(player->GetGUID().GetCounter());
+ NotNormalLootItemMap::const_iterator itr = PlayerQuestItems.find(player->GetGUID().GetCounter());
return items.size() + (itr != PlayerQuestItems.end() ? itr->second->size() : 0);
}
@@ -806,12 +802,12 @@ bool Loot::hasItemForAll() const
// return true if there is any FFA, quest or conditional item for the player.
bool Loot::hasItemFor(Player* player) const
{
- QuestItemMap const& lootPlayerQuestItems = GetPlayerQuestItems();
- QuestItemMap::const_iterator q_itr = lootPlayerQuestItems.find(player->GetGUID().GetCounter());
+ NotNormalLootItemMap const& lootPlayerQuestItems = GetPlayerQuestItems();
+ NotNormalLootItemMap::const_iterator q_itr = lootPlayerQuestItems.find(player->GetGUID().GetCounter());
if (q_itr != lootPlayerQuestItems.end())
{
- QuestItemList* q_list = q_itr->second;
- for (QuestItemList::const_iterator qi = q_list->begin(); qi != q_list->end(); ++qi)
+ NotNormalLootItemList* q_list = q_itr->second;
+ for (NotNormalLootItemList::const_iterator qi = q_list->begin(); qi != q_list->end(); ++qi)
{
const LootItem &item = quest_items[qi->index];
if (!qi->is_looted && !item.is_looted)
@@ -819,12 +815,12 @@ bool Loot::hasItemFor(Player* player) const
}
}
- QuestItemMap const& lootPlayerFFAItems = GetPlayerFFAItems();
- QuestItemMap::const_iterator ffa_itr = lootPlayerFFAItems.find(player->GetGUID().GetCounter());
+ NotNormalLootItemMap const& lootPlayerFFAItems = GetPlayerFFAItems();
+ NotNormalLootItemMap::const_iterator ffa_itr = lootPlayerFFAItems.find(player->GetGUID().GetCounter());
if (ffa_itr != lootPlayerFFAItems.end())
{
- QuestItemList* ffa_list = ffa_itr->second;
- for (QuestItemList::const_iterator fi = ffa_list->begin(); fi != ffa_list->end(); ++fi)
+ NotNormalLootItemList* ffa_list = ffa_itr->second;
+ for (NotNormalLootItemList::const_iterator fi = ffa_list->begin(); fi != ffa_list->end(); ++fi)
{
const LootItem &item = items[fi->index];
if (!fi->is_looted && !item.is_looted)
@@ -832,12 +828,12 @@ bool Loot::hasItemFor(Player* player) const
}
}
- QuestItemMap const& lootPlayerNonQuestNonFFAConditionalItems = GetPlayerNonQuestNonFFAConditionalItems();
- QuestItemMap::const_iterator nn_itr = lootPlayerNonQuestNonFFAConditionalItems.find(player->GetGUID().GetCounter());
+ NotNormalLootItemMap const& lootPlayerNonQuestNonFFAConditionalItems = GetPlayerNonQuestNonFFAConditionalItems();
+ NotNormalLootItemMap::const_iterator nn_itr = lootPlayerNonQuestNonFFAConditionalItems.find(player->GetGUID().GetCounter());
if (nn_itr != lootPlayerNonQuestNonFFAConditionalItems.end())
{
- QuestItemList* conditional_list = nn_itr->second;
- for (QuestItemList::const_iterator ci = conditional_list->begin(); ci != conditional_list->end(); ++ci)
+ NotNormalLootItemList* conditional_list = nn_itr->second;
+ for (NotNormalLootItemList::const_iterator ci = conditional_list->begin(); ci != conditional_list->end(); ++ci)
{
const LootItem &item = items[ci->index];
if (!ci->is_looted && !item.is_looted)
@@ -980,12 +976,12 @@ ByteBuffer& operator<<(ByteBuffer& b, LootView const& lv)
}
LootSlotType slotType = lv.permission == OWNER_PERMISSION ? LOOT_SLOT_TYPE_OWNER : LOOT_SLOT_TYPE_ALLOW_LOOT;
- QuestItemMap const& lootPlayerQuestItems = l.GetPlayerQuestItems();
- QuestItemMap::const_iterator q_itr = lootPlayerQuestItems.find(lv.viewer->GetGUID().GetCounter());
+ NotNormalLootItemMap const& lootPlayerQuestItems = l.GetPlayerQuestItems();
+ NotNormalLootItemMap::const_iterator q_itr = lootPlayerQuestItems.find(lv.viewer->GetGUID().GetCounter());
if (q_itr != lootPlayerQuestItems.end())
{
- QuestItemList* q_list = q_itr->second;
- for (QuestItemList::const_iterator qi = q_list->begin(); qi != q_list->end(); ++qi)
+ NotNormalLootItemList* q_list = q_itr->second;
+ for (NotNormalLootItemList::const_iterator qi = q_list->begin(); qi != q_list->end(); ++qi)
{
LootItem &item = l.quest_items[qi->index];
if (!qi->is_looted && !item.is_looted)
@@ -1021,12 +1017,12 @@ ByteBuffer& operator<<(ByteBuffer& b, LootView const& lv)
}
}
- QuestItemMap const& lootPlayerFFAItems = l.GetPlayerFFAItems();
- QuestItemMap::const_iterator ffa_itr = lootPlayerFFAItems.find(lv.viewer->GetGUID().GetCounter());
+ NotNormalLootItemMap const& lootPlayerFFAItems = l.GetPlayerFFAItems();
+ NotNormalLootItemMap::const_iterator ffa_itr = lootPlayerFFAItems.find(lv.viewer->GetGUID().GetCounter());
if (ffa_itr != lootPlayerFFAItems.end())
{
- QuestItemList* ffa_list = ffa_itr->second;
- for (QuestItemList::const_iterator fi = ffa_list->begin(); fi != ffa_list->end(); ++fi)
+ NotNormalLootItemList* ffa_list = ffa_itr->second;
+ for (NotNormalLootItemList::const_iterator fi = ffa_list->begin(); fi != ffa_list->end(); ++fi)
{
LootItem &item = l.items[fi->index];
if (!fi->is_looted && !item.is_looted)
@@ -1039,42 +1035,37 @@ ByteBuffer& operator<<(ByteBuffer& b, LootView const& lv)
}
}
- QuestItemMap const& lootPlayerNonQuestNonFFAConditionalItems = l.GetPlayerNonQuestNonFFAConditionalItems();
- QuestItemMap::const_iterator nn_itr = lootPlayerNonQuestNonFFAConditionalItems.find(lv.viewer->GetGUID().GetCounter());
+ NotNormalLootItemMap const& lootPlayerNonQuestNonFFAConditionalItems = l.GetPlayerNonQuestNonFFAConditionalItems();
+ NotNormalLootItemMap::const_iterator nn_itr = lootPlayerNonQuestNonFFAConditionalItems.find(lv.viewer->GetGUID().GetCounter());
if (nn_itr != lootPlayerNonQuestNonFFAConditionalItems.end())
{
- QuestItemList* conditional_list = nn_itr->second;
- for (QuestItemList::const_iterator ci = conditional_list->begin(); ci != conditional_list->end(); ++ci)
+ NotNormalLootItemList* conditional_list = nn_itr->second;
+ for (NotNormalLootItemList::const_iterator ci = conditional_list->begin(); ci != conditional_list->end(); ++ci)
{
LootItem &item = l.items[ci->index];
if (!ci->is_looted && !item.is_looted)
{
b << uint8(ci->index);
b << item;
- if (item.follow_loot_rules)
+ switch (lv.permission)
{
- switch (lv.permission)
- {
- case MASTER_PERMISSION:
- b << uint8(LOOT_SLOT_TYPE_MASTER);
- break;
- case RESTRICTED_PERMISSION:
- b << (item.is_blocked ? uint8(LOOT_SLOT_TYPE_LOCKED) : uint8(slotType));
- break;
- case GROUP_PERMISSION:
- case ROUND_ROBIN_PERMISSION:
- if (!item.is_blocked)
- b << uint8(LOOT_SLOT_TYPE_ALLOW_LOOT);
- else
- b << uint8(LOOT_SLOT_TYPE_ROLL_ONGOING);
- break;
- default:
- b << uint8(slotType);
- break;
- }
- }
- else
+ case MASTER_PERMISSION:
+ b << uint8(LOOT_SLOT_TYPE_MASTER);
+ break;
+ case RESTRICTED_PERMISSION:
+ b << (item.is_blocked ? uint8(LOOT_SLOT_TYPE_LOCKED) : uint8(slotType));
+ break;
+ case GROUP_PERMISSION:
+ case ROUND_ROBIN_PERMISSION:
+ if (!item.is_blocked)
+ b << uint8(LOOT_SLOT_TYPE_ALLOW_LOOT);
+ else
+ b << uint8(LOOT_SLOT_TYPE_ROLL_ONGOING);
+ break;
+ default:
b << uint8(slotType);
+ break;
+ }
++itemsShown;
}
}
@@ -1657,7 +1648,7 @@ void LoadLootTemplates_Item()
// remove real entries and check existence loot
ItemTemplateContainer const* its = sObjectMgr->GetItemTemplateStore();
for (ItemTemplateContainer::const_iterator itr = its->begin(); itr != its->end(); ++itr)
- if (lootIdSet.find(itr->second.ItemId) != lootIdSet.end() && itr->second.Flags & ITEM_PROTO_FLAG_HAS_LOOT)
+ if (lootIdSet.find(itr->second.ItemId) != lootIdSet.end() && itr->second.Flags & ITEM_FLAG_HAS_LOOT)
lootIdSet.erase(itr->second.ItemId);
// output error for any still listed (not referenced from appropriate table) ids
@@ -1682,7 +1673,7 @@ void LoadLootTemplates_Milling()
ItemTemplateContainer const* its = sObjectMgr->GetItemTemplateStore();
for (ItemTemplateContainer::const_iterator itr = its->begin(); itr != its->end(); ++itr)
{
- if (!(itr->second.Flags & ITEM_PROTO_FLAG_MILLABLE))
+ if (!(itr->second.Flags & ITEM_FLAG_IS_MILLABLE))
continue;
if (lootIdSet.find(itr->second.ItemId) != lootIdSet.end())
@@ -1745,7 +1736,7 @@ void LoadLootTemplates_Prospecting()
ItemTemplateContainer const* its = sObjectMgr->GetItemTemplateStore();
for (ItemTemplateContainer::const_iterator itr = its->begin(); itr != its->end(); ++itr)
{
- if (!(itr->second.Flags & ITEM_PROTO_FLAG_PROSPECTABLE))
+ if (!(itr->second.Flags & ITEM_FLAG_IS_PROSPECTABLE))
continue;
if (lootIdSet.find(itr->second.ItemId) != lootIdSet.end())
diff --git a/src/server/game/Loot/LootMgr.h b/src/server/game/Loot/LootMgr.h
index a66b8f0b4c5..ecfb864823f 100644
--- a/src/server/game/Loot/LootMgr.h
+++ b/src/server/game/Loot/LootMgr.h
@@ -180,24 +180,24 @@ struct TC_GAME_API LootItem
const AllowedLooterSet & GetAllowedLooters() const { return allowedGUIDs; }
};
-struct QuestItem
+struct NotNormalLootItem
{
- uint8 index; // position in quest_items;
+ uint8 index; // position in quest_items or items;
bool is_looted;
- QuestItem()
+ NotNormalLootItem()
: index(0), is_looted(false) { }
- QuestItem(uint8 _index, bool _islooted = false)
+ NotNormalLootItem(uint8 _index, bool _islooted = false)
: index(_index), is_looted(_islooted) { }
};
struct Loot;
class LootTemplate;
-typedef std::vector<QuestItem> QuestItemList;
+typedef std::vector<NotNormalLootItem> NotNormalLootItemList;
typedef std::vector<LootItem> LootItemList;
-typedef std::map<uint32, QuestItemList*> QuestItemMap;
+typedef std::map<uint32, NotNormalLootItemList*> NotNormalLootItemMap;
typedef std::list<LootStoreItem*> LootStoreItemList;
typedef std::unordered_map<uint32, LootTemplate*> LootTemplateMap;
@@ -271,13 +271,13 @@ class TC_GAME_API LootTemplate
LootGroups Groups; // groups have own (optimised) processing, grouped entries go there
// Objects of this class must never be copied, we are storing pointers in container
- LootTemplate(LootTemplate const&);
- LootTemplate& operator=(LootTemplate const&);
+ LootTemplate(LootTemplate const&) = delete;
+ LootTemplate& operator=(LootTemplate const&) = delete;
};
//=====================================================
-class LootValidatorRef : public Reference<Loot, LootValidatorRef>
+class LootValidatorRef : public Reference<Loot, LootValidatorRef>
{
public:
LootValidatorRef() { }
@@ -293,12 +293,9 @@ class LootValidatorRefManager : public RefManager<Loot, LootValidatorRef>
typedef LinkedListHead::Iterator< LootValidatorRef > iterator;
LootValidatorRef* getFirst() { return (LootValidatorRef*)RefManager<Loot, LootValidatorRef>::getFirst(); }
- LootValidatorRef* getLast() { return (LootValidatorRef*)RefManager<Loot, LootValidatorRef>::getLast(); }
iterator begin() { return iterator(getFirst()); }
- iterator end() { return iterator(NULL); }
- iterator rbegin() { return iterator(getLast()); }
- iterator rend() { return iterator(NULL); }
+ iterator end() { return iterator(nullptr); }
};
//=====================================================
@@ -311,9 +308,9 @@ struct TC_GAME_API Loot
{
friend ByteBuffer& operator<<(ByteBuffer& b, LootView const& lv);
- QuestItemMap const& GetPlayerQuestItems() const { return PlayerQuestItems; }
- QuestItemMap const& GetPlayerFFAItems() const { return PlayerFFAItems; }
- QuestItemMap const& GetPlayerNonQuestNonFFAConditionalItems() const { return PlayerNonQuestNonFFAConditionalItems; }
+ NotNormalLootItemMap const& GetPlayerQuestItems() const { return PlayerQuestItems; }
+ NotNormalLootItemMap const& GetPlayerFFAItems() const { return PlayerFFAItems; }
+ NotNormalLootItemMap const& GetPlayerNonQuestNonFFAConditionalItems() const { return PlayerNonQuestNonFFAConditionalItems; }
std::vector<LootItem> items;
std::vector<LootItem> quest_items;
@@ -343,15 +340,15 @@ struct TC_GAME_API Loot
// void clear();
void clear()
{
- for (QuestItemMap::const_iterator itr = PlayerQuestItems.begin(); itr != PlayerQuestItems.end(); ++itr)
+ for (NotNormalLootItemMap::const_iterator itr = PlayerQuestItems.begin(); itr != PlayerQuestItems.end(); ++itr)
delete itr->second;
PlayerQuestItems.clear();
- for (QuestItemMap::const_iterator itr = PlayerFFAItems.begin(); itr != PlayerFFAItems.end(); ++itr)
+ for (NotNormalLootItemMap::const_iterator itr = PlayerFFAItems.begin(); itr != PlayerFFAItems.end(); ++itr)
delete itr->second;
PlayerFFAItems.clear();
- for (QuestItemMap::const_iterator itr = PlayerNonQuestNonFFAConditionalItems.begin(); itr != PlayerNonQuestNonFFAConditionalItems.end(); ++itr)
+ for (NotNormalLootItemMap::const_iterator itr = PlayerNonQuestNonFFAConditionalItems.begin(); itr != PlayerNonQuestNonFFAConditionalItems.end(); ++itr)
delete itr->second;
PlayerNonQuestNonFFAConditionalItems.clear();
@@ -380,7 +377,7 @@ struct TC_GAME_API Loot
// Inserts the item into the loot (called by LootTemplate processors)
void AddItem(LootStoreItem const & item);
- LootItem* LootItemInSlot(uint32 lootslot, Player* player, QuestItem** qitem = NULL, QuestItem** ffaitem = NULL, QuestItem** conditem = NULL);
+ LootItem* LootItemInSlot(uint32 lootslot, Player* player, NotNormalLootItem** qitem = NULL, NotNormalLootItem** ffaitem = NULL, NotNormalLootItem** conditem = NULL);
uint32 GetMaxSlotInLootFor(Player* player) const;
bool hasItemForAll() const;
bool hasItemFor(Player* player) const;
@@ -388,14 +385,14 @@ struct TC_GAME_API Loot
private:
void FillNotNormalLootFor(Player* player, bool presentAtLooting);
- QuestItemList* FillFFALoot(Player* player);
- QuestItemList* FillQuestLoot(Player* player);
- QuestItemList* FillNonQuestNonFFAConditionalLoot(Player* player, bool presentAtLooting);
+ NotNormalLootItemList* FillFFALoot(Player* player);
+ NotNormalLootItemList* FillQuestLoot(Player* player);
+ NotNormalLootItemList* FillNonQuestNonFFAConditionalLoot(Player* player, bool presentAtLooting);
GuidSet PlayersLooting;
- QuestItemMap PlayerQuestItems;
- QuestItemMap PlayerFFAItems;
- QuestItemMap PlayerNonQuestNonFFAConditionalItems;
+ NotNormalLootItemMap PlayerQuestItems;
+ NotNormalLootItemMap PlayerFFAItems;
+ NotNormalLootItemMap PlayerNonQuestNonFFAConditionalItems;
// All rolls are registered here. They need to know, when the loot is not valid anymore
LootValidatorRefManager i_LootValidatorRefManager;
diff --git a/src/server/game/Maps/MapRefManager.h b/src/server/game/Maps/MapRefManager.h
index 09aa67d43eb..14d1d59bd36 100644
--- a/src/server/game/Maps/MapRefManager.h
+++ b/src/server/game/Maps/MapRefManager.h
@@ -26,20 +26,17 @@ class MapReference;
class MapRefManager : public RefManager<Map, Player>
{
public:
- typedef LinkedListHead::Iterator< MapReference > iterator;
- typedef LinkedListHead::Iterator< MapReference const > const_iterator;
+ typedef LinkedListHead::Iterator<MapReference> iterator;
+ typedef LinkedListHead::Iterator<MapReference const> const_iterator;
- MapReference* getFirst() { return (MapReference*)RefManager<Map, Player>::getFirst(); }
+ MapReference* getFirst() { return (MapReference*)RefManager<Map, Player>::getFirst(); }
MapReference const* getFirst() const { return (MapReference const*)RefManager<Map, Player>::getFirst(); }
- MapReference* getLast() { return (MapReference*)RefManager<Map, Player>::getLast(); }
- MapReference const* getLast() const { return (MapReference const*)RefManager<Map, Player>::getLast(); }
iterator begin() { return iterator(getFirst()); }
- iterator end() { return iterator(NULL); }
- iterator rbegin() { return iterator(getLast()); }
- iterator rend() { return iterator(NULL); }
+ iterator end() { return iterator(nullptr); }
+
const_iterator begin() const { return const_iterator(getFirst()); }
- const_iterator end() const { return const_iterator(NULL); }
+ const_iterator end() const { return const_iterator(nullptr); }
};
#endif
diff --git a/src/server/game/Miscellaneous/SharedDefines.h b/src/server/game/Miscellaneous/SharedDefines.h
index f7c440ce8bc..bf913081fef 100644
--- a/src/server/game/Miscellaneous/SharedDefines.h
+++ b/src/server/game/Miscellaneous/SharedDefines.h
@@ -374,9 +374,9 @@ enum SpellAttr2
SPELL_ATTR2_IS_ARCANE_CONCENTRATION = 0x00800000, // 23 Only mage Arcane Concentration have this flag
SPELL_ATTR2_UNK24 = 0x01000000, // 24
SPELL_ATTR2_UNK25 = 0x02000000, // 25
- SPELL_ATTR2_UNK26 = 0x04000000, // 26 unaffected by school immunity
+ SPELL_ATTR2_UNAFFECTED_BY_AURA_SCHOOL_IMMUNE = 0x04000000, // 26 unaffected by school immunity
SPELL_ATTR2_UNK27 = 0x08000000, // 27
- SPELL_ATTR2_UNK28 = 0x10000000, // 28
+ SPELL_ATTR2_IGNORE_ITEM_CHECK = 0x10000000, // 28 Spell is cast without checking item requirements (charges/reagents/totem)
SPELL_ATTR2_CANT_CRIT = 0x20000000, // 29 Spell can't crit
SPELL_ATTR2_TRIGGERED_CAN_TRIGGER_PROC = 0x40000000, // 30 spell can trigger even if triggered
SPELL_ATTR2_FOOD_BUFF = 0x80000000 // 31 Food or Drink Buff (like Well Fed)
@@ -472,7 +472,7 @@ enum SpellAttr5
SPELL_ATTR5_HASTE_AFFECT_DURATION = 0x00002000, // 13 haste effects decrease duration of this
SPELL_ATTR5_UNK14 = 0x00004000, // 14
SPELL_ATTR5_UNK15 = 0x00008000, // 15 Inflits on multiple targets?
- SPELL_ATTR5_SPECIAL_ITEM_CLASS_CHECK = 0x00010000, // 16 this allows spells with EquippedItemClass to affect spells from other items if the required item is equipped
+ SPELL_ATTR5_UNK16 = 0x00010000, // 16
SPELL_ATTR5_USABLE_WHILE_FEARED = 0x00020000, // 17 usable while feared
SPELL_ATTR5_USABLE_WHILE_CONFUSED = 0x00040000, // 18 usable while confused
SPELL_ATTR5_DONT_TURN_DURING_CAST = 0x00080000, // 19 Blocks caster's turning when casting (client does not automatically turn caster's model to face UNIT_FIELD_TARGET)
@@ -548,7 +548,7 @@ enum SpellAttr7
SPELL_ATTR7_UNK17 = 0x00020000, // 17 Only 27965 (Suicide) spell.
SPELL_ATTR7_HAS_CHARGE_EFFECT = 0x00040000, // 18 Only spells that have Charge among effects.
SPELL_ATTR7_ZONE_TELEPORT = 0x00080000, // 19 Teleports to specific zones.
- SPELL_ATTR7_UNK20 = 0x00100000, // 20 Blink, Divine Shield, Ice Block
+ SPELL_ATTR7_USABLE_IN_STUN_FEAR_CONFUSION = 0x00100000, // 20 Blink, Divine Shield, Ice Block
SPELL_ATTR7_UNK21 = 0x00200000, // 21 Not set
SPELL_ATTR7_UNK22 = 0x00400000, // 22
SPELL_ATTR7_UNK23 = 0x00800000, // 23 Motivate, Mutilate, Shattering Throw
@@ -1286,10 +1286,11 @@ enum SpellImmunity
IMMUNITY_DAMAGE = 3, // enum SpellSchoolMask
IMMUNITY_DISPEL = 4, // enum DispelType
IMMUNITY_MECHANIC = 5, // enum Mechanics
- IMMUNITY_ID = 6
+ IMMUNITY_ID = 6,
+
+ MAX_SPELL_IMMUNITY
};
-#define MAX_SPELL_IMMUNITY 7
// target enum name consist of:
// TARGET_[OBJECT_TYPE]_[REFERENCE_TYPE(skipped for caster)]_[SELECTION_TYPE(skipped for default)]_[additional specifiers(friendly, BACK_LEFT, etc.]
@@ -3136,7 +3137,9 @@ enum DiminishingGroup : uint16
DIMINISHING_SLEEP = 17,
DIMINISHING_TAUNT = 18,
DIMINISHING_LIMITONLY = 19,
- DIMINISHING_DRAGONS_BREATH = 20
+ DIMINISHING_DRAGONS_BREATH = 20,
+
+ DIMINISHING_MAX
};
enum SummonCategory
diff --git a/src/server/game/Movement/MovementGenerators/HomeMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/HomeMovementGenerator.cpp
index bae8e541ddc..61916504758 100644
--- a/src/server/game/Movement/MovementGenerators/HomeMovementGenerator.cpp
+++ b/src/server/game/Movement/MovementGenerators/HomeMovementGenerator.cpp
@@ -34,8 +34,8 @@ void HomeMovementGenerator<Creature>::DoFinalize(Creature* owner)
owner->ClearUnitState(UNIT_STATE_EVADE);
owner->SetWalk(true);
owner->LoadCreaturesAddon();
- owner->SetSpawnHealth();
owner->AI()->JustReachedHome();
+ owner->SetSpawnHealth();
}
}
diff --git a/src/server/game/Scripting/ScriptMgr.cpp b/src/server/game/Scripting/ScriptMgr.cpp
index 2737c852d98..b9357d60967 100644
--- a/src/server/game/Scripting/ScriptMgr.cpp
+++ b/src/server/game/Scripting/ScriptMgr.cpp
@@ -1202,12 +1202,11 @@ void ScriptMgr::FillSpellSummary()
}
}
-template<typename T, typename F>
-void CreateSpellOrAuraScripts(uint32 spellId, std::list<T*>& scriptVector, F&& extractor)
+template<typename T, typename F, typename O>
+void CreateSpellOrAuraScripts(uint32 spellId, std::vector<T*>& scriptVector, F&& extractor, O* objectInvoker)
{
SpellScriptsBounds bounds = sObjectMgr->GetSpellScriptsBounds(spellId);
-
- for (SpellScriptsContainer::iterator itr = bounds.first; itr != bounds.second; ++itr)
+ for (auto itr = bounds.first; itr != bounds.second; ++itr)
{
// When the script is disabled continue with the next one
if (!itr->second.second)
@@ -1218,24 +1217,28 @@ void CreateSpellOrAuraScripts(uint32 spellId, std::list<T*>& scriptVector, F&& e
continue;
T* script = (*tmpscript.*extractor)();
-
if (!script)
continue;
script->_Init(&tmpscript->GetName(), spellId);
+ if (!script->_Load(objectInvoker))
+ {
+ delete script;
+ continue;
+ }
scriptVector.push_back(script);
}
}
-void ScriptMgr::CreateSpellScripts(uint32 spellId, std::list<SpellScript*>& scriptVector)
+void ScriptMgr::CreateSpellScripts(uint32 spellId, std::vector<SpellScript*>& scriptVector, Spell* invoker) const
{
- CreateSpellOrAuraScripts(spellId, scriptVector, &SpellScriptLoader::GetSpellScript);
+ CreateSpellOrAuraScripts(spellId, scriptVector, &SpellScriptLoader::GetSpellScript, invoker);
}
-void ScriptMgr::CreateAuraScripts(uint32 spellId, std::list<AuraScript*>& scriptVector)
+void ScriptMgr::CreateAuraScripts(uint32 spellId, std::vector<AuraScript*>& scriptVector, Aura* invoker) const
{
- CreateSpellOrAuraScripts(spellId, scriptVector, &SpellScriptLoader::GetAuraScript);
+ CreateSpellOrAuraScripts(spellId, scriptVector, &SpellScriptLoader::GetAuraScript, invoker);
}
SpellScriptLoader* ScriptMgr::GetSpellScriptLoader(uint32 scriptId)
diff --git a/src/server/game/Scripting/ScriptMgr.h b/src/server/game/Scripting/ScriptMgr.h
index a6cce299645..22a84804089 100644
--- a/src/server/game/Scripting/ScriptMgr.h
+++ b/src/server/game/Scripting/ScriptMgr.h
@@ -29,6 +29,7 @@
class AccountMgr;
class AuctionHouseObject;
+class Aura;
class AuraScript;
class Battleground;
class BattlegroundMap;
@@ -896,8 +897,8 @@ class TC_GAME_API ScriptMgr
public: /* SpellScriptLoader */
- void CreateSpellScripts(uint32 spellId, std::list<SpellScript*>& scriptVector);
- void CreateAuraScripts(uint32 spellId, std::list<AuraScript*>& scriptVector);
+ void CreateSpellScripts(uint32 spellId, std::vector<SpellScript*>& scriptVector, Spell* invoker) const;
+ void CreateAuraScripts(uint32 spellId, std::vector<AuraScript*>& scriptVector, Aura* invoker) const;
SpellScriptLoader* GetSpellScriptLoader(uint32 scriptId);
public: /* ServerScript */
diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
index 28b26d42395..2b4e2e4177d 100644
--- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp
+++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
@@ -204,7 +204,7 @@ pAuraEffectHandler AuraEffectHandler[TOTAL_AURAS]=
&AuraEffect::HandleNoImmediateEffect, //144 SPELL_AURA_SAFE_FALL implemented in WorldSession::HandleMovementOpcodes
&AuraEffect::HandleAuraModPetTalentsPoints, //145 SPELL_AURA_MOD_PET_TALENT_POINTS
&AuraEffect::HandleNoImmediateEffect, //146 SPELL_AURA_ALLOW_TAME_PET_TYPE
- &AuraEffect::HandleModStateImmunityMask, //147 SPELL_AURA_MECHANIC_IMMUNITY_MASK
+ &AuraEffect::HandleModMechanicImmunityMask, //147 SPELL_AURA_MECHANIC_IMMUNITY_MASK
&AuraEffect::HandleAuraRetainComboPoints, //148 SPELL_AURA_RETAIN_COMBO_POINTS
&AuraEffect::HandleNoImmediateEffect, //149 SPELL_AURA_REDUCE_PUSHBACK
&AuraEffect::HandleShieldBlockValue, //150 SPELL_AURA_MOD_SHIELD_BLOCKVALUE_PCT
@@ -890,14 +890,12 @@ bool AuraEffect::IsAffectedOnSpell(SpellInfo const* spell) const
{
if (!spell)
return false;
- // Check family name
- if (spell->SpellFamilyName != m_spellInfo->SpellFamilyName)
+
+ // Check family name and EffectClassMask
+ if (!spell->IsAffected(m_spellInfo->SpellFamilyName, m_spellInfo->Effects[m_effIndex].SpellClassMask))
return false;
- // Check EffectClassMask
- if (m_spellInfo->Effects[m_effIndex].SpellClassMask & spell->SpellFamilyFlags)
- return true;
- return false;
+ return true;
}
void AuraEffect::SendTickImmune(Unit* target, Unit* caster) const
@@ -965,34 +963,64 @@ bool AuraEffect::CheckEffectProc(AuraApplication* aurApp, ProcEventInfo& eventIn
SpellInfo const* spellInfo = eventInfo.GetSpellInfo();
switch (GetAuraType())
{
+ case SPELL_AURA_MOD_CONFUSE:
+ case SPELL_AURA_MOD_FEAR:
+ case SPELL_AURA_MOD_STUN:
+ case SPELL_AURA_MOD_ROOT:
+ case SPELL_AURA_TRANSFORM:
+ {
+ DamageInfo* damageInfo = eventInfo.GetDamageInfo();
+ if (!damageInfo || !damageInfo->GetDamage())
+ return false;
+
+ // Spell own damage at apply won't break CC
+ if (spellInfo && spellInfo == GetSpellInfo())
+ {
+ Aura* aura = GetBase();
+ // called from spellcast, should not have ticked yet
+ if (aura->GetDuration() == aura->GetMaxDuration())
+ return false;
+ }
+ break;
+ }
case SPELL_AURA_MECHANIC_IMMUNITY:
case SPELL_AURA_MOD_MECHANIC_RESISTANCE:
// compare mechanic
if (!spellInfo || static_cast<int32>(spellInfo->Mechanic) != GetMiscValue())
- result = false;
+ return false;
break;
case SPELL_AURA_MOD_CASTING_SPEED_NOT_STACK:
// skip melee hits and instant cast spells
if (!spellInfo || !spellInfo->CalcCastTime())
- result = false;
+ return false;
break;
case SPELL_AURA_MOD_DAMAGE_FROM_CASTER:
// Compare casters
if (GetCasterGUID() != eventInfo.GetActor()->GetGUID())
- result = false;
+ return false;
break;
case SPELL_AURA_MOD_POWER_COST_SCHOOL:
case SPELL_AURA_MOD_POWER_COST_SCHOOL_PCT:
// Skip melee hits and spells with wrong school or zero cost
if (!spellInfo || (!spellInfo->ManaCost && !spellInfo->ManaCostPercentage) || // Cost Check
!(spellInfo->GetSchoolMask() & GetMiscValue())) // School Check
- result = false;
+ return false;
break;
case SPELL_AURA_REFLECT_SPELLS_SCHOOL:
// Skip melee hits and spells with wrong school
if (!spellInfo || !(spellInfo->GetSchoolMask() & GetMiscValue()))
- result = false;
+ return false;
+ break;
+ case SPELL_AURA_PROC_TRIGGER_SPELL:
+ case SPELL_AURA_PROC_TRIGGER_SPELL_WITH_VALUE:
+ {
+ // Don't proc extra attacks while already processing extra attack spell
+ uint32 triggerSpellId = GetSpellInfo()->Effects[GetEffIndex()].TriggerSpell;
+ if (SpellInfo const* triggeredSpellInfo = sSpellMgr->GetSpellInfo(triggerSpellId))
+ if (aurApp->GetTarget()->m_extraAttacks && triggeredSpellInfo->HasEffect(SPELL_EFFECT_ADD_EXTRA_ATTACKS))
+ return false;
break;
+ }
default:
break;
}
@@ -1143,15 +1171,15 @@ void AuraEffect::HandleShapeshiftBoosts(Unit* target, bool apply) const
if (apply)
{
if (spellId)
- target->CastSpell(target, spellId, true, NULL, this);
+ target->CastSpell(target, spellId, true, nullptr, this);
if (spellId2)
- target->CastSpell(target, spellId2, true, NULL, this);
+ target->CastSpell(target, spellId2, true, nullptr, this);
if (target->GetTypeId() == TYPEID_PLAYER)
{
- const PlayerSpellMap& sp_list = target->ToPlayer()->GetSpellMap();
- for (PlayerSpellMap::const_iterator itr = sp_list.begin(); itr != sp_list.end(); ++itr)
+ PlayerSpellMap const& sp_list = target->ToPlayer()->GetSpellMap();
+ for (auto itr = sp_list.begin(); itr != sp_list.end(); ++itr)
{
if (itr->second->state == PLAYERSPELL_REMOVED || itr->second->disabled)
continue;
@@ -1164,7 +1192,7 @@ void AuraEffect::HandleShapeshiftBoosts(Unit* target, bool apply) const
continue;
if (spellInfo->Stances & (UI64LIT(1) << (GetMiscValue() - 1)))
- target->CastSpell(target, itr->first, true, NULL, this);
+ target->CastSpell(target, itr->first, true, nullptr, this);
}
// Also do it for Glyphs
@@ -1179,7 +1207,7 @@ void AuraEffect::HandleShapeshiftBoosts(Unit* target, bool apply) const
continue;
if (spellInfo->Stances & (UI64LIT(1) << (GetMiscValue() - 1)))
- target->CastSpell(target, glyph->SpellId, true, NULL, this);
+ target->CastSpell(target, glyph->SpellId, true, nullptr, this);
}
}
}
@@ -1189,7 +1217,7 @@ void AuraEffect::HandleShapeshiftBoosts(Unit* target, bool apply) const
{
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(24932);
if (spellInfo && spellInfo->Stances & (UI64LIT(1) << (GetMiscValue() - 1)))
- target->CastSpell(target, 24932, true, NULL, this);
+ target->CastSpell(target, 24932, true, nullptr, this);
}
// Improved Barkskin - apply/remove armor bonus due to shapeshift
if (target->ToPlayer()->HasSpell(63410) || target->ToPlayer()->HasSpell(63411))
@@ -1202,14 +1230,14 @@ void AuraEffect::HandleShapeshiftBoosts(Unit* target, bool apply) const
if (HotWSpellId)
{ // hacky, but the only way as spell family is not SPELLFAMILY_DRUID
Unit::AuraEffectList const& mModTotalStatPct = target->GetAuraEffectsByType(SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE);
- for (Unit::AuraEffectList::const_iterator i = mModTotalStatPct.begin(); i != mModTotalStatPct.end(); ++i)
+ for (AuraEffect const* aurEff : mModTotalStatPct)
{
// Heart of the Wild
- if ((*i)->GetSpellInfo()->SpellIconID == 240 && (*i)->GetMiscValue() == 3)
+ if (aurEff->GetSpellInfo()->SpellIconID == 240 && aurEff->GetMiscValue() == 3)
{
- int32 HotWMod = (*i)->GetAmount() / 2; // For each 2% Intelligence, you get 1% stamina and 1% attack power.
+ int32 HotWMod = aurEff->GetAmount() / 2; // For each 2% Intelligence, you get 1% stamina and 1% attack power.
- target->CastCustomSpell(target, HotWSpellId, &HotWMod, NULL, NULL, true, NULL, this);
+ target->CastCustomSpell(HotWSpellId, SPELLVALUE_BASE_POINT0, HotWMod, target, true, nullptr, this);
break;
}
}
@@ -1233,13 +1261,13 @@ void AuraEffect::HandleShapeshiftBoosts(Unit* target, bool apply) const
spellId3 = 47180;
break;
}
- target->CastSpell(target, spellId3, true, NULL, this);
+ target->CastSpell(target, spellId3, true, nullptr, this);
}
// Master Shapeshifter - Cat
if (AuraEffect const* aurEff = target->GetDummyAuraEffect(SPELLFAMILY_GENERIC, 2851, 0))
{
int32 bp = aurEff->GetAmount();
- target->CastCustomSpell(target, 48420, &bp, NULL, NULL, true);
+ target->CastCustomSpell(48420, SPELLVALUE_BASE_POINT0, bp, target, true);
}
break;
case FORM_DIREBEAR:
@@ -1248,13 +1276,13 @@ void AuraEffect::HandleShapeshiftBoosts(Unit* target, bool apply) const
if (AuraEffect const* aurEff = target->GetDummyAuraEffect(SPELLFAMILY_GENERIC, 2851, 0))
{
int32 bp = aurEff->GetAmount();
- target->CastCustomSpell(target, 48418, &bp, NULL, NULL, true);
+ target->CastCustomSpell(48418, SPELLVALUE_BASE_POINT0, bp, target, true);
}
// Survival of the Fittest
if (AuraEffect const* aurEff = target->GetAuraEffect(SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE, SPELLFAMILY_DRUID, 961, 0))
{
int32 bp = aurEff->GetSpellInfo()->Effects[EFFECT_2].CalcValue();
- target->CastCustomSpell(target, 62069, &bp, NULL, NULL, true, 0, this);
+ target->CastCustomSpell(62069, SPELLVALUE_BASE_POINT0, bp, target, true, nullptr, this);
}
break;
case FORM_MOONKIN:
@@ -1262,7 +1290,7 @@ void AuraEffect::HandleShapeshiftBoosts(Unit* target, bool apply) const
if (AuraEffect const* aurEff = target->GetDummyAuraEffect(SPELLFAMILY_GENERIC, 2851, 0))
{
int32 bp = aurEff->GetAmount();
- target->CastCustomSpell(target, 48421, &bp, NULL, NULL, true);
+ target->CastCustomSpell(48421, SPELLVALUE_BASE_POINT0, bp, target, true);
}
break;
// Master Shapeshifter - Tree of Life
@@ -1270,7 +1298,7 @@ void AuraEffect::HandleShapeshiftBoosts(Unit* target, bool apply) const
if (AuraEffect const* aurEff = target->GetDummyAuraEffect(SPELLFAMILY_GENERIC, 2851, 0))
{
int32 bp = aurEff->GetAmount();
- target->CastCustomSpell(target, 48422, &bp, NULL, NULL, true);
+ target->CastCustomSpell(48422, SPELLVALUE_BASE_POINT0, bp, target, true);
}
break;
}
@@ -1284,7 +1312,7 @@ void AuraEffect::HandleShapeshiftBoosts(Unit* target, bool apply) const
target->RemoveOwnedAura(spellId2, target->GetGUID());
// Improved Barkskin - apply/remove armor bonus due to shapeshift
- if (Player* player=target->ToPlayer())
+ if (Player* player = target->ToPlayer())
{
if (player->HasSpell(63410) || player->HasSpell(63411))
{
@@ -1293,19 +1321,20 @@ void AuraEffect::HandleShapeshiftBoosts(Unit* target, bool apply) const
}
}
- const Unit::AuraEffectList& shapeshifts = target->GetAuraEffectsByType(SPELL_AURA_MOD_SHAPESHIFT);
- AuraEffect* newAura = NULL;
+ Unit::AuraEffectList const& shapeshifts = target->GetAuraEffectsByType(SPELL_AURA_MOD_SHAPESHIFT);
+ AuraEffect const* newAura = nullptr;
// Iterate through all the shapeshift auras that the target has, if there is another aura with SPELL_AURA_MOD_SHAPESHIFT, then this aura is being removed due to that one being applied
- for (Unit::AuraEffectList::const_iterator itr = shapeshifts.begin(); itr != shapeshifts.end(); ++itr)
+ for (AuraEffect const* aurEff : shapeshifts)
{
- if ((*itr) != this)
+ if (aurEff != this)
{
- newAura = *itr;
+ newAura = aurEff;
break;
}
}
+
Unit::AuraApplicationMap& tAuras = target->GetAppliedAuras();
- for (Unit::AuraApplicationMap::iterator itr = tAuras.begin(); itr != tAuras.end();)
+ for (auto itr = tAuras.begin(); itr != tAuras.end();)
{
// Use the new aura to see on what stance the target will be
uint64 newStance = newAura ? (UI64LIT(1) << (newAura->GetMiscValue() - 1)) : 0;
@@ -1746,7 +1775,12 @@ void AuraEffect::HandleAuraModShapeshift(AuraApplication const* aurApp, uint8 mo
if (aurApp->GetRemoveMode())
return;
+ ShapeshiftForm prevForm = target->GetShapeshiftForm();
target->SetShapeshiftForm(form);
+ // add the shapeshift aura's boosts
+ if (prevForm != form)
+ HandleShapeshiftBoosts(target, true);
+
if (modelid > 0)
{
SpellInfo const* transformSpellInfo = sSpellMgr->GetSpellInfo(target->getTransForm());
@@ -1818,11 +1852,10 @@ void AuraEffect::HandleAuraModShapeshift(AuraApplication const* aurApp, uint8 mo
default:
break;
}
- }
- // adding/removing linked auras
- // add/remove the shapeshift aura's boosts
- HandleShapeshiftBoosts(target, apply);
+ // remove the shapeshift aura's boosts
+ HandleShapeshiftBoosts(target, false);
+ }
if (target->GetTypeId() == TYPEID_PLAYER)
target->ToPlayer()->InitDataForForm();
@@ -2274,11 +2307,9 @@ void AuraEffect::HandleAuraModDisarm(AuraApplication const* aurApp, uint8 mode,
{
uint8 attacktype = Player::GetAttackBySlot(slot);
+ player->ApplyItemDependentAuras(item, !apply);
if (attacktype < MAX_ATTACK)
- {
player->_ApplyWeaponDamage(slot, item->GetTemplate(), NULL, !apply);
- player->_ApplyWeaponDependentAuraMods(item, WeaponAttackType(attacktype), !apply);
- }
}
}
@@ -3036,249 +3067,13 @@ void AuraEffect::HandleAuraModUseNormalSpeed(AuraApplication const* aurApp, uint
/*** IMMUNITY ***/
/*********************************************************/
-void AuraEffect::HandleModStateImmunityMask(AuraApplication const* aurApp, uint8 mode, bool apply) const
+void AuraEffect::HandleModMechanicImmunityMask(AuraApplication const* aurApp, uint8 mode, bool apply) const
{
if (!(mode & AURA_EFFECT_HANDLE_REAL))
return;
Unit* target = aurApp->GetTarget();
- std::list <AuraType> aura_immunity_list;
- uint32 mechanic_immunity_list = 0;
- int32 miscVal = GetMiscValue();
-
- switch (miscVal)
- {
- case 27:
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_SILENCE, apply);
- aura_immunity_list.push_back(SPELL_AURA_MOD_SILENCE);
- break;
- case 96:
- case 1615:
- {
- if (GetAmount())
- {
- mechanic_immunity_list = (1 << MECHANIC_SNARE) | (1 << MECHANIC_ROOT)
- | (1 << MECHANIC_FEAR) | (1 << MECHANIC_STUN)
- | (1 << MECHANIC_SLEEP) | (1 << MECHANIC_CHARM)
- | (1 << MECHANIC_SAPPED) | (1 << MECHANIC_HORROR)
- | (1 << MECHANIC_POLYMORPH) | (1 << MECHANIC_DISORIENTED)
- | (1 << MECHANIC_FREEZE) | (1 << MECHANIC_TURN);
-
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_SNARE, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_ROOT, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_FEAR, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_STUN, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_SLEEP, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_CHARM, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_SAPPED, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_HORROR, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_POLYMORPH, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_DISORIENTED, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_FREEZE, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_TURN, apply);
- aura_immunity_list.push_back(SPELL_AURA_MOD_STUN);
- aura_immunity_list.push_back(SPELL_AURA_MOD_DECREASE_SPEED);
- aura_immunity_list.push_back(SPELL_AURA_MOD_ROOT);
- aura_immunity_list.push_back(SPELL_AURA_MOD_CONFUSE);
- aura_immunity_list.push_back(SPELL_AURA_MOD_FEAR);
- }
- break;
- }
- case 679:
- {
- if (GetId() == 57742)
- {
- mechanic_immunity_list = (1 << MECHANIC_SNARE) | (1 << MECHANIC_ROOT)
- | (1 << MECHANIC_FEAR) | (1 << MECHANIC_STUN)
- | (1 << MECHANIC_SLEEP) | (1 << MECHANIC_CHARM)
- | (1 << MECHANIC_SAPPED) | (1 << MECHANIC_HORROR)
- | (1 << MECHANIC_POLYMORPH) | (1 << MECHANIC_DISORIENTED)
- | (1 << MECHANIC_FREEZE) | (1 << MECHANIC_TURN);
-
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_SNARE, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_ROOT, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_FEAR, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_STUN, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_SLEEP, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_CHARM, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_SAPPED, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_HORROR, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_POLYMORPH, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_DISORIENTED, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_FREEZE, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_TURN, apply);
- aura_immunity_list.push_back(SPELL_AURA_MOD_STUN);
- aura_immunity_list.push_back(SPELL_AURA_MOD_DECREASE_SPEED);
- aura_immunity_list.push_back(SPELL_AURA_MOD_ROOT);
- aura_immunity_list.push_back(SPELL_AURA_MOD_CONFUSE);
- aura_immunity_list.push_back(SPELL_AURA_MOD_FEAR);
- }
- break;
- }
- case 1557:
- {
- if (GetId() == 64187)
- {
- mechanic_immunity_list = (1 << MECHANIC_STUN);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_STUN, apply);
- aura_immunity_list.push_back(SPELL_AURA_MOD_STUN);
- }
- else
- {
- mechanic_immunity_list = (1 << MECHANIC_SNARE) | (1 << MECHANIC_ROOT)
- | (1 << MECHANIC_FEAR) | (1 << MECHANIC_STUN)
- | (1 << MECHANIC_SLEEP) | (1 << MECHANIC_CHARM)
- | (1 << MECHANIC_SAPPED) | (1 << MECHANIC_HORROR)
- | (1 << MECHANIC_POLYMORPH) | (1 << MECHANIC_DISORIENTED)
- | (1 << MECHANIC_FREEZE) | (1 << MECHANIC_TURN);
-
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_SNARE, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_ROOT, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_FEAR, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_STUN, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_SLEEP, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_CHARM, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_SAPPED, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_HORROR, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_POLYMORPH, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_DISORIENTED, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_FREEZE, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_TURN, apply);
- aura_immunity_list.push_back(SPELL_AURA_MOD_STUN);
- aura_immunity_list.push_back(SPELL_AURA_MOD_DECREASE_SPEED);
- aura_immunity_list.push_back(SPELL_AURA_MOD_ROOT);
- aura_immunity_list.push_back(SPELL_AURA_MOD_CONFUSE);
- aura_immunity_list.push_back(SPELL_AURA_MOD_FEAR);
- }
- break;
- }
- case 1614:
- case 1694:
- {
- target->ApplySpellImmune(GetId(), IMMUNITY_EFFECT, SPELL_EFFECT_ATTACK_ME, apply);
- aura_immunity_list.push_back(SPELL_AURA_MOD_TAUNT);
- break;
- }
- case 1630:
- {
- if (!GetAmount())
- {
- target->ApplySpellImmune(GetId(), IMMUNITY_EFFECT, SPELL_EFFECT_ATTACK_ME, apply);
- aura_immunity_list.push_back(SPELL_AURA_MOD_TAUNT);
- }
- else
- {
- mechanic_immunity_list = (1 << MECHANIC_SNARE) | (1 << MECHANIC_ROOT)
- | (1 << MECHANIC_FEAR) | (1 << MECHANIC_STUN)
- | (1 << MECHANIC_SLEEP) | (1 << MECHANIC_CHARM)
- | (1 << MECHANIC_SAPPED) | (1 << MECHANIC_HORROR)
- | (1 << MECHANIC_POLYMORPH) | (1 << MECHANIC_DISORIENTED)
- | (1 << MECHANIC_FREEZE) | (1 << MECHANIC_TURN);
-
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_SNARE, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_ROOT, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_FEAR, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_STUN, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_SLEEP, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_CHARM, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_SAPPED, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_HORROR, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_POLYMORPH, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_DISORIENTED, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_FREEZE, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_TURN, apply);
- aura_immunity_list.push_back(SPELL_AURA_MOD_STUN);
- aura_immunity_list.push_back(SPELL_AURA_MOD_DECREASE_SPEED);
- aura_immunity_list.push_back(SPELL_AURA_MOD_ROOT);
- aura_immunity_list.push_back(SPELL_AURA_MOD_CONFUSE);
- aura_immunity_list.push_back(SPELL_AURA_MOD_FEAR);
- }
- break;
- }
- case 477:
- case 1733:
- {
- if (!GetAmount())
- {
- mechanic_immunity_list = (1 << MECHANIC_SNARE) | (1 << MECHANIC_ROOT)
- | (1 << MECHANIC_FEAR) | (1 << MECHANIC_STUN)
- | (1 << MECHANIC_SLEEP) | (1 << MECHANIC_CHARM)
- | (1 << MECHANIC_SAPPED) | (1 << MECHANIC_HORROR)
- | (1 << MECHANIC_POLYMORPH) | (1 << MECHANIC_DISORIENTED)
- | (1 << MECHANIC_FREEZE) | (1 << MECHANIC_TURN);
-
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_SNARE, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_ROOT, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_FEAR, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_STUN, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_SLEEP, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_CHARM, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_SAPPED, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_HORROR, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_POLYMORPH, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_DISORIENTED, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_FREEZE, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_TURN, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_EFFECT, SPELL_EFFECT_KNOCK_BACK, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_EFFECT, SPELL_EFFECT_KNOCK_BACK_DEST, apply);
- aura_immunity_list.push_back(SPELL_AURA_MOD_STUN);
- aura_immunity_list.push_back(SPELL_AURA_MOD_DECREASE_SPEED);
- aura_immunity_list.push_back(SPELL_AURA_MOD_ROOT);
- aura_immunity_list.push_back(SPELL_AURA_MOD_CONFUSE);
- aura_immunity_list.push_back(SPELL_AURA_MOD_FEAR);
- }
- break;
- }
- case 878:
- {
- if (GetAmount() == 1)
- {
- mechanic_immunity_list = (1 << MECHANIC_SNARE) | (1 << MECHANIC_STUN)
- | (1 << MECHANIC_DISORIENTED) | (1 << MECHANIC_FREEZE);
-
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_SNARE, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_STUN, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_DISORIENTED, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_FREEZE, apply);
- aura_immunity_list.push_back(SPELL_AURA_MOD_STUN);
- aura_immunity_list.push_back(SPELL_AURA_MOD_DECREASE_SPEED);
- }
- break;
- }
- default:
- break;
- }
-
- if (aura_immunity_list.empty())
- {
- if (miscVal & (1<<10))
- aura_immunity_list.push_back(SPELL_AURA_MOD_STUN);
- if (miscVal & (1<<1))
- aura_immunity_list.push_back(SPELL_AURA_TRANSFORM);
-
- // These flag can be recognized wrong:
- if (miscVal & (1<<6))
- aura_immunity_list.push_back(SPELL_AURA_MOD_DECREASE_SPEED);
- if (miscVal & (1<<0))
- aura_immunity_list.push_back(SPELL_AURA_MOD_ROOT);
- if (miscVal & (1<<2))
- aura_immunity_list.push_back(SPELL_AURA_MOD_CONFUSE);
- if (miscVal & (1<<9))
- aura_immunity_list.push_back(SPELL_AURA_MOD_FEAR);
- if (miscVal & (1<<7))
- aura_immunity_list.push_back(SPELL_AURA_MOD_DISARM);
- }
-
- // apply immunities
- for (std::list <AuraType>::iterator iter = aura_immunity_list.begin(); iter != aura_immunity_list.end(); ++iter)
- target->ApplySpellImmune(GetId(), IMMUNITY_STATE, *iter, apply);
-
- if (apply && GetSpellInfo()->HasAttribute(SPELL_ATTR1_DISPEL_AURAS_ON_IMMUNITY))
- {
- target->RemoveAurasWithMechanic(mechanic_immunity_list, AURA_REMOVE_BY_DEFAULT, GetId());
- for (std::list <AuraType>::iterator iter = aura_immunity_list.begin(); iter != aura_immunity_list.end(); ++iter)
- target->RemoveAurasByType(*iter);
- }
+ m_spellInfo->ApplyAllSpellImmunitiesTo(target, GetEffIndex(), apply);
}
void AuraEffect::HandleModMechanicImmunity(AuraApplication const* aurApp, uint8 mode, bool apply) const
@@ -3287,52 +3082,7 @@ void AuraEffect::HandleModMechanicImmunity(AuraApplication const* aurApp, uint8
return;
Unit* target = aurApp->GetTarget();
- uint32 mechanic;
-
- switch (GetId())
- {
- case 34471: // The Beast Within
- case 19574: // Bestial Wrath
- mechanic = IMMUNE_TO_MOVEMENT_IMPAIRMENT_AND_LOSS_CONTROL_MASK;
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_CHARM, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_DISORIENTED, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_FEAR, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_ROOT, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_SLEEP, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_SNARE, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_STUN, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_FREEZE, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_KNOCKOUT, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_POLYMORPH, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_BANISH, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_SHACKLE, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_TURN, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_HORROR, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_DAZE, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_SAPPED, apply);
- break;
- case 42292: // PvP trinket
- case 59752: // Every Man for Himself
- case 53490: // Bullheaded
- mechanic = IMMUNE_TO_MOVEMENT_IMPAIRMENT_AND_LOSS_CONTROL_MASK;
- // Actually we should apply immunities here, too, but the aura has only 100 ms duration, so there is practically no point
- break;
- case 54508: // Demonic Empowerment
- mechanic = (1 << MECHANIC_SNARE) | (1 << MECHANIC_ROOT);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_SNARE, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_ROOT, apply);
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_STUN, apply);
- break;
- default:
- if (GetMiscValue() < 1)
- return;
- mechanic = 1 << GetMiscValue();
- target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, GetMiscValue(), apply);
- break;
- }
-
- if (apply && GetSpellInfo()->HasAttribute(SPELL_ATTR1_DISPEL_AURAS_ON_IMMUNITY))
- target->RemoveAurasWithMechanic(mechanic, AURA_REMOVE_BY_DEFAULT, GetId());
+ m_spellInfo->ApplyAllSpellImmunitiesTo(target, GetEffIndex(), apply);
}
void AuraEffect::HandleAuraModEffectImmunity(AuraApplication const* aurApp, uint8 mode, bool apply) const
@@ -3341,8 +3091,7 @@ void AuraEffect::HandleAuraModEffectImmunity(AuraApplication const* aurApp, uint
return;
Unit* target = aurApp->GetTarget();
-
- target->ApplySpellImmune(GetId(), IMMUNITY_EFFECT, GetMiscValue(), apply);
+ m_spellInfo->ApplyAllSpellImmunitiesTo(target, GetEffIndex(), apply);
// when removing flag aura, handle flag drop
Player* player = target->ToPlayer();
@@ -3364,11 +3113,7 @@ void AuraEffect::HandleAuraModStateImmunity(AuraApplication const* aurApp, uint8
return;
Unit* target = aurApp->GetTarget();
-
- target->ApplySpellImmune(GetId(), IMMUNITY_STATE, GetMiscValue(), apply);
-
- if (apply && GetSpellInfo()->HasAttribute(SPELL_ATTR1_DISPEL_AURAS_ON_IMMUNITY))
- target->RemoveAurasByType(AuraType(GetMiscValue()), ObjectGuid::Empty, GetBase());
+ m_spellInfo->ApplyAllSpellImmunitiesTo(target, GetEffIndex(), apply);
}
void AuraEffect::HandleAuraModSchoolImmunity(AuraApplication const* aurApp, uint8 mode, bool apply) const
@@ -3377,8 +3122,7 @@ void AuraEffect::HandleAuraModSchoolImmunity(AuraApplication const* aurApp, uint
return;
Unit* target = aurApp->GetTarget();
-
- target->ApplySpellImmune(GetId(), IMMUNITY_SCHOOL, GetMiscValue(), (apply));
+ m_spellInfo->ApplyAllSpellImmunitiesTo(target, GetEffIndex(), apply);
if (GetSpellInfo()->Mechanic == MECHANIC_BANISH)
{
@@ -3388,12 +3132,15 @@ void AuraEffect::HandleAuraModSchoolImmunity(AuraApplication const* aurApp, uint
{
bool banishFound = false;
Unit::AuraEffectList const& banishAuras = target->GetAuraEffectsByType(GetAuraType());
- for (Unit::AuraEffectList::const_iterator i = banishAuras.begin(); i != banishAuras.end(); ++i)
- if ((*i)->GetSpellInfo()->Mechanic == MECHANIC_BANISH)
+ for (AuraEffect const* aurEff : banishAuras)
+ {
+ if (aurEff->GetSpellInfo()->Mechanic == MECHANIC_BANISH)
{
banishFound = true;
break;
}
+ }
+
if (!banishFound)
target->ClearUnitState(UNIT_STATE_ISOLATED);
}
@@ -3406,23 +3153,6 @@ void AuraEffect::HandleAuraModSchoolImmunity(AuraApplication const* aurApp, uint
if (GetSpellInfo()->HasAttribute(SPELL_ATTR1_DISPEL_AURAS_ON_IMMUNITY)
&& GetSpellInfo()->HasAttribute(SPELL_ATTR2_DAMAGE_REDUCED_SHIELD))
target->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION);
-
- /// @todo optimalize this cycle - use RemoveAurasWithInterruptFlags call or something else
- if (apply
- && GetSpellInfo()->HasAttribute(SPELL_ATTR1_DISPEL_AURAS_ON_IMMUNITY)
- && GetSpellInfo()->IsPositive()) // Only positive immunity removes auras
- {
- uint32 schoolMask = GetMiscValue();
- target->RemoveAppliedAuras([this, schoolMask](AuraApplication const* aurApp)
- {
- SpellInfo const* spell = aurApp->GetBase()->GetSpellInfo();
- return (spell->GetSchoolMask() & schoolMask) // Check for school mask
- && GetSpellInfo()->CanDispelAura(spell)
- && !aurApp->IsPositive() // Don't remove positive spells
- && !spell->IsPassive() // Don't remove passive auras
- && spell->Id != GetId(); // Don't remove self
- });
- }
}
void AuraEffect::HandleAuraModDmgImmunity(AuraApplication const* aurApp, uint8 mode, bool apply) const
@@ -3431,8 +3161,7 @@ void AuraEffect::HandleAuraModDmgImmunity(AuraApplication const* aurApp, uint8 m
return;
Unit* target = aurApp->GetTarget();
-
- target->ApplySpellImmune(GetId(), IMMUNITY_DAMAGE, GetMiscValue(), apply);
+ m_spellInfo->ApplyAllSpellImmunitiesTo(target, GetEffIndex(), apply);
}
void AuraEffect::HandleAuraModDispelImmunity(AuraApplication const* aurApp, uint8 mode, bool apply) const
@@ -3441,8 +3170,7 @@ void AuraEffect::HandleAuraModDispelImmunity(AuraApplication const* aurApp, uint
return;
Unit* target = aurApp->GetTarget();
-
- target->ApplySpellDispelImmunity(m_spellInfo, DispelType(GetMiscValue()), (apply));
+ m_spellInfo->ApplyAllSpellImmunitiesTo(target, GetEffIndex(), apply);
}
/*********************************************************/
@@ -4038,29 +3766,14 @@ void AuraEffect::HandleAuraModWeaponCritPercent(AuraApplication const* aurApp, u
if (!(mode & (AURA_EFFECT_HANDLE_CHANGE_AMOUNT_MASK | AURA_EFFECT_HANDLE_STAT)))
return;
- Unit* target = aurApp->GetTarget();
+ Player* target = aurApp->GetTarget()->ToPlayer();
- if (target->GetTypeId() != TYPEID_PLAYER)
+ if (!target)
return;
- for (int i = 0; i < MAX_ATTACK; ++i)
- if (Item* pItem = target->ToPlayer()->GetWeaponForAttack(WeaponAttackType(i), true))
- target->ToPlayer()->_ApplyWeaponDependentAuraCritMod(pItem, WeaponAttackType(i), this, apply);
-
- // mods must be applied base at equipped weapon class and subclass comparison
- // with spell->EquippedItemClass and EquippedItemSubClassMask and EquippedItemInventoryTypeMask
- // GetMiscValue() comparison with item generated damage types
-
- if (GetSpellInfo()->EquippedItemClass == -1)
- {
- target->ToPlayer()->HandleBaseModValue(CRIT_PERCENTAGE, FLAT_MOD, float (GetAmount()), apply);
- target->ToPlayer()->HandleBaseModValue(OFFHAND_CRIT_PERCENTAGE, FLAT_MOD, float (GetAmount()), apply);
- target->ToPlayer()->HandleBaseModValue(RANGED_CRIT_PERCENTAGE, FLAT_MOD, float (GetAmount()), apply);
- }
- else
- {
- // done in Player::_ApplyWeaponDependentAuraMods
- }
+ target->HandleBaseModValue(CRIT_PERCENTAGE, FLAT_MOD, float(GetAmount()), apply);
+ target->HandleBaseModValue(OFFHAND_CRIT_PERCENTAGE, FLAT_MOD, float(GetAmount()), apply);
+ target->HandleBaseModValue(RANGED_CRIT_PERCENTAGE, FLAT_MOD, float(GetAmount()), apply);
}
void AuraEffect::HandleModHitChance(AuraApplication const* aurApp, uint8 mode, bool apply) const
@@ -4361,6 +4074,7 @@ void AuraEffect::HandleAuraModAttackPowerOfArmor(AuraApplication const* aurApp,
if (target->GetTypeId() == TYPEID_PLAYER)
target->ToPlayer()->UpdateAttackPowerAndDamage(false);
}
+
/********************************/
/*** DAMAGE BONUS ***/
/********************************/
@@ -4371,79 +4085,22 @@ void AuraEffect::HandleModDamageDone(AuraApplication const* aurApp, uint8 mode,
Unit* target = aurApp->GetTarget();
- // apply item specific bonuses for already equipped weapon
- if (target->GetTypeId() == TYPEID_PLAYER)
- {
- for (int i = 0; i < MAX_ATTACK; ++i)
- if (Item* pItem = target->ToPlayer()->GetWeaponForAttack(WeaponAttackType(i), true))
- target->ToPlayer()->_ApplyWeaponDependentAuraDamageMod(pItem, WeaponAttackType(i), this, apply);
- }
-
- // GetMiscValue() is bitmask of spell schools
- // 1 (0-bit) - normal school damage (SPELL_SCHOOL_MASK_NORMAL)
- // 126 - full bitmask all magic damages (SPELL_SCHOOL_MASK_MAGIC) including wands
- // 127 - full bitmask any damages
- //
- // mods must be applied base at equipped weapon class and subclass comparison
- // with spell->EquippedItemClass and EquippedItemSubClassMask and EquippedItemInventoryTypeMask
- // GetMiscValue() comparison with item generated damage types
-
- if ((GetMiscValue() & SPELL_SCHOOL_MASK_NORMAL) != 0)
- {
- // apply generic physical damage bonuses including wand case
- if (GetSpellInfo()->EquippedItemClass == -1 || target->GetTypeId() != TYPEID_PLAYER)
- {
- target->HandleStatModifier(UNIT_MOD_DAMAGE_MAINHAND, TOTAL_VALUE, float(GetAmount()), apply);
- target->HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND, TOTAL_VALUE, float(GetAmount()), apply);
- target->HandleStatModifier(UNIT_MOD_DAMAGE_RANGED, TOTAL_VALUE, float(GetAmount()), apply);
-
- if (target->GetTypeId() == TYPEID_PLAYER)
- {
- if (GetAmount() > 0)
- target->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS, GetAmount(), apply);
- else
- target->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG, GetAmount(), apply);
- }
- }
- else
- {
- // done in Player::_ApplyWeaponDependentAuraMods
- }
- }
-
- // Skip non magic case for speedup
- if ((GetMiscValue() & SPELL_SCHOOL_MASK_MAGIC) == 0)
- return;
-
- if (GetSpellInfo()->EquippedItemClass != -1 || GetSpellInfo()->EquippedItemInventoryTypeMask != 0)
+ if (GetMiscValue() & SPELL_SCHOOL_MASK_NORMAL)
{
- // wand magic case (skip generic to all item spell bonuses)
- // done in Player::_ApplyWeaponDependentAuraMods
-
- // Skip item specific requirements for not wand magic damage
- return;
+ target->HandleStatModifier(UNIT_MOD_DAMAGE_MAINHAND, TOTAL_VALUE, float(GetAmount()), apply);
+ target->HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND, TOTAL_VALUE, float(GetAmount()), apply);
+ target->HandleStatModifier(UNIT_MOD_DAMAGE_RANGED, TOTAL_VALUE, float(GetAmount()), apply);
}
- // Magic damage modifiers implemented in Unit::SpellDamageBonus
+ // Magic damage modifiers implemented in Unit::SpellBaseDamageBonusDone
// This information for client side use only
if (target->GetTypeId() == TYPEID_PLAYER)
{
- if (GetAmount() > 0)
- {
- for (int i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; i++)
- {
- if ((GetMiscValue() & (1<<i)) != 0)
- target->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS+i, GetAmount(), apply);
- }
- }
- else
- {
- for (int i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; i++)
- {
- if ((GetMiscValue() & (1<<i)) != 0)
- target->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG+i, GetAmount(), apply);
- }
- }
+ uint16 baseField = GetAmount() >= 0 ? PLAYER_FIELD_MOD_DAMAGE_DONE_POS : PLAYER_FIELD_MOD_DAMAGE_DONE_NEG;
+ for (uint16 i = 0; i < MAX_SPELL_SCHOOL; ++i)
+ if (GetMiscValue() & (1 << i))
+ target->ApplyModUInt32Value(baseField + i, GetAmount(), apply);
+
if (Guardian* pet = target->ToPlayer()->GetGuardianPet())
pet->UpdateAttackPowerAndDamage();
}
@@ -4459,14 +4116,7 @@ void AuraEffect::HandleModDamagePercentDone(AuraApplication const* aurApp, uint8
if (abs(spellGroupVal) >= abs(GetAmount()))
return;
- if (target->GetTypeId() == TYPEID_PLAYER)
- {
- for (int i = 0; i < MAX_ATTACK; ++i)
- if (Item* item = target->ToPlayer()->GetWeaponForAttack(WeaponAttackType(i), false))
- target->ToPlayer()->_ApplyWeaponDependentAuraDamageMod(item, WeaponAttackType(i), this, apply);
- }
-
- if ((GetMiscValue() & SPELL_SCHOOL_MASK_NORMAL) && (GetSpellInfo()->EquippedItemClass == -1 || target->GetTypeId() != TYPEID_PLAYER))
+ if (GetMiscValue() & SPELL_SCHOOL_MASK_NORMAL)
{
if (spellGroupVal)
{
@@ -4474,22 +4124,25 @@ void AuraEffect::HandleModDamagePercentDone(AuraApplication const* aurApp, uint8
target->HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND, TOTAL_PCT, float(spellGroupVal), !apply);
target->HandleStatModifier(UNIT_MOD_DAMAGE_RANGED, TOTAL_PCT, float(spellGroupVal), !apply);
}
+
target->HandleStatModifier(UNIT_MOD_DAMAGE_MAINHAND, TOTAL_PCT, float(GetAmount()), apply);
target->HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND, TOTAL_PCT, float(GetAmount()), apply);
target->HandleStatModifier(UNIT_MOD_DAMAGE_RANGED, TOTAL_PCT, float(GetAmount()), apply);
+ }
- if (Player* player = target->ToPlayer())
+ if (target->GetTypeId() == TYPEID_PLAYER)
+ {
+ for (uint16 i = 0; i < MAX_SPELL_SCHOOL; ++i)
{
- if (spellGroupVal)
- player->ApplyPercentModFloatValue(PLAYER_FIELD_MOD_DAMAGE_DONE_PCT, float(spellGroupVal), !apply);
+ if (GetMiscValue() & (1 << i))
+ {
+ if (spellGroupVal)
+ target->ApplyPercentModFloatValue(PLAYER_FIELD_MOD_DAMAGE_DONE_PCT + i, float(spellGroupVal), !apply);
- player->ApplyPercentModFloatValue(PLAYER_FIELD_MOD_DAMAGE_DONE_PCT, float(GetAmount()), apply);
+ target->ApplyPercentModFloatValue(PLAYER_FIELD_MOD_DAMAGE_DONE_PCT + i, float(GetAmount()), apply);
+ }
}
}
- else
- {
- // done in Player::_ApplyWeaponDependentAuraMods for SPELL_SCHOOL_MASK_NORMAL && EquippedItemClass != -1 and also for wand case
- }
}
void AuraEffect::HandleModOffhandDamagePercent(AuraApplication const* aurApp, uint8 mode, bool apply) const
@@ -5413,13 +5066,11 @@ void AuraEffect::HandlePeriodicDummyAuraTick(Unit* target, Unit* caster) const
{
// Master of Subtlety
case 31666:
- if (!target->HasAuraType(SPELL_AURA_MOD_STEALTH))
- target->RemoveAurasDueToSpell(31665);
+ target->RemoveAurasDueToSpell(31665);
break;
// Overkill
case 58428:
- if (!target->HasAuraType(SPELL_AURA_MOD_STEALTH))
- target->RemoveAurasDueToSpell(58427);
+ target->RemoveAurasDueToSpell(58427);
break;
}
break;
@@ -5816,8 +5467,6 @@ void AuraEffect::HandlePeriodicDamageAurasTick(Unit* target, Unit* caster) const
}
}
- uint32 absorb = 0;
- uint32 resist = 0;
CleanDamage cleanDamage = CleanDamage(0, 0, BASE_ATTACK, MELEE_HIT_NORMAL);
// AOE spells are not affected by the new periodic system.
@@ -5912,13 +5561,16 @@ void AuraEffect::HandlePeriodicDamageAurasTick(Unit* target, Unit* caster) const
damage = caster->SpellCriticalDamageBonus(m_spellInfo, damage, target);
int32 dmg = damage;
-
if (!GetSpellInfo()->HasAttribute(SPELL_ATTR4_FIXED_DAMAGE))
- caster->ApplyResilience(target, NULL, &dmg, crit, CR_CRIT_TAKEN_SPELL);
+ caster->ApplyResilience(target, nullptr, &dmg, crit, CR_CRIT_TAKEN_SPELL);
damage = dmg;
- caster->CalcAbsorbResist(target, GetSpellInfo()->GetSchoolMask(), DOT, damage, &absorb, &resist, GetSpellInfo());
+ DamageInfo damageInfo(caster, target, damage, GetSpellInfo(), GetSpellInfo()->GetSchoolMask(), DOT, BASE_ATTACK);
+ caster->CalcAbsorbResist(damageInfo);
+ damage = damageInfo.GetDamage();
+ uint32 absorb = damageInfo.GetAbsorb();
+ uint32 resist = damageInfo.GetResist();
TC_LOG_DEBUG("spells.periodic", "PeriodicTick: %s attacked %s for %u dmg inflicted by %u absorb is %u",
GetCasterGUID().ToString().c_str(), target->GetGUID().ToString().c_str(), damage, GetId(), absorb);
@@ -5927,10 +5579,12 @@ void AuraEffect::HandlePeriodicDamageAurasTick(Unit* target, Unit* caster) const
// Set trigger flag
uint32 procAttacker = PROC_FLAG_DONE_PERIODIC;
uint32 procVictim = PROC_FLAG_TAKEN_PERIODIC;
- uint32 hitMask = crit ? PROC_HIT_CRITICAL : PROC_HIT_NORMAL;
- damage = (damage <= absorb+resist) ? 0 : (damage-absorb-resist);
+ uint32 hitMask = damageInfo.GetHitMask();
if (damage)
+ {
+ hitMask |= crit ? PROC_HIT_CRITICAL : PROC_HIT_NORMAL;
procVictim |= PROC_FLAG_TAKEN_DAMAGE;
+ }
int32 overkill = damage - target->GetHealth();
if (overkill < 0)
@@ -5939,7 +5593,6 @@ void AuraEffect::HandlePeriodicDamageAurasTick(Unit* target, Unit* caster) const
SpellPeriodicAuraLogInfo pInfo(this, damage, overkill, absorb, resist, 0.0f, crit);
target->SendPeriodicAuraLog(&pInfo);
- DamageInfo damageInfo(caster, target, damage, GetSpellInfo(), GetSpellInfo()->GetSchoolMask(), DOT, BASE_ATTACK);
caster->ProcSkillsAndAuras(target, procAttacker, procVictim, PROC_SPELL_TYPE_DAMAGE, PROC_SPELL_PHASE_NONE, hitMask, nullptr, &damageInfo, nullptr);
caster->DealDamage(target, damage, &cleanDamage, DOT, GetSpellInfo()->GetSchoolMask(), GetSpellInfo(), true);
@@ -5960,8 +5613,6 @@ void AuraEffect::HandlePeriodicHealthLeechAuraTick(Unit* target, Unit* caster) c
caster->SpellHitResult(target, GetSpellInfo(), false) != SPELL_MISS_NONE)
return;
- uint32 absorb = 0;
- uint32 resist = 0;
CleanDamage cleanDamage = CleanDamage(0, 0, BASE_ATTACK, MELEE_HIT_NORMAL);
bool isAreaAura = m_spellInfo->Effects[m_effIndex].IsAreaAuraEffect() || m_spellInfo->Effects[m_effIndex].IsEffect(SPELL_EFFECT_PERSISTENT_AREA_AURA);
@@ -5976,6 +5627,9 @@ void AuraEffect::HandlePeriodicHealthLeechAuraTick(Unit* target, Unit* caster) c
else
damage = std::max(int32(damage * GetDonePct()), 0);
+ if (Player* modOwner = caster->GetSpellModOwner())
+ modOwner->ApplySpellMod<SPELLMOD_DOT>(GetSpellInfo()->Id, damage);
+
damage = target->SpellDamageBonusTaken(caster, GetSpellInfo(), damage, DOT, GetBase()->GetStackAmount());
// Calculate armor mitigation
@@ -5987,12 +5641,14 @@ void AuraEffect::HandlePeriodicHealthLeechAuraTick(Unit* target, Unit* caster) c
}
if (!m_spellInfo->HasAttribute(SPELL_ATTR4_FIXED_DAMAGE))
+ {
if (m_spellInfo->Effects[m_effIndex].IsTargetingArea() || isAreaAura)
{
damage = uint32(float(damage) * target->GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_AOE_DAMAGE_AVOIDANCE, m_spellInfo->SchoolMask));
if (caster->GetTypeId() != TYPEID_PLAYER)
damage = uint32(float(damage) * target->GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_CREATURE_AOE_DAMAGE_AVOIDANCE, m_spellInfo->SchoolMask));
}
+ }
bool crit = false;
@@ -6004,29 +5660,33 @@ void AuraEffect::HandlePeriodicHealthLeechAuraTick(Unit* target, Unit* caster) c
int32 dmg = damage;
if (!GetSpellInfo()->HasAttribute(SPELL_ATTR4_FIXED_DAMAGE))
- caster->ApplyResilience(target, NULL, &dmg, crit, CR_CRIT_TAKEN_SPELL);
+ caster->ApplyResilience(target, nullptr, &dmg, crit, CR_CRIT_TAKEN_SPELL);
damage = dmg;
- caster->CalcAbsorbResist(target, GetSpellInfo()->GetSchoolMask(), DOT, damage, &absorb, &resist, m_spellInfo);
+ DamageInfo damageInfo(caster, target, damage, GetSpellInfo(), GetSpellInfo()->GetSchoolMask(), DOT, BASE_ATTACK);
+ caster->CalcAbsorbResist(damageInfo);
+ uint32 absorb = damageInfo.GetAbsorb();
+ uint32 resist = damageInfo.GetResist();
TC_LOG_DEBUG("spells.periodic", "PeriodicTick: %s health leech of %s for %u dmg inflicted by %u abs is %u",
GetCasterGUID().ToString().c_str(), target->GetGUID().ToString().c_str(), damage, GetId(), absorb);
+ // SendSpellNonMeleeDamageLog expects non-absorbed/non-resisted damage
caster->SendSpellNonMeleeDamageLog(target, GetId(), damage, GetSpellInfo()->GetSchoolMask(), absorb, resist, false, 0, crit);
+ damage = damageInfo.GetDamage();
// Set trigger flag
uint32 procAttacker = PROC_FLAG_DONE_PERIODIC;
uint32 procVictim = PROC_FLAG_TAKEN_PERIODIC;
- uint32 hitMask = crit ? PROC_HIT_CRITICAL : PROC_HIT_NORMAL;
- damage = (damage <= absorb+resist) ? 0 : (damage-absorb-resist);
+ uint32 hitMask = damageInfo.GetHitMask();
if (damage)
+ {
+ hitMask |= crit ? PROC_HIT_CRITICAL : PROC_HIT_NORMAL;
procVictim |= PROC_FLAG_TAKEN_DAMAGE;
+ }
if (caster->IsAlive())
- {
- DamageInfo damageInfo(caster, target, damage, GetSpellInfo(), GetSpellInfo()->GetSchoolMask(), DOT, BASE_ATTACK);
caster->ProcSkillsAndAuras(target, procAttacker, procVictim, PROC_SPELL_TYPE_DAMAGE, PROC_SPELL_PHASE_NONE, hitMask, nullptr, &damageInfo, nullptr);
- }
int32 new_damage = caster->DealDamage(target, damage, &cleanDamage, DOT, GetSpellInfo()->GetSchoolMask(), GetSpellInfo(), false);
if (caster->IsAlive())
@@ -6399,23 +6059,12 @@ void AuraEffect::HandlePeriodicPowerBurnAuraTick(Unit* target, Unit* caster) con
void AuraEffect::HandleBreakableCCAuraProc(AuraApplication* aurApp, ProcEventInfo& eventInfo)
{
- DamageInfo* damageInfo = eventInfo.GetDamageInfo();
- if (!damageInfo)
- return;
-
- // aura own damage at apply won't break CC
- if (eventInfo.GetSpellPhaseMask() & PROC_SPELL_PHASE_CAST)
- {
- if (SpellInfo const* spellInfo = eventInfo.GetSpellInfo())
- if (spellInfo == GetSpellInfo())
- return;
- }
+ int32 const damageLeft = GetAmount() - static_cast<int32>(eventInfo.GetDamageInfo()->GetDamage());
- int32 damageLeft = GetAmount();
- if (damageLeft < int32(damageInfo->GetDamage()))
+ if (damageLeft <= 0)
aurApp->GetTarget()->RemoveAura(aurApp);
else
- SetAmount(damageLeft - damageInfo->GetDamage());
+ SetAmount(damageLeft);
}
void AuraEffect::HandleProcTriggerSpellAuraProc(AuraApplication* aurApp, ProcEventInfo& eventInfo)
@@ -6456,6 +6105,12 @@ void AuraEffect::HandleProcTriggerDamageAuraProc(AuraApplication* aurApp, ProcEv
Unit* target = aurApp->GetTarget();
Unit* triggerTarget = eventInfo.GetProcTarget();
+ if (triggerTarget->HasUnitState(UNIT_STATE_ISOLATED) || triggerTarget->IsImmunedToDamage(GetSpellInfo()))
+ {
+ SendTickImmune(triggerTarget, target);
+ return;
+ }
+
SpellNonMeleeDamage damageInfo(target, triggerTarget, GetId(), GetSpellInfo()->SchoolMask);
uint32 damage = target->SpellDamageBonusDone(triggerTarget, GetSpellInfo(), GetAmount(), SPELL_DIRECT_DAMAGE);
damage = triggerTarget->SpellDamageBonusTaken(target, GetSpellInfo(), damage, SPELL_DIRECT_DAMAGE);
diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.h b/src/server/game/Spells/Auras/SpellAuraEffects.h
index 2bfdde97b4b..05bfe7c0534 100644
--- a/src/server/game/Spells/Auras/SpellAuraEffects.h
+++ b/src/server/game/Spells/Auras/SpellAuraEffects.h
@@ -198,7 +198,7 @@ class TC_GAME_API AuraEffect
void HandleAuraModDecreaseSpeed(AuraApplication const* aurApp, uint8 mode, bool apply) const;
void HandleAuraModUseNormalSpeed(AuraApplication const* aurApp, uint8 mode, bool apply) const;
// immunity
- void HandleModStateImmunityMask(AuraApplication const* aurApp, uint8 mode, bool apply) const;
+ void HandleModMechanicImmunityMask(AuraApplication const* aurApp, uint8 mode, bool apply) const;
void HandleModMechanicImmunity(AuraApplication const* aurApp, uint8 mode, bool apply) const;
void HandleAuraModEffectImmunity(AuraApplication const* aurApp, uint8 mode, bool apply) const;
void HandleAuraModStateImmunity(AuraApplication const* aurApp, uint8 mode, bool apply) const;
diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp
index 2a6545520ae..45ea44f1dfb 100644
--- a/src/server/game/Spells/Auras/SpellAuras.cpp
+++ b/src/server/game/Spells/Auras/SpellAuras.cpp
@@ -360,7 +360,7 @@ m_procCooldown(std::chrono::steady_clock::time_point::min())
AuraScript* Aura::GetScriptByName(std::string const& scriptName) const
{
- for (std::list<AuraScript*>::const_iterator itr = m_loadedScripts.begin(); itr != m_loadedScripts.end(); ++itr)
+ for (auto itr = m_loadedScripts.begin(); itr != m_loadedScripts.end(); ++itr)
if ((*itr)->_GetScriptName()->compare(scriptName) == 0)
return *itr;
return NULL;
@@ -381,12 +381,10 @@ void Aura::_InitEffects(uint8 effMask, Unit* caster, int32 *baseAmount)
Aura::~Aura()
{
// unload scripts
- while (!m_loadedScripts.empty())
+ for (auto itr = m_loadedScripts.begin(); itr != m_loadedScripts.end(); ++itr)
{
- std::list<AuraScript*>::iterator itr = m_loadedScripts.begin();
(*itr)->_Unload();
delete (*itr);
- m_loadedScripts.erase(itr);
}
// free effects memory
@@ -490,37 +488,36 @@ void Aura::UpdateTargetMap(Unit* caster, bool apply)
m_updateTargetMapInterval = UPDATE_TARGET_MAP_INTERVAL;
// fill up to date target list
- // target, effMask
- std::map<Unit*, uint8> targets;
-
+ // target, effMask
+ std::unordered_map<Unit*, uint8> targets;
FillTargetMap(targets, caster);
- UnitList targetsToRemove;
+ std::deque<Unit*> targetsToRemove;
// mark all auras as ready to remove
for (ApplicationMap::iterator appIter = m_applications.begin(); appIter != m_applications.end();++appIter)
{
- std::map<Unit*, uint8>::iterator existing = targets.find(appIter->second->GetTarget());
+ auto itr = targets.find(appIter->second->GetTarget());
// not found in current area - remove the aura
- if (existing == targets.end())
+ if (itr == targets.end())
targetsToRemove.push_back(appIter->second->GetTarget());
else
{
// needs readding - remove now, will be applied in next update cycle
// (dbcs do not have auras which apply on same type of targets but have different radius, so this is not really needed)
- if (appIter->second->GetEffectMask() != existing->second || !CanBeAppliedOn(existing->first))
+ if (appIter->second->GetEffectMask() != itr->second || !CanBeAppliedOn(itr->first))
targetsToRemove.push_back(appIter->second->GetTarget());
// nothing todo - aura already applied
// remove from auras to register list
- targets.erase(existing);
+ targets.erase(itr);
}
}
// register auras for units
- for (std::map<Unit*, uint8>::iterator itr = targets.begin(); itr!= targets.end();)
+ for (auto itr = targets.begin(); itr!= targets.end();)
{
// aura mustn't be already applied on target
- if (AuraApplication * aurApp = GetApplicationOfTarget(itr->first->GetGUID()))
+ if (AuraApplication* aurApp = GetApplicationOfTarget(itr->first->GetGUID()))
{
// the core created 2 different units with same guid
// this is a major failue, which i can't fix right now
@@ -530,7 +527,7 @@ void Aura::UpdateTargetMap(Unit* caster, bool apply)
if (aurApp->GetTarget() != itr->first)
{
// remove from auras to register list
- targets.erase(itr++);
+ itr = targets.erase(itr);
continue;
}
else
@@ -584,7 +581,7 @@ void Aura::UpdateTargetMap(Unit* caster, bool apply)
}
}
if (!addUnit)
- targets.erase(itr++);
+ itr = targets.erase(itr);
else
{
// owner has to be in world, or effect has to be applied to self
@@ -602,17 +599,17 @@ void Aura::UpdateTargetMap(Unit* caster, bool apply)
}
// remove auras from units no longer needing them
- for (UnitList::iterator itr = targetsToRemove.begin(); itr != targetsToRemove.end();++itr)
- if (AuraApplication * aurApp = GetApplicationOfTarget((*itr)->GetGUID()))
- (*itr)->_UnapplyAura(aurApp, AURA_REMOVE_BY_DEFAULT);
+ for (Unit* unit : targetsToRemove)
+ if (AuraApplication* aurApp = GetApplicationOfTarget(unit->GetGUID()))
+ unit->_UnapplyAura(aurApp, AURA_REMOVE_BY_DEFAULT);
if (!apply)
return;
// apply aura effects for units
- for (std::map<Unit*, uint8>::iterator itr = targets.begin(); itr!= targets.end();++itr)
+ for (auto itr = targets.begin(); itr!= targets.end(); ++itr)
{
- if (AuraApplication * aurApp = GetApplicationOfTarget(itr->first->GetGUID()))
+ if (AuraApplication* aurApp = GetApplicationOfTarget(itr->first->GetGUID()))
{
// owner has to be in world, or effect has to be applied to self
ASSERT((!GetOwner()->IsInWorld() && GetOwner() == itr->first) || GetOwner()->IsInMap(itr->first));
@@ -988,6 +985,10 @@ bool Aura::CanBeSaved() const
if (IsUsingCharges() && !GetCharges())
return false;
+ // don't save permanent auras triggered by items, they'll be recasted on login if necessary
+ if (GetCastItemGUID() && IsPermanent())
+ return false;
+
return true;
}
@@ -1292,20 +1293,27 @@ void Aura::HandleAuraSpecificMods(AuraApplication const* aurApp, Unit* caster, b
case SPELLFAMILY_PRIEST:
if (!caster)
break;
+
// Devouring Plague
- if (GetSpellInfo()->SpellFamilyFlags[0] & 0x02000000 && GetEffect(0))
+ if (GetSpellInfo()->SpellFamilyFlags[0] & 0x02000000)
{
+ AuraEffect const* devouringPlague = GetEffect(EFFECT_0);
+ if (!devouringPlague)
+ break;
+
// Improved Devouring Plague
if (AuraEffect const* aurEff = caster->GetDummyAuraEffect(SPELLFAMILY_PRIEST, 3790, 1))
{
- uint32 damage = caster->SpellDamageBonusDone(target, GetSpellInfo(), GetEffect(0)->GetAmount(), DOT);
- damage *= caster->SpellDamagePctDone(target, GetSpellInfo(), SPELL_DIRECT_DAMAGE);
+ int32 damage = (devouringPlague->GetAmount() + devouringPlague->GetBonusAmount()) * devouringPlague->GetDonePct();
+ if (Player* modOwner = caster->GetSpellModOwner())
+ modOwner->ApplySpellMod<SPELLMOD_DOT>(GetSpellInfo()->Id, damage);
+
damage = target->SpellDamageBonusTaken(caster, GetSpellInfo(), damage, DOT);
- int32 basepoints0 = aurEff->GetAmount() * GetEffect(0)->GetTotalTicks() * int32(damage) / 100;
- int32 heal = int32(CalculatePct(basepoints0, 15));
- caster->CastCustomSpell(target, 63675, &basepoints0, NULL, NULL, true, NULL, GetEffect(0));
- caster->CastCustomSpell(caster, 75999, &heal, NULL, NULL, true, NULL, GetEffect(0));
+ int32 basepoints0 = CalculatePct(devouringPlague->GetTotalTicks() * static_cast<int32>(damage), aurEff->GetAmount());
+ int32 heal = CalculatePct(basepoints0, 15);
+ caster->CastCustomSpell(63675, SPELLVALUE_BASE_POINT0, basepoints0, target, true, nullptr, devouringPlague);
+ caster->CastCustomSpell(75999, SPELLVALUE_BASE_POINT0, heal, (Unit*)nullptr, true, nullptr, devouringPlague);
}
}
// Power Word: Shield
@@ -1592,6 +1600,9 @@ void Aura::HandleAuraSpecificMods(AuraApplication const* aurApp, Unit* caster, b
target->CastSpell(target, 31666, true);
else
{
+ // Remove counter aura
+ target->RemoveAurasDueToSpell(31666);
+
int32 basepoints0 = aurEff->GetAmount();
target->CastCustomSpell(target, 31665, &basepoints0, NULL, NULL, true);
}
@@ -1602,7 +1613,12 @@ void Aura::HandleAuraSpecificMods(AuraApplication const* aurApp, Unit* caster, b
if (!apply)
target->CastSpell(target, 58428, true);
else
+ {
+ // Remove counter aura
+ target->RemoveAurasDueToSpell(58428);
+
target->CastSpell(target, 58427, true);
+ }
}
break;
}
@@ -1866,13 +1882,34 @@ void Aura::PrepareProcToTrigger(AuraApplication* aurApp, ProcEventInfo& eventInf
AddProcCooldown(now + procEntry->Cooldown);
}
-uint8 Aura::IsProcTriggeredOnEvent(AuraApplication* aurApp, ProcEventInfo& eventInfo, std::chrono::steady_clock::time_point now) const
+uint8 Aura::GetProcEffectMask(AuraApplication* aurApp, ProcEventInfo& eventInfo, std::chrono::steady_clock::time_point now) const
{
SpellProcEntry const* procEntry = sSpellMgr->GetSpellProcEntry(GetId());
// only auras with spell proc entry can trigger proc
if (!procEntry)
return 0;
+ // check spell triggering us
+ if (Spell const* spell = eventInfo.GetProcSpell())
+ {
+ // Do not allow auras to proc from effect triggered from itself
+ if (spell->IsTriggeredByAura(m_spellInfo))
+ return 0;
+
+ // check if aura can proc when spell is triggered (exception for hunter auto shot & wands)
+ if (spell->IsTriggered() && !(procEntry->AttributesMask & PROC_ATTR_TRIGGERED_CAN_PROC) && !(eventInfo.GetTypeMask() & AUTO_ATTACK_PROC_FLAG_MASK))
+ if (!GetSpellInfo()->HasAttribute(SPELL_ATTR3_CAN_PROC_WITH_TRIGGERED))
+ return 0;
+ }
+
+ // check don't break stealth attr present
+ if (m_spellInfo->HasAura(SPELL_AURA_MOD_STEALTH))
+ {
+ if (SpellInfo const* spellInfo = eventInfo.GetSpellInfo())
+ if (spellInfo->HasAttribute(SPELL_ATTR0_CU_DONT_BREAK_STEALTH))
+ return 0;
+ }
+
// check if we have charges to proc with
if (IsUsingCharges())
{
@@ -1890,16 +1927,9 @@ uint8 Aura::IsProcTriggeredOnEvent(AuraApplication* aurApp, ProcEventInfo& event
return 0;
// do checks against db data
- if (!sSpellMgr->CanSpellTriggerProcOnEvent(*procEntry, eventInfo))
+ if (!SpellMgr::CanSpellTriggerProcOnEvent(*procEntry, eventInfo))
return 0;
- // check if aura can proc when spell is triggered
- if (!(procEntry->AttributesMask & PROC_ATTR_TRIGGERED_CAN_PROC))
- if (Spell const* spell = eventInfo.GetProcSpell())
- if (spell->IsTriggered())
- if (!GetSpellInfo()->HasAttribute(SPELL_ATTR3_CAN_PROC_WITH_TRIGGERED))
- return 0;
-
// do checks using conditions table
if (!sConditionMgr->IsObjectMeetingNotGroupedConditions(CONDITION_SOURCE_TYPE_SPELL_PROC, GetId(), eventInfo.GetActor(), eventInfo.GetActionTarget()))
return 0;
@@ -1910,11 +1940,11 @@ uint8 Aura::IsProcTriggeredOnEvent(AuraApplication* aurApp, ProcEventInfo& event
return 0;
// At least one effect has to pass checks to proc aura
- uint8 procEffectMask = 0;
+ uint8 procEffectMask = aurApp->GetEffectMask();
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
- if (aurApp->HasEffect(i))
- if (GetEffect(i)->CheckEffectProc(aurApp, eventInfo))
- procEffectMask |= (1 << i);
+ if (procEffectMask & (1 << i))
+ if ((procEntry->AttributesMask & (PROC_ATTR_DISABLE_EFF_0 << i)) || !GetEffect(i)->CheckEffectProc(aurApp, eventInfo))
+ procEffectMask &= ~(1 << i);
if (!procEffectMask)
return 0;
@@ -2025,30 +2055,21 @@ void Aura::_DeleteRemovedApplications()
void Aura::LoadScripts()
{
- sScriptMgr->CreateAuraScripts(m_spellInfo->Id, m_loadedScripts);
- for (std::list<AuraScript*>::iterator itr = m_loadedScripts.begin(); itr != m_loadedScripts.end();)
+ sScriptMgr->CreateAuraScripts(m_spellInfo->Id, m_loadedScripts, this);
+ for (auto itr = m_loadedScripts.begin(); itr != m_loadedScripts.end(); ++itr)
{
- if (!(*itr)->_Load(this))
- {
- std::list<AuraScript*>::iterator bitr = itr;
- ++itr;
- delete (*bitr);
- m_loadedScripts.erase(bitr);
- continue;
- }
TC_LOG_DEBUG("spells", "Aura::LoadScripts: Script `%s` for aura `%u` is loaded now", (*itr)->_GetScriptName()->c_str(), m_spellInfo->Id);
(*itr)->Register();
- ++itr;
}
}
bool Aura::CallScriptCheckAreaTargetHandlers(Unit* target)
{
bool result = true;
- for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
+ for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
(*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_CHECK_AREA_TARGET);
- std::list<AuraScript::CheckAreaTargetHandler>::iterator hookItrEnd = (*scritr)->DoCheckAreaTarget.end(), hookItr = (*scritr)->DoCheckAreaTarget.begin();
+ auto hookItrEnd = (*scritr)->DoCheckAreaTarget.end(), hookItr = (*scritr)->DoCheckAreaTarget.begin();
for (; hookItr != hookItrEnd; ++hookItr)
result &= hookItr->Call(*scritr, target);
@@ -2059,10 +2080,10 @@ bool Aura::CallScriptCheckAreaTargetHandlers(Unit* target)
void Aura::CallScriptDispel(DispelInfo* dispelInfo)
{
- for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
+ for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
(*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_DISPEL);
- std::list<AuraScript::AuraDispelHandler>::iterator hookItrEnd = (*scritr)->OnDispel.end(), hookItr = (*scritr)->OnDispel.begin();
+ auto hookItrEnd = (*scritr)->OnDispel.end(), hookItr = (*scritr)->OnDispel.begin();
for (; hookItr != hookItrEnd; ++hookItr)
hookItr->Call(*scritr, dispelInfo);
@@ -2072,10 +2093,10 @@ void Aura::CallScriptDispel(DispelInfo* dispelInfo)
void Aura::CallScriptAfterDispel(DispelInfo* dispelInfo)
{
- for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
+ for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
(*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_AFTER_DISPEL);
- std::list<AuraScript::AuraDispelHandler>::iterator hookItrEnd = (*scritr)->AfterDispel.end(), hookItr = (*scritr)->AfterDispel.begin();
+ auto hookItrEnd = (*scritr)->AfterDispel.end(), hookItr = (*scritr)->AfterDispel.begin();
for (; hookItr != hookItrEnd; ++hookItr)
hookItr->Call(*scritr, dispelInfo);
@@ -2086,10 +2107,10 @@ void Aura::CallScriptAfterDispel(DispelInfo* dispelInfo)
bool Aura::CallScriptEffectApplyHandlers(AuraEffect const* aurEff, AuraApplication const* aurApp, AuraEffectHandleModes mode)
{
bool preventDefault = false;
- for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
+ for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
(*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_APPLY, aurApp);
- std::list<AuraScript::EffectApplyHandler>::iterator effEndItr = (*scritr)->OnEffectApply.end(), effItr = (*scritr)->OnEffectApply.begin();
+ auto effEndItr = (*scritr)->OnEffectApply.end(), effItr = (*scritr)->OnEffectApply.begin();
for (; effItr != effEndItr; ++effItr)
if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
effItr->Call(*scritr, aurEff, mode);
@@ -2106,10 +2127,10 @@ bool Aura::CallScriptEffectApplyHandlers(AuraEffect const* aurEff, AuraApplicati
bool Aura::CallScriptEffectRemoveHandlers(AuraEffect const* aurEff, AuraApplication const* aurApp, AuraEffectHandleModes mode)
{
bool preventDefault = false;
- for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
+ for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
(*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_REMOVE, aurApp);
- std::list<AuraScript::EffectApplyHandler>::iterator effEndItr = (*scritr)->OnEffectRemove.end(), effItr = (*scritr)->OnEffectRemove.begin();
+ auto effEndItr = (*scritr)->OnEffectRemove.end(), effItr = (*scritr)->OnEffectRemove.begin();
for (; effItr != effEndItr; ++effItr)
if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
effItr->Call(*scritr, aurEff, mode);
@@ -2124,10 +2145,10 @@ bool Aura::CallScriptEffectRemoveHandlers(AuraEffect const* aurEff, AuraApplicat
void Aura::CallScriptAfterEffectApplyHandlers(AuraEffect const* aurEff, AuraApplication const* aurApp, AuraEffectHandleModes mode)
{
- for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
+ for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
(*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_AFTER_APPLY, aurApp);
- std::list<AuraScript::EffectApplyHandler>::iterator effEndItr = (*scritr)->AfterEffectApply.end(), effItr = (*scritr)->AfterEffectApply.begin();
+ auto effEndItr = (*scritr)->AfterEffectApply.end(), effItr = (*scritr)->AfterEffectApply.begin();
for (; effItr != effEndItr; ++effItr)
if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
effItr->Call(*scritr, aurEff, mode);
@@ -2138,10 +2159,10 @@ void Aura::CallScriptAfterEffectApplyHandlers(AuraEffect const* aurEff, AuraAppl
void Aura::CallScriptAfterEffectRemoveHandlers(AuraEffect const* aurEff, AuraApplication const* aurApp, AuraEffectHandleModes mode)
{
- for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
+ for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
(*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_AFTER_REMOVE, aurApp);
- std::list<AuraScript::EffectApplyHandler>::iterator effEndItr = (*scritr)->AfterEffectRemove.end(), effItr = (*scritr)->AfterEffectRemove.begin();
+ auto effEndItr = (*scritr)->AfterEffectRemove.end(), effItr = (*scritr)->AfterEffectRemove.begin();
for (; effItr != effEndItr; ++effItr)
if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
effItr->Call(*scritr, aurEff, mode);
@@ -2153,10 +2174,10 @@ void Aura::CallScriptAfterEffectRemoveHandlers(AuraEffect const* aurEff, AuraApp
bool Aura::CallScriptEffectPeriodicHandlers(AuraEffect const* aurEff, AuraApplication const* aurApp)
{
bool preventDefault = false;
- for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
+ for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
(*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_PERIODIC, aurApp);
- std::list<AuraScript::EffectPeriodicHandler>::iterator effEndItr = (*scritr)->OnEffectPeriodic.end(), effItr = (*scritr)->OnEffectPeriodic.begin();
+ auto effEndItr = (*scritr)->OnEffectPeriodic.end(), effItr = (*scritr)->OnEffectPeriodic.begin();
for (; effItr != effEndItr; ++effItr)
if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
effItr->Call(*scritr, aurEff);
@@ -2172,10 +2193,10 @@ bool Aura::CallScriptEffectPeriodicHandlers(AuraEffect const* aurEff, AuraApplic
void Aura::CallScriptEffectUpdatePeriodicHandlers(AuraEffect* aurEff)
{
- for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
+ for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
(*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_UPDATE_PERIODIC);
- std::list<AuraScript::EffectUpdatePeriodicHandler>::iterator effEndItr = (*scritr)->OnEffectUpdatePeriodic.end(), effItr = (*scritr)->OnEffectUpdatePeriodic.begin();
+ auto effEndItr = (*scritr)->OnEffectUpdatePeriodic.end(), effItr = (*scritr)->OnEffectUpdatePeriodic.begin();
for (; effItr != effEndItr; ++effItr)
if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
effItr->Call(*scritr, aurEff);
@@ -2186,10 +2207,10 @@ void Aura::CallScriptEffectUpdatePeriodicHandlers(AuraEffect* aurEff)
void Aura::CallScriptEffectCalcAmountHandlers(AuraEffect const* aurEff, int32 & amount, bool & canBeRecalculated)
{
- for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
+ for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
(*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_CALC_AMOUNT);
- std::list<AuraScript::EffectCalcAmountHandler>::iterator effEndItr = (*scritr)->DoEffectCalcAmount.end(), effItr = (*scritr)->DoEffectCalcAmount.begin();
+ auto effEndItr = (*scritr)->DoEffectCalcAmount.end(), effItr = (*scritr)->DoEffectCalcAmount.begin();
for (; effItr != effEndItr; ++effItr)
if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
effItr->Call(*scritr, aurEff, amount, canBeRecalculated);
@@ -2200,10 +2221,10 @@ void Aura::CallScriptEffectCalcAmountHandlers(AuraEffect const* aurEff, int32 &
void Aura::CallScriptEffectCalcPeriodicHandlers(AuraEffect const* aurEff, bool & isPeriodic, int32 & amplitude)
{
- for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
+ for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
(*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_CALC_PERIODIC);
- std::list<AuraScript::EffectCalcPeriodicHandler>::iterator effEndItr = (*scritr)->DoEffectCalcPeriodic.end(), effItr = (*scritr)->DoEffectCalcPeriodic.begin();
+ auto effEndItr = (*scritr)->DoEffectCalcPeriodic.end(), effItr = (*scritr)->DoEffectCalcPeriodic.begin();
for (; effItr != effEndItr; ++effItr)
if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
effItr->Call(*scritr, aurEff, isPeriodic, amplitude);
@@ -2214,10 +2235,10 @@ void Aura::CallScriptEffectCalcPeriodicHandlers(AuraEffect const* aurEff, bool &
void Aura::CallScriptEffectCalcSpellModHandlers(AuraEffect const* aurEff, SpellModifier* & spellMod)
{
- for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
+ for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
(*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_CALC_SPELLMOD);
- std::list<AuraScript::EffectCalcSpellModHandler>::iterator effEndItr = (*scritr)->DoEffectCalcSpellMod.end(), effItr = (*scritr)->DoEffectCalcSpellMod.begin();
+ auto effEndItr = (*scritr)->DoEffectCalcSpellMod.end(), effItr = (*scritr)->DoEffectCalcSpellMod.begin();
for (; effItr != effEndItr; ++effItr)
if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
effItr->Call(*scritr, aurEff, spellMod);
@@ -2228,10 +2249,10 @@ void Aura::CallScriptEffectCalcSpellModHandlers(AuraEffect const* aurEff, SpellM
void Aura::CallScriptEffectAbsorbHandlers(AuraEffect* aurEff, AuraApplication const* aurApp, DamageInfo & dmgInfo, uint32 & absorbAmount, bool& defaultPrevented)
{
- for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
+ for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
(*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_ABSORB, aurApp);
- std::list<AuraScript::EffectAbsorbHandler>::iterator effEndItr = (*scritr)->OnEffectAbsorb.end(), effItr = (*scritr)->OnEffectAbsorb.begin();
+ auto effEndItr = (*scritr)->OnEffectAbsorb.end(), effItr = (*scritr)->OnEffectAbsorb.begin();
for (; effItr != effEndItr; ++effItr)
if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
@@ -2246,10 +2267,10 @@ void Aura::CallScriptEffectAbsorbHandlers(AuraEffect* aurEff, AuraApplication co
void Aura::CallScriptEffectAfterAbsorbHandlers(AuraEffect* aurEff, AuraApplication const* aurApp, DamageInfo & dmgInfo, uint32 & absorbAmount)
{
- for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
+ for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
(*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_AFTER_ABSORB, aurApp);
- std::list<AuraScript::EffectAbsorbHandler>::iterator effEndItr = (*scritr)->AfterEffectAbsorb.end(), effItr = (*scritr)->AfterEffectAbsorb.begin();
+ auto effEndItr = (*scritr)->AfterEffectAbsorb.end(), effItr = (*scritr)->AfterEffectAbsorb.begin();
for (; effItr != effEndItr; ++effItr)
if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
effItr->Call(*scritr, aurEff, dmgInfo, absorbAmount);
@@ -2260,10 +2281,10 @@ void Aura::CallScriptEffectAfterAbsorbHandlers(AuraEffect* aurEff, AuraApplicati
void Aura::CallScriptEffectManaShieldHandlers(AuraEffect* aurEff, AuraApplication const* aurApp, DamageInfo & dmgInfo, uint32 & absorbAmount, bool & /*defaultPrevented*/)
{
- for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
+ for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
(*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_MANASHIELD, aurApp);
- std::list<AuraScript::EffectManaShieldHandler>::iterator effEndItr = (*scritr)->OnEffectManaShield.end(), effItr = (*scritr)->OnEffectManaShield.begin();
+ auto effEndItr = (*scritr)->OnEffectManaShield.end(), effItr = (*scritr)->OnEffectManaShield.begin();
for (; effItr != effEndItr; ++effItr)
if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
effItr->Call(*scritr, aurEff, dmgInfo, absorbAmount);
@@ -2274,10 +2295,10 @@ void Aura::CallScriptEffectManaShieldHandlers(AuraEffect* aurEff, AuraApplicatio
void Aura::CallScriptEffectAfterManaShieldHandlers(AuraEffect* aurEff, AuraApplication const* aurApp, DamageInfo & dmgInfo, uint32 & absorbAmount)
{
- for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
+ for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
(*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_AFTER_MANASHIELD, aurApp);
- std::list<AuraScript::EffectManaShieldHandler>::iterator effEndItr = (*scritr)->AfterEffectManaShield.end(), effItr = (*scritr)->AfterEffectManaShield.begin();
+ auto effEndItr = (*scritr)->AfterEffectManaShield.end(), effItr = (*scritr)->AfterEffectManaShield.begin();
for (; effItr != effEndItr; ++effItr)
if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
effItr->Call(*scritr, aurEff, dmgInfo, absorbAmount);
@@ -2288,10 +2309,10 @@ void Aura::CallScriptEffectAfterManaShieldHandlers(AuraEffect* aurEff, AuraAppli
void Aura::CallScriptEffectSplitHandlers(AuraEffect* aurEff, AuraApplication const* aurApp, DamageInfo & dmgInfo, uint32 & splitAmount)
{
- for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
+ for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
(*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_SPLIT, aurApp);
- std::list<AuraScript::EffectSplitHandler>::iterator effEndItr = (*scritr)->OnEffectSplit.end(), effItr = (*scritr)->OnEffectSplit.begin();
+ auto effEndItr = (*scritr)->OnEffectSplit.end(), effItr = (*scritr)->OnEffectSplit.begin();
for (; effItr != effEndItr; ++effItr)
if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
effItr->Call(*scritr, aurEff, dmgInfo, splitAmount);
@@ -2303,10 +2324,10 @@ void Aura::CallScriptEffectSplitHandlers(AuraEffect* aurEff, AuraApplication con
bool Aura::CallScriptCheckProcHandlers(AuraApplication const* aurApp, ProcEventInfo& eventInfo)
{
bool result = true;
- for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
+ for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
(*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_CHECK_PROC, aurApp);
- std::list<AuraScript::CheckProcHandler>::iterator hookItrEnd = (*scritr)->DoCheckProc.end(), hookItr = (*scritr)->DoCheckProc.begin();
+ auto hookItrEnd = (*scritr)->DoCheckProc.end(), hookItr = (*scritr)->DoCheckProc.begin();
for (; hookItr != hookItrEnd; ++hookItr)
result &= hookItr->Call(*scritr, eventInfo);
@@ -2319,10 +2340,10 @@ bool Aura::CallScriptCheckProcHandlers(AuraApplication const* aurApp, ProcEventI
bool Aura::CallScriptPrepareProcHandlers(AuraApplication const* aurApp, ProcEventInfo& eventInfo)
{
bool prepare = true;
- for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
+ for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
(*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_PREPARE_PROC, aurApp);
- std::list<AuraScript::AuraProcHandler>::iterator effEndItr = (*scritr)->DoPrepareProc.end(), effItr = (*scritr)->DoPrepareProc.begin();
+ auto effEndItr = (*scritr)->DoPrepareProc.end(), effItr = (*scritr)->DoPrepareProc.begin();
for (; effItr != effEndItr; ++effItr)
effItr->Call(*scritr, eventInfo);
@@ -2338,10 +2359,10 @@ bool Aura::CallScriptPrepareProcHandlers(AuraApplication const* aurApp, ProcEven
bool Aura::CallScriptProcHandlers(AuraApplication const* aurApp, ProcEventInfo& eventInfo)
{
bool handled = false;
- for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
+ for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
(*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_PROC, aurApp);
- std::list<AuraScript::AuraProcHandler>::iterator hookItrEnd = (*scritr)->OnProc.end(), hookItr = (*scritr)->OnProc.begin();
+ auto hookItrEnd = (*scritr)->OnProc.end(), hookItr = (*scritr)->OnProc.begin();
for (; hookItr != hookItrEnd; ++hookItr)
hookItr->Call(*scritr, eventInfo);
@@ -2354,10 +2375,10 @@ bool Aura::CallScriptProcHandlers(AuraApplication const* aurApp, ProcEventInfo&
void Aura::CallScriptAfterProcHandlers(AuraApplication const* aurApp, ProcEventInfo& eventInfo)
{
- for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
+ for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
(*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_AFTER_PROC, aurApp);
- std::list<AuraScript::AuraProcHandler>::iterator hookItrEnd = (*scritr)->AfterProc.end(), hookItr = (*scritr)->AfterProc.begin();
+ auto hookItrEnd = (*scritr)->AfterProc.end(), hookItr = (*scritr)->AfterProc.begin();
for (; hookItr != hookItrEnd; ++hookItr)
hookItr->Call(*scritr, eventInfo);
@@ -2368,10 +2389,10 @@ void Aura::CallScriptAfterProcHandlers(AuraApplication const* aurApp, ProcEventI
bool Aura::CallScriptCheckEffectProcHandlers(AuraEffect const* aurEff, AuraApplication const* aurApp, ProcEventInfo& eventInfo)
{
bool result = true;
- for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
+ for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
(*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_CHECK_EFFECT_PROC, aurApp);
- std::list<AuraScript::CheckEffectProcHandler>::iterator hookItrEnd = (*scritr)->DoCheckEffectProc.end(), hookItr = (*scritr)->DoCheckEffectProc.begin();
+ auto hookItrEnd = (*scritr)->DoCheckEffectProc.end(), hookItr = (*scritr)->DoCheckEffectProc.begin();
for (; hookItr != hookItrEnd; ++hookItr)
if (hookItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
result &= hookItr->Call(*scritr, aurEff, eventInfo);
@@ -2385,10 +2406,10 @@ bool Aura::CallScriptCheckEffectProcHandlers(AuraEffect const* aurEff, AuraAppli
bool Aura::CallScriptEffectProcHandlers(AuraEffect const* aurEff, AuraApplication const* aurApp, ProcEventInfo& eventInfo)
{
bool preventDefault = false;
- for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
+ for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
(*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_PROC, aurApp);
- std::list<AuraScript::EffectProcHandler>::iterator effEndItr = (*scritr)->OnEffectProc.end(), effItr = (*scritr)->OnEffectProc.begin();
+ auto effEndItr = (*scritr)->OnEffectProc.end(), effItr = (*scritr)->OnEffectProc.begin();
for (; effItr != effEndItr; ++effItr)
if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
effItr->Call(*scritr, aurEff, eventInfo);
@@ -2403,10 +2424,10 @@ bool Aura::CallScriptEffectProcHandlers(AuraEffect const* aurEff, AuraApplicatio
void Aura::CallScriptAfterEffectProcHandlers(AuraEffect const* aurEff, AuraApplication const* aurApp, ProcEventInfo& eventInfo)
{
- for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
+ for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
(*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_AFTER_PROC, aurApp);
- std::list<AuraScript::EffectProcHandler>::iterator effEndItr = (*scritr)->AfterEffectProc.end(), effItr = (*scritr)->AfterEffectProc.begin();
+ auto effEndItr = (*scritr)->AfterEffectProc.end(), effItr = (*scritr)->AfterEffectProc.begin();
for (; effItr != effEndItr; ++effItr)
if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
effItr->Call(*scritr, aurEff, eventInfo);
@@ -2449,18 +2470,17 @@ void UnitAura::Remove(AuraRemoveMode removeMode)
GetUnitOwner()->RemoveOwnedAura(this, removeMode);
}
-void UnitAura::FillTargetMap(std::map<Unit*, uint8> & targets, Unit* caster)
+void UnitAura::FillTargetMap(std::unordered_map<Unit*, uint8>& targets, Unit* caster)
{
for (uint8 effIndex = 0; effIndex < MAX_SPELL_EFFECTS; ++effIndex)
{
if (!HasEffect(effIndex))
continue;
- UnitList targetList;
+
+ std::deque<Unit*> units;
// non-area aura
if (GetSpellInfo()->Effects[effIndex].Effect == SPELL_EFFECT_APPLY_AURA)
- {
- targetList.push_back(GetUnitOwner());
- }
+ units.push_back(GetUnitOwner());
else
{
float radius = GetSpellInfo()->Effects[effIndex].CalcRadius(caster);
@@ -2472,48 +2492,48 @@ void UnitAura::FillTargetMap(std::map<Unit*, uint8> & targets, Unit* caster)
case SPELL_EFFECT_APPLY_AREA_AURA_PARTY:
case SPELL_EFFECT_APPLY_AREA_AURA_RAID:
{
- targetList.push_back(GetUnitOwner());
- Trinity::AnyGroupedUnitInObjectRangeCheck u_check(GetUnitOwner(), GetUnitOwner(), radius, GetSpellInfo()->Effects[effIndex].Effect == SPELL_EFFECT_APPLY_AREA_AURA_RAID);
- Trinity::UnitListSearcher<Trinity::AnyGroupedUnitInObjectRangeCheck> searcher(GetUnitOwner(), targetList, u_check);
+ units.push_back(GetUnitOwner());
+ Trinity::AnyGroupedUnitInObjectRangeCheck u_check(GetUnitOwner(), GetUnitOwner(), radius, m_spellInfo->Effects[effIndex].Effect == SPELL_EFFECT_APPLY_AREA_AURA_RAID, m_spellInfo->HasAttribute(SPELL_ATTR3_ONLY_TARGET_PLAYERS));
+ Trinity::UnitListSearcher<Trinity::AnyGroupedUnitInObjectRangeCheck> searcher(GetUnitOwner(), units, u_check);
GetUnitOwner()->VisitNearbyObject(radius, searcher);
break;
}
case SPELL_EFFECT_APPLY_AREA_AURA_FRIEND:
{
- targetList.push_back(GetUnitOwner());
- Trinity::AnyFriendlyUnitInObjectRangeCheck u_check(GetUnitOwner(), GetUnitOwner(), radius);
- Trinity::UnitListSearcher<Trinity::AnyFriendlyUnitInObjectRangeCheck> searcher(GetUnitOwner(), targetList, u_check);
+ units.push_back(GetUnitOwner());
+ Trinity::AnyFriendlyUnitInObjectRangeCheck u_check(GetUnitOwner(), GetUnitOwner(), radius, m_spellInfo->HasAttribute(SPELL_ATTR3_ONLY_TARGET_PLAYERS));
+ Trinity::UnitListSearcher<Trinity::AnyFriendlyUnitInObjectRangeCheck> searcher(GetUnitOwner(), units, u_check);
GetUnitOwner()->VisitNearbyObject(radius, searcher);
break;
}
case SPELL_EFFECT_APPLY_AREA_AURA_ENEMY:
{
- Trinity::AnyAoETargetUnitInObjectRangeCheck u_check(GetUnitOwner(), GetUnitOwner(), radius); // No GetCharmer in searcher
- Trinity::UnitListSearcher<Trinity::AnyAoETargetUnitInObjectRangeCheck> searcher(GetUnitOwner(), targetList, u_check);
+ Trinity::AnyAoETargetUnitInObjectRangeCheck u_check(GetUnitOwner(), GetUnitOwner(), radius, m_spellInfo); // No GetCharmer in searcher
+ Trinity::UnitListSearcher<Trinity::AnyAoETargetUnitInObjectRangeCheck> searcher(GetUnitOwner(), units, u_check);
GetUnitOwner()->VisitNearbyObject(radius, searcher);
break;
}
case SPELL_EFFECT_APPLY_AREA_AURA_PET:
- targetList.push_back(GetUnitOwner());
+ units.push_back(GetUnitOwner());
// no break
case SPELL_EFFECT_APPLY_AREA_AURA_OWNER:
{
if (Unit* owner = GetUnitOwner()->GetCharmerOrOwner())
if (GetUnitOwner()->IsWithinDistInMap(owner, radius))
- targetList.push_back(owner);
+ units.push_back(owner);
break;
}
}
}
}
- for (UnitList::iterator itr = targetList.begin(); itr!= targetList.end();++itr)
+ for (Unit* unit : units)
{
- std::map<Unit*, uint8>::iterator existing = targets.find(*itr);
- if (existing != targets.end())
- existing->second |= 1<<effIndex;
+ auto itr = targets.find(unit);
+ if (itr != targets.end())
+ itr->second |= 1 << effIndex;
else
- targets[*itr] = 1<<effIndex;
+ targets[unit] = 1 << effIndex;
}
}
}
@@ -2536,7 +2556,7 @@ void DynObjAura::Remove(AuraRemoveMode removeMode)
_Remove(removeMode);
}
-void DynObjAura::FillTargetMap(std::map<Unit*, uint8> & targets, Unit* /*caster*/)
+void DynObjAura::FillTargetMap(std::unordered_map<Unit*, uint8>& targets, Unit* /*caster*/)
{
Unit* dynObjOwnerCaster = GetDynobjOwner()->GetCaster();
float radius = GetDynobjOwner()->GetRadius();
@@ -2545,28 +2565,29 @@ void DynObjAura::FillTargetMap(std::map<Unit*, uint8> & targets, Unit* /*caster*
{
if (!HasEffect(effIndex))
continue;
- UnitList targetList;
+
+ std::deque<Unit*> units;
if (GetSpellInfo()->Effects[effIndex].TargetB.GetTarget() == TARGET_DEST_DYNOBJ_ALLY
|| GetSpellInfo()->Effects[effIndex].TargetB.GetTarget() == TARGET_UNIT_DEST_AREA_ALLY)
{
- Trinity::AnyFriendlyUnitInObjectRangeCheck u_check(GetDynobjOwner(), dynObjOwnerCaster, radius);
- Trinity::UnitListSearcher<Trinity::AnyFriendlyUnitInObjectRangeCheck> searcher(GetDynobjOwner(), targetList, u_check);
+ Trinity::AnyFriendlyUnitInObjectRangeCheck u_check(GetDynobjOwner(), dynObjOwnerCaster, radius, m_spellInfo->HasAttribute(SPELL_ATTR3_ONLY_TARGET_PLAYERS));
+ Trinity::UnitListSearcher<Trinity::AnyFriendlyUnitInObjectRangeCheck> searcher(GetDynobjOwner(), units, u_check);
GetDynobjOwner()->VisitNearbyObject(radius, searcher);
}
else
{
Trinity::AnyAoETargetUnitInObjectRangeCheck u_check(GetDynobjOwner(), dynObjOwnerCaster, radius);
- Trinity::UnitListSearcher<Trinity::AnyAoETargetUnitInObjectRangeCheck> searcher(GetDynobjOwner(), targetList, u_check);
+ Trinity::UnitListSearcher<Trinity::AnyAoETargetUnitInObjectRangeCheck> searcher(GetDynobjOwner(), units, u_check);
GetDynobjOwner()->VisitNearbyObject(radius, searcher);
}
- for (UnitList::iterator itr = targetList.begin(); itr!= targetList.end();++itr)
+ for (Unit* unit : units)
{
- std::map<Unit*, uint8>::iterator existing = targets.find(*itr);
- if (existing != targets.end())
- existing->second |= 1<<effIndex;
+ auto itr = targets.find(unit);
+ if (itr != targets.end())
+ itr->second |= 1 << effIndex;
else
- targets[*itr] = 1<<effIndex;
+ targets[unit] = 1 << effIndex;
}
}
}
diff --git a/src/server/game/Spells/Auras/SpellAuras.h b/src/server/game/Spells/Auras/SpellAuras.h
index ff7070cea15..1533746893a 100644
--- a/src/server/game/Spells/Auras/SpellAuras.h
+++ b/src/server/game/Spells/Auras/SpellAuras.h
@@ -113,7 +113,7 @@ class TC_GAME_API Aura
void _Remove(AuraRemoveMode removeMode);
virtual void Remove(AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT) = 0;
- virtual void FillTargetMap(std::map<Unit*, uint8> & targets, Unit* caster) = 0;
+ virtual void FillTargetMap(std::unordered_map<Unit*, uint8>& targets, Unit* caster) = 0;
void UpdateTargetMap(Unit* caster, bool apply = true);
void _RegisterForTargets() {Unit* caster = GetCaster(); UpdateTargetMap(caster, false);}
@@ -204,7 +204,7 @@ class TC_GAME_API Aura
bool IsUsingCharges() const { return m_isUsingCharges; }
void SetUsingCharges(bool val) { m_isUsingCharges = val; }
void PrepareProcToTrigger(AuraApplication* aurApp, ProcEventInfo& eventInfo, std::chrono::steady_clock::time_point now);
- uint8 IsProcTriggeredOnEvent(AuraApplication* aurApp, ProcEventInfo& eventInfo, std::chrono::steady_clock::time_point now) const;
+ uint8 GetProcEffectMask(AuraApplication* aurApp, ProcEventInfo& eventInfo, std::chrono::steady_clock::time_point now) const;
float CalcProcChance(SpellProcEntry const& procEntry, ProcEventInfo& eventInfo) const;
void TriggerProcOnEvent(uint8 procEffectMask, AuraApplication* aurApp, ProcEventInfo& eventInfo);
@@ -238,9 +238,11 @@ class TC_GAME_API Aura
AuraScript* GetScriptByName(std::string const& scriptName) const;
- std::list<AuraScript*> m_loadedScripts;
+ std::vector<AuraScript*> m_loadedScripts;
+
private:
void _DeleteRemovedApplications();
+
protected:
SpellInfo const* const m_spellInfo;
ObjectGuid const m_casterGuid;
@@ -283,14 +285,14 @@ class TC_GAME_API UnitAura : public Aura
void Remove(AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT) override;
- void FillTargetMap(std::map<Unit*, uint8> & targets, Unit* caster) override;
+ void FillTargetMap(std::unordered_map<Unit*, uint8>& targets, Unit* caster) override;
// Allow Apply Aura Handler to modify and access m_AuraDRGroup
void SetDiminishGroup(DiminishingGroup group) { m_AuraDRGroup = group; }
DiminishingGroup GetDiminishGroup() const { return m_AuraDRGroup; }
private:
- DiminishingGroup m_AuraDRGroup:8; // Diminishing
+ DiminishingGroup m_AuraDRGroup; // Diminishing
};
class TC_GAME_API DynObjAura : public Aura
@@ -301,7 +303,7 @@ class TC_GAME_API DynObjAura : public Aura
public:
void Remove(AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT) override;
- void FillTargetMap(std::map<Unit*, uint8> & targets, Unit* caster) override;
+ void FillTargetMap(std::unordered_map<Unit*, uint8>& targets, Unit* caster) override;
};
class TC_GAME_API ChargeDropEvent : public BasicEvent
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index 9b21ea4c5fb..c082c0a7584 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -586,8 +586,6 @@ m_caster((info->HasAttribute(SPELL_ATTR6_CAST_BY_CHARMER) && caster->GetCharmerO
destTarget = NULL;
damage = 0;
effectHandleMode = SPELL_EFFECT_HANDLE_LAUNCH;
- m_diminishLevel = DIMINISHING_LEVEL_1;
- m_diminishGroup = DIMINISHING_NONE;
m_damage = 0;
m_healing = 0;
m_procAttacker = 0;
@@ -628,12 +626,10 @@ m_caster((info->HasAttribute(SPELL_ATTR6_CAST_BY_CHARMER) && caster->GetCharmerO
Spell::~Spell()
{
// unload scripts
- while (!m_loadedScripts.empty())
+ for (auto itr = m_loadedScripts.begin(); itr != m_loadedScripts.end(); ++itr)
{
- std::list<SpellScript*>::iterator itr = m_loadedScripts.begin();
(*itr)->_Unload();
delete (*itr);
- m_loadedScripts.erase(itr);
}
if (m_referencedFromCurrentSpell && m_selfContainer && *m_selfContainer == this)
@@ -649,7 +645,8 @@ Spell::~Spell()
delete m_spellValue;
- CheckEffectExecuteData();
+ // missing cleanup somewhere, mem leaks so let's crash
+ AssertEffectExecuteData();
}
void Spell::InitExplicitTargets(SpellCastTargets const& targets)
@@ -1121,8 +1118,14 @@ void Spell::SelectImplicitConeTargets(SpellEffIndex effIndex, SpellImplicitTarge
SpellTargetObjectTypes objectType = targetType.GetObjectType();
SpellTargetCheckTypes selectionType = targetType.GetCheckType();
ConditionContainer* condList = m_spellInfo->Effects[effIndex].ImplicitTargetConditions;
- float coneAngle = float(M_PI) / 2;
- float radius = m_spellInfo->Effects[effIndex].CalcRadius(m_caster) * m_spellValue->RadiusMod;
+ float coneAngle = float(M_PI) / 2.f;
+
+ float radius = m_spellInfo->Effects[effIndex].CalcRadius(m_caster);
+ // Workaround for some spells that don't have RadiusEntry set in dbc (but SpellRange instead)
+ if (G3D::fuzzyEq(radius, 0.f))
+ radius = m_spellInfo->GetMaxRange(m_spellInfo->IsPositiveEffect(effIndex), m_caster, this);
+
+ radius *= m_spellValue->RadiusMod;
if (uint32 containerTypeMask = GetSearcherTypeMask(objectType, condList))
{
@@ -1208,7 +1211,13 @@ void Spell::SelectImplicitAreaTargets(SpellEffIndex effIndex, SpellImplicitTarge
return;
}
std::list<WorldObject*> targets;
- float radius = m_spellInfo->Effects[effIndex].CalcRadius(m_caster) * m_spellValue->RadiusMod;
+ float radius = m_spellInfo->Effects[effIndex].CalcRadius(m_caster);
+ // Workaround for some spells that don't have RadiusEntry set in dbc (but SpellRange instead)
+ if (G3D::fuzzyEq(radius, 0.f))
+ radius = m_spellInfo->GetMaxRange(m_spellInfo->IsPositiveEffect(effIndex), m_caster, this);
+
+ radius *= m_spellValue->RadiusMod;
+
SearchAreaTargets(targets, radius, center, referer, targetType.GetObjectType(), targetType.GetCheckType(), m_spellInfo->Effects[effIndex].ImplicitTargetConditions);
CallScriptObjectAreaTargetSelectHandlers(targets, effIndex, targetType);
@@ -1994,11 +2003,17 @@ void Spell::prepareDataForTriggerSystem()
// Hunter trap spells - activation proc for Lock and Load, Entrapment and Misdirection
if (m_spellInfo->SpellFamilyName == SPELLFAMILY_HUNTER &&
- (m_spellInfo->SpellFamilyFlags[0] & 0x18 || // Freezing and Frost Trap, Freezing Arrow
- m_spellInfo->Id == 57879 || // Snake Trap - done this way to avoid double proc
- m_spellInfo->SpellFamilyFlags[2] & 0x00024000)) // Explosive and Immolation Trap
+ (m_spellInfo->SpellFamilyFlags[0] & 0x18 || // Freezing and Frost Trap, Freezing Arrow
+ m_spellInfo->Id == 57879 || // Snake Trap - done this way to avoid double proc
+ m_spellInfo->SpellFamilyFlags[2] & 0x00024000)) // Explosive and Immolation Trap
+ {
m_procAttacker |= PROC_FLAG_DONE_TRAP_ACTIVATION;
+ // also fill up other flags (DoAllEffectOnTarget only fills up flag if both are not set)
+ m_procAttacker |= PROC_FLAG_DONE_SPELL_MAGIC_DMG_CLASS_NEG;
+ m_procVictim |= PROC_FLAG_TAKEN_SPELL_MAGIC_DMG_CLASS_NEG;
+ }
+
// Hellfire Effect - trigger as DOT
if (m_spellInfo->SpellFamilyName == SPELLFAMILY_WARLOCK && m_spellInfo->SpellFamilyFlags[0] & 0x00000040)
{
@@ -2052,7 +2067,7 @@ void Spell::AddUnitTarget(Unit* target, uint32 effectMask, bool checkIfValid /*=
return;
if (checkIfValid)
- if (m_spellInfo->CheckTarget(m_caster, target, implicit) != SPELL_CAST_OK)
+ if (m_spellInfo->CheckTarget(m_caster, target, implicit || m_caster->GetEntry() == WORLD_TRIGGER) != SPELL_CAST_OK) // skip stealth checks for GO casts
return;
// Check for effect immune skip if immuned
@@ -2310,7 +2325,7 @@ void Spell::DoAllEffectOnTarget(TargetInfo* target)
m_spellAura = nullptr; // 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 cast on self
- bool canEffectTrigger = !m_spellInfo->HasAttribute(SPELL_ATTR3_CANT_TRIGGER_PROC) && (CanExecuteTriggersOnHit(mask) || missInfo == SPELL_MISS_IMMUNE || missInfo == SPELL_MISS_IMMUNE2);
+ bool const canEffectTrigger = !m_spellInfo->HasAttribute(SPELL_ATTR3_CANT_TRIGGER_PROC) && unitTarget->CanProc() && (CanExecuteTriggersOnHit(mask) || missInfo == SPELL_MISS_IMMUNE || missInfo == SPELL_MISS_IMMUNE2);
Unit* spellHitTarget = nullptr;
if (missInfo == SPELL_MISS_NONE) // In case spell hit target, do all effect on that target
@@ -2354,7 +2369,19 @@ void Spell::DoAllEffectOnTarget(TargetInfo* target)
if (m_damage > 0)
positive = false;
else if (!m_healing)
- positive = m_spellInfo->IsPositive();
+ {
+ for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
+ {
+ if (!(target->effectMask & (1 << i)))
+ continue;
+
+ if (!m_spellInfo->IsPositiveEffect(i))
+ {
+ positive = false;
+ break;
+ }
+ }
+ }
switch (m_spellInfo->DmgClass)
{
@@ -2415,15 +2442,29 @@ void Spell::DoAllEffectOnTarget(TargetInfo* target)
// Fill base damage struct (unitTarget - is real spell target)
SpellNonMeleeDamage damageInfo(caster, unitTarget, m_spellInfo->Id, m_spellSchoolMask);
- // Add bonuses and fill damageInfo struct
- caster->CalculateSpellDamageTaken(&damageInfo, m_damage, m_spellInfo, m_attackType, target->crit);
- caster->DealDamageMods(damageInfo.target, damageInfo.damage, &damageInfo.absorb);
+ // Check damage immunity
+ if (unitTarget->IsImmunedToDamage(m_spellInfo))
+ {
+ hitMask = PROC_HIT_IMMUNE;
+ m_damage = 0;
+
+ // no packet found in sniffs
+ }
+ else
+ {
+ // Add bonuses and fill damageInfo struct
+ caster->CalculateSpellDamageTaken(&damageInfo, m_damage, m_spellInfo, m_attackType, target->crit);
+ caster->DealDamageMods(damageInfo.target, damageInfo.damage, &damageInfo.absorb);
+
+ // Send log damage message to client
+ caster->SendSpellNonMeleeDamageLog(&damageInfo);
- // Send log damage message to client
- caster->SendSpellNonMeleeDamageLog(&damageInfo);
+ hitMask |= createProcHitMask(&damageInfo, missInfo);
+ procVictim |= PROC_FLAG_TAKEN_DAMAGE;
- hitMask |= createProcHitMask(&damageInfo, missInfo);
- procVictim |= PROC_FLAG_TAKEN_DAMAGE;
+ m_damage = damageInfo.damage;
+ caster->DealSpellDamage(&damageInfo, true);
+ }
// Do triggers for unit
if (canEffectTrigger)
@@ -2435,10 +2476,6 @@ void Spell::DoAllEffectOnTarget(TargetInfo* target)
(m_spellInfo->DmgClass == SPELL_DAMAGE_CLASS_MELEE || m_spellInfo->DmgClass == SPELL_DAMAGE_CLASS_RANGED))
caster->ToPlayer()->CastItemCombatSpell(spellDamageInfo);
}
-
- m_damage = damageInfo.damage;
-
- caster->DealSpellDamage(&damageInfo, true);
}
// Passive spell hits/misses or active spells only misses (only triggers)
else
@@ -2504,7 +2541,7 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit* unit, uint32 effectMask, bool scaleA
return SPELL_MISS_EVADE;
// For delayed spells immunity may be applied between missile launch and hit - check immunity for that case
- if (m_spellInfo->Speed && (unit->IsImmunedToDamage(m_spellInfo) || unit->IsImmunedToSpell(m_spellInfo)))
+ if (m_spellInfo->Speed && unit->IsImmunedToSpell(m_spellInfo))
return SPELL_MISS_IMMUNE;
// disable effects to which unit is immune
@@ -2517,15 +2554,12 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit* unit, uint32 effectMask, bool scaleA
effectMask &= ~(1 << effectNumber);
else if (m_spellInfo->Effects[effectNumber].IsAura() && !m_spellInfo->IsPositiveEffect(effectNumber))
{
- int32 debuff_resist_chance = unit->GetMaxPositiveAuraModifierByMiscValue(SPELL_AURA_MOD_DEBUFF_RESISTANCE, int32(m_spellInfo->Dispel));
- debuff_resist_chance += unit->GetMaxNegativeAuraModifierByMiscValue(SPELL_AURA_MOD_DEBUFF_RESISTANCE, int32(m_spellInfo->Dispel));
-
- if (debuff_resist_chance > 0)
- if (irand(0, 10000) <= (debuff_resist_chance * 100))
- {
- effectMask &= ~(1 << effectNumber);
- returnVal = SPELL_MISS_RESIST;
- }
+ int32 debuff_resist_chance = unit->GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_DEBUFF_RESISTANCE, static_cast<int32>(m_spellInfo->Dispel));
+ if (debuff_resist_chance > 0 && roll_chance_i(debuff_resist_chance))
+ {
+ effectMask &= ~(1 << effectNumber);
+ returnVal = SPELL_MISS_RESIST;
+ }
}
}
}
@@ -2556,12 +2590,7 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit* unit, uint32 effectMask, bool scaleA
return SPELL_MISS_EVADE;
if (m_caster->_IsValidAttackTarget(unit, m_spellInfo))
- {
unit->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_HITBYSPELL);
-
- if (!m_spellInfo->HasAttribute(SPELL_ATTR0_CU_DONT_BREAK_STEALTH))
- unit->RemoveAurasByType(SPELL_AURA_MOD_STEALTH);
- }
else if (m_caster->IsFriendlyTo(unit))
{
// for delayed spells ignore negative spells (after duel end) for friendly targets
@@ -2591,16 +2620,19 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit* unit, uint32 effectMask, bool scaleA
aura_effmask |= 1 << i;
// Get Data Needed for Diminishing Returns, some effects may have multiple auras, so this must be done on spell hit, not aura add
- m_diminishGroup = GetDiminishingReturnsGroupForSpell(m_spellInfo, m_triggeredByAuraSpell != nullptr);
- if (m_diminishGroup && aura_effmask)
+ bool const triggered = m_triggeredByAuraSpell != nullptr;
+ DiminishingGroup const diminishGroup = m_spellInfo->GetDiminishingReturnsGroupForSpell(triggered);
+
+ DiminishingLevels diminishLevel = DIMINISHING_LEVEL_1;
+ if (diminishGroup && aura_effmask)
{
- m_diminishLevel = unit->GetDiminishing(m_diminishGroup);
- DiminishingReturnsType type = GetDiminishingReturnsGroupType(m_diminishGroup);
+ diminishLevel = unit->GetDiminishing(diminishGroup);
+ DiminishingReturnsType type = m_spellInfo->GetDiminishingReturnsGroupType(triggered);
// Increase Diminishing on unit, current informations for actually casts will use values above
if ((type == DRTYPE_PLAYER &&
(unit->GetCharmerOrOwnerPlayerOrPlayerItself() || (unit->GetTypeId() == TYPEID_UNIT && unit->ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_ALL_DIMINISH))) ||
type == DRTYPE_ALL)
- unit->IncrDiminishing(m_diminishGroup);
+ unit->IncrDiminishing(m_spellInfo, triggered);
}
if (aura_effmask)
@@ -2643,8 +2675,7 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit* unit, uint32 effectMask, bool scaleA
// Now Reduce spell duration using data received at spell hit
int32 duration = m_spellAura->GetMaxDuration();
- int32 limitduration = GetDiminishingReturnsLimitDuration(m_diminishGroup, aurSpellInfo);
- float diminishMod = unit->ApplyDiminishingToDuration(m_diminishGroup, duration, m_originalCaster, m_diminishLevel, limitduration);
+ float diminishMod = unit->ApplyDiminishingToDuration(aurSpellInfo, triggered, duration, m_originalCaster, diminishLevel);
// unit is immune to aura if it was diminished to 0 duration
if (diminishMod == 0.0f)
@@ -2659,7 +2690,7 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit* unit, uint32 effectMask, bool scaleA
}
else
{
- ((UnitAura*)m_spellAura)->SetDiminishGroup(m_diminishGroup);
+ ((UnitAura*)m_spellAura)->SetDiminishGroup(diminishGroup);
bool positive = m_spellAura->GetSpellInfo()->IsPositive();
if (AuraApplication* aurApp = m_spellAura->GetApplicationOfTarget(m_originalCaster->GetGUID()))
@@ -2723,8 +2754,8 @@ void Spell::DoTriggersOnSpellHit(Unit* unit, uint8 effMask)
// info confirmed with retail sniffs of permafrost and shadow weaving
if (!m_hitTriggerSpells.empty())
{
- int _duration = 0;
- for (HitTriggerSpellList::const_iterator i = m_hitTriggerSpells.begin(); i != m_hitTriggerSpells.end(); ++i)
+ int32 _duration = 0;
+ for (auto i = m_hitTriggerSpells.begin(); i != m_hitTriggerSpells.end(); ++i)
{
if (CanExecuteTriggersOnHit(effMask, i->triggeredByAura) && roll_chance_i(i->chance))
{
@@ -2936,7 +2967,8 @@ void Spell::prepare(SpellCastTargets const* targets, AuraEffect const* triggered
if ((_triggeredCastFlags & TRIGGERED_IGNORE_COMBO_POINTS) || m_CastItem || !m_caster->m_playerMovingMe)
m_needComboPoints = false;
- SpellCastResult result = CheckCast(true);
+ uint32 param1 = 0, param2 = 0;
+ SpellCastResult result = CheckCast(true, &param1, &param2);
if (result != SPELL_CAST_OK && !IsAutoRepeat()) //always cast autorepeat dummy for triggering
{
// Periodic auras should be interrupted when aura triggers a spell which can't be cast
@@ -2957,7 +2989,10 @@ void Spell::prepare(SpellCastTargets const* targets, AuraEffect const* triggered
m_caster->ToPlayer()->SetSpellModTakingSpell(this, false);
}
- SendCastResult(result);
+ if (param1 || param2)
+ SendCastResult(result, &param1, &param2);
+ else
+ SendCastResult(result);
finish(false);
return;
@@ -2982,7 +3017,7 @@ void Spell::prepare(SpellCastTargets const* targets, AuraEffect const* triggered
m_casttime = m_spellInfo->CalcCastTime(this);
if (m_caster->GetTypeId() == TYPEID_UNIT && !m_caster->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED)) // _UNIT actually means creature. for some reason.
- if (!(IsNextMeleeSwingSpell() || IsAutoRepeat() || _triggeredCastFlags & TRIGGERED_IGNORE_SET_FACING))
+ if (!(m_spellInfo->IsNextMeleeSwingSpell() || IsAutoRepeat() || (_triggeredCastFlags & TRIGGERED_IGNORE_SET_FACING)))
{
if (m_targets.GetObjectTarget() && m_caster != m_targets.GetObjectTarget())
m_caster->ToCreature()->FocusTarget(this, m_targets.GetObjectTarget());
@@ -2995,8 +3030,8 @@ void Spell::prepare(SpellCastTargets const* targets, AuraEffect const* triggered
// (even if they are interrupted on moving, spells with almost immediate effect get to have their effect processed before movement interrupter kicks in)
if ((m_spellInfo->IsChanneled() || m_casttime) && m_caster->GetTypeId() == TYPEID_PLAYER && !(m_caster->IsCharmed() && m_caster->GetCharmerGUID().IsCreature()) && m_caster->isMoving() && (m_spellInfo->InterruptFlags & SPELL_INTERRUPT_FLAG_MOVEMENT))
{
- // 1. Is a channel spell, 2. Has no casttime, 3. And has flag to allow movement during channel
- if (!(m_spellInfo->IsChanneled() && !m_casttime && m_spellInfo->HasAttribute(SPELL_ATTR5_CAN_CHANNEL_WHEN_MOVING)))
+ // 1. Has casttime, 2. Or doesn't have flag to allow movement during channel
+ if (m_casttime || !m_spellInfo->IsMoveAllowedChannel())
{
SendCastResult(SPELL_FAILED_MOVING);
finish(false);
@@ -3144,10 +3179,11 @@ void Spell::cast(bool skipCheck)
// skip check if done already (for instant cast spells for example)
if (!skipCheck)
{
- SpellCastResult castResult = CheckCast(false);
+ uint32 param1 = 0, param2 = 0;
+ SpellCastResult castResult = CheckCast(false, &param1, &param2);
if (castResult != SPELL_CAST_OK)
{
- SendCastResult(castResult);
+ SendCastResult(castResult, &param1, &param2);
SendInterrupted(0);
//restore spell mods
if (m_caster->GetTypeId() == TYPEID_PLAYER)
@@ -3460,9 +3496,6 @@ uint64 Spell::handle_delayed(uint64 t_offset)
void Spell::_handle_immediate_phase()
{
m_spellAura = NULL;
- // initialize Diminishing Returns Data
- m_diminishLevel = DIMINISHING_LEVEL_1;
- m_diminishGroup = DIMINISHING_NONE;
// handle some immediate features of the spell here
HandleThreatSpells();
@@ -3498,12 +3531,12 @@ void Spell::_handle_finish_phase()
m_caster->m_playerMovingMe->GainSpellComboPoints(m_comboPointGain);
}
- if (m_caster->HasExtraAttacksPending() && m_spellInfo->HasEffect(SPELL_EFFECT_ADD_EXTRA_ATTACKS))
+ if (m_caster->m_extraAttacks && m_spellInfo->HasEffect(SPELL_EFFECT_ADD_EXTRA_ATTACKS))
{
if (Unit* victim = ObjectAccessor::GetUnit(*m_caster, m_targets.GetOrigUnitTargetGUID()))
m_caster->HandleProcExtraAttackFor(victim);
else
- m_caster->SetExtraAttacks(0);
+ m_caster->m_extraAttacks = 0;
}
// Handle procs on finish
@@ -3554,7 +3587,7 @@ void Spell::update(uint32 difftime)
(m_spellInfo->Effects[0].Effect != SPELL_EFFECT_STUCK || !m_caster->HasUnitMovementFlag(MOVEMENTFLAG_FALLING_FAR))))
{
// don't cancel for melee, autorepeat, triggered and instant spells
- if (!IsNextMeleeSwingSpell() && !IsAutoRepeat() && !IsTriggered() && !(IsChannelActive() && m_spellInfo->HasAttribute(SPELL_ATTR5_CAN_CHANNEL_WHEN_MOVING)))
+ if (!m_spellInfo->IsNextMeleeSwingSpell() && !IsAutoRepeat() && !IsTriggered() && !(IsChannelActive() && m_spellInfo->IsMoveAllowedChannel()))
{
// if charmed by creature, trust the AI not to cheat and allow the cast to proceed
// @todo this is a hack, "creature" movesplines don't differentiate turning/moving right now
@@ -3576,7 +3609,7 @@ void Spell::update(uint32 difftime)
m_timer -= difftime;
}
- if (m_timer == 0 && !IsNextMeleeSwingSpell() && !IsAutoRepeat())
+ if (m_timer == 0 && !m_spellInfo->IsNextMeleeSwingSpell() && !IsAutoRepeat())
// don't CheckCast for instant spells - done in spell::prepare, skip duplicate checks, needed for range checks for example
cast(!m_casttime);
break;
@@ -3589,8 +3622,12 @@ void Spell::update(uint32 difftime)
if (!UpdateChanneledTargetList())
{
TC_LOG_DEBUG("spells", "Channeled spell %d is removed due to lack of targets", m_spellInfo->Id);
- SendChannelUpdate(0);
- finish();
+ m_timer = 0;
+
+ // Also remove applied auras
+ for (TargetInfo const& target : m_UniqueTargetInfo)
+ if (Unit* unit = m_caster->GetGUID() == target.targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, target.targetGUID))
+ unit->RemoveOwnedAura(m_spellInfo->Id, m_originalCasterGUID, 0, AURA_REMOVE_BY_CANCEL);
}
if (m_timer > 0)
@@ -3692,7 +3729,7 @@ void Spell::finish(bool ok)
m_caster->AttackStop();
}
-void Spell::WriteCastResultInfo(WorldPacket& data, Player* caster, SpellInfo const* spellInfo, uint8 castCount, SpellCastResult result, SpellCustomErrors customError)
+void Spell::WriteCastResultInfo(WorldPacket& data, Player* caster, SpellInfo const* spellInfo, uint8 castCount, SpellCastResult result, SpellCustomErrors customError, uint32* param1 /*= nullptr*/, uint32* param2 /*= nullptr*/)
{
data << uint8(castCount); // single cast or multi 2.3 (0/1)
data << uint32(spellInfo->Id);
@@ -3700,115 +3737,185 @@ void Spell::WriteCastResultInfo(WorldPacket& data, Player* caster, SpellInfo con
switch (result)
{
case SPELL_FAILED_REQUIRES_SPELL_FOCUS:
- data << uint32(spellInfo->RequiresSpellFocus); // SpellFocusObject.dbc id
+ if (param1)
+ data << uint32(*param1);
+ else
+ data << uint32(spellInfo->RequiresSpellFocus); // SpellFocusObject.dbc id
break;
case SPELL_FAILED_REQUIRES_AREA: // AreaTable.dbc id
- // hardcode areas limitation case
- switch (spellInfo->Id)
+ if (param1)
+ data << uint32(*param1);
+ else
{
- case 41617: // Cenarion Mana Salve
- case 41619: // Cenarion Healing Salve
- data << uint32(3905);
- break;
- case 41618: // Bottled Nethergon Energy
- case 41620: // Bottled Nethergon Vapor
- data << uint32(3842);
- break;
- case 45373: // Bloodberry Elixir
- data << uint32(4075);
- break;
- default: // default case (don't must be)
- data << uint32(0);
- break;
+ // hardcode areas limitation case
+ switch (spellInfo->Id)
+ {
+ case 41617: // Cenarion Mana Salve
+ case 41619: // Cenarion Healing Salve
+ data << uint32(3905);
+ break;
+ case 41618: // Bottled Nethergon Energy
+ case 41620: // Bottled Nethergon Vapor
+ data << uint32(3842);
+ break;
+ case 45373: // Bloodberry Elixir
+ data << uint32(4075);
+ break;
+ default: // default case (don't must be)
+ data << uint32(0);
+ break;
+ }
}
break;
case SPELL_FAILED_TOTEMS:
- if (spellInfo->Totem[0])
- data << uint32(spellInfo->Totem[0]);
- if (spellInfo->Totem[1])
- data << uint32(spellInfo->Totem[1]);
+ if (param1)
+ {
+ data << uint32(*param1);
+ if (param2)
+ data << uint32(*param2);
+ }
+ else
+ {
+ if (spellInfo->Totem[0])
+ data << uint32(spellInfo->Totem[0]);
+ if (spellInfo->Totem[1])
+ data << uint32(spellInfo->Totem[1]);
+ }
break;
case SPELL_FAILED_TOTEM_CATEGORY:
- if (spellInfo->TotemCategory[0])
- data << uint32(spellInfo->TotemCategory[0]);
- if (spellInfo->TotemCategory[1])
- data << uint32(spellInfo->TotemCategory[1]);
+ if (param1)
+ {
+ data << uint32(*param1);
+ if (param2)
+ data << uint32(*param2);
+ }
+ else
+ {
+ if (spellInfo->TotemCategory[0])
+ data << uint32(spellInfo->TotemCategory[0]);
+ if (spellInfo->TotemCategory[1])
+ data << uint32(spellInfo->TotemCategory[1]);
+ }
break;
case SPELL_FAILED_EQUIPPED_ITEM_CLASS:
case SPELL_FAILED_EQUIPPED_ITEM_CLASS_MAINHAND:
case SPELL_FAILED_EQUIPPED_ITEM_CLASS_OFFHAND:
- data << uint32(spellInfo->EquippedItemClass);
- data << uint32(spellInfo->EquippedItemSubClassMask);
+ if (param1 && param2)
+ {
+ data << uint32(*param1);
+ data << uint32(*param2);
+ }
+ else
+ {
+ data << uint32(spellInfo->EquippedItemClass);
+ data << uint32(spellInfo->EquippedItemSubClassMask);
+ }
break;
case SPELL_FAILED_TOO_MANY_OF_ITEM:
{
- uint32 item = 0;
- for (int8 eff = 0; eff < MAX_SPELL_EFFECTS; eff++)
- if (spellInfo->Effects[eff].ItemType)
- item = spellInfo->Effects[eff].ItemType;
- ItemTemplate const* proto = sObjectMgr->GetItemTemplate(item);
- if (proto && proto->ItemLimitCategory)
- data << uint32(proto->ItemLimitCategory);
- break;
+ if (param1)
+ data << uint32(*param1);
+ else
+ {
+ uint32 item = 0;
+ for (uint8 effIndex = 0; effIndex < MAX_SPELL_EFFECTS && !item; ++effIndex)
+ if (uint32 itemType = spellInfo->Effects[effIndex].ItemType)
+ item = itemType;
+
+ ItemTemplate const* proto = sObjectMgr->GetItemTemplate(item);
+ if (proto && proto->ItemLimitCategory)
+ data << uint32(proto->ItemLimitCategory);
+ }
+ break;
}
case SPELL_FAILED_CUSTOM_ERROR:
data << uint32(customError);
break;
case SPELL_FAILED_REAGENTS:
{
- uint32 missingItem = 0;
- for (uint32 i = 0; i < MAX_SPELL_REAGENTS; i++)
+ if (param1)
+ data << uint32(*param1);
+ else
{
- if (spellInfo->Reagent[i] <= 0)
- continue;
+ uint32 missingItem = 0;
+ for (uint32 i = 0; i < MAX_SPELL_REAGENTS; i++)
+ {
+ if (spellInfo->Reagent[i] <= 0)
+ continue;
- uint32 itemid = spellInfo->Reagent[i];
- uint32 itemcount = spellInfo->ReagentCount[i];
+ uint32 itemid = spellInfo->Reagent[i];
+ uint32 itemcount = spellInfo->ReagentCount[i];
- if (!caster->HasItemCount(itemid, itemcount))
- {
- missingItem = itemid;
- break;
+ if (!caster->HasItemCount(itemid, itemcount))
+ {
+ missingItem = itemid;
+ break;
+ }
}
- }
- data << uint32(missingItem); // first missing item
+ data << uint32(missingItem); // first missing item
+ }
break;
}
case SPELL_FAILED_PREVENTED_BY_MECHANIC:
- data << uint32(spellInfo->Mechanic);
+ if (param1)
+ data << uint32(*param1);
+ else
+ data << uint32(spellInfo->Mechanic);
break;
case SPELL_FAILED_NEED_EXOTIC_AMMO:
- data << uint32(spellInfo->EquippedItemSubClassMask);
+ if (param1)
+ data << uint32(*param1);
+ else
+ data << uint32(spellInfo->EquippedItemSubClassMask);
break;
case SPELL_FAILED_NEED_MORE_ITEMS:
- data << uint32(0); // Item entry
- data << uint32(0); // Count
+ if (param1 && param2)
+ {
+ data << uint32(*param1);
+ data << uint32(*param2);
+ }
+ else
+ {
+ data << uint32(0); // Item entry
+ data << uint32(0); // Count
+ }
break;
case SPELL_FAILED_MIN_SKILL:
- data << uint32(0); // SkillLine.dbc Id
- data << uint32(0); // Amount
+ if (param1 && param2)
+ {
+ data << uint32(*param1);
+ data << uint32(*param2);
+ }
+ else
+ {
+ data << uint32(0); // SkillLine.dbc Id
+ data << uint32(0); // Amount
+ }
break;
case SPELL_FAILED_FISHING_TOO_LOW:
- data << uint32(0); // Skill level
+ if (param1)
+ data << uint32(*param1);
+ else
+ data << uint32(0); // Skill level
break;
default:
break;
}
}
-void Spell::SendCastResult(Player* caster, SpellInfo const* spellInfo, uint8 castCount, SpellCastResult result, SpellCustomErrors customError /*= SPELL_CUSTOM_ERROR_NONE*/)
+void Spell::SendCastResult(Player* caster, SpellInfo const* spellInfo, uint8 castCount, SpellCastResult result, SpellCustomErrors customError /*= SPELL_CUSTOM_ERROR_NONE*/, uint32* param1 /*= nullptr*/, uint32* param2 /*= nullptr*/)
{
if (result == SPELL_CAST_OK)
return;
WorldPacket data(SMSG_CAST_FAILED, 1 + 4 + 1);
- WriteCastResultInfo(data, caster, spellInfo, castCount, result, customError);
+ WriteCastResultInfo(data, caster, spellInfo, castCount, result, customError, param1, param2);
- caster->GetSession()->SendPacket(&data);
+ caster->SendDirectMessage(&data);
}
-void Spell::SendCastResult(SpellCastResult result)
+void Spell::SendCastResult(SpellCastResult result, uint32* param1 /*= nullptr*/, uint32* param2 /*= nullptr*/) const
{
if (result == SPELL_CAST_OK)
return;
@@ -3816,13 +3923,13 @@ void Spell::SendCastResult(SpellCastResult result)
if (m_caster->GetTypeId() != TYPEID_PLAYER)
return;
- if (m_caster->ToPlayer()->GetSession()->PlayerLoading()) // don't send cast results at loading time
+ if (m_caster->ToPlayer()->IsLoading()) // don't send cast results at loading time
return;
if (_triggeredCastFlags & TRIGGERED_DONT_REPORT_CAST_ERROR)
result = SPELL_FAILED_DONT_REPORT;
- SendCastResult(m_caster->ToPlayer(), m_spellInfo, m_cast_count, result, m_customError);
+ SendCastResult(m_caster->ToPlayer(), m_spellInfo, m_cast_count, result, m_customError, param1, param2);
}
void Spell::SendPetCastResult(SpellCastResult result)
@@ -4471,7 +4578,7 @@ void Spell::TakeAmmo()
}
}
-SpellCastResult Spell::CheckRuneCost(uint32 runeCostID)
+SpellCastResult Spell::CheckRuneCost(uint32 runeCostID) const
{
if (m_spellInfo->PowerType != POWER_RUNE || !runeCostID)
return SPELL_CAST_OK;
@@ -4496,7 +4603,7 @@ SpellCastResult Spell::CheckRuneCost(uint32 runeCostID)
{
runeCost[i] = src->RuneCost[i];
if (Player* modOwner = m_caster->GetSpellModOwner())
- modOwner->ApplySpellMod<SPELLMOD_COST>(m_spellInfo->Id, runeCost[i], this);
+ modOwner->ApplySpellMod<SPELLMOD_COST>(m_spellInfo->Id, runeCost[i], const_cast<Spell*>(this));
}
runeCost[RUNE_DEATH] = MAX_RUNES; // calculated later
@@ -4616,7 +4723,7 @@ void Spell::TakeReagents()
ItemTemplate const* castItemTemplate = m_CastItem ? m_CastItem->GetTemplate() : NULL;
// do not take reagents for these item casts
- if (castItemTemplate && castItemTemplate->Flags & ITEM_PROTO_FLAG_TRIGGERED_CAST)
+ if (castItemTemplate && castItemTemplate->Flags & ITEM_FLAG_NO_REAGENT_COST)
return;
Player* p_caster = m_caster->ToPlayer();
@@ -4695,7 +4802,7 @@ void Spell::HandleThreatSpells()
continue;
// positive spells distribute threat among all units that are in combat with target, like healing
- if (m_spellInfo->_IsPositiveSpell())
+ if (m_spellInfo->IsPositive())
target->getHostileRefManager().threatAssist(m_caster, threatToAdd, m_spellInfo);
// for negative spells threat gets distributed among affected targets
else
@@ -4706,7 +4813,7 @@ void Spell::HandleThreatSpells()
target->AddThreat(m_caster, threatToAdd, m_spellInfo->GetSchoolMask(), m_spellInfo);
}
}
- TC_LOG_DEBUG("spells", "Spell %u, added an additional %f threat for %s %u target(s)", m_spellInfo->Id, threat, m_spellInfo->_IsPositiveSpell() ? "assisting" : "harming", uint32(m_UniqueTargetInfo.size()));
+ TC_LOG_DEBUG("spells", "Spell %u, added an additional %f threat for %s %u target(s)", m_spellInfo->Id, threat, m_spellInfo->IsPositive() ? "assisting" : "harming", uint32(m_UniqueTargetInfo.size()));
}
void Spell::HandleEffects(Unit* pUnitTarget, Item* pItemTarget, GameObject* pGOTarget, uint32 i, SpellEffectHandleMode mode)
@@ -4732,7 +4839,7 @@ void Spell::HandleEffects(Unit* pUnitTarget, Item* pItemTarget, GameObject* pGOT
}
}
-SpellCastResult Spell::CheckCast(bool strict)
+SpellCastResult Spell::CheckCast(bool strict, uint32* param1 /*= nullptr*/, uint32* param2 /*= nullptr*/)
{
// check death state
if (!m_caster->IsAlive() && !m_spellInfo->IsPassive() && !(m_spellInfo->HasAttribute(SPELL_ATTR0_CASTABLE_WHILE_DEAD) || (IsTriggered() && !m_triggeredByAuraSpell)))
@@ -4795,13 +4902,15 @@ SpellCastResult Spell::CheckCast(bool strict)
bool checkForm = true;
// Ignore form req aura
Unit::AuraEffectList const& ignore = m_caster->GetAuraEffectsByType(SPELL_AURA_MOD_IGNORE_SHAPESHIFT);
- for (Unit::AuraEffectList::const_iterator i = ignore.begin(); i != ignore.end(); ++i)
+ for (AuraEffect const* aurEff : ignore)
{
- if (!(*i)->IsAffectedOnSpell(m_spellInfo))
+ if (!aurEff->IsAffectedOnSpell(m_spellInfo))
continue;
+
checkForm = false;
break;
}
+
if (checkForm)
{
// Cannot be used in this stance/form
@@ -4897,14 +5006,18 @@ SpellCastResult Spell::CheckCast(bool strict)
if (!(m_spellInfo->IsPassive() && (!m_targets.GetUnitTarget() || m_targets.GetUnitTarget() == m_caster)))
{
// Check explicit target for m_originalCaster - todo: get rid of such workarounds
- SpellCastResult castResult = m_spellInfo->CheckExplicitTarget(m_originalCaster ? m_originalCaster : m_caster, m_targets.GetObjectTarget(), m_targets.GetItemTarget());
+ Unit* caster = m_caster;
+ if (m_originalCaster && m_caster->GetEntry() != WORLD_TRIGGER) // Do a simplified check for gameobject casts
+ caster = m_originalCaster;
+
+ SpellCastResult castResult = m_spellInfo->CheckExplicitTarget(caster, m_targets.GetObjectTarget(), m_targets.GetItemTarget());
if (castResult != SPELL_CAST_OK)
return castResult;
}
if (Unit* target = m_targets.GetUnitTarget())
{
- SpellCastResult castResult = m_spellInfo->CheckTarget(m_caster, target, false);
+ SpellCastResult castResult = m_spellInfo->CheckTarget(m_caster, target, m_caster->GetEntry() == WORLD_TRIGGER); // skip stealth checks for GO casts
if (castResult != SPELL_CAST_OK)
return castResult;
@@ -5005,7 +5118,7 @@ SpellCastResult Spell::CheckCast(bool strict)
// always (except passive spells) check items (only player related checks)
if (!m_spellInfo->IsPassive())
{
- castResult = CheckItems();
+ castResult = CheckItems(param1, param2);
if (castResult != SPELL_CAST_OK)
return castResult;
}
@@ -5025,7 +5138,7 @@ SpellCastResult Spell::CheckCast(bool strict)
if (!(_triggeredCastFlags & TRIGGERED_IGNORE_CASTER_AURAS))
{
- castResult = CheckCasterAuras();
+ castResult = CheckCasterAuras(param1);
if (castResult != SPELL_CAST_OK)
return castResult;
}
@@ -5039,6 +5152,7 @@ SpellCastResult Spell::CheckCast(bool strict)
bool hasNonDispelEffect = false;
uint32 dispelMask = 0;
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
+ {
if (m_spellInfo->Effects[i].Effect == SPELL_EFFECT_DISPEL)
{
if (m_spellInfo->Effects[i].IsTargetingArea() || m_spellInfo->HasAttribute(SPELL_ATTR1_MELEE_COMBAT_START))
@@ -5054,6 +5168,7 @@ SpellCastResult Spell::CheckCast(bool strict)
hasNonDispelEffect = true;
break;
}
+ }
if (!hasNonDispelEffect && !hasDispellableAura && dispelMask && !IsTriggered())
{
@@ -5168,7 +5283,7 @@ SpellCastResult Spell::CheckCast(bool strict)
m_caster->RemoveMovementImpairingAuras();
}
- if (m_caster->HasUnitState(UNIT_STATE_ROOT))
+ if (!(_triggeredCastFlags & TRIGGERED_IGNORE_CASTER_AURAS) && m_caster->HasUnitState(UNIT_STATE_ROOT))
return SPELL_FAILED_ROOTED;
if (GetSpellInfo()->NeedsExplicitUnitTarget())
@@ -5637,139 +5752,114 @@ SpellCastResult Spell::CheckPetCast(Unit* target)
return CheckCast(true);
}
-SpellCastResult Spell::CheckCasterAuras() const
+SpellCastResult Spell::CheckCasterAuras(uint32* param1) const
{
// spells totally immuned to caster auras (wsg flag drop, give marks etc)
if (m_spellInfo->HasAttribute(SPELL_ATTR6_IGNORE_CASTER_AURAS))
return SPELL_CAST_OK;
- uint8 school_immune = 0;
- uint32 mechanic_immune = 0;
- uint32 dispel_immune = 0;
-
- // Check if the spell grants school or mechanic immunity.
- // We use bitmasks so the loop is done only once and not on every aura check below.
- if (m_spellInfo->HasAttribute(SPELL_ATTR1_DISPEL_AURAS_ON_IMMUNITY))
+ bool usableWhileStunned = m_spellInfo->HasAttribute(SPELL_ATTR5_USABLE_WHILE_STUNNED);
+ bool usableWhileFeared = m_spellInfo->HasAttribute(SPELL_ATTR5_USABLE_WHILE_FEARED);
+ bool usableWhileConfused = m_spellInfo->HasAttribute(SPELL_ATTR5_USABLE_WHILE_CONFUSED);
+ if (m_spellInfo->HasAttribute(SPELL_ATTR7_USABLE_IN_STUN_FEAR_CONFUSION))
{
- for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
- {
- if (m_spellInfo->Effects[i].ApplyAuraName == SPELL_AURA_SCHOOL_IMMUNITY)
- school_immune |= uint32(m_spellInfo->Effects[i].MiscValue);
- else if (m_spellInfo->Effects[i].ApplyAuraName == SPELL_AURA_MECHANIC_IMMUNITY)
- mechanic_immune |= 1 << uint32(m_spellInfo->Effects[i].MiscValue);
- else if (m_spellInfo->Effects[i].ApplyAuraName == SPELL_AURA_DISPEL_IMMUNITY)
- dispel_immune |= SpellInfo::GetDispelMask(DispelType(m_spellInfo->Effects[i].MiscValue));
- }
- // immune movement impairment and loss of control
- if (m_spellInfo->Id == 42292 || m_spellInfo->Id == 59752 || m_spellInfo->Id == 19574 || m_spellInfo->Id == 53490)
- mechanic_immune = IMMUNE_TO_MOVEMENT_IMPAIRMENT_AND_LOSS_CONTROL_MASK;
+ usableWhileStunned = true;
+ usableWhileFeared = true;
+ usableWhileConfused = true;
}
- bool usableInStun = m_spellInfo->HasAttribute(SPELL_ATTR5_USABLE_WHILE_STUNNED);
-
// Glyph of Pain Suppression
// there is no other way to handle it
if (m_spellInfo->Id == 33206 && !m_caster->HasAura(63248))
- usableInStun = false;
+ usableWhileStunned = false;
// Check whether the cast should be prevented by any state you might have.
- SpellCastResult prevented_reason = SPELL_CAST_OK;
- // Have to check if there is a stun aura. Otherwise will have problems with ghost aura apply while logging out
- uint32 unitflag = m_caster->GetUInt32Value(UNIT_FIELD_FLAGS); // Get unit state
- if (unitflag & UNIT_FLAG_STUNNED)
- {
- // spell is usable while stunned, check if caster has allowed stun auras, another stun types must prevent cast spell
- if (usableInStun)
- {
- static uint32 const allowedStunMask =
- 1 << MECHANIC_STUN
- | 1 << MECHANIC_FREEZE
- | 1 << MECHANIC_SAPPED
- | 1 << MECHANIC_SLEEP;
-
- bool foundNotStun = false;
- Unit::AuraEffectList const& stunAuras = m_caster->GetAuraEffectsByType(SPELL_AURA_MOD_STUN);
- for (Unit::AuraEffectList::const_iterator i = stunAuras.begin(); i != stunAuras.end(); ++i)
- {
- uint32 mechanicMask = (*i)->GetSpellInfo()->GetAllEffectsMechanicMask();
- if (mechanicMask && !(mechanicMask & allowedStunMask))
- {
- foundNotStun = true;
- break;
- }
- }
- if (foundNotStun)
- prevented_reason = SPELL_FAILED_STUNNED;
- }
- else
- prevented_reason = SPELL_FAILED_STUNNED;
- }
- else if (unitflag & UNIT_FLAG_CONFUSED && !m_spellInfo->HasAttribute(SPELL_ATTR5_USABLE_WHILE_CONFUSED))
- prevented_reason = SPELL_FAILED_CONFUSED;
- else if (unitflag & UNIT_FLAG_FLEEING && !m_spellInfo->HasAttribute(SPELL_ATTR5_USABLE_WHILE_FEARED))
- prevented_reason = SPELL_FAILED_FLEEING;
- else if (unitflag & UNIT_FLAG_SILENCED && m_spellInfo->PreventionType == SPELL_PREVENTION_TYPE_SILENCE)
- prevented_reason = SPELL_FAILED_SILENCED;
- else if (unitflag & UNIT_FLAG_PACIFIED && m_spellInfo->PreventionType == SPELL_PREVENTION_TYPE_PACIFY)
- prevented_reason = SPELL_FAILED_PACIFIED;
+ SpellCastResult result = SPELL_CAST_OK;
+
+ // Get unit state
+ uint32 const unitflag = m_caster->GetUInt32Value(UNIT_FIELD_FLAGS);
+ if (m_caster->GetCharmerGUID())
+ {
+ if (Unit* charmer = m_caster->GetCharmer())
+ if (charmer->GetUnitBeingMoved() != m_caster && CheckCasterNotImmunedCharmAuras(param1))
+ result = SPELL_FAILED_CHARMED;
+ }
+ else if (unitflag & UNIT_FLAG_STUNNED && !usableWhileStunned && CheckCasterNotImmunedStunAuras(param1))
+ result = SPELL_FAILED_STUNNED;
+ else if (unitflag & UNIT_FLAG_SILENCED && m_spellInfo->PreventionType == SPELL_PREVENTION_TYPE_SILENCE && CheckCasterNotImmunedSilenceAuras(param1))
+ result = SPELL_FAILED_SILENCED;
+ else if (unitflag & UNIT_FLAG_PACIFIED && m_spellInfo->PreventionType == SPELL_PREVENTION_TYPE_PACIFY && CheckCasterNotImmunedPacifyAuras(param1))
+ result = SPELL_FAILED_PACIFIED;
+ else if (unitflag & UNIT_FLAG_FLEEING && !usableWhileFeared && CheckCasterNotImmunedFearAuras(param1))
+ result = SPELL_FAILED_FLEEING;
+ else if (unitflag & UNIT_FLAG_CONFUSED && !usableWhileConfused && CheckCasterNotImmunedDisorientAuras(param1))
+ result = SPELL_FAILED_CONFUSED;
// Attr must make flag drop spell totally immune from all effects
- if (prevented_reason != SPELL_CAST_OK)
+ if (result != SPELL_CAST_OK)
+ return (param1 && *param1) ? SPELL_FAILED_PREVENTED_BY_MECHANIC : result;
+
+ return SPELL_CAST_OK;
+}
+
+// based on sub_00804430 from 12340 client
+bool Spell::CheckCasterHasNotImmunedAuraType(AuraType auraType, uint32* param1) const
+{
+ // Checking auras is needed now, because you are prevented by some state but the spell grants immunity.
+ Unit::AuraEffectList const& auraEffects = m_caster->GetAuraEffectsByType(auraType);
+ if (auraEffects.empty())
+ return false;
+
+ for (AuraEffect const* aurEff : auraEffects)
{
- if (school_immune || mechanic_immune || dispel_immune)
- {
- //Checking auras is needed now, because you are prevented by some state but the spell grants immunity.
- Unit::AuraApplicationMap const& auras = m_caster->GetAppliedAuras();
- for (Unit::AuraApplicationMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
- {
- Aura const* aura = itr->second->GetBase();
- SpellInfo const* auraInfo = aura->GetSpellInfo();
- if (auraInfo->GetAllEffectsMechanicMask() & mechanic_immune)
- continue;
- if (auraInfo->GetSchoolMask() & school_immune && !auraInfo->HasAttribute(SPELL_ATTR1_UNAFFECTED_BY_SCHOOL_IMMUNE))
- continue;
- if (auraInfo->GetDispelMask() & dispel_immune)
- continue;
+ SpellInfo const* auraInfo = aurEff->GetSpellInfo();
+ if (m_spellInfo->CanSpellCastOverrideAuraEffect(auraInfo, aurEff->GetEffIndex()))
+ continue;
- //Make a second check for spell failed so the right SPELL_FAILED message is returned.
- //That is needed when your casting is prevented by multiple states and you are only immune to some of them.
- for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
- {
- if (AuraEffect* part = aura->GetEffect(i))
- {
- switch (part->GetAuraType())
- {
- case SPELL_AURA_MOD_STUN:
- if (!usableInStun || !(auraInfo->GetAllEffectsMechanicMask() & (1<<MECHANIC_STUN)))
- return SPELL_FAILED_STUNNED;
- break;
- case SPELL_AURA_MOD_CONFUSE:
- if (!m_spellInfo->HasAttribute(SPELL_ATTR5_USABLE_WHILE_CONFUSED))
- return SPELL_FAILED_CONFUSED;
- break;
- case SPELL_AURA_MOD_FEAR:
- if (!m_spellInfo->HasAttribute(SPELL_ATTR5_USABLE_WHILE_FEARED))
- return SPELL_FAILED_FLEEING;
- break;
- case SPELL_AURA_MOD_SILENCE:
- case SPELL_AURA_MOD_PACIFY:
- case SPELL_AURA_MOD_PACIFY_SILENCE:
- if (m_spellInfo->PreventionType == SPELL_PREVENTION_TYPE_PACIFY)
- return SPELL_FAILED_PACIFIED;
- else if (m_spellInfo->PreventionType == SPELL_PREVENTION_TYPE_SILENCE)
- return SPELL_FAILED_SILENCED;
- break;
- default: break;
- }
- }
- }
- }
+ if (param1)
+ {
+ *param1 = auraInfo->Effects[aurEff->GetEffIndex()].Mechanic;
+ if (!*param1)
+ *param1 = auraInfo->Mechanic;
}
- // You are prevented from casting and the spell cast does not grant immunity. Return a failed error.
- else
- return prevented_reason;
+ return true;
}
- return SPELL_CAST_OK;
+
+ return false;
+}
+
+bool Spell::CheckCasterNotImmunedCharmAuras(uint32* param1) const
+{
+ return CheckCasterHasNotImmunedAuraType(SPELL_AURA_MOD_CHARM, param1) ||
+ CheckCasterHasNotImmunedAuraType(SPELL_AURA_AOE_CHARM, param1) ||
+ CheckCasterHasNotImmunedAuraType(SPELL_AURA_MOD_POSSESS, param1);
+}
+
+bool Spell::CheckCasterNotImmunedStunAuras(uint32* param1) const
+{
+ return CheckCasterHasNotImmunedAuraType(SPELL_AURA_MOD_STUN, param1);
+}
+
+bool Spell::CheckCasterNotImmunedSilenceAuras(uint32* param1) const
+{
+ return CheckCasterHasNotImmunedAuraType(SPELL_AURA_MOD_SILENCE, param1) ||
+ CheckCasterHasNotImmunedAuraType(SPELL_AURA_MOD_PACIFY_SILENCE, param1);
+}
+
+bool Spell::CheckCasterNotImmunedPacifyAuras(uint32* param1) const
+{
+ return CheckCasterHasNotImmunedAuraType(SPELL_AURA_MOD_PACIFY, param1) ||
+ CheckCasterHasNotImmunedAuraType(SPELL_AURA_MOD_PACIFY_SILENCE, param1);
+}
+
+bool Spell::CheckCasterNotImmunedFearAuras(uint32* param1) const
+{
+ return CheckCasterHasNotImmunedAuraType(SPELL_AURA_MOD_FEAR, param1);
+}
+
+bool Spell::CheckCasterNotImmunedDisorientAuras(uint32* param1) const
+{
+ return CheckCasterHasNotImmunedAuraType(SPELL_AURA_MOD_CONFUSE, param1);
}
bool Spell::CanAutoCast(Unit* target)
@@ -5828,7 +5918,7 @@ bool Spell::CanAutoCast(Unit* target)
return false;
}
-SpellCastResult Spell::CheckRange(bool strict)
+SpellCastResult Spell::CheckRange(bool strict) const
{
// Don't check for instant cast spells
if (!strict && m_casttime == 0)
@@ -5858,20 +5948,20 @@ SpellCastResult Spell::CheckRange(bool strict)
if (m_targets.HasDst() && !m_targets.HasTraj())
{
if (m_caster->GetExactDistSq(m_targets.GetDstPos()) > maxRange)
- return !(_triggeredCastFlags & TRIGGERED_DONT_REPORT_CAST_ERROR) ? SPELL_FAILED_OUT_OF_RANGE : SPELL_FAILED_DONT_REPORT;
+ return SPELL_FAILED_OUT_OF_RANGE;
if (minRange > 0.0f && m_caster->GetExactDistSq(m_targets.GetDstPos()) < minRange)
- return !(_triggeredCastFlags & TRIGGERED_DONT_REPORT_CAST_ERROR) ? SPELL_FAILED_OUT_OF_RANGE : SPELL_FAILED_DONT_REPORT;
+ return SPELL_FAILED_OUT_OF_RANGE;
}
return SPELL_CAST_OK;
}
-std::pair<float, float> Spell::GetMinMaxRange(bool strict)
+std::pair<float, float> Spell::GetMinMaxRange(bool strict) const
{
float rangeMod = 0.0f;
float minRange = 0.0f;
float maxRange = 0.0f;
- if (strict && IsNextMeleeSwingSpell())
+ if (strict && m_spellInfo->IsNextMeleeSwingSpell())
{
maxRange = 100.0f;
return std::pair<float, float>(minRange, maxRange);
@@ -5913,14 +6003,14 @@ std::pair<float, float> Spell::GetMinMaxRange(bool strict)
maxRange *= ranged->GetTemplate()->RangedModRange * 0.01f;
if (Player* modOwner = m_caster->GetSpellModOwner())
- modOwner->ApplySpellMod<SPELLMOD_RANGE>(m_spellInfo->Id, maxRange, this);
+ modOwner->ApplySpellMod<SPELLMOD_RANGE>(m_spellInfo->Id, maxRange, const_cast<Spell*>(this));
maxRange += rangeMod;
return std::pair<float, float>(minRange, maxRange);
}
-SpellCastResult Spell::CheckPower()
+SpellCastResult Spell::CheckPower() const
{
// item cast not used power
if (m_CastItem)
@@ -5956,12 +6046,15 @@ SpellCastResult Spell::CheckPower()
return SPELL_CAST_OK;
}
-SpellCastResult Spell::CheckItems()
+SpellCastResult Spell::CheckItems(uint32* param1 /*= nullptr*/, uint32* param2 /*= nullptr*/) const
{
Player* player = m_caster->ToPlayer();
if (!player)
return SPELL_CAST_OK;
+ if (m_spellInfo->HasAttribute(SPELL_ATTR2_IGNORE_ITEM_CHECK))
+ return SPELL_CAST_OK;
+
if (!m_CastItem)
{
if (m_castItemGUID)
@@ -6037,10 +6130,11 @@ SpellCastResult Spell::CheckItems()
// check target item
if (m_targets.GetItemTargetGUID())
{
- if (!m_targets.GetItemTarget())
+ Item* item = m_targets.GetItemTarget();
+ if (!item)
return SPELL_FAILED_ITEM_GONE;
- if (!m_targets.GetItemTarget()->IsFitToSpellRequirements(m_spellInfo))
+ if (!item->IsFitToSpellRequirements(m_spellInfo))
return SPELL_FAILED_EQUIPPED_ITEM_CLASS;
}
// if not item target then required item must be equipped
@@ -6052,7 +6146,7 @@ SpellCastResult Spell::CheckItems()
}
// do not take reagents for these item casts
- if (!(m_CastItem && m_CastItem->GetTemplate()->Flags & ITEM_PROTO_FLAG_TRIGGERED_CAST))
+ if (!(m_CastItem && m_CastItem->GetTemplate()->Flags & ITEM_FLAG_NO_REAGENT_COST))
{
bool checkReagents = !(_triggeredCastFlags & TRIGGERED_IGNORE_POWER_AND_REAGENT_COST) && !player->CanNoReagentCast(m_spellInfo);
// Not own traded item (in trader trade slot) requires reagents even if triggered spell
@@ -6090,7 +6184,11 @@ SpellCastResult Spell::CheckItems()
}
}
if (!player->HasItemCount(itemid, itemcount))
+ {
+ if (param1)
+ *param1 = itemid;
return SPELL_FAILED_REAGENTS;
+ }
}
}
@@ -6174,7 +6272,7 @@ SpellCastResult Spell::CheckItems()
if (m_targets.GetItemTarget()->GetOwner() != m_caster)
return SPELL_FAILED_NOT_TRADEABLE;
// do not allow to enchant vellum from scroll made by vellum-prevent exploit
- if (m_CastItem && m_CastItem->GetTemplate()->Flags & ITEM_PROTO_FLAG_TRIGGERED_CAST)
+ if (m_CastItem && m_CastItem->GetTemplate()->Flags & ITEM_FLAG_NO_REAGENT_COST)
return SPELL_FAILED_TOTEM_CATEGORY;
ItemPosCountVec dest;
InventoryResult msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, m_spellInfo->Effects[i].ItemType, 1);
@@ -6294,21 +6392,29 @@ SpellCastResult Spell::CheckItems()
}
case SPELL_EFFECT_PROSPECTING:
{
- if (!m_targets.GetItemTarget())
+ Item* item = m_targets.GetItemTarget();
+ if (!item)
return SPELL_FAILED_CANT_BE_PROSPECTED;
//ensure item is a prospectable ore
- if (!(m_targets.GetItemTarget()->GetTemplate()->Flags & ITEM_PROTO_FLAG_PROSPECTABLE))
+ if (!(item->GetTemplate()->Flags & ITEM_FLAG_IS_PROSPECTABLE))
return SPELL_FAILED_CANT_BE_PROSPECTED;
//prevent prospecting in trade slot
- if (m_targets.GetItemTarget()->GetOwnerGUID() != m_caster->GetGUID())
+ if (item->GetOwnerGUID() != m_caster->GetGUID())
return SPELL_FAILED_CANT_BE_PROSPECTED;
//Check for enough skill in jewelcrafting
- uint32 item_prospectingskilllevel = m_targets.GetItemTarget()->GetTemplate()->RequiredSkillRank;
- if (item_prospectingskilllevel >player->GetSkillValue(SKILL_JEWELCRAFTING))
+ uint32 item_prospectingskilllevel = item->GetTemplate()->RequiredSkillRank;
+ if (item_prospectingskilllevel > player->GetSkillValue(SKILL_JEWELCRAFTING))
return SPELL_FAILED_LOW_CASTLEVEL;
//make sure the player has the required ores in inventory
- if (m_targets.GetItemTarget()->GetCount() < 5)
+ if (item->GetCount() < 5)
+ {
+ if (param1 && param2)
+ {
+ *param1 = item->GetEntry();
+ *param2 = 5;
+ }
return SPELL_FAILED_NEED_MORE_ITEMS;
+ }
if (!LootTemplates_Prospecting.HaveLootFor(m_targets.GetItemTargetEntry()))
return SPELL_FAILED_CANT_BE_PROSPECTED;
@@ -6317,21 +6423,29 @@ SpellCastResult Spell::CheckItems()
}
case SPELL_EFFECT_MILLING:
{
- if (!m_targets.GetItemTarget())
+ Item* item = m_targets.GetItemTarget();
+ if (!item)
return SPELL_FAILED_CANT_BE_MILLED;
//ensure item is a millable herb
- if (!(m_targets.GetItemTarget()->GetTemplate()->Flags & ITEM_PROTO_FLAG_MILLABLE))
+ if (!(item->GetTemplate()->Flags & ITEM_FLAG_IS_MILLABLE))
return SPELL_FAILED_CANT_BE_MILLED;
//prevent milling in trade slot
- if (m_targets.GetItemTarget()->GetOwnerGUID() != m_caster->GetGUID())
+ if (item->GetOwnerGUID() != m_caster->GetGUID())
return SPELL_FAILED_CANT_BE_MILLED;
//Check for enough skill in inscription
- uint32 item_millingskilllevel = m_targets.GetItemTarget()->GetTemplate()->RequiredSkillRank;
+ uint32 item_millingskilllevel = item->GetTemplate()->RequiredSkillRank;
if (item_millingskilllevel > player->GetSkillValue(SKILL_INSCRIPTION))
return SPELL_FAILED_LOW_CASTLEVEL;
//make sure the player has the required herbs in inventory
- if (m_targets.GetItemTarget()->GetCount() < 5)
+ if (item->GetCount() < 5)
+ {
+ if (param1 && param2)
+ {
+ *param1 = item->GetEntry();
+ *param2 = 5;
+ }
return SPELL_FAILED_NEED_MORE_ITEMS;
+ }
if (!LootTemplates_Milling.HaveLootFor(m_targets.GetItemTargetEntry()))
return SPELL_FAILED_CANT_BE_MILLED;
@@ -6603,14 +6717,14 @@ bool Spell::UpdatePointers()
CurrentSpellTypes Spell::GetCurrentContainer() const
{
- if (IsNextMeleeSwingSpell())
- return(CURRENT_MELEE_SPELL);
+ if (m_spellInfo->IsNextMeleeSwingSpell())
+ return CURRENT_MELEE_SPELL;
else if (IsAutoRepeat())
- return(CURRENT_AUTOREPEAT_SPELL);
+ return CURRENT_AUTOREPEAT_SPELL;
else if (m_spellInfo->IsChanneled())
- return(CURRENT_CHANNELED_SPELL);
- else
- return(CURRENT_GENERIC_SPELL);
+ return CURRENT_CHANNELED_SPELL;
+
+ return CURRENT_GENERIC_SPELL;
}
bool Spell::CheckEffectTarget(Unit const* target, uint32 eff, Position const* losPosition) const
@@ -6689,11 +6803,6 @@ bool Spell::CheckEffectTarget(Unit const* target, uint32 eff, Position const* lo
return true;
}
-bool Spell::IsNextMeleeSwingSpell() const
-{
- return m_spellInfo->HasAttribute(SPELL_ATTR0_ON_NEXT_SWING);
-}
-
bool Spell::IsAutoActionResetSpell() const
{
/// @todo changed SPELL_INTERRUPT_FLAG_AUTOATTACK -> SPELL_INTERRUPT_FLAG_INTERRUPT to fix compile - is this check correct at all?
@@ -7071,7 +7180,7 @@ void Spell::SetSpellValue(SpellValueMod mod, int32 value)
void Spell::PrepareTargetProcessing()
{
- CheckEffectExecuteData();
+ AssertEffectExecuteData();
}
void Spell::FinishTargetProcessing()
@@ -7096,7 +7205,7 @@ void Spell::InitEffectExecuteData(uint8 effIndex)
}
}
-void Spell::CheckEffectExecuteData()
+void Spell::AssertEffectExecuteData() const
{
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
ASSERT(!m_effectExecuteData[i]);
@@ -7104,29 +7213,20 @@ void Spell::CheckEffectExecuteData()
void Spell::LoadScripts()
{
- sScriptMgr->CreateSpellScripts(m_spellInfo->Id, m_loadedScripts);
- for (std::list<SpellScript*>::iterator itr = m_loadedScripts.begin(); itr != m_loadedScripts.end();)
+ sScriptMgr->CreateSpellScripts(m_spellInfo->Id, m_loadedScripts, this);
+ for (auto itr = m_loadedScripts.begin(); itr != m_loadedScripts.end(); ++itr)
{
- if (!(*itr)->_Load(this))
- {
- std::list<SpellScript*>::iterator bitr = itr;
- ++itr;
- delete (*bitr);
- m_loadedScripts.erase(bitr);
- continue;
- }
TC_LOG_DEBUG("spells", "Spell::LoadScripts: Script `%s` for spell `%u` is loaded now", (*itr)->_GetScriptName()->c_str(), m_spellInfo->Id);
(*itr)->Register();
- ++itr;
}
}
void Spell::CallScriptBeforeCastHandlers()
{
- for (std::list<SpellScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
+ for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
(*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_BEFORE_CAST);
- std::list<SpellScript::CastHandler>::iterator hookItrEnd = (*scritr)->BeforeCast.end(), hookItr = (*scritr)->BeforeCast.begin();
+ auto hookItrEnd = (*scritr)->BeforeCast.end(), hookItr = (*scritr)->BeforeCast.begin();
for (; hookItr != hookItrEnd; ++hookItr)
(*hookItr).Call(*scritr);
@@ -7136,10 +7236,10 @@ void Spell::CallScriptBeforeCastHandlers()
void Spell::CallScriptOnCastHandlers()
{
- for (std::list<SpellScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
+ for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
(*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_ON_CAST);
- std::list<SpellScript::CastHandler>::iterator hookItrEnd = (*scritr)->OnCast.end(), hookItr = (*scritr)->OnCast.begin();
+ auto hookItrEnd = (*scritr)->OnCast.end(), hookItr = (*scritr)->OnCast.begin();
for (; hookItr != hookItrEnd; ++hookItr)
(*hookItr).Call(*scritr);
@@ -7149,10 +7249,10 @@ void Spell::CallScriptOnCastHandlers()
void Spell::CallScriptAfterCastHandlers()
{
- for (std::list<SpellScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
+ for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
(*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_AFTER_CAST);
- std::list<SpellScript::CastHandler>::iterator hookItrEnd = (*scritr)->AfterCast.end(), hookItr = (*scritr)->AfterCast.begin();
+ auto hookItrEnd = (*scritr)->AfterCast.end(), hookItr = (*scritr)->AfterCast.begin();
for (; hookItr != hookItrEnd; ++hookItr)
(*hookItr).Call(*scritr);
@@ -7163,10 +7263,10 @@ void Spell::CallScriptAfterCastHandlers()
SpellCastResult Spell::CallScriptCheckCastHandlers()
{
SpellCastResult retVal = SPELL_CAST_OK;
- for (std::list<SpellScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
+ for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
(*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_CHECK_CAST);
- std::list<SpellScript::CheckCastHandler>::iterator hookItrEnd = (*scritr)->OnCheckCast.end(), hookItr = (*scritr)->OnCheckCast.begin();
+ auto hookItrEnd = (*scritr)->OnCheckCast.end(), hookItr = (*scritr)->OnCheckCast.begin();
for (; hookItr != hookItrEnd; ++hookItr)
{
SpellCastResult tempResult = (*hookItr).Call(*scritr);
@@ -7181,7 +7281,7 @@ SpellCastResult Spell::CallScriptCheckCastHandlers()
void Spell::PrepareScriptHitHandlers()
{
- for (std::list<SpellScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
+ for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
(*scritr)->_InitHit();
}
@@ -7189,9 +7289,9 @@ bool Spell::CallScriptEffectHandlers(SpellEffIndex effIndex, SpellEffectHandleMo
{
// execute script effect handler hooks and check if effects was prevented
bool preventDefault = false;
- for (std::list<SpellScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
+ for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
- std::list<SpellScript::EffectHandler>::iterator effItr, effEndItr;
+ HookList<SpellScript::EffectHandler>::iterator effItr, effEndItr;
SpellScriptHookType hookType;
switch (mode)
{
@@ -7235,10 +7335,10 @@ bool Spell::CallScriptEffectHandlers(SpellEffIndex effIndex, SpellEffectHandleMo
void Spell::CallScriptSuccessfulDispel(SpellEffIndex effIndex)
{
- for (std::list<SpellScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
+ for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
(*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_EFFECT_SUCCESSFUL_DISPEL);
- std::list<SpellScript::EffectHandler>::iterator hookItrEnd = (*scritr)->OnEffectSuccessfulDispel.end(), hookItr = (*scritr)->OnEffectSuccessfulDispel.begin();
+ auto hookItrEnd = (*scritr)->OnEffectSuccessfulDispel.end(), hookItr = (*scritr)->OnEffectSuccessfulDispel.begin();
for (; hookItr != hookItrEnd; ++hookItr)
hookItr->Call(*scritr, effIndex);
@@ -7248,10 +7348,10 @@ void Spell::CallScriptSuccessfulDispel(SpellEffIndex effIndex)
void Spell::CallScriptBeforeHitHandlers()
{
- for (std::list<SpellScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
+ for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
(*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_BEFORE_HIT);
- std::list<SpellScript::HitHandler>::iterator hookItrEnd = (*scritr)->BeforeHit.end(), hookItr = (*scritr)->BeforeHit.begin();
+ auto hookItrEnd = (*scritr)->BeforeHit.end(), hookItr = (*scritr)->BeforeHit.begin();
for (; hookItr != hookItrEnd; ++hookItr)
(*hookItr).Call(*scritr);
@@ -7261,10 +7361,10 @@ void Spell::CallScriptBeforeHitHandlers()
void Spell::CallScriptOnHitHandlers()
{
- for (std::list<SpellScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
+ for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
(*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_HIT);
- std::list<SpellScript::HitHandler>::iterator hookItrEnd = (*scritr)->OnHit.end(), hookItr = (*scritr)->OnHit.begin();
+ auto hookItrEnd = (*scritr)->OnHit.end(), hookItr = (*scritr)->OnHit.begin();
for (; hookItr != hookItrEnd; ++hookItr)
(*hookItr).Call(*scritr);
@@ -7274,10 +7374,10 @@ void Spell::CallScriptOnHitHandlers()
void Spell::CallScriptAfterHitHandlers()
{
- for (std::list<SpellScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
+ for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
(*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_AFTER_HIT);
- std::list<SpellScript::HitHandler>::iterator hookItrEnd = (*scritr)->AfterHit.end(), hookItr = (*scritr)->AfterHit.begin();
+ auto hookItrEnd = (*scritr)->AfterHit.end(), hookItr = (*scritr)->AfterHit.begin();
for (; hookItr != hookItrEnd; ++hookItr)
(*hookItr).Call(*scritr);
@@ -7287,10 +7387,10 @@ void Spell::CallScriptAfterHitHandlers()
void Spell::CallScriptObjectAreaTargetSelectHandlers(std::list<WorldObject*>& targets, SpellEffIndex effIndex, SpellImplicitTargetInfo const& targetType)
{
- for (std::list<SpellScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
+ for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
(*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_OBJECT_AREA_TARGET_SELECT);
- std::list<SpellScript::ObjectAreaTargetSelectHandler>::iterator hookItrEnd = (*scritr)->OnObjectAreaTargetSelect.end(), hookItr = (*scritr)->OnObjectAreaTargetSelect.begin();
+ auto hookItrEnd = (*scritr)->OnObjectAreaTargetSelect.end(), hookItr = (*scritr)->OnObjectAreaTargetSelect.begin();
for (; hookItr != hookItrEnd; ++hookItr)
if (hookItr->IsEffectAffected(m_spellInfo, effIndex) && targetType.GetTarget() == hookItr->GetTarget())
hookItr->Call(*scritr, targets);
@@ -7301,10 +7401,10 @@ void Spell::CallScriptObjectAreaTargetSelectHandlers(std::list<WorldObject*>& ta
void Spell::CallScriptObjectTargetSelectHandlers(WorldObject*& target, SpellEffIndex effIndex, SpellImplicitTargetInfo const& targetType)
{
- for (std::list<SpellScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
+ for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
(*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_OBJECT_TARGET_SELECT);
- std::list<SpellScript::ObjectTargetSelectHandler>::iterator hookItrEnd = (*scritr)->OnObjectTargetSelect.end(), hookItr = (*scritr)->OnObjectTargetSelect.begin();
+ auto hookItrEnd = (*scritr)->OnObjectTargetSelect.end(), hookItr = (*scritr)->OnObjectTargetSelect.begin();
for (; hookItr != hookItrEnd; ++hookItr)
if (hookItr->IsEffectAffected(m_spellInfo, effIndex) && targetType.GetTarget() == hookItr->GetTarget())
hookItr->Call(*scritr, target);
@@ -7315,10 +7415,10 @@ void Spell::CallScriptObjectTargetSelectHandlers(WorldObject*& target, SpellEffI
void Spell::CallScriptDestinationTargetSelectHandlers(SpellDestination& target, SpellEffIndex effIndex, SpellImplicitTargetInfo const& targetType)
{
- for (std::list<SpellScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
+ for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
{
(*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_DESTINATION_TARGET_SELECT);
- std::list<SpellScript::DestinationTargetSelectHandler>::iterator hookItrEnd = (*scritr)->OnDestinationTargetSelect.end(), hookItr = (*scritr)->OnDestinationTargetSelect.begin();
+ auto hookItrEnd = (*scritr)->OnDestinationTargetSelect.end(), hookItr = (*scritr)->OnDestinationTargetSelect.begin();
for (; hookItr != hookItrEnd; ++hookItr)
if (hookItr->IsEffectAffected(m_spellInfo, effIndex) && targetType.GetTarget() == hookItr->GetTarget())
hookItr->Call(*scritr, target);
@@ -7333,15 +7433,15 @@ bool Spell::CheckScriptEffectImplicitTargets(uint32 effIndex, uint32 effIndexToC
if (m_loadedScripts.empty())
return true;
- for (std::list<SpellScript*>::iterator itr = m_loadedScripts.begin(); itr != m_loadedScripts.end(); ++itr)
+ for (auto itr = m_loadedScripts.begin(); itr != m_loadedScripts.end(); ++itr)
{
- std::list<SpellScript::ObjectTargetSelectHandler>::iterator targetSelectHookEnd = (*itr)->OnObjectTargetSelect.end(), targetSelectHookItr = (*itr)->OnObjectTargetSelect.begin();
+ auto targetSelectHookEnd = (*itr)->OnObjectTargetSelect.end(), targetSelectHookItr = (*itr)->OnObjectTargetSelect.begin();
for (; targetSelectHookItr != targetSelectHookEnd; ++targetSelectHookItr)
if (((*targetSelectHookItr).IsEffectAffected(m_spellInfo, effIndex) && !(*targetSelectHookItr).IsEffectAffected(m_spellInfo, effIndexToCheck)) ||
(!(*targetSelectHookItr).IsEffectAffected(m_spellInfo, effIndex) && (*targetSelectHookItr).IsEffectAffected(m_spellInfo, effIndexToCheck)))
return false;
- std::list<SpellScript::ObjectAreaTargetSelectHandler>::iterator areaTargetSelectHookEnd = (*itr)->OnObjectAreaTargetSelect.end(), areaTargetSelectHookItr = (*itr)->OnObjectAreaTargetSelect.begin();
+ auto areaTargetSelectHookEnd = (*itr)->OnObjectAreaTargetSelect.end(), areaTargetSelectHookItr = (*itr)->OnObjectAreaTargetSelect.begin();
for (; areaTargetSelectHookItr != areaTargetSelectHookEnd; ++areaTargetSelectHookItr)
if (((*areaTargetSelectHookItr).IsEffectAffected(m_spellInfo, effIndex) && !(*areaTargetSelectHookItr).IsEffectAffected(m_spellInfo, effIndexToCheck)) ||
(!(*areaTargetSelectHookItr).IsEffectAffected(m_spellInfo, effIndex) && (*areaTargetSelectHookItr).IsEffectAffected(m_spellInfo, effIndexToCheck)))
@@ -7391,25 +7491,24 @@ void Spell::PrepareTriggersExecutedOnHit()
// save auras which were present on spell caster on cast, to prevent triggered auras from affecting caster
// and to correctly calculate proc chance when combopoints are present
Unit::AuraEffectList const& targetTriggers = m_caster->GetAuraEffectsByType(SPELL_AURA_ADD_TARGET_TRIGGER);
- for (Unit::AuraEffectList::const_iterator i = targetTriggers.begin(); i != targetTriggers.end(); ++i)
+ for (AuraEffect const* aurEff : targetTriggers)
{
- if (!(*i)->IsAffectedOnSpell(m_spellInfo))
+ if (!aurEff->IsAffectedOnSpell(m_spellInfo))
continue;
- SpellInfo const* auraSpellInfo = (*i)->GetSpellInfo();
- uint32 auraSpellIdx = (*i)->GetEffIndex();
+
+ SpellInfo const* auraSpellInfo = aurEff->GetSpellInfo();
+ uint32 auraSpellIdx = aurEff->GetEffIndex();
if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(auraSpellInfo->Effects[auraSpellIdx].TriggerSpell))
{
// calculate the chance using spell base amount, because aura amount is not updated on combo-points change
// this possibly needs fixing
- int32 auraBaseAmount = (*i)->GetBaseAmount();
+ int32 auraBaseAmount = aurEff->GetBaseAmount();
// proc chance is stored in effect amount
- int32 chance = m_caster->CalculateSpellDamage(NULL, auraSpellInfo, auraSpellIdx, &auraBaseAmount);
+ int32 chance = m_caster->CalculateSpellDamage(nullptr, auraSpellInfo, auraSpellIdx, &auraBaseAmount);
+ chance *= aurEff->GetBase()->GetStackAmount();
+
// build trigger and add to the list
- HitTriggerSpell spellTriggerInfo;
- spellTriggerInfo.triggeredSpell = spellInfo;
- spellTriggerInfo.triggeredByAura = auraSpellInfo;
- spellTriggerInfo.chance = chance * (*i)->GetBase()->GetStackAmount();
- m_hitTriggerSpells.push_back(spellTriggerInfo);
+ m_hitTriggerSpells.emplace_back(spellInfo, auraSpellInfo, chance);
}
}
}
diff --git a/src/server/game/Spells/Spell.h b/src/server/game/Spells/Spell.h
index 5823ea72dbd..aa3b6ca358a 100644
--- a/src/server/game/Spells/Spell.h
+++ b/src/server/game/Spells/Spell.h
@@ -397,7 +397,7 @@ class TC_GAME_API Spell
void TakeReagents();
void TakeCastItem();
- SpellCastResult CheckCast(bool strict);
+ SpellCastResult CheckCast(bool strict, uint32* param1 = nullptr, uint32* param2 = nullptr);
SpellCastResult CheckPetCast(Unit* target);
// handlers
@@ -407,11 +407,19 @@ class TC_GAME_API Spell
void _handle_immediate_phase();
void _handle_finish_phase();
- SpellCastResult CheckItems();
- SpellCastResult CheckRange(bool strict);
- SpellCastResult CheckPower();
- SpellCastResult CheckRuneCost(uint32 runeCostID);
- SpellCastResult CheckCasterAuras() const;
+ SpellCastResult CheckItems(uint32* param1, uint32* param2) const;
+ SpellCastResult CheckRange(bool strict) const;
+ SpellCastResult CheckPower() const;
+ SpellCastResult CheckRuneCost(uint32 runeCostID) const;
+ SpellCastResult CheckCasterAuras(uint32* param1) const;
+
+ bool CheckCasterHasNotImmunedAuraType(AuraType auraType, uint32* param1) const;
+ bool CheckCasterNotImmunedCharmAuras(uint32* param1) const;
+ bool CheckCasterNotImmunedStunAuras(uint32* param1) const;
+ bool CheckCasterNotImmunedSilenceAuras(uint32* param1) const;
+ bool CheckCasterNotImmunedPacifyAuras(uint32* param1) const;
+ bool CheckCasterNotImmunedFearAuras(uint32* param1) const;
+ bool CheckCasterNotImmunedDisorientAuras(uint32* param1) const;
int32 CalculateDamage(uint8 i, Unit const* target) const { return m_caster->CalculateSpellDamage(target, m_spellInfo, i, &m_spellValue->EffectBasePoints[i]); }
@@ -430,9 +438,9 @@ class TC_GAME_API Spell
void CheckSrc() { if (!m_targets.HasSrc()) m_targets.SetSrc(*m_caster); }
void CheckDst() { if (!m_targets.HasDst()) m_targets.SetDst(*m_caster); }
- static void WriteCastResultInfo(WorldPacket& data, Player* caster, SpellInfo const* spellInfo, uint8 castCount, SpellCastResult result, SpellCustomErrors customError);
- static void SendCastResult(Player* caster, SpellInfo const* spellInfo, uint8 castCount, SpellCastResult result, SpellCustomErrors customError = SPELL_CUSTOM_ERROR_NONE);
- void SendCastResult(SpellCastResult result);
+ static void WriteCastResultInfo(WorldPacket& data, Player* caster, SpellInfo const* spellInfo, uint8 castCount, SpellCastResult result, SpellCustomErrors customError, uint32* param1 = nullptr, uint32* param2 = nullptr);
+ static void SendCastResult(Player* caster, SpellInfo const* spellInfo, uint8 castCount, SpellCastResult result, SpellCustomErrors customError = SPELL_CUSTOM_ERROR_NONE, uint32* param1 = nullptr, uint32* param2 = nullptr);
+ void SendCastResult(SpellCastResult result, uint32* param1 = nullptr, uint32* param2 = nullptr) const;
void SendPetCastResult(SpellCastResult result);
void SendSpellStart();
void SendSpellGo();
@@ -473,12 +481,14 @@ class TC_GAME_API Spell
bool IsAutoRepeat() const { return m_autoRepeat; }
void SetAutoRepeat(bool rep) { m_autoRepeat = rep; }
void ReSetTimer() { m_timer = m_casttime > 0 ? m_casttime : 0; }
- bool IsNextMeleeSwingSpell() const;
bool IsTriggered() const { return (_triggeredCastFlags & TRIGGERED_FULL_MASK) != 0; }
bool IsIgnoringCooldowns() const { return (_triggeredCastFlags & TRIGGERED_IGNORE_SPELL_AND_CATEGORY_CD) != 0; }
+ bool IsProcDisabled() const { return (_triggeredCastFlags & TRIGGERED_DISALLOW_PROC_EVENTS) != 0; }
bool IsChannelActive() const { return m_caster->GetUInt32Value(UNIT_CHANNEL_SPELL) != 0; }
bool IsAutoActionResetSpell() const;
+ bool IsTriggeredByAura(SpellInfo const* auraSpellInfo) const { return (auraSpellInfo == m_triggeredByAuraSpell); }
+
bool IsDeletable() const { return !m_referencedFromCurrentSpell && !m_executedCurrently; }
void SetReferencedFromCurrent(bool yes) { m_referencedFromCurrentSpell = yes; }
bool IsInterruptable() const { return !m_executedCurrently; }
@@ -507,7 +517,7 @@ class TC_GAME_API Spell
void CancelGlobalCooldown();
void SendLoot(ObjectGuid guid, LootType loottype);
- std::pair<float, float> GetMinMaxRange(bool strict);
+ std::pair<float, float> GetMinMaxRange(bool strict) const;
Unit* const m_caster;
@@ -561,10 +571,6 @@ class TC_GAME_API Spell
// used in effects handlers
Aura* m_spellAura;
- // this is set in Spell Hit, but used in Apply Aura handler
- DiminishingLevels m_diminishLevel;
- DiminishingGroup m_diminishGroup;
-
// -------------------------------------------
GameObject* focusObject;
@@ -640,7 +646,7 @@ class TC_GAME_API Spell
// spell execution log
void InitEffectExecuteData(uint8 effIndex);
- void CheckEffectExecuteData();
+ void AssertEffectExecuteData() const;
// Scripting system
void LoadScripts();
@@ -658,10 +664,13 @@ class TC_GAME_API Spell
void CallScriptObjectTargetSelectHandlers(WorldObject*& target, SpellEffIndex effIndex, SpellImplicitTargetInfo const& targetType);
void CallScriptDestinationTargetSelectHandlers(SpellDestination& target, SpellEffIndex effIndex, SpellImplicitTargetInfo const& targetType);
bool CheckScriptEffectImplicitTargets(uint32 effIndex, uint32 effIndexToCheck);
- std::list<SpellScript*> m_loadedScripts;
+ std::vector<SpellScript*> m_loadedScripts;
struct HitTriggerSpell
{
+ HitTriggerSpell(SpellInfo const* spellInfo, SpellInfo const* auraSpellInfo, int32 procChance) :
+ triggeredSpell(spellInfo), triggeredByAura(auraSpellInfo), chance(procChance) { }
+
SpellInfo const* triggeredSpell;
SpellInfo const* triggeredByAura;
// uint8 triggeredByEffIdx This might be needed at a later stage - No need known for now
@@ -670,7 +679,7 @@ class TC_GAME_API Spell
bool CanExecuteTriggersOnHit(uint8 effMask, SpellInfo const* triggeredByAura = NULL) const;
void PrepareTriggersExecutedOnHit();
- typedef std::list<HitTriggerSpell> HitTriggerSpellList;
+ typedef std::vector<HitTriggerSpell> HitTriggerSpellList;
HitTriggerSpellList m_hitTriggerSpells;
// effect helpers
diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp
index 9867b25259b..7afcf52172a 100644
--- a/src/server/game/Spells/SpellEffects.cpp
+++ b/src/server/game/Spells/SpellEffects.cpp
@@ -292,14 +292,18 @@ void Spell::EffectEnvironmentalDMG(SpellEffIndex /*effIndex*/)
if (!unitTarget || !unitTarget->IsAlive())
return;
- uint32 absorb = 0;
- uint32 resist = 0;
-
- m_caster->CalcAbsorbResist(unitTarget, m_spellInfo->GetSchoolMask(), SPELL_DIRECT_DAMAGE, damage, &absorb, &resist, m_spellInfo);
-
- m_caster->SendSpellNonMeleeDamageLog(unitTarget, m_spellInfo->Id, damage, m_spellInfo->GetSchoolMask(), absorb, resist, false, 0, false);
+ // CalcAbsorbResist already in Player::EnvironmentalDamage
if (unitTarget->GetTypeId() == TYPEID_PLAYER)
unitTarget->ToPlayer()->EnvironmentalDamage(DAMAGE_FIRE, damage);
+ else
+ {
+ DamageInfo damageInfo(m_caster, unitTarget, damage, m_spellInfo, m_spellInfo->GetSchoolMask(), SPELL_DIRECT_DAMAGE, BASE_ATTACK);
+ m_caster->CalcAbsorbResist(damageInfo);
+
+ uint32 absorb = damageInfo.GetAbsorb();
+ uint32 resist = damageInfo.GetResist();
+ m_caster->SendSpellNonMeleeDamageLog(unitTarget, m_spellInfo->Id, damage, m_spellInfo->GetSchoolMask(), absorb, resist, false, 0, false);
+ }
}
void Spell::EffectSchoolDMG(SpellEffIndex effIndex)
@@ -395,9 +399,9 @@ void Spell::EffectSchoolDMG(SpellEffIndex effIndex)
// Conflagrate - consumes Immolate or Shadowflame
else if (m_spellInfo->TargetAuraState == AURA_STATE_CONFLAGRATE)
{
- AuraEffect const* aura = NULL; // found req. aura for damage calculation
+ AuraEffect const* aura = nullptr; // found req. aura for damage calculation
- Unit::AuraEffectList const &mPeriodic = unitTarget->GetAuraEffectsByType(SPELL_AURA_PERIODIC_DAMAGE);
+ Unit::AuraEffectList const& mPeriodic = unitTarget->GetAuraEffectsByType(SPELL_AURA_PERIODIC_DAMAGE);
for (Unit::AuraEffectList::const_iterator i = mPeriodic.begin(); i != mPeriodic.end(); ++i)
{
// for caster applied auras only
@@ -420,15 +424,22 @@ void Spell::EffectSchoolDMG(SpellEffIndex effIndex)
// found Immolate or Shadowflame
if (aura)
{
- uint32 pdamage = uint32(std::max(aura->GetAmount(), 0));
- pdamage = m_caster->SpellDamageBonusDone(unitTarget, aura->GetSpellInfo(), pdamage, DOT, aura->GetBase()->GetStackAmount());
- pdamage = unitTarget->SpellDamageBonusTaken(m_caster, aura->GetSpellInfo(), pdamage, DOT, aura->GetBase()->GetStackAmount());
- uint32 pct_dir = m_caster->CalculateSpellDamage(unitTarget, m_spellInfo, (effIndex + 1));
- uint8 baseTotalTicks = uint8(m_caster->CalcSpellDuration(aura->GetSpellInfo()) / aura->GetSpellInfo()->Effects[EFFECT_0].Amplitude);
- damage += int32(CalculatePct(pdamage * baseTotalTicks, pct_dir));
+ // Calculate damage of Immolate/Shadowflame tick
+ int32 pdamage = (aura->GetAmount() + aura->GetBonusAmount()) * aura->GetDonePct();
+ if (Player* modOwner = m_caster->GetSpellModOwner())
+ modOwner->ApplySpellMod<SPELLMOD_DOT>(GetSpellInfo()->Id, pdamage);
- uint32 pct_dot = m_caster->CalculateSpellDamage(unitTarget, m_spellInfo, (effIndex + 2)) / 3;
- m_spellValue->EffectBasePoints[1] = m_spellInfo->Effects[EFFECT_1].CalcBaseValue(int32(CalculatePct(pdamage * baseTotalTicks, pct_dot)));
+ pdamage = unitTarget->SpellDamageBonusTaken(m_caster, aura->GetSpellInfo(), pdamage, DOT);
+
+ // And multiply by amount of ticks to get damage potential
+ pdamage *= aura->GetSpellInfo()->GetMaxTicks();
+
+ int32 pct_dir = m_caster->CalculateSpellDamage(unitTarget, m_spellInfo, EFFECT_1);
+ damage += CalculatePct(pdamage, pct_dir);
+
+ int32 pct_dot = m_caster->CalculateSpellDamage(unitTarget, m_spellInfo, EFFECT_2);
+ int32 const dotBasePoints = CalculatePct(pdamage, pct_dot);
+ m_spellValue->EffectBasePoints[EFFECT_1] = dotBasePoints / m_spellInfo->GetMaxTicks();
apply_direct_bonus = false;
// Glyph of Conflagrate
@@ -1393,9 +1404,12 @@ void Spell::EffectHeal(SpellEffIndex /*effIndex*/)
return;
}
- int32 tickheal = targetAura->GetAmount();
- if (Unit* auraCaster = targetAura->GetCaster())
- tickheal = auraCaster->SpellHealingBonusDone(unitTarget, targetAura->GetSpellInfo(), tickheal, DOT);
+ int32 tickheal = (targetAura->GetAmount() + targetAura->GetBonusAmount()) * targetAura->GetDonePct();
+ if (Player* modOwner = m_caster->GetSpellModOwner())
+ modOwner->ApplySpellMod<SPELLMOD_DOT>(targetAura->GetId(), tickheal);
+
+ unitTarget->SpellHealingBonusTaken(m_caster, targetAura->GetSpellInfo(), tickheal, DOT);
+
//int32 tickheal = targetAura->GetSpellInfo()->EffectBasePoints[idx] + 1;
//It is said that talent bonus should not be included
@@ -2023,7 +2037,7 @@ void Spell::EffectOpenLock(SpellEffIndex effIndex)
if (gameObjTarget)
SendLoot(guid, LOOT_SKINNING);
else if (itemTarget)
- itemTarget->SetFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_UNLOCKED);
+ itemTarget->SetFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_UNLOCKED);
// not allow use skill grow at item base open
if (!m_CastItem && skillId != SKILL_NONE)
@@ -2103,6 +2117,8 @@ void Spell::EffectSummonChangeItem(SpellEffIndex effIndex)
m_castItemEntry = 0;
player->StoreItem(dest, pNewItem, true);
+ player->SendNewItem(pNewItem, 1, true, false);
+ player->ItemAddedQuestCheck(newitemid, 1);
return;
}
}
@@ -2147,6 +2163,8 @@ void Spell::EffectSummonChangeItem(SpellEffIndex effIndex)
player->EquipItem(dest, pNewItem, true);
player->AutoUnequipOffhandIfNeed();
+ player->SendNewItem(pNewItem, 1, true, false);
+ player->ItemAddedQuestCheck(newitemid, 1);
return;
}
}
@@ -2686,7 +2704,7 @@ void Spell::EffectEnchantItemPerm(SpellEffIndex effIndex)
else
{
// do not increase skill if vellum used
- if (!(m_CastItem && m_CastItem->GetTemplate()->Flags & ITEM_PROTO_FLAG_TRIGGERED_CAST))
+ if (!(m_CastItem && m_CastItem->GetTemplate()->Flags & ITEM_FLAG_NO_REAGENT_COST))
player->UpdateCraftSkill(m_spellInfo->Id);
uint32 enchant_id = m_spellInfo->Effects[effIndex].MiscValue;
@@ -3362,8 +3380,10 @@ void Spell::EffectWeaponDmg(SpellEffIndex effIndex)
}
}
- // apply to non-weapon bonus weapon total pct effect, weapon total flat effect included in weapon damage
- if (fixed_bonus || spell_bonus)
+ // if (addPctMods) { percent mods are added in Unit::CalculateDamage } else { percent mods are added in Unit::MeleeDamageBonusDone }
+ // this distinction is neccessary to properly inform the client about his autoattack damage values from Script_UnitDamage
+ bool addPctMods = !m_spellInfo->HasAttribute(SPELL_ATTR6_NO_DONE_PCT_DAMAGE_MODS) && (m_spellSchoolMask & SPELL_SCHOOL_MASK_NORMAL);
+ if (addPctMods)
{
UnitMods unitMod;
switch (m_attackType)
@@ -3374,17 +3394,14 @@ void Spell::EffectWeaponDmg(SpellEffIndex effIndex)
case RANGED_ATTACK: unitMod = UNIT_MOD_DAMAGE_RANGED; break;
}
- float weapon_total_pct = 1.0f;
- if (m_spellInfo->SchoolMask & SPELL_SCHOOL_MASK_NORMAL)
- weapon_total_pct = m_caster->GetModifierValue(unitMod, TOTAL_PCT);
-
+ float weapon_total_pct = m_caster->GetModifierValue(unitMod, TOTAL_PCT);
if (fixed_bonus)
fixed_bonus = int32(fixed_bonus * weapon_total_pct);
if (spell_bonus)
spell_bonus = int32(spell_bonus * weapon_total_pct);
}
- int32 weaponDamage = m_caster->CalculateDamage(m_attackType, normalized, true);
+ int32 weaponDamage = m_caster->CalculateDamage(m_attackType, normalized, addPctMods);
// Sequence is important
for (int j = 0; j < MAX_SPELL_EFFECTS; ++j)
@@ -3399,17 +3416,14 @@ void Spell::EffectWeaponDmg(SpellEffIndex effIndex)
weaponDamage += fixed_bonus;
break;
case SPELL_EFFECT_WEAPON_PERCENT_DAMAGE:
- weaponDamage = int32(weaponDamage* weaponDamagePercentMod);
+ weaponDamage = int32(weaponDamage * weaponDamagePercentMod);
default:
break; // not weapon damage effect, just skip
}
}
- if (spell_bonus)
- weaponDamage += spell_bonus;
-
- if (totalDamagePercentMod != 1.0f)
- weaponDamage = int32(weaponDamage* totalDamagePercentMod);
+ weaponDamage += spell_bonus;
+ weaponDamage = int32(weaponDamage * totalDamagePercentMod);
// prevent negative damage
uint32 eff_damage(std::max(weaponDamage, 0));
@@ -3531,21 +3545,12 @@ void Spell::EffectSummonObjectWild(SpellEffIndex effIndex)
if (Battleground* bg = player->GetBattleground())
bg->SetDroppedFlagGUID(pGameObj->GetGUID(), player->GetTeam() == ALLIANCE ? TEAM_HORDE: TEAM_ALLIANCE);
- if (uint32 linkedEntry = pGameObj->GetGOInfo()->GetLinkedGameObjectEntry())
+ if (GameObject* linkedTrap = pGameObj->GetLinkedTrap())
{
- GameObject* linkedGO = new GameObject();
- if (linkedGO->Create(map->GenerateLowGuid<HighGuid::GameObject>(), linkedEntry, map, m_caster->GetPhaseMask(), Position(x, y, z, target->GetOrientation()), rot, 255, GO_STATE_READY))
- {
- linkedGO->SetRespawnTime(duration > 0 ? duration/IN_MILLISECONDS : 0);
- linkedGO->SetSpellId(m_spellInfo->Id);
-
- ExecuteLogEffectSummonObject(effIndex, linkedGO);
+ linkedTrap->SetRespawnTime(duration > 0 ? duration / IN_MILLISECONDS : 0);
+ linkedTrap->SetSpellId(m_spellInfo->Id);
- // Wild object not have owner and check clickable by players
- map->AddToMap(linkedGO);
- }
- else
- delete linkedGO;
+ ExecuteLogEffectSummonObject(effIndex, linkedTrap);
}
}
@@ -4495,10 +4500,10 @@ void Spell::EffectAddExtraAttacks(SpellEffIndex effIndex)
if (!unitTarget || !unitTarget->IsAlive())
return;
- if (unitTarget->HasExtraAttacksPending())
+ if (unitTarget->m_extraAttacks)
return;
- unitTarget->SetExtraAttacks(damage);
+ unitTarget->m_extraAttacks = damage;
ExecuteLogEffectExtraAttacks(effIndex, unitTarget, damage);
}
@@ -4579,8 +4584,8 @@ void Spell::EffectQuestComplete(SpellEffIndex effIndex)
uint16 logSlot = player->FindQuestSlot(questId);
if (logSlot < MAX_QUEST_LOG_SIZE)
player->AreaExploredOrEventHappens(questId);
- else if (player->CanTakeQuest(quest, false)) // Check if the quest has already been turned in.
- player->SetRewardedQuest(questId); // If not, set status to rewarded without broadcasting it to client.
+ else if (quest->HasFlag(QUEST_FLAGS_TRACKING)) // Check if the quest is used as a serverside flag.
+ player->SetRewardedQuest(questId); // If so, set status to rewarded without broadcasting it to client.
}
}
@@ -4757,7 +4762,7 @@ void Spell::EffectLeapBack(SpellEffIndex effIndex)
float speedxy = m_spellInfo->Effects[effIndex].MiscValue / 10.f;
float speedz = damage/ 10.f;
//1891: Disengage
- m_caster->JumpTo(speedxy, speedz, m_spellInfo->SpellIconID != 1891);
+ unitTarget->JumpTo(speedxy, speedz, m_spellInfo->SpellIconID != 1891);
}
void Spell::EffectQuestClear(SpellEffIndex effIndex)
@@ -5137,26 +5142,14 @@ void Spell::EffectTransmitted(SpellEffIndex effIndex)
cMap->AddToMap(pGameObj);
- if (uint32 linkedEntry = pGameObj->GetGOInfo()->GetLinkedGameObjectEntry())
+ if (GameObject* linkedTrap = pGameObj->GetLinkedTrap())
{
- GameObject* linkedGO = new GameObject;
- if (linkedGO->Create(cMap->GenerateLowGuid<HighGuid::GameObject>(), linkedEntry, cMap, m_caster->GetPhaseMask(), pos, rot, 255, GO_STATE_READY))
- {
- linkedGO->SetRespawnTime(duration > 0 ? duration/IN_MILLISECONDS : 0);
- //linkedGO->SetUInt32Value(GAMEOBJECT_LEVEL, m_caster->getLevel());
- linkedGO->SetSpellId(m_spellInfo->Id);
- linkedGO->SetOwnerGUID(m_caster->GetGUID());
+ linkedTrap->SetRespawnTime(duration > 0 ? duration/IN_MILLISECONDS : 0);
+ //linkedTrap->SetUInt32Value(GAMEOBJECT_LEVEL, m_caster->getLevel());
+ linkedTrap->SetSpellId(m_spellInfo->Id);
+ linkedTrap->SetOwnerGUID(m_caster->GetGUID());
- ExecuteLogEffectSummonObject(effIndex, linkedGO);
-
- linkedGO->GetMap()->AddToMap(linkedGO);
- }
- else
- {
- delete linkedGO;
- linkedGO = NULL;
- return;
- }
+ ExecuteLogEffectSummonObject(effIndex, linkedTrap);
}
}
@@ -5169,7 +5162,7 @@ void Spell::EffectProspecting(SpellEffIndex /*effIndex*/)
if (!player)
return;
- if (!itemTarget || !(itemTarget->GetTemplate()->Flags & ITEM_PROTO_FLAG_PROSPECTABLE))
+ if (!itemTarget || !(itemTarget->GetTemplate()->Flags & ITEM_FLAG_IS_PROSPECTABLE))
return;
if (itemTarget->GetCount() < 5)
@@ -5194,7 +5187,7 @@ void Spell::EffectMilling(SpellEffIndex /*effIndex*/)
if (!player)
return;
- if (!itemTarget || !(itemTarget->GetTemplate()->Flags & ITEM_PROTO_FLAG_MILLABLE))
+ if (!itemTarget || !(itemTarget->GetTemplate()->Flags & ITEM_FLAG_IS_MILLABLE))
return;
if (itemTarget->GetCount() < 5)
diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp
index f69f49eb509..c0fbdf51889 100644
--- a/src/server/game/Spells/SpellInfo.cpp
+++ b/src/server/game/Spells/SpellInfo.cpp
@@ -16,6 +16,7 @@
*/
#include "SpellAuraDefines.h"
+#include "SpellAuras.h"
#include "SpellInfo.h"
#include "SpellMgr.h"
#include "Spell.h"
@@ -855,6 +856,9 @@ SpellInfo::SpellInfo(SpellEntry const* spellEntry)
ChainEntry = NULL;
ExplicitTargetMask = 0;
+
+ _spellSpecific = SPELL_SPECIFIC_NORMAL;
+ _auraState = AURA_STATE_NONE;
}
SpellInfo::~SpellInfo()
@@ -891,6 +895,31 @@ bool SpellInfo::HasAreaAuraEffect() const
return false;
}
+bool SpellInfo::HasOnlyDamageEffects() const
+{
+ for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
+ {
+ if (Effects[i].IsEffect())
+ {
+ switch (Effects[i].Effect)
+ {
+ case SPELL_EFFECT_WEAPON_DAMAGE:
+ case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL:
+ case SPELL_EFFECT_NORMALIZED_WEAPON_DMG:
+ case SPELL_EFFECT_WEAPON_PERCENT_DAMAGE:
+ case SPELL_EFFECT_SCHOOL_DAMAGE:
+ case SPELL_EFFECT_ENVIRONMENTAL_DAMAGE:
+ case SPELL_EFFECT_HEALTH_LEECH:
+ continue;
+ default:
+ return false;
+ }
+ }
+ }
+
+ return true;
+}
+
bool SpellInfo::IsExplicitDiscovery() const
{
return ((Effects[0].Effect == SPELL_EFFECT_CREATE_RANDOM_ITEM
@@ -1178,12 +1207,22 @@ bool SpellInfo::IsPositiveEffect(uint8 effIndex) const
bool SpellInfo::IsChanneled() const
{
- return HasAttribute(SPELL_ATTR1_CHANNELED_1) || HasAttribute(SPELL_ATTR1_CHANNELED_2);
+ return HasAttribute(SpellAttr1(SPELL_ATTR1_CHANNELED_1 | SPELL_ATTR1_CHANNELED_2));
+}
+
+bool SpellInfo::IsMoveAllowedChannel() const
+{
+ return IsChanneled() && HasAttribute(SPELL_ATTR5_CAN_CHANNEL_WHEN_MOVING);
}
bool SpellInfo::NeedsComboPoints() const
{
- return HasAttribute(SPELL_ATTR1_REQ_COMBO_POINTS1) || HasAttribute(SPELL_ATTR1_REQ_COMBO_POINTS2);
+ return HasAttribute(SpellAttr1(SPELL_ATTR1_REQ_COMBO_POINTS1 | SPELL_ATTR1_REQ_COMBO_POINTS2));
+}
+
+bool SpellInfo::IsNextMeleeSwingSpell() const
+{
+ return HasAttribute(SpellAttr0(SPELL_ATTR0_ON_NEXT_SWING | SPELL_ATTR0_ON_NEXT_SWING_2));
}
bool SpellInfo::IsBreakingStealth() const
@@ -1207,6 +1246,20 @@ bool SpellInfo::HasInitialAggro() const
return !(HasAttribute(SPELL_ATTR1_NO_THREAT) || HasAttribute(SPELL_ATTR3_NO_INITIAL_AGGRO));
}
+bool SpellInfo::IsAffected(uint32 familyName, flag96 const& familyFlags) const
+{
+ if (!familyName)
+ return true;
+
+ if (familyName != SpellFamilyName)
+ return false;
+
+ if (familyFlags && !(familyFlags & SpellFamilyFlags))
+ return false;
+
+ return true;
+}
+
bool SpellInfo::IsAffectedBySpellMods() const
{
return !HasAttribute(SPELL_ATTR3_NO_DONE_BONUS);
@@ -1218,42 +1271,41 @@ bool SpellInfo::IsAffectedBySpellMod(SpellModifier const* mod) const
return false;
SpellInfo const* affectSpell = sSpellMgr->GetSpellInfo(mod->spellId);
- // False if affect_spell == NULL or spellFamily not equal
- if (!affectSpell || affectSpell->SpellFamilyName != SpellFamilyName)
+ if (!affectSpell)
return false;
- // true
- if (mod->mask & SpellFamilyFlags)
- return true;
-
- return false;
+ return IsAffected(affectSpell->SpellFamilyName, mod->mask);
}
-bool SpellInfo::CanPierceImmuneAura(SpellInfo const* aura) const
+bool SpellInfo::CanPierceImmuneAura(SpellInfo const* auraSpellInfo) const
{
- // these spells pierce all avalible spells (Resurrection Sickness for example)
+ // aura can't be pierced
+ if (!auraSpellInfo || auraSpellInfo->HasAttribute(SPELL_ATTR0_UNAFFECTED_BY_INVULNERABILITY))
+ return false;
+
+ // these spells pierce all available spells (Resurrection Sickness for example)
if (HasAttribute(SPELL_ATTR0_UNAFFECTED_BY_INVULNERABILITY))
return true;
- // these spells (Cyclone for example) can pierce all... // ...but not these (Divine shield, Ice block, Cyclone and Banish for example)
- if (HasAttribute(SPELL_ATTR1_UNAFFECTED_BY_SCHOOL_IMMUNE) && !(aura && (aura->Mechanic == MECHANIC_IMMUNE_SHIELD || aura->Mechanic == MECHANIC_INVULNERABILITY || aura->Mechanic == MECHANIC_BANISH)))
+ // Dispels other auras on immunity, check if this spell makes the unit immune to aura
+ if (HasAttribute(SPELL_ATTR1_DISPEL_AURAS_ON_IMMUNITY) && CanSpellProvideImmunityAgainstAura(auraSpellInfo))
return true;
return false;
}
-bool SpellInfo::CanDispelAura(SpellInfo const* aura) const
+bool SpellInfo::CanDispelAura(SpellInfo const* auraSpellInfo) const
{
- // These spells (like Mass Dispel) can dispell all auras, except death persistent ones (like Dungeon and Battleground Deserter)
- if (HasAttribute(SPELL_ATTR0_UNAFFECTED_BY_INVULNERABILITY) && !aura->IsDeathPersistent())
- return true;
-
// These auras (like Divine Shield) can't be dispelled
- if (aura->HasAttribute(SPELL_ATTR0_UNAFFECTED_BY_INVULNERABILITY))
+ if (auraSpellInfo->HasAttribute(SPELL_ATTR0_UNAFFECTED_BY_INVULNERABILITY))
return false;
+ // These spells (like Mass Dispel) can dispel all auras
+ if (HasAttribute(SPELL_ATTR0_UNAFFECTED_BY_INVULNERABILITY))
+ return true;
+
// These auras (Cyclone for example) are not dispelable
- if (aura->HasAttribute(SPELL_ATTR1_UNAFFECTED_BY_SCHOOL_IMMUNE))
+ if (auraSpellInfo->HasAttribute(SPELL_ATTR1_UNAFFECTED_BY_SCHOOL_IMMUNE) || auraSpellInfo->HasAttribute(SPELL_ATTR2_UNAFFECTED_BY_AURA_SCHOOL_IMMUNE))
return false;
return true;
@@ -1408,9 +1460,11 @@ SpellCastResult SpellInfo::CheckLocation(uint32 map_id, uint32 zone_id, uint32 a
// continent limitation (virtual continent)
if (HasAttribute(SPELL_ATTR4_CAST_ONLY_IN_OUTLAND))
{
- uint32 v_map = GetVirtualMapForMapAndZone(map_id, zone_id);
- MapEntry const* mapEntry = sMapStore.LookupEntry(v_map);
- if (!mapEntry || mapEntry->addon < 1 || !mapEntry->IsContinent())
+ AreaTableEntry const* areaEntry = sAreaTableStore.LookupEntry(area_id);
+ if (!areaEntry)
+ areaEntry = sAreaTableStore.LookupEntry(zone_id);
+
+ if (!areaEntry || !areaEntry->IsFlyable() || !player->CanFlyInZone(map_id, zone_id))
return SPELL_FAILED_INCORRECT_AREA;
}
@@ -1854,239 +1908,1037 @@ uint32 SpellInfo::GetExplicitTargetMask() const
AuraStateType SpellInfo::GetAuraState() const
{
- // Seals
- if (GetSpellSpecific() == SPELL_SPECIFIC_SEAL)
- return AURA_STATE_JUDGEMENT;
-
- // Conflagrate aura state on Immolate and Shadowflame
- if (SpellFamilyName == SPELLFAMILY_WARLOCK &&
- // Immolate
- ((SpellFamilyFlags[0] & 4) ||
- // Shadowflame
- (SpellFamilyFlags[2] & 2)))
- return AURA_STATE_CONFLAGRATE;
-
- // Faerie Fire (druid versions)
- if (SpellFamilyName == SPELLFAMILY_DRUID && SpellFamilyFlags[0] & 0x400)
- return AURA_STATE_FAERIE_FIRE;
-
- // Sting (hunter's pet ability)
- if (GetCategory() == 1133)
- return AURA_STATE_FAERIE_FIRE;
-
- // Victorious
- if (SpellFamilyName == SPELLFAMILY_WARRIOR && SpellFamilyFlags[1] & 0x00040000)
- return AURA_STATE_WARRIOR_VICTORY_RUSH;
-
- // Swiftmend state on Regrowth & Rejuvenation
- if (SpellFamilyName == SPELLFAMILY_DRUID && SpellFamilyFlags[0] & 0x50)
- return AURA_STATE_SWIFTMEND;
-
- // Deadly poison aura state
- if (SpellFamilyName == SPELLFAMILY_ROGUE && SpellFamilyFlags[0] & 0x10000)
- return AURA_STATE_DEADLY_POISON;
-
- // Enrage aura state
- if (Dispel == DISPEL_ENRAGE)
- return AURA_STATE_ENRAGE;
-
- // Bleeding aura state
- if (GetAllEffectsMechanicMask() & 1<<MECHANIC_BLEED)
- return AURA_STATE_BLEEDING;
-
- if (GetSchoolMask() & SPELL_SCHOOL_MASK_FROST)
- for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
- if (Effects[i].IsAura() && (Effects[i].ApplyAuraName == SPELL_AURA_MOD_STUN
- || Effects[i].ApplyAuraName == SPELL_AURA_MOD_ROOT))
- return AURA_STATE_FROZEN;
+ return _auraState;
+}
- switch (Id)
+void SpellInfo::_LoadAuraState()
+{
+ _auraState = [this]() -> AuraStateType
{
- case 71465: // Divine Surge
- case 50241: // Evasive Charges
- return AURA_STATE_UNKNOWN22;
- default:
- break;
- }
+ // Seals
+ if (GetSpellSpecific() == SPELL_SPECIFIC_SEAL)
+ return AURA_STATE_JUDGEMENT;
+
+ // Conflagrate aura state on Immolate and Shadowflame
+ if (SpellFamilyName == SPELLFAMILY_WARLOCK &&
+ // Immolate
+ ((SpellFamilyFlags[0] & 4) ||
+ // Shadowflame
+ (SpellFamilyFlags[2] & 2)))
+ return AURA_STATE_CONFLAGRATE;
+
+ // Faerie Fire (druid versions)
+ if (SpellFamilyName == SPELLFAMILY_DRUID && SpellFamilyFlags[0] & 0x400)
+ return AURA_STATE_FAERIE_FIRE;
+
+ // Sting (hunter's pet ability)
+ if (GetCategory() == 1133)
+ return AURA_STATE_FAERIE_FIRE;
+
+ // Victorious
+ if (SpellFamilyName == SPELLFAMILY_WARRIOR && SpellFamilyFlags[1] & 0x00040000)
+ return AURA_STATE_WARRIOR_VICTORY_RUSH;
+
+ // Swiftmend state on Regrowth & Rejuvenation
+ if (SpellFamilyName == SPELLFAMILY_DRUID && SpellFamilyFlags[0] & 0x50)
+ return AURA_STATE_SWIFTMEND;
+
+ // Deadly poison aura state
+ if (SpellFamilyName == SPELLFAMILY_ROGUE && SpellFamilyFlags[0] & 0x10000)
+ return AURA_STATE_DEADLY_POISON;
+
+ // Enrage aura state
+ if (Dispel == DISPEL_ENRAGE)
+ return AURA_STATE_ENRAGE;
+
+ // Bleeding aura state
+ if (GetAllEffectsMechanicMask() & 1 << MECHANIC_BLEED)
+ return AURA_STATE_BLEEDING;
+
+ if (GetSchoolMask() & SPELL_SCHOOL_MASK_FROST)
+ for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
+ if (Effects[i].IsAura() && (Effects[i].ApplyAuraName == SPELL_AURA_MOD_STUN
+ || Effects[i].ApplyAuraName == SPELL_AURA_MOD_ROOT))
+ return AURA_STATE_FROZEN;
+
+ switch (Id)
+ {
+ case 71465: // Divine Surge
+ case 50241: // Evasive Charges
+ return AURA_STATE_UNKNOWN22;
+ default:
+ break;
+ }
- return AURA_STATE_NONE;
+ return AURA_STATE_NONE;
+ }();
}
SpellSpecificType SpellInfo::GetSpellSpecific() const
{
- switch (SpellFamilyName)
+ return _spellSpecific;
+}
+
+void SpellInfo::_LoadSpellSpecific()
+{
+ _spellSpecific = [this]() -> SpellSpecificType
{
- case SPELLFAMILY_GENERIC:
+ switch (SpellFamilyName)
{
- // Food / Drinks (mostly)
- if (AuraInterruptFlags & AURA_INTERRUPT_FLAG_NOT_SEATED)
+ case SPELLFAMILY_GENERIC:
{
- bool food = false;
- bool drink = false;
- for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
+ // Food / Drinks (mostly)
+ if (AuraInterruptFlags & AURA_INTERRUPT_FLAG_NOT_SEATED)
{
- if (!Effects[i].IsAura())
- continue;
- switch (Effects[i].ApplyAuraName)
+ bool food = false;
+ bool drink = false;
+ for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
{
- // Food
- case SPELL_AURA_MOD_REGEN:
- case SPELL_AURA_OBS_MOD_HEALTH:
- food = true;
- break;
- // Drink
- case SPELL_AURA_MOD_POWER_REGEN:
- case SPELL_AURA_OBS_MOD_POWER:
- drink = true;
+ if (!Effects[i].IsAura())
+ continue;
+ switch (Effects[i].ApplyAuraName)
+ {
+ // Food
+ case SPELL_AURA_MOD_REGEN:
+ case SPELL_AURA_OBS_MOD_HEALTH:
+ food = true;
+ break;
+ // Drink
+ case SPELL_AURA_MOD_POWER_REGEN:
+ case SPELL_AURA_OBS_MOD_POWER:
+ drink = true;
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (food && drink)
+ return SPELL_SPECIFIC_FOOD_AND_DRINK;
+ else if (food)
+ return SPELL_SPECIFIC_FOOD;
+ else if (drink)
+ return SPELL_SPECIFIC_DRINK;
+ }
+ // scrolls effects
+ else
+ {
+ SpellInfo const* firstRankSpellInfo = GetFirstRankSpell();
+ switch (firstRankSpellInfo->Id)
+ {
+ case 8118: // Strength
+ case 8099: // Stamina
+ case 8112: // Spirit
+ case 8096: // Intellect
+ case 8115: // Agility
+ case 8091: // Armor
+ return SPELL_SPECIFIC_SCROLL;
+ default:
break;
+ }
+
+ switch (Id)
+ {
+ case 12880: // Enrage (Enrage)
+ case 14201:
+ case 14202:
+ case 14203:
+ case 14204:
+ case 57518: // Enrage (Wrecking Crew)
+ case 57519:
+ case 57520:
+ case 57521:
+ case 57522:
+ case 57514: // Enrage (Imp. Defensive Stance)
+ case 57516:
+ return SPELL_SPECIFIC_WARRIOR_ENRAGE;
default:
break;
}
}
+ break;
+ }
+ case SPELLFAMILY_MAGE:
+ {
+ // family flags 18(Molten), 25(Frost/Ice), 28(Mage)
+ if (SpellFamilyFlags[0] & 0x12040000)
+ return SPELL_SPECIFIC_MAGE_ARMOR;
+
+ // Arcane brillance and Arcane intelect (normal check fails because of flags difference)
+ if (SpellFamilyFlags[0] & 0x400)
+ return SPELL_SPECIFIC_MAGE_ARCANE_BRILLANCE;
+
+ if ((SpellFamilyFlags[0] & 0x1000000) && Effects[0].ApplyAuraName == SPELL_AURA_MOD_CONFUSE)
+ return SPELL_SPECIFIC_MAGE_POLYMORPH;
- if (food && drink)
- return SPELL_SPECIFIC_FOOD_AND_DRINK;
- else if (food)
- return SPELL_SPECIFIC_FOOD;
- else if (drink)
- return SPELL_SPECIFIC_DRINK;
+ break;
}
- // scrolls effects
- else
+ case SPELLFAMILY_WARRIOR:
+ {
+ if (Id == 12292) // Death Wish
+ return SPELL_SPECIFIC_WARRIOR_ENRAGE;
+
+ break;
+ }
+ case SPELLFAMILY_WARLOCK:
+ {
+ // only warlock curses have this
+ if (Dispel == DISPEL_CURSE)
+ return SPELL_SPECIFIC_CURSE;
+
+ // Warlock (Demon Armor | Demon Skin | Fel Armor)
+ if (SpellFamilyFlags[1] & 0x20000020 || SpellFamilyFlags[2] & 0x00000010)
+ return SPELL_SPECIFIC_WARLOCK_ARMOR;
+
+ //seed of corruption and corruption
+ if (SpellFamilyFlags[1] & 0x10 || SpellFamilyFlags[0] & 0x2)
+ return SPELL_SPECIFIC_WARLOCK_CORRUPTION;
+ break;
+ }
+ case SPELLFAMILY_PRIEST:
+ {
+ // Divine Spirit and Prayer of Spirit
+ if (SpellFamilyFlags[0] & 0x20)
+ return SPELL_SPECIFIC_PRIEST_DIVINE_SPIRIT;
+
+ break;
+ }
+ case SPELLFAMILY_HUNTER:
+ {
+ // only hunter stings have this
+ if (Dispel == DISPEL_POISON)
+ return SPELL_SPECIFIC_STING;
+
+ // only hunter aspects have this (but not all aspects in hunter family)
+ if (SpellFamilyFlags.HasFlag(0x00380000, 0x00440000, 0x00001010))
+ return SPELL_SPECIFIC_ASPECT;
+
+ break;
+ }
+ case SPELLFAMILY_PALADIN:
+ {
+ // Collection of all the seal family flags. No other paladin spell has any of those.
+ if (SpellFamilyFlags[1] & 0x26000C00
+ || SpellFamilyFlags[0] & 0x0A000000)
+ return SPELL_SPECIFIC_SEAL;
+
+ if (SpellFamilyFlags[0] & 0x00002190)
+ return SPELL_SPECIFIC_HAND;
+
+ // Judgement of Wisdom, Judgement of Light, Judgement of Justice
+ if (Id == 20184 || Id == 20185 || Id == 20186)
+ return SPELL_SPECIFIC_JUDGEMENT;
+
+ // only paladin auras have this (for palaldin class family)
+ if (SpellFamilyFlags[2] & 0x00000020)
+ return SPELL_SPECIFIC_AURA;
+
+ break;
+ }
+ case SPELLFAMILY_SHAMAN:
+ {
+ // family flags 10 (Lightning), 42 (Earth), 37 (Water), proc shield from T2 8 pieces bonus
+ if (SpellFamilyFlags[1] & 0x420
+ || SpellFamilyFlags[0] & 0x00000400
+ || Id == 23552)
+ return SPELL_SPECIFIC_ELEMENTAL_SHIELD;
+
+ break;
+ }
+ case SPELLFAMILY_DEATHKNIGHT:
+ if (Id == 48266 || Id == 48263 || Id == 48265)
+ return SPELL_SPECIFIC_PRESENCE;
+ break;
+ }
+
+ for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
+ {
+ if (Effects[i].Effect == SPELL_EFFECT_APPLY_AURA)
{
- SpellInfo const* firstRankSpellInfo = GetFirstRankSpell();
- switch (firstRankSpellInfo->Id)
+ switch (Effects[i].ApplyAuraName)
{
- case 8118: // Strength
- case 8099: // Stamina
- case 8112: // Spirit
- case 8096: // Intellect
- case 8115: // Agility
- case 8091: // Armor
- return SPELL_SPECIFIC_SCROLL;
- case 12880: // Enrage (Enrage)
- case 57518: // Enrage (Wrecking Crew)
- return SPELL_SPECIFIC_WARRIOR_ENRAGE;
+ case SPELL_AURA_MOD_CHARM:
+ case SPELL_AURA_MOD_POSSESS_PET:
+ case SPELL_AURA_MOD_POSSESS:
+ case SPELL_AURA_AOE_CHARM:
+ return SPELL_SPECIFIC_CHARM;
+ case SPELL_AURA_TRACK_CREATURES:
+ /// @workaround For non-stacking tracking spells (We need generic solution)
+ if (Id == 30645) // Gas Cloud Tracking
+ return SPELL_SPECIFIC_NORMAL;
+ case SPELL_AURA_TRACK_RESOURCES:
+ case SPELL_AURA_TRACK_STEALTHED:
+ return SPELL_SPECIFIC_TRACKER;
}
}
- break;
}
- case SPELLFAMILY_MAGE:
- {
- // family flags 18(Molten), 25(Frost/Ice), 28(Mage)
- if (SpellFamilyFlags[0] & 0x12040000)
- return SPELL_SPECIFIC_MAGE_ARMOR;
- // Arcane brillance and Arcane intelect (normal check fails because of flags difference)
- if (SpellFamilyFlags[0] & 0x400)
- return SPELL_SPECIFIC_MAGE_ARCANE_BRILLANCE;
+ return SPELL_SPECIFIC_NORMAL;
+ }();
+}
- if ((SpellFamilyFlags[0] & 0x1000000) && Effects[0].ApplyAuraName == SPELL_AURA_MOD_CONFUSE)
- return SPELL_SPECIFIC_MAGE_POLYMORPH;
+void SpellInfo::_LoadSpellDiminishInfo()
+{
+ auto diminishingGroupCompute = [this](bool triggered) -> DiminishingGroup
+ {
+ if (IsPositive())
+ return DIMINISHING_NONE;
- break;
- }
- case SPELLFAMILY_WARRIOR:
+ for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
{
- if (Id == 12292) // Death Wish
- return SPELL_SPECIFIC_WARRIOR_ENRAGE;
-
- break;
+ if (Effects[i].ApplyAuraName == SPELL_AURA_MOD_TAUNT)
+ return DIMINISHING_TAUNT;
}
- case SPELLFAMILY_WARLOCK:
+
+ // Explicit Diminishing Groups
+ switch (SpellFamilyName)
{
- // only warlock curses have this
- if (Dispel == DISPEL_CURSE)
- return SPELL_SPECIFIC_CURSE;
+ case SPELLFAMILY_GENERIC:
+ {
+ // Pet charge effects (Infernal Awakening, Demon Charge)
+ if (SpellVisual[0] == 2816 && SpellIconID == 15)
+ return DIMINISHING_CONTROLLED_STUN;
+ // Frost Tomb
+ else if (Id == 48400)
+ return DIMINISHING_NONE;
+ // Gnaw
+ else if (Id == 47481)
+ return DIMINISHING_CONTROLLED_STUN;
+ // ToC Icehowl Arctic Breath
+ else if (SpellVisual[0] == 14153)
+ return DIMINISHING_NONE;
+ // Black Plague
+ else if (Id == 64155)
+ return DIMINISHING_NONE;
+ // Screams of the Dead (King Ymiron)
+ else if (Id == 51750)
+ return DIMINISHING_NONE;
+ break;
+ }
+ // Event spells
+ case SPELLFAMILY_UNK1:
+ return DIMINISHING_NONE;
+ case SPELLFAMILY_MAGE:
+ {
+ // Frostbite
+ if (SpellFamilyFlags[1] & 0x80000000)
+ return DIMINISHING_ROOT;
+ // Shattered Barrier
+ else if (SpellVisual[0] == 12297)
+ return DIMINISHING_ROOT;
+ // Deep Freeze
+ else if (SpellIconID == 2939 && SpellVisual[0] == 9963)
+ return DIMINISHING_CONTROLLED_STUN;
+ // Frost Nova / Freeze (Water Elemental)
+ else if (SpellIconID == 193)
+ return DIMINISHING_CONTROLLED_ROOT;
+ // Dragon's Breath
+ else if (SpellFamilyFlags[0] & 0x800000)
+ return DIMINISHING_DRAGONS_BREATH;
+ break;
+ }
+ case SPELLFAMILY_WARRIOR:
+ {
+ // Hamstring - limit duration to 10s in PvP
+ if (SpellFamilyFlags[0] & 0x2)
+ return DIMINISHING_LIMITONLY;
+ // Charge Stun (own diminishing)
+ else if (SpellFamilyFlags[0] & 0x01000000)
+ return DIMINISHING_CHARGE;
+ break;
+ }
+ case SPELLFAMILY_WARLOCK:
+ {
+ // Curses/etc
+ if ((SpellFamilyFlags[0] & 0x80000000) || (SpellFamilyFlags[1] & 0x200))
+ return DIMINISHING_LIMITONLY;
+ // Seduction
+ else if (SpellFamilyFlags[1] & 0x10000000)
+ return DIMINISHING_FEAR;
+ break;
+ }
+ case SPELLFAMILY_DRUID:
+ {
+ // Pounce
+ if (SpellFamilyFlags[0] & 0x20000)
+ return DIMINISHING_OPENING_STUN;
+ // Cyclone
+ else if (SpellFamilyFlags[1] & 0x20)
+ return DIMINISHING_CYCLONE;
+ // Entangling Roots
+ // Nature's Grasp
+ else if (SpellFamilyFlags[0] & 0x00000200)
+ return DIMINISHING_CONTROLLED_ROOT;
+ // Faerie Fire
+ else if (SpellFamilyFlags[0] & 0x400)
+ return DIMINISHING_LIMITONLY;
+ break;
+ }
+ case SPELLFAMILY_ROGUE:
+ {
+ // Gouge
+ if (SpellFamilyFlags[0] & 0x8)
+ return DIMINISHING_DISORIENT;
+ // Blind
+ else if (SpellFamilyFlags[0] & 0x1000000)
+ return DIMINISHING_FEAR;
+ // Cheap Shot
+ else if (SpellFamilyFlags[0] & 0x400)
+ return DIMINISHING_OPENING_STUN;
+ // Crippling poison - Limit to 10 seconds in PvP (No SpellFamilyFlags)
+ else if (SpellIconID == 163)
+ return DIMINISHING_LIMITONLY;
+ break;
+ }
+ case SPELLFAMILY_HUNTER:
+ {
+ // Hunter's Mark
+ if ((SpellFamilyFlags[0] & 0x400) && SpellIconID == 538)
+ return DIMINISHING_LIMITONLY;
+ // Scatter Shot (own diminishing)
+ else if ((SpellFamilyFlags[0] & 0x40000) && SpellIconID == 132)
+ return DIMINISHING_SCATTER_SHOT;
+ // Entrapment (own diminishing)
+ else if (SpellVisual[0] == 7484 && SpellIconID == 20)
+ return DIMINISHING_ENTRAPMENT;
+ // Wyvern Sting mechanic is MECHANIC_SLEEP but the diminishing is DIMINISHING_DISORIENT
+ else if ((SpellFamilyFlags[1] & 0x1000) && SpellIconID == 1721)
+ return DIMINISHING_DISORIENT;
+ // Freezing Arrow
+ else if (SpellFamilyFlags[0] & 0x8)
+ return DIMINISHING_DISORIENT;
+ break;
+ }
+ case SPELLFAMILY_PALADIN:
+ {
+ // Judgement of Justice - limit duration to 10s in PvP
+ if (SpellFamilyFlags[0] & 0x100000)
+ return DIMINISHING_LIMITONLY;
+ // Turn Evil
+ else if ((SpellFamilyFlags[1] & 0x804000) && SpellIconID == 309)
+ return DIMINISHING_FEAR;
+ break;
+ }
+ case SPELLFAMILY_SHAMAN:
+ {
+ // Storm, Earth and Fire - Earthgrab
+ if (SpellFamilyFlags[2] & 0x4000)
+ return DIMINISHING_NONE;
+ break;
+ }
+ case SPELLFAMILY_DEATHKNIGHT:
+ {
+ // Hungering Cold (no flags)
+ if (SpellIconID == 2797)
+ return DIMINISHING_DISORIENT;
+ // Mark of Blood
+ else if ((SpellFamilyFlags[0] & 0x10000000) && SpellIconID == 2285)
+ return DIMINISHING_LIMITONLY;
+ break;
+ }
+ default:
+ break;
+ }
- // Warlock (Demon Armor | Demon Skin | Fel Armor)
- if (SpellFamilyFlags[1] & 0x20000020 || SpellFamilyFlags[2] & 0x00000010)
- return SPELL_SPECIFIC_WARLOCK_ARMOR;
+ // Lastly - Set diminishing depending on mechanic
+ uint32 mechanic = GetAllEffectsMechanicMask();
+ if (mechanic & (1 << MECHANIC_CHARM))
+ return DIMINISHING_MIND_CONTROL;
+ if (mechanic & (1 << MECHANIC_SILENCE))
+ return DIMINISHING_SILENCE;
+ if (mechanic & (1 << MECHANIC_SLEEP))
+ return DIMINISHING_SLEEP;
+ if (mechanic & ((1 << MECHANIC_SAPPED) | (1 << MECHANIC_POLYMORPH) | (1 << MECHANIC_SHACKLE)))
+ return DIMINISHING_DISORIENT;
+ // Mechanic Knockout, except Blast Wave
+ if (mechanic & (1 << MECHANIC_KNOCKOUT) && SpellIconID != 292)
+ return DIMINISHING_DISORIENT;
+ if (mechanic & (1 << MECHANIC_DISARM))
+ return DIMINISHING_DISARM;
+ if (mechanic & (1 << MECHANIC_FEAR))
+ return DIMINISHING_FEAR;
+ if (mechanic & (1 << MECHANIC_STUN))
+ return triggered ? DIMINISHING_STUN : DIMINISHING_CONTROLLED_STUN;
+ if (mechanic & (1 << MECHANIC_BANISH))
+ return DIMINISHING_BANISH;
+ if (mechanic & (1 << MECHANIC_ROOT))
+ return triggered ? DIMINISHING_ROOT : DIMINISHING_CONTROLLED_ROOT;
+ if (mechanic & (1 << MECHANIC_HORROR))
+ return DIMINISHING_HORROR;
+
+ return DIMINISHING_NONE;
+ };
+
+ auto diminishingTypeCompute = [](DiminishingGroup group) -> DiminishingReturnsType
+ {
+ switch (group)
+ {
+ case DIMINISHING_TAUNT:
+ case DIMINISHING_CONTROLLED_STUN:
+ case DIMINISHING_STUN:
+ case DIMINISHING_OPENING_STUN:
+ case DIMINISHING_CYCLONE:
+ case DIMINISHING_CHARGE:
+ return DRTYPE_ALL;
+ case DIMINISHING_LIMITONLY:
+ case DIMINISHING_NONE:
+ return DRTYPE_NONE;
+ default:
+ return DRTYPE_PLAYER;
+ }
+ };
- //seed of corruption and corruption
- if (SpellFamilyFlags[1] & 0x10 || SpellFamilyFlags[0] & 0x2)
- return SPELL_SPECIFIC_WARLOCK_CORRUPTION;
- break;
+ auto diminishingMaxLevelCompute = [](DiminishingGroup group) -> DiminishingLevels
+ {
+ switch (group)
+ {
+ case DIMINISHING_TAUNT:
+ return DIMINISHING_LEVEL_TAUNT_IMMUNE;
+ default:
+ return DIMINISHING_LEVEL_IMMUNE;
}
- case SPELLFAMILY_PRIEST:
+ };
+
+ auto diminishingLimitDurationCompute = [this](DiminishingGroup group) -> int32
+ {
+ auto isGroupDurationLimited = [group]() -> bool
{
- // Divine Spirit and Prayer of Spirit
- if (SpellFamilyFlags[0] & 0x20)
- return SPELL_SPECIFIC_PRIEST_DIVINE_SPIRIT;
+ switch (group)
+ {
+ case DIMINISHING_BANISH:
+ case DIMINISHING_CONTROLLED_STUN:
+ case DIMINISHING_CONTROLLED_ROOT:
+ case DIMINISHING_CYCLONE:
+ case DIMINISHING_DISORIENT:
+ case DIMINISHING_ENTRAPMENT:
+ case DIMINISHING_FEAR:
+ case DIMINISHING_HORROR:
+ case DIMINISHING_MIND_CONTROL:
+ case DIMINISHING_OPENING_STUN:
+ case DIMINISHING_ROOT:
+ case DIMINISHING_STUN:
+ case DIMINISHING_SLEEP:
+ case DIMINISHING_LIMITONLY:
+ return true;
+ default:
+ return false;
+ }
+ };
- break;
+ if (!isGroupDurationLimited())
+ return 0;
+
+ // Explicit diminishing duration
+ switch (SpellFamilyName)
+ {
+ case SPELLFAMILY_DRUID:
+ {
+ // Faerie Fire - limit to 40 seconds in PvP (3.1)
+ if (SpellFamilyFlags[0] & 0x400)
+ return 40 * IN_MILLISECONDS;
+ break;
+ }
+ case SPELLFAMILY_HUNTER:
+ {
+ // Wyvern Sting
+ if (SpellFamilyFlags[1] & 0x1000)
+ return 6 * IN_MILLISECONDS;
+ // Hunter's Mark
+ if (SpellFamilyFlags[0] & 0x400)
+ return 120 * IN_MILLISECONDS;
+ break;
+ }
+ case SPELLFAMILY_PALADIN:
+ {
+ // Repentance - limit to 6 seconds in PvP
+ if (SpellFamilyFlags[0] & 0x4)
+ return 6 * IN_MILLISECONDS;
+ break;
+ }
+ case SPELLFAMILY_WARLOCK:
+ {
+ // Banish - limit to 6 seconds in PvP
+ if (SpellFamilyFlags[1] & 0x8000000)
+ return 6 * IN_MILLISECONDS;
+ // Curse of Tongues - limit to 12 seconds in PvP
+ else if (SpellFamilyFlags[2] & 0x800)
+ return 12 * IN_MILLISECONDS;
+ // Curse of Elements - limit to 120 seconds in PvP
+ else if (SpellFamilyFlags[1] & 0x200)
+ return 120 * IN_MILLISECONDS;
+ break;
+ }
+ default:
+ break;
}
- case SPELLFAMILY_HUNTER:
+
+ return 10 * IN_MILLISECONDS;
+ };
+
+ SpellDiminishInfo triggeredInfo, normalInfo;
+ triggeredInfo.DiminishGroup = diminishingGroupCompute(true);
+ triggeredInfo.DiminishReturnType = diminishingTypeCompute(triggeredInfo.DiminishGroup);
+ triggeredInfo.DiminishMaxLevel = diminishingMaxLevelCompute(triggeredInfo.DiminishGroup);
+ triggeredInfo.DiminishDurationLimit = diminishingLimitDurationCompute(triggeredInfo.DiminishGroup);
+
+ normalInfo.DiminishGroup = diminishingGroupCompute(false);
+ normalInfo.DiminishReturnType = diminishingTypeCompute(normalInfo.DiminishGroup);
+ normalInfo.DiminishMaxLevel = diminishingMaxLevelCompute(normalInfo.DiminishGroup);
+ normalInfo.DiminishDurationLimit = diminishingLimitDurationCompute(normalInfo.DiminishGroup);
+
+ _diminishInfoTriggered = triggeredInfo;
+ _diminishInfoNonTriggered = normalInfo;
+}
+
+DiminishingGroup SpellInfo::GetDiminishingReturnsGroupForSpell(bool triggered) const
+{
+ return triggered ? _diminishInfoTriggered.DiminishGroup : _diminishInfoNonTriggered.DiminishGroup;
+}
+
+DiminishingReturnsType SpellInfo::GetDiminishingReturnsGroupType(bool triggered) const
+{
+ return triggered ? _diminishInfoTriggered.DiminishReturnType : _diminishInfoNonTriggered.DiminishReturnType;
+}
+
+DiminishingLevels SpellInfo::GetDiminishingReturnsMaxLevel(bool triggered) const
+{
+ return triggered ? _diminishInfoTriggered.DiminishMaxLevel : _diminishInfoNonTriggered.DiminishMaxLevel;
+}
+
+int32 SpellInfo::GetDiminishingReturnsLimitDuration(bool triggered) const
+{
+ return triggered ? _diminishInfoTriggered.DiminishDurationLimit : _diminishInfoNonTriggered.DiminishDurationLimit;
+}
+
+void SpellInfo::_LoadImmunityInfo()
+{
+ for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
+ {
+ uint32 schoolImmunityMask = 0;
+ uint32 applyHarmfulAuraImmunityMask = 0;
+ uint32 mechanicImmunityMask = 0;
+ uint32 dispelImmunity = 0;
+ uint32 damageImmunityMask = 0;
+
+ int32 miscVal = Effects[i].MiscValue;
+ int32 amount = Effects[i].CalcValue();
+
+ ImmunityInfo& immuneInfo = _immunityInfo[i];
+
+ switch (Effects[i].ApplyAuraName)
{
- // only hunter stings have this
- if (Dispel == DISPEL_POISON)
- return SPELL_SPECIFIC_STING;
+ case SPELL_AURA_MECHANIC_IMMUNITY_MASK:
+ {
+ switch (miscVal)
+ {
+ case 96: // Free Friend, Uncontrollable Frenzy, Warlord's Presence
+ {
+ mechanicImmunityMask |= IMMUNE_TO_MOVEMENT_IMPAIRMENT_AND_LOSS_CONTROL_MASK;
- // only hunter aspects have this (but not all aspects in hunter family)
- if (SpellFamilyFlags.HasFlag(0x00380000, 0x00440000, 0x00001010))
- return SPELL_SPECIFIC_ASPECT;
+ immuneInfo.AuraTypeImmune.insert(SPELL_AURA_MOD_STUN);
+ immuneInfo.AuraTypeImmune.insert(SPELL_AURA_MOD_DECREASE_SPEED);
+ immuneInfo.AuraTypeImmune.insert(SPELL_AURA_MOD_ROOT);
+ immuneInfo.AuraTypeImmune.insert(SPELL_AURA_MOD_CONFUSE);
+ immuneInfo.AuraTypeImmune.insert(SPELL_AURA_MOD_FEAR);
+ break;
+ }
+ case 1615: // Incite Rage, Wolf Spirit, Overload, Lightning Tendrils
+ {
+ switch (Id)
+ {
+ case 43292: // Incite Rage
+ case 49172: // Wolf Spirit
+ mechanicImmunityMask |= IMMUNE_TO_MOVEMENT_IMPAIRMENT_AND_LOSS_CONTROL_MASK;
+
+ immuneInfo.AuraTypeImmune.insert(SPELL_AURA_MOD_STUN);
+ immuneInfo.AuraTypeImmune.insert(SPELL_AURA_MOD_DECREASE_SPEED);
+ immuneInfo.AuraTypeImmune.insert(SPELL_AURA_MOD_ROOT);
+ immuneInfo.AuraTypeImmune.insert(SPELL_AURA_MOD_CONFUSE);
+ immuneInfo.AuraTypeImmune.insert(SPELL_AURA_MOD_FEAR);
+ // no break intended
+ case 61869: // Overload
+ case 63481:
+ case 61887: // Lightning Tendrils
+ case 63486:
+ mechanicImmunityMask |= (1 << MECHANIC_INTERRUPT) | (1 << MECHANIC_SILENCE);
+
+ immuneInfo.SpellEffectImmune.insert(SPELL_EFFECT_KNOCK_BACK);
+ immuneInfo.SpellEffectImmune.insert(SPELL_EFFECT_KNOCK_BACK_DEST);
+ break;
+ default:
+ break;
+ }
+ break;
+ }
+ case 679: // Mind Control, Avenging Fury
+ {
+ if (Id == 57742) // Avenging Fury
+ {
+ mechanicImmunityMask |= IMMUNE_TO_MOVEMENT_IMPAIRMENT_AND_LOSS_CONTROL_MASK;
- break;
+ immuneInfo.AuraTypeImmune.insert(SPELL_AURA_MOD_STUN);
+ immuneInfo.AuraTypeImmune.insert(SPELL_AURA_MOD_DECREASE_SPEED);
+ immuneInfo.AuraTypeImmune.insert(SPELL_AURA_MOD_ROOT);
+ immuneInfo.AuraTypeImmune.insert(SPELL_AURA_MOD_CONFUSE);
+ immuneInfo.AuraTypeImmune.insert(SPELL_AURA_MOD_FEAR);
+ }
+ break;
+ }
+ case 1557: // Startling Roar, Warlord Roar, Break Bonds, Stormshield
+ {
+ if (Id == 64187) // Stormshield
+ {
+ mechanicImmunityMask |= (1 << MECHANIC_STUN);
+ immuneInfo.AuraTypeImmune.insert(SPELL_AURA_MOD_STUN);
+ }
+ else
+ {
+ mechanicImmunityMask |= IMMUNE_TO_MOVEMENT_IMPAIRMENT_AND_LOSS_CONTROL_MASK;
+
+ immuneInfo.AuraTypeImmune.insert(SPELL_AURA_MOD_STUN);
+ immuneInfo.AuraTypeImmune.insert(SPELL_AURA_MOD_DECREASE_SPEED);
+ immuneInfo.AuraTypeImmune.insert(SPELL_AURA_MOD_ROOT);
+ immuneInfo.AuraTypeImmune.insert(SPELL_AURA_MOD_CONFUSE);
+ immuneInfo.AuraTypeImmune.insert(SPELL_AURA_MOD_FEAR);
+ }
+ break;
+ }
+ case 1614: // Fixate
+ case 1694: // Fixated, Lightning Tendrils
+ {
+ immuneInfo.SpellEffectImmune.insert(SPELL_EFFECT_ATTACK_ME);
+ immuneInfo.AuraTypeImmune.insert(SPELL_AURA_MOD_TAUNT);
+ break;
+ }
+ case 1630: // Fervor, Berserk
+ {
+ if (Id == 64112) // Berserk
+ {
+ immuneInfo.SpellEffectImmune.insert(SPELL_EFFECT_ATTACK_ME);
+ immuneInfo.AuraTypeImmune.insert(SPELL_AURA_MOD_TAUNT);
+ }
+ else
+ {
+ mechanicImmunityMask |= IMMUNE_TO_MOVEMENT_IMPAIRMENT_AND_LOSS_CONTROL_MASK;
+
+ immuneInfo.AuraTypeImmune.insert(SPELL_AURA_MOD_STUN);
+ immuneInfo.AuraTypeImmune.insert(SPELL_AURA_MOD_DECREASE_SPEED);
+ immuneInfo.AuraTypeImmune.insert(SPELL_AURA_MOD_ROOT);
+ immuneInfo.AuraTypeImmune.insert(SPELL_AURA_MOD_CONFUSE);
+ immuneInfo.AuraTypeImmune.insert(SPELL_AURA_MOD_FEAR);
+ }
+ break;
+ }
+ case 477: // Bladestorm
+ case 1733: // Bladestorm, Killing Spree
+ {
+ if (!amount)
+ {
+ mechanicImmunityMask |= IMMUNE_TO_MOVEMENT_IMPAIRMENT_AND_LOSS_CONTROL_MASK;
+
+ immuneInfo.SpellEffectImmune.insert(SPELL_EFFECT_KNOCK_BACK);
+ immuneInfo.SpellEffectImmune.insert(SPELL_EFFECT_KNOCK_BACK_DEST);
+
+ immuneInfo.AuraTypeImmune.insert(SPELL_AURA_MOD_STUN);
+ immuneInfo.AuraTypeImmune.insert(SPELL_AURA_MOD_DECREASE_SPEED);
+ immuneInfo.AuraTypeImmune.insert(SPELL_AURA_MOD_ROOT);
+ immuneInfo.AuraTypeImmune.insert(SPELL_AURA_MOD_CONFUSE);
+ immuneInfo.AuraTypeImmune.insert(SPELL_AURA_MOD_FEAR);
+ }
+ break;
+ }
+ case 878: // Whirlwind, Fog of Corruption, Determination
+ {
+ if (Id == 66092) // Determination
+ {
+ mechanicImmunityMask |= (1 << MECHANIC_SNARE) | (1 << MECHANIC_STUN)
+ | (1 << MECHANIC_DISORIENTED) | (1 << MECHANIC_FREEZE);
+
+ immuneInfo.AuraTypeImmune.insert(SPELL_AURA_MOD_STUN);
+ immuneInfo.AuraTypeImmune.insert(SPELL_AURA_MOD_DECREASE_SPEED);
+ }
+ break;
+ }
+ default:
+ break;
+ }
+
+ if (immuneInfo.AuraTypeImmune.empty())
+ {
+ if (miscVal & (1 << 10))
+ immuneInfo.AuraTypeImmune.insert(SPELL_AURA_MOD_STUN);
+ if (miscVal & (1 << 1))
+ immuneInfo.AuraTypeImmune.insert(SPELL_AURA_TRANSFORM);
+
+ // These flag can be recognized wrong:
+ if (miscVal & (1 << 6))
+ immuneInfo.AuraTypeImmune.insert(SPELL_AURA_MOD_DECREASE_SPEED);
+ if (miscVal & (1 << 0))
+ immuneInfo.AuraTypeImmune.insert(SPELL_AURA_MOD_ROOT);
+ if (miscVal & (1 << 2))
+ immuneInfo.AuraTypeImmune.insert(SPELL_AURA_MOD_CONFUSE);
+ if (miscVal & (1 << 9))
+ immuneInfo.AuraTypeImmune.insert(SPELL_AURA_MOD_FEAR);
+ if (miscVal & (1 << 7))
+ immuneInfo.AuraTypeImmune.insert(SPELL_AURA_MOD_DISARM);
+ }
+ break;
+ }
+ case SPELL_AURA_MECHANIC_IMMUNITY:
+ {
+ switch (Id)
+ {
+ case 34471: // The Beast Within
+ case 19574: // Bestial Wrath
+ case 42292: // PvP trinket
+ case 59752: // Every Man for Himself
+ case 53490: // Bullheaded
+ mechanicImmunityMask |= IMMUNE_TO_MOVEMENT_IMPAIRMENT_AND_LOSS_CONTROL_MASK;
+ break;
+ case 54508: // Demonic Empowerment
+ mechanicImmunityMask |= (1 << MECHANIC_SNARE) | (1 << MECHANIC_ROOT) | (1 << MECHANIC_STUN);
+ break;
+ default:
+ if (miscVal < 1)
+ continue;
+
+ mechanicImmunityMask |= 1 << miscVal;
+ break;
+ }
+ break;
+ }
+ case SPELL_AURA_EFFECT_IMMUNITY:
+ {
+ immuneInfo.SpellEffectImmune.insert(static_cast<SpellEffects>(miscVal));
+ break;
+ }
+ case SPELL_AURA_STATE_IMMUNITY:
+ {
+ immuneInfo.AuraTypeImmune.insert(static_cast<AuraType>(miscVal));
+ break;
+ }
+ case SPELL_AURA_SCHOOL_IMMUNITY:
+ {
+ schoolImmunityMask |= uint32(miscVal);
+ break;
+ }
+ case SPELL_AURA_MOD_IMMUNE_AURA_APPLY_SCHOOL:
+ {
+ applyHarmfulAuraImmunityMask |= uint32(miscVal);
+ break;
+ }
+ case SPELL_AURA_DAMAGE_IMMUNITY:
+ {
+ damageImmunityMask |= uint32(miscVal);
+ break;
+ }
+ case SPELL_AURA_DISPEL_IMMUNITY:
+ {
+ dispelImmunity = uint32(miscVal);
+ break;
+ }
+ default:
+ break;
}
- case SPELLFAMILY_PALADIN:
- {
- // Collection of all the seal family flags. No other paladin spell has any of those.
- if (SpellFamilyFlags[1] & 0x26000C00
- || SpellFamilyFlags[0] & 0x0A000000)
- return SPELL_SPECIFIC_SEAL;
- if (SpellFamilyFlags[0] & 0x00002190)
- return SPELL_SPECIFIC_HAND;
+ immuneInfo.SchoolImmuneMask = schoolImmunityMask;
+ immuneInfo.ApplyHarmfulAuraImmuneMask = applyHarmfulAuraImmunityMask;
+ immuneInfo.MechanicImmuneMask = mechanicImmunityMask;
+ immuneInfo.DispelImmune = dispelImmunity;
+ immuneInfo.DamageSchoolMask = damageImmunityMask;
+
+ immuneInfo.AuraTypeImmune.shrink_to_fit();
+ immuneInfo.SpellEffectImmune.shrink_to_fit();
+ }
+}
- // Judgement of Wisdom, Judgement of Light, Judgement of Justice
- if (Id == 20184 || Id == 20185 || Id == 20186)
- return SPELL_SPECIFIC_JUDGEMENT;
+void SpellInfo::ApplyAllSpellImmunitiesTo(Unit* target, uint8 effIndex, bool apply) const
+{
+ ImmunityInfo const* immuneInfo = _immunityInfo + effIndex;
- // only paladin auras have this (for palaldin class family)
- if (SpellFamilyFlags[2] & 0x00000020)
- return SPELL_SPECIFIC_AURA;
+ if (uint32 schoolImmunity = immuneInfo->SchoolImmuneMask)
+ {
+ target->ApplySpellImmune(Id, IMMUNITY_SCHOOL, schoolImmunity, apply);
- break;
+ if (apply && HasAttribute(SPELL_ATTR1_DISPEL_AURAS_ON_IMMUNITY))
+ {
+ target->RemoveAppliedAuras([this, schoolImmunity](AuraApplication const* aurApp) -> bool
+ {
+ SpellInfo const* auraSpellInfo = aurApp->GetBase()->GetSpellInfo();
+ return ((auraSpellInfo->GetSchoolMask() & schoolImmunity) != 0 && // Check for school mask
+ CanDispelAura(auraSpellInfo) &&
+ (IsPositive() != aurApp->IsPositive()) && // Check spell vs aura possitivity
+ !auraSpellInfo->IsPassive() && // Don't remove passive auras
+ auraSpellInfo->Id != Id); // Don't remove self
+ });
}
- case SPELLFAMILY_SHAMAN:
+ }
+
+ if (uint32 mechanicImmunity = immuneInfo->MechanicImmuneMask)
+ {
+ for (uint32 i = 0; i < MAX_MECHANIC; ++i)
+ if (mechanicImmunity & (1 << i))
+ target->ApplySpellImmune(Id, IMMUNITY_MECHANIC, i, apply);
+
+ if (apply && HasAttribute(SPELL_ATTR1_DISPEL_AURAS_ON_IMMUNITY))
+ target->RemoveAurasWithMechanic(mechanicImmunity, AURA_REMOVE_BY_DEFAULT, Id);
+ }
+
+ if (uint32 dispelImmunity = immuneInfo->DispelImmune)
+ {
+ target->ApplySpellImmune(Id, IMMUNITY_DISPEL, dispelImmunity, apply);
+
+ if (apply && HasAttribute(SPELL_ATTR1_DISPEL_AURAS_ON_IMMUNITY))
{
- // family flags 10 (Lightning), 42 (Earth), 37 (Water), proc shield from T2 8 pieces bonus
- if (SpellFamilyFlags[1] & 0x420
- || SpellFamilyFlags[0] & 0x00000400
- || Id == 23552)
- return SPELL_SPECIFIC_ELEMENTAL_SHIELD;
+ target->RemoveAppliedAuras([dispelImmunity](AuraApplication const* aurApp) -> bool
+ {
+ SpellInfo const* spellInfo = aurApp->GetBase()->GetSpellInfo();
+ if (spellInfo->Dispel == dispelImmunity)
+ return true;
- break;
+ return false;
+ });
}
- case SPELLFAMILY_DEATHKNIGHT:
- if (Id == 48266 || Id == 48263 || Id == 48265)
- return SPELL_SPECIFIC_PRESENCE;
- break;
}
+ if (uint32 damageImmunity = immuneInfo->DamageSchoolMask)
+ target->ApplySpellImmune(Id, IMMUNITY_DAMAGE, damageImmunity, apply);
+
+ for (AuraType auraType : immuneInfo->AuraTypeImmune)
+ {
+ target->ApplySpellImmune(Id, IMMUNITY_STATE, auraType, apply);
+ if (apply && HasAttribute(SPELL_ATTR1_DISPEL_AURAS_ON_IMMUNITY))
+ target->RemoveAurasByType(auraType);
+ }
+
+ for (SpellEffects effectType : immuneInfo->SpellEffectImmune)
+ target->ApplySpellImmune(Id, IMMUNITY_EFFECT, effectType, apply);
+}
+
+bool SpellInfo::CanSpellProvideImmunityAgainstAura(SpellInfo const* auraSpellInfo) const
+{
+ if (!auraSpellInfo)
+ return false;
+
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
{
- if (Effects[i].Effect == SPELL_EFFECT_APPLY_AURA)
+ ImmunityInfo const* immuneInfo = _immunityInfo + i;
+
+ if (!auraSpellInfo->HasAttribute(SPELL_ATTR1_UNAFFECTED_BY_SCHOOL_IMMUNE) && !auraSpellInfo->HasAttribute(SPELL_ATTR2_UNAFFECTED_BY_AURA_SCHOOL_IMMUNE))
{
- switch (Effects[i].ApplyAuraName)
+ if (uint32 schoolImmunity = immuneInfo->SchoolImmuneMask)
+ if ((auraSpellInfo->SchoolMask & schoolImmunity) != 0)
+ return true;
+ }
+
+ if (uint32 mechanicImmunity = immuneInfo->MechanicImmuneMask)
+ if ((mechanicImmunity & (1 << auraSpellInfo->Mechanic)) != 0)
+ return true;
+
+ if (uint32 dispelImmunity = immuneInfo->DispelImmune)
+ if (auraSpellInfo->Dispel == dispelImmunity)
+ return true;
+
+ bool immuneToAllEffects = true;
+ for (uint8 effIndex = 0; effIndex < MAX_SPELL_EFFECTS; ++effIndex)
+ {
+ uint32 effectName = auraSpellInfo->Effects[effIndex].Effect;
+ if (!effectName)
+ continue;
+
+ auto spellImmuneItr = immuneInfo->SpellEffectImmune.find(static_cast<SpellEffects>(effectName));
+ if (spellImmuneItr == immuneInfo->SpellEffectImmune.cend())
{
- case SPELL_AURA_MOD_CHARM:
- case SPELL_AURA_MOD_POSSESS_PET:
- case SPELL_AURA_MOD_POSSESS:
- case SPELL_AURA_AOE_CHARM:
- return SPELL_SPECIFIC_CHARM;
- case SPELL_AURA_TRACK_CREATURES:
- /// @workaround For non-stacking tracking spells (We need generic solution)
- if (Id == 30645) // Gas Cloud Tracking
- return SPELL_SPECIFIC_NORMAL;
- case SPELL_AURA_TRACK_RESOURCES:
- case SPELL_AURA_TRACK_STEALTHED:
- return SPELL_SPECIFIC_TRACKER;
+ immuneToAllEffects = false;
+ break;
+ }
+
+ if (uint32 mechanic = auraSpellInfo->Effects[effIndex].Mechanic)
+ {
+ if (!(immuneInfo->MechanicImmuneMask & (1 << mechanic)))
+ {
+ immuneToAllEffects = false;
+ break;
+ }
}
+
+ if (!auraSpellInfo->HasAttribute(SPELL_ATTR3_IGNORE_HIT_RESULT))
+ {
+ if (uint32 auraName = auraSpellInfo->Effects[effIndex].ApplyAuraName)
+ {
+ bool isImmuneToAuraEffectApply = false;
+ auto auraImmuneItr = immuneInfo->AuraTypeImmune.find(static_cast<AuraType>(auraName));
+ if (auraImmuneItr != immuneInfo->AuraTypeImmune.cend())
+ isImmuneToAuraEffectApply = true;
+
+ if (!isImmuneToAuraEffectApply && !auraSpellInfo->IsPositiveEffect(effIndex) && !auraSpellInfo->HasAttribute(SPELL_ATTR2_UNAFFECTED_BY_AURA_SCHOOL_IMMUNE))
+ {
+ if (uint32 applyHarmfulAuraImmunityMask = immuneInfo->ApplyHarmfulAuraImmuneMask)
+ if ((auraSpellInfo->GetSchoolMask() & applyHarmfulAuraImmunityMask) != 0)
+ isImmuneToAuraEffectApply = true;
+ }
+
+ if (!isImmuneToAuraEffectApply)
+ {
+ immuneToAllEffects = false;
+ break;
+ }
+ }
+ }
+ }
+
+ if (immuneToAllEffects)
+ return true;
+ }
+
+ return false;
+}
+
+// based on client sub_007FDFA0
+bool SpellInfo::CanSpellCastOverrideAuraEffect(SpellInfo const* auraSpellInfo, uint8 auraEffIndex) const
+{
+ if (!HasAttribute(SPELL_ATTR1_DISPEL_AURAS_ON_IMMUNITY))
+ return false;
+
+ if (auraSpellInfo->HasAttribute(SPELL_ATTR0_UNAFFECTED_BY_INVULNERABILITY))
+ return false;
+
+ for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
+ {
+ if (Effects[i].Effect != SPELL_EFFECT_APPLY_AURA)
+ continue;
+
+ uint32 const miscValue = static_cast<uint32>(Effects[i].MiscValue);
+ switch (Effects[i].ApplyAuraName)
+ {
+ case SPELL_AURA_STATE_IMMUNITY:
+ if (miscValue != auraSpellInfo->Effects[auraEffIndex].ApplyAuraName)
+ continue;
+ break;
+ case SPELL_AURA_SCHOOL_IMMUNITY:
+ case SPELL_AURA_MOD_IMMUNE_AURA_APPLY_SCHOOL:
+ if (auraSpellInfo->HasAttribute(SPELL_ATTR2_UNAFFECTED_BY_AURA_SCHOOL_IMMUNE) || !(auraSpellInfo->SchoolMask & miscValue))
+ continue;
+ break;
+ case SPELL_AURA_DISPEL_IMMUNITY:
+ if (miscValue != auraSpellInfo->Dispel)
+ continue;
+ break;
+ case SPELL_AURA_MECHANIC_IMMUNITY:
+ if (miscValue != auraSpellInfo->Mechanic)
+ {
+ if (miscValue != auraSpellInfo->Effects[auraEffIndex].Mechanic)
+ continue;
+ }
+ break;
+ default:
+ continue;
}
+
+ return true;
}
- return SPELL_SPECIFIC_NORMAL;
+ return false;
}
float SpellInfo::GetMinRange(bool positive) const
@@ -2436,6 +3288,9 @@ bool SpellInfo::_IsPositiveEffect(uint8 effIndex, bool deep) const
// Impact
if (SpellIconID == 45)
return true;
+ // Arcane Missiles
+ if (SpellFamilyFlags[0] == 0x00000800)
+ return false;
break;
case SPELLFAMILY_PRIEST:
switch (Id)
@@ -2465,6 +3320,9 @@ bool SpellInfo::_IsPositiveEffect(uint8 effIndex, bool deep) const
case 32684: // Envenom (Rank 2)
case 57992: // Envenom (Rank 3)
case 57993: // Envenom (Rank 4)
+ // Slice and Dice. Prevents breaking Stealth
+ case 5171: // Slice and Dice (Rank 1)
+ case 6774: // Slice and Dice (Rank 2)
return true;
default:
break;
@@ -2485,8 +3343,16 @@ bool SpellInfo::_IsPositiveEffect(uint8 effIndex, bool deep) const
// Special case: effects which determine positivity of whole spell
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
{
- if (Effects[i].IsAura() && Effects[i].ApplyAuraName == SPELL_AURA_MOD_STEALTH)
- return true;
+ if (Effects[i].IsAura())
+ {
+ switch (Effects[i].ApplyAuraName)
+ {
+ case SPELL_AURA_MOD_STEALTH:
+ return true;
+ case SPELL_AURA_CHANNEL_DEATH_ITEM:
+ return false;
+ }
+ }
}
switch (Effects[effIndex].Effect)
diff --git a/src/server/game/Spells/SpellInfo.h b/src/server/game/Spells/SpellInfo.h
index 589ed16e409..d7b48ddb4d2 100644
--- a/src/server/game/Spells/SpellInfo.h
+++ b/src/server/game/Spells/SpellInfo.h
@@ -24,10 +24,13 @@
#include "Object.h"
#include "SpellAuraDefines.h"
+#include <boost/container/flat_set.hpp>
+
class Unit;
class Player;
class Item;
class Spell;
+class SpellMgr;
class SpellInfo;
struct SpellChainNode;
struct SpellTargetPosition;
@@ -291,201 +294,252 @@ private:
static StaticData _data[TOTAL_SPELL_EFFECTS];
};
+struct TC_GAME_API SpellDiminishInfo
+{
+ DiminishingGroup DiminishGroup = DIMINISHING_NONE;
+ DiminishingReturnsType DiminishReturnType = DRTYPE_NONE;
+ DiminishingLevels DiminishMaxLevel = DIMINISHING_LEVEL_IMMUNE;
+ int32 DiminishDurationLimit = 0;
+};
+
+struct TC_GAME_API ImmunityInfo
+{
+ uint32 SchoolImmuneMask = 0;
+ uint32 ApplyHarmfulAuraImmuneMask = 0;
+ uint32 MechanicImmuneMask = 0;
+ uint32 DispelImmune = 0;
+ uint32 DamageSchoolMask = 0;
+
+ boost::container::flat_set<AuraType> AuraTypeImmune;
+ boost::container::flat_set<SpellEffects> SpellEffectImmune;
+};
+
class TC_GAME_API SpellInfo
{
-public:
- uint32 Id;
- SpellCategoryEntry const* CategoryEntry;
- uint32 Dispel;
- uint32 Mechanic;
- uint32 Attributes;
- uint32 AttributesEx;
- uint32 AttributesEx2;
- uint32 AttributesEx3;
- uint32 AttributesEx4;
- uint32 AttributesEx5;
- uint32 AttributesEx6;
- uint32 AttributesEx7;
- uint32 AttributesCu;
- uint64 Stances;
- uint64 StancesNot;
- uint32 Targets;
- uint32 TargetCreatureType;
- uint32 RequiresSpellFocus;
- uint32 FacingCasterFlags;
- uint32 CasterAuraState;
- uint32 TargetAuraState;
- uint32 CasterAuraStateNot;
- uint32 TargetAuraStateNot;
- uint32 CasterAuraSpell;
- uint32 TargetAuraSpell;
- uint32 ExcludeCasterAuraSpell;
- uint32 ExcludeTargetAuraSpell;
- SpellCastTimesEntry const* CastTimeEntry;
- uint32 RecoveryTime;
- uint32 CategoryRecoveryTime;
- uint32 StartRecoveryCategory;
- uint32 StartRecoveryTime;
- uint32 InterruptFlags;
- uint32 AuraInterruptFlags;
- uint32 ChannelInterruptFlags;
- uint32 ProcFlags;
- uint32 ProcChance;
- uint32 ProcCharges;
- uint32 MaxLevel;
- uint32 BaseLevel;
- uint32 SpellLevel;
- SpellDurationEntry const* DurationEntry;
- uint32 PowerType;
- uint32 ManaCost;
- uint32 ManaCostPerlevel;
- uint32 ManaPerSecond;
- uint32 ManaPerSecondPerLevel;
- uint32 ManaCostPercentage;
- uint32 RuneCostID;
- SpellRangeEntry const* RangeEntry;
- float Speed;
- uint32 StackAmount;
- uint32 Totem[2];
- int32 Reagent[MAX_SPELL_REAGENTS];
- uint32 ReagentCount[MAX_SPELL_REAGENTS];
- int32 EquippedItemClass;
- int32 EquippedItemSubClassMask;
- int32 EquippedItemInventoryTypeMask;
- uint32 TotemCategory[2];
- uint32 SpellVisual[2];
- uint32 SpellIconID;
- uint32 ActiveIconID;
- char* SpellName[16];
- char* Rank[16];
- uint32 MaxTargetLevel;
- uint32 MaxAffectedTargets;
- uint32 SpellFamilyName;
- flag96 SpellFamilyFlags;
- uint32 DmgClass;
- uint32 PreventionType;
- int32 AreaGroupId;
- uint32 SchoolMask;
- SpellEffectInfo Effects[MAX_SPELL_EFFECTS];
- uint32 ExplicitTargetMask;
- SpellChainNode const* ChainEntry;
-
- SpellInfo(SpellEntry const* spellEntry);
- ~SpellInfo();
-
- uint32 GetCategory() const;
- bool HasEffect(SpellEffects effect) const;
- bool HasAura(AuraType aura) const;
- bool HasAreaAuraEffect() const;
-
- inline bool HasAttribute(SpellAttr0 attribute) const { return !!(Attributes & attribute); }
- inline bool HasAttribute(SpellAttr1 attribute) const { return !!(AttributesEx & attribute); }
- inline bool HasAttribute(SpellAttr2 attribute) const { return !!(AttributesEx2 & attribute); }
- inline bool HasAttribute(SpellAttr3 attribute) const { return !!(AttributesEx3 & attribute); }
- inline bool HasAttribute(SpellAttr4 attribute) const { return !!(AttributesEx4 & attribute); }
- inline bool HasAttribute(SpellAttr5 attribute) const { return !!(AttributesEx5 & attribute); }
- inline bool HasAttribute(SpellAttr6 attribute) const { return !!(AttributesEx6 & attribute); }
- inline bool HasAttribute(SpellAttr7 attribute) const { return !!(AttributesEx7 & attribute); }
- inline bool HasAttribute(SpellCustomAttributes customAttribute) const { return !!(AttributesCu & customAttribute); }
-
- bool IsExplicitDiscovery() const;
- bool IsLootCrafting() const;
- bool IsQuestTame() const;
- bool IsProfessionOrRiding() const;
- bool IsProfession() const;
- bool IsPrimaryProfession() const;
- bool IsPrimaryProfessionFirstRank() const;
- bool IsAbilityLearnedWithProfession() const;
- bool IsAbilityOfSkillType(uint32 skillType) const;
-
- bool IsAffectingArea() const;
- bool IsTargetingArea() const;
- bool NeedsExplicitUnitTarget() const;
- bool NeedsToBeTriggeredByCaster(SpellInfo const* triggeringSpell) const;
-
- bool IsPassive() const;
- bool IsAutocastable() const;
- bool IsStackableWithRanks() const;
- bool IsPassiveStackableWithRanks() const;
- bool IsMultiSlotAura() const;
- bool IsStackableOnOneSlotWithDifferentCasters() const;
- bool IsCooldownStartedOnEvent() const;
- bool IsDeathPersistent() const;
- bool IsRequiringDeadTarget() const;
- bool IsAllowingDeadTarget() const;
- bool IsGroupBuff() const;
- bool CanBeUsedInCombat() const;
- bool IsPositive() const;
- bool IsPositiveEffect(uint8 effIndex) const;
- bool IsChanneled() const;
- bool NeedsComboPoints() const;
- bool IsBreakingStealth() const;
- bool IsRangedWeaponSpell() const;
- bool IsAutoRepeatRangedSpell() const;
- bool HasInitialAggro() const;
-
- bool IsAffectedBySpellMods() const;
- bool IsAffectedBySpellMod(SpellModifier const* mod) const;
-
- bool CanPierceImmuneAura(SpellInfo const* aura) const;
- bool CanDispelAura(SpellInfo const* aura) const;
-
- bool IsSingleTarget() const;
- bool IsAuraExclusiveBySpecificWith(SpellInfo const* spellInfo) const;
- bool IsAuraExclusiveBySpecificPerCasterWith(SpellInfo const* spellInfo) const;
-
- SpellCastResult CheckShapeshift(uint32 form) const;
- SpellCastResult CheckLocation(uint32 map_id, uint32 zone_id, uint32 area_id, Player const* player = NULL) const;
- SpellCastResult CheckTarget(Unit const* caster, WorldObject const* target, bool implicit = true) const;
- SpellCastResult CheckExplicitTarget(Unit const* caster, WorldObject const* target, Item const* itemTarget = NULL) const;
- SpellCastResult CheckVehicle(Unit const* caster) const;
- bool CheckTargetCreatureType(Unit const* target) const;
-
- SpellSchoolMask GetSchoolMask() const;
- uint32 GetAllEffectsMechanicMask() const;
- uint32 GetEffectMechanicMask(uint8 effIndex) const;
- uint32 GetSpellMechanicMaskByEffectMask(uint32 effectMask) const;
- Mechanics GetEffectMechanic(uint8 effIndex) const;
- bool HasAnyEffectMechanic() const;
- uint32 GetDispelMask() const;
- static uint32 GetDispelMask(DispelType type);
- uint32 GetExplicitTargetMask() const;
-
- AuraStateType GetAuraState() const;
- SpellSpecificType GetSpellSpecific() const;
-
- float GetMinRange(bool positive = false) const;
- float GetMaxRange(bool positive = false, Unit* caster = NULL, Spell* spell = NULL) const;
-
- int32 GetDuration() const;
- int32 GetMaxDuration() const;
-
- uint32 GetMaxTicks() const;
-
- uint32 CalcCastTime(Spell* spell = NULL) const;
- uint32 GetRecoveryTime() const;
-
- int32 CalcPowerCost(Unit const* caster, SpellSchoolMask schoolMask) const;
-
- bool IsRanked() const;
- uint8 GetRank() const;
- SpellInfo const* GetFirstRankSpell() const;
- SpellInfo const* GetLastRankSpell() const;
- SpellInfo const* GetNextRankSpell() const;
- SpellInfo const* GetPrevRankSpell() const;
- SpellInfo const* GetAuraRankForLevel(uint8 level) const;
- bool IsRankOf(SpellInfo const* spellInfo) const;
- bool IsDifferentRankOf(SpellInfo const* spellInfo) const;
- bool IsHighRankOf(SpellInfo const* spellInfo) const;
-
- // loading helpers
- void _InitializeExplicitTargetMask();
- bool _IsPositiveEffect(uint8 effIndex, bool deep) const;
- bool _IsPositiveSpell() const;
- static bool _IsPositiveTarget(uint32 targetA, uint32 targetB);
-
- // unloading helpers
- void _UnloadImplicitTargetConditionLists();
+ friend class SpellMgr;
+
+ public:
+ uint32 Id;
+ SpellCategoryEntry const* CategoryEntry;
+ uint32 Dispel;
+ uint32 Mechanic;
+ uint32 Attributes;
+ uint32 AttributesEx;
+ uint32 AttributesEx2;
+ uint32 AttributesEx3;
+ uint32 AttributesEx4;
+ uint32 AttributesEx5;
+ uint32 AttributesEx6;
+ uint32 AttributesEx7;
+ uint32 AttributesCu;
+ uint64 Stances;
+ uint64 StancesNot;
+ uint32 Targets;
+ uint32 TargetCreatureType;
+ uint32 RequiresSpellFocus;
+ uint32 FacingCasterFlags;
+ uint32 CasterAuraState;
+ uint32 TargetAuraState;
+ uint32 CasterAuraStateNot;
+ uint32 TargetAuraStateNot;
+ uint32 CasterAuraSpell;
+ uint32 TargetAuraSpell;
+ uint32 ExcludeCasterAuraSpell;
+ uint32 ExcludeTargetAuraSpell;
+ SpellCastTimesEntry const* CastTimeEntry;
+ uint32 RecoveryTime;
+ uint32 CategoryRecoveryTime;
+ uint32 StartRecoveryCategory;
+ uint32 StartRecoveryTime;
+ uint32 InterruptFlags;
+ uint32 AuraInterruptFlags;
+ uint32 ChannelInterruptFlags;
+ uint32 ProcFlags;
+ uint32 ProcChance;
+ uint32 ProcCharges;
+ uint32 MaxLevel;
+ uint32 BaseLevel;
+ uint32 SpellLevel;
+ SpellDurationEntry const* DurationEntry;
+ uint32 PowerType;
+ uint32 ManaCost;
+ uint32 ManaCostPerlevel;
+ uint32 ManaPerSecond;
+ uint32 ManaPerSecondPerLevel;
+ uint32 ManaCostPercentage;
+ uint32 RuneCostID;
+ SpellRangeEntry const* RangeEntry;
+ float Speed;
+ uint32 StackAmount;
+ uint32 Totem[2];
+ int32 Reagent[MAX_SPELL_REAGENTS];
+ uint32 ReagentCount[MAX_SPELL_REAGENTS];
+ int32 EquippedItemClass;
+ int32 EquippedItemSubClassMask;
+ int32 EquippedItemInventoryTypeMask;
+ uint32 TotemCategory[2];
+ uint32 SpellVisual[2];
+ uint32 SpellIconID;
+ uint32 ActiveIconID;
+ char* SpellName[16];
+ char* Rank[16];
+ uint32 MaxTargetLevel;
+ uint32 MaxAffectedTargets;
+ uint32 SpellFamilyName;
+ flag96 SpellFamilyFlags;
+ uint32 DmgClass;
+ uint32 PreventionType;
+ int32 AreaGroupId;
+ uint32 SchoolMask;
+ SpellEffectInfo Effects[MAX_SPELL_EFFECTS];
+ uint32 ExplicitTargetMask;
+ SpellChainNode const* ChainEntry;
+
+ SpellInfo(SpellEntry const* spellEntry);
+ ~SpellInfo();
+
+ uint32 GetCategory() const;
+ bool HasEffect(SpellEffects effect) const;
+ bool HasAura(AuraType aura) const;
+ bool HasAreaAuraEffect() const;
+ bool HasOnlyDamageEffects() const;
+
+ inline bool HasAttribute(SpellAttr0 attribute) const { return !!(Attributes & attribute); }
+ inline bool HasAttribute(SpellAttr1 attribute) const { return !!(AttributesEx & attribute); }
+ inline bool HasAttribute(SpellAttr2 attribute) const { return !!(AttributesEx2 & attribute); }
+ inline bool HasAttribute(SpellAttr3 attribute) const { return !!(AttributesEx3 & attribute); }
+ inline bool HasAttribute(SpellAttr4 attribute) const { return !!(AttributesEx4 & attribute); }
+ inline bool HasAttribute(SpellAttr5 attribute) const { return !!(AttributesEx5 & attribute); }
+ inline bool HasAttribute(SpellAttr6 attribute) const { return !!(AttributesEx6 & attribute); }
+ inline bool HasAttribute(SpellAttr7 attribute) const { return !!(AttributesEx7 & attribute); }
+ inline bool HasAttribute(SpellCustomAttributes customAttribute) const { return !!(AttributesCu & customAttribute); }
+
+ bool IsExplicitDiscovery() const;
+ bool IsLootCrafting() const;
+ bool IsQuestTame() const;
+ bool IsProfessionOrRiding() const;
+ bool IsProfession() const;
+ bool IsPrimaryProfession() const;
+ bool IsPrimaryProfessionFirstRank() const;
+ bool IsAbilityLearnedWithProfession() const;
+ bool IsAbilityOfSkillType(uint32 skillType) const;
+
+ bool IsAffectingArea() const;
+ bool IsTargetingArea() const;
+ bool NeedsExplicitUnitTarget() const;
+ bool NeedsToBeTriggeredByCaster(SpellInfo const* triggeringSpell) const;
+
+ bool IsPassive() const;
+ bool IsAutocastable() const;
+ bool IsStackableWithRanks() const;
+ bool IsPassiveStackableWithRanks() const;
+ bool IsMultiSlotAura() const;
+ bool IsStackableOnOneSlotWithDifferentCasters() const;
+ bool IsCooldownStartedOnEvent() const;
+ bool IsDeathPersistent() const;
+ bool IsRequiringDeadTarget() const;
+ bool IsAllowingDeadTarget() const;
+ bool IsGroupBuff() const;
+ bool CanBeUsedInCombat() const;
+ bool IsPositive() const;
+ bool IsPositiveEffect(uint8 effIndex) const;
+ bool IsChanneled() const;
+ bool IsMoveAllowedChannel() const;
+ bool NeedsComboPoints() const;
+ bool IsNextMeleeSwingSpell() const;
+ bool IsBreakingStealth() const;
+ bool IsRangedWeaponSpell() const;
+ bool IsAutoRepeatRangedSpell() const;
+ bool HasInitialAggro() const;
+
+ bool IsAffected(uint32 familyName, flag96 const& familyFlags) const;
+
+ bool IsAffectedBySpellMods() const;
+ bool IsAffectedBySpellMod(SpellModifier const* mod) const;
+
+ bool CanPierceImmuneAura(SpellInfo const* auraSpellInfo) const;
+ bool CanDispelAura(SpellInfo const* auraSpellInfo) const;
+
+ bool IsSingleTarget() const;
+ bool IsAuraExclusiveBySpecificWith(SpellInfo const* spellInfo) const;
+ bool IsAuraExclusiveBySpecificPerCasterWith(SpellInfo const* spellInfo) const;
+
+ SpellCastResult CheckShapeshift(uint32 form) const;
+ SpellCastResult CheckLocation(uint32 map_id, uint32 zone_id, uint32 area_id, Player const* player = NULL) const;
+ SpellCastResult CheckTarget(Unit const* caster, WorldObject const* target, bool implicit = true) const;
+ SpellCastResult CheckExplicitTarget(Unit const* caster, WorldObject const* target, Item const* itemTarget = NULL) const;
+ SpellCastResult CheckVehicle(Unit const* caster) const;
+ bool CheckTargetCreatureType(Unit const* target) const;
+
+ SpellSchoolMask GetSchoolMask() const;
+ uint32 GetAllEffectsMechanicMask() const;
+ uint32 GetEffectMechanicMask(uint8 effIndex) const;
+ uint32 GetSpellMechanicMaskByEffectMask(uint32 effectMask) const;
+ Mechanics GetEffectMechanic(uint8 effIndex) const;
+ bool HasAnyEffectMechanic() const;
+ uint32 GetDispelMask() const;
+ static uint32 GetDispelMask(DispelType type);
+ uint32 GetExplicitTargetMask() const;
+
+ AuraStateType GetAuraState() const;
+ SpellSpecificType GetSpellSpecific() const;
+
+ float GetMinRange(bool positive = false) const;
+ float GetMaxRange(bool positive = false, Unit* caster = NULL, Spell* spell = NULL) const;
+
+ int32 GetDuration() const;
+ int32 GetMaxDuration() const;
+
+ uint32 GetMaxTicks() const;
+
+ uint32 CalcCastTime(Spell* spell = NULL) const;
+ uint32 GetRecoveryTime() const;
+
+ int32 CalcPowerCost(Unit const* caster, SpellSchoolMask schoolMask) const;
+
+ bool IsRanked() const;
+ uint8 GetRank() const;
+ SpellInfo const* GetFirstRankSpell() const;
+ SpellInfo const* GetLastRankSpell() const;
+ SpellInfo const* GetNextRankSpell() const;
+ SpellInfo const* GetPrevRankSpell() const;
+ SpellInfo const* GetAuraRankForLevel(uint8 level) const;
+ bool IsRankOf(SpellInfo const* spellInfo) const;
+ bool IsDifferentRankOf(SpellInfo const* spellInfo) const;
+ bool IsHighRankOf(SpellInfo const* spellInfo) const;
+
+ // spell diminishing returns
+ DiminishingGroup GetDiminishingReturnsGroupForSpell(bool triggered) const;
+ DiminishingReturnsType GetDiminishingReturnsGroupType(bool triggered) const;
+ DiminishingLevels GetDiminishingReturnsMaxLevel(bool triggered) const;
+ int32 GetDiminishingReturnsLimitDuration(bool triggered) const;
+
+ // spell immunities
+ void ApplyAllSpellImmunitiesTo(Unit* target, uint8 effIndex, bool apply) const;
+ bool CanSpellProvideImmunityAgainstAura(SpellInfo const* auraSpellInfo) const;
+ bool CanSpellCastOverrideAuraEffect(SpellInfo const* auraSpellInfo, uint8 auraEffIndex) const;
+
+ private:
+ // loading helpers
+ void _InitializeExplicitTargetMask();
+ bool _IsPositiveEffect(uint8 effIndex, bool deep) const;
+ bool _IsPositiveSpell() const;
+ static bool _IsPositiveTarget(uint32 targetA, uint32 targetB);
+ void _LoadSpellSpecific();
+ void _LoadAuraState();
+ void _LoadSpellDiminishInfo();
+ void _LoadImmunityInfo();
+
+ // unloading helpers
+ void _UnloadImplicitTargetConditionLists();
+
+ SpellSpecificType _spellSpecific;
+ AuraStateType _auraState;
+
+ SpellDiminishInfo _diminishInfoNonTriggered;
+ SpellDiminishInfo _diminishInfoTriggered;
+
+ ImmunityInfo _immunityInfo[MAX_SPELL_EFFECTS];
};
#endif // _SPELLINFO_H
diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp
index bab1a34c038..bd13f1b2c7b 100644
--- a/src/server/game/Spells/SpellMgr.cpp
+++ b/src/server/game/Spells/SpellMgr.cpp
@@ -51,302 +51,6 @@ bool IsPartOfSkillLine(uint32 skillId, uint32 spellId)
return false;
}
-DiminishingGroup GetDiminishingReturnsGroupForSpell(SpellInfo const* spellproto, bool triggered)
-{
- if (spellproto->IsPositive())
- return DIMINISHING_NONE;
-
- for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
- {
- if (spellproto->Effects[i].ApplyAuraName == SPELL_AURA_MOD_TAUNT)
- return DIMINISHING_TAUNT;
- }
-
- // Explicit Diminishing Groups
- switch (spellproto->SpellFamilyName)
- {
- case SPELLFAMILY_GENERIC:
- {
- // Pet charge effects (Infernal Awakening, Demon Charge)
- if (spellproto->SpellVisual[0] == 2816 && spellproto->SpellIconID == 15)
- return DIMINISHING_CONTROLLED_STUN;
- // Frost Tomb
- else if (spellproto->Id == 48400)
- return DIMINISHING_NONE;
- // Gnaw
- else if (spellproto->Id == 47481)
- return DIMINISHING_CONTROLLED_STUN;
- // ToC Icehowl Arctic Breath
- else if (spellproto->SpellVisual[0] == 14153)
- return DIMINISHING_NONE;
- // Black Plague
- else if (spellproto->Id == 64155)
- return DIMINISHING_NONE;
- // Screams of the Dead (King Ymiron)
- else if (spellproto->Id == 51750)
- return DIMINISHING_NONE;
- break;
- }
- // Event spells
- case SPELLFAMILY_UNK1:
- return DIMINISHING_NONE;
- case SPELLFAMILY_MAGE:
- {
- // Frostbite
- if (spellproto->SpellFamilyFlags[1] & 0x80000000)
- return DIMINISHING_ROOT;
- // Shattered Barrier
- else if (spellproto->SpellVisual[0] == 12297)
- return DIMINISHING_ROOT;
- // Deep Freeze
- else if (spellproto->SpellIconID == 2939 && spellproto->SpellVisual[0] == 9963)
- return DIMINISHING_CONTROLLED_STUN;
- // Frost Nova / Freeze (Water Elemental)
- else if (spellproto->SpellIconID == 193)
- return DIMINISHING_CONTROLLED_ROOT;
- // Dragon's Breath
- else if (spellproto->SpellFamilyFlags[0] & 0x800000)
- return DIMINISHING_DRAGONS_BREATH;
- break;
- }
- case SPELLFAMILY_WARRIOR:
- {
- // Hamstring - limit duration to 10s in PvP
- if (spellproto->SpellFamilyFlags[0] & 0x2)
- return DIMINISHING_LIMITONLY;
- // Charge Stun (own diminishing)
- else if (spellproto->SpellFamilyFlags[0] & 0x01000000)
- return DIMINISHING_CHARGE;
- break;
- }
- case SPELLFAMILY_WARLOCK:
- {
- // Curses/etc
- if ((spellproto->SpellFamilyFlags[0] & 0x80000000) || (spellproto->SpellFamilyFlags[1] & 0x200))
- return DIMINISHING_LIMITONLY;
- // Seduction
- else if (spellproto->SpellFamilyFlags[1] & 0x10000000)
- return DIMINISHING_FEAR;
- break;
- }
- case SPELLFAMILY_DRUID:
- {
- // Pounce
- if (spellproto->SpellFamilyFlags[0] & 0x20000)
- return DIMINISHING_OPENING_STUN;
- // Cyclone
- else if (spellproto->SpellFamilyFlags[1] & 0x20)
- return DIMINISHING_CYCLONE;
- // Entangling Roots
- // Nature's Grasp
- else if (spellproto->SpellFamilyFlags[0] & 0x00000200)
- return DIMINISHING_CONTROLLED_ROOT;
- // Faerie Fire
- else if (spellproto->SpellFamilyFlags[0] & 0x400)
- return DIMINISHING_LIMITONLY;
- break;
- }
- case SPELLFAMILY_ROGUE:
- {
- // Gouge
- if (spellproto->SpellFamilyFlags[0] & 0x8)
- return DIMINISHING_DISORIENT;
- // Blind
- else if (spellproto->SpellFamilyFlags[0] & 0x1000000)
- return DIMINISHING_FEAR;
- // Cheap Shot
- else if (spellproto->SpellFamilyFlags[0] & 0x400)
- return DIMINISHING_OPENING_STUN;
- // Crippling poison - Limit to 10 seconds in PvP (No SpellFamilyFlags)
- else if (spellproto->SpellIconID == 163)
- return DIMINISHING_LIMITONLY;
- break;
- }
- case SPELLFAMILY_HUNTER:
- {
- // Hunter's Mark
- if ((spellproto->SpellFamilyFlags[0] & 0x400) && spellproto->SpellIconID == 538)
- return DIMINISHING_LIMITONLY;
- // Scatter Shot (own diminishing)
- else if ((spellproto->SpellFamilyFlags[0] & 0x40000) && spellproto->SpellIconID == 132)
- return DIMINISHING_SCATTER_SHOT;
- // Entrapment (own diminishing)
- else if (spellproto->SpellVisual[0] == 7484 && spellproto->SpellIconID == 20)
- return DIMINISHING_ENTRAPMENT;
- // Wyvern Sting mechanic is MECHANIC_SLEEP but the diminishing is DIMINISHING_DISORIENT
- else if ((spellproto->SpellFamilyFlags[1] & 0x1000) && spellproto->SpellIconID == 1721)
- return DIMINISHING_DISORIENT;
- // Freezing Arrow
- else if (spellproto->SpellFamilyFlags[0] & 0x8)
- return DIMINISHING_DISORIENT;
- break;
- }
- case SPELLFAMILY_PALADIN:
- {
- // Judgement of Justice - limit duration to 10s in PvP
- if (spellproto->SpellFamilyFlags[0] & 0x100000)
- return DIMINISHING_LIMITONLY;
- // Turn Evil
- else if ((spellproto->SpellFamilyFlags[1] & 0x804000) && spellproto->SpellIconID == 309)
- return DIMINISHING_FEAR;
- break;
- }
- case SPELLFAMILY_SHAMAN:
- {
- // Storm, Earth and Fire - Earthgrab
- if (spellproto->SpellFamilyFlags[2] & 0x4000)
- return DIMINISHING_NONE;
- break;
- }
- case SPELLFAMILY_DEATHKNIGHT:
- {
- // Hungering Cold (no flags)
- if (spellproto->SpellIconID == 2797)
- return DIMINISHING_DISORIENT;
- // Mark of Blood
- else if ((spellproto->SpellFamilyFlags[0] & 0x10000000) && spellproto->SpellIconID == 2285)
- return DIMINISHING_LIMITONLY;
- break;
- }
- default:
- break;
- }
-
- // Lastly - Set diminishing depending on mechanic
- uint32 mechanic = spellproto->GetAllEffectsMechanicMask();
- if (mechanic & (1 << MECHANIC_CHARM))
- return DIMINISHING_MIND_CONTROL;
- if (mechanic & (1 << MECHANIC_SILENCE))
- return DIMINISHING_SILENCE;
- if (mechanic & (1 << MECHANIC_SLEEP))
- return DIMINISHING_SLEEP;
- if (mechanic & ((1 << MECHANIC_SAPPED) | (1 << MECHANIC_POLYMORPH) | (1 << MECHANIC_SHACKLE)))
- return DIMINISHING_DISORIENT;
- // Mechanic Knockout, except Blast Wave
- if (mechanic & (1 << MECHANIC_KNOCKOUT) && spellproto->SpellIconID != 292)
- return DIMINISHING_DISORIENT;
- if (mechanic & (1 << MECHANIC_DISARM))
- return DIMINISHING_DISARM;
- if (mechanic & (1 << MECHANIC_FEAR))
- return DIMINISHING_FEAR;
- if (mechanic & (1 << MECHANIC_STUN))
- return triggered ? DIMINISHING_STUN : DIMINISHING_CONTROLLED_STUN;
- if (mechanic & (1 << MECHANIC_BANISH))
- return DIMINISHING_BANISH;
- if (mechanic & (1 << MECHANIC_ROOT))
- return triggered ? DIMINISHING_ROOT : DIMINISHING_CONTROLLED_ROOT;
- if (mechanic & (1 << MECHANIC_HORROR))
- return DIMINISHING_HORROR;
-
- return DIMINISHING_NONE;
-}
-
-DiminishingReturnsType GetDiminishingReturnsGroupType(DiminishingGroup group)
-{
- switch (group)
- {
- case DIMINISHING_TAUNT:
- case DIMINISHING_CONTROLLED_STUN:
- case DIMINISHING_STUN:
- case DIMINISHING_OPENING_STUN:
- case DIMINISHING_CYCLONE:
- case DIMINISHING_CHARGE:
- return DRTYPE_ALL;
- case DIMINISHING_LIMITONLY:
- case DIMINISHING_NONE:
- return DRTYPE_NONE;
- default:
- return DRTYPE_PLAYER;
- }
-}
-
-DiminishingLevels GetDiminishingReturnsMaxLevel(DiminishingGroup group)
-{
- switch (group)
- {
- case DIMINISHING_TAUNT:
- return DIMINISHING_LEVEL_TAUNT_IMMUNE;
- default:
- return DIMINISHING_LEVEL_IMMUNE;
- }
-}
-
-int32 GetDiminishingReturnsLimitDuration(DiminishingGroup group, SpellInfo const* spellproto)
-{
- if (!IsDiminishingReturnsGroupDurationLimited(group))
- return 0;
-
- // Explicit diminishing duration
- switch (spellproto->SpellFamilyName)
- {
- case SPELLFAMILY_DRUID:
- {
- // Faerie Fire - limit to 40 seconds in PvP (3.1)
- if (spellproto->SpellFamilyFlags[0] & 0x400)
- return 40 * IN_MILLISECONDS;
- break;
- }
- case SPELLFAMILY_HUNTER:
- {
- // Wyvern Sting
- if (spellproto->SpellFamilyFlags[1] & 0x1000)
- return 6 * IN_MILLISECONDS;
- // Hunter's Mark
- if (spellproto->SpellFamilyFlags[0] & 0x400)
- return 120 * IN_MILLISECONDS;
- break;
- }
- case SPELLFAMILY_PALADIN:
- {
- // Repentance - limit to 6 seconds in PvP
- if (spellproto->SpellFamilyFlags[0] & 0x4)
- return 6 * IN_MILLISECONDS;
- break;
- }
- case SPELLFAMILY_WARLOCK:
- {
- // Banish - limit to 6 seconds in PvP
- if (spellproto->SpellFamilyFlags[1] & 0x8000000)
- return 6 * IN_MILLISECONDS;
- // Curse of Tongues - limit to 12 seconds in PvP
- else if (spellproto->SpellFamilyFlags[2] & 0x800)
- return 12 * IN_MILLISECONDS;
- // Curse of Elements - limit to 120 seconds in PvP
- else if (spellproto->SpellFamilyFlags[1] & 0x200)
- return 120 * IN_MILLISECONDS;
- break;
- }
- default:
- break;
- }
-
- return 10 * IN_MILLISECONDS;
-}
-
-bool IsDiminishingReturnsGroupDurationLimited(DiminishingGroup group)
-{
- switch (group)
- {
- case DIMINISHING_BANISH:
- case DIMINISHING_CONTROLLED_STUN:
- case DIMINISHING_CONTROLLED_ROOT:
- case DIMINISHING_CYCLONE:
- case DIMINISHING_DISORIENT:
- case DIMINISHING_ENTRAPMENT:
- case DIMINISHING_FEAR:
- case DIMINISHING_HORROR:
- case DIMINISHING_MIND_CONTROL:
- case DIMINISHING_OPENING_STUN:
- case DIMINISHING_ROOT:
- case DIMINISHING_STUN:
- case DIMINISHING_SLEEP:
- case DIMINISHING_LIMITONLY:
- return true;
- default:
- return false;
- }
-}
-
SpellMgr::SpellMgr() { }
SpellMgr::~SpellMgr()
@@ -788,7 +492,7 @@ SpellProcEntry const* SpellMgr::GetSpellProcEntry(uint32 spellId) const
return NULL;
}
-bool SpellMgr::CanSpellTriggerProcOnEvent(SpellProcEntry const& procEntry, ProcEventInfo& eventInfo) const
+bool SpellMgr::CanSpellTriggerProcOnEvent(SpellProcEntry const& procEntry, ProcEventInfo& eventInfo)
{
// proc type doesn't match
if (!(eventInfo.GetTypeMask() & procEntry.ProcFlags))
@@ -811,7 +515,8 @@ bool SpellMgr::CanSpellTriggerProcOnEvent(SpellProcEntry const& procEntry, ProcE
return true;
// do triggered cast checks
- if (!(procEntry.AttributesMask & PROC_ATTR_TRIGGERED_CAN_PROC))
+ // Do not consider autoattacks as triggered spells
+ if (!(procEntry.AttributesMask & PROC_ATTR_TRIGGERED_CAN_PROC) && !(eventInfo.GetTypeMask() & AUTO_ATTACK_PROC_FLAG_MASK))
{
if (Spell const* spell = eventInfo.GetProcSpell())
{
@@ -830,20 +535,13 @@ bool SpellMgr::CanSpellTriggerProcOnEvent(SpellProcEntry const& procEntry, ProcE
return false;
// check spell family name/flags (if set) for spells
- if (eventInfo.GetTypeMask() & (PERIODIC_PROC_FLAG_MASK | SPELL_PROC_FLAG_MASK | PROC_FLAG_DONE_TRAP_ACTIVATION))
+ if (eventInfo.GetTypeMask() & (PERIODIC_PROC_FLAG_MASK | SPELL_PROC_FLAG_MASK))
{
- SpellInfo const* eventSpellInfo = eventInfo.GetSpellInfo();
-
- if (procEntry.SpellFamilyName && eventSpellInfo && (procEntry.SpellFamilyName != eventSpellInfo->SpellFamilyName))
- return false;
-
- if (procEntry.SpellFamilyMask && eventSpellInfo && !(procEntry.SpellFamilyMask & eventSpellInfo->SpellFamilyFlags))
- return false;
- }
+ if (SpellInfo const* eventSpellInfo = eventInfo.GetSpellInfo())
+ if (!eventSpellInfo->IsAffected(procEntry.SpellFamilyName, procEntry.SpellFamilyMask))
+ return false;
- // check spell type mask (if set)
- if (eventInfo.GetTypeMask() & (SPELL_PROC_FLAG_MASK | PERIODIC_PROC_FLAG_MASK))
- {
+ // check spell type mask (if set)
if (procEntry.SpellTypeMask && !(eventInfo.GetSpellTypeMask() & procEntry.SpellTypeMask))
return false;
}
@@ -1707,71 +1405,6 @@ void SpellMgr::LoadSpellGroupStackRules()
TC_LOG_INFO("server.loading", ">> Loaded %u spell group stack rules in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
}
-// Used for prepare can/can't triggr aura
-static bool InitTriggerAuraData();
-// Define can trigger auras
-static bool isTriggerAura[TOTAL_AURAS];
-// Triggered always, even from triggered spells
-static bool isAlwaysTriggeredAura[TOTAL_AURAS];
-// Prepare lists
-static bool procPrepared = InitTriggerAuraData();
-
-// List of auras that CAN be trigger but may not exist in spell_proc_event
-// in most case need for drop charges
-// in some types of aura need do additional check
-// for example SPELL_AURA_MECHANIC_IMMUNITY - need check for mechanic
-bool InitTriggerAuraData()
-{
- for (uint16 i = 0; i < TOTAL_AURAS; ++i)
- {
- isTriggerAura[i] = false;
- isAlwaysTriggeredAura[i] = false;
- }
- isTriggerAura[SPELL_AURA_DUMMY] = true; // Most dummy auras should require scripting. Remove?
- isTriggerAura[SPELL_AURA_MOD_CONFUSE] = true; // "Any direct damaging attack will revive targets"
- isTriggerAura[SPELL_AURA_MOD_THREAT] = true; // Only one spell: 28762 part of Mage T3 8p bonus
- isTriggerAura[SPELL_AURA_MOD_STUN] = true; // Aura does not have charges but needs to be removed on trigger
- isTriggerAura[SPELL_AURA_MOD_DAMAGE_DONE] = true;
- isTriggerAura[SPELL_AURA_MOD_DAMAGE_TAKEN] = true;
- isTriggerAura[SPELL_AURA_MOD_RESISTANCE] = true;
- isTriggerAura[SPELL_AURA_MOD_STEALTH] = true;
- isTriggerAura[SPELL_AURA_MOD_FEAR] = true; // Aura does not have charges but needs to be removed on trigger
- isTriggerAura[SPELL_AURA_MOD_ROOT] = true;
- isTriggerAura[SPELL_AURA_TRANSFORM] = true;
- isTriggerAura[SPELL_AURA_REFLECT_SPELLS] = true;
- isTriggerAura[SPELL_AURA_DAMAGE_IMMUNITY] = true;
- isTriggerAura[SPELL_AURA_PROC_TRIGGER_SPELL] = true;
- isTriggerAura[SPELL_AURA_PROC_TRIGGER_DAMAGE] = true;
- isTriggerAura[SPELL_AURA_MOD_CASTING_SPEED_NOT_STACK] = true;
- isTriggerAura[SPELL_AURA_MOD_POWER_COST_SCHOOL_PCT] = true;
- isTriggerAura[SPELL_AURA_MOD_POWER_COST_SCHOOL] = true;
- isTriggerAura[SPELL_AURA_REFLECT_SPELLS_SCHOOL] = true;
- isTriggerAura[SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN] = true;
- isTriggerAura[SPELL_AURA_MOD_ATTACK_POWER] = true;
- isTriggerAura[SPELL_AURA_ADD_CASTER_HIT_TRIGGER] = true;
- isTriggerAura[SPELL_AURA_OVERRIDE_CLASS_SCRIPTS] = true;
- isTriggerAura[SPELL_AURA_MOD_MELEE_HASTE] = true;
- isTriggerAura[SPELL_AURA_MOD_ATTACKER_MELEE_HIT_CHANCE] = true;
- isTriggerAura[SPELL_AURA_RAID_PROC_FROM_CHARGE] = true;
- isTriggerAura[SPELL_AURA_RAID_PROC_FROM_CHARGE_WITH_VALUE] = true;
- isTriggerAura[SPELL_AURA_PROC_TRIGGER_SPELL_WITH_VALUE] = true;
- isTriggerAura[SPELL_AURA_MOD_SPELL_CRIT_CHANCE] = true;
- isTriggerAura[SPELL_AURA_ADD_FLAT_MODIFIER] = true;
- isTriggerAura[SPELL_AURA_ADD_PCT_MODIFIER] = true;
- isTriggerAura[SPELL_AURA_ABILITY_IGNORE_AURASTATE] = true;
-
- isAlwaysTriggeredAura[SPELL_AURA_OVERRIDE_CLASS_SCRIPTS] = true;
- isAlwaysTriggeredAura[SPELL_AURA_MOD_FEAR] = true;
- isAlwaysTriggeredAura[SPELL_AURA_MOD_ROOT] = true;
- isAlwaysTriggeredAura[SPELL_AURA_MOD_STUN] = true;
- isAlwaysTriggeredAura[SPELL_AURA_TRANSFORM] = true;
- isAlwaysTriggeredAura[SPELL_AURA_SPELL_MAGNET] = true;
- isAlwaysTriggeredAura[SPELL_AURA_SCHOOL_ABSORB] = true;
- isAlwaysTriggeredAura[SPELL_AURA_MOD_STEALTH] = true;
-
- return true;
-}
-
void SpellMgr::LoadSpellProcs()
{
uint32 oldMSTime = getMSTime();
@@ -1884,6 +1517,9 @@ void SpellMgr::LoadSpellProcs()
TC_LOG_ERROR("sql.sql", "The `spell_proc` table entry for spellId %u has wrong `HitMask` set: %u", spellInfo->Id, procEntry.HitMask);
if (procEntry.HitMask && !(procEntry.ProcFlags & TAKEN_HIT_PROC_FLAG_MASK || (procEntry.ProcFlags & DONE_HIT_PROC_FLAG_MASK && (!procEntry.SpellPhaseMask || procEntry.SpellPhaseMask & (PROC_SPELL_PHASE_HIT | PROC_SPELL_PHASE_FINISH)))))
TC_LOG_ERROR("sql.sql", "The `spell_proc` table entry for spellId %u has `HitMask` value defined, but it will not be used for defined `ProcFlags` and `SpellPhaseMask` values.", spellInfo->Id);
+ for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
+ if ((procEntry.AttributesMask & (PROC_ATTR_DISABLE_EFF_0 << i)) && !spellInfo->Effects[i].IsAura())
+ TC_LOG_ERROR("sql.sql", "The `spell_proc` table entry for spellId %u has Attribute PROC_ATTR_DISABLE_EFF_%u, but effect %u is not an aura effect", spellInfo->Id, static_cast<uint32>(i), static_cast<uint32>(i));
mSpellProcMap[spellInfo->Id] = procEntry;
@@ -1900,6 +1536,73 @@ void SpellMgr::LoadSpellProcs()
TC_LOG_INFO("server.loading", ">> Loaded %u spell proc conditions and data in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
+ // Define can trigger auras
+ bool isTriggerAura[TOTAL_AURAS];
+ // Triggered always, even from triggered spells
+ bool isAlwaysTriggeredAura[TOTAL_AURAS];
+ // SpellTypeMask to add to the proc
+ uint32 spellTypeMask[TOTAL_AURAS];
+
+ // List of auras that CAN trigger but may not exist in spell_proc
+ // in most cases needed to drop charges
+
+ // some aura types need additional checks (eg SPELL_AURA_MECHANIC_IMMUNITY needs mechanic check)
+ // see AuraEffect::CheckEffectProc
+ for (uint16 i = 0; i < TOTAL_AURAS; ++i)
+ {
+ isTriggerAura[i] = false;
+ isAlwaysTriggeredAura[i] = false;
+ spellTypeMask[i] = PROC_SPELL_TYPE_MASK_ALL;
+ }
+
+ isTriggerAura[SPELL_AURA_DUMMY] = true; // Most dummy auras should require scripting, but there are some exceptions (ie 12311)
+ isTriggerAura[SPELL_AURA_MOD_CONFUSE] = true; // "Any direct damaging attack will revive targets"
+ isTriggerAura[SPELL_AURA_MOD_THREAT] = true; // Only one spell: 28762 part of Mage T3 8p bonus
+ isTriggerAura[SPELL_AURA_MOD_STUN] = true; // Aura does not have charges but needs to be removed on trigger
+ isTriggerAura[SPELL_AURA_MOD_DAMAGE_DONE] = true;
+ isTriggerAura[SPELL_AURA_MOD_DAMAGE_TAKEN] = true;
+ isTriggerAura[SPELL_AURA_MOD_RESISTANCE] = true;
+ isTriggerAura[SPELL_AURA_MOD_STEALTH] = true;
+ isTriggerAura[SPELL_AURA_MOD_FEAR] = true; // Aura does not have charges but needs to be removed on trigger
+ isTriggerAura[SPELL_AURA_MOD_ROOT] = true;
+ isTriggerAura[SPELL_AURA_TRANSFORM] = true;
+ isTriggerAura[SPELL_AURA_REFLECT_SPELLS] = true;
+ isTriggerAura[SPELL_AURA_DAMAGE_IMMUNITY] = true;
+ isTriggerAura[SPELL_AURA_PROC_TRIGGER_SPELL] = true;
+ isTriggerAura[SPELL_AURA_PROC_TRIGGER_DAMAGE] = true;
+ isTriggerAura[SPELL_AURA_MOD_CASTING_SPEED_NOT_STACK] = true;
+ isTriggerAura[SPELL_AURA_MOD_POWER_COST_SCHOOL_PCT] = true;
+ isTriggerAura[SPELL_AURA_MOD_POWER_COST_SCHOOL] = true;
+ isTriggerAura[SPELL_AURA_REFLECT_SPELLS_SCHOOL] = true;
+ isTriggerAura[SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN] = true;
+ isTriggerAura[SPELL_AURA_MOD_ATTACK_POWER] = true;
+ isTriggerAura[SPELL_AURA_ADD_CASTER_HIT_TRIGGER] = true;
+ isTriggerAura[SPELL_AURA_OVERRIDE_CLASS_SCRIPTS] = true;
+ isTriggerAura[SPELL_AURA_MOD_MELEE_HASTE] = true;
+ isTriggerAura[SPELL_AURA_MOD_ATTACKER_MELEE_HIT_CHANCE] = true;
+ isTriggerAura[SPELL_AURA_RAID_PROC_FROM_CHARGE] = true;
+ isTriggerAura[SPELL_AURA_RAID_PROC_FROM_CHARGE_WITH_VALUE] = true;
+ isTriggerAura[SPELL_AURA_PROC_TRIGGER_SPELL_WITH_VALUE] = true;
+ isTriggerAura[SPELL_AURA_MOD_SPELL_CRIT_CHANCE] = true;
+ isTriggerAura[SPELL_AURA_ADD_FLAT_MODIFIER] = true;
+ isTriggerAura[SPELL_AURA_ADD_PCT_MODIFIER] = true;
+ isTriggerAura[SPELL_AURA_ABILITY_IGNORE_AURASTATE] = true;
+
+ isAlwaysTriggeredAura[SPELL_AURA_OVERRIDE_CLASS_SCRIPTS] = true;
+ isAlwaysTriggeredAura[SPELL_AURA_MOD_STEALTH] = true;
+ isAlwaysTriggeredAura[SPELL_AURA_MOD_CONFUSE] = true;
+ isAlwaysTriggeredAura[SPELL_AURA_MOD_FEAR] = true;
+ isAlwaysTriggeredAura[SPELL_AURA_MOD_ROOT] = true;
+ isAlwaysTriggeredAura[SPELL_AURA_MOD_STUN] = true;
+ isAlwaysTriggeredAura[SPELL_AURA_TRANSFORM] = true;
+
+ spellTypeMask[SPELL_AURA_MOD_STEALTH] = PROC_SPELL_TYPE_DAMAGE | PROC_SPELL_TYPE_NO_DMG_HEAL;
+ spellTypeMask[SPELL_AURA_MOD_CONFUSE] = PROC_SPELL_TYPE_DAMAGE;
+ spellTypeMask[SPELL_AURA_MOD_FEAR] = PROC_SPELL_TYPE_DAMAGE;
+ spellTypeMask[SPELL_AURA_MOD_ROOT] = PROC_SPELL_TYPE_DAMAGE;
+ spellTypeMask[SPELL_AURA_MOD_STUN] = PROC_SPELL_TYPE_DAMAGE;
+ spellTypeMask[SPELL_AURA_TRANSFORM] = PROC_SPELL_TYPE_DAMAGE;
+
// This generates default procs to retain compatibility with previous proc system
TC_LOG_INFO("server.loading", "Generating spell proc data from SpellMap...");
count = 0;
@@ -1910,10 +1613,16 @@ void SpellMgr::LoadSpellProcs()
if (!spellInfo)
continue;
+ // Data already present in DB, overwrites default proc
if (mSpellProcMap.find(spellInfo->Id) != mSpellProcMap.end())
continue;
- bool found = false, addTriggerFlag = false;
+ // Nothing to do if no flags set
+ if (!spellInfo->ProcFlags)
+ continue;
+
+ bool addTriggerFlag = false;
+ uint32 procSpellTypeMask = PROC_SPELL_TYPE_NONE;
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
{
if (!spellInfo->Effects[i].IsEffect())
@@ -1926,28 +1635,42 @@ void SpellMgr::LoadSpellProcs()
if (!isTriggerAura[auraName])
continue;
- found = true;
-
- if (!addTriggerFlag && isAlwaysTriggeredAura[auraName])
+ procSpellTypeMask |= spellTypeMask[auraName];
+ if (isAlwaysTriggeredAura[auraName])
addTriggerFlag = true;
+
+ // many proc auras with taken procFlag mask don't have attribute "can proc with triggered"
+ // they should proc nevertheless (example mage armor spells with judgement)
+ if (!addTriggerFlag && (spellInfo->ProcFlags & TAKEN_HIT_PROC_FLAG_MASK) != 0)
+ {
+ switch (auraName)
+ {
+ case SPELL_AURA_PROC_TRIGGER_SPELL:
+ case SPELL_AURA_PROC_TRIGGER_DAMAGE:
+ addTriggerFlag = true;
+ break;
+ default:
+ break;
+ }
+ }
break;
}
- if (!found)
- continue;
-
- if (!spellInfo->ProcFlags)
+ if (!procSpellTypeMask)
continue;
SpellProcEntry procEntry;
procEntry.SchoolMask = 0;
- procEntry.SpellFamilyName = spellInfo->SpellFamilyName;
procEntry.ProcFlags = spellInfo->ProcFlags;
+ procEntry.SpellFamilyName = 0;
for (uint32 i = 0; i < MAX_SPELL_EFFECTS; ++i)
if (spellInfo->Effects[i].IsEffect() && isTriggerAura[spellInfo->Effects[i].ApplyAuraName])
procEntry.SpellFamilyMask |= spellInfo->Effects[i].SpellClassMask;
- procEntry.SpellTypeMask = PROC_SPELL_TYPE_MASK_ALL;
+ if (procEntry.SpellFamilyMask)
+ procEntry.SpellFamilyName = spellInfo->SpellFamilyName;
+
+ procEntry.SpellTypeMask = procSpellTypeMask;
procEntry.SpellPhaseMask = PROC_SPELL_PHASE_HIT;
procEntry.HitMask = PROC_HIT_NONE; // uses default proc @see SpellMgr::CanSpellTriggerProcOnEvent
@@ -2895,6 +2618,8 @@ void SpellMgr::LoadSpellInfoCorrections()
case 2895: // Wrath of Air Totem rank 1 (Aura)
case 68933: // Wrath of Air Totem rank 2 (Aura)
case 29200: // Purify Helboar Meat
+ case 10872: // Abolish Disease Effect
+ case 3137: // Abolish Poison Effect
spellInfo->Effects[EFFECT_0].TargetA = SpellImplicitTargetInfo(TARGET_UNIT_CASTER);
spellInfo->Effects[EFFECT_0].TargetB = SpellImplicitTargetInfo();
break;
@@ -2922,6 +2647,15 @@ void SpellMgr::LoadSpellInfoCorrections()
// because of bug in dbc
spellInfo->ProcChance = 0;
break;
+ case 51528: // Maelstrom Weapon (Rank 1)
+ case 51529: // Maelstrom Weapon (Rank 2)
+ case 51530: // Maelstrom Weapon (Rank 3)
+ case 51531: // Maelstrom Weapon (Rank 4)
+ case 51532: // Maelstrom Weapon (Rank 5)
+ // due to discrepancies between ranks
+ spellInfo->EquippedItemSubClassMask = 0x0000FC33;
+ spellInfo->AttributesEx3 |= SPELL_ATTR3_CAN_PROC_WITH_TRIGGERED;
+ break;
case 20335: // Heart of the Crusader
case 20336:
case 20337:
@@ -3004,6 +2738,12 @@ void SpellMgr::LoadSpellInfoCorrections()
case 53385: // Divine Storm (Damage)
spellInfo->MaxAffectedTargets = 4;
break;
+ case 56342: // Lock and Load (Rank 1)
+ // @workaround: Delete dummy effect from rank 1,
+ // effect apply aura has TargetA == TargetB == 0 but core still applies it to caster
+ // core bug?
+ spellInfo->Effects[EFFECT_2].Effect = 0;
+ break;
case 53480: // Roar of Sacrifice
// missing spell effect 2 data, taken from 4.3.4
spellInfo->Effects[EFFECT_1].Effect = SPELL_EFFECT_APPLY_AURA;
@@ -3041,15 +2781,14 @@ void SpellMgr::LoadSpellInfoCorrections()
case 44544: // Fingers of Frost
spellInfo->Effects[EFFECT_0].SpellClassMask = flag96(685904631, 1151048, 0);
break;
- case 53257: // Cobra Strikes
- spellInfo->ProcCharges = 2;
- spellInfo->StackAmount = 0;
- break;
case 49224: // Magic Suppression - DK
case 49610: // Magic Suppression - DK
case 49611: // Magic Suppression - DK
spellInfo->ProcCharges = 0;
break;
+ case 52212: // Death and Decay
+ spellInfo->AttributesEx6 |= SPELL_ATTR6_CAN_TARGET_INVISIBLE;
+ break;
case 37408: // Oscillation Field
spellInfo->AttributesEx3 |= SPELL_ATTR3_STACK_FOR_DIFF_CASTERS;
break;
@@ -3129,6 +2868,19 @@ void SpellMgr::LoadSpellInfoCorrections()
case 27915: // Anchor to Skulls
case 27931: // Anchor to Skulls
case 27937: // Anchor to Skulls
+ case 16177: // Ancestral Fortitude (Rank 1)
+ case 16236: // Ancestral Fortitude (Rank 2)
+ case 16237: // Ancestral Fortitude (Rank 3)
+ case 47930: // Grace
+ case 45145: // Snake Trap Effect (Rank 1)
+ case 13812: // Explosive Trap Effect (Rank 1)
+ case 14314: // Explosive Trap Effect (Rank 2)
+ case 14315: // Explosive Trap Effect (Rank 3)
+ case 27026: // Explosive Trap Effect (Rank 4)
+ case 49064: // Explosive Trap Effect (Rank 5)
+ case 49065: // Explosive Trap Effect (Rank 6)
+ case 43446: // Explosive Trap Effect (Hexlord Malacrass)
+ case 68979: // Unleashed Souls
spellInfo->RangeEntry = sSpellRangeStore.LookupEntry(13);
break;
// target allys instead of enemies, target A is src_caster, spells with effect like that have ally target
@@ -3236,9 +2988,6 @@ void SpellMgr::LoadSpellInfoCorrections()
case 71839: // Drain Life - Bryntroll Heroic
spellInfo->AttributesEx2 |= SPELL_ATTR2_CANT_CRIT;
break;
- case 34471: // The Beast Within
- spellInfo->AttributesEx5 |= SPELL_ATTR5_USABLE_WHILE_CONFUSED | SPELL_ATTR5_USABLE_WHILE_FEARED | SPELL_ATTR5_USABLE_WHILE_STUNNED;
- break;
case 56606: // Ride Jokkum
case 61791: // Ride Vehicle (Yogg-Saron)
/// @todo: remove this when basepoints of all Ride Vehicle auras are calculated correctly
@@ -3277,8 +3026,23 @@ void SpellMgr::LoadSpellInfoCorrections()
spellInfo->InterruptFlags &= ~AURA_INTERRUPT_FLAG_CAST;
break;
case 42767: // Sic'em
+ case 43092: // Stop the Ascension!: Halfdan's Soul Destruction
spellInfo->Effects[EFFECT_0].TargetA = SpellImplicitTargetInfo(TARGET_UNIT_NEARBY_ENTRY);
break;
+ case 14621: // Polymorph (Six Demon Bag)
+ spellInfo->RangeEntry = sSpellRangeStore.LookupEntry(4); // Medium Range
+ break;
+ case 35101: // Concussive Barrage
+ spellInfo->RangeEntry = sSpellRangeStore.LookupEntry(155); // Hunter Range (Long)
+ break;
+ case 55741: // Desecration (Rank 1)
+ case 68766: // Desecration (Rank 2)
+ spellInfo->RangeEntry = sSpellRangeStore.LookupEntry(2); // Melee Range
+ break;
+ case 46946: // Safeguard (Rank 1)
+ case 46947: // Safeguard (Rank 2)
+ spellInfo->RangeEntry = sSpellRangeStore.LookupEntry(34); // Twenty-Five yards
+ break;
// VIOLET HOLD SPELLS
//
case 54258: // Water Globule (Ichoron)
@@ -3731,3 +3495,50 @@ void SpellMgr::LoadSpellInfoCorrections()
TC_LOG_INFO("server.loading", ">> Loaded SpellInfo corrections in %u ms", GetMSTimeDiffToNow(oldMSTime));
}
+
+void SpellMgr::LoadSpellInfoSpellSpecificAndAuraState()
+{
+ uint32 oldMSTime = getMSTime();
+
+ for (SpellInfo* spellInfo : mSpellInfoMap)
+ {
+ if (!spellInfo)
+ continue;
+
+ // AuraState depends on SpellSpecific
+ spellInfo->_LoadSpellSpecific();
+ spellInfo->_LoadAuraState();
+ }
+
+ TC_LOG_INFO("server.loading", ">> Loaded SpellInfo SpellSpecific and AuraState in %u ms", GetMSTimeDiffToNow(oldMSTime));
+}
+
+void SpellMgr::LoadSpellInfoDiminishing()
+{
+ uint32 oldMSTime = getMSTime();
+
+ for (SpellInfo* spellInfo : mSpellInfoMap)
+ {
+ if (!spellInfo)
+ continue;
+
+ spellInfo->_LoadSpellDiminishInfo();
+ }
+
+ TC_LOG_INFO("server.loading", ">> Loaded SpellInfo diminishing infos in %u ms", GetMSTimeDiffToNow(oldMSTime));
+}
+
+void SpellMgr::LoadSpellInfoImmunities()
+{
+ uint32 oldMSTime = getMSTime();
+
+ for (SpellInfo* spellInfo : mSpellInfoMap)
+ {
+ if (!spellInfo)
+ continue;
+
+ spellInfo->_LoadImmunityInfo();
+ }
+
+ TC_LOG_INFO("server.loading", ">> Loaded SpellInfo immunity infos in %u ms", GetMSTimeDiffToNow(oldMSTime));
+}
diff --git a/src/server/game/Spells/SpellMgr.h b/src/server/game/Spells/SpellMgr.h
index ff328a2ac1f..a08ff921a2e 100644
--- a/src/server/game/Spells/SpellMgr.h
+++ b/src/server/game/Spells/SpellMgr.h
@@ -160,13 +160,13 @@ enum ProcFlags
| PROC_FLAG_DONE_SPELL_RANGED_DMG_CLASS | PROC_FLAG_TAKEN_SPELL_RANGED_DMG_CLASS,
SPELL_PROC_FLAG_MASK = PROC_FLAG_DONE_SPELL_MELEE_DMG_CLASS | PROC_FLAG_TAKEN_SPELL_MELEE_DMG_CLASS
+ | PROC_FLAG_DONE_RANGED_AUTO_ATTACK | PROC_FLAG_TAKEN_RANGED_AUTO_ATTACK
| PROC_FLAG_DONE_SPELL_RANGED_DMG_CLASS | PROC_FLAG_TAKEN_SPELL_RANGED_DMG_CLASS
| PROC_FLAG_DONE_SPELL_NONE_DMG_CLASS_POS | PROC_FLAG_TAKEN_SPELL_NONE_DMG_CLASS_POS
| PROC_FLAG_DONE_SPELL_NONE_DMG_CLASS_NEG | PROC_FLAG_TAKEN_SPELL_NONE_DMG_CLASS_NEG
| PROC_FLAG_DONE_SPELL_MAGIC_DMG_CLASS_POS | PROC_FLAG_TAKEN_SPELL_MAGIC_DMG_CLASS_POS
- | PROC_FLAG_DONE_SPELL_MAGIC_DMG_CLASS_NEG | PROC_FLAG_TAKEN_SPELL_MAGIC_DMG_CLASS_NEG,
-
- SPELL_CAST_PROC_FLAG_MASK = SPELL_PROC_FLAG_MASK | PROC_FLAG_DONE_TRAP_ACTIVATION | RANGED_PROC_FLAG_MASK,
+ | PROC_FLAG_DONE_SPELL_MAGIC_DMG_CLASS_NEG | PROC_FLAG_TAKEN_SPELL_MAGIC_DMG_CLASS_NEG
+ | PROC_FLAG_DONE_TRAP_ACTIVATION,
PERIODIC_PROC_FLAG_MASK = PROC_FLAG_DONE_PERIODIC | PROC_FLAG_TAKEN_PERIODIC,
@@ -174,7 +174,8 @@ enum ProcFlags
| PROC_FLAG_DONE_SPELL_MELEE_DMG_CLASS | PROC_FLAG_DONE_SPELL_RANGED_DMG_CLASS
| PROC_FLAG_DONE_SPELL_NONE_DMG_CLASS_POS | PROC_FLAG_DONE_SPELL_NONE_DMG_CLASS_NEG
| PROC_FLAG_DONE_SPELL_MAGIC_DMG_CLASS_POS | PROC_FLAG_DONE_SPELL_MAGIC_DMG_CLASS_NEG
- | PROC_FLAG_DONE_PERIODIC | PROC_FLAG_DONE_MAINHAND_ATTACK | PROC_FLAG_DONE_OFFHAND_ATTACK,
+ | PROC_FLAG_DONE_PERIODIC | PROC_FLAG_DONE_TRAP_ACTIVATION
+ | PROC_FLAG_DONE_MAINHAND_ATTACK | PROC_FLAG_DONE_OFFHAND_ATTACK,
TAKEN_HIT_PROC_FLAG_MASK = PROC_FLAG_TAKEN_MELEE_AUTO_ATTACK | PROC_FLAG_TAKEN_RANGED_AUTO_ATTACK
| PROC_FLAG_TAKEN_SPELL_MELEE_DMG_CLASS | PROC_FLAG_TAKEN_SPELL_RANGED_DMG_CLASS
@@ -237,7 +238,11 @@ enum ProcAttributes
PROC_ATTR_REQ_EXP_OR_HONOR = 0x0000001, // requires proc target to give exp or honor for aura proc
PROC_ATTR_TRIGGERED_CAN_PROC = 0x0000002, // aura can proc even with triggered spells
PROC_ATTR_REQ_MANA_COST = 0x0000004, // requires triggering spell to have a mana cost for aura proc
- PROC_ATTR_REQ_SPELLMOD = 0x0000008 // requires triggering spell to be affected by proccing aura to drop charges
+ PROC_ATTR_REQ_SPELLMOD = 0x0000008, // requires triggering spell to be affected by proccing aura to drop charges
+
+ PROC_ATTR_DISABLE_EFF_0 = 0x0000010, // explicitly disables aura proc from effects, USE ONLY IF 100% SURE AURA SHOULDN'T PROC
+ PROC_ATTR_DISABLE_EFF_1 = 0x0000020, // used to avoid a console error if the spell has invalid trigger spell and handled elsewhere
+ PROC_ATTR_DISABLE_EFF_2 = 0x0000040 // or handling not needed
};
struct SpellProcEntry
@@ -546,13 +551,6 @@ inline bool IsProfessionOrRidingSkill(uint32 skill)
bool IsPartOfSkillLine(uint32 skillId, uint32 spellId);
-// spell diminishing returns
-TC_GAME_API DiminishingGroup GetDiminishingReturnsGroupForSpell(SpellInfo const* spellproto, bool triggered);
-TC_GAME_API DiminishingReturnsType GetDiminishingReturnsGroupType(DiminishingGroup group);
-TC_GAME_API DiminishingLevels GetDiminishingReturnsMaxLevel(DiminishingGroup group);
-TC_GAME_API int32 GetDiminishingReturnsLimitDuration(DiminishingGroup group, SpellInfo const* spellproto);
-TC_GAME_API bool IsDiminishingReturnsGroupDurationLimited(DiminishingGroup group);
-
class TC_GAME_API SpellMgr
{
// Constructors
@@ -612,7 +610,7 @@ class TC_GAME_API SpellMgr
// Spell proc table
SpellProcEntry const* GetSpellProcEntry(uint32 spellId) const;
- bool CanSpellTriggerProcOnEvent(SpellProcEntry const& procEntry, ProcEventInfo& eventInfo) const;
+ static bool CanSpellTriggerProcOnEvent(SpellProcEntry const& procEntry, ProcEventInfo& eventInfo);
// Spell bonus data table
SpellBonusEntry const* GetSpellBonusData(uint32 spellId) const;
@@ -684,6 +682,9 @@ class TC_GAME_API SpellMgr
void UnloadSpellInfoImplicitTargetConditionLists();
void LoadSpellInfoCustomAttributes();
void LoadSpellInfoCorrections();
+ void LoadSpellInfoSpellSpecificAndAuraState();
+ void LoadSpellInfoDiminishing();
+ void LoadSpellInfoImmunities();
private:
SpellDifficultySearcherMap mSpellDifficultySearcherMap;
diff --git a/src/server/game/Spells/SpellScript.cpp b/src/server/game/Spells/SpellScript.cpp
index 67aaa582776..950456394d8 100644
--- a/src/server/game/Spells/SpellScript.cpp
+++ b/src/server/game/Spells/SpellScript.cpp
@@ -301,35 +301,35 @@ void SpellScript::DestinationTargetSelectHandler::Call(SpellScript* spellScript,
bool SpellScript::_Validate(SpellInfo const* entry)
{
- for (std::list<EffectHandler>::iterator itr = OnEffectLaunch.begin(); itr != OnEffectLaunch.end(); ++itr)
+ for (auto itr = OnEffectLaunch.begin(); itr != OnEffectLaunch.end(); ++itr)
if (!(*itr).GetAffectedEffectsMask(entry))
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `OnEffectLaunch` of SpellScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
- for (std::list<EffectHandler>::iterator itr = OnEffectLaunchTarget.begin(); itr != OnEffectLaunchTarget.end(); ++itr)
+ for (auto itr = OnEffectLaunchTarget.begin(); itr != OnEffectLaunchTarget.end(); ++itr)
if (!(*itr).GetAffectedEffectsMask(entry))
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `OnEffectLaunchTarget` of SpellScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
- for (std::list<EffectHandler>::iterator itr = OnEffectHit.begin(); itr != OnEffectHit.end(); ++itr)
+ for (auto itr = OnEffectHit.begin(); itr != OnEffectHit.end(); ++itr)
if (!(*itr).GetAffectedEffectsMask(entry))
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `OnEffectHit` of SpellScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
- for (std::list<EffectHandler>::iterator itr = OnEffectHitTarget.begin(); itr != OnEffectHitTarget.end(); ++itr)
+ for (auto itr = OnEffectHitTarget.begin(); itr != OnEffectHitTarget.end(); ++itr)
if (!(*itr).GetAffectedEffectsMask(entry))
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `OnEffectHitTarget` of SpellScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
- for (std::list<EffectHandler>::iterator itr = OnEffectSuccessfulDispel.begin(); itr != OnEffectSuccessfulDispel.end(); ++itr)
+ for (auto itr = OnEffectSuccessfulDispel.begin(); itr != OnEffectSuccessfulDispel.end(); ++itr)
if (!(*itr).GetAffectedEffectsMask(entry))
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `OnEffectSuccessfulDispel` of SpellScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
- for (std::list<ObjectAreaTargetSelectHandler>::iterator itr = OnObjectAreaTargetSelect.begin(); itr != OnObjectAreaTargetSelect.end(); ++itr)
+ for (auto itr = OnObjectAreaTargetSelect.begin(); itr != OnObjectAreaTargetSelect.end(); ++itr)
if (!(*itr).GetAffectedEffectsMask(entry))
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `OnObjectAreaTargetSelect` of SpellScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
- for (std::list<ObjectTargetSelectHandler>::iterator itr = OnObjectTargetSelect.begin(); itr != OnObjectTargetSelect.end(); ++itr)
+ for (auto itr = OnObjectTargetSelect.begin(); itr != OnObjectTargetSelect.end(); ++itr)
if (!(*itr).GetAffectedEffectsMask(entry))
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `OnObjectTargetSelect` of SpellScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
- for (std::list<DestinationTargetSelectHandler>::iterator itr = OnDestinationTargetSelect.begin(); itr != OnDestinationTargetSelect.end(); ++itr)
+ for (auto itr = OnDestinationTargetSelect.begin(); itr != OnDestinationTargetSelect.end(); ++itr)
if (!(*itr).GetAffectedEffectsMask(entry))
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `OnDestinationTargetSelect` of SpellScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
@@ -624,9 +624,9 @@ SpellInfo const* SpellScript::GetTriggeringSpell()
return m_spell->m_triggeredByAuraSpell;
}
-void SpellScript::FinishCast(SpellCastResult result)
+void SpellScript::FinishCast(SpellCastResult result, uint32* param1 /*= nullptr*/, uint32* param2 /*= nullptr*/)
{
- m_spell->SendCastResult(result);
+ m_spell->SendCastResult(result, param1, param2);
m_spell->finish(result == SPELL_CAST_OK);
}
@@ -648,99 +648,99 @@ SpellValue const* SpellScript::GetSpellValue()
bool AuraScript::_Validate(SpellInfo const* entry)
{
- for (std::list<CheckAreaTargetHandler>::iterator itr = DoCheckAreaTarget.begin(); itr != DoCheckAreaTarget.end(); ++itr)
+ for (auto itr = DoCheckAreaTarget.begin(); itr != DoCheckAreaTarget.end(); ++itr)
if (!entry->HasAreaAuraEffect() && !entry->HasEffect(SPELL_EFFECT_PERSISTENT_AREA_AURA) && !entry->HasEffect(SPELL_EFFECT_APPLY_AURA))
TC_LOG_ERROR("scripts", "Spell `%u` of script `%s` does not have apply aura effect - handler bound to hook `DoCheckAreaTarget` of AuraScript won't be executed", entry->Id, m_scriptName->c_str());
- for (std::list<AuraDispelHandler>::iterator itr = OnDispel.begin(); itr != OnDispel.end(); ++itr)
+ for (auto itr = OnDispel.begin(); itr != OnDispel.end(); ++itr)
if (!entry->HasEffect(SPELL_EFFECT_APPLY_AURA) && !entry->HasAreaAuraEffect())
TC_LOG_ERROR("scripts", "Spell `%u` of script `%s` does not have apply aura effect - handler bound to hook `OnDispel` of AuraScript won't be executed", entry->Id, m_scriptName->c_str());
- for (std::list<AuraDispelHandler>::iterator itr = AfterDispel.begin(); itr != AfterDispel.end(); ++itr)
+ for (auto itr = AfterDispel.begin(); itr != AfterDispel.end(); ++itr)
if (!entry->HasEffect(SPELL_EFFECT_APPLY_AURA) && !entry->HasAreaAuraEffect())
TC_LOG_ERROR("scripts", "Spell `%u` of script `%s` does not have apply aura effect - handler bound to hook `AfterDispel` of AuraScript won't be executed", entry->Id, m_scriptName->c_str());
- for (std::list<EffectApplyHandler>::iterator itr = OnEffectApply.begin(); itr != OnEffectApply.end(); ++itr)
+ for (auto itr = OnEffectApply.begin(); itr != OnEffectApply.end(); ++itr)
if (!(*itr).GetAffectedEffectsMask(entry))
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `OnEffectApply` of AuraScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
- for (std::list<EffectApplyHandler>::iterator itr = OnEffectRemove.begin(); itr != OnEffectRemove.end(); ++itr)
+ for (auto itr = OnEffectRemove.begin(); itr != OnEffectRemove.end(); ++itr)
if (!(*itr).GetAffectedEffectsMask(entry))
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `OnEffectRemove` of AuraScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
- for (std::list<EffectApplyHandler>::iterator itr = AfterEffectApply.begin(); itr != AfterEffectApply.end(); ++itr)
+ for (auto itr = AfterEffectApply.begin(); itr != AfterEffectApply.end(); ++itr)
if (!(*itr).GetAffectedEffectsMask(entry))
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `AfterEffectApply` of AuraScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
- for (std::list<EffectApplyHandler>::iterator itr = AfterEffectRemove.begin(); itr != AfterEffectRemove.end(); ++itr)
+ for (auto itr = AfterEffectRemove.begin(); itr != AfterEffectRemove.end(); ++itr)
if (!(*itr).GetAffectedEffectsMask(entry))
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `AfterEffectRemove` of AuraScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
- for (std::list<EffectPeriodicHandler>::iterator itr = OnEffectPeriodic.begin(); itr != OnEffectPeriodic.end(); ++itr)
+ for (auto itr = OnEffectPeriodic.begin(); itr != OnEffectPeriodic.end(); ++itr)
if (!(*itr).GetAffectedEffectsMask(entry))
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `OnEffectPeriodic` of AuraScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
- for (std::list<EffectUpdatePeriodicHandler>::iterator itr = OnEffectUpdatePeriodic.begin(); itr != OnEffectUpdatePeriodic.end(); ++itr)
+ for (auto itr = OnEffectUpdatePeriodic.begin(); itr != OnEffectUpdatePeriodic.end(); ++itr)
if (!(*itr).GetAffectedEffectsMask(entry))
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `OnEffectUpdatePeriodic` of AuraScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
- for (std::list<EffectCalcAmountHandler>::iterator itr = DoEffectCalcAmount.begin(); itr != DoEffectCalcAmount.end(); ++itr)
+ for (auto itr = DoEffectCalcAmount.begin(); itr != DoEffectCalcAmount.end(); ++itr)
if (!(*itr).GetAffectedEffectsMask(entry))
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `DoEffectCalcAmount` of AuraScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
- for (std::list<EffectCalcPeriodicHandler>::iterator itr = DoEffectCalcPeriodic.begin(); itr != DoEffectCalcPeriodic.end(); ++itr)
+ for (auto itr = DoEffectCalcPeriodic.begin(); itr != DoEffectCalcPeriodic.end(); ++itr)
if (!(*itr).GetAffectedEffectsMask(entry))
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `DoEffectCalcPeriodic` of AuraScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
- for (std::list<EffectCalcSpellModHandler>::iterator itr = DoEffectCalcSpellMod.begin(); itr != DoEffectCalcSpellMod.end(); ++itr)
+ for (auto itr = DoEffectCalcSpellMod.begin(); itr != DoEffectCalcSpellMod.end(); ++itr)
if (!(*itr).GetAffectedEffectsMask(entry))
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `DoEffectCalcSpellMod` of AuraScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
- for (std::list<EffectAbsorbHandler>::iterator itr = OnEffectAbsorb.begin(); itr != OnEffectAbsorb.end(); ++itr)
+ for (auto itr = OnEffectAbsorb.begin(); itr != OnEffectAbsorb.end(); ++itr)
if (!(*itr).GetAffectedEffectsMask(entry))
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `OnEffectAbsorb` of AuraScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
- for (std::list<EffectAbsorbHandler>::iterator itr = AfterEffectAbsorb.begin(); itr != AfterEffectAbsorb.end(); ++itr)
+ for (auto itr = AfterEffectAbsorb.begin(); itr != AfterEffectAbsorb.end(); ++itr)
if (!(*itr).GetAffectedEffectsMask(entry))
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `AfterEffectAbsorb` of AuraScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
- for (std::list<EffectManaShieldHandler>::iterator itr = OnEffectManaShield.begin(); itr != OnEffectManaShield.end(); ++itr)
+ for (auto itr = OnEffectManaShield.begin(); itr != OnEffectManaShield.end(); ++itr)
if (!(*itr).GetAffectedEffectsMask(entry))
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `OnEffectManaShield` of AuraScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
- for (std::list<EffectManaShieldHandler>::iterator itr = AfterEffectManaShield.begin(); itr != AfterEffectManaShield.end(); ++itr)
+ for (auto itr = AfterEffectManaShield.begin(); itr != AfterEffectManaShield.end(); ++itr)
if (!(*itr).GetAffectedEffectsMask(entry))
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `AfterEffectManaShield` of AuraScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
- for (std::list<EffectSplitHandler>::iterator itr = OnEffectSplit.begin(); itr != OnEffectSplit.end(); ++itr)
+ for (auto itr = OnEffectSplit.begin(); itr != OnEffectSplit.end(); ++itr)
if (!(*itr).GetAffectedEffectsMask(entry))
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `OnEffectSplit` of AuraScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
- for (std::list<CheckProcHandler>::iterator itr = DoCheckProc.begin(); itr != DoCheckProc.end(); ++itr)
+ for (auto itr = DoCheckProc.begin(); itr != DoCheckProc.end(); ++itr)
if (!entry->HasEffect(SPELL_EFFECT_APPLY_AURA) && !entry->HasAreaAuraEffect())
TC_LOG_ERROR("scripts", "Spell `%u` of script `%s` does not have apply aura effect - handler bound to hook `DoCheckProc` of AuraScript won't be executed", entry->Id, m_scriptName->c_str());
- for (std::list<CheckEffectProcHandler>::iterator itr = DoCheckEffectProc.begin(); itr != DoCheckEffectProc.end(); ++itr)
+ for (auto itr = DoCheckEffectProc.begin(); itr != DoCheckEffectProc.end(); ++itr)
if (!itr->GetAffectedEffectsMask(entry))
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `DoCheckEffectProc` of AuraScript won't be executed", entry->Id, itr->ToString().c_str(), m_scriptName->c_str());
- for (std::list<AuraProcHandler>::iterator itr = DoPrepareProc.begin(); itr != DoPrepareProc.end(); ++itr)
+ for (auto itr = DoPrepareProc.begin(); itr != DoPrepareProc.end(); ++itr)
if (!entry->HasEffect(SPELL_EFFECT_APPLY_AURA) && !entry->HasAreaAuraEffect())
TC_LOG_ERROR("scripts", "Spell `%u` of script `%s` does not have apply aura effect - handler bound to hook `DoPrepareProc` of AuraScript won't be executed", entry->Id, m_scriptName->c_str());
- for (std::list<AuraProcHandler>::iterator itr = OnProc.begin(); itr != OnProc.end(); ++itr)
+ for (auto itr = OnProc.begin(); itr != OnProc.end(); ++itr)
if (!entry->HasEffect(SPELL_EFFECT_APPLY_AURA) && !entry->HasAreaAuraEffect())
TC_LOG_ERROR("scripts", "Spell `%u` of script `%s` does not have apply aura effect - handler bound to hook `OnProc` of AuraScript won't be executed", entry->Id, m_scriptName->c_str());
- for (std::list<AuraProcHandler>::iterator itr = AfterProc.begin(); itr != AfterProc.end(); ++itr)
+ for (auto itr = AfterProc.begin(); itr != AfterProc.end(); ++itr)
if (!entry->HasEffect(SPELL_EFFECT_APPLY_AURA) && !entry->HasAreaAuraEffect())
TC_LOG_ERROR("scripts", "Spell `%u` of script `%s` does not have apply aura effect - handler bound to hook `AfterProc` of AuraScript won't be executed", entry->Id, m_scriptName->c_str());
- for (std::list<EffectProcHandler>::iterator itr = OnEffectProc.begin(); itr != OnEffectProc.end(); ++itr)
+ for (auto itr = OnEffectProc.begin(); itr != OnEffectProc.end(); ++itr)
if (!(*itr).GetAffectedEffectsMask(entry))
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `OnEffectProc` of AuraScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
- for (std::list<EffectProcHandler>::iterator itr = AfterEffectProc.begin(); itr != AfterEffectProc.end(); ++itr)
+ for (auto itr = AfterEffectProc.begin(); itr != AfterEffectProc.end(); ++itr)
if (!(*itr).GetAffectedEffectsMask(entry))
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `AfterEffectProc` of AuraScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
diff --git a/src/server/game/Spells/SpellScript.h b/src/server/game/Spells/SpellScript.h
index 1ec10f03820..af30b6a7879 100644
--- a/src/server/game/Spells/SpellScript.h
+++ b/src/server/game/Spells/SpellScript.h
@@ -63,9 +63,9 @@ class TC_GAME_API _SpellScript
public:
_SpellScript() : m_currentScriptState(SPELL_SCRIPT_STATE_NONE), m_scriptName(NULL), m_scriptSpellId(0) {}
virtual ~_SpellScript() { }
- virtual void _Register();
- virtual void _Unload();
- virtual void _Init(std::string const* scriptname, uint32 spellId);
+ void _Register();
+ void _Unload();
+ void _Init(std::string const* scriptname, uint32 spellId);
std::string const* _GetScriptName() const;
protected:
@@ -441,7 +441,7 @@ class TC_GAME_API SpellScript : public _SpellScript
SpellInfo const* GetTriggeringSpell();
// finishes spellcast prematurely with selected error message
- void FinishCast(SpellCastResult result);
+ void FinishCast(SpellCastResult result, uint32* param1 = nullptr, uint32* param2 = nullptr);
void SetCustomCastResultMessage(SpellCustomErrors result);
};
diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp
index 934b33333f2..7bbf73d028d 100644
--- a/src/server/game/World/World.cpp
+++ b/src/server/game/World/World.cpp
@@ -1449,6 +1449,12 @@ void World::SetInitialWorldSettings()
TC_LOG_INFO("server.loading", "Loading SpellInfo custom attributes...");
sSpellMgr->LoadSpellInfoCustomAttributes();
+ TC_LOG_INFO("server.loading", "Loading SpellInfo diminishing infos...");
+ sSpellMgr->LoadSpellInfoDiminishing();
+
+ TC_LOG_INFO("server.loading", "Loading SpellInfo immunity infos...");
+ sSpellMgr->LoadSpellInfoImmunities();
+
TC_LOG_INFO("server.loading", "Loading GameObject models...");
LoadGameObjectModelList(m_dataPath);
@@ -1508,6 +1514,9 @@ void World::SetInitialWorldSettings()
TC_LOG_INFO("server.loading", "Loading Spell Learn Skills...");
sSpellMgr->LoadSpellLearnSkills(); // must be after LoadSpellRanks
+ TC_LOG_INFO("server.loading", "Loading SpellInfo SpellSpecific and AuraState...");
+ sSpellMgr->LoadSpellInfoSpellSpecificAndAuraState(); // must be after LoadSpellRanks
+
TC_LOG_INFO("server.loading", "Loading Spell Learn Spells...");
sSpellMgr->LoadSpellLearnSpells();
diff --git a/src/server/scripts/Commands/cs_cast.cpp b/src/server/scripts/Commands/cs_cast.cpp
index 44c606a360f..45e6c65cc6b 100644
--- a/src/server/scripts/Commands/cs_cast.cpp
+++ b/src/server/scripts/Commands/cs_cast.cpp
@@ -99,8 +99,7 @@ public:
return false;
}
- bool triggered = (triggeredStr != NULL);
-
+ TriggerCastFlags triggered = (triggeredStr != NULL) ? TRIGGERED_FULL_DEBUG_MASK : TRIGGERED_NONE;
handler->GetSession()->GetPlayer()->CastSpell(target, spellId, triggered);
return true;
@@ -132,8 +131,7 @@ public:
return false;
}
- bool triggered = (triggeredStr != NULL);
-
+ TriggerCastFlags triggered = (triggeredStr != NULL) ? TRIGGERED_FULL_DEBUG_MASK : TRIGGERED_NONE;
caster->CastSpell(handler->GetSession()->GetPlayer(), spellId, triggered);
return true;
@@ -167,8 +165,7 @@ public:
return false;
}
- bool triggered = (triggeredStr != NULL);
-
+ TriggerCastFlags triggered = (triggeredStr != NULL) ? TRIGGERED_FULL_DEBUG_MASK : TRIGGERED_NONE;
float x, y, z;
handler->GetSession()->GetPlayer()->GetClosePoint(x, y, z, dist);
@@ -230,8 +227,7 @@ public:
return false;
}
- bool triggered = (triggeredStr != NULL);
-
+ TriggerCastFlags triggered = (triggeredStr != NULL) ? TRIGGERED_FULL_DEBUG_MASK : TRIGGERED_NONE;
caster->CastSpell(caster->GetVictim(), spellId, triggered);
return true;
@@ -274,8 +270,7 @@ public:
return false;
}
- bool triggered = (triggeredStr != NULL);
-
+ TriggerCastFlags triggered = (triggeredStr != NULL) ? TRIGGERED_FULL_DEBUG_MASK : TRIGGERED_NONE;
caster->CastSpell(x, y, z, spellId, triggered);
return true;
diff --git a/src/server/scripts/Commands/cs_guild.cpp b/src/server/scripts/Commands/cs_guild.cpp
index 98fc852b573..8c4bf73395d 100644
--- a/src/server/scripts/Commands/cs_guild.cpp
+++ b/src/server/scripts/Commands/cs_guild.cpp
@@ -146,7 +146,8 @@ public:
return false;
// player's guild membership checked in AddMember before add
- return targetGuild->AddMember(targetGuid);
+ SQLTransaction trans(nullptr);
+ return targetGuild->AddMember(trans, targetGuid);
}
static bool HandleGuildUninviteCommand(ChatHandler* handler, char const* args)
@@ -164,7 +165,8 @@ public:
if (!targetGuild)
return false;
- targetGuild->DeleteMember(targetGuid, false, true, true);
+ SQLTransaction trans(nullptr);
+ targetGuild->DeleteMember(trans, targetGuid, false, true, true);
return true;
}
@@ -191,7 +193,8 @@ public:
return false;
uint8 newRank = uint8(atoi(rankStr));
- return targetGuild->ChangeMemberRank(targetGuid, newRank);
+ SQLTransaction trans(nullptr);
+ return targetGuild->ChangeMemberRank(trans, targetGuid, newRank);
}
static bool HandleGuildRenameCommand(ChatHandler* handler, char const* _args)
diff --git a/src/server/scripts/Commands/cs_message.cpp b/src/server/scripts/Commands/cs_message.cpp
index 69ff04ffb46..4b3caae686b 100644
--- a/src/server/scripts/Commands/cs_message.cpp
+++ b/src/server/scripts/Commands/cs_message.cpp
@@ -24,6 +24,7 @@ EndScriptData */
#include "ScriptMgr.h"
#include "Chat.h"
+#include "Channel.h"
#include "ChannelMgr.h"
#include "Language.h"
#include "Player.h"
@@ -63,21 +64,49 @@ public:
if (!*args)
return false;
char const* channelStr = strtok((char*)args, " ");
- char const* argStr = strtok(NULL, "");
+ char const* argStr = strtok(nullptr, "");
if (!channelStr || !argStr)
return false;
+ uint32 channelId = 0;
+ for (uint32 i = 0; i < sChatChannelsStore.GetNumRows(); ++i)
+ {
+ ChatChannelsEntry const* entry = sChatChannelsStore.LookupEntry(i);
+ if (!entry)
+ continue;
+
+ if (strstr(entry->pattern[handler->GetSessionDbcLocale()], channelStr))
+ {
+ channelId = i;
+ break;
+ }
+ }
+
+ AreaTableEntry const* zoneEntry = nullptr;
+ for (uint32 i = 0; i < sAreaTableStore.GetNumRows(); ++i)
+ {
+ AreaTableEntry const* entry = sAreaTableStore.LookupEntry(i);
+ if (!entry)
+ continue;
+
+ if (strstr(entry->area_name[handler->GetSessionDbcLocale()], channelStr))
+ {
+ zoneEntry = entry;
+ break;
+ }
+ }
+
Player* player = handler->GetSession()->GetPlayer();
- Channel* channcel = NULL;
+ Channel* channel = nullptr;
if (ChannelMgr* cMgr = ChannelMgr::forTeam(player->GetTeam()))
- channcel = cMgr->GetChannel(channelStr, player);
+ channel = cMgr->GetChannel(channelId, channelStr, player, false, zoneEntry);
if (strcmp(argStr, "on") == 0)
{
- if (channcel)
- channcel->SetOwnership(true);
+ if (channel)
+ channel->SetOwnership(true);
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHANNEL_OWNERSHIP);
stmt->setUInt8 (0, 1);
stmt->setString(1, channelStr);
@@ -86,8 +115,8 @@ public:
}
else if (strcmp(argStr, "off") == 0)
{
- if (channcel)
- channcel->SetOwnership(false);
+ if (channel)
+ channel->SetOwnership(false);
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHANNEL_OWNERSHIP);
stmt->setUInt8 (0, 0);
stmt->setString(1, channelStr);
diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp
index 16217fbaea6..5487b9c7b2f 100644
--- a/src/server/scripts/Commands/cs_misc.cpp
+++ b/src/server/scripts/Commands/cs_misc.cpp
@@ -2268,19 +2268,20 @@ public:
// melee damage by specific school
if (!spellStr)
{
- uint32 absorb = 0;
- uint32 resist = 0;
+ Player* attacker = handler->GetSession()->GetPlayer();
+ DamageInfo dmgInfo(attacker, target, damage, nullptr, schoolmask, SPELL_DIRECT_DAMAGE, BASE_ATTACK);
+ attacker->CalcAbsorbResist(dmgInfo);
- handler->GetSession()->GetPlayer()->CalcAbsorbResist(target, schoolmask, SPELL_DIRECT_DAMAGE, damage, &absorb, &resist);
-
- if (damage <= absorb + resist)
+ if (!dmgInfo.GetDamage())
return true;
- damage -= absorb + resist;
+ damage = dmgInfo.GetDamage();
- handler->GetSession()->GetPlayer()->DealDamageMods(target, damage, &absorb);
- handler->GetSession()->GetPlayer()->DealDamage(target, damage, NULL, DIRECT_DAMAGE, schoolmask, NULL, false);
- handler->GetSession()->GetPlayer()->SendAttackStateUpdate (HITINFO_AFFECTS_VICTIM, target, 1, schoolmask, damage, absorb, resist, VICTIMSTATE_HIT, 0);
+ uint32 absorb = dmgInfo.GetAbsorb();
+ uint32 resist = dmgInfo.GetResist();
+ attacker->DealDamageMods(target, damage, &absorb);
+ attacker->DealDamage(target, damage, nullptr, DIRECT_DAMAGE, schoolmask, nullptr, false);
+ attacker->SendAttackStateUpdate(HITINFO_AFFECTS_VICTIM, target, 0, schoolmask, damage, absorb, resist, VICTIMSTATE_HIT, 0);
return true;
}
@@ -2288,10 +2289,22 @@ public:
// number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
uint32 spellid = handler->extractSpellIdFromLink((char*)args);
- if (!spellid || !sSpellMgr->GetSpellInfo(spellid))
+ if (!spellid)
+ return false;
+
+ SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellid);
+ if (!spellInfo)
return false;
- handler->GetSession()->GetPlayer()->SpellNonMeleeDamageLog(target, spellid, damage);
+ Player* attacker = handler->GetSession()->GetPlayer();
+ SpellNonMeleeDamage dmgInfo(attacker, target, spellid, spellInfo->GetSchoolMask());
+ damage = attacker->SpellDamageBonusDone(target, spellInfo, damage, SPELL_DIRECT_DAMAGE);
+ damage = target->SpellDamageBonusTaken(attacker, spellInfo, damage, SPELL_DIRECT_DAMAGE);
+
+ attacker->CalculateSpellDamageTaken(&dmgInfo, damage, spellInfo);
+ attacker->DealDamageMods(dmgInfo.target, dmgInfo.damage, &dmgInfo.absorb);
+ attacker->SendSpellNonMeleeDamageLog(&dmgInfo);
+ attacker->DealSpellDamage(&dmgInfo, true);
return true;
}
diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/blackrock_spire.h b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/blackrock_spire.h
index 446cc48d2f7..2c0f16c4ff2 100644
--- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/blackrock_spire.h
+++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/blackrock_spire.h
@@ -48,7 +48,8 @@ enum DataTypes
DATA_HALL_RUNE_4 = 19,
DATA_HALL_RUNE_5 = 20,
DATA_HALL_RUNE_6 = 21,
- DATA_HALL_RUNE_7 = 22
+ DATA_HALL_RUNE_7 = 22,
+ DATA_SCARSHIELD_INFILTRATOR = 23
};
enum CreaturesIds
@@ -71,7 +72,8 @@ enum CreaturesIds
NPC_BLACKHAND_SUMMONER = 9818,
NPC_BLACKHAND_VETERAN = 9819,
NPC_BLACKHAND_INCARCERATOR = 10316,
- NPC_LORD_VICTOR_NEFARIUS = 10162
+ NPC_LORD_VICTOR_NEFARIUS = 10162,
+ NPC_SCARSHIELD_INFILTRATOR = 10299
};
enum AdditionalData
diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/instance_blackrock_spire.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/instance_blackrock_spire.cpp
index bbe8fda37eb..89617a9f4ef 100644
--- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/instance_blackrock_spire.cpp
+++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/instance_blackrock_spire.cpp
@@ -109,6 +109,9 @@ public:
if (GetBossState(DATA_GYTH) == DONE)
creature->DisappearAndDie();
break;
+ case NPC_SCARSHIELD_INFILTRATOR:
+ ScarshieldInfiltrator = creature->GetGUID();
+ break;
}
}
@@ -318,6 +321,8 @@ public:
return TheBeast;
case DATA_GENERAL_DRAKKISATH:
return GeneralDrakkisath;
+ case DATA_SCARSHIELD_INFILTRATOR:
+ return ScarshieldInfiltrator;
case GO_EMBERSEER_IN:
return go_emberseerin;
case GO_DOORS:
@@ -496,6 +501,7 @@ public:
ObjectGuid LordVictorNefarius;
ObjectGuid TheBeast;
ObjectGuid GeneralDrakkisath;
+ ObjectGuid ScarshieldInfiltrator;
ObjectGuid go_emberseerin;
ObjectGuid go_doors;
ObjectGuid go_emberseerout;
@@ -565,9 +571,33 @@ public:
}
};
+class at_nearby_scarshield_infiltrator : public AreaTriggerScript
+{
+public:
+ at_nearby_scarshield_infiltrator() : AreaTriggerScript("at_nearby_scarshield_infiltrator") { }
+
+ bool OnTrigger(Player* player, const AreaTriggerEntry* /*at*/) override
+ {
+ if (player->IsAlive())
+ if (InstanceScript* instance = player->GetInstanceScript())
+ if (Creature* infiltrator = ObjectAccessor::GetCreature(*player, instance->GetGuidData(DATA_SCARSHIELD_INFILTRATOR)))
+ {
+ if (player->getLevel() >= 57)
+ infiltrator->AI()->SetData(1, 1);
+ else if (infiltrator->GetEntry() == NPC_SCARSHIELD_INFILTRATOR)
+ infiltrator->AI()->Talk(0, player);
+
+ return true;
+ }
+
+ return false;
+ }
+};
+
void AddSC_instance_blackrock_spire()
{
new instance_blackrock_spire();
new at_dragonspire_hall();
new at_blackrock_stadium();
+ new at_nearby_scarshield_infiltrator();
}
diff --git a/src/server/scripts/EasternKingdoms/ShadowfangKeep/shadowfang_keep.cpp b/src/server/scripts/EasternKingdoms/ShadowfangKeep/shadowfang_keep.cpp
index d0430ebb3e5..67bda699643 100644
--- a/src/server/scripts/EasternKingdoms/ShadowfangKeep/shadowfang_keep.cpp
+++ b/src/server/scripts/EasternKingdoms/ShadowfangKeep/shadowfang_keep.cpp
@@ -54,7 +54,6 @@ enum Yells
enum Spells
{
SPELL_UNLOCK = 6421,
-
SPELL_DARK_OFFERING = 7154
};
@@ -205,6 +204,123 @@ public:
};
+enum ArugalSpells
+{
+ SPELL_TELE_UPPER = 7587,
+ SPELL_TELE_SPAWN = 7586,
+ SPELL_TELE_STAIRS = 7136,
+ NUM_TELEPORT_SPELLS = 3,
+ SPELL_ARUGAL_CURSE = 7621,
+ SPELL_THUNDERSHOCK = 7803,
+ SPELL_VOIDBOLT = 7588
+};
+
+enum ArugalTexts
+{
+ SAY_AGGRO = 1, // You, too, shall serve!
+ SAY_TRANSFORM = 2, // Release your rage!
+ SAY_SLAY = 3 // Another falls!
+};
+
+enum ArugalEvents
+{
+ EVENT_VOID_BOLT = 1,
+ EVENT_TELEPORT,
+ EVENT_THUNDERSHOCK,
+ EVENT_CURSE
+};
+
+class boss_archmage_arugal : public CreatureScript
+{
+ public:
+ boss_archmage_arugal() : CreatureScript("boss_archmage_arugal") { }
+
+ struct boss_archmage_arugalAI : public BossAI
+ {
+ boss_archmage_arugalAI(Creature* creature) : BossAI(creature, BOSS_ARUGAL) { }
+
+ uint32 teleportSpells[NUM_TELEPORT_SPELLS] =
+ {
+ SPELL_TELE_SPAWN,
+ SPELL_TELE_UPPER,
+ SPELL_TELE_STAIRS
+ };
+
+ void KilledUnit(Unit* who) override
+ {
+ if (who->GetTypeId() == TYPEID_PLAYER)
+ Talk(SAY_SLAY);
+ }
+
+ void SpellHitTarget(Unit* /*target*/, SpellInfo const* spell) override
+ {
+ if (spell->Id == SPELL_ARUGAL_CURSE)
+ Talk(SAY_TRANSFORM);
+ }
+
+ void EnterCombat(Unit* /*who*/) override
+ {
+ _EnterCombat();
+ Talk(SAY_AGGRO);
+ events.ScheduleEvent(EVENT_CURSE, Seconds(7));
+ events.ScheduleEvent(EVENT_TELEPORT, Seconds(15));
+ events.ScheduleEvent(EVENT_VOID_BOLT, Seconds(1));
+ events.ScheduleEvent(EVENT_THUNDERSHOCK, Seconds(10));
+ }
+
+ void AttackStart(Unit* who) override
+ {
+ AttackStartCaster(who, 100.0f); // void bolt range is 100.f
+ }
+
+ void UpdateAI(uint32 diff) override
+ {
+ if (!UpdateVictim())
+ return;
+
+ events.Update(diff);
+
+ if (me->HasUnitState(UNIT_STATE_CASTING))
+ return;
+
+ while (uint32 eventId = events.ExecuteEvent())
+ {
+ switch (eventId)
+ {
+ case EVENT_CURSE:
+ if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1, 30.0f, true))
+ DoCast(target, SPELL_ARUGAL_CURSE);
+ events.Repeat(Seconds(15));
+ break;
+ case EVENT_TELEPORT:
+ {
+ // ensure we never cast the same teleport twice in a row
+ uint8 spellIndex = urand(1, NUM_TELEPORT_SPELLS-1);
+ std::swap(teleportSpells[0], teleportSpells[spellIndex]);
+ DoCast(teleportSpells[0]);
+ events.Repeat(Seconds(20));
+ break;
+ }
+ case EVENT_THUNDERSHOCK:
+ DoCastAOE(SPELL_THUNDERSHOCK);
+ events.Repeat(Seconds(30));
+ break;
+ case EVENT_VOID_BOLT:
+ DoCastVictim(SPELL_VOIDBOLT);
+ events.Repeat(Seconds(5));
+ break;
+ }
+ }
+ DoMeleeAttackIfReady();
+ }
+ };
+
+ CreatureAI* GetAI(Creature* creature) const override
+ {
+ return GetInstanceAI<boss_archmage_arugalAI>(creature);
+ }
+};
+
class spell_shadowfang_keep_haunting_spirits : public SpellScriptLoader
{
public:
@@ -248,5 +364,6 @@ void AddSC_shadowfang_keep()
{
new npc_shadowfang_prisoner();
new npc_arugal_voidwalker();
+ new boss_archmage_arugal();
new spell_shadowfang_keep_haunting_spirits();
}
diff --git a/src/server/scripts/EasternKingdoms/ShadowfangKeep/shadowfang_keep.h b/src/server/scripts/EasternKingdoms/ShadowfangKeep/shadowfang_keep.h
index 88edc3f1ee1..7e508191f69 100644
--- a/src/server/scripts/EasternKingdoms/ShadowfangKeep/shadowfang_keep.h
+++ b/src/server/scripts/EasternKingdoms/ShadowfangKeep/shadowfang_keep.h
@@ -26,8 +26,8 @@ enum DataTypes
TYPE_FREE_NPC = 1,
TYPE_RETHILGORE = 2,
TYPE_FENRUS = 3,
- TYPE_NANDOS = 4
+ TYPE_NANDOS = 4,
+ BOSS_ARUGAL = 5
};
#endif
-
diff --git a/src/server/scripts/EasternKingdoms/eastern_kingdoms_script_loader.cpp b/src/server/scripts/EasternKingdoms/eastern_kingdoms_script_loader.cpp
index adcb4f9fc9a..d9c929794cc 100644
--- a/src/server/scripts/EasternKingdoms/eastern_kingdoms_script_loader.cpp
+++ b/src/server/scripts/EasternKingdoms/eastern_kingdoms_script_loader.cpp
@@ -175,7 +175,7 @@ void AddSC_arathi_highlands();
void AddSC_blasted_lands();
void AddSC_burning_steppes();
void AddSC_duskwood();
-void AddSC_eastern_plaguelands();
+//void AddSC_eastern_plaguelands();
void AddSC_ghostlands();
void AddSC_hinterlands();
void AddSC_isle_of_queldanas();
@@ -352,7 +352,7 @@ void AddEasternKingdomsScripts()
AddSC_blasted_lands();
AddSC_burning_steppes();
AddSC_duskwood();
- AddSC_eastern_plaguelands();
+ //AddSC_eastern_plaguelands();
AddSC_ghostlands();
AddSC_hinterlands();
AddSC_isle_of_queldanas();
diff --git a/src/server/scripts/EasternKingdoms/zone_eastern_plaguelands.cpp b/src/server/scripts/EasternKingdoms/zone_eastern_plaguelands.cpp
deleted file mode 100644
index c35c8629cef..00000000000
--- a/src/server/scripts/EasternKingdoms/zone_eastern_plaguelands.cpp
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Copyright (C) 2008-2016 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
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/* ScriptData
-SDName: Eastern_Plaguelands
-SD%Complete: 100
-SDComment: Quest support: 5211. Special vendor Augustus the Touched
-SDCategory: Eastern Plaguelands
-EndScriptData */
-
-/* ContentData
-npc_ghoul_flayer
-npc_augustus_the_touched
-npc_darrowshire_spirit
-EndContentData */
-
-#include "ScriptMgr.h"
-#include "ScriptedCreature.h"
-#include "ScriptedGossip.h"
-#include "Player.h"
-#include "WorldSession.h"
-
-class npc_ghoul_flayer : public CreatureScript
-{
-public:
- npc_ghoul_flayer() : CreatureScript("npc_ghoul_flayer") { }
-
- struct npc_ghoul_flayerAI : public ScriptedAI
- {
- npc_ghoul_flayerAI(Creature* creature) : ScriptedAI(creature) { }
-
- void Reset() override { }
-
- void EnterCombat(Unit* /*who*/) override { }
-
- void JustDied(Unit* killer) override
- {
- if (killer->GetTypeId() == TYPEID_PLAYER)
- me->SummonCreature(11064, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_DESPAWN, 60000);
- }
- };
-
- CreatureAI* GetAI(Creature* creature) const override
- {
- return new npc_ghoul_flayerAI(creature);
- }
-};
-
-/*######
-## npc_augustus_the_touched
-######*/
-
-class npc_augustus_the_touched : public CreatureScript
-{
-public:
- npc_augustus_the_touched() : CreatureScript("npc_augustus_the_touched") { }
-
- bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action) override
- {
- ClearGossipMenuFor(player);
- 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(6164))
- AddGossipItemFor(player, GOSSIP_ICON_VENDOR, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE);
-
- SendGossipMenuFor(player, player->GetGossipTextId(creature), creature->GetGUID());
- return true;
- }
-};
-
-/*######
-## npc_darrowshire_spirit
-######*/
-
-enum DarrowshireSpirit
-{
- SPELL_SPIRIT_SPAWNIN = 17321
-};
-
-class npc_darrowshire_spirit : public CreatureScript
-{
-public:
- npc_darrowshire_spirit() : CreatureScript("npc_darrowshire_spirit") { }
-
- bool OnGossipHello(Player* player, Creature* creature) override
- {
- SendGossipMenuFor(player, 3873, creature->GetGUID());
- player->TalkedToCreature(creature->GetEntry(), creature->GetGUID());
- creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
- return true;
- }
-
- CreatureAI* GetAI(Creature* creature) const override
- {
- return new npc_darrowshire_spiritAI(creature);
- }
-
- struct npc_darrowshire_spiritAI : public ScriptedAI
- {
- npc_darrowshire_spiritAI(Creature* creature) : ScriptedAI(creature) { }
-
- void Reset() override
- {
- DoCast(me, SPELL_SPIRIT_SPAWNIN);
- me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
- }
-
- void EnterCombat(Unit* /*who*/) override { }
- };
-};
-
-void AddSC_eastern_plaguelands()
-{
- new npc_ghoul_flayer();
- new npc_augustus_the_touched();
- new npc_darrowshire_spirit();
-}
diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_anetheron.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_anetheron.cpp
index 5d41908435e..722b7768617 100644
--- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_anetheron.cpp
+++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_anetheron.cpp
@@ -279,7 +279,7 @@ class spell_anetheron_vampiric_aura : public SpellScriptLoader
return true;
}
- void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
+ void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
DamageInfo* damageInfo = eventInfo.GetDamageInfo();
@@ -287,7 +287,7 @@ class spell_anetheron_vampiric_aura : public SpellScriptLoader
return;
int32 bp = damageInfo->GetDamage() * 3;
- eventInfo.GetActor()->CastCustomSpell(SPELL_VAMPIRIC_AURA_HEAL, SPELLVALUE_BASE_POINT0, bp, eventInfo.GetActor(), true);
+ eventInfo.GetActor()->CastCustomSpell(SPELL_VAMPIRIC_AURA_HEAL, SPELLVALUE_BASE_POINT0, bp, eventInfo.GetActor(), true, nullptr, aurEff);
}
void Register() override
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 137da1002af..34a456ae502 100644
--- a/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/the_black_morass.cpp
+++ b/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/the_black_morass.cpp
@@ -16,19 +16,6 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/*
-Name: The_Black_Morass
-%Complete: 30
-Comment: Misc NPC's and mobs for instance. Most here far from complete.
-Category: Caverns of Time, The Black Morass
-*/
-
-/* ContentData
-npc_medivh_bm
-npc_time_rift
-npc_saat
-EndContentData */
-
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "ScriptedGossip.h"
@@ -365,57 +352,8 @@ public:
};
-enum Saat
-{
- SPELL_CHRONO_BEACON = 34975,
- ITEM_CHRONO_BEACON = 24289
-};
-
-#define GOSSIP_ITEM_OBTAIN "[PH] Obtain Chrono-Beacon"
-
-class npc_saat : public CreatureScript
-{
-public:
- npc_saat() : CreatureScript("npc_saat") { }
-
- bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action) override
- {
- ClearGossipMenuFor(player);
- if (action == GOSSIP_ACTION_INFO_DEF+1)
- {
- CloseGossipMenuFor(player);
- creature->CastSpell(player, SPELL_CHRONO_BEACON, false);
- }
- return true;
- }
-
- bool OnGossipHello(Player* player, Creature* creature) override
- {
- if (creature->IsQuestGiver())
- player->PrepareQuestMenu(creature->GetGUID());
-
- if (player->GetQuestStatus(QUEST_OPENING_PORTAL) == QUEST_STATUS_INCOMPLETE && !player->HasItemCount(ITEM_CHRONO_BEACON))
- {
- AddGossipItemFor(player, GOSSIP_ICON_CHAT, GOSSIP_ITEM_OBTAIN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
- SendGossipMenuFor(player, 10000, creature->GetGUID());
- return true;
- }
- else if (player->GetQuestRewardStatus(QUEST_OPENING_PORTAL) && !player->HasItemCount(ITEM_CHRONO_BEACON))
- {
- AddGossipItemFor(player, GOSSIP_ICON_CHAT, GOSSIP_ITEM_OBTAIN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
- SendGossipMenuFor(player, 10001, creature->GetGUID());
- return true;
- }
-
- SendGossipMenuFor(player, 10002, creature->GetGUID());
- return true;
- }
-
-};
-
void AddSC_the_black_morass()
{
new npc_medivh_bm();
new npc_time_rift();
- new npc_saat();
}
diff --git a/src/server/scripts/Kalimdor/zone_stonetalon_mountains.cpp b/src/server/scripts/Kalimdor/zone_stonetalon_mountains.cpp
index b7f88200077..7a7c104bdba 100644
--- a/src/server/scripts/Kalimdor/zone_stonetalon_mountains.cpp
+++ b/src/server/scripts/Kalimdor/zone_stonetalon_mountains.cpp
@@ -16,18 +16,6 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/* ScriptData
-SDName: Stonetalon_Mountains
-SD%Complete: 95
-SDComment: Quest support: 6627, 6523
-SDCategory: Stonetalon Mountains
-EndScriptData */
-
-/* ContentData
-npc_braug_dimspirit
-npc_kaya_flathoof
-EndContentData */
-
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "ScriptedGossip.h"
@@ -35,61 +23,6 @@ EndContentData */
#include "Player.h"
/*######
-## npc_braug_dimspirit
-######*/
-
-#define GOSSIP_HBD1 "Ysera"
-#define GOSSIP_HBD2 "Neltharion"
-#define GOSSIP_HBD3 "Nozdormu"
-#define GOSSIP_HBD4 "Alexstrasza"
-#define GOSSIP_HBD5 "Malygos"
-
-class npc_braug_dimspirit : public CreatureScript
-{
-public:
- npc_braug_dimspirit() : CreatureScript("npc_braug_dimspirit") { }
-
- bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action) override
- {
- ClearGossipMenuFor(player);
- if (action == GOSSIP_ACTION_INFO_DEF+1)
- {
- CloseGossipMenuFor(player);
- creature->CastSpell(player, 6766, false);
-
- }
- if (action == GOSSIP_ACTION_INFO_DEF+2)
- {
- CloseGossipMenuFor(player);
- player->AreaExploredOrEventHappens(6627);
- }
- return true;
- }
-
- bool OnGossipHello(Player* player, Creature* creature) override
- {
- if (creature->IsQuestGiver())
- player->PrepareQuestMenu(creature->GetGUID());
-
- if (player->GetQuestStatus(6627) == QUEST_STATUS_INCOMPLETE)
- {
- AddGossipItemFor(player, GOSSIP_ICON_CHAT, GOSSIP_HBD1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
- AddGossipItemFor(player, GOSSIP_ICON_CHAT, GOSSIP_HBD2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2);
- AddGossipItemFor(player, GOSSIP_ICON_CHAT, GOSSIP_HBD3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
- AddGossipItemFor(player, GOSSIP_ICON_CHAT, GOSSIP_HBD4, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
- AddGossipItemFor(player, GOSSIP_ICON_CHAT, GOSSIP_HBD5, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
-
- SendGossipMenuFor(player, 5820, creature->GetGUID());
- }
- else
- SendGossipMenuFor(player, 5819, creature->GetGUID());
-
- return true;
- }
-
-};
-
-/*######
## npc_kaya_flathoof
######*/
@@ -174,6 +107,5 @@ public:
void AddSC_stonetalon_mountains()
{
- new npc_braug_dimspirit();
new npc_kaya_flathoof();
}
diff --git a/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/azjol_nerub.h b/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/azjol_nerub.h
index 685d0f51edd..2eda9509bb8 100644
--- a/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/azjol_nerub.h
+++ b/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/azjol_nerub.h
@@ -33,7 +33,8 @@ enum DataTypes
DATA_WATCHER_NARJIL,
DATA_WATCHER_GASHRA,
DATA_WATCHER_SILTHIK,
- DATA_ANUBARAK_WALL
+ DATA_ANUBARAK_WALL,
+ DATA_ANUBARAK_WALL_2
};
enum CreatureIds
diff --git a/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_anubarak.cpp b/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_anubarak.cpp
index 06a91d58705..2860698a8b2 100644
--- a/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_anubarak.cpp
+++ b/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_anubarak.cpp
@@ -121,12 +121,16 @@ public:
_petCount = 0;
}
+ bool CanAIAttack(Unit const* /*who*/) const override { return true; } // do not check boundary here
+
void EnterCombat(Unit* who) override
{
BossAI::EnterCombat(who);
if (GameObject* door = instance->GetGameObject(DATA_ANUBARAK_WALL))
door->SetGoState(GO_STATE_ACTIVE); // open door for now
+ if (GameObject* door2 = instance->GetGameObject(DATA_ANUBARAK_WALL_2))
+ door2->SetGoState(GO_STATE_ACTIVE);
Talk(SAY_AGGRO);
instance->DoStartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_GOTTA_GO_START_EVENT);
@@ -179,6 +183,8 @@ public:
case EVENT_CLOSE_DOOR:
if (GameObject* door = instance->GetGameObject(DATA_ANUBARAK_WALL))
door->SetGoState(GO_STATE_READY);
+ if (GameObject* door2 = instance->GetGameObject(DATA_ANUBARAK_WALL_2))
+ door2->SetGoState(GO_STATE_READY);
break;
case EVENT_POUND:
DoCastVictim(SPELL_POUND);
diff --git a/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_hadronox.cpp b/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_hadronox.cpp
index 7338774c21e..c41ec1c488d 100644
--- a/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_hadronox.cpp
+++ b/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_hadronox.cpp
@@ -789,7 +789,7 @@ struct npc_hadronox_foeAI : public ScriptedAI
me->GetMotionMaster()->MovePoint(MOVE_HADRONOX, hadronoxStep[2]);
break;
}
- me->GetMotionMaster()->MoveChase(hadronox);
+ AttackStart(hadronox);
}
break;
}
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 a86b02a2d6c..0d52a09bbdc 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
@@ -138,10 +138,10 @@ class boss_krik_thir : public CreatureScript
for (uint8 i = 1; i <= 3; ++i)
{
- std::list<TempSummon*> summons;
- me->SummonCreatureGroup(i, &summons);
- for (TempSummon* summon : summons)
- summon->AI()->SetData(DATA_PET_GROUP, i);
+ std::list<TempSummon*> adds;
+ me->SummonCreatureGroup(i, &adds);
+ for (TempSummon* add : adds)
+ add->AI()->SetData(DATA_PET_GROUP, i);
}
}
@@ -416,11 +416,7 @@ class npc_watcher_gashra : public CreatureScript
struct npc_watcher_gashraAI : public npc_gatewatcher_petAI
{
- npc_watcher_gashraAI(Creature* creature) : npc_gatewatcher_petAI(creature, true)
- {
- _instance = creature->GetInstanceScript();
- me->SetReactState(REACT_PASSIVE);
- }
+ npc_watcher_gashraAI(Creature* creature) : npc_gatewatcher_petAI(creature, true) { }
void Reset() override
{
@@ -481,7 +477,6 @@ class npc_watcher_gashra : public CreatureScript
private:
EventMap _events;
- InstanceScript* _instance;
};
CreatureAI* GetAI(Creature* creature) const override
@@ -499,7 +494,6 @@ class npc_watcher_narjil : public CreatureScript
{
npc_watcher_narjilAI(Creature* creature) : npc_gatewatcher_petAI(creature, true)
{
- _instance = creature->GetInstanceScript();
}
void Reset() override
@@ -561,7 +555,6 @@ class npc_watcher_narjil : public CreatureScript
private:
EventMap _events;
- InstanceScript* _instance;
};
CreatureAI* GetAI(Creature* creature) const override
@@ -579,7 +572,6 @@ class npc_watcher_silthik : public CreatureScript
{
npc_watcher_silthikAI(Creature* creature) : npc_gatewatcher_petAI(creature, true)
{
- _instance = creature->GetInstanceScript();
}
void Reset() override
@@ -641,7 +633,6 @@ class npc_watcher_silthik : public CreatureScript
private:
EventMap _events;
- InstanceScript* _instance;
};
CreatureAI* GetAI(Creature* creature) const override
@@ -934,11 +925,15 @@ class spell_gatewatcher_subboss_trigger : public SpellScriptLoader
void HandleTargets(std::list<WorldObject*>& targetList)
{
// Remove any Watchers that are already in combat
- for (std::list<WorldObject*>::iterator it = targetList.begin(); it != targetList.end(); ++it)
+ auto it = targetList.begin();
+ while (it != targetList.end())
{
if (Creature* creature = (*it)->ToCreature())
if (creature->IsAlive() && !creature->IsInCombat())
+ {
+ ++it;
continue;
+ }
it = targetList.erase(it);
}
diff --git a/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/instance_azjol_nerub.cpp b/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/instance_azjol_nerub.cpp
index 8af4f6cecc4..7f0ce5c369e 100644
--- a/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/instance_azjol_nerub.cpp
+++ b/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/instance_azjol_nerub.cpp
@@ -41,7 +41,8 @@ ObjectData const creatureData[] =
ObjectData const gameobjectData[] =
{
- { GO_ANUBARAK_DOOR_3, DATA_ANUBARAK_WALL },
+ { GO_ANUBARAK_DOOR_1, DATA_ANUBARAK_WALL },
+ { GO_ANUBARAK_DOOR_3, DATA_ANUBARAK_WALL_2 },
{ 0, 0 } // END
};
@@ -77,6 +78,17 @@ class instance_azjol_nerub : public InstanceMapScript
if (Creature* gatewatcher = GetCreature(DATA_KRIKTHIR))
gatewatcher->AI()->DoAction(-ACTION_GATEWATCHER_GREET);
}
+
+ bool CheckRequiredBosses(uint32 bossId, Player const* player) const override
+ {
+ if (_SkipCheckRequiredBosses(player))
+ return true;
+
+ if (bossId > DATA_KRIKTHIR && GetBossState(DATA_KRIKTHIR) != DONE)
+ return false;
+
+ return true;
+ }
};
InstanceScript* GetInstanceScript(InstanceMap* map) const override
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 1041d250cc7..976ef3e34db 100644
--- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_northrend_beasts.cpp
+++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_northrend_beasts.cpp
@@ -16,9 +16,6 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Known bugs:
-// Gormok - Snobolled (creature at back)
-
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "trial_of_the_crusader.h"
@@ -71,14 +68,16 @@ enum BossSpells
//Gormok
SPELL_IMPALE = 66331,
SPELL_STAGGERING_STOMP = 67648,
- SPELL_RISING_ANGER = 66636,
//Snobold
+ SPELL_RISING_ANGER = 66636,
SPELL_SNOBOLLED = 66406,
SPELL_BATTER = 66408,
SPELL_FIRE_BOMB = 66313,
SPELL_FIRE_BOMB_1 = 66317,
SPELL_FIRE_BOMB_DOT = 66318,
SPELL_HEAD_CRACK = 66407,
+ SPELL_JUMP_TO_HAND = 66342,
+ SPELL_RIDE_PLAYER = 66245,
//Acidmaw & Dreadscale Generic
SPELL_SWEEP = 66794,
@@ -117,38 +116,41 @@ enum BossSpells
enum MyActions
{
ACTION_ENABLE_FIRE_BOMB = 1,
- ACTION_DISABLE_FIRE_BOMB = 2
+ ACTION_DISABLE_FIRE_BOMB = 2,
+ ACTION_ACTIVE_SNOBOLD = 3
};
enum Events
{
// Gormok
EVENT_IMPALE = 1,
- EVENT_STAGGERING_STOMP = 2,
- EVENT_THROW = 3,
+ EVENT_STAGGERING_STOMP,
+ EVENT_THROW,
// Snobold
- EVENT_FIRE_BOMB = 4,
- EVENT_BATTER = 5,
- EVENT_HEAD_CRACK = 6,
+ EVENT_FIRE_BOMB,
+ EVENT_BATTER,
+ EVENT_HEAD_CRACK,
+ EVENT_SNOBOLLED,
+ EVENT_CHECK_MOUNT,
// Acidmaw & Dreadscale
- EVENT_BITE = 7,
- EVENT_SPEW = 8,
- EVENT_SLIME_POOL = 9,
- EVENT_SPIT = 10,
- EVENT_SPRAY = 11,
- EVENT_SWEEP = 12,
- EVENT_SUBMERGE = 13,
- EVENT_EMERGE = 14,
- EVENT_SUMMON_ACIDMAW = 15,
+ EVENT_BITE,
+ EVENT_SPEW,
+ EVENT_SLIME_POOL,
+ EVENT_SPIT,
+ EVENT_SPRAY,
+ EVENT_SWEEP,
+ EVENT_SUBMERGE,
+ EVENT_EMERGE,
+ EVENT_SUMMON_ACIDMAW,
// Icehowl
- EVENT_FEROCIOUS_BUTT = 16,
- EVENT_MASSIVE_CRASH = 17,
- EVENT_WHIRL = 18,
- EVENT_ARCTIC_BREATH = 19,
- EVENT_TRAMPLE = 20
+ EVENT_FEROCIOUS_BUTT,
+ EVENT_MASSIVE_CRASH,
+ EVENT_WHIRL,
+ EVENT_ARCTIC_BREATH,
+ EVENT_TRAMPLE
};
enum Phases
@@ -158,6 +160,13 @@ enum Phases
PHASE_SUBMERGED = 3
};
+enum GormokMisc
+{
+ DATA_NEW_TARGET = 1,
+ GORMOK_HAND_SEAT = 4,
+ PLAYER_VEHICLE_ID = 444,
+};
+
class boss_gormok : public CreatureScript
{
public:
@@ -169,9 +178,9 @@ class boss_gormok : public CreatureScript
void Reset() override
{
- events.ScheduleEvent(EVENT_IMPALE, urand(8*IN_MILLISECONDS, 10*IN_MILLISECONDS));
- events.ScheduleEvent(EVENT_STAGGERING_STOMP, 15*IN_MILLISECONDS);
- events.ScheduleEvent(EVENT_THROW, urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS));
+ events.ScheduleEvent(EVENT_IMPALE, Seconds(8), Seconds(10));
+ events.ScheduleEvent(EVENT_STAGGERING_STOMP, Seconds(15));
+ events.ScheduleEvent(EVENT_THROW, Seconds(15), Seconds(30));
summons.DespawnAll();
}
@@ -216,18 +225,7 @@ class boss_gormok : public CreatureScript
void EnterCombat(Unit* /*who*/) override
{
_EnterCombat();
- me->SetInCombatWithZone();
instance->SetData(TYPE_NORTHREND_BEASTS, GORMOK_IN_PROGRESS);
-
- for (uint8 i = 0; i < MAX_SNOBOLDS; i++)
- {
- if (Creature* pSnobold = DoSpawnCreature(NPC_SNOBOLD_VASSAL, 0, 0, 0, 0, TEMPSUMMON_CORPSE_DESPAWN, 0))
- {
- pSnobold->EnterVehicle(me, i);
- pSnobold->SetInCombatWithZone();
- pSnobold->AI()->DoAction(ACTION_ENABLE_FIRE_BOMB);
- }
- }
}
void DamageTaken(Unit* /*who*/, uint32& damage) override
@@ -235,8 +233,14 @@ class boss_gormok : public CreatureScript
// despawn the remaining passengers on death
if (damage >= me->GetHealth())
for (uint8 i = 0; i < MAX_SNOBOLDS; ++i)
- if (Unit* pSnobold = me->GetVehicleKit()->GetPassenger(i))
- pSnobold->ToCreature()->DespawnOrUnsummon();
+ if (Unit* snobold = me->GetVehicleKit()->GetPassenger(i))
+ snobold->ToCreature()->DespawnOrUnsummon();
+ }
+
+ void PassengerBoarded(Unit* who, int8 seatId, bool apply) override
+ {
+ if (apply && seatId == GORMOK_HAND_SEAT)
+ who->CastSpell(me, SPELL_RISING_ANGER, true);
}
void UpdateAI(uint32 diff) override
@@ -255,30 +259,28 @@ class boss_gormok : public CreatureScript
{
case EVENT_IMPALE:
DoCastVictim(SPELL_IMPALE);
- events.ScheduleEvent(EVENT_IMPALE, urand(8*IN_MILLISECONDS, 10*IN_MILLISECONDS));
- return;
+ events.Repeat(Seconds(8), Seconds(10));
+ break;
case EVENT_STAGGERING_STOMP:
DoCastVictim(SPELL_STAGGERING_STOMP);
- events.ScheduleEvent(EVENT_STAGGERING_STOMP, 15*IN_MILLISECONDS);
- return;
+ events.Repeat(Seconds(15));
+ break;
case EVENT_THROW:
for (uint8 i = 0; i < MAX_SNOBOLDS; ++i)
{
- if (Unit* pSnobold = me->GetVehicleKit()->GetPassenger(i))
+ if (Unit* snobold = me->GetVehicleKit()->GetPassenger(i))
{
- pSnobold->ExitVehicle();
- pSnobold->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE);
- pSnobold->ToCreature()->SetReactState(REACT_AGGRESSIVE);
- pSnobold->ToCreature()->AI()->DoAction(ACTION_DISABLE_FIRE_BOMB);
- pSnobold->CastSpell(me, SPELL_RISING_ANGER, true);
- Talk(EMOTE_SNOBOLLED);
+ snobold->ExitVehicle();
+ snobold->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE);
+ snobold->GetAI()->DoAction(ACTION_DISABLE_FIRE_BOMB);
+ snobold->CastSpell(me, SPELL_JUMP_TO_HAND, true);
break;
}
}
- events.ScheduleEvent(EVENT_THROW, urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS));
- return;
+ events.Repeat(Seconds(15), Seconds(30));
+ break;
default:
- return;
+ break;
}
}
@@ -292,6 +294,23 @@ class boss_gormok : public CreatureScript
}
};
+class SnobolledTargetSelector : public std::unary_function<Unit*, bool>
+{
+public:
+ SnobolledTargetSelector(Unit const* /*unit*/) { }
+
+ bool operator()(Unit* unit) const
+ {
+ if (unit->GetTypeId() != TYPEID_PLAYER)
+ return false;
+
+ if (unit->HasAura(SPELL_RIDE_PLAYER) || unit->HasAura(SPELL_SNOBOLLED))
+ return false;
+
+ return true;
+ }
+};
+
class npc_snobold_vassal : public CreatureScript
{
public:
@@ -299,59 +318,24 @@ class npc_snobold_vassal : public CreatureScript
struct npc_snobold_vassalAI : public ScriptedAI
{
- npc_snobold_vassalAI(Creature* creature) : ScriptedAI(creature)
+ npc_snobold_vassalAI(Creature* creature) : ScriptedAI(creature), _instance(creature->GetInstanceScript()), _isActive(false)
{
- _targetDied = false;
- _instance = creature->GetInstanceScript();
_instance->SetData(DATA_SNOBOLD_COUNT, INCREASE);
+ SetCombatMovement(false);
}
void Reset() override
{
- _events.ScheduleEvent(EVENT_BATTER, 5*IN_MILLISECONDS);
- _events.ScheduleEvent(EVENT_HEAD_CRACK, 25*IN_MILLISECONDS);
-
- _targetGUID.Clear();
- _targetDied = false;
-
- //Workaround for Snobold
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE);
- }
-
- void EnterCombat(Unit* who) override
- {
- _targetGUID = who->GetGUID();
- me->TauntApply(who);
- DoCast(who, SPELL_SNOBOLLED);
- }
-
- void DamageTaken(Unit* pDoneBy, uint32 &uiDamage) override
- {
- if (pDoneBy->GetGUID() == _targetGUID)
- uiDamage = 0;
- }
-
- void MovementInform(uint32 type, uint32 pointId) override
- {
- if (type != POINT_MOTION_TYPE)
- return;
-
- switch (pointId)
- {
- case 0:
- if (_targetDied)
- me->DespawnOrUnsummon();
- break;
- default:
- break;
- }
+ me->SetInCombatWithZone();
+ _events.ScheduleEvent(EVENT_CHECK_MOUNT, Seconds(1));
+ _events.ScheduleEvent(EVENT_FIRE_BOMB, Seconds(5), Seconds(30));
}
void JustDied(Unit* /*killer*/) override
{
if (Unit* target = ObjectAccessor::GetPlayer(*me, _targetGUID))
- if (target->IsAlive())
- target->RemoveAurasDueToSpell(SPELL_SNOBOLLED);
+ target->RemoveAurasDueToSpell(SPELL_SNOBOLLED);
_instance->SetData(DATA_SNOBOLD_COUNT, DECREASE);
}
@@ -360,50 +344,69 @@ class npc_snobold_vassal : public CreatureScript
switch (action)
{
case ACTION_ENABLE_FIRE_BOMB:
- _events.ScheduleEvent(EVENT_FIRE_BOMB, urand(5*IN_MILLISECONDS, 30*IN_MILLISECONDS));
+ _events.ScheduleEvent(EVENT_FIRE_BOMB, Seconds(5), Seconds(30));
break;
case ACTION_DISABLE_FIRE_BOMB:
_events.CancelEvent(EVENT_FIRE_BOMB);
break;
+ case ACTION_ACTIVE_SNOBOLD:
+ _isActive = true;
+ break;
default:
break;
}
}
- void UpdateAI(uint32 diff) override
+ void SetGUID(ObjectGuid guid, int32 id) override
{
- if (!UpdateVictim() || _targetDied)
+ if (id == DATA_NEW_TARGET)
+ if (Unit* target = ObjectAccessor::GetPlayer(*me, guid))
+ {
+ _targetGUID = guid;
+ AttackStart(target);
+ _events.ScheduleEvent(EVENT_BATTER, Seconds(5));
+ _events.ScheduleEvent(EVENT_HEAD_CRACK, Seconds(25));
+ _events.ScheduleEvent(EVENT_SNOBOLLED, Milliseconds(500));
+ }
+ }
+
+ void AttackStart(Unit* who) override
+ {
+ //Snobold only melee attack players that is your vehicle
+ if (!_isActive || who->GetGUID() != _targetGUID)
return;
- if (Unit* target = ObjectAccessor::GetPlayer(*me, _targetGUID))
+ ScriptedAI::AttackStart(who);
+ }
+
+ void MountOnBoss()
+ {
+ Unit* gormok = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(NPC_GORMOK));
+ if (gormok && gormok->IsAlive())
{
- if (!target->IsAlive())
- {
- Unit* gormok = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(NPC_GORMOK));
- if (gormok && gormok->IsAlive())
- {
- SetCombatMovement(false);
- _targetDied = true;
+ me->AttackStop();
+ _targetGUID.Clear();
+ _isActive = false;
+ _events.CancelEvent(EVENT_BATTER);
+ _events.CancelEvent(EVENT_HEAD_CRACK);
- // looping through Gormoks seats
- for (uint8 i = 0; i < MAX_SNOBOLDS; i++)
- {
- if (!gormok->GetVehicleKit()->GetPassenger(i))
- {
- me->EnterVehicle(gormok, i);
- DoAction(ACTION_ENABLE_FIRE_BOMB);
- break;
- }
- }
- }
- else if (Unit* target2 = SelectTarget(SELECT_TARGET_RANDOM, 0, 0.0f, true))
+ for (uint8 i = 0; i < MAX_SNOBOLDS; i++)
+ {
+ if (!gormok->GetVehicleKit()->GetPassenger(i))
{
- _targetGUID = target2->GetGUID();
- me->GetMotionMaster()->MoveJump(*target2, 15.0f, 15.0f);
+ me->EnterVehicle(gormok, i);
+ DoAction(ACTION_ENABLE_FIRE_BOMB);
+ break;
}
}
}
+ //Without Boss, snobolds should jump in another players
+ else if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, SnobolledTargetSelector(me)))
+ me->CastSpell(target, SPELL_RIDE_PLAYER, true);
+ }
+ void UpdateAI(uint32 diff) override
+ {
_events.Update(diff);
if (me->HasUnitState(UNIT_STATE_CASTING))
@@ -416,35 +419,46 @@ class npc_snobold_vassal : public CreatureScript
case EVENT_FIRE_BOMB:
if (me->GetVehicleBase())
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, -me->GetVehicleBase()->GetCombatReach(), true))
- me->CastSpell(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), SPELL_FIRE_BOMB, true);
- _events.ScheduleEvent(EVENT_FIRE_BOMB, 20*IN_MILLISECONDS);
- return;
+ me->CastSpell(target, SPELL_FIRE_BOMB);
+ _events.Repeat(Seconds(20));
+ break;
case EVENT_HEAD_CRACK:
- // commented out while SPELL_SNOBOLLED gets fixed
- //if (Unit* target = ObjectAccessor::GetPlayer(*me, m_uiTargetGUID))
- DoCastVictim(SPELL_HEAD_CRACK);
- _events.ScheduleEvent(EVENT_HEAD_CRACK, 30*IN_MILLISECONDS);
- return;
+ DoCast(me->GetVehicleBase(), SPELL_HEAD_CRACK);
+ _events.Repeat(Seconds(30));
+ break;
case EVENT_BATTER:
- // commented out while SPELL_SNOBOLLED gets fixed
- //if (Unit* target = ObjectAccessor::GetPlayer(*me, m_uiTargetGUID))
- DoCastVictim(SPELL_BATTER);
- _events.ScheduleEvent(EVENT_BATTER, 10*IN_MILLISECONDS);
- return;
+ DoCast(me->GetVehicleBase(), SPELL_BATTER);
+ _events.Repeat(Seconds(10));
+ break;
+ case EVENT_SNOBOLLED:
+ DoCastAOE(SPELL_SNOBOLLED);
+ break;
+ case EVENT_CHECK_MOUNT:
+ if (!me->GetVehicleBase())
+ MountOnBoss();
+ _events.Repeat(Seconds(1));
+ break;
default:
- return;
+ break;
}
+
+ if (me->HasUnitState(UNIT_STATE_CASTING))
+ return;
}
- // do melee attack only when not on Gormoks back
- if (!me->GetVehicleBase())
+ if (!UpdateVictim())
+ return;
+
+ // do melee attack only if is in player back.
+ if (_isActive)
DoMeleeAttackIfReady();
}
+
private:
EventMap _events;
InstanceScript* _instance;
ObjectGuid _targetGUID;
- bool _targetDied;
+ bool _isActive;
};
CreatureAI* GetAI(Creature* creature) const override
@@ -1145,6 +1159,138 @@ class boss_icehowl : public CreatureScript
}
};
+class spell_gormok_jump_to_hand : public SpellScriptLoader
+{
+public:
+ spell_gormok_jump_to_hand() : SpellScriptLoader("spell_gormok_jump_to_hand") { }
+
+ class spell_gormok_jump_to_hand_AuraScript : public AuraScript
+ {
+ PrepareAuraScript(spell_gormok_jump_to_hand_AuraScript);
+
+ bool Validate(SpellInfo const* /*spell*/) override
+ {
+ if (!sSpellMgr->GetSpellInfo(SPELL_RIDE_PLAYER))
+ return false;
+ return true;
+ }
+
+ bool Load() override
+ {
+ if (GetCaster() && GetCaster()->GetEntry() == NPC_SNOBOLD_VASSAL)
+ return true;
+ return false;
+ }
+
+ void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
+ {
+ if (Unit* caster = GetCaster())
+ {
+ if (CreatureAI* gormokAI = GetTarget()->ToCreature()->AI())
+ {
+ if (Unit* target = gormokAI->SelectTarget(SELECT_TARGET_RANDOM, 0, SnobolledTargetSelector(GetTarget())))
+ {
+ gormokAI->Talk(EMOTE_SNOBOLLED);
+ caster->GetAI()->DoAction(ACTION_ACTIVE_SNOBOLD);
+ caster->CastSpell(target, SPELL_RIDE_PLAYER, true);
+ }
+ }
+ }
+ }
+
+ void Register() override
+ {
+ AfterEffectRemove += AuraEffectRemoveFn(spell_gormok_jump_to_hand_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_CONTROL_VEHICLE, AURA_EFFECT_HANDLE_REAL);
+ }
+ };
+
+ AuraScript* GetAuraScript() const override
+ {
+ return new spell_gormok_jump_to_hand_AuraScript();
+ }
+};
+
+class spell_gormok_ride_player : public SpellScriptLoader
+{
+public:
+ spell_gormok_ride_player() : SpellScriptLoader("spell_gormok_ride_player") { }
+
+ class spell_gormok_ride_player_AuraScript : public AuraScript
+ {
+ PrepareAuraScript(spell_gormok_ride_player_AuraScript);
+
+ bool Load() override
+ {
+ if (GetCaster() && GetCaster()->GetEntry() == NPC_SNOBOLD_VASSAL)
+ return true;
+ return false;
+ }
+
+ void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
+ {
+ Unit* target = GetTarget();
+ if (target->GetTypeId() != TYPEID_PLAYER || !target->IsInWorld())
+ return;
+
+ if (!target->CreateVehicleKit(PLAYER_VEHICLE_ID, 0))
+ return;
+
+ if (Unit *caster = GetCaster())
+ caster->GetAI()->SetGUID(target->GetGUID(), DATA_NEW_TARGET);
+ }
+
+ void AfterRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
+ {
+ GetTarget()->RemoveVehicleKit();
+ }
+
+ void Register() override
+ {
+ OnEffectApply += AuraEffectApplyFn(spell_gormok_ride_player_AuraScript::OnApply, EFFECT_0, SPELL_AURA_CONTROL_VEHICLE, AURA_EFFECT_HANDLE_REAL);
+ AfterEffectRemove += AuraEffectRemoveFn(spell_gormok_ride_player_AuraScript::AfterRemove, EFFECT_0, SPELL_AURA_CONTROL_VEHICLE, AURA_EFFECT_HANDLE_REAL);
+ }
+ };
+
+ AuraScript* GetAuraScript() const override
+ {
+ return new spell_gormok_ride_player_AuraScript();
+ }
+};
+
+class spell_gormok_snobolled : public SpellScriptLoader
+{
+public:
+ spell_gormok_snobolled() : SpellScriptLoader("spell_gormok_snobolled") { }
+
+ class spell_gormok_snobolled_AuraScript : public AuraScript
+ {
+ PrepareAuraScript(spell_gormok_snobolled_AuraScript);
+
+ bool Validate(SpellInfo const* /*spell*/) override
+ {
+ if (!sSpellMgr->GetSpellInfo(SPELL_RIDE_PLAYER))
+ return false;
+ return true;
+ }
+
+ void OnPeriodic(AuraEffect const* /*aurEff*/)
+ {
+ if (!GetTarget()->HasAura(SPELL_RIDE_PLAYER))
+ Remove();
+ }
+
+ void Register() override
+ {
+ OnEffectPeriodic += AuraEffectPeriodicFn(spell_gormok_snobolled_AuraScript::OnPeriodic, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY);
+ }
+ };
+
+ AuraScript* GetAuraScript() const override
+ {
+ return new spell_gormok_snobolled_AuraScript();
+ }
+};
+
class spell_jormungars_paralytic_toxin : public SpellScriptLoader
{
public:
@@ -1293,6 +1439,9 @@ void AddSC_boss_northrend_beasts()
new npc_snobold_vassal();
new npc_firebomb();
new spell_gormok_fire_bomb();
+ new spell_gormok_jump_to_hand();
+ new spell_gormok_ride_player();
+ new spell_gormok_snobolled();
new boss_acidmaw();
new boss_dreadscale();
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 8998b77d8b5..25e2c045af9 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
@@ -406,7 +406,11 @@ class spell_devourer_of_souls_mirrored_soul_proc : public SpellScriptLoader
void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
- int32 damage = int32(CalculatePct(eventInfo.GetDamageInfo()->GetDamage(), 45));
+ DamageInfo* damageInfo = eventInfo.GetDamageInfo();
+ if (!damageInfo || !damageInfo->GetDamage())
+ return;
+
+ int32 damage = CalculatePct(static_cast<int32>(damageInfo->GetDamage()), 45);
GetTarget()->CastCustomSpell(SPELL_MIRRORED_SOUL_DAMAGE, SPELLVALUE_BASE_POINT0, damage, GetCaster(), true);
}
diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp
index a5d6d27724c..dd34f501e61 100644
--- a/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp
+++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp
@@ -729,8 +729,12 @@ class spell_blood_queen_essence_of_the_blood_queen : public SpellScriptLoader
void OnProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
- int32 heal = CalculatePct(int32(eventInfo.GetDamageInfo()->GetDamage()), aurEff->GetAmount());
- GetTarget()->CastCustomSpell(SPELL_ESSENCE_OF_THE_BLOOD_QUEEN_HEAL, SPELLVALUE_BASE_POINT0, heal, GetTarget(), TRIGGERED_FULL_MASK, NULL, aurEff);
+ DamageInfo* damageInfo = eventInfo.GetDamageInfo();
+ if (!damageInfo || !damageInfo->GetDamage())
+ return;
+
+ int32 heal = CalculatePct(static_cast<int32>(damageInfo->GetDamage()), aurEff->GetAmount());
+ GetTarget()->CastCustomSpell(SPELL_ESSENCE_OF_THE_BLOOD_QUEEN_HEAL, SPELLVALUE_BASE_POINT0, heal, GetTarget(), TRIGGERED_FULL_MASK, nullptr, aurEff);
}
void Register() override
diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_lady_deathwhisper.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_lady_deathwhisper.cpp
index 5f884ccee9e..85126b35cdb 100644
--- a/src/server/scripts/Northrend/IcecrownCitadel/boss_lady_deathwhisper.cpp
+++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_lady_deathwhisper.cpp
@@ -56,21 +56,26 @@ enum Spells
SPELL_MANA_BARRIER = 70842,
SPELL_SHADOW_BOLT = 71254,
SPELL_DEATH_AND_DECAY = 71001,
- SPELL_DOMINATE_MIND_H = 71289,
+ SPELL_DOMINATE_MIND = 71289,
+ SPELL_DOMINATE_MIND_SCALE = 71290,
SPELL_FROSTBOLT = 71420,
SPELL_FROSTBOLT_VOLLEY = 72905,
SPELL_TOUCH_OF_INSIGNIFICANCE = 71204,
SPELL_SUMMON_SHADE = 71363,
- SPELL_SHADOW_CHANNELING = 43897, // Prefight, during intro
+ SPELL_SHADOW_CHANNELING = 43897,
SPELL_DARK_TRANSFORMATION_T = 70895,
SPELL_DARK_EMPOWERMENT_T = 70896,
SPELL_DARK_MARTYRDOM_T = 70897,
+ SPELL_SUMMON_SPIRITS = 72478,
// Achievement
SPELL_FULL_HOUSE = 72827, // does not exist in dbc but still can be used for criteria check
// Both Adds
SPELL_TELEPORT_VISUAL = 41236,
+ SPELL_CLEAR_ALL_DEBUFFS = 34098,
+ SPELL_FULL_HEAL = 17683,
+ SPELL_PERMANENT_FEIGN_DEATH = 70628,
// Fanatics
SPELL_DARK_TRANSFORMATION = 70900,
@@ -86,7 +91,7 @@ enum Spells
SPELL_DEATHCHILL_BOLT = 70594,
SPELL_DEATHCHILL_BLAST = 70906,
SPELL_CURSE_OF_TORPOR = 71237,
- SPELL_SHORUD_OF_THE_OCCULT = 70768,
+ SPELL_SHROUD_OF_THE_OCCULT = 70768,
SPELL_ADHERENT_S_DETERMINATION = 71234,
SPELL_DARK_MARTYRDOM_ADHERENT = 70903,
@@ -108,44 +113,6 @@ enum Spells
enum EventTypes
{
- // Lady Deathwhisper
- EVENT_INTRO_2 = 1,
- EVENT_INTRO_3 = 2,
- EVENT_INTRO_4 = 3,
- EVENT_INTRO_5 = 4,
- EVENT_INTRO_6 = 5,
- EVENT_INTRO_7 = 6,
- EVENT_BERSERK = 7,
- EVENT_DEATH_AND_DECAY = 8,
- EVENT_DOMINATE_MIND_H = 9,
-
- // Phase 1 only
- EVENT_P1_SUMMON_WAVE = 10,
- EVENT_P1_SHADOW_BOLT = 11,
- EVENT_P1_EMPOWER_CULTIST = 12,
- EVENT_P1_REANIMATE_CULTIST = 13,
-
- // Phase 2 only
- EVENT_P2_SUMMON_WAVE = 14,
- EVENT_P2_FROSTBOLT = 15,
- EVENT_P2_FROSTBOLT_VOLLEY = 16,
- EVENT_P2_TOUCH_OF_INSIGNIFICANCE = 17,
- EVENT_P2_SUMMON_SHADE = 18,
-
- // Shared adds events
- EVENT_CULTIST_DARK_MARTYRDOM = 19,
-
- // Cult Fanatic
- EVENT_FANATIC_NECROTIC_STRIKE = 20,
- EVENT_FANATIC_SHADOW_CLEAVE = 21,
- EVENT_FANATIC_VAMPIRIC_MIGHT = 22,
-
- // Cult Adherent
- EVENT_ADHERENT_FROST_FEVER = 23,
- EVENT_ADHERENT_DEATHCHILL = 24,
- EVENT_ADHERENT_CURSE_OF_TORPOR = 25,
- EVENT_ADHERENT_SHORUD_OF_THE_OCCULT = 26,
-
// Darnavan
EVENT_DARNAVAN_BLADESTORM = 27,
EVENT_DARNAVAN_CHARGE = 28,
@@ -163,6 +130,13 @@ enum Phases
PHASE_TWO = 3
};
+enum Groups
+{
+ GROUP_INTRO = 0,
+ GROUP_ONE = 1,
+ GROUP_TWO = 2
+};
+
enum DeprogrammingData
{
NPC_DARNAVAN_10 = 38472,
@@ -185,8 +159,6 @@ enum Actions
uint32 const SummonEntries[2] = {NPC_CULT_FANATIC, NPC_CULT_ADHERENT};
-#define GUID_CULTIST 1
-
Position const SummonPositions[7] =
{
{-578.7066f, 2154.167f, 51.01529f, 1.692969f}, // 1 Left Door 1 (Cult Fanatic)
@@ -229,43 +201,67 @@ class boss_lady_deathwhisper : public CreatureScript
void Initialize()
{
_waveCounter = 0;
- _nextVengefulShadeTargetGUID.Clear();
+ _nextVengefulShadeTargetGUID.clear();
+ _cultistQueue.clear();
_darnavanGUID.Clear();
+ _phase = PHASE_ALL;
+ scheduler.SetValidator([this]
+ {
+ return !(me->HasUnitState(UNIT_STATE_CASTING) && _phase != PHASE_INTRO);
+ });
}
void Reset() override
{
- _Reset();
- me->SetPower(POWER_MANA, me->GetMaxPower(POWER_MANA));
- events.SetPhase(PHASE_ONE);
Initialize();
- DoCast(me, SPELL_SHADOW_CHANNELING);
- me->RemoveAurasDueToSpell(SPELL_BERSERK);
- me->RemoveAurasDueToSpell(SPELL_MANA_BARRIER);
+ _phase = PHASE_ONE;
+ DoCastSelf(SPELL_SHADOW_CHANNELING);
+ me->SetPower(POWER_MANA, me->GetMaxPower(POWER_MANA));
me->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_TAUNT, false);
me->ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_ATTACK_ME, false);
}
void DoAction(int32 action) override
{
- switch (action)
+ if (action != ACTION_START_INTRO)
+ return;
+
+ if (!_introDone)
{
- case ACTION_START_INTRO:
- if (!_introDone)
+ _introDone = true;
+ Talk(SAY_INTRO_1);
+ _phase = PHASE_INTRO;
+ scheduler.Schedule(Seconds(10), GROUP_INTRO, [this](TaskContext context)
+ {
+ switch (context.GetRepeatCounter())
{
- _introDone = true;
- Talk(SAY_INTRO_1);
- events.SetPhase(PHASE_INTRO);
- events.ScheduleEvent(EVENT_INTRO_2, 11000, 0, PHASE_INTRO);
- events.ScheduleEvent(EVENT_INTRO_3, 21000, 0, PHASE_INTRO);
- events.ScheduleEvent(EVENT_INTRO_4, 31500, 0, PHASE_INTRO);
- events.ScheduleEvent(EVENT_INTRO_5, 39500, 0, PHASE_INTRO);
- events.ScheduleEvent(EVENT_INTRO_6, 48500, 0, PHASE_INTRO);
- events.ScheduleEvent(EVENT_INTRO_7, 58000, 0, PHASE_INTRO);
+ case 0:
+ Talk(SAY_INTRO_2);
+ context.Repeat(Seconds(21));
+ break;
+ case 1:
+ Talk(SAY_INTRO_3);
+ context.Repeat(Seconds(11));
+ break;
+ case 2:
+ Talk(SAY_INTRO_4);
+ context.Repeat(Seconds(9));
+ break;
+ case 3:
+ Talk(SAY_INTRO_5);
+ context.Repeat(Seconds(21));
+ break;
+ case 4:
+ Talk(SAY_INTRO_6);
+ context.Repeat(Seconds(10));
+ break;
+ case 5:
+ Talk(SAY_INTRO_7);
+ return;
+ default:
+ break;
}
- break;
- default:
- break;
+ });
}
}
@@ -274,7 +270,7 @@ class boss_lady_deathwhisper : public CreatureScript
if (me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE))
return;
- if (victim && me->Attack(victim, true) && !events.IsInPhase(PHASE_ONE))
+ if (victim && me->Attack(victim, true) && _phase != PHASE_ONE)
me->GetMotionMaster()->MoveChase(victim);
}
@@ -282,31 +278,61 @@ class boss_lady_deathwhisper : public CreatureScript
{
if (!instance->CheckRequiredBosses(DATA_LADY_DEATHWHISPER, who->ToPlayer()))
{
- EnterEvadeMode();
+ EnterEvadeMode(EVADE_REASON_SEQUENCE_BREAK);
instance->DoCastSpellOnPlayers(LIGHT_S_HAMMER_TELEPORT);
return;
}
+ me->SetCombatPulseDelay(5);
me->setActive(true);
DoZoneInCombat();
-
- events.Reset();
- events.SetPhase(PHASE_ONE);
+ _phase = PHASE_ONE;
+ scheduler.CancelGroup(GROUP_INTRO);
// phase-independent events
- events.ScheduleEvent(EVENT_BERSERK, 600000);
- events.ScheduleEvent(EVENT_DEATH_AND_DECAY, 10000);
+ scheduler
+ .Schedule(Minutes(10), [this](TaskContext /*context*/)
+ {
+ DoCastSelf(SPELL_BERSERK);
+ Talk(SAY_BERSERK);
+ })
+ .Schedule(Seconds(17), [this](TaskContext death_and_decay)
+ {
+ if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM))
+ DoCast(target, SPELL_DEATH_AND_DECAY);
+ death_and_decay.Repeat(Seconds(22), Seconds(30));
+ });
+ if (GetDifficulty() != RAID_DIFFICULTY_10MAN_NORMAL)
+ scheduler.Schedule(Seconds(27), [this](TaskContext dominate_mind)
+ {
+ Talk(SAY_DOMINATE_MIND);
+ for (uint8 i = 0; i < _dominateMindCount; i++)
+ if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1, 0.0f, true, -SPELL_DOMINATE_MIND))
+ DoCast(target, SPELL_DOMINATE_MIND);
+ dominate_mind.Repeat(Seconds(40), Seconds(45));
+ });
// phase one only
- events.ScheduleEvent(EVENT_P1_SUMMON_WAVE, 5000, 0, PHASE_ONE);
- events.ScheduleEvent(EVENT_P1_SHADOW_BOLT, urand(5500, 6000), 0, PHASE_ONE);
- events.ScheduleEvent(EVENT_P1_EMPOWER_CULTIST, urand(20000, 30000), 0, PHASE_ONE);
- if (GetDifficulty() != RAID_DIFFICULTY_10MAN_NORMAL)
- events.ScheduleEvent(EVENT_DOMINATE_MIND_H, 27000);
+ scheduler
+ .Schedule(Seconds(5), GROUP_ONE, [this](TaskContext wave)
+ {
+ SummonWaveP1();
+ wave.Repeat(Seconds(IsHeroic() ? 45 : 60));
+ })
+ .Schedule(Seconds(2), GROUP_ONE, [this](TaskContext shadow_bolt)
+ {
+ if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM))
+ DoCast(target, SPELL_SHADOW_BOLT);
+ shadow_bolt.Repeat(Milliseconds(2450), Milliseconds(3600));
+ })
+ .Schedule(Seconds(15), GROUP_ONE, [this](TaskContext context)
+ {
+ DoImproveCultist();
+ context.Repeat(Seconds(25));
+ });
Talk(SAY_AGGRO);
DoStartNoMovement(who);
me->RemoveAurasDueToSpell(SPELL_SHADOW_CHANNELING);
- DoCast(me, SPELL_MANA_BARRIER, true);
-
+ DoCastSelf(SPELL_MANA_BARRIER, true);
instance->SetBossState(DATA_LADY_DEATHWHISPER, IN_PROGRESS);
}
@@ -338,7 +364,7 @@ class boss_lady_deathwhisper : public CreatureScript
{
if (Group* group = owner->GetGroup())
{
- for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
+ for (GroupReference* itr = group->GetFirstMember(); itr != nullptr; itr = itr->next())
if (Player* member = itr->GetSource())
member->KilledMonsterCredit(NPC_DARNAVAN_CREDIT);
}
@@ -351,17 +377,14 @@ class boss_lady_deathwhisper : public CreatureScript
_JustDied();
}
- void JustReachedHome() override
+ void EnterEvadeMode(EvadeReason /*why*/) override
{
- _JustReachedHome();
- instance->SetBossState(DATA_LADY_DEATHWHISPER, FAIL);
-
+ scheduler.CancelAll();
summons.DespawnAll();
if (Creature* darnavan = ObjectAccessor::GetCreature(*me, _darnavanGUID))
- {
darnavan->DespawnOrUnsummon();
- _darnavanGUID.Clear();
- }
+
+ _DespawnAtEvade();
}
void KilledUnit(Unit* victim) override
@@ -373,151 +396,98 @@ class boss_lady_deathwhisper : public CreatureScript
void DamageTaken(Unit* /*damageDealer*/, uint32& damage) override
{
// phase transition
- if (events.IsInPhase(PHASE_ONE) && damage > me->GetPower(POWER_MANA))
+ if (_phase == PHASE_ONE && damage > me->GetPower(POWER_MANA))
{
+ _phase = PHASE_TWO;
Talk(SAY_PHASE_2);
Talk(EMOTE_PHASE_2);
DoStartMovement(me->GetVictim());
+ DoResetThreat();
damage -= me->GetPower(POWER_MANA);
me->SetPower(POWER_MANA, 0);
me->RemoveAurasDueToSpell(SPELL_MANA_BARRIER);
- events.SetPhase(PHASE_TWO);
- events.ScheduleEvent(EVENT_P2_FROSTBOLT, urand(10000, 12000), 0, PHASE_TWO);
- events.ScheduleEvent(EVENT_P2_FROSTBOLT_VOLLEY, urand(19000, 21000), 0, PHASE_TWO);
- events.ScheduleEvent(EVENT_P2_TOUCH_OF_INSIGNIFICANCE, urand(6000, 9000), 0, PHASE_TWO);
- events.ScheduleEvent(EVENT_P2_SUMMON_SHADE, urand(12000, 15000), 0, PHASE_TWO);
+ scheduler.CancelGroup(GROUP_ONE);
+
+ scheduler
+ .Schedule(Seconds(12), GROUP_TWO, [this](TaskContext frostbolt)
+ {
+ DoCastVictim(SPELL_FROSTBOLT);
+ frostbolt.Repeat();
+ })
+ .Schedule(Seconds(20), GROUP_TWO, [this](TaskContext frostboldVolley)
+ {
+ DoCastAOE(SPELL_FROSTBOLT_VOLLEY);
+ frostboldVolley.Repeat();
+ })
+ .Schedule(Seconds(6), Seconds(9), GROUP_TWO, [this](TaskContext touch)
+ {
+ if (me->GetVictim())
+ me->AddAura(SPELL_TOUCH_OF_INSIGNIFICANCE, me->EnsureVictim());
+ touch.Repeat();
+ })
+ .Schedule(Seconds(12), GROUP_TWO, [this](TaskContext summonShade)
+ {
+ me->CastCustomSpell(SPELL_SUMMON_SPIRITS, SPELLVALUE_MAX_TARGETS, Is25ManRaid() ? 2 : 1);
+ summonShade.Repeat();
+ });
+
// on heroic mode Lady Deathwhisper is immune to taunt effects in phase 2 and continues summoning adds
if (IsHeroic())
{
me->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_TAUNT, true);
me->ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_ATTACK_ME, true);
- events.ScheduleEvent(EVENT_P2_SUMMON_WAVE, 45000, 0, PHASE_TWO);
+ scheduler.Schedule(Seconds(), GROUP_TWO, [this](TaskContext context)
+ {
+ SummonWaveP2();
+ context.Repeat(Seconds(45));
+ });
}
}
}
- void JustSummoned(Creature* summon) override
+ void SpellHitTarget(Unit* target, const SpellInfo* spell) override
{
- if (summon->GetEntry() == NPC_DARNAVAN)
- _darnavanGUID = summon->GetGUID();
- else
- summons.Summon(summon);
+ if (spell->Id == SPELL_SUMMON_SPIRITS)
+ _nextVengefulShadeTargetGUID.push_back(target->GetGUID());
+ }
- Unit* target = NULL;
- if (summon->GetEntry() == NPC_VENGEFUL_SHADE)
+ void JustSummoned(Creature* summon) override
+ {
+ switch (summon->GetEntry())
{
- target = ObjectAccessor::GetUnit(*me, _nextVengefulShadeTargetGUID); // Vengeful Shade
- _nextVengefulShadeTargetGUID.Clear();
+ case NPC_DARNAVAN_10:
+ case NPC_DARNAVAN_25:
+ _darnavanGUID = summon->GetGUID();
+ summon->AI()->AttackStart(SelectTarget(SELECT_TARGET_RANDOM));
+ return;
+ case NPC_VENGEFUL_SHADE:
+ if (_nextVengefulShadeTargetGUID.empty())
+ break;
+ summon->AI()->SetGUID(_nextVengefulShadeTargetGUID.front());
+ _nextVengefulShadeTargetGUID.pop_front();
+ break;
+ case NPC_CULT_ADHERENT:
+ case NPC_CULT_FANATIC:
+ _cultistQueue.push_back(summon->GetGUID());
+ summon->AI()->AttackStart(SelectTarget(SELECT_TARGET_RANDOM));
+ break;
+ default:
+ break;
}
- else
- target = SelectTarget(SELECT_TARGET_RANDOM); // Wave adds
-
- summon->AI()->AttackStart(target); // CAN be NULL
- if (summon->GetEntry() == NPC_REANIMATED_FANATIC)
- summon->CastSpell(summon, SPELL_FANATIC_S_DETERMINATION, true);
- else if (summon->GetEntry() == NPC_REANIMATED_ADHERENT)
- summon->CastSpell(summon, SPELL_ADHERENT_S_DETERMINATION, true);
+ summons.Summon(summon);
}
void UpdateAI(uint32 diff) override
{
- if (!UpdateVictim() && !events.IsInPhase(PHASE_INTRO))
+ if (!UpdateVictim() && _phase != PHASE_INTRO)
return;
- events.Update(diff);
-
- if (me->HasUnitState(UNIT_STATE_CASTING) && !events.IsInPhase(PHASE_INTRO))
- return;
-
- while (uint32 eventId = events.ExecuteEvent())
+ scheduler.Update(diff, [this]
{
- switch (eventId)
- {
- case EVENT_INTRO_2:
- Talk(SAY_INTRO_2);
- break;
- case EVENT_INTRO_3:
- Talk(SAY_INTRO_3);
- break;
- case EVENT_INTRO_4:
- Talk(SAY_INTRO_4);
- break;
- case EVENT_INTRO_5:
- Talk(SAY_INTRO_5);
- break;
- case EVENT_INTRO_6:
- Talk(SAY_INTRO_6);
- break;
- case EVENT_INTRO_7:
- Talk(SAY_INTRO_7);
- break;
- case EVENT_DEATH_AND_DECAY:
- if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM))
- DoCast(target, SPELL_DEATH_AND_DECAY);
- events.ScheduleEvent(EVENT_DEATH_AND_DECAY, urand(22000, 30000));
- break;
- case EVENT_DOMINATE_MIND_H:
- Talk(SAY_DOMINATE_MIND);
- for (uint8 i = 0; i < _dominateMindCount; i++)
- if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1, 0.0f, true, -SPELL_DOMINATE_MIND_H))
- DoCast(target, SPELL_DOMINATE_MIND_H);
- events.ScheduleEvent(EVENT_DOMINATE_MIND_H, urand(40000, 45000));
- break;
- case EVENT_P1_SUMMON_WAVE:
- SummonWaveP1();
- events.ScheduleEvent(EVENT_P1_SUMMON_WAVE, IsHeroic() ? 45000 : 60000, 0, PHASE_ONE);
- break;
- case EVENT_P1_SHADOW_BOLT:
- if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM))
- DoCast(target, SPELL_SHADOW_BOLT);
- events.ScheduleEvent(EVENT_P1_SHADOW_BOLT, urand(5000, 8000), 0, PHASE_ONE);
- break;
- case EVENT_P1_REANIMATE_CULTIST:
- ReanimateCultist();
- break;
- case EVENT_P1_EMPOWER_CULTIST:
- EmpowerCultist();
- events.ScheduleEvent(EVENT_P1_EMPOWER_CULTIST, urand(18000, 25000));
- break;
- case EVENT_P2_FROSTBOLT:
- DoCastVictim(SPELL_FROSTBOLT);
- events.ScheduleEvent(EVENT_P2_FROSTBOLT, urand(10000, 11000), 0, PHASE_TWO);
- break;
- case EVENT_P2_FROSTBOLT_VOLLEY:
- DoCastAOE(SPELL_FROSTBOLT_VOLLEY);
- events.ScheduleEvent(EVENT_P2_FROSTBOLT_VOLLEY, urand(13000, 15000), 0, PHASE_TWO);
- break;
- case EVENT_P2_TOUCH_OF_INSIGNIFICANCE:
- DoCastVictim(SPELL_TOUCH_OF_INSIGNIFICANCE);
- events.ScheduleEvent(EVENT_P2_TOUCH_OF_INSIGNIFICANCE, urand(9000, 13000), 0, PHASE_TWO);
- break;
- case EVENT_P2_SUMMON_SHADE:
- if (Unit* shadeTarget = SelectTarget(SELECT_TARGET_RANDOM, 1))
- {
- _nextVengefulShadeTargetGUID = shadeTarget->GetGUID();
- DoCast(shadeTarget, SPELL_SUMMON_SHADE);
- }
- events.ScheduleEvent(EVENT_P2_SUMMON_SHADE, urand(18000, 23000), 0, PHASE_TWO);
- break;
- case EVENT_P2_SUMMON_WAVE:
- SummonWaveP2();
- events.ScheduleEvent(EVENT_P2_SUMMON_WAVE, 45000, 0, PHASE_TWO);
- break;
- case EVENT_BERSERK:
- DoCast(me, SPELL_BERSERK);
- Talk(SAY_BERSERK);
- break;
- }
-
- if (me->HasUnitState(UNIT_STATE_CASTING) && !events.IsInPhase(PHASE_INTRO))
- return;
- }
-
- // We should not melee attack when barrier is up
- if (me->HasAura(SPELL_MANA_BARRIER))
- return;
-
- DoMeleeAttackIfReady();
+ // We should not melee attack when barrier is up
+ if (!me->HasAura(SPELL_MANA_BARRIER))
+ DoMeleeAttackIfReady();
+ });
}
// summoning function for first phase
@@ -568,72 +538,40 @@ class boss_lady_deathwhisper : public CreatureScript
summon->CastSpell(summon, SPELL_TELEPORT_VISUAL);
}
- void SetGUID(ObjectGuid guid, int32 id/* = 0*/) override
+ void SummonedCreatureDies(Creature* summon, Unit* /*killer*/) override
{
- if (id != GUID_CULTIST)
- return;
-
- _reanimationQueue.push_back(guid);
- events.ScheduleEvent(EVENT_P1_REANIMATE_CULTIST, 3000, 0, PHASE_ONE);
+ if (summon->GetEntry() == NPC_CULT_ADHERENT || summon->GetEntry() == NPC_CULT_FANATIC)
+ _cultistQueue.remove(summon->GetGUID());
}
- void ReanimateCultist()
+ void DoImproveCultist()
{
- if (_reanimationQueue.empty())
+ if (_cultistQueue.empty())
return;
- ObjectGuid cultistGUID = _reanimationQueue.front();
- Creature* cultist = ObjectAccessor::GetCreature(*me, cultistGUID);
- _reanimationQueue.pop_front();
+ _cultistGUID = Trinity::Containers::SelectRandomContainerElement(_cultistQueue);
+ _cultistQueue.remove(_cultistGUID);
+ Creature* cultist = ObjectAccessor::GetCreature(*me, _cultistGUID);
if (!cultist)
return;
- Talk(SAY_ANIMATE_DEAD);
- DoCast(cultist, SPELL_DARK_MARTYRDOM_T);
- }
-
- void SpellHitTarget(Unit* target, SpellInfo const* spell) override
- {
- if (spell->Id == SPELL_DARK_MARTYRDOM_T)
+ if (RAND(0,1))
+ me->CastSpell(cultist, SPELL_DARK_MARTYRDOM_T);
+ else
{
- Position pos = target->GetPosition();
- if (target->GetEntry() == NPC_CULT_FANATIC)
- me->SummonCreature(NPC_REANIMATED_FANATIC, pos, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 10000);
- else
- me->SummonCreature(NPC_REANIMATED_ADHERENT, pos, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 10000);
-
- if (TempSummon* summon = target->ToTempSummon())
- summon->UnSummon();
+ me->CastSpell(cultist, cultist->GetEntry() == NPC_CULT_FANATIC ? SPELL_DARK_TRANSFORMATION_T : SPELL_DARK_EMPOWERMENT_T, true);
+ Talk(uint8(cultist->GetEntry() == NPC_CULT_FANATIC ? SAY_DARK_TRANSFORMATION : SAY_DARK_EMPOWERMENT));
}
}
- void EmpowerCultist()
- {
- if (summons.empty())
- return;
-
- std::list<Creature*> temp;
- for (SummonList::iterator itr = summons.begin(); itr != summons.end(); ++itr)
- if (Creature* cre = ObjectAccessor::GetCreature(*me, *itr))
- if (cre->IsAlive() && (cre->GetEntry() == NPC_CULT_FANATIC || cre->GetEntry() == NPC_CULT_ADHERENT))
- temp.push_back(cre);
-
- // noone to empower
- if (temp.empty())
- return;
-
- // select random cultist
- Creature* cultist = Trinity::Containers::SelectRandomContainerElement(temp);
- DoCast(cultist, cultist->GetEntry() == NPC_CULT_FANATIC ? SPELL_DARK_TRANSFORMATION_T : SPELL_DARK_EMPOWERMENT_T, true);
- Talk(uint8(cultist->GetEntry() == NPC_CULT_FANATIC ? SAY_DARK_TRANSFORMATION : SAY_DARK_EMPOWERMENT));
- }
-
private:
- ObjectGuid _nextVengefulShadeTargetGUID;
ObjectGuid _darnavanGUID;
- GuidDeque _reanimationQueue;
+ ObjectGuid _cultistGUID;
+ GuidList _cultistQueue;
+ GuidList _nextVengefulShadeTargetGUID;
uint32 _waveCounter;
uint8 const _dominateMindCount;
+ uint8 _phase;
bool _introDone;
};
@@ -643,8 +581,6 @@ class boss_lady_deathwhisper : public CreatureScript
}
};
-typedef boss_lady_deathwhisper::boss_lady_deathwhisperAI DeathwisperAI;
-
class npc_cult_fanatic : public CreatureScript
{
public:
@@ -652,71 +588,91 @@ class npc_cult_fanatic : public CreatureScript
struct npc_cult_fanaticAI : public ScriptedAI
{
- npc_cult_fanaticAI(Creature* creature) : ScriptedAI(creature) { }
+ npc_cult_fanaticAI(Creature* creature) : ScriptedAI(creature), _instance(creature->GetInstanceScript()) { }
void Reset() override
{
- Events.Reset();
- Events.ScheduleEvent(EVENT_FANATIC_NECROTIC_STRIKE, urand(10000, 12000));
- Events.ScheduleEvent(EVENT_FANATIC_SHADOW_CLEAVE, urand(14000, 16000));
- Events.ScheduleEvent(EVENT_FANATIC_VAMPIRIC_MIGHT, urand(20000, 27000));
- if (me->GetEntry() == NPC_CULT_FANATIC)
- Events.ScheduleEvent(EVENT_CULTIST_DARK_MARTYRDOM, urand(18000, 32000));
+ _scheduler.CancelAll();
+ _scheduler
+ .SetValidator([this]
+ {
+ return !me->HasUnitState(UNIT_STATE_CASTING);
+ })
+ .Schedule(Seconds(17), [this](TaskContext vampiric_might)
+ {
+ DoCastSelf(SPELL_VAMPIRIC_MIGHT);
+ vampiric_might.Repeat(Seconds(25));
+ })
+ .Schedule(Seconds(12), [this](TaskContext shadow_cleave)
+ {
+ DoCastVictim(SPELL_SHADOW_CLEAVE);
+ shadow_cleave.Repeat(Seconds(14));
+ })
+ .Schedule(Seconds(10), [this](TaskContext necrotic_strike)
+ {
+ DoCastVictim(SPELL_NECROTIC_STRIKE);
+ necrotic_strike.Repeat(Seconds(17));
+ });
}
void SpellHit(Unit* /*caster*/, SpellInfo const* spell) override
{
- if (spell->Id == SPELL_DARK_TRANSFORMATION)
- me->UpdateEntry(NPC_DEFORMED_FANATIC);
- else if (spell->Id == SPELL_DARK_TRANSFORMATION_T)
+ switch (spell->Id)
{
- Events.CancelEvent(EVENT_CULTIST_DARK_MARTYRDOM);
- me->InterruptNonMeleeSpells(true);
- DoCast(me, SPELL_DARK_TRANSFORMATION);
+ case SPELL_DARK_TRANSFORMATION_T:
+ me->InterruptNonMeleeSpells(true);
+ DoCastSelf(SPELL_DARK_TRANSFORMATION);
+ break;
+ case SPELL_DARK_TRANSFORMATION:
+ DoCastSelf(SPELL_FULL_HEAL);
+ me->UpdateEntry(NPC_DEFORMED_FANATIC);
+ break;
+ case SPELL_DARK_MARTYRDOM_T:
+ me->SetReactState(REACT_PASSIVE);
+ me->InterruptNonMeleeSpells(true);
+ me->AttackStop();
+ DoCastSelf(SPELL_DARK_MARTYRDOM_FANATIC);
+ break;
+ case SPELL_DARK_MARTYRDOM_FANATIC:
+ _scheduler
+ .Schedule(Seconds(2), [this](TaskContext /*context*/)
+ {
+ me->UpdateEntry(NPC_REANIMATED_FANATIC);
+ DoCastSelf(SPELL_PERMANENT_FEIGN_DEATH);
+ DoCastSelf(SPELL_CLEAR_ALL_DEBUFFS);
+ DoCastSelf(SPELL_FULL_HEAL, true);
+ me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED | UNIT_FLAG_UNK_29 | UNIT_FLAG_NOT_SELECTABLE);
+ })
+ .Schedule(Seconds(6), [this](TaskContext /*context*/)
+ {
+ me->RemoveAurasDueToSpell(SPELL_PERMANENT_FEIGN_DEATH);
+ me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED | UNIT_FLAG_UNK_29 | UNIT_FLAG_NOT_SELECTABLE);
+ me->SetReactState(REACT_AGGRESSIVE);
+ DoZoneInCombat(me);
+
+ if (Creature* ladyDeathwhisper = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_LADY_DEATHWHISPER)))
+ ladyDeathwhisper->AI()->Talk(SAY_ANIMATE_DEAD);
+ });
+ break;
+ default:
+ break;
}
}
void UpdateAI(uint32 diff) override
{
- if (!UpdateVictim())
- return;
-
- Events.Update(diff);
-
- if (me->HasUnitState(UNIT_STATE_CASTING))
+ if (!UpdateVictim() && !me->HasAura(SPELL_PERMANENT_FEIGN_DEATH))
return;
- while (uint32 eventId = Events.ExecuteEvent())
+ _scheduler.Update(diff, [this]
{
- switch (eventId)
- {
- case EVENT_FANATIC_NECROTIC_STRIKE:
- DoCastVictim(SPELL_NECROTIC_STRIKE);
- Events.ScheduleEvent(EVENT_FANATIC_NECROTIC_STRIKE, urand(11000, 13000));
- break;
- case EVENT_FANATIC_SHADOW_CLEAVE:
- DoCastVictim(SPELL_SHADOW_CLEAVE);
- Events.ScheduleEvent(EVENT_FANATIC_SHADOW_CLEAVE, urand(9500, 11000));
- break;
- case EVENT_FANATIC_VAMPIRIC_MIGHT:
- DoCast(me, SPELL_VAMPIRIC_MIGHT);
- Events.ScheduleEvent(EVENT_FANATIC_VAMPIRIC_MIGHT, urand(20000, 27000));
- break;
- case EVENT_CULTIST_DARK_MARTYRDOM:
- DoCast(me, SPELL_DARK_MARTYRDOM_FANATIC);
- Events.ScheduleEvent(EVENT_CULTIST_DARK_MARTYRDOM, urand(16000, 21000));
- break;
- }
-
- if (me->HasUnitState(UNIT_STATE_CASTING))
- return;
- }
-
- DoMeleeAttackIfReady();
+ DoMeleeAttackIfReady();
+ });
}
protected:
- EventMap Events;
+ TaskScheduler _scheduler;
+ InstanceScript* _instance;
};
CreatureAI* GetAI(Creature* creature) const override
@@ -732,80 +688,88 @@ class npc_cult_adherent : public CreatureScript
struct npc_cult_adherentAI : public ScriptedAI
{
- npc_cult_adherentAI(Creature* creature) : ScriptedAI(creature) { }
+ npc_cult_adherentAI(Creature* creature) : ScriptedAI(creature), _instance(creature->GetInstanceScript()) { }
void Reset() override
{
- Events.Reset();
- Events.ScheduleEvent(EVENT_ADHERENT_FROST_FEVER, urand(10000, 12000));
- Events.ScheduleEvent(EVENT_ADHERENT_DEATHCHILL, urand(14000, 16000));
- Events.ScheduleEvent(EVENT_ADHERENT_CURSE_OF_TORPOR, urand(14000, 16000));
- Events.ScheduleEvent(EVENT_ADHERENT_SHORUD_OF_THE_OCCULT, urand(32000, 39000));
- if (me->GetEntry() == NPC_CULT_ADHERENT)
- Events.ScheduleEvent(EVENT_CULTIST_DARK_MARTYRDOM, urand(18000, 32000));
+ _scheduler.CancelAll();
+ _scheduler
+ .SetValidator([this]
+ {
+ return !me->HasUnitState(UNIT_STATE_CASTING);
+ })
+ .Schedule(Seconds(5), [this](TaskContext deathchill)
+ {
+ if (me->GetEntry() == NPC_EMPOWERED_ADHERENT)
+ DoCastVictim(SPELL_DEATHCHILL_BLAST);
+ else
+ DoCastVictim(SPELL_DEATHCHILL_BOLT);
+ deathchill.Repeat(Milliseconds(2500));
+ })
+ .Schedule(Seconds(15), [this](TaskContext shroud_of_the_occult)
+ {
+ DoCastSelf(SPELL_SHROUD_OF_THE_OCCULT);
+ shroud_of_the_occult.Repeat(Seconds(10));
+ })
+ .Schedule(Seconds(15), [this](TaskContext curse_of_torpor)
+ {
+ if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1))
+ DoCast(target, SPELL_CURSE_OF_TORPOR);
+ curse_of_torpor.Repeat(Seconds(18));
+ });
}
void SpellHit(Unit* /*caster*/, SpellInfo const* spell) override
{
- if (spell->Id == SPELL_DARK_EMPOWERMENT)
- me->UpdateEntry(NPC_EMPOWERED_ADHERENT);
- else if (spell->Id == SPELL_DARK_EMPOWERMENT_T)
+ switch (spell->Id)
{
- Events.CancelEvent(EVENT_CULTIST_DARK_MARTYRDOM);
- me->InterruptNonMeleeSpells(true);
- DoCast(me, SPELL_DARK_EMPOWERMENT);
+ case SPELL_DARK_EMPOWERMENT_T:
+ me->UpdateEntry(NPC_EMPOWERED_ADHERENT);
+ break;
+ case SPELL_DARK_MARTYRDOM_T:
+ me->SetReactState(REACT_PASSIVE);
+ me->InterruptNonMeleeSpells(true);
+ me->AttackStop();
+ DoCastSelf(SPELL_DARK_MARTYRDOM_ADHERENT);
+ break;
+ case SPELL_DARK_MARTYRDOM_ADHERENT:
+ _scheduler
+ .Schedule(Seconds(2), [this](TaskContext /*context*/)
+ {
+ me->UpdateEntry(NPC_REANIMATED_ADHERENT);
+ DoCastSelf(SPELL_PERMANENT_FEIGN_DEATH);
+ DoCastSelf(SPELL_CLEAR_ALL_DEBUFFS);
+ DoCastSelf(SPELL_FULL_HEAL, true);
+ me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED | UNIT_FLAG_UNK_29 | UNIT_FLAG_NOT_SELECTABLE);
+ })
+ .Schedule(Seconds(6), [this](TaskContext /*context*/)
+ {
+ me->RemoveAurasDueToSpell(SPELL_PERMANENT_FEIGN_DEATH);
+ me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED | UNIT_FLAG_UNK_29 | UNIT_FLAG_NOT_SELECTABLE);
+ me->SetReactState(REACT_AGGRESSIVE);
+ DoCastSelf(SPELL_SHROUD_OF_THE_OCCULT);
+ DoZoneInCombat(me);
+
+ if (Creature* ladyDeathwhisper = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_LADY_DEATHWHISPER)))
+ ladyDeathwhisper->AI()->Talk(SAY_ANIMATE_DEAD);
+ });
+ break;
+ default:
+ break;
}
}
void UpdateAI(uint32 diff) override
{
- if (!UpdateVictim())
+ if (!UpdateVictim() && !me->HasAura(SPELL_PERMANENT_FEIGN_DEATH))
return;
- Events.Update(diff);
-
- if (me->HasUnitState(UNIT_STATE_CASTING))
- return;
-
- while (uint32 eventId = Events.ExecuteEvent())
- {
- switch (eventId)
- {
- case EVENT_ADHERENT_FROST_FEVER:
- DoCastVictim(SPELL_FROST_FEVER);
- Events.ScheduleEvent(EVENT_ADHERENT_FROST_FEVER, urand(9000, 13000));
- break;
- case EVENT_ADHERENT_DEATHCHILL:
- if (me->GetEntry() == NPC_EMPOWERED_ADHERENT)
- DoCastVictim(SPELL_DEATHCHILL_BLAST);
- else
- DoCastVictim(SPELL_DEATHCHILL_BOLT);
- Events.ScheduleEvent(EVENT_ADHERENT_DEATHCHILL, urand(9000, 13000));
- break;
- case EVENT_ADHERENT_CURSE_OF_TORPOR:
- if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1))
- DoCast(target, SPELL_CURSE_OF_TORPOR);
- Events.ScheduleEvent(EVENT_ADHERENT_CURSE_OF_TORPOR, urand(9000, 13000));
- break;
- case EVENT_ADHERENT_SHORUD_OF_THE_OCCULT:
- DoCast(me, SPELL_SHORUD_OF_THE_OCCULT);
- Events.ScheduleEvent(EVENT_ADHERENT_SHORUD_OF_THE_OCCULT, urand(27000, 32000));
- break;
- case EVENT_CULTIST_DARK_MARTYRDOM:
- DoCast(me, SPELL_DARK_MARTYRDOM_ADHERENT);
- Events.ScheduleEvent(EVENT_CULTIST_DARK_MARTYRDOM, urand(16000, 21000));
- break;
- }
-
- if (me->HasUnitState(UNIT_STATE_CASTING))
- return;
- }
-
- DoMeleeAttackIfReady();
+ _scheduler.Update(diff);
}
protected:
- EventMap Events;
+ TaskScheduler _scheduler;
+ InstanceScript* _instance;
};
CreatureAI* GetAI(Creature* creature) const override
@@ -821,15 +785,28 @@ class npc_vengeful_shade : public CreatureScript
struct npc_vengeful_shadeAI : public ScriptedAI
{
- npc_vengeful_shadeAI(Creature* creature) : ScriptedAI(creature)
- {
- me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
- me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
- }
+ npc_vengeful_shadeAI(Creature* creature) : ScriptedAI(creature) { }
void Reset() override
{
+ me->SetReactState(REACT_PASSIVE);
me->AddAura(SPELL_VENGEFUL_BLAST_PASSIVE, me);
+
+ _scheduler
+ .Schedule(Seconds(2), [this](TaskContext /*context*/)
+ {
+ me->SetReactState(REACT_AGGRESSIVE);
+ me->AI()->AttackStart(ObjectAccessor::GetUnit(*me, _targetGUID));
+ })
+ .Schedule(Seconds(7), [this](TaskContext /*context*/)
+ {
+ me->KillSelf();
+ });
+ }
+
+ void SetGUID(ObjectGuid guid, int32 /*type*/) override
+ {
+ _targetGUID = guid;
}
void SpellHitTarget(Unit* /*target*/, SpellInfo const* spell) override
@@ -846,6 +823,18 @@ class npc_vengeful_shade : public CreatureScript
break;
}
}
+
+ void UpdateAI(uint32 diff) override
+ {
+ _scheduler.Update(diff, [this]
+ {
+ DoMeleeAttackIfReady();
+ });
+ }
+
+ private:
+ TaskScheduler _scheduler;
+ ObjectGuid _targetGUID;
};
CreatureAI* GetAI(Creature* creature) const override
@@ -875,10 +864,10 @@ class npc_darnavan : public CreatureScript
void Reset() override
{
_events.Reset();
- _events.ScheduleEvent(EVENT_DARNAVAN_BLADESTORM, 10000);
- _events.ScheduleEvent(EVENT_DARNAVAN_INTIMIDATING_SHOUT, urand(20000, 25000));
- _events.ScheduleEvent(EVENT_DARNAVAN_MORTAL_STRIKE, urand(25000, 30000));
- _events.ScheduleEvent(EVENT_DARNAVAN_SUNDER_ARMOR, urand(5000, 8000));
+ _events.ScheduleEvent(EVENT_DARNAVAN_BLADESTORM, Seconds(10));
+ _events.ScheduleEvent(EVENT_DARNAVAN_INTIMIDATING_SHOUT, Seconds(20), Seconds(25));
+ _events.ScheduleEvent(EVENT_DARNAVAN_MORTAL_STRIKE, Seconds(25), Seconds(30));
+ _events.ScheduleEvent(EVENT_DARNAVAN_SUNDER_ARMOR, Seconds(5), Seconds(8));
Initialize();
}
@@ -889,7 +878,7 @@ class npc_darnavan : public CreatureScript
{
if (Group* group = owner->GetGroup())
{
- for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
+ for (GroupReference* itr = group->GetFirstMember(); itr != nullptr; itr = itr->next())
if (Player* member = itr->GetSource())
member->FailQuest(QUEST_DEPROGRAMMING);
}
@@ -925,7 +914,7 @@ class npc_darnavan : public CreatureScript
{
DoCastVictim(SPELL_SHATTERING_THROW);
_canShatter = false;
- _events.ScheduleEvent(EVENT_DARNAVAN_SHATTERING_THROW, 30000);
+ _events.ScheduleEvent(EVENT_DARNAVAN_SHATTERING_THROW, Seconds(30));
return;
}
@@ -933,7 +922,7 @@ class npc_darnavan : public CreatureScript
{
DoCastVictim(SPELL_CHARGE);
_canCharge = false;
- _events.ScheduleEvent(EVENT_DARNAVAN_CHARGE, 20000);
+ _events.ScheduleEvent(EVENT_DARNAVAN_CHARGE, Seconds(20));
return;
}
@@ -943,25 +932,25 @@ class npc_darnavan : public CreatureScript
{
case EVENT_DARNAVAN_BLADESTORM:
DoCast(SPELL_BLADESTORM);
- _events.ScheduleEvent(EVENT_DARNAVAN_BLADESTORM, urand(90000, 100000));
+ _events.ScheduleEvent(EVENT_DARNAVAN_BLADESTORM, Seconds(90), Seconds(100));
break;
case EVENT_DARNAVAN_CHARGE:
_canCharge = true;
break;
case EVENT_DARNAVAN_INTIMIDATING_SHOUT:
DoCast(SPELL_INTIMIDATING_SHOUT);
- _events.ScheduleEvent(EVENT_DARNAVAN_INTIMIDATING_SHOUT, urand(90000, 120000));
+ _events.ScheduleEvent(EVENT_DARNAVAN_INTIMIDATING_SHOUT, Seconds(90), Minutes(2));
break;
case EVENT_DARNAVAN_MORTAL_STRIKE:
DoCastVictim(SPELL_MORTAL_STRIKE);
- _events.ScheduleEvent(EVENT_DARNAVAN_MORTAL_STRIKE, urand(15000, 30000));
+ _events.ScheduleEvent(EVENT_DARNAVAN_MORTAL_STRIKE, Seconds(15), Seconds(30));
break;
case EVENT_DARNAVAN_SHATTERING_THROW:
_canShatter = true;
break;
case EVENT_DARNAVAN_SUNDER_ARMOR:
DoCastVictim(SPELL_SUNDER_ARMOR);
- _events.ScheduleEvent(EVENT_DARNAVAN_SUNDER_ARMOR, urand(3000, 7000));
+ _events.ScheduleEvent(EVENT_DARNAVAN_SUNDER_ARMOR, Seconds(3), Seconds(7));
break;
}
}
@@ -1013,50 +1002,86 @@ class spell_deathwhisper_mana_barrier : public SpellScriptLoader
}
};
-class spell_cultist_dark_martyrdom : public SpellScriptLoader
+class at_lady_deathwhisper_entrance : public AreaTriggerScript
{
public:
- spell_cultist_dark_martyrdom() : SpellScriptLoader("spell_cultist_dark_martyrdom") { }
+ at_lady_deathwhisper_entrance() : AreaTriggerScript("at_lady_deathwhisper_entrance") { }
- class spell_cultist_dark_martyrdom_SpellScript : public SpellScript
+ bool OnTrigger(Player* player, AreaTriggerEntry const* /*areaTrigger*/) override
{
- PrepareSpellScript(spell_cultist_dark_martyrdom_SpellScript);
+ if (InstanceScript* instance = player->GetInstanceScript())
+ if (instance->GetBossState(DATA_LADY_DEATHWHISPER) != DONE)
+ if (Creature* ladyDeathwhisper = ObjectAccessor::GetCreature(*player, instance->GetGuidData(DATA_LADY_DEATHWHISPER)))
+ ladyDeathwhisper->AI()->DoAction(ACTION_START_INTRO);
+
+ return true;
+ }
+};
+
+class spell_deathwhisper_dominated_mind : public SpellScriptLoader
+{
+ public:
+ spell_deathwhisper_dominated_mind() : SpellScriptLoader("spell_deathwhisper_dominated_mind") { }
- void HandleEffect(SpellEffIndex /*effIndex*/)
+ class spell_deathwhisper_dominated_mind_AuraScript : public AuraScript
+ {
+ PrepareAuraScript(spell_deathwhisper_dominated_mind_AuraScript);
+
+ bool Validate(SpellInfo const* /*spell*/) override
{
- if (GetCaster()->IsSummon())
- if (Unit* owner = GetCaster()->ToTempSummon()->GetSummoner())
- owner->GetAI()->SetGUID(GetCaster()->GetGUID(), GUID_CULTIST);
+ if (!sSpellMgr->GetSpellInfo(SPELL_DOMINATE_MIND_SCALE))
+ return false;
+ return true;
+ }
- GetCaster()->KillSelf();
- GetCaster()->SetDisplayId(uint32(GetCaster()->GetEntry() == NPC_CULT_FANATIC ? 38009 : 38010));
+ void HandleApply(AuraEffect const* /*eff*/, AuraEffectHandleModes /*mode*/)
+ {
+ Unit* target = GetTarget();
+ target->CastSpell(target, SPELL_DOMINATE_MIND_SCALE, true);
}
void Register() override
{
- OnEffectHitTarget += SpellEffectFn(spell_cultist_dark_martyrdom_SpellScript::HandleEffect, EFFECT_2, SPELL_EFFECT_FORCE_DESELECT);
+ AfterEffectApply += AuraEffectApplyFn(spell_deathwhisper_dominated_mind_AuraScript::HandleApply, EFFECT_0, SPELL_AURA_AOE_CHARM, AURA_EFFECT_HANDLE_REAL);
}
};
- SpellScript* GetSpellScript() const override
+ AuraScript* GetAuraScript() const override
{
- return new spell_cultist_dark_martyrdom_SpellScript();
+ return new spell_deathwhisper_dominated_mind_AuraScript();
}
};
-class at_lady_deathwhisper_entrance : public AreaTriggerScript
+class spell_deathwhisper_summon_spirits : public SpellScriptLoader
{
public:
- at_lady_deathwhisper_entrance() : AreaTriggerScript("at_lady_deathwhisper_entrance") { }
+ spell_deathwhisper_summon_spirits() : SpellScriptLoader("spell_deathwhisper_summon_spirits") { }
- bool OnTrigger(Player* player, AreaTriggerEntry const* /*areaTrigger*/) override
+ class spell_deathwhisper_summon_spirits_SpellScript : public SpellScript
{
- if (InstanceScript* instance = player->GetInstanceScript())
- if (instance->GetBossState(DATA_LADY_DEATHWHISPER) != DONE)
- if (Creature* ladyDeathwhisper = ObjectAccessor::GetCreature(*player, instance->GetGuidData(DATA_LADY_DEATHWHISPER)))
- ladyDeathwhisper->AI()->DoAction(ACTION_START_INTRO);
+ PrepareSpellScript(spell_deathwhisper_summon_spirits_SpellScript);
- return true;
+ bool Validate(SpellInfo const* /*spell*/) override
+ {
+ if (!sSpellMgr->GetSpellInfo(SPELL_SUMMON_SHADE))
+ return false;
+ return true;
+ }
+
+ void HandleScriptEffect(SpellEffIndex /*effIndex*/)
+ {
+ GetCaster()->CastSpell(GetHitUnit(), SPELL_SUMMON_SHADE, true);
+ }
+
+ void Register() override
+ {
+ OnEffectHitTarget += SpellEffectFn(spell_deathwhisper_summon_spirits_SpellScript::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_DUMMY);
+ }
+ };
+
+ SpellScript* GetSpellScript() const override
+ {
+ return new spell_deathwhisper_summon_spirits_SpellScript();
}
};
@@ -1068,6 +1093,7 @@ void AddSC_boss_lady_deathwhisper()
new npc_vengeful_shade();
new npc_darnavan();
new spell_deathwhisper_mana_barrier();
- new spell_cultist_dark_martyrdom();
+ new spell_deathwhisper_dominated_mind();
+ new spell_deathwhisper_summon_spirits();
new at_lady_deathwhisper_entrance();
}
diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp
index 77805dbfcb2..15e4885d4a7 100644
--- a/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp
+++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp
@@ -1115,7 +1115,7 @@ class spell_putricide_ooze_tank_protection : public SpellScriptLoader
PreventDefaultAction();
Unit* actionTarget = eventInfo.GetActionTarget();
- actionTarget->CastSpell((Unit*)nullptr, GetSpellInfo()->Effects[aurEff->GetEffIndex()].TriggerSpell, true);
+ actionTarget->CastSpell((Unit*)nullptr, GetSpellInfo()->Effects[aurEff->GetEffIndex()].TriggerSpell, true, nullptr, aurEff);
}
void Register() override
diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp
index a2348119dff..f3021cdbab5 100644
--- a/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp
+++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp
@@ -1099,6 +1099,12 @@ class spell_sindragosa_s_fury : public SpellScriptLoader
if (!GetHitUnit()->IsAlive() || !_targetCount)
return;
+ if (GetHitUnit()->IsImmunedToDamage(GetSpellInfo()))
+ {
+ GetCaster()->SendSpellDamageImmune(GetHitUnit(), GetSpellInfo()->Id);
+ return;
+ }
+
float resistance = float(GetHitUnit()->GetResistance(SpellSchoolMask(GetSpellInfo()->SchoolMask)));
uint32 minResistFactor = uint32((resistance / (resistance + 510.0f)) * 10.0f) * 2;
uint32 randomResist = urand(0, (9 - minResistFactor) * 100) / 100 + minResistFactor;
diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp
index b618cb9ce2d..44f300e1efa 100644
--- a/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp
+++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp
@@ -2991,8 +2991,12 @@ class spell_the_lich_king_dark_hunger : public SpellScriptLoader
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
- int32 heal = int32(eventInfo.GetDamageInfo()->GetDamage() / 2);
- GetTarget()->CastCustomSpell(SPELL_DARK_HUNGER_HEAL, SPELLVALUE_BASE_POINT0, heal, GetTarget(), true, NULL, aurEff);
+ DamageInfo* damageInfo = eventInfo.GetDamageInfo();
+ if (!damageInfo || !damageInfo->GetDamage())
+ return;
+
+ int32 heal = static_cast<int32>(damageInfo->GetDamage()) / 2;
+ GetTarget()->CastCustomSpell(SPELL_DARK_HUNGER_HEAL, SPELLVALUE_BASE_POINT0, heal, GetTarget(), true, nullptr, aurEff);
}
void Register() override
diff --git a/src/server/scripts/Northrend/Nexus/Oculus/oculus.cpp b/src/server/scripts/Northrend/Nexus/Oculus/oculus.cpp
index 3d9ea97b136..b06bc9e872f 100644
--- a/src/server/scripts/Northrend/Nexus/Oculus/oculus.cpp
+++ b/src/server/scripts/Northrend/Nexus/Oculus/oculus.cpp
@@ -604,8 +604,11 @@ class spell_oculus_temporal_rift : public SpellScriptLoader
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
- int32 amount = aurEff->GetAmount() + eventInfo.GetDamageInfo()->GetDamage();
+ DamageInfo* damageInfo = eventInfo.GetDamageInfo();
+ if (!damageInfo || !damageInfo->GetDamage())
+ return;
+ int32 amount = aurEff->GetAmount() + damageInfo->GetDamage();
if (amount >= 15000)
{
if (Unit* caster = GetCaster())
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 6c27aaef25d..70d9fc90cb9 100644
--- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_yogg_saron.cpp
+++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_yogg_saron.cpp
@@ -2751,8 +2751,12 @@ class spell_yogg_saron_grim_reprisal : public SpellScriptLoader // 63305
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
- int32 damage = CalculatePct(int32(eventInfo.GetDamageInfo()->GetDamage()), 60);
- GetTarget()->CastCustomSpell(SPELL_GRIM_REPRISAL_DAMAGE, SPELLVALUE_BASE_POINT0, damage, eventInfo.GetDamageInfo()->GetAttacker(), true, NULL, aurEff);
+ DamageInfo* damageInfo = eventInfo.GetDamageInfo();
+ if (!damageInfo || !damageInfo->GetDamage())
+ return;
+
+ int32 damage = CalculatePct(static_cast<int32>(damageInfo->GetDamage()), 60);
+ GetTarget()->CastCustomSpell(SPELL_GRIM_REPRISAL_DAMAGE, SPELLVALUE_BASE_POINT0, damage, damageInfo->GetAttacker(), true, nullptr, aurEff);
}
void Register() override
diff --git a/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/utgarde_keep.cpp b/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/utgarde_keep.cpp
index b25f7ed3eca..82abb2836ba 100644
--- a/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/utgarde_keep.cpp
+++ b/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/utgarde_keep.cpp
@@ -222,11 +222,11 @@ class spell_uk_second_wind : public SpellScriptLoader
return (spellInfo->GetAllEffectsMechanicMask() & ((1 << MECHANIC_ROOT) | (1 << MECHANIC_STUN))) != 0;
}
- void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
+ void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
Unit* caster = eventInfo.GetActionTarget();
- caster->CastSpell(caster, SPELL_SECOND_WIND_TRIGGER, true);
+ caster->CastSpell(caster, SPELL_SECOND_WIND_TRIGGER, true, nullptr, aurEff);
}
void Register() override
diff --git a/src/server/scripts/Northrend/zone_dragonblight.cpp b/src/server/scripts/Northrend/zone_dragonblight.cpp
index c22cd2d9ad7..cb5a7462000 100644
--- a/src/server/scripts/Northrend/zone_dragonblight.cpp
+++ b/src/server/scripts/Northrend/zone_dragonblight.cpp
@@ -701,6 +701,31 @@ class npc_torturer_lecraft : public CreatureScript
}
};
+enum MessengerTorvus
+{
+ NPC_MESSENGER_TORVUS = 26649,
+ QUEST_MESSAGE_FROM_THE_WEST = 12033,
+
+ TALK_0 = 0
+};
+
+class at_nearby_messenger_torvus : public AreaTriggerScript
+{
+public:
+ at_nearby_messenger_torvus() : AreaTriggerScript("at_nearby_messenger_torvus") { }
+
+ bool OnTrigger(Player* player, const AreaTriggerEntry* /*at*/) override
+ {
+ if (player->IsAlive())
+ if (Quest const* quest = sObjectMgr->GetQuestTemplate(QUEST_MESSAGE_FROM_THE_WEST))
+ if (player->CanTakeQuest(quest, false))
+ if (Creature* creature = player->FindNearestCreature(NPC_MESSENGER_TORVUS, 50.0f, true))
+ creature->AI()->Talk(TALK_0, player);
+
+ return true;
+ }
+};
+
void AddSC_dragonblight()
{
new npc_commander_eligor_dawnbringer();
@@ -708,4 +733,5 @@ void AddSC_dragonblight()
new spell_q12096_q12092_bark();
new npc_wyrmrest_defender();
new npc_torturer_lecraft();
+ new at_nearby_messenger_torvus();
}
diff --git a/src/server/scripts/Northrend/zone_storm_peaks.cpp b/src/server/scripts/Northrend/zone_storm_peaks.cpp
index 2effc1d9a2a..54ae9c27aeb 100644
--- a/src/server/scripts/Northrend/zone_storm_peaks.cpp
+++ b/src/server/scripts/Northrend/zone_storm_peaks.cpp
@@ -281,6 +281,7 @@ public:
void UpdateAI(uint32 diff) override
{
+ VehicleAI::UpdateAI(diff);
events.Update(diff);
switch (events.ExecuteEvent())
diff --git a/src/server/scripts/Northrend/zone_wintergrasp.cpp b/src/server/scripts/Northrend/zone_wintergrasp.cpp
index 0519f964fd6..e45b1f42fa1 100644
--- a/src/server/scripts/Northrend/zone_wintergrasp.cpp
+++ b/src/server/scripts/Northrend/zone_wintergrasp.cpp
@@ -247,39 +247,39 @@ class npc_wg_queue : public CreatureScript
public:
npc_wg_queue() : CreatureScript("npc_wg_queue") { }
- struct npc_wg_queueAI : public ScriptedAI
- {
- npc_wg_queueAI(Creature* creature) : ScriptedAI(creature)
+ struct npc_wg_queueAI : public ScriptedAI
{
- FrostArmor_Timer = 0;
- }
+ npc_wg_queueAI(Creature* creature) : ScriptedAI(creature)
+ {
+ FrostArmor_Timer = 0;
+ }
- uint32 FrostArmor_Timer;
+ uint32 FrostArmor_Timer;
- void Reset() override
- {
- FrostArmor_Timer = 0;
- }
+ void Reset() override
+ {
+ FrostArmor_Timer = 0;
+ }
- void EnterCombat(Unit* /*who*/) override { }
+ void EnterCombat(Unit* /*who*/) override { }
- void UpdateAI(uint32 diff) override
- {
- if (FrostArmor_Timer <= diff)
+ void UpdateAI(uint32 diff) override
{
- DoCast(me, SPELL_FROST_ARMOR);
- FrostArmor_Timer = 180000;
+ if (FrostArmor_Timer <= diff)
+ {
+ DoCast(me, SPELL_FROST_ARMOR);
+ FrostArmor_Timer = 180000;
+ }
+ else FrostArmor_Timer -= diff;
+
+ DoMeleeAttackIfReady();
}
- else FrostArmor_Timer -= diff;
+ };
- DoMeleeAttackIfReady();
+ CreatureAI* GetAI(Creature* creature) const override
+ {
+ return new npc_wg_queueAI(creature);
}
- };
-
- CreatureAI* GetAI(Creature* creature) const override
- {
- return new npc_wg_queueAI(creature);
- }
bool OnGossipHello(Player* player, Creature* creature) override
{
@@ -380,111 +380,31 @@ class go_wg_vehicle_teleporter : public GameObjectScript
}
};
-class npc_wg_quest_giver : public CreatureScript
+class npc_wg_give_promotion_credit : public CreatureScript
{
public:
- npc_wg_quest_giver() : CreatureScript("npc_wg_quest_giver") { }
+ npc_wg_give_promotion_credit() : CreatureScript("npc_wg_give_promotion_credit") { }
- bool OnGossipHello(Player* player, Creature* creature) override
+ struct npc_wg_give_promotion_creditAI : public ScriptedAI
{
- Battlefield* wintergrasp = sBattlefieldMgr->GetBattlefieldByBattleId(BATTLEFIELD_BATTLEID_WG);
- if (!wintergrasp)
- return true;
-
- if (creature->IsVendor())
- {
- AddGossipItemFor(player, Player::GetDefaultGossipMenuForSource(creature), 0, GOSSIP_SENDER_MAIN, GOSSIP_OPTION_VENDOR);
- player->PlayerTalkClass->GetGossipMenu().AddGossipMenuItemData(0, 0, 0);
- }
-
- /// @todo: move this to conditions or something else
+ npc_wg_give_promotion_creditAI(Creature* creature) : ScriptedAI(creature) { }
- // Player::PrepareQuestMenu(guid)
- if (creature->IsQuestGiver())
+ void JustDied(Unit* killer) override
{
- QuestRelationBounds objectQR = sObjectMgr->GetCreatureQuestRelationBounds(creature->GetEntry());
- QuestRelationBounds objectQIR = sObjectMgr->GetCreatureQuestInvolvedRelationBounds(creature->GetEntry());
+ if (killer->GetTypeId() != TYPEID_PLAYER)
+ return;
- QuestMenu& qm = player->PlayerTalkClass->GetQuestMenu();
- qm.ClearMenu();
-
- for (QuestRelations::const_iterator i = objectQIR.first; i != objectQIR.second; ++i)
- {
- uint32 questId = i->second;
- QuestStatus status = player->GetQuestStatus(questId);
- if (status == QUEST_STATUS_COMPLETE)
- qm.AddMenuItem(questId, 4);
- else if (status == QUEST_STATUS_INCOMPLETE)
- qm.AddMenuItem(questId, 4);
- //else if (status == QUEST_STATUS_AVAILABLE)
- // qm.AddMenuItem(quest_id, 2);
- }
+ BattlefieldWG* wintergrasp = static_cast<BattlefieldWG*>(sBattlefieldMgr->GetBattlefieldByBattleId(BATTLEFIELD_BATTLEID_WG));
+ if (!wintergrasp)
+ return;
- for (QuestRelations::const_iterator i = objectQR.first; i != objectQR.second; ++i)
- {
- uint32 questId = i->second;
- Quest const* quest = sObjectMgr->GetQuestTemplate(questId);
- if (!quest)
- continue;
-
- if (!player->CanTakeQuest(quest, false))
- continue;
-
- switch (questId)
- {
- // Horde attacker
- case QUEST_BONES_AND_ARROWS_HORDE_ATT:
- case QUEST_JINXING_THE_WALLS_HORDE_ATT:
- case QUEST_SLAY_THEM_ALL_HORDE_ATT:
- case QUEST_FUELING_THE_DEMOLISHERS_HORDE_ATT:
- case QUEST_HEALING_WITH_ROSES_HORDE_ATT:
- case QUEST_DEFEND_THE_SIEGE_HORDE_ATT:
- if (wintergrasp->GetAttackerTeam() != TEAM_HORDE)
- continue;
- break;
- // Horde defender
- case QUEST_BONES_AND_ARROWS_HORDE_DEF:
- case QUEST_WARDING_THE_WALLS_HORDE_DEF:
- case QUEST_SLAY_THEM_ALL_HORDE_DEF:
- case QUEST_FUELING_THE_DEMOLISHERS_HORDE_DEF:
- case QUEST_HEALING_WITH_ROSES_HORDE_DEF:
- case QUEST_TOPPLING_THE_TOWERS_HORDE_DEF:
- case QUEST_STOP_THE_SIEGE_HORDE_DEF:
- if (wintergrasp->GetDefenderTeam() != TEAM_HORDE)
- continue;
- break;
- // Alliance attacker
- case QUEST_BONES_AND_ARROWS_ALLIANCE_ATT:
- case QUEST_WARDING_THE_WARRIORS_ALLIANCE_ATT:
- case QUEST_NO_MERCY_FOR_THE_MERCILESS_ALLIANCE_ATT:
- case QUEST_DEFEND_THE_SIEGE_ALLIANCE_ATT:
- case QUEST_A_RARE_HERB_ALLIANCE_ATT:
- if (wintergrasp->GetAttackerTeam() != TEAM_ALLIANCE)
- continue;
- break;
- // Alliance defender
- case QUEST_BONES_AND_ARROWS_ALLIANCE_DEF:
- case QUEST_WARDING_THE_WARRIORS_ALLIANCE_DEF:
- case QUEST_NO_MERCY_FOR_THE_MERCILESS_ALLIANCE_DEF:
- case QUEST_SHOUTHERN_SABOTAGE_ALLIANCE_DEF:
- case QUEST_STOP_THE_SIEGE_ALLIANCE_DEF:
- case QUEST_A_RARE_HERB_ALLIANCE_DEF:
- if (wintergrasp->GetDefenderTeam() != TEAM_ALLIANCE)
- continue;
- break;
- default:
- break;
- }
-
- if (quest->IsAutoComplete())
- qm.AddMenuItem(questId, 4);
- else if (player->GetQuestStatus(questId) == QUEST_STATUS_NONE)
- qm.AddMenuItem(questId, 2);
- }
+ wintergrasp->HandlePromotion(killer->ToPlayer(), me);
}
+ };
- SendGossipMenuFor(player, player->GetGossipTextId(creature), creature->GetGUID());
- return true;
+ CreatureAI* GetAI(Creature* creature) const override
+ {
+ return new npc_wg_give_promotion_creditAI(creature);
}
};
@@ -554,26 +474,26 @@ class spell_wintergrasp_grab_passenger : public SpellScriptLoader
class achievement_wg_didnt_stand_a_chance : public AchievementCriteriaScript
{
-public:
- achievement_wg_didnt_stand_a_chance() : AchievementCriteriaScript("achievement_wg_didnt_stand_a_chance") { }
-
- bool OnCheck(Player* source, Unit* target) override
- {
- if (!target)
- return false;
+ public:
+ achievement_wg_didnt_stand_a_chance() : AchievementCriteriaScript("achievement_wg_didnt_stand_a_chance") { }
- if (Player* victim = target->ToPlayer())
+ bool OnCheck(Player* source, Unit* target) override
{
- if (!victim->IsMounted())
+ if (!target)
return false;
- if (Vehicle* vehicle = source->GetVehicle())
- if (vehicle->GetVehicleInfo()->m_ID == 244) // Wintergrasp Tower Cannon
- return true;
- }
+ if (Player* victim = target->ToPlayer())
+ {
+ if (!victim->IsMounted())
+ return false;
+
+ if (Vehicle* vehicle = source->GetVehicle())
+ if (vehicle->GetVehicleInfo()->m_ID == 244) // Wintergrasp Tower Cannon
+ return true;
+ }
- return false;
- }
+ return false;
+ }
};
enum WgTeleport
@@ -583,91 +503,91 @@ enum WgTeleport
class spell_wintergrasp_defender_teleport : public SpellScriptLoader
{
-public:
- spell_wintergrasp_defender_teleport() : SpellScriptLoader("spell_wintergrasp_defender_teleport") { }
-
- class spell_wintergrasp_defender_teleport_SpellScript : public SpellScript
- {
- PrepareSpellScript(spell_wintergrasp_defender_teleport_SpellScript);
+ public:
+ spell_wintergrasp_defender_teleport() : SpellScriptLoader("spell_wintergrasp_defender_teleport") { }
- SpellCastResult CheckCast()
+ class spell_wintergrasp_defender_teleport_SpellScript : public SpellScript
{
- if (Battlefield* wg = sBattlefieldMgr->GetBattlefieldByBattleId(BATTLEFIELD_BATTLEID_WG))
- if (Player* target = GetExplTargetUnit()->ToPlayer())
- // check if we are in Wintergrasp at all, SotA uses same teleport spells
- if ((target->GetZoneId() == 4197 && target->GetTeamId() != wg->GetDefenderTeam()) || target->HasAura(SPELL_WINTERGRASP_TELEPORT_TRIGGER))
- return SPELL_FAILED_BAD_TARGETS;
- return SPELL_CAST_OK;
- }
+ PrepareSpellScript(spell_wintergrasp_defender_teleport_SpellScript);
- void Register() override
+ SpellCastResult CheckCast()
+ {
+ if (Battlefield* wg = sBattlefieldMgr->GetBattlefieldByBattleId(BATTLEFIELD_BATTLEID_WG))
+ if (Player* target = GetExplTargetUnit()->ToPlayer())
+ // check if we are in Wintergrasp at all, SotA uses same teleport spells
+ if ((target->GetZoneId() == 4197 && target->GetTeamId() != wg->GetDefenderTeam()) || target->HasAura(SPELL_WINTERGRASP_TELEPORT_TRIGGER))
+ return SPELL_FAILED_BAD_TARGETS;
+ return SPELL_CAST_OK;
+ }
+
+ void Register() override
+ {
+ OnCheckCast += SpellCheckCastFn(spell_wintergrasp_defender_teleport_SpellScript::CheckCast);
+ }
+ };
+
+ SpellScript* GetSpellScript() const override
{
- OnCheckCast += SpellCheckCastFn(spell_wintergrasp_defender_teleport_SpellScript::CheckCast);
+ return new spell_wintergrasp_defender_teleport_SpellScript();
}
- };
-
- SpellScript* GetSpellScript() const override
- {
- return new spell_wintergrasp_defender_teleport_SpellScript();
- }
};
class spell_wintergrasp_defender_teleport_trigger : public SpellScriptLoader
{
-public:
- spell_wintergrasp_defender_teleport_trigger() : SpellScriptLoader("spell_wintergrasp_defender_teleport_trigger") { }
-
- class spell_wintergrasp_defender_teleport_trigger_SpellScript : public SpellScript
- {
- PrepareSpellScript(spell_wintergrasp_defender_teleport_trigger_SpellScript);
+ public:
+ spell_wintergrasp_defender_teleport_trigger() : SpellScriptLoader("spell_wintergrasp_defender_teleport_trigger") { }
- void HandleDummy(SpellEffIndex /*effindex*/)
+ class spell_wintergrasp_defender_teleport_trigger_SpellScript : public SpellScript
{
- if (Unit* target = GetHitUnit())
+ PrepareSpellScript(spell_wintergrasp_defender_teleport_trigger_SpellScript);
+
+ void HandleDummy(SpellEffIndex /*effindex*/)
{
- WorldLocation loc = target->GetWorldLocation();
- SetExplTargetDest(loc);
+ if (Unit* target = GetHitUnit())
+ {
+ WorldLocation loc = target->GetWorldLocation();
+ SetExplTargetDest(loc);
+ }
}
- }
- void Register() override
+ void Register() override
+ {
+ OnEffectHitTarget += SpellEffectFn(spell_wintergrasp_defender_teleport_trigger_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
+ }
+ };
+
+ SpellScript* GetSpellScript() const override
{
- OnEffectHitTarget += SpellEffectFn(spell_wintergrasp_defender_teleport_trigger_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
+ return new spell_wintergrasp_defender_teleport_trigger_SpellScript();
}
- };
-
- SpellScript* GetSpellScript() const override
- {
- return new spell_wintergrasp_defender_teleport_trigger_SpellScript();
- }
};
class condition_is_wintergrasp_horde : public ConditionScript
{
-public:
- condition_is_wintergrasp_horde() : ConditionScript("condition_is_wintergrasp_horde") { }
+ public:
+ condition_is_wintergrasp_horde() : ConditionScript("condition_is_wintergrasp_horde") { }
- bool OnConditionCheck(Condition const* /* condition */, ConditionSourceInfo& /* sourceInfo */)
- {
- Battlefield* wintergrasp = sBattlefieldMgr->GetBattlefieldByBattleId(BATTLEFIELD_BATTLEID_WG);
- if (wintergrasp->IsEnabled() && wintergrasp->GetDefenderTeam() == TEAM_HORDE)
- return true;
- return false;
- }
+ bool OnConditionCheck(Condition const* /* condition */, ConditionSourceInfo& /* sourceInfo */)
+ {
+ Battlefield* wintergrasp = sBattlefieldMgr->GetBattlefieldByBattleId(BATTLEFIELD_BATTLEID_WG);
+ if (wintergrasp && wintergrasp->IsEnabled() && wintergrasp->GetDefenderTeam() == TEAM_HORDE)
+ return true;
+ return false;
+ }
};
class condition_is_wintergrasp_alliance : public ConditionScript
{
-public:
- condition_is_wintergrasp_alliance() : ConditionScript("condition_is_wintergrasp_alliance") { }
+ public:
+ condition_is_wintergrasp_alliance() : ConditionScript("condition_is_wintergrasp_alliance") { }
- bool OnConditionCheck(Condition const* /* condition */, ConditionSourceInfo& /* sourceInfo */)
- {
- Battlefield* wintergrasp = sBattlefieldMgr->GetBattlefieldByBattleId(BATTLEFIELD_BATTLEID_WG);
- if (wintergrasp->IsEnabled() && wintergrasp->GetDefenderTeam() == TEAM_ALLIANCE)
- return true;
- return false;
- }
+ bool OnConditionCheck(Condition const* /* condition */, ConditionSourceInfo& /* sourceInfo */)
+ {
+ Battlefield* wintergrasp = sBattlefieldMgr->GetBattlefieldByBattleId(BATTLEFIELD_BATTLEID_WG);
+ if (wintergrasp && wintergrasp->IsEnabled() && wintergrasp->GetDefenderTeam() == TEAM_ALLIANCE)
+ return true;
+ return false;
+ }
};
void AddSC_wintergrasp()
@@ -676,7 +596,7 @@ void AddSC_wintergrasp()
new npc_wg_spirit_guide();
new npc_wg_demolisher_engineer();
new go_wg_vehicle_teleporter();
- new npc_wg_quest_giver();
+ new npc_wg_give_promotion_credit();
new spell_wintergrasp_force_building();
new spell_wintergrasp_grab_passenger();
new achievement_wg_didnt_stand_a_chance();
diff --git a/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/shadow_labyrinth.cpp b/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/shadow_labyrinth.cpp
index 1b0d5c22833..bcfd40234b7 100644
--- a/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/shadow_labyrinth.cpp
+++ b/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/shadow_labyrinth.cpp
@@ -48,7 +48,7 @@ class spell_mark_of_malice : public SpellScriptLoader
if (aurEff->GetBase()->GetCharges() > 1)
return;
- GetTarget()->CastSpell(GetTarget(), SPELL_MARK_OF_MALICE_TRIGGERED, true);
+ GetTarget()->CastSpell(GetTarget(), SPELL_MARK_OF_MALICE_TRIGGERED, true, nullptr, aurEff);
}
void Register() override
diff --git a/src/server/scripts/Outland/BlackTemple/black_temple.h b/src/server/scripts/Outland/BlackTemple/black_temple.h
index 0856639f4c2..9d2c3dacb3f 100644
--- a/src/server/scripts/Outland/BlackTemple/black_temple.h
+++ b/src/server/scripts/Outland/BlackTemple/black_temple.h
@@ -47,27 +47,29 @@ enum DataTypes
DATA_BLOOD_ELF_COUNCIL_VOICE = 15,
DATA_GO_ILLIDAN_GATE = 16,
- DATA_GO_ILLIDAN_DOOR_R = 17,
- DATA_GO_ILLIDAN_DOOR_L = 18
};
enum CreatureIds
{
+ //Bosses
NPC_HIGH_WARLORD_NAJENTUS = 22887,
NPC_SUPREMUS = 22898,
NPC_SHADE_OF_AKAMA = 22841,
- NPC_AKAMA_SHADE = 23191, // This is the Akama that starts the Shade of Akama encounter.
- NPC_AKAMA = 23089, // This is the Akama that starts the Illidan encounter.
+ NPC_TERON_GOREFIEND = 22871,
+ NPC_GURTOGG_BLOODBOIL = 22948,
+ NPC_RELIQUARY_OF_SOULS = 22856,
+ NPC_MOTHER_SHAHRAZ = 22947,
+ NPC_ILLIDARI_COUNCIL = 23426,
+ NPC_ILLIDAN_STORMRAGE = 22917,
+ //Misc
NPC_GATHIOS_THE_SHATTERER = 22949,
NPC_HIGH_NETHERMANCER_ZEREVOR = 22950,
NPC_LADY_MALANDE = 22951,
NPC_VERAS_DARKSHADOW = 22952,
- NPC_ILLIDARI_COUNCIL = 23426,
NPC_BLOOD_ELF_COUNCIL_VOICE = 23499,
-
- NPC_ILLIDAN_STORMRAGE = 22917,
-
+ NPC_AKAMA = 23089, // This is the Akama that starts the Illidan encounter.
+ NPC_AKAMA_SHADE = 23191, // This is the Akama that starts the Shade of Akama encounter.
NPC_SUPREMUS_VOLCANO = 23085
};
diff --git a/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp b/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp
index a2215862219..07578b4c9ae 100644
--- a/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp
+++ b/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp
@@ -539,8 +539,7 @@ public:
void EnterCombat(Unit* /*who*/) override
{
me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC);
- me->setActive(true);
- DoZoneInCombat();
+ _EnterCombat();
}
void AttackStart(Unit* who) override
@@ -561,9 +560,6 @@ public:
{
me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
- for (uint8 i = DATA_GO_ILLIDAN_DOOR_R; i < DATA_GO_ILLIDAN_DOOR_L + 1; ++i)
- instance->HandleGameObject(instance->GetGuidData(i), true);
-
_JustDied();
}
@@ -1412,23 +1408,13 @@ public:
IllidanGUID = instance->GetGuidData(DATA_ILLIDAN_STORMRAGE);
GateGUID = instance->GetGuidData(DATA_GO_ILLIDAN_GATE);
- DoorGUID[0] = instance->GetGuidData(DATA_GO_ILLIDAN_DOOR_R);
- DoorGUID[1] = instance->GetGuidData(DATA_GO_ILLIDAN_DOOR_L);
if (JustCreated) // close all doors at create
- {
instance->HandleGameObject(GateGUID, false);
-
- 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
-
- for (uint8 i = 0; i < 2; ++i)
- instance->HandleGameObject(DoorGUID[i], true);
}
KillAllElites();
@@ -1480,9 +1466,6 @@ public:
void BeginTalk()
{
- instance->SetBossState(DATA_ILLIDAN_STORMRAGE, IN_PROGRESS);
- for (uint8 i = 0; i < 2; ++i)
- instance->HandleGameObject(DoorGUID[i], false);
if (Creature* illidan = ObjectAccessor::GetCreature(*me, IllidanGUID))
{
illidan->RemoveAurasDueToSpell(SPELL_KNEEL);
@@ -1674,10 +1657,6 @@ public:
{
switch (WalkCount)
{
- case 6:
- for (uint8 i = 0; i < 2; ++i)
- instance->HandleGameObject(DoorGUID[i], true);
- break;
case 8:
if (Phase == PHASE_WALK)
EnterPhase(PHASE_TALK);
@@ -1795,7 +1774,6 @@ public:
ObjectGuid ChannelGUID;
ObjectGuid SpiritGUID[2];
ObjectGuid GateGUID;
- ObjectGuid DoorGUID[2];
uint32 ChannelCount;
uint32 WalkCount;
uint32 TalkCount;
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 347843ec7ff..d83e9f8aed9 100644
--- a/src/server/scripts/Outland/BlackTemple/boss_shade_of_akama.cpp
+++ b/src/server/scripts/Outland/BlackTemple/boss_shade_of_akama.cpp
@@ -46,7 +46,7 @@ enum Spells
SPELL_FIXATE = 40607,
SPELL_CHAIN_LIGHTNING = 39945,
SPELL_DESTRUCTIVE_POISON = 40874,
- SPELL_AKAMA_SOUL_EXPEL = 40902,
+ SPELL_AKAMA_SOUL_RETRIEVE = 40902,
// Shade
SPELL_THREAT = 41602,
SPELL_SHADE_OF_AKAMA_TRIGGER = 40955,
@@ -108,7 +108,7 @@ enum Events
EVENT_CHAIN_LIGHTNING = 4,
EVENT_DESTRUCTIVE_POISON = 5,
EVENT_START_BROKEN_FREE = 6,
- EVENT_START_SOUL_EXPEL = 7,
+ EVENT_START_SOUL_RETRIEVE = 7,
EVENT_EVADE_CHECK = 8,
EVENT_BROKEN_FREE_1 = 9,
EVENT_BROKEN_FREE_2 = 10,
@@ -246,11 +246,11 @@ public:
events.ScheduleEvent(EVENT_START_CHANNELERS_AND_SPAWNERS, Seconds(1));
me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_NONE);
events.ScheduleEvent(EVENT_EVADE_CHECK, Seconds(10));
- if (Creature* akama = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_AKAMA_SHADE)))
+ if (Creature* akama = instance->GetCreature(DATA_AKAMA_SHADE))
AttackStart(akama);
}
- if (spell->Id == SPELL_AKAMA_SOUL_EXPEL)
+ if (spell->Id == SPELL_AKAMA_SOUL_RETRIEVE)
DoCastSelf(SPELL_AKAMA_SOUL_EXPEL_CHANNEL);
}
@@ -273,7 +273,7 @@ public:
{
DoCastSelf(SPELL_SHADE_OF_AKAMA_TRIGGER);
- if (Creature* akama = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_AKAMA_SHADE)))
+ if (Creature* akama = instance->GetCreature(DATA_AKAMA_SHADE))
akama->AI()->DoAction(ACTION_SHADE_OF_AKAMA_DEAD);
for (ObjectGuid const& spawnerGuid : _spawners)
@@ -401,7 +401,7 @@ public:
_isInCombat = true;
me->SetWalk(false);
me->RemoveAurasDueToSpell(SPELL_AKAMA_SOUL_CHANNEL);
- if (Creature* shade = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_SHADE_OF_AKAMA)))
+ if (Creature* shade = _instance->GetCreature(DATA_SHADE_OF_AKAMA))
{
shade->RemoveAurasDueToSpell(SPELL_AKAMA_SOUL_CHANNEL);
AttackStart(shade);
@@ -445,7 +445,7 @@ public:
{
me->SetWalk(false);
me->SetFacingTo(0.08726646f, true);
- _events.ScheduleEvent(EVENT_START_SOUL_EXPEL, Seconds(1));
+ _events.ScheduleEvent(EVENT_START_SOUL_RETRIEVE, Seconds(1));
}
}
@@ -489,14 +489,14 @@ public:
break;
case EVENT_CHAIN_LIGHTNING:
DoCastVictim(SPELL_CHAIN_LIGHTNING);
- _events.Repeat(randtime(Seconds(8), Seconds(15)));
+ _events.Repeat(Seconds(8), Seconds(15));
break;
case EVENT_DESTRUCTIVE_POISON:
DoCastSelf(SPELL_DESTRUCTIVE_POISON);
- _events.Repeat(randtime(Seconds(3), Seconds(7)));
+ _events.Repeat(Seconds(3), Seconds(7));
break;
- case EVENT_START_SOUL_EXPEL:
- DoCast(SPELL_AKAMA_SOUL_EXPEL);
+ case EVENT_START_SOUL_RETRIEVE:
+ DoCast(SPELL_AKAMA_SOUL_RETRIEVE);
_events.ScheduleEvent(EVENT_START_BROKEN_FREE, Seconds(15));
break;
case EVENT_START_BROKEN_FREE:
@@ -541,7 +541,7 @@ public:
{
_summons.DespawnAll();
Talk(SAY_DEAD);
- if (Creature* shade = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_SHADE_OF_AKAMA)))
+ if (Creature* shade = _instance->GetCreature(DATA_SHADE_OF_AKAMA))
if (shade->IsAlive())
shade->AI()->EnterEvadeMode(EVADE_REASON_OTHER);
}
@@ -587,7 +587,7 @@ public:
{
_scheduler.Schedule(Seconds(2), [this](TaskContext channel)
{
- if (Creature* shade = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_SHADE_OF_AKAMA)))
+ if (Creature* shade = _instance->GetCreature(DATA_SHADE_OF_AKAMA))
{
if (shade->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE))
DoCastSelf(SPELL_SHADE_SOUL_CHANNEL);
@@ -657,12 +657,12 @@ public:
if (_leftSide)
{
_events.ScheduleEvent(EVENT_SPAWN_WAVE_B, Milliseconds(100));
- _events.ScheduleEvent(EVENT_SUMMON_ASHTONGUE_SORCERER, randtime(Seconds(2), Seconds(5)));
+ _events.ScheduleEvent(EVENT_SUMMON_ASHTONGUE_SORCERER, Seconds(2), Seconds(5));
}
else
{
_events.ScheduleEvent(EVENT_SPAWN_WAVE_B, Seconds(10));
- _events.ScheduleEvent(EVENT_SUMMON_ASHTONGUE_DEFENDER, randtime(Seconds(2), Seconds(5)));
+ _events.ScheduleEvent(EVENT_SUMMON_ASHTONGUE_DEFENDER, Seconds(2), Seconds(5));
}
break;
case ACTION_STOP_SPAWNING:
@@ -687,15 +687,15 @@ public:
{
case EVENT_SPAWN_WAVE_B:
DoCastSelf(SPELL_ASHTONGUE_WAVE_B);
- _events.Repeat(randtime(Seconds(50), Seconds(60)));
+ _events.Repeat(Seconds(50), Seconds(60));
break;
case EVENT_SUMMON_ASHTONGUE_SORCERER: // left
DoCastSelf(SPELL_SUMMON_ASHTONGUE_SORCERER);
- _events.Repeat(randtime(Seconds(30), Seconds(35)));
+ _events.Repeat(Seconds(30), Seconds(35));
break;
case EVENT_SUMMON_ASHTONGUE_DEFENDER: // right
DoCastSelf(SPELL_SUMMON_ASHTONGUE_DEFENDER);
- _events.Repeat(randtime(Seconds(30), Seconds(40)));
+ _events.Repeat(Seconds(30), Seconds(40));
break;
default:
break;
@@ -736,16 +736,13 @@ public:
void Reset() override
{
- if (Creature* shade = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_SHADE_OF_AKAMA)))
+ if (Creature* shade = _instance->GetCreature(DATA_SHADE_OF_AKAMA))
{
if (shade->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE))
me->GetMotionMaster()->MovePoint(0, shade->GetPosition());
- else
- {
- if (Creature* akama = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_AKAMA_SHADE)))
- AttackStart(akama);
- }
+ else if (Creature* akama = _instance->GetCreature(DATA_AKAMA_SHADE))
+ AttackStart(akama);
}
Initialize();
}
@@ -777,7 +774,7 @@ public:
_scheduler.Schedule(Seconds(1) + Milliseconds(500), [this](TaskContext sorcer_channel)
{
- if (Creature* shade = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_SHADE_OF_AKAMA)))
+ if (Creature* shade = _instance->GetCreature(DATA_SHADE_OF_AKAMA))
{
if (shade->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE))
{
@@ -789,7 +786,7 @@ public:
{
me->InterruptSpell(CURRENT_CHANNELED_SPELL);
_switchToCombat = true;
- if (Creature* akama = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_AKAMA_SHADE)))
+ if (Creature* akama = _instance->GetCreature(DATA_AKAMA_SHADE))
AttackStart(akama);
}
}
@@ -837,7 +834,7 @@ public:
void Reset() override
{
- if (Creature* akama = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_AKAMA_SHADE)))
+ if (Creature* akama = _instance->GetCreature(DATA_AKAMA_SHADE))
AttackStart(akama);
}
@@ -849,9 +846,9 @@ public:
void EnterCombat(Unit* /*who*/) override
{
_events.ScheduleEvent(EVENT_HEROIC_STRIKE, Seconds(5));
- _events.ScheduleEvent(EVENT_SHIELD_BASH, randtime(Seconds(10), Seconds(16)));
- _events.ScheduleEvent(EVENT_DEBILITATING_STRIKE, randtime(Seconds(10), Seconds(16)));
- _events.ScheduleEvent(EVENT_WINDFURY, randtime(Seconds(8), Seconds(12)));
+ _events.ScheduleEvent(EVENT_SHIELD_BASH, Seconds(10), Seconds(16));
+ _events.ScheduleEvent(EVENT_DEBILITATING_STRIKE, Seconds(10), Seconds(16));
+ _events.ScheduleEvent(EVENT_WINDFURY, Seconds(8), Seconds(12));
}
@@ -868,19 +865,19 @@ public:
{
case EVENT_DEBILITATING_STRIKE:
DoCastVictim(SPELL_DEBILITATING_STRIKE);
- _events.Repeat(randtime(Seconds(20), Seconds(25)));
+ _events.Repeat(Seconds(20), Seconds(25));
break;
case EVENT_HEROIC_STRIKE:
DoCastSelf(SPELL_HEROIC_STRIKE);
- _events.Repeat(randtime(Seconds(5), Seconds(15)));
+ _events.Repeat(Seconds(5), Seconds(15));
break;
case EVENT_SHIELD_BASH:
DoCastVictim(SPELL_SHIELD_BASH);
- _events.Repeat(randtime(Seconds(10), Seconds(20)));
+ _events.Repeat(Seconds(10), Seconds(20));
break;
case EVENT_WINDFURY:
DoCastVictim(SPELL_WINDFURY);
- _events.Repeat(randtime(Seconds(6), Seconds(8)));
+ _events.Repeat(Seconds(6), Seconds(8));
break;
default:
break;
@@ -915,7 +912,7 @@ public:
void Reset() override
{
- if (Creature* akama = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_AKAMA_SHADE)))
+ if (Creature* akama = _instance->GetCreature(DATA_AKAMA_SHADE))
AttackStart(akama);
}
@@ -926,8 +923,8 @@ public:
void EnterCombat(Unit* /*who*/) override
{
- _events.ScheduleEvent(EVENT_DEBILITATING_POISON, randtime(Milliseconds(500), Seconds(2)));
- _events.ScheduleEvent(EVENT_EVISCERATE, randtime(Seconds(2), Seconds(5)));
+ _events.ScheduleEvent(EVENT_DEBILITATING_POISON, Milliseconds(500), Seconds(2));
+ _events.ScheduleEvent(EVENT_EVISCERATE, Seconds(2), Seconds(5));
}
void EnterEvadeMode(EvadeReason /*why*/) override { }
@@ -945,11 +942,11 @@ public:
{
case EVENT_DEBILITATING_POISON:
DoCastVictim(SPELL_DEBILITATING_POISON);
- _events.Repeat(randtime(Seconds(15), Seconds(20)));
+ _events.Repeat(Seconds(15), Seconds(20));
break;
case EVENT_EVISCERATE:
DoCastVictim(SPELL_EVISCERATE);
- _events.Repeat(randtime(Seconds(12), Seconds(20)));
+ _events.Repeat(Seconds(12), Seconds(20));
break;
default:
break;
@@ -984,7 +981,7 @@ public:
void Reset() override
{
- if (Creature* akama = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_AKAMA_SHADE)))
+ if (Creature* akama = _instance->GetCreature(DATA_AKAMA_SHADE))
AttackStart(akama);
}
@@ -1014,11 +1011,11 @@ public:
{
case EVENT_RAIN_OF_FIRE:
DoCastVictim(SPELL_RAIN_OF_FIRE);
- _events.Repeat(randtime(Seconds(15), Seconds(20)));
+ _events.Repeat(Seconds(15), Seconds(20));
break;
case EVENT_LIGHTNING_BOLT:
DoCastVictim(SPELL_LIGHTNING_BOLT);
- _events.Repeat(randtime(Seconds(8), Seconds(15)));
+ _events.Repeat(Seconds(8), Seconds(15));
break;
default:
break;
@@ -1062,7 +1059,7 @@ public:
{
Initialize();
- if (Creature* akama = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_AKAMA_SHADE)))
+ if (Creature* akama = _instance->GetCreature(DATA_AKAMA_SHADE))
AttackStart(akama);
}
@@ -1073,7 +1070,7 @@ public:
void EnterCombat(Unit* /*who*/) override
{
- _events.ScheduleEvent(EVENT_SPIRIT_HEAL, randtime(Seconds(5), Seconds(6)));
+ _events.ScheduleEvent(EVENT_SPIRIT_HEAL, Seconds(5), Seconds(6));
}
void DamageTaken(Unit* /*who*/, uint32& /*damage*/) override
@@ -1083,7 +1080,7 @@ public:
{
DoCastSelf(SPELL_SPIRIT_MEND);
_spiritMend = true;
- _events.ScheduleEvent(EVENT_SPIRIT_MEND_RESET, randtime(Seconds(10),Seconds(15)));
+ _events.ScheduleEvent(EVENT_SPIRIT_MEND_RESET, Seconds(10),Seconds(15));
}
if (!_chainHeal)
@@ -1091,7 +1088,7 @@ public:
{
DoCastSelf(SPELL_CHAIN_HEAL);
_chainHeal = true;
- _events.ScheduleEvent(EVENT_CHAIN_HEAL_RESET, randtime(Seconds(10), Seconds(15)));
+ _events.ScheduleEvent(EVENT_CHAIN_HEAL_RESET, Seconds(10), Seconds(15));
}
}
@@ -1108,7 +1105,7 @@ public:
{
case EVENT_SPIRIT_HEAL:
DoCastSelf(SPELL_SPIRITBINDER_SPIRIT_HEAL);
- _events.Repeat(randtime(Seconds(13), Seconds(16)));
+ _events.Repeat(Seconds(13), Seconds(16));
break;
case EVENT_SPIRIT_MEND_RESET:
_spiritMend = false;
@@ -1157,7 +1154,7 @@ public:
if (motionType != POINT_MOTION_TYPE)
return;
- if (Creature* akama = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_AKAMA_SHADE)))
+ if (Creature* akama = _instance->GetCreature(DATA_AKAMA_SHADE))
me->SetFacingToObject(akama);
}
diff --git a/src/server/scripts/Outland/BlackTemple/instance_black_temple.cpp b/src/server/scripts/Outland/BlackTemple/instance_black_temple.cpp
index bac996918ac..2784792fe8d 100644
--- a/src/server/scripts/Outland/BlackTemple/instance_black_temple.cpp
+++ b/src/server/scripts/Outland/BlackTemple/instance_black_temple.cpp
@@ -22,17 +22,20 @@
DoorData const doorData[] =
{
{ GO_NAJENTUS_GATE, DATA_HIGH_WARLORD_NAJENTUS, DOOR_TYPE_PASSAGE },
- { GO_NAJENTUS_GATE, DATA_SUPREMUS, DOOR_TYPE_ROOM },
+ { GO_NAJENTUS_GATE, DATA_SUPREMUS, DOOR_TYPE_ROOM },
{ GO_SUPREMUS_GATE, DATA_SUPREMUS, DOOR_TYPE_PASSAGE },
- { GO_SHADE_OF_AKAMA_DOOR, DATA_SHADE_OF_AKAMA, DOOR_TYPE_ROOM },
- { GO_TERON_DOOR_1, DATA_TERON_GOREFIEND, DOOR_TYPE_ROOM },
- { GO_TERON_DOOR_2, DATA_TERON_GOREFIEND, DOOR_TYPE_ROOM },
+ { GO_SHADE_OF_AKAMA_DOOR, DATA_SHADE_OF_AKAMA, DOOR_TYPE_ROOM },
+ { GO_TERON_DOOR_1, DATA_TERON_GOREFIEND, DOOR_TYPE_ROOM },
+ { GO_TERON_DOOR_2, DATA_TERON_GOREFIEND, DOOR_TYPE_ROOM },
{ GO_GURTOGG_DOOR, DATA_GURTOGG_BLOODBOIL, DOOR_TYPE_PASSAGE },
{ GO_TEMPLE_DOOR, DATA_RELIQUARY_OF_SOULS, DOOR_TYPE_PASSAGE },
{ GO_MOTHER_SHAHRAZ_DOOR, DATA_MOTHER_SHAHRAZ, DOOR_TYPE_PASSAGE },
- { GO_COUNCIL_DOOR_1, DATA_ILLIDARI_COUNCIL, DOOR_TYPE_ROOM },
- { GO_COUNCIL_DOOR_2, DATA_ILLIDARI_COUNCIL, DOOR_TYPE_ROOM },
- { 0, 0, DOOR_TYPE_ROOM } // END
+ { GO_COUNCIL_DOOR_1, DATA_ILLIDARI_COUNCIL, DOOR_TYPE_ROOM },
+ { GO_COUNCIL_DOOR_2, DATA_ILLIDARI_COUNCIL, DOOR_TYPE_ROOM },
+ //{ GO_ILLIDAN_GATE, DATA_GO_ILLIDAN_GATE, DOOR_TYPE_PASSAGE },
+ { GO_ILLIDAN_DOOR_R, DATA_ILLIDAN_STORMRAGE, DOOR_TYPE_ROOM },
+ { GO_ILLIDAN_DOOR_L, DATA_ILLIDAN_STORMRAGE, DOOR_TYPE_ROOM },
+ { 0, 0, DOOR_TYPE_ROOM } // END
};
BossBoundaryData const boundaries =
@@ -49,6 +52,27 @@ BossBoundaryData const boundaries =
{ DATA_ILLIDAN_STORMRAGE, new EllipseBoundary(Position(694.8f, 309.0f), 70.0 , 85.0) }
};
+ObjectData const creatureData[] =
+{
+ { NPC_HIGH_WARLORD_NAJENTUS, DATA_HIGH_WARLORD_NAJENTUS },
+ { NPC_SUPREMUS, DATA_SUPREMUS },
+ { NPC_SHADE_OF_AKAMA, DATA_SHADE_OF_AKAMA },
+ { NPC_TERON_GOREFIEND, DATA_TERON_GOREFIEND },
+ { NPC_GURTOGG_BLOODBOIL, DATA_GURTOGG_BLOODBOIL },
+ { NPC_RELIQUARY_OF_SOULS, DATA_RELIQUARY_OF_SOULS },
+ { NPC_MOTHER_SHAHRAZ, DATA_MOTHER_SHAHRAZ },
+ { NPC_ILLIDARI_COUNCIL, DATA_ILLIDARI_COUNCIL },
+ { NPC_ILLIDAN_STORMRAGE, DATA_ILLIDAN_STORMRAGE },
+ { NPC_AKAMA_SHADE, DATA_AKAMA_SHADE },
+ { NPC_AKAMA, DATA_AKAMA },
+ { NPC_GATHIOS_THE_SHATTERER, DATA_GATHIOS_THE_SHATTERER },
+ { NPC_HIGH_NETHERMANCER_ZEREVOR, DATA_HIGH_NETHERMANCER_ZEREVOR },
+ { NPC_LADY_MALANDE, DATA_LADY_MALANDE },
+ { NPC_VERAS_DARKSHADOW, DATA_VERAS_DARKSHADOW },
+ { NPC_BLOOD_ELF_COUNCIL_VOICE, DATA_BLOOD_ELF_COUNCIL_VOICE },
+ { 0, 0 } // end
+};
+
class instance_black_temple : public InstanceMapScript
{
public:
@@ -61,165 +85,28 @@ class instance_black_temple : public InstanceMapScript
SetHeaders(DataHeader);
SetBossNumber(EncounterCount);
LoadDoorData(doorData);
+ LoadObjectData(creatureData, nullptr);
LoadBossBoundaries(boundaries);
}
- void OnCreatureCreate(Creature* creature) override
- {
- switch (creature->GetEntry())
- {
- case NPC_HIGH_WARLORD_NAJENTUS:
- NajentusGUID = creature->GetGUID();
- break;
- case NPC_SUPREMUS:
- SupremusGUID = creature->GetGUID();
- break;
- case NPC_SHADE_OF_AKAMA:
- ShadeOfAkamaGUID = creature->GetGUID();
- break;
- case NPC_AKAMA_SHADE:
- AkamaShadeGUID = creature->GetGUID();
- break;
- case NPC_AKAMA:
- AkamaGUID = creature->GetGUID();
- break;
- case NPC_GATHIOS_THE_SHATTERER:
- GathiosTheShattererGUID = creature->GetGUID();
- break;
- case NPC_HIGH_NETHERMANCER_ZEREVOR:
- HighNethermancerZerevorGUID = creature->GetGUID();
- break;
- case NPC_LADY_MALANDE:
- LadyMalandeGUID = creature->GetGUID();
- break;
- case NPC_VERAS_DARKSHADOW:
- VerasDarkshadowGUID = creature->GetGUID();
- break;
- case NPC_ILLIDARI_COUNCIL:
- IllidariCouncilGUID = creature->GetGUID();
- break;
- case NPC_BLOOD_ELF_COUNCIL_VOICE:
- BloodElfCouncilVoiceGUID = creature->GetGUID();
- break;
- case NPC_ILLIDAN_STORMRAGE:
- IllidanStormrageGUID = creature->GetGUID();
- break;
- default:
- break;
- }
- }
-
void OnGameObjectCreate(GameObject* go) override
{
- switch (go->GetEntry())
- {
- case GO_NAJENTUS_GATE:
- case GO_SUPREMUS_GATE:
- case GO_SHADE_OF_AKAMA_DOOR:
- case GO_TERON_DOOR_1:
- case GO_TERON_DOOR_2:
- case GO_GURTOGG_DOOR:
- case GO_TEMPLE_DOOR:
- case GO_MOTHER_SHAHRAZ_DOOR:
- case GO_COUNCIL_DOOR_1:
- case GO_COUNCIL_DOOR_2:
- AddDoor(go, true);
- break;
- case GO_ILLIDAN_GATE:
- IllidanGateGUID = go->GetGUID();
- break;
- case GO_ILLIDAN_DOOR_R:
- IllidanDoorGUIDs[0] = go->GetGUID();
- break;
- case GO_ILLIDAN_DOOR_L:
- IllidanDoorGUIDs[1] = go->GetGUID();
- break;
- default:
- break;
- }
- }
+ if (go->GetEntry() == GO_ILLIDAN_GATE)
+ IllidanGateGUID = go->GetGUID();
- void OnGameObjectRemove(GameObject* go) override
- {
- switch (go->GetEntry())
- {
- case GO_NAJENTUS_GATE:
- case GO_SUPREMUS_GATE:
- case GO_SHADE_OF_AKAMA_DOOR:
- case GO_TERON_DOOR_1:
- case GO_TERON_DOOR_2:
- case GO_GURTOGG_DOOR:
- case GO_TEMPLE_DOOR:
- case GO_MOTHER_SHAHRAZ_DOOR:
- case GO_COUNCIL_DOOR_1:
- case GO_COUNCIL_DOOR_2:
- AddDoor(go, false);
- break;
- default:
- break;
- }
+ InstanceScript::OnGameObjectCreate(go);
}
ObjectGuid GetGuidData(uint32 type) const override
{
- switch (type)
- {
- case DATA_HIGH_WARLORD_NAJENTUS:
- return NajentusGUID;
- case DATA_SUPREMUS:
- return SupremusGUID;
- case DATA_SHADE_OF_AKAMA:
- return ShadeOfAkamaGUID;
- case DATA_AKAMA_SHADE:
- return AkamaShadeGUID;
- case DATA_AKAMA:
- return AkamaGUID;
- case DATA_GATHIOS_THE_SHATTERER:
- return GathiosTheShattererGUID;
- case DATA_HIGH_NETHERMANCER_ZEREVOR:
- return HighNethermancerZerevorGUID;
- case DATA_LADY_MALANDE:
- return LadyMalandeGUID;
- case DATA_VERAS_DARKSHADOW:
- return VerasDarkshadowGUID;
- case DATA_ILLIDARI_COUNCIL:
- return IllidariCouncilGUID;
- case DATA_BLOOD_ELF_COUNCIL_VOICE:
- return BloodElfCouncilVoiceGUID;
- case DATA_ILLIDAN_STORMRAGE:
- return IllidanStormrageGUID;
- case DATA_GO_ILLIDAN_GATE:
- return IllidanGateGUID;
- case DATA_GO_ILLIDAN_DOOR_R:
- return IllidanDoorGUIDs[0];
- case DATA_GO_ILLIDAN_DOOR_L:
- return IllidanDoorGUIDs[1];
- default:
- break;
- }
+ if (type == DATA_GO_ILLIDAN_GATE)
+ return IllidanGateGUID;
- return ObjectGuid::Empty;
+ return InstanceScript::GetGuidData(type);
}
protected:
- ObjectGuid NajentusGUID;
- ObjectGuid SupremusGUID;
- ObjectGuid ShadeOfAkamaGUID;
- ObjectGuid AkamaShadeGUID;
- ObjectGuid AkamaGUID;
-
- ObjectGuid GathiosTheShattererGUID;
- ObjectGuid HighNethermancerZerevorGUID;
- ObjectGuid LadyMalandeGUID;
- ObjectGuid VerasDarkshadowGUID;
-
- ObjectGuid IllidariCouncilGUID;
- ObjectGuid BloodElfCouncilVoiceGUID;
-
- ObjectGuid IllidanStormrageGUID;
-
ObjectGuid IllidanGateGUID;
- ObjectGuid IllidanDoorGUIDs[2];
};
InstanceScript* GetInstanceScript(InstanceMap* map) const override
diff --git a/src/server/scripts/Outland/boss_doomlord_kazzak.cpp b/src/server/scripts/Outland/boss_doomlord_kazzak.cpp
index f305c1e47be..daea6d24a4a 100644
--- a/src/server/scripts/Outland/boss_doomlord_kazzak.cpp
+++ b/src/server/scripts/Outland/boss_doomlord_kazzak.cpp
@@ -239,14 +239,14 @@ class spell_twisted_reflection : public SpellScriptLoader
return true;
}
- void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
+ void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
DamageInfo* damageInfo = eventInfo.GetDamageInfo();
if (!damageInfo || !damageInfo->GetDamage())
return;
- eventInfo.GetActionTarget()->CastSpell(eventInfo.GetActor(), SPELL_TWISTED_REFLECTION_HEAL, true);
+ eventInfo.GetActionTarget()->CastSpell(eventInfo.GetActor(), SPELL_TWISTED_REFLECTION_HEAL, true, nullptr, aurEff);
}
void Register() override
diff --git a/src/server/scripts/Outland/zone_hellfire_peninsula.cpp b/src/server/scripts/Outland/zone_hellfire_peninsula.cpp
index 90bf8bb1948..3b364d557ed 100644
--- a/src/server/scripts/Outland/zone_hellfire_peninsula.cpp
+++ b/src/server/scripts/Outland/zone_hellfire_peninsula.cpp
@@ -332,8 +332,14 @@ public:
enum FelGuard
{
- SPELL_SUMMON_POO = 37688,
- NPC_DERANGED_HELBOAR = 16863
+ SPELL_SUMMON_POO = 37688,
+ SPELL_FAKE_BLOOD = 37692,
+ NPC_DERANGED_HELBOAR = 16863,
+
+ EVENT_SEARCH_HELBOAR = 1,
+ EVENT_HELBOAR_FOUND = 2,
+ EVENT_SUMMON_POO = 3,
+ EVENT_FOLLOW_PLAYER = 4
};
class npc_fel_guard_hound : public CreatureScript
@@ -350,8 +356,8 @@ public:
void Initialize()
{
- checkTimer = 5000; //check for creature every 5 sec
helboarGUID.Clear();
+ _events.ScheduleEvent(EVENT_SEARCH_HELBOAR, Seconds(3));
}
void Reset() override
@@ -366,29 +372,54 @@ public:
if (Creature* helboar = ObjectAccessor::GetCreature(*me, helboarGUID))
{
- helboar->RemoveCorpse();
- DoCast(SPELL_SUMMON_POO);
-
- if (Player* owner = me->GetCharmerOrOwnerPlayerOrPlayerItself())
- me->GetMotionMaster()->MoveFollow(owner, 0.0f, 0.0f);
+ _events.CancelEvent(EVENT_SEARCH_HELBOAR);
+ me->HandleEmoteCommand(EMOTE_ONESHOT_ATTACK_UNARMED);
+ me->CastSpell(helboar, SPELL_FAKE_BLOOD);
+ _events.ScheduleEvent(EVENT_HELBOAR_FOUND, Seconds(2));
}
}
void UpdateAI(uint32 diff) override
{
- if (checkTimer <= diff)
+ _events.Update(diff);
+
+ while (uint32 eventId = _events.ExecuteEvent())
{
- if (Creature* helboar = me->FindNearestCreature(NPC_DERANGED_HELBOAR, 10.0f, false))
+ switch (eventId)
{
- if (helboar->GetGUID() != helboarGUID && me->GetMotionMaster()->GetCurrentMovementGeneratorType() != POINT_MOTION_TYPE && !me->FindCurrentSpellBySpellId(SPELL_SUMMON_POO))
- {
- helboarGUID = helboar->GetGUID();
- me->GetMotionMaster()->MovePoint(1, helboar->GetPositionX(), helboar->GetPositionY(), helboar->GetPositionZ());
- }
+ case EVENT_SEARCH_HELBOAR:
+ if (Creature* helboar = me->FindNearestCreature(NPC_DERANGED_HELBOAR, 10.0f, false))
+ {
+ if (helboar->GetGUID() != helboarGUID && me->GetMotionMaster()->GetCurrentMovementGeneratorType() != POINT_MOTION_TYPE && !me->FindCurrentSpellBySpellId(SPELL_SUMMON_POO))
+ {
+ helboarGUID = helboar->GetGUID();
+ me->SetWalk(true);
+ me->GetMotionMaster()->MovePoint(1, helboar->GetPositionX(), helboar->GetPositionY(), helboar->GetPositionZ());
+ helboar->DespawnOrUnsummon(Seconds(10));
+ }
+ }
+ _events.Repeat(Seconds(3));
+ break;
+ case EVENT_HELBOAR_FOUND:
+ if (Creature* helboar = ObjectAccessor::GetCreature(*me, helboarGUID))
+ {
+ me->HandleEmoteCommand(EMOTE_ONESHOT_ATTACK_UNARMED);
+ me->CastSpell(helboar, SPELL_FAKE_BLOOD);
+ _events.ScheduleEvent(EVENT_SUMMON_POO, Seconds(1));
+ }
+ break;
+ case EVENT_SUMMON_POO:
+ DoCast(SPELL_SUMMON_POO);
+ _events.ScheduleEvent(EVENT_FOLLOW_PLAYER, Seconds(2));
+ break;
+ case EVENT_FOLLOW_PLAYER:
+ me->SetWalk(false);
+ if (Player* owner = me->GetCharmerOrOwnerPlayerOrPlayerItself())
+ me->GetMotionMaster()->MoveFollow(owner, 0.0f, 0.0f);
+ _events.ScheduleEvent(EVENT_SEARCH_HELBOAR, Seconds(3));
+ break;
}
- checkTimer = 5000;
}
- else checkTimer -= diff;
if (!UpdateVictim())
return;
@@ -397,7 +428,7 @@ public:
}
private:
- uint32 checkTimer;
+ EventMap _events;
ObjectGuid helboarGUID;
};
@@ -892,6 +923,122 @@ public:
}
};
+enum Aledis
+{
+ SAY_CHALLENGE = 0,
+ SAY_DEFEATED = 1,
+ EVENT_TALK = 1,
+ EVENT_ATTACK = 2,
+ EVENT_EVADE = 3,
+ EVENT_FIREBALL = 4,
+ EVENT_FROSTNOVA = 5,
+ SPELL_FIREBALL = 20823,
+ SPELL_FROSTNOVA = 11831
+};
+
+class npc_magister_aledis : public CreatureScript
+{
+public:
+ npc_magister_aledis() : CreatureScript("npc_magister_aledis") { }
+
+ bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 /*action*/) override
+ {
+ CloseGossipMenuFor(player);
+ creature->StopMoving();
+ ENSURE_AI(npc_magister_aledis::npc_magister_aledisAI, creature->AI())->StartFight(player);
+ return true;
+ }
+
+ struct npc_magister_aledisAI : public ScriptedAI
+ {
+ npc_magister_aledisAI(Creature* creature) : ScriptedAI(creature) { }
+
+ void StartFight(Player* player)
+ {
+ me->Dismount();
+ me->SetFacingToObject(player, true);
+ me->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
+ _playerGUID = player->GetGUID();
+ _events.ScheduleEvent(EVENT_TALK, Seconds(2));
+ }
+
+ void Reset() override
+ {
+ me->RestoreFaction();
+ me->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER);
+ me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
+ me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC);
+ }
+
+ void DamageTaken(Unit* /*attacker*/, uint32 &damage) override
+ {
+ if (damage > me->GetHealth() || me->HealthBelowPctDamaged(20, damage))
+ {
+ damage = 0;
+
+ _events.Reset();
+ me->RestoreFaction();
+ me->RemoveAllAuras();
+ me->DeleteThreatList();
+ me->CombatStop(true);
+ me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER);
+ me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC);
+ Talk(SAY_DEFEATED);
+
+ _events.ScheduleEvent(EVENT_EVADE, Minutes(1));
+ }
+ }
+
+ void UpdateAI(uint32 diff) override
+ {
+ _events.Update(diff);
+
+ while (uint32 eventId = _events.ExecuteEvent())
+ {
+ switch (eventId)
+ {
+ case EVENT_TALK:
+ Talk(SAY_CHALLENGE);
+ _events.ScheduleEvent(EVENT_ATTACK, Seconds(2));
+ break;
+ case EVENT_ATTACK:
+ me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC);
+ me->setFaction(FACTION_HOSTILE);
+ me->CombatStart(ObjectAccessor::GetPlayer(*me, _playerGUID));
+ _events.ScheduleEvent(EVENT_FIREBALL, 1);
+ _events.ScheduleEvent(EVENT_FROSTNOVA, Seconds(5));
+ break;
+ case EVENT_FIREBALL:
+ DoCast(SPELL_FIREBALL);
+ _events.ScheduleEvent(EVENT_FIREBALL, Seconds(10));
+ break;
+ case EVENT_FROSTNOVA:
+ DoCastAOE(SPELL_FROSTNOVA);
+ _events.ScheduleEvent(EVENT_FROSTNOVA, Seconds(20));
+ break;
+ case EVENT_EVADE:
+ EnterEvadeMode();
+ break;
+ }
+ }
+
+ if (!UpdateVictim())
+ return;
+
+ DoMeleeAttackIfReady();
+ }
+
+ private:
+ EventMap _events;
+ ObjectGuid _playerGUID;
+ };
+
+ CreatureAI* GetAI(Creature* creature) const override
+ {
+ return new npc_magister_aledisAI(creature);
+ }
+};
+
void AddSC_hellfire_peninsula()
{
new npc_aeranas();
@@ -900,4 +1047,5 @@ void AddSC_hellfire_peninsula()
new npc_fel_guard_hound();
new npc_colonel_jules();
new npc_barada();
+ new npc_magister_aledis();
}
diff --git a/src/server/scripts/Pet/pet_hunter.cpp b/src/server/scripts/Pet/pet_hunter.cpp
index 7f6654bd6dd..7092300af4d 100644
--- a/src/server/scripts/Pet/pet_hunter.cpp
+++ b/src/server/scripts/Pet/pet_hunter.cpp
@@ -42,6 +42,10 @@ enum PetSpellsMisc
SPELL_PET_GUARD_DOG_HAPPINESS = 54445,
SPELL_PET_SILVERBACK_RANK_1 = 62800,
SPELL_PET_SILVERBACK_RANK_2 = 62801,
+
+ SPELL_PET_SWOOP = 52825,
+ SPELL_PET_CHARGE = 61685,
+
PET_ICON_ID_GROWL = 201,
PET_ICON_ID_CLAW = 262,
PET_ICON_ID_BITE = 1680,
@@ -152,6 +156,53 @@ class npc_pet_hunter_snake_trap : public CreatureScript
}
};
+// 57627 - Charge
+class spell_pet_charge : public SpellScriptLoader
+{
+ public:
+ spell_pet_charge() : SpellScriptLoader("spell_pet_charge") { }
+
+ class spell_pet_charge_AuraScript : public AuraScript
+ {
+ PrepareAuraScript(spell_pet_charge_AuraScript);
+
+ bool Validate(SpellInfo const* /*spellInfo*/) override
+ {
+ if (!sSpellMgr->GetSpellInfo(SPELL_PET_SWOOP) ||
+ !sSpellMgr->GetSpellInfo(SPELL_PET_CHARGE))
+ return false;
+ return true;
+ }
+
+ void HandleDummy(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
+ {
+ // Prevent console log
+ PreventDefaultAction();
+
+ // Remove +% AP aura
+ Unit* pet = eventInfo.GetActor();
+ Aura* aura = pet->GetAura(SPELL_PET_SWOOP, pet->GetGUID());
+ if (!aura)
+ aura = pet->GetAura(SPELL_PET_CHARGE, pet->GetGUID());
+
+ if (!aura)
+ return;
+
+ aura->DropCharge(AURA_REMOVE_BY_EXPIRE);
+ }
+
+ void Register() override
+ {
+ OnEffectProc += AuraEffectProcFn(spell_pet_charge_AuraScript::HandleDummy, EFFECT_0, SPELL_AURA_DUMMY);
+ }
+ };
+
+ AuraScript* GetAuraScript() const override
+ {
+ return new spell_pet_charge_AuraScript();
+ }
+};
+
// -53178 - Guard Dog
class spell_pet_guard_dog : public SpellScriptLoader
{
@@ -185,9 +236,9 @@ class spell_pet_guard_dog : public SpellScriptLoader
PreventDefaultAction();
Unit* caster = eventInfo.GetActor();
- caster->CastSpell((Unit*)nullptr, SPELL_PET_GUARD_DOG_HAPPINESS, true);
+ caster->CastSpell((Unit*)nullptr, SPELL_PET_GUARD_DOG_HAPPINESS, true, nullptr, aurEff);
- float addThreat = CalculatePct(eventInfo.GetSpellInfo()->Effects[EFFECT_0].CalcValue(caster), aurEff->GetAmount());
+ float addThreat = CalculatePct(ASSERT_NOTNULL(eventInfo.GetSpellInfo())->Effects[EFFECT_0].CalcValue(caster), aurEff->GetAmount());
eventInfo.GetProcTarget()->AddThreat(caster, addThreat);
}
@@ -232,14 +283,14 @@ class spell_pet_silverback : public SpellScriptLoader
return true;
}
- void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
+ void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
static uint32 const triggerSpell[2] = { SPELL_PET_SILVERBACK_RANK_1, SPELL_PET_SILVERBACK_RANK_2 };
PreventDefaultAction();
uint32 spellId = triggerSpell[GetSpellInfo()->GetRank() - 1];
- eventInfo.GetActor()->CastSpell((Unit*)nullptr, spellId, true);
+ eventInfo.GetActor()->CastSpell((Unit*)nullptr, spellId, true, nullptr, aurEff);
}
void Register() override
@@ -301,6 +352,7 @@ class spell_pet_culling_the_herd : public SpellScriptLoader
void AddSC_hunter_pet_scripts()
{
new npc_pet_hunter_snake_trap();
+ new spell_pet_charge();
new spell_pet_guard_dog();
new spell_pet_silverback();
new spell_pet_culling_the_herd();
diff --git a/src/server/scripts/Spells/spell_dk.cpp b/src/server/scripts/Spells/spell_dk.cpp
index b3612ec6428..13eec799493 100644
--- a/src/server/scripts/Spells/spell_dk.cpp
+++ b/src/server/scripts/Spells/spell_dk.cpp
@@ -129,9 +129,9 @@ public:
bool CheckProc(ProcEventInfo& eventInfo)
{
- if (eventInfo.GetDamageInfo())
+ if (DamageInfo* damageInfo = eventInfo.GetDamageInfo())
{
- switch (GetFirstSchoolInMask(eventInfo.GetDamageInfo()->GetSchoolMask()))
+ switch (GetFirstSchoolInMask(damageInfo->GetSchoolMask()))
{
case SPELL_SCHOOL_HOLY:
case SPELL_SCHOOL_FIRE:
@@ -529,8 +529,12 @@ class spell_dk_blood_gorged : public SpellScriptLoader
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
- int32 bp = int32(eventInfo.GetDamageInfo()->GetDamage() * 1.5f);
- GetTarget()->CastCustomSpell(SPELL_DK_BLOOD_GORGED_HEAL, SPELLVALUE_BASE_POINT0, bp, _procTarget, true, NULL, aurEff);
+ DamageInfo* damageInfo = eventInfo.GetDamageInfo();
+ if (!damageInfo || !damageInfo->GetDamage())
+ return;
+
+ int32 bp = static_cast<int32>(damageInfo->GetDamage() * 1.5f);
+ GetTarget()->CastCustomSpell(SPELL_DK_BLOOD_GORGED_HEAL, SPELLVALUE_BASE_POINT0, bp, _procTarget, true, nullptr, aurEff);
}
void Register() override
@@ -596,7 +600,7 @@ class spell_dk_butchery : public SpellScriptLoader
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
- eventInfo.GetActor()->CastCustomSpell(SPELL_DK_BUTCHERY_RUNIC_POWER, SPELLVALUE_BASE_POINT0, aurEff->GetAmount(), (Unit*)nullptr, true);
+ eventInfo.GetActor()->CastCustomSpell(SPELL_DK_BUTCHERY_RUNIC_POWER, SPELLVALUE_BASE_POINT0, aurEff->GetAmount(), (Unit*)nullptr, true, nullptr, aurEff);
}
void Register() override
@@ -1245,10 +1249,10 @@ class spell_dk_glyph_of_scourge_strike : public SpellScriptLoader
return true;
}
- void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
+ void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
- eventInfo.GetActor()->CastSpell(eventInfo.GetProcTarget(), SPELL_DK_GLYPH_OF_SCOURGE_STRIKE_SCRIPT, true);
+ eventInfo.GetActor()->CastSpell(eventInfo.GetProcTarget(), SPELL_DK_GLYPH_OF_SCOURGE_STRIKE_SCRIPT, true, nullptr, aurEff);
}
void Register() override
@@ -1436,7 +1440,7 @@ public:
{
PreventDefaultAction();
if (DamageInfo* dmgInfo = eventInfo.GetDamageInfo())
- eventInfo.GetActor()->CastCustomSpell(SPELL_DK_IMPROVED_BLOOD_PRESENCE_HEAL, SPELLVALUE_BASE_POINT0, CalculatePct(int32(dmgInfo->GetDamage()), aurEff->GetAmount()),
+ eventInfo.GetActor()->CastCustomSpell(SPELL_DK_IMPROVED_BLOOD_PRESENCE_HEAL, SPELLVALUE_BASE_POINT0, CalculatePct(static_cast<int32>(dmgInfo->GetDamage()), aurEff->GetAmount()),
eventInfo.GetActor(), true, nullptr, aurEff);
}
@@ -1584,10 +1588,10 @@ class spell_dk_pvp_4p_bonus : public SpellScriptLoader
return (spellInfo->GetAllEffectsMechanicMask() & ((1 << MECHANIC_ROOT) | (1 << MECHANIC_SNARE))) != 0;
}
- void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
+ void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
- eventInfo.GetActionTarget()->CastSpell((Unit*)nullptr, SPELL_DK_RUNIC_RETURN, true);
+ eventInfo.GetActionTarget()->CastSpell((Unit*)nullptr, SPELL_DK_RUNIC_RETURN, true, nullptr, aurEff);
}
void Register() override
@@ -1620,10 +1624,10 @@ class spell_dk_mark_of_blood : public SpellScriptLoader
return true;
}
- void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
+ void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
- eventInfo.GetActor()->CastSpell(eventInfo.GetProcTarget(), SPELL_DK_MARK_OF_BLOOD_HEAL, true);
+ eventInfo.GetActor()->CastSpell(eventInfo.GetProcTarget(), SPELL_DK_MARK_OF_BLOOD_HEAL, true, nullptr, aurEff);
}
void Register() override
@@ -1664,7 +1668,7 @@ class spell_dk_necrosis : public SpellScriptLoader
return;
int32 amount = CalculatePct(static_cast<int32>(damageInfo->GetDamage()), aurEff->GetAmount());
- eventInfo.GetActor()->CastCustomSpell(SPELL_DK_NECROSIS_DAMAGE, SPELLVALUE_BASE_POINT0, amount, eventInfo.GetProcTarget(), true);
+ eventInfo.GetActor()->CastCustomSpell(SPELL_DK_NECROSIS_DAMAGE, SPELLVALUE_BASE_POINT0, amount, eventInfo.GetProcTarget(), true, nullptr, aurEff);
}
void Register() override
@@ -2068,6 +2072,34 @@ class spell_dk_rime : public SpellScriptLoader
}
};
+// 56817 - Rune strike proc (Serverside spell)
+class spell_dk_rune_strike_proc : public SpellScriptLoader
+{
+ public:
+ spell_dk_rune_strike_proc() : SpellScriptLoader("spell_dk_rune_strike_proc") { }
+
+ class spell_dk_rune_strike_proc_AuraScript : public AuraScript
+ {
+ PrepareAuraScript(spell_dk_rune_strike_proc_AuraScript);
+
+ void HandleDummy(AuraEffect const* /*aurEff*/, ProcEventInfo& /*eventInfo*/)
+ {
+ // Prevent console log
+ PreventDefaultAction();
+ }
+
+ void Register() override
+ {
+ OnEffectProc += AuraEffectProcFn(spell_dk_rune_strike_proc_AuraScript::HandleDummy, EFFECT_0, SPELL_AURA_DUMMY);
+ }
+ };
+
+ AuraScript* GetAuraScript() const override
+ {
+ return new spell_dk_rune_strike_proc_AuraScript();
+ }
+};
+
// 59754 Rune Tap - Party
class spell_dk_rune_tap_party : public SpellScriptLoader
{
@@ -2295,7 +2327,7 @@ class spell_dk_sudden_doom : public SpellScriptLoader
return true;
}
- void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
+ void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
@@ -2315,7 +2347,7 @@ class spell_dk_sudden_doom : public SpellScriptLoader
if (!spellId)
return;
- caster->CastSpell(eventInfo.GetProcTarget(), spellId, true);
+ caster->CastSpell(eventInfo.GetProcTarget(), spellId, true, nullptr, aurEff);
}
void Register() override
@@ -2392,7 +2424,7 @@ class spell_dk_threat_of_thassarian : public SpellScriptLoader
return;
spellId = sSpellMgr->GetSpellWithRank(spellId, spellInfo->GetRank());
- caster->CastSpell(eventInfo.GetProcTarget(), spellId, true);
+ caster->CastSpell(eventInfo.GetProcTarget(), spellId, true, nullptr, aurEff);
}
void Register() override
@@ -2446,7 +2478,7 @@ class spell_dk_unholy_blight : public SpellScriptLoader
// Add remaining ticks to healing done
amount += target->GetRemainingPeriodicAmount(caster->GetGUID(), SPELL_DK_UNHOLY_BLIGHT_DAMAGE, SPELL_AURA_PERIODIC_DAMAGE);
- caster->CastCustomSpell(SPELL_DK_UNHOLY_BLIGHT_DAMAGE, SPELLVALUE_BASE_POINT0, amount, target, true);
+ caster->CastCustomSpell(SPELL_DK_UNHOLY_BLIGHT_DAMAGE, SPELLVALUE_BASE_POINT0, amount, target, true, nullptr, aurEff);
}
void Register() override
@@ -2509,7 +2541,7 @@ class spell_dk_vendetta : public SpellScriptLoader
PreventDefaultAction();
Unit* caster = eventInfo.GetActor();
int32 amount = caster->CountPctFromMaxHealth(aurEff->GetAmount());
- caster->CastCustomSpell(SPELL_DK_VENDETTA_HEAL, SPELLVALUE_BASE_POINT0, amount, (Unit*)nullptr, true);
+ caster->CastCustomSpell(SPELL_DK_VENDETTA_HEAL, SPELLVALUE_BASE_POINT0, amount, (Unit*)nullptr, true, nullptr, aurEff);
}
void Register() override
@@ -2554,7 +2586,7 @@ class spell_dk_wandering_plague : public SpellScriptLoader
return;
int32 amount = CalculatePct(static_cast<int32>(damageInfo->GetDamage()), aurEff->GetAmount());
- caster->CastCustomSpell(SPELL_DK_WANDERING_PLAGUE_DAMAGE, SPELLVALUE_BASE_POINT0, amount, target, true);
+ caster->CastCustomSpell(SPELL_DK_WANDERING_PLAGUE_DAMAGE, SPELLVALUE_BASE_POINT0, amount, target, true, nullptr, aurEff);
}
void Register() override
@@ -2769,17 +2801,25 @@ public:
class player_ghoulAI : public PlayerAI
{
public:
- player_ghoulAI(Player* player, ObjectGuid ghoulGUID) : PlayerAI(player), _ghoulGUID(ghoulGUID) { }
+ player_ghoulAI(Player* player, ObjectGuid ghoulGUID) : PlayerAI(player), _ghoulGUID(ghoulGUID), _ghoulCheckTimer(1000){ }
- void UpdateAI(uint32 /*diff*/) override
+ void UpdateAI(uint32 diff) override
{
- Creature* ghoul = ObjectAccessor::GetCreature(*me, _ghoulGUID);
- if (!ghoul || !ghoul->IsAlive())
- me->RemoveAura(SPELL_DK_RAISE_ALLY);
+ if (_ghoulCheckTimer <= diff)
+ {
+ _ghoulCheckTimer = 1000;
+
+ Creature* ghoul = ObjectAccessor::GetCreature(*me, _ghoulGUID);
+ if (!ghoul || !ghoul->IsAlive())
+ me->RemoveAura(SPELL_DK_RAISE_ALLY);
+ }
+ else
+ _ghoulCheckTimer -= diff;
}
private:
ObjectGuid _ghoulGUID;
+ uint32 _ghoulCheckTimer;
};
// 46619 - Raise Ally
@@ -2801,7 +2841,7 @@ public:
void SendText()
{
if (Unit* original = GetOriginalCaster())
- original->Whisper(TEXT_RISE_ALLY, GetCaster()->ToPlayer(), true);
+ original->Unit::Whisper(TEXT_RISE_ALLY, GetCaster()->ToPlayer(), true);
}
void HandleSummon(SpellEffIndex effIndex)
@@ -3028,6 +3068,7 @@ void AddSC_deathknight_spell_scripts()
new spell_dk_presence();
new spell_dk_raise_dead();
new spell_dk_rime();
+ new spell_dk_rune_strike_proc();
new spell_dk_rune_tap_party();
new spell_dk_scent_of_blood();
new spell_dk_scent_of_blood_trigger();
diff --git a/src/server/scripts/Spells/spell_druid.cpp b/src/server/scripts/Spells/spell_druid.cpp
index 3e03316d9e4..56624346772 100644
--- a/src/server/scripts/Spells/spell_druid.cpp
+++ b/src/server/scripts/Spells/spell_druid.cpp
@@ -201,68 +201,90 @@ class spell_dru_dash : public SpellScriptLoader
}
};
+// -48516 - Eclipse
class spell_dru_eclipse : public SpellScriptLoader
{
-public:
- spell_dru_eclipse() : SpellScriptLoader("spell_dru_eclipse") { }
-
- class spell_dru_eclipse_AuraScript : public AuraScript
- {
- PrepareAuraScript(spell_dru_eclipse_AuraScript);
+ public:
+ spell_dru_eclipse() : SpellScriptLoader("spell_dru_eclipse") { }
- bool Validate(SpellInfo const* /*spellInfo*/) override
+ class spell_dru_eclipse_AuraScript : public AuraScript
{
- if (!sSpellMgr->GetSpellInfo(SPELL_DRUID_ECLIPSE_LUNAR_PROC))
- return false;
- if (!sSpellMgr->GetSpellInfo(SPELL_DRUID_ECLIPSE_SOLAR_PROC))
- return false;
- return true;
- }
+ PrepareAuraScript(spell_dru_eclipse_AuraScript);
- bool CheckProc(ProcEventInfo& eventInfo)
- {
- if (!eventInfo.GetSpellInfo())
- return false;
+ bool Validate(SpellInfo const* /*spellInfo*/) override
+ {
+ if (!sSpellMgr->GetSpellInfo(SPELL_DRUID_ECLIPSE_LUNAR_PROC))
+ return false;
+ if (!sSpellMgr->GetSpellInfo(SPELL_DRUID_ECLIPSE_SOLAR_PROC))
+ return false;
+ return true;
+ }
- if (eventInfo.GetActor()->HasAura(SPELL_DRUID_ECLIPSE_LUNAR_PROC) || eventInfo.GetActor()->HasAura(SPELL_DRUID_ECLIPSE_SOLAR_PROC))
- return false;
+ bool CheckProc(ProcEventInfo& eventInfo)
+ {
+ if (eventInfo.GetActor()->HasAura(SPELL_DRUID_ECLIPSE_LUNAR_PROC) || eventInfo.GetActor()->HasAura(SPELL_DRUID_ECLIPSE_SOLAR_PROC))
+ return false;
- // Triggered by Wrath?
- if (eventInfo.GetSpellInfo()->SpellFamilyFlags[0] & 1)
- return roll_chance_f(GetSpellInfo()->ProcChance * 0.6f) && _lunarProcCooldownEnd <= std::chrono::steady_clock::now();
+ return true;
+ }
- return _solarProcCooldownEnd <= std::chrono::steady_clock::now();
- }
+ bool CheckSolar(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
+ {
+ SpellInfo const* spellInfo = eventInfo.GetSpellInfo();
+ if (!spellInfo || !(spellInfo->SpellFamilyFlags[0] & 4)) // Starfire
+ return false;
- void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
- {
- PreventDefaultAction();
- if (eventInfo.GetSpellInfo()->SpellFamilyFlags[0] & 1)
+ return _solarProcCooldownEnd <= std::chrono::steady_clock::now();
+ }
+
+ bool CheckLunar(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
{
- _lunarProcCooldownEnd = std::chrono::steady_clock::now() + Seconds(aurEff->GetAmount());
- eventInfo.GetActor()->CastSpell(eventInfo.GetActor(), SPELL_DRUID_ECLIPSE_LUNAR_PROC, TRIGGERED_FULL_MASK, nullptr, aurEff);
+ SpellInfo const* spellInfo = eventInfo.GetSpellInfo();
+ if (!spellInfo || !(spellInfo->SpellFamilyFlags[0] & 1)) // Wrath
+ return false;
+
+ // Reduced lunar proc chance (60% of normal)
+ if (!roll_chance_i(60))
+ return false;
+
+ return _lunarProcCooldownEnd <= std::chrono::steady_clock::now();
}
- else
+
+ void ProcSolar(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
- _solarProcCooldownEnd = std::chrono::steady_clock::now() + Seconds(aurEff->GetAmount());
+ PreventDefaultAction();
+
+ _solarProcCooldownEnd = std::chrono::steady_clock::now() + Seconds(30);
eventInfo.GetActor()->CastSpell(eventInfo.GetActor(), SPELL_DRUID_ECLIPSE_SOLAR_PROC, TRIGGERED_FULL_MASK, nullptr, aurEff);
}
- }
- void Register() override
- {
- DoCheckProc += AuraCheckProcFn(spell_dru_eclipse_AuraScript::CheckProc);
- OnEffectProc += AuraEffectProcFn(spell_dru_eclipse_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_DUMMY);
- }
+ void ProcLunar(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
+ {
+ PreventDefaultAction();
- std::chrono::steady_clock::time_point _lunarProcCooldownEnd = std::chrono::steady_clock::time_point::min();
- std::chrono::steady_clock::time_point _solarProcCooldownEnd = std::chrono::steady_clock::time_point::min();
- };
+ _lunarProcCooldownEnd = std::chrono::steady_clock::now() + Seconds(30);
+ eventInfo.GetActor()->CastSpell(eventInfo.GetActor(), SPELL_DRUID_ECLIPSE_LUNAR_PROC, TRIGGERED_FULL_MASK, nullptr, aurEff);
+ }
- AuraScript* GetAuraScript() const override
- {
- return new spell_dru_eclipse_AuraScript();
- }
+ void Register() override
+ {
+ DoCheckProc += AuraCheckProcFn(spell_dru_eclipse_AuraScript::CheckProc);
+
+ DoCheckEffectProc += AuraCheckEffectProcFn(spell_dru_eclipse_AuraScript::CheckSolar, EFFECT_0, SPELL_AURA_DUMMY);
+ DoCheckEffectProc += AuraCheckEffectProcFn(spell_dru_eclipse_AuraScript::CheckLunar, EFFECT_1, SPELL_AURA_DUMMY);
+
+ OnEffectProc += AuraEffectProcFn(spell_dru_eclipse_AuraScript::ProcSolar, EFFECT_0, SPELL_AURA_DUMMY);
+ OnEffectProc += AuraEffectProcFn(spell_dru_eclipse_AuraScript::ProcLunar, EFFECT_1, SPELL_AURA_DUMMY);
+ }
+
+ std::chrono::steady_clock::time_point _lunarProcCooldownEnd = std::chrono::steady_clock::time_point::min();
+ std::chrono::steady_clock::time_point _solarProcCooldownEnd = std::chrono::steady_clock::time_point::min();
+ };
+
+ AuraScript* GetAuraScript() const override
+ {
+ return new spell_dru_eclipse_AuraScript();
+ }
};
// 5229 - Enrage
@@ -464,10 +486,10 @@ class spell_dru_glyph_of_barkskin : public SpellScriptLoader
return true;
}
- void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
+ void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
- eventInfo.GetActor()->CastSpell((Unit*)nullptr, SPELL_DRUID_BARKSKIN_01, true);
+ eventInfo.GetActor()->CastSpell((Unit*)nullptr, SPELL_DRUID_BARKSKIN_01, true, nullptr, aurEff);
}
void Register() override
@@ -508,7 +530,7 @@ class spell_dru_glyph_of_innervate : public SpellScriptLoader
int32 amount = CalculatePct(static_cast<int32>(caster->GetCreatePowers(POWER_MANA)), aurEff->GetAmount());
amount /= spellInfo->GetMaxTicks();
- caster->CastCustomSpell(SPELL_DRUID_GLYPH_OF_INNERVATE_REGEN, SPELLVALUE_BASE_POINT0, amount, (Unit*)nullptr, true);
+ caster->CastCustomSpell(SPELL_DRUID_GLYPH_OF_INNERVATE_REGEN, SPELLVALUE_BASE_POINT0, amount, (Unit*)nullptr, true, nullptr, aurEff);
}
void Register() override
@@ -545,10 +567,10 @@ class spell_dru_glyph_of_rake : public SpellScriptLoader
return eventInfo.GetProcTarget()->GetTypeId() == TYPEID_UNIT;
}
- void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
+ void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
- eventInfo.GetActor()->CastSpell(eventInfo.GetProcTarget(), SPELL_DRUID_GLYPH_OF_RAKE_TRIGGERED, true);
+ eventInfo.GetActor()->CastSpell(eventInfo.GetProcTarget(), SPELL_DRUID_GLYPH_OF_RAKE_TRIGGERED, true, nullptr, aurEff);
}
void Register() override
@@ -594,7 +616,7 @@ class spell_dru_glyph_of_rejuvenation : public SpellScriptLoader
return;
int32 amount = CalculatePct(static_cast<int32>(healInfo->GetHeal()), aurEff->GetAmount());
- eventInfo.GetActor()->CastCustomSpell(SPELL_DRUID_GLYPH_OF_REJUVENATION_HEAL, SPELLVALUE_BASE_POINT0, amount, eventInfo.GetProcTarget(), true);
+ eventInfo.GetActor()->CastCustomSpell(SPELL_DRUID_GLYPH_OF_REJUVENATION_HEAL, SPELLVALUE_BASE_POINT0, amount, eventInfo.GetProcTarget(), true, nullptr, aurEff);
}
void Register() override
@@ -740,10 +762,10 @@ class spell_dru_glyph_of_starfire_dummy : public SpellScriptLoader
return true;
}
- void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
+ void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
- eventInfo.GetActor()->CastSpell(eventInfo.GetProcTarget(), SPELL_DRUID_GLYPH_OF_STARFIRE_SCRIPT, true);
+ eventInfo.GetActor()->CastSpell(eventInfo.GetProcTarget(), SPELL_DRUID_GLYPH_OF_STARFIRE_SCRIPT, true, nullptr, aurEff);
}
void Register() override
@@ -883,7 +905,7 @@ class spell_dru_leader_of_the_pack : public SpellScriptLoader
return;
int32 amount = caster->CountPctFromMaxHealth(aurEff->GetAmount());
- caster->CastCustomSpell(SPELL_DRUID_IMP_LEADER_OF_THE_PACK_HEAL, SPELLVALUE_BASE_POINT0, amount, (Unit*)nullptr, true);
+ caster->CastCustomSpell(SPELL_DRUID_IMP_LEADER_OF_THE_PACK_HEAL, SPELLVALUE_BASE_POINT0, amount, (Unit*)nullptr, true, nullptr, aurEff);
// Because of how proc system works, we can't store proc cd on db, it would be applied to entire aura
// so aura could only proc once per 6 seconds, independently of caster
@@ -893,12 +915,11 @@ class spell_dru_leader_of_the_pack : public SpellScriptLoader
if (aurEff->GetCasterGUID() != caster->GetGUID())
return;
- AuraEffect const* impLotpMana = caster->GetAuraEffectOfRankedSpell(SPELL_DRUID_IMP_LEADER_OF_THE_PACK_R1, EFFECT_1, aurEff->GetCasterGUID());
- if (!impLotpMana)
- return;
+ AuraEffect const* impLotpMana = caster->GetAuraEffectOfRankedSpell(SPELL_DRUID_IMP_LEADER_OF_THE_PACK_R1, EFFECT_0, aurEff->GetCasterGUID());
+ ASSERT(impLotpMana);
- int32 manaAmount = CalculatePct(static_cast<int32>(caster->GetMaxPower(POWER_MANA)), impLotpMana->GetAmount());
- caster->CastCustomSpell(SPELL_DRUID_IMP_LEADER_OF_THE_PACK_MANA, SPELLVALUE_BASE_POINT0, manaAmount, (Unit*)nullptr, true);
+ int32 manaAmount = CalculatePct(static_cast<int32>(caster->GetMaxPower(POWER_MANA)), impLotpMana->GetSpellInfo()->Effects[EFFECT_1].CalcValue());
+ caster->CastCustomSpell(SPELL_DRUID_IMP_LEADER_OF_THE_PACK_MANA, SPELLVALUE_BASE_POINT0, manaAmount, (Unit*)nullptr, true, nullptr, aurEff);
}
void Register() override
@@ -1021,7 +1042,7 @@ class spell_dru_living_seed : public SpellScriptLoader
return;
int32 amount = CalculatePct(healInfo->GetHeal(), aurEff->GetAmount());
- GetTarget()->CastCustomSpell(SPELL_DRUID_LIVING_SEED_PROC, SPELLVALUE_BASE_POINT0, amount, eventInfo.GetProcTarget(), true, NULL, aurEff);
+ GetTarget()->CastCustomSpell(SPELL_DRUID_LIVING_SEED_PROC, SPELLVALUE_BASE_POINT0, amount, eventInfo.GetProcTarget(), true, nullptr, aurEff);
}
void Register() override
@@ -1140,11 +1161,11 @@ class spell_dru_omen_of_clarity : public SpellScriptLoader
return true;
}
- void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& /*eventInfo*/)
+ void HandleProc(AuraEffect const* aurEff, ProcEventInfo& /*eventInfo*/)
{
Unit* target = GetTarget();
if (target->HasAura(SPELL_DRUID_BALANCE_T10_BONUS))
- target->CastSpell((Unit*)nullptr, SPELL_DRUID_BALANCE_T10_BONUS_PROC, true, nullptr);
+ target->CastSpell((Unit*)nullptr, SPELL_DRUID_BALANCE_T10_BONUS_PROC, true, nullptr, aurEff);
}
void Register() override
@@ -1313,7 +1334,7 @@ class spell_dru_revitalize : public SpellScriptLoader
return;
}
- eventInfo.GetActor()->CastSpell(target, spellId, true);
+ eventInfo.GetActor()->CastSpell(target, spellId, true, nullptr, aurEff);
}
void Register() override
@@ -1398,7 +1419,7 @@ class spell_dru_savage_defense : public SpellScriptLoader
PreventDefaultAction();
Unit* caster = eventInfo.GetActor();
int32 amount = static_cast<int32>(CalculatePct(caster->GetTotalAttackPowerValue(BASE_ATTACK), aurEff->GetAmount()));
- caster->CastCustomSpell(GetSpellInfo()->Effects[aurEff->GetEffIndex()].TriggerSpell, SPELLVALUE_BASE_POINT0, amount, (Unit*)nullptr, true);
+ caster->CastCustomSpell(GetSpellInfo()->Effects[aurEff->GetEffIndex()].TriggerSpell, SPELLVALUE_BASE_POINT0, amount, (Unit*)nullptr, true, nullptr, aurEff);
}
void Register() override
@@ -1591,7 +1612,7 @@ class spell_dru_survival_instincts : public SpellScriptLoader
{
Unit* target = GetTarget();
int32 bp0 = target->CountPctFromMaxHealth(aurEff->GetAmount());
- target->CastCustomSpell(target, SPELL_DRUID_SURVIVAL_INSTINCTS, &bp0, NULL, NULL, true);
+ target->CastCustomSpell(target, SPELL_DRUID_SURVIVAL_INSTINCTS, &bp0, nullptr, nullptr, true, nullptr, aurEff);
}
void AfterRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
@@ -1632,7 +1653,7 @@ class spell_dru_swift_flight_passive : public SpellScriptLoader
return GetCaster()->GetTypeId() == TYPEID_PLAYER;
}
- void CalculateAmount(AuraEffect const* /*aurEff*/, int32 & amount, bool & /*canBeRecalculated*/)
+ void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool & /*canBeRecalculated*/)
{
if (Player* caster = GetCaster()->ToPlayer())
if (caster->Has310Flyer(false))
@@ -1734,7 +1755,7 @@ class spell_dru_t3_2p_bonus : public SpellScriptLoader
return true;
}
- void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
+ void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
Unit* target = eventInfo.GetProcTarget();
@@ -1755,7 +1776,7 @@ class spell_dru_t3_2p_bonus : public SpellScriptLoader
return;
}
- eventInfo.GetActor()->CastSpell(target, spellId, true);
+ eventInfo.GetActor()->CastSpell(target, spellId, true, nullptr, aurEff);
}
void Register() override
@@ -1788,10 +1809,10 @@ class spell_dru_t3_6p_bonus : public SpellScriptLoader
return true;
}
- void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
+ void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
- eventInfo.GetActor()->CastSpell(eventInfo.GetProcTarget(), SPELL_DRUID_BLESSING_OF_THE_CLAW, true);
+ eventInfo.GetActor()->CastSpell(eventInfo.GetProcTarget(), SPELL_DRUID_BLESSING_OF_THE_CLAW, true, nullptr, aurEff);
}
void Register() override
@@ -1832,7 +1853,7 @@ class spell_dru_t3_8p_bonus : public SpellScriptLoader
Unit* caster = eventInfo.GetActor();
int32 amount = CalculatePct(spellInfo->CalcPowerCost(caster, spellInfo->GetSchoolMask()), aurEff->GetAmount());
- caster->CastCustomSpell(SPELL_DRUID_EXHILARATE, SPELLVALUE_BASE_POINT0, amount, (Unit*)nullptr, true);
+ caster->CastCustomSpell(SPELL_DRUID_EXHILARATE, SPELLVALUE_BASE_POINT0, amount, (Unit*)nullptr, true, nullptr, aurEff);
}
void Register() override
@@ -1865,10 +1886,10 @@ class spell_dru_t4_2p_bonus : public SpellScriptLoader
return true;
}
- void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
+ void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
- eventInfo.GetActor()->CastSpell((Unit*)nullptr, SPELL_DRUID_INFUSION, true);
+ eventInfo.GetActor()->CastSpell((Unit*)nullptr, SPELL_DRUID_INFUSION, true, nullptr, aurEff);
}
void Register() override
@@ -1902,7 +1923,7 @@ class spell_dru_item_t6_trinket : public SpellScriptLoader
return true;
}
- void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
+ void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
SpellInfo const* spellInfo = eventInfo.GetSpellInfo();
@@ -1934,7 +1955,7 @@ class spell_dru_item_t6_trinket : public SpellScriptLoader
return;
if (roll_chance_i(chance))
- eventInfo.GetActor()->CastSpell((Unit*)nullptr, spellId, true);
+ eventInfo.GetActor()->CastSpell((Unit*)nullptr, spellId, true, nullptr, aurEff);
}
void Register() override
@@ -2054,7 +2075,7 @@ class spell_dru_t10_balance_4p_bonus : public SpellScriptLoader
// Add remaining ticks to damage done
amount += target->GetRemainingPeriodicAmount(caster->GetGUID(), SPELL_DRUID_LANGUISH, SPELL_AURA_PERIODIC_DAMAGE);
- caster->CastCustomSpell(SPELL_DRUID_LANGUISH, SPELLVALUE_BASE_POINT0, amount, target, true);
+ caster->CastCustomSpell(SPELL_DRUID_LANGUISH, SPELLVALUE_BASE_POINT0, amount, target, true, nullptr, aurEff);
}
void Register() override
@@ -2158,12 +2179,12 @@ class spell_dru_t10_restoration_4p_bonus_dummy : public SpellScriptLoader
return caster->GetGroup() || caster != eventInfo.GetProcTarget();
}
- void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
+ void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
int32 amount = static_cast<int32>(eventInfo.GetHealInfo()->GetHeal());
- eventInfo.GetActor()->CastCustomSpell(SPELL_DRUID_REJUVENATION_T10_PROC, SPELLVALUE_BASE_POINT0, amount, (Unit*)nullptr, true);
+ eventInfo.GetActor()->CastCustomSpell(SPELL_DRUID_REJUVENATION_T10_PROC, SPELLVALUE_BASE_POINT0, amount, (Unit*)nullptr, true, nullptr, aurEff);
}
void Register() override
diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp
index a8d71d57297..d0fcd1080bb 100644
--- a/src/server/scripts/Spells/spell_generic.cpp
+++ b/src/server/scripts/Spells/spell_generic.cpp
@@ -113,7 +113,8 @@ class spell_gen_adaptive_warding : public SpellScriptLoader
bool CheckProc(ProcEventInfo& eventInfo)
{
- if (eventInfo.GetDamageInfo()->GetSpellInfo()) // eventInfo.GetSpellInfo()
+ DamageInfo* damageInfo = eventInfo.GetDamageInfo();
+ if (!damageInfo || !damageInfo->GetSpellInfo())
return false;
// find Mage Armor
@@ -156,7 +157,7 @@ class spell_gen_adaptive_warding : public SpellScriptLoader
default:
return;
}
- GetTarget()->CastSpell(GetTarget(), spellId, true, NULL, aurEff);
+ GetTarget()->CastSpell(GetTarget(), spellId, true, nullptr, aurEff);
}
void Register() override
@@ -1099,9 +1100,17 @@ class spell_gen_creature_permanent_feign_death : public SpellScriptLoader
target->ToCreature()->SetReactState(REACT_PASSIVE);
}
+ void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
+ {
+ Unit* target = GetTarget();
+ target->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_DEAD);
+ target->RemoveFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FEIGN_DEATH);
+ }
+
void Register() override
{
OnEffectApply += AuraEffectApplyFn(spell_gen_creature_permanent_feign_death_AuraScript::HandleEffectApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
+ OnEffectRemove += AuraEffectRemoveFn(spell_gen_creature_permanent_feign_death_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
}
};
@@ -2312,7 +2321,8 @@ class spell_gen_obsidian_armor : public SpellScriptLoader
bool CheckProc(ProcEventInfo& eventInfo)
{
- if (eventInfo.GetDamageInfo()->GetSpellInfo()) // eventInfo.GetSpellInfo()
+ DamageInfo* damageInfo = eventInfo.GetDamageInfo();
+ if (!damageInfo || !damageInfo->GetSpellInfo())
return false;
if (GetFirstSchoolInMask(eventInfo.GetSchoolMask()) == SPELL_SCHOOL_NORMAL)
@@ -3560,7 +3570,7 @@ class spell_gen_vampiric_touch : public SpellScriptLoader
return true;
}
- void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
+ void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
DamageInfo* damageInfo = eventInfo.GetDamageInfo();
@@ -3569,7 +3579,7 @@ class spell_gen_vampiric_touch : public SpellScriptLoader
Unit* caster = eventInfo.GetActor();
int32 bp = damageInfo->GetDamage() / 2;
- caster->CastCustomSpell(SPELL_VAMPIRIC_TOUCH_HEAL, SPELLVALUE_BASE_POINT0, bp, caster, true);
+ caster->CastCustomSpell(SPELL_VAMPIRIC_TOUCH_HEAL, SPELLVALUE_BASE_POINT0, bp, caster, true, nullptr, aurEff);
}
void Register() override
diff --git a/src/server/scripts/Spells/spell_hunter.cpp b/src/server/scripts/Spells/spell_hunter.cpp
index a6f9008955d..b341c5799ed 100644
--- a/src/server/scripts/Spells/spell_hunter.cpp
+++ b/src/server/scripts/Spells/spell_hunter.cpp
@@ -225,7 +225,7 @@ class spell_hun_chimera_shot : public SpellScriptLoader
// first, calculate damage of basic tick (C&P from AuraEffect::HandlePeriodicDamageAurasTick)
basePoint = (aurEff->GetAmount() + aurEff->GetBonusAmount()) * aurEff->GetDonePct();
if (Player* modOwner = caster->GetSpellModOwner())
- modOwner->ApplySpellMod<SPELLMOD_DOT>(aurEff->GetSpellInfo()->Id, basePoint);
+ modOwner->ApplySpellMod<SPELLMOD_DOT>(aurEff->GetId(), basePoint);
basePoint = unitTarget->SpellDamageBonusTaken(caster, aurEff->GetSpellInfo(), basePoint, DOT, aura->GetStackAmount());
// then, multiply to get damage potential
@@ -237,20 +237,15 @@ class spell_hun_chimera_shot : public SpellScriptLoader
{
spellId = SPELL_HUNTER_CHIMERA_SHOT_VIPER;
- // Amount of one aura tick (C&P from AuraEffect::HandlePeriodicManaLeechAuraTick)
- basePoint = aurEff->GetAmount();
- // max value
- int32 maxmana = CalculatePct(caster->GetMaxPower(POWER_MANA), basePoint * 2.0f);
- ApplyPct(basePoint, caster->GetMaxPower(POWER_MANA));
- if (basePoint > maxmana)
- basePoint = maxmana;
+ // % of mana drained in max duration
+ basePoint = aurEff->GetAmount() * aurEff->GetTotalTicks();
- basePoint = int32(CalculatePct(unitTarget->GetMaxPower(POWER_MANA), aurEff->GetAmount()));
- int32 casterBasePoint = CalculatePct(caster->GetMaxPower(POWER_MANA), aurEff->GetAmount() * 2.0f);
- if (basePoint > casterBasePoint)
- basePoint = casterBasePoint;
+ // max value
+ int32 maxManaReturn = CalculatePct(static_cast<int32>(caster->GetMaxPower(POWER_MANA)), basePoint * 2);
+ ApplyPct(basePoint, unitTarget->GetMaxPower(POWER_MANA));
+ if (basePoint > maxManaReturn)
+ basePoint = maxManaReturn;
- basePoint *= aurEff->GetTotalTicks();
ApplyPct(basePoint, 60);
}
// Scorpid Sting - Attempts to Disarm the target for 10 sec. This effect cannot occur more than once per 1 minute.
@@ -265,8 +260,6 @@ class spell_hun_chimera_shot : public SpellScriptLoader
if (spellId)
caster->CastCustomSpell(spellId, SPELLVALUE_BASE_POINT0, basePoint, unitTarget, TriggerCastFlags(TRIGGERED_FULL_MASK & ~TRIGGERED_IGNORE_SPELL_AND_CATEGORY_CD));
- if (spellId == SPELL_HUNTER_CHIMERA_SHOT_SCORPID && caster->ToPlayer()) // Scorpid Sting - Add 1 minute cooldown
- caster->GetSpellHistory()->AddCooldown(spellId, 0, std::chrono::minutes(1));
}
}
@@ -282,6 +275,70 @@ class spell_hun_chimera_shot : public SpellScriptLoader
}
};
+// -53256 - Cobra Strikes
+class spell_hun_cobra_strikes : public SpellScriptLoader
+{
+ public:
+ spell_hun_cobra_strikes() : SpellScriptLoader("spell_hun_cobra_strikes") { }
+
+ class spell_hun_cobra_strikes_AuraScript : public AuraScript
+ {
+ PrepareAuraScript(spell_hun_cobra_strikes_AuraScript);
+
+ bool Validate(SpellInfo const* spellInfo) override
+ {
+ if (!sSpellMgr->GetSpellInfo(spellInfo->Effects[EFFECT_0].TriggerSpell))
+ return false;
+ return true;
+ }
+
+ void HandleProc(AuraEffect const* aurEff, ProcEventInfo& /*eventInfo*/)
+ {
+ PreventDefaultAction();
+
+ SpellInfo const* triggeredSpellInfo = sSpellMgr->AssertSpellInfo(GetSpellInfo()->Effects[aurEff->GetEffIndex()].TriggerSpell);
+ GetTarget()->CastCustomSpell(triggeredSpellInfo->Id, SPELLVALUE_AURA_STACK, triggeredSpellInfo->StackAmount, (Unit*)nullptr, true);
+ }
+
+ void Register() override
+ {
+ OnEffectProc += AuraEffectProcFn(spell_hun_cobra_strikes_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_PROC_TRIGGER_SPELL);
+ }
+ };
+
+ AuraScript* GetAuraScript() const override
+ {
+ return new spell_hun_cobra_strikes_AuraScript();
+ }
+};
+
+// 53257 - Cobra Strikes (triggered spell)
+class spell_hun_cobra_strikes_triggered : public SpellScriptLoader
+{
+ public:
+ spell_hun_cobra_strikes_triggered() : SpellScriptLoader("spell_hun_cobra_strikes_triggered") { }
+
+ class spell_hun_cobra_strikes_triggered_AuraScript : public AuraScript
+ {
+ PrepareAuraScript(spell_hun_cobra_strikes_triggered_AuraScript);
+
+ void HandleStackDrop(AuraEffect const* /*aurEff*/, ProcEventInfo& /*eventInfo*/)
+ {
+ ModStackAmount(-1);
+ }
+
+ void Register() override
+ {
+ OnEffectProc += AuraEffectProcFn(spell_hun_cobra_strikes_triggered_AuraScript::HandleStackDrop, EFFECT_0, SPELL_AURA_ADD_FLAT_MODIFIER);
+ }
+ };
+
+ AuraScript* GetAuraScript() const override
+ {
+ return new spell_hun_cobra_strikes_triggered_AuraScript();
+ }
+};
+
// 781 - Disengage
class spell_hun_disengage : public SpellScriptLoader
{
@@ -392,10 +449,10 @@ class spell_hun_glyph_of_mend_pet : public SpellScriptLoader
return true;
}
- void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
+ void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
- eventInfo.GetActor()->CastSpell(eventInfo.GetProcTarget(), SPELL_HUNTER_GLYPH_OF_MEND_PET_HAPPINESS, true);
+ eventInfo.GetProcTarget()->CastSpell((Unit*)nullptr, SPELL_HUNTER_GLYPH_OF_MEND_PET_HAPPINESS, true, nullptr, aurEff);
}
void Register() override
@@ -427,10 +484,10 @@ class spell_hun_hunting_party : public SpellScriptLoader
return true;
}
- void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
+ void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
- eventInfo.GetActor()->CastSpell((Unit*)nullptr, SPELL_REPLENISHMENT, true);
+ eventInfo.GetActor()->CastSpell((Unit*)nullptr, SPELL_REPLENISHMENT, true, nullptr, aurEff);
}
void Register() override
@@ -621,26 +678,33 @@ class spell_hun_lock_and_load : public SpellScriptLoader
{
if (eventInfo.GetActor()->HasAura(SPELL_HUNTER_LOCK_AND_LOAD_MARKER))
return false;
-
return true;
}
- template <uint32 mask>
- void HandleProcs(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
+ bool CheckTrapProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
- PreventDefaultAction();
+ if (!(eventInfo.GetTypeMask() & PROC_FLAG_DONE_TRAP_ACTIVATION))
+ return false;
- if (!(eventInfo.GetTypeMask() & mask))
- return;
+ // Do not proc on traps for immolation/explosive trap
+ DamageInfo* damageInfo = eventInfo.GetDamageInfo();
+ if (!damageInfo || !(damageInfo->GetSchoolMask() & SPELL_SCHOOL_MASK_FROST))
+ return false;
- // Additional check: do not proc on traps for immolation/explosive trap
- // (But still do it for the periodic damage part)
- if (mask == PROC_FLAG_DONE_TRAP_ACTIVATION)
- if (!(eventInfo.GetDamageInfo()->GetSchoolMask() & SPELL_SCHOOL_MASK_FROST))
- return;
+ return roll_chance_i(aurEff->GetAmount());
+ }
- if (!roll_chance_i(aurEff->GetAmount()))
- return;
+ bool CheckPeriodicProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
+ {
+ if (!(eventInfo.GetTypeMask() & PROC_FLAG_DONE_PERIODIC))
+ return false;
+
+ return roll_chance_i(aurEff->GetAmount());
+ }
+
+ void HandleProc(ProcEventInfo& eventInfo)
+ {
+ PreventDefaultAction();
Unit* caster = eventInfo.GetActor();
caster->CastSpell(caster, SPELL_HUNTER_LOCK_AND_LOAD_TRIGGER, true);
@@ -651,8 +715,10 @@ class spell_hun_lock_and_load : public SpellScriptLoader
{
DoCheckProc += AuraCheckProcFn(spell_hun_lock_and_load_AuraScript::CheckProc);
- OnEffectProc += AuraEffectProcFn(spell_hun_lock_and_load_AuraScript::HandleProcs<PROC_FLAG_DONE_TRAP_ACTIVATION>, EFFECT_0, SPELL_AURA_PROC_TRIGGER_SPELL);
- OnEffectProc += AuraEffectProcFn(spell_hun_lock_and_load_AuraScript::HandleProcs<PROC_FLAG_DONE_PERIODIC>, EFFECT_1, SPELL_AURA_DUMMY);
+ DoCheckEffectProc += AuraCheckEffectProcFn(spell_hun_lock_and_load_AuraScript::CheckTrapProc, EFFECT_0, SPELL_AURA_PROC_TRIGGER_SPELL);
+ DoCheckEffectProc += AuraCheckEffectProcFn(spell_hun_lock_and_load_AuraScript::CheckPeriodicProc, EFFECT_1, SPELL_AURA_DUMMY);
+
+ OnProc += AuraProcFn(spell_hun_lock_and_load_AuraScript::HandleProc);
}
};
@@ -679,30 +745,58 @@ class spell_hun_masters_call : public SpellScriptLoader
return true;
}
+ bool Load() override
+ {
+ return GetCaster()->GetTypeId() == TYPEID_PLAYER;
+ }
+
+ SpellCastResult DoCheckCast()
+ {
+ Pet* pet = GetCaster()->ToPlayer()->GetPet();
+ ASSERT(pet); // checked in Spell::CheckCast
+
+ if (!pet->IsAlive())
+ return SPELL_FAILED_CANT_DO_THAT_RIGHT_NOW;
+
+ // Do a mini Spell::CheckCasterAuras on the pet, no other way of doing this
+ SpellCastResult result = SPELL_CAST_OK;
+ uint32 const unitflag = pet->GetUInt32Value(UNIT_FIELD_FLAGS);
+ if (pet->GetCharmerGUID())
+ result = SPELL_FAILED_CHARMED;
+ else if (unitflag & UNIT_FLAG_STUNNED)
+ result = SPELL_FAILED_STUNNED;
+ else if (unitflag & UNIT_FLAG_FLEEING)
+ result = SPELL_FAILED_FLEEING;
+ else if (unitflag & UNIT_FLAG_CONFUSED)
+ result = SPELL_FAILED_CONFUSED;
+
+ if (result != SPELL_CAST_OK)
+ return result;
+
+ Unit* target = GetExplTargetUnit();
+ if (!target)
+ return SPELL_FAILED_BAD_TARGETS;
+
+ if (!pet->IsWithinLOSInMap(target))
+ return SPELL_FAILED_LINE_OF_SIGHT;
+
+ return SPELL_CAST_OK;
+ }
+
void HandleDummy(SpellEffIndex /*effIndex*/)
{
- if (Unit* ally = GetHitUnit())
- if (Player* caster = GetCaster()->ToPlayer())
- if (Pet* target = caster->GetPet())
- {
- TriggerCastFlags castMask = TriggerCastFlags(TRIGGERED_FULL_MASK & ~TRIGGERED_IGNORE_CASTER_AURASTATE);
- target->CastSpell(ally, GetEffectValue(), castMask);
- target->CastSpell(ally, GetSpellInfo()->Effects[EFFECT_0].CalcValue(), castMask);
- }
+ GetCaster()->ToPlayer()->GetPet()->CastSpell(GetHitUnit(), GetEffectValue(), true);
}
void HandleScriptEffect(SpellEffIndex /*effIndex*/)
{
- if (Unit* target = GetHitUnit())
- {
- // Cannot be processed while pet is dead
- TriggerCastFlags castMask = TriggerCastFlags(TRIGGERED_FULL_MASK & ~TRIGGERED_IGNORE_CASTER_AURASTATE);
- target->CastSpell(target, SPELL_HUNTER_MASTERS_CALL_TRIGGERED, castMask);
- }
+ GetHitUnit()->CastSpell((Unit*)nullptr, SPELL_HUNTER_MASTERS_CALL_TRIGGERED, true);
}
void Register() override
{
+ OnCheckCast += SpellCheckCastFn(spell_hun_masters_call_SpellScript::DoCheckCast);
+
OnEffectHitTarget += SpellEffectFn(spell_hun_masters_call_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
OnEffectHitTarget += SpellEffectFn(spell_hun_masters_call_SpellScript::HandleScriptEffect, EFFECT_1, SPELL_EFFECT_SCRIPT_EFFECT);
}
@@ -1020,7 +1114,7 @@ class spell_hun_rapid_recuperation_trigger : public SpellScriptLoader
}
}
- void HandleRapidKillingProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
+ void HandleRapidKillingProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
static uint32 const triggerSpells[2] = { SPELL_HUNTER_RAPID_RECUPERATION_MANA_R1, SPELL_HUNTER_RAPID_RECUPERATION_MANA_R2 };
@@ -1033,7 +1127,7 @@ class spell_hun_rapid_recuperation_trigger : public SpellScriptLoader
uint8 rank = GetSpellInfo()->GetRank();
uint32 spellId = triggerSpells[rank - 1];
- eventInfo.GetActor()->CastSpell((Unit*)nullptr, spellId, true);
+ eventInfo.GetActor()->CastSpell((Unit*)nullptr, spellId, true, nullptr, aurEff);
}
void Register() override
@@ -1111,9 +1205,16 @@ class spell_hun_roar_of_sacrifice : public SpellScriptLoader
return true;
}
- bool CheckProc(ProcEventInfo& eventInfo)
+ bool CheckProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
- return GetCaster() && (eventInfo.GetDamageInfo()->GetSchoolMask() & GetEffect(EFFECT_1)->GetMiscValue()) != 0;
+ DamageInfo* damageInfo = eventInfo.GetDamageInfo();
+ if (!damageInfo || !(damageInfo->GetSchoolMask() & aurEff->GetMiscValue()))
+ return false;
+
+ if (!GetCaster())
+ return false;
+
+ return true;
}
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
@@ -1126,7 +1227,7 @@ class spell_hun_roar_of_sacrifice : public SpellScriptLoader
void Register() override
{
- DoCheckProc += AuraCheckProcFn(spell_hun_roar_of_sacrifice_AuraScript::CheckProc);
+ DoCheckEffectProc += AuraCheckEffectProcFn(spell_hun_roar_of_sacrifice_AuraScript::CheckProc, EFFECT_1, SPELL_AURA_DUMMY);
OnEffectProc += AuraEffectProcFn(spell_hun_roar_of_sacrifice_AuraScript::HandleProc, EFFECT_1, SPELL_AURA_DUMMY);
}
};
@@ -1359,7 +1460,7 @@ class spell_hun_thrill_of_the_hunt : public SpellScriptLoader
if (!amount)
return;
- caster->CastCustomSpell(SPELL_HUNTER_THRILL_OF_THE_HUNT_MANA, SPELLVALUE_BASE_POINT0, amount, (Unit*)nullptr, true);
+ caster->CastCustomSpell(SPELL_HUNTER_THRILL_OF_THE_HUNT_MANA, SPELLVALUE_BASE_POINT0, amount, (Unit*)nullptr, true, nullptr, aurEff);
}
void Register() override
@@ -1440,7 +1541,7 @@ class spell_hun_viper_attack_speed : public SpellScriptLoader
void OnApply(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/)
{
if (GetTarget()->HasAura(SPELL_HUNTER_ASPECT_OF_THE_VIPER))
- GetTarget()->CastSpell(GetTarget(), SPELL_HUNTER_VICIOUS_VIPER, true, NULL, aurEff);
+ GetTarget()->CastSpell(GetTarget(), SPELL_HUNTER_VICIOUS_VIPER, true, nullptr, aurEff);
}
void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
@@ -1467,6 +1568,8 @@ void AddSC_hunter_spell_scripts()
new spell_hun_aspect_of_the_beast();
new spell_hun_ascpect_of_the_viper();
new spell_hun_chimera_shot();
+ new spell_hun_cobra_strikes();
+ new spell_hun_cobra_strikes_triggered();
new spell_hun_disengage();
new spell_hun_glyph_of_arcane_shot();
new spell_hun_glyph_of_mend_pet();
diff --git a/src/server/scripts/Spells/spell_item.cpp b/src/server/scripts/Spells/spell_item.cpp
index 0db0be0ef9c..9ef5c5d0b4d 100644
--- a/src/server/scripts/Spells/spell_item.cpp
+++ b/src/server/scripts/Spells/spell_item.cpp
@@ -148,7 +148,7 @@ class spell_item_alchemists_stone : public SpellScriptLoader
return true;
}
- void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
+ void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
SpellInfo const* spellInfo = eventInfo.GetSpellInfo();
@@ -172,7 +172,7 @@ class spell_item_alchemists_stone : public SpellScriptLoader
}
int32 amount = CalculatePct(spellInfo->Effects[i].CalcValue(caster), 40);
- caster->CastCustomSpell(spellId, SPELLVALUE_BASE_POINT0, amount, (Unit*)nullptr, true);
+ caster->CastCustomSpell(spellId, SPELLVALUE_BASE_POINT0, amount, (Unit*)nullptr, true, nullptr, aurEff);
}
}
@@ -220,7 +220,7 @@ class spell_item_anger_capacitor : public SpellScriptLoader
return true;
}
- void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
+ void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
Unit* caster = eventInfo.GetActor();
@@ -237,7 +237,7 @@ class spell_item_anger_capacitor : public SpellScriptLoader
if (player->GetWeaponForAttack(OFF_ATTACK, true) && urand(0, 1))
spellId = SPELL_MANIFEST_ANGER_OFF_HAND;
- caster->CastSpell(target, spellId, true);
+ caster->CastSpell(target, spellId, true, nullptr, aurEff);
}
void Register() override
@@ -281,6 +281,38 @@ class spell_item_arcane_shroud : public SpellScriptLoader
}
};
+// Item - 12846: Argent Dawn Commission
+// Item - 13209: Seal of the Dawn
+// Item - 19812: Rune of the Dawn
+
+// 17670 - Argent Dawn Commission
+class spell_item_argent_dawn_commission : public SpellScriptLoader
+{
+ public:
+ spell_item_argent_dawn_commission() : SpellScriptLoader("spell_item_argent_dawn_commission") { }
+
+ class spell_item_argent_dawn_commission_AuraScript : public AuraScript
+ {
+ PrepareAuraScript(spell_item_argent_dawn_commission_AuraScript);
+
+ void HandleDummy(AuraEffect const* /*aurEff*/, ProcEventInfo& /*eventInfo*/)
+ {
+ // Prevent console log
+ PreventDefaultAction();
+ }
+
+ void Register() override
+ {
+ OnEffectProc += AuraEffectProcFn(spell_item_argent_dawn_commission_AuraScript::HandleDummy, EFFECT_0, SPELL_AURA_DUMMY);
+ }
+ };
+
+ AuraScript* GetAuraScript() const override
+ {
+ return new spell_item_argent_dawn_commission_AuraScript();
+ }
+};
+
enum AuraOfMadness
{
SPELL_SOCIOPATH = 39511, // Sociopath: +35 strength(Paladin, Rogue, Druid, Warrior)
@@ -326,7 +358,7 @@ class spell_item_aura_of_madness : public SpellScriptLoader
return true;
}
- void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
+ void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
static std::vector<uint32> const triggeredSpells[MAX_CLASSES] =
{
@@ -359,7 +391,7 @@ class spell_item_aura_of_madness : public SpellScriptLoader
PreventDefaultAction();
Unit* caster = eventInfo.GetActor();
uint32 spellId = Trinity::Containers::SelectRandomContainerElement(triggeredSpells[caster->getClass()]);
- caster->CastSpell(caster, spellId, true);
+ caster->CastSpell(caster, spellId, true, nullptr, aurEff);
if (roll_chance_i(10))
caster->Unit::Say(SAY_MADNESS);
@@ -395,10 +427,10 @@ class spell_item_dementia : public SpellScriptLoader
return true;
}
- void HandlePeriodicDummy(AuraEffect const* /*aurEff*/)
+ void HandlePeriodicDummy(AuraEffect const* aurEff)
{
PreventDefaultAction();
- GetTarget()->CastSpell(GetTarget(), RAND(SPELL_DEMENTIA_POS, SPELL_DEMENTIA_NEG), true);
+ GetTarget()->CastSpell(GetTarget(), RAND(SPELL_DEMENTIA_POS, SPELL_DEMENTIA_NEG), true, nullptr, aurEff);
}
void Register() override
@@ -458,7 +490,7 @@ class spell_item_blessing_of_ancient_kings : public SpellScriptLoader
protEff->GetBase()->RefreshDuration();
}
else
- GetTarget()->CastCustomSpell(SPELL_PROTECTION_OF_ANCIENT_KINGS, SPELLVALUE_BASE_POINT0, absorb, eventInfo.GetProcTarget(), true, NULL, aurEff);
+ GetTarget()->CastCustomSpell(SPELL_PROTECTION_OF_ANCIENT_KINGS, SPELLVALUE_BASE_POINT0, absorb, eventInfo.GetProcTarget(), true, nullptr, aurEff);
}
void Register() override
@@ -584,7 +616,7 @@ class spell_item_deathbringers_will : public SpellScriptLoader
return true;
}
- void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
+ void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
static std::vector<uint32> const triggeredSpells[MAX_CLASSES] =
{
@@ -616,12 +648,12 @@ class spell_item_deathbringers_will : public SpellScriptLoader
PreventDefaultAction();
Unit* caster = eventInfo.GetActor();
- auto const& randomSpells = triggeredSpells[caster->getClass()];
+ std::vector<uint32> const& randomSpells = triggeredSpells[caster->getClass()];
if (randomSpells.empty())
return;
uint32 spellId = Trinity::Containers::SelectRandomContainerElement(randomSpells);
- caster->CastSpell(caster, spellId, true);
+ caster->CastSpell(caster, spellId, true, nullptr, aurEff);
}
void Register() override
@@ -1051,7 +1083,7 @@ class spell_item_frozen_shadoweave : public SpellScriptLoader
int32 amount = CalculatePct(static_cast<int32>(damageInfo->GetDamage()), aurEff->GetAmount());
Unit* caster = eventInfo.GetActor();
- caster->CastCustomSpell(SPELL_SHADOWMEND, SPELLVALUE_BASE_POINT0, amount, (Unit*)nullptr, true);
+ caster->CastCustomSpell(SPELL_SHADOWMEND, SPELLVALUE_BASE_POINT0, amount, (Unit*)nullptr, true, nullptr, aurEff);
}
void Register() override
@@ -1096,9 +1128,9 @@ class spell_item_gnomish_death_ray : public SpellScriptLoader
if (Unit* target = GetHitUnit())
{
if (urand(0, 99) < 15)
- caster->CastSpell(caster, SPELL_GNOMISH_DEATH_RAY_SELF, true, NULL); // failure
+ caster->CastSpell(caster, SPELL_GNOMISH_DEATH_RAY_SELF, true); // failure
else
- caster->CastSpell(target, SPELL_GNOMISH_DEATH_RAY_TARGET, true, NULL);
+ caster->CastSpell(target, SPELL_GNOMISH_DEATH_RAY_TARGET, true);
}
}
@@ -1137,10 +1169,10 @@ class spell_item_healing_touch_refund : public SpellScriptLoader
return true;
}
- void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
+ void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
- eventInfo.GetActor()->CastSpell((Unit*)nullptr, SPELL_HEALING_TOUCH_MANA, true);
+ eventInfo.GetActor()->CastSpell((Unit*)nullptr, SPELL_HEALING_TOUCH_MANA, true, nullptr, aurEff);
}
void Register() override
@@ -1194,7 +1226,7 @@ class spell_item_heartpierce : public SpellScriptLoader
return true;
}
- void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
+ void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
Unit* caster = eventInfo.GetActor();
@@ -1211,6 +1243,7 @@ class spell_item_heartpierce : public SpellScriptLoader
case POWER_RAGE:
spellId = Rage;
break;
+ // Death Knights can't use daggers, but oh well
case POWER_RUNIC_POWER:
spellId = RunicPower;
break;
@@ -1218,7 +1251,7 @@ class spell_item_heartpierce : public SpellScriptLoader
return;
}
- caster->CastSpell((Unit*)nullptr, spellId, true);
+ caster->CastSpell((Unit*)nullptr, spellId, true, nullptr, aurEff);
}
void Register() override
@@ -1348,14 +1381,14 @@ class spell_item_mark_of_conquest : public SpellScriptLoader
return true;
}
- void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
+ void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
if (eventInfo.GetTypeMask() & (PROC_FLAG_DONE_RANGED_AUTO_ATTACK | PROC_FLAG_DONE_SPELL_RANGED_DMG_CLASS))
{
// in that case, do not cast heal spell
PreventDefaultAction();
// but mana instead
- eventInfo.GetActor()->CastSpell((Unit*)nullptr, SPELL_MARK_OF_CONQUEST_ENERGIZE, true);
+ eventInfo.GetActor()->CastSpell((Unit*)nullptr, SPELL_MARK_OF_CONQUEST_ENERGIZE, true, nullptr, aurEff);
}
}
@@ -1457,8 +1490,12 @@ class spell_item_necrotic_touch : public SpellScriptLoader
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
- int32 bp = CalculatePct(int32(eventInfo.GetDamageInfo()->GetDamage()), aurEff->GetAmount());
- GetTarget()->CastCustomSpell(SPELL_ITEM_NECROTIC_TOUCH_PROC, SPELLVALUE_BASE_POINT0, bp, eventInfo.GetProcTarget(), true, NULL, aurEff);
+ DamageInfo* damageInfo = eventInfo.GetDamageInfo();
+ if (!damageInfo || !damageInfo->GetDamage())
+ return;
+
+ int32 bp = CalculatePct(static_cast<int32>(damageInfo->GetDamage()), aurEff->GetAmount());
+ GetTarget()->CastCustomSpell(SPELL_ITEM_NECROTIC_TOUCH_PROC, SPELLVALUE_BASE_POINT0, bp, eventInfo.GetProcTarget(), true, nullptr, aurEff);
}
void Register() override
@@ -1510,7 +1547,7 @@ class spell_item_net_o_matic : public SpellScriptLoader
else if (roll < 4) // 2% for 20 sec root, charge to target (off-like chance unknown)
spellId = SPELL_NET_O_MATIC_TRIGGERED2;
- GetCaster()->CastSpell(target, spellId, true, NULL);
+ GetCaster()->CastSpell(target, spellId, true, nullptr);
}
}
@@ -1566,7 +1603,7 @@ class spell_item_noggenfogger_elixir : public SpellScriptLoader
case 2: spellId = SPELL_NOGGENFOGGER_ELIXIR_TRIGGERED2; break;
}
- caster->CastSpell(caster, spellId, true, NULL);
+ caster->CastSpell(caster, spellId, true, nullptr);
}
void Register() override
@@ -1698,7 +1735,7 @@ class spell_item_pet_healing : public SpellScriptLoader
int32 bp = CalculatePct(static_cast<int32>(damageInfo->GetDamage()), aurEff->GetAmount());
Unit* caster = eventInfo.GetActor();
- caster->CastCustomSpell(SPELL_HEALTH_LINK, SPELLVALUE_BASE_POINT0, bp, (Unit*)nullptr, true);
+ caster->CastCustomSpell(SPELL_HEALTH_LINK, SPELLVALUE_BASE_POINT0, bp, (Unit*)nullptr, true, nullptr, aurEff);
}
void Register() override
@@ -1925,6 +1962,8 @@ class spell_item_shadows_fate : public SpellScriptLoader
void HandleProc(ProcEventInfo& procInfo)
{
+ PreventDefaultAction();
+
Unit* caster = procInfo.GetActor();
Unit* target = GetCaster();
if (!caster || !target)
@@ -2168,7 +2207,7 @@ class spell_item_swift_hand_justice_dummy : public SpellScriptLoader
Unit* caster = eventInfo.GetActor();
int32 amount = caster->CountPctFromMaxHealth(aurEff->GetAmount());
- caster->CastCustomSpell(SPELL_SWIFT_HAND_OF_JUSTICE_HEAL, SPELLVALUE_BASE_POINT0, amount, (Unit*)nullptr, true);
+ caster->CastCustomSpell(SPELL_SWIFT_HAND_OF_JUSTICE_HEAL, SPELLVALUE_BASE_POINT0, amount, (Unit*)nullptr, true, nullptr, aurEff);
}
void Register() override
@@ -2206,10 +2245,10 @@ class spell_item_totem_of_flowing_water : public SpellScriptLoader
return true;
}
- void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
+ void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
- eventInfo.GetActor()->CastSpell((Unit*)nullptr, SPELL_LESSER_HEALING_WAVE_MANA, true);
+ eventInfo.GetActor()->CastSpell((Unit*)nullptr, SPELL_LESSER_HEALING_WAVE_MANA, true, nullptr, aurEff);
}
void Register() override
@@ -3703,17 +3742,17 @@ class spell_item_shard_of_the_scale : public SpellScriptLoader
return true;
}
- void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
+ void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
Unit* caster = eventInfo.GetActor();
Unit* target = eventInfo.GetProcTarget();
if (eventInfo.GetTypeMask() & PROC_FLAG_DONE_SPELL_MAGIC_DMG_CLASS_POS)
- caster->CastSpell(target, HealProc, true);
+ caster->CastSpell(target, HealProc, true, nullptr, aurEff);
if (eventInfo.GetTypeMask() & PROC_FLAG_DONE_SPELL_MAGIC_DMG_CLASS_NEG)
- caster->CastSpell(target, DamageProc, true);
+ caster->CastSpell(target, DamageProc, true, nullptr, aurEff);
}
void Register() override
@@ -3849,7 +3888,7 @@ class spell_item_sunwell_neck : public SpellScriptLoader
return true;
}
- void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
+ void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
Player* player = eventInfo.GetActor()->ToPlayer();
@@ -3857,10 +3896,10 @@ class spell_item_sunwell_neck : public SpellScriptLoader
// Aggression checks are in the spell system... just cast and forget
if (player->GetReputationRank(FACTION_ALDOR) == REP_EXALTED)
- player->CastSpell(target, Aldors, true);
+ player->CastSpell(target, Aldors, true, nullptr, aurEff);
if (player->GetReputationRank(FACTION_SCRYERS) == REP_EXALTED)
- player->CastSpell(target, Scryers, true);
+ player->CastSpell(target, Scryers, true, nullptr, aurEff);
}
void Register() override
@@ -4307,6 +4346,119 @@ class spell_item_taunt_flag_targeting : public SpellScriptLoader
}
};
+// 13180 - Gnomish Mind Control Cap
+enum MindControlCap
+{
+ ROLL_CHANCE_DULLARD = 32,
+ ROLL_CHANCE_NO_BACKFIRE = 95,
+ SPELL_GNOMISH_MIND_CONTROL_CAP = 13181,
+ SPELL_DULLARD = 67809
+};
+
+class spell_item_mind_control_cap : public SpellScriptLoader
+{
+ public:
+ spell_item_mind_control_cap() : SpellScriptLoader("spell_item_mind_control_cap") { }
+
+ class spell_item_mind_control_cap_SpellScript : public SpellScript
+ {
+ PrepareSpellScript(spell_item_mind_control_cap_SpellScript);
+
+ bool Load() override
+ {
+ if (!GetCastItem())
+ return false;
+ return true;
+ }
+
+ bool Validate(SpellInfo const* /*spell*/) override
+ {
+ if (!sSpellMgr->GetSpellInfo(SPELL_GNOMISH_MIND_CONTROL_CAP) || !sSpellMgr->GetSpellInfo(SPELL_DULLARD))
+ return false;
+ return true;
+ }
+
+ void HandleDummy(SpellEffIndex /* effIndex */)
+ {
+ Unit* caster = GetCaster();
+ if (Unit* target = GetHitUnit())
+ {
+ if (roll_chance_i(ROLL_CHANCE_NO_BACKFIRE))
+ caster->CastSpell(target, roll_chance_i(ROLL_CHANCE_DULLARD) ? SPELL_DULLARD : SPELL_GNOMISH_MIND_CONTROL_CAP, true, GetCastItem());
+ else
+ target->CastSpell(caster, SPELL_GNOMISH_MIND_CONTROL_CAP, true); // backfire - 5% chance
+ }
+ }
+
+ void Register() override
+ {
+ OnEffectHitTarget += SpellEffectFn(spell_item_mind_control_cap_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
+ }
+ };
+
+ SpellScript* GetSpellScript() const override
+ {
+ return new spell_item_mind_control_cap_SpellScript();
+ }
+};
+
+// 8344 - Universal Remote (Gnomish Universal Remote)
+enum UniversalRemote
+{
+ SPELL_CONTROL_MACHINE = 8345,
+ SPELL_MOBILITY_MALFUNCTION = 8346,
+ SPELL_TARGET_LOCK = 8347
+};
+
+class spell_item_universal_remote : public SpellScriptLoader
+{
+ public:
+ spell_item_universal_remote() : SpellScriptLoader("spell_item_universal_remote") { }
+
+ class spell_item_universal_remote_SpellScript : public SpellScript
+ {
+ PrepareSpellScript(spell_item_universal_remote_SpellScript);
+
+ bool Load() override
+ {
+ if (!GetCastItem())
+ return false;
+ return true;
+ }
+
+ bool Validate(SpellInfo const* /*spellInfo*/) override
+ {
+ if (!sSpellMgr->GetSpellInfo(SPELL_CONTROL_MACHINE) || !sSpellMgr->GetSpellInfo(SPELL_MOBILITY_MALFUNCTION) || !sSpellMgr->GetSpellInfo(SPELL_TARGET_LOCK))
+ return false;
+ return true;
+ }
+
+ void HandleDummy(SpellEffIndex /*effIndex*/)
+ {
+ if (Unit* target = GetHitUnit())
+ {
+ uint8 chance = urand(0, 99);
+ if (chance < 15)
+ GetCaster()->CastSpell(target, SPELL_TARGET_LOCK, true, GetCastItem());
+ else if (chance < 25)
+ GetCaster()->CastSpell(target, SPELL_MOBILITY_MALFUNCTION, true, GetCastItem());
+ else
+ GetCaster()->CastSpell(target, SPELL_CONTROL_MACHINE, true, GetCastItem());
+ }
+ }
+
+ void Register() override
+ {
+ OnEffectHitTarget += SpellEffectFn(spell_item_universal_remote_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
+ }
+ };
+
+ SpellScript* GetSpellScript() const override
+ {
+ return new spell_item_universal_remote_SpellScript();
+ }
+};
+
enum ZandalarianCharms
{
SPELL_UNSTABLE_POWER_AURA_STACK = 24659,
@@ -4386,6 +4538,7 @@ void AddSC_item_spell_scripts()
new spell_item_alchemists_stone();
new spell_item_anger_capacitor<8>("spell_item_tiny_abomination_in_a_jar");
new spell_item_anger_capacitor<7>("spell_item_tiny_abomination_in_a_jar_hero");
+ new spell_item_argent_dawn_commission();
new spell_item_aura_of_madness();
new spell_item_dementia();
new spell_item_blessing_of_ancient_kings();
@@ -4478,6 +4631,8 @@ void AddSC_item_spell_scripts()
new spell_item_charm_witch_doctor();
new spell_item_mana_drain();
new spell_item_taunt_flag_targeting();
+ new spell_item_mind_control_cap();
+ new spell_item_universal_remote();
new spell_item_zandalarian_charm("spell_item_unstable_power", SPELL_UNSTABLE_POWER_AURA_STACK);
new spell_item_zandalarian_charm("spell_item_restless_strength", SPELL_RESTLESS_STRENGTH_AURA_STACK);
diff --git a/src/server/scripts/Spells/spell_mage.cpp b/src/server/scripts/Spells/spell_mage.cpp
index f60c1f81601..5c496024599 100644
--- a/src/server/scripts/Spells/spell_mage.cpp
+++ b/src/server/scripts/Spells/spell_mage.cpp
@@ -114,14 +114,14 @@ class spell_mage_arcane_potency : public SpellScriptLoader
return true;
}
- void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
+ void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
static uint32 const triggerSpell[2] = { SPELL_MAGE_ARCANE_POTENCY_RANK_1, SPELL_MAGE_ARCANE_POTENCY_RANK_2 };
PreventDefaultAction();
Unit* caster = eventInfo.GetActor();
uint32 spellId = triggerSpell[GetSpellInfo()->GetRank() - 1];
- caster->CastSpell(caster, spellId, true);
+ caster->CastSpell(caster, spellId, true, nullptr, aurEff);
}
void Register() override
@@ -258,17 +258,21 @@ class spell_mage_burnout : public SpellScriptLoader
bool CheckProc(ProcEventInfo& eventInfo)
{
- return eventInfo.GetDamageInfo()->GetSpellInfo() != nullptr;
+ DamageInfo* damageInfo = eventInfo.GetDamageInfo();
+ if (!damageInfo || !damageInfo->GetSpellInfo())
+ return false;
+
+ return true;
}
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
- int32 mana = int32(eventInfo.GetDamageInfo()->GetSpellInfo()->CalcPowerCost(GetTarget(), eventInfo.GetDamageInfo()->GetSchoolMask()));
+ int32 mana = eventInfo.GetDamageInfo()->GetSpellInfo()->CalcPowerCost(GetTarget(), eventInfo.GetDamageInfo()->GetSchoolMask());
mana = CalculatePct(mana, aurEff->GetAmount());
- GetTarget()->CastCustomSpell(SPELL_MAGE_BURNOUT, SPELLVALUE_BASE_POINT0, mana, GetTarget(), true, NULL, aurEff);
+ GetTarget()->CastCustomSpell(SPELL_MAGE_BURNOUT, SPELLVALUE_BASE_POINT0, mana, GetTarget(), true, nullptr, aurEff);
}
void Register() override
@@ -379,11 +383,11 @@ class spell_mage_imp_blizzard : public SpellScriptLoader
return true;
}
- void HandleChill(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
+ void HandleChill(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
uint32 triggerSpellId = sSpellMgr->GetSpellWithRank(SPELL_MAGE_CHILLED, GetSpellInfo()->GetRank());
- eventInfo.GetActor()->CastSpell(eventInfo.GetProcTarget(), triggerSpellId, true);
+ eventInfo.GetActor()->CastSpell(eventInfo.GetProcTarget(), triggerSpellId, true, nullptr, aurEff);
}
void Register() override
@@ -416,10 +420,10 @@ class spell_mage_imp_mana_gems : public SpellScriptLoader
return true;
}
- void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
+ void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
- eventInfo.GetActor()->CastSpell((Unit*)nullptr, SPELL_MAGE_MANA_SURGE, true);
+ eventInfo.GetActor()->CastSpell((Unit*)nullptr, SPELL_MAGE_MANA_SURGE, true, nullptr, aurEff);
}
void Register() override
@@ -832,7 +836,7 @@ class spell_mage_hot_streak : public SpellScriptLoader
return;
Unit* caster = eventInfo.GetActor();
- caster->CastSpell(caster, SPELL_MAGE_HOT_STREAK_PROC, true);
+ caster->CastSpell(caster, SPELL_MAGE_HOT_STREAK_PROC, true, nullptr, aurEff);
}
// reset counter
@@ -939,7 +943,7 @@ class spell_mage_ignite : public SpellScriptLoader
bool CheckProc(ProcEventInfo& eventInfo)
{
- return eventInfo.GetProcTarget() != nullptr;
+ return eventInfo.GetDamageInfo() && eventInfo.GetProcTarget();
}
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
@@ -951,7 +955,7 @@ class spell_mage_ignite : public SpellScriptLoader
int32 amount = int32(CalculatePct(eventInfo.GetDamageInfo()->GetDamage(), pct) / igniteDot->GetMaxTicks());
amount += eventInfo.GetProcTarget()->GetRemainingPeriodicAmount(eventInfo.GetActor()->GetGUID(), SPELL_MAGE_IGNITE, SPELL_AURA_PERIODIC_DAMAGE);
- GetTarget()->CastCustomSpell(SPELL_MAGE_IGNITE, SPELLVALUE_BASE_POINT0, amount, eventInfo.GetProcTarget(), true, NULL, aurEff);
+ GetTarget()->CastCustomSpell(SPELL_MAGE_IGNITE, SPELLVALUE_BASE_POINT0, amount, eventInfo.GetProcTarget(), true, nullptr, aurEff);
}
void Register() override
@@ -1028,7 +1032,7 @@ class spell_mage_magic_absorption : public SpellScriptLoader
PreventDefaultAction();
Unit* caster = eventInfo.GetActionTarget();
int32 bp = CalculatePct(static_cast<int32>(caster->GetMaxPower(POWER_MANA)), aurEff->GetAmount());
- caster->CastCustomSpell(SPELL_MAGE_MAGIC_ABSORPTION_MANA, SPELLVALUE_BASE_POINT0, bp, caster, true);
+ caster->CastCustomSpell(SPELL_MAGE_MAGIC_ABSORPTION_MANA, SPELLVALUE_BASE_POINT0, bp, caster, true, nullptr, aurEff);
}
void Register() override
@@ -1076,10 +1080,10 @@ class spell_mage_mana_shield : public SpellScriptLoader
}
}
- void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
+ void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
Unit* caster = eventInfo.GetActionTarget();
- caster->CastSpell(caster, SPELL_MAGE_ARCANE_SURGE, true);
+ caster->CastSpell(caster, SPELL_MAGE_ARCANE_SURGE, true, nullptr, aurEff);
}
void Register() override
@@ -1116,18 +1120,22 @@ class spell_mage_master_of_elements : public SpellScriptLoader
bool CheckProc(ProcEventInfo& eventInfo)
{
- return eventInfo.GetDamageInfo()->GetSpellInfo() != nullptr;
+ DamageInfo* damageInfo = eventInfo.GetDamageInfo();
+ if (!damageInfo || !damageInfo->GetSpellInfo())
+ return false;
+
+ return true;
}
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
- int32 mana = int32(eventInfo.GetDamageInfo()->GetSpellInfo()->CalcPowerCost(GetTarget(), eventInfo.GetDamageInfo()->GetSchoolMask()));
+ int32 mana = eventInfo.GetDamageInfo()->GetSpellInfo()->CalcPowerCost(GetTarget(), eventInfo.GetDamageInfo()->GetSchoolMask());
mana = CalculatePct(mana, aurEff->GetAmount());
if (mana > 0)
- GetTarget()->CastCustomSpell(SPELL_MAGE_MASTER_OF_ELEMENTS_ENERGIZE, SPELLVALUE_BASE_POINT0, mana, GetTarget(), true, NULL, aurEff);
+ GetTarget()->CastCustomSpell(SPELL_MAGE_MASTER_OF_ELEMENTS_ENERGIZE, SPELLVALUE_BASE_POINT0, mana, GetTarget(), true, nullptr, aurEff);
}
void Register() override
diff --git a/src/server/scripts/Spells/spell_paladin.cpp b/src/server/scripts/Spells/spell_paladin.cpp
index a289226f934..693990edd0a 100644
--- a/src/server/scripts/Spells/spell_paladin.cpp
+++ b/src/server/scripts/Spells/spell_paladin.cpp
@@ -156,9 +156,16 @@ class spell_pal_ardent_defender : public SpellScriptLoader
enum Spell
{
- PAL_SPELL_ARDENT_DEFENDER_HEAL = 66235,
+ PAL_SPELL_ARDENT_DEFENDER_HEAL = 66235
};
+ bool Validate(SpellInfo const* /*spellInfo*/) override
+ {
+ if (!sSpellMgr->GetSpellInfo(PAL_SPELL_ARDENT_DEFENDER_HEAL))
+ return false;
+ return true;
+ }
+
bool Load() override
{
healPct = GetSpellInfo()->Effects[EFFECT_1].CalcValue();
@@ -192,7 +199,7 @@ class spell_pal_ardent_defender : public SpellScriptLoader
: float(defenseSkillValue) / float(reqDefForMaxHeal);
int32 healAmount = int32(victim->CountPctFromMaxHealth(uint32(healPct * pctFromDefense)));
- victim->CastCustomSpell(victim, PAL_SPELL_ARDENT_DEFENDER_HEAL, &healAmount, NULL, NULL, true, NULL, aurEff);
+ victim->CastCustomSpell(PAL_SPELL_ARDENT_DEFENDER_HEAL, SPELLVALUE_BASE_POINT0, healAmount, victim, true, nullptr, aurEff);
victim->GetSpellHistory()->AddCooldown(PAL_SPELL_ARDENT_DEFENDER_HEAL, 0, std::chrono::minutes(2));
}
else if (remainingHealth < int32(allowedHealth))
@@ -698,9 +705,13 @@ class spell_pal_eye_for_an_eye : public SpellScriptLoader
void OnProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
+ DamageInfo* damageInfo = eventInfo.GetDamageInfo();
+ if (!damageInfo || !damageInfo->GetDamage())
+ return;
+
// return damage % to attacker but < 50% own total health
- int32 damage = int32(std::min(CalculatePct(eventInfo.GetDamageInfo()->GetDamage(), aurEff->GetAmount()), GetTarget()->GetMaxHealth() / 2));
- GetTarget()->CastCustomSpell(SPELL_PALADIN_EYE_FOR_AN_EYE_DAMAGE, SPELLVALUE_BASE_POINT0, damage, eventInfo.GetProcTarget(), true, NULL, aurEff);
+ int32 damage = std::min(CalculatePct(static_cast<int32>(damageInfo->GetDamage()), aurEff->GetAmount()), static_cast<int32>(GetTarget()->GetMaxHealth()) / 2);
+ GetTarget()->CastCustomSpell(SPELL_PALADIN_EYE_FOR_AN_EYE_DAMAGE, SPELLVALUE_BASE_POINT0, damage, eventInfo.GetProcTarget(), true, nullptr, aurEff);
}
void Register() override
@@ -820,7 +831,7 @@ class spell_pal_glyph_of_holy_light_dummy : public SpellScriptLoader
Unit* target = eventInfo.GetProcTarget();
int32 amount = CalculatePct(static_cast<int32>(healInfo->GetHeal()), aurEff->GetAmount());
- caster->CastCustomSpell(SPELL_PALADIN_GLYPH_OF_HOLY_LIGHT_HEAL, SPELLVALUE_BASE_POINT0, amount, target, true);
+ caster->CastCustomSpell(SPELL_PALADIN_GLYPH_OF_HOLY_LIGHT_HEAL, SPELLVALUE_BASE_POINT0, amount, target, true, nullptr, aurEff);
}
void Register() override
@@ -972,12 +983,12 @@ class spell_pal_heart_of_the_crusader : public SpellScriptLoader
return true;
}
- void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
+ void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
uint32 spellId = sSpellMgr->GetSpellWithRank(SPELL_PALADIN_HEART_OF_THE_CRUSADER_EFF_R1, GetSpellInfo()->GetRank());
- eventInfo.GetActor()->CastSpell(eventInfo.GetProcTarget(), spellId, true);
+ eventInfo.GetActor()->CastSpell(eventInfo.GetProcTarget(), spellId, true, nullptr, aurEff);
}
void Register() override
@@ -1299,6 +1310,8 @@ class spell_pal_infusion_of_light : public SpellScriptLoader
Unit* target = GetTarget();
int32 duration = sSpellMgr->AssertSpellInfo(SPELL_PALADIN_FLASH_OF_LIGHT_PROC)->GetMaxDuration() / 1000;
int32 pct = GetSpellInfo()->Effects[EFFECT_2].CalcValue();
+ ASSERT(duration > 0);
+
int32 bp0 = CalculatePct(healInfo->GetHeal() / duration, pct);
// Item - Paladin T9 Holy 4P Bonus
@@ -1379,7 +1392,7 @@ class spell_pal_item_t6_trinket : public SpellScriptLoader
return true;
}
- void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
+ void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
SpellInfo const* spellInfo = eventInfo.GetSpellInfo();
@@ -1405,7 +1418,7 @@ class spell_pal_item_t6_trinket : public SpellScriptLoader
return;
if (roll_chance_i(chance))
- eventInfo.GetActor()->CastSpell(eventInfo.GetProcTarget(), spellId, true);
+ eventInfo.GetActor()->CastSpell(eventInfo.GetProcTarget(), spellId, true, nullptr, aurEff);
}
void Register() override
@@ -1536,7 +1549,7 @@ class spell_pal_judgement_of_light_heal : public SpellScriptLoader
Unit* caster = eventInfo.GetProcTarget();
int32 amount = static_cast<int32>(caster->CountPctFromMaxHealth(aurEff->GetAmount()));
- caster->CastCustomSpell(SPELL_PALADIN_JUDGEMENT_OF_LIGHT_HEAL, SPELLVALUE_BASE_POINT0, amount, (Unit*)nullptr, true);
+ caster->CastCustomSpell(SPELL_PALADIN_JUDGEMENT_OF_LIGHT_HEAL, SPELLVALUE_BASE_POINT0, amount, (Unit*)nullptr, true, nullptr, aurEff, GetCasterGUID());
}
void Register() override
@@ -1580,7 +1593,7 @@ class spell_pal_judgement_of_wisdom_mana : public SpellScriptLoader
Unit* caster = eventInfo.GetProcTarget();
int32 amount = CalculatePct(static_cast<int32>(caster->GetCreateMana()), aurEff->GetAmount());
- caster->CastCustomSpell(SPELL_PALADIN_JUDGEMENT_OF_WISDOM_MANA, SPELLVALUE_BASE_POINT0, amount, (Unit*)nullptr, true);
+ caster->CastCustomSpell(SPELL_PALADIN_JUDGEMENT_OF_WISDOM_MANA, SPELLVALUE_BASE_POINT0, amount, (Unit*)nullptr, true, nullptr, aurEff, GetCasterGUID());
}
void Register() override
@@ -1649,13 +1662,13 @@ class spell_pal_judgements_of_the_wise : public SpellScriptLoader
return true;
}
- void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
+ void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
Unit* caster = eventInfo.GetActor();
- caster->CastSpell((Unit*)nullptr, SPELL_PALADIN_JUDGEMENTS_OF_THE_WISE_MANA, true);
- caster->CastSpell((Unit*)nullptr, SPELL_REPLENISHMENT, true);
+ caster->CastSpell((Unit*)nullptr, SPELL_PALADIN_JUDGEMENTS_OF_THE_WISE_MANA, true, nullptr, aurEff);
+ caster->CastSpell((Unit*)nullptr, SPELL_REPLENISHMENT, true, nullptr, aurEff);
}
void Register() override
@@ -1776,7 +1789,7 @@ class spell_pal_light_s_beacon : public SpellScriptLoader
/// @todo: caster must be the healed unit to perform distance checks correctly
/// but that will break animation on clientside
/// caster in spell packets must be the healing unit
- eventInfo.GetActor()->CastCustomSpell(healSpellId, SPELLVALUE_BASE_POINT0, heal, beaconTarget, true);
+ eventInfo.GetActor()->CastCustomSpell(healSpellId, SPELLVALUE_BASE_POINT0, heal, beaconTarget, true, nullptr, aurEff);
}
void Register() override
@@ -1890,7 +1903,7 @@ class spell_pal_righteous_vengeance : public SpellScriptLoader
// Add remaining ticks to damage done
amount += target->GetRemainingPeriodicAmount(caster->GetGUID(), SPELL_PALADIN_RIGHTEOUS_VENGEANCE_DAMAGE, SPELL_AURA_PERIODIC_DAMAGE);
- caster->CastCustomSpell(SPELL_PALADIN_RIGHTEOUS_VENGEANCE_DAMAGE, SPELLVALUE_BASE_POINT0, amount, target, true);
+ caster->CastCustomSpell(SPELL_PALADIN_RIGHTEOUS_VENGEANCE_DAMAGE, SPELLVALUE_BASE_POINT0, amount, target, true, nullptr, aurEff);
}
void Register() override
@@ -1984,7 +1997,7 @@ class spell_pal_sacred_shield_dummy : public SpellScriptLoader
cooldown = Seconds(bonus->GetAmount());
_cooldownEnd = now + cooldown;
- caster->CastSpell(eventInfo.GetActionTarget(), SPELL_PALADIN_SACRED_SHIELD_TRIGGER, true);
+ caster->CastSpell(eventInfo.GetActionTarget(), SPELL_PALADIN_SACRED_SHIELD_TRIGGER, true, nullptr, aurEff);
}
void Register() override
@@ -2086,7 +2099,7 @@ class spell_pal_seal_of_vengeance : public SpellScriptLoader
5 33% 38%
*/
- void HandleApplyDoT(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
+ void HandleApplyDoT(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
@@ -2094,22 +2107,23 @@ class spell_pal_seal_of_vengeance : public SpellScriptLoader
return;
// don't cast triggered, spell already has SPELL_ATTR4_CAN_CAST_WHILE_CASTING attr
- eventInfo.GetActor()->CastSpell(eventInfo.GetProcTarget(), DoTSpell, false);
+ eventInfo.GetActor()->CastSpell(eventInfo.GetProcTarget(), DoTSpell, TRIGGERED_DONT_RESET_PERIODIC_TIMER, nullptr, aurEff);
}
- void HandleSeal(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
+ void HandleSeal(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
Unit* caster = eventInfo.GetActor();
Unit* target = eventInfo.GetProcTarget();
- AuraEffect const* aurEff = target->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_PALADIN, 0x00000000, 0x00000800, 0x00000000, caster->GetGUID());
- if (!aurEff)
+ // get current aura on target, if any
+ AuraEffect const* sealDot = target->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_PALADIN, 0x00000000, 0x00000800, 0x00000000, caster->GetGUID());
+ if (!sealDot)
return;
- uint8 stacks = aurEff->GetBase()->GetStackAmount();
- uint8 maxStacks = aurEff->GetSpellInfo()->StackAmount;
+ uint8 const stacks = sealDot->GetBase()->GetStackAmount();
+ uint8 const maxStacks = sealDot->GetSpellInfo()->StackAmount;
if (stacks < maxStacks && !(eventInfo.GetTypeMask() & PROC_FLAG_DONE_SPELL_MELEE_DMG_CLASS))
return;
@@ -2119,7 +2133,7 @@ class spell_pal_seal_of_vengeance : public SpellScriptLoader
amount *= stacks;
amount /= maxStacks;
- caster->CastCustomSpell(DamageSpell, SPELLVALUE_BASE_POINT0, amount, target, true);
+ caster->CastCustomSpell(DamageSpell, SPELLVALUE_BASE_POINT0, amount, target, true, nullptr, aurEff);
}
void Register() override
@@ -2203,7 +2217,7 @@ class spell_pal_spiritual_attunement : public SpellScriptLoader
HealInfo* healInfo = eventInfo.GetHealInfo();
int32 amount = CalculatePct(static_cast<int32>(healInfo->GetEffectiveHeal()), aurEff->GetAmount());
- eventInfo.GetActionTarget()->CastCustomSpell(SPELL_PALADIN_SPIRITUAL_ATTUNEMENT_MANA, SPELLVALUE_BASE_POINT0, amount, (Unit*)nullptr, true);
+ eventInfo.GetActionTarget()->CastCustomSpell(SPELL_PALADIN_SPIRITUAL_ATTUNEMENT_MANA, SPELLVALUE_BASE_POINT0, amount, (Unit*)nullptr, true, nullptr, aurEff);
}
void Register() override
@@ -2250,10 +2264,10 @@ class spell_pal_sheath_of_light : public SpellScriptLoader
SpellInfo const* spellInfo = sSpellMgr->AssertSpellInfo(SPELL_PALADIN_SHEATH_OF_LIGHT_HEAL);
int32 amount = CalculatePct(static_cast<int32>(healInfo->GetHeal()), aurEff->GetAmount());
amount /= spellInfo->GetMaxTicks();
- // Add remaining ticks to damage done
+ // Add remaining ticks to healing done
amount += target->GetRemainingPeriodicAmount(caster->GetGUID(), SPELL_PALADIN_SHEATH_OF_LIGHT_HEAL, SPELL_AURA_PERIODIC_HEAL);
- caster->CastCustomSpell(SPELL_PALADIN_SHEATH_OF_LIGHT_HEAL, SPELLVALUE_BASE_POINT0, amount, target, true);
+ caster->CastCustomSpell(SPELL_PALADIN_SHEATH_OF_LIGHT_HEAL, SPELLVALUE_BASE_POINT0, amount, target, true, nullptr, aurEff);
}
void Register() override
@@ -2288,7 +2302,7 @@ class spell_pal_t3_6p_bonus : public SpellScriptLoader
return true;
}
- void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
+ void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
@@ -2319,7 +2333,7 @@ class spell_pal_t3_6p_bonus : public SpellScriptLoader
return;
}
- caster->CastSpell(target, spellId, true);
+ caster->CastSpell(target, spellId, true, nullptr, aurEff);
}
void Register() override
@@ -2365,10 +2379,10 @@ class spell_pal_t8_2p_bonus : public SpellScriptLoader
SpellInfo const* spellInfo = sSpellMgr->AssertSpellInfo(SPELL_PALADIN_HOLY_MENDING);
int32 amount = CalculatePct(static_cast<int32>(healInfo->GetHeal()), aurEff->GetAmount());
amount /= spellInfo->GetMaxTicks();
- // Add remaining ticks to damage done
+ // Add remaining ticks to healing done
amount += target->GetRemainingPeriodicAmount(caster->GetGUID(), SPELL_PALADIN_HOLY_MENDING, SPELL_AURA_PERIODIC_HEAL);
- caster->CastCustomSpell(SPELL_PALADIN_HOLY_MENDING, SPELLVALUE_BASE_POINT0, amount, target, true);
+ caster->CastCustomSpell(SPELL_PALADIN_HOLY_MENDING, SPELLVALUE_BASE_POINT0, amount, target, true, nullptr, aurEff);
}
void Register() override
diff --git a/src/server/scripts/Spells/spell_priest.cpp b/src/server/scripts/Spells/spell_priest.cpp
index d1b8ab2e8df..8a4bdeedccc 100644
--- a/src/server/scripts/Spells/spell_priest.cpp
+++ b/src/server/scripts/Spells/spell_priest.cpp
@@ -120,7 +120,7 @@ class spell_pri_aq_3p_bonus : public SpellScriptLoader
return true;
}
- void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
+ void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
Unit* caster = eventInfo.GetActor();
@@ -132,7 +132,7 @@ class spell_pri_aq_3p_bonus : public SpellScriptLoader
return;
int32 amount = CalculatePct(static_cast<int32>(healInfo->GetHeal()), 10);
- caster->CastCustomSpell(SPELL_PRIEST_ORACULAR_HEAL, SPELLVALUE_BASE_POINT0, amount, caster, true);
+ caster->CastCustomSpell(SPELL_PRIEST_ORACULAR_HEAL, SPELLVALUE_BASE_POINT0, amount, caster, true, nullptr, aurEff);
}
void Register() override
@@ -236,7 +236,7 @@ class spell_pri_body_and_soul : public SpellScriptLoader
return;
if (roll_chance_i(aurEff->GetAmount()))
- caster->CastSpell(caster, SPELL_PRIEST_BODY_AND_SOUL_POISON_TRIGGER, true);
+ caster->CastSpell(caster, SPELL_PRIEST_BODY_AND_SOUL_POISON_TRIGGER, true, nullptr, aurEff);
}
void Register() override
@@ -332,7 +332,7 @@ class spell_pri_divine_aegis : public SpellScriptLoader
absorb = std::min(absorb, eventInfo.GetProcTarget()->getLevel() * 125);
- GetTarget()->CastCustomSpell(SPELL_PRIEST_DIVINE_AEGIS, SPELLVALUE_BASE_POINT0, absorb, eventInfo.GetProcTarget(), true, NULL, aurEff);
+ GetTarget()->CastCustomSpell(SPELL_PRIEST_DIVINE_AEGIS, SPELLVALUE_BASE_POINT0, absorb, eventInfo.GetProcTarget(), true, nullptr, aurEff);
}
void Register() override
@@ -412,7 +412,7 @@ class spell_pri_glyph_of_dispel_magic : public SpellScriptLoader
Unit* target = eventInfo.GetProcTarget();
int32 amount = static_cast<int32>(target->CountPctFromMaxHealth(aurEff->GetAmount()));
- caster->CastCustomSpell(SPELL_PRIEST_GLYPH_OF_DISPEL_MAGIC_HEAL, SPELLVALUE_BASE_POINT0, amount, target, true);
+ caster->CastCustomSpell(SPELL_PRIEST_GLYPH_OF_DISPEL_MAGIC_HEAL, SPELLVALUE_BASE_POINT0, amount, target, true, nullptr, aurEff);
}
void Register() override
@@ -454,7 +454,7 @@ class spell_pri_glyph_of_prayer_of_healing : public SpellScriptLoader
SpellInfo const* triggeredSpellInfo = sSpellMgr->AssertSpellInfo(SPELL_PRIEST_GLYPH_OF_PRAYER_OF_HEALING_HEAL);
int32 heal = int32(CalculatePct(healInfo->GetHeal(), aurEff->GetAmount()) / triggeredSpellInfo->GetMaxTicks());
- GetTarget()->CastCustomSpell(SPELL_PRIEST_GLYPH_OF_PRAYER_OF_HEALING_HEAL, SPELLVALUE_BASE_POINT0, heal, eventInfo.GetProcTarget(), true, NULL, aurEff);
+ GetTarget()->CastCustomSpell(SPELL_PRIEST_GLYPH_OF_PRAYER_OF_HEALING_HEAL, SPELLVALUE_BASE_POINT0, heal, eventInfo.GetProcTarget(), true, nullptr, aurEff);
}
void Register() override
@@ -660,15 +660,15 @@ class spell_pri_item_t6_trinket : public SpellScriptLoader
return true;
}
- void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
+ void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
Unit* caster = eventInfo.GetActor();
if (eventInfo.GetSpellTypeMask() & PROC_SPELL_TYPE_HEAL)
- caster->CastSpell((Unit*)nullptr, SPELL_PRIEST_DIVINE_BLESSING, true);
+ caster->CastSpell((Unit*)nullptr, SPELL_PRIEST_DIVINE_BLESSING, true, nullptr, aurEff);
if (eventInfo.GetSpellTypeMask() & PROC_SPELL_TYPE_DAMAGE)
- caster->CastSpell((Unit*)nullptr, SPELL_PRIEST_DIVINE_WRATH, true);
+ caster->CastSpell((Unit*)nullptr, SPELL_PRIEST_DIVINE_WRATH, true, nullptr, aurEff);
}
void Register() override
@@ -1091,17 +1091,22 @@ class spell_pri_renew : public SpellScriptLoader
void HandleApplyEffect(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/)
{
- if (Unit* caster = GetCaster())
+ Unit* caster = GetCaster();
+ if (!caster)
+ return;
+
+ // Empowered Renew
+ if (AuraEffect const* empoweredRenewAurEff = caster->GetDummyAuraEffect(SPELLFAMILY_PRIEST, PRIEST_ICON_ID_EMPOWERED_RENEW_TALENT, EFFECT_1))
{
- // Empowered Renew
- if (AuraEffect const* empoweredRenewAurEff = caster->GetDummyAuraEffect(SPELLFAMILY_PRIEST, PRIEST_ICON_ID_EMPOWERED_RENEW_TALENT, EFFECT_1))
- {
- uint32 heal = caster->SpellHealingBonusDone(GetTarget(), GetSpellInfo(), GetEffect(EFFECT_0)->GetAmount(), DOT);
- heal = GetTarget()->SpellHealingBonusTaken(caster, GetSpellInfo(), heal, DOT);
+ int32 heal = (aurEff->GetAmount() + aurEff->GetBonusAmount()) * aurEff->GetDonePct();
+ if (Player* modOwner = caster->GetSpellModOwner())
+ modOwner->ApplySpellMod<SPELLMOD_DOT>(GetId(), heal);
+ heal = GetTarget()->SpellHealingBonusTaken(caster, GetSpellInfo(), heal, DOT);
- int32 basepoints0 = empoweredRenewAurEff->GetAmount() * GetEffect(EFFECT_0)->GetTotalTicks() * int32(heal) / 100;
- caster->CastCustomSpell(GetTarget(), SPELL_PRIEST_EMPOWERED_RENEW, &basepoints0, NULL, NULL, true, NULL, aurEff);
- }
+ heal *= GetSpellInfo()->GetMaxTicks();
+
+ int32 basepoints0 = CalculatePct(heal, empoweredRenewAurEff->GetAmount());
+ caster->CastCustomSpell(SPELL_PRIEST_EMPOWERED_RENEW, SPELLVALUE_BASE_POINT0, basepoints0, GetTarget(), true, nullptr, aurEff);
}
}
@@ -1147,11 +1152,11 @@ class spell_pri_shadowfiend_death : public SpellScriptLoader
return shadowfiend->HealthBelowPctDamaged(1, damageInfo->GetDamage());
}
- void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
+ void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
Unit* caster = eventInfo.GetActionTarget()->GetOwner();
- caster->CastSpell(caster, SPELL_PRIEST_GLYPH_OF_SHADOWFIEND_MANA, true);
+ caster->CastSpell(caster, SPELL_PRIEST_GLYPH_OF_SHADOWFIEND_MANA, true, nullptr, aurEff);
}
void Register() override
@@ -1227,7 +1232,7 @@ class spell_pri_vampiric_embrace : public SpellScriptLoader
int32 selfHeal = CalculatePct(static_cast<int32>(damageInfo->GetDamage()), aurEff->GetAmount());
int32 partyHeal = selfHeal / 5;
Unit* caster = eventInfo.GetActor();
- caster->CastCustomSpell((Unit*)nullptr, SPELL_PRIEST_VAMPIRIC_EMBRACE_HEAL, &partyHeal, &selfHeal, nullptr, true);
+ caster->CastCustomSpell((Unit*)nullptr, SPELL_PRIEST_VAMPIRIC_EMBRACE_HEAL, &partyHeal, &selfHeal, nullptr, true, nullptr, aurEff);
}
void Register() override
@@ -1275,16 +1280,16 @@ class spell_pri_vampiric_touch : public SpellScriptLoader
{
int32 damage = aurEff->GetAmount() * 8;
// backfire damage
- caster->CastCustomSpell(target, SPELL_PRIEST_VAMPIRIC_TOUCH_DISPEL, &damage, NULL, NULL, true, NULL, aurEff);
+ caster->CastCustomSpell(SPELL_PRIEST_VAMPIRIC_TOUCH_DISPEL, SPELLVALUE_BASE_POINT0, damage, target, true, nullptr, aurEff);
}
}
}
}
- void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
+ void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
- eventInfo.GetActor()->CastSpell((Unit*)nullptr, SPELL_REPLENISHMENT, true);
+ eventInfo.GetActor()->CastSpell((Unit*)nullptr, SPELL_REPLENISHMENT, true, nullptr, aurEff);
}
void Register() override
@@ -1319,10 +1324,10 @@ class spell_pri_t3_4p_bonus : public SpellScriptLoader
return true;
}
- void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
+ void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
- eventInfo.GetActor()->CastSpell(eventInfo.GetProcTarget(), SPELL_PRIEST_ARMOR_OF_FAITH, true);
+ eventInfo.GetActor()->CastSpell(eventInfo.GetProcTarget(), SPELL_PRIEST_ARMOR_OF_FAITH, true, nullptr, aurEff);
}
void Register() override
@@ -1418,7 +1423,7 @@ class spell_pri_t10_heal_2p_bonus : public SpellScriptLoader
Unit* target = eventInfo.GetProcTarget();
amount += target->GetRemainingPeriodicAmount(caster->GetGUID(), SPELL_PRIEST_BLESSED_HEALING, SPELL_AURA_PERIODIC_HEAL);
- caster->CastCustomSpell(SPELL_PRIEST_BLESSED_HEALING, SPELLVALUE_BASE_POINT0, amount, target, true);
+ caster->CastCustomSpell(SPELL_PRIEST_BLESSED_HEALING, SPELLVALUE_BASE_POINT0, amount, target, true, nullptr, aurEff);
}
void Register() override
diff --git a/src/server/scripts/Spells/spell_quest.cpp b/src/server/scripts/Spells/spell_quest.cpp
index 2eca20199b4..fd99888f8d9 100644
--- a/src/server/scripts/Spells/spell_quest.cpp
+++ b/src/server/scripts/Spells/spell_quest.cpp
@@ -2565,6 +2565,146 @@ public:
}
};
+enum ApplyHeatAndStir
+{
+ SPELL_SPURTS_AND_SMOKE = 38594,
+ SPELL_FAILED_MIX_1 = 43376,
+ SPELL_FAILED_MIX_2 = 43378,
+ SPELL_FAILED_MIX_3 = 43970,
+ SPELL_SUCCESSFUL_MIX = 43377,
+
+ CREATURE_GENERIC_TRIGGER_LAB = 24042,
+
+ TALK_0 = 0,
+ TALK_1 = 1
+};
+
+class spell_q11306_mixing_blood : public SpellScriptLoader
+{
+public:
+ spell_q11306_mixing_blood() : SpellScriptLoader("spell_q11306_mixing_blood") { }
+
+ class spell_q11306_mixing_blood_SpellScript : public SpellScript
+ {
+ PrepareSpellScript(spell_q11306_mixing_blood_SpellScript);
+
+ void HandleEffect(SpellEffIndex /*effIndex*/)
+ {
+ if (Unit* caster = GetCaster())
+ if (Creature* trigger = caster->FindNearestCreature(CREATURE_GENERIC_TRIGGER_LAB, 100.0f))
+ trigger->AI()->DoCastSelf(SPELL_SPURTS_AND_SMOKE);
+ }
+
+ void Register() override
+ {
+ OnEffectHit += SpellEffectFn(spell_q11306_mixing_blood_SpellScript::HandleEffect, EFFECT_1, SPELL_EFFECT_SEND_EVENT);
+ }
+ };
+
+ SpellScript* GetSpellScript() const override
+ {
+ return new spell_q11306_mixing_blood_SpellScript();
+ }
+};
+
+class spell_q11306_mixing_vrykul_blood : public SpellScriptLoader
+{
+ public:
+ spell_q11306_mixing_vrykul_blood() : SpellScriptLoader("spell_q11306_mixing_vrykul_blood") { }
+
+ class spell_q11306_mixing_vrykul_blood_SpellScript : public SpellScript
+ {
+ PrepareSpellScript(spell_q11306_mixing_vrykul_blood_SpellScript);
+
+ void HandleDummy(SpellEffIndex /*effIndex*/)
+ {
+ if (Unit* caster = GetCaster())
+ {
+ uint8 chance = urand(0, 99);
+ uint32 spellId = 0;
+
+ // 90% chance of getting one out of three failure effects
+ if (chance < 30)
+ spellId = SPELL_FAILED_MIX_1;
+ else if (chance < 60)
+ spellId = SPELL_FAILED_MIX_2;
+ else if (chance < 90)
+ spellId = SPELL_FAILED_MIX_3;
+ else // 10% chance of successful cast
+ spellId = SPELL_SUCCESSFUL_MIX;
+
+ caster->CastSpell(caster, spellId, true);
+ }
+ }
+
+ void Register() override
+ {
+ OnEffectHitTarget += SpellEffectFn(spell_q11306_mixing_vrykul_blood_SpellScript::HandleDummy, EFFECT_1, SPELL_EFFECT_DUMMY);
+ }
+ };
+
+ SpellScript* GetSpellScript() const override
+ {
+ return new spell_q11306_mixing_vrykul_blood_SpellScript();
+ }
+};
+
+class spell_q11306_failed_mix_43376 : public SpellScriptLoader
+{
+public:
+ spell_q11306_failed_mix_43376() : SpellScriptLoader("spell_q11306_failed_mix_43376") { }
+
+ class spell_q11306_failed_mix_43376_SpellScript : public SpellScript
+ {
+ PrepareSpellScript(spell_q11306_failed_mix_43376_SpellScript);
+
+ void HandleEffect(SpellEffIndex /*effIndex*/)
+ {
+ if (Unit* caster = GetCaster())
+ if (Creature* trigger = caster->FindNearestCreature(CREATURE_GENERIC_TRIGGER_LAB, 100.0f))
+ trigger->AI()->Talk(TALK_0, caster);
+ }
+
+ void Register() override
+ {
+ OnEffectHit += SpellEffectFn(spell_q11306_failed_mix_43376_SpellScript::HandleEffect, EFFECT_1, SPELL_EFFECT_SEND_EVENT);
+ }
+ };
+
+ SpellScript* GetSpellScript() const override
+ {
+ return new spell_q11306_failed_mix_43376_SpellScript();
+ }
+};
+
+class spell_q11306_failed_mix_43378 : public SpellScriptLoader
+{
+public:
+ spell_q11306_failed_mix_43378() : SpellScriptLoader("spell_q11306_failed_mix_43378") { }
+
+ class spell_q11306_failed_mix_43378_SpellScript : public SpellScript
+ {
+ PrepareSpellScript(spell_q11306_failed_mix_43378_SpellScript);
+
+ void HandleEffect(SpellEffIndex /*effIndex*/)
+ {
+ if (Unit* caster = GetCaster())
+ if (Creature* trigger = caster->FindNearestCreature(CREATURE_GENERIC_TRIGGER_LAB, 100.0f))
+ trigger->AI()->Talk(TALK_1, caster);
+ }
+
+ void Register() override
+ {
+ OnEffectHit += SpellEffectFn(spell_q11306_failed_mix_43378_SpellScript::HandleEffect, EFFECT_2, SPELL_EFFECT_SEND_EVENT);
+ }
+ };
+
+ SpellScript* GetSpellScript() const override
+ {
+ return new spell_q11306_failed_mix_43378_SpellScript();
+ }
+};
+
void AddSC_quest_spell_scripts()
{
new spell_q55_sacred_cleansing();
@@ -2628,4 +2768,8 @@ void AddSC_quest_spell_scripts()
new spell_q12414_hand_over_reins();
new spell_q13665_q13790_bested_trigger();
new spell_59064_59439_portals();
+ new spell_q11306_mixing_blood();
+ new spell_q11306_mixing_vrykul_blood();
+ new spell_q11306_failed_mix_43376();
+ new spell_q11306_failed_mix_43378();
}
diff --git a/src/server/scripts/Spells/spell_rogue.cpp b/src/server/scripts/Spells/spell_rogue.cpp
index bd74e9b2e73..f3d30af1f84 100644
--- a/src/server/scripts/Spells/spell_rogue.cpp
+++ b/src/server/scripts/Spells/spell_rogue.cpp
@@ -83,10 +83,10 @@ class spell_rog_blade_flurry : public SpellScriptLoader
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
- if (eventInfo.GetDamageInfo())
+ if (DamageInfo* damageInfo = eventInfo.GetDamageInfo())
{
- int32 damage = eventInfo.GetDamageInfo()->GetDamage();
- GetTarget()->CastCustomSpell(SPELL_ROGUE_BLADE_FLURRY_EXTRA_ATTACK, SPELLVALUE_BASE_POINT0, damage, _procTarget, true, NULL, aurEff);
+ int32 damage = damageInfo->GetDamage();
+ GetTarget()->CastCustomSpell(SPELL_ROGUE_BLADE_FLURRY_EXTRA_ATTACK, SPELLVALUE_BASE_POINT0, damage, _procTarget, true, nullptr, aurEff);
}
}
@@ -232,10 +232,10 @@ class spell_rog_deadly_brew : public SpellScriptLoader
return true;
}
- void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
+ void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
- eventInfo.GetActor()->CastSpell(eventInfo.GetProcTarget(), SPELL_ROGUE_CRIPPLING_POISON, true);
+ eventInfo.GetActor()->CastSpell(eventInfo.GetProcTarget(), SPELL_ROGUE_CRIPPLING_POISON, true, nullptr, aurEff);
}
void Register() override
@@ -625,7 +625,7 @@ class spell_rog_quick_recovery : public SpellScriptLoader
Unit* caster = eventInfo.GetActor();
int32 amount = CalculatePct(spellInfo->CalcPowerCost(caster, spellInfo->GetSchoolMask()), aurEff->GetAmount());
- caster->CastCustomSpell(SPELL_ROGUE_QUICK_RECOVERY_ENERGY, SPELLVALUE_BASE_POINT0, amount, (Unit*)nullptr, true);
+ caster->CastCustomSpell(SPELL_ROGUE_QUICK_RECOVERY_ENERGY, SPELLVALUE_BASE_POINT0, amount, (Unit*)nullptr, true, nullptr, aurEff);
}
void Register() override
@@ -721,10 +721,10 @@ class spell_rog_glyph_of_backstab : public SpellScriptLoader
return true;
}
- void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
+ void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
- eventInfo.GetActor()->CastSpell(eventInfo.GetProcTarget(), SPELL_ROGUE_GLYPH_OF_BACKSTAB_TRIGGER, true);
+ eventInfo.GetActor()->CastSpell(eventInfo.GetProcTarget(), SPELL_ROGUE_GLYPH_OF_BACKSTAB_TRIGGER, true, nullptr, aurEff);
}
void Register() override
diff --git a/src/server/scripts/Spells/spell_shaman.cpp b/src/server/scripts/Spells/spell_shaman.cpp
index 2a568316ad4..37b08aee7ca 100644
--- a/src/server/scripts/Spells/spell_shaman.cpp
+++ b/src/server/scripts/Spells/spell_shaman.cpp
@@ -83,7 +83,8 @@ enum ShamanSpells
SPELL_SHAMAN_LIGHTNING_SHIELD_DAMAGE_R1 = 26364,
SPELL_SHAMAN_SHAMANISTIC_RAGE_PROC = 30824,
SPELL_SHAMAN_MAELSTROM_POWER = 70831,
- SPELL_SHAMAN_T10_ENHANCEMENT_4P_BONUS = 70832
+ SPELL_SHAMAN_T10_ENHANCEMENT_4P_BONUS = 70832,
+ SPELL_SHAMAN_BLESSING_OF_THE_ETERNALS_R1 = 51554
};
enum ShamanSpellIcons
@@ -118,7 +119,7 @@ class spell_sha_ancestral_awakening : public SpellScriptLoader
return;
int32 amount = CalculatePct(static_cast<int32>(healInfo->GetHeal()), aurEff->GetAmount());
- eventInfo.GetActor()->CastCustomSpell(SPELL_SHAMAN_ANCESTRAL_AWAKENING_DUMMY, SPELLVALUE_BASE_POINT0, amount, (Unit*)nullptr, true);
+ eventInfo.GetActor()->CastCustomSpell(SPELL_SHAMAN_ANCESTRAL_AWAKENING_DUMMY, SPELLVALUE_BASE_POINT0, amount, (Unit*)nullptr, true, nullptr, aurEff);
}
void Register() override
@@ -422,7 +423,7 @@ class spell_sha_earth_shield : public SpellScriptLoader
{
PreventDefaultAction();
- GetTarget()->CastCustomSpell(SPELL_SHAMAN_EARTH_SHIELD_HEAL, SPELLVALUE_BASE_POINT0, aurEff->GetAmount(), GetTarget(), true, NULL, aurEff, GetCasterGUID());
+ GetTarget()->CastCustomSpell(SPELL_SHAMAN_EARTH_SHIELD_HEAL, SPELLVALUE_BASE_POINT0, aurEff->GetAmount(), GetTarget(), true, nullptr, aurEff, GetCasterGUID());
}
void Register() override
@@ -537,6 +538,46 @@ class spell_sha_earthen_power : public SpellScriptLoader
}
};
+// -51940 - Earthliving Weapon (Passive)
+class spell_sha_earthliving_weapon : public SpellScriptLoader
+{
+ public:
+ spell_sha_earthliving_weapon() : SpellScriptLoader("spell_sha_earthliving_weapon") { }
+
+ class spell_sha_earthliving_weapon_AuraScript : public AuraScript
+ {
+ PrepareAuraScript(spell_sha_earthliving_weapon_AuraScript);
+
+ bool Validate(SpellInfo const* /*spellInfo*/) override
+ {
+ if (!sSpellMgr->GetSpellInfo(SPELL_SHAMAN_BLESSING_OF_THE_ETERNALS_R1))
+ return false;
+ return true;
+ }
+
+ bool CheckProc(ProcEventInfo& eventInfo)
+ {
+ int32 chance = 20;
+ Unit* caster = eventInfo.GetActor();
+ if (AuraEffect const* aurEff = caster->GetAuraEffectOfRankedSpell(SPELL_SHAMAN_BLESSING_OF_THE_ETERNALS_R1, EFFECT_1, caster->GetGUID()))
+ if (eventInfo.GetProcTarget()->HasAuraState(AURA_STATE_HEALTHLESS_35_PERCENT))
+ chance += aurEff->GetAmount();
+
+ return roll_chance_i(chance);
+ }
+
+ void Register() override
+ {
+ DoCheckProc += AuraCheckProcFn(spell_sha_earthliving_weapon_AuraScript::CheckProc);
+ }
+ };
+
+ AuraScript* GetAuraScript() const override
+ {
+ return new spell_sha_earthliving_weapon_AuraScript();
+ }
+};
+
// -1535 - Fire Nova
class spell_sha_fire_nova : public SpellScriptLoader
{
@@ -691,25 +732,25 @@ class spell_sha_flametongue_weapon : public SpellScriptLoader
Item* item = ASSERT_NOTNULL(player->GetWeaponForAttack(attType));
- float basePoints(GetSpellInfo()->Effects[aurEff->GetEffIndex()].CalcValue());
+ float const basePoints = GetSpellInfo()->Effects[aurEff->GetEffIndex()].CalcValue();
// Flametongue max damage is normalized based on a 4.0 speed weapon
// Tooltip says max damage = BasePoints / 25, so BasePoints / 25 / 4 to get base damage per 1.0s AS
float fireDamage = basePoints / 100.0f;
- float attackSpeed = player->GetAttackTime(attType) / 1000.f;
+ float const attackSpeed = player->GetAttackTime(attType) / 1000.f;
fireDamage *= attackSpeed;
// clip value between (BasePoints / 77) and (BasePoints / 25) as the tooltip indicates
RoundToInterval(fireDamage, basePoints / 77.0f, basePoints / 25.0f);
// Calculate Spell Power scaling
- float spellPowerBonus(player->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_FIRE) + target->SpellBaseDamageBonusTaken(SPELL_SCHOOL_MASK_FIRE));
+ float spellPowerBonus = player->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_FIRE) + target->SpellBaseDamageBonusTaken(SPELL_SCHOOL_MASK_FIRE);
float const spCoeff = 0.03811f;
spellPowerBonus *= spCoeff * attackSpeed;
// All done, now proc damage
int32 amount = static_cast<int32>(fireDamage + spellPowerBonus);
- player->CastCustomSpell(SPELL_SHAMAN_FLAMETONGUE_ATTACK, SPELLVALUE_BASE_POINT0, amount, target, true, item);
+ player->CastCustomSpell(SPELL_SHAMAN_FLAMETONGUE_ATTACK, SPELLVALUE_BASE_POINT0, amount, target, true, item, aurEff);
}
void Register() override
@@ -757,7 +798,7 @@ class spell_sha_frozen_power : public SpellScriptLoader
if (caster->GetDistance(target) < minDistance)
return;
- caster->CastSpell(target, SPELL_SHAMAN_FREEZE, true);
+ caster->CastSpell(target, SPELL_SHAMAN_FREEZE, true, nullptr, aurEff);
}
void Register() override
@@ -840,7 +881,7 @@ class spell_sha_glyph_of_healing_wave : public SpellScriptLoader
return;
int32 amount = CalculatePct(static_cast<int32>(healInfo->GetHeal()), aurEff->GetAmount());
- caster->CastCustomSpell(SPELL_SHAMAN_GLYPH_OF_HEALING_WAVE_HEAL, SPELLVALUE_BASE_POINT0, amount, (Unit*)nullptr, true);
+ caster->CastCustomSpell(SPELL_SHAMAN_GLYPH_OF_HEALING_WAVE_HEAL, SPELLVALUE_BASE_POINT0, amount, (Unit*)nullptr, true, nullptr, aurEff);
}
void Register() override
@@ -900,7 +941,7 @@ class spell_sha_glyph_of_totem_of_wrath : public SpellScriptLoader
int32 bp0 = CalculatePct(totemSpell->Effects[EFFECT_0].CalcValue(caster), aurEff->GetAmount());
int32 bp1 = CalculatePct(totemSpell->Effects[EFFECT_1].CalcValue(caster), aurEff->GetAmount());
- caster->CastCustomSpell((Unit*)nullptr, SPELL_SHAMAN_TOTEM_OF_WRATH_SPELL_POWER, &bp0, &bp1, nullptr, true);
+ caster->CastCustomSpell((Unit*)nullptr, SPELL_SHAMAN_TOTEM_OF_WRATH_SPELL_POWER, &bp0, &bp1, nullptr, true, nullptr, aurEff);
}
void Register() override
@@ -956,7 +997,8 @@ class spell_sha_healing_stream_totem : public SpellScriptLoader
damage = int32(target->SpellHealingBonusTaken(owner, triggeringSpell, damage, HEAL));
}
- caster->CastCustomSpell(target, SPELL_SHAMAN_TOTEM_HEALING_STREAM_HEAL, &damage, 0, 0, true, 0, 0, GetOriginalCaster()->GetGUID());
+
+ caster->CastCustomSpell(SPELL_SHAMAN_TOTEM_HEALING_STREAM_HEAL, SPELLVALUE_BASE_POINT0, damage, target, true, nullptr, nullptr, GetOriginalCaster()->GetGUID());
}
}
}
@@ -1003,9 +1045,8 @@ class spell_sha_heroism : public SpellScriptLoader
void Register() override
{
- OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_sha_heroism_SpellScript::RemoveInvalidTargets, EFFECT_0, TARGET_UNIT_CASTER_AREA_RAID);
- OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_sha_heroism_SpellScript::RemoveInvalidTargets, EFFECT_1, TARGET_UNIT_CASTER_AREA_RAID);
- OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_sha_heroism_SpellScript::RemoveInvalidTargets, EFFECT_2, TARGET_UNIT_CASTER_AREA_RAID);
+ OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_sha_heroism_SpellScript::RemoveInvalidTargets, EFFECT_ALL, TARGET_UNIT_CASTER_AREA_RAID);
+
AfterHit += SpellHitFn(spell_sha_heroism_SpellScript::ApplyDebuff);
}
};
@@ -1050,17 +1091,17 @@ class spell_sha_imp_water_shield : public SpellScriptLoader
return true;
}
- void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
+ void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
Unit* caster = eventInfo.GetActor();
// Get Water Shield
- AuraEffect const* aurEff = caster->GetAuraEffect(SPELL_AURA_PROC_TRIGGER_SPELL, SPELLFAMILY_SHAMAN, 0x00000000, 0x00000020, 0x00000000, caster->GetGUID());
- if (!aurEff)
+ AuraEffect const* waterShield = caster->GetAuraEffect(SPELL_AURA_PROC_TRIGGER_SPELL, SPELLFAMILY_SHAMAN, 0x00000000, 0x00000020, 0x00000000, caster->GetGUID());
+ if (!waterShield)
return;
- uint32 spellId = aurEff->GetSpellInfo()->Effects[aurEff->GetEffIndex()].TriggerSpell;
- caster->CastSpell((Unit*)nullptr, spellId, true);
+ uint32 spellId = waterShield->GetSpellInfo()->Effects[waterShield->GetEffIndex()].TriggerSpell;
+ caster->CastSpell((Unit*)nullptr, spellId, true, nullptr, aurEff);
}
void Register() override
@@ -1094,7 +1135,7 @@ class spell_sha_lightning_overload : public SpellScriptLoader
return true;
}
- void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
+ void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
@@ -1120,7 +1161,7 @@ class spell_sha_lightning_overload : public SpellScriptLoader
spellId = sSpellMgr->GetSpellWithRank(SPELL_SHAMAN_CHAIN_LIGHTNING_OVERLOAD_R1, spellInfo->GetRank());
}
- eventInfo.GetActor()->CastSpell(eventInfo.GetProcTarget(), spellId, true);
+ eventInfo.GetActor()->CastSpell(eventInfo.GetProcTarget(), spellId, true, nullptr, aurEff);
}
void Register() override
@@ -1155,7 +1196,7 @@ class spell_sha_item_lightning_shield : public SpellScriptLoader
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
- GetTarget()->CastSpell(eventInfo.GetProcTarget(), SPELL_SHAMAN_ITEM_LIGHTNING_SHIELD, true, NULL, aurEff);
+ GetTarget()->CastSpell(eventInfo.GetProcTarget(), SPELL_SHAMAN_ITEM_LIGHTNING_SHIELD, true, nullptr, aurEff);
}
void Register() override
@@ -1190,7 +1231,7 @@ class spell_sha_item_lightning_shield_trigger : public SpellScriptLoader
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& /*eventInfo*/)
{
PreventDefaultAction();
- GetTarget()->CastSpell(GetTarget(), SPELL_SHAMAN_ITEM_LIGHTNING_SHIELD_DAMAGE, true, NULL, aurEff);
+ GetTarget()->CastSpell(GetTarget(), SPELL_SHAMAN_ITEM_LIGHTNING_SHIELD_DAMAGE, true, nullptr, aurEff);
}
void Register() override
@@ -1222,11 +1263,6 @@ class spell_sha_item_mana_surge : public SpellScriptLoader
return true;
}
- bool CheckProc(ProcEventInfo& eventInfo)
- {
- return eventInfo.GetDamageInfo()->GetSpellInfo() != nullptr;
- }
-
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
@@ -1237,12 +1273,11 @@ class spell_sha_item_mana_surge : public SpellScriptLoader
int32 mana = spellInfo->CalcPowerCost(GetTarget(), eventInfo.GetSchoolMask());
int32 damage = CalculatePct(mana, 35);
- GetTarget()->CastCustomSpell(SPELL_SHAMAN_ITEM_MANA_SURGE, SPELLVALUE_BASE_POINT0, damage, GetTarget(), true, NULL, aurEff);
+ GetTarget()->CastCustomSpell(SPELL_SHAMAN_ITEM_MANA_SURGE, SPELLVALUE_BASE_POINT0, damage, GetTarget(), true, nullptr, aurEff);
}
void Register() override
{
- DoCheckProc += AuraCheckProcFn(spell_sha_item_mana_surge_AuraScript::CheckProc);
OnEffectProc += AuraEffectProcFn(spell_sha_item_mana_surge_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_PROC_TRIGGER_SPELL);
}
};
@@ -1271,7 +1306,7 @@ class spell_sha_item_t6_trinket : public SpellScriptLoader
return true;
}
- void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
+ void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
SpellInfo const* spellInfo = eventInfo.GetSpellInfo();
@@ -1303,7 +1338,7 @@ class spell_sha_item_t6_trinket : public SpellScriptLoader
return;
if (roll_chance_i(chance))
- eventInfo.GetActor()->CastSpell((Unit*)nullptr, spellId, true);
+ eventInfo.GetActor()->CastSpell((Unit*)nullptr, spellId, true, nullptr, aurEff);
}
void Register() override
@@ -1472,7 +1507,7 @@ class spell_sha_maelstrom_weapon : public SpellScriptLoader
if (!aurEff || !roll_chance_i(aurEff->GetAmount()))
return;
- caster->CastSpell((Unit*)nullptr, SPELL_SHAMAN_MAELSTROM_POWER, true);
+ caster->CastSpell((Unit*)nullptr, SPELL_SHAMAN_MAELSTROM_POWER, true, nullptr, aurEff);
}
void Register() override
@@ -1558,7 +1593,7 @@ class spell_sha_mana_tide_totem : public SpellScriptLoader
effValue += dummy->GetAmount();
// Regenerate 6% of Total Mana Every 3 secs
int32 effBasePoints0 = int32(CalculatePct(unitTarget->GetMaxPower(POWER_MANA), effValue));
- caster->CastCustomSpell(unitTarget, SPELL_SHAMAN_MANA_TIDE_TOTEM, &effBasePoints0, NULL, NULL, true, NULL, NULL, GetOriginalCaster()->GetGUID());
+ caster->CastCustomSpell(SPELL_SHAMAN_MANA_TIDE_TOTEM, SPELLVALUE_BASE_POINT0, effBasePoints0, unitTarget, true, nullptr, nullptr, GetOriginalCaster()->GetGUID());
}
}
}
@@ -1597,7 +1632,7 @@ public:
{
PreventDefaultAction();
DamageInfo* damageInfo = eventInfo.GetDamageInfo();
- if (!damageInfo)
+ if (!damageInfo || !damageInfo->GetDamage())
return;
int32 healthpct = aurEff->GetSpellInfo()->Effects[EFFECT_1].CalcValue(); // %s2 - the 30% threshold for health
@@ -1606,7 +1641,6 @@ public:
{
if (target->HealthBelowPctDamaged(healthpct, damageInfo->GetDamage()))
{
-
uint32 bp = CalculatePct(target->GetMaxHealth(), aurEff->GetAmount());
target->CastCustomSpell(SPELL_SHAMAN_NATURE_GUARDIAN, SPELLVALUE_BASE_POINT0, bp, target, true, nullptr, aurEff);
@@ -1743,8 +1777,8 @@ class spell_sha_spirit_hunt : public SpellScriptLoader
return;
int32 amount = CalculatePct(static_cast<int32>(damageInfo->GetDamage()), aurEff->GetAmount());
- caster->CastCustomSpell(SPELL_SHAMAN_SPIRIT_HUNT_HEAL, SPELLVALUE_BASE_POINT0, amount, caster, true);
- caster->CastCustomSpell(SPELL_SHAMAN_SPIRIT_HUNT_HEAL, SPELLVALUE_BASE_POINT0, amount, target, true);
+ caster->CastCustomSpell(SPELL_SHAMAN_SPIRIT_HUNT_HEAL, SPELLVALUE_BASE_POINT0, amount, caster, true, nullptr, aurEff);
+ caster->CastCustomSpell(SPELL_SHAMAN_SPIRIT_HUNT_HEAL, SPELLVALUE_BASE_POINT0, amount, target, true, nullptr, aurEff);
}
void Register() override
@@ -1776,20 +1810,20 @@ class spell_sha_static_shock : public SpellScriptLoader
return true;
}
- void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
+ void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
Unit* caster = eventInfo.GetActor();
// Get Lightning Shield
- AuraEffect const* aurEff = caster->GetAuraEffect(SPELL_AURA_PROC_TRIGGER_SPELL, SPELLFAMILY_SHAMAN, 0x00000400, 0x00000000, 0x00000000, caster->GetGUID());
- if (!aurEff)
+ AuraEffect const* lightningShield = caster->GetAuraEffect(SPELL_AURA_PROC_TRIGGER_SPELL, SPELLFAMILY_SHAMAN, 0x00000400, 0x00000000, 0x00000000, caster->GetGUID());
+ if (!lightningShield)
return;
- uint32 spellId = sSpellMgr->GetSpellWithRank(SPELL_SHAMAN_LIGHTNING_SHIELD_DAMAGE_R1, aurEff->GetSpellInfo()->GetRank());
- eventInfo.GetActor()->CastSpell(eventInfo.GetProcTarget(), spellId, true);
- aurEff->GetBase()->DropCharge();
+ uint32 spellId = sSpellMgr->GetSpellWithRank(SPELL_SHAMAN_LIGHTNING_SHIELD_DAMAGE_R1, lightningShield->GetSpellInfo()->GetRank());
+ eventInfo.GetActor()->CastSpell(eventInfo.GetProcTarget(), spellId, true, nullptr, aurEff);
+ lightningShield->GetBase()->DropCharge();
}
void Register() override
@@ -1885,14 +1919,14 @@ public:
return true;
}
- void HandleDummy(AuraEffect const* /*aurEff*/)
+ void HandleDummy(AuraEffect const* aurEff)
{
Unit* target = GetTarget();
for (uint8 i = SUMMON_SLOT_TOTEM; i < MAX_TOTEM_SLOT; ++i)
if (!target->m_SummonSlot[i])
return;
- target->CastSpell(target, SPELL_SHAMAN_TOTEMIC_MASTERY, true);
+ target->CastSpell(target, SPELL_SHAMAN_TOTEMIC_MASTERY, true, nullptr, aurEff);
PreventDefaultAction();
}
@@ -1928,7 +1962,7 @@ class spell_sha_t3_6p_bonus : public SpellScriptLoader
return true;
}
- void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
+ void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
@@ -1959,7 +1993,7 @@ class spell_sha_t3_6p_bonus : public SpellScriptLoader
return;
}
- caster->CastSpell(target, spellId, true);
+ caster->CastSpell(target, spellId, true, nullptr, aurEff);
}
void Register() override
@@ -2003,12 +2037,12 @@ class spell_sha_t8_elemental_4p_bonus : public SpellScriptLoader
int32 amount = CalculatePct(static_cast<int32>(damageInfo->GetDamage()), aurEff->GetAmount());
amount /= spellInfo->GetMaxTicks();
- // Add remaining ticks to healing done
+ // Add remaining ticks to damage done
Unit* caster = eventInfo.GetActor();
Unit* target = eventInfo.GetProcTarget();
amount += target->GetRemainingPeriodicAmount(caster->GetGUID(), SPELL_SHAMAN_ELECTRIFIED, SPELL_AURA_PERIODIC_DAMAGE);
- caster->CastCustomSpell(SPELL_SHAMAN_ELECTRIFIED, SPELLVALUE_BASE_POINT0, amount, target, true);
+ caster->CastCustomSpell(SPELL_SHAMAN_ELECTRIFIED, SPELLVALUE_BASE_POINT0, amount, target, true, nullptr, aurEff);
}
void Register() override
@@ -2052,12 +2086,12 @@ class spell_sha_t9_elemental_4p_bonus : public SpellScriptLoader
int32 amount = CalculatePct(static_cast<int32>(damageInfo->GetDamage()), aurEff->GetAmount());
amount /= spellInfo->GetMaxTicks();
- // Add remaining ticks to healing done
+ // Add remaining ticks to damage done
Unit* caster = eventInfo.GetActor();
Unit* target = eventInfo.GetProcTarget();
amount += target->GetRemainingPeriodicAmount(caster->GetGUID(), SPELL_SHAMAN_LAVA_BURST_BONUS_DAMAGE, SPELL_AURA_PERIODIC_DAMAGE);
- caster->CastCustomSpell(SPELL_SHAMAN_LAVA_BURST_BONUS_DAMAGE, SPELLVALUE_BASE_POINT0, amount, target, true);
+ caster->CastCustomSpell(SPELL_SHAMAN_LAVA_BURST_BONUS_DAMAGE, SPELLVALUE_BASE_POINT0, amount, target, true, nullptr, aurEff);
}
void Register() override
@@ -2151,7 +2185,7 @@ class spell_sha_t10_restoration_4p_bonus : public SpellScriptLoader
Unit* target = eventInfo.GetProcTarget();
amount += target->GetRemainingPeriodicAmount(caster->GetGUID(), SPELL_SHAMAN_CHAINED_HEAL, SPELL_AURA_PERIODIC_HEAL);
- caster->CastCustomSpell(SPELL_SHAMAN_CHAINED_HEAL, SPELLVALUE_BASE_POINT0, amount, target, true);
+ caster->CastCustomSpell(SPELL_SHAMAN_CHAINED_HEAL, SPELLVALUE_BASE_POINT0, amount, target, true, nullptr, aurEff);
}
void Register() override
@@ -2187,7 +2221,6 @@ class spell_sha_windfury_weapon : public SpellScriptLoader
bool CheckProc(ProcEventInfo& eventInfo)
{
-
Player* player = eventInfo.GetActor()->ToPlayer();
if (!player)
return false;
@@ -2207,7 +2240,7 @@ class spell_sha_windfury_weapon : public SpellScriptLoader
return true;
}
- void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
+ void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
@@ -2247,7 +2280,7 @@ class spell_sha_windfury_weapon : public SpellScriptLoader
// Attack twice
for (uint8 i = 0; i < 2; ++i)
- player->CastCustomSpell(spellId, SPELLVALUE_BASE_POINT0, amount, eventInfo.GetProcTarget(), true, item);
+ player->CastCustomSpell(spellId, SPELLVALUE_BASE_POINT0, amount, eventInfo.GetProcTarget(), true, item, aurEff);
}
void Register() override
@@ -2275,6 +2308,7 @@ void AddSC_shaman_spell_scripts()
new spell_sha_earth_shield();
new spell_sha_earthbind_totem();
new spell_sha_earthen_power();
+ new spell_sha_earthliving_weapon();
new spell_sha_fire_nova();
new spell_sha_flame_shock();
new spell_sha_flametongue_weapon();
diff --git a/src/server/scripts/Spells/spell_warlock.cpp b/src/server/scripts/Spells/spell_warlock.cpp
index 0c1d6647f34..1a8252ad7ec 100644
--- a/src/server/scripts/Spells/spell_warlock.cpp
+++ b/src/server/scripts/Spells/spell_warlock.cpp
@@ -74,6 +74,7 @@ enum WarlockSpells
SPELL_WARLOCK_SHADOWFLAME = 37378,
SPELL_WARLOCK_FLAMESHADOW = 37379,
SPELL_WARLOCK_GLYPH_OF_SUCCUBUS = 56250,
+ SPELL_WARLOCK_IMPROVED_DRAIN_SOUL_R1 = 18213,
SPELL_WARLOCK_IMPROVED_DRAIN_SOUL_PROC = 18371
};
@@ -449,6 +450,50 @@ class spell_warl_demonic_empowerment : public SpellScriptLoader
}
};
+// -1120 - Drain Soul
+class spell_warl_drain_soul : public SpellScriptLoader
+{
+ public:
+ spell_warl_drain_soul() : SpellScriptLoader("spell_warl_drain_soul") { }
+
+ class spell_warl_drain_soul_AuraScript : public AuraScript
+ {
+ PrepareAuraScript(spell_warl_drain_soul_AuraScript);
+
+ bool Validate(SpellInfo const* /*spellInfo*/) override
+ {
+ if (!sSpellMgr->GetSpellInfo(SPELL_WARLOCK_IMPROVED_DRAIN_SOUL_R1) ||
+ !sSpellMgr->GetSpellInfo(SPELL_WARLOCK_IMPROVED_DRAIN_SOUL_PROC))
+ return false;
+ return true;
+ }
+
+ void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
+ {
+ PreventDefaultAction();
+
+ Unit* caster = eventInfo.GetActor();
+ // Improved Drain Soul
+ Aura const* impDrainSoul = caster->GetAuraOfRankedSpell(SPELL_WARLOCK_IMPROVED_DRAIN_SOUL_R1, caster->GetGUID());
+ if (!impDrainSoul)
+ return;
+
+ int32 amount = CalculatePct(caster->GetMaxPower(POWER_MANA), impDrainSoul->GetSpellInfo()->Effects[EFFECT_2].CalcValue());
+ caster->CastCustomSpell(SPELL_WARLOCK_IMPROVED_DRAIN_SOUL_PROC, SPELLVALUE_BASE_POINT0, amount, (Unit*)nullptr, true, nullptr, aurEff);
+ }
+
+ void Register() override
+ {
+ OnEffectProc += AuraEffectProcFn(spell_warl_drain_soul_AuraScript::HandleProc, EFFECT_2, SPELL_AURA_PROC_TRIGGER_SPELL);
+ }
+ };
+
+ AuraScript* GetAuraScript() const override
+ {
+ return new spell_warl_drain_soul_AuraScript();
+ }
+};
+
// 47422 - Everlasting Affliction
class spell_warl_everlasting_affliction : public SpellScriptLoader
{
@@ -505,15 +550,19 @@ class spell_warl_fel_synergy : public SpellScriptLoader
bool CheckProc(ProcEventInfo& eventInfo)
{
- return GetTarget()->GetGuardianPet() && eventInfo.GetDamageInfo()->GetDamage();
+ DamageInfo* damageInfo = eventInfo.GetDamageInfo();
+ if (!damageInfo || !damageInfo->GetDamage())
+ return false;
+
+ return GetTarget()->GetGuardianPet() != nullptr;
}
void OnProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
- int32 heal = CalculatePct(int32(eventInfo.GetDamageInfo()->GetDamage()), aurEff->GetAmount());
- GetTarget()->CastCustomSpell(SPELL_WARLOCK_FEL_SYNERGY_HEAL, SPELLVALUE_BASE_POINT0, heal, (Unit*)NULL, true, NULL, aurEff); // TARGET_UNIT_PET
+ int32 heal = CalculatePct(static_cast<int32>(eventInfo.GetDamageInfo()->GetDamage()), aurEff->GetAmount());
+ GetTarget()->CastCustomSpell(SPELL_WARLOCK_FEL_SYNERGY_HEAL, SPELLVALUE_BASE_POINT0, heal, (Unit*)nullptr, true, nullptr, aurEff); // TARGET_UNIT_PET
}
void Register() override
@@ -547,11 +596,11 @@ class spell_warl_glyph_of_corruption_nightfall : public SpellScriptLoader
return true;
}
- void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
+ void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
Unit* caster = eventInfo.GetActor();
- caster->CastSpell(caster, SPELL_WARLOCK_SHADOW_TRANCE, true);
+ caster->CastSpell(caster, SPELL_WARLOCK_SHADOW_TRANCE, true, nullptr, aurEff);
}
void Register() override
@@ -583,11 +632,11 @@ public:
return true;
}
- void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
+ void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
Unit* caster = eventInfo.GetActor();
- caster->CastSpell(caster, SPELL_WARLOCK_GLYPH_OF_LIFE_TAP_TRIGGERED, true);
+ caster->CastSpell(caster, SPELL_WARLOCK_GLYPH_OF_LIFE_TAP_TRIGGERED, true, nullptr, aurEff);
}
void Register() override
@@ -740,44 +789,6 @@ class spell_warl_health_funnel : public SpellScriptLoader
}
};
-// -18213 - Improved Drain Soul
-class spell_warl_improved_drain_soul : public SpellScriptLoader
-{
- public:
- spell_warl_improved_drain_soul() : SpellScriptLoader("spell_warl_improved_drain_soul") { }
-
- class spell_warl_improved_drain_soul_AuraScript : public AuraScript
- {
- PrepareAuraScript(spell_warl_improved_drain_soul_AuraScript);
-
- bool Validate(SpellInfo const* /*spellInfo*/) override
- {
- if (!sSpellMgr->GetSpellInfo(SPELL_WARLOCK_IMPROVED_DRAIN_SOUL_PROC))
- return false;
- return true;
- }
-
- void HandleProc(AuraEffect const* aurEff, ProcEventInfo& /*eventInfo*/)
- {
- PreventDefaultAction();
-
- Unit* target = GetTarget();
- int32 bp0 = CalculatePct(target->GetMaxPower(POWER_MANA), GetSpellInfo()->Effects[EFFECT_2].BasePoints);
- target->CastCustomSpell(SPELL_WARLOCK_IMPROVED_DRAIN_SOUL_PROC, SPELLVALUE_BASE_POINT0, bp0, target, true, nullptr, aurEff);
- }
-
- void Register() override
- {
- OnEffectProc += AuraEffectProcFn(spell_warl_improved_drain_soul_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_DUMMY);
- }
- };
-
- AuraScript* GetAuraScript() const override
- {
- return new spell_warl_improved_drain_soul_AuraScript();
- }
-};
-
// -1454 - Life Tap
class spell_warl_life_tap : public SpellScriptLoader
{
@@ -874,9 +885,9 @@ public:
bool CheckProc(ProcEventInfo& eventInfo)
{
- if (eventInfo.GetDamageInfo())
+ if (DamageInfo* damageInfo = eventInfo.GetDamageInfo())
{
- switch (GetFirstSchoolInMask(eventInfo.GetDamageInfo()->GetSchoolMask()))
+ switch (GetFirstSchoolInMask(damageInfo->GetSchoolMask()))
{
case SPELL_SCHOOL_HOLY:
case SPELL_SCHOOL_FIRE:
@@ -1106,7 +1117,7 @@ class spell_warl_seed_of_corruption_dummy : public SpellScriptLoader
{
PreventDefaultAction();
DamageInfo* damageInfo = eventInfo.GetDamageInfo();
- if (!damageInfo)
+ if (!damageInfo || !damageInfo->GetDamage())
return;
int32 amount = aurEff->GetAmount() - damageInfo->GetDamage();
@@ -1124,7 +1135,7 @@ class spell_warl_seed_of_corruption_dummy : public SpellScriptLoader
return;
uint32 spellId = sSpellMgr->GetSpellWithRank(SPELL_WARLOCK_SEED_OF_CORRUPTION_DAMAGE_R1, GetSpellInfo()->GetRank());
- caster->CastSpell(eventInfo.GetActionTarget(), spellId, true);
+ caster->CastSpell(eventInfo.GetActionTarget(), spellId, true, nullptr, aurEff);
}
void Register() override
@@ -1166,7 +1177,7 @@ class spell_warl_seed_of_corruption_generic : public SpellScriptLoader
{
PreventDefaultAction();
DamageInfo* damageInfo = eventInfo.GetDamageInfo();
- if (!damageInfo)
+ if (!damageInfo || !damageInfo->GetDamage())
return;
int32 amount = aurEff->GetAmount() - damageInfo->GetDamage();
@@ -1182,7 +1193,7 @@ class spell_warl_seed_of_corruption_generic : public SpellScriptLoader
if (!caster)
return;
- caster->CastSpell(eventInfo.GetActionTarget(), SPELL_WARLOCK_SEED_OF_CORRUPTION_GENERIC, true);
+ caster->CastSpell(eventInfo.GetActionTarget(), SPELL_WARLOCK_SEED_OF_CORRUPTION_GENERIC, true, nullptr, aurEff);
}
void Register() override
@@ -1255,19 +1266,23 @@ class spell_warl_siphon_life : public SpellScriptLoader
bool CheckProc(ProcEventInfo& eventInfo)
{
- return eventInfo.GetDamageInfo()->GetDamage() && GetTarget()->IsAlive();
+ DamageInfo* damageInfo = eventInfo.GetDamageInfo();
+ if (!damageInfo || !damageInfo->GetDamage())
+ return false;
+
+ return GetTarget()->IsAlive();
}
void OnProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
- int32 amount = int32(CalculatePct(eventInfo.GetDamageInfo()->GetDamage(), aurEff->GetAmount()));
+ int32 amount = CalculatePct(static_cast<int32>(eventInfo.GetDamageInfo()->GetDamage()), aurEff->GetAmount());
// Glyph of Siphon Life
if (AuraEffect const* glyph = GetTarget()->GetAuraEffect(SPELL_WARLOCK_GLYPH_OF_SIPHON_LIFE, EFFECT_0))
AddPct(amount, glyph->GetAmount());
- GetTarget()->CastCustomSpell(SPELL_WARLOCK_SIPHON_LIFE_HEAL, SPELLVALUE_BASE_POINT0, amount, GetTarget(), true, NULL, aurEff);
+ GetTarget()->CastCustomSpell(SPELL_WARLOCK_SIPHON_LIFE_HEAL, SPELLVALUE_BASE_POINT0, amount, GetTarget(), true, nullptr, aurEff);
}
void Register() override
@@ -1329,11 +1344,11 @@ class spell_warl_soul_leech : public SpellScriptLoader
uint32 selfSpellId = casterMana[impSoulLeechRank - 1];
uint32 petSpellId = petMana[impSoulLeechRank - 1];
- caster->CastSpell((Unit*)nullptr, selfSpellId, true);
- caster->CastSpell((Unit*)nullptr, petSpellId, true);
+ caster->CastSpell((Unit*)nullptr, selfSpellId, true, nullptr, aurEff);
+ caster->CastSpell((Unit*)nullptr, petSpellId, true, nullptr, aurEff);
if (roll_chance_i(impSoulLeech->GetAmount()))
- caster->CastSpell((Unit*)nullptr, SPELL_REPLENISHMENT, true);
+ caster->CastSpell((Unit*)nullptr, SPELL_REPLENISHMENT, true, nullptr, aurEff);
}
void Register() override
@@ -1407,11 +1422,11 @@ class spell_warl_t4_2p_bonus : public SpellScriptLoader
return true;
}
- void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
+ void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
Unit* caster = eventInfo.GetActor();
- caster->CastSpell(caster, Trigger, true);
+ caster->CastSpell(caster, Trigger, true, nullptr, aurEff);
}
void Register() override
@@ -1476,6 +1491,7 @@ void AddSC_warlock_spell_scripts()
new spell_warl_demonic_circle_teleport();
new spell_warl_demonic_empowerment();
new spell_warl_demonic_pact();
+ new spell_warl_drain_soul();
new spell_warl_everlasting_affliction();
new spell_warl_fel_synergy();
new spell_warl_glyph_of_life_tap();
@@ -1483,7 +1499,6 @@ void AddSC_warlock_spell_scripts()
new spell_warl_haunt();
new spell_warl_health_funnel();
new spell_warl_glyph_of_corruption_nightfall();
- new spell_warl_improved_drain_soul();
new spell_warl_life_tap();
new spell_warl_nether_protection();
new spell_warl_ritual_of_doom_effect();
diff --git a/src/server/scripts/Spells/spell_warrior.cpp b/src/server/scripts/Spells/spell_warrior.cpp
index 2b6b6facc33..81fb4ec2457 100644
--- a/src/server/scripts/Spells/spell_warrior.cpp
+++ b/src/server/scripts/Spells/spell_warrior.cpp
@@ -326,7 +326,11 @@ class spell_warr_deep_wounds_aura : public SpellScriptLoader
bool CheckProc(ProcEventInfo& eventInfo)
{
- return eventInfo.GetActor()->GetTypeId() == TYPEID_PLAYER && eventInfo.GetDamageInfo();
+ DamageInfo* damageInfo = eventInfo.GetDamageInfo();
+ if (!damageInfo)
+ return false;
+
+ return eventInfo.GetActor()->GetTypeId() == TYPEID_PLAYER;
}
void OnProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
@@ -482,11 +486,11 @@ class spell_warr_glyph_of_blocking : public SpellScriptLoader
return true;
}
- void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
+ void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
Unit* caster = eventInfo.GetActor();
- caster->CastSpell(caster, SPELL_WARRIOR_GLYPH_OF_BLOCKING, true);
+ caster->CastSpell(caster, SPELL_WARRIOR_GLYPH_OF_BLOCKING, true, nullptr, aurEff);
}
void Register() override
@@ -558,7 +562,7 @@ class spell_warr_improved_spell_reflection : public SpellScriptLoader
{
PreventDefaultAction();
Unit* caster = eventInfo.GetActor();
- caster->CastCustomSpell(SPELL_WARRIOR_IMPROVED_SPELL_REFLECTION_TRIGGER, SPELLVALUE_MAX_TARGETS, aurEff->GetAmount(), caster, true);
+ caster->CastCustomSpell(SPELL_WARRIOR_IMPROVED_SPELL_REFLECTION_TRIGGER, SPELLVALUE_MAX_TARGETS, aurEff->GetAmount(), caster, true, nullptr, aurEff);
}
void Register() override
@@ -828,14 +832,14 @@ class spell_warr_second_wind : public SpellScriptLoader
return (spellInfo->GetAllEffectsMechanicMask() & ((1 << MECHANIC_ROOT) | (1 << MECHANIC_STUN))) != 0;
}
- void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
+ void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
static uint32 const triggeredSpells[2] = { SPELL_WARRIOR_SECOND_WIND_TRIGGER_1, SPELL_WARRIOR_SECOND_WIND_TRIGGER_2 };
PreventDefaultAction();
Unit* caster = eventInfo.GetActionTarget();
uint32 spellId = triggeredSpells[GetSpellInfo()->GetRank() - 1];
- caster->CastSpell(caster, spellId, true);
+ caster->CastSpell(caster, spellId, true, nullptr, aurEff);
}
void Register() override
@@ -950,18 +954,18 @@ class spell_warr_sweeping_strikes : public SpellScriptLoader
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
- if (eventInfo.GetDamageInfo())
+ if (DamageInfo* damageInfo = eventInfo.GetDamageInfo())
{
- SpellInfo const* spellInfo = eventInfo.GetDamageInfo()->GetSpellInfo();
+ SpellInfo const* spellInfo = damageInfo->GetSpellInfo();
if (spellInfo && (spellInfo->Id == SPELL_WARRIOR_BLADESTORM_PERIODIC_WHIRLWIND || (spellInfo->Id == SPELL_WARRIOR_EXECUTE && !_procTarget->HasAuraState(AURA_STATE_HEALTHLESS_20_PERCENT))))
{
// If triggered by Execute (while target is not under 20% hp) or Bladestorm deals normalized weapon damage
- GetTarget()->CastSpell(_procTarget, SPELL_WARRIOR_SWEEPING_STRIKES_EXTRA_ATTACK_2, true, NULL, aurEff);
+ GetTarget()->CastSpell(_procTarget, SPELL_WARRIOR_SWEEPING_STRIKES_EXTRA_ATTACK_2, true, nullptr, aurEff);
}
else
{
- int32 damage = eventInfo.GetDamageInfo()->GetDamage();
- GetTarget()->CastCustomSpell(SPELL_WARRIOR_SWEEPING_STRIKES_EXTRA_ATTACK_1, SPELLVALUE_BASE_POINT0, damage, _procTarget, true, NULL, aurEff);
+ int32 damage = damageInfo->GetDamage();
+ GetTarget()->CastCustomSpell(SPELL_WARRIOR_SWEEPING_STRIKES_EXTRA_ATTACK_1, SPELLVALUE_BASE_POINT0, damage, _procTarget, true, nullptr, aurEff);
}
}
}
@@ -1049,6 +1053,34 @@ class spell_warr_t3_prot_8p_bonus : public SpellScriptLoader
}
};
+// 32216 - Victorious
+class spell_warr_victorious : public SpellScriptLoader
+{
+ public:
+ spell_warr_victorious() : SpellScriptLoader("spell_warr_victorious") { }
+
+ class spell_warr_victorious_AuraScript : public AuraScript
+ {
+ PrepareAuraScript(spell_warr_victorious_AuraScript);
+
+ void HandleDummy(AuraEffect const* /*aurEff*/, ProcEventInfo& /*eventInfo*/)
+ {
+ // Prevent console log
+ PreventDefaultAction();
+ }
+
+ void Register() override
+ {
+ OnEffectProc += AuraEffectProcFn(spell_warr_victorious_AuraScript::HandleDummy, EFFECT_0, SPELL_AURA_DUMMY);
+ }
+ };
+
+ AuraScript* GetAuraScript() const override
+ {
+ return new spell_warr_victorious_AuraScript();
+ }
+};
+
// 50720 - Vigilance
class spell_warr_vigilance : public SpellScriptLoader
{
@@ -1201,6 +1233,7 @@ void AddSC_warrior_spell_scripts()
new spell_warr_sweeping_strikes();
new spell_warr_sword_and_board();
new spell_warr_t3_prot_8p_bonus();
+ new spell_warr_victorious();
new spell_warr_vigilance();
new spell_warr_vigilance_trigger();
}
diff --git a/src/server/scripts/World/go_scripts.cpp b/src/server/scripts/World/go_scripts.cpp
index 75e5e63c2c0..91166294355 100644
--- a/src/server/scripts/World/go_scripts.cpp
+++ b/src/server/scripts/World/go_scripts.cpp
@@ -1316,6 +1316,9 @@ public:
struct go_brewfest_musicAI : public GameObjectAI
{
+ uint32 rnd = 0;
+ uint32 musicTime = 1000;
+
go_brewfest_musicAI(GameObject* go) : GameObjectAI(go)
{
_events.ScheduleEvent(EVENT_BM_SELECT_MUSIC, 1000);
@@ -1325,8 +1328,6 @@ public:
void UpdateAI(uint32 diff) override
{
_events.Update(diff);
- uint32 rnd;
- uint32 musicTime = 1000;
while (uint32 eventId = _events.ExecuteEvent())
{
switch (eventId)
@@ -1394,6 +1395,180 @@ public:
}
};
+/*####
+## go_midsummer_music
+####*/
+
+enum MidsummerMusic
+{
+ EVENTMIDSUMMERFIREFESTIVAL_A = 12319, // 1.08 min
+ EVENTMIDSUMMERFIREFESTIVAL_H = 12325, // 1.12 min
+};
+
+enum MidsummerMusicEvents
+{
+ EVENT_MM_START_MUSIC = 1
+};
+
+class go_midsummer_music : public GameObjectScript
+{
+public:
+ go_midsummer_music() : GameObjectScript("go_midsummer_music") { }
+
+ struct go_midsummer_musicAI : public GameObjectAI
+ {
+ go_midsummer_musicAI(GameObject* go) : GameObjectAI(go)
+ {
+ _events.ScheduleEvent(EVENT_MM_START_MUSIC, 1000);
+ }
+
+ void UpdateAI(uint32 diff) override
+ {
+ _events.Update(diff);
+ while (uint32 eventId = _events.ExecuteEvent())
+ {
+ switch (eventId)
+ {
+ case EVENT_MM_START_MUSIC:
+ {
+ if (!IsHolidayActive(HOLIDAY_FIRE_FESTIVAL))
+ break;
+
+ std::vector<Player*> playersNearby;
+ go->GetPlayerListInGrid(playersNearby, go->GetMap()->GetVisibilityRange());
+ for (Player* player : playersNearby)
+ {
+ if (player->GetTeamId() == TEAM_HORDE)
+ go->PlayDirectMusic(EVENTMIDSUMMERFIREFESTIVAL_H, player);
+ else
+ go->PlayDirectMusic(EVENTMIDSUMMERFIREFESTIVAL_A, player);
+ }
+ _events.ScheduleEvent(EVENT_MM_START_MUSIC, 5000); // Every 5 second's SMSG_PLAY_MUSIC packet (PlayDirectMusic) is pushed to the client (sniffed value)
+ break;
+ }
+ default:
+ break;
+ }
+ }
+ }
+ private:
+ EventMap _events;
+ };
+
+ GameObjectAI* GetAI(GameObject* go) const override
+ {
+ return new go_midsummer_musicAI(go);
+ }
+};
+
+/*####
+## go_darkmoon_faire_music
+####*/
+
+enum DarkmoonFaireMusic
+{
+ MUSIC_DARKMOON_FAIRE_MUSIC = 8440
+};
+
+enum DarkmoonFaireMusicEvents
+{
+ EVENT_DFM_START_MUSIC = 1
+};
+
+class go_darkmoon_faire_music : public GameObjectScript
+{
+public:
+ go_darkmoon_faire_music() : GameObjectScript("go_darkmoon_faire_music") { }
+
+ struct go_darkmoon_faire_musicAI : public GameObjectAI
+ {
+ go_darkmoon_faire_musicAI(GameObject* go) : GameObjectAI(go)
+ {
+ _events.ScheduleEvent(EVENT_DFM_START_MUSIC, 1000);
+ }
+
+ void UpdateAI(uint32 diff) override
+ {
+ _events.Update(diff);
+ while (uint32 eventId = _events.ExecuteEvent())
+ {
+ switch (eventId)
+ {
+ case EVENT_DFM_START_MUSIC:
+ if (!IsHolidayActive(HOLIDAY_DARKMOON_FAIRE_ELWYNN) || !IsHolidayActive(HOLIDAY_DARKMOON_FAIRE_THUNDER) || !IsHolidayActive(HOLIDAY_DARKMOON_FAIRE_SHATTRATH))
+ break;
+ go->PlayDirectMusic(MUSIC_DARKMOON_FAIRE_MUSIC);
+ _events.ScheduleEvent(EVENT_DFM_START_MUSIC, 5000); // Every 5 second's SMSG_PLAY_MUSIC packet (PlayDirectMusic) is pushed to the client (sniffed value)
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ private:
+ EventMap _events;
+ };
+
+ GameObjectAI* GetAI(GameObject* go) const override
+ {
+ return new go_darkmoon_faire_musicAI(go);
+ }
+};
+
+/*####
+## go_pirate_day_music
+####*/
+
+enum PirateDayMusic
+{
+ MUSIC_PIRATE_DAY_MUSIC = 12845
+};
+
+enum PirateDayMusicEvents
+{
+ EVENT_PDM_START_MUSIC = 1
+};
+
+class go_pirate_day_music : public GameObjectScript
+{
+public:
+ go_pirate_day_music() : GameObjectScript("go_pirate_day_music") { }
+
+ struct go_pirate_day_musicAI : public GameObjectAI
+ {
+ go_pirate_day_musicAI(GameObject* go) : GameObjectAI(go)
+ {
+ _events.ScheduleEvent(EVENT_PDM_START_MUSIC, 1000);
+ }
+
+ void UpdateAI(uint32 diff) override
+ {
+ _events.Update(diff);
+ while (uint32 eventId = _events.ExecuteEvent())
+ {
+ switch (eventId)
+ {
+ case EVENT_PDM_START_MUSIC:
+ if (!IsHolidayActive(HOLIDAY_PIRATES_DAY))
+ break;
+ go->PlayDirectMusic(MUSIC_PIRATE_DAY_MUSIC);
+ _events.ScheduleEvent(EVENT_PDM_START_MUSIC, 5000); // Every 5 second's SMSG_PLAY_MUSIC packet (PlayDirectMusic) is pushed to the client (sniffed value)
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ private:
+ EventMap _events;
+ };
+
+ GameObjectAI* GetAI(GameObject* go) const override
+ {
+ return new go_pirate_day_musicAI(go);
+ }
+};
+
void AddSC_go_scripts()
{
new go_cat_figurine();
@@ -1432,4 +1607,7 @@ void AddSC_go_scripts()
new go_midsummer_ribbon_pole();
new go_toy_train_set();
new go_brewfest_music();
+ new go_midsummer_music();
+ new go_darkmoon_faire_music();
+ new go_pirate_day_music();
}
diff --git a/src/server/shared/Dynamic/LinkedList.h b/src/server/shared/Dynamic/LinkedList.h
index 94f67cac909..1c99144db0e 100644
--- a/src/server/shared/Dynamic/LinkedList.h
+++ b/src/server/shared/Dynamic/LinkedList.h
@@ -32,18 +32,18 @@ class LinkedListElement
LinkedListElement* iNext;
LinkedListElement* iPrev;
+
public:
- LinkedListElement() : iNext(NULL), iPrev(NULL) { }
- virtual ~LinkedListElement() { delink(); }
+ LinkedListElement() : iNext(nullptr), iPrev(nullptr) { }
- bool hasNext() const { return(iNext && iNext->iNext != NULL); }
- bool hasPrev() const { return(iPrev && iPrev->iPrev != NULL); }
- bool isInList() const { return(iNext != NULL && iPrev != NULL); }
+ bool hasNext() const { return (iNext && iNext->iNext != nullptr); }
+ bool hasPrev() const { return (iPrev && iPrev->iPrev != nullptr); }
+ bool isInList() const { return (iNext != nullptr && iPrev != nullptr); }
- LinkedListElement * next() { return hasNext() ? iNext : NULL; }
- LinkedListElement const* next() const { return hasNext() ? iNext : NULL; }
- LinkedListElement * prev() { return hasPrev() ? iPrev : NULL; }
- LinkedListElement const* prev() const { return hasPrev() ? iPrev : NULL; }
+ LinkedListElement * next() { return hasNext() ? iNext : nullptr; }
+ LinkedListElement const* next() const { return hasNext() ? iNext : nullptr; }
+ LinkedListElement * prev() { return hasPrev() ? iPrev : nullptr; }
+ LinkedListElement const* prev() const { return hasPrev() ? iPrev : nullptr; }
LinkedListElement * nocheck_next() { return iNext; }
LinkedListElement const* nocheck_next() const { return iNext; }
@@ -52,10 +52,13 @@ class LinkedListElement
void delink()
{
- if (isInList())
- {
- iNext->iPrev = iPrev; iPrev->iNext = iNext; iNext = NULL; iPrev = NULL;
- }
+ if (!isInList())
+ return;
+
+ iNext->iPrev = iPrev;
+ iPrev->iNext = iNext;
+ iNext = nullptr;
+ iPrev = nullptr;
}
void insertBefore(LinkedListElement* pElem)
@@ -75,8 +78,14 @@ class LinkedListElement
}
private:
- LinkedListElement(LinkedListElement const&);
- LinkedListElement& operator=(LinkedListElement const&);
+ LinkedListElement(LinkedListElement const&) = delete;
+ LinkedListElement& operator=(LinkedListElement const&) = delete;
+
+ protected:
+ ~LinkedListElement()
+ {
+ delink();
+ }
};
//============================================
@@ -97,15 +106,13 @@ class LinkedListHead
iLast.iPrev = &iFirst;
}
- virtual ~LinkedListHead() { }
-
bool isEmpty() const { return(!iFirst.iNext->isInList()); }
- LinkedListElement * getFirst() { return(isEmpty() ? NULL : iFirst.iNext); }
- LinkedListElement const* getFirst() const { return(isEmpty() ? NULL : iFirst.iNext); }
+ LinkedListElement * getFirst() { return (isEmpty() ? nullptr : iFirst.iNext); }
+ LinkedListElement const* getFirst() const { return (isEmpty() ? nullptr : iFirst.iNext); }
- LinkedListElement * getLast() { return(isEmpty() ? NULL : iLast.iPrev); }
- LinkedListElement const* getLast() const { return(isEmpty() ? NULL : iLast.iPrev); }
+ LinkedListElement * getLast() { return(isEmpty() ? nullptr : iLast.iPrev); }
+ LinkedListElement const* getLast() const { return(isEmpty() ? nullptr : iLast.iPrev); }
void insertFirst(LinkedListElement* pElem)
{
@@ -248,8 +255,11 @@ class LinkedListHead
typedef Iterator<LinkedListElement> iterator;
private:
- LinkedListHead(LinkedListHead const&);
- LinkedListHead& operator=(LinkedListHead const&);
+ LinkedListHead(LinkedListHead const&) = delete;
+ LinkedListHead& operator=(LinkedListHead const&) = delete;
+
+ protected:
+ ~LinkedListHead() { }
};
//============================================
diff --git a/src/server/shared/Dynamic/LinkedReference/RefManager.h b/src/server/shared/Dynamic/LinkedReference/RefManager.h
index 9dbab4f338e..3c716e3c6b7 100644
--- a/src/server/shared/Dynamic/LinkedReference/RefManager.h
+++ b/src/server/shared/Dynamic/LinkedReference/RefManager.h
@@ -23,31 +23,29 @@
#include "Dynamic/LinkedList.h"
#include "Dynamic/LinkedReference/Reference.h"
-template <class TO, class FROM> class RefManager : public LinkedListHead
+template <class TO, class FROM>
+class RefManager : public LinkedListHead
{
public:
- typedef LinkedListHead::Iterator< Reference<TO, FROM> > iterator;
+ typedef LinkedListHead::Iterator<Reference<TO, FROM>> iterator;
RefManager() { }
- virtual ~RefManager() { clearReferences(); }
- Reference<TO, FROM>* getFirst() { return ((Reference<TO, FROM>*) LinkedListHead::getFirst()); }
- Reference<TO, FROM> const* getFirst() const { return ((Reference<TO, FROM> const*) LinkedListHead::getFirst()); }
- Reference<TO, FROM>* getLast() { return ((Reference<TO, FROM>*) LinkedListHead::getLast()); }
- Reference<TO, FROM> const* getLast() const { return ((Reference<TO, FROM> const*) LinkedListHead::getLast()); }
+ Reference<TO, FROM>* getFirst() { return static_cast<Reference<TO, FROM>*>(LinkedListHead::getFirst()); }
+
+ Reference<TO, FROM> const* getFirst() const { return static_cast<Reference<TO, FROM> const*>(LinkedListHead::getFirst()); }
iterator begin() { return iterator(getFirst()); }
- iterator end() { return iterator(NULL); }
- iterator rbegin() { return iterator(getLast()); }
- iterator rend() { return iterator(NULL); }
+ iterator end() { return iterator(nullptr); }
+
+ virtual ~RefManager()
+ {
+ clearReferences();
+ }
void clearReferences()
{
- LinkedListElement* ref;
- while ((ref = getFirst()) != NULL)
- {
- ((Reference<TO, FROM>*) ref)->invalidate();
- ref->delink(); // the delink might be already done by invalidate(), but doing it here again does not hurt and insures an empty list
- }
+ while (Reference<TO, FROM>* ref = getFirst())
+ ref->invalidate();
}
};
diff --git a/src/server/shared/Dynamic/LinkedReference/Reference.h b/src/server/shared/Dynamic/LinkedReference/Reference.h
index 4a473b0f2ac..0dcf91fb052 100644
--- a/src/server/shared/Dynamic/LinkedReference/Reference.h
+++ b/src/server/shared/Dynamic/LinkedReference/Reference.h
@@ -29,6 +29,7 @@ template <class TO, class FROM> class Reference : public LinkedListElement
private:
TO* iRefTo;
FROM* iRefFrom;
+
protected:
// Tell our refTo (target) object that we have a link
virtual void targetObjectBuildLink() = 0;
@@ -90,14 +91,14 @@ template <class TO, class FROM> class Reference : public LinkedListElement
Reference<TO, FROM> * nocheck_prev() { return((Reference<TO, FROM> *) LinkedListElement::nocheck_prev()); }
Reference<TO, FROM> const* nocheck_prev() const { return((Reference<TO, FROM> const*) LinkedListElement::nocheck_prev()); }
- TO* operator ->() const { return iRefTo; }
+ TO* operator->() const { return iRefTo; }
TO* getTarget() const { return iRefTo; }
FROM* GetSource() const { return iRefFrom; }
private:
- Reference(Reference const&);
- Reference& operator=(Reference const&);
+ Reference(Reference const&) = delete;
+ Reference& operator=(Reference const&) = delete;
};
//=====================================================
diff --git a/src/server/worldserver/worldserver.conf.dist b/src/server/worldserver/worldserver.conf.dist
index fab4cf54a9a..1d173057e6f 100644
--- a/src/server/worldserver/worldserver.conf.dist
+++ b/src/server/worldserver/worldserver.conf.dist
@@ -3070,6 +3070,15 @@ PreventRenameCharacterOnCustomization = 0
###################################################################################################
# AUCTION HOUSE BOT SETTINGS
#
+# AuctionHouseBot.Account
+# Description: Account ID for AHBot characters. If non-zero, all auctions and bids associated
+# with the AHBot will randomly be assigned one of this account's characters.
+# Default: 0
+#
+
+AuctionHouseBot.Account = 0
+
+#
# AuctionHouseBot.Update.Interval
# Description: Interval in seconds for AHBot to get updated
# Default: 20
diff --git a/src/tools/vmap4_extractor/mpq_libmpq.cpp b/src/tools/vmap4_extractor/mpq_libmpq.cpp
index 690600867d9..f106f96f5ec 100644
--- a/src/tools/vmap4_extractor/mpq_libmpq.cpp
+++ b/src/tools/vmap4_extractor/mpq_libmpq.cpp
@@ -19,6 +19,7 @@
#include "mpq_libmpq04.h"
#include <deque>
#include <cstdio>
+#include <algorithm>
ArchiveSet gOpenArchives;
@@ -52,6 +53,11 @@ MPQArchive::MPQArchive(const char* filename)
gOpenArchives.push_front(this);
}
+bool MPQArchive::isOpened() const
+{
+ return std::find(gOpenArchives.begin(), gOpenArchives.end(), this) != gOpenArchives.end();
+}
+
void MPQArchive::close()
{
//gOpenArchives.erase(erase(&mpq_a);
diff --git a/src/tools/vmap4_extractor/mpq_libmpq04.h b/src/tools/vmap4_extractor/mpq_libmpq04.h
index 97b77d4643b..f4a9d2aa596 100644
--- a/src/tools/vmap4_extractor/mpq_libmpq04.h
+++ b/src/tools/vmap4_extractor/mpq_libmpq04.h
@@ -34,7 +34,7 @@ public:
mpq_archive_s *mpq_a;
MPQArchive(const char* filename);
- ~MPQArchive() { close(); }
+ ~MPQArchive() { if (isOpened()) close(); }
void GetFileListTo(std::vector<std::string>& filelist) {
uint32_t filenum;
@@ -66,6 +66,7 @@ public:
private:
void close();
+ bool isOpened() const;
};
typedef std::deque<MPQArchive*> ArchiveSet;
@@ -95,13 +96,8 @@ public:
inline void flipcc(char *fcc)
{
- char t;
- t=fcc[0];
- fcc[0]=fcc[3];
- fcc[3]=t;
- t=fcc[1];
- fcc[1]=fcc[2];
- fcc[2]=t;
+ std::swap(fcc[0], fcc[3]);
+ std::swap(fcc[1], fcc[2]);
}
#endif