/// <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); } } }
/// <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); }
/// <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); }
/// <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); } }
static ReputationInfo GetInfo(FactionReputationIndex index) { ReputationInfo rep; if (!InfosById.TryGetValue(index, out rep)) { InfosById.Add(index, rep = new ReputationInfo(index)); } return rep; }
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); }
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); }
/// <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; } }
public Reputation ModValue(FactionReputationIndex reputationIndex, int value) { Reputation rep = this.GetOrCreate(reputationIndex); if (rep != null) { this.ModValue(rep, value); } return(rep); }
public StandingLevel GetStandingLevel(FactionReputationIndex reputationIndex) { Reputation reputation; if (this.m_byIndex.TryGetValue(reputationIndex, out reputation)) { return(reputation.StandingLevel); } return(StandingLevel.Hated); }
public int GetValue(FactionReputationIndex reputationIndex) { Reputation reputation; if (this.m_byIndex.TryGetValue(reputationIndex, out reputation)) { return(reputation.Value); } return(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); }
/// <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); }
public void SetInactive(FactionReputationIndex reputationIndex, bool inactive) { Reputation reputation = this.GetOrCreate(reputationIndex); if (reputation == null) { return; } reputation.IsInactive = true; }
/// <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); }
public static Faction Get(FactionReputationIndex repuataionIndex) { if ((uint)repuataionIndex >= ByReputationIndex.Length || repuataionIndex < 0) { return(null); } return(ByReputationIndex[(uint)repuataionIndex]); }
public Reputation SetValue(FactionReputationIndex reputationIndex, int value) { Reputation rep = GetOrCreate(reputationIndex); if (rep != null) { SetValue(rep, value); } return(rep); }
public Reputation ModValue(FactionReputationIndex reputationIndex, int value) { var rep = GetOrCreate(reputationIndex); if (rep != null) { ModValue(rep, value); } return(rep); }
/// <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); }
static ReputationInfo GetInfo(FactionReputationIndex index) { ReputationInfo rep; if (!InfosById.TryGetValue(index, out rep)) { InfosById.Add(index, rep = new ReputationInfo(index)); } return(rep); }
public StandingLevel GetStandingLevel(FactionReputationIndex reputationIndex) { Reputation rep; if (m_byIndex.TryGetValue(reputationIndex, out rep)) { return(rep.StandingLevel); } return(StandingLevel.Unknown); }
public int GetValue(FactionReputationIndex reputationIndex) { Reputation rep; if (m_byIndex.TryGetValue(reputationIndex, out rep)) { return(rep.Value); } return(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); }
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."); } }
/// <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); }
/// <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); }
/// <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; }
public int GetValue(FactionReputationIndex reputationIndex) { Reputation rep; if (m_byIndex.TryGetValue(reputationIndex, out rep)) { return rep.Value; } return 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."); } }
/// <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; }
public ReputationInfo(FactionReputationIndex faction) { Faction = faction; }
/// <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); }
public static FactionId GetId(FactionReputationIndex reputationIndex) { return(FactionId.None); }
public static Faction Get(FactionReputationIndex repuataionIndex) { return(NPCMgr.DefaultFaction); }
public StandingLevel GetStandingLevel(FactionReputationIndex reputationIndex) { Reputation rep; if (m_byIndex.TryGetValue(reputationIndex, out rep)) { return rep.StandingLevel; } return StandingLevel.Unknown; }
public Reputation SetValue(FactionReputationIndex reputationIndex, int value) { Reputation rep = GetOrCreate(reputationIndex); if (rep != null) { SetValue(rep, value); } return rep; }
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; }
public static Faction Get(FactionReputationIndex repuataionIndex) { if ((uint)repuataionIndex >= ByReputationIndex.Length || repuataionIndex < 0) { return null; } return ByReputationIndex[(uint)repuataionIndex]; }
public Reputation ModValue(FactionReputationIndex reputationIndex, int value) { var rep = GetOrCreate(reputationIndex); if (rep != null) { ModValue(rep, value); } return rep; }
/// <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); } } }
/// <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; }
/// <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); }