View Single Post
07/30/18, 01:38 PM   #5
SlippyCheeze
AddOn Author - Click to view addons
Join Date: Jul 2018
Posts: 53
Originally Posted by SDPhantom View Post
Here's a drycoded example of how I can see this working. Without access to unique mob IDs, this can run into problems of false triggering.

Lua Code:
  1. local TargetTimeout=5000;
  2.  
  3. local function OnTimeout()
  4.     if DoesUnitExist("reticleover") and GetUnitReaction("reticleover")==UNIT_REACTION_HOSTILE and ArePlayerWeaponsSheathed() then
  5.         TogglePlayerWield();
  6.     end
  7.     EVENT_MANAGER:UnregisterForUpdate("AutoDraw");
  8. end
  9.  
  10. EVENT_MANAGER:RegisterForEvent("AutoDraw",EVENT_RETICLE_TARGET_CHANGED,function()
  11.     EVENT_MANAGER[(DoesUnitExist("reticleover") and GetUnitReaction("reticleover")==UNIT_REACTION_HOSTILE) and "RegisterForUpdate" or "UnregisterForUpdate"](EVENT_MANAGER,"AutoDraw",TargetTimeout,OnTimeout);
  12. end);
Sorry for not getting back to you sooner, thank you very much! I'll be honest, I don't really care too much about false positives in this, because drawing my weapon is never really much of an inconvenience (that I know of, anyway), compared to not drawing it when [s]I'm stupid[/s] I forget, so don't get that first light attack, and then screw up the flow of weaving for a few more.
  Reply With Quote