mirror of
https://github.com/mangosfour/server.git
synced 2025-12-17 16:37:00 +00:00
[10053] Use UNIT_STAT_CONTROLED for mark unit state under direct player control.
* This allow prevent move home/to caster at apply * Also replace AI and reset movegens at control time * Also stop combat and clear threat/hostile list at lost control for prevent combat with freindly units.
This commit is contained in:
parent
e427ce80cc
commit
b4b45333d8
9 changed files with 60 additions and 32 deletions
|
|
@ -3619,6 +3619,8 @@ void Aura::HandleModPossess(bool apply, bool Real)
|
|||
|
||||
if( apply )
|
||||
{
|
||||
target->addUnitState(UNIT_STAT_CONTROLED);
|
||||
|
||||
target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);
|
||||
|
||||
target->SetCharmerGUID(p_caster->GetGUID());
|
||||
|
|
@ -3630,24 +3632,28 @@ void Aura::HandleModPossess(bool apply, bool Real)
|
|||
p_caster->SetClientControl(target, 1);
|
||||
p_caster->SetMover(target);
|
||||
|
||||
target->CombatStop();
|
||||
target->CombatStop(true);
|
||||
target->DeleteThreatList();
|
||||
target->getHostileRefManager().deleteReferences();
|
||||
|
||||
if(CharmInfo *charmInfo = target->InitCharmInfo(target))
|
||||
{
|
||||
charmInfo->InitPossessCreateSpells();
|
||||
charmInfo->SetReactState(REACT_PASSIVE);
|
||||
charmInfo->SetCommandState(COMMAND_STAY);
|
||||
}
|
||||
|
||||
p_caster->PossessSpellInitialize();
|
||||
|
||||
if(target->GetTypeId() == TYPEID_UNIT)
|
||||
{
|
||||
target->StopMoving();
|
||||
target->GetMotionMaster()->Clear();
|
||||
target->GetMotionMaster()->MoveIdle();
|
||||
((Creature*)target)->AIM_Initialize();
|
||||
}
|
||||
else if(target->GetTypeId() == TYPEID_PLAYER)
|
||||
{
|
||||
((Player*)target)->SetClientControl(target, 0);
|
||||
}
|
||||
|
||||
if(CharmInfo *charmInfo = target->InitCharmInfo(target))
|
||||
charmInfo->InitPossessCreateSpells();
|
||||
|
||||
p_caster->PossessSpellInitialize();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -3664,6 +3670,12 @@ void Aura::HandleModPossess(bool apply, bool Real)
|
|||
if(m_removeMode == AURA_REMOVE_BY_DELETE)
|
||||
return;
|
||||
|
||||
target->clearUnitState(UNIT_STAT_CONTROLED);
|
||||
|
||||
target->CombatStop(true);
|
||||
target->DeleteThreatList();
|
||||
target->getHostileRefManager().deleteReferences();
|
||||
|
||||
target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);
|
||||
|
||||
target->SetCharmerGUID(0);
|
||||
|
|
@ -3772,8 +3784,9 @@ void Aura::HandleModCharm(bool apply, bool Real)
|
|||
target->CastStop(target == caster ? GetId() : 0);
|
||||
caster->SetCharm(target);
|
||||
|
||||
target->CombatStop();
|
||||
target->CombatStop(true);
|
||||
target->DeleteThreatList();
|
||||
target->getHostileRefManager().deleteReferences();
|
||||
|
||||
if(target->GetTypeId() == TYPEID_UNIT)
|
||||
{
|
||||
|
|
@ -3848,6 +3861,10 @@ void Aura::HandleModCharm(bool apply, bool Real)
|
|||
if(caster->GetTypeId() == TYPEID_PLAYER)
|
||||
((Player*)caster)->RemovePetActionBar();
|
||||
|
||||
target->CombatStop(true);
|
||||
target->DeleteThreatList();
|
||||
target->getHostileRefManager().deleteReferences();
|
||||
|
||||
if(target->GetTypeId() == TYPEID_UNIT)
|
||||
{
|
||||
((Creature*)target)->AIM_Initialize();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue