View Single Post
07/26/18, 05:14 AM   #4
SDPhantom
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 47
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);

Last edited by SDPhantom : 07/26/18 at 05:16 AM.
  Reply With Quote