Core/Unit: Some charm fixes:
Port From (https://github.com/TrinityCore/TrinityCore/commit/34f9666f209ab3f281bf81de92c4bc1a164b0059)
This commit is contained in:
@@ -41,10 +41,11 @@ namespace Game.Entities
|
||||
for (var i = 0; i < SharedConst.ActionBarIndexMax; ++i)
|
||||
PetActionBar[i] = new UnitActionBarEntry();
|
||||
|
||||
if (_unit.IsTypeId(TypeId.Unit))
|
||||
Creature creature = _unit.ToCreature();
|
||||
if (creature != null)
|
||||
{
|
||||
_oldReactState = _unit.ToCreature().GetReactState();
|
||||
_unit.ToCreature().SetReactState(ReactStates.Passive);
|
||||
_oldReactState = creature.GetReactState();
|
||||
creature.SetReactState(ReactStates.Passive);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -329,13 +329,6 @@ namespace Game.Entities
|
||||
GetMotionMaster().Clear(MovementGeneratorPriority.Normal);
|
||||
|
||||
StopMoving();
|
||||
|
||||
// AI will schedule its own change if appropriate
|
||||
UnitAI ai = GetAI();
|
||||
if (ai != null)
|
||||
ai.OnCharmed(false);
|
||||
else
|
||||
ScheduleAIChange();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -345,16 +338,6 @@ namespace Game.Entities
|
||||
if (player.IsAFK())
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -416,6 +399,16 @@ namespace Game.Entities
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -424,10 +417,12 @@ namespace Game.Entities
|
||||
if (!IsCharmed())
|
||||
return;
|
||||
|
||||
if (!charmer)
|
||||
if (charmer)
|
||||
Cypher.Assert(charmer == GetCharmer());
|
||||
else
|
||||
charmer = GetCharmer();
|
||||
if (charmer != GetCharmer()) // one aura overrides another?
|
||||
return;
|
||||
|
||||
Cypher.Assert(charmer);
|
||||
|
||||
CharmType type;
|
||||
if (HasUnitState(UnitState.Possessed))
|
||||
@@ -455,10 +450,6 @@ namespace Game.Entities
|
||||
if (type != CharmType.Vehicle)
|
||||
LastCharmerGUID = charmer.GetGUID();
|
||||
|
||||
// If charmer still exists
|
||||
if (!charmer)
|
||||
return;
|
||||
|
||||
Cypher.Assert(type != CharmType.Possess || charmer.IsTypeId(TypeId.Player));
|
||||
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())
|
||||
{
|
||||
UnitAI charmedAI = GetAI();
|
||||
@@ -508,19 +513,6 @@ namespace Game.Entities
|
||||
else
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user