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);
    }
}
Esempio n. 2
0
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);
	}
}
Esempio n. 4
0
void Player::ModStanding(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())
	{
		// New faction!
		FactionReputation * rep = new FactionReputation;
		rep->flag = 0;
		rep->standing = Value;
		rep->baseStanding = 0;
		m_reputation[dbc->ID] = rep;
		if(dbc->RepListId >= 0)
			reputationByListId[dbc->RepListId] = rep;
	}
	else
	{
		// Bonus
		if(pctReputationMod > 0)
		{
			float d = float(float(pctReputationMod) / 100.0f);
			Value += FL2UINT( float( float(Value) * d ) );
		}

		// Increment it.
		if(RankChanged(itr->second->standing, Value))
		{
			itr->second->standing += Value;
			UpdateInrangeSetsBasedOnReputation();
		}
		else
		{
			itr->second->standing += Value;
		}

		// Set visible if invisible.
		if(!Visible(itr->second->flag))
		{
			SetFlagVisible(itr->second->flag);
			if(IsInWorld())
				m_session->OutPacket(SMSG_SET_FACTION_VISIBLE, 4, &dbc->RepListId);
		}

		// Set at war if we're beyond hostile.
		if(GetReputationRankFromStanding(itr->second->standing) <= STANDING_HOSTILE && !AtWar(itr->second->flag))
			SetFlagAtWar(itr->second->flag);

		if(IsInWorld() && Visible(itr->second->flag))
		{
			WorldPacket data(SMSG_SET_FACTION_STANDING, 12);
			data << uint32(0) << uint8(0) << uint32(1) << dbc->RepListId << itr->second->CalcStanding();
			m_session->SendPacket(&data);
		}
   }

#ifdef OPTIMIZED_PLAYER_SAVING
	save_Reputation();
#endif
}