protected override void OnTarget(Mobile from, object targeted) { if (!(targeted is Container)) { from.SendMessage("That is not a container."); return; } Container craftbag = (Container)targeted; if (!craftbag.IsChildOf(from.Backpack)) { from.SendMessage("That is not inside your backpack."); return; } XmlAttachment att = XmlAttach.FindAttachment(from, typeof(CraftBagAtt)); if (att == null) { att = new CraftBagAtt(craftbag); XmlAttach.AttachTo(from, att); } else { CraftBagAtt lb = att as CraftBagAtt; lb.CraftBag = craftbag; } from.SendMessage("You will now craft into that container."); }
private bool TestAge(object o) { if (Searchage <= 0) { return(true); } if (o is XmlAttachment) { XmlAttachment a = (XmlAttachment)o; if (Searchagedirection) { // true means allow only mobs greater than the age if ((DateTime.UtcNow - a.CreationTime) > TimeSpan.FromHours(Searchage)) { return(true); } } else { // false means allow only mobs less than the age if ((DateTime.UtcNow - a.CreationTime) < TimeSpan.FromHours(Searchage)) { return(true); } } } return(false); }
protected virtual void OnGiveReward(ConquestState s, XmlAttachment reward) { if (s == null || s.User == null || reward == null || reward.Deleted) { return; } if (!XmlAttach.AttachTo(s.User, reward)) { reward.Delete(); } }
private void DoShowProps(int index) { if (m_From == null || m_From.Deleted) { return; } if (index < m_SearchList.Count) { XmlAttachment x = m_SearchList[index]; if (x == null || x.Deleted) { return; } m_From.SendGump(new PropertiesGump(m_From, x)); } }
public override void OnResponse(NetState state, RelayInfo info) { if (info == null || state == null || state.Mobile == null) { return; } int radiostate = -1; if (info.Switches.Length > 0) { radiostate = info.Switches[0]; } switch (info.ButtonID) { default: { if (radiostate == 1 && SearchList != null && SelectedList != null) { // accept for (int i = 0; i < SearchList.Count; i++) { int index = i - DisplayFrom; if ((index >= 0 && index < SelectedList.Length && SelectedList[index] == true) || selectAll) { XmlAttachment o = SearchList[i]; // some objects may not delete gracefully (null map items are particularly error prone) so trap them try { o.Delete(); } catch { } } } // refresh the gump state.Mobile.CloseGump(typeof(XmlGetAttGump)); state.Mobile.SendGump(new XmlGetAttGump(state.Mobile, m_target, 0, 0)); } break; } } }
private void DoShowProps(int index) { if (this.m_From == null || this.m_From.Deleted) { return; } if (index < this.m_SearchList.Count) { object o = this.m_SearchList[index]; if (o is XmlAttachment) { XmlAttachment x = (XmlAttachment)o; if (x == null || x.Deleted) { return; } this.m_From.SendGump(new PropertiesGump(this.m_From, o)); } } }
public override void OnResponse(NetState state, RelayInfo info) { if (info == null || state == null || state.Mobile == null) { return; } int radiostate = -1; if (info.Switches.Length > 0) { radiostate = info.Switches[0]; } // read the text entries for the search criteria Searchage = 0; TextRelay tr = info.GetTextEntry(400); // displayfrom info try{ DisplayFrom = int.Parse(tr.Text); } catch {} switch (info.ButtonID) { case 0: // Close { return; } case 156: // Delete selected items { Refresh(state); int allcount = 0; if (m_SearchList != null) { allcount = m_SearchList.Count; } state.Mobile.SendGump(new XmlConfirmDeleteGump(state.Mobile, m_TargetObject, m_SearchList, m_SelectionList, DisplayFrom, SelectAll, allcount)); return; } case 201: // forward block { // clear the selections if (m_SelectionList != null && !SelectAll) { Array.Clear(m_SelectionList, 0, m_SelectionList.Length); } if (m_SearchList != null && DisplayFrom + MaxEntries < m_SearchList.Count) { DisplayFrom += MaxEntries; // clear any selection Selected = -1; } break; } case 202: // backward block { // clear the selections if (m_SelectionList != null && !SelectAll) { Array.Clear(m_SelectionList, 0, m_SelectionList.Length); } DisplayFrom -= MaxEntries; if (DisplayFrom < 0) { DisplayFrom = 0; } // clear any selection Selected = -1; break; } case 700: // Sort { // clear any selection Selected = -1; // clear the selections if (m_SelectionList != null && !SelectAll) { Array.Clear(m_SelectionList, 0, m_SelectionList.Length); } Sorttype = false; Sortname = false; // read the toggle switches that determine the sort if (radiostate == 0) // sort by type { Sorttype = true; } if (radiostate == 1) // sort by name { Sortname = true; } SortFindList(); break; } case 701: // descending sort { Descendingsort = !Descendingsort; break; } case 9998: // refresh the gump { // clear any selection Selected = -1; break; } default: { if (info.ButtonID >= 3000 && info.ButtonID < 3000 + MaxEntries) { Selected = info.ButtonID - 3000; // Show the props window Refresh(state); DoShowProps(info.ButtonID - 3000 + DisplayFrom); return; } if (info.ButtonID == 3998) { SelectAll = !SelectAll; // dont allow individual selection with the selectall button selected if (m_SelectionList != null) { for (int i = 0; i < MaxEntries; i++) { if (i < m_SelectionList.Length) { // only toggle the selection list entries for things that actually have entries m_SelectionList[i] = SelectAll; } else { break; } } } } if (info.ButtonID == 3999) { // dont allow individual selection with the selectall button selected if (m_SelectionList != null && m_SearchList != null && !SelectAll) { for (int i = 0; i < MaxEntries; i++) { if (i < m_SelectionList.Length) { // only toggle the selection list entries for things that actually have entries if ((m_SearchList.Count - DisplayFrom > i)) { m_SelectionList[i] = !m_SelectionList[i]; } } else { break; } } } } if (info.ButtonID >= 4000 && info.ButtonID < 4000 + MaxEntries) { int i = info.ButtonID - 4000; // dont allow individual selection with the selectall button selected if (m_SelectionList != null && i >= 0 && i < m_SelectionList.Length && !SelectAll) { // only toggle the selection list entries for things that actually have entries if (m_SearchList != null && (m_SearchList.Count - DisplayFrom > i)) { m_SelectionList[i] = !m_SelectionList[i]; } } } if (info.ButtonID >= 5000 && info.ButtonID < 5000 + MaxEntries) { int i = info.ButtonID - 5000; // dont allow individual selection with the selectall button selected if (m_SelectionList != null && i >= 0 && i < m_SelectionList.Length && !SelectAll) { // only toggle the selection list entries for things that actually have entries if (m_SearchList != null && (m_SearchList.Count - DisplayFrom > i)) { XmlAttachment a = m_SearchList[i + DisplayFrom]; if (a != null) { state.Mobile.SendMessage(a.OnIdentify(state.Mobile)); } } } } break; } } // Create a new gump //m_Spawner.OnDoubleClick( state.Mobile); Refresh(state); }
public XmlGetAttGump(Mobile from, object targeted, bool firststart, bool descend, bool dosearchtype, bool dosearchname, bool dosearchage, string searchtype, string searchname, bool searchagedirection, double searchage, List <XmlAttachment> searchlist, int selected, int displayfrom, bool sorttype, bool sortname, bool selectall, bool [] selectionlist, int X, int Y) : base(X, Y) { m_TargetObject = targeted; m_From = from; m_SelectionList = selectionlist; if (m_SelectionList == null) { m_SelectionList = new bool[MaxEntries]; } SelectAll = selectall; Sorttype = sorttype; Sortname = sortname; DisplayFrom = displayfrom; Selected = selected; Descendingsort = descend; Dosearchtype = dosearchtype; Dosearchname = dosearchname; Dosearchage = dosearchage; Searchagedirection = searchagedirection; Searchage = searchage; Searchtype = searchtype; Searchname = searchname; m_SearchList = searchlist; if (firststart) { string status_str; m_SearchList = Search(m_TargetObject, out status_str); } // prepare the page AddPage(0); AddBackground(0, 0, 640, 474, 5054); AddAlphaRegion(0, 0, 640, 474); string tnamestr = null; if (targeted is Item) { tnamestr = ((Item)targeted).Name; } else if (targeted is Mobile) { tnamestr = ((Mobile)targeted).Name; } AddLabel(2, 0, 0x33, String.Format("Attachments on {0} : {1}", targeted.GetType().Name, tnamestr)); // add the Sort button AddButton(5, 450, 0xFAB, 0xFAD, 700, GumpButtonType.Reply, 0); AddLabel(38, 450, 0x384, "Sort"); // add the sort direction button if (Descendingsort) { AddButton(75, 453, 0x15E2, 0x15E6, 701, GumpButtonType.Reply, 0); AddLabel(100, 450, 0x384, "descend"); } else { AddButton(75, 453, 0x15E0, 0x15E4, 701, GumpButtonType.Reply, 0); AddLabel(100, 450, 0x384, "ascend"); } // add the Sort on type toggle AddRadio(155, 450, 0xD2, 0xD3, Sorttype, 0); AddLabel(155, 425, 0x384, "type"); // add the Sort on name toggle AddRadio(200, 450, 0xD2, 0xD3, Sortname, 1); AddLabel(200, 425, 0x384, "name"); AddLabel(42, 13, 0x384, "Name"); AddLabel(145, 13, 0x384, "Type"); AddLabel(285, 13, 0x384, "Created"); AddLabel(425, 13, 0x384, "Expires In"); AddLabel(505, 13, 0x384, "Attached By"); // add the Delete button AddButton(250, 450, 0xFB1, 0xFB3, 156, GumpButtonType.Reply, 0); AddLabel(283, 450, 0x384, "Delete"); // add the page buttons for (int i = 0; i < (int)(MaxEntries / MaxEntriesPerPage); i++) { //AddButton( 38+i*30, 365, 2206, 2206, 0, GumpButtonType.Page, 1+i ); AddButton(418 + i * 25, 450, 0x8B1 + i, 0x8B1 + i, 0, GumpButtonType.Page, 1 + i); } // add the advance pageblock buttons AddButton(415 + 25 * (int)(MaxEntries / MaxEntriesPerPage), 450, 0x15E1, 0x15E5, 201, GumpButtonType.Reply, 0); // block forward AddButton(395, 450, 0x15E3, 0x15E7, 202, GumpButtonType.Reply, 0); // block backward // add the displayfrom entry AddLabel(460, 450, 0x384, "Display"); AddImageTiled(500, 450, 60, 21, 0xBBC); AddTextEntry(501, 450, 60, 21, 0, 400, DisplayFrom.ToString()); AddButton(560, 450, 0xFAB, 0xFAD, 9998, GumpButtonType.Reply, 0); // display the item list if (m_SearchList != null) { AddLabel(320, 425, 68, String.Format("Found {0} attachments", m_SearchList.Count)); AddLabel(500, 425, 68, String.Format("Displaying {0}-{1}", DisplayFrom, (DisplayFrom + MaxEntries < m_SearchList.Count ? DisplayFrom + MaxEntries : m_SearchList.Count))); } // display the select-all-displayed toggle AddButton(620, 5, 0xD2, 0xD3, 3999, GumpButtonType.Reply, 0); // display the select-all toggle AddButton(600, 5, (SelectAll? 0xD3:0xD2), (SelectAll? 0xD2:0xD3), 3998, GumpButtonType.Reply, 0); for (int i = 0; i < MaxEntries; i++) { int index = i + DisplayFrom; if (m_SearchList == null || index >= m_SearchList.Count) { break; } int page = (int)(i / MaxEntriesPerPage); if (i % MaxEntriesPerPage == 0) { AddPage(page + 1); } // background for search results area //AddImageTiled( 235, 22 * (i%MaxEntriesPerPage) + 30, 386, 23, 0x52 ); //AddImageTiled( 236, 22 * (i%MaxEntriesPerPage) + 31, 384, 21, 0xBBC ); // add the Props button for each entry AddButton(5, 22 * (i % MaxEntriesPerPage) + 30, 0xFAB, 0xFAD, 3000 + i, GumpButtonType.Reply, 0); string namestr = null; string typestr = null; string expirestr = null; //string description = null; string attachedby = null; string created = null; int texthue = 0; object o = (object)m_SearchList[index]; if (o is XmlAttachment) { XmlAttachment a = m_SearchList[index]; namestr = a.Name; typestr = a.GetType().Name; expirestr = a.Expiration.ToString(); //description = a.OnIdentify(m_From); created = a.CreationTime.ToString(); attachedby = a.AttachedBy; } bool sel = false; if (m_SelectionList != null && i < m_SelectionList.Length) { sel = m_SelectionList[i]; } if (sel) { texthue = 33; } if (i == Selected) { texthue = 68; } // display the name AddImageTiled(36, 22 * (i % MaxEntriesPerPage) + 31, 102, 21, 0xBBC); AddLabelCropped(38, 22 * (i % MaxEntriesPerPage) + 31, 100, 21, texthue, namestr); // display the type AddImageTiled(140, 22 * (i % MaxEntriesPerPage) + 31, 133, 21, 0xBBC); AddLabelCropped(140, 22 * (i % MaxEntriesPerPage) + 31, 133, 21, texthue, typestr); // display the creation time AddImageTiled(275, 22 * (i % MaxEntriesPerPage) + 31, 138, 21, 0xBBC); AddLabelCropped(275, 22 * (i % MaxEntriesPerPage) + 31, 138, 21, texthue, created); // display the expiration AddImageTiled(415, 22 * (i % MaxEntriesPerPage) + 31, 78, 21, 0xBBC); AddLabelCropped(415, 22 * (i % MaxEntriesPerPage) + 31, 78, 21, texthue, expirestr); // display the attachedby AddImageTiled(495, 22 * (i % MaxEntriesPerPage) + 31, 125, 21, 0xBBC); AddLabelCropped(495, 22 * (i % MaxEntriesPerPage) + 31, 105, 21, texthue, attachedby); // display the descriptio button AddButton(600, 22 * (i % MaxEntriesPerPage) + 32, 0x5689, 0x568A, 5000 + i, GumpButtonType.Reply, 0); // display the selection button AddButton(620, 22 * (i % MaxEntriesPerPage) + 32, (sel? 0xD3:0xD2), (sel? 0xD2:0xD3), 4000 + i, GumpButtonType.Reply, 0); } }
public override void OnResponse(NetState state, RelayInfo info) { if (info == null || state == null || state.Mobile == null || this.Rewards == null) { return; } Mobile from = state.Mobile; switch (info.ButtonID) { case 12: // page up int nitems = 0; if (this.Rewards != null) { nitems = this.Rewards.Count; } int page = this.viewpage + 1; if (page > (int)(nitems / this.maxItemsPerPage)) { page = (int)(nitems / this.maxItemsPerPage); } state.Mobile.SendGump(new QuestRewardGump(state.Mobile, page)); break; case 13: // page down page = this.viewpage - 1; if (page < 0) { page = 0; } state.Mobile.SendGump(new QuestRewardGump(state.Mobile, page)); break; default: { if (info.ButtonID >= 1000) { int selection = info.ButtonID - 1000; if (selection < this.Rewards.Count) { XmlQuestPointsRewards r = this.Rewards[selection] as XmlQuestPointsRewards; // check the price if (XmlQuestPoints.HasCredits(from, r.Cost)) { // create an instance of the reward type object o = null; try { o = Activator.CreateInstance(r.RewardType, r.RewardArgs); } catch { } bool received = true; if (o is Item) { // and give them the item from.AddToBackpack((Item)o); } else if (o is Mobile) { // if it is controllable then set the buyer as master. Note this does not check for control slot limits. if (o is BaseCreature) { BaseCreature b = o as BaseCreature; b.Controlled = true; b.ControlMaster = from; } ((Mobile)o).MoveToWorld(from.Location, from.Map); } else if (o is XmlAttachment) { XmlAttachment a = o as XmlAttachment; XmlAttach.AttachTo(from, a); } else { from.SendMessage(33, "unable to create {0}.", r.RewardType.Name); received = false; } // complete the transaction if (received) { // charge them XmlQuestPoints.TakeCredits(from, r.Cost); from.SendMessage("You have purchased {0} for {1} credits.", r.Name, r.Cost); } } else { from.SendMessage("Insufficient Credits for {0}.", r.Name); } from.SendGump(new QuestRewardGump(from, this.viewpage)); } } break; } } }
public override void OnResponse(NetState state, RelayInfo info) { if (info == null || state == null || state.Mobile == null || Rewards == null) { return; } Mobile from = state.Mobile; switch (info.ButtonID) { case 12: // page up int nitems = 0; if (Rewards != null) { nitems = Rewards.Count; } int page = viewpage + 1; if (page > nitems / maxItemsPerPage) { page = nitems / maxItemsPerPage; } state.Mobile.SendGump(new ReferralRewardsGump(state.Mobile, page)); break; case 13: // page down page = viewpage - 1; if (page < 0) { page = 0; } state.Mobile.SendGump(new ReferralRewardsGump(state.Mobile, page)); break; default: { if (info.ButtonID >= 1000 && info.ButtonID < 2000) { int selection = info.ButtonID - 1000; if (selection < Rewards.Count) { ReferralRewardItems r = Rewards[selection] as ReferralRewardItems; XmlReferralRewards re = (XmlReferralRewards)XmlAttach.FindAttachment(from, typeof(XmlReferralRewards)); if (((re.LastRewardChosen + TimeSpan.FromDays(1.0)) > DateTime.Now) && from.AccessLevel < AccessLevel.GameMaster) { from.SendMessage(39, "You can only purchase one referral reward per day."); return; } if (re != null && re.PointsAvailable >= r.Cost) { re.PointsAvailable = re.PointsAvailable - r.Cost; re.PointsSpent = re.PointsSpent + r.Cost; re.RewardsChosen++; re.LastRewardChosen = DateTime.Now; // create an instance of the reward type object o = null; try { o = Activator.CreateInstance(r.RewardType, r.RewardArgs); } catch { } bool received = true; if (o is Item) { if (o is BasePotion) { BasePotion bp = o as BasePotion; bp.Amount = 500; } // and give them the item PlayerMobile pm = from as PlayerMobile; BankBox box = null; if (pm != null) { box = pm.FindBankNoCreate(); } if (box != null) { box.AddItem((Item)o); from.SendMessage("{0} has been placed in your bank box.", ((Item)o).Name); } else if (pm.Backpack != null && !pm.Backpack.Deleted) { pm.Backpack.AddItem((Item)o); from.SendMessage("{0} has been placed in your backpack.", ((Item)o).Name); } else { received = false; from.SendMessage("An error has occured, please page staff about this issue immediately!"); } } else if (o is Mobile) { // if it is controllable then set the buyer as master. Note this does not check for control slot limits. if (o is BaseCreature) { BaseCreature b = o as BaseCreature; b.Controlled = true; b.ControlMaster = from; } ((Mobile)o).MoveToWorld(from.Location, from.Map); } else if (o is XmlAttachment) { XmlAttachment a = o as XmlAttachment; XmlAttach.AttachTo(from, a); } else { from.SendMessage(33, "Unable to create {0}. Please page a staff member.", r.RewardType.Name); received = false; } from.SendMessage("You have purchased {0} for {1} Referral Points.", r.Name, r.Cost); LogPurchase(r, from, state, received); // creates a log of the purchased items to Donations.log in the main server folder. This is for Owners to verify donation claims, tracking what sells best, etc. } else { from.SendMessage("Insufficient Referral Points for {0}.", r.Name); } from.SendGump(new ReferralRewardsGump(from, viewpage)); } } else if (info.ButtonID >= 2000) { int selection = info.ButtonID - 2000; if (selection < Rewards.Count) { ReferralRewardItems r = Rewards[selection] as ReferralRewardItems; from.SendGump(new ReferralRewardsGump(from, viewpage)); if (r != null) { from.CloseGump(typeof(ReferralRewardDescriptionGump)); from.SendGump(new ReferralRewardDescriptionGump(r)); } } } break; } } }
private Item TryStealItem(Item toSteal, ref bool caught) { try { Item stolen = null; object root = toSteal.RootParent; if (root is TeiravonMobile) { TeiravonMobile m_Player = (TeiravonMobile)m_Thief; if (!m_Player.HasFeat(TeiravonMobile.Feats.NimbleFingers)) { m_Thief.SendMessage("You must have the Nimble Fingers Feat to steal from players."); return(null); } } if (!IsEmptyHanded(m_Thief)) { m_Thief.SendLocalizedMessage(1005584); // Both hands must be free to steal. } /* * else if ( root is Mobile && ((Mobile)root).Player && IsInnocentTo( m_Thief, (Mobile)root ) && !IsInGuild( m_Thief ) ) * { * m_Thief.SendLocalizedMessage( 1005596 ); // You must be in the thieves guild to steal from other players. * } * else if ( SuspendOnMurder && root is Mobile && ((Mobile)root).Player && IsInGuild( m_Thief ) && m_Thief.Kills > 0 ) * { * m_Thief.SendLocalizedMessage( 502706 ); // You are currently suspended from the thieves guild. * } */ else if (root is BaseVendor && ((BaseVendor)root).IsInvulnerable) { m_Thief.SendLocalizedMessage(1005598); // You can't steal from shopkeepers. } else if (root is PlayerVendor) { m_Thief.SendLocalizedMessage(502709); // You can't steal from vendors. } else if (!m_Thief.CanSee(toSteal)) { m_Thief.SendLocalizedMessage(500237); // Target can not be seen. } else if (m_Thief.Backpack == null || !m_Thief.Backpack.CheckHold(m_Thief, toSteal, false, true)) { m_Thief.SendLocalizedMessage(1048147); // Your backpack can't hold anything else. } #region Sigils else if (toSteal is Sigil) { PlayerState pl = PlayerState.Find(m_Thief); Faction faction = (pl == null ? null : pl.Faction); Sigil sig = (Sigil)toSteal; if (!m_Thief.InRange(toSteal.GetWorldLocation(), 1)) { m_Thief.SendLocalizedMessage(502703); // You must be standing next to an item to steal it. } else if (root != null) // not on the ground { m_Thief.SendLocalizedMessage(502710); // You can't steal that! } else if (faction != null) { if (!m_Thief.CanBeginAction(typeof(IncognitoSpell))) { m_Thief.SendLocalizedMessage(1010581); // You cannot steal the sigil when you are incognito } else if (DisguiseGump.IsDisguised(m_Thief)) { m_Thief.SendLocalizedMessage(1010583); // You cannot steal the sigil while disguised } else if (!m_Thief.CanBeginAction(typeof(PolymorphSpell))) { m_Thief.SendLocalizedMessage(1010582); // You cannot steal the sigil while polymorphed } else if (TransformationSpell.UnderTransformation(m_Thief)) { m_Thief.SendLocalizedMessage(1061622); // You cannot steal the sigil while in that form. } else if (pl.IsLeaving) { m_Thief.SendLocalizedMessage(1005589); // You are currently quitting a faction and cannot steal the town sigil } else if (sig.IsBeingCorrupted && sig.LastMonolith.Faction == faction) { m_Thief.SendLocalizedMessage(1005590); // You cannot steal your own sigil } else if (sig.IsPurifying) { m_Thief.SendLocalizedMessage(1005592); // You cannot steal this sigil until it has been purified } else if (m_Thief.CheckTargetSkill(SkillName.Stealing, toSteal, 80.0, 80.0)) { if (Sigil.ExistsOn(m_Thief)) { m_Thief.SendLocalizedMessage(1010258); // The sigil has gone back to its home location because you already have a sigil. } else if (m_Thief.Backpack == null || !m_Thief.Backpack.CheckHold(m_Thief, sig, false, true)) { m_Thief.SendLocalizedMessage(1010259); // The sigil has gone home because your backpack is full } else { if (sig.IsBeingCorrupted) { sig.GraceStart = DateTime.Now; // begin grace period } m_Thief.SendLocalizedMessage(1010586); // YOU STOLE THE SIGIL!!! (woah, call down now) if (sig.LastMonolith != null) { sig.LastMonolith.Sigil = null; } sig.LastStolen = DateTime.Now; return(sig); } } else { m_Thief.SendLocalizedMessage(1005594); // You do not have enough skill to steal the sigil } } else { m_Thief.SendLocalizedMessage(1005588); // You must join a faction to do that } } #endregion else if (toSteal.Parent == null || toSteal.LootType == LootType.Newbied || toSteal.CheckBlessed(root)) { m_Thief.SendLocalizedMessage(502710); // You can't steal that! } else if (Core.AOS && toSteal is Container) { m_Thief.SendLocalizedMessage(502710); // You can't steal that! } else if (!m_Thief.InRange(toSteal.GetWorldLocation(), 1)) { m_Thief.SendLocalizedMessage(502703); // You must be standing next to an item to steal it. } else if (toSteal.Parent is Mobile) { m_Thief.SendLocalizedMessage(1005585); // You cannot steal items which are equiped. } else if (root == m_Thief) { m_Thief.SendLocalizedMessage(502704); // You catch yourself red-handed. } else if (root is Mobile && ((Mobile)root).AccessLevel > AccessLevel.Player) { m_Thief.SendLocalizedMessage(502710); // You can't steal that! } else if (root is Mobile && !m_Thief.CanBeHarmful((Mobile)root)) { } else if (root is Corpse) { m_Thief.SendLocalizedMessage(502710); // You can't steal that! } else { if (!toSteal.Movable) { XmlAttachment flag = XmlAttach.FindAttachment(toSteal, typeof(XmlData), "stealable"); if (flag == null) { m_Thief.SendLocalizedMessage(502710); // You can't steal that! return(null); } } double w = toSteal.Weight + toSteal.TotalWeight; if (w > 10) { m_Thief.SendMessage("That is too heavy to steal."); } else { if (toSteal.Stackable && toSteal.Amount > 1) { int maxAmount = (int)((m_Thief.Skills[SkillName.Stealing].Value / 10.0) / toSteal.Weight); if (maxAmount < 1) { maxAmount = 1; } else if (maxAmount > toSteal.Amount) { maxAmount = toSteal.Amount; } int amount = Utility.RandomMinMax(1, maxAmount); if (amount >= toSteal.Amount) { int pileWeight = (int)Math.Ceiling(toSteal.Weight * toSteal.Amount); pileWeight *= 10; if (m_Thief.CheckTargetSkill(SkillName.Stealing, toSteal, pileWeight - 22.5, pileWeight + 27.5)) { stolen = toSteal; } } else { int pileWeight = (int)Math.Ceiling(toSteal.Weight * amount); pileWeight *= 10; if (m_Thief.CheckTargetSkill(SkillName.Stealing, toSteal, pileWeight - 22.5, pileWeight + 27.5)) { stolen = toSteal.Dupe(amount); toSteal.Amount -= amount; } } } else { int iw = (int)Math.Ceiling(w); iw *= 10; if (m_Thief.CheckTargetSkill(SkillName.Stealing, toSteal, iw - 22.5, iw + 27.5)) { stolen = toSteal; } } if (stolen != null) { m_Thief.SendLocalizedMessage(502724); // You succesfully steal the item. stolen.Movable = true; } else { m_Thief.SendLocalizedMessage(502723); // You fail to steal the item. } caught = (m_Thief.Skills[SkillName.Stealing].Value < Utility.Random(150)); } } return(stolen); } catch { return(null); } }
protected virtual bool OnBeforeGiveReward(ConquestState s, XmlAttachment reward) { return(Enabled && !Deleted && s != null && s.User != null && reward != null && !reward.Deleted); }
public override void DoTransmute(Mobile from, Recipe r) { if (r == null || from == null) { return; } Recipes rid = (Recipes)r.RecipeID; switch (rid) { case Recipes.PowerScrollSkillChange: { // get the target value from one of the powerscrolls Item[] slist = this.FindItemsByType(typeof(PowerScroll), true); double value = 0; // make sure they are all of the same value foreach (Item s in slist) { if (value == 0) { value = ((PowerScroll)s).Value; } else { if (value != ((PowerScroll)s).Value) { from.SendMessage("All powerscrolls must be of the same level"); return; } } } PowerScroll newps = PowerScroll.CreateRandom((int)(value - 100), (int)(value - 100)); // consume ingredients this.ConsumeAll(); // add the new powerscroll this.DropItem(newps); break; } case Recipes.SmallBODChange: { // get the target value from one of the powerscrolls Item[] slist = this.FindItemsByType(typeof(SmallBOD), true); Type t = null; // make sure they are all of the same type foreach (Item s in slist) { if (t == null) { t = ((SmallBOD)s).GetType(); } else { if (t != ((SmallBOD)s).GetType()) { from.SendMessage("All BODs must be of the same type"); return; } } } SmallBOD newbod = null; if (t == typeof(SmallTailorBOD)) { newbod = new SmallTailorBOD(); } else if (t == typeof(SmallSmithBOD)) { newbod = new SmallSmithBOD(); } else { from.SendMessage("Cannot transmute those BODs"); return; } if (newbod == null) { return; } // consume ingredients this.ConsumeAll(); // add the new powerscroll this.DropItem(newbod); break; } case Recipes.LargeBODChange: { // get the target value from one of the powerscrolls Item[] slist = this.FindItemsByType(typeof(LargeBOD), true); Type t = null; // make sure they are all of the same type foreach (Item s in slist) { if (t == null) { t = ((LargeBOD)s).GetType(); } else { if (t != ((LargeBOD)s).GetType()) { from.SendMessage("All BODs must be of the same type"); return; } } } LargeBOD newbod = null; if (t == typeof(LargeTailorBOD)) { newbod = new LargeTailorBOD(); } else if (t == typeof(LargeSmithBOD)) { newbod = new LargeSmithBOD(); } else { from.SendMessage("Cannot transmute those BODs"); return; } if (newbod == null) { return; } // consume ingredients this.ConsumeAll(); // add the new powerscroll this.DropItem(newbod); break; } case Recipes.UpgradeAncientAugment: { // check what type of augment is being upgraded BaseSocketAugmentation augment = null; if (this.Items.Count > 0) { augment = this.Items[0] as BaseSocketAugmentation; } if (augment == null) { return; } // make sure they are all the same foreach (Item i in this.Items) { if (augment.GetType() != i.GetType()) { return; } } // take the ingredients this.ConsumeAll(); // and add the result if (augment is AncientDiamond) { this.DropItem(new LegendaryDiamond()); } else if (augment is AncientSapphire) { this.DropItem(new LegendarySapphire()); } else if (augment is AncientSkull) { this.DropItem(new LegendarySkull()); } else if (augment is AncientTourmaline) { this.DropItem(new LegendaryTourmaline()); } else if (augment is AncientWood) { this.DropItem(new LegendaryWood()); } else if (augment is AncientRuby) { this.DropItem(new LegendaryRuby()); } else if (augment is AncientEmerald) { this.DropItem(new LegendaryEmerald()); } else if (augment is AncientAmethyst) { this.DropItem(new LegendaryAmethyst()); } break; } case Recipes.UpgradeLegendaryAugment: { // check what type of augment is being upgraded BaseSocketAugmentation augment = null; if (this.Items.Count > 0) { augment = this.Items[0] as BaseSocketAugmentation; } if (augment == null) { return; } // make sure they are all the same foreach (Item i in this.Items) { if (augment.GetType() != i.GetType()) { return; } } // take the ingredients this.ConsumeAll(); // and add the result if (augment is LegendaryDiamond) { this.DropItem(new MythicDiamond()); } else if (augment is LegendarySapphire) { this.DropItem(new MythicSapphire()); } else if (augment is LegendarySkull) { this.DropItem(new MythicSkull()); } else if (augment is LegendaryTourmaline) { this.DropItem(new MythicTourmaline()); } else if (augment is LegendaryWood) { this.DropItem(new MythicWood()); } else if (augment is LegendaryRuby) { this.DropItem(new MythicRuby()); } else if (augment is LegendaryEmerald) { this.DropItem(new MythicEmerald()); } else if (augment is LegendaryAmethyst) { this.DropItem(new MythicAmethyst()); } break; } case Recipes.UpgradeCrystalAugment: { // check what type of augment is being upgraded BaseSocketAugmentation augment = null; if (this.Items.Count > 0) { augment = this.Items[0] as BaseSocketAugmentation; } if (augment == null) { return; } // make sure they are all the same foreach (Item i in this.Items) { if (augment.GetType() != i.GetType()) { return; } } // take the ingredients this.ConsumeAll(); // and add the result if (augment is RhoCrystal) { this.DropItem(new RadiantRhoCrystal()); } else if (augment is RysCrystal) { this.DropItem(new RadiantRysCrystal()); } else if (augment is WyrCrystal) { this.DropItem(new RadiantWyrCrystal()); } else if (augment is FreCrystal) { this.DropItem(new RadiantFreCrystal()); } else if (augment is TorCrystal) { this.DropItem(new RadiantTorCrystal()); } else if (augment is VelCrystal) { this.DropItem(new RadiantVelCrystal()); } else if (augment is XenCrystal) { this.DropItem(new RadiantXenCrystal()); } else if (augment is PolCrystal) { this.DropItem(new RadiantPolCrystal()); } else if (augment is WolCrystal) { this.DropItem(new RadiantWolCrystal()); } else if (augment is BalCrystal) { this.DropItem(new RadiantBalCrystal()); } else if (augment is TalCrystal) { this.DropItem(new RadiantTalCrystal()); } else if (augment is JalCrystal) { this.DropItem(new RadiantJalCrystal()); } else if (augment is RalCrystal) { this.DropItem(new RadiantRalCrystal()); } else if (augment is KalCrystal) { this.DropItem(new RadiantKalCrystal()); } break; } case Recipes.RecoverAugmentation: { // does item have any sockets on it? Item b = this.FindItemByType(typeof(BaseArmor), true); if (b == null) { b = this.FindItemByType(typeof(BaseWeapon), true); } if (b == null) { b = this.FindItemByType(typeof(BaseJewel), true); } XmlSockets a = XmlAttach.FindAttachment(b, typeof(XmlSockets)) as XmlSockets; if (a == null) { // if so then forget it from.SendMessage("This item is not socketed."); return; } if (a.NSockets == 0) { from.SendMessage("This item is has no sockets."); return; } BaseSocketAugmentation augment = a.RecoverRandomAugmentation(from, b); if (augment != null) { // consume the crystal this.ConsumeTotal(typeof(AncientRuby), 1, true); // put the recovered augment in the container this.DropItem(augment); from.SendMessage("Recovered a {0} augmentation.", augment.Name); // update the sockets gump a.OnIdentify(from); } else { from.SendMessage("Failed to recover augmentation."); } break; } case Recipes.HammerOfRecovery: { // consume ingredients this.ConsumeAll(); // add the hammer this.DropItem(new HammerOfRecovery(1)); break; } case Recipes.ExceptionalSocketHammer: { // consume ingredients this.ConsumeAll(); // add the hammer this.DropItem(new ExceptionalSocketHammer(1)); break; } case Recipes.SocketWeapon: { // does the weapon already have any sockets on it? Item b = this.FindItemByType(typeof(BaseWeapon), true); XmlAttachment a = XmlAttach.FindAttachment(b, typeof(XmlSockets)); if (a != null) { // if so then forget it from.SendMessage("Weapon already socketed."); return; } // otherwise add the socket XmlAttach.AttachTo(b, new XmlSockets(1)); // consume the crystal this.ConsumeTotal(typeof(RadiantRhoCrystal), 1, true); break; } case Recipes.SocketArmor: { // does the armor already have any sockets on it? Item b = this.FindItemByType(typeof(BaseArmor), true); XmlAttachment a = XmlAttach.FindAttachment(b, typeof(XmlSockets)); if (a != null) { // if so then forget it from.SendMessage("Armor already socketed."); return; } // otherwise add the socket XmlAttach.AttachTo(b, new XmlSockets(1)); // consume the crystal this.ConsumeTotal(typeof(RadiantRhoCrystal), 1, true); break; } // Uncomment the follow recipes if you have XmlMobFactions installed and you would like to allow faction gain through these recipes #if (XMLMOBFACTIONS) case Recipes.UndeadFaction: { // how much gold is being offered Item b = FindItemByType(typeof(Gold), true); int value = 0; if (b != null) { value = b.Amount / 10; } // take the ingredients ConsumeAll(); // add the faction XmlAttach.AttachTo(from, new XmlAddFaction("Undead", value)); break; } case Recipes.AbyssFaction: { // how much gold is being offered Item b = FindItemByType(typeof(Gold), true); int value = 0; if (b != null) { value = b.Amount / 10; } // take the ingredients ConsumeAll(); // add the faction XmlAttach.AttachTo(from, new XmlAddFaction("Abyss", value)); break; } case Recipes.HumanoidFaction: { // how much gold is being offered Item b = FindItemByType(typeof(Gold), true); int value = 0; if (b != null) { value = b.Amount / 10; } // take the ingredients ConsumeAll(); // add the faction XmlAttach.AttachTo(from, new XmlAddFaction("Humanoid", value)); break; } case Recipes.ReptilianFaction: { // how much gold is being offered Item b = FindItemByType(typeof(Gold), true); int value = 0; if (b != null) { value = b.Amount / 10; } // take the ingredients ConsumeAll(); // add the faction XmlAttach.AttachTo(from, new XmlAddFaction("Reptilian", value)); break; } case Recipes.ArachnidFaction: { // how much gold is being offered Item b = FindItemByType(typeof(Gold), true); int value = 0; if (b != null) { value = b.Amount / 10; } // take the ingredients ConsumeAll(); // add the faction XmlAttach.AttachTo(from, new XmlAddFaction("Arachnid", value)); break; } case Recipes.ElementalFaction: { // how much gold is being offered Item b = FindItemByType(typeof(Gold), true); int value = 0; if (b != null) { value = b.Amount / 10; } // take the ingredients ConsumeAll(); // add the faction XmlAttach.AttachTo(from, new XmlAddFaction("Elemental", value)); break; } case Recipes.UnderworldFaction: { // how much gold is being offered Item b = FindItemByType(typeof(Gold), true); int value = 0; if (b != null) { value = b.Amount / 10; } // take the ingredients ConsumeAll(); // add the faction XmlAttach.AttachTo(from, new XmlAddFaction("Underworld", value)); break; } // end of commented-out XmlMobFactions recipes #endif } // give effects for successful transmutation from.PlaySound(503); base.DoTransmute(from, r); }