internal bool UpdateContainer() { if (!(m_Parent is Serial) || Deleted) { return(true); } object o = null; Serial contSer = (Serial)m_Parent; if (contSer.IsItem) { o = World.FindItem(contSer); } else if (contSer.IsMobile) { o = World.FindMobile(contSer); } if (o == null) { return(false); } m_Parent = o; if (m_Parent is Item) { ((Item)m_Parent).AddItem(this); } else if (m_Parent is Mobile) { ((Mobile)m_Parent).AddItem(this); } if (World.Player != null && (IsChildOf(World.Player.Backpack) || IsChildOf(World.Player.Quiver))) { if (m_IsNew) { if (m_AutoStack) { AutoStackResource(); } if (RazorEnhanced.Settings.General.ReadBool("AutoSearch") && IsContainer && !(IsSearchable && RazorEnhanced.Settings.General.ReadBool("NoSearchPouches")) && !this.IsBagOfSending ) { PacketHandlers.IgnoreGumps.Add(this); PlayerData.DoubleClick(this); for (int c = 0; c < Contains.Count; c++) { Item icheck = (Item)Contains[c]; if (icheck.IsContainer) { if (icheck.IsSearchable && RazorEnhanced.Settings.General.ReadBool("NoSearchPouches")) { continue; } if (icheck.IsBagOfSending) { continue; } PacketHandlers.IgnoreGumps.Add(icheck); PlayerData.DoubleClick(icheck); } } } } } m_AutoStack = m_IsNew = false; return(true); }
/// <summary> /// Handles the common Next/Prev logic based on a list of targets passed in already filtered by the calling /// functions conditions. /// </summary> /// <param name="targets">The list of targets (already filtered)</param> /// <param name="nextTarget">next target true, previous target false</param> /// <param name="isFriend">Indicates this was the Next/Prev Friend hot key</param> /// <param name="isFriendly"></param> /// <param name="isNonFriendly"></param> public static void NextPrevTarget(List <Mobile> targets, bool nextTarget, bool isFriend = false, bool isFriendly = false, bool isNonFriendly = false) { if (targets.Count <= 0) { World.Player.SendMessage(MsgLevel.Warning, LocString.TargNoOne); return; } Mobile mobile = null, old = World.FindMobile(m_LastTarget?.Serial ?? Serial.Zero); var target = new TargetInfo(); // Loop through 3 times and break out if you can't get a target for some reason for (var i = 0; i < 3; i++) { if (nextTarget) { _nextPrevTargetIndex++; if (_nextPrevTargetIndex >= targets.Count) { _nextPrevTargetIndex = 0; } } else { _nextPrevTargetIndex--; if (_nextPrevTargetIndex < 0) { _nextPrevTargetIndex = targets.Count - 1; } } try { mobile = targets[_nextPrevTargetIndex]; } catch { mobile = null; } if (mobile != null && mobile != World.Player && mobile != old) { break; } mobile = null; } if (mobile == null) { mobile = old; } if (mobile == null) { World.Player.SendMessage(MsgLevel.Warning, LocString.TargNoOne); return; } m_LastGroundTarg = m_LastTarget = target; if (IsSmartTargetingEnabled()) { if ((Config.GetBool("OnlyNextPrevBeneficial") && isFriend) || (Config.GetBool("FriendlyBeneficialOnly") && isFriendly)) { m_LastBeneTarg = target; } else if ((Config.GetBool("OnlyNextPrevBeneficial") && !isFriend) || (Config.GetBool("NonFriendlyHarmfulOnly") && isNonFriendly)) { m_LastHarmTarg = target; } else { m_LastBeneTarg = m_LastHarmTarg = target; } } else { m_LastBeneTarg = m_LastHarmTarg = target; } if (m_HasTarget) { target.Flags = m_CurFlags; } else { target.Type = 0; } target.Gfx = mobile.Body; target.Serial = mobile.Serial; target.X = mobile.Position.X; target.Y = mobile.Position.Y; target.Z = mobile.Position.Z; if (!isFriend || Config.GetBool("HighlightFriend")) { Client.Instance.SendToClient(new ChangeCombatant(mobile)); m_LastCombatant = mobile.Serial; } World.Player.SendMessage(MsgLevel.Force, LocString.NewTargSet); OverheadTargetMessage(target); ScriptManager.TargetFound = true; }
public static bool DoLastTarget() { if (FromGrabHotKey) { return(true); } TargetInfo targ; if (IsSmartTargetingEnabled()) { if (m_AllowGround && m_LastGroundTarg != null) { targ = m_LastGroundTarg; } else if (m_CurFlags == 1) { targ = m_LastHarmTarg; } else if (m_CurFlags == 2) { targ = m_LastBeneTarg; } else { targ = m_LastTarget; } if (targ == null) { targ = m_LastTarget; } } else { if (m_AllowGround && m_LastGroundTarg != null) { targ = m_LastGroundTarg; } else { targ = m_LastTarget; } } if (targ == null) { return(false); } Point3D pos = Point3D.Zero; if (targ.Serial.IsMobile) { Mobile m = World.FindMobile(targ.Serial); if (m != null) { pos = m.Position; targ.X = pos.X; targ.Y = pos.Y; targ.Z = pos.Z; } else { pos = Point3D.Zero; } } else if (targ.Serial.IsItem) { Item i = World.FindItem(targ.Serial); if (i != null) { pos = i.GetWorldPosition(); targ.X = i.Position.X; targ.Y = i.Position.Y; targ.Z = i.Position.Z; } else { pos = Point3D.Zero; targ.X = targ.Y = targ.Z = 0; } } else { if (!m_AllowGround && (targ.Serial == Serial.Zero || targ.Serial >= 0x80000000)) { World.Player.SendMessage(MsgLevel.Warning, LocString.LTGround); return(false); } else { pos = new Point3D(targ.X, targ.Y, targ.Z); } } if (Config.GetBool("RangeCheckLT") && Client.Instance.AllowBit(FeatureBit.RangeCheckLT) && (pos == Point3D.Zero || !Utility.InRange(World.Player.Position, pos, Config.GetInt("LTRange")))) { if (Config.GetBool("QueueTargets")) { m_QueueTarget = LastTargetAction; } World.Player.SendMessage(MsgLevel.Warning, LocString.LTOutOfRange); return(false); } if (CheckHealPoisonTarg(m_CurrentID, targ.Serial)) { return(false); } CancelClientTarget(); m_HasTarget = false; targ.TargID = m_CurrentID; if (m_Intercept) { OneTimeResponse(targ); } else { Client.Instance.SendToServer(new TargetResponse(targ)); } return(true); }
public bool UpdateContainer() { if (!(m_Parent is Serial) || Deleted) { return(true); } object o = null; Serial contSer = (Serial)m_Parent; if (contSer.IsItem) { o = World.FindItem(contSer); } else if (contSer.IsMobile) { o = World.FindMobile(contSer); } if (o == null) { return(false); } m_Parent = o; if (m_Parent is Item) { ((Item)m_Parent).AddItem(this); } else if (m_Parent is Mobile) { ((Mobile)m_Parent).AddItem(this); } if (World.Player != null && (IsChildOf(World.Player.Backpack) || IsChildOf(World.Player.Quiver))) { bool exempt = SearchExemptionAgent.IsExempt(this); if (!exempt) { Counter.Count(this); } if (m_IsNew) { if (m_AutoStack) { AutoStackResource(); } if (IsContainer && !exempt && (!IsPouch || !Config.GetBool("NoSearchPouches")) && Config.GetBool("AutoSearch")) { PacketHandlers.IgnoreGumps.Add(this); PlayerData.DoubleClick(this); for (int c = 0; c < Contains.Count; c++) { Item icheck = (Item)Contains[c]; if (icheck.IsContainer && !SearchExemptionAgent.IsExempt(icheck) && (!icheck.IsPouch || !Config.GetBool("NoSearchPouches"))) { PacketHandlers.IgnoreGumps.Add(icheck); PlayerData.DoubleClick(icheck); } } } } } m_AutoStack = m_IsNew = false; return(true); }
public static bool ClientPacket(Packet p) { if (Playing) { if (p == null || World.Player == null) { return(false); } switch (p.PacketID) { case 0x02: // Movement Req { Direction dir = (Direction)p.ReadByte(); byte seq = p.ReadByte(); ClientCommunication.ForceSendToClient(new MoveReject(seq, World.Player)); World.Player.Resync(); break; } case 0x06: // Double Click { Serial s = p.ReadUInt32(); Mobile m; if ((s.Value & 0x80000000) != 0 || s == World.Player.Serial) { m = World.Player; } else { m = World.FindMobile(s); } if (m != null) { string name = m.Name; if (name == null || name == "") { name = "<No Data>"; } ClientCommunication.ForceSendToClient(new DisplayPaperdoll(m, name)); } break; } case 0x07: // Lift Req { ClientCommunication.ForceSendToClient(new LiftRej(5)); //inspecific break; } case 0x09: // single click { Serial s = p.ReadUInt32(); if (s.IsMobile) { Mobile m = World.FindMobile(s); if (m != null && m.Name != null && m.Name != "") { int hue; switch (m.Notoriety) { case 1: hue = 0x059; break; case 2: hue = 0x03F; break; case 3: case 4: hue = 0x3B2; break; case 5: hue = 0x090; break; case 6: hue = 0x022; break; case 7: hue = 0x035; break; default: hue = 0x481; break; } ClientCommunication.ForceSendToClient(new UnicodeMessage(s, m.Body, MessageType.Label, hue, 3, "ENU", "", m.Name)); } } else if (s.IsItem) { Item i = World.FindItem(s); if (i != null && i.Name != null && i.Name != "") { ClientCommunication.ForceSendToClient(new UnicodeMessage(s, i.ItemID, MessageType.Label, 0x3B2, 3, "ENU", "", i.Name)); } } break; } case 0x34: // Mobile Info Query { p.ReadInt32(); // 0xEDEDEDED int type = p.ReadByte(); Mobile m = World.FindMobile(p.ReadUInt32()); if (m == null) { break; } switch (type) { case 0x04: // Stats { if (m == World.Player) { ClientCommunication.ForceSendToClient(new MobileStatusExtended(World.Player)); ClientCommunication.ForceSendToClient(new StatLockInfo(World.Player)); } else { if (m.Hits == 0 && (m.HitsMax == 0 || m.HitsMax == 1)) { m.HitsMax = 1; if (m.Name == null || m.Name == "") { m.Name = "<No Data>"; } } else if (m.Name == null || m.Name == "" || m.Name == "<No Data>") { m.Name = "<No Name>"; } ClientCommunication.ForceSendToClient(new MobileStatusCompact(m)); } break; } case 0x05: { ClientCommunication.ForceSendToClient(new SkillsList()); break; } } break; } case 0x6C: // target { p.ReadByte(); // type uint tid = p.ReadUInt32(); p.ReadByte(); // flags Serial s = p.ReadUInt32(); if (tid == Targeting.LocalTargID) { ClientCommunication.ForceSendToClient(new UnicodeMessage(0xFFFFFFFF, -1, MessageType.Regular, 0x25, 3, Language.CliLocName, "System", String.Format("Serial Number is {0}", s))); } break; } case 0xAD: // speech { p.MoveToData(); Command.OnSpeech(p, new PacketHandlerEventArgs()); break; } case 0xBF: // Extended Packet { ushort subType = p.ReadUInt16(); switch (subType) { case 0x1E: // QueryDesignDetails (custom house) { Item i = World.FindItem(p.ReadUInt32()); if (i != null && i.HousePacket != null) { ClientCommunication.ForceSendToClient(new Packet(i.HousePacket, i.HousePacket.Length, true)); } break; } } break; } } return(false); } else if (m_Recording) { if (p == null) { return(true); } switch (p.PacketID) { case 0xB1: // gump response p.ReadInt32(); // skip serial WritePacket(new CloseGump(p.ReadUInt32())); break; } return(true); } else { return(true); } }
public static bool ServerPacket(Packet p) { if (Playing) { return(false); // dont allow the client to recv server packets. } else if (m_Recording && p != null) { if (World.Player == null) { Stop(); return(true); } switch (p.PacketID) { case 0x21: // Movement Reject case 0x27: // Lift Reject case 0x6C: // Target case 0x7C: // Menu case 0x88: // Display paper doll case 0xB2: // Chat Message case 0xBA: // Quest Arrow return(true); case 0x22: // Movement Ack { // replace movement ack with a force walk byte seq = p.ReadByte(); if (World.Player.HasWalkEntry(seq)) { WritePacket(new ForceWalk(World.Player.GetMoveEntry(seq).Dir & Direction.Mask)); //WritePacket( new MobileUpdate( World.Player ) ); } return(true); } case 0xBF: { short type = p.ReadInt16(); switch (type) { case 0x06: // party stuff { byte subType = p.ReadByte(); if (subType == 0x03 || subType == 0x04) { Mobile from = World.FindMobile(p.ReadUInt32()); string msg = p.ReadUnicodeStringSafe(); string send = String.Format("[{0}]: {1}", from != null && from.Name != null && from.Name.Length > 0 ? from.Name : "Party", msg); WritePacket(new UnicodeMessage(Serial.MinusOne, 0, MessageType.System, 0x3b2, 3, "ENU", "Party", send)); } return(true); } case 0x1D: // House Revision info { Item i = World.FindItem(p.ReadUInt32()); if (i != null) { i.HouseRevision = p.ReadInt32(); if (!m_HouseDataWritten.Contains(i.Serial)) { if (i.HousePacket == null) { i.MakeHousePacket(); } if (i.HousePacket != null) { m_HouseDataWritten.Add(i.Serial); // WritePacket( p ); WritePacket(new Packet(i.HousePacket, i.HousePacket.Length, true)); return(true); } } } break; } } break; } case 0xD8: // Custom House data { p.ReadByte(); // Compression p.ReadByte(); // Unknown Serial s = p.ReadUInt32(); m_HouseDataWritten.Add(s); break; } } WritePacket(p); return(true); } else { return(true); } }