Core/AreaTriggers: Refactor
* Moved IsServerside to custom flags * Flags moved from areatrigger_template to areatrigger_create_properties * New field to create custom CreateProperties (IsCustom) * New field to reference custom areatriggers (IsAreatriggerCustom) * Moved fields for shape data to areatrigger_create_properties Port From (https://github.com/TrinityCore/TrinityCore/commit/37eb2e64a6ad075e9866af6feb72bb4fbccb2adc)
This commit is contained in:
@@ -3,23 +3,13 @@
|
|||||||
|
|
||||||
namespace Framework.Constants
|
namespace Framework.Constants
|
||||||
{
|
{
|
||||||
public enum AreaTriggerFlags
|
public enum AreaTriggerFlag
|
||||||
{
|
{
|
||||||
HasAbsoluteOrientation = 0x01,
|
None = 0x00,
|
||||||
HasDynamicShape = 0x02, // Implemented For Spheres
|
IsServerSide = 0x01
|
||||||
HasAttached = 0x04,
|
|
||||||
HasFaceMovementDir = 0x08,
|
|
||||||
HasFollowsTerrain = 0x010, // Nyi
|
|
||||||
Unk1 = 0x020,
|
|
||||||
HasTargetRollPitchYaw = 0x040, // Nyi
|
|
||||||
HasAnimID = 0x080,
|
|
||||||
Unk3 = 0x100,
|
|
||||||
HasAnimKitID = 0x200,
|
|
||||||
HasCircularMovement = 0x400,
|
|
||||||
Unk5 = 0x800
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum AreaTriggerTypes
|
public enum AreaTriggerShapeType
|
||||||
{
|
{
|
||||||
Sphere = 0,
|
Sphere = 0,
|
||||||
Box = 1,
|
Box = 1,
|
||||||
@@ -49,4 +39,21 @@ namespace Framework.Constants
|
|||||||
Caster = 5,
|
Caster = 5,
|
||||||
Max = 6
|
Max = 6
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum AreaTriggerCreatePropertiesFlag
|
||||||
|
{
|
||||||
|
None = 0x00,
|
||||||
|
HasAbsoluteOrientation = 0x01,
|
||||||
|
HasDynamicShape = 0x02,
|
||||||
|
HasAttached = 0x04,
|
||||||
|
HasFaceMovementDir = 0x08,
|
||||||
|
HasFollowsTerrain = 0x10, // NYI
|
||||||
|
Unk1 = 0x20,
|
||||||
|
HasTargetRollPitchYaw = 0x40, // NYI
|
||||||
|
HasAnimId = 0x80, // DEPRECATED
|
||||||
|
Unk3 = 0x100,
|
||||||
|
HasAnimKitId = 0x200, // DEPRECATED
|
||||||
|
HasCircularMovement = 0x400, // DEPRECATED
|
||||||
|
Unk5 = 0x800,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1039,7 +1039,9 @@ namespace Framework.Constants
|
|||||||
CmdparserCurrencyNoExist = 1516,
|
CmdparserCurrencyNoExist = 1516,
|
||||||
CmdparserQuestNoExist = 1517,
|
CmdparserQuestNoExist = 1517,
|
||||||
|
|
||||||
// 1516-1998 - Free
|
// 1516-1996 - Free
|
||||||
|
DebugAreatriggerEntityEntered = 1997,
|
||||||
|
DebugAreatriggerEntityLeft = 1998,
|
||||||
DebugAreatriggerLeft = 1999,
|
DebugAreatriggerLeft = 1999,
|
||||||
// Ticket Strings 2000-2030
|
// Ticket Strings 2000-2030
|
||||||
CommandTicketnew = 2000, // 3.3.5 Reserved
|
CommandTicketnew = 2000, // 3.3.5 Reserved
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace Framework.Constants
|
|||||||
TimedActionlist = 9,
|
TimedActionlist = 9,
|
||||||
Scene = 10,
|
Scene = 10,
|
||||||
AreaTriggerEntity = 11,
|
AreaTriggerEntity = 11,
|
||||||
AreaTriggerEntityServerside = 12,
|
AreaTriggerEntityCustom = 12,
|
||||||
Max = 11
|
Max = 11
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -127,11 +127,11 @@ namespace Game.AI
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SmartScriptType.AreaTriggerEntityServerside:
|
case SmartScriptType.AreaTriggerEntityCustom:
|
||||||
{
|
{
|
||||||
if (Global.AreaTriggerDataStorage.GetAreaTriggerTemplate(new AreaTriggerId((uint)temp.EntryOrGuid, true)) == null)
|
if (Global.AreaTriggerDataStorage.GetAreaTriggerTemplate(new AreaTriggerId((uint)temp.EntryOrGuid, true)) == null)
|
||||||
{
|
{
|
||||||
Log.outError(LogFilter.Sql, $"SmartAIMgr.LoadFromDB: AreaTrigger entry ({temp.EntryOrGuid} IsServerSide true) does not exist, skipped loading.");
|
Log.outError(LogFilter.Sql, $"SmartAIMgr.LoadFromDB: AreaTrigger entry ({temp.EntryOrGuid} IsCustom true) does not exist, skipped loading.");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -1123,9 +1123,9 @@ namespace Game.AI
|
|||||||
}
|
}
|
||||||
case SmartEvents.AreatriggerOntrigger:
|
case SmartEvents.AreatriggerOntrigger:
|
||||||
{
|
{
|
||||||
if (e.Event.areatrigger.id != 0 && (e.GetScriptType() == SmartScriptType.AreaTriggerEntity || e.GetScriptType() == SmartScriptType.AreaTriggerEntityServerside))
|
if (e.Event.areatrigger.id != 0 && (e.GetScriptType() == SmartScriptType.AreaTriggerEntity || e.GetScriptType() == SmartScriptType.AreaTriggerEntityCustom))
|
||||||
{
|
{
|
||||||
Log.outError(LogFilter.Sql, $"SmartAIMgr: Entry {e.EntryOrGuid} SourceType {e.GetScriptType()} Event {e.EventId} Action {e.GetActionType()} areatrigger param not supported for SMART_SCRIPT_TYPE_AREATRIGGER_ENTITY and SMART_SCRIPT_TYPE_AREATRIGGER_ENTITY_SERVERSIDE, skipped.");
|
Log.outError(LogFilter.Sql, $"SmartAIMgr: Entry {e.EntryOrGuid} SourceType {e.GetScriptType()} Event {e.EventId} Action {e.GetActionType()} areatrigger param not supported for SMART_SCRIPT_TYPE_AREATRIGGER_ENTITY and SMART_SCRIPT_TYPE_AREATRIGGER_ENTITY_CUSTOM, skipped.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2351,7 +2351,7 @@ namespace Game.AI
|
|||||||
SmartScriptType.TimedActionlist => SmartScriptTypeMaskId.TimedActionlist,
|
SmartScriptType.TimedActionlist => SmartScriptTypeMaskId.TimedActionlist,
|
||||||
SmartScriptType.Scene => SmartScriptTypeMaskId.Scene,
|
SmartScriptType.Scene => SmartScriptTypeMaskId.Scene,
|
||||||
SmartScriptType.AreaTriggerEntity => SmartScriptTypeMaskId.AreatrigggerEntity,
|
SmartScriptType.AreaTriggerEntity => SmartScriptTypeMaskId.AreatrigggerEntity,
|
||||||
SmartScriptType.AreaTriggerEntityServerside => SmartScriptTypeMaskId.AreatrigggerEntity,
|
SmartScriptType.AreaTriggerEntityCustom => SmartScriptTypeMaskId.AreatrigggerEntity,
|
||||||
_ => 0,
|
_ => 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -2240,7 +2240,7 @@ namespace Game.AI
|
|||||||
|
|
||||||
Log.outDebug(LogFilter.ScriptsAi, $"SmartScript::ProcessAction:: SMART_ACTION_PLAY_ANIMKIT: target: {target.GetName()} ({target.GetGUID()}), AnimKit: {e.Action.animKit.animKit}, Type: {e.Action.animKit.type}");
|
Log.outDebug(LogFilter.ScriptsAi, $"SmartScript::ProcessAction:: SMART_ACTION_PLAY_ANIMKIT: target: {target.GetName()} ({target.GetGUID()}), AnimKit: {e.Action.animKit.animKit}, Type: {e.Action.animKit.type}");
|
||||||
}
|
}
|
||||||
else if(IsGameObject(target))
|
else if (IsGameObject(target))
|
||||||
{
|
{
|
||||||
switch (e.Action.animKit.type)
|
switch (e.Action.animKit.type)
|
||||||
{
|
{
|
||||||
@@ -3764,9 +3764,7 @@ namespace Game.AI
|
|||||||
|
|
||||||
public void OnUpdate(uint diff)
|
public void OnUpdate(uint diff)
|
||||||
{
|
{
|
||||||
if ((_scriptType == SmartScriptType.Creature || _scriptType == SmartScriptType.GameObject
|
if ((_scriptType == SmartScriptType.Creature || _scriptType == SmartScriptType.GameObject || _scriptType == SmartScriptType.AreaTriggerEntity || _scriptType == SmartScriptType.AreaTriggerEntityCustom) && GetBaseObject() == null)
|
||||||
|| _scriptType == SmartScriptType.AreaTriggerEntity || _scriptType == SmartScriptType.AreaTriggerEntityServerside)
|
|
||||||
&& GetBaseObject() == null)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_me != null && _me.IsInEvadeMode())
|
if (_me != null && _me.IsInEvadeMode())
|
||||||
@@ -3930,7 +3928,7 @@ namespace Game.AI
|
|||||||
FillScript(e, _go, null, null, null, 0);
|
FillScript(e, _go, null, null, null, 0);
|
||||||
break;
|
break;
|
||||||
case SmartScriptType.AreaTriggerEntity:
|
case SmartScriptType.AreaTriggerEntity:
|
||||||
case SmartScriptType.AreaTriggerEntityServerside:
|
case SmartScriptType.AreaTriggerEntityCustom:
|
||||||
e = Global.SmartAIMgr.GetScript((int)_areaTrigger.GetEntry(), _scriptType);
|
e = Global.SmartAIMgr.GetScript((int)_areaTrigger.GetEntry(), _scriptType);
|
||||||
FillScript(e, _areaTrigger, null, null, null, 0);
|
FillScript(e, _areaTrigger, null, null, null, 0);
|
||||||
break;
|
break;
|
||||||
@@ -4041,8 +4039,8 @@ namespace Game.AI
|
|||||||
break;
|
break;
|
||||||
case TypeId.AreaTrigger:
|
case TypeId.AreaTrigger:
|
||||||
_areaTrigger = obj.ToAreaTrigger();
|
_areaTrigger = obj.ToAreaTrigger();
|
||||||
_scriptType = _areaTrigger.IsServerSide() ? SmartScriptType.AreaTriggerEntityServerside : SmartScriptType.AreaTriggerEntity;
|
_scriptType = _areaTrigger.IsCustom() ? SmartScriptType.AreaTriggerEntityCustom : SmartScriptType.AreaTriggerEntity;
|
||||||
Log.outDebug(LogFilter.ScriptsAi, $"SmartScript.OnInitialize: source is AreaTrigger {_areaTrigger.GetEntry()}, IsServerSide {_areaTrigger.IsServerSide()}");
|
Log.outDebug(LogFilter.ScriptsAi, $"SmartScript.OnInitialize: source is AreaTrigger {_areaTrigger.GetEntry()}, IsCustom {_areaTrigger.IsCustom()}");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Log.outError(LogFilter.Scripts, "SmartScript.OnInitialize: Unhandled TypeID !WARNING!");
|
Log.outError(LogFilter.Scripts, "SmartScript.OnInitialize: Unhandled TypeID !WARNING!");
|
||||||
@@ -4104,7 +4102,7 @@ namespace Game.AI
|
|||||||
Cell.VisitGridObjects(_me, searcher, range);
|
Cell.VisitGridObjects(_me, searcher, range);
|
||||||
return searcher.GetTarget();
|
return searcher.GetTarget();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DoFindFriendlyCC(List<Creature> creatures, float range)
|
void DoFindFriendlyCC(List<Creature> creatures, float range)
|
||||||
{
|
{
|
||||||
if (_me == null)
|
if (_me == null)
|
||||||
@@ -4204,7 +4202,7 @@ namespace Game.AI
|
|||||||
}
|
}
|
||||||
|
|
||||||
public bool HasAnyEventWithFlag(SmartEventFlags flag) { return _allEventFlags.HasAnyFlag(flag); }
|
public bool HasAnyEventWithFlag(SmartEventFlags flag) { return _allEventFlags.HasAnyFlag(flag); }
|
||||||
|
|
||||||
public bool IsUnit(WorldObject obj) { return obj != null && (obj.IsTypeId(TypeId.Unit) || obj.IsTypeId(TypeId.Player)); }
|
public bool IsUnit(WorldObject obj) { return obj != null && (obj.IsTypeId(TypeId.Unit) || obj.IsTypeId(TypeId.Player)); }
|
||||||
|
|
||||||
public bool IsPlayer(WorldObject obj) { return obj != null && obj.IsTypeId(TypeId.Player); }
|
public bool IsPlayer(WorldObject obj) { return obj != null && obj.IsTypeId(TypeId.Player); }
|
||||||
|
|||||||
@@ -17,18 +17,18 @@ namespace Game.DataStorage
|
|||||||
public void LoadAreaTriggerTemplates()
|
public void LoadAreaTriggerTemplates()
|
||||||
{
|
{
|
||||||
uint oldMSTime = Time.GetMSTime();
|
uint oldMSTime = Time.GetMSTime();
|
||||||
MultiMap<uint, Vector2> verticesByCreateProperties = new();
|
MultiMap<AreaTriggerId, Vector2> verticesByCreateProperties = new();
|
||||||
MultiMap<uint, Vector2> verticesTargetByCreateProperties = new();
|
MultiMap<AreaTriggerId, Vector2> verticesTargetByCreateProperties = new();
|
||||||
MultiMap<uint, Vector3> splinesByCreateProperties = new();
|
MultiMap<AreaTriggerId, Vector3> splinesByCreateProperties = new();
|
||||||
MultiMap<AreaTriggerId, AreaTriggerAction> actionsByAreaTrigger = new();
|
MultiMap<AreaTriggerId, AreaTriggerAction> actionsByAreaTrigger = new();
|
||||||
|
|
||||||
// 0 1 2 3 4
|
// 0 1 2 3 4
|
||||||
SQLResult templateActions = DB.World.Query("SELECT AreaTriggerId, IsServerSide, ActionType, ActionParam, TargetType FROM `areatrigger_template_actions`");
|
SQLResult templateActions = DB.World.Query("SELECT AreaTriggerId, IsCustom, ActionType, ActionParam, TargetType FROM `areatrigger_template_actions`");
|
||||||
if (!templateActions.IsEmpty())
|
if (!templateActions.IsEmpty())
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
AreaTriggerId areaTriggerId = new(templateActions.Read<uint>(0), templateActions.Read<byte>(1) == 1);
|
AreaTriggerId areaTriggerId = new(templateActions.Read<uint>(0), templateActions.Read<bool>(1));
|
||||||
|
|
||||||
AreaTriggerAction action;
|
AreaTriggerAction action;
|
||||||
action.Param = templateActions.Read<uint>(3);
|
action.Param = templateActions.Read<uint>(3);
|
||||||
@@ -37,13 +37,13 @@ namespace Game.DataStorage
|
|||||||
|
|
||||||
if (action.ActionType >= AreaTriggerActionTypes.Max)
|
if (action.ActionType >= AreaTriggerActionTypes.Max)
|
||||||
{
|
{
|
||||||
Log.outError(LogFilter.Sql, $"Table `areatrigger_template_actions` has invalid ActionType ({action.ActionType}, IsServerSide: {areaTriggerId.IsServerSide}) for AreaTriggerId {areaTriggerId.Id} and Param {action.Param}");
|
Log.outError(LogFilter.Sql, $"Table `areatrigger_template_actions` has invalid ActionType ({action.ActionType}, for AreaTriggerId ({areaTriggerId.Id},{areaTriggerId.IsCustom}) and Param {action.Param}");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (action.TargetType >= AreaTriggerActionUserTypes.Max)
|
if (action.TargetType >= AreaTriggerActionUserTypes.Max)
|
||||||
{
|
{
|
||||||
Log.outError(LogFilter.Sql, $"Table `areatrigger_template_actions` has invalid TargetType ({action.TargetType}, IsServerSide: {areaTriggerId.IsServerSide}) for AreaTriggerId {areaTriggerId} and Param {action.Param}");
|
Log.outError(LogFilter.Sql, $"Table `areatrigger_template_actions` has invalid TargetType ({action.TargetType} for AreaTriggerId ({areaTriggerId.Id},{areaTriggerId.IsCustom}) and Param {action.Param}");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ namespace Game.DataStorage
|
|||||||
{
|
{
|
||||||
if (Global.ObjectMgr.GetWorldSafeLoc(action.Param) == null)
|
if (Global.ObjectMgr.GetWorldSafeLoc(action.Param) == null)
|
||||||
{
|
{
|
||||||
Log.outError(LogFilter.Sql, $"Table `areatrigger_template_actions` has invalid (Id: {areaTriggerId}, IsServerSide: {areaTriggerId.IsServerSide}) with TargetType=Teleport and Param ({action.Param}) not a valid world safe loc entry");
|
Log.outError(LogFilter.Sql, $"Table `areatrigger_template_actions` has invalid (Id: {areaTriggerId}, for AreaTriggerId ({areaTriggerId.Id},{areaTriggerId.IsCustom}) with TargetType=Teleport and Param ({action.Param}) not a valid world safe loc entry");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -66,20 +66,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 6
|
||||||
SQLResult vertices = DB.World.Query("SELECT AreaTriggerCreatePropertiesId, Idx, VerticeX, VerticeY, VerticeTargetX, VerticeTargetY FROM `areatrigger_create_properties_polygon_vertex` ORDER BY `AreaTriggerCreatePropertiesId`, `Idx`");
|
SQLResult vertices = DB.World.Query("SELECT AreaTriggerCreatePropertiesId, IsCustom, Idx, VerticeX, VerticeY, VerticeTargetX, VerticeTargetY FROM `areatrigger_create_properties_polygon_vertex` ORDER BY `AreaTriggerCreatePropertiesId`, `IsCustom`, `Idx`");
|
||||||
if (!vertices.IsEmpty())
|
if (!vertices.IsEmpty())
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
uint areaTriggerCreatePropertiesId = vertices.Read<uint>(0);
|
AreaTriggerId createPropertiesId = new (vertices.Read<uint>(0), vertices.Read<bool>(1));
|
||||||
|
|
||||||
verticesByCreateProperties.Add(areaTriggerCreatePropertiesId, new Vector2(vertices.Read<float>(2), vertices.Read<float>(3)));
|
verticesByCreateProperties.Add(createPropertiesId, new Vector2(vertices.Read<float>(3), vertices.Read<float>(4)));
|
||||||
|
|
||||||
if (!vertices.IsNull(4) && !vertices.IsNull(5))
|
if (!vertices.IsNull(5) && !vertices.IsNull(6))
|
||||||
verticesTargetByCreateProperties.Add(areaTriggerCreatePropertiesId, new Vector2(vertices.Read<float>(4), vertices.Read<float>(5)));
|
verticesTargetByCreateProperties.Add(createPropertiesId, new Vector2(vertices.Read<float>(5), vertices.Read<float>(6)));
|
||||||
else if (vertices.IsNull(4) != vertices.IsNull(5))
|
else if (vertices.IsNull(5) != vertices.IsNull(6))
|
||||||
Log.outError(LogFilter.Sql, $"Table `areatrigger_create_properties_polygon_vertex` has listed invalid target vertices (AreaTriggerCreatePropertiesId: {areaTriggerCreatePropertiesId}, Index: {vertices.Read<uint>(1)}).");
|
Log.outError(LogFilter.Sql, $"Table `areatrigger_create_properties_polygon_vertex` has listed invalid target vertices (AreaTriggerCreatePropertiesId: (Id: {createPropertiesId.Id}, IsCustom: {createPropertiesId.IsCustom}), Index: {vertices.Read<uint>(1)}).");
|
||||||
}
|
}
|
||||||
while (vertices.NextRow());
|
while (vertices.NextRow());
|
||||||
}
|
}
|
||||||
@@ -88,16 +88,14 @@ namespace Game.DataStorage
|
|||||||
Log.outInfo(LogFilter.ServerLoading, "Loaded 0 AreaTrigger polygon polygon vertices. DB table `areatrigger_create_properties_polygon_vertex` is empty.");
|
Log.outInfo(LogFilter.ServerLoading, "Loaded 0 AreaTrigger polygon polygon vertices. DB table `areatrigger_create_properties_polygon_vertex` is empty.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 0 1 2 3
|
// 0 1 2 3 4
|
||||||
SQLResult splines = DB.World.Query("SELECT AreaTriggerCreatePropertiesId, X, Y, Z FROM `areatrigger_create_properties_spline_point` ORDER BY `AreaTriggerCreatePropertiesId`, `Idx`");
|
SQLResult splines = DB.World.Query("SELECT AreaTriggerCreatePropertiesId, IsCustom, X, Y, Z FROM `areatrigger_create_properties_spline_point` ORDER BY `AreaTriggerCreatePropertiesId`, `IsCustom`, `Idx`");
|
||||||
if (!splines.IsEmpty())
|
if (!splines.IsEmpty())
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
uint areaTriggerCreatePropertiesId = splines.Read<uint>(0);
|
AreaTriggerId createPropertiesId = new(splines.Read<uint>(0), splines.Read<bool>(1));
|
||||||
Vector3 spline = new(splines.Read<float>(1), splines.Read<float>(2), splines.Read<float>(3));
|
splinesByCreateProperties.Add(createPropertiesId, new(splines.Read<float>(2), splines.Read<float>(3), splines.Read<float>(4)));
|
||||||
|
|
||||||
splinesByCreateProperties.Add(areaTriggerCreatePropertiesId, spline);
|
|
||||||
}
|
}
|
||||||
while (splines.NextRow());
|
while (splines.NextRow());
|
||||||
}
|
}
|
||||||
@@ -106,23 +104,15 @@ namespace Game.DataStorage
|
|||||||
Log.outInfo(LogFilter.ServerLoading, "Loaded 0 AreaTrigger splines. DB table `areatrigger_create_properties_spline_point` is empty.");
|
Log.outInfo(LogFilter.ServerLoading, "Loaded 0 AreaTrigger splines. DB table `areatrigger_create_properties_spline_point` is empty.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 0 1 2
|
// 0 1 2
|
||||||
SQLResult templates = DB.World.Query("SELECT Id, IsServerSide, Flags FROM `areatrigger_template`");
|
SQLResult templates = DB.World.Query("SELECT Id, IsCustom, Flags FROM `areatrigger_template`");
|
||||||
if (!templates.IsEmpty())
|
if (!templates.IsEmpty())
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
AreaTriggerTemplate areaTriggerTemplate = new();
|
AreaTriggerTemplate areaTriggerTemplate = new();
|
||||||
areaTriggerTemplate.Id = new(templates.Read<uint>(0), templates.Read<byte>(1) == 1);
|
areaTriggerTemplate.Id = new(templates.Read<uint>(0), templates.Read<bool>(1));
|
||||||
|
areaTriggerTemplate.Flags = (AreaTriggerFlag)templates.Read<uint>(2);
|
||||||
areaTriggerTemplate.Flags = (AreaTriggerFlags)templates.Read<uint>(2);
|
|
||||||
|
|
||||||
if (areaTriggerTemplate.Id.IsServerSide && areaTriggerTemplate.Flags != 0)
|
|
||||||
{
|
|
||||||
Log.outError(LogFilter.Sql, $"Table `areatrigger_template` has listed server-side areatrigger (Id: {areaTriggerTemplate.Id.Id}, IsServerSide: {areaTriggerTemplate.Id.IsServerSide}) with none-zero flags");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
areaTriggerTemplate.Actions = actionsByAreaTrigger[areaTriggerTemplate.Id];
|
areaTriggerTemplate.Actions = actionsByAreaTrigger[areaTriggerTemplate.Id];
|
||||||
|
|
||||||
_areaTriggerTemplateStore[areaTriggerTemplate.Id] = areaTriggerTemplate;
|
_areaTriggerTemplateStore[areaTriggerTemplate.Id] = areaTriggerTemplate;
|
||||||
@@ -130,31 +120,36 @@ namespace Game.DataStorage
|
|||||||
while (templates.NextRow());
|
while (templates.NextRow());
|
||||||
}
|
}
|
||||||
|
|
||||||
// 0 1 2 3 4 5 6 7 8 9 10
|
// 0 1 2 3 4
|
||||||
SQLResult areatriggerCreateProperties = DB.World.Query("SELECT Id, AreaTriggerId, MoveCurveId, ScaleCurveId, MorphCurveId, FacingCurveId, AnimId, AnimKitId, DecalPropertiesId, TimeToTarget, TimeToTargetScale, " +
|
SQLResult areatriggerCreateProperties = DB.World.Query("SELECT Id, IsCustom, AreaTriggerId, IsAreatriggerCustom, Flags, " +
|
||||||
//11 12 13 14 15 16 17 18 19 20
|
//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
|
||||||
"Shape, ShapeData0, ShapeData1, ShapeData2, ShapeData3, ShapeData4, ShapeData5, ShapeData6, ShapeData7, ScriptName FROM `areatrigger_create_properties`");
|
"Shape, ShapeData0, ShapeData1, ShapeData2, ShapeData3, ShapeData4, ShapeData5, ShapeData6, ShapeData7, ScriptName FROM `areatrigger_create_properties`");
|
||||||
if (!areatriggerCreateProperties.IsEmpty())
|
if (!areatriggerCreateProperties.IsEmpty())
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
AreaTriggerCreateProperties createProperties = new();
|
AreaTriggerCreateProperties createProperties = new();
|
||||||
createProperties.Id = areatriggerCreateProperties.Read<uint>(0);
|
AreaTriggerId createPropertiesId = new(areatriggerCreateProperties.Read<uint>(0), areatriggerCreateProperties.Read<bool>(1));
|
||||||
|
createProperties.Id = createPropertiesId;
|
||||||
|
|
||||||
uint areatriggerId = areatriggerCreateProperties.Read<uint>(1);
|
AreaTriggerId areaTriggerId = new(areatriggerCreateProperties.Read<uint>(2), areatriggerCreateProperties.Read<bool>(3));
|
||||||
createProperties.Template = GetAreaTriggerTemplate(new AreaTriggerId(areatriggerId, false));
|
createProperties.Template = GetAreaTriggerTemplate(areaTriggerId);
|
||||||
|
|
||||||
AreaTriggerTypes shape = (AreaTriggerTypes)areatriggerCreateProperties.Read<byte>(11);
|
createProperties.Flags = (AreaTriggerCreatePropertiesFlag)areatriggerCreateProperties.Read<uint>(4);
|
||||||
|
|
||||||
if (areatriggerId != 0 && createProperties.Template == null)
|
AreaTriggerShapeType shape = (AreaTriggerShapeType)areatriggerCreateProperties.Read<byte>(14);
|
||||||
|
|
||||||
|
if (areaTriggerId.Id != 0 && createProperties.Template == null)
|
||||||
{
|
{
|
||||||
Log.outError(LogFilter.Sql, $"Table `areatrigger_create_properties` reference invalid AreaTriggerId {areatriggerId} for AreaTriggerCreatePropertiesId {createProperties.Id}");
|
Log.outError(LogFilter.Sql, $"Table `areatrigger_create_properties` references invalid AreaTrigger (Id: {areaTriggerId.Id}, IsCustom: {areaTriggerId.IsCustom}) for AreaTriggerCreatePropertiesId (Id: {createPropertiesId.Id}, IsCustom: {createPropertiesId.IsCustom})");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shape >= AreaTriggerTypes.Max)
|
if (shape >= AreaTriggerShapeType.Max)
|
||||||
{
|
{
|
||||||
Log.outError(LogFilter.Sql, $"Table `areatrigger_create_properties` has listed areatrigger create properties {createProperties.Id} with invalid shape {shape}.");
|
Log.outError(LogFilter.Sql, $"Table `areatrigger_create_properties` has listed AreaTriggerCreatePropertiesId (Id: {createPropertiesId.Id}, IsCustom: {createPropertiesId.IsCustom}) with invalid shape {shape}.");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,35 +157,35 @@ namespace Game.DataStorage
|
|||||||
{
|
{
|
||||||
if (value != 0 && !CliDB.CurveStorage.ContainsKey(value))
|
if (value != 0 && !CliDB.CurveStorage.ContainsKey(value))
|
||||||
{
|
{
|
||||||
Log.outError(LogFilter.Sql, $"Table `areatrigger_create_properties` has listed areatrigger (AreaTriggerCreatePropertiesId: {createProperties.Id}, Id: {areatriggerId}) with invalid Curve ({value}), set to 0!");
|
Log.outError(LogFilter.Sql, $"Table `areatrigger_create_properties` has listed AreaTrigger (Id: {areaTriggerId.Id}, IsCustom: {areaTriggerId.IsCustom}) for AreaTriggerCreatePropertiesId (Id: {createPropertiesId.Id}, IsCustom: {createPropertiesId.IsCustom}) with invalid Curve ({value}), set to 0!");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
createProperties.MoveCurveId = ValidateAndSetCurve(areatriggerCreateProperties.Read<uint>(2));
|
createProperties.MoveCurveId = ValidateAndSetCurve(areatriggerCreateProperties.Read<uint>(5));
|
||||||
createProperties.ScaleCurveId = ValidateAndSetCurve(areatriggerCreateProperties.Read<uint>(3));
|
createProperties.ScaleCurveId = ValidateAndSetCurve(areatriggerCreateProperties.Read<uint>(6));
|
||||||
createProperties.MorphCurveId = ValidateAndSetCurve(areatriggerCreateProperties.Read<uint>(4));
|
createProperties.MorphCurveId = ValidateAndSetCurve(areatriggerCreateProperties.Read<uint>(7));
|
||||||
createProperties.FacingCurveId = ValidateAndSetCurve(areatriggerCreateProperties.Read<uint>(5));
|
createProperties.FacingCurveId = ValidateAndSetCurve(areatriggerCreateProperties.Read<uint>(8));
|
||||||
|
|
||||||
createProperties.AnimId = areatriggerCreateProperties.Read<int>(6);
|
createProperties.AnimId = areatriggerCreateProperties.Read<int>(9);
|
||||||
createProperties.AnimKitId = areatriggerCreateProperties.Read<uint>(7);
|
createProperties.AnimKitId = areatriggerCreateProperties.Read<uint>(10);
|
||||||
createProperties.DecalPropertiesId = areatriggerCreateProperties.Read<uint>(8);
|
createProperties.DecalPropertiesId = areatriggerCreateProperties.Read<uint>(11);
|
||||||
|
|
||||||
createProperties.TimeToTarget = areatriggerCreateProperties.Read<uint>(9);
|
createProperties.TimeToTarget = areatriggerCreateProperties.Read<uint>(12);
|
||||||
createProperties.TimeToTargetScale = areatriggerCreateProperties.Read<uint>(10);
|
createProperties.TimeToTargetScale = areatriggerCreateProperties.Read<uint>(13);
|
||||||
|
|
||||||
createProperties.Shape.TriggerType = shape;
|
createProperties.Shape.TriggerType = shape;
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
for (byte i = 0; i < SharedConst.MaxAreatriggerEntityData; ++i)
|
for (byte i = 0; i < SharedConst.MaxAreatriggerEntityData; ++i)
|
||||||
createProperties.Shape.DefaultDatas.Data[i] = areatriggerCreateProperties.Read<float>(12 + i);
|
createProperties.Shape.DefaultDatas.Data[i] = areatriggerCreateProperties.Read<float>(15 + i);
|
||||||
}
|
}
|
||||||
|
|
||||||
createProperties.ScriptId = Global.ObjectMgr.GetScriptId(areatriggerCreateProperties.Read<string>(20));
|
createProperties.ScriptId = Global.ObjectMgr.GetScriptId(areatriggerCreateProperties.Read<string>(23));
|
||||||
|
|
||||||
if (shape == AreaTriggerTypes.Polygon)
|
if (shape == AreaTriggerShapeType.Polygon)
|
||||||
{
|
{
|
||||||
if (createProperties.Shape.PolygonDatas.Height <= 0.0f)
|
if (createProperties.Shape.PolygonDatas.Height <= 0.0f)
|
||||||
{
|
{
|
||||||
@@ -200,12 +195,12 @@ namespace Game.DataStorage
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
createProperties.PolygonVertices = verticesByCreateProperties[createProperties.Id];
|
createProperties.Shape.PolygonVertices = verticesByCreateProperties[createProperties.Id];
|
||||||
createProperties.PolygonVerticesTarget = verticesTargetByCreateProperties[createProperties.Id];
|
createProperties.Shape.PolygonVerticesTarget = verticesTargetByCreateProperties[createProperties.Id];
|
||||||
if (!createProperties.PolygonVerticesTarget.Empty() && createProperties.PolygonVertices.Count != createProperties.PolygonVerticesTarget.Count)
|
if (!createProperties.Shape.PolygonVerticesTarget.Empty() && createProperties.Shape.PolygonVertices.Count != createProperties.Shape.PolygonVerticesTarget.Count)
|
||||||
{
|
{
|
||||||
Log.outError(LogFilter.Sql, $"Table `areatrigger_create_properties_polygon_vertex` has invalid target vertices, either all or none vertices must have a corresponding target vertex (AreaTriggerCreatePropertiesId: {createProperties.Id}).");
|
Log.outError(LogFilter.Sql, $"Table `areatrigger_create_properties_polygon_vertex` has invalid target vertices, either all or none vertices must have a corresponding target vertex (AreaTriggerCreatePropertiesId: (Id: {createPropertiesId.Id}, IsCustom: {createPropertiesId.IsCustom})).");
|
||||||
createProperties.PolygonVerticesTarget.Clear();
|
createProperties.Shape.PolygonVerticesTarget.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
createProperties.SplinePoints = splinesByCreateProperties[createProperties.Id];
|
createProperties.SplinePoints = splinesByCreateProperties[createProperties.Id];
|
||||||
@@ -219,54 +214,44 @@ namespace Game.DataStorage
|
|||||||
Log.outInfo(LogFilter.ServerLoading, "Loaded 0 AreaTrigger create properties. DB table `areatrigger_create_properties` is empty.");
|
Log.outInfo(LogFilter.ServerLoading, "Loaded 0 AreaTrigger create properties. DB table `areatrigger_create_properties` is empty.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 0 1 2 3 4 5 6 7
|
// 0 1 2 3 4 5 6 7 8
|
||||||
SQLResult circularMovementInfos = DB.World.Query("SELECT AreaTriggerCreatePropertiesId, StartDelay, CircleRadius, BlendFromRadius, InitialAngle, ZOffset, CounterClockwise, CanLoop FROM `areatrigger_create_properties_orbit`");
|
SQLResult circularMovementInfos = DB.World.Query("SELECT AreaTriggerCreatePropertiesId, IsCustom, StartDelay, CircleRadius, BlendFromRadius, InitialAngle, ZOffset, CounterClockwise, CanLoop FROM `areatrigger_create_properties_orbit`");
|
||||||
if (!circularMovementInfos.IsEmpty())
|
if (!circularMovementInfos.IsEmpty())
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
uint areaTriggerCreatePropertiesId = circularMovementInfos.Read<uint>(0);
|
AreaTriggerId createPropertiesId = new(circularMovementInfos.Read<uint>(0), circularMovementInfos.Read<bool>(1));
|
||||||
|
|
||||||
var createProperties = _areaTriggerCreateProperties.LookupByKey(areaTriggerCreatePropertiesId);
|
var createProperties = _areaTriggerCreateProperties.LookupByKey(createPropertiesId);
|
||||||
if (createProperties == null)
|
if (createProperties == null)
|
||||||
{
|
{
|
||||||
Log.outError(LogFilter.Sql, $"Table `areatrigger_create_properties_orbit` reference invalid AreaTriggerCreatePropertiesId {areaTriggerCreatePropertiesId}");
|
Log.outError(LogFilter.Sql, $"Table `areatrigger_create_properties_orbit` reference invalid AreaTriggerCreatePropertiesId: (Id: {createPropertiesId.Id}, IsCustom: {createPropertiesId.IsCustom})");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
AreaTriggerOrbitInfo orbitInfo = new();
|
AreaTriggerOrbitInfo orbitInfo = new();
|
||||||
|
|
||||||
orbitInfo.StartDelay = circularMovementInfos.Read<uint>(1);
|
orbitInfo.StartDelay = circularMovementInfos.Read<uint>(2);
|
||||||
orbitInfo.Radius = circularMovementInfos.Read<float>(2);
|
|
||||||
if (!float.IsFinite(orbitInfo.Radius))
|
float ValidateAndSetFloat(float value)
|
||||||
{
|
{
|
||||||
Log.outError(LogFilter.Sql, $"Table `areatrigger_create_properties_orbit` has listed areatrigger (AreaTriggerCreatePropertiesId: {areaTriggerCreatePropertiesId}) with invalid Radius ({orbitInfo.Radius}), set to 0!");
|
if (!float.IsFinite(value))
|
||||||
orbitInfo.Radius = 0.0f;
|
{
|
||||||
|
Log.outError(LogFilter.Sql, $"Table `areatrigger_create_properties_orbit` has listed areatrigger (AreaTriggerCreatePropertiesId: {createPropertiesId.Id}, IsCustom: {createPropertiesId.IsCustom}) with invalid Float ({value}), set to 0!");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
orbitInfo.BlendFromRadius = circularMovementInfos.Read<float>(3);
|
|
||||||
if (!float.IsFinite(orbitInfo.BlendFromRadius))
|
|
||||||
{
|
|
||||||
Log.outError(LogFilter.Sql, $"Table `areatrigger_create_properties_orbit` has listed areatrigger (AreaTriggerCreatePropertiesId: {areaTriggerCreatePropertiesId}) with invalid BlendFromRadius ({orbitInfo.BlendFromRadius}), set to 0!");
|
|
||||||
orbitInfo.BlendFromRadius = 0.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
orbitInfo.InitialAngle = circularMovementInfos.Read<float>(4);
|
orbitInfo.Radius = ValidateAndSetFloat(circularMovementInfos.Read<float>(3));
|
||||||
if (!float.IsFinite(orbitInfo.InitialAngle))
|
orbitInfo.BlendFromRadius = circularMovementInfos.Read<float>(4);
|
||||||
{
|
orbitInfo.InitialAngle = circularMovementInfos.Read<float>(5);
|
||||||
Log.outError(LogFilter.Sql, $"Table `areatrigger_create_properties_orbit` has listed areatrigger (AreaTriggerCreatePropertiesId: {areaTriggerCreatePropertiesId}) with invalid InitialAngle ({orbitInfo.InitialAngle}), set to 0!");
|
orbitInfo.ZOffset = circularMovementInfos.Read<float>(6);
|
||||||
orbitInfo.InitialAngle = 0.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
orbitInfo.ZOffset = circularMovementInfos.Read<float>(5);
|
orbitInfo.CounterClockwise = circularMovementInfos.Read<bool>(7);
|
||||||
if (!float.IsFinite(orbitInfo.ZOffset))
|
orbitInfo.CanLoop = circularMovementInfos.Read<bool>(8);
|
||||||
{
|
|
||||||
Log.outError(LogFilter.Sql, $"Table `spell_areatrigger_circular` has listed areatrigger (MiscId: {areaTriggerCreatePropertiesId}) with invalid ZOffset ({orbitInfo.ZOffset}), set to 0!");
|
|
||||||
orbitInfo.ZOffset = 0.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
orbitInfo.CounterClockwise = circularMovementInfos.Read<bool>(6);
|
|
||||||
orbitInfo.CanLoop = circularMovementInfos.Read<bool>(7);
|
|
||||||
|
|
||||||
createProperties.OrbitInfo = orbitInfo;
|
createProperties.OrbitInfo = orbitInfo;
|
||||||
}
|
}
|
||||||
@@ -289,34 +274,56 @@ namespace Game.DataStorage
|
|||||||
|
|
||||||
uint oldMSTime = Time.GetMSTime();
|
uint oldMSTime = Time.GetMSTime();
|
||||||
// Load area trigger positions (to put them on the server)
|
// Load area trigger positions (to put them on the server)
|
||||||
// 0 1 2 3 4 5 6 7 8 9 10 11
|
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13
|
||||||
SQLResult result = DB.World.Query("SELECT SpawnId, AreaTriggerId, IsServerSide, MapId, SpawnDifficulties, PosX, PosY, PosZ, Orientation, PhaseUseFlags, PhaseId, PhaseGroup, " +
|
SQLResult result = DB.World.Query("SELECT SpawnId, AreaTriggerCreatePropertiesId, IsCustom, MapId, SpawnDifficulties, PosX, PosY, PosZ, Orientation, PhaseUseFlags, PhaseId, PhaseGroup, SpellForVisuals, ScriptName FROM `areatrigger`");
|
||||||
//12 13 14 15 16 17 18 19 20 21 22
|
|
||||||
"Shape, ShapeData0, ShapeData1, ShapeData2, ShapeData3, ShapeData4, ShapeData5, ShapeData6, ShapeData7, SpellForVisuals, ScriptName FROM `areatrigger`");
|
|
||||||
if (!result.IsEmpty())
|
if (!result.IsEmpty())
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
ulong spawnId = result.Read<ulong>(0);
|
ulong spawnId = result.Read<ulong>(0);
|
||||||
AreaTriggerId areaTriggerId = new(result.Read<uint>(1), result.Read<byte>(2) == 1);
|
AreaTriggerId createPropertiesId = new(result.Read<uint>(1), result.Read<bool>(2));
|
||||||
WorldLocation location = new(result.Read<uint>(3), result.Read<float>(5), result.Read<float>(6), result.Read<float>(7), result.Read<float>(8));
|
WorldLocation location = new(result.Read<uint>(3), result.Read<float>(5), result.Read<float>(6), result.Read<float>(7), result.Read<float>(8));
|
||||||
AreaTriggerTypes shape = (AreaTriggerTypes)result.Read<byte>(12);
|
|
||||||
|
|
||||||
if (GetAreaTriggerTemplate(areaTriggerId) == null)
|
AreaTriggerCreateProperties createProperties = GetAreaTriggerCreateProperties(createPropertiesId);
|
||||||
|
if (createProperties == null)
|
||||||
{
|
{
|
||||||
Log.outError(LogFilter.Sql, $"Table `areatrigger` has listed areatrigger that doesn't exist: Id: {areaTriggerId.Id}, IsServerSide: {areaTriggerId.IsServerSide} for SpawnId {spawnId}");
|
Log.outError(LogFilter.Sql, $"Table `areatrigger` has listed AreaTriggerCreatePropertiesId (Id: {createPropertiesId.Id}, IsCustom: {createPropertiesId.IsCustom}) that doesn't exist for SpawnId {spawnId}");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (createProperties.Flags != AreaTriggerCreatePropertiesFlag.None)
|
||||||
|
{
|
||||||
|
Log.outError(LogFilter.Sql, $"Table `areatrigger` has listed AreaTriggerCreatePropertiesId (Id: {createPropertiesId.Id}, IsCustom: {createPropertiesId.IsCustom}) with non - zero flags");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (createProperties.ScaleCurveId != 0 || createProperties.MorphCurveId != 0 || createProperties.FacingCurveId != 0 || createProperties.MoveCurveId != 0)
|
||||||
|
{
|
||||||
|
Log.outError(LogFilter.Sql, $"Table `areatrigger` has listed AreaTriggerCreatePropertiesId (Id: {createPropertiesId.Id}, IsCustom: {createPropertiesId.IsCustom}) with curve values");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (createProperties.TimeToTarget != 0 || createProperties.TimeToTargetScale != 0 || createProperties.FacingCurveId != 0 || createProperties.MoveCurveId != 0)
|
||||||
|
{
|
||||||
|
Log.outError(LogFilter.Sql, $"Table `areatrigger` has listed AreaTriggerCreatePropertiesId (Id: {createPropertiesId.Id}, IsCustom: {createPropertiesId.IsCustom}) with time to target values");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (createProperties.OrbitInfo != null)
|
||||||
|
{
|
||||||
|
Log.outError(LogFilter.Sql, $"Table `areatrigger` has listed AreaTriggerCreatePropertiesId (Id: {createPropertiesId.Id}, IsCustom: {createPropertiesId.IsCustom}) with orbit info");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (createProperties.HasSplines())
|
||||||
|
{
|
||||||
|
Log.outError(LogFilter.Sql, $"Table `areatrigger` has listed AreaTriggerCreatePropertiesId (Id: {createPropertiesId.Id}, IsCustom: {createPropertiesId.IsCustom}) with splines");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!GridDefines.IsValidMapCoord(location))
|
if (!GridDefines.IsValidMapCoord(location))
|
||||||
{
|
{
|
||||||
Log.outError(LogFilter.Sql, $"Table `areatrigger` has listed an invalid position: SpawnId: {spawnId}, MapId: {location.GetMapId()}, Position: {location}");
|
Log.outError(LogFilter.Sql, $"Table `areatrigger` has listed an invalid position: SpawnId: {spawnId}, MapId {location.GetMapId()}, Position {location}");
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (shape >= AreaTriggerTypes.Max)
|
|
||||||
{
|
|
||||||
Log.outError(LogFilter.Sql, $"Table `areatrigger` has listed areatrigger SpawnId: {spawnId} with invalid shape {shape}.");
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -330,31 +337,24 @@ namespace Game.DataStorage
|
|||||||
AreaTriggerSpawn spawn = new();
|
AreaTriggerSpawn spawn = new();
|
||||||
spawn.SpawnId = spawnId;
|
spawn.SpawnId = spawnId;
|
||||||
spawn.MapId = location.GetMapId();
|
spawn.MapId = location.GetMapId();
|
||||||
spawn.TriggerId = areaTriggerId;
|
spawn.Id = createPropertiesId;
|
||||||
spawn.SpawnPoint = new Position(location);
|
spawn.SpawnPoint = new Position(location);
|
||||||
|
|
||||||
spawn.PhaseUseFlags = (PhaseUseFlagsValues)result.Read<byte>(9);
|
spawn.PhaseUseFlags = (PhaseUseFlagsValues)result.Read<byte>(9);
|
||||||
spawn.PhaseId = result.Read<uint>(10);
|
spawn.PhaseId = result.Read<uint>(10);
|
||||||
spawn.PhaseGroup = result.Read<uint>(11);
|
spawn.PhaseGroup = result.Read<uint>(11);
|
||||||
|
|
||||||
spawn.Shape.TriggerType = shape;
|
if (!result.IsNull(12))
|
||||||
unsafe
|
|
||||||
{
|
{
|
||||||
for (var i = 0; i < SharedConst.MaxAreatriggerEntityData; ++i)
|
spawn.SpellForVisuals = result.Read<uint>(12);
|
||||||
spawn.Shape.DefaultDatas.Data[i] = result.Read<float>(13 + i);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!result.IsNull(21))
|
|
||||||
{
|
|
||||||
spawn.SpellForVisuals = result.Read<uint>(21);
|
|
||||||
if (!Global.SpellMgr.HasSpellInfo(spawn.SpellForVisuals.Value, Difficulty.None))
|
if (!Global.SpellMgr.HasSpellInfo(spawn.SpellForVisuals.Value, Difficulty.None))
|
||||||
{
|
{
|
||||||
Log.outError(LogFilter.Sql, $"Table `areatrigger` has listed areatrigger SpawnId: {spawnId} with invalid SpellForVisual {spawn.SpellForVisuals}, set to none.");
|
Log.outError(LogFilter.Sql, $"Table `areatrigger` has areatrigger (GUID: {spawnId}) with invalid SpellForVisual {spawn.SpellForVisuals}, set to none.");
|
||||||
spawn.SpellForVisuals = null;
|
spawn.SpellForVisuals = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
spawn.ScriptId = Global.ObjectMgr.GetScriptId(result.Read<string>(22));
|
spawn.ScriptId = Global.ObjectMgr.GetScriptId(result.Read<string>(13));
|
||||||
spawn.spawnGroupData = Global.ObjectMgr.GetLegacySpawnGroup();
|
spawn.spawnGroupData = Global.ObjectMgr.GetLegacySpawnGroup();
|
||||||
|
|
||||||
// Add the trigger to a map::cell map, which is later used by GridLoader to query
|
// Add the trigger to a map::cell map, which is later used by GridLoader to query
|
||||||
@@ -384,9 +384,9 @@ namespace Game.DataStorage
|
|||||||
return _areaTriggerTemplateStore.LookupByKey(areaTriggerId);
|
return _areaTriggerTemplateStore.LookupByKey(areaTriggerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AreaTriggerCreateProperties GetAreaTriggerCreateProperties(uint spellMiscValue)
|
public AreaTriggerCreateProperties GetAreaTriggerCreateProperties(AreaTriggerId areaTriggerCreatePropertiesId)
|
||||||
{
|
{
|
||||||
return _areaTriggerCreateProperties.LookupByKey(spellMiscValue);
|
return _areaTriggerCreateProperties.LookupByKey(areaTriggerCreatePropertiesId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SortedSet<ulong> GetAreaTriggersForMapAndCell(uint mapId, Difficulty difficulty, uint cellId)
|
public SortedSet<ulong> GetAreaTriggersForMapAndCell(uint mapId, Difficulty difficulty, uint cellId)
|
||||||
@@ -406,6 +406,6 @@ namespace Game.DataStorage
|
|||||||
Dictionary<(uint, Difficulty), Dictionary<uint, SortedSet<ulong>>> _areaTriggerSpawnsByLocation = new();
|
Dictionary<(uint, Difficulty), Dictionary<uint, SortedSet<ulong>>> _areaTriggerSpawnsByLocation = new();
|
||||||
Dictionary<ulong, AreaTriggerSpawn> _areaTriggerSpawnsBySpawnId = new();
|
Dictionary<ulong, AreaTriggerSpawn> _areaTriggerSpawnsBySpawnId = new();
|
||||||
Dictionary<AreaTriggerId, AreaTriggerTemplate> _areaTriggerTemplateStore = new();
|
Dictionary<AreaTriggerId, AreaTriggerTemplate> _areaTriggerTemplateStore = new();
|
||||||
Dictionary<uint, AreaTriggerCreateProperties> _areaTriggerCreateProperties = new();
|
Dictionary<AreaTriggerId, AreaTriggerCreateProperties> _areaTriggerCreateProperties = new();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,31 +69,31 @@ namespace Game.Entities
|
|||||||
HandleUnitEnterExit(new List<Unit>());
|
HandleUnitEnterExit(new List<Unit>());
|
||||||
|
|
||||||
base.RemoveFromWorld();
|
base.RemoveFromWorld();
|
||||||
if (_spawnId != 0)
|
if (IsStaticSpawn())
|
||||||
GetMap().GetAreaTriggerBySpawnIdStore().Remove(_spawnId, this);
|
GetMap().GetAreaTriggerBySpawnIdStore().Remove(_spawnId, this);
|
||||||
|
|
||||||
GetMap().GetObjectsStore().Remove(GetGUID());
|
GetMap().GetObjectsStore().Remove(GetGUID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Create(uint areaTriggerCreatePropertiesId, Unit caster, Unit target, SpellInfo spellInfo, Position pos, int duration, SpellCastVisualField spellVisual, Spell spell, AuraEffect aurEff)
|
bool Create(AreaTriggerId areaTriggerCreatePropertiesId, Map map, Position pos, int duration, AreaTriggerSpawn spawnData = null, Unit caster = null, Unit target = null, SpellCastVisual spellVisual = default, SpellInfo spellInfo = null, Spell spell = null, AuraEffect aurEff = null)
|
||||||
{
|
{
|
||||||
_targetGuid = target != null ? target.GetGUID() : ObjectGuid.Empty;
|
_targetGuid = target != null ? target.GetGUID() : ObjectGuid.Empty;
|
||||||
_aurEff = aurEff;
|
_aurEff = aurEff;
|
||||||
|
|
||||||
SetMap(caster.GetMap());
|
SetMap(map);
|
||||||
Relocate(pos);
|
Relocate(pos);
|
||||||
RelocateStationaryPosition(pos);
|
RelocateStationaryPosition(pos);
|
||||||
if (!IsPositionValid())
|
if (!IsPositionValid())
|
||||||
{
|
{
|
||||||
Log.outError(LogFilter.AreaTrigger, $"AreaTrigger (areaTriggerCreatePropertiesId: {areaTriggerCreatePropertiesId}) not created. Invalid coordinates (X: {GetPositionX()} Y: {GetPositionY()})");
|
Log.outError(LogFilter.AreaTrigger, $"AreaTrigger (AreaTriggerCreatePropertiesId: (Id: {areaTriggerCreatePropertiesId.Id}, IsCustom: {areaTriggerCreatePropertiesId.IsCustom})) not created. Invalid coordinates (X: {GetPositionX()} Y: {GetPositionY()})");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
_areaTriggerCreateProperties = Global.AreaTriggerDataStorage.GetAreaTriggerCreateProperties(areaTriggerCreatePropertiesId);
|
_areaTriggerCreateProperties = Global.AreaTriggerDataStorage.GetAreaTriggerCreateProperties(areaTriggerCreatePropertiesId);
|
||||||
if (_areaTriggerCreateProperties == null)
|
if (_areaTriggerCreateProperties == null)
|
||||||
{
|
{
|
||||||
Log.outError(LogFilter.AreaTrigger, $"AreaTrigger (areaTriggerCreatePropertiesId {areaTriggerCreatePropertiesId}) not created. Invalid areatrigger create properties id ({areaTriggerCreatePropertiesId})");
|
Log.outError(LogFilter.AreaTrigger, $"AreaTrigger (AreaTriggerCreatePropertiesId: (Id: {areaTriggerCreatePropertiesId.Id}, IsCustom: {areaTriggerCreatePropertiesId.IsCustom})) not created. Invalid areatrigger create properties id");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,64 +101,77 @@ namespace Game.Entities
|
|||||||
|
|
||||||
_areaTriggerTemplate = _areaTriggerCreateProperties.Template;
|
_areaTriggerTemplate = _areaTriggerCreateProperties.Template;
|
||||||
|
|
||||||
_Create(ObjectGuid.Create(HighGuid.AreaTrigger, GetMapId(), GetTemplate() != null ? GetTemplate().Id.Id : 0, caster.GetMap().GenerateLowGuid(HighGuid.AreaTrigger)));
|
_Create(ObjectGuid.Create(HighGuid.AreaTrigger, GetMapId(), GetTemplate() != null ? GetTemplate().Id.Id : 0, GetMap().GenerateLowGuid(HighGuid.AreaTrigger)));
|
||||||
|
|
||||||
if (GetTemplate() != null)
|
if (GetTemplate() != null)
|
||||||
SetEntry(GetTemplate().Id.Id);
|
SetEntry(GetTemplate().Id.Id);
|
||||||
|
|
||||||
SetDuration(duration);
|
|
||||||
|
|
||||||
SetObjectScale(1.0f);
|
SetObjectScale(1.0f);
|
||||||
|
SetDuration(duration);
|
||||||
|
|
||||||
_shape = GetCreateProperties().Shape;
|
_shape = GetCreateProperties().Shape;
|
||||||
|
|
||||||
var areaTriggerData = m_values.ModifyValue(m_areaTriggerData);
|
var areaTriggerData = m_values.ModifyValue(m_areaTriggerData);
|
||||||
SetUpdateFieldValue(areaTriggerData.ModifyValue(m_areaTriggerData.Caster), caster.GetGUID());
|
if (caster != null)
|
||||||
|
SetUpdateFieldValue(areaTriggerData.ModifyValue(m_areaTriggerData.Caster), caster.GetGUID());
|
||||||
if (spell != null)
|
if (spell != null)
|
||||||
SetUpdateFieldValue(areaTriggerData.ModifyValue(m_areaTriggerData.CreatingEffectGUID), spell.m_castId);
|
SetUpdateFieldValue(areaTriggerData.ModifyValue(m_areaTriggerData.CreatingEffectGUID), spell.m_castId);
|
||||||
|
|
||||||
SetUpdateFieldValue(areaTriggerData.ModifyValue(m_areaTriggerData.SpellID), spellInfo.Id);
|
if (spellInfo != null && !IsStaticSpawn())
|
||||||
SetUpdateFieldValue(areaTriggerData.ModifyValue(m_areaTriggerData.SpellForVisuals), spellInfo.Id);
|
SetUpdateFieldValue(areaTriggerData.ModifyValue(m_areaTriggerData.SpellID), spellInfo.Id);
|
||||||
|
if (spellInfo != null)
|
||||||
|
SetUpdateFieldValue(areaTriggerData.ModifyValue(m_areaTriggerData.SpellForVisuals), spellInfo.Id);
|
||||||
|
|
||||||
SpellCastVisualField spellCastVisual = areaTriggerData.ModifyValue(m_areaTriggerData.SpellVisual);
|
SpellCastVisualField spellCastVisual = areaTriggerData.ModifyValue(m_areaTriggerData.SpellVisual);
|
||||||
SetUpdateFieldValue(ref spellCastVisual.SpellXSpellVisualID, spellVisual.SpellXSpellVisualID);
|
SetUpdateFieldValue(ref spellCastVisual.SpellXSpellVisualID, spellVisual.SpellXSpellVisualID);
|
||||||
SetUpdateFieldValue(ref spellCastVisual.ScriptVisualID, spellVisual.ScriptVisualID);
|
SetUpdateFieldValue(ref spellCastVisual.ScriptVisualID, spellVisual.ScriptVisualID);
|
||||||
|
|
||||||
SetUpdateFieldValue(areaTriggerData.ModifyValue(m_areaTriggerData.TimeToTargetScale), GetCreateProperties().TimeToTargetScale != 0 ? GetCreateProperties().TimeToTargetScale : m_areaTriggerData.Duration);
|
if (!IsStaticSpawn())
|
||||||
SetUpdateFieldValue(areaTriggerData.ModifyValue(m_areaTriggerData.BoundsRadius2D), GetCreateProperties().GetMaxSearchRadius());
|
SetUpdateFieldValue(areaTriggerData.ModifyValue(m_areaTriggerData.TimeToTargetScale), GetCreateProperties().TimeToTargetScale != 0 ? GetCreateProperties().TimeToTargetScale : m_areaTriggerData.Duration);
|
||||||
|
SetUpdateFieldValue(areaTriggerData.ModifyValue(m_areaTriggerData.BoundsRadius2D), GetCreateProperties().Shape.GetMaxSearchRadius());
|
||||||
SetUpdateFieldValue(areaTriggerData.ModifyValue(m_areaTriggerData.DecalPropertiesID), GetCreateProperties().DecalPropertiesId);
|
SetUpdateFieldValue(areaTriggerData.ModifyValue(m_areaTriggerData.DecalPropertiesID), GetCreateProperties().DecalPropertiesId);
|
||||||
|
if (IsServerSide())
|
||||||
|
SetUpdateFieldValue(areaTriggerData.ModifyValue(m_areaTriggerData.DecalPropertiesID), 24u); // Blue decal, for .debug areatrigger visibility
|
||||||
|
|
||||||
SetScaleCurve(areaTriggerData.ModifyValue(m_areaTriggerData.ExtraScaleCurve), GetCreateProperties().ExtraScale);
|
AreaTriggerScaleCurveTemplate extraScaleCurve = IsStaticSpawn() ? new AreaTriggerScaleCurveTemplate() : GetCreateProperties().ExtraScale;
|
||||||
|
SetScaleCurve(areaTriggerData.ModifyValue(m_areaTriggerData.ExtraScaleCurve), extraScaleCurve);
|
||||||
|
|
||||||
Player modOwner = caster.GetSpellModOwner();
|
if (caster != null)
|
||||||
if (modOwner != null)
|
|
||||||
{
|
{
|
||||||
float multiplier = 1.0f;
|
Player modOwner = caster.GetSpellModOwner();
|
||||||
int flat = 0;
|
if (modOwner != null)
|
||||||
modOwner.GetSpellModValues(spellInfo, SpellModOp.Radius, spell, (float)m_areaTriggerData.BoundsRadius2D, ref flat, ref multiplier);
|
|
||||||
if (multiplier != 1.0f)
|
|
||||||
{
|
{
|
||||||
AreaTriggerScaleCurveTemplate overrideScale = new();
|
float multiplier = 1.0f;
|
||||||
overrideScale.Curve = multiplier;
|
int flat = 0;
|
||||||
SetScaleCurve(areaTriggerData.ModifyValue(m_areaTriggerData.OverrideScaleCurve), overrideScale);
|
modOwner.GetSpellModValues(spellInfo, SpellModOp.Radius, spell, (float)m_areaTriggerData.BoundsRadius2D, ref flat, ref multiplier);
|
||||||
|
if (multiplier != 1.0f)
|
||||||
|
{
|
||||||
|
AreaTriggerScaleCurveTemplate overrideScale = new();
|
||||||
|
overrideScale.Curve = multiplier;
|
||||||
|
SetScaleCurve(areaTriggerData.ModifyValue(m_areaTriggerData.OverrideScaleCurve), overrideScale);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VisualAnim visualAnim = areaTriggerData.ModifyValue(m_areaTriggerData.VisualAnim);
|
VisualAnim visualAnim = areaTriggerData.ModifyValue(m_areaTriggerData.VisualAnim);
|
||||||
SetUpdateFieldValue(visualAnim.ModifyValue(visualAnim.AnimationDataID), GetCreateProperties().AnimId);
|
SetUpdateFieldValue(visualAnim.ModifyValue(visualAnim.AnimationDataID), GetCreateProperties().AnimId);
|
||||||
SetUpdateFieldValue(visualAnim.ModifyValue(visualAnim.AnimKitID), GetCreateProperties().AnimKitId);
|
SetUpdateFieldValue(visualAnim.ModifyValue(visualAnim.AnimKitID), GetCreateProperties().AnimKitId);
|
||||||
if (GetTemplate() != null && GetTemplate().HasFlag(AreaTriggerFlags.Unk3))
|
if (GetCreateProperties() != null && GetCreateProperties().Flags.HasFlag(AreaTriggerCreatePropertiesFlag.Unk3))
|
||||||
SetUpdateFieldValue(visualAnim.ModifyValue(visualAnim.Field_C), true);
|
SetUpdateFieldValue(visualAnim.ModifyValue(visualAnim.Field_C), true);
|
||||||
|
|
||||||
PhasingHandler.InheritPhaseShift(this, caster);
|
if (caster != null)
|
||||||
|
PhasingHandler.InheritPhaseShift(this, caster);
|
||||||
if (target != null && GetTemplate() != null && GetTemplate().HasFlag(AreaTriggerFlags.HasAttached))
|
else if (IsStaticSpawn() && spawnData != null)
|
||||||
{
|
{
|
||||||
m_movementInfo.transport.guid = target.GetGUID();
|
if (spawnData.PhaseUseFlags != 0 || spawnData.PhaseId != 0 || spawnData.PhaseGroup != 0)
|
||||||
|
PhasingHandler.InitDbPhaseShift(GetPhaseShift(), spawnData.PhaseUseFlags, spawnData.PhaseId, spawnData.PhaseGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdatePositionData();
|
if (target != null && GetCreateProperties() != null && GetCreateProperties().Flags.HasFlag(AreaTriggerCreatePropertiesFlag.HasAttached))
|
||||||
SetZoneScript();
|
m_movementInfo.transport.guid = target.GetGUID();
|
||||||
|
|
||||||
|
if (!IsStaticSpawn())
|
||||||
|
UpdatePositionData();
|
||||||
|
|
||||||
UpdateShape();
|
UpdateShape();
|
||||||
|
|
||||||
@@ -167,7 +180,7 @@ namespace Game.Entities
|
|||||||
if (GetCreateProperties().OrbitInfo != null)
|
if (GetCreateProperties().OrbitInfo != null)
|
||||||
{
|
{
|
||||||
AreaTriggerOrbitInfo orbit = GetCreateProperties().OrbitInfo;
|
AreaTriggerOrbitInfo orbit = GetCreateProperties().OrbitInfo;
|
||||||
if (target != null && GetTemplate() != null && GetTemplate().HasFlag(AreaTriggerFlags.HasAttached))
|
if (target != null && GetCreateProperties() != null && GetCreateProperties().Flags.HasFlag(AreaTriggerCreatePropertiesFlag.HasAttached))
|
||||||
orbit.PathTarget = target.GetGUID();
|
orbit.PathTarget = target.GetGUID();
|
||||||
else
|
else
|
||||||
orbit.Center = new(pos.posX, pos.posY, pos.posZ);
|
orbit.Center = new(pos.posX, pos.posY, pos.posZ);
|
||||||
@@ -180,16 +193,21 @@ namespace Game.Entities
|
|||||||
}
|
}
|
||||||
|
|
||||||
// movement on transport of areatriggers on unit is handled by themself
|
// movement on transport of areatriggers on unit is handled by themself
|
||||||
ITransport transport = m_movementInfo.transport.guid.IsEmpty() ? caster.GetTransport() : null;
|
ITransport transport = null;
|
||||||
if (transport != null)
|
if (caster != null)
|
||||||
{
|
{
|
||||||
float x, y, z, o;
|
transport = m_movementInfo.transport.guid.IsEmpty() ? caster.GetTransport() : null;
|
||||||
pos.GetPosition(out x, out y, out z, out o);
|
|
||||||
transport.CalculatePassengerOffset(ref x, ref y, ref z, ref o);
|
|
||||||
m_movementInfo.transport.pos.Relocate(x, y, z, o);
|
|
||||||
|
|
||||||
// This object must be added to transport before adding to map for the client to properly display it
|
if (transport != null)
|
||||||
transport.AddPassenger(this);
|
{
|
||||||
|
float x, y, z, o;
|
||||||
|
pos.GetPosition(out x, out y, out z, out o);
|
||||||
|
transport.CalculatePassengerOffset(ref x, ref y, ref z, ref o);
|
||||||
|
m_movementInfo.transport.pos.Relocate(x, y, z, o);
|
||||||
|
|
||||||
|
// This object must be added to transport before adding to map for the client to properly display it
|
||||||
|
transport.AddPassenger(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AI_Initialize();
|
AI_Initialize();
|
||||||
@@ -198,24 +216,27 @@ namespace Game.Entities
|
|||||||
if (HasOrbit())
|
if (HasOrbit())
|
||||||
Relocate(CalculateOrbitPosition());
|
Relocate(CalculateOrbitPosition());
|
||||||
|
|
||||||
if (!GetMap().AddToMap(this))
|
if (!IsStaticSpawn())
|
||||||
{ // Returning false will cause the object to be deleted - remove from transport
|
{
|
||||||
if (transport != null)
|
if (!GetMap().AddToMap(this))
|
||||||
transport.RemovePassenger(this);
|
{ // Returning false will cause the object to be deleted - remove from transport
|
||||||
return false;
|
if (transport != null)
|
||||||
|
transport.RemovePassenger(this);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
caster._RegisterAreaTrigger(this);
|
caster?._RegisterAreaTrigger(this);
|
||||||
|
|
||||||
_ai.OnCreate(spell);
|
_ai.OnCreate(spell);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AreaTrigger CreateAreaTrigger(uint areaTriggerCreatePropertiesId, Unit caster, Unit target, SpellInfo spellInfo, Position pos, int duration, SpellCastVisualField spellVisual, Spell spell = null, AuraEffect aurEff = null)
|
public static AreaTrigger CreateAreaTrigger(AreaTriggerId areaTriggerCreatePropertiesId, Position pos, int duration, Unit caster, Unit target, SpellCastVisual spellVisual = default, SpellInfo spellInfo = null, Spell spell = null, AuraEffect aurEff = null)
|
||||||
{
|
{
|
||||||
AreaTrigger at = new();
|
AreaTrigger at = new();
|
||||||
if (!at.Create(areaTriggerCreatePropertiesId, caster, target, spellInfo, pos, duration, spellVisual, spell, aurEff))
|
if (!at.Create(areaTriggerCreatePropertiesId, caster.GetMap(), pos, duration, null, caster, target, spellVisual, spellInfo, spell, aurEff))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
return at;
|
return at;
|
||||||
@@ -230,70 +251,23 @@ namespace Game.Entities
|
|||||||
{
|
{
|
||||||
_spawnId = spawnId;
|
_spawnId = spawnId;
|
||||||
|
|
||||||
AreaTriggerSpawn position = Global.AreaTriggerDataStorage.GetAreaTriggerSpawn(spawnId);
|
AreaTriggerSpawn spawnData = Global.AreaTriggerDataStorage.GetAreaTriggerSpawn(spawnId);
|
||||||
if (position == null)
|
if (spawnData == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
AreaTriggerTemplate areaTriggerTemplate = Global.AreaTriggerDataStorage.GetAreaTriggerTemplate(position.TriggerId);
|
AreaTriggerCreateProperties createProperties = Global.AreaTriggerDataStorage.GetAreaTriggerCreateProperties(spawnData.Id);
|
||||||
if (areaTriggerTemplate == null)
|
if (createProperties == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return CreateServer(map, areaTriggerTemplate, position);
|
SpellInfo spellInfo = null;
|
||||||
}
|
SpellCastVisual spellVisual = default;
|
||||||
|
if (spawnData.SpellForVisuals != 0)
|
||||||
bool CreateServer(Map map, AreaTriggerTemplate areaTriggerTemplate, AreaTriggerSpawn position)
|
|
||||||
{
|
|
||||||
SetMap(map);
|
|
||||||
Relocate(position.SpawnPoint);
|
|
||||||
RelocateStationaryPosition(position.SpawnPoint);
|
|
||||||
if (!IsPositionValid())
|
|
||||||
{
|
{
|
||||||
Log.outError(LogFilter.AreaTrigger, $"AreaTriggerServer (id {areaTriggerTemplate.Id}) not created. Invalid coordinates (X: {GetPositionX()} Y: {GetPositionY()})");
|
spellInfo = Global.SpellMgr.GetSpellInfo((uint)spawnData.SpellForVisuals, Difficulty.None);
|
||||||
return false;
|
if (spellInfo != null)
|
||||||
|
spellVisual.SpellXSpellVisualID = spellInfo.GetSpellXSpellVisualId();
|
||||||
}
|
}
|
||||||
|
return Create(spawnData.Id, map, spawnData.SpawnPoint, -1, spawnData, null, null, spellVisual, spellInfo);
|
||||||
SetZoneScript();
|
|
||||||
|
|
||||||
_areaTriggerTemplate = areaTriggerTemplate;
|
|
||||||
|
|
||||||
_Create(ObjectGuid.Create(HighGuid.AreaTrigger, GetMapId(), areaTriggerTemplate.Id.Id, GetMap().GenerateLowGuid(HighGuid.AreaTrigger)));
|
|
||||||
|
|
||||||
SetEntry(areaTriggerTemplate.Id.Id);
|
|
||||||
|
|
||||||
SetObjectScale(1.0f);
|
|
||||||
SetDuration(-1);
|
|
||||||
|
|
||||||
_shape = position.Shape;
|
|
||||||
|
|
||||||
if (position.SpellForVisuals.HasValue)
|
|
||||||
{
|
|
||||||
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(position.SpellForVisuals.Value, Difficulty.None);
|
|
||||||
SetUpdateFieldValue(m_areaTriggerData.ModifyValue(m_areaTriggerData.SpellForVisuals), position.SpellForVisuals.Value);
|
|
||||||
|
|
||||||
SpellCastVisualField spellCastVisual = m_areaTriggerData.ModifyValue(m_areaTriggerData.SpellVisual);
|
|
||||||
SetUpdateFieldValue(ref spellCastVisual.SpellXSpellVisualID, spellInfo.GetSpellXSpellVisualId());
|
|
||||||
SetUpdateFieldValue(ref spellCastVisual.ScriptVisualID, 0u);
|
|
||||||
}
|
|
||||||
|
|
||||||
SetUpdateFieldValue(m_areaTriggerData.ModifyValue(m_areaTriggerData.BoundsRadius2D), _shape.GetMaxSearchRadius());
|
|
||||||
if (IsServerSide())
|
|
||||||
SetUpdateFieldValue(m_areaTriggerData.ModifyValue(m_areaTriggerData.DecalPropertiesID), 24u); // blue decal, for .debug areatrigger visibility
|
|
||||||
|
|
||||||
SetScaleCurve(m_areaTriggerData.ModifyValue(m_areaTriggerData.ExtraScaleCurve), new AreaTriggerScaleCurveTemplate());
|
|
||||||
|
|
||||||
VisualAnim visualAnim = m_areaTriggerData.ModifyValue(m_areaTriggerData.VisualAnim);
|
|
||||||
SetUpdateFieldValue(visualAnim.ModifyValue(visualAnim.AnimationDataID), -1);
|
|
||||||
|
|
||||||
if (position.PhaseUseFlags != 0 || position.PhaseId != 0 || position.PhaseGroup != 0)
|
|
||||||
PhasingHandler.InitDbPhaseShift(GetPhaseShift(), position.PhaseUseFlags, position.PhaseId, position.PhaseGroup);
|
|
||||||
|
|
||||||
UpdateShape();
|
|
||||||
|
|
||||||
AI_Initialize();
|
|
||||||
|
|
||||||
_ai.OnCreate(null);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Update(uint diff)
|
public override void Update(uint diff)
|
||||||
@@ -301,7 +275,7 @@ namespace Game.Entities
|
|||||||
base.Update(diff);
|
base.Update(diff);
|
||||||
_timeSinceCreated += diff;
|
_timeSinceCreated += diff;
|
||||||
|
|
||||||
if (!IsServerSide())
|
if (!IsStaticSpawn())
|
||||||
{
|
{
|
||||||
// "If" order matter here, Orbit > Attached > Splines
|
// "If" order matter here, Orbit > Attached > Splines
|
||||||
if (HasOverridePosition())
|
if (HasOverridePosition())
|
||||||
@@ -312,7 +286,7 @@ namespace Game.Entities
|
|||||||
{
|
{
|
||||||
UpdateOrbitPosition(diff);
|
UpdateOrbitPosition(diff);
|
||||||
}
|
}
|
||||||
else if (GetTemplate() != null && GetTemplate().HasFlag(AreaTriggerFlags.HasAttached))
|
else if (GetCreateProperties() != null && GetCreateProperties().Flags.HasFlag(AreaTriggerCreatePropertiesFlag.HasAttached))
|
||||||
{
|
{
|
||||||
Unit target = GetTarget();
|
Unit target = GetTarget();
|
||||||
if (target != null)
|
if (target != null)
|
||||||
@@ -322,7 +296,7 @@ namespace Game.Entities
|
|||||||
if (createProperties != null && createProperties.FacingCurveId != 0)
|
if (createProperties != null && createProperties.FacingCurveId != 0)
|
||||||
orientation = Global.DB2Mgr.GetCurveValueAt(createProperties.FacingCurveId, GetProgress());
|
orientation = Global.DB2Mgr.GetCurveValueAt(createProperties.FacingCurveId, GetProgress());
|
||||||
|
|
||||||
if (GetTemplate() == null || !GetTemplate().HasFlag(AreaTriggerFlags.HasAbsoluteOrientation))
|
if (GetCreateProperties() == null || !GetCreateProperties().Flags.HasFlag(AreaTriggerCreatePropertiesFlag.HasAbsoluteOrientation))
|
||||||
orientation += target.GetOrientation();
|
orientation += target.GetOrientation();
|
||||||
|
|
||||||
GetMap().AreaTriggerRelocation(this, target.GetPositionX(), target.GetPositionY(), target.GetPositionZ(), orientation);
|
GetMap().AreaTriggerRelocation(this, target.GetPositionX(), target.GetPositionY(), target.GetPositionZ(), orientation);
|
||||||
@@ -338,7 +312,7 @@ namespace Game.Entities
|
|||||||
if (createProperties != null && createProperties.FacingCurveId != 0)
|
if (createProperties != null && createProperties.FacingCurveId != 0)
|
||||||
{
|
{
|
||||||
float orientation = Global.DB2Mgr.GetCurveValueAt(createProperties.FacingCurveId, GetProgress());
|
float orientation = Global.DB2Mgr.GetCurveValueAt(createProperties.FacingCurveId, GetProgress());
|
||||||
if (GetTemplate() == null || !GetTemplate().HasFlag(AreaTriggerFlags.HasAbsoluteOrientation))
|
if (GetCreateProperties() == null || !GetCreateProperties().Flags.HasFlag(AreaTriggerCreatePropertiesFlag.HasAbsoluteOrientation))
|
||||||
orientation += GetStationaryO();
|
orientation += GetStationaryO();
|
||||||
|
|
||||||
SetOrientation(orientation);
|
SetOrientation(orientation);
|
||||||
@@ -597,22 +571,22 @@ namespace Game.Entities
|
|||||||
|
|
||||||
switch (_shape.TriggerType)
|
switch (_shape.TriggerType)
|
||||||
{
|
{
|
||||||
case AreaTriggerTypes.Sphere:
|
case AreaTriggerShapeType.Sphere:
|
||||||
SearchUnitInSphere(targetList);
|
SearchUnitInSphere(targetList);
|
||||||
break;
|
break;
|
||||||
case AreaTriggerTypes.Box:
|
case AreaTriggerShapeType.Box:
|
||||||
SearchUnitInBox(targetList);
|
SearchUnitInBox(targetList);
|
||||||
break;
|
break;
|
||||||
case AreaTriggerTypes.Polygon:
|
case AreaTriggerShapeType.Polygon:
|
||||||
SearchUnitInPolygon(targetList);
|
SearchUnitInPolygon(targetList);
|
||||||
break;
|
break;
|
||||||
case AreaTriggerTypes.Cylinder:
|
case AreaTriggerShapeType.Cylinder:
|
||||||
SearchUnitInCylinder(targetList);
|
SearchUnitInCylinder(targetList);
|
||||||
break;
|
break;
|
||||||
case AreaTriggerTypes.Disk:
|
case AreaTriggerShapeType.Disk:
|
||||||
SearchUnitInDisk(targetList);
|
SearchUnitInDisk(targetList);
|
||||||
break;
|
break;
|
||||||
case AreaTriggerTypes.BoundedPlane:
|
case AreaTriggerShapeType.BoundedPlane:
|
||||||
SearchUnitInBoundedPlane(targetList);
|
SearchUnitInBoundedPlane(targetList);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -621,7 +595,7 @@ namespace Game.Entities
|
|||||||
|
|
||||||
if (GetTemplate() != null)
|
if (GetTemplate() != null)
|
||||||
{
|
{
|
||||||
var conditions = Global.ConditionMgr.GetConditionsForAreaTrigger(GetTemplate().Id.Id, GetTemplate().Id.IsServerSide);
|
var conditions = Global.ConditionMgr.GetConditionsForAreaTrigger(GetTemplate().Id.Id, GetTemplate().Id.IsCustom);
|
||||||
if (!conditions.Empty())
|
if (!conditions.Empty())
|
||||||
targetList.RemoveAll(target => !Global.ConditionMgr.IsObjectMeetToConditions(target, conditions));
|
targetList.RemoveAll(target => !Global.ConditionMgr.IsObjectMeetToConditions(target, conditions));
|
||||||
}
|
}
|
||||||
@@ -632,7 +606,7 @@ namespace Game.Entities
|
|||||||
void SearchUnits(List<Unit> targetList, float radius, bool check3D)
|
void SearchUnits(List<Unit> targetList, float radius, bool check3D)
|
||||||
{
|
{
|
||||||
var check = new AnyUnitInObjectRangeCheck(this, radius, check3D);
|
var check = new AnyUnitInObjectRangeCheck(this, radius, check3D);
|
||||||
if (IsServerSide())
|
if (IsStaticSpawn())
|
||||||
{
|
{
|
||||||
var searcher = new PlayerListSearcher(this, targetList, check);
|
var searcher = new PlayerListSearcher(this, targetList, check);
|
||||||
Cell.VisitWorldObjects(this, searcher, GetMaxSearchRadius());
|
Cell.VisitWorldObjects(this, searcher, GetMaxSearchRadius());
|
||||||
@@ -781,7 +755,7 @@ namespace Game.Entities
|
|||||||
if (player != null)
|
if (player != null)
|
||||||
{
|
{
|
||||||
if (player.IsDebugAreaTriggers)
|
if (player.IsDebugAreaTriggers)
|
||||||
player.SendSysMessage(CypherStrings.DebugAreatriggerEntered, GetEntry());
|
player.SendSysMessage(CypherStrings.DebugAreatriggerEntityEntered, GetEntry(), IsCustom(), IsStaticSpawn(), GetGUID().GetCounter());
|
||||||
|
|
||||||
player.UpdateQuestObjectiveProgress(QuestObjectiveType.AreaTriggerEnter, (int)GetEntry(), 1);
|
player.UpdateQuestObjectiveProgress(QuestObjectiveType.AreaTriggerEnter, (int)GetEntry(), 1);
|
||||||
}
|
}
|
||||||
@@ -800,7 +774,7 @@ namespace Game.Entities
|
|||||||
if (player != null)
|
if (player != null)
|
||||||
{
|
{
|
||||||
if (player.IsDebugAreaTriggers)
|
if (player.IsDebugAreaTriggers)
|
||||||
player.SendSysMessage(CypherStrings.DebugAreatriggerLeft, GetEntry());
|
player.SendSysMessage(CypherStrings.DebugAreatriggerEntityLeft, GetEntry(), IsCustom(), IsStaticSpawn(), GetGUID().GetCounter());
|
||||||
|
|
||||||
player.UpdateQuestObjectiveProgress(QuestObjectiveType.AreaTriggerExit, (int)GetEntry(), 1);
|
player.UpdateQuestObjectiveProgress(QuestObjectiveType.AreaTriggerExit, (int)GetEntry(), 1);
|
||||||
}
|
}
|
||||||
@@ -859,15 +833,16 @@ namespace Game.Entities
|
|||||||
void UpdatePolygonVertices()
|
void UpdatePolygonVertices()
|
||||||
{
|
{
|
||||||
AreaTriggerCreateProperties createProperties = GetCreateProperties();
|
AreaTriggerCreateProperties createProperties = GetCreateProperties();
|
||||||
|
AreaTriggerShapeInfo shape = GetShape();
|
||||||
float newOrientation = GetOrientation();
|
float newOrientation = GetOrientation();
|
||||||
|
|
||||||
// No need to recalculate, orientation didn't change
|
// No need to recalculate, orientation didn't change
|
||||||
if (MathFunctions.fuzzyEq(_verticesUpdatePreviousOrientation, newOrientation) && (createProperties == null) || createProperties.PolygonVerticesTarget.Empty())
|
if (MathFunctions.fuzzyEq(_verticesUpdatePreviousOrientation, newOrientation) && shape.PolygonVerticesTarget.Empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_polygonVertices = createProperties.PolygonVertices;
|
_polygonVertices = shape.PolygonVertices;
|
||||||
|
|
||||||
if (!createProperties.PolygonVerticesTarget.Empty())
|
if (!shape.PolygonVerticesTarget.Empty())
|
||||||
{
|
{
|
||||||
float progress = GetProgress();
|
float progress = GetProgress();
|
||||||
if (createProperties.MorphCurveId != 0)
|
if (createProperties.MorphCurveId != 0)
|
||||||
@@ -876,7 +851,7 @@ namespace Game.Entities
|
|||||||
for (var i = 0; i < _polygonVertices.Count; ++i)
|
for (var i = 0; i < _polygonVertices.Count; ++i)
|
||||||
{
|
{
|
||||||
Vector2 vertex = _polygonVertices[i];
|
Vector2 vertex = _polygonVertices[i];
|
||||||
Vector2 vertexTarget = createProperties.PolygonVerticesTarget[i];
|
Vector2 vertexTarget = shape.PolygonVerticesTarget[i];
|
||||||
|
|
||||||
vertex.X = MathFunctions.Lerp(vertex.X, vertexTarget.X, progress);
|
vertex.X = MathFunctions.Lerp(vertex.X, vertexTarget.X, progress);
|
||||||
vertex.Y = MathFunctions.Lerp(vertex.Y, vertexTarget.Y, progress);
|
vertex.Y = MathFunctions.Lerp(vertex.Y, vertexTarget.Y, progress);
|
||||||
@@ -1004,12 +979,12 @@ namespace Game.Entities
|
|||||||
|
|
||||||
void DoActions(Unit unit)
|
void DoActions(Unit unit)
|
||||||
{
|
{
|
||||||
Unit caster = IsServerSide() ? unit : GetCaster();
|
Unit caster = IsStaticSpawn() ? unit : GetCaster();
|
||||||
if (caster != null && GetTemplate() != null)
|
if (caster != null && GetTemplate() != null)
|
||||||
{
|
{
|
||||||
foreach (AreaTriggerAction action in GetTemplate().Actions)
|
foreach (AreaTriggerAction action in GetTemplate().Actions)
|
||||||
{
|
{
|
||||||
if (IsServerSide() || UnitFitToActionRequirement(unit, caster, action))
|
if (IsStaticSpawn() || UnitFitToActionRequirement(unit, caster, action))
|
||||||
{
|
{
|
||||||
switch (action.ActionType)
|
switch (action.ActionType)
|
||||||
{
|
{
|
||||||
@@ -1210,7 +1185,7 @@ namespace Game.Entities
|
|||||||
if (createProperties != null && createProperties.FacingCurveId != 0)
|
if (createProperties != null && createProperties.FacingCurveId != 0)
|
||||||
orientation = Global.DB2Mgr.GetCurveValueAt(createProperties.FacingCurveId, GetProgress());
|
orientation = Global.DB2Mgr.GetCurveValueAt(createProperties.FacingCurveId, GetProgress());
|
||||||
|
|
||||||
if (GetTemplate() == null || !GetTemplate().HasFlag(AreaTriggerFlags.HasAbsoluteOrientation))
|
if (GetCreateProperties() == null || !GetCreateProperties().Flags.HasFlag(AreaTriggerCreatePropertiesFlag.HasAbsoluteOrientation))
|
||||||
{
|
{
|
||||||
orientation += angle;
|
orientation += angle;
|
||||||
orientation += cmi.CounterClockwise ? MathFunctions.PiOver4 : -MathFunctions.PiOver4;
|
orientation += cmi.CounterClockwise ? MathFunctions.PiOver4 : -MathFunctions.PiOver4;
|
||||||
@@ -1266,7 +1241,7 @@ namespace Game.Entities
|
|||||||
float progress = Global.DB2Mgr.GetCurveValueAt(createProperties.MoveCurveId, currentTimePercent);
|
float progress = Global.DB2Mgr.GetCurveValueAt(createProperties.MoveCurveId, currentTimePercent);
|
||||||
if (progress < 0.0f || progress > 1.0f)
|
if (progress < 0.0f || progress > 1.0f)
|
||||||
{
|
{
|
||||||
Log.outError(LogFilter.AreaTrigger, $"AreaTrigger (Id: {GetEntry()}, AreaTriggerCreatePropertiesId: {createProperties.Id}) has wrong progress ({progress}) caused by curve calculation (MoveCurveId: {createProperties.MorphCurveId})");
|
Log.outError(LogFilter.AreaTrigger, $"AreaTrigger (Id: {GetEntry()}, AreaTriggerCreatePropertiesId: (Id: {createProperties.Id.Id}, IsCustom: {createProperties.Id.IsCustom})) has wrong progress ({progress}) caused by curve calculation (MoveCurveId: {createProperties.MoveCurveId})");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
currentTimePercent = progress;
|
currentTimePercent = progress;
|
||||||
@@ -1283,7 +1258,7 @@ namespace Game.Entities
|
|||||||
if (createProperties != null && createProperties.FacingCurveId != 0)
|
if (createProperties != null && createProperties.FacingCurveId != 0)
|
||||||
orientation += Global.DB2Mgr.GetCurveValueAt(createProperties.FacingCurveId, GetProgress());
|
orientation += Global.DB2Mgr.GetCurveValueAt(createProperties.FacingCurveId, GetProgress());
|
||||||
|
|
||||||
if (GetTemplate() != null && !GetTemplate().HasFlag(AreaTriggerFlags.HasAbsoluteOrientation) && GetTemplate().HasFlag(AreaTriggerFlags.HasFaceMovementDir))
|
if (GetCreateProperties() != null && !GetCreateProperties().Flags.HasFlag(AreaTriggerCreatePropertiesFlag.HasAbsoluteOrientation) && GetCreateProperties().Flags.HasFlag(AreaTriggerCreatePropertiesFlag.HasFaceMovementDir))
|
||||||
{
|
{
|
||||||
_spline.Evaluate_Derivative(lastPositionIndex, percentFromLastPoint, out Vector3 derivative);
|
_spline.Evaluate_Derivative(lastPositionIndex, percentFromLastPoint, out Vector3 derivative);
|
||||||
if (derivative.X != 0.0f || derivative.Y != 0.0f)
|
if (derivative.X != 0.0f || derivative.Y != 0.0f)
|
||||||
@@ -1313,7 +1288,7 @@ namespace Game.Entities
|
|||||||
if (GetCreateProperties().FacingCurveId != 0)
|
if (GetCreateProperties().FacingCurveId != 0)
|
||||||
{
|
{
|
||||||
orientation = Global.DB2Mgr.GetCurveValueAt(GetCreateProperties().FacingCurveId, GetProgress());
|
orientation = Global.DB2Mgr.GetCurveValueAt(GetCreateProperties().FacingCurveId, GetProgress());
|
||||||
if (GetTemplate() == null || !GetTemplate().HasFlag(AreaTriggerFlags.HasAbsoluteOrientation))
|
if (GetCreateProperties() == null || !GetCreateProperties().Flags.HasFlag(AreaTriggerCreatePropertiesFlag.HasAbsoluteOrientation))
|
||||||
orientation += GetStationaryO();
|
orientation += GetStationaryO();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1342,7 +1317,7 @@ namespace Game.Entities
|
|||||||
if (base.IsNeverVisibleFor(seer, allowServersideObjects))
|
if (base.IsNeverVisibleFor(seer, allowServersideObjects))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (IsServerSide() && !allowServersideObjects)
|
if (IsCustom() && !allowServersideObjects)
|
||||||
{
|
{
|
||||||
Player seerPlayer = seer.ToPlayer();
|
Player seerPlayer = seer.ToPlayer();
|
||||||
if (seerPlayer != null)
|
if (seerPlayer != null)
|
||||||
@@ -1418,7 +1393,9 @@ namespace Game.Entities
|
|||||||
|
|
||||||
public T GetAI<T>() where T : AreaTriggerAI { return (T)_ai; }
|
public T GetAI<T>() where T : AreaTriggerAI { return (T)_ai; }
|
||||||
|
|
||||||
public bool IsServerSide() { return _areaTriggerTemplate.Id.IsServerSide; }
|
public bool IsCustom() { return _areaTriggerTemplate.Id.IsCustom; }
|
||||||
|
public bool IsServerSide() { return _areaTriggerTemplate.Flags.HasFlag(AreaTriggerFlag.IsServerSide); }
|
||||||
|
public bool IsStaticSpawn() { return _spawnId != 0; }
|
||||||
|
|
||||||
[System.Diagnostics.Conditional("DEBUG")]
|
[System.Diagnostics.Conditional("DEBUG")]
|
||||||
void DebugVisualizePosition()
|
void DebugVisualizePosition()
|
||||||
|
|||||||
@@ -119,17 +119,17 @@ namespace Game.Entities
|
|||||||
public struct AreaTriggerId
|
public struct AreaTriggerId
|
||||||
{
|
{
|
||||||
public uint Id;
|
public uint Id;
|
||||||
public bool IsServerSide;
|
public bool IsCustom;
|
||||||
|
|
||||||
public AreaTriggerId(uint id, bool isServerSide)
|
public AreaTriggerId(uint id, bool isCustom)
|
||||||
{
|
{
|
||||||
Id = id;
|
Id = id;
|
||||||
IsServerSide = isServerSide;
|
IsCustom = isCustom;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int GetHashCode()
|
public override int GetHashCode()
|
||||||
{
|
{
|
||||||
return Id.GetHashCode() ^ IsServerSide.GetHashCode();
|
return Id.GetHashCode() ^ IsCustom.GetHashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
@@ -139,7 +139,7 @@ namespace Game.Entities
|
|||||||
|
|
||||||
public static bool operator ==(AreaTriggerId left, AreaTriggerId right)
|
public static bool operator ==(AreaTriggerId left, AreaTriggerId right)
|
||||||
{
|
{
|
||||||
return left.Id == right.Id && left.IsServerSide == right.IsServerSide;
|
return left.Id == right.Id && left.IsCustom == right.IsCustom;
|
||||||
}
|
}
|
||||||
public static bool operator !=(AreaTriggerId left, AreaTriggerId right)
|
public static bool operator !=(AreaTriggerId left, AreaTriggerId right)
|
||||||
{
|
{
|
||||||
@@ -149,27 +149,44 @@ namespace Game.Entities
|
|||||||
|
|
||||||
public class AreaTriggerShapeInfo : AreaTriggerData
|
public class AreaTriggerShapeInfo : AreaTriggerData
|
||||||
{
|
{
|
||||||
public AreaTriggerTypes TriggerType;
|
public AreaTriggerShapeType TriggerType;
|
||||||
|
public List<Vector2> PolygonVertices;
|
||||||
|
public List<Vector2> PolygonVerticesTarget;
|
||||||
|
|
||||||
public AreaTriggerShapeInfo()
|
public AreaTriggerShapeInfo()
|
||||||
{
|
{
|
||||||
TriggerType = AreaTriggerTypes.Max;
|
TriggerType = AreaTriggerShapeType.Max;
|
||||||
|
PolygonVertices = new();
|
||||||
|
PolygonVerticesTarget = new();
|
||||||
}
|
}
|
||||||
|
|
||||||
public unsafe float GetMaxSearchRadius()
|
public unsafe float GetMaxSearchRadius()
|
||||||
{
|
{
|
||||||
switch (TriggerType)
|
switch (TriggerType)
|
||||||
{
|
{
|
||||||
case AreaTriggerTypes.Sphere:
|
case AreaTriggerShapeType.Sphere:
|
||||||
return Math.Max(SphereDatas.Radius, SphereDatas.RadiusTarget);
|
return Math.Max(SphereDatas.Radius, SphereDatas.RadiusTarget);
|
||||||
case AreaTriggerTypes.Box:
|
case AreaTriggerShapeType.Box:
|
||||||
return MathF.Sqrt(Math.Max(BoxDatas.Extents[0] * BoxDatas.Extents[0] + BoxDatas.Extents[1] * BoxDatas.Extents[1],
|
return MathF.Sqrt(Math.Max(BoxDatas.Extents[0] * BoxDatas.Extents[0] + BoxDatas.Extents[1] * BoxDatas.Extents[1],
|
||||||
BoxDatas.ExtentsTarget[0] * BoxDatas.ExtentsTarget[0] + BoxDatas.ExtentsTarget[1] * BoxDatas.ExtentsTarget[1]));
|
BoxDatas.ExtentsTarget[0] * BoxDatas.ExtentsTarget[0] + BoxDatas.ExtentsTarget[1] * BoxDatas.ExtentsTarget[1]));
|
||||||
case AreaTriggerTypes.Cylinder:
|
case AreaTriggerShapeType.Polygon:
|
||||||
|
{
|
||||||
|
Position center = new(0.0f, 0.0f);
|
||||||
|
float maxSearchRadius = 0.0f;
|
||||||
|
|
||||||
|
foreach (var vertex in PolygonVertices)
|
||||||
|
maxSearchRadius = Math.Max(maxSearchRadius, center.GetExactDist2d(vertex.X, vertex.Y));
|
||||||
|
|
||||||
|
foreach (var vertex in PolygonVerticesTarget)
|
||||||
|
maxSearchRadius = Math.Max(maxSearchRadius, center.GetExactDist2d(vertex.X, vertex.Y));
|
||||||
|
|
||||||
|
return maxSearchRadius;
|
||||||
|
}
|
||||||
|
case AreaTriggerShapeType.Cylinder:
|
||||||
return Math.Max(CylinderDatas.Radius, CylinderDatas.RadiusTarget);
|
return Math.Max(CylinderDatas.Radius, CylinderDatas.RadiusTarget);
|
||||||
case AreaTriggerTypes.Disk:
|
case AreaTriggerShapeType.Disk:
|
||||||
return Math.Max(DiskDatas.OuterRadius, DiskDatas.OuterRadiusTarget);
|
return Math.Max(DiskDatas.OuterRadius, DiskDatas.OuterRadiusTarget);
|
||||||
case AreaTriggerTypes.BoundedPlane:
|
case AreaTriggerShapeType.BoundedPlane:
|
||||||
return MathF.Sqrt(Math.Max(BoundedPlaneDatas.Extents[0] * BoundedPlaneDatas.Extents[0] / 4 + BoundedPlaneDatas.Extents[1] * BoundedPlaneDatas.Extents[1] / 4,
|
return MathF.Sqrt(Math.Max(BoundedPlaneDatas.Extents[0] * BoundedPlaneDatas.Extents[0] / 4 + BoundedPlaneDatas.Extents[1] * BoundedPlaneDatas.Extents[1] / 4,
|
||||||
BoundedPlaneDatas.ExtentsTarget[0] * BoundedPlaneDatas.ExtentsTarget[0] / 4 + BoundedPlaneDatas.ExtentsTarget[1] * BoundedPlaneDatas.ExtentsTarget[1] / 4));
|
BoundedPlaneDatas.ExtentsTarget[0] * BoundedPlaneDatas.ExtentsTarget[0] / 4 + BoundedPlaneDatas.ExtentsTarget[1] * BoundedPlaneDatas.ExtentsTarget[1] / 4));
|
||||||
}
|
}
|
||||||
@@ -177,12 +194,12 @@ namespace Game.Entities
|
|||||||
return 0.0f;
|
return 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsSphere() { return TriggerType == AreaTriggerTypes.Sphere; }
|
public bool IsSphere() { return TriggerType == AreaTriggerShapeType.Sphere; }
|
||||||
public bool IsBox() { return TriggerType == AreaTriggerTypes.Box; }
|
public bool IsBox() { return TriggerType == AreaTriggerShapeType.Box; }
|
||||||
public bool IsPolygon() { return TriggerType == AreaTriggerTypes.Polygon; }
|
public bool IsPolygon() { return TriggerType == AreaTriggerShapeType.Polygon; }
|
||||||
public bool IsCylinder() { return TriggerType == AreaTriggerTypes.Cylinder; }
|
public bool IsCylinder() { return TriggerType == AreaTriggerShapeType.Cylinder; }
|
||||||
public bool IsDisk() { return TriggerType == AreaTriggerTypes.Disk; }
|
public bool IsDisk() { return TriggerType == AreaTriggerShapeType.Disk; }
|
||||||
public bool IsBoudedPlane() { return TriggerType == AreaTriggerTypes.BoundedPlane; }
|
public bool IsBoundedPlane() { return TriggerType == AreaTriggerShapeType.BoundedPlane; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class AreaTriggerOrbitInfo
|
public class AreaTriggerOrbitInfo
|
||||||
@@ -225,43 +242,15 @@ namespace Game.Entities
|
|||||||
public class AreaTriggerTemplate
|
public class AreaTriggerTemplate
|
||||||
{
|
{
|
||||||
public AreaTriggerId Id;
|
public AreaTriggerId Id;
|
||||||
public AreaTriggerFlags Flags;
|
public AreaTriggerFlag Flags;
|
||||||
|
|
||||||
public List<AreaTriggerAction> Actions = new();
|
public List<AreaTriggerAction> Actions = new();
|
||||||
|
|
||||||
public bool HasFlag(AreaTriggerFlags flag) { return Flags.HasAnyFlag(flag); }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public unsafe class AreaTriggerCreateProperties
|
public class AreaTriggerCreateProperties
|
||||||
{
|
{
|
||||||
public AreaTriggerCreateProperties()
|
public AreaTriggerId Id;
|
||||||
{
|
|
||||||
ExtraScale = new();
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool HasSplines() { return SplinePoints.Count >= 2; }
|
|
||||||
|
|
||||||
public float GetMaxSearchRadius()
|
|
||||||
{
|
|
||||||
if (Shape.TriggerType == AreaTriggerTypes.Polygon)
|
|
||||||
{
|
|
||||||
Position center = new(0.0f, 0.0f);
|
|
||||||
float maxSearchRadius = 0.0f;
|
|
||||||
|
|
||||||
foreach (var vertex in PolygonVertices)
|
|
||||||
maxSearchRadius = Math.Max(maxSearchRadius, center.GetExactDist2d(vertex.X, vertex.Y));
|
|
||||||
|
|
||||||
foreach (var vertex in PolygonVerticesTarget)
|
|
||||||
maxSearchRadius = Math.Max(maxSearchRadius, center.GetExactDist2d(vertex.X, vertex.Y));
|
|
||||||
|
|
||||||
return maxSearchRadius;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Shape.GetMaxSearchRadius();
|
|
||||||
}
|
|
||||||
|
|
||||||
public uint Id;
|
|
||||||
public AreaTriggerTemplate Template;
|
public AreaTriggerTemplate Template;
|
||||||
|
public AreaTriggerCreatePropertiesFlag Flags;
|
||||||
|
|
||||||
public uint MoveCurveId;
|
public uint MoveCurveId;
|
||||||
public uint ScaleCurveId;
|
public uint ScaleCurveId;
|
||||||
@@ -280,18 +269,23 @@ namespace Game.Entities
|
|||||||
public AreaTriggerScaleCurveTemplate ExtraScale;
|
public AreaTriggerScaleCurveTemplate ExtraScale;
|
||||||
|
|
||||||
public AreaTriggerShapeInfo Shape = new();
|
public AreaTriggerShapeInfo Shape = new();
|
||||||
public List<Vector2> PolygonVertices = new();
|
|
||||||
public List<Vector2> PolygonVerticesTarget = new();
|
|
||||||
public List<Vector3> SplinePoints = new();
|
public List<Vector3> SplinePoints = new();
|
||||||
public AreaTriggerOrbitInfo OrbitInfo;
|
public AreaTriggerOrbitInfo OrbitInfo;
|
||||||
|
|
||||||
public uint ScriptId;
|
public uint ScriptId;
|
||||||
|
|
||||||
|
public AreaTriggerCreateProperties()
|
||||||
|
{
|
||||||
|
Id = new(0, false);
|
||||||
|
ExtraScale = new();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool HasSplines() { return SplinePoints.Count >= 2; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class AreaTriggerSpawn : SpawnData
|
public class AreaTriggerSpawn : SpawnData
|
||||||
{
|
{
|
||||||
public AreaTriggerId TriggerId;
|
public AreaTriggerId Id;
|
||||||
public AreaTriggerShapeInfo Shape = new();
|
|
||||||
public uint? SpellForVisuals;
|
public uint? SpellForVisuals;
|
||||||
|
|
||||||
public AreaTriggerSpawn() : base(SpawnObjectType.AreaTrigger) { }
|
public AreaTriggerSpawn() : base(SpawnObjectType.AreaTrigger) { }
|
||||||
|
|||||||
@@ -429,20 +429,19 @@ namespace Game.Entities
|
|||||||
{
|
{
|
||||||
AreaTrigger areaTrigger = ToAreaTrigger();
|
AreaTrigger areaTrigger = ToAreaTrigger();
|
||||||
AreaTriggerCreateProperties createProperties = areaTrigger.GetCreateProperties();
|
AreaTriggerCreateProperties createProperties = areaTrigger.GetCreateProperties();
|
||||||
AreaTriggerTemplate areaTriggerTemplate = areaTrigger.GetTemplate();
|
|
||||||
AreaTriggerShapeInfo shape = areaTrigger.GetShape();
|
AreaTriggerShapeInfo shape = areaTrigger.GetShape();
|
||||||
|
|
||||||
data.WriteUInt32(areaTrigger.GetTimeSinceCreated());
|
data.WriteUInt32(areaTrigger.GetTimeSinceCreated());
|
||||||
|
|
||||||
data.WriteVector3(areaTrigger.GetRollPitchYaw());
|
data.WriteVector3(areaTrigger.GetRollPitchYaw());
|
||||||
|
|
||||||
bool hasAbsoluteOrientation = areaTriggerTemplate != null && areaTriggerTemplate.HasFlag(AreaTriggerFlags.HasAbsoluteOrientation);
|
bool hasAbsoluteOrientation = createProperties != null && createProperties.Flags.HasFlag(AreaTriggerCreatePropertiesFlag.HasAbsoluteOrientation);
|
||||||
bool hasDynamicShape = areaTriggerTemplate != null && areaTriggerTemplate.HasFlag(AreaTriggerFlags.HasDynamicShape);
|
bool hasDynamicShape = createProperties != null && createProperties.Flags.HasFlag(AreaTriggerCreatePropertiesFlag.HasDynamicShape);
|
||||||
bool hasAttached = areaTriggerTemplate != null && areaTriggerTemplate.HasFlag(AreaTriggerFlags.HasAttached);
|
bool hasAttached = createProperties != null && createProperties.Flags.HasFlag(AreaTriggerCreatePropertiesFlag.HasAttached);
|
||||||
bool hasFaceMovementDir = areaTriggerTemplate != null && areaTriggerTemplate.HasFlag(AreaTriggerFlags.HasFaceMovementDir);
|
bool hasFaceMovementDir = createProperties != null && createProperties.Flags.HasFlag(AreaTriggerCreatePropertiesFlag.HasFaceMovementDir);
|
||||||
bool hasFollowsTerrain = areaTriggerTemplate != null && areaTriggerTemplate.HasFlag(AreaTriggerFlags.HasFollowsTerrain);
|
bool hasFollowsTerrain = createProperties != null && createProperties.Flags.HasFlag(AreaTriggerCreatePropertiesFlag.HasFollowsTerrain);
|
||||||
bool hasUnk1 = areaTriggerTemplate != null && areaTriggerTemplate.HasFlag(AreaTriggerFlags.Unk1);
|
bool hasUnk1 = createProperties != null && createProperties.Flags.HasFlag(AreaTriggerCreatePropertiesFlag.Unk1);
|
||||||
bool hasTargetRollPitchYaw = areaTriggerTemplate != null && areaTriggerTemplate.HasFlag(AreaTriggerFlags.HasTargetRollPitchYaw);
|
bool hasTargetRollPitchYaw = createProperties != null && createProperties.Flags.HasFlag(AreaTriggerCreatePropertiesFlag.HasTargetRollPitchYaw);
|
||||||
bool hasScaleCurveID = createProperties != null && createProperties.ScaleCurveId != 0;
|
bool hasScaleCurveID = createProperties != null && createProperties.ScaleCurveId != 0;
|
||||||
bool hasMorphCurveID = createProperties != null && createProperties.MorphCurveId != 0;
|
bool hasMorphCurveID = createProperties != null && createProperties.MorphCurveId != 0;
|
||||||
bool hasFacingCurveID = createProperties != null && createProperties.FacingCurveId != 0;
|
bool hasFacingCurveID = createProperties != null && createProperties.FacingCurveId != 0;
|
||||||
@@ -452,7 +451,7 @@ namespace Game.Entities
|
|||||||
bool hasAreaTriggerPolygon = createProperties != null && shape.IsPolygon();
|
bool hasAreaTriggerPolygon = createProperties != null && shape.IsPolygon();
|
||||||
bool hasAreaTriggerCylinder = shape.IsCylinder();
|
bool hasAreaTriggerCylinder = shape.IsCylinder();
|
||||||
bool hasDisk = shape.IsDisk();
|
bool hasDisk = shape.IsDisk();
|
||||||
bool hasBoundedPlane = shape.IsBoudedPlane();
|
bool hasBoundedPlane = shape.IsBoundedPlane();
|
||||||
bool hasAreaTriggerSpline = areaTrigger.HasSplines();
|
bool hasAreaTriggerSpline = areaTrigger.HasSplines();
|
||||||
bool hasOrbit = areaTrigger.HasOrbit();
|
bool hasOrbit = areaTrigger.HasOrbit();
|
||||||
bool hasMovementScript = false;
|
bool hasMovementScript = false;
|
||||||
@@ -525,15 +524,15 @@ namespace Game.Entities
|
|||||||
|
|
||||||
if (hasAreaTriggerPolygon)
|
if (hasAreaTriggerPolygon)
|
||||||
{
|
{
|
||||||
data.WriteInt32(createProperties.PolygonVertices.Count);
|
data.WriteInt32(shape.PolygonVertices.Count);
|
||||||
data.WriteInt32(createProperties.PolygonVerticesTarget.Count);
|
data.WriteInt32(shape.PolygonVerticesTarget.Count);
|
||||||
data.WriteFloat(shape.PolygonDatas.Height);
|
data.WriteFloat(shape.PolygonDatas.Height);
|
||||||
data.WriteFloat(shape.PolygonDatas.HeightTarget);
|
data.WriteFloat(shape.PolygonDatas.HeightTarget);
|
||||||
|
|
||||||
foreach (var vertice in createProperties.PolygonVertices)
|
foreach (var vertice in shape.PolygonVertices)
|
||||||
data.WriteVector2(vertice);
|
data.WriteVector2(vertice);
|
||||||
|
|
||||||
foreach (var vertice in createProperties.PolygonVerticesTarget)
|
foreach (var vertice in shape.PolygonVerticesTarget)
|
||||||
data.WriteVector2(vertice);
|
data.WriteVector2(vertice);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5775,7 +5775,8 @@ namespace Game.Spells
|
|||||||
|
|
||||||
if (apply)
|
if (apply)
|
||||||
{
|
{
|
||||||
AreaTrigger.CreateAreaTrigger((uint)GetMiscValue(), GetCaster(), target, GetSpellInfo(), target, GetBase().GetDuration(), GetBase().GetSpellVisual(), null, this);
|
AreaTriggerId createPropertiesId = new((uint)GetMiscValue(), false);
|
||||||
|
AreaTrigger.CreateAreaTrigger(createPropertiesId, target, GetBase().GetDuration(), GetCaster(), target, GetBase().GetSpellVisual(), GetSpellInfo(), null, this);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5067,8 +5067,9 @@ namespace Game.Spells
|
|||||||
if (unitCaster == null || !m_targets.HasDst())
|
if (unitCaster == null || !m_targets.HasDst())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
AreaTriggerId createPropertiesId = new((uint)effectInfo.MiscValue, false);
|
||||||
int duration = GetSpellInfo().CalcDuration(GetCaster());
|
int duration = GetSpellInfo().CalcDuration(GetCaster());
|
||||||
AreaTrigger.CreateAreaTrigger((uint)effectInfo.MiscValue, unitCaster, null, GetSpellInfo(), destTarget.GetPosition(), duration, m_SpellVisual, this);
|
AreaTrigger.CreateAreaTrigger(createPropertiesId, destTarget.GetPosition(), duration, unitCaster, null, m_SpellVisual, GetSpellInfo(), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
[SpellEffectHandler(SpellEffectName.RemoveTalent)]
|
[SpellEffectHandler(SpellEffectName.RemoveTalent)]
|
||||||
|
|||||||
Reference in New Issue
Block a user