mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-02-01 14:46:54 +01:00
Core/AreaTriggers: Move SpellForVisuals override from AT spawn to properties (#29982)
(cherry picked from commit 2ad7c7829b)
# Conflicts:
# src/server/game/Entities/AreaTrigger/AreaTrigger.cpp
This commit is contained in:
17
sql/updates/world/master/2024_05_18_01_world.sql
Normal file
17
sql/updates/world/master/2024_05_18_01_world.sql
Normal file
@@ -0,0 +1,17 @@
|
||||
DELIMITER ;;
|
||||
CREATE PROCEDURE 2024_05_18_01_areatrigger_spellvisual() BEGIN
|
||||
IF NOT EXISTS (SELECT * FROM `information_schema`.`columns` WHERE `table_schema`=SCHEMA() AND `table_name`='areatrigger_create_properties' AND `column_name`='SpellsForVisuals') THEN
|
||||
|
||||
ALTER TABLE `areatrigger`
|
||||
DROP COLUMN `SpellForVisuals`;
|
||||
|
||||
ALTER TABLE `areatrigger_create_properties`
|
||||
ADD COLUMN `SpellForVisuals` INT AFTER `DecalPropertiesId`;
|
||||
|
||||
END IF;
|
||||
END;;
|
||||
|
||||
DELIMITER ;
|
||||
CALL 2024_05_18_01_areatrigger_spellvisual();
|
||||
|
||||
DROP PROCEDURE IF EXISTS 2024_05_18_01_areatrigger_spellvisual;
|
||||
@@ -109,7 +109,7 @@ void AreaTrigger::PlaySpellVisual(uint32 spellVisualId) const
|
||||
SendMessageToSet(packet.Write(), false);
|
||||
}
|
||||
|
||||
bool AreaTrigger::Create(AreaTriggerCreatePropertiesId areaTriggerCreatePropertiesId, Map* map, Position const& pos, int32 duration, AreaTriggerSpawn const* spawnData /* nullptr */, Unit* caster /*= nullptr*/, Unit* target /*= nullptr*/, SpellCastVisual spellVisual /*= { 0, 0 }*/, SpellInfo const* spellInfo /*= nullptr*/, Spell* spell /*= nullptr*/, AuraEffect const* aurEff /*= nullptr*/)
|
||||
bool AreaTrigger::Create(AreaTriggerCreatePropertiesId areaTriggerCreatePropertiesId, Map* map, Position const& pos, int32 duration, AreaTriggerSpawn const* spawnData /*= nullptr*/, Unit* caster /*= nullptr*/, Unit* target /*= nullptr*/, SpellCastVisual spellVisual /*= { 0, 0 }*/, SpellInfo const* spellInfo /*= nullptr*/, Spell* spell /*= nullptr*/, AuraEffect const* aurEff /*= nullptr*/)
|
||||
{
|
||||
_targetGuid = target ? target->GetGUID() : ObjectGuid::Empty;
|
||||
_aurEff = aurEff;
|
||||
@@ -151,8 +151,18 @@ bool AreaTrigger::Create(AreaTriggerCreatePropertiesId areaTriggerCreateProperti
|
||||
SetUpdateFieldValue(areaTriggerData.ModifyValue(&UF::AreaTriggerData::CreatingEffectGUID), spell->m_castId);
|
||||
if (spellInfo && !IsStaticSpawn())
|
||||
SetUpdateFieldValue(areaTriggerData.ModifyValue(&UF::AreaTriggerData::SpellID), spellInfo->Id);
|
||||
if (spellInfo)
|
||||
SetUpdateFieldValue(areaTriggerData.ModifyValue(&UF::AreaTriggerData::SpellForVisuals), spellInfo->Id);
|
||||
|
||||
SpellInfo const* spellForVisuals = spellInfo;
|
||||
if (GetCreateProperties()->SpellForVisuals)
|
||||
{
|
||||
spellForVisuals = sSpellMgr->GetSpellInfo(*GetCreateProperties()->SpellForVisuals, DIFFICULTY_NONE);
|
||||
|
||||
if (spellForVisuals)
|
||||
spellVisual.SpellXSpellVisualID = spellForVisuals->GetSpellXSpellVisualId();
|
||||
}
|
||||
if (spellForVisuals)
|
||||
SetUpdateFieldValue(areaTriggerData.ModifyValue(&UF::AreaTriggerData::SpellForVisuals), spellForVisuals->Id);
|
||||
|
||||
SetUpdateFieldValue(areaTriggerData.ModifyValue(&UF::AreaTriggerData::SpellXSpellVisualID), spellVisual.SpellXSpellVisualID);
|
||||
if (!IsStaticSpawn())
|
||||
SetUpdateFieldValue(areaTriggerData.ModifyValue(&UF::AreaTriggerData::TimeToTargetScale), GetCreateProperties()->TimeToTargetScale != 0 ? GetCreateProperties()->TimeToTargetScale : *m_areaTriggerData->Duration);
|
||||
@@ -289,17 +299,7 @@ bool AreaTrigger::LoadFromDB(ObjectGuid::LowType spawnId, Map* map, bool /*addTo
|
||||
if (!createProperties)
|
||||
return false;
|
||||
|
||||
SpellInfo const* spellInfo = nullptr;
|
||||
SpellCastVisual spellVisual;
|
||||
if (spawnData->SpellForVisuals)
|
||||
{
|
||||
spellInfo = sSpellMgr->GetSpellInfo(*spawnData->SpellForVisuals, DIFFICULTY_NONE);
|
||||
|
||||
if (spellInfo)
|
||||
spellVisual.SpellXSpellVisualID = spellInfo->GetSpellXSpellVisualId();
|
||||
}
|
||||
|
||||
return Create(spawnData->Id, map, spawnData->spawnPoint, -1, spawnData, nullptr, nullptr, spellVisual, spellInfo);
|
||||
return Create(spawnData->Id, map, spawnData->spawnPoint, -1, spawnData);
|
||||
}
|
||||
|
||||
void AreaTrigger::Update(uint32 diff)
|
||||
|
||||
@@ -246,6 +246,8 @@ public:
|
||||
|
||||
uint32 DecalPropertiesId;
|
||||
|
||||
Optional<int32> SpellForVisuals;
|
||||
|
||||
uint32 TimeToTarget;
|
||||
uint32 TimeToTargetScale;
|
||||
|
||||
@@ -265,7 +267,6 @@ struct AreaTriggerSpawn : SpawnData
|
||||
AreaTriggerSpawn() : SpawnData(SPAWN_TYPE_AREATRIGGER) { }
|
||||
|
||||
AreaTriggerCreatePropertiesId Id;
|
||||
Optional<int32> SpellForVisuals;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -167,9 +167,9 @@ void AreaTriggerDataStore::LoadAreaTriggerTemplates()
|
||||
|
||||
// 0 1 2 3 4
|
||||
if (QueryResult areatriggerCreateProperties = WorldDatabase.Query("SELECT Id, IsCustom, AreaTriggerId, IsAreatriggerCustom, Flags, "
|
||||
// 5 6 7 8 9 10 11 12 13
|
||||
"MoveCurveId, ScaleCurveId, MorphCurveId, FacingCurveId, AnimId, AnimKitId, DecalPropertiesId, TimeToTarget, TimeToTargetScale, "
|
||||
// 14 15 16 17 18 19 20 21 22 23
|
||||
// 5 6 7 8 9 10 11 12 13 14
|
||||
"MoveCurveId, ScaleCurveId, MorphCurveId, FacingCurveId, AnimId, AnimKitId, DecalPropertiesId, SpellForVisuals, TimeToTarget, TimeToTargetScale, "
|
||||
// 15 16 17 18 19 20 21 22 23 24
|
||||
"Shape, ShapeData0, ShapeData1, ShapeData2, ShapeData3, ShapeData4, ShapeData5, ShapeData6, ShapeData7, ScriptName FROM `areatrigger_create_properties`"))
|
||||
{
|
||||
do
|
||||
@@ -185,7 +185,7 @@ void AreaTriggerDataStore::LoadAreaTriggerTemplates()
|
||||
|
||||
createProperties.Flags = AreaTriggerCreatePropertiesFlag(fields[4].GetUInt32());
|
||||
|
||||
AreaTriggerShapeType shape = AreaTriggerShapeType(fields[14].GetUInt8());
|
||||
AreaTriggerShapeType shape = AreaTriggerShapeType(fields[15].GetUInt8());
|
||||
|
||||
if (areaTriggerId.Id && !createProperties.Template)
|
||||
{
|
||||
@@ -222,14 +222,24 @@ void AreaTriggerDataStore::LoadAreaTriggerTemplates()
|
||||
|
||||
createProperties.DecalPropertiesId = fields[11].GetUInt32();
|
||||
|
||||
createProperties.TimeToTarget = fields[12].GetUInt32();
|
||||
createProperties.TimeToTargetScale = fields[13].GetUInt32();
|
||||
if (!fields[12].IsNull())
|
||||
{
|
||||
createProperties.SpellForVisuals = fields[12].GetInt32();
|
||||
if (!sSpellMgr->GetSpellInfo(*createProperties.SpellForVisuals, DIFFICULTY_NONE))
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "Table `areatrigger_create_properties` has AreaTriggerCreatePropertiesId (Id: {}, IsCustom: {}) with invalid SpellForVisual {}, set to none.", createPropertiesId.Id, uint32(createPropertiesId.IsCustom), *createProperties.SpellForVisuals);
|
||||
createProperties.SpellForVisuals.reset();
|
||||
}
|
||||
}
|
||||
|
||||
createProperties.TimeToTarget = fields[13].GetUInt32();
|
||||
createProperties.TimeToTargetScale = fields[14].GetUInt32();
|
||||
|
||||
createProperties.Shape.Type = static_cast<AreaTriggerShapeType>(shape);
|
||||
for (uint8 i = 0; i < MAX_AREATRIGGER_ENTITY_DATA; ++i)
|
||||
createProperties.Shape.DefaultDatas.Data[i] = fields[15 + i].GetFloat();
|
||||
createProperties.Shape.DefaultDatas.Data[i] = fields[16 + i].GetFloat();
|
||||
|
||||
createProperties.ScriptId = sObjectMgr->GetScriptId(fields[23].GetString());
|
||||
createProperties.ScriptId = sObjectMgr->GetScriptId(fields[24].GetString());
|
||||
|
||||
if (shape == AreaTriggerShapeType::Polygon)
|
||||
{
|
||||
@@ -317,8 +327,8 @@ void AreaTriggerDataStore::LoadAreaTriggerSpawns()
|
||||
spawnMasks[mapDifficulty->MapID].insert(Difficulty(mapDifficulty->DifficultyID));
|
||||
|
||||
uint32 oldMSTime = getMSTime();
|
||||
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13
|
||||
if (QueryResult templates = WorldDatabase.Query("SELECT SpawnId, AreaTriggerCreatePropertiesId, IsCustom, MapId, SpawnDifficulties, PosX, PosY, PosZ, Orientation, PhaseUseFlags, PhaseId, PhaseGroup, SpellForVisuals, ScriptName FROM `areatrigger`"))
|
||||
// 0 1 2 3 4 5 6 7 8 9 10 11 12
|
||||
if (QueryResult templates = WorldDatabase.Query("SELECT SpawnId, AreaTriggerCreatePropertiesId, IsCustom, MapId, SpawnDifficulties, PosX, PosY, PosZ, Orientation, PhaseUseFlags, PhaseId, PhaseGroup, ScriptName FROM `areatrigger`"))
|
||||
{
|
||||
do
|
||||
{
|
||||
@@ -395,17 +405,7 @@ void AreaTriggerDataStore::LoadAreaTriggerSpawns()
|
||||
spawn.phaseId = fields[10].GetUInt32();
|
||||
spawn.phaseGroup = fields[11].GetUInt32();
|
||||
|
||||
if (!fields[12].IsNull())
|
||||
{
|
||||
spawn.SpellForVisuals = fields[12].GetInt32();
|
||||
if (!sSpellMgr->GetSpellInfo(spawn.SpellForVisuals.value(), DIFFICULTY_NONE))
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "Table `areatrigger` has areatrigger (GUID: {}) with invalid SpellForVisual {}, set to none.", spawnId, *spawn.SpellForVisuals);
|
||||
spawn.SpellForVisuals.reset();
|
||||
}
|
||||
}
|
||||
|
||||
spawn.scriptId = sObjectMgr->GetScriptId(fields[13].GetString());
|
||||
spawn.scriptId = sObjectMgr->GetScriptId(fields[12].GetString());
|
||||
spawn.spawnGroupData = sObjectMgr->GetLegacySpawnGroup();
|
||||
|
||||
// Add the trigger to a map::cell map, which is later used by GridLoader to query
|
||||
|
||||
Reference in New Issue
Block a user