public override void OnKilled(Mobile killed, Mobile killer) { base.OnKill(killed, killer); if (killer == null) { return; } XmlMobFactions.GroupTypes g = XmlMobFactions.GroupTypes.End_Unused; try{ g = (XmlMobFactions.GroupTypes)Enum.Parse(typeof(XmlMobFactions.GroupTypes), FactionType, true); } catch {} if (g != XmlMobFactions.GroupTypes.End_Unused) { // give the killer the faction // get XmlMobFaction type attachments and add the faction ArrayList list = XmlAttach.FindAttachments(XmlAttach.MobileAttachments, killer, typeof(XmlMobFactions)); if (list != null && list.Count > 0) { foreach (XmlMobFactions x in list) { x.SetFactionLevel(g, x.GetFactionLevel(g) + Value); } } killer.SendMessage("Receive {0}", OnIdentify(killer)); } }
public XmlMobFactionsRewards(string faction, int minfaction, Type reward, string name, int cost, int id, object[] args) { RewardType = reward; Cost = cost; ItemID = id; Name = name; RewardArgs = args; RequiredFaction = XmlMobFactions.GroupTypes.End_Unused; if(faction != null) try{ RequiredFaction = (XmlMobFactions.GroupTypes)Enum.Parse(typeof(XmlMobFactions.GroupTypes), faction); } catch{}; MinFaction = minfaction; }
public XmlMobFactionsRewards(string faction, int minfaction, Type reward, string name, int cost, int id, object[] args) { RewardType = reward; Cost = cost; ItemID = id; Name = name; RewardArgs = args; RequiredFaction = XmlMobFactions.GroupTypes.End_Unused; if (faction != null) { try{ RequiredFaction = (XmlMobFactions.GroupTypes)Enum.Parse(typeof(XmlMobFactions.GroupTypes), faction); } catch {} } ; MinFaction = minfaction; }
public override void OnAttach() { base.OnAttach(); // apply the mod if (this.AttachedTo is PlayerMobile) { // for players just add it immediately // lookup the group type XmlMobFactions.GroupTypes g = XmlMobFactions.GroupTypes.End_Unused; try { g = (XmlMobFactions.GroupTypes)Enum.Parse(typeof(XmlMobFactions.GroupTypes), this.FactionType, true); } catch { } if (g != XmlMobFactions.GroupTypes.End_Unused) { // get XmlMobFaction type attachments and add the faction List <XmlAttachment> list = XmlAttach.FindAttachments(this.AttachedTo, typeof(XmlMobFactions)); if (list != null && list.Count > 0) { foreach (XmlMobFactions x in list) { x.SetFactionLevel(g, x.GetFactionLevel(g) + this.Value); } } ((Mobile)this.AttachedTo).SendMessage("Receive {0}", this.OnIdentify((Mobile)this.AttachedTo)); } else { ((Mobile)this.AttachedTo).SendMessage("{0}: no such faction", this.FactionType); } // and then remove the attachment this.Delete(); } else if (this.AttachedTo is Item) { // dont allow item attachments this.Delete(); } }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); this.m_MobFactionArea = new Rectangle3D[0]; switch (version) { case 1: { this.m_EjectLocation = reader.ReadPoint3D(); string ejectmap = reader.ReadString(); try { this.m_EjectMap = Map.Parse(ejectmap); } catch { } string factiontype = reader.ReadString(); try { this.m_FactionType = (XmlMobFactions.GroupTypes)Enum.Parse(typeof(XmlMobFactions.GroupTypes), factiontype); } catch { } this.m_FactionLevel = reader.ReadInt(); goto case 0; } case 0: { this.m_Music = (MusicName)reader.ReadInt(); this.m_MobFactionPriority = reader.ReadInt(); if (version < 1) { // old region area reader.ReadRect2D(); } this.m_MobFactionRegionName = reader.ReadString(); string mapname = reader.ReadString(); try { this.m_MobFactionMap = Map.Parse(mapname); } catch { } this.m_CopiedRegion = reader.ReadString(); // do the coord list int count = reader.ReadInt(); if (count > 0) { // the old version used 2D rectangles for the region area. The new version uses 3D if (version < 1) { Rectangle2D[] area = new Rectangle2D[count]; for (int i = 0; i < count; i++) { area[i] = reader.ReadRect2D(); } this.m_MobFactionArea = Region.ConvertTo3D(area); } else { this.m_MobFactionArea = new Rectangle3D[count]; for (int i = 0; i < count; i++) { this.m_MobFactionArea[i] = new Rectangle3D(reader.ReadPoint3D(), reader.ReadPoint3D()); } } } break; } } // refresh the region Timer.DelayCall(TimeSpan.Zero, new TimerCallback(RefreshRegions)); }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); m_MobFactionArea = new Rectangle3D[0]; switch (version) { case 1: { m_EjectLocation = reader.ReadPoint3D(); string ejectmap = reader.ReadString(); try { m_EjectMap = Map.Parse(ejectmap); } catch { } string factiontype = reader.ReadString(); try { m_FactionType = (XmlMobFactions.GroupTypes)Enum.Parse(typeof(XmlMobFactions.GroupTypes), factiontype); } catch {} m_FactionLevel = reader.ReadInt(); goto case 0; } case 0: { m_Music = (MusicName)reader.ReadInt(); m_MobFactionPriority = reader.ReadInt(); if (version < 1) { // old region area reader.ReadRect2D(); } m_MobFactionRegionName = reader.ReadString(); string mapname = reader.ReadString(); try { m_MobFactionMap = Map.Parse(mapname); } catch { } m_CopiedRegion = reader.ReadString(); // do the coord list int count = reader.ReadInt(); if (count > 0) { // the old version used 2D rectangles for the region area. The new version uses 3D if (version < 1) { Rectangle2D[] area = new Rectangle2D[count]; for (int i = 0; i < count; i++) { area[i] = reader.ReadRect2D(); } m_MobFactionArea = Region.ConvertTo3D(area); } else { m_MobFactionArea = new Rectangle3D[count]; for (int i = 0; i < count; i++) { m_MobFactionArea[i] = new Rectangle3D(reader.ReadPoint3D(), reader.ReadPoint3D()); } } } break; } } // refresh the region Timer.DelayCall(TimeSpan.Zero, new TimerCallback(RefreshRegions)); }