*Update bind sight spells code.
--HG-- branch : trunk
This commit is contained in:
+1
-1
@@ -220,6 +220,6 @@ bool Corpse::LoadFromDB(uint32 guid, Field *fields)
|
||||
|
||||
bool Corpse::isVisibleForInState(Player const* u, bool inVisibleList) const
|
||||
{
|
||||
return IsInWorld() && u->IsInWorld() && IsWithinDistInMap(u,World::GetMaxVisibleDistanceForObject()+(inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f), false);
|
||||
return IsInWorld() && u->IsInWorld() && IsWithinDistInMap(u->m_seer,World::GetMaxVisibleDistanceForObject()+(inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f), false);
|
||||
}
|
||||
|
||||
|
||||
@@ -142,7 +142,6 @@ void DynamicObject::Delay(int32 delaytime)
|
||||
bool DynamicObject::isVisibleForInState(Player const* u, bool inVisibleList) const
|
||||
{
|
||||
return IsInWorld() && u->IsInWorld()
|
||||
&& (IsWithinDistInMap(u,World::GetMaxVisibleDistanceForObject()+(inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f), false)
|
||||
|| GetCasterGUID() == u->GetGUID());
|
||||
&& (IsWithinDistInMap(u->m_seer,World::GetMaxVisibleDistanceForObject()+(inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f), false));
|
||||
}
|
||||
|
||||
|
||||
@@ -754,7 +754,7 @@ bool GameObject::isVisibleForInState(Player const* u, bool inVisibleList) const
|
||||
}
|
||||
|
||||
// check distance
|
||||
return IsWithinDistInMap(u,World::GetMaxVisibleDistanceForObject() +
|
||||
return IsWithinDistInMap(u->m_seer,World::GetMaxVisibleDistanceForObject() +
|
||||
(inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f), false);
|
||||
}
|
||||
|
||||
|
||||
@@ -1433,21 +1433,15 @@ void WorldSession::HandleFarSightOpcode( WorldPacket & recv_data )
|
||||
uint8 apply;
|
||||
recv_data >> apply;
|
||||
|
||||
CellPair pair;
|
||||
|
||||
switch(apply)
|
||||
{
|
||||
case 0:
|
||||
_player->SetFarsightVision(false);
|
||||
pair = Trinity::ComputeCellPair(_player->GetPositionX(), _player->GetPositionY());
|
||||
sLog.outDebug("Player %u set vision to himself", _player->GetGUIDLow());
|
||||
_player->SetSeer(_player);
|
||||
sLog.outDebug("Player %u set vision to self", _player->GetGUIDLow());
|
||||
break;
|
||||
case 1:
|
||||
_player->SetFarsightVision(true);
|
||||
if (WorldObject* obj = _player->GetFarsightTarget())
|
||||
pair = Trinity::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY());
|
||||
else
|
||||
return;
|
||||
_player->SetSeer(_player->GetFarsightTarget());
|
||||
sLog.outDebug("Added FarSight " I64FMT " to player %u", _player->GetFarSightGUID(), _player->GetGUIDLow());
|
||||
break;
|
||||
default:
|
||||
|
||||
+2
-2
@@ -50,14 +50,14 @@ enum TypeMask
|
||||
TYPEMASK_OBJECT = 0x0001,
|
||||
TYPEMASK_ITEM = 0x0002,
|
||||
TYPEMASK_CONTAINER = 0x0006, // TYPEMASK_ITEM | 0x0004
|
||||
TYPEMASK_UNIT = 0x0008,
|
||||
TYPEMASK_UNIT = 0x0008, //creature or player
|
||||
TYPEMASK_PLAYER = 0x0010,
|
||||
TYPEMASK_GAMEOBJECT = 0x0020,
|
||||
TYPEMASK_DYNAMICOBJECT = 0x0040,
|
||||
TYPEMASK_CORPSE = 0x0080,
|
||||
TYPEMASK_AIGROUP = 0x0100,
|
||||
TYPEMASK_AREATRIGGER = 0x0200,
|
||||
TYPEMASK_FARSIGHTOBJ = TYPEMASK_PLAYER | TYPEMASK_UNIT | TYPEMASK_DYNAMICOBJECT
|
||||
TYPEMASK_SEER = TYPEMASK_UNIT | TYPEMASK_DYNAMICOBJECT
|
||||
};
|
||||
|
||||
enum TypeID
|
||||
|
||||
+34
-26
@@ -455,7 +455,8 @@ Player::Player (WorldSession *session): Unit(), m_achievementMgr(this)
|
||||
//Default movement to run mode
|
||||
m_unit_movement_flags = 0;
|
||||
|
||||
m_mover = NULL;
|
||||
m_mover = this;
|
||||
m_seer = this;
|
||||
|
||||
m_miniPet = 0;
|
||||
m_bgAfkReportedTimer = 0;
|
||||
@@ -14936,14 +14937,13 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
|
||||
|
||||
// clear charm/summon related fields
|
||||
SetCharm(NULL);
|
||||
SetMover(NULL);
|
||||
SetMover(this);
|
||||
SetPet(NULL);
|
||||
SetCharmerGUID(0);
|
||||
SetOwnerGUID(0);
|
||||
SetCreatorGUID(0);
|
||||
|
||||
// reset some aura modifiers before aura apply
|
||||
SetFarSightGUID(0);
|
||||
SetUInt32Value(PLAYER_TRACK_CREATURES, 0 );
|
||||
SetUInt32Value(PLAYER_TRACK_RESOURCES, 0 );
|
||||
|
||||
@@ -18571,9 +18571,9 @@ bool Player::canSeeOrDetect(Unit const* u, bool detect, bool inVisibleList, bool
|
||||
return false;
|
||||
|
||||
// If the player is currently channeling vision, update visibility from the target unit's location
|
||||
const WorldObject* target = GetFarsightTarget();
|
||||
if (!target || !HasFarsightVision()) // Vision needs to be on the farsight target
|
||||
target = this;
|
||||
const WorldObject* target = m_seer;
|
||||
//if (!target || !HasFarsightVision()) // Vision needs to be on the farsight target
|
||||
// target = this;
|
||||
|
||||
// different visible distance checks
|
||||
if(isInFlight()) // what see player in flight
|
||||
@@ -18973,6 +18973,7 @@ void Player::SendInitialPacketsBeforeAddToMap()
|
||||
AddUnitMovementFlag(MOVEMENTFLAG_FLYING2);
|
||||
|
||||
m_mover = this;
|
||||
m_seer = this;
|
||||
}
|
||||
|
||||
void Player::SendInitialPacketsAfterAddToMap()
|
||||
@@ -20141,7 +20142,7 @@ WorldObject* Player::GetFarsightTarget() const
|
||||
{
|
||||
// Players can have in farsight field another player's guid, a creature's guid, or a dynamic object's guid
|
||||
if(uint64 guid = GetFarSightGUID())
|
||||
return (WorldObject*)ObjectAccessor::GetObjectByTypeMask(*this, guid, TYPEMASK_FARSIGHTOBJ);
|
||||
return (WorldObject*)ObjectAccessor::GetObjectByTypeMask(*this, guid, TYPEMASK_SEER);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -20149,30 +20150,39 @@ void Player::StopCastingBindSight()
|
||||
{
|
||||
if (WorldObject* target = GetFarsightTarget())
|
||||
{
|
||||
if (target->isType(TYPEMASK_PLAYER | TYPEMASK_UNIT))
|
||||
if (target->isType(TYPEMASK_UNIT))
|
||||
((Unit*)target)->RemoveSpellsCausingAura(SPELL_AURA_BIND_SIGHT);
|
||||
}
|
||||
}
|
||||
|
||||
void Player::ClearFarsight()
|
||||
void Player::SetSeer(WorldObject* target)
|
||||
{
|
||||
if(GetFarSightGUID())
|
||||
{
|
||||
SetFarSightGUID(0);
|
||||
WorldPacket data(SMSG_CLEAR_FAR_SIGHT_IMMEDIATE, 0);
|
||||
GetSession()->SendPacket(&data);
|
||||
}
|
||||
}
|
||||
|
||||
void Player::SetFarsightTarget(WorldObject* obj)
|
||||
{
|
||||
if (!obj || !obj->isType(TYPEMASK_PLAYER | TYPEMASK_UNIT | TYPEMASK_DYNAMICOBJECT))
|
||||
if(target == m_seer)
|
||||
return;
|
||||
|
||||
// Remove the current target if there is one
|
||||
StopCastingBindSight();
|
||||
sLog.outDebug("Player::SetSeer: Player %s set object %u (TypeId: %u) as seer.", GetName(), target->GetEntry(), target->GetTypeId());
|
||||
|
||||
SetFarSightGUID(obj->GetGUID());
|
||||
if(target == this)
|
||||
{
|
||||
if(GetFarSightGUID())
|
||||
{
|
||||
SetFarSightGUID(0);
|
||||
WorldPacket data(SMSG_CLEAR_FAR_SIGHT_IMMEDIATE, 0);
|
||||
GetSession()->SendPacket(&data);
|
||||
}
|
||||
|
||||
if(m_seer->isType(TYPEMASK_UNIT))
|
||||
((Unit*)m_seer)->RemovePlayerFromVision(this);
|
||||
}
|
||||
else if(target->isType(TYPEMASK_SEER))
|
||||
{
|
||||
StopCastingBindSight();
|
||||
SetFarSightGUID(target->GetGUID());
|
||||
|
||||
if(target->isType(TYPEMASK_UNIT))
|
||||
((Unit*)target)->AddPlayerToVision(this);
|
||||
}
|
||||
m_seer = target;
|
||||
}
|
||||
|
||||
bool Player::CanUseBattleGroundObject()
|
||||
@@ -20270,7 +20280,6 @@ void Player::EnterVehicle(Vehicle *vehicle)
|
||||
|
||||
SetCharm(vehicle); // charm
|
||||
SetMover(vehicle);
|
||||
SetFarSightGUID(vehicle->GetGUID()); // set view
|
||||
|
||||
SetClientControl(vehicle, 1); // redirect controls to vehicle
|
||||
|
||||
@@ -20321,8 +20330,7 @@ void Player::ExitVehicle(Vehicle *vehicle)
|
||||
vehicle->setFaction((GetTeam() == ALLIANCE) ? vehicle->GetCreatureInfo()->faction_A : vehicle->GetCreatureInfo()->faction_H);
|
||||
|
||||
SetCharm(NULL);
|
||||
SetMover(NULL);
|
||||
SetFarSightGUID(0);
|
||||
SetMover(this);
|
||||
|
||||
SetClientControl(vehicle, 0);
|
||||
|
||||
|
||||
+3
-3
@@ -2030,6 +2030,7 @@ class TRINITY_DLL_SPEC Player : public Unit
|
||||
uint32 m_lastFallTime;
|
||||
float m_lastFallZ;
|
||||
Unit *m_mover;
|
||||
WorldObject *m_seer;
|
||||
void SetFallInformation(uint32 time, float z)
|
||||
{
|
||||
m_lastFallTime = time;
|
||||
@@ -2051,14 +2052,13 @@ class TRINITY_DLL_SPEC Player : public Unit
|
||||
void EnterVehicle(Vehicle *vehicle);
|
||||
void ExitVehicle(Vehicle *vehicle);
|
||||
|
||||
void SetMover(Unit* target) { m_mover = target ? target : this; }
|
||||
void SetMover(Unit* target) { SetSeer(target); m_mover = target; }
|
||||
void SetSeer(WorldObject *target);
|
||||
void StopCastingCharm() { Uncharm(); }
|
||||
void StopCastingBindSight();
|
||||
uint64 GetFarSightGUID() const { return GetUInt64Value(PLAYER_FARSIGHT); }
|
||||
void SetFarSightGUID(uint64 guid) { SetUInt64Value(PLAYER_FARSIGHT, guid); }
|
||||
WorldObject* GetFarsightTarget() const;
|
||||
void ClearFarsight();
|
||||
void SetFarsightTarget(WorldObject* target);
|
||||
// Controls if vision is currently on farsight object, updated in FAR_SIGHT opcode
|
||||
void SetFarsightVision(bool apply) { m_farsightVision = apply; }
|
||||
bool HasFarsightVision() const { return m_farsightVision; }
|
||||
|
||||
@@ -1918,7 +1918,7 @@ void Aura::HandleAuraDummy(bool apply, bool Real)
|
||||
if( m_target->GetTypeId() == TYPEID_PLAYER && GetSpellProto()->Effect[0]==72 )
|
||||
{
|
||||
// spells with SpellEffect=72 and aura=4: 6196, 6197, 21171, 21425
|
||||
((Player*)m_target)->ClearFarsight();
|
||||
((Player*)m_target)->SetSeer(m_target);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2819,19 +2819,17 @@ void Aura::HandleBindSight(bool apply, bool Real)
|
||||
if(!caster || caster->GetTypeId() != TYPEID_PLAYER)
|
||||
return;
|
||||
|
||||
if(apply)
|
||||
m_target->AddPlayerToVision((Player*)caster);
|
||||
else
|
||||
m_target->RemovePlayerFromVision((Player*)caster);
|
||||
((Player*)caster)->SetSeer(apply ? m_target : caster);
|
||||
}
|
||||
|
||||
void Aura::HandleFarSight(bool apply, bool Real)
|
||||
{
|
||||
Unit* caster = GetCaster();
|
||||
//Handled by client
|
||||
/*Unit* caster = GetCaster();
|
||||
if(!caster || caster->GetTypeId() != TYPEID_PLAYER)
|
||||
return;
|
||||
|
||||
((Player*)caster)->SetFarSightGUID(apply ? m_target->GetGUID() : 0);
|
||||
((Player*)caster)->SetFarSightGUID(apply ? m_target->GetGUID() : 0);*/
|
||||
}
|
||||
|
||||
void Aura::HandleAuraTrackCreatures(bool apply, bool Real)
|
||||
|
||||
@@ -3648,8 +3648,8 @@ void Spell::EffectAddFarsight(uint32 i)
|
||||
dynObj->GetMap()->Add(dynObj); //grid will also be loaded
|
||||
|
||||
// Need to update visibility of object for client to accept farsight guid
|
||||
((Player*)m_caster)->UpdateVisibilityOf(dynObj);
|
||||
((Player*)m_caster)->SetFarsightTarget(dynObj);
|
||||
((Player*)m_caster)->SetSeer(dynObj);
|
||||
//((Player*)m_caster)->UpdateVisibilityOf(dynObj);
|
||||
}
|
||||
|
||||
void Spell::EffectSummonWild(uint32 i)
|
||||
|
||||
+3
-5
@@ -8136,6 +8136,7 @@ Unit* Unit::GetNextRandomRaidMemberOrPet(float radius)
|
||||
return nearMembers[randTarget];
|
||||
}
|
||||
|
||||
//only called in Player::SetSeer
|
||||
void Unit::AddPlayerToVision(Player* plr)
|
||||
{
|
||||
if(m_sharedVision.empty())
|
||||
@@ -8144,9 +8145,9 @@ void Unit::AddPlayerToVision(Player* plr)
|
||||
SetWorldObject(true);
|
||||
}
|
||||
m_sharedVision.push_back(plr);
|
||||
plr->SetFarsightTarget(this);
|
||||
}
|
||||
|
||||
//only called in Player::SetSeer
|
||||
void Unit::RemovePlayerFromVision(Player* plr)
|
||||
{
|
||||
m_sharedVision.remove(plr);
|
||||
@@ -8155,7 +8156,6 @@ void Unit::RemovePlayerFromVision(Player* plr)
|
||||
setActive(false);
|
||||
SetWorldObject(false);
|
||||
}
|
||||
plr->ClearFarsight();
|
||||
}
|
||||
|
||||
void Unit::RemoveBindSightAuras()
|
||||
@@ -10765,7 +10765,7 @@ Unit* Unit::GetUnit(WorldObject& object, uint64 guid)
|
||||
|
||||
bool Unit::isVisibleForInState( Player const* u, bool inVisibleList ) const
|
||||
{
|
||||
return isVisibleForOrDetect(u, false, inVisibleList, false);
|
||||
return u->canSeeOrDetect(this, false, inVisibleList, false);
|
||||
}
|
||||
|
||||
uint32 Unit::GetCreatureType() const
|
||||
@@ -13018,7 +13018,6 @@ void Unit::SetCharmedOrPossessedBy(Unit* charmer, bool possess)
|
||||
{
|
||||
addUnitState(UNIT_STAT_POSSESSED);
|
||||
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNK_24);
|
||||
AddPlayerToVision((Player*)charmer);
|
||||
((Player*)charmer)->SetClientControl(this, 1);
|
||||
((Player*)charmer)->SetMover(this);
|
||||
charmer->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE);
|
||||
@@ -13101,7 +13100,6 @@ void Unit::RemoveCharmedOrPossessedBy(Unit *charmer)
|
||||
charmer->SetCharm(0);
|
||||
if(possess)
|
||||
{
|
||||
RemovePlayerFromVision((Player*)charmer);
|
||||
((Player*)charmer)->SetClientControl(charmer, 1);
|
||||
((Player*)charmer)->SetMover(charmer);
|
||||
charmer->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE);
|
||||
|
||||
+1
-1
@@ -1344,7 +1344,7 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
|
||||
void DestroyForNearbyPlayers();
|
||||
|
||||
// common function for visibility checks for player/creatures with detection code
|
||||
virtual bool canSeeOrDetect(Unit const* u, bool detect, bool inVisibleList = false, bool is3dDistance = true) const;
|
||||
virtual bool canSeeOrDetect(Unit const* u, bool detect, bool inVisibleList = false, bool is3dDistance = true) const = 0;
|
||||
bool isVisibleForOrDetect(Unit const* u, bool detect, bool inVisibleList = false, bool is3dDistance = true) const;
|
||||
bool canDetectInvisibilityOf(Unit const* u) const;
|
||||
bool canDetectStealthOf(Unit const* u, float distance) const;
|
||||
|
||||
Reference in New Issue
Block a user