void Player::SetAtWar(uint32 Faction, bool Set)
{
    if( Faction >= 128 )
        return;

    FactionReputation * rep = reputationByListId[Faction];
    if(!rep)
        return;

    if(GetReputationRankFromStanding(rep->standing) <= STANDING_HOSTILE && !Set) // At this point we have to be at war.
        return;

    if(rep->flag & 0x4 || rep->flag & 16 )
        return;

    if(Set)
    {
        if(!AtWar(rep->flag))
            SetFlagAtWar(rep->flag);

        UpdateInrangeSetsBasedOnReputation();
    }
    else
    {
        if(AtWar(rep->flag))
            UnsetFlagAtWar(rep->flag);

        UpdateInrangeSetsBasedOnReputation();
    }
}
示例#2
0
void Player::SetAtWar(uint32 Faction, bool Set)
{
	if( Faction >= 128 )
		return;

	FactionReputation * rep = reputationByListId[Faction];
	if(!rep) return;
	
	if(GetReputationRankFromStanding(rep->standing) <= STANDING_HOSTILE && !Set) // At this point we have to be at war.
		return;

	FactionDBC * f = dbcFaction.LookupEntry(Faction);
	if(rep->flag & 0x4)
		return;

	if(Set)
	{
		if(!AtWar(rep->flag))
			SetFlagAtWar(rep->flag);

		UpdateInrangeSetsBasedOnReputation();
	}
	else
	{
		if(AtWar(rep->flag))
			UnsetFlagAtWar(rep->flag);

		UpdateInrangeSetsBasedOnReputation();
	}

#ifdef OPTIMIZED_PLAYER_SAVING
	save_Reputation();
#endif
}
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 );
    }
}
示例#5
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
}
示例#6
0
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
}
示例#7
0
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())
	{
		// 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
	{
		// Increment it.
		if(RankChangedFlat(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.
		Standing rank = GetReputationRankFromStanding(itr->second->standing);
		if(rank <= STANDING_HOSTILE && !AtWar(itr->second->flag))
			SetFlagAtWar(itr->second->flag);
		else if(rank >= STANDING_NEUTRAL && AtWar(itr->second->flag))
			UnsetFlagAtWar(itr->second->flag);

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

#ifdef OPTIMIZED_PLAYER_SAVING
	save_Reputation();
#endif
}
void Player::SetAtWar(uint32 Faction, bool Set)
{
	if(Faction >= 128)
		return;

	FactionReputation* rep = reputationByListId[Faction];
	if(rep == NULL)
		return;

	if(GetReputationRankFromStanding(rep->standing) <= STANDING_HOSTILE && !Set)     // At this point we have to be at war.
		return;

	if(!CanToggleAtWar(rep->flag))
		return;

	if(SetFlagAtWar(rep->flag, Set))
	{
		UpdateInrangeSetsBasedOnReputation();
	}
}
示例#9
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);
	}
}
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())
			{
#ifdef USING_BIG_ENDIAN
				uint32 swapped = swap32(dbc->RepListId);
				m_session->OutPacket(SMSG_SET_FACTION_VISIBLE, 4, &swapped);
#else
				m_session->OutPacket(SMSG_SET_FACTION_VISIBLE, 4, &dbc->RepListId);
#endif
			}
		}

		// 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) << uint32(1) << dbc->RepListId << itr->second->CalcStanding();
			m_session->SendPacket(&data);
		}
   }

#ifdef OPTIMIZED_PLAYER_SAVING
	save_Reputation();
#endif
}