You've pretty much answered your question :P
This clears the bots' hatelist when you use ^attack:
https://github.com/EQEmu/Server/blob...mand.cpp#L2534
For the 'untargetable' mobs, there is a flag that makes the client ignore the mob object when set..but, it is still a viable target in the server code.
I would imagine that pets also have this problem unless special consideration was put into their hate code.