void Player::Reputation_OnTalk(FactionDBC * dbc)
{
	// set faction visible if not visible
	if(!dbc || dbc->RepListId < 0)
		return;

	FactionReputation * rep = reputationByListId[dbc->RepListId];
	if(!rep)
		return;

	if(!Visible(rep->flag))
	{
		SetFlagVisible(rep->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
		}

#ifdef OPTIMIZED_PLAYER_SAVING
		save_Reputation();
#endif
	}
}
Esempio n. 2
0
void Player::_InitialReputation()
{
	// Generate Initial Reputation Values
	FactionReputation * rep;
	FactionDBC * f;
	int32 BaseRep = 0;
	uint32 j;
	uint32 RaceMask = getRaceMask();
	for(uint32 i = 0; i < dbcFaction.GetNumRows(); ++i)
	{
		f = dbcFaction.LookupRow(i);
		if(f == 0) continue;

		// Get Base Reputation
		for(j = 0; j < 4; ++j)
		{
			if(f->baseRepMask[j] & RaceMask)
			{
				BaseRep = f->baseRepValue[j];
				break;
			}
		}

		if(j != 4 && f->RepListId >= 0)
		{
			// This is one we can add.
			rep = new FactionReputation;
			rep->standing = BaseRep;
			rep->flag = 0;
			rep->baseStanding = BaseRep;
			if(GetReputationRankFromStanding(BaseRep) <= STANDING_HOSTILE)
				SetFlagAtWar(rep->flag);

			// Visible-ness shit.
			if((f->parentFaction == 469 && GetTeam() == 0) ||		// Alliance own faction.
				(f->parentFaction == 67 && GetTeam() == 1) )		 // Horde own faction.
			{
				SetFlagVisible(rep->flag);
				SetFlagPeaceForced(rep->flag);
			}

			if((f->parentFaction == 469 && GetTeam() == 1) ||		// Alliance own faction.
				(f->parentFaction == 67 && GetTeam() == 0) )		 // Horde own faction.
			{
				SetForcedInvisible(rep->flag);
			}
				
			reputationByListId[f->RepListId] = rep;
		}
		else
		{
			// No default standing.
			continue;
		}

		m_reputation[f->ID] = rep;
	}
}
Esempio n. 3
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
}
Esempio n. 4
0
void Player::OnModStanding( FactionDBC * dbc, FactionReputation * rep )
{
	if ( SetFlagVisible( rep->flag, true ) && 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
	}

	SetFlagAtWar( rep->flag, ( GetReputationRankFromStanding( rep->standing ) <= STANDING_HOSTILE ) );

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

	// PVP title as a reward for exalted reputations
	switch( dbc->RepListId )
	{
		case FACTION_STORMPIKE_GUARDS:
		case FACTION_SILVERWING_SENTINELS:
		case FACTION_THE_LEAGUE_OF_ARATHOR:
		{
			if( GetTeam() == 0 && 
				GetStandingRank( 730 ) == STANDING_EXALTED &&
				GetStandingRank( 890 ) == STANDING_EXALTED &&
				GetStandingRank( 509 ) == STANDING_EXALTED )
			{
				SetKnownTitle( PVPTITLE_JUSTICAR , true );
			}
			else
				SetKnownTitle( PVPTITLE_JUSTICAR , false );
		} break;
		case FACTION_THE_DEFILERS:
		case FACTION_FROSTWOLF_CLAN:
		case FACTION_WARSONG_OUTRIDERS:
		{
			if( GetTeam() == 1 && 
				GetStandingRank( 510 ) == STANDING_EXALTED &&
				GetStandingRank( 729 ) == STANDING_EXALTED &&
				GetStandingRank( 889 ) == STANDING_EXALTED )
			{
				SetKnownTitle( PVPTITLE_CONQUEROR , true );
			}
			else
				SetKnownTitle( PVPTITLE_CONQUEROR , false );
		} break;
	}
}
void Player::Reputation_OnTalk(FactionDBC* dbc)
{
	// set faction visible if not visible
	if(dbc == NULL || dbc->RepListId < 0)
		return;

	FactionReputation* rep = reputationByListId[dbc->RepListId];
	if(rep == NULL)
		return;

	if(SetFlagVisible(rep->flag, true) && IsInWorld())
	{
		m_session->OutPacket(SMSG_SET_FACTION_VISIBLE, 4, &dbc->RepListId);
	}
}
void Player::Reputation_OnTalk(FactionDBC * dbc)
{
    // set faction visible if not visible
    if(!dbc || dbc->RepListId < 0)
        return;

    FactionReputation * rep = reputationByListId[dbc->RepListId];
    if(!rep)
        return;

    if(!Visible(rep->flag))
    {
        SetFlagVisible(rep->flag);
        if(IsInWorld())
            m_session->OutPacket(SMSG_SET_FACTION_VISIBLE, 4, &dbc->RepListId);
    }
}
void Player::OnModStanding(FactionDBC* dbc, FactionReputation* rep)
{
	if(SetFlagVisible(rep->flag, true) && IsInWorld())
	{

		m_session->OutPacket(SMSG_SET_FACTION_VISIBLE, 4, &dbc->RepListId);
	}

	SetFlagAtWar(rep->flag, (GetReputationRankFromStanding(rep->standing) <= STANDING_HOSTILE));

	if(Visible(rep->flag) && IsInWorld())
	{
		WorldPacket data(SMSG_SET_FACTION_STANDING, 17);
		data << uint32(0) ;
		data << uint8(1) ;   //count
		data << uint32(rep->flag) << dbc->RepListId << rep->CalcStanding();
		m_session->SendPacket(&data);
	}
}
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
}