Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --all gray text like this are comments and do not run as code
- --build the settings and basic functions for the hook
- function (self, unitId, unitFrame, envTable)
- --declare setting variables:
- local textColor = "white";
- local textSize = 12;
- local showInRaid = true;
- local showInDungeon = true;
- local showInArena = false;
- local showInBattleground = false;
- local showInOpenWorld = true;
- envTable.UpdateInterval = 2; --each 2 updates in the nameplate it'll update the amount of targets
- local anchor = {
- side = 6, --1 = topleft 2 = left 3 = bottomleft 4 = bottom 5 = bottom right 6 = right 7 = topright 8 = top
- x = -20, --x offset
- y = 12, --y offset
- };
- ---------------------------------------------------------------------------------------------------------------------------------------------
- --frames:
- --create the text that will show the amount of people targeting the unit
- if (not unitFrame.healthBar.TargetAmount) then
- envTable.TargetAmount = Plater:CreateLabel (unitFrame.healthBar, "", textSize, textColor);
- Plater.SetAnchor (envTable.TargetAmount, anchor);
- unitFrame.healthBar.TargetAmount = envTable.TargetAmount
- end
- --in case Plater wipes the envTable
- envTable.TargetAmount = unitFrame.healthBar.TargetAmount
- ---------------------------------------------------------------------------------------------------------------------------------------------
- --private variables (they will be used in the other scripts within this hook)
- envTable.CanShow = false;
- envTable.UpdateCooldown = 0;
- envTable.InRaid = false;
- envTable.InParty = false;
- ---------------------------------------------------------------------------------------------------------------------------------------------
- --functions
- --update the InRaid or InParty proprieties
- function envTable.UpdateGroupType()
- if (IsInRaid()) then
- envTable.InRaid = true;
- envTable.InParty = false;
- elseif (IsInGroup()) then
- envTable.InRaid = false;
- envTable.InParty = true;
- else
- envTable.InRaid = false;
- envTable.InParty = false;
- end
- end
- --this function controls if the amount of targets can show following the settings in the top of this script
- function envTable.CanShowTargetAmount()
- local _, instanceType, difficultyID, _, _, _, _, instanceMapID, instanceGroupSize = GetInstanceInfo()
- if (showInRaid and instanceType == "raid") then
- envTable.UpdateGroupType()
- return true
- end
- if (showInDungeon and instanceType == "party") then
- envTable.UpdateGroupType()
- return true
- end
- if (showInArena and instanceType == "arena") then
- envTable.UpdateGroupType()
- return true
- end
- if (showInBattleground and instanceType == "pvp") then
- envTable.UpdateGroupType()
- return true
- end
- if (showInOpenWorld and instanceType == "none") then
- envTable.UpdateGroupType()
- if (envTable.InRaid or envTable.InParty) then
- return true
- end
- end
- return false
- end
- --get the amount of player targetting the unit in raid or party
- function envTable.NumTargetsInRaid (unitFrame)
- local amount = 0
- for i = 1, GetNumGroupMembers() do
- local unit = "raid" .. i .. "target"
- if (UnitGUID (unit) == unitFrame.namePlateUnitGUID) then
- amount = amount + 1
- end
- end
- return amount
- end
- function envTable.NumTargetsInParty()
- local amount = 0
- for i = 1, GetNumGroupMembers() - 1 do
- local unit = "party" .. i .. "target"
- if (UnitGUID (unit) == unitFrame.namePlateUnitGUID) then
- amount = amount + 1
- end
- end
- local unit = "playertarget"
- if (UnitGUID (unit) == unitFrame.namePlateUnitGUID) then
- amount = amount + 1
- end
- return amount
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement