Core/Units: Added helper functions to modify UNIT_FLAG_UNINTERACTIBLE
Port From (https://github.com/TrinityCore/TrinityCore/commit/88ff97c1f96381565c47f8ca1993bdc7fce19fd6)
This commit is contained in:
@@ -373,7 +373,7 @@ namespace Game.Entities
|
||||
|
||||
// trigger creature is always not selectable and can not be attacked
|
||||
if (IsTrigger())
|
||||
SetUnitFlag(UnitFlags.Uninteractible);
|
||||
SetUninteractible(true);
|
||||
|
||||
InitializeReactState();
|
||||
|
||||
@@ -2305,7 +2305,7 @@ namespace Game.Entities
|
||||
if (IsCivilian())
|
||||
return false;
|
||||
|
||||
if (HasUnitFlag(UnitFlags.NonAttackable | UnitFlags.Uninteractible) || IsImmuneToNPC())
|
||||
if (HasUnitFlag(UnitFlags.NonAttackable) || IsImmuneToNPC() || IsUninteractible())
|
||||
return false;
|
||||
|
||||
// skip fighting creature
|
||||
|
||||
@@ -2557,7 +2557,7 @@ namespace Game.Entities
|
||||
if ((bySpell == null || !bySpell.HasAttribute(SpellAttr6.CanTargetUntargetable)) && unitTarget != null && unitTarget.HasUnitFlag(UnitFlags.NonAttackable2))
|
||||
return false;
|
||||
|
||||
if (unitTarget != null && unitTarget.HasUnitFlag(UnitFlags.Uninteractible))
|
||||
if (unitTarget != null && unitTarget.IsUninteractible())
|
||||
return false;
|
||||
|
||||
Player playerAttacker = ToPlayer();
|
||||
@@ -2714,7 +2714,7 @@ namespace Game.Entities
|
||||
if ((bySpell == null || !bySpell.HasAttribute(SpellAttr6.CanTargetUntargetable)) && unitTarget != null && unitTarget.HasUnitFlag(UnitFlags.NonAttackable2))
|
||||
return false;
|
||||
|
||||
if (unitTarget != null && unitTarget.HasUnitFlag(UnitFlags.Uninteractible))
|
||||
if (unitTarget != null && unitTarget.IsUninteractible())
|
||||
return false;
|
||||
|
||||
// check flags for negative spells
|
||||
|
||||
@@ -3371,7 +3371,7 @@ namespace Game.Entities
|
||||
{
|
||||
Creature creature = GetMap().GetCreature(guid);
|
||||
// Update fields of triggers, transformed units or unselectable units (values dependent on GM state)
|
||||
if (creature == null || (!creature.IsTrigger() && !creature.HasAuraType(AuraType.Transform) && !creature.HasUnitFlag(UnitFlags.Uninteractible)))
|
||||
if (creature == null || (!creature.IsTrigger() && !creature.HasAuraType(AuraType.Transform) && !creature.IsUninteractible()))
|
||||
continue;
|
||||
|
||||
creature.m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.DisplayID);
|
||||
|
||||
@@ -147,7 +147,7 @@ namespace Game.Entities
|
||||
if (!IsAlive())
|
||||
return false;
|
||||
|
||||
if (HasUnitFlag(UnitFlags.NonAttackable | UnitFlags.Uninteractible))
|
||||
if (HasUnitFlag(UnitFlags.NonAttackable) || IsUninteractible())
|
||||
return false;
|
||||
|
||||
if (IsTypeId(TypeId.Player) && ToPlayer().IsGameMaster())
|
||||
|
||||
@@ -3209,6 +3209,16 @@ namespace Game.Entities
|
||||
|
||||
public virtual void SetImmuneToNPC(bool apply) { SetImmuneToNPC(apply, false); }
|
||||
|
||||
public bool IsUninteractible() { return HasUnitFlag(UnitFlags.Uninteractible); }
|
||||
|
||||
public void SetUninteractible(bool apply)
|
||||
{
|
||||
if (apply)
|
||||
SetUnitFlag(UnitFlags.Uninteractible);
|
||||
else
|
||||
RemoveUnitFlag(UnitFlags.Uninteractible);
|
||||
}
|
||||
|
||||
public virtual float GetBlockPercent(uint attackerLevel) { return 30.0f; }
|
||||
|
||||
void UpdateReactives(uint p_time)
|
||||
|
||||
@@ -365,7 +365,7 @@ namespace Game.Entities
|
||||
|
||||
// Remove UNIT_FLAG_NOT_SELECTABLE if passenger did not have it before entering vehicle
|
||||
if (seat.Value.SeatInfo.HasFlag(VehicleSeatFlags.PassengerNotSelectable) && !seat.Value.Passenger.IsUninteractible)
|
||||
unit.RemoveUnitFlag(UnitFlags.Uninteractible);
|
||||
unit.SetUninteractible(false);
|
||||
|
||||
seat.Value.Passenger.Reset();
|
||||
|
||||
@@ -642,7 +642,7 @@ namespace Game.Entities
|
||||
|
||||
Passenger.SetVehicle(Target);
|
||||
Seat.Value.Passenger.Guid = Passenger.GetGUID();
|
||||
Seat.Value.Passenger.IsUninteractible = Passenger.HasUnitFlag(UnitFlags.Uninteractible);
|
||||
Seat.Value.Passenger.IsUninteractible = Passenger.IsUninteractible();
|
||||
Seat.Value.Passenger.IsGravityDisabled = Passenger.HasUnitMovementFlag(MovementFlag.DisableGravity);
|
||||
if (Seat.Value.SeatInfo.CanEnterOrExit())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user