Interesting code, for an interesting situation.
You've had some adventures and encountered a scenario and looking to resolve it yourself.
I applaud your efforts and enthusiasm to get stuck in and wrestle with code! Great stuff!
I would like to make one line of observation for you.
[CODE title="Get Loose Mob codes for KA " highlight="10"]} else {
/varset MyTargetID 0
/varset MyTargetName
/if (${Target.ID}) /squelch /target clear
/varset WaitTimer 0s
/varset AttackingMobID ${NearestSpawn[npc radius 39 targetable "${AttackingMob}"].ID}
/if (${Spawn[${AttackingMobID}].ID}) {
/moveto dist 10
/call Broadcast y "Mob >>${AttackingMob}<< (${AttackingMobID}) attacking me! "
/bca //getloosemob ${AttackingMobID}
}
}[/CODE]
Are you really wanting to broadcast to everyone connected to the EQBCS to run that code,
/getloosemob ${AttackingMobID} ?
For a group only instruction
(exclude yourself), its
/bcg
For all connected
(exclude yourself), as you've used its
/bca
Both calls to include yourself have an additional 'a', i.e.
/bcga /bcaa.
I mention the importance of this as there are members in the community that run more than a group on a computer and perhaps are doing things concurrently in different zones.
e.g. Another group doing KA activities away from where your protagonist is fighting a loose mob, they will be given instruction to randomly engage some innocent mob.
Accepting the new code has some opening fail fasts in there
(great to see!), so only the tank will consider these new orders.
Looking more at the next bit of code, from the view of a tank in a random 2nd+ group.
[CODE title="more codes" highlight="2"]/varset AggroTargetID2 ${AttackingMobID}
/squelch /target id ${AttackingMobID}
/delay 10 ${Target.ID}==${AttackingMobID}
/varset MyTargetID ${Target.ID}
/varset MyTargetName ${Target.CleanName}
/if (${Me.Pet.ID} && ${Math.Distance[${Target.Y},${Target.X}:${Me.Pet.Y},${Me.Pet.X}]}<=${PetAttackRange}) /pet attack
|Sanity check... should I go back to previous target?[/CODE]
If the 2nd group is in the same zone but another camp spot, their tank will have just become very interested in the 1st groups mobs, at least by targeting it, regardless of distance.
If the 2nd group tank is in a different zone, that instruction to target could be giving an ID,
- it might not exist as a valid ID.
- it could be something from anywhere in the zone,
- A nearby guard?
- A target 1000s of feet away?
Stepping further away, I've read over the code a couple more times from a high level to try and grasp a feel for the problem you're trying to battle.
It feels that the flow is of the ilk; there has been an aggro problem detected, as mob is playing whack-a-groupie. The tank is directed to abandon wacking on it's current
(trash) mob and focus on the new one to gain aggro.
Perhaps the group has no active CC in the party and so keeping aggro towards the tank, away from healer
(working overtime) and the dps.
But then what if there is a CC, a couple partially chewed up mobs now exist. Many KA rules for mez say don't do it if go below a certain percentage so the CC won't try and lock down extra mobs.
If the scenario were considered some fresh spawns appear in an ongoing fight. It's a race condition of the KA codes, does the CC or Tank react first. I feel the CC is on the back foot having to react, target and cast mez successfully to get in their first and negate the tank engaging.
The CC may now be considering options what to do with the initial mob the tank has just switched away from. It's hp may be high enough for a mez to be attempted, but it may be loaded with dots.
This idea of loose mobs, it feels a right pickle onion, the more I think about it, and peel back layers of scenarios, the game of chess, what if this, then this happens.
As players we know if we have a CC awake and should be doing things.
Similar we know that if aggro wanders, we can click targets, taunt or cast non-damage hate raising spells and click back where we were, repeating as necessary. This allowing the CC to step in if they can. DPS
not switching target.
Or go more drastic action and move to the target and go wack-a-mob on it instead
(perhaps some mez immune mobs arrive, and the CC is screaming!) and the DPS
do switch, perhaps or finish chopping down that first one.
We can arbitrate the risk of hp damage, multiple mobs on the tank versus one or two wild for a little time, can it be handled by the groupie rather than risk over damage the healer can't cope with on the tank.
There are likely more options than fingers n toes to count on of possible scenarios.
I feel its a big task to try and code to handle it with a view of covering most scenarios.
Regards and Best Wishes