public void WillGetDiffHits() { _player.Hits = 90; _player.HitsMax = 100; Assert.AreEqual(10, MobileCommands.DiffHits(_player.Serial)); }
public void WillGetHiddenNoParam() { _player.Status |= MobileStatus.Hidden; _player.Status |= MobileStatus.Female; bool hidden = MobileCommands.Hidden(); Assert.IsTrue(hidden); }
public Mobile GetClosestMobile(IEnumerable <Notoriety> notoriety, TargetBodyType bodyType = TargetBodyType.Any, TargetFriendType friendType = TargetFriendType.Include, TargetInfliction inflictionType = TargetInfliction.Any) { Mobile mobile; Func <int, bool> bodyTypePredicate; switch (bodyType) { case TargetBodyType.Any: bodyTypePredicate = i => true; break; case TargetBodyType.Humanoid: bodyTypePredicate = i => _bodyData.Where(bd => bd.BodyType == TargetBodyType.Humanoid).Select(bd => bd.Graphic) .Contains(i); break; case TargetBodyType.Transformation: bodyTypePredicate = i => _bodyData.Where(bd => bd.BodyType == TargetBodyType.Transformation).Select(bd => bd.Graphic) .Contains(i); break; case TargetBodyType.Both: bodyTypePredicate = i => _bodyData.Where(bd => bd.BodyType == TargetBodyType.Humanoid || bd.BodyType == TargetBodyType.Transformation) .Select(bd => bd.Graphic).Contains(i); break; default: throw new ArgumentOutOfRangeException(nameof(bodyType), bodyType, null); } if (friendType == TargetFriendType.Only) { mobile = Engine.Mobiles .SelectEntities(m => MobileCommands.InFriendList(m.Serial) && bodyTypePredicate(m.ID) && (!Options.CurrentOptions.GetFriendEnemyUsesIgnoreList || !ObjectCommands.IgnoreList.Contains(m.Serial))) .OrderBy(m => m.Distance).ByInflication(inflictionType).FirstOrDefault(); } else { mobile = Engine.Mobiles.SelectEntities(m => notoriety.Contains(m.Notoriety) && m.Distance < MAX_DISTANCE && bodyTypePredicate(m.ID) && (friendType == TargetFriendType.Include || !MobileCommands.InFriendList(m.Serial)) && (!Options.CurrentOptions.GetFriendEnemyUsesIgnoreList || !ObjectCommands.IgnoreList.Contains(m.Serial))).OrderBy(m => m.Distance) .ByInflication(inflictionType)?.FirstOrDefault(); } return(mobile); }
public void WillGetHitsNoParam() { _player.Hits = 100; int val = MobileCommands.Hits(); Assert.AreEqual(100, val); _player.Hits = 0; }
public void WillGetDead() { Assert.IsFalse(MobileCommands.Dead()); _player.ID = 0x192; Assert.IsTrue(MobileCommands.Dead()); _player.ID = 0x190; }
public void WillGetStats() { _player.Strength = 100; _player.Int = 90; _player.Dex = 25; Assert.AreEqual(100, MobileCommands.Str()); Assert.AreEqual(90, MobileCommands.Int()); Assert.AreEqual(25, MobileCommands.Dex()); }
private static bool OnAddFriend(string[] args) { if (args.Length != 0) { return(false); } Task.Run(() => MobileCommands.AddFriend()); return(true); }
public void WillGetDeadParam() { Mobile m = new Mobile(2); Engine.Mobiles.Add(m); Assert.IsFalse(MobileCommands.Dead(2)); m.ID = 0x192; Assert.IsTrue(MobileCommands.Dead(2)); Engine.Mobiles.Remove(m); }
public void WillGetHitsSerialParam() { Mobile mobile = new Mobile(2) { Hits = 200 }; Engine.Mobiles.Add(mobile); int val = MobileCommands.Hits(mobile.Serial); Assert.AreEqual(200, val); Engine.Mobiles.Remove(mobile); }
public Target(TargetType targetType, int senderSerial, TargetFlags flags, int targetSerial, int x, int y, int z, int id, bool cancelClientCursor) { if (senderSerial == -1) { senderSerial = Engine.TargetSerial; } if (targetSerial > 0) { Engine.Player.LastTargetSerial = targetSerial; Engine.Player.LastTargetType = targetType; } if (Engine.TargetFlags == TargetFlags.Harmful && Options.CurrentOptions.PreventTargetingFriendsWithHarmful && MobileCommands.InFriendList(targetSerial)) { Commands.SystemMessage(Strings.Target_blocked____try_again___); Commands.ResendTargetToClient(); return; } _writer = new PacketWriter(19); _writer.Write((byte)0x6C); _writer.Write((byte)targetType); _writer.Write(senderSerial); _writer.Write((byte)flags); _writer.Write(targetSerial); _writer.Write((short)x); _writer.Write((short)y); _writer.Write((short)z); _writer.Write((short)id); Engine.TargetExists = false; if (cancelClientCursor) { Engine.SendPacketToClient(new Target(targetType, senderSerial, TargetFlags.Cancel, targetSerial, x, y, z, id, false)); Engine.AddSendPreFilter(new PacketFilterInfo(0x6C, new[] { PacketFilterConditions.IntAtPositionCondition(senderSerial, 2) }, (p, pfi) => { Engine.RemoveSendPreFilter(pfi); })); } }
public void WillGetHitsStringParam() { Mobile mobile = new Mobile(2) { Hits = 250 }; Engine.Mobiles.Add(mobile); AliasCommands.SetAlias("mobile", mobile.Serial); int val = MobileCommands.Hits("mobile"); Assert.AreEqual(250, val); Engine.Mobiles.Remove(mobile); }
private static void OnTargetSent(PacketReader reader) { if (Engine.Player == null) { return; } TargetType targetType = (TargetType)reader.ReadByte(); Engine.Player.LastTargetType = targetType; int senderSerial = reader.ReadInt32(); // sender serial int flags = reader.ReadByte(); int serial = reader.ReadInt32(); int x = reader.ReadInt16(); int y = reader.ReadInt16(); int z = reader.ReadInt16(); int id = reader.ReadInt16(); if (targetType == TargetType.Object && flags != 0x03 && serial != 0) { Engine.Player.LastTargetSerial = serial; Engine.Player.LastTargetType = targetType; switch ((TargetFlags)flags) { case TargetFlags.Harmful when Engine.Mobiles.GetMobile(serial, out Mobile enemyMobile) && AliasCommands.GetAlias("enemy") != serial: TargetManager.GetInstance().SetEnemy(enemyMobile); break; case TargetFlags.Beneficial when Engine.Mobiles.GetMobile(serial, out Mobile friendMobile) && MobileCommands.InFriendList(serial) && AliasCommands.GetAlias("friend") != serial: TargetManager.GetInstance().SetFriend(friendMobile); break; } } Engine.TargetExists = false; TargetSentEvent?.Invoke(targetType, senderSerial, flags, serial, x, y, z, id); }
public void WillGetMountedParam() { Item mount = new Item(2); Engine.Items.Add(mount); AliasCommands.SetAlias("self", 1); AliasCommands.SetAlias("mount", 2); Assert.IsFalse(MobileCommands.Mounted("self")); _player.SetLayer(Layer.Mount, 2); Assert.IsTrue(MobileCommands.Mounted("self")); Engine.Items.Remove(mount); _player.SetLayer(Layer.Mount, 0); }
public override void Execute() { MobileCommands.AddFriend(); }
private static void OnPartyCommand(PacketReader reader) { int command = reader.ReadByte(); switch (command) { case 1: { int count = reader.ReadByte(); List <int> partyMembers = new List <int>(); for (int i = 0; i < count; i++) { int serial = reader.ReadInt32(); partyMembers.Add(serial); } if (Engine.Player == null) { return; } Engine.Player.Party = partyMembers.ToArray(); break; } case 2: { int count = reader.ReadByte(); reader.ReadInt32(); // removed member serial List <int> partyMembers = new List <int>(); for (int i = 0; i < count; i++) { int serial = reader.ReadInt32(); partyMembers.Add(serial); } if (Engine.Player == null) { return; } Engine.Player.Party = partyMembers.ToArray(); break; } case 7: { int leaderSerial = reader.ReadInt32(); if (Options.CurrentOptions.AutoAcceptPartyInvite) { if (!Options.CurrentOptions.AutoAcceptPartyOnlyFromFriends || Options.CurrentOptions.AutoAcceptPartyOnlyFromFriends && MobileCommands.InFriendList(leaderSerial)) { Engine.SendPacketToServer(new AcceptPartyInvitation(leaderSerial)); } } break; } } }
public void WillGetHits() { _player.Hits = 100; Assert.AreEqual(100, MobileCommands.Hits(_player.Serial)); }
public Mobile GetNextMobile(IEnumerable <Notoriety> notoriety, TargetBodyType bodyType = TargetBodyType.Any, int distance = MAX_DISTANCE, TargetFriendType friendType = TargetFriendType.Include, TargetInfliction inflictionType = TargetInfliction.Any, bool reverse = false) { bool looped = false; while (true) { Mobile[] mobiles; Func <int, bool> bodyTypePredicate; switch (bodyType) { case TargetBodyType.Any: bodyTypePredicate = i => true; break; case TargetBodyType.Humanoid: bodyTypePredicate = i => _bodyData.Where(bd => bd.BodyType == TargetBodyType.Humanoid).Select(bd => bd.Graphic) .Contains(i); break; case TargetBodyType.Transformation: bodyTypePredicate = i => _bodyData.Where(bd => bd.BodyType == TargetBodyType.Transformation) .Select(bd => bd.Graphic).Contains(i); break; case TargetBodyType.Both: bodyTypePredicate = i => _bodyData.Where(bd => bd.BodyType == TargetBodyType.Humanoid || bd.BodyType == TargetBodyType.Transformation) .Select(bd => bd.Graphic).Contains(i); break; default: throw new ArgumentOutOfRangeException(nameof(bodyType), bodyType, null); } if (friendType == TargetFriendType.Only) { //Notoriety, bodyType ignored mobiles = Engine.Mobiles.SelectEntities(m => m.Distance < distance && MobileCommands.InFriendList(m.Serial) && bodyTypePredicate(m.ID) && !_ignoreList.Contains(m) && (!Options.CurrentOptions.GetFriendEnemyUsesIgnoreList || !ObjectCommands.IgnoreList.Contains(m.Serial))); } else { mobiles = Engine.Mobiles.SelectEntities(m => notoriety.Contains(m.Notoriety) && m.Distance < distance && bodyTypePredicate(m.ID) && !_ignoreList.Contains(m) && (friendType == TargetFriendType.Include || !MobileCommands.InFriendList(m.Serial)) && (!Options.CurrentOptions.GetFriendEnemyUsesIgnoreList || !ObjectCommands.IgnoreList.Contains(m.Serial))); } if (reverse) { mobiles = mobiles.Reverse().ToArray(); } mobiles = mobiles.ByInflication(inflictionType); if (mobiles == null || mobiles.Length == 0) { _ignoreList.Clear(); if (looped) { return(null); } looped = true; continue; } Mobile mobile = mobiles.FirstOrDefault(); _ignoreList.Add(mobile); return(mobile); } }
public void WillGetName() { string name = MobileCommands.Name("self"); Assert.AreEqual("Shmoo", name); }