Forgot the files.
This commit is contained in:
@@ -31,8 +31,8 @@ namespace Game.DataStorage
|
|||||||
public void LoadAreaTriggerTemplates()
|
public void LoadAreaTriggerTemplates()
|
||||||
{
|
{
|
||||||
uint oldMSTime = Time.GetMSTime();
|
uint oldMSTime = Time.GetMSTime();
|
||||||
MultiMap<uint, Vector2> verticesByAreaTrigger = new();
|
MultiMap<uint, Vector2> verticesBySpellMisc = new();
|
||||||
MultiMap<uint, Vector2> verticesTargetByAreaTrigger = new();
|
MultiMap<uint, Vector2> verticesTargetBySpellMisc = new();
|
||||||
MultiMap<uint, Vector3> splinesBySpellMisc = new();
|
MultiMap<uint, Vector3> splinesBySpellMisc = new();
|
||||||
MultiMap<AreaTriggerId, AreaTriggerAction> actionsByAreaTrigger = new();
|
MultiMap<AreaTriggerId, AreaTriggerAction> actionsByAreaTrigger = new();
|
||||||
|
|
||||||
@@ -80,20 +80,20 @@ namespace Game.DataStorage
|
|||||||
Log.outInfo(LogFilter.ServerLoading, "Loaded 0 AreaTrigger templates actions. DB table `areatrigger_template_actions` is empty.");
|
Log.outInfo(LogFilter.ServerLoading, "Loaded 0 AreaTrigger templates actions. DB table `areatrigger_template_actions` is empty.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 0 1 2 3 4 5
|
// 0 1 2 3 4 5
|
||||||
SQLResult vertices = DB.World.Query("SELECT AreaTriggerId, Idx, VerticeX, VerticeY, VerticeTargetX, VerticeTargetY FROM `areatrigger_template_polygon_vertices` ORDER BY `AreaTriggerId`, `Idx`");
|
SQLResult vertices = DB.World.Query("SELECT SpellMiscId, Idx, VerticeX, VerticeY, VerticeTargetX, VerticeTargetY FROM `spell_areatrigger_vertices` ORDER BY `SpellMiscId`, `Idx`");
|
||||||
if (!vertices.IsEmpty())
|
if (!vertices.IsEmpty())
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
uint areaTriggerId = vertices.Read<uint>(0);
|
uint spellMiscId = vertices.Read<uint>(0);
|
||||||
|
|
||||||
verticesByAreaTrigger.Add(areaTriggerId, new Vector2(vertices.Read<float>(2), vertices.Read<float>(3)));
|
verticesBySpellMisc.Add(spellMiscId, new Vector2(vertices.Read<float>(2), vertices.Read<float>(3)));
|
||||||
|
|
||||||
if (!vertices.IsNull(4) && !vertices.IsNull(5))
|
if (!vertices.IsNull(4) && !vertices.IsNull(5))
|
||||||
verticesTargetByAreaTrigger.Add(areaTriggerId, new Vector2(vertices.Read<float>(4), vertices.Read<float>(5)));
|
verticesTargetBySpellMisc.Add(spellMiscId, new Vector2(vertices.Read<float>(4), vertices.Read<float>(5)));
|
||||||
else if (vertices.IsNull(4) != vertices.IsNull(5))
|
else if (vertices.IsNull(4) != vertices.IsNull(5))
|
||||||
Log.outError(LogFilter.Sql, "Table `areatrigger_template_polygon_vertices` has listed invalid target vertices (AreaTrigger: {0}, Index: {1}).", areaTriggerId, vertices.Read<uint>(1));
|
Log.outError(LogFilter.Sql, $"Table `spell_areatrigger_vertices` has listed invalid target vertices (SpellMiscId: {spellMiscId}, Index: {vertices.Read<uint>(1)}).");
|
||||||
}
|
}
|
||||||
while (vertices.NextRow());
|
while (vertices.NextRow());
|
||||||
}
|
}
|
||||||
@@ -153,11 +153,6 @@ namespace Game.DataStorage
|
|||||||
}
|
}
|
||||||
|
|
||||||
areaTriggerTemplate.ScriptId = Global.ObjectMgr.GetScriptId(templates.Read<string>(10));
|
areaTriggerTemplate.ScriptId = Global.ObjectMgr.GetScriptId(templates.Read<string>(10));
|
||||||
if (!areaTriggerTemplate.Id.IsServerSide)
|
|
||||||
{
|
|
||||||
areaTriggerTemplate.PolygonVertices = verticesByAreaTrigger[areaTriggerTemplate.Id.Id];
|
|
||||||
areaTriggerTemplate.PolygonVerticesTarget = verticesTargetByAreaTrigger[areaTriggerTemplate.Id.Id];
|
|
||||||
}
|
|
||||||
areaTriggerTemplate.Actions = actionsByAreaTrigger[areaTriggerTemplate.Id];
|
areaTriggerTemplate.Actions = actionsByAreaTrigger[areaTriggerTemplate.Id];
|
||||||
|
|
||||||
areaTriggerTemplate.InitMaxSearchRadius();
|
areaTriggerTemplate.InitMaxSearchRadius();
|
||||||
@@ -207,6 +202,8 @@ namespace Game.DataStorage
|
|||||||
miscTemplate.TimeToTarget = areatriggerSpellMiscs.Read<uint>(9);
|
miscTemplate.TimeToTarget = areatriggerSpellMiscs.Read<uint>(9);
|
||||||
miscTemplate.TimeToTargetScale = areatriggerSpellMiscs.Read<uint>(10);
|
miscTemplate.TimeToTargetScale = areatriggerSpellMiscs.Read<uint>(10);
|
||||||
|
|
||||||
|
miscTemplate.PolygonVertices = verticesBySpellMisc[miscTemplate.MiscId];
|
||||||
|
miscTemplate.PolygonVerticesTarget = verticesTargetBySpellMisc[miscTemplate.MiscId];
|
||||||
miscTemplate.SplinePoints = splinesBySpellMisc[miscTemplate.MiscId];
|
miscTemplate.SplinePoints = splinesBySpellMisc[miscTemplate.MiscId];
|
||||||
|
|
||||||
_areaTriggerTemplateSpellMisc[miscTemplate.MiscId] = miscTemplate;
|
_areaTriggerTemplateSpellMisc[miscTemplate.MiscId] = miscTemplate;
|
||||||
|
|||||||
@@ -107,6 +107,11 @@ namespace Game.Entities
|
|||||||
|
|
||||||
SetObjectScale(1.0f);
|
SetObjectScale(1.0f);
|
||||||
|
|
||||||
|
if (GetTemplate().IsPolygon())
|
||||||
|
_maxSearchRadius = GetMiscTemplate().GetPolygonMaxSearchRadius();
|
||||||
|
else
|
||||||
|
_maxSearchRadius = GetTemplate().MaxSearchRadius;
|
||||||
|
|
||||||
SetUpdateFieldValue(m_values.ModifyValue(m_areaTriggerData).ModifyValue(m_areaTriggerData.Caster), caster.GetGUID());
|
SetUpdateFieldValue(m_values.ModifyValue(m_areaTriggerData).ModifyValue(m_areaTriggerData.Caster), caster.GetGUID());
|
||||||
SetUpdateFieldValue(m_values.ModifyValue(m_areaTriggerData).ModifyValue(m_areaTriggerData.CreatingEffectGUID), castId);
|
SetUpdateFieldValue(m_values.ModifyValue(m_areaTriggerData).ModifyValue(m_areaTriggerData.CreatingEffectGUID), castId);
|
||||||
|
|
||||||
@@ -118,7 +123,7 @@ namespace Game.Entities
|
|||||||
SetUpdateFieldValue(ref spellCastVisual.ScriptVisualID, spellVisual.ScriptVisualID);
|
SetUpdateFieldValue(ref spellCastVisual.ScriptVisualID, spellVisual.ScriptVisualID);
|
||||||
|
|
||||||
SetUpdateFieldValue(m_values.ModifyValue(m_areaTriggerData).ModifyValue(m_areaTriggerData.TimeToTargetScale), GetMiscTemplate().TimeToTargetScale != 0 ? GetMiscTemplate().TimeToTargetScale : m_areaTriggerData.Duration);
|
SetUpdateFieldValue(m_values.ModifyValue(m_areaTriggerData).ModifyValue(m_areaTriggerData.TimeToTargetScale), GetMiscTemplate().TimeToTargetScale != 0 ? GetMiscTemplate().TimeToTargetScale : m_areaTriggerData.Duration);
|
||||||
SetUpdateFieldValue(m_values.ModifyValue(m_areaTriggerData).ModifyValue(m_areaTriggerData.BoundsRadius2D), GetTemplate().MaxSearchRadius);
|
SetUpdateFieldValue(m_values.ModifyValue(m_areaTriggerData).ModifyValue(m_areaTriggerData.BoundsRadius2D), GetMaxSearchRadius());
|
||||||
SetUpdateFieldValue(m_values.ModifyValue(m_areaTriggerData).ModifyValue(m_areaTriggerData.DecalPropertiesID), GetMiscTemplate().DecalPropertiesId);
|
SetUpdateFieldValue(m_values.ModifyValue(m_areaTriggerData).ModifyValue(m_areaTriggerData.DecalPropertiesID), GetMiscTemplate().DecalPropertiesId);
|
||||||
|
|
||||||
ScaleCurve extraScaleCurve = m_values.ModifyValue(m_areaTriggerData).ModifyValue(m_areaTriggerData.ExtraScaleCurve);
|
ScaleCurve extraScaleCurve = m_values.ModifyValue(m_areaTriggerData).ModifyValue(m_areaTriggerData.ExtraScaleCurve);
|
||||||
@@ -356,12 +361,12 @@ namespace Game.Entities
|
|||||||
if (IsServerSide())
|
if (IsServerSide())
|
||||||
{
|
{
|
||||||
var searcher = new PlayerListSearcher(this, targetList, check);
|
var searcher = new PlayerListSearcher(this, targetList, check);
|
||||||
Cell.VisitWorldObjects(this, searcher, GetTemplate().MaxSearchRadius);
|
Cell.VisitWorldObjects(this, searcher, GetMaxSearchRadius());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var searcher = new UnitListSearcher(this, targetList, check);
|
var searcher = new UnitListSearcher(this, targetList, check);
|
||||||
Cell.VisitAllObjects(this, searcher, GetTemplate().MaxSearchRadius);
|
Cell.VisitAllObjects(this, searcher, GetMaxSearchRadius());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -381,7 +386,7 @@ namespace Game.Entities
|
|||||||
|
|
||||||
void SearchUnitInBox(List<Unit> targetList)
|
void SearchUnitInBox(List<Unit> targetList)
|
||||||
{
|
{
|
||||||
SearchUnits(targetList, GetTemplate().MaxSearchRadius, false);
|
SearchUnits(targetList, GetMaxSearchRadius(), false);
|
||||||
|
|
||||||
Position boxCenter = GetPosition();
|
Position boxCenter = GetPosition();
|
||||||
float extentsX, extentsY, extentsZ;
|
float extentsX, extentsY, extentsZ;
|
||||||
@@ -398,7 +403,7 @@ namespace Game.Entities
|
|||||||
|
|
||||||
void SearchUnitInPolygon(List<Unit> targetList)
|
void SearchUnitInPolygon(List<Unit> targetList)
|
||||||
{
|
{
|
||||||
SearchUnits(targetList, GetTemplate().MaxSearchRadius, false);
|
SearchUnits(targetList, GetMaxSearchRadius(), false);
|
||||||
|
|
||||||
float height = GetTemplate().PolygonDatas.Height;
|
float height = GetTemplate().PolygonDatas.Height;
|
||||||
float minZ = GetPositionZ() - height;
|
float minZ = GetPositionZ() - height;
|
||||||
@@ -409,7 +414,7 @@ namespace Game.Entities
|
|||||||
|
|
||||||
void SearchUnitInCylinder(List<Unit> targetList)
|
void SearchUnitInCylinder(List<Unit> targetList)
|
||||||
{
|
{
|
||||||
SearchUnits(targetList, GetTemplate().MaxSearchRadius, false);
|
SearchUnits(targetList, GetMaxSearchRadius(), false);
|
||||||
|
|
||||||
float height = GetTemplate().CylinderDatas.Height;
|
float height = GetTemplate().CylinderDatas.Height;
|
||||||
float minZ = GetPositionZ() - height;
|
float minZ = GetPositionZ() - height;
|
||||||
@@ -508,7 +513,7 @@ namespace Game.Entities
|
|||||||
if (MathFunctions.fuzzyEq(_previousCheckOrientation, newOrientation))
|
if (MathFunctions.fuzzyEq(_previousCheckOrientation, newOrientation))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_polygonVertices = GetTemplate().PolygonVertices;
|
_polygonVertices = GetMiscTemplate().PolygonVertices;
|
||||||
|
|
||||||
float angleSin = (float)Math.Sin(newOrientation);
|
float angleSin = (float)Math.Sin(newOrientation);
|
||||||
float angleCos = (float)Math.Cos(newOrientation);
|
float angleCos = (float)Math.Cos(newOrientation);
|
||||||
@@ -1014,6 +1019,7 @@ namespace Game.Entities
|
|||||||
public override ObjectGuid GetOwnerGUID() { return GetCasterGuid(); }
|
public override ObjectGuid GetOwnerGUID() { return GetCasterGuid(); }
|
||||||
public ObjectGuid GetCasterGuid() { return m_areaTriggerData.Caster; }
|
public ObjectGuid GetCasterGuid() { return m_areaTriggerData.Caster; }
|
||||||
|
|
||||||
|
float GetMaxSearchRadius() { return _maxSearchRadius; }
|
||||||
public Vector3 GetRollPitchYaw() { return _rollPitchYaw; }
|
public Vector3 GetRollPitchYaw() { return _rollPitchYaw; }
|
||||||
public Vector3 GetTargetRollPitchYaw() { return _targetRollPitchYaw; }
|
public Vector3 GetTargetRollPitchYaw() { return _targetRollPitchYaw; }
|
||||||
|
|
||||||
@@ -1029,6 +1035,7 @@ namespace Game.Entities
|
|||||||
|
|
||||||
AuraEffect _aurEff;
|
AuraEffect _aurEff;
|
||||||
|
|
||||||
|
float _maxSearchRadius;
|
||||||
int _duration;
|
int _duration;
|
||||||
int _totalDuration;
|
int _totalDuration;
|
||||||
uint _timeSinceCreated;
|
uint _timeSinceCreated;
|
||||||
|
|||||||
@@ -234,19 +234,12 @@ namespace Game.Entities
|
|||||||
MaxSearchRadius = (float)Math.Sqrt(BoxDatas.Extents[0] * BoxDatas.Extents[0] / 4 + BoxDatas.Extents[1] * BoxDatas.Extents[1] / 4);
|
MaxSearchRadius = (float)Math.Sqrt(BoxDatas.Extents[0] * BoxDatas.Extents[0] / 4 + BoxDatas.Extents[1] * BoxDatas.Extents[1] / 4);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
// Polygon is SpellMisc based, can't init MaxSearchRadius
|
||||||
case AreaTriggerTypes.Polygon:
|
case AreaTriggerTypes.Polygon:
|
||||||
{
|
{
|
||||||
if (PolygonDatas.Height <= 0.0f)
|
if (PolygonDatas.Height <= 0.0f)
|
||||||
PolygonDatas.Height = 1.0f;
|
PolygonDatas.Height = 1.0f;
|
||||||
|
|
||||||
foreach (Vector2 vertice in PolygonVertices)
|
|
||||||
{
|
|
||||||
float pointDist = vertice.GetLength();
|
|
||||||
|
|
||||||
if (pointDist > MaxSearchRadius)
|
|
||||||
MaxSearchRadius = pointDist;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AreaTriggerTypes.Cylinder:
|
case AreaTriggerTypes.Cylinder:
|
||||||
@@ -272,8 +265,6 @@ namespace Game.Entities
|
|||||||
public uint ScriptId;
|
public uint ScriptId;
|
||||||
public float MaxSearchRadius;
|
public float MaxSearchRadius;
|
||||||
|
|
||||||
public List<Vector2> PolygonVertices = new();
|
|
||||||
public List<Vector2> PolygonVerticesTarget = new();
|
|
||||||
public List<AreaTriggerAction> Actions = new();
|
public List<AreaTriggerAction> Actions = new();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -289,6 +280,22 @@ namespace Game.Entities
|
|||||||
|
|
||||||
public bool HasSplines() { return SplinePoints.Count >= 2; }
|
public bool HasSplines() { return SplinePoints.Count >= 2; }
|
||||||
|
|
||||||
|
public float GetPolygonMaxSearchRadius()
|
||||||
|
{
|
||||||
|
Position center = new(0.0f, 0.0f);
|
||||||
|
float maxSearchRadius = 0.0f;
|
||||||
|
|
||||||
|
foreach (var vertice in PolygonVertices)
|
||||||
|
{
|
||||||
|
float pointDist = center.GetExactDist2d(vertice.X, vertice.Y);
|
||||||
|
|
||||||
|
if (pointDist > maxSearchRadius)
|
||||||
|
maxSearchRadius = pointDist;
|
||||||
|
}
|
||||||
|
|
||||||
|
return maxSearchRadius;
|
||||||
|
}
|
||||||
|
|
||||||
public uint MiscId;
|
public uint MiscId;
|
||||||
public uint AreaTriggerEntry;
|
public uint AreaTriggerEntry;
|
||||||
|
|
||||||
@@ -310,6 +317,9 @@ namespace Game.Entities
|
|||||||
public AreaTriggerOrbitInfo OrbitInfo;
|
public AreaTriggerOrbitInfo OrbitInfo;
|
||||||
|
|
||||||
public AreaTriggerTemplate Template;
|
public AreaTriggerTemplate Template;
|
||||||
|
|
||||||
|
public List<Vector2> PolygonVertices = new();
|
||||||
|
public List<Vector2> PolygonVerticesTarget = new();
|
||||||
public List<Vector3> SplinePoints = new();
|
public List<Vector3> SplinePoints = new();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user