How do I block right-clicking Civilians?
I have a question. First, a short summary of the addon I'm attempting to make:
I'm trying to make an addon which will stop whole raids from getting accidental Dishonorable Kills. It'll have a feature where you can easily check if everyone in the raid has the addon, kick out anyone who doesn't, and send auto-tells to those without the addon specifying where to get it from. I'm even planning a built-in table of Civilian names so that if you're lower than level 60, the addon will still be able to tell who's a Civilian to level 60s, even if they're not Civilians to you. I'm also planning a built-in "location database" that specifies where AOEs and multi-shot will be blocked from use.
I'm off to a good start in that when PLAYER_TARGET_CHANGED is fired, my code calls ClearTarget() if it sees a true response from UnitIsCivilian("target") (or if it knows the NPC name is a known Civilian name from the addon's database). And that succeeds. If the player tries to target a Civilian, it is cleared right away so that the player cannot press the T button to attack him.. and he can't cast a non-AOE spell on the Civilian either.
However, my problem is when you right-click the Civilian (obviously, I'm trying this from far away). Although my code still succeeds with ClearTarget() in that the target is cleared, the melee auto attack is still on, and if I were to move close to the Civilian, I would be attacking him (even though the target is clear!!!)
I'm not sure how to solve this. I've tried reacting to PLAYER_ENTER_COMBAT being fired. I've tried hooking AttackTarget(). No luck. I've even tried having the PLAYER_ENTER_COMBAT handler call AttackTarget() to try to toggle auto-attack off. No luck.
Is there any way for me to totally block right-clicking on Civilians?
|