Core/Creatures: moved summon passive spell casting into SummonInfo API and allow any controlled summon to cast them
This commit is contained in:
1 parent
85a5e24182
commit
373aad90a2
3 files changed
+48
-5
No files matched your search
@@ -637,10 +637,6 @@ void DBCManager::LoadStores(const std::string& dataPath, uint32 defaultLocale)
|
||||
if (!spellInfo)
|
||||
continue;
|
||||
|
||||
SpellLevelsEntry const* levels = sSpellLevelsStore.LookupEntry(spellInfo->LevelsID);
|
||||
if (spellInfo->LevelsID && (!levels || levels->SpellLevel))
|
||||
continue;
|
||||
|
||||
if (spellInfo && spellInfo->Attributes & SPELL_ATTR0_PASSIVE)
|
||||
{
|
||||
for (CreatureFamilyEntry const* cFamily : sCreatureFamilyStore)
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "Log.h"
|
||||
#include "ObjectAccessor.h"
|
||||
#include "Player.h"
|
||||
#include "SpellMgr.h"
|
||||
#include "SummonInfoArgs.h"
|
||||
#include "TotemPackets.h"
|
||||
|
||||
@@ -130,6 +131,8 @@ void SummonInfo::HandlePreSummonActions()
|
||||
|
||||
// Totem slot summons always send the TotemCreated packet. Some non-Shaman classes use this
|
||||
// to display summon icons that can be canceled (Consecration, DK ghouls, Wild Mushrooms)
|
||||
// This packet must be sent before the creature is being added to the world so that the client
|
||||
// does send correct GUIDs in CMSG_TOTEM_DESTROYED
|
||||
switch (slot)
|
||||
{
|
||||
case SummonPropertiesSlot::Totem1:
|
||||
@@ -187,6 +190,10 @@ void SummonInfo::HandlePostSummonActions()
|
||||
if (_summonedCreature->IsAIEnabled())
|
||||
_summonedCreature->AI()->IsSummonedBy(summoner);
|
||||
}
|
||||
|
||||
// Casting passive spells
|
||||
if (IsControlledBySummoner())
|
||||
castPassiveSpells();
|
||||
}
|
||||
|
||||
void SummonInfo::HandlePreUnsummonActions()
|
||||
@@ -288,3 +295,31 @@ SummonPropertiesControl SummonInfo::GetControl() const
|
||||
{
|
||||
return _control;
|
||||
}
|
||||
|
||||
void SummonInfo::castPassiveSpells()
|
||||
{
|
||||
CreatureTemplate const* creatureInfo = _summonedCreature->GetCreatureTemplate();
|
||||
if (!creatureInfo)
|
||||
return;
|
||||
|
||||
CreatureFamilyEntry const* creatureFamilyEntry = sCreatureFamilyStore.LookupEntry(creatureInfo->family);
|
||||
if (!creatureFamilyEntry)
|
||||
return;
|
||||
|
||||
auto const petSpellStore = sPetFamilySpellsStore.find(creatureFamilyEntry->ID);
|
||||
if (petSpellStore == sPetFamilySpellsStore.end())
|
||||
return;
|
||||
|
||||
for (uint32 spellId : petSpellStore->second)
|
||||
{
|
||||
if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId))
|
||||
{
|
||||
if (spellInfo->IsPassive())
|
||||
{
|
||||
_summonedCreature->CastSpell(nullptr, spellId);
|
||||
//if (spellInfo->HasAttribute(SPELL_ATTR4_OWNER_POWER_SCALING))
|
||||
// _scalingAuras.push_back(spellId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,15 @@ class Unit;
|
||||
|
||||
struct SummonInfoArgs;
|
||||
|
||||
/*
|
||||
The API for summoned creatures. This class contains all the functionality and features to handle summons
|
||||
in a safe manner. However, do not store pointers to SummonInfo instances in scripts as they may change during runtime.
|
||||
Instead resort to the accessor methods provided in the Unit class which always return intact instances
|
||||
and pointers to both ends of a summon relation:
|
||||
- Unit::GetSummonInSlot
|
||||
- Unit::GetSummonsByCreatureId
|
||||
- Unit::GetSummonsBySpellId
|
||||
*/
|
||||
class TC_GAME_API SummonInfo
|
||||
{
|
||||
public:
|
||||
@@ -93,9 +102,12 @@ public:
|
||||
SummonPropertiesControl GetControl() const;
|
||||
|
||||
private:
|
||||
// Looks up and casts all passive spells of the creature summon. Often used for scaling auras.
|
||||
void castPassiveSpells();
|
||||
|
||||
Creature* _summonedCreature;
|
||||
ObjectGuid _summonerGUID;
|
||||
Optional<Milliseconds> _remainingDuration; // NYI
|
||||
Optional<Milliseconds> _remainingDuration; // Implemented in SummonInfo::UpdateRemainingDuration
|
||||
Optional<uint64> _maxHealth; // Implemented in Creature::UpdateLevelDependantStats
|
||||
Optional<uint32> _factionId; // Implemented in Creature::UpdateEntry
|
||||
Optional<uint8> _creatureLevel; // Implemented in Creature::SelectLevel
|
||||
|
||||
Reference in new issue
Block a user