Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local math_ceil = math.ceil
- local math_floor = math.floor
- local math_random = math.random
- local iconScale = 0.5
- local COMBAT_TITLE = "UI6: BarHPinCombat"
- local LEFT_LABEL = "LT"
- local RIGHT_LABEL = "RT"
- local BARNAME = "UI6: Bar"
- local PLAYER_HPFILL = "UI6: BarHPFill"
- local OVERHEAD = "Overhead"
- local BAR_WIDTH = 128
- local BAR_HEIGHT = 16
- local PREVIOUS_FRIENDLY_ID = 1
- local PREVIOUS_HOSTILE_ID = 1
- local function decimals(number, decimals)
- local power = 10^decimals
- return math_floor(number * power) / power
- end
- --[[
- local function GetCareer()
- local type
- local min
- local max
- -- 102 - WL, 27 - SH, 67 - Mag, 23 - Eng
- if GameData.Player.career.id == 102 or GameData.Player.career.id == 27 or GameData.Player.career.id == 67 or GameData.Player.career.id == 23 then
- type = "pet"
- min = 0
- max = 100
- --BO AND SM
- elseif GameData.Player.career.id == 24 or GameData.Player.career.id == 100 then
- type = "stance"
- min = 1
- max = 3
- -- CHOSEN AND KNIGHT
- elseif GameData.Player.career.id == 64 or GameData.Player.career.id == 61 then
- type = "none"
- min = 0
- max = 0
- -- WH AND WE
- elseif GameData.Player.career.id == 60 or GameData.Player.career.id == 105 then
- type = "combo"
- min = 1
- max = 4
- -- BW AND SORC
- elseif GameData.Player.career.id == 62 or GameData.Player.career.id == 107 then
- type = "combustion"
- min = 1
- max = 4
- -- WARRIOR P AND DOK
- elseif GameData.Player.career.id == 63 or GameData.Player.career.id == 106 then
- type = "prayer"
- min = 1
- max = 4
- -- SHAMMY AND AM
- elseif GameData.Player.career.id == 103 or GameData.Player.career.id == 26 then
- type = "coin"
- min = 1
- max = 4
- -- IB AND BG
- elseif GameData.Player.career.id == 20 or GameData.Player.career.id == 104 then
- type = "hate"
- min = 1
- max = 4
- -- ZEALOT AND RP
- elseif GameData.Player.career.id == 22 or GameData.Player.career.id == 66 then
- type = "dunno"
- min = 1
- max = 4
- -- SLAYER AND CHOP CHOPS
- elseif GameData.Player.career.id == 25 or GameData.Player.career.id == 21 then
- type = "rage"
- min = 1
- max = 4
- -- MAU AND SW
- elseif GameData.Player.career.id == 65 or GameData.Player.career.id == 101 then
- type = "stance"
- min = 1
- max = 4
- else
- d("ERROR: what class?")
- return
- end
- max = CareerResourceData:GetMaximum() or nil
- d(max)
- return type, min, max
- end
- ]]--
- function UI6.registerplayerHUD()
- d("REGISTER")
- UI6.drawplayerHUD() -- <-- can't do some of these things while loading
- RegisterEventHandler(SystemData.Events.PLAYER_CUR_HIT_POINTS_UPDATED, "UI6.updateHP")
- RegisterEventHandler(SystemData.Events.PLAYER_MAX_HIT_POINTS_UPDATED, "UI6.updateHP")
- RegisterEventHandler(SystemData.Events.PLAYER_DEATH, "UI6.updateHP")
- RegisterEventHandler(SystemData.Events.PLAYER_CUR_ACTION_POINTS_UPDATED, "UI6.updateAP")
- RegisterEventHandler(SystemData.Events.PLAYER_MAX_ACTION_POINTS_UPDATED, "UI6.updateAP")
- RegisterEventHandler(SystemData.Events.PLAYER_DEATH, "UI6.updateAP")
- RegisterEventHandler(SystemData.Events.ENTER_WORLD, "UI6.drawIcon")
- RegisterEventHandler(SystemData.Events.INTERFACE_RELOADED, "UI6.drawIcon")
- RegisterEventHandler(SystemData.Events.PLAYER_TARGET_UPDATED, "UI6.targetUpdate")
- if UI6settings["combatIndicator"] == true then
- RegisterEventHandler(SystemData.Events.PLAYER_COMBAT_FLAG_UPDATED, "UI6.combatSymbol")
- end
- UI6.drawTargetbars()
- if GameData.Player.career.id == 102 or GameData.Player.career.id == 27 or GameData.Player.career.id == 67 or GameData.Player.career.id == 23 then
- UI6.drawPetbar()
- --RegisterEventHandler(SystemData.Events.PLAYER_PET_UPDATED, "UI6.updatePetbar")
- --RegisterEventHandler(SystemData.Events.PLAYER_PET_STATE_UPDATED, "UI6.updatePetbar")
- RegisterEventHandler(SystemData.Events.PLAYER_PET_HEALTH_UPDATED, "UI6.updatePetbar")
- UI6.updatePetbar()
- end
- end
- function UI6.getHP()
- local cur = GameData.Player.hitPoints.current
- local max = GameData.Player.hitPoints.maximum
- local percent = math_floor((cur / max) * 1000) /10
- return percent
- end
- function UI6.getAP()
- local cur = GameData.Player.actionPoints.current
- local max = GameData.Player.actionPoints.maximum
- local percent = math_floor((cur / max) * 1000) /10
- return percent
- end
- function UI6.updateHP()
- local targetClassification = "selfHP"
- local targetName = GameData.Player.name
- local careerId = GameData.Player.career.id
- local rank = GameData.Player.rank
- local targetHP = UI6.getHP()
- --local targetAP = UI6.getAP()
- --local guID = GameData.Player.worldObjId
- --local isNPC = false
- local animFlag = false
- local windowName = UI6.getWindowName(targetClassification)
- local cur = GameData.Player.hitPoints.current
- local text = towstring(decimals(cur, 1))..L" ("..towstring(decimals(targetHP, 1))..L"%)"
- UI6.updateBar(targetHP, windowName, targetClassification, targetName, careerId, animFlag)
- UI6.updateText(text, windowName, targetClassification, targetName, careerId, rank)
- end
- function UI6.updateAP()
- local targetClassification = "selfAP"
- local targetName = GameData.Player.name
- local careerId = GameData.Player.career.id
- local rank = GameData.Player.rank
- local targetAP = UI6.getAP()
- local guID = GameData.Player.worldObjId
- local isNPC = false
- local animFlag = false
- local windowName = UI6.getWindowName(targetClassification)
- local cur = GameData.Player.actionPoints.current
- local text = towstring(decimals(cur, 1))..L" ("..towstring(decimals(targetAP, 1))..L"%)"
- UI6.updateBar(targetAP, windowName, targetClassification, targetName, careerId, animFlag)
- UI6.updateText(text, windowName, targetClassification, targetName, careerId, rank)
- end
- function UI6.specialWarning(name, worldObjId)
- --check for a name and trigger a sound/UI element
- local nothing = nil
- end
- function UI6.prevTargetSame(targetClassification, targetId)
- if targetClassification == "selffriendlytarget" then
- if PREVIOUS_FRIENDLY_ID ~= targetId then
- return true
- end
- elseif targetClassification == "selfhostiletarget" then
- if PREVIOUS_HOSTILE_ID ~= targetId then
- return true
- end
- end
- -- oh, it must be you
- return false
- end
- function UI6.setIconAndTint(windowName, careerId)
- local r = UI6.Color(careerId, "icon")
- if r == nil then r = { 135, 135, 135} end
- if careerId == (nil or 0) then
- WindowSetAlpha(windowName.."Icon", 0)
- else
- WindowSetAlpha(windowName.."Icon", 1)
- local tTex, x, y = GetIconData(Icons.GetCareerIconIDFromCareerLine(careerId))
- DynamicImageSetTexture (windowName.."Icon", tTex, x, y)
- WindowSetScale(windowName.."Icon", WindowGetScale(windowName) * iconScale)
- end
- WindowSetTintColor(windowName.."Fill", r[1], r[2], r[3])
- end
- function UI6.getWindowName(targetClassification)
- if targetClassification == "selfHP" then
- return BARNAME.."HP"
- elseif targetClassification == "selfAP" then
- return BARNAME.."AP"
- elseif targetClassification == "selfhostiletarget" then
- return BARNAME.."Hostile"
- elseif targetClassification == "selffriendlytarget" then
- return BARNAME.."Friendly"
- end
- d("error: getWindowName()")
- end
- function UI6.windowAnimateAlpha(windowName)
- if WindowGetAlpha(windowName) < 1 then
- WindowSetScale(windowName, 2)
- WindowStartAlphaAnimation(windowName, Window.AnimationType.SINGLE_NO_RESET, 0, 1, 0.2, false, 0, 0)
- end
- end
- function UI6.setPreviousTarget(targetClassification, guID)
- if targetClassification == "selffriendlytarget" then
- PREVIOUS_FRIENDLY_ID = guID
- elseif targetClassification == "selfhostiletarget" then
- PREVIOUS_HOSTILE_ID = guID
- end
- end
- function UI6.targetUpdate(targetClassification, targetId, targetType)
- if (targetClassification ~= "selffriendlytarget" and targetClassification ~= "selfhostiletarget") then return end
- if (targetType == SystemData.TargetObjectType.NONE) then
- UI6.destroyWindows()
- PREVIOUS_FRIENDLY_ID = nil
- PREVIOUS_HOSTILE_ID = nil
- return
- end
- TargetInfo:UpdateFromClient()
- local targetName = TargetInfo:UnitName(targetClassification)
- local careerId = TargetInfo:UnitCareer(targetClassification)
- local rank = TargetInfo:UnitLevel(targetClassification)
- local targetHP = TargetInfo:UnitHealth(targetClassification)
- local guID = TargetInfo:UnitEntityId(targetClassification)
- local isNPC = TargetInfo:UnitIsNPC(targetClassification)
- local animFlag = UI6.prevTargetSame(targetClassification, targetId)
- local windowName = UI6.getWindowName(targetClassification)
- if targetHP < 100 and WindowGetShowing(windowName.."splitter") == false then
- WindowSetShowing(windowName.."splitter", true)
- end
- UI6.setIconAndTint(windowName, careerId)
- UI6.windowAnimateAlpha(windowName) -- animate the health bar appearing by fading in over 0.2 seconds
- UI6.updateBar(targetHP, windowName, targetClassification, targetName, careerId, animFlag)
- local updateText = targetHP..L"%"
- UI6.updateText(updateText, windowName, targetClassification, targetName, careerId, rank)
- if UI6settings["targetOHUD"] == true then
- UI6.updateoverheadBar(targetHP, TARGETSTRING, guID, targetName)
- --complete incorrect atm, do not use
- end
- if UI6settings["danger"] == true then
- local dangerScore = UI6.dangerSilentCheck(targetName)
- UI6.drawGlow(windowName, dangerScore)
- end
- UI6.setPreviousTarget(targetClassification, guID)
- end
- function UI6.updateBar(targetHP, windowName, targetClassification, targetName, careerId, animFlag)
- --local resize = (cur / max) * HP_BAR_WIDTH
- local THIS_BAR_WIDTH = BAR_WIDTH
- local THIS_BAR_HEIGHT = BAR_HEIGHT
- local resize = (targetHP / 100) * THIS_BAR_WIDTH
- if resize > THIS_BAR_WIDTH then
- resize = THIS_BAR_WIDTH
- elseif resize < 0 then
- resize = 0
- end
- WindowSetDimensions(windowName.."Fill", resize, THIS_BAR_HEIGHT)
- if resize == 0 and targetClassification == "selfHP" then
- -- died, you have zero ap now too.
- WindowSetDimensions("UI6: BarAPFill", resize, THIS_BAR_HEIGHT)
- end
- if animFlag == true then
- WindowSetDimensions(windowName.."anim", resize, THIS_BAR_HEIGHT)
- end
- if UI6settings["danger"] == true and targetName ~= nil then
- local dangerScore = UI6.dangerSilentCheck(targetName)
- UI6.drawGlow(windowName, dangerScore)
- end
- --[[
- --WindowStartAlphaAnimation("UI6: Bar"..type.."BGFlash", Window.AnimationType.SINGLE, 0.2, 0, .9, false, 0, 0)
- ]]--
- end
- function UI6.updateText(targetHP, windowName, targetClassification, targetName, careerId, rank)
- if targetClassification == "selfAP" then
- local text = targetHP
- LabelSetText(windowName.."Text", text)
- LabelSetText(windowName.."TextShadow", text)
- WindowSetScale(windowName.."Text", WindowGetScale(windowName) * iconScale)
- WindowSetScale(windowName.."TextShadow", WindowGetScale(windowName) * iconScale)
- else
- local text = targetName
- LabelSetText(windowName..LEFT_LABEL, text)
- LabelSetText(windowName..LEFT_LABEL.."Shadow", text)
- local text = targetHP
- LabelSetText(windowName..RIGHT_LABEL, text)
- LabelSetText(windowName..RIGHT_LABEL.."Shadow", text)
- WindowSetScale(windowName..LEFT_LABEL, WindowGetScale(windowName) * iconScale)
- WindowSetScale(windowName..LEFT_LABEL.."Shadow", WindowGetScale(windowName) * iconScale)
- WindowSetScale(windowName..RIGHT_LABEL, WindowGetScale(windowName) * iconScale)
- WindowSetScale(windowName..RIGHT_LABEL.."Shadow", WindowGetScale(windowName) * iconScale)
- end
- end
- function UI6.combatSymbol(inCombat)
- if inCombat == true then
- WindowStartAlphaAnimation (COMBAT_TITLE, Window.AnimationType.SINGLE_NO_RESET, 0, 0.6, 0.4, true, 0, 0)
- elseif inCombat == false then
- WindowStartAlphaAnimation (COMBAT_TITLE, Window.AnimationType.SINGLE_NO_RESET, 0.6, 0, 0.25, true, 0, 0)
- end
- end
- function UI6.onRMouseButtonUp()
- if GameData.Player.inCombat == false then
- if SystemData.MouseOverWindow.name == "UI6: BarHP-Button" then
- PlayerMenuWindow.ShowMenu(GameData.Player.name)
- elseif SystemData.MouseOverWindow.name == "UI6: BarFriendly-Button" then
- PlayerMenuWindow.ShowMenu(TargetInfo:UnitName("selffriendlytarget"))
- elseif SystemData.MouseOverWindow.name == "UI6: BarHostile-Button" then
- --PlayerMenuWindow.ShowMenu(TargetInfo:UnitName("selfhostiletarget"))
- --/slit if alive
- --/salute if dead
- local targetHP = TargetInfo:UnitHealth("selfhostiletarget")
- if targetHP == 0 then
- SendChatText(towstring("/salute"), L"")
- else
- SendChatText(towstring("/slit"), L"")
- end
- end
- end
- end
- function UI6.onLMouseButtonUp()
- local activeWindow = SystemData.MouseOverWindow.name
- local target
- if activeWindow == "UI6: BarFriendly-Button" then
- target = TargetInfo:UnitName("selffriendlytarget") or nil
- elseif activeWindow == "UI6: BarHP-Button" then
- target = GameData.Player.name
- elseif activeWindow == "UI6: BarHostile-Button" then
- target = TargetInfo:UnitName("selfhostiletarget") or nil
- elseif activeWindow == "UI6: BarPet-Button" then
- target = GameData.Player.Pet.name or nil
- end
- WindowSetGameActionData(activeWindow, GameData.PlayerActions.SET_TARGET, 0, target)
- end
- function UI6.drawPetbar()
- CreateWindowFromTemplate(BARNAME.."Pet", "UI6: BarPet", "Root")
- LayoutEditor.RegisterWindow(BARNAME.."Pet", towstring(BARNAME)..L"Pet", towstring(BARNAME)..L"Pet", false, false, false, nil)
- WindowSetDimensions(BARNAME.."Pet", 128, 16)
- WindowSetAlpha(BARNAME.."Pet", 1)
- WindowSetScale(BARNAME.."Pet", 1.25)
- WindowSetTintColor(BARNAME.."PetFill", barColors["GREEN"][1],barColors["GREEN"][2],barColors["GREEN"][3])
- WindowSetTintColor(BARNAME.."Petanim", barColors["GRAY"][1],barColors["GRAY"][2],barColors["GRAY"][3])
- WindowSetTintColor(BARNAME.."PetBG", barColors["BLACK"][1],barColors["BLACK"][2],barColors["BLACK"][3])
- end
- function UI6.updatePetbar()
- local targetHP = GameData.Player.Pet.healthPercent
- local windowName = BARNAME.."Pet"
- local targetClassification = "selfAP"
- local animFlag = false
- local targetName, careerId, rank = nil
- UI6.updateBar(targetHP, windowName, targetClassification, targetName, careerId, animFlag)
- local updateText = targetHP..L"%"
- UI6.updateText(updateText, windowName, targetClassification, targetName, careerId, rank)
- end
- function UI6.drawMechanic()
- local type, max, min = GetCareer()
- end
- function UI6.destroyWindows()
- WindowSetAlpha(BARNAME.."Friendly", 0)
- LabelSetText(BARNAME.."Friendly"..LEFT_LABEL, L"")
- LabelSetText(BARNAME.."Friendly"..LEFT_LABEL.."Shadow", L"")
- LabelSetText(BARNAME.."Friendly"..RIGHT_LABEL, L"")
- LabelSetText(BARNAME.."Friendly"..RIGHT_LABEL.."Shadow", L"")
- WindowSetAlpha(BARNAME.."Hostile", 0)
- LabelSetText(BARNAME.."Hostile"..LEFT_LABEL, L"")
- LabelSetText(BARNAME.."Hostile"..LEFT_LABEL.."Shadow", L"")
- LabelSetText(BARNAME.."Hostile"..RIGHT_LABEL, L"")
- LabelSetText(BARNAME.."Hostile"..RIGHT_LABEL.."Shadow", L"")
- if UI6settings["targetOHUD"] == true then
- WindowSetAlpha(BARNAME..OVERHEAD.."Friendly", 0)
- WindowSetAlpha(BARNAME..OVERHEAD.."Hostile", 0)
- DetachWindowFromWorldObject(BARNAME..OVERHEAD.."Friendly", PREVIOUS_FRIENDLY_ID)
- DetachWindowFromWorldObject(BARNAME..OVERHEAD.."Hostile", PREVIOUS_HOSTILE_ID)
- end
- end
- function UI6.drawTargetbars()
- CreateWindowFromTemplate(BARNAME.."Friendly", "UI6: BarFriendly", "Root")
- CreateWindowFromTemplate(BARNAME.."Hostile", "UI6: BarHostile", "Root")
- LayoutEditor.RegisterWindow(BARNAME.."Friendly", towstring(BARNAME)..L"Friendly", towstring(BARNAME)..L"Friendly", false, false, false, nil)
- LayoutEditor.RegisterWindow(BARNAME.."Hostile", towstring(BARNAME)..L"Hostile", towstring(BARNAME)..L"Hostile", false, false, false, nil)
- WindowSetDimensions(BARNAME.."Friendly", 128, 16)
- WindowSetDimensions(BARNAME.."Hostile", 128, 16)
- WindowSetAlpha(BARNAME.."Friendly", 0)
- WindowSetAlpha(BARNAME.."Hostile", 0)
- WindowSetScale(BARNAME.."Friendly", 2)
- WindowSetScale(BARNAME.."Hostile", 2)
- WindowSetTintColor(BARNAME.."FriendlyBG", barColors["BLACK"][1],barColors["BLACK"][2],barColors["BLACK"][3])
- WindowSetTintColor(BARNAME.."HostileBG", barColors["BLACK"][1],barColors["BLACK"][2],barColors["BLACK"][3])
- if UI6settings["targetOHUD"] == true then
- CreateWindowFromTemplate(BARNAME..OVERHEAD.."Friendly", BARNAME..OVERHEAD, "Root")
- CreateWindowFromTemplate(BARNAME..OVERHEAD.."Hostile", BARNAME..OVERHEAD, "Root")
- WindowSetAlpha(BARNAME..OVERHEAD.."Friendly", 1)
- WindowSetAlpha(BARNAME..OVERHEAD.."Hostile", 1)
- end
- end
- function UI6.drawplayerHUD()
- d("DRAW FRAME NOW")
- CreateWindow("UI6: BarHP", true)
- CreateWindow("UI6: BarAP", true)
- WindowSetScale("UI6: BarAP", 2)
- WindowSetScale("UI6: BarHP", 2)
- WindowSetTintColor( "UI6: BarHPFill", barColors["GREEN"][1],barColors["GREEN"][2],barColors["GREEN"][3])
- WindowSetTintColor( "UI6: BarHPanim", barColors["GRAY"][1],barColors["GRAY"][2],barColors["GRAY"][3])
- WindowSetTintColor( "UI6: BarHPBG", barColors["BLACK"][1],barColors["BLACK"][2],barColors["BLACK"][3])
- WindowSetTintColor( "UI6: BarAPFill", barColors["GOLD"][1],barColors["GOLD"][2],barColors["GOLD"][3])
- WindowSetTintColor( "UI6: BarAPanim", barColors["GRAY"][1],barColors["GRAY"][2],barColors["GRAY"][3]) -- could use the old color
- WindowSetTintColor( "UI6: BarAPBG", barColors["BLACK"][1],barColors["BLACK"][2],barColors["BLACK"][3])-- and -75
- LayoutEditor.RegisterWindow("UI6: BarHP", L"UI6: BarHP", L"UI6: BarHP", false, false, false, nil)
- LayoutEditor.RegisterWindow("UI6: BarAP", L"UI6: BarAP", L"UI6: BarAP", false, false, false, nil)
- WindowSetDimensions("UI6: BarHP", 128, 16)
- WindowSetDimensions("UI6: BarAP", 128, 16)
- UI6.updateHP()
- UI6.updateAP()
- --UI6.drawIcon()
- end
- function UI6.drawIcon()
- if DoesWindowExist("UI6: BarHPIcon") ~= true then return end
- local tTex, x, y = GetIconData(Icons.GetCareerIconIDFromCareerLine(GameData.Player.career.line))
- GetIconData(Icons.GetCareerIconIDFromCareerLine(GameData.Player.career.line))
- DynamicImageSetTexture ("UI6: BarHPIcon", tTex, x, y)
- WindowSetScale("UI6: BarHPIcon", WindowGetScale("UI6: BarHP") * iconScale)
- local r = UI6.Color(GameData.Player.career.line, "icon")
- WindowSetTintColor(PLAYER_HPFILL, r[1], r[2], r[3])
- UI6.updateHP()
- UI6.updateAP()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement