Core/AreaTriggers: Check actionset flags for client areatriggers to allow some areatriggers to trigger while dead

Port From (https://github.com/TrinityCore/TrinityCore/commit/d51d6b0abeec25a7c7fd4903ddbca0124ee8c723)
This commit is contained in:
Hondacrx
2024-08-26 17:49:33 -04:00
parent b7b166c0f0
commit 254d04d37e
7 changed files with 79 additions and 19 deletions
+29 -6
View File
@@ -2437,23 +2437,46 @@ namespace Game.Entities
if (!PhasingHandler.InDbPhaseShift(this, (PhaseUseFlagsValues)areaTrigger.PhaseUseFlags, areaTrigger.PhaseID, areaTrigger.PhaseGroupID))
return false;
Position areaTriggerPos = new(areaTrigger.Pos.X, areaTrigger.Pos.Y, areaTrigger.Pos.Z, areaTrigger.BoxYaw);
switch (areaTrigger.ShapeType)
bool hasActionSetFlag(AreaTriggerActionSetFlag flag)
{
case 0: // Sphere
var areaTriggerActionSet = CliDB.AreaTriggerActionSetStorage.LookupByKey(areaTrigger.AreaTriggerActionSetID);
if (areaTriggerActionSet != null)
return areaTriggerActionSet.GetFlags().HasFlag(flag);
return false;
}
switch (GetDeathState())
{
case DeathState.Dead:
if (!hasActionSetFlag(AreaTriggerActionSetFlag.AllowWhileGhost))
return false;
break;
case DeathState.Corpse:
if (!hasActionSetFlag(AreaTriggerActionSetFlag.AllowWhileDead))
return false;
break;
default:
break;
}
Position areaTriggerPos = new(areaTrigger.Pos.X, areaTrigger.Pos.Y, areaTrigger.Pos.Z, areaTrigger.BoxYaw);
switch (areaTrigger.GetShapeType())
{
case AreaTriggerShapeType.Sphere:
if (!IsInDist(areaTriggerPos, areaTrigger.Radius))
return false;
break;
case 1: // Box
case AreaTriggerShapeType.Box:
if (!IsWithinBox(areaTriggerPos, areaTrigger.BoxLength / 2.0f, areaTrigger.BoxWidth / 2.0f, areaTrigger.BoxHeight / 2.0f))
return false;
break;
case 3: // Polygon
case AreaTriggerShapeType.Polygon:
var polygon = ObjectMgr.GetAreaTriggerPolygon(areaTrigger.Id);
if (polygon == null || (polygon.Height.HasValue && GetPositionZ() > areaTrigger.Pos.Z + polygon.Height) || !IsInPolygon2D(areaTriggerPos, polygon.Vertices))
return false;
break;
case 4: // Cylinder
case AreaTriggerShapeType.Cylinder:
if (!IsWithinVerticalCylinder(areaTriggerPos, areaTrigger.Radius, areaTrigger.BoxHeight))
return false;
break;