Core/AreaTriggers: Rename spell_areatrigger* tables to areatrigger_create_properties* according to last MiscValue research for areatrigger effects

* Move areatrigger_template.DataX to areatrigger_create_properties.ShapeDataX
This commit is contained in:
Shauren
2021-09-16 22:22:14 +02:00
parent ca67286905
commit ee73948a64
8 changed files with 369 additions and 293 deletions

View File

@@ -0,0 +1,54 @@
RENAME TABLE `spell_areatrigger` TO `areatrigger_create_properties`;
RENAME TABLE `spell_areatrigger_circular` TO `areatrigger_create_properties_orbit`;
RENAME TABLE `spell_areatrigger_splines` TO `areatrigger_create_properties_spline_point`;
RENAME TABLE `spell_areatrigger_vertices` TO `areatrigger_create_properties_polygon_vertex`;
ALTER TABLE `areatrigger_create_properties`
CHANGE `SpellMiscId` `Id` int(10) unsigned NOT NULL,
ADD `Shape` tinyint(0) UNSIGNED NOT NULL DEFAULT '0' AFTER `TimeToTargetScale`,
ADD `ShapeData0` float NOT NULL DEFAULT '0' AFTER `Shape`,
ADD `ShapeData1` float NOT NULL DEFAULT '0' AFTER `ShapeData0`,
ADD `ShapeData2` float NOT NULL DEFAULT '0' AFTER `ShapeData1`,
ADD `ShapeData3` float NOT NULL DEFAULT '0' AFTER `ShapeData2`,
ADD `ShapeData4` float NOT NULL DEFAULT '0' AFTER `ShapeData3`,
ADD `ShapeData5` float NOT NULL DEFAULT '0' AFTER `ShapeData4`;
ALTER TABLE `areatrigger_create_properties_orbit`
CHANGE `SpellMiscId` `AreaTriggerCreatePropertiesId` int(10) unsigned NOT NULL;
ALTER TABLE `areatrigger_create_properties_spline_point`
CHANGE `SpellMiscId` `AreaTriggerCreatePropertiesId` int(10) unsigned NOT NULL;
ALTER TABLE `areatrigger_create_properties_polygon_vertex`
CHANGE `SpellMiscId` `AreaTriggerCreatePropertiesId` int(10) unsigned NOT NULL;
ALTER TABLE `areatrigger`
ADD `Shape` tinyint(0) UNSIGNED NOT NULL DEFAULT '0' AFTER `PhaseGroup`,
ADD `ShapeData0` float NOT NULL DEFAULT '0' AFTER `Shape`,
ADD `ShapeData1` float NOT NULL DEFAULT '0' AFTER `ShapeData0`,
ADD `ShapeData2` float NOT NULL DEFAULT '0' AFTER `ShapeData1`,
ADD `ShapeData3` float NOT NULL DEFAULT '0' AFTER `ShapeData2`,
ADD `ShapeData4` float NOT NULL DEFAULT '0' AFTER `ShapeData3`,
ADD `ShapeData5` float NOT NULL DEFAULT '0' AFTER `ShapeData4`;
UPDATE `areatrigger_create_properties` `acp`
LEFT JOIN `areatrigger_template` `at` ON `acp`.`AreaTriggerId`=`at`.`Id` AND `at`.`IsServerSide`=FALSE
SET `acp`.`Shape`=`at`.`Type`,
`acp`.`ShapeData0`=`at`.`Data0`,
`acp`.`ShapeData1`=`at`.`Data1`,
`acp`.`ShapeData2`=`at`.`Data2`,
`acp`.`ShapeData3`=`at`.`Data3`,
`acp`.`ShapeData4`=`at`.`Data4`,
`acp`.`ShapeData5`=`at`.`Data5`;
UPDATE `areatrigger` `a`
LEFT JOIN `areatrigger_template` `at` ON `a`.`AreaTriggerId`=`at`.`Id` AND `at`.`IsServerSide`=TRUE
SET `a`.`Shape`=`at`.`Type`,
`a`.`ShapeData0`=`at`.`Data0`,
`a`.`ShapeData1`=`at`.`Data1`,
`a`.`ShapeData2`=`at`.`Data2`,
`a`.`ShapeData3`=`at`.`Data3`,
`a`.`ShapeData4`=`at`.`Data4`,
`a`.`ShapeData5`=`at`.`Data5`;
DELETE FROM `areatrigger_template` WHERE `Id`=0 AND `IsServerSide`=FALSE;

View File

@@ -41,7 +41,7 @@
AreaTrigger::AreaTrigger() : WorldObject(false), MapObject(), _aurEff(nullptr), _maxSearchRadius(0.0f),
_duration(0), _totalDuration(0), _timeSinceCreated(0), _previousCheckOrientation(std::numeric_limits<float>::infinity()),
_isRemoved(false), _reachedDestination(true), _lastSplineIndex(0), _movementTime(0),
_areaTriggerMiscTemplate(nullptr), _areaTriggerTemplate(nullptr)
_areaTriggerCreateProperties(nullptr), _areaTriggerTemplate(nullptr)
{
m_objectType |= TYPEMASK_AREATRIGGER;
m_objectTypeId = TYPEID_AREATRIGGER;
@@ -84,7 +84,7 @@ void AreaTrigger::RemoveFromWorld()
}
}
bool AreaTrigger::Create(uint32 spellMiscId, Unit* caster, Unit* target, SpellInfo const* spell, Position const& pos, int32 duration, SpellCastVisual spellVisual, ObjectGuid const& castId, AuraEffect const* aurEff)
bool AreaTrigger::Create(uint32 areaTriggerCreatePropertiesId, Unit* caster, Unit* target, SpellInfo const* spell, Position const& pos, int32 duration, SpellCastVisual spellVisual, ObjectGuid const& castId, AuraEffect const* aurEff)
{
_targetGuid = target ? target->GetGUID() : ObjectGuid::Empty;
_aurEff = aurEff;
@@ -93,30 +93,30 @@ bool AreaTrigger::Create(uint32 spellMiscId, Unit* caster, Unit* target, SpellIn
Relocate(pos);
if (!IsPositionValid())
{
TC_LOG_ERROR("entities.areatrigger", "AreaTrigger (spellMiscId %u) not created. Invalid coordinates (X: %f Y: %f)", spellMiscId, GetPositionX(), GetPositionY());
TC_LOG_ERROR("entities.areatrigger", "AreaTrigger (areaTriggerCreatePropertiesId %u) not created. Invalid coordinates (X: %f Y: %f)", areaTriggerCreatePropertiesId, GetPositionX(), GetPositionY());
return false;
}
_areaTriggerMiscTemplate = sAreaTriggerDataStore->GetAreaTriggerMiscTemplate(spellMiscId);
if (!_areaTriggerMiscTemplate)
_areaTriggerCreateProperties = sAreaTriggerDataStore->GetAreaTriggerCreateProperties(areaTriggerCreatePropertiesId);
if (!_areaTriggerCreateProperties)
{
TC_LOG_ERROR("entities.areatrigger", "AreaTrigger (spellMiscId %u) not created. Invalid areatrigger miscid (%u)", spellMiscId, spellMiscId);
TC_LOG_ERROR("entities.areatrigger", "AreaTrigger (areaTriggerCreatePropertiesId %u) not created. Invalid areatrigger create properties id (%u)", areaTriggerCreatePropertiesId, areaTriggerCreatePropertiesId);
return false;
}
_areaTriggerTemplate = _areaTriggerMiscTemplate->Template;
_areaTriggerTemplate = _areaTriggerCreateProperties->Template;
Object::_Create(ObjectGuid::Create<HighGuid::AreaTrigger>(GetMapId(), GetTemplate()->Id.Id, caster->GetMap()->GenerateLowGuid<HighGuid::AreaTrigger>()));
Object::_Create(ObjectGuid::Create<HighGuid::AreaTrigger>(GetMapId(), GetTemplate() ? GetTemplate()->Id.Id : 0, caster->GetMap()->GenerateLowGuid<HighGuid::AreaTrigger>()));
if (GetTemplate())
SetEntry(GetTemplate()->Id.Id);
SetEntry(GetTemplate()->Id.Id);
SetDuration(duration);
SetObjectScale(1.0f);
if (GetTemplate()->IsPolygon())
_maxSearchRadius = GetMiscTemplate()->GetPolygonMaxSearchRadius();
else
_maxSearchRadius = GetTemplate()->MaxSearchRadius;
_shape = GetCreateProperties()->Shape;
_maxSearchRadius = GetCreateProperties()->GetMaxSearchRadius();
auto areaTriggerData = m_values.ModifyValue(&AreaTrigger::m_areaTriggerData);
SetUpdateFieldValue(areaTriggerData.ModifyValue(&UF::AreaTriggerData::Caster), caster->GetGUID());
@@ -126,51 +126,51 @@ bool AreaTrigger::Create(uint32 spellMiscId, Unit* caster, Unit* target, SpellIn
SetUpdateFieldValue(areaTriggerData.ModifyValue(&UF::AreaTriggerData::SpellForVisuals), spell->Id);
SetUpdateFieldValue(areaTriggerData.ModifyValue(&UF::AreaTriggerData::SpellVisual).ModifyValue(&UF::SpellCastVisual::SpellXSpellVisualID), spellVisual.SpellXSpellVisualID);
SetUpdateFieldValue(areaTriggerData.ModifyValue(&UF::AreaTriggerData::SpellVisual).ModifyValue(&UF::SpellCastVisual::ScriptVisualID), spellVisual.ScriptVisualID);
SetUpdateFieldValue(areaTriggerData.ModifyValue(&UF::AreaTriggerData::TimeToTargetScale), GetMiscTemplate()->TimeToTargetScale != 0 ? GetMiscTemplate()->TimeToTargetScale : *m_areaTriggerData->Duration);
SetUpdateFieldValue(areaTriggerData.ModifyValue(&UF::AreaTriggerData::TimeToTargetScale), GetCreateProperties()->TimeToTargetScale != 0 ? GetCreateProperties()->TimeToTargetScale : *m_areaTriggerData->Duration);
SetUpdateFieldValue(areaTriggerData.ModifyValue(&UF::AreaTriggerData::BoundsRadius2D), GetMaxSearchRadius());
SetUpdateFieldValue(areaTriggerData.ModifyValue(&UF::AreaTriggerData::DecalPropertiesID), GetMiscTemplate()->DecalPropertiesId);
SetUpdateFieldValue(areaTriggerData.ModifyValue(&UF::AreaTriggerData::DecalPropertiesID), GetCreateProperties()->DecalPropertiesId);
if (GetMiscTemplate()->ExtraScale.Data.Structured.StartTimeOffset)
SetUpdateFieldValue(areaTriggerData.ModifyValue(&UF::AreaTriggerData::ExtraScaleCurve).ModifyValue(&UF::ScaleCurve::StartTimeOffset), GetMiscTemplate()->ExtraScale.Data.Structured.StartTimeOffset);
if (GetMiscTemplate()->ExtraScale.Data.Structured.Points[0] || GetMiscTemplate()->ExtraScale.Data.Structured.Points[1])
if (GetCreateProperties()->ExtraScale.Data.Structured.StartTimeOffset)
SetUpdateFieldValue(areaTriggerData.ModifyValue(&UF::AreaTriggerData::ExtraScaleCurve).ModifyValue(&UF::ScaleCurve::StartTimeOffset), GetCreateProperties()->ExtraScale.Data.Structured.StartTimeOffset);
if (GetCreateProperties()->ExtraScale.Data.Structured.Points[0] || GetCreateProperties()->ExtraScale.Data.Structured.Points[1])
{
Position point(GetMiscTemplate()->ExtraScale.Data.Structured.Points[0], GetMiscTemplate()->ExtraScale.Data.Structured.Points[1]);
Position point(GetCreateProperties()->ExtraScale.Data.Structured.Points[0], GetCreateProperties()->ExtraScale.Data.Structured.Points[1]);
SetUpdateFieldValue(areaTriggerData.ModifyValue(&UF::AreaTriggerData::ExtraScaleCurve).ModifyValue(&UF::ScaleCurve::Points, 0), point);
}
if (GetMiscTemplate()->ExtraScale.Data.Structured.Points[2] || GetMiscTemplate()->ExtraScale.Data.Structured.Points[3])
if (GetCreateProperties()->ExtraScale.Data.Structured.Points[2] || GetCreateProperties()->ExtraScale.Data.Structured.Points[3])
{
Position point(GetMiscTemplate()->ExtraScale.Data.Structured.Points[2], GetMiscTemplate()->ExtraScale.Data.Structured.Points[3]);
Position point(GetCreateProperties()->ExtraScale.Data.Structured.Points[2], GetCreateProperties()->ExtraScale.Data.Structured.Points[3]);
SetUpdateFieldValue(areaTriggerData.ModifyValue(&UF::AreaTriggerData::ExtraScaleCurve).ModifyValue(&UF::ScaleCurve::Points, 1), point);
}
if (GetMiscTemplate()->ExtraScale.Data.Raw[5])
SetUpdateFieldValue(areaTriggerData.ModifyValue(&UF::AreaTriggerData::ExtraScaleCurve).ModifyValue(&UF::ScaleCurve::ParameterCurve), GetMiscTemplate()->ExtraScale.Data.Raw[5]);
if (GetMiscTemplate()->ExtraScale.Data.Structured.OverrideActive)
SetUpdateFieldValue(areaTriggerData.ModifyValue(&UF::AreaTriggerData::ExtraScaleCurve).ModifyValue(&UF::ScaleCurve::OverrideActive), GetMiscTemplate()->ExtraScale.Data.Structured.OverrideActive);
if (GetCreateProperties()->ExtraScale.Data.Raw[5])
SetUpdateFieldValue(areaTriggerData.ModifyValue(&UF::AreaTriggerData::ExtraScaleCurve).ModifyValue(&UF::ScaleCurve::ParameterCurve), GetCreateProperties()->ExtraScale.Data.Raw[5]);
if (GetCreateProperties()->ExtraScale.Data.Structured.OverrideActive)
SetUpdateFieldValue(areaTriggerData.ModifyValue(&UF::AreaTriggerData::ExtraScaleCurve).ModifyValue(&UF::ScaleCurve::OverrideActive), GetCreateProperties()->ExtraScale.Data.Structured.OverrideActive);
PhasingHandler::InheritPhaseShift(this, caster);
if (target && GetTemplate()->HasFlag(AREATRIGGER_FLAG_HAS_ATTACHED))
if (target && GetTemplate() && GetTemplate()->HasFlag(AREATRIGGER_FLAG_HAS_ATTACHED))
{
m_movementInfo.transport.guid = target->GetGUID();
}
UpdateShape();
uint32 timeToTarget = GetMiscTemplate()->TimeToTarget != 0 ? GetMiscTemplate()->TimeToTarget : *m_areaTriggerData->Duration;
uint32 timeToTarget = GetCreateProperties()->TimeToTarget != 0 ? GetCreateProperties()->TimeToTarget : *m_areaTriggerData->Duration;
if (GetTemplate()->HasFlag(AREATRIGGER_FLAG_HAS_CIRCULAR_MOVEMENT))
if (GetCreateProperties()->OrbitInfo)
{
AreaTriggerOrbitInfo cmi = GetMiscTemplate()->OrbitInfo;
if (target && GetTemplate()->HasFlag(AREATRIGGER_FLAG_HAS_ATTACHED))
cmi.PathTarget = target->GetGUID();
AreaTriggerOrbitInfo orbit = *GetCreateProperties()->OrbitInfo;
if (target && GetTemplate() && GetTemplate()->HasFlag(AREATRIGGER_FLAG_HAS_ATTACHED))
orbit.PathTarget = target->GetGUID();
else
cmi.Center = pos;
orbit.Center = pos;
InitOrbit(cmi, timeToTarget);
InitOrbit(orbit, timeToTarget);
}
else if (GetMiscTemplate()->HasSplines())
else if (GetCreateProperties()->HasSplines())
{
InitSplineOffsets(GetMiscTemplate()->SplinePoints, timeToTarget);
InitSplineOffsets(GetCreateProperties()->SplinePoints, timeToTarget);
}
// movement on transport of areatriggers on unit is handled by themself
@@ -207,10 +207,10 @@ bool AreaTrigger::Create(uint32 spellMiscId, Unit* caster, Unit* target, SpellIn
return true;
}
AreaTrigger* AreaTrigger::CreateAreaTrigger(uint32 spellMiscId, Unit* caster, Unit* target, SpellInfo const* spell, Position const& pos, int32 duration, SpellCastVisual spellVisual, ObjectGuid const& castId /*= ObjectGuid::Empty*/, AuraEffect const* aurEff /*= nullptr*/)
AreaTrigger* AreaTrigger::CreateAreaTrigger(uint32 areaTriggerCreatePropertiesId, Unit* caster, Unit* target, SpellInfo const* spell, Position const& pos, int32 duration, SpellCastVisual spellVisual, ObjectGuid const& castId /*= ObjectGuid::Empty*/, AuraEffect const* aurEff /*= nullptr*/)
{
AreaTrigger* at = new AreaTrigger();
if (!at->Create(spellMiscId, caster, target, spell, pos, duration, spellVisual, castId, aurEff))
if (!at->Create(areaTriggerCreatePropertiesId, caster, target, spell, pos, duration, spellVisual, castId, aurEff))
{
delete at;
return nullptr;
@@ -251,6 +251,9 @@ bool AreaTrigger::CreateServer(Map* map, AreaTriggerTemplate const* areaTriggerT
SetObjectScale(1.0f);
_shape = position.Shape;
_maxSearchRadius = _shape.GetMaxSearchRadius();
if (position.PhaseUseFlags || position.PhaseId || position.PhaseGroup)
PhasingHandler::InitDbPhaseShift(GetPhaseShift(), position.PhaseUseFlags, position.PhaseId, position.PhaseGroup);
@@ -275,7 +278,7 @@ void AreaTrigger::Update(uint32 diff)
{
UpdateOrbitPosition(diff);
}
else if (GetTemplate()->HasFlag(AREATRIGGER_FLAG_HAS_ATTACHED))
else if (GetTemplate() && GetTemplate()->HasFlag(AREATRIGGER_FLAG_HAS_ATTACHED))
{
if (Unit* target = GetTarget())
GetMap()->AreaTriggerRelocation(this, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), target->GetOrientation());
@@ -338,7 +341,7 @@ void AreaTrigger::UpdateTargetList()
{
std::vector<Unit*> targetList;
switch (GetTemplate()->Type)
switch (_shape.Type)
{
case AREATRIGGER_TYPE_SPHERE:
SearchUnitInSphere(targetList);
@@ -376,14 +379,14 @@ void AreaTrigger::SearchUnits(std::vector<Unit*>& targetList, float radius, bool
void AreaTrigger::SearchUnitInSphere(std::vector<Unit*>& targetList)
{
float radius = GetTemplate()->SphereDatas.Radius;
if (GetTemplate()->HasFlag(AREATRIGGER_FLAG_HAS_DYNAMIC_SHAPE))
float radius = _shape.SphereDatas.Radius;
if (GetTemplate() && GetTemplate()->HasFlag(AREATRIGGER_FLAG_HAS_DYNAMIC_SHAPE))
{
if (GetMiscTemplate()->MorphCurveId)
if (GetCreateProperties()->MorphCurveId)
{
radius = G3D::lerp(GetTemplate()->SphereDatas.Radius,
GetTemplate()->SphereDatas.RadiusTarget,
sDB2Manager.GetCurveValueAt(GetMiscTemplate()->MorphCurveId, GetProgress()));
radius = G3D::lerp(_shape.SphereDatas.Radius,
_shape.SphereDatas.RadiusTarget,
sDB2Manager.GetCurveValueAt(GetCreateProperties()->MorphCurveId, GetProgress()));
}
}
@@ -395,9 +398,9 @@ void AreaTrigger::SearchUnitInBox(std::vector<Unit*>& targetList)
SearchUnits(targetList, GetMaxSearchRadius(), false);
Position const& boxCenter = GetPosition();
float extentsX = GetTemplate()->BoxDatas.Extents[0];
float extentsY = GetTemplate()->BoxDatas.Extents[1];
float extentsZ = GetTemplate()->BoxDatas.Extents[2];
float extentsX = _shape.BoxDatas.Extents[0];
float extentsY = _shape.BoxDatas.Extents[1];
float extentsZ = _shape.BoxDatas.Extents[2];
targetList.erase(std::remove_if(targetList.begin(), targetList.end(), [boxCenter, extentsX, extentsY, extentsZ](Unit* unit) -> bool
{
@@ -409,7 +412,7 @@ void AreaTrigger::SearchUnitInPolygon(std::vector<Unit*>& targetList)
{
SearchUnits(targetList, GetMaxSearchRadius(), false);
float height = GetTemplate()->PolygonDatas.Height;
float height = _shape.PolygonDatas.Height;
float minZ = GetPositionZ() - height;
float maxZ = GetPositionZ() + height;
@@ -425,7 +428,7 @@ void AreaTrigger::SearchUnitInCylinder(std::vector<Unit*>& targetList)
{
SearchUnits(targetList, GetMaxSearchRadius(), false);
float height = GetTemplate()->CylinderDatas.Height;
float height = _shape.CylinderDatas.Height;
float minZ = GetPositionZ() - height;
float maxZ = GetPositionZ() + height;
@@ -456,7 +459,7 @@ void AreaTrigger::HandleUnitEnterExit(std::vector<Unit*> const& newTargetList)
if (Player* player = unit->ToPlayer())
{
if (player->isDebugAreaTriggers)
ChatHandler(player->GetSession()).PSendSysMessage(LANG_DEBUG_AREATRIGGER_ENTERED, GetTemplate()->Id.Id);
ChatHandler(player->GetSession()).PSendSysMessage(LANG_DEBUG_AREATRIGGER_ENTERED, GetEntry());
player->UpdateQuestObjectiveProgress(QUEST_OBJECTIVE_AREA_TRIGGER_ENTER, GetEntry(), 1);
}
@@ -473,7 +476,7 @@ void AreaTrigger::HandleUnitEnterExit(std::vector<Unit*> const& newTargetList)
if (Player* player = leavingUnit->ToPlayer())
{
if (player->isDebugAreaTriggers)
ChatHandler(player->GetSession()).PSendSysMessage(LANG_DEBUG_AREATRIGGER_LEFT, GetTemplate()->Id.Id);
ChatHandler(player->GetSession()).PSendSysMessage(LANG_DEBUG_AREATRIGGER_LEFT, GetEntry());
player->UpdateQuestObjectiveProgress(QUEST_OBJECTIVE_AREA_TRIGGER_EXIT, GetEntry(), 1);
}
@@ -492,7 +495,7 @@ AreaTriggerTemplate const* AreaTrigger::GetTemplate() const
uint32 AreaTrigger::GetScriptId() const
{
return GetTemplate()->ScriptId;
return GetTemplate() ? GetTemplate()->ScriptId : 0;
}
Unit* AreaTrigger::GetCaster() const
@@ -521,7 +524,7 @@ void AreaTrigger::UpdatePolygonOrientation()
if (G3D::fuzzyEq(_previousCheckOrientation, newOrientation))
return;
_polygonVertices.assign(GetMiscTemplate()->PolygonVertices.begin(), GetMiscTemplate()->PolygonVertices.end());
_polygonVertices.assign(GetCreateProperties()->PolygonVertices.begin(), GetCreateProperties()->PolygonVertices.end());
float angleSin = std::sin(newOrientation);
float angleCos = std::cos(newOrientation);
@@ -608,7 +611,7 @@ bool AreaTrigger::CheckIsInPolygon2D(Position const* pos) const
void AreaTrigger::UpdateShape()
{
if (GetTemplate()->IsPolygon())
if (_shape.IsPolygon())
UpdatePolygonOrientation();
}
@@ -648,7 +651,7 @@ void AreaTrigger::DoActions(Unit* unit)
{
Unit* caster = IsServerSide() ? unit : GetCaster();
if (caster)
if (caster && GetTemplate())
{
for (AreaTriggerAction const& action : GetTemplate()->Actions)
{
@@ -679,9 +682,10 @@ void AreaTrigger::DoActions(Unit* unit)
void AreaTrigger::UndoActions(Unit* unit)
{
for (AreaTriggerAction const& action : GetTemplate()->Actions)
if (action.ActionType == AREATRIGGER_ACTION_CAST || action.ActionType == AREATRIGGER_ACTION_ADDAURA)
unit->RemoveAurasDueToSpell(action.Param, GetCasterGuid());
if (GetTemplate())
for (AreaTriggerAction const& action : GetTemplate()->Actions)
if (action.ActionType == AREATRIGGER_ACTION_CAST || action.ActionType == AREATRIGGER_ACTION_ADDAURA)
unit->RemoveAurasDueToSpell(action.Param, GetCasterGuid());
}
void AreaTrigger::InitSplineOffsets(std::vector<Position> const& offsets, uint32 timeToTarget)
@@ -753,10 +757,10 @@ bool AreaTrigger::HasSplines() const
return bool(_spline);
}
void AreaTrigger::InitOrbit(AreaTriggerOrbitInfo const& cmi, uint32 timeToTarget)
void AreaTrigger::InitOrbit(AreaTriggerOrbitInfo const& orbit, uint32 timeToTarget)
{
// Circular movement requires either a center position or an attached unit
ASSERT(cmi.Center.is_initialized() || cmi.PathTarget.is_initialized());
ASSERT(orbit.Center.is_initialized() || orbit.PathTarget.is_initialized());
// should be sent in object create packets only
DoWithSuppressingObjectUpdates([&]()
@@ -765,7 +769,7 @@ void AreaTrigger::InitOrbit(AreaTriggerOrbitInfo const& cmi, uint32 timeToTarget
const_cast<UF::AreaTriggerData&>(*m_areaTriggerData).ClearChanged(&UF::AreaTriggerData::TimeToTarget);
});
_orbitInfo = cmi;
_orbitInfo = orbit;
_orbitInfo->TimeToTarget = timeToTarget;
_orbitInfo->ElapsedTimeForMovement = 0;
@@ -883,13 +887,13 @@ void AreaTrigger::UpdateSplinePosition(uint32 diff)
if (currentTimePercent <= 0.f)
return;
if (GetMiscTemplate()->MoveCurveId)
if (GetCreateProperties()->MoveCurveId)
{
float progress = sDB2Manager.GetCurveValueAt(GetMiscTemplate()->MoveCurveId, currentTimePercent);
float progress = sDB2Manager.GetCurveValueAt(GetCreateProperties()->MoveCurveId, currentTimePercent);
if (progress < 0.f || progress > 1.f)
{
TC_LOG_ERROR("entities.areatrigger", "AreaTrigger (Id: %u, SpellMiscId: %u) has wrong progress (%f) caused by curve calculation (MoveCurveId: %u)",
GetTemplate()->Id.Id, GetMiscTemplate()->MiscId, progress, GetMiscTemplate()->MorphCurveId);
TC_LOG_ERROR("entities.areatrigger", "AreaTrigger (Id: %u, AreaTriggerCreatePropertiesId: %u) has wrong progress (%f) caused by curve calculation (MoveCurveId: %u)",
GetEntry(), GetCreateProperties()->Id, progress, GetCreateProperties()->MorphCurveId);
}
else
currentTimePercent = progress;
@@ -903,7 +907,7 @@ void AreaTrigger::UpdateSplinePosition(uint32 diff)
_spline->evaluate_percent(lastPositionIndex, percentFromLastPoint, currentPosition);
float orientation = GetOrientation();
if (GetTemplate()->HasFlag(AREATRIGGER_FLAG_HAS_FACE_MOVEMENT_DIR))
if (GetTemplate() && GetTemplate()->HasFlag(AREATRIGGER_FLAG_HAS_FACE_MOVEMENT_DIR))
{
G3D::Vector3 const& nextPoint = _spline->getPoint(lastPositionIndex + 1);
orientation = GetAngle(nextPoint.x, nextPoint.y);

View File

@@ -66,11 +66,11 @@ class TC_GAME_API AreaTrigger : public WorldObject, public GridObject<AreaTrigge
bool IsNeverVisibleFor(WorldObject const* /*seer*/) const override { return IsServerSide(); }
private:
bool Create(uint32 spellMiscId, Unit* caster, Unit* target, SpellInfo const* spell, Position const& pos, int32 duration, SpellCastVisual spellVisual, ObjectGuid const& castId, AuraEffect const* aurEff);
bool Create(uint32 areaTriggerCreatePropertiesId, Unit* caster, Unit* target, SpellInfo const* spell, Position const& pos, int32 duration, SpellCastVisual spellVisual, ObjectGuid const& castId, AuraEffect const* aurEff);
bool CreateServer(Map* map, AreaTriggerTemplate const* areaTriggerTemplate, AreaTriggerSpawn const& position);
public:
static AreaTrigger* CreateAreaTrigger(uint32 spellMiscId, Unit* caster, Unit* target, SpellInfo const* spell, Position const& pos, int32 duration, SpellCastVisual spellVisual, ObjectGuid const& castId = ObjectGuid::Empty, AuraEffect const* aurEff = nullptr);
static AreaTrigger* CreateAreaTrigger(uint32 areaTriggerCreatePropertiesId, Unit* caster, Unit* target, SpellInfo const* spell, Position const& pos, int32 duration, SpellCastVisual spellVisual, ObjectGuid const& castId = ObjectGuid::Empty, AuraEffect const* aurEff = nullptr);
bool LoadFromDB(ObjectGuid::LowType spawnId, Map* map, bool addToMap, bool allowDuplicate);
void Update(uint32 diff) override;
@@ -88,7 +88,7 @@ class TC_GAME_API AreaTrigger : public WorldObject, public GridObject<AreaTrigge
GuidUnorderedSet const& GetInsideUnits() const { return _insideUnits; }
AreaTriggerMiscTemplate const* GetMiscTemplate() const { return _areaTriggerMiscTemplate; }
AreaTriggerCreateProperties const* GetCreateProperties() const { return _areaTriggerCreateProperties; }
AreaTriggerTemplate const* GetTemplate() const;
uint32 GetScriptId() const;
@@ -99,6 +99,7 @@ class TC_GAME_API AreaTrigger : public WorldObject, public GridObject<AreaTrigge
uint32 GetFaction() const override;
AreaTriggerShapeInfo const& GetShape() const { return _shape; }
float GetMaxSearchRadius() const { return _maxSearchRadius; }
Position const& GetRollPitchYaw() const { return _rollPitchYaw; }
Position const& GetTargetRollPitchYaw() const { return _targetRollPitchYaw; }
@@ -108,7 +109,7 @@ class TC_GAME_API AreaTrigger : public WorldObject, public GridObject<AreaTrigge
::Movement::Spline<int32> const& GetSpline() const { return *_spline; }
uint32 GetElapsedTimeForMovement() const { return GetTimeSinceCreated(); } /// @todo: research the right value, in sniffs both timers are nearly identical
void InitOrbit(AreaTriggerOrbitInfo const& cmi, uint32 timeToTarget);
void InitOrbit(AreaTriggerOrbitInfo const& orbit, uint32 timeToTarget);
bool HasOrbit() const;
Optional<AreaTriggerOrbitInfo> const& GetCircularMovementInfo() const { return _orbitInfo; }
@@ -145,6 +146,7 @@ class TC_GAME_API AreaTrigger : public WorldObject, public GridObject<AreaTrigge
AuraEffect const* _aurEff;
AreaTriggerShapeInfo _shape;
float _maxSearchRadius;
int32 _duration;
int32 _totalDuration;
@@ -163,7 +165,7 @@ class TC_GAME_API AreaTrigger : public WorldObject, public GridObject<AreaTrigge
Optional<AreaTriggerOrbitInfo> _orbitInfo;
AreaTriggerMiscTemplate const* _areaTriggerMiscTemplate;
AreaTriggerCreateProperties const* _areaTriggerCreateProperties;
AreaTriggerTemplate const* _areaTriggerTemplate;
GuidUnorderedSet _insideUnits;

View File

@@ -26,58 +26,43 @@ AreaTriggerScaleInfo::AreaTriggerScaleInfo()
memset(Data.Raw, 0, sizeof(Data.Raw));
}
AreaTriggerShapeInfo::AreaTriggerShapeInfo()
{
Type = AREATRIGGER_TYPE_MAX;
memset(DefaultDatas.Data, 0, sizeof(DefaultDatas.Data));
}
float AreaTriggerShapeInfo::GetMaxSearchRadius() const
{
switch (Type)
{
case AREATRIGGER_TYPE_SPHERE:
return std::max(SphereDatas.Radius, SphereDatas.RadiusTarget);
case AREATRIGGER_TYPE_BOX:
return std::sqrt(BoxDatas.Extents[0] * BoxDatas.Extents[0] / 4 + BoxDatas.Extents[1] * BoxDatas.Extents[1] / 4);
case AREATRIGGER_TYPE_CYLINDER:
return CylinderDatas.Radius;
default:
break;
}
return 0.0f;
}
AreaTriggerTemplate::AreaTriggerTemplate()
{
Id = { 0, false };
Type = AREATRIGGER_TYPE_MAX;
Flags = 0;
ScriptId = 0;
MaxSearchRadius = 0.0f;
memset(DefaultDatas.Data, 0, sizeof(DefaultDatas.Data));
}
AreaTriggerTemplate::~AreaTriggerTemplate()
{
}
// Init the MaxSearchRadius that will be used in TrinitySearcher, avoiding calculate it at each update
void AreaTriggerTemplate::InitMaxSearchRadius()
AreaTriggerCreateProperties::AreaTriggerCreateProperties()
{
switch (Type)
{
case AREATRIGGER_TYPE_SPHERE:
{
MaxSearchRadius = std::max(SphereDatas.Radius, SphereDatas.RadiusTarget);
break;
}
case AREATRIGGER_TYPE_BOX:
{
MaxSearchRadius = std::sqrt(BoxDatas.Extents[0] * BoxDatas.Extents[0] / 4 + BoxDatas.Extents[1] * BoxDatas.Extents[1] / 4);
break;
}
// Polygon is SpellMisc based, can't init MaxSearchRadius
case AREATRIGGER_TYPE_POLYGON:
{
if (PolygonDatas.Height <= 0.0f)
PolygonDatas.Height = 1.0f;
break;
}
case AREATRIGGER_TYPE_CYLINDER:
{
MaxSearchRadius = CylinderDatas.Radius;
break;
}
default:
break;
}
}
AreaTriggerMiscTemplate::AreaTriggerMiscTemplate()
{
MiscId = 0;
AreaTriggerEntry = 0;
Id = 0;
MoveCurveId = 0;
ScaleCurveId = 0;
@@ -102,27 +87,32 @@ AreaTriggerMiscTemplate::AreaTriggerMiscTemplate()
Template = nullptr;
}
AreaTriggerMiscTemplate::~AreaTriggerMiscTemplate()
AreaTriggerCreateProperties::~AreaTriggerCreateProperties()
{
}
bool AreaTriggerMiscTemplate::HasSplines() const
bool AreaTriggerCreateProperties::HasSplines() const
{
return SplinePoints.size() >= 2;
}
float AreaTriggerMiscTemplate::GetPolygonMaxSearchRadius() const
float AreaTriggerCreateProperties::GetMaxSearchRadius() const
{
Position center(0.0f, 0.0f);
float maxSearchRadius = 0.0f;
for (TaggedPosition<Position::XY> const& vertice : PolygonVertices)
if (Shape.Type == AREATRIGGER_TYPE_POLYGON)
{
float pointDist = center.GetExactDist2d(vertice);
Position center(0.0f, 0.0f);
float maxSearchRadius = 0.0f;
if (pointDist > maxSearchRadius)
maxSearchRadius = pointDist;
for (TaggedPosition<Position::XY> const& vertice : PolygonVertices)
{
float pointDist = center.GetExactDist2d(vertice);
if (pointDist > maxSearchRadius)
maxSearchRadius = pointDist;
}
return maxSearchRadius;
}
return maxSearchRadius;
return Shape.GetMaxSearchRadius();
}

View File

@@ -36,10 +36,10 @@ enum AreaTriggerFlags
AREATRIGGER_FLAG_HAS_FOLLOWS_TERRAIN = 0x00010, // NYI
AREATRIGGER_FLAG_UNK1 = 0x00020,
AREATRIGGER_FLAG_HAS_TARGET_ROLL_PITCH_YAW = 0x00040, // NYI
AREATRIGGER_FLAG_HAS_ANIM_ID = 0x00080,
AREATRIGGER_FLAG_HAS_ANIM_ID = 0x00080, // DEPRECATED
AREATRIGGER_FLAG_UNK3 = 0x00100,
AREATRIGGER_FLAG_HAS_ANIM_KIT_ID = 0x00200,
AREATRIGGER_FLAG_HAS_CIRCULAR_MOVEMENT = 0x00400,
AREATRIGGER_FLAG_HAS_ANIM_KIT_ID = 0x00200, // DEPRECATED
AREATRIGGER_FLAG_HAS_CIRCULAR_MOVEMENT = 0x00400, // DEPRECATED
AREATRIGGER_FLAG_UNK5 = 0x00800,
};
@@ -115,42 +115,17 @@ struct AreaTriggerScaleInfo
} Data;
};
struct AreaTriggerOrbitInfo
struct AreaTriggerShapeInfo
{
Optional<ObjectGuid> PathTarget;
Optional<TaggedPosition<Position::XYZ>> Center;
bool CounterClockwise = false;
bool CanLoop = false;
uint32 TimeToTarget = 0;
int32 ElapsedTimeForMovement = 0;
uint32 StartDelay = 0;
float Radius = 0.0f;
float BlendFromRadius = 0.0f;
float InitialAngle = 0.0f;
float ZOffset = 0.0f;
};
class AreaTriggerTemplate
{
public:
AreaTriggerTemplate();
~AreaTriggerTemplate();
bool HasFlag(uint32 flag) const { return (Flags & flag) != 0; }
AreaTriggerShapeInfo();
bool IsSphere() const { return Type == AREATRIGGER_TYPE_SPHERE; }
bool IsBox() const { return Type == AREATRIGGER_TYPE_BOX; }
bool IsPolygon() const { return Type == AREATRIGGER_TYPE_POLYGON; }
bool IsCylinder() const { return Type == AREATRIGGER_TYPE_CYLINDER; }
float GetMaxSearchRadius() const;
void InitMaxSearchRadius();
AreaTriggerId Id;
AreaTriggerTypes Type;
uint32 Flags;
uint32 ScriptId;
float MaxSearchRadius;
std::vector<AreaTriggerAction> Actions;
union
{
@@ -193,17 +168,46 @@ public:
};
};
class AreaTriggerMiscTemplate
struct AreaTriggerOrbitInfo
{
Optional<ObjectGuid> PathTarget;
Optional<TaggedPosition<Position::XYZ>> Center;
bool CounterClockwise = false;
bool CanLoop = false;
uint32 TimeToTarget = 0;
int32 ElapsedTimeForMovement = 0;
uint32 StartDelay = 0;
float Radius = 0.0f;
float BlendFromRadius = 0.0f;
float InitialAngle = 0.0f;
float ZOffset = 0.0f;
};
class AreaTriggerTemplate
{
public:
AreaTriggerMiscTemplate();
~AreaTriggerMiscTemplate();
AreaTriggerTemplate();
~AreaTriggerTemplate();
bool HasFlag(uint32 flag) const { return (Flags & flag) != 0; }
AreaTriggerId Id;
uint32 Flags;
uint32 ScriptId;
std::vector<AreaTriggerAction> Actions;
};
class AreaTriggerCreateProperties
{
public:
AreaTriggerCreateProperties();
~AreaTriggerCreateProperties();
bool HasSplines() const;
float GetPolygonMaxSearchRadius() const;
float GetMaxSearchRadius() const;
uint32 MiscId;
uint32 AreaTriggerEntry;
uint32 Id;
AreaTriggerTemplate const* Template;
uint32 MoveCurveId;
uint32 ScaleCurveId;
@@ -220,13 +224,13 @@ public:
AreaTriggerScaleInfo OverrideScale;
AreaTriggerScaleInfo ExtraScale;
AreaTriggerOrbitInfo OrbitInfo;
AreaTriggerTemplate const* Template;
AreaTriggerShapeInfo Shape;
std::vector<TaggedPosition<Position::XY>> PolygonVertices;
std::vector<TaggedPosition<Position::XY>> PolygonVerticesTarget;
std::vector<Position> SplinePoints;
Optional<AreaTriggerOrbitInfo> OrbitInfo;
};
struct AreaTriggerSpawn
@@ -237,6 +241,8 @@ struct AreaTriggerSpawn
uint32 PhaseId = 0;
uint32 PhaseGroup = 0;
uint8 PhaseUseFlags = 0;
AreaTriggerShapeInfo Shape;
};
#endif

View File

@@ -429,7 +429,7 @@ void Object::BuildMovementUpdate(ByteBuffer* data, CreateObjectBits flags) const
if (flags.Vehicle)
{
Unit const* unit = ToUnit();
*data << uint32(unit->GetVehicleKit()->GetVehicleInfo()->ID); // RecID
*data << uint32(unit->GetVehicleKit()->GetVehicleInfo()->ID); // RecID
*data << float(unit->GetOrientation()); // InitialRawFacing
}
@@ -456,32 +456,33 @@ void Object::BuildMovementUpdate(ByteBuffer* data, CreateObjectBits flags) const
if (flags.AreaTrigger)
{
AreaTrigger const* areaTrigger = ToAreaTrigger();
AreaTriggerMiscTemplate const* areaTriggerMiscTemplate = areaTrigger->GetMiscTemplate();
AreaTriggerCreateProperties const* createProperties = areaTrigger->GetCreateProperties();
AreaTriggerTemplate const* areaTriggerTemplate = areaTrigger->GetTemplate();
AreaTriggerShapeInfo const& shape = areaTrigger->GetShape();
*data << uint32(areaTrigger->GetTimeSinceCreated());
*data << areaTrigger->GetRollPitchYaw().PositionXYZStream();
bool hasAbsoluteOrientation = areaTriggerTemplate->HasFlag(AREATRIGGER_FLAG_HAS_ABSOLUTE_ORIENTATION);
bool hasDynamicShape = areaTriggerTemplate->HasFlag(AREATRIGGER_FLAG_HAS_DYNAMIC_SHAPE);
bool hasAttached = areaTriggerTemplate->HasFlag(AREATRIGGER_FLAG_HAS_ATTACHED);
bool hasFaceMovementDir = areaTriggerTemplate->HasFlag(AREATRIGGER_FLAG_HAS_FACE_MOVEMENT_DIR);
bool hasFollowsTerrain = areaTriggerTemplate->HasFlag(AREATRIGGER_FLAG_HAS_FOLLOWS_TERRAIN);
bool hasUnk1 = areaTriggerTemplate->HasFlag(AREATRIGGER_FLAG_UNK1);
bool hasTargetRollPitchYaw = areaTriggerTemplate->HasFlag(AREATRIGGER_FLAG_HAS_TARGET_ROLL_PITCH_YAW);
bool hasScaleCurveID = areaTriggerMiscTemplate->ScaleCurveId != 0;
bool hasMorphCurveID = areaTriggerMiscTemplate->MorphCurveId != 0;
bool hasFacingCurveID = areaTriggerMiscTemplate->FacingCurveId != 0;
bool hasMoveCurveID = areaTriggerMiscTemplate->MoveCurveId != 0;
bool hasAnimation = areaTriggerTemplate->HasFlag(AREATRIGGER_FLAG_HAS_ANIM_ID);
bool hasUnk3 = areaTriggerTemplate->HasFlag(AREATRIGGER_FLAG_UNK3);
bool hasAnimKitID = areaTriggerTemplate->HasFlag(AREATRIGGER_FLAG_HAS_ANIM_KIT_ID);
bool hasAbsoluteOrientation = areaTriggerTemplate && areaTrigger->GetTemplate()->HasFlag(AREATRIGGER_FLAG_HAS_ABSOLUTE_ORIENTATION);
bool hasDynamicShape = areaTriggerTemplate && areaTrigger->GetTemplate()->HasFlag(AREATRIGGER_FLAG_HAS_DYNAMIC_SHAPE);
bool hasAttached = areaTriggerTemplate && areaTrigger->GetTemplate()->HasFlag(AREATRIGGER_FLAG_HAS_ATTACHED);
bool hasFaceMovementDir = areaTriggerTemplate && areaTrigger->GetTemplate()->HasFlag(AREATRIGGER_FLAG_HAS_FACE_MOVEMENT_DIR);
bool hasFollowsTerrain = areaTriggerTemplate && areaTrigger->GetTemplate()->HasFlag(AREATRIGGER_FLAG_HAS_FOLLOWS_TERRAIN);
bool hasUnk1 = areaTriggerTemplate && areaTrigger->GetTemplate()->HasFlag(AREATRIGGER_FLAG_UNK1);
bool hasTargetRollPitchYaw = areaTriggerTemplate && areaTrigger->GetTemplate()->HasFlag(AREATRIGGER_FLAG_HAS_TARGET_ROLL_PITCH_YAW);
bool hasScaleCurveID = createProperties && createProperties->ScaleCurveId != 0;
bool hasMorphCurveID = createProperties && createProperties->MorphCurveId != 0;
bool hasFacingCurveID = createProperties && createProperties->FacingCurveId != 0;
bool hasMoveCurveID = createProperties && createProperties->MoveCurveId != 0;
bool hasAnimation = createProperties && createProperties->AnimId;
bool hasUnk3 = areaTriggerTemplate && areaTrigger->GetTemplate()->HasFlag(AREATRIGGER_FLAG_UNK3);
bool hasAnimKitID = createProperties && createProperties->AnimKitId;
bool hasAnimProgress = false;
bool hasAreaTriggerSphere = areaTriggerTemplate->IsSphere();
bool hasAreaTriggerBox = areaTriggerTemplate->IsBox();
bool hasAreaTriggerPolygon = areaTriggerTemplate->IsPolygon();
bool hasAreaTriggerCylinder = areaTriggerTemplate->IsCylinder();
bool hasAreaTriggerSphere = shape.IsSphere();
bool hasAreaTriggerBox = shape.IsBox();
bool hasAreaTriggerPolygon = createProperties && shape.IsPolygon();
bool hasAreaTriggerCylinder = shape.IsCylinder();
bool hasAreaTriggerSpline = areaTrigger->HasSplines();
bool hasOrbit = areaTrigger->HasOrbit();
bool hasMovementScript = false;
@@ -526,64 +527,64 @@ void Object::BuildMovementUpdate(ByteBuffer* data, CreateObjectBits flags) const
*data << areaTrigger->GetTargetRollPitchYaw().PositionXYZStream();
if (hasScaleCurveID)
*data << uint32(areaTriggerMiscTemplate->ScaleCurveId);
*data << uint32(createProperties->ScaleCurveId);
if (hasMorphCurveID)
*data << uint32(areaTriggerMiscTemplate->MorphCurveId);
*data << uint32(createProperties->MorphCurveId);
if (hasFacingCurveID)
*data << uint32(areaTriggerMiscTemplate->FacingCurveId);
*data << uint32(createProperties->FacingCurveId);
if (hasMoveCurveID)
*data << uint32(areaTriggerMiscTemplate->MoveCurveId);
*data << uint32(createProperties->MoveCurveId);
if (hasAnimation)
*data << int32(areaTriggerMiscTemplate->AnimId);
*data << int32(createProperties->AnimId);
if (hasAnimKitID)
*data << int32(areaTriggerMiscTemplate->AnimKitId);
*data << int32(createProperties->AnimKitId);
if (hasAnimProgress)
*data << uint32(0);
if (hasAreaTriggerSphere)
{
*data << float(areaTriggerTemplate->SphereDatas.Radius);
*data << float(areaTriggerTemplate->SphereDatas.RadiusTarget);
*data << float(shape.SphereDatas.Radius);
*data << float(shape.SphereDatas.RadiusTarget);
}
if (hasAreaTriggerBox)
{
*data << float(areaTriggerTemplate->BoxDatas.Extents[0]);
*data << float(areaTriggerTemplate->BoxDatas.Extents[1]);
*data << float(areaTriggerTemplate->BoxDatas.Extents[2]);
*data << float(areaTriggerTemplate->BoxDatas.ExtentsTarget[0]);
*data << float(areaTriggerTemplate->BoxDatas.ExtentsTarget[1]);
*data << float(areaTriggerTemplate->BoxDatas.ExtentsTarget[2]);
*data << float(shape.BoxDatas.Extents[0]);
*data << float(shape.BoxDatas.Extents[1]);
*data << float(shape.BoxDatas.Extents[2]);
*data << float(shape.BoxDatas.ExtentsTarget[0]);
*data << float(shape.BoxDatas.ExtentsTarget[1]);
*data << float(shape.BoxDatas.ExtentsTarget[2]);
}
if (hasAreaTriggerPolygon)
{
*data << int32(areaTriggerMiscTemplate->PolygonVertices.size());
*data << int32(areaTriggerMiscTemplate->PolygonVerticesTarget.size());
*data << float(areaTriggerTemplate->PolygonDatas.Height);
*data << float(areaTriggerTemplate->PolygonDatas.HeightTarget);
*data << int32(createProperties->PolygonVertices.size());
*data << int32(createProperties->PolygonVerticesTarget.size());
*data << float(shape.PolygonDatas.Height);
*data << float(shape.PolygonDatas.HeightTarget);
for (TaggedPosition<Position::XY> const& vertice : areaTriggerMiscTemplate->PolygonVertices)
for (TaggedPosition<Position::XY> const& vertice : createProperties->PolygonVertices)
*data << vertice;
for (TaggedPosition<Position::XY> const& vertice : areaTriggerMiscTemplate->PolygonVerticesTarget)
for (TaggedPosition<Position::XY> const& vertice : createProperties->PolygonVerticesTarget)
*data << vertice;
}
if (hasAreaTriggerCylinder)
{
*data << float(areaTriggerTemplate->CylinderDatas.Radius);
*data << float(areaTriggerTemplate->CylinderDatas.RadiusTarget);
*data << float(areaTriggerTemplate->CylinderDatas.Height);
*data << float(areaTriggerTemplate->CylinderDatas.HeightTarget);
*data << float(areaTriggerTemplate->CylinderDatas.LocationZOffset);
*data << float(areaTriggerTemplate->CylinderDatas.LocationZOffsetTarget);
*data << float(shape.CylinderDatas.Radius);
*data << float(shape.CylinderDatas.RadiusTarget);
*data << float(shape.CylinderDatas.Height);
*data << float(shape.CylinderDatas.HeightTarget);
*data << float(shape.CylinderDatas.LocationZOffset);
*data << float(shape.CylinderDatas.LocationZOffsetTarget);
}
//if (hasMovementScript)

View File

@@ -52,15 +52,15 @@ namespace
std::unordered_map<std::pair<uint32/*mapId*/, uint32/*cell_id*/>, std::set<ObjectGuid::LowType>> _areaTriggerSpawnsByLocation;
std::unordered_map<uint32, AreaTriggerSpawn> _areaTriggerSpawnsBySpawnId;
std::unordered_map<AreaTriggerId, AreaTriggerTemplate> _areaTriggerTemplateStore;
std::unordered_map<uint32, AreaTriggerMiscTemplate> _areaTriggerTemplateSpellMisc;
std::unordered_map<uint32, AreaTriggerCreateProperties> _areaTriggerCreateProperties;
}
void AreaTriggerDataStore::LoadAreaTriggerTemplates()
{
uint32 oldMSTime = getMSTime();
std::unordered_map<uint32, std::vector<TaggedPosition<Position::XY>>> verticesBySpellMisc;
std::unordered_map<uint32, std::vector<TaggedPosition<Position::XY>>> verticesTargetBySpellMisc;
std::unordered_map<uint32, std::vector<Position>> splinesBySpellMisc;
std::unordered_map<uint32, std::vector<TaggedPosition<Position::XY>>> verticesByCreateProperties;
std::unordered_map<uint32, std::vector<TaggedPosition<Position::XY>>> verticesTargetByCreateProperties;
std::unordered_map<uint32, std::vector<Position>> splinesByCreateProperties;
std::unordered_map<AreaTriggerId, std::vector<AreaTriggerAction>> actionsByAreaTrigger;
// 0 1 2 3 4
@@ -112,46 +112,46 @@ void AreaTriggerDataStore::LoadAreaTriggerTemplates()
TC_LOG_INFO("server.loading", ">> Loaded 0 AreaTrigger templates actions. DB table `areatrigger_template_actions` is empty.");
}
// 0 1 2 3 4 5
if (QueryResult vertices = WorldDatabase.Query("SELECT SpellMiscId, Idx, VerticeX, VerticeY, VerticeTargetX, VerticeTargetY FROM `spell_areatrigger_vertices` ORDER BY `SpellMiscId`, `Idx`"))
// 0 1 2 3 4 5
if (QueryResult vertices = WorldDatabase.Query("SELECT AreaTriggerCreatePropertiesId, Idx, VerticeX, VerticeY, VerticeTargetX, VerticeTargetY FROM `areatrigger_create_properties_polygon_vertex` ORDER BY `AreaTriggerCreatePropertiesId`, `Idx`"))
{
do
{
Field* verticeFields = vertices->Fetch();
uint32 spellMiscId = verticeFields[0].GetUInt32();
uint32 areaTriggerCreatePropertiesId = verticeFields[0].GetUInt32();
verticesBySpellMisc[spellMiscId].emplace_back(verticeFields[2].GetFloat(), verticeFields[3].GetFloat());
verticesByCreateProperties[areaTriggerCreatePropertiesId].emplace_back(verticeFields[2].GetFloat(), verticeFields[3].GetFloat());
if (!verticeFields[4].IsNull() && !verticeFields[5].IsNull())
verticesTargetBySpellMisc[spellMiscId].emplace_back(verticeFields[4].GetFloat(), verticeFields[5].GetFloat());
verticesTargetByCreateProperties[areaTriggerCreatePropertiesId].emplace_back(verticeFields[4].GetFloat(), verticeFields[5].GetFloat());
else if (verticeFields[4].IsNull() != verticeFields[5].IsNull())
TC_LOG_ERROR("sql.sql", "Table `spell_areatrigger_vertices` has listed invalid target vertices (SpellMiscId: %u, Index: %u).", spellMiscId, verticeFields[1].GetUInt32());
TC_LOG_ERROR("sql.sql", "Table `areatrigger_create_properties_polygon_vertex` has listed invalid target vertices (AreaTriggerCreatePropertiesId: %u, Index: %u).", areaTriggerCreatePropertiesId, verticeFields[1].GetUInt32());
}
while (vertices->NextRow());
}
else
{
TC_LOG_INFO("server.loading", ">> Loaded 0 AreaTrigger templates polygon vertices. DB table `areatrigger_template_polygon_vertices` is empty.");
TC_LOG_INFO("server.loading", ">> Loaded 0 AreaTrigger polygon vertices. DB table `areatrigger_create_properties_polygon_vertex` is empty.");
}
// 0 1 2 3
if (QueryResult splines = WorldDatabase.Query("SELECT SpellMiscId, X, Y, Z FROM `spell_areatrigger_splines` ORDER BY `SpellMiscId`, `Idx`"))
// 0 1 2 3
if (QueryResult splines = WorldDatabase.Query("SELECT AreaTriggerCreatePropertiesId, X, Y, Z FROM `areatrigger_create_properties_spline_point` ORDER BY `AreaTriggerCreatePropertiesId`, `Idx`"))
{
do
{
Field* splineFields = splines->Fetch();
uint32 spellMiscId = splineFields[0].GetUInt32();
splinesBySpellMisc[spellMiscId].emplace_back(splineFields[1].GetFloat(), splineFields[2].GetFloat(), splineFields[3].GetFloat());
uint32 areaTriggerCreatePropertiesId = splineFields[0].GetUInt32();
splinesByCreateProperties[areaTriggerCreatePropertiesId].emplace_back(splineFields[1].GetFloat(), splineFields[2].GetFloat(), splineFields[3].GetFloat());
}
while (splines->NextRow());
}
else
{
TC_LOG_INFO("server.loading", ">> Loaded 0 AreaTrigger templates splines. DB table `spell_areatrigger_splines` is empty.");
TC_LOG_INFO("server.loading", ">> Loaded 0 AreaTrigger splines. DB table `areatrigger_create_properties_spline_point` is empty.");
}
// 0 1 2 3 4 5 6 7 8 9 10
if (QueryResult templates = WorldDatabase.Query("SELECT Id, IsServerSide, Type, Flags, Data0, Data1, Data2, Data3, Data4, Data5, ScriptName FROM `areatrigger_template`"))
// 0 1 2 3
if (QueryResult templates = WorldDatabase.Query("SELECT Id, IsServerSide, Flags, ScriptName FROM `areatrigger_template`"))
{
do
{
@@ -160,17 +160,7 @@ void AreaTriggerDataStore::LoadAreaTriggerTemplates()
AreaTriggerTemplate areaTriggerTemplate;
areaTriggerTemplate.Id.Id = fields[0].GetUInt32();
areaTriggerTemplate.Id.IsServerSide = fields[1].GetUInt8() == 1;
uint8 type = fields[2].GetUInt8();
if (type >= AREATRIGGER_TYPE_MAX)
{
TC_LOG_ERROR("sql.sql", "Table `areatrigger_template` has listed areatrigger (Id: %u, IsServerSide: %u) with invalid type %u.",
areaTriggerTemplate.Id.Id, uint32(areaTriggerTemplate.Id.IsServerSide), type);
continue;
}
areaTriggerTemplate.Type = static_cast<AreaTriggerTypes>(type);
areaTriggerTemplate.Flags = fields[3].GetUInt32();
areaTriggerTemplate.Flags = fields[2].GetUInt32();
if (areaTriggerTemplate.Id.IsServerSide && areaTriggerTemplate.Flags != 0)
{
@@ -179,100 +169,115 @@ void AreaTriggerDataStore::LoadAreaTriggerTemplates()
continue;
}
for (uint8 i = 0; i < MAX_AREATRIGGER_ENTITY_DATA; ++i)
areaTriggerTemplate.DefaultDatas.Data[i] = fields[4 + i].GetFloat();
areaTriggerTemplate.ScriptId = sObjectMgr->GetScriptId(fields[10].GetString());
areaTriggerTemplate.ScriptId = sObjectMgr->GetScriptId(fields[3].GetString());
areaTriggerTemplate.Actions = std::move(actionsByAreaTrigger[areaTriggerTemplate.Id]);
areaTriggerTemplate.InitMaxSearchRadius();
_areaTriggerTemplateStore[areaTriggerTemplate.Id] = areaTriggerTemplate;
}
while (templates->NextRow());
}
// 0 1 2 3 4 5 6 7 8 9 10
if (QueryResult areatriggerSpellMiscs = WorldDatabase.Query("SELECT SpellMiscId, AreaTriggerId, MoveCurveId, ScaleCurveId, MorphCurveId, FacingCurveId, AnimId, AnimKitId, DecalPropertiesId, TimeToTarget, TimeToTargetScale FROM `spell_areatrigger`"))
// 0 1 2 3 4 5 6 7 8 9 10
if (QueryResult areatriggerCreateProperties = WorldDatabase.Query("SELECT Id, AreaTriggerId, MoveCurveId, ScaleCurveId, MorphCurveId, FacingCurveId, AnimId, AnimKitId, DecalPropertiesId, TimeToTarget, TimeToTargetScale, "
// 11 12 13 14 15 16 17
"Shape, ShapeData0, ShapeData1, ShapeData2, ShapeData3, ShapeData4, ShapeData5 FROM `areatrigger_create_properties`"))
{
do
{
AreaTriggerMiscTemplate miscTemplate;
AreaTriggerCreateProperties createProperties;
Field* areatriggerSpellMiscFields = areatriggerSpellMiscs->Fetch();
miscTemplate.MiscId = areatriggerSpellMiscFields[0].GetUInt32();
Field* fields = areatriggerCreateProperties->Fetch();
createProperties.Id = fields[0].GetUInt32();
uint32 areatriggerId = areatriggerSpellMiscFields[1].GetUInt32();
miscTemplate.Template = GetAreaTriggerTemplate({ areatriggerId, false });
uint32 areatriggerId = fields[1].GetUInt32();
createProperties.Template = GetAreaTriggerTemplate({ areatriggerId, false });
if (!miscTemplate.Template)
uint8 shape = fields[11].GetUInt8();
if (areatriggerId && !createProperties.Template)
{
TC_LOG_ERROR("sql.sql", "Table `spell_areatrigger` reference invalid AreaTriggerId %u for miscId %u", areatriggerId, miscTemplate.MiscId);
TC_LOG_ERROR("sql.sql", "Table `areatrigger_create_properties` references invalid AreaTriggerId %u for AreaTriggerCreatePropertiesId %u", areatriggerId, createProperties.Id);
continue;
}
if (shape >= AREATRIGGER_TYPE_MAX)
{
TC_LOG_ERROR("sql.sql", "Table `areatrigger_create_properties` has listed areatrigger create properties %u with invalid shape %u.",
createProperties.Id, uint32(shape));
continue;
}
#define VALIDATE_AND_SET_CURVE(Curve, Value) \
miscTemplate.Curve = Value; \
if (miscTemplate.Curve && !sCurveStore.LookupEntry(miscTemplate.Curve)) \
createProperties.Curve = Value; \
if (createProperties.Curve && !sCurveStore.LookupEntry(createProperties.Curve)) \
{ \
TC_LOG_ERROR("sql.sql", "Table `spell_areatrigger` has listed areatrigger (MiscId: %u, Id: %u) with invalid " #Curve " (%u), set to 0!", \
miscTemplate.MiscId, areatriggerId, miscTemplate.Curve); \
miscTemplate.Curve = 0; \
TC_LOG_ERROR("sql.sql", "Table `areatrigger_create_properties` has listed areatrigger (AreaTriggerCreatePropertiesId: %u, Id: %u) with invalid " #Curve " (%u), set to 0!", \
createProperties.Id, areatriggerId, createProperties.Curve); \
createProperties.Curve = 0; \
}
VALIDATE_AND_SET_CURVE(MoveCurveId, areatriggerSpellMiscFields[2].GetUInt32());
VALIDATE_AND_SET_CURVE(ScaleCurveId, areatriggerSpellMiscFields[3].GetUInt32());
VALIDATE_AND_SET_CURVE(MorphCurveId, areatriggerSpellMiscFields[4].GetUInt32());
VALIDATE_AND_SET_CURVE(FacingCurveId, areatriggerSpellMiscFields[5].GetUInt32());
VALIDATE_AND_SET_CURVE(MoveCurveId, fields[2].GetUInt32());
VALIDATE_AND_SET_CURVE(ScaleCurveId, fields[3].GetUInt32());
VALIDATE_AND_SET_CURVE(MorphCurveId, fields[4].GetUInt32());
VALIDATE_AND_SET_CURVE(FacingCurveId, fields[5].GetUInt32());
#undef VALIDATE_AND_SET_CURVE
miscTemplate.AnimId = areatriggerSpellMiscFields[6].GetInt32();
miscTemplate.AnimKitId = areatriggerSpellMiscFields[7].GetInt32();
createProperties.AnimId = fields[6].GetInt32();
createProperties.AnimKitId = fields[7].GetInt32();
miscTemplate.DecalPropertiesId = areatriggerSpellMiscFields[8].GetUInt32();
createProperties.DecalPropertiesId = fields[8].GetUInt32();
miscTemplate.TimeToTarget = areatriggerSpellMiscFields[9].GetUInt32();
miscTemplate.TimeToTargetScale = areatriggerSpellMiscFields[10].GetUInt32();
createProperties.TimeToTarget = fields[9].GetUInt32();
createProperties.TimeToTargetScale = fields[10].GetUInt32();
miscTemplate.PolygonVertices = std::move(verticesBySpellMisc[miscTemplate.MiscId]);
miscTemplate.PolygonVerticesTarget = std::move(verticesTargetBySpellMisc[miscTemplate.MiscId]);
miscTemplate.SplinePoints = std::move(splinesBySpellMisc[miscTemplate.MiscId]);
createProperties.Shape.Type = static_cast<AreaTriggerTypes>(shape);
for (uint8 i = 0; i < MAX_AREATRIGGER_ENTITY_DATA; ++i)
createProperties.Shape.DefaultDatas.Data[i] = fields[12 + i].GetFloat();
_areaTriggerTemplateSpellMisc[miscTemplate.MiscId] = miscTemplate;
if (shape == AREATRIGGER_TYPE_POLYGON)
if (createProperties.Shape.PolygonDatas.Height <= 0.0f)
createProperties.Shape.PolygonDatas.Height = 1.0f;
createProperties.PolygonVertices = std::move(verticesByCreateProperties[createProperties.Id]);
createProperties.PolygonVerticesTarget = std::move(verticesTargetByCreateProperties[createProperties.Id]);
createProperties.SplinePoints = std::move(splinesByCreateProperties[createProperties.Id]);
_areaTriggerCreateProperties[createProperties.Id] = createProperties;
}
while (areatriggerSpellMiscs->NextRow());
while (areatriggerCreateProperties->NextRow());
}
else
{
TC_LOG_INFO("server.loading", ">> Loaded 0 Spell AreaTrigger templates. DB table `spell_areatrigger` is empty.");
TC_LOG_INFO("server.loading", ">> Loaded 0 AreaTrigger create properties. DB table `areatrigger_create_properties` is empty.");
}
// 0 1 2 3 4 5 6 7
if (QueryResult circularMovementInfos = WorldDatabase.Query("SELECT SpellMiscId, StartDelay, CircleRadius, BlendFromRadius, InitialAngle, ZOffset, CounterClockwise, CanLoop FROM `spell_areatrigger_circular` ORDER BY `SpellMiscId`"))
// 0 1 2 3 4 5 6 7
if (QueryResult circularMovementInfos = WorldDatabase.Query("SELECT AreaTriggerCreatePropertiesId, StartDelay, CircleRadius, BlendFromRadius, InitialAngle, ZOffset, CounterClockwise, CanLoop FROM `areatrigger_create_properties_orbit`"))
{
do
{
Field* circularMovementInfoFields = circularMovementInfos->Fetch();
uint32 spellMiscId = circularMovementInfoFields[0].GetUInt32();
uint32 areaTriggerCreatePropertiesId = circularMovementInfoFields[0].GetUInt32();
auto atSpellMiscItr = _areaTriggerTemplateSpellMisc.find(spellMiscId);
if (atSpellMiscItr == _areaTriggerTemplateSpellMisc.end())
AreaTriggerCreateProperties* createProperties = Trinity::Containers::MapGetValuePtr(_areaTriggerCreateProperties, areaTriggerCreatePropertiesId);
if (!createProperties)
{
TC_LOG_ERROR("sql.sql", "Table `spell_areatrigger_circular` reference invalid SpellMiscId %u", spellMiscId);
TC_LOG_ERROR("sql.sql", "Table `areatrigger_create_properties_orbit` reference invalid AreaTriggerCreatePropertiesId %u", areaTriggerCreatePropertiesId);
continue;
}
AreaTriggerOrbitInfo& orbitInfo = atSpellMiscItr->second.OrbitInfo;
createProperties->OrbitInfo.emplace();
orbitInfo.StartDelay = circularMovementInfoFields[1].GetUInt32();
createProperties->OrbitInfo->StartDelay = circularMovementInfoFields[1].GetUInt32();
#define VALIDATE_AND_SET_FLOAT(Float, Value) \
orbitInfo.Float = Value; \
if (!std::isfinite(orbitInfo.Float)) \
createProperties->OrbitInfo->Float = Value; \
if (!std::isfinite(createProperties->OrbitInfo->Float)) \
{ \
TC_LOG_ERROR("sql.sql", "Table `spell_areatrigger_circular` has listed areatrigger (MiscId: %u) with invalid " #Float " (%f), set to 0!", \
spellMiscId, orbitInfo.Float); \
orbitInfo.Float = 0.0f; \
TC_LOG_ERROR("sql.sql", "Table `areatrigger_create_properties_orbit` has listed areatrigger (AreaTriggerCreatePropertiesId: %u) with invalid " #Float " (%f), set to 0!", \
areaTriggerCreatePropertiesId, createProperties->OrbitInfo->Float); \
createProperties->OrbitInfo->Float = 0.0f; \
}
VALIDATE_AND_SET_FLOAT(Radius, circularMovementInfoFields[2].GetFloat());
@@ -282,14 +287,14 @@ void AreaTriggerDataStore::LoadAreaTriggerTemplates()
#undef VALIDATE_AND_SET_FLOAT
orbitInfo.CounterClockwise = circularMovementInfoFields[6].GetBool();
orbitInfo.CanLoop = circularMovementInfoFields[7].GetBool();
createProperties->OrbitInfo->CounterClockwise = circularMovementInfoFields[6].GetBool();
createProperties->OrbitInfo->CanLoop = circularMovementInfoFields[7].GetBool();
}
while (circularMovementInfos->NextRow());
}
else
{
TC_LOG_INFO("server.loading", ">> Loaded 0 AreaTrigger templates circular movement infos. DB table `spell_areatrigger_circular` is empty.");
TC_LOG_INFO("server.loading", ">> Loaded 0 AreaTrigger templates circular movement infos. DB table `areatrigger_create_properties_orbit` is empty.");
}
TC_LOG_INFO("server.loading", ">> Loaded " SZFMTD " spell areatrigger templates in %u ms.", _areaTriggerTemplateStore.size(), GetMSTimeDiffToNow(oldMSTime));
@@ -300,7 +305,9 @@ void AreaTriggerDataStore::LoadAreaTriggerSpawns()
uint32 oldMSTime = getMSTime();
// Load area trigger positions (to put them on the server)
// 0 1 2 3 4 5 6 7 8 9 10
if (QueryResult templates = WorldDatabase.Query("SELECT SpawnId, AreaTriggerId, IsServerSide, MapId, PosX, PosY, PosZ, Orientation, PhaseUseFlags, PhaseId, PhaseGroup FROM `areatrigger`"))
if (QueryResult templates = WorldDatabase.Query("SELECT SpawnId, AreaTriggerId, IsServerSide, MapId, PosX, PosY, PosZ, Orientation, PhaseUseFlags, PhaseId, PhaseGroup, "
// 11 12 13 14 15 16 17
"Shape, ShapeData0, ShapeData1, ShapeData2, ShapeData3, ShapeData4, ShapeData5 FROM `areatrigger`"))
{
do
{
@@ -309,6 +316,7 @@ void AreaTriggerDataStore::LoadAreaTriggerSpawns()
ObjectGuid::LowType spawnId = fields[0].GetUInt64();
AreaTriggerId areaTriggerid = { fields[1].GetUInt32(), fields[2].GetUInt8() == 1 };
WorldLocation location(fields[3].GetUInt32(), fields[4].GetFloat(), fields[5].GetFloat(), fields[6].GetFloat(), fields[7].GetFloat());
uint8 shape = fields[11].GetUInt8();
if (!GetAreaTriggerTemplate(areaTriggerid))
{
@@ -324,6 +332,13 @@ void AreaTriggerDataStore::LoadAreaTriggerSpawns()
continue;
}
if (shape >= AREATRIGGER_TYPE_MAX)
{
TC_LOG_ERROR("sql.sql", "Table `areatrigger` has listed areatrigger SpawnId: " UI64FMTD " with invalid shape %u.",
spawnId, uint32(shape));
continue;
}
AreaTriggerSpawn spawn;
spawn.SpawnId = spawnId;
spawn.Id = areaTriggerid;
@@ -333,6 +348,10 @@ void AreaTriggerDataStore::LoadAreaTriggerSpawns()
spawn.PhaseId = fields[9].GetUInt32();
spawn.PhaseGroup = fields[10].GetUInt32();
spawn.Shape.Type = static_cast<AreaTriggerTypes>(shape);
for (uint8 i = 0; i < MAX_AREATRIGGER_ENTITY_DATA; ++i)
spawn.Shape.DefaultDatas.Data[i] = fields[12 + i].GetFloat();
// Add the trigger to a map::cell map, which is later used by GridLoader to query
CellCoord cellCoord = Trinity::ComputeCellCoord(spawn.Location.GetPositionX(), spawn.Location.GetPositionY());
_areaTriggerSpawnsByLocation[{ spawn.Location.GetMapId(), cellCoord.GetId() }].insert(spawnId);
@@ -350,9 +369,9 @@ AreaTriggerTemplate const* AreaTriggerDataStore::GetAreaTriggerTemplate(AreaTrig
return Trinity::Containers::MapGetValuePtr(_areaTriggerTemplateStore, areaTriggerId);
}
AreaTriggerMiscTemplate const* AreaTriggerDataStore::GetAreaTriggerMiscTemplate(uint32 spellMiscValue) const
AreaTriggerCreateProperties const* AreaTriggerDataStore::GetAreaTriggerCreateProperties(uint32 areaTriggerCreatePropertiesId) const
{
return Trinity::Containers::MapGetValuePtr(_areaTriggerTemplateSpellMisc, spellMiscValue);
return Trinity::Containers::MapGetValuePtr(_areaTriggerCreateProperties, areaTriggerCreatePropertiesId);
}
std::set<ObjectGuid::LowType> const* AreaTriggerDataStore::GetAreaTriggersForMapAndCell(uint32 mapId, uint32 cellId) const

View File

@@ -23,7 +23,7 @@
#include <set>
class AreaTriggerTemplate;
class AreaTriggerMiscTemplate;
class AreaTriggerCreateProperties;
struct AreaTriggerId;
struct AreaTriggerSpawn;
@@ -36,7 +36,7 @@ public:
std::set<ObjectGuid::LowType> const* GetAreaTriggersForMapAndCell(uint32 mapId, uint32 cellId) const;
AreaTriggerSpawn const* GetAreaTriggerSpawn(ObjectGuid::LowType spawnId) const;
AreaTriggerTemplate const* GetAreaTriggerTemplate(AreaTriggerId const& areaTriggerId) const;
AreaTriggerMiscTemplate const* GetAreaTriggerMiscTemplate(uint32 spellMiscValue) const;
AreaTriggerCreateProperties const* GetAreaTriggerCreateProperties(uint32 areaTriggerCreatePropertiesId) const;
static AreaTriggerDataStore* Instance();
};