Closed Lyricalpanda closed 1 year ago
Note there are limits on what is allowed to target. Anything that isn't LoS will not be picked up. I did several hours of testings and it seemed to work fine as long as I didn't lose LoS.
foreach (var s in _spawns.Get().OrderBy(x => x.Distance))
{
//find all mobs that are close
if (!s.Targetable) continue;
if (!s.Aggressive) continue;
if (!MQ.Query<bool>($"${{Spawn[npc id {s.ID}].LineOfSight}}")) continue;
if (s.Distance > 60) break;//mob is too far away, and since it is ordered, kick out.
if (s.TypeDesc == "Corpse") continue;
if (s.Name.Contains("'s pet'")) continue;
if (s.Name.IndexOf("Chest", StringComparison.OrdinalIgnoreCase) > -1) continue;
if (s.Name.IndexOf("a box", StringComparison.OrdinalIgnoreCase) > -1) continue;
if (s.Name.IndexOf("crate", StringComparison.OrdinalIgnoreCase) > -1) continue;
if (s.Name.IndexOf("hollow_tree", StringComparison.OrdinalIgnoreCase) > -1) continue;
if (s.Name.IndexOf("wooden box", StringComparison.OrdinalIgnoreCase) > -1) continue;
//its valid to attack!
MobToAttack = s.ID;
break;
}
Please reopen if the issue is continuing or you have more information.
This happened to me twice, added some debugging to try and narrow down a bit what's happening. Maybe MobToAttack isn't clearing for certain mobs? https://github.com/RekkasGit/E3Next/blob/master/E3Next/Processors/ClearXTargets.cs#L37
Added in some print lines, saw this interesting tidbit:
I had called assist on ID 3. Immediately after, I get two bots saying that's a corpse and my driver actually changed targets to ID 108 to cast a spell on. Then I see a bunch of spam that we're still waiting on ID 3 to die, turn into a corpse, and proceed to next XTarget.
It's looking like it's not stopping prematurely as much as a potential issue with MobToAttack and ClearTargets thinking the target is still alive.
So you can see where the extra writes are coming from:
if (MobToAttack == 0)
{
int counter = 0;
foreach (var s in _spawns.Get().OrderBy(x => x.Distance))
{
counter += 1;
//find all mobs that are close
if (!s.Targetable) continue;
if (!s.Aggressive) continue;
if (!MQ.Query<bool>($"${{Spawn[npc id {s.ID}].LineOfSight}}")) continue;
if (s.Distance > 60) {
MQ.Write($"ClearTargets kicking out because distance {s.Distance}");
break;//mob is too far away, and since it is ordered, kick out.
}
if (s.TypeDesc == "Corpse") continue;
if (s.Name.Contains("'s pet'")) continue;
if (s.Name.IndexOf("Chest", StringComparison.OrdinalIgnoreCase) > -1) continue;
if (s.Name.IndexOf("a box", StringComparison.OrdinalIgnoreCase) > -1) continue;
if (s.Name.IndexOf("crate", StringComparison.OrdinalIgnoreCase) > -1) continue;
if (s.Name.IndexOf("hollow_tree", StringComparison.OrdinalIgnoreCase) > -1) continue;
if (s.Name.IndexOf("wooden box", StringComparison.OrdinalIgnoreCase) > -1) continue;
//its valid to attack!
MobToAttack = s.ID;
MQ.Write($"ClearTargets found Mob ID {s.ID} name {s.CleanName}");
break;
}
MQ.Write($"ClearTargets looked through {counter} mobs");
if (MobToAttack == 0)
{
//we are done, stop killing
Enabled = false;
MQ.Write("\agClear Targets complete.");
return;
}
//mobs to attack will be sorted by distance.
if (MobToAttack > 0)
{
//pop it off and start assisting.
Int32 mobId = MobToAttack;
Spawn s;
if (_spawns.TryByID(mobId, out s))
{
MQ.Write("\agClear Targets: \aoIssuing Assist.");
Assist.AllowControl = true;
Assist.AssistOn(mobId);
MQ.Delay(500);
E3.Bots.BroadcastCommandToGroup($"/assistme {mobId}");
}
}
} else
{
MQ.Write($"ClearTargets Mob to attack {MobToAttack}");
}
Also, I actually can't reopen issues 😆. But will ping once I have some more information.
Not sure why, but just happened again.
We're trying to attack ID 31, which is reported to be a corpse right after assist call. Driver is now casting on a new mob. After combat, I checked for target id 31, which resulted in nothing.
I had no looters on, so the corpse should still be there.
Looks like a missing else for when !(_spawns.TryByID(MobToAttack, out ts) { MobToAttack = 0} ? I'll try the following locally
if (MobToAttack > 0)
{
Spawn ts;
if (_spawns.TryByID(MobToAttack, out ts))
{
//is it still alive?
if (ts.TypeDesc == "Corpse")
{
//its dead jim
MobToAttack = 0;
}
} else {
//Can't find mob, look for new one
MQ.Write($"ClearTargets Can't find spawn ID {MobToAttack}, clearing.");
MobToAttack = 0;
}
}
I will be adding a delay before we refresh the spawns, this should make sure that we have the most up to date spawn data. Reopening this so we can test once i push it into master.
no update, closing for now.
Made sure I pulled in the latest copy, just ran into it three times on the same fight in guk ldon (particularly unlucky). Should we have a safe guard of MobToAttack=0
if _spawns.TryByID
fails? To cover if a corpse doesn't spawn or if the corpse is looted before the next system tick on the driver.
Funnily enough, FUKU is also a good test for this (someone tried this on our attempt 😆) as the adds don't leave behind corpses
From report: "pressing cleartargets again , they continue"
Console prints out "TrueTarget has no spawn count"