Пример #1
0
        /// <summary>
        /// Only called if the player declared war
        /// </summary>
        public void DeclareWar(FactionReputationIndex reputationIndex, bool hostile, bool sendUpdate)
        {
            var rep = GetOrCreate(reputationIndex);

            // impossible to declare war on your own faction
            if (rep.IsForcedAtPeace)
            {
                return;
            }

            // this shouldnt be needed because of the previous check
            if (rep.Faction.Group == m_owner.Faction.Group)
            {
                // can't declare war on your own faction.
                return;
            }

            if (rep.DeclaredWar != hostile)
            {
                rep.DeclaredWar = hostile;
                if (sendUpdate && rep.DeclaredWar)
                {
                    FactionHandler.SendSetAtWar(m_owner.Client, rep);
                }
            }
        }
Пример #2
0
        /// <summary>Sets the specified faction to the inactive state</summary>
        public static void HandleStopWatchingFaction(IRealmClient client, RealmPacketIn packet)
        {
            FactionReputationIndex reputationIndex = (FactionReputationIndex)packet.ReadInt32();
            bool inactive = packet.ReadBoolean();

            client.ActiveCharacter.Reputations.SetInactive(reputationIndex, inactive);
        }
Пример #3
0
        /// <summary>User starts/ends war with a faction</summary>
        public static void HandleStartWar(IRealmClient client, RealmPacketIn packet)
        {
            FactionReputationIndex reputationIndex = (FactionReputationIndex)packet.ReadUInt32();
            bool hostile = packet.ReadBoolean();

            client.ActiveCharacter.Reputations.DeclareWar(reputationIndex, hostile, true);
        }
Пример #4
0
 /// <summary>Makes the given faction visible to the client.</summary>
 public static void SendVisible(IPacketReceiver client, FactionReputationIndex reputationIndex)
 {
     using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SMSG_SET_FACTION_VISIBLE, 4))
     {
         packet.Write((int)reputationIndex);
         client.Send(packet, false);
     }
 }
Пример #5
0
 static ReputationInfo GetInfo(FactionReputationIndex index)
 {
     ReputationInfo rep;
     if (!InfosById.TryGetValue(index, out rep))
     {
         InfosById.Add(index, rep = new ReputationInfo(index));
     }
     return rep;
 }
Пример #6
0
 public Faction(FactionEntry entry, FactionTemplateEntry template)
 {
     Entry           = entry;
     Template        = template;
     Id              = entry.Id;
     ReputationIndex = entry.FactionIndex;
     IsAlliance      = template.FactionGroup.HasFlag(FactionGroupMask.Alliance);
     IsHorde         = template.FactionGroup.HasFlag(FactionGroupMask.Horde);
 }
Пример #7
0
 public Faction(FactionEntry entry, FactionTemplateEntry template)
 {
     this.Entry           = entry;
     this.Template        = template;
     this.Id              = entry.Id;
     this.ReputationIndex = entry.FactionIndex;
     this.IsAlliance      = template.FactionGroup.HasFlag((Enum)FactionGroupMask.Alliance);
     this.IsHorde         = template.FactionGroup.HasFlag((Enum)FactionGroupMask.Horde);
 }
Пример #8
0
		/// <summary>
		/// Makes the given faction visible to the client.
		/// </summary>
		public static void SendVisible(IPacketReceiver client, FactionReputationIndex reputationIndex)
		{
			using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_SET_FACTION_VISIBLE, 4))
			{
				packet.Write((int)reputationIndex);

				client.Send(packet);
			}
		}
Пример #9
0
        public void SetInactive(FactionReputationIndex reputationIndex, bool inactive)
        {
            var faction = GetOrCreate(reputationIndex);

            if (faction != null)
            {
                faction.IsInactive = true;
            }
        }
Пример #10
0
        public Reputation ModValue(FactionReputationIndex reputationIndex, int value)
        {
            Reputation rep = this.GetOrCreate(reputationIndex);

            if (rep != null)
            {
                this.ModValue(rep, value);
            }
            return(rep);
        }
Пример #11
0
        public StandingLevel GetStandingLevel(FactionReputationIndex reputationIndex)
        {
            Reputation reputation;

            if (this.m_byIndex.TryGetValue(reputationIndex, out reputation))
            {
                return(reputation.StandingLevel);
            }
            return(StandingLevel.Hated);
        }
Пример #12
0
        public int GetValue(FactionReputationIndex reputationIndex)
        {
            Reputation reputation;

            if (this.m_byIndex.TryGetValue(reputationIndex, out reputation))
            {
                return(reputation.Value);
            }
            return(0);
        }
Пример #13
0
        /// <summary>
        /// Creates a Reputation object that represents the relation to the given faction, or null
        /// </summary>
        /// <param name="factionIndex">The repListId of the faction</param>
        private Reputation Create(FactionReputationIndex factionIndex)
        {
            Faction faction = FactionMgr.Get(factionIndex);

            if (faction != null)
            {
                return(this.Create(faction));
            }
            return((Reputation)null);
        }
Пример #14
0
        /// <summary>
        /// Returns the corresponding Reputation object. Creates a new one
        /// if the player didn't meet this faction yet.
        /// </summary>
        /// <param name="reputationIndex">The repListId of the faction</param>
        internal Reputation GetOrCreate(FactionReputationIndex reputationIndex)
        {
            Reputation reputation;

            if (!this.m_byIndex.TryGetValue(reputationIndex, out reputation))
            {
                reputation = this.Create(reputationIndex);
            }
            return(reputation);
        }
Пример #15
0
        public void SetInactive(FactionReputationIndex reputationIndex, bool inactive)
        {
            Reputation reputation = this.GetOrCreate(reputationIndex);

            if (reputation == null)
            {
                return;
            }
            reputation.IsInactive = true;
        }
Пример #16
0
        /// <summary>
        /// Returns the corresponding Reputation object. Creates a new one
        /// if the player didn't meet this faction yet.
        /// </summary>
        /// <param name="reputationIndex">The repListId of the faction</param>
        internal Reputation GetOrCreate(FactionReputationIndex reputationIndex)
        {
            Reputation rep;

            if (!m_byIndex.TryGetValue(reputationIndex, out rep))
            {
                rep = Create(reputationIndex);
            }
            return(rep);
        }
Пример #17
0
        public static Faction Get(FactionReputationIndex repuataionIndex)
        {
            if ((uint)repuataionIndex >= ByReputationIndex.Length ||

                repuataionIndex < 0)
            {
                return(null);
            }
            return(ByReputationIndex[(uint)repuataionIndex]);
        }
Пример #18
0
        public Reputation SetValue(FactionReputationIndex reputationIndex, int value)
        {
            Reputation rep = GetOrCreate(reputationIndex);

            if (rep != null)
            {
                SetValue(rep, value);
            }
            return(rep);
        }
Пример #19
0
        public Reputation ModValue(FactionReputationIndex reputationIndex, int value)
        {
            var rep = GetOrCreate(reputationIndex);

            if (rep != null)
            {
                ModValue(rep, value);
            }
            return(rep);
        }
Пример #20
0
        /// <summary>
        /// Creates a Reputation object that represents the relation to the given faction, or null
        /// </summary>
        /// <param name="factionIndex">The repListId of the faction</param>
        private Reputation Create(FactionReputationIndex factionIndex)
        {
            var fac = FactionMgr.Get(factionIndex);

            if (fac != null)
            {
                return(Create(fac));
            }
            return(null);
        }
Пример #21
0
        static ReputationInfo GetInfo(FactionReputationIndex index)
        {
            ReputationInfo rep;

            if (!InfosById.TryGetValue(index, out rep))
            {
                InfosById.Add(index, rep = new ReputationInfo(index));
            }
            return(rep);
        }
Пример #22
0
        public StandingLevel GetStandingLevel(FactionReputationIndex reputationIndex)
        {
            Reputation rep;

            if (m_byIndex.TryGetValue(reputationIndex, out rep))
            {
                return(rep.StandingLevel);
            }
            return(StandingLevel.Unknown);
        }
Пример #23
0
        public int GetValue(FactionReputationIndex reputationIndex)
        {
            Reputation rep;

            if (m_byIndex.TryGetValue(reputationIndex, out rep))
            {
                return(rep.Value);
            }

            return(0);
        }
Пример #24
0
 public static FactionId GetId(FactionReputationIndex reputationIndex)
 {
     if (reputationIndex != FactionReputationIndex.End && (uint)reputationIndex < ByReputationIndex.Length)
     {
         var faction = ByReputationIndex[(uint)reputationIndex];
         if (faction != null)
         {
             return(faction.Id);
         }
     }
     return(0);
 }
Пример #25
0
 public Reputation this[FactionReputationIndex key]
 {
     get
     {
         Reputation rep;
         m_byIndex.TryGetValue(key, out rep);
         return(rep);
     }
     set
     {
         // don't do anything
         throw new Exception("To modify the reputation with a specific faction, just modify the values of an already existing Reputation object.");
     }
 }
Пример #26
0
        /// <summary>Only called if the player declared war</summary>
        public void DeclareWar(FactionReputationIndex reputationIndex, bool hostile, bool sendUpdate)
        {
            Reputation rep = this.GetOrCreate(reputationIndex);

            if (rep.IsForcedAtPeace || rep.Faction.Group == this.m_owner.Faction.Group || rep.DeclaredWar == hostile)
            {
                return;
            }
            rep.DeclaredWar = hostile;
            if (!sendUpdate || !rep.DeclaredWar)
            {
                return;
            }
            FactionHandler.SendSetAtWar((IPacketReceiver)this.m_owner.Client, rep);
        }
Пример #27
0
        /// <summary>Called when interacting with an NPC.</summary>
        public void OnTalkWith(NPC npc)
        {
            FactionReputationIndex reputationIndex = npc.Faction.ReputationIndex;

            if (reputationIndex < FactionReputationIndex.None || reputationIndex >= FactionReputationIndex.End)
            {
                return;
            }
            Reputation reputation = this.GetOrCreate(reputationIndex);

            if (reputation.IsForcedInvisible)
            {
                return;
            }
            reputation.IsVisible = true;
            this.Owner.Achievements.CheckPossibleAchievementUpdates(AchievementCriteriaType.KnownFactions, 0U, 0U,
                                                                    (Unit)null);
            FactionHandler.SendVisible((IPacketReceiver)this.m_owner.Client, reputationIndex);
        }
Пример #28
0
		/// <summary>
		/// Creates a Reputation object that represents the relation to the given faction, or null
		/// </summary>
		/// <param name="factionIndex">The repListId of the faction</param>
		private Reputation Create(FactionReputationIndex factionIndex)
		{
			var fac = FactionMgr.Get(factionIndex);
			if (fac != null)
			{
				return Create(fac);
			}
			return null;
		}
Пример #29
0
		public int GetValue(FactionReputationIndex reputationIndex)
		{
			Reputation rep;
			if (m_byIndex.TryGetValue(reputationIndex, out rep))
			{
				return rep.Value;
			}

			return 0;
		}
Пример #30
0
		public Reputation this[FactionReputationIndex key]
		{
			get
			{
				Reputation rep;
				m_byIndex.TryGetValue(key, out rep);
				return rep;
			}
			set
			{
				// don't do anything
				throw new Exception("To modify the reputation with a specific faction, just modify the values of an already existing Reputation object.");
			}
		}
Пример #31
0
		/// <summary>
		/// Returns the corresponding Reputation object. Creates a new one
		/// if the player didn't meet this faction yet.
		/// </summary>
		/// <param name="reputationIndex">The repListId of the faction</param>
		internal Reputation GetOrCreate(FactionReputationIndex reputationIndex)
		{
			Reputation rep;
			if (!m_byIndex.TryGetValue(reputationIndex, out rep))
			{
				rep = Create(reputationIndex);
			}
			return rep;
		}
Пример #32
0
 public ReputationInfo(FactionReputationIndex faction)
 {
     Faction = faction;
 }
Пример #33
0
        /// <summary>
        /// Returns the cost of this item after the reputation discount has been applied.
        /// </summary>
        public uint GetDiscountedCost(FactionReputationIndex reputationIndex, uint cost)
        {
            var lvl = GetStandingLevel(reputationIndex);

            return((cost * (100 - Reputation.GetReputationDiscountPct(lvl))) / 100);
        }
Пример #34
0
		public ReputationInfo(FactionReputationIndex faction)
		{
			Faction = faction;
		}
Пример #35
0
 public static FactionId GetId(FactionReputationIndex reputationIndex)
 {
     return(FactionId.None);
 }
Пример #36
0
 public static Faction Get(FactionReputationIndex repuataionIndex)
 {
     return(NPCMgr.DefaultFaction);
 }
Пример #37
0
		public StandingLevel GetStandingLevel(FactionReputationIndex reputationIndex)
		{
			Reputation rep;
			if (m_byIndex.TryGetValue(reputationIndex, out rep))
			{
				return rep.StandingLevel;
			}
			return StandingLevel.Unknown;
		}
Пример #38
0
		public Reputation SetValue(FactionReputationIndex reputationIndex, int value)
		{
			Reputation rep = GetOrCreate(reputationIndex);
			if (rep != null)
			{
				SetValue(rep, value);
			}
			return rep;
		}
Пример #39
0
		public static FactionId GetId(FactionReputationIndex reputationIndex)
		{
			if (reputationIndex != FactionReputationIndex.End && (uint)reputationIndex < ByReputationIndex.Length)
			{
				var faction = ByReputationIndex[(uint)reputationIndex];
				if (faction != null)
				{
					return faction.Id;
				}
			}
			return 0;
		}
Пример #40
0
		public static Faction Get(FactionReputationIndex repuataionIndex)
		{
			if ((uint)repuataionIndex >= ByReputationIndex.Length ||

				repuataionIndex < 0)
			{
				return null;
			}
			return ByReputationIndex[(uint)repuataionIndex];
		}
Пример #41
0
		public Reputation ModValue(FactionReputationIndex reputationIndex, int value)
		{
			var rep = GetOrCreate(reputationIndex);
			if (rep != null)
			{
				ModValue(rep, value);
			}
			return rep;
		}
Пример #42
0
 public void SetInactive(FactionReputationIndex reputationIndex, bool inactive)
 {
     var faction = GetOrCreate(reputationIndex);
     if (faction != null)
     {
         faction.IsInactive = true;
     }
 }
Пример #43
0
		/// <summary>
		/// Only called if the player declared war
		/// </summary>
		public void DeclareWar(FactionReputationIndex reputationIndex, bool hostile, bool sendUpdate)
		{
			var rep = GetOrCreate(reputationIndex);

            // impossible to declare war on your own faction
            if (rep.IsForcedAtPeace)
                return;

            // this shouldnt be needed because of the previous check
            if (rep.Faction.Group == m_owner.Faction.Group)
            {
                // can't declare war on your own faction.
                return;
            }

			if (rep.DeclaredWar != hostile)
			{
				rep.DeclaredWar = hostile;
				if (sendUpdate && rep.DeclaredWar)
				{
					FactionHandler.SendSetAtWar(m_owner.Client, rep);
				}
			}
		}
Пример #44
0
		public Faction(FactionEntry entry, FactionTemplateEntry template)
		{
			Entry = entry;
			Template = template;
			Id = entry.Id;
			ReputationIndex = entry.FactionIndex;

            IsAlliance = template.FactionGroup.HasFlag(FactionGroupMask.Alliance);
		    IsHorde = template.FactionGroup.HasFlag(FactionGroupMask.Horde);
		}
Пример #45
0
		/// <summary>
		/// Returns the cost of this item after the reputation discount has been applied.
		/// </summary>
		public uint GetDiscountedCost(FactionReputationIndex reputationIndex, uint cost)
		{
			var lvl = GetStandingLevel(reputationIndex);
			return (cost * (100 - Reputation.GetReputationDiscountPct(lvl))) / 100;
		}
Пример #46
0
        /// <summary>
        /// Returns the cost of this item after the reputation discount has been applied.
        /// </summary>
        public uint GetDiscountedCost(FactionReputationIndex reputationIndex, uint cost)
        {
            StandingLevel standingLevel = this.GetStandingLevel(reputationIndex);

            return(cost * (100U - Reputation.GetReputationDiscountPct(standingLevel)) / 100U);
        }