public MobFactionGump(Mobile from, XmlMobFactions a, string text) : base(0, 0) { if (a == null) { return; } m_attachment = a; m_text = text; // prepare the page AddPage(0); AddBackground(0, 0, 400, 330, 5054); AddAlphaRegion(0, 0, 400, 330); AddLabel(20, 2, 55, "Mob Faction Standings"); if (a != null) { AddLabel(200, 2, 30, String.Format("Available Credits: {0}", a.Credits)); } AddHtml(20, 20, 360, 260, text, true, true); // add the verbose factions checkbox AddLabel(50, 290, 55, "Verbose Factions"); AddButton(20, 290, (a.verboseMobFactions ? 0xD3 :0xD2), (a.verboseMobFactions ? 0xD2 :0xD3), 100, GumpButtonType.Reply, 0); }
public static int GetFactionLevel(Mobile m, GroupTypes grouptype) { if (m == null || grouptype == GroupTypes.End_Unused) { return(0); } XmlMobFactions x = XmlAttach.FindAttachment(m, typeof(XmlMobFactions), "Standard") as XmlMobFactions; if (x != null) { if (x.FactionList == null) { return(0); } foreach (GroupStatus g in x.FactionList) { if (g.GroupType == grouptype) { return(g.FactionLevel); } } } return(0); }
public override void OnAttach() { base.OnAttach(); // apply the mod if (AttachedTo is PlayerMobile) { // for players just add it immediately XmlMobFactions x = (XmlMobFactions)XmlAttach.FindAttachment(AttachedTo, typeof(XmlMobFactions)); if (x != null) { x.Credits += Value; ((Mobile)AttachedTo).SendMessage("Receive {0}", OnIdentify((Mobile)AttachedTo)); } // and then remove the attachment Delete(); } else if (AttachedTo is Item) { // dont allow item attachments Delete(); } }
public static void VerboseMobFactions_OnCommand(CommandEventArgs e) { // get the mob factions attachment ArrayList list = XmlAttach.FindAttachments(XmlAttach.MobileAttachments, e.Mobile, typeof(XmlMobFactions), "Standard"); if (list != null && list.Count > 0) { XmlMobFactions x = list[0] as XmlMobFactions; if (e.Arguments.Length > 0) { try { x.verboseMobFactions = bool.Parse(e.Arguments[0]); } catch { } } e.Mobile.SendMessage("VerboseMobFactions is set to {0}", x.verboseMobFactions); } else { e.Mobile.SendMessage("Standard XmlMobFactions attachment not found"); } }
public static int GetFactionLevel(Mobile m, GroupTypes grouptype) { if (m == null || grouptype == GroupTypes.End_Unused) { return(0); } ArrayList list = XmlAttach.FindAttachments(XmlAttach.MobileAttachments, m, typeof(XmlMobFactions), "Standard"); if (list != null && list.Count > 0) { XmlMobFactions x = list[0] as XmlMobFactions; if (x.FactionList == null) { return(0); } foreach (GroupStatus g in x.FactionList) { if (g.GroupType == grouptype) { return(g.FactionLevel); } } } return(0); }
public override bool OnMoveInto(Mobile m, Direction d, Point3D newLocation, Point3D oldLocation) { if (m.AccessLevel > AccessLevel.Player || Contains(oldLocation)) { return(true); } // do they have enough faction to enter? XmlMobFactions a = (XmlMobFactions)XmlAttach.FindAttachment(m, typeof(XmlMobFactions)); if (a == null) { return(false); } int fac = a.GetFactionLevel(m_FactionType); if (fac < FactionLevel) { // throttle message display if (DateTime.UtcNow - m_lastmsg > TimeSpan.FromSeconds(1)) { m.SendMessage("Your {0} faction is too low to enter here", FactionType); m_lastmsg = DateTime.UtcNow; } return(false); } return(true); }
public override bool CanEquip(Mobile from) { // check to see if the owners faction is sufficient ArrayList list = XmlAttach.FindAttachments(XmlAttach.MobileAttachments, from, typeof(XmlMobFactions), "Standard"); if (list != null && list.Count > 0) { int faclevel = 0; XmlMobFactions x = list[0] as XmlMobFactions; if (this.m_GroupType != XmlMobFactions.GroupTypes.End_Unused) { faclevel = x.GetFactionLevel(this.m_GroupType); } if (faclevel < this.MinValue && this.AttachedTo is Item && this.AttachedTo != null) { Item item = this.AttachedTo as Item; string name = item.Name; if (name == null) { name = item.ItemData.Name; } from.SendMessage("Cannot equip {2}. Need {0} {1} faction.", this.MinValue, this.FactionType, name); return(false); } } return(true); }
public static void CheckMobFactions_OnCommand(CommandEventArgs e) { // get the mob factions attachment XmlMobFactions x = XmlAttach.FindAttachment(e.Mobile, typeof(XmlMobFactions), "Standard") as XmlMobFactions; if (x != null) { e.Mobile.SendMessage("{0}", x.OnIdentify(e.Mobile)); } }
public static void CheckMobFactions_OnCommand(CommandEventArgs e) { // get the mob factions attachment ArrayList list = XmlAttach.FindAttachments(XmlAttach.MobileAttachments, e.Mobile, typeof(XmlMobFactions), "Standard"); if (list != null && list.Count > 0) { XmlMobFactions x = list[0] as XmlMobFactions; e.Mobile.SendMessage("{0}", x.OnIdentify(e.Mobile)); } }
public static int GetCredits(Mobile m) { int val = 0; XmlMobFactions x = XmlAttach.FindAttachment(m, typeof(XmlMobFactions), "Standard") as XmlMobFactions; if (x != null) { val = x.Credits; } return(val); }
public override void OnKilled(Mobile killed, Mobile killer) { base.OnKill(killed, killer); if (killer == null) { return; } // for players just add it immediately XmlMobFactions x = (XmlMobFactions)XmlAttach.FindAttachment(AttachedTo, typeof(XmlMobFactions)); if (x != null) { x.Credits += Value; killer.SendMessage("Receive {0}", OnIdentify(killer)); } }
public static bool HasCredits(Mobile m, int credits) { if (m == null || m.Deleted) { return(false); } XmlMobFactions x = XmlAttach.FindAttachment(m, typeof(XmlMobFactions), "Standard") as XmlMobFactions; if (x != null) { if (x.Credits >= credits) { return(true); } } return(false); }
public static void AddAllMobFactions_OnCommand(CommandEventArgs e) { int count = 0; foreach (Mobile m in World.Mobiles.Values) { if (m.Player) { // does this player already have a points attachment? XmlMobFactions x = XmlAttach.FindAttachment(m, typeof(XmlMobFactions), "Standard") as XmlMobFactions; if (x == null) { x = new XmlMobFactions(); XmlAttach.AttachTo(e.Mobile, m, x); count++; } } } e.Mobile.SendMessage("Added XmlMobFaction attachments to {0} players", count); }
public static bool HasCredits(Mobile m, int credits) { if (m == null || m.Deleted) { return(false); } ArrayList list = XmlAttach.FindAttachments(m, typeof(XmlMobFactions), "Standard"); if (list != null && list.Count > 0) { XmlMobFactions x = list[0] as XmlMobFactions; if (x.Credits >= credits) { return(true); } } return(false); }
public override void OnEnter(Mobile m) { if (m == null || m.AccessLevel > AccessLevel.Player) { return; } // do they have enough faction to enter? XmlMobFactions a = (XmlMobFactions)XmlAttach.FindAttachment(m, typeof(XmlMobFactions)); if (a == null) { // kick them out KickOut(m); return; } int fac = a.GetFactionLevel(m_FactionType); if (fac < FactionLevel) { KickOut(m); } }
public static void AddAllMobFactions_OnCommand( CommandEventArgs e ) { int count = 0; foreach(Mobile m in World.Mobiles.Values) { if(m.Player) { // does this player already have a points attachment? ArrayList list = XmlAttach.FindAttachments(m, typeof(XmlMobFactions), "Standard"); if(list == null || list.Count == 0) { XmlAttachment x = new XmlMobFactions(); XmlAttach.AttachTo(e.Mobile, m,x); count++; } } } e.Mobile.SendMessage("Added XmlMobFaction attachments to {0} players",count); }
public override string OnIdentify(Mobile from) { if (from == null) { if (Expiration > TimeSpan.Zero) { return(String.Format("Faction Mastery : increased damage vs {0}, {1}% hitchance, expires in {2} mins", m_Enemy, Chance, Expiration.TotalMinutes)); } else { return(String.Format("Faction Mastery : increased damage vs {0}, {1}% hitchance", m_Enemy, Chance)); } } string msg = null; string raisestr = "improve "; int percentincrease = 0; // compute the damage increase based upon the owner's faction level for the specified enemy type ArrayList list = XmlAttach.FindAttachments(XmlAttach.MobileAttachments, from, typeof(XmlMobFactions), "Standard"); if (list != null && list.Count > 0) { XmlMobFactions x = list[0] as XmlMobFactions; // get the percent damage increase based upon total faction level of opponent groups int totalfac = 0; // get the target enemy group XmlMobFactions.Group g = XmlMobFactions.FindGroup(m_EnemyType); if (g != null && g.Opponents != null) { // go through all of the opponents for (int i = 0; i < g.Opponents.Length; i++) { try{ totalfac += (int)(x.GetFactionLevel(g.Opponents[i].GroupType) * g.OpponentGain[i]); raisestr = String.Format("{0}{1}, ", raisestr, g.Opponents[i].GroupType); } catch {} } } percentincrease = ComputeIncrease(totalfac); } if (Expiration > TimeSpan.Zero) { msg = String.Format("Faction Mastery : +{3}% damage vs {0} ({4}% max), {1}% hitchance, expires in {2} mins", m_Enemy, Chance, Expiration.TotalMinutes, percentincrease, PercentCap); } else { msg = String.Format("Faction Mastery : +{2}% damage vs {0} ({3}% max), {1}% hitchance", m_Enemy, Chance, percentincrease, PercentCap); } msg = String.Format("{0} : {1}faction to enhance damage.", msg, raisestr); return(msg); }
// note that this method will be called when attached to either a mobile or a weapon // when attached to a weapon, only that weapon will do additional damage // when attached to a mobile, any weapon the mobile wields will do additional damage public override void OnWeaponHit(Mobile attacker, Mobile defender, BaseWeapon weapon, int damageGiven) { if (m_Chance <= 0 || Utility.Random(100) > m_Chance) { return; } if (defender != null && attacker != null && m_EnemyType != XmlMobFactions.GroupTypes.End_Unused) { // check to the owner's faction levels ArrayList list = XmlAttach.FindAttachments(XmlAttach.MobileAttachments, attacker, typeof(XmlMobFactions), "Standard"); if (list != null && list.Count > 0) { XmlMobFactions x = list[0] as XmlMobFactions; double increase = 0; // go through all of the factions the defender might belong to ArrayList glist = XmlMobFactions.FindGroups(defender); if (glist != null && glist.Count > 0) { foreach (XmlMobFactions.GroupTypes targetgroup in glist) { // found the group that matches the enemy type for this attachment if (targetgroup == m_EnemyType) { // get the percent damage increase based upon total faction level of opponent groups int totalfac = 0; // get the target enemy group XmlMobFactions.Group g = XmlMobFactions.FindGroup(m_EnemyType); if (g.Opponents != null) { // go through all of the opponents of this group for (int i = 0; i < g.Opponents.Length; i++) { // and sum the faction levels try{ totalfac += (int)(x.GetFactionLevel(g.Opponents[i].GroupType) * g.OpponentGain[i]); } catch {} } } // what is the damage increase based upon the total opponent faction level increase = (double)ComputeIncrease(totalfac) / 100.0; break; } } } if (increase > 0) { // apply the additional damage if any defender.Damage((int)(damageGiven * increase), attacker); } } } }
public MobFactionGump( Mobile from, XmlMobFactions a, string text) : base( 0,0) { if(a == null) return; m_attachment = a; m_text = text; // prepare the page AddPage( 0 ); AddBackground( 0, 0, 400, 330, 5054 ); AddAlphaRegion( 0, 0, 400, 330 ); AddLabel( 20, 2, 55, "Mob Faction Standings" ); if(a != null) { AddLabel( 200, 2, 30, String.Format("Available Credits: {0}", a.Credits) ); } AddHtml( 20,20, 360, 260, text, true , true ); // add the verbose factions checkbox AddLabel( 50, 290, 55, "Verbose Factions" ); AddButton( 20, 290, (a.verboseMobFactions ? 0xD3 :0xD2), (a.verboseMobFactions ? 0xD2 :0xD3), 100, GumpButtonType.Reply, 0); }
public static double GetScaledFaction(Mobile from, Mobile mob, double min, double max, double scale) { if (from == null || mob == null || !from.Player) { return(0); } double facvalue = 0; //XmlMobFactions x = (XmlMobFactions)XmlAttach.FindAttachment(XmlAttach.MobileAttachments, from, typeof(XmlMobFactions), "Standard"); XmlMobFactions x = XmlAttach.FindAttachment(from, typeof(XmlMobFactions), "Standard") as XmlMobFactions; if (x != null) { //if(x != null) //{ int count = 0; // find any static groups that this mob belongs to. Note, if it belongs to more than one group, calculate the average. List <GroupTypes> glist = FindGroups(mob); if (glist != null && glist.Count > 0) { foreach (GroupTypes g in glist) { if (g != GroupTypes.End_Unused) { facvalue += x.GetFactionLevel(g) * scale; count++; } } } // does this mob have dynamic faction assignments? List <XmlAttachment> dlist = XmlAttach.FindAttachments(mob, typeof(XmlDynamicFaction)); if (dlist != null && dlist.Count > 0) { //if(XmlAttach.FindAttachment(XmlAttach.MobileAttachments, mob, typeof(XmlDynamicFaction)) != null) //{ // do this for dynamic factions as well List <GroupTypes> dglist = DynamicFindGroups(mob); if (dglist != null && dglist.Count > 0) { foreach (GroupTypes g in dglist) { if (g != GroupTypes.End_Unused) { facvalue += x.GetFactionLevel(g) * scale; count++; } } } } // compute the average faction value if (count > 0) { facvalue /= count; } } if (facvalue > max) { facvalue = max; } if (facvalue < min) { facvalue = min; } return(facvalue); }