diff options
Diffstat (limited to 'src')
53 files changed, 638 insertions, 422 deletions
diff --git a/src/server/authserver/Server/AuthSocket.cpp b/src/server/authserver/Server/AuthSocket.cpp index 2e73498eb52..792e1bf2a86 100644 --- a/src/server/authserver/Server/AuthSocket.cpp +++ b/src/server/authserver/Server/AuthSocket.cpp @@ -196,12 +196,12 @@ const AuthHandler table[] = Patcher PatchesCache; // Constructor - set the N and g values for SRP6 -AuthSocket::AuthSocket(RealmSocket& socket) : pPatch(NULL), socket_(socket) +AuthSocket::AuthSocket(RealmSocket& socket) : + pPatch(NULL), socket_(socket), _authed(false), _build(0), + _expversion(0), _accountSecurityLevel(SEC_PLAYER) { N.SetHexStr("894B645E89E1535BBDAD5B8B290650530801B18EBFBF5E8FAB3C82872A3E9BB7"); g.SetDword(7); - _authed = false; - _accountSecurityLevel = SEC_PLAYER; } // Close patch file descriptor before leaving diff --git a/src/server/authserver/Server/RealmSocket.cpp b/src/server/authserver/Server/RealmSocket.cpp index e249894a4d3..6710a6a88ae 100644 --- a/src/server/authserver/Server/RealmSocket.cpp +++ b/src/server/authserver/Server/RealmSocket.cpp @@ -27,7 +27,9 @@ RealmSocket::Session::Session(void) {} RealmSocket::Session::~Session(void) { } -RealmSocket::RealmSocket(void) : input_buffer_(4096), session_(NULL), _remoteAddress() +RealmSocket::RealmSocket(void) : + input_buffer_(4096), session_(NULL), + _remoteAddress(), _remotePort(0) { reference_counting_policy().value(ACE_Event_Handler::Reference_Counting_Policy::ENABLED); diff --git a/src/server/collision/Management/VMapManager2.cpp b/src/server/collision/Management/VMapManager2.cpp index 8a1bd346957..6355dbcf4ce 100644 --- a/src/server/collision/Management/VMapManager2.cpp +++ b/src/server/collision/Management/VMapManager2.cpp @@ -96,7 +96,10 @@ namespace VMAP std::string mapFileName = getMapFileName(mapId); StaticMapTree* newTree = new StaticMapTree(mapId, basePath); if (!newTree->InitMap(mapFileName, this)) + { + delete newTree; return false; + } instanceTree = iInstanceMapTrees.insert(InstanceTreeMap::value_type(mapId, newTree)).first; } diff --git a/src/server/collision/Maps/MapTree.cpp b/src/server/collision/Maps/MapTree.cpp index 7dbfcd78bc9..dc12bb68e0d 100644 --- a/src/server/collision/Maps/MapTree.cpp +++ b/src/server/collision/Maps/MapTree.cpp @@ -119,8 +119,9 @@ namespace VMAP return intersectionCallBack.result; } - StaticMapTree::StaticMapTree(uint32 mapID, const std::string &basePath) - : iMapID(mapID), iIsTiled(false), iTreeValues(0), iBasePath(basePath) + StaticMapTree::StaticMapTree(uint32 mapID, const std::string &basePath) : + iMapID(mapID), iIsTiled(false), iTreeValues(NULL), + iNTreeValues(0), iBasePath(basePath) { if (iBasePath.length() > 0 && iBasePath[iBasePath.length()-1] != '/' && iBasePath[iBasePath.length()-1] != '\\') { @@ -273,54 +274,49 @@ namespace VMAP bool StaticMapTree::InitMap(const std::string &fname, VMapManager2* vm) { VMAP_DEBUG_LOG(LOG_FILTER_MAPS, "StaticMapTree::InitMap() : initializing StaticMapTree '%s'", fname.c_str()); - bool success = true; + bool success = false; std::string fullname = iBasePath + fname; FILE* rf = fopen(fullname.c_str(), "rb"); if (!rf) return false; - else + + char chunk[8]; + char tiled = '\0'; + + if (readChunk(rf, chunk, VMAP_MAGIC, 8) && fread(&tiled, sizeof(char), 1, rf) == 1 && + readChunk(rf, chunk, "NODE", 4) && iTree.readFromFile(rf)) { - char chunk[8]; - //general info - if (!readChunk(rf, chunk, VMAP_MAGIC, 8)) success = false; - char tiled = '\0'; - if (success && fread(&tiled, sizeof(char), 1, rf) != 1) success = false; - iIsTiled = bool(tiled); - // Nodes - if (success && !readChunk(rf, chunk, "NODE", 4)) success = false; - if (success) success = iTree.readFromFile(rf); - if (success) - { - iNTreeValues = iTree.primCount(); - iTreeValues = new ModelInstance[iNTreeValues]; - } + iNTreeValues = iTree.primCount(); + iTreeValues = new ModelInstance[iNTreeValues]; + success = readChunk(rf, chunk, "GOBJ", 4); + } + + iIsTiled = bool(tiled); - if (success && !readChunk(rf, chunk, "GOBJ", 4)) success = false; - // global model spawns - // only non-tiled maps have them, and if so exactly one (so far at least...) - ModelSpawn spawn; + // global model spawns + // only non-tiled maps have them, and if so exactly one (so far at least...) + ModelSpawn spawn; #ifdef VMAP_DEBUG - TC_LOG_DEBUG(LOG_FILTER_MAPS, "StaticMapTree::InitMap() : map isTiled: %u", static_cast<uint32>(iIsTiled)); + TC_LOG_DEBUG(LOG_FILTER_MAPS, "StaticMapTree::InitMap() : map isTiled: %u", static_cast<uint32>(iIsTiled)); #endif - if (!iIsTiled && ModelSpawn::readFromFile(rf, spawn)) + if (!iIsTiled && ModelSpawn::readFromFile(rf, spawn)) + { + WorldModel* model = vm->acquireModelInstance(iBasePath, spawn.name); + VMAP_DEBUG_LOG(LOG_FILTER_MAPS, "StaticMapTree::InitMap() : loading %s", spawn.name.c_str()); + if (model) { - WorldModel* model = vm->acquireModelInstance(iBasePath, spawn.name); - VMAP_DEBUG_LOG(LOG_FILTER_MAPS, "StaticMapTree::InitMap() : loading %s", spawn.name.c_str()); - if (model) - { - // assume that global model always is the first and only tree value (could be improved...) - iTreeValues[0] = ModelInstance(spawn, model); - iLoadedSpawns[0] = 1; - } - else - { - success = false; - VMAP_ERROR_LOG(LOG_FILTER_GENERAL, "StaticMapTree::InitMap() : could not acquire WorldModel pointer for '%s'", spawn.name.c_str()); - } + // assume that global model always is the first and only tree value (could be improved...) + iTreeValues[0] = ModelInstance(spawn, model); + iLoadedSpawns[0] = 1; + } + else + { + success = false; + VMAP_ERROR_LOG(LOG_FILTER_GENERAL, "StaticMapTree::InitMap() : could not acquire WorldModel pointer for '%s'", spawn.name.c_str()); } - - fclose(rf); } + + fclose(rf); return success; } diff --git a/src/server/collision/Maps/MapTree.h b/src/server/collision/Maps/MapTree.h index e97c44d089e..c66893da82f 100644 --- a/src/server/collision/Maps/MapTree.h +++ b/src/server/collision/Maps/MapTree.h @@ -85,7 +85,8 @@ namespace VMAP struct AreaInfo { - AreaInfo(): result(false), ground_Z(-G3D::inf()) {} + AreaInfo(): result(false), ground_Z(-G3D::inf()), flags(0), adtId(0), + rootId(0), groupId(0) {} bool result; float ground_Z; uint32 flags; diff --git a/src/server/collision/Maps/TileAssembler.cpp b/src/server/collision/Maps/TileAssembler.cpp index aca7c02e79f..4b61e5da40b 100644 --- a/src/server/collision/Maps/TileAssembler.cpp +++ b/src/server/collision/Maps/TileAssembler.cpp @@ -152,23 +152,25 @@ namespace VMAP uint32 x, y; StaticMapTree::unpackTileID(tile->first, x, y); tilefilename << std::setw(2) << x << '_' << std::setw(2) << y << ".vmtile"; - FILE* tilefile = fopen(tilefilename.str().c_str(), "wb"); - // file header - if (success && fwrite(VMAP_MAGIC, 1, 8, tilefile) != 8) success = false; - // write number of tile spawns - if (success && fwrite(&nSpawns, sizeof(uint32), 1, tilefile) != 1) success = false; - // write tile spawns - for (uint32 s=0; s<nSpawns; ++s) + if (FILE* tilefile = fopen(tilefilename.str().c_str(), "wb")) { - if (s) - ++tile; - const ModelSpawn &spawn2 = map_iter->second->UniqueEntries[tile->second]; - success = success && ModelSpawn::writeToFile(tilefile, spawn2); - // MapTree nodes to update when loading tile: - std::map<uint32, uint32>::iterator nIdx = modelNodeIdx.find(spawn2.ID); - if (success && fwrite(&nIdx->second, sizeof(uint32), 1, tilefile) != 1) success = false; + // file header + if (success && fwrite(VMAP_MAGIC, 1, 8, tilefile) != 8) success = false; + // write number of tile spawns + if (success && fwrite(&nSpawns, sizeof(uint32), 1, tilefile) != 1) success = false; + // write tile spawns + for (uint32 s=0; s<nSpawns; ++s) + { + if (s) + ++tile; + const ModelSpawn &spawn2 = map_iter->second->UniqueEntries[tile->second]; + success = success && ModelSpawn::writeToFile(tilefile, spawn2); + // MapTree nodes to update when loading tile: + std::map<uint32, uint32>::iterator nIdx = modelNodeIdx.find(spawn2.ID); + if (success && fwrite(&nIdx->second, sizeof(uint32), 1, tilefile) != 1) success = false; + } + fclose(tilefile); } - fclose(tilefile); } // break; //test, extract only first map; TODO: remvoe this line } diff --git a/src/server/collision/Maps/TileAssembler.h b/src/server/collision/Maps/TileAssembler.h index a11ce272d62..56cb7600e4f 100644 --- a/src/server/collision/Maps/TileAssembler.h +++ b/src/server/collision/Maps/TileAssembler.h @@ -40,6 +40,7 @@ namespace VMAP private: G3D::Matrix3 iRotation; public: + ModelPosition(): iScale(0.0f) { } G3D::Vector3 iPos; G3D::Vector3 iDir; float iScale; @@ -74,7 +75,8 @@ namespace VMAP std::vector<G3D::Vector3> vertexArray; class WmoLiquid* liquid; - GroupModel_Raw() : liquid(0) {} + GroupModel_Raw() : mogpflags(0), GroupWMOID(0), liquidflags(0), + liquid(NULL) {} ~GroupModel_Raw(); bool Read(FILE* f); diff --git a/src/server/collision/Models/WorldModel.cpp b/src/server/collision/Models/WorldModel.cpp index ca0f95c74e3..3c72cb80308 100644 --- a/src/server/collision/Models/WorldModel.cpp +++ b/src/server/collision/Models/WorldModel.cpp @@ -205,35 +205,48 @@ namespace VMAP bool WmoLiquid::writeToFile(FILE* wf) { - bool result = true; - if (result && fwrite(&iTilesX, sizeof(uint32), 1, wf) != 1) result = false; - if (result && fwrite(&iTilesY, sizeof(uint32), 1, wf) != 1) result = false; - if (result && fwrite(&iCorner, sizeof(Vector3), 1, wf) != 1) result = false; - if (result && fwrite(&iType, sizeof(uint32), 1, wf) != 1) result = false; - uint32 size = (iTilesX + 1)*(iTilesY + 1); - if (result && fwrite(iHeight, sizeof(float), size, wf) != size) result = false; - size = iTilesX*iTilesY; - if (result && fwrite(iFlags, sizeof(uint8), size, wf) != size) result = false; + bool result = false; + if (fwrite(&iTilesX, sizeof(uint32), 1, wf) == 1 && + fwrite(&iTilesY, sizeof(uint32), 1, wf) == 1 && + fwrite(&iCorner, sizeof(Vector3), 1, wf) == 1 && + fwrite(&iType, sizeof(uint32), 1, wf) == 1) + { + uint32 size = (iTilesX + 1) * (iTilesY + 1); + if (fwrite(iHeight, sizeof(float), size, wf) == size) + { + size = iTilesX*iTilesY; + result = fwrite(iFlags, sizeof(uint8), size, wf) == size; + } + } + return result; } bool WmoLiquid::readFromFile(FILE* rf, WmoLiquid* &out) { - bool result = true; + bool result = false; WmoLiquid* liquid = new WmoLiquid(); - if (result && fread(&liquid->iTilesX, sizeof(uint32), 1, rf) != 1) result = false; - if (result && fread(&liquid->iTilesY, sizeof(uint32), 1, rf) != 1) result = false; - if (result && fread(&liquid->iCorner, sizeof(Vector3), 1, rf) != 1) result = false; - if (result && fread(&liquid->iType, sizeof(uint32), 1, rf) != 1) result = false; - uint32 size = (liquid->iTilesX + 1)*(liquid->iTilesY + 1); - liquid->iHeight = new float[size]; - if (result && fread(liquid->iHeight, sizeof(float), size, rf) != size) result = false; - size = liquid->iTilesX * liquid->iTilesY; - liquid->iFlags = new uint8[size]; - if (result && fread(liquid->iFlags, sizeof(uint8), size, rf) != size) result = false; + + if (fread(&liquid->iTilesX, sizeof(uint32), 1, rf) == 1 && + fread(&liquid->iTilesY, sizeof(uint32), 1, rf) == 1 && + fread(&liquid->iCorner, sizeof(Vector3), 1, rf) == 1 && + fread(&liquid->iType, sizeof(uint32), 1, rf) == 1) + { + uint32 size = (liquid->iTilesX + 1) * (liquid->iTilesY + 1); + liquid->iHeight = new float[size]; + if (fread(liquid->iHeight, sizeof(float), size, rf) == size) + { + size = liquid->iTilesX * liquid->iTilesY; + liquid->iFlags = new uint8[size]; + result = fread(liquid->iFlags, sizeof(uint8), size, rf) == size; + } + } + if (!result) delete liquid; - out = liquid; + else + out = liquid; + return result; } diff --git a/src/server/game/AI/CoreAI/UnitAI.cpp b/src/server/game/AI/CoreAI/UnitAI.cpp index 0ab807466d5..70c4761e025 100644 --- a/src/server/game/AI/CoreAI/UnitAI.cpp +++ b/src/server/game/AI/CoreAI/UnitAI.cpp @@ -123,34 +123,45 @@ void UnitAI::DoCastToAllHostilePlayers(uint32 spellid, bool triggered) void UnitAI::DoCast(uint32 spellId) { Unit* target = NULL; - //TC_LOG_ERROR(LOG_FILTER_GENERAL, "aggre %u %u", spellId, (uint32)AISpellInfo[spellId].target); + switch (AISpellInfo[spellId].target) { default: - case AITARGET_SELF: target = me; break; - case AITARGET_VICTIM: target = me->getVictim(); break; + case AITARGET_SELF: + target = me; + break; + case AITARGET_VICTIM: + target = me->getVictim(); + break; case AITARGET_ENEMY: { - const SpellInfo* spellInfo = sSpellMgr->GetSpellInfo(spellId); - bool playerOnly = spellInfo->AttributesEx3 & SPELL_ATTR3_ONLY_TARGET_PLAYERS; - //float range = GetSpellMaxRange(spellInfo, false); - target = SelectTarget(SELECT_TARGET_RANDOM, 0, spellInfo->GetMaxRange(false), playerOnly); + if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId)) + { + bool playerOnly = spellInfo->AttributesEx3 & SPELL_ATTR3_ONLY_TARGET_PLAYERS; + target = SelectTarget(SELECT_TARGET_RANDOM, 0, spellInfo->GetMaxRange(false), playerOnly); + } break; } - case AITARGET_ALLY: target = me; break; - case AITARGET_BUFF: target = me; break; + case AITARGET_ALLY: + target = me; + break; + case AITARGET_BUFF: + target = me; + break; case AITARGET_DEBUFF: { - const SpellInfo* spellInfo = sSpellMgr->GetSpellInfo(spellId); - bool playerOnly = spellInfo->AttributesEx3 & SPELL_ATTR3_ONLY_TARGET_PLAYERS; - float range = spellInfo->GetMaxRange(false); - - DefaultTargetSelector targetSelector(me, range, playerOnly, -(int32)spellId); - if (!(spellInfo->AuraInterruptFlags & AURA_INTERRUPT_FLAG_NOT_VICTIM) - && targetSelector(me->getVictim())) - target = me->getVictim(); - else - target = SelectTarget(SELECT_TARGET_RANDOM, 0, targetSelector); + if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId)) + { + bool playerOnly = spellInfo->AttributesEx3 & SPELL_ATTR3_ONLY_TARGET_PLAYERS; + float range = spellInfo->GetMaxRange(false); + + DefaultTargetSelector targetSelector(me, range, playerOnly, -(int32)spellId); + if (!(spellInfo->AuraInterruptFlags & AURA_INTERRUPT_FLAG_NOT_VICTIM) + && targetSelector(me->getVictim())) + target = me->getVictim(); + else + target = SelectTarget(SELECT_TARGET_RANDOM, 0, targetSelector); + } break; } } diff --git a/src/server/game/AI/CreatureAI.h b/src/server/game/AI/CreatureAI.h index 9d61ec0a214..3d71abb47a9 100644 --- a/src/server/game/AI/CreatureAI.h +++ b/src/server/game/AI/CreatureAI.h @@ -169,7 +169,7 @@ class CreatureAI : public UnitAI virtual void PassengerBoarded(Unit* /*passenger*/, int8 /*seatId*/, bool /*apply*/) {} - virtual void OnSpellClick(Unit* /*clicker*/) { } + virtual void OnSpellClick(Unit* /*clicker*/, bool& /*result*/) { } virtual bool CanSeeAlways(WorldObject const* /*obj*/) { return false; } protected: diff --git a/src/server/game/AI/SmartScripts/SmartAI.cpp b/src/server/game/AI/SmartScripts/SmartAI.cpp index 96979cf2c49..a2612df2f89 100644 --- a/src/server/game/AI/SmartScripts/SmartAI.cpp +++ b/src/server/game/AI/SmartScripts/SmartAI.cpp @@ -828,8 +828,11 @@ void SmartAI::sOnGameEvent(bool start, uint16 eventId) GetScript()->ProcessEventsFor(start ? SMART_EVENT_GAME_EVENT_START : SMART_EVENT_GAME_EVENT_END, NULL, eventId); } -void SmartAI::OnSpellClick(Unit* clicker) +void SmartAI::OnSpellClick(Unit* clicker, bool& result) { + if (!result) + return; + GetScript()->ProcessEventsFor(SMART_EVENT_ON_SPELLCLICK, clicker); } diff --git a/src/server/game/AI/SmartScripts/SmartAI.h b/src/server/game/AI/SmartScripts/SmartAI.h index dee6bec905c..4b4909e9c6c 100644 --- a/src/server/game/AI/SmartScripts/SmartAI.h +++ b/src/server/game/AI/SmartScripts/SmartAI.h @@ -197,7 +197,7 @@ class SmartAI : public CreatureAI void RemoveAuras(); - void OnSpellClick(Unit* clicker); + void OnSpellClick(Unit* clicker, bool& result); private: uint32 mFollowCreditType; diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index 576d77a2e24..9d182ee6885 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -657,9 +657,18 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u { if (IsUnit(*itr)) { - (*itr)->ToUnit()->SetFlag(UNIT_FIELD_FLAGS, e.action.unitFlag.flag); - TC_LOG_DEBUG(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction:: SMART_ACTION_SET_UNIT_FLAG. Unit %u added flag %u to UNIT_FIELD_FLAGS", + if (!e.action.unitFlag.type) + { + (*itr)->ToUnit()->SetFlag(UNIT_FIELD_FLAGS, e.action.unitFlag.flag); + TC_LOG_DEBUG(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction:: SMART_ACTION_SET_UNIT_FLAG. Unit %u added flag %u to UNIT_FIELD_FLAGS", + (*itr)->GetGUIDLow(), e.action.unitFlag.flag); + } + else + { + (*itr)->ToUnit()->SetFlag(UNIT_FIELD_FLAGS_2, e.action.unitFlag.flag); + TC_LOG_DEBUG(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction:: SMART_ACTION_SET_UNIT_FLAG. Unit %u added flag %u to UNIT_FIELD_FLAGS_2", (*itr)->GetGUIDLow(), e.action.unitFlag.flag); + } } } @@ -676,9 +685,18 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u { if (IsUnit(*itr)) { - (*itr)->ToUnit()->RemoveFlag(UNIT_FIELD_FLAGS, e.action.unitFlag.flag); - TC_LOG_DEBUG(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction:: SMART_ACTION_REMOVE_UNIT_FLAG. Unit %u removed flag %u to UNIT_FIELD_FLAGS", + if (!e.action.unitFlag.type) + { + (*itr)->ToUnit()->RemoveFlag(UNIT_FIELD_FLAGS, e.action.unitFlag.flag); + TC_LOG_DEBUG(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction:: SMART_ACTION_REMOVE_UNIT_FLAG. Unit %u removed flag %u to UNIT_FIELD_FLAGS", + (*itr)->GetGUIDLow(), e.action.unitFlag.flag); + } + else + { + (*itr)->ToUnit()->RemoveFlag(UNIT_FIELD_FLAGS_2, e.action.unitFlag.flag); + TC_LOG_DEBUG(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction:: SMART_ACTION_REMOVE_UNIT_FLAG. Unit %u removed flag %u to UNIT_FIELD_FLAGS_2", (*itr)->GetGUIDLow(), e.action.unitFlag.flag); + } } } diff --git a/src/server/game/AI/SmartScripts/SmartScript.h b/src/server/game/AI/SmartScripts/SmartScript.h index 409d0e7d324..6801c132331 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.h +++ b/src/server/game/AI/SmartScripts/SmartScript.h @@ -117,7 +117,7 @@ class SmartScript smart = false; if (!smart) - TC_LOG_ERROR(LOG_FILTER_SQL, "SmartScript: Action target Creature(entry: %u) is not using SmartAI, action skipped to prevent crash.", c ? c->GetEntry() : (me ? me->GetEntry() : 0)); + TC_LOG_ERROR(LOG_FILTER_SQL, "SmartScript: Action target Creature (GUID: %u Entry: %u) is not using SmartAI, action skipped to prevent crash.", c ? c->GetDBTableGUIDLow() : (me ? me->GetDBTableGUIDLow() : 0), c ? c->GetEntry() : (me ? me->GetEntry() : 0)); return smart; } @@ -131,7 +131,7 @@ class SmartScript if (!go || go->GetAIName() != "SmartGameObjectAI") smart = false; if (!smart) - TC_LOG_ERROR(LOG_FILTER_SQL, "SmartScript: Action target GameObject(entry: %u) is not using SmartGameObjectAI, action skipped to prevent crash.", g ? g->GetEntry() : (go ? go->GetEntry() : 0)); + TC_LOG_ERROR(LOG_FILTER_SQL, "SmartScript: Action target GameObject (GUID: %u Entry: %u) is not using SmartGameObjectAI, action skipped to prevent crash.", g ? g->GetDBTableGUIDLow() : (go ? go->GetDBTableGUIDLow() : 0), g ? g->GetEntry() : (go ? go->GetEntry() : 0)); return smart; } diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.h b/src/server/game/AI/SmartScripts/SmartScriptMgr.h index 33e458976f1..2fcee55ed14 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.h +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.h @@ -827,6 +827,7 @@ struct SmartAction struct { uint32 flag; + uint32 type; } unitFlag; struct diff --git a/src/server/game/Achievements/AchievementMgr.cpp b/src/server/game/Achievements/AchievementMgr.cpp index b7b065a8b31..00bffb8f21c 100644 --- a/src/server/game/Achievements/AchievementMgr.cpp +++ b/src/server/game/Achievements/AchievementMgr.cpp @@ -1639,6 +1639,9 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui bool AchievementMgr::IsCompletedCriteria(AchievementCriteriaEntry const* achievementCriteria, AchievementEntry const* achievement) { + if (!achievement) + return false; + // counter can never complete if (achievement->flags & ACHIEVEMENT_FLAG_COUNTER) return false; @@ -1951,8 +1954,11 @@ void AchievementMgr::SetCriteriaProgress(AchievementCriteriaEntry const* entry, SendCriteriaUpdate(entry, progress, timeElapsed, timedCompleted); } -void AchievementMgr::RemoveCriteriaProgress(const AchievementCriteriaEntry* entry) +void AchievementMgr::RemoveCriteriaProgress(AchievementCriteriaEntry const* entry) { + if (!entry) + return; + CriteriaProgressMap::iterator criteriaProgress = m_criteriaProgress.find(entry->ID); if (criteriaProgress == m_criteriaProgress.end()) return; @@ -2127,12 +2133,11 @@ void AchievementMgr::SendRespondInspectAchievements(Player* player) const */ void AchievementMgr::BuildAllDataPacket(WorldPacket* data) const { - AchievementEntry const* achievement = NULL; for (CompletedAchievementMap::const_iterator iter = m_completedAchievements.begin(); iter != m_completedAchievements.end(); ++iter) { // Skip hidden achievements - achievement = sAchievementMgr->GetAchievement(iter->first); - if (achievement->flags & ACHIEVEMENT_FLAG_HIDDEN) + AchievementEntry const* achievement = sAchievementMgr->GetAchievement(iter->first); + if (!achievement || achievement->flags & ACHIEVEMENT_FLAG_HIDDEN) continue; *data << uint32(iter->first); diff --git a/src/server/game/Battlefield/Zones/BattlefieldWG.h b/src/server/game/Battlefield/Zones/BattlefieldWG.h index d7f9aa66582..0b7999fcf57 100644 --- a/src/server/game/Battlefield/Zones/BattlefieldWG.h +++ b/src/server/game/Battlefield/Zones/BattlefieldWG.h @@ -1481,6 +1481,7 @@ struct WGWorkshop bf = _bf; workshopId = _workshopId; + teamControl = BATTLEFIELD_WG_TEAM_NEUTRAL; } void GiveControlTo(uint8 team, bool init /* for first call in setup*/) diff --git a/src/server/game/Chat/Chat.cpp b/src/server/game/Chat/Chat.cpp index 3f2908cbdad..5218c9c9e55 100644 --- a/src/server/game/Chat/Chat.cpp +++ b/src/server/game/Chat/Chat.cpp @@ -205,7 +205,7 @@ bool ChatHandler::hasStringAbbr(const char* name, const char* part) if (!*part) return false; - for (;;) + while (true) { if (!*part) return true; diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 50f745669a7..f274f201e04 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -2456,19 +2456,18 @@ uint32 Creature::GetVendorItemCurrentCount(VendorItem const* vItem) time_t ptime = time(NULL); if (time_t(vCount->lastIncrementTime + vItem->incrtime) <= ptime) - { - ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(vItem->item); - - uint32 diff = uint32((ptime - vCount->lastIncrementTime)/vItem->incrtime); - if ((vCount->count + diff * pProto->BuyCount) >= vItem->maxcount) + if (ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(vItem->item)) { - m_vendorItemCounts.erase(itr); - return vItem->maxcount; - } + uint32 diff = uint32((ptime - vCount->lastIncrementTime)/vItem->incrtime); + if ((vCount->count + diff * pProto->BuyCount) >= vItem->maxcount) + { + m_vendorItemCounts.erase(itr); + return vItem->maxcount; + } - vCount->count += diff * pProto->BuyCount; - vCount->lastIncrementTime = ptime; - } + vCount->count += diff * pProto->BuyCount; + vCount->lastIncrementTime = ptime; + } return vCount->count; } @@ -2495,15 +2494,14 @@ uint32 Creature::UpdateVendorItemCurrentCount(VendorItem const* vItem, uint32 us time_t ptime = time(NULL); if (time_t(vCount->lastIncrementTime + vItem->incrtime) <= ptime) - { - ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(vItem->item); - - uint32 diff = uint32((ptime - vCount->lastIncrementTime)/vItem->incrtime); - if ((vCount->count + diff * pProto->BuyCount) < vItem->maxcount) - vCount->count += diff * pProto->BuyCount; - else - vCount->count = vItem->maxcount; - } + if (ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(vItem->item)) + { + uint32 diff = uint32((ptime - vCount->lastIncrementTime)/vItem->incrtime); + if ((vCount->count + diff * pProto->BuyCount) < vItem->maxcount) + vCount->count += diff * pProto->BuyCount; + else + vCount->count = vItem->maxcount; + } vCount->count = vCount->count > used_count ? vCount->count-used_count : 0; vCount->lastIncrementTime = ptime; diff --git a/src/server/game/Entities/Creature/GossipDef.cpp b/src/server/game/Entities/Creature/GossipDef.cpp index 8a8c9ad895f..d59015fd359 100644 --- a/src/server/game/Entities/Creature/GossipDef.cpp +++ b/src/server/game/Entities/Creature/GossipDef.cpp @@ -184,7 +184,9 @@ void PlayerMenu::SendGossipMenu(uint32 titleTextId, uint64 objectGUID) const data << item.BoxMessage; // accept text (related to money) pop up box, 2.0.3 } - data << uint32(_questMenu.GetMenuItemCount()); // max count 0x20 + size_t count_pos = data.wpos(); + data << uint32(0); // max count 0x20 + uint32 count = 0; // Store this instead of checking the Singleton every loop iteration bool questLevelInTitle = sWorld->getBoolConfig(CONFIG_UI_QUESTLEVELS_IN_DIALOGS); @@ -193,26 +195,29 @@ void PlayerMenu::SendGossipMenu(uint32 titleTextId, uint64 objectGUID) const { QuestMenuItem const& item = _questMenu.GetItem(i); uint32 questID = item.QuestId; - Quest const* quest = sObjectMgr->GetQuestTemplate(questID); - - data << uint32(questID); - data << uint32(item.QuestIcon); - data << int32(quest->GetQuestLevel()); - data << uint32(quest->GetFlags()); // 3.3.3 quest flags - data << uint8(0); // 3.3.3 changes icon: blue question or yellow exclamation - std::string title = quest->GetTitle(); + if (Quest const* quest = sObjectMgr->GetQuestTemplate(questID)) + { + ++count; + data << uint32(questID); + data << uint32(item.QuestIcon); + data << int32(quest->GetQuestLevel()); + data << uint32(quest->GetFlags()); // 3.3.3 quest flags + data << uint8(0); // 3.3.3 changes icon: blue question or yellow exclamation + std::string title = quest->GetTitle(); - int32 locale = _session->GetSessionDbLocaleIndex(); - if (locale >= 0) - if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(questID)) - ObjectMgr::GetLocaleString(localeData->Title, locale, title); + int32 locale = _session->GetSessionDbLocaleIndex(); + if (locale >= 0) + if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(questID)) + ObjectMgr::GetLocaleString(localeData->Title, locale, title); - if (questLevelInTitle) - AddQuestLevelToTitle(title, quest->GetQuestLevel()); + if (questLevelInTitle) + AddQuestLevelToTitle(title, quest->GetQuestLevel()); - data << title; // max 0x200 + data << title; // max 0x200 + } } + data.put<uint8>(count_pos, count); _session->SendPacket(&data); } @@ -300,20 +305,21 @@ void PlayerMenu::SendQuestGiverQuestList(QEmote eEmote, const std::string& Title data << uint32(eEmote._Emote); // NPC emote size_t count_pos = data.wpos(); - data << uint8 (_questMenu.GetMenuItemCount()); + data << uint8 (0); uint32 count = 0; // Store this instead of checking the Singleton every loop iteration bool questLevelInTitle = sWorld->getBoolConfig(CONFIG_UI_QUESTLEVELS_IN_DIALOGS); - for (; count < _questMenu.GetMenuItemCount(); ++count) + for (uint32 i = 0; i < _questMenu.GetMenuItemCount(); ++i) { - QuestMenuItem const& qmi = _questMenu.GetItem(count); + QuestMenuItem const& qmi = _questMenu.GetItem(i); uint32 questID = qmi.QuestId; if (Quest const* quest = sObjectMgr->GetQuestTemplate(questID)) { + ++count; std::string title = quest->GetTitle(); int32 locale = _session->GetSessionDbLocaleIndex(); diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index cc9e87052f7..1556703e45b 100644 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -87,7 +87,10 @@ bool GameObject::AIM_Initialize() std::string GameObject::GetAIName() const { - return sObjectMgr->GetGameObjectTemplate(GetEntry())->AIName; + if (GameObjectTemplate const* got = sObjectMgr->GetGameObjectTemplate(GetEntry())) + return got->AIName; + + return ""; } void GameObject::CleanupsBeforeDelete(bool /*finalCleanup*/) diff --git a/src/server/game/Entities/Item/Item.cpp b/src/server/game/Entities/Item/Item.cpp index e1ca398c7f3..d87e1e8fbbc 100644 --- a/src/server/game/Entities/Item/Item.cpp +++ b/src/server/game/Entities/Item/Item.cpp @@ -877,16 +877,26 @@ bool Item::IsFitToSpellRequirements(SpellInfo const* spellInfo) const return true; } -void Item::SetEnchantment(EnchantmentSlot slot, uint32 id, uint32 duration, uint32 charges) +void Item::SetEnchantment(EnchantmentSlot slot, uint32 id, uint32 duration, uint32 charges, uint64 caster /*= 0*/) { // Better lost small time at check in comparison lost time at item save to DB. if ((GetEnchantmentId(slot) == id) && (GetEnchantmentDuration(slot) == duration) && (GetEnchantmentCharges(slot) == charges)) return; + Player* owner = GetOwner(); + if (slot < MAX_INSPECTED_ENCHANTMENT_SLOT) + { + if (uint32 oldEnchant = GetEnchantmentId(slot)) + owner->GetSession()->SendEnchantmentLog(GetOwnerGUID(), 0, GetEntry(), oldEnchant); + + if (id) + owner->GetSession()->SendEnchantmentLog(GetOwnerGUID(), caster, GetEntry(), id); + } + SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot*MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_ID_OFFSET, id); SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot*MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_DURATION_OFFSET, duration); SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot*MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_CHARGES_OFFSET, charges); - SetState(ITEM_CHANGED, GetOwner()); + SetState(ITEM_CHANGED, owner); } void Item::SetEnchantmentDuration(EnchantmentSlot slot, uint32 duration, Player* owner) @@ -1003,6 +1013,16 @@ bool Item::IsLimitedToAnotherMapOrZone(uint32 cur_mapId, uint32 cur_zoneId) cons return proto && ((proto->Map && proto->Map != cur_mapId) || (proto->Area && proto->Area != cur_zoneId)); } +void Item::SendUpdateSockets() +{ + WorldPacket data(SMSG_SOCKET_GEMS_RESULT, 8+4+4+4+4); + data << uint64(GetGUID()); + for (uint32 i = SOCK_ENCHANTMENT_SLOT; i <= BONUS_ENCHANTMENT_SLOT; ++i) + data << uint32(GetEnchantmentId(EnchantmentSlot(i))); + + GetOwner()->GetSession()->SendPacket(&data); +} + // Though the client has the information in the item's data field, // we have to send SMSG_ITEM_TIME_UPDATE to display the remaining // time. diff --git a/src/server/game/Entities/Item/Item.h b/src/server/game/Entities/Item/Item.h index 0d34305d15c..b18dfe694d6 100644 --- a/src/server/game/Entities/Item/Item.h +++ b/src/server/game/Entities/Item/Item.h @@ -289,7 +289,7 @@ class Item : public Object void SetItemRandomProperties(int32 randomPropId); void UpdateItemSuffixFactor(); static int32 GenerateItemRandomPropertyId(uint32 item_id); - void SetEnchantment(EnchantmentSlot slot, uint32 id, uint32 duration, uint32 charges); + void SetEnchantment(EnchantmentSlot slot, uint32 id, uint32 duration, uint32 charges, uint64 caster = 0); void SetEnchantmentDuration(EnchantmentSlot slot, uint32 duration, Player* owner); void SetEnchantmentCharges(EnchantmentSlot slot, uint32 charges); void ClearEnchantment(EnchantmentSlot slot); @@ -300,6 +300,8 @@ class Item : public Object std::string const& GetText() const { return m_text; } void SetText(std::string const& text) { m_text = text; } + void SendUpdateSockets(); + void SendTimeUpdate(Player* owner); void UpdateDuration(Player* owner, uint32 diff); diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 4b2c5e29d35..1d3eebf4c58 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -22238,7 +22238,7 @@ void Player::UpdateTriggerVisibility() if (!obj || !(obj->isTrigger() || obj->HasAuraType(SPELL_AURA_TRANSFORM))) // can transform into triggers continue; - obj->BuildCreateUpdateBlockForPlayer(&udata, this); + obj->BuildValuesUpdateBlockForPlayer(&udata, this); } } @@ -23225,7 +23225,7 @@ void Player::UpdateForQuestWorldObjects() if (buildUpdateBlock) { - obj->BuildCreateUpdateBlockForPlayer(&udata, this); + obj->BuildValuesUpdateBlockForPlayer(&udata, this); break; } } diff --git a/src/server/game/Entities/Transport/Transport.cpp b/src/server/game/Entities/Transport/Transport.cpp index 74842d8d80d..f41b5c2f001 100644 --- a/src/server/game/Entities/Transport/Transport.cpp +++ b/src/server/game/Entities/Transport/Transport.cpp @@ -692,30 +692,34 @@ void Transport::UpdatePassengerPositions() float x, y, z, o; npc->m_movementInfo.t_pos.GetPosition(x, y, z, o); - CalculatePassengerPosition(x, y, z, o); + CalculatePassengerPosition(x, y, z, &o); GetMap()->CreatureRelocation(npc, x, y, z, o, false); npc->GetTransportHomePosition(x, y, z, o); - CalculatePassengerPosition(x, y, z, o); + CalculatePassengerPosition(x, y, z, &o); npc->SetHomePosition(x, y, z, o); } } -void Transport::CalculatePassengerPosition(float& x, float& y, float& z, float& o) const +void Transport::CalculatePassengerPosition(float& x, float& y, float& z, float* o /*= NULL*/) const { - float inx = x, iny = y, inz = z, ino = o; - o = GetOrientation() + ino; + float inx = x, iny = y, inz = z; + if (o) + *o = Position::NormalizeOrientation(GetOrientation() + *o); + x = GetPositionX() + inx * std::cos(GetOrientation()) - iny * std::sin(GetOrientation()); y = GetPositionY() + iny * std::cos(GetOrientation()) + inx * std::sin(GetOrientation()); z = GetPositionZ() + inz; } -void Transport::CalculatePassengerOffset(float& x, float& y, float& z, float& o) const +void Transport::CalculatePassengerOffset(float& x, float& y, float& z, float* o /*= NULL*/) const { - o -= GetOrientation(); + if (o) + *o = Position::NormalizeOrientation(*o - GetOrientation()); + z -= GetPositionZ(); y -= GetPositionY(); // y = searchedY * std::cos(o) + searchedX * std::sin(o) x -= GetPositionX(); // x = searchedX * std::cos(o) + searchedY * std::sin(o + pi) float inx = x, iny = y; - y = (iny - inx * tan(GetOrientation())) / (cos(GetOrientation()) + std::sin(GetOrientation()) * tan(GetOrientation())); - x = (inx + iny * tan(GetOrientation())) / (cos(GetOrientation()) + std::sin(GetOrientation()) * tan(GetOrientation())); + y = (iny - inx * std::tan(GetOrientation())) / (std::cos(GetOrientation()) + std::sin(GetOrientation()) * std::tan(GetOrientation())); + x = (inx + iny * std::tan(GetOrientation())) / (std::cos(GetOrientation()) + std::sin(GetOrientation()) * std::tan(GetOrientation())); } diff --git a/src/server/game/Entities/Transport/Transport.h b/src/server/game/Entities/Transport/Transport.h index bae09335f62..445bec456fd 100644 --- a/src/server/game/Entities/Transport/Transport.h +++ b/src/server/game/Entities/Transport/Transport.h @@ -50,10 +50,10 @@ class Transport : public GameObject, public TransportBase void UpdatePassengerPositions(); /// This method transforms supplied transport offsets into global coordinates - void CalculatePassengerPosition(float& x, float& y, float& z, float& o) const; + void CalculatePassengerPosition(float& x, float& y, float& z, float* o = NULL) const; /// This method transforms supplied global coordinates into local offsets - void CalculatePassengerOffset(float& x, float& y, float& z, float& o) const; + void CalculatePassengerOffset(float& x, float& y, float& z, float* o = NULL) const; void BuildStartMovePacket(Map const* targetMap); void BuildStopMovePacket(Map const* targetMap); diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 9adcbdd9365..4ad2a06a61e 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -414,7 +414,7 @@ void Unit::UpdateSplineMovement(uint32 t_diff) pos.m_orientation = loc.orientation; if (TransportBase* transport = GetDirectTransport()) - transport->CalculatePassengerPosition(loc.x, loc.y, loc.z, loc.orientation); + transport->CalculatePassengerPosition(loc.x, loc.y, loc.z, &loc.orientation); } if (HasUnitState(UNIT_STATE_CANNOT_TURN)) @@ -16801,12 +16801,9 @@ bool Unit::HandleSpellClick(Unit* clicker, int8 seatId) result = true; } - if (result) - { - Creature* creature = ToCreature(); - if (creature && creature->IsAIEnabled) - creature->AI()->OnSpellClick(clicker); - } + Creature* creature = ToCreature(); + if (creature && creature->IsAIEnabled) + creature->AI()->OnSpellClick(clicker, result); return result; } diff --git a/src/server/game/Entities/Vehicle/Vehicle.cpp b/src/server/game/Entities/Vehicle/Vehicle.cpp index d3c2a16c592..6d7d3f2b2ff 100755 --- a/src/server/game/Entities/Vehicle/Vehicle.cpp +++ b/src/server/game/Entities/Vehicle/Vehicle.cpp @@ -557,7 +557,7 @@ void Vehicle::RelocatePassengers() float px, py, pz, po; passenger->m_movementInfo.t_pos.GetPosition(px, py, pz, po); - CalculatePassengerPosition(px, py, pz, po); + CalculatePassengerPosition(px, py, pz, &po); passenger->UpdatePosition(px, py, pz, po); } } @@ -675,24 +675,28 @@ uint8 Vehicle::GetAvailableSeatCount() const return ret; } -void Vehicle::CalculatePassengerPosition(float& x, float& y, float& z, float& o) const +void Vehicle::CalculatePassengerPosition(float& x, float& y, float& z, float* o /*= NULL*/) const { - float inx = x, iny = y, inz = z, ino = o; - o = GetBase()->GetOrientation() + ino; + float inx = x, iny = y, inz = z; + if (o) + *o = Position::NormalizeOrientation(GetBase()->GetOrientation() + *o); + x = GetBase()->GetPositionX() + inx * std::cos(GetBase()->GetOrientation()) - iny * std::sin(GetBase()->GetOrientation()); y = GetBase()->GetPositionY() + iny * std::cos(GetBase()->GetOrientation()) + inx * std::sin(GetBase()->GetOrientation()); z = GetBase()->GetPositionZ() + inz; } -void Vehicle::CalculatePassengerOffset(float& x, float& y, float& z, float& o) const +void Vehicle::CalculatePassengerOffset(float& x, float& y, float& z, float* o /*= NULL*/) const { - o -= GetBase()->GetOrientation(); + if (o) + *o = Position::NormalizeOrientation(*o - GetBase()->GetOrientation()); + z -= GetBase()->GetPositionZ(); y -= GetBase()->GetPositionY(); // y = searchedY * std::cos(o) + searchedX * std::sin(o) x -= GetBase()->GetPositionX(); // x = searchedX * std::cos(o) + searchedY * std::sin(o + pi) float inx = x, iny = y; - y = (iny - inx * tan(GetBase()->GetOrientation())) / (cos(GetBase()->GetOrientation()) + std::sin(GetBase()->GetOrientation()) * tan(GetBase()->GetOrientation())); - x = (inx + iny * tan(GetBase()->GetOrientation())) / (cos(GetBase()->GetOrientation()) + std::sin(GetBase()->GetOrientation()) * tan(GetBase()->GetOrientation())); + y = (iny - inx * std::tan(GetBase()->GetOrientation())) / (std::cos(GetBase()->GetOrientation()) + std::sin(GetBase()->GetOrientation()) * std::tan(GetBase()->GetOrientation())); + x = (inx + iny * std::tan(GetBase()->GetOrientation())) / (std::cos(GetBase()->GetOrientation()) + std::sin(GetBase()->GetOrientation()) * std::tan(GetBase()->GetOrientation())); } /** diff --git a/src/server/game/Entities/Vehicle/Vehicle.h b/src/server/game/Entities/Vehicle/Vehicle.h index 3e4a2fd3a78..c83a9fa5f33 100644 --- a/src/server/game/Entities/Vehicle/Vehicle.h +++ b/src/server/game/Entities/Vehicle/Vehicle.h @@ -89,10 +89,10 @@ class Vehicle : public TransportBase void InitMovementInfoForBase(); /// This method transforms supplied transport offsets into global coordinates - void CalculatePassengerPosition(float& x, float& y, float& z, float& o) const; + void CalculatePassengerPosition(float& x, float& y, float& z, float* o = NULL) const; /// This method transforms supplied global coordinates into local offsets - void CalculatePassengerOffset(float& x, float& y, float& z, float& o) const; + void CalculatePassengerOffset(float& x, float& y, float& z, float* o = NULL) const; void RemovePendingEvent(VehicleJoinEvent* e); void RemovePendingEventsForSeat(int8 seatId); diff --git a/src/server/game/Entities/Vehicle/VehicleDefines.h b/src/server/game/Entities/Vehicle/VehicleDefines.h index b02448b2d96..dd73ab3a01b 100644 --- a/src/server/game/Entities/Vehicle/VehicleDefines.h +++ b/src/server/game/Entities/Vehicle/VehicleDefines.h @@ -83,10 +83,10 @@ protected: public: /// This method transforms supplied transport offsets into global coordinates - virtual void CalculatePassengerPosition(float& x, float& y, float& z, float& o) const = 0; + virtual void CalculatePassengerPosition(float& x, float& y, float& z, float* o = NULL) const = 0; /// This method transforms supplied global coordinates into local offsets - virtual void CalculatePassengerOffset(float& x, float& y, float& z, float& o) const = 0; + virtual void CalculatePassengerOffset(float& x, float& y, float& z, float* o = NULL) const = 0; }; #endif diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index e684de730da..2290a7c088e 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -5724,7 +5724,7 @@ WorldSafeLocsEntry const* ObjectMgr::GetClosestGraveYard(float x, float y, float MapEntry const* map = sMapStore.LookupEntry(MapId); // not need to check validity of map object; MapId _MUST_ be valid here - if (range.first == range.second && !map->IsBattleArena()) + if (range.first == range.second && !map->IsBattlegroundOrArena()) { TC_LOG_ERROR(LOG_FILTER_SQL, "Table `game_graveyard_zone` incomplete: Zone %u Team %u does not have a linked graveyard.", zoneId, team); return GetDefaultGraveYard(team); diff --git a/src/server/game/Handlers/ItemHandler.cpp b/src/server/game/Handlers/ItemHandler.cpp index e1a9dd27450..13f1988f050 100644 --- a/src/server/game/Handlers/ItemHandler.cpp +++ b/src/server/game/Handlers/ItemHandler.cpp @@ -1007,15 +1007,14 @@ void WorldSession::HandleSetAmmoOpcode(WorldPacket& recvData) GetPlayer()->SetAmmo(item); } -void WorldSession::SendEnchantmentLog(uint64 Target, uint64 Caster, uint32 ItemID, uint32 SpellID) +void WorldSession::SendEnchantmentLog(uint64 target, uint64 caster, uint32 itemId, uint32 enchantId) { - WorldPacket data(SMSG_ENCHANTMENTLOG, (8+8+4+4+1)); // last check 2.0.10 - data << uint64(Target); - data << uint64(Caster); - data << uint32(ItemID); - data << uint32(SpellID); - data << uint8(0); - SendPacket(&data); + WorldPacket data(SMSG_ENCHANTMENTLOG, (8+8+4+4)); // last check 2.0.10 + data.appendPackGUID(target); + data.appendPackGUID(caster); + data << uint32(itemId); + data << uint32(enchantId); + GetPlayer()->SendMessageToSet(&data, true); } void WorldSession::SendItemEnchantTimeUpdate(uint64 Playerguid, uint64 Itemguid, uint32 slot, uint32 Duration) @@ -1334,7 +1333,7 @@ void WorldSession::HandleSocketOpcode(WorldPacket& recvData) { if (GemEnchants[i]) { - itemTarget->SetEnchantment(EnchantmentSlot(SOCK_ENCHANTMENT_SLOT+i), GemEnchants[i], 0, 0); + itemTarget->SetEnchantment(EnchantmentSlot(SOCK_ENCHANTMENT_SLOT+i), GemEnchants[i], 0, 0, _player->GetGUID()); if (Item* guidItem = _player->GetItemByGuid(gem_guids[i])) _player->DestroyItem(guidItem->GetBagSlot(), guidItem->GetSlot(), true); } @@ -1347,7 +1346,7 @@ void WorldSession::HandleSocketOpcode(WorldPacket& recvData) if (SocketBonusActivated ^ SocketBonusToBeActivated) //if there was a change... { _player->ApplyEnchantment(itemTarget, BONUS_ENCHANTMENT_SLOT, false); - itemTarget->SetEnchantment(BONUS_ENCHANTMENT_SLOT, (SocketBonusToBeActivated ? itemTarget->GetTemplate()->socketBonus : 0), 0, 0); + itemTarget->SetEnchantment(BONUS_ENCHANTMENT_SLOT, (SocketBonusToBeActivated ? itemTarget->GetTemplate()->socketBonus : 0), 0, 0, _player->GetGUID()); _player->ApplyEnchantment(itemTarget, BONUS_ENCHANTMENT_SLOT, true); //it is not displayed, client has an inbuilt system to determine if the bonus is activated } @@ -1356,6 +1355,8 @@ void WorldSession::HandleSocketOpcode(WorldPacket& recvData) _player->RemoveTradeableItem(itemTarget); itemTarget->ClearSoulboundTradeable(_player); // clear tradeable flag + + itemTarget->SendUpdateSockets(); } void WorldSession::HandleCancelTempEnchantmentOpcode(WorldPacket& recvData) diff --git a/src/server/game/Handlers/QuestHandler.cpp b/src/server/game/Handlers/QuestHandler.cpp index 4e4ec1350cb..43a0b083b91 100644 --- a/src/server/game/Handlers/QuestHandler.cpp +++ b/src/server/game/Handlers/QuestHandler.cpp @@ -580,7 +580,7 @@ void WorldSession::HandlePushQuestToParty(WorldPacket& recvPacket) continue; } - player->PlayerTalkClass->SendQuestGiverQuestDetails(quest, player->GetGUID(), true); + player->PlayerTalkClass->SendQuestGiverQuestDetails(quest, _player->GetGUID(), true); player->SetDivider(_player->GetGUID()); } } diff --git a/src/server/game/Movement/MotionMaster.h b/src/server/game/Movement/MotionMaster.h index f2f3959dba5..156813f56fb 100644 --- a/src/server/game/Movement/MotionMaster.h +++ b/src/server/game/Movement/MotionMaster.h @@ -153,8 +153,8 @@ class MotionMaster //: private std::stack<MovementGenerator *> void MoveChase(Unit* target, float dist = 0.0f, float angle = 0.0f); void MoveConfused(); void MoveFleeing(Unit* enemy, uint32 time = 0); - void MovePoint(uint32 id, const Position &pos) - { MovePoint(id, pos.m_positionX, pos.m_positionY, pos.m_positionZ); } + void MovePoint(uint32 id, Position const& pos, bool generatePath = true) + { MovePoint(id, pos.m_positionX, pos.m_positionY, pos.m_positionZ, generatePath); } void MovePoint(uint32 id, float x, float y, float z, bool generatePath = true); // These two movement types should only be used with creatures having landing/takeoff animations diff --git a/src/server/game/Movement/MovementGenerators/PointMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/PointMovementGenerator.cpp index ea7a8c4c710..227780daa1f 100755 --- a/src/server/game/Movement/MovementGenerators/PointMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/PointMovementGenerator.cpp @@ -24,6 +24,7 @@ #include "MoveSplineInit.h" #include "MoveSpline.h" #include "Player.h" +#include "CreatureGroups.h" //----- Point Movement Generator template<class T> @@ -42,6 +43,11 @@ void PointMovementGenerator<T>::DoInitialize(T* unit) if (speed > 0.0f) init.SetVelocity(speed); init.Launch(); + + //Call for creature group update + if (Creature* creature = unit->ToCreature()) + if (creature->GetFormation() && creature->GetFormation()->getLeader() == creature) + creature->GetFormation()->LeaderMoveTo(i_x, i_y, i_z); } template<class T> @@ -66,6 +72,11 @@ bool PointMovementGenerator<T>::DoUpdate(T* unit, uint32 /*diff*/) if (speed > 0.0f) // Default value for point motion type is 0.0, if 0.0 spline will use GetSpeed on unit init.SetVelocity(speed); init.Launch(); + + //Call for creature group update + if (Creature* creature = unit->ToCreature()) + if (creature->GetFormation() && creature->GetFormation()->getLeader() == creature) + creature->GetFormation()->LeaderMoveTo(i_x, i_y, i_z); } return !unit->movespline->Finalized(); diff --git a/src/server/game/Movement/Spline/MoveSplineInit.cpp b/src/server/game/Movement/Spline/MoveSplineInit.cpp index 49a33a4f79e..2f4224c8b91 100644 --- a/src/server/game/Movement/Spline/MoveSplineInit.cpp +++ b/src/server/game/Movement/Spline/MoveSplineInit.cpp @@ -29,11 +29,7 @@ namespace Movement { UnitMoveType SelectSpeedType(uint32 moveFlags) { - /*! Not sure about MOVEMENTFLAG_CAN_FLY here - do creatures that can fly - but are on ground right now also have it? If yes, this needs a more - dynamic check, such as is flying now - */ - if (moveFlags & (MOVEMENTFLAG_FLYING | MOVEMENTFLAG_CAN_FLY | MOVEMENTFLAG_DISABLE_GRAVITY)) + if (moveFlags & MOVEMENTFLAG_FLYING) { if (moveFlags & MOVEMENTFLAG_BACKWARD /*&& speed_obj.flight >= speed_obj.flight_back*/) return MOVE_FLIGHT_BACK; @@ -55,6 +51,8 @@ namespace Movement else if (moveFlags & MOVEMENTFLAG_BACKWARD /*&& speed_obj.run >= speed_obj.run_back*/) return MOVE_RUN_BACK; + // Flying creatures use MOVEMENTFLAG_CAN_FLY or MOVEMENTFLAG_DISABLE_GRAVITY + // Run speed is their default flight speed. return MOVE_RUN; } @@ -90,22 +88,25 @@ namespace Movement move_spline.onTransport = transport; uint32 moveFlags = unit->m_movementInfo.GetMovementFlags(); - if (args.flags.walkmode) - moveFlags |= MOVEMENTFLAG_WALKING; - else - moveFlags &= ~MOVEMENTFLAG_WALKING; - moveFlags |= (MOVEMENTFLAG_SPLINE_ENABLED|MOVEMENTFLAG_FORWARD); + if (moveFlags & MOVEMENTFLAG_ROOT) + moveFlags &= ~MOVEMENTFLAG_MASK_MOVING; + if (!args.HasVelocity) - args.velocity = unit->GetSpeed(SelectSpeedType(moveFlags)); + { + // If spline is initialized with SetWalk method it only means we need to select + // walk move speed for it but not add walk flag to unit + uint32 moveFlagsForSpeed = moveFlags; + if (args.flags.walkmode) + moveFlagsForSpeed |= MOVEMENTFLAG_WALKING; + + args.velocity = unit->GetSpeed(SelectSpeedType(moveFlagsForSpeed)); + } if (!args.Validate(unit)) return 0; - if (moveFlags & MOVEMENTFLAG_ROOT) - moveFlags &= ~MOVEMENTFLAG_MASK_MOVING; - unit->m_movementInfo.SetMovementFlags((MovementFlags)moveFlags); move_spline.Initialize(args); @@ -175,13 +176,8 @@ namespace Movement Vector3 TransportPathTransform::operator()(Vector3 input) { if (_transformForTransport) - { if (TransportBase* transport = _owner->GetDirectTransport()) - { - float unused = 0.0f; // need reference - transport->CalculatePassengerOffset(input.x, input.y, input.z, unused); - } - } + transport->CalculatePassengerOffset(input.x, input.y, input.z); return input; } diff --git a/src/server/game/Server/Protocol/Opcodes.cpp b/src/server/game/Server/Protocol/Opcodes.cpp index 7237d5f74f7..065b80cb08f 100644 --- a/src/server/game/Server/Protocol/Opcodes.cpp +++ b/src/server/game/Server/Protocol/Opcodes.cpp @@ -1317,7 +1317,7 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x508*/ { "CMSG_SET_ALLOW_LOW_LEVEL_RAID1", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, /*0x509*/ { "CMSG_SET_ALLOW_LOW_LEVEL_RAID2", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, /*0x50A*/ { "SMSG_CAMERA_SHAKE", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, - /*0x50B*/ { "SMSG_UPDATE_ITEM_ENCHANTMENTS", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, + /*0x50B*/ { "SMSG_SOCKET_GEMS_RESULT", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x50C*/ { "CMSG_SET_CHARACTER_MODEL", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, /*0x50D*/ { "SMSG_REDIRECT_CLIENT", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x50E*/ { "CMSG_REDIRECTION_FAILED", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, diff --git a/src/server/game/Server/Protocol/Opcodes.h b/src/server/game/Server/Protocol/Opcodes.h index 30c5b1dcdf4..254f9fe5350 100644 --- a/src/server/game/Server/Protocol/Opcodes.h +++ b/src/server/game/Server/Protocol/Opcodes.h @@ -1325,7 +1325,7 @@ enum Opcodes CMSG_SET_ALLOW_LOW_LEVEL_RAID1 = 0x508, CMSG_SET_ALLOW_LOW_LEVEL_RAID2 = 0x509, SMSG_CAMERA_SHAKE = 0x50A, // uint32 SpellEffectCameraShakes.dbc index, uint32 - SMSG_UPDATE_ITEM_ENCHANTMENTS = 0x50B, // some item update packet? + SMSG_SOCKET_GEMS_RESULT = 0x50B, CMSG_SET_CHARACTER_MODEL = 0x50C, SMSG_REDIRECT_CLIENT = 0x50D, // uint32 ip, uint16 port, uint32 unk, uint8[20] hash (ip + port, seed=sessionkey) CMSG_REDIRECTION_FAILED = 0x50E, // something with networking diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h index b714cd71e6d..bf79b34822d 100644 --- a/src/server/game/Server/WorldSession.h +++ b/src/server/game/Server/WorldSession.h @@ -322,7 +322,7 @@ class WorldSession void SendAuctionOwnerNotification(AuctionEntry* auction); //Item Enchantment - void SendEnchantmentLog(uint64 Target, uint64 Caster, uint32 ItemID, uint32 SpellID); + void SendEnchantmentLog(uint64 target, uint64 caster, uint32 itemId, uint32 enchantId); void SendItemEnchantTimeUpdate(uint64 Playerguid, uint64 Itemguid, uint32 slot, uint32 Duration); //Taxi diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index db6263a8062..64a538dce86 100644 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -2771,7 +2771,7 @@ void Spell::EffectEnchantItemPerm(SpellEffIndex effIndex) // remove old enchanting before applying new if equipped item_owner->ApplyEnchantment(itemTarget, PERM_ENCHANTMENT_SLOT, false); - itemTarget->SetEnchantment(PERM_ENCHANTMENT_SLOT, enchant_id, 0, 0); + itemTarget->SetEnchantment(PERM_ENCHANTMENT_SLOT, enchant_id, 0, 0, m_caster->GetGUID()); // add new enchanting if equipped item_owner->ApplyEnchantment(itemTarget, PERM_ENCHANTMENT_SLOT, true); @@ -2836,7 +2836,7 @@ void Spell::EffectEnchantItemPrismatic(SpellEffIndex effIndex) // remove old enchanting before applying new if equipped item_owner->ApplyEnchantment(itemTarget, PRISMATIC_ENCHANTMENT_SLOT, false); - itemTarget->SetEnchantment(PRISMATIC_ENCHANTMENT_SLOT, enchant_id, 0, 0); + itemTarget->SetEnchantment(PRISMATIC_ENCHANTMENT_SLOT, enchant_id, 0, 0, m_caster->GetGUID()); // add new enchanting if equipped item_owner->ApplyEnchantment(itemTarget, PRISMATIC_ENCHANTMENT_SLOT, true); @@ -2970,7 +2970,7 @@ void Spell::EffectEnchantItemTmp(SpellEffIndex effIndex) // remove old enchanting before applying new if equipped item_owner->ApplyEnchantment(itemTarget, TEMP_ENCHANTMENT_SLOT, false); - itemTarget->SetEnchantment(TEMP_ENCHANTMENT_SLOT, enchant_id, duration * 1000, 0); + itemTarget->SetEnchantment(TEMP_ENCHANTMENT_SLOT, enchant_id, duration * 1000, 0, m_caster->GetGUID()); // add new enchanting if equipped item_owner->ApplyEnchantment(itemTarget, TEMP_ENCHANTMENT_SLOT, true); @@ -4521,7 +4521,7 @@ void Spell::EffectEnchantHeldItem(SpellEffIndex effIndex) if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) return; - Player* item_owner = (Player*)unitTarget; + Player* item_owner = unitTarget->ToPlayer(); Item* item = item_owner->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND); if (!item) @@ -4552,7 +4552,7 @@ void Spell::EffectEnchantHeldItem(SpellEffIndex effIndex) return; // Apply the temporary enchantment - item->SetEnchantment(slot, enchant_id, duration*IN_MILLISECONDS, 0); + item->SetEnchantment(slot, enchant_id, duration*IN_MILLISECONDS, 0, m_caster->GetGUID()); item_owner->ApplyEnchantment(item, slot, true); } } diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp index 026c61d4965..9cedfdf922f 100644 --- a/src/server/game/Spells/SpellMgr.cpp +++ b/src/server/game/Spells/SpellMgr.cpp @@ -499,6 +499,9 @@ uint32 SpellMgr::GetSpellIdForDifficulty(uint32 spellId, Unit const* caster) con SpellInfo const* SpellMgr::GetSpellForDifficultyFromSpell(SpellInfo const* spell, Unit const* caster) const { + if (!spell) + return NULL; + uint32 newSpellId = GetSpellIdForDifficulty(spell->Id, caster); SpellInfo const* newSpell = GetSpellInfo(newSpellId); if (!newSpell) diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp index 80577c3462e..9d2ee2eb2ba 100644 --- a/src/server/game/World/World.cpp +++ b/src/server/game/World/World.cpp @@ -2675,14 +2675,12 @@ void World::SendAutoBroadcast() if (abcenter == 0) sWorld->SendWorldText(LANG_AUTO_BROADCAST, msg.c_str()); - else if (abcenter == 1) { WorldPacket data(SMSG_NOTIFICATION, (msg.size()+1)); data << msg; sWorld->SendGlobalMessage(&data); } - else if (abcenter == 2) { sWorld->SendWorldText(LANG_AUTO_BROADCAST, msg.c_str()); diff --git a/src/server/scripts/Commands/cs_server.cpp b/src/server/scripts/Commands/cs_server.cpp index 309380a9cbb..11b4ebf33ae 100644 --- a/src/server/scripts/Commands/cs_server.cpp +++ b/src/server/scripts/Commands/cs_server.cpp @@ -338,7 +338,8 @@ public: } else sWorld->ShutdownServ(time, SHUTDOWN_MASK_IDLE, SHUTDOWN_EXIT_CODE); - return true; + + return true; } // Exit the realm diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp index 9e312ef8f94..b6b701c513d 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp @@ -716,27 +716,27 @@ public: if (CheckTimer <= diff) { Creature* Kalec = Unit::GetCreature(*me, KalecGUID); - if (!Kalec || (Kalec && !Kalec->isAlive())) + if (!Kalec || !Kalec->isAlive()) { if (Creature* Kalecgos = Unit::GetCreature(*me, KalecgosGUID)) Kalecgos->AI()->EnterEvadeMode(); - return; + return; } + if (HealthBelowPct(10) && !isEnraged) { if (Creature* Kalecgos = Unit::GetCreature(*me, KalecgosGUID)) Kalecgos->AI()->DoAction(DO_ENRAGE); DoAction(DO_ENRAGE); } + Creature* Kalecgos = Unit::GetCreature(*me, KalecgosGUID); - if (Kalecgos) + if (Kalecgos && !Kalecgos->isInCombat()) { - if (!Kalecgos->isInCombat()) - { - me->AI()->EnterEvadeMode(); - return; - } + me->AI()->EnterEvadeMode(); + return; } + if (!isBanished && HealthBelowPct(1)) { if (Kalecgos) @@ -746,8 +746,7 @@ public: me->DealDamage(me, me->GetHealth()); return; } - else - DoAction(DO_BANISH); + DoAction(DO_BANISH); } else { diff --git a/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/instance_halls_of_reflection.cpp b/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/instance_halls_of_reflection.cpp index 0e2308a8e1a..bff18b508d5 100644 --- a/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/instance_halls_of_reflection.cpp +++ b/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/instance_halls_of_reflection.cpp @@ -267,8 +267,8 @@ public: case NPC_WAVE_MAGE: { uint32 deadNpcs = 0; - uint32 internalWaveId = _waveCount - ((_waveCount < 5) ? 1 : 2); - for (std::set<uint64>::const_iterator itr = waveGuidList[internalWaveId].begin(); itr != waveGuidList[internalWaveId].end(); ++itr) + uint32 waveId = creature->AI()->GetData(0); + for (std::set<uint64>::const_iterator itr = waveGuidList[waveId].begin(); itr != waveGuidList[waveId].end(); ++itr) { Creature* npc = instance->GetCreature(*itr); if (!npc || !npc->isAlive()) @@ -277,7 +277,7 @@ public: // because the current npc returns isAlive when OnUnitDeath happens // we check if the number of dead npcs is equal to the list-1 - if (deadNpcs == waveGuidList[internalWaveId].size() - 1) + if (deadNpcs == waveGuidList[waveId].size() - 1) { ++_waveCount; events.ScheduleEvent(EVENT_NEXT_WAVE, 10000); @@ -322,7 +322,7 @@ public: possibilityList.push_back(NPC_WAVE_MAGE); // iterate each wave - for (uint8 i = 0; i < 8; i++) + for (uint8 i = 0; i < 8; ++i) { tempList = possibilityList; diff --git a/src/server/scripts/Northrend/Gundrak/gundrak.h b/src/server/scripts/Northrend/Gundrak/gundrak.h index 0c65b4d16de..a43edb4fcd7 100644 --- a/src/server/scripts/Northrend/Gundrak/gundrak.h +++ b/src/server/scripts/Northrend/Gundrak/gundrak.h @@ -43,12 +43,31 @@ enum Data64 enum mainCreatures { - CREATURE_RUIN_DWELLER = 29920, - CREATURE_SLAD_RAN = 29304, - CREATURE_MOORABI = 29305, - CREATURE_GALDARAH = 29306, - CREATURE_DRAKKARICOLOSSUS = 29307, - CREATURE_ECK = 29932 + CREATURE_RUIN_DWELLER = 29920, + CREATURE_SLAD_RAN = 29304, + CREATURE_MOORABI = 29305, + CREATURE_GALDARAH = 29306, + CREATURE_DRAKKARICOLOSSUS = 29307, + CREATURE_ECK = 29932 +}; + +enum Gameobjects { + + GO_SLADRAN_ALTAR = 192518, + GO_MOORABI_ALTAR = 192519, + GO_DRAKKARI_COLOSSUS_ALTAR = 192520, + GO_SLADRAN_STATUE = 192564, + GO_MOORABI_STATUE = 192565, + GO_GALDARAH_STATUE = 192566, + GO_DRAKKARI_COLOSSUS_STATUE = 192567, + GO_ECK_THE_FEROCIOUS_DOOR = 192632, + GO_ECK_THE_FEROCIOUS_DOOR_BEHIND = 192569, + GO_GALDARAH_DOOR1 = 193208, + GO_GALDARAH_DOOR2 = 193209, + GO_GALDARAH_DOOR3 = 192568, + GO_BRIDGE = 193188, + GO_COLLISION = 192633 + }; #endif diff --git a/src/server/scripts/Northrend/Gundrak/instance_gundrak.cpp b/src/server/scripts/Northrend/Gundrak/instance_gundrak.cpp index a9bbffa5fb0..d17198b0c92 100644 --- a/src/server/scripts/Northrend/Gundrak/instance_gundrak.cpp +++ b/src/server/scripts/Northrend/Gundrak/instance_gundrak.cpp @@ -45,44 +45,45 @@ public: { instance_gundrak_InstanceMapScript(Map* map) : InstanceScript(map) { - bHeroicMode = map->IsHeroic(); + isHeroic = map->IsHeroic(); } - bool bHeroicMode; + bool isHeroic; bool spawnSupport; uint32 timer; uint32 phase; uint64 toActivate; - uint64 uiSladRan; - uint64 uiMoorabi; - uint64 uiDrakkariColossus; - uint64 uiGalDarah; - uint64 uiEckTheFerocious; - - uint64 uiSladRanAltar; - uint64 uiMoorabiAltar; - uint64 uiDrakkariColossusAltar; - uint64 uiSladRanStatue; - uint64 uiMoorabiStatue; - uint64 uiDrakkariColossusStatue; - uint64 uiGalDarahStatue; - uint64 uiEckTheFerociousDoor; - uint64 uiEckTheFerociousDoorBehind; - uint64 uiGalDarahDoor1; - uint64 uiGalDarahDoor2; - uint64 uiBridge; - uint64 uiCollision; + uint64 sladRanGUID; + uint64 moorabiGUID; + uint64 drakkariColossusGUID; + uint64 galDarahGUID; + uint64 eckTheFerociousGUID; + + uint64 sladRanAltarGUID; + uint64 moorabiAltarGUID; + uint64 drakkariColossusAltarGUID; + uint64 sladRanStatueGUID; + uint64 moorabiStatueGUID; + uint64 drakkariColossusStatueGUID; + uint64 galDarahStatueGUID; + uint64 eckTheFerociousDoorGUID; + uint64 eckTheFerociousDoorBehindGUID; + uint64 galDarahDoor1GUID; + uint64 galDarahDoor2GUID; + uint64 galDarahDoor3GUID; + uint64 bridgeGUID; + uint64 collisionGUID; uint32 m_auiEncounter[MAX_ENCOUNTER]; - GOState uiSladRanStatueState; - GOState uiMoorabiStatueState; - GOState uiDrakkariColossusStatueState; - GOState uiGalDarahStatueState; - GOState uiBridgeState; - GOState uiCollisionState; + GOState sladRanStatueState; + GOState moorabiStatueState; + GOState drakkariColossusStatueState; + GOState galDarahStatueState; + GOState bridgeState; + GOState collisionState; std::set<uint64> DwellerGUIDs; @@ -96,35 +97,36 @@ public: phase = 0; toActivate = 0; - uiSladRan = 0; - uiMoorabi = 0; - uiDrakkariColossus = 0; - uiGalDarah = 0; - uiEckTheFerocious = 0; - - uiSladRanAltar = 0; - uiMoorabiAltar = 0; - uiDrakkariColossusAltar = 0; - - uiSladRanStatue = 0; - uiMoorabiStatue = 0; - uiDrakkariColossusStatue = 0; - uiGalDarahStatue = 0; - - uiEckTheFerociousDoor = 0; - uiEckTheFerociousDoorBehind = 0; - uiGalDarahDoor1 = 0; - uiGalDarahDoor2 = 0; - - uiBridge = 0; - uiCollision = 0; - - uiSladRanStatueState = GO_STATE_ACTIVE; - uiMoorabiStatueState = GO_STATE_ACTIVE; - uiDrakkariColossusStatueState = GO_STATE_ACTIVE; - uiGalDarahStatueState = GO_STATE_READY; - uiBridgeState = GO_STATE_ACTIVE; - uiCollisionState = GO_STATE_READY; + sladRanGUID = 0; + moorabiGUID = 0; + drakkariColossusGUID = 0; + galDarahGUID = 0; + eckTheFerociousGUID = 0; + + sladRanAltarGUID = 0; + moorabiAltarGUID = 0; + drakkariColossusAltarGUID = 0; + + sladRanStatueGUID = 0; + moorabiStatueGUID = 0; + drakkariColossusStatueGUID = 0; + galDarahStatueGUID = 0; + + eckTheFerociousDoorGUID = 0; + eckTheFerociousDoorBehindGUID = 0; + galDarahDoor1GUID = 0; + galDarahDoor2GUID = 0; + galDarahDoor3GUID = 0; + + bridgeGUID = 0; + collisionGUID = 0; + + sladRanStatueState = GO_STATE_ACTIVE; + moorabiStatueState = GO_STATE_ACTIVE; + drakkariColossusStatueState = GO_STATE_ACTIVE; + galDarahStatueState = GO_STATE_READY; + bridgeState = GO_STATE_ACTIVE; + collisionState = GO_STATE_READY; DwellerGUIDs.clear(); @@ -144,11 +146,21 @@ public: { switch (creature->GetEntry()) { - case CREATURE_SLAD_RAN: uiSladRan = creature->GetGUID(); break; - case CREATURE_MOORABI: uiMoorabi = creature->GetGUID(); break; - case CREATURE_GALDARAH: uiGalDarah = creature->GetGUID(); break; - case CREATURE_DRAKKARICOLOSSUS: uiDrakkariColossus = creature->GetGUID(); break; - case CREATURE_ECK: uiEckTheFerocious = creature->GetGUID(); break; + case CREATURE_SLAD_RAN: + sladRanGUID = creature->GetGUID(); + break; + case CREATURE_MOORABI: + moorabiGUID = creature->GetGUID(); + break; + case CREATURE_GALDARAH: + galDarahGUID = creature->GetGUID(); + break; + case CREATURE_DRAKKARICOLOSSUS: + drakkariColossusGUID = creature->GetGUID(); + break; + case CREATURE_ECK: + eckTheFerociousGUID = creature->GetGUID(); + break; case CREATURE_RUIN_DWELLER: if (creature->isAlive()) DwellerGUIDs.insert(creature->GetGUID()); @@ -160,13 +172,13 @@ public: { switch (go->GetEntry()) { - case 192518: - uiSladRanAltar = go->GetGUID(); + case GO_SLADRAN_ALTAR: + sladRanAltarGUID = go->GetGUID(); // Make sure that they start out as unusuable go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); if (m_auiEncounter[0] == DONE) { - if (uiSladRanStatueState == GO_STATE_ACTIVE) + if (sladRanStatueState == GO_STATE_ACTIVE) go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); else { @@ -175,13 +187,13 @@ public: } } break; - case 192519: - uiMoorabiAltar = go->GetGUID(); + case GO_MOORABI_ALTAR: + moorabiAltarGUID = go->GetGUID(); // Make sure that they start out as unusuable go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); if (m_auiEncounter[0] == DONE) { - if (uiMoorabiStatueState == GO_STATE_ACTIVE) + if (moorabiStatueState == GO_STATE_ACTIVE) go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); else { @@ -190,13 +202,13 @@ public: } } break; - case 192520: - uiDrakkariColossusAltar = go->GetGUID(); + case GO_DRAKKARI_COLOSSUS_ALTAR: + drakkariColossusAltarGUID = go->GetGUID(); // Make sure that they start out as unusuable go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); if (m_auiEncounter[0] == DONE) { - if (uiDrakkariColossusStatueState == GO_STATE_ACTIVE) + if (drakkariColossusStatueState == GO_STATE_ACTIVE) go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); else { @@ -205,53 +217,58 @@ public: } } break; - case 192564: - uiSladRanStatue = go->GetGUID(); - go->SetGoState(uiSladRanStatueState); + case GO_SLADRAN_STATUE: + sladRanStatueGUID = go->GetGUID(); + go->SetGoState(sladRanStatueState); break; - case 192565: - uiMoorabiStatue = go->GetGUID(); - go->SetGoState(uiMoorabiStatueState); + case GO_MOORABI_STATUE: + moorabiStatueGUID = go->GetGUID(); + go->SetGoState(moorabiStatueState); break; - case 192566: - uiGalDarahStatue = go->GetGUID(); - go->SetGoState(uiGalDarahStatueState); + case GO_GALDARAH_STATUE: + galDarahStatueGUID = go->GetGUID(); + go->SetGoState(galDarahStatueState); break; - case 192567: - uiDrakkariColossusStatue = go->GetGUID(); - go->SetGoState(uiDrakkariColossusStatueState); + case GO_DRAKKARI_COLOSSUS_STATUE: + drakkariColossusStatueGUID = go->GetGUID(); + go->SetGoState(drakkariColossusStatueState); break; - case 192632: - uiEckTheFerociousDoor = go->GetGUID(); - if (bHeroicMode && m_auiEncounter[1] == DONE) + case GO_ECK_THE_FEROCIOUS_DOOR: + eckTheFerociousDoorGUID = go->GetGUID(); + if (isHeroic && m_auiEncounter[1] == DONE) HandleGameObject(0, true, go); break; - case 192569: - uiEckTheFerociousDoorBehind = go->GetGUID(); - if (bHeroicMode && m_auiEncounter[4] == DONE) + case GO_ECK_THE_FEROCIOUS_DOOR_BEHIND: + eckTheFerociousDoorBehindGUID = go->GetGUID(); + if (isHeroic && m_auiEncounter[4] == DONE) HandleGameObject(0, true, go); - case 193208: - uiGalDarahDoor1 = go->GetGUID(); + case GO_GALDARAH_DOOR1: + galDarahDoor1GUID = go->GetGUID(); if (m_auiEncounter[3] == DONE) HandleGameObject(0, true, go); break; - case 193209: - uiGalDarahDoor2 = go->GetGUID(); + case GO_GALDARAH_DOOR2: + galDarahDoor2GUID = go->GetGUID(); if (m_auiEncounter[3] == DONE) HandleGameObject(0, true, go); break; - case 193188: - uiBridge = go->GetGUID(); - go->SetGoState(uiBridgeState); + case GO_BRIDGE: + bridgeGUID = go->GetGUID(); + go->SetGoState(bridgeState); break; - case 192633: - uiCollision = go->GetGUID(); - go->SetGoState(uiCollisionState); + case GO_COLLISION: + collisionGUID = go->GetGUID(); + go->SetGoState(collisionState); // Can't spawn here with SpawnGameObject because go isn't added to world yet... - if (uiCollisionState == GO_STATE_ACTIVE_ALTERNATIVE) + if (collisionState == GO_STATE_ACTIVE_ALTERNATIVE) spawnSupport = true; break; + case GO_GALDARAH_DOOR3: + galDarahDoor3GUID = go->GetGUID(); + if (m_auiEncounter[3] != IN_PROGRESS) + HandleGameObject(galDarahDoor3GUID, true, go); + break; } } @@ -263,7 +280,7 @@ public: m_auiEncounter[0] = data; if (data == DONE) { - GameObject* go = instance->GetGameObject(uiSladRanAltar); + GameObject* go = instance->GetGameObject(sladRanAltarGUID); if (go) go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); } @@ -272,18 +289,18 @@ public: m_auiEncounter[1] = data; if (data == DONE) { - GameObject* go = instance->GetGameObject(uiMoorabiAltar); + GameObject* go = instance->GetGameObject(moorabiAltarGUID); if (go) go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); - if (bHeroicMode) - HandleGameObject(uiEckTheFerociousDoor, true); + if (isHeroic) + HandleGameObject(eckTheFerociousDoorGUID, true); } break; case DATA_DRAKKARI_COLOSSUS_EVENT: m_auiEncounter[2] = data; if (data == DONE) { - GameObject* go = instance->GetGameObject(uiDrakkariColossusAltar); + GameObject* go = instance->GetGameObject(drakkariColossusAltarGUID); if (go) go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); } @@ -292,14 +309,15 @@ public: m_auiEncounter[3] = data; if (data == DONE) { - HandleGameObject(uiGalDarahDoor1, true); - HandleGameObject(uiGalDarahDoor2, true); + HandleGameObject(galDarahDoor1GUID, true); + HandleGameObject(galDarahDoor2GUID, true); } + HandleGameObject(galDarahDoor3GUID, data == IN_PROGRESS ? false : true); break; case DATA_ECK_THE_FEROCIOUS_EVENT: m_auiEncounter[4] = data; - if (bHeroicMode && data == DONE) - HandleGameObject(uiEckTheFerociousDoorBehind, true); + if (isHeroic && data == DONE) + HandleGameObject(eckTheFerociousDoorBehindGUID, true); break; } @@ -345,19 +363,19 @@ public: switch (type) { case DATA_SLAD_RAN_ALTAR: - return uiSladRanAltar; + return sladRanAltarGUID; case DATA_MOORABI_ALTAR: - return uiMoorabiAltar; + return moorabiAltarGUID; case DATA_DRAKKARI_COLOSSUS_ALTAR: - return uiDrakkariColossusAltar; + return drakkariColossusAltarGUID; case DATA_SLAD_RAN_STATUE: - return uiSladRanStatue; + return sladRanStatueGUID; case DATA_MOORABI_STATUE: - return uiMoorabiStatue; + return moorabiStatueGUID; case DATA_DRAKKARI_COLOSSUS_STATUE: - return uiDrakkariColossusStatue; + return drakkariColossusStatueGUID; case DATA_DRAKKARI_COLOSSUS: - return uiDrakkariColossus; + return drakkariColossusGUID; case DATA_STATUE_ACTIVATE: return toActivate; } @@ -372,9 +390,9 @@ public: std::ostringstream saveStream; saveStream << "G D " << m_auiEncounter[0] << ' ' << m_auiEncounter[1] << ' ' << m_auiEncounter[2] << ' ' << m_auiEncounter[3] << ' ' << m_auiEncounter[4] << ' ' - << (uiSladRanStatue ? GetObjState(uiSladRanStatue) : GO_STATE_ACTIVE) << ' ' << (uiMoorabiStatue ? GetObjState(uiMoorabiStatue) : GO_STATE_ACTIVE) << ' ' - << (uiDrakkariColossusStatue ? GetObjState(uiDrakkariColossusStatue) : GO_STATE_ACTIVE) << ' ' << (uiGalDarahStatue ? GetObjState(uiGalDarahStatue) : GO_STATE_READY) << ' ' - << (uiBridge ? GetObjState(uiBridge) : GO_STATE_ACTIVE) << ' ' << (uiCollision ? GetObjState(uiCollision) : GO_STATE_READY); + << (sladRanStatueGUID ? GetObjState(sladRanStatueGUID) : GO_STATE_ACTIVE) << ' ' << (moorabiStatueGUID ? GetObjState(moorabiStatueGUID) : GO_STATE_ACTIVE) << ' ' + << (drakkariColossusStatueGUID ? GetObjState(drakkariColossusStatueGUID) : GO_STATE_ACTIVE) << ' ' << (galDarahStatueGUID ? GetObjState(galDarahStatueGUID) : GO_STATE_READY) << ' ' + << (bridgeGUID ? GetObjState(bridgeGUID) : GO_STATE_ACTIVE) << ' ' << (collisionGUID ? GetObjState(collisionGUID) : GO_STATE_READY); str_data = saveStream.str(); @@ -406,12 +424,12 @@ public: m_auiEncounter[2] = data2; m_auiEncounter[3] = data3; m_auiEncounter[4] = data4; - uiSladRanStatueState = GOState(data5); - uiMoorabiStatueState = GOState(data6); - uiDrakkariColossusStatueState = GOState(data7); - uiGalDarahStatueState = GOState(data8); - uiBridgeState = GOState(data9); - uiCollisionState = GOState(data10); + sladRanStatueState = GOState(data5); + moorabiStatueState = GOState(data6); + drakkariColossusStatueState = GOState(data7); + galDarahStatueState = GOState(data8); + bridgeState = GOState(data9); + collisionState = GOState(data10); for (uint8 i = 0; i < MAX_ENCOUNTER; ++i) if (m_auiEncounter[i] == IN_PROGRESS) @@ -426,8 +444,8 @@ public: // Spawn the support for the bridge if necessary if (spawnSupport) { - if (GameObject* pCollision = instance->GetGameObject(uiCollision)) - pCollision->SummonGameObject(192743, pCollision->GetPositionX(), pCollision->GetPositionY(), pCollision->GetPositionZ(), pCollision->GetOrientation(), 0, 0, 0, 0, 0); + if (GameObject* collision = instance->GetGameObject(collisionGUID)) + collision->SummonGameObject(192743, collision->GetPositionX(), collision->GetPositionY(), collision->GetPositionZ(), collision->GetOrientation(), 0, 0, 0, 0, 0); spawnSupport = false; } @@ -438,25 +456,25 @@ public: if (timer < diff) { timer = 0; - if (toActivate == uiBridge) + if (toActivate == bridgeGUID) { - GameObject* pBridge = instance->GetGameObject(uiBridge); - GameObject* pCollision = instance->GetGameObject(uiCollision); - GameObject* pSladRanStatue = instance->GetGameObject(uiSladRanStatue); - GameObject* pMoorabiStatue = instance->GetGameObject(uiMoorabiStatue); - GameObject* pDrakkariColossusStatue = instance->GetGameObject(uiDrakkariColossusStatue); - GameObject* pGalDarahStatue = instance->GetGameObject(uiGalDarahStatue); + GameObject* bridge = instance->GetGameObject(bridgeGUID); + GameObject* collision = instance->GetGameObject(collisionGUID); + GameObject* sladRanStatue = instance->GetGameObject(sladRanStatueGUID); + GameObject* moorabiStatue = instance->GetGameObject(moorabiStatueGUID); + GameObject* drakkariColossusStatue = instance->GetGameObject(drakkariColossusStatueGUID); + GameObject* galDarahStatue = instance->GetGameObject(galDarahStatueGUID); toActivate = 0; - if (pBridge && pCollision && pSladRanStatue && pMoorabiStatue && pDrakkariColossusStatue && pGalDarahStatue) + if (bridge && collision && sladRanStatue && moorabiStatue && drakkariColossusStatue && galDarahStatue) { - pBridge->SetGoState(GO_STATE_ACTIVE_ALTERNATIVE); - pCollision->SetGoState(GO_STATE_ACTIVE_ALTERNATIVE); - pSladRanStatue->SetGoState(GO_STATE_ACTIVE_ALTERNATIVE); - pMoorabiStatue->SetGoState(GO_STATE_ACTIVE_ALTERNATIVE); - pDrakkariColossusStatue->SetGoState(GO_STATE_ACTIVE_ALTERNATIVE); - pGalDarahStatue->SetGoState(GO_STATE_ACTIVE_ALTERNATIVE); + bridge->SetGoState(GO_STATE_ACTIVE_ALTERNATIVE); + collision->SetGoState(GO_STATE_ACTIVE_ALTERNATIVE); + sladRanStatue->SetGoState(GO_STATE_ACTIVE_ALTERNATIVE); + moorabiStatue->SetGoState(GO_STATE_ACTIVE_ALTERNATIVE); + drakkariColossusStatue->SetGoState(GO_STATE_ACTIVE_ALTERNATIVE); + galDarahStatue->SetGoState(GO_STATE_ACTIVE_ALTERNATIVE); // Add the GO that solidifies the bridge so you can walk on it spawnSupport = true; @@ -466,27 +484,27 @@ public: else { uint32 spell = 0; - GameObject* pAltar = NULL; - if (toActivate == uiSladRanStatue) + GameObject* altar = NULL; + if (toActivate == sladRanStatueGUID) { spell = 57071; - pAltar = instance->GetGameObject(uiSladRanAltar); + altar = instance->GetGameObject(sladRanAltarGUID); } - else if (toActivate == uiMoorabiStatue) + else if (toActivate == moorabiStatueGUID) { spell = 57068; - pAltar = instance->GetGameObject(uiMoorabiAltar); + altar = instance->GetGameObject(moorabiAltarGUID); } - else if (toActivate == uiDrakkariColossusStatue) + else if (toActivate == drakkariColossusStatueGUID) { spell = 57072; - pAltar = instance->GetGameObject(uiDrakkariColossusAltar); + altar = instance->GetGameObject(drakkariColossusAltarGUID); } // This is a workaround to make the beam cast properly. The caster should be ID 30298 but since the spells // all are with scripted target for that same ID, it will hit itself. - if (pAltar) - if (Creature* trigger = pAltar->SummonCreature(18721, pAltar->GetPositionX(), pAltar->GetPositionY(), pAltar->GetPositionZ() + 3, pAltar->GetOrientation(), TEMPSUMMON_CORPSE_DESPAWN, 5000)) + if (altar) + if (Creature* trigger = altar->SummonCreature(18721, altar->GetPositionX(), altar->GetPositionY(), altar->GetPositionZ() + 3, altar->GetOrientation(), TEMPSUMMON_CORPSE_DESPAWN, 5000)) { // Set the trigger model to invisible trigger->SetDisplayId(11686); @@ -499,7 +517,7 @@ public: toActivate = 0; if (phase == 3) - SetData64(DATA_STATUE_ACTIVATE, uiBridge); + SetData64(DATA_STATUE_ACTIVATE, bridgeGUID); else SaveToDB(); // Don't save in between last statue and bridge turning in case of crash leading to stuck instance } @@ -526,7 +544,7 @@ public: bool OnGossipHello(Player* /*player*/, GameObject* go) { InstanceScript* instance = go->GetInstanceScript(); - uint64 uiStatue = 0; + uint64 statueGUID = 0; go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); go->SetGoState(GO_STATE_ACTIVE); @@ -535,20 +553,20 @@ public: { switch (go->GetEntry()) { - case 192518: - uiStatue = instance->GetData64(DATA_SLAD_RAN_STATUE); + case GO_SLADRAN_ALTAR: + statueGUID = instance->GetData64(DATA_SLAD_RAN_STATUE); break; - case 192519: - uiStatue = instance->GetData64(DATA_MOORABI_STATUE); + case GO_MOORABI_ALTAR: + statueGUID = instance->GetData64(DATA_MOORABI_STATUE); break; - case 192520: - uiStatue = instance->GetData64(DATA_DRAKKARI_COLOSSUS_STATUE); + case GO_DRAKKARI_COLOSSUS_ALTAR: + statueGUID = instance->GetData64(DATA_DRAKKARI_COLOSSUS_STATUE); break; } if (!instance->GetData64(DATA_STATUE_ACTIVATE)) { - instance->SetData64(DATA_STATUE_ACTIVATE, uiStatue); + instance->SetData64(DATA_STATUE_ACTIVATE, statueGUID); go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); go->SetGoState(GO_STATE_ACTIVE); } diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp index 97a70f43c27..259f2c28300 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp @@ -1013,8 +1013,11 @@ class npc_dream_portal : public CreatureScript { } - void OnSpellClick(Unit* /*clicker*/) + void OnSpellClick(Unit* /*clicker*/, bool& result) { + if (!result) + return; + _used = true; me->DespawnOrUnsummon(); } diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_assembly_of_iron.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_assembly_of_iron.cpp index 6ad70d38635..b3f5cc38c9f 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_assembly_of_iron.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_assembly_of_iron.cpp @@ -122,9 +122,11 @@ enum AssemblyYells EMOTE_BRUNDIR_OVERLOAD = 7 }; -enum AssemblyNPCs +enum Misc { - NPC_WORLD_TRIGGER = 22515 + NPC_WORLD_TRIGGER = 22515, + + DATA_PHASE_3 = 1 }; #define FLOOR_Z 427.28f @@ -158,6 +160,14 @@ class boss_steelbreaker : public CreatureScript events.ScheduleEvent(EVENT_FUSION_PUNCH, 15000); } + uint32 GetData(uint32 type) const + { + if (type == DATA_PHASE_3) + return (phase >= 3) ? 1 : 0; + + return 0; + } + void DoAction(int32 action) { switch (action) @@ -184,7 +194,7 @@ class boss_steelbreaker : public CreatureScript if (instance->GetBossState(BOSS_ASSEMBLY_OF_IRON) == DONE) { - DoCastAOE(SPELL_KILL_CREDIT); + DoCastAOE(SPELL_KILL_CREDIT, true); Talk(SAY_STEELBREAKER_ENCOUNTER_DEFEATED); } else @@ -287,6 +297,14 @@ class boss_runemaster_molgeim : public CreatureScript events.ScheduleEvent(EVENT_RUNE_OF_POWER, 20000); } + uint32 GetData(uint32 type) const + { + if (type == DATA_PHASE_3) + return (phase >= 3) ? 1 : 0; + + return 0; + } + void DoAction(int32 action) { switch (action) @@ -313,7 +331,7 @@ class boss_runemaster_molgeim : public CreatureScript if (instance->GetBossState(BOSS_ASSEMBLY_OF_IRON) == DONE) { - DoCastAOE(SPELL_KILL_CREDIT); + DoCastAOE(SPELL_KILL_CREDIT, true); Talk(SAY_MOLGEIM_ENCOUNTER_DEFEATED); } else @@ -429,6 +447,14 @@ class boss_stormcaller_brundir : public CreatureScript me->ApplySpellImmune(0, IMMUNITY_MECHANIC, MECHANIC_STUN, false); // Reset immumity, Brundir should be stunnable by default } + uint32 GetData(uint32 type) const + { + if (type == DATA_PHASE_3) + return (phase >= 3) ? 1 : 0; + + return 0; + } + void EnterCombat(Unit* /*who*/) { _EnterCombat(); @@ -470,7 +496,7 @@ class boss_stormcaller_brundir : public CreatureScript if (instance->GetBossState(BOSS_ASSEMBLY_OF_IRON) == DONE) { - DoCastAOE(SPELL_KILL_CREDIT); + DoCastAOE(SPELL_KILL_CREDIT, true); Talk(SAY_BRUNDIR_ENCOUNTER_DEFEATED); } else @@ -697,6 +723,17 @@ class spell_assembly_rune_of_summoning : public SpellScriptLoader } }; +class achievement_assembly_i_choose_you : public AchievementCriteriaScript +{ + public: + achievement_assembly_i_choose_you() : AchievementCriteriaScript("achievement_assembly_i_choose_you") { } + + bool OnCheck(Player* /*player*/, Unit* target) + { + return target && target->GetAI()->GetData(DATA_PHASE_3); + } +}; + void AddSC_boss_assembly_of_iron() { new boss_steelbreaker(); @@ -705,4 +742,5 @@ void AddSC_boss_assembly_of_iron() new spell_shield_of_runes(); new spell_assembly_meltdown(); new spell_assembly_rune_of_summoning(); + new achievement_assembly_i_choose_you(); } diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp index f89112e3d67..37ecf7874b8 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp @@ -709,8 +709,11 @@ class boss_flame_leviathan_overload_device : public CreatureScript { } - void OnSpellClick(Unit* /*clicker*/) + void OnSpellClick(Unit* /*clicker*/, bool& result) { + if (!result) + return; + if (me->GetVehicle()) { me->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK); diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_yogg_saron.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_yogg_saron.cpp index 105b4757066..97554a63217 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_yogg_saron.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_yogg_saron.cpp @@ -1421,8 +1421,10 @@ class npc_descend_into_madness : public CreatureScript { npc_descend_into_madnessAI(Creature* creature) : PassiveAI(creature), _instance(creature->GetInstanceScript()) { } - void OnSpellClick(Unit* clicker) + void OnSpellClick(Unit* clicker, bool& result) { + if (!result) + return; clicker->RemoveAurasDueToSpell(SPELL_BRAIN_LINK); me->DespawnOrUnsummon(); } diff --git a/src/server/scripts/Spells/spell_quest.cpp b/src/server/scripts/Spells/spell_quest.cpp index 3036c52876d..4cc464af9ab 100644 --- a/src/server/scripts/Spells/spell_quest.cpp +++ b/src/server/scripts/Spells/spell_quest.cpp @@ -1640,6 +1640,37 @@ class spell_q13291_q13292_q13239_q13261_armored_decoy_summon_skytalon : public S } }; +class spell_q12847_summon_soul_moveto_bunny : public SpellScriptLoader +{ + public: + spell_q12847_summon_soul_moveto_bunny() : SpellScriptLoader("spell_q12847_summon_soul_moveto_bunny") { } + + class spell_q12847_summon_soul_moveto_bunny_SpellScript : public SpellScript + { + PrepareSpellScript(spell_q12847_summon_soul_moveto_bunny_SpellScript); + + void ChangeSummonPos(SpellEffIndex /*effIndex*/) + { + // Adjust effect summon position + WorldLocation summonPos = *GetExplTargetDest(); + Position offset = { 0.0f, 0.0f, 2.5f, 0.0f }; + summonPos.RelocateOffset(offset); + SetExplTargetDest(summonPos); + GetHitDest()->RelocateOffset(offset); + } + + void Register() + { + OnEffectHit += SpellEffectFn(spell_q12847_summon_soul_moveto_bunny_SpellScript::ChangeSummonPos, EFFECT_0, SPELL_EFFECT_SUMMON); + } + }; + + SpellScript *GetSpellScript() const + { + return new spell_q12847_summon_soul_moveto_bunny_SpellScript(); + } +}; + void AddSC_quest_spell_scripts() { new spell_q55_sacred_cleansing(); @@ -1680,4 +1711,5 @@ void AddSC_quest_spell_scripts() new spell_q12527_zuldrak_rat(); new spell_q13291_q13292_q13239_q13261_frostbrood_skytalon_grab_decoy(); new spell_q13291_q13292_q13239_q13261_armored_decoy_summon_skytalon(); + new spell_q12847_summon_soul_moveto_bunny(); } diff --git a/src/server/shared/Database/Implementation/CharacterDatabase.cpp b/src/server/shared/Database/Implementation/CharacterDatabase.cpp index fce78638414..446f89aef4f 100644 --- a/src/server/shared/Database/Implementation/CharacterDatabase.cpp +++ b/src/server/shared/Database/Implementation/CharacterDatabase.cpp @@ -45,12 +45,12 @@ void CharacterDatabaseConnection::DoPrepareStatements() PrepareStatement(CHAR_SEL_ENUM, "SELECT c.guid, c.name, c.race, c.class, c.gender, c.playerBytes, c.playerBytes2, c.level, c.zone, c.map, c.position_x, c.position_y, c.position_z, " "gm.guildid, c.playerFlags, c.at_login, cp.entry, cp.modelid, cp.level, c.equipmentCache, cb.guid " "FROM characters AS c LEFT JOIN character_pet AS cp ON c.guid = cp.owner AND cp.slot = ? LEFT JOIN guild_member AS gm ON c.guid = gm.guid " - "LEFT JOIN character_banned AS cb ON c.guid = cb.guid AND cb.active = 1 WHERE c.account = ? ORDER BY c.guid", CONNECTION_ASYNC); + "LEFT JOIN character_banned AS cb ON c.guid = cb.guid AND cb.active = 1 WHERE c.account = ? AND c.deleteInfos_Name IS NULL ORDER BY c.guid", CONNECTION_ASYNC); PrepareStatement(CHAR_SEL_ENUM_DECLINED_NAME, "SELECT c.guid, c.name, c.race, c.class, c.gender, c.playerBytes, c.playerBytes2, c.level, c.zone, c.map, " "c.position_x, c.position_y, c.position_z, gm.guildid, c.playerFlags, c.at_login, cp.entry, cp.modelid, cp.level, c.equipmentCache, " "cb.guid, cd.genitive FROM characters AS c LEFT JOIN character_pet AS cp ON c.guid = cp.owner AND cp.slot = ? " "LEFT JOIN character_declinedname AS cd ON c.guid = cd.guid LEFT JOIN guild_member AS gm ON c.guid = gm.guid " - "LEFT JOIN character_banned AS cb ON c.guid = cb.guid AND cb.active = 1 WHERE c.account = ? ORDER BY c.guid", CONNECTION_ASYNC); + "LEFT JOIN character_banned AS cb ON c.guid = cb.guid AND cb.active = 1 WHERE c.account = ? AND c.deleteInfos_Name IS NULL ORDER BY c.guid", CONNECTION_ASYNC); PrepareStatement(CHAR_SEL_FREE_NAME, "SELECT guid, name FROM characters WHERE guid = ? AND account = ? AND (at_login & ?) = ? AND NOT EXISTS (SELECT NULL FROM characters WHERE name = ?)", CONNECTION_ASYNC); PrepareStatement(CHAR_SEL_GUID_RACE_ACC_BY_NAME, "SELECT guid, race, account FROM characters WHERE name = ?", CONNECTION_BOTH); PrepareStatement(CHAR_SEL_CHAR_RACE, "SELECT race FROM characters WHERE guid = ?", CONNECTION_SYNCH); |
