[8147] Some fixes and cleanups in mind control and charmed code. Mind control stil not finished.

* Allow command to mind controlled unit attack target at client. Rename related flag to UNIT_FLAG_PLAYER_CONTROLLED.
* Move code for pet action bar remove at client side to new function Player::RemovePetActionBar
* Not allow cast spells with SPELL_AURA_MOD_POSSESS and SPELL_AURA_MOD_POSSESS_PET by non-players and simplify related code base at this.
This commit is contained in:
VladimirMangos 2009-07-08 17:50:02 +04:00
parent 1ad013e25b
commit 3bfe549a2b
7 changed files with 153 additions and 125 deletions

View file

@ -16359,9 +16359,7 @@ void Player::RemovePet(Pet* pet, PetSaveMode mode, bool returnreagent)
if(pet->isControlled())
{
WorldPacket data(SMSG_PET_SPELLS, 8);
data << uint64(0);
GetSession()->SendPacket(&data);
RemovePetActionBar();
if(GetGroup())
SetGroupUpdateFlag(GROUP_UPDATE_PET);
@ -16623,6 +16621,13 @@ void Player::CharmSpellInitialize()
GetSession()->SendPacket(&data);
}
void Player::RemovePetActionBar()
{
WorldPacket data(SMSG_PET_SPELLS, 8);
data << uint64(0);
SendDirectMessage(&data);
}
bool Player::IsAffectedBySpellmod(SpellEntry const *spellInfo, SpellModifier *mod, Spell const* spell)
{
if (!mod || !spellInfo)
@ -19380,7 +19385,7 @@ void Player::EnterVehicle(Vehicle *vehicle)
vehicle->SetCharmerGUID(GetGUID());
vehicle->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK);
vehicle->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNK_24);
vehicle->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);
vehicle->setFaction(getFaction());
SetCharm(vehicle); // charm
@ -19432,7 +19437,7 @@ void Player::ExitVehicle(Vehicle *vehicle)
{
vehicle->SetCharmerGUID(0);
vehicle->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK);
vehicle->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNK_24);
vehicle->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);
vehicle->setFaction((GetTeam() == ALLIANCE) ? vehicle->GetCreatureInfo()->faction_A : vehicle->GetCreatureInfo()->faction_H);
SetCharm(NULL);
@ -19454,9 +19459,7 @@ void Player::ExitVehicle(Vehicle *vehicle)
data << uint32(0); // fall time
GetSession()->SendPacket(&data);
data.Initialize(SMSG_PET_SPELLS, 8);
data << uint64(0);
GetSession()->SendPacket(&data);
RemovePetActionBar();
// maybe called at dummy aura remove?
// CastSpell(this, 45472, true); // Parachute