public static void Initialize() { if (!Enabled) { return; } if (AutoGenerateNew) { foreach (MLQuest quest in Quests.Values) { if (quest?.Deserialized == false) { quest.Generate(); } } } MLQuestPersistence.EnsureExistence(); CommandSystem.Register("MLQuestsInfo", AccessLevel.Administrator, MLQuestsInfo_OnCommand); CommandSystem.Register("SaveQuest", AccessLevel.Administrator, SaveQuest_OnCommand); CommandSystem.Register("SaveAllQuests", AccessLevel.Administrator, SaveAllQuests_OnCommand); CommandSystem.Register("InvalidQuestItems", AccessLevel.Administrator, InvalidQuestItems_OnCommand); TargetCommands.Register(new ViewQuestsCommand()); TargetCommands.Register(new ViewContextCommand()); EventSink.QuestGumpRequest += EventSink_QuestGumpRequest; }
public void WillGetUnmounted() { Engine.Player = new PlayerMobile(0x01); for (int i = 2; i < 10; i++) { Mobile m = new Mobile(i) { Notoriety = Notoriety.Criminal, Hits = 25, HitsMax = 25, X = i, Y = i }; m.SetLayer(Layer.Mount, 1); Engine.Mobiles.Add(m); } Engine.Mobiles.GetMobile(7).SetLayer(Layer.Mount, 0); TargetCommands.GetEnemy(new[] { "Criminal" }, "Any", "Closest", "Unmounted"); Assert.AreEqual(7, AliasCommands.GetAlias("enemy")); TargetCommands.GetFriend(new[] { "Criminal" }, "Any", "Closest", "Unmounted"); Assert.AreEqual(7, AliasCommands.GetAlias("friend")); Engine.Mobiles.Clear(); Engine.Player = null; }
public override void Execute() { if (Options.CurrentOptions.SmartTargetOption == SmartTargetOption.None) { TargetCommands.Target("last", Options.CurrentOptions.RangeCheckLastTarget, Options.CurrentOptions.QueueLastTarget); } else { if (Engine.TargetExists) { if (Options.CurrentOptions.SmartTargetOption.HasFlag(SmartTargetOption.Friend) && Engine.TargetFlags == TargetFlags.Beneficial && AliasCommands.FindAlias("friend")) { TargetCommands.Target("friend", Options.CurrentOptions.RangeCheckLastTarget, Options.CurrentOptions.QueueLastTarget); return; } if (Options.CurrentOptions.SmartTargetOption.HasFlag(SmartTargetOption.Enemy) && Engine.TargetFlags == TargetFlags.Harmful && AliasCommands.FindAlias("enemy")) { TargetCommands.Target("enemy", Options.CurrentOptions.RangeCheckLastTarget, Options.CurrentOptions.QueueLastTarget); return; } } TargetCommands.Target("last", Options.CurrentOptions.RangeCheckLastTarget, Options.CurrentOptions.QueueLastTarget); } }
public void WontGetEnemyFriendClosest() { Engine.Player = new PlayerMobile(0x01); Mobile mate = new Mobile(0x02) { X = 1, Y = 1, Notoriety = Notoriety.Murderer }; Mobile random = new Mobile(0x03) { X = 5, Y = 5, Notoriety = Notoriety.Murderer }; Engine.Mobiles.Add(mate); Engine.Mobiles.Add(random); Options.CurrentOptions.Friends.Add(new FriendEntry { Name = "Mate", Serial = mate.Serial }); // Won't get mate even though he is closest bool result = TargetCommands.GetEnemy(new[] { "Murderer" }, "Any", "Closest"); Assert.IsTrue(result); Assert.AreEqual(random.Serial, AliasCommands.GetAlias("enemy")); Options.CurrentOptions.Friends.Clear(); Engine.Mobiles.Clear(); Engine.Player = null; }
public void WillGetMortaledFriend() { Engine.Player = new PlayerMobile(0x01); for (int i = 2; i < 10; i++) { Engine.Mobiles.Add(new Mobile(i) { Notoriety = Notoriety.Ally, Hits = 25, HitsMax = 25, X = i, Y = i }); } Engine.Mobiles.GetMobile(7).HealthbarColour |= HealthbarColour.Yellow; TargetCommands.GetFriend(new[] { "Friend" }, "Any", "Closest", "Mortaled"); Assert.AreEqual(7, AliasCommands.GetAlias("friend")); Engine.Mobiles.Clear(); Engine.Player = null; AliasCommands.SetAlias("friend", -1); }
public void WillGetMortaledFriendOnly() { Engine.Player = new PlayerMobile(0x01); Options.CurrentOptions.Friends = new ObservableCollection <FriendEntry>(); for (int i = 2; i < 10; i++) { Engine.Mobiles.Add(new Mobile(i) { Notoriety = Notoriety.Criminal, Hits = 25, HitsMax = 25, X = i, Y = i }); Options.CurrentOptions.Friends.Add(new FriendEntry { Name = "Friend", Serial = i }); } Engine.Mobiles.GetMobile(7).HealthbarColour |= HealthbarColour.Yellow; TargetCommands.GetFriendListOnly("Closest", "Mortaled"); Assert.AreEqual(7, AliasCommands.GetAlias("friend")); Options.CurrentOptions.Friends.Clear(); Engine.Mobiles.Clear(); Engine.Player = null; AliasCommands.SetAlias("friend", -1); }
public void WillTargetGround() { Engine.Player = new PlayerMobile(0x01); Mobile mobile = new Mobile(0x02) { ID = 0x191 }; Engine.Mobiles.Add(mobile); AutoResetEvent are = new AutoResetEvent(false); void PassOnTargetSent(byte[] data, int length) { if (data[0] == 0x6C) { are.Set(); } } Engine.InternalPacketSentEvent += PassOnTargetSent; TargetCommands.TargetGround(mobile.ID); bool result = are.WaitOne(5000); Assert.IsTrue(result); Engine.InternalPacketSentEvent -= PassOnTargetSent; Engine.Mobiles.Clear(); Engine.Player = null; }
public void WillGetPoisonedEnemy() { Engine.Player = new PlayerMobile(0x01); for (int i = 2; i < 10; i++) { Engine.Mobiles.Add(new Mobile(i) { Notoriety = Notoriety.Criminal, Hits = 25, HitsMax = 25, X = i, Y = i }); } Engine.Mobiles.GetMobile(7).HealthbarColour |= HealthbarColour.Green; TargetCommands.GetEnemy(new[] { "Criminal" }, "Any", "Closest", "Poisoned"); Assert.AreEqual(7, AliasCommands.GetAlias("enemy")); Engine.Mobiles.Clear(); Engine.Player = null; }
public void WillGetEnemyClosestBodyType() { Engine.Player = new PlayerMobile(0x01); Mobile any = new Mobile(0x02) { ID = 1, X = 1, Y = 1, Notoriety = Notoriety.Murderer }; Mobile humanoid = new Mobile(0x03) { ID = 400, X = 2, Y = 2, Notoriety = Notoriety.Murderer }; Mobile transformation = new Mobile(0x04) { ID = 748, X = 3, Y = 3, Notoriety = Notoriety.Murderer }; Engine.Mobiles.Add(new[] { any, humanoid, transformation }); TargetCommands.GetEnemy(new[] { "Murderer" }, "Any", "Closest"); Assert.AreEqual(any.Serial, AliasCommands.GetAlias("enemy")); TargetCommands.GetEnemy(new[] { "Murderer" }, "Humanoid", "Closest"); Assert.AreEqual(humanoid.Serial, AliasCommands.GetAlias("enemy")); TargetCommands.GetEnemy(new[] { "Murderer" }, "Transformation", "Closest"); Assert.AreEqual(transformation.Serial, AliasCommands.GetAlias("enemy")); TargetCommands.GetEnemy(new[] { "Murderer" }, "Both", "Closest"); Assert.AreEqual(humanoid.Serial, AliasCommands.GetAlias("enemy")); Engine.Player = null; }
private void AddSkillCommands() { #if DEBUG UnitCommandMenu.CheckValidCommands(SimpleCommands.Keys); UnitCommandMenu.CheckValidCommands(TargetCommands.Keys); #endif // Skills: Savior TargetCommands.Add(UnitCommandMenu.SkillCommandId(SkillMenuIds.Shelter), (Game_Unit unit, UnitCommandMenu menu) => Shelter(unit, menu)); TargetCommands.Add(UnitCommandMenu.SkillCommandId(SkillMenuIds.Refuge), (Game_Unit unit, UnitCommandMenu menu) => Refuge(unit, menu)); // Skills: Dash SimpleCommands.Add(UnitCommandMenu.SkillCommandId(SkillMenuIds.Dash), (Game_Unit unit) => Dash(unit)); // Skills: Swoop SimpleCommands.Add(UnitCommandMenu.SkillCommandId(SkillMenuIds.Swoop), (Game_Unit unit) => Swoop(unit)); // Skills: Trample SimpleCommands.Add(UnitCommandMenu.SkillCommandId(SkillMenuIds.Trample), (Game_Unit unit) => Trample(unit)); // Skills: Sacrifice TargetCommands.Add(UnitCommandMenu.SkillCommandId(SkillMenuIds.Sacrifice), (Game_Unit unit, UnitCommandMenu menu) => Sacrifice(unit, menu)); // Skills: Old Swoop //@Debug SimpleCommands.Add(UnitCommandMenu.SkillCommandId(SkillMenuIds.OldSwoop), (Game_Unit unit) => OldSwoop(unit)); }
public void WillUseIgnoreListIfEnabledGetNextFriend() { Options.CurrentOptions.GetFriendEnemyUsesIgnoreList = true; Engine.Player = new PlayerMobile(0x01); Mobile mobile = new Mobile(0x02) { Notoriety = Notoriety.Murderer }; Engine.Mobiles.Add(mobile); bool result = TargetCommands.GetFriend(new[] { Notoriety.Murderer.ToString() }); Assert.IsTrue(result); Assert.AreEqual(mobile.Serial, AliasCommands.GetAlias("friend")); AliasCommands.UnsetAlias("enemy"); ObjectCommands.IgnoreObject(mobile.Serial); result = TargetCommands.GetFriend(new[] { Notoriety.Murderer.ToString() }); Assert.IsFalse(result); ObjectCommands.ClearIgnoreList(); Engine.Mobiles.Clear(); Engine.Player = null; AliasCommands.SetAlias("friend", -1); }
public void WillGetNextLowestEnemy() { Engine.Player = new PlayerMobile(0x01); for (int i = 2; i < 10; i++) { Engine.Mobiles.Add(new Mobile(i) { Notoriety = Notoriety.Criminal, Hits = 25, HitsMax = 25, X = i, Y = i }); } Engine.Mobiles.GetMobile(7).Hits = 10; Engine.Mobiles.GetMobile(8).Hits = 11; TargetCommands.GetEnemy(new[] { "Criminal" }, "Any", "Next", "Lowest"); Assert.AreEqual(7, AliasCommands.GetAlias("enemy")); TargetCommands.GetEnemy(new[] { "Criminal" }, "Any", "Next", "Lowest"); Assert.AreEqual(8, AliasCommands.GetAlias("enemy")); Engine.Mobiles.Clear(); Engine.Player = null; }
public void WontGetEnemyFriendNext() { Engine.Player = new PlayerMobile(0x01); Mobile mate = new Mobile(0x02) { X = 1, Y = 1, Notoriety = Notoriety.Murderer }; Engine.Mobiles.Add(mate); // Will get mate because he's not in the friends list yet bool result = TargetCommands.GetEnemy(new[] { "Murderer" }); Assert.IsTrue(result); Assert.AreEqual(mate.Serial, AliasCommands.GetAlias("enemy")); Options.CurrentOptions.Friends.Add(new FriendEntry { Name = "Mate", Serial = mate.Serial }); // Won't get a result because mate is in the friends list result = TargetCommands.GetEnemy(new[] { "Murderer" }); Assert.IsFalse(result); Options.CurrentOptions.Friends.Clear(); Engine.Mobiles.Clear(); Engine.Player = null; }
private static void OnTarget(PacketReader reader) { byte type = reader.ReadByte(); int tid = reader.ReadInt32(); TargetFlags flags = (TargetFlags)reader.ReadByte(); Engine.TargetType = (TargetType)type; Engine.TargetSerial = tid; Engine.TargetFlags = flags; Engine.TargetExists = flags != TargetFlags.Cancel; if (Engine.TargetExists) { Engine.WaitingForTarget = false; } if (!Options.CurrentOptions.QueueLastTarget || (TargetType)type != TargetType.Object || Engine.LastTargetQueue.Count == 0) { return; } object obj = Engine.LastTargetQueue.Dequeue(); if (obj == null) { return; } TargetCommands.Target(obj, Options.CurrentOptions.RangeCheckLastTarget); Engine.TargetExists = false; }
public void WontGetDeadFriendLowest() { Engine.Player = new PlayerMobile(0x01); for (int i = 2; i < 10; i++) { Engine.Mobiles.Add(new Mobile(i) { Notoriety = Notoriety.Ally, Hits = 25, HitsMax = 25, X = i, Y = i }); } Engine.Mobiles.GetMobile(7).Hits = 0; Engine.Mobiles.GetMobile(7).ID = 0x192; TargetCommands.GetFriend(new[] { "Friend" }, "Any", "Closest", "Lowest"); Assert.AreNotEqual(7, AliasCommands.GetAlias("friend")); Engine.Mobiles.Clear(); Engine.Player = null; AliasCommands.SetAlias("friend", -1); }
public void WontGetInvalidBodyGetFriendListOnlyTransformation() { Engine.Player = new PlayerMobile(0x01); Mobile mobile = new Mobile(0x02) { Notoriety = Notoriety.Murderer, ID = 0x190 }; Engine.Mobiles.Add(mobile); Options.CurrentOptions.Friends.Add(new FriendEntry { Name = "Friend", Serial = mobile.Serial }); bool result = TargetCommands.GetFriendListOnly("Closest", "Any", "Humanoid"); Assert.IsTrue(result); Assert.AreEqual(mobile.Serial, AliasCommands.GetAlias("friend")); result = TargetCommands.GetFriendListOnly("Closest", "Any", "Transformation"); Assert.IsFalse(result); result = TargetCommands.GetFriendListOnly("Next"); Assert.IsTrue(result); Assert.AreEqual(mobile.Serial, AliasCommands.GetAlias("friend")); Options.CurrentOptions.Friends.Clear(); ObjectCommands.ClearIgnoreList(); Engine.Mobiles.Clear(); Engine.Player = null; AliasCommands.SetAlias("friend", -1); }
public void WillTargetTypeLessThanSearchLevel() { Engine.Player = new PlayerMobile(0x01); Item backpack = new Item(0x40000000, Engine.Player.Serial) { Container = new ItemCollection(0x40000000) }; Engine.Items.Add(backpack); Engine.Player.SetLayer(Layer.Backpack, backpack.Serial); ItemCollection container = backpack.Container; for (int i = 0; i < 5; i++) { Item subitem = new Item(container.Serial + 1, container.Serial) { Container = new ItemCollection(container.Serial + 1), Owner = container.Serial }; container.Add(subitem); container = subitem.Container; } Item item = new Item(container.Serial + 1, container.Serial) { ID = 0xfeef }; container.Add(item); AutoResetEvent are = new AutoResetEvent(false); void PassOnTargetSent(byte[] data, int length) { if (data[0] == 0x6C) { are.Set(); } } Engine.InternalPacketSentEvent += PassOnTargetSent; TargetCommands.TargetType(item.ID, -1, 5); bool result = are.WaitOne(5000); Assert.IsTrue(result); Engine.InternalPacketSentEvent -= PassOnTargetSent; Engine.Items.Clear(); Engine.Player = null; }
public void WillSetLastTargetSerialOnInternalTargetSent() { Engine.Player = new PlayerMobile(0x01); Assert.AreEqual(0, Engine.Player.LastTargetSerial); TargetCommands.Target(0x00aabbcc); Assert.AreEqual(0x00aabbcc, Engine.Player.LastTargetSerial); Engine.Player = null; }
public void WontTargetTypeGreaterThanSearchLevel() { Engine.Player = new PlayerMobile(0x01); Item backpack = new Item(0x40000000, Engine.Player.Serial) { Container = new ItemCollection(0x40000000) }; Engine.Items.Add(backpack); Engine.Player.SetLayer(Layer.Backpack, backpack.Serial); ItemCollection container = backpack.Container; for (int i = 0; i < 5; i++) { Item subitem = new Item(container.Serial + 1, container.Serial) { Container = new ItemCollection(container.Serial + 1), Owner = container.Serial }; container.Add(subitem); container = subitem.Container; } Item item = new Item(container.Serial + 1, container.Serial) { ID = 0xfeef }; container.Add(item); void FailOnTargetSent(byte[] data, int length) { if (data[0] == 0x6C) { Assert.Fail(); } } Engine.InternalPacketSentEvent += FailOnTargetSent; TargetCommands.TargetType(item.ID, -1, 4); Engine.InternalPacketSentEvent -= FailOnTargetSent; Engine.Items.Clear(); Engine.Player = null; }
public void WillGetFriend() { Engine.Player = new PlayerMobile(0x01); Mobile[] mobiles = { new Mobile(0x02) { Notoriety = Notoriety.Innocent }, new Mobile(0x03) { Notoriety = Notoriety.Ally }, new Mobile(0x04) { Notoriety = Notoriety.Murderer }, new Mobile(0x05) { Notoriety = Notoriety.Criminal } }; Engine.Mobiles.Add(mobiles); TargetCommands.GetFriend(new[] { "Innocent" }); Assert.AreEqual(0x02, AliasCommands.GetAlias("friend")); TargetCommands.GetFriend(new[] { "Friend" }); Assert.AreEqual(0x03, AliasCommands.GetAlias("friend")); TargetCommands.GetFriend(new[] { "Murderer" }); Assert.AreEqual(0x04, AliasCommands.GetAlias("friend")); TargetCommands.GetFriend(new[] { "Innocent", "Friend", "Murderer" }); int friend = AliasCommands.GetAlias("friend"); Assert.IsTrue(((IList) new[] { 0x02, 0x03, 0x04 }).Contains(friend)); Engine.Mobiles.Remove(mobiles); Engine.Player = null; }
public void WillTargetTileRelativeSelfRunning() { Engine.Player = new PlayerMobile(0x01) { X = 100, Y = 100, Direction = (Direction)((int)Direction.East | 0x80) }; AutoResetEvent are = new AutoResetEvent(false); void OnInternalPacketSentEvent(byte[] data, int length) { if (data[0] != 0x6C) { Assert.Fail(); } int x = (data[11] << 8) | data[12]; //int y = ( data[ 13 ] << 8 ) | data[ 14 ]; if (x != 101) { Assert.Fail(); } are.Set(); } Engine.InternalPacketSentEvent += OnInternalPacketSentEvent; AliasCommands.SetAlias("self", 0x01); Engine.TargetType = TargetType.Tile; TargetCommands.TargetTileRelative("self", 1); bool result = are.WaitOne(5000); Assert.IsTrue(result); Engine.InternalPacketSentEvent -= OnInternalPacketSentEvent; Engine.Player = null; }
public void WillTargetType() { Engine.Player = new PlayerMobile(0x01); Item backpack = new Item(0x40000000, Engine.Player.Serial) { Container = new ItemCollection(0x40000000) }; Engine.Items.Add(backpack); Engine.Player.SetLayer(Layer.Backpack, backpack.Serial); Item item = new Item(0x40000001, backpack.Serial) { ID = 0xfeef }; backpack.Container.Add(item); AutoResetEvent are = new AutoResetEvent(false); void PassOnTargetSent(byte[] data, int length) { if (data[0] == 0x6C) { are.Set(); } } Engine.InternalPacketSentEvent += PassOnTargetSent; TargetCommands.TargetType(item.ID); bool result = are.WaitOne(5000); Assert.IsTrue(result); Engine.InternalPacketSentEvent -= PassOnTargetSent; Engine.Items.Clear(); Engine.Player = null; }
public static void Initialize() { CommandSystem.Prefix = "["; Register("LiveFreeze", AccessLevel.Administrator, new CommandEventHandler(LiveFreeze_OnCommand)); Register("GetBlockNumber", AccessLevel.GameMaster, new CommandEventHandler(getBlockNumber_OnCommand)); Register("QueryClientHash", AccessLevel.GameMaster, new CommandEventHandler(queryClientHash_OnCommand)); Register("updateblock", AccessLevel.GameMaster, new CommandEventHandler(updateBlock_OnCommand)); Register("CircularIndent", AccessLevel.GameMaster, new CommandEventHandler(circularIndent_OnCommand)); TargetCommands.Register(new IncStaticYCommand()); TargetCommands.Register(new IncStaticXCommand()); TargetCommands.Register(new IncStaticAltCommand()); TargetCommands.Register(new SetStaticHueCommand()); TargetCommands.Register(new SetStaticAltCommand()); TargetCommands.Register(new SetStaticIDCommand()); TargetCommands.Register(new DelStaticCommand()); TargetCommands.Register(new AddStaticCommand()); TargetCommands.Register(new MoveStaticCommand()); TargetCommands.Register(new IncLandAltCommand()); TargetCommands.Register(new SetLandAltCommand()); TargetCommands.Register(new SetLandIDCommand()); }
public void WillOnlyGetClosestFriend() { Engine.Player = new PlayerMobile(0x01); Mobile mate = new Mobile(0x02) { X = 5, Y = 5, Notoriety = Notoriety.Murderer }; Mobile random = new Mobile(0x03) { X = 1, Y = 1, Notoriety = Notoriety.Murderer }; Engine.Mobiles.Add(mate); Engine.Mobiles.Add(random); Options.CurrentOptions.Friends.Add(new FriendEntry { Name = "Mate", Serial = mate.Serial }); bool result = TargetCommands.GetFriend(new[] { "Murderer" }, "Any", "Closest"); Assert.IsTrue(result); Assert.AreEqual(random.Serial, AliasCommands.GetAlias("friend")); // Will get mate even though he is further away result = TargetCommands.GetFriendListOnly("Closest"); Assert.IsTrue(result); Assert.AreEqual(mate.Serial, AliasCommands.GetAlias("friend")); Options.CurrentOptions.Friends.Clear(); Engine.Mobiles.Clear(); Engine.Player = null; }
public static void Initialize() { TargetCommands.Register(new AddToVirtueCommand()); }
public static void Initialize() { TargetCommands.Register(new AddToBuildingCommand()); }
public static void Initialize() { TargetCommands.Register(new ToggleCommand()); }
public static void Initialize() { TargetCommands.Register(new ExportSpawnerCommand()); CommandSystem.Register("ImportSpawners", AccessLevel.Administrator, new CommandEventHandler(ImportSpawners_OnCommand)); }
public static void Initialize() { TargetCommands.Register(new SpawnPropsCommand()); }
public static void Initialize() { TargetCommands.Register(new BountyCommand()); }