Core/Spells: SpellAttr8 fixups - use creator instead of owner for SPELL_ATTR8_ONLY_TARGET_IF_SAME_CREATOR and removed cast time requirement for channelled spell predicted healing

This commit is contained in:
Shauren
2023-10-24 10:38:27 +02:00
parent 7b6143a438
commit 930a08fe03
9 changed files with 20 additions and 4 deletions

View File

@@ -137,6 +137,7 @@ class TC_GAME_API AreaTrigger : public WorldObject, public GridObject<AreaTrigge
AreaTriggerTemplate const* GetTemplate() const;
uint32 GetScriptId() const;
ObjectGuid GetCreatorGUID() const override { return GetCasterGuid(); }
ObjectGuid GetOwnerGUID() const override { return GetCasterGuid(); }
ObjectGuid const& GetCasterGuid() const { return m_areaTriggerData->Caster; }
Unit* GetCaster() const;

View File

@@ -66,8 +66,8 @@ class TC_GAME_API Conversation : public WorldObject, public GridObject<Conversat
void AddActor(int32 actorId, uint32 actorIdx, ObjectGuid const& actorGuid);
void AddActor(int32 actorId, uint32 actorIdx, ConversationActorType type, uint32 creatureId, uint32 creatureDisplayInfoId);
ObjectGuid const& GetCreatorGuid() const { return _creatorGuid; }
ObjectGuid GetOwnerGUID() const override { return GetCreatorGuid(); }
ObjectGuid GetCreatorGUID() const override { return _creatorGuid; }
ObjectGuid GetOwnerGUID() const override { return GetCreatorGUID(); }
uint32 GetFaction() const override { return 0; }
float GetStationaryX() const override { return _stationaryPosition.GetPositionX(); }

View File

@@ -94,6 +94,7 @@ class TC_GAME_API Corpse : public WorldObject, public GridObject<Corpse>
void RemoveCorpseDynamicFlag(CorpseDynFlags dynamicFlags) { RemoveUpdateFieldFlagValue(m_values.ModifyValue(&Corpse::m_corpseData).ModifyValue(&UF::CorpseData::DynamicFlags), dynamicFlags); }
void ReplaceAllCorpseDynamicFlags(CorpseDynFlags dynamicFlags) { SetUpdateFieldValue(m_values.ModifyValue(&Corpse::m_corpseData).ModifyValue(&UF::CorpseData::DynamicFlags), dynamicFlags); }
ObjectGuid GetCreatorGUID() const override { return m_corpseData->Owner; }
ObjectGuid GetOwnerGUID() const override { return m_corpseData->Owner; }
void SetOwnerGUID(ObjectGuid owner) { SetUpdateFieldValue(m_values.ModifyValue(&Corpse::m_corpseData).ModifyValue(&UF::CorpseData::Owner), owner); }
void SetPartyGUID(ObjectGuid partyGuid) { SetUpdateFieldValue(m_values.ModifyValue(&Corpse::m_corpseData).ModifyValue(&UF::CorpseData::PartyGUID), partyGuid); }

View File

@@ -79,6 +79,7 @@ class TC_GAME_API DynamicObject : public WorldObject, public GridObject<DynamicO
uint32 GetSpellId() const { return m_dynamicObjectData->SpellID; }
SpellInfo const* GetSpellInfo() const;
ObjectGuid GetCasterGUID() const { return m_dynamicObjectData->Caster; }
ObjectGuid GetCreatorGUID() const override { return GetCasterGUID(); }
ObjectGuid GetOwnerGUID() const override { return GetCasterGUID(); }
float GetRadius() const { return m_dynamicObjectData->Radius; }

View File

@@ -223,6 +223,7 @@ class TC_GAME_API GameObject : public WorldObject, public GridObject<GameObject>
bool LoadFromDB(ObjectGuid::LowType spawnId, Map* map, bool addToMap, bool = true); // arg4 is unused, only present to match the signature on Creature
static bool DeleteFromDB(ObjectGuid::LowType spawnId);
ObjectGuid GetCreatorGUID() const override { return m_gameObjectData->CreatedBy; }
void SetOwnerGUID(ObjectGuid owner)
{
// Owner already found and different than expected owner - remove object from old owner

View File

@@ -627,6 +627,7 @@ class TC_GAME_API WorldObject : public Object, public WorldLocation
GameObject* FindNearestGameObjectOfType(GameobjectTypes type, float range) const;
Player* SelectNearestPlayer(float distance) const;
virtual ObjectGuid GetCreatorGUID() const = 0;
virtual ObjectGuid GetOwnerGUID() const = 0;
virtual ObjectGuid GetCharmerOrOwnerGUID() const { return GetOwnerGUID(); }
ObjectGuid GetCharmerOrOwnerOrOwnGUID() const;

View File

@@ -65,6 +65,7 @@ public:
bool Create(ObjectGuid::LowType lowGuid, SceneType type, uint32 sceneId, uint32 scriptPackageId, Map* map, Unit* creator,
Position const& pos, ObjectGuid privateObjectOwner);
ObjectGuid GetCreatorGUID() const override { return *m_sceneObjectData->CreatedBy; }
ObjectGuid GetOwnerGUID() const override { return *m_sceneObjectData->CreatedBy; }
uint32 GetFaction() const override { return 0; }

View File

@@ -5268,7 +5268,7 @@ void Spell::SendChannelStart(uint32 duration)
spellChannelStart.InterruptImmunities->Immunities = mechanicImmunityMask;
}
if (m_spellInfo->HasAttribute(SPELL_ATTR8_HEAL_PREDICTION) && m_casttime && m_caster->IsUnit())
if (m_spellInfo->HasAttribute(SPELL_ATTR8_HEAL_PREDICTION) && m_caster->IsUnit())
{
WorldPackets::Spells::SpellTargetedHealPrediction& healPrediction = spellChannelStart.HealPrediction.emplace();
if (unitCaster->m_unitData->ChannelObjects.size() == 1 && unitCaster->m_unitData->ChannelObjects[0].IsUnit())

View File

@@ -2173,8 +2173,18 @@ SpellCastResult SpellInfo::CheckTarget(WorldObject const* caster, WorldObject co
Unit const* unitTarget = target->ToUnit();
if (HasAttribute(SPELL_ATTR8_ONLY_TARGET_IF_SAME_CREATOR))
if (caster != target && caster->GetGUID() != target->GetOwnerGUID())
{
auto getCreatorOrSelf = [](WorldObject const* obj)
{
ObjectGuid creator = obj->GetCreatorGUID();
if (creator.IsEmpty())
creator = obj->GetGUID();
return creator;
};
if (getCreatorOrSelf(caster) != getCreatorOrSelf(target))
return SPELL_FAILED_BAD_TARGETS;
}
// creature/player specific target checks
if (unitTarget)