Core/Units: Added helper functions to modify UNIT_FLAG_UNINTERACTIBLE
Port From (https://github.com/TrinityCore/TrinityCore/commit/88ff97c1f96381565c47f8ca1993bdc7fce19fd6)
This commit is contained in:
@@ -374,7 +374,7 @@ namespace Game.AI
|
||||
point.SetUnitFlag(UnitFlags.Stunned);
|
||||
point.SetImmuneToAll(true);
|
||||
if (!hasOutOfBoundsNeighbor)
|
||||
point.SetUnitFlag(UnitFlags.Uninteractible);
|
||||
point.SetUninteractible(true);
|
||||
}
|
||||
Q.Remove(front);
|
||||
}
|
||||
|
||||
@@ -2408,15 +2408,8 @@ namespace Game.AI
|
||||
case SmartActions.SetUninteractible:
|
||||
{
|
||||
foreach (var target in targets)
|
||||
{
|
||||
if (IsUnit(target))
|
||||
{
|
||||
if (e.Action.setUninteractible.uninteractible != 0)
|
||||
target.ToUnit().SetUnitFlag(UnitFlags.Uninteractible);
|
||||
else
|
||||
target.ToUnit().RemoveUnitFlag(UnitFlags.Uninteractible);
|
||||
}
|
||||
}
|
||||
target.ToUnit().SetUninteractible(e.Action.setUninteractible.uninteractible != 0);
|
||||
break;
|
||||
}
|
||||
case SmartActions.ActivateGameobject:
|
||||
|
||||
@@ -461,7 +461,8 @@ namespace Game.BattleFields
|
||||
{
|
||||
creature.CombatStop();
|
||||
creature.SetReactState(ReactStates.Passive);
|
||||
creature.SetUnitFlag(UnitFlags.NonAttackable | UnitFlags.Uninteractible);
|
||||
creature.SetUnitFlag(UnitFlags.NonAttackable);
|
||||
creature.SetUninteractible(true);
|
||||
creature.DisappearAndDie();
|
||||
creature.SetVisible(false);
|
||||
}
|
||||
@@ -469,7 +470,8 @@ namespace Game.BattleFields
|
||||
public void ShowNpc(Creature creature, bool aggressive)
|
||||
{
|
||||
creature.SetVisible(true);
|
||||
creature.RemoveUnitFlag(UnitFlags.NonAttackable | UnitFlags.Uninteractible);
|
||||
creature.RemoveUnitFlag(UnitFlags.NonAttackable);
|
||||
creature.SetUninteractible(false);
|
||||
if (!creature.IsAlive())
|
||||
creature.Respawn(true);
|
||||
if (aggressive)
|
||||
|
||||
@@ -629,9 +629,15 @@ namespace Game.BattleGrounds.Zones
|
||||
if (dem)
|
||||
{
|
||||
if (start)
|
||||
dem.SetUnitFlag(UnitFlags.NonAttackable | UnitFlags.Uninteractible);
|
||||
{
|
||||
dem.SetUnitFlag(UnitFlags.NonAttackable);
|
||||
dem.SetUninteractible(true);
|
||||
}
|
||||
else
|
||||
dem.RemoveUnitFlag(UnitFlags.NonAttackable | UnitFlags.Uninteractible);
|
||||
{
|
||||
dem.RemoveUnitFlag(UnitFlags.NonAttackable);
|
||||
dem.SetUninteractible(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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