diff options
Diffstat (limited to 'src')
93 files changed, 501 insertions, 472 deletions
diff --git a/src/server/collision/Management/MMapManager.h b/src/server/collision/Management/MMapManager.h index f51f6ecd981..42292b76942 100644 --- a/src/server/collision/Management/MMapManager.h +++ b/src/server/collision/Management/MMapManager.h @@ -20,11 +20,12 @@ #define _MMAP_MANAGER_H #include "Define.h" -#include "DetourAlloc.h" #include "DetourNavMesh.h" #include "DetourNavMeshQuery.h" + #include <string> #include <unordered_map> +#include <vector> // move map related classes namespace MMAP diff --git a/src/server/collision/Management/VMapManager2.cpp b/src/server/collision/Management/VMapManager2.cpp index a1cdb5502a9..9594951196f 100644 --- a/src/server/collision/Management/VMapManager2.cpp +++ b/src/server/collision/Management/VMapManager2.cpp @@ -107,7 +107,7 @@ namespace VMAP } // load one tile (internal use only) - bool VMapManager2::_loadMap(unsigned int mapId, const std::string& basePath, uint32 tileX, uint32 tileY) + bool VMapManager2::_loadMap(uint32 mapId, const std::string& basePath, uint32 tileX, uint32 tileY) { InstanceTreeMap::iterator instanceTree = iInstanceMapTrees.find(mapId); if (instanceTree == iInstanceMapTrees.end()) diff --git a/src/server/collision/Models/GameObjectModel.cpp b/src/server/collision/Models/GameObjectModel.cpp index dd1502c45b0..dbdc0554e06 100644 --- a/src/server/collision/Models/GameObjectModel.cpp +++ b/src/server/collision/Models/GameObjectModel.cpp @@ -20,13 +20,9 @@ #include "VMapManager2.h" #include "VMapDefinitions.h" #include "WorldModel.h" - #include "GameObjectModel.h" #include "Log.h" -#include "GameObject.h" -#include "Object.h" -#include "DBCStores.h" -#include "World.h" +#include "Timer.h" using G3D::Vector3; using G3D::Ray; @@ -44,13 +40,13 @@ struct GameobjectModelData typedef std::unordered_map<uint32, GameobjectModelData> ModelList; ModelList model_list; -void LoadGameObjectModelList() +void LoadGameObjectModelList(std::string const& dataPath) { #ifndef NO_CORE_FUNCS uint32 oldMSTime = getMSTime(); #endif - FILE* model_list_file = fopen((sWorld->GetDataPath() + "vmaps/" + VMAP::GAMEOBJECT_MODELS).c_str(), "rb"); + FILE* model_list_file = fopen((dataPath + "vmaps/" + VMAP::GAMEOBJECT_MODELS).c_str(), "rb"); if (!model_list_file) { VMAP_ERROR_LOG("misc", "Unable to open '%s' file.", VMAP::GAMEOBJECT_MODELS); @@ -84,7 +80,7 @@ void LoadGameObjectModelList() model_list.insert ( - ModelList::value_type( displayId, GameobjectModelData(std::string(buff, name_length), AABox(v1, v2)) ) + ModelList::value_type(displayId, GameobjectModelData(std::string(buff, name_length), AABox(v1, v2))) ); } @@ -98,9 +94,9 @@ GameObjectModel::~GameObjectModel() ((VMAP::VMapManager2*)VMAP::VMapFactory::createOrGetVMapManager())->releaseModelInstance(name); } -bool GameObjectModel::initialize(const GameObject& go, const GameObjectDisplayInfoEntry& info) +bool GameObjectModel::initialize(std::unique_ptr<GameObjectModelOwnerBase> modelOwner, std::string const& dataPath) { - ModelList::const_iterator it = model_list.find(info.Displayid); + ModelList::const_iterator it = model_list.find(modelOwner->GetDisplayId()); if (it == model_list.end()) return false; @@ -112,21 +108,18 @@ bool GameObjectModel::initialize(const GameObject& go, const GameObjectDisplayIn return false; } - iModel = ((VMAP::VMapManager2*)VMAP::VMapFactory::createOrGetVMapManager())->acquireModelInstance(sWorld->GetDataPath() + "vmaps/", it->second.name); + iModel = ((VMAP::VMapManager2*)VMAP::VMapFactory::createOrGetVMapManager())->acquireModelInstance(dataPath + "vmaps/", it->second.name); if (!iModel) return false; name = it->second.name; - //flags = VMAP::MOD_M2; - //adtId = 0; - //ID = 0; - iPos = Vector3(go.GetPositionX(), go.GetPositionY(), go.GetPositionZ()); - phasemask = go.GetPhaseMask(); - iScale = go.GetObjectScale(); + iPos = modelOwner->GetPosition(); + phasemask = modelOwner->GetPhaseMask(); + iScale = modelOwner->GetScale(); iInvScale = 1.f / iScale; - G3D::Matrix3 iRotation = G3D::Matrix3::fromEulerAnglesZYX(go.GetOrientation(), 0, 0); + G3D::Matrix3 iRotation = G3D::Matrix3::fromEulerAnglesZYX(modelOwner->GetOrientation(), 0, 0); iInvRot = iRotation.inverse(); // transform bounding box: mdl_box = AABox(mdl_box.low() * iScale, mdl_box.high() * iScale); @@ -140,22 +133,18 @@ bool GameObjectModel::initialize(const GameObject& go, const GameObjectDisplayIn for (int i = 0; i < 8; ++i) { Vector3 pos(iBound.corner(i)); - go.SummonCreature(1, pos.x, pos.y, pos.z, 0, TEMPSUMMON_MANUAL_DESPAWN); + modelOwner->DebugVisualizeCorner(pos); } #endif - owner = &go; + owner = std::move(modelOwner); return true; } -GameObjectModel* GameObjectModel::Create(const GameObject& go) +GameObjectModel* GameObjectModel::Create(std::unique_ptr<GameObjectModelOwnerBase> modelOwner, std::string const& dataPath) { - const GameObjectDisplayInfoEntry* info = sGameObjectDisplayInfoStore.LookupEntry(go.GetDisplayId()); - if (!info) - return NULL; - GameObjectModel* mdl = new GameObjectModel(); - if (!mdl->initialize(go, *info)) + if (!mdl->initialize(std::move(modelOwner), dataPath)) { delete mdl; return NULL; @@ -166,7 +155,7 @@ GameObjectModel* GameObjectModel::Create(const GameObject& go) bool GameObjectModel::intersectRay(const G3D::Ray& ray, float& MaxDist, bool StopAtFirstHit, uint32 ph_mask) const { - if (!(phasemask & ph_mask) || !owner->isSpawned()) + if (!(phasemask & ph_mask) || !owner->IsSpawned()) return false; float time = ray.intersectionTime(iBound); @@ -203,7 +192,7 @@ bool GameObjectModel::UpdatePosition() return false; } - iPos = Vector3(owner->GetPositionX(), owner->GetPositionY(), owner->GetPositionZ()); + iPos = owner->GetPosition(); G3D::Matrix3 iRotation = G3D::Matrix3::fromEulerAnglesZYX(owner->GetOrientation(), 0, 0); iInvRot = iRotation.inverse(); @@ -219,7 +208,7 @@ bool GameObjectModel::UpdatePosition() for (int i = 0; i < 8; ++i) { Vector3 pos(iBound.corner(i)); - owner->SummonCreature(1, pos.x, pos.y, pos.z, 0, TEMPSUMMON_MANUAL_DESPAWN); + owner->DebugVisualizeCorner(pos); } #endif diff --git a/src/server/collision/Models/GameObjectModel.h b/src/server/collision/Models/GameObjectModel.h index 43d299d6d8f..17669189af5 100644 --- a/src/server/collision/Models/GameObjectModel.h +++ b/src/server/collision/Models/GameObjectModel.h @@ -25,6 +25,7 @@ #include <G3D/Ray.h> #include "Define.h" +#include <memory> namespace VMAP { @@ -34,21 +35,21 @@ namespace VMAP class GameObject; struct GameObjectDisplayInfoEntry; -class GameObjectModel /*, public Intersectable*/ +class GameObjectModelOwnerBase { - uint32 phasemask; - G3D::AABox iBound; - G3D::Matrix3 iInvRot; - G3D::Vector3 iPos; - //G3D::Vector3 iRot; - float iInvScale; - float iScale; - VMAP::WorldModel* iModel; - GameObject const* owner; - - GameObjectModel() : phasemask(0), iInvScale(0), iScale(0), iModel(NULL), owner(NULL) { } - bool initialize(const GameObject& go, const GameObjectDisplayInfoEntry& info); +public: + virtual bool IsSpawned() const { return false; } + virtual uint32 GetDisplayId() const { return 0; } + virtual uint32 GetPhaseMask() const { return 0; } + virtual G3D::Vector3 GetPosition() const { return G3D::Vector3::zero(); } + virtual float GetOrientation() const { return 0.0f; } + virtual float GetScale() const { return 1.0f; } + virtual void DebugVisualizeCorner(G3D::Vector3 const& /*corner*/) const { } +}; +class GameObjectModel /*, public Intersectable*/ +{ + GameObjectModel() : phasemask(0), iInvScale(0), iScale(0), iModel(NULL) { } public: std::string name; @@ -66,9 +67,21 @@ public: bool intersectRay(const G3D::Ray& Ray, float& MaxDist, bool StopAtFirstHit, uint32 ph_mask) const; - static GameObjectModel* Create(const GameObject& go); + static GameObjectModel* Create(std::unique_ptr<GameObjectModelOwnerBase> modelOwner, std::string const& dataPath); bool UpdatePosition(); + +private: + bool initialize(std::unique_ptr<GameObjectModelOwnerBase> modelOwner, std::string const& dataPath); + + uint32 phasemask; + G3D::AABox iBound; + G3D::Matrix3 iInvRot; + G3D::Vector3 iPos; + float iInvScale; + float iScale; + VMAP::WorldModel* iModel; + std::unique_ptr<GameObjectModelOwnerBase> owner; }; #endif // _GAMEOBJECT_MODEL_H diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index 9cae4bbf539..9fa2269fd8b 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -765,6 +765,15 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u player->GroupEventHappens(e.action.quest.quest, GetBaseObject()); break; } + case SMART_ACTION_COMBAT_STOP: + { + if (!me) + break; + + me->CombatStop(true); + TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_COMBAT_STOP: %s CombatStop", me->GetGUID().ToString().c_str()); + break; + } case SMART_ACTION_REMOVEAURASFROMSPELL: { ObjectList* targets = GetTargets(e, unit); @@ -3257,10 +3266,6 @@ void SmartScript::InitTimer(SmartScriptHolder& e) case SMART_EVENT_UPDATE_OOC: RecalcTimer(e, e.event.minMaxRepeat.min, e.event.minMaxRepeat.max); break; - case SMART_EVENT_IC_LOS: - case SMART_EVENT_OOC_LOS: - RecalcTimer(e, e.event.los.cooldownMin, e.event.los.cooldownMax); - break; case SMART_EVENT_DISTANCE_CREATURE: case SMART_EVENT_DISTANCE_GAMEOBJECT: RecalcTimer(e, e.event.distance.repeat, e.event.distance.repeat); diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp index 013acd2e314..6ccc581c54e 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp @@ -1135,6 +1135,7 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e) case SMART_ACTION_STORE_TARGET_LIST: case SMART_ACTION_EVADE: case SMART_ACTION_FLEE_FOR_ASSIST: + case SMART_ACTION_COMBAT_STOP: case SMART_ACTION_DIE: case SMART_ACTION_SET_IN_COMBAT_WITH_ZONE: case SMART_ACTION_SET_ACTIVE: diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.h b/src/server/game/AI/SmartScripts/SmartScriptMgr.h index 1f4891d6c24..8565c5d3497 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.h +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.h @@ -452,7 +452,7 @@ enum SMART_ACTION SMART_ACTION_EVADE = 24, // No Params SMART_ACTION_FLEE_FOR_ASSIST = 25, // With Emote SMART_ACTION_CALL_GROUPEVENTHAPPENS = 26, // QuestID - // none = 27, + SMART_ACTION_COMBAT_STOP = 27, // SMART_ACTION_REMOVEAURASFROMSPELL = 28, // Spellid (0 removes all auras), charges (0 removes aura) SMART_ACTION_FOLLOW = 29, // Distance (0 = default), Angle (0 = default), EndCreatureEntry, credit, creditType (0monsterkill, 1event) SMART_ACTION_RANDOM_PHASE = 30, // PhaseId1, PhaseId2, PhaseId3... diff --git a/src/server/game/AuctionHouseBot/AuctionHouseBot.cpp b/src/server/game/AuctionHouseBot/AuctionHouseBot.cpp index c0c753100bc..c905ccedf2d 100644 --- a/src/server/game/AuctionHouseBot/AuctionHouseBot.cpp +++ b/src/server/game/AuctionHouseBot/AuctionHouseBot.cpp @@ -97,6 +97,11 @@ void AuctionBotConfig::SetConfig(AuctionBotConfigBoolValues index, char const* f SetConfig(index, sConfigMgr->GetBoolDefault(fieldname, defvalue)); } +void AuctionBotConfig::SetConfig(AuctionBotConfigFloatValues index, char const* fieldname, float defvalue) +{ + SetConfig(index, sConfigMgr->GetFloatDefault(fieldname, defvalue)); +} + //Get AuctionHousebot configuration file void AuctionBotConfig::GetConfigFromFile() { @@ -111,6 +116,8 @@ void AuctionBotConfig::GetConfigFromFile() SetConfig(CONFIG_AHBOT_BUYER_HORDE_ENABLED, "AuctionHouseBot.Buyer.Horde.Enabled", false); SetConfig(CONFIG_AHBOT_BUYER_NEUTRAL_ENABLED, "AuctionHouseBot.Buyer.Neutral.Enabled", false); + SetConfig(CONFIG_AHBOT_BUYER_CHANCE_FACTOR, "AuctionHouseBot.Buyer.ChanceFactor", 2.0f); + SetConfig(CONFIG_AHBOT_ITEMS_VENDOR, "AuctionHouseBot.Items.Vendor", false); SetConfig(CONFIG_AHBOT_ITEMS_LOOT, "AuctionHouseBot.Items.Loot", true); SetConfig(CONFIG_AHBOT_ITEMS_MISC, "AuctionHouseBot.Items.Misc", false); diff --git a/src/server/game/AuctionHouseBot/AuctionHouseBot.h b/src/server/game/AuctionHouseBot/AuctionHouseBot.h index d7570c37d44..225d3b7ee25 100644 --- a/src/server/game/AuctionHouseBot/AuctionHouseBot.h +++ b/src/server/game/AuctionHouseBot/AuctionHouseBot.h @@ -174,6 +174,12 @@ enum AuctionBotConfigBoolValues CONFIG_UINT32_AHBOT_BOOL_COUNT }; +enum AuctionBotConfigFloatValues +{ + CONFIG_AHBOT_BUYER_CHANCE_FACTOR, + CONFIG_AHBOT_FLOAT_COUNT +}; + // All basic config data used by other AHBot classes for self-configure. class AuctionBotConfig { @@ -196,8 +202,10 @@ public: uint32 GetConfig(AuctionBotConfigUInt32Values index) const { return _configUint32Values[index]; } bool GetConfig(AuctionBotConfigBoolValues index) const { return _configBoolValues[index]; } + float GetConfig(AuctionBotConfigFloatValues index) const { return _configFloatValues[index]; } void SetConfig(AuctionBotConfigBoolValues index, bool value) { _configBoolValues[index] = value; } void SetConfig(AuctionBotConfigUInt32Values index, uint32 value) { _configUint32Values[index] = value; } + void SetConfig(AuctionBotConfigFloatValues index, float value) { _configFloatValues[index] = value; } uint32 GetConfigItemAmountRatio(AuctionHouseType houseType) const; bool GetConfigBuyerEnabled(AuctionHouseType houseType) const; @@ -217,6 +225,7 @@ private: uint32 _configUint32Values[CONFIG_UINT32_AHBOT_UINT32_COUNT]; bool _configBoolValues[CONFIG_UINT32_AHBOT_BOOL_COUNT]; + float _configFloatValues[CONFIG_AHBOT_FLOAT_COUNT]; void SetAHBotIncludes(const std::string& AHBotIncludes) { _AHBotIncludes = AHBotIncludes; } void SetAHBotExcludes(const std::string& AHBotExcludes) { _AHBotExcludes = AHBotExcludes; } @@ -225,6 +234,7 @@ private: void SetConfigMax(AuctionBotConfigUInt32Values index, char const* fieldname, uint32 defvalue, uint32 maxvalue); void SetConfigMinMax(AuctionBotConfigUInt32Values index, char const* fieldname, uint32 defvalue, uint32 minvalue, uint32 maxvalue); void SetConfig(AuctionBotConfigBoolValues index, char const* fieldname, bool defvalue); + void SetConfig(AuctionBotConfigFloatValues index, char const* fieldname, float defvalue); void GetConfigFromFile(); }; diff --git a/src/server/game/AuctionHouseBot/AuctionHouseBotBuyer.cpp b/src/server/game/AuctionHouseBot/AuctionHouseBotBuyer.cpp index 64463948574..4bf6aa950c6 100644 --- a/src/server/game/AuctionHouseBot/AuctionHouseBotBuyer.cpp +++ b/src/server/game/AuctionHouseBot/AuctionHouseBotBuyer.cpp @@ -157,18 +157,18 @@ bool AuctionBotBuyer::RollBuyChance(const BuyerItemInfo* ahInfo, const Item* ite if (!auction->buyout) return false; - uint32 itemBuyPrice = auction->buyout / item->GetCount(); - uint32 itemPrice = item->GetTemplate()->SellPrice ? item->GetTemplate()->SellPrice : GetVendorPrice(item->GetTemplate()->Quality); + float itemBuyPrice = float(auction->buyout / item->GetCount()); + float itemPrice = float(item->GetTemplate()->SellPrice ? item->GetTemplate()->SellPrice : GetVendorPrice(item->GetTemplate()->Quality)); // The AH cut needs to be added to the price, but we dont want a 100% chance to buy if the price is exactly AH default itemPrice *= 1.4f; // This value is between 0 and 100 and is used directly as the chance to buy or bid // Value equal or above 100 means 100% chance and value below 0 means 0% chance - float chance = 100 / sqrt(itemBuyPrice / float(itemPrice)); + float chance = std::min(100.f, std::pow(100.f, 1.f + (1.f - itemBuyPrice / itemPrice) / sAuctionBotConfig->GetConfig(CONFIG_AHBOT_BUYER_CHANCE_FACTOR))); // If a player has bidded on item, have fifth of normal chance if (auction->bidder) - chance = chance / 5; + chance = chance / 5.f; if (ahInfo) { @@ -178,31 +178,29 @@ bool AuctionBotBuyer::RollBuyChance(const BuyerItemInfo* ahInfo, const Item* ite // If there are more than 5 items on AH of this entry, try weigh in the average buyout price if (ahInfo->BuyItemCount > 5) - { - chance *= 1 / sqrt(itemBuyPrice / avgBuyPrice); - } + chance *= 1.f / std::sqrt(itemBuyPrice / avgBuyPrice); } // Add config weigh in for quality chance *= GetChanceMultiplier(item->GetTemplate()->Quality) / 100.0f; - float rand = frand(0, 100); + float rand = frand(0.f, 100.f); bool win = rand <= chance; - TC_LOG_DEBUG("ahbot", "AHBot: %s BUY! chance = %.2f, price = %u, buyprice = %u.", win ? "WIN" : "LOSE", chance, itemPrice, itemBuyPrice); + TC_LOG_DEBUG("ahbot", "AHBot: %s BUY! chance = %.2f, price = %u, buyprice = %u.", win ? "WIN" : "LOSE", chance, uint32(itemPrice), uint32(itemBuyPrice)); return win; } // ahInfo can be NULL bool AuctionBotBuyer::RollBidChance(const BuyerItemInfo* ahInfo, const Item* item, const AuctionEntry* auction, uint32 bidPrice) { - uint32 itemBidPrice = bidPrice / item->GetCount(); - uint32 itemPrice = item->GetTemplate()->SellPrice ? item->GetTemplate()->SellPrice : GetVendorPrice(item->GetTemplate()->Quality); + float itemBidPrice = float(bidPrice / item->GetCount()); + float itemPrice = float(item->GetTemplate()->SellPrice ? item->GetTemplate()->SellPrice : GetVendorPrice(item->GetTemplate()->Quality)); // The AH cut needs to be added to the price, but we dont want a 100% chance to buy if the price is exactly AH default itemPrice *= 1.4f; // This value is between 0 and 100 and is used directly as the chance to buy or bid // Value equal or above 100 means 100% chance and value below 0 means 0% chance - float chance = 100 / sqrt(itemBidPrice / float(itemPrice)); + float chance = std::min(100.f, std::pow(100.f, 1.f + (1.f - itemBidPrice / itemPrice) / sAuctionBotConfig->GetConfig(CONFIG_AHBOT_BUYER_CHANCE_FACTOR))); if (ahInfo) { @@ -212,21 +210,19 @@ bool AuctionBotBuyer::RollBidChance(const BuyerItemInfo* ahInfo, const Item* ite // If there are more than 5 items on AH of this entry, try weigh in the average bid price if (ahInfo->BidItemCount >= 5) - { - chance *= 1 / sqrt(itemBidPrice / avgBidPrice); - } + chance *= 1.f / std::sqrt(itemBidPrice / avgBidPrice); } // If a player has bidded on item, have fifth of normal chance if (auction->bidder) - chance = chance / 5; + chance = chance / 5.f; // Add config weigh in for quality chance *= GetChanceMultiplier(item->GetTemplate()->Quality) / 100.0f; - float rand = frand(0, 100); + float rand = frand(0.f, 100.f); bool win = rand <= chance; - TC_LOG_DEBUG("ahbot", "AHBot: %s BID! chance = %.2f, price = %u, bidprice = %u.", win ? "WIN" : "LOSE", chance, itemPrice, itemBidPrice); + TC_LOG_DEBUG("ahbot", "AHBot: %s BID! chance = %.2f, price = %u, bidprice = %u.", win ? "WIN" : "LOSE", chance, uint32(itemPrice), uint32(itemBidPrice)); return win; } diff --git a/src/server/game/Battlegrounds/ArenaTeamMgr.cpp b/src/server/game/Battlegrounds/ArenaTeamMgr.cpp index b8f90ce7f1e..d54f7814137 100644 --- a/src/server/game/Battlegrounds/ArenaTeamMgr.cpp +++ b/src/server/game/Battlegrounds/ArenaTeamMgr.cpp @@ -21,8 +21,8 @@ #include "Log.h" #include "DatabaseEnv.h" #include "Language.h" -#include "ObjectAccessor.h" #include "Player.h" +#include "ObjectAccessor.h" ArenaTeamMgr::ArenaTeamMgr() { diff --git a/src/server/game/Battlegrounds/BattlegroundQueue.cpp b/src/server/game/Battlegrounds/BattlegroundQueue.cpp index 43b7acde925..d9950f4ccbc 100644 --- a/src/server/game/Battlegrounds/BattlegroundQueue.cpp +++ b/src/server/game/Battlegrounds/BattlegroundQueue.cpp @@ -290,10 +290,11 @@ void BattlegroundQueue::RemovePlayer(ObjectGuid guid, bool decreaseInvitedCount) itr = m_QueuedPlayers.find(guid); if (itr == m_QueuedPlayers.end()) { + //This happens if a player logs out while in a bg because WorldSession::LogoutPlayer() notifies the bg twice std::string playerName = "Unknown"; if (Player* player = ObjectAccessor::FindPlayer(guid)) playerName = player->GetName(); - TC_LOG_ERROR("bg.battleground", "BattlegroundQueue: couldn't find player %s (%s)", playerName.c_str(), guid.ToString().c_str()); + TC_LOG_DEBUG("bg.battleground", "BattlegroundQueue: couldn't find player %s (%s)", playerName.c_str(), guid.ToString().c_str()); return; } diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp index cac65a1d2e1..9c654a1793c 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp @@ -21,7 +21,6 @@ #include "ObjectMgr.h" #include "WorldPacket.h" -#include "Formulas.h" #include "GameObject.h" #include "Language.h" #include "Player.h" diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundDS.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundDS.cpp index 9e62a8c4616..02f9d6a32a6 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundDS.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundDS.cpp @@ -18,7 +18,6 @@ #include "BattlegroundDS.h" #include "Creature.h" -#include "GameObject.h" #include "Player.h" #include "WorldPacket.h" diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp index ef2e2b15411..fac6bbcfe99 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp @@ -17,13 +17,13 @@ */ #include "BattlegroundEY.h" -#include "ObjectMgr.h" #include "WorldPacket.h" #include "BattlegroundMgr.h" #include "Creature.h" #include "Language.h" #include "Player.h" #include "Util.h" +#include "ObjectAccessor.h" // these variables aren't used outside of this file, so declare them only here uint32 BG_EY_HonorScoreTicks[BG_HONOR_MODE_NUM] = diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp index cc3daec1649..f94639efaf4 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp @@ -20,10 +20,10 @@ #include "GameObject.h" #include "Language.h" #include "Object.h" -#include "ObjectMgr.h" #include "BattlegroundMgr.h" #include "Player.h" #include "WorldPacket.h" +#include "ObjectAccessor.h" // these variables aren't used outside of this file, so declare them only here enum BG_WSG_Rewards @@ -882,7 +882,10 @@ bool BattlegroundWS::CheckAchievementCriteriaMeet(uint32 criteriaId, Player cons switch (criteriaId) { case BG_CRITERIA_CHECK_SAVE_THE_DAY: - return GetFlagState(player->GetTeam()) == BG_WS_FLAG_STATE_ON_BASE; + if (target) + if (Player const* playerTarget = target->ToPlayer()) + return GetFlagState(playerTarget->GetTeam()) == BG_WS_FLAG_STATE_ON_BASE; + return false; } return Battleground::CheckAchievementCriteriaMeet(criteriaId, player, target, miscValue); diff --git a/src/server/game/Chat/Chat.cpp b/src/server/game/Chat/Chat.cpp index 3cbdcbcaff1..5a74ad05b66 100644 --- a/src/server/game/Chat/Chat.cpp +++ b/src/server/game/Chat/Chat.cpp @@ -19,7 +19,6 @@ #include "Common.h" #include "ObjectMgr.h" #include "World.h" -#include "WorldPacket.h" #include "WorldSession.h" #include "DatabaseEnv.h" @@ -29,9 +28,7 @@ #include "GridNotifiersImpl.h" #include "Language.h" #include "Log.h" -#include "Opcodes.h" #include "Player.h" -#include "UpdateMask.h" #include "ScriptMgr.h" #include "ChatLink.h" diff --git a/src/server/game/Conditions/ConditionMgr.cpp b/src/server/game/Conditions/ConditionMgr.cpp index b05f9ac2a0d..9106bfdd394 100644 --- a/src/server/game/Conditions/ConditionMgr.cpp +++ b/src/server/game/Conditions/ConditionMgr.cpp @@ -27,7 +27,6 @@ #include "ScriptMgr.h" #include "SpellAuras.h" #include "SpellMgr.h" -#include "Spell.h" char const* ConditionMgr::StaticSourceTypeData[CONDITION_SOURCE_TYPE_MAX] = { diff --git a/src/server/game/Conditions/DisableMgr.cpp b/src/server/game/Conditions/DisableMgr.cpp index fac8484e77f..6f77d2af66b 100644 --- a/src/server/game/Conditions/DisableMgr.cpp +++ b/src/server/game/Conditions/DisableMgr.cpp @@ -309,7 +309,7 @@ bool IsDisabledFor(DisableType type, uint32 entry, Unit const* unit, uint8 flags if (unit) { if ((spellFlags & SPELL_DISABLE_PLAYER && unit->GetTypeId() == TYPEID_PLAYER) || - (unit->GetTypeId() == TYPEID_UNIT && ((unit->ToCreature()->IsPet() && spellFlags & SPELL_DISABLE_PET) || spellFlags & SPELL_DISABLE_CREATURE))) + (unit->GetTypeId() == TYPEID_UNIT && ((unit->IsPet() && spellFlags & SPELL_DISABLE_PET) || spellFlags & SPELL_DISABLE_CREATURE))) { if (spellFlags & SPELL_DISABLE_MAP) { diff --git a/src/server/game/DataStores/DBCStores.cpp b/src/server/game/DataStores/DBCStores.cpp index 5cd9b363ae0..d9061dfb106 100644 --- a/src/server/game/DataStores/DBCStores.cpp +++ b/src/server/game/DataStores/DBCStores.cpp @@ -600,7 +600,7 @@ void LoadDBCStores(const std::string& dataPath) for (TaxiPathSetForSource::const_iterator dest_i = src_i->second.begin(); dest_i != src_i->second.end(); ++dest_i) { // not spell path - if (spellPaths.find(dest_i->second.ID) == spellPaths.end()) + if (dest_i->second.price || spellPaths.find(dest_i->second.ID) == spellPaths.end()) { ok = true; break; diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 6e51257eb82..84a12fd6409 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -36,7 +36,6 @@ #include "LootMgr.h" #include "MoveSpline.h" #include "ObjectMgr.h" -#include "Opcodes.h" #include "Player.h" #include "PoolMgr.h" #include "QuestDef.h" @@ -2554,7 +2553,7 @@ void Creature::UpdateMovementFlags() return; // Set the movement flags if the creature is in that mode. (Only fly if actually in air, only swim if in water, etc) - float ground = GetMap()->GetHeight(GetPositionX(), GetPositionY(), GetPositionZMinusOffset()); + float ground = GetMap()->GetHeight(GetPhaseMask(), GetPositionX(), GetPositionY(), GetPositionZMinusOffset()); bool isInAir = (G3D::fuzzyGt(GetPositionZMinusOffset(), ground + 0.05f) || G3D::fuzzyLt(GetPositionZMinusOffset(), ground - 0.05f)); // Can be underground too, prevent the falling diff --git a/src/server/game/Entities/Creature/GossipDef.cpp b/src/server/game/Entities/Creature/GossipDef.cpp index c8a251394cc..63be8d06739 100644 --- a/src/server/game/Entities/Creature/GossipDef.cpp +++ b/src/server/game/Entities/Creature/GossipDef.cpp @@ -19,8 +19,6 @@ #include "QuestDef.h" #include "GossipDef.h" #include "ObjectMgr.h" -#include "Opcodes.h" -#include "WorldPacket.h" #include "WorldSession.h" #include "Formulas.h" diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index d1e3d8a82af..9777672e175 100644 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -113,7 +113,8 @@ void GameObject::RemoveFromOwner() return; } - TC_LOG_FATAL("misc", "Removed GameObject (GUID: %u Entry: %u SpellId: %u LinkedGO: %u) that just lost any reference to the owner (%s) GO list", + // This happens when a mage portal is despawned after the caster changes map (for example using the portal) + TC_LOG_DEBUG("misc", "Removed GameObject (GUID: %u Entry: %u SpellId: %u LinkedGO: %u) that just lost any reference to the owner (%s) GO list", GetGUIDLow(), GetGOInfo()->entry, m_spellId, GetGOInfo()->GetLinkedGameObjectEntry(), ownerGUID.ToString().c_str()); SetOwnerGUID(ObjectGuid::Empty); } @@ -226,7 +227,7 @@ bool GameObject::Create(uint32 guidlow, uint32 name_id, Map* map, uint32 phaseMa SetDisplayId(goinfo->displayId); - m_model = GameObjectModel::Create(*this); + m_model = CreateModel(); // GAMEOBJECT_BYTES_1, index at 0, 1, 2 and 3 SetGoType(GameobjectTypes(goinfo->type)); SetGoState(go_state); @@ -2128,7 +2129,7 @@ void GameObject::UpdateModel() if (GetMap()->ContainsGameObjectModel(*m_model)) GetMap()->RemoveGameObjectModel(*m_model); delete m_model; - m_model = GameObjectModel::Create(*this); + m_model = CreateModel(); if (m_model) GetMap()->InsertGameObjectModel(*m_model); } @@ -2321,3 +2322,25 @@ void GameObject::UpdateModelPosition() GetMap()->InsertGameObjectModel(*m_model); } } + +class GameObjectModelOwnerImpl : public GameObjectModelOwnerBase +{ +public: + explicit GameObjectModelOwnerImpl(GameObject const* owner) : _owner(owner) { } + + virtual bool IsSpawned() const override { return _owner->isSpawned(); } + virtual uint32 GetDisplayId() const override { return _owner->GetDisplayId(); } + virtual uint32 GetPhaseMask() const override { return _owner->GetPhaseMask(); } + virtual G3D::Vector3 GetPosition() const override { return G3D::Vector3(_owner->GetPositionX(), _owner->GetPositionY(), _owner->GetPositionZ()); } + virtual float GetOrientation() const override { return _owner->GetOrientation(); } + virtual float GetScale() const override { return _owner->GetObjectScale(); } + virtual void DebugVisualizeCorner(G3D::Vector3 const& corner) const override { _owner->SummonCreature(1, corner.x, corner.y, corner.z, 0, TEMPSUMMON_MANUAL_DESPAWN); } + +private: + GameObject const* _owner; +}; + +GameObjectModel* GameObject::CreateModel() +{ + return GameObjectModel::Create(Trinity::make_unique<GameObjectModelOwnerImpl>(this), sWorld->GetDataPath()); +} diff --git a/src/server/game/Entities/GameObject/GameObject.h b/src/server/game/Entities/GameObject/GameObject.h index 9da4afd7957..7ef8ef2737d 100644 --- a/src/server/game/Entities/GameObject/GameObject.h +++ b/src/server/game/Entities/GameObject/GameObject.h @@ -850,6 +850,7 @@ class GameObject : public WorldObject, public GridObject<GameObject>, public Map protected: bool AIM_Initialize(); + GameObjectModel* CreateModel(); void UpdateModel(); // updates model in case displayId were changed uint32 m_spellId; time_t m_respawnTime; // (secs) time of next respawn (or despawn if GO have owner()), diff --git a/src/server/game/Entities/Item/ItemEnchantmentMgr.cpp b/src/server/game/Entities/Item/ItemEnchantmentMgr.cpp index be27f5eca30..042d66d7f9e 100644 --- a/src/server/game/Entities/Item/ItemEnchantmentMgr.cpp +++ b/src/server/game/Entities/Item/ItemEnchantmentMgr.cpp @@ -16,17 +16,17 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include <stdlib.h> -#include <functional> #include "ItemEnchantmentMgr.h" #include "DatabaseEnv.h" #include "Log.h" #include "ObjectMgr.h" -#include <list> -#include <vector> #include "Util.h" #include "DBCStores.h" +#include <list> +#include <vector> +#include <stdlib.h> + struct EnchStoreItem { uint32 ench; diff --git a/src/server/game/Entities/Object/ObjectGuid.cpp b/src/server/game/Entities/Object/ObjectGuid.cpp index c15668c3887..b86a253a84d 100644 --- a/src/server/game/Entities/Object/ObjectGuid.cpp +++ b/src/server/game/Entities/Object/ObjectGuid.cpp @@ -18,6 +18,7 @@ #include "ObjectGuid.h" #include "World.h" +#include "ObjectMgr.h" #include <sstream> #include <iomanip> diff --git a/src/server/game/Entities/Object/ObjectGuid.h b/src/server/game/Entities/Object/ObjectGuid.h index 45881ddab6d..b541328c467 100644 --- a/src/server/game/Entities/Object/ObjectGuid.h +++ b/src/server/game/Entities/Object/ObjectGuid.h @@ -89,6 +89,11 @@ class ObjectGuid explicit ObjectGuid(uint64 guid) : _guid(guid) { } ObjectGuid(HighGuid hi, uint32 entry, LowType counter) : _guid(counter ? uint64(counter) | (uint64(entry) << 24) | (uint64(hi) << 48) : 0) { } ObjectGuid(HighGuid hi, LowType counter) : _guid(counter ? uint64(counter) | (uint64(hi) << 48) : 0) { } + ObjectGuid(ObjectGuid const& r) : _guid(r._guid) { } + ObjectGuid(ObjectGuid&& r) : _guid(r._guid) { } + + ObjectGuid& operator=(ObjectGuid const& r) { _guid = r._guid; return *this; } + ObjectGuid& operator=(ObjectGuid&& r) { _guid = r._guid; return *this; } operator uint64() const { return _guid; } PackedGuidReader ReadAsPacked() { return PackedGuidReader(*this); } diff --git a/src/server/game/Entities/Object/Position.cpp b/src/server/game/Entities/Object/Position.cpp index 530e51cd8f5..ae559cbac3a 100644 --- a/src/server/game/Entities/Object/Position.cpp +++ b/src/server/game/Entities/Object/Position.cpp @@ -17,9 +17,10 @@ #include "Position.h" #include "ByteBuffer.h" -#include "G3D/g3dmath.h" #include "GridDefines.h" +#include <G3D/g3dmath.h> + bool Position::operator==(Position const &a) { return (G3D::fuzzyEq(a.m_positionX, m_positionX) && @@ -97,6 +98,34 @@ void Position::GetSinCos(const float x, const float y, float &vsin, float &vcos) } } +bool Position::IsWithinBox(const Position& center, float xradius, float yradius, float zradius) const +{ + // rotate the WorldObject position instead of rotating the whole cube, that way we can make a simplified + // is-in-cube check and we have to calculate only one point instead of 4 + + // 2PI = 360*, keep in mind that ingame orientation is counter-clockwise + double rotation = 2 * M_PI - center.GetOrientation(); + double sinVal = std::sin(rotation); + double cosVal = std::cos(rotation); + + float BoxDistX = GetPositionX() - center.GetPositionX(); + float BoxDistY = GetPositionY() - center.GetPositionY(); + + float rotX = float(center.GetPositionX() + BoxDistX * cosVal - BoxDistY*sinVal); + float rotY = float(center.GetPositionY() + BoxDistY * cosVal + BoxDistX*sinVal); + + // box edges are parallel to coordiante axis, so we can treat every dimension independently :D + float dz = GetPositionZ() - center.GetPositionZ(); + float dx = rotX - center.GetPositionX(); + float dy = rotY - center.GetPositionY(); + if ((std::fabs(dx) > xradius) || + (std::fabs(dy) > yradius) || + (std::fabs(dz) > zradius)) + return false; + + return true; +} + bool Position::HasInArc(float arc, const Position* obj, float border) const { // always have self in arc diff --git a/src/server/game/Entities/Object/Position.h b/src/server/game/Entities/Object/Position.h index 5bd37567811..b3e474fa96b 100644 --- a/src/server/game/Entities/Object/Position.h +++ b/src/server/game/Entities/Object/Position.h @@ -195,6 +195,7 @@ public: return GetExactDistSq(pos) < dist * dist; } + bool IsWithinBox(const Position& center, float xradius, float yradius, float zradius) const; bool HasInArc(float arcangle, Position const* pos, float border = 2.0f) const; bool HasInLine(Position const* pos, float width) const; std::string ToString() const; diff --git a/src/server/game/Entities/Object/Updates/UpdateData.cpp b/src/server/game/Entities/Object/Updates/UpdateData.cpp index 937bda3a79d..ce27319de74 100644 --- a/src/server/game/Entities/Object/Updates/UpdateData.cpp +++ b/src/server/game/Entities/Object/Updates/UpdateData.cpp @@ -20,7 +20,6 @@ #include "ByteBuffer.h" #include "WorldPacket.h" #include "UpdateData.h" -#include "Log.h" #include "Opcodes.h" #include "World.h" #include "zlib.h" diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 16485d25057..14dc5b5c0d6 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -781,10 +781,7 @@ Player::Player(WorldSession* session): Unit(true) ////////////////////Rest System///////////////////// time_inn_enter = 0; - inn_pos_mapid = 0; - inn_pos_x = 0.0f; - inn_pos_y = 0.0f; - inn_pos_z = 0.0f; + inn_triggerId = 0; m_rest_bonus = 0; rest_type = REST_TYPE_NO; ////////////////////Rest System///////////////////// @@ -1751,6 +1748,17 @@ void Player::Update(uint32 p_time) { if (p_time >= m_zoneUpdateTimer) { + // On zone update tick check if we are still in an inn if we are supposed to be in one + if (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING) && GetRestType() == REST_TYPE_IN_TAVERN) + { + AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(GetInnTriggerId()); + if (!atEntry || !IsInAreaTriggerRadius(atEntry)) + { + RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING); + SetRestType(REST_TYPE_NO); + } + } + uint32 newzone, newarea; GetZoneAndAreaId(newzone, newarea); @@ -1941,12 +1949,9 @@ void Player::setDeathState(DeathState s) SetUInt32Value(PLAYER_SELF_RES_SPELL, 0); } -void Player::InnEnter(time_t time, uint32 mapid, float x, float y, float z) +void Player::InnEnter(time_t time, uint32 triggerId) { - inn_pos_mapid = mapid; - inn_pos_x = x; - inn_pos_y = y; - inn_pos_z = z; + inn_triggerId = triggerId; time_inn_enter = time; } @@ -2837,6 +2842,28 @@ void Player::SetInWater(bool apply) getHostileRefManager().updateThreatTables(); } +bool Player::IsInAreaTriggerRadius(const AreaTriggerEntry* trigger) const +{ + if (!trigger || GetMapId() != trigger->mapid) + return false; + + if (trigger->radius > 0.f) + { + // if we have radius check it + float dist = GetDistance(trigger->x, trigger->y, trigger->z); + if (dist > trigger->radius) + return false; + } + else + { + Position center(trigger->x, trigger->y, trigger->z, trigger->box_orientation); + if (!IsWithinBox(center, trigger->box_x / 2.f, trigger->box_y / 2.f, trigger->box_z / 2.f)) + return false; + } + + return true; +} + void Player::SetGameMaster(bool on) { if (on) @@ -7339,7 +7366,7 @@ void Player::UpdateArea(uint32 newArea) { SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING); SetRestType(REST_TYPE_IN_FACTION_AREA); - InnEnter(time(0), GetMapId(), 0, 0, 0); + InnEnter(time(nullptr), 0); } else if (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING) && GetRestType() == REST_TYPE_IN_FACTION_AREA) { @@ -7414,7 +7441,7 @@ void Player::UpdateZone(uint32 newZone, uint32 newArea) { SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING); SetRestType(REST_TYPE_IN_CITY); - InnEnter(time(0), GetMapId(), 0, 0, 0); + InnEnter(time(nullptr), 0); } pvpInfo.IsInNoPvPArea = true; } @@ -7424,8 +7451,10 @@ void Player::UpdateZone(uint32 newZone, uint32 newArea) { if (GetRestType() == REST_TYPE_IN_TAVERN) // Still inside a tavern or has recently left { - // Remove rest state if we have recently left a tavern. - if (GetMapId() != GetInnPosMapId() || GetExactDist(GetInnPosX(), GetInnPosY(), GetInnPosZ()) > 1.0f) + // check that we are still inside the tavern (in areatrigger radius) + + AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(GetInnTriggerId()); + if (!atEntry || !IsInAreaTriggerRadius(atEntry)) { RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING); SetRestType(REST_TYPE_NO); @@ -22163,7 +22192,7 @@ inline void BeforeVisibilityDestroy(T* /*t*/, Player* /*p*/) { } template<> inline void BeforeVisibilityDestroy<Creature>(Creature* t, Player* p) { - if (p->GetPetGUID() == t->GetGUID() && t->ToCreature()->IsPet()) + if (p->GetPetGUID() == t->GetGUID() && t->IsPet()) ((Pet*)t)->Remove(PET_SAVE_NOT_IN_SLOT, true); } @@ -23563,8 +23592,8 @@ bool Player::isHonorOrXPTarget(Unit* victim) const if (victim->GetTypeId() == TYPEID_UNIT) { - if (victim->ToCreature()->IsTotem() || - victim->ToCreature()->IsPet() || + if (victim->IsTotem() || + victim->IsPet() || victim->ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_NO_XP_AT_KILL) return false; } diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index c1417177320..42fa6dc2ea3 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -1124,6 +1124,7 @@ class Player : public Unit, public GridObject<Player> bool IsInWater() const override { return m_isInWater; } bool IsUnderWater() const override; bool IsFalling() { return GetPositionZ() < m_lastFallZ; } + bool IsInAreaTriggerRadius(const AreaTriggerEntry* trigger) const; void SendInitialPacketsBeforeAddToMap(); void SendInitialPacketsAfterAddToMap(); @@ -1186,7 +1187,7 @@ class Player : public Unit, public GridObject<Player> void setDeathState(DeathState s) override; // overwrite Unit::setDeathState - void InnEnter(time_t time, uint32 mapid, float x, float y, float z); + void InnEnter(time_t time, uint32 triggerId); float GetRestBonus() const { return m_rest_bonus; } void SetRestBonus(float rest_bonus_new); @@ -1194,10 +1195,7 @@ class Player : public Unit, public GridObject<Player> RestType GetRestType() const { return rest_type; } void SetRestType(RestType n_r_type) { rest_type = n_r_type; } - uint32 GetInnPosMapId() const { return inn_pos_mapid; } - float GetInnPosX() const { return inn_pos_x; } - float GetInnPosY() const { return inn_pos_y; } - float GetInnPosZ() const { return inn_pos_z; } + uint32 GetInnTriggerId() const { return inn_triggerId; } time_t GetTimeInnEnter() const { return time_inn_enter; } void UpdateInnerTime (time_t time) { time_inn_enter = time; } @@ -1629,9 +1627,9 @@ class Player : public Unit, public GridObject<Player> // Dual Spec void UpdateSpecCount(uint8 count); - uint32 GetActiveSpec() { return m_activeSpec; } + uint32 GetActiveSpec() const { return m_activeSpec; } void SetActiveSpec(uint8 spec){ m_activeSpec = spec; } - uint8 GetSpecsCount() { return m_specsCount; } + uint8 GetSpecsCount() const { return m_specsCount; } void SetSpecsCount(uint8 count) { m_specsCount = count; } void ActivateSpec(uint8 spec); @@ -2529,10 +2527,7 @@ class Player : public Unit, public GridObject<Player> ////////////////////Rest System///////////////////// time_t time_inn_enter; - uint32 inn_pos_mapid; - float inn_pos_x; - float inn_pos_y; - float inn_pos_z; + uint32 inn_triggerId; float m_rest_bonus; RestType rest_type; ////////////////////Rest System///////////////////// diff --git a/src/server/game/Entities/Transport/Transport.cpp b/src/server/game/Entities/Transport/Transport.cpp index 6d98a4c78b2..d6a130c0317 100644 --- a/src/server/game/Entities/Transport/Transport.cpp +++ b/src/server/game/Entities/Transport/Transport.cpp @@ -94,7 +94,7 @@ bool Transport::Create(uint32 guidlow, uint32 entry, uint32 mapid, float x, floa SetName(goinfo->name); UpdateRotationFields(0.0f, 1.0f); - m_model = GameObjectModel::Create(*this); + m_model = CreateModel(); return true; } diff --git a/src/server/game/Entities/Unit/StatSystem.cpp b/src/server/game/Entities/Unit/StatSystem.cpp index 67101dc8961..fb27fea7060 100644 --- a/src/server/game/Entities/Unit/StatSystem.cpp +++ b/src/server/game/Entities/Unit/StatSystem.cpp @@ -23,7 +23,6 @@ #include "SharedDefines.h" #include "SpellAuras.h" #include "SpellAuraEffects.h" -#include "SpellMgr.h" #include "World.h" inline bool _ModifyUInt32(bool apply, uint32& baseValue, int32& amount) diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index b3b757e6a2e..c29b14d9c13 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -54,8 +54,8 @@ #include "SpellHistory.h" #include "SpellMgr.h" #include "TemporarySummon.h" -#include "Totem.h" #include "Transport.h" +#include "Totem.h" #include "UpdateFieldFlags.h" #include "Util.h" #include "Vehicle.h" @@ -330,7 +330,7 @@ void Unit::Update(uint32 p_time) SendThreatListUpdate(); // update combat timer only for players and pets (only pets with PetAI) - if (IsInCombat() && (GetTypeId() == TYPEID_PLAYER || (ToCreature()->IsPet() && IsControlledByPlayer()))) + if (IsInCombat() && (GetTypeId() == TYPEID_PLAYER || (IsPet() && IsControlledByPlayer()))) { // Check UNIT_STATE_MELEE_ATTACKING or UNIT_STATE_CHASE (without UNIT_STATE_FOLLOW in this case) so pets can reach far away // targets without stopping half way there and running off. @@ -2131,8 +2131,8 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst (const Unit* victim, WeaponAttackT // Max 40% chance to score a glancing blow against mobs that are higher level (can do only players and pets and not with ranged weapon) if (attType != RANGED_ATTACK && - (GetTypeId() == TYPEID_PLAYER || ToCreature()->IsPet()) && - victim->GetTypeId() != TYPEID_PLAYER && !victim->ToCreature()->IsPet() && + (GetTypeId() == TYPEID_PLAYER || IsPet()) && + victim->GetTypeId() != TYPEID_PLAYER && !victim->IsPet() && getLevel() < victim->getLevelForTarget(this)) { // cap possible value (with bonuses > max skill) @@ -2206,6 +2206,9 @@ uint32 Unit::CalculateDamage(WeaponAttackType attType, bool normalized, bool add } } + minDamage = std::max(0.f, minDamage); + maxDamage = std::max(0.f, maxDamage); + if (minDamage > maxDamage) std::swap(minDamage, maxDamage); @@ -2702,7 +2705,7 @@ float Unit::GetUnitDodgeChance() const return GetFloatValue(PLAYER_DODGE_PERCENTAGE); else { - if (ToCreature()->IsTotem()) + if (IsTotem()) return 0.0f; else { @@ -2777,7 +2780,7 @@ float Unit::GetUnitBlockChance() const } else { - if (ToCreature()->IsTotem()) + if (IsTotem()) return 0.0f; else { @@ -3482,7 +3485,7 @@ void Unit::_UnapplyAura(AuraApplicationMap::iterator &i, AuraRemoveMode removeMo ASSERT(!aurApp->GetEffectMask()); // Remove totem at next update if totem loses its aura - if (aurApp->GetRemoveMode() == AURA_REMOVE_BY_EXPIRE && GetTypeId() == TYPEID_UNIT && ToCreature()->IsTotem()) + if (aurApp->GetRemoveMode() == AURA_REMOVE_BY_EXPIRE && GetTypeId() == TYPEID_UNIT && IsTotem()) { if (ToTotem()->GetSpell() == aura->GetId() && ToTotem()->GetTotemType() == TOTEM_PASSIVE) ToTotem()->setDeathState(JUST_DIED); @@ -8981,7 +8984,7 @@ bool Unit::Attack(Unit* victim, bool meleeAttack) //if (GetTypeId() == TYPEID_UNIT) // ToCreature()->SetCombatStartPosition(GetPositionX(), GetPositionY(), GetPositionZ()); - if (GetTypeId() == TYPEID_UNIT && !ToCreature()->IsPet()) + if (GetTypeId() == TYPEID_UNIT && !IsPet()) { // should not let player enter combat by right clicking target - doesn't helps SetInCombatWith(victim); @@ -9470,7 +9473,7 @@ void Unit::GetAllMinionsByEntry(std::list<Creature*>& Minions, uint32 entry) Unit* unit = *itr; ++itr; if (unit->GetEntry() == entry && unit->GetTypeId() == TYPEID_UNIT - && unit->ToCreature()->IsSummon()) // minion, actually + && unit->IsSummon()) // minion, actually Minions.push_back(unit->ToCreature()); } } @@ -9482,7 +9485,7 @@ void Unit::RemoveAllMinionsByEntry(uint32 entry) Unit* unit = *itr; ++itr; if (unit->GetEntry() == entry && unit->GetTypeId() == TYPEID_UNIT - && unit->ToCreature()->IsSummon()) // minion, actually + && unit->IsSummon()) // minion, actually unit->ToTempSummon()->UnSummon(); // i think this is safe because i have never heard that a despawned minion will trigger a same minion } @@ -9582,7 +9585,7 @@ int32 Unit::DealHeal(Unit* victim, uint32 addhealth) Unit* unit = this; - if (GetTypeId() == TYPEID_UNIT && ToCreature()->IsTotem()) + if (GetTypeId() == TYPEID_UNIT && IsTotem()) unit = GetOwner(); if (Player* player = unit->ToPlayer()) @@ -9626,7 +9629,6 @@ Unit* Unit::GetMagicHitRedirectTarget(Unit* victim, SpellInfo const* spellInfo) { if (Unit* magnet = (*itr)->GetBase()->GetCaster()) if (spellInfo->CheckExplicitTarget(this, magnet) == SPELL_CAST_OK - && spellInfo->CheckTarget(this, magnet, false) == SPELL_CAST_OK && _IsValidAttackTarget(magnet, spellInfo)) { /// @todo handle this charge drop by proc in cast phase on explicit target @@ -9635,7 +9637,7 @@ Unit* Unit::GetMagicHitRedirectTarget(Unit* victim, SpellInfo const* spellInfo) // Set up missile speed based delay uint32 delay = uint32(std::floor(std::max<float>(victim->GetDistance(this), 5.0f) / spellInfo->Speed * 1000.0f)); // Schedule charge drop - (*itr)->GetBase()->DropChargeDelayed(delay,AURA_REMOVE_BY_EXPIRE); + (*itr)->GetBase()->DropChargeDelayed(delay, AURA_REMOVE_BY_EXPIRE); } else (*itr)->GetBase()->DropCharge(AURA_REMOVE_BY_EXPIRE); @@ -9724,7 +9726,7 @@ Unit* Unit::GetNextRandomRaidMemberOrPet(float radius) if (GetTypeId() == TYPEID_PLAYER) player = ToPlayer(); // Should we enable this also for charmed units? - else if (GetTypeId() == TYPEID_UNIT && ToCreature()->IsPet()) + else if (GetTypeId() == TYPEID_UNIT && IsPet()) player = GetOwner()->ToPlayer(); if (!player) @@ -9874,7 +9876,7 @@ uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, uin return pdamage; // For totems get damage bonus from owner - if (GetTypeId() == TYPEID_UNIT && ToCreature()->IsTotem()) + if (GetTypeId() == TYPEID_UNIT && IsTotem()) if (Unit* owner = GetOwner()) return owner->SpellDamageBonusDone(victim, spellProto, pdamage, damagetype); @@ -10005,14 +10007,14 @@ float Unit::SpellDamagePctDone(Unit* victim, SpellInfo const* spellProto, Damage return 1.0f; // For totems pct done mods are calculated when its calculation is run on the player in SpellDamageBonusDone. - if (GetTypeId() == TYPEID_UNIT && ToCreature()->IsTotem()) + if (GetTypeId() == TYPEID_UNIT && IsTotem()) return 1.0f; // Done total percent damage auras float DoneTotalMod = 1.0f; // Pet damage? - if (GetTypeId() == TYPEID_UNIT && !ToCreature()->IsPet()) + if (GetTypeId() == TYPEID_UNIT && !IsPet()) DoneTotalMod *= ToCreature()->GetSpellDamageMod(ToCreature()->GetCreatureTemplate()->rank); AuraEffectList const& mModDamagePercentDone = GetAuraEffectsByType(SPELL_AURA_MOD_DAMAGE_PERCENT_DONE); @@ -12568,7 +12570,7 @@ bool Unit::CanHaveThreatList(bool skipAliveCheck) const return false; // totems can not have threat list - if (ToCreature()->IsTotem()) + if (IsTotem()) return false; // vehicles can not have threat list @@ -14516,7 +14518,7 @@ Player* Unit::GetSpellModOwner() const if (Player* player = const_cast<Unit*>(this)->ToPlayer()) return player; - if (ToCreature()->IsPet() || ToCreature()->IsTotem()) + if (IsPet() || IsTotem()) { if (Unit* owner = GetOwner()) if (Player* player = owner->ToPlayer()) @@ -14787,7 +14789,7 @@ void Unit::ApplyCastTimePercentMod(float val, bool apply) uint32 Unit::GetCastingTimeForBonus(SpellInfo const* spellProto, DamageEffectType damagetype, uint32 CastingTime) const { // Not apply this to creature cast spells with casttime == 0 - if (CastingTime == 0 && GetTypeId() == TYPEID_UNIT && !ToCreature()->IsPet()) + if (CastingTime == 0 && GetTypeId() == TYPEID_UNIT && !IsPet()) return 3500; if (CastingTime > 7000) CastingTime = 7000; @@ -14887,7 +14889,7 @@ void Unit::UpdateAuraForGroup(uint8 slot) player->SetAuraUpdateMaskForRaid(slot); } } - else if (GetTypeId() == TYPEID_UNIT && ToCreature()->IsPet()) + else if (GetTypeId() == TYPEID_UNIT && IsPet()) { Pet* pet = ((Pet*)this); if (pet->isControlled()) @@ -16055,7 +16057,7 @@ void Unit::RemoveCharmedBy(Unit* charmer) // a guardian should always have charminfo if (playerCharmer && this != charmer->GetFirstControlled()) playerCharmer->SendRemoveControlBar(); - else if (GetTypeId() == TYPEID_PLAYER || (GetTypeId() == TYPEID_UNIT && !ToCreature()->IsGuardian())) + else if (GetTypeId() == TYPEID_PLAYER || (GetTypeId() == TYPEID_UNIT && !IsGuardian())) DeleteCharmInfo(); } diff --git a/src/server/game/Globals/ObjectAccessor.cpp b/src/server/game/Globals/ObjectAccessor.cpp index 859633b16c4..35d6ba91401 100644 --- a/src/server/game/Globals/ObjectAccessor.cpp +++ b/src/server/game/Globals/ObjectAccessor.cpp @@ -16,9 +16,6 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include <boost/thread/shared_mutex.hpp> -#include <boost/thread/locks.hpp> - #include "ObjectAccessor.h" #include "Corpse.h" #include "Creature.h" @@ -32,7 +29,9 @@ #include "Pet.h" #include "Player.h" #include "World.h" -#include "WorldPacket.h" + +#include <boost/thread/shared_mutex.hpp> +#include <boost/thread/locks.hpp> ObjectAccessor::ObjectAccessor() { } diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index c65e52c8de7..d67d7446d41 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -25,7 +25,6 @@ #include "Common.h" #include "DatabaseEnv.h" #include "DisableMgr.h" -#include "GameEventMgr.h" #include "GossipDef.h" #include "GroupMgr.h" #include "GuildMgr.h" @@ -36,19 +35,15 @@ #include "MapManager.h" #include "Object.h" #include "ObjectMgr.h" -#include "Pet.h" #include "PoolMgr.h" #include "ReputationMgr.h" #include "ScriptMgr.h" #include "SpellAuras.h" -#include "Spell.h" #include "SpellMgr.h" #include "SpellScript.h" -#include "Transport.h" #include "UpdateMask.h" #include "Util.h" #include "Vehicle.h" -#include "WaypointManager.h" #include "World.h" ScriptMapMap sSpellScripts; @@ -2759,6 +2754,14 @@ void ObjectMgr::LoadItemTemplates() TC_LOG_ERROR("sql.sql", "Item (Entry: %u) has broken spell in spellid_%d (%d)", entry, j+1, itemTemplate.Spells[j].SpellId); itemTemplate.Spells[j].SpellId = 0; } + + if (spellInfo && itemTemplate.Spells[j].SpellCategory) + { + bool added = sSpellsByCategoryStore[itemTemplate.Spells[j].SpellCategory].insert(itemTemplate.Spells[j].SpellId).second; + if (added) + TC_LOG_DEBUG("sql.sql", "Item(Entry: %u) spellid_%d (%d) category %u added to sSpellsByCategoryStore", + entry, j + 1, itemTemplate.Spells[j].SpellId, itemTemplate.Spells[j].SpellCategory); + } } } } @@ -9146,8 +9149,8 @@ void ObjectMgr::LoadGameObjectQuestItems() { uint32 oldMSTime = getMSTime(); - // 0 1 - QueryResult result = WorldDatabase.Query("SELECT GameObjectEntry, ItemId FROM gameobject_questitem ORDER BY Idx ASC"); + // 0 1 2 + QueryResult result = WorldDatabase.Query("SELECT GameObjectEntry, ItemId, Idx FROM gameobject_questitem ORDER BY Idx ASC"); if (!result) { @@ -9161,7 +9164,22 @@ void ObjectMgr::LoadGameObjectQuestItems() Field* fields = result->Fetch(); uint32 entry = fields[0].GetUInt32(); - uint32 item = fields[1].GetUInt32(); + uint32 item = fields[1].GetUInt32(); + uint32 idx = fields[2].GetUInt32(); + + GameObjectTemplate const* goInfo = GetGameObjectTemplate(entry); + if (!goInfo) + { + TC_LOG_ERROR("sql.sql", "Table `gameobject_questitem` has data for nonexistent gameobject (entry: %u, idx: %u), skipped", entry, idx); + continue; + }; + + ItemEntry const* db2Data = sItemStore.LookupEntry(item); + if (!db2Data) + { + TC_LOG_ERROR("sql.sql", "Table `gameobject_questitem` has nonexistent item (ID: %u) in gameobject (entry: %u, idx: %u), skipped", item, entry, idx); + continue; + }; _gameObjectQuestItemStore[entry].push_back(item); @@ -9176,8 +9194,8 @@ void ObjectMgr::LoadCreatureQuestItems() { uint32 oldMSTime = getMSTime(); - // 0 1 - QueryResult result = WorldDatabase.Query("SELECT CreatureEntry, ItemId FROM creature_questitem ORDER BY Idx ASC"); + // 0 1 2 + QueryResult result = WorldDatabase.Query("SELECT CreatureEntry, ItemId, Idx FROM creature_questitem ORDER BY Idx ASC"); if (!result) { @@ -9191,7 +9209,22 @@ void ObjectMgr::LoadCreatureQuestItems() Field* fields = result->Fetch(); uint32 entry = fields[0].GetUInt32(); - uint32 item = fields[1].GetUInt32(); + uint32 item = fields[1].GetUInt32(); + uint32 idx = fields[2].GetUInt32(); + + CreatureTemplate const* creatureInfo = GetCreatureTemplate(entry); + if (!creatureInfo) + { + TC_LOG_ERROR("sql.sql", "Table `creature_questitem` has data for nonexistent creature (entry: %u, idx: %u), skipped", entry, idx); + continue; + }; + + ItemEntry const* db2Data = sItemStore.LookupEntry(item); + if (!db2Data) + { + TC_LOG_ERROR("sql.sql", "Table `creature_questitem` has nonexistent item (ID: %u) in creature (entry: %u, idx: %u), skipped", item, entry, idx); + continue; + }; _creatureQuestItemStore[entry].push_back(item); diff --git a/src/server/game/Grids/Notifiers/GridNotifiers.h b/src/server/game/Grids/Notifiers/GridNotifiers.h index ccf9748e67a..16e36d98d33 100644 --- a/src/server/game/Grids/Notifiers/GridNotifiers.h +++ b/src/server/game/Grids/Notifiers/GridNotifiers.h @@ -950,7 +950,7 @@ namespace Trinity bool operator()(Unit* u) { // Check contains checks for: live, non-selectable, non-attackable flags, flight check and GM check, ignore totems - if (u->GetTypeId() == TYPEID_UNIT && u->ToCreature()->IsTotem()) + 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)) diff --git a/src/server/game/Handlers/ArenaTeamHandler.cpp b/src/server/game/Handlers/ArenaTeamHandler.cpp index 5ac5ae02b90..ead05033a35 100644 --- a/src/server/game/Handlers/ArenaTeamHandler.cpp +++ b/src/server/game/Handlers/ArenaTeamHandler.cpp @@ -17,17 +17,14 @@ */ #include "Player.h" -#include "World.h" #include "WorldPacket.h" #include "WorldSession.h" -#include "DatabaseEnv.h" - #include "ArenaTeam.h" -#include "Log.h" -#include "ObjectMgr.h" #include "SocialMgr.h" #include "ArenaTeamMgr.h" #include "Opcodes.h" +#include "ObjectAccessor.h" +#include "ObjectMgr.h" void WorldSession::HandleInspectArenaTeamsOpcode(WorldPacket& recvData) { diff --git a/src/server/game/Handlers/AuctionHouseHandler.cpp b/src/server/game/Handlers/AuctionHouseHandler.cpp index 4975d19743d..8ee14d6baa9 100644 --- a/src/server/game/Handlers/AuctionHouseHandler.cpp +++ b/src/server/game/Handlers/AuctionHouseHandler.cpp @@ -25,7 +25,6 @@ #include "AuctionHouseMgr.h" #include "Log.h" #include "Language.h" -#include "Opcodes.h" #include "UpdateMask.h" #include "Util.h" #include "AccountMgr.h" diff --git a/src/server/game/Handlers/CombatHandler.cpp b/src/server/game/Handlers/CombatHandler.cpp index 39ba593c8d9..ac33880cb98 100644 --- a/src/server/game/Handlers/CombatHandler.cpp +++ b/src/server/game/Handlers/CombatHandler.cpp @@ -24,7 +24,6 @@ #include "CreatureAI.h" #include "Vehicle.h" #include "Player.h" -#include "Opcodes.h" void WorldSession::HandleAttackSwingOpcode(WorldPacket& recvData) { diff --git a/src/server/game/Handlers/GroupHandler.cpp b/src/server/game/Handlers/GroupHandler.cpp index 9d6359c56e9..f8531adeb88 100644 --- a/src/server/game/Handlers/GroupHandler.cpp +++ b/src/server/game/Handlers/GroupHandler.cpp @@ -22,7 +22,6 @@ #include "GroupMgr.h" #include "Log.h" #include "ObjectMgr.h" -#include "Opcodes.h" #include "Pet.h" #include "Player.h" #include "SocialMgr.h" diff --git a/src/server/game/Handlers/LootHandler.cpp b/src/server/game/Handlers/LootHandler.cpp index 26d1737257e..18ad2e828f0 100644 --- a/src/server/game/Handlers/LootHandler.cpp +++ b/src/server/game/Handlers/LootHandler.cpp @@ -25,9 +25,7 @@ #include "LootMgr.h" #include "ObjectAccessor.h" #include "Object.h" -#include "Opcodes.h" #include "Player.h" -#include "World.h" #include "WorldPacket.h" #include "WorldSession.h" diff --git a/src/server/game/Handlers/MiscHandler.cpp b/src/server/game/Handlers/MiscHandler.cpp index 7b8ce80ccd7..683b77e7aa0 100644 --- a/src/server/game/Handlers/MiscHandler.cpp +++ b/src/server/game/Handlers/MiscHandler.cpp @@ -28,7 +28,6 @@ #include "ObjectMgr.h" #include "GuildMgr.h" #include "WorldSession.h" -#include "LootMgr.h" #include "Chat.h" #include "zlib.h" #include "ObjectAccessor.h" @@ -37,7 +36,6 @@ #include "OutdoorPvP.h" #include "SocialMgr.h" #include "AccountMgr.h" -#include "CreatureAI.h" #include "DBCEnums.h" #include "ScriptMgr.h" #include "MapManager.h" @@ -825,59 +823,13 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recvData) return; } - if (player->GetMapId() != atEntry->mapid) + if (!player->IsInAreaTriggerRadius(atEntry)) { - TC_LOG_DEBUG("network", "HandleAreaTriggerOpcode: Player '%s' (GUID: %u) too far (trigger map: %u player map: %u), ignore Area Trigger ID: %u", - player->GetName().c_str(), atEntry->mapid, player->GetMapId(), player->GetGUIDLow(), triggerId); + TC_LOG_DEBUG("network", "HandleAreaTriggerOpcode: Player '%s' (GUID: %u) too far, ignore Area Trigger ID: %u", + player->GetName().c_str(), player->GetGUIDLow(), triggerId); return; } - // delta is safe radius - const float delta = 5.0f; - - if (atEntry->radius > 0) - { - // if we have radius check it - float dist = player->GetDistance(atEntry->x, atEntry->y, atEntry->z); - if (dist > atEntry->radius + delta) - { - TC_LOG_DEBUG("network", "HandleAreaTriggerOpcode: Player '%s' (GUID: %u) too far (radius: %f distance: %f), ignore Area Trigger ID: %u", - player->GetName().c_str(), player->GetGUIDLow(), atEntry->radius, dist, triggerId); - return; - } - } - else - { - // we have only extent - - // rotate the players position instead of rotating the whole cube, that way we can make a simplified - // is-in-cube check and we have to calculate only one point instead of 4 - - // 2PI = 360°, keep in mind that ingame orientation is counter-clockwise - double rotation = 2 * M_PI - atEntry->box_orientation; - double sinVal = std::sin(rotation); - double cosVal = std::cos(rotation); - - float playerBoxDistX = player->GetPositionX() - atEntry->x; - float playerBoxDistY = player->GetPositionY() - atEntry->y; - - float rotPlayerX = float(atEntry->x + playerBoxDistX * cosVal - playerBoxDistY*sinVal); - float rotPlayerY = float(atEntry->y + playerBoxDistY * cosVal + playerBoxDistX*sinVal); - - // box edges are parallel to coordiante axis, so we can treat every dimension independently :D - float dz = player->GetPositionZ() - atEntry->z; - float dx = rotPlayerX - atEntry->x; - float dy = rotPlayerY - atEntry->y; - if ((std::fabs(dx) > atEntry->box_x / 2 + delta) || - (std::fabs(dy) > atEntry->box_y / 2 + delta) || - (std::fabs(dz) > atEntry->box_z / 2 + delta)) - { - TC_LOG_DEBUG("network", "HandleAreaTriggerOpcode: Player '%s' (GUID: %u) too far (1/2 box X: %f 1/2 box Y: %f 1/2 box Z: %f rotatedPlayerX: %f rotatedPlayerY: %f dZ:%f), ignore Area Trigger ID: %u", - player->GetName().c_str(), player->GetGUIDLow(), atEntry->box_x/2, atEntry->box_y/2, atEntry->box_z/2, rotPlayerX, rotPlayerY, dz, triggerId); - return; - } - } - if (player->isDebugAreaTriggers) ChatHandler(player->GetSession()).PSendSysMessage(LANG_DEBUG_AREATRIGGER_REACHED, triggerId); @@ -893,7 +845,7 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recvData) { // set resting flag we are in the inn player->SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING); - player->InnEnter(time(NULL), atEntry->mapid, atEntry->x, atEntry->y, atEntry->z); + player->InnEnter(time(nullptr), atEntry->id); player->SetRestType(REST_TYPE_IN_TAVERN); if (sWorld->IsFFAPvPRealm()) diff --git a/src/server/game/Handlers/PetHandler.cpp b/src/server/game/Handlers/PetHandler.cpp index 0bf33eee234..8ec887ea94d 100644 --- a/src/server/game/Handlers/PetHandler.cpp +++ b/src/server/game/Handlers/PetHandler.cpp @@ -52,7 +52,7 @@ void WorldSession::HandleDismissCritter(WorldPacket& recvData) if (_player->GetCritterGUID() == pet->GetGUID()) { - if (pet->GetTypeId() == TYPEID_UNIT && pet->ToCreature()->IsSummon()) + if (pet->GetTypeId() == TYPEID_UNIT && pet->IsSummon()) pet->ToTempSummon()->UnSummon(); } } @@ -217,7 +217,7 @@ void WorldSession::HandlePetActionHelper(Unit* pet, ObjectGuid guid1, uint32 spe pet->ToCreature()->AI()->AttackStart(TargetUnit); //10% chance to play special pet attack talk, else growl - if (pet->ToCreature()->IsPet() && ((Pet*)pet)->getPetType() == SUMMON_PET && pet != TargetUnit && urand(0, 100) < 10) + if (pet->IsPet() && ((Pet*)pet)->getPetType() == SUMMON_PET && pet != TargetUnit && urand(0, 100) < 10) pet->SendPetTalk((uint32)PET_TALK_ATTACK); else { @@ -349,7 +349,7 @@ void WorldSession::HandlePetActionHelper(Unit* pet, ObjectGuid guid1, uint32 spe //10% chance to play special pet attack talk, else growl //actually this only seems to happen on special spells, fire shield for imp, torment for voidwalker, but it's stupid to check every spell - if (pet->ToCreature()->IsPet() && (((Pet*)pet)->getPetType() == SUMMON_PET) && (pet != unit_target) && (urand(0, 100) < 10)) + if (pet->IsPet() && (((Pet*)pet)->getPetType() == SUMMON_PET) && (pet != unit_target) && (urand(0, 100) < 10)) pet->SendPetTalk((uint32)PET_TALK_SPECIAL_SPELL); else { @@ -555,7 +555,7 @@ void WorldSession::HandlePetSetAction(WorldPacket& recvData) //sign for autocast if (act_state == ACT_ENABLED) { - if (pet->GetTypeId() == TYPEID_UNIT && pet->ToCreature()->IsPet()) + if (pet->GetTypeId() == TYPEID_UNIT && pet->IsPet()) ((Pet*)pet)->ToggleAutocast(spellInfo, true); else for (Unit::ControlList::iterator itr = GetPlayer()->m_Controlled.begin(); itr != GetPlayer()->m_Controlled.end(); ++itr) @@ -565,7 +565,7 @@ void WorldSession::HandlePetSetAction(WorldPacket& recvData) //sign for no/turn off autocast else if (act_state == ACT_DISABLED) { - if (pet->GetTypeId() == TYPEID_UNIT && pet->ToCreature()->IsPet()) + if (pet->GetTypeId() == TYPEID_UNIT && pet->IsPet()) ((Pet*)pet)->ToggleAutocast(spellInfo, false); else for (Unit::ControlList::iterator itr = GetPlayer()->m_Controlled.begin(); itr != GetPlayer()->m_Controlled.end(); ++itr) diff --git a/src/server/game/Handlers/QueryHandler.cpp b/src/server/game/Handlers/QueryHandler.cpp index fda3551bf2b..906c3017100 100644 --- a/src/server/game/Handlers/QueryHandler.cpp +++ b/src/server/game/Handlers/QueryHandler.cpp @@ -20,7 +20,6 @@ #include "DatabaseEnv.h" #include "WorldPacket.h" #include "WorldSession.h" -#include "Opcodes.h" #include "Log.h" #include "World.h" #include "ObjectMgr.h" diff --git a/src/server/game/Handlers/QuestHandler.cpp b/src/server/game/Handlers/QuestHandler.cpp index 3c6258b2d7c..b6297e1705a 100644 --- a/src/server/game/Handlers/QuestHandler.cpp +++ b/src/server/game/Handlers/QuestHandler.cpp @@ -20,7 +20,6 @@ #include "Log.h" #include "WorldPacket.h" #include "WorldSession.h" -#include "Opcodes.h" #include "World.h" #include "ObjectMgr.h" #include "Player.h" diff --git a/src/server/game/Handlers/ReferAFriendHandler.cpp b/src/server/game/Handlers/ReferAFriendHandler.cpp index cf864772b7c..f87198834b9 100644 --- a/src/server/game/Handlers/ReferAFriendHandler.cpp +++ b/src/server/game/Handlers/ReferAFriendHandler.cpp @@ -18,7 +18,6 @@ #include "WorldSession.h" #include "Player.h" #include "ObjectMgr.h" -#include "Opcodes.h" #include "Log.h" void WorldSession::HandleGrantLevel(WorldPacket& recvData) diff --git a/src/server/game/Handlers/SkillHandler.cpp b/src/server/game/Handlers/SkillHandler.cpp index 6da2efa38a6..5f50a7305ee 100644 --- a/src/server/game/Handlers/SkillHandler.cpp +++ b/src/server/game/Handlers/SkillHandler.cpp @@ -19,7 +19,6 @@ #include "Common.h" #include "Log.h" #include "ObjectAccessor.h" -#include "Opcodes.h" #include "Player.h" #include "Pet.h" #include "WorldPacket.h" diff --git a/src/server/game/Handlers/TicketHandler.cpp b/src/server/game/Handlers/TicketHandler.cpp index 3ae9d6c8672..f3b421a4b93 100644 --- a/src/server/game/Handlers/TicketHandler.cpp +++ b/src/server/game/Handlers/TicketHandler.cpp @@ -24,7 +24,6 @@ #include "Player.h" #include "TicketMgr.h" #include "Util.h" -#include "World.h" #include "WorldPacket.h" #include "WorldSession.h" diff --git a/src/server/game/Handlers/TradeHandler.cpp b/src/server/game/Handlers/TradeHandler.cpp index 4f7e9f05725..c50888544de 100644 --- a/src/server/game/Handlers/TradeHandler.cpp +++ b/src/server/game/Handlers/TradeHandler.cpp @@ -22,7 +22,6 @@ #include "World.h" #include "ObjectAccessor.h" #include "Log.h" -#include "Opcodes.h" #include "Player.h" #include "Item.h" #include "Spell.h" diff --git a/src/server/game/Handlers/VehicleHandler.cpp b/src/server/game/Handlers/VehicleHandler.cpp index 6b9d64be91a..6328eb3e2fe 100644 --- a/src/server/game/Handlers/VehicleHandler.cpp +++ b/src/server/game/Handlers/VehicleHandler.cpp @@ -17,7 +17,6 @@ #include "WorldPacket.h" #include "WorldSession.h" -#include "Opcodes.h" #include "Vehicle.h" #include "Player.h" #include "Log.h" diff --git a/src/server/game/Handlers/VoiceChatHandler.cpp b/src/server/game/Handlers/VoiceChatHandler.cpp index 277755c6eb1..e667eb4bfd9 100644 --- a/src/server/game/Handlers/VoiceChatHandler.cpp +++ b/src/server/game/Handlers/VoiceChatHandler.cpp @@ -19,7 +19,6 @@ #include "Common.h" #include "WorldPacket.h" #include "WorldSession.h" -#include "Log.h" void WorldSession::HandleVoiceSessionEnableOpcode(WorldPacket& recvData) { diff --git a/src/server/game/Mails/Mail.cpp b/src/server/game/Mails/Mail.cpp index be0310017f7..e8eec55ed12 100644 --- a/src/server/game/Mails/Mail.cpp +++ b/src/server/game/Mails/Mail.cpp @@ -22,7 +22,6 @@ #include "World.h" #include "ObjectMgr.h" #include "Player.h" -#include "Unit.h" #include "BattlegroundMgr.h" #include "Item.h" #include "AuctionHouseMgr.h" diff --git a/src/server/game/Maps/MapUpdater.cpp b/src/server/game/Maps/MapUpdater.cpp index 46b2fb86596..20b8da796a5 100644 --- a/src/server/game/Maps/MapUpdater.cpp +++ b/src/server/game/Maps/MapUpdater.cpp @@ -16,12 +16,11 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include <mutex> -#include <condition_variable> - #include "MapUpdater.h" #include "Map.h" +#include <mutex> + class MapUpdateRequest { diff --git a/src/server/game/Movement/MovementGenerators/PointMovementGenerator.h b/src/server/game/Movement/MovementGenerators/PointMovementGenerator.h index f143e19b24b..5b1155507aa 100644 --- a/src/server/game/Movement/MovementGenerators/PointMovementGenerator.h +++ b/src/server/game/Movement/MovementGenerators/PointMovementGenerator.h @@ -36,7 +36,7 @@ class PointMovementGenerator : public MovementGeneratorMedium< T, PointMovementG void MovementInform(T*); - void unitSpeedChanged() { i_recalculateSpeed = true; } + void unitSpeedChanged() override { i_recalculateSpeed = true; } MovementGeneratorType GetMovementGeneratorType() const override { return POINT_MOTION_TYPE; } diff --git a/src/server/game/Movement/Spline/MoveSpline.cpp b/src/server/game/Movement/Spline/MoveSpline.cpp index 1beeebbbad3..ccf8824051b 100644 --- a/src/server/game/Movement/Spline/MoveSpline.cpp +++ b/src/server/game/Movement/Spline/MoveSpline.cpp @@ -17,10 +17,11 @@ */ #include "MoveSpline.h" -#include <sstream> #include "Log.h" #include "Creature.h" +#include <sstream> + namespace Movement{ Location MoveSpline::ComputePosition() const diff --git a/src/server/game/Scripting/MapScripts.cpp b/src/server/game/Scripting/MapScripts.cpp index 3beaa7daa9b..f5c4375712c 100644 --- a/src/server/game/Scripting/MapScripts.cpp +++ b/src/server/game/Scripting/MapScripts.cpp @@ -23,6 +23,7 @@ #include "Map.h" #include "ObjectMgr.h" #include "Pet.h" +#include "Item.h" #include "ScriptedCreature.h" #include "ScriptMgr.h" #include "Transport.h" diff --git a/src/server/game/Scripting/ScriptLoader.cpp b/src/server/game/Scripting/ScriptLoader.cpp index f0ee013bcc2..7c4b11769b5 100644 --- a/src/server/game/Scripting/ScriptLoader.cpp +++ b/src/server/game/Scripting/ScriptLoader.cpp @@ -360,7 +360,6 @@ void AddSC_orgrimmar(); void AddSC_silithus(); void AddSC_stonetalon_mountains(); void AddSC_tanaris(); -void AddSC_teldrassil(); void AddSC_the_barrens(); void AddSC_thousand_needles(); void AddSC_thunder_bluff(); @@ -1066,7 +1065,6 @@ void AddKalimdorScripts() AddSC_silithus(); AddSC_stonetalon_mountains(); AddSC_tanaris(); - AddSC_teldrassil(); AddSC_the_barrens(); AddSC_thousand_needles(); AddSC_thunder_bluff(); diff --git a/src/server/game/Server/Protocol/Opcodes.cpp b/src/server/game/Server/Protocol/Opcodes.cpp index 14ce4cfe3c1..4f7b8f510b0 100644 --- a/src/server/game/Server/Protocol/Opcodes.cpp +++ b/src/server/game/Server/Protocol/Opcodes.cpp @@ -1273,7 +1273,7 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x4DC*/ { "SMSG_PVP_QUEUE_STATS", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x4DD*/ { "CMSG_SET_PAID_SERVICE_CHEAT", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, /*0x4DE*/ { "SMSG_BATTLEFIELD_MGR_ENTRY_INVITE", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, - /*0x4DF*/ { "CMSG_BATTLEFIELD_MGR_ENTRY_INVITE_RESPONSE", STATUS_LOGGEDIN, PROCESS_INPLACE, &WorldSession::HandleBfEntryInviteResponse }, + /*0x4DF*/ { "CMSG_BATTLEFIELD_MGR_ENTRY_INVITE_RESPONSE", STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleBfEntryInviteResponse }, /*0x4E0*/ { "SMSG_BATTLEFIELD_MGR_ENTERED", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x4E1*/ { "SMSG_BATTLEFIELD_MGR_QUEUE_INVITE", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x4E2*/ { "CMSG_BATTLEFIELD_MGR_QUEUE_INVITE_RESPONSE", STATUS_LOGGEDIN, PROCESS_INPLACE, &WorldSession::HandleBfQueueInviteResponse }, diff --git a/src/server/game/Server/WorldSession.cpp b/src/server/game/Server/WorldSession.cpp index d6055e9733b..bb22d27221e 100644 --- a/src/server/game/Server/WorldSession.cpp +++ b/src/server/game/Server/WorldSession.cpp @@ -39,10 +39,12 @@ #include "BattlegroundMgr.h" #include "OutdoorPvPMgr.h" #include "SocialMgr.h" -#include "zlib.h" #include "ScriptMgr.h" #include "WardenWin.h" #include "MoveSpline.h" +#include "WardenMac.h" + +#include <zlib.h> namespace { diff --git a/src/server/game/Server/WorldSocket.cpp b/src/server/game/Server/WorldSocket.cpp index be70d67b4de..066a4e501be 100644 --- a/src/server/game/Server/WorldSocket.cpp +++ b/src/server/game/Server/WorldSocket.cpp @@ -19,10 +19,10 @@ #include "WorldSocket.h" #include "BigNumber.h" #include "Opcodes.h" -#include "Player.h" #include "ScriptMgr.h" #include "SHA1.h" #include "PacketLog.h" + #include <memory> using boost::asio::ip::tcp; diff --git a/src/server/game/Server/WorldSocketMgr.cpp b/src/server/game/Server/WorldSocketMgr.cpp index 86c09ef6b6b..da35017cc2b 100644 --- a/src/server/game/Server/WorldSocketMgr.cpp +++ b/src/server/game/Server/WorldSocketMgr.cpp @@ -21,6 +21,7 @@ #include "ScriptMgr.h" #include "WorldSocket.h" #include "WorldSocketMgr.h" + #include <boost/system/error_code.hpp> static void OnSocketAccept(tcp::socket&& sock) diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index 286cdf51bf1..9ba7a62e215 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -25,15 +25,15 @@ #include "Player.h" #include "Unit.h" #include "ObjectAccessor.h" +#include "CellImpl.h" #include "Util.h" #include "Spell.h" #include "SpellHistory.h" #include "SpellAuraEffects.h" #include "Battleground.h" #include "OutdoorPvPMgr.h" -#include "Formulas.h" #include "GridNotifiers.h" -#include "CellImpl.h" +#include "GridNotifiersImpl.h" #include "ScriptMgr.h" #include "Vehicle.h" #include "Battlefield.h" @@ -2799,7 +2799,7 @@ void AuraEffect::HandleModPossessPet(AuraApplication const* aurApp, uint8 mode, // return; Unit* target = aurApp->GetTarget(); - if (target->GetTypeId() != TYPEID_UNIT || !target->ToCreature()->IsPet()) + if (target->GetTypeId() != TYPEID_UNIT || !target->IsPet()) return; Pet* pet = target->ToPet(); @@ -3464,7 +3464,7 @@ void AuraEffect::HandleAuraModResistance(AuraApplication const* aurApp, uint8 mo if (GetMiscValue() & int32(1<<x)) { target->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + x), TOTAL_VALUE, float(GetAmount()), apply); - if (target->GetTypeId() == TYPEID_PLAYER || target->ToCreature()->IsPet()) + if (target->GetTypeId() == TYPEID_PLAYER || target->IsPet()) target->ApplyResistanceBuffModsMod(SpellSchools(x), GetAmount() > 0, (float)GetAmount(), apply); } } @@ -3481,7 +3481,7 @@ void AuraEffect::HandleAuraModBaseResistancePCT(AuraApplication const* aurApp, u if (target->GetTypeId() != TYPEID_PLAYER) { //pets only have base armor - if (target->ToCreature()->IsPet() && (GetMiscValue() & SPELL_SCHOOL_MASK_NORMAL)) + if (target->IsPet() && (GetMiscValue() & SPELL_SCHOOL_MASK_NORMAL)) target->HandleStatModifier(UNIT_MOD_ARMOR, BASE_PCT, float(GetAmount()), apply); } else @@ -3518,7 +3518,7 @@ void AuraEffect::HandleModResistancePercent(AuraApplication const* aurApp, uint8 } } target->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + i), TOTAL_PCT, float(GetAmount()), apply); - if (target->GetTypeId() == TYPEID_PLAYER || target->ToCreature()->IsPet()) + if (target->GetTypeId() == TYPEID_PLAYER || target->IsPet()) { target->ApplyResistanceBuffModsPercentMod(SpellSchools(i), true, (float)GetAmount(), apply); target->ApplyResistanceBuffModsPercentMod(SpellSchools(i), false, (float)GetAmount(), apply); @@ -3538,7 +3538,7 @@ void AuraEffect::HandleModBaseResistance(AuraApplication const* aurApp, uint8 mo if (target->GetTypeId() != TYPEID_PLAYER) { //only pets have base stats - if (target->ToCreature()->IsPet() && (GetMiscValue() & SPELL_SCHOOL_MASK_NORMAL)) + if (target->IsPet() && (GetMiscValue() & SPELL_SCHOOL_MASK_NORMAL)) target->HandleStatModifier(UNIT_MOD_ARMOR, TOTAL_VALUE, float(GetAmount()), apply); } else @@ -3595,13 +3595,13 @@ void AuraEffect::HandleAuraModStat(AuraApplication const* aurApp, uint8 mode, bo if (spellGroupVal) { target->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START + i), TOTAL_VALUE, float(spellGroupVal), !apply); - if (target->GetTypeId() == TYPEID_PLAYER || target->ToCreature()->IsPet()) + if (target->GetTypeId() == TYPEID_PLAYER || target->IsPet()) target->ApplyStatBuffMod(Stats(i), float(spellGroupVal), !apply); } //target->ApplyStatMod(Stats(i), m_amount, apply); target->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START + i), TOTAL_VALUE, float(GetAmount()), apply); - if (target->GetTypeId() == TYPEID_PLAYER || target->ToCreature()->IsPet()) + if (target->GetTypeId() == TYPEID_PLAYER || target->IsPet()) target->ApplyStatBuffMod(Stats(i), (float)GetAmount(), apply); } } @@ -3728,7 +3728,7 @@ void AuraEffect::HandleModTotalPercentStat(AuraApplication const* aurApp, uint8 if (GetMiscValue() == i || GetMiscValue() == -1) // affect the same stats { target->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START + i), TOTAL_PCT, float(spellGroupVal), !apply); - if (target->GetTypeId() == TYPEID_PLAYER || target->ToCreature()->IsPet()) + if (target->GetTypeId() == TYPEID_PLAYER || target->IsPet()) target->ApplyStatPercentBuffMod(Stats(i), float(spellGroupVal), !apply); } } @@ -3749,12 +3749,12 @@ void AuraEffect::HandleModTotalPercentStat(AuraApplication const* aurApp, uint8 if (spellGroupVal2) { target->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START + i), TOTAL_PCT, float(spellGroupVal2), !apply); - if (target->GetTypeId() == TYPEID_PLAYER || target->ToCreature()->IsPet()) + if (target->GetTypeId() == TYPEID_PLAYER || target->IsPet()) target->ApplyStatPercentBuffMod(Stats(i), float(spellGroupVal2), !apply); } target->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START + i), TOTAL_PCT, float(GetAmount()), apply); - if (target->GetTypeId() == TYPEID_PLAYER || target->ToCreature()->IsPet()) + if (target->GetTypeId() == TYPEID_PLAYER || target->IsPet()) target->ApplyStatPercentBuffMod(Stats(i), float(GetAmount()), apply); } } diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index cf460f938cc..03f14d1cdc8 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -728,7 +728,7 @@ void Spell::SelectExplicitTargets() { // check for explicit target redirection, for Grounding Totem for example if (m_spellInfo->GetExplicitTargetMask() & TARGET_FLAG_UNIT_ENEMY - || (m_spellInfo->GetExplicitTargetMask() & TARGET_FLAG_UNIT && !m_spellInfo->IsPositive())) + || (m_spellInfo->GetExplicitTargetMask() & TARGET_FLAG_UNIT && !m_caster->IsFriendlyTo(target))) { Unit* redirect; switch (m_spellInfo->DmgClass) @@ -1415,7 +1415,7 @@ void Spell::SelectImplicitCasterObjectTargets(SpellEffIndex effIndex, SpellImpli case TARGET_UNIT_PASSENGER_5: case TARGET_UNIT_PASSENGER_6: case TARGET_UNIT_PASSENGER_7: - if (m_caster->GetTypeId() == TYPEID_UNIT && m_caster->ToCreature()->IsVehicle()) + if (m_caster->GetTypeId() == TYPEID_UNIT && m_caster->IsVehicle()) target = m_caster->GetVehicleKit()->GetPassenger(targetType.GetTarget() - TARGET_UNIT_PASSENGER_0); break; default: @@ -1995,7 +1995,7 @@ void Spell::prepareDataForTriggerSystem(AuraEffect const* /*triggeredByAura*/) m_procEx |= PROC_EX_INTERNAL_TRIGGERED; } // Totem casts require spellfamilymask defined in spell_proc_event to proc - if (m_originalCaster && m_caster != m_originalCaster && m_caster->GetTypeId() == TYPEID_UNIT && m_caster->ToCreature()->IsTotem() && m_caster->IsControlledByPlayer()) + if (m_originalCaster && m_caster != m_originalCaster && m_caster->GetTypeId() == TYPEID_UNIT && m_caster->IsTotem() && m_caster->IsControlledByPlayer()) m_procEx |= PROC_EX_INTERNAL_REQ_FAMILY; } @@ -3550,7 +3550,7 @@ void Spell::finish(bool ok) if (!ok) return; - if (m_caster->GetTypeId() == TYPEID_UNIT && m_caster->ToCreature()->IsSummon()) + if (m_caster->GetTypeId() == TYPEID_UNIT && m_caster->IsSummon()) { // Unsummon statue uint32 spell = m_caster->GetUInt32Value(UNIT_CREATED_BY_SPELL); @@ -3773,7 +3773,7 @@ void Spell::SendSpellStart() if (m_spellInfo->HasAttribute(SPELL_ATTR0_REQ_AMMO)) castFlags |= CAST_FLAG_AMMO; if ((m_caster->GetTypeId() == TYPEID_PLAYER || - (m_caster->GetTypeId() == TYPEID_UNIT && m_caster->ToCreature()->IsPet())) + (m_caster->GetTypeId() == TYPEID_UNIT && m_caster->IsPet())) && m_spellInfo->PowerType != POWER_HEALTH) castFlags |= CAST_FLAG_POWER_LEFT_SELF; @@ -3827,7 +3827,7 @@ void Spell::SendSpellGo() castFlags |= CAST_FLAG_AMMO; // arrows/bullets visual if ((m_caster->GetTypeId() == TYPEID_PLAYER || - (m_caster->GetTypeId() == TYPEID_UNIT && m_caster->ToCreature()->IsPet())) + (m_caster->GetTypeId() == TYPEID_UNIT && m_caster->IsPet())) && m_spellInfo->PowerType != POWER_HEALTH) castFlags |= CAST_FLAG_POWER_LEFT_SELF; // should only be sent to self, but the current messaging doesn't make that possible @@ -5096,12 +5096,13 @@ SpellCastResult Spell::CheckCast(bool strict) m_preGeneratedPath.SetPathLengthLimit(range); // first try with raycast, if it fails fall back to normal path - bool result = m_preGeneratedPath.CalculatePath(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ() + target->GetObjectSize() / 2.f, false, true); + float targetObjectSize = std::min(target->GetObjectSize(), 4.0f); + bool result = m_preGeneratedPath.CalculatePath(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ() + targetObjectSize, false, true); if (m_preGeneratedPath.GetPathType() & PATHFIND_SHORT) return SPELL_FAILED_OUT_OF_RANGE; else if (!result || m_preGeneratedPath.GetPathType() & (PATHFIND_NOPATH | PATHFIND_INCOMPLETE)) { - result = m_preGeneratedPath.CalculatePath(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ() + target->GetObjectSize() / 2.f, false, false); + result = m_preGeneratedPath.CalculatePath(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ() + targetObjectSize, false, false); if (m_preGeneratedPath.GetPathType() & PATHFIND_SHORT) return SPELL_FAILED_OUT_OF_RANGE; else if (!result || m_preGeneratedPath.GetPathType() & (PATHFIND_NOPATH | PATHFIND_INCOMPLETE)) @@ -5386,7 +5387,7 @@ SpellCastResult Spell::CheckCast(bool strict) if (Unit* target = m_targets.GetUnitTarget()) { - if (target->GetTypeId() == TYPEID_UNIT && target->ToCreature()->IsVehicle()) + if (target->GetTypeId() == TYPEID_UNIT && target->IsVehicle()) return SPELL_FAILED_BAD_IMPLICIT_TARGETS; if (target->IsMounted()) diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index 69607b43785..91eb7330dda 100644 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -441,7 +441,7 @@ void Spell::EffectSchoolDMG(SpellEffIndex effIndex) // Shadow Bite else if (m_spellInfo->SpellFamilyFlags[1] & 0x400000) { - if (m_caster->GetTypeId() == TYPEID_UNIT && m_caster->ToCreature()->IsPet()) + if (m_caster->GetTypeId() == TYPEID_UNIT && m_caster->IsPet()) { if (Player* owner = m_caster->GetOwner()->ToPlayer()) { @@ -2981,7 +2981,7 @@ void Spell::EffectSummonPet(SpellEffIndex effIndex) if (m_originalCaster) { owner = m_originalCaster->ToPlayer(); - if (!owner && m_originalCaster->ToCreature()->IsTotem()) + if (!owner && m_originalCaster->IsTotem()) owner = m_originalCaster->GetCharmerOrOwnerPlayerOrPlayerItself(); } @@ -3038,7 +3038,7 @@ void Spell::EffectSummonPet(SpellEffIndex effIndex) if (m_caster->GetTypeId() == TYPEID_UNIT) { - if (m_caster->ToCreature()->IsTotem()) + if (m_caster->IsTotem()) pet->SetReactState(REACT_AGGRESSIVE); else pet->SetReactState(REACT_DEFENSIVE); @@ -3868,7 +3868,7 @@ void Spell::EffectScriptEffect(SpellEffIndex effIndex) } case 52173: // Coyote Spirit Despawn case 60243: // Blood Parrot Despawn - if (unitTarget->GetTypeId() == TYPEID_UNIT && unitTarget->ToCreature()->IsSummon()) + if (unitTarget->GetTypeId() == TYPEID_UNIT && unitTarget->IsSummon()) unitTarget->ToTempSummon()->UnSummon(); return; case 52479: // Gift of the Harvester @@ -3963,7 +3963,7 @@ void Spell::EffectScriptEffect(SpellEffIndex effIndex) } case 60123: // Lightwell { - if (m_caster->GetTypeId() != TYPEID_UNIT || !m_caster->ToCreature()->IsSummon()) + if (m_caster->GetTypeId() != TYPEID_UNIT || !m_caster->IsSummon()) return; uint32 spell_heal; @@ -5718,7 +5718,7 @@ void Spell::EffectRenamePet(SpellEffIndex /*effIndex*/) return; if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT || - !unitTarget->ToCreature()->IsPet() || ((Pet*)unitTarget)->getPetType() != HUNTER_PET) + !unitTarget->IsPet() || ((Pet*)unitTarget)->getPetType() != HUNTER_PET) return; unitTarget->SetByteFlag(UNIT_FIELD_BYTES_2, 2, UNIT_CAN_BE_RENAMED); diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp index 54262d8f2e4..d9f24a9010a 100644 --- a/src/server/game/Spells/SpellMgr.cpp +++ b/src/server/game/Spells/SpellMgr.cpp @@ -3147,6 +3147,11 @@ void SpellMgr::LoadSpellInfoCorrections() case 28200: // Ascendance (Talisman of Ascendance trinket) spellInfo->ProcCharges = 6; break; + case 49224: // Magic Suppression - DK + case 49610: // Magic Suppression - DK + case 49611: // Magic Suppression - DK + spellInfo->ProcCharges = 0; + break; case 37408: // Oscillation Field spellInfo->AttributesEx3 |= SPELL_ATTR3_STACK_FOR_DIFF_CASTERS; break; @@ -3515,6 +3520,13 @@ void SpellMgr::LoadSpellInfoCorrections() case 71415: // Orange Ooze Summon (Professor Putricide) spellInfo->Effects[EFFECT_0].TargetA = SpellImplicitTargetInfo(TARGET_UNIT_TARGET_ANY); break; + case 69783: // Ooze flood + case 69797: // Ooze flood + case 69799: // Ooze flood + case 69802: // Ooze flood + // Those spells are cast on creatures with same entry as caster while they have TARGET_UNIT_NEARBY_ENTRY. + spellInfo->AttributesEx |= SPELL_ATTR1_CANT_TARGET_SELF; + break; case 71159: // Awaken Plagued Zombies spellInfo->DurationEntry = sSpellDurationStore.LookupEntry(21); break; diff --git a/src/server/game/Spells/SpellScript.cpp b/src/server/game/Spells/SpellScript.cpp index 0b178b62825..95857be27dc 100644 --- a/src/server/game/Spells/SpellScript.cpp +++ b/src/server/game/Spells/SpellScript.cpp @@ -15,10 +15,11 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include <string> #include "Spell.h" #include "SpellAuras.h" #include "SpellScript.h" +#include "SpellMgr.h" +#include <string> bool _SpellScript::_Validate(SpellInfo const* entry) { diff --git a/src/server/game/Warden/Warden.cpp b/src/server/game/Warden/Warden.cpp index ecf7697db0d..69facc6895b 100644 --- a/src/server/game/Warden/Warden.cpp +++ b/src/server/game/Warden/Warden.cpp @@ -22,12 +22,13 @@ #include "Log.h" #include "Opcodes.h" #include "ByteBuffer.h" -#include <openssl/sha.h> #include "World.h" #include "Util.h" #include "Warden.h" #include "AccountMgr.h" +#include <openssl/sha.h> + Warden::Warden() : _session(NULL), _inputCrypto(16), _outputCrypto(16), _checkTimer(10000/*10 sec*/), _clientResponseTimer(0), _dataSent(false), _previousTimestamp(0), _module(NULL), _initialized(false) { diff --git a/src/server/game/Warden/WardenMac.cpp b/src/server/game/Warden/WardenMac.cpp index 2eccd4c46ff..8abd48bd3f7 100644 --- a/src/server/game/Warden/WardenMac.cpp +++ b/src/server/game/Warden/WardenMac.cpp @@ -23,13 +23,14 @@ #include "Log.h" #include "Opcodes.h" #include "ByteBuffer.h" -#include <openssl/md5.h> #include "World.h" #include "Player.h" #include "Util.h" #include "WardenMac.h" #include "WardenModuleMac.h" +#include <openssl/md5.h> + WardenMac::WardenMac() : Warden() { } WardenMac::~WardenMac() { } diff --git a/src/server/game/Warden/WardenWin.cpp b/src/server/game/Warden/WardenWin.cpp index 7db5e8f39e5..2fe11a7eeed 100644 --- a/src/server/game/Warden/WardenWin.cpp +++ b/src/server/game/Warden/WardenWin.cpp @@ -24,7 +24,6 @@ #include "Log.h" #include "Opcodes.h" #include "ByteBuffer.h" -#include <openssl/md5.h> #include "Database/DatabaseEnv.h" #include "World.h" #include "Player.h" @@ -32,6 +31,7 @@ #include "WardenWin.h" #include "WardenModuleWin.h" #include "WardenCheckMgr.h" +#include <openssl/md5.h> WardenWin::WardenWin() : Warden(), _serverTicks(0) {} diff --git a/src/server/game/Weather/WeatherMgr.cpp b/src/server/game/Weather/WeatherMgr.cpp index 9100dd464b9..64775a05faa 100644 --- a/src/server/game/Weather/WeatherMgr.cpp +++ b/src/server/game/Weather/WeatherMgr.cpp @@ -25,7 +25,6 @@ #include "Log.h" #include "ObjectMgr.h" #include "Player.h" -#include "WorldPacket.h" #include "WorldSession.h" namespace WeatherMgr diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp index fc79f351a54..9c4cb1002c7 100644 --- a/src/server/game/World/World.cpp +++ b/src/server/game/World/World.cpp @@ -1299,7 +1299,7 @@ void World::LoadConfigSettings(bool reload) sScriptMgr->OnConfigLoad(reload); } -extern void LoadGameObjectModelList(); +extern void LoadGameObjectModelList(std::string const& dataPath); /// Initialize the World void World::SetInitialWorldSettings() @@ -1399,7 +1399,7 @@ void World::SetInitialWorldSettings() sSpellMgr->LoadSpellInfoCustomAttributes(); TC_LOG_INFO("server.loading", "Loading GameObject models..."); - LoadGameObjectModelList(); + LoadGameObjectModelList(m_dataPath); TC_LOG_INFO("server.loading", "Loading Script Names..."); sObjectMgr->LoadScriptNames(); diff --git a/src/server/scripts/Commands/cs_modify.cpp b/src/server/scripts/Commands/cs_modify.cpp index 54d1f314140..9fd0260ed2e 100644 --- a/src/server/scripts/Commands/cs_modify.cpp +++ b/src/server/scripts/Commands/cs_modify.cpp @@ -421,7 +421,7 @@ public: target->ToPlayer()->SendTalentsInfoData(false); return true; } - else if (target->ToCreature()->IsPet()) + else if (target->IsPet()) { Unit* owner = target->GetOwner(); if (owner && owner->GetTypeId() == TYPEID_PLAYER && ((Pet*)target)->IsPermanentPetFor(owner->ToPlayer())) diff --git a/src/server/scripts/EasternKingdoms/ZulAman/instance_zulaman.cpp b/src/server/scripts/EasternKingdoms/ZulAman/instance_zulaman.cpp index b3ad89b08f8..f6622ffe1f4 100644 --- a/src/server/scripts/EasternKingdoms/ZulAman/instance_zulaman.cpp +++ b/src/server/scripts/EasternKingdoms/ZulAman/instance_zulaman.cpp @@ -113,7 +113,7 @@ class instance_zulaman : public InstanceMapScript return false; } - void OnPlayerEnter(Player* /*player*/) + void OnPlayerEnter(Player* /*player*/) override { if (!HarrisonJonesGUID) instance->SummonCreature(NPC_HARRISON_JONES, HarrisonJonesLoc); @@ -197,7 +197,7 @@ class instance_zulaman : public InstanceMapScript return ss.str(); } - void Load(const char* load) + void Load(const char* load) override { if (!load) return; diff --git a/src/server/scripts/EasternKingdoms/zone_hinterlands.cpp b/src/server/scripts/EasternKingdoms/zone_hinterlands.cpp index 5b63c509eaa..de2bcc5561e 100644 --- a/src/server/scripts/EasternKingdoms/zone_hinterlands.cpp +++ b/src/server/scripts/EasternKingdoms/zone_hinterlands.cpp @@ -235,7 +235,7 @@ public: summoned->GetMotionMaster()->MovePoint(0, AmbushMoveTo[spawnId]); } - void sQuestAccept(Player* player, Quest const* quest) + void sQuestAccept(Player* player, Quest const* quest) override { if (quest->GetQuestId() == QUEST_RINJI_TRAPPED) { diff --git a/src/server/scripts/EasternKingdoms/zone_redridge_mountains.cpp b/src/server/scripts/EasternKingdoms/zone_redridge_mountains.cpp index ecfd705cf4d..607b449552f 100644 --- a/src/server/scripts/EasternKingdoms/zone_redridge_mountains.cpp +++ b/src/server/scripts/EasternKingdoms/zone_redridge_mountains.cpp @@ -63,11 +63,12 @@ public: Initialize(); } - void sQuestAccept(Player* player, Quest const* quest) + void sQuestAccept(Player* player, Quest const* quest) override { if (quest->GetQuestId() == QUEST_MISSING_IN_ACTION) { Talk(SAY_CORPORAL_1, player); + me->setFaction(250); npc_escortAI::Start(true, false, player->GetGUID(), quest); } } diff --git a/src/server/scripts/EasternKingdoms/zone_swamp_of_sorrows.cpp b/src/server/scripts/EasternKingdoms/zone_swamp_of_sorrows.cpp index 5707ebbf734..b162b4f4d75 100644 --- a/src/server/scripts/EasternKingdoms/zone_swamp_of_sorrows.cpp +++ b/src/server/scripts/EasternKingdoms/zone_swamp_of_sorrows.cpp @@ -61,7 +61,7 @@ public: Talk(SAY_ATTACKED, who); } - void sQuestAccept(Player* player, Quest const* quest) + void sQuestAccept(Player* player, Quest const* quest) override { if (quest->GetQuestId() == QUEST_GALENS_ESCAPE) { diff --git a/src/server/scripts/Kalimdor/CMakeLists.txt b/src/server/scripts/Kalimdor/CMakeLists.txt index ce8d0cfbcfd..f74b809c814 100644 --- a/src/server/scripts/Kalimdor/CMakeLists.txt +++ b/src/server/scripts/Kalimdor/CMakeLists.txt @@ -111,7 +111,6 @@ set(scripts_STAT_SRCS Kalimdor/zone_winterspring.cpp Kalimdor/zone_thousand_needles.cpp Kalimdor/zone_ashenvale.cpp - Kalimdor/zone_teldrassil.cpp Kalimdor/OnyxiasLair/boss_onyxia.cpp Kalimdor/OnyxiasLair/onyxias_lair.h Kalimdor/OnyxiasLair/instance_onyxias_lair.cpp diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_kazrogal.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_kazrogal.cpp index b897eb4464a..12e0ae8d194 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_kazrogal.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_kazrogal.cpp @@ -229,7 +229,7 @@ class spell_mark_of_kazrogal : public SpellScriptLoader } }; - SpellScript* GetSpellScript() const + SpellScript* GetSpellScript() const override { return new spell_mark_of_kazrogal_SpellScript(); } diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_skeram.cpp b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_skeram.cpp index 7238760822b..05ec05873f5 100644 --- a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_skeram.cpp +++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_skeram.cpp @@ -208,11 +208,13 @@ class PlayerOrPetCheck public: bool operator()(WorldObject* object) const { - if (object->GetTypeId() != TYPEID_PLAYER) - if (!object->ToCreature()->IsPet()) - return true; + if (object->GetTypeId() == TYPEID_PLAYER) + return false; - return false; + if (Creature* creature = object->ToCreature()) + return !creature->IsPet(); + + return true; } }; diff --git a/src/server/scripts/Kalimdor/zone_teldrassil.cpp b/src/server/scripts/Kalimdor/zone_teldrassil.cpp deleted file mode 100644 index 2173cd6de06..00000000000 --- a/src/server/scripts/Kalimdor/zone_teldrassil.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (C) 2008-2015 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: Teldrassil -SD%Complete: 100 -SDComment: Quest support: 938 -SDCategory: Teldrassil -EndScriptData */ - -/* ContentData -npc_mist -EndContentData */ - -#include "ScriptMgr.h" -#include "ScriptedCreature.h" -#include "ScriptedFollowerAI.h" -#include "Player.h" - -/*#### -# npc_mist -####*/ - -enum Mist -{ - SAY_AT_HOME = 0, - EMOTE_AT_HOME = 1, - QUEST_MIST = 938, - NPC_ARYNIA = 3519, - FACTION_DARNASSUS = 79 -}; - -class npc_mist : public CreatureScript -{ -public: - npc_mist() : CreatureScript("npc_mist") { } - - bool OnQuestAccept(Player* player, Creature* creature, Quest const* quest) override - { - if (quest->GetQuestId() == QUEST_MIST) - if (npc_mistAI* pMistAI = CAST_AI(npc_mist::npc_mistAI, creature->AI())) - pMistAI->StartFollow(player, FACTION_DARNASSUS, quest); - - return true; - } - - CreatureAI* GetAI(Creature* creature) const override - { - return new npc_mistAI(creature); - } - - struct npc_mistAI : public FollowerAI - { - npc_mistAI(Creature* creature) : FollowerAI(creature) { } - - void Reset() override { } - - void MoveInLineOfSight(Unit* who) override - - { - FollowerAI::MoveInLineOfSight(who); - - if (!me->GetVictim() && !HasFollowState(STATE_FOLLOW_COMPLETE) && who->GetEntry() == NPC_ARYNIA) - { - if (me->IsWithinDistInMap(who, 10.0f)) - { - Talk(SAY_AT_HOME, who); - DoComplete(); - } - } - } - - void DoComplete() - { - Talk(EMOTE_AT_HOME); - - Player* player = GetLeaderForFollower(); - if (player && player->GetQuestStatus(QUEST_MIST) == QUEST_STATUS_INCOMPLETE) - player->GroupEventHappens(QUEST_MIST, me); - - //The follow is over (and for later development, run off to the woods before really end) - SetFollowComplete(); - } - - //call not needed here, no known abilities - /*void UpdateFollowerAI(const uint32 Diff) override - { - if (!UpdateVictim()) - return; - - DoMeleeAttackIfReady(); - }*/ - }; - -}; - -void AddSC_teldrassil() -{ - new npc_mist(); -} diff --git a/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_halion.cpp b/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_halion.cpp index 434028ab255..0b8fa7459a8 100644 --- a/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_halion.cpp +++ b/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_halion.cpp @@ -105,7 +105,7 @@ enum Spells SPELL_LEAVE_TWILIGHT_REALM = 74812, SPELL_TWILIGHT_PHASING = 74808, // Phase spell from phase 1 to phase 2 SPELL_SUMMON_TWILIGHT_PORTAL = 74809, // Summons go 202794 - SPELL_SUMMON_EXIT_PORTALS = 74805, // Custom spell created in spell_dbc. + SPELL_SUMMON_EXIT_PORTALS = 74805, // Custom spell created in spell_dbc. // Used in Cataclysm, need a sniff of cata and up SPELL_TWILIGHT_MENDING = 75509, SPELL_TWILIGHT_REALM = 74807, SPELL_DUSK_SHROUD = 75476, @@ -124,20 +124,20 @@ enum Events EVENT_TAIL_LASH = 6, // Twilight Halion - EVENT_SOUL_CONSUMPTION = 8, + EVENT_SOUL_CONSUMPTION = 7, // Meteor Strike - EVENT_SPAWN_METEOR_FLAME = 9, + EVENT_SPAWN_METEOR_FLAME = 8, // Halion Controller - EVENT_START_INTRO = 10, - EVENT_INTRO_PROGRESS_1 = 11, - EVENT_INTRO_PROGRESS_2 = 12, - EVENT_INTRO_PROGRESS_3 = 13, - EVENT_CHECK_CORPOREALITY = 14, - EVENT_SHADOW_PULSARS_SHOOT = 15, - EVENT_TRIGGER_BERSERK = 16, - EVENT_TWILIGHT_MENDING = 17, + EVENT_START_INTRO = 9, + EVENT_INTRO_PROGRESS_1 = 10, + EVENT_INTRO_PROGRESS_2 = 11, + EVENT_INTRO_PROGRESS_3 = 12, + EVENT_CHECK_CORPOREALITY = 13, + EVENT_SHADOW_PULSARS_SHOOT = 14, + EVENT_TRIGGER_BERSERK = 15, + EVENT_TWILIGHT_MENDING = 16 }; enum Actions @@ -150,13 +150,7 @@ enum Actions ACTION_MONITOR_CORPOREALITY = 3, // Orb Carrier - ACTION_SHOOT = 4, - - // Living Inferno - ACTION_SUMMON_LIVING_EMBERS = 5, - - // Meteor Flame - ACTION_SUMMON_FLAME = 6 + ACTION_SHOOT = 4 }; enum Phases @@ -1006,8 +1000,7 @@ class npc_meteor_strike_initial : public CreatureScript if (HalionAI* halionAI = CAST_AI(HalionAI, owner->AI())) { Position const* ownerPos = halionAI->GetMeteorStrikePosition(); - // Adjust randomness between 0 and pi. - float randomAdjustment = frand(static_cast<float>(M_PI / 14), static_cast<float>(13 * M_PI / 14)); + float randomAdjustment = frand(0.0f, static_cast<float>(M_PI / 5.0f)); float angle[4]; angle[0] = me->GetAngle(ownerPos); angle[1] = angle[0] + randomAdjustment; @@ -1088,16 +1081,12 @@ class npc_meteor_strike : public CreatureScript void UpdateAI(uint32 diff) override { _events.Update(diff); + if (_events.ExecuteEvent() == EVENT_SPAWN_METEOR_FLAME) { - Position pos = me->GetNearPosition(5.0f, 0.0f); + Position pos = me->GetNearPosition(5.0f, frand(-static_cast<float>(M_PI / 6.0f), static_cast<float>(M_PI / 6.0f))); if (Creature* flame = me->SummonCreature(NPC_METEOR_STRIKE_FLAME, pos, TEMPSUMMON_TIMED_DESPAWN, 25000)) - { - flame->SetOrientation(me->GetOrientation()); - - flame->AI()->SetGUID(GetGUID()); - flame->AI()->DoAction(ACTION_SUMMON_FLAME); - } + flame->AI()->SetGUID(me->GetGUID()); } } @@ -1129,43 +1118,43 @@ class npc_meteor_strike_flame : public CreatureScript void SetGUID(ObjectGuid guid, int32 /*id = 0 */) override { _rootOwnerGuid = guid; + _events.ScheduleEvent(EVENT_SPAWN_METEOR_FLAME, 800); } - void DoAction(int32 action) override + void IsSummonedBy(Unit* /*summoner*/) override + { + // Let Halion Controller count as summoner. + if (Creature* controller = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_HALION_CONTROLLER))) + controller->AI()->JustSummoned(me); + } + + void UpdateAI(uint32 diff) override { - if (action != ACTION_SUMMON_FLAME || _rootOwnerGuid.IsEmpty()) + _events.Update(diff); + if (_events.ExecuteEvent() != EVENT_SPAWN_METEOR_FLAME) return; me->CastSpell(me, SPELL_METEOR_STRIKE_FIRE_AURA_2, true); Creature* meteorStrike = ObjectAccessor::GetCreature(*me, _rootOwnerGuid); - if (!meteorStrike || meteorStrike->AI()->GetData(DATA_SPAWNED_FLAMES) > 5) + if (!meteorStrike) return; - me->SetOrientation(me->GetOrientation() + frand(static_cast<float>(-M_PI / 16), static_cast<float>(M_PI / 16))); - Position pos = me->GetNearPosition(5.0f, 0.0f); + meteorStrike->AI()->SetData(DATA_SPAWNED_FLAMES, 1); + if (meteorStrike->AI()->GetData(DATA_SPAWNED_FLAMES) > 5) + return; + Position pos = me->GetNearPosition(5.0f, frand(-static_cast<float>(M_PI / 6.0f), static_cast<float>(M_PI / 6.0f))); if (Creature* flame = me->SummonCreature(NPC_METEOR_STRIKE_FLAME, pos, TEMPSUMMON_TIMED_DESPAWN, 25000)) - { flame->AI()->SetGUID(_rootOwnerGuid); - meteorStrike->AI()->SetData(DATA_SPAWNED_FLAMES, 1); - } - } - - void IsSummonedBy(Unit* /*summoner*/) override - { - // Let Halion Controller count as summoner. - if (Creature* controller = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_HALION_CONTROLLER))) - controller->AI()->JustSummoned(me); } - void UpdateAI(uint32 /*diff*/) override { } void EnterEvadeMode() override { } private: InstanceScript* _instance; EventMap _events; - ObjectGuid _rootOwnerGuid = ObjectGuid::Empty; + ObjectGuid _rootOwnerGuid; }; CreatureAI* GetAI(Creature* creature) const override @@ -1362,7 +1351,7 @@ class go_twilight_portal : public GameObjectScript _spellId = gameobject->GetGOInfo()->goober.spellId; break; case GO_HALION_PORTAL_1: - case GO_HALION_PORTAL_2: // Not used, not seen in sniffs. Just in case. + case GO_HALION_PORTAL_2: gameobject->SetPhaseMask(0x1, true); /// Because WDB template has non-existent spell ID, not seen in sniffs either, meh _spellId = SPELL_TWILIGHT_REALM; diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp index d7a580800bc..be134a06173 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp @@ -205,7 +205,7 @@ struct RotfaceHeightCheck bool operator()(Creature* stalker) const { - return stalker->GetPositionZ() < _rotface->GetPositionZ() + 5.0f; + return stalker->GetPositionZ() > _rotface->GetPositionZ() + 5.0f; } private: diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_rotface.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_rotface.cpp index d56a3f80f75..c1d930cb62c 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_rotface.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_rotface.cpp @@ -480,8 +480,8 @@ class spell_rotface_ooze_flood : public SpellScriptLoader targets.sort(Trinity::ObjectDistanceOrderPred(GetCaster())); // .resize() runs pop_back(); - if (targets.size() > 4) - targets.resize(4); + if (targets.size() > 5) + targets.resize(5); while (targets.size() > 2) targets.pop_front(); diff --git a/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp b/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp index ff1ba5ee9b1..cc9af9413e5 100644 --- a/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp +++ b/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp @@ -1485,7 +1485,7 @@ public: creature->AI()->SetGUID(me->GetGUID(), DATA_LAST_OVERLOAD_GUID); } - void UpdateAI(uint32 /*diff*/) + void UpdateAI(uint32 /*diff*/) override { } diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_freya.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_freya.cpp index 2228a860e0d..05bdb568a2e 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_freya.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_freya.cpp @@ -594,8 +594,8 @@ class boss_freya : public CreatureScript const uint32 summonSpell[2][4] = { /* 0Elder, 1Elder, 2Elder, 3Elder */ - /* 10N */ {62950, 62953, 62955, 62957}, - /* 25N */ {62952, 62954, 62956, 62958} + /* 10N */ {62950, 62952, 62953, 62954}, + /* 25N */ {62955, 62956, 62957, 62958} }; me->CastSpell((Unit*)NULL, summonSpell[me->GetMap()->GetDifficulty()][elderCount], true); diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_mimiron.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_mimiron.cpp index 3c068915585..bd4fee60c42 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_mimiron.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_mimiron.cpp @@ -120,7 +120,7 @@ enum Spells SPELL_SUMMON_ROCKET_STRIKE = 63036, SPELL_SCRIPT_EFFECT_ROCKET_STRIKE = 63681, // Cast by Rocket (Mimiron Visual) SPELL_ROCKET_STRIKE = 64064, // Added in creature_template_addon - SPELL_ROCKET_STRIKE_LEFT = 64402, // Cast by VX-001 + SPELL_ROCKET_STRIKE_SINGLE = 64402, // Cast by VX-001 SPELL_ROCKET_STRIKE_BOTH = 65034, // Cast by VX-001 // Flames @@ -320,6 +320,12 @@ enum Waypoints WP_AERIAL_P4_POS }; +enum SeatIds : int8 +{ + ROCKET_SEAT_LEFT = 5, + ROCKET_SEAT_RIGHT = 6 +}; + uint32 const RepairSpells[4] = { SPELL_SEAT_1, @@ -1043,18 +1049,18 @@ class boss_vx_001 : public CreatureScript events.RescheduleEvent(EVENT_RAPID_BURST, 3000, 0, PHASE_VX_001); break; case EVENT_ROCKET_STRIKE: - DoCastAOE(events.IsInPhase(PHASE_VX_001) ? SPELL_ROCKET_STRIKE_LEFT : SPELL_ROCKET_STRIKE_BOTH); + DoCastAOE(events.IsInPhase(PHASE_VX_001) ? SPELL_ROCKET_STRIKE_SINGLE : SPELL_ROCKET_STRIKE_BOTH); events.ScheduleEvent(EVENT_RELOAD, 10000); events.RescheduleEvent(EVENT_ROCKET_STRIKE, urand(20000, 25000)); break; case EVENT_RELOAD: - for (uint8 seat = 6; seat <= 7; seat++) + for (int8 seat = ROCKET_SEAT_LEFT; seat <= ROCKET_SEAT_RIGHT; ++seat) if (Unit* rocket = me->GetVehicleKit()->GetPassenger(seat)) rocket->SetDisplayId(rocket->GetNativeDisplayId()); break; case EVENT_HAND_PULSE: if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 120, true)) - DoCast(target, urand(0, 1) == 0 ? SPELL_HAND_PULSE_LEFT : SPELL_HAND_PULSE_RIGHT); + DoCast(target, RAND(SPELL_HAND_PULSE_LEFT, SPELL_HAND_PULSE_RIGHT)); events.RescheduleEvent(EVENT_HAND_PULSE, urand(1500, 3000), 0, PHASE_VOL7RON); break; case EVENT_FROST_BOMB: @@ -2187,8 +2193,8 @@ class spell_mimiron_rocket_strike : public SpellScriptLoader if (targets.empty()) return; - if (m_scriptSpellId == SPELL_ROCKET_STRIKE_LEFT && GetCaster()->IsVehicle()) - if (WorldObject* target = GetCaster()->GetVehicleKit()->GetPassenger(6)) + if (m_scriptSpellId == SPELL_ROCKET_STRIKE_SINGLE && GetCaster()->IsVehicle()) + if (WorldObject* target = GetCaster()->GetVehicleKit()->GetPassenger(RAND(ROCKET_SEAT_LEFT, ROCKET_SEAT_RIGHT))) { targets.clear(); targets.push_back(target); diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/ulduar.h b/src/server/scripts/Northrend/Ulduar/Ulduar/ulduar.h index 2d10ffc01bc..9f640c410ef 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/ulduar.h +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/ulduar.h @@ -425,11 +425,13 @@ class PlayerOrPetCheck public: bool operator()(WorldObject* object) const { - if (object->GetTypeId() != TYPEID_PLAYER) - if (!object->ToCreature()->IsPet()) - return true; + if (object->GetTypeId() == TYPEID_PLAYER) + return false; - return false; + if (Creature* creature = object->ToCreature()) + return !creature->IsPet(); + + return true; } }; diff --git a/src/server/scripts/OutdoorPvP/OutdoorPvPZM.h b/src/server/scripts/OutdoorPvP/OutdoorPvPZM.h index 9c76b35937e..a07905b3ae6 100644 --- a/src/server/scripts/OutdoorPvP/OutdoorPvPZM.h +++ b/src/server/scripts/OutdoorPvP/OutdoorPvPZM.h @@ -188,7 +188,7 @@ class OPvPCapturePointZM_GraveYard : public OPvPCapturePoint void ChangeState() override { } - void FillInitialWorldStates(WorldPacket & data); + void FillInitialWorldStates(WorldPacket & data) override; void UpdateTowerState(); diff --git a/src/server/scripts/Spells/spell_hunter.cpp b/src/server/scripts/Spells/spell_hunter.cpp index 450dade68f8..f2871871c30 100644 --- a/src/server/scripts/Spells/spell_hunter.cpp +++ b/src/server/scripts/Spells/spell_hunter.cpp @@ -640,6 +640,45 @@ class spell_hun_pet_heart_of_the_phoenix : public SpellScriptLoader } }; +// 56654, 58882 - Rapid Recuperation +class spell_hun_rapid_recuperation : public SpellScriptLoader +{ + public: + spell_hun_rapid_recuperation() : SpellScriptLoader("spell_hun_rapid_recuperation") { } + + class spell_hun_rapid_recuperation_AuraScript : public AuraScript + { + PrepareAuraScript(spell_hun_rapid_recuperation_AuraScript); + + bool Validate(SpellInfo const* spellInfo) override + { + if (!sSpellMgr->GetSpellInfo(spellInfo->Effects[EFFECT_0].TriggerSpell)) + return false; + return true; + } + + void HandlePeriodic(AuraEffect const* aurEff) + { + PreventDefaultAction(); + + Unit* target = GetTarget(); + uint32 mana = CalculatePct(target->GetMaxPower(POWER_MANA), aurEff->GetAmount()); + + target->CastCustomSpell(GetSpellInfo()->Effects[aurEff->GetEffIndex()].TriggerSpell, SPELLVALUE_BASE_POINT0, int32(mana), target, true, nullptr, aurEff); + } + + void Register() override + { + OnEffectPeriodic += AuraEffectPeriodicFn(spell_hun_rapid_recuperation_AuraScript::HandlePeriodic, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); + } + }; + + AuraScript* GetAuraScript() const override + { + return new spell_hun_rapid_recuperation_AuraScript(); + } +}; + // 23989 - Readiness class spell_hun_readiness : public SpellScriptLoader { @@ -921,6 +960,7 @@ void AddSC_hunter_spell_scripts() new spell_hun_misdirection_proc(); new spell_hun_pet_carrion_feeder(); new spell_hun_pet_heart_of_the_phoenix(); + new spell_hun_rapid_recuperation(); new spell_hun_readiness(); new spell_hun_scatter_shot(); new spell_hun_sniper_training(); diff --git a/src/server/scripts/Spells/spell_pet.cpp b/src/server/scripts/Spells/spell_pet.cpp index 764debc1a6b..a0664a2ea00 100644 --- a/src/server/scripts/Spells/spell_pet.cpp +++ b/src/server/scripts/Spells/spell_pet.cpp @@ -1367,7 +1367,7 @@ public: if (GetCaster()->GetOwner()->ToPlayer()) { // Pet's base damage changes depending on happiness - if (GetCaster()->IsPet() && GetCaster()->ToPet()->IsHunterPet()) + if (GetCaster()->IsPet() && GetCaster()->IsHunterPet()) { switch (GetCaster()->ToPet()->GetHappinessState()) { diff --git a/src/server/worldserver/worldserver.conf.dist b/src/server/worldserver/worldserver.conf.dist index 447ef9a45a8..8e06c1c9ca4 100644 --- a/src/server/worldserver/worldserver.conf.dist +++ b/src/server/worldserver/worldserver.conf.dist @@ -2265,7 +2265,7 @@ Battleground.RewardLoserHonorLast = 5 # Wintergrasp.Enable # Description: Enable the Wintergrasp battlefield. # Default: 0 - (Disabled) -# 1 - (Enabled, Experimental as of still being in development) +# 1 - (Enabled, Experimental as in incomplete, bugged and with crashes) Wintergrasp.Enable = 0 @@ -2943,6 +2943,19 @@ AuctionHouseBot.Horde.Price.Ratio = 100 AuctionHouseBot.Neutral.Price.Ratio = 100 # +# AuctionHouseBot.Items.QUALITY.Price.Ratio +# Description: Percentage by which the price of items sold of each quality is incremented / decreased (for all houses) +# Default: 100 - (No change) + +AuctionHouseBot.Items.Gray.Price.Ratio = 100 +AuctionHouseBot.Items.White.Price.Ratio = 100 +AuctionHouseBot.Items.Green.Price.Ratio = 100 +AuctionHouseBot.Items.Blue.Price.Ratio = 100 +AuctionHouseBot.Items.Purple.Price.Ratio = 100 +AuctionHouseBot.Items.Orange.Price.Ratio = 100 +AuctionHouseBot.Items.Yellow.Price.Ratio = 100 + +# # AuctionHouseBot.Items.ItemLevel.* # Description: Prevent seller from listing items below/above this item level # Default: 0 - (Disabled) @@ -3115,6 +3128,13 @@ AuctionHouseBot.Buyer.Alliance.Enabled = 0 AuctionHouseBot.Buyer.Horde.Enabled = 0 AuctionHouseBot.Buyer.Neutral.Enabled = 0 +# AuctionHouseBot.Buyer.ChanceFactor +# Description: k value in the formula used for the chance to buy an item "100^(1 + (1 - (AuctionBid / ItemPrice)) / k)" +# It must be a decimal number in the range of (0, +infinity). The higher the number the higher chance to buy overpriced auctions +# Default: 2 + +AuctionHouseBot.Buyer.ChanceFactor = 2 + # # AuctionHouseBot.Buyer.Baseprice.QUALITY # Description: Base sellprices in copper for non priced items for each quality. |