Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: auto join any party via contains title #628

Merged
merged 1 commit into from
Mar 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions Plugins/RSBot.Map/Views/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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<SpawnedEntity>(out var entities))
return;

Expand All @@ -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);
}
}
Expand Down
6 changes: 4 additions & 2 deletions Plugins/RSBot.Party/Bundle/AutoParty/AutoPartyBundle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
}

Expand All @@ -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;

Expand Down
9 changes: 3 additions & 6 deletions Plugins/RSBot.Protection/Components/Town/DeadHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,18 @@ public static void Initialize()
/// </summary>
private static void SubscribeEvents()
{
EventManager.SubscribeEvent("OnUpdateEntityLifeState", new System.Action<uint>(OnEntityLifeStateChanged));
EventManager.SubscribeEvent("OnPlayerDied", OnPlayerDied);
}

/// <summary>
/// Cores the entity life state changed.
/// </summary>
/// <param name="uniqueId">The unique identifier.</param>
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);
Expand All @@ -53,7 +50,7 @@ private static async void OnEntityLifeStateChanged(uint uniqueId)
return;

var itemsToUse = PlayerConfig.GetArray<string>("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();
Expand Down