protected override void OnTarget(Mobile from, object targ) { bool done = false; if (!(targ is Item)) { from.SendMessage("You can only dupe items."); return; } CommandLogging.WriteLine(from, "{0} {1} duping {2} (inBag={3}; amount={4})", from.AccessLevel, CommandLogging.Format(from), CommandLogging.Format(targ), m_InBag, m_Amount); Item copy = (Item)targ; Container pack; if (m_InBag) { if (copy.Parent is Container) { pack = (Container)copy.Parent; } else if (copy.Parent is Mobile) { pack = ((Mobile)copy.Parent).Backpack; } else { pack = null; } } else { pack = from.Backpack; } Type t = copy.GetType(); //ConstructorInfo[] info = t.GetConstructors(); ConstructorInfo c = t.GetConstructor(Type.EmptyTypes); if (c != null) { try { from.SendMessage("Duping {0}...", m_Amount); for (int i = 0; i < m_Amount; i++) { object o = c.Invoke(null); if (o != null && o is Item) { Item newItem = (Item)o; CopyProperties(newItem, copy); //copy.Dupe( item, copy.Amount ); copy.OnAfterDuped(newItem); newItem.Parent = null; if (pack != null) { pack.DropItem(newItem); } else { newItem.MoveToWorld(from.Location, from.Map); } CommandLogging.WriteLine(from, "{0} {1} duped {2} creating {3}", from.AccessLevel, CommandLogging.Format(from), CommandLogging.Format(targ), CommandLogging.Format(newItem)); } } from.SendMessage("Done"); done = true; } catch { from.SendMessage("Error!"); return; } } if (!done) { from.SendMessage("Unable to dupe. Item must have a 0 parameter constructor."); } }
protected override void OnTarget(Mobile from, object targeted) { if (targeted is Mobile) { Mobile targ = (Mobile)targeted; if (from != targ) { from.SendMessage("You may only set your own body to GM style."); } else { m_Mobile = from; if (Config.Get("Staff.Staffbody", true)) { m_Mobile.BodyValue = 987; if (Config.Get("Staff.UseColoring", true)) { switch (m_Mobile.AccessLevel) { case AccessLevel.Owner: m_Mobile.Hue = Config.Get("Staff.Owner", 1001); break; case AccessLevel.Developer: m_Mobile.Hue = Config.Get("Staff.Developer", 1001); break; case AccessLevel.Administrator: m_Mobile.Hue = Config.Get("Staff.Administrator", 1001); break; case AccessLevel.Seer: m_Mobile.Hue = Config.Get("Staff.Seer", 467); break; case AccessLevel.GameMaster: m_Mobile.Hue = Config.Get("Staff.GameMaster", 39); break; case AccessLevel.Counselor: m_Mobile.Hue = Config.Get("Staff.Counselor", 3); break; } } } if (Config.Get("Staff.CutHair", true)) { m_Mobile.HairItemID = 0; } if (Config.Get("Staff.CutFacialHair", true)) { m_Mobile.FacialHairItemID = 0; } CommandLogging.WriteLine(from, "{0} {1} is assuming a GM body", from.AccessLevel, CommandLogging.Format(from)); Container pack = from.Backpack; ArrayList ItemsToDelete = new ArrayList(); foreach (Item item in from.Items) { if (item.Layer != Layer.Bank && item.Layer != Layer.Hair && item.Layer != Layer.FacialHair && item.Layer != Layer.Mount && item.Layer != Layer.Backpack) { ItemsToDelete.Add(item); } } foreach (Item item in ItemsToDelete) { item.Delete(); } if (pack == null) { pack = new Backpack(); pack.Movable = false; from.AddItem(pack); } else { pack.Delete(); pack = new Backpack(); pack.Movable = false; from.AddItem(pack); } from.Hunger = 20; from.Thirst = 20; from.Fame = 0; from.Karma = 0; from.Kills = 0; from.Hidden = true; from.Blessed = true; from.Hits = from.HitsMax; from.Mana = from.ManaMax; from.Stam = from.StamMax; if (from.IsStaff()) { EquipItem(new StaffRing()); PackItem(new GMHidingStone()); PackItem(new GMEthereal()); PackItem(new StaffOrb()); from.RawStr = 100; from.RawDex = 100; from.RawInt = 100; from.Hits = from.HitsMax; from.Mana = from.ManaMax; from.Stam = from.StamMax; for (int i = 0; i < targ.Skills.Length; ++i) { targ.Skills[i].Base = 120; } } if (Config.Get("Staff.GiveBoots", true)) { int color = 0; if (Config.Get("Staff.UseColoring", true)) { switch (m_Mobile.AccessLevel) { case AccessLevel.Owner: color = Config.Get("Staff.Owner", 1001); break; case AccessLevel.Developer: color = Config.Get("Staff.Developer", 1001); break; case AccessLevel.Administrator: color = Config.Get("Staff.Administrator", 1001); break; case AccessLevel.Seer: color = Config.Get("Staff.Seer", 467); break; case AccessLevel.GameMaster: color = Config.Get("Staff.GameMaster", 39); break; case AccessLevel.Counselor: color = Config.Get("Staff.Counselor", 3); break; } } if (from.IsStaff() && from.AccessLevel <= AccessLevel.Spawner) { EquipItem(new FurBoots(color)); } else if (from.AccessLevel == AccessLevel.GameMaster) { EquipItem(new FurBoots(color)); } if (from.AccessLevel == AccessLevel.Seer) { EquipItem(new FurBoots(color)); } if (from.AccessLevel == AccessLevel.Administrator) { EquipItem(new FurBoots(color)); } if (from.AccessLevel == AccessLevel.Developer) { EquipItem(new FurBoots(color)); } if (from.AccessLevel >= AccessLevel.CoOwner) { EquipItem(new FurBoots(color)); } } } } }
public override void OnResponse(NetState sender, RelayInfo info) { if (m_Mobile.Deleted) { m_From.SendGump(new InterfaceGump(m_From, m_List, m_Page)); return; } else if (!BaseCommand.IsAccessible(m_From, m_Mobile)) { m_From.SendMessage("That is no longer accessible."); m_From.SendGump(new InterfaceGump(m_From, m_List, m_Page)); return; } switch (info.ButtonID) { case 0: case 1: { m_From.SendGump(new InterfaceGump(m_From, m_List, m_Page)); break; } case 2: // Properties { m_From.SendGump(new InterfaceMobileGump(m_From, m_List, m_Page, m_Mobile)); m_From.SendGump(new PropertiesGump(m_From, m_Mobile)); break; } case 3: // Delete { if (!m_Mobile.Player) { CommandLogging.WriteLine(m_From, "{0} {1} deleting {2}", m_From.AccessLevel, CommandLogging.Format(m_From), CommandLogging.Format(m_Mobile)); m_Mobile.Delete(); m_From.SendGump(new InterfaceGump(m_From, m_List, m_Page)); } break; } case 4: // Go there { m_From.SendGump(new InterfaceMobileGump(m_From, m_List, m_Page, m_Mobile)); InvokeCommand(String.Format("Go {0}", m_Mobile.Serial.Value)); break; } case 5: // Bring them here { if (m_From.Map == null || m_From.Map == Map.Internal) { m_From.SendMessage("You cannot bring that person here."); } else { m_From.SendGump(new InterfaceMobileGump(m_From, m_List, m_Page, m_Mobile)); m_Mobile.MoveToWorld(m_From.Location, m_From.Map); } break; } case 6: // Move to target { m_From.SendGump(new InterfaceMobileGump(m_From, m_List, m_Page, m_Mobile)); m_From.Target = new MoveTarget(m_Mobile); break; } case 7: // Kill { if (m_From == m_Mobile || m_From.AccessLevel > m_Mobile.AccessLevel) { m_Mobile.Kill(); } m_From.SendGump(new InterfaceMobileGump(m_From, m_List, m_Page, m_Mobile)); break; } case 8: // Res { if (m_From == m_Mobile || m_From.AccessLevel > m_Mobile.AccessLevel) { m_Mobile.PlaySound(0x214); m_Mobile.FixedEffect(0x376A, 10, 16); m_Mobile.Resurrect(); } m_From.SendGump(new InterfaceMobileGump(m_From, m_List, m_Page, m_Mobile)); break; } case 9: // Client { m_From.SendGump(new InterfaceMobileGump(m_From, m_List, m_Page, m_Mobile)); if (m_Mobile.NetState != null) { m_From.SendGump(new ClientGump(m_From, m_Mobile.NetState)); } break; } } }
protected override void OnTarget(Mobile from, object targ) { bool done = false; if (!(targ is Item)) { from.SendMessage("You can only dupe items."); return; } CommandLogging.WriteLine(from, "{0} {1} duping {2} (inBag={3}; amount={4})", from.AccessLevel, CommandLogging.Format(from), CommandLogging.Format(targ), m_InBag, m_Amount); Item copy = (Item)targ; Container pack = null; if (m_InBag) { if (copy.Parent is Container cont) { pack = cont; } else if (copy.Parent is Mobile m) { pack = m.Backpack; } } else { pack = from.Backpack; } ConstructorInfo c = ActivatorUtil.GetConstructor(copy.GetType()); if (c != null) { var paramList = c.GetParameters(); object[] args = paramList.Length == 0 ? null : new object[paramList.Length]; if (args != null) { Array.Fill(args, Type.Missing); } try { from.SendMessage("Duping {0}...", m_Amount); for (int i = 0; i < m_Amount; i++) { if (c.Invoke(args) is Item newItem) { CopyProperties(newItem, copy); //copy.Dupe( item, copy.Amount ); copy.OnAfterDuped(newItem); newItem.Parent = null; if (pack != null) { pack.DropItem(newItem); } else { newItem.MoveToWorld(from.Location, from.Map); } newItem.InvalidateProperties(); CommandLogging.WriteLine(from, "{0} {1} duped {2} creating {3}", from.AccessLevel, CommandLogging.Format(from), CommandLogging.Format(targ), CommandLogging.Format(newItem)); } } from.SendMessage("Done"); done = true; } catch { from.SendMessage("Error!"); return; } } if (!done) { from.SendMessage("Unable to dupe. Item must have a 0 parameter constructor."); } }
public static void GetFollowers_OnTarget(Mobile from, object obj) { if (obj is PlayerMobile) { PlayerMobile master = (PlayerMobile)obj; List <Mobile> pets = master.AllFollowers; if (pets.Count > 0) { CommandLogging.WriteLine(from, "{0} {1} getting all followers of {2}", from.AccessLevel, CommandLogging.Format(from), CommandLogging.Format(master)); from.SendMessage("That player has {0} pet{1}.", pets.Count, pets.Count != 1 ? "s" : ""); for (int i = 0; i < pets.Count; ++i) { Mobile pet = (Mobile)pets[i]; if (pet is IMount) { ((IMount)pet).Rider = null; // make sure it's dismounted } pet.MoveToWorld(from.Location, from.Map); } } else { from.SendMessage("There were no pets found for that player."); } } else if (obj is Mobile && ((Mobile)obj).Player) { Mobile master = (Mobile)obj; ArrayList pets = new ArrayList(); foreach (Mobile m in World.Mobiles.Values) { if (m is BaseCreature) { BaseCreature bc = (BaseCreature)m; if ((bc.Controlled && bc.ControlMaster == master) || (bc.Summoned && bc.SummonMaster == master)) { pets.Add(bc); } } } if (pets.Count > 0) { CommandLogging.WriteLine(from, "{0} {1} getting all followers of {2}", from.AccessLevel, CommandLogging.Format(from), CommandLogging.Format(master)); from.SendMessage("That player has {0} pet{1}.", pets.Count, pets.Count != 1 ? "s" : ""); for (int i = 0; i < pets.Count; ++i) { Mobile pet = (Mobile)pets[i]; if (pet is IMount) { ((IMount)pet).Rider = null; // make sure it's dismounted } pet.MoveToWorld(from.Location, from.Map); } } else { from.SendMessage("There were no pets found for that player."); } } else { from.BeginTarget(-1, false, TargetFlags.None, new TargetCallback(GetFollowers_OnTarget)); from.SendMessage("That is not a player. Try again."); } }
public static int Build(Mobile from, Point3D start, Point3D end, ConstructorInfo ctor, object[] values, string[,] props, PropertyInfo[] realProps, List <Container> packs, bool outline, bool mapAvg) { try { Map map = from.Map; int width = end.X - start.X + 1; int height = end.Y - start.Y + 1; if (outline && (width < 3 || height < 3)) { outline = false; } int objectCount; if (packs != null) { objectCount = packs.Count; } else if (outline) { objectCount = (width + height - 2) * 2; } else { objectCount = width * height; } if (objectCount >= 20) { from.SendMessage("Constructing {0} objects, please wait.", objectCount); } bool sendError = true; StringBuilder sb = new StringBuilder(); sb.Append("Serials: "); if (packs != null) { for (int i = 0; i < packs.Count; ++i) { IEntity built = Build(from, ctor, values, props, realProps, ref sendError); sb.AppendFormat("0x{0:X}; ", built.Serial.Value); if (built is Item) { Container pack = packs[i]; pack.DropItem((Item)built); } else if (built is Mobile) { Mobile m = (Mobile)built; m.MoveToWorld(new Point3D(start.X, start.Y, start.Z), map); } } } else { int z = start.Z; for (int x = start.X; x <= end.X; ++x) { for (int y = start.Y; y <= end.Y; ++y) { if (outline && x != start.X && x != end.X && y != start.Y && y != end.Y) { continue; } if (mapAvg) { z = map.GetAverageZ(x, y); } IEntity built = Build(from, ctor, values, props, realProps, ref sendError); sb.AppendFormat("0x{0:X}; ", built.Serial.Value); if (built is Item) { Item item = (Item)built; item.MoveToWorld(new Point3D(x, y, z), map); } else if (built is Mobile) { Mobile m = (Mobile)built; m.MoveToWorld(new Point3D(x, y, z), map); } } } } CommandLogging.WriteLine(from, sb.ToString()); return(objectCount); } catch (Exception e) { Server.Diagnostics.ExceptionLogging.LogException(e); return(0); } }
public static void DoWipe(Mobile from, Map map, Point3D start, Point3D end, WipeType type) { CommandLogging.WriteLine(from, "{0} {1} wiping from {2} to {3} in {5} ({4})", from.AccessLevel, CommandLogging.Format(from), start, end, type, map); bool mobiles = ((type & WipeType.Mobiles) != 0); bool multis = ((type & WipeType.Multis) != 0); bool items = ((type & WipeType.Items) != 0); ArrayList toDelete = new ArrayList(); Rectangle2D rect = new Rectangle2D(start.X, start.Y, end.X - start.X + 1, end.Y - start.Y + 1); IPooledEnumerable eable; if ((items || multis) && mobiles) { eable = map.GetObjectsInBounds(rect); } else if (items || multis) { eable = map.GetItemsInBounds(rect); } else if (mobiles) { eable = map.GetMobilesInBounds(rect); } else { return; } foreach (object obj in eable) { if (items && (obj is Item) && !((obj is BaseMulti) || (obj is HouseSign))) { toDelete.Add(obj); } else if (multis && (obj is BaseMulti)) { toDelete.Add(obj); } else if (mobiles && (obj is Mobile) && !((Mobile)obj).Player) { toDelete.Add(obj); } } eable.Free(); for (int i = 0; i < toDelete.Count; ++i) { if (toDelete[i] is Item) { ((Item)toDelete[i]).Delete(); } else if (toDelete[i] is Mobile) { ((Mobile)toDelete[i]).Delete(); } } }
protected override void OnTarget(Mobile m, object targ) { var done = false; if (!(targ is Item)) { m.SendMessage("You can only dupe items."); return; } CommandLogging.WriteLine( m, "{0} {1} duping {2} (inBag={3}; amount={4})", m.AccessLevel, CommandLogging.Format(m), CommandLogging.Format(targ), _InBag, _Amount); var item = (Item)targ; Container pack; if (_InBag) { if (item.Parent is Container) { pack = (Container)item.Parent; } else if (item.Parent is Mobile) { pack = ((Mobile)item.Parent).Backpack; } else { pack = null; } } else { pack = m.Backpack; } var t = item.GetType(); var a = t.GetCustomAttributes(typeof(ConstructibleAttribute), false); if (a.OfType <ConstructibleAttribute>().Any(ca => ca.AccessLevel > m.AccessLevel)) { return; } try { m.SendMessage("Duping {0}...", _Amount); var noCtor = false; for (var i = 0; i < _Amount; i++) { Item o; try { o = Activator.CreateInstance(t, true) as Item; } catch { o = null; } if (o == null) { noCtor = true; break; } CopyProperties(item, o); o.Parent = null; item.OnAfterDuped(o); if (item is Container && o is Container) { m.SendMessage("Duping Container Children..."); DupeChildren(m, (Container)item, (Container)o); } if (pack != null) { pack.DropItem(o); } else { o.MoveToWorld(m.Location, m.Map); } o.UpdateTotals(); o.InvalidateProperties(); o.Delta(ItemDelta.Update); CommandLogging.WriteLine( m, "{0} {1} duped {2} creating {3}", m.AccessLevel, CommandLogging.Format(m), CommandLogging.Format(item), CommandLogging.Format(o)); } if (!noCtor) { m.SendMessage("Done"); done = true; } } catch (Exception e) { Console.WriteLine(e.StackTrace); m.SendMessage("Error!"); return; } if (!done) { m.SendMessage("Unable to dupe. Item must have a 0 parameter constructor."); } else { item.Delta(ItemDelta.Update); } }
public static void Invoke( Mobile from, Point3D start, Point3D end, string[] args, List <Container> packs = null, bool outline = false, bool mapAvg = false ) { var sb = new StringBuilder(); sb.AppendFormat("{0} {1} building ", from.AccessLevel, CommandLogging.Format(from)); if (start == end) { sb.AppendFormat("at {0} in {1}", start, from.Map); } else { sb.AppendFormat("from {0} to {1} in {2}", start, end, from.Map); } sb.Append(':'); for (var i = 0; i < args.Length; ++i) { sb.AppendFormat(" \"{0}\"", args[i]); } CommandLogging.WriteLine(from, sb.ToString()); var name = args[0]; FixArgs(ref args); string[,] props = null; for (var i = 0; i < args.Length; ++i) { if (args[i].InsensitiveEquals("set")) { var remains = args.Length - i - 1; if (remains >= 2) { props = new string[remains / 2, 2]; remains /= 2; for (var j = 0; j < remains; ++j) { props[j, 0] = args[i + j * 2 + 1]; props[j, 1] = args[i + j * 2 + 2]; } FixSetString(ref args, i); } break; } } var type = AssemblyHandler.FindTypeByName(name); if (!IsEntity(type)) { from.SendMessage("No type with that name was found."); return; } var watch = new Stopwatch(); watch.Start(); var built = BuildObjects(from, type, start, end, args, props, packs, outline, mapAvg); if (built > 0) { watch.Stop(); from.SendMessage( "{0} object{1} generated in {2:F2} seconds.", built, built != 1 ? "s" : "", watch.Elapsed.TotalSeconds ); } else { SendUsage(type, from); } }
public static int Build(Mobile from, Point3D start, Point3D end, ConstructorInfo ctor, object[] values, string[,] props, PropertyInfo[] realProps, List <Container> packs) { try { Map map = from.Map; int objectCount = (packs == null ? (((end.X - start.X) + 1) * ((end.Y - start.Y) + 1)) : packs.Count); if (objectCount >= 20) { from.SendMessage("Constructing {0} objects, please wait.", objectCount); } bool sendError = true; StringBuilder sb = new StringBuilder(); sb.Append("Serials: "); if (packs != null) { for (int i = 0; i < packs.Count; ++i) { IEntity built = Build(from, ctor, values, props, realProps, ref sendError); sb.AppendFormat("0x{0:X}; ", built.Serial.Value); if (built is Item) { Container pack = packs[i]; pack.DropItem((Item)built); } else if (built is Mobile) { Mobile m = (Mobile)built; m.MoveToWorld(new Point3D(start.X, start.Y, start.Z), map); } } } else { for (int x = start.X; x <= end.X; ++x) { for (int y = start.Y; y <= end.Y; ++y) { IEntity built = Build(from, ctor, values, props, realProps, ref sendError); sb.AppendFormat("0x{0:X}; ", built.Serial.Value); if (built is Item) { Item item = (Item)built; item.MoveToWorld(new Point3D(x, y, start.Z), map); } else if (built is Mobile) { Mobile m = (Mobile)built; m.MoveToWorld(new Point3D(x, y, start.Z), map); } } } } CommandLogging.WriteLine(from, sb.ToString()); return(objectCount); } catch (Exception ex) { Misc.ExceptionLogging.WriteLine(ex); return(0); } }
protected override void OnTarget(Mobile from, object targ) { var done = false; if (!(targ is Item)) { from.SendMessage("You can only dupe items."); return; } CommandLogging.WriteLine( from, "{0} {1} duping {2} (inBag={3}; amount={4})", from.AccessLevel, CommandLogging.Format(from), CommandLogging.Format(targ), m_InBag, m_Amount ); var copy = (Item)targ; Container pack = null; if (m_InBag) { pack = copy.Parent switch { Container cont => cont, Mobile m => m.Backpack, _ => pack }; } else { pack = from.Backpack; } var c = copy.GetType().GetConstructor(); if (c != null) { var paramList = c.GetParameters(); var args = paramList.Length == 0 ? null : new object[paramList.Length]; if (args != null) { Array.Fill(args, Type.Missing); } try { from.SendMessage("Duping {0}...", m_Amount); for (var i = 0; i < m_Amount; i++) { if (c.Invoke(args) is Item newItem) { CopyProperties(newItem, copy); copy.OnAfterDuped(newItem); if (pack != null) { pack.DropItem(newItem); } else { newItem.MoveToWorld(from.Location, from.Map); } newItem.UpdateTotals(); newItem.InvalidateProperties(); newItem.Delta(ItemDelta.Update); CommandLogging.WriteLine( from, "{0} {1} duped {2} creating {3}", from.AccessLevel, CommandLogging.Format(from), CommandLogging.Format(targ), CommandLogging.Format(newItem) ); } } from.SendMessage("Done"); done = true; } catch { from.SendMessage("Error!"); return; } } if (!done) { from.SendMessage("Unable to dupe. Item must have a constructor with zero required parameters."); } }
protected override void OnTarget(Mobile from, object targeted) { if (targeted is Mobile) { Mobile targ = (Mobile)targeted; if (from != targ) { from.SendMessage("You may only set your own body to GM style."); } else { m_Mobile = from; CommandLogging.WriteLine(from, "{0} {1} is assuming a GM body", from.AccessLevel, CommandLogging.Format(from)); Container pack = from.Backpack; ArrayList ItemsToDelete = new ArrayList(); foreach (Item item in from.Items) { if (item.Layer != Layer.Bank && item.Layer != Layer.Hair && item.Layer != Layer.FacialHair && item.Layer != Layer.Mount && item.Layer != Layer.Backpack) { ItemsToDelete.Add(item); } } foreach (Item item in ItemsToDelete) { item.Delete(); } if (pack == null) { pack = new Backpack(); pack.Movable = false; from.AddItem(pack); } else { pack.Delete(); pack = new Backpack(); pack.Movable = false; from.AddItem(pack); } from.Hunger = 20; from.Thirst = 20; from.Fame = 0; from.Karma = 0; from.Kills = 0; from.Hidden = true; from.Blessed = true; from.Hits = from.HitsMax; from.Mana = from.ManaMax; from.Stam = from.StamMax; if (from.IsStaff()) { EquipItem(new StaffRing()); EquipItem(new StaffRobe()); PackItem(new GMHidingStone()); PackItem(new GMEthereal()); PackItem(new StaffOrb(from)); PackItem(new Spellbook((ulong)18446744073709551615)); PackItem(new NecromancerSpellbook((ulong)0xffff)); PackItem(new BookOfChivalry()); PackItem(new BookOfBushido()); PackItem(new SpellweavingBook((ulong)0xffff)); from.RawStr = 100; from.RawDex = 100; from.RawInt = 100; from.Hits = from.HitsMax; from.Mana = from.ManaMax; from.Stam = from.StamMax; for (int i = 0; i < targ.Skills.Length; ++i) { targ.Skills[i].Base = 120; } } if (from.IsStaff() && from.AccessLevel <= AccessLevel.Spawner) { EquipItem(new FurBoots(3)); } else if (from.AccessLevel == AccessLevel.GameMaster) { EquipItem(new FurBoots(39)); } if (from.AccessLevel == AccessLevel.Seer) { EquipItem(new FurBoots(467)); } if (from.AccessLevel == AccessLevel.Administrator) { EquipItem(new FurBoots(1001)); } if (from.AccessLevel == AccessLevel.Developer) { EquipItem(new FurBoots(1001)); } if (from.AccessLevel >= AccessLevel.CoOwner) { EquipItem(new FurBoots(1001)); } } } }
protected override void OnTarget(Mobile from, object targ) { bool done = false; if (!(targ is Item)) { from.SendMessage("You can only dupe items."); return; } CommandLogging.WriteLine(from, "{0} {1} duping {2} (inBag={3}; amount={4})", from.AccessLevel, CommandLogging.Format(from), CommandLogging.Format(targ), m_InBag, m_Amount); Item copy = (Item)targ; Container pack; if (m_InBag) { if (copy.Parent is Container) { pack = (Container)copy.Parent; } else if (copy.Parent is Mobile) { pack = ((Mobile)copy.Parent).Backpack; } else { pack = null; } } else { pack = from.Backpack; } from.SendMessage("Duping {0}...", m_Amount); for (int i = 0; i < m_Amount; i++) { Item a = DupeItem(from, copy, true); if (a == null) { break; } if (pack != null) { pack.DropItem(a); } else { a.MoveToWorld(from.Location, from.Map); } done = true; } if (done) { from.SendMessage("Done"); } else { from.SendMessage("Error!"); } }
public static Item DupeItem(Mobile m, Item item) { try { var t = item.GetType(); if (m != null) { var a = t.GetCustomAttributes(typeof(ConstructibleAttribute), false); if (a.OfType <ConstructibleAttribute>().Any(ca => ca.AccessLevel > m.AccessLevel)) { return(null); } } Item o; try { o = Activator.CreateInstance(t, true) as Item; } catch { o = null; } if (o == null) { return(null); } CopyProperties(item, o); o.Parent = null; item.OnAfterDuped(o); if (item is Container && o is Container) { DupeChildren(m, (Container)item, (Container)o); } if (m != null) { o.MoveToWorld(m.Location, m.Map); o.UpdateTotals(); o.InvalidateProperties(); o.Delta(ItemDelta.Update); CommandLogging.WriteLine(m, "{0} {1} duped {2} creating {3}", m.AccessLevel, CommandLogging.Format(m), CommandLogging.Format(item), CommandLogging.Format(o)); } item.Delta(ItemDelta.Update); return(o); } catch { return(null); } }
protected override void OnTarget(Mobile from, object targeted) { if (targeted is Mobile) { Mobile targ = (Mobile)targeted; if (from != targ) { from.SendMessage("You may only set your own body to GM style."); } else { m_Mobile = from; CommandLogging.WriteLine(from, "{0} {1} is assuming a GM body", from.AccessLevel, CommandLogging.Format(from)); Container pack = from.Backpack; if (pack == null) { pack = new Backpack(); pack.Movable = false; from.AddItem(pack); } from.Hunger = 20; from.Thirst = 20; from.Fame = 0; from.Karma = 0; from.Kills = 0; from.Hidden = true; from.Hits = from.HitsMax; from.Mana = from.ManaMax; from.Stam = from.StamMax; if (from.AccessLevel >= AccessLevel.Counselor) { EquipItem(new StaffRing()); Spellbook book1 = new Spellbook((ulong)18446744073709551615); Spellbook book2 = new NecromancerSpellbook((ulong)0xffff); Spellbook book3 = new BookOfChivalry(); Spellbook book4 = new BookOfBushido(); Spellbook book5 = new BookOfNinjitsu(); PackItem(book1); PackItem(book2); PackItem(book3); PackItem(book4); PackItem(book5); PackItem(new PropsStone()); PackItem(new TeleportStone()); PackItem(new GoStone()); PackItem(new GMHidingStone()); PackItem(new SpeedStone()); from.RawStr = 100; from.RawDex = 100; from.RawInt = 100; from.Hits = from.HitsMax; from.Mana = from.ManaMax; from.Stam = from.StamMax; for (int i = 0; i < targ.Skills.Length; ++i) { targ.Skills[i].Base = 120; } } if (from.AccessLevel == AccessLevel.Counselor) { EquipItem(new CounselorRobe()); EquipItem(new ThighBoots(3)); from.Title = "[Counselor]"; } if (from.AccessLevel == AccessLevel.GameMaster) { PackItem(new RemoveStone()); EquipItem(new GMRobe()); EquipItem(new ThighBoots(39)); from.Title = "[GM]"; } if (from.AccessLevel == AccessLevel.Seer) { PackItem(new RemoveStone()); EquipItem(new SeerRobe()); EquipItem(new ThighBoots(467)); from.Title = "[Seer]"; } if (from.AccessLevel == AccessLevel.Administrator) { PackItem(new RemoveStone()); PackItem(new PremiumStone()); PackItem(new AdminStone()); EquipItem(new AdminRobe()); EquipItem(new ThighBoots(1001)); from.Title = "[Admin]"; } if (from.AccessLevel == AccessLevel.Developer) { PackItem(new RemoveStone()); PackItem(new PremiumStone()); PackItem(new AdminStone()); EquipItem(new AdminRobe()); EquipItem(new ThighBoots(1001)); from.Title = "[Developer]"; } if (from.AccessLevel == AccessLevel.Owner) { PackItem(new RemoveStone()); PackItem(new PremiumStone()); PackItem(new AdminStone()); EquipItem(new AdminRobe()); EquipItem(new ThighBoots(1001)); from.Title = "[Owner]"; } } } }
public static void DupeChildren(Mobile m, Container src, Container dest) { foreach (var item in src.Items) { try { var t = item.GetType(); if (m != null) { var a = t.GetCustomAttributes(typeof(ConstructibleAttribute), false); if (a.OfType <ConstructibleAttribute>().Any(ca => ca.AccessLevel > m.AccessLevel)) { continue; } } Item o; try { o = Activator.CreateInstance(t, true) as Item; } catch { o = null; } if (o == null) { continue; } CopyProperties(item, o); o.Parent = null; item.OnAfterDuped(o); if (item is Container && o is Container) { DupeChildren(m, (Container)item, (Container)o); } dest.DropItem(o); o.Location = item.Location; o.UpdateTotals(); o.InvalidateProperties(); o.Delta(ItemDelta.Update); CommandLogging.WriteLine( m, "{0} {1} duped {2} creating {3}", m.AccessLevel, CommandLogging.Format(m), CommandLogging.Format(item), CommandLogging.Format(o)); item.Delta(ItemDelta.Update); } catch { } } }
public static void egate_OnCommand(CommandEventArgs e) { CommandLogging.WriteLine(e.Mobile, " accessed the egate gump."); e.Mobile.CloseGump(typeof(egategump)); e.Mobile.SendGump(new egategump()); }
public void DupeEntity() { if (!HasAccess(m_Entity.GetType())) { return; } if (m_Entity is Item) { Mobile rootparent = ((Item)m_Entity).RootParent as Mobile; if (rootparent != null && m_From.AccessLevel < rootparent.AccessLevel) { m_From.SendMessage("You cannot dupe what does not belong to you."); return; } } //Set saves off? m_EntityInfo = new Entity(m_Entity.Serial, m_Entity.Location, m_Entity.Map); m_Parent = m_Entity is Item ? ((Item)m_Entity).Parent : null; if (m_Entity is Mobile) { ((Mobile)m_Entity).Internalize(); } else if (m_Entity is Item) { ((Item)m_Entity).Internalize(); } m_Entities.Add(m_Entity); if (m_Entity is Mobile && !AddEntitiesFromList(((Mobile)m_Entity).Items)) { return; } if (m_Entity is Item && !AddEntitiesFromList(((Item)m_Entity).LookupItems())) { return; } else { m_DupeBag = new Bag(); m_DupeBag.Hue = 6; m_DupeBag.Name = "Duped on " + DateTime.Today.ToString("dd.MM.yyyy"); } IEntity entity = Dupe(); //Main duping method; returns null if error or failure. if (entity is Item) { if (m_DupeBag != null) { m_DupeBag.DropItem((Item)entity); m_DupeBag.UpdateTotals(); m_DupeBag.InvalidateProperties(); m_DupeBag.ProcessDelta(); } else { ((Item)entity).MoveToWorld(m_EntityInfo.Location, m_EntityInfo.Map); } } else if (entity is Mobile) { ((Mobile)entity).MoveToWorld(m_EntityInfo.Location, m_EntityInfo.Map); } if (m_Entity is Item) { Item origitem = m_Entity as Item; if (m_Parent != null) { if (m_Parent is Mobile) { ((Mobile)m_Parent).EquipItem(origitem); } else if (m_Parent is Container) { ((Container)m_Parent).DropItem(origitem); origitem.Location = m_EntityInfo.Location; origitem.ProcessDelta(); } } else { origitem.MoveToWorld(m_EntityInfo.Location, m_EntityInfo.Map); } } else if (m_Entity is Mobile) { ((Mobile)m_Entity).MoveToWorld(m_EntityInfo.Location, m_EntityInfo.Map); } m_From.AddToBackpack(m_DupeBag); if (m_NewEntities.Count > 0) { m_From.SendGump(new InterfaceGump(m_From, new string[] { "Entity" }, new ArrayList(m_NewEntities), 0, null)); StringBuilder sb = new StringBuilder(); sb.AppendFormat("{0} {1} duping ", m_From.AccessLevel, CommandLogging.Format(m_From)); sb.AppendFormat("at {0} in {1}: ", m_From.Location, m_From.Map); int serial = (m_Entity is Item ? ((Item)m_Entity).Serial : ((Mobile)m_Entity).Serial); sb.AppendFormat("{0} objects via target {1:X}", m_NewEntities.Count, serial); CommandLogging.WriteLine(m_From, sb.ToString()); sb = new StringBuilder(); StringBuilder sbm = new StringBuilder(); sb.Append("Serials been duped:"); sbm.Append("Serials:"); for (int i = 0; i < m_Entities.Count; i++) { sb.AppendFormat(" 0x{0:X};", m_Entities[i].Serial); sbm.AppendFormat(" 0x{0:X};", m_NewEntities[i].Serial); } CommandLogging.WriteLine(m_From, sb.ToString()); CommandLogging.WriteLine(m_From, sbm.ToString()); } m_From.SendMessage("Duping completed."); }
protected override void OnTarget(Mobile from, object targeted) { if (targeted is Mobile && m_type < 2) { Mobile targ = (Mobile)targeted; if (from != targ && from.AccessLevel > targ.AccessLevel) { CommandLogging.WriteLine(from, "{0} {1} forcing speech on {2}.", from.AccessLevel, CommandLogging.Format(from), CommandLogging.Format(targ)); if (m_toSay.StartsWith(CommandSystem.Prefix)) { targ.SendMessage("{0} makes you invoke {1}.", from.Name, m_toSay); CommandSystem.Handle(targ, String.Format("{0}{1}", CommandSystem.Prefix, m_toSay.Substring(1))); } else { if (targ.Player) { PlayerMobile pm = (PlayerMobile)targ; DoSpeech(pm, m_toSay); } else { targ.Say(m_toSay); } } } else if (from == targ) { from.SendMessage("You don't need this command to make yourself say something!"); } else if (from.AccessLevel <= targ.AccessLevel) { from.SendMessage("You cannot do that."); } } else if (targeted is Item && m_type != 1) { Item targ = (Item)targeted; object root = targ.RootParent; if (root == null) { targ.PublicOverheadMessage(MessageType.Regular, (SpeechHueOverride < 0 ? Utility.RandomDyedHue() : SpeechHueOverride), false, m_toSay); } else if (root is Mobile) { if (from != (root) && from.AccessLevel > ((Mobile)root).AccessLevel) { CommandLogging.WriteLine(from, "{0} {1} forcing speech on {2}.", from.AccessLevel, CommandLogging.Format(from), CommandLogging.Format((root))); if (m_toSay.StartsWith(CommandSystem.Prefix)) { ((Mobile)root).SendMessage("{0} makes you invoke {1}.", from.Name, m_toSay); CommandSystem.Handle(((Mobile)root), String.Format("{0}{1}", CommandSystem.Prefix, m_toSay.Substring(1))); } else { ((Mobile)root).Say(m_toSay); } } else if (from == (root)) { from.SendMessage("You don't need this command to make yourself say something!"); } else if (from.AccessLevel <= ((Mobile)root).AccessLevel) { from.SendMessage("You cannot do that."); } } else if (root is Item) { targ.PublicOverheadMessage(MessageType.Regular, (SpeechHueOverride < 0 ? Utility.RandomDyedHue() : SpeechHueOverride), false, m_toSay); } } else if (targeted is StaticTarget && m_type != 1) { StaticOverhead s = new StaticOverhead(); s.MoveToWorld(((StaticTarget)targeted).Location, from.Map); s.PublicOverheadMessage(MessageType.Regular, (SpeechHueOverride < 0 ? Utility.RandomDyedHue() : SpeechHueOverride), false, m_toSay); } else { from.SendMessage("Invaild Target Type"); } }
protected override void OnTarget(Mobile from, object targeted) { if (targeted is Mobile) { Mobile targ = (Mobile)targeted; if (from != targ) { from.SendMessage("You may only set your own body to GM style."); } else { m_Mobile = from; CommandLogging.WriteLine(from, "{0} {1} is assuming a GM body", from.AccessLevel, CommandLogging.Format(from)); string prefix = Server.Commands.CommandSystem.Prefix; CommandSystem.Handle(from, String.Format("{0}AutoSpeedBooster true", prefix)); Container pack = from.Backpack; List <Item> ItemsToDelete = new List <Item>(); foreach (Item item in from.Items) { if (item.Layer != Layer.Bank && item.Layer != Layer.Hair && item.Layer != Layer.FacialHair && item.Layer != Layer.Mount && item.Layer != Layer.Backpack) { ItemsToDelete.Add(item); } } foreach (Item item in ItemsToDelete) { item.Delete(); } if (pack == null) { pack = new Backpack(); pack.Movable = false; from.AddItem(pack); } else { pack.Delete(); pack = new Backpack(); pack.Movable = false; from.AddItem(pack); } from.Hunger = 20; from.Thirst = 20; from.Fame = 0; from.Karma = 0; from.Kills = 0; from.Hidden = true; from.Blessed = true; from.Hits = from.HitsMax; from.Mana = from.ManaMax; from.Stam = from.StamMax; if (from.AccessLevel >= AccessLevel.Counselor) { EquipItem(new StaffRing()); Spellbook book1 = new Spellbook((ulong)18446744073709551615); Spellbook book2 = new NecromancerSpellbook((ulong)0xffff); Spellbook book3 = new BookOfChivalry(); Spellbook book4 = new BookOfBushido(); Spellbook book5 = new BookOfNinjitsu(); PackItem(book1); PackItem(book2); PackItem(book3); PackItem(book4); PackItem(book5); from.RawStr = 100; from.RawDex = 100; from.RawInt = 100; from.Hits = from.HitsMax; from.Mana = from.ManaMax; from.Stam = from.StamMax; for (int i = 0; i < targ.Skills.Length; ++i) { targ.Skills[i].Base = 120; } } if (from.AccessLevel == AccessLevel.Counselor) { EquipItem(new CounselorRobe()); EquipItem(new ThighBoots(3)); from.Title = "[Counselor]"; } if (from.AccessLevel == AccessLevel.GameMaster) { EquipItem(new GMRobe()); EquipItem(new ThighBoots(39)); from.Title = "[GM]"; } if (from.AccessLevel == AccessLevel.Seer) { EquipItem(new SeerRobe()); EquipItem(new ThighBoots(467)); from.Title = "[Seer]"; } if (from.AccessLevel >= AccessLevel.Administrator) { PackItem(new StaffCloak()); EquipItem(new ThighBoots(1001)); EquipItem(new AdminRobe()); } if (from.AccessLevel == AccessLevel.Administrator) { from.Title = "[Admin]"; } if (from.AccessLevel == AccessLevel.Developer) { from.Title = "[Developer]"; } if (from.AccessLevel == AccessLevel.Owner) { from.Title = "[Owner]"; } } } }
public EquipMenu(Mobile from, Mobile m, ItemListEntry[] entries) : base("Equipment", entries) { m_Mobile = m; CommandLogging.WriteLine(from, "{0} {1} viewing equipment of {2}", from.AccessLevel, CommandLogging.Format(from), CommandLogging.Format(m)); }
public static void Invoke(Mobile from, Point3D start, Point3D end, string[] args, List <Container> packs, bool outline, bool mapAvg) { StringBuilder sb = new StringBuilder(); sb.AppendFormat("{0} {1} building ", from.AccessLevel, CommandLogging.Format(from)); if (start == end) { sb.AppendFormat("at {0} in {1}", start, from.Map); } else { sb.AppendFormat("from {0} to {1} in {2}", start, end, from.Map); } sb.Append(":"); for (int i = 0; i < args.Length; ++i) { sb.AppendFormat(" \"{0}\"", args[i]); } CommandLogging.WriteLine(from, sb.ToString()); string name = args[0]; FixArgs(ref args); string[,] props = null; for (int i = 0; i < args.Length; ++i) { if (Insensitive.Equals(args[i], "set")) { int remains = args.Length - i - 1; if (remains >= 2) { props = new string[remains / 2, 2]; remains /= 2; for (int j = 0; j < remains; ++j) { props[j, 0] = args[i + (j * 2) + 1]; props[j, 1] = args[i + (j * 2) + 2]; } FixSetString(ref args, i); } break; } } Type type = ScriptCompiler.FindTypeByName(name); if (!IsEntity(type)) { from.SendMessage("No type with that name was found."); return; } DateTime time = DateTime.UtcNow; int built = BuildObjects(from, type, start, end, args, props, packs, outline, mapAvg); if (built > 0) { from.SendMessage("{0} object{1} generated in {2:F1} seconds.", built, built != 1 ? "s" : "", (DateTime.UtcNow - time).TotalSeconds); } else { SendUsage(type, from); } }
public override void OnResponse(NetState sender, RelayInfo info) { if (m_Item.Deleted) { m_From.SendGump(new InterfaceGump(m_From, m_List, m_Page)); return; } else if (!BaseCommand.IsAccessible(m_From, m_Item)) { m_From.SendMessage("That is no longer accessible."); m_From.SendGump(new InterfaceGump(m_From, m_List, m_Page)); return; } switch (info.ButtonID) { case 0: case 1: { m_From.SendGump(new InterfaceGump(m_From, m_List, m_Page)); break; } case 2: // Properties { m_From.SendGump(new InterfaceItemGump(m_From, m_List, m_Page, m_Item)); m_From.SendGump(new PropertiesGump(m_From, m_Item)); break; } case 3: // Delete { CommandLogging.WriteLine(m_From, "{0} {1} deleting {2}", m_From.AccessLevel, CommandLogging.Format(m_From), CommandLogging.Format(m_Item)); m_Item.Delete(); m_From.SendGump(new InterfaceGump(m_From, m_List, m_Page)); break; } case 4: // Go there { m_From.SendGump(new InterfaceItemGump(m_From, m_List, m_Page, m_Item)); InvokeCommand(String.Format("Go {0}", m_Item.Serial.Value)); break; } case 5: // Move to target { m_From.SendGump(new InterfaceItemGump(m_From, m_List, m_Page, m_Item)); m_From.Target = new MoveTarget(m_Item); break; } case 6: // Bring to pack { Mobile owner = m_Item.RootParent as Mobile; if (owner != null && (owner.Map != null && owner.Map != Map.Internal) && !m_From.CanSee(owner)) { m_From.SendMessage("You can not get what you can not see."); } else if (owner != null && (owner.Map == null || owner.Map == Map.Internal) && owner.Hidden && owner.AccessLevel >= m_From.AccessLevel) { m_From.SendMessage("You can not get what you can not see."); } else { m_From.SendGump(new InterfaceItemGump(m_From, m_List, m_Page, m_Item)); m_From.AddToBackpack(m_Item); } break; } } }