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
@@ -9,18 +9,6 @@ namespace Framework.Constants
IsServerSide = 0x01
}
public enum AreaTriggerShapeType
{
Sphere = 0,
Box = 1,
Unk = 2,
Polygon = 3,
Cylinder = 4,
Disk = 5,
BoundedPlane = 6,
Max
}
public enum AreaTriggerActionTypes
{
Cast = 0,
+32
View File
@@ -952,6 +952,38 @@ namespace Framework.Constants
ClientEnforcesMount = 0x10
}
[Flags]
public enum AreaTriggerActionSetFlag
{
None = 0x00,
OnlyTriggeredByCaster = 0x01,
ResurrectIfConditionFails = 0x02,
Obsolete = 0x04,
AllowWhileGhost = 0x08,
AllowWhileDead = 0x10,
UnifyAllInstances = 0x20,
SuppressConditionError = 0x40, // NYI
NotTriggeredbyCaster = 0x80,
CreatorsPartyOnly = 0x100,
DontRunOnLeaveWhenExpiring = 0x200,
CanAffectUninteractible = 0x400,
DontDespawnWithCreator = 0x800,
CanAffectBeastmaster = 0x1000,
RequiresLineOfSight = 0x2000
}
public enum AreaTriggerShapeType
{
Sphere = 0,
Box = 1,
Unk = 2,
Polygon = 3,
Cylinder = 4,
Disk = 5,
BoundedPlane = 6,
Max
}
public enum ArtifactCategory
{
Primary = 1,
@@ -55,6 +55,9 @@ namespace Framework.Database
PrepareStatement(HotfixStatements.SEL_AREA_TRIGGER, "SELECT PosX, PosY, PosZ, ID, ContinentID, PhaseUseFlags, PhaseID, PhaseGroupID, Radius, BoxLength, " +
"BoxWidth, BoxHeight, BoxYaw, ShapeType, ShapeID, AreaTriggerActionSetID, Flags FROM area_trigger WHERE (`VerifiedBuild` > 0) = ?");
// AreaTriggerActionSet.db2
PrepareStatement(HotfixStatements.SEL_AREA_TRIGGER_ACTION_SET, "SELECT ID, Flags FROM area_trigger_action_set WHERE (`VerifiedBuild` > 0) = ?");
// ArmorLocation.db2
PrepareStatement(HotfixStatements.SEL_ARMOR_LOCATION, "SELECT ID, Clothmodifier, Leathermodifier, Chainmodifier, Platemodifier, Modifier FROM armor_location" +
" WHERE (`VerifiedBuild` > 0) = ?");
@@ -1642,6 +1645,8 @@ namespace Framework.Database
SEL_AREA_TRIGGER,
SEL_AREA_TRIGGER_ACTION_SET,
SEL_ARMOR_LOCATION,
SEL_ARTIFACT,
+2
View File
@@ -57,6 +57,7 @@ namespace Game.DataStorage
AreaGroupMemberStorage = ReadDB2<AreaGroupMemberRecord>("AreaGroupMember.db2", HotfixStatements.SEL_AREA_GROUP_MEMBER);
AreaTableStorage = ReadDB2<AreaTableRecord>("AreaTable.db2", HotfixStatements.SEL_AREA_TABLE, HotfixStatements.SEL_AREA_TABLE_LOCALE);
AreaTriggerStorage = ReadDB2<AreaTriggerRecord>("AreaTrigger.db2", HotfixStatements.SEL_AREA_TRIGGER);
AreaTriggerActionSetStorage = ReadDB2<AreaTriggerActionSetRecord>("AreaTriggerActionSet.db2", HotfixStatements.SEL_AREA_TRIGGER_ACTION_SET);
ArmorLocationStorage = ReadDB2<ArmorLocationRecord>("ArmorLocation.db2", HotfixStatements.SEL_ARMOR_LOCATION);
ArtifactStorage = ReadDB2<ArtifactRecord>("Artifact.db2", HotfixStatements.SEL_ARTIFACT, HotfixStatements.SEL_ARTIFACT_APPEARANCE_LOCALE);
ArtifactAppearanceStorage = ReadDB2<ArtifactAppearanceRecord>("ArtifactAppearance.db2", HotfixStatements.SEL_ARTIFACT_APPEARANCE, HotfixStatements.SEL_ARTIFACT_APPEARANCE_LOCALE);
@@ -501,6 +502,7 @@ namespace Game.DataStorage
public static DB6Storage<AreaGroupMemberRecord> AreaGroupMemberStorage;
public static DB6Storage<AreaTableRecord> AreaTableStorage;
public static DB6Storage<AreaTriggerRecord> AreaTriggerStorage;
public static DB6Storage<AreaTriggerActionSetRecord> AreaTriggerActionSetStorage;
public static DB6Storage<ArmorLocationRecord> ArmorLocationStorage;
public static DB6Storage<ArtifactRecord> ArtifactStorage;
public static DB6Storage<ArtifactAppearanceRecord> ArtifactAppearanceStorage;
@@ -158,6 +158,16 @@ namespace Game.DataStorage
public short ShapeID;
public int AreaTriggerActionSetID;
public sbyte Flags;
public AreaTriggerShapeType GetShapeType() { return (AreaTriggerShapeType)ShapeType; }
}
public sealed class AreaTriggerActionSetRecord
{
public uint Id;
public int Flags;
public AreaTriggerActionSetFlag GetFlags() { return (AreaTriggerActionSetFlag)Flags; }
}
public sealed class ArmorLocationRecord
+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;
+1 -1
View File
@@ -5470,7 +5470,7 @@ namespace Game
{
foreach (var (_, areaTrigger) in CliDB.AreaTriggerStorage)
{
if (areaTrigger.ShapeType != 3)
if (areaTrigger.GetShapeType() != AreaTriggerShapeType.Polygon)
continue;
PathDb2 path = Global.DB2Mgr.GetPath((uint)areaTrigger.ShapeID);