void Player::ModStanding(uint32 Faction, int32 Value)
{
    ReputationMap::iterator itr = m_reputation.find(Faction);
    FactionDBC* dbc = dbcFaction.LookupEntryForced(Faction);
    if (dbc == NULL || dbc->RepListId < 0)
        return;

    if(itr == m_reputation.end())
    {
        if (AddNewFaction(dbc, 0, true)) 
            return;
        itr = m_reputation.find( Faction );
        UpdateInrangeSetsBasedOnReputation();
        OnModStanding( dbc, itr->second );
    }
    else
    {
        int32 oldValue = itr->second->standing;
        int32 modValue = Value + (pctReputationMod > 0 ? Value * pctReputationMod / 100 : 0);
        int32 newValue = oldValue + modValue;
        itr->second->standing = newValue < -42000 ? -42000 : newValue > 42999 ? 42999 : newValue;
        if (RankChanged(oldValue, modValue)) 
            UpdateInrangeSetsBasedOnReputation();
        OnModStanding(dbc, itr->second);
    }
}
void Player::SetStanding(uint32 Faction, int32 Value)
{
    ReputationMap::iterator itr = m_reputation.find(Faction);
    FactionDBC * dbc = dbcFaction.LookupEntry(Faction);
    if(dbc == 0) return;

    if(itr == m_reputation.end())
    {
        if( !AddNewFaction( dbc, Value, false ) )
            return;
        itr = m_reputation.find( Faction );
        UpdateInrangeSetsBasedOnReputation();
        OnModStanding( dbc, itr->second );
    }
    else
    {
        // Assign it.
        if ( RankChangedFlat( itr->second->standing, Value ) )
        {
            itr->second->standing = Value;
            UpdateInrangeSetsBasedOnReputation();
        }
        else
            itr->second->standing = Value;
        
        OnModStanding( dbc, itr->second );
    }
}
Exemple #3
0
void Player::SetStanding(uint32 Faction, int32 Value)
{
	const int32 minReputation = -42000;      //   0/36000 Hated
	const int32 exaltedReputation = 42000;   //   0/1000  Exalted
	const int32 maxReputation = 42999;       // 999/1000  Exalted
	int32 newValue = Value;
	FactionDBC* f = dbcFaction.LookupEntryForced(Faction);
	if(f == NULL || f->RepListId < 0)
		return;
	ReputationMap::iterator itr = m_reputation.find(Faction);

	if(newValue < minReputation)
		newValue = minReputation;
	else if(newValue > maxReputation)
		newValue = maxReputation;

	if(itr == m_reputation.end())
	{
		if(!AddNewFaction(f, newValue, false))
			return;

		itr = m_reputation.find(Faction);
#ifdef ENABLE_ACHIEVEMENTS
		if(itr->second->standing >= 42000)   // check if we are exalted now
			m_achievementMgr.UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_EXALTED_REPUTATION, 1, 0, 0);   // increment # of exalted

		m_achievementMgr.UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_REPUTATION, f->ID, itr->second->standing, 0);
#endif
		UpdateInrangeSetsBasedOnReputation();
		OnModStanding(f, itr->second);
	}
	else
	{
		// Assign it.
		if(RankChangedFlat(itr->second->standing, newValue))
		{
#ifdef ENABLE_ACHIEVEMENTS
			if(itr->second->standing - newValue >= exaltedReputation) // somehow we lost exalted status
				m_achievementMgr.UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_EXALTED_REPUTATION, -1, 0, 0); // decrement # of exalted
			else if(newValue >= exaltedReputation) // check if we are exalted now
				m_achievementMgr.UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_EXALTED_REPUTATION, 1, 0, 0); // increment # of exalted
#endif
			itr->second->standing = newValue;
			UpdateInrangeSetsBasedOnReputation();
#ifdef ENABLE_ACHIEVEMENTS
			m_achievementMgr.UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_REPUTATION, f->ID, Value, 0);
#endif
		}
		else
			itr->second->standing = newValue;

		OnModStanding(f, itr->second);
	}

#ifdef OPTIMIZED_PLAYER_SAVING
	save_Reputation();
#endif
}
void Player::SetStanding( uint32 Faction, int32 Value )
{
	FactionDBC * f = dbcFaction.LookupEntry( Faction );
	if ( f == NULL || f->RepListId < 0 )
		return;
	ReputationMap::iterator itr = m_reputation.find( Faction );

	if( itr == m_reputation.end() )
	{
		if ( !AddNewFaction( f, Value, false ) )
			return;
	}
	else
	{
		// Increment it.
		if ( RankChangedFlat( itr->second->standing, Value ) )
		{
			itr->second->standing = Value;
			UpdateInrangeSetsBasedOnReputation();
		}
		else
			itr->second->standing = Value;
		
		OnModStanding( f, itr->second );
	}

#ifdef OPTIMIZED_PLAYER_SAVING
	save_Reputation();
#endif
}
void Player::ModStanding( uint32 Faction, int32 Value )
{
	FactionDBC * f = dbcFaction.LookupEntry( Faction );
	if ( f == NULL || f->RepListId < 0 )
		return;
	ReputationMap::iterator itr = m_reputation.find( Faction );

	if ( pctReputationMod > 0 )
	{
		float d = float( float( pctReputationMod ) / 100.0f );
		Value += FL2UINT( float( float( Value ) * d ) );
	}

	if ( itr == m_reputation.end() )
	{
		if ( !AddNewFaction( f, Value, false ) )
			return;
	}
	else
	{
		// Increment it.
		if ( RankChanged( itr->second->standing, Value ) )
		{
			itr->second->standing += Value;
			UpdateInrangeSetsBasedOnReputation();
		}
		else
		{
			itr->second->standing += Value;
		}
		
		OnModStanding( f, itr->second );
   }

#ifdef OPTIMIZED_PLAYER_SAVING
	save_Reputation();
#endif
}
void Player::ModStanding(uint32 Faction, int32 Value)
{
	const int32 minReputation = -42000;      //   0/36000 Hated
	const int32 exaltedReputation = 42000;   //   0/1000  Exalted
	const int32 maxReputation = 42999;       // 999/1000  Exalted

	// WE ARE THE CHAMPIONS MY FRIENDS! WE KEEP ON FIGHTING 'TILL THE END!
	//
	// If we are in a lvl80 instance or heroic, or raid and we have a championing tabard on,
	// we get reputation after the faction determined by the worn tabard.
	if((GetMapMgr()->GetMapInfo()->minlevel == 80 ||
	        (GetMapMgr()->iInstanceMode == MODE_HEROIC &&
	         GetMapMgr()->GetMapInfo()->minlevel_heroic == 80)) &&
	        ChampioningFactionID != 0)
		Faction = ChampioningFactionID;

	FactionDBC* f = dbcFaction.LookupEntryForced(Faction);
	int32 newValue = Value;
	if(f == NULL || f->RepListId < 0)
		return;
	ReputationMap::iterator itr = m_reputation.find(Faction);

	if(itr == m_reputation.end())
	{
		if(newValue < minReputation)
			newValue = minReputation;
		else if(newValue > maxReputation)
			newValue = maxReputation;

		if(!AddNewFaction(f, newValue, false))
			return;

		itr = m_reputation.find(Faction);
#ifdef ENABLE_ACHIEVEMENTS
		if(itr->second->standing >= 42000)   // check if we are exalted now
			m_achievementMgr.UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_EXALTED_REPUTATION, 1, 0, 0);   // increment # of exalted

		m_achievementMgr.UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_REPUTATION, f->ID, itr->second->standing, 0);
#endif
		UpdateInrangeSetsBasedOnReputation();
		OnModStanding(f, itr->second);
	}
	else
	{
		if(pctReputationMod > 0)
		{
			newValue = Value + (Value * pctReputationMod / 100);
		}
		// Increment it.
		if(RankChanged(itr->second->standing, newValue))
		{
			itr->second->standing += newValue;
			UpdateInrangeSetsBasedOnReputation();
#ifdef ENABLE_ACHIEVEMENTS
			m_achievementMgr.UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_REPUTATION, f->ID, itr->second->standing, 0);
			if(itr->second->standing >= exaltedReputation) // check if we are exalted now
				m_achievementMgr.UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_EXALTED_REPUTATION, 1, 0, 0); // increment # of exalted
			else if(itr->second->standing - newValue >= exaltedReputation) // somehow we lost exalted status
				m_achievementMgr.UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_EXALTED_REPUTATION, -1, 0, 0); // decrement # of exalted
#endif
		}
		else
			itr->second->standing += newValue;

		if(itr->second->standing < minReputation)
			itr->second->standing = minReputation;
		else if(itr->second->standing > maxReputation)
			itr->second->standing = maxReputation;
		OnModStanding(f, itr->second);
	}
}