Core/Combat: Disable triggers entering combat

Port From (https://github.com/TrinityCore/TrinityCore/commit/1dfcb7086e17902f0904ee6c09bc55a229b65cc1)
This commit is contained in:
hondacrx
2022-03-01 17:38:12 -05:00
parent 62cb6ffd33
commit 6f1b2f5cd5
3 changed files with 14 additions and 3 deletions
+3 -2
View File
@@ -210,6 +210,7 @@ namespace Framework.Constants
UnitIsQuestBoss = 0x80000000 // Not verified UnitIsQuestBoss = 0x80000000 // Not verified
} }
[Flags]
public enum CreatureFlagsExtra : uint public enum CreatureFlagsExtra : uint
{ {
InstanceBind = 0x01, // Creature Kill Bind Instance With Killer And Killer'S Group InstanceBind = 0x01, // Creature Kill Bind Instance With Killer And Killer'S Group
@@ -225,7 +226,7 @@ namespace Framework.Constants
GhostVisibility = 0x400, // creature will be only visible for dead players GhostVisibility = 0x400, // creature will be only visible for dead players
UseOffhandAttack = 0x800, // creature will use offhand attacks UseOffhandAttack = 0x800, // creature will use offhand attacks
NoSellVendor = 0x1000, // players can't sell items to this vendor NoSellVendor = 0x1000, // players can't sell items to this vendor
Unused13 = 0x2000, NoCombat = 0x2000, // creature is not allowed to enter combat
Worldevent = 0x4000, // Custom Flag For World Event Creatures (Left Room For Merging) Worldevent = 0x4000, // Custom Flag For World Event Creatures (Left Room For Merging)
Guard = 0x8000, // Creature Is Guard Guard = 0x8000, // Creature Is Guard
Unused16 = 0x00010000, Unused16 = 0x00010000,
@@ -246,7 +247,7 @@ namespace Framework.Constants
Unused31 = 0x80000000, Unused31 = 0x80000000,
// Masks // Masks
AllUnused = (Unused13 | Unused16 | Unused22 | Unused23 | Unused24 | Unused25 | Unused26 | Unused27 | Unused31), AllUnused = (Unused16 | Unused22 | Unused23 | Unused24 | Unused25 | Unused26 | Unused27 | Unused31),
DBAllowed = (0xFFFFFFFF & ~(AllUnused | DungeonBoss)) DBAllowed = (0xFFFFFFFF & ~(AllUnused | DungeonBoss))
} }
+6
View File
@@ -57,6 +57,12 @@ namespace Game.Combat
return false; return false;
if (a.HasUnitState(UnitState.InFlight) || b.HasUnitState(UnitState.InFlight)) if (a.HasUnitState(UnitState.InFlight) || b.HasUnitState(UnitState.InFlight))
return false; return false;
Creature aCreature = a.ToCreature();
if (aCreature?.IsCombatDisallowed())
return false;
Creature bCreature = b.ToCreature();
if (bCreature?.IsCombatDisallowed())
return false;
if (a.IsFriendlyTo(b) || b.IsFriendlyTo(a)) if (a.IsFriendlyTo(b) || b.IsFriendlyTo(a))
return false; return false;
Player playerA = a.GetCharmerOrOwnerPlayerOrPlayerItself(); Player playerA = a.GetCharmerOrOwnerPlayerOrPlayerItself();
+5 -1
View File
@@ -3098,7 +3098,11 @@ namespace Game.Entities
{ {
return GetCreatureTemplate().FlagsExtra.HasAnyFlag(CreatureFlagsExtra.Guard); return GetCreatureTemplate().FlagsExtra.HasAnyFlag(CreatureFlagsExtra.Guard);
} }
bool IsCombatDisallowed()
{
return GetCreatureTemplate().FlagsExtra.HasFlag(CreatureFlagsExtra.NoCombat);
}
public bool CanWalk() { return GetMovementTemplate().IsGroundAllowed(); } public bool CanWalk() { return GetMovementTemplate().IsGroundAllowed(); }
public override bool CanSwim() { return GetMovementTemplate().IsSwimAllowed() || IsPet();} public override bool CanSwim() { return GetMovementTemplate().IsSwimAllowed() || IsPet();}
public override bool CanFly() { return GetMovementTemplate().IsFlightAllowed() || IsFlying(); } public override bool CanFly() { return GetMovementTemplate().IsFlightAllowed() || IsFlying(); }