mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 07:37:01 +00:00
Merge branch 'master' into 310
Conflicts: src/game/Player.cpp src/game/Player.h src/game/Unit.cpp
This commit is contained in:
commit
963aed5e0b
49 changed files with 1124 additions and 986 deletions
|
|
@ -261,11 +261,9 @@ std::ostringstream& operator<< (std::ostringstream& ss, PlayerTaxi const& taxi)
|
|||
|
||||
//== Player ====================================================
|
||||
|
||||
const int32 Player::ReputationRank_Length[MAX_REPUTATION_RANK] = {36000, 3000, 3000, 3000, 6000, 12000, 21000, 1000};
|
||||
|
||||
UpdateMask Player::updateVisualBits;
|
||||
|
||||
Player::Player (WorldSession *session): Unit(), m_achievementMgr(this)
|
||||
Player::Player (WorldSession *session): Unit(), m_achievementMgr(this), m_reputationMgr(this)
|
||||
{
|
||||
m_transport = 0;
|
||||
|
||||
|
|
@ -447,7 +445,7 @@ 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_miniPet = 0;
|
||||
m_bgAfkReportedTimer = 0;
|
||||
|
|
@ -455,6 +453,9 @@ Player::Player (WorldSession *session): Unit(), m_achievementMgr(this)
|
|||
|
||||
m_declinedname = NULL;
|
||||
m_runes = NULL;
|
||||
|
||||
m_lastFallTime = 0;
|
||||
m_lastFallZ = 0;
|
||||
}
|
||||
|
||||
Player::~Player ()
|
||||
|
|
@ -822,7 +823,7 @@ void Player::StopMirrorTimer(MirrorTimerType Type)
|
|||
GetSession()->SendPacket( &data );
|
||||
}
|
||||
|
||||
void Player::EnvironmentalDamage(uint64 guid, EnviromentalDamage type, uint32 damage)
|
||||
void Player::EnvironmentalDamage(EnviromentalDamage type, uint32 damage)
|
||||
{
|
||||
if(!isAlive() || isGameMaster())
|
||||
return;
|
||||
|
|
@ -838,11 +839,11 @@ void Player::EnvironmentalDamage(uint64 guid, EnviromentalDamage type, uint32 da
|
|||
damage-=absorb+resist;
|
||||
|
||||
WorldPacket data(SMSG_ENVIRONMENTALDAMAGELOG, (21));
|
||||
data << (uint64)guid;
|
||||
data << (uint8)(type!=DAMAGE_FALL_TO_VOID ? type : DAMAGE_FALL);
|
||||
data << (uint32)damage;
|
||||
data << (uint32)absorb; // absorb
|
||||
data << (uint32)resist; // resist
|
||||
data << uint64(GetGUID());
|
||||
data << uint8(type!=DAMAGE_FALL_TO_VOID ? type : DAMAGE_FALL);
|
||||
data << uint32(damage);
|
||||
data << uint32(absorb);
|
||||
data << uint32(resist);
|
||||
SendMessageToSet(&data, true);
|
||||
|
||||
DealDamage(this, damage, NULL, SELF_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
|
||||
|
|
@ -921,7 +922,7 @@ void Player::HandleDrowning(uint32 time_diff)
|
|||
// Calculate and deal damage
|
||||
// TODO: Check this formula
|
||||
uint32 damage = GetMaxHealth() / 5 + urand(0, getLevel()-1);
|
||||
EnvironmentalDamage(GetGUID(), DAMAGE_DROWNING, damage);
|
||||
EnvironmentalDamage(DAMAGE_DROWNING, damage);
|
||||
}
|
||||
else if (!(m_MirrorTimerFlagsLast & UNDERWATER_INWATER)) // Update time in client if need
|
||||
SendMirrorTimer(BREATH_TIMER, getMaxTimer(BREATH_TIMER), m_MirrorTimer[BREATH_TIMER], -1);
|
||||
|
|
@ -957,7 +958,7 @@ void Player::HandleDrowning(uint32 time_diff)
|
|||
if (isAlive()) // Calculate and deal damage
|
||||
{
|
||||
uint32 damage = GetMaxHealth() / 5 + urand(0, getLevel()-1);
|
||||
EnvironmentalDamage(GetGUID(), DAMAGE_EXHAUSTED, damage);
|
||||
EnvironmentalDamage(DAMAGE_EXHAUSTED, damage);
|
||||
}
|
||||
else if (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST)) // Teleport ghost to graveyard
|
||||
RepopAtGraveyard();
|
||||
|
|
@ -991,9 +992,9 @@ void Player::HandleDrowning(uint32 time_diff)
|
|||
// TODO: Check this formula
|
||||
uint32 damage = urand(600, 700);
|
||||
if (m_MirrorTimerFlags&UNDERWATER_INLAVA)
|
||||
EnvironmentalDamage(GetGUID(), DAMAGE_LAVA, damage);
|
||||
EnvironmentalDamage(DAMAGE_LAVA, damage);
|
||||
else
|
||||
EnvironmentalDamage(GetGUID(), DAMAGE_SLIME, damage);
|
||||
EnvironmentalDamage(DAMAGE_SLIME, damage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -5586,439 +5587,27 @@ void Player::setFactionForRace(uint8 race)
|
|||
setFaction( getFactionForRace(race) );
|
||||
}
|
||||
|
||||
void Player::UpdateReputation() const
|
||||
{
|
||||
sLog.outDetail( "WORLD: Player::UpdateReputation" );
|
||||
|
||||
for(FactionStateList::const_iterator itr = m_factions.begin(); itr != m_factions.end(); ++itr)
|
||||
{
|
||||
SendFactionState(&(itr->second));
|
||||
}
|
||||
}
|
||||
|
||||
void Player::SendFactionState(FactionState const* faction) const
|
||||
{
|
||||
if(faction->Flags & FACTION_FLAG_VISIBLE) //If faction is visible then update it
|
||||
{
|
||||
WorldPacket data(SMSG_SET_FACTION_STANDING, (16)); // last check 2.4.0
|
||||
data << (float) 0; // unk 2.4.0
|
||||
data << (uint8) 0; // wotlk 8634
|
||||
data << (uint32) 1; // count
|
||||
// for
|
||||
data << (uint32) faction->ReputationListID;
|
||||
data << (uint32) faction->Standing;
|
||||
// end for
|
||||
GetSession()->SendPacket(&data);
|
||||
}
|
||||
}
|
||||
|
||||
void Player::SendInitialReputations()
|
||||
{
|
||||
WorldPacket data(SMSG_INITIALIZE_FACTIONS, (4+128*5));
|
||||
data << uint32 (0x00000080);
|
||||
|
||||
RepListID a = 0;
|
||||
|
||||
for (FactionStateList::const_iterator itr = m_factions.begin(); itr != m_factions.end(); ++itr)
|
||||
{
|
||||
// fill in absent fields
|
||||
for (; a != itr->first; a++)
|
||||
{
|
||||
data << uint8 (0x00);
|
||||
data << uint32 (0x00000000);
|
||||
}
|
||||
|
||||
// fill in encountered data
|
||||
data << uint8 (itr->second.Flags);
|
||||
data << uint32 (itr->second.Standing);
|
||||
|
||||
++a;
|
||||
}
|
||||
|
||||
// fill in absent fields
|
||||
for (; a != 128; a++)
|
||||
{
|
||||
data << uint8 (0x00);
|
||||
data << uint32 (0x00000000);
|
||||
}
|
||||
|
||||
GetSession()->SendPacket(&data);
|
||||
}
|
||||
|
||||
FactionState const* Player::GetFactionState( FactionEntry const* factionEntry) const
|
||||
{
|
||||
FactionStateList::const_iterator itr = m_factions.find(factionEntry->reputationListID);
|
||||
if (itr != m_factions.end())
|
||||
return &itr->second;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void Player::SetFactionAtWar(FactionState* faction, bool atWar)
|
||||
{
|
||||
// not allow declare war to own faction
|
||||
if(atWar && (faction->Flags & FACTION_FLAG_PEACE_FORCED) )
|
||||
return;
|
||||
|
||||
// already set
|
||||
if(((faction->Flags & FACTION_FLAG_AT_WAR) != 0) == atWar)
|
||||
return;
|
||||
|
||||
if( atWar )
|
||||
faction->Flags |= FACTION_FLAG_AT_WAR;
|
||||
else
|
||||
faction->Flags &= ~FACTION_FLAG_AT_WAR;
|
||||
|
||||
faction->Changed = true;
|
||||
}
|
||||
|
||||
void Player::SetFactionInactive(FactionState* faction, bool inactive)
|
||||
{
|
||||
// always invisible or hidden faction can't be inactive
|
||||
if(inactive && ((faction->Flags & (FACTION_FLAG_INVISIBLE_FORCED|FACTION_FLAG_HIDDEN)) || !(faction->Flags & FACTION_FLAG_VISIBLE) ) )
|
||||
return;
|
||||
|
||||
// already set
|
||||
if(((faction->Flags & FACTION_FLAG_INACTIVE) != 0) == inactive)
|
||||
return;
|
||||
|
||||
if(inactive)
|
||||
faction->Flags |= FACTION_FLAG_INACTIVE;
|
||||
else
|
||||
faction->Flags &= ~FACTION_FLAG_INACTIVE;
|
||||
|
||||
faction->Changed = true;
|
||||
}
|
||||
|
||||
void Player::SetFactionVisibleForFactionTemplateId(uint32 FactionTemplateId)
|
||||
{
|
||||
FactionTemplateEntry const*factionTemplateEntry = sFactionTemplateStore.LookupEntry(FactionTemplateId);
|
||||
|
||||
if(!factionTemplateEntry)
|
||||
return;
|
||||
|
||||
if(factionTemplateEntry->faction)
|
||||
SetFactionVisibleForFactionId(factionTemplateEntry->faction);
|
||||
}
|
||||
|
||||
void Player::SetFactionVisibleForFactionId(uint32 FactionId)
|
||||
{
|
||||
FactionEntry const *factionEntry = sFactionStore.LookupEntry(FactionId);
|
||||
if(!factionEntry)
|
||||
return;
|
||||
|
||||
if(factionEntry->reputationListID < 0)
|
||||
return;
|
||||
|
||||
FactionStateList::iterator itr = m_factions.find(factionEntry->reputationListID);
|
||||
if (itr == m_factions.end())
|
||||
return;
|
||||
|
||||
SetFactionVisible(&itr->second);
|
||||
}
|
||||
|
||||
void Player::SetFactionVisible(FactionState* faction)
|
||||
{
|
||||
// always invisible or hidden faction can't be make visible
|
||||
if(faction->Flags & (FACTION_FLAG_INVISIBLE_FORCED|FACTION_FLAG_HIDDEN))
|
||||
return;
|
||||
|
||||
// already set
|
||||
if(faction->Flags & FACTION_FLAG_VISIBLE)
|
||||
return;
|
||||
|
||||
faction->Flags |= FACTION_FLAG_VISIBLE;
|
||||
faction->Changed = true;
|
||||
|
||||
if(!m_session->PlayerLoading())
|
||||
{
|
||||
// make faction visible in reputation list at client
|
||||
WorldPacket data(SMSG_SET_FACTION_VISIBLE, 4);
|
||||
data << faction->ReputationListID;
|
||||
GetSession()->SendPacket(&data);
|
||||
}
|
||||
}
|
||||
|
||||
void Player::SetInitialFactions()
|
||||
{
|
||||
for(unsigned int i = 1; i < sFactionStore.GetNumRows(); i++)
|
||||
{
|
||||
FactionEntry const *factionEntry = sFactionStore.LookupEntry(i);
|
||||
|
||||
if( factionEntry && (factionEntry->reputationListID >= 0))
|
||||
{
|
||||
FactionState newFaction;
|
||||
newFaction.ID = factionEntry->ID;
|
||||
newFaction.ReputationListID = factionEntry->reputationListID;
|
||||
newFaction.Standing = 0;
|
||||
newFaction.Flags = GetDefaultReputationFlags(factionEntry);
|
||||
newFaction.Changed = true;
|
||||
|
||||
m_factions[newFaction.ReputationListID] = newFaction;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint32 Player::GetDefaultReputationFlags(const FactionEntry *factionEntry) const
|
||||
{
|
||||
if (!factionEntry)
|
||||
return 0;
|
||||
|
||||
uint32 raceMask = getRaceMask();
|
||||
uint32 classMask = getClassMask();
|
||||
for (int i=0; i < 4; i++)
|
||||
{
|
||||
if( (factionEntry->BaseRepRaceMask[i] & raceMask) &&
|
||||
(factionEntry->BaseRepClassMask[i]==0 ||
|
||||
(factionEntry->BaseRepClassMask[i] & classMask) ) )
|
||||
return factionEntry->ReputationFlags[i];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32 Player::GetBaseReputation(const FactionEntry *factionEntry) const
|
||||
{
|
||||
if (!factionEntry)
|
||||
return 0;
|
||||
|
||||
uint32 raceMask = getRaceMask();
|
||||
uint32 classMask = getClassMask();
|
||||
for (int i=0; i < 4; i++)
|
||||
{
|
||||
if( (factionEntry->BaseRepRaceMask[i] & raceMask) &&
|
||||
(factionEntry->BaseRepClassMask[i]==0 ||
|
||||
(factionEntry->BaseRepClassMask[i] & classMask) ) )
|
||||
return factionEntry->BaseRepValue[i];
|
||||
}
|
||||
|
||||
// in faction.dbc exist factions with (RepListId >=0, listed in character reputation list) with all BaseRepRaceMask[i]==0
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32 Player::GetReputation(uint32 faction_id) const
|
||||
{
|
||||
FactionEntry const *factionEntry = sFactionStore.LookupEntry(faction_id);
|
||||
|
||||
if (!factionEntry)
|
||||
{
|
||||
sLog.outError("Player::GetReputation: Can't get reputation of %s for unknown faction (faction template id) #%u.",GetName(), faction_id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return GetReputation(factionEntry);
|
||||
}
|
||||
|
||||
int32 Player::GetReputation(const FactionEntry *factionEntry) const
|
||||
{
|
||||
// Faction without recorded reputation. Just ignore.
|
||||
if(!factionEntry)
|
||||
return 0;
|
||||
|
||||
FactionStateList::const_iterator itr = m_factions.find(factionEntry->reputationListID);
|
||||
if (itr != m_factions.end())
|
||||
return GetBaseReputation(factionEntry) + itr->second.Standing;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
ReputationRank Player::GetReputationRank(uint32 faction) const
|
||||
{
|
||||
FactionEntry const*factionEntry = sFactionStore.LookupEntry(faction);
|
||||
if(!factionEntry)
|
||||
return MIN_REPUTATION_RANK;
|
||||
|
||||
return GetReputationRank(factionEntry);
|
||||
}
|
||||
|
||||
ReputationRank Player::ReputationToRank(int32 standing) const
|
||||
{
|
||||
int32 Limit = Reputation_Cap + 1;
|
||||
for (int i = MAX_REPUTATION_RANK-1; i >= MIN_REPUTATION_RANK; --i)
|
||||
{
|
||||
Limit -= ReputationRank_Length[i];
|
||||
if (standing >= Limit )
|
||||
return ReputationRank(i);
|
||||
}
|
||||
return MIN_REPUTATION_RANK;
|
||||
}
|
||||
|
||||
ReputationRank Player::GetReputationRank(const FactionEntry *factionEntry) const
|
||||
{
|
||||
int32 Reputation = GetReputation(factionEntry);
|
||||
return ReputationToRank(Reputation);
|
||||
}
|
||||
|
||||
ReputationRank Player::GetBaseReputationRank(const FactionEntry *factionEntry) const
|
||||
{
|
||||
int32 Reputation = GetBaseReputation(factionEntry);
|
||||
return ReputationToRank(Reputation);
|
||||
}
|
||||
|
||||
bool Player::ModifyFactionReputation(uint32 FactionTemplateId, int32 DeltaReputation)
|
||||
{
|
||||
FactionTemplateEntry const* factionTemplateEntry = sFactionTemplateStore.LookupEntry(FactionTemplateId);
|
||||
|
||||
if(!factionTemplateEntry)
|
||||
{
|
||||
sLog.outError("Player::ModifyFactionReputation: Can't update reputation of %s for unknown faction (faction template id) #%u.", GetName(), FactionTemplateId);
|
||||
return false;
|
||||
}
|
||||
|
||||
FactionEntry const *factionEntry = sFactionStore.LookupEntry(factionTemplateEntry->faction);
|
||||
|
||||
// Faction without recorded reputation. Just ignore.
|
||||
if(!factionEntry)
|
||||
return false;
|
||||
|
||||
return ModifyFactionReputation(factionEntry, DeltaReputation);
|
||||
}
|
||||
|
||||
bool Player::ModifyFactionReputation(FactionEntry const* factionEntry, int32 standing)
|
||||
{
|
||||
SimpleFactionsList const* flist = GetFactionTeamList(factionEntry->ID);
|
||||
if (flist)
|
||||
{
|
||||
bool res = false;
|
||||
for (SimpleFactionsList::const_iterator itr = flist->begin();itr != flist->end();++itr)
|
||||
{
|
||||
FactionEntry const *factionEntryCalc = sFactionStore.LookupEntry(*itr);
|
||||
if(factionEntryCalc)
|
||||
res = ModifyOneFactionReputation(factionEntryCalc, standing);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
else
|
||||
return ModifyOneFactionReputation(factionEntry, standing);
|
||||
}
|
||||
|
||||
bool Player::ModifyOneFactionReputation(FactionEntry const* factionEntry, int32 standing)
|
||||
{
|
||||
FactionStateList::iterator itr = m_factions.find(factionEntry->reputationListID);
|
||||
if (itr != m_factions.end())
|
||||
{
|
||||
int32 BaseRep = GetBaseReputation(factionEntry);
|
||||
int32 new_rep = BaseRep + itr->second.Standing + standing;
|
||||
|
||||
if (new_rep > Reputation_Cap)
|
||||
new_rep = Reputation_Cap;
|
||||
else
|
||||
if (new_rep < Reputation_Bottom)
|
||||
new_rep = Reputation_Bottom;
|
||||
|
||||
if(ReputationToRank(new_rep) <= REP_HOSTILE)
|
||||
SetFactionAtWar(&itr->second,true);
|
||||
|
||||
itr->second.Standing = new_rep - BaseRep;
|
||||
itr->second.Changed = true;
|
||||
|
||||
SetFactionVisible(&itr->second);
|
||||
|
||||
for( int i = 0; i < MAX_QUEST_LOG_SIZE; ++i )
|
||||
{
|
||||
if(uint32 questid = GetQuestSlotQuestId(i))
|
||||
{
|
||||
Quest const* qInfo = objmgr.GetQuestTemplate(questid);
|
||||
if( qInfo && qInfo->GetRepObjectiveFaction() == factionEntry->ID )
|
||||
{
|
||||
QuestStatusData& q_status = mQuestStatus[questid];
|
||||
if( q_status.m_status == QUEST_STATUS_INCOMPLETE )
|
||||
{
|
||||
if(GetReputation(factionEntry) >= qInfo->GetRepObjectiveValue())
|
||||
if ( CanCompleteQuest( questid ) )
|
||||
CompleteQuest( questid );
|
||||
}
|
||||
else if( q_status.m_status == QUEST_STATUS_COMPLETE )
|
||||
{
|
||||
if(GetReputation(factionEntry) < qInfo->GetRepObjectiveValue())
|
||||
IncompleteQuest( questid );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_REPUTATION,factionEntry->ID);
|
||||
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_EXALTED_REPUTATION,factionEntry->ID);
|
||||
SendFactionState(&(itr->second));
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Player::SetFactionReputation(uint32 FactionTemplateId, int32 standing)
|
||||
{
|
||||
FactionTemplateEntry const* factionTemplateEntry = sFactionTemplateStore.LookupEntry(FactionTemplateId);
|
||||
|
||||
if(!factionTemplateEntry)
|
||||
{
|
||||
sLog.outError("Player::SetFactionReputation: Can't set reputation of %s for unknown faction (faction template id) #%u.", GetName(), FactionTemplateId);
|
||||
return false;
|
||||
}
|
||||
|
||||
FactionEntry const *factionEntry = sFactionStore.LookupEntry(factionTemplateEntry->faction);
|
||||
|
||||
// Faction without recorded reputation. Just ignore.
|
||||
if(!factionEntry)
|
||||
return false;
|
||||
|
||||
return SetFactionReputation(factionEntry, standing);
|
||||
}
|
||||
|
||||
bool Player::SetFactionReputation(FactionEntry const* factionEntry, int32 standing)
|
||||
{
|
||||
SimpleFactionsList const* flist = GetFactionTeamList(factionEntry->ID);
|
||||
if (flist)
|
||||
{
|
||||
bool res = false;
|
||||
for (SimpleFactionsList::const_iterator itr = flist->begin();itr != flist->end();++itr)
|
||||
{
|
||||
FactionEntry const *factionEntryCalc = sFactionStore.LookupEntry(*itr);
|
||||
if(factionEntryCalc)
|
||||
res = SetOneFactionReputation(factionEntryCalc, standing);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
else
|
||||
return SetOneFactionReputation(factionEntry, standing);
|
||||
}
|
||||
|
||||
bool Player::SetOneFactionReputation(FactionEntry const* factionEntry, int32 standing)
|
||||
{
|
||||
FactionStateList::iterator itr = m_factions.find(factionEntry->reputationListID);
|
||||
if (itr != m_factions.end())
|
||||
{
|
||||
if (standing > Reputation_Cap)
|
||||
standing = Reputation_Cap;
|
||||
else
|
||||
if (standing < Reputation_Bottom)
|
||||
standing = Reputation_Bottom;
|
||||
|
||||
int32 BaseRep = GetBaseReputation(factionEntry);
|
||||
itr->second.Standing = standing - BaseRep;
|
||||
itr->second.Changed = true;
|
||||
|
||||
SetFactionVisible(&itr->second);
|
||||
|
||||
if(ReputationToRank(standing) <= REP_HOSTILE)
|
||||
SetFactionAtWar(&itr->second,true);
|
||||
|
||||
SendFactionState(&(itr->second));
|
||||
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_REPUTATION,factionEntry->ID);
|
||||
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_EXALTED_REPUTATION,factionEntry->ID);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
FactionEntry const* factionEntry = sFactionStore.LookupEntry(faction);
|
||||
return GetReputationMgr().GetRank(factionEntry);
|
||||
}
|
||||
|
||||
//Calculate total reputation percent player gain with quest/creature level
|
||||
int32 Player::CalculateReputationGain(uint32 creatureOrQuestLevel, int32 rep, bool for_quest)
|
||||
{
|
||||
int32 percent = 100;
|
||||
float percent = 100.0f;
|
||||
|
||||
float rate = for_quest ? sWorld.getRate(RATE_REPUTATION_LOWLEVEL_QUEST) : sWorld.getRate(RATE_REPUTATION_LOWLEVEL_KILL);
|
||||
|
||||
if(rate != 1.0f && creatureOrQuestLevel <= MaNGOS::XP::GetGrayLevel(getLevel()))
|
||||
percent *= rate;
|
||||
|
||||
int32 repMod = GetTotalAuraModifier(SPELL_AURA_MOD_REPUTATION_GAIN);
|
||||
|
||||
percent += rep > 0 ? repMod : -repMod;
|
||||
|
||||
if(percent <=0)
|
||||
if(percent <= 0.0f)
|
||||
return 0;
|
||||
|
||||
return int32(sWorld.getRate(RATE_REPUTATION_GAIN)*rep*percent/100);
|
||||
|
|
@ -6040,16 +5629,16 @@ void Player::RewardReputation(Unit *pVictim, float rate)
|
|||
int32 donerep1 = CalculateReputationGain(pVictim->getLevel(),Rep->repvalue1,false);
|
||||
donerep1 = int32(donerep1*rate);
|
||||
FactionEntry const *factionEntry1 = sFactionStore.LookupEntry(Rep->repfaction1);
|
||||
uint32 current_reputation_rank1 = GetReputationRank(factionEntry1);
|
||||
uint32 current_reputation_rank1 = GetReputationMgr().GetRank(factionEntry1);
|
||||
if(factionEntry1 && current_reputation_rank1 <= Rep->reputation_max_cap1)
|
||||
ModifyFactionReputation(factionEntry1, donerep1);
|
||||
GetReputationMgr().ModifyReputation(factionEntry1, donerep1);
|
||||
|
||||
// Wiki: Team factions value divided by 2
|
||||
if(Rep->is_teamaward1)
|
||||
{
|
||||
FactionEntry const *team1_factionEntry = sFactionStore.LookupEntry(factionEntry1->team);
|
||||
if(team1_factionEntry)
|
||||
ModifyFactionReputation(team1_factionEntry, donerep1 / 2);
|
||||
GetReputationMgr().ModifyReputation(team1_factionEntry, donerep1 / 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -6058,16 +5647,16 @@ void Player::RewardReputation(Unit *pVictim, float rate)
|
|||
int32 donerep2 = CalculateReputationGain(pVictim->getLevel(),Rep->repvalue2,false);
|
||||
donerep2 = int32(donerep2*rate);
|
||||
FactionEntry const *factionEntry2 = sFactionStore.LookupEntry(Rep->repfaction2);
|
||||
uint32 current_reputation_rank2 = GetReputationRank(factionEntry2);
|
||||
uint32 current_reputation_rank2 = GetReputationMgr().GetRank(factionEntry2);
|
||||
if(factionEntry2 && current_reputation_rank2 <= Rep->reputation_max_cap2)
|
||||
ModifyFactionReputation(factionEntry2, donerep2);
|
||||
GetReputationMgr().ModifyReputation(factionEntry2, donerep2);
|
||||
|
||||
// Wiki: Team factions value divided by 2
|
||||
if(Rep->is_teamaward2)
|
||||
{
|
||||
FactionEntry const *team2_factionEntry = sFactionStore.LookupEntry(factionEntry2->team);
|
||||
if(team2_factionEntry)
|
||||
ModifyFactionReputation(team2_factionEntry, donerep2 / 2);
|
||||
GetReputationMgr().ModifyReputation(team2_factionEntry, donerep2 / 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -6083,7 +5672,7 @@ void Player::RewardReputation(Quest const *pQuest)
|
|||
int32 rep = CalculateReputationGain(GetQuestLevel(pQuest),pQuest->RewRepValue[i],true);
|
||||
FactionEntry const* factionEntry = sFactionStore.LookupEntry(pQuest->RewRepFaction[i]);
|
||||
if(factionEntry)
|
||||
ModifyFactionReputation(factionEntry, rep);
|
||||
GetReputationMgr().ModifyReputation(factionEntry, rep);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -10283,7 +9872,7 @@ uint8 Player::CanUseAmmo( uint32 item ) const
|
|||
}
|
||||
if( pProto->RequiredSpell != 0 && !HasSpell( pProto->RequiredSpell ) )
|
||||
return EQUIP_ERR_NO_REQUIRED_PROFICIENCY;
|
||||
/*if( GetReputation() < pProto->RequiredReputation )
|
||||
/*if( GetReputationMgr().GetReputation() < pProto->RequiredReputation )
|
||||
return EQUIP_ERR_CANT_EQUIP_REPUTATION;
|
||||
*/
|
||||
if( getLevel() < pProto->RequiredLevel )
|
||||
|
|
@ -12454,7 +12043,7 @@ bool Player::CanCompleteQuest( uint32 quest_id )
|
|||
}
|
||||
|
||||
uint32 repFacId = qInfo->GetRepObjectiveFaction();
|
||||
if ( repFacId && GetReputation(repFacId) < qInfo->GetRepObjectiveValue() )
|
||||
if ( repFacId && GetReputationMgr().GetReputation(repFacId) < qInfo->GetRepObjectiveValue() )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
|
@ -12588,7 +12177,8 @@ void Player::AddQuest( Quest const *pQuest, Object *questGiver )
|
|||
AdjustQuestReqItemCount( pQuest, questStatusData );
|
||||
|
||||
if( pQuest->GetRepObjectiveFaction() )
|
||||
SetFactionVisibleForFactionId(pQuest->GetRepObjectiveFaction());
|
||||
if(FactionEntry const* factionEntry = sFactionStore.LookupEntry(pQuest->GetRepObjectiveFaction()))
|
||||
GetReputationMgr().SetVisible(factionEntry);
|
||||
|
||||
uint32 qtime = 0;
|
||||
if( pQuest->HasFlag( QUEST_MANGOS_FLAGS_TIMED ) )
|
||||
|
|
@ -13081,7 +12671,7 @@ bool Player::SatisfyQuestRace( Quest const* qInfo, bool msg )
|
|||
bool Player::SatisfyQuestReputation( Quest const* qInfo, bool msg )
|
||||
{
|
||||
uint32 fIdMin = qInfo->GetRequiredMinRepFaction(); //Min required rep
|
||||
if(fIdMin && GetReputation(fIdMin) < qInfo->GetRequiredMinRepValue())
|
||||
if(fIdMin && GetReputationMgr().GetReputation(fIdMin) < qInfo->GetRequiredMinRepValue())
|
||||
{
|
||||
if( msg )
|
||||
SendCanTakeQuestResponse( INVALIDREASON_DONT_HAVE_REQ );
|
||||
|
|
@ -13089,7 +12679,7 @@ bool Player::SatisfyQuestReputation( Quest const* qInfo, bool msg )
|
|||
}
|
||||
|
||||
uint32 fIdMax = qInfo->GetRequiredMaxRepFaction(); //Max required rep
|
||||
if(fIdMax && GetReputation(fIdMax) >= qInfo->GetRequiredMaxRepValue())
|
||||
if(fIdMax && GetReputationMgr().GetReputation(fIdMax) >= qInfo->GetRequiredMaxRepValue())
|
||||
{
|
||||
if( msg )
|
||||
SendCanTakeQuestResponse( INVALIDREASON_DONT_HAVE_REQ );
|
||||
|
|
@ -13733,6 +13323,34 @@ void Player::MoneyChanged( uint32 count )
|
|||
}
|
||||
}
|
||||
|
||||
void Player::ReputationChanged(FactionEntry const* factionEntry )
|
||||
{
|
||||
for( int i = 0; i < MAX_QUEST_LOG_SIZE; ++i )
|
||||
{
|
||||
if(uint32 questid = GetQuestSlotQuestId(i))
|
||||
{
|
||||
if(Quest const* qInfo = objmgr.GetQuestTemplate(questid))
|
||||
{
|
||||
if(qInfo->GetRepObjectiveFaction() == factionEntry->ID )
|
||||
{
|
||||
QuestStatusData& q_status = mQuestStatus[questid];
|
||||
if( q_status.m_status == QUEST_STATUS_INCOMPLETE )
|
||||
{
|
||||
if(GetReputationMgr().GetReputation(factionEntry) >= qInfo->GetRepObjectiveValue())
|
||||
if ( CanCompleteQuest( questid ) )
|
||||
CompleteQuest( questid );
|
||||
}
|
||||
else if( q_status.m_status == QUEST_STATUS_COMPLETE )
|
||||
{
|
||||
if(GetReputationMgr().GetReputation(factionEntry) < qInfo->GetRepObjectiveValue())
|
||||
IncompleteQuest( questid );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Player::HasQuestForItem( uint32 itemid ) const
|
||||
{
|
||||
for( int i = 0; i < MAX_QUEST_LOG_SIZE; ++i )
|
||||
|
|
@ -14179,7 +13797,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
|
|||
//Need to call it to initialize m_team (m_team can be calculated from m_race)
|
||||
//Other way is to saves m_team into characters table.
|
||||
setFactionForRace(m_race);
|
||||
SetCharm(0);
|
||||
SetCharm(NULL);
|
||||
|
||||
m_class = fields[5].GetUInt8();
|
||||
|
||||
|
|
@ -14513,7 +14131,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
|
|||
learnDefaultSpells();
|
||||
|
||||
// must be before inventory (some items required reputation check)
|
||||
_LoadReputation(holder->GetResult(PLAYER_LOGIN_QUERY_LOADREPUTATION));
|
||||
m_reputationMgr.LoadFromDB(holder->GetResult(PLAYER_LOGIN_QUERY_LOADREPUTATION));
|
||||
|
||||
_LoadInventory(holder->GetResult(PLAYER_LOGIN_QUERY_LOADINVENTORY), time_diff);
|
||||
|
||||
|
|
@ -15260,61 +14878,6 @@ void Player::_LoadDailyQuestStatus(QueryResult *result)
|
|||
m_DailyQuestChanged = false;
|
||||
}
|
||||
|
||||
void Player::_LoadReputation(QueryResult *result)
|
||||
{
|
||||
m_factions.clear();
|
||||
|
||||
// Set initial reputations (so everything is nifty before DB data load)
|
||||
SetInitialFactions();
|
||||
|
||||
//QueryResult *result = CharacterDatabase.PQuery("SELECT faction,standing,flags FROM character_reputation WHERE guid = '%u'",GetGUIDLow());
|
||||
|
||||
if(result)
|
||||
{
|
||||
do
|
||||
{
|
||||
Field *fields = result->Fetch();
|
||||
|
||||
FactionEntry const *factionEntry = sFactionStore.LookupEntry(fields[0].GetUInt32());
|
||||
if( factionEntry && (factionEntry->reputationListID >= 0))
|
||||
{
|
||||
FactionState* faction = &m_factions[factionEntry->reputationListID];
|
||||
|
||||
// update standing to current
|
||||
faction->Standing = int32(fields[1].GetUInt32());
|
||||
|
||||
uint32 dbFactionFlags = fields[2].GetUInt32();
|
||||
|
||||
if( dbFactionFlags & FACTION_FLAG_VISIBLE )
|
||||
SetFactionVisible(faction); // have internal checks for forced invisibility
|
||||
|
||||
if( dbFactionFlags & FACTION_FLAG_INACTIVE)
|
||||
SetFactionInactive(faction,true); // have internal checks for visibility requirement
|
||||
|
||||
if( dbFactionFlags & FACTION_FLAG_AT_WAR ) // DB at war
|
||||
SetFactionAtWar(faction,true); // have internal checks for FACTION_FLAG_PEACE_FORCED
|
||||
else // DB not at war
|
||||
{
|
||||
// allow remove if visible (and then not FACTION_FLAG_INVISIBLE_FORCED or FACTION_FLAG_HIDDEN)
|
||||
if( faction->Flags & FACTION_FLAG_VISIBLE )
|
||||
SetFactionAtWar(faction,false); // have internal checks for FACTION_FLAG_PEACE_FORCED
|
||||
}
|
||||
|
||||
// set atWar for hostile
|
||||
if(GetReputationRank(factionEntry) <= REP_HOSTILE)
|
||||
SetFactionAtWar(faction,true);
|
||||
|
||||
// reset changed flag if values similar to saved in DB
|
||||
if(faction->Flags==dbFactionFlags)
|
||||
faction->Changed = false;
|
||||
}
|
||||
}
|
||||
while( result->NextRow() );
|
||||
|
||||
delete result;
|
||||
}
|
||||
}
|
||||
|
||||
void Player::_LoadSpells(QueryResult *result)
|
||||
{
|
||||
//QueryResult *result = CharacterDatabase.PQuery("SELECT spell,active,disabled FROM character_spell WHERE guid = '%u'",GetGUIDLow());
|
||||
|
|
@ -15776,7 +15339,8 @@ void Player::SaveToDB()
|
|||
_SaveSpellCooldowns();
|
||||
_SaveActions();
|
||||
_SaveAuras();
|
||||
_SaveReputation();
|
||||
m_achievementMgr.SaveToDB();
|
||||
m_reputationMgr.SaveToDB();
|
||||
_SaveEquipmentSets();
|
||||
GetSession()->SaveTutorialsData(); // changed only while character in game
|
||||
|
||||
|
|
@ -15792,7 +15356,6 @@ void Player::SaveToDB()
|
|||
// save pet (hunter pet level and experience and all type pets health/mana).
|
||||
if(Pet* pet = GetPet())
|
||||
pet->SavePetToDB(PET_SAVE_AS_CURRENT);
|
||||
m_achievementMgr.SaveToDB();
|
||||
}
|
||||
|
||||
// fast save function for item/money cheating preventing - save only inventory and money state
|
||||
|
|
@ -16056,19 +15619,6 @@ void Player::_SaveDailyQuestStatus()
|
|||
GetGUIDLow(), GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx),uint64(m_lastDailyQuestTime));
|
||||
}
|
||||
|
||||
void Player::_SaveReputation()
|
||||
{
|
||||
for(FactionStateList::iterator itr = m_factions.begin(); itr != m_factions.end(); ++itr)
|
||||
{
|
||||
if (itr->second.Changed)
|
||||
{
|
||||
CharacterDatabase.PExecute("DELETE FROM character_reputation WHERE guid = '%u' AND faction='%u'", GetGUIDLow(), itr->second.ID);
|
||||
CharacterDatabase.PExecute("INSERT INTO character_reputation (guid,faction,standing,flags) VALUES ('%u', '%u', '%i', '%u')", GetGUIDLow(), itr->second.ID, itr->second.Standing, itr->second.Flags);
|
||||
itr->second.Changed = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Player::_SaveSpells()
|
||||
{
|
||||
for (PlayerSpellMap::iterator itr = m_spells.begin(), next = m_spells.begin(); itr != m_spells.end();)
|
||||
|
|
@ -16308,16 +15858,6 @@ void Player::SendAutoRepeatCancel()
|
|||
GetSession()->SendPacket( &data );
|
||||
}
|
||||
|
||||
void Player::PlaySound(uint32 Sound, bool OnlySelf)
|
||||
{
|
||||
WorldPacket data(SMSG_PLAY_SOUND, 4);
|
||||
data << Sound;
|
||||
if (OnlySelf)
|
||||
GetSession()->SendPacket( &data );
|
||||
else
|
||||
SendMessageToSet( &data, true );
|
||||
}
|
||||
|
||||
void Player::SendExplorationExperience(uint32 Area, uint32 Experience)
|
||||
{
|
||||
WorldPacket data( SMSG_EXPLORATION_EXPERIENCE, 8 );
|
||||
|
|
@ -18223,7 +17763,7 @@ void Player::SendInitialPacketsBeforeAddToMap()
|
|||
GetSession()->SendPacket(&data);
|
||||
|
||||
SendInitialActionButtons();
|
||||
SendInitialReputations();
|
||||
m_reputationMgr.SendInitialReputations();
|
||||
m_achievementMgr.SendAllAchievementData();
|
||||
|
||||
// update zone
|
||||
|
|
@ -18742,6 +18282,7 @@ void Player::SummonIfPossible(bool agree)
|
|||
}
|
||||
|
||||
// drop flag at summon
|
||||
// this code can be reached only when GM is summoning player who carries flag, because player should be immune to summoning spells when he carries flag
|
||||
if(BattleGround *bg = GetBattleGround())
|
||||
bg->EventPlayerDroppedFlag(this);
|
||||
|
||||
|
|
@ -19388,6 +18929,7 @@ bool Player::CanUseBattleGroundObject()
|
|||
return ( //InBattleGround() && // in battleground - not need, check in other cases
|
||||
//!IsMounted() && - not correct, player is dismounted when he clicks on flag
|
||||
//i'm not sure if these two are correct, because invisible players should get visible when they click on flag
|
||||
!isTotalImmune() && // not totally immune
|
||||
!HasStealthAura() && // not stealthed
|
||||
!HasInvisibilityAura() && // not invisible
|
||||
!HasAura(SPELL_RECENTLY_DROPPED_FLAG, 0) && // can't pickup
|
||||
|
|
@ -19555,6 +19097,20 @@ void Player::ExitVehicle(Vehicle *vehicle)
|
|||
CastSpell(this, 45472, true); // Parachute
|
||||
}
|
||||
|
||||
bool Player::isTotalImmune()
|
||||
{
|
||||
AuraList const& immune = GetAurasByType(SPELL_AURA_SCHOOL_IMMUNITY);
|
||||
|
||||
uint32 immuneMask = 0;
|
||||
for(AuraList::const_iterator itr = immune.begin(); itr != immune.end(); ++itr)
|
||||
{
|
||||
immuneMask |= (*itr)->GetModifier()->m_miscvalue;
|
||||
if( immuneMask & SPELL_SCHOOL_MASK_ALL ) // total immunity
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Player::HasTitle(uint32 bitIndex)
|
||||
{
|
||||
if (bitIndex > 128)
|
||||
|
|
@ -19865,7 +19421,7 @@ void Player::HandleFall(MovementInfo const& movementInfo)
|
|||
if (GetDummyAura(43621))
|
||||
damage = GetMaxHealth()/2;
|
||||
|
||||
EnvironmentalDamage(GetGUID(), DAMAGE_FALL, damage);
|
||||
EnvironmentalDamage(DAMAGE_FALL, damage);
|
||||
|
||||
// recheck alive, might have died of EnvironmentalDamage
|
||||
if (isAlive())
|
||||
|
|
@ -20143,6 +19699,12 @@ void Player::UpdateKnownCurrencies(uint32 itemId, bool apply)
|
|||
}
|
||||
}
|
||||
|
||||
void Player::UpdateFallInformationIfNeed( MovementInfo const& minfo,uint16 opcode )
|
||||
{
|
||||
if (m_lastFallTime >= minfo.fallTime || m_lastFallZ <=minfo.z || opcode == MSG_MOVE_FALL_LAND)
|
||||
SetFallInformation(minfo.fallTime, minfo.z);
|
||||
}
|
||||
|
||||
void Player::BuildPlayerTalentsInfoData(WorldPacket *data)
|
||||
{
|
||||
*data << uint32(GetFreeTalentPoints()); // unspentTalentPoints
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue