aboutsummaryrefslogtreecommitdiff
path: root/src/game/Player.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/Player.cpp')
-rw-r--r--src/game/Player.cpp110
1 files changed, 54 insertions, 56 deletions
diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index 51fbc3413c0..a9b0b95307c 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -1394,8 +1394,8 @@ void Player::Update( uint32 p_time )
SendUpdateToOutOfRangeGroupMembers();
Pet* pet = GetPet();
- if (pet && !IsWithinDistInMap(pet, OWNER_MAX_DISTANCE) && !pet->isPossessed())
- //if(pet && !IsWithinDistInMap(pet, OWNER_MAX_DISTANCE) && (GetCharmGUID() && (pet->GetGUID() != GetCharmGUID())))
+ if (pet && !pet->IsWithinDistInMap(this, GetMap()->GetVisibilityDistance()) && !pet->isPossessed())
+ //if(pet && !pet->IsWithinDistInMap(this, GetMap()->GetVisibilityDistance()) && (GetCharmGUID() && (pet->GetGUID() != GetCharmGUID())))
RemovePet(pet, PET_SAVE_NOT_IN_SLOT, true);
//we should execute delayed teleports only for alive(!) players
@@ -1748,7 +1748,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
if (!(options & TELE_TO_NOT_UNSUMMON_PET))
{
//same map, only remove pet if out of range for new position
- if(pet && !pet->IsWithinDist3d(x,y,z, OWNER_MAX_DISTANCE))
+ if(pet && !pet->IsWithinDist3d(x,y,z, GetMap()->GetVisibilityDistance()))
UnsummonPetTemporaryIfAny();
}
@@ -5124,56 +5124,6 @@ float Player::GetRatingBonusValue(CombatRating cr) const
return float(GetUInt32Value(PLAYER_FIELD_COMBAT_RATING_1 + cr)) / GetRatingCoefficient(cr);
}
-uint32 Player::GetMeleeCritDamageReduction(uint32 damage) const
-{
- float melee = GetRatingBonusValue(CR_CRIT_TAKEN_MELEE)*2.2f;
- if (melee>33.0f) melee = 33.0f;
- return uint32 (melee * damage /100.0f);
-}
-
-uint32 Player::GetMeleeDamageReduction(uint32 damage) const
-{
- float rate = GetRatingBonusValue(CR_CRIT_TAKEN_MELEE);
- // Resilience not limited (limit it by 100%)
- if (rate > 100.0f)
- rate = 100.0f;
- return uint32 (rate * damage / 100.0f);
-}
-
-uint32 Player::GetRangedCritDamageReduction(uint32 damage) const
-{
- float ranged = GetRatingBonusValue(CR_CRIT_TAKEN_RANGED)*2.2f;
- if (ranged>33.0f) ranged=33.0f;
- return uint32 (ranged * damage /100.0f);
-}
-
-uint32 Player::GetRangedDamageReduction(uint32 damage) const
-{
- float rate = GetRatingBonusValue(CR_CRIT_TAKEN_RANGED);
- // Resilience not limited (limit it by 100%)
- if (rate > 100.0f)
- rate = 100.0f;
- return uint32 (rate * damage / 100.0f);
-}
-
-uint32 Player::GetSpellCritDamageReduction(uint32 damage) const
-{
- float spell = GetRatingBonusValue(CR_CRIT_TAKEN_SPELL)*2.2f;
- // In wow script resilience limited to 33%
- if (spell>33.0f)
- spell = 33.0f;
- return uint32 (spell * damage / 100.0f);
-}
-
-uint32 Player::GetSpellDamageReduction(uint32 damage) const
-{
- float rate = GetRatingBonusValue(CR_CRIT_TAKEN_SPELL);
- // Resilience not limited (limit it by 100%)
- if (rate > 100.0f)
- rate = 100.0f;
- return uint32 (rate * damage / 100.0f);
-}
-
float Player::GetExpertiseDodgeOrParryReduction(WeaponAttackType attType) const
{
switch (attType)
@@ -14507,6 +14457,33 @@ void Player::SendCanTakeQuestResponse( uint32 msg )
sLog.outDebug("WORLD: Sent SMSG_QUESTGIVER_QUEST_INVALID");
}
+void Player::SendQuestConfirmAccept(const Quest* pQuest, Player* pReceiver)
+{
+ if (pReceiver)
+ {
+ std::string strTitle = pQuest->GetTitle();
+
+ int loc_idx = pReceiver->GetSession()->GetSessionDbLocaleIndex();
+
+ if (loc_idx >= 0)
+ {
+ if (const QuestLocale* pLocale = objmgr.GetQuestLocale(pQuest->GetQuestId()))
+ {
+ if (pLocale->Title.size() > loc_idx && !pLocale->Title[loc_idx].empty())
+ strTitle = pLocale->Title[loc_idx];
+ }
+ }
+
+ WorldPacket data(SMSG_QUEST_CONFIRM_ACCEPT, (4 + strTitle.size() + 8));
+ data << uint32(pQuest->GetQuestId());
+ data << strTitle;
+ data << uint64(GetGUID());
+ pReceiver->GetSession()->SendPacket(&data);
+
+ sLog.outDebug("WORLD: Sent SMSG_QUEST_CONFIRM_ACCEPT");
+ }
+}
+
void Player::SendPushToPartyResponse( Player *pPlayer, uint32 msg )
{
if( pPlayer )
@@ -17398,9 +17375,13 @@ void Player::Whisper(const std::string& text, uint32 language,uint64 receiver)
BuildPlayerChat(&data, CHAT_MSG_WHISPER, text, language);
rPlayer->GetSession()->SendPacket(&data);
- data.Initialize(SMSG_MESSAGECHAT, 200);
- rPlayer->BuildPlayerChat(&data, CHAT_MSG_REPLY, text, language);
- GetSession()->SendPacket(&data);
+ // not send confirmation for addon messages
+ if (language != LANG_ADDON)
+ {
+ data.Initialize(SMSG_MESSAGECHAT, 200);
+ rPlayer->BuildPlayerChat(&data, CHAT_MSG_REPLY, text, language);
+ GetSession()->SendPacket(&data);
+ }
}
else
{
@@ -19321,12 +19302,27 @@ inline void UpdateVisibilityOf_helper(std::set<uint64>& s64, Player* target, std
v.insert(target);
}
+template<class T>
+inline void BeforeVisibilityDestroy(T* /*t*/, Player* /*p*/)
+{
+}
+
+template<>
+inline void BeforeVisibilityDestroy<Creature>(Creature* t, Player* p)
+{
+ if (p->GetPetGUID()==t->GetGUID() && ((Creature*)t)->isPet())
+ ((Pet*)t)->Remove(PET_SAVE_NOT_IN_SLOT, true);
+}
+
void Player::UpdateVisibilityOf(WorldObject* target)
{
if(HaveAtClient(target))
{
if(!target->isVisibleForInState(this, true))
{
+ if (target->GetTypeId()==TYPEID_UNIT)
+ BeforeVisibilityDestroy<Creature>((Creature*)target,this);
+
target->DestroyForPlayer(this);
m_clientGUIDs.erase(target->GetGUID());
@@ -19378,6 +19374,8 @@ void Player::UpdateVisibilityOf(T* target, UpdateData& data, std::set<Unit*>& vi
{
if(!target->isVisibleForInState(this,true))
{
+ BeforeVisibilityDestroy<T>(target,this);
+
target->BuildOutOfRangeUpdateBlock(&data);
m_clientGUIDs.erase(target->GetGUID());