Пример #1
0
        bool CanGainParagonReputationForFaction(FactionRecord factionEntry)
        {
            if (!CliDB.FactionStorage.ContainsKey(factionEntry.ParagonFactionID))
            {
                return(false);
            }

            if (GetRank(factionEntry) != ReputationRank.Exalted)
            {
                return(false);
            }

            ParagonReputationRecord paragonReputation = Global.DB2Mgr.GetParagonReputation(factionEntry.ParagonFactionID);

            if (paragonReputation == null)
            {
                return(false);
            }

            Quest quest = Global.ObjectMgr.GetQuestTemplate((uint)paragonReputation.QuestID);

            if (quest == null)
            {
                return(false);
            }

            return(_player.GetLevel() >= _player.GetQuestMinLevel(quest));
        }
Пример #2
0
        int GetParagonLevel(FactionRecord paragonFactionEntry)
        {
            if (paragonFactionEntry == null)
            {
                return(0);
            }

            ParagonReputationRecord paragonReputation = Global.DB2Mgr.GetParagonReputation(paragonFactionEntry.Id);

            if (paragonReputation != null)
            {
                return(GetReputation(paragonFactionEntry) / paragonReputation.LevelThreshold);
            }

            return(0);
        }
Пример #3
0
        int GetMaxReputation(FactionRecord factionEntry)
        {
            ParagonReputationRecord paragonReputation = Global.DB2Mgr.GetParagonReputation(factionEntry.Id);

            if (paragonReputation != null)
            {
                // has reward quest, cap is just before threshold for another quest reward
                // for example: if current reputation is 12345 and questa are given every 10000 and player has unclaimed reward
                // then cap will be 19999

                // otherwise cap is one theshold level larger
                // if current reputation is 12345 and questa are given every 10000 and player does NOT have unclaimed reward
                // then cap will be 29999

                int reputation = GetReputation(factionEntry);
                int cap        = reputation + paragonReputation.LevelThreshold - reputation % paragonReputation.LevelThreshold - 1;

                if (_player.GetQuestStatus((uint)paragonReputation.QuestID) == QuestStatus.None)
                {
                    cap += paragonReputation.LevelThreshold;
                }

                return(cap);
            }

            var friendshipReactions = Global.DB2Mgr.GetFriendshipRepReactions(factionEntry.FriendshipRepID);

            if (!friendshipReactions.Empty())
            {
                return(friendshipReactions.LastOrDefault().ReactionThreshold);
            }

            int dataIndex = GetFactionDataIndexForRaceAndClass(factionEntry);

            if (dataIndex >= 0)
            {
                return(factionEntry.ReputationMax[dataIndex]);
            }

            return(ReputationRankThresholds.LastOrDefault());
        }
Пример #4
0
        public bool SetOneFactionReputation(FactionRecord factionEntry, int standing, bool incremental)
        {
            var factionState = _factions.LookupByKey((uint)factionEntry.ReputationIndex);

            if (factionState != null)
            {
                int BaseRep = GetBaseReputation(factionEntry);

                if (incremental)
                {
                    // int32 *= float cause one point loss?
                    standing  = (int)(Math.Floor(standing * WorldConfig.GetFloatValue(WorldCfg.RateReputationGain) + 0.5f));
                    standing += factionState.Standing + BaseRep;
                }

                if (standing > GetMaxReputation(factionEntry))
                {
                    standing = GetMaxReputation(factionEntry);
                }
                else if (standing < GetMinReputation(factionEntry))
                {
                    standing = GetMinReputation(factionEntry);
                }

                ReputationRank old_rank = ReputationToRank(factionEntry, factionState.Standing + BaseRep);
                ReputationRank new_rank = ReputationToRank(factionEntry, standing);

                int oldStanding = factionState.Standing + BaseRep;
                int newStanding = standing - BaseRep;

                _player.ReputationChanged(factionEntry, newStanding - factionState.Standing);

                factionState.Standing = newStanding;
                factionState.needSend = true;
                factionState.needSave = true;

                SetVisible(factionState);

                if (new_rank <= ReputationRank.Hostile)
                {
                    SetAtWar(factionState, true);
                }

                if (new_rank > old_rank)
                {
                    _sendFactionIncreased = true;
                }

                ParagonReputationRecord paragonReputation = Global.DB2Mgr.GetParagonReputation(factionEntry.Id);
                if (paragonReputation != null)
                {
                    int oldParagonLevel = oldStanding / paragonReputation.LevelThreshold;
                    int newParagonLevel = standing / paragonReputation.LevelThreshold;
                    if (oldParagonLevel != newParagonLevel)
                    {
                        Quest paragonRewardQuest = Global.ObjectMgr.GetQuestTemplate((uint)paragonReputation.QuestID);
                        if (paragonRewardQuest != null)
                        {
                            _player.AddQuestAndCheckCompletion(paragonRewardQuest, null);
                        }
                    }
                }

                if (factionEntry.FriendshipRepID == 0 && paragonReputation == null)
                {
                    UpdateRankCounters(old_rank, new_rank);
                }

                _player.UpdateCriteria(CriteriaType.TotalFactionsEncountered, factionEntry.Id);
                _player.UpdateCriteria(CriteriaType.ReputationGained, factionEntry.Id);
                _player.UpdateCriteria(CriteriaType.TotalExaltedFactions, factionEntry.Id);
                _player.UpdateCriteria(CriteriaType.TotalReveredFactions, factionEntry.Id);
                _player.UpdateCriteria(CriteriaType.TotalHonoredFactions, factionEntry.Id);

                return(true);
            }
            return(false);
        }