I'm really glad to see someone putting some effort into this. The second "chance to cast" check always bothered me as well.
Another thing that concerns me is the fact that healers cast specific types of healing spells (or don't heal at all) dependent on whether or not the target of the heal is engaged. This isn't a problem in and of itself, but the way it checks it doesn't seem correct. I'm under the impression that a call to IsEngaged() on a client object will almost always return false, because it just executes return(!hate_list.IsEmpty()). I don't think a client uses the hate list unless it happens to be AI controlled (charmed).
This is, of course, also a problem when running client/group engagement checks when spawning bots.
If I'm not completely off-base with my assumptions, this will work better:
Code:
bool mbrIsEngaged = g->members[i]->IsClient() ? g->members[i]->CastToClient()->GetAggroCount() : g->members[i]->IsEngaged();