Merge branch '4.3.4' of https://gitlab.com/trinitycore/TrinityCore_434 into ShatteredWorld

# Conflicts:
#	src/server/scripts/EasternKingdoms/Gilneas/chapter1.cpp
#	src/server/scripts/Kalimdor/LostCityOfTheTolvir/boss_lockmaw_and_augh.cpp
#	src/server/scripts/Kalimdor/LostCityOfTheTolvir/instance_lost_city_of_the_tolvir.cpp
#	src/server/scripts/Kalimdor/LostCityOfTheTolvir/lost_city_of_the_tolvir.h
#	src/server/scripts/Spells/spell_quest.cpp
This commit is contained in:
Ovahlord committed 2017-12-27 18:06:47 +01:00
commit 3e4451cab7
39 files changed
+608 -158

No files matched your search

+3 -2
View File
@@ -25,6 +25,7 @@
#include "QuestDef.h"
#include "GameObject.h"
#include "CreatureAI.h"
#include "ObjectGuid.h"
class TC_GAME_API GameObjectAI
{
@@ -42,8 +43,8 @@ class TC_GAME_API GameObjectAI
// Pass parameters between AI
virtual void DoAction(int32 /*param = 0 */) { }
virtual void SetGUID(uint64 /*guid*/, int32 /*id = 0 */) { }
virtual uint64 GetGUID(int32 /*id = 0 */) const { return 0; }
virtual void SetGUID(ObjectGuid /*guid*/, int32 /*id = 0 */) { }
virtual ObjectGuid GetGUID(int32 /*id = 0 */) const { return ObjectGuid::Empty; }
static int32 Permissible(GameObject const* /*go*/) { return PERMIT_BASE_NO; }
+2
View File
@@ -551,6 +551,8 @@ bool PetAI::CanAttack(Unit* target)
return false;
}
ASSERT(me->GetCharmInfo());
// Passive - passive pets can attack if told to
if (me->HasReactState(REACT_PASSIVE))
return me->GetCharmInfo()->IsCommandAttack();
@@ -2610,12 +2610,6 @@ void Creature::SetPosition(float x, float y, float z, float o)
GetVehicleKit()->RelocatePassengers();
}
bool Creature::IsDungeonBoss() const
{
CreatureTemplate const* cinfo = sObjectMgr->GetCreatureTemplate(GetEntry());
return cinfo && (cinfo->flags_extra & CREATURE_FLAG_EXTRA_DUNGEON_BOSS);
}
float Creature::GetAggroRange(Unit const* target) const
{
// Determines the aggro range for creatures (usually pets), used mainly for aggressive pet target selection.
+2 -2
View File
@@ -502,6 +502,8 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma
bool CanWalk() const { return (GetCreatureTemplate()->InhabitType & INHABIT_GROUND) != 0; }
bool CanSwim() const { return (GetCreatureTemplate()->InhabitType & INHABIT_WATER) != 0 || IsPet(); }
bool CanFly() const override { return (GetCreatureTemplate()->InhabitType & INHABIT_AIR) != 0; }
bool IsDungeonBoss() const { return (GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_DUNGEON_BOSS) != 0; }
bool IsAffectedByDiminishingReturns() const override { return Unit::IsAffectedByDiminishingReturns() || (GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_ALL_DIMINISH) != 0; }
void SetReactState(ReactStates st) { m_reactState = st; }
ReactStates GetReactState() const { return m_reactState; }
@@ -518,8 +520,6 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma
bool isElite() const;
bool isWorldBoss() const;
bool IsDungeonBoss() const;
uint8 getLevelForTarget(WorldObject const* target) const override; // overwrite Unit::getLevelForTarget for boss level support
bool IsInEvadeMode() const { return HasUnitState(UNIT_STATE_EVADE); }
+32 -29
View File
@@ -4481,17 +4481,6 @@ bool Unit::HasNegativeAuraWithInterruptFlag(uint32 flag, ObjectGuid guid) const
return false;
}
bool Unit::HasNegativeAuraWithAttribute(uint32 flag, ObjectGuid guid) const
{
for (AuraApplicationMap::const_iterator iter = m_appliedAuras.begin(); iter != m_appliedAuras.end(); ++iter)
{
Aura const* aura = iter->second->GetBase();
if (!iter->second->IsPositive() && aura->GetSpellInfo()->Attributes & flag && (!guid || aura->GetCasterGUID() == guid))
return true;
}
return false;
}
bool Unit::HasAuraWithMechanic(uint32 mechanicMask) const
{
for (AuraApplicationMap::const_iterator iter = m_appliedAuras.begin(); iter != m_appliedAuras.end(); ++iter)
@@ -4509,6 +4498,26 @@ bool Unit::HasAuraWithMechanic(uint32 mechanicMask) const
return false;
}
bool Unit::HasStrongerAuraWithDR(SpellInfo const* auraSpellInfo, Unit* caster, bool triggered) const
{
DiminishingGroup diminishGroup = auraSpellInfo->GetDiminishingReturnsGroupForSpell(triggered);
DiminishingLevels level = GetDiminishing(diminishGroup);
for (auto itr = m_appliedAuras.begin(); itr != m_appliedAuras.end(); ++itr)
{
SpellInfo const* spellInfo = itr->second->GetBase()->GetSpellInfo();
if (spellInfo->GetDiminishingReturnsGroupForSpell(triggered) != diminishGroup)
continue;
int32 existingDuration = itr->second->GetBase()->GetMaxDuration();
int32 newDuration = auraSpellInfo->GetMaxDuration();
ApplyDiminishingToDuration(auraSpellInfo, triggered, newDuration, caster, level);
if (newDuration > 0 && newDuration < existingDuration)
return true;
}
return false;
}
AuraEffect* Unit::IsScriptOverriden(SpellInfo const* spell, int32 script) const
{
AuraEffectList const& auras = GetAuraEffectsByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS);
@@ -9434,31 +9443,28 @@ void Unit::ModSpellDurationTime(SpellInfo const* spellInfo, int32 & duration, Sp
duration = int32(float(duration) * m_modAttackSpeedPct[RANGED_ATTACK]);
}
DiminishingLevels Unit::GetDiminishing(DiminishingGroup group)
DiminishingLevels Unit::GetDiminishing(DiminishingGroup group) const
{
DiminishingReturn& diminish = m_Diminishing[group];
DiminishingReturn const& diminish = m_Diminishing[group];
if (!diminish.hitCount)
return DIMINISHING_LEVEL_1;
// If last spell was cast more than 15 seconds ago - reset the count.
// If last spell was cast more than 15 seconds ago - reset level
if (!diminish.stack && GetMSTimeDiffToNow(diminish.hitTime) > 15000)
{
diminish.hitCount = DIMINISHING_LEVEL_1;
return DIMINISHING_LEVEL_1;
}
return DiminishingLevels(diminish.hitCount);
}
void Unit::IncrDiminishing(SpellInfo const* auraSpellInfo, bool triggered)
{
DiminishingGroup const group = auraSpellInfo->GetDiminishingReturnsGroupForSpell(triggered);
DiminishingLevels const maxLevel = auraSpellInfo->GetDiminishingReturnsMaxLevel(triggered);
DiminishingGroup group = auraSpellInfo->GetDiminishingReturnsGroupForSpell(triggered);
uint32 currentLevel = GetDiminishing(group);
uint32 const maxLevel = auraSpellInfo->GetDiminishingReturnsMaxLevel(triggered);
// Checking for existing in the table
DiminishingReturn& diminish = m_Diminishing[group];
if (static_cast<int32>(diminish.hitCount) < maxLevel)
++diminish.hitCount;
if (currentLevel < maxLevel)
diminish.hitCount = currentLevel + 1;
}
bool Unit::ApplyDiminishingToDuration(SpellInfo const* auraSpellInfo, bool triggered, int32& duration, Unit* caster, DiminishingLevels previousLevel) const
@@ -9479,9 +9485,7 @@ bool Unit::ApplyDiminishingToDuration(SpellInfo const* auraSpellInfo, bool trigg
Unit const* target = targetOwner ? targetOwner : this;
Unit const* source = casterOwner ? casterOwner : caster;
if ((target->GetTypeId() == TYPEID_PLAYER
|| target->ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_ALL_DIMINISH)
&& source->GetTypeId() == TYPEID_PLAYER)
if (target->IsAffectedByDiminishingReturns() && source->GetTypeId() == TYPEID_PLAYER)
duration = limitDuration;
}
@@ -9503,10 +9507,9 @@ bool Unit::ApplyDiminishingToDuration(SpellInfo const* auraSpellInfo, bool trigg
}
}
// Some diminishings applies to mobs too (for example, Stun)
else if ((auraSpellInfo->GetDiminishingReturnsGroupType(triggered) == DRTYPE_PLAYER
&& ((targetOwner ? (targetOwner->GetTypeId() == TYPEID_PLAYER) : (GetTypeId() == TYPEID_PLAYER))
|| (GetTypeId() == TYPEID_UNIT && ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_ALL_DIMINISH)))
|| auraSpellInfo->GetDiminishingReturnsGroupType(triggered) == DRTYPE_ALL)
else if (auraSpellInfo->GetDiminishingReturnsGroupType(triggered) == DRTYPE_ALL ||
(auraSpellInfo->GetDiminishingReturnsGroupType(triggered) == DRTYPE_PLAYER &&
(targetOwner ? targetOwner->IsAffectedByDiminishingReturns() : IsAffectedByDiminishingReturns())))
{
DiminishingLevels diminish = previousLevel;
switch (diminish)
+5 -2
View File
@@ -1315,7 +1315,8 @@ class TC_GAME_API Unit : public WorldObject
void CleanupBeforeRemoveFromMap(bool finalCleanup);
void CleanupsBeforeDelete(bool finalCleanup = true) override; // used in ~Creature/~Player (or before mass creature delete to remove cross-references to already deleted units)
DiminishingLevels GetDiminishing(DiminishingGroup group);
virtual bool IsAffectedByDiminishingReturns() const { return (GetCharmerOrOwnerPlayerOrPlayerItself() != nullptr); }
DiminishingLevels GetDiminishing(DiminishingGroup group) const;
void IncrDiminishing(SpellInfo const* auraSpellInfo, bool triggered);
bool ApplyDiminishingToDuration(SpellInfo const* auraSpellInfo, bool triggered, int32& duration, Unit* caster, DiminishingLevels previousLevel) const;
void ApplyDiminishingAura(DiminishingGroup group, bool apply);
@@ -1598,7 +1599,9 @@ class TC_GAME_API Unit : public WorldObject
void CastSpell(SpellCastTargets const& targets, SpellInfo const* spellInfo, CustomSpellValues const* value, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, ObjectGuid originalCaster = ObjectGuid::Empty);
void CastSpell(Unit* victim, uint32 spellId, bool triggered, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, ObjectGuid originalCaster = ObjectGuid::Empty);
void CastSpell(std::nullptr_t, uint32 spellId, bool triggered, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, ObjectGuid originalCaster = ObjectGuid::Empty) { CastSpell((Unit*)nullptr, spellId, triggered, castItem, triggeredByAura, originalCaster); }
void CastSpell(Unit* victim, uint32 spellId, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, ObjectGuid originalCaster = ObjectGuid::Empty);
void CastSpell(std::nullptr_t, uint32 spellId, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, ObjectGuid originalCaster = ObjectGuid::Empty) { CastSpell((Unit*)nullptr, spellId, triggerFlags, castItem, triggeredByAura, originalCaster); }
void CastSpell(Unit* victim, SpellInfo const* spellInfo, bool triggered, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, ObjectGuid originalCaster = ObjectGuid::Empty);
void CastSpell(Unit* victim, SpellInfo const* spellInfo, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, ObjectGuid originalCaster = ObjectGuid::Empty);
void CastSpell(float x, float y, float z, uint32 spellId, bool triggered, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, ObjectGuid originalCaster = ObjectGuid::Empty);
@@ -1840,8 +1843,8 @@ class TC_GAME_API Unit : public WorldObject
bool HasAuraTypeWithAffectMask(AuraType auratype, SpellInfo const* affectedSpell) const;
bool HasAuraTypeWithValue(AuraType auratype, int32 value) const;
bool HasNegativeAuraWithInterruptFlag(uint32 flag, ObjectGuid guid = ObjectGuid::Empty) const;
bool HasNegativeAuraWithAttribute(uint32 flag, ObjectGuid guid = ObjectGuid::Empty) const;
bool HasAuraWithMechanic(uint32 mechanicMask) const;
bool HasStrongerAuraWithDR(SpellInfo const* auraSpellInfo, Unit* caster, bool triggered) const;
AuraEffect* IsScriptOverriden(SpellInfo const* spell, int32 script) const;
uint32 GetDiseasesByCaster(ObjectGuid casterGUID, bool remove = false);
+1 -1
View File
@@ -1719,7 +1719,7 @@ void GameEventMgr::SetHolidayEventTime(GameEventData& event)
if (!event.holidayStage) // Ignore holiday
return;
const HolidaysEntry* holiday = sHolidaysStore.LookupEntry(event.holiday_id);
HolidaysEntry const* holiday = sHolidaysStore.LookupEntry(event.holiday_id);
if (!holiday->Date[0] || !holiday->Duration[0]) // Invalid definitions
{
+8 -1
View File
@@ -899,7 +899,14 @@ void ObjectMgr::CheckCreatureTemplate(CreatureTemplate const* cInfo)
ok = true;
}
if (cInfo->AIName == "TotemAI")
if (cInfo->mingold > cInfo->maxgold)
{
TC_LOG_ERROR("sql.sql", "Creature (Entry: %u) has `mingold` %u which is greater than `maxgold` %u, setting `maxgold` to %u.",
cInfo->Entry, cInfo->mingold, cInfo->maxgold, cInfo->mingold);
const_cast<CreatureTemplate*>(cInfo)->maxgold = cInfo->mingold;
}
if (cInfo->AIName == "TotemAI" || cInfo->AIName == "PetAI")
{
TC_LOG_ERROR("sql.sql", "Creature (Entry: %u) has not-allowed `AIName` '%s' set, removing", cInfo->Entry, cInfo->AIName.c_str());
const_cast<CreatureTemplate*>(cInfo)->AIName.clear();
+84 -58
View File
@@ -556,23 +556,10 @@ void PoolGroup<Quest>::ReSpawn1Object(PoolObject* /*obj*/) { }
////////////////////////////////////////////////////////////
// Methods of class PoolMgr
PoolMgr::PoolMgr() : max_pool_id(0) { }
PoolMgr::PoolMgr() { }
void PoolMgr::Initialize()
{
QueryResult result = WorldDatabase.Query("SELECT MAX(entry) FROM pool_template");
if (result)
{
Field* fields = result->Fetch();
max_pool_id = fields[0].GetUInt32();
}
mPoolTemplate.resize(max_pool_id + 1);
mPoolCreatureGroups.resize(max_pool_id + 1);
mPoolGameobjectGroups.resize(max_pool_id + 1);
mPoolPoolGroups.resize(max_pool_id + 1);
mPoolQuestGroups.resize(max_pool_id + 1);
mQuestSearchMap.clear();
mGameobjectSearchMap.clear();
mCreatureSearchMap.clear();
@@ -645,9 +632,10 @@ void PoolMgr::LoadFromDB()
TC_LOG_ERROR("sql.sql", "`pool_creature` has a non existing creature spawn (GUID: %u) defined for pool id (%u), skipped.", guid, pool_id);
continue;
}
if (pool_id > max_pool_id)
auto it = mPoolTemplate.find(pool_id);
if (it == mPoolTemplate.end())
{
TC_LOG_ERROR("sql.sql", "`pool_creature` pool id (%u) is out of range compared to max pool id in `pool_template`, skipped.", pool_id);
TC_LOG_ERROR("sql.sql", "`pool_creature` pool id (%u) is not in `pool_template`, skipped.", pool_id);
continue;
}
if (chance < 0 || chance > 100)
@@ -711,9 +699,10 @@ void PoolMgr::LoadFromDB()
continue;
}
if (pool_id > max_pool_id)
auto it = mPoolTemplate.find(pool_id);
if (it == mPoolTemplate.end())
{
TC_LOG_ERROR("sql.sql", "`pool_gameobject` pool id (%u) is out of range compared to max pool id in `pool_template`, skipped.", pool_id);
TC_LOG_ERROR("sql.sql", "`pool_gameobject` pool id (%u) is not in `pool_template`, skipped.", pool_id);
continue;
}
@@ -763,15 +752,21 @@ void PoolMgr::LoadFromDB()
uint32 mother_pool_id = fields[1].GetUInt32();
float chance = fields[2].GetFloat();
if (mother_pool_id > max_pool_id)
{
TC_LOG_ERROR("sql.sql", "`pool_pool` mother_pool id (%u) is out of range compared to max pool id in `pool_template`, skipped.", mother_pool_id);
continue;
auto it = mPoolTemplate.find(mother_pool_id);
if (it == mPoolTemplate.end())
{
TC_LOG_ERROR("sql.sql", "`pool_pool` mother_pool id (%u) is not in `pool_template`, skipped.", mother_pool_id);
continue;
}
}
if (child_pool_id > max_pool_id)
{
TC_LOG_ERROR("sql.sql", "`pool_pool` included pool_id (%u) is out of range compared to max pool id in `pool_template`, skipped.", child_pool_id);
continue;
auto it = mPoolTemplate.find(child_pool_id);
if (it == mPoolTemplate.end())
{
TC_LOG_ERROR("sql.sql", "`pool_pool` included pool_id (%u) is not in `pool_template`, skipped.", child_pool_id);
continue;
}
}
if (mother_pool_id == child_pool_id)
{
@@ -796,10 +791,11 @@ void PoolMgr::LoadFromDB()
while (result->NextRow());
// Now check for circular reference
for (uint32 i=0; i < max_pool_id; ++i)
// All pool_ids are in pool_template
for (auto const it : mPoolTemplate)
{
std::set<uint32> checkedPools;
for (SearchMap::iterator poolItr = mPoolSearchMap.find(i); poolItr != mPoolSearchMap.end(); poolItr = mPoolSearchMap.find(poolItr->second))
for (SearchMap::iterator poolItr = mPoolSearchMap.find(it.first); poolItr != mPoolSearchMap.end(); poolItr = mPoolSearchMap.find(poolItr->second))
{
checkedPools.insert(poolItr->first);
if (checkedPools.find(poolItr->second) != checkedPools.end())
@@ -862,9 +858,10 @@ void PoolMgr::LoadFromDB()
continue;
}
if (pool_id > max_pool_id)
auto it = mPoolTemplate.find(pool_id);
if (it == mPoolTemplate.end())
{
TC_LOG_ERROR("sql.sql", "`pool_quest` pool id (%u) is out of range compared to max pool id in `pool_template`, skipped.", pool_id);
TC_LOG_ERROR("sql.sql", "`pool_quest` pool id (%u) is not in `pool_template`, skipped.", pool_id);
continue;
}
@@ -969,10 +966,10 @@ void PoolMgr::SaveQuestsToDB()
for (PoolGroupQuestMap::iterator itr = mPoolQuestGroups.begin(); itr != mPoolQuestGroups.end(); ++itr)
{
if (itr->isEmpty())
if (itr->second.isEmpty())
continue;
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_QUEST_POOL_SAVE);
stmt->setUInt32(0, itr->GetPoolId());
stmt->setUInt32(0, itr->second.GetPoolId());
trans->Append(stmt);
}
@@ -994,12 +991,12 @@ void PoolMgr::ChangeDailyQuests()
{
for (PoolGroupQuestMap::iterator itr = mPoolQuestGroups.begin(); itr != mPoolQuestGroups.end(); ++itr)
{
if (Quest const* quest = sObjectMgr->GetQuestTemplate(itr->GetFirstEqualChancedObjectId()))
if (Quest const* quest = sObjectMgr->GetQuestTemplate(itr->second.GetFirstEqualChancedObjectId()))
{
if (quest->IsWeekly())
continue;
UpdatePool<Quest>(itr->GetPoolId(), 1); // anything non-zero means don't load from db
UpdatePool<Quest>(itr->second.GetPoolId(), 1); // anything non-zero means don't load from db
}
}
@@ -1010,12 +1007,12 @@ void PoolMgr::ChangeWeeklyQuests()
{
for (PoolGroupQuestMap::iterator itr = mPoolQuestGroups.begin(); itr != mPoolQuestGroups.end(); ++itr)
{
if (Quest const* quest = sObjectMgr->GetQuestTemplate(itr->GetFirstEqualChancedObjectId()))
if (Quest const* quest = sObjectMgr->GetQuestTemplate(itr->second.GetFirstEqualChancedObjectId()))
{
if (quest->IsDaily())
continue;
UpdatePool<Quest>(itr->GetPoolId(), 1);
UpdatePool<Quest>(itr->second.GetPoolId(), 1);
}
}
@@ -1027,8 +1024,9 @@ void PoolMgr::ChangeWeeklyQuests()
template<>
void PoolMgr::SpawnPool<Creature>(uint32 pool_id, uint32 db_guid)
{
if (!mPoolCreatureGroups[pool_id].isEmpty())
mPoolCreatureGroups[pool_id].SpawnObject(mSpawnedData, mPoolTemplate[pool_id].MaxLimit, db_guid);
auto it = mPoolCreatureGroups.find(pool_id);
if (it != mPoolCreatureGroups.end() && !it->second.isEmpty())
it->second.SpawnObject(mSpawnedData, mPoolTemplate[pool_id].MaxLimit, db_guid);
}
// Call to spawn a pool, if cache if true the method will spawn only if cached entry is different
@@ -1036,8 +1034,9 @@ void PoolMgr::SpawnPool<Creature>(uint32 pool_id, uint32 db_guid)
template<>
void PoolMgr::SpawnPool<GameObject>(uint32 pool_id, uint32 db_guid)
{
if (!mPoolGameobjectGroups[pool_id].isEmpty())
mPoolGameobjectGroups[pool_id].SpawnObject(mSpawnedData, mPoolTemplate[pool_id].MaxLimit, db_guid);
auto it = mPoolGameobjectGroups.find(pool_id);
if (it != mPoolGameobjectGroups.end() && !it->second.isEmpty())
it->second.SpawnObject(mSpawnedData, mPoolTemplate[pool_id].MaxLimit, db_guid);
}
// Call to spawn a pool, if cache if true the method will spawn only if cached entry is different
@@ -1045,16 +1044,18 @@ void PoolMgr::SpawnPool<GameObject>(uint32 pool_id, uint32 db_guid)
template<>
void PoolMgr::SpawnPool<Pool>(uint32 pool_id, uint32 sub_pool_id)
{
if (!mPoolPoolGroups[pool_id].isEmpty())
mPoolPoolGroups[pool_id].SpawnObject(mSpawnedData, mPoolTemplate[pool_id].MaxLimit, sub_pool_id);
auto it = mPoolPoolGroups.find(pool_id);
if (it != mPoolPoolGroups.end() && !it->second.isEmpty())
it->second.SpawnObject(mSpawnedData, mPoolTemplate[pool_id].MaxLimit, sub_pool_id);
}
// Call to spawn a pool
template<>
void PoolMgr::SpawnPool<Quest>(uint32 pool_id, uint32 quest_id)
{
if (!mPoolQuestGroups[pool_id].isEmpty())
mPoolQuestGroups[pool_id].SpawnObject(mSpawnedData, mPoolTemplate[pool_id].MaxLimit, quest_id);
auto it = mPoolQuestGroups.find(pool_id);
if (it != mPoolQuestGroups.end() && !it->second.isEmpty())
it->second.SpawnObject(mSpawnedData, mPoolTemplate[pool_id].MaxLimit, quest_id);
}
void PoolMgr::SpawnPool(uint32 pool_id)
@@ -1068,27 +1069,52 @@ void PoolMgr::SpawnPool(uint32 pool_id)
// Call to despawn a pool, all gameobjects/creatures in this pool are removed
void PoolMgr::DespawnPool(uint32 pool_id)
{
if (!mPoolCreatureGroups[pool_id].isEmpty())
mPoolCreatureGroups[pool_id].DespawnObject(mSpawnedData);
if (!mPoolGameobjectGroups[pool_id].isEmpty())
mPoolGameobjectGroups[pool_id].DespawnObject(mSpawnedData);
if (!mPoolPoolGroups[pool_id].isEmpty())
mPoolPoolGroups[pool_id].DespawnObject(mSpawnedData);
if (!mPoolQuestGroups[pool_id].isEmpty())
mPoolQuestGroups[pool_id].DespawnObject(mSpawnedData);
{
auto it = mPoolCreatureGroups.find(pool_id);
if (it != mPoolCreatureGroups.end() && !it->second.isEmpty())
it->second.DespawnObject(mSpawnedData);
}
{
auto it = mPoolGameobjectGroups.find(pool_id);
if (it != mPoolGameobjectGroups.end() && !it->second.isEmpty())
it->second.DespawnObject(mSpawnedData);
}
{
auto it = mPoolPoolGroups.find(pool_id);
if (it != mPoolPoolGroups.end() && !it->second.isEmpty())
it->second.DespawnObject(mSpawnedData);
}
{
auto it = mPoolQuestGroups.find(pool_id);
if (it != mPoolQuestGroups.end() && !it->second.isEmpty())
it->second.DespawnObject(mSpawnedData);
}
}
// Method that check chance integrity of the creatures and gameobjects in this pool
bool PoolMgr::CheckPool(uint32 pool_id) const
{
return pool_id <= max_pool_id &&
mPoolGameobjectGroups[pool_id].CheckPool() &&
mPoolCreatureGroups[pool_id].CheckPool() &&
mPoolPoolGroups[pool_id].CheckPool() &&
mPoolQuestGroups[pool_id].CheckPool();
{
auto it = mPoolGameobjectGroups.find(pool_id);
if (it != mPoolGameobjectGroups.end() && !it->second.CheckPool())
return false;
}
{
auto it = mPoolCreatureGroups.find(pool_id);
if (it != mPoolCreatureGroups.end() && !it->second.CheckPool())
return false;
}
{
auto it = mPoolPoolGroups.find(pool_id);
if (it != mPoolPoolGroups.end() && !it->second.CheckPool())
return false;
}
{
auto it = mPoolQuestGroups.find(pool_id);
if (it != mPoolQuestGroups.end() && !it->second.CheckPool())
return false;
}
return true;
}
// Call to update the pool when a gameobject/creature part of pool [pool_id] is ready to respawn
+5 -6
View File
@@ -139,12 +139,11 @@ class TC_GAME_API PoolMgr
template<typename T>
void SpawnPool(uint32 pool_id, uint32 db_guid_or_pool_id);
uint32 max_pool_id;
typedef std::vector<PoolTemplateData> PoolTemplateDataMap;
typedef std::vector<PoolGroup<Creature> > PoolGroupCreatureMap;
typedef std::vector<PoolGroup<GameObject> > PoolGroupGameObjectMap;
typedef std::vector<PoolGroup<Pool> > PoolGroupPoolMap;
typedef std::vector<PoolGroup<Quest> > PoolGroupQuestMap;
typedef std::unordered_map<uint32, PoolTemplateData> PoolTemplateDataMap;
typedef std::unordered_map<uint32, PoolGroup<Creature>> PoolGroupCreatureMap;
typedef std::unordered_map<uint32, PoolGroup<GameObject>> PoolGroupGameObjectMap;
typedef std::unordered_map<uint32, PoolGroup<Pool>> PoolGroupPoolMap;
typedef std::unordered_map<uint32, PoolGroup<Quest>> PoolGroupQuestMap;
typedef std::pair<uint32, uint32> SearchPair;
typedef std::map<uint32, uint32> SearchMap;
+38 -14
View File
@@ -2662,9 +2662,7 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit* unit, uint32 effectMask, bool scaleA
diminishLevel = unit->GetDiminishing(diminishGroup);
DiminishingReturnsType type = m_spellInfo->GetDiminishingReturnsGroupType(triggered);
// Increase Diminishing on unit, current informations for actually casts will use values above
if ((type == DRTYPE_PLAYER &&
(unit->GetCharmerOrOwnerPlayerOrPlayerItself() || (unit->GetTypeId() == TYPEID_UNIT && unit->ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_ALL_DIMINISH))) ||
type == DRTYPE_ALL)
if (type == DRTYPE_ALL || (type == DRTYPE_PLAYER && unit->IsAffectedByDiminishingReturns()))
unit->IncrDiminishing(m_spellInfo, triggered);
}
@@ -3259,11 +3257,9 @@ void Spell::_cast(bool skipCheck)
// skip check if done already (for instant cast spells for example)
if (!skipCheck)
{
uint32 param1 = 0, param2 = 0;
SpellCastResult castResult = CheckCast(false, &param1, &param2);
if (castResult != SPELL_CAST_OK)
auto cleanupSpell = [this, modOwner](SpellCastResult res, uint32* p1 = nullptr, uint32* p2 = nullptr)
{
SendCastResult(castResult, &param1, &param2);
SendCastResult(res, p1, p2);
SendInterrupted(0);
if (modOwner)
@@ -3271,6 +3267,13 @@ void Spell::_cast(bool skipCheck)
finish(false);
SetExecutedCurrently(false);
};
uint32 param1 = 0, param2 = 0;
SpellCastResult castResult = CheckCast(false, &param1, &param2);
if (castResult != SPELL_CAST_OK)
{
cleanupSpell(castResult, &param1, &param2);
return;
}
@@ -3286,18 +3289,39 @@ void Spell::_cast(bool skipCheck)
{
// Spell will be cast after completing the trade. Silently ignore at this place
my_trade->SetSpell(m_spellInfo->Id, m_CastItem);
SendCastResult(SPELL_FAILED_DONT_REPORT);
SendInterrupted(0);
modOwner->SetSpellModTakingSpell(this, false);
finish(false);
SetExecutedCurrently(false);
cleanupSpell(SPELL_FAILED_DONT_REPORT);
return;
}
}
}
}
// check diminishing returns (again, only after finish cast bar, tested on retail)
if (Unit* target = m_targets.GetUnitTarget())
{
uint8 aura_effmask = 0;
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
if (m_spellInfo->Effects[i].IsUnitOwnedAuraEffect())
aura_effmask |= 1 << i;
if (aura_effmask)
{
bool const triggered = m_triggeredByAuraSpell != nullptr;
if (DiminishingGroup diminishGroup = m_spellInfo->GetDiminishingReturnsGroupForSpell(triggered))
{
DiminishingReturnsType type = m_spellInfo->GetDiminishingReturnsGroupType(triggered);
if (type == DRTYPE_ALL || (type == DRTYPE_PLAYER && target->IsAffectedByDiminishingReturns()))
{
Unit* caster = m_originalCaster ? m_originalCaster : m_caster;
if (target->HasStrongerAuraWithDR(m_spellInfo, caster, triggered))
{
cleanupSpell(SPELL_FAILED_AURA_BOUNCED);
return;
}
}
}
}
}
}
// if the spell allows the creature to turn while casting, then adjust server-side orientation to face the target now
@@ -25,10 +25,16 @@ EndScriptData */
#include "ScriptMgr.h"
#include "AreaBoundary.h"
#include "ScriptedCreature.h"
#include "Creature.h"
#include "CreatureAI.h"
#include "EventMap.h"
#include "GameObject.h"
#include "InstanceScript.h"
#include "stratholme.h"
#include "Log.h"
#include "Map.h"
#include "MotionMaster.h"
#include "Player.h"
#include "stratholme.h"
enum InstanceEvents
{
@@ -36,6 +42,11 @@ enum InstanceEvents
EVENT_SLAUGHTER_SQUARE = 2
};
enum StratholmeMisc
{
SAY_YSIDA_SAVED = 0
};
Position const timmyTheCruelSpawnPosition = { 3625.358f, -3188.108f, 130.3985f, 4.834562f };
EllipseBoundary const beforeScarletGate(Position(3671.158f, -3181.79f), 60.0f, 40.0f);
@@ -76,8 +87,10 @@ class instance_stratholme : public InstanceMapScript
ObjectGuid portGauntletGUID;
ObjectGuid portSlaugtherGUID;
ObjectGuid portElderGUID;
ObjectGuid ysidaCageGUID;
ObjectGuid baronGUID;
ObjectGuid ysidaGUID;
ObjectGuid ysidaTriggerGUID;
GuidSet crystalsGUID;
GuidSet abomnationGUID;
@@ -156,6 +169,10 @@ class instance_stratholme : public InstanceMapScript
case NPC_ABOM_VENOM:
abomnationGUID.insert(creature->GetGUID());
break;
case NPC_YSIDA:
ysidaGUID = creature->GetGUID();
creature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER);
break;
}
}
@@ -223,6 +240,9 @@ class instance_stratholme : public InstanceMapScript
case GO_PORT_ELDERS:
portElderGUID = go->GetGUID();
break;
case GO_YSIDA_CAGE:
ysidaCageGUID = go->GetGUID();
break;
}
}
@@ -242,14 +262,41 @@ class instance_stratholme : public InstanceMapScript
break;
case FAIL:
DoRemoveAurasDueToSpellOnPlayers(SPELL_BARON_ULTIMATUM);
if (Creature* ysida = instance->GetCreature(ysidaGUID))
ysida->CastSpell(ysida, SPELL_PERM_FEIGN_DEATH, true);
EncounterState[0] = data;
break;
case DONE:
EncounterState[0] = data;
if (Creature* ysidaTrigger = instance->GetCreature(ysidaTriggerGUID))
if (Creature* ysida = instance->GetCreature(ysidaGUID))
{
Position ysidaPos = ysidaTrigger->GetPosition();
ysidaTrigger->SummonCreature(NPC_YSIDA, ysidaPos, TEMPSUMMON_TIMED_DESPAWN, 1800000);
if (GameObject* cage = instance->GetGameObject(ysidaCageGUID))
cage->UseDoorOrButton();
float x, y, z;
//! This spell handles the Dead man's plea quest completion
ysida->CastSpell(nullptr, SPELL_YSIDA_SAVED, true);
ysida->SetWalk(true);
ysida->AI()->Talk(SAY_YSIDA_SAVED);
ysida->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER);
ysida->GetClosePoint(x, y, z, ysida->GetObjectScale() / 3, 4.0f);
ysida->GetMotionMaster()->MovePoint(1, x, y, z);
Map::PlayerList const& players = instance->GetPlayers();
for (auto const& i : players)
{
if (Player* player = i.GetSource())
{
if (player->IsGameMaster())
continue;
//! im not quite sure what this one is supposed to do
//! this is server-side spell
player->CastSpell(ysida, SPELL_YSIDA_CREDIT_EFFECT, true);
}
}
}
events.CancelEvent(EVENT_BARON_RUN);
break;
@@ -332,19 +379,9 @@ class instance_stratholme : public InstanceMapScript
{
HandleGameObject(portGauntletGUID, true);
if (GetData(TYPE_BARON_RUN) == IN_PROGRESS)
{
DoRemoveAurasDueToSpellOnPlayers(SPELL_BARON_ULTIMATUM);
Map::PlayerList const& players = instance->GetPlayers();
if (!players.isEmpty())
for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
if (Player* player = itr->GetSource())
if (player->GetQuestStatus(QUEST_DEAD_MAN_PLEA) == QUEST_STATUS_INCOMPLETE)
{
player->AreaExploredOrEventHappens(QUEST_DEAD_MAN_PLEA);
player->KilledMonsterCredit(NPC_YSIDA);
}
SetData(TYPE_BARON_RUN, DONE);
}
SetData(TYPE_BARON_RUN, DONE);
}
EncounterState[5] = data;
break;
@@ -438,6 +475,8 @@ class instance_stratholme : public InstanceMapScript
return baronGUID;
case DATA_YSIDA_TRIGGER:
return ysidaTriggerGUID;
case NPC_YSIDA:
return ysidaGUID;
}
return ObjectGuid::Empty;
}
@@ -31,12 +31,17 @@ npc_spectral_ghostly_citizen
EndContentData */
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "stratholme.h"
#include "Group.h"
#include "Player.h"
#include "SpellInfo.h"
#include "GameObject.h"
#include "GameObjectAI.h"
#include "Group.h"
#include "InstanceScript.h"
#include "MotionMaster.h"
#include "ObjectAccessor.h"
#include "Player.h"
#include "ScriptedCreature.h"
#include "SpellInfo.h"
#include "SpellScript.h"
#include "stratholme.h"
/*######
## go_gauntlet_gate (this is the _first_ of the gauntlet gates, two exist)
@@ -297,9 +302,43 @@ public:
};
class spell_ysida_saved_credit : public SpellScript
{
PrepareSpellScript(spell_ysida_saved_credit);
bool Validate(SpellInfo const* /*spell*/) override
{
return ValidateSpellInfo({ SPELL_YSIDA_SAVED });
}
void FilterTargets(std::list<WorldObject*>& targets)
{
targets.remove_if([](WorldObject* obj)
{
return obj->GetTypeId() != TYPEID_PLAYER;
});
}
void HandleScript(SpellEffIndex /*effIndex*/)
{
if (Player* player = GetHitUnit()->ToPlayer())
{
player->AreaExploredOrEventHappens(QUEST_DEAD_MAN_PLEA);
player->KilledMonsterCredit(NPC_YSIDA);
}
}
void Register() override
{
OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_ysida_saved_credit::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENTRY);
OnEffectHitTarget += SpellEffectFn(spell_ysida_saved_credit::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
}
};
void AddSC_stratholme()
{
new go_gauntlet_gate();
new npc_restless_soul();
new npc_spectral_ghostly_citizen();
RegisterSpellScript(spell_ysida_saved_credit);
}
@@ -76,7 +76,8 @@ enum STRGameobjectIds
GO_ZIGGURAT5 = 175796, // baron
GO_PORT_GAUNTLET = 175374, // port from gauntlet to slaugther
GO_PORT_SLAUGTHER = 175373, // port at slaugther
GO_PORT_ELDERS = 175377 // port at elders square
GO_PORT_ELDERS = 175377, // port at elders square
GO_YSIDA_CAGE = 181071
};
enum STRQuestIds
@@ -86,7 +87,10 @@ enum STRQuestIds
enum STRSpellIds
{
SPELL_BARON_ULTIMATUM = 27861
SPELL_BARON_ULTIMATUM = 27861,
SPELL_PERM_FEIGN_DEATH = 29266,
SPELL_YSIDA_SAVED = 31912,
SPELL_YSIDA_CREDIT_EFFECT = 31913
};
enum STRMisc
@@ -122,7 +122,7 @@ class VoidSpawnSummon : public BasicEvent
bool Execute(uint64 /*time*/, uint32 /*diff*/)
{
_owner->CastSpell((Unit*)nullptr, SPELL_SUMMON_VOID_SENTINEL, true);
_owner->CastSpell(nullptr, SPELL_SUMMON_VOID_SENTINEL, true);
return true;
}
@@ -590,7 +590,7 @@ class spell_summon_blood_elves_script : SpellScriptLoader
void HandleScript(SpellEffIndex /*effIndex*/)
{
for (uint8 i = 0; i < MAX_SUMMON_BLOOD_ELVES; ++i)
GetCaster()->CastSpell((Unit*)nullptr, SummonBloodElvesSpells[urand(0,3)], true);
GetCaster()->CastSpell(nullptr, SummonBloodElvesSpells[urand(0,3)], true);
}
void Register() override
@@ -625,7 +625,7 @@ class spell_muru_darkness : SpellScriptLoader
void HandleAfterCast()
{
for (uint8 i = 0; i < MAX_SUMMON_DARK_FIEND; ++i)
GetCaster()->CastSpell((Unit*)nullptr, SummonDarkFiendSpells[i], true);
GetCaster()->CastSpell(nullptr, SummonDarkFiendSpells[i], true);
}
void Register() override
@@ -687,7 +687,7 @@ class spell_transform_visual_missile_periodic : public SpellScriptLoader
void OnPeriodic(AuraEffect const* /*aurEff*/)
{
GetTarget()->CastSpell((Unit*)nullptr, RAND(TRANSFORM_VISUAL_MISSILE_1, TRANSFORM_VISUAL_MISSILE_2), true);
GetTarget()->CastSpell(nullptr, RAND(TRANSFORM_VISUAL_MISSILE_1, TRANSFORM_VISUAL_MISSILE_2), true);
}
void Register() override
@@ -713,7 +713,7 @@ class spell_summon_blood_elves_periodic : public SpellScriptLoader
void OnPeriodic(AuraEffect const* /*aurEff*/)
{
GetTarget()->CastSpell((Unit*)nullptr, SPELL_SUMMON_BLOOD_ELVES_SCRIPT, true);
GetTarget()->CastSpell(nullptr, SPELL_SUMMON_BLOOD_ELVES_SCRIPT, true);
}
void Register() override
@@ -242,7 +242,7 @@ class npc_corrupted_soul_fragment : public CreatureScript
if (instance->GetGuidData(DATA_BRONJAHM).GetCounter() != id)
return;
me->CastSpell((Unit*)nullptr, SPELL_CONSUME_SOUL, true);
me->CastSpell(nullptr, SPELL_CONSUME_SOUL, true);
me->DespawnOrUnsummon();
}
@@ -319,7 +319,7 @@ class instance_gundrak : public InstanceMapScript
if (GameObject* altar = GetGameObject(altarId))
if (Creature* trigger = altar->FindNearestCreature(NPC_ALTAR_TRIGGER, 10.0f))
trigger->CastSpell((Unit*)nullptr, spellId, true);
trigger->CastSpell(nullptr, spellId, true);
// eventId equals statueId
ToggleGameObject(eventId, GO_STATE_READY);
@@ -1845,8 +1845,8 @@ class spell_igb_rocket_pack : public SpellScriptLoader
void HandleRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/)
{
SpellInfo const* damageInfo = sSpellMgr->AssertSpellInfo(SPELL_ROCKET_PACK_DAMAGE);
GetTarget()->CastCustomSpell(SPELL_ROCKET_PACK_DAMAGE, SPELLVALUE_BASE_POINT0, 2 * (damageInfo->Effects[EFFECT_0].CalcValue() + aurEff->GetTickNumber() * aurEff->GetAmplitude()), NULL, TRIGGERED_FULL_MASK);
GetTarget()->CastSpell(NULL, SPELL_ROCKET_BURST, TRIGGERED_FULL_MASK);
GetTarget()->CastCustomSpell(SPELL_ROCKET_PACK_DAMAGE, SPELLVALUE_BASE_POINT0, 2 * (damageInfo->Effects[EFFECT_0].CalcValue() + aurEff->GetTickNumber() * aurEff->GetAmplitude()), nullptr, TRIGGERED_FULL_MASK);
GetTarget()->CastSpell(nullptr, SPELL_ROCKET_BURST, TRIGGERED_FULL_MASK);
}
void Register() override
@@ -857,7 +857,7 @@ class spell_summon_gauntlet_mobs_periodic : public SpellScriptLoader
for (uint8 i = 0; i < 2; ++i)
{
uint32 spellId = SummonSpellsList.front();
GetTarget()->CastSpell((Unit*)nullptr, spellId, true);
GetTarget()->CastSpell(nullptr, spellId, true);
SummonSpellsList.push_back(spellId);
SummonSpellsList.pop_front();
}
@@ -2369,7 +2369,7 @@ public:
{
if (GetTarget()->isDead())
if (Unit* caster = GetCaster())
caster->CastSpell(NULL, SPELL_WINDSOUL_CREDT);
caster->CastSpell(nullptr, SPELL_WINDSOUL_CREDT);
}
void Register() override