/// <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);
			}
		}
        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);
        }