diff options
65 files changed, 291 insertions, 268 deletions
diff --git a/sql/updates/characters/2011_10_09_00_characters_character_aura.sql b/sql/updates/characters/2011_10_09_00_characters_character_aura.sql new file mode 100644 index 00000000000..a8223fa06d6 --- /dev/null +++ b/sql/updates/characters/2011_10_09_00_characters_character_aura.sql @@ -0,0 +1 @@ +DELETE FROM `character_aura` WHERE `spell` = 73001; diff --git a/sql/updates/world/2011_10_11_00_world_creature_template.sql b/sql/updates/world/2011_10_11_00_world_creature_template.sql new file mode 100644 index 00000000000..a86e5e53ea5 --- /dev/null +++ b/sql/updates/world/2011_10_11_00_world_creature_template.sql @@ -0,0 +1 @@ +UPDATE `creature_template` SET `scale`=1 WHERE `entry`=37690; -- Growing Ooze Puddle diff --git a/sql/updates/world/2011_10_12_00_world_spell_script_names.sql b/sql/updates/world/2011_10_12_00_world_spell_script_names.sql new file mode 100644 index 00000000000..cf2ea31306d --- /dev/null +++ b/sql/updates/world/2011_10_12_00_world_spell_script_names.sql @@ -0,0 +1,6 @@ +DELETE FROM `spell_script_names` WHERE `ScriptName`='spell_putricide_slime_puddle'; +INSERT INTO `spell_script_names` (`spell_id`,`ScriptName`) VALUES +(70346,'spell_putricide_slime_puddle'), +(72456,'spell_putricide_slime_puddle'), +(72868,'spell_putricide_slime_puddle'), +(72869,'spell_putricide_slime_puddle'); diff --git a/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp b/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp index cdea190dfbc..f210f077fdd 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp @@ -493,7 +493,7 @@ void npc_escortAI::SetEscortPaused(bool on) bool npc_escortAI::SetNextWaypoint(uint32 pointId, float x, float y, float z, float orientation) { - me->SetPosition(x, y, z, orientation); + me->UpdatePosition(x, y, z, orientation); return SetNextWaypoint(pointId, false, true); } @@ -516,7 +516,7 @@ bool npc_escortAI::SetNextWaypoint(uint32 pointId, bool setPosition, bool resetW if (waypoint.id == pointId) { if (setPosition) - me->SetPosition(waypoint.x, waypoint.y, waypoint.z, me->GetOrientation()); + me->UpdatePosition(waypoint.x, waypoint.y, waypoint.z, me->GetOrientation()); CurrentWP = WaypointList.begin(); return true; diff --git a/src/server/game/Battlegrounds/Battleground.cpp b/src/server/game/Battlegrounds/Battleground.cpp index ce555b3c503..339f2ebba3b 100755 --- a/src/server/game/Battlegrounds/Battleground.cpp +++ b/src/server/game/Battlegrounds/Battleground.cpp @@ -1454,7 +1454,7 @@ bool Battleground::AddObject(uint32 type, uint32 entry, float x, float y, float data.go_state = 1; */ // Add to world, so it can be later looked up from HashMapHolder - map->Add(go); + map->AddToMap(go); m_BgObjects[type] = go->GetGUID(); return true; } @@ -1521,7 +1521,7 @@ void Battleground::SpawnBGObject(uint32 type, uint32 respawntime) // Change state from GO_JUST_DEACTIVATED to GO_READY in case battleground is starting again obj->SetLootState(GO_READY); obj->SetRespawnTime(respawntime); - map->Add(obj); + map->AddToMap(obj); } } @@ -1557,7 +1557,7 @@ Creature* Battleground::AddCreature(uint32 entry, uint32 type, uint32 teamval, f creature->SetSpeed(MOVE_WALK, cinfo->speed_walk); creature->SetSpeed(MOVE_RUN, cinfo->speed_run); - map->Add(creature); + map->AddToMap(creature); m_BgCreatures[type] = creature->GetGUID(); if (respawntime) diff --git a/src/server/game/Chat/Commands/Level2.cpp b/src/server/game/Chat/Commands/Level2.cpp index 9e772e2cde7..b4b0cff9ea7 100755 --- a/src/server/game/Chat/Commands/Level2.cpp +++ b/src/server/game/Chat/Commands/Level2.cpp @@ -895,7 +895,7 @@ bool ChatHandler::HandleCreatePetCommand(const char* /*args*/) pet->InitPetCreateSpells(); pet->SetFullHealth(); - pet->GetMap()->Add(pet->ToCreature()); + pet->GetMap()->AddToMap(pet->ToCreature()); // visual effect for levelup pet->SetUInt32Value(UNIT_FIELD_LEVEL, creatureTarget->getLevel()); diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 5ac2fdcaca1..3842cc1924e 100755 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -2387,21 +2387,28 @@ const char* Creature::GetNameForLocaleIdx(LocaleConstant loc_idx) const return GetName(); } +//Do not if this works or not, moving creature to another map is very dangerous void Creature::FarTeleportTo(Map* map, float X, float Y, float Z, float O) { - InterruptNonMeleeSpells(true); - CombatStop(); - ClearComboPointHolders(); - DeleteThreatList(); - GetMotionMaster()->Clear(false); - DestroyForNearbyPlayers(); - - RemoveFromWorld(); - ResetMap(); + CleanupBeforeRemoveFromMap(false); + GetMap()->RemoveFromMap(this, false); + Relocate(X, Y, Z, O); SetMap(map); - AddToWorld(); + GetMap()->AddToMap(this); +} + +void Creature::SetPosition(float x, float y, float z, float o) +{ + // prevent crash when a bad coord is sent by the client + if (!Trinity::IsValidMapCoord(x, y, z, o)) + { + sLog->outDebug(LOG_FILTER_UNITS, "Creature::SetPosition(%f, %f, %f) .. bad coordinates!", x, y, z); + return; + } - SetPosition(X, Y, Z, O, true); + GetMap()->CreatureRelocation(ToCreature(), x, y, z, o); + if (IsVehicle()) + GetVehicleKit()->RelocatePassengers(x, y, z, o); } bool Creature::IsDungeonBoss() const diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h index 6bca501f76b..1d25dd46992 100755 --- a/src/server/game/Entities/Creature/Creature.h +++ b/src/server/game/Entities/Creature/Creature.h @@ -664,6 +664,9 @@ class Creature : public Unit, public GridObject<Creature>, public MapCreature return m_charmInfo->GetCharmSpell(pos)->GetAction(); } + void SetPosition(float x, float y, float z, float o); + void SetPosition(const Position &pos) { SetPosition(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation()); } + void SetHomePosition(float x, float y, float z, float o) { m_homePosition.Relocate(x, y, z, o); } void SetHomePosition(const Position &pos) { m_homePosition.Relocate(pos); } void GetHomePosition(float &x, float &y, float &z, float &ori) { m_homePosition.GetPosition(x, y, z, ori); } diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index 03da98d5624..6e991bdc005 100755 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -382,7 +382,7 @@ void GameObject::Update(uint32 diff) if (poolid) sPoolMgr->UpdatePool<GameObject>(poolid, GetDBTableGUIDLow()); else - GetMap()->Add(this); + GetMap()->AddToMap(this); break; } } @@ -595,7 +595,7 @@ void GameObject::Refresh() return; if (isSpawned()) - GetMap()->Add(this); + GetMap()->AddToMap(this); } void GameObject::AddUniqueUse(Player* player) diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index 0b275f833e6..82c0eb3a169 100755 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -2199,7 +2199,7 @@ TempSummon* Map::SummonCreature(uint32 entry, Position const& pos, SummonPropert summon->SetHomePosition(pos); summon->InitStats(duration); - Add(summon->ToCreature()); + AddToMap(summon->ToCreature()); summon->InitSummon(); //ObjectAccessor::UpdateObjectVisibility(summon); @@ -2307,7 +2307,7 @@ Pet* Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetTy break; } - map->Add(pet->ToCreature()); + map->AddToMap(pet->ToCreature()); switch (petType) { @@ -2368,7 +2368,7 @@ GameObject* WorldObject::SummonGameObject(uint32 entry, float x, float y, float ((Unit*)this)->AddGameObject(go); else go->SetSpawnedByDefault(false); - map->Add(go); + map->AddToMap(go); return go; } diff --git a/src/server/game/Entities/Pet/Pet.cpp b/src/server/game/Entities/Pet/Pet.cpp index 4150810a4ab..ca8d863dee9 100755 --- a/src/server/game/Entities/Pet/Pet.cpp +++ b/src/server/game/Entities/Pet/Pet.cpp @@ -185,7 +185,7 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petentry, uint32 petnumber, bool c CreatureTemplate const* cinfo = GetCreatureInfo(); if (cinfo->type == CREATURE_TYPE_CRITTER) { - map->Add(this->ToCreature()); + map->AddToMap(this->ToCreature()); return true; } @@ -279,7 +279,7 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petentry, uint32 petnumber, bool c } owner->SetMinion(this, true); - map->Add(this->ToCreature()); + map->AddToMap(this->ToCreature()); InitTalentForLevel(); // set original talents points before spell loading diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 4a8e2c9de0d..01203dd1d54 100755 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -2278,7 +2278,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati // remove from old map now if (oldmap) - oldmap->Remove(this, false); + oldmap->RemoveFromMap(this, false); // new final coordinates float final_x = x; @@ -5044,7 +5044,7 @@ void Player::BuildPlayerRepop() sLog->outError("Error creating corpse for Player %s [%u]", GetName(), GetGUIDLow()); return; } - GetMap()->Add(corpse); + GetMap()->AddToMap(corpse); // convert player body to ghost SetHealth(1); @@ -6727,9 +6727,9 @@ ActionButton const* Player::GetActionButton(uint8 button) return &buttonItr->second; } -bool Player::SetPosition(float x, float y, float z, float orientation, bool teleport) +bool Player::UpdatePosition(float x, float y, float z, float orientation, bool teleport) { - if (!Unit::SetPosition(x, y, z, orientation, teleport)) + if (!Unit::UpdatePosition(x, y, z, orientation, teleport)) return false; //if (movementInfo.flags & MOVEMENTFLAG_MOVING) @@ -6743,7 +6743,7 @@ bool Player::SetPosition(float x, float y, float z, float orientation, bool tele SetGroupUpdateFlag(GROUP_UPDATE_FLAG_POSITION); // code block for underwater state update - // Unit::SetPosition() checks for validity and updates our coordinates + // Unit::UpdatePosition() checks for validity and updates our coordinates // so we re-fetch them instead of using "raw" coordinates from function params UpdateUnderwaterState(GetMap(), GetPositionX(), GetPositionY(), GetPositionZ()); diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index 862b271c464..05ef060add9 100755 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -1937,8 +1937,8 @@ class Player : public Unit, public GridObject<Player> void SendResetInstanceFailed(uint32 reason, uint32 MapId); void SendResetFailedNotify(uint32 mapid); - virtual bool SetPosition(float x, float y, float z, float orientation, bool teleport = false); - bool SetPosition(const Position &pos, bool teleport = false) { return SetPosition(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), teleport); } + virtual bool UpdatePosition(float x, float y, float z, float orientation, bool teleport = false); + bool UpdatePosition(const Position &pos, bool teleport = false) { return UpdatePosition(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), teleport); } void UpdateUnderwaterState(Map* m, float x, float y, float z); void SendMessageToSet(WorldPacket* data, bool self) {SendMessageToSetInRange(data, GetVisibilityRange(), self); };// overwrite Object::SendMessageToSet diff --git a/src/server/game/Entities/Transport/Transport.cpp b/src/server/game/Entities/Transport/Transport.cpp index dbe9697bcaf..28d916fe0af 100755 --- a/src/server/game/Entities/Transport/Transport.cpp +++ b/src/server/game/Entities/Transport/Transport.cpp @@ -673,7 +673,7 @@ uint32 Transport::AddNPCPassenger(uint32 tguid, uint32 entry, float x, float y, return 0; } - map->Add(creature); + map->AddToMap(creature); m_NPCPassengerSet.insert(creature); if (tguid == 0) diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 6d02d943f63..6e70469df73 100755 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -12384,6 +12384,15 @@ int32 Unit::ModifyPower(Powers power, int32 dVal) return gain; } +// returns negative amount on power reduction +int32 Unit::ModifyPowerPct(Powers power, float pct, bool apply) +{ + float amount = (float)GetMaxPower(power); + ApplyPercentModFloatVar(amount, pct, apply); + + return ModifyPower(power, (int32)amount - (int32)GetMaxPower(power)); +} + bool Unit::isAlwaysVisibleFor(WorldObject const* seer) const { if (WorldObject::isAlwaysVisibleFor(seer)) @@ -13710,7 +13719,7 @@ void Unit::RemoveFromWorld() } } -void Unit::CleanupsBeforeDelete(bool finalCleanup) +void Unit::CleanupBeforeRemoveFromMap(bool finalCleanup) { // This needs to be before RemoveFromWorld to make GetCaster() return a valid pointer on aura removal InterruptNonMeleeSpells(true); @@ -13734,6 +13743,11 @@ void Unit::CleanupsBeforeDelete(bool finalCleanup) DeleteThreatList(); getHostileRefManager().setOnlineOfflineState(false); GetMotionMaster()->Clear(false); // remove different non-standard movement generators. +} + +void Unit::CleanupsBeforeDelete(bool finalCleanup) +{ + CleanupBeforeRemoveFromMap(finalCleanup); if (Creature* thisCreature = ToCreature()) if (GetTransport()) @@ -17151,16 +17165,16 @@ void Unit::NearTeleportTo(float x, float y, float z, float orientation, bool cas { // FIXME: this interrupts spell visual DestroyForNearbyPlayers(); - SetPosition(x, y, z, orientation, true); + UpdatePosition(x, y, z, orientation, true); } } -bool Unit::SetPosition(float x, float y, float z, float orientation, bool teleport) +bool Unit::UpdatePosition(float x, float y, float z, float orientation, bool teleport) { // prevent crash when a bad coord is sent by the client if (!Trinity::IsValidMapCoord(x, y, z, orientation)) { - sLog->outDebug(LOG_FILTER_UNITS, "Unit::SetPosition(%f, %f, %f) .. bad coordinates!", x, y, z); + sLog->outDebug(LOG_FILTER_UNITS, "Unit::UpdatePosition(%f, %f, %f) .. bad coordinates!", x, y, z); return false; } diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 8f052ab41ae..7629050ea8a 100755 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -1247,6 +1247,7 @@ class Unit : public WorldObject void AddToWorld(); void RemoveFromWorld(); + void CleanupBeforeRemoveFromMap(bool finalCleanup); void CleanupsBeforeDelete(bool finalCleanup = true); // used in ~Creature/~Player (or before mass creature delete to remove cross-references to already deleted units) DiminishingLevels GetDiminishing(DiminishingGroup group); @@ -1370,6 +1371,7 @@ class Unit : public WorldObject void SetMaxPower(Powers power, uint32 val); // returns the change in power int32 ModifyPower(Powers power, int32 val); + int32 ModifyPowerPct(Powers power, float pct, bool apply = true); uint32 GetAttackTime(WeaponAttackType att) const { @@ -1600,9 +1602,9 @@ class Unit : public WorldObject void SendSpellDamageImmune(Unit* target, uint32 spellId); void NearTeleportTo(float x, float y, float z, float orientation, bool casting = false); - virtual bool SetPosition(float x, float y, float z, float ang, bool teleport = false); + virtual bool UpdatePosition(float x, float y, float z, float ang, bool teleport = false); // returns true if unit's position really changed - bool SetPosition(const Position &pos, bool teleport = false) { return SetPosition(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), teleport); } + bool UpdatePosition(const Position &pos, bool teleport = false) { return UpdatePosition(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), teleport); } void KnockbackFrom(float x, float y, float speedXY, float speedZ); void JumpTo(float speedXY, float speedZ, bool forward = true); diff --git a/src/server/game/Entities/Vehicle/Vehicle.cpp b/src/server/game/Entities/Vehicle/Vehicle.cpp index effd43cd320..107e275d47b 100755 --- a/src/server/game/Entities/Vehicle/Vehicle.cpp +++ b/src/server/game/Entities/Vehicle/Vehicle.cpp @@ -445,7 +445,7 @@ void Vehicle::RelocatePassengers(float x, float y, float z, float ang) float pz = z + passenger->m_movementInfo.t_pos.m_positionZ; float po = ang + passenger->m_movementInfo.t_pos.m_orientation; - passenger->SetPosition(px, py, pz, po); + passenger->UpdatePosition(px, py, pz, po); } } diff --git a/src/server/game/Events/GameEventMgr.cpp b/src/server/game/Events/GameEventMgr.cpp index e81cd053003..cb42b898406 100755 --- a/src/server/game/Events/GameEventMgr.cpp +++ b/src/server/game/Events/GameEventMgr.cpp @@ -1179,7 +1179,7 @@ void GameEventMgr::GameEventSpawn(int16 event_id) if (!creature->LoadFromDB(*itr, map)) delete creature; else - map->Add(creature); + map->AddToMap(creature); } } } @@ -1210,7 +1210,7 @@ void GameEventMgr::GameEventSpawn(int16 event_id) else { if (pGameobject->isSpawnedByDefault()) - map->Add(pGameobject); + map->AddToMap(pGameobject); } } } diff --git a/src/server/game/Globals/ObjectAccessor.cpp b/src/server/game/Globals/ObjectAccessor.cpp index c351efb334f..f98702d4393 100755 --- a/src/server/game/Globals/ObjectAccessor.cpp +++ b/src/server/game/Globals/ObjectAccessor.cpp @@ -199,10 +199,10 @@ void ObjectAccessor::RemoveCorpse(Corpse* corpse) { ASSERT(corpse && corpse->GetType() != CORPSE_BONES); - if (corpse->FindMap()) + if (Map* map = corpse->FindMap()) { corpse->DestroyForNearbyPlayers(); - corpse->FindMap()->Remove(corpse, false); + map->RemoveFromMap(corpse, false); } else corpse->RemoveFromWorld(); @@ -317,7 +317,7 @@ Corpse* ObjectAccessor::ConvertCorpseForPlayer(uint64 player_guid, bool insignia } // add bones in grid store if grid loaded where corpse placed - map->Add(bones); + map->AddToMap(bones); } // all references to the corpse should be removed at this point diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index 3c3fc36da05..ae7e2d57991 100755 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -1636,7 +1636,7 @@ uint32 ObjectMgr::AddGOData(uint32 entry, uint32 mapId, float x, float y, float delete go; return 0; } - map->Add(go); + map->AddToMap(go); } sLog->outDebug(LOG_FILTER_MAPS, "AddGOData: dbguid %u entry %u map %u x %f y %f z %f o %f", guid, entry, mapId, x, y, z, o); @@ -1672,7 +1672,7 @@ bool ObjectMgr::MoveCreData(uint32 guid, uint32 mapId, Position pos) delete creature; return false; } - map->Add(creature); + map->AddToMap(creature); } } return true; @@ -1725,7 +1725,7 @@ uint32 ObjectMgr::AddCreData(uint32 entry, uint32 /*team*/, uint32 mapId, float delete creature; return 0; } - map->Add(creature); + map->AddToMap(creature); } } diff --git a/src/server/game/Grids/ObjectGridLoader.cpp b/src/server/game/Grids/ObjectGridLoader.cpp index b0e7de88491..ee488f404dc 100755 --- a/src/server/game/Grids/ObjectGridLoader.cpp +++ b/src/server/game/Grids/ObjectGridLoader.cpp @@ -82,11 +82,11 @@ class ObjectWorldLoader uint32 i_corpses; }; -template<class T> static void ObjectGridLoader::SetObjectCell(T* /*obj*/, CellPair const& /*cell_pair*/) +template<class T> void ObjectGridLoader::SetObjectCell(T* /*obj*/, CellPair const& /*cell_pair*/) { } -template<> static void ObjectGridLoader::SetObjectCell(Creature* obj, CellPair const& cell_pair) +template<> void ObjectGridLoader::SetObjectCell(Creature* obj, CellPair const& cell_pair) { Cell cell(cell_pair); diff --git a/src/server/game/Groups/Group.cpp b/src/server/game/Groups/Group.cpp index 44d7f62305f..0442172b0fd 100755 --- a/src/server/game/Groups/Group.cpp +++ b/src/server/game/Groups/Group.cpp @@ -1261,11 +1261,12 @@ void Group::UpdatePlayerOutOfRange(Player* player) WorldPacket data; player->GetSession()->BuildPartyMemberStatsChangedPacket(player, &data); + Player* member; for (GroupReference* itr = GetFirstMember(); itr != NULL; itr = itr->next()) { - player = itr->getSource(); - if (player && !player->IsWithinDist(player, player->GetSightRange(), false)) - player->GetSession()->SendPacket(&data); + member = itr->getSource(); + if (member && !member->IsWithinDist(player, member->GetSightRange(), false)) + member->GetSession()->SendPacket(&data); } } @@ -1273,12 +1274,12 @@ void Group::BroadcastPacket(WorldPacket* packet, bool ignorePlayersInBGRaid, int { for (GroupReference* itr = GetFirstMember(); itr != NULL; itr = itr->next()) { - Player* pl = itr->getSource(); - if (!pl || (ignore != 0 && pl->GetGUID() == ignore) || (ignorePlayersInBGRaid && pl->GetGroup() != this)) + Player* plr = itr->getSource(); + if (!plr || (ignore != 0 && plr->GetGUID() == ignore) || (ignorePlayersInBGRaid && plr->GetGroup() != this)) continue; - if (pl->GetSession() && (group == -1 || itr->getSubGroup() == group)) - pl->GetSession()->SendPacket(packet); + if (plr->GetSession() && (group == -1 || itr->getSubGroup() == group)) + plr->GetSession()->SendPacket(packet); } } @@ -1286,10 +1287,10 @@ void Group::BroadcastReadyCheck(WorldPacket* packet) { for (GroupReference* itr = GetFirstMember(); itr != NULL; itr = itr->next()) { - Player* pl = itr->getSource(); - if (pl && pl->GetSession()) - if (IsLeader(pl->GetGUID()) || IsAssistant(pl->GetGUID())) - pl->GetSession()->SendPacket(packet); + Player* plr = itr->getSource(); + if (plr && plr->GetSession()) + if (IsLeader(plr->GetGUID()) || IsAssistant(plr->GetGUID())) + plr->GetSession()->SendPacket(packet); } } @@ -1297,8 +1298,8 @@ void Group::OfflineReadyCheck() { for (member_citerator citr = m_memberSlots.begin(); citr != m_memberSlots.end(); ++citr) { - Player* pl = ObjectAccessor::FindPlayer(citr->guid); - if (!pl || !pl->GetSession()) + Player* plr = ObjectAccessor::FindPlayer(citr->guid); + if (!plr || !plr->GetSession()) { WorldPacket data(MSG_RAID_READY_CHECK_CONFIRM, 9); data << uint64(citr->guid); @@ -1328,6 +1329,7 @@ bool Group::SameSubGroup(Player const* member1, Player const* member2) const { if (!member1 || !member2) return false; + if (member1->GetGroup() != this || member2->GetGroup() != this) return false; else @@ -1364,10 +1366,8 @@ void Group::ChangeMembersGroup(uint64 guid, uint8 group) if (!isBGGroup()) CharacterDatabase.PExecute("UPDATE group_member SET subgroup='%u' WHERE memberGuid='%u'", group, GUID_LOPART(guid)); - Player* player = ObjectAccessor::FindPlayer(guid); - // In case the moved player is online, update the player object with the new sub group references - if (player) + if (Player* player = ObjectAccessor::FindPlayer(guid)) { if (player->GetGroup() == this) player->GetGroupRef().setSubGroup(group); diff --git a/src/server/game/Groups/Group.h b/src/server/game/Groups/Group.h index ed1fc80fd20..c51aa6dd7bf 100755 --- a/src/server/game/Groups/Group.h +++ b/src/server/game/Groups/Group.h @@ -57,14 +57,14 @@ enum RollVote enum GroupMemberOnlineStatus { MEMBER_STATUS_OFFLINE = 0x0000, - MEMBER_STATUS_ONLINE = 0x0001, - MEMBER_STATUS_PVP = 0x0002, - MEMBER_STATUS_UNK0 = 0x0004, // dead? (health=0) - MEMBER_STATUS_UNK1 = 0x0008, // ghost? (health=1) - MEMBER_STATUS_UNK2 = 0x0010, // never seen - MEMBER_STATUS_UNK3 = 0x0020, // never seen - MEMBER_STATUS_UNK4 = 0x0040, // appears with dead and ghost flags - MEMBER_STATUS_UNK5 = 0x0080, // never seen + MEMBER_STATUS_ONLINE = 0x0001, // Lua_UnitIsConnected + MEMBER_STATUS_PVP = 0x0002, // Lua_UnitIsPVP + MEMBER_STATUS_DEAD = 0x0004, // Lua_UnitIsDead + MEMBER_STATUS_GHOST = 0x0008, // Lua_UnitIsGhost + MEMBER_STATUS_PVP_FFA = 0x0010, // Lua_UnitIsPVPFreeForAll + MEMBER_STATUS_UNK3 = 0x0020, // used in calls from Lua_GetPlayerMapPosition/Lua_GetBattlefieldFlagPosition + MEMBER_STATUS_AFK = 0x0040, // Lua_UnitIsAFK + MEMBER_STATUS_DND = 0x0080, // Lua_UnitIsDND }; enum GroupMemberFlags diff --git a/src/server/game/Instances/InstanceSaveMgr.h b/src/server/game/Instances/InstanceSaveMgr.h index 63d54e4ec94..dec50e40127 100755 --- a/src/server/game/Instances/InstanceSaveMgr.h +++ b/src/server/game/Instances/InstanceSaveMgr.h @@ -80,8 +80,8 @@ class InstanceSave /* online players bound to the instance (perm/solo) does not include the members of the group unless they have permanent saves */ - void AddPlayer(Player* player) { m_playerList.push_back(player); } - bool RemovePlayer(Player* player) { m_playerList.remove(player); return UnloadIfEmpty(); } + void AddPlayer(Player* player) { ACE_GUARD(ACE_Thread_Mutex, guard, _lock); m_playerList.push_back(player); } + bool RemovePlayer(Player* player) { ACE_GUARD_RETURN(ACE_Thread_Mutex, guard, _lock, false); m_playerList.remove(player); return UnloadIfEmpty(); } /* all groups bound to the instance */ void AddGroup(Group* group) { m_groupList.push_back(group); } bool RemoveGroup(Group* group) { m_groupList.remove(group); return UnloadIfEmpty(); } @@ -110,6 +110,8 @@ class InstanceSave uint32 m_mapid; Difficulty m_difficulty; bool m_canReset; + + ACE_Thread_Mutex _lock; }; typedef UNORDERED_MAP<uint32 /*PAIR32(map, difficulty)*/, time_t /*resetTime*/> ResetTimeByMapDifficultyMap; diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp index 4096154fa37..89049f39127 100755 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -404,7 +404,7 @@ void Map::LoadGrid(float x, float y) EnsureGridLoaded(cell); } -bool Map::Add(Player* player) +bool Map::AddToMap(Player* player) { // Check if we are adding to correct map ASSERT (player->GetMap() == this); @@ -448,7 +448,7 @@ void Map::InitializeObject(Creature* obj) template<class T> void -Map::Add(T *obj) +Map::AddToMap(T *obj) { CellPair p = Trinity::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY()); if (p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP) @@ -682,7 +682,7 @@ void Map::ProcessRelocationNotifies(const uint32 diff) } } -void Map::Remove(Player* player, bool remove) +void Map::RemoveFromMap(Player* player, bool remove) { player->RemoveFromWorld(); SendRemoveTransports(player); @@ -714,7 +714,7 @@ void Map::Remove(Player* player, bool remove) template<class T> void -Map::Remove(T *obj, bool remove) +Map::RemoveFromMap(T *obj, bool remove) { obj->RemoveFromWorld(); if (obj->isActiveObject()) @@ -2089,20 +2089,20 @@ void Map::RemoveAllObjectsInRemoveList() if (!corpse) sLog->outError("Tried to delete corpse/bones %u that is not in map.", obj->GetGUIDLow()); else - Remove(corpse, true); + RemoveFromMap(corpse, true); break; } case TYPEID_DYNAMICOBJECT: - Remove((DynamicObject*)obj, true); + RemoveFromMap((DynamicObject*)obj, true); break; case TYPEID_GAMEOBJECT: - Remove((GameObject*)obj, true); + RemoveFromMap((GameObject*)obj, true); break; case TYPEID_UNIT: // in case triggered sequence some spell can continue casting after prev CleanupsBeforeDelete call // make sure that like sources auras/etc removed before destructor start obj->ToCreature()->CleanupsBeforeDelete(); - Remove(obj->ToCreature(), true); + RemoveFromMap(obj->ToCreature(), true); break; default: sLog->outError("Non-grid object (TypeId: %u) is in grid object remove list, ignored.", obj->GetTypeId()); @@ -2212,15 +2212,15 @@ void Map::RemoveFromActive(Creature* c) } } -template void Map::Add(Corpse*); -template void Map::Add(Creature*); -template void Map::Add(GameObject*); -template void Map::Add(DynamicObject*); +template void Map::AddToMap(Corpse*); +template void Map::AddToMap(Creature*); +template void Map::AddToMap(GameObject*); +template void Map::AddToMap(DynamicObject*); -template void Map::Remove(Corpse*, bool); -template void Map::Remove(Creature*, bool); -template void Map::Remove(GameObject*, bool); -template void Map::Remove(DynamicObject*, bool); +template void Map::RemoveFromMap(Corpse*, bool); +template void Map::RemoveFromMap(Creature*, bool); +template void Map::RemoveFromMap(GameObject*, bool); +template void Map::RemoveFromMap(DynamicObject*, bool); /* ******* Dungeon Instance Maps ******* */ @@ -2315,7 +2315,7 @@ bool InstanceMap::CanEnter(Player* player) /* Do map specific checks and add the player to the map if successful. */ -bool InstanceMap::Add(Player* player) +bool InstanceMap::AddToMap(Player* player) { // TODO: Not sure about checking player level: already done in HandleAreaTriggerOpcode // GMs still can teleport player in instance. @@ -2425,7 +2425,7 @@ bool InstanceMap::Add(Player* player) } // this will acquire the same mutex so it cannot be in the previous block - Map::Add(player); + Map::AddToMap(player); if (i_data) i_data->OnPlayerEnter(player); @@ -2441,13 +2441,13 @@ void InstanceMap::Update(const uint32 t_diff) i_data->Update(t_diff); } -void InstanceMap::Remove(Player* player, bool remove) +void InstanceMap::RemoveFromMap(Player* player, bool remove) { sLog->outDetail("MAP: Removing player '%s' from instance '%u' of map '%s' before relocating to another map", player->GetName(), GetInstanceId(), GetMapName()); //if last player set unload timer if (!m_unloadTimer && m_mapRefManager.getSize() == 1) m_unloadTimer = m_unloadWhenEmpty ? MIN_UNLOAD_DELAY : std::max(sWorld->getIntConfig(CONFIG_INSTANCE_UNLOAD_DELAY), (uint32)MIN_UNLOAD_DELAY); - Map::Remove(player, remove); + Map::RemoveFromMap(player, remove); // for normal instances schedule the reset after all players have left SetResetSchedule(true); } @@ -2661,7 +2661,7 @@ bool BattlegroundMap::CanEnter(Player* player) return Map::CanEnter(player); } -bool BattlegroundMap::Add(Player* player) +bool BattlegroundMap::AddToMap(Player* player) { { ACE_GUARD_RETURN(ACE_Thread_Mutex, guard, Lock, false); @@ -2671,13 +2671,13 @@ bool BattlegroundMap::Add(Player* player) // reset instance validity, battleground maps do not homebind player->m_InstanceValid = true; } - return Map::Add(player); + return Map::AddToMap(player); } -void BattlegroundMap::Remove(Player* player, bool remove) +void BattlegroundMap::RemoveFromMap(Player* player, bool remove) { sLog->outDetail("MAP: Removing player '%s' from bg '%u' of map '%s' before relocating to another map", player->GetName(), GetInstanceId(), GetMapName()); - Map::Remove(player, remove); + Map::RemoveFromMap(player, remove); } void BattlegroundMap::SetUnload() diff --git a/src/server/game/Maps/Map.h b/src/server/game/Maps/Map.h index 8359a49a316..fd58fd0cc72 100755 --- a/src/server/game/Maps/Map.h +++ b/src/server/game/Maps/Map.h @@ -244,10 +244,10 @@ class Map : public GridRefManager<NGridType> return false; } - virtual bool Add(Player*); - virtual void Remove(Player*, bool); - template<class T> void Add(T *); - template<class T> void Remove(T *, bool); + virtual bool AddToMap(Player*); + virtual void RemoveFromMap(Player*, bool); + template<class T> void AddToMap(T *); + template<class T> void RemoveFromMap(T *, bool); void VisitNearbyCellsOf(WorldObject* obj, TypeContainerVisitor<Trinity::ObjectUpdater, GridTypeMapContainer> &gridVisitor, TypeContainerVisitor<Trinity::ObjectUpdater, WorldTypeMapContainer> &worldVisitor); virtual void Update(const uint32); @@ -571,8 +571,8 @@ class InstanceMap : public Map public: InstanceMap(uint32 id, time_t, uint32 InstanceId, uint8 SpawnMode, Map* _parent); ~InstanceMap(); - bool Add(Player*); - void Remove(Player*, bool); + bool AddToMap(Player*); + void RemoveFromMap(Player*, bool); void Update(const uint32); void CreateInstanceData(bool load); bool Reset(uint8 method); @@ -601,8 +601,8 @@ class BattlegroundMap : public Map BattlegroundMap(uint32 id, time_t, uint32 InstanceId, Map* _parent, uint8 spawnMode); ~BattlegroundMap(); - bool Add(Player*); - void Remove(Player*, bool); + bool AddToMap(Player*); + void RemoveFromMap(Player*, bool); bool CanEnter(Player* player); void SetUnload(); //void UnloadAll(bool pForce); diff --git a/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp index 4ad2f0638d0..99deef200a6 100755 --- a/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp @@ -266,7 +266,7 @@ void FlightPathMovementGenerator::Finalize(Player & player) float y = 0; float z = 0; i_destinationHolder.GetLocationNow(player.GetBaseMap(), x, y, z); - player.SetPosition(x, y, z, player.GetOrientation()); + player.UpdatePosition(x, y, z, player.GetOrientation()); } diff --git a/src/server/game/Movement/Traveller.h b/src/server/game/Movement/Traveller.h index 27700eb61c4..9cd6a6cda17 100755 --- a/src/server/game/Movement/Traveller.h +++ b/src/server/game/Movement/Traveller.h @@ -85,7 +85,7 @@ inline float Traveller<Creature>::Speed() template<> inline void Traveller<Creature>::Relocation(float x, float y, float z, float orientation) { - i_traveller.SetPosition(x, y, z, orientation); + i_traveller.UpdatePosition(x, y, z, orientation); } template<> @@ -136,7 +136,7 @@ inline float Traveller<Player>::GetMoveDestinationTo(float x, float y, float z) template<> inline void Traveller<Player>::Relocation(float x, float y, float z, float orientation) { - i_traveller.SetPosition(x, y, z, orientation); + i_traveller.UpdatePosition(x, y, z, orientation); } template<> diff --git a/src/server/game/Pools/PoolMgr.cpp b/src/server/game/Pools/PoolMgr.cpp index 03accce42ed..35c19a6a62f 100755 --- a/src/server/game/Pools/PoolMgr.cpp +++ b/src/server/game/Pools/PoolMgr.cpp @@ -371,7 +371,7 @@ void PoolGroup<Creature>::Spawn1Object(PoolObject* obj) return; } else - map->Add(creature); + map->AddToMap(creature); } } } @@ -399,7 +399,7 @@ void PoolGroup<GameObject>::Spawn1Object(PoolObject* obj) else { if (pGameobject->isSpawnedByDefault()) - map->Add(pGameobject); + map->AddToMap(pGameobject); } } } @@ -507,7 +507,7 @@ void PoolGroup<Creature>::ReSpawn1Object(PoolObject* obj) { if (CreatureData const* data = sObjectMgr->GetCreatureData(obj->guid)) if (Creature* creature = ObjectAccessor::GetObjectInWorld(MAKE_NEW_GUID(obj->guid, data->id, HIGHGUID_UNIT), (Creature*)NULL)) - creature->GetMap()->Add(creature); + creature->GetMap()->AddToMap(creature); } // Method that does the respawn job on the specified gameobject @@ -516,7 +516,7 @@ void PoolGroup<GameObject>::ReSpawn1Object(PoolObject* obj) { if (GameObjectData const* data = sObjectMgr->GetGOData(obj->guid)) if (GameObject* pGameobject = ObjectAccessor::GetObjectInWorld(MAKE_NEW_GUID(obj->guid, data->id, HIGHGUID_GAMEOBJECT), (GameObject*)NULL)) - pGameobject->GetMap()->Add(pGameobject); + pGameobject->GetMap()->AddToMap(pGameobject); } // Nothing to do for a child Pool diff --git a/src/server/game/Scripting/MapScripts.cpp b/src/server/game/Scripting/MapScripts.cpp index 3ded63fe812..b141f889196 100755 --- a/src/server/game/Scripting/MapScripts.cpp +++ b/src/server/game/Scripting/MapScripts.cpp @@ -539,8 +539,8 @@ void Map::ScriptsProcess() // when script called for item spell casting then target == (unit or GO) and source is player WorldObject* worldObject; - Player* pTarget = target->ToPlayer(); - if (pTarget) + Player* plrTarget = target->ToPlayer(); + if (plrTarget) { if (source->GetTypeId() != TYPEID_UNIT && source->GetTypeId() != TYPEID_GAMEOBJECT && source->GetTypeId() != TYPEID_PLAYER) { @@ -552,8 +552,8 @@ void Map::ScriptsProcess() } else { - pTarget = source->ToPlayer(); - if (target) + plrTarget = source->ToPlayer(); + if (plrTarget) { if (target->GetTypeId() != TYPEID_UNIT && target->GetTypeId() != TYPEID_GAMEOBJECT && target->GetTypeId() != TYPEID_PLAYER) { @@ -566,19 +566,18 @@ void Map::ScriptsProcess() else { sLog->outError("%s neither source nor target is player (source: TypeId: %u, Entry: %u, GUID: %u; target: TypeId: %u, Entry: %u, GUID: %u), skipping.", - step.script->GetDebugInfo().c_str(), - source ? source->GetTypeId() : 0, source ? source->GetEntry() : 0, source ? source->GetGUIDLow() : 0, - target ? target->GetTypeId() : 0, target ? target->GetEntry() : 0, target ? target->GetGUIDLow() : 0); + step.script->GetDebugInfo().c_str(), source->GetTypeId(), source->GetEntry(), source->GetGUIDLow(), + target->GetTypeId(), target->GetEntry(), target->GetGUIDLow()); break; } } // quest id and flags checked at script loading if ((worldObject->GetTypeId() != TYPEID_UNIT || ((Unit*)worldObject)->isAlive()) && - (step.script->QuestExplored.Distance == 0 || worldObject->IsWithinDistInMap(pTarget, float(step.script->QuestExplored.Distance)))) - pTarget->AreaExploredOrEventHappens(step.script->QuestExplored.QuestID); + (step.script->QuestExplored.Distance == 0 || worldObject->IsWithinDistInMap(plrTarget, float(step.script->QuestExplored.Distance)))) + plrTarget->AreaExploredOrEventHappens(step.script->QuestExplored.QuestID); else - pTarget->FailQuest(step.script->QuestExplored.QuestID); + plrTarget->FailQuest(step.script->QuestExplored.QuestID); break; } @@ -628,7 +627,7 @@ void Map::ScriptsProcess() pGO->SetLootState(GO_READY); pGO->SetRespawnTime(nTimeToDespawn); - pGO->GetMap()->Add(pGO); + pGO->GetMap()->AddToMap(pGO); } } break; diff --git a/src/server/game/Server/Protocol/Handlers/CharacterHandler.cpp b/src/server/game/Server/Protocol/Handlers/CharacterHandler.cpp index d4ca425d606..a468d05bcdf 100755 --- a/src/server/game/Server/Protocol/Handlers/CharacterHandler.cpp +++ b/src/server/game/Server/Protocol/Handlers/CharacterHandler.cpp @@ -742,7 +742,7 @@ void WorldSession::HandleCharDeleteOpcode(WorldPacket & recv_data) sLog->outDetail("Account: %d (IP: %s) Delete Character:[%s] (GUID: %u)", GetAccountId(), IP_str.c_str(), name.c_str(), GUID_LOPART(guid)); sLog->outChar("Account: %d (IP: %s) Delete Character:[%s] (GUID: %u)", GetAccountId(), IP_str.c_str(), name.c_str(), GUID_LOPART(guid)); sScriptMgr->OnPlayerDelete(guid); - sWorld->DeleteCharaceterNameData(guid); + sWorld->DeleteCharaceterNameData(GUID_LOPART(guid)); if (sLog->IsOutCharDump()) // optimize GetPlayerDump call { @@ -920,7 +920,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder * holder) } } - if (!pCurrChar->GetMap()->Add(pCurrChar) || !pCurrChar->CheckInstanceLoginValid()) + if (!pCurrChar->GetMap()->AddToMap(pCurrChar) || !pCurrChar->CheckInstanceLoginValid()) { AreaTrigger const* at = sObjectMgr->GetGoBackTrigger(pCurrChar->GetMapId()); if (at) diff --git a/src/server/game/Server/Protocol/Handlers/GroupHandler.cpp b/src/server/game/Server/Protocol/Handlers/GroupHandler.cpp index 57a54bd440f..404a949371a 100755 --- a/src/server/game/Server/Protocol/Handlers/GroupHandler.cpp +++ b/src/server/game/Server/Protocol/Handlers/GroupHandler.cpp @@ -850,10 +850,8 @@ void WorldSession::BuildPartyMemberStatsChangedPacket(Player* player, WorldPacke if (mask & GROUP_UPDATE_FLAG_VEHICLE_SEAT) { - if (player->GetVehicle()){ - Vehicle* vv=player->GetVehicle(); - *data << (uint32) vv->GetVehicleInfo()->m_seatID[player->m_movementInfo.t_seat]; - } + if (Vehicle* veh = player->GetVehicle()) + *data << (uint32) veh->GetVehicleInfo()->m_seatID[player->m_movementInfo.t_seat]; } if (mask & GROUP_UPDATE_FLAG_PET_AURAS) diff --git a/src/server/game/Server/Protocol/Handlers/MovementHandler.cpp b/src/server/game/Server/Protocol/Handlers/MovementHandler.cpp index bf971cae32f..d343e1b2dae 100755 --- a/src/server/game/Server/Protocol/Handlers/MovementHandler.cpp +++ b/src/server/game/Server/Protocol/Handlers/MovementHandler.cpp @@ -68,7 +68,7 @@ void WorldSession::HandleMoveWorldportAckOpcode() if (GetPlayer()->IsInWorld()) { sLog->outCrash("Player (Name %s) is still in world when teleported from map %u to new map %u", GetPlayer()->GetName(), oldMap->GetId(), loc.GetMapId()); - oldMap->Remove(GetPlayer(), false); + oldMap->RemoveFromMap(GetPlayer(), false); } // relocate the player to the teleport destination @@ -88,7 +88,7 @@ void WorldSession::HandleMoveWorldportAckOpcode() GetPlayer()->SetMap(newMap); GetPlayer()->SendInitialPacketsBeforeAddToMap(); - if (!GetPlayer()->GetMap()->Add(GetPlayer())) + if (!GetPlayer()->GetMap()->AddToMap(GetPlayer())) { sLog->outError("WORLD: failed to teleport player %s (%d) to map %d because of unknown reason!", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow(), loc.GetMapId()); GetPlayer()->ResetMap(); @@ -215,7 +215,7 @@ void WorldSession::HandleMoveTeleportAck(WorldPacket& recv_data) WorldLocation const& dest = plMover->GetTeleportDest(); - plMover->SetPosition(dest, true); + plMover->UpdatePosition(dest, true); uint32 newzone, newarea; plMover->GetZoneAndAreaId(newzone, newarea); @@ -355,7 +355,7 @@ void WorldSession::HandleMovementOpcodes(WorldPacket & recv_data) return; } - mover->SetPosition(movementInfo.pos); + mover->UpdatePosition(movementInfo.pos); if (plMover) // nothing is charmed, or player charmed { diff --git a/src/server/game/Server/WorldSession.cpp b/src/server/game/Server/WorldSession.cpp index cc57b72d9b4..9cb2b1cbe3f 100755 --- a/src/server/game/Server/WorldSession.cpp +++ b/src/server/game/Server/WorldSession.cpp @@ -494,7 +494,7 @@ void WorldSession::LogoutPlayer(bool Save) _player->CleanupsBeforeDelete(); sLog->outChar("Account: %d (IP: %s) Logout Character:[%s] (GUID: %u)", GetAccountId(), GetRemoteAddress().c_str(), _player->GetName(), _player->GetGUIDLow()); Map* _map = _player->GetMap(); - _map->Remove(_player, true); + _map->RemoveFromMap(_player, true); SetPlayer(NULL); // deleted in Remove call ///- Send the 'logout complete' packet to the client diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index 4876f435f55..e8906d718dc 100755 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -903,25 +903,6 @@ void AuraEffect::CalculateSpellMod() default: break; } - case SPELL_AURA_MOD_SPELL_CRIT_CHANCE: - switch (GetId()) - { - case 51466: // Elemental oath - case 51470: // Elemental oath - // "while Clearcasting from Elemental Focus is active, you deal 5%/10% more spell damage." - if (!m_spellmod) - { - m_spellmod = new SpellModifier(GetBase()); - m_spellmod->op = SPELLMOD_EFFECT2; - m_spellmod->type = SPELLMOD_FLAT; - m_spellmod->spellId = GetId(); - m_spellmod->mask[1] = 0x0004000; - } - m_spellmod->value = GetBase()->GetUnitOwner()->CalculateSpellDamage(GetBase()->GetUnitOwner(), GetSpellInfo(), 1); - break; - default: - break; - } break; case SPELL_AURA_ADD_FLAT_MODIFIER: case SPELL_AURA_ADD_PCT_MODIFIER: @@ -4003,8 +3984,18 @@ void AuraEffect::HandleAuraModIncreaseEnergyPercent(AuraApplication const* aurAp // return; UnitMods unitMod = UnitMods(UNIT_MOD_POWER_START + powerType); + float amount = float(GetAmount()); - target->HandleStatModifier(unitMod, TOTAL_PCT, float(GetAmount()), apply); + if (apply) + { + target->HandleStatModifier(unitMod, TOTAL_PCT, amount, apply); + target->ModifyPowerPct(powerType, amount, apply); + } + else + { + target->ModifyPowerPct(powerType, amount, apply); + target->HandleStatModifier(unitMod, TOTAL_PCT, amount, apply); + } } void AuraEffect::HandleAuraModIncreaseHealthPercent(AuraApplication const* aurApp, uint8 mode, bool apply) const diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index 926a2280d18..19f84854ae4 100755 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -2575,7 +2575,7 @@ void Spell::EffectPersistentAA(SpellEffIndex effIndex) return; } - dynObj->GetMap()->Add(dynObj); + dynObj->GetMap()->AddToMap(dynObj); if (Aura* aura = Aura::TryCreate(m_spellInfo, MAX_EFFECT_MASK, dynObj, caster, &m_spellValue->EffectBasePoints[0])) { @@ -3368,7 +3368,7 @@ void Spell::EffectDistract(SpellEffIndex /*effIndex*/) if (unitTarget->GetTypeId() == TYPEID_PLAYER) { // For players just turn them - unitTarget->ToPlayer()->SetPosition(unitTarget->GetPositionX(), unitTarget->GetPositionY(), unitTarget->GetPositionZ(), angle, false); + unitTarget->ToPlayer()->UpdatePosition(unitTarget->GetPositionX(), unitTarget->GetPositionY(), unitTarget->GetPositionZ(), angle, false); unitTarget->ToPlayer()->SendTeleportAckPacket(); } else @@ -3422,7 +3422,7 @@ void Spell::EffectAddFarsight(SpellEffIndex effIndex) dynObj->SetDuration(duration); dynObj->setActive(true); //must before add to map to be put in world container - dynObj->GetMap()->Add(dynObj); //grid will also be loaded + dynObj->GetMap()->AddToMap(dynObj); //grid will also be loaded dynObj->SetCasterViewpoint(); } @@ -3812,7 +3812,7 @@ void Spell::EffectTameCreature(SpellEffIndex /*effIndex*/) pet->SetUInt32Value(UNIT_FIELD_LEVEL, level - 1); // add to world - pet->GetMap()->Add(pet->ToCreature()); + pet->GetMap()->AddToMap(pet->ToCreature()); // visual effect for levelup pet->SetUInt32Value(UNIT_FIELD_LEVEL, level); @@ -4378,7 +4378,7 @@ void Spell::EffectSummonObjectWild(SpellEffIndex effIndex) ExecuteLogEffectSummonObject(effIndex, pGameObj); // Wild object not have owner and check clickable by players - map->Add(pGameObj); + map->AddToMap(pGameObj); if (pGameObj->GetGoType() == GAMEOBJECT_TYPE_FLAGDROP && m_caster->GetTypeId() == TYPEID_PLAYER) { @@ -4423,7 +4423,7 @@ void Spell::EffectSummonObjectWild(SpellEffIndex effIndex) ExecuteLogEffectSummonObject(effIndex, linkedGO); // Wild object not have owner and check clickable by players - map->Add(linkedGO); + map->AddToMap(linkedGO); } else { @@ -5583,7 +5583,7 @@ void Spell::EffectDuel(SpellEffIndex effIndex) ExecuteLogEffectSummonObject(effIndex, pGameObj); m_caster->AddGameObject(pGameObj); - map->Add(pGameObj); + map->AddToMap(pGameObj); //END // Send request @@ -5934,7 +5934,7 @@ void Spell::EffectSummonObject(SpellEffIndex effIndex) ExecuteLogEffectSummonObject(effIndex, pGameObj); - map->Add(pGameObj); + map->AddToMap(pGameObj); m_caster->m_ObjectSlot[slot] = pGameObj->GetGUID(); } @@ -6630,7 +6630,7 @@ void Spell::EffectTransmitted(SpellEffIndex effIndex) //m_caster->AddGameObject(pGameObj); //m_ObjToDel.push_back(pGameObj); - cMap->Add(pGameObj); + cMap->AddToMap(pGameObj); if (uint32 linkedEntry = pGameObj->GetGOInfo()->GetLinkedGameObjectEntry()) { @@ -6645,7 +6645,7 @@ void Spell::EffectTransmitted(SpellEffIndex effIndex) ExecuteLogEffectSummonObject(effIndex, linkedGO); - linkedGO->GetMap()->Add(linkedGO); + linkedGO->GetMap()->AddToMap(linkedGO); } else { @@ -6968,7 +6968,7 @@ void Spell::EffectCreateTamedPet(SpellEffIndex effIndex) return; // add to world - pet->GetMap()->Add(pet->ToCreature()); + pet->GetMap()->AddToMap(pet->ToCreature()); // unitTarget has pet now unitTarget->SetMinion(pet, true); diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp index cfa28080b2b..4fc9564baa3 100755 --- a/src/server/game/Spells/SpellMgr.cpp +++ b/src/server/game/Spells/SpellMgr.cpp @@ -3090,11 +3090,18 @@ void SpellMgr::LoadDbcDataCorrections() case 48422: spellInfo->Stances = 1 << (FORM_TREE - 1); break; + case 51466: // Elemental Oath (Rank 1) + case 51470: // Elemental Oath (Rank 2) + spellInfo->Effect[EFFECT_1] = SPELL_EFFECT_APPLY_AURA; + spellInfo->EffectApplyAuraName[EFFECT_1] = SPELL_AURA_ADD_FLAT_MODIFIER; + spellInfo->EffectMiscValue[EFFECT_1] = SPELLMOD_EFFECT2; + spellInfo->EffectSpellClassMask[EFFECT_1] = flag96(0x00000000, 0x00004000, 0x00000000); + break; case 47569: // Improved Shadowform (Rank 1) // with this spell atrribute aura can be stacked several times spellInfo->Attributes &= ~SPELL_ATTR0_NOT_SHAPESHIFT; break; - case 64904: //Hymn of Hope + case 64904: // Hymn of Hope spellInfo->EffectApplyAuraName[EFFECT_1] = SPELL_AURA_MOD_INCREASE_ENERGY_PERCENT; break; case 30421: // Nether Portal - Perseverence diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp index 11e46a8c878..9e1d5717f1f 100644 --- a/src/server/scripts/Commands/cs_debug.cpp +++ b/src/server/scripts/Commands/cs_debug.cpp @@ -925,7 +925,7 @@ public: return false; } - map->Add(v->ToCreature()); + map->AddToMap(v->ToCreature()); return true; } diff --git a/src/server/scripts/Commands/cs_gobject.cpp b/src/server/scripts/Commands/cs_gobject.cpp index 3ea49345f5f..4c9960992e1 100644 --- a/src/server/scripts/Commands/cs_gobject.cpp +++ b/src/server/scripts/Commands/cs_gobject.cpp @@ -171,7 +171,7 @@ public: return false; } - map->Add(object); + map->AddToMap(object); // TODO: is it really necessary to add both the real and DB table guid here ? sObjectMgr->AddGameobjectToGrid(guidLow, sObjectMgr->GetGOData(guidLow)); diff --git a/src/server/scripts/Commands/cs_npc.cpp b/src/server/scripts/Commands/cs_npc.cpp index cdb87fde354..0fecfa83221 100644 --- a/src/server/scripts/Commands/cs_npc.cpp +++ b/src/server/scripts/Commands/cs_npc.cpp @@ -149,7 +149,7 @@ public: // To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells(); creature->LoadFromDB(db_guid, map); - map->Add(creature); + map->AddToMap(creature); sObjectMgr->AddCreatureToGrid(db_guid, sObjectMgr->GetCreatureData(db_guid)); return true; } @@ -623,7 +623,7 @@ public: const_cast<CreatureData*>(data)->posZ = z; const_cast<CreatureData*>(data)->orientation = o; } - creature->GetMap()->CreatureRelocation(creature, x, y, z, o); + creature->SetPosition(x, y, z, o); creature->GetMotionMaster()->Initialize(); if (creature->isAlive()) // dead creature will reset movement generator at respawn { @@ -1142,7 +1142,7 @@ public: pet->SetUInt32Value(UNIT_FIELD_LEVEL, level - 1); // add to world - pet->GetMap()->Add(pet->ToCreature()); + pet->GetMap()->AddToMap(pet->ToCreature()); // visual effect for levelup pet->SetUInt32Value(UNIT_FIELD_LEVEL, level); diff --git a/src/server/scripts/Commands/cs_wp.cpp b/src/server/scripts/Commands/cs_wp.cpp index 34ea264fd9e..75904764f23 100644 --- a/src/server/scripts/Commands/cs_wp.cpp +++ b/src/server/scripts/Commands/cs_wp.cpp @@ -591,7 +591,7 @@ public: wpCreature2->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn()); // To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells(); wpCreature2->LoadFromDB(wpCreature2->GetDBTableGUIDLow(), map); - map->Add(wpCreature2); + map->AddToMap(wpCreature2); //sMapMgr->GetMap(npcCreature->GetMapId())->Add(wpCreature2); } @@ -790,7 +790,7 @@ public: wpCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn()); // To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells(); wpCreature->LoadFromDB(wpCreature->GetDBTableGUIDLow(), map); - map->Add(wpCreature); + map->AddToMap(wpCreature); if (target) { @@ -837,7 +837,7 @@ public: creature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn()); creature->LoadFromDB(creature->GetDBTableGUIDLow(), map); - map->Add(creature); + map->AddToMap(creature); if (target) { @@ -885,7 +885,7 @@ public: creature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn()); creature->LoadFromDB(creature->GetDBTableGUIDLow(), map); - map->Add(creature); + map->AddToMap(creature); if (target) { diff --git a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_felblood_kaelthas.cpp b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_felblood_kaelthas.cpp index ce4a2a10cac..c64fc6f2dab 100644 --- a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_felblood_kaelthas.cpp +++ b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_felblood_kaelthas.cpp @@ -206,7 +206,7 @@ public: { float x = KaelLocations[0][0]; float y = KaelLocations[0][1]; - me->GetMap()->CreatureRelocation(me, x, y, LOCATION_Z, 0.0f); + me->SetPosition(x, y, LOCATION_Z, 0.0f); //me->SendMonsterMove(x, y, LOCATION_Z, 0, 0, 0); // causes some issues... std::list<HostileReference*>::const_iterator i = me->getThreatManager().getThreatList().begin(); for (i = me->getThreatManager().getThreatList().begin(); i!= me->getThreatManager().getThreatList().end(); ++i) diff --git a/src/server/scripts/EasternKingdoms/ScarletEnclave/the_scarlet_enclave.cpp b/src/server/scripts/EasternKingdoms/ScarletEnclave/the_scarlet_enclave.cpp index e6610294071..a61b88a990d 100644 --- a/src/server/scripts/EasternKingdoms/ScarletEnclave/the_scarlet_enclave.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletEnclave/the_scarlet_enclave.cpp @@ -53,7 +53,7 @@ public: me->GetPosition(x, y, z); z += 4; x -= 3.5; y -= 5; me->GetMotionMaster()->Clear(false); - me->GetMap()->CreatureRelocation(me, x, y, z, 0.0f); + me->SetPosition(x, y, z, 0.0f); } void UpdateAI(const uint32 diff) diff --git a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp index 667e1cd279e..9afbeaa0172 100644 --- a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp @@ -756,7 +756,7 @@ public: { float x, y, z; me->GetPosition(x, y, z); //this visual aura some under ground - me->GetMap()->CreatureRelocation(me, x, y, z + 0.35f, 0.0f); + me->SetPosition(x, y, z + 0.35f, 0.0f); Despawn(); Creature* debuff = DoSpawnCreature(HELPER, 0, 0, 0, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 14500); if (debuff) diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp index 2e4e92685ea..df3bb5d4525 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp @@ -661,7 +661,7 @@ public: void JustDied(Unit* /*killer*/) { DoScriptText(SAY_SATH_DEATH, me); - me->GetMap()->CreatureRelocation(me, me->GetPositionX(), me->GetPositionY(), DRAGON_REALM_Z, me->GetOrientation()); + me->SetPosition(me->GetPositionX(), me->GetPositionY(), DRAGON_REALM_Z, me->GetOrientation()); TeleportAllPlayersBack(); if (Creature* Kalecgos = Unit::GetCreature(*me, KalecgosGUID)) { diff --git a/src/server/scripts/EasternKingdoms/ZulAman/boss_hexlord.cpp b/src/server/scripts/EasternKingdoms/ZulAman/boss_hexlord.cpp index d4d4e7314b4..162c84f1fa7 100644 --- a/src/server/scripts/EasternKingdoms/ZulAman/boss_hexlord.cpp +++ b/src/server/scripts/EasternKingdoms/ZulAman/boss_hexlord.cpp @@ -335,7 +335,7 @@ class boss_hexlord_malacrass : public CreatureScript else { creature->AI()->EnterEvadeMode(); - creature->GetMap()->CreatureRelocation(me, Pos_X[i], POS_Y, POS_Z, ORIENT); + creature->SetPosition(Pos_X[i], POS_Y, POS_Z, ORIENT); creature->StopMoving(); } } diff --git a/src/server/scripts/EasternKingdoms/ZulGurub/boss_marli.cpp b/src/server/scripts/EasternKingdoms/ZulGurub/boss_marli.cpp index b9ae61c122e..f6704a50e6f 100644 --- a/src/server/scripts/EasternKingdoms/ZulGurub/boss_marli.cpp +++ b/src/server/scripts/EasternKingdoms/ZulGurub/boss_marli.cpp @@ -185,7 +185,7 @@ class boss_marli : public CreatureScript if (target) { DoCast(target, SPELL_CHARGE); - //me->GetMap()->CreatureRelocation(me, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0); + //me->SetPosition(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0); //me->SendMonsterMove(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, true, 1); AttackStart(target); } diff --git a/src/server/scripts/EasternKingdoms/undercity.cpp b/src/server/scripts/EasternKingdoms/undercity.cpp index 042c8f695c7..b8f2499c4e6 100644 --- a/src/server/scripts/EasternKingdoms/undercity.cpp +++ b/src/server/scripts/EasternKingdoms/undercity.cpp @@ -107,10 +107,10 @@ public: { if (summoned->GetEntry() == ENTRY_HIGHBORNE_BUNNY) { - if (Unit* target = Unit::GetUnit(*summoned, targetGUID)) + if (Creature* target = Unit::GetCreature(*summoned, targetGUID)) { target->SendMonsterMove(target->GetPositionX(), target->GetPositionY(), me->GetPositionZ()+15.0f, 0); - target->GetMap()->CreatureRelocation(me, target->GetPositionX(), target->GetPositionY(), me->GetPositionZ()+15.0f, 0.0f); + target->SetPosition(target->GetPositionX(), target->GetPositionY(), me->GetPositionZ()+15.0f, 0.0f); summoned->CastSpell(target, SPELL_RIBBON_OF_SOULS, false); } @@ -187,7 +187,7 @@ public: { me->AddUnitMovementFlag(MOVEMENTFLAG_LEVITATING); me->SendMonsterMoveWithSpeed(me->GetPositionX(), me->GetPositionY(), HIGHBORNE_LOC_Y_NEW, 5000); - me->GetMap()->CreatureRelocation(me, me->GetPositionX(), me->GetPositionY(), HIGHBORNE_LOC_Y_NEW, me->GetOrientation()); + me->SetPosition(me->GetPositionX(), me->GetPositionY(), HIGHBORNE_LOC_Y_NEW, me->GetOrientation()); EventMove = false; } else EventMove_Timer -= diff; } diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal_trash.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal_trash.cpp index ef75307c625..748d0dfa071 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal_trash.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal_trash.cpp @@ -1202,7 +1202,7 @@ public: me->GetPosition(x, y, z); z = me->GetMap()->GetHeight(x, y, z); me->GetMotionMaster()->MovePoint(0, x, y, z); - me->GetMap()->CreatureRelocation(me, x, y, z, 0); + me->SetPosition(x, y, z, 0); } void EnterCombat(Unit* /*who*/) {} @@ -1321,7 +1321,7 @@ public: me->GetPosition(x, y, z); z = me->GetMap()->GetHeight(x, y, z); me->GetMotionMaster()->MovePoint(0, x, y, z); - me->GetMap()->CreatureRelocation(me, x, y, z, 0); + me->SetPosition(x, y, z, 0); hyjal_trashAI::JustDied(victim); } diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp index dd2531d5aad..4cc1069b838 100644 --- a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp +++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp @@ -1073,7 +1073,7 @@ public: if (!target->HasAura(SPELL_DIGESTIVE_ACID)) { - me->GetMap()->CreatureRelocation(me, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0); + me->SetPosition(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0); if (Creature* pPortal = me->SummonCreature(MOB_SMALL_PORTAL, *me, TEMPSUMMON_CORPSE_DESPAWN)) { pPortal->SetReactState(REACT_PASSIVE); @@ -1185,7 +1185,7 @@ public: if (!target->HasAura(SPELL_DIGESTIVE_ACID)) { - me->GetMap()->CreatureRelocation(me, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0); + me->SetPosition(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0); if (Creature* pPortal = me->SummonCreature(MOB_GIANT_PORTAL, *me, TEMPSUMMON_CORPSE_DESPAWN)) { pPortal->SetReactState(REACT_PASSIVE); diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_skeram.cpp b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_skeram.cpp index b0033aa582a..0ba6bdb1154 100644 --- a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_skeram.cpp +++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_skeram.cpp @@ -157,15 +157,15 @@ public: switch (urand(0, 2)) { case 0: - me->GetMap()->CreatureRelocation(me, -8340.782227f, 2083.814453f, 125.648788f, 0.0f); + me->SetPosition(-8340.782227f, 2083.814453f, 125.648788f, 0.0f); DoResetThreat(); break; case 1: - me->GetMap()->CreatureRelocation(me, -8341.546875f, 2118.504639f, 133.058151f, 0.0f); + me->SetPosition(-8341.546875f, 2118.504639f, 133.058151f, 0.0f); DoResetThreat(); break; case 2: - me->GetMap()->CreatureRelocation(me, -8318.822266f, 2058.231201f, 133.058151f, 0.0f); + me->SetPosition(-8318.822266f, 2058.231201f, 133.058151f, 0.0f); DoResetThreat(); break; } @@ -252,7 +252,7 @@ public: me->RemoveAllAuras(); me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); me->SetVisible(false); - me->GetMap()->CreatureRelocation(me, bossc->x, bossc->y, bossc->z, bossc->r); + me->SetPosition(bossc->x, bossc->y, bossc->z, bossc->r); Invisible = true; DoResetThreat(); DoStopAttack(); diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_twinemperors.cpp b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_twinemperors.cpp index c501a060194..29b92957ace 100644 --- a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_twinemperors.cpp +++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_twinemperors.cpp @@ -216,15 +216,12 @@ struct boss_twinemperorsAI : public ScriptedAI if (pOtherBoss) { //me->MonsterYell("Teleporting ...", LANG_UNIVERSAL, 0); - float other_x = pOtherBoss->GetPositionX(); - float other_y = pOtherBoss->GetPositionY(); - float other_z = pOtherBoss->GetPositionZ(); - float other_o = pOtherBoss->GetOrientation(); - - Map* thismap = me->GetMap(); - thismap->CreatureRelocation(pOtherBoss, me->GetPositionX(), - me->GetPositionY(), me->GetPositionZ(), me->GetOrientation()); - thismap->CreatureRelocation(me, other_x, other_y, other_z, other_o); + Position thisPos; + thisPos.Relocate(me); + Position otherPos; + otherPos.Relocate(pOtherBoss); + pOtherBoss->SetPosition(thisPos); + me->SetPosition(otherPos); SetAfterTeleport(); CAST_AI(boss_twinemperorsAI, pOtherBoss->AI())->SetAfterTeleport(); diff --git a/src/server/scripts/Kalimdor/azshara.cpp b/src/server/scripts/Kalimdor/azshara.cpp index 88e46e7fb26..6fbc424f3d4 100644 --- a/src/server/scripts/Kalimdor/azshara.cpp +++ b/src/server/scripts/Kalimdor/azshara.cpp @@ -357,7 +357,7 @@ public: Map* map = me->GetMap(); if (map) { - map->CreatureRelocation(me, 3706.39f, -3969.15f, 35.9118f, 0); + me->SetPosition(3706.39f, -3969.15f, 35.9118f, 0); me->AI_SendMoveToPacket(3706.39f, -3969.15f, 35.9118f, 0, 0, 0); } //begin swimming and summon depth charges diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp index b351d7de9d7..4a5d609eb67 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp @@ -239,25 +239,6 @@ class boss_blood_council_controller : public CreatureScript _invocationOrder[1] = InvocationData(instance->GetData64(DATA_PRINCE_KELESETH_GUID), SPELL_INVOCATION_OF_BLOOD_KELESETH, EMOTE_KELESETH_INVOCATION, 71080); _invocationOrder[2] = InvocationData(instance->GetData64(DATA_PRINCE_TALDARAM_GUID), SPELL_INVOCATION_OF_BLOOD_TALDARAM, EMOTE_TALDARAM_INVOCATION, 71081); } - - if (IsHeroic()) - { - Map::PlayerList const &PlList = me->GetMap()->GetPlayers(); - if (PlList.isEmpty()) - return; - - for (Map::PlayerList::const_iterator i = PlList.begin(); i != PlList.end(); ++i) - { - if (Player* player = i->getSource()) - { - if (player->isGameMaster()) - continue; - - if (player->isAlive()) - player->AddAura(SPELL_SHADOW_PRISON_DUMMY, player); - } - } - } } void SetData(uint32 /*type*/, uint32 data) @@ -297,8 +278,6 @@ class boss_blood_council_controller : public CreatureScript killer->Kill(prince); } } - - instance->DoRemoveAurasDueToSpellOnPlayers(SPELL_SHADOW_PRISON_DUMMY); } void UpdateAI(uint32 const diff) @@ -409,8 +388,6 @@ class boss_prince_keleseth_icc : public CreatureScript me->SetHealth(_spawnHealth); instance->SetData(DATA_ORB_WHISPERER_ACHIEVEMENT, uint32(true)); me->SetReactState(REACT_DEFENSIVE); - if (IsHeroic()) - DoCast(me, SPELL_SHADOW_PRISON); } void EnterCombat(Unit* /*who*/) @@ -421,6 +398,12 @@ class boss_prince_keleseth_icc : public CreatureScript events.ScheduleEvent(EVENT_BERSERK, 600000); events.ScheduleEvent(EVENT_SHADOW_RESONANCE, urand(10000, 15000)); events.ScheduleEvent(EVENT_SHADOW_LANCE, 2000); + + if (IsHeroic()) + { + me->AddAura(SPELL_SHADOW_PRISON, me); + DoCast(me, SPELL_SHADOW_PRISON_DUMMY); + } } void JustDied(Unit* /*killer*/) @@ -629,8 +612,6 @@ class boss_prince_taldaram_icc : public CreatureScript me->SetHealth(_spawnHealth); instance->SetData(DATA_ORB_WHISPERER_ACHIEVEMENT, uint32(true)); me->SetReactState(REACT_DEFENSIVE); - if (IsHeroic()) - DoCast(me, SPELL_SHADOW_PRISON); } void MoveInLineOfSight(Unit* /*who*/) @@ -645,6 +626,8 @@ class boss_prince_taldaram_icc : public CreatureScript events.ScheduleEvent(EVENT_BERSERK, 600000); events.ScheduleEvent(EVENT_GLITTERING_SPARKS, urand(12000, 15000)); events.ScheduleEvent(EVENT_CONJURE_FLAME, 20000); + if (IsHeroic()) + me->AddAura(SPELL_SHADOW_PRISON, me); } void JustDied(Unit* /*killer*/) @@ -852,8 +835,6 @@ class boss_prince_valanar_icc : public CreatureScript me->SetHealth(me->GetMaxHealth()); instance->SetData(DATA_ORB_WHISPERER_ACHIEVEMENT, uint32(true)); me->SetReactState(REACT_DEFENSIVE); - if (IsHeroic()) - DoCast(me, SPELL_SHADOW_PRISON); } void MoveInLineOfSight(Unit* /*who*/) @@ -868,6 +849,8 @@ class boss_prince_valanar_icc : public CreatureScript events.ScheduleEvent(EVENT_BERSERK, 600000); events.ScheduleEvent(EVENT_KINETIC_BOMB, urand(18000, 24000)); events.ScheduleEvent(EVENT_SHOCK_VORTEX, urand(15000, 20000)); + if (IsHeroic()) + me->AddAura(SPELL_SHADOW_PRISON, me); } void JustDied(Unit* /*killer*/) diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp index a6e3e78c96a..a84471d132b 100755 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp @@ -78,6 +78,7 @@ enum Spells // Slime Puddle SPELL_GROW_STACKER = 70345, + SPELL_GROW = 70347, SPELL_SLIME_PUDDLE_AURA = 70343, // Gas Cloud @@ -253,6 +254,9 @@ class boss_professor_putricide : public CreatureScript case NPC_GROWING_OOZE_PUDDLE: summon->CastSpell(summon, SPELL_GROW_STACKER, true); summon->CastSpell(summon, SPELL_SLIME_PUDDLE_AURA, true); + // blizzard casts this spell 7 times initially (confirmed in sniff) + for (uint8 i = 0; i < 7; ++i) + summon->CastSpell(summon, SPELL_GROW, true); break; case NPC_GAS_CLOUD: // no possible aura seen in sniff adding the aurastate @@ -811,38 +815,45 @@ class spell_putricide_ooze_channel : public SpellScriptLoader } }; +class ExactDistanceCheck +{ + public: + ExactDistanceCheck(Unit* source, float dist) : _source(source), _dist(dist) {} + + bool operator()(Unit* unit) + { + return _source->GetExactDist2d(unit) > _dist; + } + + private: + Unit* _source; + float _dist; +}; + class spell_putricide_slime_puddle : public SpellScriptLoader { public: spell_putricide_slime_puddle() : SpellScriptLoader("spell_putricide_slime_puddle") { } - class spell_putricide_slime_puddle_AuraScript : public AuraScript + class spell_putricide_slime_puddle_SpellScript : public SpellScript { - PrepareAuraScript(spell_putricide_slime_puddle_AuraScript); + PrepareSpellScript(spell_putricide_slime_puddle_SpellScript); - void HandleTriggerSpell(AuraEffect const* aurEff) + void ScaleRange(std::list<Unit*>& targets) { - PreventDefaultAction(); - if (Unit* caster = GetCaster()) - { - int32 radiusMod = 4; - if (Aura* size = caster->GetAura(70347)) - radiusMod += size->GetStackAmount(); - - uint32 triggerSpellId = GetSpellInfo()->Effects[aurEff->GetEffIndex()].TriggerSpell; - caster->CastCustomSpell(triggerSpellId, SPELLVALUE_RADIUS_MOD, radiusMod * 100, caster, true); - } + targets.remove_if(ExactDistanceCheck(GetCaster(), 2.5f * GetCaster()->GetFloatValue(OBJECT_FIELD_SCALE_X))); } void Register() { - OnEffectPeriodic += AuraEffectPeriodicFn(spell_putricide_slime_puddle_AuraScript::HandleTriggerSpell, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); + OnUnitTargetSelect += SpellUnitTargetFn(spell_putricide_slime_puddle_SpellScript::ScaleRange, EFFECT_0, TARGET_UNIT_DEST_AREA_ENEMY); + OnUnitTargetSelect += SpellUnitTargetFn(spell_putricide_slime_puddle_SpellScript::ScaleRange, EFFECT_1, TARGET_UNIT_DEST_AREA_ENTRY); } }; - AuraScript* GetAuraScript() const + SpellScript* GetSpellScript() const { - return new spell_putricide_slime_puddle_AuraScript(); + return new spell_putricide_slime_puddle_SpellScript(); } }; @@ -1047,7 +1058,6 @@ class spell_putricide_unbound_plague : public SpellScriptLoader return; uint32 plagueId = sSpellMgr->GetSpellIdForDifficulty(SPELL_UNBOUND_PLAGUE, GetCaster()); - uint32 searcherId = sSpellMgr->GetSpellIdForDifficulty(SPELL_UNBOUND_PLAGUE_SEARCHER, GetCaster()); if (!GetHitUnit()->HasAura(plagueId)) { @@ -1057,10 +1067,10 @@ class spell_putricide_unbound_plague : public SpellScriptLoader { if (Aura* newPlague = professor->AddAura(plagueId, GetHitUnit())) { - newPlague->SetMaxDuration(oldPlague->GetDuration()); + newPlague->SetMaxDuration(oldPlague->GetMaxDuration()); newPlague->SetDuration(oldPlague->GetDuration()); oldPlague->Remove(); - GetCaster()->RemoveAurasDueToSpell(searcherId); + GetCaster()->RemoveAurasDueToSpell(SPELL_UNBOUND_PLAGUE_SEARCHER); GetCaster()->CastSpell(GetCaster(), SPELL_PLAGUE_SICKNESS, true); GetCaster()->CastSpell(GetCaster(), SPELL_UNBOUND_PLAGUE_PROTECTION, true); professor->CastSpell(GetHitUnit(), SPELL_UNBOUND_PLAGUE_SEARCHER, true); @@ -1110,14 +1120,14 @@ class spell_putricide_eat_ooze : public SpellScriptLoader if (Aura* grow = target->GetAura(uint32(GetEffectValue()))) { - if (grow->GetStackAmount() < 4) + if (grow->GetStackAmount() < 3) { target->RemoveAurasDueToSpell(SPELL_GROW_STACKER); target->RemoveAura(grow); - target->DespawnOrUnsummon(); + target->DespawnOrUnsummon(1); } else - grow->ModStackAmount(-4); + grow->ModStackAmount(-3); } } diff --git a/src/server/scripts/Northrend/Nexus/EyeOfEternity/instance_eye_of_eternity.cpp b/src/server/scripts/Northrend/Nexus/EyeOfEternity/instance_eye_of_eternity.cpp index 09fe37d140c..4d4b8e90e7b 100644 --- a/src/server/scripts/Northrend/Nexus/EyeOfEternity/instance_eye_of_eternity.cpp +++ b/src/server/scripts/Northrend/Nexus/EyeOfEternity/instance_eye_of_eternity.cpp @@ -86,6 +86,7 @@ public: return true; } + //TODO: this should be handled in map, maybe add a summon function in map // There is no other way afaik... void SpawnGameObject(uint32 entry, Position& pos) { @@ -98,7 +99,7 @@ public: return; } - instance->Add(go); + instance->AddToMap(go); } void OnGameObjectCreate(GameObject* go) diff --git a/src/server/scripts/Northrend/Nexus/Nexus/boss_magus_telestra.cpp b/src/server/scripts/Northrend/Nexus/Nexus/boss_magus_telestra.cpp index 1c7b538eb02..a8edd40d6b5 100644 --- a/src/server/scripts/Northrend/Nexus/Nexus/boss_magus_telestra.cpp +++ b/src/server/scripts/Northrend/Nexus/Nexus/boss_magus_telestra.cpp @@ -238,7 +238,7 @@ public: for (uint8 n = 0; n < 3; ++n) time[n] = 0; me->GetMotionMaster()->Clear(); - me->GetMap()->CreatureRelocation(me, CenterOfRoom.GetPositionX(), CenterOfRoom.GetPositionY(), CenterOfRoom.GetPositionZ(), CenterOfRoom.GetOrientation()); + me->SetPosition(CenterOfRoom.GetPositionX(), CenterOfRoom.GetPositionY(), CenterOfRoom.GetPositionZ(), CenterOfRoom.GetOrientation()); DoCast(me, SPELL_TELESTRA_BACK); me->SetVisible(true); if (Phase == 1) 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 ec336d3402c..ad79d1b56cc 100644 --- a/src/server/scripts/Northrend/Ulduar/ulduar/boss_flame_leviathan.cpp +++ b/src/server/scripts/Northrend/Ulduar/ulduar/boss_flame_leviathan.cpp @@ -757,7 +757,7 @@ class boss_flame_leviathan_safety_container : public CreatureScript me->GetPosition(x, y, z); z = me->GetMap()->GetHeight(x, y, z); me->GetMotionMaster()->MovePoint(0, x, y, z); - me->GetMap()->CreatureRelocation(me, x, y, z, 0); + me->SetPosition(x, y, z, 0); } void UpdateAI(uint32 const /*diff*/) @@ -1680,7 +1680,8 @@ class spell_pursue : public SpellScriptLoader void FilterTargetsSubsequently(std::list<Unit*>& targets) { targets.clear(); - targets.push_back(_target); + if(_target) + targets.push_back(_target); } void HandleScript(SpellEffIndex /*eff*/) diff --git a/src/server/scripts/Northrend/VaultOfArchavon/boss_toravon.cpp b/src/server/scripts/Northrend/VaultOfArchavon/boss_toravon.cpp index 41d43a08f5d..41e80b1b777 100644 --- a/src/server/scripts/Northrend/VaultOfArchavon/boss_toravon.cpp +++ b/src/server/scripts/Northrend/VaultOfArchavon/boss_toravon.cpp @@ -260,7 +260,7 @@ class mob_frozen_orb_stalker : public CreatureScript { Position pos; me->GetNearPoint(toravon, pos.m_positionX, pos.m_positionY, pos.m_positionZ, 0.0f, 10.0f, 0.0f); - me->SetPosition(pos, true); + me->SetPosition(pos); DoCast(me, SPELL_FROZEN_ORB_SUMMON); } } diff --git a/src/server/scripts/OutdoorPvP/OutdoorPvPSI.cpp b/src/server/scripts/OutdoorPvP/OutdoorPvPSI.cpp index 7727f761588..23477741ba1 100755 --- a/src/server/scripts/OutdoorPvP/OutdoorPvPSI.cpp +++ b/src/server/scripts/OutdoorPvP/OutdoorPvPSI.cpp @@ -170,7 +170,7 @@ bool OutdoorPvPSI::HandleDropFlag(Player* player, uint32 spellId) else { go->SetRespawnTime(0); - map->Add(go); + map->AddToMap(go); } } } @@ -199,7 +199,7 @@ bool OutdoorPvPSI::HandleDropFlag(Player* player, uint32 spellId) else { go->SetRespawnTime(0); - map->Add(go); + map->AddToMap(go); } } } diff --git a/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_grandmaster_vorpil.cpp b/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_grandmaster_vorpil.cpp index 9b985d6d93e..6d3a5f181d4 100644 --- a/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_grandmaster_vorpil.cpp +++ b/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_grandmaster_vorpil.cpp @@ -291,7 +291,7 @@ public: if (i_pl->isAlive() && !i_pl->HasAura(SPELL_BANISH)) i_pl->TeleportTo(me->GetMapId(), VorpilPosition[0], VorpilPosition[1], VorpilPosition[2], 0, TELE_TO_NOT_LEAVE_COMBAT); - me->GetMap()->CreatureRelocation(me, VorpilPosition[0], VorpilPosition[1], VorpilPosition[2], 0.0f); + me->SetPosition(VorpilPosition[0], VorpilPosition[1], VorpilPosition[2], 0.0f); DoCast(me, SPELL_DRAW_SHADOWS, true); DoCast(me, SPELL_RAIN_OF_FIRE); diff --git a/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp b/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp index 60845ae6365..aec9ffcf5cc 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp @@ -1967,7 +1967,7 @@ void boss_illidan_stormrage::boss_illidan_stormrageAI::HandleTalkSequence() Summons.DespawnAll(); break; case 17: - if (GETUNIT(Akama, AkamaGUID)) + if (GETCRE(Akama, AkamaGUID)) { if (!me->IsWithinDistInMap(Akama, 15)) { @@ -1976,7 +1976,7 @@ void boss_illidan_stormrage::boss_illidan_stormrageAI::HandleTalkSequence() x += 10; y += 10; Akama->GetMotionMaster()->Clear(false); //Akama->GetMotionMaster()->MoveIdle(); - Akama->GetMap()->CreatureRelocation(me, x, y, z, 0.0f); + Akama->SetPosition(x, y, z, 0.0f); Akama->SendMonsterMove(x, y, z, 0, MOVEMENTFLAG_NONE, 0);//Illidan must not die until Akama arrives. Akama->GetMotionMaster()->MoveChase(me); } diff --git a/src/server/scripts/Outland/TempestKeep/Eye/boss_alar.cpp b/src/server/scripts/Outland/TempestKeep/Eye/boss_alar.cpp index 19280bd71f5..dcbc2832f27 100644 --- a/src/server/scripts/Outland/TempestKeep/Eye/boss_alar.cpp +++ b/src/server/scripts/Outland/TempestKeep/Eye/boss_alar.cpp @@ -291,7 +291,7 @@ class boss_alar : public CreatureScript if (me->IsWithinDist3d(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 5.0f)) dist = 5.0f; WaitTimer = 1000 + uint32(floor(dist / 80 * 1000.0f)); - me->GetMap()->CreatureRelocation(me, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0.0f); + me->SetPosition(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0.0f); me->StopMoving(); WaitEvent = WE_LAND; } diff --git a/src/server/scripts/Outland/TempestKeep/Eye/boss_astromancer.cpp b/src/server/scripts/Outland/TempestKeep/Eye/boss_astromancer.cpp index f079f68d943..6fac13aa8ad 100644 --- a/src/server/scripts/Outland/TempestKeep/Eye/boss_astromancer.cpp +++ b/src/server/scripts/Outland/TempestKeep/Eye/boss_astromancer.cpp @@ -278,7 +278,7 @@ class boss_high_astromancer_solarian : public CreatureScript Phase1_Timer = 50000; //After these 50 seconds she portals to the middle of the room and disappears, leaving 3 light portals behind. me->GetMotionMaster()->Clear(); - me->GetMap()->CreatureRelocation(me, CENTER_X, CENTER_Y, CENTER_Z, CENTER_O); + me->SetPosition(CENTER_X, CENTER_Y, CENTER_Z, CENTER_O); for (uint8 i=0; i <= 2; ++i) { if (!i) @@ -346,7 +346,7 @@ class boss_high_astromancer_solarian : public CreatureScript //15 seconds later Solarian reappears out of one of the 3 portals. Simultaneously, 2 healers appear in the two other portals. int i = rand()%3; me->GetMotionMaster()->Clear(); - me->GetMap()->CreatureRelocation(me, Portals[i][0], Portals[i][1], Portals[i][2], CENTER_O); + me->SetPosition(Portals[i][0], Portals[i][1], Portals[i][2], CENTER_O); for (int j=0; j <= 2; j++) if (j != i) diff --git a/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp b/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp index 52a23196ee0..d987601c5bd 100644 --- a/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp +++ b/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp @@ -819,7 +819,7 @@ class boss_kaelthas : public CreatureScript me->StopMoving(); me->GetMotionMaster()->Clear(); me->GetMotionMaster()->MoveIdle(); - me->GetMap()->CreatureRelocation(me, afGravityPos[0], afGravityPos[1], afGravityPos[2], 0); + me->SetPosition(afGravityPos[0], afGravityPos[1], afGravityPos[2], 0); me->SendMonsterMove(afGravityPos[0], afGravityPos[1], afGravityPos[2], 0, 0, 0); me->InterruptNonMeleeSpells(false); @@ -886,7 +886,7 @@ class boss_kaelthas : public CreatureScript me->StopMoving(); me->GetMotionMaster()->Clear(); me->GetMotionMaster()->MoveIdle(); - me->GetMap()->CreatureRelocation(me, afGravityPos[0], afGravityPos[1], afGravityPos[2], 0); + me->SetPosition(afGravityPos[0], afGravityPos[1], afGravityPos[2], 0); me->SendMonsterMove(afGravityPos[0], afGravityPos[1], afGravityPos[2], 0, MOVEMENTFLAG_NONE, 0); // 1) Kael'thas will portal the whole raid right into his body |