SHARE
TWEET

Untitled

a guest Nov 19th, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --all gray text like this are comments and do not run as code
  2. --build the settings and basic functions for the hook
  3.  
  4. function (self, unitId, unitFrame, envTable)
  5.    
  6.     --declare setting variables:
  7.     local textColor = "white";
  8.     local textSize = 12;
  9.    
  10.     local showInRaid = true;
  11.     local showInDungeon = true;
  12.     local showInArena = false;
  13.     local showInBattleground = false;
  14.     local showInOpenWorld = true;
  15.    
  16.     envTable.UpdateInterval = 2; --each 2 updates in the nameplate it'll update the amount of targets
  17.    
  18.     local anchor = {
  19.         side = 6, --1 = topleft 2 = left 3 = bottomleft 4 = bottom 5 = bottom right 6 = right 7 = topright 8 = top
  20.         x = -20, --x offset
  21.         y = 12, --y offset
  22.     };
  23.    
  24.    
  25.     ---------------------------------------------------------------------------------------------------------------------------------------------
  26.    
  27.    
  28.     --frames:
  29.    
  30.     --create the text that will show the amount of people targeting the unit
  31.     if (not  unitFrame.healthBar.TargetAmount) then
  32.         envTable.TargetAmount = Plater:CreateLabel (unitFrame.healthBar, "", textSize, textColor);
  33.         Plater.SetAnchor (envTable.TargetAmount, anchor);
  34.         unitFrame.healthBar.TargetAmount = envTable.TargetAmount
  35.     end
  36.    
  37.     --in case Plater wipes the envTable
  38.     envTable.TargetAmount = unitFrame.healthBar.TargetAmount
  39.    
  40.     ---------------------------------------------------------------------------------------------------------------------------------------------          
  41.     --private variables (they will be used in the other scripts within this hook)
  42.     envTable.CanShow = false;
  43.     envTable.UpdateCooldown = 0;
  44.     envTable.InRaid = false;
  45.     envTable.InParty = false;
  46.    
  47.     ---------------------------------------------------------------------------------------------------------------------------------------------          
  48.     --functions
  49.    
  50.     --update the InRaid or InParty proprieties
  51.     function envTable.UpdateGroupType()
  52.         if (IsInRaid()) then
  53.             envTable.InRaid = true;
  54.             envTable.InParty = false;    
  55.            
  56.         elseif (IsInGroup()) then
  57.             envTable.InRaid = false;
  58.             envTable.InParty = true;  
  59.            
  60.         else
  61.             envTable.InRaid = false;            
  62.             envTable.InParty = false;
  63.         end
  64.     end
  65.    
  66.     --this function controls if the amount of targets can show following the settings in the top of this script
  67.     function envTable.CanShowTargetAmount()
  68.        
  69.         local _, instanceType, difficultyID, _, _, _, _, instanceMapID, instanceGroupSize = GetInstanceInfo()
  70.        
  71.         if (showInRaid and instanceType == "raid") then
  72.             envTable.UpdateGroupType()
  73.             return true
  74.         end
  75.        
  76.         if (showInDungeon and instanceType == "party") then
  77.             envTable.UpdateGroupType()
  78.             return true
  79.         end
  80.        
  81.         if (showInArena and instanceType == "arena") then
  82.             envTable.UpdateGroupType()
  83.             return true
  84.         end
  85.        
  86.         if (showInBattleground and instanceType == "pvp") then
  87.             envTable.UpdateGroupType()
  88.             return true
  89.         end
  90.        
  91.         if (showInOpenWorld and instanceType == "none") then
  92.             envTable.UpdateGroupType()
  93.             if (envTable.InRaid or envTable.InParty) then
  94.                 return true
  95.             end
  96.         end
  97.        
  98.         return false
  99.     end
  100.    
  101.     --get the amount of player targetting the unit in raid or party
  102.     function envTable.NumTargetsInRaid (unitFrame)
  103.         local amount = 0
  104.         for i = 1, GetNumGroupMembers() do
  105.             local unit = "raid" .. i .. "target"
  106.             if (UnitGUID (unit) == unitFrame.namePlateUnitGUID) then
  107.                 amount = amount + 1
  108.             end
  109.         end
  110.        
  111.         return amount
  112.     end
  113.    
  114.     function envTable.NumTargetsInParty()
  115.         local amount = 0
  116.         for i = 1, GetNumGroupMembers() - 1 do
  117.             local unit = "party" .. i .. "target"
  118.             if (UnitGUID (unit) == unitFrame.namePlateUnitGUID) then
  119.                 amount = amount + 1
  120.             end
  121.         end
  122.        
  123.         local unit = "playertarget"
  124.         if (UnitGUID (unit) == unitFrame.namePlateUnitGUID) then
  125.             amount = amount + 1
  126.         end        
  127.        
  128.         return amount
  129.     end
  130.    
  131. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top