mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-20 09:17:36 +01:00
*Set pvp flags for units controlled by player.
*Reset pvp flags when unit is uncharmed. *Remove walk flag when unit is charmed. --HG-- branch : trunk
This commit is contained in:
@@ -8341,10 +8341,10 @@ void Unit::SetMinion(Minion *minion, bool apply)
|
||||
//else if(minion->m_Properties && minion->m_Properties->Type == SUMMON_TYPE_MINIPET)
|
||||
// AddUInt64Value(UNIT_FIELD_CRITTER, minion->GetGUID());
|
||||
|
||||
// FIXME: hack, speed must be set only at follow
|
||||
if(HasByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP))
|
||||
minion->SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
|
||||
// PvP, FFAPvP
|
||||
minion->SetByteValue(UNIT_FIELD_BYTES_2, 1, GetByteValue(UNIT_FIELD_BYTES_2, 1));
|
||||
|
||||
// FIXME: hack, speed must be set only at follow
|
||||
if(GetTypeId() == TYPEID_PLAYER && minion->HasSummonMask(SUMMON_MASK_PET))
|
||||
for(int i = 0; i < MAX_MOVE_TYPE; ++i)
|
||||
minion->SetSpeed(UnitMoveType(i), m_speed_rate[i], true);
|
||||
@@ -8411,13 +8411,24 @@ void Unit::SetCharm(Unit* charm, bool apply)
|
||||
sLog.outCrash("Player %s is trying to charm unit %u, but it already has a charmed unit %u", GetName(), charm->GetEntry(), GetCharmGUID());
|
||||
|
||||
charm->m_ControlledByPlayer = true;
|
||||
// TODO: maybe we can use this flag to check if controlled by player
|
||||
charm->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE);
|
||||
}
|
||||
else
|
||||
charm->m_ControlledByPlayer = false;
|
||||
|
||||
// PvP, FFAPvP
|
||||
charm->SetByteValue(UNIT_FIELD_BYTES_2, 1, GetByteValue(UNIT_FIELD_BYTES_2, 1));
|
||||
|
||||
if(!charm->AddUInt64Value(UNIT_FIELD_CHARMEDBY, GetGUID()))
|
||||
sLog.outCrash("Unit %u is being charmed, but it already has a charmer %u", charm->GetEntry(), charm->GetCharmerGUID());
|
||||
|
||||
if(charm->HasUnitMovementFlag(MOVEMENTFLAG_WALK_MODE))
|
||||
{
|
||||
charm->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
|
||||
charm->SendMovementFlagUpdate();
|
||||
}
|
||||
|
||||
m_Controlled.insert(charm);
|
||||
}
|
||||
else
|
||||
@@ -8428,10 +8439,24 @@ void Unit::SetCharm(Unit* charm, bool apply)
|
||||
sLog.outCrash("Player %s is trying to uncharm unit %u, but it has another charmed unit %u", GetName(), charm->GetEntry(), GetCharmGUID());
|
||||
}
|
||||
|
||||
if(charm->GetTypeId() == TYPEID_PLAYER || IS_PLAYER_GUID(charm->GetOwnerGUID()))
|
||||
if(charm->GetTypeId() == TYPEID_PLAYER)
|
||||
{
|
||||
charm->m_ControlledByPlayer = true;
|
||||
charm->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE);
|
||||
((Player*)charm)->UpdatePvPState();
|
||||
}
|
||||
else if(Player *player = charm->GetCharmerOrOwnerPlayerOrPlayerItself())
|
||||
{
|
||||
charm->m_ControlledByPlayer = true;
|
||||
charm->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE);
|
||||
charm->SetByteValue(UNIT_FIELD_BYTES_2, 1, player->GetByteValue(UNIT_FIELD_BYTES_2, 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
charm->m_ControlledByPlayer = false;
|
||||
charm->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE);
|
||||
charm->SetByteValue(UNIT_FIELD_BYTES_2, 1, 0);
|
||||
}
|
||||
|
||||
if(!charm->RemoveUInt64Value(UNIT_FIELD_CHARMEDBY, GetGUID()))
|
||||
sLog.outCrash("Unit %u is being uncharmed, but it has another charmer %u", charm->GetEntry(), charm->GetCharmerGUID());
|
||||
@@ -13389,7 +13414,6 @@ void Unit::SetCharmedOrPossessedBy(Unit* charmer, bool possess)
|
||||
if(GetTypeId() == TYPEID_PLAYER && ((Player*)this)->GetTransport())
|
||||
return;
|
||||
|
||||
RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
|
||||
CastStop();
|
||||
CombatStop(); //TODO: CombatStop(true) may cause crash (interrupt spells)
|
||||
DeleteThreatList();
|
||||
@@ -13414,7 +13438,6 @@ void Unit::SetCharmedOrPossessedBy(Unit* charmer, bool possess)
|
||||
|
||||
// Set charmed
|
||||
setFaction(charmer->getFaction());
|
||||
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE);
|
||||
charmer->SetCharm(this, true);
|
||||
|
||||
if(GetTypeId() == TYPEID_UNIT)
|
||||
|
||||
Reference in New Issue
Block a user