public static void EventSink_Speech(SpeechEventArgs args) { Mobile from = args.Mobile; int[] keywords = args.Keywords; if (from is PlayerMobile) { PlayerMobile player = from as PlayerMobile; if (args.Speech.ToLower().Equals("trick or treat")) { Item[] items = from.Backpack.FindItemsByType(typeof(TrickOrTreatBag)); if (items.Length == 0) { from.SendMessage("You need a goodie bag to go trick or treating!"); } else { bool foundbag = false; foreach (TrickOrTreatBag tb in items) { if (tb.Uses > 0) { foreach (Mobile m in from.GetMobilesInRange(3)) // TODO: Validate range { if (!m.Player && m.Body.IsHuman && (m is BaseVendor)) { if (m is BaseCreature && (((BaseCreature)m).IsHumanInTown())) { from.Direction = from.GetDirectionTo(m); m.Direction = m.GetDirectionTo(from); TrickOrTreat.GiveTreat(from, m, tb); tb.ConsumeUse(from); return; } } } foundbag = true; break; } } if (!foundbag) { from.SendMessage("You don't have any uses left on your goodie bags"); } } } } }
public static void EventSink_Speech(SpeechEventArgs args) { Mobile from = args.Mobile; int[] keywords = args.Keywords; if (from is PlayerMobile) { PlayerMobile player = from as PlayerMobile; if (args.Speech.ToLower().Equals("trick or treat")) { Item[] items = from.Backpack.FindItemsByType(typeof(TrickOrTreatBag)); if (items.Length == 0) { from.SendMessage("You need a goodie basket to go trick or treating!"); } else { bool foundbag = false; foreach (TrickOrTreatBag tb in items) { if (tb.Uses > 0) { foreach (Mobile m in from.GetMobilesInRange(2)) // TODO: Validate range { Container cont = m.Backpack; if (m is KungFu) { from.Direction = from.GetDirectionTo(m); m.Direction = m.GetDirectionTo(from); m.Say("Sorry, I do not celebrate Halloween."); } else if ((m is BaseVendor) && (player.BodyMod == 0)) { from.Direction = from.GetDirectionTo(m); m.Direction = m.GetDirectionTo(from); m.Say("You are not in costume so how can you go trick or treating?"); } else if ((m is BaseVendor) && (Utility.Random(100) > 80)) { Gold m_Gold = (Gold)m.Backpack.FindItemByType(typeof(Gold)); int m_Amount = m.Backpack.GetAmount(typeof(Gold)); from.Direction = from.GetDirectionTo(m); m.Direction = m.GetDirectionTo(from); cont.ConsumeTotal(typeof(Gold), m_Amount); m.Say("Sorry, I don't have anything to give you at the moment."); } else if ((m is BaseVendor) && (cont.ConsumeTotal(typeof(Gold), 1))) { Gold m_Gold = (Gold)m.Backpack.FindItemByType(typeof(Gold)); int m_Amount = m.Backpack.GetAmount(typeof(Gold)); from.Direction = from.GetDirectionTo(m); m.Direction = m.GetDirectionTo(from); TrickOrTreat.GiveTreat(from, m, tb); tb.ConsumeUse(from); cont.ConsumeTotal(typeof(Gold), m_Amount); return; } else if (m is BaseVendor) { from.Direction = from.GetDirectionTo(m); m.Direction = m.GetDirectionTo(from); m.Say("Sorry, I don't have anything to give you at the moment."); } } foundbag = true; break; } } if (!foundbag) { from.SendMessage("Your trick-or-treat bag seems to be worn out from all the things it was filled with."); } } } } }