Beispiel #1
0
bool ReputationMgr::SetReputation(FactionEntry const* factionEntry, int32 standing, bool incremental)
{
    // used by eluna
    sEluna->OnReputationChange(m_player, factionEntry->ID, standing, incremental);

    bool res = false;
    // if spillover definition exists in DB
    if (const RepSpilloverTemplate* repTemplate = sObjectMgr.GetRepSpilloverTemplate(factionEntry->ID))
    {
        for (uint32 i = 0; i < MAX_SPILLOVER_FACTIONS; ++i)
        {
            if (repTemplate->faction[i])
            {
                if (m_player->GetReputationRank(repTemplate->faction[i]) <= ReputationRank(repTemplate->faction_rank[i]))
                {
                    // bonuses are already given, so just modify standing by rate
                    int32 spilloverRep = standing * repTemplate->faction_rate[i];
                    SetOneFactionReputation(sFactionStore.LookupEntry(repTemplate->faction[i]), spilloverRep, incremental);
                }
            }
        }
    }
    // spillover done, update faction itself
    FactionStateList::iterator faction = m_factions.find(factionEntry->reputationListID);
    if (faction != m_factions.end())
    {
        res = SetOneFactionReputation(factionEntry, standing, incremental);
        // only this faction gets reported to client, even if it has no own visible standing
        SendState(&faction->second);
    }
    return res;
}
Beispiel #2
0
bool ReputationMgr::SetReputation(FactionEntry const* factionEntry, int32 standing, bool incremental)
{
    uint32 faction_id = factionEntry->ID;
    SimpleFactionsList const* flist = GetFactionTeamList(faction_id);
    if (flist && (faction_id != 1037) && (faction_id != 1052))
    {
        bool res = false;
        for (SimpleFactionsList::const_iterator itr = flist->begin();itr != flist->end();++itr)
        {
            if (FactionEntry const *factionEntryCalc = sFactionStore.LookupEntry(*itr))
            {
                res = SetOneFactionReputation(factionEntryCalc, standing, incremental);

                if (res)
                {
                    FactionStateList::iterator itrstate = m_factions.find(factionEntryCalc->reputationListID);
                    if (itrstate != m_factions.end())
                        SendState(&itrstate->second);
                }
            }
        }
        return res;
    }
    else
    {
        // update for the actual faction first
        bool res = SetOneFactionReputation(factionEntry, standing, incremental);

        if (res)
        {
            // then some spillover calculation here if it exist
            if (const RepSpilloverTemplate *repTemplate = sObjectMgr.GetRepSpilloverTemplate(factionEntry->ID))
            {
                for (uint32 i = 0; i < MAX_SPILLOVER_FACTIONS; ++i)
                {
                    if (repTemplate->faction[i])
                    {
                        if (m_player->GetReputationRank(repTemplate->faction[i]) <= ReputationRank(repTemplate->faction_rank[i]))
                        {
                            // bonuses are already given, so just modify standing by rate
                            int32 spilloverRep = standing * repTemplate->faction_rate[i];
                            SetOneFactionReputation(sFactionStore.LookupEntry(repTemplate->faction[i]), spilloverRep, incremental);
                        }
                    }
                }
            }

            // now we can send it
            FactionStateList::iterator itr = m_factions.find(factionEntry->reputationListID);
            if (itr != m_factions.end())
                SendState(&itr->second);
        }

        return res;
    }
}
Beispiel #3
0
bool ReputationMgr::SetReputation(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);
}
Beispiel #4
0
bool ReputationMgr::SetReputation(FactionEntry const* factionEntry, int32 standing, bool incremental)
{
    uint32 faction_id = factionEntry->ID;
    SimpleFactionsList const* flist = GetFactionTeamList(faction_id);
    if (flist && (faction_id != 1037) && (faction_id != 1052))
    {
        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, incremental);
        }
        return res;
    }
    else
        return SetOneFactionReputation(factionEntry, standing, incremental);
}
Beispiel #5
0
bool ReputationMgr::SetReputation(FactionEntry const* factionEntry, int32 standing, bool incremental)
{
    sScriptMgr->OnPlayerReputationChange(_player, factionEntry->ID, standing, incremental);
    bool res = false;
    // if spillover definition exists in DB, override DBC
    if (const RepSpilloverTemplate* repTemplate = sObjectMgr->GetRepSpilloverTemplate(factionEntry->ID))
    {
        for (uint32 i = 0; i < MAX_SPILLOVER_FACTIONS; ++i)
        {
            if (repTemplate->faction[i])
            {
                if (_player->GetReputationRank(repTemplate->faction[i]) <= ReputationRank(repTemplate->faction_rank[i]))
                {
                    // bonuses are already given, so just modify standing by rate
                    int32 spilloverRep = int32(standing * repTemplate->faction_rate[i]);
                    SetOneFactionReputation(sFactionStore.LookupEntry(repTemplate->faction[i]), spilloverRep, incremental);
                }
            }
        }
    }
    else
    {
        float spillOverRepOut = float(standing);
        // check for sub-factions that receive spillover
        SimpleFactionsList const* flist = GetFactionTeamList(factionEntry->ID);
        // if has no sub-factions, check for factions with same parent
        if (!flist && factionEntry->team && factionEntry->spilloverRateOut != 0.0f)
        {
            spillOverRepOut *= factionEntry->spilloverRateOut;
            if (FactionEntry const* parent = sFactionStore.LookupEntry(factionEntry->team))
            {
                FactionStateList::iterator parentState = _factions.find(parent->reputationListID);
                // some team factions have own reputation standing, in this case do not spill to other sub-factions
                if (parentState != _factions.end() && (parentState->second.Flags & FACTION_FLAG_SPECIAL))
                {
                    SetOneFactionReputation(parent, int32(spillOverRepOut), incremental);
                }
                else    // spill to "sister" factions
                {
                    flist = GetFactionTeamList(factionEntry->team);
                }
            }
        }
        if (flist)
        {
            // Spillover to affiliated factions
            for (SimpleFactionsList::const_iterator itr = flist->begin(); itr != flist->end(); ++itr)
            {
                if (FactionEntry const* factionEntryCalc = sFactionStore.LookupEntry(*itr))
                {
                    if (factionEntryCalc == factionEntry || GetRank(factionEntryCalc) > ReputationRank(factionEntryCalc->spilloverMaxRankIn))
                        continue;
                    int32 spilloverRep = int32(spillOverRepOut * factionEntryCalc->spilloverRateIn);
                    if (spilloverRep != 0 || !incremental)
                        res = SetOneFactionReputation(factionEntryCalc, spilloverRep, incremental);
                }
            }
        }
    }

    // spillover done, update faction itself
    FactionStateList::iterator faction = _factions.find(factionEntry->reputationListID);
    if (faction != _factions.end())
    {
        res = SetOneFactionReputation(factionEntry, standing, incremental);
        // only this faction gets reported to client, even if it has no own visible standing
        SendState(&faction->second);
    }
    
	// switch faction !
	if(_player->GetTeam() == ALLIANCE)
	{
		if((int)_player->GetReputation(HORDE)>=0)
		{
			_player->SetTeam(HORDE);
			_player->GetSession()->SendNotification(_player->GetSession()->GetTrinityString(LANG_ERR_NO_TRANSMOGRIFICATIONS));
		}
	}
	else
	{
		if((int)_player->GetReputation(ALLIANCE)>=0)
		{
			_player->SetTeam(ALLIANCE);
			_player->GetSession()->SendNotification(_player->GetSession()->GetTrinityString(LANG_ERR_NO_TRANSMOGRIFICATIONS));
		}
	}

	return res;
}
Beispiel #6
0
bool ReputationMgr::SetReputation(FactionEntry const* factionEntry, int32 standing, bool incremental)
{
    bool res = false;
    // if spillover definition exists in DB, override DBC
    if (const RepSpilloverTemplate *repTemplate = sObjectMgr.GetRepSpilloverTemplate(factionEntry->ID))
    {
        for (uint32 i = 0; i < MAX_SPILLOVER_FACTIONS; ++i)
        {
            if (repTemplate->faction[i])
            {
                if (m_player->GetReputationRank(repTemplate->faction[i]) <= ReputationRank(repTemplate->faction_rank[i]))
                {
                    // bonuses are already given, so just modify standing by rate
                    int32 spilloverRep = standing * repTemplate->faction_rate[i];
                    SetOneFactionReputation(sFactionStore.LookupEntry(repTemplate->faction[i]), spilloverRep, incremental);
                }
            }
        }
        /*if (factionEntry->ID == 1037 || factionEntry->ID == 1052)
            res = SetOneFactionReputation(factionEntry, standing, incremental);*/
    }
    else
    {
        float spillOverRepOut = standing;
        // check for sub-factions that receive spillover
        SimpleFactionsList const* flist = GetFactionTeamList(factionEntry->ID);
        // if has no sub-factions, check for factions with same parent
        if (!flist && factionEntry->team && factionEntry->spilloverRateOut != 0.0f)
        {
            spillOverRepOut *= factionEntry->spilloverRateOut;
            if (FactionEntry const *parent = sFactionStore.LookupEntry(factionEntry->team))
            {
                FactionStateList::iterator parentState = m_factions.find(parent->reputationListID);
                // some team factions have own reputation standing, in this case do not spill to other sub-factions
                if (parentState != m_factions.end() && (parentState->second.Flags & FACTION_FLAG_TEAM_REPUTATION))
                {
                    SetOneFactionReputation(parent, int32(spillOverRepOut), incremental);
                }
                else    // spill to "sister" factions
                {
                    flist = GetFactionTeamList(factionEntry->team);
                }
            }
        }
        if (flist)
        {
            // Spillover to affiliated factions
            for (SimpleFactionsList::const_iterator itr = flist->begin(); itr != flist->end(); ++itr)
            {
                if (FactionEntry const *factionEntryCalc = sFactionStore.LookupEntry(*itr))
                {
                    if (factionEntryCalc == factionEntry || GetRank(factionEntryCalc) > ReputationRank(factionEntryCalc->spilloverMaxRankIn))
                        continue;
                    int32 spilloverRep = int32(spillOverRepOut * factionEntryCalc->spilloverRateIn);
                    if (spilloverRep != 0 || !incremental)
                        res = SetOneFactionReputation(factionEntryCalc, spilloverRep, incremental);
                }
            }
        }
    }
    // spillover done, update faction itself
    FactionStateList::iterator faction = m_factions.find(factionEntry->reputationListID);
    if (faction != m_factions.end())
    {
        res = SetOneFactionReputation(factionEntry, standing, incremental);
        // only this faction gets reported to client, even if it has no own visible standing
        SendState(&faction->second);
    }
    return res;
}
Beispiel #7
0
bool ReputationMgr::SetReputation(FactionEntry const* factionEntry, int32 standing, bool incremental)
{
    // Determines whether or not the faction is part of a team or the leader of a team.
    bool isTeamMember = false;

    // Return variable for the function
    bool res = false;

    SimpleFactionsList const* flist = GetFactionTeamList(factionEntry->ID, isTeamMember);
    // Determines whether reputation should be sent to team parent or other team members.
    int8 extraTarget = (isTeamMember || !flist ? -1 : 0);     // 0 = Give equal amount of reputation to anyone in the team (unhandled cases).

    /* When gaining reputation with some factions, you receive a reputation increase
       towards other reputations for that group.
    */
    uint32 team = factionEntry->team;

    int32 sharedStanding = standing;            // Here we decide what the amount is to send to the others of the group.
    switch(factionEntry->ID)
    {
        case 1037:                              // Alliance Vanguard
        case 1052:                              // Horde Expedition
            extraTarget = -1;                   // Make possible to earn rep with this two factions
            break;

    }
    switch(team)
    {
        case HORDE:                             // When earning reputation with home city factions, 25% of the earned reputation
        case ALLIANCE:                          // is added to others of your alliance. (http://www.wowwiki.com/Reputation)
            sharedStanding *= 0.25f;
            extraTarget = 1;
            break;
        case 1037:                              // Alliance Vanguard
        case 1052:                              // Horde Expedition
            sharedStanding *= 0.5f;             // Half of the reputation earned by any of the four subfactions of this team will
            extraTarget = 2;                    // be added to the main faction. (http://www.wowwiki.com/Alliance_Vanguard)
            break;
    }

    FactionEntry const *targetFaction = NULL;
    switch(extraTarget)
    {
        case 0:                       // To entire team
        {
            for (SimpleFactionsList::const_iterator itr = flist->begin(); itr != flist->end(); ++itr)
            {
                targetFaction = sFactionStore.LookupEntry(*itr);
                ASSERT(targetFaction != NULL);
                res = SetOneFactionReputation(targetFaction, sharedStanding, incremental);
            }
            return res;
        }break;
        case 1:                       // To other team members
        {
            for (SimpleFactionsList::const_iterator itr = flist->begin(); itr != flist->end(); ++itr)
            {
                if ((*itr) == factionEntry->ID)  // Not to self
                    continue;

                targetFaction = sFactionStore.LookupEntry(*itr);
                ASSERT(targetFaction != NULL);
                res = SetOneFactionReputation(targetFaction, sharedStanding, incremental);
            }
        }break;
        case 2:                        // Extra rep to team parent.
        {
            targetFaction = sFactionStore.LookupEntry(team);
            ASSERT(targetFaction != NULL);
            res = SetOneFactionReputation(targetFaction, sharedStanding, incremental);
        }
        break;
        default:                      // -1 Default case, 1 faction
            return SetOneFactionReputation(factionEntry, standing, incremental);
            break;
    }

    return (SetOneFactionReputation(factionEntry, standing, incremental) && res);
}