Changeset 233 for trunk/src/game/Player.cpp
- Timestamp:
- 11/19/08 13:49:07 (17 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/game/Player.cpp
r230 r233 428 428 429 429 m_isActive = true; 430 431 m_farsightVision = false; 430 432 } 431 433 … … 1292 1294 RemoveGuardians(); 1293 1295 1296 // remove possession 1297 if(isPossessing()) 1298 RemovePossess(false); 1299 else 1300 RemoveFarsightTarget(); 1301 1294 1302 // save value before aura remove in Unit::setDeathState 1295 1303 ressSpellId = GetUInt32Value(PLAYER_SELF_RES_SPELL); … … 1545 1553 ((Player*)GetCharmer())->RemovePossess(); 1546 1554 1547 // The player was ported to another map and looses the duel immediately. 1555 // Remove player's possession before teleporting 1556 if (isPossessing()) 1557 RemovePossess(false); 1558 1559 // Empty vision list and clear farsight (if it hasn't already been cleared by RemovePossess) before teleporting 1560 RemoveAllFromVision(); 1561 RemoveFarsightTarget(); 1562 1563 // The player was ported to another map and looses the duel immediatly. 1548 1564 // We have to perform this check before the teleport, otherwise the 1549 1565 // ObjectAccessor won't find the flag. … … 1763 1779 RemoveMiniPet(); 1764 1780 RemoveGuardians(); 1781 RemoveFarsightTarget(); 1765 1782 } 1766 1783 … … 17294 17311 return false; 17295 17312 17296 // If the player is currently possessing, update visibility from the possessed unit's location 17297 const Unit* target = isPossessing() ? GetCharm() : this; 17313 // If the player is currently channeling vision, update visibility from the target unit's location 17314 const WorldObject* target = GetFarsightTarget(); 17315 if (!target || !HasFarsightVision()) // Vision needs to be on the farsight target 17316 target = this; 17298 17317 17299 17318 // different visible distance checks … … 18744 18763 SetPossessedTarget(target); 18745 18764 18765 // Start channeling packets to possessor 18766 target->AddPlayerToVision(this); 18767 18746 18768 target->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, getFaction()); 18747 18769 target->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); … … 18749 18771 target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE); 18750 18772 SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE); 18751 SetUInt64Value(PLAYER_FARSIGHT, target->GetGUID());18752 18773 18753 18774 if(target->GetTypeId() == TYPEID_UNIT) 18754 18775 { 18755 // Set target to active in the grid and place it in the world container to be picked up by all regular player cell visits18756 Map* map = target->GetMap();18757 map->SwitchGridContainers((Creature*)target, true);18758 target->setActive(true);18759 18760 18776 ((Creature*)target)->InitPossessedAI(); // Initialize the possessed AI 18761 18777 target->StopMoving(); … … 18810 18826 RemovePossessedTarget(); 18811 18827 18828 // Stop channeling packets back to possessor 18829 target->RemovePlayerFromVision(this); 18830 18812 18831 if(target->GetTypeId() == TYPEID_PLAYER) 18813 18832 ((Player*)target)->setFactionForRace(target->getRace()); 18814 18833 else if(target->GetTypeId() == TYPEID_UNIT) 18815 18834 { 18816 // Set creature to inactive in grid and place it back into the grid container18817 Map* map = target->GetMap();18818 target->setActive(false);18819 map->SwitchGridContainers((Creature*)target, false);18820 18821 18835 if(((Creature*)target)->isPet()) 18822 18836 { … … 18832 18846 target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNKNOWN5); 18833 18847 RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE); 18834 SetUInt64Value(PLAYER_FARSIGHT, 0);18835 18848 18836 18849 // Remove pet spell action bar … … 18898 18911 } 18899 18912 18913 WorldObject* Player::GetFarsightTarget() const 18914 { 18915 // Players can have in farsight field another player's guid, a creature's guid, or a dynamic object's guid 18916 if (uint64 guid = GetUInt64Value(PLAYER_FARSIGHT)) 18917 return (WorldObject*)ObjectAccessor::GetObjectByTypeMask(*this, guid, TYPEMASK_PLAYER | TYPEMASK_UNIT | TYPEMASK_DYNAMICOBJECT); 18918 return NULL; 18919 } 18920 18921 void Player::RemoveFarsightTarget() 18922 { 18923 if (WorldObject* fTarget = GetFarsightTarget()) 18924 { 18925 if (fTarget->isType(TYPEMASK_PLAYER | TYPEMASK_UNIT)) 18926 ((Unit*)fTarget)->RemovePlayerFromVision(this); 18927 } 18928 ClearFarsight(); 18929 } 18930 18931 void Player::ClearFarsight() 18932 { 18933 if (GetUInt64Value(PLAYER_FARSIGHT)) 18934 { 18935 SetUInt64Value(PLAYER_FARSIGHT, 0); 18936 WorldPacket data(SMSG_CLEAR_FAR_SIGHT_IMMEDIATE, 0); 18937 GetSession()->SendPacket(&data); 18938 } 18939 } 18940 18941 void Player::SetFarsightTarget(WorldObject* obj) 18942 { 18943 if (!obj || !obj->isType(TYPEMASK_PLAYER | TYPEMASK_UNIT | TYPEMASK_DYNAMICOBJECT)) 18944 return; 18945 18946 // Remove the current target if there is one 18947 RemoveFarsightTarget(); 18948 18949 SetUInt64Value(PLAYER_FARSIGHT, obj->GetGUID()); 18950 } 18951 18900 18952 bool Player::isAllowUseBattleGroundObject() 18901 18953 {