Core/Unit: Some charm fixes:
Port From (https://github.com/TrinityCore/TrinityCore/commit/34f9666f209ab3f281bf81de92c4bc1a164b0059)
This commit is contained in:
@@ -732,9 +732,16 @@ namespace Game.AI
|
|||||||
else
|
else
|
||||||
me.SetWalk(!_run);
|
me.SetWalk(!_run);
|
||||||
|
|
||||||
Unit charmer = me.GetCharmer();
|
if (!me.LastCharmerGUID.IsEmpty())
|
||||||
if (charmer)
|
{
|
||||||
AttackStart(charmer);
|
if (!me.HasReactState(ReactStates.Passive))
|
||||||
|
{
|
||||||
|
Unit lastCharmer = Global.ObjAccessor.GetUnit(me, me.LastCharmerGUID);
|
||||||
|
if (lastCharmer != null)
|
||||||
|
me.EngageWithTarget(lastCharmer);
|
||||||
|
}
|
||||||
|
me.LastCharmerGUID.Clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GetScript().ProcessEventsFor(SmartEvents.Charmed, null, 0, 0, charmed);
|
GetScript().ProcessEventsFor(SmartEvents.Charmed, null, 0, 0, charmed);
|
||||||
|
|||||||
@@ -41,10 +41,11 @@ namespace Game.Entities
|
|||||||
for (var i = 0; i < SharedConst.ActionBarIndexMax; ++i)
|
for (var i = 0; i < SharedConst.ActionBarIndexMax; ++i)
|
||||||
PetActionBar[i] = new UnitActionBarEntry();
|
PetActionBar[i] = new UnitActionBarEntry();
|
||||||
|
|
||||||
if (_unit.IsTypeId(TypeId.Unit))
|
Creature creature = _unit.ToCreature();
|
||||||
|
if (creature != null)
|
||||||
{
|
{
|
||||||
_oldReactState = _unit.ToCreature().GetReactState();
|
_oldReactState = creature.GetReactState();
|
||||||
_unit.ToCreature().SetReactState(ReactStates.Passive);
|
creature.SetReactState(ReactStates.Passive);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -329,13 +329,6 @@ namespace Game.Entities
|
|||||||
GetMotionMaster().Clear(MovementGeneratorPriority.Normal);
|
GetMotionMaster().Clear(MovementGeneratorPriority.Normal);
|
||||||
|
|
||||||
StopMoving();
|
StopMoving();
|
||||||
|
|
||||||
// AI will schedule its own change if appropriate
|
|
||||||
UnitAI ai = GetAI();
|
|
||||||
if (ai != null)
|
|
||||||
ai.OnCharmed(false);
|
|
||||||
else
|
|
||||||
ScheduleAIChange();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -345,16 +338,6 @@ namespace Game.Entities
|
|||||||
if (player.IsAFK())
|
if (player.IsAFK())
|
||||||
player.ToggleAFK();
|
player.ToggleAFK();
|
||||||
|
|
||||||
if (charmer.IsTypeId(TypeId.Unit)) // we are charmed by a creature
|
|
||||||
{
|
|
||||||
// change AI to charmed AI on next Update tick
|
|
||||||
UnitAI ai = GetAI();
|
|
||||||
if (ai != null)
|
|
||||||
ai.OnCharmed(false);
|
|
||||||
else
|
|
||||||
player.ScheduleAIChange();
|
|
||||||
}
|
|
||||||
|
|
||||||
player.SetClientControl(this, false);
|
player.SetClientControl(this, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -416,6 +399,16 @@ namespace Game.Entities
|
|||||||
}
|
}
|
||||||
|
|
||||||
AddUnitState(UnitState.Charmed);
|
AddUnitState(UnitState.Charmed);
|
||||||
|
|
||||||
|
if (!IsPlayer() || !charmer.IsPlayer())
|
||||||
|
{
|
||||||
|
// AI will schedule its own change if appropriate
|
||||||
|
UnitAI ai = GetAI();
|
||||||
|
if (ai != null)
|
||||||
|
ai.OnCharmed(false);
|
||||||
|
else
|
||||||
|
ScheduleAIChange();
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -424,10 +417,12 @@ namespace Game.Entities
|
|||||||
if (!IsCharmed())
|
if (!IsCharmed())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!charmer)
|
if (charmer)
|
||||||
|
Cypher.Assert(charmer == GetCharmer());
|
||||||
|
else
|
||||||
charmer = GetCharmer();
|
charmer = GetCharmer();
|
||||||
if (charmer != GetCharmer()) // one aura overrides another?
|
|
||||||
return;
|
Cypher.Assert(charmer);
|
||||||
|
|
||||||
CharmType type;
|
CharmType type;
|
||||||
if (HasUnitState(UnitState.Possessed))
|
if (HasUnitState(UnitState.Possessed))
|
||||||
@@ -455,10 +450,6 @@ namespace Game.Entities
|
|||||||
if (type != CharmType.Vehicle)
|
if (type != CharmType.Vehicle)
|
||||||
LastCharmerGUID = charmer.GetGUID();
|
LastCharmerGUID = charmer.GetGUID();
|
||||||
|
|
||||||
// If charmer still exists
|
|
||||||
if (!charmer)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Cypher.Assert(type != CharmType.Possess || charmer.IsTypeId(TypeId.Player));
|
Cypher.Assert(type != CharmType.Possess || charmer.IsTypeId(TypeId.Player));
|
||||||
Cypher.Assert(type != CharmType.Vehicle || (IsTypeId(TypeId.Unit) && IsVehicle()));
|
Cypher.Assert(type != CharmType.Vehicle || (IsTypeId(TypeId.Unit) && IsVehicle()));
|
||||||
|
|
||||||
@@ -500,6 +491,20 @@ namespace Game.Entities
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Player player = ToPlayer();
|
||||||
|
if (player != null)
|
||||||
|
player.SetClientControl(this, true);
|
||||||
|
|
||||||
|
if (playerCharmer && this != charmer.GetFirstControlled())
|
||||||
|
playerCharmer.SendRemoveControlBar();
|
||||||
|
|
||||||
|
// a guardian should always have charminfo
|
||||||
|
if (!IsGuardian())
|
||||||
|
DeleteCharmInfo();
|
||||||
|
|
||||||
|
// reset confused movement for example
|
||||||
|
ApplyControlStatesIfNeeded();
|
||||||
|
|
||||||
if (!IsPlayer() || charmer.IsCreature())
|
if (!IsPlayer() || charmer.IsCreature())
|
||||||
{
|
{
|
||||||
UnitAI charmedAI = GetAI();
|
UnitAI charmedAI = GetAI();
|
||||||
@@ -508,19 +513,6 @@ namespace Game.Entities
|
|||||||
else
|
else
|
||||||
ScheduleAIChange();
|
ScheduleAIChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
Player player = ToPlayer();
|
|
||||||
if (player != null)
|
|
||||||
player.SetClientControl(this, true);
|
|
||||||
|
|
||||||
// a guardian should always have charminfo
|
|
||||||
if (playerCharmer && this != charmer.GetFirstControlled())
|
|
||||||
playerCharmer.SendRemoveControlBar();
|
|
||||||
else if (IsTypeId(TypeId.Player) || (IsTypeId(TypeId.Unit) && !IsGuardian()))
|
|
||||||
DeleteCharmInfo();
|
|
||||||
|
|
||||||
// reset confused movement for example
|
|
||||||
ApplyControlStatesIfNeeded();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GetAllMinionsByEntry(List<TempSummon> Minions, uint entry)
|
public void GetAllMinionsByEntry(List<TempSummon> Minions, uint entry)
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ namespace Game.Movement
|
|||||||
if (owner == null)
|
if (owner == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (owner.HasUnitState(UnitState.NotMove) || owner.IsMovementPreventedByCasting())
|
if (owner.HasUnitState(UnitState.NotMove | UnitState.LostControl) || owner.IsMovementPreventedByCasting())
|
||||||
{
|
{
|
||||||
AddFlag(MovementGeneratorFlags.Interrupted);
|
AddFlag(MovementGeneratorFlags.Interrupted);
|
||||||
owner.StopMoving();
|
owner.StopMoving();
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ namespace Game.Movement
|
|||||||
if (HasFlag(MovementGeneratorFlags.Finalized | MovementGeneratorFlags.Paused) || _path == null || _path.nodes.Empty())
|
if (HasFlag(MovementGeneratorFlags.Finalized | MovementGeneratorFlags.Paused) || _path == null || _path.nodes.Empty())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (owner.HasUnitState(UnitState.NotMove) || owner.IsMovementPreventedByCasting())
|
if (owner.HasUnitState(UnitState.NotMove | UnitState.LostControl) || owner.IsMovementPreventedByCasting())
|
||||||
{
|
{
|
||||||
AddFlag(MovementGeneratorFlags.Interrupted);
|
AddFlag(MovementGeneratorFlags.Interrupted);
|
||||||
owner.StopMoving();
|
owner.StopMoving();
|
||||||
|
|||||||
Reference in New Issue
Block a user