public static void PrivateOverheadMessage(this Item item, MessageType type, int hue, bool ascii, string text, NetState state) { if (item.Map != null && state != null) { Point3D worldLoc = item.GetWorldLocation(); Mobile m = state.Mobile; if (m != null && m.CanSee(item) && m.InRange(worldLoc, item.GetUpdateRange(m))) { if (ascii) { state.Send(new AsciiMessage(item.Serial, item.ItemID, type, hue, 3, item.Name, text)); } else { state.Send(new UnicodeMessage(item.Serial, item.ItemID, type, hue, 3, m.Language, item.Name, text)); } } } }
public static void PrivateOverheadMessage(this Item item, MessageType type, int hue, int number, NetState state, string args = "") { if (item.Map != null && state != null) { Packet p = null; Point3D worldLoc = item.GetWorldLocation(); Mobile m = state.Mobile; if (m != null && m.CanSee(item) && m.InRange(worldLoc, item.GetUpdateRange(m))) { if (p == null) { p = Packet.Acquire(new MessageLocalized(item.Serial, item.ItemID, type, hue, 3, number, item.Name, args)); } state.Send(p); } Packet.Release(p); } }
public void NotifyLocationChangeOnSmooth(Mobile mobile, Point3D oldLocation) { Map map = mobile.Map; Point3D newLocation = mobile.Location; if (map != null) { // First, send a remove message to everyone who can no longer see us. (inOldRange && !inNewRange) Packet removeThis = null; IPooledEnumerable eable = map.GetClientsInRange(oldLocation); foreach (NetState ns in eable) { if (ns != mobile.NetState && !Utility.InUpdateRange(newLocation, ns.Mobile.Location)) { if (removeThis == null) { removeThis = mobile.RemovePacket; } ns.Send(removeThis); } } eable.Free(); NetState ourState = mobile.NetState; // Check to see if we are attached to a client if (ourState != null) { eable = mobile.Map.GetObjectsInRange(newLocation, Core.GlobalMaxUpdateRange); // We are attached to a client, so it's a bit more complex. We need to send new items and people to ourself, and ourself to other clients foreach (object o in eable) { if (o is Item) { Item item = (Item)o; if (item.NoMoveHS) { continue; } int range = item.GetUpdateRange(mobile); Point3D loc = item.Location; if (/*!Utility.InRange(oldLocation, loc, range) && */ Utility.InRange(newLocation, loc, range) && mobile.CanSee(item)) { item.SendInfoTo(ourState); } } else if (o != mobile && o is Mobile) { Mobile m = (Mobile)o; if (m.NoMoveHS) { continue; } if (!Utility.InUpdateRange(newLocation, m.Location)) { continue; } bool inOldRange = Utility.InUpdateRange(oldLocation, m.Location); if (!inOldRange && m.NetState != null && m.CanSee(mobile)) { m.NetState.Send(new MobileIncoming(m, mobile)); if (mobile.Poison != null) { m.NetState.Send(new HealthbarPoison(mobile)); } if (mobile.Blessed || mobile.YellowHealthbar) { m.NetState.Send(new HealthbarYellow(mobile)); } if (mobile.IsDeadBondedPet) { m.NetState.Send(new BondedStatus(0, mobile.Serial, 1)); } if (ObjectPropertyList.Enabled) { m.NetState.Send(m.OPLPacket); } } if (!inOldRange && mobile.CanSee(m)) { ourState.Send(new MobileIncoming(mobile, m)); if (m.Poisoned) { ourState.Send(new HealthbarPoison(m)); } if (m.Blessed || m.YellowHealthbar) { ourState.Send(new HealthbarYellow(m)); } if (m.IsDeadBondedPet) { ourState.Send(new BondedStatus(0, mobile.Serial, 1)); } if (ObjectPropertyList.Enabled) { ourState.Send(m.OPLPacket); } } } } eable.Free(); } else { if (mobile == null) { return; } eable = mobile.Map.GetClientsInRange(newLocation); // We're not attached to a client, so simply send an Incoming foreach (NetState ns in eable) { if (mobile.NoMoveHS) { continue; } if (Utility.InUpdateRange(oldLocation, ns.Mobile.Location) && ns.Mobile.CanSee(mobile)) { if (ns.StygianAbyss) { ns.Send(new MobileIncoming(ns.Mobile, mobile)); if (mobile.Poison != null) { ns.Send(new HealthbarPoison(mobile)); } if (mobile.Blessed || mobile.YellowHealthbar) { ns.Send(new HealthbarYellow(mobile)); } } else { ns.Send(new MobileIncomingOld(ns.Mobile, mobile)); } if (mobile.IsDeadBondedPet) { ns.Send(new BondedStatus(0, mobile.Serial, 1)); } if (ObjectPropertyList.Enabled) { ns.Send(mobile.OPLPacket); } } } eable.Free(); } } }