From 179ccb9dcc0a9ed7c3e019672ab1f11fa6f3b6fc Mon Sep 17 00:00:00 2001 From: Mahmut YILDIRIM Date: Mon, 20 Mar 2023 19:58:36 +0300 Subject: [PATCH] Fix: auto join any party via contains title (#628) --- Plugins/RSBot.Map/Views/Main.cs | 18 +++++++++++------- .../Bundle/AutoParty/AutoPartyBundle.cs | 6 ++++-- .../Components/Town/DeadHandler.cs | 9 +++------ 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/Plugins/RSBot.Map/Views/Main.cs b/Plugins/RSBot.Map/Views/Main.cs index 8f536ae4..182550e0 100644 --- a/Plugins/RSBot.Map/Views/Main.cs +++ b/Plugins/RSBot.Map/Views/Main.cs @@ -322,8 +322,12 @@ private void PopulateMapAndGrid(Graphics graphics) { foreach (var member in Game.Party.Members.ToArray()) { - if (!(Game.Player.Movement.Source.DistanceTo(member.Position) < 50)) + if (Game.Player.Position.DistanceTo(member.Position) > 50) continue; + + if (member.Name == Game.Player.Name) + continue; + DrawPointAt(graphics, member.Position, 6); AddGridItem(member.Name, "Party Member", member.Level, member.Position); } @@ -382,12 +386,15 @@ private void DrawCollisions(Graphics gfx) { if (CollisionManager.HasActiveMeshes && CollisionManager.Enabled) { - //Draw collisions foreach (var collisionNavmesh in CollisionManager.ActiveCollisionMeshes) { - foreach (var collider in collisionNavmesh.Collisions.Where(c => c.Source.DistanceToPlayer() < 100 || c.Destination.DistanceToPlayer() < 100)) + var colliders = collisionNavmesh.Collisions + .Where(c => c.Source.DistanceToPlayer() < 100 || c.Destination.DistanceToPlayer() < 100); + + foreach (var collider in colliders) DrawLineAt(gfx, collider.Source, collider.Destination, Pens.Red); } + if (!SpawnManager.TryGetEntities(out var entities)) return; @@ -398,11 +405,8 @@ private void DrawCollisions(Graphics gfx) if (!collision.HasValue) continue; - var rayPen = new Pen(Color.DeepSkyBlue); - rayPen.DashStyle = DashStyle.Dot; - rayPen.EndCap = LineCap.Square; - DrawLineAt(gfx, Game.Player.Position, collision.Value.CollidedAt, Pens.DeepSkyBlue); + DrawLineAt(gfx, Game.Player.Position, collision.Value.CollidedAt, Pens.GreenYellow); DrawLineAt(gfx, collision.Value.CollidedWith.Source, collision.Value.CollidedWith.Destination, Pens.Yellow); } } diff --git a/Plugins/RSBot.Party/Bundle/AutoParty/AutoPartyBundle.cs b/Plugins/RSBot.Party/Bundle/AutoParty/AutoPartyBundle.cs index e1251a0d..1b99b5a8 100644 --- a/Plugins/RSBot.Party/Bundle/AutoParty/AutoPartyBundle.cs +++ b/Plugins/RSBot.Party/Bundle/AutoParty/AutoPartyBundle.cs @@ -109,10 +109,12 @@ private void CheckForAutoPartyJoin() while (true) { var currentPage = Container.PartyMatching.RequestPartyList(page); + + _partyEntriesCache.AddRange(currentPage.Parties); + if (currentPage.Page == currentPage.PageCount - 1) break; - _partyEntriesCache.AddRange(currentPage.Parties); page++; } @@ -131,7 +133,7 @@ private void CheckForAutoPartyJoin() if (Config.AutoJoinByTitle) { - var partyEntry = _partyEntriesCache.Find(p => p.Title.Equals(Config.AutoJoinByTitleContent, StringComparison.CurrentCultureIgnoreCase)); + var partyEntry = _partyEntriesCache.Find(p => p.Title.Contains(Config.AutoJoinByTitleContent, StringComparison.CurrentCultureIgnoreCase)); if (partyEntry == null) return; diff --git a/Plugins/RSBot.Protection/Components/Town/DeadHandler.cs b/Plugins/RSBot.Protection/Components/Town/DeadHandler.cs index 4f01b376..f3ca3662 100644 --- a/Plugins/RSBot.Protection/Components/Town/DeadHandler.cs +++ b/Plugins/RSBot.Protection/Components/Town/DeadHandler.cs @@ -22,21 +22,18 @@ public static void Initialize() /// private static void SubscribeEvents() { - EventManager.SubscribeEvent("OnUpdateEntityLifeState", new System.Action(OnEntityLifeStateChanged)); + EventManager.SubscribeEvent("OnPlayerDied", OnPlayerDied); } /// /// Cores the entity life state changed. /// /// The unique identifier. - private static async void OnEntityLifeStateChanged(uint uniqueId) + private static async void OnPlayerDied() { if (!Kernel.Bot.Running) return; - if (uniqueId != Game.Player.UniqueId) - return; - if(Game.Player.Level < 10) { await Task.Delay(5000); @@ -53,7 +50,7 @@ private static async void OnEntityLifeStateChanged(uint uniqueId) return; var itemsToUse = PlayerConfig.GetArray("RSBot.Inventory.AutoUseAccordingToPurpose"); - var inventoryItem = Game.Player.Inventory.GetItem(new TypeIdFilter(3, 3, 13, 6), p => itemsToUse.Contains(p.Record.CodeName)); + var inventoryItem = Game.Player.Inventory.GetItem(new(3, 3, 13, 6), p => itemsToUse.Contains(p.Record.CodeName)); if (inventoryItem != null) { inventoryItem.Use();